Esempio n. 1
0
 function mkCacheData($date_from, $date_to, $product_id)
 {
     $conditions = array();
     $info = $this->dbstuff->GetRow("SELECT * FROM " . $this->table_prefix . "products WHERE id='" . $product_id . "'");
     if (!empty($info)) {
         $_GET['pn'] = $info['name'];
     }
     $mdt = date("Ymd") . "_" . substr(md5($_GET['pn'] . $_GET['ds'] . $_GET['de']), 0, 6);
     $file_item = $mdt;
     $file_path = DATA_PATH . "tmp/" . $file_item . $this->cache_ext;
     if (!file_exists($file_path)) {
         // use the chart class to build the chart:
         include_once LIB_PATH . 'ofc/chart.php';
         $g = new graph();
         $result = $this->dbstuff->GetArray("SELECT DATE_FORMAT(FROM_UNIXTIME(created),'%m') as mn,avg(max_price) AS avmax,avg(min_price) AS avmin FROM " . $this->table_prefix . "quotes WHERE product_id=" . $product_id . " AND created BETWEEN {$date_from} AND {$date_to} group by mn ORDER BY created ASC");
         if (!empty($result)) {
             foreach ($result as $val) {
                 $data[] = floor(($val['avmax'] + $val['avmin']) / 2);
             }
             $title = L("stat_charts", "tpl") . $_GET['ds'] . L("arrive_to", "tpl") . $_GET['de'];
         } elseif ($info['name']) {
             $title = $info['name'];
         } else {
             $title = L("data_not_exists") . df();
         }
         $g->title($title, '{font-size: 24px;color: #0000FF}');
         $g->set_data($data);
         $g->line_hollow(2, 4, '0x80a033', $_GET['pn'], 10);
         // label each point with its value
         //$g->set_x_labels( explode(",", L("months", "tpl")) );
         $x_result = $this->dbstuff->GetArray("select CONCAT(FROM_UNIXTIME(created, '%Y'),'/',FROM_UNIXTIME(created, '%m')) as m from " . $this->table_prefix . "quotes WHERE created BETWEEN {$date_from} AND {$date_to} group by DATE_FORMAT(FROM_UNIXTIME(created),'%m') ORDER BY created ASC");
         foreach ($x_result as $val) {
             $x_tmp[] = $val['m'];
         }
         $g->set_x_labels($x_tmp);
         $label_y = $this->dbstuff->GetRow("select max(max_price) as price_max,min(min_price) as price_min from " . $this->table_prefix . "quotes WHERE product_id=" . $product_id . " AND created BETWEEN {$date_from} AND {$date_to}");
         $y_max = !empty($label_y['price_max']) ? $label_y['price_max'] : 100;
         // set the Y max
         $this->max_price = $label_y['price_max'];
         $this->min_price = $label_y['price_min'];
         $g->set_y_max($label_y['price_max']);
         // label every 20 (0,20,40,60)
         $g->y_label_steps(6);
         // display the data
         file_put_contents($file_path, $g->render());
     }
     $this->cache_datafile = $file_item . $this->cache_ext;
 }
Esempio n. 2
0
 function grafico($titulo)
 {
     $this->load->library('Graph');
     $mSQL_1 = "SELECT cod_cli,nombre,   \r\n\t\t\tsum(totalg*IF(tipo_doc='D', -1, 1)) AS grantotal, \r\n\t\t\tsum(totalg*(referen IN ('E', 'M'))*IF(tipo_doc='D', -1, 1)) AS contado,\r\n\t\t\tsum(totalg*(referen NOT IN ('E', 'M'))*IF(tipo_doc='D', -1, 1)) AS credito \r\n\t\t\tFROM sfac\r\n\t\t\tWHERE tipo_doc<>'X' AND fecha>='20070101' AND fecha<='20071231' \r\n\t\t\tGROUP BY cod_cli ORDER BY grantotal DESC LIMIT 10";
     // generate some random data
     srand((double) microtime() * 1000000);
     $bar_1 = new bar_fade(50, '#209B2C');
     $bar_1->key('Contado', 10);
     $bar_2 = new bar_fade(50, '#9933CC');
     $bar_2->key('Credito', 10);
     $bar_3 = new bar_fade(50, '#639F45');
     $bar_3->key('Total', 10);
     $maxval = 0;
     $label = $tips = array();
     $query = $this->db->query($mSQL_1);
     foreach ($query->result() as $row) {
         if ($row->grantotal > $maxval) {
             $maxval = $row->grantotal;
         }
         $bar_1->data[] = $row->contado;
         $bar_2->data[] = $row->credito;
         $bar_3->data[] = $row->grantotal;
         //$bar_1->tips = $data_tips_3;
         $tips[] = $row->nombre;
         $label[] = $row->cod_cli;
     }
     $g = new graph();
     $g->title($titulo, '{font-size: 26px;}');
     $g->data_sets[] = $bar_1;
     $g->data_sets[] = $bar_2;
     $g->data_sets[] = $bar_3;
     $g->set_x_labels($label);
     $g->set_x_label_style(10, '#9933CC', 2, 1);
     $g->set_x_axis_steps(10);
     $g->bg_colour = '#FFFFFF';
     $g->set_tool_tip('#key#<br>Codigo de Clinte: #x_label# <br>Monto: #tip#');
     $g->tips = $tips;
     $g->set_y_max($maxval);
     $g->y_label_steps(3);
     $g->set_y_legend('Open Flash Chart', 12, '0x736AFF');
     echo utf8_encode($g->render());
 }
Esempio n. 3
0
 function compras($id = '')
 {
     if (empty($id)) {
         return;
     }
     $this->load->library('Graph');
     $codigo = $this->datasis->dameval("SELECT codigo FROM sinv WHERE id={$id}");
     $mSQL = "SELECT\tMID(a.fecha,1,7) mes,\n\t\t\tSUM(a.cantidad*(b.tipo_doc='FC')) cventa,\n\t\t\tSUM(a.cantidad*(b.tipo_doc='NC')) cdevol,\n\t\t\tSUM(a.cantidad*if(b.tipo_doc='NC',-1,1)) cana,\n\t\t\tSUM(a.importe*(b.tipo_doc='FC')) mventa,\n\t\t\tSUM(a.importe*(b.tipo_doc='NC')) mdevol,\n\t\t\tSUM(a.importe*if(b.tipo_doc='NC',-1,1)) tota\n\t\tFROM itscst a JOIN scst b ON a.control=b.control\n\t\tWHERE a.codigo='{$codigo}' AND b.tipo_doc IN ('FC','NC') AND b.fecha >= CONCAT(MID(SUBDATE(curdate(),365),1,8),'01')\n\t\t\t\tAND  a.fecha <= b.actuali\n\t\tGROUP BY MID( b.fecha, 1,7 ) LIMIT 7  ";
     $maxval = 0;
     $query = $this->db->query($mSQL);
     $data_1 = $data_2 = $meses = array();
     foreach ($query->result() as $row) {
         if ($row->cana > $maxval) {
             $maxval = $row->cana;
         }
         $meses[] = $row->mes;
         $data_1[] = $row->cana;
     }
     $om = 1;
     while ($maxval / $om > 100) {
         $om = $om * 10;
     }
     $bar_1 = new bar(75, '#9053A4');
     $bar_1->key('Compra', 10);
     for ($i = 0; $i < count($data_1); $i++) {
         $bar_1->add_data_tip($data_1[$i] / $om, graph::esc(number_format($data_1[$i], 2, ',', '.')));
         $bar_1->links[] = site_url("/ventas/clientes/mensuales/{$codigo}/" . $meses[$i]);
     }
     $g = new graph();
     $g->set_is_decimal_separator_comma(1);
     if ($maxval > 0) {
         $g->title('Compras por Mes ', '{font-size: 16px; color:#0F3054}');
         $g->data_sets[] = $bar_1;
         $g->set_x_labels($meses);
         $g->set_x_label_style(10, '#000000', 2, 1);
         $g->set_x_axis_steps(10);
         $g->set_x_legend('Meses ', 14, '#004381');
         $g->bg_colour = '#FFFFFF';
         $g->set_tool_tip('#key#<br>Mes: #x_label# <br>Cantidad: #tip#');
         $g->set_y_max(ceil($maxval / $om));
         $g->y_label_steps(5);
         $g->set_y_legend('Compras x ' . number_format($om, 0, '', '.'), 16, '#004381');
     } else {
         $g->title('No existen ventas en el a&ntilde;o seleccionado', '{font-size:18px; color: #d01f3c}');
     }
     $g->bg_colour = '#FFFFFF';
     echo utf8_encode($g->render());
 }
