Built files from Bizgaze WebServer
Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

printinvoice.js 36KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441
  1. var Bizgaze;
  2. (function (Bizgaze) {
  3. let Apps;
  4. (function (Apps) {
  5. let Transact;
  6. (function (Transact) {
  7. let Components;
  8. (function (Components) {
  9. let Invoices;
  10. (function (Invoices) {
  11. class PrintInvoice extends Unibase.Platform.Core.BaseComponent {
  12. constructor() {
  13. super(...arguments);
  14. this.sampleInvoiceNo = "";
  15. }
  16. jsFiles() {
  17. return ["platform/bundle/index.purchases.details.js"];
  18. }
  19. cssFiles() {
  20. return [];
  21. }
  22. html() {
  23. var html = `<input type="hidden" id="hf_SeriesId"/><input type="hidden" id="hf_LobId"/><input type="hidden" id="hf_InvoiceType"/><form id="Bizgazetransact_ConfirmInvoiceDetails" method="post" data-validate="parsley"><div class="b-b bg-white modal-header bg-white b-b modal-header pa-10"><strong id="spnModelHeading">Confirm Invoice Details</strong></div><div style = "height: 627px; overflow: hidden auto;" class="simple-scroll-bar modal-body bg-cyan-light-5"><div id="bizgaze_CreateErrorMessages" class="clear"></div><div class="card"><div class="card-header ">Select Template </div><div class="card-body"><div id="CurrentInvoiceNumber" class="row"><div class="col-sm-6 input-group d-felx align-items-center"><span>Your invoice number going to be : </span><span class="list-item-main-title ml-1" id="spnNextInvoiceNo"></span></div></div><div id="divInvoiceserise" class="row mt-5" ><div class="col-sm-4 div_SeriesId"><div class="floating-label-form-group floating-label-form-group-with-value"><label for= "ddl_InvoiceSeries"> Invoice Series <span class= "text-red">*</span></label><select id= "ddl_InvoiceSeries" class="form-control"></select></div></div><div class="col-sm-4 div_TemplateId"><div class="floating-label-form-group floating-label-form-group-with-value"><label for="ddl_TemplateId">Select Template<span class="text-red">*</span ></label><select id="ddl_TemplateId" class="form-control value-control confirm_print floating-label-control" data-placeholder="Select Template" placeholder="Select Template" data-label="Template Name"></select></div></div ></div></div></div><div class="card preview_card d-none"><div class="card-header">Template Preview</div><div class="card-body print-template-text" id="templateText"></div></div></div ><div class="b-t bg-white modal-footer pa-10"><a href="javascript:;" id = "btn_ClosePrintInvoice" class="btn btn-light btn-sm mr-auto">Close</a><a href="javascript:;" id="btnConfirmShipment_ConfirmPrint" style="width:150px" class="btnConfirmShipment_SaveAndPrint btn btn-primary btn-sm">Confirm & Print</a> <a href="javascript:;" id = "btnConfirmShipment_PrintPreview" style = "width:150px" class="btnConfirmShipment_PrintPreview btn btn-warning btn-sm"> Print Preview </a></div></form>`;
  24. return html;
  25. }
  26. load(item) {
  27. Unibase.Platform.Helpers.FileCacheHelper.Instance().addCacheFiles(["platform/series/managers/seriesmanager.js", "apps/transact/managers/invoicemanager.js"]);
  28. let InstalledAppId = Unibase.Themes.Providers.DetailHelper.installedAppId;
  29. let invoiceno = Unibase.Themes.Providers.Detail_Settings.Instance().InputParameters.find(x => x.Key == "hf_" + InstalledAppId + "_invoiceno").Value;
  30. if (invoiceno != undefined) {
  31. var invoiceNo = invoiceno;
  32. var date = Unibase.Themes.Providers.Detail_Settings.Instance().InputParameters.find(x => x.Key == "hf_" + Unibase.Themes.Providers.DetailHelper.installedAppId + "_invoicedate").Value;
  33. var LobId = Unibase.Themes.Providers.Detail_Settings.Instance().InputParameters.find(x => x.Key == "hf_" + InstalledAppId + "_lobid").Value;
  34. var JournalTypeId = Unibase.Themes.Providers.Detail_Settings.Instance().InputParameters.find(x => x.Key == "hf_" + InstalledAppId + "_journaltypeid").Value;
  35. var InvoiceDate = Unibase.Themes.Providers.Detail_Settings.Instance().InputParameters.find(x => x.Key == "hf_" + InstalledAppId + "_invoicedate").Value;
  36. var invidate = Bizgaze.Apps.Transact.Components.Invoices.PrintInvoice.Instance().formatDate(InvoiceDate);
  37. invoiceNo = invoiceNo.toString().replace('#', '');
  38. var templateid = Unibase.Themes.Providers.Detail_Settings.Instance().InputParameters.find(x => x.Key == "hf_" + InstalledAppId + "_templateid").Value;
  39. $('#ddl_InvoiceSeries').change(function () {
  40. Bizgaze.Apps.Transact.Components.Invoices.PrintInvoice.Instance().changeSeries($(this).val());
  41. });
  42. $('.btnConfirmShipment_SaveAndPrint').click(function () {
  43. $('.btnConfirmShipment_SaveAndPrint').addClass('disabled', "true");
  44. $('#hfinvoice_no').replaceWith(PrintInvoice.Instance().sampleInvoiceNo);
  45. Unibase.Themes.Providers.Detail_Settings.Instance().InputParameters.find(x => x.Key == "hf_" + InstalledAppId + "_invoiceno").Value = "0";
  46. PrintInvoice.Instance().confirmPrint();
  47. });
  48. $("#btn_ClosePrintInvoice").click(function () {
  49. PrintInvoice.Instance().navigationHelper.closePopUp();
  50. });
  51. $('#btnConfirmShipment_PrintPreview').click(function () {
  52. PrintInvoice.Instance().printPreview(Unibase.Themes.Providers.DetailHelper.recordId);
  53. });
  54. if (Unibase.Themes.Providers.Detail_Settings.Instance().InputParameters.find(x => x.Key == "hf_" + InstalledAppId + "_invoicetypeid").Value == "1" || templateid == "0") {
  55. $('#btnConfirmShipment_PrintPreview').hide();
  56. }
  57. var seriesid = Unibase.Themes.Providers.Detail_Settings.Instance().InputParameters.find(x => x.Key == "hf_" + InstalledAppId + "_seriesid").Value;
  58. if (invoiceno.indexOf('#') >= 0) {
  59. Bizgaze.Apps.Transact.Managers.InvoiceManager.Instance().GetSampleInvoiceNo(invoiceNo, invidate, seriesid).then(function (response) {
  60. PrintInvoice.Instance().sampleInvoiceNo = response.result;
  61. $('#spnNextInvoiceNo').text(PrintInvoice.Instance().sampleInvoiceNo);
  62. });
  63. }
  64. else {
  65. PrintInvoice.Instance().sampleInvoiceNo = invoiceno;
  66. $('#spnNextInvoiceNo').text(invoiceno);
  67. }
  68. $(".confirm_print").change(function () {
  69. $(".preview_card").removeClass("d-none");
  70. let templateid = $(this).val();
  71. Unibase.Platform.Helpers.FileCacheHelper.Instance().loadJsFile('platform/templates/components/templateprint.js', function () { Unibase.Platform.Templates.Components.TemplatePrint.Instance().loadtemplatehtmldata(templateid); });
  72. });
  73. $("#ddl_TemplateId").change(function () {
  74. if ($('#ddl_TemplateId').val() == 0) {
  75. $('.btnConfirmShipment_SaveAndPrint').addClass('disabled');
  76. }
  77. else {
  78. $('.btnConfirmShipment_SaveAndPrint').removeClass('disabled');
  79. }
  80. });
  81. PrintInvoice.Instance().loadSeries();
  82. PrintInvoice.Instance().loadTemplates();
  83. }
  84. }
  85. init() {
  86. let instance = this;
  87. let jsfiles = ["platform/bundle/index.purchases.details.js"];
  88. PrintInvoice.Instance().fileCacheHelper.addCacheFiles(["platform/series/managers/seriesmanager.js", "apps/transact/managers/invoicemanager.js"]);
  89. PrintInvoice.Instance().fileCacheHelper.loadJsFiles(jsfiles, null);
  90. let InstalledAppId = Unibase.Themes.Providers.DetailHelper.installedAppId;
  91. let invoiceno = Unibase.Themes.Providers.Detail_Settings.Instance().InputParameters.find(x => x.Key == "hf_" + InstalledAppId + "_invoiceno").Value;
  92. let InvoiceId = Unibase.Themes.Providers.Detail_Settings.Instance().InputParameters.find(x => x.Key == "hf_" + InstalledAppId + "_invoiceid").Value;
  93. var invoicetypeid = Unibase.Themes.Providers.Detail_Settings.Instance().InputParameters.find(x => x.Key == "hf_" + InstalledAppId + "_invoicetypeid").Value;
  94. let SystemLock = Unibase.Themes.Providers.Detail_Settings.Instance().InputParameters.find(x => x.Key == "hf_" + InstalledAppId + "_issystemlock");
  95. let IsSystemLock = "false";
  96. if ((invoiceno.indexOf('#') >= 0) && Number(invoicetypeid) == 1) {
  97. $(".DetailSetting_" + InstalledAppId + "_Print").text("Confirm & Print");
  98. $(".DetailSetting_" + InstalledAppId + "_Print").addClass("hidden");
  99. if (SystemLock == undefined) {
  100. instance.fileCacheHelper.loadJsFile("apps/transact/managers/invoicemanager.js", function () {
  101. Bizgaze.Apps.Transact.Managers.InvoiceManager.Instance().getInvoiceDetails(InvoiceId).then(function (invres) {
  102. IsSystemLock = invres.result.IssystemLock.toString();
  103. if (IsSystemLock == "false") {
  104. $(".DetailSetting_" + InstalledAppId + "_Print").removeClass("hidden");
  105. }
  106. });
  107. });
  108. }
  109. else {
  110. IsSystemLock = SystemLock.Value;
  111. if (IsSystemLock == "true") {
  112. $(".DetailSetting_" + InstalledAppId + "_Print").addClass("hidden");
  113. }
  114. }
  115. }
  116. $(".DetailSetting_" + InstalledAppId + "_Print").click(function () {
  117. var templateid = Unibase.Themes.Providers.Detail_Settings.Instance().InputParameters.find(x => x.Key == "hf_" + InstalledAppId + "_templateid").Value;
  118. if ((invoiceno.indexOf('#') >= 0 || templateid == "0") && Number(invoicetypeid) == 1) {
  119. Unibase.Platform.Helpers.NavigationHelper.Instance().popup(0, '', Bizgaze.Apps.Transact.Components.Invoices.PrintInvoice.Instance(), null, Unibase.Platform.Helpers.Size.Large);
  120. }
  121. else {
  122. if (!Boolean(templateid)) {
  123. Unibase.Platform.Helpers.FileCacheHelper.Instance().loadJsFile("/platform/core/helpers/printhelper/printhelper.js", function () {
  124. Unibase.Platform.Helpers.PrintHelper.Instance().showPrintErrorModal();
  125. return;
  126. });
  127. }
  128. else {
  129. PrintInvoice.Instance().sampleInvoiceNo = invoiceno;
  130. var invoiceid = Unibase.Themes.Providers.Detail_Settings.Instance().InputParameters.find(x => x.Key == "hf_" + InstalledAppId + "_invoiceid").Value;
  131. PrintInvoice.Instance().printPreview(invoiceid);
  132. }
  133. }
  134. });
  135. }
  136. loadSeries() {
  137. let InstallAppId = Unibase.Themes.Providers.DetailHelper.installedAppId;
  138. var seriesid = Number(Unibase.Themes.Providers.Detail_Settings.Instance().InputParameters.find(x => x.Key == "hf_" + InstallAppId + "_seriesid").Value);
  139. Unibase.Platform.Series.Managers.SeriesManager.Instance().getSeries(0, InstallAppId).then(function (response) {
  140. $('#ddl_InvoiceSeries').empty();
  141. var data = response.result;
  142. var cmbSeries = document.getElementById('ddl_InvoiceSeries');
  143. $('#ddl_InvoiceSeries').empty();
  144. for (var i = 0; i < data.length; i++) {
  145. if (data[i].StatusId == 1) {
  146. var option = new Option(data[i].SeriesName, data[i].SeriesId.toString());
  147. $("#ddl_InvoiceSeries").append(option);
  148. }
  149. }
  150. if (seriesid != 0) {
  151. $('#ddl_InvoiceSeries option[value=' + seriesid + ']').attr('selected', 'selected');
  152. Bizgaze.Apps.Transact.Components.Invoices.PrintInvoice.Instance().changeSeries(seriesid);
  153. }
  154. else
  155. Bizgaze.Apps.Transact.Components.Invoices.PrintInvoice.Instance().changeSeries(data[0].SeriesId);
  156. });
  157. }
  158. loadTemplates() {
  159. let InstallAppId = Unibase.Themes.Providers.DetailHelper.installedAppId;
  160. var templateid = Number(Unibase.Themes.Providers.Detail_Settings.Instance().InputParameters.find(x => x.Key == "hf_" + InstallAppId + "_templateid").Value);
  161. Bizgaze.Apps.Transact.Managers.InvoiceManager.Instance().gettemplates(InstallAppId).then(function (response) {
  162. if (response.result.length > 0) {
  163. var ddlTemplate = document.getElementById('ddl_TemplateId');
  164. $('#ddl_TemplateId').empty();
  165. $("#ddl_TemplateId").append('<option value="0">--select--</option>');
  166. for (var i = 0; i < response.result.length; i++) {
  167. var option = new Option(response.result[i].TemplateName, response.result[i].TemplateId);
  168. $("#ddl_TemplateId").append(option);
  169. }
  170. }
  171. if (templateid != 0) {
  172. $('#ddl_TemplateId option[value=' + templateid + ']').attr('selected', 'selected');
  173. }
  174. else {
  175. var branchid = Number(Unibase.Themes.Providers.Detail_Settings.Instance().InputParameters.find(x => x.Key == "hf_" + InstallAppId + "_branchid").Value);
  176. var lobid = Number(Unibase.Themes.Providers.Detail_Settings.Instance().InputParameters.find(x => x.Key == "hf_" + InstallAppId + "_lobid").Value);
  177. Bizgaze.Apps.Transact.Managers.InvoiceManager.Instance().GetTemplateSetting(InstallAppId, branchid, lobid).then(function (res) {
  178. if (res.result != null) {
  179. $('#ddl_TemplateId option[value=' + res.result.TemplateId + ']').attr('selected', 'selected');
  180. }
  181. });
  182. }
  183. if (response.result.length <= 0) {
  184. $(".div_TemplateId").addClass('hidden');
  185. MessageHelper.Instance().showError("Please Create Template", "bizgaze_CreateErrorMessages");
  186. }
  187. let seletedTemplate = $(".confirm_print option:selected").val();
  188. if (seletedTemplate != 0) {
  189. $(".preview_card").removeClass("d-none");
  190. Unibase.Platform.Helpers.FileCacheHelper.Instance().loadJsFile('platform/templates/components/templateprint.js', function () { Unibase.Platform.Templates.Components.TemplatePrint.Instance().loadtemplatehtmldata(seletedTemplate); });
  191. }
  192. });
  193. }
  194. changeSeries(seriesId) {
  195. let InstalledAppId = Unibase.Themes.Providers.DetailHelper.installedAppId;
  196. var InvoiceDate = Unibase.Themes.Providers.Detail_Settings.Instance().InputParameters.find(x => x.Key == "hf_" + InstalledAppId + "_invoicedate").Value;
  197. var invidate = Bizgaze.Apps.Transact.Components.Invoices.PrintInvoice.Instance().formatDate(InvoiceDate);
  198. Bizgaze.Apps.Transact.Managers.InvoiceManager.Instance().getTempNextNumber(seriesId, invidate).then(function (data) {
  199. if (data.status == 2) {
  200. MessageHelper.Instance().showError(data.message, "bizgaze_CreateErrorMessages");
  201. $('#spnNextInvoiceNo').text("");
  202. }
  203. else {
  204. $('#spnNextInvoiceNo').text(data.result.SeriesName);
  205. PrintInvoice.Instance().sampleInvoiceNo = data.result.SeriesName;
  206. $('#bizgaze_CreateErrorMessages').empty();
  207. }
  208. }, function (response) {
  209. MessageHelper.Instance().showError(response.message, "bizgaze_CreateErrorMessages");
  210. });
  211. }
  212. printPreview(InvoiceId) {
  213. var instance = this;
  214. instance.navigationHelper.showLoading();
  215. let InstallAppId = Unibase.Themes.Providers.DetailHelper.installedAppId;
  216. PrintInvoice.Instance().fileCacheHelper.loadJsFile("apps/transact/managers/invoicemanager.js", function () {
  217. Bizgaze.Apps.Transact.Managers.InvoiceManager.Instance().getprintinvoice(InvoiceId, true, false).then(function (data) {
  218. instance.navigationHelper.hideLoading();
  219. var resp = data.result;
  220. if (isMobileApp()) {
  221. Unibase.Platform.Helpers.MobileHelper.Instance().previewHtml(data.result.PrintHTML);
  222. }
  223. else {
  224. if (resp.FilePath != "" && resp.FilePath != null) {
  225. var path = resp.FilePath.replace("~", "");
  226. instance.download(_appsettings.asset_url() + path, resp.FileName + ".pdf");
  227. }
  228. else {
  229. PrintInvoice.Instance().printPopup(resp);
  230. }
  231. }
  232. }, function (response) {
  233. MessageHelper.Instance().showError(response.responseText, "");
  234. });
  235. });
  236. }
  237. download(url, fileName) {
  238. var xhr = new XMLHttpRequest();
  239. xhr.open('GET', url, true);
  240. xhr.responseType = 'blob';
  241. xhr.onload = function (event) {
  242. if (this.status == 200) {
  243. PrintInvoice.Instance()._saveBlob(this.response, fileName);
  244. }
  245. };
  246. xhr.send();
  247. }
  248. _saveBlob(response, fileName) {
  249. if (navigator.msSaveBlob) {
  250. navigator.msSaveBlob(response, fileName);
  251. }
  252. else {
  253. this._html5Saver(response, fileName);
  254. }
  255. }
  256. _html5Saver(blob, fileName) {
  257. var a = document.createElement("a");
  258. document.body.appendChild(a);
  259. var url = window.URL.createObjectURL(blob);
  260. a.href = url;
  261. a.download = fileName;
  262. a.click();
  263. document.body.removeChild(a);
  264. }
  265. printPopup(data) {
  266. var mywindow = window.open('', 'my Print', 'height=400,width=850');
  267. var content = '<html><head><title>Print</title><link rel="stylesheet" href="lib/bizgaze/print.css" /><link rel="stylesheet" href="lib/bootstrap/bootstrap-theme.min.css" /></head><body>';
  268. content += data.PrintHTML;
  269. content += "<script>print();</script>";
  270. content += '</body></html>';
  271. mywindow.document.write(content);
  272. return true;
  273. }
  274. confirmPrint() {
  275. let InstallAppId = Unibase.Themes.Providers.DetailHelper.installedAppId;
  276. var seriesid = Number($('#ddl_InvoiceSeries').val());
  277. let invoiceno = Unibase.Themes.Providers.Detail_Settings.Instance().InputParameters.find(x => x.Key == "hf_" + InstallAppId + "_invoiceno").Value;
  278. invoiceno = invoiceno.toString().replace(/\//g, '.');
  279. if (seriesid == undefined) {
  280. seriesid = Number(Unibase.Themes.Providers.Detail_Settings.Instance().InputParameters.find(x => x.Key == "hf_" + InstallAppId + "_seriesid").Value);
  281. }
  282. if ($('#ddl_TemplateId option').length == 0) {
  283. MessageHelper.Instance().showError("Please Create Template", "bizgaze_CreateErrorMessages");
  284. $('.btnConfirmShipment_SaveAndPrint').removeClass('disabled');
  285. return false;
  286. }
  287. if ($('#ddl_TemplateId').val() == '' || $('#ddl_TemplateId').val() == "0") {
  288. Unibase.Platform.Helpers.FileCacheHelper.Instance().loadJsFile("/platform/core/helpers/printhelper/printhelper.js", function () {
  289. Unibase.Platform.Helpers.PrintHelper.Instance().showPrintErrorModal();
  290. return;
  291. });
  292. $('.btnConfirmShipment_SaveAndPrint').removeClass('disabled');
  293. return false;
  294. }
  295. var invoiceId = Number(Unibase.Themes.Providers.Detail_Settings.Instance().InputParameters.find(x => x.Key == "hf_" + InstallAppId + "_invoiceid").Value);
  296. var templateid = Number($('#ddl_TemplateId').val());
  297. Bizgaze.Apps.Transact.Managers.InvoiceManager.Instance().updateinvoiceseries(invoiceId, seriesid, invoiceno, templateid).then(function (data) {
  298. if (data.status == 2) {
  299. MessageHelper.Instance().showError(data.message, 'bizgaze_CreateErrorMessages');
  300. return false;
  301. }
  302. PrintInvoice.Instance().navigationHelper.closePopUp();
  303. var detailobj = Unibase.Themes.Providers.DetailHelper.DetailInstance();
  304. detailobj._recordId = Unibase.Themes.Providers.DetailHelper.recordId;
  305. detailobj._installedAppId = Unibase.Themes.Providers.DetailHelper.installedAppId;
  306. detailobj._containerId = detailobj._containerId;
  307. detailobj.loadPortlets(detailobj);
  308. var invoiceId = Number(Unibase.Themes.Providers.Detail_Settings.Instance().InputParameters.find(x => x.Key == "hf_" + InstallAppId + "_invoiceid").Value);
  309. if (invoiceId == undefined || invoiceId == 0)
  310. invoiceId = Unibase.Themes.Providers.DetailHelper.recordId;
  311. PrintInvoice.Instance().printPreview(detailobj._recordId);
  312. });
  313. }
  314. formatDate(date) {
  315. var datearray = date.split("/");
  316. var newdate = datearray[1] + '/' + datearray[0] + '/' + datearray[2];
  317. var d = new Date(newdate), month = '' + (d.getMonth() + 1), day = '' + d.getDate(), year = d.getFullYear();
  318. if (month.length < 2)
  319. month = '0' + month;
  320. if (day.length < 2)
  321. day = '0' + day;
  322. return [year, month, day].join('-');
  323. }
  324. print() {
  325. let InstallAppId = Unibase.Themes.Providers.DetailHelper.installedAppId;
  326. var invoiceNo = Unibase.Themes.Providers.Detail_Settings.Instance().InputParameters.find(x => x.Key == "hf_" + InstallAppId + "_invoioceno").Value;
  327. if (invoiceNo.indexOf("#") >= 0) {
  328. invoiceNo = invoiceNo.replace('#', '');
  329. Unibase.Platform.Helpers.NavigationHelper.Instance().popup(0, "", Bizgaze.Apps.Transact.Components.Invoices.PrintInvoice.Instance(), null, Unibase.Platform.Helpers.Size.Large);
  330. }
  331. else {
  332. var invoiceId = Number(Unibase.Themes.Providers.Detail_Settings.Instance().InputParameters.find(x => x.Key == "hf_" + InstallAppId + "_invoioceid").Value);
  333. var TemplateId = Number(Unibase.Themes.Providers.Detail_Settings.Instance().InputParameters.find(x => x.Key == "hf_" + InstallAppId + "_templateid").Value);
  334. if (TemplateId == 0) {
  335. }
  336. else {
  337. Bizgaze.Apps.Transact.Managers.InvoiceManager.Instance().getprintinvoice(invoiceId, true, false).then(function (data) {
  338. var resp = data.result;
  339. var printhtml = '<div id="divPrint hidden"><span class="printDataN">' + resp.Html + '</span></div >';
  340. }, function (response) {
  341. MessageHelper.Instance().showError(response.responseText, "");
  342. });
  343. }
  344. }
  345. }
  346. downloadPrint(InvoiceId) {
  347. Unibase.Platform.Helpers.FileCacheHelper.Instance().loadJsFiles(["platform/templates/managers/templatemanager.js", "platform/files/managers/filemanager.js", "platform/core/helpers/mobile/mobilehelper.js", "platform/core/helpers/mobile/interfaces/imobilehelper.js", "platform/core/helpers/mobile/android/androidhelper.js"], function () {
  348. Unibase.Platform.Templates.Managers.TemplateManager.Instance().getTemplatePdfFile("Bizgaze_Extension_Transact_Transact_PrintProvider_InvoicePrint", InvoiceId).then(function (responce) {
  349. if (responce.errors == null) {
  350. if (isMobileApp) {
  351. var filePath = responce.result.FilePath;
  352. if (filePath != null && filePath != undefined && filePath != "") {
  353. filePath = filePath.replace("file://" + '/', '');
  354. filePath = filePath.replace(window.location.origin + '/', '');
  355. Unibase.Platform.Helpers.MobileHelper.Instance().getMobileFilePath(responce, filePath, Bizgaze.Apps.Transact.Components.Invoices.PrintInvoice.Instance().MobileFilePathCallBack);
  356. }
  357. }
  358. else {
  359. var Filepath = responce.result.FilePath;
  360. Filepath = Filepath.substring(8) + ".pdf";
  361. var a = document.createElement("a");
  362. a.href = Filepath;
  363. a.download = responce.result.FileName;
  364. a.click();
  365. }
  366. }
  367. });
  368. });
  369. }
  370. MobileFilePathCallBack(responce, filePath, mobileFilePath) {
  371. mobileFilePath.replace(/^\//, '');
  372. filePath = filePath.replace(mobileFilePath + '/', '');
  373. var tempPath = filePath.split("~/");
  374. var checkPath = tempPath[tempPath.length - 1];
  375. filePath = checkPath;
  376. var server_url = _appsettings.server_url();
  377. if (!filePath.includes(server_url)) {
  378. filePath = server_url + "/" + filePath;
  379. }
  380. var a = document.createElement("a");
  381. a.href = filePath;
  382. a.download = responce.result.FileName;
  383. a.click();
  384. }
  385. downloadGstrReport(gstno) {
  386. Unibase.Platform.Helpers.FileCacheHelper.Instance().loadJsFiles(["libs/xlsx/xlsx.core.min.js", "libs/alasql/alasql.min.js", "apps/transact/managers/invoicemanager.js"], function () {
  387. if (gstno == "" || gstno == "Select")
  388. gstno = 0;
  389. Bizgaze.Apps.Transact.Managers.InvoiceManager.Instance().getGSTRReport(gstno).then(function (result) {
  390. var GstSummary = JSON.parse(result.result[0]);
  391. var B2BData = JSON.parse(result.result[1]);
  392. var B2CSData = JSON.parse(result.result[2]);
  393. var B2CLdata = [""];
  394. if (result.result[3] != '[]')
  395. B2CLdata = JSON.parse(result.result[3]);
  396. var CDNRdata = [""];
  397. if (result.result[4] != '[]')
  398. CDNRdata = JSON.parse(result.result[4]);
  399. var CDNUdata = [""];
  400. if (result.result[5] != '[]')
  401. CDNUdata = JSON.parse(result.result[5]);
  402. var HSNSdata = [""];
  403. if (result.result[6] != '[]')
  404. HSNSdata = JSON.parse(result.result[6]);
  405. var PurchaseHSNSdata = [""];
  406. if (result.result[7] != '[]')
  407. PurchaseHSNSdata = JSON.parse(result.result[7]);
  408. var PurchaseB2B = [""];
  409. if (result.result[8] != '[]')
  410. PurchaseB2B = JSON.parse(result.result[8]);
  411. var Seriesdata = [""];
  412. if (result.result[9] != '[]')
  413. Seriesdata = JSON.parse(result.result[9]);
  414. var opts = [{ sheetid: 'GstSummary', header: true }, { sheetid: 'B2BDetails', header: true }, { sheetid: 'B2CSDetails', header: false }, { sheetid: 'B2CLDetails', header: false }, { sheetid: 'CDNR', header: false }, { sheetid: 'CDNU', header: false }, { sheetid: 'HSN', header: false }, { sheetid: 'PurchaseHSN', header: false }, { sheetid: 'PurchaseB2B', header: false }, { sheetid: 'DOCS', header: false }];
  415. let _alexcelclient = window['alasql'];
  416. var res = _alexcelclient('SELECT INTO XLSX("GSTRReturnsDetails.xlsx",?) FROM ?', [opts, [GstSummary, B2BData, B2CSData, B2CLdata, CDNRdata, CDNUdata, HSNSdata, PurchaseHSNSdata, PurchaseB2B, Seriesdata]]);
  417. }, function (response) {
  418. MessageHelper.Instance().showError(response.responseText, "");
  419. });
  420. });
  421. }
  422. refreshTaxclassifications() {
  423. Unibase.Platform.Helpers.FileCacheHelper.Instance().loadJsFiles(["apps/transact/managers/invoicemanager.js"], function () {
  424. Bizgaze.Apps.Transact.Managers.InvoiceManager.Instance().refreshTaxclassifications().then(function (result) {
  425. MessageHelper.Instance().showSuccess(result.message, "Invoice TaxClassifications refreshed successfully");
  426. });
  427. });
  428. }
  429. static Instance() {
  430. if (this.instance === undefined) {
  431. this.instance = new PrintInvoice();
  432. }
  433. return this.instance;
  434. }
  435. }
  436. Invoices.PrintInvoice = PrintInvoice;
  437. })(Invoices = Components.Invoices || (Components.Invoices = {}));
  438. })(Components = Transact.Components || (Transact.Components = {}));
  439. })(Transact = Apps.Transact || (Apps.Transact = {}));
  440. })(Apps = Bizgaze.Apps || (Bizgaze.Apps = {}));
  441. })(Bizgaze || (Bizgaze = {}));