// array('select' => 'SUM(quantity)', 'from' => TB_PREF."stock_moves", 'group' => 'location')
//
// $name is base name for pager controls
// array('select' => 'SUM(quantity)', 'from' => TB_PREF."stock_moves", 'group' => 'location')
//
// $name is base name for pager controls
- function db_pager($sql, $name, $table = null, $page_len=0)
+ function __construct($sql, $name, $table = null, $page_len=0)
- // add result field names to column defs for
- // col value retrieve and sort purposes
- $cnt = min(db_num_fields($result), count($this->columns));
+ // add result field names to column defs for
+ // col value retrieve and sort purposes
+ $cnt = min(db_num_fields($result), count($this->columns));
for ($c = $i = 0; $c < $cnt; $c++) {
if (!(isset($this->columns[$c]['insert']) && $this->columns[$c]['insert'])) {
// if (!@($this->columns[$c]['type']=='skip'))
$this->columns[$c]['name']= db_field_name($result, $i);
if (!@($this->columns[$c]['type']=='insert'))
for ($c = $i = 0; $c < $cnt; $c++) {
if (!(isset($this->columns[$c]['insert']) && $this->columns[$c]['insert'])) {
// if (!@($this->columns[$c]['type']=='skip'))
$this->columns[$c]['name']= db_field_name($result, $i);
if (!@($this->columns[$c]['type']=='insert'))
- case 'next':
- $page = $this->curr_page+1; break;
- case 'prev':
- $page = $this->curr_page-1; break;
- case 'last':
- $page = $this->last_page; break;
- default:
- if (is_numeric($to)) {
- $page = $to; break;
- }
- case 'first':
- $page = 1; break;
+ case 'next':
+ $page = $this->curr_page+1; break;
+ case 'prev':
+ $page = $this->curr_page-1; break;
+ case 'last':
+ $page = $this->last_page; break;
+ default:
+ if (is_numeric($to)) {
+ $page = $to; break;
+ }
+ case 'first':
+ $page = 1; break;
- if ($page < 1)
- $page = 1;
- $max = $this->max_page;
- if ($page > $max)
- $page = $max;
- $this->curr_page = $page;
- $this->next_page = ($page < $max) ? $page+1 : null;
- $this->prev_page = ($page > 1) ? ($page-1) : null;
- $this->last_page = ($page < $max) ? $max : null;
- $this->first_page = ($page != 1) ? 1: null;
+ if ($page < 1)
+ $page = 1;
+ $max = $this->max_page;
+ if ($page > $max)
+ $page = $max;
+ $this->curr_page = $page;
+ $this->next_page = ($page < $max) ? $page+1 : null;
+ $this->prev_page = ($page > 1) ? ($page-1) : null;
+ $this->last_page = ($page < $max) ? $max : null;
+ $this->first_page = ($page != 1) ? 1: null;
if (count($ord)) {
$ord = array_map('db_escape_function', $ord);
$sql .= " ORDER BY " . implode(',', $ord);
if (count($ord)) {
$ord = array_map('db_escape_function', $ord);
$sql .= " ORDER BY " . implode(',', $ord);
// check if field names are set explicite in col def
// for all initially ordered columns
foreach ($this->columns as $col) {
// check if field names are set explicite in col def
// for all initially ordered columns
foreach ($this->columns as $col) {
-// return inactive_control_cell($row[$this->inactive_ctrl['key']],
-// $row['inactive'], $this->inactive_ctrl['table'],
-// $this->inactive_ctrl['key']);