Esempio n. 4
0
 function gdiarias($anio = '', $cliente = '', $mes = '')
 {
     $this->load->library('Graph');
     if (empty($mes) or empty($anio) or empty($cliente)) {
         return;
     }
     $fechai = $anio . str_pad($mes, 2, "0", STR_PAD_LEFT) . '01';
     $fechaf = $anio . str_pad($mes, 2, "0", STR_PAD_LEFT) . '31';
     $mSQL = "SELECT cod_cli,nombre,fecha,DAYOFMONTH(fecha) as dia,                                             \n\t\tsum(gtotal*IF(tipo='D', -1, 1)) AS grantotal,                              \n\t\tsum(gtotal*IF(tipo='D', -1, 1)) AS contado,        \n\t\tsum(gtotal*IF(tipo='D', -1, 1)) AS credito     \n\t\tFROM fmay                                                                      \n\t\tWHERE tipo<>'X' AND fecha>='{$fechai}' AND fecha<='{$fechaf}' AND cod_cli='{$cliente}'                 \n\t\tGROUP BY fecha ORDER BY fecha,grantotal DESC LIMIT 31";
     //echo $mSQL;
     $maxval = 0;
     $query = $this->db->query($mSQL);
     foreach ($query->result() as $row) {
         if ($row->grantotal > $maxval) {
             $maxval = $row->grantotal;
         }
         $fecha[] = $row->dia;
         $data_1[] = $row->contado;
         $data_2[] = $row->credito;
         $data_3[] = $row->grantotal;
     }
     $nombre = $row->nombre;
     $om = 1;
     while ($maxval / $om > 100) {
         $om = $om * 10;
     }
     $bar_1 = new bar(75, '#0053A4');
     $bar_2 = new bar(75, '#9933CC');
     $bar_3 = new bar(75, '#639F45');
     $bar_1->key('Contado', 10);
     $bar_2->key('Credito', 10);
     $bar_3->key('Total', 10);
     for ($i = 0; $i < count($data_1); $i++) {
         $bar_1->add_data_tip($data_1[$i] / $om, graph::esc(number_format($data_1[$i], 2, ',', '.')));
         $bar_2->add_data_tip($data_2[$i] / $om, graph::esc(number_format($data_2[$i], 2, ',', '.')));
         $bar_3->add_data_tip($data_3[$i] / $om, graph::esc(number_format($data_3[$i], 2, ',', '.')));
     }
     $g = new graph();
     $g->set_is_decimal_separator_comma(1);
     if ($maxval > 0) {
         $g->title('Compras de el cliente ' . $nombre . '  en el mes ' . $mes . '/' . $anio, '{font-size: 16px; color:#0F3054}');
         $g->data_sets[] = $bar_1;
         $g->data_sets[] = $bar_2;
         $g->data_sets[] = $bar_3;
         $g->set_x_labels($fecha);
         $g->set_x_label_style(10, '#000000', 3, 1);
         $g->set_x_axis_steps(10);
         $g->set_x_legend('Dias', 14, '#004381');
         $g->bg_colour = '#FFFFFF';
         $g->set_tool_tip('#key#<br>Dia: #x_label# <br>Monto: #tip#');
         $g->set_y_max(ceil($maxval / $om));
         $g->y_label_steps(5);
         $g->set_y_legend('hospitalidad x ' . number_format($om, 0, '', '.') . ' (Bs)', 16, '#004381');
     } else {
         $g->title('No existen ventas con los datos seleccionados', '{font-size:18px; color: #d01f3c}');
     }
     $g->bg_colour = '#FFFFFF';
     echo utf8_encode($g->render());
 }
  	$data_2[] = $row['vr_custo'];
  	$data_3[] = $row['vr_totalvenda']-$row['vr_custo'];
  	
  	$labels[] = date('d/m/Y',strtotime($row['data_venda']));

  	$max_value = ($max_value<$row['vr_totalvenda'])?$row['vr_totalvenda']:$max_value;
  	
}


$g = new graph();

$g->set_data( $data_1 );
$g->set_data( $data_2 );
$g->set_data( $data_3 );

$g->line_hollow( 3, 5, '0x9933CC', 'Venda', 10 );
$g->line_hollow( 3, 5, '0xCC3399', 'Custo', 10);    // <-- 3px thick + dots
$g->line_hollow( 3, 5, '0x80a033', 'Lucro', 10 );

$g->set_x_labels( $labels );
$g->set_x_label_style( 10, '0x000000', 0, 2 );

$g->set_y_max( $max_value );
$g->y_label_steps( 4 );
$g->set_y_legend( 'Valores em Real - R$', 12, '#000000' );
$g->bg_colour = '#FFFFFF';

echo $g->render();

?>
Esempio n. 6
0
 function gdiarias($anio = '', $proveed = '', $mes = '')
 {
     $this->load->library('Graph');
     if (empty($mes) or empty($anio) or empty($proveed)) {
         return;
     }
     $proveed = radecode($proveed);
     $fechai = $anio . str_pad($mes, 2, '0', STR_PAD_LEFT) . '01';
     $fechaf = $anio . str_pad($mes, 2, '0', STR_PAD_LEFT) . '31';
     $dbfechai = $this->db->escape($fechai);
     $dbfechaf = $this->db->escape($fechaf);
     $dbproveed = $this->db->escape($proveed);
     $mSQL = "SELECT  LEFT(nombre,10)as nombre,proveed,DAYOFMONTH(fecha) AS dia ,\n\t\tSUM(montonet*IF(tipo_doc='NC', -1, 1)) AS grantotal,\n\t\tSUM(credito*IF( tipo_doc='NC', -1, 1)) AS credito,\n\t\tSUM(inicial*IF( tipo_doc='NC', -1, 1)) AS contado\n\t\tFROM scst\n\t\tWHERE tipo_doc<>'NE' AND fecha>={$dbfechai} AND fecha<={$dbfechaf} AND proveed={$dbproveed}\n\t\t\tAND actuali >= fecha\n\t\tGROUP BY fecha ORDER BY fecha,grantotal DESC LIMIT 31";
     //echo $mSQL;
     $maxval = 0;
     $query = $this->db->query($mSQL);
     foreach ($query->result() as $row) {
         if ($row->grantotal > $maxval) {
             $maxval = $row->grantotal;
         }
         $fecha[] = $row->dia;
         $nombre = str_replace('&', '', $row->nombre);
         //$data_1[]=$row->contado;
         //$data_2[]=$row->credito;
         $data_3[] = $row->grantotal;
     }
     $om = 1;
     while ($maxval / $om > 100) {
         $om = $om * 10;
     }
     //$bar_1 = new bar(75, '#0053A4');
     //$bar_2 = new bar(75, '#9933CC');
     $bar_3 = new bar(75, '#639F45');
     //$bar_1->key('Contado',10);
     //$bar_2->key('Credito',10);
     $bar_3->key('Total Bs.', 10);
     for ($i = 0; $i < count($data_3); $i++) {
         //$bar_1->add_data_tip($data_1[$i]/$om, graph::esc( number_format($data_1[$i],2,',','.')));
         //$bar_2->add_data_tip($data_2[$i]/$om, graph::esc( number_format($data_2[$i],2,',','.')));
         $bar_3->add_data_tip($data_3[$i] / $om, graph::esc(number_format($data_3[$i], 2, ',', '.')));
     }
     $g = new graph();
     $g->set_is_decimal_separator_comma(1);
     if ($maxval > 0) {
         $g->title('Compras a ' . $nombre . '  en el mes ' . $mes . '/' . $anio, '{font-size: 16px; color:##00264A}');
         //$g->data_sets[] = $bar_1;
         //$g->data_sets[] = $bar_2;
         $g->data_sets[] = $bar_3;
         $g->set_x_labels($fecha);
         $g->set_x_label_style(10, '#000000', 3, 1);
         $g->set_x_axis_steps(10);
         $g->set_x_legend('Dias', 14, '#004381');
         $g->bg_colour = '#FFFFFF';
         $g->set_tool_tip('#key#<br>Dia: #x_label# <br>Monto: #tip#');
         $g->set_y_max(ceil($maxval / $om));
         $g->y_label_steps(5);
         $g->set_y_legend('Compras x ' . number_format($om, 0, '', '.') . ' (Bs)', 16, '#004381');
     } else {
         $g->title('No existen compras con los datos seleccionados', '{font-size:18px; color: #d01f3c}');
     }
     $g->bg_colour = '#FFFFFF';
     echo utf8_encode($g->render());
 }
Esempio n. 7
0
    }
    $bar_green->data[] = $t[2];
    if ($t[0] > $tmax) {
        $tmax = $t[0];
    }
    if ($t[1] > $tmax) {
        $tmax = $t[1];
    }
    if ($t[2] > $tmax) {
        $tmax = $t[2];
    }
}
// create the graph object:
$g = new graph();
$g->title('Statystyka rozmów', '{font-size:15px; color: #FFFFFF; margin: 5px; background-color: #505050; padding:5px; padding-left: 20px; padding-right: 20px;}');
//$g->set_data( $data_1 );
//$g->bar_3D( 75, '#D54C78', '2006', 10 );
//$g->set_data( $data_2 );
//$g->bar_3D( 75, '#3334AD', '2007', 10 );
$g->data_sets[] = $bar_red;
$g->data_sets[] = $bar_blue;
$g->data_sets[] = $bar_green;
// $g->set_x_axis_3d( 3 );
$g->x_axis_colour('#909090', '#ADB5C7');
$g->y_axis_colour('#909090', '#ADB5C7');
$g->set_x_labels($x_labels);
$g->set_x_label_style(10, 'black', 1);
$g->set_y_max($tmax);
$g->y_label_steps(5);
$g->set_y_legend('Ilosc sekund', 12, '#736AFF');
echo $g->render();
Esempio n. 8
0
function umc_donation_java_chart()
{
    global $UMC_SETTING;
    $sql_chart = "SELECT SUM(amount) as monthly, year(date) as date_year, month(date) as date_month FROM minecraft_srvr.`donations` GROUP BY YEAR(date), MONTH(date);";
    $D = umc_mysql_fetch_all($sql_chart);
    $lastdate = "2010-11";
    $ydata = array();
    $legend = array();
    $minval = $maxval = 0;
    $sum = 0;
    foreach ($D as $row) {
        $month = sprintf("%02d", $row['date_month']);
        $date = $row['date_year'] . '-' . $month;
        $datetime1 = new DateTime("{$lastdate}-01");
        $datetime2 = new DateTime("{$date}-01");
        $interval = $datetime1->diff($datetime2);
        $int = $interval->format('%m');
        $int--;
        for ($i = $int; $i > 0; $i--) {
            // echo "$i $int - ";
            $e_date = date("Y-m", mktime(0, 0, 0, $row['date_month'] - $i, 01, $row['date_year']));
            // $e_month = $row['date_month'] - $i;
            // $e_date = $row['date_year'] . '-' . $e_month;
            $sum = $sum - 135;
            $ydata[] = $sum;
            //echo $e_date . ": " . $sum . "<br>";
            $legend[] = $e_date . "-01";
            $maxval = max($sum, $maxval);
            $minval = min($sum, $minval);
        }
        $sum = $sum + $row['monthly'] - 135;
        //echo $date . ": " . $sum . "<br>";
        $ydata[] = $sum;
        $legend[] = $date . "-01";
        $lastdate = $date;
        $maxval = max($sum, $maxval);
        $minval = min($sum, $minval);
    }
    $outstanding = $sum * -1;
    require_once $UMC_SETTING['path']['html'] . '/admin/flash/open-flash-chart.php';
    $g = new graph();
    //$g->title("Donation Stats", '{font-size: 15px; color: #000000}');
    $g->bg_colour = '#FFFFFF';
    // Some data (line 1):
    $g->set_data($ydata);
    $legend1 = "Cost vs. donations balance in USD";
    $g->line(1, '#0000FF', $legend1, 10);
    // $g->set_y_legend( $legend1, 12, '#0000FF' );
    $g->set_y_max($maxval);
    $g->set_y_min($minval);
    $g->y_axis_colour('#0000FF', '#DFDFDF');
    $g->x_axis_colour('#DFDFDF', '#FFFFFF');
    $g->set_x_legend('Uncovery Minecraft Server uptime', 12, '#000000');
    // The X Axis labels are the time, 00:00, 01:00, 02:00 etc...
    $g->set_x_labels($legend);
    $g->set_x_label_style(8, '#000000', 1, 1, '#DFDFDF');
    // lines in the background
    $g->y_label_steps(10);
    $g->set_width('100%');
    $g->set_height(300);
    $g->set_output_type('js');
    $g->set_js_path('/admin/flash/');
    $g->set_swf_path('/admin/flash/');
    return array('chart' => $g->render(), 'outstanding' => $outstanding);
}
Esempio n. 9
0
    $steg > $max_steg ? $max_steg = $steg : "";
    $x_labels[] = $veckodagar[date("N", strtotime(abs($i) . " days ago")) - 1];
}
if ($bar->data[7] > 0) {
    $bar->data = array_slice($bar->data, 1, 7);
    $x_labels = array_slice($x_labels, 1, 7);
} else {
    $bar->data = array_slice($bar->data, 1, 7);
    $x_labels = array_slice($x_labels, 1, 7);
}
$x_labels = array($x_labels[0], '', '', $x_labels[3], '', '', $x_labels[6]);
$g = new graph();
if (isset($flaghigher) && $flaghigher == 40000) {
    $g->set_bg_image('/img/guld_silver_bg.gif', 'right', 'bottom');
    $g->set_y_max(40000);
    $g->y_label_steps(4);
} else {
    $g->set_bg_image('/img/20000_guld_silver_bg.gif', 'right', 'bottom');
    $g->set_y_max(20000);
    $g->y_label_steps(2);
}
$g->set_x_labels($x_labels);
$g->set_x_axis_steps(0);
//
// BAR CHART:
//
//$g->set_data( $data );
//$g->bar_filled( 50, '#9933CC', '#8010A0', 'Page views', 10 );
//
// ------------------------
//
Esempio n. 10
0
 function CasesByProcess()
 {
     $dataSet = $this->getCasesByProcess();
     $data = $dataSet['data'];
     //$series2 = $dataSet['series2'];
     $g = new graph();
     $g->title(' Cases by Process ', '{font-size: 14px;}');
     $bar_red = new bar_3d(50, '#3334AD');
     $bar_red->key('cases', 10);
     $bar_red->data = $data;
     $g->data_sets[] = $bar_red;
     $g->set_x_axis_3d(12);
     $g->x_axis_colour('#909090', '#ADB5C7');
     $g->y_axis_colour('#909090', '#ADB5C7');
     $g->set_x_labels($dataSet['label']);
     $g->set_y_max($dataSet['max']);
     $g->y_label_steps(6);
     echo $g->render();
 }
