orders.blade.php_1 52 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058
  1. @extends('layouts.app')
  2. @section('css')
  3. <link href="{!! env('APP_ASSETS') !!}css/liveorder.css" rel="stylesheet" type="text/css">
  4. @endsection
  5. @section('content')
  6. <style>
  7. body {
  8. background-color: #FFF;
  9. }
  10. #show-recipes .box-header{
  11. padding: 15px 1.5rem 5px;
  12. }
  13. @-webkit-keyframes special {
  14. from { background-color: rgba(255, 121, 77, 0.27); }
  15. to { background-color: inherit; }
  16. }
  17. @-moz-keyframes special {
  18. from { background-color: rgba(255, 121, 77, 0.27);; }
  19. to { background-color: inherit; }
  20. }
  21. @-o-keyframes special {
  22. from { background-color: rgba(255, 121, 77, 0.27);; }
  23. to { background-color: inherit; }
  24. }
  25. @keyframes special {
  26. from { background-color: rgba(255, 121, 77, 0.27);; }
  27. to { background-color: inherit; }
  28. }
  29. .special {
  30. -webkit-animation: special 1s infinite; /* Safari 4+ */
  31. -moz-animation: special 1s infinite; /* Fx 5+ */
  32. -o-animation: special 1s infinite; /* Opera 12+ */
  33. animation: special 1s infinite; /* IE 10+ */
  34. }
  35. .mlist_li.selected .media, .mlist_li.selected .box{
  36. background-color: transparent !important;
  37. }
  38. .mlist_li.selected p{
  39. color:#000
  40. }
  41. .labelcenter { width: auto}
  42. .gap-items p.status{ font-size: 12px}
  43. .gap-items p.min{
  44. line-height: 13px;
  45. padding-top: 11px;
  46. font-size: 11px;
  47. }
  48. .bg-danger p.min, .bg-danger .gap-items p.status{
  49. display: none;}
  50. .bg-danger .circle-div{ height: 10px; width: 10px; background: #fff !important;}
  51. .mlist_li.selected .media-list-hover > .media:not(.media-list-header):not(.media-list-footer):hover,.mlist_li.selected .media-list-hover .media-list-body > .media:hover{
  52. background-color: transparent; !important;
  53. }
  54. .sidebar-mini.sidebar-collapse .content-wrapper {
  55. width: calc(100% - 60px) !important;
  56. margin-left: 60px !important;
  57. }
  58. .no-order-found{
  59. background-color: #000;
  60. background-image: url({!! env('APP_ASSETS') !!}images/no-order.png);
  61. background-repeat: no-repeat;
  62. background-position: center;
  63. ;
  64. }
  65. @media screen and (min-device-width: 1200px) and (max-device-width: 1600px) and (-webkit-min-device-pixel-ratio: 1){
  66. body {
  67. padding: 0px !important;
  68. }
  69. }
  70. </style>
  71. <!-- Content Wrapper. Contains page content -->
  72. <div class="content-wrapper">
  73. <div id="countdown"></div>
  74. <div class="container-full">
  75. <section class="content p-0">
  76. <div class="row">
  77. <div class="col-sm-12">
  78. <nav class="navbar navbar-static-top ">
  79. <!-- Sidebar toggle button-->
  80. <div class="row">
  81. <div class="col-md-12 tab-bar-section">
  82. <div class="app">
  83. <ul class="hs full nav nav-tabs" role="tablist">
  84. <li class="item nav-item d-flex align-items-start">
  85. <div class="gap-items-4 d-flex justify-content-end">
  86. <a class="nav-link p-0 active" data-bs-toggle="tab" href="#all-orders" data-status="all" role="tab">All
  87. <span class="labelcenter label-default all">0</span></a>
  88. </div>
  89. </li>
  90. <li class="item nav-item d-flex align-items-start ">
  91. <div class="gap-items-4 d-flex justify-content-end">
  92. <a class="nav-link p-0" data-bs-toggle="tab" href="#new-orders" data-status="new" role="tab">New
  93. <span class="labelcenter label-default new">0</span></a>
  94. </div>
  95. </li>
  96. <li class="item nav-item d-flex align-items-start">
  97. <div class="gap-items-4 d-flex justify-content-end">
  98. <a class="nav-link p-0" data-bs-toggle="tab" href="#in-kitchen" data-status="kitchen" role="tab">In Prep
  99. <span class="labelcenter label-default kitchen">0</span></a>
  100. </div>
  101. </li>
  102. <li class="item nav-item d-flex align-items-start">
  103. <div class="gap-items-4 d-flex justify-content-end">
  104. <a class="nav-link p-0" data-bs-toggle="tab" href="#in-route" data-status="route" role="tab" >In Route/Ready
  105. <span class="labelcenter label-default route">0</span></a>
  106. </div>
  107. </li>
  108. </ul>
  109. </div>
  110. </div>
  111. </div>
  112. <!-- <div class="app-menu"></div> -->
  113. <a href="#" class="d-inline-block btn right-bar-btn waves-effect waves-circle btn btn-circle btn-danger btn-sm right-close-btn">
  114. <i class="mdi mdi-close"></i>
  115. </a>
  116. </nav>
  117. </div>
  118. </div>
  119. <div class="row">
  120. <div class="col-sm-12 col-md-4 order-sections-list" style="background-color: #f1f1f1">
  121. <div class="row p-10">
  122. <div class="col-md-12 mt-5">
  123. <div class="search-bx mx-5">
  124. <form>
  125. <div class="input-group search-div">
  126. <input type="search" class="form-control" style="background-color: transparent" placeholder="Search by order id" aria-label="Search" aria-describedby="button-addon2">
  127. <div class="input-group-append">
  128. <button class="btn btn-sarch" type="submit" id="button-addon3"><i class="ti-search"></i></button>
  129. </div>
  130. </div>
  131. </form>
  132. </div>
  133. </div>
  134. </div>
  135. <div class="row mt-5 list_row">
  136. <div class=" col-md-12 p-0">
  137. <div class="tab-content">
  138. <div class="tab-pane fade in active all-orders" id="all-orders" role="tabpanel" style="max-height: 82vh; min-height: 82vh; overflow: auto;">
  139. <div class="p-0">
  140. <ul class="list-group list-ul list-unstyled orders-list" id="orders-list">
  141. {{--<li class="mlist_li p-5 mb-5 pl-15">
  142. <div class="d-grid gap-2 d-flex justify-content-center">
  143. <button class="btn btn-md btn-primary ref-btn">Refresh</button>
  144. </div>
  145. </li>--}}
  146. </ul>
  147. </div>
  148. </div>
  149. </div>
  150. </div>
  151. </div>
  152. </div>
  153. <div class="col-sm-12 col-md-6 box-shadowed">
  154. <div class="no-order" style="padding-top: 50%; height: 90vh ;">
  155. <h3 class="text-center text-light">No order selected</h3>
  156. </div>
  157. <div class="order-section" style="display: none; height: 90vh ; overflow-x: auto">
  158. <div class="row back-to-orders d-md-none d-lg-none">
  159. <div class="col-sm-12 text-center">
  160. Orders
  161. </div>
  162. </div>
  163. <div class="row">
  164. <div class="col-sm-12">
  165. <div class="boxs">
  166. <div class="box-header with-border">
  167. <div class="d-flex justify-content-between align-items-center">
  168. <p class="fw-bold" rel="order_ref"></p>
  169. <p rel="order_placed"></p>
  170. <p class="p-2 inkitchen-btn" id="toggle"></p>
  171. </div>
  172. </div>
  173. </div>
  174. </div>
  175. <div class="row">
  176. <div class="col-sm-12 mt-1 text-end">
  177. <a href="#!">Print</a>
  178. </div>
  179. </div>
  180. <div class="row right-panel-box">
  181. <div class="col-md-6">
  182. <div class="boxs">
  183. <div class="box-body">
  184. <div class="d-flex align-items-start">
  185. <div>
  186. <p class="text-fade mb-0">Brand</p>
  187. <p rel="brand_name"></p>
  188. </div>
  189. </div>
  190. </div>
  191. </div>
  192. </div>
  193. <div class="col-md-6">
  194. <div class="boxs">
  195. <div class="box-body">
  196. <div class="d-flex align-items-start">
  197. <div>
  198. <p class="text-fade mb-0">Outlet</p>
  199. <p rel="outlet_name"></p>
  200. </div>
  201. </div>
  202. </div>
  203. </div>
  204. </div>
  205. </div>
  206. <div class="row right-panel-box">
  207. <div class="col-md-6">
  208. <div class="boxs">
  209. <div class="box-body">
  210. <div class="d-flex align-items-start">
  211. <div>
  212. <p class="text-fade mb-0">Order type</p>
  213. <p>
  214. <i class="icon-Dinner"><span class="path1"></span><span class="path2"></span><span class="path3"></span><span class="path4"></span><span class="path5"></span></i>
  215. <span rel="order_type"></span>
  216. </p>
  217. </div>
  218. </div>
  219. </div>
  220. </div>
  221. </div>
  222. <div class="col-md-6">
  223. <div class="boxs">
  224. <div class="box-body">
  225. <div class="d-flex align-items-start">
  226. <div class="">
  227. <p class="text-fade mb-0">Delivery at</p>
  228. <p rel="delivery_at"></p>
  229. </div>
  230. </div>
  231. </div>
  232. </div>
  233. </div>
  234. </div>
  235. <div class="row right-panel-box">
  236. <div class="col-md-6">
  237. <div class="boxs">
  238. <div class="box-body">
  239. <div class="d-flex align-items-start">
  240. <div class="">
  241. <p class="text-fade mb-0">Customer</p>
  242. <p rel="customer"> <br>
  243. <i class="mdi mdi-crown org-color"></i>
  244. <small class="org-color">Ordered 5 times </small>
  245. </p>
  246. </div>
  247. </div>
  248. </div>
  249. </div>
  250. </div>
  251. <div class="col-md-6">
  252. <div class="boxs">
  253. <div class="box-body">
  254. <div class="d-flex align-items-start">
  255. <div class="">
  256. <p class="text-fade mb-0">Phone number</p>
  257. <p rel="phone"></p>
  258. </div>
  259. </div>
  260. </div>
  261. </div>
  262. </div>
  263. </div>
  264. <div class="row right-panel-box">
  265. <div class="col-md-6">
  266. <div class="boxs">
  267. <div class="box-body">
  268. <div class="d-flex align-items-start">
  269. <div class="">
  270. <p class="text-fade mb-0">Payment</p>
  271. <p>Cash</p>
  272. </div>
  273. </div>
  274. </div>
  275. </div>
  276. </div>
  277. <div class="col-md-6">
  278. <div class="boxs">
  279. <div class="box-body">
  280. <div class="d-flex align-items-start">
  281. <div class="">
  282. <p class="text-fade mb-0">Channel</p>
  283. <p rel="channel"></p>
  284. </div>
  285. </div>
  286. </div>
  287. </div>
  288. </div>
  289. </div>
  290. <div class="row right-panel-box">
  291. <div class="col-md-6">
  292. <div class="boxs">
  293. <div class="box-body">
  294. <div class="d-flex align-items-start">
  295. <div class="">
  296. <p class="text-fade mb-0">Address</p>
  297. <p rel="address"></p>
  298. </div>
  299. </div>
  300. </div>
  301. </div>
  302. </div>
  303. <div class="col-md-6">
  304. <div class="boxs">
  305. <div class="box-body">
  306. <div class="d-flex align-items-start">
  307. <div class="">
  308. <p class="text-fade mb-0">Order Notes</p>
  309. <p rel="delivery_notes"></p>
  310. </div>
  311. </div>
  312. </div>
  313. </div>
  314. </div>
  315. </div>
  316. </div>
  317. <div class="row mt-0 right-panel-footer ">
  318. <div class="col-12" id="show-recipes">
  319. </div>
  320. <div class="col-12">
  321. <div class="box-header border-0 p-15 mt-0 pb-0">
  322. <div class="d-flex justify-content-between align-items-center m-0">
  323. <p>Subtotal:</p>
  324. <p class="sub_total"></p>
  325. </div>
  326. <div class="d-flex justify-content-between align-items-center m-0">
  327. <p>Delivery Fee:</p>
  328. <p class="delivery_fee"></p>
  329. </div>
  330. <div class="d-flex justify-content-between align-items-center m-0">
  331. <p class="p-15 m-5 ">Total:</p>
  332. <p class="total_txt"></p>
  333. </div>
  334. </div>
  335. </div>
  336. <div class="col-12 mt-5 button-bottom-div">
  337. <div class="m-5">
  338. <button type="button" class="waves-effect waves-light btn btn-outline btn-danger mb-0 btn-w80 rounded-0 rclose-btn reject change-status-reject" data-status="Rejected" style="display: none">Reject</button>
  339. <button type="button" class="waves-effect waves-light btn btn-outline btn-dark mb-0 btn-w50 rounded-0 rclose-btn accept change-status-reject" data-status="Close" style="display: none">Close</button>
  340. <button type="button" class="waves-effect waves-light btn btn-outline btn-danger mb-0 btn-w50 rounded-0 accept change-status-reject" data-status="Rejected" style="display: none">Cancel</button>
  341. <button type="button" class="waves-effect waves-light btn btn-default btn-w80 rounded-0 ready-collect change-status " data-status="">Accept</button>
  342. </div>
  343. </div>
  344. </div>
  345. </div>
  346. </div>
  347. </div>
  348. </section>
  349. <!-- /.content -->
  350. </div>
  351. </div>
  352. <!-- /.content-wrapper -->
  353. <div class="modal center-modal fade" id="accept-modal" tabindex="-1">
  354. <div class="modal-dialog">
  355. <div class="modal-content">
  356. <div class="modal-body">
  357. <h4> Order Settings</h4>
  358. <p>Set the time needed for preparing and delivering orders</p>
  359. <div class="row">
  360. <div class="col-sm-6">
  361. <div class="form-group">
  362. <label>Preparation (minutes)</label>
  363. <input type="text" name="preparation_time" class="form-control" value="15" />
  364. </div>
  365. </div>
  366. <div class="col-sm-6">
  367. <div class="form-group">
  368. <label>Preparation + delivery (minutes)</label>
  369. <input type="text" name="preperation_delivery" class="form-control" value="40" />
  370. </div>
  371. </div>
  372. </div>
  373. </div>
  374. <div class="modal-footer modal-footer-uniform">
  375. <button type="button" class="btn btn-danger" data-bs-dismiss="modal">Close</button>
  376. <button type="button" class="btn btn-primary float-end accept-order">Accept Order</button>
  377. </div>
  378. </div>
  379. </div>
  380. </div>
  381. @endsection
  382. @section('js')
  383. <script src="{!! env('APP_ASSETS') !!}js/jquery.jscroll.min.js"></script>
  384. <script src="{!! env('APP_ASSETS') !!}js/jquery.countdown360.min.js"></script>
  385. <script src="{!! env('APP_ASSETS') !!}vendor_components/sweetalert/sweetalert.min.js"></script>
  386. <script>
  387. var resto_id = 0;
  388. var status = "all";
  389. var counter = 0;
  390. var order_id = null;
  391. $(function () {
  392. $("body").on("click",".back-to-orders",function () {
  393. $(".order-section").hide();
  394. });
  395. $.ajax({
  396. url: "{!! env('APP_URL') !!}order/counts",
  397. success: function (response) {
  398. // response = $.parseJSON(response);
  399. var total_accepted = 0;
  400. var total = 0;
  401. $.each(response,function (i,v) {
  402. if(v.status=="Send_to_Kitchen" || v.status=="Accepted"){
  403. total_accepted+=parseInt(v.status_count);
  404. total+=parseInt(v.status_count);
  405. $(".labelcenter.kitchen").text(total_accepted);
  406. }
  407. if(v.status=="On_Road"){
  408. $(".labelcenter.route").text(v.status_count);
  409. total+=parseInt(v.status_count);
  410. }
  411. if(v.status=="Placed"){
  412. $(".labelcenter.new").text(v.status_count);
  413. total+=parseInt(v.status_count);
  414. if(parseInt(v.status_count) > 0){
  415. $("#order-counter").html(v.status_count);
  416. $("#order-counter").show();
  417. }
  418. }
  419. });
  420. $(".labelcenter.all").text(total);
  421. }
  422. });
  423. $("#all-orders").removeClass('no-order-found');
  424. $.ajax({
  425. url:"{!! env('APP_URL') !!}liveorders/"+status,
  426. success:function (response) {
  427. // response = $.parseJSON(response);
  428. if(response){
  429. if(response.type=="success"){
  430. $.each(response.orders,function (i,v) {
  431. var str='<li class="mlist_li" rel="detail" data-order-id="'+v.id+'">\n' +
  432. ' <div class="box '+v.box_bg+' rounded-0">\n' +
  433. ' <div class="media-list media-list-divided media-list-hover">\n' +
  434. ' <div class="media align-items-center">\n' +
  435. ' <div class="media-body">\n' +
  436. ' <p>#'+v.order_ref+'</p>\n' +
  437. ' <p> '+(v.campaign_type!=""?v.campaign_type:"Direct")+', '+v.created_at+'</p>\n' +
  438. ' </div>\n' +
  439. ' <div class="media-right gap-items">\n' +
  440. ' <div class="user-social-acount text-center">\n' +
  441. ' <p class="m-0 status">'+v.status+'</p>\n' +
  442. ' <div class="d-flex align-items-center float-end">\n' +
  443. ' <div class="circle-div '+v.bg+' text-center" data-min="'+v.remaining_min+'" data-color="'+v.bg_color+'">\n' +
  444. ' <p class="mb-5 min">'+v.remaining_min+'<br />\n'+
  445. ' Min</p>\n'+
  446. ' </div>\n' +
  447. ' </div>\n' +
  448. ' </div>\n' +
  449. ' </div>\n' +
  450. ' </div>\n' +
  451. ' </div>\n' +
  452. ' </div>\n' +
  453. '</li>';
  454. counter = counter+1;
  455. $("#orders-list").append(str);
  456. });
  457. $("span."+status).html(counter);
  458. }else{
  459. $("#all-orders").addClass('no-order-found');
  460. }
  461. }
  462. }
  463. });
  464. $("body").on("click",".nav-link",function () {
  465. $("#orders-list").html('');
  466. $(".no-order").show();
  467. $(".order-section").hide();
  468. status = $(this).data('status');
  469. $("#all-orders").removeClass('no-order-found');
  470. var counter = 0;
  471. $.ajax({
  472. url:"{!! env('APP_URL') !!}liveorders/"+status,
  473. success:function (response) {
  474. // response = $.parseJSON(response);
  475. if(response){
  476. if(response.type=="success"){
  477. $.each(response.orders,function (i,v) {
  478. var str='<li class="mlist_li" rel="detail" data-order-id="'+v.id+'">\n' +
  479. ' <div class="box '+v.box_bg+' rounded-0">\n' +
  480. ' <div class="media-list media-list-divided media-list-hover">\n' +
  481. ' <div class="media align-items-center">\n' +
  482. ' <div class="media-body">\n' +
  483. ' <p>#'+v.order_ref+'</p>\n' +
  484. ' <p> '+(v.campaign_type!=""?v.campaign_type:"Direct")+', '+v.created_at+'</p>\n' +
  485. ' </div>\n' +
  486. ' <div class="media-right gap-items">\n' +
  487. ' <div class="user-social-acount text-center">\n' +
  488. ' <p class="m-0 status">'+v.status+'</p>\n' +
  489. ' <div class="circle-div '+v.bg+' text-center" data-min="'+v.remaining_min+'" data-color="'+v.bg_color+'">\n' +
  490. ' <p class="mb-5 min">'+v.remaining_min+'<br />\n'+
  491. ' Min</p>\n'+
  492. ' </div>\n' +
  493. ' </div>\n' +
  494. ' </div>\n' +
  495. ' </div>\n' +
  496. ' </div>\n' +
  497. ' </div>\n' +
  498. '</li>';
  499. $("#orders-list").append(str);
  500. counter = counter+1;
  501. });
  502. }else{
  503. $("#all-orders").addClass('no-order-found');
  504. }
  505. //$("span."+status).html(counter);
  506. }
  507. }
  508. });
  509. });
  510. $("body").on("click","li[rel=detail]",function () {
  511. var id = $(this).data("order-id");
  512. order_id = id;
  513. $(".mlist_li.selected").removeClass('selected');
  514. $("#show-recipes").html('');
  515. $(this).addClass('selected');
  516. $.ajax({
  517. url:"{!! env('APP_URL') !!}get/order/detail/"+id,
  518. success:function (response) {
  519. response = $.parseJSON(response);
  520. var price = 0;
  521. var delivery_fee = 0;
  522. $(".change-status").attr('data-id',id);
  523. $(".change-status-reject").attr('data-id',id);
  524. $.each(response,function (i,v) {
  525. $("p[rel="+i+"]").text(v);
  526. $("span[rel="+i+"]").text(v);
  527. if(i=="delivery_fee"){
  528. delivery_fee = v;
  529. $(".delivery_fee").html("IQD "+v);
  530. }
  531. if(i=="status"){
  532. $(".inkitchen-btn").html(v);
  533. $(".inkitchen-btn").addClass();
  534. if(v=="New"){
  535. $(".reject").show();
  536. $(".accept").hide();
  537. }else{
  538. $(".accept").show();
  539. $(".reject").hide();
  540. }
  541. }
  542. if(i=="bg"){
  543. $(".inkitchen-btn").removeClass('org-bg');
  544. $(".inkitchen-btn").removeClass('bg-danger');
  545. $(".inkitchen-btn").removeClass('green-bg');
  546. $(".inkitchen-btn").addClass(v);
  547. }
  548. if(i=="next_action"){
  549. $(".change-status").html(v);
  550. }
  551. if(i=="next_status"){
  552. $(".change-status").attr('data-status',v);
  553. }
  554. if(i=="recipes"){
  555. var recipes = v;
  556. if(recipes){
  557. $.each(recipes,function(m,n){
  558. $("#show-recipes").append(show_recipe(n));
  559. price+=parseFloat(n.total_price);
  560. });
  561. $(".sub_total").html('IQD '+price);
  562. }
  563. }
  564. $(".total_txt").html("IQD "+(price+delivery_fee));
  565. });
  566. }
  567. });
  568. $(".no-order").hide();
  569. $(".order-section").show();
  570. });
  571. $('ul.pagination').hide();
  572. $('#all-orders').jscroll({
  573. autoTrigger: true,
  574. loadingHtml: '<img class="text-center" src="{!! env('APP_ASSETS') !!}images/preloaders/preloader.svg" alt="Loading..." />',
  575. padding: 0,
  576. nextSelector: '.pagination li.active + li a',
  577. contentSelector: 'div.mlist_li',
  578. callback: function() {
  579. $('ul.pagination').remove();
  580. }
  581. });
  582. $("body").on("click",".nav-link",function () {
  583. $(".nav-link").removeClass('active')
  584. $(this).addClass('active')
  585. });
  586. $("body").on("click",".order-row",function () {
  587. var id = $(this).data('id');
  588. window.location = "{!! env('APP_URL') !!}order/show/"+id;
  589. });
  590. $("body").on("click",".accept-order",function () {
  591. var preparation_time = $("input[name=preparation_time]").val();
  592. var preperation_delivery = $("input[name=preperation_delivery]").val();
  593. if(preperation_delivery==""){
  594. $("input[name=preperation_delivery]").focus();
  595. return false;
  596. }
  597. if(preparation_time==""){
  598. $("input[name=preparation_time]").focus();
  599. return false;
  600. }
  601. $.ajax({
  602. url:"{!! env('APP_URL') !!}update/order/status",
  603. type:"POST",
  604. data:{
  605. id:order_id,
  606. status:"Accepted",
  607. preparation_time:preparation_time,
  608. preperation_delivery:preperation_delivery,
  609. "_token":"{!! csrf_token() !!}"
  610. },
  611. success:function () {
  612. // alert();
  613. $(".mlist_li.selected").remove();
  614. if(status=="all"){
  615. $("#orders-list").html('');
  616. /*$.ajax({
  617. url:"{!! env('APP_URL') !!}liveorders/"+status,
  618. success:function (response) {
  619. //response = $.parseJSON(response);
  620. if(response){
  621. $.each(response.orders,function (i,v) {
  622. var str='<li class="mlist_li" rel="detail" data-order-id="'+v.id+'">\n' +
  623. ' <div class="box '+v.box_bg+' rounded-0">\n' +
  624. ' <div class="media-list media-list-divided media-list-hover">\n' +
  625. ' <div class="media align-items-center">\n' +
  626. ' <div class="media-body">\n' +
  627. ' <p>#'+v.order_ref+'</p>\n' +
  628. ' <p> '+(v.campaign_type!=""?v.campaign_type:"Direct")+', '+v.created_at+'</p>\n' +
  629. ' </div>\n' +
  630. ' <div class="media-right gap-items">\n' +
  631. ' <div class="user-social-acount text-center">\n' +
  632. ' <p class="m-0 status">'+v.status+'</p>\n' +
  633. ' <div class="d-flex align-items-center float-end">\n' +
  634. ' <div class="circle-div '+v.bg+' text-center" data-min="'+v.remaining_min+'" data-color="'+v.bg_color+'">\n' +
  635. ' <p class="mb-5 min">'+v.remaining_min+'<br />\n'+
  636. ' Min</p>\n'+
  637. ' </div>\n' +
  638. ' </div>\n' +
  639. ' </div>\n' +
  640. ' </div>\n' +
  641. ' </div>\n' +
  642. ' </div>\n' +
  643. ' </div>\n' +
  644. '</li>';
  645. counter = counter+1;
  646. $("#orders-list").append(str);
  647. });
  648. $("span."+status).html(counter);
  649. }
  650. }
  651. });*/
  652. }
  653. $(".no-order").show();
  654. $(".order-section").hide();
  655. /*$.ajax({
  656. url: "{!! env('APP_URL') !!}order/counts",
  657. success: function (response) {
  658. // response = $.parseJSON(response);
  659. var total_accepted = 0;
  660. var total = 0;
  661. $.each(response,function (i,v) {
  662. if(v.status=="Send_to_Kitchen" || v.status=="Accepted"){
  663. total_accepted+=parseInt(v.status_count);
  664. total+=parseInt(v.status_count);
  665. $(".labelcenter.kitchen").text(total_accepted);
  666. }
  667. if(v.status=="On_Road"){
  668. $(".labelcenter.route").text(v.status_count);
  669. total+=parseInt(v.status_count);
  670. }
  671. if(v.status=="Placed"){
  672. $(".labelcenter.new").html(v.status_count);
  673. total+=parseInt(v.status_count);
  674. if(parseInt(v.status_count) > 0){
  675. $("#order-counter").html(v.status_count);
  676. $("#order-counter").show();
  677. }else{
  678. audio.pause();
  679. $("#order-counter").html(0);
  680. $("#order-counter").hide();
  681. }
  682. }
  683. });
  684. $(".labelcenter.all").text(total);
  685. }
  686. });*/
  687. // swal("Accepted!", "Order is Accepted.", "success");
  688. $("#accept-modal").modal('hide');
  689. }
  690. });
  691. });
  692. $("body").on("click",'.change-status,.change-status-reject',function (e) {
  693. // alert();
  694. var s = $(".nav-link.active").data('status');
  695. var status = $(this).attr('data-status');
  696. // alert(status); return;
  697. if(status=="Rejected"){
  698. swal({
  699. title: "Are you sure?",
  700. text: "You will not be able to recover this order!",
  701. type: "warning",
  702. showCancelButton: true,
  703. confirmButtonColor: "#DD6B55",
  704. confirmButtonText: "Yes, Reject it!",
  705. closeOnConfirm: true
  706. }, function(){
  707. $.ajax({
  708. url:"{!! env('APP_URL') !!}update/order/status",
  709. type:"POST",
  710. data:{
  711. id:order_id,
  712. status:status,
  713. "_token":"{!! csrf_token() !!}"
  714. },
  715. success:function () {
  716. //alert();
  717. $(".mlist_li.selected").remove();
  718. $(".no-order").show();
  719. $(".order-section").hide();
  720. $.ajax({
  721. url: "{!! env('APP_URL') !!}order/counts",
  722. success: function (response) {
  723. // response = $.parseJSON(response);
  724. var total_accepted = 0;
  725. var total = 0;
  726. $.each(response,function (i,v) {
  727. if(v.status=="Send_to_Kitchen" || v.status=="Accepted"){
  728. total_accepted+=parseInt(v.status_count);
  729. total+=parseInt(v.status_count);
  730. $(".labelcenter.kitchen").text(total_accepted);
  731. }
  732. if(v.status=="On_Road"){
  733. $(".labelcenter.route").text(v.status_count);
  734. total+=parseInt(v.status_count);
  735. }
  736. if(v.status=="Placed"){
  737. $(".labelcenter.new").html(v.status_count);
  738. total+=parseInt(v.status_count);
  739. if(parseInt(v.status_count) > 0){
  740. $("#order-counter").html(v.status_count);
  741. $("#order-counter").show();
  742. }else{
  743. audio.pause();
  744. $("#order-counter").html(0);
  745. $("#order-counter").hide();
  746. }
  747. }
  748. });
  749. $(".labelcenter.all").text(total);
  750. }
  751. });
  752. // swal("Rejected!", "Order is rejected.", "success");
  753. }
  754. });
  755. });
  756. return false;
  757. }
  758. if(status=="Accepted"){
  759. $("#accept-modal").modal('show');
  760. return false;
  761. }
  762. // alert(order_id);
  763. $.ajax({
  764. url:"{!! env('APP_URL') !!}update/order/status",
  765. type:"POST",
  766. data:{
  767. id:order_id,
  768. status:status,
  769. "_token":"{!! csrf_token() !!}"
  770. },
  771. success:function () {
  772. $(".mlist_li.selected").remove();
  773. if(s=="all"){
  774. $("#orders-list").html('');
  775. /* $.ajax({
  776. url:"{!! env('APP_URL') !!}liveorders/all",
  777. success:function (response) {
  778. // response = $.parseJSON(response);
  779. if(response){
  780. $.each(response.orders,function (i,v) {
  781. var str='<li class="mlist_li" rel="detail" data-order-id="'+v.id+'">\n' +
  782. ' <div class="box '+v.box_bg+' rounded-0">\n' +
  783. ' <div class="media-list media-list-divided media-list-hover">\n' +
  784. ' <div class="media align-items-center">\n' +
  785. ' <div class="media-body">\n' +
  786. ' <p>#'+v.order_ref+'</p>\n' +
  787. ' <p> '+(v.campaign_type!=""?v.campaign_type:"Direct")+', '+v.created_at+'</p>\n' +
  788. ' </div>\n' +
  789. ' <div class="media-right gap-items">\n' +
  790. ' <div class="user-social-acount text-center">\n' +
  791. ' <p class="m-0 status">'+v.status+'</p>\n' +
  792. ' <div class="d-flex align-items-center float-end">\n' +
  793. ' <div class="circle-div '+v.bg+' text-center" data-min="'+v.remaining_min+'" data-color="'+v.bg_color+'">\n' +
  794. ' <p class="mb-5 min">'+v.remaining_min+'<br />\n'+
  795. ' Min</p>\n'+
  796. ' </div>\n' +
  797. ' </div>\n' +
  798. ' </div>\n' +
  799. ' </div>\n' +
  800. ' </div>\n' +
  801. ' </div>\n' +
  802. ' </div>\n' +
  803. '</li>';
  804. counter = counter+1;
  805. $("#orders-list").append(str);
  806. });
  807. $("span."+status).html(counter);
  808. }
  809. }
  810. });*/
  811. }
  812. $(".no-order").show();
  813. $(".order-section").hide();
  814. /*$.ajax({
  815. url: "{!! env('APP_URL') !!}order/counts",
  816. success: function (response) {
  817. // response = $.parseJSON(response);
  818. var total_accepted = 0;
  819. var total = 0;
  820. $.each(response,function (i,v) {
  821. if(v.status=="Send_to_Kitchen" || v.status=="Accepted"){
  822. total_accepted+=parseInt(v.status_count);
  823. total+=parseInt(v.status_count);
  824. $(".labelcenter.kitchen").text(total_accepted);
  825. }
  826. if(v.status=="On_Road"){
  827. $(".labelcenter.route").text(v.status_count);
  828. total+=parseInt(v.status_count);
  829. }
  830. if(v.status=="Placed"){
  831. $(".labelcenter.new").text(v.status_count);
  832. total+=parseInt(v.status_count);
  833. }
  834. });
  835. $(".labelcenter.all").text(total);
  836. }
  837. });*/
  838. }
  839. });
  840. e.preventDefault();
  841. e.stopPropagation();
  842. });
  843. $('.table').DataTable({
  844. "order": [[ 0, "desc" ]],
  845. 'paging' : true,
  846. 'lengthChange': true,
  847. 'searching' : true,
  848. 'ordering' : true,
  849. 'info' : true,
  850. 'autoWidth' : true,
  851. /*"processing": true,
  852. "serverSide": true,
  853. "ajax": "{!! env('APP_URL') !!}get/ajax/orders",
  854. "order": [[ 0, "desc", ]],*/
  855. "lengthMenu": [ 50, 100, 150 ]
  856. });
  857. var min_minus = 1;
  858. setInterval(function(){
  859. $(".circle-div").each(function (i,v) {
  860. var min = parseInt($(this).data('min'));
  861. if((min)>0){
  862. var new_time = (min-min_minus);
  863. $(this).attr('data-min',new_time);
  864. $(this).find('p.min').html(new_time+"<br />Min");
  865. }
  866. });
  867. min_minus++;
  868. },60000);
  869. })
  870. function show_recipe(recipe){
  871. return str='<div class="box-header border-1 ">\n' +
  872. ' <div class="ml-5">\n' +
  873. ' <div class="d-flex justify-content-between align-items-center">\n' +
  874. ' <p>'+recipe.quantity+'x '+recipe.recipe_name+'</p>\n' +
  875. ' <p>IQD '+recipe.total_price+'</p>\n' +
  876. ' </div>\n' +
  877. ' </div>\n' +
  878. ' </div>';
  879. }
  880. </script>
  881. @endsection