From e000d0b3fb245b02de604356b1f60c65b5f4962f Mon Sep 17 00:00:00 2001 From: Janusz Dobrowolski Date: Tue, 18 Nov 2008 21:42:59 +0000 Subject: [PATCH] Next fixes to db_pager usage/behaviour. --- dimensions/inquiry/search_dimensions.php | 4 ++++ includes/db_pager.inc | 7 +++--- includes/ui/db_pager_view.inc | 5 +++- inventory/inquiry/stock_movements.php | 23 +++++++++++-------- manufacturing/inquiry/where_used_inquiry.php | 3 +++ manufacturing/search_work_orders.php | 4 ++++ .../allocations/supplier_allocation_main.php | 13 ++++------- purchasing/inquiry/po_search.php | 6 +++-- purchasing/inquiry/po_search_completed.php | 6 +++-- .../inquiry/supplier_allocation_inquiry.php | 4 ++++ purchasing/inquiry/supplier_inquiry.php | 6 +++-- .../allocations/customer_allocation_main.php | 10 +++----- sales/inquiry/customer_allocation_inquiry.php | 5 +++- sales/inquiry/customer_inquiry.php | 10 ++++---- sales/inquiry/sales_deliveries_view.php | 6 ++++- sales/inquiry/sales_orders_view.php | 5 +++- 16 files changed, 74 insertions(+), 43 deletions(-) diff --git a/dimensions/inquiry/search_dimensions.php b/dimensions/inquiry/search_dimensions.php index 54749330..ceb7c4e0 100644 --- a/dimensions/inquiry/search_dimensions.php +++ b/dimensions/inquiry/search_dimensions.php @@ -176,6 +176,10 @@ if ($outstanding_only) { $table =& new_db_pager('dim_tbl', $sql, $cols); $table->set_marker('is_overdue', _("Marked dimensions are overdue.")); +if (get_post('SearchOrders')) { + $table->set_sql($sql); + $table->set_columns($cols); +} start_form(); display_db_pager($table); diff --git a/includes/db_pager.inc b/includes/db_pager.inc index 90f61ec3..328a424f 100644 --- a/includes/db_pager.inc +++ b/includes/db_pager.inc @@ -375,12 +375,13 @@ function &new_db_pager($name, $sql, $coldef, $page_len = 0) { if ($_SERVER['REQUEST_METHOD'] == 'GET') unset($_SESSION[$name]); // kill old pager if any exists on first page call - if (!isset($_SESSION[$name])) + if (!isset($_SESSION[$name])) { $_SESSION[$name] =& new db_pager($sql, $name, $page_len); + $_SESSION[$name]->set_sql($sql); + $_SESSION[$name]->set_columns($coldef); + } $ret = &$_SESSION[$name]; - $ret->set_sql($sql); - $ret->set_columns($coldef); return $ret; } diff --git a/includes/ui/db_pager_view.inc b/includes/ui/db_pager_view.inc index 67b3ea47..d4490241 100644 --- a/includes/ui/db_pager_view.inc +++ b/includes/ui/db_pager_view.inc @@ -104,7 +104,10 @@ function display_db_pager(&$pager) { else amount_cell($cell, false); break; case 'qty': - qty_cell($cell); break; + if ($cell=='') + label_cell(''); + else + qty_cell($cell, false, isset($col['dec']) ? $col['dec'] : null); break; case 'rate': rate_cell($cell); break; default: diff --git a/inventory/inquiry/stock_movements.php b/inventory/inquiry/stock_movements.php index 52b2aa1f..1731e7bf 100644 --- a/inventory/inquiry/stock_movements.php +++ b/inventory/inquiry/stock_movements.php @@ -76,7 +76,6 @@ function get_summary(&$table) $sum['dec'] = $item_dec = get_qty_dec($_POST['stock_id']); $table->sum = $sum; - $Ajax->activate('summary'); } //----------------------------------------------------------------------------- @@ -157,12 +156,12 @@ function before_status($pager) .':'."", "align='right' colspan=5"); if($pager->sum['beg']>=0) { $r[] = array (number_format2($pager->sum['beg'], $pager->sum['dec']), - "align='right'"); + "align='right'"); $r[] = array(" "); } else { $r[] = array(" "); $r[] = array (number_format2($pager->sum['beg'], $pager->sum['dec']), - "align='right'"); + "align='right'"); } return $r; } @@ -174,12 +173,12 @@ function after_status($pager) .':'."", "align='right' colspan=5"); if($pager->sum['end']>=0) { $r[] = array (number_format2($pager->sum['end'], $pager->sum['dec']), - "align='right'"); - $r[] = array(" ", "colspan=2"); + "align='right'"); + $r[] = array(" "); } else { - $r[] = array(" ", "colspan=2"); + $r[] = array(" "); $r[] = array (number_format2($pager->sum['end'], $pager->sum['dec']), - "align='right'"); + "align='right'"); } return $r; } @@ -207,8 +206,8 @@ $cols = array( _("Reference"), _("Date") => array('date', 'ord'=>'desc'), _("Detail") => array('fun'=>'show_details' ), - _("Quantity In") => array('type'=>'amount', 'dec'=> $item_dec, 'insert'=>true,'fun'=>'qty_in' ), - _("Quantity Out") => array('type'=>'amount', 'dec'=> $item_dec,'insert'=>true,'fun'=>'qty_out' ), + _("Quantity In") => array('type'=>'qty', 'dec'=> $item_dec, 'insert'=>true,'fun'=>'qty_in' ), + _("Quantity Out") => array('type'=>'qty', 'dec'=> $item_dec,'insert'=>true,'fun'=>'qty_out' ), // _("Quantity On Hand") => array('insert'=>true,'type'=>'amount', 'fun'=>'show_qoh' ) ); @@ -217,8 +216,12 @@ $table->set_header('before_status'); $table->set_footer('after_status'); if (!$table->ready) // new sql query - update summary - get_summary(&$table); + get_summary($table); +if (get_post('ShowMoves')) { + $table->set_sql($sql); + $table->set_columns($cols); +} start_form(); display_db_pager($table); diff --git a/manufacturing/inquiry/where_used_inquiry.php b/manufacturing/inquiry/where_used_inquiry.php index 2c3f876a..bd9aa64d 100644 --- a/manufacturing/inquiry/where_used_inquiry.php +++ b/manufacturing/inquiry/where_used_inquiry.php @@ -52,6 +52,9 @@ $sql = "SELECT $table =& new_db_pager('usage_table', $sql, $cols); +if (get_post('_stock_id_update')) + $table->set_sql($sql); + display_db_pager($table); end_form(); diff --git a/manufacturing/search_work_orders.php b/manufacturing/search_work_orders.php index 70f29788..cff20c05 100644 --- a/manufacturing/search_work_orders.php +++ b/manufacturing/search_work_orders.php @@ -201,6 +201,10 @@ $cols = array( $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); +} start_form(); display_db_pager($table); diff --git a/purchasing/allocations/supplier_allocation_main.php b/purchasing/allocations/supplier_allocation_main.php index b7cfb1a5..b52f9ada 100644 --- a/purchasing/allocations/supplier_allocation_main.php +++ b/purchasing/allocations/supplier_allocation_main.php @@ -44,8 +44,7 @@ start_form(); echo "
"; check(_("Show Settled Items:"), 'ShowSettled', null, true); echo "

"; - -end_form(); + end_form(); set_global_supplier($_POST['supplier_id']); if (isset($_POST['supplier_id']) && ($_POST['supplier_id'] == reserved_words::get_all())) @@ -119,13 +118,11 @@ $table->set_marker('check_settled', _("Marked items are settled."), 'settledbg', if (get_post('_ShowSettled_update') || get_post('_supplier_id_update') ) { $table->set_sql($sql); $table->set_columns($cols); - $Ajax->activate('alloc_tbl'); } +start_form(); - start_form(); - display_db_pager($table); - end_form(); -end_page(); - +display_db_pager($table); +end_form(); +end_page(); ?> \ No newline at end of file diff --git a/purchasing/inquiry/po_search.php b/purchasing/inquiry/po_search.php index 3427e101..753fe2ff 100644 --- a/purchasing/inquiry/po_search.php +++ b/purchasing/inquiry/po_search.php @@ -62,9 +62,7 @@ stock_items_list_cells(_("Item:"), 'SelectStockFromList', null, true); submit_cells('SearchOrders', _("Search"),'',_('Select documents'), true); end_row(); end_table(); - end_form(); - //--------------------------------------------------------------------------------------------- function trans_view($trans) { @@ -182,6 +180,10 @@ if (get_post('StockLocation') != $all_items) { $table =& new_db_pager('orders_tbl', $sql, $cols); $table->set_marker('check_overdue', _("Marked orders have overdue items.")); +if (get_post('SearchOrders')) { + $table->set_sql($sql); + $table->set_columns($cols); +} start_form(); display_db_pager($table); diff --git a/purchasing/inquiry/po_search_completed.php b/purchasing/inquiry/po_search_completed.php index 0fddf251..56945c6b 100644 --- a/purchasing/inquiry/po_search_completed.php +++ b/purchasing/inquiry/po_search_completed.php @@ -60,9 +60,7 @@ stock_items_list_cells(_("for item:"), 'SelectStockFromList', null, true); submit_cells('SearchOrders', _("Search"),'',_('Select documents'), true); end_row(); end_table(); - end_form(); - //--------------------------------------------------------------------------------------------- if (isset($_POST['order_number'])) { @@ -155,6 +153,10 @@ if (get_post('StockLocation') != $all_items) { $table =& new_db_pager('orders_tbl', $sql, $cols); +if (get_post('SearchOrders')) { + $table->set_sql($sql); + $table->set_columns($cols); +} start_form(); display_db_pager($table); diff --git a/purchasing/inquiry/supplier_allocation_inquiry.php b/purchasing/inquiry/supplier_allocation_inquiry.php index b9f7a841..ee78a352 100644 --- a/purchasing/inquiry/supplier_allocation_inquiry.php +++ b/purchasing/inquiry/supplier_allocation_inquiry.php @@ -185,6 +185,10 @@ if ($_POST['supplier_id'] != reserved_words::get_all()) { $table =& new_db_pager('doc_tbl', $sql, $cols); $table->set_marker('check_overdue', _("Marked items are overdue.")); +if (get_post('RefreshInquiry')) { + $table->set_sql($sql); + $table->set_columns($cols); +} start_form(); display_db_pager($table); diff --git a/purchasing/inquiry/supplier_inquiry.php b/purchasing/inquiry/supplier_inquiry.php index d65e3b81..e2f237db 100644 --- a/purchasing/inquiry/supplier_inquiry.php +++ b/purchasing/inquiry/supplier_inquiry.php @@ -45,9 +45,7 @@ submit_cells('RefreshInquiry', _("Search"),'',_('Refresh Inquiry'), true); end_row(); end_table(); - end_form(); - set_global_supplier($_POST['supplier_id']); //------------------------------------------------------------------------------------------------ @@ -215,6 +213,10 @@ if ($_POST['supplier_id'] != reserved_words::get_all()) $table =& new_db_pager('trans_tbl', $sql, $cols); $table->set_marker('check_overdue', _("Marked items are overdue.")); +if (get_post('RefreshInquiry')) { + $table->set_sql($sql); + $table->set_columns($cols); +} start_form(); display_db_pager($table); diff --git a/sales/allocations/customer_allocation_main.php b/sales/allocations/customer_allocation_main.php index b0c3c6de..4ba875bd 100644 --- a/sales/allocations/customer_allocation_main.php +++ b/sales/allocations/customer_allocation_main.php @@ -38,8 +38,6 @@ start_form(); check(_("Show Settled Items:"), 'ShowSettled', null, true); echo "

"; -end_form(); - set_global_customer($_POST['customer_id']); if (isset($_POST['customer_id']) && ($_POST['customer_id'] == reserved_words::get_all())) @@ -116,12 +114,10 @@ $table->set_marker('check_settled', _("Marked items are settled."), 'settledbg', 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(); +display_db_pager($table); +end_form(); +end_page(); ?> \ No newline at end of file diff --git a/sales/inquiry/customer_allocation_inquiry.php b/sales/inquiry/customer_allocation_inquiry.php index 41067832..dde0a8a5 100644 --- a/sales/inquiry/customer_allocation_inquiry.php +++ b/sales/inquiry/customer_allocation_inquiry.php @@ -46,7 +46,6 @@ set_global_customer($_POST['customer_id']); end_row(); end_table(); end_form(); - //------------------------------------------------------------------------------------------------ function check_overdue($row) { @@ -214,6 +213,10 @@ if ($_POST['customer_id'] != reserved_words::get_all()) { $table =& new_db_pager('doc_tbl', $sql, $cols); $table->set_marker('check_overdue', _("Marked items are overdue.")); +if (get_post('RefreshInquiry')) { + $table->set_sql($sql); + $table->set_columns($cols); +} start_form(); display_db_pager($table); diff --git a/sales/inquiry/customer_inquiry.php b/sales/inquiry/customer_inquiry.php index 87ea76ec..52b82ef9 100644 --- a/sales/inquiry/customer_inquiry.php +++ b/sales/inquiry/customer_inquiry.php @@ -45,9 +45,7 @@ cust_allocations_list_cells(null, 'filterType', $_POST['filterType'], true); submit_cells('RefreshInquiry', _("Search"),'',_('Refresh Inquiry'), true); end_row(); end_table(); - end_form(); - set_global_customer($_POST['customer_id']); //------------------------------------------------------------------------------------------------ @@ -82,7 +80,7 @@ function display_customer_summary($customer_record) amount_cell($customer_record["Balance"]); end_row(); - end_table();; + end_table(); } //------------------------------------------------------------------------------------------------ @@ -280,9 +278,11 @@ if ($_POST['customer_id'] != reserved_words::get_all()) { $table =& new_db_pager('trans_tbl', $sql, $cols); $table->set_marker('check_overdue', _("Marked items are overdue.")); - +if (get_post('RefreshInquiry')) { + $table->set_sql($sql); + $table->set_columns($cols); +} start_form(); - display_db_pager($table); end_form(); diff --git a/sales/inquiry/sales_deliveries_view.php b/sales/inquiry/sales_deliveries_view.php index 794378b5..d55bc081 100644 --- a/sales/inquiry/sales_deliveries_view.php +++ b/sales/inquiry/sales_deliveries_view.php @@ -106,7 +106,7 @@ hidden('OutstandingOnly', $_POST['OutstandingOnly']); end_row(); end_table(); - +end_form(); //--------------------------------------------------------------------------------------------- if (isset($_POST['SelectStockFromList']) && ($_POST['SelectStockFromList'] != "") && @@ -246,6 +246,10 @@ if (isset($_SESSION['Batch'])) $table =& new_db_pager('deliveries_tbl', $sql, $cols); $table->set_marker('check_overdue', _("Marked items are overdue.")); +if (get_post('SearchOrders')) { + $table->set_sql($sql); + $table->set_columns($cols); +} start_form(); display_db_pager($table); diff --git a/sales/inquiry/sales_orders_view.php b/sales/inquiry/sales_orders_view.php index 5dde39a8..aba6a1cf 100644 --- a/sales/inquiry/sales_orders_view.php +++ b/sales/inquiry/sales_orders_view.php @@ -185,7 +185,6 @@ end_row(); end_table(1); end_form(); - //--------------------------------------------------------------------------------------------- // Orders inquiry table // @@ -289,6 +288,10 @@ if ($_POST['order_view_mode'] == 'OutstandingOnly') { $table =& new_db_pager('orders_tbl', $sql, $cols); $table->set_marker('check_overdue', _("Marked items are overdue.")); +if (get_post('SearchOrders')) { + $table->set_sql($sql); + $table->set_columns($cols); +} start_form(); display_db_pager($table); -- 2.30.2