Esempio n. 11
0
 function gmensuales($mes = '', $anio = '')
 {
     $this->load->library('Graph');
     $this->lang->load('calendar');
     if (empty($anio) or empty($mes)) {
         return;
     }
     $fechai = $anio . str_pad($mes, 2, "0", STR_PAD_LEFT) . '01';
     $fechaf = $anio . str_pad($mes, 2, "0", STR_PAD_LEFT) . '31';
     $mSQL = "SELECT DAYOFMONTH(fecha)AS dia,\r\n    SUM(monto)AS grantotal\r\n    FROM  pres \r\n    WHERE fecha>='{$fechai}' AND fecha<='{$fechaf}'\r\n    GROUP BY fecha";
     //echo $mSQL;
     $maxval = 0;
     $query = $this->db->query($mSQL);
     foreach ($query->result() as $row) {
         if ($row->grantotal > $maxval) {
             $maxval = $row->grantotal;
         }
         $fecha[] = $row->dia;
         $data_1[] = $row->grantotal;
     }
     $om = 1;
     while ($maxval / $om > 100) {
         $om = $om * 10;
     }
     $bar_1 = new bar(75, '#329B98');
     $bar_1->key('Total', 10);
     for ($i = 0; $i < count($data_1); $i++) {
         $bar_1->add_data_tip($data_1[$i] / $om, graph::esc(number_format($data_1[$i], 2, ',', '.')));
     }
     $g = new graph();
     $g->set_is_decimal_separator_comma(1);
     if ($maxval > 0) {
         $g->title('Prestamos de el mes ' . $mes . '/' . $anio, '{font-size: 16px; color:#0F3054}');
         $g->data_sets[] = $bar_1;
         $g->set_x_labels($fecha);
         $g->set_x_label_style(10, '#000000', 3, 1);
         $g->set_x_axis_steps(10);
         $g->set_x_legend('Dias', 16, '#004381');
         $g->bg_colour = '#FFFFFF';
         $g->set_tool_tip('#key#<br>Dia: #x_label# <br>Monto: #tip#');
         $g->set_y_max(ceil($maxval / $om));
         $g->y_label_steps(5);
         $g->set_y_legend('Prestamos x ' . number_format($om, 0, '', '.') . ' (Bs)', 16, '#004381');
     } else {
         $g->title('No existen prestamos con los datos seleccionados', '{font-size:18px; color: #d01f3c}');
     }
     $g->bg_colour = '#FFFFFF';
     echo utf8_encode($g->render());
 }
Esempio n. 12
0
 function grafico($anio = '')
 {
     $this->load->library('Graph');
     if (empty($anio)) {
         return;
     }
     $fechai = $anio . '0101';
     $fechaf = $anio . '1231';
     $mSQL = "SELECT a.vd, LEFT(b.nombre, 8)as nombre2,                                            \n\t\t sum(a.totalg*IF(a.tipo_doc='D', -1, 1)) AS grantotal,                              \n\t\t sum(a.totalg*(a.referen IN ('E', 'M'))*IF(a.tipo_doc='D', -1, 1)) AS contado,        \n\t\t sum(a.totalg*(a.referen NOT IN ('E', 'M'))*IF(a.tipo_doc='D', -1, 1)) AS credito     \n\t\t FROM sfac AS a \n\t\t JOIN vend AS b  ON a.vd=b.vendedor                                                                   \n\t\t WHERE a.tipo_doc<>'X' AND a.fecha>='{$fechai}' AND a.fecha<='{$fechaf}'                  \n\t\t GROUP BY a.vd ORDER BY a.vd,grantotal DESC LIMIT 10";
     $maxval = 0;
     $query = $this->db->query($mSQL);
     $data_1 = $data_2 = $data_3 = $vendedor = array();
     foreach ($query->result() as $row) {
         if ($row->grantotal > $maxval) {
             $maxval = $row->grantotal;
         }
         $nombre[] = $row->nombre2;
         $vendedor[] = $row->vd;
         $data_1[] = $row->contado;
         $data_2[] = $row->credito;
         $data_3[] = $row->grantotal;
     }
     $om = 1;
     while ($maxval / $om > 100) {
         $om = $om * 10;
     }
     $bar_1 = new bar(75, '#0053A4');
     $bar_2 = new bar(75, '#9933CC');
     $bar_3 = new bar(75, '#639F45');
     $bar_1->key('Contado', 10);
     $bar_2->key('Credito', 10);
     $bar_3->key('Total', 10);
     for ($i = 0; $i < count($data_1); $i++) {
         $bar_1->add_data_tip($data_1[$i] / $om, graph::esc(number_format($data_1[$i], 2, ',', '.')));
         $bar_2->add_data_tip($data_2[$i] / $om, graph::esc(number_format($data_2[$i], 2, ',', '.')));
         $bar_3->add_data_tip($data_3[$i] / $om, graph::esc(number_format($data_3[$i], 2, ',', '.')));
         $bar_1->links[] = site_url("/ventas/vendedoresmensuales/index/{$anio}/" . $vendedor[$i]);
         $bar_2->links[] = site_url("/ventas/vendedoresmensuales/index/{$anio}/" . $vendedor[$i]);
         $bar_3->links[] = site_url("/ventas/vendedoresmensuales/index/{$anio}/" . $vendedor[$i]);
     }
     $g = new graph();
     $g->title('Los 10 vendedores con los indice de ventas m&aacute;s altos en el a&ntilde;o' . $anio, '{font-size: 22px; color:##00264A}');
     $g->set_is_decimal_separator_comma(1);
     $g->data_sets[] = $bar_1;
     $g->data_sets[] = $bar_2;
     $g->data_sets[] = $bar_3;
     $g->set_x_labels($nombre);
     $g->set_x_label_style(10, '#000000', 3, 1);
     $g->set_x_axis_steps(10);
     $g->set_x_legend('Vendedores', 14, '#004381');
     $g->bg_colour = '#FFFFFF';
     $g->set_tool_tip('#key#<br>Vendedor: #x_label# <br>Monto: #tip#');
     $g->set_y_max(ceil($maxval / $om));
     $g->y_label_steps(5);
     $g->set_y_legend('Ventas x ' . number_format($om, 0, '', '.') . ' (Bs)', 16, '#004381');
     echo utf8_encode($g->render());
 }
 function Chart3DBAR($LimiteMaximo = 100, $titulo = "", $titulo2 = "")
 {
     $data = $this->mValues;
     $label = $this->mLabels;
     $g = new graph();
     $g->title($this->mTitle, '{font-size:16px; color: #FFFFFF; margin: 5px; background-color: #505050; padding:5px; padding-left: 20px; padding-right: 20px;}');
     //$g->set_data( $data_1 );
     //$g->bar_3D( 75, '#D54C78', '2006', 10 );
     //$g->set_data( $data_2 );
     //$g->bar_3D( 75, '#3334AD', '2007', 10 );
     //Crea el Bar Blue
     $bar_blue = new bar_3d(75, '#3334AD');
     $bar_blue->key($titulo, 10);
     $bar_blue->data = $this->mValues;
     $g->data_sets[] = $bar_blue;
     if (is_array($this->mValues2)) {
         $bar_blue2 = new bar_3d(75, '#ff0000');
         $bar_blue2->key($titulo2, 10);
         $bar_blue2->data = $this->mValues2;
         $g->data_sets[] = $bar_blue2;
     }
     $g->set_x_axis_3d(12);
     $g->x_axis_colour('#909090', '#ADB5C7');
     $g->y_axis_colour('#909090', '#ADB5C7');
     $g->set_x_labels($this->mLabels);
     $g->set_y_max($LimiteMaximo);
     $g->y_label_steps(5);
     //$g->set_y_legend( 'Open Flash Chart', 12, '#736AFF' );
     $x = $g->render();
     return $this->setWriteFile($x);
 }
