var isFirst=1; function MyAjaxFileUpload() { //starting setting some animation when the ajax starts and completes $("#loading").show(); /* prepareing ajax file upload url: the url of script file handling the uploaded files fileElementId: the file type of input element id and it will be the index of $_FILES Array() dataType: it support json, xml secureuri:use secure protocol success: call back function when the ajax complete error: callback function when the ajax failed */ $.ajaxFileUpload ( { url:'ajax_fileupload?constructionsite_id='+$("#constructionsite_id").val(), secureuri:false, fileElementId:'fileToUpload', dataType: 'json', success: function (data, status) { $("#loading").hide(); if((typeof(data.error) != 'undefined') && (isFirst != 1)) { $('#errortext').html(data.error); if(data.error != '') { $('#errortext').css("display","block"); }else { $('#errortext').css("display","none"); } } else { $('#errortext').css("display","none"); } isFirst=0; $("#fileToUpload").val(""); var tablename="table_images"; var listname="list_images"; //Alle Zeilen der Tabelle entfernen $("#table_images tr").slice(1).remove(); $("#"+listname).html(""); var gic=0; $.each(data.resulthash, function (i, v) { $("#"+listname).append("
  • "); $("#"+listname+" li:last").append(""); $("#"+listname+" li:last").append(""); $("#"+listname+" li:last").append(""); $("#"+listname+" li:last").append(""); gic++; }); //sortable $('#'+listname).sortable(); $('#'+listname).sortable().bind('sortupdate', function() { var sortstr=""; $(".img_sort").each(function (i,v) { if (sortstr != "") { sortstr=sortstr+","; } sortstr=sortstr+$(v).val(); }); $.ajax({ url: 'ajax_fileupload', data: { sorting : sortstr, mode : "sort", constructionsite_id : $("#constructionsite_id").val() }, type: "POST", dataType: "html" }); }); $(".img_delete").bind('click', function (e) { e.preventDefault(); //console.log("Click to delete "+$(this).attr("data-imgid")); $("#delete_img_button").attr("data-imgid",$(this).attr("data-imgid")); $.magnificPopup.open({ closeBtnInside: false, showCloseBtn: false, removalDelay: 300, mainClass: 'mfp-fade', modal: true, items: { src: $("#deletepopup"), type: 'inline' } }); $(".popup-modal-dismiss").bind('click', function (e) { e.preventDefault(); $.magnificPopup.close(); }); }); $('.edittext').typing({ start: function (event) {}, stop: function (event, elem) { $(elem).after(""); $.ajax({ url: 'ajax_fileupload', data: { mode : "title_save", imgid : $(elem).attr("data-imgid"), title : $(elem).val(), constructionsite_id : $("#constructionsite_id").val() }, type: "POST", dataType: "html" }).done(function() { $("#loader-img").remove(); }); }, delay: 400 }); } } ) return false; } function MyAjaxUserFileUpload() { //starting setting some animation when the ajax starts and completes $("#loading").show(); /* prepareing ajax file upload url: the url of script file handling the uploaded files fileElementId: the file type of input element id and it will be the index of $_FILES Array() dataType: it support json, xml secureuri:use secure protocol success: call back function when the ajax complete error: callback function when the ajax failed */ $.ajaxFileUpload ( { url:'ajax_fileuploaduser?uid='+$("#uid").val(), secureuri:false, fileElementId:'fileToUpload', dataType: 'json', success: function (data, status) { $("#loading").hide(); if((typeof(data.error) != 'undefined')) { $('#errortext_popup').html(data.error); if(data.error != '') { $('#errortext_popup').css("display","block"); }else { $('#errortext_popup').css("display","none"); $.magnificPopup.close(); } } else { $('#errortext_popup').css("display","none"); $.magnificPopup.close(); } $("#fileToUpload").val(""); //console.log(data.media); $("#user_profile").attr("src",data.media+"?timestamp=" + new Date().getTime()); } } ) return false; } function MyAjaxInvoiceFileUpload() { //starting setting some animation when the ajax starts and completes $("#loading").show(); /* prepareing ajax file upload url: the url of script file handling the uploaded files fileElementId: the file type of input element id and it will be the index of $_FILES Array() dataType: it support json, xml secureuri:use secure protocol success: call back function when the ajax complete error: callback function when the ajax failed */ $.ajaxFileUpload ( { url:'ajax_fileuploadinvoice?trade_id='+$("#trade_id").val()+'&amount='+$("#amount").val()+'&invoice_id='+$("#invoice_id").val(), secureuri:false, fileElementId:'fileToUpload', dataType: 'json', success: function (data, status) { $("#loading").hide(); if((typeof(data.error) != 'undefined')) { $('#errortext_popup').html(data.error); if(data.error != '') { $('#errortext_popup').css("display","block"); }else { $('#errortext_popup').css("display","none"); //$.magnificPopup.close(); } } else { $('#errortext_popup').css("display","none"); //$.magnificPopup.close(); } $("#invoice_id").val(data.invoice_id); $("#uploaded_invoice").html(data.filename); $("#uploaded_invoice").attr("href", "get_invoice?invoice_id="+data.invoice_id); //console.log(data.filename); //console.log($("#uploaded_invoice").html()); $("#fileToUpload").val(""); $("#fileToUpload").off("change").on("change", function() { if ($(this).val() !="") { $('#buttonUpload').trigger("click"); } }); } } ) return false; } function MyAjaxLogisticInvoiceFileUpload() { //starting setting some animation when the ajax starts and completes $("#loading").show(); /* prepareing ajax file upload url: the url of script file handling the uploaded files fileElementId: the file type of input element id and it will be the index of $_FILES Array() dataType: it support json, xml secureuri:use secure protocol success: call back function when the ajax complete error: callback function when the ajax failed */ var addfields=""; if ($("#invoice_type").val() == '1' || $("#invoice_type").val() == '2') { addfields='&container_id='+$("#container_id").val(); } else if ($("#invoice_type").val() == '3') { addfields='&office_id='+$("#office_id").val()+'&office_type='+$("#office_type").val(); } $.ajaxFileUpload ( { url:'ajax_fileuploadlogisticinvoice?invoice_type='+$("#invoice_type").val()+'&invoice_id='+$("#invoice_id").val()+addfields, secureuri:false, fileElementId:'fileToUpload', dataType: 'json', success: function (data, status) { $("#loading").hide(); if((typeof(data.error) != 'undefined')) { $('#errortext_popup').html(data.error); if(data.error != '') { $('#errortext_popup').css("display","block"); }else { $('#errortext_popup').css("display","none"); //$.magnificPopup.close(); } } else { $('#errortext_popup').css("display","none"); //$.magnificPopup.close(); } $("#invoice_id").val(data.invoice_id); $("#uploaded_invoice").html(data.filename); $("#uploaded_invoice").attr("href", "get_logistic_invoice?invoice_id="+data.invoice_id); //console.log(data.filename); //console.log($("#uploaded_invoice").html()); $("#fileToUpload").val(""); $("#fileToUpload").off("change").on("change", function() { if ($(this).val() !="") { $('#buttonUpload').trigger("click"); } }); } } ) return false; } function MyAjaxCOOFileUpload() { //starting setting some animation when the ajax starts and completes $("#loading").show(); /* prepareing ajax file upload url: the url of script file handling the uploaded files fileElementId: the file type of input element id and it will be the index of $_FILES Array() dataType: it support json, xml secureuri:use secure protocol success: call back function when the ajax complete error: callback function when the ajax failed */ $.ajaxFileUpload ( { url:'ajax_fileuploadcoo?delivery_id='+$("#delivery_id").val(), secureuri:false, fileElementId:'fileToUpload', dataType: 'json', success: function (data, status) { $("#loading").hide(); if((typeof(data.error) != 'undefined')) { $('#errortext_popup').html(data.error); if(data.error != '') { $('#errortext_popup').css("display","block"); }else { $('#errortext_popup').css("display","none"); //$.magnificPopup.close(); } } else { $('#errortext_popup').css("display","none"); //$.magnificPopup.close(); } $("#delivery_id").val(data.delivery_id); $("#uploaded_file").html("Certificate of Origin"); $("#uploaded_file").attr("href", "get_coo?delivery_id="+data.delivery_id); $(".coo").show(); //console.log(data.filename); //console.log($("#uploaded_invoice").html()); $("#fileToUpload").val(""); $("#fileToUpload").off("change").on("change", function() { if ($(this).val() !="") { $('#buttonUpload').trigger("click"); } }); } } ) return false; } function MyAjaxShipDocFileUpload(fileID) { //starting setting some animation when the ajax starts and completes $("#loading").show(); /* prepareing ajax file upload url: the url of script file handling the uploaded files fileElementId: the file type of input element id and it will be the index of $_FILES Array() dataType: it support json, xml secureuri:use secure protocol success: call back function when the ajax complete error: callback function when the ajax failed */ $.ajaxFileUpload ( { url:'ajax_fileuploadshipment?delivery_id='+$("#delivery_id").val()+"&file="+fileID, secureuri:false, fileElementId:fileID, dataType: 'json', success: function (data, status) { $("#loading").hide(); if((typeof(data.error) != 'undefined')) { $('#errortext_popup').html(data.error); if(data.error != '') { $('#errortext_popup').css("display","block"); }else { $('#errortext_popup').css("display","none"); var p = $("."+fileID).parent(); p.html('Download'); } } else { $('#errortext_popup').css("display","none"); var p = $("."+fileID).parent(); p.html('Download'); } $("#"+fileID).val(""); $(".fileToUpload").on("click", function() { $("#errortext_popup").hide(); }); $(".fileToUpload").off("change").on("change", function() { if ($(this).val() !="") { var t=$(this); MyAjaxShipDocFileUpload(t.attr("id")); } }); } } ) return false; } function MyAjaxPDIrecordFileUpload(type) { //starting setting some animation when the ajax starts and completes $("#loading").show(); /* prepareing ajax file upload url: the url of script file handling the uploaded files fileElementId: the file type of input element id and it will be the index of $_FILES Array() dataType: it support json, xml secureuri:use secure protocol success: call back function when the ajax complete error: callback function when the ajax failed */ $.ajaxFileUpload ( { url:'ajax_fileuploadpdirecord?type='+type+'&stock_id='+$("#stock_id").val(), secureuri:false, fileElementId:'fileToUpload_'+type, dataType: 'json', success: function (data, status) { $("#loading").hide(); var error = 1; if((typeof(data.error) != 'undefined')) { $('#errortext_popup_'+type).html(data.error); if(data.error != '') { $('#errortext_popup_'+type).css("display","block"); }else { $('#errortext_popup_'+type).css("display","none"); //$.magnificPopup.close(); error = 0; } } else { $('errortext_popup_').css("display","none"); //$.magnificPopup.close(); } if (error == 0) { $("#uploaded_file_"+type).attr("href", "get_pdirecord?type="+type+"&stock_id="+$("#stock_id").val()); $("#date_"+type).html(data.dt); $("#name_"+type).html(data.filename); $("#filename_"+type).html(data.filename); $("."+type).show(); } //$("#uploaded_file_"+type).html("Certificate of Origin"); //console.log(data.filename); //console.log($("#uploaded_invoice").html()); if (type === 'pdirecord' && error == 0) { if ($("[data-stock_id='"+$("#stock_id").val()+"']").attr("data-dontmodify") != "1") { $("[data-stock_id='"+$("#stock_id").val()+"']").html("R").removeClass("red"); } } $("#fileToUpload_"+type).val(""); $("#fileToUpload_"+type).off("change").on("change", function() { if ($(this).val() !="") { $('#buttonUpload_'+type).trigger("click"); } }); } } ) return false; }