ReportHourly.cshtml 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303
  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. @model List<DailyReport>
  10. @{
  11. var listService = Context.Session.GetComplexData<List<Services>>("listService");
  12. Users user = Context.Session.GetComplexData<Users>("user");
  13. }
  14. <!-- BEGIN: Content-->
  15. <div class="app-content content">
  16. <div class="content-wrapper">
  17. <div class="content-body">
  18. <div class="card">
  19. <div class="card-header">
  20. <h4 class="card-title">Search</h4>
  21. <a class="heading-elements-toggle"><i class="fa fa-ellipsis-v font-medium-3"></i></a>
  22. <div class="heading-elements">
  23. <ul class="list-inline mb-0">
  24. <li><a data-action="collapse"><i class="ft-minus"></i></a></li>
  25. <li><a data-action="reload"><i class="ft-rotate-cw"></i></a></li>
  26. <li><a data-action="expand"><i class="ft-maximize"></i></a></li>
  27. <li><a data-action="close"><i class="ft-x"></i></a></li>
  28. </ul>
  29. </div>
  30. </div>
  31. <div class="card-content collapse show">
  32. <div class="card-body">
  33. <form class="form">
  34. <div class="row">
  35. <div class="col-md-4 col-sm-4 col-6">
  36. <div class="form-group">
  37. <label>Service</label>
  38. <div class='input-group'>
  39. <select class="form-control" id="service_id">
  40. @if (listService != null)
  41. {
  42. if (user.role == Common.UserRole.Admin)
  43. {
  44. foreach (Services sv in listService)
  45. {
  46. <option value="@sv.id">@sv.sv_name</option>
  47. }
  48. }
  49. else
  50. {
  51. foreach (Services sv in listService)
  52. {
  53. if (sv.sv_code.StartsWith("LUCKYCALL"))
  54. {
  55. <option value="@sv.id">@sv.sv_name</option>
  56. }
  57. }
  58. }
  59. }
  60. </select>
  61. </div>
  62. </div>
  63. </div>
  64. <div class="col-md-4 col-sm-4 col-6">
  65. <div class="form-group">
  66. <label>From</label>
  67. <div class='input-group'>
  68. <input type="text" class="form-control fromDate" id="fromDate">
  69. </div>
  70. </div>
  71. </div>
  72. <div class="col-md-4 col-sm-4 col-6">
  73. <div class="form-group">
  74. <label>To</label>
  75. <div class='input-group'>
  76. <input type="text" class="form-control toDate" id="toDate">
  77. </div>
  78. </div>
  79. </div>
  80. <div class="col-md-4 col-sm-4 col-12">
  81. <div class="form-group " style="margin-top: 10px">
  82. <button type="button" class="btn btn-primary btn-min-width "
  83. onclick="SearchHistory();" id="btnSearch">
  84. Search
  85. </button>
  86. </div>
  87. </div>
  88. </div>
  89. </form>
  90. </div>
  91. </div>
  92. </div>
  93. <div class="card">
  94. <div class="card-header">
  95. <h4 class="card-title">Report</h4>
  96. </div>
  97. <div class="card-content collapse show">
  98. <div class="card-body">
  99. <table class="table table-striped table-bordered base-style">
  100. <thead>
  101. <tr>
  102. <th>No.</th>
  103. <th>Report date</th>
  104. <th>Revenue</th>
  105. <th>Revenue Buy</th>
  106. <th>Paid Money</th>
  107. <th>Count sub</th>
  108. <th>Register new</th>
  109. <th>Deactive</th>
  110. </tr>
  111. </thead>
  112. <tbody id="gridbody2">
  113. @if (Model != null && Model.Count > 0)
  114. {
  115. for (int i = 0; i < Model.Count; i++)
  116. {
  117. var his = Model[i];
  118. <tr>
  119. <td class="text-right">@(i + 1)</td>
  120. <td class="text-center">@(his.report_date + "h")</td>
  121. <td class="text-right">@his.revenue</td>
  122. <td class="text-right">@his.revenue_buy</td>
  123. <td class="text-right">@his.paid_money</td>
  124. <td class="text-right">@his.count_active</td>
  125. <td class="text-right">@his.count_reg</td>
  126. <td class="text-right">@his.count_deactive</td>
  127. </tr>
  128. }
  129. }
  130. </tbody>
  131. </table>
  132. </div>
  133. </div>
  134. </div>
  135. </div>
  136. </div>
  137. </div>
  138. <div class="hidden">
  139. <div class="row">
  140. <div class="col-lg-12 mb-1">
  141. <div class="input-group">
  142. <div class="input-group-prepend">
  143. <span class="input-group-text">
  144. <span class="fa fa-calendar-o"></span>
  145. </span>
  146. </div>
  147. <input id="picker_from" class="form-control datepicker" type="date">
  148. </div>
  149. </div>
  150. <div class="col-lg-12">
  151. <div class="input-group">
  152. <div class="input-group-prepend">
  153. <span class="input-group-text">
  154. <span class="fa fa-calendar-o"></span>
  155. </span>
  156. </div>
  157. <input id="picker_to" class="form-control datepicker" type="date">
  158. </div>
  159. </div>
  160. </div>
  161. </div>
  162. <!-- END: Content-->
  163. @section Scripts {
  164. <script src="~/admin-assets/js/scripts/tables/datatables/datatable-styling.min.js"></script>
  165. <script src="~/admin-assets/js/scripts/pickers/dateTime/bootstrap-datetime.min.js"></script>
  166. <script src="~/admin-assets/js/scripts/pickers/dateTime/pick-a-datetime.min.js"></script>
  167. <script>
  168. var dataTable = $(".base-style").DataTable({
  169. "paging": 0
  170. });
  171. var opts = {
  172. lines: 8, // The number of lines to draw
  173. length: 5, // The length of each line
  174. width: 3, // The line thickness
  175. radius: 5, // The radius of the inner circle
  176. scale: 1, // Scales overall size of the spinner
  177. corners: 1, // Corner roundness (0..1)
  178. color: '#ffffff', // CSS color or array of colors
  179. fadeColor: 'transparent', // CSS color or array of colors
  180. speed: 1, // Rounds per second
  181. rotate: 0, // The rotation offset
  182. animation: 'spinner-line-fade-quick', // The CSS animation name for the lines
  183. direction: 1, // 1: clockwise, -1: counterclockwise
  184. zIndex: 2e9, // The z-index (defaults to 2000000000)
  185. className: 'spinner', // The CSS class to assign to the spinner
  186. //top: '50%', // Top position relative to parent
  187. //left: '50%', // Left position relative to parent
  188. shadow: '0 0 1px transparent', // Box-shadow for the lines
  189. //position: 'absolute' // Element positioning
  190. };
  191. var spinner = new Spinner(opts);
  192. function startSpinner(obj) {
  193. var target = document.getElementById(obj);
  194. $("#" + obj).prop("disabled", true);
  195. spinner.spin(target);
  196. }
  197. function stopSpinner(obj) {
  198. $("#" + obj).prop("disabled", false);
  199. if (spinner != undefined) {
  200. spinner.stop();
  201. }
  202. }
  203. //$( document ).ready(function() {
  204. // $("#timerange").datetimepicker({
  205. // format: "d/MM/YYYY hh:mm a - d/MM/YYYY hh:mm a"
  206. // })
  207. //});
  208. function SearchHistory() {
  209. if (dataTable != null && dataTable != undefined) {
  210. dataTable
  211. .clear()
  212. .destroy();
  213. }
  214. var service_id = $("#service_id").val();
  215. var fromDate = $("#fromDate").val();
  216. var toDate = $("#toDate").val();
  217. startSpinner('btnSearch');
  218. $.ajax({
  219. url: subDomain + "/Admin/GetReportHourly",
  220. data: {
  221. fromDate: fromDate,
  222. toDate: toDate,
  223. service_id: service_id
  224. },
  225. type: "POST",
  226. success: function (data) {
  227. stopSpinner('btnSearch');
  228. console.log(data);
  229. if (data.error != "0") {
  230. console.log(data.content);
  231. //setTimeout(function () {
  232. // showModal('message-dialog');
  233. // $('#message-content').html(data.content.split("\n").join("<br />"));
  234. //}, 1000);
  235. } else {
  236. updateGridCharge("gridbody2", data.dailyReport);
  237. //console.log("format table");
  238. dataTable = $(".base-style").DataTable({
  239. "paging": 0
  240. });
  241. }
  242. },
  243. error: function (data) {
  244. stopSpinner('btnSearch');
  245. console.log(data.error);
  246. }
  247. })
  248. }
  249. function updateGridCharge(gridbody, val) {
  250. $("#" + gridbody).html("");
  251. console.log(val);
  252. var html = "";
  253. if (val != undefined) {
  254. for (var i = 0; i < val.length; i++) {
  255. var news = val[i];
  256. html += "<tr>";
  257. html += "<td scope = 'row'> " + (i + 1) + "</td>";
  258. html += "<td class='text-center'> " + news.report_date + "h</td> ";
  259. html += "<td class='text-right'> " + news.revenue + "</td> ";
  260. html += "<td class='text-right'> " + news.revenue_buy + "</td> ";
  261. html += "<td class='text-right'> " + news.paid_money + "</td> ";
  262. html += "<td class='text-right'> " + news.count_active + "</td> ";
  263. html += "<td class='text-right'> " + news.count_reg + "</td> ";
  264. html += "<td class='text-right'> " + news.count_deactive + "</td> ";
  265. html += "</tr>";
  266. }
  267. }
  268. $("#" + gridbody).html(html);
  269. }
  270. $(document).ready(function () {
  271. $("#fromDate").datetimepicker({
  272. format: "DD/MM/YYYY",
  273. defaultDate: moment().add(-1, 'days')
  274. });
  275. $("#toDate").datetimepicker({
  276. format: "DD/MM/YYYY",
  277. defaultDate: moment().startOf('day')
  278. })
  279. });
  280. </script>
  281. }