discounts.blade.php 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272
  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. $discounts = \App\Models\Discounts::where('resto_id',\App\Helpers\CommonMethods::getRestuarantID())->whereNull('deleted_at')->orderBy('created_at','DESC')->get();
  56. @endphp
  57. @php
  58. $restuarant1 = $resto;
  59. $resto_meta = isset($restuarant1->resto_metas)?$restuarant1->resto_metas:null;
  60. //dump($resto_meta);
  61. $resto_metas = [];
  62. $billing = [];
  63. if(isset($resto_meta)){
  64. foreach($resto_meta as $meta){
  65. $index_name = isset($meta->resto_meta_defs->parents)?$meta->resto_meta_defs->parents->meta_def_name:$meta->resto_meta_defs->meta_def_name;
  66. // dump($meta->resto_meta_defs);
  67. if($index_name=="BILLING_GATEWAY"){
  68. // dump($meta->resto_meta_defs->meta_def_name);
  69. // $resto_metas['BILLING_GATEWAY'][] = $meta->meta_val;
  70. $billing[] = array('id'=>$meta->meta_id,'value'=>$meta->meta_val);
  71. }
  72. $resto_metas[$index_name] = $meta->meta_val;
  73. }
  74. }
  75. $resto_metas['BILLING_GATEWAY'] = $billing;
  76. $currency = isset($resto_metas['BUSSINESS_CCY'])?$resto_metas['BUSSINESS_CCY']:"IQD";
  77. $business_type = isset($resto_metas['BUSSINESS_TYPE'])?$resto_metas['BUSSINESS_TYPE']:"Restaurants";
  78. @endphp
  79. <div class="col-md-5">
  80. <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">
  81. <i class="fa fa-plus mr-2"></i>
  82. <!-- <i class="mdi mdi-plus-circle"></i> --> {{__('label.add_discount')}}
  83. </a>
  84. </div>
  85. </div>
  86. <div class="row">
  87. <div class="col-12 mt-4">
  88. <div class="table-responsive">
  89. <table class="table table-striped" id="discount-table">
  90. <thead>
  91. <tr>
  92. <th scope="col">{{__('label.status')}}</th>
  93. <th scope="col">{{__('label.discount_code')}}</th>
  94. <th scope="col">{{__('label.application')}}</th>
  95. <th scope="col">{{__('label.type')}}</th>
  96. <th scope="col">{{__('label.min_basket')}}</th>
  97. <th scope="col">{{__('label.max_discount')}}</th>
  98. <th scope="col">{{__('label.availability')}}</th>
  99. <th scope="col">{{__('label.total_sale')}}</th>
  100. <th scope="col">{{__('label.total_usage')}}</th>
  101. <th></th>
  102. </tr>
  103. </thead>
  104. <tbody>
  105. @if(isset($discounts) && $discounts->count() > 0)
  106. @foreach($discounts as $discount)
  107. <tr data-id="{!! $discount->unique_key !!}">
  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> {{__('label.active')}}
  112. </td>
  113. <td>
  114. {!! $discount->discount_code !!}
  115. </td>
  116. <td>{!! $discount->application_type !!}</td>
  117. <td>{!! ucwords($discount->order_type) !!}</td>
  118. <td>{!! $discount->minimum_order_value !!}</td>
  119. <td>{!! $discount->maximum_discount !!}</td>
  120. <td>{!! date('d, M Y',strtotime($discount->start_date)).' '.$discount->start_time !!} @if($discount->xpire_on_date=="never_expire") Never Expire @else - {!! date('d, M Y',strtotime($discount->end_date)).' '.$discount->end_time !!} @endif</td>
  121. <td>{!! $currency !!}0.00</td>
  122. <td>0</td>
  123. <td><a type="button" data-id="{!! $discount->unique_key !!}" class="waves-effect waves-circle btn btn-circle delete-discount btn-danger btn-xs mb-5"><i class="mdi mdi-delete"></i></a></td>
  124. </tr>
  125. @endforeach
  126. @endif
  127. </tbody>
  128. </table>
  129. </div>
  130. </div>
  131. </div>
  132. </section>
  133. <!-- /.content -->
  134. </div>
  135. </div>
  136. <!-- /.content-wrapper -->
  137. @endsection
  138. @section('js')
  139. <script>
  140. $(function () {
  141. $("body").on("click",".switch-me",function (e) {
  142. var is_active = $(this).attr("aria-pressed");
  143. var id = $(this).data('id');
  144. is_active = $.trim(is_active);
  145. var status = 0;
  146. if(is_active=="false"){
  147. status = 0;
  148. }else{
  149. status = 1;
  150. }
  151. $.ajax({
  152. url:"{!! env('APP_URL') !!}discount/update/status",
  153. type:"POST",
  154. data:{
  155. id:id,
  156. status:status,
  157. "_token":'{!! csrf_token() !!}'
  158. },
  159. success:function () {
  160. if(is_active=="false"){
  161. $.toast({
  162. heading: "{{__('label.discount_status')}}",
  163. text: "{{__('label.discount_deactive')}}",
  164. position: 'top-right',
  165. loaderBg: '#ff6849',
  166. icon: 'error',
  167. hideAfter: 3000,
  168. stack: 1
  169. });
  170. }else{
  171. $.toast({
  172. heading: "{{__('label.discount_status')}}",
  173. text: "{{__('label.discount_deactive')}}",
  174. position: 'top-right',
  175. loaderBg: '#ff6849',
  176. icon: 'success',
  177. hideAfter: 3000,
  178. stack: 1
  179. });
  180. }
  181. }
  182. });
  183. e.preventDefault();
  184. e.stopPropagation();
  185. });
  186. $('.table').DataTable({
  187. paging: true,
  188. bLengthChange:false,
  189. searching: false,
  190. language: {
  191. @if($lang=='ar')
  192. url:`{{asset('public/assets/js/dataTablear.json')}}`,
  193. @endif
  194. },
  195. });
  196. $("body").on("click",".delete-discount",function(e){
  197. var id = $(this).data('id');
  198. var _this = $(this);
  199. swal({
  200. title: " Confirm?",
  201. text: "Do you want delete?",
  202. type: "error",
  203. showCancelButton: true,
  204. confirmButtonClass: "btn-danger",
  205. confirmButtonText: " Confirm, delete it!",
  206. cancelButtonText: "No, cancel please!",
  207. closeOnConfirm: true,
  208. closeOnCancel: true
  209. },
  210. function(isConfirm) {
  211. if (isConfirm) {
  212. $.ajax({
  213. url:"{!! env('APP_URL') !!}delete/discount/"+id,
  214. success:function(){
  215. _this.parent('tr').remove();
  216. }
  217. });
  218. }
  219. });
  220. e.preventDefault();
  221. e.stopPropagation();
  222. });
  223. $("body").on("click","#discount-table tr",function(){
  224. var id = $(this).data('id');
  225. window.location = "{!! env('APP_URL') !!}discount/"+id;
  226. });
  227. })
  228. </script>
  229. @endsection