function setupReportLines() { $this->addComment("setupReportLines() called."); $q = "SELECT *\n\t\t\t\tFROM lcm_rep_line as l, lcm_fields as f\n\t\t\t\tWHERE id_report = " . $this->getId() . "\n\t\t\t\tAND l.id_field = f.id_field\n\t\t\t\tORDER BY col_order, id_line ASC"; $result = lcm_query($q); while ($row = lcm_fetch_array($result)) { $my_line_table = $row['table_name']; $this->addLine(prefix_field($row['table_name'], $row['field_name'])); $this->addHeader(_Th($row['description']), $row['filter'], $row['enum_type'], '', $row['field_name']); if ($row['field_name'] == 'count(*)') { $this->setOption('do_grouping', 'yes'); } // $do_grouping = true; } if (count($this->getLines())) { return; } // // No fields were specified: show them all (avoids errors) // if ($this->rep_info['line_src_type'] == 'table') { $q = "SELECT * \n\t\t\t\t\tFROM lcm_fields \n\t\t\t\t\tWHERE table_name = 'lcm_" . $this->rep_info['line_src_name'] . "'\n\t\t\t\t\t AND field_name != 'count(*)'"; $result = lcm_query($q); while ($row = lcm_fetch_array($result)) { $this->addLine(prefix_field($row['table_name'], $row['field_name'])); $this->addHeader(_Th($row['description']), $row['filter'], $row['enum_type'], '', $row['field_name']); } } elseif ($this->rep_info['line_src_type'] == 'keyword') { $kwg = get_kwg_from_name($this->rep_info['line_src_name']); $this->addLine("k.title as 'TRAD'"); $this->addHeader(_Th(remove_number_prefix($kwg['title'])), $kwg['filter'], $kwg['enum_type'], '', 'k.id_keyword'); // XXX not sure about id_keyword } }
function apply_filter($f) { $ret = ''; $filter_conv = array("neq" => "!=", "eq" => "=", "lt" => "<", "le" => "<=", "gt" => ">", "ge" => ">="); if (!$f['type']) { return ''; } if ($f['type'] == 'date_in') { $dates = array(); if ($f['value']) { $dates = explode(";", $f['value']); } else { $dates[0] = get_datetime_from_array($_REQUEST, 'filter_val' . $f['id_filter'] . '_start', 'start'); $dates[1] = get_datetime_from_array($_REQUEST, 'filter_val' . $f['id_filter'] . '_end', 'end'); } $ret .= "(DATE_FORMAT(" . prefix_field($f['table_name'], $f['field_name']) . ", '%Y-%m-%d') " . " >= DATE_FORMAT('" . $dates[0] . "', '%Y-%m-%d')" . " AND DATE_FORMAT(" . prefix_field($f['table_name'], $f['field_name']) . ", '%Y-%m-%d') " . " <= DATE_FORMAT('" . $dates[1] . "', '%Y-%m-%d')) "; } else { $foo = explode("_", $f['type']); // ex: date_eq $filter_type = $foo[0]; // date $filter_op = $foo[1]; // eq if (!$f['value']) { if (isset($_REQUEST['filter_val' . $f['id_filter']])) { $f['value'] = $_REQUEST['filter_val' . $f['id_filter']]; } } // FIELD OPERATOR 'VALUE' if ($filter_conv[$filter_op]) { switch ($filter_type) { case 'date': $ret .= "DATE_FORMAT(" . prefix_field($f['table_name'], $f['field_name']) . ", '%Y-%m-%d')" . " " . $filter_conv[$filter_op] . " " . "DATE_FORMAT('" . get_datetime_from_array($_REQUEST, 'filter_val' . $f['id_filter']) . "', '%Y-%m-%d') "; break; case 'text': $ret .= $f['field_name'] . " " . $filter_conv[$filter_op] . " " . "'" . $f['value'] . "' "; break; default: // number if ($f['description'] == 'time_input_length') { $f['value'] = " " . $f['value'] . " * 3600 "; } $ret .= $f['field_name'] . " " . $filter_conv[$filter_op] . " " . $f['value'] . " "; } } else { lcm_log("no filter_conv for {$filter_op} ?"); return ''; } } return $ret; }