if (typeof console == 'undefined'){ window.console = { log:function(){}, info:function(){}, error:function(){}, warn:function(){} } } function cancelUpload(file){ $('#file_upload').uploadify('cancel', file.id) $.ajax({ url: "https://naswietlarnia.acad.pl/ftp/cancelUpload", type: "POST", data: {session_id: 'c5avblbv980u4fke04sato7564'}, success: function(response){ console.log(response, 'ftp/cancelUpload'); }, error: function (){} }) } function finishUpload(file){ $.ajax({ url: "https://naswietlarnia.acad.pl/ftp/finishUpload", type: "POST", data: {session_id: 'c5avblbv980u4fke04sato7564'}, success: function(response){ console.log(response, 'ftp/finishUpload'); }, error: function (){} }) } function unsetCurrentlyEditedOrder(){ $.ajax({ url: 'https://naswietlarnia.acad.pl/main_order/unsetCurrentlyEditedOrder', dataType: 'json', async: false, success: function(response){ console.log(response, 'success'); }, error: function(){ console.log('error'); } }) } function beforeUnload(){ console.log(window.location.href); console.log(window.current_location); // alert('stop'); // var c = new String(window.current_location); // var n = new String(window.location); // if(c != n){ // alert('onbeforeunload: ' + window.current_location); // } // if(window.location != window.current_location){ // alert('onbeforeunload: ' + window.current_location); // } alert('onbeforeunload: ' + window.current_location); } function onLoad(){ window.current_location = window.location; alert('onLoad: ' + window.current_location); } window.__div_backup = new Array() function ajax(url_sufix, data, div) { url = url_sufix; //url = '/'+url_sufix; //window.location.hash = data; console.log(div); if (typeof(div) != 'object' || !(div instanceof Array) && div != '') { div = new Array(div); } if (div != ''){ for(i = 0; i < div.length; i++) { marg_l = ($(div[i]).width() - 32) / 2; marg_t = ($(div[i]).height() - 32) / 2; window.__div_backup[i] = new Array(div[i], $(div[i]).html()); $(div[i]).html("Ładowanie danych..."); } } window.__url = url; window.__data = data; window.__div = div; document.body.style.cursor = 'wait'; $.ajax( { type: "POST", url: url, data: data, async: true, dataType: "json", global: false, success: function(values) { // console.log(values, 'values'); if (!values[0]['div']) values[0]['div'] = window.__div; openMessages(values); // $( ".home_item a, input[type='submit']" ).button(); document.body.style.cursor = 'default'; }, error: function() { console.log('error'); restoreDivs(); document.body.style.cursor = 'default'; } }); return false; } function openMessages(values) { if(values) { $.each(values, function(key, value) { if (value['message'] == 'go_to_location') { window.location = value['location']; } else if (value['message'] == 'restore_divs') { restoreDivs(); } else // =html { value['div'] = value['div'] + ''; $(value['div']).html(value['html']); //$(value['div']).css("opacity", 1.0); } }); } return true; } function restoreDivs() { $.each(window.__div_backup, function(key, value) {$(value[0]).html(value[1])}); window.__div_backup = new Array(); } $(document).ready(function() { }); function checkAttachedFiles(){ var attached = $('.ftp_file_list').find('.ids:checked').length; if(!attached){ setLoadingShadow('check_attacher_files_50', 50); window.check_attached_files_dialog = new Dialog( 'check_attached_files_dialog', { title: 'Informacja o dołaczeniu plików do druku', width: 450, close: 'check_attached_files_dialog', on_close: 'clearLoadingShadow("check_attacher_files_50");', close_button: false, } ); ajax("https://naswietlarnia.acad.pl/ftp/checkAttachedFiles", null, '#check_attached_files_dialog_content'); }else{ window.ftp_dialog.options.no_close_aftre_on_onclose = false; window.ftp_dialog.options.on_close = ''; window.ftp_dialog.close(); clearLoadingShadow('check_attacher_files_50'); } } function openHelp(url, _title){ if(!window.help_dialog || !$('#help_dialog_content').length){ var help_info = ' info'; window.help_dialog = new Dialog('help_dialog', { title: _title + ' ' + help_info, resizable: true, width: 400, to_right: true, margin: 10, close: 'help_dialog', background: false }); } ajax(url, null, '#help_dialog_content'); return false; } function call(phone_nr, internal){ console.log(phone_nr, 'phone_nr'); if (phone_nr == '' ){ alert("Wprowadź numer telefonu"); return false; } phone_nr = onlyDigit(phone_nr); // if (phone_nr == '' || (phone_nr.length != 9 && phone_nr.length != 10)){ if (phone_nr == '' || (phone_nr.length < 9 )){ alert("Wprowadź numer telefonu"); return false; } var url = 'https://naswietlarnia.acad.pl/telephone/call/phone_nr/' + phone_nr ; if(internal != undefined){ url += '/internal/'+internal; } window.call_dialog = new Dialog('call_dialog', {title: 'Połączenie telefoniczne', width: 550, close: 'call_dialog'}); ajax(url, null, '#call_dialog_content'); return false; } function saveAll(ob, url, content_id, collback, lock){ if (content_id == undefined || content_id == '' ){ content_id = 'dialog_loading_id'; } if (collback == undefined || collback == '' ){ collback = 'console.log("collback")'; } if (lock == undefined || lock == '' ){ lock = '1'; } setLoadingShadow() // $('#dialog_loading_id').html('Ładowanie danych...'); var post = ''; $(ob).parent().parent().find('input[type="text"], input[type="hidden"], select').each(function(index) { post += $(this).attr('name') + '=' + $(this).val() + '&'; }); $.ajax({ url: url, dataType: "json", cache: false, data: post + 'lock=' + lock, type: 'POST', error: function(jqXHR, textStatus, errorThrown) { console.log(jqXHR); console.log(textStatus); console.log(errorThrown); clearLoadingShadow(); }, complete: function(response){ clearLoadingShadow(); }, success: function(response) { var json = eval(response) lockError(json); $('#' + content_id).html(''); clearLoadingShadow(); // collback(); } }); return false; } function sendFinishInfo(id){ setLoadingShadow(); $('#main_order_form_id').ajaxForm( { success: function(responseText, statusText, xhr, form){ if (statusText == 'success'){ $.ajax({ type: "POST", url: 'https://naswietlarnia.acad.pl/main_order/sendFinishOrderInformation', data: 'id=' + id, dataType: "json", success: function(values){ var json = eval(values); if (json.status == true){ alert('Powiadomienie zostało wysłane do klienta'); } if (json.status == false){ alert('Wystąpił błąd. Powiadomienie nie zostało wysłane do klienta'); } clearLoadingShadow(); }, error: function(){ console.log('error'); clearLoadingShadow(); } }); } clearLoadingShadow(); } } ); $('#main_order_form_id').submit(); $('#main_order_form_id').unbind('submit').find('input:submit:not(.print_button),input:image:not(.print_button),button:submit:not(.print_button)').unbind('click'); return false; } function setCorrect(obj){ var arr = obj.attr('id').split('_'); var correct = ''; var parent = obj.parent().parent().attr('id'); if (obj.attr('checked')){ //ustaw correct = arr[1]; if (obj.attr('class') == 'status_cancel'){ $('#' + parent + ' .status_finished').attr('checked', false); } if (obj.attr('class') == 'status_finished'){ $('#' + parent + ' .status_cancel').attr('checked', false); } }else{ //zdejmij correct = '0'; } setLoadingShadow(); $.ajax({ url: "https://naswietlarnia.acad.pl/main_order/remoteSave/id/" + arr[0], data: obj.attr('name') + '=' + correct, dataType: 'json', type: 'POST', success: function(response){ var json = eval(response) lockError(json); clearLoadingShadow(); if (correct == '1'){ $('#' + arr[0] + '_2' ).attr('checked', false); } if (correct == '2'){ $('#' + arr[0] + '_1' ).attr('checked', false); } }, error: function(response){ clearLoadingShadow(); } }); } function sendCheckboxValue(obj, reload){ if (reload == undefined){ reload = false; } var arr = obj.attr('id').split('_'); var value = ''; var parent = obj.parent().parent().attr('id'); if (obj.attr('checked')){ //ustaw value = obj.val(); // value = arr[1]; }else{ //zdejmij value = '0'; } setLoadingShadow(); $.ajax({ url: "https://naswietlarnia.acad.pl/main_order/remoteSave/id/" + arr[0], data: obj.attr('name') + '=' + value, dataType: 'json', type: 'POST', success: function(response){ var json = eval(response) lockError(json); if (reload){ location.reload(true); } clearLoadingShadow(); }, error: function(response){ clearLoadingShadow(); } }); } function unlockOrder(order_id, type){ $.ajax({ url: "https://naswietlarnia.acad.pl/main_order/unlockOrder", data: 'id=' + order_id + '&user_id=&order_type=' + type, dataType: 'json', success: function(response){ history.back(); } }); } function automatic(){ $.ajax({ url: "https://naswietlarnia.acad.pl/default/automatic", data: 'data=null', dataType: 'json', success: function(response){ console.log(response,'response'); if(response.show_alert == '1'){ infoWindow("Informacje", response.alert_content, ""); } } }); } function autoSession(){ $.ajax({ url: "https://naswietlarnia.acad.pl/default/autoSession", data: 'data=null', dataType: 'json', success: function(response){ console.log(response,'response'); if(response.show_alert == '1'){ infoWindow("Informacje", response.alert_content, ""); } } }); } //Załadowanie listy adreesów do wysyłi dla konkretnej firmy w zleceniu głównym (mała lista) function LoadSimpleShipmentList(acad_firma_id){ $('#shipment_adresses_list').html("Ładowanie danych..."); $('#shipment_adresses_list').load('https://naswietlarnia.acad.pl/shipment/shipmentAddressesList/simple/1/action_from/main_order/acad_firma_id/' + acad_firma_id ); } // Oznaczenie klasą wybranego adresu dla zlecenia function setCurrentAddressClass(id){ if($('#shipment_adresses_list .order_list_of_addresses').length){ $("#shipment_adresses_list .order_list_of_addresses tr").removeClass('current_order_address'); $("#shipment_adresses_list .order_list_of_addresses #item_id_" + id).addClass('current_order_address'); } } /* wstawienie danyc z dodatkowych adresów dostawy wybieranych z selecta, listy itp */ function setShipmentAdresInfo(shipment_id, parent_id, form_name){ console.log('setShipmentAdresInfo'); if (parent_id == undefined){ parent_id = ' '; }else{ parent_id = parent_id + ' '; } if (form_name === undefined){ form_name = 'provider'; if($('#provider_form_id').length){ form_name = 'provider'; } if($('#realize_order_box_id').length){ form_name = 'query'; } if($('#generate_order_box_id').length){ form_name = 'query'; } } if(!$('#shipment_load_box_id').length){ return false; } $.ajax({ type: "POST", url: 'https://naswietlarnia.acad.pl/shipment/getById/id/' + shipment_id, dataType: 'json', success: function(response){ if(response.status == 'EMPTY' || response.data == null){ clearShipmentInfo(parent_id); return; } var data = response.data; var post = new Object(); post.data = data; // data.shipment_company_name = $(parent_id + '#company_name').val().replace(/"/g, '"'); $('#shipment_load_box_id').load('https://naswietlarnia.acad.pl/shipment/setShipmentInfo/form_name/' + form_name, post, function(){ checkShipmentInfoCorrect(parent_id); //setTextShipmentInfo('#current_shipment_load_box_id'); }); // if ($(parent_id + '#shipment_company_name').length ){ // $(parent_id + '#shipment_company_name').val(data.shipment_company_name.replace(/"/g, '"')); // } // if ($(parent_id + '#shipment_address').length ){ // $(parent_id + '#shipment_address').val(data.shipment_address); // } // if ($(parent_id + '#shipment_zip_code').length ){ // $(parent_id + '#shipment_zip_code').val(data.shipment_zip_code); // } // if ($(parent_id + '#shipment_city').length ){ // $(parent_id + '#shipment_city').val(data.shipment_city); // } // //// if ($(parent_id + '#km').length ){ //// $(parent_id + '#km').val(data.km); //// } // //// if ($(parent_id + '#delivery_price').length ){ //// $(parent_id + '#delivery_price').val(data.delivery_price); //// } //// //// if ($(parent_id + '#courier_price').length ){ //// $(parent_id + '#courier_price').val(data.courier_price); //// } // // if ($(parent_id + ' #shipment_first_name').length ){ // $(parent_id + ' #shipment_first_name').val(data.shipment_first_name); // } // if ($(parent_id + ' #shipment_last_name').length ){ // $(parent_id + ' #shipment_last_name').val(data.shipment_last_name); // } // if ($(parent_id + ' #shipment_phone').length ){ // $(parent_id + ' #shipment_phone').val(data.shipment_phone); // } // if ($(parent_id + ' #shipment_phone_internal').length ){ // $(parent_id + ' #shipment_phone_internal').val(data.shipment_phone_internal); // } // if ($(parent_id + ' #shipment_mobile').length ){ // $(parent_id + ' #shipment_mobile').val(data.shipment_mobile); // } // if ($(parent_id + ' #shipment_email').length ){ // $(parent_id + ' #shipment_email').val(data.shipment_email); // } //// if ($(parent_id + ' #shipment_work_time').length ){ //// $(parent_id + ' #shipment_work_time').val(data.shipment_work_time); //// } // if ($(parent_id + ' #shipment_info').length ){ // $(parent_id + ' #shipment_info').val(data.shipment_info); // } // // if ($(parent_id + '#shipment_addresses_id').length ){ // $(parent_id + '#shipment_addresses_id').val(data.id); // } // checkShipmentInfoCorrect(parent_id); return; } }) } function checkShipmentInfoCorrect(parent_id){ console.log('checkShipmentInfoCorrect'); if (parent_id == undefined){ parent_id = ' '; }else{ parent_id = parent_id + ' '; } var log = true; if ($(parent_id + '#shipment_company_name').length && $(parent_id + '#shipment_company_name').val() == ''){ log = false; $(parent_id + '#shipment_company_name').css('border', '2px solid red'); }else{ $(parent_id + '#shipment_company_name').css('border', '1px solid red'); } if ($(parent_id + '#shipment_address').length && $(parent_id + '#shipment_address').val() == ''){ log = false; $(parent_id + '#shipment_address').css('border', '2px solid red'); }else{ $(parent_id + '#shipment_address').css('border', '1px solid red'); } if ($(parent_id + '#shipment_zip_code').length && $(parent_id + '#shipment_zip_code').val() == ''){ log = false; $(parent_id + '#shipment_zip_code').css('border', '2px solid red'); }else{ $(parent_id + '#shipment_zip_code').css('border', '1px solid red'); } if ($(parent_id + '#shipment_city').length && $(parent_id + '#shipment_city').val() == ''){ log = false; $(parent_id + '#shipment_city').css('border', '2px solid red'); }else{ $(parent_id + '#shipment_city').css('border', '1px solid red'); } var html = ''; if(log){ html = '
Dane dostawy są kompletne
' }else{ html = '
Dane dostawy są nie kompletne
' } $(parent_id + '#shipment_information').html(html); } function setOrderStatus(obj, url, no_confirm){ if(no_confirm == undefined || no_confirm == ''){ no_confirm = false; } var arr = obj.attr('id').split('_'); var status = ''; var parent = obj.parent().parent().attr('id'); if (obj.attr('checked')){ $('#' + parent + ' .status_finished').attr('checked', false); $('#' + parent + ' .status_cancel').attr('checked', false); $('#' + parent + ' .status_realization').attr('checked', false); //ustaw status = arr[1]; // if (obj.hasClass('status_cancel')){ // console.log('1'); // }else{ // console.log('2'); // } // console.log(obj.attr('class'), 'class'); // console.log(no_confirm, 'no_confirm'); // console.log(parent, 'parent'); if (obj.hasClass('status_cancel')){ if (no_confirm == false && !confirm('Czy jesteś pewien, że chcesz anulować to zamówienie ?')){ obj.attr('checked', false); return; } $('#' + parent + ' .status_cancel').attr('checked', true); } if (obj.hasClass('status_finished')){ $('#' + parent + ' .status_finished').attr('checked', true); } if (obj.hasClass('status_realization')){ $('#' + parent + ' .status_realization').attr('checked', true); } }else{ //zdejmij status = arr[2]; } setLoadingShadow(); $.ajax({ url: url + "/id/" + arr[0], data: obj.attr('name') + '=' + status, dataType: 'json', type: 'POST', success: function(response){ var json = eval(response) lockError(json); loadOrdersInfo(); window.intervalID = window.setInterval("loadOrdersInfo();", 300000); clearLoadingShadow(); } }); } function loadOrders(acad_firma_id, container_id){ console.log('js loadOrders'); $.ajax({ type: "POST", url: 'https://naswietlarnia.acad.pl/main_order/list/container/'+ container_id + '?search[acad_firma_id]=' + acad_firma_id , data: '', async: true, dataType: "json", global: false, success: function(response){ var json = eval(response); $('#' + container_id).html(json[0].html); $('#loading_box').html(''); clearLoadingShadow(); }, error: function() { console.log('error'); document.body.style.cursor = 'default'; clearLoadingShadow(); } }) } function loadNoPayInvoice(id, container_id){ console.log('js loadNoPayInvoice'); $.ajax({ type: "POST", url: 'https://naswietlarnia.acad.pl/invoice/noPay/container/'+ container_id + '/id/' + id + '/no_layout/1', data: '', async: true, dataType: "json", global: false, success: function(response){ var el_class = ''; if (response.count.out_of_term > 0){ el_class = 'errors'; } $('#' + container_id).html('Wyświetl faktury dla zapłaty (' + response.count.no_pay + ', ' + response.count.out_of_term + ')'); // ('#' + container_id).html(json[0].html); $('#loading_box').html(''); clearLoadingShadow(); }, error: function() { console.log('error'); document.body.style.cursor = 'default'; clearLoadingShadow(); } }) } function loadRepresentative(id, selected_id){ console.log('loadRepresentative'); if (id == 0 || id == '' || id == null){ console.log('return'); // return false; } setLoadingShadow(); if (selected_id == undefined || selected_id == ''){ selected_id = ''; } if ($('#note_acad_only').length ){ $('#note_acad_only').html(''); $('#show_info').css('font-weight', 'normal'); } if ($('#blocked_info').length){ $('#blocked_info').html(''); } if ($('#no_pay_invoice').length){ $('#no_pay_invoice').html(''); } if ($('#provider_states').length){ $('#provider_states').html(''); } // return; $.ajax({ type: "POST", url: 'https://naswietlarnia.acad.pl/provider/getProvider/states/1/id/' + id, data: '', dataType: "json", global: false, success: function(data){ if (data == null){ return; } //zazncczenie sposobu dostawy ustawionego w rekordzie dostawcy if ($('#method_of_delivery').length && selected_id == ''){ $('#method_of_delivery').val(data.sposob_dostawy); } //zazncczenie sposobu dostawy ustawionego w rekordzie dostawcy if ($('#provider_method_of_delivery').length && selected_id == ''){ $('#provider_method_of_delivery').val(data.provider_method_of_delivery); } //zazncczenie sposobu dostawy ustawionego w rekordzie dostawcy if ($('#payment_time').length && selected_id == ''){ $('#payment_time').val((data.termin_platnosci)?data.termin_platnosci:'0'); } //zazncczenie sposobu dostawy ustawionego w rekordzie dostawcy if ($('#provider_payment_time').length && selected_id == ''){ $('#provider_payment_time').val(data.provider_payment_time); } if ($('#report').length && selected_id == ''){ $('#report').val(data.report); } //informacje o wysyłce jakie kanały if (selected_id == ''){ $('#finish_order_email').val(data.finish_order_email) $('#finish_order_email_enable').val(data.finish_order_email_enable) // if(data.finish_order_email_enable == '1'){ // $('#finish_order_email_enable').attr('checked', true); // }else{ // $('#finish_order_email_enable').attr('checked', false); // } $('#finish_order_mobile').val(data.finish_order_mobile) if(data.finish_order_mobile_enable == '1'){ $('#finish_order_mobile_enable').attr('checked', true); }else{ $('#finish_order_mobile_enable').attr('checked', false); } } }, error: function() { console.log('error'); } }) } function getRepesentative(id, select, representative_data_id){ console.log('getRepesentative'); setLoadingShadow(); if (representative_data_id == '' || representative_data_id == undefined){ representative_data_id = 'representative_data'; } $.ajax({ type: "POST", url: 'https://naswietlarnia.acad.pl/representative/getRepresentative/id/' + id, data: '', async: true, dataType: "json", global: false, success: function(data) { // console.log(data); if (data == null){ $('#representative_data').html(''); if ($('#representative_td_id').length ){ $('#representative_id').html(''); }else{ $('#representative_id').val(''); } $('#representative_name').val(''); if ($('#representative_null_info').length){ $('#representative_null_info').html('Wybrana firma nie ma zdefiniowanych przedstawicieli'); } if ($('#representative_form').length){ $('#representative_form').find('input[type="text"], #method_of_delivery').each(function(index) { $(this).val(''); }); } clearLoadingShadow(); return false; } if ($('#representative_null_info').length){ $('#representative_null_info').html(''); } if (select == '1'){ if ($('#representative_td_id').length ){ $('#representative_id').html('') } } $('#representative_id').val(data.id); $('#representative_name').val(data.osoba_imie + ' ' + data.osoba_nazwisko); if ($('#'+representative_data_id).length){ var html = '
'; if(data.email != ''){ html += 'e-mail: ' + data.email + '
'; if ($('#phone_td').length){ $('#phone_td').hide(); $('#phone_td input').attr('disabled', true); } }else{ html += 'e-mail: brak adresu e-mail
'; if ($('#phone_td').length){ $('#phone_td').show(); $('#phone_td input').removeAttr('disabled'); } } if (data.telefon_kom != ''){ html += 'komórka: ' + data.telefon_kom + '
'; } if (data.telefon != ''){ html += 'telefon: ' + data.telefon + ''; } $('#'+representative_data_id).html(html) ; } if ($('#representative_form').length){ var html = ''; if(data.email == ''){ html += 'Nie można wysłać maila. Brak adresu'; if ($('#send_email').length){ $('#send_email').hide(); } if ($('#send_1').length){ $('#send_1').removeAttr('disabled'); } }else{ if ($('#send_email').length){ $('#send_email').show(); } if ($('#send_1').length){ $('#send_1').attr('disabled', true); } html = ''; } if (data.telefon_kom != ''){ console.log('nie ma'); if ($('#send_sms').length){ $('#send_sms').show(); } }else{ console.log('jest'); if ($('#send_sms').length){ $('#send_sms').hide(); } // if ($('#sms_alert').length){ // $('#sms_alert').html('Nie można wysłać maila. Brak adresu'); // } } $('#full_name').val(data.osoba_nazwisko + ' ' +data.osoba_imie) $('#email_alert').html(html); $('#first_name').val(data.osoba_imie) $('#last_name').val(data.osoba_nazwisko) $('#function').val(data.funkcja) $('#phone').val(data.telefon) $('#internal').val(data.telefon_wew) $('#mobile').val(data.telefon_kom) $('#fax').val(data.fax) $('#fax_internal').val(data.fax_wew) $('#email').val(data.email) } clearLoadingShadow(); }, error: function() { console.log('error'); document.body.style.cursor = 'default'; clearLoadingShadow(); } }) } function loadProvider(id, container_id){ console.log('loadProvider'); if (id == 0 || id == '' || id == null){ return false; } setLoadingShadow(); $.ajax({ type: "POST", url: 'https://naswietlarnia.acad.pl/provider/getProvider/id/' + id, data: '', async: true, dataType: "json", global: false, success: function(response){ var data = eval(response); var html = ''; var html_e = ''; if (data.min_order_no_pay){ html_e += 'Adres email: ' + data.provider_email + '
'; if ($('#phone_td').length){ $('#phone_td').hide(); $('#phone_td input').attr('disabled', true); } }else{ // html_e += 'brak adresu e-mail
'; html_e += 'Adres email:
'; if ($('#phone_td').length){ $('#phone_td').show(); $('#phone_td input').removeAttr('disabled'); } } // if (data.min_order_no_pay){ html += 'Minimalne zamówinie bez opłaty za dowóz: ' + data.min_order_no_pay + '
'; // } // if (data.min_order_no_pay){ html += 'Opłata za dowóz przy zamówieniu poniżej minimum: ' + data.fee_for_transport + '
'; // } // if (data.min_order_no_pay){ html += 'Opłata za pobranie: ' + data.fee_for_cash_on_delivery + '
'; // } // if (data.min_order_no_pay){ html += 'Godziny pracy: ' + data.working_hours + '
'; // } // if (data.min_order_no_pay){ html += 'Standardowy czas dostawy: ' + data.delivery_time + '
'; // } if (html == ''){ html += 'brak danych o dostawie'; } $('#' + container_id).html(html_e + html); $('#nazwa_do_faktury').val(data.nazwa_do_faktury) $('#nip').val(data.nip) $('#regon').val(data.regon) $('#adres').val(data.adres) $('#kod_pocztowy').val(data.kod_pocztowy) $('#miasto').val(data.miasto) $('#payment_time').val((data.termin_platnosci)?data.termin_platnosci:'0') //recount_payment_box podczas tworzenia faktury if ($('#recount_payment_box').length && $('#brutto').length){ recountPayment(id, $('#brutto').val()); } clearLoadingShadow(); }, error: function() { console.log('error'); document.body.style.cursor = 'default'; clearLoadingShadow(); } }) } function loadProviderAndRepesentatives(id, container_id, select_name){ console.log('loadProviderAndRepesentatives'); if (id == 0 || id == '' || id == null){ return false; } setLoadingShadow(); if (select_name == undefined || select_name == ''){ var index = new Date().getTime(); select_name = 'query[representatives][' + index + '][id]'; } $.ajax({ type: "POST", url: 'https://naswietlarnia.acad.pl/provider/getAllRepresentatives2/id/' + id, data: '', async: true, dataType: "json", global: false, success: function(response){ var json = eval(response); $('#' + container_id).append(json[0].html); $('#' + container_id + ' tbody:last-child select').attr('name', select_name); $('#' + container_id + ' tbody:last-child').attr('id', 'id_' + index); $('#loading_box').html(''); getRepesentative($('#id_' + index + ' select').val(), '', 'id_' + index + ' .representative_data'); clearLoadingShadow(); }, error: function() { console.log('error'); document.body.style.cursor = 'default'; clearLoadingShadow(); } }) } function searchAndLoad(to_id, search_id, url, only_provider){ console.log('searchAndLoad'); if (to_id == undefined || to_id == ''){ to_id = 'provider_select'; } if (search_id == undefined || search_id == ''){ search_id = 'privider_search_key'; } if (url == undefined || url == ''){ url = 'https://naswietlarnia.acad.pl/provider/load'; } if (only_provider == undefined || only_provider == ''){ only_provider = false; } var key = $('#' + search_id).val(); // var key = htmlEncode($('#' + search_id).val(), false, false); console.log(key, 'key'); $.ajax( { type: "POST", url: url , //data: 'key=' + $('#' + search_id).val().replace(/\s/gi, "+"), data: 'key=' + key.replace(/\s/gi, "+"), success: function(response) { var json = eval(response); $('#' + to_id).html(json[0].html); if ($('#privider_search_key').length && only_provider == false){ console.log('1'); loadRepresentative($('#' + to_id).val()); } if ($('#representative_search_key').length && only_provider == false){ console.log('2'); getRepesentative($('#' + to_id).val()); } if ($('#provider_data').length){ console.log('3'); loadProvider($('#' + to_id).val(), 'n_n'); } clearLoadingShadow(); // console.log(response, 'response'); }, error: function() { console.log('error'); document.body.style.cursor = 'default'; clearLoadingShadow(); } }); } function loadOrdersInfo(){ $('#orderInfoBox').html('Ładowanie danych...'); $.ajax({ type: "POST", url: 'https://naswietlarnia.acad.pl/main_order/loadOrderInfo', data: '', success: function(values){ var html = eval(values); $('#orderInfoBox').html(html[0]['html']); clearInterval(window.intervalID); window.intervalID = window.setInterval("loadOrdersInfo();", 300000); }, error: function(){ console.log('error'); } }); } function interfaceEdit(obj){ window.edit_interface_dialog = new Dialog("edit_interface_dialog", { title: "Edycja wpisu", width: 450, close: "edit_interface_dialog"}); ajax('https://naswietlarnia.acad.pl/interface/editSingle/key/' + $(obj).attr('id'), null, '#edit_interface_dialog_content'); return false; } function loadDeliveryInfo(type_view){ $('#deliveryInfoBox').html('Ładowanie danych...'); $.ajax({ type: "POST", url: 'https://naswietlarnia.acad.pl/main_order/loadDeliveryInfo/type_view/' + type_view, data: '', // dataType: "json", success: function(values){ var html = eval(values); $('#deliveryInfoBox').html(html[0]['html']); clearInterval(window.intervalID_D); window.intervalID_D = window.setInterval("loadDeliveryInfo();", 300000); }, error: function(){ console.log('error'); } }); } function loadMainOrderMenu(main_order_id, type){ if (type == '' || type == undefined){ type = 'small'; } $('#all_orders_list').html('
Ładowanie danych
'); $('#all_orders_list').load('https://naswietlarnia.acad.pl/main_order/loadMenuList/type/' + type + '/main/' + main_order_id, function(response, status, xhr){ json = eval(response); $('#all_orders_list').html(json[0]['html']); }); } function openOtherWithoutPrice(){ window.new_other_without_price = new Dialog("new_other_without_price", { title: "Informacja", width: 660, close: 'new_other_without_price'}); ajax("https://naswietlarnia.acad.pl/order_other/noPriceInformation/type/1", null, "#new_other_without_price_content"); return false; } function openOtherOrder(){ window.new_other_without_price_2 = new Dialog('new_other_without_price_2', { title: "Informacja", width: 660, close: 'new_other_without_price_2'}); ajax("https://naswietlarnia.acad.pl/order_other/noPriceInformation/type/0", null, '#new_other_without_price_2_content'); return false; } jQuery(function($){ $.datepicker.regional['pl'] = {clearText: 'Wyczyść', clearStatus: '', closeText: 'Zamknij', closeStatus: 'Zamknięcie bez zapisu', prevText: '', nextStatus: 'Następny miesiąc', currentText: 'Dziś', currentStatus: 'Pokarz aktualny mieśiąc', monthNames: ['Styczeń','Luty','Marzec','Kwiecień','Maj','Czerwiec','Lipiec','Sierpień','Wrzesień','Pażdziernik','Listopad','Grudzień'], monthNamesShort: ['Sty','Lut','Marz','Kwi','Maj','Cze','Lip','Sie','Wrz','Paż','Lis','Gru'], monthStatus: 'Show a different month', yearStatus: 'Show a different year', weekHeader: 'Ty', weekStatus: '', dayNames: ['Niedziela','Poniedziłek','Wtorek','Środa','Czwartek','Piątek','Sobota'], dayNamesShort: ['Nie','Pon','Wto','Śro','Czw','Pi','Sob'], dayNamesMin: ['Ni','Po','Wt','Śr','Cz','Pi','So'], dayStatus: 'et DD as first week day', dateStatus: 'Select D, M d', dateFormat: 'dd/mm/yy', firstDay: 0, initStatus: 'Wybierz datę', isRTL: false}; $.datepicker.setDefaults($.datepicker.regional['pl']); }); function jsValidatorNormalText(){ $('.validator_normal_text').live('keypress', function(event){ return only(event, this, /^[żźćńąśłęóŻŹĆŃĄŚŁĘÓ\/a-zA-Z0-9\s-,\.]$/, "Możesz używać normalnych znaków od a do z, cyfr oraz polskich znaków dialektycznych.",""); }) } function jsValidatorOnlyDigits(){ $('.validator_only_digits').live('keypress', function(event){ return only(event, this, /^[0-9]$/, "Możesz używać tylko cyfr.",""); }) }