You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

266 lines
15 KiB

1 year ago
@extends('layouts.vendor.app')
@section('title','Add new coupon')
@push('css_or_js')
@endpush
@section('content')
<div class="content container-fluid">
<!-- Page Header -->
<div class="page-header">
<div class="row align-items-center">
<div class="col-sm mb-2 mb-sm-0">
<h1 class="page-header-title"><i class="tio-add-circle-outlined"></i> {{translate('messages.add')}} {{translate('messages.new')}} {{translate('messages.coupon')}}</h1>
</div>
</div>
</div>
<!-- End Page Header -->
<div class="row gx-2 gx-lg-3">
<div class="col-sm-12 col-lg-12 mb-3 mb-lg-2">
<form action="{{route('vendor.coupon.store')}}" method="post">
@csrf
<div class="row">
<div class="col-4">
<div class="form-group">
<label class="input-label" for="exampleFormControlInput1">{{translate('messages.title')}}</label>
<input type="text" name="title" class="form-control" placeholder="{{translate('messages.new_coupon')}}" required>
</div>
</div>
<div class="col-4">
<div class="form-group">
<label class="input-label" for="exampleFormControlInput1">{{translate('messages.coupon')}} {{translate('messages.type')}}</label>
<select name="coupon_type" class="form-control" onchange="coupon_type_change(this.value)">
<option value="default">{{translate('messages.default')}}</option>
<option value="first_order">{{translate('messages.first')}} {{translate('messages.order')}}</option>
</select>
</div>
</div>
<div class="col-4" id="limit-for-user">
<div class="form-group">
<label class="input-label" for="exampleFormControlInput1">{{translate('messages.limit')}} {{translate('messages.for')}} {{translate('messages.same')}} {{translate('messages.user')}}</label>
<input type="number" name="limit" class="form-control" placeholder="{{ translate('messages.Ex :') }} 10">
</div>
</div>
</div>
<div class="row">
<div class="col-md-4 col-6">
<div class="form-group">
<label class="input-label" for="exampleFormControlInput1">{{translate('messages.code')}}</label>
<input type="text" name="code" class="form-control"
placeholder="{{\Illuminate\Support\Str::random(8)}}" required>
</div>
</div>
<div class="col-md-4 col-6">
<div class="form-group">
<label class="input-label" for="exampleFormControlInput1">{{translate('messages.start')}} {{translate('messages.date')}}</label>
<input type="date" name="start_date" class="form-control" required>
</div>
</div>
<div class="col-md-4 col-6">
<div class="form-group">
<label class="input-label" for="exampleFormControlInput1">{{translate('messages.expire')}} {{translate('messages.date')}}</label>
<input type="date" name="expire_date" class="form-control" required>
</div>
</div>
</div>
<div class="row">
<div class="col-md-3 col-6">
<div class="form-group">
<label class="input-label" for="exampleFormControlInput1">{{translate('messages.min')}} {{translate('messages.purchase')}}</label>
<input type="number" step="0.01" name="min_purchase" value="0" min="0" max="100000" class="form-control"
placeholder="100">
</div>
</div>
<div class="col-md-3 col-6">
<div class="form-group">
<label class="input-label" for="exampleFormControlInput1">{{translate('messages.max')}} {{translate('messages.discount')}}</label>
<input type="number" step="0.01" min="0" value="0" max="1000000" name="max_discount" class="form-control">
</div>
</div>
<div class="col-md-4 col-6">
<div class="form-group">
<label class="input-label" for="exampleFormControlInput1">{{translate('messages.discount')}}</label>
<input type="number" step="0.01" min="1" max="10000" name="discount" class="form-control" required>
</div>
</div>
<div class="col-md-2 col-6">
<div class="form-group">
<label class="input-label" for="exampleFormControlInput1">{{translate('messages.discount')}} {{translate('messages.type')}}</label>
<select name="discount_type" class="form-control">
<option value="amount">{{translate('messages.amount')}}</option>
<option value="percent">{{translate('messages.percent')}}</option>
</select>
</div>
</div>
</div>
<button type="submit" class="btn btn-primary">{{translate('messages.submit')}}</button>
</form>
</div>
<div class="col-sm-12 col-lg-12 mb-3 mb-lg-2">
<hr>
<div class="card">
<div class="card-header">
<h5 class="card-header-title"></h5>
</div>
<!-- Table -->
<div class="table-responsive datatable-custom">
<table id="columnSearchDatatable"
class="table table-borderless table-thead-bordered table-nowrap table-align-middle card-table"
data-hs-datatables-options='{
"order": [],
"orderCellsTop": true,
"paging":false
}'>
<thead class="thead-light">
<tr>
<th>{{translate('messages.#')}}</th>
<th>{{translate('messages.title')}}</th>
<th>{{translate('messages.code')}}</th>
<th>{{translate('messages.min')}} {{translate('messages.purchase')}}</th>
<th>{{translate('messages.max')}} {{translate('messages.discount')}}</th>
<th>{{translate('messages.discount')}}</th>
<th>{{translate('messages.discount')}} {{translate('messages.type')}}</th>
<th>{{translate('messages.start')}} {{translate('messages.date')}}</th>
<th>{{translate('messages.expire')}} {{translate('messages.date')}}</th>
<th>{{translate('messages.status')}}</th>
<th>{{translate('messages.action')}}</th>
</tr>
<tr>
<th></th>
<th>
<input type="text" id="column1_search" class="form-control form-control-sm"
placeholder="{{translate('messages.search')}}">
</th>
<th></th>
<th></th>
<th></th>
<th></th>
<th></th>
<th></th>
<th></th>
<th>
{{--<select id="column3_search" class="js-select2-custom"
data-hs-select2-options='{
"minimumResultsForSearch": "Infinity",
"customClass": "custom-select custom-select-sm text-capitalize"
}'>
<option value="">Any</option>
<option value="Active">Active</option>
<option value="Disabled">Disabled</option>
</select>--}}
</th>
<th></th>
</tr>
</thead>
<tbody>
@foreach($coupons as $key=>$coupon)
<tr>
<td>{{$key+1}}</td>
<td>
<span class="d-block font-size-sm text-body">
{{$coupon['title']}}
</span>
</td>
<td>{{$coupon['code']}}</td>
<td>{{\App\CentralLogics\Helpers::format_currency($coupon['min_purchase'])}}</td>
<td>{{\App\CentralLogics\Helpers::format_currency($coupon['max_discount'])}}</td>
<td>{{$coupon['discount']}}</td>
<td>{{$coupon['discount_type']}}</td>
<td>{{$coupon['start_date']}}</td>
<td>{{$coupon['expire_date']}}</td>
<td>
@if($coupon['status']==1)
<div class="initial-76" onclick="location.href='{{route('vendor.coupon.status',[$coupon['id'],0])}}'">
<span class="legend-indicator bg-success"></span>{{translate('messages.active')}}
</div>
@else
<div class="initial-76" onclick="location.href='{{route('vendor.coupon.status',[$coupon['id'],1])}}'">
<span class="legend-indicator bg-danger"></span>{{translate('messages.disabled')}}
</div>
@endif
</td>
<td>
<!-- Dropdown -->
<div class="dropdown">
<button class="btn btn-secondary dropdown-toggle" type="button"
id="dropdownMenuButton" data-toggle="dropdown" aria-haspopup="true"
aria-expanded="false">
<i class="tio-settings"></i>
</button>
<div class="dropdown-menu" aria-labelledby="dropdownMenuButton">
<a class="dropdown-item"
href="{{route('vendor.coupon.update',[$coupon['id']])}}">{{translate('messages.edit')}}</a>
<a class="dropdown-item" href="javascript:"
onclick="form_alert('coupon-{{$coupon['id']}}','Want to delete this coupon ?')">{{translate('messages.delete')}}</a>
<form action="{{route('vendor.coupon.delete',[$coupon['id']])}}"
method="post" id="coupon-{{$coupon['id']}}">
@csrf @method('delete')
</form>
</div>
</div>
<!-- End Dropdown -->
</td>
</tr>
@endforeach
</tbody>
</table>
<hr>
<table>
<tfoot>
{!! $coupons->links() !!}
</tfoot>
</table>
</div>
</div>
</div>
<!-- End Table -->
</div>
</div>
@endsection
@push('script_2')
<script>
$(document).on('ready', function () {
// INITIALIZATION OF DATATABLES
// =======================================================
var datatable = $.HSCore.components.HSDatatables.init($('#columnSearchDatatable'));
$('#column1_search').on('keyup', function () {
datatable
.columns(1)
.search(this.value)
.draw();
});
$('#column3_search').on('change', function () {
datatable
.columns(9)
.search(this.value)
.draw();
});
// INITIALIZATION OF SELECT2
// =======================================================
$('.js-select2-custom').each(function () {
var select2 = $.HSCore.components.HSSelect2.init($(this));
});
});
function coupon_type_change(order_type) {
if(order_type=='first_order'){
$('#limit-for-user').hide();
}else{
$('#limit-for-user').show();
}
}
</script>
@endpush