Built files from Bizgaze WebServer
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

wizard.js 22KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275
  1. var Unibase;
  2. (function (Unibase) {
  3. let Themes;
  4. (function (Themes) {
  5. let Compact;
  6. (function (Compact) {
  7. let Components;
  8. (function (Components) {
  9. let Wizard;
  10. (function (Wizard_1) {
  11. class Wizard {
  12. constructor() {
  13. this.logoFileData = {};
  14. }
  15. wizardApp() {
  16. let instance = this;
  17. let html = ` <!--Wizard div start popup -->
  18. <a href="javascript:;" class="btn btn-sm btn-primary hidden" data-toggle="modal" data-target="#wizard-multi-step"></a>
  19. <div id="wizard-multi-step" class="multi-step" data-wizard="Multi-step-form">
  20. </div><!--Wizard div end popup -->`;
  21. var _fileCacheHelper = Unibase.Platform.Helpers.FileCacheHelper.Instance();
  22. let result = Unibase.Themes.Compact.Components.Index.Instance().currentTheme;
  23. let css = `<style id="wizard"> .multi-step .modal-header .modal-steps .step.completed .dot:before { background: ${result.primaryColor} !important; }.multi-step .modal-header .modal-steps .step.current .dot {border-color: ${result.primaryColor} !important;} .multi-step .modal-header .modal-steps .step.completed:after { border-color: ${result.primaryColor} !important; }.multi-step .modal-header .modal-steps .step.current:after { border-color: ${result.primaryColor} !important; }.multi-step .modal-header .modal-steps .step.completed .dot { border-color: ${result.primaryColor} !important; }
  24. </style>`;
  25. $('head').append(css);
  26. $('#bizgaze_body + [data-target="#wizard-multi-step"]').remove();
  27. $('#bizgaze_body + [id="wizard-multi-step"]').remove();
  28. $('#bizgaze_body').after(html);
  29. _fileCacheHelper.loadJsFile("libs/wizard/js/MultiStep.js", function () {
  30. _fileCacheHelper.loadCssFiles(["libs/wizard/css/MultiStep.min.css", "libs/wizard/css/MultiStep-theme.min.css"], null);
  31. eval(`$(document).ready(function () {
  32. $('#wizard-multi-step').MultiStep({
  33. data:[{
  34. label:'Company Details',
  35. content:'<ul class="d-flex flex-column"><li class="d-flex flex-column li_CompanyName pt-1 pb-20" id="li_CompanyName"><label for="txt_companyName" class="" id="lbl">Company Name<span class="text-danger"> *</span></label> <input type="text" id="txt_companyName" class="form-control floating-label-control shadow-none" data-validation="true" placeholder="Company Name *" data-placeholder="Enter Company Name" data-validatename="Company Name" data-label="Company Name *" required></li><li class="d-flex flex-column li_ShortCode pt-1 pb-20" id="li_ShortCode"><label for="txt_cmpyShortCode" class="" id="lbl">Company Short Code<span class="text-danger"> *</span></label> <input type="text" id="txt_cmpyShortCode" class="form-control floating-label-control shadow-none" placeholder="Company Short Code *" data-validation="true" data-placeholder="Enter Company Short Code" data-validatename="Company Short Code" data-label="Company Short Code *" required></li><li class="d-flex flex-column li_gst-number pt-1 pb-20" id="li_gst-number"><label for="txt_gstNumber" class="" id="lbl">GST Number<span class="text-danger"> *</span></label> <input type="text" id="txt_gstNumber" class="form-control floating-label-control shadow-none" data-validation="true" placeholder="GST Number *" data-placeholder="Enter GST Number" data-validatename="GST Number" data-label="GST Number *" required maxlength="15"></li><li><ul class="p-2 d-flex flex-column"><li><p class="font-16 text-center text-dark">Upload Company Logo</p></li><li class="d-flex flex-column mx-auto" onchange="Unibase.Themes.Compact.Components.Wizard.Wizard.Instance().uploadlogo(this);"><div class="file position-relative d-flex justify-content-center mt-2" id="div_logo-File"><label for="txt_logoFile" id="lbl_logo" class="d-flex "><span class="w-50p"><img src="tenants/themes/compact/imgs/cloud.svg" class="img-fluid"></span></label><input type="file" class="d-none" id="txt_logoFile"></div><div style="margin-top:-15px;"><span class="text-dark" id="lblLogoFileName"></span><span class="text-dark hidden" for="txt_logoFile" id="lbl-logo-path"></span><input type="hidden" id="hf_logoPath" value=""></div></li></ul></li></ul>'
  36. },{
  37. label:'Address Details',
  38. content:'<ul class="d-flex flex-column"><li class="d-flex flex-column li_BranchName pt-1 pb-20" id="li_BranchName"><label for="txt_BranchName" class="" id="lbl">Branch Name<span class="text-danger"> *</span></label> <input type="text" id="txt_BranchName" class="form-control floating-label-control shadow-none" data-validation="true" placeholder="Branch Name *" data-placeholder="Enter Branch Name" data-validatename="Branch Name" data-label="Branch Name *"></li><li class="d-flex flex-column li_ShortCode pt-1 pb-20" id="li_ShortCode"><label for="txt_ShortCode" class="" id="lbl">Short Code<span class="text-danger"> *</span></label> <input type="text" id="txt_ShortCode" class="form-control floating-label-control shadow-none" data-validation="true" placeholder="Short Code *" data-placeholder="Enter Short Code" data-validatename="Short Code" data-label="Short Code *"></li><li class="d-flex flex-column li_Address pt-1 pb-20" id="li_Address"><label for="txt_Address" class="" id="lbl">Address<span class="text-danger"> *</span></label> <input type="text" id="txt_Address" class="form-control floating-label-control shadow-none" placeholder="Address *" data-validation="true"data-placeholder="Enter Address" data-validatename="Address" data-label="Address *"></li><li><ul class="d-flex justify-content-between"><li class="w-45 d-flex flex-column li_CityName pt-1 pb-20 mr-20" id="li_CityName"><label for="txt_CityName" class="" id="lbl">City Name<span class="text-danger"> *</span></label> <select type="text" id="txt_CityName" class="form-control floating-label-control shadow-none" data-validation="true" placeholder="City Name *" data-placeholder="Enter City Name" data-validatename="City Name" data-label="City Name *"></select></li><li class="w-45 d-flex flex-column li_PinCode pt-1 pb-20" id="li_PinCode"><label for="txt_PinCode" class="" id="lbl">Pin-Code<span class="text-danger"> *</span></label> <input type="number" id="txt_PinCode" class="form-control floating-label-control shadow-none" placeholder="Pin Code *" data-validation="true" data-placeholder="Enter Pin Code" data-validatename="Pin Code" min="0" max="6" data-label="Pin Code *"></li></ul></li></ul>'
  39. }],
  40. finalLabel:'Confirmation',
  41. final:'<ul class="w-100 d-flex align-items-center flex-column justify-content-center"><li class="w-100 d-flex justify-content-center"><i class="fa-4x fa fa-check-circle text-success"></i></li><li class="mt-20 mb-1 text-center">Your Company information is successfully updated for more help<a class="ml-1" href="javascript:;">Click here</a></li></ul>',
  42. modalSize:'md'
  43. });
  44. Unibase.Themes.Compact.Components.Wizard.Wizard.Instance().logoFileData = {};
  45. Unibase.Themes.Compact.Components.Wizard.Wizard.Instance().autoComplete();
  46. $('[data-target="#wizard-multi-step"]').click();
  47. $('[data-isNext="true"]').on('click', function(){
  48. Unibase.Themes.Compact.Components.Wizard.Wizard.Instance().validation();
  49. });
  50. Unibase.Themes.Compact.Components.Wizard.Wizard.Instance().clickEvent();
  51. $('#txt_gstNumber').on('keydown', function(){
  52. $(this).addClass('text-uppercase');
  53. let gst_val = $(this).val();
  54. if(gst_val.length < 2){
  55. return numericOnly(event);
  56. }
  57. else if((gst_val.length >= 2) && (gst_val.length < 7)){
  58. return alphaOnly(event);
  59. }
  60. else if((gst_val.length >= 7) && (gst_val.length < 11)){
  61. return numericOnly(event);
  62. }
  63. else if((gst_val.length >= 11) && (gst_val.length < 12)){
  64. return alphaOnly(event);
  65. }
  66. else if((gst_val.length >= 12) && (gst_val.length < 13)){
  67. return numericOnly(event);
  68. }
  69. else if((gst_val.length >= 13) && (gst_val.length < 14)){
  70. return alphaOnly(event);
  71. }
  72. else if((gst_val.length >= 14) && (gst_val.length < 15)){
  73. return alphaNumeric(event);
  74. }
  75. })
  76. function alphaOnly(event) {
  77. var key = event.keyCode;
  78. if(((key >= 65 && key <= 90) || key == 8) == false){
  79. MessageHelper.Instance().showError("Please Enter valid GST Number", "div_errroMessage");
  80. }
  81. else if((key >= 65 && key <= 90) || key == 8){
  82. if ($('#Bizgaze-messageInfo')) {
  83. $('#Bizgaze-messageInfo').click()
  84. }
  85. }
  86. return ((key >= 65 && key <= 90) || key == 8);
  87. };
  88. function numericOnly(event) {
  89. var key = event.keyCode;
  90. if(((key >= 47 && key <= 58) || key == 8 || (key > 95 && key < 106)) == false){
  91. MessageHelper.Instance().showError("Please Enter valid GST Number", "div_errroMessage");
  92. }
  93. else if((key >= 47 && key <= 58) || key == 8 || (key > 95 && key < 106)){
  94. if ($('#Bizgaze-messageInfo')) {
  95. $('#Bizgaze-messageInfo').click()
  96. }
  97. }
  98. return ((key > 47 && key < 58) || key == 8 || (key > 95 && key < 106));
  99. };
  100. function alphaNumeric(event) {
  101. var key = event.keyCode;
  102. return ((key > 47 && key < 58) || key == 8 || (key >= 65 && key <= 90));
  103. };
  104. });
  105. `);
  106. });
  107. }
  108. validation() {
  109. let instance = Unibase.Themes.Compact.Components.Wizard.Wizard.Instance().logoFileData;
  110. let validation = true;
  111. $('.step-content.active').find('[data-validation="true"]').each(function () {
  112. if ($(this).val() == '') {
  113. $(this).attr('style', 'border-bottom:1px solid rgb(251, 107, 91) !important');
  114. $(this).on('click', function () {
  115. $(this).attr('style', '');
  116. });
  117. validation = false;
  118. MessageHelper.Instance().showError("Please Enter manadatory", "div_errroMessage");
  119. }
  120. else if ($('.step-content.active').find('#div_logo-File').length > 0) {
  121. var regex = /^[0-9]{2}[A-Z]{5}[0-9]{4}[A-Z]{1}[1-9A-Z]{1}Z[0-9A-Z]{1}$/;
  122. if (instance == undefined || instance.FileData == undefined || instance.FileName == undefined) {
  123. validation = false;
  124. MessageHelper.Instance().showError("Please Upload Company Logo", "div_errroMessage");
  125. }
  126. else if (regex.test($("#txt_gstNumber").val().toString()) == false) {
  127. validation = false;
  128. MessageHelper.Instance().showError("Please Enter valid GST Number", "div_errroMessage");
  129. }
  130. }
  131. });
  132. if (validation) {
  133. if ($('#Bizgaze-messageInfo')) {
  134. $('#Bizgaze-messageInfo').click();
  135. }
  136. let i = Number($('.step-content.active').attr('data-step'));
  137. let j = i + 1;
  138. if (i == 3) {
  139. $('a.close-btn').click();
  140. Unibase.Platform.Membership.Infos.Identity.currentUser.settings.filter(function (x) { return x.settingName == "isloginfirsttime"; })[0].settingValue == false;
  141. Unibase.Themes.Compact.Components.Dashboard.Instance().appTourGuide();
  142. }
  143. if (i != 3) {
  144. $('[id="multi_Step-next"]').click();
  145. }
  146. }
  147. }
  148. uploadlogo(e) {
  149. let instance = this;
  150. const inputEl = document.getElementById('txt_logoFile');
  151. const fileType = inputEl.files[0].type.split('/').pop().toLowerCase();
  152. if (fileType != "jpeg" && fileType != "jpg" && fileType != "png" && fileType != "bmp" && fileType != "gif") {
  153. MessageHelper.Instance().showError('Please select a valid image file', 'layoutBuilderErrMsg');
  154. $("#logoUploadInput").val('');
  155. return false;
  156. }
  157. else {
  158. const [file] = inputEl.files;
  159. let name;
  160. if (file) {
  161. const reader = new FileReader();
  162. reader.readAsDataURL(file);
  163. reader.onloadend = function () {
  164. var base64String = reader.result.toString().replace(/^data:.+;base64,/, '');
  165. var fileReq = {
  166. FileData: base64String,
  167. FileName: inputEl.files[0].name,
  168. FileType: fileType,
  169. ByteData: null
  170. };
  171. instance.logoFileData = fileReq;
  172. $('[data-span_file="true"]').remove();
  173. $(inputEl).parents('#div_logo-File').after('<span data-span_file="true">' + inputEl.files[0].name + '</span>');
  174. };
  175. }
  176. }
  177. }
  178. clickEvent() {
  179. let instance = this;
  180. instance.multiStep();
  181. $('#multi_Step-prev').on('click', function () {
  182. instance.multiStep();
  183. });
  184. }
  185. autoComplete() {
  186. Unibase.Themes.Compact.Wizard.Manager.WizardManager.Instance().getCityName().then(function (res) {
  187. let response = res.result, data = [];
  188. response.forEach(function (item, index) {
  189. data.push({ id: item.cityid, text: item.cityname });
  190. });
  191. $('#txt_CityName').select2({
  192. placeholder: "Select City",
  193. data: data
  194. });
  195. });
  196. }
  197. multiStep() {
  198. $('.step-content').each(function (index, item) {
  199. if (index == 0 && $(this).hasClass("active")) {
  200. $('#multi_Step-next').attr('onclick', 'Unibase.Themes.Compact.Components.Wizard.Wizard.Instance().companyDetails()');
  201. }
  202. else if (index == 1 && $(this).hasClass("active")) {
  203. $('#multi_Step-next').attr('onclick', 'Unibase.Themes.Compact.Components.Wizard.Wizard.Instance().BranchDetails()');
  204. }
  205. else if (index == 2 && $(this).hasClass("active")) {
  206. $('#multi_Step-next').attr('onclick', 'Unibase.Themes.Compact.Components.Wizard.Wizard.Instance().emptyMultiStep()');
  207. }
  208. });
  209. }
  210. emptyMultiStep() {
  211. $('a.close-btn').click();
  212. $('[id="wizard-multi-step"]').remove();
  213. $('[data-target="#wizard-multi-step"]').remove();
  214. }
  215. companyDetails() {
  216. let instance = this;
  217. if ($('#txt_companyName').val() != "" && $('#txt_cmpyShortCode').val() != "" && $('#txt_gstNumber').val() != 0) {
  218. let obj;
  219. obj = {
  220. CompanyName: $('#txt_companyName').val(),
  221. ShortCode: $('#txt_cmpyShortCode').val(),
  222. GstInNo: $('#txt_gstNumber').val(),
  223. FileName: instance.logoFileData.FileName,
  224. FileData: instance.logoFileData.FileData
  225. };
  226. Unibase.Themes.Compact.Wizard.Manager.WizardManager.Instance().saveCompanyDetails(obj).then(function (response) {
  227. if (response.status == 0) {
  228. instance.multiStep();
  229. }
  230. else {
  231. MessageHelper.Instance().showError(response.code, "div_errroMessage");
  232. $("p:nth-child(0)").addClass('active');
  233. }
  234. });
  235. }
  236. else {
  237. }
  238. }
  239. BranchDetails() {
  240. let instance = this;
  241. console.log("Branch Details");
  242. let obj;
  243. obj = {
  244. AliasName: $('#txt_BranchName').val(),
  245. ShortCode: $('#txt_ShortCode').val(),
  246. PinCode: Number($('#txt_PinCode').val()),
  247. AddressName: $('#txt_Address').val(),
  248. CityName: $('#txt_CityName option:selected').text(),
  249. Addressline1: " ",
  250. CityId: Number($('#txt_CityName option:selected').val())
  251. };
  252. Unibase.Themes.Compact.Wizard.Manager.WizardManager.Instance().saveBranchDetails(obj).then(function (response) {
  253. if (response.status == 0) {
  254. instance.multiStep();
  255. }
  256. else {
  257. $('.step-content').removeClass('active');
  258. $("p:nth-child(1)").addClass('active');
  259. }
  260. });
  261. }
  262. static Instance() {
  263. if (this._instance === undefined)
  264. this._instance = new Unibase.Themes.Compact.Components.Wizard.Wizard;
  265. return this._instance;
  266. }
  267. }
  268. Wizard_1.Wizard = Wizard;
  269. })(Wizard = Components.Wizard || (Components.Wizard = {}));
  270. })(Components = Compact.Components || (Compact.Components = {}));
  271. })(Compact = Themes.Compact || (Themes.Compact = {}));
  272. })(Themes = Unibase.Themes || (Unibase.Themes = {}));
  273. })(Unibase || (Unibase = {}));