$query = "UPDATE lcm_report\n\t\t\tSET col_src_type = '',\n\t\t\t\tcol_src_name = ''\n\t\t\tWHERE id_report = " . $rep; lcm_query($query); $ref_tag = "#col"; } if (_request('unselect_line')) { $query = "UPDATE lcm_report\n\t\t\tSET line_src_type = '',\n\t\t\t\tline_src_name = ''\n\t\t\tWHERE id_report = " . $rep; lcm_query($query); $ref_tag = "#line"; } if (_request('filecustom')) { if (include_custom_report_exists(_request('filecustom'))) { include_custom_report(_request('filecustom')); $obj = new CustomReportSpecs(); $do_update = false; $query = "UPDATE lcm_report SET "; if ($info = $obj->getReportLine()) { $query .= "line_src_type = '" . $info['type'] . "',\n\t\t\t\t\t\tline_src_name = '" . $info['name'] . "'"; $do_update = true; } if ($info = $obj->getReportCol()) { if ($do_update) { $query .= ", "; } $query .= " col_src_type = '" . $info['type'] . "'"; // Ignore if name not set, or name restricts the choice (ex: keyword that applies to 'case') if (!$info['name'] || substr($info['name'], 0, 4) == 'FOR:') { $query .= ", col_src_name = '' "; } else { $query .= ", col_src_name = '" . $info['name'] . "' "; } $do_update = true;
function show_report_field_edit($type, $rep_info) { $src_type = $rep_info[$type . '_src_type']; $src_name = $rep_info[$type . '_src_name']; if ($src_type == 'table' && $src_name && !preg_match('/^lcm_/', $src_name)) { $src_name = 'lcm_' . $src_name; } // Extract source type, if any if ($src_type && $src_name) { if ($src_type == 'keyword') { $kwg = get_kwg_from_name($src_name); echo '<p class="normal_text">' . _Ti('rep_info_source_' . $src_type) . " (" . _T('rep_info_table_lcm_' . $kwg['type']) . ") " . _T(remove_number_prefix($kwg['title'])); } else { echo "<p class='normal_text'>" . _Ti('rep_info_source_' . $src_type) . _T('rep_info_table_' . $src_name); } // Show list of fields for line/col, if any $my_id = $type == 'col' ? 'id_column' : 'id_line'; $my_fields = array(); $query = "SELECT " . $my_id . ", f.id_field, f.description \n\t\t\tFROM lcm_rep_" . $type . " as rl, lcm_fields as f\n\t\t\tWHERE id_report = " . $rep_info['id_report'] . "\n\t\t\tAND rl.id_field = f.id_field\n\t\t\tORDER BY col_order, " . $my_id . " ASC"; $result_fields = lcm_query($query); if (lcm_num_rows($result_fields)) { echo "</p>\n"; echo "<table border='0' class='tbl_usr_dtl' width='99%'>\n"; while ($field = lcm_fetch_array($result_fields)) { echo "<tr>\n"; echo "<td>" . _Th($field['description']) . "</td>\n"; echo "<td><a href='upd_rep_field.php?rep=" . $rep_info['id_report'] . "&" . "remove=" . $type . "&" . $my_id . "=" . $field[$my_id] . "' class='content_link'>" . "X" . "</a></td>\n"; // ACCESSIBILITY echo "</tr>\n"; array_push($my_fields, $field['id_field']); } echo "</table>\n"; } else { if (!$rep_info['filecustom']) { // Allow to change the source table echo ' <a href="upd_rep_field.php?rep=' . $rep_info['id_report'] . '&unselect_' . $type . '=1" class="content_link">' . "X" . '</a>'; // TRAD ACCESSIBILITY echo "</p>\n"; } } // Add field (if line_src_type == table) // TODO: add 'not in (...existing fields..) $query = "SELECT *\n\t\t\tFROM lcm_fields\n\t\t\tWHERE table_name = '" . $src_name . "'"; $result = lcm_query($query); if (lcm_num_rows($result)) { echo "\n<br />\n\n"; echo "<form action='upd_rep_field.php' name='frm_" . $type . "_additem' method='get'>\n"; echo "<input name='rep' value='" . $rep_info['id_report'] . "' type='hidden' />\n"; echo "<input name='add' value='" . $type . "' type='hidden' />\n"; echo "<table border='0' class='tbl_usr_dtl' width='99%'>\n"; echo "<tr>\n"; echo "<th class='heading'>" . _Ti('rep_input_item_add') . "</th>\n"; echo "<td>\n"; echo "<select name='id_field' class='sel_frm'>"; echo "<option value=''>...</option>\n"; while ($row = lcm_fetch_array($result)) { echo "<option value='" . $row['id_field'] . "'>" . _Th($row['description']) . "</option>\n"; } echo "</select>\n"; echo "<button class='simple_form_btn' name='validate_" . $type . "_additem'>" . _T('button_validate') . "</button>\n"; echo "</td>\n"; echo "</tr>\n"; echo "</table>\n"; echo "</form>\n"; } } else { if (!$src_type || $src_type != 'keyword') { echo "<form action='upd_rep_field.php' name='frm_" . $type . "_source' method='post'>\n"; echo "<input name='rep' value='" . $rep_info['id_report'] . "' type='hidden' />\n"; echo '<p class="normal_text">' . f_err_star('rep_' . $type) . _Ti('rep_info_source_table'); echo "<input name='select_" . $type . "_type' value='table' type='hidden' />\n"; echo "<select name='select_" . $type . "_name' class='sel_frm'>\n\t\t\t\t<option value='author'>" . _T('rep_info_table_lcm_author') . "</option>\n\t\t\t\t<option value='case'>" . _T('rep_info_table_lcm_case') . "</option>\n\t\t\t\t<option value='stage'>" . _T('rep_info_table_lcm_stage') . "</option>\n\t\t\t\t<option value='client'>" . _T('rep_info_table_lcm_client') . "</option>\n\t\t\t\t<option value='followup'>" . _T('rep_info_table_lcm_followup') . "</option>\n\t\t\t\t</select>\n"; echo "<button class='simple_form_btn' name='validate_" . $type . "_source'>" . _T('button_validate') . "</button>\n"; echo "</p>\n"; echo "</form>\n"; } if (!$src_type) { echo '<p class="normal_text">' . _T('info_or') . "</p>\n"; } if (!$src_type || $src_type != 'table') { echo "<form action='upd_rep_field.php' name='frm_" . $type . "_source' method='post'>\n"; echo "<input name='rep' value='" . $rep_info['id_report'] . "' type='hidden' />\n"; echo "<p class='normal_text'>" . _Ti('rep_info_source_keyword'); echo "<input name='select_" . $type . "_type' value='keyword' type='hidden' />\n"; // Restrict list of keywords if custom report if ($rep_info['filecustom']) { include_custom_report($rep_info['filecustom']); $obj = new CustomReportSpecs(); $info = $type == 'line' ? $obj->getReportLine() : $obj->getReportCol(); if (substr($info['name'], 0, 4) == 'FOR:') { $choices = split(':', $info['name']); $all_kwgs = get_kwg_all($choices[1], true); } else { lcm_panic("Error in custom report specifications."); } } else { $all_kwgs = get_kwg_all('', true); } echo "<select name='select_" . $type . "_name' class='sel_frm'>\n"; echo "<option value=''>...</option>\n"; foreach ($all_kwgs as $kwg) { echo "<option value='" . $kwg['name'] . "'>" . _T('rep_info_table_lcm_' . $kwg['type']) . " - " . _T(remove_number_prefix($kwg['title'])) . "</option>\n"; } echo "</select>\n"; echo "<button class='simple_form_btn' name='validate_" . $type . "_source_kw'>" . _T('button_validate') . "</button>\n"; echo "</p>\n"; echo "</form>\n"; } } }