コード例 #1
0
 function each_line($val)
 {
     reportico_report::each_line($val);
     // Set the values for the fields in the record
     $record = array();
     foreach ($this->query->display_order_set["column"] as $col) {
         $qn = get_query_column($col->query_name, $this->columns);
         $this->results[$qn->query_name][] = $qn->column_value;
         $ct = count($this->results[$qn->query_name]);
     }
 }
コード例 #2
0
 function format_group_header(&$col, $custom)
 {
     if ($custom) {
         return;
     }
     $this->text .= '<TR class="swRepGrpHdrRow">';
     $this->text .= '<TD class="swRepGrpHdrLbl" ' . $this->get_style_tags($this->query->output_group_header_label_styles) . '>';
     $qn = get_query_column($col->query_name, $this->query->columns);
     $padstring = $qn->column_value;
     // Create sensible group header label from column name
     $tempstring = column_name_to_label($col->query_name);
     $tempstring = $col->derive_attribute("column_title", $tempstring);
     $tempstring = sw_translate($col->derive_attribute("column_title", $tempstring));
     $this->text .= sw_translate($col->derive_attribute("group_header_label", $tempstring));
     $this->text .= "</TD>";
     $this->text .= '<TD class="swRepGrpHdrDat" ' . $this->get_style_tags($this->query->output_group_header_value_styles) . '>';
     $this->text .= "{$padstring}";
     $this->text .= "</TD>";
     $this->text .= "</TR>";
 }
コード例 #3
0
 function format_group_header(&$col)
 {
     $qn = get_query_column($col->query_name, $this->query->columns);
     // Create sensible group header label from column name
     $tempstring = column_name_to_label($col->query_name);
     $tempstring = $col->derive_attribute("column_title", $tempstring);
     $tempstring = sw_translate($col->derive_attribute("column_title", $tempstring));
     if (!isset($this->jar["pages"][$this->page_count]["groups"]["headers"])) {
         $this->jar["pages"][$this->page_count]["groups"]["headers"] = array();
     }
     $hct = count($this->jar["pages"][$this->page_count]["groups"]["headers"]) - 1;
     $this->jar["pages"][$this->page_count]["groups"]["headers"][$hct] = array("label" => $tempstring, "labelstyle" => $this->query->output_group_header_label_styles, "value" => $qn->column_value, "valuestyle" => $this->query->output_group_header_value_styles);
 }
