| | |
| | | var $pagingValues;
|
| | | var $searchChanged = 0;
|
| | | var $module;
|
| | | var $dateformat = 'd.m.Y';
|
| | |
|
| | | function loadListDef($file,$module = '') {
|
| | | global $app,$conf;
|
| | |
| | | include_once($file);
|
| | | $this->listDef = $liste;
|
| | | $this->module = $module;
|
| | | |
| | | // Fill datasources
|
| | | foreach($this->listDef["item"] as $key => $field) {
|
| | | if(is_array($field['datasource'])) {
|
| | | $this->listDef["item"][$key]["value"] = $this->getDatasourceData($field);
|
| | | }
|
| | | }
|
| | | |
| | | return true;
|
| | | }
|
| | | |
| | | /**
|
| | | * Get the key => value array of a form filed from a datasource definitiom
|
| | | *
|
| | | * @param field = array with field definition
|
| | | * @param record = Dataset as array
|
| | | * @return key => value array for the value field of a form
|
| | | */
|
| | |
|
| | | function getDatasourceData($field) {
|
| | | global $app;
|
| | |
|
| | | $values = array();
|
| | |
|
| | | if($field["datasource"]["type"] == 'SQL') {
|
| | |
|
| | | // Preparing SQL string. We will replace some
|
| | | // common placeholders
|
| | | $querystring = $field["datasource"]["querystring"];
|
| | | $querystring = str_replace("{USERID}",$_SESSION["s"]["user"]["userid"],$querystring);
|
| | | $querystring = str_replace("{GROUPID}",$_SESSION["s"]["user"]["default_group"],$querystring);
|
| | | $querystring = str_replace("{GROUPS}",$_SESSION["s"]["user"]["groups"],$querystring);
|
| | | $table_idx = $this->formDef['db_table_idx'];
|
| | | //$querystring = str_replace("{RECORDID}",$record[$table_idx],$querystring);
|
| | | $app->uses("tform");
|
| | | $querystring = str_replace("{AUTHSQL}",$app->tform->getAuthSQL('r'),$querystring);
|
| | |
|
| | | // Getting the records
|
| | | $tmp_records = $app->db->queryAllRecords($querystring);
|
| | | if($app->db->errorMessage != '') die($app->db->errorMessage);
|
| | | if(is_array($tmp_records)) {
|
| | | $key_field = $field["datasource"]["keyfield"];
|
| | | $value_field = $field["datasource"]["valuefield"];
|
| | | foreach($tmp_records as $tmp_rec) {
|
| | | $tmp_id = $tmp_rec[$key_field];
|
| | | $values[$tmp_id] = $tmp_rec[$value_field];
|
| | | }
|
| | | }
|
| | | }
|
| | |
|
| | | if($field["datasource"]["type"] == 'CUSTOM') {
|
| | | // Calls a custom class to validate this record
|
| | | if($field["datasource"]['class'] != '' and $field["datasource"]['function'] != '') {
|
| | | $datasource_class = $field["datasource"]['class'];
|
| | | $datasource_function = $field["datasource"]['function'];
|
| | | $app->uses($datasource_class);
|
| | | $record = array();
|
| | | $values = $app->$datasource_class->$datasource_function($field, $record);
|
| | | } else {
|
| | | $this->errorMessage .= "Custom datasource class or function is empty<br>\r\n";
|
| | | }
|
| | | }
|
| | |
|
| | | return $values;
|
| | |
|
| | | }
|
| | |
|
| | | function getSearchSQL($sql_where = "") {
|
| | |
| | |
|
| | | foreach($this->listDef["item"] as $i) {
|
| | | $field = $i["field"];
|
| | | if($_REQUEST[$search_prefix.$field] != '') $sql_where .= " $field ".$i["op"]." '".$i["prefix"].$_REQUEST[$search_prefix.$field].$i["suffix"]."' and";
|
| | | //if($_REQUEST[$search_prefix.$field] != '') $sql_where .= " $field ".$i["op"]." '".$i["prefix"].$_REQUEST[$search_prefix.$field].$i["suffix"]."' and";
|
| | | if($_SESSION["search"][$list_name][$search_prefix.$field] != '') $sql_where .= " $field ".$i["op"]." '".$i["prefix"].$_SESSION["search"][$list_name][$search_prefix.$field].$i["suffix"]."' and";
|
| | | }
|
| | |
|
| | | if($sql_where != '') {
|
| | |
| | |
|
| | | $sql_von = $_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"] / $records_per_page);
|
| | | $pages = intval(($record_count["anzahl"] - 1) / $records_per_page);
|
| | |
|
| | |
|
| | | $vars["list_file"] = $this->listDef["file"];
|
| | |
| | |
|
| | |
|
| | | if($_SESSION["search"][$list_name]["page"] > 0) $vars["show_page_back"] = 1;
|
| | | if($_SESSION["search"][$list_name]["page"] <= $seiten - 1) $vars["show_page_next"] = 1;
|
| | | if($_SESSION["search"][$list_name]["page"] <= $vars["pages"] - 1) $vars["show_page_next"] = 1;
|
| | |
|
| | | $this->pagingValues = $vars;
|
| | | $this->pagingHTML = $this->getPagingHTML($vars);
|
| | |
| | | }
|
| | |
|
| | | function getPagingHTML($vars) {
|
| | | global $app;
|
| | | $content = '<a href="'.$vars["list_file"].'?page=0'.$vars["page_params"].'"><img src="../themes/iprg/images/btn_left.png" border="0"></a> ';
|
| | | if($vars["show_page_back"] == 1) $content .= '<a href="'.$vars["list_file"].'?page='.$vars["last_page"].$vars["page_params"].'"><img src="../themes/iprg/images/btn_back.png" border="0"></a> ';
|
| | | $content .= ' '.$app->lng('Page').' '.$vars["next_page"].' '.$app->lng('of').' '.$vars["max_pages"].' ';
|
| | | if($vars["show_page_next"] == 1) $content .= '<a href="'.$vars["list_file"].'?page='.$vars["next_page"].$vars["page_params"].'"><img src="../themes/iprg/images/btn_next.png" border="0"></a> ';
|
| | | $content .= '<a href="'.$vars["list_file"].'?page='.$vars["pages"].$vars["page_params"].'"> <img src="../themes/iprg/images/btn_right.png" border="0"></a>';
|
| | |
|
| | | return $content;
|
| | | }
|
| | | |
| | | function getPagingHTMLasTXT($vars) {
|
| | | global $app;
|
| | | $content = '[<a href="'.$vars["list_file"].'?page=0'.$vars["page_params"].'">|<< </a>]';
|
| | | if($vars["show_page_back"] == 1) $content .= '[<< <a href="'.$vars["list_file"].'?page='.$vars["last_page"].$vars["page_params"].'">'.$app->lng('Back').'</a>] ';
|
| | |
| | | break;
|
| | |
|
| | | case 'DATE':
|
| | | if($val > 0) {
|
| | | if($record[$key] > 0) {
|
| | | $record[$key] = date($this->dateformat,$record[$key]);
|
| | | }
|
| | | } else {
|
| | | $record[$key] = '';
|
| | | }
|
| | | break;
|
| | |
|
| | | case 'INTEGER':
|
| | |
| | | default:
|
| | | $record[$key] = stripslashes($record[$key]);
|
| | | }
|
| | | |
| | | }
|
| | |
|
| | | }
|