add metrics
This commit is contained in:
75
app/Http/Controllers/Admin/Shop/PriceListValueController.php
Normal file
75
app/Http/Controllers/Admin/Shop/PriceListValueController.php
Normal file
@@ -0,0 +1,75 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Admin\Shop;
|
||||
|
||||
use App\Datatables\Shop\PriceListValuesDataTable;
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Repositories\Shop\Packages;
|
||||
use App\Repositories\Shop\PriceListValueCategories;
|
||||
use App\Repositories\Shop\PriceListValues;
|
||||
use App\Repositories\Shop\Taxes;
|
||||
use App\Repositories\Shop\Unities;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class PriceListValueController extends Controller
|
||||
{
|
||||
public function index(PriceListValuesDataTable $dataTable)
|
||||
{
|
||||
$data['categories'] = PriceListValueCategories::getOptions();
|
||||
|
||||
return $dataTable->render('Admin.Shop.PriceListValues.list', $data);
|
||||
}
|
||||
|
||||
public function create()
|
||||
{
|
||||
$data['unities'] = Unities::getOptions();
|
||||
$data['taxes_options'] = Taxes::getOptions();
|
||||
$data['categories'] = PriceListValueCategories::getOptions();
|
||||
|
||||
return view('Admin.Shop.PriceListValues.create', $data);
|
||||
}
|
||||
|
||||
public function edit($id)
|
||||
{
|
||||
$data['generic'] = PriceListValues::getFull($id)->toArray();
|
||||
$data['packages'] = Packages::getSelectByFamily($data['generic']['category']['article_family_id']);
|
||||
$data['unities'] = ($data['packages']['id'] ?? false) ? Unities::getSelectByPackage($data['packages']['id']) : [];
|
||||
$data['taxes_options'] = Taxes::getOptions();
|
||||
$data['categories'] = PriceListValueCategories::getOptions();
|
||||
|
||||
return view('Admin.Shop.PriceListValues.edit', $data);
|
||||
}
|
||||
|
||||
public function store(Request $request)
|
||||
{
|
||||
$ret = PriceListValues::store($request->all());
|
||||
|
||||
return redirect()->route('Admin.Shop.PriceListValues.index');
|
||||
}
|
||||
|
||||
public function show($id)
|
||||
{
|
||||
$data = PriceListValues::get($id);
|
||||
|
||||
return view('Admin.Shop.PriceListValues.view', $data);
|
||||
}
|
||||
|
||||
public function destroy($id)
|
||||
{
|
||||
return PriceListValues::destroy($id);
|
||||
}
|
||||
|
||||
public function getPrice($id)
|
||||
{
|
||||
$data['generic'] = PriceListValues::getFull($id);
|
||||
|
||||
return view('Admin.Shop.PriceListValues.partials.table-prices', $data);
|
||||
}
|
||||
|
||||
public function addPrice($index)
|
||||
{
|
||||
$data['index'] = $index;
|
||||
|
||||
return view('Admin.Shop.PriceListValues.partials.row_price', $data);
|
||||
}
|
||||
}
|
||||
@@ -69,6 +69,11 @@ class Order extends Model
|
||||
return $query->where('delivery_id', $deliveryId);
|
||||
}
|
||||
|
||||
public function scopeWaiting($query)
|
||||
{
|
||||
return $query->byStatus(0);
|
||||
}
|
||||
|
||||
public function scopePreparation($query)
|
||||
{
|
||||
return $query->byStatus(1);
|
||||
|
||||
@@ -3,10 +3,13 @@
|
||||
namespace App\Repositories\Shop;
|
||||
|
||||
use App\Models\Shop\Basket;
|
||||
use App\Traits\Model\Basic;
|
||||
use Darryldecode\Cart\CartCollection;
|
||||
|
||||
class BasketStores
|
||||
{
|
||||
use Basic;
|
||||
|
||||
public function has($key)
|
||||
{
|
||||
return Basket::find($key);
|
||||
@@ -14,30 +17,29 @@ class BasketStores
|
||||
|
||||
public function get($key)
|
||||
{
|
||||
if($this->has($key))
|
||||
{
|
||||
if($this->has($key)) {
|
||||
return new CartCollection(Basket::find($key)->cart_data);
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
return [];
|
||||
}
|
||||
}
|
||||
|
||||
public function put($key, $value)
|
||||
{
|
||||
if($row = Basket::find($key))
|
||||
{
|
||||
if($row = Basket::find($key)) {
|
||||
// update
|
||||
$row->cart_data = $value;
|
||||
$row->save();
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
Basket::create([
|
||||
'id' => $key,
|
||||
'cart_data' => $value
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
public static function getModel()
|
||||
{
|
||||
return Basket::query();
|
||||
}
|
||||
}
|
||||
|
||||
32
app/Repositories/Shop/CustomerMetrics.php
Normal file
32
app/Repositories/Shop/CustomerMetrics.php
Normal file
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
namespace App\Repositories\Shop;
|
||||
|
||||
use App\Models\Shop\Customer;
|
||||
use App\Repositories\Core\DateStats;
|
||||
use App\Traits\Model\Basic;
|
||||
|
||||
class CustomerMetrics
|
||||
{
|
||||
use Basic, DateStats;
|
||||
|
||||
public static function countOfToday()
|
||||
{
|
||||
return Customer::ofToday()->count();
|
||||
}
|
||||
|
||||
public static function countOfLastWeek()
|
||||
{
|
||||
return Customer::ofLastWeek()->count();
|
||||
}
|
||||
|
||||
public static function countOfLastMonth()
|
||||
{
|
||||
return Customer::ofLastMonth()->count();
|
||||
}
|
||||
|
||||
public static function getModel()
|
||||
{
|
||||
return Customer::query();
|
||||
}
|
||||
}
|
||||
@@ -10,12 +10,15 @@ class Dashboards
|
||||
'orders_count' => OrderMetrics::countByPeriod($start, $end),
|
||||
'orders_sum' => OrderMetrics::sumByPeriod($start, $end, 'total_shipped'),
|
||||
'orders_avg' => OrderMetrics::avgByPeriod($start, $end, 'total_shipped'),
|
||||
'offers_count' => Offers::count(),
|
||||
'clients_count' => Customers::count(),
|
||||
'countClients' => CustomerMetrics::countByPeriod($start, $end),
|
||||
'waitingOrders' => OrderMetrics::countWaiting(),
|
||||
'preparationLess24H' => OrderMetrics::countPreparationLess24h(),
|
||||
'preparationLess48H' => OrderMetrics::countPreparationLess48h(),
|
||||
'preparationMore48H' => OrderMetrics::countPreparationMore48h(),
|
||||
'offers_count' => Offers::count(),
|
||||
'stocksWarning' => OfferStocks::countAlerts(),
|
||||
'countCustomers' => Customers::count(),
|
||||
'lastOrders' => Orders::getLast(),
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,6 +20,11 @@ class OrderMetrics
|
||||
return self::sumMonthly('total_taxed');
|
||||
}
|
||||
|
||||
public static function countWaiting()
|
||||
{
|
||||
return Order::waiting()->count();
|
||||
}
|
||||
|
||||
public static function countPreparationLess24h()
|
||||
{
|
||||
$date = now()->subHours(24);
|
||||
|
||||
@@ -14,6 +14,11 @@ class Orders
|
||||
{
|
||||
use Basic, DateStats;
|
||||
|
||||
public static function getLast($nb = 10)
|
||||
{
|
||||
return Order::with('customer')->orderBy('id', 'DESC')->take($nb)->get();
|
||||
}
|
||||
|
||||
public static function getPdfByUUID($uuid)
|
||||
{
|
||||
return self::getPdf(self::getIdByUUID($uuid), 'commande-' . $uuid . '.pdf');
|
||||
|
||||
@@ -1,17 +1,10 @@
|
||||
<x-card title="Aperçu de l'activité">
|
||||
<div class="counter">
|
||||
<span class="index">Paniers Actifs</span>
|
||||
<div class="value float-right">40</div>
|
||||
</div>
|
||||
<div>
|
||||
<span class="text-muted">dans les 30 dernières minutes</span>
|
||||
</div>
|
||||
|
||||
<x-card title="Etat des commandes" class="dashtable" classBody="p-1 bg-light">
|
||||
<table class="table table-stripped counter w-100">
|
||||
<tr>
|
||||
<td class="index">Commandes</td>
|
||||
<td class="value text-right">{{ $orders_count }}</td>
|
||||
<td class="index">Commandes en attente</td>
|
||||
<td class="value text-right">{{ $waitingOrders ?? 0 }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="index">En préparation depuis moins de 24h</td>
|
||||
@@ -46,8 +39,12 @@
|
||||
</table>
|
||||
</x-card>
|
||||
|
||||
<x-card title="Suivi des stocks" class="dashtable" classBody="p-1 bg-light">
|
||||
<x-card title="Suivi des offres & stocks" class="dashtable" classBody="p-1 bg-light">
|
||||
<table class="table table-stripped counter w-100">
|
||||
<tr>
|
||||
<td class="index">Offres disponibles</td>
|
||||
<td class="value float-right">{{ $offers_count ?? 0 }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="index">Stock critique</td>
|
||||
<td class="value float-right">{{ $stocksWarning ?? 0 }}</td>
|
||||
@@ -58,8 +55,8 @@
|
||||
<x-card title="Clients et suivi client" class="dashtable" classBody="p-1 bg-light">
|
||||
<table class="table table-stripped counter w-100">
|
||||
<tr>
|
||||
<td class="index">Nouveaux clients</td>
|
||||
<td class="value float-right">{{ $newClients ?? 0 }}</td>
|
||||
<td class="index">Clients</td>
|
||||
<td class="value float-right">{{ $countCustomers ?? 0 }}</td>
|
||||
</tr>
|
||||
</table>
|
||||
</x-card>
|
||||
|
||||
@@ -1,4 +1,11 @@
|
||||
<div class="row">
|
||||
<div class="col-sm-3 col-xs-6">
|
||||
<div class="description-block">
|
||||
<span class="description-percentage text-red"><i class="fa fa-caret-down"></i> 18%</span>
|
||||
<h5 class="description-header">{{ $orders_count ?? 0 }}</h5>
|
||||
<span class="description-text">NB COMMANDES</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-sm-3 col-xs-6">
|
||||
<div class="description-block border-right">
|
||||
<span class="description-percentage text-green"><i class="fa fa-caret-up"></i> 17%</span>
|
||||
@@ -16,15 +23,8 @@
|
||||
<div class="col-sm-3 col-xs-6">
|
||||
<div class="description-block border-right">
|
||||
<span class="description-percentage text-green"><i class="fa fa-caret-up"></i> 20%</span>
|
||||
<h5 class="description-header">{{ $clients_count ?? 0 }}</h5>
|
||||
<h5 class="description-header">{{ $countClients ?? 0 }}</h5>
|
||||
<span class="description-text">NB CLIENTS</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-sm-3 col-xs-6">
|
||||
<div class="description-block">
|
||||
<span class="description-percentage text-red"><i class="fa fa-caret-down"></i> 18%</span>
|
||||
<h5 class="description-header">{{ $offers_count ?? 0 }}</h5>
|
||||
<span class="description-text">NB OFFRES</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -8,7 +8,6 @@
|
||||
<button type="button" class="btn btn-tool" data-widget="remove"><i class="fa fa-times"></i></button>
|
||||
</div>
|
||||
</div>
|
||||
<!-- /.box-header -->
|
||||
<div class="card-body">
|
||||
<div class="table-responsive">
|
||||
<table class="table no-margin">
|
||||
@@ -17,16 +16,34 @@
|
||||
<th>Nom</th>
|
||||
<th>Localisation</th>
|
||||
<th>Date</th>
|
||||
<th>Montant</th>
|
||||
<th class="text-right">Montant</th>
|
||||
<th></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@if (count($lastOrders))
|
||||
@foreach ($lastOrders as $order)
|
||||
<tr>
|
||||
<td><a href="pages/examples/invoice.html">Ludovic CANDELLIER</a></td>
|
||||
<td>Amiens (80)</td>
|
||||
<td>14/05/2020</td>
|
||||
<td><span class="label label-success">300.53 €</span></td>
|
||||
<td>
|
||||
<a href="{{ route('Admin.Shop.Customers.edit', ['id' => $order->customer->id]) }}"
|
||||
class="alert-link green">
|
||||
{{ $order->customer->first_name }}
|
||||
{{ $order->customer->last_name }}
|
||||
</a>
|
||||
</td>
|
||||
<td>{{ $order->customer->city }} ({{ substr($order->customer->zipcode, 0, 2) }})</td>
|
||||
<td>{{ Carbon\Carbon::parse($order->created_at)->format('d/m/Y H:i') }}</td>
|
||||
<td class="text-right font-weight-bold">
|
||||
{{ $order->total_shipped }} €
|
||||
</td>
|
||||
<td class="text-right">
|
||||
<a href="{{ route('Admin.Shop.Orders.edit', ['id' => $order->id]) }}">
|
||||
<button class="btn btn-sm btn-success"><i class="fa fa-eye"></i></button>
|
||||
</a>
|
||||
</td>
|
||||
</tr>
|
||||
@endforeach
|
||||
@endif
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
@@ -34,8 +51,12 @@
|
||||
</div>
|
||||
<!-- /.box-body -->
|
||||
<div class="card-header clearfix">
|
||||
<a href="javascript:void(0)" class="btn btn-sm btn-info btn-flat pull-left">Nouvelle commande</a>
|
||||
<a href="javascript:void(0)" class="btn btn-sm btn-default btn-flat pull-right">Voir toutes les commandes</a>
|
||||
<a href="{{ route('Admin.Shop.Orders.create') }}" class="btn btn-sm btn-info btn-flat pull-left">
|
||||
Nouvelle commande
|
||||
</a>
|
||||
<a href="{{ route('Admin.Shop.Orders.index') }}" class="btn btn-sm btn-default btn-flat pull-right">
|
||||
Voir toutes les commandes
|
||||
</a>
|
||||
</div>
|
||||
<!-- /.box-footer -->
|
||||
</div>
|
||||
|
||||
10
routes/Admin/Shop/PriceListValues.php
Normal file
10
routes/Admin/Shop/PriceListValues.php
Normal file
@@ -0,0 +1,10 @@
|
||||
<?php
|
||||
|
||||
Route::prefix('PriceListValues')->name('PriceListValues.')->group(function () {
|
||||
Route::get('', 'PriceListValueController@index')->name('index');
|
||||
Route::get('create', 'PriceListValueController@create')->name('create');
|
||||
Route::delete('destroy/{id?}', 'PriceListValueController@destroy')->name('destroy');
|
||||
Route::post('store', 'PriceListValueController@store')->name('store');
|
||||
Route::get('edit/{id}', 'PriceListValueController@edit')->name('edit');
|
||||
Route::get('addPrice/{index?}', 'PriceListValueController@addPrice')->name('addPrice');
|
||||
});
|
||||
@@ -19,6 +19,7 @@ Route::middleware('auth')->prefix('Shop')->namespace('Shop')->name('Shop.')->gro
|
||||
include_once __DIR__.'/Orders.php';
|
||||
include_once __DIR__.'/Packages.php';
|
||||
include_once __DIR__.'/PriceLists.php';
|
||||
include_once __DIR__.'/PriceListValues.php';
|
||||
include_once __DIR__.'/Producers.php';
|
||||
include_once __DIR__.'/SaleChannels.php';
|
||||
include_once __DIR__.'/Tags.php';
|
||||
|
||||
Reference in New Issue
Block a user