File manager - Edit - /home/autoph/public_html/ltms-upload/js/ltms11-18-24.js
Back
var upload_image_name = []; var myDropzone; function photoDropzoneListener() { Dropzone.autoDiscover = false; // Disable auto-discovery // Initialize Dropzone myDropzone = new Dropzone("#upload-ltms-photo", { url: "upload.php", // Ensure the URL is correct autoProcessQueue: false, // Disable auto-upload acceptedFiles: '.png,.jpg,.jpeg', maxFilesize: 40, // Max file size in MB maxFiles: 10, // Max number of files clickable: true, addRemoveLinks: true, dictCancelUpload: 'Cancel', parallelUploads: 10, // Allow multiple files to be uploaded in parallel renameFile: function (file) { var extension = file.name.substr((file.name.lastIndexOf('.') + 1)).toLowerCase(); let newName = uniqImgId() + '.' + extension; upload_image_name.push(newName); console.log(newName); return newName; }, init: function () { this.on("maxfilesexceeded", function (file) { alert('Only 10 images allowed.'); this.removeFile(file); return; }); this.on("error", function (file, response) { alert(response || 'Error uploading file.'); }); this.on("success", function (file, response) { var removeLink = file.previewElement.querySelector('.dz-remove'); if (removeLink) { removeLink.parentNode.removeChild(removeLink); } }); this.on('sending', function (file, xhr, formData) { formData.append("fullname", $("#fullname").val()); formData.append('cs_number', $("#cs_number").val()); }); this.on('complete', function (file) { console.log(file) if (myDropzone.getQueuedFiles().length === 0 && myDropzone.getUploadingFiles().length === 0) { const now = new Date(); const formatter = new Intl.DateTimeFormat("en-PH", { timeZone: "Asia/Manila", year: "numeric", month: "long", day: "numeric", // hour: "2-digit", // minute: "2-digit", // second: "2-digit", // hour12: true }); const formattedTime = formatter.format(now); var fullname = $("#fullname").val(); var csNumber = $("#cs_number").val() || "(N/A)"; // Show N/A if CS Number is not provided Swal.fire({ title: "Success!", html: `<p>Your image has been uploaded successfully.</p><br> <p><strong>Registered Name:</strong> ${fullname}</p> <p><strong>CS Number:</strong> ${csNumber}</p> <p><strong>Date:</strong> ${formattedTime}</p><br> <small><p>You can screenshot this message for your reference.</p></small>`, icon: "success", showConfirmButton: true, confirmButtonText: "Close", allowOutsideClick: false }).then(() => { // Refresh the page when the alert is closed window.location.reload(); $("#fullname").val(''); $("#cs_number").val(''); }); } }); } }); // Handle form submit button click $('#ltms-submit').on('click', function (e) { e.preventDefault(); // Prevent default form submission if($("#fullname").val()==''){ Swal.fire({ title: "Warning!", text: "Fullname is required!", icon: "warning" }); return; // setTimeout(() => { // // Refresh the page or update the UI // window.location.reload(); // }, "1500"); } if (myDropzone.getQueuedFiles().length > 0) { // Show loading indicator myDropzone.processQueue(); // Upload files if there are any } else { alert('No files to upload.'); } }); } $("#btn-upload-ltms").on('click',function(){ $("#ltms-container").show(); $(this).hide(); $("#customer-ltms-image-data").hide(); }); // $("#ltms-submit-cancel").on('click',function(){ // // window.location.reload(); // $("#ltms-container").hide(); // $("#btn-upload-ltms").show(); // $("#customer-ltms-image-data").show(); // }); function uniqImgId() { var id = Math.round(new Date().getTime() + (Math.random() * 100)); return id; } function removeImage(id) { // alert(id); Swal.fire({ icon: 'warning', html: 'Do you want to remove this image?', showDenyButton: false, showCancelButton: true, confirmButtonText: `Confirm`, denyButtonText: `Don't Confirm`, }).then((result) => { if (result.isConfirmed) { // toastr.remove(); $.ajax({ url: "api/upload/upload_image_ltms.php", method: "POST", data: { apiKey: '9434631886897744', id: id }, cache: false, beforeSend: function() { alert('info', 'Oops...', 'Removing image...'); }, success: function(data) { // fetchVehicleInfo(vehicle_record_id, customer_record_id) // readVehicleImage(vehicle_record_id); readLtmsUpload(); sweetAlertSimple('success', 'Oops...', 'Image remove successfully.'); // setTimeout(() => { // // Refresh the page or update the UI // window.location.reload(); // }, "1000"); } }) } else if (result.isDenied) { // Swal.fire('', 'Changes are not saved', 'info') } }) } // function readLtmsUpload() { // $.ajax({ // url: "api/upload/upload_image_ltms.php", // type: "POST", // dataType: 'json', // data: { // apiKey: '1164288154587287', // cuid:customer_record_id // }, // beforeSend: function() {}, // success: function(result) { // // result.total // $('#customer-ltms-image-data').html(''); // $('#customer-ltms-image-data').append(result.vehicle_image); // } // }); // } // readLtmsUpload(); photoDropzoneListener();
| ver. 1.4 |
.
| PHP 7.3.33 | Generation time: 0.05 |
proxy
|
phpinfo
|
Settings