resto_dashboard.blade.php_bk 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291
  1. @extends('layouts.app')
  2. @section('content')
  3. @php
  4. $resto = isset(\Illuminate\Support\Facades\Auth::user()->restaurants)?\Illuminate\Support\Facades\Auth::user()->restaurants:NULL;
  5. @endphp
  6. <!-- Content Wrapper. Contains page content -->
  7. <div class="content-wrapper">
  8. <div class="container-full">
  9. <!-- Main content -->
  10. <section class="content">
  11. <div class="row">
  12. <div class="col-xxxl-3 col-lg-6 col-12">
  13. <div class="box">
  14. <div class="box-body">
  15. <div class="d-flex align-items-start">
  16. <div>
  17. <img src="{!! env('APP_ASSETS') !!}images/food/online-order-1.png" class="w-80 me-20" alt="" />
  18. </div>
  19. <div>
  20. <h2 class="my-0 fw-700">{!! isset($resto)?($resto->orders->count()):0; !!}</h2>
  21. <p class="text-fade mb-0">Total Order</p>
  22. {{--<p class="fs-12 mb-0 text-success"><span class="badge badge-pill badge-success-light me-5"><i class="fa fa-arrow-up"></i></span>3% (15 Days)</p>--}}
  23. </div>
  24. </div>
  25. </div>
  26. </div>
  27. </div>
  28. <div class="col-xxxl-3 col-lg-6 col-12">
  29. <div class="box">
  30. <div class="box-body">
  31. <div class="d-flex align-items-start">
  32. <div>
  33. <img src="{!! env('APP_ASSETS') !!}images/food/online-order-2.png" class="w-80 me-20" alt="" />
  34. </div>
  35. <div>
  36. <h2 class="my-0 fw-700">{!! isset($resto)?($resto->delivered_orders->count()):0; !!}</h2>
  37. <p class="text-fade mb-0">Total Delivered</p>
  38. {{-- <p class="fs-12 mb-0 text-success"><span class="badge badge-pill badge-success-light me-5"><i class="fa fa-arrow-up"></i></span>8% (15 Days)</p>--}}
  39. </div>
  40. </div>
  41. </div>
  42. </div>
  43. </div>
  44. <div class="col-xxxl-3 col-lg-6 col-12">
  45. <div class="box">
  46. <div class="box-body">
  47. <div class="d-flex align-items-start">
  48. <div>
  49. <img src="{!! env('APP_ASSETS') !!}images/food/online-order-3.png" class="w-80 me-20" alt="" />
  50. </div>
  51. <div>
  52. <h2 class="my-0 fw-700">{!! isset($resto)?($resto->cancelled_by_customer_orders->count()):0; !!}</h2>
  53. <p class="text-fade mb-0">Total Cancelled</p>
  54. {{-- <p class="fs-12 mb-0 text-primary"><span class="badge badge-pill badge-primary-light me-5"><i class="fa fa-arrow-down"></i></span>2% (15 Days)</p>--}}
  55. </div>
  56. </div>
  57. </div>
  58. </div>
  59. </div>
  60. <div class="col-xxxl-3 col-lg-6 col-12">
  61. <div class="box">
  62. <div class="box-body">
  63. <div class="d-flex align-items-start">
  64. <div>
  65. <img src="{!! env('APP_ASSETS') !!}images/food/online-order-4.png" class="w-80 me-20" alt="" />
  66. </div>
  67. <div>
  68. @php
  69. $totalRevenue = \App\Restaurants::totalRevenue($resto->id);
  70. $last7DaysData = \App\Restaurants::totalRevenueLast7Days($resto->id);
  71. $last7DaysDataCount = \App\Restaurants::totalCountRevenue($resto->id);
  72. $totalOnlineOrders = \App\Restaurants::totalOnlineOrders($resto->id);
  73. $totalOnlineOrders7Days = \App\Restaurants::totalOnlineOrdersLast7Days($resto->id);
  74. $totalCountOnlineOrders7Days = \App\Restaurants::totalCountOnlineOrdersLast7Days($resto->id);
  75. $last7DaysData = isset($last7DaysData)?$last7DaysData:NULL;
  76. @endphp
  77. <h2 class="my-0 fw-700">IQD {!! isset($totalRevenue)?number_format($totalRevenue[0]->total_price):0 !!}</h2>
  78. <p class="text-fade mb-0">Total Revenue</p>
  79. {{-- <p class="fs-12 mb-0 text-primary"><span class="badge badge-pill badge-primary-light me-5"><i class="fa fa-arrow-down"></i></span>12% (15 Days)</p>--}}
  80. </div>
  81. </div>
  82. </div>
  83. </div>
  84. </div>
  85. <div class="col-xxxl-7 col-xl-6 col-lg-6 col-12">
  86. <div class="box">
  87. <div class="box-body">
  88. <div class="d-flex justify-content-between">
  89. <div>
  90. <h4 class="box-title mb-0">Daily Revenue</h4>
  91. </div>
  92. <div class="text-end">
  93. <h3 class="box-title mb-0 fw-700">IQD {!! isset($last7DaysDataCount)?number_format($last7DaysDataCount[0]->total_price):0 !!}</h3>
  94. </div>
  95. </div>
  96. <div id="chart" class="mt-20"></div>
  97. </div>
  98. </div>
  99. </div>
  100. <div class="col-xxxl-5 col-xl-6 col-lg-6 col-12">
  101. <div class="box">
  102. <div class="box-body">
  103. <h4 class="box-title mb-1">Customer Flow</h4>
  104. <div class="d-md-flex d-block justify-content-between">
  105. <div>
  106. <h3 class="mb-0 mt-0 fw-700">{!! isset($totalCountOnlineOrders7Days)?$totalCountOnlineOrders7Days[0]['total_orders']:0 !!}</h3>
  107. <p class="mb-0 text-danger"><small>Online Order</small></p>
  108. </div>
  109. </div>
  110. <div id="yearly-comparison"></div>
  111. </div>
  112. </div>
  113. </div>
  114. </div>
  115. </section>
  116. <!-- /.content -->
  117. </div>
  118. </div>
  119. <!-- /.content-wrapper -->
  120. @endsection
  121. @section('js')
  122. <script src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.8.0/Chart.min.js" crossorigin="anonymous"></script>
  123. <!-- Chart Js -->
  124. <!-- Datatable Js -->
  125. <script>
  126. var resto_id = 0;
  127. $(function () {
  128. var data = '{!! $last7DaysData !!}';
  129. var order_data = '{!! $totalOnlineOrders7Days !!}';
  130. data = $.parseJSON(data);
  131. order_data = $.parseJSON(order_data);
  132. var days = [];
  133. var sale = [];
  134. $.each(data,function (i,v) {
  135. days.push(v.day_name);
  136. sale.push(v.total_price);
  137. });
  138. var order_days = [];
  139. var orders = [];
  140. $.each(order_data,function (i,v) {
  141. order_days.push(v.day_name);
  142. orders.push(v.total_orders);
  143. });
  144. $("body").on('click','.delete-recipe',function () {
  145. var id = $(this).data('id');
  146. $.ajax({
  147. url:"{!! env('APP_URL') !!}recipe/delete/"+id,
  148. success:function (response) {
  149. location.reload();
  150. }
  151. });
  152. });
  153. // var data = ["200,500,500,600,290,12,80"];
  154. var options = {
  155. series: [{
  156. name: 'Revenue',
  157. data: sale
  158. }],
  159. chart: {
  160. height: 350,
  161. type: 'area',
  162. zoom: {
  163. enabled: false
  164. },
  165. },
  166. colors: ["#4c95dd"],
  167. dataLabels: {
  168. enabled: false
  169. },
  170. stroke: {
  171. curve: 'smooth'
  172. },
  173. xaxis: {
  174. categories: days
  175. },
  176. tooltip: {
  177. y: {
  178. formatter: function (val) {
  179. return "IQD " + val + " "
  180. }
  181. },
  182. },
  183. };
  184. var chart = new ApexCharts(document.querySelector("#chart"), options);
  185. chart.render();
  186. console.log(order_data);
  187. var options = {
  188. chart: {
  189. height: 325,
  190. type: 'bar',
  191. toolbar: {
  192. show: false
  193. },
  194. },
  195. plotOptions: {
  196. bar: {
  197. horizontal: false,
  198. endingShape: 'rounded',
  199. columnWidth: '65%',
  200. },
  201. },
  202. dataLabels: {
  203. enabled: false
  204. },
  205. stroke: {
  206. show: true,
  207. width: 5,
  208. colors: ['transparent']
  209. },
  210. colors: ["#e66430"],
  211. series: [ {
  212. name: 'Online Order',
  213. data: orders
  214. }],
  215. xaxis: {
  216. categories: order_days,
  217. axisBorder: {
  218. show: true,
  219. color: '#bec7e0',
  220. },
  221. axisTicks: {
  222. show: true,
  223. color: '#bec7e0',
  224. },
  225. },
  226. legend: {
  227. show: false,
  228. },
  229. fill: {
  230. opacity: 1
  231. },
  232. grid: {
  233. row: {
  234. colors: ['transparent'], // takes an array which will be repeated on columns
  235. opacity: 0.2
  236. },
  237. borderColor: '#f1f3fa'
  238. },
  239. tooltip: {
  240. y: {
  241. formatter: function (val) {
  242. return + val + " Orders"
  243. }
  244. }
  245. }
  246. }
  247. var chart = new ApexCharts(
  248. document.querySelector("#yearly-comparison"),
  249. options
  250. );
  251. chart.render();
  252. })
  253. </script>
  254. @endsection