ServiceAdvManagement.cshtml 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409
  1. 
  2. @{
  3. ViewBag.Title = "Services";
  4. Layout = "~/Views/Shared/_Layout.cshtml";
  5. }
  6. @using ReportWeb.Models;
  7. @using SuperAdmin.Controllers;
  8. @using SuperCms.Extensions;
  9. @model List<Services>
  10. @functions{
  11. void MsgTypeToText(string msgType)
  12. {
  13. if (msgType == "0")
  14. {
  15. <span>SMS Text</span>
  16. }
  17. else if (msgType == "1")
  18. {
  19. <span>SMS Flash</span>
  20. }
  21. else if (msgType == "200")
  22. {
  23. <span>USSD Push</span>
  24. }
  25. else if (msgType == "201")
  26. {
  27. <span>USSD Flash</span>
  28. }
  29. }
  30. void StatusToText(int status)
  31. {
  32. if (status == 0)
  33. {
  34. <span>Inactive</span>
  35. }
  36. else if (status == 1)
  37. {
  38. <span>Active</span>
  39. }
  40. }}
  41. <style>
  42. </style>
  43. <div class="app-content content">
  44. <div class="content-wrapper">
  45. <div class="content-header row">
  46. <div class="content-header-left col-md-6 col-xs-12 mb-1">
  47. <h2 class="content-header-title">Services Adv</h2>
  48. </div>
  49. <div class="content-header-right breadcrumbs-right breadcrumbs-top col-md-6 col-xs-12">
  50. <div class="breadcrumb-wrapper col-xs-12">
  51. <ol class="breadcrumb">
  52. <li class="breadcrumb-item">
  53. <a href="Index">Admin</a>
  54. </li>
  55. <li class="breadcrumb-item">
  56. <a href="#">Services Adv</a>
  57. </li>
  58. </ol>
  59. </div>
  60. </div>
  61. </div>
  62. <div class="content-body">
  63. <!-- Basic form layout section start -->
  64. <section id="basic-form-layouts">
  65. <div class="row service-height">
  66. <div class="col-md-12">
  67. <div class="card">
  68. <div class="card-header">
  69. <h4 class="card-title" id="basic-layout-form">Search</h4>
  70. <a class="heading-elements-toggle"><i class="icon-ellipsis font-medium-3"></i></a>
  71. <div class="heading-elements">
  72. <ul class="list-inline mb-0">
  73. <li><a data-action="collapse"><i class="icon-minus4"></i></a></li>
  74. @*<li><a data-action="reload"><i class="icon-reload"></i></a></li>*@
  75. <li><a data-action="expand"><i class="icon-expand2"></i></a></li>
  76. @*<li><a data-action="close"><i class="icon-cross2"></i></a></li>*@
  77. </ul>
  78. </div>
  79. </div>
  80. <div class="card-content collapse show">
  81. <div class="card-body">
  82. <div class="card-block">
  83. <div class="form-body">
  84. @Html.AntiForgeryToken()
  85. @*<div class="row">
  86. <div class="col-md-4">
  87. <div class="form-group">
  88. <label for="teamName">Team</label>
  89. <input class="form-control" type="text" id="teamName" name="teamName">
  90. </div>
  91. </div>
  92. </div>*@
  93. <div class="row">
  94. <div class="col-md-12">
  95. <button type="button" class="btn btn-primary" onclick="searchServiceAdv()" id="btnSearch">
  96. <i class="icon-search"></i> Search
  97. </button>
  98. <button type="button" class="btn btn-success" onclick="addServiceAdv()">
  99. <i class="icon-plus-circle"></i> Add
  100. </button>
  101. @*<button type="button" class="btn btn-danger" onclick="deleteTable('exercise')">
  102. <i class="icon-bin"></i> Delete Data
  103. </button>*@
  104. </div>
  105. </div>
  106. </div>
  107. </div>
  108. </div>
  109. </div>
  110. </div>
  111. </div>
  112. <div class="col-12">
  113. <div class="card">
  114. <div class="card-content">
  115. <div class="col-md-12 table-responsive">
  116. <table class="table table-striped table-hover">
  117. <thead class="thead-inverse">
  118. <tr>
  119. <th scope="col">#</th>
  120. <th scope="col" class="text-center">Action</th>
  121. <th scope="col" class="text-center">Service Code</th>
  122. <th scope="col" class="text-center">Adv Name</th>
  123. <th scope="col" class="text-center">Message</th>
  124. <th scope="col" class="text-center">Channel</th>
  125. <th scope="col" class="text-center">Message Type</th>
  126. <th scope="col" class="text-center">From Money</th>
  127. <th scope="col" class="text-center">Status</th>
  128. </tr>
  129. </thead>
  130. <tbody id="gridbody">
  131. @if (Model != null)
  132. {
  133. for (int i = 0; i < Model.Count; i++)
  134. {
  135. Services service = Model[@i];
  136. <tr>
  137. <td scope="row">@(i + 1)</td>
  138. <td class="text-center">
  139. <span class="fa fa-edit cursor-pointer" onclick="editServiceAdv('@service.adv_id')"></span>
  140. @if (service.status == 1)
  141. {
  142. <span class="fa fa-remove text-danger cursor-pointer" onclick="removeServiceAdv('@service.adv_id')"></span>
  143. }
  144. else
  145. {
  146. <span class="fa fa-undo text-primary cursor-pointer" onclick="enableServiceAdv('@service.adv_id')"></span>
  147. }
  148. </td>
  149. <td class="text-left">@service.sv_name</td>
  150. <td class="text-left">@service.adv_name</td>
  151. <td class="text-left">@service.msg_adv</td>
  152. <td class="text-center">@service.channel_adv</td>
  153. <td class="text-center">@{MsgTypeToText(service.message_type);}</td>
  154. <td class="text-right">@service.from_money</td>
  155. <td class="text-center">@{StatusToText(service.status);}</td>
  156. </tr>
  157. }
  158. }
  159. </tbody>
  160. </table>
  161. </div>
  162. </div>
  163. </div>
  164. </div>
  165. </div>
  166. </section>
  167. <!-- // Basic form layout section end -->
  168. </div>
  169. <div class="modal fade text-xs-left" id="modal-add-service" tabindex="-1" role="dialog" aria-labelledby="myModalLabel17" style="display: none;" aria-hidden="true">
  170. <div class="modal-dialog modal-lg" role="document">
  171. <div class="modal-content">
  172. <div class="modal-header">
  173. <h4 class="modal-title" id="modalLabelService">New Service Adv</h4>
  174. <button type="button" class="close" data-dismiss="modal" aria-label="Close">
  175. <span aria-hidden="true">×</span>
  176. </button>
  177. </div>
  178. <hidden id="advId"></hidden>
  179. <div class="modal-body">
  180. <div class="row">
  181. <div class="col-md-6">
  182. <div class="form-group">
  183. <label for="serviceCode">Service</label>
  184. <select id="serviceCode" name="serviceCode" class="form-control">
  185. </select>
  186. </div>
  187. </div>
  188. <div class="col-md-6">
  189. <div class="form-group">
  190. <label for="team1">Adv Name</label>
  191. <input class="form-control" type="text" id="advName" name="advName" autocomplete="on">
  192. </div>
  193. </div>
  194. <div class="col-md-6">
  195. <div class="form-group">
  196. <label for="team2">Message type</label>
  197. <select class="form-control" id="messageType" name="messageType">
  198. <option value="0" selected>SMS Text</option>
  199. @*<option value="1">SMS Flash</option>*@
  200. <option value="200">USSD Push</option>
  201. <option value="201">USSD Flash</option>
  202. </select>
  203. </div>
  204. </div>
  205. <div class="col-md-6">
  206. <div class="form-group">
  207. <label for="team1">Channel</label>
  208. <input class="form-control" type="text" id="channelAdv" name="channelAdv" autocomplete="on">
  209. </div>
  210. </div>
  211. <div class="col-md-12">
  212. <div class="form-group">
  213. <label for="fromDate">Message adv</label>
  214. <textarea class="form-control" id="msgAdv" name="msgAdv" autocomplete="off" rows="3"></textarea>
  215. </div>
  216. </div>
  217. <div class="col-md-6">
  218. <div class="form-group">
  219. <label for="team2">From money</label>
  220. <input class="form-control" type="number" id="fromMoney" name="fromMoney">
  221. </div>
  222. </div>
  223. </div>
  224. </div>
  225. <div class="modal-footer">
  226. <button type="button" class="btn grey btn-outline-secondary" data-dismiss="modal">Close</button>
  227. <button type="button" id="btnAddService" class="btn btn-outline-primary" onclick="addNewServiceAdv()">Add</button>
  228. <button type="button" id="btnUpdateInfo" class="btn btn-outline-primary" onclick="saveChangeServiceAdv()">Save Info</button>
  229. </div>
  230. </div>
  231. </div>
  232. </div>
  233. </div>
  234. </div>
  235. @*<link href="~/editor/summernote.css" rel="stylesheet">*@
  236. @*<script type="text/javascript" src="~/editor/summernote.js"></script>*@
  237. @*<script type="text/javascript" src="~/editor/script-custom-editor.js"></script>*@
  238. @section Scripts {
  239. <script>
  240. $(document).ready(function () {
  241. $.ajax({
  242. url: subDomain + "/Admin/SearchService",
  243. data: {
  244. },
  245. type: "POST",
  246. success: function (data) {
  247. console.log(data);
  248. for (var i = 0; i < data.listService.length; i++) {
  249. var sv = data.listService[i];
  250. console.log(sv);
  251. var o = new Option(sv.sv_name, sv.sv_code);
  252. $(o).html(sv.sv_name);
  253. console.log(o);
  254. $("#serviceCode").append(o);
  255. }
  256. }
  257. })
  258. });
  259. function addServiceAdv() {
  260. // clear data
  261. $("#advName").val("");
  262. $("#messageType").val("0");
  263. $("#msgAdv").val("");
  264. $("#fromMoney").val("0");
  265. $("#btnAddService").show();
  266. $("#btnUpdateInfo").hide();
  267. // show modal
  268. showModal("modal-add-service");
  269. }
  270. function editServiceAdv(advId) {
  271. console.log(advId);
  272. // get service info
  273. $.ajax({
  274. url: subDomain + "/Admin/GetServiceAdvById",
  275. data: {
  276. advId: advId
  277. },
  278. type: "POST",
  279. success: function (data) {
  280. console.log(data);
  281. if (data.error != "0") {
  282. setTimeout(function () {
  283. showModal('message-dialog');
  284. $('#message-content').html(data.content.split("\n").join("<br />"));
  285. }, 1000);
  286. } else {
  287. var service = data.service;
  288. // change data
  289. $("#serviceCode").val(service.sv_code);
  290. $("#advId").val(service.adv_id);
  291. console.log($("#advId").val());
  292. $("#advName").val(service.adv_name);
  293. $("#channelAdv").val(service.channel_adv);
  294. $("#messageType").val(service.message_type);
  295. $("#msgAdv").val(service.msg_adv);
  296. $("#fromMoney").val(service.from_money);
  297. $("#btnAddService").hide();
  298. $("#btnUpdateInfo").show();
  299. // show modal
  300. showModal("modal-add-service");
  301. }
  302. },
  303. error: function (data) {
  304. console.log(data.error);
  305. }
  306. })
  307. }
  308. function removeServiceAdv(id) {
  309. console.log(id);
  310. // get service info
  311. $.ajax({
  312. url: subDomain + "/Admin/UpdateServiceAdvStatus",
  313. data: {
  314. advId: id,
  315. status: "0"
  316. },
  317. type: "POST",
  318. success: function (data) {
  319. console.log(data);
  320. if (data.error_code != "0") {
  321. setTimeout(function () {
  322. showModal('message-dialog');
  323. $('#message-content').html(data.content.split("\n").join("<br />"));
  324. }, 1000);
  325. } else {
  326. searchServiceAdv();
  327. }
  328. },
  329. error: function (data) {
  330. console.log(data.error_code);
  331. }
  332. })
  333. }
  334. function enableServiceAdv(id) {
  335. console.log(id);
  336. // get service info
  337. $.ajax({
  338. url: subDomain + "/Admin/UpdateServiceAdvStatus",
  339. data: {
  340. advId: id,
  341. status: "1"
  342. },
  343. type: "POST",
  344. success: function (data) {
  345. console.log(data);
  346. if (data.error_code != "0") {
  347. setTimeout(function () {
  348. showModal('message-dialog');
  349. $('#message-content').html(data.content.split("\n").join("<br />"));
  350. }, 1000);
  351. } else {
  352. searchServiceAdv();
  353. }
  354. },
  355. error: function (data) {
  356. console.log(data.error_code);
  357. }
  358. })
  359. }
  360. function updateGridData(val) {
  361. console.log(val);
  362. $("#gridbody").html("");
  363. var html = "";
  364. if (val != undefined) {
  365. for (var i = 0; i < val.length; i++) {
  366. var service = val[i];
  367. html += "<tr>";
  368. html += "<td scope='row'>" + (i + 1) + "</td>";
  369. html += "<td class='text-center'><span class='fa fa-edit cursor-pointer' onclick='editServiceAdv(\"" + service.adv_id + "\")'></span> "
  370. + (service.status == 1 ? "<span class='fa fa-remove text-danger cursor-pointer' onclick='removeServiceAdv(\"" + service.adv_id + "\")'></span></td >"
  371. : "<span class='fa fa-undo text-primary cursor-pointer' onclick='enableServiceAdv(\"" + service.adv_id + "\")'></span></td >");
  372. html += "<td class='text-left'>" + service.sv_name + "</td>";
  373. html += "<td class='text-left'>" + service.adv_name + "</td>";
  374. html += "<td class='text-left'>" + service.msg_adv + "</td>";
  375. html += "<td class='text-center'>" + service.channel_adv + "</td>";
  376. html += "<td class='text-center'>" + MsgTypeToText(service.message_type) + "</td>";
  377. html += "<td class='text-right'>" + service.from_money + "</td>";
  378. html += "<td class='text-center'>" + StatusToText(service.status) + "</td>";
  379. html += "</tr>";
  380. }
  381. }
  382. $("#gridbody").html(html);
  383. }
  384. </script>
  385. }