"use strict"; var KTCreateAccount = function() { var reason_othersel, e, t, i, a, r, newPhotoSubmitBtn, newMeasurementSubmitBtn, newObjectSubmitBtn, newRoomSubmitBtn, editRoomSubmitBtn, stepperSubmitBtn, stepperNextBtn, stepperPrevBtn, locationStepper, tableRooms, tablePhotos, tableMeasurements, tableObjects, curr_roomid, curr_uploadphoto="", myDropzone_photo, myDropzone_measurement, myDropzone_object, uploadChk, nextsignature, s = []; var updateVal = function(cell,val){ $.ajax({ type: "POST", dataType: "JSON", url: '/reports/update_val', data: {'val':val,'cell':cell,'report_id':report_id}, success: function(e, t, n) { }, error: function(e) { toastr.error("Bitte versuchen Sie es erneut", "Es ist ein Fehler aufgetreten", { timeOut: 0, extendedTimeOut: 0, closeButton: !0, closeDuration: 0 }) }, complete: function() { } }); } var dtRooms; var initDatatableRooms = function () { dtRooms = $("#kt_datatable_rooms").DataTable({ language: { url: '//cdn.datatables.net/plug-ins/2.0.8/i18n/de-DE.json', }, /* responsive: { details: { renderer: DataTable.Responsive.renderer.listHiddenNodes(), display: DataTable.Responsive.display.childRowImmediate, target: '', type: 'none' } },*/ searchDelay: 500, paging: false, processing: true, serverSide: false, order: [[0, 'desc']], stateSave: true, ajax: { url: "/room/getrooms/"+location_id+"/"+report_id, }, columns: [ /* { data: 'name' }, { data: 'count_photos' }, { data: 'count_measurements' }, { data: 'count_objects' },*/ { data: null } ], columnDefs: [ /* { targets: 0, orderable: false, render: function (data, type, row) { return ` ${row.name}`; } }, { targets: [1,2,3], orderable: false, className: 'dt-body-center dt-head-center', render: function (data, type, row) { if(data == 0){ return data; }else{ return `${data}`; } } },*/ { targets: 0, data: null, orderable: false, sortable: false, className: '', render: function (data, type, row) { if(row.count_photos == 0){ var ret_ph=`

${row.count_photos}

`; }else{ var ret_ph=`${row.count_photos}`; } if(row.count_measurements == 0){ var ret_mes=`

${row.count_measurements}

`; }else{ var ret_mes=`${row.count_measurements}`; } if(row.count_objects == 0){ var ret_obj=`

${row.count_objects}

`; }else{ var ret_obj=`${row.count_objects}`; } return `
${row.name}
Fotos:
${ret_ph}
Messungen:
${ret_mes}
Objekte:
${ret_obj}
`; }, } ] }); tableRooms = dtRooms.$; // Re-init functions on every table re-draw -- more info: https://datatables.net/reference/event/draw dtRooms.on('draw', function () { handleSelectRoom(); $("#kt_datatable_rooms thead").remove(); }); } var dtPhotos; var initDatatablePhotos = function () { dtPhotos = $("#kt_datatable_listphotos").DataTable({ language: { url: '//cdn.datatables.net/plug-ins/2.0.8/i18n/de-DE.json', }, searchDelay: 500, paging: false, processing: true, serverSide: false, order: [[0, 'desc']], stateSave: true, /* ajax: { url: "/photo/getphotos/"+room_id, },*/ columns: [ { data: null } ], columnDefs: [ { targets: 0, data: null, orderable: false, sortable: false, className: '', render: function (data, type, row) { return `
${row.title}

${row.description}
`; }, } ] }); tablePhotos = dtPhotos.$; // Re-init functions on every table re-draw -- more info: https://datatables.net/reference/event/draw dtPhotos.on('draw', function () { handleSelectPhoto(); $("#kt_datatable_listphotos thead").remove(); }); } var dtMeasurements; var initDatatableMeasurements = function () { dtMeasurements = $("#kt_datatable_listmeasurements").DataTable({ language: { url: '//cdn.datatables.net/plug-ins/2.0.8/i18n/de-DE.json', }, searchDelay: 500, paging: false, processing: true, serverSide: false, order: [[0, 'desc']], stateSave: true, /* ajax: { url: "/photo/getphotos/"+room_id, },*/ columns: [ { data: null } ], columnDefs: [ { targets: 0, data: null, orderable: false, sortable: false, className: '', render: function (data, type, row) { return `
${row.measurement_type}

${row.value}

${row.title}

${row.description}
`; }, } ] }); tableMeasurements = dtMeasurements.$; // Re-init functions on every table re-draw -- more info: https://datatables.net/reference/event/draw dtMeasurements.on('draw', function () { handleSelectMeasurement(); $("#kt_datatable_listmeasurements thead").remove(); }); } var dtObjects; var initDatatableObjects= function () { dtObjects = $("#kt_datatable_listobjects").DataTable({ language: { url: '//cdn.datatables.net/plug-ins/2.0.8/i18n/de-DE.json', }, searchDelay: 500, paging: false, processing: true, serverSide: false, order: [[0, 'desc']], stateSave: true, /* ajax: { url: "/photo/getphotos/"+room_id, },*/ columns: [ { data: null } ], columnDefs: [ { targets: 0, data: null, orderable: false, sortable: false, className: '', render: function (data, type, row) { return `
${row.object_name}

${row.measured_value}

${row.title}

${row.description}
`; }, } ] }); tableObjects = dtObjects.$; // Re-init functions on every table re-draw -- more info: https://datatables.net/reference/event/draw dtObjects.on('draw', function () { handleSelectObject(); $("#kt_datatable_listobjects thead").remove(); }); } // Select Photo var handleSelectPhoto = () => { const deletePhotoButtons = document.querySelectorAll('[data-kt-docs-table-filter="delete_photo"]') deletePhotoButtons.forEach(d => { d.addEventListener('click', function (e) { e.preventDefault(); var imgid=$(this).attr("data-id"); Swal.fire({ html: `Möchten Sie das ausgewählte Bild löschen?`, icon: "error", buttonsStyling: false, showCancelButton: true, confirmButtonText: "Ja", cancelButtonText: 'Nein, abbrechen', customClass: { confirmButton: "btn btn-primary", cancelButton: 'btn btn-danger' } }).then((function(ev) { if(ev.isConfirmed){ deletePhoto(imgid); } })); }) }); } // Select Measurement var handleSelectMeasurement = () => { const deleteMeasureButtons = document.querySelectorAll('[data-kt-docs-table-filter="delete_measurement"]') deleteMeasureButtons.forEach(d => { d.addEventListener('click', function (e) { e.preventDefault(); var imgid=$(this).attr("data-id"); Swal.fire({ html: `Möchten Sie die ausgewählte Messung löschen?`, icon: "error", buttonsStyling: false, showCancelButton: true, confirmButtonText: "Ja", cancelButtonText: 'Nein, abbrechen', customClass: { confirmButton: "btn btn-primary", cancelButton: 'btn btn-danger' } }).then((function(ev) { if(ev.isConfirmed){ deleteMeasurement(imgid); } })); }) }); } // Select Object var handleSelectObject = () => { const deleteObjectButtons = document.querySelectorAll('[data-kt-docs-table-filter="delete_object"]') deleteObjectButtons.forEach(d => { d.addEventListener('click', function (e) { e.preventDefault(); var imgid=$(this).attr("data-id"); Swal.fire({ html: `Möchten Sie das ausgewählte Objekt löschen?`, icon: "error", buttonsStyling: false, showCancelButton: true, confirmButtonText: "Ja", cancelButtonText: 'Nein, abbrechen', customClass: { confirmButton: "btn btn-primary", cancelButton: 'btn btn-danger' } }).then((function(ev) { if(ev.isConfirmed){ deleteObject(imgid); } })); }) }); } // Select Room var handleSelectRoom = () => { // Select all delete buttons var selectListFotoButtons = document.querySelectorAll('[data-kt-docs-table-filter="list_photos"]'); selectListFotoButtons.forEach(d => { d.addEventListener('click', function (e) { e.preventDefault(); curr_roomid = $(this).attr("data-roomid"); updateDatatablePhotos($(this).attr("data-roomid")); $("#kt_modal_listphotos").modal('show'); }) }); var selectListMeasureButtons = document.querySelectorAll('[data-kt-docs-table-filter="list_measurements"]'); selectListMeasureButtons.forEach(d => { d.addEventListener('click', function (e) { e.preventDefault(); curr_roomid = $(this).attr("data-roomid"); updateDatatableMeasurements($(this).attr("data-roomid")); $("#kt_modal_listmeasurments").modal('show'); }) }); var selectListObjectsButtons = document.querySelectorAll('[data-kt-docs-table-filter="list_objects"]'); selectListObjectsButtons.forEach(d => { d.addEventListener('click', function (e) { e.preventDefault(); curr_roomid = $(this).attr("data-roomid"); updateDatatableObjects($(this).attr("data-roomid")); $("#kt_modal_listobjects").modal('show'); }) }); var selectFotoButtons = document.querySelectorAll('[data-kt-docs-table-filter="room_photo"]'); selectFotoButtons.forEach(d => { d.addEventListener('click', function (e) { e.preventDefault(); curr_roomid = $(this).attr("data-roomid"); $("#kt_modal_new_photo").modal('show'); }) }); var selectObjectButtons = document.querySelectorAll('[data-kt-docs-table-filter="room_object"]'); selectObjectButtons.forEach(d => { d.addEventListener('click', function (e) { e.preventDefault(); curr_roomid = $(this).attr("data-roomid"); $("#kt_modal_new_object").modal('show'); }) }); var selectMeasureButtons = document.querySelectorAll('[data-kt-docs-table-filter="room_measure"]'); selectMeasureButtons.forEach(d => { d.addEventListener('click', function (e) { e.preventDefault(); curr_roomid = $(this).attr("data-roomid"); $("#kt_modal_new_measurement").modal('show'); }) }); var editRoomButtons = document.querySelectorAll('[data-kt-docs-table-filter="edit_room"]'); editRoomButtons.forEach(d => { d.addEventListener('click', function (e) { e.preventDefault(); // const parent = e.target.closest('div'); const roomName = parent.querySelectorAll('span')[0].innerText; $("#room_name").val(roomName); $("#room_id").val($(this).attr("data-id")); $("#kt_modal_rename_room").modal('show'); }) }); } //update rooms var updateDatatableRooms = function (){ $("#kt_datatable_rooms").DataTable().ajax.url("/room/getrooms/"+location_id+"/"+report_id).load(); } var updateDatatablePhotos = function (room_id){ $("#kt_datatable_listphotos").DataTable().ajax.url("/photo/getphotos/"+room_id).load(); } var updateDatatableMeasurements = function (room_id){ $("#kt_datatable_listmeasurements").DataTable().ajax.url("/photo/getmeasurements/"+room_id).load(); } var updateDatatableObjects = function (room_id){ $("#kt_datatable_listobjects").DataTable().ajax.url("/photo/getobjects/"+room_id).load(); } /* delete photo */ var deletePhoto = function(id){ $.ajax({ type: "POST", dataType: "JSON", url: '/photo/deletephoto', data: {'photoId':id}, success: function(e, t, n) { }, error: function(e) { toastr.error("Bitte versuchen Sie es erneut", "Es ist ein Fehler aufgetreten", { timeOut: 0, extendedTimeOut: 0, closeButton: !0, closeDuration: 0 }) }, complete: function() { $("#kt_datatable_listphotos").DataTable().ajax.url("/photo/getphotos/"+curr_roomid).load(); updateDatatableRooms(); } }) } /* delete measurement */ var deleteMeasurement = function(id){ $.ajax({ type: "POST", dataType: "JSON", url: '/photo/deletemeasurement', data: {'photoId':id}, success: function(e, t, n) { }, error: function(e) { toastr.error("Bitte versuchen Sie es erneut", "Es ist ein Fehler aufgetreten", { timeOut: 0, extendedTimeOut: 0, closeButton: !0, closeDuration: 0 }) }, complete: function() { $("#kt_datatable_listmeasurements").DataTable().ajax.url("/photo/getmeasurements/"+curr_roomid).load(); updateDatatableRooms(); } }) } /* delete object */ var deleteObject = function(id){ $.ajax({ type: "POST", dataType: "JSON", url: '/photo/deleteobject', data: {'photoId':id}, success: function(e, t, n) { }, error: function(e) { toastr.error("Bitte versuchen Sie es erneut", "Es ist ein Fehler aufgetreten", { timeOut: 0, extendedTimeOut: 0, closeButton: !0, closeDuration: 0 }) }, complete: function() { $("#kt_datatable_listobjects").DataTable().ajax.url("/photo/getobjects/"+curr_roomid).load(); updateDatatableRooms(); } }) } /* DROPZONES */ var initDropZones = () => { myDropzone_photo = new Dropzone("#kt_modal_dropzone_photo", { url: "/photo/make_photo", paramName: "inputImg", maxFiles: 1, uploadMultiple: false, maxFilesize: 10, // MB addRemoveLinks: true, init: function() { this.on("maxfilesexceeded", function(file,s) { this.removeAllFiles(); this.addFile(file); }); this.on("removedfile", function(file) { curr_uploadphoto=""; }); }, accept: function (file, done) { //console.log(file); // console.log(done); // if (file.name == "justinbieber.jpg") { // done("Alert"); // } else { done(); //} }, success: function( file, response ) { var jsonobj=JSON.parse(response); curr_uploadphoto= jsonobj.imgfile; } }); myDropzone_measurement = new Dropzone("#kt_modal_dropzone_measure", { url: "/photo/make_photo", paramName: "inputImg", maxFiles: 1, uploadMultiple: false, maxFilesize: 10, // MB addRemoveLinks: true, init: function() { this.on("maxfilesexceeded", function(file) { this.removeAllFiles(); this.addFile(file); }); this.on("removedfile", function(file) { curr_uploadphoto=""; }); }, accept: function (file, done) { done(); }, success: function( file, response ) { var jsonobj=JSON.parse(response); curr_uploadphoto= jsonobj.imgfile; } }); myDropzone_object = new Dropzone("#kt_modal_dropzone_object", { url: "/photo/make_photo", paramName: "inputImg", maxFiles: 1, uploadMultiple: false, maxFilesize: 10, // MB addRemoveLinks: true, init: function() { this.on("maxfilesexceeded", function(file) { this.removeAllFiles(); this.addFile(file); }); this.on("removedfile", function(file) { curr_uploadphoto=""; }); }, accept: function (file, done) { done(); }, success: function( file, response ) { var jsonobj=JSON.parse(response); curr_uploadphoto= jsonobj.imgfile; } }); } /* datepicker */ var initDatePickers = () => { // Due date. For more info, please visit the official plugin site: https://flatpickr.js.org/ var dateUser = document.querySelector('[name="date_user"]'); dateUser.flatpickr({ enableTime: true, dateFormat: "d, M Y, H:i", time_24hr: true, locale: { weekdays: { longhand: ['Montag', 'Dientag', 'MIttwoch', 'Donnerstrag', 'Freitag', 'Samstag', 'Sonnatg'], shorthand: ['Mo', 'Di', 'Mi', 'Do', 'PFrr', 'Sa', 'So'] }, months: { longhand: ['Januar', 'Februar', 'März', 'April', 'Mai', 'Juni', 'Juli', 'August', 'September', 'Oktober', 'November', 'Dezember'], shorthand: ['Jan', 'Feb', 'Mär', 'Apr', 'Ai', 'Jun', 'Jul', 'Aug', 'Sept', 'Okt', 'Nov', 'Dez'] }, today: 'Heute', clear: 'löschen' } }); var dateClient = document.querySelector('[name="date_client"]'); dateClient.flatpickr({ enableTime: true, dateFormat: "d, M Y, H:i", time_24hr: true, locale: { weekdays: { longhand: ['Montag', 'Dientag', 'MIttwoch', 'Donnerstrag', 'Freitag', 'Samstag', 'Sonnatg'], shorthand: ['Mo', 'Di', 'Mi', 'Do', 'PFrr', 'Sa', 'So'] }, months: { longhand: ['Januar', 'Februar', 'März', 'April', 'Mai', 'Juni', 'Juli', 'August', 'September', 'Oktober', 'November', 'Dezember'], shorthand: ['Jan', 'Feb', 'Mär', 'Apr', 'Ai', 'Jun', 'Jul', 'Aug', 'Sept', 'Okt', 'Nov', 'Dez'] }, today: 'Heute', clear: 'löschen' } }); } /* signatures */ var initSignatures = function (){ const wrapper = document.getElementById("signature-pad"); const canvasWrapper = document.getElementById("canvas-wrapper"); const clearButton = wrapper.querySelector("[data-action=clear]"); const canvas = wrapper.querySelector("canvas"); const signaturePad = new SignaturePad(canvas, { // It's Necessary to use an opaque color when saving image as JPEG; // this option can be omitted if only saving as PNG or SVG backgroundColor: 'rgb(255, 255, 255)' }); var clearSignButton= document.getElementById("clear_signature"); clearSignButton.addEventListener("click", () => { signaturePad.clear(); }); var confirmSignButton= document.getElementById("confirm_signature"); confirmSignButton.addEventListener("click", () => { $("#signature_"+nextsignature+"_ready").css("background-image","url("+signaturePad.toDataURL()+")"); $("#kt_modal_signature").modal('hide'); signaturePad.clear(); }); function resizeCanvas() { // When zoomed out to less than 100%, for some very strange reason, // some browsers report devicePixelRatio as less than 1 // and only part of the canvas is cleared then. const ratio = Math.max(window.devicePixelRatio || 1, 1); // This part causes the canvas to be cleared canvas.width = canvas.offsetWidth * ratio; canvas.height = canvas.offsetHeight * ratio; canvas.getContext("2d").scale(ratio, ratio); // This library does not listen for canvas changes, so after the canvas is automatically // cleared by the browser, SignaturePad#isEmpty might still return false, even though the // canvas looks empty, because the internal data of this library wasn't cleared. To make sure // that the state of this library is consistent with visual state of the canvas, you // have to clear it manually. //signaturePad.clear(); // If you want to keep the drawing on resize instead of clearing it you can reset the data. signaturePad.fromData(signaturePad.toData()); } $('#kt_modal_signature').on('shown.bs.modal', function (e) { signaturePad.clear(); resizeCanvas(); nextsignature=$(e.relatedTarget).attr("data-nextsign"); }); // On mobile devices it might make more sense to listen to orientation change, // rather than window resize events. window.onresize = resizeCanvas; } return { init: function() { initDatatableRooms(); initDatatablePhotos(); initDatatableMeasurements(); initDatatableObjects(); initDropZones(); initDatePickers(); initSignatures(); (e = document.querySelector("#kt_modal_create_account")) && new bootstrap.Modal(e), (t = document.querySelector("#kt_create_account_stepper")) && (i = t.querySelector("#kt_create_account_form"), stepperSubmitBtn = t.querySelector('[data-kt-stepper-action="submit"]'), stepperNextBtn = t.querySelector('[data-kt-stepper-action="next"]'), stepperPrevBtn = t.querySelector('[data-kt-stepper-action="previous"]'), (locationStepper = new KTStepper(t)).on("kt.stepper.changed", (function(e) { /*dtRooms.columns.adjust(),*/ 5 === locationStepper.getCurrentStepIndex() ? (stepperSubmitBtn.classList.remove("d-none"), stepperSubmitBtn.classList.add("d-inline-block"), stepperNextBtn.classList.add("d-none")) : 6 === locationStepper.getCurrentStepIndex() ? (stepperSubmitBtn.classList.add("d-none"), stepperNextBtn.classList.add("d-none"), stepperPrevBtn.classList.add("d-none")) : (stepperSubmitBtn.classList.remove("d-inline-block"), stepperSubmitBtn.classList.remove("d-none"), stepperNextBtn.classList.remove("d-none")) })), locationStepper.on("kt.stepper.next", (function(e) { console.log("stepper.next"); var t = s[e.getCurrentStepIndex() - 1]; t ? t.validate().then((function(t) { console.log("validated!"), "Valid" == t ? (e.goNext(), KTUtil.scrollTop()) : Swal.fire({ text: "Sorry, looks like there are some errors detected, please try again.", icon: "error", buttonsStyling: !1, confirmButtonText: "Ok, got it!", customClass: { confirmButton: "btn btn-light" } }).then((function() { KTUtil.scrollTop() })) })) : (e.goNext(), KTUtil.scrollTop()) })), locationStepper.on("kt.stepper.previous", (function(e) { console.log("stepper.previous"), e.goPrevious(), KTUtil.scrollTop() })), s.push(FormValidation.formValidation(i, { fields: { reason_type: { validators: { notEmpty: { message: "Account type is required" } } } }, plugins: { trigger: new FormValidation.plugins.Trigger, bootstrap: new FormValidation.plugins.Bootstrap5({ rowSelector: ".fv-row", eleInvalidClass: "", eleValidClass: "" }) } })), s.push(FormValidation.formValidation(i, { fields: { account_team_size: { validators: { notEmpty: { message: "Time size is required" } } }, account_name: { validators: { notEmpty: { message: "Account name is required" } } }, account_plan: { validators: { notEmpty: { message: "Account plan is required" } } } }, plugins: { trigger: new FormValidation.plugins.Trigger, bootstrap: new FormValidation.plugins.Bootstrap5({ rowSelector: ".fv-row", eleInvalidClass: "", eleValidClass: "" }) } })), s.push(FormValidation.formValidation(i, { fields: { business_name: { validators: { notEmpty: { message: "Busines name is required" } } }, business_descriptor: { validators: { notEmpty: { message: "Busines descriptor is required" } } }, business_type: { validators: { notEmpty: { message: "Busines type is required" } } }, business_email: { validators: { notEmpty: { message: "Busines email is required" }, emailAddress: { message: "The value is not a valid email address" } } } }, plugins: { trigger: new FormValidation.plugins.Trigger, bootstrap: new FormValidation.plugins.Bootstrap5({ rowSelector: ".fv-row", eleInvalidClass: "", eleValidClass: "" }) } })), s.push(FormValidation.formValidation(i, { fields: { card_name: { validators: { notEmpty: { message: "Name on card is required" } } }, card_number: { validators: { notEmpty: { message: "Card member is required" }, creditCard: { message: "Card number is not valid" } } }, card_expiry_month: { validators: { notEmpty: { message: "Month is required" } } }, card_expiry_year: { validators: { notEmpty: { message: "Year is required" } } }, card_cvv: { validators: { notEmpty: { message: "CVV is required" }, digits: { message: "CVV must contain only digits" }, stringLength: { min: 3, max: 4, message: "CVV must contain 3 to 4 digits only" } } } }, plugins: { trigger: new FormValidation.plugins.Trigger, bootstrap: new FormValidation.plugins.Bootstrap5({ rowSelector: ".fv-row", eleInvalidClass: "", eleValidClass: "" }) } })), stepperSubmitBtn.addEventListener("click", (function(e) { s[3].validate().then((function(t) { console.log("validated!"), "Valid" == t ? (e.preventDefault(), stepperSubmitBtn.disabled = !0, stepperSubmitBtn.setAttribute("data-kt-indicator", "on"), setTimeout((function() { stepperSubmitBtn.removeAttribute("data-kt-indicator"), stepperSubmitBtn.disabled = !1, locationStepper.goNext() }), 2e3)) : Swal.fire({ text: "Sorry, looks like there are some errors detected, please try again.", icon: "error", buttonsStyling: !1, confirmButtonText: "Ok, got it!", customClass: { confirmButton: "btn btn-light" } }).then((function() { KTUtil.scrollTop() })) })) })), $(i.querySelector('[name="card_expiry_month"]')).on("change", (function() { s[3].revalidateField("card_expiry_month") })), $(i.querySelector('[name="card_expiry_year"]')).on("change", (function() { s[3].revalidateField("card_expiry_year") })), $(i.querySelector('[name="business_type"]')).on("change", (function() { s[2].revalidateField("business_type") })), /* select reason*/ $('input[name="reason_type"]').on("click", (function() { if ($(this).parent().is(':last-of-type')) { $("#reason_input_other").removeClass("d-none"); }else{ $("#reason_input_other").addClass("d-none"); } updateVal("reason_ids",$(this).val()); })), $('input[name="reason_input_other"]').on("focusout", (function() { updateVal("reason_other",$(this).val()); })), /* select system*/ $('input[name="system_types"]').on("click", (function() { if ($(this).parent().parent().parent().is(':last-of-type')) { if($(this).prop('checked')){ $("#system_other").removeClass("d-none"); }else{ $("#system_other").addClass("d-none"); } } var systenid_str = $.map($('input[name="system_types"]:checked'), function(c){return c.value; }).join(','); updateVal("system_ids",systenid_str); })), $('input[name="system_sonstiges"]').on("focusout", (function() { updateVal("system_other",$(this).val()); })), /* select material system*/ $('input[name="material_types"]').on("click", (function() { if ($(this).parent().parent().parent().is(':last-of-type')) { if($(this).prop('checked')){ $("#material_other").removeClass("d-none"); }else{ $("#material_other").addClass("d-none"); } } var materialid_str = $.map($('input[name="material_types"]:checked'), function(c){return c.value; }).join(','); updateVal("material_ids",materialid_str); })), $('input[name="material_other"]').on("focusout", (function() { updateVal("material_other",$(this).val()); })), /* scause found yes no*/ $('input[name="causefound"]').on("click", (function() { updateVal("cause_found",$(this).val()); })), $('input[name="damage_location"]').on("focusout", (function() { updateVal("damage_location",$(this).val()); })), $('textarea[name="damage_affected_areas"]').on("focusout", (function() { updateVal("damage_affected_areas",$(this).val()); })), /* select actions*/ $('input[name="needed_actions"]').on("click", (function() { if ($(this).parent().parent().is(':last-of-type')) { if($(this).prop('checked')){ $("#action_other").removeClass("d-none"); }else{ $("#action_other").addClass("d-none"); } } var action_ids = $.map($('input[name="needed_actions"]:checked'), function(c){return c.value; }).join(','); updateVal("action_ids",action_ids); })), $('input[name="action_other"]').on("focusout", (function() { updateVal("action_other",$(this).val()); })), $('textarea[name="recommendation"]').on("focusout", (function() { updateVal("recommendation",$(this).val()); })), /* text_templates builder s*/ $('input[name="text_templates"]').on("click", (function() { })), /* new room */ $("#room_tempates").on("change", (function(ev) { if($(this).val() != ""){ $("#new_roomname").val($(this).val()); $("#new_roomname").parent().find(".checkicon").addClass("ok"); $("#room_tempates").val('').trigger('change'); } })), $("#new_roomname").on("input", (function(ev) { if($(this).val() != "" && $(this).val().length > 2){ $("#new_roomname").parent().find(".checkicon").addClass("ok"); }else{ $("#new_roomname").parent().find(".checkicon").removeClass("ok"); } })), $("#room_name").on("input", (function(ev) { if($(this).val() != "" && $(this).val().length > 2){ $("#room_name").parent().find(".checkicon").addClass("ok"); }else{ $("#room_name").parent().find(".checkicon").removeClass("ok"); } })), /* new object */ $("#object_tempates").on("change", (function(ev) { if($(this).val() != ""){ $("#object_name").val($(this).val()); $("#object_name").parent().find(".checkicon").addClass("ok"); $("#object_tempates").val('').trigger('change'); } })), $("#object_name").on("input", (function(ev) { if($(this).val() != "" && $(this).val().length > 2){ $("#object_name").parent().find(".checkicon").addClass("ok"); }else{ $("#object_name").parent().find(".checkicon").removeClass("ok"); } })), /* teext templates */ $("#text_tempates").on("change", (function(ev) { if($(this).val() != ""){ var selectedContent = $('#text_tempates option:selected').text(); $("#detailed_report").append(selectedContent + '\n\n'); $("#text_tempates").val('').trigger('change'); } })), /********************************************************************************************************************************************************** new photo ***********************************************************************************************************************************************************/ newPhotoSubmitBtn = document.querySelector("#newPhotoSubmit"), newPhotoSubmitBtn.addEventListener("click", (function(e) { e.preventDefault(); if(!uploadChk($("#photo_title").val())){ return; } $.ajax({ type: "POST", dataType: "JSON", url: '/Photo/addPhoto', data: { 'title':$("#photo_title").val(), 'description':$("#photo_description").val(), 'room_id':curr_roomid, 'location_id':location_id, 'report_id':report_id, 'filename':curr_uploadphoto}, success: function(e, t, n) { }, error: function(e) { toastr.error("Bitte versuchen Sie es erneut", "Es ist ein Fehler aufgetreten", { timeOut: 0, extendedTimeOut: 0, closeButton: !0, closeDuration: 0 }) }, complete: function() { newPhotoSubmitBtn.removeAttribute("data-kt-indicator"); $("#kt_modal_new_photo").modal('hide'); newPhotoSubmitBtn.disabled = !1; $("#photo_title").val(""); $("#photo_description").val(""); curr_uploadphoto=""; myDropzone_photo.removeAllFiles(true); updateDatatableRooms(); toastr.success("erfolgreich erstellt!", "Neues Photo", { timeOut: 2000, extendedTimeOut: 100, closeButton: !0, closeDuration: 0 }) } }) })), /********************************************************************************************************************************************************** new measurement ***********************************************************************************************************************************************************/ newMeasurementSubmitBtn = document.querySelector("#newMeasureSubmit"), newMeasurementSubmitBtn.addEventListener("click", (function(e) { e.preventDefault(); $.ajax({ type: "POST", dataType: "JSON", url: '/Photo/addMeasurement', data: { 'measurement_type':$("#measurement_type").val(), 'measurement_value':$("#measurement_value").val(), 'title':$("#measurement_title").val(), 'description':$("#measurement_description").val(), 'room_id':curr_roomid, 'location_id':location_id, 'report_id':report_id, 'filename':curr_uploadphoto}, success: function(e, t, n) { }, error: function(e) { toastr.error("Bitte versuchen Sie es erneut", "Es ist ein Fehler aufgetreten", { timeOut: 0, extendedTimeOut: 0, closeButton: !0, closeDuration: 0 }) }, complete: function() { newMeasurementSubmitBtn.removeAttribute("data-kt-indicator"); $("#kt_modal_new_measurement").modal('hide'); newMeasurementSubmitBtn.disabled = !1; $("#measurement_type").val('').trigger('change'); $("#measurement_value").val(""); $("#measurement_title").val(""); $("#measurement_description").val(""); curr_uploadphoto=""; myDropzone_measurement.removeAllFiles(true); updateDatatableRooms(); toastr.success("erfolgreich erstellt!", "Neue Messung", { timeOut: 2000, extendedTimeOut: 100, closeButton: !0, closeDuration: 0 }) } }) })), /********************************************************************************************************************************************************** new object ***********************************************************************************************************************************************************/ newObjectSubmitBtn = document.querySelector("#newObjectSubmit"), newObjectSubmitBtn.addEventListener("click", (function(e) { e.preventDefault(); $.ajax({ type: "POST", dataType: "JSON", url: '/Photo/addObject', data: { 'object_name':$("#object_name").val(), 'measured_value':$("#object_measuredvalue").val(), 'title':$("#object_title").val(), 'description':$("#object_description").val(), 'room_id':curr_roomid, 'location_id':location_id, 'report_id':report_id, 'filename':curr_uploadphoto}, success: function(e, t, n) { }, error: function(e) { toastr.error("Bitte versuchen Sie es erneut", "Es ist ein Fehler aufgetreten", { timeOut: 0, extendedTimeOut: 0, closeButton: !0, closeDuration: 0 }) }, complete: function() { newObjectSubmitBtn.removeAttribute("data-kt-indicator"); $("#kt_modal_new_object").modal('hide'); newObjectSubmitBtn.disabled = !1; $("#object_name").val(""); $("#object_title").val(""); $("#object_description").val(""); curr_uploadphoto=""; myDropzone_object.removeAllFiles(true); updateDatatableRooms(); toastr.success("erfolgreich erstellt!", "Neues Object", { timeOut: 2000, extendedTimeOut: 100, closeButton: !0, closeDuration: 0 }) } }) })), /********************************************************************************************************************************************************** check image and title ***********************************************************************************************************************************************************/ uploadChk = function (title){ if(curr_uploadphoto == ""){ Swal.fire({ text: "Bitte wählen Sie ein Bild aus.", icon: "warning", buttonsStyling: !1, confirmButtonText: "Ok", customClass: { confirmButton: "btn btn-light" }}); return false; }else if(title == ""){ Swal.fire({ text: "Bitte geben Sie mind. einen Titel ein", icon: "warning", buttonsStyling: !1, confirmButtonText: "Ok", customClass: { confirmButton: "btn btn-light" }}); return false; }else{ return true; } }, /********************************************************************************************************************************************************** validation new room ***********************************************************************************************************************************************************/ newRoomSubmitBtn = document.querySelector("#newRoomSubmit"), editRoomSubmitBtn = document.querySelector("#editRoomSubmit"), newRoomSubmitBtn.addEventListener("click", (function(e) { e.preventDefault(); if($("#new_roomname").val() == "" && $("#new_roomname").val() < 4){ Swal.fire({ text: "Bitte wählen Sie einen Namen aus der Vorlage aus oder geben Sie eine Raumbezeichnung ein.", icon: "error", buttonsStyling: !1, confirmButtonText: "Ok", customClass: { confirmButton: "btn btn-primary" } }) }else{ newRoomSubmitBtn.setAttribute("data-kt-indicator", "on"); newRoomSubmitBtn.disabled = !0; $.ajax({ type: "POST", dataType: "JSON", url: '/room/add', data: {'name':$("#new_roomname").val(),'location_id':location_id}, success: function(e, t, n) { }, error: function(e) { toastr.error("Bitte versuchen Sie es erneut", "Es ist ein Fehler aufgetreten", { timeOut: 0, extendedTimeOut: 0, closeButton: !0, closeDuration: 0 }) }, complete: function() { newRoomSubmitBtn.removeAttribute("data-kt-indicator"); $("#kt_modal_new_room").modal('hide'); newRoomSubmitBtn.disabled = !1; $("#new_roomname").val(""); $("#new_roomname").parent().find(".checkicon").removeClass("ok"); updateDatatableRooms(); toastr.success("erfolgreich angelegt!", "Neuer Raum", { timeOut: 2000, extendedTimeOut: 100, closeButton: !0, closeDuration: 0 }) } }) } })), editRoomSubmitBtn.addEventListener("click", (function(e) { e.preventDefault(); if($("#room_name").val() == "" && $("#room_name").val().length < 4){ Swal.fire({ text: "Bitte geben Sie eine Raumbezeichnung ein.", icon: "error", buttonsStyling: !1, confirmButtonText: "Ok", customClass: { confirmButton: "btn btn-primary" } }) }else{ editRoomSubmitBtn.setAttribute("data-kt-indicator", "on"); editRoomSubmitBtn.disabled = !0; $.ajax({ type: "POST", dataType: "JSON", url: '/room/add', data: {'name':$("#room_name").val(),'room_id':$("#room_id").val(),'location_id':location_id}, success: function(e, t, n) { }, error: function(e) { toastr.error("Bitte versuchen Sie es erneut", "Es ist ein Fehler aufgetreten", { timeOut: 0, extendedTimeOut: 0, closeButton: !0, closeDuration: 0 }) }, complete: function() { editRoomSubmitBtn.removeAttribute("data-kt-indicator"); $("#kt_modal_rename_room").modal('hide'); editRoomSubmitBtn.disabled = !1; $("#room_name").val(""); $("#room_name").parent().find(".checkicon").removeClass("ok"); updateDatatableRooms(); toastr.success("Neue Bezeichnung übernommen", "Raum", { timeOut: 2000, extendedTimeOut: 100, closeButton: !0, closeDuration: 0 }) } }) } })) /**********************************************************************************************************************************************************/ ) } } }(); KTUtil.onDOMContentLoaded((function() { KTCreateAccount.init() }));