! -> Note
$ -> Affected files
+03-Jun-2009 Joe Hunt
+! Changed to present reference number in Print Invoices/Credit Notes if global $print_invoice_no = 0
+$ /reporting/includes/reports_classes.inc
+# Deleting of Locations was too easy. Implemented much more checks
+$ /inventory/manage/locations.php
+! Report Stock Check Sheet and 'Inventory Item Status' was wrong when Locations were selected.
+$ /reporting/rep302.php
+ /reporting/rep303.php
+ /includes/db/manufacturing_db.inc
+# When producing advanced manufacture there should be errors when insuffient qoh in items (if 'Allow Negative Stock' is not marked).
+$ /manufacturing/work_order_issue.php
+ /manufacturing/work_order_add_finished.php
+
27-May-2009 Joe Hunt
# After heavy testing a new set of nested subtypes in COA, Monthly Breakdown, Balance Sheet and P&L Statement.
$ /gl/includes/db/gl_db_accounts.inc
$result = db_query($sql,"No transactions were returned");
$row = db_fetch($result);
+ if ($row === false)
+ return 0;
return $row['QtyDemand'];
}
$date = date2sql(Today());
$sql = "SELECT stock_id, SUM(qty) FROM ".TB_PREF."stock_moves WHERE tran_date <= '$date'";
- if ($location != null) $sql .= " AND loc_code = '$location'";
+ if ($location != '') $sql .= " AND loc_code = '$location'";
$sql .= " GROUP BY stock_id";
$result = db_query($sql, "QOH calulcation failed");
while ($row = db_fetch($result)) {
$bom = $bom_list[$stock_id];
if ($bom == NULL) {
$sql = "SELECT parent, component, quantity FROM ".TB_PREF."bom WHERE parent = '$stock_id'";
- if ($location != '') $sql .= " AND loc_code = '$location'";
+ if ($location != "") $sql .= " AND loc_code = '$location'";
$result = db_query($sql, "Could not search bom");
$bom = array();
// Even if we get no results, remember that fact
return false;
}
+ $sql= "SELECT COUNT(*) FROM ".TB_PREF."bom WHERE loc_code='$selected_id'";
+ $result = db_query($sql, "could not query bom");
+ $myrow = db_fetch_row($result);
+ if ($myrow[0] > 0)
+ {
+ display_error(_("Cannot delete this location because it is used by some related records in other tables."));
+ return false;
+ }
+ $sql= "SELECT COUNT(*) FROM ".TB_PREF."grn_batch WHERE loc_code='$selected_id'";
+ $result = db_query($sql, "could not query grn batch");
+ $myrow = db_fetch_row($result);
+ if ($myrow[0] > 0)
+ {
+ display_error(_("Cannot delete this location because it is used by some related records in other tables."));
+ return false;
+ }
+ $sql= "SELECT COUNT(*) FROM ".TB_PREF."purch_orders WHERE into_stock_location='$selected_id'";
+ $result = db_query($sql, "could not query purch orders");
+ $myrow = db_fetch_row($result);
+ if ($myrow[0] > 0)
+ {
+ display_error(_("Cannot delete this location because it is used by some related records in other tables."));
+ return false;
+ }
+ $sql= "SELECT COUNT(*) FROM ".TB_PREF."sales_orders WHERE from_stk_loc='$selected_id'";
+ $result = db_query($sql, "could not query sales orders");
+ $myrow = db_fetch_row($result);
+ if ($myrow[0] > 0)
+ {
+ display_error(_("Cannot delete this location because it is used by some related records in other tables."));
+ return false;
+ }
+ $sql= "SELECT COUNT(*) FROM ".TB_PREF."sales_pos WHERE pos_location='$selected_id'";
+ $result = db_query($sql, "could not query sales pos");
+ $myrow = db_fetch_row($result);
+ if ($myrow[0] > 0)
+ {
+ display_error(_("Cannot delete this location because it is used by some related records in other tables."));
+ return false;
+ }
return true;
}
}
}
+ // if production we need to check the qoh of the wo requirements
+ if (($_POST['ProductionType'] == 1) && !sys_prefs::allow_negative_stock())
+ {
+ $err = false;
+ $result = get_wo_requirements($_POST['selected_id']);
+ while ($row = db_fetch($result))
+ {
+ if ($row['mb_flag'] == 'D') // service, non stock
+ continue;
+ $qoh = get_qoh_on_date($row["stock_id"], $row["loc_code"], $date_);
+ if ($qoh - $row['units_req'] * $_POST['quantity'] < 0)
+ {
+ display_error( _("The production cannot be processed because a required item would cause a negative inventory balance :") .
+ " " . $row['stock_id'] . " - " . $row['description']);
+ $err = true;
+ }
+ }
+ if ($err)
+ {
+ set_focus('quantity');
+ return false;
+ }
+ }
return true;
}
//--------------------------------------------------------------------------------------------------
-if (isset($_POST['Process']) || (isset($_POST['ProcessAndClose']) && can_process() == true))
+if (isset($_POST['ProcessAndClose']) && can_process() == true)
{
- $close_wo = 0;
- if (isset($_POST['ProcessAndClose']) && ($_POST['ProcessAndClose']!=""))
- $close_wo = 1;
-
+ $close_wo = 1;
// if unassembling, negate quantity
if ($_POST['ProductionType'] == 0)
$_POST['quantity'] = -$_POST['quantity'];
end_table(1);
-submit_center_first('Process', _("Process"), '', true);
-submit_center_last('ProcessAndClose', _("Process And Close Order"), '', true);
+submit_center('ProcessAndClose', _("Process And Close Order"), true, '', true);
end_form();
}
$failed_item = $_SESSION['issue_items']->check_qoh($_POST['Location'], $_POST['date_'], !$_POST['IssueType']);
- if ($failed_item >= 0)
+ if ($failed_item != -1)
{
display_error( _("The issue cannot be processed because an entered item would cause a negative inventory balance :") .
" " . $failed_item->stock_id . " - " . $failed_item->item_description);
function getDisplay()
{
- global $path_to_root, $use_date_picker, $pdf_debug;
+ global $path_to_root, $use_date_picker, $pdf_debug, $print_invoice_no;
$st = '';
$dummy = "";
case 'INVOICE':
$IV = _("IV");
$CN = _("CN");
- $sql = "SELECT concat(".TB_PREF."debtor_trans.trans_no, '-',
- ".TB_PREF."debtor_trans.type) AS TNO, concat(".TB_PREF."debtor_trans.trans_no, if (type=10, ' $IV ', ' $CN '), ".TB_PREF."debtors_master.name) as IName
- FROM ".TB_PREF."debtors_master, ".TB_PREF."debtor_trans WHERE (type=10 OR type=11) AND ".TB_PREF."debtors_master.debtor_no=".TB_PREF."debtor_trans.debtor_no ORDER BY ".TB_PREF."debtor_trans.trans_no DESC";
+ if ($print_invoice_no == 1)
+ $sql = "SELECT concat(".TB_PREF."debtor_trans.trans_no, '-',
+ ".TB_PREF."debtor_trans.type) AS TNO, concat(".TB_PREF."debtor_trans.trans_no, if (type=10, ' $IV ', ' $CN '), ".TB_PREF."debtors_master.name) as IName
+ FROM ".TB_PREF."debtors_master, ".TB_PREF."debtor_trans WHERE (type=10 OR type=11) AND ".TB_PREF."debtors_master.debtor_no=".TB_PREF."debtor_trans.debtor_no ORDER BY ".TB_PREF."debtor_trans.trans_no DESC";
+ else
+ $sql = "SELECT concat(".TB_PREF."debtor_trans.trans_no, '-',
+ ".TB_PREF."debtor_trans.type) AS TNO, concat(".TB_PREF."debtor_trans.reference, if (type=10, ' $IV ', ' $CN '), ".TB_PREF."debtors_master.name) as IName
+ FROM ".TB_PREF."debtors_master, ".TB_PREF."debtor_trans WHERE (type=10 OR type=11) AND ".TB_PREF."debtors_master.debtor_no=".TB_PREF."debtor_trans.debtor_no ORDER BY ".TB_PREF."debtor_trans.trans_no DESC";
$st .= dup_simple_codeandname_list($sql, "PARAM_$index", $dummy);
break;
case 'DELIVERY':
if ($category != 0)
$sql .= " AND ".TB_PREF."stock_master.category_id = '$category'";
if ($location != 'all')
- $sql .= " AND ".TB_PREF."stock_moves.loc_code = '$location'";
+ $sql .= " AND IF(".TB_PREF."stock_moves.stock_id IS NULL, '1=1',".TB_PREF."stock_moves.loc_code = '$location')";
$sql .= " GROUP BY ".TB_PREF."stock_master.category_id,
".TB_PREF."stock_category.description,
".TB_PREF."stock_master.stock_id,
if ($location == 'all')
$loc_code = "";
else
- $loc_code = $trans['loc_code'];
+ $loc_code = $location;
$custqty = get_demand_qty($trans['stock_id'], $loc_code);
$custqty += get_demand_asm_qty($trans['stock_id'], $loc_code);
$suppqty = get_on_porder_qty($trans['stock_id'], $loc_code);
".TB_PREF."stock_master.stock_id,
".TB_PREF."stock_master.description,
IF(".TB_PREF."stock_moves.stock_id IS NULL, '', ".TB_PREF."stock_moves.loc_code) AS loc_code,
- SUM(IF(".TB_PREF."stock_moves.stock_id IS NULL,0,".TB_PREF."stock_moves.qty)) AS QtyOnHand
+ SUM(IF(".TB_PREF."stock_moves.stock_id IS NULL,0,".TB_PREF."stock_moves.qty)) AS qty_on_hand
FROM (".TB_PREF."stock_master,
".TB_PREF."stock_category)
LEFT JOIN ".TB_PREF."stock_moves ON
if ($category != 0)
$sql .= " AND ".TB_PREF."stock_master.category_id = '$category'";
if ($location != 'all')
- $sql .= " AND ".TB_PREF."stock_moves.loc_code = '$location'";
+ $sql .= " AND IF(".TB_PREF."stock_moves.stock_id IS NULL, '1=1',".TB_PREF."stock_moves.loc_code = '$location')";
$sql .= " GROUP BY ".TB_PREF."stock_master.category_id,
".TB_PREF."stock_category.description,
".TB_PREF."stock_master.stock_id,
$catt = '';
while ($trans=db_fetch($res))
{
+ if ($location == 'all')
+ $loc_code = "";
+ else
+ $loc_code = $location;
$demandqty = get_demand_qty($trans['stock_id'], $loc_code);
$demandqty += get_demand_asm_qty($trans['stock_id'], $loc_code);
$onorder = get_on_porder_qty($trans['stock_id'], $loc_code);
$catt = $trans['cat_description'];
$rep->NewLine();
}
- if ($location == 'all')
- $loc_code = "";
- else
- $loc_code = $trans['loc_code'];
$rep->NewLine();
$dec = get_qty_dec($trans['stock_id']);
$rep->TextCol(0, 1, $trans['stock_id']);
$rep->End();
}
-?>
\ No newline at end of file
+?>