The reference for deposits and payments didn't show up in Tax Report
[fa-stable.git] / includes / db_pager.inc
index c34a855fa9234596320b603264d7057397f708f3..819b4757f5c7e3381b749f9bc3d7073b8ea187ec 100644 (file)
@@ -1,4 +1,14 @@
 <?php
+/**********************************************************************
+    Copyright (C) FrontAccounting, LLC.
+       Released under the terms of the GNU General Public License, GPL, 
+       as published by the Free Software Foundation, either version 3 
+       of the License, or (at your option) any later version.
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  
+    See the License here <http://www.gnu.org/licenses/gpl-3.0.html>.
+***********************************************************************/
 //
 //     Controler part of database table pager with column sort.
 //     To display actual html object call display_db_pager($name) inside
@@ -253,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'];
@@ -284,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');
@@ -291,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;
            }