X-Git-Url: https://delta.frontaccounting.com/gitweb/?a=blobdiff_plain;f=includes%2Fdb_pager.inc;h=819b4757f5c7e3381b749f9bc3d7073b8ea187ec;hb=2e181b13aa722a43e78b897404912d6b13a0a937;hp=a3eee7967c339dbf23b10e960bb42ef87a43fe82;hpb=a212015bc65db88ebe4c5a55baec0bf5e4e03b79;p=fa-stable.git diff --git a/includes/db_pager.inc b/includes/db_pager.inc index a3eee796..819b4757 100644 --- a/includes/db_pager.inc +++ b/includes/db_pager.inc @@ -1,4 +1,14 @@ . +***********************************************************************/ // // Controler part of database table pager with column sort. // To display actual html object call display_db_pager($name) inside @@ -16,6 +26,7 @@ class db_pager { var $marker_txt; var $marker_class; var $notice_class; + var $width; // table width (default '95%') var $header_fun; // additional row between title and body var $header_class; var $footer_fun; @@ -47,6 +58,8 @@ class db_pager { // $name is base name for pager controls function db_pager($sql, $name, $page_len=0) { + global $table_style; + $this->width = "95%"; if ($page_len == 0) $page_len = user_query_size(); $this->name = $name; $this->page_len = $page_len; @@ -250,10 +263,10 @@ class db_pager { } $sql = "$select FROM $from $where"; - if($group) $sql.= " GROUP BY $group"; + if ($group) $sql.= " GROUP BY $group"; $ord = array(); - foreach( $this->columns as $col) { + foreach ($this->columns as $col) { if (isset($col['ord'])) { if ( $col['ord'] != '' && isset($col['name'])) { $ord[] = $col['name'] .' '. $col['ord']; @@ -281,6 +294,8 @@ class db_pager { // function _init() { + global $go_debug; + if ($this->ready == false ) { $sql = $this->_sql_gen(true); $result = db_query($sql, 'Error reading record set'); @@ -288,7 +303,20 @@ class db_pager { return false; $row = db_fetch_row($result); $this->rec_count = $row[0]; - $this->max_page = ceil($this->rec_count/$this->page_len); + $this->max_page = $this->page_len ? + ceil($this->rec_count/$this->page_len) : 0; + + if ($go_debug) { // FIX - need column name parsing, but for now: + // check if field names are set explicite in col def + // for all initially ordered columns + foreach ($this->columns as $col) { + if (isset($col['ord']) && $col['ord'] != '' + && !isset($col['name'])) { + display_warning("Result field names must be set + for all intially ordered db_pager columns."); + } + } + } $this->set_page(1); $this->ready = true; }