$page_security = 2;
$path_to_root="../..";
+include($path_to_root . "/includes/db_pager.inc");
include($path_to_root . "/includes/session.inc");
page(_("Inventory Item Where Used Inquiry"));
-//include($path_to_root . "/includes/date_functions.inc");
include($path_to_root . "/includes/ui.inc");
check_db_has_stock_items(_("There are no items defined in the system."));
echo "<hr></center>";
set_global_stock_item($_POST['stock_id']);
-
-if (list_updated('stock_id'))
- $Ajax->activate('usage_table');
-
-if (isset($_POST['stock_id']))
+//-----------------------------------------------------------------------------
+function select_link($row)
{
- $sql = "SELECT ".TB_PREF."bom.*,".TB_PREF."stock_master.description,".TB_PREF."workcentres.name As WorkCentreName, ".TB_PREF."locations.location_name
- FROM ".TB_PREF."bom, ".TB_PREF."stock_master, ".TB_PREF."workcentres, ".TB_PREF."locations
- WHERE ".TB_PREF."bom.parent = ".TB_PREF."stock_master.stock_id AND ".TB_PREF."bom.workcentre_added = ".TB_PREF."workcentres.id
- AND ".TB_PREF."bom.loc_code = ".TB_PREF."locations.loc_code
- AND ".TB_PREF."bom.component='" . $_POST['stock_id'] . "'";
-
- $result = db_query($sql,"No parent items were returned");
-
- div_start('usage_table');
- if (db_num_rows($result) == 0)
- {
- display_note(_("The selected item is not used in any BOMs."));
- }
- else
- {
-
- start_table("$table_style width=80%");
-
- $th = array(_("Parent Item"), _("Work Centre"), _("Location"), _("Quantity Required"));
- table_header($th);
-
- $k = $j = 0;
- while ($myrow = db_fetch($result))
- {
-
- alt_table_row_color($k);
-
- $select_item = $path_to_root . "/manufacturing/manage/bom_edit.php?" . SID . "stock_id=" . $myrow["parent"];
-
- label_cell("<a href='$select_item'>" . $myrow["parent"]. " - " . $myrow["description"]. "</a>");
- label_cell($myrow["WorkCentreName"]);
- label_cell($myrow["location_name"]);
- qty_cell($myrow["quantity"], false, get_qty_dec($_POST['stock_id']));
- end_row();
-
- $j++;
- If ($j == 12)
- {
- $j = 1;
- table_header($th);
- }
- //end of page full new headings if
- }
+ return pager_link( $row["parent"]. " - " . $row["description"],
+ "/manufacturing/manage/bom_edit.php?stock_id=" . $row["parent"]);
+}
- end_table();
- }
- div_end();
+$sql = "SELECT
+ bom.parent,
+ workcentre.name As WorkCentreName,
+ location.location_name,
+ bom.quantity,
+ parent.description
+ FROM ".TB_PREF."bom as bom, "
+ .TB_PREF."stock_master as parent, "
+ .TB_PREF."workcentres as workcentre, "
+ .TB_PREF."locations as location
+ WHERE bom.parent = parent.stock_id
+ AND bom.workcentre_added = workcentre.id
+ AND bom.loc_code = location.loc_code
+ AND bom.component='" . $_POST['stock_id'] . "'";
+
+ $cols = array(
+ _("Parent Item") => array('fun'=>'select_link'),
+ _("Work Centre"),
+ _("Location"),
+ _("Quantity Required")
+ );
+
+$table =& new_db_pager('usage_table', $sql, $cols);
+
+if (list_updated('stock_id')) {
+ $table->set_sql($sql);
+ $table->set_columns($cols);
+ $Ajax->activate('usage_table');
}
+display_db_pager($table);
+
end_form();
end_page();
$page_security = 2;
$path_to_root="..";
+include($path_to_root . "/includes/db_pager.inc");
include_once($path_to_root . "/includes/session.inc");
include_once($path_to_root . "/includes/date_functions.inc");
$Ajax->addDisable(true, 'SelectedStockItem', $disable);
if ($disable) {
-// $Ajax->addFocus(true, 'OrderNumber');
set_focus('OrderNumber');
} else
-// $Ajax->addFocus(true, 'StockLocation');
set_focus('StockLocation');
$Ajax->activate('orders_tbl');
end_form();
-$sql = "SELECT ".TB_PREF."workorders.*, ".TB_PREF."stock_master.description,".TB_PREF."locations.location_name
- FROM ".TB_PREF."workorders,".TB_PREF."stock_master,".TB_PREF."locations
- WHERE ".TB_PREF."stock_master.stock_id=".TB_PREF."workorders.stock_id AND
- ".TB_PREF."locations.loc_code=".TB_PREF."workorders.loc_code ";
+//-----------------------------------------------------------------------------
+function check_overdue($row)
+{
+ return (!$row["closed"]
+ && date_diff(Today(), sql2date($row["required_by"]), "d") > 0);
+}
+
+function view_link($dummy, $order_no)
+{
+ return get_trans_view_str(systypes::work_order(), $order_no);
+}
+
+function view_stock($row)
+{
+ return view_stock_status($row["stock_id"], $row["description"], false);
+}
+
+function wo_type_name($dummy, $type)
+{
+ return wo_types::name($type);
+}
+
+function edit_link($row)
+{
+ return $row['closed'] ? '<i>'._('Closed').'</i>' :
+ pager_link(_("Edit"),
+ "/manufacturing/work_order_entry.php?trans_no=" . $row["id"]);
+}
+
+function release_link($row)
+{
+ return $row["closed"] ? '' :
+ ($row["released"]==0 ?
+ pager_link(_('Release'),
+ "/manufacturing/work_order_release.php?trans_no=" . $row["id"])
+ :
+ pager_link(_('Issue'),
+ "/manufacturing/work_order_issue.php?trans_no=" .$row["id"]));
+}
+
+function produce_link($row)
+{
+ return $row["closed"] || !$row["released"] ? '' :
+ pager_link(_('Produce'),
+ "/manufacturing/work_order_add_finished.php?trans_no=" .$row["id"]);
+}
+
+function costs_link($row)
+{
+ return $row["closed"] || !$row["released"] ? '' :
+ pager_link(_('Costs'),
+ "/gl/gl_bank.php?NewPayment=1&PayType="
+ .payment_person_types::WorkOrder(). "&PayPerson=" .$row["id"]);
+}
+
+function dec_amount($row, $amount)
+{
+ return number_format2($amount, $row['decimals']);
+}
+
+$sql = "SELECT
+ workorder.id,
+ workorder.wo_ref,
+ workorder.type,
+ location.location_name,
+ item.description,
+ workorder.units_reqd,
+ workorder.units_issued,
+ workorder.date_,
+ workorder.required_by,
+ workorder.released_date,
+ workorder.closed,
+ workorder.released,
+ workorder.stock_id,
+ unit.decimals
+ FROM ".TB_PREF."workorders as workorder,"
+ .TB_PREF."stock_master as item,"
+ .TB_PREF."item_units as unit,"
+ .TB_PREF."locations as location
+ WHERE workorder.stock_id=item.stock_id
+ AND workorder.loc_code=location.loc_code
+ AND item.units=unit.abbr";
if (check_value('OpenOnly') || $outstanding_only != 0)
{
- $sql .= " AND ".TB_PREF."workorders.closed=0 ";
+ $sql .= " AND workorder.closed=0";
}
if (isset($_POST['StockLocation']) && $_POST['StockLocation'] != $all_items)
{
- $sql .= "AND ".TB_PREF."workorders.loc_code='" . $_POST['StockLocation'] . "' ";
+ $sql .= " AND workorder.loc_code='" . $_POST['StockLocation'] . "' ";
}
if (isset($_POST['OrderNumber']) && $_POST['OrderNumber'] != "")
{
- $sql .= "AND ".TB_PREF."workorders.wo_ref LIKE '%". $_POST['OrderNumber'] . "%'";
+ $sql .= " AND workorder.wo_ref LIKE '%". $_POST['OrderNumber'] . "%'";
}
if (isset($_POST['SelectedStockItem']) && $_POST['SelectedStockItem'] != $all_items)
{
- $sql .= "AND ".TB_PREF."workorders.stock_id='". $_POST['SelectedStockItem'] . "'";
+ $sql .= " AND workorder.stock_id='". $_POST['SelectedStockItem'] . "'";
}
if (check_value('OverdueOnly'))
{
$Today = date2sql(Today());
- $sql .= "AND ".TB_PREF."workorders.required_by < '$Today' ";
-}
-$sql .= " ORDER BY ".TB_PREF."workorders.required_by";
-
-$result = db_query($sql,"No orders were returned");
-
-div_start('orders_tbl');
-start_table("$table_style width=80%");
-
-$th = array(_("#"), _("Reference"), _("Type"), _("Location"), _("Item"),
- _("Required"), _("Manufactured"), _("Date"), _("Required By"),
- '', '', '', '', '');
-table_header($th);
-
-$j = 1;
-$k = 0;
-
-while ($myrow = db_fetch($result))
-{
-
-
- // check if it's an overdue work order
- if (!$myrow["closed"] && date_diff(Today(), sql2date($myrow["required_by"]), "d") > 0)
- {
- start_row("class='overduebg'");
- }
- else
- alt_table_row_color($k);
-
- $dec = get_qty_dec($myrow["stock_id"]);
- label_cell(get_trans_view_str(systypes::work_order(), $myrow["id"]));
- label_cell(get_trans_view_str(systypes::work_order(), $myrow["id"], $myrow["wo_ref"]));
- label_cell(wo_types::name($myrow["type"]));
- label_cell($myrow["location_name"]);
- view_stock_status_cell($myrow["stock_id"], $myrow["description"]);
- qty_cell($myrow["units_reqd"], false, $dec);
- qty_cell($myrow["units_issued"], false, $dec);
- label_cell(sql2date($myrow["date_"]));
- label_cell(sql2date($myrow["required_by"]));
-
- $l1 = $l2 = $l3 = $l4 = '';
- if ($myrow["closed"] == 0)
- {
- $modify_page = $path_to_root . "/manufacturing/work_order_entry.php?" . SID . "trans_no=" . $myrow["id"];
- $l1 = "<a href=$modify_page>"._('Edit').'</a>';
- if ($myrow["released"] == 0)
- {
- $release_page = $path_to_root . "/manufacturing/work_order_release.php?" . SID . "trans_no=" . $myrow["id"];
- $l2 = "<a href=$release_page>"._('Release').'</a>';
- }
- else
- {
- $issue = $path_to_root . "/manufacturing/work_order_issue.php?" . SID . "trans_no=" .$myrow["id"];
- $add_finished = $path_to_root . "/manufacturing/work_order_add_finished.php?" . SID . "trans_no=" .$myrow["id"];
- $costs = $path_to_root . "/gl/gl_bank.php?NewPayment=1&PayType=" . payment_person_types::WorkOrder(). "&PayPerson=" .$myrow["id"];
- $l2 = "<a href=$issue>" . _("Issue") . "</a>";
- $l3 = "<a href=$add_finished>" . _("Produce") . "</a>";
- $l4 = "<a href=$costs>" . _("Costs") . "</a>";
- }
- }
- else
- {
- $l1 = "<i>"._('Closed')."</i>";
- }
- label_cell($l1);
- label_cell($l2);
- label_cell($l3);
- label_cell($l4);
- label_cell(get_gl_view_str(systypes::work_order(), $myrow["id"]));
-
- end_row();
-
- $j++;
- If ($j == 12)
- {
- $j = 1;
- table_header($th);
- }
- //end of page full new headings if
-}
-//end of while loop
-
-end_table(1);
-div_end();
-//---------------------------------------------------------------------------------
+ $sql .= " AND workorder.required_by < '$Today' ";
+}
+
+$cols = array(
+ _("#") => array('fun'=>'view_link'),
+ _("Reference"), // viewlink 2 ?
+ _("Type") => array('fun'=>'wo_type_name'),
+ _("Location"),
+ _("Item") => array('fun'=>'view_stock'),
+ _("Required") => array('fun'=>'dec_amount', 'align'=>'right'),
+ _("Manufactured") => array('fun'=>'dec_amount', 'align'=>'right'),
+ _("Date") => 'date',
+ _("Required By") => array('type'=>'date', 'ord'=>''),
+ array('insert'=>true, 'fun'=> 'edit_link'),
+ array('insert'=>true, 'fun'=> 'release_link'),
+ array('insert'=>true, 'fun'=> 'produce_link'),
+ array('insert'=>true, 'fun'=> 'costs_link')
+);
+
+$table =& new_db_pager('orders_tbl', $sql, $cols);
+$table->set_marker('check_overdue', _("Marked orders are overdue."));
+
+if (get_post('SearchOrders')) {
+ $table->set_sql($sql);
+ $table->set_columns($cols);
+ $Ajax->activate('orders_tbl');
+}
+start_form();
+display_db_pager($table);
+end_form();
end_page();
?>
$path_to_root="../..";
$page_security = 3;
+include($path_to_root . "/includes/db_pager.inc");
include_once($path_to_root . "/includes/session.inc");
include_once($path_to_root . "/includes/date_functions.inc");
//--------------------------------------------------------------------------------
-function display_allocatable_transactions()
-{
- global $table_style, $path_to_root;
- start_form();
+start_form();
/* show all outstanding receipts and credits to be allocated */
/*Clear any previous allocation records */
check(_("Show Settled Items:"), 'ShowSettled', null, true);
echo "</center><br><br>";
+end_form();
set_global_supplier($_POST['supplier_id']);
if (isset($_POST['supplier_id']) && ($_POST['supplier_id'] == reserved_words::get_all()))
$settled = false;
if (check_value('ShowSettled'))
$settled = true;
-
$supplier_id = null;
if (isset($_POST['supplier_id']))
$supplier_id = $_POST['supplier_id'];
- $trans_items = get_allocatable_from_supp_transactions($supplier_id, $settled);
- div_start('alloc_tbl');
- start_table($table_style);
- if (!isset($_POST['supplier_id']))
- $th = array(_("Transaction Type"), _("#"), _("Reference"), _("Date"), _("Supplier"),
- _("Currency"), _("Total"), _("Left To Allocate"));
- else
- $th = array(_("Transaction Type"), _("#"), _("Reference"), _("Date"),
- _("Total"), _("Left To Allocate"));
- table_header($th);
-
- $k = 0; //row colour counter
- $has_settled_items = false;
-
- while ($myrow = db_fetch($trans_items))
- {
- if ($myrow["settled"] == 1)
- {
- start_row("class='settledbg'");
- $has_settled_items = true;
- }
- else
- {
- alt_table_row_color($k);
- }
-
- label_cell(systypes::name($myrow["type"]));
- label_cell(get_trans_view_str($myrow["type"], $myrow["trans_no"]));
- label_cell($myrow["reference"]);
- label_cell(sql2date($myrow["tran_date"]));
-
- if (!isset($_POST['supplier_id']))
- {
- label_cell($myrow["supp_name"]);
- label_cell($myrow["curr_code"]);
- }
- amount_cell(-$myrow["Total"]);
- amount_cell(-$myrow["Total"]-$myrow["alloc"]);
- label_cell("<a href='$path_to_root/purchasing/allocations/supplier_allocate.php?trans_no=" . $myrow["trans_no"] . "&trans_type=" . $myrow["type"] . "'>" . _("Allocate") . "</a>");
- end_row();
- }
+//--------------------------------------------------------------------------------
+function systype_name($dummy, $type)
+{
+ return systypes::name($type);
+}
- end_table();
+function trans_view($trans)
+{
+ return get_trans_view_str($trans["type"], $trans["trans_no"]);
+}
- if ($has_settled_items)
- display_note(_("Marked items are settled."), 0, 1, "class='settledfg'");
+function alloc_link($row)
+{
+ return pager_link(_("Allocate"),
+ "/purchasing/allocations/supplier_allocate.php?trans_no="
+ .$row["trans_no"] . "&trans_type=" . $row["type"] );
+}
- if (db_num_rows($trans_items) == 0)
- display_note(_("There are no allocations to be done."), 1, 2);
- div_end();
- end_form();
+function amount_left($row)
+{
+ return -$row["Total"]-$row["alloc"];
}
-//--------------------------------------------------------------------------------
+function amount_total($row)
+{
+ return -$row["Total"];
+}
-if (get_post('_ShowSettled_update')) {
- $Ajax->activate('alloc_tbl');
+function check_settled($row)
+{
+ return $row['settled'] == 1;
}
-display_allocatable_transactions();
-//--------------------------------------------------------------------------------
+$sql = get_allocatable_from_supp_sql($supplier_id, $settled);
+
+$cols = array(
+ _("Transaction Type") => array('fun'=>'systype_name'),
+ _("#") => array('fun'=>'trans_view'),
+ _("Reference"),
+ _("Date") => array('type'=>'date', 'ord'=>'asc'),
+ _("Supplier") => array('ord'=>''),
+ _("Currency") => array('align'=>'center'),
+ _("Total") => 'amount',
+ _("Left to Allocate") => array('align'=>'right','insert'=>true, 'fun'=>'amount_left'),
+ array('insert'=>true, 'fun'=>'alloc_link')
+ );
+
+if (isset($_POST['customer_id'])) {
+ $cols[_("Supplier")] = 'skip';
+ $cols[_("Currency")] = 'skip';
+}
+
+$table =& new_db_pager('alloc_tbl', $sql, $cols);
+$table->set_marker('check_settled', _("Marked items are settled."), 'settledbg', 'settledfg');
+
+if (get_post('_ShowSettled_update') || get_post('_supplier_id_update') ) {
+ $table->set_sql($sql);
+ $table->set_columns($cols);
+ $Ajax->activate('alloc_tbl');
+}
+
+ start_form();
+ display_db_pager($table);
+ end_form();
end_page();
+
?>
\ No newline at end of file
$path_to_root="../..";
$page_security = 3;
+include($path_to_root . "/includes/db_pager.inc");
include_once($path_to_root . "/includes/session.inc");
include_once($path_to_root . "/sales/includes/sales_ui.inc");
context_call($path_to_root.'/sales/manage/customers.php?debtor_no='.$_POST['customer_id'] );
}
-function display_allocatable_transactions()
-{
- global $table_style, $path_to_root;
- start_form();
-
+start_form();
/* show all outstanding receipts and credits to be allocated */
/*Clear any previous allocation records */
if (isset($_SESSION['alloc']))
check(_("Show Settled Items:"), 'ShowSettled', null, true);
echo "</center><br><br>";
+end_form();
+
set_global_customer($_POST['customer_id']);
if (isset($_POST['customer_id']) && ($_POST['customer_id'] == reserved_words::get_all()))
if (isset($_POST['customer_id']))
$customer_id = $_POST['customer_id'];
- $trans_items = get_allocatable_from_cust_transactions($customer_id, $settled);
- div_start('alloc_tbl');
- start_table($table_style);
- if (!isset($_POST['customer_id']))
- $th = array(_("Transaction Type"), _("#"), _("Reference"), _("Date"), _("Customer"),
- _("Currency"), _("Total"), _("Left To Allocate"), "");
- else
- $th = array(_("Transaction Type"), _("#"), _("Reference"), _("Date"),
- _("Total"), _("Left To Allocate"), "");
- table_header($th);
- $k = 0; //row colour counter
- $has_settled_items = false;
-
- while ($myrow = db_fetch($trans_items))
- {
- if ($myrow["settled"] == 1)
- {
- start_row("class='settledbg'");
- $has_settled_items = true;
- }
- else
- {
- alt_table_row_color($k);
- }
-
- label_cell(systypes::name($myrow["type"]));
- label_cell(get_trans_view_str($myrow["type"], $myrow["trans_no"]));
- label_cell($myrow["reference"]);
- label_cell(sql2date($myrow["tran_date"]));
-
- if (!isset($_POST['customer_id']))
- {
- label_cell($myrow["DebtorName"]);
- label_cell($myrow["curr_code"]);
- }
- amount_cell($myrow["Total"]);
- amount_cell($myrow["Total"] - $myrow["alloc"]);
- label_cell("<a href='$path_to_root/sales/allocations/customer_allocate.php?trans_no="
- .$myrow["trans_no"] . "&trans_type=" . $myrow["type"] . "'>" . _("Allocate") . "</a>");
- end_row();
- }
+//--------------------------------------------------------------------------------
+function systype_name($dummy, $type)
+{
+ return systypes::name($type);
+}
- end_table();
+function trans_view($trans)
+{
+ return get_trans_view_str($trans["type"], $trans["trans_no"]);
+}
- if ($has_settled_items)
- display_note(_("Marked items are settled."), 0, 1, "class='settledfg'");
+function alloc_link($row)
+{
+ return pager_link(_("Allocate"),
+ "/sales/allocations/customer_allocate.php?trans_no="
+ .$row["trans_no"] . "&trans_type=" . $row["type"]
+ );
+}
- if (db_num_rows($trans_items) == 0)
- display_note(_("There are no allocations to be done."), 1, 2);
- div_end();
- end_form();
+function amount_left($row)
+{
+ return $row["Total"]-$row["alloc"];
}
-//--------------------------------------------------------------------------------
-if (get_post('_ShowSettled_update')) {
- $Ajax->activate('alloc_tbl');
+function check_settled($row)
+{
+ return $row['settled'] == 1;
}
-display_allocatable_transactions();
-//--------------------------------------------------------------------------------
+$sql = get_allocatable_from_cust_sql($customer_id, $settled);
+
+$cols = array(
+ _("Transaction Type") => array('fun'=>'systype_name'),
+ _("#") => array('fun'=>'trans_view'),
+ _("Reference"),
+ _("Date") => array('type'=>'date', 'ord'=>'asc'),
+ _("Customer") => array('ord'=>''),
+ _("Currency") => array('align'=>'center'),
+ _("Total") => 'amount',
+ _("Left to Allocate") => array('align'=>'right','insert'=>true, 'fun'=>'amount_left'),
+ array('insert'=>true, 'fun'=>'alloc_link')
+ );
+
+if (isset($_POST['customer_id'])) {
+ $cols[_("Customer")] = 'skip';
+ $cols[_("Currency")] = 'skip';
+}
+
+$table =& new_db_pager('alloc_tbl', $sql, $cols);
+$table->set_marker('check_settled', _("Marked items are settled."), 'settledbg', 'settledfg');
+
+if (get_post('_ShowSettled_update') || get_post('_customer_id_update')) {
+ $table->set_sql($sql);
+ $table->set_columns($cols);
+ $Ajax->activate('alloc_tbl');
+}
+
+ start_form();
+ display_db_pager($table);
+ end_form();
end_page();
?>
\ No newline at end of file