X-Git-Url: https://delta.frontaccounting.com/gitweb/?a=blobdiff_plain;f=includes%2Fdb_pager.inc;h=c407675dedfb1f97142afe389a8c50cbd51b3740;hb=425942b6c30c1722da6d7e5bf99462e07249bc45;hp=ce739535acad64f41e7af8c0f4aa5db418429929;hpb=ffb0ae97be5c30eeee98ad9aac45cf5077b515c7;p=fa-stable.git diff --git a/includes/db_pager.inc b/includes/db_pager.inc index ce739535..c407675d 100644 --- a/includes/db_pager.inc +++ b/includes/db_pager.inc @@ -112,7 +112,7 @@ class db_pager { // Change sort column direction // in order asc->desc->none->asc // - function sort_table($col=null) + function sort_table($col) { $ord = $this->columns[$col]['ord']; $ord = ($ord == '') ? 'asc' : (($ord == 'asc') ? 'desc' : ''); @@ -145,7 +145,7 @@ class db_pager { // add result field names to column defs for // col value retrieve and sort purposes for ($c = $i = 0; $c < count($this->columns); $c++) { - if ($this->columns[$c]['type'] != 'insert') + if (!(isset($this->columns[$c]['insert']) && $this->columns[$c]['insert'])) $this->columns[$c]['name']= mysql_field_name($result, $i++); } @@ -196,7 +196,7 @@ class db_pager { $flds = array($flds); } foreach ($flds as $colnum=>$coldef) { - if (!is_numeric($colnum)) { // 'colname'=>params + if (is_string($colnum)) { // 'colname'=>params $h = $colnum; $c = $coldef; } else { // n=>params @@ -207,9 +207,8 @@ class db_pager { $h = $coldef; $c = 'text'; } - $c = ''; } - if (!is_array($c)) // params is simple column type + if (is_string($c)) // params is simple column type $c = array('type'=>$c); if (!isset($c['type'])) @@ -249,7 +248,8 @@ class db_pager { return "SELECT COUNT($group) FROM $from $where"; } - $sql = "$select FROM $from $where GROUP BY $group"; + $sql = "$select FROM $from $where"; + if($group) $sql.= " GROUP BY $group"; $ord = array(); foreach( $this->columns as $col) { @@ -297,10 +297,16 @@ class db_pager { global $Ajax; $page = find_submit($this->name.'_page_', false); - $sort = find_submit($this->name.'_sort_', false); + $sort = find_submit($this->name.'_sort_', true); if ($page) { $this->change_page($page); - } elseif ($sort) { + if ($page == 'next' && !$this->next_page || + $page == 'last' && !$this->last_page) + set_focus($this->name.'_page_prev'); + if ($page == 'prev' && !$this->prev_page || + $page == 'first' && !$this->first_page) + set_focus($this->name.'_page_next'); + } elseif ($sort != -1) { $this->sort_table($sort); } else $this->query(); @@ -324,16 +330,15 @@ class db_pager { // $sql - base sql for data inquiry. Order of fields implies // pager columns order. // $coldef - array of column definitions. Example definitions -// Text column with title 'User name': +// Column with title 'User name' and default text format: // 'User name' // Skipped field from sql query. Data for the field is not displayed: // 'dummy' => 'skip' -// Column without title, formated with function func(). Field value -// is passed as parameter: -// array('type'=>'spec', 'fun'=>'func') -// Inserted column with title 'Some', formated with function rowfun(). Row -// values are passed as parameter array: -// 'Some' => array('type'=>'insert', 'fun'=>'rowfun') +// Column without title, data retrieved form row data with function func(): +// array('fun'=>'func') +// Inserted column with title 'Some', formated with function rowfun(). +// formated as date: +// 'Some' => array('type'=>'date, 'insert'=>true, 'fun'=>'rowfun') // Column with name 'Another', formatted as date, // sortable with ascending start order (available orders: asc,desc, ''). // 'Another' => array('type'=>'date', 'ord'=>'asc')