Skip to content

Commit

Permalink
nueva
Browse files Browse the repository at this point in the history
  • Loading branch information
mauroziux committed Oct 22, 2015
1 parent 72a49ab commit b798e25
Show file tree
Hide file tree
Showing 20 changed files with 4,387 additions and 408 deletions.
1 change: 1 addition & 0 deletions .idea/dataSources.ids

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion .idea/dataSources.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

577 changes: 198 additions & 379 deletions .idea/workspace.xml

Large diffs are not rendered by default.

13 changes: 3 additions & 10 deletions app/Http/Controllers/ClientesController.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,13 +62,12 @@ public function store(Request $request)
public function show($id)
{
//
dd(ventas::top_ventas($id));
//dd(ventas::top_ventas($id));
$cliente = clientes::find($id);
$ciudadesJSON = ciudades::all()->toJson();
$departamentos = departamentos::lists('departamento', 'id');
$ciudades = ciudades::lists('ciudad', 'id');
$ventas = ventas::with('clientes', 'tiendas', 'factura_venta')->where('cliente_id', $id)->get();

$datos = ventas::datos($ventas);
return view('app.clientes.clientes_show', compact('cliente','ciudades','ciudadesJSON',
'departamentos','ventas','datos'));
Expand Down Expand Up @@ -117,13 +116,7 @@ public function destroy($id)
public function chart(Request $request)
{
//cargar graficos de estadisticas
$id = $request->id;
$top_ventas = ventas::top_ventas($id);
foreach ($top_ventas as $compra) {
$label[] = date_format($compra->created_at, 'd/m/y');
$data[] = $compra->precio;
}
$compras = (['label' => $label, 'data' => $data]);
return response()->json($compras);
$top_ventas = ventas::top_ventas($request->id);
return response()->json($top_ventas);
}
}
2 changes: 1 addition & 1 deletion app/Http/routes.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
Route::resource('proveedores', 'ProveedoresController',['except' => ['chart']]);

/******* clientes ********/
Route::get('clientes/chart', 'ProveedoresController@chart');
Route::get('clientes/chart', 'ClientesController@chart');
Route::resource('clientes', 'ClientesController',['except' => ['chart']]);

/******* impuestos ********/
Expand Down
1 change: 1 addition & 0 deletions app/venta_detalle.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ public static function AgregarVentaDetalle($items, $id)
$producto = new venta_detalle();
$producto->venta_id = $id;
$producto->producto_configurable_id = $item['id'];
$producto->producto = $item['nombre'];
$producto->cantidad = $item['cantidad'];
$producto->venta = ($item['valor']);
$producto->compra = ($item['compra']);
Expand Down
17 changes: 13 additions & 4 deletions app/ventas.php
Original file line number Diff line number Diff line change
Expand Up @@ -231,9 +231,18 @@ public static function crear_pdf($id)

public static function top_ventas($id)
{
//pendiente para realizar
$ventas = ventas::with('ventas_detalle.productos_configurables.productos')->where('cliente_id', $id)->get();

return $ventas;
//pendiente para realizar
$ventas = ventas::where('cliente_id', $id)->select('id')->get();
$ventas = $ventas->toArray();
$productos = venta_detalle::with('productos_configurables.productos')->wherein('venta_id',$ventas)
->groupby('producto_configurable_id')->selectraw('*, sum(cantidad) as SumCantidad')
->orderby('SumCantidad','desc')->take(10)->get();
foreach($productos as $producto){
$label[] = $producto->producto;
$data[] = $producto->SumCantidad;
}
$top = (['label' => $label, 'data' => $data]);

return $top;
}
}
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@
"intervention/image": "^2.3",
"barryvdh/laravel-httpcache": "0.2.x@dev",
"barryvdh/laravel-dompdf": "0.6.*",
"barryvdh/laravel-async-queue": "0.4.x"
"barryvdh/laravel-async-queue": "0.4.x",
"fx3costa/laravelchartjs": "^1.2"


},
Expand Down
49 changes: 47 additions & 2 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions config/app.php
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,7 @@
Barryvdh\HttpCache\ServiceProvider::class,
Barryvdh\DomPDF\ServiceProvider::class,
Barryvdh\Queue\AsyncServiceProvider::class,
Fx3costa\Laravelchartjs\Providers\ChartjsServiceProvider::class,


