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 }
protected function process_import_row($table, $row, $dupMode, $dupCheckColumns, $mode, &$addedRecordId) { global $dblink; $sep = getRequest('decimal_separator', ','); if ($sep != '.') { $fieldDefs = getFormElements($table); foreach ($row as $key => &$value) { foreach ($fieldDefs as $fieldDef) { if ($fieldDef['name'] === $key) { if ($fieldDef['type'] == 'INT' && in_array($fieldDef['style'], ['percent', 'currency'])) { $value = str_replace($sep, '.', $value); } break; } } } } $result = ''; $recordId = null; if ($dupMode != '' && count($dupCheckColumns) > 0) { $query = "select id from {prefix}{$table} where Deleted=0"; $where = ''; $params = []; foreach ($dupCheckColumns as $dupCol) { $where .= " AND {$dupCol}=?"; $params[] = $row[$dupCol]; } $res = mysqli_param_query($query . $where, $params); if ($dupRow = mysqli_fetch_row($res)) { $id = $dupRow[0]; $found_dup = true; if ($dupMode == 'update') { $result = "Update existing row id {$id} in table {$table}"; } else { $result = "Not updating existing row id {$id} in table {$table}"; } if ($mode == 'import' && $dupMode == 'update') { // Update existing row $query = "UPDATE {prefix}{$table} SET "; $columns = ''; $params = []; foreach ($row as $key => $value) { if ($key == 'id') { continue; } if ($columns) { $columns .= ', '; } $columns .= "{$key}=?"; $params[] = $value; } $query .= "{$columns} WHERE id=?"; $params[] = $id; mysqli_param_query($query, $params); } return $result; } } // Add new row $query = "INSERT INTO {prefix}{$table} "; $columns = ''; $values = ''; $params = []; foreach ($row as $key => $value) { if ($key == 'id') { continue; } if ($columns) { $columns .= ', '; } if ($values) { $values .= ', '; } $columns .= $key; $values .= '?'; $params[] = $value; } $query .= "({$columns}) VALUES ({$values})"; if ($mode == 'import') { mysqli_param_query($query, $params); $addedRecordId = mysqli_insert_id($dblink); } else { $addedRecordId = 'x'; } $result = "Add as new (ID {$addedRecordId}) into table {$table}"; return $result; }
function actualizarFax($smarty, $module_name, $local_templates_dir) { $smarty->assign(array('CANCEL' => _tr('Cancel'), 'APPLY_CHANGES' => _tr('Apply changes'), 'REQUIRED_FIELD' => _tr('Required field'))); $idFax = getParameter('id'); if (isset($_POST['cancel']) || !ctype_digit("{$idFax}")) { header("Location: ?menu={$module_name}"); return; } $smarty->assign("id_fax", $idFax); $oFax = new paloFaxVisor(); if (isset($_POST['save'])) { if (empty($_POST['name_company']) || empty($_POST['fax_company'])) { $smarty->assign("mb_title", _tr('ERROR') . ":"); $smarty->assign("mb_message", _tr('ERROR')); } elseif (!$oFax->updateInfoFaxFromDB($idFax, $_POST['name_company'], $_POST['fax_company'])) { $smarty->assign("mb_title", _tr('ERROR') . ":"); $smarty->assign("mb_message", _tr('ERROR')); } else { header("Location: ?menu={$module_name}"); return; } } $arrDataFax = $oFax->obtener_fax($idFax); if (is_array($arrDataFax) && count($arrDataFax) > 0) { if (!isset($_POST['name_company'])) { $_POST['name_company'] = $arrDataFax['company_name']; } if (!isset($_POST['fax_company'])) { $_POST['fax_company'] = $arrDataFax['company_fax']; } } $oForm = new paloForm($smarty, getFormElements()); $htmlForm = $oForm->fetchForm("{$local_templates_dir}/edit.tpl", _tr('Edit'), $_POST); return "<form method='POST' style='margin-bottom:0;' action='?menu={$module_name}&action=edit'>" . $htmlForm . "</form>"; }
function actualizarFax($smarty, $module_name, $local_templates_dir, $pDB, $credentials) { $smarty->assign(array('CANCEL' => _tr('Cancel'), 'APPLY_CHANGES' => _tr('Apply changes'), 'REQUIRED_FIELD' => _tr('Required field'))); $idFax = getParameter('id'); if (isset($_POST['cancel']) || !ctype_digit("{$idFax}")) { header("Location: ?menu={$module_name}"); return; } $oFax = new paloFaxVisor($pDB); if (empty($idFax)) { $smarty->assign("mb_title", _tr('ERROR')); $smarty->assign("mb_message", _tr('Invalid Fax')); return listarFaxes($smarty, $module_name, $local_templates_dir, $pDB, $credentials); } if ($credentials['userlevel'] != 'superadmin') { if (!$oFax->fax_bellowOrganization($idFax, $credentials['id_organization'])) { $smarty->assign("mb_title", _tr('ERROR') . ":"); $smarty->assign("mb_message", _tr("Invalid Fax")); return listarFaxes($smarty, $module_name, $local_templates_dir, $pDB, $credentials); } } if (isset($_POST['save'])) { if (!$oFax->updateInfoFaxFromDB($idFax, $_POST['name_company'], $_POST['fax_company'])) { $smarty->assign("mb_title", _tr('ERROR')); $smarty->assign("mb_message", _tr($oFax->errMsg)); } else { $smarty->assign("mb_title", _tr('MESSAGE')); $smarty->assign("mb_message", _tr("Changes were applied successfully")); return listarFaxes($smarty, $module_name, $local_templates_dir, $pDB, $credentials); } } $smarty->assign("id_fax", $idFax); $arrDataFax = $oFax->obtener_fax($idFax); if (is_array($arrDataFax) && count($arrDataFax) > 0) { if (!isset($_POST['name_company'])) { $_POST['name_company'] = $arrDataFax['company_name']; } if (!isset($_POST['fax_company'])) { $_POST['fax_company'] = $arrDataFax['company_fax']; } } else { $smarty->assign("mb_title", _tr('ERROR')); $smarty->assign("mb_message", _tr('Fax does not exist')); return listarFaxes($smarty, $module_name, $local_templates_dir, $pDB, $credentials); } $oForm = new paloForm($smarty, getFormElements(array())); $htmlForm = $oForm->fetchForm("{$local_templates_dir}/edit.tpl", _tr('Edit'), $_POST); return "<form method='POST' style='margin-bottom:0;' action='?menu={$module_name}&action=edit'>" . $htmlForm . "</form>"; }