1: <?php
2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30:
31:
32: function build_change_table_form_archiv($table_infos_ar, $table_name)
33:
34:
35:
36: {
37: global $url;
38: $change_table_form = " <form method='get' action='$url' name='change_table_form'>\n";
39: $change_table_form .= " <select name='table_name' class='select_change_table' onchange=\"document.change_table_form.submit()\">\n";
40:
41: $count_temp = count($table_infos_ar);
42: for($i=0; $i<$count_temp; $i++){
43: $change_table_form .= " <option value='".htmlspecialchars($table_infos_ar[$i]['table_name'])."'";
44: if ($table_name == $table_infos_ar[$i]['table_name']){
45: $change_table_form .= " selected";
46: }
47: $change_table_form .= ">".$table_infos_ar[$i]['table_alias']."</option>\n";
48: }
49: $change_table_form .= " </select>\n";
50: $change_table_form .= " </form>\n";
51:
52: if ($count_temp == 1){
53: return "";
54: }
55: else{
56: return $change_table_form;
57: }
58:
59: }
60:
61: function build_results_table_archiv($fields_labels_ar, $table_name, $result, $action, $where_clause, $page, $order, $order_type, $table_infos_ar, $details)
62:
63:
64:
65:
66: {
67: global $submit_buttons_ar, $edit_target_window, $restore_icon, $details_icon, $word_wrap_col, $word_wrap_fix_width, $alias_prefix, $enable_row_highlighting, $prefix_internal_table, $db, $url, $lang;
68:
69: $function = "search";
70:
71: $unique_field_name = $db->get_primary_key($table_name);
72:
73:
74:
75:
76: $results_table = "";
77: $results_table .= "<table class='results'>\n";
78:
79:
80: $results_table .= "<tr>\n";
81:
82:
83: $results_table .= "<th class='results'> </th>\n";
84: $count_temp = count($fields_labels_ar);
85: for ($i=0; $i<$count_temp; $i++){
86: if ($fields_labels_ar[$i]["present_results_search_field"] == "1" || $fields_labels_ar[$i]["name_field"] == "timestamp" || $fields_labels_ar[$i]["name_field"] == "archive_type" || ($details == "1" && $fields_labels_ar[$i]["present_details_form_field"] == "1")) {
87: $label_to_display = $fields_labels_ar[$i]["label_" . $lang . "_field"];
88: if ($word_wrap_fix_width === 1){
89: $spaces_to_add = $word_wrap_col-strlen($label_to_display);
90: if ( $spaces_to_add > 0) {
91: for ($j=0; $j<$spaces_to_add; $j++) {
92: $label_to_display .= ' ';
93: }
94: }
95: }
96:
97: $results_table .= "<th class='results'>";
98: $field_is_current_order_by = 0;
99: if ($order != $fields_labels_ar[$i]["name_field"]){
100: $link_class="order_link";
101: $new_order_type = "ASC";
102: }
103: else{
104: $field_is_current_order_by = 1;
105: $link_class="order_link_selected";
106: if ( $order_type == "DESC") {
107: $new_order_type = "ASC";
108: }
109: else{
110: $new_order_type = "DESC";
111: }
112: }
113:
114: $results_table .= "<a class='".$link_class."' href='".$action."?table_name=". urlencode($table_name)."&function=search&where_clause=".urlencode($where_clause)."&page=$page&order=".urlencode($fields_labels_ar[$i]["name_field"])."&order_type=$new_order_type'>";
115:
116: if ($field_is_current_order_by === 1) {
117: if ($order_type === 'ASC') {
118: $results_table .= '<span class="arrow">↑</span> ';
119: }
120: else {
121: $results_table .= '<span class="arrow">↓</span> ';
122: }
123: }
124:
125: $results_table .= "$label_to_display</a></th>\n";
126: }
127: }
128: $results_table .= "</tr>\n";
129: if ($details == "1") {
130: $sql = build_select_part($fields_labels_ar, $table_name);
131: $where_clause_aktuell = str_replace("archive__", "", $where_clause);
132: $sql .= " WHERE $where_clause_aktuell";
133: display_sql($sql);
134:
135: $res_details = $db->send_query($sql);
136: while ($details_row = $db->db_fetch_assoc($res_details)){
137: $results_table .= "<tr class='tr_results_current'>\n";
138: $results_table .= "<td class='controls_current'></td>\n";
139: for ($i=0; $i<$count_temp; $i++){
140: if ($fields_labels_ar[$i]["name_field"] == "timestamp" || $fields_labels_ar[$i]["name_field"] == "archive_type" || $fields_labels_ar[$i]["present_results_search_field"] == "1" || $fields_labels_ar[$i]["present_details_form_field"] == "1") {
141: $results_table .= "<td>";
142:
143: $field_name_temp = $fields_labels_ar[$i]["name_field"];
144: $field_type = $fields_labels_ar[$i]["type_field"];
145: $field_content = $fields_labels_ar[$i]["content_field"];
146: $field_separator = $fields_labels_ar[$i]["separator_field"];
147:
148: $field_values_ar = array();
149:
150: $primary_key_field_field = $fields_labels_ar[$i]["primary_key_field_field"];
151: if (!empty($primary_key_field_field)){
152: $primary_key_table_field = $fields_labels_ar[$i]["primary_key_table_field"];
153: $primary_key_db_field = $fields_labels_ar[$i]["primary_key_db_field"];
154: $linked_fields_field = $fields_labels_ar[$i]["linked_fields_field"];
155: $alias_suffix_field = $fields_labels_ar[$i]["alias_suffix_field"];
156: $linked_fields_ar = explode($fields_labels_ar[$i]["separator_field"], $linked_fields_field);
157:
158:
159: $k = 0;
160: foreach ($table_infos_ar as $table_infos) {
161: $tables_names_ar[$k] = $table_infos['table_name'];
162: $k++;
163: }
164:
165:
166: if (in_array($primary_key_table_field, $tables_names_ar)) {
167: $linked_table_installed = 1;
168:
169: $fields_labels_linked_field_ar = build_fields_labels_array($prefix_internal_table.$primary_key_table_field, 1);
170: }
171: else {
172: $linked_table_installed = 0;
173: }
174: for ($j=0;$j<count($linked_fields_ar);$j++) {
175: $field_values_ar[$j] = $details_row[$primary_key_table_field.$alias_prefix.$linked_fields_ar[$j].$alias_prefix.$alias_suffix_field];
176: }
177: } elseif ($field_name_temp === "archive_type") {
178: $field_values_ar[0] = "";
179: } else {
180: $field_values_ar[0] = $details_row[$field_name_temp];
181: }
182: $count_temp_2 = count($field_values_ar);
183: for ($j=0; $j<$count_temp_2; $j++) {
184:
185: if ($primary_key_field_field != "" && $primary_key_field_field != NULL && $linked_table_installed === 1){
186: foreach ($fields_labels_linked_field_ar as $fields_labels_linked_field_ar_element){
187: if ($fields_labels_linked_field_ar_element['name_field'] === $linked_fields_ar[$j]) {
188: $linked_field_type = $fields_labels_linked_field_ar_element['type_field'];
189: $linked_field_content = $fields_labels_linked_field_ar_element['content_field'];
190: $linked_field_separator = $fields_labels_linked_field_ar_element['separator_field'];
191: }
192: }
193:
194: reset($fields_labels_linked_field_ar);
195: $field_to_display = get_field_correct_displaying($field_values_ar[$j], $linked_field_type, $linked_field_content, "results_table");
196: }
197: else {
198: $field_to_display = get_field_correct_displaying($field_values_ar[$j], $field_type, $field_content, "results_table");
199: }
200: if ($field_name_temp === "archive_type") {
201: $field_to_display = "<div class='center'><strong>" . _("Current record") . "</strong></div>";
202: } elseif (empty($field_to_display)) {
203: $field_to_display = " ";
204: }
205: $results_table .= $field_to_display." ";
206: }
207: $results_table = substr($results_table, 0, -6);
208: $results_table .= "</td>\n";
209: }
210: }
211: $results_table .= "</tr>\n";
212: }
213: }
214: $tr_results_class = 'tr_results_1';
215: $td_controls_class = 'controls_1';
216:
217:
218: while ($records_row = $db->db_fetch_assoc($result)){
219:
220: if ($details == "1" && strpos($records_row['archive_type'], "_delete") !== false) {
221: $td_controls_class = 'controls_delete';
222: $tr_results_class = 'tr_results_delete';
223: }
224: elseif ($tr_results_class === 'tr_results_1') {
225: $td_controls_class = 'controls_2';
226: $tr_results_class = 'tr_results_2';
227: }
228: else {
229: $td_controls_class = 'controls_1';
230: $tr_results_class = 'tr_results_1';
231: }
232:
233:
234: if (!empty($unique_field_name)){
235: $where_field = $unique_field_name;
236: $where_value = $records_row[$unique_field_name];
237: }
238: if (!empty($records_row['timestamp'])){
239: $timestamp = $records_row['timestamp'];
240: }
241:
242:
243:
244: if ($enable_row_highlighting === 1) {
245: $results_table .= "<tr class='$tr_results_class' onmouseover=\"if (this.className!='tr_highlighted_onclick'){this.className='tr_highlighted_onmouseover'}\" onmouseout=\"if (this.className!='tr_highlighted_onclick'){this.className='$tr_results_class'}\" onclick=\"if (this.className == 'tr_highlighted_onclick'){ this.className='$tr_results_class';}else{ this.className='tr_highlighted_onclick';}\">\n";
246: }
247: else {
248: $results_table .= "<tr class='$tr_results_class'>\n";
249: }
250:
251: $results_table .= "<td class='$td_controls_class'>";
252: if (!empty($unique_field_name)){
253:
254: if ($details == "1") {
255: $from_function = "details";
256: } else {
257: $from_function = "search";
258: }
259: $results_table .= "<a class='onlyscreen' onclick=\"if (!confirm('" . _("Restore record") . "?')){ return false;}\" href='$url?table_name=".urlencode($table_name)."&function=restore&where_field=".urlencode($where_field)."&where_value=".urlencode($where_value)."×tamp=".urlencode($timestamp)."&from_function=$from_function";
260: $results_table .= "'><img src='$restore_icon' alt='" . _("Restore record") . "' title='" . _("Restore record") . "'></a>";
261: if ($details != "1") {
262: $results_table .= "<a class='onlyscreen' target='_$edit_target_window' href='$url?table_name=".urlencode($table_name)."&details=1&where_field=".urlencode($where_field)."&where_value=".urlencode($where_value)."'><img src='$details_icon' alt='".$submit_buttons_ar["details"]."' title='" . _("Details from this record") . "'></a>";
263: }
264: }
265: $results_table .= "</td>\n";
266: for ($i=0; $i<$count_temp; $i++){
267: if ($fields_labels_ar[$i]["present_results_search_field"] == "1" || $fields_labels_ar[$i]["name_field"] == "timestamp" || $fields_labels_ar[$i]["name_field"] == "archive_type" || ($details == "1" && $fields_labels_ar[$i]["present_details_form_field"] == "1")){
268: $results_table .= "<td>";
269:
270: $field_name_temp = $fields_labels_ar[$i]["name_field"];
271: $field_type = $fields_labels_ar[$i]["type_field"];
272: $field_content = $fields_labels_ar[$i]["content_field"];
273: $field_separator = $fields_labels_ar[$i]["separator_field"];
274:
275: $field_values_ar = array();
276:
277: $primary_key_field_field = $fields_labels_ar[$i]["primary_key_field_field"];
278: if (!empty($primary_key_field_field)){
279: $primary_key_table_field = $fields_labels_ar[$i]["primary_key_table_field"];
280: $primary_key_db_field = $fields_labels_ar[$i]["primary_key_db_field"];
281: $linked_fields_field = $fields_labels_ar[$i]["linked_fields_field"];
282: $alias_suffix_field = $fields_labels_ar[$i]["alias_suffix_field"];
283: $linked_fields_ar = explode($fields_labels_ar[$i]["separator_field"], $linked_fields_field);
284:
285:
286: $k = 0;
287: foreach ($table_infos_ar as $table_infos) {
288: $tables_names_ar[$k] = $table_infos['table_name'];
289: $k++;
290: }
291:
292:
293: if (in_array($primary_key_table_field, $tables_names_ar)) {
294: $linked_table_installed = 1;
295:
296: $fields_labels_linked_field_ar = build_fields_labels_array($prefix_internal_table.$primary_key_table_field, 1);
297: }
298: else {
299: $linked_table_installed = 0;
300: }
301: for ($j=0;$j<count($linked_fields_ar);$j++) {
302: $field_values_ar[$j] = $records_row[$primary_key_table_field.$alias_prefix.$linked_fields_ar[$j].$alias_prefix.$alias_suffix_field];
303: }
304: } else {
305: $field_values_ar[0] = $records_row[$field_name_temp];
306: }
307: $count_temp_2 = count($field_values_ar);
308: for ($j=0; $j<$count_temp_2; $j++) {
309:
310: if ($primary_key_field_field != "" && $primary_key_field_field != NULL && $linked_table_installed === 1){
311: foreach ($fields_labels_linked_field_ar as $fields_labels_linked_field_ar_element){
312: if ($fields_labels_linked_field_ar_element['name_field'] === $linked_fields_ar[$j]) {
313: $linked_field_type = $fields_labels_linked_field_ar_element['type_field'];
314: $linked_field_content = $fields_labels_linked_field_ar_element['content_field'];
315: $linked_field_separator = $fields_labels_linked_field_ar_element['separator_field'];
316: }
317: }
318:
319: reset($fields_labels_linked_field_ar);
320: $field_to_display = get_field_correct_displaying($field_values_ar[$j], $linked_field_type, $linked_field_content, "results_table");
321: }
322: else {
323: $field_to_display = get_field_correct_displaying($field_values_ar[$j], $field_type, $field_content, "results_table");
324: }
325: if (empty($field_to_display)) {
326: $field_to_display = " ";
327: } elseif ($field_name_temp === "archive_type") {
328: $archive_type_ar = array (
329: "admin_delete" => _("Deleting records of a user by Administrator"),
330: "datadmin_update" => _("Updating the record by Data Maintenance"),
331: "datadmin_delete" => _("Deleting the record by Data Maintenance"),
332: "datadmin_multi_delete" => _("Deleting records by Data Maintenance"),
333: "express_update" => _("Update the record by Express-Tool"),
334: "BZH_restruct" => _("Restructuring of the symptoms from BZH")
335: );
336: if (substr($field_to_display, 0, 8) == "restore_") {
337: $time = substr($field_to_display, 8);
338: if (substr($time, 0, 10) !== '0000-00-00') {
339: $time = date("d.m.Y H:i", strtotime($time));
340: if (substr($time, 0, 10) !== '01.01.1970') {
341: $field_to_display = _("Replaced by version from") . " $time";
342: } else {
343: $field_to_display = _("Replaced by original version");
344: }
345: } else {
346: $field_to_display = _("Replaced by original version");
347: }
348: } else {
349: $field_to_display = $archive_type_ar[$field_to_display];
350: }
351: }
352: $results_table .= $field_to_display." ";
353: }
354: $results_table = substr($results_table, 0, -6);
355: $results_table .= "</td>\n";
356: }
357: }
358: $results_table .= "</tr>\n";
359: }
360: $results_table .= "</table>\n";
361:
362: return $results_table;
363:
364: }
365: