// // Pages: Project Submit // var progressStep = 0; var projectStep = 0; var projectSubStep = 1; var projectMaxSubStep = [5, 7, 1]; // Max sub step var projectFromInputValue = []; var projectFromInputValueReview = []; var changeStepLock = false; var persianDatepickerInput = null; var persianDatepickerInputSubmit = null; var stepBackup = projectStep; var subStepBackUp = projectSubStep; // Map variables var map = null; var mapReview = null; var sourceLat = ''; var sourceLng = ''; var destLat = ''; var destLng = ''; var countMarker = 0; var sourceMarker = null; var destMarker = null; var sourceReviewMarker = null; var destReviewMarker = null; var routeControls = []; var popupArrays = []; var polyline = null; var originPlaceName = ''; var destinationPlaceName = ''; // Sliders var projectRialSlider, projectPhysicalSlider1, projectPhysicalSlider2, projectPhysicalSlider3, projectPhysicalSlider4, projectPhysicalSlider5, projectPhysicalSlider6; //:: Handler Variables var OstanList = []; var filespath = []; var myDropzone; function changeProgressStep(step, selected = null) { if (step > 0) { if (selected) { let selectedProgressStep = $('.project-timeline > .card-timeline > .card-header ul > li:nth-child(' + (selected + 2) + ')'); selectedProgressStep.addClass('is-active').removeClass('is-completed'); selectedProgressStep.prevAll('li').each(function (index, element) { $(element).addClass('is-completed'); }); } else { let currentProgressStep = $('.project-timeline > .card-timeline > .card-header .is-active').addClass('is-completed').removeClass('is-active'); currentProgressStep.next().addClass('is-active'); } } else { if (selected) { let selectedProgressStep = $('.project-timeline > .card-timeline > .card-header ul > li:nth-child(' + (selected + 2) + ')'); selectedProgressStep.addClass('is-active').removeClass('is-completed'); selectedProgressStep.nextAll('li').each(function (index, element) { $(element).removeClass('is-completed is-active'); }); } else { let currentProgressStep = $('.project-timeline > .card-timeline > .card-header .is-active').removeClass('is-active'); currentProgressStep.prev().addClass('is-active').removeClass('is-completed'); } } progressStep += (step * 25); $('.project-timeline > .card-timeline > .card-header .step-progress').width(progressStep + '%'); } function checkFormValidation() { let message = []; if (projectStep === 0) { return 1; } else { switch (projectStep) { case 1: break; case 2: break; case 3: break; } if (message.length > 0) { showFormErrorMessage(message); return 0; } else { return 1; } } } function checkSubFormValidation() { let message = []; if (projectStep === 0) { return 1; } else { switch (projectStep) { case 1: switch (projectSubStep) { case 1: { if ($('#modalOperationType1').is(':checked')) { setFormInputValue('operationType', 'احداث'); setFormInputValue('operationType_DB', 0); let constructionSubOperations = $('#modalConstructionSubOperation input:checked'); if (constructionSubOperations.length) { let checkedSubOperations = []; let checkedSubOperationsDB = []; for (let index = 0; index < constructionSubOperations.length; index++) { checkedSubOperations.push(returnSubOperation(constructionSubOperations[index].id)); checkedSubOperationsDB.push(parseInt((constructionSubOperations[index].id).substr(-1))); } setFormInputValue('operationSubType', checkedSubOperations); setFormInputValue('operationSubType_DB', checkedSubOperationsDB); } else { message.push('نوع زیر عملیات را انتخاب کنید.'); } } else if ($('#modalOperationType2').is(':checked')) { setFormInputValue('operationType', 'نگهداری'); setFormInputValue('operationType_DB', 1); let maintenanceSubOperations = $('#modalMaintenanceSubOperation input:checked'); if (maintenanceSubOperations.length) { let checkedSubOperations = []; let checkedSubOperationsDB = []; for (let index = 0; index < maintenanceSubOperations.length; index++) { checkedSubOperations.push(returnSubOperation(maintenanceSubOperations[index].id)); checkedSubOperationsDB.push(parseInt((maintenanceSubOperations[index].id).substr(-1)) + 6); } setFormInputValue('operationSubType', checkedSubOperations); setFormInputValue('operationSubType_DB', checkedSubOperationsDB); } else { message.push('نوع زیر عملیات را انتخاب کنید.'); } } else { message.push('نوع عملیات را انتخاب کنید.'); } break; } case 2: { if (!$('input[name=sourceCord]').val()) { message.push('مختصات ابتدای پروژه را وارد کنید.'); } else { let sourceCord = $('input[name=sourceCord]').val().split(' - '); setFormInputValue('projectSourceCord', [sourceCord[0].slice(1, -1), sourceCord[1].slice(1, -1)]); setFormInputValue('projectSourceCordLat_DB', parseFloat(sourceCord[0].slice(1, -1))); setFormInputValue('projectSourceCordLng_DB', parseFloat(sourceCord[1].slice(1, -1))); } if (!$('input[name=destCord]').val()) { message.push('مختصات انتهای پروژه را وارد کنید.'); } else { let destCord = $('input[name=destCord]').val().split(' - '); setFormInputValue('projectDestCord', [destCord[0].slice(1, -1), destCord[1].slice(1, -1)]); setFormInputValue('projectDestCordLat_DB', parseFloat(destCord[0].slice(1, -1))); setFormInputValue('projectDestCordLng_DB', parseFloat(destCord[1].slice(1, -1))); } if (!$('input[name=calcDistance]').val()) { message.push('طول پروژه را به درستی وارد کنید.'); } else { let calcDistance = $('input[name=calcDistance]').val(); setFormInputValue('projectCalcDistance', calcDistance); setFormInputValue('projectCalcDistance_DB', parseFloat(calcDistance)); } break; } case 3: { if (!$('select[name=selectOstan] > option:selected').val()) { message.push('انتخاب اداره کل ضروری است.'); } else { setFormInputValue('selectedProvince', $('select[name=selectOstan] > option:selected').val()); setFormInputValue('selectedProvinceString', $('select[name=selectOstan] > option:selected').text()); setFormInputValue('selectedProvince_DB', parseInt($('select[name=selectOstan] > option:selected').val())); } if (!$("#subOstan").val() || $("#subOstan").val() == 0) { message.push('نام شهرستان ضروری است.'); } else { setFormInputValue('selectedTown', $("#subOstan :selected").val()); setFormInputValue('selectedTownString', $("#subOstan :selected").text()); setFormInputValue('selectedTown_DB', parseInt($('#subOstan :selected').val())); } break; } case 4: { if (value = $('input[name=projectAxis]').val()) { let keepVal = value; setFormInputValue('projectAxis', keepVal); setFormInputValue('projectAxis_DB', keepVal); } if (value = $('input[name=projectName]').val()) { let keepVal = value; setFormInputValue('projectName', keepVal); setFormInputValue('projectName_DB', keepVal); } break; } case 5: { if ($('#axisType1').is(':checked')) { setFormInputValue('projectAxisType', 'اصلی شریانی'); setFormInputValue('projectAxisType_DB', 0); } else if ($('#axisType2').is(':checked')) { setFormInputValue('projectAxisType', 'اصلی غیرشریانی'); setFormInputValue('projectAxisType_DB', 1); } else if ($('#axisType3').is(':checked')) { setFormInputValue('projectAxisType', 'فرعی'); setFormInputValue('projectAxisType_DB', 2); } else if ($('#axisType4').is(':checked')) { setFormInputValue('projectAxisType', 'روستایی'); setFormInputValue('projectAxisType_DB', 3); } else { message.push('نوع محور را تعیین کنید.'); } break; } } break; case 2: switch (projectSubStep) { case 1: { if (value = $('input[name=projectStartDate]').val()) { setFormInputValue('projectStartDate', value); setFormInputValue('projectStartDate_DB', persianDatepickerInput.getState().selected.unixDate); } else { message.push('تاریخ شروع به کار را تعیین کنید.'); } break; } case 2: { if ($('#projectType1').is(':checked')) { setFormInputValue('projectType', 'امانی'); setFormInputValue('projectType_DB', 0); } else if ($('#projectType2').is(':checked')) { setFormInputValue('projectType', 'پیمانی'); setFormInputValue('projectType_DB', 1); } else if ($('#projectType3').is(':checked')) { setFormInputValue('projectType', 'امانی - پیمانی'); setFormInputValue('projectType_DB', 2); } else { message.push('نوع پروژه را انتخاب کنید.'); } if (value = $('input[name=projectConsultantName]').val()) { let keepVal = value; setFormInputValue('projectConsultantName', keepVal); setFormInputValue('projectConsultantName_DB', keepVal); } if (value = $('input[name=projectContractorName]').val()) { let keepVal = value; setFormInputValue('projectContractorName', keepVal); setFormInputValue('projectContractorName_DB', keepVal); } break; } case 3: { if (value = $('input[name=orderCredit]').val()) { let keepVal = value; setFormInputValue('amountOrderCredit', keepVal); setFormInputValue('amountOrderCredit_DB', parseInt(keepVal)); } else { message.push('میزان اعتبار قرارداد باید وارد شود.'); } if (value = $('input[name=absorbedCredit]').val()) { let keepVal = value; setFormInputValue('amountAbsorbedCredit', keepVal); setFormInputValue('amountAbsorbedCredit_DB', parseInt(keepVal)); } else { message.push('میزان اعتبار جذب شده باید وارد شود.'); } if (value = $('input[name=endCredit]').val()) { let keepVal = value; setFormInputValue('amountEndCredit', keepVal); setFormInputValue('amountEndCredit_DB', parseInt(keepVal)); } if ($('input[name=orderCredit]').val() && $('input[name=absorbedCredit]').val()) { let keepVal = parseInt((parseInt(projectFromInputValue['amountAbsorbedCredit']) / parseInt(projectFromInputValue['amountOrderCredit'])) * 100); setFormInputValue('projectRialSlider', keepVal); setFormInputValue('projectRialSlider_DB', keepVal); } break; } case 4: { if (value = $('select[name=announcedNumber] > option:selected').val()) { let keepVal = value; setFormInputValue('projectPlanNumber', keepVal); setFormInputValue('projectPlanNumber_DB', keepVal); } if (value = $('input[name=announcedDate]').val()) { setFormInputValue('projectAnnouncedDate', value); setFormInputValue('projectAnnouncedDate_DB', persianDatepickerInput.getState().selected.unixDate); } } case 5: { let dbIndex = 0; let dbSlider = []; for (let index = 1; index < 7; index++) { if ($('#projectPhysicalSlider' + index).length) { setFormInputValue('projectPhysicalSlider' + index, window['projectPhysicalSlider' + index].slider('getValue')); dbSlider[dbIndex++] = window['projectPhysicalSlider' + index].slider('getValue'); } } if (dbSlider.length > 0) { setFormInputValue('projectPhysicalSlider_DB', dbSlider); } break; } case 6: { setFormInputValue('projectRialSlider', projectRialSlider.slider('getValue')); setFormInputValue('projectRialSlider_DB', projectRialSlider.slider('getValue')); break; } case 7: { if (value = $('textarea[name=projectProblem]').val()) { let keepVal = value; setFormInputValue('projectProblem', keepVal); setFormInputValue('projectProblem_DB', keepVal); } setFormInputValue('projectProblemUploadedFiles_DB', $('input[name=modalUpFileSubmit]')[0]); // filespath = []; // myDropzone.files.forEach(function (item) { // //filespath.push(item.dataURL); // filespath.push(item.name); // }); // //==================================================maxter // if (filespath.length > 0) { // setFormInputValue('projectProblemUploadedFiles', filespath); // setFormInputValue('projectProblemUploadedFiles_DB', filespath); // } //======================================= break; } } break; case 3: switch (projectSubStep) { case 1: { if ($('#projectStatus1').is(':checked')) { setFormInputValue('projectStatus', 'فعال'); setFormInputValue('projectStatus_DB', 0); } else if ($('#projectStatus2').is(':checked')) { setFormInputValue('projectStatus', 'متوقف'); setFormInputValue('projectStatus_DB', 1); let projectStatusStop = $('#projectStatus2Box input:checked'); if (projectStatusStop.length) { let checkedStatusStop = []; let checkedStatusStop_DB = []; for (let index = 0; index < projectStatusStop.length; index++) { checkedStatusStop.push(projectStatusStop[index].id); checkedStatusStop_DB.push(parseInt((projectStatusStop[index].id).substr(-1))); } setFormInputValue('projectStopReasons', checkedStatusStop); setFormInputValue('projectStopReasons_DB', checkedStatusStop_DB); } else { message.push('دلایل توقف را تعیین کنید.'); } } else if ($('#projectStatus3').is(':checked')) { setFormInputValue('projectStatus', 'خاتمه‌یافته'); setFormInputValue('projectStatus_DB', 2); } else { message.push('وضعیت فعلی پروژه را تعیین کنید.'); } if ($('#projectCanOpening1').is(':checked')) { setFormInputValue('projectCanOpening', 1); setFormInputValue('projectCanOpening_DB', 1); if (value = $('input[name=projectOpening]').val()) { setFormInputValue('projectOpeningDate', value); setFormInputValue('projectOpeningDate_DB', persianDatepickerInput.getState().selected.unixDate); } else { message.push('تاریخ افتتاح پروژه را تعیین کنید.'); } } else { setFormInputValue('projectCanOpening', 0); setFormInputValue('projectCanOpening_DB', 0); } $('input[name=projectNazerName]').val('نام ناظر پروژه'); $('input[name=projectMasName]').val('نام مسئول پروژه'); //$('input[name=projectReportDate]').val(); setFormInputValue('projectNazerName_DB', 'نام ناظر پروژه'); setFormInputValue('projectMasName_DB', 'نام مسئول پروژه'); setFormInputValue('projectReportDate', $('input[name=projectReportDate]').val()); setFormInputValue('projectReportDate_DB', persianDatepickerInputSubmit.getState().selected.unixDate); break; } case 2: { if (!$('input[name=projectNazerName]').val()) { message.push('نام ناظر پروژه اجباری است.'); } else { setFormInputValue('projectNazerName', $('input[name=projectNazerName]').val()); } if (!$('input[name=projectMasName]').val()) { message.push('نام مسئول پروژه اجباری است.'); } else { setFormInputValue('projectMasName', $('input[name=projectMasName]').val()); } break; } case 3: { if (!$('input[name=projectReportDate]').val()) { message.push('تاریخ ثبت گزارش را انتخاب کنید.'); } else { setFormInputValue('projectReportDate', $('input[name=projectReportDate]').val()); } break; } } break; } if (message.length > 0) { showSubFormErrorMessage(message); return 0; } else { return 1; } } } function returnSubOperation(id) { switch (id) { case 'constructionSubOperation1': { return 'خاکی'; } case 'constructionSubOperation2': { return 'ابنیه'; } case 'constructionSubOperation3': { return 'زیراساس'; } case 'constructionSubOperation4': { return 'اساس'; } case 'constructionSubOperation5': { return 'آسفالت'; } case 'constructionSubOperation6': { return 'ایمن سازی'; } case 'maintenanceSubOperation1': { return 'لکه گیری'; } case 'maintenanceSubOperation2': { return 'روکش گرم'; } case 'maintenanceSubOperation3': { return 'ماسه آسفالت'; } case 'maintenanceSubOperation4': { return 'روکش حفاظتی'; } case 'maintenanceSubOperation5': { return 'تثبیت'; } case 'maintenanceSubOperation6': { return 'ایمن سازی'; } } } function setFormInputValue(name, value) { projectFromInputValue[name] = value; $('input[name=' + name + 'Review]').val(value); checkShowFromReview(); console.log(projectFromInputValue); } function getFormInputValue(name) { if (value = projectFromInputValue[name]) { return value; } else { return false; } } function checkShowFromReview() { for (let i = 1; i <= 12; i++) { if ($('#physical' + i).parent().find('input').val()) { showOrHideFromReview($('#physical' + i).parent().parent(), 1); } else { showOrHideFromReview($('#physical' + i).parent().parent(), 0); } } if ($('input[name=projectStopReasonsReview]').val()) { showOrHideFromReview($('input[name=projectStopReasonsReview]').parent().parent(), 1); let projectStopReasonsFa = []; for (let i = 0; i < (projectFromInputValue['projectStopReasons']).length; i++) { switch (projectFromInputValue['projectStopReasons'][i]) { case "stopReason1": { projectStopReasonsFa.push('کمبود اعتبارات'); break; } case "stopReason2": { projectStopReasonsFa.push('کمبود نیروی انسانی'); break; } case "stopReason3": { projectStopReasonsFa.push('نبود ماشین آلات'); break; } case "stopReason4": { projectStopReasonsFa.push('شرایط جوی'); break; } case "stopReason5": { projectStopReasonsFa.push('قیر'); break; } } } $('input[name=projectStopReasonsReview]').val(projectStopReasonsFa); } else { showOrHideFromReview($('input[name=projectStopReasonsReview]').parent().parent(), 0); } if (getFormInputValue('projectSourceCord').length > 0) { //console.log('Update Map'); } if ($('input[name=projectConsultantNameReview]').val()) { showOrHideFromReview($('input[name=projectConsultantNameReview]').parent().parent(), 1); } else { showOrHideFromReview($('input[name=projectConsultantNameReview]').parent().parent(), 0); } if ($('input[name=projectContractorNameReview]').val()) { showOrHideFromReview($('input[name=projectContractorNameReview]').parent().parent(), 1); } else { showOrHideFromReview($('input[name=projectContractorNameReview]').parent().parent(), 0); } if ($('input[name=projectPlanNumberReview]').val()) { showOrHideFromReview($('input[name=projectPlanNumberReview]').parent().parent(), 1); } else { showOrHideFromReview($('input[name=projectPlanNumberReview]').parent().parent(), 0); } if ($('input[name=projectAnnouncedDateReview]').val()) { showOrHideFromReview($('input[name=projectAnnouncedDateReview]').parent().parent(), 1); } else { showOrHideFromReview($('input[name=projectAnnouncedDateReview]').parent().parent(), 0); } } function showOrHideFromReview(element, show) { if (show) { $(element).show(); } else { $(element).hide(); } } function showFormErrorMessage(msg) { alert(msg); } function showSubFormErrorMessage(msg) { let stepModalBodyErrorMenu = $(".project-timeline > .card-timeline > .card-body #stepModal .modal-body >.row ul.step-modal-error"); if (stepModalBodyErrorMenu.length) { stepModalBodyErrorMenu.empty(); msg.forEach(element => { stepModalBodyErrorMenu.append('
  • ' + element + '
  • '); }); } else { let stepModalBody = $(".project-timeline > .card-timeline > .card-body #stepModal .modal-body >.row"); let stepModalBodyErrorCol = $('
    '); let stepModalBodyErrorMenu = $(''); stepModalBodyErrorCol.append('\ \ '); msg.forEach(element => { stepModalBodyErrorMenu.append('
  • ' + element + '
  • '); }); stepModalBody.prepend(stepModalBodyErrorCol.append(stepModalBodyErrorMenu)); } } function addSubStepInput(subStep) { let rowElement = $('
    '); showInputModal(rowElement.append(fetchOrCreateSubStepInput(subStep)), subStep); } function fetchOrCreateSubStepInput(subStep) { let inputElement = '

    New Input Element

    '; switch (projectStep) { case 1: switch (subStep) { case 1: { if (projectFromInputValue['operationType']) { inputElement = '\
    \
    نوع عملیات
    \
    \
    \ \ \
    \
    \ \ \
    \
    \
    \
    \
    \ \
    \
    \
    \ = 0) ? 'checked' : '') + '>\ \
    \
    \
    \
    \ = 0) ? 'checked' : '') + '>\ \
    \
    \
    \
    \ = 0) ? 'checked' : '') + '>\ \
    \
    \
    \
    \
    \
    \ = 0) ? 'checked' : '') + '>\ \
    \
    \
    \
    \ = 0) ? 'checked' : '') + '>\ \
    \
    \
    \
    \ = 0) ? 'checked' : '') + '>\ \
    \
    \
    \
    \
    \
    \
    \ \
    \
    \
    \ = 0) ? 'checked' : '') + '>\ \
    \
    \
    \
    \ = 0) ? 'checked' : '') + '>\ \
    \
    \
    \
    \ = 0) ? 'checked' : '') + '>\ \
    \
    \
    \
    \
    \
    \ = 0) ? 'checked' : '') + '>\ \
    \
    \
    \
    \ = 0) ? 'checked' : '') + '>\ \
    \
    \
    \
    \ = 0) ? 'checked' : '') + '>\ \
    \
    \
    \
    \
    \ '; } else { inputElement = '\
    \
    نوع عملیات
    \
    \
    \ \ \
    \
    \ \ \
    \
    \
    \ \ \ '; } break; } case 2: { if (projectFromInputValue['projectSourceCord']) { inputElement = '\
    \
    \ \
    \ \
    \
    \ \
    \
    \
    \
    \
    \
    \
    \
    \
    \
    \ \ \
    \
    \
    \
    \ \ \
    \
    \
    \
    \ \ \
    \
    \
    \
    \
    \
    \ '; } else { inputElement = '\
    \
    \
    \
    \
    \

    تعیین مختصات جغرافیایی پروژه

    \

    \ برای دسترسی سریع تر به موقعیت مکانی پروژه روی نقشه، می توانید نزدیک ترین\ شهر یا روستا را جستجو کنید:\

    \
    \
    \ \
    \
    \
    \
    \ انتخاب دستی از روی نقشه\
    \
    \
    \
    \
    \
    \ \
    \
    \ \
    \
    \
    \
    \
    \
    \
    \
    \
    \
    \ \ \
    \
    \
    \
    \ \ \
    \
    \
    \
    \ \ \
    \
    \
    \
    \
    \
    \ '; } break; } case 3: { inputElement = '\
    \
    \ \ \
    \
    \
    \
    \ \ \
    \
    \ '; break; } case 4: { inputElement = '\
    \
    \ \ \ \ \
    \
    \ '; break; } case 5: { inputElement = '\
    \
    نوع محور
    \
    \
    \ \ \
    \
    \ \ \
    \
    \ \ \
    \
    \ \ \
    \
    \
    \ '; break; } } break; case 2: switch (subStep) { case 1: { inputElement = '\
    \
    \ \ \
    \
    \ '; break; } case 2: { if (!projectFromInputValue['projectType']) { inputElement = '\
    \
    نوع پروژه را انتخاب کنید:
    \
    \
    \ \ \
    \
    \ \ \
    \
    \ \ \
    \
    \
    \
    \
    \ \ \
    \ \
    \ '; } else { inputElement = '\
    \
    نوع پروژه را انتخاب کنید:
    \
    \
    \ \ \
    \
    \ \ \
    \
    \ \ \
    \
    \
    \
    \
    \ \ \
    \
    \ \ \
    \
    \ '; } break; } case 3: { inputElement = '\
    \
    \ \ \
    \
    \ \ \
    \
    \ \ \
    \
    \ '; break; } case 4: { inputElement = '\
    \
    \ \ \ \ \
    \
    \ '; break; } case 5: { if (getFormInputValue('operationType') === 'احداث') { inputElement = '\
    \
    \ درصد پیشرفت فیزیکی هر مرحله را تعیین کنید (احداث):\
    \ '; if ((getFormInputValue('operationSubType')).indexOf("خاکی") >= 0) { inputElement += '\
    \ خاکی:\
    \
    \ \
    \ '; } if ((getFormInputValue('operationSubType')).indexOf("ابنیه") >= 0) { inputElement += '\
    \ ابنیه:\
    \
    \ \
    \ '; } if ((getFormInputValue('operationSubType')).indexOf("زیراساس") >= 0) { inputElement += '\
    \ زیراساس:\
    \
    \ \
    \ '; } if ((getFormInputValue('operationSubType')).indexOf("اساس") >= 0) { inputElement += '\
    \ اساس:\
    \
    \ \
    \ '; } if ((getFormInputValue('operationSubType')).indexOf("آسفالت") >= 0) { inputElement += '\
    \ آسفالت:\
    \
    \ \
    \ '; } if ((getFormInputValue('operationSubType')).indexOf("ایمن سازی") >= 0) { inputElement += '\
    \ ایمن سازی:\
    \
    \ \
    \ '; } } else { inputElement = '\
    \
    \ درصد پیشرفت فیزیکی هر مرحله را تعیین کنید (نگهداری):\
    \ '; if ((getFormInputValue('operationSubType')).indexOf("لکه گیری") >= 0) { inputElement += '\
    \ لکه گیری:\
    \
    \ \
    \ '; } if ((getFormInputValue('operationSubType')).indexOf("روکش گرم") >= 0) { inputElement += '\
    \ روکش گرم:\
    \
    \ \
    \ '; } if ((getFormInputValue('operationSubType')).indexOf("ماسه آسفالت") >= 0) { inputElement += '\
    \ ماسه آسفالت:\
    \
    \ \
    \ '; } if ((getFormInputValue('operationSubType')).indexOf("روکش حفاظتی") >= 0) { inputElement += '\
    \ روکش حفاظتی:\
    \
    \ \
    \ '; } if ((getFormInputValue('operationSubType')).indexOf("تثبیت") >= 0) { inputElement += '\
    \ تثبیت:\
    \
    \ \
    \ '; } if ((getFormInputValue('operationSubType')).indexOf("ایمن سازی") >= 0) { inputElement += '\
    \ ایمن سازی:\
    \
    \ \
    \ '; } } inputElement += '\
    \ '; break; } case 6: { inputElement = '\
    \
    \ درصد پیشرفت ریالی پروژه را تعیین کنید:\
    \
    \ \
    \
    \ \
    ٪' + ((projectFromInputValue['projectRialSlider']) ? projectFromInputValue['projectRialSlider'] : 0) + '
    \ \
    \
    \ '; break; } case 7: { inputElement = '\
    \
    \ \ \
    \
    \ \
    \ \
    \
    \
    \ '; break; } case 8: { //
    \ // \ //
    \ // \ //
    \ //
    \ // inputElement = '\ //
    \ // پایان مرحله دوم\ //
    \ // '; break; } } break; case 3: switch (subStep) { case 1: { inputElement = '\
    \
    وضعیت فعلی پروژه را تعیین کنید:
    \
    \
    \ \ \
    \
    \ \ \
    \
    \ \ \
    \
    \
    \
    \
    \ \
    \
    \
    \ = 0) ? 'checked' : '') + '>\ \
    \
    \
    \
    \ = 0) ? 'checked' : '') + '>\ \
    \
    \
    \
    \ = 0) ? 'checked' : '') + '>\ \
    \
    \
    \
    \
    \
    \ = 0) ? 'checked' : '') + '>\ \
    \
    \
    \
    \ = 0) ? 'checked' : '') + '>\ \
    \
    \
    \
    \
    \
    \
    \
    \
    \
    \ \ \
    \
    \
    \
    \
    \ \ \
    \
    \
    \
    \ '; break; } /*case 2: { inputElement = '\
    \
    \ \ \
    \
    \ \ \
    \
    \ '; break; } case 3: { inputElement = '\
    \
    \ \ \
    \
    \ '; break; }*/ //case 4: { // inputElement = '\ //
    \ // پایان مرحله سوم\ //
    \ // '; //break; //} } break; default: // } return inputElement; } function showInputModal(element, subStep) { let stepModal = $(".project-timeline > .card-timeline > .card-body #stepModal"); let stepModalBody = stepModal.find('.modal-body'); stepModalBody.empty(); stepModalBody.append(element); stepModal.modal({ backdrop: 'static', keyboard: false }); stepModal.modal('hide'); stepModal.modal('show'); someActionAfterShowModal(subStep); } function changeProjectSliderColor(sliderId, sliderVal) { if (sliderVal < 34) { sliderId.find('.slider-selection').css('background', '#c82333'); sliderId.find('.slider-handle').css('background', '#c82333'); sliderId.find('.slider-tick.in-selection').css('background', '#c82333'); } else if (sliderVal < 67) { sliderId.find('.slider-selection').css('background', '#ffc107'); sliderId.find('.slider-handle').css('background', '#ffc107'); sliderId.find('.slider-tick.in-selection').css('background', '#ffc107'); } else { sliderId.find('.slider-selection').css('background', '#28a745'); sliderId.find('.slider-handle').css('background', '#28a745'); sliderId.find('.slider-tick.in-selection').css('background', '#28a745'); } } function someActionAfterShowModal(subStep) { switch (projectStep) { case 1: switch (subStep) { case 1: { // When one radio button is checked $('#modalOperationType1').on('click', function () { if ($(this).is(':checked')) { $('#modalMaintenanceSubOperation').hide(); $('#modalConstructionSubOperation').show(); } else { $('#modalConstructionSubOperation').hide(); } }); $('#modalOperationType2').on('click', function () { if ($(this).is(':checked')) { $('#modalConstructionSubOperation').hide(); $('#modalMaintenanceSubOperation').show(); } else { $('#modalMaintenanceSubOperation').hide(); } }); break; } case 2: { // Coordinates input mask $('[data-mask]').inputmask(); // Location search autocomplete /*initiate the autocomplete function on the "myInput" element, and pass along the countries array as possible autocomplete values:*/ inputAutoComplete(document.getElementById("myInput")); // Show map showMap(); // getUserCurrentLocation(); if (projectFromInputValue['projectSourceCord'] && projectFromInputValue['projectDestCord']) { initialMapRouting(getFormInputValue('operationType')); } else { handleMapRouting(getFormInputValue('operationType')); } break; } case 3: { $.get('https://testmap.141.ir/nominatim/reverse.php?format=json&lat=' + sourceLat + '&lon=' + sourceLng + '&zoom=12&accept-language=fa', function (result) { //console.log(result.address.county.substring(8)); //maxterix it = 0; var txt; var cindex; var crtown; $("#selectOstan > option").each(function () { txt = $(this).attr("name"); OstanList.push({ value: it, name: txt }); it = it + 1; }); txt = result.address.state.substring(6); crtown = result.address.county.substring(8); //console.log(OstanList); for (var i = 1; i < OstanList.length; i++) { var oname = OstanList[i].name; var qx = oname.localeCompare(txt); if (qx == 0) { cindex = i; if (projectFromInputValue['selectedProvince']) { cindex = parseInt(projectFromInputValue['selectedProvince']); } $("#selectOstan").val(cindex); $('#selectOstan').change(); applyctx(cindex); // alert(cindex); break; } } //=================CtSelect maxwind============== $('#selectOstan').on('change', function (e) { var optionSelected = $("option:selected", this); var valueSelected = this.value; applyctx(this, 1); }); //======================================= function applyctx(th, onChange = 0) { var tx = 0; var nct = 0; var listtxt; var crx; selected_city = $('#selectOstan').val() || null; nct = parseInt(selected_city); //========================== // alert(crtown); //=================================== $('#subOstan').html('').fadeIn(800).append(''); //console.log(citix); var cities = JSON.stringify(citix); if (projectFromInputValue['selectedTown']) { $('#subOstan').html('').fadeIn(800).append(''); } else { $('#subOstan').html('').fadeIn(800).append(''); } $.each(citix, function (i, city) { if (nct == city.ID) { for (let ii = 0; ii < city.sub.length; ++ii) { tx = tx + 1; listtxt = city.sub[ii].name; $('#subOstan').append(''); if (crtown.localeCompare(listtxt) == 0 || crtown == listtxt) { crx = ii + 1; // $('#subOstan').val(ii+1); // $('#subOstan').change(); } } } }); if (projectFromInputValue['selectedTown']) { $('#subOstan').val(parseInt(projectFromInputValue['selectedTown'])); $('#subOstan').change(); } else if (onChange) { $('#subOstan').val(0); $('#subOstan').change(); } else { $('#subOstan').val(crx); $('#subOstan').change(); } }; //maxterix========================================= //$('select option[name=' + '"' + result.address.state.substring(6) + '"' + ']').attr('selected', 'selected'); //$('input[name="town"]').attr('value', result.address.county.substring(8)); }); $.get('https://testmap.141.ir/nominatim/reverse.php?format=json&lat=' + sourceLat + '&lon=' + sourceLng + '&zoom=14&accept-language=fa', function (result) { //console.log(result); if ('village' in result.address) { originPlaceName = result.address.village; } else if ('town' in result.address) { originPlaceName = result.address.town; } else if ('city' in result.address) { originPlaceName = result.address.city; } }); $.get('https://testmap.141.ir/nominatim/reverse.php?format=json&lat=' + destLat + '&lon=' + destLng + '&zoom=14&accept-language=fa', function (result) { //console.log(result); if ('village' in result.address) { destinationPlaceName = result.address.village; } else if ('town' in result.address) { destinationPlaceName = result.address.town; } else if ('city' in result.address) { destinationPlaceName = result.address.city; } }); break; } case 4: { if (!projectFromInputValue['projectAxis']) { $('input[name=projectAxis]').val(originPlaceName + '-' + destinationPlaceName); } break; } } break; case 2: switch (subStep) { case 1: { persianDatepickerInput = $('input[name=projectStartDate]').persianDatepicker({ format: 'YYYY/MM/DD', initialValue: false, autoClose: true }); break; } case 2: { $('#projectType1').on('click', function () { $('#contractorNameBox').hide(); }); $('#projectType2').on('click', function () { $('#contractorNameBox').show(); }); $('#projectType3').on('click', function () { $('#contractorNameBox').show(); }); break; } case 3: { break; } case 4: { persianDatepickerInput = $('input[name=announcedDate]').persianDatepicker({ format: 'YYYY/MM/DD', initialValue: false, autoClose: true }); } case 5: { if (getFormInputValue('operationType') == 'احداث') { $('#physical1').text('خاکی'); $('#physical2').text('ابنیه'); $('#physical3').text('زیراساس'); $('#physical4').text('اساس'); $('#physical5').text('آسفالت'); $('#physical6').text('ایمن سازی'); } else { $('#physical1').text('لکه گیری'); $('#physical2').text('روکش گرم'); $('#physical3').text('ماسه آسفالت'); $('#physical4').text('روکش حفاظتی'); $('#physical5').text('تثبیت'); $('#physical6').text('ایمن سازی'); } if ($("#projectPhysicalSlider1").length > 0) { projectPhysicalSlider1 = $("#projectPhysicalSlider1").slider({ min: 0, max: 100, value: (projectFromInputValue['projectPhysicalSlider1']) ? (projectFromInputValue['projectPhysicalSlider1']) : 0, ticks: [0, 100], ticks_snap_bounds: 1, formatter: function (value) { return value + '٪'; }, tooltip: 'always', tooltip_position: 'bottom' }); } if ($("#projectPhysicalSlider2").length > 0) { projectPhysicalSlider2 = $("#projectPhysicalSlider2").slider({ min: 0, max: 100, value: (projectFromInputValue['projectPhysicalSlider2']) ? (projectFromInputValue['projectPhysicalSlider2']) : 0, ticks: [0, 100], ticks_snap_bounds: 1, formatter: function (value) { return value + '٪'; }, tooltip: 'always', tooltip_position: 'bottom' }); } if ($("#projectPhysicalSlider3").length > 0) { projectPhysicalSlider3 = $("#projectPhysicalSlider3").slider({ min: 0, max: 100, value: (projectFromInputValue['projectPhysicalSlider3']) ? (projectFromInputValue['projectPhysicalSlider3']) : 0, ticks: [0, 100], ticks_snap_bounds: 1, formatter: function (value) { return value + '٪'; }, tooltip: 'always', tooltip_position: 'bottom' }); } if ($("#projectPhysicalSlider4").length > 0) { projectPhysicalSlider4 = $("#projectPhysicalSlider4").slider({ min: 0, max: 100, value: (projectFromInputValue['projectPhysicalSlider4']) ? (projectFromInputValue['projectPhysicalSlider4']) : 0, ticks: [0, 100], ticks_snap_bounds: 1, formatter: function (value) { return value + '٪'; }, tooltip: 'always', tooltip_position: 'bottom' }); } if ($("#projectPhysicalSlider5").length > 0) { projectPhysicalSlider5 = $("#projectPhysicalSlider5").slider({ min: 0, max: 100, value: (projectFromInputValue['projectPhysicalSlider5']) ? (projectFromInputValue['projectPhysicalSlider5']) : 0, ticks: [0, 100], ticks_snap_bounds: 1, formatter: function (value) { return value + '٪'; }, tooltip: 'always', tooltip_position: 'bottom' }); } if ($("#projectPhysicalSlider6").length > 0) { projectPhysicalSlider6 = $("#projectPhysicalSlider6").slider({ min: 0, max: 100, value: (projectFromInputValue['projectPhysicalSlider6']) ? (projectFromInputValue['projectPhysicalSlider6']) : 0, ticks: [0, 100], ticks_snap_bounds: 1, formatter: function (value) { return value + '٪'; }, tooltip: 'always', tooltip_position: 'bottom' }); } for (let index = 1; index < 7; index++) { if ($('#projectPhysicalSlider' + index).length) { let getValue = window['projectPhysicalSlider' + index].slider('getValue'); let sliderEl = $("#projectPhysicalSlider" + index); changeProjectSliderColor(sliderEl, getValue); } } $("#projectPhysicalSlider1").on("slide", function (slideEvt) { changeProjectSliderColor($(this), slideEvt.value); }); $("#projectPhysicalSlider2").on("slide", function (slideEvt) { changeProjectSliderColor($(this), slideEvt.value); }); $("#projectPhysicalSlider3").on("slide", function (slideEvt) { changeProjectSliderColor($(this), slideEvt.value); }); $("#projectPhysicalSlider4").on("slide", function (slideEvt) { changeProjectSliderColor($(this), slideEvt.value); }); $("#projectPhysicalSlider5").on("slide", function (slideEvt) { changeProjectSliderColor($(this), slideEvt.value); }); $("#projectPhysicalSlider6").on("slide", function (slideEvt) { changeProjectSliderColor($(this), slideEvt.value); }); break; } case 6: { projectRialSlider = $("#projectRialSlider").slider({ min: 0, max: 100, value: (projectFromInputValue['projectRialSlider']) ? (projectFromInputValue['projectRialSlider']) : 0, ticks: [0, 100], ticks_snap_bounds: 1, formatter: function (value) { return value + '٪'; }, tooltip: 'always', tooltip_position: 'bottom' }); if (projectFromInputValue['projectRialSlider']) { changeProjectSliderColor($("#dataProjectRialSlider"), projectFromInputValue['projectRialSlider']); } $("#dataProjectRialSlider").on("slide", function (slideEvt) { changeProjectSliderColor($(this), slideEvt.value); $('.project-slider-button > div > .slider-button-value').text(slideEvt.value); }); $('.project-slider-button > span.slider-button-up').on('click', function () { let sliderValue = parseInt($('.project-slider-button > div > .slider-button-value').text()); if (sliderValue < 100) { sliderValue++; } $('#projectRialSlider').slider('setValue', sliderValue); changeProjectSliderColor($("#dataProjectRialSlider"), sliderValue); $('.project-slider-button > div > .slider-button-value').text(sliderValue); }); $('.project-slider-button > span.slider-button-down').on('click', function () { let sliderValue = parseInt($('.project-slider-button > div > .slider-button-value').text()); if (sliderValue > 0) { sliderValue--; } $('#projectRialSlider').slider('setValue', sliderValue); changeProjectSliderColor($("#dataProjectRialSlider"), sliderValue); $('.project-slider-button > div > .slider-button-value').text(sliderValue); }); break; } case 7: { $('.custom-file-input[name=projectProblemFile]').on("change", function () { var fileName = $(this).val().split("\\").pop(); $(this).siblings(".custom-file-label").addClass("selected").html(fileName); }); //==========================Maxter111 // myDropzone = new Dropzone("div#upzone", { url: "/upload" }); // Dropzone.options.myDropzone = { // paramName: "file", // autoProcessQueue: false, // autoQueue: false, // clickable: true, // maxFilesize: 10, //in mb // addRemoveLinks: true, // // acceptedFiles: '.png,.jpg', // dictDefaultMessage: "فایل های بکشید و اینجا رها کنید", // }; //============================================mixbox /*myDropzone.on('selectedfiles', function (files) { $(files).each(function (index) { this.delay = index * 100; }); });*/ //============================= $('#upbox').on('click', function (e) { //myDropzone.processQueue(); }); break; } } break; case 3: switch (subStep) { case 1: { if (getFormInputValue('operationType') == 'احداث') { $('#physical7').text('خاکی'); $('#physical8').text('ابنیه'); $('#physical9').text('زیراساس'); $('#physical10').text('اساس'); $('#physical11').text('آسفالت'); $('#physical12').text('ایمن سازی'); } else { $('#physical7').text('لکه گیری'); $('#physical8').text('روکش گرم'); $('#physical9').text('ماسه آسفالت'); $('#physical10').text('روکش حفاظتی'); $('#physical11').text('تثبیت'); $('#physical12').text('ایمن سازی'); } $('#projectStatus1').on('click', function () { $('#projectStatus2Box').hide(); if ($('input[name=projectCanOpening]').is(':checked')) { $('input[name=projectCanOpening]').click(); } }); $('#projectStatus2').on('click', function () { $('#projectStatus2Box').show(); if ($('input[name=projectCanOpening]').is(':checked')) { $('input[name=projectCanOpening]').click(); } }); $('#projectStatus3').on('click', function () { $('#projectStatus2Box').hide(); if (!$('input[name=projectCanOpening]').is(':checked')) { $('input[name=projectCanOpening]').click(); } }); $('input[name=projectCanOpening]').on('click', function () { if ($(this).is(':checked')) { $('#projectOpeningBox').show(); } else { $('#projectOpeningBox').hide(); } }); persianDatepickerInput = $('input[name=projectOpening]').persianDatepicker({ format: 'YYYY/MM/DD', initialValue: (projectFromInputValue['projectOpeningDate']) ? false : true, autoClose: true }); persianDatepickerInputSubmit = $('input[name=projectReportDate]').persianDatepicker({ format: 'YYYY/MM/DD HH:MM', autoClose: true, timePicker: { enabled: true } }); break; } case 3: { $('input[name=projectReportDate]').persianDatepicker({ format: 'YYYY/MM/DD HH:MM', autoClose: true, timePicker: { enabled: true } }); break; } } break; default: // } } function changeCardStep(currentProjectStep = null, stepArrow) { if (!currentProjectStep) { currentProjectStep = $('.project-timeline > .card-timeline > .card-body .submit-step.active'); } if (stepArrow === 1) { if (projectStep === 3) { let formData = new FormData(); if (projectFromInputValue['operationType_DB'] != null) formData.append('operationType_DB', projectFromInputValue['operationType_DB']); if (projectFromInputValue['operationSubType_DB'] != null) formData.append('operationSubType_DB', projectFromInputValue['operationSubType_DB']); if (projectFromInputValue['projectSourceCordLat_DB'] != null) formData.append('projectSourceCordLat_DB', projectFromInputValue['projectSourceCordLat_DB']); if (projectFromInputValue['projectSourceCordLng_DB'] != null) formData.append('projectSourceCordLng_DB', projectFromInputValue['projectSourceCordLng_DB']); if (projectFromInputValue['projectDestCordLat_DB'] != null) formData.append('projectDestCordLat_DB', projectFromInputValue['projectDestCordLat_DB']); if (projectFromInputValue['projectDestCordLng_DB'] != null) formData.append('projectDestCordLng_DB', projectFromInputValue['projectDestCordLng_DB']); if (projectFromInputValue['projectCalcDistance_DB'] != null) formData.append('projectCalcDistance_DB', projectFromInputValue['projectCalcDistance_DB']); if (projectFromInputValue['selectedProvince_DB'] != null) formData.append('selectedProvince_DB', projectFromInputValue['selectedProvince_DB']); if (projectFromInputValue['selectedTown_DB'] != null) formData.append('selectedTown_DB', projectFromInputValue['selectedTown_DB']); if (projectFromInputValue['projectAxis_DB'] != null) formData.append('projectAxis_DB', projectFromInputValue['projectAxis_DB']); if (projectFromInputValue['projectAxisType_DB'] != null) formData.append('projectAxisType_DB', projectFromInputValue['projectAxisType_DB']); if (projectFromInputValue['projectName_DB'] != null) formData.append('projectName_DB', projectFromInputValue['projectName_DB']); if (projectFromInputValue['projectType_DB'] != null) formData.append('projectType_DB', projectFromInputValue['projectType_DB']); if (projectFromInputValue['projectStartDate'] != null) formData.append('projectStartDate_DB', projectFromInputValue['projectStartDate']); if (projectFromInputValue['projectConsultantName_DB'] != null) formData.append('projectConsultantName_DB', projectFromInputValue['projectConsultantName_DB']); if (projectFromInputValue['projectContractorName_DB'] != null) formData.append('projectContractorName_DB', projectFromInputValue['projectContractorName_DB']); if (projectFromInputValue['amountOrderCredit_DB'] != null) formData.append('amountOrderCredit_DB', projectFromInputValue['amountOrderCredit_DB']); if (projectFromInputValue['amountAbsorbedCredit_DB'] != null) formData.append('amountAbsorbedCredit_DB', projectFromInputValue['amountAbsorbedCredit_DB']); if (projectFromInputValue['amountEndCredit_DB'] != null) formData.append('amountEndCredit_DB', projectFromInputValue['amountEndCredit_DB']); if (projectFromInputValue['projectPlanNumber_DB'] != null) formData.append('projectPlanNumber_DB', projectFromInputValue['projectPlanNumber_DB']); //formData.append('Planoffice', projectFromInputValue['Planoffice']); if (projectFromInputValue['projectAnnouncedDate'] != null) formData.append('projectAnnouncedDate_DB', projectFromInputValue['projectAnnouncedDate']); if (projectFromInputValue['projectRialSlider_DB'] != null) formData.append('projectRialSlider_DB', projectFromInputValue['projectRialSlider_DB']); if (projectFromInputValue['projectPhysicalSlider_DB'] != null) formData.append('projectPhysicalSlider_DB', projectFromInputValue['projectPhysicalSlider_DB']); if (projectFromInputValue['projectProblem_DB'] != null) formData.append('projectProblem_DB', projectFromInputValue['projectProblem_DB']); for (let i = 0; i < projectFromInputValue['projectProblemUploadedFiles_DB'].files.length; i++) { formData.append('item_files_' + i, projectFromInputValue['projectProblemUploadedFiles_DB'].files[i]); } if (projectFromInputValue['projectStatus_DB'] != null) formData.append('projectStatus_DB', projectFromInputValue['projectStatus_DB']); if (projectFromInputValue['projectStopReasons_DB'] != null) formData.append('projectStopReasons_DB', projectFromInputValue['projectStopReasons_DB']); if (projectFromInputValue['projectCanOpening'] != null) formData.append('projectCanOpening', projectFromInputValue['projectCanOpening']); if (projectFromInputValue['projectOpeningDate'] != null) formData.append('projectOpeningDate_DB', projectFromInputValue['projectOpeningDate']); if (projectFromInputValue['projectNazerName_DB'] != null) formData.append('projectNazerName_DB', projectFromInputValue['projectNazerName_DB']); if (projectFromInputValue['projectMasName_DB'] != null) formData.append('projectMasName_DB', projectFromInputValue['projectMasName_DB']); if (projectFromInputValue['projectReportDate'] != null) formData.append('projectReportDate_DB', projectFromInputValue['projectReportDate']); // Go to first page changeProgressStep(1); showLoaderScreen(); setTimeout(function () { $.ajax({ url: '/road-construction', type: 'POST', headers: { 'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content') }, data: formData, cache: false, contentType: false, processData: false, success: function (result) { console.log(result); alert('پروژه با موفقیت ثبت شد'); hideLoaderScreen(); window.open("../rmto?operationType=" + getFormInputValue('operationType') + "&projectStatus=" + getFormInputValue('projectStatus') + "&selectedProvince=" + getFormInputValue('selectedProvinceString') + "&selectedTown=" + getFormInputValue('selectedTownString') + "&sourceLat=" + sourceLat + "&sourceLng=" + sourceLng, "_self"); }, error: function (error) { console.log(error); hideLoaderScreen(); window.open("../rmto", _self); } }); }, 500); } else { if (checkFormValidation() && !changeStepLock) { changeStepLock = true; changeProgressStep(1); currentProjectStep.removeClass('active'); currentProjectStep.next().addClass('active'); currentProjectStep.fadeOut(300, function () { if (projectStep < 3) { $('.project-timeline > .card-timeline > .card-body > button.btn-next').text('مرحله بعدی'); $('.project-timeline > .card-timeline > .card-body > button.btn-prev').text('مرحله قبلی'); } else { $('.project-timeline > .card-timeline > .card-body > button.btn-next').text('تایید و ثبت پروژه'); //$('.project-timeline > .card-timeline > .card-body > button.btn-prev').hide(); } currentProjectStep.next().fadeIn(300, function () { changeStepLock = false; addSubStepInput(projectSubStep = 1); }); }); projectStep++; } } } else if (stepArrow === -1) { if (projectStep === 0) { window.open('/rmto', '_self'); } else { if (!changeStepLock) { changeStepLock = true; if (projectStep === 1) { $('.project-timeline > .card-timeline > .card-body > button.btn-next').text('شروع ثبت پروژه'); $('.project-timeline > .card-timeline > .card-body > button.btn-prev').text('بازگشت به صفحه اصلی'); } else { $('.project-timeline > .card-timeline > .card-body > button.btn-next').text('مرحله بعدی'); $('.project-timeline > .card-timeline > .card-body > button.btn-prev').text('مرحله قبلی'); } changeProgressStep(-1); currentProjectStep.removeClass('active'); currentProjectStep.prev().addClass('active'); currentProjectStep.fadeOut(300, function () { currentProjectStep.prev().fadeIn(300, function () { changeStepLock = false; projectSubStep = projectMaxSubStep[projectStep - 1]; }); }); projectStep--; } } } } $('.project-timeline > .card-timeline > .card-body > button').on('click', function () { let currentProjectStep = $(this).parent().find('.submit-step.active'); if ($(this).hasClass('btn-next')) { changeCardStep(currentProjectStep, 1); } else if ($(this).hasClass('btn-prev')) { changeCardStep(currentProjectStep, -1); } }); $('.project-timeline > .card-timeline > .card-body #stepModal .modal-footer > button').on('click', function () { if ($(this).hasClass('btn-next')) { switch (projectStep) { case 1: { if (projectSubStep === projectMaxSubStep[0]) { //alert('شروع مرحله ۲'); if (checkSubFormValidation()) { $(".project-timeline > .card-timeline > .card-body #stepModal").modal('hide'); } // changeCardStep(null, 1); } else { if (checkSubFormValidation()) { projectSubStep++; addSubStepInput(projectSubStep); } } break; } case 2: { if (projectSubStep === projectMaxSubStep[1]) { //alert('شروع مرحله ۳'); if (checkSubFormValidation()) { $(".project-timeline > .card-timeline > .card-body #stepModal").modal('hide'); } // changeCardStep(null, 1); } else { if (checkSubFormValidation()) { projectSubStep++; addSubStepInput(projectSubStep); } } break; } case 3: { if (projectSubStep === projectMaxSubStep[2]) { //alert('پایان'); if (checkSubFormValidation()) { $(".project-timeline > .card-timeline > .card-body #stepModal").modal('hide'); } //changeCardStep(null, 1); } else { if (checkSubFormValidation()) { projectSubStep++; addSubStepInput(projectSubStep); } } break; } } } else if ($(this).hasClass('btn-prev')) { switch (projectStep) { case 1: { if (projectSubStep === 1) { //alert('برگشت به شروع'); $('.project-timeline > .card-timeline > .card-body > button.btn-next').text('شروع ثبت پروژه'); $('.project-timeline > .card-timeline > .card-body > button.btn-prev').text('بازگشت به صفحه اصلی'); $(".project-timeline > .card-timeline > .card-body #stepModal").modal('hide'); changeCardStep(null, -1); } else { projectSubStep--; addSubStepInput(projectSubStep); } break; } case 2: { if (projectSubStep === 1) { //alert('برگشت به مرحله ۱'); $(".project-timeline > .card-timeline > .card-body #stepModal").modal('hide'); changeCardStep(null, -1); } else { projectSubStep--; addSubStepInput(projectSubStep); } break; } case 3: { if (projectSubStep === 1) { //alert('برگشت به مرحله ۲'); $(".project-timeline > .card-timeline > .card-body #stepModal").modal('hide'); changeCardStep(null, -1); } else { projectSubStep--; addSubStepInput(projectSubStep); } break; } } } else if ($(this).hasClass('btn-applyChange')) { if (checkSubFormValidation()) { $(".project-timeline > .card-timeline > .card-body #stepModal").modal('hide'); let stepModalFooter = $('#stepModal .modal-content > .modal-footer'); stepModalFooter.find('button.btn-applyChange').hide(); stepModalFooter.find('button.btn-applyChangeCancel').hide(); stepModalFooter.find('button.btn-prev').show(); stepModalFooter.find('button.btn-next').show(); projectStep = stepBackup; projectSubStep = subStepBackUp; } } else if ($(this).hasClass('btn-applyChangeCancel')) { $(".project-timeline > .card-timeline > .card-body #stepModal").modal('hide'); let stepModalFooter = $('#stepModal .modal-content > .modal-footer'); stepModalFooter.find('button.btn-applyChange').hide(); stepModalFooter.find('button.btn-applyChangeCancel').hide(); stepModalFooter.find('button.btn-prev').show(); stepModalFooter.find('button.btn-next').show(); projectStep = stepBackup; projectSubStep = subStepBackUp; } }); function inputAutoComplete(inp) { /*the autocomplete function takes two arguments, the text field element and an array of possible autocompleted values:*/ var currentFocus; /*execute a function when someone writes in the text field:*/ inp.addEventListener("input", function (e) { var a, b, i, val = this.value; // console.log(val); /*close any already open lists of autocompleted values*/ closeAllLists(); if (!val) { return false; } currentFocus = -1; /*create a DIV element that will contain the items (values):*/ a = document.createElement("DIV"); a.setAttribute("id", this.id + "autocomplete-list"); a.setAttribute("class", "autocomplete-items"); /*append the DIV element as a child of the autocomplete container:*/ this.parentNode.appendChild(a); /*for each item in the array...*/ if (val.length > 1) { // Request for location name let url = 'https://testmap.141.ir/nominatim/search?city=' + val + '&limit=10&format=json&addressdetails=1&accept-language=fa'; $.get(url, function (result) { // console.log(result); if (result.length) { for (i = 0; i < result.length; i++) { /*create a DIV element for each matching element:*/ b = document.createElement("DIV"); /*make the matching letters bold:*/ b.innerHTML = "" + result[i].display_name.substr(0, val.length) + ""; b.innerHTML += result[i].display_name.substr(val.length); /*insert a input field that will hold the current array item's value:*/ b.innerHTML += ""; b.setAttribute('id', result[i].lat + ',' + result[i].lon); $(b).css('font-size', '12px'); /*execute a function when someone clicks on the item value (DIV element):*/ b.addEventListener("click", function (e) { /*insert the value for the autocomplete text field:*/ inp.value = this.getElementsByTagName("input")[0].value; /*close the list of autocompleted values, (or any other open lists of autocompleted values:*/ closeAllLists(); // Hide instruction box & zoom to selected place $('.map-overlay').hide(); let placeCoordinates = this.id.split(','); map.flyTo([parseFloat(placeCoordinates[0]), parseFloat(placeCoordinates[1])], 13); }); a.appendChild(b); } } }); } }); /*execute a function presses a key on the keyboard:*/ inp.addEventListener("keydown", function (e) { var x = document.getElementById(this.id + "autocomplete-list"); if (x) x = x.getElementsByTagName("div"); // if (e.keyCode == 40) { // /*If the arrow DOWN key is pressed, // increase the currentFocus variable:*/ // currentFocus++; // /*and and make the current item more visible:*/ // addActive(x); // } else if (e.keyCode == 38) { //up // /*If the arrow UP key is pressed, // decrease the currentFocus variable:*/ // currentFocus--; // /*and and make the current item more visible:*/ // addActive(x); // } else if (e.keyCode == 13) { /*If the ENTER key is pressed, prevent the form from being submitted,*/ e.preventDefault(); if (currentFocus > -1) { /*and simulate a click on the "active" item:*/ if (x) x[currentFocus].click(); } } }); // function addActive(x) { // /*a function to classify an item as "active":*/ // if (!x) return false; // /*start by removing the "active" class on all items:*/ // removeActive(x); // if (currentFocus >= x.length) currentFocus = 0; // if (currentFocus < 0) currentFocus = (x.length - 1); // /*add class "autocomplete-active":*/ // x[currentFocus].classList.add("autocomplete-active"); // } // function removeActive(x) { // /*a function to remove the "active" class from all autocomplete items:*/ // for (var i = 0; i < x.length; i++) { // x[i].classList.remove("autocomplete-active"); // } // } function closeAllLists(elmnt) { /*close all autocomplete lists in the document, except the one passed as an argument:*/ var x = document.getElementsByClassName("autocomplete-items"); for (var i = 0; i < x.length; i++) { if (elmnt != x[i] && elmnt != inp) { x[i].parentNode.removeChild(x[i]); } } } /*execute a function when someone clicks in the document:*/ document.addEventListener("click", function (e) { closeAllLists(e.target); }); } function clearInstructionBox() { $('.map-overlay').hide(); } function showMap() { var bounds = [ [42.9130026312, 75.6166317076], [20.5782370061, 35.5092252948] ]; map = L.map('map-layout', { maxBounds: bounds, minZoom: 6 }).setView([35.620, 51.471], 9); L.tileLayer('https://testmap.141.ir/141map/{z}/{x}/{y}.png', {}).addTo(map); if (!mapReview) { mapReview = L.map('map-layout-review', { maxBounds: bounds, minZoom: 6 }).setView([35.620, 51.471], 9); L.tileLayer('https://testmap.141.ir/141map/{z}/{x}/{y}.png', {}).addTo(mapReview); } } // function getUserCurrentLocation() { // map.locate() // .on('locationfound', function (e) { // map.flyTo([e.latitude, e.longitude], 17); // $('.map-overlay').css('display', 'none'); // // var marker = L.marker([e.latitude, e.longitude], { // // icon: L.icon({ // // iconUrl: '../dist/images/source-ico.png', // // iconSize: [32, 32], // // iconAnchor: [16, 30] // // }) // // }).bindPopup('شما اینجا هستید!'); // // map.addLayer(marker); // }) // .on('locationerror', function (e) { // // alert("امکان دریافت موقعیت فعلی وجود ندارد."); // showIRANMap(); // }); // } // function showIRANMap() { // $.ajax({ // url: "https://141.ir/iranmap", // type: 'GET' // }).done(function (data) { // $('.map-overlay').html('Tooltip text' + data); // $(".map-overlay > svg #iran > path").mousemove(function (event) { // let left = event.pageX - $('.map-overlay').offset().left + 20; // let top = event.pageY - $('.map-overlay').offset().top; // let mapSelectedId = $(this).attr('id').substring(3); // $('.map-overlay > .tooltiptextmap').text(returnProvinceName(mapSelectedId)); // $('.map-overlay > .tooltiptextmap').css({ top: top, left: left }).show(); // }); // $('.map-overlay > svg #iran > path').mouseout(function () { // $('.map-overlay > .tooltiptextmap').hide(); // }); // $(".map-overlay > svg #iran path").on('click', function () { // $(".map-overlay > svg #iran .map-selected").removeClass('map-selected'); // $(this).addClass('map-selected'); // // Hide SVG map, then Zoom to selected province // $('.map-overlay').css('display', 'none'); // let mapSelectedId = $(this).attr('id').substring(3); // map.flyTo(returnProvinceLatLng(mapSelectedId), 7); // }); // }); // } // function returnProvinceName(provinceId) { // switch (provinceId) { // case '01': return 'آذربایجان شرقی'; // case '02': return 'آذربایجان غربی'; // case '03': return 'اردبیل'; // case '04': return 'اصفهان'; // case '05': return 'ایلام'; // case '06': return 'بوشهر'; // case '07': return 'تهران'; // case '08': return 'چهارمحال و بختیاری'; // // case '09': return ''; // case '10': return 'خوزستان'; // case '11': return 'زنجان'; // case '12': return 'سمنان'; // case '13': return 'سیستان و بلوچستان'; // case '14': return 'فارس'; // case '15': return 'کرمان'; // case '16': return 'کردستان'; // case '17': return 'کرمانشاه'; // case '18': return 'کهگیلویه و بویر احمد'; // case '19': return 'گیلان'; // case '20': return 'لرستان'; // case '21': return 'مازندران'; // case '22': return 'مرکزی'; // case '23': return 'هرمزگان'; // case '24': return 'همدان'; // case '25': return 'یزد'; // case '26': return 'قم'; // case '27': return 'گلستان'; // case '28': return 'قزوین'; // case '29': return 'خراسان جنوبی'; // case '30': return 'خراسان رضوی'; // case '31': return 'خراسان شمالی'; // case '32': return 'البرز'; // } // } // function returnProvinceLatLng(provinceId) { // switch (provinceId) { // case '01': return [37.9211202, 46.6821517]; // case '02': return [37.7416484, 45.0207638]; // case '03': return [38.4583983, 47.9313001]; // case '04': return [33.196733, 50.7884216]; // case '05': return [33.1545696, 46.7576343]; // case '06': return [28.8936645, 51.3204877]; // case '07': return [35.50219455, 51.3269098]; // case '08': return [32.0163307, 50.685709]; // // case '09': return ''; // case '10': return [31.5535141, 49.0077168]; // case '11': return [36.515854, 48.4777616]; // case '12': return [35.4380386, 54.8626294]; // case '13': return [28.1292481, 60.8236848]; // case '14': return [29.299051, 53.218456]; // case '15': return [29.571858, 57.301047]; // case '16': return [35.672803, 47.0124376]; // case '17': return [34.3789744, 46.7010122]; // case '18': return [30.8143476, 50.8661454]; // case '19': return [37.5115476, 49.355442]; // case '20': return [33.5372643, 48.2435197]; // case '21': return [36.3159159, 51.8968597]; // case '22': return [34.5302705, 49.7864561]; // case '23': return [27.7198095, 56.335807]; // case '24': return [34.973321, 48.6555779]; // case '25': return [32.2452686, 55.105172]; // case '26': return [34.7191915, 51.0122844]; // case '27': return [37.1984436, 55.070672]; // case '28': return [36.0156291, 49.8398161]; // case '29': return [33.0006776, 58.3262335]; // case '30': return [35.756361, 59.1280992]; // case '31': return [37.5378855, 56.9526137]; // case '32': return [35.9413239, 52.504026]; // } // } function handleMapRouting(operationType) { $('#org-pin').on('click', function () { // Set source coordinates into local vars & text field sourceLat = map.getCenter().lat; sourceLng = map.getCenter().lng; $('input[name=sourceCord]').val('(' + sourceLat.toFixed(7) + ')' + ' - ' + '(' + sourceLng.toFixed(7) + ')'); // Drop origin marker onto map sourceMarker = new L.marker(L.latLng(map.getCenter()), { icon: L.icon({ iconUrl: '../dist/images/origin.png', iconSize: [55, 75], iconAnchor: [30, 70] }), draggable: true }).addTo(map); // Hide origin image $(this).hide(); // Show destination image $('#dest-pin').show(); // What if user wants to change its location? sourceMarker.on('dragend', function (event) { var marker = event.target; var position = marker.getLatLng(); $('input[name=sourceCord]').val('(' + position.lat.toFixed(7) + ')' + ' - ' + '(' + position.lng.toFixed(7) + ')'); sourceLat = position.lat; sourceLng = position.lng; if (destLat != '') drawPath(operationType); }); }); $('#dest-pin').on('click', function () { // Set destination coordinates into local vars & text field destLat = map.getCenter().lat; destLng = map.getCenter().lng; $('input[name=destCord]').val('(' + destLat.toFixed(7) + ')' + ' - ' + '(' + destLng.toFixed(7) + ')'); // Drop origin marker onto map destMarker = new L.marker(L.latLng(map.getCenter()), { icon: L.icon({ iconUrl: '../dist/images/destination.png', iconSize: [55, 75], iconAnchor: [30, 70] }), draggable: true }).addTo(map); // Hide destination image $(this).hide(); // What if user wants to change its location? destMarker.on('dragend', function (event) { var marker = event.target; var position = marker.getLatLng(); $('input[name=destCord]').val('(' + position.lat.toFixed(7) + ')' + ' - ' + '(' + position.lng.toFixed(7) + ')'); destLat = position.lat; destLng = position.lng; if (sourceLat != '') drawPath(operationType); }); // Draw path from origin to destination drawPath(operationType); }); } function initialMapRouting(operationType) { // Drop origin marker onto map sourceMarker = new L.marker(L.latLng([sourceLat, sourceLng]), { icon: L.icon({ iconUrl: '../dist/images/origin.png', iconSize: [55, 75], iconAnchor: [30, 70] }), draggable: true }).addTo(map); sourceMarker.on('dragend', function (event) { var marker = event.target; var position = marker.getLatLng(); $('input[name=sourceCord]').val('(' + position.lat.toFixed(7) + ')' + ' - ' + '(' + position.lng.toFixed(7) + ')'); sourceLat = position.lat; sourceLng = position.lng; if (destLat != '') drawPath(operationType); }); // Hide origin image $('#org-pin').hide(); // Drop origin marker onto map destMarker = new L.marker(L.latLng(destLat, destLng), { icon: L.icon({ iconUrl: '../dist/images/destination.png', iconSize: [55, 75], iconAnchor: [30, 70] }), draggable: true }).addTo(map); destMarker.on('dragend', function (event) { var marker = event.target; var position = marker.getLatLng(); $('input[name=destCord]').val('(' + position.lat.toFixed(7) + ')' + ' - ' + '(' + position.lng.toFixed(7) + ')'); destLat = position.lat; destLng = position.lng; if (sourceLat != '') drawPath(operationType); }); // Draw path from origin to destination drawPath(operationType); initialMapRoutingReview(operationType); } function initialMapRoutingReview(operationType) { if (sourceReviewMarker) { mapReview.removeLayer(sourceReviewMarker); mapReview.removeLayer(destReviewMarker); } // Drop origin marker onto map review sourceReviewMarker = new L.marker(L.latLng([sourceLat, sourceLng]), { icon: L.icon({ iconUrl: '../dist/images/origin.png', iconSize: [55, 75], iconAnchor: [30, 70] }), draggable: false }).addTo(mapReview); // Drop origin marker onto map review destReviewMarker = new L.marker(L.latLng(destLat, destLng), { icon: L.icon({ iconUrl: '../dist/images/destination.png', iconSize: [55, 75], iconAnchor: [30, 70] }), draggable: false }).addTo(mapReview); } function drawPath(operationType) { if (routeControls.length) { $(routeControls).each(function (index, control) { map.removeControl(control); routeControls.splice(routeControls.indexOf(index), 1); }); } if (polyline != null) { map.removeLayer(polyline); } switch (operationType) { case 'احداث': { // Construction $('input[name="calcDistance"]').prop('disabled', false); polyline = L.polyline( [ [sourceLat, sourceLng], [destLat, destLng] ], { color: '#28a745', opacity: .8, weight: 5 } ).addTo(map); //console.log(polyline); break; } case 'نگهداری': { // Maintenance $.get(`https://testmap.141.ir/route/v1/driving/${sourceLng},${sourceLat};${destLng},${destLat}?overview=false&alternatives=true&steps=true`, function (data) { routeControls.push( L.Routing.control({ waypoints: [ L.latLng(parseFloat(sourceLat), parseFloat(sourceLng)), L.latLng(parseFloat(destLat), parseFloat(destLng)) ], fitSelectedRoutes: false, draggableWaypoints: true, createMarker: function () { return null; }, lineOptions: { addWaypoints: false, styles: [{ color: '#28a745', opacity: .8, weight: 5 }] }, }).on('routesfound', function (e) { var divideBy = 2; for (let index = 0; index < popupArrays.length; index++) { if (popupArrays[index] !== null) { map.removeLayer(popupArrays[index]); } } var customOptions = { 'maxWidth': '300', 'maxHeight': '150', 'className': 'customRouteEstimate' } // for (let index = 0; index < e.routes.length; index++) { var popup = new L.Popup(customOptions); var popupLocation = new L.LatLng(e.routes[0].coordinates[parseInt(e.routes[0] .coordinates .length / divideBy)].lat, e.routes[0].coordinates[parseInt(e.routes[0].coordinates.length / divideBy)] .lng); var popupContent = "مسافت : " + parseFloat(e.routes[0].summary.totalDistance / 1000.0).toFixed(2) + " کیلومتر"; popup.setLatLng(popupLocation); popup.setContent(popupContent); popupArrays.push(popup); map.addLayer(popup); // } }).addTo(map) ); $('input[name=calcDistance]').val((data.routes[0].distance / 1000).toFixed(2)); $('input[name=routeName]').val(data.routes[0].legs[0].summary); $('select[name=selectOstan]').val(1); $('input[name=selectCity]').val('تهران'); }); $('.leaflet-control-container').css('display', 'none'); $('.leaflet-routing-container-hide').css('display', 'none'); break; } } } $('.project-timeline .timeline-item').on('click', function () { if ($(this).hasClass('is-completed')) { let projectSelectedStep = parseInt($(this).find('span').text()); $('.project-timeline > .card-timeline > .card-body > button.btn-next').text('مرحله بعدی'); $('.project-timeline > .card-timeline > .card-body > button.btn-prev').text('مرحله قبلی'); changeStepLock = true; changeProgressStep(projectSelectedStep - projectStep, projectSelectedStep); let currentProjectStep = $('.submit-step.active').removeClass('active'); let SelectedProjectStep = $('#submit-step-' + projectSelectedStep).addClass('active'); currentProjectStep.fadeOut(300, function () { SelectedProjectStep.fadeIn(300, function () { changeStepLock = false; }); }); projectStep = projectSelectedStep; projectSubStep = projectMaxSubStep[projectStep - 1]; } }); $(document).ready(function () { $('.select2Construction').select2(); $('.select2Maintenance').select2(); // When one radio button is checked $('#operationType1').on('click', function () { if ($(this).is(':checked')) { $('#maintenanceSubOperation').hide(); $('#constructionSubOperation').show(); } else { $('#constructionSubOperation').hide(); } }); $('#operationType2').on('click', function () { if ($(this).is(':checked')) { $('#constructionSubOperation').hide(); $('#maintenanceSubOperation').show(); } else { $('#maintenanceSubOperation').hide(); } }); $('.submit-step .form-group').on('click', function () { let step = $(this).find('input').attr('stepid'); if (step != '0') { let subStep = $(this).find('input').attr('stepid'); showSpecificModal(parseInt(step.substr(0, 1)), parseInt(subStep.substr(-1))); } }); }); function showSpecificModal(step, subStep) { let stepModalFooter = $('#stepModal .modal-content > .modal-footer'); stepModalFooter.find('button.btn-applyChange').show(); stepModalFooter.find('button.btn-applyChangeCancel').show(); stepModalFooter.find('button.btn-prev').hide(); stepModalFooter.find('button.btn-next').hide(); stepBackup = projectStep; subStepBackUp = projectSubStep; projectStep = step; addSubStepInput(projectSubStep = subStep); } //=========mixstar11 // Dropzone.autoDiscover = false; // var myDropzone = new Dropzone(".dropzone", { // autoProcessQueue: false, // parallelUploads: 10 // Number of files process at a time (default 2) // }); // $('#uploadfiles').click(function(){ // myDropzone.processQueue(); // }); // //====================================== // var myDropzone = new Dropzone("div#upfiles", { // url: "/file/post" // }); // $("div#upfiles").dropzone({ // url: "/file/post" // }); function showLoaderScreen() { $('.starter-loader-container').css('display', 'flex').hide().fadeIn(); } function hideLoaderScreen() { $('.starter-loader-container').fadeOut(); }