X-Git-Url: https://delta.frontaccounting.com/gitweb/?a=blobdiff_plain;f=includes%2Fdb_pager.inc;h=c407675dedfb1f97142afe389a8c50cbd51b3740;hb=50c800e82b6cca17cd88717cf0bc0a187dc4e171;hp=f00cc9060ea20e4c4c4e7e5e1af5b7227e47e282;hpb=44d00255d78bd56e9071e1fce0f0f9713cd3c7b8;p=fa-stable.git diff --git a/includes/db_pager.inc b/includes/db_pager.inc index f00cc906..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,7 +297,7 @@ 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); if ($page == 'next' && !$this->next_page || @@ -306,7 +306,7 @@ class db_pager { if ($page == 'prev' && !$this->prev_page || $page == 'first' && !$this->first_page) set_focus($this->name.'_page_next'); - } elseif ($sort) { + } elseif ($sort != -1) { $this->sort_table($sort); } else $this->query(); @@ -330,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')