Esempio n. 14
0
 function gmensuales($anio = '', $cliente = '')
 {
     $this->load->library('Graph');
     if (empty($anio) or empty($cliente)) {
         return;
     }
     $fechai = $anio . '0101';
     $fechaf = $anio . '1231';
     $mSQL = "SELECT cliente,nombres,DATE_FORMAT(fecha,'%m')AS mes, SUM(gtotal)AS grantotal, SUM(impuesto)AS impuesto \n\t\tFROM viefac                                                                    \n\t\tWHERE tipo<>'X' AND fecha>='{$fechai}' AND fecha<='{$fechaf}' AND cliente='{$cliente}'                 \n\t\tGROUP BY MONTH(fecha) ORDER BY fecha";
     //echo $mSQL;
     $maxval = 0;
     $query = $this->db->query($mSQL);
     foreach ($query->result() as $row) {
         if ($row->grantotal > $maxval) {
             $maxval = $row->grantotal;
         }
         $nombre = $row->nombres;
         $mes[] = $row->mes;
         $data_1[] = $row->grantotal;
     }
     $om = 1;
     while ($maxval / $om > 100) {
         $om = $om * 10;
     }
     $bar_1 = new bar(75, '#8E4B97');
     $bar_1->key('Total', 10);
     for ($i = 0; $i < count($data_1); $i++) {
         $bar_1->add_data_tip($data_1[$i] / $om, graph::esc(number_format($data_1[$i], 2, ',', '.')));
         //$bar_1->links[]= site_url("supermercado/clientes/diarias/$anio/$cliente/$mes[$i]");
     }
     $g = new graph();
     $g->set_is_decimal_separator_comma(1);
     if ($maxval > 0) {
         $g->title('Compras de el cliente ' . $nombre . ' en el a&ntilde;o ' . $anio, '{font-size: 16px; color:#0F3054}');
         $g->data_sets[] = $bar_1;
         $g->set_x_labels($mes);
         $g->set_x_label_style(10, '#000000', 3, 1);
         $g->set_x_axis_steps(10);
         $g->set_x_legend('Meses', 14, '#004381');
         $g->bg_colour = '#FFFFFF';
         $g->set_tool_tip('#key#<br>Mes: #x_label# <br>Monto: #tip#');
         $g->set_y_max(ceil($maxval / $om));
         $g->y_label_steps(5);
         $g->set_y_legend('supermercado x ' . number_format($om, 0, '', '.') . ' (Bs)', 16, '#004381');
     } else {
         $g->title('No existen ventas con los datos seleccionados', '{font-size:18px; color: #d01f3c}');
     }
     $g->bg_colour = '#FFFFFF';
     echo utf8_encode($g->render());
 }
Esempio n. 15
0
 function gdiarias($anio = '', $concep = '', $mes = '')
 {
     $this->load->library('Graph');
     $this->lang->load('calendar');
     if (empty($anio) or empty($concep)) {
         return;
     }
     $fechai = $anio . str_pad($mes, 2, "0", STR_PAD_LEFT) . '01';
     $fechaf = $anio . str_pad($mes, 2, "0", STR_PAD_LEFT) . '31';
     $mSQL = "SELECT a.fecha,a.concep,SUM(a.monto)AS grantotal,b.nombre,DATE_FORMAT(fecha,'%d') AS dia\n\t\tFROM est_pago  as a JOIN banc as b ON a.concep=b.codbanc\n\t\tWHERE fecha>='{$fechai}' AND fecha<='{$fechaf}' AND a.concep='{$concep}'\n\t\tGROUP BY fecha ORDER BY fecha ASC";
     //echo $mSQL;
     $maxval = 0;
     $query = $this->db->query($mSQL);
     foreach ($query->result() as $row) {
         if ($row->grantotal > $maxval) {
             $maxval = $row->grantotal;
         }
         $dia[] = $row->dia;
         $data_1[] = $row->grantotal;
     }
     $om = 1;
     while ($maxval / $om > 100) {
         $om = $om * 10;
     }
     $bar_1 = new bar(55, '#07A8E7');
     $bar_1->key('Monto', 10);
     for ($i = 0; $i < count($data_1); $i++) {
         $bar_1->add_data_tip($data_1[$i] / $om, graph::esc(number_format($data_1[$i], 2, ',', '.')));
     }
     $g = new graph();
     $g->set_is_decimal_separator_comma(1);
     if ($maxval > 0) {
         $g->title('Ventas de el' . $mes . '/' . $anio, 'concep de pago' . $concep, '{font-size: 16px; color:##00264A}');
         $g->data_sets[] = $bar_1;
         $g->x_axis_colour('#A6A6A6', '#ADB5C7');
         $g->set_x_labels($dia);
         $g->set_x_label_style(10, '#000000', 3, 1);
         $g->set_x_axis_steps(10);
         $g->set_x_legend('Dias', 14, '#004381');
         $g->bg_colour = '#FFFFFF';
         $g->set_tool_tip('#key#<br>Dia: #x_label# <br>Monto: #tip#');
         $g->set_y_max(ceil($maxval / $om));
         $g->y_label_steps(5);
         $g->y_axis_colour('#A6A6A6', '#ADB5C7');
         $g->set_y_legend('Ventas x ' . number_format($om, 0, '', '.') . ' (Bs)', 16, '#004381');
     } else {
         $g->title('No existen ventas con los datos seleccionados', '{font-size:18px; color: #d01f3c}');
     }
     $g->bg_colour = '#FFFFFF';
     echo utf8_encode($g->render());
 }
Esempio n. 16
0
 function gmensuales($anio = '', $mes = '')
 {
     $this->load->library('Graph');
     if (empty($mes) or empty($anio)) {
         return;
     }
     $fechai = $anio . str_pad($mes, 2, "0", STR_PAD_LEFT) . '01';
     $fechaf = $anio . str_pad($mes, 2, "0", STR_PAD_LEFT) . '31';
     $mSQL = "SELECT DAYOFMONTH(fecha)as dia, fecha,\n\t\tSUM(monto)AS grantotal,SUM(impuesto)AS IVA,SUM(transac)as transacciones \n\t\tfrom est_fecha where fecha>='{$fechai}' AND fecha<='{$fechaf}'\n\t\tGROUP BY  fecha                                                  \n\t\tORDER BY fecha ASC";
     //echo $mSQL;
     $maxval = 0;
     $query = $this->db->query($mSQL);
     foreach ($query->result() as $row) {
         if ($row->grantotal > $maxval) {
             $maxval = $row->grantotal;
         }
         $fecha[] = $row->dia;
         $data_1[] = $row->grantotal;
     }
     $om = 1;
     while ($maxval / $om > 100) {
         $om = $om * 10;
     }
     $bar_1 = new bar(75, '#44AC37');
     $bar_1->key('Monto', 10);
     for ($i = 0; $i < count($data_1); $i++) {
         $bar_1->add_data_tip($data_1[$i] / $om, graph::esc(number_format($data_1[$i], 2, ',', '.')));
     }
     $g = new graph();
     $g->set_is_decimal_separator_comma(1);
     if ($maxval > 0) {
         $g->title('Ventas de en el mes ' . $mes . '/' . $anio, '{font-size: 16px; color:##00264A}');
         $g->data_sets[] = $bar_1;
         $g->x_axis_colour('#A6A6A6', '#ADB5C7');
         $g->set_x_labels($fecha);
         $g->set_x_label_style(10, '#000000', 3, 1);
         $g->set_x_axis_steps(10);
         $g->set_x_legend('Dias', 14, '#004381');
         $g->bg_colour = '#FFFFFF';
         $g->set_tool_tip('#key#<br>Dia: #x_label# <br>Monto: #tip#');
         $g->set_y_max(ceil($maxval / $om));
         $g->y_label_steps(5);
         $g->y_axis_colour('#A6A6A6', '#ADB5C7');
         $g->set_y_legend('Ventas x ' . number_format($om, 0, '', '.') . ' (Bs)', 16, '#004381');
     } else {
         $g->title('No existen ventas con los datos seleccionados', '{font-size:18px; color: #d01f3c}');
     }
     $g->bg_colour = '#FFFFFF';
     echo utf8_encode($g->render());
 }
Esempio n. 17
0
 function grafico($anio = '', $codigo = '')
 {
     $this->load->library('Graph');
     if (empty($anio) or empty($codigo)) {
         return;
     }
     $fechai = $anio . '0101';
     $fechaf = $anio . '1231';
     $mSQL = "SELECT MONTHNAME(fecha)AS mes,codigo,nombre,sueldoa,sueldo FROM ausu\n    WHERE fecha>='{$fechai}' AND fecha<='{$fechaf}'AND codigo='{$codigo}'\n    ORDER BY fecha";
     //echo $mSQL;
     $maxval = 0;
     $query = $this->db->query($mSQL);
     foreach ($query->result() as $row) {
         if ($row->sueldoa > $maxval) {
             $maxval = $row->sueldoa;
         }
         $nombre = $row->nombre;
         $meses[] = $row->mes;
         $data_1[] = $row->sueldoa;
         $data_2[] = $row->sueldo;
         //$data_3[]=$row->sueldoa;
     }
     $om = 1;
     while ($maxval / $om > 100) {
         $om = $om * 10;
     }
     $bar_1 = new bar(75, '#0053A4');
     $bar_2 = new bar(75, '#9933CC');
     //$bar_3 = new bar(75, '#639F45');
     $bar_1->key('Sueldo Anterior', 10);
     $bar_2->key('Sueldo con Aumento', 10);
     //$bar_3->key('Total'  ,10);
     for ($i = 0; $i < count($data_1); $i++) {
         $bar_1->add_data_tip($data_1[$i] / $om, graph::esc(number_format($data_1[$i], 2, ',', '.')));
         $bar_2->add_data_tip($data_2[$i] / $om, graph::esc(number_format($data_2[$i], 2, ',', '.')));
         //$bar_3->add_data_tip($data_3[$i]/$om, graph::esc( number_format($data_3[$i],2,',','.')));
     }
     $g = new graph();
     $g->title('Aumento de ' . $nombre . ' en el a&ntilde;o ' . $anio, '{font-size: 20px; color:##00264A}');
     $g->set_is_decimal_separator_comma(1);
     $g->data_sets[] = $bar_1;
     $g->data_sets[] = $bar_2;
     //$g->data_sets[] = $bar_3;
     $g->set_x_labels($meses);
     $g->set_x_label_style(10, '#000000', 3, 1);
     $g->set_x_axis_steps(10);
     $g->set_x_legend('Meses', 16, '#004381');
     $g->bg_colour = '#FFFFFF';
     $g->set_tool_tip('#key#<br>Mes: #x_label# <br>Monto: #tip#');
     $g->set_y_max(ceil($maxval / $om));
     $g->y_label_steps(5);
     $g->set_y_legend('Ventas x ' . number_format($om, 0, '', '.') . ' (Bs)', 16, '#004381');
     echo utf8_encode($g->render());
 }
