PHP - Reporte de ventas agrupadas por meses

 
Vista:
Imágen de perfil de novo34

Reporte de ventas agrupadas por meses

Publicado por novo34 (9 intervenciones) el 24/04/2016 17:54:28
Hola amigos, soy nuevo en programación y he aprendido algo de php con video tutoriales y leyendo mucho en internet.

Actualmente me encuentro haciendo un sistema en el que necesito crear reporte de ventas mensuales pero por mas que he buscado no encuentro la manera de aplicarlo.

tengo la siguiente consulta que funciona en mysql:

1
SELECT Month(created_at) AS Mes,Sum(total) AS total_Mes FROM ".self::$tablename." WHERE Year(created_at)=2016 GROUP BY Mes ORDER BY Mes asc;


Pero en la seguiente función no me funciona:
1
2
3
4
5
public static function getVentas(){
		$sql = "SELECT Month(created_at) AS Mes,Sum(total) AS total_Mes FROM ".self::$tablename." WHERE Year(created_at)=2016 GROUP BY Mes ORDER BY Mes asc;";
		$query = Executor::doit($sql);
		return Model::many($query[0],new SellData());
	}

y necesito ponerla en este grafico:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
<!DOCTYPE HTML>
<html>
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
		<title>Highcharts Example</title>
 
		<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js"></script>
		<style type="text/css">
#container {
    height: 400px;
    min-width: 310px;
    max-width: 800px;
    margin: 0 auto;
}
		</style>
		<script type="text/javascript">
$(function () {
    $('#container').highcharts({
        chart: {
            type: 'column',
            options3d: {
                enabled: true,
                alpha: 10,
                beta: 25,
                depth: 70
            }
        },
        title: {
            text: 'Reporte Mensual'
        },
        subtitle: {
            text: 'Notice the difference between a 0 value and a null point'
        },
        plotOptions: {
            column: {
                depth: 25
            }
        },
        xAxis: {
            categories: Highcharts.getOptions().lang.shortMonths
        },
        yAxis: {
            title: {
                text: null
            }
        },
        series: [{
            name: 'Ventas',
            data: [2,1,3,4,5,6,7]
        }]
    });
});
		</script>
	</head>
	<body>
 
<script src="https://code.highcharts.com/highcharts.js"></script>
<script src="https://code.highcharts.com/highcharts-3d.js"></script>
<script src="https://code.highcharts.com/modules/exporting.js"></script>
 
<div id="container" style="height: 400px"></div>
	</body>
</html>

Ayudenme por favor llevo dos semanas queriendo hacerlo y no encuentro la solución en ninguna parte.
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder