Built files from Bizgaze WebServer
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

logitics.component.js 8.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  1. var Bizgaze;
  2. (function (Bizgaze) {
  3. let Apps;
  4. (function (Apps) {
  5. let Transact;
  6. (function (Transact) {
  7. let Controls;
  8. (function (Controls) {
  9. class Logistics extends Unibase.Platform.Core.BaseComponent {
  10. init(formpropertyid, prop, callback) {
  11. var instance = this;
  12. var companyId = 0;
  13. if (Unibase.Platform.Membership.Infos.Identity.getCurrentUser().settings != null) {
  14. var companySetting = Unibase.Platform.Membership.Infos.Identity.getCurrentUser().settings.find(x => x.settingName == "companyid");
  15. if (companySetting != null) {
  16. companyId = companySetting.settingValue;
  17. var Parameters = [{ "ColumnName": "companyid", "Value": companyId, }];
  18. Unibase.Forms.Controls.AutoComplete.Instance().LoadAutoComplete($(".txtAutoComplete_fromaddressid"), Parameters);
  19. }
  20. else {
  21. $(".txtAutoComplete_leadid").attr("disabled", "disabled");
  22. Unibase.Platform.Forms.Components.FormViewer.Instance().showError("Please Configure Default Branch");
  23. }
  24. }
  25. else {
  26. $(".txtAutoComplete_leadid").attr("disabled", "disabled");
  27. Unibase.Platform.Forms.Components.FormViewer.Instance().showError("Please Configure Default Branch");
  28. }
  29. var Parameters = [{ "ColumnName": "contactid", "Value": Number($(".txtAutoComplete_leadid option:selected").val()), }];
  30. Unibase.Forms.Controls.AutoComplete.Instance().LoadAutoComplete($(".txtAutoComplete_toaddressid"), Parameters);
  31. $(".txtAutoComplete_leadid").change(function () {
  32. var Parameters = [{ "ColumnName": "contactid", "Value": Number($(".txtAutoComplete_leadid option:selected").val()), }];
  33. Unibase.Forms.Controls.AutoComplete.Instance().LoadAutoComplete($(".txtAutoComplete_toaddressid"), Parameters);
  34. setTimeout(function () {
  35. var Number = $('.txtAutoComplete_leadid').attr("data-addldata");
  36. if (Number != undefined) {
  37. $(".txt_contactnumber").val(Number);
  38. }
  39. }, 200);
  40. });
  41. Unibase.Platform.Helpers.FileCacheHelper.Instance().loadJsFiles(["apps/transact/controls/pricelist/managers/pricelistmanager.js", "apps/transact/managers/inventory/itemmanager.js"], function () {
  42. $(".txtAutoComplete_itemid").change(function () {
  43. Bizgaze.Apps.Transact.Managers.PriceListManager.Instance().getPriceValue(Number($(".txtAutoComplete_itemid option:selected").val())).then(function (response) {
  44. if (response.result != null) {
  45. $(".txt_unitprice").val(response.result.ListPrice);
  46. }
  47. });
  48. Bizgaze.Apps.Transact.Managers.ItemManager.Instance().getItem(Number($(".txtAutoComplete_itemid option:selected").val())).then(function (response) {
  49. if (response.result != null) {
  50. $(".txt_height").val(response.result.ItemHeight);
  51. $(".txt_length").val(response.result.ItemLength);
  52. $(".txt_width").val(response.result.ItemWidth);
  53. $(".txt_weight").val(response.result.ItemWeight);
  54. $(".txt_weight").attr("disabled", "disabled");
  55. }
  56. });
  57. });
  58. $(".txtAutoComplete_fromaddressid").change(function () {
  59. instance.getDistance();
  60. });
  61. $(".txtAutoComplete_toaddressid").change(function () {
  62. setTimeout(function () {
  63. instance.getDistance();
  64. }, 200);
  65. });
  66. });
  67. }
  68. getDistance() {
  69. var fromplace = Number($('.txtAutoComplete_fromaddressid').attr("data-addldata"));
  70. var apikey = 'AIzaSyBGmahAAg3EVzAUJvttDZsjdZiJenJxGt8';
  71. if (apikey == undefined) {
  72. }
  73. var toplace = Number($('.txtAutoComplete_toaddressid').attr("data-addldata"));
  74. if (toplace == 0) {
  75. $('.txt_distance').val(0);
  76. }
  77. else {
  78. $.ajax({
  79. url: "https://maps.googleapis.com/maps/api/geocode/json?address=" + fromplace + "%20%22&key=" + apikey + "&sensor=false",
  80. method: "POST",
  81. success: function (data) {
  82. let latitude, longitude, flatitude, flongitude;
  83. flatitude = data.results[0].geometry.location.lat;
  84. flongitude = data.results[0].geometry.location.lng;
  85. $.ajax({
  86. url: "https://maps.googleapis.com/maps/api/geocode/json?address=" + toplace + "%20%22&key=" + apikey + "&sensor=false",
  87. method: "POST",
  88. success: function (_data) {
  89. latitude = _data.results[0].geometry.location.lat;
  90. longitude = _data.results[0].geometry.location.lng;
  91. var dd = getDistanceFromLatLonInKm(flatitude, flongitude, latitude, longitude);
  92. $('.txt_distance').val(Math.round(dd));
  93. }
  94. });
  95. }
  96. });
  97. function getDistanceFromLatLonInKm(lat1, lon1, lat2, lon2) {
  98. var R = 6371;
  99. var dLat = deg2rad(lat2 - lat1);
  100. var dLon = deg2rad(lon2 - lon1);
  101. var a = Math.sin(dLat / 2) * Math.sin(dLat / 2) +
  102. Math.cos(deg2rad(lat1)) * Math.cos(deg2rad(lat2)) *
  103. Math.sin(dLon / 2) * Math.sin(dLon / 2);
  104. var c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1 - a));
  105. var d = R * c;
  106. return d;
  107. }
  108. function deg2rad(deg) {
  109. return deg * (Math.PI / 180);
  110. }
  111. }
  112. }
  113. loadControl(containerid, prop) {
  114. return "";
  115. }
  116. loadControlSettings(controlsettingjson, formpropertyid) {
  117. return "";
  118. }
  119. loadPropertySettings(propertysettings, formpropertyid, DocPropertyName) {
  120. return "";
  121. }
  122. bindEditFormDetails(formpropertyid, propval, DocPropertyName) {
  123. return "";
  124. }
  125. static Instance() {
  126. if (this.instance === undefined) {
  127. this.instance = new Logistics();
  128. }
  129. return this.instance;
  130. }
  131. }
  132. Controls.Logistics = Logistics;
  133. })(Controls = Transact.Controls || (Transact.Controls = {}));
  134. })(Transact = Apps.Transact || (Apps.Transact = {}));
  135. })(Apps = Bizgaze.Apps || (Bizgaze.Apps = {}));
  136. })(Bizgaze || (Bizgaze = {}));