var moveinterval = 0; var cal = ''; function ajax_submitform(url, withupdate, formname) { formname = formname ? formname : "ajax_form"; try { if (withupdate == 1) { navitree_submitForm(url, '', $(formname).serialize(), ajax_error, ajax_complete_update, ajax_success_update) } else { navitree_submitForm(url, '', $(formname).serialize(), ajax_error, ajax_complete, ajax_success) } //Run some code here } catch(err) { alert(err); //Handle errors here alert("Browser incompatibility error. Check if javascript is enabled or ajax technologies supported."); } } function ajax_error(atext) { if (atext) { showDialog('Error', atext, 'error'); } else { showDialog('Error', "Szerver hiba! Kérjük próbálkozzon később.", 'error'); } } function ajax_complete(originalRequest, json, ajax) { if (originalRequest.responseText.length > 0) { if (originalRequest.responseText == '1') { showDialog('Success', "Customer saved", 'success'); } else { if (originalRequest.responseText == -1) { ajax_error("Error during data saving. Please try again later!"); } else { showDialog('Success', originalRequest.responseText, 'success'); } } } else showDialog('Error', '1. Server timeout. Please try again later!', 'error'); } function ajax_success(originalRequest, json, ajax) { ajax_complete(originalRequest, json, ajax) } function ajax_complete_update(originalRequest, json, ajax) { if (originalRequest.responseText.length > 0) { formupdateResponse(originalRequest); } else { showDialog('Error', '2. Server timeout. Please try again later!', 'error'); } } function ajax_success_update(originalRequest, json, ajax) { ajax_complete_update(originalRequest, json, ajax) } function order_checkField(formname, fieldname) { ajax_submitform('/ajax.php?module=web_cart_checkfield&web_cart_checkvalue='+fieldname, 1, formname); } function reg_checkField(formname, fieldname) { ajax_submitform('/ajax.php?module=reg_checkfield®_checkvalue='+fieldname, 1, formname); } function setDisplayCookie(id) { var obj = $(id); if (obj) { document.cookie = 'lgo_' + id + '_display=' + obj.style.display; } } function setCookie(id, val) { var obj = $(id); if (obj) objval = obj.value ? obj.value : ''; document.cookie = id + '=' + (val ? val : objval); } /* Toggle minimize/maximize icon */ function toggleMinMaxImage(id) { var img = $(id); if (img) { var str = img.src; if (str.search("ftab_min.gif") > 0) img.src = "../img/ftab/ftab_max.gif"; else img.src = "../img/ftab/ftab_min.gif"; } } /* Show/hide element. Parameter 'block' contains the display style of element when visible (block by default, can be set to inline-block, table cell etc.). */ function toggleElement(element, tofocus, block, loadcontentvar, loadcontenturl) { if (block == '') { block = 'block'; } if (!$(element).style.display || ($(element).style.display == 'none')) { $(element).style.display = block; if (tofocus == 1) $(element).focus(); } else { $(element).style.display = 'none'; } if ($(element).style.display != 'none') {//load content if required if (loadcontentvar) { if ($(loadcontentvar).value == 0) { ajax_submitform(loadcontenturl, 1); } } } } function showElementBlock(element, tofocus) { $(element).style.display = 'block'; if (tofocus == 1) $(element).focus(); } function showElement(element, tofocus) { $(element).style.display = 'inline-block'; if (tofocus == 1) $(element).focus(); } function hideElement(element) { $(element).style.display = 'none'; } function openPopup(id) { var minmax = $(id+'_t_min'); if (minmax) { var str = minmax.getAttribute("src"); if (str.search('ftab_max.gif') > 0) { minmax.onclick(); } } } /* Place the given element in the middle of the screen. */ function centerElement(element) { openPopup(element); $(element).style.left = f_scrollLeft() + (f_clientWidth() - $(element).clientWidth)/2 + 'px'; $(element).style.top = Math.max(0, f_scrollTop() + (f_clientHeight() - $(element).clientHeight)/2) + 'px'; $(element).focus(); } function f_clientWidth() { return f_filterResults ( window.innerWidth ? window.innerWidth : 0, document.documentElement ? document.documentElement.clientWidth : 0, document.body ? document.body.clientWidth : 0 ); } function f_clientHeight() { return f_filterResults ( window.innerHeight ? window.innerHeight : 0, document.documentElement ? document.documentElement.clientHeight : 0, document.body ? document.body.clientHeight : 0 ); } function f_scrollLeft() { return f_filterResults ( window.pageXOffset ? window.pageXOffset : 0, document.documentElement ? document.documentElement.scrollLeft : 0, document.body ? document.body.scrollLeft : 0 ); } function f_scrollTop() { return f_filterResults ( window.pageYOffset ? window.pageYOffset : 0, document.documentElement ? document.documentElement.scrollTop : 0, document.body ? document.body.scrollTop : 0 ); } function f_filterResults(n_win, n_docel, n_body) { var n_result = n_win ? n_win : 0; if (n_docel && (!n_result || (n_result > n_docel))) n_result = n_docel; return n_body && (!n_result || (n_result > n_body)) ? n_body : n_result; } /* Highlight the active table's header. */ function setActiveTable(tablename) { var tables = new Array ("product", "category", "campaign", "adgroup", "ad", "template", "ad", "keyword", "product_adm", "category_adm", "order_adm", "orderitem_adm", "package_adm", "invoice_adm", "client_adm", "courier_adm", "supplier_adm", "mailtemplate_adm", "operator_adm", "actionlog", "deletelog", "supplylog", "maillog"); var table; for (var i = 0; i < tables.length; i++) { table = $(tables[i] + '_list'); // table.setAttribute("class", "list"); table.className = "list"; } table = $(tablename + '_list'); // table.setAttribute("class", "actlist"); table.className = "actlist"; } /* Open table. */ function openActiveTable(tablename) { if ($(tablename+'min')) $(tablename+'min').src = "../img/ftab/ftab_min.gif"; showElementBlock(tablename+'table', 0); setDisplayCookie(tablename+'table'); } /* Jump to a given table - used in top navigation menu. */ function jumpToTable(activetab, listname, tablename) { // switch to appropriate tab if ($('ftab_p_title'+activetab)) $('ftab_p_title'+activetab).onclick(); // open table openActiveTable(listname); // highlight table header setActiveTable(tablename); } /* Save changes when ENTER is pressed. */ function watchKeys(e, obj) { var keynum; if(window.event) {// IE keynum = e.keyCode; } else if(e.which) {// Netscape/Firefox/Opera keynum = e.which; } if (keynum == 13) {// ENTER pressed obj.blur(); } } /* Save changes when ENTER is pressed. */ /* Discard changes when ESC is pressed. */ function watchKeysEsc(e, obj, res) { var keynum; if(window.event) {// IE keynum = e.keyCode; } else if(e.which) {// Netscape/Firefox/Opera keynum = e.which; } if (keynum == 13) {// ENTER pressed obj.blur(); } if (keynum == 27) {// ESC pressed obj.value = res; obj.blur(); return false; } return true; } /* Discard changes when ESC is pressed. */ function watchKeysEscOnly(e, obj, res) { var keynum; if(window.event) {// IE keynum = e.keyCode; } else if(e.which) {// Netscape/Firefox/Opera keynum = e.which; } if (keynum == 27) {// ESC pressed obj.value = res; obj.blur(); return false; } return true; } /* Check/uncheck all checkboxes */ function checkControl(control, form, id, name) { var chk = $(form).elements[id]; if(control.checked == true) { for (i = 0; i < chk.length; i++) { chk[i].checked = true; document.cookie = name + "[" + chk[i].value + "]=" + chk[i].value; } } else { for (i = 0; i < chk.length; i++) { chk[i].checked = false; var date = new Date();// current date & time date.setTime (date.getTime() - 1); document.cookie = name + "[" + chk[i].value + "]=; expires=" + date.toGMTString(); } } } /* Check if at least one campaign/product/template was selected before creating new ads. */ function validateCreateAd() { var found; var chk; found = false; chk = $('ajax_form').elements['select_campaign[]']; if (chk) { for (i = 0; i < chk.length; i++) { if (chk[i].checked) { found = true; break; } } } if (!found) { showDialog('Error', "Please select at least one campaign!", 'error'); return false; } found = false; chk = $('ajax_form').elements['select_template[]']; if (chk) { for (i = 0; i < chk.length; i++) { if (chk[i].checked) { found = true; break; } } } if (!found) { showDialog('Error', "Please select at least one template!", 'error'); return false; } found = false; chk = $('ajax_form').elements['select_product[]']; if (chk) { for (i = 0; i < chk.length; i++) { if (chk[i].checked) { found = true; break; } } } chk = $('ajax_form').elements['select_category[]']; if (chk) { for (i = 0; i < chk.length; i++) { if (chk[i].checked) { found = true; break; } } } if (!found) { showDialog('Error', "Please select at least one product or category!", 'error'); return false; } return true; } /* Deletes the given cookie by setting its expire date. */ function deleteCookie(name) { var date = new Date();// current date & time date.setTime (date.getTime() - 1); document.cookie = name += "=; expires=" + date.toGMTString(); } /* Deletes the given cookies by setting their expire date. */ function deleteCookies(cookies) { var date = new Date();// current date & time date.setTime (date.getTime() - 1); for (i = 0; i < cookies.length; i++) { document.cookie = cookies[i] += "=; expires=" + date.toGMTString(); } } /* Show/hide a certain column in a given table */ function ShowHideField(header, gridID, chk) { var theGrid = $(gridID); var displayValue; if (chk) { displayValue = ""; } else { displayValue = "none"; } if (theGrid != null) { var theHeaders = theGrid.getElementsByTagName("th"); var theRows = theGrid.getElementsByTagName("tr"); var numHeaders = theHeaders.length; var numRows = theRows.length; var i; var foundHeader = false; //searching through the headers in the grid for one that matches the header value provided for (i = 0; i < numHeaders && foundHeader==false; i++) { var headerText = theHeaders[i].id; if (headerText == header) { //once found the header, set the header's display value to display or not depending on what was provided foundHeader = true; theHeaders[i].style.display = displayValue; var j; for (j = 0; j < numRows; j++) { //looping through all of the rows in the grid and setting each cell in the column to display or not. var cells = theRows[j].getElementsByTagName("td"); if (cells.length > i) { cells[i].style.display = displayValue; } } } } } } /* Reset the form elements within the given div */ function resetDiv(div) { if (!div) return; div = (typeof div === "string") ? $(div) : div; var elements = div.getElementsByTagName("*"); for(i=0; i 0)) { alert("Please select the status of invoice."); return false; } return true; } /* Validate submitted data before creating new package. */ function validatePackage() { if (!$("newpack_code").value) { alert("Please fill in the code of package."); return false; } if (!($("newpack_courier").value > 0)) { alert("Please select the courier."); return false; } if (!$("newpack_client").value) { alert("Please fill in the name of client."); return false; } if (!$("newpack_zip").value) { alert("Please fill in the zip."); return false; } if (!$("newpack_locality").value) { alert("Please fill in the locality."); return false; } if (!$("newpack_address").value) { alert("Please fill in the address."); return false; } var pattern = /^\d{4}-\d{2}-\d{2}$/; if (!pattern.test($("newpack_date").value)) { alert("Please fill in a correct date of format 'yyyy-mm-dd'."); return false; } if (!($("newpack_status").value > 0)) { alert("Please select the status of package."); return false; } return true; } /* Validate submitted data before creating new courier. */ function validateCourier() { if (!$("newcourier_name").value) { alert("Please fill in the name of courier."); return false; } var pattern = /^[a-zA-Z0-9._-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}$/; if (!pattern.test($("newcourier_email").value)) { alert("Please fill in a valid email address."); return false; } if (!$("newcourier_phone").value) { alert("Please fill in the phone number."); return false; } if ($("newcourier_cemail").value) { if (!pattern.test($("newcourier_cemail").value)) { alert("Please fill in a valid contact email address."); return false; } } return true; } /* Validate submitted data before creating new supplier. */ function validateSupplier() { if (!$("newsupplier_name").value) { alert("Please fill in the name of supplier."); return false; } var pattern = /^[a-zA-Z0-9._-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}$/; if (!pattern.test($("newsupplier_email").value)) { alert("Please fill in a valid email address."); return false; } if (!$("newsupplier_address").value) { alert("Please fill in the address."); return false; } if (!$("newsupplier_phone").value) { alert("Please fill in the phone number."); return false; } return true; } /* Validate submitted data before creating new supplier. */ function validateSupplierProduct() { if (!$("newsupplierproduct_supplier").value) { alert("Please fill in the supplier."); return false; } if (!$("newsupplierproduct_invoice").value) { alert("Please fill in the invoice number."); return false; } if (!$("newsupplierproduct_payment").value) { alert("Please fill in the payment method."); return false; } if (!$("newsupplierproduct_invoicedate").value) { alert("Please fill in the invoice date."); return false; } return true; } function validateClientProduct() { if (!$("newclientproduct_order").value) { alert("Please fill in the order."); return false; } if (!$("newclientproduct_client").value) { alert("Please fill in the client."); return false; } if (!$("newclientproduct_payment").value) { alert("Please fill in the payment method."); return false; } if (!$("newclientproduct_invoicedate").value) { alert("Please fill in the invoice date."); return false; } if (!$("newclientproduct_storage").value) { alert("Please fill in the storage."); return false; } return true; } /* Validate submitted data before creating new order item. */ function validateOrderItem() { if (!$("newitem_order").value) { alert("Please fill in the code of order."); return false; } if (!$("newitem_product").value) { alert("Please fill in the SKU of product."); return false; } if (!$("newitem_gross").value) { alert("Please fill in the net value."); return false; } if (!$("newitem_prime").value) { alert("Please fill in the prime cost."); return false; } if (!($("newitem_status").value > 0)) { alert("Please select the status of order item."); return false; } return true; } /* Validate submitted data before creating new order item. */ function validateProduct() { if (!$("newprod_sku").value) { alert("Please fill in the sku of product."); return false; } if (!$("newprod_name").value) { alert("Please fill in the name of product."); return false; } if (!$("newprod_short_desc").value) { alert("Please fill in the short description."); return false; } if (!$("newprod_desc").value) { alert("Please fill in the description."); return false; } if (!($("newprod_status").value >= 0)) { alert("Please select the status of product."); return false; } return true; } /* Validate submitted data before creating new order item. */ function validateCategory() { if (!$("new_catwebshop").value) { alert("Please select webshop."); return false; } if (!$("newcat_name").value) { alert("Please fill in the name of category."); return false; } if (($("newcat_status").value == '')) { alert("Please select the status of category."); return false; } return true; } /* Validate product supplier settings. */ function validateProdSupplier() { if (!$("setsupplier_default").value) { alert("Please select the default supplier."); return false; } else { var r = document.forms[0].setsupplier_default; var p; if (r) { for (i=0; i */ function nl2br(str) { return str.replace(/(\r\n|\r|\n)/g, "
"); } /* Replace
with new line */ function br2nl(str) { return str.replace(/(|\r\n|\r|\n)/g, "\n"); } function smoothMove() { var Dif = parseInt((document.body.scrollTop+topOffset-document.all.navBar.offsetTop)*.1) // Work-around wierd Netscape NaN bug when Dif is 0 if (isNaN(Dif)) Dif=0 document.all.navBar.style.pixelTop+=Dif } function doLoad() { topFixed($('fixedmenubar'),0); cal = Calendar.setup({ onSelect: function(cal) { cal.hide() }, bottomBar: false }); cal.manageFields("global_enddate_trigger", "global_enddate", "%Y-%m-%d"); cal.manageFields("global_startdate_trigger", "global_startdate", "%Y-%m-%d"); } function moveup() { window.scrollBy(0, -46); clearInterval(moveinterval); } function startmoveup() { moveinterval = window.setInterval("moveup()",15) } function topFixed(ele,dist) { if (ele) { // set the initial position based on 'dist' ele.style.top = dist+'px'; // bad browser detect! but it should work... var ieMatch = navigator.appVersion.match(/MSIE (\d+)\./); if(!ieMatch || +ieMatch[1]>=7) { // set it to fixed, and forget it! we're done! ele.style.position = 'fixed'; } else { // uh-oh... not supported! // set the position to absolute... ele.style.position = 'absolute'; // then set up a func to run every .01 sec... setInterval(function(ele) {if(ele){ ele.style.display = 'none'; // turn visibility off... ele.style.top = dist+'px'; // change the offset... // and turn it back on to force the browser to reposition! ele.style.display = 'block'; }},10,ele); } // the rest takes care of itself! } } /* Set the radiobox and visible form elements according to the selected action (export/import) */ function selectImpexAction(action) { if (action) {//export hideElement('order_import'); showElementBlock('order_export'); document.forms[0].impex[0].checked=false; document.forms[0].impex[1].checked=true; } else {//import hideElement('order_export'); showElementBlock('order_import'); document.forms[0].impex[0].checked=true; document.forms[0].impex[1].checked=false; } } function validateOrderExport() { if ($('order_export_type').value > 0) { return true; } else { alert("Please select the type of the export!"); return false; } } function validateOrderImport() { var valid = true; if ($('order_import_type').value <= 0) { alert("Please select the type of the import!"); return false; } if (!$('order_import_file').value) { alert("Please select the import file!"); return false; } else { return true; } } function refreshallboxes() { ajax_submitform('/ajax.php?module=listadmorders', 1); ajax_submitform('/ajax.php?module=listadmorderitems', 1); ajax_submitform('/ajax.php?module=listadmclients', 1); ajax_submitform('/ajax.php?module=listadminvoices', 1); ajax_submitform('/ajax.php?module=listadmpackages', 1); ajax_submitform('/ajax.php?module=listadmproducts', 1); } function refreshallboxesdate(start, end) { ajax_submitform('/ajax.php?module=listadmorders'+(start?"&orders_startdate="+start:"")+(end?"&orders_enddate="+end:""), 1); setCookie("orders_startdate", start); setCookie("orders_enddate", end); ajax_submitform('/ajax.php?module=listadmorderitems'+(start?"&orderitems_startdate="+start:"")+(end?"&orderitems_enddate="+end:""), 1); setCookie("invoices_startdate", start); setCookie("invoices_enddate", end); ajax_submitform('/ajax.php?module=listadminvoices'+(start?"&invoices_startdate="+start:"")+(end?"&invoices_enddate="+end:""), 1); setCookie("packages_startdate", start); setCookie("packages_enddate", end); ajax_submitform('/ajax.php?module=listadmpackages'+(start?"&packages_startdate="+start:"")+(end?"&packages_enddate="+end:""), 1); } /* Convert all HTML entities to their applicable characters. */ function html_entity_decode(string, quote_style) { var hash_map = {}, symbol = '', tmp_str = '', entity = ''; tmp_str = string.toString(); if (false === (hash_map = get_html_translation_table('HTML_ENTITIES', quote_style))) { return false; } delete(hash_map['&']); hash_map['&'] = '&'; for (symbol in hash_map) { entity = hash_map[symbol]; tmp_str = tmp_str.split(entity).join(symbol); } tmp_str = tmp_str.split(''').join("'"); return tmp_str; } /* Returns the internal translation table used by htmlspecialchars and htmlentities. */ function get_html_translation_table(table, quote_style) { var entities = {}, hash_map = {}, decimal = 0, symbol = ''; var constMappingTable = {}, constMappingQuoteStyle = {}; var useTable = {}, useQuoteStyle = {}; // Translate arguments constMappingTable[0] = 'HTML_SPECIALCHARS'; constMappingTable[1] = 'HTML_ENTITIES'; constMappingQuoteStyle[0] = 'ENT_NOQUOTES'; constMappingQuoteStyle[2] = 'ENT_COMPAT'; constMappingQuoteStyle[3] = 'ENT_QUOTES'; useTable = !isNaN(table) ? constMappingTable[table] : table ? table.toUpperCase() : 'HTML_SPECIALCHARS'; useQuoteStyle = !isNaN(quote_style) ? constMappingQuoteStyle[quote_style] : quote_style ? quote_style.toUpperCase() : 'ENT_COMPAT'; if (useTable !== 'HTML_SPECIALCHARS' && useTable !== 'HTML_ENTITIES') { throw new Error("Table: "+useTable+' not supported'); } entities['38'] = '&'; if (useTable === 'HTML_ENTITIES') { entities['160'] = ' '; entities['161'] = '¡'; entities['162'] = '¢'; entities['163'] = '£'; entities['164'] = '¤'; entities['165'] = '¥'; entities['166'] = '¦'; entities['167'] = '§'; entities['168'] = '¨'; entities['169'] = '©'; entities['170'] = 'ª'; entities['171'] = '«'; entities['172'] = '¬'; entities['173'] = '­'; entities['174'] = '®'; entities['175'] = '¯'; entities['176'] = '°'; entities['177'] = '±'; entities['178'] = '²'; entities['179'] = '³'; entities['180'] = '´'; entities['181'] = 'µ'; entities['182'] = '¶'; entities['183'] = '·'; entities['184'] = '¸'; entities['185'] = '¹'; entities['186'] = 'º'; entities['187'] = '»'; entities['188'] = '¼'; entities['189'] = '½'; entities['190'] = '¾'; entities['191'] = '¿'; entities['192'] = 'À'; entities['193'] = 'Á'; entities['194'] = 'Â'; entities['195'] = 'Ã'; entities['196'] = 'Ä'; entities['197'] = 'Å'; entities['198'] = 'Æ'; entities['199'] = 'Ç'; entities['200'] = 'È'; entities['201'] = 'É'; entities['202'] = 'Ê'; entities['203'] = 'Ë'; entities['204'] = 'Ì'; entities['205'] = 'Í'; entities['206'] = 'Î'; entities['207'] = 'Ï'; entities['208'] = 'Ð'; entities['209'] = 'Ñ'; entities['210'] = 'Ò'; entities['211'] = 'Ó'; entities['212'] = 'Ô'; entities['213'] = 'Õ'; entities['214'] = 'Ö'; entities['215'] = '×'; entities['216'] = 'Ø'; entities['217'] = 'Ù'; entities['218'] = 'Ú'; entities['219'] = 'Û'; entities['220'] = 'Ü'; entities['221'] = 'Ý'; entities['222'] = 'Þ'; entities['223'] = 'ß'; entities['224'] = 'à'; entities['225'] = 'á'; entities['226'] = 'â'; entities['227'] = 'ã'; entities['228'] = 'ä'; entities['229'] = 'å'; entities['230'] = 'æ'; entities['231'] = 'ç'; entities['232'] = 'è'; entities['233'] = 'é'; entities['234'] = 'ê'; entities['235'] = 'ë'; entities['236'] = 'ì'; entities['237'] = 'í'; entities['238'] = 'î'; entities['239'] = 'ï'; entities['240'] = 'ð'; entities['241'] = 'ñ'; entities['242'] = 'ò'; entities['243'] = 'ó'; entities['244'] = 'ô'; entities['245'] = 'õ'; entities['246'] = 'ö'; entities['247'] = '÷'; entities['248'] = 'ø'; entities['249'] = 'ù'; entities['250'] = 'ú'; entities['251'] = 'û'; entities['252'] = 'ü'; entities['253'] = 'ý'; entities['254'] = 'þ'; entities['255'] = 'ÿ'; } if (useQuoteStyle !== 'ENT_NOQUOTES') { entities['34'] = '"'; } if (useQuoteStyle === 'ENT_QUOTES') { entities['39'] = '''; } entities['60'] = '<'; entities['62'] = '>'; // ascii decimals to real symbols for (decimal in entities) { symbol = String.fromCharCode(decimal); hash_map[symbol] = entities[decimal]; } return hash_map; } /* Used by the New Order Item form to fill out product data (vat, price, prime cost) on autocomplete. */ function fillProductData(vat, gross, prime) { var vatobj = $('newitem_vat'); if (vatobj) { for(var i=0; i < vatobj.length; i++) { if(vatobj[i].value == vat) vatobj.selectedIndex = i; } } var grossobj = $('newitem_gross'); if (grossobj) grossobj.value = gross; var primeobj = $('newitem_prime'); if (primeobj) primeobj.value = prime; } /* Used by the New Supplier Product form to fill out product data (sku, name) on autocomplete. */ function fillProductSkuName(etype, pos, sku, pname, unit_price, vat, value_net, vat_value, gross_amount) { if (etype == 'supplier') { $('newsupplierproduct_productname'+pos).value = pname; $('newsupplierproduct_sku'+pos).value = sku; $('newsupplierproduct_unit_price'+pos).value = unit_price; $('newsupplierproduct_vat'+pos).value = vat; $('newsupplierproduct_net_value'+pos).innerHTML = value_net; $('newsupplierproduct_vat_value'+pos).innerHTML = vat_value; $('newsupplierproduct_gross_value'+pos).innerHTML = gross_amount; newskuproduct_updatePrices(etype, pos); } if (etype == 'client') { $('newclientproduct_productname'+pos).value = pname; $('newclientproduct_sku'+pos).value = sku; $('newclientproduct_unit_price'+pos).value = unit_price; $('newclientproduct_vat'+pos).value = vat; $('newclientproduct_net_value'+pos).innerHTML = value_net; $('newclientproduct_vat_value'+pos).innerHTML = vat_value; $('newclientproduct_gross_value'+pos).innerHTML = gross_amount; newskuproduct_updatePrices(etype, pos); } } /* Used by the New Invoice/Package form to fill out order data (client, company, phone, zip, locality, address) on autocomplete. */ function fillOrderData(form, fields, params) { var obj; for (i=0; i < fields.length; i++) { obj = $(form+'_'+fields[i]); if (obj) obj.value = params[i]; } } /* Used by the New Invoice/Package form to fill out order data (client, company, phone, zip, locality, address) on autocomplete.on client invoice entry page */ function fillOrderDataEntryExit(fields, params, ajax) { for (i=0; i < fields.length; i++) { $(fields[i]).value = params[i]; } ajax_submitform(ajax, 1); } /* Used by the Product Entry form to change vat and net value */ function newskuproduct_updatePrices(etype, pos) { if (pos>0) { if (etype == 'supplier') { $('newsupplierproduct_net_value'+pos).innerHTML = $('newsupplierproduct_cantity'+pos).value * $('newsupplierproduct_unit_price'+pos).value; $('newsupplierproduct_vat_value'+pos).innerHTML = $('newsupplierproduct_cantity'+pos).value * $('newsupplierproduct_vat'+pos).value * $('newsupplierproduct_unit_price'+pos).value / 100; $('newsupplierproduct_gross_value'+pos).innerHTML = ($('newsupplierproduct_cantity'+pos).value * $('newsupplierproduct_unit_price'+pos).value) + ($('newsupplierproduct_cantity'+pos).value * $('newsupplierproduct_vat'+pos).value * $('newsupplierproduct_unit_price'+pos).value / 100); //update sum var vat_value = 0; var net_value = 0; var gross_value = 0; for (i=1; i<=$('supplierproduct_product_count').value; i++) { vat_value+=parseInt($('newsupplierproduct_vat_value'+i).innerHTML); net_value+=parseInt($('newsupplierproduct_net_value'+i).innerHTML); gross_value+=parseInt($('newsupplierproduct_gross_value'+i).innerHTML); } $('supplierproduct_value_vat_sum').innerHTML = vat_value; $('supplierproduct_value_net_sum').innerHTML = net_value; $('supplierproduct_value_gross_sum').innerHTML = gross_value; } if (etype == 'client') { $('newclientproduct_net_value'+pos).innerHTML = $('newclientproduct_cantity'+pos).value * $('newclientproduct_unit_price'+pos).value; $('newclientproduct_vat_value'+pos).innerHTML = $('newclientproduct_cantity'+pos).value * $('newclientproduct_vat'+pos).value * $('newclientproduct_unit_price'+pos).value / 100; $('newclientproduct_gross_value'+pos).innerHTML = ($('newclientproduct_cantity'+pos).value * $('newclientproduct_unit_price'+pos).value) + ($('newclientproduct_cantity'+pos).value * $('newclientproduct_vat'+pos).value * $('newclientproduct_unit_price'+pos).value / 100); //update sum var vat_value = 0; var net_value = 0; var gross_value = 0; for (i=1; i<=$('clientproduct_product_count').value; i++) { vat_value+=parseInt($('newclientproduct_vat_value'+i).innerHTML); net_value+=parseInt($('newclientproduct_net_value'+i).innerHTML); gross_value+=parseInt($('newclientproduct_gross_value'+i).innerHTML); } $('clientproduct_value_vat_sum').innerHTML = vat_value; $('clientproduct_value_net_sum').innerHTML = net_value; $('clientproduct_value_gross_sum').innerHTML = gross_value; } } } function clientproduct_showInvoicePrint(invoice_id) { hideElement('fnew_clientproduct'); window.open('print.php?printinvoice_id='+invoice_id, 'Print', 'width=800,height=600,menubar=no,status=no,scrollbars=1') } function clientproduct_printClientInvoice(number) { for (i=1; i<= number; i++) $('print_preview'+i).style.display = "none"; window.print(); window.close(); } function orders_admtrchange(orderidclass) { var parts = orderidclass.split("+"); var classparts = $("admorder_tr"+parts[0]).className.split("0"); if (classparts.indexOf("0") != -1) classpart = "0"; else classpart = "1"; $("admorder_tr"+parts[0]).className = "row"+classpart+parts[1]; } function setFree(obj, string) { if (obj.value == string) obj.value=""; } function setDef(obj, string) { if (obj.value == "") obj.value=string; }