show.blade.php 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534
  1. @extends('layouts.app')
  2. @section('content')
  3. <style>
  4. ul.timeline {
  5. list-style-type: none;
  6. position: relative;
  7. }
  8. ul.timeline:before {
  9. content: ' ';
  10. background: #d4d9df;
  11. display: inline-block;
  12. position: absolute;
  13. left: 29px;
  14. width: 2px;
  15. height: 100%;
  16. z-index: 400;
  17. }
  18. ul.timeline > li {
  19. margin: 20px 0;
  20. padding-left: 20px;
  21. }
  22. ul.timeline > li:before {
  23. content: ' ';
  24. background: white;
  25. display: inline-block;
  26. position: absolute;
  27. border-radius: 50%;
  28. border: 3px solid #22c0e8;
  29. left: 20px;
  30. width: 20px;
  31. height: 20px;
  32. z-index: 400;
  33. }
  34. p div{
  35. background: #f7f6f6;
  36. padding: 2px 5px;
  37. border-radius: 0;
  38. margin-bottom: 2px;
  39. }
  40. #print-recipt{
  41. display: none; }
  42. .custom-gap{
  43. padding: 1rem 1.5rem;
  44. }
  45. .custom-gap h5{ font-size: 14px; }
  46. .custom-gap p{ font-size: 12px; }
  47. #top .logo {
  48. / / float: left;
  49. height: 60px;
  50. width: 60px;
  51. // background: url({!! env('APP_URL').'public/uploads/logo/'.\Illuminate\Support\Facades\Auth::user()->restaurants->photos->file_name !!}) no-repeat;
  52. background-size: 60px 60px;
  53. }
  54. .clientlogo {
  55. float: left;
  56. height: 60px;
  57. width: 60px;
  58. // background: url({!! env('APP_URL').'public/uploads/logo/'.\Illuminate\Support\Facades\Auth::user()->restaurants->photos->file_name !!}) no-repeat;
  59. background-size: 60px 60px;
  60. border-radius: 50px;
  61. }
  62. </style>
  63. <!-- Content Wrapper. Contains page content -->
  64. <div class="content-wrapper">
  65. <div class="container-full">
  66. <!-- Content Header (Page header) -->
  67. <div class="content-header">
  68. <div class="d-flex align-items-center">
  69. <div class="me-auto">
  70. <h4 class="page-title">Order Details</h4>
  71. <div class="d-inline-block align-items-center">
  72. <nav>
  73. <ol class="breadcrumb">
  74. <li class="breadcrumb-item"><a href="{!! env('APP_URL') !!}dashboard"><i class="mdi mdi-home-outline"></i></a></li>
  75. <li class="breadcrumb-item" aria-current="page"><a href="{!! env('APP_URL') !!}orders">Order</a> </li>
  76. <li class="breadcrumb-item active" aria-current="page">Order Details</li>
  77. </ol>
  78. </nav>
  79. </div>
  80. </div>
  81. </div>
  82. </div>
  83. <!-- Main content -->
  84. <section class="content">
  85. <div class="row">
  86. <div class="col-xxxl-4 col-12">
  87. <div class="box">
  88. <div class="box-body">
  89. <div class="d-flex align-items-center">
  90. <!-- <img class="me-10 rounded-circle avatar avatar-xl b-2 border-primary" src="{!! env('APP_ASSETS') !!}images/avatar/1.jpg" alt=""> -->
  91. <i class="fa fa-user-circle" style="
  92. font-size: 54px;
  93. margin-right: 10px;
  94. "></i>
  95. <div>
  96. <h5 class="mb-0">{!! $order->customer_name !!}</h5>
  97. <span class="fs-14 text-info">Customer</span>
  98. </div>
  99. </div>
  100. </div>
  101. <div class="box-body border-bottom">
  102. <div class="d-flex align-items-center">
  103. <i class="fa fa-phone me-10 fs-24"></i>
  104. @php
  105. $new_phone = "";
  106. if(isset($order->customers)){
  107. $pos = strpos($order->customers->users->email, env('COUNTRY_CODE'));
  108. if ($pos !== false) {
  109. $new_phone = substr_replace($order->customers->users->email, '', $pos, strlen(env('COUNTRY_CODE')));
  110. }
  111. }
  112. @endphp
  113. <h4 class="mb-0">{!! $new_phone !!}</h4>
  114. </div>
  115. </div>
  116. <div class="box-body border-bottom">
  117. <div class="d-flex align-items-center">
  118. <i class="fa fa-map-marker me-10 fs-24"></i>
  119. <h5 class="mb-0 text-black"> @if(isset($order->customers) && isset($order->customers->customer_addresses))
  120. <p class="m-0">
  121. <strong> {!! isset($order->customers->customer_addresses[0])?ucwords($order->customers->customer_addresses[0]->label):NULL !!}</strong> ،
  122. {!! isset($order->customers->customer_addresses[0])?$order->customers->customer_addresses[0]->area:NULL !!} ،
  123. {!! isset($order->customers->customer_addresses[0])?$order->customers->customer_addresses[0]->address:NULL !!}
  124. </p>
  125. @endif</h5>
  126. </div>
  127. </div>
  128. <div class="box-body border-bottom">
  129. <h5 class="mb-10">Delivery Notes</h5>
  130. <p>@if(isset($order->customers) && isset($order->customers->customer_addresses))
  131. {!! isset($order->customers->customer_addresses[0])?$order->customers->customer_addresses[0]->instructions:NULL !!}
  132. @endif
  133. </p>
  134. </div>
  135. @php
  136. $classname = "badge-primary";
  137. if(strtolower($order->status)=="placed")
  138. $classname = "badge-info";
  139. if(strtolower($order->status)=="send_to_kitchen")
  140. $classname = "badge-warning";
  141. if(strtolower($order->status)=="rejected" || strtolower($order->status)=="cancelled_by_customer")
  142. $classname = "badge-danger";
  143. if(strtolower($order->status)=="preparing_order")
  144. $classname = "badge-primary";
  145. if(strtolower($order->status)=="has_delivered")
  146. $classname = "badge-success";
  147. @endphp
  148. @php
  149. $statesu = Illuminate\Support\Facades\DB::select( \Illuminate\Support\Facades\DB::raw("SELECT SUBSTRING(COLUMN_TYPE,5) as status FROM information_schema.COLUMNS WHERE TABLE_NAME='tb_dm_orders' AND COLUMN_NAME='status'"));
  150. $status = explode(',',str_replace(['(',')',"'"],'',$statesu[0]->status));
  151. $ignore_status = ['Rejected','Served','Preparing_Order'];
  152. $status = array_diff($status,$ignore_status);
  153. $custom_status = ['Placed'=>'Placed','Send_to_Kitchen'=>'Send to Kitchen','On_Road'=>'On the Way', 'Has_Delivered'=>'Delivered'];
  154. asort($status)
  155. @endphp
  156. <div class="box-body border-bottom custom-gap">
  157. <h5 class="mb-10">Order ID</h5>
  158. <p>{!! $order->order_ref !!} </span>
  159. </p>
  160. </div>
  161. <div class="box-body border-bottom custom-gap">
  162. <h5 class="mb-10">Order Instructions</h5>
  163. <p id="instruction">{!! nl2br($order->order_instructions) !!}</p>
  164. <textarea class="form-control mb-2" style="display: none">{!! ($order->order_instructions) !!}</textarea>
  165. <a href="#!" class="edit-instruction" >Edit Instruction</a>
  166. <a href="#!" class="update-instruction" style="display: none;" >Update Instruction</a>
  167. </div>
  168. <div class="box-body border-bottom custom-gap">
  169. <h5 class="mb-10">Order Delivery Time</h5>
  170. <p>{!! $order->order_deliver_time!=""?$order->order_deliver_time:"(اقرب وقت)" !!}
  171. </p>
  172. </div>
  173. <div class="box-body border-bottom custom-gap">
  174. <h5 class="mb-10">Order Date</h5>
  175. <p>{!! \App\Helpers\CommonMethods::formatDateTime($order->created_at) !!}
  176. </p>
  177. </div>
  178. </div>
  179. </div>
  180. @php
  181. $custom_status_buttons['Placed'] = ['Accepted'=>'Accepted','Rejected'=>'Rejected', 'Rejected_by_User'=>'Rejected by User'];
  182. $custom_status_buttons['Accepted'] = ['On_Road'=>'On the Way','Rejected'=>'Rejected', 'Rejected_by_User'=>'Rejected by User'];
  183. $custom_status_buttons['On_Road'] = ['Has_Delivered'=>'Delivered','Rejected'=>'Rejected', 'Rejected_by_User'=>'Rejected by User'];
  184. $timeline_status['Accepted'] = ['Placed'=>'Placed','Accepted'=>'Accepted','On_Road'=>'On the Way' ,'Has_Delivered'=>'Delivered'];
  185. $timeline_status['Rejected'] = ['Placed'=>'Placed','Rejected'=>'Rejected'];
  186. $timeline_status['Rejected_by_User'] = ['Placed'=>'Placed','Rejected_by_User'=>'Rejected by User'];
  187. $time_line_status = 'Accepted';
  188. if($order->status=="Rejected_by_User")
  189. $time_line_status="Rejected_by_User";
  190. if($order->status=="Rejected")
  191. $time_line_status="Rejected";
  192. @endphp
  193. <div class="col-xxxl-8 col-12">
  194. <div class="box">
  195. <div class="box-body border-bottom">
  196. <ol class="c-progress-steps">
  197. @foreach($timeline_status[$time_line_status] as $k=>$s)
  198. <li class="c-progress-steps__step @if(in_array(($k), $activities)) done @endif"><span>{!! $s !!}</span></li>
  199. @endforeach
  200. </ol>
  201. </div>
  202. <div class="box-body">
  203. @if(isset($custom_status_buttons[$order->status]))
  204. @foreach($custom_status_buttons[$order->status] as $k=>$s)
  205. @php
  206. $classname = "btn-secondary";
  207. if(strtolower($k)=="placed")
  208. $classname = "btn-info";
  209. if(strtolower($k)=="on_road")
  210. $classname = "btn-warning";
  211. if(strtolower($k)=="rejected" || strtolower($k)=="cancelled_by_customer"||strtolower($k)=="rejected_by_user")
  212. $classname = "btn-danger";
  213. if(strtolower($k)=="preparing_order")
  214. $classname = "btn-primary";
  215. if(strtolower($k)=="has_delivered")
  216. $classname = "btn-success";
  217. @endphp
  218. <button type="button" @if(in_array($k,$activities)) disabled="" @endif class="btn bg-gradient btn-sm {!! $classname !!} order-status" data-status="{!! $k !!}">{!! str_replace('_',' ',$s) !!}</button>
  219. @endforeach @endif
  220. </div>
  221. </div>
  222. <div class="box">
  223. <div class="box-body">
  224. <div class="table-responsive-xl">
  225. <table class="table product-overview">
  226. <thead>
  227. <tr>
  228. <th>Item</th>
  229. <th width="35%">Product Info</th>
  230. <th width="10%">Price</th>
  231. <th width="10%">Quantity</th>
  232. <th>Total</th>
  233. <th>Action</th>
  234. {{--<th>Action</th>--}}
  235. </tr>
  236. </thead>
  237. <tbody>
  238. @if(isset($order->orderItems) && $order->orderItems->count() > 0)
  239. @php
  240. $extra_price = 0;
  241. @endphp
  242. @foreach($order->orderItems as $item)
  243. <tr>
  244. <td>
  245. @if(isset($item->recipes) && isset($item->recipes->main_images))
  246. <div style="width: 80px; height: 52px; background: url({!! $item->recipes->main_images->file_name !!});background-size: contain; background-position: center; "></div>
  247. @else
  248. <img src="{!! env('APP_ASSETS') !!}images/product/product-1.png" alt="" width="80">
  249. @endif
  250. </td>
  251. <td>
  252. @php
  253. $recipe = $item->recipes;
  254. $cate_name = "";
  255. $categories = isset($recipe->categories)?$recipe->categories->pluck('category_id'):NULL;
  256. if($categories){
  257. $categories = \App\Categories::whereIn('id',$categories)->pluck('name')->toArray();
  258. $cate_name = $categories[0];
  259. }
  260. @endphp
  261. @php
  262. $extra_options = NULL;
  263. $opt = [];
  264. if(!empty($item->extra_options)){
  265. $extra_options = json_decode($item->extra_options);
  266. //$opt = "<ul>";
  267. foreach($extra_options as $option){
  268. $itm = \App\ExtraOptionItems::find($option->id);
  269. if(isset($itm)){
  270. $opt[] = $itm->name;
  271. // $opt.="<li>".$itm->name.' <span class="ml-2 badge badge-danger">'.($itm->price).'</span>';
  272. $extra_price = $extra_price+$itm->price;
  273. if(isset($option->sub_items)){
  274. foreach($option->sub_items as $sub){
  275. $itm = \App\ExtraOptionItems::find($sub->sub_item_id);
  276. $extra_price = $extra_price+$itm->price;
  277. }
  278. }
  279. //$opt.="</li>";
  280. }
  281. }
  282. // $opt.="</ul>";
  283. }
  284. @endphp
  285. <h6>{!! $cate_name !!}</h6>
  286. <h4>{!! isset($item->recipes)?$item->recipes->name:"" !!}
  287. </h4> @if(count($opt) > 0)( {!! implode(', ',$opt) !!} ) @endif
  288. </td>
  289. <td>IQD {!! number_format($item->price) !!}</td>
  290. <td><input type="number" class="form-control" value="{!! $item->qty !!}" placeholder="1" min="0"></td>
  291. <th>IQD {!! number_format($item->qty*$item->price) !!}</th>
  292. <td>
  293. <a href="javascript:;" class="btn btn-circle btn-primary btn-xs remove-item" data-quantity="{!! $item->qty !!}" data-price="{!! $item->price !!}" data-item-id="{!! $item->order_item_id !!}" data-toggle="tooltip" data-placement="top" title="Remove"><i class="ti-trash"></i> </a>
  294. </td>
  295. </tr>
  296. @endforeach
  297. <tr>
  298. <th>
  299. Delivery Fee:
  300. </th>
  301. <th colspan="6">IDQ {!! number_format($order->delivery_fee) !!}</th>
  302. </tr>
  303. <tr>
  304. <th>
  305. Total:
  306. </th>
  307. <th colspan="6">IQD {!! number_format($order->delivery_fee+$order->total_price+$extra_price) !!}</th>
  308. </tr>
  309. <tr>
  310. <th>Print Receipt</th>
  311. <th colspan="6">
  312. <button class="btn btn-default print" data-id="{!! $order->id !!}"><i class="glyphicon glyphicon-print"></i> </button>
  313. </th>
  314. </tr>
  315. @endif
  316. </tbody>
  317. </table>
  318. </div>
  319. <div id="print-recipt">
  320. </div>
  321. </div>
  322. </div>
  323. </div>
  324. </div>
  325. </section>
  326. <!-- /.content -->
  327. </div>
  328. </div>
  329. <!-- /.content-wrapper -->
  330. @endsection
  331. @section('js')
  332. <script>
  333. $(function () {
  334. $("body").on("click",".print",function () {
  335. $.ajax({
  336. url:"{!! env('APP_URL') !!}order/print/{!! $order->id !!}",
  337. success:function (response) {
  338. $('#print-recipt').html(response);
  339. $('#print-recipt').printThis();
  340. }
  341. });
  342. });
  343. $(".edit-instruction").click(function () {
  344. $("textarea").show();
  345. $(".update-instruction").show();
  346. $("#instruction").hide();
  347. $(this).hide();
  348. });
  349. $("body").on("click",".remove-item",function () {
  350. return;
  351. var id = $(this).data('item-id');
  352. var quantity = $(this).data('quantity');
  353. var price = $(this).data('price');
  354. var total_less_price = quantity * price;
  355. var _this = $(this);
  356. _this.parents('tr').remove();
  357. $.ajax({
  358. url:"{!! env('APP_URL') !!}delete/order/item",
  359. type:"POST",
  360. data:{
  361. itemId:id,
  362. orderId:"{!! $order->id !!}",
  363. total_less_price:total_less_price,
  364. "_token":"{!! csrf_token() !!}"
  365. },
  366. success:function () {
  367. }
  368. });
  369. });
  370. $("body").on("click",".update-instruction",function () {
  371. var text = $("textarea").val();
  372. $.ajax({
  373. url:"{!! env('APP_URL') !!}update/instruction",
  374. data:{
  375. id:"{!! $order->id !!}",
  376. text:text,
  377. "_token":"{!! csrf_token() !!}",
  378. },
  379. type:"POST",
  380. success:function () {
  381. $(".update-instruction").hide();
  382. $(".edit-instruction").show();
  383. $("#instruction").show();
  384. $("textarea").hide();
  385. }
  386. });
  387. });
  388. $("body").on('click','.save',function () {
  389. $(".alert").hide();
  390. if($("#password-form").valid()){
  391. $("#password-form").ajaxForm(function (response) {
  392. response = $.parseJSON(response);
  393. if(response){
  394. if(response.type=="success"){
  395. $('#password-form .alert.success').html(response.message);
  396. $('#password-form .alert.success').show();
  397. setTimeout(function(){
  398. location.reload();
  399. },2000)
  400. }else{
  401. $('#password-form .alert.error').html(response.message);
  402. $('#password-form .alert.error').show();
  403. }
  404. }
  405. }).submit();
  406. }
  407. });
  408. $("body").on("click",'.order-status',function () {
  409. // alert();
  410. var status = $(this).data('status');
  411. $.ajax({
  412. url:"{!! env('APP_URL') !!}update/order/status",
  413. type:"POST",
  414. data:{
  415. id:"{!! $order->id !!}",
  416. status:status,
  417. "_token":"{!! csrf_token() !!}"
  418. },
  419. success:function () {
  420. location.reload();
  421. }
  422. });
  423. });
  424. })
  425. </script>
  426. @endsection