Esempio n. 18
0
 function gmensuales($anio = '', $dia = '')
 {
     $this->load->library('Graph');
     //$this->lang->load('calendar');
     //if (empty($mes) or empty($dia)) return;
     $fechai = $anio . '0101';
     $fechaf = $anio . '1231';
     $mSQL = "SELECT fecha,IF(WEEKDAY(fecha)=0,'Lunes',IF(WEEKDAY(fecha)=1,'Martes',IF(WEEKDAY(fecha)=2,'Miercoles',IF(WEEKDAY(fecha)=3,'Jueves',IF(WEEKDAY(fecha)=4,'Viernes',IF(WEEKDAY(fecha)=5,'Sabado','Domingo'))))))AS tdia,\n    DATE_FORMAT(fecha,'%m')AS mes,SUM(monto)AS grantotal,SUM(impuesto)AS IVA,SUM(transac)as transacciones \n\t\tFROM est_fecha WHERE fecha>='{$fechai}' AND fecha<='{$fechaf}'AND WEEKDAY(fecha)='{$dia}'\n\t\tGROUP BY  MONTH(fecha)\n\t\tORDER BY fecha ASC";
     //echo $mSQL;
     $maxval = 0;
     $query = $this->db->query($mSQL);
     foreach ($query->result() as $row) {
         if ($row->grantotal > $maxval) {
             $maxval = $row->grantotal;
         }
         $mes[] = $row->mes;
         $tdia = $row->tdia;
         $data_1[] = $row->grantotal;
     }
     $om = 1;
     while ($maxval / $om > 100) {
         $om = $om * 10;
     }
     $bar_1 = new bar_outline(50, '#56AC8B', '#3F7E66');
     $bar_1->key('Monto', 10);
     for ($i = 0; $i < count($data_1); $i++) {
         $bar_1->add_data_tip($data_1[$i] / $om, graph::esc(number_format($data_1[$i], 2, ',', '.')));
     }
     $g = new graph();
     $g->set_is_decimal_separator_comma(1);
     if ($maxval > 0) {
         $g->title('Ventas en el a&ntilde;o ' . $anio . ' del dia ' . $tdia, '{font-size: 16px; color:##00264A}');
         $g->data_sets[] = $bar_1;
         $g->x_axis_colour('#A6A6A6', '#ADB5C7');
         $g->set_x_labels($mes);
         $g->set_x_label_style(10, '#000000', 3, 1);
         $g->set_x_axis_steps(10);
         $g->set_x_legend('Mes', 14, '#004381');
         $g->bg_colour = '#FFFFFF';
         $g->set_tool_tip('#key#<br>Mes: #x_label# <br>Monto: #tip#');
         $g->set_y_max(ceil($maxval / $om));
         $g->y_label_steps(5);
         $g->y_axis_colour('#A6A6A6', '#ADB5C7');
         $g->set_y_legend('Ventas x ' . number_format($om, 0, '', '.') . ' (Bs)', 16, '#004381');
     } else {
         $g->title('No existen ventas con los datos seleccionados', '{font-size:18px; color: #d01f3c}');
     }
     $g->bg_colour = '#FFFFFF';
     echo utf8_encode($g->render());
 }
Esempio n. 19
0
 function gproducto($anio = '', $depto = '', $fami = '', $grupo = '')
 {
     $this->load->library('Graph');
     if (empty($anio)) {
         return;
     }
     $fechai = $anio . '0101';
     $fechaf = $anio . '1231';
     $mSQL = "SELECT a.codigo,a.depto,a.familia,a.grupo,e.descrip as nombre,\n\t\tSUM(a.monto) AS grantotal,  \n\t\tSUM(a.costo) AS costo,      \n\t\tSUM(a.cantidad) AS cantidad,\n\t\tSUM(a.monto)-SUM(a.costo) AS ganancia\n\t\tFROM  est_item AS a\n\t\tJOIN  maes AS e ON a.codigo= e.codigo\n\t\tWHERE a.fecha>='{$fechai}' AND a.fecha<='{$fechaf}' AND a.depto='{$depto}' AND a.familia='{$fami}' AND a.grupo='{$grupo}'\n\t\tGROUP BY a.codigo LIMIT 10";
     //echo $mSQL;
     $maxval = 0;
     $query = $this->db->query($mSQL);
     foreach ($query->result() as $row) {
         if ($row->grantotal > $maxval) {
             $maxval = $row->grantotal;
         }
         $nombre[] = $row->nombre;
         $famili = $row->famili;
         $dpto = $row->dpto;
         $grup = $row->grup;
         $data_1[] = $row->grantotal;
         $data_2[] = $row->ganancia;
     }
     $om = 1;
     while ($maxval / $om > 100) {
         $om = $om * 10;
     }
     $bar_1 = new bar_fade(55, '#C31812');
     $bar_2 = new bar_fade(55, '#424581');
     $bar_1->key('Total', 10);
     $bar_2->key('Ganancias', 10);
     for ($i = 0; $i < count($data_1); $i++) {
         $bar_1->add_data_tip($data_1[$i] / $om, graph::esc(number_format($data_1[$i], 2, ',', '.')));
         $bar_2->add_data_tip($data_2[$i] / $om, graph::esc(number_format($data_2[$i], 2, ',', '.')));
     }
     $g = new graph();
     $g->set_is_decimal_separator_comma(1);
     if ($maxval > 0) {
         $g->title('Ventas de el a&ntilde;o ' . $anio, '{font-size: 16px; color:#0F3054}');
         $g->data_sets[] = $bar_1;
         $g->data_sets[] = $bar_2;
         $g->set_x_labels($nombre);
         $g->set_x_label_style(10, '#000000', 2, 1);
         $g->set_x_axis_steps(10);
         $g->set_x_legend('Productos', 14, '#004381');
         $g->bg_colour = '#FFFFFF';
         $g->set_tool_tip('#key#<br>Producto: #x_label# <br>Monto: #tip#');
         $g->set_y_max(ceil($maxval / $om));
         $g->y_label_steps(5);
         $g->set_y_legend('Ventas x ' . number_format($om, 0, '', '.') . ' (Bs)', 16, '#004381');
     } else {
         $g->title('No existen ventas en el a&ntilde;o seleccionado', '{font-size:18px; color: #d01f3c}');
     }
     $g->bg_colour = '#FFFFFF';
     echo utf8_encode($g->render());
 }
Esempio n. 20
0
 function gdiarias($anio = '', $producto = '', $mes = '')
 {
     $this->load->library('Graph');
     $this->lang->load('calendar');
     if (empty($anio)) {
         return;
     }
     $producto = radecode($producto);
     $fechai = $anio . str_pad($mes, 2, "0", STR_PAD_LEFT) . '01';
     $fechaf = $anio . str_pad($mes, 2, "0", STR_PAD_LEFT) . '31';
     //echo "fechai=".$fechai;
     //echo "fechaf=".$fechaf;
     $mSQL = "SELECT codigo, LEFT(descrip,20)AS nombre,DAYOFMONTH(a.fecha) as dia,\n    SUM(cantidad)AS cantidad,\n    SUM(importe)AS grantotal\n    FROM itscst  AS a\n    WHERE fecha>='{$fechai}' AND fecha<='{$fechaf}' AND codigo='{$producto}'\n    GROUP BY dia ORDER BY fecha";
     //echo $mSQL;
     $maxval = 0;
     $query = $this->db->query($mSQL);
     foreach ($query->result() as $row) {
         if ($row->grantotal > $maxval) {
             $maxval = $row->grantotal;
         }
         $fecha[] = $row->dia;
         $nombre = $row->nombre;
         $data_1[] = $row->grantotal;
     }
     $om = 1;
     while ($maxval / $om > 100) {
         $om = $om * 10;
     }
     $bar_1 = new bar(75, '#ADD8E6');
     $bar_1->key('Compras', 10);
     for ($i = 0; $i < count($data_1); $i++) {
         $bar_1->add_data_tip($data_1[$i] / $om, graph::esc(number_format($data_1[$i], 2, ',', '.')));
     }
     $g = new graph();
     $g->set_is_decimal_separator_comma(1);
     if ($maxval > 0) {
         $g->title('Compra de ' . $nombre . ' en el mes ' . $mes . '/' . $anio, '{font-size: 16px; color:##00264A}');
         $g->data_sets[] = $bar_1;
         $g->set_x_labels($fecha);
         $g->set_x_label_style(9, '#000000', 3, 1);
         $g->set_x_axis_steps(10);
         $g->x_axis_colour('#A6A6A6', '#ADB5C7');
         $g->set_x_legend('Dias', 16, '#004381');
         $g->bg_colour = '#FFFFFF';
         $g->set_tool_tip('#key#<br>Dia: #x_label# <br>Monto: #tip#');
         $g->set_y_max(ceil($maxval / $om));
         $g->y_label_steps(5);
         $g->y_axis_colour('#A6A6A6', '#ADB5C7');
         $g->set_y_legend('Compras x ' . number_format($om, 0, '', '.') . ' (Bs)', 16, '#004381');
     } else {
         $g->title('No existen compras con los datos seleccionados', '{font-size:18px; color: #d01f3c}');
     }
     $g->bg_colour = '#FFFFFF';
     echo utf8_encode($g->render());
 }
