public function createReport() { $strReport = getRequest('report', ''); if ($strReport) { $this->printReport(); return; } $intProductId = getRequest('product', false); ?> <div class="form_container ui-widget-content ui-helper-clearfix"> <form method="get" id="params" name="params"> <input name="func" type="hidden" value="reports"> <input name="form" type="hidden" value="product_stock"> <input name="report" type="hidden" value="1"> <div class="unlimited_label"><h1><?php echo $GLOBALS['locProductStockReport']; ?> </h1></div> <div class="medium_label"><?php echo $GLOBALS['locProduct']; ?> </div> <div class="field"><?php echo htmlFormElement('product', 'LIST', $intProductId, 'medium', 'SELECT id, product_name FROM {prefix}product WHERE deleted=0 ORDER BY product_name', 'MODIFY', FALSE); ?> </div> <div class="field_sep"></div> <div class="medium_label"></div><div class="field"><input type="checkbox" name="purchase_price" value="1"> <?php echo $GLOBALS['locOnlyProductsWithPurchasePrice']; ?> </div> <div class="medium_label"><?php echo $GLOBALS['locPrintFormat']; ?> </div> <div class="field"><input type="radio" name="format" value="html" checked="checked"><?php echo $GLOBALS['locPrintFormatHTML']; ?> </input></div> <div class="medium_label"></div> <div class="field"><input type="radio" name="format" value="pdf"><?php echo $GLOBALS['locPrintFormatPDF']; ?> </input></div> <div class="field_sep"></div> <div class="medium_label"> <a class="actionlink" href="#" onclick="document.getElementById('params').submit(); return false;"><?php echo $GLOBALS['locCreateReport']; ?> </a> </div> </form> </div> <?php }
public function createReport() { $strReport = getRequest('report', ''); if ($strReport) { $this->printReport(); return; } $intBaseId = getRequest('base', false); $intCompanyId = getRequest('company', false); $invoiceDateRange = getRequest('date', ''); $invoiceRowDateRange = getRequest('row_date', ''); $paymentDateRange = getRequest('payment_date', ''); $fields = getRequest('fields[]', array()); $rowTypes = getRequest('row_types', 'all'); $format = getRequest('format', 'html'); $grouping = getRequest('grouping', ''); ?> <script type="text/javascript"> $(document).ready(function() { $('input[class~="hasDateRangePicker"]').each(function() { $(this).daterangepicker(<?php echo $GLOBALS['locDateRangePickerOptions']; ?> ); }); }); </script> <div class="form_container ui-widget-content ui-helper-clearfix"> <form method="get" id="params" name="params"> <input name="func" type="hidden" value="reports"> <input name="form" type="hidden" value="invoice"> <input name="report" type="hidden" value="1"> <div class="unlimited_label"><strong><?php echo $GLOBALS['locInvoiceReport']; ?> </strong></div> <div style="float: left; clear: both; margin-right: 20px;"> <div class="medium_label"><?php echo $GLOBALS['locInvoiceDateInterval']; ?> </div> <div class="field"><?php echo htmlFormElement('date', 'TEXT', $invoiceDateRange, 'medium hasDateRangePicker', '', 'MODIFY', false); ?> </div> <div class="medium_label"><?php echo $GLOBALS['locInvoiceRowDateInterval']; ?> </div> <div class="field"><?php echo htmlFormElement('row_date', 'TEXT', $invoiceRowDateRange, 'medium hasDateRangePicker', '', 'MODIFY', false); ?> </div> <div class="medium_label"><?php echo $GLOBALS['locPaymentDateInterval']; ?> </div> <div class="field"><?php echo htmlFormElement('payment_date', 'TEXT', $paymentDateRange, 'medium hasDateRangePicker', '', 'MODIFY', false); ?> </div> <div class="medium_label"><?php echo $GLOBALS['locBiller']; ?> </div> <div class="field"><?php echo htmlFormElement('base', 'LIST', $intBaseId, 'medium', 'SELECT id, name FROM {prefix}base WHERE deleted=0 ORDER BY name', 'MODIFY', false); ?> </div> <div class="medium_label"><?php echo $GLOBALS['locClient']; ?> </div> <div class="field"><?php echo htmlFormElement('company', 'LIST', $intCompanyId, 'medium', 'SELECT id, company_name FROM {prefix}company WHERE deleted=0 ORDER BY company_name', 'MODIFY', false); ?> </div> <div class="medium_label"><?php echo $GLOBALS['locPrintFormat']; ?> </div> <div class="field"><input type="radio" name="format" value="html"<?php if ($format == 'html') { echo ' checked="checked"'; } ?> ><?php echo $GLOBALS['locPrintFormatHTML']; ?> </div> <div class="medium_label"></div> <div class="field"><input type="radio" name="format" value="pdf"<?php if ($format == 'pdf') { echo ' checked="checked"'; } ?> ><?php echo $GLOBALS['locPrintFormatPDF']; ?> </div> <div class="medium_label"></div> <div class="field"><input type="radio" name="format" value="pdfl"<?php if ($format == 'pdfl') { echo ' checked="checked"'; } ?> ><?php echo $GLOBALS['locPrintFormatPDFLandscape']; ?> </div> <div class="field_sep"></div> <div class="medium_label"><?php echo $GLOBALS['locInvoiceRowTypes']; ?> </div> <div class="field"><input type="radio" name="row_types" value="all"<?php if ($rowTypes == 'all') { echo ' checked="checked"'; } ?> ><?php echo $GLOBALS['locPrintInvoiceRowTypeAll']; ?> </div> <div class="medium_label"></div> <div class="field"><input type="radio" name="row_types" value="normal"<?php if ($rowTypes == 'normal') { echo ' checked="checked"'; } ?> ><?php echo $GLOBALS['locPrintInvoiceRowTypeNormal']; ?> </div> <div class="medium_label"></div> <div class="field"><input type="radio" name="row_types" value="reminder"<?php if ($rowTypes == 'reminder') { echo ' checked="checked"'; } ?> ><?php echo $GLOBALS['locPrintInvoiceRowTypeReminder']; ?> </div> <div class="field_sep"></div> <div class="medium_label"><?php echo $GLOBALS['locPrintGrouping']; ?> </div> <div class="field"><input type="radio" name="grouping" value=""<?php if ($grouping == '') { echo ' checked="checked"'; } ?> ><?php echo $GLOBALS['locPrintGroupingNone']; ?> </div> <div class="medium_label"></div> <div class="field"><input type="radio" name="grouping" value="state"<?php if ($grouping == 'state') { echo ' checked="checked"'; } ?> ><?php echo $GLOBALS['locPrintGroupingState']; ?> </div> <div class="medium_label"></div> <div class="field"><input type="radio" name="grouping" value="month"<?php if ($grouping == 'month') { echo ' checked="checked"'; } ?> ><?php echo $GLOBALS['locPrintGroupingMonth']; ?> </div> <div class="medium_label"></div> <div class="field"><input type="radio" name="grouping" value="client"<?php if ($grouping == 'client') { echo ' checked="checked"'; } ?> ><?php echo $GLOBALS['locPrintGroupingClient']; ?> </div> <div class="field_sep"> </div> </div> <div style="float: left; margin-right: 20px;"> <div class="medium_label"><?php echo $GLOBALS['locPrintReportStates']; ?> </div> <?php $strQuery = "SELECT id, name " . "FROM {prefix}invoice_state WHERE deleted=0 " . "ORDER BY order_no"; $intRes = mysqli_query_check($strQuery); $first = true; while ($row = mysqli_fetch_assoc($intRes)) { $intStateId = $row['id']; $strStateName = isset($GLOBALS['loc' . $row['name']]) ? $GLOBALS['loc' . $row['name']] : $row['name']; $tmpSelected = getRequest("stateid_{$intStateId}", TRUE) ? TRUE : false; $strChecked = $tmpSelected ? ' checked' : ''; if (!$first) { echo " <div class=\"medium_label\"></div>\n"; } $first = false; ?> <div class="field"><input type="checkbox" name="stateid_<?php echo $intStateId; ?> " value="1"<?php echo $strChecked; ?> > <?php echo htmlspecialchars($strStateName); ?> </div> <?php } ?> </div> <div style="float: left"> <div class="medium_label"><?php echo $GLOBALS['locPrintFields']; ?> </div> <?php $first = true; foreach ($this->fields as $field => $spec) { $label = $GLOBALS[$spec['label']]; $checked = $spec['checked'] ? 'checked="checked"' : ''; if (!$first) { echo " <div class=\"medium_label\"></div>\n"; } ?> <div class="field"><input type="checkbox" name="fields[]" value="<?php echo $field; ?> " <?php echo $checked; ?> > <?php echo $label; ?> </div> <?php $first = false; } ?> </div> <div class="medium_label"> <a class="actionlink" href="#" onclick="document.getElementById('params').submit(); return false;"><?php echo $GLOBALS['locCreateReport']; ?> </a> </div> </form> </div> <?php }
function createIForm($astrFormElements, $elem, $intKeyValue, $newRecord, $strForm) { ?> <div class="iform <?php echo $elem['style']; ?> ui-corner-tl ui-corner-bl ui-corner-br ui-corner-tr ui-helper-clearfix" id="<?php echo $elem['name']; ?> "<?php echo $elem['elem_attributes'] ? ' ' . $elem['elem_attributes'] : ''; ?> > <div class="ui-corner-tl ui-corner-tr fg-toolbar ui-toolbar ui-widget-header"><?php echo $elem['label']; ?> </div> <?php if ($newRecord) { ?> <div id="inewmessage" class="new_message"><?php echo $GLOBALS['locSaveRecordToAddRows']; ?> </div> </div> <?php return; } ?> <script type="text/javascript"> /* <![CDATA[ */ function format_currency(value, decimals) { var s = parseFloat(value).toFixed(decimals).replace('.', '<?php echo $GLOBALS['locDecimalSeparator']; ?> '); <?php if ($GLOBALS['locThousandSeparator']) { ?> var parts = s.split('<?php echo $GLOBALS['locDecimalSeparator']; ?> '); var regexp = /(\d+)(\d{3})<?php echo $GLOBALS['locDecimalSeparator']; ?> ?/; while (regexp.test(parts[0])) { parts[0] = parts[0].replace(regexp, '$1' + '<?php echo $GLOBALS['locThousandSeparator']; ?> ' + '$2'); } s = parts[0]; if (parts.length > 1) { s += '<?php echo $GLOBALS['locDecimalSeparator']; ?> ' + parts[1]; } <?php } ?> return s; } function round_number(num, dec) { return Math.round(num * Math.pow(10, dec)) / Math.pow(10, dec); } function init_rows() { <?php $subFormElements = getFormElements($elem['name']); $rowSumColumns = getFormRowSumColumns($elem['name']); $strParentKey = getFormParentKey($elem['name']); $clearRowValuesAfterAdd = getFormClearRowValuesAfterAdd($elem['name']); $onAfterRowAdded = getFormOnAfterRowAdded($elem['name']); $formJSONType = getFormJSONType($elem['name']); foreach ($subFormElements as $subElem) { if ($subElem['type'] != 'LIST') { continue; } echo ' var arr_' . $subElem['name'] . ' = {"0":"-"'; $res = mysqli_query_check($subElem['listquery']); $translate = strstr($subElem['style'], ' translated'); while ($row = mysqli_fetch_row($res)) { if ($translate && isset($GLOBALS["loc{$row[1]}"])) { $row[1] = $GLOBALS["loc{$row[1]}"]; } echo ',' . $row[0] . ':"' . addcslashes($row[1], '\\"\\/') . '"'; } echo "};\n"; } ?> $.getJSON('json.php?func=get_<?php echo $elem['name']; ?> &parent_id=<?php echo $intKeyValue; ?> ', function(json) { $('#itable > tbody > tr[id!=form_row]').remove(); var table = document.getElementById('itable'); for (var i = 0; i < json.records.length; i++) { var record = json.records[i]; var tr = $('<tr/>'); <?php foreach ($subFormElements as $subElem) { if (in_array($subElem['type'], array('HID_INT', 'SECHID_INT', 'BUTTON', 'NEWLINE'))) { continue; } $name = $subElem['name']; $class = $subElem['style']; if ($subElem['type'] == 'LIST' || $subElem['type'] == 'SEARCHLIST') { echo " if (record.{$name} == null) record.{$name} = 0; \$('<td/>').addClass('{$class}' + (record.deleted == 1 ? ' deleted' : '')).text(record.{$name}_text).appendTo(tr);\n"; } elseif ($subElem['type'] == 'INT') { if (isset($subElem['decimals'])) { echo " \$('<td/>').addClass('{$class}' + (record.deleted == 1 ? ' deleted' : '')).text(record.{$name} ? format_currency(record.{$name}, {$subElem['decimals']}) : '').appendTo(tr);\n"; } else { echo " \$('<td/>').addClass('{$class}' + (record.deleted == 1 ? ' deleted' : '')).text(record.{$name} ? record.{$name}.replace('.', '{$GLOBALS['locDecimalSeparator']}') : '').appendTo(tr);\n"; } } elseif ($subElem['type'] == 'INTDATE') { echo " \$('<td/>').addClass('{$class}' + (record.deleted == 1 ? ' deleted' : '')).text(record.{$name}.substr(6, 2) + '.' + record.{$name}.substr(4, 2) + '.' + record.{$name}.substr(0, 4)).appendTo(tr);\n"; } elseif ($subElem['type'] == 'CHECK') { echo " \$('<td/>').addClass('{$class}' + (record.deleted == 1 ? ' deleted' : '')).text(record.{$name} == 1 ? \"" . $GLOBALS['locYesButton'] . '" : "' . $GLOBALS['locNoButton'] . "\").appendTo(tr);\n"; } elseif ($subElem['type'] == 'ROWSUM') { ?> var items = record.<?php echo $rowSumColumns['multiplier']; ?> ; var price = record.<?php echo $rowSumColumns['price']; ?> ; var discount = record.<?php echo $rowSumColumns['discount']; ?> || 0; var VATPercent = record.<?php echo $rowSumColumns['vat']; ?> ; var VATIncluded = record.<?php echo $rowSumColumns['vat_included']; ?> ; price *= (1 - discount / 100); var sum = 0; var sumVAT = 0; var VAT = 0; if (VATIncluded == 1) { sumVAT = round_number(items * price, 2); sum = round_number(sumVAT / (1 + VATPercent / 100), 2); VAT = sumVAT - sum; } else { sum = round_number(items * price, 2); VAT = round_number(sum * (VATPercent / 100), 2); sumVAT = sum + VAT; } sum = format_currency(sum, <?php echo isset($subElem['decimals']) ? $subElem['decimals'] : 2; ?> ); VAT = format_currency(VAT, <?php echo isset($subElem['decimals']) ? $subElem['decimals'] : 2; ?> ); sumVAT = format_currency(sumVAT, <?php echo isset($subElem['decimals']) ? $subElem['decimals'] : 2; ?> ); var title = '<?php echo $GLOBALS['locVATLess'] . ': '; ?> ' + sum + ' – ' + '<?php echo $GLOBALS['locVATPart'] . ': '; ?> ' + VAT; $('<td/>').addClass('<?php echo $class; ?> ' + (record.deleted == 1 ? ' deleted' : '')).append('<span title="' + title + '">' + sumVAT + '<\/span>').appendTo(tr); <?php } else { echo " \$('<td/>').addClass('{$class}' + (record.deleted == 1 ? ' deleted' : '')).text(record.{$name} ? record.{$name} : '').appendTo(tr);\n"; } } if (sesWriteAccess()) { ?> $('<td/>').addClass('button').append('<a class="tinyactionlink row_edit_button rec' + record.id + '" href="#"><?php echo $GLOBALS['locEdit']; ?> <\/a>').appendTo(tr); $('<td/>').addClass('button').append('<a class="tinyactionlink row_copy_button rec' + record.id + '" href="#"><?php echo $GLOBALS['locCopy']; ?> <\/a>').appendTo(tr); <?php } ?> $(table).append(tr); } <?php if (isset($rowSumColumns['show_summary']) && $rowSumColumns['show_summary']) { ?> var totSum = 0; var totVAT = 0; var totSumVAT = 0; for (var i = 0; i < json.records.length; i++) { var record = json.records[i]; var items = record.<?php echo $rowSumColumns['multiplier']; ?> ; var price = record.<?php echo $rowSumColumns['price']; ?> ; var discount = record.<?php echo $rowSumColumns['discount']; ?> || 0; var VATPercent = record.<?php echo $rowSumColumns['vat']; ?> ; var VATIncluded = record.<?php echo $rowSumColumns['vat_included']; ?> ; price *= (1 - discount / 100); var sum = 0; var sumVAT = 0; var VAT = 0; if (VATIncluded == 1) { sumVAT = round_number(items * price, 2); sum = round_number(sumVAT / (1 + VATPercent / 100), 2); VAT = sumVAT - sum; } else { sum = round_number(items * price, 2); VAT = round_number(sum * (VATPercent / 100), 2); sumVAT = sum + VAT; } totSum += sum; totVAT += VAT; totSumVAT += sumVAT; } var tr = $('<tr/>').addClass('summary'); $('<td/>').addClass('input').attr('colspan', '10').attr('align', 'right').text('<?php echo $GLOBALS['locTotalExcludingVAT']; ?> ').appendTo(tr); $('<td/>').addClass('input').attr('align', 'right').text(format_currency(totSum, 2)).appendTo(tr); $(table).append(tr); tr = $('<tr/>').addClass('summary'); $('<td/>').addClass('input').attr('colspan', '10').attr('align', 'right').text('<?php echo $GLOBALS['locTotalVAT']; ?> ').appendTo(tr); $('<td/>').addClass('input').attr('align', 'right').text(format_currency(totVAT, 2)).appendTo(tr); $(table).append(tr); var tr = $('<tr/>').addClass('summary'); $('<td/>').addClass('input').attr('colspan', '10').attr('align', 'right').text('<?php echo $GLOBALS['locTotalIncludingVAT']; ?> ').appendTo(tr); $('<td/>').addClass('input').attr('align', 'right').text(format_currency(totSumVAT, 2)).appendTo(tr); $(table).append(tr); <?php } ?> $('a[class~="row_edit_button"]').click(function(event) { var row_id = $(this).attr('class').match(/rec(\d+)/)[1]; popup_editor(event, '<?php echo $GLOBALS['locRowModification']; ?> ', row_id, false); return false; }); $('a[class~="row_copy_button"]').click(function(event) { var row_id = $(this).attr('class').match(/rec(\d+)/)[1]; popup_editor(event, '<?php echo $GLOBALS['locRowCopy']; ?> ', row_id, true); return false; }); $('a[class~="tinyactionlink"]').button(); init_rows_done(); }); } <?php if (sesWriteAccess()) { ?> function save_row(form_id) { var form = document.getElementById(form_id); var obj = new Object(); <?php foreach ($subFormElements as $subElem) { if (!in_array($subElem['type'], array('HID_INT', 'SECHID_INT', 'BUTTON', 'NEWLINE', 'ROWSUM', 'CHECK', 'INT'))) { ?> obj.<?php echo $subElem['name']; ?> = document.getElementById(form_id + '_<?php echo $subElem['name']; ?> ').value; <?php } elseif ($subElem['type'] == 'CHECK') { ?> obj.<?php echo $subElem['name']; ?> = document.getElementById(form_id + '_<?php echo $subElem['name']; ?> ').checked ? 1 : 0; <?php } elseif ($subElem['type'] == 'INT') { ?> obj.<?php echo $subElem['name']; ?> = document.getElementById(form_id + '_<?php echo $subElem['name']; ?> ').value.replace('<?php echo $GLOBALS['locDecimalSeparator']; ?> ', '.'); <?php } } ?> obj.<?php echo $elem['parent_key'] . " = {$intKeyValue}"; ?> ; if (form.row_id) obj.id = form.row_id.value; $.ajax({ 'url': "json.php?func=put_<?php echo $formJSONType; ?> ", 'type': 'POST', 'dataType': 'json', 'data': $.toJSON(obj), 'contentType': 'application/json; charset=utf-8', 'success': function(data) { if (data.missing_fields) { errormsg('<?php echo $GLOBALS['locErrValueMissing']; ?> : ' + data.missing_fields); } else { if (form_id == 'iform') $('.add_row_button').removeClass('ui-state-highlight'); init_rows(); if (form_id == 'iform_popup') $("#popup_edit").dialog('close'); if (!obj.id) { <?php echo $onAfterRowAdded; foreach ($subFormElements as $subElem) { if (!in_array($subElem['type'], array('HID_INT', 'SECHID_INT', 'BUTTON', 'NEWLINE', 'ROWSUM'))) { if (isset($subElem['default']) && strstr($subElem['default'], 'ADD')) { // The value is taken from whatever form was used but put into iform ?> var fld = document.getElementById(form_id + '_<?php echo $subElem['name']; ?> '); document.getElementById('iform_<?php echo $subElem['name']; ?> ').value = parseInt(fld.value) + 5; <?php } elseif ($clearRowValuesAfterAdd && $subElem['type'] != 'INTDATE') { if ($subElem['type'] == 'LIST' || $subElem['type'] == 'SEARCHLIST') { ?> document.getElementById('iform_<?php echo $subElem['name']; ?> ').selectedIndex = 0; <?php } elseif ($subElem['type'] == 'CHECK') { ?> document.getElementById('iform_<?php echo $subElem['name']; ?> ').checked = 0; <?php } else { ?> document.getElementById('iform_<?php echo $subElem['name']; ?> ').value = ''; <?php } } } } ?> } } }, 'error': function(XMLHTTPReq, textStatus, errorThrown) { if (textStatus == 'timeout') alert('Timeout trying to save row'); else alert('Error trying to save row: ' + XMLHTTPReq.status + ' - ' + XMLHTTPReq.statusText); return false; } }); } function update_row_dates(id) { var buttons = new Object(); buttons["<?php echo $GLOBALS['locUpdateRowDates']; ?> "] = function() { var date = $("#popup_date_edit_field").val(); if (date == '') { alert('<?php echo $GLOBALS['locErrValueMissing']; ?> '); return; } var params = { func: 'update_invoice_row_dates', id: <?php echo $intKeyValue; ?> , date: date }; $.ajax({ 'url': 'json.php', 'data': params, 'type': 'GET', 'dataType': 'json', 'contentType': 'application/json; charset=utf-8', 'success': function(data) { if (data.status != 'ok') { alert(data.errors); } else { $("#popup_date_edit").dialog('close'); init_rows(); } }, 'error': function(XMLHTTPReq, textStatus, errorThrown) { if (textStatus == 'timeout') errormsg('Timeout trying to update row dates'); else errormsg('Error trying to update row dates: ' + XMLHTTPReq.status + ' - ' + XMLHTTPReq.statusText); return false; } }); }; buttons["<?php echo $GLOBALS['locClose']; ?> "] = function() { $("#popup_date_edit").dialog('close'); }; $("#popup_date_edit").dialog({ modal: true, width: 420, height: 120, resizable: false, buttons: buttons, title: '<?php echo $GLOBALS['locUpdateAllRowDates']; ?> ' }); } function delete_row(form_id) { var form = document.getElementById(form_id); var id = form.row_id.value; $.ajax({ 'url': "json.php?func=delete_<?php echo $formJSONType; ?> &id=" + id, 'type': 'GET', 'dataType': 'json', 'contentType': 'application/json; charset=utf-8', 'success': function(data) { init_rows(); if (form_id == 'iform_popup') $("#popup_edit").dialog('close'); }, 'error': function(XMLHTTPReq, textStatus, errorThrown) { if (textStatus == 'timeout') errormsg('Timeout trying to save row'); else errormsg('Error trying to save row: ' + XMLHTTPReq.status + ' - ' + XMLHTTPReq.statusText); return false; } }); } function popup_editor(event, title, id, copy_row) { $.getJSON('json.php?func=get_<?php echo $formJSONType; ?> &id=' + id, function(json) { if (!json.id) return; var form = document.getElementById('iform_popup'); if (copy_row) form.row_id.value = ''; else form.row_id.value = id; <?php foreach ($subFormElements as $subElem) { if (in_array($subElem['type'], array('HID_INT', 'SECHID_INT', 'BUTTON', 'NEWLINE', 'ROWSUM'))) { continue; } $name = $subElem['name']; if ($subElem['type'] == 'SEARCHLIST') { ?> var item = { id: json.<?php echo $name; ?> , text: json.<?php echo $name; ?> _text }; $('#<?php echo "iform_popup_{$name}"; ?> ').select2('data', item); <?php } elseif ($subElem['type'] == 'LIST') { ?> for (var i = 0; i < form.<?php echo "iform_popup_{$name}"; ?> .options.length; i++) { var item = form.<?php echo "iform_popup_{$name}"; ?> .options[i]; if (item.value == json.<?php echo $name; ?> ) { item.selected = true; break; } } <?php } elseif ($subElem['type'] == 'INT') { if (isset($subElem['default']) && strstr($subElem['default'], 'ADD')) { ?> var value; if (copy_row) value = document.getElementById('<?php echo "iform_{$name}"; ?> ').value; else value = json.<?php echo $name; ?> ? json.<?php echo $name; ?> .replace('.', '<?php $GLOBALS['locDecimalSeparator']; ?> ') : ''; form.<?php echo "iform_popup_{$name}"; ?> .value = value; <?php } else { if (isset($subElem['decimals'])) { ?> form.<?php echo "iform_popup_{$name}"; ?> .value = json.<?php echo $name; ?> ? format_currency(json.<?php echo $name; ?> , <?php echo $subElem['decimals']; ?> ) : ''; <?php } else { ?> form.<?php echo "iform_popup_{$name}"; ?> .value = json.<?php echo $name; ?> ? json.<?php echo $name; ?> .replace('.', '<?php echo $GLOBALS['locDecimalSeparator']; ?> ') : ''; <?php } } } elseif ($subElem['type'] == 'INTDATE') { ?> form.<?php echo "iform_popup_{$name}"; ?> .value = json.<?php echo $name; ?> ? json.<?php echo $name; ?> .substr(6, 2) + '.' + json.<?php echo $name; ?> .substr(4, 2) + '.' + json.<?php echo $name; ?> .substr(0, 4) : ''; <?php } elseif ($subElem['type'] == 'CHECK') { ?> form.<?php echo "iform_popup_{$name}"; ?> .checked = json.<?php echo $name; ?> != 0 ? true : false; <?php } else { ?> form.<?php echo "iform_popup_{$name}"; ?> .value = json.<?php echo $name; ?> ; <?php } } ?> var buttons = new Object(); buttons["<?php echo $GLOBALS['locSave']; ?> "] = function() { save_row('iform_popup'); }; if (!copy_row) buttons["<?php echo $GLOBALS['locDelete']; ?> "] = function() { if(confirm('<?php echo $GLOBALS['locConfirmDelete']; ?> ')==true) { delete_row('iform_popup'); } return false; }; buttons["<?php echo $GLOBALS['locClose']; ?> "] = function() { $("#popup_edit").dialog('close'); }; $("#popup_edit").dialog({ modal: true, width: 840, height: 150, resizable: false, buttons: buttons, title: title, }); }); } <?php } ?> /* ]]> */ </script> <form method="post" name="iform" id="iform"> <table class="iform" id="itable"> <thead> <tr> <?php foreach ($subFormElements as $subElem) { if (!in_array($subElem['type'], array('HID_INT', 'SECHID_INT', 'BUTTON', 'NEWLINE'))) { ?> <th class="label ui-state-default <?php echo strtolower($subElem['style']); ?> _label"><?php echo $subElem['label']; ?> </th> <?php } } ?> </tr> </thead> <tbody> <?php if (sesWriteAccess()) { ?> <tr id="form_row"> <?php foreach ($subFormElements as $subElem) { if (!in_array($subElem['type'], array('HID_INT', 'SECHID_INT', 'BUTTON', 'NEWLINE', 'ROWSUM'))) { $value = getFormDefaultValue($subElem, $intKeyValue); ?> <td class="label <?php echo strtolower($subElem['style']); ?> _label"> <?php echo htmlFormElement('iform_' . $subElem['name'], $subElem['type'], $value, $subElem['style'], $subElem['listquery'], 'MODIFY', 0, '', array(), $subElem['elem_attributes']); ?> </td> <?php } elseif ($subElem['type'] == 'ROWSUM') { ?> <td class="label <?php echo strtolower($subElem['style']); ?> _label"> </td> <?php } } if ($strForm == 'invoice') { ?> <td class="button"> <a class="tinyactionlink add_row_button" href="#" onclick="save_row('iform'); return false;"><?php echo $GLOBALS['locAddRow']; ?> </a> </td> <td class="button"> <a class="tinyactionlink update_row_dates" href="#" onclick="update_row_dates(); return false;"><?php echo $GLOBALS['locUpdateRowDates']; ?> </a> </td> <?php } else { ?> <td class="button" colspan="2"> <a class="tinyactionlink add_row_button" href="#" onclick="save_row('iform'); return false;"><?php echo $GLOBALS['locAddRow']; ?> </a> </td> <?php } ?> </tr> </tbody> </table> </form> </div> <div id="popup_edit" style="display: none; width: 900px; overflow: hidden"> <form method="post" name="iform_popup" id="iform_popup"> <input type="hidden" name="row_id" value=""> <input type="hidden" name="<?php echo $strParentKey; ?> " value="<?php echo $intKeyValue; ?> "> <table class="iform"> <tr> <?php foreach ($subFormElements as $elem) { if (!in_array($elem['type'], array('HID_INT', 'SECHID_INT', 'BUTTON', 'NEWLINE', 'ROWSUM'))) { ?> <td class="label <?php echo strtolower($elem['style']); ?> _label"> <?php echo $elem['label']; ?> <br> <?php echo htmlFormElement('iform_popup_' . $elem['name'], $elem['type'], '', $elem['style'], $elem['listquery'], 'MODIFY', 0, '', array(), $elem['elem_attributes']); ?> </td> <?php } elseif ($elem['type'] == 'SECHID_INT') { ?> <input type="hidden" name="<?php echo 'iform_popup_' . $elem['name']; ?> " value="<?php echo gpcStripSlashes($astrValues[$elem['name']]); ?> "> <?php } elseif ($elem['type'] == 'BUTTON') { ?> <td class="label"> </td> <?php } } } ?> </tr> </table> </form> </div> <div id="popup_date_edit" style="display: none; width: 300px; overflow: hidden"> <form method="post" name="form_date_popup" id="form_date_popup"> <input id="popup_date_edit_field" type="text" class="medium hasCalendar"> </form> </div> <?php }
public function createReport() { $strReport = getRequest('report', ''); if ($strReport) { $this->printReport(); return; } $intBaseId = getRequest('base', FALSE); $intCompanyId = getRequest('company', FALSE); $intProductId = getRequest('product', FALSE); $dateRange = getRequest('date', ''); ?> <script type="text/javascript"> $(document).ready(function() { $('input[class~="hasDateRangePicker"]').daterangepicker(<?php echo $GLOBALS['locDateRangePickerOptions']; ?> ); }); </script> <div class="form_container ui-widget-content ui-helper-clearfix"> <form method="get" id="params" name="params"> <input name="func" type="hidden" value="reports"> <input name="form" type="hidden" value="product"> <input name="report" type="hidden" value="1"> <div class="unlimited_label"> <h1><?php echo $GLOBALS['locProductReport']; ?> </h1> </div> <div class="medium_label"><?php echo $GLOBALS['locInvoiceDateInterval']; ?> </div> <div class="field"><?php echo htmlFormElement('date', 'TEXT', "{$dateRange}", 'medium hasDateRangePicker', '', 'MODIFY', FALSE); ?> </div> <div class="medium_label"><?php echo $GLOBALS['locBiller']; ?> </div> <div class="field"><?php echo htmlFormElement('base', 'LIST', $intBaseId, 'medium', 'SELECT id, name FROM {prefix}base WHERE deleted=0 ORDER BY name', 'MODIFY', FALSE); ?> </div> <div class="medium_label"><?php echo $GLOBALS['locClient']; ?> </div> <div class="field"><?php echo htmlFormElement('company', 'LIST', $intCompanyId, 'medium', 'SELECT id, company_name FROM {prefix}company WHERE deleted=0 ORDER BY company_name', 'MODIFY', FALSE); ?> </div> <div class="medium_label"><?php echo $GLOBALS['locProduct']; ?> </div> <div class="field"><?php echo htmlFormElement('product', 'LIST', $intProductId, 'medium', 'SELECT id, product_name FROM {prefix}product WHERE deleted=0 ORDER BY product_name', 'MODIFY', FALSE); ?> </div> <div class="medium_label"><?php echo $GLOBALS['locPrintFormat']; ?> </div> <div class="field"> <input type="radio" name="format" value="html" checked="checked"><?php echo $GLOBALS['locPrintFormatHTML']; ?> </input> </div> <div class="medium_label"></div> <div class="field"> <input type="radio" name="format" value="pdf"><?php echo $GLOBALS['locPrintFormatPDF']; ?> </input> </div> <div class="field_sep"></div> <div class="medium_label"><?php echo $GLOBALS['locPrintReportStates']; ?> </div> <?php $strQuery = 'SELECT id, name ' . 'FROM {prefix}invoice_state WHERE deleted=0 ' . 'ORDER BY order_no'; $intRes = mysqli_query_check($strQuery); $first = true; while ($row = mysqli_fetch_assoc($intRes)) { $intStateId = $row['id']; $strStateName = isset($GLOBALS['loc' . $row['name']]) ? $GLOBALS['loc' . $row['name']] : $row['name']; $tmpSelected = getRequest("stateid_{$intStateId}", TRUE) ? TRUE : false; $strChecked = $tmpSelected ? ' checked' : ''; if (!$first) { echo " <div class=\"medium_label\"></div>\n"; } $first = false; ?> <div class="field"> <input type="checkbox" name="stateid_<?php echo $intStateId; ?> " value="1" <?php echo $strChecked; ?> > <?php echo htmlspecialchars($strStateName); ?> </div> <?php } ?> <div class="medium_label"> <a class="actionlink" href="#" onclick="document.getElementById('params').submit(); return false;"><?php echo $GLOBALS['locCreateReport']; ?> </a> </div> </form> </div> <?php }
} ?> <tr class="search_row"> <td class="label"> <?php echo $astrFormElements[$j]['label']; ?> </td> <td class="field"> <?php echo htmlListBox('searchmatch_' . $astrFormElements[$j]['name'], $comparisonValues, $strSearchMatch, '', 0); ?> </td> <td class="field"> <?php echo htmlFormElement($astrFormElements[$j]['name'], $astrFormElements[$j]['type'], $astrValues[$astrFormElements[$j]['name']], $astrFormElements[$j]['style'], $astrFormElements[$j]['listquery'], 'MODIFY', $astrFormElements[$j]['parent_key'], '', [], '', isset($astrFormElements[$j]['options']) ? $astrFormElements[$j]['options'] : NULL); ?> </td> <td><input type="hidden" name="delete_<?php echo $astrFormElements[$j]['name']; ?> _x" value="0"> <a class="tinyactionlink" href="#" title="<?php echo $GLOBALS['locDelRow']; ?> " onclick="self.document.forms[0].delete_<?php echo $astrFormElements[$j]['name']; ?>
function createSettingsList() { if (!sesAdminAccess()) { ?> <div class="form_container ui-widget-content"> <?php echo $GLOBALS['locNoAccess'] . "\n"; ?> </div> <?php return; } require 'settings_def.php'; $messages = ''; $blnSave = getPostRequest('saveact', FALSE) ? TRUE : FALSE; if ($blnSave) { foreach ($arrSettings as $name => $elem) { $type = $elem['type']; $label = $elem['label']; if ($type == 'LABEL') { continue; } $newValue = getPost($name, NULL); if (!isset($newValue) || $newValue === '') { if (!$elem['allow_null']) { $messages .= $GLOBALS['locErrValueMissing'] . ": '{$label}'<br>\n"; continue; } else { $newValue = ''; } } if (in_array($type, array('CURRENCY', 'PERCENT'))) { $newValue = str_replace($GLOBALS['locDecimalSeparator'], '.', $newValue); } if (in_array($type, array('CURRENCY', 'PERCENT', 'INT'))) { $newValue = trim($newValue); if (!is_numeric($newValue)) { $messages .= $GLOBALS['locErrInvalidValue'] . " '{$label}'<br>\n"; continue; } } if (isset($elem['session']) && $elem['session']) { $_SESSION[$name] = $newValue; } mysqli_param_query('DELETE from {prefix}settings WHERE name=?', array($name)); mysqli_param_query('INSERT INTO {prefix}settings (name, value) VALUES (?, ?)', array($name, $newValue)); } } ?> <div class="form_container ui-widget-content"> <?php if ($messages) { ?> <div class="ui-widget ui-state-error"><?php echo $messages; ?> </div> <?php } ?> <script type="text/javascript"> <!-- $(document).ready(function() { $('input[class~="hasCalendar"]').datepicker(); $('iframe[class~="resizable"]').load(function() { var iframe = $(this); var body = iframe.contents().find("body"); var newHeight = body.outerHeight(true) + 10; // Leave room for calendar popup if (newHeight < 250) newHeight = 250; iframe.css("height", newHeight + 'px'); body.css("overflow", "hidden"); }); $('#admin_form').find('input[type="text"],input[type="checkbox"],select,textarea').change(function() { $('.save_button').addClass('unsaved'); }); }); --> </script> <?php createSettingsListButtons(); ?> <div class="form"> <form method="post" name="admin_form" id="admin_form"> <?php foreach ($arrSettings as $name => $elem) { $elemType = $elem['type']; if ($elemType == 'LABEL') { ?> <div class="sublabel ui-widget-header ui-state-default"><?php echo $elem['label']; ?> </div> <?php continue; } $value = getPost($name, NULL); if (!isset($value)) { if (isset($elem['session']) && $elem['session']) { $value = isset($_SESSION[$name]) ? $_SESSION[$name] : (isset($elem['default']) ? cond_utf8_decode($elem['default']) : ''); } else { $res = mysqli_param_query('SELECT value from {prefix}settings WHERE name=?', array($name)); if ($row = mysqli_fetch_assoc($res)) { $value = $row['value']; } else { $value = isset($elem['default']) ? cond_utf8_decode($elem['default']) : ''; } } if ($elemType == 'CURRENCY') { $value = miscRound2Decim($value); } elseif ($elemType == 'PERCENT') { $value = miscRound2Decim($value, 1); } } if ($elemType == 'CURRENCY' || $elemType == 'PERCENT') { $elemType = 'INT'; } if ($elemType == 'CHECK') { ?> <div class="field" style="clear: both"> <?php echo htmlFormElement($name, $elemType, $value, $elem['style'], '', "MODIFY", '', '', array(), isset($elem['elem_attributes']) ? $elem['elem_attributes'] : '', isset($elem['options']) ? $elem['options'] : null); ?> <label for="<?php echo $name; ?> "><?php echo $elem['label']; ?> </label> </div> <?php } else { ?> <div class="label" style="clear: both"><label for="<?php echo $name; ?> "><?php echo $elem['label']; ?> </label></div> <div class="field" style="clear: both"> <?php echo htmlFormElement($name, $elemType, $value, $elem['style'], '', "MODIFY", '', '', array(), isset($elem['elem_attributes']) ? $elem['elem_attributes'] : '', isset($elem['options']) ? $elem['options'] : null); ?> </div> <?php } } ?> <input type="hidden" name="saveact" value="0"> <?php createSettingsListButtons(); ?> </form> </div> </div> <?php }