discounts.blade.php 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281
  1. @extends('layouts.app')
  2. @section('page-title')| {{__('label.discounts')}} @endsection
  3. @section('css')
  4. <link href="{!! env('APP_ASSETS') !!}css/discounts.css" rel="stylesheet" type="text/css">
  5. @endsection
  6. @php
  7. $resto = \App\Models\Restaurants::find(\App\Helpers\CommonMethods::getRestuarantID());
  8. $lang = $resto->default_lang;
  9. app()->setLocale($lang);
  10. if(session('app_lang') !==null){
  11. $lang = session('app_lang');
  12. app()->setLocale($lang);
  13. }
  14. @endphp
  15. @section('content')
  16. <style>
  17. @-webkit-keyframes special {
  18. from { background-color: rgba(255, 121, 77, 0.27); }
  19. to { background-color: inherit; }
  20. }
  21. @-moz-keyframes special {
  22. from { background-color: rgba(255, 121, 77, 0.27);; }
  23. to { background-color: inherit; }
  24. }
  25. @-o-keyframes special {
  26. from { background-color: rgba(255, 121, 77, 0.27);; }
  27. to { background-color: inherit; }
  28. }
  29. @keyframes special {
  30. from { background-color: rgba(255, 121, 77, 0.27);; }
  31. to { background-color: inherit; }
  32. }
  33. .special {
  34. -webkit-animation: special 1s infinite; /* Safari 4+ */
  35. -moz-animation: special 1s infinite; /* Fx 5+ */
  36. -o-animation: special 1s infinite; /* Opera 12+ */
  37. animation: special 1s infinite; /* IE 10+ */
  38. }
  39. .btn-toggle.btn-sm,.btn-toggle.btn-sm > .handle{
  40. border-radius: 16px;
  41. }
  42. </style>
  43. <!-- Content Wrapper. Contains page content -->
  44. <div class="content-wrapper">
  45. <div class="container-full">
  46. <!-- Main content -->
  47. <section class="content">
  48. <div class="row ">
  49. <div class="col-md-6">
  50. <div class="m-15">
  51. <h3 class="title">{{__('label.discounts')}}</h3>
  52. </div>
  53. </div>
  54. @php
  55. $resto = \App\Models\Restaurants::find(\App\Helpers\CommonMethods::getRestuarantID());
  56. $discounts = \App\Models\Discounts::where('resto_id',\App\Helpers\CommonMethods::getRestuarantID())->whereNull('deleted_at')->orderBy('created_at','DESC')->get();
  57. @endphp
  58. @php
  59. $restuarant1 = $resto;
  60. $resto_meta = isset($restuarant1->resto_metas)?$restuarant1->resto_metas:null;
  61. //dump($resto_meta);
  62. $resto_metas = [];
  63. $billing = [];
  64. if(isset($resto_meta)){
  65. foreach($resto_meta as $meta){
  66. $index_name = isset($meta->resto_meta_defs->parents)?$meta->resto_meta_defs->parents->meta_def_name:$meta->resto_meta_defs->meta_def_name;
  67. // dump($meta->resto_meta_defs);
  68. if($index_name=="BILLING_GATEWAY"){
  69. // dump($meta->resto_meta_defs->meta_def_name);
  70. // $resto_metas['BILLING_GATEWAY'][] = $meta->meta_val;
  71. $billing[] = array('id'=>$meta->meta_id,'value'=>$meta->meta_val);
  72. }
  73. $resto_metas[$index_name] = $meta->meta_val;
  74. }
  75. }
  76. $resto_metas['BILLING_GATEWAY'] = $billing;
  77. $currency = isset($resto_metas['BUSSINESS_CCY'])?$resto_metas['BUSSINESS_CCY']:"IQD";
  78. $business_type = isset($resto_metas['BUSSINESS_TYPE'])?$resto_metas['BUSSINESS_TYPE']:"Restaurants";
  79. @endphp
  80. <div class="col-md-5">
  81. <a style="width: 200px" href="{!! env('APP_URL') !!}business/{!! $resto->unique_shared_key !!}/new/discount" class="form-control btn btn-primary btn-md add-discount text-center">
  82. <i class="fa fa-plus mr-2"></i>
  83. <!-- <i class="mdi mdi-plus-circle"></i> --> {{__('label.add_discount')}}
  84. </a>
  85. </div>
  86. </div>
  87. <div class="row">
  88. <div class="col-12 mt-4">
  89. <div class="table-responsive">
  90. <table class="table table-striped" id="discount-table">
  91. <thead>
  92. <tr>
  93. <th scope="col">{{__('label.status')}}</th>
  94. <th scope="col">{{__('label.discount_code')}}</th>
  95. <th scope="col">{{__('label.discount_name')}}</th>
  96. <th scope="col">{{__('label.application')}}</th>
  97. <th scope="col">{{__('label.type')}}</th>
  98. <th scope="col">{{__('label.min_basket')}}</th>
  99. <th scope="col">{{__('label.max_discount')}}</th>
  100. <th scope="col">{{__('label.availability')}}</th>
  101. <th></th>
  102. </tr>
  103. </thead>
  104. <tbody>
  105. @if(isset($discounts) && $discounts->count() > 0)
  106. @foreach($discounts as $discount)
  107. <tr>
  108. <td>
  109. <button type="button" data-on-text="Open" data-off-text="Closed" class="btn btn-toggle btn-sm btn-success @if($discount->is_active=="1") active @endif switch-me" data-id="{!! $discount->unique_key !!}" data-bs-toggle="button" aria-pressed="@if($discount->is_active=="1") true @else false @endif" autocomplete="off">
  110. <div class="handle"></div>
  111. </button>
  112. </td>
  113. <td>
  114. {!! $discount->discount_code !!}
  115. </td>
  116. <td>
  117. {!! $discount->discount_name !!}
  118. </td>
  119. <td>{!! $discount->application_type !!}</td>
  120. <td>{!! ucwords($discount->order_type) !!}</td>
  121. <td>{!! $discount->minimum_order_value !!}</td>
  122. <td>{!! $discount->maximum_discount !!}</td>
  123. <td>{!! date('d, M Y',strtotime($discount->start_date)).' '.$discount->start_time !!} @if($discount->expire_on_date=="never_expire") - Never Expire @else - {!! date('d, M Y',strtotime($discount->end_date)).' '.$discount->end_time !!} @endif</td>
  124. <td>
  125. <a type="button" href="{!! env('APP_URL') !!}discount/{!! $discount->unique_key !!}" data-id="{!! $discount->unique_key !!}" class="waves-effect waves-circle btn btn-circle btn-primary btn-xs mb-5">
  126. <i class="mdi mdi-pencil"></i></a>
  127. </td>
  128. </tr>
  129. @endforeach
  130. @endif
  131. </tbody>
  132. </table>
  133. </div>
  134. </div>
  135. </div>
  136. </section>
  137. <!-- /.content -->
  138. </div>
  139. </div>
  140. <!-- /.content-wrapper -->
  141. @endsection
  142. @section('js')
  143. <script>
  144. $(function () {
  145. $("body").on("click",".switch-me",function (e) {
  146. var is_active = $(this).attr("aria-pressed");
  147. var id = $(this).data('id');
  148. is_active = $.trim(is_active);
  149. var status = 0;
  150. if(is_active=="false"){
  151. status = 0;
  152. }else{
  153. status = 1;
  154. }
  155. $.ajax({
  156. url:"{!! env('APP_URL') !!}discount/update/status",
  157. type:"POST",
  158. data:{
  159. id:id,
  160. status:status,
  161. "_token":'{!! csrf_token() !!}'
  162. },
  163. success:function () {
  164. if(is_active=="false"){
  165. $.toast({
  166. heading: "{{__('label.discount_status')}}",
  167. text: "{{__('label.discount_deactive')}}",
  168. position: 'top-right',
  169. loaderBg: '#ff6849',
  170. icon: 'error',
  171. hideAfter: 3000,
  172. stack: 1
  173. });
  174. }else{
  175. $.toast({
  176. heading: "{{__('label.discount_status')}}",
  177. text: "{{__('label.discount_deactive')}}",
  178. position: 'top-right',
  179. loaderBg: '#ff6849',
  180. icon: 'success',
  181. hideAfter: 3000,
  182. stack: 1
  183. });
  184. }
  185. }
  186. });
  187. e.preventDefault();
  188. e.stopPropagation();
  189. });
  190. $('.table').DataTable({
  191. paging: true,
  192. bLengthChange:false,
  193. searching: true,
  194. "bSort": true,
  195. "aaSorting": [[7,'desc']],
  196. language: {
  197. @if($lang=='ar')
  198. url:`{{asset('public/assets/js/dataTablear.json')}}`,
  199. @endif
  200. },
  201. });
  202. $("body").on("click",".delete-discount",function(e){
  203. var id = $(this).data('id');
  204. var _this = $(this);
  205. swal({
  206. title: " Confirm?",
  207. text: "Do you want delete?",
  208. type: "error",
  209. showCancelButton: true,
  210. confirmButtonClass: "btn-danger",
  211. confirmButtonText: " Confirm, delete it!",
  212. cancelButtonText: "No, cancel please!",
  213. closeOnConfirm: true,
  214. closeOnCancel: true
  215. },
  216. function(isConfirm) {
  217. if (isConfirm) {
  218. $.ajax({
  219. url:"{!! env('APP_URL') !!}delete/discount/"+id,
  220. success:function(){
  221. _this.parent('tr').remove();
  222. }
  223. });
  224. }
  225. });
  226. e.preventDefault();
  227. e.stopPropagation();
  228. });
  229. {{--$("body").on("click","#discount-table tr",function(){--}}
  230. {{-- var id = $(this).data('id');--}}
  231. {{-- window.location = "{!! env('APP_URL') !!}discount/"+id;--}}
  232. {{--});--}}
  233. })
  234. </script>
  235. @endsection