$additional_headers .= "Content-Type: text/plain; charset=utf-8"; $subject = DB_NAME . ' - ' . $table_name . ' - ' . $normal_messages_ar['new_insert_executed']; $subject = $mailer->mail_header_escape($subject); mail($to_addresses, $subject, $insert_notice_email, $additional_headers); } // end if } // end if if ($insert_again_after_insert == 1) { //txt_out("<p>".$normal_messages_ar["insert_result"]); txt_out($normal_messages_ar["record_inserted"]); txt_out("<h3>" . $normal_messages_ar["insert_record"] . "</h3>"); $form_type = "insert"; $res_details = ""; // re-get the array containg label ant other information about the fields, could be changed in the insert (other choices......) $fields_labels_ar = build_fields_labels_array($table_internal_name, "1"); $show_insert_form_after_error = 0; $show_edit_form_after_error = 0; // display the form $form = build_form($table_name, $action, $fields_labels_ar, $form_type, $res_details, "", "", $show_insert_form_after_error, $show_edit_form_after_error); echo $form; } else { $unique_field_name = $db->get_primary_key($table_name); $location_url = $site_url . $dadabik_main_file . '?table_name=' . urlencode($table_name) . '&function=search&where_clause=&page=0&just_inserted=1'; if ($unique_field_name != '') { $location_url .= '&order=' . $unique_field_name . '&order_type=desc'; } // end if header('Location: ' . $location_url); } // end else
if (isset($_GET["execute_search"])) { $execute_search = $_GET["execute_search"]; } // end if // set to 1 after a delete with no authorization // delete case if (isset($_GET["just_delete_no_authorization"])) { $just_delete_no_authorization = $_GET["just_delete_no_authorization"]; } // end if // the timestamp if (isset($_GET["timestamp"])) { $timestamp = $_GET["timestamp"]; } // end if $fields_labels_ar = build_fields_labels_array($prefix_internal_table . $table_name, 1); if ($function == "restore") { // restore of a record from the archiv, after the restore we need to redirect to the show results or details mode if ($from_function == "details") { $call = "&details=1&where_field=" . urlencode($where_field) . "&where_value=" . urlencode($where_value); } else { $call = "&function=" . urlencode($from_function); } $location_url = $site_url . $url . '?table_name=' . urlencode($table_name) . $call; if (!empty($where_clause)) { $location_url .= "&where_clause=" . urlencode($where_clause); } $sql_1 = "SELECT COUNT(*) FROM `{$table_name}` WHERE `{$where_field}` = '{$where_value}'"; // test, if the value to restore exist still in the main database $db->send_query($sql_1); $value_exist = $db->db_fetch_row();
function build_results_table_archiv($fields_labels_ar, $table_name, $result, $action, $where_clause, $page, $order, $order_type, $table_infos_ar, $details) { 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; $function = "search"; $unique_field_name = $db->get_primary_key($table_name); // build the results HTML table /////////////////////////////// $results_table = ""; $results_table .= "<table class='results'>\n"; // build the table heading $results_table .= "<tr>\n"; $results_table .= "<th class='results'> </th>\n"; // skip the first column for edit, delete and details $count_temp = count($fields_labels_ar); for ($i = 0; $i < $count_temp; $i++) { 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") { // the user want to display the field in the basic search results page $label_to_display = $fields_labels_ar[$i]["label_" . $lang . "_field"]; if ($word_wrap_fix_width === 1) { $spaces_to_add = $word_wrap_col - strlen($label_to_display); if ($spaces_to_add > 0) { for ($j = 0; $j < $spaces_to_add; $j++) { $label_to_display .= ' '; } } } // end if $results_table .= "<th class='results'>"; $field_is_current_order_by = 0; if ($order != $fields_labels_ar[$i]["name_field"]) { // the results are not ordered by this field at the moment $link_class = "order_link"; $new_order_type = "ASC"; } else { $field_is_current_order_by = 1; $link_class = "order_link_selected"; if ($order_type == "DESC") { $new_order_type = "ASC"; } else { $new_order_type = "DESC"; } } // end elseif ($order != $fields_labels_ar[$i]["name_field"]) $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}'>"; if ($field_is_current_order_by === 1) { if ($order_type === 'ASC') { $results_table .= '<span class="arrow">↑</span> '; } else { $results_table .= '<span class="arrow">↓</span> '; } // end if } // end if $results_table .= "{$label_to_display}</a></th>\n"; // insert the linked name of the field in the <th> } // end if } // end for $results_table .= "</tr>\n"; if ($details == "1") { $sql = build_select_part($fields_labels_ar, $table_name); $where_clause_aktuell = str_replace("archive__", "", $where_clause); $sql .= " WHERE {$where_clause_aktuell}"; display_sql($sql); // execute the select query $res_details = $db->send_query($sql); while ($details_row = $db->db_fetch_assoc($res_details)) { $results_table .= "<tr class='tr_results_current'>\n"; $results_table .= "<td class='controls_current'></td>\n"; for ($i = 0; $i < $count_temp; $i++) { 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") { $results_table .= "<td>"; // start the cell $field_name_temp = $fields_labels_ar[$i]["name_field"]; $field_type = $fields_labels_ar[$i]["type_field"]; $field_content = $fields_labels_ar[$i]["content_field"]; $field_separator = $fields_labels_ar[$i]["separator_field"]; $field_values_ar = array(); // reset the array containing values to display, otherwise for each loop I have the previous values $primary_key_field_field = $fields_labels_ar[$i]["primary_key_field_field"]; if (!empty($primary_key_field_field)) { $primary_key_table_field = $fields_labels_ar[$i]["primary_key_table_field"]; $primary_key_db_field = $fields_labels_ar[$i]["primary_key_db_field"]; $linked_fields_field = $fields_labels_ar[$i]["linked_fields_field"]; $alias_suffix_field = $fields_labels_ar[$i]["alias_suffix_field"]; $linked_fields_ar = explode($fields_labels_ar[$i]["separator_field"], $linked_fields_field); // get the list of all the installed tables $k = 0; foreach ($table_infos_ar as $table_infos) { $tables_names_ar[$k] = $table_infos['table_name']; $k++; } // if the linked table is installed I can get type content and separator of the linked field if (in_array($primary_key_table_field, $tables_names_ar)) { $linked_table_installed = 1; $fields_labels_linked_field_ar = build_fields_labels_array($prefix_internal_table . $primary_key_table_field, 1); } else { $linked_table_installed = 0; } // end else for ($j = 0; $j < count($linked_fields_ar); $j++) { $field_values_ar[$j] = $details_row[$primary_key_table_field . $alias_prefix . $linked_fields_ar[$j] . $alias_prefix . $alias_suffix_field]; } // end for } elseif ($field_name_temp === "archive_type") { $field_values_ar[0] = ""; } else { $field_values_ar[0] = $details_row[$field_name_temp]; } // end else $count_temp_2 = count($field_values_ar); for ($j = 0; $j < $count_temp_2; $j++) { // if it's a linked field and the linked table is installed, get the correct $field_type $field_content $field_separator if ($primary_key_field_field != "" && $primary_key_field_field != NULL && $linked_table_installed === 1) { foreach ($fields_labels_linked_field_ar as $fields_labels_linked_field_ar_element) { if ($fields_labels_linked_field_ar_element['name_field'] === $linked_fields_ar[$j]) { $linked_field_type = $fields_labels_linked_field_ar_element['type_field']; $linked_field_content = $fields_labels_linked_field_ar_element['content_field']; $linked_field_separator = $fields_labels_linked_field_ar_element['separator_field']; } // end if } // end foreach reset($fields_labels_linked_field_ar); $field_to_display = get_field_correct_displaying($field_values_ar[$j], $linked_field_type, $linked_field_content, "results_table"); // get the correct display mode for the field } else { $field_to_display = get_field_correct_displaying($field_values_ar[$j], $field_type, $field_content, "results_table"); // get the correct display mode for the field } // end else if ($field_name_temp === "archive_type") { $field_to_display = "<div class='center'><strong>" . _("Current record") . "</strong></div>"; } elseif (empty($field_to_display)) { $field_to_display = " "; } $results_table .= $field_to_display . " "; // at the field value to the table } // end for $results_table = substr($results_table, 0, -6); // delete the last $results_table .= "</td>\n"; // end the cell } // end if } // end for $results_table .= "</tr>\n"; } // end while } $tr_results_class = 'tr_results_1'; $td_controls_class = 'controls_1'; // build the table body while ($records_row = $db->db_fetch_assoc($result)) { if ($details == "1" && strpos($records_row['archive_type'], "_delete") !== false) { $td_controls_class = 'controls_delete'; $tr_results_class = 'tr_results_delete'; } elseif ($tr_results_class === 'tr_results_1') { $td_controls_class = 'controls_2'; $tr_results_class = 'tr_results_2'; } else { $td_controls_class = 'controls_1'; $tr_results_class = 'tr_results_1'; } // end else // set where clause for details and update /////////////////////////////////////////// if (!empty($unique_field_name)) { // exists a unique number $where_field = $unique_field_name; $where_value = $records_row[$unique_field_name]; } // end if if (!empty($records_row['timestamp'])) { $timestamp = $records_row['timestamp']; } // end if /////////////////////////////////////////// // end build where clause for details and update if ($enable_row_highlighting === 1) { $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"; } else { $results_table .= "<tr class='{$tr_results_class}'>\n"; } // end else $results_table .= "<td class='{$td_controls_class}'>"; if (!empty($unique_field_name)) { // exists a unique number: restore, details make sense // display the restore icon if ($details == "1") { $from_function = "details"; } else { $from_function = "search"; } $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}"; $results_table .= "'><img src='{$restore_icon}' alt='" . _("Restore record") . "' title='" . _("Restore record") . "'></a>"; if ($details != "1") { // display the details icon $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>"; } } // end if $results_table .= "</td>\n"; for ($i = 0; $i < $count_temp; $i++) { 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") { // the user want to display the field in the search results page $results_table .= "<td>"; // start the cell $field_name_temp = $fields_labels_ar[$i]["name_field"]; $field_type = $fields_labels_ar[$i]["type_field"]; $field_content = $fields_labels_ar[$i]["content_field"]; $field_separator = $fields_labels_ar[$i]["separator_field"]; $field_values_ar = array(); // reset the array containing values to display, otherwise for each loop I have the previous values $primary_key_field_field = $fields_labels_ar[$i]["primary_key_field_field"]; if (!empty($primary_key_field_field)) { $primary_key_table_field = $fields_labels_ar[$i]["primary_key_table_field"]; $primary_key_db_field = $fields_labels_ar[$i]["primary_key_db_field"]; $linked_fields_field = $fields_labels_ar[$i]["linked_fields_field"]; $alias_suffix_field = $fields_labels_ar[$i]["alias_suffix_field"]; $linked_fields_ar = explode($fields_labels_ar[$i]["separator_field"], $linked_fields_field); // get the list of all the installed tables $k = 0; foreach ($table_infos_ar as $table_infos) { $tables_names_ar[$k] = $table_infos['table_name']; $k++; } // if the linked table is installed I can get type content and separator of the linked field if (in_array($primary_key_table_field, $tables_names_ar)) { $linked_table_installed = 1; $fields_labels_linked_field_ar = build_fields_labels_array($prefix_internal_table . $primary_key_table_field, 1); } else { $linked_table_installed = 0; } // end else for ($j = 0; $j < count($linked_fields_ar); $j++) { $field_values_ar[$j] = $records_row[$primary_key_table_field . $alias_prefix . $linked_fields_ar[$j] . $alias_prefix . $alias_suffix_field]; } // end for } else { $field_values_ar[0] = $records_row[$field_name_temp]; } // end else $count_temp_2 = count($field_values_ar); for ($j = 0; $j < $count_temp_2; $j++) { // if it's a linked field and the linked table is installed, get the correct $field_type $field_content $field_separator if ($primary_key_field_field != "" && $primary_key_field_field != NULL && $linked_table_installed === 1) { foreach ($fields_labels_linked_field_ar as $fields_labels_linked_field_ar_element) { if ($fields_labels_linked_field_ar_element['name_field'] === $linked_fields_ar[$j]) { $linked_field_type = $fields_labels_linked_field_ar_element['type_field']; $linked_field_content = $fields_labels_linked_field_ar_element['content_field']; $linked_field_separator = $fields_labels_linked_field_ar_element['separator_field']; } // end if } // end foreach reset($fields_labels_linked_field_ar); $field_to_display = get_field_correct_displaying($field_values_ar[$j], $linked_field_type, $linked_field_content, "results_table"); // get the correct display mode for the field } else { $field_to_display = get_field_correct_displaying($field_values_ar[$j], $field_type, $field_content, "results_table"); // get the correct display mode for the field } // end else if (empty($field_to_display)) { $field_to_display = " "; } elseif ($field_name_temp === "archive_type") { $archive_type_ar = array("admin_delete" => _("Deleting records of a user by Administrator"), "datadmin_update" => _("Updating the record by Data Maintenance"), "datadmin_delete" => _("Deleting the record by Data Maintenance"), "datadmin_multi_delete" => _("Deleting records by Data Maintenance"), "express_update" => _("Update the record by Express-Tool"), "BZH_restruct" => _("Restructuring of the symptoms from BZH")); if (substr($field_to_display, 0, 8) == "restore_") { $time = substr($field_to_display, 8); if (substr($time, 0, 10) !== '0000-00-00') { $time = date("d.m.Y H:i", strtotime($time)); if (substr($time, 0, 10) !== '01.01.1970') { $field_to_display = _("Replaced by version from") . " {$time}"; } else { $field_to_display = _("Replaced by original version"); } } else { $field_to_display = _("Replaced by original version"); } } else { $field_to_display = $archive_type_ar[$field_to_display]; } } $results_table .= $field_to_display . " "; // at the field value to the table } // end for $results_table = substr($results_table, 0, -6); // delete the last $results_table .= "</td>\n"; // end the cell } // end if } // end for $results_table .= "</tr>\n"; } // end while $results_table .= "</table>\n"; return $results_table; }
function build_details_table($fields_labels_ar, $res_details) { global $db, $alias_prefix, $prefix_internal_table, $lang; // build the table $details_table = ""; $details_table .= "<table>"; while ($details_row = $db->db_fetch_assoc($res_details)) { // should be just one $count_temp = count($fields_labels_ar); for ($i = 0; $i < $count_temp; $i++) { if ($fields_labels_ar[$i]["present_details_form_field"] == "1") { $field_name_temp = $fields_labels_ar[$i]["name_field"]; $field_values_ar = array(); // reset the array containing values to display, otherwise for each loop if I don't call build_linked_field_values_ar I have the previous values $primary_key_field_field = $fields_labels_ar[$i]["primary_key_field_field"]; if ($primary_key_field_field != "") { $primary_key_field_field = $fields_labels_ar[$i]["primary_key_field_field"]; $primary_key_table_field = $fields_labels_ar[$i]["primary_key_table_field"]; $primary_key_db_field = $fields_labels_ar[$i]["primary_key_db_field"]; $linked_fields_field = $fields_labels_ar[$i]["linked_fields_field"]; $linked_fields_ar = explode($fields_labels_ar[$i]["separator_field"], $linked_fields_field); $alias_suffix_field = $fields_labels_ar[$i]["alias_suffix_field"]; // get the list of all the installed tables $tables_names_ar = build_tables_names_array(0); // if the linked table is installed I can get type content and separator of the linked field if (in_array($primary_key_table_field, $tables_names_ar)) { $linked_table_installed = 1; $fields_labels_linked_field_ar = build_fields_labels_array($prefix_internal_table . $primary_key_table_field, "1"); } else { $linked_table_installed = 0; } // end else for ($j = 0; $j < count($linked_fields_ar); $j++) { ////*$field_values_ar[$j] = $details_row[$linked_fields_ar[$j].$alias_prefix.$alias_suffix_field]; $field_values_ar[$j] = $details_row[$primary_key_table_field . $alias_prefix . $linked_fields_ar[$j] . $alias_prefix . $alias_suffix_field]; } // end for } else { $field_values_ar[0] = $details_row[$field_name_temp]; } $count_temp_2 = count($field_values_ar); $details_table .= "<tr><td class='td_label_details'><b>" . $fields_labels_ar[$i]["label_" . $lang . "_field"] . "</b></td><td class='td_value_details'>"; for ($j = 0; $j < $count_temp_2; $j++) { // if it's a linked field and the linked table is installed, get the correct $field_type $field_content $field_separator if ($primary_key_field_field != "" && $primary_key_field_field != NULL && $linked_table_installed === 1) { foreach ($fields_labels_linked_field_ar as $fields_labels_linked_field_ar_element) { if ($fields_labels_linked_field_ar_element['name_field'] === $linked_fields_ar[$j]) { $linked_field_type = $fields_labels_linked_field_ar_element['type_field']; $linked_field_content = $fields_labels_linked_field_ar_element['content_field']; $linked_field_separator = $fields_labels_linked_field_ar_element['separator_field']; } // end if } // end foreach reset($fields_labels_linked_field_ar); $field_to_display = get_field_correct_displaying($field_values_ar[$j], $linked_field_type, $linked_field_content, "details_table"); // get the correct display mode for the field } else { $field_to_display = get_field_correct_displaying($field_values_ar[$j], $fields_labels_ar[$i]["type_field"], $fields_labels_ar[$i]["content_field"], "details_table"); // get the correct display mode for the field } // end else $details_table .= $field_to_display . " "; // at the field value to the table } $details_table = substr($details_table, 0, -6); // delete the last $details_table .= "</td></tr>"; } // end if } // end for } // end while $details_table .= "</table>"; return $details_table; }