/* ********************************************************************************************************************* * B I B L I O T E K A W S P Ó L N A * * VER 3.0.1 - 01/08/2021 * * * * Sierpień 2021 VER 3.0 Rozdzielne sesje * * (C) 2021 AKK Time for Chopin * ************************************************************************************************************************/ //-----------------------------Rozsterowanie menu głównego z wywołaniem stron ----------------------- function menu_TFC_Koncerty (e, str, menu_item) { if (str != 0) {if (!zapisano_rec()) { return;}} retriveSession("./index.php"); switch (menu_item) { case 'rez-nrez': case 'rez-disp': location = "TFC_Koncerty_REZ.php?" + menu_item + "&SID="+encodeURIComponent(ses_sid); break; case 'knc-nknc': case 'knc-mddl': case 'knc-disp': case 'knc-live': location = "TFC_Koncerty_KNC.php?" + menu_item + "&SID="+encodeURIComponent(ses_sid); break; case 'rdn-prck': case 'rdn-morp': case 'rdn-wyrp': case 'rdn-kfrd': case 'rdn-rgot': location = "TFC_Koncerty_RDN.php?" + menu_item + "&SID="+encodeURIComponent(ses_sid); break; case 'fvk-rfvk': case 'fvk-wyfk': location = "TFC_Koncerty_RFV.php?" + menu_item + "&SID="+encodeURIComponent(ses_sid); break; } } function menu_TFC_Finanse (e, str, menu_item) { if (str != 0) {if (!zapisano_rec()) { return;}} retriveSession("./index.php"); switch (menu_item) { case 'wyn-przy': case 'wyn-kosz': case 'wyn-pmng': location = "TFC_Finanse_WYN.php?" + menu_item + "&SID="+encodeURIComponent(ses_sid); break; case 'rap-opod': case 'rap-rgot': case 'rap-fkos': case 'rap-fprz': case 'rap-plac': location = "TFC_Finanse_RAP.php?" + menu_item + "&SID="+encodeURIComponent(ses_sid); break; case 'kal-konc': case 'kal-ceny': location = "TFC_Finanse_KAL.php?" + menu_item + "&SID="+encodeURIComponent(ses_sid); break; case 'prs-prac': case 'prs-list': location = "TFC_Finanse_PRC.php?" + menu_item + "&SID="+encodeURIComponent(ses_sid); break; case 'pla-rokr': case 'pla-staw': case 'pla-list': case 'pla-hote': location = "TFC_Finanse_ROK.php?" + menu_item + "&SID="+encodeURIComponent(ses_sid); break; case 'fvp-wyfv': case 'fvp-mofv': case 'fvp-list': case 'fvp-kont': case 'fvp-koli': location = "TFC_Finanse_FWY.php?" + menu_item + "&SID="+encodeURIComponent(ses_sid); break; } } /* ----------------------------------- CHANGE PSSWD --------------------------------------------------*/ function changePwd(args) { console.log(args); var psenc = encodeURIComponent(ses_sid); let prog = "login/change-pwd.php?"+"SID="+psenc+"&"+args; location.replace(prog); } /* -------------------------------------- LOG OUT ----------------------------------------------------*/ function logOut(args) { var psenc = encodeURIComponent(ses_sid); let prog = "login/logout.php?"+"SID="+psenc+"&"+args; // console.log(prog); location.replace(prog); } /* ----------------------------------- SESSION RETRIVE -----------------------------------------------*/ function retriveSession(indx) { zadanie = {"ster":777, "SID":ses_sid}; zadanie_s = JSON.stringify(zadanie); // console.log(zadanie_s); xmlhttp = new XMLHttpRequest(); xmlhttp.onreadystatechange = function() { if (this.readyState == 4 && this.status == 200) { // console.log(this.responseText); var resp = JSON.parse(this.responseText); if (resp.SID == "407") { // Sesja nie istnieje - zaloguj ponownie location.replace(indx); } } //this.readyState }; //onreadystatechange xmlhttp.open("POST", "TFC_Konc_PST.php", false); //Wystrzel zapytanie do serwera xmlhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded"); xmlhttp.send("x=" + zadanie_s); } /* ------------------------------- FUNKCJE OBSŁUGI COOKIES --------------------------------------------*/ function setCookie(cname,cvalue,exmins) { // SET COOKIE var d = new Date(); d.setTime(d.getTime() + (exmins*60*1000)); var expires = "expires=" + d.toUTCString(); // console.log(cname + "=" + cvalue + ";" + expires + ";path=/"); document.cookie = cname + "=" + cvalue + ";" + expires + ";path=/"; } function getCookie(cname) { // GET COOKIE var name = cname + "="; var decodedCookie = decodeURIComponent(document.cookie); var ca = decodedCookie.split(';'); for(var i = 0; i < ca.length; i++) { var c = ca[i]; while (c.charAt(0) == ' ') { c = c.substring(1); } if (c.indexOf(name) == 0) { // console.log(c.substring(name.length, c.length)); return c.substring(name.length, c.length); } } return ""; } function destroyCookie(cname){ setCookie(cname,"",0); } function checkCookie() { // CHECK COOKIE var user=getCookie("username"); if (user != "") { alert("Welcome again " + user); } else { user = prompt("Please enter your name:",""); if (user != "" && user != null) { setCookie("username", user, 30); } } } /* -------------------------------------- DO PDF -----------------------------------------------------*/ function zapisz_PDF(div_id){ printdiv(div_id); //Tu wywołanie zrzutu do PDF - na razie drukowanie //Do PDF } //-----------------------------------PRINT PAGE-------------------------------------------- //Funkcja drukuje zawartość wybranego kontenera div id=printpage function printdiv(printpage) { printcolor ='#116211;'; printcolor ='#000000;'; var contents = document.getElementById(printpage).innerHTML; var frame1 = document.createElement('iframe'); frame1.name = "frame1"; frame1.style.position = "absolute"; frame1.style.top = "-1000000px"; frame1.style.fontFamily = "11px Helvetica"; frame1.className = "rez_data_title"; hd1 = document.getElementById('fv_poz_hdr'); // hd1.className = "fv_data_hdr"; document.body.appendChild(frame1); var frameDoc = (frame1.contentWindow) ? frame1.contentWindow : (frame1.contentDocument.document) ? frame1.contentDocument.document : frame1.contentDocument; frameDoc.document.open(); //frameDoc.document.write(''); frameDoc.document.write(''); frameDoc.document.write(''); // frameDoc.document.write(''); frameDoc.document.write(''); frameDoc.document.write(''); // frameDoc.style.backgroundColor = "#EAF6ED"; //frameDoc.document.write('') frameDoc.document.write('Time for Chopin'); frameDoc.document.write(''); frameDoc.document.write(contents); frameDoc.document.write(''); frameDoc.document.close(); setTimeout(function () { window.frames["frame1"].focus(); frame1.style.fontFamily = "11px Helvetica"; window.frames["frame1"].print(); document.body.removeChild(frame1); }, 500); return false; } /* ----------------------------------------- Save DIV as pdf file ----------------------------------------------------- */ function saveDivAsPdf (divID, filename) { const element = document.getElementById(divID); let opt = { margin: 0, filename: filename, image: { type: 'jpeg', quality: 0.82 }, html2canvas: { scale: 2 }, jsPDF: { unit: 'cm', format: 'A4', orientation: 'portrait' } }; html2pdf().set(opt).from(element).toPdf().save(); // Plik będzie wyświetlony w czytniku pdf z mozliwością zapisu } //--------------------------------------FORMATTED TABLE---------------------------------------- // Dane: w tabl. tableData. id kontenera: cont_id // {"CONT_ID":tab_id, "SZER":szer_tabeli, "TYT_1":tytul, "TYT_2":""; "TYT_D":tyt_d, "HDR":hdr_names, "FONT_H":wysokość czcionki, // "FONT_C":wektor kolorów czcionki, "FONT_B":wektor kolorów tła headera, "ALIGN":Wektor justacji kolumn, "CLASS_H":klasa headera, // "CLASS_T":klasa tabeli, "PUSTA":false} // Jeśli któraś watość w wektorze jest pusta "" - obowiązuje wartość z danej klasy function formattedTable(tableData, dMode) { if (tableData.length == 0 && !dMode.PUSTA) { return;} n_rows = tableData.length; n_cells = dMode.PUSTA ? dMode.HDR.length : tableData[0].length; var cont_id = dMode.CONT_ID; // Alias div id=cont_id (do cont). var cont = document.getElementById(cont_id); if (dMode.TYT_1 != "") { // Utwórz span w div i wyświetl tytuł 1 $(('#' + cont_id)).append('
'); var t1 = document.getElementById(cont_id + "_ty1"); var dty1 = document.getElementById(cont_id + "_dty1"); dty1.style.marginBottom = '10px'; t1.className = "rez_data_title"; t1.innerHTML = dMode.TYT_1; } if (dMode.TYT_2 != "") { // Utwórz span w div i wyświetl tytuł 2 $(('#' + cont_id)).append('
'); var t2 = document.getElementById(cont_id + "_ty2"); var dty2 = document.getElementById(cont_id + "_dty2"); dty2.style.marginBottom = '10px'; t2.className = "rez_data_title"; t2.innerHTML = dMode.TYT_2; } $(('#' + cont_id)).append('
'); // Utwódz tabelę w div id=cont_id (alias cont). Alias tabeli: xr var xr = document.getElementById(cont_id + "_rdt"); // xr.className = dMode.CLASS_T; // xr.style.fontFamily = "6px Arial"; // zakoment. i do css xr.style.width = dMode.SZER; if (dMode.HDR !== "") { var header = xr.createTHead(); //Header tabeli. Nazwy kolumn w hdr_names[] var drow = header.insertRow(0); drow.id = cont_id + "_hdr"; drow.className = dMode.CLASS_H; // "rez_data_hdr"; var hdr = dMode.HDR; for (i = 0; i < hdr.length; i++) { var dcell = drow.insertCell(i); // ew. dcell.style.textAlign = dMode.ALIGN[i]; if (dMode.ALIGN[i] == 'left') dcell.style.paddingLeft = '10px'; if (dMode.ALIGN[i] == 'right') dcell.style.paddingRight = '10px'; dcell.style.width = dMode.WIDTH[i]; dcell.innerHTML = hdr[i]; } } var tableBody = document.createElement('tbody'); //body tabeli tableBody.className = dMode.CLASS_T; // var tableBody = document.createElement('tbody'); //body tabeli // tableBody.className = "rez_body"; if (dMode.PUSTA) {return;} // rezerw_id.length = 0; lp = 1; tableData.forEach(function(rowData) { //Kreator wierszy tabeli: licznik lp var row = document.createElement('tr'); if (dMode.ROW_H != "") row.style.height = dMode.ROW_H; // row.style.backgroundColor = "white"; row.style.color = (dMode.FONT_C == "") ? 'green' : dMode.FONT_C[lp-1]; lc = 0; rowData.forEach(function(cellData) { //Kreator komórek w wierszu: licznik lc var cell = document.createElement('td'); cell.style.width = dMode.WIDTH[lc]; cell.appendChild(document.createTextNode(cellData)); cell.style.textAlign = dMode.ALIGN[lc]; if (dMode.ALIGN[lc] == 'left') cell.style.paddingLeft = '10px'; if (dMode.ALIGN[lc] == 'right') cell.style.paddingRight = '10px'; row.appendChild(cell); lc += 1; }); tableBody.appendChild(row); //Gotowy wiersz dołącz do body lp += 1; }); xr.appendChild(tableBody); //Kompletne Body dołacz do tabeli cont.appendChild(xr); //Dołącz tabelę do kontenera div if (dMode.TYT_D != "") { // Utwórz span i wyświetl tytuł dolny $(('#' + cont_id)).append('
'); var tyd = document.getElementById(cont_id + "_tyd"); var dyd = document.getElementById(cont_id + "_dyd"); tyd.className = "rez_data_title"; dyd.style.width = dMode.SZER; dyd.style.textAlign = 'right'; dyd.style.marginTop = '10px'; tyd.innerHTML = dMode.TYT_D; } } //--------------------------------------CREATETABLE---------------------------------------- // Dane: w tabl. tableData. id konteneta: cont_id // {"CONT_ID":tab_id, "SZER":szer_tabeli, "TYT_1":tytul, "TYT_2":""; "TYT_D":tyt_d, "HDR":hdr6_names, "PUSTA":false} function createTable(tableData, dMode) { if (tableData.length == 0 && !dMode.PUSTA) { return;} n_rows = tableData.length; n_cells = dMode.PUSTA ? 0 : tableData[0].length; var cont_id = dMode.CONT_ID; // Alias div id=cont_id (do cont). var cont = document.getElementById(cont_id); if (dMode.TYT_1 != "") { // Utwórz span w div i wyświetl tytuł 1 $(('#' + cont_id)).append('
'); var t1 = document.getElementById(cont_id + "_ty1"); var dty1 = document.getElementById(cont_id + "_dty1"); dty1.style.marginBottom = '10px'; t1.className = "rez_data_title"; t1.innerHTML = dMode.TYT_1; } if (dMode.TYT_2 != "") { // Utwórz span w div i wyświetl tytuł 2 $(('#' + cont_id)).append('
'); var t2 = document.getElementById(cont_id + "_ty2"); var dty2 = document.getElementById(cont_id + "_dty2"); dty2.style.marginBottom = '10px'; t2.className = "rez_data_title"; t2.innerHTML = dMode.TYT_2; } $(('#' + cont_id)).append('
'); // Utwódz tabelę w div id=cont_id (alias cont). Alias tabeli: xr var xr = document.getElementById(cont_id + "_rdt"); xr.className = "rez_data"; xr.style.fontFamily = "10px Arial"; // zakoment. i do css xr.style.width = dMode.SZER; var header = xr.createTHead(); //Header tabeli. Nazwy kolumn w hdr_names[] var drow = header.insertRow(0); drow.id = "rez_dt_hdr"; drow.className = "rez_data_hdr"; drow.style.height = "30px"; // do css? drow.style.fontWeight = "bold"; drow.style.padding = "10px"; drow.style.textAlign = 'center'; var hdr = dMode.HDR; for (i = 0; i < hdr.length; i++) { var dcell = drow.insertCell(i); // ew. dcell.style.textAlign = dMode.ALIGN[i]; dcell.innerHTML = hdr[i]; } var tableBody = document.createElement('tbody'); //body tabeli tableBody.className = "rez_body"; if (dMode.PUSTA) {return;} rezerw_id.length = 0; lp = 0; tableData.forEach(function(rowData) { //Kreator wierszy tabeli: licznik lp var row = document.createElement('tr'); row.style.height = "20px"; // row.style.backgroundColor = "white"; lc = 1 var cell = document.createElement('td'); //Wyświetl numer wiersza w 1-szej komórce cell.appendChild(document.createTextNode(lp+1)); cell.style.textAlign = 'right'; cell.style.paddingRight = '10px'; cell.style.width = "30px"; row.appendChild(cell); rowData.forEach(function(cellData) { //Kreator komórek w wierszu: licznik lc var cell = document.createElement('td'); if (lc++ === 1) { rezerw_id[lp] = parseInt(cellData); } else { if (nav_rez.m === 4 && lc === n_cells+1) { var chkbox = document.createElement('input'); chkbox.type = "checkbox"; chkbox.id = "chk_" + lp; chkbox.className = "chk" ; chkbox.setAttribute('onchange', 'rez_chb(' + lp + ')'); chkbox.checked = czybyli[lp]; cell.appendChild(chkbox); cellData = "TAK/NIE"; cell.style.width = "100px"; // cell.style.textAlign = 'center'; } cell.appendChild(document.createTextNode(cellData)); //---- var cond1 = cell.innerHTML.match(/^[0-9\s\.,()\-'\xa0''zł']+$/); // jesli to liczba ew. z . lub , if (cond1){ cell.style.textAlign = 'right'; cell.style.paddingRight = '10px'; } var cond1 = cell.innerHTML.match(/(\d{4})-(\d{2})-(\d{2})/); // jesli to data yyyy-mm-dd if (cond1){ cell.style.textAlign = 'left'; cell.style.paddingLeft = '10px'; } //---- row.appendChild(cell); } }); tableBody.appendChild(row); //Gotowy wiersz dołącz do body lp += 1; }); xr.appendChild(tableBody); //Kompletne Body dołacz do tabeli cont.appendChild(xr); //Dołącz tabelę do kontenera div /* $('tr').each( function () // *JUSTYFIKACJA*: dla każdego wiersza { $(this).children('td').filter(function() // dla kolejnych komórek od 2-giej :gt(0) { var cond1 = this.innerHTML.match(/^[0-9\s\.,()\-'\xa0''zł']+$/); // jesli to liczba ew. z . lub , if (cond1){ $(this).css('text-align','right'); // justuj do prawej this.style.paddingRight = '20px'; // $(this).css('padding-right', '20px'); // $(".testclass").css('text-align','right'); // $(".testclass").css('padding-right','20px'); } }).css('text-align','right'); }); */ if (dMode.TYT_D != "") { // Utwórz span i wyświetl tytuł dolny $(('#' + cont_id)).append('
'); var tyd = document.getElementById(cont_id + "_tyd"); var dyd = document.getElementById(cont_id + "_dyd"); tyd.className = "rez_data_title"; dyd.style.width = dMode.SZER; dyd.style.textAlign = 'right'; dyd.style.marginTop = '10px'; tyd.innerHTML = dMode.TYT_D; } // d_r.disabled = true; //Deaktywuj przycisk "Wyświetl" if (nav_rez.m === 1 && tabelarez_on) { tabelarez_on = true; } if (nav_rez.m === 1) {document.getElementById("b_print").style.display = "inline"; } //Wyświetl przycisk "Drukuj" if (nav_rez.m === 3) {document.getElementById("w_print").style.display = "inline"; } //Wyświetl przycisk "Drukuj" // console.log(JSON.stringify(rezerw_id)); // if (nav_rez.m > 3) { console.log(JSON.stringify(czybyli)); } } //------------------------------------ADD_TABLE_ROW ------------------------------------------ function addTableRow (tableData, cont_id) { var akt_oper = nav_rez.m; nav_rez.m = 4; var xr = document.getElementById(cont_id + "_rdt"); if (!xr){ //Czy istnieje tabela? var tableData_1 = [[]]; tableData_1[0] = tableData; createTable(tableData_1, cont_id, true); var xr = document.getElementById(cont_id + "_rdt"); } var row = document.createElement('tr'); // var cont = document.getElementById("rez_dn"); row.className = "rez_data"; row.style.fontFamily = "10px Arial"; row.style.height = "20px"; // row.style.backgroundColor = "white"; tableData.forEach(function(cellData) { //Kreator komórek w wierszu: licznik lc var cell = document.createElement('td'); cell.appendChild(document.createTextNode(cellData)); var cond1 = cell.innerHTML.match(/^[0-9\s\.,()\-'\xa0''zł']+$/); // jesli to liczba ew. z . lub , if (cond1){ cell.style.textAlign = 'right'; cell.style.paddingRight = '10px'; } var cond1 = cell.innerHTML.match(/(\d{4})-(\d{2})-(\d{2})/); // jesli to data yyyy-mm-dd if (cond1){ cell.style.textAlign = 'left'; cell.style.paddingLeft = '10px'; } row.appendChild(cell); }); xr.appendChild(row); //Gotowy wiersz dołącz do body nav_rez.m = akt_oper; } /*--------------------------------- USUŃ WSZYSTKIE ELEMENTY Z CONT_ID ---------------------------------------- */ function usun_Elementy(cont_ID) { var list = document.getElementById(cont_ID); while (list.hasChildNodes()) {       list.removeChild(list.firstChild); } } //----------------------------------REMOVE_TABLE--------------------------------------------- function removeTable(cont_id) { var tt1 = document.getElementById(cont_id + "_dty1"); if (tt1) tt1.parentNode.removeChild(tt1); var tt2 = document.getElementById(cont_id + "_dty2"); if (tt2) tt2.parentNode.removeChild(tt2); var tbl = document.getElementById(cont_id + "_rdt"); if (tbl) tbl.parentNode.removeChild(tbl); //Usuń ją z DOM var ttd = document.getElementById(cont_id + "_dyd"); if (ttd) ttd.parentNode.removeChild(ttd); var knt = document.getElementById(cont_id); if (knt) knt.innerHTML = ""; // if (tyt) {document.getElementById("rpr_title").innerHTML = "";} return; if (nav_rez.m !== 3 ) { document.getElementById("rez_title1").innerHTML = ""; if (nav_rez.m > 3) {document.getElementById("rez_title2").innerHTML = "";} document.getElementById("b_print").style.display = "none"; //Ukryj przycisk "Drukuj" } else { document.getElementById("wys_title").innerHTML = ""; document.getElementById("w_print").style.display = "none"; //Ukryj przycisk "Drukuj" } } /* -------------------- SORTUJ TABLICĘ 2D a WZGLĘDEM WARTOŚCI W KOL. colIndex -------------------------- */ function sortByColumn(a, colIndex){ a.sort(sortFunction); function sortFunction(a, b) { if (a[colIndex] === b[colIndex]) { return 0; } else { return (a[colIndex] < b[colIndex]) ? -1 : 1; } } return a; } /* -----------------------------------EXPORT ARRAY ROWS DO CSV (SEP.: ;) -------------------------------- */ /* https://stackoverflow.com/questions/14964035/how-to-export-javascript-array-info-to-csv-on-client-side */ function zapisz_CSV(filename, rows) { var processRow = function (row) { var finalVal = ''; for (var j = 0; j < row.length; j++) { var innerValue = row[j] === null ? '' : row[j].toString(); if (row[j] instanceof Date) { innerValue = row[j].toLocaleString(); }; var result = innerValue.replace(/"/g, '""'); if (result.match(/^[0-9\s\.()\-'\xa0''zł']+$/)) // jesli to liczba zamień '.' na ',' result = result.replace('.', ','); if (result.search(/("|;|\n)/g) >= 0) // Zam. sep. ',' na ';' result = '"' + result + '"'; if (j > 0) finalVal += ';'; finalVal += result; } return finalVal + '\r\n'; }; var csvFile = ''; for (var i = 0; i < rows.length; i++) { csvFile += processRow(rows[i]); } var blob = new Blob([csvFile], { type: 'text/csv;charset=utf-8;' }); if (navigator.msSaveBlob) { // IE 10+ navigator.msSaveBlob(blob, filename); } else { var link = document.createElement("a"); if (link.download !== undefined) { // feature detection // Browsers that support HTML5 download attribute var url = URL.createObjectURL(blob); link.setAttribute("href", url); link.setAttribute("download", filename); link.style.visibility = 'hidden'; document.body.appendChild(link); link.click(); document.body.removeChild(link); } } } //----------------------------------REMOVE ALL OPTIONS--------------------------------------- //Usunięcie wszystkich opcji z listy select_id function removeAllOptions(select_id){ var select_menu = document.getElementById(select_id); select_menu.options.length = 0; } //----------------------------OBLICZ KWOTĘ ZOBOWIĄZANIA PADATKOWEGO DLA ZAKUPÓW ONLINE ------------------------------- function zobow_podatkowe_RONL(prog){ var cena_RONL = {"Sklep":60, "Booking.com":54, "Trip Advisor":14, "Veltra":12, "Classictic":15, "GetYourGuide":60}; f2 = rezerwacja.l_rez * cena_RONL[rezerwacja.instyt]; rezerwacja.data_op = rezerwacja.data_rez; switch (rezerwacja.instyt) { case "Sklep": rezerwacja.data_wp = rezerwacja.data_wp == "" ? theday() : rezerwacja.data_wp; d = new Date(rezerwacja.data_wp); var n = d.getDay(); n==0 ? n = 7 : n = n; var data_zaplaty = from_theday(d, 8-n); // Następny poniedziałek rezerwacja.data_op = (prawda_ze (rezerwacja.data_rez, ">", data_zaplaty)) ? data_zaplaty : rezerwacja.data_rez; if (prog == 1) { var x2 = $('#s_plt').val() var f2 = parseFloat(x2.replace(',','.')); if (isNaN(f2)) { window.alert("Wpis kwoty nie jest prawidłową liczbą"); return (0); } $("#s_plt").val(f2.toFixed(2)); } else { rezerwacja.comment = "*** Sprawdź kwotę ręcznie ***"; } rezerwacja.stawka_ind = f2; break; case "Booking.com": if (prog == 1) { $("#s_plt").val(f2.toFixed(2));} rezerwacja.stawka_ind = f2; break; case "Veltra": case "Trip Advisor": case "Classictic": case "GetYourGuide": if (prog == 1) { var x2 = $('#s_plt').val() var f2 = parseFloat(x2.replace(',','.')); if (isNaN(f2)) { window.alert("Wpis kwoty nie jest prawidłową liczbą"); return (0); } $("#s_plt").val(f2.toFixed(2)); } else { rezerwacja.comment = "*** Sprawdź kwotę ręcznie ***"; } rezerwacja.stawka_ind = f2; break; } return(1); } //-----------------------------------DZISIEJSZA DATA---------------------------------------- function theday () { var today = new Date(); var dd = today.getDate(); var mm = today.getMonth()+1; //January is 0! var yyyy = today.getFullYear(); if (dd < 10) { dd = '0'+dd; } if (mm < 10) { mm = '0'+mm; } today = yyyy + '-' + mm + '-' + dd; return (today); } //--------------------------------- AKTUALNY CZAS hh:mm ---------------------------------- function thetime() { var czas = new Date(); var hh = czas.getHours(); var min = czas.getMinutes(); if (hh < 10) { hh = '0'+hh; }; if (min < 10) { min = '0'+min; }; return hh + ':' + min; } function from_today (nd) { var d = new Date(); d.setDate(d.getDate() + nd); // var today = new Date(); var dd = d.getDate(); var mm = d.getMonth()+1; //January is 0! var yyyy = d.getFullYear(); if (dd < 10) { dd = '0'+dd; } if (mm < 10) { mm = '0'+mm; } var today = yyyy + '-' + mm + '-' + dd; return (today); } function from_theday (theday, nd) { var d = new Date(theday); d.setDate(d.getDate() + nd); // var today = new Date(); var dd = d.getDate(); var mm = d.getMonth()+1; //January is 0! var yyyy = d.getFullYear(); if (dd < 10) { dd = '0'+dd; } if (mm < 10) { mm = '0'+mm; } today = yyyy + '-' + mm + '-' + dd; return (today); } function caly_miesiac(dt1, dt2) { var d = new Date(dt1); var mt1 = d.getMonth(); var dp = from_theday (dt1, -1); var d = new Date(dp); var mt2 = d.getMonth(); var poczatek = mt1 != mt2; if (prawda_ze(theday(), "<", dt2)) return (false); var d = new Date(dt2); var mt1 = d.getMonth(); var dn = from_theday (dt2, 1); var d = new Date(dn); var mt2 = d.getMonth(); var koniec = mt1 != mt2; return(poczatek && koniec); } function ustaw_poprz_mc(mpt, dt1, dt2) { var d = new Date(); var dd = d.getDate(); var mm = d.getMonth()+1; //January is 0! $(mpt).val(mm-1); var yyyy = d.getFullYear(); if (mm < 10) { mc = '0'+mm; } else {mc = mm;} var pocz_mc = yyyy + '-' + mc + '-01'; if (mm == 12) { mm = 1; yyyy += 1; } else mm += 1; if (mm < 10) { mc = '0'+mm; } else {mc = mm;} var konc_mc = yyyy + '-' + mc + '-01'; konc_mc = from_theday (konc_mc, -1); $(dt1).val(pocz_mc); $(dt2).val(konc_mc); return; } function now (){ var now = new Date(); var czas = new Date(); now = theday(); var hh = czas.getHours(); var min = czas.getMinutes(); if (hh < 10) { hh = '0'+hh; }; if (min < 10) { min = '0'+min; }; now += ' ' + hh + ':' + min; return (now); } function prawda_ze (data1, relacja, data2) { var newdate1 = new Date(data1); var newdate2 = new Date(data2); switch (relacja) { case ">": if ( newdate1.setDate(newdate1.getDate()) > newdate2.setDate(newdate2.getDate()) ) { return (true); } break; case ">=": if ( newdate1.setDate(newdate1.getDate()) >= newdate2.setDate(newdate2.getDate()) ) { return (true); } break; case "<": if ( newdate1.setDate(newdate1.getDate()) < newdate2.setDate(newdate2.getDate()) ) { return (true); } break; case "<=": if ( newdate1.setDate(newdate1.getDate()) <= newdate2.setDate(newdate2.getDate()) ) { return (true); } break; case "=": case "==": if ( newdate1.setDate(newdate1.getDate()) === newdate2.setDate(newdate2.getDate()) ) { return (true); } break; case "!=": if ( newdate1.setDate(newdate1.getDate()) !== newdate2.setDate(newdate2.getDate()) ) { return (true); } break; } return (false); } function capitalFirst(str) { str = str.toLowerCase(); str = str.trim().replace(/\s{2,}/g, ' '); str = str.split(/[ ]/); for (var i = 0, x = str.length; i < x; i++) { str[i] = str[i][0].toUpperCase() + str[i].substr(1); } return str.join(" "); } /* ------------------------------------- ZAMIEŃ STRING NA LICZBĘ LUB BŁĄD ---------------------------------- */ function liczba_wpr (x){ if(!x || !(x = $.trim(x))) { x = "0";} var f2 = parseFloat(x.replace(',','.')); if (isNaN(f2)) { window.alert("Wpis kwoty nie jest prawidłową liczbą"); return(0); } return(f2); } /*------------------------------- SPRAWDŹ, CZY DATA JEST W DOPUSZCZALNYM PRZEDZIALE ----------------------------*/ function data_poprawna (data1) { if (prawda_ze (data1, ">", theday())) { window.alert("Nie można wpisać do rejestru prac przyszłych"); $('#dt').val(theday); $('#dt_m').val(theday); $('#dk').val(theday); $('#dk_m').val(theday); $('#df1').val(theday); $('#dg_m').val(theday); return false; } if (prawda_ze (data1, "<", data_zamkniecia)) { window.alert("Data zamkniecia rozliczeń to:-- " + data_zamkniecia + " --wczesniejsze dane nie mogą być wprowadzane ani modyfikowane"); $('#dt').val(data_zamkniecia); $('#dt_m').val(data_zamkniecia); $('#dk').val(data_zamkniecia); $('#dk_m').val(data_zamkniecia); $('#df1').val(theday); $('#dg_m').val(theday); return false; } else { return true; } } /*---------------------------------- RÓŻNICA W DNIACH POMIĘDZY DWIEMA DATAMI -------------------------------*/ var date_diff_indays = function(date1, date2) { dt1 = new Date(date1); dt2 = new Date(date2); return Math.floor((Date.UTC(dt2.getFullYear(), dt2.getMonth(), dt2.getDate()) - Date.UTC(dt1.getFullYear(), dt1.getMonth(), dt1.getDate()) ) /(1000 * 60 * 60 * 24)); } /*--------------------------------- LICZBA PEŁNYCH LAT POMIEDZY DWIEMA DATAMI ------------------------------*/ function dateDiffInYears(dateold, datenew) { if (prawda_ze (datenew, "<", dateold)) {var dx = datenew; datenew = dateold; dateold=dx;} dtold = new Date(dateold); dtnew = new Date(datenew); var ynew = dtnew.getFullYear(); var mnew = dtnew.getMonth(); var dnew = dtnew.getDate(); var yold = dtold.getFullYear(); var mold = dtold.getMonth(); var dold = dtold.getDate(); var diff = ynew - yold; if (mold > mnew) diff--; else { if (mold == mnew) { if (dold > dnew) diff--; } } return diff; } /* ------------------------------------- ZAMIEŃ STRING NA LICZBĘ RZCZYWISTĄ LUB BŁĄD ---------------------------------- */ function liczba_wpr (x){ if(!x || !(x = $.trim(x))) { x = "0";} var f2 = parseFloat(x.replace(',','.')); if (isNaN(f2)) { window.alert("Wpis kwoty nie jest prawidłową liczbą"); return(0); } return(f2); } /* ------------------------------------- ZAMIEŃ STRING NA LICZBĘ CAŁKOWIĄ LUB BŁĄD ---------------------------------- */ function liczba_calk (x){ if(!x || !(x = $.trim(x))) { x = "0";} var f2 = parseInt(x); if (isNaN(f2)) { window.alert("Wpis " + x +" nie jest prawidłową liczbą całkowitą"); return(0); } return(f2); } //-----------------znajdź substr w string i zwróć kolejny substr o dł. len znaków ----------------- function parse_String (string, substr, len) { var pos = string.indexOf(substr); if (pos >= 0) { return (string.substring(pos+1, pos+len+1)); } else { return (""); } } /*--------------znajdź token w string i zwróć kolejny substr o dł. len znaków lub do ------*/ function get_Substring (string, token, eol, len) { var token_len = 0; var pos = string.indexOf(token); if (pos < 0) return (""); var token_start = pos + token.length; if (eol == "" && len == 0) { rez_str = string.substring(token_start).replace(/ {2,}/g, ' '); return (rez_str.trim()); } if (eol != "") { var pos_eol = string.substring(token_start).indexOf(eol); token_len = (pos_eol >= 0) ? pos_eol : 0; rez_str = string.substring(token_start, token_start + token_len).replace(/ {2,}/g, ' '); return (rez_str.trim()); } if (len > 0) { rez_str = string.substring(token_start, token_start + len).replace(/ {2,}/g, ' '); return (rez_str.trim()); } } //------------------------------------- PAUZA WYKONANIA PROGRAMU W SEK. ------------------------------------ async function sleep(sec) { await new Promise(r => setTimeout(r, sec*1000)); } //------------------------------- SUMA REZERWACJI OBECNYCH KOL NR_KOL TABELI TABELA-------------------------- function suma_rezerw(tabela, l_rows, nr_kol, dod) { var sum_r = 0; for (i=0; i 0) { var s = Math.floor((liczba % 1000)/100); var n = 0; var d = Math.floor((liczba % 100)/10); var j = Math.floor(liczba % 10); if (d == 1 && j>0) { n = j; d = 0; j = 0; } var k = 2; if (j == 1 && s+d+n == 0) k = 0; if (j == 2 || j == 3 || j == 4) k = 1; if (s+d+n+j > 0) wynik = setki[s]+dziesiatki[d]+nascie[n]+jednosci[j]+grupy[g][k]+wynik; g++; liczba = Math.floor(liczba/1000); } return(znak + wynik + ' ' + liczba_gro +"/100"); } else { return "Błędna kwota"; } } // -------------------------------------Kwota słownie jęz. angielski --------------------------------- function inwords(liczba) { var jednosci = ["", " one", " two", " three", " four", " five", " six", " seven", " eight", " nine"]; var nascie = ["", " eleven", " twelve", " thirteen", " fourteen", " fifteen", " sixteen", " seventeen", " eighteen", " nineteen"]; var dziesiatki = ["", " ten", " twenty", " thirty", " fourty", " fivety", " sixty", " seventy", " eighty", " ninety"]; var setki = ["", " one hundred", " two hundred", " three hundred", " four hundred", " five hundred", " six hundred", " seven hundred", " eight hundred", " nine hundred"]; var grupy = [ ["" ,"" ,""], [" thousand" ," thousands" ," thousands"], [" million" ," millions" ," millions"], [" billion"," billions"," billions"], [" trillion" ," trillions" ," trillions"], [" quadrillion"," quadrillions"," quadrillions"], [" quintillion"," quintillions"," quintillions"]]; if (!isNaN(liczba)){ var wynik = ''; var znak = ''; if (liczba == 0) wynik = "zero"; if (liczba < 0) { znak = "minus"; liczba = -liczba; } liczba_dec = parseFloat(liczba).toFixed(2); liczba_clk = Math.trunc(liczba_dec); liczba_gro = Math.trunc((liczba_dec - liczba_clk) * 100); var g = 0; while (liczba > 0) { var s = Math.floor((liczba % 1000)/100); var n = 0; var d = Math.floor((liczba % 100)/10); var j = Math.floor(liczba % 10); if (d == 1 && j>0) { n = j; d = 0; j = 0; } var k = 2; if (j == 1 && s+d+n == 0) k = 0; if (j == 2 || j == 3 || j == 4) k = 1; if (s+d+n+j > 0) wynik = setki[s]+dziesiatki[d]+nascie[n]+jednosci[j]+grupy[g][k]+wynik; g++; liczba = Math.floor(liczba/1000); } return(znak + wynik + ' ' + liczba_gro +"/100"); } else { return "Błędna kwota"; } }