Esempio n. 21
0
$ofc = $g->render();
/****************** bar de la catégorie sur l'année */
$g = new graph();
$g->title("{$cat_name}", '{font-size:20px; color: #bcd6ff; margin:10px;}');
$color = $oCat->getColor($cat_id);
$bar = new bar_glass(55, "{$color}", "{$color}");
$bar->data = $cat_annee;
$g->data_sets[] = $bar;
// label the X axis (10 labels for 10 bars):
$g->set_x_labels(array('January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October'));
// colour the chart to make it pretty:
$g->x_axis_colour('#909090', '#D2D2FB');
$g->y_axis_colour('#909090', '#D2D2FB');
$g->set_y_min(0);
$g->set_y_max(max_tab($cat_annee));
$g->y_label_steps(6);
$g->set_y_legend('Open Flash Chart', 12, '#736AFF');
$g->set_width(650);
$g->set_height(400);
$g->set_output_type('js');
$ofc3 = $g->render();
/***********************************/
/************* Camembert sur l'année de toutes les catégories ***************************/
$pie = new graph();
//
// PIE chart, 60% alpha
//
$pie->pie(60, '#505050', '{font-size: 12px; color: #404040;');
//
// pass in two arrays, one of data, the other data labels
//
Esempio n. 22
0
 function grafico4($codigoadm, $partida)
 {
     $this->load->library('Graph');
     $mSQL = "SELECT codigopres,a.ordinal, \r\n\t\t\t\t\tSUM(asignacion+aumento-disminucion+traslados) as presupuesto, \r\n\t\t                        SUM(comprometido) comprometido, \r\n\t\t                        SUM(causado) causado, \r\n\t\t                        SUM(pagado) pagado\r\n\t\tFROM ordinal a JOIN ppla b ON a.codigopres=b.codigo\r\n\t\tWHERE b.movimiento='S' AND a.codigoadm='{$codigoadm}' AND codigopres LIKE '{$partida}%'\r\n\t\tGROUP BY codigopres,a.ordinal\r\n\t\tHAVING presupuesto<>0";
     $maxval = 0;
     $query = $this->db->query($mSQL);
     foreach ($query->result() as $row) {
         if ($row->presupuesto > $maxval) {
             $maxval = $row->presupuesto;
         }
         $codigopres[] = $row->ordinal;
         $data_1[] = $row->presupuesto;
         $data_2[] = $row->comprometido;
         $data_3[] = $row->causado;
         $data_4[] = $row->pagado;
     }
     $om = 1;
     while ($maxval / $om > 100) {
         $om = $om * 10;
     }
     $bar_1 = new bar(75, '#0053A4');
     $bar_2 = new bar(75, '#9933CC');
     $bar_3 = new bar(75, '#639F45');
     $bar_4 = new bar(75, '#C34F33');
     $bar_1->key('Presupuesto', 10);
     $bar_2->key('Comprometido', 10);
     $bar_3->key('Causado', 10);
     $bar_4->key('Pagado', 10);
     for ($i = 0; $i < count($data_1); $i++) {
         $bar_1->add_data_tip($data_1[$i] / $om, graph::esc(number_format($data_1[$i], 2, ',', '.')));
         $bar_2->add_data_tip($data_2[$i] / $om, graph::esc(number_format($data_2[$i], 2, ',', '.')));
         $bar_3->add_data_tip($data_3[$i] / $om, graph::esc(number_format($data_3[$i], 2, ',', '.')));
         $bar_4->add_data_tip($data_4[$i] / $om, graph::esc(number_format($data_4[$i], 2, ',', '.')));
     }
     $g = new graph();
     $g->set_is_decimal_separator_comma(1);
     if ($maxval > 0) {
         $g->data_sets[] = $bar_1;
         $g->data_sets[] = $bar_2;
         $g->data_sets[] = $bar_3;
         $g->data_sets[] = $bar_4;
         $g->set_x_labels($codigopres);
         $g->set_x_label_style(10, '#000000', 2, 1);
         $g->set_x_axis_steps(10);
         $g->set_x_legend('Presupuestos', 14, '#004381');
         $g->bg_colour = '#FFFFFF';
         $g->set_tool_tip('#key#<br>Codigo: #x_label# <br>Monto: #tip#');
         $g->set_y_max(ceil($maxval / $om));
         $g->y_label_steps(5);
         $g->set_y_legend('Presupuesto x ' . number_format($om, 0, '', '.') . ' (Bs)', 16, '#004381');
     } else {
         $g->title('No existen Presupuestos', '{font-size:18px; color: #d01f3c}');
     }
     $g->bg_colour = '#FFFFFF';
     echo utf8_encode($g->render());
 }
Esempio n. 23
0
 function grafico($codigo = '', $mes = '', $anio = '')
 {
     $this->load->library('Graph');
     if (empty($mes) and empty($anio)) {
         return;
     }
     $fechad = $anio . str_pad($mes, 2, "0", STR_PAD_LEFT) . '01';
     $fechah = $anio . str_pad($mes, 2, "0", STR_PAD_LEFT) . '31';
     $mSQL = "SELECT DATE_FORMAT(fecha, '%d')as fecha, codigo, sum(cantidad) cantidad, IF(sum(cantidad)<=salcant,sum(cantidad),salcant)*(salcant>0)as salcant \n\t\tFROM costos \n\t\tWHERE codigo='{$codigo}' AND fecha>='{$fechad}' AND fecha<='{$fechah}' AND origen='3I'\n\t\tGROUP BY fecha HAVING cantidad>0";
     echo $mSQL;
     $maxval = 0;
     $query = $this->db->query($mSQL);
     foreach ($query->result() as $row) {
         if ($row->cantidad > $maxval) {
             $maxval = $row->cantidad;
         }
         $fecha[] = $row->fecha;
         $codigo = $row->codigo;
         $data_1[] = $row->cantidad;
         $data_2[] = $row->salcant;
     }
     $fechadd = dbdate_to_human($fechad);
     $fechahh = dbdate_to_human($fechah);
     $nombre = $this->datasis->dameval("SELECT descrip FROM sinv WHERE codigo='{$codigo}'");
     $om = 1;
     while ($maxval / $om > 100) {
         $om = $om * 10;
     }
     $bar_1 = new bar_glass(55, '#D54C78', '#C31812');
     $bar_1->key('Ventas', 10);
     $bar_2 = new line_dot(3, 5, '#0066CC', 'Downloads', 10);
     $bar_2->key('Existencias', 10);
     for ($i = 0; $i < count($data_1); $i++) {
         $bar_1->add_data_tip($data_1[$i] / $om, graph::esc(number_format($data_1[$i], 2, ',', '.')));
         $bar_2->add_data_tip($data_2[$i] / $om, graph::esc(number_format($data_2[$i], 2, ',', '.')));
         //  $bar_1->links[]= site_url("/inventario/gproductos/mensuales/$anio/".str_replace('/',':slach:',$proveed[$i]));
         //  $bar_1->links[]= site_url("/inventario/gproductos/mensuales/$anio/".raencode($proveed[$i]));
     }
     $g = new graph();
     $g->set_is_decimal_separator_comma(1);
     if ($maxval > 0) {
         $g->title('Grafico de ' . $nombre . ' Desde ' . $fechadd . ' Hasta ' . $fechahh, '{font-size: 16px; color:#0F3054}');
         $g->data_sets[] = $bar_1;
         $g->data_sets[] = $bar_2;
         $g->set_x_labels($fecha);
         $g->set_x_label_style(10, '#000000', 2, 1);
         $g->set_x_axis_steps(10);
         $g->set_x_legend('Fecha', 14, '#004381');
         $g->bg_colour = '#FFFFFF';
         $g->set_tool_tip('#key#<br>Fecha: #x_label# <br>Cantidad: #tip#');
         $g->set_y_max(ceil($maxval / $om));
         $g->y_label_steps(5);
         //$g->set_y_legend('Ventas x '.number_format($om,0,'','.').' (Bs)', 16, '#004381' );
     } else {
         $g->title('No existen datos con la informacion seleccionada', '{font-size:18px; color: #d01f3c}');
     }
     $g->bg_colour = '#FFFFFF';
     echo utf8_encode($g->render());
 }
Esempio n. 24
0
 /**
  * Generates report of projects created
  *
  * @access	public
  * @param	nil
  * @return	void
  */
 function projectsCreated()
 {
     //Load Language File For this
     $this->lang->load('enduser/reports', $this->config->item('language_code'));
     //Load Library File
     $this->load->library('graph');
     // generate some random data
     srand((double) microtime() * 1000000);
     // NOTE: how we are filling 3 arrays full of data,
     //       one for each line on the graph
     $data_1 = array();
     $mon = array();
     for ($i = 0; $i < 6; $i++) {
         $lastmonth = mktime(0, 0, 0, date("m") - $i, date("d"), date("Y"));
         $month = date('n', $lastmonth);
         $year = date('Y', $lastmonth);
         $data_1[] = $this->skills_model->getNumProjectsByMonth($month, $year);
         $mon[] = date('M', $lastmonth);
     }
     $g = new graph();
     $g->title($this->lang->line('Projects added last 6 months'), '{font-size: 20px; color: #999999}');
     // we add 2 sets of data:
     $g->set_data($data_1);
     $g->set_bg_colour('0xFFFFFF');
     // we add the 3 line types and key labels
     $g->line_dot(3, 5, 'FF6633', 'Projects', 12);
     // <-- 3px thick + dots
     $g->set_x_labels($mon);
     $g->set_x_label_style(10, '0x000000', 0, 1);
     $g->set_y_max(50);
     $g->y_label_steps(4);
     echo $g->render();
 }
