load($array); } public function load_options($options = array()) { if ((bool) !$options) { return false; } $this->options = $options; return TRUE; } public function load($array = array()) { if ((bool) !$array) { return false; } // ITS4YOU-UP SlOl | 15.7.2014 11:03 ch_image_name foreach (array('library_loaded', 'graphic_type', 'create_div', 'dashboard_div', 'filter_div', 'chart_div', 'class_filter_div', 'class_dashboard_div', 'class_chart_div', 'open_js_tag', 'control_type', 'ch_image_name') as $p) { if (isset($array[$p])) { if ($p == 'graphic_type') { $this->set_graphic_type($array[$p]); continue; } $this->$p = $array[$p]; } } } public function load_library() { $return_script = ""; if (!$this->library_loaded) { $this->library_loaded = TRUE; $onlin_jsapi = "https://www.google.com/jsapi"; $local_jsapi = "modules/ITS4YouReports/jsapi.js"; $load_script = true; if(file_get_contents($onlin_jsapi)!==false){ $scipt_path = $onlin_jsapi; }elseif(file_exists($local_jsapi)){ $scipt_path = $local_jsapi; }else{ echo "
";print_r("Save content of url: JS Api to directory modules/ITS4YouReports/jsapi.js please !");echo "";
die();
}
if($scipt_path){
$return_script .='';
}
}
return $return_script;
}
public function set_graphic_type($type = NULL) {
if (is_null($type))
return false;
$type = strtolower(trim($type));
$types = array(
'linechart' => 'LineChart',
'piechart' => 'PieChart',
'columnchart' => 'ColumnChart',
'areachart' => 'AreaChart',
'treemap' => 'TreeMap',
'scatterchart' => 'ScatterChart',
'gauge' => 'Gauge',
'geochart' => 'GeoChart',
'combochart' => 'ComboChart',
'barchart' => 'BarChart',
'candlestickchart' => 'CandlestickChart',
'table' => 'Table');
if (!in_array($type, array_keys($types))) {
exit('Error: Type of graph is not defined. [' . $type . ']');
}
$this->graphic_type = $types[$type];
return true;
}
public function set_options($options = array()) {
if ((bool) !$options) {
return array();
}
$this->gen_options = $options;
return true;
}
public function set_control_options($options = array()) {
if ((bool) !$options) {
return array();
}
$this->control_options = $options;
return true;
}
public function generate($data) {
if ((bool) !$data) {
return false;
}
if (is_null($this->chart_div)) {
//$key = $this->gerarkey(10);
//$this->chart_div = 'gcharts_' . $key;
$this->chart_div = 'innerchdiv';
}
if ($this->dashboard_div === TRUE) {
$this->dashboard_div = 'dashboard_' . $key;
$this->use_dashboard = TRUE;
}
if ($this->filter_div === TRUE) {
$this->filter_div = 'filter_' . $key;
}
/*if ($this->use_dashboard === FALSE) {
return $this->GenWithoutDashboard($data);
} else {
return $this->GenWithDashboard($data);
}*/
if ($this->use_dashboard === FALSE) {
return $this->GenWithoutDashboard($data);
}else{
return $this->GenWithDashboard($data);
}
return false;
}
/*private function GenWithDashboard($data) {
$js = NULL;
$js .= $this->load_library() . "\n";
if ($this->open_js_tag === TRUE) {
$js .= '' . "\n";
}
/* CRIA AS DIVS * /
if ($this->create_div === TRUE) {
/* DASHBOARD DIV * /
if (!is_null($this->dashboard_div)) {
$js .= '