/*
Expand Down
51 changes: 51 additions & 0 deletions config/chartjs.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
<?php
return [

/*
|--------------------------------------------------------------------------
| Chart Colors Configuration
|--------------------------------------------------------------------------
|
| This section defines the default colors to be used for each type of chart
| and what are the colors of each dataset that is used. Consequently, increasing the
| number of datasets, you must increase the colors.
|
*/
'colours' => [

'bar' => [
'rgba(220,220,220,0.5)',
'rgba(151,187,205,0.8)',
'rgba(24, 164, 103, 0.7)',
],

/**
* If the number of data exceeds the number of colors configured,
* the data will use default color definied in ChartPie.php
*/
'pie' => [
[
'colour' => "#F7464A",
'highlight' => "#FF5A5E"
],
[
'colour' => "#46BFBD",
'highlight' => "#5AD3D1"
],
[
'colour' => "#FDB45C",
'highlight' => "#FFC870"
],

]
],


/*
|--------------------------------------------------------------------------
|
|--------------------------------------------------------------------------
|
*/

];
1 change: 1 addition & 0 deletions database/migrations/2015_09_12_032400_venta_detalle.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ public function up()
$table->increments('id');
$table->integer('venta_id');
$table->integer('producto_configurable_id');
$table->string('producto');
$table->integer('cantidad');
$table->decimal('venta',10,2);
$table->decimal('compra',10,2);
Expand Down
Binary file added public/img/catalog/1/19-iphone.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
22 changes: 12 additions & 10 deletions resources/views/app/clientes/clientes_show_estadisticas.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
<h3 class="block-title">Historico Precios de compra</h3>
</div>
<div class="block-content block-content-full text-center" >
<canvas id="historico_compras" class="js-chartjs-lines" height="250" ></canvas>
<canvas id="top_ventass" ></canvas>
</div>
</div>
<!-- END Lines Chart -->
Expand All @@ -30,7 +30,7 @@
<h3 class="block-title">Historico Precios de compra</h3>
</div>
<div class="block-content block-content-full text-center" >
<canvas id="historico_ventas" class="js-chartjs-lines" height="250" ></canvas>
<canvas id="top_ventas" class="js-chartjs-lines" style="width:100%; height: 300px" ></canvas>
</div>
</div>
<!-- END Lines Chart -->
Expand All @@ -44,25 +44,27 @@ function chart() {
$.getJSON("chart?id=" + codigo, function (result) {
console.log(result.label)
console.log(result.data)
var options = {
responsive: true,
showScale: false
};
var buyerData = {
labels: result.label,
datasets: [
{
fillColor: "rgba(220,220,220,0.2)",
strokeColor: "rgba(220,220,220,1)",
pointColor: "rgba(220,220,220,1)",
pointStrokeColor: "#fff",
pointHighlightFill: "#fff",
pointHighlightStroke: "rgba(220,220,220,1)",
highlightFill: "rgba(220,220,220,0.75)",
highlightStroke: "rgba(220,220,220,1)",
data: result.data
}
]
};
var compras = document.getElementById('historico_compras').getContext('2d');
var ventas = document.getElementById('historico_ventas').getContext('2d');
new Chart(compras).Line(buyerData, {bezierCurve: true});
new Chart(ventas).Line(buyerData, {bezierCurve: true});
var ventas = document.getElementById('top_ventas').getContext('2d');
new Chart(ventas).Bar(buyerData, options);
});
},3000)
Expand Down
Loading

0 comments on commit b798e25

Please sign in to comment.