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ñ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()); }
$DirFile = str_replace($partsarr, "", $parts); //Set here Base Path define('SPATH_BASE', $DirFile); include_once "" . SPATH_BASE . "/web.config.php"; $data = array(); // include_once(SITE_OFC.'ofc-library/open-flash-chart.php'); $bar = new bar_outline(50, '#1D6DC2', '#000000'); $max = 0; $sql = "SELECT pr.vProdName, count( ord.iOrderId ) AS Totodr\r\nFROM " . PRJ_DB_PREFIX . "_product AS pr, " . PRJ_DB_PREFIX . "_order AS ord\r\nWHERE pr.iProductId = ord.iProductId\r\nGROUP BY ord.iProductId\r\nORDER BY ord.iOrderId DESC\r\nLIMIT 0 , 5"; $db_sql = $dbobj->MySQLSelect($sql); for ($i = 0; $i < count($db_sql); $i++) { $data[] = substr(stripslashes($db_sql[$i]['vProdName']), 0, 8) . "..."; $Adata = $db_sql[$i]['Totodr']; $tip = "Product Name : " . $db_sql[$i]['vProdName'] . "<br>"; $tip .= "Total Order : " . $db_sql[$i]['Totodr'] . "<br>"; $bar->add_data_tip($Adata, $tip); if ($max != $db_sql[$i]['Totodr']) { if ($max < $db_sql[$i]['Totodr']) { $max = $db_sql[$i]['Totodr']; } } } $g = new graph(); $g->bg_colour = 'FBFBFB'; $g->title('Most Ordered Product ', '{font-size: 18px;}'); $g->set_tool_tip('#tip#'); $g->data_sets[] = $bar; $g->set_x_labels($data); $g->set_x_label_style(10, '#000000', 2, 1); $g->set_x_axis_steps(1); $g->set_y_max($max);