accounting.blade.php 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164
  1. @extends('admin.layouts')
  2. @section('content')
  3. <div class="page-content container">
  4. <div class="card card-shadow">
  5. <div class="card-block p-30">
  6. <div class="row pb-20">
  7. <div class="col-md-8 col-sm-6">
  8. <div class="blue-grey-700 font-size-26 font-weight-500">{{ trans('admin.report.daily_accounting') }}</div>
  9. </div>
  10. </div>
  11. <canvas id="days"></canvas>
  12. </div>
  13. </div>
  14. <div class="card card-shadow">
  15. <div class="card-block p-30">
  16. <div class="row pb-20">
  17. <div class="col-md-8 col-sm-6">
  18. <div class="blue-grey-700 font-size-26 font-weight-500">{{ trans('admin.report.monthly_accounting') }}</div>
  19. </div>
  20. </div>
  21. <canvas id="months"></canvas>
  22. </div>
  23. </div>
  24. <div class="card card-shadow">
  25. <div class="card-block p-30">
  26. <div class="row pb-20">
  27. <div class="col-md-8 col-sm-6">
  28. <div class="blue-grey-700 font-size-26 font-weight-500">{{ trans('admin.report.annually_accounting') }}</div>
  29. </div>
  30. </div>
  31. <canvas id="years"></canvas>
  32. </div>
  33. </div>
  34. </div>
  35. @endsection
  36. @section('javascript')
  37. <script src="/assets/global/vendor/chart-js/chart.umd.min.js"></script>
  38. <script type="text/javascript">
  39. function label_callbacks(tail) {
  40. return {
  41. mode: 'index',
  42. intersect: false,
  43. callbacks: {
  44. title: function(context) {
  45. return context[0].label + tail;
  46. },
  47. label: function(context) {
  48. let label = context.dataset.label || '';
  49. if (label) {
  50. label += ': ';
  51. }
  52. if (context.parsed.y !== null) {
  53. label += new Intl.NumberFormat('{{ str_replace('_', '-', app()->getLocale()) }}', {
  54. style: 'currency',
  55. currency: '{{ sysConfig('standard_currency') }}',
  56. }).format(context.parsed.y);
  57. }
  58. return label;
  59. },
  60. },
  61. };
  62. }
  63. function common_options(label) {
  64. return {
  65. responsive: true,
  66. scales: {
  67. x: {
  68. grid: {
  69. display: false
  70. }
  71. },
  72. y: {
  73. grid: {
  74. display: false
  75. },
  76. min: 0
  77. },
  78. },
  79. plugins: {
  80. legend: {
  81. labels: {
  82. padding: 20,
  83. usePointStyle: true,
  84. pointStyle: 'circle',
  85. font: {
  86. size: 14
  87. },
  88. },
  89. },
  90. tooltip: label_callbacks(label || ''),
  91. },
  92. };
  93. }
  94. function area(label, data, backgroundColor, aboveColor) {
  95. return {
  96. label: label,
  97. backgroundColor: backgroundColor,
  98. borderColor: backgroundColor,
  99. data: data,
  100. fill: {
  101. target: 'origin',
  102. above: aboveColor
  103. },
  104. tension: 0.4,
  105. };
  106. }
  107. new Chart(document.getElementById('days'), {
  108. type: 'line',
  109. data: {
  110. labels: @json($data['days']),
  111. datasets: [
  112. area('{{ trans('admin.report.current_month') }}', @json($data['currentMonth']), 'rgba(184, 215, 255)', 'rgba(184, 215, 255, 0.5)'),
  113. area('{{ trans('admin.report.last_month') }} ', @json($data['lastMonth']), 'rgba(146, 240, 230)', 'rgba(146, 240, 230, 0.5)')
  114. ],
  115. },
  116. options: common_options(' {{ trans_choice('common.days.attribute', 2) }}'),
  117. });
  118. new Chart(document.getElementById('months'), {
  119. type: 'line',
  120. data: {
  121. labels: @json($data['months']),
  122. datasets: [
  123. area('{{ trans('admin.report.current_year') }}', @json($data['currentYear']), 'rgba(184, 215, 255)', 'rgba(184, 215, 255, 0.5)'),
  124. area('{{ trans('admin.report.last_year') }}', @json($data['lastYear']), 'rgba(146, 240, 230)', 'rgba(146, 240, 230, 0.5)')
  125. ],
  126. },
  127. options: common_options(),
  128. });
  129. new Chart(document.getElementById('years'), {
  130. type: 'line',
  131. data: {
  132. labels: @json(array_keys($data['ordersByYear'])),
  133. datasets: [
  134. area('', @json(array_values($data['ordersByYear'])), 'rgba(184, 215, 255)')
  135. ],
  136. },
  137. options: {
  138. responsive: true,
  139. scales: {
  140. x: {
  141. grid: {
  142. display: false
  143. }
  144. },
  145. y: {
  146. grid: {
  147. display: false
  148. },
  149. min: 0
  150. }
  151. },
  152. plugins: {
  153. legend: false,
  154. tooltip: label_callbacks(' {{ ucfirst(trans('validation.attributes.year')) }}')
  155. },
  156. },
  157. });
  158. </script>
  159. @endsection