start_form();
switch(@$_POST['Page']) {
default:
-// include ('../install.html');
-// submit_center('continue', _('Continue >>'));
-// break;
case '1':
div_start('welcome');
subpage_title(_('System Diagnostics'));
function can_process()
{
- global $Refs, $SysPrefs;
+ global $SysPrefs;
$adj = &$_SESSION['adj_items'];
function handle_new_item()
{
add_to_order($_SESSION['adj_items'], $_POST['stock_id'],
- input_num('qty'), input_num('std_cost'));
+ input_num('qty'), input_num('std_cost'));
line_start_focus();
}
if (!$page_nested)
{
echo "<center>" . _("Item:"). " ";
- //echo stock_costable_items_list('stock_id', $_POST['stock_id'], false, true);
echo stock_items_list('stock_id', $_POST['stock_id'], false, true);
echo "</center><hr>";
if (is_service($mb_flag))
{
- //display_db_error("Cannot do cost update for Service item : $stock_id", "");
-
- //Chaitanya
$sql = "UPDATE ".TB_PREF."stock_master SET material_cost=".db_escape($material_cost)."
WHERE stock_id=".db_escape($stock_id);
if ($value_of_change != 0)
{
+ global $Refs;
$stock_gl_code = get_stock_gl_code($stock_id);
$cart = new items_cart(ST_COSTUPDATE);
$sql .= " ORDER BY name";
return db_query($sql, "could not get stock categories");
}
-// 2008-06-15. Added Joe Hunt to get a measure of unit by given stock_id
+// 2008-06-15. Added to get a measure of unit by given stock_id
function get_unit_dec($stock_id)
{
$sql = "SELECT decimals FROM ".TB_PREF."item_units, ".TB_PREF."stock_master
{
$before_date = date2sql($BeforeDate);
$after_date = date2sql($AfterDate);
- $sql = "SELECT move.*, IF(ISNULL(supplier.supplier_id), debtor.name, supplier.supp_name) name";
+ $sql = "SELECT move.*, IF(ISNULL(supplier.supplier_id), debtor.name, supplier.supp_name) name";
if(!$StockLocation) {
$sql .= ", move.loc_code";
}
- $sql.= " FROM ".TB_PREF."stock_moves move
+ $sql.= " FROM ".TB_PREF."stock_moves move
LEFT JOIN ".TB_PREF."supp_trans credit ON credit.trans_no=move.trans_no AND credit.type=move.type
LEFT JOIN ".TB_PREF."grn_batch grn ON grn.id=move.trans_no AND 25=move.type
LEFT JOIN ".TB_PREF."suppliers supplier ON IFNULL(grn.supplier_id, credit.supplier_id)=supplier.supplier_id
LEFT JOIN ".TB_PREF."debtors_master debtor ON cust_trans.debtor_no=debtor.debtor_no
WHERE";
- if ($StockLocation) {
- $sql.= " move.loc_code=".db_escape($StockLocation)." AND";
+ if ($StockLocation) {
+ $sql.= " move.loc_code=".db_escape($StockLocation)." AND";
}
$sql.= " move.tran_date >= '". $after_date . "'
- AND move.tran_date <= '" . $before_date . "'
- AND move.stock_id = ".db_escape($stock_id) . " ORDER BY move.tran_date, move.trans_id";
+ AND move.tran_date <= '" . $before_date . "'
+ AND move.stock_id = ".db_escape($stock_id) . " ORDER BY move.tran_date, move.trans_id";
- return db_query($sql, "could not query stock moves");
+ return db_query($sql, "could not query stock moves");
}
function calculate_reorder_level($location, $line, &$st_ids, &$st_names, &$st_num, &$st_reorder)
require_once($path_to_root . "/reporting/includes/class.mail.inc");
$company = get_company_prefs();
$mail = new email($company['coy_name'], $company['email']);
- $from = $company['coy_name'] . " <" . $company['email'] . ">";
$to = $loc['location_name'] . " <" . $loc['email'] . ">";
$subject = _("Stocks below Re-Order Level at " . $loc['location_name']);
$msg = "\n";
qty_cells(null, 'qty', $_POST['qty'], null, null, $dec);
label_cell($_POST['units'], '', 'units');
- //amount_cells(null, 'std_cost', $_POST['std_cost']);
amount_cells(null, 'std_cost', null, null, null, $dec2);
label_cell(" ");
$th = array(_("Item Code"), _("Item Description"), _("Quantity"), _("Unit"), '');
if ( count($order->line_items)) $th[] = '';
table_header($th);
- $subtotal = 0;
$k = 0; //row colour counter
$low_stock = $order->check_qoh($_POST['FromStockLocation'], $_POST['AdjDate'], true);
$after_qty = $before_qty;
-/*
-if (!isset($before_qty_row[0]))
-{
- $after_qty = $before_qty = 0;
-}
-*/
start_row("class='inquirybg'");
$header_span = $display_location ? 6 : 5;
label_cell("<b>"._("Quantity on hand before") . " " . $_POST['AfterDate']."</b>", "align=center colspan=$header_span");
$_POST['stock_id'] = get_global_stock_item();
echo "<center>" . _("Item:"). " ";
-//Chaitanya : Manufcatured item visible
+//Manufcatured item visible
echo stock_items_list('stock_id', $_POST['stock_id'], false, true);
-//echo stock_purchasable_items_list('stock_id', $_POST['stock_id'], false, true);
echo "<hr></center>";
$imagetype = $type;
else
$imagetype = false;
- //$imagetype = exif_imagetype($_FILES['pic']['tmp_name']);
+
if ($imagetype != IMAGETYPE_GIF && $imagetype != IMAGETYPE_JPEG && $imagetype != IMAGETYPE_PNG)
{ //File type Check
display_warning( _('Only graphics files can be uploaded'));
elseif ( $_FILES['pic']['type'] == "text/plain" )
{ //File type Check
display_warning( _('Only graphics files can be uploaded'));
- $upload_file ='No';
+ $upload_file ='No';
}
elseif (file_exists($filename))
{
if (isset($_POST['NewStockID']) && file_exists(company_path().'/images/'
.item_img_name($_POST['NewStockID']).".jpg"))
{
- // 31/08/08 - rand() call is necessary here to avoid caching problems. Thanks to Peter D.
+ // 31/08/08 - rand() call is necessary here to avoid caching problems.
$stock_img_link .= "<img id='item_img' alt = '[".$_POST['NewStockID'].".jpg".
"]' src='".company_path().'/images/'.item_img_name($_POST['NewStockID']).
".jpg?nocache=".rand()."'"." height='".$SysPrefs->pic_height."' border='0'>";
check_db_has_stock_items(_("There are no items defined in the system."));
simple_page_mode(true);
-/*
-if (isset($_GET['item_code']))
-{
- $_POST['item_code'] = $_GET['item_code'];
- $selected_kit = $_GET['item_code'];
-}
-*/
+
//--------------------------------------------------------------------------------------------------
function display_kit_items($selected_kit)
{
} //END WHILE LIST LOOP
end_table();
-div_end();
+ div_end();
}
//--------------------------------------------------------------------------------------------------
{
display_error(_("The quantity entered must be numeric and greater than zero."));
set_focus('quantity');
- return;
+ return 0;
}
elseif (get_post('description') == '')
{
display_error( _("Item code description cannot be empty."));
set_focus('description');
- return;
+ return 0;
}
elseif ($component_id == -1) // adding new component to alias/kit with optional kit creation
{
if (get_post('kit_code') == '') {
display_error( _("Kit/alias code cannot be empty."));
set_focus('kit_code');
- return;
+ return 0;
}
$kit = get_item_kit(get_post('kit_code'));
if (db_num_rows($kit)) {
$input_error = 1;
display_error( _("This item code is already assigned to stock item or sale kit."));
set_focus('kit_code');
- return;
+ return 0;
}
}
}
if (check_item_in_kit($component_id, $selected_kit, get_post('component'), true)) {
display_error(_("The selected component contains directly or on any lower level the kit under edition. Recursive kits are not allowed."));
set_focus('component');
- return;
+ return 0;
}
/*Now check to see that the component is not already in the kit */
if (check_item_in_kit($component_id, $selected_kit, get_post('component'))) {
display_error(_("The selected component is already in this kit. You can modify it's quantity but it cannot appear more than once in the same kit."));
set_focus('component');
- return;
+ return 0;
}
if ($component_id == -1) { // new component in alias/kit
if ($selected_kit == '') {
sales_local_items_list_row(_("Component:"),'component', null, false, true);
-// if (get_post('description') == '')
-// $_POST['description'] = get_kit_name($_POST['component']);
if (get_post('item_code') == '') { // new kit/alias
if ($Mode!='ADD_ITEM' && $Mode!='UPDATE_ITEM') {
$_POST['description'] = $props['description'];
if (!$page_nested)
{
echo "<center>" . _("Item:"). " ";
- //Chaitanya : All items can be purchased
+ // All items can be purchased
echo stock_items_list('stock_id', $_POST['stock_id'], false, true);
- //echo stock_purchasable_items_list('stock_id', $_POST['stock_id'], false, true);
echo "<hr></center>";
}
else
e.setAttribute('_last', e.selectedIndex);
e.onblur = function() {
var box = document.getElementsByName(this.getAttribute('rel'))[0];
-// if(string_contains(this.className, 'combo'))
-// _update_box(this);
if ((this.selectedIndex != this.getAttribute('_last'))
||((string_contains(this.className, 'combo') || string_contains(this.className, 'combo3')) && _update_box(this))
)
var ulist=ul.getElementsByTagName("li");
for (var x=0; x<ulist.length; x++){ //loop through each LI e
var tab=ulist[x].getElementsByTagName("button")[0];
-// if(tab.onclick==undefined) {
-// ? var modifiedurl=ulistlink.getAttribute("href").replace(/^http:\/\/[^\/]+\//i, "http://"+window.location.hostname+"/")
var url = tab.form.action
tab.onclick=function(){
if (!_hotkeys.alt && !tab.disabled)
};
}
}
-/* 'tr.editrow': function(e) {
- e.onkeydown = function(ev) {
- ev = ev||window.event;
- key = ev.keyCode||ev.which;
- if(key == 13) {
- // Find & click additem/update button
-
- } else if(key == 27) {
- return false;
- }
- }
-
- },
-*//* '#msgbox': function(e) {
- // this is to avoid changing div height after ajax update in IE7
- e.style.display = e.innerHTML.length ? 'block' : 'none';
- }
-*//* TODO
+/* TODO
'a.date_picker': function(e) {
// this un-hides data picker for js enabled browsers
e.href = date_picker(this.getAttribute('rel'));
if ($to_work_order)
$item->quantity = -$item->quantity;
- //Chaitanya: Stamp the standard_cost
+ // Stamp the standard_cost
$standard_cost = get_standard_cost($item->stock_id);
// insert a -ve stock move for each item
add_stock_move(ST_MANUISSUE, $item->stock_id, $number,
$issue = get_stock_gl_code($item->stock_id);
$stockitem = get_item($item->stock_id);
- //Chaitanya : Compatibility for Service Items
+ // Compatibility for Service Items
if (!is_service($issue["mb_flag"]))
$ivaccount = $issue["inventory_account"];
else
$issue_total += $issue_cost;
}
if ($issue_total != 0)
- //Chaitanya : Apply cost to QOH as adjustment only
+ // Apply cost to QOH as adjustment only
add_issue_cost($details['stock_id'], $details['units_reqd'], $date_, $issue_total, true);
$issue = get_stock_gl_code($details['stock_id']);
$stockitem = get_item($details['stock_id']);
.db_escape($type_no);
db_query($sql,"A work order issue item could not be voided");
- // void any related gl trans
- //Chaitanya : Nothing happens due to next statement as all gl postings are done against WO
- //void_gl_trans(ST_MANUISSUE, $type_no, true);
-
- //Chaitanya : Reverse the gl posting
+ // Reverse the gl posting
$issue = get_work_order_issue($type_no);
$manf_stock_id = $issue["stock_id"];
$date_ = sql2date($issue["issue_date"]);
$issue = get_stock_gl_code($myrow["stock_id"]);
$stockitem = get_item($myrow["stock_id"]);
- //Chaitanya : Compatibility for Service Items
+ // Compatibility for Service Items
if (!is_service($issue["mb_flag"]))
$ivaccount = $issue["inventory_account"];
else
}
}
if ($issue_total != 0)
- //Chaitanya : Revese cost effect on manfactured stock item as adjustment only
+ // Revese cost effect on manfactured stock item as adjustment only
add_issue_cost($manf_stock_id, 0, $date_, $issue_total, true);
$issue = get_stock_gl_code($manf_stock_id);
$stockitem = get_item($manf_stock_id);
0, 0, $date_.": "._("Reversed the issue to")." ".$stockitem["description"],
-$total_cost);
- //Chaitanya : Shifted below void all related stock moves
+ // Shifted below void all related stock moves
void_stock_move(ST_MANUISSUE, $type_no);
commit_transaction();
work_order_quick_costs($woid, $details["stock_id"], $quantity, $date_, $id);
// -------------------------------------------------------------------------
- // Chaitanya: stamp BOM cost to finished item
+ // Stamp BOM cost to finished item
$m_cost = 0;
$result = get_bom($details["stock_id"]);
while ($bom_item = db_fetch($result))
begin_transaction();
hook_db_prevoid(ST_MANURECEIVE, $type_no);
- //Chaitanya : Skip processing already voided entry i.e. explicitly voided
+ // Skip processing already voided entry i.e. explicitly voided
$void_entry = get_voided_entry(ST_MANURECEIVE, $type_no);
if ($void_entry)
return;
// deduct the quantity of this production from the parent work order
work_order_update_finished_quantity($row["workorder_id"], -$row["quantity"]);
- //Chaitanya : skipped this step as BOM may have got changed
- //work_order_quick_costs($row['workorder_id'], $row['stock_id'], -$row['quantity'], sql2date($row['date_']), $type_no);
-
// void any related gl trans
- //Chaitanya : Nothing happens due to next statement as all gl postings are done against WO
- //void_gl_trans(ST_MANURECEIVE, $type_no, true);
-
+
$woid = $row["workorder_id"];
$date_ = sql2date($row["date_"]);
$issue = get_stock_gl_code($myrow["stock_id"]);
$stockitem = get_item($myrow["stock_id"]);
- //Chaitanya : Compatibility for Service Items
+ // Compatibility for Service Items
if (!is_service($issue["mb_flag"]))
$ivaccount = $issue["inventory_account"];
else
$sql = "UPDATE ".TB_PREF."wo_manufacture SET quantity=0 WHERE id=".db_escape($type_no);
db_query($sql, "Cannot void a wo production");
- //Chaitanya : Shifted below
+ // Shifted below
// void all related stock moves
void_stock_move(ST_MANURECEIVE, $type_no);
function work_order_quick_costs($woid, $stock_id, $units_reqd, $date_, $advanced=0, $costs=0, $cr_acc="", $labour=0, $cr_lab_acc="")
{
- global $wo_cost_types;
$result = get_bom($stock_id);
// credit all the components
if ($advanced)
{
$wo = get_work_order($woid);
- // also take the additional issues
- // moved to work_order_issues_db.inc
- /*
- $res = get_additional_issues($woid);
- $issue_total = 0;
- while ($item = db_fetch($res))
- {
- $standard_cost = get_standard_cost($item['stock_id']);
- $issue_cost = $standard_cost * $item['qty_issued'] * $units_reqd / $wo['units_reqd'];
- $issue = get_stock_gl_code($item['stock_id']);
- $stockitem = get_item($item['stock_id']);
- $total_cost += add_gl_trans_std_cost(ST_WORKORDER, $woid, $date_, $issue["inventory_account"], 0, 0,
- $date_.": "._("Issue of")." ".$stockitem["description"], -$issue_cost);
- $issue_total += $issue_cost;
- }
- if ($issue_total != 0)
- add_issue_cost($stock_id, $units_reqd, $date_, $issue_total);
- */
$lcost = get_gl_wo_cost($woid, WO_LABOUR);
add_labour_cost($stock_id, $units_reqd, $date_, $lcost * $units_reqd / $wo['units_reqd']);
$ocost = get_gl_wo_cost($woid, WO_OVERHEAD);
foreach ($order->line_items as $line_no=>$stock_item)
{
-// $total += ($stock_item->standard_cost * $stock_item->quantity);
-
if ($id != $line_no)
{
if (in_array($stock_item->stock_id, $low_stock))
if ($id == -1)
issue_edit_item_controls($order);
-// label_row(_("Total"), number_format2($total,user_price_dec()), "colspan=5", "align=right");
-
end_table();
if (@$low_stock)
display_note(_("Marked items have insufficient quantities in stock as on day of issue."), 0, 1, "class='stockmankofg'");
$_POST['stock_id'] = $order->line_items[$id]->stock_id;
$_POST['qty'] = qty_format($order->line_items[$id]->quantity,
$order->line_items[$id]->stock_id, $dec);
- //$_POST['std_cost'] = price_format($order->line_items[$id]->standard_cost);
$std_cost = $order->line_items[$id]->standard_cost;
$_POST['units'] = $order->line_items[$id]->units;
$dec = $item_info["decimals"];
$_POST['qty'] = number_format2(0, $dec);
- //$_POST['std_cost'] = price_format($item_info["standard_cost"]);
$std_cost = $item_info["standard_cost"];
$_POST['units'] = $item_info["units"];
}
yesno_list_row(_("Type:"), 'IssueType', $_POST['IssueType'],
_("Return Items to Location"), _("Issue Items to Work order"));
-
-
textarea_row(_("Memo"), 'memo_', null, 50, 3);
end_table(1);
$_POST['stock_id'] = $_GET['stock_id'];
}
if (list_updated('stock_id'))
- $Ajax->activate('_page_body');
+ $Ajax->activate('_page_body');
start_form(false, true);
start_table(TABLESTYLE_NOBORDER);
$selected_component = $selected_id;
//--------------------------------------------------------------------------------------------------
-//if (isset($_GET["NewItem"]))
-//{
-// $_POST['stock_id'] = $_GET["NewItem"];
-//}
if (isset($_GET['stock_id']))
{
$_POST['stock_id'] = $_GET['stock_id'];
$selected_parent = $_GET['stock_id'];
}
-/* selected_parent could come from a post or a get */
-/*if (isset($_GET["selected_parent"]))
-{
- $selected_parent = $_GET["selected_parent"];
-}
-else if (isset($_POST["selected_parent"]))
-{
- $selected_parent = $_POST["selected_parent"];
-}
-*/
-/* selected_component could also come from a post or a get */
-/*if (isset($_GET["selected_component"]))
-{
- $selected_component = $_GET["selected_component"];
-}
-else
-{
- $selected_component = get_post("selected_component", -1);
-}
-*/
-
//--------------------------------------------------------------------------------------------------
function display_bom_items($selected_parent)
function costs_link($row)
{
-/*
- return $row["closed"] || !$row["released"] ? '' :
- pager_link(_('Costs'),
- "/gl/gl_bank.php?NewPayment=1&PayType="
- .PT_WORKORDER. "&PayPerson=" .$row["id"]);
-*/
return $row["closed"] || !$row["released"] ? '' :
pager_link(_('Costs'),
"/manufacturing/work_order_costs.php?trans_no=" .$row["id"]);
function view_gl_link($row)
{
- //if ($row['closed'] == 0)
- // return '';
return get_gl_view_str(ST_WORKORDER, $row['id']);
}
function can_process($wo_details)
{
- global $SysPrefs, $Refs;
+ global $SysPrefs;
if (!check_reference($_POST['ref'], ST_MANURECEIVE))
{
start_form();
hidden('selected_id', $_POST['selected_id']);
-//hidden('WOReqQuantity', $_POST['WOReqQuantity']);
$dec = get_qty_dec($wo_details["stock_id"]);
if (!isset($_POST['quantity']) || $_POST['quantity'] == '')
function can_process()
{
- global $selected_id, $SysPrefs, $Refs;
+ global $selected_id, $SysPrefs;
if (!isset($selected_id))
{
display_error( _("The date entered is in an invalid format."));
return false;
}
- //elseif (!is_date_in_fiscalyear($_POST['RequDate']))
- //{
- // display_error(_("The entered date is out of fiscal year or is closed for further data entry."));
- // return false;
- //}
if (isset($selected_id))
{
- $myrow = get_work_order($selected_id, true);
-
if ($_POST['units_issued'] > input_num('quantity'))
{
set_focus('quantity');
//-----------------------------------------------------------------------------------------------
function can_process()
{
- global $Refs;
-
if (!is_date($_POST['date_']))
{
display_error(_("The entered date for the issue is invalid."));
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the License here <http://www.gnu.org/licenses/gpl-3.0.html>.
***********************************************************************/
-//------------------- update average material cost ------------------------------------------ Joe Hunt Mar-03-2008
+//------------------- update average material cost ----------------------------------------------
function update_average_material_cost($supplier, $stock_id, $price, $qty, $date, $adj_only=false)
{
// probably this function should be optimized
$price_in_home_currency_ = $price_in_home_currency;
- //Handle if inventory will become negative
- //8-OCT-2011 : Skip negative inventory adjustment for case of adjust_only
+ // Handle if inventory will become negative
+ // Skip negative inventory adjustment for case of adjust_only
if (is_inventory_item($stock_id) && !$adj_only)
handle_negative_inventory($stock_id, $qty, $price_in_home_currency, $date);
//Price adjustment for manufactured item
if (!$adj_only && $myrow['mb_flag'] == 'M')
{
- $standard_cost = get_standard_cost($stock_id);
//reduce overhead_cost and labour_cost from price as those will remain as is
$price_in_home_currency = $price_in_home_currency - $myrow['labour_cost'] - $myrow['overhead_cost'];
}
- if ($adj_only)
- $exclude = ST_CUSTDELIVERY;
- else
- $exclude = 0;
$cost_adjust = false;
$qoh = get_qoh_on_date($stock_id);
$material_cost = ($qoh * $material_cost + $qty * $price_in_home_currency) / ($qoh + $qty);
}
- if ($cost_adjust) // new 2010-02-10 //Chaitanya : Material_cost replaced with price
+ if ($cost_adjust) // Material_cost replaced with price
adjust_deliveries($stock_id, $price_in_home_currency_, $date);
$sql = "UPDATE ".TB_PREF."stock_master SET material_cost=".db_escape($material_cost)."
WHERE stock_id=".db_escape($stock_id);
{
$stock_gl_code = get_stock_gl_code($order_line->stock_id);
- /*Update sales_order_details for the new quantity received and the standard cost used for postings to GL and recorded in the stock movements for FIFO/LIFO stocks valuations*/
- //------------------- update average material cost and clearing account ----- Joe Hunt Mar-03-2008
+ /*Update sales_order_details for the new quantity received and the standard cost used for postings to GL
+ and recorded in the stock movements for FIFO/LIFO stocks valuations*/
+ //------------------- update average material cost and clearing account --------------------------------
if (is_inventory_item($order_line->stock_id))
{
if ($clearing_act)
$total += add_gl_trans_supplier(ST_SUPPRECEIVE, $grn, $date_, $stock_gl_code["inventory_account"],
$stock_gl_code['dimension_id'], $stock_gl_code['dimension2_id'],
- $order_line->receive_qty * $order_line->taxfree_charge_price($po), $po->supplier_id, '', 0, $order_line->stock_id);
+ $order_line->receive_qty * $order_line->taxfree_charge_price($po), $po->supplier_id, '', 0,
+ $order_line->stock_id);
update_average_material_cost($po->supplier_id, $order_line->stock_id, $order_line->price,
$order_line->receive_qty, $date_);
}
- //----------------------------------------------------------------------------------------------------------------
+ //------------------------------------------------------------------------------------------------------
if ($order_line->qty_received == 0)
{
/*This must be the first receipt of goods against this line */
/*Need to get the standard cost as it is now so we can process GL jorunals later*/
$order_line->standard_cost = get_standard_cost($order_line->stock_id);
}
- // added 2008-12-08 Joe Hunt. Update the purchase data table
+ // Update the purchase data table
add_or_update_purchase_data($po->supplier_id, $order_line->stock_id, $order_line->price,
$order_line->item_description);
quantity_ordered=".db_escape($quantity).",
act_price=".db_escape($price)."
WHERE po_detail_item = ".db_escape($po_detail_item);
-
db_query($sql, "a purchase order details record could not be updated. This receipt of goods has not been processed ");
$sql = "INSERT INTO ".TB_PREF."grn_items (grn_batch_id, po_detail_item, item_code, description, qty_recd)
while ($myrow = db_fetch($result))
{
if ($myrow['qty_recd'] == 0 && $myrow['quantity_inv'] == 0)
- continue; // 2011-01-18 Joe Hunt. We will not have empty credited rows.
+ continue; // We will not have empty credited rows.
if (is_null($myrow["units"]))
{
$units = "";
$Refs->save(ST_PURCHORDER, $po_obj->order_no, $po_obj->reference);
- //add_comments(ST_PURCHORDER, $po_obj->order_no, $po_obj->orig_order_date, $po_obj->Comments);
-
add_audit_trail(ST_PURCHORDER, $po_obj->order_no, $po_obj->orig_order_date);
hook_db_postwrite($po_obj, ST_PURCHORDER);
commit_transaction();
db_query($sql, "One of the purchase order detail records could not be updated");
}
-//_vd($po_obj->prepayments);
reallocate_payments($po_obj->order_no, ST_PURCHORDER, $po_obj->orig_order_date, $po_obj->get_trans_total(), $po_obj->prepayments);
-//_vd($p = get_payments_for($po_obj->order_no, ST_PURCHORDER));
-//_vd(get_supp_trans($p[0]['trans_no_from'], $p[0]['trans_type_from']));
-//exit;
-
- // add_comments(ST_PURCHORDER, $po_obj->order_no, $po_obj->orig_order_date, $po_obj->Comments);
add_audit_trail($po_obj->trans_type, $po_obj->order_no, Today(), _("Updated."));
hook_db_postwrite($po_obj, ST_PURCHORDER);
{
if ($data['supplier_description'] != "")
$myrow['description'] = $data['supplier_description'];
- //if ($data['suppliers_uom'] != "")
- // $myrow['units'] = $data['suppliers_uom'];
}
if (is_null($myrow["units"]))
{
$myrow["quantity_ordered"],$myrow["description"],
$myrow["unit_price"],$units, sql2date($myrow["delivery_date"]),
$myrow["qty_invoiced"], $myrow["quantity_received"])) {
- $newline = &$order->line_items[$order->lines_on_order-1];
- $newline->po_detail_rec = $myrow["po_detail_item"];
- $newline->standard_cost = $myrow["std_cost_unit"]; /*Needed for receiving goods and GL interface */
- // set for later GRN edition
-// $newline->receive_qty = $newline->quantity - $newline->qty_dispatched;
+ $order->line_items[$order->lines_on_order-1]->po_detail_rec = $myrow["po_detail_item"];
}
} /* line po from purchase order details */
} //end of checks on returned data set
$sql .= " AND person_id=".db_escape($person_id);
db_query($sql, "could not void supp transactions for type=$type and trans_no=$type_no");
-// is this necessary?
-// if ($date != "")
-// exchange_variation($type, $type_no, $row['trans_type_to'], $row['trans_no_to'], $date,
-// $row['amt'], PT_SUPPLIER, true);
}
//-------------------------------------------------------------------------------------------------------------
}
else
{
-// FIXME: change to form below when prepayments terms finally can be selected in PO entry form:
-// $sql .= " AND round(prep_amount) > 0 AND ISNULL(grn.purch_order_no)"; // only sales orders with prepayment level set and no yet received
$sql .= " AND ISNULL(grn.purch_order_no)"; // only sales orders no yet received
}
if ($supplier_id)
AND trans.type NOT IN (".implode(',',array(ST_SUPPAYMENT,ST_BANKPAYMENT)).")";
$sql .= " GROUP BY type, trans_no";
}
-//_vd($sql);
return db_query($sql." ORDER BY due_date", "Cannot retreive alloc to transactions");
}
FROM ".TB_PREF."supp_allocations allocs
LEFT JOIN ".TB_PREF."purch_order_details line ON line.order_no=allocs.trans_no_to AND trans_type_to=".ST_PURCHORDER."
WHERE line.po_detail_item IN(".implode(',', array_values($line_ids)).")";
-//_vd($sql);
+
$result = db_query($sql, "Cannot retrieve po prepayments");
while($dat = db_fetch($result))
function display_grn_summary(&$po)
{
- global $Refs;
- start_table(TABLESTYLE2, "width='90%'");
+
+ start_table(TABLESTYLE2, "width='90%'");
start_row();
label_cells(_("Supplier"), $po->supplier_name, "class='tableheader2'");
function edit_grn_summary(&$po)
{
global $Refs;
-
+
start_outer_table(TABLESTYLE2, "width='80%'");
table_section(1);
date_row(_("Date Items Received"), 'DefaultReceivedDate', '', true, 0, 0, 0, '', true);
table_section(3);
- // currently this is related order supp reference
-// ref_row(_("Supplier's Reference"), 'supp_ref', _("Supplier's Reference"));
label_row(_("Supplier's Reference"), $po->supp_ref);
label_row(_("Delivery Address"), $po->delivery_address);
{
foreach ( $supp_trans->gl_codes as $gl_line)
{
- ////////// 2009-08-18 Joe Hunt
if (!is_tax_account($gl_line->gl_code) || $supp_trans->tax_included)
$supp_trans->ov_amount += $gl_line->amount;
}
if ($supp_trans->trans_type == ST_SUPPCREDIT && $supp_trans->src_docs)
{
-// $trans = get_supp_trans($_POST['invoice_no'], ST_SUPPINVOICE);
-// $trans = get_supp_trans($supp_trans->supplier_id, ST_SUPPINVOICE);
-// $_POST['supplier_id'] = $trans['supplier_id'];
-// $supp = $trans['supplier_name'] . " - " . $trans['SupplierCurrCode'];
-
$_POST['supplier_id'] = $supp_trans->supplier_id;
$supp = $supp_trans->supplier_name." - ".$supp_trans->currency;
label_row(_("Supplier:"), $supp.hidden('supplier_id', $_POST['supplier_id'], false));
amount_cells(null, 'amount');
if ($dim < 1)
text_cells_ex(null, 'memo_', 35, 50, null, null, null, hidden('dimension_id', 0, false).hidden('dimension2_id', 0, false));
- else if ($dim < 2)
+ elseif ($dim < 2)
text_cells_ex(null, 'memo_', 35, 50, null, null, null, hidden('dimension2_id', 0, false));
else
text_cells_ex(null, 'memo_', 35, 50, null, null, null);
$dim = get_company_pref('use_dimension');
if ($dim == 2)
$th = array(_("Account"), _("Name"), _("Dimension")." 1", _("Dimension")." 2", _("Amount"), _("Memo"));
- else if ($dim == 1)
+ elseif ($dim == 1)
$th = array(_("Account"), _("Name"), _("Dimension"), _("Amount"), _("Memo"));
else
$th = array(_("Account"), _("Name"), _("Amount"), _("Memo"));
label_cell("");
}
end_row();
- /////////// 2009-08-18 Joe Hunt
if ($mode > 1) {
if ($supp_trans->tax_included || !is_tax_account($entered_gl_code->gl_code))
$total_gl_value += $entered_gl_code->amount;
{ // only invoiced
if (isset($_POST['receive_begin']) && isset($_POST['receive_end']))
$result = get_grn_items(0, $supp_trans->supplier_id, false, true, 0, $_POST['receive_begin'], $_POST['receive_end']);
- else if ($supp_trans->src_docs)
+ elseif ($supp_trans->src_docs)
$result = get_grn_items(0, $supp_trans->supplier_id, false, true, array_keys($supp_trans->src_docs));
else
$result = get_grn_items(0, $supp_trans->supplier_id, false, true);
$id = find_submit('Edit');
if (($id != -1) && $line_no == $id)
{
-// hidden('line_no', $id);
$_POST['stock_id'] = $order->line_items[$id]->stock_id;
$dec = get_qty_dec($_POST['stock_id']);
$_POST['qty'] = qty_format($order->line_items[$id]->quantity, $_POST['stock_id'], $dec);
- //$_POST['price'] = price_format($order->line_items[$id]->price);
$_POST['price'] = price_decimal_format($order->line_items[$id]->price, $dec2);
if ($order->trans_type == ST_PURCHORDER)
$_POST['req_del_date'] = $order->line_items[$id]->req_del_date;
text_cells(null,'item_description', null, 45, 150);
else {
hidden('item_description', $_POST['item_description']);
-// label_cell($_POST['item_description']);
label_cell($order->line_items[$id]->item_description);
}
}
else
{
-// hidden('line_no', ($_SESSION['PO']->lines_on_order + 1));
- //Chaitanya : Manufcatured item can be purchased
+ // Manufcatured item can be purchased
stock_items_list_cells(null, 'stock_id', null, false, true, false, true, array('editable' => 30));
- //stock_purchasable_items_list_cells(null, 'stock_id', null, false, true, true);
if (list_updated('stock_id')) {
$Ajax->activate('price');
$Ajax->activate('units');
$dec = $item_info["decimals"];
$_POST['qty'] = number_format2(get_purchase_conversion_factor ($order->supplier_id, $_POST['stock_id']), $dec);
- //$_POST['price'] = price_format(get_purchase_price ($order->supplier_id, $_POST['stock_id']));
$_POST['price'] = price_decimal_format(get_purchase_price ($order->supplier_id, $_POST['stock_id']), $dec2);
if ($order->trans_type == ST_PURCHORDER)
$_POST['req_del_date'] = add_days(Today(), $SysPrefs->default_receival_required_by());
else
amount_cells(null, 'price', null, null, null, $dec2);
- //$line_total = $_POST['qty'] * $_POST['price'] * (1 - $_POST['Disc'] / 100);
$line_total = round(input_num('qty') * input_num('price'), user_price_dec());
amount_cell($line_total, false, '','line_total');
if (db_has_suppliers())
{
start_table(false, "", 3);
-// start_table(TABLESTYLE_NOBORDER);
start_row();
supplier_list_cells(_("Select a supplier: "), 'supplier_id', null,
_('New supplier'), true, check_value('show_inactive'));
$clearing_act = get_company_pref('grn_clearing_act');
if ($clearing_act)
display_note(get_gl_view_str($trans_type, $trans_no, _("View the GL Journal Entries for this Delivery")), 1);
-// not yet
-// display_note(print_document_link($trans_no, _("&Print This GRN"), true, $trans_type), 0, 1);
hyperlink_params("$path_to_root/purchasing/supplier_invoice.php",
_("Entry purchase &invoice for this receival"), "New=1");
display_note(get_trans_view_str($trans_type, $trans_no, _("&View this Invoice")), 0);
-// not yet
-// display_note(print_document_link($trans_no, _("&Print This Invoice"), true, $trans_type), 0, 1);
-
display_note(get_gl_view_str($trans_type, $trans_no, _("View the GL Journal Entries for this Invoice")), 1);
hyperlink_params("$path_to_root/purchasing/supplier_payment.php", _("Entry supplier &payment for this invoice"),
if ($allow_update)
{
- $myrow = db_fetch($result);
$_SESSION['PO']->add_to_order (count($_SESSION['PO']->line_items), $_POST['stock_id'], input_num('qty'),
get_post('stock_id_text'), //$myrow["description"],
input_num('price'), '', // $myrow["units"], (retrived in cart)
function can_commit()
{
- global $Refs;
-
if (!get_post('supplier_id'))
{
display_error(_("There is no supplier selected."));
{
if (!check_reference(get_post('ref'), $_SESSION['PO']->trans_type))
{
+ _vd("bad reference");
+ exit;
set_focus('ref');
return false;
}
set_focus('StkLocation');
return false;
}
- if (!db_has_currency_rates($_SESSION['PO']->curr_code, $_POST['OrderDate']))
+ if (!db_has_currency_rates($_SESSION['PO']->curr_code, $_POST['OrderDate'], true))
return false;
if ($_SESSION['PO']->order_has_items() == false)
{
{
/*Now need to check that the order details are the same as they were when they were read
into the Items array. If they've changed then someone else must have altered them */
- // Sherifoz 22.06.03 Compare against COMPLETED items only !!
+ // Compare against COMPLETED items only !!
// Otherwise if you try to fullfill item quantities separately will give error.
$result = get_po_items($_SESSION['PO']->order_no);
function can_process()
{
- global $SysPrefs, $Refs;
+ global $SysPrefs;
if (count($_SESSION['PO']->line_items) <= 0)
{
$_SESSION['supp_trans']->trans_type = ST_SUPPCREDIT;
$_SESSION['supp_trans']->trans_no = 0;
$_SESSION['supp_trans']->supp_reference = '';
- // $_SESSION['supp_trans']->supp_reference = $_POST['invoice_no'] = $_GET['invoice_no'];
$help_context = "Supplier Credit Note";
$_SESSION['page_title'] = _("Supplier Credit Note");
function check_data()
{
- global $Refs, $SysPrefs;
+ global $SysPrefs;
if (!$_SESSION['supp_trans']->is_valid_trans_to_post())
{
echo "</td></tr>";
end_table(1); // outer table
-//_vd($purchase_order);
+
display_allocations_to(PT_SUPPLIER, $purchase_order->supplier_id, ST_PURCHORDER, $purchase_order->order_no, $total + $tax_total);
//----------------------------------------------------------------------------------------------------
AND taxrec.tran_date >= '$fromdate'
AND taxrec.tran_date <= '$todate'
ORDER BY taxrec.trans_type, taxrec.tran_date, taxrec.trans_no, taxrec.ex_rate";
-//display_error($sql);
return db_query($sql,"No transactions were returned");
}