Merge branch 'add/calculo_credito_cliente' into 'main'

Add/calculo credito cliente

See merge request jjimenez/safekat!620
This commit is contained in:
2025-03-27 23:53:07 +00:00
20 changed files with 960 additions and 806 deletions

View File

@ -21,6 +21,8 @@ const SK_PERMISSION_MATRIX = [
"presupuesto-cliente.edit", "presupuesto-cliente.edit",
"presupuesto-cliente.delete", "presupuesto-cliente.delete",
"presupuesto-cliente.menu", "presupuesto-cliente.menu",
"pedidos-validacion.view",
"pedidos-validacion.menu",
"pedidos-activos.view", "pedidos-activos.view",
"pedidos-activos.menu", "pedidos-activos.menu",
"pedidos-finalizados.view", "pedidos-finalizados.view",

View File

@ -21,6 +21,8 @@ const SK_PERMISSIONS = [
'presupuesto-cliente.edit' => 'Can edit', 'presupuesto-cliente.edit' => 'Can edit',
'presupuesto-cliente.delete' => 'Can delete', 'presupuesto-cliente.delete' => 'Can delete',
'presupuesto-cliente.menu' => 'Menu shall be visualize', 'presupuesto-cliente.menu' => 'Menu shall be visualize',
'pedidos-validacion.view' => 'Can view',
'pedidos-validacion.menu' => 'Menu shall be visualize',
'pedidos-activos.view' => 'Can view', 'pedidos-activos.view' => 'Can view',
'pedidos-activos.menu' => 'Menu shall be visualize', 'pedidos-activos.menu' => 'Menu shall be visualize',
'pedidos-finalizados.view' => 'Can view', 'pedidos-finalizados.view' => 'Can view',

View File

@ -743,8 +743,8 @@ $routes->group('presupuestotiradasalternativas', ['namespace' => 'App\Controller
}); });
$routes->group('pedidos', ['namespace' => 'App\Controllers\Pedidos'], function ($routes) { $routes->group('pedidos', ['namespace' => 'App\Controllers\Pedidos'], function ($routes) {
$routes->get('list', 'Pedido::todos', ['as' => 'listaPresupuestos']); $routes->get('list', 'Pedido::todos', ['as' => 'listaPedidos']);
$routes->get('listActivos', 'Pedido::activos', ['as' => 'listaPresupuestosActivos']); $routes->get('listActivos', 'Pedido::activos', ['as' => 'listaPedidosActivos']);
$routes->get('listFinalizados', 'Pedido::finalizados', ['as' => 'listaFinalizados']); $routes->get('listFinalizados', 'Pedido::finalizados', ['as' => 'listaFinalizados']);
$routes->get('listCancelados', 'Pedido::cancelados', ['as' => 'listaCancelados']); $routes->get('listCancelados', 'Pedido::cancelados', ['as' => 'listaCancelados']);
$routes->post('datatable', 'Pedido::datatable', ['as' => 'dataTableOfPedidos']); $routes->post('datatable', 'Pedido::datatable', ['as' => 'dataTableOfPedidos']);

View File

@ -68,7 +68,7 @@ class Pedido extends \App\Controllers\BaseResourceController
'pedidoEntity' => new PedidoEntity(), 'pedidoEntity' => new PedidoEntity(),
'usingServerSideDataTable' => true, 'usingServerSideDataTable' => true,
'pageTitle' => lang('Pedidos.Pedidos'), 'pageTitle' => lang('Pedidos.Pedidos'),
'estadoPedidos' => 'activo', 'estadoPedidos' => 'produccion',
['title' => lang("App.menu_pedidos"), 'route' => site_url('pedidos/todos'), 'active' => true] ['title' => lang("App.menu_pedidos"), 'route' => site_url('pedidos/todos'), 'active' => true]
]; ];
@ -112,6 +112,32 @@ class Pedido extends \App\Controllers\BaseResourceController
return view(static::$viewPath . 'viewPedidosList', $viewData); return view(static::$viewPath . 'viewPedidosList', $viewData);
} }
public function validacion()
{
$viewData = [
'currentModule' => static::$controllerSlug,
'pageSubTitle' => lang('Basic.global.ManageAllRecords', [lang('Pedidos.pedido')]),
'pedidoEntity' => new PedidoEntity(),
'usingServerSideDataTable' => true,
'pageTitle' => lang('Pedidos.Pedidos'),
'estadoPedidos' => 'validacion',
['title' => lang("App.menu_pedidos"), 'route' => site_url('pedidos/todos'), 'active' => true]
];
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;
}
$viewData['cliente_id'] = $clienteId;
return view(static::$viewPath . 'viewPedidosList', $viewData);
}
public function cancelados() public function cancelados()
{ {
$viewData = [ $viewData = [
@ -284,6 +310,12 @@ class Pedido extends \App\Controllers\BaseResourceController
$this->viewData['importePendiente'] = $pendiente; $this->viewData['importePendiente'] = $pendiente;
} }
$modelOrden = new \App\Models\OrdenTrabajo\OrdenTrabajoModel();
$orden = $modelOrden->where('pedido_id', $pedidoEntity->id)->first();
if($orden){
$this->viewData['orden_id'] = $orden->id;
}
$this->viewData['boxTitle'] = lang('Basic.global.edit2') . ' ' . lang('Pedidos.moduleTitle') . ' ' . lang('Basic.global.edit3'); $this->viewData['boxTitle'] = lang('Basic.global.edit2') . ' ' . lang('Pedidos.moduleTitle') . ' ' . lang('Basic.global.edit3');
return $this->displayForm(__METHOD__, $id); return $this->displayForm(__METHOD__, $id);
@ -317,23 +349,22 @@ class Pedido extends \App\Controllers\BaseResourceController
$resourceData = $model_linea->getResource($searchValues, $estado, $cliente_id)->orderBy($order, $dir)->limit($length, $start)->get()->getResultObject(); $resourceData = $model_linea->getResource($searchValues, $estado, $cliente_id)->orderBy($order, $dir)->limit($length, $start)->get()->getResultObject();
$totalTirada = $model_linea->getSumOfTirada($searchValues, $estado, $cliente_id, $start, $length); $totalTirada = $model_linea->getSumOfTirada($searchValues, $estado, $cliente_id, $start, $length);
$total = $model_linea->getSumOfTotalAceptado($searchValues, $estado, $cliente_id, $start, $length); $total = $model_linea->getSumOfTotalAceptado($searchValues, $estado, $cliente_id, $start, $length);
$extra_data['total_tirada'] = $totalTirada;
$extra_data['total'] = $total;
$total2 = 0; $total2 = 0;
if($showTotal){ if($showTotal){
$total2 = $model_linea->getTotalOfTotalAceptado(); $total2 = $model_linea->getTotalOfTotalAceptado($estado);
$tirada2 = $model_linea->getTotalTirada($estado);
$extra_data['total2'] = $total2;
$extra_data['total_tirada2'] = $tirada2;
} }
if($total2 != 0){
$total = "" . $total . " \n(" . $total2 . ")";
}
return $this->respond(Collection::datatable( return $this->respond(Collection::datatable(
$resourceData, $resourceData,
$model_linea->getResource("", $estado)->countAllResults(), $model_linea->getResource("", $estado)->countAllResults(),
$model_linea->getResource($searchValues, $estado)->countAllResults(), $model_linea->getResource($searchValues, $estado)->countAllResults(),
"", "",
[ $extra_data
'total_tirada' => $totalTirada,
'total' => $total
]
)); ));
} else { } else {
return $this->failUnauthorized('Invalid request', 403); return $this->failUnauthorized('Invalid request', 403);

View File

@ -401,6 +401,17 @@ class Presupuestoadmin extends \App\Controllers\BaseResourceController
$this->viewData['cliente_id'] = $presupuestoEntity->cliente_id; $this->viewData['cliente_id'] = $presupuestoEntity->cliente_id;
$modelPedidoLinea = new \App\Models\Pedidos\PedidoLineaModel();
$linea = $modelPedidoLinea->where('presupuesto_id', $id)->first();
if($linea){
$this->viewData['pedido_id'] = $linea->pedido_id;
$modelOrden = new \App\Models\OrdenTrabajo\OrdenTrabajoModel();
$orden = $modelOrden->where('pedido_id', $linea->pedido_id)->first();
if($orden){
$this->viewData['orden_id'] = $orden->id;
}
}
// Si se ha llamado a esta funcion porque se ha duplicado el presupuesto // Si se ha llamado a esta funcion porque se ha duplicado el presupuesto
// se actualiza la bbdd para que sólo ejecute algunas funciones una vez // se actualiza la bbdd para que sólo ejecute algunas funciones una vez
if ($presupuestoEntity->is_duplicado) { if ($presupuestoEntity->is_duplicado) {

View File

@ -153,7 +153,7 @@ class Ordentrabajo extends BaseController
->add("logo", fn($q) => site_url($logo->get_logo_path($q->presupuesto_linea_tipo))) ->add("logo", fn($q) => site_url($logo->get_logo_path($q->presupuesto_linea_tipo)))
->edit( ->edit(
"fecha_encuadernado_at", "fecha_encuadernado_at",
fn($q) => Time::createFromFormat("Y-m-d", $q->fecha_encuadernado_at)->format("d/m/Y") fn($q) => $q->fecha_encuadernado_at? Time::createFromFormat("Y-m-d", $q->fecha_encuadernado_at)->format("d/m/Y"):""
) )
->add("action", fn($q) => $q->id) ->add("action", fn($q) => $q->id)
->toJson(true); ->toJson(true);
@ -168,7 +168,7 @@ class Ordentrabajo extends BaseController
->add("logo", fn($q) => site_url($logo->get_logo_path($q->presupuesto_linea_tipo))) ->add("logo", fn($q) => site_url($logo->get_logo_path($q->presupuesto_linea_tipo)))
->edit( ->edit(
"fecha_encuadernado_at", "fecha_encuadernado_at",
fn($q) => Time::createFromFormat("Y-m-d", $q->fecha_encuadernado_at)->format("d/m/Y") fn($q) => $q->fecha_encuadernado_at?Time::createFromFormat("Y-m-d", $q->fecha_encuadernado_at)->format("d/m/Y"):""
) )
->add("action", fn($q) => $q->id) ->add("action", fn($q) => $q->id)
->toJson(true); ->toJson(true);

View File

@ -749,7 +749,8 @@ return [
"menu_informes" => "Informes", "menu_informes" => "Informes",
"menu_pedidos" => "Pedidos", "menu_pedidos" => "Pedidos",
"menu_pedidos_activos" => "Activos", "menu_pedidos_validacion" => "Validación",
"menu_pedidos_activos" => "Producción",
"menu_pedidos_finalizados" => "Finalizados", "menu_pedidos_finalizados" => "Finalizados",
"menu_pedidos_cancelados" => "Cancelados", "menu_pedidos_cancelados" => "Cancelados",
"menu_pedidos_todos" => "Todos", "menu_pedidos_todos" => "Todos",

View File

@ -33,7 +33,8 @@ return [
'direccionesSection' => 'Direcciones', 'direccionesSection' => 'Direcciones',
'presupuestoSection' => 'Presupuestos', 'presupuestoSection' => 'Presupuestos',
'presupuestoClienteSection' => 'Presupuestos de Cliente', 'presupuestoClienteSection' => 'Presupuestos de Cliente',
'pedidosActivosSection' => 'Activos', 'pedidosValidacionSection' => 'Validación',
'pedidosActivosSection' => 'Producción',
'pedidosFinalizadosSection' => 'Finalizados', 'pedidosFinalizadosSection' => 'Finalizados',
'pedidosCanceladosSection' => 'Cancelados', 'pedidosCanceladosSection' => 'Cancelados',
'pedidosTodosSection' => 'Todos', 'pedidosTodosSection' => 'Todos',

View File

@ -61,9 +61,9 @@ class OrdenTrabajoDate extends Model
// Callbacks // Callbacks
protected $allowCallbacks = true; protected $allowCallbacks = true;
protected $beforeInsert = []; protected $beforeInsert = [];
protected $afterInsert = ["updateOrdenTrabajoUser"]; protected $afterInsert = [];
protected $beforeUpdate = []; protected $beforeUpdate = [];
protected $afterUpdate = ["updateOrdenTrabajoUser"]; protected $afterUpdate = [];
protected $beforeFind = []; protected $beforeFind = [];
protected $afterFind = []; protected $afterFind = [];
protected $beforeDelete = []; protected $beforeDelete = [];

View File

@ -75,7 +75,7 @@ class PedidoLineaModel extends \App\Models\BaseModel
} }
} }
if($cliente_id != -1) { if($cliente_id != -1 && $cliente_id != "-1") {
$builder->where("t3.cliente_id", $cliente_id); $builder->where("t3.cliente_id", $cliente_id);
} }
@ -106,9 +106,11 @@ class PedidoLineaModel extends \App\Models\BaseModel
$builder->join("pedidos t2", "t2.id = t1.pedido_id", "left"); $builder->join("pedidos t2", "t2.id = t1.pedido_id", "left");
$builder->join("presupuestos t3", "t1.presupuesto_id = t3.id", "left"); $builder->join("presupuestos t3", "t1.presupuesto_id = t3.id", "left");
$builder->join("clientes t4", "t4.id = t3.cliente_id", "left");
$builder->join("users t5", "t5.id = t4.comercial_id", "left");
$builder->join("ubicaciones t6", "t6.id = t1.ubicacion_id", "left");
if($cliente_id != -1 && $cliente_id != "-1") {
if($cliente_id != -1) {
$builder->where("t3.cliente_id", $cliente_id); $builder->where("t3.cliente_id", $cliente_id);
} }
@ -128,7 +130,7 @@ class PedidoLineaModel extends \App\Models\BaseModel
} }
if ($estado !== '') { if ($estado !== '') {
$builder->where('estado', $estado); $builder->where('t2.estado', $estado);
} }
// Aplicar el orden y el límite // Aplicar el orden y el límite
@ -146,8 +148,11 @@ class PedidoLineaModel extends \App\Models\BaseModel
$builder->join("pedidos t2", "t2.id = t1.pedido_id", "left"); $builder->join("pedidos t2", "t2.id = t1.pedido_id", "left");
$builder->join("presupuestos t3", "t1.presupuesto_id = t3.id", "left"); $builder->join("presupuestos t3", "t1.presupuesto_id = t3.id", "left");
$builder->join("clientes t4", "t4.id = t3.cliente_id", "left");
$builder->join("users t5", "t5.id = t4.comercial_id", "left");
$builder->join("ubicaciones t6", "t6.id = t1.ubicacion_id", "left");
if($cliente_id != -1) { if($cliente_id != -1 && $cliente_id != "-1") {
$builder->where("t3.cliente_id", $cliente_id); $builder->where("t3.cliente_id", $cliente_id);
} }
@ -167,7 +172,7 @@ class PedidoLineaModel extends \App\Models\BaseModel
} }
if ($estado !== '') { if ($estado !== '') {
$builder->where('estado', $estado); $builder->where('t2.estado', $estado);
} }
// Aplicar el orden y el límite // Aplicar el orden y el límite
@ -177,7 +182,7 @@ class PedidoLineaModel extends \App\Models\BaseModel
return $builder->get()->getRow()->total; return $builder->get()->getRow()->total;
} }
public function getTotalOfTotalAceptado() public function getTotalOfTotalAceptado($estado = "")
{ {
$builder = $this->db $builder = $this->db
@ -187,10 +192,30 @@ class PedidoLineaModel extends \App\Models\BaseModel
$builder->join("pedidos t2", "t2.id = t1.pedido_id", "left"); $builder->join("pedidos t2", "t2.id = t1.pedido_id", "left");
$builder->join("presupuestos t3", "t1.presupuesto_id = t3.id", "left"); $builder->join("presupuestos t3", "t1.presupuesto_id = t3.id", "left");
if ($estado !== '') {
$builder->where('t2.estado', $estado);
}
return $builder->get()->getRow()->total; return $builder->get()->getRow()->total;
} }
public function getTotalTirada($estado = "")
{
$builder = $this->db
->table($this->table . " t1")
->selectSum('t3.tirada', 'total_tirada');
$builder->join("pedidos t2", "t2.id = t1.pedido_id", "left");
$builder->join("presupuestos t3", "t1.presupuesto_id = t3.id", "left");
if ($estado !== '') {
$builder->where('t2.estado', $estado);
}
return $builder->get()->getRow()->total_tirada;
}
public function obtenerLineasPedidoSinFacturar($cliente_id) { public function obtenerLineasPedidoSinFacturar($cliente_id) {
$resultaArray = []; $resultaArray = [];

View File

@ -193,7 +193,7 @@ class PresupuestoAcabadosModel extends \App\Models\BaseModel
->table($this->table . " t1") ->table($this->table . " t1")
->set('presupuesto_id', $presupuesto_id) ->set('presupuesto_id', $presupuesto_id)
->set('tarifa_acabado_id', $tarifa->tarifa_id) ->set('tarifa_acabado_id', $tarifa->tarifa_id)
->set('proveedor_id', $proveedor, false) ->set('proveedor_id', $proveedor)
->set('precio_unidad', $tarifa->precio_unidad) ->set('precio_unidad', $tarifa->precio_unidad)
->set('precio_total', $tarifa->precio_total) ->set('precio_total', $tarifa->precio_total)
->set('margen', $tarifa->margen) ->set('margen', $tarifa->margen)

View File

@ -9,7 +9,7 @@ use CodeIgniter\Model;
class TarifaExtraMaquinaModel extends Model class TarifaExtraMaquinaModel extends Model
{ {
protected $table = 'tarifa_acabado_maquinas'; protected $table = 'tarifa_extra_maquinas';
protected $primaryKey = 'id'; protected $primaryKey = 'id';
protected $useAutoIncrement = true; protected $useAutoIncrement = true;
protected $returnType = TarifaExtraMaquinaEntity::class; protected $returnType = TarifaExtraMaquinaEntity::class;

View File

@ -17,12 +17,12 @@ use App\Models\Configuracion\ConfigVariableModel;
use App\Models\Presupuestos\PresupuestoModel; use App\Models\Presupuestos\PresupuestoModel;
use App\Models\Usuarios\UserModel; use App\Models\Usuarios\UserModel;
use CodeIgniter\Config\BaseService; use CodeIgniter\Config\BaseService;
use CodeIgniter\Email\Email; use App\Services\EmailService;
class ChatService extends BaseService class ChatService extends BaseService
{ {
protected ?ChatEntity $chatEntity; protected ?ChatEntity $chatEntity;
protected Email $emailService; protected EmailService $emailService;
protected UserModel $userModel; protected UserModel $userModel;
protected ChatModel $chatModel; protected ChatModel $chatModel;
protected ChatMessageModel $chatMessageModel; protected ChatMessageModel $chatMessageModel;

View File

@ -253,7 +253,8 @@ class PresupuestoService extends BaseService
$linea['fields']['precio_libro'] = $linea['fields']['pliegos_libro'] * $linea['fields']['precios_pliegos']; $linea['fields']['precio_libro'] = $linea['fields']['pliegos_libro'] * $linea['fields']['precios_pliegos'];
// Precio papel pedido // Precio papel pedido
$linea['fields']['precio_pedido'] = $linea['fields']['precio_libro'] * ($datosPedido->tirada + $datosPedido->merma); $linea['fields']['precio_pedido'] = $linea['fields']['precio_libro'] * ($datosPedido->tirada + $datosPedido->merma);
$linea['fields']['margen_papel_pedido'] = $linea['fields']['pliegos_libro'] * $margen_pliego_impresion * ($datosPedido->tirada + $datosPedido->merma);; $linea['fields']['margen_papel_pedido'] = $linea['fields']['pliegos_libro'] * $margen_pliego_impresion * ($datosPedido->tirada + $datosPedido->merma);
;
$linea['fields']['a_favor_fibra'] = $parametrosRotativa->a_favor_fibra; $linea['fields']['a_favor_fibra'] = $parametrosRotativa->a_favor_fibra;
$linea['fields']['maquina'] = $maquina->maquina; $linea['fields']['maquina'] = $maquina->maquina;
@ -890,8 +891,7 @@ class PresupuestoService extends BaseService
if ($lomoRedondo) { if ($lomoRedondo) {
$ancho_total += 6; $ancho_total += 6;
} }
} } else if ($uso == 'faja' || $uso == 'sobrecubierta') {
else if ($uso == 'faja' || $uso == 'sobrecubierta') {
if ($datosPedido->solapas) { if ($datosPedido->solapas) {
// 7 es el vuelo de la tapa dura sobre el interior // 7 es el vuelo de la tapa dura sobre el interior
$ancho_total += (floatval($datosPedido->solapas_ancho) * 2) + (2 * self::SANGRE_FORMAS) + 2 * 7; $ancho_total += (floatval($datosPedido->solapas_ancho) * 2) + (2 * self::SANGRE_FORMAS) + 2 * 7;
@ -1898,7 +1898,16 @@ class PresupuestoService extends BaseService
if ($id_linea != 0 && $pedido_id != 0) { if ($id_linea != 0 && $pedido_id != 0) {
if ($data_pedido['estado'] == "produccion") { if ($data_pedido['estado'] == "produccion") {
$response = (new Pedido())->to_produccion($pedido_id);
$serviceProduction = service('production');
$modelPedido = model('App\Models\Pedidos\PedidoModel');
$pedido = $modelPedido->find($pedido_id);
$serviceProduction->setPedido($pedido);
if (!$pedido->orden_trabajo()) {
$r = $serviceProduction->createOrdenTrabajo();
$modelPedido->set(['estado' => 'produccion'])->where('id', $pedido_id)->update();
}
} }
return true; return true;
} }

View File

@ -13,9 +13,20 @@
<!--//.card-header --> <!--//.card-header -->
<form id="pedidoForm" method="post" class="card-body" action="<?= $formAction ?>"> <form id="pedidoForm" method="post" class="card-body" action="<?= $formAction ?>">
<?= csrf_field() ?> <?= csrf_field() ?>
<div class="card-body"> <div class="card-body pt-0">
<?= view("themes/_commonPartialsBs/_alertBoxes") ?> <?= view("themes/_commonPartialsBs/_alertBoxes") ?>
<?= !empty($validation->getErrors()) ? $validation->listErrors("bootstrap_style") : "" ?> <?= !empty($validation->getErrors()) ? $validation->listErrors("bootstrap_style") : "" ?>
<?php if (isset($orden_id)): ?>
<div class="row mt-1 justify-content-end">
<div class="col-auto">
<div class="btn mt-3 btn-warning waves-effect waves-light ml-2"
onclick="window.location.href='<?= route_to("viewOrdenTrabajoEdit", $orden_id) ?>'" >
<span class="align-middle d-sm-inline-block d-none me-sm-1">Orden</span>
<i class="ti ti-building-factory-2 ti-xs"></i>
</div>
</div>
</div>
<?php endif; ?>
<?= view("themes/vuexy/form/pedidos/_cabeceraItems") ?> <?= view("themes/vuexy/form/pedidos/_cabeceraItems") ?>
<?= view("themes/vuexy/form/pedidos/_lineasItems") ?> <?= view("themes/vuexy/form/pedidos/_lineasItems") ?>
<?php if (!(auth()->user()->inGroup('cliente-admin') || auth()->user()->inGroup('cliente-editor'))) : ?> <?php if (!(auth()->user()->inGroup('cliente-admin') || auth()->user()->inGroup('cliente-editor'))) : ?>
@ -29,7 +40,7 @@
<div class="row"> <div class="row">
<div class="col-md-12 d-flex justify-content-between"> <div class="col-md-12 d-flex justify-content-between">
<div class="pt-4"> <div class="pt-4">
<?= anchor(route_to("listaPresupuestos"), lang("Basic.global.Cancel"), ["class" => "btn btn-secondary float-start"]) ?> <?= anchor(route_to("listaPedidos"), lang("Basic.global.Cancel"), ["class" => "btn btn-secondary float-start"]) ?>
</div><!-- /.card-footer --> </div><!-- /.card-footer -->
</div> </div>
</div> </div>

View File

@ -72,10 +72,10 @@ $('#tableOfPedidos thead tr:eq(1) th').each(function (i) {
var title = $(this).text(); var title = $(this).text();
if($(this).hasClass("totalizador")){ if($(this).hasClass("totalizador")){
if(i==9){ if(i==9){
$(this).html('<span id="total_tirada" class="autonumeric"></span>'); $(this).html('<span id="total_tirada" class="autonumeric-int"></span><br><span id="total_tirada_2" class="mostrar-totales autonumeric-int d-none"></span>');
} }
else if(i==10){ else if(i==10){
$(this).html('<span id="total_aceptado" class="autonumeric"></span>'); $(this).html('<span id="total_aceptado" class="autonumeric"></span>€<br><span id="total_aceptado_2" class="mostrar-totales autonumeric d-none"></span><span class="mostrar-totales d-none">€</span>');
} }
} }
else{ else{
@ -125,7 +125,9 @@ $('#tableOfPedidos thead tr:eq(1) th').each(function (i) {
} }
else if (i == 11) { else if (i == 11) {
// Agregar un selector en la tercera columna
if("<?= $estadoPedidos ?>" == "" || "<?= $estadoPedidos ?>" == "todos"){
$(this).html('<select class="form-control" style="min-width:100px;max-width:120px;font-size:0.8rem !important;"></select>'); $(this).html('<select class="form-control" style="min-width:100px;max-width:120px;font-size:0.8rem !important;"></select>');
// Agregar opciones al selector // Agregar opciones al selector
@ -145,6 +147,10 @@ $('#tableOfPedidos thead tr:eq(1) th').each(function (i) {
theTable.column(i).search(val).draw(); theTable.column(i).search(val).draw();
}); });
} }
else{
$(this).html('<span></span>');
}
}
else{ else{
$(this).html('<input type="text" class="form-control " style="min-width:100px;max-width:120px;font-size:0.8rem !important;" />'); $(this).html('<input type="text" class="form-control " style="min-width:100px;max-width:120px;font-size:0.8rem !important;" />');
@ -189,7 +195,7 @@ $('#tableOfPedidos thead tr:eq(1) th').each(function (i) {
} }
], ],
stateSave: false, stateSave: false,
order: [[0, 'asc']], order: [[0, 'desc']],
language: { language: {
url: "/themes/vuexy/vendor/libs/datatables-sk/plugins/i18n/es-ES.json" url: "/themes/vuexy/vendor/libs/datatables-sk/plugins/i18n/es-ES.json"
}, },
@ -256,17 +262,21 @@ $('#tableOfPedidos thead tr:eq(1) th').each(function (i) {
{ 'data': actionBtns } { 'data': actionBtns }
], ],
drawCallback: function (settings) { drawCallback: function (settings) {
$('#total_tirada').text(settings.json.extra.total_tirada);
$('#total_aceptado').text(settings.json.extra.total);
}
});
theTable.on( 'draw.dt', function () { var api = this.api();
$('#total_tirada').text(settings.json.extra.total_tirada??0);
$('#total_tirada_2').text(settings.json.extra.total_tirada2??0);
$('#total_aceptado').text(settings.json.extra.total??0);
$('#total_aceptado_2').text(settings.json.extra.total2??0);
AutoNumeric.multiple('.autonumeric', { decimalPlaces: 2 });
AutoNumeric.multiple('.autonumeric-int', { decimalPlaces: 0 });
const dateCols = [1,2]; const dateCols = [1,2];
const priceCols = [10]; const priceCols = [10];
for (let coln of dateCols) { for (let coln of dateCols) {
theTable.column(coln, { page: 'current' }).nodes().each( function (cell, i) { api.column(coln, { page: 'current' }).nodes().each( function (cell, i) {
const datestr = cell.innerHTML; const datestr = cell.innerHTML;
const dateStrLen = datestr.toString().trim().length; const dateStrLen = datestr.toString().trim().length;
if (dateStrLen > 0) { if (dateStrLen > 0) {
@ -277,19 +287,30 @@ $('#tableOfPedidos thead tr:eq(1) th').each(function (i) {
} }
}); });
} }
if(<?= $cliente_id ?> != -1){ if(<?= $cliente_id ?> != -1){
// Se oculta la columna de cliente (3) api.column(3).visible(false);
theTable.column(3).visible(false);
} }
else{ else{
theTable.column(3).visible(true); api.column(3).visible(true);
}
},
"rowCallback": function(row, data, index) {
if('<?= $estadoPedidos ?>' == 'todos'){
if (data['estado'] === "cancelado") {
$(row).css('background-color', '#ffcccc'); // Rojo claro
} else if (data['estado'] === "validacion") {
$(row).css('background-color', '#fff5cc'); // Amarillo claro
} else if (data['estado'] === "finalizado") {
$(row).css('background-color', '#ccffcc'); // Verde claro
}
}
} }
}); });
$(document).on('click', '.btn-edit', function(e) { $(document).on('click', '.btn-edit', function(e) {
var url = '<?= route_to('editarPedido', ':id') ?>'; var url = '<?= route_to('editarPedido', ':id') ?>';
url = url.replace(':id', `${$(this).attr('data-id')}` ); url = url.replace(':id', `${$(this).attr('data-id')}` );
@ -301,6 +322,12 @@ $('#tableOfPedidos thead tr:eq(1) th').each(function (i) {
}); });
$('#showTotal').on('change', function() { $('#showTotal').on('change', function() {
if($('#showTotal').is(':checked')){
$('.mostrar-totales').removeClass('d-none');
}
else{
$('.mostrar-totales').addClass('d-none');
}
theTable.clearPipeline(); theTable.clearPipeline();
theTable.ajax.reload(null, false); theTable.ajax.reload(null, false);
//theTable.draw(); //theTable.draw();

View File

@ -31,6 +31,28 @@
<input type="hidden" name="POD" id="POD" class="form-control" <input type="hidden" name="POD" id="POD" class="form-control"
value="<?= $POD ?>"></input> value="<?= $POD ?>"></input>
<?php if (isset($orden__id) || isset($pedido_id)): ?>
<div class="row mt-1 justify-content-end">
<?php if (isset($pedido_id)): ?>
<div class="col-auto">
<div class="btn mt-3 btn-warning waves-effect waves-light ml-2"
onclick="window.location.href='<?= route_to("editarPedido", $pedido_id) ?>'" >
<span class="align-middle d-sm-inline-block d-none me-sm-1"><?= lang('Pedidos.pedido') ?></span>
<i class="ti ti-file-description ti-xs"></i>
</div>
</div>
<?php endif; ?>
<?php if (isset($orden_id)): ?>
<div class="col-auto">
<div class="btn mt-3 btn-warning waves-effect waves-light ml-2"
onclick="window.location.href='<?= route_to("viewOrdenTrabajoEdit", $orden_id) ?>'" >
<span class="align-middle d-sm-inline-block d-none me-sm-1">Orden</span>
<i class="ti ti-building-factory-2 ti-xs"></i>
</div>
</div>
<?php endif; ?>
</div>
<?php endif; ?>
<?= view("themes/vuexy/form/presupuestos/admin/_datosPresupuestoItems") ?> <?= view("themes/vuexy/form/presupuestos/admin/_datosPresupuestoItems") ?>
<?= view("themes/vuexy/form/presupuestos/admin/_datosLibroItems") ?> <?= view("themes/vuexy/form/presupuestos/admin/_datosLibroItems") ?>
<?php if (str_contains($formAction, 'edit')): ?> <?php if (str_contains($formAction, 'edit')): ?>

View File

@ -309,8 +309,10 @@ id = -1;
table : "#tableOfTarifaencuadernacionlineasHoras", table : "#tableOfTarifaencuadernacionlineasHoras",
idSrc: 'id', idSrc: 'id',
fields: [ fields: [
{name: "id", {
"type": "readonly"}, name: "id",
"type": "readonly"
},
{ {
name: "tiempo_min", name: "tiempo_min",
attr: { attr: {
@ -358,6 +360,7 @@ id = -1;
}, },
] ]
}); });
editor3.on('open', (event) => { editor3.on('open', (event) => {
$("input.autonumeric").each(function () { $("input.autonumeric").each(function () {
let autoNumericInstance = AutoNumeric.getAutoNumericElement(this) let autoNumericInstance = AutoNumeric.getAutoNumericElement(this)
@ -374,6 +377,7 @@ id = -1;
}); });
}) })
}) })
editor3.on('preSubmit', (e, d, type) => { editor3.on('preSubmit', (e, d, type) => {
if (d.data) { if (d.data) {
Object.keys(d.data).forEach(function (key) { Object.keys(d.data).forEach(function (key) {
@ -389,6 +393,7 @@ id = -1;
}); });
} }
}) })
editor3.on('preSubmit', function (e, d, type) { editor3.on('preSubmit', function (e, d, type) {
if (type === 'create') { if (type === 'create') {
d.data[0]['tirada_encuadernacion_id'] = selected_tirada_id; d.data[0]['tirada_encuadernacion_id'] = selected_tirada_id;
@ -531,8 +536,6 @@ id = -1;
} }
<?= $this->endSection() ?> <?= $this->endSection() ?>
@ -553,8 +556,10 @@ id = -1;
table : "#tableOfTarifaencuadernacionlineas", table : "#tableOfTarifaencuadernacionlineas",
idSrc: 'id', idSrc: 'id',
fields: [ fields: [
{name: "id", {
"type": "readonly"}, name: "id",
"type": "readonly"
},
{ {
name: "dimensiones_id", name: "dimensiones_id",
"type": "select" "type": "select"
@ -697,7 +702,8 @@ id = -1;
}), }),
columns: [ columns: [
{ 'data': 'id' }, { 'data': 'id' },
{ 'data': 'dimensiones_id', {
'data': 'dimensiones_id',
render: function (data, type, row, meta) { render: function (data, type, row, meta) {
var value = dimensionesList.find(element => element.value === data); var value = dimensionesList.find(element => element.value === data);
return value['label']; return value['label'];
@ -797,7 +803,6 @@ id = -1;
} }
<?= $this->endSection() ?> <?= $this->endSection() ?>
<!-------------------------------------------> <!------------------------------------------->
@ -808,7 +813,6 @@ id = -1;
// Definicion de la ultima columna de la tabla // Definicion de la ultima columna de la tabla
const lastColNr2 = $('#tableOfTarifaencuadernaciontiradas').find("tr:first th").length - 1; const lastColNr2 = $('#tableOfTarifaencuadernaciontiradas').find("tr:first th").length - 1;
// Datatables Editor // Datatables Editor
var editor2 = new $.fn.dataTable.Editor({ var editor2 = new $.fn.dataTable.Editor({
ajax: { ajax: {
@ -946,7 +950,8 @@ id = -1;
async: true, async: true,
}), }),
columns: [ columns: [
{ 'data': 'proveedor_id', {
'data': 'proveedor_id',
render: function (data, type, row, meta) { render: function (data, type, row, meta) {
var value = suppliersList.find(element => element.value === data); var value = suppliersList.find(element => element.value === data);
return value['label']; return value['label'];

View File

@ -16,6 +16,13 @@ if (
<?= lang("App.menu_pedidos") ?> <?= lang("App.menu_pedidos") ?>
</a> </a>
<ul class="menu-sub"> <ul class="menu-sub">
<?php if (auth()->user()->can('pedidos-validacion.menu')) { ?>
<li class="menu-item">
<a href="<?= site_url("pedidos/pedido/validacion") ?>" class="menu-link">
<?= lang("App.menu_pedidos_validacion") ?>
</a>
</li>
<?php } ?>
<?php if (auth()->user()->can('pedidos-activos.menu')) { ?> <?php if (auth()->user()->can('pedidos-activos.menu')) { ?>
<li class="menu-item"> <li class="menu-item">
<a href="<?= site_url("pedidos/pedido/activos") ?>" class="menu-link"> <a href="<?= site_url("pedidos/pedido/activos") ?>" class="menu-link">

View File

@ -169,8 +169,8 @@ class PresupuestoAdminEdit {
new Ajax('/presupuestoadmin/edit/' + id, data, {}, new Ajax('/presupuestoadmin/edit/' + id, data, {},
function (response) { function (response) {
popSuccessAlert(response.mensaje); sessionStorage.setItem('message', response.mensaje);
$('#loader').modal('hide'); location.reload();
}, },
function (error) { function (error) {
console.error(error); console.error(error);