Skip to content

Commit

Permalink
Sales report - Pt2
Browse files Browse the repository at this point in the history
  • Loading branch information
Kev1nByte committed Jul 20, 2023
1 parent d4a08cd commit 4743b2a
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 15 deletions.
Empty file removed views/modulos/grafico-ventas.php
Empty file.
60 changes: 45 additions & 15 deletions views/modulos/reportes/grafico-ventas.php
Expand Up @@ -22,13 +22,29 @@

foreach ($respuesta as $key => $value) {

#Capturamos sólo el año y el mes
$fecha = substr($value["fecha"],0,7);

#Introducir las fechas en arrayFechas
array_push($arrayFechas, $fecha);

#Capturamos las ventas
$arrayVentas = array($fecha => $value["total"]);

#Sumamos los pagos que ocurrieron el mismo mes
foreach ($arrayVentas as $key => $value) {

$sumaPagosMes[$key] += $value;

}

}


$noRepetirFechas = array_unique($arrayFechas);

?>

?>
<!-- GRÁFICO DE VENTAS -->

<div class="box box-solid bg-teal-gradient">
Expand All @@ -45,30 +61,42 @@

<div class="chart" id="line-chart-ventas" style="height: 250px;"></div>

</div>
</div>

</div>

<script>

var line = new Morris.Line({
var line = new Morris.Line({
element : 'line-chart-ventas',
resize : true,
data : [
{ y: '2011 Q1', item1: 2666 },
{ y: '2011 Q2', item1: 2778 },
{ y: '2011 Q3', item1: 4912 },
{ y: '2011 Q4', item1: 3767 },
{ y: '2012 Q1', item1: 6810 },
{ y: '2012 Q2', item1: 5670 },
{ y: '2012 Q3', item1: 4820 },
{ y: '2012 Q4', item1: 15073 },
{ y: '2013 Q1', item1: 10687 },
{ y: '2013 Q2', item1: 8432 }

<?php

if($noRepetirFechas != null){

foreach($noRepetirFechas as $key){

echo "{ y: '".$key."', ventas: ".$sumaPagosMes[$key]." },";


}

echo "{y: '".$key."', ventas: ".$sumaPagosMes[$key]." }";

}else{

echo "{ y: '0', ventas: '0' }";

}

?>

],
xkey : 'y',
ykeys : ['item1'],
labels : ['Item 1'],
ykeys : ['ventas'],
labels : ['ventas'],
lineColors : ['#efefef'],
lineWidth : 2,
hideHover : 'auto',
Expand All @@ -78,7 +106,9 @@
pointStrokeColors: ['#efefef'],
gridLineColor : '#efefef',
gridTextFamily : 'Open Sans',
preUnits : 'S/. ',
gridTextSize : 10

});

</script>

0 comments on commit 4743b2a

Please sign in to comment.