| | |
| | | |
| | | public function getSearchSQL($sql_where = '') |
| | | { |
| | | global $db; |
| | | global $app, $db; |
| | | |
| | | //* Get config variable |
| | | $list_name = $this->listDef['name']; |
| | |
| | | } |
| | | |
| | | //* Store field in session |
| | | if(isset($_REQUEST[$search_prefix.$field])){ |
| | | if(isset($_REQUEST[$search_prefix.$field]) && !stristr($_REQUEST[$search_prefix.$field],"'")){ |
| | | $_SESSION['search'][$list_name][$search_prefix.$field] = $_REQUEST[$search_prefix.$field]; |
| | | } |
| | | if(preg_match("/['\\\\]/", $_SESSION['search'][$list_name][$search_prefix.$field])) $_SESSION['search'][$list_name][$search_prefix.$field] = ''; |
| | | } |
| | | |
| | | if(isset($i['formtype']) && $i['formtype'] == 'SELECT'){ |
| | | if(is_array($i['value'])) { |
| | |
| | | $field = $i['field']; |
| | | // if($_REQUEST[$search_prefix.$field] != '') $sql_where .= " $field ".$i["op"]." '".$i["prefix"].$_REQUEST[$search_prefix.$field].$i["suffix"]."' and"; |
| | | if(isset($_SESSION['search'][$list_name][$search_prefix.$field]) && $_SESSION['search'][$list_name][$search_prefix.$field] != ''){ |
| | | $sql_where .= " $field ".$i['op']." '".$i['prefix'].$_SESSION['search'][$list_name][$search_prefix.$field].$i['suffix']."' and"; |
| | | $sql_where .= " $field ".$i['op']." '".$app->db->quote($i['prefix'].$_SESSION['search'][$list_name][$search_prefix.$field].$i['suffix'])."' and"; |
| | | } |
| | | } |
| | | } |
| | |
| | | public function getPagingSQL($sql_where = '1') |
| | | { |
| | | global $app, $conf; |
| | | |
| | | //* Add Global Limit from selectbox |
| | | if(!empty($_POST['search_limit']) AND $app->functions->intval($_POST['search_limit'])){ |
| | | $_SESSION['search']['limit'] = $app->functions->intval($_POST['search_limit']); |
| | | } |
| | | |
| | | //* Get Config variables |
| | | $list_name = $this->listDef['name']; |
| | | $search_prefix = $this->listDef['search_prefix']; |
| | | $records_per_page = $this->listDef['records_per_page']; |
| | | $records_per_page = (empty($_SESSION['search']['limit']) ? $app->functions->intval($this->listDef['records_per_page']) : $app->functions->intval($_SESSION['search']['limit'])) ; |
| | | $table = $this->listDef['table']; |
| | | |
| | | //* set PAGE to zero, if in session not set |
| | |
| | | } |
| | | |
| | | //* set PAGE to worth request variable "PAGE" - ? setze page auf wert der request variablen "page" |
| | | if(isset($_REQUEST["page"])) $_SESSION["search"][$list_name]["page"] = $_REQUEST["page"]; |
| | | if(isset($_REQUEST["page"])) $_SESSION["search"][$list_name]["page"] = $app->functions->intval($_REQUEST["page"]); |
| | | |
| | | //* PAGE to 0 set, if look for themselves ? page auf 0 setzen, wenn suche sich ge�ndert hat. |
| | | if($this->searchChanged == 1) $_SESSION['search'][$list_name]['page'] = 0; |
| | | |
| | | $sql_von = $_SESSION['search'][$list_name]['page'] * $records_per_page; |
| | | $sql_von = $app->functions->intval($_SESSION['search'][$list_name]['page'] * $records_per_page); |
| | | $record_count = $app->db->queryOneRecord("SELECT count(*) AS anzahl FROM $table WHERE $sql_where"); |
| | | $pages = intval(($record_count['anzahl'] - 1) / $records_per_page); |
| | | $pages = $app->functions->intval(($record_count['anzahl'] - 1) / $records_per_page); |
| | | |
| | | |
| | | $vars['list_file'] = $_SESSION['s']['module']['name'].'/'.$this->listDef['file']; |
| | |
| | | //* Show Back |
| | | if(isset($vars['show_page_back']) && $vars['show_page_back'] == 1){ |
| | | $content .= '<a href="'."javascript:loadContent('".$vars['list_file'].'?page='.$vars['last_page'].$vars['page_params']."');".'">' |
| | | .'<img src="themes/'.$_SESSION['s']['theme'].'/icons/x16/arrow_180.png"></a> '; |
| | | .'<img src="themes/'.$_SESSION['s']['theme'].'/icons/x16/arrow_180.png"></a> '; |
| | | } |
| | | $content .= ' '.$this->lng('page_txt').' '.$vars['next_page'].' '.$this->lng('page_of_txt').' '.$vars['max_pages'].' '; |
| | | $content .= ' '.$this->lng('page_txt').' '.$vars['next_page'].' '.$this->lng('page_of_txt').' '.$vars['max_pages'].' '; |
| | | //* Show Next |
| | | if(isset($vars['show_page_next']) && $vars['show_page_next'] == 1){ |
| | | $content .= '<a href="'."javascript:loadContent('".$vars['list_file'].'?page='.$vars['next_page'].$vars['page_params']."');".'">' |
| | |
| | | if(is_array($record) && count($record) > 0 && is_array($this->listDef['item'])) { |
| | | foreach($this->listDef['item'] as $field){ |
| | | $key = $field['field']; |
| | | //* Apply filter to record value. |
| | | if(isset($field['filters']) && is_array($field['filters'])) { |
| | | $app->uses('tform'); |
| | | $record[$key] = $app->tform->filterField($key, (isset($record[$key]))?$record[$key]:'', $field['filters'], 'SHOW'); |
| | | } |
| | | if(isset($record[$key])) { |
| | | switch ($field['datatype']){ |
| | | case 'VARCHAR': |
| | |
| | | case 'DATETSTAMP': |
| | | if ($record[$key] > 0) { |
| | | // is value int? |
| | | if (preg_match("/^[0-9]+[.]?[0-9]*$/", $record[$key], $p)) { |
| | | if (preg_match("/^[0-9]+[\.]?[0-9]*$/", $record[$key], $p)) { |
| | | $record[$key] = date($this->lng('conf_format_dateshort'), $record[$key]); |
| | | } else { |
| | | $record[$key] = date($this->lng('conf_format_dateshort'), strtotime($record[$key])); |
| | |
| | | case 'DATE': |
| | | if ($record[$key] > 0) { |
| | | // is value int? |
| | | if (preg_match("/^[0-9]+[.]?[0-9]*$/", $record[$key], $p)) { |
| | | if (preg_match("/^[0-9]+[\.]?[0-9]*$/", $record[$key], $p)) { |
| | | $record[$key] = date($this->lng('conf_format_dateshort'), $record[$key]); |
| | | } else { |
| | | $record[$key] = date($this->lng('conf_format_dateshort'), strtotime($record[$key])); |
| | |
| | | case 'DATETIME': |
| | | if ($record[$key] > 0) { |
| | | // is value int? |
| | | if (preg_match("/^[0-9]+[.]?[0-9]*$/", $record[$key], $p)) { |
| | | if (preg_match("/^[0-9]+[\.]?[0-9]*$/", $record[$key], $p)) { |
| | | $record[$key] = date($this->lng('conf_format_datetime'), $record[$key]); |
| | | } else { |
| | | $record[$key] = date($this->lng('conf_format_datetime'), strtotime($record[$key])); |
| | |
| | | break; |
| | | |
| | | case 'INTEGER': |
| | | $record[$key] = intval($record[$key]); |
| | | $record[$key] = $app->functions->intval($record[$key]); |
| | | break; |
| | | |
| | | case 'DOUBLE': |
| | |
| | | break; |
| | | |
| | | case 'INTEGER': |
| | | $record[$key] = intval($record[$key]); |
| | | $record[$key] = $app->functions->intval($record[$key]); |
| | | break; |
| | | |
| | | case 'DOUBLE': |
| | |
| | | |
| | | } |
| | | |
| | | ?> |
| | | ?> |