function can_process()
{
- if (!is_numeric($_POST['po_over_receive']) || ($_POST['po_over_receive'] < 0)
- || ($_POST['po_over_receive'] > 100))
+ if (!check_num('po_over_receive', 0, 100))
{
display_error(_("The delivery over-receive allowance must be between 0 and 100."));
return false;
}
- if (!is_numeric($_POST['po_over_charge']) || ($_POST['po_over_charge'] < 0)
- || ($_POST['po_over_charge'] > 100))
+ if (!check_num('po_over_charge', 0, 100))
{
display_error(_("The invoice over-charge allowance must be between 0 and 100."));
return false;
}
- if (!is_numeric($_POST['past_due_days']) || ($_POST['past_due_days'] < 0)
- || ($_POST['past_due_days'] > 100))
+ if (!check_num('past_due_days', 0, 100))
{
display_error(_("The past due days interval allowance must be between 0 and 100."));
return false;
$_POST['default_inv_sales_act'],
$_POST['default_assembly_act'], $_POST['payroll_act'],
check_value('allow_negative_stock'),
- $_POST['po_over_receive'],
- $_POST['po_over_charge'],
+ input_num('po_over_receive'),
+ input_num('po_over_charge'),
$_POST['past_due_days'],
$_POST['default_credit_limit'],
$_POST['default_workorder_required'],
$_POST['allow_negative_stock'] = $myrow['allow_negative_stock'];
-$_POST['po_over_receive'] = $myrow['po_over_receive'];
-$_POST['po_over_charge'] = $myrow['po_over_charge'];
+$_POST['po_over_receive'] = percent_format($myrow['po_over_receive']);
+$_POST['po_over_charge'] = percent_format($myrow['po_over_charge']);
$_POST['past_due_days'] = $myrow['past_due_days'];
$_POST['default_credit_limit'] = $myrow['default_credit_limit'];
return false;
}
- if (!is_numeric($_POST['amount']))
+ if (!check_num('amount', 0))
{
- display_error(_("The entered amount is invalid."));
- return false;
- }
- if ($_POST['amount'] <= 0)
- {
- display_error(_("The entered amount must be a positive number."));
+ display_error(_("The entered amount is invalid or less than zero."));
return false;
}
global $path_to_root;
$trans_no = add_bank_transfer($_POST['FromBankAccount'], $_POST['ToBankAccount'],
- $_POST['DatePaid'], $_POST['amount'],
+ $_POST['DatePaid'], input_num('amount'),
$_POST['TransferType'], $_POST['ref'], $_POST['memo_']);
meta_forward($_SERVER['PHP_SELF'], "AddedID=$trans_no");
for ($i = 0, $da = $_POST['begin']; date1_greater_date2($_POST['end'], $da); $i++)
{
if (isset($_POST['add']))
- add_update_gl_budget_trans($da, $_POST['account'], $_POST['dim1'], $_POST['dim2'], $_POST['amount'.$i]);
+ add_update_gl_budget_trans($da, $_POST['account'], $_POST['dim1'], $_POST['dim2'], input_num('amount'.$i));
else
delete_gl_budget_trans($da, $_POST['account'], $_POST['dim1'], $_POST['dim2']);
$da = add_months($da, 1);
for ($i = 0, $date_ = $begin; date1_greater_date2($end, $date_); $i++)
{
start_row();
- $_POST['amount'.$i] = get_only_budget_trans_from_to($date_, $date_, $_POST['account'], $_POST['dim1'], $_POST['dim2']);
+ $_POST['amount'.$i] = number_format2(get_only_budget_trans_from_to($date_, $date_, $_POST['account'], $_POST['dim1'], $_POST['dim2']), 0);
label_cell($date_);
if (!isset($_POST['amount'.$i]))
- $_POST['amount'.$i] = "0";
- text_cells(null, 'amount'.$i, null, 15);
+ $_POST['amount'.$i] = '0';
+ amount_cells(null, 'amount'.$i, null, 15);
if ($showdims)
{
$d = get_budget_trans_from_to($date_, $date_, $_POST['account'], $_POST['dim1'], $_POST['dim2']);
$btotal += $d;
}
$lamount = get_gl_trans_from_to(add_years($date_, -1), add_years(end_month($date_), -1), $_POST['account'], $_POST['dim1'], $_POST['dim2']);
- $total += $_POST['amount'.$i];
+ $total += input_num('amount'.$i);
$ltotal += $lamount;
label_cell(number_format2($lamount, 0), "nowrap align=right");
$date_ = add_months($date_, 1);
}
start_row();
label_cell("<b>"._("Total")."</b>");
- label_cell("<b>".number_format2($total, 0)."</b>");
+ label_cell("<b>".number_format2($total, 0)."</b>", 'align=right');
if ($showdims)
label_cell("<b>".number_format2($btotal, 0)."</b>", "nowrap align=right");
label_cell("<b>".number_format2($ltotal, 0)."</b>", "nowrap align=right");
function check_item_data()
{
- if (!is_numeric($_POST['amount']))
+ if (!check_num('amount', 0))
{
- display_error( _("The amount entered is not a valid number."));
- return false;
- }
-
- if ($_POST['amount'] <= 0)
- {
- display_error( _("The amount entered must be a postitive number."));
+ display_error( _("The amount entered is not a valid number or is less than zero."));
return false;
}
{
if($_POST['UpdateItem'] != "" && check_item_data())
{
- $_SESSION['deposit_items']->update_gl_item($_POST['Index'], $_POST['dimension_id'], $_POST['dimension2_id'], -$_POST['amount'], $_POST['LineMemo']);
+ $_SESSION['deposit_items']->update_gl_item($_POST['Index'], $_POST['dimension_id'],
+ $_POST['dimension2_id'], -input_num('amount'), $_POST['LineMemo']);
}
}
if (!check_item_data())
return;
- $_SESSION['deposit_items']->add_gl_item($_POST['code_id'], $_POST['dimension_id'], $_POST['dimension2_id'], -$_POST['amount'], $_POST['LineMemo']);
+ $_SESSION['deposit_items']->add_gl_item($_POST['code_id'], $_POST['dimension_id'],
+ $_POST['dimension2_id'], -input_num('amount'), $_POST['LineMemo']);
}
//-----------------------------------------------------------------------------------------------
return false;
}
- if (strlen($_POST['AmountDebit']) && strlen($_POST['AmountCredit']))
- {
- display_error(_("You cannot enter both a debit amount and a credit amount."));
- return false;
- }
-
- if ((!isset($_POST['AmountDebit']) && !isset($_POST['AmountCredit']))
- || ($_POST['AmountDebit'] == "" && $_POST['AmountCredit'] == ""))
+ if (!(!strlen($_POST['AmountDebit']) ^ !strlen($_POST['AmountCredit'])))
{
display_error(_("You must enter either a debit amount or a credit amount."));
- return false;
- }
-
- if (isset($_POST['AmountDebit']) && $_POST['AmountDebit'] != "")
- {
-
- if (!is_numeric($_POST['AmountDebit']))
- {
- display_error(_("The debit amount entered is not a valid number."));
return false;
- }
+ }
- if ($_POST['AmountDebit'] <= 0)
- {
- display_error(_("The debit amount entered cannot be zero or negative."));
+ if (strlen($_POST['AmountDebit']) && !check_num('AmountDebit', 0))
+ {
+ display_error(_("The debit amount entered is not a valid number or is less than zero."));
return false;
- }
- }
-
- if (isset($_POST['AmountCredit']) && $_POST['AmountCredit'] != "")
+ } elseif (strlen($_POST['AmountCredit']) && !check_num('AmountCredit', 0))
{
-
- if (!is_numeric($_POST['AmountCredit']))
- {
- display_error(_("The credit amount entered is not a valid number."));
+ display_error(_("The credit amount entered is not a valid number or is less than zero."));
return false;
- }
+ }
- if ($_POST['AmountCredit'] <= 0)
- {
- display_error(_("The credit amount entered cannot be zero or negative."));
- return false;
- }
- }
if ($_SESSION["wa_current_user"]->access != 2 && is_bank_account($_POST['code_id']))
{
{
if($_POST['UpdateItem'] != "" && check_item_data())
{
- if ($_POST['AmountDebit'] > 0)
- $amount = $_POST['AmountDebit'];
+ if (input_num('AmountDebit') > 0)
+ $amount = input_num('AmountDebit');
else
- $amount = -$_POST['AmountCredit'];
+ $amount = -input_num('AmountCredit');
$_SESSION['journal_items']->update_gl_item($_POST['Index'], $_POST['dimension_id'],
$_POST['dimension2_id'], $amount, $_POST['LineMemo']);
if (!check_item_data())
return;
- if ($_POST['AmountDebit'] > 0)
- $amount = $_POST['AmountDebit'];
+ if (input_num('AmountDebit') > 0)
+ $amount = input_num('AmountDebit');
else
- $amount = -$_POST['AmountCredit'];
+ $amount = -input_num('AmountCredit');
$_SESSION['journal_items']->add_gl_item($_POST['code_id'], $_POST['dimension_id'],
$_POST['dimension2_id'], $amount, $_POST['LineMemo']);
end_row();
end_table(1);
-if (!isset($_POST['Process']))
+if ($_SESSION['journal_items']->count_gl_items() >= 1 &&
+ abs($_SESSION['journal_items']->gl_items_total()) < 0.0001)
{
- if ($_SESSION['journal_items']->count_gl_items() >= 1 &&
- abs($_SESSION['journal_items']->gl_items_total()) < 0.0001)
- {
- submit_center('Process', _("Process Journal Entry"));
- }
- else
- {
- display_note(_("The journal must balance (debits equal to credits) before it can be processed."), 0, 1);
- }
+ submit_center('Process', _("Process Journal Entry"));
+}
+else
+{
+ display_note(_("The journal must balance (debits equal to credits) before it can be processed."), 0, 1);
}
end_form();
function check_item_data()
{
- if (!is_numeric($_POST['amount']))
+ if (!check_num('amount', 0))
{
- display_error( _("The amount entered is not a valid number."));
- return false;
- }
-
- if ($_POST['amount'] <= 0)
- {
- display_error( _("The amount entered must be a postitive number."));
+ display_error( _("The amount entered is not a valid number or is less than zero."));
return false;
}
if($_POST['UpdateItem'] != "" && check_item_data())
{
$_SESSION['pay_items']->update_gl_item($_POST['Index'], $_POST['dimension_id'],
- $_POST['dimension2_id'], $_POST['amount'], $_POST['LineMemo']);
+ $_POST['dimension2_id'], input_num('amount'), $_POST['LineMemo']);
}
}
return;
$_SESSION['pay_items']->add_gl_item($_POST['code_id'], $_POST['dimension_id'],
- $_POST['dimension2_id'], $_POST['amount'], $_POST['LineMemo']);
+ $_POST['dimension2_id'], input_num('amount'), $_POST['LineMemo']);
}
//-----------------------------------------------------------------------------------------------
// convert to customer currency
$cust_amount = exchange_from_to($total_amount, $currency, get_customer_currency($person_id), $date_);
- $trans_no = add_customer_trans($trans_type, $person_id, $person_detail_id, $date_,
+ $trans_no = write_customer_trans($trans_type, 0, $person_id, $person_detail_id, $date_,
$ref, $cust_amount);
}
if (!isset($_POST['dimension2_id']))
$_POST['dimension2_id'] = $order->gl_items[$Index]->dimension2_id;
if (!isset($_POST['amount']) || ($_POST['amount'] == ""))
- $_POST['amount'] = -$order->gl_items[$Index]->amount;
+ $_POST['amount'] = -price_format($order->gl_items[$Index]->amount);
if (!isset($_POST['description']) || ($_POST['description'] == ""))
$_POST['description'] = $order->gl_items[$Index]->description;
if (!isset($_POST['LineMemo']) || ($_POST['LineMemo'] == ""))
}
else
{
- $_POST['amount'] = 0;
+ $_POST['amount'] = price_format(0);
$_POST['dimension_id'] = 0;
$_POST['dimension2_id'] = 0;
$_POST['LineMemo'] = "";
else
$th = array(_("Account Code"), _("Account Description"),
_("Debit"), _("Credit"), _("Memo"));
+
+ if (count($order->gl_items)) $th[] = '';
+
table_header($th);
$k = 0;
$_POST['dimension2_id'] = $item->dimension2_id;
if ((!isset($_POST['AmountDebit']) || ($_POST['AmountDebit']=="")) && $item->amount > 0)
- $_POST['AmountDebit'] = $item->amount;
+ $_POST['AmountDebit'] = price_format($item->amount);
if ((!isset($_POST['AmountCredit']) || ($_POST['AmountCredit']=="")) && $item->amount <= 0)
- $_POST['AmountCredit'] = abs($item->amount);
+ $_POST['AmountCredit'] = price_format(abs($item->amount));
if (!isset($_POST['description']) || ($_POST['description'] == ""))
$_POST['description'] = $item->description;
}
else
{
- $_POST['AmountDebit'] = 0;
- $_POST['AmountCredit'] = 0;
+ $_POST['AmountDebit'] = ''; //price_format(0);
+ $_POST['AmountCredit'] = ''; //price_format(0);
$_POST['dimension_id'] = 0;
$_POST['dimension2_id'] = 0;
$_POST['LineMemo'] = "";
if ($dim < 2)
hidden('dimension2_id', 0);
- amount_cells(null, 'AmountDebit');
- amount_cells(null, 'AmountCredit');
+ small_amount_cells(null, 'AmountDebit');
+ small_amount_cells(null, 'AmountCredit');
text_cells_ex(null, 'LineMemo', 35, 50);
if (isset($_GET['Edit']))
else
$th = array(_("Account Code"), _("Account Description"),
_("Amount"), _("Memo"));
+
+ if (count($order->gl_items)) $th[] = '';
+
table_header($th);
$k = 0; //row colour counter
if (!isset($_POST['dimension2_id']))
$_POST['dimension2_id'] = $order->gl_items[$Index]->dimension2_id;
if (!isset($_POST['amount']) || ($_POST['amount'] == ""))
- $_POST['amount'] = $order->gl_items[$Index]->amount;
+ $_POST['amount'] = price_format($order->gl_items[$Index]->amount);
if (!isset($_POST['description']) || ($_POST['description'] == ""))
$_POST['description'] = $order->gl_items[$Index]->description;
if (!isset($_POST['LineMemo']) || ($_POST['LineMemo'] == ""))
}
else
{
- $_POST['amount'] = 0;
+ $_POST['amount'] = price_format(0);
$_POST['dimension_id'] = 0;
$_POST['dimension2_id'] = 0;
$_POST['LineMemo'] = "";
else
$selected_id = "";
//---------------------------------------------------------------------------------------------
-
function check_data()
{
if (!is_date($_POST['date_']))
display_error( _("The entered date is invalid."));
return false;
}
- if (!is_numeric($_POST['BuyRate']))
+ if (!check_num('BuyRate', 0))
{
- display_error( _("The exchange rate must be numeric."));
+ display_error( _("The exchange rate must be numeric and greater than zero."));
return false;
}
if ($_POST['BuyRate'] <= 0)
if ($selected_id != "")
{
- update_exchange_rate($_POST['curr_abrev'], $_POST['date_'], $_POST['BuyRate'],
- $_POST['BuyRate']);
+ update_exchange_rate($_POST['curr_abrev'], $_POST['date_'],
+ input_num('BuyRate'), input_num('BuyRate'));
}
else
{
- add_exchange_rate($_POST['curr_abrev'], $_POST['date_'], $_POST['BuyRate'],
- $_POST['BuyRate']);
+ add_exchange_rate($_POST['curr_abrev'], $_POST['date_'],
+ input_num('BuyRate'), input_num('BuyRate'));
}
return true;
if (isset($_POST['get_rate']))
{
- $_POST['BuyRate'] = get_ecb_rate($_POST['curr_abrev']);
- $_POST['BuyRate'] = number_format($_POST['BuyRate'], user_exrate_dec());
+ $_POST['BuyRate'] = exrate_format(get_ecb_rate($_POST['curr_abrev']));
}
if ($selected_id != "")
{
- //editing an existing payment terms
+ //editing an existing exchange rate
$myrow = get_exchange_rate($selected_id);
$_POST['date_'] = sql2date($myrow["date_"]);
- $_POST['BuyRate'] = $myrow["rate_buy"];
+ $_POST['BuyRate'] = exrate_format($myrow["rate_buy"]);
hidden('selected_id', $selected_id);
hidden('date_', $_POST['date_']);
{
date_row(_("Date to Use From:"), 'date_');
}
- text_row(_("Exchange Rate:"), 'BuyRate', null, 15, 12, "", submit('get_rate',_("Get"), false));
+ small_amount_row(_("Exchange Rate:"), 'BuyRate', null, '', submit('get_rate',_("Get"), false));
end_table(1);
function check_item_data()
{
- if (!is_numeric($_POST['qty']))
+ if (!check_num('qty',0))
{
- display_error(_("The quantity entered is not a valid number."));
+ display_error(_("The quantity entered is negative or invalid."));
return false;
}
- if ($_POST['qty'] <= 0)
- {
- display_error(_("The quantity entered must be greater than zero."));
- return false;
- }
-
- if (!is_numeric($_POST['std_cost']) || $_POST['std_cost'] < 0)
+ if (!check_num('std_cost', 0))
{
display_error(_("The entered standard cost is negative or invalid."));
return false;
{
if($_POST['UpdateItem'] != "" && check_item_data())
{
- $_SESSION['adj_items']->update_cart_item($_POST['stock_id'], $_POST['qty'], $_POST['std_cost']);
+ $_SESSION['adj_items']->update_cart_item($_POST['stock_id'],
+ input_num('qty'), input_num('std_cost'));
}
}
if (!check_item_data())
return;
- add_to_order($_SESSION['adj_items'], $_POST['stock_id'], $_POST['qty'], $_POST['std_cost']);
+ add_to_order($_SESSION['adj_items'], $_POST['stock_id'],
+ input_num('qty'), input_num('std_cost'));
}
//-----------------------------------------------------------------------------------------------
if (isset($_POST['UpdateData']))
{
- $old_cost = $_POST['OldMaterialCost'] + $_POST['OldLabourCost'] + $_POST['OldOverheadCost'];
- $new_cost = $_POST['material_cost'] + $_POST['labour_cost'] + $_POST['overhead_cost'];
+ $old_cost = input_num('OldMaterialCost') + input_num('OldLabourCost')
+ + input_num('OldOverheadCost');
+ $new_cost = input_num('material_cost') + input_num('labour_cost')
+ + input_num('overhead_cost');
$should_update = true;
- if (!is_numeric($_POST['material_cost']) || !is_numeric($_POST['labour_cost']) ||
- !is_numeric($_POST['overhead_cost']))
+ if (!check_num('material_cost') || !check_num('labour_cost') ||
+ !check_num('overhead_cost'))
{
display_error( _("The entered cost is not numeric."));
$should_update = false;
if ($should_update)
{
- $update_no = stock_cost_update($_POST['stock_id'], $_POST['material_cost'],
- $_POST['labour_cost'], $_POST['overhead_cost'], $old_cost);
+ $update_no = stock_cost_update($_POST['stock_id'],
+ input_num('material_cost'), input_num('labour_cost'),
+ input_num('overhead_cost'), $old_cost);
display_note(_("Cost has been updated."));
hidden("OldOverheadCost", $myrow["overhead_cost"]);
start_table($table_style2);
-label_row(_("Last Cost"), number_format2($myrow["last_cost"],user_price_dec()),
+label_row(_("Last Cost"), price_format($myrow["last_cost"]),
"class='tableheader2'", "nowrap align=right");
-text_row(_("Standard Material Cost Per Unit"), "material_cost",
- number_format($myrow["material_cost"],user_price_dec()), "", "", "class='tableheader2'");
+amount_row(_("Standard Material Cost Per Unit"), "material_cost",
+ price_format($myrow["material_cost"]), "", "", "class='tableheader2'");
if ($myrow["mb_flag"]=='M')
{
- text_row(_("Standard Labour Cost Per Unit"), "labour_cost",
- number_format($myrow["labour_cost"],user_price_dec()), "", "", "class='tableheader2'");
- text_row(_("Standard Overhead Cost Per Unit"), "overhead_cost",
- number_format($myrow["overhead_cost"],user_price_dec()), "", "", "class='tableheader2'");
+ amount_row(_("Standard Labour Cost Per Unit"), "labour_cost",
+ price_format($myrow["labour_cost"]), '', "", "class='tableheader2'");
+ amount_row(_("Standard Overhead Cost Per Unit"), "overhead_cost",
+ price_format($myrow["overhead_cost"]), "", "", "class='tableheader2'");
}
else
{
start_table("$table_style width=80%");
$th = array(_("Item Code"), _("Item Description"), _("Quantity"),
_("Unit"), _("Unit Cost"), _("Total"));
+ if ( count($order->line_items)) $th[] = '';
+
table_header($th);
$total = 0;
$k = 0; //row colour counter
if (!isset($_POST['stock_id']))
$_POST['stock_id'] = $order->line_items[$stock_id]->stock_id;
if (!isset($_POST['qty']) OR ($_POST['qty']==""))
- $_POST['qty'] = $order->line_items[$stock_id]->quantity;
+ $_POST['qty'] = qty_format($order->line_items[$stock_id]->quantity);
if (!isset($_POST['std_cost']) OR ($_POST['std_cost']==""))
- $_POST['std_cost'] = $order->line_items[$stock_id]->standard_cost;
+ $_POST['std_cost'] = price_format($order->line_items[$stock_id]->standard_cost);
$_POST['units'] = $order->line_items[$stock_id]->units;
$item_info = get_item_edit_info($_POST['stock_id']);
- $_POST['qty'] = 0;
- $_POST['std_cost'] = $item_info["standard_cost"];
+ $_POST['qty'] = qty_format(0);
+ $_POST['std_cost'] = price_format($item_info["standard_cost"]);
$_POST['units'] = $item_info["units"];
}
- text_cells(null, 'qty', $_POST['qty'], 13, 15);
+ amount_cells(null, 'qty', $_POST['qty']);
label_cell($_POST['units']);
- text_cells(null, 'std_cost', $_POST['std_cost'], 15, 14);
+ amount_cells(null, 'std_cost', $_POST['std_cost']);
label_cell(" ");
if (isset($_GET['Edit']))
display_heading($title);
start_table("$table_style width=80%");
- $th = array(_("Item Code"), _("Item Description"), _("Quantity"), _("Unit"));
+ $th = array(_("Item Code"), _("Item Description"), _("Quantity"), _("Unit"),'');
table_header($th);
$subtotal = 0;
$k = 0; //row colour counter
{
if (!isset($_POST['stock_id']))
$_POST['stock_id'] = $order->line_items[$stock_id]->stock_id;
- if (!isset($_POST['qty']) || ($_POST['qty']==""))
- $_POST['qty'] = $order->line_items[$stock_id]->quantity;
+ if (!isset($_POST['qty']) || $_POST['qty'] == '')
+ $_POST['qty'] = qty_format($order->line_items[$stock_id]->quantity);
$_POST['units'] = $order->line_items[$stock_id]->units;
$item_info = get_item_edit_info($_POST['stock_id']);
- $_POST['qty'] = 0;
+ $_POST['qty'] = qty_format(0);
$_POST['units'] = $item_info["units"];
}
- text_cells(null, 'qty', $_POST['qty'], 13, 15);
+ small_amount_cells(null, 'qty', $_POST['qty']);
label_cell($_POST['units']);
if (isset($_GET['Edit']))
} else
text_row(_("Unit Abbreviation:"), 'abbr', null, 20, 20);
text_row(_("Descriptive Name:"), 'description', null, 40, 40);
-text_row(_("Decimal Places:"), 'decimals', null, 40, 40);
+text_row(_("Decimal Places:"), 'decimals', null, 3, 3);
end_table(1);
if (isset($_POST['updatePrice']))
{
- if (!is_numeric($_POST['price']) || $_POST['price'] == "")
+ if (!check_num('price', 0))
{
$input_error = 1;
display_error( _("The price entered must be numeric."));
if (isset($_POST['PriceID']))
{
//editing an existing price
- update_item_price($_POST['PriceID'], $_POST['sales_type_id'], $_POST['curr_abrev'], $_POST['price']);
+ update_item_price($_POST['PriceID'], $_POST['sales_type_id'],
+ $_POST['curr_abrev'], input_num('price'));
$msg = _("This price has been updated.");
}
elseif ($input_error !=1)
{
- add_item_price($_POST['stock_id'], $_POST['sales_type_id'], $_POST['curr_abrev'], $_POST['price']);
+ add_item_price($_POST['stock_id'], $_POST['sales_type_id'],
+ $_POST['curr_abrev'], input_num('price'));
display_note(_("The new price has been added."));
}
hidden('PriceID', $_GET['PriceID']);
$_POST['curr_abrev'] = $myrow["curr_abrev"];
$_POST['sales_type_id'] = $myrow["sales_type_id"];
- $_POST['price'] = $myrow["price"];
+ $_POST['price'] = price_format($myrow["price"]);
}
start_table($table_style2);
sales_types_list_row(_("Sales Type:"), 'sales_type_id', null);
-text_row(_("Price:"), 'price', null, 10, 10);
+small_amount_row(_("Price:"), 'price', null);
end_table(1);
$input_error = 1;
display_error( _("There is no item selected."));
}
- elseif (!is_numeric($_POST['price']) || $_POST['price']==0)
+ elseif (!check_num('price', 0))
{
$input_error = 1;
display_error( _("The price entered was not numeric."));
}
- elseif (!is_numeric($_POST['conversion_factor']))
+ elseif (!check_num('conversion_factor'))
{
$input_error = 1;
display_error( _("The conversion factor entered was not numeric. The conversion factor is the number by which the price must be divided by to get the unit price in our unit of measure."));
$sql = "INSERT INTO ".TB_PREF."purch_data (supplier_id, stock_id, price, suppliers_uom,
conversion_factor, supplier_description) VALUES (";
- $sql .= "'$supplier_id', '" . $_POST['stock_id'] . "', " . $_POST['price'] . ", '" . $_POST['suppliers_uom'] . "', " .
- $_POST['conversion_factor'] . ", '" . $_POST['supplier_description'] . "')";
+ $sql .= "'$supplier_id', '" . $_POST['stock_id'] . "', " .
+ input_num('price') . ", '" . $_POST['suppliers_uom'] . "', " .
+ input_num('conversion_factor') . ", '" . $_POST['supplier_description'] . "')";
db_query($sql,"The supplier purchasing details could not be added");
display_notification(_("This supplier purchasing data has been added."));
if (isset($_POST['UpdateRecord']))
{
- $sql = "UPDATE ".TB_PREF."purch_data SET price=" . $_POST['price'] . ",
+ $sql = "UPDATE ".TB_PREF."purch_data SET price=" . input_num('price') . ",
suppliers_uom='" . $_POST['suppliers_uom'] . "',
- conversion_factor=" . $_POST['conversion_factor'] . ",
+ conversion_factor=" . input_num('conversion_factor') . ",
supplier_description='" . $_POST['supplier_description'] . "'
WHERE stock_id='" . $_POST['stock_id'] . "' AND
supplier_id='$supplier_id'";
$myrow = db_fetch($result);
$supp_name = $myrow["supp_name"];
- $_POST['price'] = $myrow["price"];
+ $_POST['price'] = price_format($myrow["price"]);
$_POST['suppliers_uom'] = $myrow["suppliers_uom"];
$_POST['supplier_description'] = $myrow["supplier_description"];
- $_POST['conversion_factor'] = $myrow["conversion_factor"];
+ $_POST['conversion_factor'] = exrate_format($myrow["conversion_factor"]);
}
echo "<br>";
supplier_list_row(_("Supplier:"), 'supplier_id', null, false, true);
$supplier_id = $_POST['supplier_id'];
}
-text_row(_("Price:"), 'price', null, 12, 12, "", get_supplier_currency($supplier_id));
+amount_row(_("Price:"), 'price', null,'', get_supplier_currency($supplier_id));
text_row(_("Suppliers Unit of Measure:"), 'suppliers_uom', null, 50, 51);
if (!isset($_POST['conversion_factor']) || $_POST['conversion_factor'] == "")
{
- $_POST['conversion_factor'] = 1;
+ $_POST['conversion_factor'] = exrate_format(1);
}
-text_row(_("Conversion Factor (to our UOM):"), 'conversion_factor', $_POST['conversion_factor'], 12, 12);
+amount_row(_("Conversion Factor (to our UOM):"), 'conversion_factor', exrate_format($_POST['conversion_factor']));
text_row(_("Supplier's Code or Description:"), 'supplier_description', null, 50, 51);
end_table(1);
alt_table_row_color($k);
- if (isset($_POST['UpdateData']) && is_numeric($_POST[$myrow["loc_code"]]))
+ if (isset($_POST['UpdateData']) && check_num($myrow["loc_code"]))
{
- $myrow["reorder_level"] = $_POST[$myrow["loc_code"]];
- set_reorder_level($_POST['stock_id'], $myrow["loc_code"], $_POST[$myrow["loc_code"]]);
+ $myrow["reorder_level"] = input_num($myrow["loc_code"]);
+ set_reorder_level($_POST['stock_id'], $myrow["loc_code"], input_num($myrow["loc_code"]));
}
$qoh = get_qoh_on_date($_POST['stock_id'], $myrow["loc_code"]);
-
+
label_cell($myrow["location_name"]);
+
+ $_POST[$myrow["loc_code"]] = qty_format($myrow["reorder_level"]);
+
label_cell(number_format2($qoh,user_qty_dec()), "nowrap align='right'");
- text_cells(null, $myrow["loc_code"], $myrow["reorder_level"], 10, 10);
+ amount_cells(null, $myrow["loc_code"]);
end_row();
$j++;
If ($j == 12)
function check_item_data()
{
- if (!is_numeric($_POST['qty']) || ($_POST['qty'] == 0))
+ if (!check_num('qty'))
{
display_error( _("The quantity entered is not a valid number."));
return false;
}
- if ($_POST['qty'] <= 0)
+ if (!check_num('qty', 0))
{
display_error(_("The quantity entered must be a positive number."));
return false;
{
if (!isset($_POST['std_cost']))
$_POST['std_cost'] = $_SESSION['transfer_items']->line_items[$_POST['stock_id']]->standard_cost;
- $_SESSION['transfer_items']->update_cart_item($_POST['stock_id'], $_POST['qty'], $_POST['std_cost']);
+ $_SESSION['transfer_items']->update_cart_item($_POST['stock_id'], input_num('qty'), $_POST['std_cost']);
}
}
return;
if (!isset($_POST['std_cost']))
$_POST['std_cost'] = 0;
- add_to_order($_SESSION['transfer_items'], $_POST['stock_id'], $_POST['qty'], $_POST['std_cost']);
+ add_to_order($_SESSION['transfer_items'], $_POST['stock_id'], input_num('qty'), $_POST['std_cost']);
}
//-----------------------------------------------------------------------------------------------
label_cell("<a href='$select_item'>" . $myrow["parent"]. " - " . $myrow["description"]. "</a>");
label_cell($myrow["WorkCentreName"]);
label_cell($myrow["location_name"]);
- label_cell($myrow["quantity"]);
+ label_cell(qty_format($myrow["quantity"]));
end_row();
$j++;
label_cell($myrow["description"]);
label_cell($myrow["location_name"]);
label_cell($myrow["WorkCentreDescription"]);
- label_cell($myrow["quantity"]);
+ label_cell(qty_format($myrow["quantity"]));
label_cell($myrow["units"]);
edit_link_cell(SID . "NewItem=$selected_parent&selected_component=" . $myrow["id"]);
delete_link_cell(SID . "delete=" . $myrow["id"]. "&stock_id=" . $_POST['stock_id']);
//--------------------------------------------------------------------------------------------------
-function on_submit($selected_parent, $selected_component)
+function on_submit($selected_parent, $selected_component=null)
{
- if (!is_numeric($_POST['quantity']))
+ if (!check_num('quantity', 0))
{
- display_error(_("The quantity entered must be numeric."));
+ display_error(_("The quantity entered must be numeric and greater than zero."));
return;
}
- if ($_POST['quantity'] <= 0)
- {
- display_error(_("The quantity entered must be greater than zero."));
- return;
- }
-
-
if (isset($selected_parent) && isset($selected_component))
{
$sql = "UPDATE ".TB_PREF."bom SET workcentre_added='" . $_POST['workcentre_added'] . "',
loc_code='" . $_POST['loc_code'] . "',
- quantity= " . $_POST['quantity'] . "
+ quantity= " . input_num('quantity') . "
WHERE parent='" . $selected_parent . "'
AND id='" . $selected_component . "'";
check_db_error("Could not update this bom component", $sql);
elseif (!isset($selected_component) && isset($selected_parent))
{
- /*Selected component is null cos no item selected on first time round so must be adding a record must be Submitting new entries in the new component form */
+ /*Selected component is null cos no item selected on first time round
+ so must be adding a record must be Submitting new entries in the new
+ component form */
//need to check not recursive bom component of itself!
If (!check_for_recursive_bom($selected_parent, $_POST['component']))
if (db_num_rows($result) == 0)
{
$sql = "INSERT INTO ".TB_PREF."bom (parent, component, workcentre_added, loc_code, quantity)
- VALUES ('$selected_parent', '" . $_POST['component'] . "', '" . $_POST['workcentre_added'] . "', '" . $_POST['loc_code'] . "', " . $_POST['quantity'] . ")";
+ VALUES ('$selected_parent', '" . $_POST['component'] . "', '"
+ . $_POST['workcentre_added'] . "', '" . $_POST['loc_code'] . "', "
+ . input_num('quantity') . ")";
db_query($sql,"check failed");
if (isset($_POST['stock_id']))
{ //Parent Item selected so display bom or edit component
$selected_parent = $_POST['stock_id'];
-
- if (isset($selected_parent) && isset($_POST['Submit']))
+ if (isset($selected_parent) && isset($_POST['Submit'])) {
+ if(isset($selected_component))
on_submit($selected_parent, $selected_component);
-
+ else
+ on_submit($selected_parent);
+ }
//--------------------------------------------------------------------------------------
display_bom_items($selected_parent);
$_POST['loc_code'] = $myrow["loc_code"];
$_POST['workcentre_added'] = $myrow["workcentre_added"];
- $_POST['quantity'] = $myrow["quantity"];
+ $_POST['quantity'] = qty_format($myrow["quantity"]);
hidden('selected_parent', $selected_parent);
hidden('selected_component', $selected_component);
if (!isset($_POST['quantity']))
{
- $_POST['quantity'] = 1;
+ $_POST['quantity'] = qty_format(1);
}
- text_row(_("Quantity:"), 'quantity', $_POST['quantity'], 10, 18);
+ amount_row(_("Quantity:"), 'quantity', $_POST['quantity']);
end_table(1);
submit_center('Submit', _("Add/Update"));
}
}
- if (!is_numeric($_POST['quantity']))
+ if (!check_num('quantity', 0))
{
- display_error( _("The quantity entered must be numeric."));
- return false;
- }
-
- if ($_POST['quantity'] <= 0)
- {
- display_error( _("The quantity entered must be a positive number greater than zero."));
+ display_error( _("The quantity entered is invalid or less than zero."));
return false;
}
}
if ($_POST['Costs'] == "")
- $_POST['Costs'] = 0;
- if (!is_numeric($_POST['Costs']))
- {
- display_error( _("The cost entered must be numeric."));
- return false;
- }
-
- if ($_POST['Costs'] < 0)
+ $_POST['Costs'] = price_format(0);
+ if (!check_num('Costs', 0))
{
- display_error( _("The cost entered cannot be negative."));
+ display_error( _("The cost entered is invalid or less than zero."));
return false;
}
if (has_stock_holding($bom_item["ResourceType"]))
{
- $quantity = $bom_item["quantity"] * $_POST['quantity'];
+ $quantity = $bom_item["quantity"] * input_num('quantity');
$qoh = get_qoh_on_date($bom_item["component"], $bom_item["loc_code"], $_POST['date_']);
if (-$quantity + $qoh < 0)
{
// if unassembling, check item to unassemble
$qoh = get_qoh_on_date($_POST['stock_id'], $_POST['StockLocation'], $_POST['date_']);
- if (-$_POST['quantity'] + $qoh < 0)
+ if (-input_num('quantity') + $qoh < 0)
{
display_error(_("The selected item cannot be unassembled because there is insufficient stock."));
return false;
{
$myrow = get_work_order($selected_id, true);
- if ($_POST['units_issued'] > $_POST['quantity'])
+ if ($_POST['units_issued'] > input_num('quantity'))
{
display_error(_("The quantity cannot be changed to be less than the quantity already manufactured for this order."));
return false;
if (isset($_POST['ADD_ITEM']) && can_process())
{
- $id = add_work_order($_POST['wo_ref'], $_POST['StockLocation'], $_POST['quantity'],
+ $id = add_work_order($_POST['wo_ref'], $_POST['StockLocation'], input_num('quantity'),
$_POST['stock_id'], $_POST['type'], $_POST['date_'],
- $_POST['RequDate'], $_POST['Costs'], $_POST['memo_']);
+ $_POST['RequDate'], input_num('Costs'), $_POST['memo_']);
meta_forward($_SERVER['PHP_SELF'], "AddedID=$id");
}
if (isset($_POST['UPDATE_ITEM']) && can_process())
{
- update_work_order($selected_id, $_POST['StockLocation'], $_POST['quantity'],
+ update_work_order($selected_id, $_POST['StockLocation'], input_num('quantity'),
$_POST['stock_id'], $_POST['date_'], $_POST['RequDate'], $_POST['memo_']);
meta_forward($_SERVER['PHP_SELF'], "UpdatedID=$selected_id");
}
$_POST['wo_ref'] = $myrow["wo_ref"];
- $_POST['quantity'] = $myrow["units_reqd"];
+ $_POST['quantity'] = qty_format($myrow["units_reqd"]);
$_POST['StockLocation'] = $myrow["loc_code"];
$_POST['released'] = $myrow["released"];
$_POST['closed'] = $myrow["closed"];
$_POST['released_date'] = sql2date($myrow["released_date"]);
$_POST['memo_'] = "";
$_POST['units_issued'] = $myrow["units_issued"];
- $_POST['Costs'] = $myrow["Costs"];
+ $_POST['Costs'] = price_format($myrow["Costs"]);
$_POST['memo_'] = get_comments_string(systypes::work_order(), $selected_id);
}
if (!isset($_POST['quantity']))
- $_POST['quantity'] = 1;
+ $_POST['quantity'] = qty_format(1);
if ($_POST['type'] == wo_types::advanced())
{
- text_row_ex(_("Quantity Required:"), 'quantity', 12);
+ amount_row(_("Quantity Required:"), 'quantity', 12);
if ($_POST['released'])
- label_row(_("Quantity Manufactured:"), $_POST['units_issued']);
+ label_row(_("Quantity Manufactured:"), qty_format($_POST['units_issued']));
date_row(_("Date") . ":", 'date_');
date_row(_("Date Required By") . ":", 'RequDate', null, sys_prefs::default_wo_required_by());
}
else
{
- text_row_ex(_("Quantity:"), 'quantity', 12);
+ amount_row(_("Quantity:"), 'quantity', 12);
date_row(_("Date") . ":", 'date_');
hidden('RequDate', '');
if (!isset($_POST['Costs']))
- $_POST['Costs'] = 0;
+ $_POST['Costs'] = price_format(0);
amount_row(_("Total Additional Costs:"), 'Costs');
}
$js = "";
if ($use_popup_windows)
$js .= get_js_open_window(900, 500);
+
+$js .= get_js_allocate();
+
page(_("Allocate Supplier Payment or Credit Note"), false, false, "", $js);
for ($counter=0; $counter < $_POST["TotalNumberOfAllocs"]; $counter++)
{
- if (!is_numeric($_POST['amount' . $counter]))
+ if (!check_num('amount' . $counter, 0))
{
- display_error(_("The entry for one or more amounts is invalid."));
- return false;
- }
-
- if ($_POST['amount' . $counter] < 0)
- {
- display_error(_("The entry for an amount to allocate was negative. A positive allocation amount is expected."));
+ display_error(_("The entry for one or more amounts is invalid or negative."));
return false;
}
/*Now check to see that the AllocAmt is no greater than the
amount left to be allocated against the transaction under review */
- if ($_POST['amount' . $counter] > $_POST['un_allocated' . $counter])
+ if (input_num('amount' . $counter) > $_POST['un_allocated' . $counter])
{
//$_POST['amount' . $counter] = $_POST['un_allocated' . $counter];
}
- $_SESSION['alloc']->allocs[$counter]->current_allocated = $_POST['amount' . $counter];
+ $_SESSION['alloc']->allocs[$counter]->current_allocated = input_num('amount' . $counter);
- $total_allocated += $_POST['amount' . $counter];
+ $total_allocated += input_num('amount' . $counter);
}
if ($total_allocated + $_SESSION['alloc']->amount > sys_prefs::allocation_settled_allowance())
display_heading($_SESSION['alloc']->person_name);
display_heading2(_("Date:") . " <b>" . $_SESSION['alloc']->date_ . "</b>");
- display_heading2(_("Total:") . " <b>" . number_format2(-$_SESSION['alloc']->amount,user_price_dec()) . "</b>");
+ display_heading2(_("Total:") . " <b>" . price_format(-$_SESSION['alloc']->amount) . "</b>");
echo "<br>";
{
start_table($table_style);
$th = array(_("Transaction Type"), _("#"), _("Date"), _("Due Date"), _("Amount"),
- _("Other Allocations"), _("This Allocation"), _("Left to Allocate"));
+ _("Other Allocations"), _("This Allocation"), _("Left to Allocate"),'');
table_header($th);
$k = $counter = $total_allocated = 0;
label_cell($alloc_item->date_, "align=right");
label_cell($alloc_item->due_date, "align=right");
amount_cell($alloc_item->amount);
- amount_cell($alloc_item->amount_allocated);
+ amount_cell($alloc_item->amount_allocated);
if (!isset($_POST['amount' . $counter]) || $_POST['amount' . $counter] == "")
- $_POST['amount' . $counter] = $alloc_item->current_allocated;
- text_cells(null, "amount" . $counter, $_POST['amount' . $counter], 13, 12);
+ $_POST['amount' . $counter] = price_format($alloc_item->current_allocated);
+ amount_cells(null, "amount" . $counter, price_format('amount' . $counter));
$un_allocated = round($alloc_item->amount - $alloc_item->amount_allocated, 6);
hidden("un_allocated" . $counter, $un_allocated);
amount_cell($un_allocated);
+ label_cell("<a href='#' name=Alloc$counter onclick='allocate_all(this.name.substr(5));return true;'>"
+ . _("All") . "</a>");
+ label_cell("<a href='#' name=DeAll$counter onclick='allocate_none(this.name.substr(5));return true;'>"
+ . _("None") . "</a>");
- label_cell("<a href='#' onclick='forms[0].amount$counter.value=forms[0].un_allocated$counter.value; return true;'>" . _("All") . "</a>");
- label_cell("<a href='#' onclick='forms[0].amount$counter.value=0; return true;'>" . _("None") . "</a>");
+// label_cell("<a href='#' onclick='forms[0].amount$counter.value=forms[0].un_allocated$counter.value; return true;'>" . _("All") . "</a>");
+// label_cell("<a href='#' onclick='forms[0].amount$counter.value=0; return true;'>" . _("None") . "</a>");
end_row();
- $total_allocated += $_POST['amount' . $counter];
+ $total_allocated += input_num('amount' . $counter);
$counter++;
}
}
else
$font1 = $font2 = "";
- label_row(_("Left to Allocate"), $font1 . number_format2(-$_SESSION['alloc']->amount -
- $total_allocated,user_price_dec()) . $font2, "colspan=6 align=right",
+ $left_to_allocate = price_format(-$_SESSION['alloc']->amount - $total_allocated);
+ label_row(_("Left to Allocate"), $font1 . $left_to_allocate . $font2, "colspan=6 align=right",
"nowrap align=right");
end_table();
hidden('TotalNumberOfAllocs', $counter);
+ hidden('left_to_allocate', $left_to_allocate);
echo "<br><center>";
submit('UpdateDisplay', _("Update"));
echo " ";
$th = array(_("Item Code"), _("Item Description"), _("Quantity"), _("Unit"),
_("Required Delivery Date"), _("Price"), _("Line Total"));
+
+ if (count($order->line_items)) $th[] = '';
table_header($th);
$total = 0;
if (!isset($_GET['Edit']) && $editable)
po_item_controls($order);
- $display_total = number_format2($total,user_price_dec());
+ $display_total = price_format($total);
label_row(_("Total Excluding Shipping/Tax"), $display_total, "colspan=6 align=right",
"nowrap align=right");
if (!isset($_POST['stock_id']))
$_POST['stock_id'] = $order->line_items[$_GET['Edit']]->stock_id;
if (!isset($_POST['qty']) || ($_POST['qty'] == ""))
- $_POST['qty'] = $order->line_items[$_GET['Edit']]->quantity;
+ $_POST['qty'] = qty_format($order->line_items[$_GET['Edit']]->quantity);
if (!isset($_POST['price']) || ($_POST['price'] == ""))
- $_POST['price'] = $order->line_items[$_GET['Edit']]->price;
+ $_POST['price'] = price_format($order->line_items[$_GET['Edit']]->price);
if (!isset($_POST['req_del_date']) || ($_POST['req_del_date'] == ""))
$_POST['req_del_date'] = $order->line_items[$_GET['Edit']]->req_del_date;
$item_info = get_item_edit_info($_POST['stock_id']);
$_POST['units'] = $item_info["units"];
- $_POST['qty'] = 1;
- $_POST['price'] = get_purchase_price ($order->supplier_id, $_POST['stock_id']);
+ $_POST['qty'] = qty_format(1);
+ $_POST['price'] = price_format(get_purchase_price ($order->supplier_id, $_POST['stock_id']));
$_POST['req_del_date'] = add_days(Today(), 10);
}
- text_cells(null, 'qty', null, 13, 15);
+ amount_cells(null, 'qty', null);
label_cell($_POST['units']);
date_cells(null, 'req_del_date', null, 0, 0, 0);
- text_cells(null, 'price', null, 15, 14);
+ amount_cells(null, 'price', null);
//$line_total = $_POST['qty'] * $_POST['price'] * (1 - $_POST['Disc'] / 100);
- $line_total = $_POST['qty'] * $_POST['price'];
+ $line_total = input_num('qty') * input_num('price');
amount_cell($line_total);
if (isset($_GET['Edit']))
if (isset($_POST['StockLocation']) && $_POST['StockLocation'] == $all_items)
$th = array(_("#"), _("Reference"), _("Supplier"), _("Location"),
- _("Supplier's Reference"), _("Order Date"), _("Currency"), _("Order Total"));
+ _("Supplier's Reference"), _("Order Date"), _("Currency"), _("Order Total"),'');
else
$th = array(_("#"), _("Reference"), _("Supplier"),
- _("Supplier's Reference"), _("Order Date"), _("Currency"), _("Order Total"));
+ _("Supplier's Reference"), _("Order Date"), _("Currency"), _("Order Total"),'');
table_header($th);
function check_data()
{
- if (!is_numeric($_POST['qty']))
+ if (!check_num('qty',0))
{
- display_error(_("The quantity of the order item must be numeric."));
+ display_error(_("The quantity of the order item must be numeric and not less than zero."));
return false;
}
- if ($_POST['qty'] <= 0)
- {
- display_error(_("The quantity of the ordered item entered must be a positive amount."));
- return false;
- }
- if (!is_numeric($_POST['price']))
+
+ if (!check_num('price', 0))
{
- display_error(_("The price entered must be numeric."));
+ display_error(_("The price entered must be numeric and not less than zero."));
return false;
}
if (!is_date($_POST['req_del_date'])){
$allow_update = check_data();
if ($allow_update &&
- ($_SESSION['PO']->line_items[$_POST['line_no']]->qty_inv > $_POST['qty'] ||
- $_SESSION['PO']->line_items[$_POST['line_no']]->qty_received > $_POST['qty']))
+ ($_SESSION['PO']->line_items[$_POST['line_no']]->qty_inv > input_num('qty') ||
+ $_SESSION['PO']->line_items[$_POST['line_no']]->qty_received > input_num('qty')))
{
display_error(_("You are attempting to make the quantity ordered a quantity less than has already been invoiced or received. This is prohibited.") .
"<br>" . _("The quantity received can only be modified by entering a negative receipt and the quantity invoiced can only be reduced by entering a credit note against this item."));
return;
}
- $_SESSION['PO']->update_order_item($_POST['line_no'], $_POST['qty'], $_POST['price'],
+ $_SESSION['PO']->update_order_item($_POST['line_no'], input_num('qty'), input_num('price'),
$_POST['req_del_date']);
unset_form_variables();
}
if ($allow_update)
{
$myrow = db_fetch($result);
- $_SESSION['PO']->add_to_order ($_POST['line_no'], $_POST['stock_id'], $_POST['qty'],
- $myrow["description"], $_POST['price'], $myrow["units"],
+ $_SESSION['PO']->add_to_order ($_POST['line_no'], $_POST['stock_id'], input_num('qty'),
+ $myrow["description"], input_num('price'), $myrow["units"],
$_POST['req_del_date'], 0, 0);
unset_form_variables();
//echo "<BR>";
//echo get_gl_view_str(25, $grn, _("View the GL Journal Entries for this Delivery"));
- echo "<br>";
+// echo "<br>";
hyperlink_no_params("$path_to_root/purchasing/inquiry/po_search.php", _("Select a different purchase order for receiving items against"));
display_footer_exit();
qty_cell($qty_outstanding);
if ($qty_outstanding > 0)
- text_cells(null, $ln_itm->line_no, $ln_itm->receive_qty, 10, 10, "align=right");
+ amount_cells(null, $ln_itm->line_no, qty_format($ln_itm->receive_qty), "align=right");
else
- text_cells(null, $ln_itm->line_no, $ln_itm->receive_qty, 10, 10, "align=right",
- "", "disabled");
+ amount_cells(null, $ln_itm->line_no, qty_format($ln_itm->receive_qty), "align=right",
+ "disabled");
amount_cell($ln_itm->price);
amount_cell($line_total);
{
$_POST[$line->line_no] = max($_POST[$line->line_no], 0);
- if (!is_numeric($_POST[$line->line_no]))
- $_POST[$line->line_no] = 0;
+ if (!check_num($line->line_no))
+ $_POST[$line->line_no] = qty_format(0);
if (!isset($_POST['DefaultReceivedDate']) || $_POST['DefaultReceivedDate'] == "")
$_POST['DefaultReceivedDate'] = Today();
- $_SESSION['PO']->line_items[$line->line_no]->receive_qty = $_POST[$line->line_no];
+ $_SESSION['PO']->line_items[$line->line_no]->receive_qty = input_num($line->line_no);
if (isset($_POST[$line->stock_id . "Desc"]) && strlen($_POST[$line->stock_id . "Desc"]) > 0)
{
function check_data()
{
- if (!is_numeric($_POST['This_QuantityCredited']))
+ if (!check_num('This_QuantityCredited', 0))
{
- display_error(_("The quantity to credit must be numeric."));
+ display_error(_("The quantity to credit must be numeric and greater than zero."));
return false;
}
- if ($_POST['This_QuantityCredited'] <= 0)
- {
- display_error(_("The quantity to credit must be greater than zero."));
- return false;
- }
-
- if (!is_numeric($_POST['ChgPrice']) || $_POST['ChgPrice'] < 0)
+ if (!check_num('ChgPrice', 0))
{
display_error(_("The price is either not numeric or negative."));
return false;
$_SESSION['supp_trans']->add_grn_to_trans($_POST['GRNNumber'],
$_POST['po_detail_item'], $_POST['item_code'],
$_POST['item_description'], $_POST['qty_recd'],
- $_POST['prev_quantity_inv'], $_POST['This_QuantityCredited'],
- $_POST['order_price'], $_POST['ChgPrice'], $complete,
+ $_POST['prev_quantity_inv'], input_num('This_QuantityCredited'),
+ $_POST['order_price'], input_num('ChgPrice'), $complete,
$_POST['std_cost_unit'], "");
}
}
label_cell($_POST['grn_item_id']);
label_cell($myrow['item_code'] . " " . $myrow['description']);
qty_cell($myrow["quantity_inv"]);
- text_cells(null, 'This_QuantityCredited', max($myrow['quantity_inv'], 0), 13, 15);
+ amount_cells(null, 'This_QuantityCredited', qty_format(max($myrow['quantity_inv'],0)));
amount_cell($myrow['unit_price']);
- text_cells(null, 'ChgPrice', $myrow['unit_price'], 13, 15);
+ amount_cells(null, 'ChgPrice', price_format($myrow['unit_price']));
end_row();
end_table(1);
{
global $check_price_charged_vs_order_price,
$check_qty_charged_vs_del_qty;
- if (!is_numeric($_POST['this_quantity_inv']))
+ if (!check_num('this_quantity_inv', 0) || input_num('this_quantity_inv')==0)
{
- display_error( _("The quantity to invoice must be numeric."));
+ display_error( _("The quantity to invoice must be numeric and greater than zero."));
return false;
}
- if ($_POST['this_quantity_inv'] <= 0)
- {
- display_error( _("The quantity to invoice must be greater than zero."));
- return false;
- }
-
- if (!is_numeric($_POST['ChgPrice']))
+ if (!check_num('ChgPrice'))
{
display_error( _("The price is not numeric."));
return false;
if ($check_price_charged_vs_order_price == True)
{
- if ($_POST['ChgPrice']/$_POST['order_price'] >
+ if (input_num('ChgPrice')/$_POST['order_price'] >
(1 + (sys_prefs::over_charge_allowance() / 100)))
{
display_error(_("The price being invoiced is more than the purchase order price by more than the allowed over-charge percentage. The system is set up to prohibit this. See the system administrator to modify the set up parameters if necessary.") .
if ($check_qty_charged_vs_del_qty == True)
{
- if ($_POST['this_quantity_inv'] / ($_POST['qty_recd'] - $_POST['prev_quantity_inv']) >
+ if (input_num('this_quantity_inv') / ($_POST['qty_recd'] - $_POST['prev_quantity_inv']) >
(1+ (sys_prefs::over_charge_allowance() / 100)))
{
display_error( _("The quantity being invoiced is more than the outstanding quantity by more than the allowed over-charge percentage. The system is set up to prohibit this. See the system administrator to modify the set up parameters if necessary.")
if (check_data())
{
- if ($_POST['this_quantity_inv'] >= ($_POST['qty_recd'] - $_POST['prev_quantity_inv']))
+ if (input_num('this_quantity_inv') >= ($_POST['qty_recd'] - $_POST['prev_quantity_inv']))
{
$complete = True;
}
$complete = False;
}
- //$_SESSION['supp_trans']->add_grn_to_trans($_POST['GRNNumber'], $_POST['po_detail_item'],
- // $_POST['item_code'], $_POST['item_description'], $_POST['qty_recd'],
- // $_POST['prev_quantity_inv'], $_POST['this_quantity_inv'],
- // $_POST['order_price'], $_POST['ChgPrice'], $complete,
- // $_POST['std_cost_unit'], $_POST['gl_code']);
$_SESSION['supp_trans']->add_grn_to_trans($_POST['GRNNumber'], $_POST['po_detail_item'],
$_POST['item_code'], $_POST['item_description'], $_POST['qty_recd'],
- $_POST['prev_quantity_inv'], $_POST['this_quantity_inv'],
- $_POST['order_price'], $_POST['ChgPrice'], $complete,
+ $_POST['prev_quantity_inv'], input_num('this_quantity_inv'),
+ $_POST['order_price'], input_num('ChgPrice'), $complete,
$_POST['std_cost_unit'], "");
}
}
label_cell($myrow['item_code']);
label_cell($myrow['description']);
qty_cell($myrow['QtyOstdg']);
- text_cells(null, 'this_quantity_inv', $myrow['QtyOstdg'], 13, 15);
+ amount_cells(null, 'this_quantity_inv', qty_format($myrow['QtyOstdg']));
amount_cell($myrow['unit_price']);
- text_cells(null, 'ChgPrice', $myrow['unit_price'], 13, 15);
+ small_amount_cells(null, 'ChgPrice', price_format($myrow['unit_price']));
end_row();
end_table(1);;
display_note(get_gl_view_str(22, $payment_id, _("View the GL Journal Entries for this Payment")));
- echo "<center><br>";
hyperlink_params($path_to_root . "/purchasing/allocations/supplier_allocate.php", _("Allocate this Payment"), "trans_no=$payment_id&trans_type=22");
- echo "<br><br>";
hyperlink_params($_SERVER['PHP_SELF'], _("Enter another supplier payment"), "supplier_id=" . $_POST['supplier_id']);
- echo "</center><br><br>";
-
- end_page();
- exit;
+ display_footer_exit();
}
//----------------------------------------------------------------------------------------
{
if ($_POST['amount'] == "")
{
- $_POST['amount'] = 0;
+ $_POST['amount'] = price_format(0);
}
- if (!is_numeric($_POST['amount']) || $_POST['amount'] < 0)
+ if (!check_num('amount', 0))
{
display_error(_("The entered amount is invalid or less than zero."));
return false;
$_POST['discount'] = 0;
}
- if (!is_numeric($_POST['discount']) OR $_POST['discount'] < 0)
+ if (!check_num('discount', 0))
{
display_error(_("The entered discount is invalid or less than zero."));
return false;
}
- if ($_POST['amount'] - $_POST['discount'] <= 0)
+ if (input_num('amount') - input_num('discount') <= 0)
{
display_error(_("The total of the amount and the discount negative. Please enter positive values."));
return false;
{
$payment_id = add_supp_payment($_POST['supplier_id'], $_POST['DatePaid'],
$_POST['PaymentType'], $_POST['bank_account'],
- $_POST['amount'], $_POST['discount'], $_POST['ref'], $_POST['memo_']);
+ input_num('amount'), input_num('discount'), $_POST['ref'], $_POST['memo_']);
//unset($_POST['supplier_id']);
unset($_POST['bank_account']);
{
$myrow = db_fetch_row($result);
$gl_act_name = $myrow[1];
- if (!is_numeric($_POST['amount']))
+ if (!check_num('amount'))
{
display_error(_("The amount entered is not numeric. This line cannot be added to the transaction."));
$input_error = true;
if ($input_error == false)
{
$_SESSION['supp_trans']->add_gl_codes_to_trans($_POST['gl_code'], $gl_act_name,
- $_POST['dimension_id'], $_POST['dimension2_id'], $_POST['amount'], $_POST['memo_']);
+ $_POST['dimension_id'], $_POST['dimension2_id'],
+ input_num('amount'), $_POST['memo_']);
clear_fields();
}
}
for ($counter = 0; $counter < $_POST["TotalNumberOfAllocs"]; $counter++)
{
- if (!is_numeric($_POST['amount' . $counter]))
+ if (!check_num('amount' . $counter))
{
display_error(_("The entry for one or more amounts is invalid."));
return false;
}
- if ($_POST['amount' . $counter] < 0)
+ if (!check_num('amount' . $counter,0))
{
display_error(_("The entry for an amount to allocate was negative. A positive allocation amount is expected."));
return false;
/*Now check to see that the AllocAmt is no greater than the
amount left to be allocated against the transaction under review */
- if ($_POST['amount' . $counter] > $_POST['un_allocated' . $counter])
+ if (input_num('amount' . $counter) > $_POST['un_allocated' . $counter])
{
//$_POST['amount' . $counter] = $_POST['un_allocated' . $counter];
}
- $_SESSION['alloc']->allocs[$counter]->current_allocated = $_POST['amount' . $counter];
+ $_SESSION['alloc']->allocs[$counter]->current_allocated = input_num('amount' . $counter);
- $total_allocated += $_POST['amount' . $counter];
+ $total_allocated += input_num('amount' . $counter);
}
if ($total_allocated - $_SESSION['alloc']->amount > sys_prefs::allocation_settled_allowance())
update_debtor_trans_allocation($allocn_item->type, $allocn_item->type_no,
$allocn_item->current_allocated);
$total_allocated += $allocn_item->current_allocated;
+
}
} /*end of the loop through the array of allocations made */
display_heading($_SESSION['alloc']->person_name);
display_heading2(_("Date:") . " <b>" . $_SESSION['alloc']->date_ . "</b>");
- display_heading2(_("Total:") . " <b>" . number_format2($_SESSION['alloc']->amount,user_price_dec()) . "</b>");
+ display_heading2(_("Total:") . " <b>" . price_format($_SESSION['alloc']->amount) . "</b>");
echo "<br>";
amount_cell($allocn_item->amount);
amount_cell($allocn_item->amount_allocated);
- if (!isset($_POST['amount' . $counter]) || $_POST['amount' . $counter] == "")
- $_POST['amount' . $counter] = $allocn_item->current_allocated;
- text_cells(null, "amount" . $counter, $_POST['amount' . $counter], 13, 12);
+ if (!check_num('amount' . $counter))
+ $_POST['amount' . $counter] = price_format($allocn_item->current_allocated);
+ amount_cells(null, 'amount' . $counter, $_POST['amount' . $counter]);
$un_allocated = round($allocn_item->amount - $allocn_item->amount_allocated, 6);
hidden("un_allocated" . $counter, $un_allocated);
. _("None") . "</a>");
end_row();
- $total_allocated += $_POST['amount' . $counter];
+ $total_allocated += input_num('amount' . $counter);
$counter++;
}
- label_row(_("Total Allocated"), number_format2($total_allocated,user_price_dec()),
+ label_row(_("Total Allocated"), price_format($total_allocated),
"colspan=6 align=right", "nowrap align=right");
if ($_SESSION['alloc']->amount - $total_allocated < 0)
{
else
$font1 = $font2 = "";
$left_to_allocate = $_SESSION['alloc']->amount - $total_allocated;
- $left_to_allocate = number_format2($left_to_allocate, user_price_dec());
+ $left_to_allocate = price_format($left_to_allocate);
label_row(_("Left to Allocate"), $font1 . $left_to_allocate . $font2,
- "colspan=6 align=right", "nowrap align=right");
+ "colspan=6 align=right ", "nowrap align=right");
end_table(1);
hidden('TotalNumberOfAllocs', $counter);
{
$_SESSION['Items']->Comments = $_POST['CreditText'];
$_SESSION['Items']->document_date = $_POST['OrderDate'];
- $_SESSION['Items']->freight_cost = $_POST['ChargeFreightCost'];
+ $_SESSION['Items']->freight_cost = input_num('ChargeFreightCost');
$_SESSION['Items']->Location = $_POST["Location"];
$_SESSION['Items']->sales_type = $_POST['sales_type_id'];
$_SESSION['Items']->reference = $_POST['ref'];
{
$_POST['CreditText'] = $_SESSION['Items']->Comments;
$_POST['OrderDate'] = $_SESSION['Items']->document_date;
- $_POST['ChargeFreightCost'] = $_SESSION['Items']->freight_cost;
+ $_POST['ChargeFreightCost'] = price_format($_SESSION['Items']->freight_cost);
$_POST['Location'] = $_SESSION['Items']->Location;
$_POST['sales_type_id'] = $_SESSION['Items']->sales_type;
$_POST['ref'] = $_SESSION['Items']->reference;
$input_error = 0;
- if ($_SESSION['Items']->count_items() == 0
- && (!isset($_POST['ChargeFreightCost']) || $_POST['ChargeFreightCost'] <= 0))
+ if ($_SESSION['Items']->count_items() == 0 && (!check_num('ChargeFreightCost',0)))
return false;
-
- if (!references::is_valid($_POST['ref'])) {
+ if($_SESSION['Items']->trans_no == 0) {
+ if (!references::is_valid($_POST['ref'])) {
display_error( _("You must enter a reference."));
$input_error = 1;
- } elseif (!is_new_reference($_POST['ref'], 11)) {
+ } elseif (!is_new_reference($_POST['ref'], 11)) {
display_error( _("The entered reference is already in use."));
$input_error = 1;
- } elseif (!is_date($_POST['OrderDate'])) {
+ }
+ }
+ if (!is_date($_POST['OrderDate'])) {
display_error(_("The entered date for the credit note is invalid."));
$input_error = 1;
} elseif (!is_date_in_fiscalyear($_POST['OrderDate'])) {
function check_item_data()
{
- if ($_POST['qty'] <= 0) {
+ if (!check_num('qty',0)) {
display_error(_("The quantity must be greater than zero."));
return false;
}
- if (!is_numeric($_POST['price']) || $_POST['price'] < 0) {
+ if (!check_num('price',0)) {
display_error(_("The entered price is negative or invalid."));
return false;
}
- if (!is_numeric($_POST['Disc']) || $_POST['Disc'] > 100 || $_POST['Disc'] < 0) {
+ if (!check_num('Disc', 0, 100)) {
display_error(_("The entered discount percent is negative, greater than 100 or invalid."));
return false;
}
function handle_update_item()
{
if ($_POST['UpdateItem'] != "" && check_item_data()) {
- $_SESSION['Items']->update_cart_item($_POST['line_no'], $_POST['qty'],
- $_POST['price'], ($_POST['Disc'] / 100));
+ $_SESSION['Items']->update_cart_item($_POST['line_no'], input_num('qty'),
+ input_num('price'), input_num('Disc') / 100);
}
}
if (!check_item_data())
return;
- add_to_order($_SESSION['Items'], $_POST['stock_id'], $_POST['qty'],
- $_POST['price'], $_POST['Disc'] / 100);
+ add_to_order($_SESSION['Items'], $_POST['stock_id'], input_num('qty'),
+ input_num('price'), input_num('Disc') / 100);
}
//-----------------------------------------------------------------------------
if (isset($_GET['Delete']) || isset($_GET['Edit']))
return false;
}
}
- if (!is_numeric($_POST['ChargeFreightCost']) || $_POST['ChargeFreightCost'] < 0) {
+ if (!check_num('ChargeFreightCost', 0)) {
display_error(_("The entered shipping cost is invalid or less than zero."));;
return false;
}
} else {
foreach ($_SESSION['Items']->line_items as $line_no=>$itm) {
if (isset($_POST['Line'.$line_no])) {
- $line_qty = $_POST['Line'.$line_no];
- if (is_numeric($line_qty) && $_POST['Line'.$line_no] <= ($itm->quantity - $itm->qty_done)) {
- $_SESSION['Items']->line_items[$line_no]->qty_dispatched = $line_qty;
+ if (check_num('Line'.$line_no, ($itm->quantity - $itm->qty_done))) {
+ $_SESSION['Items']->line_items[$line_no]->qty_dispatched =
+ input_num('Line'.$line_no);
}
}
{
$cart = &$_SESSION['Items'];
$cart->ship_via = $_POST['ShipperID'];
- $cart->freight_cost = $_POST['ChargeFreightCost'];
+ $cart->freight_cost = input_num('ChargeFreightCost');
$cart->document_date = $_POST['CreditDate'];
$cart->Location = $_POST['Location'];
$cart->Comments = $_POST['CreditText'];
{
$cart = &$_SESSION['Items'];
$_POST['ShipperID'] = $cart->ship_via;
- $_POST['ChargeFreightCost'] = $cart->freight_cost;
+ $_POST['ChargeFreightCost'] = price_format($cart->freight_cost);
$_POST['CreditDate']= $cart->document_date;
$_POST['Location']= $cart->Location;
$_POST['CreditText']= $cart->Comments;
// view_stock_status_cell($ln_itm->stock_id); alternative view
label_cell($ln_itm->stock_id);
- text_cells(null, 'Line'.$line_no.'Desc', $ln_itm->item_description, 30, 50);
+ text_cells(null, 'Line'.$line_no.'Desc', $ln_itm->item_description, 30, 50);
qty_cell($ln_itm->quantity);
label_cell($ln_itm->units);
- text_cells(null, 'Line'.$line_no, $ln_itm->qty_dispatched, 13, 15);
+
+ amount_cells(null, 'Line'.$line_no, qty_format($ln_itm->qty_dispatched));
$line_total =($ln_itm->qty_dispatched * $ln_itm->price * (1 - $ln_itm->discount_percent));
amount_cell($ln_itm->price);
- amount_cell($ln_itm->discount_percent*100);
+ percent_cell($ln_itm->discount_percent*100);
amount_cell($line_total);
end_row();
}
- if (!isset($_POST['ChargeFreightCost']) || ($_POST['ChargeFreightCost'] == "")) {
- $_POST['ChargeFreightCost'] = $_SESSION['Items']->freight_cost;
+ if (!check_num('ChargeFreightCost')) {
+ $_POST['ChargeFreightCost'] = price_format($_SESSION['Items']->freight_cost);
}
- if (!is_numeric($_POST['ChargeFreightCost']))
- {
- $_POST['ChargeFreightCost'] = 0;
- }
start_row();
label_cell(_("Credit Shipping Cost"), "colspan=7 align=right");
- text_cells(null, "ChargeFreightCost", $_POST['ChargeFreightCost'], 6, 6);
+ amount_cells(null, "ChargeFreightCost", $_POST['ChargeFreightCost'], 6, 6);
end_row();
$inv_items_total = $_SESSION['Items']->get_items_total_dispatch();
- $display_sub_total = number_format2($inv_items_total + $_POST['ChargeFreightCost'],user_price_dec());
+ $display_sub_total = price_format($inv_items_total + input_num($_POST['ChargeFreightCost']));
label_row(_("Sub-total"), $display_sub_total, "colspan=7 align=right", "align=right");
- $taxes = $_SESSION['Items']->get_taxes($_POST['ChargeFreightCost']);
+ $taxes = $_SESSION['Items']->get_taxes(input_num($_POST['ChargeFreightCost']));
$tax_total = display_edit_tax_items($taxes, 7, $_SESSION['Items']->tax_included);
- $display_total = number_format2(($inv_items_total + $_POST['ChargeFreightCost'] + $tax_total), user_price_dec());
+ $display_total = price_format(($inv_items_total + input_num('ChargeFreightCost') + $tax_total));
label_row(_("Credit Note Total"), $display_total, "colspan=7 align=right", "align=right");
exit;
} elseif (!check_quantities()) {
- display_error(_("Selected quantity cannot be less then quantity invoiced nor more then quantity
+ display_error(_("Selected quantity cannot be less than quantity invoiced nor more than quantity
not dispatched on sales order."));
-}
+
+} elseif(!check_num('ChargeFreightCost', 0))
+ display_error(_("Freight cost cannot be less than zero"));
+
+
//-----------------------------------------------------------------------------
function check_data()
}
}
if ($_POST['ChargeFreightCost'] == "") {
- $_POST['ChargeFreightCost'] = 0;
+ $_POST['ChargeFreightCost'] = price_format(0);
}
- if (!is_numeric($_POST['ChargeFreightCost']) || $_POST['ChargeFreightCost'] < 0) {
+ if (!check_num('ChargeFreightCost',0)) {
display_error(_("The entered shipping value is not numeric."));
return false;
}
- if ($_SESSION['Items']->has_items_dispatch() == 0 && $_POST['ChargeFreightCost'] == 0) {
+ if ($_SESSION['Items']->has_items_dispatch() == 0 && input_num('ChargeFreightCost') == 0) {
display_error(_("There are no item quantities on this delivery note."));
return false;
}
if (!check_quantities()) {
- display_error(_("Selected quantity cannot be less then quantity invoiced nor more then quantity
+ display_error(_("Selected quantity cannot be less than quantity invoiced nor more than quantity
not dispatched on sales order."));
return false;
}
{
$cart = &$_SESSION['Items'];
$cart->ship_via = $_POST['ship_via'];
- $cart->freight_cost = $_POST['ChargeFreightCost'];
+ $cart->freight_cost = input_num('ChargeFreightCost');
$cart->document_date = $_POST['DispatchDate'];
$cart->due_date = $_POST['due_date'];
$cart->Location = $_POST['Location'];
{
$cart = &$_SESSION['Items'];
$_POST['ship_via'] = $cart->ship_via;
- $_POST['ChargeFreightCost'] = $cart->freight_cost;
+ $_POST['ChargeFreightCost'] = price_format($cart->freight_cost);
$_POST['DispatchDate']= $cart->document_date;
$_POST['due_date'] = $cart->due_date;
$_POST['Location']= $cart->Location;
// Update cart delivery quantities/descriptions
foreach ($_SESSION['Items']->line_items as $line=>$itm) {
if (isset($_POST['Line'.$line])) {
- $line_qty = $_POST['Line'.$line];
- if (is_numeric($line_qty) && ($_POST['Line'.$line] <= $itm->quantity) &&
- ($_POST['Line'.$line] >= $itm->qty_done)) {
-
- $_SESSION['Items']->line_items[$line]->qty_dispatched = $line_qty;
+ if (!check_num('Line'.$line, $itm->qty_done, $itm->quantity) == 0) {
+ $_SESSION['Items']->line_items[$line]->qty_dispatched =
+ input_num('Line'.$line);
} else {
$ok = 0;
}
}
}
}
- $_SESSION['Items']->freight_cost = $_POST['ChargeFreightCost'];
-
+// ...
+// else
+// $_SESSION['Items']->freight_cost = input_num('ChargeFreightCost');
return $ok;
}
//------------------------------------------------------------------------------
label_cell($ln_itm->units);
qty_cell($ln_itm->qty_done);
- text_cells(null, 'Line'.$line, $ln_itm->qty_dispatched, 10, 10);
+ small_amount_cells(null, 'Line'.$line, qty_format($ln_itm->qty_dispatched));
- $display_discount_percent = number_format2($ln_itm->discount_percent*100,user_percent_dec()) . "%";
+ $display_discount_percent = percent_format($ln_itm->discount_percent*100) . "%";
$line_total = ($ln_itm->qty_dispatched * $ln_itm->price * (1 - $ln_itm->discount_percent));
end_row();
}
-$_POST['ChargeFreightCost'] = $_SESSION['Items']->freight_cost;
+$_POST['ChargeFreightCost'] = price_format($_SESSION['Items']->freight_cost);
-if (!is_numeric($_POST['ChargeFreightCost'])) {
- $_POST['ChargeFreightCost'] = 0;
+if (!check_num('ChargeFreightCost')) {
+ $_POST['ChargeFreightCost'] = price_format(0);
}
start_row();
$inv_items_total = $_SESSION['Items']->get_items_total_dispatch();
-$display_sub_total = number_format2($inv_items_total + $_POST['ChargeFreightCost'],user_price_dec());
+$display_sub_total = price_format($inv_items_total + input_num('ChargeFreightCost'));
label_row(_("Sub-total"), $display_sub_total, "colspan=9 align=right","align=right");
-$taxes = $_SESSION['Items']->get_taxes($_POST['ChargeFreightCost']);
+$taxes = $_SESSION['Items']->get_taxes(input_num('ChargeFreightCost'));
$tax_total = display_edit_tax_items($taxes, 9, $_SESSION['Items']->tax_included);
-$display_total = number_format2(($inv_items_total + $_POST['ChargeFreightCost'] + $tax_total), user_price_dec());
+$display_total = price_format(($inv_items_total + input_num('ChargeFreightCost') + $tax_total));
label_row(_("Amount Total"), $display_total, "colspan=9 align=right","align=right");
} else {
foreach ($_SESSION['Items']->line_items as $line_no=>$itm) {
if (isset($_POST['Line'.$line_no])) {
- $line_qty = $_POST['Line'.$line_no];
- if (is_numeric($line_qty) && $_POST['Line'.$line_no] <= ($itm->quantity - $itm->qty_done)) {
- $_SESSION['Items']->line_items[$line_no]->qty_dispatched = $line_qty;
+ if (!check_num('Line'.$line_no, 0, ($itm->quantity - $itm->qty_done))) {
+ $_SESSION['Items']->line_items[$line_no]->qty_dispatched =
+ input_num('Line'.$line_no);
}
}
{
$cart = &$_SESSION['Items'];
$cart->ship_via = $_POST['ship_via'];
- $cart->freight_cost = $_POST['ChargeFreightCost'];
+ $cart->freight_cost = input_num('ChargeFreightCost');
$cart->document_date = $_POST['InvoiceDate'];
$cart->due_date = $_POST['due_date'];
$cart->Comments = $_POST['Comments'];
{
$cart = &$_SESSION['Items'];
$_POST['ship_via'] = $cart->ship_via;
- $_POST['ChargeFreightCost'] = $cart->freight_cost;
+ $_POST['ChargeFreightCost'] = price_format($cart->freight_cost);
$_POST['InvoiceDate']= $cart->document_date;
$_POST['due_date'] = $cart->due_date;
$_POST['Comments']= $cart->Comments;
}
if ($_POST['ChargeFreightCost'] == "") {
- $_POST['ChargeFreightCost'] = 0;
+ $_POST['ChargeFreightCost'] = price_format(0);
}
- if (!is_numeric($_POST['ChargeFreightCost']) || $_POST['ChargeFreightCost'] < 0) {
+ if (!check_num('ChargeFreightCost', 0)) {
display_error(_("The entered shipping value is not numeric."));
return false;
}
- if ($_SESSION['Items']->has_items_dispatch() == 0 && $_POST['ChargeFreightCost'] == 0) {
+ if ($_SESSION['Items']->has_items_dispatch() == 0 && input_num('ChargeFreightCost') == 0) {
display_error(_("There are no item quantities on this invoice."));
return false;
}
_("This Invoice"), _("Price"), _("Tax Type"), _("Discount"), _("Total"));
if ($is_batch_invoice) {
-$th[] = _("DN");
-$th[] = "";
+ $th[] = _("DN");
+ $th[] = "";
}
if ($is_edition) {
-$th[4] = _("Credited");
+ $th[4] = _("Credited");
}
table_header($th);
// for batch invoices we can only remove whole deliveries
echo '<td nowrap align=right>';
hidden('Line' . $line, $ln_itm->qty_dispatched );
- echo number_format2($ln_itm->qty_dispatched, user_qty_dec()).'</td>';
+ echo qty_format($ln_itm->qty_dispatched).'</td>';
} else {
- text_cells(null, 'Line'.$line, $ln_itm->qty_dispatched, 10, 10);
+ small_amount_cells(null, 'Line'.$line, qty_format($ln_itm->qty_dispatched));
}
- $display_discount_percent = number_format2($ln_itm->discount_percent*100, user_percent_dec()) . "%";
+ $display_discount_percent = percent_format($ln_itm->discount_percent*100) . " %";
$line_total = ($ln_itm->qty_dispatched * $ln_itm->price * (1 - $ln_itm->discount_percent));
if (!isset($_POST['ChargeFreightCost']) || $_POST['ChargeFreightCost'] == "") {
if ($_SESSION['Items']->any_already_delivered() == 1) {
- $_POST['ChargeFreightCost'] = 0;
+ $_POST['ChargeFreightCost'] = price_format(0);
} else {
- $_POST['ChargeFreightCost'] = $_SESSION['Items']->freight_cost;
+ $_POST['ChargeFreightCost'] = price_format($_SESSION['Items']->freight_cost);
}
- if (!is_numeric($_POST['ChargeFreightCost'])) {
- $_POST['ChargeFreightCost'] = 0;
+ if (!check_num('ChargeFreightCost')) {
+ $_POST['ChargeFreightCost'] = price_format(0);
}
}
end_row();
$inv_items_total = $_SESSION['Items']->get_items_total_dispatch();
-$display_sub_total = number_format2($inv_items_total + $_POST['ChargeFreightCost'],user_price_dec());
+$display_sub_total = price_format($inv_items_total + input_num('ChargeFreightCost'));
label_row(_("Sub-total"), $display_sub_total, "colspan=9 align=right","align=right", $is_batch_invoice ? 2 : 0);
-$taxes = $_SESSION['Items']->get_taxes($_POST['ChargeFreightCost']);
+$taxes = $_SESSION['Items']->get_taxes(input_num('ChargeFreightCost'));
$tax_total = display_edit_tax_items($taxes, 9, $_SESSION['Items']->tax_included, $is_batch_invoice ? 2:0);
-$display_total = number_format2(($inv_items_total + $_POST['ChargeFreightCost'] + $tax_total), user_price_dec());
+$display_total = price_format(($inv_items_total + input_num('ChargeFreightCost') + $tax_total));
label_row(_("Invoice Total"), $display_total, "colspan=9 align=right","align=right", $is_batch_invoice ? 2 : 0);
return false;
}
- if ((!is_numeric($_POST['amount']) || $_POST['amount'] < 0)) {
+ if (!check_num('amount', 0)) {
display_error(_("The entered amount is invalid or negative and cannot be processed."));
return false;
}
- if (!isset($_POST['discount']) || ($_POST['discount'] == "")) {
- $_POST['discount'] = 0;
- }
-
- if (!is_numeric($_POST['discount'])) {
+ if (!check_num('discount')) {
display_error(_("The entered discount is not a valid number."));
return false;
}
- if (($_POST['amount'] - $_POST['discount'] <= 0)) {
+ if ((input_num('amount') - input_num('discount') <= 0)) {
display_error(_("The balance of the amount and discout is zero or negative. Please enter valid amounts."));
return false;
}
if (isset($_POST['AddPaymentItem'])) {
$payment_no = write_customer_payment(0, $_POST['customer_id'], $_POST['BranchID'],
$_POST['bank_account'], $_POST['DateBanked'], $_POST['ReceiptType'], $_POST['ref'],
- $_POST['amount'], $_POST['discount'], $_POST['memo_']);
+ input_num('amount'), input_num('discount'), $_POST['memo_']);
meta_forward($_SERVER['PHP_SELF'], "AddedID=$payment_no");
}
echo "</table></table>";
display_note(_("This customer account is on hold."), 0, 0, "class='redfb'");
} else {
- $display_discount_percent = number_format2($_POST['pymt_discount']*100,user_price_dec()) . "%";
+ $display_discount_percent = percent_format($_POST['pymt_discount']*100) . "%";
amount_row(_("Amount:"), 'amount');
if (!isset($_POST['ref']))
$_POST['ref'] = references::get_next(11);
if ($_SESSION['Items']->trans_no==0)
- ref_row(_("Reference:"), 'ref');
+ ref_row(_("Reference").':', 'ref');
else
- label_row(_("Reference"), $_POST['ref'], "class='tableheader2'");
+ label_row(_("Reference").':', $_POST['ref'] );
if (!isset($_GET['Edit']))
credit_edit_item_controls($order);
- $display_sub_total = number_format2($subtotal,user_price_dec());
+ $display_sub_total = price_format($subtotal);
label_row(_("Sub-total"), $display_sub_total, "colspan=6 align=right", "align=right");
if (!isset($_POST['ChargeFreightCost']) OR ($_POST['ChargeFreightCost'] == ""))
- $_POST['ChargeFreightCost'] = 0;
+ $_POST['ChargeFreightCost'] = price_format(0);
- text_row(_("Shipping"), 'ChargeFreightCost', $_POST['ChargeFreightCost'], 8, 8, "colspan=6 align=right");
+ amount_cells_ex(_("Shipping"), 'ChargeFreightCost', 8, 8, $_POST['ChargeFreightCost'], "colspan=6 align=right");
$taxes = $order->get_taxes($_POST['ChargeFreightCost']);
$tax_total = display_edit_tax_items($taxes, 6, $_SESSION['Items']->tax_included);
- $display_total = number_format2(($subtotal + $_POST['ChargeFreightCost'] + $tax_total), user_price_dec());
- label_row(_("Credit Note Total"), $display_total, "colspan=6 align=right","align=right");
+ $display_total = price_format(($subtotal + $_POST['ChargeFreightCost'] + $tax_total));
+
+ label_row(_("Credit Note Total"), $display_total, "colspan=6 align=right","class='amount'");
end_table();
}
if (!isset($_POST['stock_id']))
$_POST['stock_id'] = $order->line_items[$_GET['Edit']]->stock_id;
if (!isset($_POST['qty']) || ($_POST['qty']==""))
- $_POST['qty'] = $order->line_items[$_GET['Edit']]->qty_dispatched;
+ $_POST['qty'] = qty_format($order->line_items[$_GET['Edit']]->qty_dispatched);
if (!isset($_POST['price']) || ($_POST['price']==""))
- $_POST['price'] = $order->line_items[$_GET['Edit']]->price;
+ $_POST['price'] = price_format($order->line_items[$_GET['Edit']]->price);
if (!isset($_POST['Disc']) || ($_POST['Disc']==""))
- $_POST['Disc'] = ($order->line_items[$_GET['Edit']]->discount_percent)*100;
+ $_POST['Disc'] = percent_format(($order->line_items[$_GET['Edit']]->discount_percent)*100);
$_POST['units'] = $order->line_items[$_GET['Edit']]->units;
text_cells(null, "StockID2", "", 12, 10, "", "", "onkeyup='recalcAccounts();' onKeyDown='if (event.keyCode==13) event.keyCode=9;' onblur='return setAccount(0, true);'");
stock_items_list_cells(null, 'stock_id', null, false, false, "onchange='return setAccount(1, true)'");
}
- $item_info = get_item_edit_info($_POST['stock_id']);
+ $item_info = get_item_edit_info($_POST['stock_id']);
$_POST['units'] = $item_info["units"];
- $_POST['qty'] = 0;
+ $_POST['qty'] = qty_format(0);
$_POST['price'] = get_price($_POST['stock_id'],
$order->customer_currency, $order->sales_type);
// default to the customer's discount %
- $_POST['Disc'] = $order->default_discount * 100;
+ $_POST['Disc'] = percent_format($order->default_discount * 100);
}
- text_cells(null, 'qty', $_POST['qty'], 13, 15);
+ amount_cells(null, 'qty', $_POST['qty']);
// if ($order->trans_no!=0) {
// amount_cell($line_no==-1 ? 0 :$order->line_items[$line_no]->qty_done);
// }
label_cell($_POST['units']);
- text_cells(null, 'price', null, 13, 15);
- text_cells(null, 'Disc', $_POST['Disc'], 7, 5);
+ amount_cells(null, 'price', null);
+ small_amount_cells(null, 'Disc', percent_format(0));
amount_cell($_POST['qty'] * $_POST['price'] * (1 - $_POST['Disc']/100));
function add_to_order(&$order, $new_item, $new_item_qty, $price, $discount)
{
- foreach ($order->line_items AS $order_item)
+ foreach ($order->line_items AS $order_item)
{
- if (strcasecmp($order_item->stock_id, $new_item) == 0)
- {
- display_notification(_("For Part :") . $new_item . " " . _("This item is already on this order. You have been warned."));
- break;
+ if (strcasecmp($order_item->stock_id, $new_item) == 0)
+ {
+ display_notification(_("For Part :") . $new_item . " " . _("This item is already on this order. You have been warned."));
+ break;
}
}
-
+
$order->add_to_cart (count($order->line_items),$new_item, $new_item_qty, $price, $discount);
}
$ret_error = "";
$myrow = get_customer_to_order($customer_id);
-
+
$name = $myrow['name'];
if ($myrow['dissallow_invoices'] == 1)
$ret_error = _("The selected customer account is currently on hold. Please contact the credit control personnel to discuss.");
-/* if (!isset($_POST['branch_id']) || $_POST['branch_id'] == "")
+/* if (!isset($_POST['branch_id']) || $_POST['branch_id'] == "")
{
$ret_error = _("The selected customer does not have any branches. Please create at least one branch.");
unset($_POST['branch_id']);
$order->set_customer($customer_id, $name, $myrow['curr_code'], $myrow['discount']);
// the sales type determines the price list to be used by default
- $order->set_sales_type($myrow['salestype'], $myrow['sales_type'], $myrow['tax_included']);
+ $order->set_sales_type($myrow['salestype'], $myrow['sales_type'], $myrow['tax_included']);
// if ($order->Branch != 0)
{
$result = get_branch_to_order($customer_id, $branch_id);
- if (db_num_rows($result) == 0)
- {
- return _("The selected customer and branch are not valid, or the customer does not have any branches.");
- }
+ if (db_num_rows($result) == 0)
+ {
+ return _("The selected customer and branch are not valid, or the customer does not have any branches.");
+ }
- $myrow = db_fetch($result);
+ $myrow = db_fetch($result);
$order->set_branch($branch_id, $myrow["tax_group_id"],
- $myrow["tax_group_name"], $myrow["phone"], $myrow["email"]);
+ $myrow["tax_group_name"], $myrow["phone"], $myrow["email"]);
- $address = $myrow["br_post_address"];
+ $address = $myrow["br_post_address"];
- if (strlen($address) <= 1) // if branch has no address
- $address = $deliver; // set sales order address
+ if (strlen($address) <= 1) // if branch has no address
+ $address = $deliver; // set sales order address
$order->set_location($myrow["default_location"], $myrow["location_name"]);
- $order->set_delivery($myrow["default_ship_via"], $myrow["br_name"],
- $address);
+ $order->set_delivery($myrow["default_ship_via"], $myrow["br_name"],
+ $address);
}
return $ret_error;
display_heading($title);
start_table("$table_style colspan=7 width=90%");
$th = array(_("Item Code"), _("Item Description"), _("Quantity"),
- _("Delivered"),
+ _("Delivered"),
_("Unit"), _("Price"), _("Discount %"), _("Total"), "");
if ($order->trans_no==0) {
- unset( $th[3] );
+ unset( $th[3] );
}
if (count($order->line_items)) $th[]= '';
- table_header($th);
+ table_header($th);
$total = 0;
$k = 0; //row colour counter
- foreach ($order->line_items as $line_no=>$stock_item)
+ foreach ($order->line_items as $line_no=>$stock_item)
{
$line_total = $stock_item->qty_dispatched * $stock_item->price * (1 - $stock_item->discount_percent);
-
+
if (!isset($_GET['Edit']))
$id = -1;
else
if (!$editable_items || $id != $line_no)
{
- alt_table_row_color($k);
+ alt_table_row_color($k);
view_stock_status_cell($stock_item->stock_id);
-
- label_cell($stock_item->item_description);
- qty_cell($stock_item->qty_dispatched);
-
- if ($order->trans_no!=0)
- amount_cell($stock_item->qty_done);
-
- label_cell($stock_item->units);
- amount_cell($stock_item->price);
-
- amount_cell($stock_item->discount_percent * 100);
- amount_cell($line_total);
-
- if ($editable_items)
- {
- edit_link_cell(SID . "Edit=$line_no");
- delete_link_cell(SID . "Delete=$line_no");
- }
- end_row();
- }
- else
+
+ label_cell($stock_item->item_description);
+ qty_cell($stock_item->qty_dispatched);
+
+ if ($order->trans_no!=0)
+ amount_cell($stock_item->qty_done);
+
+ label_cell($stock_item->units);
+ amount_cell($stock_item->price);
+
+ percent_cell($stock_item->discount_percent * 100);
+ amount_cell($line_total);
+
+ if ($editable_items)
+ {
+ edit_link_cell(SID . "Edit=$line_no");
+ delete_link_cell(SID . "Delete=$line_no");
+ }
+ end_row();
+ }
+ else
{
sales_order_item_controls($order, $line_no);
}
if (!isset($_GET['Edit']) && $editable_items)
sales_order_item_controls($order);
- $display_total = number_format2($total,user_price_dec());
+ $display_total = price_format($total);
label_row(_("Total Excluding Shipping"), $display_total, "colspan=6 align=right",
"nowrap align=right");
echo "<table>";
$customer_error = "";
- $change_prices = 0;
+ $change_prices = 0;
if (isset($order) && !$editable)
{
// can't change the customer/branch if items already received on this order
echo $order->customer_name . " - " . $order->deliver_to;
- hidden('customer_id', $order->customer_id);
- hidden('branch_id', $order->Branch);
- }
- else
+ hidden('customer_id', $order->customer_id);
+ hidden('branch_id', $order->Branch);
+ hidden('sales_type', $order->sales_type);
+ }
+ else
{
- if (!isset($_POST['customer_id']) && (get_global_customer() != reserved_words::get_all()))
- $_POST['customer_id'] = get_global_customer();
+ if (!isset($_POST['customer_id']) && (get_global_customer() != reserved_words::get_all()))
+ $_POST['customer_id'] = get_global_customer();
- customer_list_row(_("Customer:"), 'customer_id', null, false, true);
+ customer_list_row(_("Customer:"), 'customer_id', null, false, true);
- if (!isset($_POST['delivery_date']))
- {
+ if (!isset($_POST['delivery_date']))
+ {
if ($order->trans_type==10)
- $_POST['delivery_date'] = $_SESSION['Items']->due_date =
+ $_POST['delivery_date'] = $_SESSION['Items']->due_date =
get_invoice_duedate($_POST['customer_id'], $_POST['OrderDate']);
- else
- $_POST['delivery_date'] = $_SESSION['Items']->due_date =
+ else
+ $_POST['delivery_date'] = $_SESSION['Items']->due_date =
add_days($_POST['OrderDate'], 10); // FIX this should be in company prefs
- }
- if ($order->customer_id != $_POST['customer_id'])
- {
+ }
+ if ($order->customer_id != $_POST['customer_id'])
+ {
// customer has changed
// delete all the order items - drastic but necessary because of
// change of currency, sales type, etc
- // $order->clear_items();
+ // $order->clear_items();
// clear the branch selection
unset($_POST['branch_id']);
- }
- if (!isset($_POST['branch_id']))
+ }
+ if (!isset($_POST['branch_id']))
$_POST['branch_id'] = "";
customer_branches_list_row(_("Branch:"), $_POST['customer_id'], 'branch_id', null, false, true, true);
- if (!isset($_POST['branch_id']) || $_POST['branch_id'] == "")
- {
- $customer_error = _("The selected customer does not have any branches. Please create at least one branch.");
- unset($_POST['branch_id']);
- $order->Branch = 0;
- } else
- {
- //set_global_customer($_POST['customer_id']);
- if (($order->customer_id != $_POST['customer_id']) ||
- ($order->Branch != $_POST['branch_id'])) {
-
- $old_order = (PHP_VERSION<5) ? $order : clone( $order );
- $customer_error = get_customer_details_to_order($order, $_POST['customer_id'], $_POST['branch_id']);
- $_POST['Location'] = $order->Location;
- $_POST['deliver_to'] = $order->deliver_to;
- $_POST['delivery_address'] = $order->delivery_address;
- $_POST['phone'] = $order->phone;
- $_POST['sales_type'] = $order->sales_type;
-
- // change prices if necessary
- // what about discount in template case?
- if ( $old_order->customer_currency!=$order->customer_currency
- || $old_order->sales_type!=$order->sales_type
- // || $old_order->default_discount!=$order->default_discount
- ) {
- $change_prices = 1;
- }
-
- }
- } // changed branch
- set_global_customer($_POST['customer_id']);
+ if (!isset($_POST['branch_id']) || $_POST['branch_id'] == "")
+ {
+ $customer_error = _("The selected customer does not have any branches. Please create at least one branch.");
+ unset($_POST['branch_id']);
+ $order->Branch = 0;
+ } else
+ {
+ //set_global_customer($_POST['customer_id']);
+ if (($order->customer_id != $_POST['customer_id']) ||
+ ($order->Branch != $_POST['branch_id'])) {
+
+ $old_order = (PHP_VERSION<5) ? $order : clone( $order );
+ $customer_error = get_customer_details_to_order($order, $_POST['customer_id'], $_POST['branch_id']);
+ $_POST['Location'] = $order->Location;
+ $_POST['deliver_to'] = $order->deliver_to;
+ $_POST['delivery_address'] = $order->delivery_address;
+ $_POST['phone'] = $order->phone;
+ $_POST['sales_type'] = $order->sales_type;
+
+ // change prices if necessary
+ // what about discount in template case?
+ if ( $old_order->customer_currency!=$order->customer_currency
+ || $old_order->sales_type!=$order->sales_type
+ // || $old_order->default_discount!=$order->default_discount
+ ) {
+ $change_prices = 1;
+ }
+
+ }
+ } // changed branch
+ set_global_customer($_POST['customer_id']);
}
if ($_SESSION['Items']->trans_type!=30) {
- ref_cells(_("Reference").':', 'ref', null, "");
+ ref_cells(_("Reference").':', 'ref', null, '');
}
echo "</table>";
{
echo "<table height='5'>";
label_row(_("Customer Currency:"), $order->customer_currency);
- exchange_rate_display($order->customer_currency, get_company_currency(),
- ($editable?$_POST['OrderDate']:$order->document_date), $editable);
+ exchange_rate_display($order->customer_currency, get_company_currency(),
+ ($editable ? $_POST['OrderDate'] : $order->document_date), $editable);
echo "</table>";
echo "</td><td>"; // outer table
}
- if( $order->sales_type != $_POST['sales_type']) {
- $myrow = get_sales_type($_POST['sales_type']);
- $order->set_sales_type($myrow['id'], $myrow['sales_type'],
+ if( $order->sales_type != $_POST['sales_type']) {
+ $myrow = get_sales_type($_POST['sales_type']);
+ $order->set_sales_type($myrow['id'], $myrow['sales_type'],
$myrow['tax_included']);
- $change_prices = 1;
+ $change_prices = 1;
}
- if($change_prices!=0)
- {
- foreach ($order->line_items as $line_no=>$item) {
+ if($change_prices!=0)
+ {
+ foreach ($order->line_items as $line_no=>$item) {
$line = &$order->line_items[$line_no];
$line->price = get_price($line->stock_id, $order->customer_currency,
- $order->sales_type);
+ $order->sales_type);
// $line->discount_percent = $order->default_discount;
- }
+ }
}
echo "<table height='5'>";
if($editable)
- sales_types_list_row(_("Price List"), 'sales_type', $_POST['sales_type'], true);
- else
- label_row(_("Price List:"), $order->sales_type_name);
+ sales_types_list_row(_("Price List"), 'sales_type', $_POST['sales_type'], true);
+ else {
+ label_row(_("Price List:"), $order->sales_type_name);
+ }
label_row(_("Customer Discount:"), ($order->default_discount * 100) . "%");
echo "</table>";
echo "<table height='5'>";
- if ($editable)
+ if ($editable)
{
- if (!isset($_POST['OrderDate']) || $_POST['OrderDate'] == "")
- $_POST['OrderDate'] = $order->document_date;
+ if (!isset($_POST['OrderDate']) || $_POST['OrderDate'] == "")
+ $_POST['OrderDate'] = $order->document_date;
date_row($date_text, 'OrderDate');
}
- else
+ else
{
label_row($date_text, $order->document_date);
hidden('OrderDate', $order->document_date);
}
- if ($display_tax_group)
+ if ($display_tax_group)
{
-/* if ($editable)
+/* if ($editable)
{
- if (!isset($_POST['tax_group_id']))
- $_POST['tax_group_id'] = $_SESSION['Items']->tax_group_id;
- tax_groups_list_row(_("Tax Group:"), 'tax_group_id', $_POST['tax_group_id'], true);
- }
- else
+ if (!isset($_POST['tax_group_id']))
+ $_POST['tax_group_id'] = $_SESSION['Items']->tax_group_id;
+ tax_groups_list_row(_("Tax Group:"), 'tax_group_id', $_POST['tax_group_id'], true);
+ }
+ else
*/ {
label_row(_("Tax Group:"), $order->tax_group_name);
hidden('tax_group_id', $_SESSION['Items']->tax_group_id);
echo "</table>";
echo "</td></tr>";
-
+
end_table(1); // outer table
return $customer_error;
if (!isset($_POST['stock_id']))
$_POST['stock_id'] = $order->line_items[$_GET['Edit']]->stock_id;
if (!isset($_POST['qty']) || ($_POST['qty'] == ""))
- $_POST['qty'] = $order->line_items[$_GET['Edit']]->qty_dispatched;
+ $_POST['qty'] = qty_format($order->line_items[$_GET['Edit']]->qty_dispatched);
if (!isset($_POST['price']) || ($_POST['price'] == ""))
- $_POST['price'] = $order->line_items[$_GET['Edit']]->price;
+ $_POST['price'] = price_format($order->line_items[$_GET['Edit']]->price);
if (!isset($_POST['Disc']) || ($_POST['Disc'] == ""))
- $_POST['Disc'] = ($order->line_items[$_GET['Edit']]->discount_percent)*100;
+ $_POST['Disc'] = percent_format($order->line_items[$_GET['Edit']]->discount_percent*100);
$_POST['units'] = $order->line_items[$_GET['Edit']]->units;
hidden('stock_id', $_POST['stock_id']);
label_cell($_POST['stock_id']);
label_cell($order->line_items[$line_no]->item_description);
- }
- else
+ }
+ else
{
- global $no_item_list;
+ global $no_item_list;
if ($no_item_list)
{
echo "<td colspan=2>\n";
}
else
{
- text_cells(null, "StockID2", "", 12, 10, "", "", "onkeyup='recalcAccounts();' onKeyDown='if (event.keyCode==13) event.keyCode=9;' onblur='return setAccount(0, true);'");
+ text_cells(null, "StockID2", "", 12, 10, "", "", "onkeyup='recalcAccounts();' onKeyDown='if (event.keyCode==13) event.keyCode=9;' onblur='return setAccount(0, true);'");
stock_items_list_cells(null, 'stock_id', null, false, false, "onchange='return setAccount(1, true)'");
}
$item_info = get_item_edit_info($_POST['stock_id']);
$_POST['units'] = $item_info["units"];
- $_POST['qty'] = 1;
- $_POST['price'] = get_price ($_POST['stock_id'],
- $order->customer_currency, $order->sales_type);
+ $_POST['qty'] = qty_format(1);
+ $_POST['price'] = price_format(get_price ($_POST['stock_id'],
+ $order->customer_currency, $order->sales_type));
// default to the customer's discount %
- $_POST['Disc'] = $order->default_discount * 100;
+ $_POST['Disc'] = percent_format($order->default_discount * 100);
}
- text_cells(null, 'qty', $_POST['qty'], 12, 15);
+ amount_cells(null, 'qty', qty_format($_POST['qty']));
if ($order->trans_no!=0) {
- amount_cell($line_no==-1 ? 0 :$order->line_items[$line_no]->qty_done);
+ amount_cell($line_no==-1 ? 0 :$order->line_items[$line_no]->qty_done);
}
label_cell($_POST['units']);
amount_cells(null, 'price');
- text_cells(null, 'Disc', $_POST['Disc'], 7, 5);
+ small_amount_cells(null, 'Disc', percent_format($_POST['Disc']));
$line_total = $_POST['qty'] * $_POST['price'] * (1 - $_POST['Disc'] / 100);
amount_cell($line_total);
- if (isset($_GET['Edit']))
+ if (isset($_GET['Edit']))
{
- submit_cells('UpdateItem', _("Update"));
- submit_cells('CancelItemChanges', _("Cancel"));
+ submit_cells('UpdateItem', _("Update"));
+ submit_cells('CancelItemChanges', _("Cancel"));
hidden('LineNo', $line_no);
- }
- else
+ }
+ else
{
submit_cells('AddItem', _("Add Item"), "colspan=2");
}
function display_delivery_details(&$order)
{
global $table_style2;
- if ($order->trans_type==10)
+ if ($order->trans_type==10)
{
$title = _("Delivery Details");
$delname = _("Due Date").':';
- }
- elseif ($order->trans_type==13)
+ }
+ elseif ($order->trans_type==13)
{
$title = _("Invoice Delivery Details");
$delname = _("Invoice before").':';
- }
- else
+ }
+ else
{
$title = _("Order Delivery Details");
$delname = _("Required Delivery Date").':';
}
display_heading($title);
- echo "<br>";
- start_table("$table_style2 width=90%");
- echo "<tr valign=top><td>"; // outer table
+ echo "<br>";
+ start_table("$table_style2 width=90%");
+ echo "<tr valign=top><td>"; // outer table
- echo "<table>";
+ echo "<table>";
// echo $order->Location, $_POST['Location'];
- locations_list_row(_("Deliver from Location:"), 'Location', $_POST['Location']);
+ locations_list_row(_("Deliver from Location:"), 'Location', $_POST['Location']);
- date_row($delname, 'delivery_date', $order->due_date, 0, 0, 0);
+ date_row($delname, 'delivery_date', $order->due_date, 0, 0, 0);
- text_row(_("Deliver To:"), 'deliver_to', $order->deliver_to, 40, 40);
+ text_row(_("Deliver To:"), 'deliver_to', $order->deliver_to, 40, 40);
- textarea_row(_("Address:"), 'delivery_address', $order->delivery_address, 35, 5);
- text_row(_("Contact Phone Number:"), 'phone', $order->phone, 25, 25);
+ textarea_row(_("Address:"), 'delivery_address', $order->delivery_address, 35, 5);
+ text_row(_("Contact Phone Number:"), 'phone', $order->phone, 25, 25);
- echo "</table>";
+ echo "</table>";
- echo "</td><td>"; // outer table
+ echo "</td><td>"; // outer table
- echo "<table>";
+ echo "<table>";
- text_row(_("Customer Reference:"), 'cust_ref', $order->cust_ref, 25, 25);
- textarea_row(_("Comments:"), "Comments", $order->Comments, 31, 5);
+ text_row(_("Customer Reference:"), 'cust_ref', $order->cust_ref, 25, 25);
+ textarea_row(_("Comments:"), "Comments", $order->Comments, 31, 5);
- text_row(_("Shipping Charge:"), 'freight_cost', $order->freight_cost, 10, 10);
+ small_amount_row(_("Shipping Charge:"), 'freight_cost',
+ price_format($_POST['freight_cost']));
- shippers_list_row(_("Shipping Company:"), 'ship_via', $order->ship_via);
+ shippers_list_row(_("Shipping Company:"), 'ship_via', $order->ship_via);
- echo "</table>";
+ echo "</table>";
- echo "</td></tr>";
- end_table(1); // outer table
+ echo "</td></tr>";
+ end_table(1); // outer table
}
?>
\ No newline at end of file
return false;
}
- if (!is_numeric( $_POST['credit_limit']))
+ if (!check_num('credit_limit', 0))
{
- display_error(_("The credit limit must be numeric."));
+ display_error(_("The credit limit must be numeric and not less than zero."));
return false;
}
- if (!is_numeric( $_POST['pymt_discount']))
+ if (!check_num('pymt_discount', 0, 100))
{
- display_error(_("The payment discount must be numeric."));
+ display_error(_("The payment discount must be numeric and is expected to be less than 100% and greater than or equal to 0."));
return false;
}
- if (!is_numeric( $_POST['discount']))
+ if (!check_num('discount', 0, 100))
{
- display_error(_("The discount percentage must be numeric."));
+ display_error(_("The discount percentage must be numeric and is expected to be less than 100% and greater than or equal to 0."));
return false;
}
-
- if ($_POST['credit_limit'] < 0)
- {
- display_error(_("The credit limit must be a positive number."));
- return false;
- }
-
- if (($_POST['pymt_discount'] >= 100) || ($_POST['pymt_discount'] < 0))
- {
- display_error(_("The payment discount is expected to be less than 100% and greater than or equal to 0."));
- return false;
- }
-
- if (($_POST['discount'] >= 100) || ($_POST['discount'] < 0))
- {
- display_error(_("The discount percent is expected to be less than 100 and greater than or equal to 0."));
- return false;
- }
-
+
return true;
}
if (!isset($_POST['New']))
{
- // Sherifoz 22.06.03 convert percent to fraction
$sql = "UPDATE ".TB_PREF."debtors_master SET name='" . $_POST['CustName'] . "',
address='" . $_POST['address'] . "',
tax_id='" . $_POST['tax_id'] . "',
dimension2_id=" . $_POST['dimension2_id'] . ",
credit_status='" . $_POST['credit_status'] . "',
payment_terms='" . $_POST['payment_terms'] . "',
- discount=" . ($_POST['discount']) / 100 . ",
- pymt_discount=" . ($_POST['pymt_discount']) / 100 . ",
- credit_limit=" . $_POST['credit_limit'] . ",
+ discount=" . input_num('discount') / 100 . ",
+ pymt_discount=" . input_num('pymt_discount') / 100 . ",
+ credit_limit=" . input_num('credit_limit') . ",
sales_type = '" . $_POST['sales_type'] . "'
WHERE debtor_no = '" . $_POST['customer_id'] . "'";
curr_code, credit_status, payment_terms, discount, pymt_discount,credit_limit,
sales_type) VALUES ('" . $_POST['CustName'] ."', '" . $_POST['address'] . "', '" . $_POST['tax_id'] . "',
'" . $_POST['email'] . "', " . $_POST['dimension_id'] . ", " . $_POST['dimension2_id'] . ", '" . $_POST['curr_code'] . "',
- " . $_POST['credit_status'] . ", '" . $_POST['payment_terms'] . "', " . ($_POST['discount'])/100 . ",
- " . ($_POST['pymt_discount'])/100 . ", " . $_POST['credit_limit'] . ", '" . $_POST['sales_type'] . "')";
+ " . $_POST['credit_status'] . ", '" . $_POST['payment_terms'] . "', " . input_num('discount')/100 . ",
+ " . input_num('pymt_discount')/100 . ", " . $_POST['credit_limit'] . ", '" . $_POST['sales_type'] . "')";
db_query($sql,"The customer could not be added");
$_POST['curr_code'] = get_company_currency();
$_POST['credit_status'] = -1;
$_POST['payment_terms'] = '';
- $_POST['discount'] = $_POST['pymt_discount'] = 0;
- $_POST['credit_limit'] = sys_prefs::default_credit_limit();
+ $_POST['discount'] = $_POST['pymt_discount'] = percent_format(0);
+ $_POST['credit_limit'] = price_format(sys_prefs::default_credit_limit());
}
else
{
$_POST['curr_code'] = $myrow["curr_code"];
$_POST['credit_status'] = $myrow["credit_status"];
$_POST['payment_terms'] = $myrow["payment_terms"];
- $_POST['discount'] = $myrow["discount"] * 100; // Sherifoz 21.6.03 convert to displayable percentage
- $_POST['pymt_discount'] = $myrow["pymt_discount"] * 100; // Sherifoz 21.6.03 convert to displayable percentage
- $_POST['credit_limit'] = $myrow["credit_limit"];
+ $_POST['discount'] = percent_format($myrow["discount"] * 100);
+ $_POST['pymt_discount'] = percent_format($myrow["pymt_discount"] * 100);
+ $_POST['credit_limit'] = price_format($myrow["credit_limit"]);
}
text_row(_("Customer Name:"), 'CustName', $_POST['CustName'], 40, 40);
if ($dim < 2)
hidden('dimension2_id', 0);
-text_row(_("Discount Percent:"), 'discount', $_POST['discount'], 5, 4);
-text_row(_("Prompt Payment Discount Percent:"), 'pymt_discount', $_POST['pymt_discount'], 5, 4);
-text_row(_("Credit Limit:"), 'credit_limit', $_POST['credit_limit'], 16, 14);
+percent_row(_("Discount Percent:"), 'discount', $_POST['discount']);
+percent_row(_("Prompt Payment Discount Percent:"), 'pymt_discount', $_POST['pymt_discount']);
+amount_row(_("Credit Limit:"), 'credit_limit', $_POST['credit_limit']);
payment_terms_list_row(_("Payment Terms:"), 'payment_terms', $_POST['payment_terms']);
credit_status_list_row(_("Credit Status:"), 'credit_status', $_POST['credit_status']);
salesman_phone='" . $_POST['salesman_phone'] . "',
salesman_fax='" . $_POST['salesman_fax'] . "',
salesman_email='" . $_POST['salesman_email'] . "',
- provision=".$_POST['provision'].",
- break_pt=".$_POST['break_pt'].",
- provision2=".$_POST['provision2']."
+ provision=".input_num('provision').",
+ break_pt=".input_num('break_pt').",
+ provision2=".input_num('provision2')."
WHERE salesman_code = '$selected_id'";
}
else
/*Selected group is null cos no item selected on first time round so must be adding a record must be submitting new entries in the new Sales-person form */
$sql = "INSERT INTO ".TB_PREF."salesman (salesman_name, salesman_phone, salesman_fax, salesman_email,
provision, break_pt, provision2)
- VALUES ('" . $_POST['salesman_name'] . "', '" . $_POST['salesman_phone'] . "', '" . $_POST['salesman_fax'] . "', '" . $_POST['salesman_email'] . "', ".
- $_POST['provision'].", ".$_POST['break_pt'].", ".$_POST['provision2'].")";
+ VALUES ('" . $_POST['salesman_name'] . "', '" .$_POST['salesman_phone'] . "', '" . $_POST['salesman_fax'] . "', '" . $_POST['salesman_email'] . "', ".
+ input_num('provision').", ".input_num('break_pt').", ".input_num('provision2').")";
}
//run the sql from either of the above possibilites
label_cell($myrow["salesman_phone"]);
label_cell($myrow["salesman_fax"]);
label_cell($myrow["salesman_email"]);
- percent_cell($myrow["provision"]);
+ label_cell(percent_format($myrow["provision"])." %", "nowrap align=right");
amount_cell($myrow["break_pt"]);
- percent_cell($myrow["provision2"]);
+ label_cell(percent_format($myrow["provision2"])." %", "nowrap align=right");
edit_link_cell(SID . "selected_id=" . $myrow["salesman_code"]);
delete_link_cell(SID . "selected_id=" . $myrow["salesman_code"]. "&delete=1");
end_row();
$_POST['salesman_phone'] = $myrow["salesman_phone"];
$_POST['salesman_fax'] = $myrow["salesman_fax"];
$_POST['salesman_email'] = $myrow["salesman_email"];
- $_POST['provision'] = $myrow["provision"];
- $_POST['break_pt'] = $myrow["break_pt"];
- $_POST['provision2'] = $myrow["provision2"];
+ $_POST['provision'] = percent_format($myrow["provision"]);
+ $_POST['break_pt'] = price_format($myrow["break_pt"]);
+ $_POST['provision2'] = percent_format($myrow["provision2"]);
hidden('selected_id', $selected_id);
}
$cart->document_date = $_POST['OrderDate'];
$cart->due_date = $_POST['delivery_date'];
$cart->cust_ref = $_POST['cust_ref'];
- $cart->freight_cost = $_POST['freight_cost'];
+ $cart->freight_cost = input_num('freight_cost');
$cart->deliver_to = $_POST['deliver_to'];
$cart->delivery_address = $_POST['delivery_address'];
$cart->phone = $_POST['phone'];
$_POST['OrderDate'] = $cart->document_date;
$_POST['delivery_date'] = $cart->due_date;
$_POST['cust_ref'] = $cart->cust_ref;
- $_POST['freight_cost'] = $cart->freight_cost;
+ $_POST['freight_cost'] = price_format($cart->freight_cost);
$_POST['deliver_to'] = $cart->deliver_to;
$_POST['delivery_address'] = $cart->delivery_address;
}
if ($_POST['freight_cost'] == "")
- $_POST['freight_cost'] = 0;
+ $_POST['freight_cost'] = price_format(0);
- if (!is_numeric($_POST['freight_cost'])) {
+ if (!check_num('freight_cost',0)) {
display_error(_("The shipping cost entered is expected to be numeric."));
return false;
}
function check_item_data()
{
- if (!is_numeric($_POST['qty']) || $_POST['qty'] < 0 || $_POST['Disc'] > 100 || $_POST['Disc'] < 0) {
+
+ if (!check_num('qty', 0) || !check_num('Disc', 0, 100)) {
display_error( _("The item could not be updated because you are attempting to set the quantity ordered to less than 0, or the discount percent to more than 100."));
return false;
- } elseif (!is_numeric($_POST['price']) || $_POST['price'] < 0) {
-
- display_error( _("Price for item must be entered and can not be less then 0"));
+ } elseif (!check_num('price', 0)) {
+ display_error( _("Price for item must be entered and can not be less than 0"));
return false;
} elseif (isset($_POST['LineNo']) && isset($_SESSION['Items']->line_items[$_POST['LineNo']])
- && $_SESSION['Items']->line_items[$_POST['LineNo']]->qty_done > $_POST['qty']) {
+ && !check_num('qty', $_SESSION['Items']->line_items[$_POST['LineNo']]->qty_done)) {
display_error(_("You attempting to make the quantity ordered a quantity less than has already been delivered. The quantity delivered cannot be modified retrospectively."));
return false;
function handle_update_item()
{
if ($_POST['UpdateItem'] != '' && check_item_data()) {
- $_SESSION['Items']->update_cart_item($_POST['LineNo'], $_POST['qty'],
- $_POST['price'], ($_POST['Disc'] / 100));
+ $_SESSION['Items']->update_cart_item($_POST['LineNo'],
+ input_num('qty'), input_num('price'),
+ input_num('Disc') / 100 );
}
+ copy_from_cart();
}
//--------------------------------------------------------------------------------
if (!check_item_data()) {
return;
}
- add_to_order($_SESSION['Items'], $_POST['stock_id'], $_POST['qty'],
- $_POST['price'], $_POST['Disc'] / 100);
+ add_to_order($_SESSION['Items'], $_POST['stock_id'], input_num('qty'),
+ input_num('price'), input_num('Disc') / 100);
$_POST['StockID2'] = $_POST['stock_id'] = "";
}
//--------------------------------------------------------------------------------
+
+if (isset($_GET['Delete']) || isset($_GET['Edit']))
+ copy_from_cart(); // GET method need form restore
+
if (isset($_POST['CancelOrder']))
handle_cancel_order();
}
else
{
- $display_discount = number_format2($myrow2["discount_percent"]*100,user_percent_dec()) . "%";
+ $display_discount = percent_format($myrow2["discount_percent"]*100) . "%";
}
label_cell($myrow2["stock_id"]);
else
display_note(_("There are no line items on this credit note."), 1, 2);
-$display_sub_tot = number_format2($sub_total,user_price_dec());
-$display_freight = number_format2($myrow["ov_freight"],user_price_dec());
+$display_sub_tot = price_format($sub_total);
+$display_freight = price_format($myrow["ov_freight"]);
$credit_total = $myrow["ov_freight"]+$myrow["ov_gst"]+$myrow["ov_amount"]+$myrow["ov_freight_tax"];
-$display_total = number_format2($credit_total,user_price_dec());
+$display_total = price_format($credit_total);
/*Print out the invoice text entered */
if ($sub_total != 0)
}
else
{
- $display_discount = number_format2($myrow2["discount_percent"]*100,user_percent_dec()) . "%";
+ $display_discount = percent_format($myrow2["discount_percent"]*100) . "%";
}
label_cell($myrow2["stock_id"]);
else
display_note(_("There are no line items on this dispatch."), 1, 2);
-$display_sub_tot = number_format2($sub_total,user_price_dec());
-$display_freight = number_format2($myrow["ov_freight"],user_price_dec());
+$display_sub_tot = price_format($sub_total);
+$display_freight = price_format($myrow["ov_freight"]);
/*Print out the delivery note text entered */
label_row(_("Sub-total"), $display_sub_tot, "colspan=6 align=right",
$tax_items = get_customer_trans_tax_details(13, $trans_id);
display_customer_trans_tax_details($tax_items, 6);
-$display_total = number_format2($myrow["ov_freight"]+$myrow["ov_amount"]+$myrow["ov_freight_tax"]+$myrow["ov_gst"],user_price_dec());
+$display_total = price_format($myrow["ov_freight"]+$myrow["ov_amount"]+$myrow["ov_freight_tax"]+$myrow["ov_gst"]);
label_row(_("TOTAL VALUE"), $display_total, "colspan=6 align=right",
"nowrap align=right");
}
else
{
- $display_discount = number_format2($myrow2["discount_percent"]*100,user_percent_dec()) . "%";
+ $display_discount = percent_format2($myrow2["discount_percent"]*100) . "%";
}
label_cell($myrow2["stock_id"]);
else
display_note(_("There are no line items on this invoice."), 1, 2);
-$display_sub_tot = number_format2($sub_total,user_price_dec());
-$display_freight = number_format2($myrow["ov_freight"],user_price_dec());
+$display_sub_tot = price_format($sub_total);
+$display_freight = price_format($myrow["ov_freight"]);
/*Print out the invoice text entered */
label_row(_("Sub-total"), $display_sub_tot, "colspan=6 align=right",
$tax_items = get_customer_trans_tax_details(10, $trans_id);
display_customer_trans_tax_details($tax_items, 6);
-$display_total = number_format2($myrow["ov_freight"]+$myrow["ov_gst"]+$myrow["ov_amount"]+$myrow["ov_freight_tax"],user_price_dec());
+$display_total = price_format($myrow["ov_freight"]+$myrow["ov_gst"]+$myrow["ov_amount"]+$myrow["ov_freight_tax"]);
label_row(_("TOTAL INVOICE"), $display_total, "colspan=6 align=right",
"nowrap align=right");
end_row();
start_row();
label_cells(_("Payment Currency"), $receipt['curr_code'], "class='tableheader2'");
-label_cells(_("Amount"), number_format2(-$receipt['ov_amount'], user_price_dec()), "class='tableheader2'");
-label_cells(_("Discount"), number_format2(-$receipt['ov_discount'], user_price_dec()), "class='tableheader2'");
+label_cells(_("Amount"), price_format($receipt['ov_amount']), "class='tableheader2'");
+label_cells(_("Discount"), price_format($receipt['ov_discount']), "class='tableheader2'");
end_row();
start_row();
label_cells(_("Payment Type"), $receipt['BankTransType'], "class='tableheader2'");
}
-label_row(null, number_format2($delivery_total,user_price_dec()), "", "colspan=4 align=right");
+label_row(null, price_format($delivery_total), "", "colspan=4 align=right");
end_table();
echo "</td><td valign='top'>";
}
-label_row(null, number_format2($invoices_total,user_price_dec()), "", "colspan=4 align=right");
+label_row(null, price_format($invoices_total), "", "colspan=4 align=right");
end_table();
}
-label_row(null, "<font color=red>" . number_format2(-$credits_total,user_price_dec()) . "</font>",
+label_row(null, "<font color=red>" . price_format(-$credits_total) . "</font>",
"", "colspan=4 align=right");
$items_total = $_SESSION['Items']->get_items_total();
-$display_total = number_format2($items_total + $_SESSION['Items']->freight_cost,user_price_dec());
+$display_total = price_format($items_total + $_SESSION['Items']->freight_cost);
-label_row(_("Shipping"), number_format2($_SESSION['Items']->freight_cost,user_price_dec()),
+label_row(_("Shipping"), price_format($_SESSION['Items']->freight_cost),
"align=right colspan=6", "nowrap align=right");
label_row(_("Total Order Value"), $display_total, "align=right colspan=6",
"nowrap align=right");
alt_table_row_color($k);
label_cell($myrow["name"]);
- percent_cell($myrow["rate"]);
+ label_cell(percent_format($myrow["rate"])." %", "nowrap align=right");
check_cells("", 'ExemptTax' . $myrow["id"], null);
end_row();
}
{
if (isset($_POST['tax_type_id' . $i]) &&
$_POST['tax_type_id' . $i] != reserved_words::get_all_numeric() &&
- (!is_numeric($_POST['rate' . $i]) || $_POST['rate' . $i] < 0))
+ !check_num('rate' . $i, 0))
{
display_error( _("An entered tax rate is invalid or less than zero."));
$input_error = 1;
$_POST['tax_type_id' . $i] != reserved_words::get_any_numeric())
{
$taxes[] = $_POST['tax_type_id' . $i];
- $rates[] = $_POST['rate' . $i];
+ $rates[] = input_num('rate' . $i);
}
}
while ($tax_item = db_fetch($items))
{
$_POST['tax_type_id' . $i] = $tax_item["tax_type_id"];
- $_POST['rate' . $i] = $tax_item["rate"];
+ $_POST['rate' . $i] = percent_format($tax_item["rate"]);
$i ++;
}
}
{
$default_rate = get_tax_type_default_rate($_POST['tax_type_id' . $i]);
- label_cell(number_format2($default_rate, user_percent_dec()), "nowrap align=right");
+ label_cell(percent_format($default_rate), "nowrap align=right");
if (!isset($_POST['rate' . $i]) || $_POST['rate' . $i] == "")
- $_POST['rate' . $i] = $default_rate;
- text_cells(null, 'rate' . $i, $_POST['rate' . $i], 10, 10);
+ $_POST['rate' . $i] = percent_format($default_rate);
+ small_amount_cells(null, 'rate' . $i, $_POST['rate' . $i]);
}
end_row();
}
display_error(_("The tax type name cannot be empty."));
return false;
}
- elseif (!is_numeric($_POST['rate']))
+ elseif (!check_num('rate', 0))
{
- display_error( _("The default tax rate must be numeric."));
- return false;
- }
- elseif ($_POST['rate'] < 0)
- {
- display_error( _("The default tax rate cannot be less than zero."));
+ display_error( _("The default tax rate must be numeric and not less than zero."));
return false;
}
{
add_tax_type($_POST['name'], $_POST['sales_gl_code'],
- $_POST['purchasing_gl_code'], $_POST['rate']);
+ $_POST['purchasing_gl_code'], imput_num('rate'));
meta_forward($_SERVER['PHP_SELF']);
}
{
update_tax_type($selected_id, $_POST['name'],
- $_POST['sales_gl_code'], $_POST['purchasing_gl_code'], $_POST['rate']);
+ $_POST['sales_gl_code'], $_POST['purchasing_gl_code'], input_num('rate'));
meta_forward($_SERVER['PHP_SELF']);
}
alt_table_row_color($k);
label_cell($myrow["name"]);
- label_cell(number_format2($myrow["rate"],user_percent_dec()), "align=right");
+ label_cell(percent_format($myrow["rate"]), "align=right");
label_cell($myrow["sales_gl_code"] . " " . $myrow["SalesAccountName"]);
label_cell($myrow["purchasing_gl_code"] . " " . $myrow["PurchasingAccountName"]);
$myrow = get_tax_type($selected_id);
$_POST['name'] = $myrow["name"];
- $_POST['rate'] = $myrow["rate"];
+ $_POST['rate'] = percent_format($myrow["rate"]);
$_POST['sales_gl_code'] = $myrow["sales_gl_code"];
$_POST['purchasing_gl_code'] = $myrow["purchasing_gl_code"];
hidden('selected_id', $selected_id);
}
text_row_ex(_("Description:"), 'name', 50);
-text_row_ex(_("Default Rate:"), 'rate', 10, 10, "", "%");
+small_amount_row(_("Default Rate:"), 'rate', '', "", "%");
gl_all_accounts_list_row(_("Sales GL Account:"), 'sales_gl_code', null);
gl_all_accounts_list_row(_("Purchasing GL Account:"), 'purchasing_gl_code', null);