Built files from Bizgaze WebServer
Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

ewaybill.component.js 21KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268
  1. var Bizgaze;
  2. (function (Bizgaze) {
  3. let Apps;
  4. (function (Apps) {
  5. let Integrations;
  6. (function (Integrations) {
  7. let EWayBill;
  8. (function (EWayBill_1) {
  9. let Components;
  10. (function (Components) {
  11. class EWayBill extends Unibase.Platform.Core.BaseComponent {
  12. jsFiles() {
  13. return [];
  14. }
  15. cssFiles() {
  16. return [];
  17. }
  18. html() {
  19. return null;
  20. }
  21. load() {
  22. Bizgaze.Apps.Integrations.EWayBill.Components.EWayBill.Instance().getInvoiceDetails();
  23. $(".txt_vehicleno").keyup(function () {
  24. $(".txt_vehicleno").val($(".txt_vehicleno").val().toString().toUpperCase());
  25. });
  26. $(".txt_topincode,.txt_frompincode").on("click", function () {
  27. Bizgaze.Apps.Integrations.EWayBill.Components.EWayBill.Instance().GetDistanceByPinCode();
  28. });
  29. }
  30. getAddressById(id) {
  31. let AutoComplete_branchid = Number($(".txtAutoComplete_branchid").val());
  32. if (id != 0)
  33. AutoComplete_branchid = id;
  34. Unibase.Platform.Helpers.FileCacheHelper.Instance().loadJsFile("apps/crm/contacts/managers/contactmanager.js", function () {
  35. Bizgaze.Apps.Crm.Contacts.Managers.ContactManager.Instance().getAddressById(AutoComplete_branchid).then(function (response) {
  36. if (response.result != null) {
  37. $(".txt_frompincode").val(response.result.ZipCode).parent().addClass("floating-label-form-group-with-value");
  38. ;
  39. $(".labelSection_FromGSTIN").html("<span>From GSTIN : " + response.result.GSTNO + "</span>");
  40. Bizgaze.Apps.Integrations.EWayBill.Components.EWayBill.Instance().getDistance();
  41. $(".hdn_fromplace").val(response.result.AliasName);
  42. $(".hdn_fromstatecode").val(response.result.StateCode);
  43. if (Number($(".txtAutoComplete_branchid").val()) == 0) {
  44. let supplytype = new Option(response.result.AliasName, AutoComplete_branchid.toString(), true);
  45. $(".txtAutoComplete_branchid").append(supplytype);
  46. $(".hfAutoCompleteId_branchid").val(AutoComplete_branchid);
  47. }
  48. }
  49. });
  50. });
  51. }
  52. getInvoiceDetails() {
  53. var InstalledAppId = Unibase.Themes.Providers.DetailHelper.installedAppId;
  54. if (Unibase.Themes.Providers.Detail_Settings.Instance().InputParameters.find(x => x.Key == "hf_" + InstalledAppId + "_invoiceid") != undefined) {
  55. var invoiceid = Number(Unibase.Themes.Providers.Detail_Settings.Instance().InputParameters.find(x => x.Key == "hf_" + InstalledAppId + "_invoiceid").Value);
  56. if (invoiceid != 0) {
  57. Unibase.Platform.Helpers.FileCacheHelper.Instance().loadJsFiles(["apps/transact/managers/invoicemanager.js"], function () {
  58. Bizgaze.Apps.Transact.Managers.InvoiceManager.Instance().getInvoiceDetails(invoiceid).then(function (response) {
  59. if (response.result != null) {
  60. $(".txt_frompincode").val(response.result.BillFromZipCode).parent().addClass("floating-label-form-group-with-value");
  61. $(".txt_topincode").val(response.result.BillToZipCode).parent().addClass("floating-label-form-group-with-value");
  62. $(".labelSection_ToGSTIN").html("<span>To GSTIN : " + response.result.GSTNo + "</span>");
  63. $(".hdn_refid").val(invoiceid);
  64. $(".hdn_dcid").val(response.result.DcId);
  65. $(".hdn_invoiceid").val(invoiceid);
  66. $(".hdn_refinstalledappid").val(response.result.InstalledAppId);
  67. let supplytype = new Option("Outward", "1", true);
  68. $(".txtAutoComplete_supplytypeid").append(supplytype).val(1).trigger("change");
  69. Bizgaze.Apps.Integrations.EWayBill.Components.EWayBill.Instance().getAddressById(response.result.BillFromAddressId);
  70. }
  71. });
  72. });
  73. }
  74. }
  75. else {
  76. if (Unibase.Themes.Providers.Detail_Settings.Instance().InputParameters.find(x => x.Key == "hf_" + InstalledAppId + "_dcid") != undefined) {
  77. var dcid = Number(Unibase.Themes.Providers.Detail_Settings.Instance().InputParameters.find(x => x.Key == "hf_" + InstalledAppId + "_dcid").Value);
  78. if (dcid != 0) {
  79. Unibase.Platform.Helpers.FileCacheHelper.Instance().loadJsFiles(["apps/transact/managers/inventory/dcmanager.js"], function () {
  80. Bizgaze.Apps.Transact.Managers.DCManager.Instance().getdc(dcid).then(function (response) {
  81. if (response.result != null) {
  82. $(".txt_frompincode").val(response.result.ShipFromZipCode).addClass("floating-label-form-group-with-value");
  83. ;
  84. $(".txt_topincode").val(response.result.ShipToZipCode).addClass("floating-label-form-group-with-value");
  85. ;
  86. $(".labelSection_ToGSTIN").html("<span>To GSTIN : " + response.result.GSTInNo + "</span>");
  87. $(".hdn_isdc").val("true");
  88. $(".hdn_refid").val(dcid);
  89. $(".hdn_invoiceid").val(response.result.InvoiceId);
  90. $(".hdn_dcid").val(dcid);
  91. $(".hdn_refinstalledappid").val(response.result.DcInstallAppId);
  92. let supplytype = new Option("Inward", "2", true);
  93. $(".txtAutoComplete_supplytypeid").append(supplytype).val(2).trigger("change");
  94. ;
  95. Bizgaze.Apps.Integrations.EWayBill.Components.EWayBill.Instance().getAddressById(0);
  96. }
  97. });
  98. });
  99. }
  100. }
  101. }
  102. }
  103. getDistance() {
  104. var fromplace = Number($('.txt_frompincode').val());
  105. var apikey = 'AIzaSyBGmahAAg3EVzAUJvttDZsjdZiJenJxGt8';
  106. if (apikey == undefined) {
  107. }
  108. var toplace = Number($('.txt_topincode').val());
  109. if (toplace == 0) {
  110. $('.number_approxdistance').val(0);
  111. }
  112. else {
  113. $.ajax({
  114. url: "https://maps.googleapis.com/maps/api/geocode/json?address=" + fromplace + "%20%22&key=" + apikey + "&sensor=false",
  115. method: "POST",
  116. success: function (data) {
  117. let latitude, longitude, flatitude, flongitude;
  118. if (data.results.length > 0) {
  119. flatitude = data.results[0].geometry.location.lat;
  120. flongitude = data.results[0].geometry.location.lng;
  121. $.ajax({
  122. url: "https://maps.googleapis.com/maps/api/geocode/json?address=" + toplace + "%20%22&key=" + apikey + "&sensor=false",
  123. method: "POST",
  124. success: function (_data) {
  125. latitude = _data.results[0].geometry.location.lat;
  126. longitude = _data.results[0].geometry.location.lng;
  127. var dd = getDistanceFromLatLonInKm(flatitude, flongitude, latitude, longitude);
  128. $('.number_approxdistance').val(Math.round(dd));
  129. }
  130. });
  131. }
  132. }
  133. });
  134. function getDistanceFromLatLonInKm(lat1, lon1, lat2, lon2) {
  135. var R = 6371;
  136. var dLat = deg2rad(lat2 - lat1);
  137. var dLon = deg2rad(lon2 - lon1);
  138. var a = Math.sin(dLat / 2) * Math.sin(dLat / 2) +
  139. Math.cos(deg2rad(lat1)) * Math.cos(deg2rad(lat2)) *
  140. Math.sin(dLon / 2) * Math.sin(dLon / 2);
  141. var c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1 - a));
  142. var d = R * c;
  143. return d;
  144. }
  145. function deg2rad(deg) {
  146. return deg * (Math.PI / 180);
  147. }
  148. }
  149. }
  150. ShowPrintButton() {
  151. debugger;
  152. let instance = this;
  153. let InstalledAppId = Unibase.Themes.Providers.DetailHelper.installedAppId;
  154. let EWaybillId = Number(Unibase.Themes.Providers.DetailHelper.recordId);
  155. let detailContainer = "#" + Unibase.Platform.Helpers.NavigationHelper.ModalContainerIds[Unibase.Platform.Helpers.NavigationHelper.ModalContainerIds.length - 1];
  156. $(detailContainer).find(".DetailSetting_" + InstalledAppId + "_Print").removeClass("btn-undefined").addClass("btn-warning");
  157. $(".btn-undefined").addClass("btn-success").removeClass("btn-undefined");
  158. instance.fileCacheHelper.loadJsFile("apps/transact/managers/ewaybill/ewaybillmanager.js", function (response) {
  159. Bizgaze.Apps.Transact.Managers.EWayBillManager.Instance().getEwayBill(EWaybillId).then(function (ewaybillresponse) {
  160. if (ewaybillresponse.result.Notes != null && ewaybillresponse.result.Notes != undefined && ewaybillresponse.result.Notes != "") {
  161. $(detailContainer).find(".li_DetailSetting_" + InstalledAppId + "_ApprovalError").remove();
  162. $(detailContainer).find('#div_App_DefaultWidgetSettings').append(`<div><div class="ActionsApprovalError mx-20 mb-2 rounded py-10 px-0 li_DetailSetting_` + InstalledAppId + `_ApprovalError" id="li_DetailSetting_` + InstalledAppId + `_ApprovalError" style="background-color:rgb(252 250 247);border-left: 3px solid #ff6060;padding:0.5rem 1rem 1rem;"> <p class="font-14 text-danger col-sm-12">` + ewaybillresponse.result.Notes + `</p> </div>`);
  163. $(detailContainer).find('#div_App_DefaultWidgetSettings').addClass('pb-0');
  164. }
  165. });
  166. });
  167. instance.Print();
  168. }
  169. Print() {
  170. let instance = this;
  171. let detailContainer = "#" + Unibase.Platform.Helpers.NavigationHelper.ModalContainerIds[Unibase.Platform.Helpers.NavigationHelper.ModalContainerIds.length - 1];
  172. if ($(".printsetting").length != 0) {
  173. let printhtml = $(".printsetting")[0].outerHTML;
  174. $(".printsetting").remove();
  175. $(detailContainer).find("#div_App_DefaultWidgetSettings").find(".row").append(printhtml);
  176. $(".printsetting").find(".pull-right").removeClass("pull-right");
  177. }
  178. $('.DetailSetting_' + Unibase.Themes.Providers.DetailHelper.installedAppId + '_Print').html('<span><i class=\"fa fa-print\"></i></span>');
  179. $(detailContainer).find('.DetailSetting_' + Unibase.Themes.Providers.DetailHelper.installedAppId + '_Print').click(function () {
  180. let EwaybillId = Unibase.Themes.Providers.DetailHelper.recordId;
  181. Unibase.Platform.Helpers.FileCacheHelper.Instance().loadJsFiles(["apps/transact/managers/ewaybill/ewaybillmanager.js", "platform/core/helpers/printhelper/printhelper.js"], function () {
  182. Bizgaze.Apps.Transact.Managers.EWayBillManager.Instance().getPrintEWayBill(EwaybillId).then(function (response) {
  183. Unibase.Platform.Helpers.PrintHelper.Instance().printPopup(response.result.PrintHTML);
  184. });
  185. });
  186. });
  187. }
  188. GetDistanceByPinCode() {
  189. let instance = this;
  190. var FromPinCode = $(".txt_frompincode").val().toString();
  191. var ToPinCode = $(".txt_topincode").val().toString();
  192. if (FromPinCode.length == 6 && ToPinCode.length == 6) {
  193. instance.getDistance();
  194. }
  195. }
  196. ShoworHideEWayBillButton() {
  197. let instance = this;
  198. let InstalledAppId = Unibase.Themes.Providers.DetailHelper.installedAppId;
  199. let detailContainer = "#" + Unibase.Platform.Helpers.NavigationHelper.ModalContainerIds[Unibase.Platform.Helpers.NavigationHelper.ModalContainerIds.length - 1];
  200. let RefStatusId = Number(Unibase.Themes.Providers.Detail_Settings.Instance().InputParameters.find(x => x.Key == "hf_" + InstalledAppId + "_refstatusid").Value);
  201. if (RefStatusId == 1 || RefStatusId == 2 || RefStatusId == 6) {
  202. $(detailContainer).find('.li_DetailSetting_' + InstalledAppId + '_E-WayBill').addClass('hidden');
  203. }
  204. else {
  205. $('.DetailSetting_' + Unibase.Themes.Providers.DetailHelper.installedAppId + '_E-WayBill').addClass('hidden');
  206. let ewaybillid = Number(Unibase.Themes.Providers.Detail_Settings.Instance().InputParameters.find(x => x.Key == "hf_" + Unibase.Themes.Providers.DetailHelper.installedAppId + "_ewaybillid") == undefined ? 0 : Unibase.Themes.Providers.Detail_Settings.Instance().InputParameters.find(x => x.Key == "hf_" + Unibase.Themes.Providers.DetailHelper.installedAppId + "_ewaybillid").Value);
  207. if (ewaybillid == 0)
  208. $('.DetailSetting_' + Unibase.Themes.Providers.DetailHelper.installedAppId + '_E-WayBill').removeClass('hidden');
  209. }
  210. }
  211. getdcdetails() {
  212. Unibase.Platform.Helpers.FileCacheHelper.Instance().loadJsFiles(["apps/transact/managers/inventory/dcmanager.js"], function () {
  213. Bizgaze.Apps.Transact.Managers.DCManager.Instance().getdc($(".txtAutoComplete_dcid").val()).then(function (response) {
  214. if (response.result != null) {
  215. $(".hfAutoCompleteId_invoiceid").val(response.result.InvoiceId);
  216. $(".hdn_refid").val($(".txtAutoComplete_dcid").val());
  217. }
  218. });
  219. });
  220. }
  221. GetInvoice() {
  222. Unibase.Platform.Helpers.FileCacheHelper.Instance().loadJsFiles(["apps/transact/managers/invoicemanager.js"], function () {
  223. Bizgaze.Apps.Transact.Managers.InvoiceManager.Instance().getInvoiceDetails($(".txtAutoComplete_invoiceid").val()).then(function (response) {
  224. if (response.result != null) {
  225. $(".hfAutoCompleteId_dcid").val(response.result.DcId);
  226. $(".hdn_refid").val($(".txtAutoComplete_invoiceid").val());
  227. }
  228. });
  229. });
  230. }
  231. checkstatus() {
  232. var installedAppId = Unibase.Themes.Providers.DetailHelper.installedAppId;
  233. var einvoiceid = String(Unibase.Themes.Providers.Detail_Settings.Instance().InputParameters.find(x => x.Key == "hf_" + installedAppId + "_ewaybillid").Value);
  234. var statusid = Number(Unibase.Themes.Providers.Detail_Settings.Instance().InputParameters.find(x => x.Key == "hf_" + installedAppId + "_statusid").Value);
  235. if (statusid != undefined) {
  236. if (statusid == 2) {
  237. $(".DetailSetting_" + installedAppId + "_Cancele-WayBill").addClass("hidden");
  238. $(".DetailSetting_" + installedAppId + "_UpdateVehicleNo").addClass("hidden");
  239. $(".DetailSetting_" + installedAppId + "_e-waybill").addClass("hidden");
  240. }
  241. else {
  242. $(".DetailSetting_" + installedAppId + "_Cancele-WayBill").removeClass("hidden");
  243. $(".DetailSetting_" + installedAppId + "_UpdateVehicleNo").removeClass("hidden");
  244. $(".DetailSetting_" + installedAppId + "_e-waybill").removeClass("hidden");
  245. }
  246. }
  247. }
  248. checkewaybillstatus() {
  249. var installedAppId = Unibase.Themes.Providers.DetailHelper.installedAppId;
  250. var ewaybillno = String(Unibase.Themes.Providers.Detail_Settings.Instance().InputParameters.find(x => x.Key == "hf_" + installedAppId + "_ewaybillno").Value);
  251. if (ewaybillno == " " || ewaybillno == "") {
  252. $(".DetailSetting_" + installedAppId + "_e-waybill").removeClass("hidden");
  253. }
  254. $(".DetailSetting_" + installedAppId + "_e-waybill").addClass("hidden");
  255. }
  256. static Instance() {
  257. if (this.instance === undefined) {
  258. this.instance = new EWayBill();
  259. }
  260. return this.instance;
  261. }
  262. }
  263. Components.EWayBill = EWayBill;
  264. })(Components = EWayBill_1.Components || (EWayBill_1.Components = {}));
  265. })(EWayBill = Integrations.EWayBill || (Integrations.EWayBill = {}));
  266. })(Integrations = Apps.Integrations || (Apps.Integrations = {}));
  267. })(Apps = Bizgaze.Apps || (Bizgaze.Apps = {}));
  268. })(Bizgaze || (Bizgaze = {}));