SearchHistory.cshtml 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377
  1. 
  2. @{
  3. ViewBag.Title = "Search History";
  4. Layout = "~/Views/Shared/_Layout.cshtml";
  5. }
  6. @using ReportWeb;
  7. @using ReportWeb.Models;
  8. @using SuperCms.Extensions;
  9. @model SearchModel
  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-6">
  81. <div class="form-group">
  82. <label>Msisdn</label>
  83. <div class='input-group'>
  84. <input type="text" class="form-control" id="msisdn">
  85. </div>
  86. </div>
  87. </div>
  88. <div class="col-md-4 col-sm-4 col-12">
  89. <div class="form-group " style="margin-top: 10px">
  90. <button type="button" class="btn btn-primary btn-min-width "
  91. onclick="SearchHistory();" id="btnSearch">
  92. Search
  93. </button>
  94. </div>
  95. </div>
  96. </div>
  97. </form>
  98. </div>
  99. </div>
  100. </div>
  101. <div class="card">
  102. <div class="card-header">
  103. <h4 class="card-title">Register Information</h4>
  104. </div>
  105. <div class="card-content collapse show">
  106. <div class="card-body">
  107. <table class="table table-striped table-bordered base-style" id="table-reg-info">
  108. <thead>
  109. <tr>
  110. <th>No.</th>
  111. <th>Msisdn</th>
  112. <th>Package name</th>
  113. <th>Register time</th>
  114. <th>Expire time</th>
  115. <th>Last renew</th>
  116. <th>Renew status</th>
  117. <th>Active status</th>
  118. <th>Channel</th>
  119. </tr>
  120. </thead>
  121. <tbody id="gridbody1">
  122. @if (Model != null && Model.listRegInfo != null && Model.listRegInfo.Count > 0)
  123. {
  124. for (int i = 0; i < Model.listRegInfo.Count; i++)
  125. {
  126. var his = Model.listRegInfo[i];
  127. <tr>
  128. <td class="text-right">@(i + 1)</td>
  129. <td class="text-center">@his.msisdn</td>
  130. <td class="text-right">@his.product_name</td>
  131. <td class="text-right">@his.register_time.Value.ToString("dd/MM/yyyy HH:mm:ss")</td>
  132. <td class="text-right">@his.expire_time.Value.ToString("dd/MM/yyyy HH:mm:ss")</td>
  133. <td class="text-right">@(his.last_extend == null ? "" : his.last_extend.Value.ToString("dd/MM/yyyy HH:mm:ss"))</td>
  134. <td class="text-right">@(his.last_extend == null ? "" : his.extend_status == 0 ? "Success" : "Failed")</td>
  135. <td class="text-right">@(his.status == 1 ? "Active" : "Cancelled")</td>
  136. <td class="text-right">@(his.channel)</td>
  137. </tr>
  138. }
  139. }
  140. </tbody>
  141. </table>
  142. </div>
  143. </div>
  144. </div>
  145. <div class="card">
  146. <div class="card-header">
  147. <h4 class="card-title">Charge Log</h4>
  148. </div>
  149. <div class="card-content collapse show">
  150. <div class="card-body">
  151. <table class="table table-striped table-bordered base-style" id="table-charge-log">
  152. <thead>
  153. <tr>
  154. <th>No.</th>
  155. <th>Msisdn</th>
  156. <th>Money</th>
  157. <th>Charge time</th>
  158. <th>Package</th>
  159. <th>Description</th>
  160. <th>Channel</th>
  161. </tr>
  162. </thead>
  163. <tbody id="gridbody2">
  164. @if (Model != null && Model.listChargeLog != null && Model.listChargeLog.Count > 0)
  165. {
  166. for (int i = 0; i < Model.listChargeLog.Count; i++)
  167. {
  168. var his = Model.listChargeLog[i];
  169. <tr>
  170. <td class="text-right">@(i + 1)</td>
  171. <td class="text-center">@his.msisdn</td>
  172. <td class="text-right">@his.fee</td>
  173. <td class="text-right">@his.chargeTime.Value.ToString("dd/MM/yyyy HH:mm:ss")</td>
  174. <td class="text-right">@his.product_name</td>
  175. <td class="text-right">@his.description</td>
  176. <td class="text-right">@(his.channel == "1" ? "Web" : his.channel)</td>
  177. </tr>
  178. }
  179. }
  180. </tbody>
  181. </table>
  182. </div>
  183. </div>
  184. </div>
  185. </div>
  186. </div>
  187. </div>
  188. <div class="hidden">
  189. <div class="row">
  190. <div class="col-lg-12 mb-1">
  191. <div class="input-group">
  192. <div class="input-group-prepend">
  193. <span class="input-group-text">
  194. <span class="fa fa-calendar-o"></span>
  195. </span>
  196. </div>
  197. <input id="picker_from" class="form-control datepicker" type="date">
  198. </div>
  199. </div>
  200. <div class="col-lg-12">
  201. <div class="input-group">
  202. <div class="input-group-prepend">
  203. <span class="input-group-text">
  204. <span class="fa fa-calendar-o"></span>
  205. </span>
  206. </div>
  207. <input id="picker_to" class="form-control datepicker" type="date">
  208. </div>
  209. </div>
  210. </div>
  211. </div>
  212. <!-- END: Content-->
  213. @section Scripts {
  214. <script src="~/admin-assets/js/scripts/tables/datatables/datatable-styling.min.js"></script>
  215. <script src="~/admin-assets/js/scripts/pickers/dateTime/bootstrap-datetime.min.js"></script>
  216. <script src="~/admin-assets/js/scripts/pickers/dateTime/pick-a-datetime.min.js"></script>
  217. <script>
  218. var dataTable1 = $("#table-reg-info").DataTable();
  219. var dataTable2 = $("#table-charge-log").DataTable();
  220. var opts = {
  221. lines: 8, // The number of lines to draw
  222. length: 5, // The length of each line
  223. width: 3, // The line thickness
  224. radius: 5, // The radius of the inner circle
  225. scale: 1, // Scales overall size of the spinner
  226. corners: 1, // Corner roundness (0..1)
  227. color: '#ffffff', // CSS color or array of colors
  228. fadeColor: 'transparent', // CSS color or array of colors
  229. speed: 1, // Rounds per second
  230. rotate: 0, // The rotation offset
  231. animation: 'spinner-line-fade-quick', // The CSS animation name for the lines
  232. direction: 1, // 1: clockwise, -1: counterclockwise
  233. zIndex: 2e9, // The z-index (defaults to 2000000000)
  234. className: 'spinner', // The CSS class to assign to the spinner
  235. //top: '50%', // Top position relative to parent
  236. //left: '50%', // Left position relative to parent
  237. shadow: '0 0 1px transparent', // Box-shadow for the lines
  238. //position: 'absolute' // Element positioning
  239. };
  240. var spinner = new Spinner(opts);
  241. function startSpinner(obj) {
  242. var target = document.getElementById(obj);
  243. $("#" + obj).prop("disabled", true);
  244. spinner.spin(target);
  245. }
  246. function stopSpinner(obj) {
  247. $("#" + obj).prop("disabled", false);
  248. if (spinner != undefined) {
  249. spinner.stop();
  250. }
  251. }
  252. //$( document ).ready(function() {
  253. // $("#timerange").datetimepicker({
  254. // format: "d/MM/YYYY hh:mm a - d/MM/YYYY hh:mm a"
  255. // })
  256. //});
  257. function SearchHistory() {
  258. if (dataTable1 != null && dataTable1 != undefined) {
  259. dataTable1
  260. .clear()
  261. .destroy();
  262. }
  263. if (dataTable2 != null && dataTable2 != undefined) {
  264. dataTable2
  265. .clear()
  266. .destroy();
  267. }
  268. var service_id = $("#service_id").val();
  269. var msisdn = $("#msisdn").val();
  270. var fromDate = $("#fromDate").val();
  271. var toDate = $("#toDate").val();
  272. startSpinner('btnSearch');
  273. $.ajax({
  274. url: subDomain + "/Admin/SearchHistoryAction",
  275. data: {
  276. fromDate: fromDate,
  277. toDate: toDate,
  278. service_id: service_id,
  279. msisdn: msisdn
  280. },
  281. type: "POST",
  282. success: function (data) {
  283. stopSpinner('btnSearch');
  284. console.log(data);
  285. if (data.error != "0") {
  286. console.log(data.content);
  287. swal("Warning", data.content, "warning");
  288. } else {
  289. updateGridRegInfo("gridbody1", data.listRegInfo);
  290. updateGridCharge("gridbody2", data.listChargeLog);
  291. dataTable1 = $("#table-reg-info").DataTable();
  292. dataTable2 = $("#table-charge-log").DataTable();
  293. }
  294. },
  295. error: function (data) {
  296. stopSpinner('btnSearch');
  297. console.log(data.error);
  298. dataTable1 = $("#table-reg-info").DataTable();
  299. dataTable2 = $("#table-charge-log").DataTable();
  300. }
  301. })
  302. }
  303. function updateGridRegInfo(gridbody, val) {
  304. $("#" + gridbody).html("");
  305. console.log(val);
  306. var html = "";
  307. if (val != undefined) {
  308. for (var i = 0; i < val.length; i++) {
  309. var news = val[i];
  310. html += "<tr>";
  311. html += "<td scope = 'row'> " + (i + 1) + "</td>";
  312. html += "<td class='text-left'> " + news.msisdn + "</td> ";
  313. html += "<td class='text-left'> " + news.product_name + "</td> ";
  314. html += "<td class='text-center'> " + moment(news.register_time).format("DD/MM/YYYY HH:mm:ss") + "</td> ";
  315. html += "<td class='text-center'> " + moment(news.expire_time).format("DD/MM/YYYY HH:mm:ss") + "</td> ";
  316. html += "<td class='text-center'> " + (news.last_extend == null ? "" : moment(news.last_extend).format("DD/MM/YYYY HH:mm:ss")) + "</td> ";
  317. html += "<td class='text-center'> " + (news.last_extend == null ? "" : news.extend_status == 0 ? "Success" : "Failed") + "</td> ";
  318. html += "<td class='text-center'> " + (news.status == 1 ? "Active" : "Cancelled") + "</td> ";
  319. html += "<td class='text-center'> " + (news.channel == "1" ? "WEB": news.channel) + "</td> ";
  320. html += "</tr>";
  321. }
  322. }
  323. $("#" + gridbody).html(html);
  324. }
  325. function updateGridCharge(gridbody, val) {
  326. $("#" + gridbody).html("");
  327. console.log(val);
  328. var html = "";
  329. if (val != undefined) {
  330. for (var i = 0; i < val.length; i++) {
  331. var news = val[i];
  332. html += "<tr>";
  333. html += "<td scope = 'row'> " + (i + 1) + "</td>";
  334. html += "<td class='text-left'> " + news.msisdn + "</td> ";
  335. html += "<td class='text-right'> " + news.fee + "</td> ";
  336. html += "<td class='text-center'> " + moment(news.chargeTime).format("DD/MM/YYYY HH:mm:ss") + "</td> ";
  337. html += "<td class='text-left'> " + news.product_name + "</td> ";
  338. html += "<td class='text-left'> " + news.description + "</td> ";
  339. html += "<td class='text-left'> " + (news.channel == "1" ? "Web" : news.channel) + "</td> ";
  340. html += "</tr>";
  341. }
  342. }
  343. $("#" + gridbody).html(html);
  344. }
  345. $(document).ready(function () {
  346. $("#fromDate").datetimepicker({
  347. format: "DD/MM/YYYY",
  348. defaultDate: moment().add(-1, 'days')
  349. });
  350. $("#toDate").datetimepicker({
  351. format: "DD/MM/YYYY",
  352. defaultDate: moment().startOf('day')
  353. })
  354. });
  355. </script>
  356. }