totalizadores implementados

This commit is contained in:
2024-08-05 21:25:16 +02:00
parent 4255b74f33
commit 8ea0ab13c0
6 changed files with 234 additions and 84 deletions

View File

@ -245,15 +245,31 @@ class Pedido extends \App\Controllers\BaseResourceController
$estado = $reqData['estado'] ?? 'todos';
if($estado == 'todos') $estado = '';
$showTotal = $reqData['showTotal'] ?? false;
$searchValues = get_filter_datatables_columns($reqData);
$model_linea = model('\App\Models\Pedidos\PedidoLineaModel');
$resourceData = $model_linea->getResource($searchValues, $estado)->orderBy($order, $dir)->limit($length, $start)->get()->getResultObject();
$totalTirada = $model_linea->getSumOfTirada($searchValues, $estado, $start, $length);
$total = $model_linea->getSumOfTotalAceptado($searchValues, $estado, $start, $length);
$total2 = 0;
if($showTotal){
$total2 = $model_linea->getTotalOfTotalAceptado();
}
if($total2 != 0){
$total = "" . $total . " \n(" . $total2 . ")";
}
return $this->respond(Collection::datatable(
$resourceData,
$model_linea->getResource("", $estado)->countAllResults(),
$model_linea->getResource($searchValues, $estado)->countAllResults()
$model_linea->getResource($searchValues, $estado)->countAllResults(),
"",
[
'total_tirada' => $totalTirada,
'total' => $total
]
));
} else {
return $this->failUnauthorized('Invalid request', 403);