mirror of
https://git.imnavajas.es/jjimenez/safekat.git
synced 2025-07-25 22:52:08 +00:00
añadido facturas. faltan filtros pedidos
This commit is contained in:
@ -236,13 +236,16 @@ class Facturas extends \App\Controllers\BaseResourceController
|
||||
public function datatable()
|
||||
{
|
||||
|
||||
$dataForClienteForm = false;
|
||||
if (auth()->user()->inGroup('cliente-admin') || auth()->user()->inGroup('cliente-editor')) {
|
||||
// Se obtiene el cliente ID a partir del usuario de la sesion
|
||||
$model_user = model('App\Models\Usuarios\UserModel');
|
||||
$user = $model_user->find(auth()->user()->id);
|
||||
$clienteId = $user->cliente_id;
|
||||
} else {
|
||||
$clienteId = -1;
|
||||
$temp = $this->request->getGet('cliente_id');
|
||||
$clienteId = ($temp && $temp != null && $temp != "") ? $temp : -1;
|
||||
$dataForClienteForm = ($temp && $temp != null && $temp != "") ? true : false;
|
||||
}
|
||||
|
||||
$model = model(FacturaModel::class);
|
||||
@ -342,8 +345,10 @@ class Facturas extends \App\Controllers\BaseResourceController
|
||||
if ($clienteId != -1) {
|
||||
$result->hide('cliente');
|
||||
$result->hide('creditoAsegurado');
|
||||
$result->hide('estado');
|
||||
$result->hide('estado_pago');
|
||||
if(!$dataForClienteForm){
|
||||
$result->hide('estado');
|
||||
$result->hide('estado_pago');
|
||||
}
|
||||
$result->hide('forma_pago');
|
||||
$result->hide('vencimiento');
|
||||
$result->hide('dias_vencimiento');
|
||||
@ -352,6 +357,11 @@ class Facturas extends \App\Controllers\BaseResourceController
|
||||
return $result->toJson(returnAsObject: true);
|
||||
}
|
||||
|
||||
public function getDatosFacturacionClienteForm($cliente_id){
|
||||
|
||||
return $this->respond($this->model->getSumatoriosFacturacionCliente($cliente_id));
|
||||
}
|
||||
|
||||
|
||||
public function datatablePedidos()
|
||||
{
|
||||
|
||||
@ -8,6 +8,8 @@ use App\Models\Collection;
|
||||
use App\Models\Pedidos\PedidoModel;
|
||||
use App\Services\PedidoXMLService;
|
||||
use App\Services\ProductionService;
|
||||
use Hermawan\DataTables\DataTable;
|
||||
use CodeIgniter\I18n\Time;
|
||||
|
||||
class Pedido extends \App\Controllers\BaseResourceController
|
||||
{
|
||||
@ -34,6 +36,7 @@ class Pedido extends \App\Controllers\BaseResourceController
|
||||
$this->viewData['breadcrumb'] = [
|
||||
['title' => lang("App.menu_pedidos"), 'route' => "javascript:void(0);", 'active' => false],
|
||||
];
|
||||
helper("time");
|
||||
|
||||
parent::initController($request, $response, $logger);
|
||||
|
||||
@ -371,6 +374,73 @@ class Pedido extends \App\Controllers\BaseResourceController
|
||||
}
|
||||
}
|
||||
|
||||
public function tablaClienteForm()
|
||||
{
|
||||
|
||||
$clienteId = $this->request->getGet('cliente_id') ?? -1;
|
||||
|
||||
$q = $this->model->getPedidosClienteForm($clienteId);
|
||||
|
||||
/*$searchValue = $this->request->getGet('fecha') ?? '';
|
||||
if (!empty($searchValue)) {
|
||||
// Extraer las fechas del formato "YYYY-MM-DD|YYYY-MM-DD"
|
||||
$dates = explode('|', $searchValue);
|
||||
if (count($dates) == 2) {
|
||||
$q->where('created_at >=', $dates[0] . ' 00:00:00')
|
||||
->where('created_at <=', $dates[1] . ' 23:59:59');
|
||||
}
|
||||
}
|
||||
$searchValue = $this->request->getGet('fecha_entrega') ?? '';
|
||||
if (!empty($searchValue)) {
|
||||
// Extraer las fechas del formato "YYYY-MM-DD|YYYY-MM-DD"
|
||||
$dates = explode('|', $searchValue);
|
||||
if (count($dates) == 2) {
|
||||
$q->where('fecha_entrega_real >=', $dates[0] . ' 00:00:00')
|
||||
->where('fecha_entrega_real <=', $dates[1] . ' 23:59:59');
|
||||
}
|
||||
}*/
|
||||
|
||||
|
||||
$result = DataTable::of($q)
|
||||
->edit(
|
||||
'fecha',
|
||||
fn($q) => $q->fecha?Time::createFromFormat("Y-m-d H:i:s", $q->fecha)->format("d/m/Y"):""
|
||||
)
|
||||
->edit(
|
||||
'fecha_entrega',
|
||||
fn($q) => $q->fecha_entrega?Time::createFromFormat("Y-m-d H:i:s", $q->fecha_entrega)->format("d/m/Y"):""
|
||||
)
|
||||
->edit(
|
||||
"estado",
|
||||
function ($row, $meta) {
|
||||
switch ($row->estado) {
|
||||
case "validacion":
|
||||
return lang('Pedidos.validacion');
|
||||
case "produccion":
|
||||
return lang('Pedidos.produccion');
|
||||
case "finalizado":
|
||||
return lang('Pedidos.finalizado');
|
||||
case "enviado":
|
||||
return lang('Pedidos.enviado');
|
||||
case "cancelado":
|
||||
return lang('Pedidos.cancelado');
|
||||
default:
|
||||
return '--'; // Debug
|
||||
}
|
||||
}
|
||||
)
|
||||
->add("action", callback: function ($q) {
|
||||
return '
|
||||
<div class="btn-group btn-group-sm">
|
||||
<a href="javascript:void(0);"><i class="ti ti-eye ti-sm btn-edit mx-2" data-id="' . $q->id . '"></i></a>
|
||||
</div>
|
||||
';
|
||||
|
||||
});
|
||||
|
||||
return $result->toJson(returnAsObject: true) ;
|
||||
}
|
||||
|
||||
|
||||
public function obtenerPedidosForFacturas(){
|
||||
if ($this->request->isAJAX()) {
|
||||
|
||||
Reference in New Issue
Block a user