Esempio n. 25
0
 function gproducto($anio = '', $departamento = '', $linea = '', $grupo = '')
 {
     $this->load->library('Graph');
     $this->load->library('calendar');
     //$this->calendar->generate();
     if (empty($anio) or empty($departamento) or empty($linea) or empty($grupo)) {
         return;
     }
     $fechai = $anio . '0101';
     $fechaf = $anio . '1231';
     $mSQL = "SELECT a.fecha,b.codigo,b.descrip AS nnombre,LEFT(b.descrip,20)AS nombre,e.depto,e.descrip,d.linea,d.descrip,b.grupo,b.descrip,c.nom_grup as ngrupo,\n    SUM(a.promedio*a.cantidad) AS costo,\n    SUM(a.venta) AS ventas,\n    SUM(a.venta)-SUM(a.promedio*a.cantidad) AS ganancias\n    FROM {$this->from} ";
     foreach ($this->join as $valor) {
         $mSQL .= "{$valor['2']} JOIN {$valor['0']} ON {$valor['1']}";
     }
     $mSQL .= " WHERE a.origen IN ('3I','3M') AND a.fecha>='{$fechai}' AND a.fecha<='{$fechaf}' AND e.depto='{$departamento}' AND d.linea='{$linea}' AND b.grupo='{$grupo}'\n    GROUP BY a.codigo ORDER BY ganancias DESC LIMIT 15";
     //echo $mSQL;
     $maxval = 0;
     $query = $this->db->query($mSQL);
     foreach ($query->result() as $row) {
         if ($row->ganancias > $maxval) {
             $maxval = $row->ganancias;
         }
         $nombre[] = $row->nombre;
         $data_1[] = $row->ganancias;
     }
     $ngrupo = $row->ngrupo;
     $om = 1;
     while ($maxval / $om > 100) {
         $om = $om * 10;
     }
     $bar_1 = new bar(75, '#639F45');
     $bar_1->key('Ganancias', 10);
     for ($i = 0; $i < count($data_1); $i++) {
         $bar_1->add_data_tip($data_1[$i] / $om, graph::esc(number_format($data_1[$i], 2, ',', '.')));
         //$bar_1->links[]= site_url("ventas/gananciasproducto/index/$anio/$departamento/".$linea[$i]);
     }
     $g = new graph();
     $g->set_is_decimal_separator_comma(1);
     if ($maxval > 0) {
         $g->title('Ganancias por producto de el grupo ' . $ngrupo . ' en el a&ntilde;o ' . $anio, '{font-size: 16px; color:#0F3054}');
         $g->data_sets[] = $bar_1;
         $g->set_x_axis_3d(5);
         $g->x_axis_colour('#909090', '#ADB5C7');
         $g->set_x_labels($nombre);
         $g->set_x_label_style(10, '#000000', 2, 1);
         $g->set_x_axis_steps(10);
         $g->set_x_legend('Productos', 14, '#004381');
         $g->y_axis_colour('#909090', '#ADB5C7');
         $g->bg_colour = '#FFFFFF';
         $g->set_tool_tip('#key#<br>Producto: #x_label# <br>Monto: #tip#');
         $g->set_y_max(ceil($maxval / $om));
         $g->y_label_steps(5);
         $g->set_y_legend('Ganancia x ' . number_format($om, 0, '', '.') . ' (Bs)', 16, '#004381');
     } else {
         $g->title('No existen ganancias con los datos seleccionados', '{font-size:18px; color: #d01f3c}');
     }
     $g->bg_colour = '#FFFFFF';
     echo utf8_encode($g->render());
 }
Esempio n. 26
0
} elseif ($racine == 'biodiv') {
    $g->set_x_labels(array('1992', '1993', '1994', '1995', '1996', '1997', '1998', '1999', '2000', '2001', '2002', '2003', '2004', '2005', '2006', '2007', '2008', '2009'));
} else {
    $g->set_x_labels($xlab);
}
if ($type_date = 'annee') {
    $g->set_x_labels($xlab_an);
}
if ($type_date = 'jour') {
    $g->set_x_labels($xlab);
}
echo '<br><br>';
print_r($xlab);
echo '<br><br>';
//$max_data = ceil(max($data_propre) * 1.1);
//echo ceil(ceil(max($data_propre) * 1.10)/$steps_nb);
echo 'on en est là:';
//print_r(array_keys);
echo ceil(max(array_keys($data_propre)) * 1.1);
echo 'on en est là.';
$max_data = intval(ceil(ceil(max($data_propre) * 1.1) / $steps_nb)) * $steps_nb;
echo $max_data;
echo 'on en est là.';
$g->set_y_max($max_data);
$g->y_label_steps(min($max_data, $steps_nb));
// display the data
echo $g->render();
?>


Esempio n. 27
0
function PN_BlogStatisticsProcess($target)
{
    global $blogid, $pluginURL, $defaultURL, $blog;
    if (doesHaveOwnership()) {
        include_once 'lib/open-flash-chart.php';
        $grpStyle = $_GET['grpStyle'];
        $grpData = explode("|", $_GET['grpData']);
        $grpTotal = $_GET['grpTotal'];
        $grpYear = $_GET['grpYear'];
        $grpTypeName = $_GET['grpTypeName'];
        $grpLinkType = $_GET['grpLinkType'];
        $grpXLabelType = isset($_GET['grpXLabelType']) ? $_GET['grpXLabelType'] : 0;
        $grpLabel = explode("|", $_GET['grpLabel']);
        $grpSubTitle = array();
        $grpLabelTemp = array();
        if (!empty($_GET['grpData'])) {
            if ($grpTypeName == "category") {
                for ($i = 0; $i < count($grpLabel); $i++) {
                    $grpSubTitle[] = rawurlencode($grpLabel[$i] == 0 ? _t('분류없음') : htmlspecialchars(UTF8::lessenAsEm(getCategoryNameById($blogid, $grpLabel[$i]), 15)));
                }
            } else {
                if ($grpTypeName == "hits" || $grpTypeName == "cmmax" || $grpTypeName == "tbmax" || $grpTypeName == "tagmax") {
                    for ($i = 0; $i < count($grpLabel); $i++) {
                        $grpSubTitle[] = rawurlencode(htmlspecialchars(UTF8::lessenAsEm(str_replace(",", "-", getEntryTitleById($blogid, $grpLabel[$i])), 25)));
                    }
                } else {
                    if ($grpTypeName == "commenter" || $grpTypeName == "tag") {
                        for ($i = 0; $i < count($grpLabel); $i++) {
                            $grpSubTitle[] = htmlspecialchars(UTF8::lessenAsEm($grpLabel[$i], 15));
                            $grpLabelTemp[] = htmlspecialchars(UTF8::lessenAsEm($grpLabel[$i], 6, ''));
                        }
                        $grpLabel = $grpLabelTemp;
                    } else {
                        if ($grpTypeName == "time") {
                            for ($i = 0; $i < count($grpLabel); $i++) {
                                $grpSubTitle[] = rawurlencode($grpLabel[$i] . "시");
                            }
                        } else {
                            if ($grpTypeName == "refer") {
                                for ($i = 0; $i < count($grpLabel); $i++) {
                                    $tmpHost = explode('.', $grpLabel[$i]);
                                    $tmpHostCnt = count($tmpHost) - 1;
                                    $tmpDomain = (strlen($tmpHost[$tmpHostCnt]) < 3 ? $tmpHost[$tmpHostCnt - 2] . '.' : '') . $tmpHost[$tmpHostCnt - 1] . '.' . $tmpHost[$tmpHostCnt];
                                    $cutDomain = explode('.', $tmpDomain);
                                    $grpSubTitle[] = htmlspecialchars($grpLabel[$i]);
                                    $grpLabelTemp[] = htmlspecialchars(UTF8::lessenAsEm($cutDomain[0], 6, ''));
                                }
                                $grpLabel = $grpLabelTemp;
                            } else {
                                if ($grpTypeName == "referkey") {
                                    for ($i = 0; $i < count($grpLabel); $i++) {
                                        $tmpLabel = explode('(', $grpLabel[$i]);
                                        $grpSubTitle[] = htmlspecialchars(UTF8::lessenAsEm($grpLabel[$i], 15));
                                        $grpLabelTemp[] = htmlspecialchars(UTF8::lessenAsEm($tmpLabel[0], 6, ''));
                                    }
                                    $grpLabel = $grpLabelTemp;
                                }
                            }
                        }
                    }
                }
            }
            $g = new graph();
            $g->bg_colour = '#FFFFFF';
            if ($grpStyle == "pie") {
                $grpClickLink = "";
                $grpPercent = array();
                $grpLink = array();
                for ($i = 0; $i < count($grpData); $i++) {
                    $grpPercent[] = round($grpData[$i] / $grpTotal * 100, 0);
                }
                if ($grpLinkType == "archiveYear") {
                    for ($i = 0; $i < count($grpLabel); $i++) {
                        $permalink = $defaultURL . "/archive/" . substr($grpLabel[$i], 0, 4);
                        $grpLink[] = "javascript:window.open('{$permalink}');void(0)";
                    }
                    $grpClickLink = "<br>click on the pie.";
                } else {
                    if ($grpLinkType == "archiveMonth" && $grpYear != "9999") {
                        for ($i = 0; $i < count($grpLabel); $i++) {
                            $cutMonth = str_replace("월", "", $grpLabel[$i]);
                            $tmpMonth = strlen($cutMonth) == 1 ? "0" . $cutMonth : $cutMonth;
                            $permalink = $defaultURL . "/archive/" . $grpYear . $tmpMonth;
                            $grpLink[] = "javascript:window.open('{$permalink}');void(0)";
                        }
                        $grpClickLink = "<br>click on the pie.";
                    } else {
                        if ($grpLinkType == "category") {
                            for ($i = 0; $i < count($grpLabel); $i++) {
                                $permalink = $defaultURL . "/category/" . getCategoryLabelById($blogid, $grpLabel[$i]);
                                $grpLink[] = "javascript:window.open('{$permalink}');void(0)";
                            }
                            $grpClickLink = "<br>click on the pie.";
                        } else {
                            if ($grpLinkType == "entry") {
                                for ($i = 0; $i < count($grpLabel); $i++) {
                                    $permalink = $defaultURL . ($blog['useSlogan'] ? "/entry/" . getEntrySloganById($blogid, $grpLabel[$i]) : "/" . $grpLabel[$i]);
                                    $grpLink[] = "javascript:window.open('{$permalink}');void(0)";
                                }
                                $grpClickLink = "<br>click on the pie.";
                            } else {
                                if ($grpLinkType == "tag") {
                                    for ($i = 0; $i < count($grpLabel); $i++) {
                                        $permalink = $defaultURL . "/tag/" . $grpLabel[$i];
                                        $grpLink[] = "javascript:window.open('{$permalink}');void(0)";
                                    }
                                    $grpClickLink = "<br>click on the pie.";
                                }
                            }
                        }
                    }
                }
                $g->pie(75, '#ffffff', '#000000', false, 1);
                $g->pie_values($grpData, $grpLabel, $grpLink, $grpSubTitle);
                $g->pie_slice_colours(array('#B9D2E6', '#E2B11C', '#A3CF22', '#EC7122', '#4FC0C0', '#D45E5E', '#A275A2', '#52A7D2', '#9F373B', '#B4ADA5', '#5FC97E', '#CFB85D', '#9DC64E', '#FFAB29', '#E23838', '#43CEA9', '#4CA9D9', '#BA4ECA', '#6C79DA', '#CCCCCC', '#AB5C06', '#C06868', '#5FC97E', 'CFB85D'));
                $g->set_tool_tip((count($grpSubTitle) ? '#x_title#<br>' : '#x_label#<br>') . '#val#(#percent#%25)' . $grpClickLink);
            } else {
                if ($grpStyle == "bar") {
                    $g->title('&nbsp;', '{font-size:12px; color:#000000;margin-top:0px;padding:3px;}');
                    $g->set_data($grpData);
                    $g->set_bar_titles($grpSubTitle);
                    $g->bar_glass(70, '#68B1D9', '#62A0C1', '', 12);
                    $g->bar_colours(array('#B9D2E6', '#E2B11C', '#A3CF22', '#EC7122', '#4FC0C0', '#D45E5E', '#A275A2', '#52A7D2', '#9F373B', '#B4ADA5', '#5FC97E', '#CFB85D', '#9DC64E', '#FFAB29', '#E23838', '#43CEA9', '#4CA9D9', '#BA4ECA', '#6C79DA', '#CCCCCC', '#AB5C06', '#C06868', '#5FC97E', 'CFB85D'));
                    $g->x_axis_colour('#909090', '#D2D2FB');
                    $g->y_axis_colour('#909090', '#D2D2FB');
                    $g->set_x_labels($grpLabel);
                    $g->set_x_label_style(10, '#000000', $grpXLabelType, -1);
                    $g->set_y_label_style(9, '#888888');
                    $tmp_data_max = floor(Max($grpData) * 1.2);
                    if ($tmp_y_max = $tmp_data_max % 10) {
                        $tmp_data_max = $tmp_data_max + (10 - $tmp_y_max);
                    }
                    $g->set_y_max($tmp_data_max);
                    $g->set_y_legend('', 11, '#736AFF');
                    $g->set_tool_tip((count($grpSubTitle) ? '#x_title#<br>' : '#x_label#<br>') . '#val#');
                } else {
                    if ($grpStyle == "line") {
                        $g->title('', '{font-size:1px; color:#000000;}');
                        $g->set_data($grpData);
                        $g->line_dot(2, 4, '#6FBBC6', _t('최근 7일간 방문자 수'), 11);
                        // <-- 3px thick + dots
                        $g->set_x_labels($grpLabel);
                        $g->set_x_label_style(8, '#333333', $grpXLabelType, -1);
                        $g->x_axis_colour('#909090', '#e7e7e7');
                        $g->y_axis_colour('#909090', '#e7e7e7');
                        $tmp_data_max = floor(Max($grpData) * 1.2);
                        if ($tmp_y_max = $tmp_data_max % 10) {
                            $tmp_data_max = $tmp_data_max + (10 - $tmp_y_max);
                        }
                        $g->set_y_max($tmp_data_max);
                        $g->set_y_legend('', 1, '#736AFF');
                        $g->y_label_steps(4);
                        $g->set_y_label_style(8, '#333333', $grpXLabelType, -1);
                        $g->set_tool_tip((count($grpSubTitle) ? '#x_title#<br>' : '#x_label#<br>') . '#val#');
                    }
                }
            }
            echo $g->render();
            flush();
        }
    }
}
Esempio n. 28
0
 function gdiarias($anio = '', $producto = '', $mes = '')
 {
     $this->load->library('Graph');
     if (empty($mes) or empty($anio) or empty($producto)) {
         return;
     }
     $fechai = $anio . str_pad($mes, 2, "0", STR_PAD_LEFT) . '01';
     $fechaf = $anio . str_pad($mes, 2, "0", STR_PAD_LEFT) . '31';
     $mSQL = "SELECT a.codigo AS codigo,b.descrip AS nombre,DAYOFMONTH(a.fecha) as dia,a.cantidad AS cantidad,\n    SUM(a.venta)AS grantotal \n    FROM  costos AS a \n    JOIN  maes AS b ON a.codigo=b.codigo\n    WHERE a.fecha >='{$fechai}' AND a.fecha <='{$fechaf}' AND a.codigo='{$producto}'\n    GROUP BY fecha ORDER BY grantotal DESC";
     echo $mSQL;
     $maxval = 0;
     $query = $this->db->query($mSQL);
     foreach ($query->result() as $row) {
         if ($row->grantotal > $maxval) {
             $maxval = $row->grantotal;
         }
         $fecha[] = $row->dia;
         $data_1[] = $row->grantotal;
     }
     $nombre = $row->nombre;
     $om = 1;
     while ($maxval / $om > 100) {
         $om = $om * 10;
     }
     $bar_1 = new bar(75, '#0F235F');
     $bar_1->key('supermercado', 10);
     for ($i = 0; $i < count($data_1); $i++) {
         $bar_1->add_data_tip($data_1[$i] / $om, graph::esc(number_format($data_1[$i], 2, ',', '.')));
     }
     $g = new graph();
     $g->set_is_decimal_separator_comma(1);
     if ($maxval > 0) {
         $g->title('Ventas de ' . $nombre . '  en el mes ' . $mes . '/' . $anio, '{font-size: 16px; color:#0F3054}');
         $g->data_sets[] = $bar_1;
         $g->set_x_labels($fecha);
         $g->set_x_label_style(10, '#000000', 3, 1);
         $g->set_x_axis_steps(10);
         $g->set_x_legend('Dias', 14, '#004381');
         $g->bg_colour = '#FFFFFF';
         $g->set_tool_tip('#key#<br>Dia: #x_label# <br>Monto: #tip#');
         $g->set_y_max(ceil($maxval / $om));
         $g->y_label_steps(5);
         $g->set_y_legend('supermercado x ' . number_format($om, 0, '', '.') . ' (Bs)', 16, '#004381');
     } else {
         $g->title('No existen ventas con los datos seleccionados', '{font-size:18px; color: #d01f3c}');
     }
     $g->bg_colour = '#FFFFFF';
     echo utf8_encode($g->render());
 }
