ReportRevenue.cshtml 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366
  1. 
  2. @{
  3. ViewBag.Title = "Report Hourly";
  4. Layout = "~/Views/Shared/_Layout.cshtml";
  5. }
  6. @using ReportWeb;
  7. @using ReportWeb.Models;
  8. @using SuperCms.Extensions;
  9. @{
  10. var listService = Context.Session.GetComplexData<List<Services>>("listService");
  11. Users user = Context.Session.GetComplexData<Users>("user");
  12. }
  13. <!-- BEGIN: Content-->
  14. <div class="app-content content">
  15. <div class="content-wrapper">
  16. <div class="content-body">
  17. <div class="card">
  18. <div class="card-header">
  19. <h4 class="card-title">Search</h4>
  20. <a class="heading-elements-toggle"><i class="fa fa-ellipsis-v font-medium-3"></i></a>
  21. <div class="heading-elements">
  22. <ul class="list-inline mb-0">
  23. <li><a data-action="collapse"><i class="ft-minus"></i></a></li>
  24. <li><a data-action="reload"><i class="ft-rotate-cw"></i></a></li>
  25. <li><a data-action="expand"><i class="ft-maximize"></i></a></li>
  26. <li><a data-action="close"><i class="ft-x"></i></a></li>
  27. </ul>
  28. </div>
  29. </div>
  30. <div class="card-content collapse show">
  31. <div class="card-body">
  32. <form class="form">
  33. <div class="row">
  34. <div class="col-md-4 col-sm-4 col-6">
  35. <div class="form-group">
  36. <label>Service</label>
  37. <div class='input-group'>
  38. <select class="form-control" id="service_id">
  39. @if (listService != null)
  40. {
  41. if (user.role == Common.UserRole.Admin)
  42. {
  43. foreach (Services sv in listService)
  44. {
  45. <option value="@sv.id">@sv.sv_name</option>
  46. }
  47. }
  48. else
  49. {
  50. foreach (Services sv in listService)
  51. {
  52. if (sv.sv_code.StartsWith("LUCKYCALL"))
  53. {
  54. <option value="@sv.id">@sv.sv_name</option>
  55. }
  56. }
  57. }
  58. }
  59. </select>
  60. </div>
  61. </div>
  62. </div>
  63. <div class="col-md-4 col-sm-4 col-6">
  64. <div class="form-group">
  65. <label>From</label>
  66. <div class='input-group'>
  67. <input type="text" class="form-control fromDate" id="fromDate">
  68. </div>
  69. </div>
  70. </div>
  71. <div class="col-md-4 col-sm-4 col-6">
  72. <div class="form-group">
  73. <label>To</label>
  74. <div class='input-group'>
  75. <input type="text" class="form-control toDate" id="toDate">
  76. </div>
  77. </div>
  78. </div>
  79. <div class="col-md-4 col-sm-4 col-12">
  80. <div class="form-group " style="margin-top: 10px">
  81. <button type="button" class="btn btn-primary btn-min-width "
  82. onclick="SearchHistory();" id="btnSearch">
  83. Search
  84. </button>
  85. </div>
  86. </div>
  87. </div>
  88. </form>
  89. </div>
  90. </div>
  91. </div>
  92. <div class="card">
  93. <div class="card-header">
  94. <h4 class="card-title">Report</h4>
  95. </div>
  96. <div class="card-content collapse show">
  97. <div class="card-body">
  98. <table class="table table-striped table-bordered base-style table-responsive">
  99. <thead>
  100. <tr>
  101. <th>No.</th>
  102. <th>Service</th>
  103. <th>Report date</th>
  104. <th>Total</th>
  105. <th>H00</th>
  106. <th>H01</th>
  107. <th>H02</th>
  108. <th>H03</th>
  109. <th>H04</th>
  110. <th>H05</th>
  111. <th>H06</th>
  112. <th>H07</th>
  113. <th>H08</th>
  114. <th>H09</th>
  115. <th>H10</th>
  116. <th>H11</th>
  117. <th>H12</th>
  118. <th>H13</th>
  119. <th>H14</th>
  120. <th>H15</th>
  121. <th>H16</th>
  122. <th>H17</th>
  123. <th>H18</th>
  124. <th>H19</th>
  125. <th>H20</th>
  126. <th>H21</th>
  127. <th>H22</th>
  128. <th>H23</th>
  129. </tr>
  130. </thead>
  131. <tbody id="gridbody2">
  132. </tbody>
  133. @*<tfoot>
  134. <tr>
  135. <th></th>
  136. <th>Total</th>
  137. <th></th>
  138. <th></th>
  139. <th></th>
  140. <th></th>
  141. <th></th>
  142. <th></th>
  143. <th></th>
  144. <th></th>
  145. <th></th>
  146. <th></th>
  147. <th></th>
  148. <th></th>
  149. <th></th>
  150. <th></th>
  151. <th></th>
  152. <th></th>
  153. <th></th>
  154. <th></th>
  155. <th></th>
  156. <th></th>
  157. <th></th>
  158. <th></th>
  159. <th></th>
  160. <th></th>
  161. <th></th>
  162. </tr>
  163. </tfoot>*@
  164. </table>
  165. </div>
  166. </div>
  167. </div>
  168. </div>
  169. </div>
  170. </div>
  171. <div class="hidden">
  172. <div class="row">
  173. <div class="col-lg-12 mb-1">
  174. <div class="input-group">
  175. <div class="input-group-prepend">
  176. <span class="input-group-text">
  177. <span class="fa fa-calendar-o"></span>
  178. </span>
  179. </div>
  180. <input id="picker_from" class="form-control datepicker" type="date">
  181. </div>
  182. </div>
  183. <div class="col-lg-12">
  184. <div class="input-group">
  185. <div class="input-group-prepend">
  186. <span class="input-group-text">
  187. <span class="fa fa-calendar-o"></span>
  188. </span>
  189. </div>
  190. <input id="picker_to" class="form-control datepicker" type="date">
  191. </div>
  192. </div>
  193. </div>
  194. </div>
  195. <!-- END: Content-->
  196. @section Scripts {
  197. <script src="~/admin-assets/js/scripts/tables/datatables/datatable-styling.min.js"></script>
  198. <script src="~/admin-assets/js/scripts/pickers/dateTime/bootstrap-datetime.min.js"></script>
  199. <script src="~/admin-assets/js/scripts/pickers/dateTime/pick-a-datetime.min.js"></script>
  200. <script>
  201. var dataTable = $(".base-style").DataTable({
  202. "paging": 0
  203. });
  204. var opts = {
  205. lines: 8, // The number of lines to draw
  206. length: 5, // The length of each line
  207. width: 3, // The line thickness
  208. radius: 5, // The radius of the inner circle
  209. scale: 1, // Scales overall size of the spinner
  210. corners: 1, // Corner roundness (0..1)
  211. color: '#ffffff', // CSS color or array of colors
  212. fadeColor: 'transparent', // CSS color or array of colors
  213. speed: 1, // Rounds per second
  214. rotate: 0, // The rotation offset
  215. animation: 'spinner-line-fade-quick', // The CSS animation name for the lines
  216. direction: 1, // 1: clockwise, -1: counterclockwise
  217. zIndex: 2e9, // The z-index (defaults to 2000000000)
  218. className: 'spinner', // The CSS class to assign to the spinner
  219. //top: '50%', // Top position relative to parent
  220. //left: '50%', // Left position relative to parent
  221. shadow: '0 0 1px transparent', // Box-shadow for the lines
  222. //position: 'absolute' // Element positioning
  223. };
  224. var spinner = new Spinner(opts);
  225. function startSpinner(obj) {
  226. var target = document.getElementById(obj);
  227. $("#" + obj).prop("disabled", true);
  228. spinner.spin(target);
  229. }
  230. function stopSpinner(obj) {
  231. $("#" + obj).prop("disabled", false);
  232. if (spinner != undefined) {
  233. spinner.stop();
  234. }
  235. }
  236. //$( document ).ready(function() {
  237. // $("#timerange").datetimepicker({
  238. // format: "d/MM/YYYY hh:mm a - d/MM/YYYY hh:mm a"
  239. // })
  240. //});
  241. function SearchHistory() {
  242. if (dataTable != null && dataTable != undefined) {
  243. dataTable
  244. .clear()
  245. .destroy();
  246. }
  247. var service_id = $("#service_id").val();
  248. var fromDate = $("#fromDate").val();
  249. var toDate = $("#toDate").val();
  250. startSpinner('btnSearch');
  251. $.ajax({
  252. url: subDomain + "/Admin/GetRevenueHourly",
  253. data: {
  254. fromDate: fromDate,
  255. toDate: toDate,
  256. service_id: service_id
  257. },
  258. type: "POST",
  259. success: function (data) {
  260. stopSpinner('btnSearch');
  261. if (data.error != "0") {
  262. //setTimeout(function () {
  263. // showModal('message-dialog');
  264. // $('#message-content').html(data.content.split("\n").join("<br />"));
  265. //}, 1000);
  266. } else {
  267. var json = JSON.parse(data.data);
  268. console.log(json);
  269. updateGridCharge("gridbody2", json);
  270. dataTable = $(".base-style").DataTable({
  271. "paging": false
  272. //"ajax": json,
  273. //"dataSrc": "",
  274. //"columns": [
  275. // { "data": "SV_CODE" },
  276. // { "data": "REPORT_DATE" },
  277. // { "data": "H00" },
  278. // { "data": "H01" },
  279. // { "data": "H02" },
  280. // { "data": "H03" },
  281. // { "data": "H04" }
  282. //]
  283. });
  284. }
  285. },
  286. error: function (data) {
  287. stopSpinner('btnSearch');
  288. console.log(data.error);
  289. }
  290. })
  291. }
  292. function updateGridCharge(gridbody, val) {
  293. $("#" + gridbody).html("");
  294. //console.log(val);
  295. var html = "";
  296. if (val != undefined) {
  297. for (var i = 0; i < val.length; i++) {
  298. var news = val[i];
  299. console.log(news);
  300. html += "<tr>";
  301. html += "<td scope = 'row'> " + (i + 1) + "</td>";
  302. html += "<td class='text-center'> " + news.SV_CODE + "</td> ";
  303. html += "<td class='text-center'> " + moment(news.REPORT_DATE).format("DD/MM/YYYY") + "</td> ";
  304. html += "<td class='text-right'> " + news.TOTAL + "</td> ";
  305. html += "<td class='text-right'> " + news.H00 + "</td> ";
  306. html += "<td class='text-right'> " + news.H01 + "</td> ";
  307. html += "<td class='text-right'> " + news.H02 + "</td> ";
  308. html += "<td class='text-right'> " + news.H03 + "</td> ";
  309. html += "<td class='text-right'> " + news.H04 + "</td> ";
  310. html += "<td class='text-right'> " + news.H05 + "</td> ";
  311. html += "<td class='text-right'> " + news.H06 + "</td> ";
  312. html += "<td class='text-right'> " + news.H07 + "</td> ";
  313. html += "<td class='text-right'> " + news.H08 + "</td> ";
  314. html += "<td class='text-right'> " + news.H09 + "</td> ";
  315. html += "<td class='text-right'> " + news.H10 + "</td> ";
  316. html += "<td class='text-right'> " + news.H11 + "</td> ";
  317. html += "<td class='text-right'> " + news.H12 + "</td> ";
  318. html += "<td class='text-right'> " + news.H13 + "</td> ";
  319. html += "<td class='text-right'> " + news.H14 + "</td> ";
  320. html += "<td class='text-right'> " + news.H15 + "</td> ";
  321. html += "<td class='text-right'> " + news.H16 + "</td> ";
  322. html += "<td class='text-right'> " + news.H17 + "</td> ";
  323. html += "<td class='text-right'> " + news.H18 + "</td> ";
  324. html += "<td class='text-right'> " + news.H19 + "</td> ";
  325. html += "<td class='text-right'> " + news.H20 + "</td> ";
  326. html += "<td class='text-right'> " + news.H21 + "</td> ";
  327. html += "<td class='text-right'> " + news.H22 + "</td> ";
  328. html += "<td class='text-right'> " + news.H23 + "</td> ";
  329. html += "</tr>";
  330. }
  331. }
  332. $("#" + gridbody).html(html);
  333. }
  334. $(document).ready(function () {
  335. $("#fromDate").datetimepicker({
  336. format: "DD/MM/YYYY",
  337. defaultDate: moment().add(-7, 'days')
  338. });
  339. $("#toDate").datetimepicker({
  340. format: "DD/MM/YYYY",
  341. defaultDate: moment().startOf('day')
  342. })
  343. });
  344. </script>
  345. }