-
-
Notifications
You must be signed in to change notification settings - Fork 549
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
8b162e6
commit 6857a9b
Showing
8 changed files
with
339 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
<?php | ||
/** | ||
* Mage2 | ||
* | ||
* NOTICE OF LICENSE | ||
* | ||
* This source file is subject to the GNU General Public License v3.0 | ||
* that is bundled with this package in the file LICENSE.txt. | ||
* It is also available through the world-wide-web at this URL: | ||
* https://www.gnu.org/licenses/gpl-3.0.en.html | ||
* If you did not receive a copy of the license and are unable to | ||
* obtain it through the world-wide-web, please send an email | ||
* to [email protected] so we can send you a copy immediately. | ||
* | ||
* DISCLAIMER | ||
* | ||
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer | ||
* versions in the future. If you wish to customize PrestaShop for your | ||
* needs please refer to http://mage2.website for more information. | ||
* | ||
* @author Purvesh <[email protected]> | ||
* @copyright 2016-2017 Mage2 | ||
* @license https://www.gnu.org/licenses/gpl-3.0.en.html GNU General Public License v3.0 | ||
*/ | ||
namespace Mage2\Sale\Models; | ||
|
||
use Carbon\Carbon; | ||
use Mage2\Framework\System\Models\BaseModel; | ||
|
||
class GiftCoupon extends BaseModel | ||
{ | ||
protected $fillable = [ 'title', 'code', 'start_date','end_date','status']; | ||
|
||
protected $dates = ['start_date','end_date','created_at','updated_at']; | ||
|
||
public function getStartDateAttribute($val , $format = true) { | ||
$value = Carbon::createFromTimestamp(strtotime($val)); | ||
|
||
if(true === $format) { | ||
return $value->format('d-M-Y'); | ||
} | ||
|
||
return $value; | ||
} | ||
|
||
public function setStartDateAttribute($val) { | ||
$value = Carbon::createFromTimestamp(strtotime($val)); | ||
$this->attributes['start_date'] = $value->toDateString(); | ||
} | ||
|
||
public function getEndDateAttribute($val , $format = true) { | ||
$value = Carbon::createFromTimestamp(strtotime($val)); | ||
|
||
if(true === $format) { | ||
return $value->format('d-M-Y'); | ||
} | ||
|
||
return $value; | ||
} | ||
|
||
public function setEndDateAttribute($val) { | ||
$value = Carbon::createFromTimestamp(strtotime($val)); | ||
$this->attributes['end_date'] = $value->toDateString(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
<?php | ||
/** | ||
* Mage2 | ||
* | ||
* NOTICE OF LICENSE | ||
* | ||
* This source file is subject to the GNU General Public License v3.0 | ||
* that is bundled with this package in the file LICENSE.txt. | ||
* It is also available through the world-wide-web at this URL: | ||
* https://www.gnu.org/licenses/gpl-3.0.en.html | ||
* If you did not receive a copy of the license and are unable to | ||
* obtain it through the world-wide-web, please send an email | ||
* to [email protected] so we can send you a copy immediately. | ||
* | ||
* DISCLAIMER | ||
* | ||
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer | ||
* versions in the future. If you wish to customize PrestaShop for your | ||
* needs please refer to http://mage2.website for more information. | ||
* | ||
* @author Purvesh <[email protected]> | ||
* @copyright 2016-2017 Mage2 | ||
* @license https://www.gnu.org/licenses/gpl-3.0.en.html GNU General Public License v3.0 | ||
*/ | ||
namespace Mage2\Sale\Requests; | ||
|
||
use Illuminate\Foundation\Http\FormRequest as Request; | ||
|
||
class GiftCouponRequest extends Request | ||
{ | ||
/** | ||
* Determine if the user is authorized to make this request. | ||
* | ||
* @return bool | ||
*/ | ||
public function authorize() | ||
{ | ||
return true; | ||
} | ||
|
||
/** | ||
* Get the validation rules that apply to the request. | ||
* | ||
* @return array | ||
*/ | ||
public function rules() | ||
{ | ||
$validationRule = []; | ||
|
||
$validationRule['title'] = 'required|max:255'; | ||
$validationRule['code'] = 'required|max:255'; | ||
|
||
|
||
return $validationRule; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 7 additions & 0 deletions
7
modules/base/Mage2/Sale/views/admin/gift-coupon/_fields.blade.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
|
||
{!! Form::text('title','Title',['autofocus'=>true,'class' => 'form-control']) !!} | ||
{!! Form::text('code','Code') !!} | ||
{!! Form::text('start_date','Start Date') !!} | ||
{!! Form::text('end_date','End Date') !!} | ||
{!! Form::select('status','Status',['ENABLED' => 'Enabled','DISABLED' => 'Disabled']) !!} | ||
|
24 changes: 24 additions & 0 deletions
24
modules/base/Mage2/Sale/views/admin/gift-coupon/create.blade.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
@extends('layouts.admin') | ||
|
||
|
||
@section('content') | ||
<div class="row"> | ||
<div class="col-md-12"> | ||
<div class="panel panel-default"> | ||
<div class="panel-heading">Create Gift Coupon</div> | ||
<div class="panel-body"> | ||
|
||
{!! Form::open(['action' => route('admin.gift-coupon.store'),'method' => 'POST']) !!} | ||
@include('mage2sale::admin.gift-coupon._fields') | ||
|
||
<div class="input-field"> | ||
{!! Form::submit("Create Gift Coupon",['class' => 'btn btn-primary']) !!} | ||
{!! Form::button("cancel",['class' => 'btn disabled','onclick' => 'location="' . route('admin.gift-coupon.index'). '"']) !!} | ||
</div> | ||
|
||
{!! Form::close() !!} | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
@endsection |
27 changes: 27 additions & 0 deletions
27
modules/base/Mage2/Sale/views/admin/gift-coupon/edit.blade.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
@extends('layouts.admin') | ||
|
||
@section('content') | ||
<div class="row"> | ||
<div class="col-md-12"> | ||
|
||
<div class="panel-default panel"> | ||
<div class="panel-heading"> | ||
|
||
Edit Gift Coupon | ||
<!--<small>Sub title</small> --> | ||
|
||
</div> | ||
<div class="panel-body"> | ||
|
||
{!! Form::bind($giftCoupon, ['method' => 'PUT', 'action' => route('admin.gift-coupon.update', $giftCoupon->id)]) !!} | ||
@include('mage2sale::admin.gift-coupon._fields') | ||
|
||
{!! Form::submit("Update Gift Coupon",['class' => 'btn btn-primary']) !!} | ||
{!! Form::button("cancel",['class' => 'btn disabled','onclick' => 'location="' . route('admin.gift-coupon.index'). '"']) !!} | ||
{!! Form::close() !!} | ||
</div> | ||
</div> | ||
|
||
</div> | ||
</div> | ||
@endsection |
62 changes: 62 additions & 0 deletions
62
modules/base/Mage2/Sale/views/admin/gift-coupon/index.blade.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
@extends('layouts.admin') | ||
|
||
@section('content') | ||
<div class="container"> | ||
<h1> | ||
<span class="main-title-wrap">Gift Coupon List</span> | ||
<a style="" href="{{ route('admin.gift-coupon.create') }}" class="btn btn-primary pull-right">Create | ||
Gift Coupon</a> | ||
</h1> | ||
|
||
<table class="table table-bordered" id="gift-coupon-table"> | ||
<thead> | ||
<tr> | ||
<th>Id</th> | ||
<th>Title</th> | ||
|
||
<th>Edit</th> | ||
<th>Destroy</th> | ||
</tr> | ||
</thead> | ||
</table> | ||
</div> | ||
@stop | ||
|
||
@push('scripts') | ||
<script> | ||
$(function () { | ||
$('#gift-coupon-table').DataTable({ | ||
processing: true, | ||
searching: false, | ||
serverSide: true, | ||
ajax: '{!! route('admin.sale.gift-coupon.data-grid-table.get-data') !!}', | ||
columns: [ | ||
{data: 'id', name: 'id'}, | ||
{data: 'title', name: 'title'}, | ||
{ | ||
data: 'edit', | ||
name: 'edit', | ||
sortable: false, | ||
render: function (data, type, object, meta) { | ||
return '<a href="/admin/sale/gift-coupon/'+ object.id +'/edit">Edit</a>'; | ||
} | ||
}, | ||
{ | ||
data: 'destroy', | ||
name: 'destroy', | ||
sortable: false, | ||
render: function (data, type, object, meta) { | ||
return '<form id="admin-gift-coupon-destroy-'+object.id+'" method="post" action="/admin/sale/gift-coupon/'+object.id+'" >' + | ||
'<input type="hidden" name="_method" value="DELETE"/>' + | ||
'<input type="hidden" name="_token" value="{{ csrf_token() }}"/>' + | ||
'</form>' + | ||
'<a onclick="event.preventDefault();jQuery(\'#admin-gift-coupon-destroy-'+object.id+'\').submit()"' + | ||
'href="/admin/sale/gift-coupon/'+object.id+'">Destroy' + | ||
'</a>'; | ||
} | ||
} | ||
] | ||
}); | ||
}); | ||
</script> | ||
@endpush |