diff --git a/interface/lib/classes/listform.inc.php b/interface/lib/classes/listform.inc.php index 68d89b3d2774e73f19084dcf7f2e5b6731685b56..cf8f6410f415b18acc94e713735c9719db4086f7 100644 --- a/interface/lib/classes/listform.inc.php +++ b/interface/lib/classes/listform.inc.php @@ -236,7 +236,13 @@ class listform { } return ( $sql_where != '' ) ? $sql_where = substr($sql_where,0,-3) : '1'; } - + + public function getPagingValue($key) { + if(!is_array($this->pagingValues)) return null; + if(!array_key_exists($key, $this->pagingValues)) return null; + return $this->pagingValues[$key]; + } + public function getPagingSQL($sql_where = '1') { global $app, $conf; @@ -281,6 +287,8 @@ class listform { $vars['max_pages'] = $pages + 1; $vars['records_gesamt'] = $record_count['anzahl']; $vars['page_params'] = (isset($this->listDef['page_params'])) ? $this->listDef['page_params'] : ''; + $vars['offset'] = $sql_von; + $vars['records_per_page'] = $records_per_page; //$vars['module'] = $_SESSION['s']['module']['name']; if($_SESSION['search'][$list_name]['page'] > 0) $vars['show_page_back'] = 1; diff --git a/interface/lib/classes/listform_actions.inc.php b/interface/lib/classes/listform_actions.inc.php index acb0b96d1a6ca3895ed5b94724b70f1ce2917196..70a6bde375bd4848d59b63aa7595507188f0ad16 100644 --- a/interface/lib/classes/listform_actions.inc.php +++ b/interface/lib/classes/listform_actions.inc.php @@ -126,7 +126,7 @@ class listform_actions { } // Getting Datasets from DB - $records = $app->db->queryAllRecords($this->getQueryString()); + $records = $app->db->queryAllRecords($this->getQueryString($php_sort)); $this->DataRowColor = "#FFFFFF"; $records_new = ''; @@ -147,6 +147,9 @@ class listform_actions { $this->sortKeys = array($order_by => $order_dir); uasort($records_new, array($this, '_sort')); } + if($php_sort) { + $records_new = array_slice($records_new, $app->listform->getPagingValue('offset'), $app->listform->getPagingValue('records_per_page')); + } $app->tpl->setLoop('records',$records_new); @@ -185,7 +188,7 @@ class listform_actions { return $rec; } - public function getQueryString() { + public function getQueryString($no_limit = false) { global $app; $sql_where = ''; @@ -231,7 +234,8 @@ class listform_actions { } $select = implode(', ', $table_selects); - $sql = 'SELECT '.$select.$extselect.' FROM '.$app->listform->listDef['table'].($app->listform->listDef['additional_tables'] != ''? ','.$app->listform->listDef['additional_tables'] : '')."$join WHERE $sql_where $order_by_sql $limit_sql"; + $sql = 'SELECT '.$select.$extselect.' FROM '.$app->listform->listDef['table'].($app->listform->listDef['additional_tables'] != ''? ','.$app->listform->listDef['additional_tables'] : '')."$join WHERE $sql_where $order_by_sql"; + if($no_limit == false) $sql .= " $limit_sql"; //echo $sql; return $sql; }