Ejemplo n.º 1
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());
 }
Ejemplo n.º 2
0
 function gdiarias($anio = '', $caja = '', $mes = '')
 {
     $this->load->library('Graph');
     $this->lang->load('calendar');
     if (empty($anio) or empty($caja)) {
         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 DATE_FORMAT(fecha,'%d')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}' AND caja='{$caja}'\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;
         }
         $dia[] = $row->dia;
         $data_1[] = $row->grantotal;
     }
     $om = 1;
     while ($maxval / $om > 100) {
         $om = $om * 10;
     }
     $bar_1 = new bar_fade(55, '#424581');
     $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, 'Cajero' . $caja, '{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());
     }
 }