app.blade.php 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505
  1. @php
  2. $resto_rtl = \App\Models\Restaurants::find(\App\Helpers\CommonMethods::getRestuarantID());
  3. $lang = $resto_rtl->default_lang;
  4. if(!empty($resto_rtl->time_zone)){
  5. config(['app.timezone' => $resto_rtl->time_zone]);
  6. date_default_timezone_set($resto_rtl->time_zone);
  7. // dd(\Carbon\Carbon::now()->format('Y-m-d H:i:s'));
  8. }
  9. app()->setLocale($lang);
  10. if(session('app_lang') !==null){
  11. $lang = session('app_lang');
  12. app()->setLocale($lang);
  13. }
  14. if(\Illuminate\Support\Facades\Auth::user()->role=="administrator" || \Illuminate\Support\Facades\Auth::user()->role=="admin_user")
  15. $lang="en";
  16. @endphp
  17. <!DOCTYPE html>
  18. @if($lang=="ar")
  19. <!--<html lang="ar" dir="rtl">-->
  20. <html lang="ar" dir="rtl">
  21. @else
  22. <html lang="en">
  23. @endif
  24. <meta charset="utf-8" />
  25. <meta http-equiv="X-UA-Compatible" content="IE=edge" />
  26. <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no" />
  27. <!--<title> {!! env('APP_NAME') !!} @yield('page-title')</title>-->
  28. <title> {!! env('APP_NAME') !!} </title>
  29. <meta property="og:type" content="website" />
  30. <!-- Favicon Icon -->
  31. <link rel="icon" type="image/png" href="{!! env('APP_ASSETS') !!}images/{!! env('FAV_ICON') !!}">
  32. <link rel="apple-touch-icon" href="{!! env('APP_ASSETS') !!}images/{!! env('FAV_ICON') !!}">
  33. <link rel="shortcut icon" href="{!! env('APP_ASSETS') !!}images/{!! env('FAV_ICON') !!}">
  34. <!-- Feather Icon-->
  35. <link href="{!! env('APP_ASSETS') !!}css/vendors_css.css" rel="stylesheet" type="text/css">
  36. <!-- Fontawesome Icon-->
  37. <!-- <link href="{!! env('APP_ASSETS') !!}css/style.css" rel="stylesheet" type="text/css">-->
  38. <link href="{!! env('APP_ASSETS') !!}css/style_new.css?v=1.5" rel="stylesheet" type="text/css">
  39. {{--
  40. <link href="{!! env('APP_ASSETS') !!}css/style_rtl.css" rel="stylesheet" type="text/css">--}}
  41. <!-- Bootstrap Css -->
  42. <link href="{!! env('APP_ASSETS') !!}css/skin_color.css" rel="stylesheet"><!-- Custom Css -->
  43. <link href="{!! env('APP_ASSETS') !!}css/sidebar-new.css?v=1.5" rel="stylesheet" type="text/css">
  44. <link href="{!! env('APP_ASSETS') !!}css/admin_ar.css" rel="stylesheet" type="text/css">
  45. <link href="{!! env('APP_ASSETS') !!}vendor_components/sweetalert/sweetalert.css" rel="stylesheet" type="text/css">
  46. <link href="{!! env('APP_ASSETS') !!}css/responsive.css" rel="stylesheet" type="text/css">
  47. <link href="{!! env('APP_ASSETS') !!}css/responsive_ar.css" rel="stylesheet" type="text/css">
  48. <link href="{!! env('APP_ASSETS') !!}vendor_components/jquery-toast-plugin-master/src/jquery.toast.css" rel="stylesheet" type="text/css">
  49. @yield('css')
  50. <style>
  51. @include('inc.dashboard_css')
  52. </style>
  53. </head>
  54. <body class="light-skin sidebar-mini theme-primary fixed">
  55. <div class="wrapper">
  56. <div id="loader"></div>
  57. @include('inc.header')
  58. @if(\Illuminate\Support\Facades\Auth::user()->role=="administrator")
  59. @include('inc.sidebar_admin')
  60. @elseif(\Illuminate\Support\Facades\Auth::user()->role=="resto_user")
  61. @include('inc.sidebar_resto_user')
  62. @elseif(\Illuminate\Support\Facades\Auth::user()->role=="admin_user")
  63. @include('inc.sidebar_admin_users')
  64. @else
  65. @include('inc.sidebar_resto')
  66. @endif
  67. @yield('content')
  68. @php
  69. if(\Illuminate\Support\Facades\Auth::user()->role=="restaurant"){
  70. $placed_order = false;
  71. $recent_till = \Carbon\Carbon::now()->subDays(2)->format('Y-m-d');;
  72. $one_order = \Illuminate\Support\Facades\Auth::user()->restaurants->id;
  73. $order1 = \App\Models\Orders::where('status','Placed')->where('resto_id',$one_order)->where('created_at','>=',$recent_till)->first();
  74. if(isset($order1) && $order1->status=="Placed"){
  75. $placed_order = true;
  76. }
  77. //dump($order);
  78. }
  79. @endphp
  80. {{-- @include('inc.sidebar_resto_right')--}}
  81. {{--<footer class="main-footer" style="font-size: 10px">
  82. <video controls="controls" src="{!! env('APP_URL') !!}/1sec.avi" muted autoplay loop style="display:none">
  83. Your browser does not support the HTML5 Video element.
  84. </video>
  85. <img src="{!! env('APP_ASSETS') !!}images/favicon.png" height="18" /> meem powered by <img src="{!! env('APP_ASSETS') !!}images/taiftec.png" height="16" />
  86. </footer>--}}
  87. <input type="button" id="toggle" value="Wake Lock is disabled" style="display:none"/>
  88. </div>
  89. </body>
  90. <script src="{!! env('APP_ASSETS') !!}js/vendors.min.js"></script>
  91. <script src="{!! env('APP_ASSETS') !!}js/pages/chat-popup.js"></script>
  92. <script src="{!! env('APP_ASSETS') !!}icons/feather-icons/feather.min.js"></script>
  93. <script src="{!! env('APP_ASSETS') !!}vendor_components/progressbar.js-master/dist/progressbar.js"></script>
  94. <script src="{!! env('APP_ASSETS') !!}vendor_components/OwlCarousel2/dist/owl.carousel.js"></script>
  95. <script src="{!! env('APP_ASSETS') !!}vendor_components/datatable/datatables.min.js"></script>
  96. <script src="{!! env('APP_ASSETS') !!}vendor_components/jquery-toast-plugin-master/src/jquery.toast.js"></script>
  97. <script src="{!! env('APP_ASSETS') !!}vendor_components/sweetalert/sweetalert.min.js"></script>
  98. <script src="{!! env('APP_ASSETS') !!}js/printThis.js"></script>
  99. <script src="{!! env('APP_ASSETS') !!}js/jquery.uploadPreview.js"></script>
  100. <script type="text/javascript" src="{!! env('APP_ASSETS') !!}js/moment.min.js"></script>
  101. <script src="{!! env('APP_ASSETS') !!}js/jquery.validate.min.js"></script>
  102. <script src="{!! env('APP_ASSETS') !!}js/jquery.form.js"></script>
  103. <script src="{!! env('APP_ASSETS') !!}js/NoSleep.min.js"></script>
  104. <!-- Riday Admin App -->
  105. <script src="//js.pusher.com/3.1/pusher.min.js"></script>
  106. <script src="{!! env('APP_ASSETS') !!}js/template.js"></script>
  107. <script type="text/javascript">
  108. var progress_img = '<img src="{!! env('APP_ASSETS') !!}images/preloader-1.svg" style="height: 25px;">';
  109. </script>
  110. <script>
  111. //screen.orientation.lock('');
  112. nosleep();
  113. function nosleep()
  114. {
  115. var noSleep = new NoSleep();
  116. noSleep.enable();
  117. }
  118. </script>
  119. <!-- AUDIO.JS -->
  120. <script type="text/javascript">
  121. const CACHE_NAME = "audioCache";
  122. const FILE_NAME = 'https://admin.meemapp.net/notif-order.mp3';
  123. (function main(){
  124. updateStatus();
  125. })();
  126. // Update the status field
  127. function updateStatus() {
  128. isCached().then(value => {
  129. });
  130. }
  131. function isCached() {
  132. return window.caches.open(CACHE_NAME)
  133. .then(cache => cache.match(FILE_NAME))
  134. .then(Boolean);
  135. }
  136. function addToCache() {
  137. window.caches.open(CACHE_NAME)
  138. .then(cache => cache.add(FILE_NAME))
  139. .then(() => console.log('cached audio file'))
  140. .catch(e => console.error('failed to cache file', e))
  141. .finally(updateStatus); // This only works in chrome/ff at the time of writing
  142. }
  143. function removeFromCache() {
  144. window.caches.open(CACHE_NAME)
  145. .then(cache => cache.delete(FILE_NAME))
  146. .then(() => console.log('removed cached file'))
  147. .catch(e => console.error('failed to remove cached file', e))
  148. .finally(updateStatus); // This only works in chrome/ff at the time of writing
  149. }
  150. </script>
  151. <script>
  152. if ('serviceWorker' in navigator) {
  153. var file = "{!! env('APP_ASSETS') !!}js/audio_cache_sw.js"
  154. navigator.serviceWorker.register(file)
  155. .then(function(reg) {
  156. console.log('Registration succeeded.');
  157. }).catch(function(error) {
  158. console.log('Registration failed with ' + error);
  159. });
  160. }
  161. </script>
  162. <!-- END AUDIO.JS -->
  163. <script>
  164. /*let src = "https://admin.meemapp.net/notif-order.mp3";
  165. let audio = new Audio(src);
  166. audio.loop = true;
  167. audio.play();
  168. */
  169. addToCache();
  170. var timeFormat = function(datetime){
  171. var time =datetime;
  172. var date = new Date(time);
  173. date = date.getFullYear()+"-"+date.getMonth()+"-"+date.getDate()+" "+date.getHours()+":"+date.getMinutes()+":"+date.getMilliseconds();
  174. return date;
  175. };
  176. var logged_user = "{!! \Illuminate\Support\Facades\Auth::user()->role=="restaurant" && isset(\Illuminate\Support\Facades\Auth::user()->restaurants)?\Illuminate\Support\Facades\Auth::user()->restaurants->id:NULL !!}";
  177. var site_url = "{!! env('APP_URL') !!}";
  178. logged_user = parseInt(logged_user);
  179. $(function () {
  180. $('[data-toggle="tooltip"]').tooltip();
  181. // $('#dataTable').DataTable();
  182. $("body").on("click",".notifications",function () {
  183. $.ajax({
  184. url:"{!! env('APP_URL') !!}read/notifications",
  185. success:function (response) {
  186. $(".badge-counter").attr("data-count",0);
  187. $(".badge-counter").html("");
  188. }
  189. });
  190. });
  191. })
  192. </script>
  193. <script>
  194. let src = "{!! env('APP_URL') !!}notif-order.mp3";
  195. let audio = new Audio(src);
  196. audio.loop = true;
  197. @if(\Illuminate\Support\Facades\Auth::user()->role=="restaurant")
  198. @if(Route::currentRouteName()=="OrderListing" || $placed_order)
  199. @if((isset($is_pending_order) && !empty($is_pending_order)) || $placed_order)
  200. audio.play();
  201. @endif
  202. @endif
  203. @endif
  204. var pusher = new Pusher('{{env("PUSHER_APP_KEY")}}', {
  205. cluster: '{{env("PUSHER_APP_CLUSTER")}}',
  206. encrypted: true
  207. });
  208. var notification_counter = parseInt($(".badge-counter").data('count'));
  209. var new_order_count = parseInt($("#order-counter").html());
  210. if(new_order_count=="")
  211. new_order_count = 0;
  212. var channel = pusher.subscribe("{!! env('PUHER_APP_CHANNEL') !!}");
  213. channel.bind('App\\Events\\OrderNotification', function(data) {
  214. console.log('data');
  215. console.log(data);
  216. console.log('notification: '+data.notification_for);
  217. var order_resto_id = parseInt(data.order_resto_id);
  218. if(data.notification_for=="delivered-order-status")
  219. order_resto_id = parseInt(data.resto_id);
  220. if(order_resto_id==logged_user && (data.notification_for=="update-order-status" || data.notification_for=="delivered-order-status")){
  221. var order_id = data.order_id;
  222. if(data.notification_for=="delivered-order-status")
  223. order_id = parseInt(data.resto_id);
  224. console.log("update-roder-status : OrderID: "+data.order_id);
  225. $(".order-section").hide();
  226. $(".no-order").show();
  227. // location.reload();
  228. audio.pause();
  229. // $("#orders-list").html('');
  230. var after_pusher_status = $(".nav-link.active").data('status');
  231. if(after_pusher_status && after_pusher_status=="")
  232. after_pusher_status = "all";
  233. $("#all-orders").removeClass('no-order-found');
  234. $(".mlist_li[data-order-id="+data.order_id+"]").remove();
  235. count_order_status();
  236. $(".mlist_li[data-order-id="+data.order_id+"]").remove();
  237. }
  238. var resto_id = parseInt(data.resto_id);
  239. if(resto_id==logged_user){
  240. $("#all-orders").removeClass('no-order-found');
  241. if(data.notification_for!="delivered-order-status")
  242. audio.play();
  243. var new_order = (data.order_data);
  244. var v = new_order;
  245. var li = '<li class="mlist_li" rel="detail" data-order-id="'+v.id+'">\n' +
  246. ' <div class="box bg-danger rounded-0">\n' +
  247. ' <div class="media-list media-list-divided media-list-hover">\n' +
  248. ' <div class="media align-items-center">\n' +
  249. ' <div class="media-body">\n' +
  250. ' <p>#'+v.order_ref+'</p>\n' +
  251. ' <p> '+(v.campaign_type?v.campaign_type:"Direct")+', Just now</p>\n' +
  252. ' </div>\n' +
  253. ' <div class="media-right gap-items">\n' +
  254. ' <div class="user-social-acount text-center">\n' +
  255. ' <p class="m-0 status">New</p>\n' +
  256. ' <div class="d-flex align-items-center float-end">\n' +
  257. ' <div class="circle-div blu-bg text-center">\n' +
  258. ' <p class="mb-5 min">0<br />\n' +
  259. ' Min</p>\n' +
  260. ' </div>\n' +
  261. ' </div>\n' +
  262. ' </div>\n' +
  263. ' </div>\n' +
  264. ' </div>\n' +
  265. ' </div>\n' +
  266. ' </div>\n' +
  267. '</li>';
  268. /* var action_list = '<div class="btn-group">\n' +
  269. ' <a class="hover-primary dropdown-toggle no-caret" data-bs-toggle="dropdown"><i class="fa fa-ellipsis-h"></i></a>\n' +
  270. ' <div class="dropdown-menu">\n' +
  271. ' <a class="dropdown-item order-status" href="#!" data-id="'+new_order.id+'" data-status="Accepted">Accepted</a>\n' +
  272. ' <a class="dropdown-item order-status" href="#!" data-id="'+new_order.id+'" data-status="Rejected">Rejected</a>\n' +
  273. ' <a class="dropdown-item order-status" href="#!" data-id="'+new_order.id+'" data-status="Rejected_by_User">Rejected by User</a>\n' +
  274. ' \n' +
  275. ' </div>\n' +
  276. ' </div>';
  277. var row = '<tr class="special order-row" data-id="'+new_order.id+'">';
  278. row+='<td>'+new_order.order_ref+'</td>';
  279. row+='<td>'+timeFormat(new_order.created_at)+'</td>';
  280. row+='<td>'+new_order.customer_name+'</td>';
  281. row+='<td>'+ data.customer_mobile+ '</td>';
  282. row+='<td>'+data.customer_location+'</td>';
  283. row+='<td>'+new_order.order_type+'</td>';
  284. // row+='<td>'+new_order.campaign_name+'</td>';
  285. // row+='<td>'+new_order.campaign_date+'</td>';
  286. row+='<td>'+new_order.campaign_type+'</td>';
  287. row+='<td>'+data.total_price+'</td>';
  288. /!* row+='<td>'+(new_order.order_deliver_time?new_order.order_deliver_time:"(اقرب وقت)\t")+'</td>';*!/
  289. row+='<td><span class="badge badge-info-light">Placed</span></td>';
  290. row+='<td>'+action_list+'</td>';
  291. row+='</tr>';*/
  292. // $.ajax({
  293. // url: "{!! env('APP_URL') !!}order/counts",
  294. // success: function (response) {
  295. // // response = $.parseJSON(response);
  296. // var total_accepted = 0;
  297. // var total = 0;
  298. //
  299. // $.each(response,function (i,v) {
  300. // if(v.status=="Send_to_Kitchen" || v.status=="Accepted"){
  301. // total_accepted+=parseInt(v.status_count);
  302. // total+=parseInt(v.status_count);
  303. // $(".labelcenter.kitchen").text(total_accepted);
  304. // }
  305. //
  306. // if(v.status=="On_Road"){
  307. // $(".labelcenter.route").text(v.status_count);
  308. // total+=parseInt(v.status_count);
  309. // }
  310. //
  311. // if(v.status=="Placed"){
  312. // $(".labelcenter.new").text(v.status_count);
  313. // total+=parseInt(v.status_count);
  314. // if(parseInt(v.status_count) > 0){
  315. // $("#order-counter").html(v.status_count);
  316. // $("#order-counter").show();
  317. // }
  318. //
  319. // }
  320. //
  321. // });
  322. // $(".labelcenter.all").text(total);
  323. // }
  324. // });
  325. count_order_status();
  326. @if(\Illuminate\Support\Facades\Auth::user()->role=="restaurant")
  327. @if(Route::currentRouteName()=="OrderListing")
  328. if(data.notification_for!="delivered-order-status")
  329. $("#orders-list").prepend(li);
  330. @endif
  331. @endif
  332. // $("#new-order-tables tbody").prepend(row);
  333. // $("#new-orders-modal").modal();
  334. setTimeout(function () {
  335. $("#new-orders-modal").modal('hide');
  336. },30000);
  337. var notification = '<li>\n' +
  338. ' <a href="{!! env('APP_URL') !!}order/show/'+data.order_id+'">\n' +
  339. ' <i class="fa fa-users text-info"></i> '+data.message+'.\n' +
  340. ' </a>\n' +
  341. ' </li>';
  342. $("#notifications").prepend(notification);
  343. notification_counter += 1;
  344. new_order_count += 1;
  345. $(".badge-counter").attr('data-count',notification_counter);
  346. $(".badge-counter").html(notification_counter);
  347. $("#order-counter").html(new_order_count);
  348. $("#order-counter").show();
  349. }
  350. });
  351. $("body").on("click",".push-btn",function () {
  352. $(".main-sidebar").toggleClass('sidebar-active')
  353. });
  354. $("body").on("click",".change-lang",function () {
  355. var _lang = $(this).data('lang');
  356. $.ajax({
  357. url:"{!! env('APP_URL') !!}change/lang/"+_lang,
  358. success:function(){
  359. location.reload();
  360. }
  361. });
  362. });
  363. function count_order_status(){
  364. $.ajax({
  365. url: "{!! env('APP_URL') !!}order/counts",
  366. success: function (response) {
  367. // response = $.parseJSON(response);
  368. var total_accepted = 0;
  369. var total = 0;
  370. $.each(response,function (i,v) {
  371. if(v.status=="Send_to_Kitchen" || v.status=="Accepted"){
  372. total_accepted+=parseInt(v.status_count);
  373. total+=parseInt(v.status_count);
  374. $(".labelcenter.kitchen").text(total_accepted);
  375. }
  376. if(v.status=="On_Road"){
  377. $(".labelcenter.route").text(v.status_count);
  378. total+=parseInt(v.status_count);
  379. }
  380. if(v.status=="Placed"){
  381. $(".labelcenter.new").text(v.status_count);
  382. total+=parseInt(v.status_count);
  383. if(parseInt(v.status_count) > 0){
  384. $("#order-counter").html(v.status_count);
  385. $("#order-counter").show();
  386. }else{
  387. $("#order-counter").hide();
  388. }
  389. }
  390. });
  391. $(".labelcenter.all").text(total);
  392. }
  393. });
  394. }
  395. </script>
  396. </html>
  397. @yield('js')