コード例 #4
0
ファイル: reportico.php プロジェクト: arnon22/transportcm
	static function reportico_meta_sql_criteria(&$in_query, $in_string, $prev_col_value = false)
	{
        // Replace user parameters with values

        $external_param1 = get_reportico_session_param("external_param1");
        $external_param2 = get_reportico_session_param("external_param2");
        $external_param3 = get_reportico_session_param("external_param3");
        $external_user = get_reportico_session_param("external_user");

        if ( $external_param1 ) $in_string = preg_replace ("/{EXTERNAL_PARAM1}/", "'".$external_param1."'", $in_string);
        if ( $external_param2 ) $in_string = preg_replace ("/{EXTERNAL_PARAM2}/", "'".$external_param2."'", $in_string);
        if ( $external_param3 ) $in_string = preg_replace ("/{EXTERNAL_PARAM3}/", "'".$external_param3."'", $in_string);
        if ( $external_user ) $in_string = preg_replace ("/{FRAMEWORK_USER}/", "'".$external_user."'", $in_string);

        // Replace External parameters specified by {USER_PARAM,xxxxx}
		if ( preg_match_all ( "/{USER_PARAM,([^}]*)}/", $in_string, $matches ) )
        {
            foreach ( $matches[0] as $k => $v )
            {
                $param = $matches[1][$k];
                if ( isset($in_query->user_parameters[$param] ) )
                {
                    $in_string = preg_replace("/{USER_PARAM,$param}/", $in_query->user_parameters[$param], $in_string);
                }
                else
                {
		            trigger_error("User parameter $param, specified but not provided to reportico", E_USER_ERROR);
                }
            }
        }

		$looping = true;
		$out_string = $in_string;
		$ct = 0;
		while ( $looping )
		{
			$ct++;
			if ( $ct > 100 )
			{
				echo "Problem with SQL cannot resolve Criteria Items<br>";
				break;
			}
			$regpat = "/{([^}]*)/";
			if ( preg_match ( $regpat, $out_string, $matches ) )
			{
				$crit = $matches[1];
				$first = substr($crit, 0, 1);

				$critexp = $crit;
				if ( $first == "=" )
				{
					$crit = substr ( $crit, 1 );
					$critexp = $crit;
					if ( array_key_exists($crit, $in_query->lookup_queries) )
						$clause = $in_query->lookup_queries[$crit]->get_criteria_clause(false, false, true);
					else if ( $cl = get_query_column($crit, $this->query->columns ) )
						if ( $prev_col_value )
							$clause = $cl->old_column_value;
						else
							$clause = $cl->column_value;
					else
					{
						handle_error( "Unknown Criteria Item $crit in Query $in_string");
						return $in_string;
					}
				}
				else
				{
					$eltype = "VALUE";
                    $showquotes = true;
					if ( preg_match ( "/(.*),(.*),(.*)/", $crit, $critel ) )
					{
							$crit = $critel[1];
							$eltype = $critel[2];
							if ( $critel[3] == "false" )
                                $showquotes = false;
					}
					if ( preg_match ( "/(.*),(.*)/", $crit, $critel ) )
					{
							$crit = $critel[1];
							if ( $critel[2] == "false" )
                                $showquotes = false;
                            else
							    $eltype = $critel[2];
					}
					if ( array_key_exists($crit, $in_query->lookup_queries) )
					{
						switch ( $eltype )
						{
							case "FULL" :
								$clause = $in_query->lookup_queries[$crit]->get_criteria_clause(true, true, true, false, false, $showquotes);
								break;
	
							case "RANGE1" :
								$clause = $in_query->lookup_queries[$crit]->get_criteria_clause(false, false, false, true, false, $showquotes);
								break;
	
							case "RANGE2" :
								$clause = $in_query->lookup_queries[$crit]->get_criteria_clause(false, false, false, false, true, $showquotes);
								break;
	
							case "VALUE" :
							default :
								$clause = $in_query->lookup_queries[$crit]->get_criteria_clause(false, false, true, false, false, $showquotes);
						}
					}
					else if ( $cl = get_query_column($crit, $in_query->columns ) )
							if ( $prev_col_value )
								$clause = $cl->old_column_value;
							else
								$clause = $cl->column_value;
					else
					{
						//handle_error( "Unknown Criteria Item $crit in Query $in_string");
						return $in_string;
					}
				}

				if  (!$clause)
				{
					$out_string = preg_replace("/\[[^[]*\{$critexp\}[^[]*\]/", '',  $out_string);
				}
				else
				{
					$out_string = preg_replace("/\{=*$critexp\}/", 
						$clause,
						$out_string);
					$out_string = preg_replace("/\[\([^[]*\)\]/", "\1", $out_string);
				}


			}
			else
				$looping = false;

		}
	

		$out_string = preg_replace("/\[\[/", "<STARTBRACKET>", $out_string);
		$out_string = preg_replace("/\]\]/", "<ENDBRACKET>", $out_string);
		$out_string = preg_replace("/\[/", "", $out_string);
		$out_string = preg_replace("/\]/", "", $out_string);
		$out_string = preg_replace("/<STARTBRACKET>/", "[", $out_string);
		$out_string = preg_replace("/<ENDBRACKET>/", "]", $out_string);
		// echo "<br>Meta clause: $out_string<BR>";

		//$out_string = addcslashes($out_string, "\"");
		//$cmd = trim('$out_string = "'.$out_string.'";');
		//echo $out_string;
		
		//if ( $cmd )
			//eval($cmd);
		return $out_string;
	}
コード例 #5
0
 function each_line($val)
 {
     if ($this->page_count == 0) {
         $this->begin_page();
         // Print Criteria Items at top of report
         $this->format_criteria_selection_set();
         //$this->page_headers();
     }
     $this->debug("Base Each Line");
     $this->debug("Base Each Line");
     if (get_reportico_session_param("target_show_group_trailers")) {
         $this->after_group_trailers();
     }
     //echo "each line $this->inOverflow<BR>";
     $this->before_group_headers();
     $this->page_line_count++;
     $this->line_count++;
     // Add relevant values to any graphs
     foreach ($this->query->graphs as $k => $v) {
         $gr =& $this->query->graphs[$k];
         if (!$gr) {
             continue;
         }
         foreach ($gr->plot as $k1 => $v1) {
             $pl =& $gr->plot[$k1];
             $col = get_query_column($pl["name"], $this->query->columns);
             $gr->add_plot_value($pl["name"], $k1, $col->column_value);
         }
         if ($gr->xlabel_column) {
             $col1 = get_query_column($gr->xlabel_column, $this->query->columns);
             $gr->add_xlabel($col1->column_value);
         }
     }
     $this->debug("Line: " . $this->page_line_count . "/" . $this->line_count);
 }