Esempio n. 29
0
 function grafico($anio = '')
 {
     $this->load->library('Graph');
     $this->lang->load('calendar');
     if (empty($anio)) {
         return;
     }
     $fechai = $anio . '0101';
     $fechaf = $anio . '1231';
     $mSQL = "SELECT MONTHNAME(fecha)AS mes,\n\t\tAVG(sueldoa) AS anterior,\n\t\tAVG(sueldo)  AS actual\n\t\tFROM ausu\n\t\tWHERE fecha>='{$fechai}' AND fecha<='{$fechaf}'\n\t\tGROUP BY mes ORDER BY fecha";
     //echo $mSQL;
     $maxval = 0;
     $query = $this->db->query($mSQL);
     foreach ($query->result() as $row) {
         if ($row->anterior > $maxval) {
             $maxval = $row->anterior;
         }
         $nmes[] = $this->lang->line('cal_' . strtolower($row->mes));
         $data_1[] = $row->anterior;
         $data_2[] = $row->actual;
         //$data_3[]=$row->actual;
     }
     $om = 1;
     while ($maxval / $om > 100) {
         $om = $om * 10;
     }
     $bar_1 = new bar(75, '#0053A4');
     $bar_2 = new bar(75, '#9933CC');
     $bar_3 = new bar(75, '#639F45');
     $bar_1->key('Sueldo Anterior', 10);
     $bar_2->key('Sueldo con Aumento', 10);
     //$bar_3->key('Total'  ,10);
     for ($i = 0; $i < count($data_1); $i++) {
         $bar_1->add_data_tip($data_1[$i] / $om, graph::esc(number_format($data_1[$i], 2, ',', '.')));
         $bar_2->add_data_tip($data_2[$i] / $om, graph::esc(number_format($data_2[$i], 2, ',', '.')));
         $bar_3->add_data_tip($data_3[$i] / $om, graph::esc(number_format($data_3[$i], 2, ',', '.')));
     }
     $g = new graph();
     $g->title('Promedio de Aumento de Sueldos en el a&ntilde;o ' . $anio, '{font-size: 22px; color:##00264A}');
     $g->set_is_decimal_separator_comma(1);
     $g->data_sets[] = $bar_1;
     $g->data_sets[] = $bar_2;
     $g->data_sets[] = $bar_3;
     $g->set_x_labels($nmes);
     $g->set_x_label_style(9, '#000000', 3, 1);
     $g->set_x_axis_steps(8);
     $g->set_x_legend('Meses ', 16, '#004381');
     $g->bg_colour = '#FFFFFF';
     $g->set_tool_tip('#key#<br>Mes: #x_label# <br>Monto: #tip#');
     $g->set_y_max(ceil($maxval / $om));
     $g->y_label_steps(5);
     $g->set_y_legend('Sueldo x ' . number_format($om, 0, '', '.') . ' (Bs)', 16, '#004381');
     echo utf8_encode($g->render());
 }
 function PostByUserFlash()
 {
     $dataSet = $this->getPostByUser();
     $data = $dataSet['data'];
     $g = new graph();
     $g->title(' Posts by User last week ' . date("Y-m-d"), '{font-size: 16px;}');
     $max = 1;
     foreach ($dataSet['data'] as $k => $val) {
         if ($val > $max) {
             $max = $val;
         }
     }
     $max = intval($max / 4) * 4 + 4;
     $bar_red = new bar_3d(50, '#356aa0');
     $bar_red->key('posts', 10);
     $bar_red->data = $data;
     $bar_blue = new bar_3d(75, '#D54C78');
     $bar_blue->key('completed', 10);
     $bar_blue->data = $data;
     $g->data_sets[] = $bar_red;
     //$g->data_sets[] = $bar_blue;
     $g->set_x_axis_3d(12);
     $g->x_axis_colour('#909090', '#ADB5C7');
     $g->y_axis_colour('#909090', '#ADB5C7');
     $g->set_x_labels($dataSet['label']);
     $g->set_y_max($max);
     $g->y_label_steps(4);
     $g->set_y_legend('Processmaker', 12, '#736AFF');
     echo $g->render();
 }