1- <?php
2-
3- class plugin_listview extends plugin_base {
4-
5- var $ module ;
6- var $ form ;
7- var $ tab ;
8- var $ record_id ;
9- var $ formdef ;
10- var $ options ;
11-
12- function onShow () {
13-
14- global $ app ;
15-
16- $ app ->uses ('listform ' );
17- $ app ->listform ->loadListDef ($ this ->options ["listdef " ]);
18-
19- //$app->listform->SQLExtWhere = "type = 'alias'";
20-
21- $ listTpl = new tpl ;
22- $ listTpl ->newTemplate ('templates/ ' .$ app ->listform ->listDef ["name " ].'_list.htm ' );
23-
24- //die(print_r($app->tform_actions));
25-
26- // Changing some of the list values to reflect that the list is called within a tform page
27- $ app ->listform ->listDef ["file " ] = $ app ->tform ->formDef ["action " ];
28- // $app->listform->listDef["page_params"] = "&id=".$app->tform_actions->id."&next_tab=".$_SESSION["s"]["form"]["tab"];
29- $ app ->listform ->listDef ["page_params " ] = "&id= " .$ _REQUEST ["id " ]."&next_tab= " .$ _SESSION ["s " ]["form " ]["tab " ];
30-
31-
32- // Generate the SQL for searching
33- if ($ app ->listform ->listDef ["auth " ] != 'no ' ) {
34- if ($ _SESSION ["s " ]["user " ]["typ " ] == "admin " ) {
35- $ sql_where = "" ;
36- } else {
37- $ sql_where = $ app ->tform ->getAuthSQL ('r ' )." and " ;
38- }
39- }
40-
41- if ($ this ->options ["sqlextwhere " ] != '' ) {
42- $ sql_where .= " " .$ this ->options ["sqlextwhere " ]." and " ;
43- }
44-
45- $ sql_where = $ app ->listform ->getSearchSQL ($ sql_where );
46- $ listTpl ->setVar ($ app ->listform ->searchValues );
47-
48- // Generate SQL for paging
49- $ limit_sql = $ app ->listform ->getPagingSQL ($ sql_where );
50- $ listTpl ->setVar ("paging " ,$ app ->listform ->pagingHTML );
51-
52-
53-
54- // Get the data
55- $ records = $ app ->db ->queryAllRecords ("SELECT * FROM " .$ app ->listform ->listDef ["table " ]." WHERE $ sql_where $ limit_sql " );
56-
57- $ bgcolor = "#FFFFFF " ;
58- if (is_array ($ records )) {
59- $ idx_key = $ app ->listform ->listDef ["table_idx " ];
60- foreach ($ records as $ rec ) {
61-
62- $ rec = $ app ->listform ->decode ($ rec );
63-
64- // Change of color
65- $ bgcolor = ($ bgcolor == "#FFFFFF " )?"#EEEEEE " :"#FFFFFF " ;
66- $ rec ["bgcolor " ] = $ bgcolor ;
67-
68- // substitute value for select fields
69- foreach ($ app ->listform ->listDef ["item " ] as $ field ) {
70- $ key = $ field ["field " ];
71- if ($ field ['formtype ' ] == "SELECT " ) {
72- $ rec [$ key ] = $ field ['value ' ][$ rec [$ key ]];
73- }
74- }
75-
76- // The variable "id" contains always the index field
77- $ rec ["id " ] = $ rec [$ idx_key ];
78-
79- $ records_new [] = $ rec ;
80- }
81- }
82-
83- $ listTpl ->setLoop ('records ' ,$ records_new );
84-
85- // Loading language field
86- $ lng_file = "lib/lang/ " .$ _SESSION ["s " ]["language " ]."_ " .$ app ->listform ->listDef ['name ' ]."_list.lng " ;
87- include ($ lng_file );
88- $ listTpl ->setVar ($ wb );
89-
90- // Setting Returnto information in the session
91- $ list_name = $ app ->listform ->listDef ["name " ];
92- $ _SESSION ["s " ]["list " ][$ list_name ]["parent_id " ] = $ app ->tform_actions ->id ;
93- $ _SESSION ["s " ]["list " ][$ list_name ]["parent_name " ] = $ app ->tform ->formDef ["name " ];
94- $ _SESSION ["s " ]["list " ][$ list_name ]["parent_tab " ] = $ _SESSION ["s " ]["form " ]["tab " ];
95- $ _SESSION ["s " ]["list " ][$ list_name ]["parent_script " ] = $ app ->tform ->formDef ["action " ];
96- $ _SESSION ["s " ]["form " ]["return_to " ] = $ list_name ;
97-
98- return $ listTpl ->grab ();
99-
100- }
101- }
102-
1+ <?php
2+
3+ class plugin_listview extends plugin_base {
4+
5+ var $ module ;
6+ var $ form ;
7+ var $ tab ;
8+ var $ record_id ;
9+ var $ formdef ;
10+ var $ options ;
11+
12+ function onShow () {
13+
14+ global $ app ;
15+
16+ $ app ->uses ('listform ' );
17+ $ app ->listform ->loadListDef ($ this ->options ["listdef " ]);
18+
19+ //$app->listform->SQLExtWhere = "type = 'alias'";
20+
21+ $ listTpl = new tpl ;
22+ $ listTpl ->newTemplate ('templates/ ' .$ app ->listform ->listDef ["name " ].'_list.htm ' );
23+
24+ //die(print_r($app->tform_actions));
25+
26+ // Changing some of the list values to reflect that the list is called within a tform page
27+ $ app ->listform ->listDef ["file " ] = $ app ->tform ->formDef ["action " ];
28+ // $app->listform->listDef["page_params"] = "&id=".$app->tform_actions->id."&next_tab=".$_SESSION["s"]["form"]["tab"];
29+ $ app ->listform ->listDef ["page_params " ] = "&id= " .$ this ->form ->id ."&next_tab= " .$ _SESSION ["s " ]["form " ]["tab " ];
30+ $ listTpl ->setVar ('parent_id ' ,$ this ->form ->id );
31+
32+ // Generate the SQL for searching
33+ if ($ app ->listform ->listDef ["auth " ] != 'no ' ) {
34+ if ($ _SESSION ["s " ]["user " ]["typ " ] == "admin " ) {
35+ $ sql_where = "" ;
36+ } else {
37+ $ sql_where = $ app ->tform ->getAuthSQL ('r ' )." and " ;
38+ }
39+ }
40+
41+ if ($ this ->options ["sqlextwhere " ] != '' ) {
42+ $ sql_where .= " " .$ this ->options ["sqlextwhere " ]." and " ;
43+ }
44+
45+ $ sql_where = $ app ->listform ->getSearchSQL ($ sql_where );
46+ $ listTpl ->setVar ($ app ->listform ->searchValues );
47+
48+ // Generate SQL for paging
49+ $ limit_sql = $ app ->listform ->getPagingSQL ($ sql_where );
50+ $ listTpl ->setVar ("paging " ,$ app ->listform ->pagingHTML );
51+
52+
53+
54+ // Get the data
55+ $ records = $ app ->db ->queryAllRecords ("SELECT * FROM " .$ app ->listform ->listDef ["table " ]." WHERE $ sql_where $ limit_sql " );
56+
57+ $ bgcolor = "#FFFFFF " ;
58+ if (is_array ($ records )) {
59+ $ idx_key = $ app ->listform ->listDef ["table_idx " ];
60+ foreach ($ records as $ rec ) {
61+
62+ $ rec = $ app ->listform ->decode ($ rec );
63+
64+ // Change of color
65+ $ bgcolor = ($ bgcolor == "#FFFFFF " )?"#EEEEEE " :"#FFFFFF " ;
66+ $ rec ["bgcolor " ] = $ bgcolor ;
67+
68+ // substitute value for select fields
69+ foreach ($ app ->listform ->listDef ["item " ] as $ field ) {
70+ $ key = $ field ["field " ];
71+ if ($ field ['formtype ' ] == "SELECT " ) {
72+ $ rec [$ key ] = $ field ['value ' ][$ rec [$ key ]];
73+ }
74+ }
75+
76+ // The variable "id" contains always the index field
77+ $ rec ["id " ] = $ rec [$ idx_key ];
78+
79+ $ records_new [] = $ rec ;
80+ }
81+ }
82+
83+ $ listTpl ->setLoop ('records ' ,$ records_new );
84+
85+ // Loading language field
86+ $ lng_file = "lib/lang/ " .$ _SESSION ["s " ]["language " ]."_ " .$ app ->listform ->listDef ['name ' ]."_list.lng " ;
87+ include ($ lng_file );
88+ $ listTpl ->setVar ($ wb );
89+
90+ // Setting Returnto information in the session
91+ $ list_name = $ app ->listform ->listDef ["name " ];
92+ // $_SESSION["s"]["list"][$list_name]["parent_id"] = $app->tform_actions->id;
93+ $ _SESSION ["s " ]["list " ][$ list_name ]["parent_id " ] = $ this ->form ->id ;
94+ $ _SESSION ["s " ]["list " ][$ list_name ]["parent_name " ] = $ app ->tform ->formDef ["name " ];
95+ $ _SESSION ["s " ]["list " ][$ list_name ]["parent_tab " ] = $ _SESSION ["s " ]["form " ]["tab " ];
96+ $ _SESSION ["s " ]["list " ][$ list_name ]["parent_script " ] = $ app ->tform ->formDef ["action " ];
97+ $ _SESSION ["s " ]["form " ]["return_to " ] = $ list_name ;
98+ //die(print_r($_SESSION["s"]["list"][$list_name]));
99+
100+ return $ listTpl ->grab ();
101+
102+ }
103+ }
104+
103105?>
0 commit comments