コード例 #6
0
 function check_graphic_fit()
 {
     $will_fit = true;
     $max_height = $this->vsize;
     foreach ($this->columns as $col) {
         $contenttype = $col->derive_attribute("content_type", $col->query_name);
         $qn = get_query_column($col->query_name, $this->query->columns);
         if ($contenttype == "graphic" || preg_match("/imagesql=/", $qn->column_value)) {
             $qn = get_query_column($col->query_name, $this->query->columns);
             $sql = @preg_replace("/.*imagesql=/", "", $qn->column_value);
             $sql = @preg_replace("/'>\$/", "", $sql);
             $str =& get_db_image_string($this->query->datasource->driver, $this->query->datasource->database, $this->query->datasource->host_name, $sql, $this->query->datasource->ado_connection);
             if ($str) {
                 //$im = convert_image_string_to_image($str, "png");
                 $tmpnam = tempnam(SW_TMP_DIR, "dbi");
                 unlink($tmpnam);
                 $width = $qn->abs_column_width;
                 $height = 20;
                 $im = imagecreatefromstring($str);
                 if (imagepng($im, $tmpnam . ".png")) {
                     $h = $this->draw_image($tmpnam . ".png", 0, 0, $width, 0, true);
                     unlink($tmpnam . ".png");
                     if ($max_height < $h) {
                         $max_height = $h;
                     }
                 }
             }
         }
     }
     $y = $this->document->GetY();
     if ($y + $max_height > $this->abs_bottom_margin) {
         $this->finish_page();
         $this->begin_page();
         //$this->before_group_headers();
         $this->page_line_count++;
     }
 }
コード例 #7
0
ファイル: reportico_report_csv.php プロジェクト: GLUD/EcoHack
 function format_group_header(&$col, $custom)
 {
     // Excel requires group headers are printed as the first columns in the spreadsheet against
     // the detail.
     return;
     $qn = get_query_column($col->query_name, $this->query->columns);
     $padstring = $qn->column_value;
     $tempstring = str_replace("_", " ", $col->query_name);
     $tempstring = ucwords(strtolower($tempstring));
     echo sw_translate($col->derive_attribute("column_title", $tempstring));
     echo ": ";
     echo "{$padstring}";
     echo "\n";
 }
コード例 #8
0
ファイル: swsql.php プロジェクト: GLUD/EcoHack
 function import_into_query(&$in_query)
 {
     $in_query->sql_raw = $this->sql_raw;
     //When importing into query, we need to ensure that we remove
     // any columns already existing which do not appear in the
     // new query
     $delete_columns = array();
     foreach ($in_query->columns as $k => $v) {
         if ($v->in_select) {
             $delete_columns[$v->query_name] = true;
         }
     }
     foreach ($this->columns as $col) {
         $qn = $col["name"];
         if ($col["alias"]) {
             $qn = $col["alias"];
         }
         $in_query->create_criteria_column($qn, $col["table"], $col["name"], "char", 30, "####", true);
         if (array_key_exists($qn, $delete_columns)) {
             $delete_columns[$qn] = false;
         }
     }
     $ct = 0;
     $tabtext = "";
     foreach ($this->tables as $col) {
         if ($ct++ > 0) {
             $tabtext .= ",";
         }
         switch ($col["jointype"]) {
             case "outer":
                 $tabtext .= "outer ";
                 break;
             case "inner":
             case "default":
         }
         $tabtext .= $col["name"];
         if ($col["alias"]) {
             $tabtext .= " " . $col["alias"];
         }
     }
     $in_query->table_text = $tabtext;
     $in_query->table_text = $this->table_text;
     $in_query->where_text = false;
     if (substr($in_query->where_text, 0, 9) == "AND 1 = 1") {
         $in_query->where_text = substr($in_query->where_text, 9);
     }
     if ($this->group) {
         $in_query->group_text = "GROUP BY " . $this->group;
     } else {
         $in_query->group_text = "";
     }
     // Delete existing order columns
     $in_query->order_set = array();
     foreach ($this->orders as $col) {
         if ($qc = get_query_column($col["name"], $in_query->columns)) {
             $in_query->create_order_column($col["name"], $col["type"]);
         }
     }
     // Now remove from the parent query any columns which were not in the
     // imported SQL
     foreach ($delete_columns as $k => $v) {
         if ($v) {
             $in_query->remove_column($k);
         }
     }
     // Now order the query columns in the reportico query to reflect the order specified in
     // the select statement
     $pos = 0;
     $xx = false;
     foreach ($this->columns as $col) {
         $pos2 = 0;
         $cut = false;
         foreach ($in_query->columns as $k => $v) {
             if ($v->query_name == $col["alias"]) {
                 $cut = array_splice($in_query->columns, $pos2, 1);
                 break;
             }
             $pos2++;
         }
         if ($cut) {
             array_splice($in_query->columns, $pos, 0, $cut);
         }
         $pos++;
     }
     $in_query->rowselection = "all";
     if ($this->unique) {
         $in_query->rowselection = "unique";
     }
 }
