//--------------------------------------------------------------------------------------
-function get_sql_for_search_dimensions($dim)
-{
+function get_sql_for_search_dimensions($dim, $from, $to, $order='', $type = -1, $open=false, $overdue = false)
+{
$sql = "SELECT dim.id,
dim.reference,
dim.name,
dim.closed
FROM ".TB_PREF."dimensions as dim WHERE id > 0";
- if (isset($_POST['OrderNumber']) && $_POST['OrderNumber'] != "")
+ if ($order)
{
- $sql .= " AND reference LIKE ".db_escape("%". $_POST['OrderNumber'] . "%");
+ $sql .= " AND reference LIKE ".db_escape("%". $order . "%");
} else {
if ($dim == 1)
$sql .= " AND type_=1";
- if (isset($_POST['OpenOnly']))
- {
+ if ($open)
$sql .= " AND closed=0";
- }
- if (isset($_POST['type_']) && ($_POST['type_'] > 0))
- {
- $sql .= " AND type_=".db_escape($_POST['type_']);
- }
+ if ($type > 0)
+ $sql .= " AND type_=".db_escape($type);
- if (isset($_POST['OverdueOnly']))
+ if ($overdue)
{
$today = date2sql(Today());
$sql .= " AND due_date < '$today'";
}
- $sql .= " AND date_ >= '" . date2sql($_POST['FromDate']) . "'
- AND date_ <= '" . date2sql($_POST['ToDate']) . "'";
+ $sql .= " AND date_ >= '" . date2sql($from) . "'
+ AND date_ <= '" . date2sql($to) . "'";
}
return $sql;
-}
+}
?>
\ No newline at end of file
"/dimensions/dimension_entry.php?trans_no=" . $row["id"], ICON_EDIT);
}
-$sql = get_sql_for_search_dimensions($dim);
+$sql = get_sql_for_search_dimensions($dim, $_POST['FromDate'], $_POST['ToDate'],
+ $_POST['OrderNumber'], $_POST['type_'], $_POST['OpenOnly'], $_POST['OverdueOnly']);
$cols = array(
_("#") => array('fun'=>'view_link'),
//-----------------------------------------------------------------------------
-function get_sql_for_exchange_rates()
+function get_sql_for_exchange_rates($curr)
{
$sql = "SELECT date_, rate_buy, id FROM "
.TB_PREF."exchange_rates "
- ."WHERE curr_code=".db_escape($_POST['curr_abrev'])."
+ ."WHERE curr_code=".db_escape($curr)."
ORDER BY date_ DESC";
return $sql;
}
set_global_curr_code($_POST['curr_abrev']);
-$sql = get_sql_for_exchange_rates();
+$sql = get_sql_for_exchange_rates($_POST['curr_abrev']);
$cols = array(
_("Date to Use From") => 'date',
if (isset($_GET['path_to_root']) || isset($_POST['path_to_root']))
die("Restricted access");
@include_once($path_to_root . "/lang/installed_languages.inc");
-include_once($path_to_root . "/includes/lang/gettext.php");
+include_once($path_to_root . "/includes/lang/gettext.inc");
class language
{
//--------------------------------------------------------------------------------------
function update_work_order($woid, $loc_code, $units_reqd, $stock_id,
- $date_, $required_by, $memo_)
+ $date_, $required_by, $memo_, $old_stock_id, $old_qty)
{
begin_transaction();
$args = func_get_args();
'date_', 'required_by', 'memo_'), $args);
hook_db_prewrite($args, ST_WORKORDER);
- add_material_cost($_POST['old_stk_id'], -$_POST['old_qty'], $date_);
+ add_material_cost($old_stock_id, -$old_qty, $date_);
add_material_cost($stock_id, $units_reqd, $date_);
$date = date2sql($date_);
commit_transaction();
}
-function delete_work_order($woid)
+function delete_work_order($woid, $stock_id, $qty, $date)
{
begin_transaction();
hook_db_prevoid(ST_WORKORDER, $woid);
- add_material_cost($_POST['stock_id'], -$_POST['quantity'], $_POST['date_']);
+ add_material_cost($stock_id, -$qty, $date);
// delete the work order requirements
delete_wo_requirements($woid);
db_query($sql,"The work order could not be deleted");
delete_comments(ST_WORKORDER, $woid);
- add_audit_trail(ST_WORKORDER, $woid, $_POST['date_'], _("Canceled."));
+ add_audit_trail(ST_WORKORDER, $woid, $date, _("Canceled."));
commit_transaction();
}
commit_transaction();
}
-function get_sql_for_work_orders($outstanding_only, $all_items)
+function get_sql_for_work_orders($outstanding_only, $stock_id, $location = ALL_TEXT, $order = '', $overdue = false)
{
$sql = "SELECT
workorder.id,
$sql .= " AND workorder.closed=0";
}
- if (isset($_POST['StockLocation']) && $_POST['StockLocation'] != $all_items)
+ if ($location != ALL_TEXT)
{
- $sql .= " AND workorder.loc_code=".db_escape($_POST['StockLocation']);
+ $sql .= " AND workorder.loc_code=".db_escape($location);
}
- if (isset($_POST['OrderNumber']) && $_POST['OrderNumber'] != "")
+ if ($order != '')
{
- $sql .= " AND workorder.wo_ref LIKE ".db_escape('%'.$_POST['OrderNumber'].'%');
+ $sql .= " AND workorder.wo_ref LIKE ".db_escape('%'.$order.'%');
}
- if (isset($_POST['SelectedStockItem']) && $_POST['SelectedStockItem'] != $all_items)
+ if ($stock_id != '')
{
- $sql .= " AND workorder.stock_id=".db_escape($_POST['SelectedStockItem']);
+ $sql .= " AND workorder.stock_id=".db_escape($stock_id);
}
- if (check_value('OverdueOnly'))
+ if ($overdue)
{
$Today = date2sql(Today());
return $sql;
}
-function get_sql_for_where_used()
+function get_sql_for_where_used($stock_id)
{
$sql = "SELECT
bom.parent,
WHERE bom.parent = parent.stock_id
AND bom.workcentre_added = workcentre.id
AND bom.loc_code = location.loc_code
- AND bom.component=".db_escape($_POST['stock_id']);
- return $sql;
+ AND bom.component=".db_escape($stock_id);
+ return $sql;
}
//--------------------------------------------------------------------------------------
function get_gl_wo_cost($woid, $cost_type)
"/manufacturing/manage/bom_edit.php?stock_id=" . $row["parent"]);
}
-$sql = get_sql_for_where_used();
+$sql = get_sql_for_where_used($_POST['stock_id']);
$cols = array(
_("Parent Item") => array('fun'=>'select_link'),
return number_format2($amount, $row['decimals']);
}
-$sql = get_sql_for_work_orders($outstanding_only, $all_items);
+$sql = get_sql_for_work_orders($outstanding_only, $_POST['SelectedStockItem'], $_POST['StockLocation'],
+ $_POST['OrderNumber'], check_value('OverdueOnly'));
$cols = array(
_("#") => array('fun'=>'view_link', 'ord'=>''),
{
update_work_order($selected_id, $_POST['StockLocation'], input_num('quantity'),
- $_POST['stock_id'], $_POST['date_'], $_POST['RequDate'], $_POST['memo_']);
+ $_POST['stock_id'], $_POST['date_'], $_POST['RequDate'], $_POST['memo_'],
+ $_POST['old_stk_id'], $_POST['old_qty']);
new_doc_date($_POST['date_']);
meta_forward($_SERVER['PHP_SELF'], "UpdatedID=$selected_id");
}
{ //ie not cancelled the delete as a result of above tests
// delete the actual work order
- delete_work_order($selected_id);
+ delete_work_order($selected_id, $_POST['stock_id'], $_POST['quantity'], $_POST['date_']);
meta_forward($_SERVER['PHP_SELF'], "DeletedID=$selected_id");
}
}
return db_query($sql,"The stock details for " . $stock_id . " could not be retrieved");
}
-function get_sql_for_po_search_completed($supplier_id=ALL_TEXT)
+function get_sql_for_po_search_completed($from, $to, $supplier_id=ALL_TEXT, $location=ALL_TEXT,
+ $order_number = '', $stock_id = '')
{
- global $order_number, $selected_stock_item;;
$sql = "SELECT
porder.order_no,
AND porder.supplier_id = supplier.supplier_id
AND location.loc_code = porder.into_stock_location ";
- if (isset($_GET['supplier_id']))
- $sql .= "AND supplier.supplier_id=".@$_GET['supplier_id']." ";
+ if ($supplier_id != ALL_TEXT)
+ $sql .= "AND supplier.supplier_id=".$supplier_id." ";
if (isset($order_number) && $order_number != "")
{
$sql .= "AND porder.reference LIKE ".db_escape('%'. $order_number . '%');
else
{
- $data_after = date2sql($_POST['OrdersAfterDate']);
- $date_before = date2sql($_POST['OrdersToDate']);
+ $data_after = date2sql($from);
+ $date_before = date2sql($to);
$sql .= " AND porder.ord_date >= '$data_after'";
$sql .= " AND porder.ord_date <= '$date_before'";
- if (isset($_POST['StockLocation']) && $_POST['StockLocation'] != ALL_TEXT)
+ if ($location != ALL_TEXT)
{
- $sql .= " AND porder.into_stock_location = ".db_escape($_POST['StockLocation']);
+ $sql .= " AND porder.into_stock_location = ".db_escape($location);
}
if (isset($selected_stock_item))
{
- $sql .= " AND line.item_code=".db_escape($selected_stock_item);
+ $sql .= " AND line.item_code=".db_escape($stock_id);
}
if ($supplier_id != ALL_TEXT)
$sql .= " AND supplier.supplier_id=".db_escape($supplier_id);
-
- } //end not order number selected
+
+ }
$sql .= " GROUP BY porder.order_no";
return $sql;
-}
+}
-function get_sql_for_po_search($supplier_id=ALL_TEXT)
+function get_sql_for_po_search($from, $to, $supplier_id=ALL_TEXT, $location=ALL_TEXT)
{
global $all_items, $order_number, $selected_stock_item;;
}
else
{
- $data_after = date2sql($_POST['OrdersAfterDate']);
- $data_before = date2sql($_POST['OrdersToDate']);
+ $data_after = date2sql($from);
+ $data_before = date2sql($to);
$sql .= " AND porder.ord_date >= '$data_after'";
$sql .= " AND porder.ord_date <= '$data_before'";
- if (isset($_POST['StockLocation']) && $_POST['StockLocation'] != $all_items)
+ if ($location != ALL_TEXT)
{
- $sql .= " AND porder.into_stock_location = ".db_escape($_POST['StockLocation']);
+ $sql .= " AND porder.into_stock_location = ".db_escape($location);
}
if (isset($selected_stock_item))
}
-function get_sql_for_supplier_allocation_inquiry()
+function get_sql_for_supplier_allocation_inquiry($from, $to, $filter, $supplier_id, $all=false)
{
- $date_after = date2sql($_POST['TransAfterDate']);
- $date_to = date2sql($_POST['TransToDate']);
+ $date_after = date2sql($from);
+ $date_to = date2sql($to);
$sql = "SELECT
trans.type,
AND trans.tran_date >= '$date_after'
AND trans.tran_date <= '$date_to'";
- if ($_POST['supplier_id'] != ALL_TEXT)
- $sql .= " AND trans.supplier_id = ".db_escape($_POST['supplier_id']);
- if (isset($_POST['filterType']) && $_POST['filterType'] != ALL_TEXT)
+ if ($supplier_id != ALL_TEXT)
+ $sql .= " AND trans.supplier_id = ".db_escape($supplier_id);
+
+ if ($filter != ALL_TEXT)
{
- if (($_POST['filterType'] == '1') || ($_POST['filterType'] == '2'))
+ if (($filter == '1') || ($filter == '2'))
{
$sql .= " AND trans.type = ".ST_SUPPINVOICE." ";
}
- elseif ($_POST['filterType'] == '3')
+ elseif ($filter == '3')
{
$sql .= " AND trans.type = ".ST_SUPPAYMENT." ";
}
- elseif (($_POST['filterType'] == '4') || ($_POST['filterType'] == '5'))
+ elseif (($filter == '4') || ($filter == '5'))
{
$sql .= " AND trans.type = ".ST_SUPPCREDIT." ";
}
- if (($_POST['filterType'] == '2') || ($_POST['filterType'] == '5'))
+ if (($filter == '2') || ($filter == '5'))
{
$today = date2sql(Today());
$sql .= " AND trans.due_date < '$today' ";
}
}
- if (!check_value('showSettled'))
+ if (!$all)
{
$sql .= " AND (round(abs(ov_amount + ov_gst + ov_discount) - alloc,6) != 0) ";
}
supp_account_no, bank_account, credit_limit, dimension_id, dimension2_id, curr_code,
payment_terms, payable_account, purchase_account, payment_discount_account, notes,
tax_group_id, tax_included, tax_algorithm)
- VALUES (".db_escape($_POST['supp_name']). ", "
+ VALUES (".db_escape($supp_name). ", "
.db_escape($supp_ref). ", "
.db_escape($address) . ", "
.db_escape($supp_address) . ", "
$order_number = $_POST['order_number'];
}
-if (isset($_POST['SelectStockFromList']) && ($_POST['SelectStockFromList'] != "") &&
- ($_POST['SelectStockFromList'] != $all_items))
-{
- $selected_stock_item = $_POST['SelectStockFromList'];
-}
-else
-{
- unset($selected_stock_item);
-}
-
//figure out the sql required from the inputs available
-$sql = get_sql_for_po_search($_POST['supplier_id']);
+$sql = get_sql_for_po_search($_POST['OrdersAfterDate'], $_POST['OrdersToDate'], $_POST['supplier_id'],
+ $_POST['StockLocation']);
//$result = db_query($sql,"No orders were returned");
if (isset($_GET['order_number']))
{
- $order_number = $_GET['order_number'];
+ $_POST['order_number'] = $_GET['order_number'];
}
//-----------------------------------------------------------------------------------
end_row();
end_table(1);
//---------------------------------------------------------------------------------------------
-if (isset($_POST['order_number']))
-{
- $order_number = $_POST['order_number'];
-}
-
-if (isset($_POST['SelectStockFromList']) && ($_POST['SelectStockFromList'] != "") &&
- ($_POST['SelectStockFromList'] != ALL_TEXT))
-{
- $selected_stock_item = $_POST['SelectStockFromList'];
-}
-else
-{
- unset($selected_stock_item);
-}
-//---------------------------------------------------------------------------------------------
function trans_view($trans)
{
return get_trans_view_str(ST_PURCHORDER, $trans["order_no"]);
//---------------------------------------------------------------------------------------------
-$sql = get_sql_for_po_search_completed(!@$_GET['popup'] ? $_POST['supplier_id'] : ALL_TEXT);
+$sql = get_sql_for_po_search_completed(get_post('OrdersAfterDate'), get_post('OrdersToDate'),
+ @$_GET['popup'] ? ALL_TEXT : get_post('supplier_id'),
+ get_post('StockLocation'), get_post('order_number'), get_post('SelectStockFromList'));
$cols = array(
_("#") => array('fun'=>'trans_view', 'ord'=>''),
}
//------------------------------------------------------------------------------------------------
-$sql = get_sql_for_supplier_allocation_inquiry();
+$sql = get_sql_for_supplier_allocation_inquiry($_POST['TransAfterDate'],$_POST['TransToDate'],
+ $_POST['filterType'], $_POST['supplier_id'], check_value('showSettled'));
$cols = array(
_("Type") => array('fun'=>'systype_name'),
display_footer_exit();
} else
- check_edit_conflicts();
+ check_edit_conflicts(get_post('cart_id'));
//--------------------------------------------------------------------------------
display_footer_exit();
} else
- check_edit_conflicts();
+ check_edit_conflicts(get_post('cart_id'));
//-----------------------------------------------------------------------------
exit;
} else {
- check_edit_conflicts();
+ check_edit_conflicts(get_post('cart_id'));
if (!check_quantities()) {
display_error(_("Selected quantity cannot be less than quantity invoiced nor more than quantity not dispatched on sales order."));
//-----------------------------------------------------------------------------
-check_edit_conflicts();
+check_edit_conflicts(get_post('cart_id'));
if (isset($_GET['AddedID'])) {
return db_fetch($result);
}
-function get_sql_for_customer_branches()
+function get_sql_for_customer_branches($customer_id)
{
$sql = "SELECT "
."b.branch_code, "
WHERE b.tax_group_id=t.id
AND b.area=a.area_code
AND b.salesman=s.salesman_code
- AND b.debtor_no = ".db_escape($_POST['customer_id']);
+ AND b.debtor_no = ".db_escape($customer_id);
if (!get_post('show_inactive')) $sql .= " AND !b.inactive";
$sql .= " GROUP BY b.branch_code ORDER BY branch_ref";
}
//----------------------------------------------------------------------------------------
-
-function get_sql_for_customer_inquiry()
+function get_sql_for_customer_inquiry($from, $to, $cust_id = ALL_TEXT, $filter = ALL_TEXT)
{
- $date_after = date2sql($_POST['TransAfterDate']);
- $date_to = date2sql($_POST['TransToDate']);
+ $date_after = date2sql($from);
+ $date_to = date2sql($to);
$sql = "SELECT
trans.type,
debtor.curr_code,
(trans.ov_amount + trans.ov_gst + trans.ov_freight
+ trans.ov_freight_tax + trans.ov_discount) AS TotalAmount, ";
- if ($_POST['filterType'] != ALL_TEXT)
+ if ($filter != ALL_TEXT)
$sql .= "@bal := @bal+(trans.ov_amount + trans.ov_gst + trans.ov_freight + trans.ov_freight_tax + trans.ov_discount), ";
// else
AND trans.tran_date <= '$date_to'
AND trans.branch_code = branch.branch_code";
- if ($_POST['customer_id'] != ALL_TEXT)
- $sql .= " AND trans.debtor_no = ".db_escape($_POST['customer_id']);
+ if ($cust_id != ALL_TEXT)
+ $sql .= " AND trans.debtor_no = ".db_escape($cust_id);
- if ($_POST['filterType'] != ALL_TEXT)
+ if ($filter != ALL_TEXT)
{
- if ($_POST['filterType'] == '1')
+ if ($filter == '1')
{
$sql .= " AND (trans.type = ".ST_SALESINVOICE.") ";
}
- elseif ($_POST['filterType'] == '2')
+ elseif ($filter == '2')
{
$sql .= " AND (trans.type = ".ST_SALESINVOICE.") ";
}
- elseif ($_POST['filterType'] == '3')
+ elseif ($filter == '3')
{
$sql .= " AND (trans.type = " . ST_CUSTPAYMENT
." OR trans.type = ".ST_BANKDEPOSIT." OR trans.type = ".ST_BANKPAYMENT.") ";
}
- elseif ($_POST['filterType'] == '4')
+ elseif ($filter == '4')
{
$sql .= " AND trans.type = ".ST_CUSTCREDIT." ";
}
- elseif ($_POST['filterType'] == '5')
+ elseif ($filter == '5')
{
$sql .= " AND trans.type = ".ST_CUSTDELIVERY." ";
}
- if ($_POST['filterType'] == '2')
+ if ($filter == '2')
{
$today = date2sql(Today());
$sql .= " AND trans.due_date < '$today'
return $sql;
}
-function get_sql_for_sales_deliveries_view($selected_customer, $selected_stock_item=null, $customer_id=ALL_TEXT)
+function get_sql_for_sales_deliveries_view($from, $to, $customer_id, $stock_item, $location, $delivery, $outstanding=false)
{
$sql = "SELECT trans.trans_no,
debtor.name,
AND trans.branch_code = branch.branch_code
AND trans.debtor_no = branch.debtor_no ";
- if ($_POST['OutstandingOnly'] == true) {
+ if ($outstanding == true) {
$sql .= " AND line.qty_done < line.quantity ";
}
//figure out the sql required from the inputs available
- if (isset($_POST['DeliveryNumber']) && $_POST['DeliveryNumber'] != "")
+ if ($delivery)
{
- $delivery = "%".$_POST['DeliveryNumber'];
- $sql .= " AND trans.trans_no LIKE ".db_escape($delivery);
+ $sql .= " AND trans.trans_no LIKE %".db_escape($delivery);
$sql .= " GROUP BY trans.trans_no";
}
else
{
- $sql .= " AND trans.tran_date >= '".date2sql($_POST['DeliveryAfterDate'])."'";
- $sql .= " AND trans.tran_date <= '".date2sql($_POST['DeliveryToDate'])."'";
+ $sql .= " AND trans.tran_date >= '".date2sql($from)."'";
+ $sql .= " AND trans.tran_date <= '".date2sql($to)."'";
- if ($selected_customer != -1)
- $sql .= " AND trans.debtor_no=".db_escape($selected_customer)." ";
+ if ($stock_item)
+ $sql .= " AND line.stock_id=".db_escape($stock_item)." ";
- if (isset($selected_stock_item))
- $sql .= " AND line.stock_id=".db_escape($selected_stock_item)." ";
+ if ($location != ALL_TEXT)
+ $sql .= " AND sorder.from_stk_loc = ".db_escape($location)." ";
- if (isset($_POST['StockLocation']) && $_POST['StockLocation'] != ALL_TEXT)
- $sql .= " AND sorder.from_stk_loc = ".db_escape($_POST['StockLocation'])." ";
-
if ($customer_id != ALL_TEXT)
- $sql .= " AND trans.debtor_no = ".db_escape($customer_id);
+ $sql .= " AND trans.debtor_no = ".db_escape($customer_id);
$sql .= " GROUP BY trans.trans_no ";
Check if the cart was not destroyed during opening the edition page in
another browser tab.
*/
-function check_edit_conflicts($cartname='Items')
+function check_edit_conflicts($cart_id, $cartname='Items')
{
global $Ajax, $no_check_edit_conflicts;
- if ((!isset($no_check_edit_conflicts) || $no_check_edit_conflicts==0) && get_post('cart_id') && $_POST['cart_id'] != $_SESSION[$cartname]->cart_id) {
+ if ((!isset($no_check_edit_conflicts) || $no_check_edit_conflicts==0) && get_post('cart_id') && $cart_id != $_SESSION[$cartname]->cart_id) {
display_error(_('This edit session has been abandoned by opening sales document in another browser tab. You cannot edit more than one sales document at once.'));
$Ajax->activate('_page_body');
display_footer_exit();
&& floatcmp($row["TotalAmount"], $row["Allocated"]) != 0;
}
//------------------------------------------------------------------------------------------------
-$sql = get_sql_for_customer_inquiry();
+$sql = get_sql_for_customer_inquiry(get_post('TransAfterDate'), get_post('TransToDate'),
+ get_post('customer_id'), get_post('filterType'));
//------------------------------------------------------------------------------------------------
db_query("set @bal:=0");
if (isset($_GET['selected_customer']))
{
- $selected_customer = $_GET['selected_customer'];
+ $_POST['customer_id'] = $_GET['selected_customer'];
}
elseif (isset($_POST['selected_customer']))
{
- $selected_customer = $_POST['selected_customer'];
+ $_POST['customer_id'] = $_POST['selected_customer'];
}
-else
- $selected_customer = -1;
if (isset($_POST['BatchInvoice']))
{
end_table(1);
//---------------------------------------------------------------------------------------------
-if (isset($_POST['SelectStockFromList']) && ($_POST['SelectStockFromList'] != "") &&
- ($_POST['SelectStockFromList'] != ALL_TEXT))
-{
- $selected_stock_item = $_POST['SelectStockFromList'];
-}
-else
-{
- $selected_stock_item = null;
-}
-
-//---------------------------------------------------------------------------------------------
function trans_view($trans, $trans_no)
{
return get_customer_trans_view_str(ST_CUSTDELIVERY, $trans['trans_no']);
$row["Outstanding"]!=0;
}
//------------------------------------------------------------------------------------------------
-$sql = get_sql_for_sales_deliveries_view($selected_customer, $selected_stock_item, $_POST['customer_id']);
+$sql = get_sql_for_sales_deliveries_view(get_post('DeliveryAfterDate'), get_post('DeliveryToDate'), get_post('customer_id'),
+ get_post('SelectStockFromList'), get_post('StockLocation'), get_post('DeliveryNumber'), get_post('OutstandingOnly'));
$cols = array(
_("Delivery #") => array('fun'=>'trans_view'),
echo customer_list('customer_id', null, false, true);
echo "</center><br>";
-$num_branches = db_customer_has_branches($_POST['customer_id']);
+$num_branches = db_customer_has_branches(get_post('customer_id'));
-$sql = get_sql_for_customer_branches();
+$sql = get_sql_for_customer_branches(get_post('customer_id'));
//------------------------------------------------------------------------------------------------
if ($num_branches)
display_footer_exit();
} else
- check_edit_conflicts();
+ check_edit_conflicts(get_post('cart_id'));
//-----------------------------------------------------------------------------
function copy_to_cart()