main.js 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572
  1. function categoryClick(categoryID) {
  2. console.log("categoryID: ", categoryID);
  3. $("#categoryID").val(categoryID);
  4. $("#page").val("1");
  5. $("#message-post").submit();
  6. }
  7. function refeshContentModel() {
  8. const myNode = document.getElementById("contentModel");
  9. while (myNode.lastElementChild) {
  10. myNode.removeChild(myNode.lastElementChild);
  11. }
  12. }
  13. $(".edit-btn").on("click", function () {
  14. var tableType = $("#table-type").val();
  15. $.ajax({
  16. type: "POST",
  17. url: "/Config/Editing",
  18. headers: { 'RequestVerificationToken': $('input[name=__RequestVerificationToken]').val() },
  19. data: {
  20. "__RequestVerificationToken": $('input[name=__RequestVerificationToken]').val(),
  21. id: $(this).attr("value"),
  22. tableType: tableType,
  23. },
  24. success: function (data) {
  25. $('#contentModel').html(data);
  26. $('#myContent').modal({ "backdrop": "static", keyboard: true });
  27. $('#myContent').modal('show');
  28. },
  29. failure: function (data) {
  30. console.log(data);
  31. alert(data);
  32. },
  33. error: function (data) {
  34. console.log(data);
  35. alert(data);
  36. }
  37. });
  38. })
  39. $(".delete-btn").on("click", function () {
  40. var tableType = $("#table-type").val();
  41. var id = $(this).attr("value");
  42. console.log("id: ", id);
  43. console.log("tableType: ", tableType);
  44. $.ajax({
  45. type: "POST",
  46. url: "/Partial/Confirm",
  47. data: {
  48. "message": "Are you sure ?",
  49. "id": id,
  50. "tableType": tableType,
  51. "url": "/Config/DeletingAction"
  52. },
  53. success: function (data) {
  54. $('#informModel').html(data);
  55. $('#myInform').modal({ "backdrop": "static", keyboard: true });
  56. $('#myInform').modal('show');
  57. },
  58. failure: function (data) {
  59. console.log(data);
  60. alert(data);
  61. },
  62. error: function (data) {
  63. console.log(data);
  64. alert(data);
  65. }
  66. });
  67. })
  68. function searchData() {
  69. $.ajax({
  70. type: "POST",
  71. url: "/Message/Search",
  72. headers: { 'RequestVerificationToken': $('input[name=__RequestVerificationToken]').val() },
  73. data: {
  74. "__RequestVerificationToken": $('input[name=__RequestVerificationToken]').val(),
  75. },
  76. success: function (data) {
  77. $('#informModel').html(data);
  78. $('#myInform').modal({ "backdrop": "static", keyboard: true });
  79. $('#myInform').modal('show');
  80. },
  81. failure: function (data) {
  82. console.log(data);
  83. alert(data);
  84. },
  85. error: function (data) {
  86. console.log(data);
  87. alert(data);
  88. }
  89. });
  90. }
  91. function chooseTableTypeClick(tableType) {
  92. $(".tableType").val(tableType);
  93. $("#support-form").submit();
  94. }
  95. function chooseTypeClick(typeGet) {
  96. var telcoID = $("#telcoIndex").val();
  97. var companyID = $("#companyIndex").val();
  98. var dateGet = $("#dateGetIndex").val();
  99. console.log("telcoID: ", telcoID);
  100. console.log("companyID: ", companyID);
  101. $(".dateGet").val(dateGet);
  102. $(".typeGet").val(typeGet);
  103. $(".telcoID").val(telcoID);
  104. $(".companyID").val(companyID);
  105. $(".__RequestVerificationToken").val($('input[name=__RequestVerificationToken]').val());
  106. $("#report-index-form").submit();
  107. }
  108. function chooseDateClick(dateGet) {
  109. var telcoID = $("#telcoIndex").val();
  110. var companyID = $("#companyIndex").val();
  111. var typeGet = $("#typeGetIndex").val();
  112. console.log("telcoID: ", telcoID);
  113. console.log("companyID: ", companyID);
  114. $(".dateGet").val(dateGet);
  115. $(".typeGet").val(typeGet);
  116. $(".telcoID").val(telcoID);
  117. $(".companyID").val(companyID);
  118. $(".__RequestVerificationToken").val($('input[name=__RequestVerificationToken]').val());
  119. $("#report-index-form").submit();
  120. }
  121. function telcoClick(telcoID) {
  122. var typeGet = $("#typeGetIndex").val();
  123. var dateGet = $("#dateGetIndex").val();
  124. console.log("typeGet: ", typeGet);
  125. $(".dateGet").val(dateGet);
  126. $(".typeGet").val(typeGet);
  127. $(".telcoID").val(telcoID);
  128. $(".__RequestVerificationToken").val($('input[name=__RequestVerificationToken]').val());
  129. $("#report-index-form").submit();
  130. }
  131. function companyClick(telcoID, companyID) {
  132. var typeGet = $("#typeGetIndex").val();
  133. var dateGet = $("#dateGetIndex").val();
  134. console.log("typeGet: ", typeGet);
  135. $(".dateGet").val(dateGet);
  136. $(".typeGet").val(typeGet);
  137. $(".telcoID").val(telcoID);
  138. $(".companyID").val(companyID);
  139. $(".__RequestVerificationToken").val($('input[name=__RequestVerificationToken]').val());
  140. $("#report-index-form").submit();
  141. }
  142. function exportData(telcoID, companyID) {
  143. console.log("excel");
  144. $.ajax({
  145. type: "POST",
  146. url: "/Report/Export",
  147. headers: { 'RequestVerificationToken': $('input[name=__RequestVerificationToken]').val() },
  148. data: {
  149. "__RequestVerificationToken": $('input[name=__RequestVerificationToken]').val(),
  150. telcoID: telcoID,
  151. companyID: companyID,
  152. },
  153. success: function (data) {
  154. $('#contentModel').html(data);
  155. $('#myContent').modal({ "backdrop": "static", keyboard: true });
  156. $('#myContent').modal('show');
  157. },
  158. failure: function (data) {
  159. console.log(data);
  160. alert(data);
  161. },
  162. error: function (data) {
  163. console.log(data);
  164. alert(data);
  165. }
  166. });
  167. }
  168. function telcoExportClick(telcoID) {
  169. console.log("telcoID: ", telcoID);
  170. if (telcoID != "-1") {
  171. $(".company-model-style").removeClass("disable");
  172. $(".service-model-style").removeClass("disable");
  173. exportData(telcoID, null);
  174. } else {
  175. $(".company-model-style").addClass("disable");
  176. $(".service-model-style").addClass("disable");
  177. $("#companyExport").val("-1");
  178. $("#serviceExport").val("-1");
  179. }
  180. }
  181. function companyExportClick(companyID) {
  182. var telcoID = $("#telcoExport").val();
  183. console.log("telcoID: ", telcoID);
  184. console.log("companyID: ", companyID);
  185. if (companyID != "-1") {
  186. $(".service-model-style").removeClass("disable");
  187. exportData(telcoID, companyID);
  188. } else {
  189. $(".service-model-style").addClass("disable");
  190. $("#serviceExport").val("-1");
  191. }
  192. }
  193. function exportAction() {
  194. // get all data
  195. var telcoID = $("#telcoExport").val();
  196. var companyID = $("#companyExport").val();
  197. var serviceID = $("#serviceExport").val();
  198. var startMonth = $("#fromDate").val();
  199. var endMonth = $("#toDate").val();
  200. //console.log("telcoID: ", telcoID);
  201. //console.log("companyID: ", companyID);
  202. //console.log("serviceID: ", serviceID);
  203. //console.log("startMonth: ", startMonth);
  204. //console.log("endMonth: ", endMonth);
  205. $("#modeltelcoID").val(telcoID);
  206. $("#modelcompanyID").val(companyID);
  207. $("#modelserviceID").val(serviceID);
  208. $("#modelstartMonth").val(startMonth);
  209. $("#modelendMonth").val(endMonth);
  210. $("#report-export-action-form").submit();
  211. $('#myContent').modal('hide');
  212. }
  213. function tableTypeClick(tableType) {
  214. $("#tableType").val(tableType);
  215. $("#config-form").submit();
  216. }
  217. function addConfigData(tableType) {
  218. console.log("addConfigData");
  219. $.ajax({
  220. type: "POST",
  221. url: "/Config/Adding",
  222. headers: { 'RequestVerificationToken': $('input[name=__RequestVerificationToken]').val() },
  223. data: {
  224. "__RequestVerificationToken": $('input[name=__RequestVerificationToken]').val(),
  225. tableType: tableType,
  226. },
  227. success: function (data) {
  228. $('#contentModel').html(data);
  229. $('#myContent').modal({ "backdrop": "static", keyboard: true });
  230. $('#myContent').modal('show');
  231. },
  232. failure: function (data) {
  233. console.log(data);
  234. alert(data);
  235. },
  236. error: function (data) {
  237. console.log(data);
  238. alert(data);
  239. }
  240. });
  241. }
  242. // for send mail
  243. function telcoServiceClick(telcoID) {
  244. //var companyID = $("#companyExport").val();
  245. console.log("telcoID: ", telcoID);
  246. //console.log("companyID: ", companyID);
  247. if (telcoID != "-1") {
  248. $(".company-model-style").removeClass("disable");
  249. $(".service-model-style").removeClass("disable");
  250. exportServiceData(telcoID, null);
  251. } else {
  252. $(".company-model-style").addClass("disable");
  253. $(".service-model-style").addClass("disable");
  254. $("#companyExport").val("-1");
  255. $("#serviceExport").val("-1");
  256. }
  257. }
  258. function companyServiceClick(companyID) {
  259. var telcoID = $("#telcoId").val();
  260. console.log("telcoID: ", telcoID);
  261. console.log("companyID: ", companyID);
  262. if (companyID != "-1") {
  263. $(".service-model-style").removeClass("disable");
  264. exportServiceData(telcoID, companyID);
  265. } else {
  266. $(".service-model-style").addClass("disable");
  267. $("#serviceExport").val("-1");
  268. }
  269. }
  270. function exportServiceData(telcoID, companyID) {
  271. console.log("exportSendMailData");
  272. var status = $("#status").val();
  273. var serviceName = $("#serviceName").val();
  274. var url = $("#url").val();
  275. var status = $("#status").val();
  276. var state = $("#state").val();
  277. var vSql = $("#vSql").val();
  278. var connection = $("#connection").val();
  279. var tableType = $("#tableType").val();
  280. //console.log("tableType: ", tableType);
  281. //console.log("listMail: ", listMail);
  282. //console.log("message: ", message);
  283. var formData = new FormData();
  284. formData.append('telcoId', telcoID);
  285. formData.append('companyId', companyID);
  286. formData.append('serviceName', serviceName);
  287. formData.append('url', url);
  288. formData.append('state', state);
  289. formData.append('vSql', vSql);
  290. formData.append('status', status);
  291. formData.append('connection', connection);
  292. formData.append('tableType', tableType);
  293. $.ajax({
  294. type: "POST",
  295. url: "/Config/ExportService",
  296. headers: { 'RequestVerificationToken': $('input[name=__RequestVerificationToken]').val() },
  297. data: formData,
  298. processData: false,
  299. contentType: false,
  300. success: function (data) {
  301. $('#contentModel').html(data);
  302. $('#myContent').modal({ "backdrop": "static", keyboard: true });
  303. $('#myContent').modal('show');
  304. },
  305. failure: function (data) {
  306. console.log(data);
  307. //alert(data);
  308. },
  309. error: function (data) {
  310. console.log(data);
  311. //alert(data);
  312. }
  313. });
  314. }
  315. // for send mail
  316. function telcoSendMailClick(telcoID) {
  317. //var companyID = $("#companyExport").val();
  318. console.log("telcoID: ", telcoID);
  319. //console.log("companyID: ", companyID);
  320. if (telcoID != "-1") {
  321. $(".company-model-style").removeClass("disable");
  322. $(".service-model-style").removeClass("disable");
  323. exportSendMailData(telcoID, null);
  324. } else {
  325. $(".company-model-style").addClass("disable");
  326. $(".service-model-style").addClass("disable");
  327. $("#companyExport").val("-1");
  328. $("#serviceExport").val("-1");
  329. }
  330. }
  331. function companySendMailClick(companyID) {
  332. var telcoID = $("#telcoId").val();
  333. console.log("telcoID: ", telcoID);
  334. console.log("companyID: ", companyID);
  335. if (companyID != "-1") {
  336. $(".service-model-style").removeClass("disable");
  337. exportSendMailData(telcoID, companyID);
  338. } else {
  339. $(".service-model-style").addClass("disable");
  340. $("#serviceExport").val("-1");
  341. }
  342. }
  343. function exportSendMailData(telcoID, companyID) {
  344. console.log("exportSendMailData");
  345. var status = $("#status").val();
  346. var serviceId = $("#serviceId").val();
  347. var timeSend = $("#timeSend").val();
  348. var listMail = $("#listMail").val();
  349. var message = $("#message").val();
  350. var tableType = $("#tableType").val();
  351. console.log("tableType: ", tableType);
  352. console.log("listMail: ", listMail);
  353. console.log("message: ", message);
  354. var formData = new FormData();
  355. formData.append('telcoId', telcoID);
  356. formData.append('companyId', companyID);
  357. formData.append('serviceId', serviceId);
  358. formData.append('timeSend', timeSend);
  359. formData.append('listMail', listMail);
  360. formData.append('message', message);
  361. formData.append('status', status);
  362. formData.append('tableType', tableType);
  363. $.ajax({
  364. type: "POST",
  365. url: "/Config/ExportSendMail",
  366. headers: { 'RequestVerificationToken': $('input[name=__RequestVerificationToken]').val() },
  367. data: formData,
  368. processData: false,
  369. contentType: false,
  370. success: function (data) {
  371. $('#contentModel').html(data);
  372. $('#myContent').modal({ "backdrop": "static", keyboard: true });
  373. $('#myContent').modal('show');
  374. },
  375. failure: function (data) {
  376. console.log(data);
  377. //alert(data);
  378. },
  379. error: function (data) {
  380. console.log(data);
  381. //alert(data);
  382. }
  383. });
  384. }
  385. // -----------------------------------------------------------------
  386. function uploadData(typeTable) {
  387. var fileExtension = ['xls', 'xlsx'];
  388. var filename = $('#fileupload').val();
  389. if (filename.length == 0) {
  390. alert("Please select a file.");
  391. return false;
  392. }
  393. else {
  394. var extension = filename.replace(/^.*\./, '');
  395. if ($.inArray(extension, fileExtension) == -1) {
  396. alert("Please select only excel files.");
  397. return false;
  398. }
  399. }
  400. var fdata = new FormData();
  401. var fileUpload = $("#fileupload").get(0);
  402. var files = fileUpload.files;
  403. fdata.append(files[0].name, files[0]);
  404. fdata.append("typeTable", typeTable);
  405. $.ajax({
  406. type: "POST",
  407. url: "/Support/UploadAction",
  408. beforeSend: function (xhr) {
  409. xhr.setRequestHeader("XSRF-TOKEN",
  410. $('input:hidden[name="__RequestVerificationToken"]').val());
  411. },
  412. data: fdata,
  413. contentType: false,
  414. processData: false,
  415. success: function (response) {
  416. console.log(response);
  417. if (response.length == 0)
  418. alert('Some error occured while uploading');
  419. else {
  420. $('#importButton').prop("disabled", false);
  421. $('#divShow').hide();
  422. $('#divPrint').html(response);
  423. }
  424. },
  425. error: function (e) {
  426. $('#divPrint').html(e.responseText);
  427. }
  428. });
  429. }
  430. function importData(typeTable) {
  431. var timeNow = $("#timeNow").val();
  432. $.ajax({
  433. type: "POST",
  434. url: "/Support/ImportAction",
  435. beforeSend: function (xhr) {
  436. xhr.setRequestHeader("XSRF-TOKEN",
  437. $('input:hidden[name="__RequestVerificationToken"]').val());
  438. },
  439. data: {
  440. 'RequestVerificationToken': $('input[name=__RequestVerificationToken]').val(),
  441. typeTable: typeTable,
  442. timeNow: timeNow,
  443. },
  444. success: function (data) {
  445. //$('#downloadButton').prop("disabled", false);
  446. $.ajax({
  447. type: "POST",
  448. url: "/Partial/Response",
  449. data: {
  450. "message": data.message
  451. },
  452. success: function (data) {
  453. $('#informModel').html(data);
  454. $('#myInform').modal({ "backdrop": "static", keyboard: true });
  455. $('#myInform').modal('show');
  456. },
  457. failure: function (data) {
  458. },
  459. error: function (data) {
  460. }
  461. });
  462. },
  463. error: function (e) {
  464. $('#divPrint').html(e.responseText);
  465. }
  466. });
  467. }
  468. function showFileClick(tableType) {
  469. $("#tableType").val(tableType);
  470. $("#actionFile").val("1");
  471. $("#support-form").submit();
  472. }
  473. function saveFileClick(tableType) {
  474. $("#tableType").val(tableType);
  475. $("#actionFile").val("2");
  476. $("#support-form").submit();
  477. }
  478. function downloadClick(typeTable) {
  479. $('#importButton').prop("disabled", true);
  480. //$('#downloadButton').prop("disabled", true);
  481. console.log("typeTable " + typeTable);
  482. $("#tableTypeDownload").val(typeTable);
  483. $("#support-download-form").submit();
  484. //$.ajax({
  485. // type: "POST",
  486. // url: "/Support/DownloadAction",
  487. // beforeSend: function (xhr) {
  488. // xhr.setRequestHeader("XSRF-TOKEN",
  489. // $('input:hidden[name="__RequestVerificationToken"]').val());
  490. // },
  491. // data: {
  492. // 'RequestVerificationToken': $('input[name=__RequestVerificationToken]').val(),
  493. // typeTable: typeTable,
  494. // },
  495. // success: function (data) {
  496. // console.log("data " + data);
  497. // },
  498. // error: function (e) {
  499. // $('#divPrint').html(e.responseText);
  500. // }
  501. //});
  502. }
  503. function exportStock() {
  504. }
  505. function downloadRegistry() {
  506. }