/** * @copyright 2021 Double Bastion LLC * * @author Double Bastion LLC * * @license GNU AGPL version 3 or any later version * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE * License as published by the Free Software Foundation; either * version 3 of the License, or any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU AFFERO GENERAL PUBLIC LICENSE for more details. * * You should have received a copy of the GNU Affero General Public * License along with this program. If not, see . * */ $(document).ready(function() { var userid = ""; var readtxtfile = []; var readhtmlfile = []; var readjpg = []; var readpng = []; // Check the available balance $("#checkbalance").on("click", function(event) { $('#checkbalance').addClass('icon-loading'); var getbalanceUrl = OC.generateUrl("/apps/pax_fax/user/getbalance"); $.ajax({ url: getbalanceUrl + '/' + userid, type: "POST", data: {userid: userid}, cache: false, processData: false, contentType: false, success: function(phaxiobalance) { var balanceindlrs = phaxiobalance / 100; var balanceproc = "$ " + balanceindlrs.toFixed(2); $('#currentbalance').text(balanceproc); $('#checkbalance').removeClass('icon-loading'); } }); }); // Select the Caller ID $("#selectcalleridbttn").on("click", function(event) { $('#selectcalleridbttn').addClass('icon-loading'); var getfaxnumbersUrl = OC.generateUrl("/apps/pax_fax/user/getfaxnumbers"); var selectednmbr = null; $.ajax({ url: getfaxnumbersUrl + '/' + userid, type: "POST", data: {userid: userid}, cache: false, processData: false, contentType: false, success: function(phaxionmbrs) { $('#currentfaxnmbrs').empty(); $('#currentfaxnmbrs').append(""); $('#currentfaxnmbrs').append(""); $.each(phaxionmbrs, function(key, indfxnmb) { $('#currentfaxnmbrs').append(""); }); $('#selectcalleridbttn').removeClass('icon-loading'); } }); }); // Clean the Pax_Fax/temp_files directory var cleanflUrl = OC.generateUrl("/apps/pax_fax/user/cleantempdir"); $.ajax({ url: cleanflUrl + '/' + userid, type: "POST", data: {userid: userid}, cache: false, processData: false, contentType: false }); var n = 1; var uploadedtofax = []; var ordernmbrs = []; // Upload files to be faxed $("#uploadfileforfax").change(function(e){ OC.msg.startAction("#pf_upload_msg", t("pax_fax", "Uploading ...")); $('#faxdocpreview').addClass('icon-loading'); $('#filestotsize').show(); var userid = ""; var baseUrl = OC.generateUrl("/apps/pax_fax/user/uploadfile"); var formData = new FormData(); formData.append('uploadfileforfax', $('#uploadfileforfax')[0].files[0]); var currentflsize = $('#uploadfileforfax')[0].files[0].size; var fileup = $('#uploadfileforfax').val(); var fileuptrim = fileup.split('\\').pop(); if ($.inArray(fileuptrim, uploadedtofax) != -1) { var duplicatescheck = 1; } else var duplicatescheck = 0; var extension = fileup.replace(/^.*\./, ''); if (extension == fileup) { extension = ""; } else { extension = extension.toLowerCase(); } var validExtensions = ["pdf", "doc", "docx", "tif", "tiff", "jpg", "odt", "txt", "html", "png"]; if ($.inArray(extension, validExtensions) != -1) { if (duplicatescheck == 0) { if (currentflsize < 20971520) { if (n < 21) { uploadedtofax.push(fileuptrim); $.ajax({ url: baseUrl + '/' + userid, type: "POST", data: formData, cache: false, processData: false, contentType: false, success: function(totalflsize) { $('#filessizetext').text(totalflsize); // Check if the total file size is over 20 MB var rectotfilesz = parseFloat(totalflsize.replace(" MB", "")); if (rectotfilesz > 20.00) { $('#filestotsize').css('color', '#ba3555'); alert("Error ! You can't send files having a total size of more than 20 MB in one fax call ! Please consider removing files so that the total files size would drop to or below 20 MB"); $('#submitfax').attr("disabled", true); } else { $('#submitfax').attr("disabled", false); $('#filestotsize').css('color', '#18bf6e'); } $('#fileuploadednm').append("
" + n + ") " + fileuptrim + "
X

"); n++; // Preview the file $("div:visible[id*='indfilediv']").each(function() { $(this).on("click", function(eventclck) { var faxfilenameinit = $(this).text(); var faxfilenamesec = faxfilenameinit.substring(faxfilenameinit.indexOf(" ") + 1); var faxfilename = faxfilenamesec.replace("X",""); var baseUrl = OC.generateUrl("/remote.php/webdav/Pax_Fax/temp_files/"+faxfilename); var extenlst = faxfilename.replace(/^.*\./, ''); if (extenlst == faxfilename) { extenlst = ""; } else { extenlst = extenlst.toLowerCase(); } if (extenlst == 'pdf') { var viewerclick = OC.generateUrl('/apps/files_pdfviewer/?file={file}', {file: baseUrl}); var $iframe = $('