コード例 #9
0
 function each_line($val)
 {
     reportico_report::each_line($val);
     // Set the values for the fields in the record
     $this->results["data"][$this->line_ct] = array();
     if ($this->line_ct == 0) {
         $qn = get_query_column("golap", $this->columns);
         if ($qn) {
             $arr = explode(",", $qn->column_value);
             foreach ($arr as $k => $v) {
                 $arr1 = explode("=", $v);
                 $this->results["displaylike"][$arr1[0]] = $arr1[1];
             }
         }
     }
     foreach ($this->query->display_order_set["column"] as $col) {
         $qn = get_query_column($col->query_name, $this->columns);
         $coltitle = $col->derive_attribute("column_title", $col->query_name);
         $coltitle = str_replace("_", " ", $coltitle);
         $coltitle = ucwords(strtolower($coltitle));
         $coltitle = sw_translate($coltitle);
         $disp = $col->derive_attribute("column_display", "show");
         if ($disp == "hide") {
             continue;
         }
         $this->results["data"][$this->line_ct][$coltitle] = $qn->column_value;
     }
     $this->line_ct++;
 }
コード例 #10
0
 function each_line($val)
 {
     reportico_report::each_line($val);
     //if ( $this->line_ct > 3 ) return;
     // Set the values for the fields in the record
     $this->results[] = array("id" => $this->line_ct, "cell" => array());
     $this->results[count($this->results) - 1]["cell"][] = "options";
     // Excel requires group headers are printed as the first columns in the spreadsheet against
     // the detail.
     foreach ($this->query->groups as $name => $group) {
         if (count($group->headers) > 0) {
             foreach ($group->headers as $gphk => $col) {
                 $qn = get_query_column($col->query_name, $this->query->columns);
                 $coltitle = $col->derive_attribute("column_title", $col->query_name);
                 $coltitle = str_replace("_", " ", $coltitle);
                 $coltitle = ucwords(strtolower($coltitle));
                 $coltitle = sw_translate($coltitle);
                 if ($col->query_name == $this->key_column) {
                     $this->results[count($this->results) - 1]["id"][] = $qn->column_value;
                 }
                 $this->results[count($this->results) - 1]["cell"][] = $qn->column_value;
                 if ($this->line_ct == 0) {
                     $this->colmodel[] = array("name" => $col->query_name, "index" => $col->query_name, "editable" => derive_jquerygrid_col_params($this->report_name, $col->query_name, "editable", false), "edittype" => "text", "sorttype" => "text", "jsonmap" => $col->query_name, "width" => derive_jquerygrid_col_params($this->report_name, $col->query_name, "width", "80"));
                     // Map colname to col
                     $this->colmap[$col->query_name] = count($this->colmodel) - 1;
                     if ($v = derive_jquerygrid_col_params($this->report_name, $col->query_name, "edittype", "")) {
                         $this->colmodel[count($this->colmodel) - 1]["edittype"] = $v;
                     }
                     if ($v = derive_jquerygrid_col_params($this->report_name, $col->query_name, "sorttype", "")) {
                         $this->colmodel[count($this->colmodel) - 1]["sorttype"] = $v;
                     }
                     if ($v = derive_jquerygrid_col_params($this->report_name, $col->query_name, "editoptions", "")) {
                         $this->colmodel[count($this->colmodel) - 1]["editoptions"] = $v;
                     }
                     if ($v = derive_jquerygrid_col_params($this->report_name, $col->query_name, "filtertype", "")) {
                         if ($v == "select") {
                             $this->colmodel[count($this->colmodel) - 1]["stype"] = "select";
                             if (!$this->colmodel[count($this->colmodel) - 1]["editoptions"]) {
                                 $this->colmodel[count($this->colmodel) - 1]["editoptions"] = array();
                                 $this->colfilters[$col->query_name] = array();
                                 $this->colmodel[count($this->colmodel) - 1]["editoptions"]["value"] = ":All";
                             }
                         }
                     }
                     $this->colnames[] = $coltitle;
                 }
                 if ($this->colmodel[$this->colmap[$col->query_name]]["stype"] == "select") {
                     if (!array_key_exists($qn->column_value, $this->colfilters[$col->query_name])) {
                         //$this->colmodel[$this->colmap[$col->query_name]]["editoptions"][$qn->column_value] = $qn->column_value;
                         $this->colfilters[$col->query_name][$qn->column_value] = "1";
                         $this->colmodel[$this->colmap[$col->query_name]]["editoptions"]["value"] .= ";" . $qn->column_value . ":" . $qn->column_value;
                     }
                 }
             }
         }
     }
     foreach ($this->query->display_order_set["column"] as $col) {
         $qn = get_query_column($col->query_name, $this->columns);
         $coltitle = $col->derive_attribute("column_title", $col->query_name);
         $coltitle = str_replace("_", " ", $coltitle);
         $coltitle = ucwords(strtolower($coltitle));
         $coltitle = sw_translate($coltitle);
         if ($col->query_name == $this->key_column) {
             $this->results[count($this->results) - 1]["id"] = $qn->column_value;
         }
         $disp = $col->derive_attribute("column_display", "show");
         if ($disp == "hide") {
             continue;
         }
         if ($this->line_ct == 0) {
             $this->colmodel[] = array("name" => $col->query_name, "index" => $col->query_name, "editable" => derive_jquerygrid_col_params($this->report_name, $col->query_name, "editable", false), "edittype" => "text", "sorttype" => "int", "jsonmap" => $col->query_name, "width" => derive_jquerygrid_col_params($this->report_name, $col->query_name, "width", "80"));
             // Map colname to col
             $this->colmap[$col->query_name] = count($this->colmodel) - 1;
             if ($v = derive_jquerygrid_col_params($this->report_name, $col->query_name, "hidden", "")) {
                 $this->colmodel[count($this->colmodel) - 1]["hidden"] = $v;
             }
             if ($v = derive_jquerygrid_col_params($this->report_name, $col->query_name, "edittype", "")) {
                 $this->colmodel[count($this->colmodel) - 1]["edittype"] = $v;
             }
             if ($v = derive_jquerygrid_col_params($this->report_name, $col->query_name, "sorttype", "")) {
                 $this->colmodel[count($this->colmodel) - 1]["sorttype"] = $v;
             }
             if ($v = derive_jquerygrid_col_params($this->report_name, $col->query_name, "filtertype", "")) {
                 if ($v == "select") {
                     $this->colmodel[count($this->colmodel) - 1]["stype"] = "select";
                     if (!$this->colmodel[count($this->colmodel) - 1]["editoptions"]) {
                         $this->colmodel[count($this->colmodel) - 1]["editoptions"] = array();
                         $this->colfilters[$col->query_name] = array();
                         $this->colmodel[count($this->colmodel) - 1]["editoptions"]["value"] = ":All";
                     }
                 }
             }
             if ($v = derive_jquerygrid_col_params($this->report_name, $col->query_name, "editoptions", "")) {
                 $this->colmodel[count($this->colmodel) - 1]["editoptions"] = $v;
             }
             $this->colnames[] = $coltitle;
         }
         // Add value to filter options if type is select
         if ($this->colmodel[$this->colmap[$col->query_name]]["stype"] == "select") {
             if (!array_key_exists($qn->column_value, $this->colfilters[$col->query_name])) {
                 //$this->colmodel[$this->colmap[$col->query_name]]["editoptions"][$qn->column_value] = $qn->column_value;
                 $this->colfilters[$col->query_name][$qn->column_value] = "1";
                 $this->colmodel[$this->colmap[$col->query_name]]["editoptions"]["value"] .= ";" . $qn->column_value . ":" . $qn->column_value;
             }
         }
         $this->results[count($this->results) - 1]["cell"][] = $qn->column_value;
     }
     // $this->results[] = $cells;
     $this->line_ct++;
 }