function build_form_html($action, $id = '') { global $db, $currencies; require_once DIR_FS_MODULES . 'phreepos/classes/tills.php'; require_once DIR_FS_MODULES . 'phreepos/defaults.php'; if ($action != 'new' && $this->error == false) { $sql = "select * from " . $this->db_table . " where ot_id = " . $id; $result = $db->Execute($sql); foreach ($result->fields as $key => $value) { $this->{$key} = $value; } } $tills = new tills(); $output = "<script type='text/javascript'>\n\t\t\t\t\t\t\$(document).ready(function(){\n\t\t\t\t\t\t\tchangeOfType();\n\t\t\t\t\t\t});\n\t\t\n\t\t\t\t\t\tfunction changeOfType(){\n\t\t\t\t\t\t\tvar elt = document.getElementById('type');\n\t\t\t\t\t\t\tif(elt.options[elt.selectedIndex].value == 'expenses'){\n\t\t\t\t\t\t\t\t\$('#use_tax_row').show();\n\t\t\t\t\t\t\t\t\$('#tax_row').show();\n\t\t\t\t\t\t\t}else{\n\t\t\t\t\t\t\t\t\$('#use_tax_row').hide();\n\t\t\t\t\t\t\t\t\$('#tax_row').hide();\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t</script>"; $output .= '<table style="border-collapse:collapse;margin-left:auto; margin-right:auto;">' . chr(10); $output .= ' <thead class="ui-widget-header">' . "\n"; $output .= ' <tr>' . chr(10); $output .= ' <th colspan="2">' . ($action == 'new' ? TEXT_ENTER_NEW_OTHER_TRANSACTION : TEXT_EDIT_OTHER_TRANSACTION) . '</th>' . chr(10); $output .= ' </tr>' . chr(10); $output .= ' </thead>' . "\n"; $output .= ' <tbody class="ui-widget-content">' . "\n"; $output .= ' <tr>' . chr(10); $output .= ' <td>' . TEXT_DESCRIPTION . '</td>' . chr(10); $output .= ' <td>' . html_input_field('description', $this->description, 'size="16" maxlength="15"') . '</td>' . chr(10); $output .= ' </tr>' . chr(10); if ($tills->showDropDown()) { $output .= ' <tr>' . chr(10); $output .= ' <td>' . TEXT_TILLS . '</td>' . chr(10); $output .= ' <td>' . html_pull_down_menu('till_id', $tills->till_array(), $this->till_id ? $this->till_id : $tills->default_till()) . '</td>' . chr(10); $output .= ' </tr>' . chr(10); } else { $output .= html_hidden_field('till_id', $tills->default_till()); } //type change cash or expences. $output .= ' <tr>' . chr(10); $output .= ' <td>' . TEXT_PHREEPOS_TRANSACTION_TYPE . '</td>' . chr(10); $output .= ' <td>' . html_pull_down_menu('type', gen_build_pull_down($ot_options), $this->type, 'onchange="changeOfType();"') . '</td>' . chr(10); $output .= ' </tr>' . chr(10); $output .= ' <tr>' . chr(10); //gl account $output .= ' <tr>' . chr(10); $output .= ' <td>' . TEXT_GL_ACCOUNT . '</td>' . chr(10); $output .= ' <td>' . html_pull_down_menu('gl_acct_id', gen_coa_pull_down(SHOW_FULL_GL_NAMES, true, true, false, false), $this->gl_acct_id) . '</td>' . chr(10); $output .= ' </tr>' . chr(10); $output .= ' <tr>' . chr(10); //Only show this when it are expenses //use show tax $output .= ' <tr id="use_tax_row">' . chr(10); $output .= ' <td>' . TEXT_USE_TAX . '</td>' . chr(10); $output .= ' <td>' . html_checkbox_field('use_tax', '0', $this->use_tax) . '</td>' . chr(10); $output .= ' </tr>' . chr(10); //default tax $output .= ' <tr id="tax_row">' . chr(10); $output .= ' <td>' . TEXT_TAX . '</td>' . chr(10); $output .= ' <td>' . html_pull_down_menu('taxable', inv_calculate_tax_drop_down('v', false), $this->taxable) . '</td>' . chr(10); $output .= ' </tr>' . chr(10); $output .= ' <tr>' . chr(10); $output .= ' </tbody>' . chr(10); $output .= '</table>' . chr(10); return $output; }
$cleared_items = array(); $current_cleard_items = unserialize($_POST['current_cleard_items']); $all_items = array(); $gl_types = array('pmt', 'ttl', 'tpm'); $post_date = $_POST['post_date'] ? gen_db_date($_POST['post_date']) : ''; $payment_modules = load_all_methods('payment'); $tills = new tills(); $glEntry = new journal(); if (isset($_GET['till_id'])) { $tills->get_till_info(db_prepare_input($_GET['till_id'])); $post_date = gen_db_date(gen_locale_date(date('Y-m-d'))); } else { if (isset($_POST['till_id'])) { $tills->get_till_info(db_prepare_input($_POST['till_id'])); } else { if ($tills->showDropDown() == false) { $tills->get_default_till_info(); } else { $post_date = ''; $_REQUEST['action'] = ''; } } } if ($post_date) { $period = gen_calculate_period($post_date); } foreach ($payment_modules as $pmt_class) { $class = $pmt_class['id']; ${$class} = new $class(); } $glEntry->currencies_code = DEFAULT_CURRENCY;