Merge branch 'main' into 'mod/autoroute'

terminado añadir usuarios y fechas a pedidos. añadido inaplazable. color en...

See merge request jjimenez/safekat!695
This commit is contained in:
Ignacio Martinez Navajas
2025-04-12 20:18:05 +00:00
46 changed files with 965 additions and 1134 deletions

View File

@ -1,387 +0,0 @@
<?php
const SK_PERMISSION_MATRIX = [
"admin" => [
"clientes.create",
"clientes.edit",
"clientes.delete",
"clientes.menu",
"plantilla-tarifa.create",
"plantilla-tarifa.edit",
"plantilla-tarifa.delete",
"plantilla-tarifa.menu",
"direcciones.create",
"direcciones.edit",
"direcciones.delete",
"direcciones.menu",
"presupuesto.create",
"presupuesto.edit",
"presupuesto.delete",
"presupuesto.menu",
"presupuesto-cliente.create",
"presupuesto-cliente.edit",
"presupuesto-cliente.delete",
"presupuesto-cliente.menu",
"pedidos-activos.view",
"pedidos-activos.menu",
"pedidos-finalizados.view",
"pedidos-finalizados.menu",
"pedidos-cancelados.view",
"pedidos-cancelados.menu",
"pedidos-todos.view",
"pedidos-todos.menu",
"tarifa-preimpresion.create",
"tarifa-preimpresion.edit",
"tarifa-preimpresion.delete",
"tarifa-preimpresion.menu",
"tarifa-manipulado.create",
"tarifa-manipulado.edit",
"tarifa-manipulado.delete",
"tarifa-manipulado.menu",
"tarifa-acabado.create",
"tarifa-acabado.edit",
"tarifa-acabado.delete",
"tarifa-acabado.menu",
"tarifa-encuadernacion.create",
"tarifa-encuadernacion.edit",
"tarifa-encuadernacion.delete",
"tarifa-encuadernacion.menu",
"tarifa-extra.create",
"tarifa-extra.edit",
"tarifa-extra.delete",
"tarifa-extra.menu",
"tarifa-envio.create",
"tarifa-envio.edit",
"tarifa-envio.delete",
"tarifa-envio.menu",
"servicio-acabado.create",
"servicio-acabado.edit",
"servicio-acabado.delete",
"servicio-acabado.menu",
"proveedores.create",
"proveedores.edit",
"proveedores.delete",
"proveedores.menu",
"ajustes.create",
"ajustes.edit",
"ajustes.delete",
"ajustes.menu",
"actividad.create",
"actividad.edit",
"actividad.delete",
"actividad.menu",
"paises.create",
"paises.edit",
"paises.delete",
"paises.menu",
"maquinas.create",
"maquinas.edit",
"maquinas.delete",
"maquinas.menu",
"maquinas-defecto.create",
"maquinas-defecto.edit",
"maquinas-defecto.delete",
"maquinas-defecto.menu",
"papel-generico.create",
"papel-generico.edit",
"papel-generico.delete",
"papel-generico.menu",
"papel-impresion.create",
"papel-impresion.edit",
"papel-impresion.delete",
"papel-impresion.menu",
"usuarios.create",
"usuarios.edit",
"usuarios.delete",
"usuarios.menu",
"roles-permisos.create",
"roles-permisos.edit",
"roles-permisos.delete",
"roles-permisos.menu",
"tickets.create",
"tickets.edit",
"tickets.menu",
"facturas.create",
"facturas.edit",
"facturas.vencimientos",
"facturas.menu",
],
"cliente-admin" => [
"presupuesto-cliente.create",
"presupuesto-cliente.edit",
"presupuesto-cliente.delete",
"presupuesto-cliente.menu",
"pedidos-activos.view",
"pedidos-activos.menu",
"pedidos-finalizados.view",
"pedidos-finalizados.menu",
"pedidos-cancelados.view",
"pedidos-cancelados.menu",
"pedidos-todos.view",
"pedidos-todos.menu",
],
"cliente-editor" => [
"presupuesto-cliente.create",
"presupuesto-cliente.edit",
"presupuesto-cliente.menu",
"pedidos-activos.view",
"pedidos-activos.menu",
"pedidos-finalizados.view",
"pedidos-finalizados.menu",
"pedidos-cancelados.view",
"pedidos-cancelados.menu",
"pedidos-todos.view",
"pedidos-todos.menu",
],
"comercial" => [
"clientes.create",
"clientes.edit",
"clientes.menu",
"direcciones.create",
"direcciones.edit",
"direcciones.menu",
"presupuesto.create",
"presupuesto.edit",
"presupuesto.menu",
"presupuesto-cliente.create",
"presupuesto-cliente.edit",
"presupuesto-cliente.menu",
"pedidos-activos.view",
"pedidos-activos.menu",
"pedidos-finalizados.view",
"pedidos-finalizados.menu",
"pedidos-cancelados.view",
"pedidos-cancelados.menu",
"pedidos-todos.view",
"pedidos-todos.menu",
],
"produccion" => [
"direcciones.create",
"direcciones.edit",
"direcciones.menu",
"presupuesto.create",
"presupuesto.edit",
"presupuesto.menu",
"presupuesto-cliente.create",
"presupuesto-cliente.edit",
"presupuesto-cliente.menu",
"pedidos-validacion.view",
"pedidos-validacion.menu",
"pedidos-activos.view",
"pedidos-activos.menu",
"pedidos-finalizados.view",
"pedidos-finalizados.menu",
"pedidos-cancelados.view",
"pedidos-cancelados.menu",
"pedidos-todos.view",
"pedidos-todos.menu",
"pedidos-gestion.toprod",
"pedidos-gestion.menu",
"tickets.edit",
"tickets.menu",
],
"maquina" => [
"token.token",
"token.menu",
],
"maquetador" => [
"token.token",
"token.menu",
],
"director" => [
"clientes.create",
"clientes.edit",
"clientes.menu",
"plantilla-tarifa.create",
"plantilla-tarifa.edit",
"plantilla-tarifa.menu",
"direcciones.create",
"direcciones.edit",
"direcciones.menu",
"presupuesto.create",
"presupuesto.edit",
"presupuesto.menu",
"presupuesto-cliente.create",
"presupuesto-cliente.edit",
"presupuesto-cliente.menu",
"pedidos-activos.view",
"pedidos-activos.menu",
"pedidos-finalizados.view",
"pedidos-finalizados.menu",
"pedidos-cancelados.view",
"pedidos-cancelados.menu",
"pedidos-todos.view",
"pedidos-todos.menu",
"pedidos-gestion.toprod",
"pedidos-gestion.menu",
"tarifa-preimpresion.create",
"tarifa-preimpresion.edit",
"tarifa-preimpresion.menu",
"tarifa-manipulado.create",
"tarifa-manipulado.edit",
"tarifa-manipulado.menu",
"tarifa-acabado.create",
"tarifa-acabado.edit",
"tarifa-acabado.menu",
"tarifa-encuadernacion.create",
"tarifa-encuadernacion.edit",
"tarifa-encuadernacion.menu",
"tarifa-extra.create",
"tarifa-extra.edit",
"tarifa-extra.menu",
"tarifa-envio.create",
"tarifa-envio.edit",
"tarifa-envio.menu",
"servicio-acabado.create",
"servicio-acabado.edit",
"servicio-acabado.menu",
"proveedores.create",
"proveedores.edit",
"proveedores.menu",
"tickets.edit",
"tickets.menu",
"facturas.create",
"facturas.edit",
"facturas.vencimientos",
"facturas.menu",
],
"contabilidad" => [
"clientes.create",
"clientes.edit",
"clientes.menu",
"direcciones.create",
"direcciones.edit",
"direcciones.menu",
"presupuesto.create",
"presupuesto.edit",
"presupuesto.menu",
"pedidos-validacion.view",
"pedidos-validacion.menu",
"pedidos-activos.view",
"pedidos-activos.menu",
"pedidos-finalizados.view",
"pedidos-finalizados.menu",
"pedidos-cancelados.view",
"pedidos-cancelados.menu",
"pedidos-todos.view",
"pedidos-todos.menu",
"proveedores.create",
"proveedores.edit",
"proveedores.menu",
"tickets.edit",
"tickets.menu",
"facturas.create",
"facturas.edit",
"facturas.vencimientos",
"facturas.menu",
],
"editor" => [
"token.token",
"token.menu",
"Profile.index",
"Profile.menu",
],
"beta" => [
"clientes.create",
"clientes.edit",
"clientes.delete",
"clientes.menu",
"plantilla-tarifa.create",
"plantilla-tarifa.edit",
"plantilla-tarifa.delete",
"plantilla-tarifa.menu",
"direcciones.create",
"direcciones.edit",
"direcciones.delete",
"direcciones.menu",
"presupuesto.create",
"presupuesto.edit",
"presupuesto.delete",
"presupuesto.menu",
"presupuesto-cliente.create",
"presupuesto-cliente.edit",
"presupuesto-cliente.delete",
"presupuesto-cliente.menu",
"pedidos-activos.view",
"pedidos-activos.menu",
"pedidos-finalizados.view",
"pedidos-finalizados.menu",
"pedidos-cancelados.view",
"pedidos-cancelados.menu",
"pedidos-todos.view",
"pedidos-todos.menu",
"tarifa-preimpresion.create",
"tarifa-preimpresion.edit",
"tarifa-preimpresion.delete",
"tarifa-preimpresion.menu",
"tarifa-manipulado.create",
"tarifa-manipulado.edit",
"tarifa-manipulado.delete",
"tarifa-manipulado.menu",
"tarifa-acabado.create",
"tarifa-acabado.edit",
"tarifa-acabado.delete",
"tarifa-acabado.menu",
"tarifa-encuadernacion.create",
"tarifa-encuadernacion.edit",
"tarifa-encuadernacion.delete",
"tarifa-encuadernacion.menu",
"tarifa-extra.create",
"tarifa-extra.edit",
"tarifa-extra.delete",
"tarifa-extra.menu",
"tarifa-envio.create",
"tarifa-envio.edit",
"tarifa-envio.delete",
"tarifa-envio.menu",
"servicio-acabado.create",
"servicio-acabado.edit",
"servicio-acabado.delete",
"servicio-acabado.menu",
"proveedores.create",
"proveedores.edit",
"proveedores.delete",
"proveedores.menu",
"ajustes.create",
"ajustes.edit",
"ajustes.delete",
"ajustes.menu",
"actividad.create",
"actividad.edit",
"actividad.delete",
"actividad.menu",
"paises.create",
"paises.edit",
"paises.delete",
"paises.menu",
"maquinas.create",
"maquinas.edit",
"maquinas.delete",
"maquinas.menu",
"maquinas-defecto.create",
"maquinas-defecto.edit",
"maquinas-defecto.delete",
"maquinas-defecto.menu",
"papel-generico.create",
"papel-generico.edit",
"papel-generico.delete",
"papel-generico.menu",
"papel-impresion.create",
"papel-impresion.edit",
"papel-impresion.delete",
"papel-impresion.menu",
"usuarios.create",
"usuarios.edit",
"usuarios.delete",
"usuarios.menu",
"roles-permisos.create",
"roles-permisos.edit",
"roles-permisos.delete",
"roles-permisos.menu",
"tickets.edit",
"tickets.menu",
"facturas.create",
"facturas.edit",
"facturas.vencimientos",
"facturas.menu",
],
];

View File

@ -1,111 +0,0 @@
<?php
const SK_PERMISSIONS = [
'clientes.create' => 'Can create',
'clientes.edit' => 'Can edit',
'clientes.delete' => 'Can delete',
'clientes.menu' => 'Menu shall be visualize',
'plantilla-tarifa.create' => 'Can create',
'plantilla-tarifa.edit' => 'Can edit',
'plantilla-tarifa.delete' => 'Can delete',
'plantilla-tarifa.menu' => 'Menu shall be visualize',
'direcciones.create' => 'Can create',
'direcciones.edit' => 'Can edit',
'direcciones.delete' => 'Can delete',
'direcciones.menu' => 'Menu shall be visualize',
'presupuesto.create' => 'Can create',
'presupuesto.edit' => 'Can edit',
'presupuesto.delete' => 'Can delete',
'presupuesto.menu' => 'Menu shall be visualize',
'presupuesto-cliente.create' => 'Can create',
'presupuesto-cliente.edit' => 'Can edit',
'presupuesto-cliente.delete' => 'Can delete',
'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.menu' => 'Menu shall be visualize',
'pedidos-finalizados.view' => 'Can view',
'pedidos-finalizados.menu' => 'Menu shall be visualize',
'pedidos-cancelados.view' => 'Can view',
'pedidos-cancelados.menu' => 'Menu shall be visualize',
'pedidos-todos.view' => 'Can view',
'pedidos-todos.menu' => 'Menu shall be visualize',
'pedidos-gestion.toprod' => 'Can toprod',
'pedidos-gestion.menu' => 'Menu shall be visualize',
'tarifa-preimpresion.create' => 'Can create',
'tarifa-preimpresion.edit' => 'Can edit',
'tarifa-preimpresion.delete' => 'Can delete',
'tarifa-preimpresion.menu' => 'Menu shall be visualize',
'tarifa-manipulado.create' => 'Can create',
'tarifa-manipulado.edit' => 'Can edit',
'tarifa-manipulado.delete' => 'Can delete',
'tarifa-manipulado.menu' => 'Menu shall be visualize',
'tarifa-acabado.create' => 'Can create',
'tarifa-acabado.edit' => 'Can edit',
'tarifa-acabado.delete' => 'Can delete',
'tarifa-acabado.menu' => 'Menu shall be visualize',
'tarifa-encuadernacion.create' => 'Can create',
'tarifa-encuadernacion.edit' => 'Can edit',
'tarifa-encuadernacion.delete' => 'Can delete',
'tarifa-encuadernacion.menu' => 'Menu shall be visualize',
'tarifa-extra.create' => 'Can create',
'tarifa-extra.edit' => 'Can edit',
'tarifa-extra.delete' => 'Can delete',
'tarifa-extra.menu' => 'Menu shall be visualize',
'tarifa-envio.create' => 'Can create',
'tarifa-envio.edit' => 'Can edit',
'tarifa-envio.delete' => 'Can delete',
'tarifa-envio.menu' => 'Menu shall be visualize',
'servicio-acabado.create' => 'Can create',
'servicio-acabado.edit' => 'Can edit',
'servicio-acabado.delete' => 'Can delete',
'servicio-acabado.menu' => 'Menu shall be visualize',
'proveedores.create' => 'Can create',
'proveedores.edit' => 'Can edit',
'proveedores.delete' => 'Can delete',
'proveedores.menu' => 'Menu shall be visualize',
'ajustes.create' => 'Can create',
'ajustes.edit' => 'Can edit',
'ajustes.delete' => 'Can delete',
'ajustes.menu' => 'Menu shall be visualize',
'actividad.create' => 'Can create',
'actividad.edit' => 'Can edit',
'actividad.delete' => 'Can delete',
'actividad.menu' => 'Menu shall be visualize',
'paises.create' => 'Can create',
'paises.edit' => 'Can edit',
'paises.delete' => 'Can delete',
'paises.menu' => 'Menu shall be visualize',
'maquinas.create' => 'Can create',
'maquinas.edit' => 'Can edit',
'maquinas.delete' => 'Can delete',
'maquinas.menu' => 'Menu shall be visualize',
'maquinas-defecto.create' => 'Can create',
'maquinas-defecto.edit' => 'Can edit',
'maquinas-defecto.delete' => 'Can delete',
'maquinas-defecto.menu' => 'Menu shall be visualize',
'papel-generico.create' => 'Can create',
'papel-generico.edit' => 'Can edit',
'papel-generico.delete' => 'Can delete',
'papel-generico.menu' => 'Menu shall be visualize',
'papel-impresion.create' => 'Can create',
'papel-impresion.edit' => 'Can edit',
'papel-impresion.delete' => 'Can delete',
'papel-impresion.menu' => 'Menu shall be visualize',
'usuarios.create' => 'Can create',
'usuarios.edit' => 'Can edit',
'usuarios.delete' => 'Can delete',
'usuarios.menu' => 'Menu shall be visualize',
'roles-permisos.create' => 'Can create',
'roles-permisos.edit' => 'Can edit',
'roles-permisos.delete' => 'Can delete',
'roles-permisos.menu' => 'Menu shall be visualize',
'tickets.create' => 'Can create',
'tickets.edit' => 'Can edit',
'tickets.menu' => 'Menu shall be visualize',
'facturas.create' => 'Can create',
'facturas.edit' => 'Can edit',
'facturas.vencimientos' => 'Can vencimientos',
'facturas.menu' => 'Menu shall be visualize',
];

View File

@ -1,22 +0,0 @@
{
"superadmin": {
"title": "Super Admin",
"description": "Complete control of the site."
},
"admin": {
"title": "Admin",
"description": "Day to day administrators of the site."
},
"developer": {
"title": "Developer",
"description": "Site programmers."
},
"user": {
"title": "User",
"description": "General users of the site. Often customers."
},
"beta": {
"title": "Beta User",
"description": "Has access to beta-level features."
}
}

View File

@ -1,48 +0,0 @@
<?php
const SK_ROLES = [
'admin' => [
'title' => 'Administrador',
'description' => 'Administrador del ERP',
],
'cliente-admin' => [
'title' => 'Cliente administrador',
'description' => 'Rol de cliente con permisos de administración',
],
'cliente-editor' => [
'title' => 'Cliente editor',
'description' => 'Rol de cliente con permisos de edición',
],
'comercial' => [
'title' => 'Comercial',
'description' => '',
],
'produccion' => [
'title' => 'Producción',
'description' => '',
],
'maquina' => [
'title' => 'Máquina',
'description' => '',
],
'maquetador' => [
'title' => 'Maquetador',
'description' => '',
],
'director' => [
'title' => 'Director',
'description' => 'Para los directores de área',
],
'contabilidad' => [
'title' => 'Contabilidad',
'description' => '',
],
'editor' => [
'title' => 'Editor',
'description' => '',
],
'beta' => [
'title' => 'Beta',
'description' => '',
],
];

View File

@ -464,7 +464,7 @@ class Cliente extends \App\Controllers\BaseResourceController
return null;
}
$modelPlantillaPreciosCliente = model('App\Models\Clientes\ClientePlantillaPreciosModel');
$plantilla = $modelPlantillaPreciosCliente->where("id", $plantilla_id)->where("is_deleted", 0)->first();
$plantilla = $modelPlantillaPreciosCliente->where("id", $plantilla_id)->where("deleted_at", null)->first();
if ($plantilla == false) {
return null;
} else {

View File

@ -135,7 +135,6 @@ class ClientePrecios extends \App\Controllers\BaseResourceController
Field::inst('tipo_impresion'),
Field::inst('user_updated_id'),
Field::inst('updated_at'),
Field::inst('is_deleted'),
Field::inst('tiempo_min')
->getFormatter('Format::toDecimalChar')->setFormatter('Format::fromDecimalChar')
->validator(
@ -205,7 +204,6 @@ class ClientePrecios extends \App\Controllers\BaseResourceController
if ($action === Editor::ACTION_CREATE || $action === Editor::ACTION_EDIT) {
foreach ($data['data'] as $pkey => $values) {
// Si no se quiere borrar...
if ($data['data'][$pkey]['is_deleted'] != 1) {
$process_data['tiempo_min'] = $data['data'][$pkey]['tiempo_min'];
$process_data['tiempo_max'] = $data['data'][$pkey]['tiempo_max'];
$process_data['tipo'] = $data['data'][$pkey]['tipo'];
@ -217,7 +215,6 @@ class ClientePrecios extends \App\Controllers\BaseResourceController
if (!empty($response)) {
return $response;
}
}
}
}
})

View File

@ -155,7 +155,6 @@ class Clienteplantillaprecioslineas extends \App\Controllers\BaseResourceControl
Field::inst( 'tipo_impresion' ),
Field::inst( 'user_updated_id' ),
Field::inst( 'deleted_at' ),
Field::inst( 'is_deleted' ),
Field::inst( 'updated_at' ),
Field::inst( 'tiempo_min' )
->getFormatter( 'Format::toDecimalChar')->setFormatter( 'Format::fromDecimalChar')

View File

@ -230,6 +230,10 @@ class Facturas extends \App\Controllers\BaseResourceController
$factura->updated_by = $userModel->getFullName($factura->user_updated_id);
$factura->created_at_footer = $factura->created_at ? date(' H:i d/m/Y', strtotime($factura->created_at)) : '';
$factura->updated_at_footer = $factura->updated_at ? date(' H:i d/m/Y', strtotime($factura->updated_at)) : '';
$factura->showDeleteButton = model('App\Models\Facturas\FacturaPagoModel')
->where('factura_id', $factura->id)->countAllResults() == 0;
$this->viewData['facturaEntity'] = $factura;
$this->viewData['boxTitle'] = lang('Basic.global.edit2') . ' ' . lang('Facturas.factura') . ' ' . lang('Basic.global.edit3');
@ -692,7 +696,9 @@ class Facturas extends \App\Controllers\BaseResourceController
// Se añade la linea de factura
$descripcion = $model_presupuesto->generarLineaPedido($presupuesto->id, true, $linea->pedido_id);
$cantidad = intval($presupuesto->tirada) - intval($model_factura->getCantidadLineaPedidoFacturada($linea->id));
$base = $cantidad * floatval($presupuesto->total_precio_unidad);
$base =
floatval($presupuesto->total_aceptado_revisado && $presupuesto->total_aceptado_revisado != 0 ?
$presupuesto->total_aceptado_revisado : $presupuesto->total_aceptado);
$base = round($base, 2);
$total_iva = $base * ($presupuesto->iva_reducido == 1 ? 0.04 : 0.21);
// se redondea a dos decimales
@ -701,10 +707,9 @@ class Facturas extends \App\Controllers\BaseResourceController
$data = (object) [
'factura_id' => $factura_id,
'pedido_linea_impresion_id' => $linea->pedido_id,
'pedido_linea_impresion_id' => $pedido_linea_id,
'descripcion' => $descripcion[0]->concepto,
'cantidad' => $cantidad,
'precio_unidad' => $presupuesto->total_precio_unidad,
'iva' => $presupuesto->iva_reducido == 1 ? 4 : 21,
'base' => $base,
'total_iva' => $total_iva,

View File

@ -101,15 +101,6 @@ class FacturasLineas extends \App\Controllers\BaseResourceController
->validator('Validate::notEmpty', array(
'message' => lang('Facturas.validation.requerido'))
),
Field::inst( 'precio_unidad' )
->getFormatter( 'Format::toDecimalChar')->setFormatter( 'Format::fromDecimalChar')
->validator('Validate::numeric', array(
"decimal" => ',',
'message' => lang('Facturas.validation.decimal'))
)
->validator('Validate::notEmpty', array(
'message' => lang('Facturas.validation.requerido'))
),
Field::inst( 'iva' )
->validator('Validate::numeric', array(
'message' => lang('Facturas.validation.numerico'))
@ -128,7 +119,7 @@ class FacturasLineas extends \App\Controllers\BaseResourceController
$totales = $this->generate_totales(
$values['factura_id'],
$values['pedido_linea_impresion_id'],
$values['precio_unidad'],
$values['total'],
$values['iva'],
$values['cantidad'],
$values['old_cantidad']);
@ -152,7 +143,7 @@ class FacturasLineas extends \App\Controllers\BaseResourceController
$totales = $this->generate_totales(
$values['factura_id'],
$values['pedido_linea_impresion_id'],
$values['precio_unidad'],
$values['total'],
$values['iva'],
$values['cantidad'],
$values['old_cantidad']);
@ -203,7 +194,7 @@ class FacturasLineas extends \App\Controllers\BaseResourceController
$model->updateTotales($factura_id);
}
private function generate_totales($factura_id, $pedido_linea_id, $precio_unidad, $iva, $cantidad, $old_cantidad)
private function generate_totales($factura_id, $pedido_linea_id, $total, $iva, $cantidad, $old_cantidad)
{
// si es una linea que se refiere a pedido
@ -214,6 +205,7 @@ class FacturasLineas extends \App\Controllers\BaseResourceController
// se calcula y se actualiza el subtotal, total_iva y total
// redondeando a 4 decimales el precio_unidad y a dos el resto
$precio_unidad = round($total / $old_cantidad, 4);
$base = round($precio_unidad * $cantidad, 2);
$total_iva = round($base * $iva / 100, 2);
$total = round($base + $total_iva, 2);

View File

@ -57,10 +57,7 @@ class FacturasPagos extends \App\Controllers\BaseResourceController
->fields(
Field::inst( 'id' ),
Field::inst( 'forma_pago_id' ),
Field::inst( 'notes' )
->validator('Validate::notEmpty', array(
'message' => lang('Facturas.validation.requerido'))
),
Field::inst( 'notes' ),
Field::inst( 'fecha_pago_at' )
->validator( Validate::dateFormat( 'Y-m-d H:i:s' ) )
->getFormatter( Format::dateSqlToFormat( 'Y-m-d H:i:s' ) )

View File

@ -211,6 +211,8 @@ class Pedido extends \App\Controllers\BaseResourceController
public function update($id = null){
$data = [];
if ($this->request->isAJAX()) {
$newTokenHash = csrf_hash();
$csrfTokenName = csrf_token();
@ -242,6 +244,14 @@ class Pedido extends \App\Controllers\BaseResourceController
$sanitizedData = $this->sanitized($postData, $nullIfEmpty);
foreach(array_keys($sanitizedData) as $key){
if(str_starts_with($key, "fecha_")){
$sanitizedData[$key . "_change_user_id"] =
auth()->user()->id;
$data[$key . "_change_user"] =
model('App\Models\Usuarios\UserModel')->getFullName(auth()->user()->id);
}
}
// JJO
$sanitizedData['user_updated_id'] = auth()->user()->id;
@ -268,10 +278,9 @@ class Pedido extends \App\Controllers\BaseResourceController
$id = $pedidoEntity->id ?? $id;
$message = lang('Basic.global.updateSuccess', [lang('Basic.global.record')]) . '.';
$data = [
'error' => 0,
$csrfTokenName => $newTokenHash
];
$data['error'] = 0;
$data[$csrfTokenName] = $newTokenHash;
return $this->respond($data);
endif; // $noException && $successfulResult
@ -303,7 +312,15 @@ class Pedido extends \App\Controllers\BaseResourceController
$this->obtenerDatosFormulario($pedidoEntity);
$pedidoEntity->fecha_entrega_real_change_user = $pedidoEntity->fecha_entrega_real_change_user_id?model('App\Models\Usuarios\UserModel')->
getFullName($pedidoEntity->fecha_entrega_real_change_user_id):"";
$pedidoEntity->fecha_impresion_change_user = $pedidoEntity->fecha_impresion_change_user_id?model('App\Models\Usuarios\UserModel')->
getFullName($pedidoEntity->fecha_impresion_change_user_id):"";
$pedidoEntity->fecha_encuadernado_change_user = $pedidoEntity->fecha_encuadernado_change_user_id?model('App\Models\Usuarios\UserModel')->
getFullName($pedidoEntity->fecha_encuadernado_change_user_id):"";
$pedidoEntity->fecha_entrega_change_externo_user = $pedidoEntity->fecha_entrega_change_externo_user_id?model('App\Models\Usuarios\UserModel')->
getFullName($pedidoEntity->fecha_entrega_change_externo_user_id):"";
$this->viewData['pedidoEntity'] = $pedidoEntity;
if($pedidoEntity->estado == 'validacion'){
@ -321,6 +338,7 @@ class Pedido extends \App\Controllers\BaseResourceController
$this->viewData['boxTitle'] = lang('Basic.global.edit2') . ' ' . lang('Pedidos.moduleTitle') . ' ' . lang('Basic.global.edit3');
return $this->displayForm(__METHOD__, $id);
}

View File

@ -366,6 +366,36 @@ class Presupuestoadmin extends \App\Controllers\BaseResourceController
PresupuestoService::crearPedido($id);
}
// modificar los datos del pedido y de la factura si no está la factura validada
if ($presupuestoEntity->estado_id == 2){
$facturaModel = model('App\Models\Facturas\FacturaModel');
if(!$facturaModel->presupuestoHasFacturaValidada($id)){
// se actualiza primero el pedido
$pedidoModel = model('App\Models\Pedidos\PedidoLineaModel');
$pedidoLineaId = $pedidoModel->where('presupuesto_id', $id)->first()->id;
$linea_pedido = $this->model->generarLineaPedido($id)[0];
$idPedido = $pedidoModel->join('pedidos', 'pedidos_linea.pedido_id = pedidos.id')
->where('pedidos_linea.presupuesto_id', $id)
->first()->pedido_id;
$pedidoModel->update($pedidoLineaId, [
'cantidad' => $linea_pedido->unidades,
'descripcion' => $linea_pedido->concepto
]);
// se actualiza la factura
$linea_pedido = $this->model->generarLineaPedido($id, true, $idPedido)[0];
$facturaLineaModel = model('App\Models\Facturas\FacturaLineaModel');
$facturaLineaId = $facturaLineaModel->where('pedido_linea_impresion_id', $pedidoLineaId)->
where('deleted_at', null)->first()->id;
$facturaLineaModel->update($facturaLineaId, [
'cantidad' => $linea_pedido->unidades,
'descripcion' => $linea_pedido->concepto
]);
}
}
$newTokenHash = csrf_hash();
$csrfTokenName = csrf_token();
$data = [

View File

@ -15,6 +15,7 @@ use CodeIgniter\HTTP\ResponseInterface;
use CodeIgniter\I18n\Time;
use CodeIgniter\Validation\Validation;
use Config\LogoImpresion;
use Exception;
use Hermawan\DataTables\DataTable;
use Psr\Log\LoggerInterface;
@ -276,16 +277,26 @@ class Ordentrabajo extends BaseController
}
public function get_portada_img($orden_trabajo_id)
{
$ot = $this->otModel->find($orden_trabajo_id);
if ($ot->portada_path) {
$filePath = WRITEPATH . 'uploads/' . $ot->portada_path;
$mimeType = mime_content_type($filePath);
return $this->response
->setHeader('Content-Type', $mimeType)
->setHeader('Content-Length', filesize($filePath))
->setBody(file_get_contents($filePath));
} else {
return $this->response->setJSON(["message" => "Portada error", "error" => "No hay portada"])->setStatusCode(400);
try {
$ot = $this->otModel->find($orden_trabajo_id);
if ($ot->portada_path) {
$filePath = WRITEPATH . 'uploads/' . $ot->portada_path;
if (file_exists($filePath)) {
$mimeType = mime_content_type($filePath);
return $this->response
->setHeader('Content-Type', $mimeType)
->setHeader('Content-Length', filesize($filePath))
->setBody(file_get_contents($filePath));
} else {
throw new Exception('File' . $ot->portada_path . ' does not exist');
}
} else {
return $this->response->setJSON(["message" => "Portada error", "error" => "No hay portada"])->setStatusCode(400);
}
} catch (\Throwable $th) {
return $this->response->setJSON(["message" => "Portada error", "error" => $th->getMessage()])->setStatusCode(500);
}
}
public function planning_rotativa_datatable()
@ -302,8 +313,8 @@ class Ordentrabajo extends BaseController
{
$q = $this->produccionService->planningPlanaQueryDatatable();
$padreId = $this->request->getGet('padre_id');
if($padreId){
$q->where('lg_maquinas.padre_id',$padreId);
if ($padreId) {
$q->where('lg_maquinas.padre_id', $padreId);
}
return DataTable::of($q)
->edit("tiempo_real_sum", fn($q) => $q->tiempo_real_sum)
@ -372,9 +383,9 @@ class Ordentrabajo extends BaseController
$ps = $this->produccionService->init($bodyData["orden_trabajo_id"]);
$existingFiles = json_decode($bodyData["oldFiles"]);
$ps->deleteOtFiles($existingFiles);
if($files){
if ($files) {
$response = $ps->storeOtFiles($files);
}else{
} else {
$response = null;
}
return $this->response->setJSON([

View File

@ -0,0 +1,24 @@
<?php
namespace App\Database\Migrations;
use CodeIgniter\Database\Migration;
class RemovePrecioUnidadFacturas extends Migration
{
public function up()
{
$this->forge->dropColumn('facturas_lineas', 'precio_unidad');
}
public function down()
{
$fields = [
'precio_unidad' => [
'type' => 'DOUBLE',
'null' => false,
],
];
$this->forge->addColumn('facturas_lineas', $fields);
}
}

View File

@ -0,0 +1,74 @@
<?php
namespace App\Database\Migrations;
use CodeIgniter\Database\Migration;
use CodeIgniter\I18n\Time;
class DropIsDeletedField extends Migration
{
public function up()
{
$m = $this->db->table('clientes');
$m->where('is_deleted',1)->update(['deleted_at' => Time::now()]);
$m->where('is_deleted',0)->update(['deleted_at' => null]);
$this->forge->dropColumn('clientes',"is_deleted");
$m = $this->db->table('cliente_contactos');
$m->where('is_deleted',1)->update(['deleted_at' => Time::now()]);
$m->where('is_deleted',0)->update(['deleted_at' => null]);
$this->forge->dropColumn('cliente_contactos',"is_deleted");
$m = $this->db->table('cliente_precios');
$m->where('is_deleted',1)->update(['deleted_at' => Time::now()]);
$m->where('is_deleted',0)->update(['deleted_at' => null]);
$this->forge->dropColumn('cliente_precios',"is_deleted");
$m = $this->db->table('cliente_plantilla_precios_lineas');
$m->where('is_deleted',1)->update(['deleted_at' => Time::now()]);
$m->where('is_deleted',0)->update(['deleted_at' => null]);
$this->forge->dropColumn('cliente_plantilla_precios_lineas',"is_deleted");
$m = $this->db->table('cliente_plantilla_precios');
$m->where('is_deleted',1)->update(['deleted_at' => Time::now()]);
$m->where('is_deleted',0)->update(['deleted_at' => null]);
$this->forge->dropColumn('cliente_plantilla_precios',"is_deleted");
}
public function down()
{
$column = [
'is_deleted' => [
'type' => 'BOOLEAN',
'default' => false,
],
];
$this->forge->addColumn('clientes',$column);
$m = $this->db->table('clientes');
$m->where('deleted_at IS NOT NULL',null,false)->update(['is_deleted' => true]);
$m->where('deleted_at',null)->update(['is_deleted' => false]);
$this->forge->addColumn('cliente_contactos',$column);
$m = $this->db->table('cliente_contactos');
$m->where('deleted_at IS NOT NULL',null,false)->update(['is_deleted' => true]);
$m->where('deleted_at',null)->update(['is_deleted' => false]);
$this->forge->addColumn('cliente_precios',$column);
$m = $this->db->table('cliente_precios');
$m->where('deleted_at IS NOT NULL',null,false)->update(['is_deleted' => true]);
$m->where('deleted_at',null)->update(['is_deleted' => false]);
$this->forge->addColumn('cliente_plantilla_precios_lineas',$column);
$m = $this->db->table('cliente_plantilla_precios_lineas');
$m->where('deleted_at IS NOT NULL',null,false)->update(['is_deleted' => true]);
$m->where('deleted_at',null)->update(['is_deleted' => false]);
$this->forge->addColumn('cliente_plantilla_precios',$column);
$m = $this->db->table('cliente_plantilla_precios');
$m->where('deleted_at IS NOT NULL',null,false)->update(['is_deleted' => true]);
$m->where('deleted_at',null)->update(['is_deleted' => false]);
}
}

View File

@ -0,0 +1,61 @@
<?php
namespace App\Database\Migrations;
use CodeIgniter\Database\Migration;
use CodeIgniter\Database\RawSql;
class AddUserIDFechasEntregaPedido extends Migration
{
protected array $USER_COLUMNS = [
"inaplazable" => [
"type" => "INT",
"unsigned" => true,
"constraint" => 1,
"null" => true,
],
'fecha_entrega_real_change_user_id' => [
'type' => 'INT',
"constraint" => 10,
"unsigned" => true,
"null" => true,
],
"fecha_impresion_change_user_id" => [
"type" => "INT",
"constraint" => 10,
"unsigned" => true,
"null" => true,
],
"fecha_encuadernado_change_user_id" => [
"type" => "INT",
"unsigned" => true,
"constraint" => 10,
"null" => true,
],
"fecha_entrega_externo_change_user_id" => [
"type" => "INT",
"unsigned" => true,
"constraint" => 10,
"null" => true,
],
"inaplazable_change_user_id" => [
"type" => "INT",
"unsigned" => true,
"constraint" => 10,
"null" => true,
],
];
public function up()
{
$this->forge->addColumn("pedidos", $this->USER_COLUMNS);
}
public function down()
{
$this->forge->dropColumn("pedidos", array_keys($this->USER_COLUMNS));
}
}

View File

@ -0,0 +1,33 @@
<?php
namespace App\Database\Migrations;
use CodeIgniter\Database\Migration;
use CodeIgniter\Database\RawSql;
class AddCantidadConceptoPedidoLinea extends Migration
{
protected array $USER_COLUMNS = [
"cantidad" => [
"type" => "INT",
"unsigned" => true,
"constraint" => 10,
"null" => true,
],
'descripcion' => [
'type' => 'TEXT',
"null" => true,
],
];
public function up()
{
$this->forge->addColumn("pedidos_linea", $this->USER_COLUMNS);
}
public function down()
{
$this->forge->dropColumn("pedidos_linea", array_keys($this->USER_COLUMNS));
}
}

View File

@ -12,7 +12,6 @@ class FacturaLineaEntity extends \CodeIgniter\Entity\Entity
'pedido_maquetacion_id' => null,
'descripcion' => null,
'cantidad' => null,
'precio_unidad' => null,
'iva' => null,
'base' => null,
'total_iva' => null,
@ -29,7 +28,6 @@ class FacturaLineaEntity extends \CodeIgniter\Entity\Entity
'pedido_linea_impresion_id' => 'int',
'pedido_maquetacion_id' => 'int',
'cantidad' => 'float',
'precio_unidad' => 'float',
'iva' => 'float',
'base' => 'float',
'total_iva' => 'float',

View File

@ -18,6 +18,7 @@ class PedidoEntity extends \CodeIgniter\Entity\Entity
"total_precio" => null,
"total_tirada" => null,
"estado" => null,
"inaplazable" => null,
"user_created_id" => null,
"user_updated_id" => null,
"user_validated_id" => null,
@ -25,6 +26,11 @@ class PedidoEntity extends \CodeIgniter\Entity\Entity
"fecha_impresion" => null,
"fecha_encuadernado" => null,
"fecha_entrega_externo" => null,
"fecha_entrega_real_change_user_id" => null,
"fecha_impresion_change_user_id" => null,
"fecha_encuadernado_change_user_id" => null,
"fecha_entrega_change_externo_user_id" => null,
"inaplazable_change_user_id" => null,
"created_at" => null,
"updated_at" => null,
"validated_at" => null,

View File

@ -16,6 +16,8 @@ class PedidoLineaEntity extends \CodeIgniter\Entity\Entity
"user_updated_id" => null,
"created_at" => null,
"updated_at" => null,
"cantidad" => null,
"descripcion" => null,
];
@ -23,6 +25,7 @@ class PedidoLineaEntity extends \CodeIgniter\Entity\Entity
"pedido_id" => "int",
"presupuesto_id" => "int",
"ubicacion_id" => "int",
"cantidad" => "int",
];
public function ubicacion() : UbicacionesEntity
{

View File

@ -2,17 +2,15 @@
namespace App\Entities\Produccion;
use App\Controllers\Produccion\Ordentrabajo;
use App\Database\Migrations\OrdenTrabajoDatesTable;
use App\Entities\Pedidos\PedidoEntity;
use App\Entities\Usuarios\UserEntity;
use App\Entities\Usuarios\UsersEntity;
use App\Models\OrdenTrabajo\OrdenTrabajoDate;
use App\Models\OrdenTrabajo\OrdenTrabajoFileModel;
use App\Models\OrdenTrabajo\OrdenTrabajoTarea;
use App\Models\OrdenTrabajo\OrdenTrabajoUser;
use App\Models\Pedidos\PedidoModel;
use App\Models\UserModel;
use App\Models\Usuarios\UserModel;
use CodeIgniter\Entity\Entity;
use Picqer\Barcode\Renderers\PngRenderer;
use Picqer\Barcode\Types\TypeCode128;
@ -123,7 +121,7 @@ class OrdenTrabajoEntity extends Entity
$m = model(OrdenTrabajoFileModel::class);
return $m->where('orden_trabajo_id',$this->attributes['id'])->findAll() ?? [];
}
public function pedidoEsperaBy() : ?UsersEntity
public function pedidoEsperaBy() : ?UserEntity
{
$m = model(UserModel::class);
if($this->attributes['pedido_espera_by']){
@ -132,7 +130,7 @@ class OrdenTrabajoEntity extends Entity
return null;
}
}
public function getPedidoEsperaBy(): ?UsersEntity
public function getPedidoEsperaBy(): ?UserEntity
{
return $this->pedidoEsperaBy();
}

View File

@ -29,8 +29,12 @@ if (!function_exists('generate_php_roles_constant')) {
// Close the array
$phpCode .= "];\n";
// Write PHP code to a file
$filePath = APPPATH . "Config/RBAC/roles.php";
$dirPath = APPPATH . "Config/RBAC";
if (!is_dir($dirPath)) {
mkdir($dirPath, 0775, true); // true permite crear carpetas anidadas
}
$filePath = $dirPath . "/roles.php";
file_put_contents($filePath, $phpCode);
}
@ -58,9 +62,14 @@ if (!function_exists('generate_php_permissions_constant')) {
// Close the array
$phpCode .= "];\n";
// Write PHP code to a file
$filePath = APPPATH . "Config/RBAC/permissions.php";
$dirPath = APPPATH . "Config/RBAC";
if (!is_dir($dirPath)) {
mkdir($dirPath, 0775, true); // true permite crear carpetas anidadas
}
$filePath = $dirPath . "/permissions.php";
file_put_contents($filePath, $phpCode);
}
}
@ -87,8 +96,12 @@ if (!function_exists('generate_php_permissions_matrix_constant')) {
// Close the array
$phpCode .= "];\n";
// Write PHP code to a file
$filePath = APPPATH . "Config/RBAC/permissionMatrix.php";
$dirPath = APPPATH . "Config/RBAC";
if (!is_dir($dirPath)) {
mkdir($dirPath, 0775, true); // true permite crear carpetas anidadas
}
$filePath = $dirPath . "/permissionMatrix.php";
file_put_contents($filePath, $phpCode);
}
}
@ -130,9 +143,9 @@ if (!function_exists('checkGroups')) {
*/
function checkGroups(array $groups, string $redirectRoute = null)
{
$session = \Config\Services::session();
$session = \Config\Services::session();
$response = \Config\Services::response();
$auth = auth(); // Shield auth service
$auth = auth(); // Shield auth service
$user = $auth->user();

View File

@ -25,12 +25,12 @@ class ClienteContactoModel extends \App\Models\BaseModel
protected $returnType = "App\Entities\Clientes\ClienteContactoEntity";
protected $useTimestamps = true;
protected $useSoftDeletes = false;
protected $useSoftDeletes = true;
protected $deletedField = 'deleted_at';
protected $createdField = "created_at";
protected $updatedField = "updated_at";
protected $deletedField = 'deleted_at';
public static $labelField = "nombre";
@ -113,7 +113,7 @@ class ClienteContactoModel extends \App\Models\BaseModel
);
$builder->where('t1.cliente_id', $cliente_id);
$builder->where("t1.is_deleted", 0);
$builder->where("t1.deleted_at", null);
$builder->join("clientes t2", "t1.cliente_id = t2.id", "left");
return empty($search)

View File

@ -2,6 +2,8 @@
namespace App\Models\Clientes;
use App\Entities\Clientes\ClienteEntity;
class ClienteModel extends \App\Models\BaseModel
{
protected $table = "clientes";
@ -57,13 +59,11 @@ class ClienteModel extends \App\Models\BaseModel
"comentarios_tirada_flexible",
"margen_plantilla_id",
"comentarios",
"is_deleted",
"deleted_at",
"user_created_id",
"user_update_id",
];
protected $returnType = "App\Entities\Clientes\ClienteEntity";
protected $returnType = ClienteEntity::class;
protected $useSoftDeletes = true;
protected $deletedField = 'deleted_at';
public static $labelField = "nombre";
@ -197,10 +197,7 @@ class ClienteModel extends \App\Models\BaseModel
"fecha_vencimiento" => [
"max_length" => "Clientes.validation.fecha_vencimiento.max_length",
],
"is_deleted" => [
"integer" => "Clientes.validation.is_deleted.integer",
"required" => "Clientes.validation.is_deleted.required",
],
"limite_credito" => [
"decimal" => "Clientes.validation.limite_credito.decimal",
"required" => "Clientes.validation.limite_credito.required",
@ -287,7 +284,7 @@ class ClienteModel extends \App\Models\BaseModel
->select(
"t1.id AS id, t1.nombre AS nombre, t1.alias AS alias, t1.cif AS cif, t1.email AS email, t1.vencimiento AS vencimiento, t5.first_name AS comercial, t7.nombre AS forma_pago_id"
)
->where("is_deleted", 0);;
->where("t1.deleted_at", null);;
$builder->join("users t5", "t1.comercial_id = t5.id", "left");
$builder->join("formas_pago t7", "t1.forma_pago_id = t7.id", "left");
@ -315,7 +312,7 @@ class ClienteModel extends \App\Models\BaseModel
->select(
"t1.limite_credito AS limite_credito"
)
->where("t1.is_deleted", 0)
->where("t1.deleted_at", null)
->where("t1.id", $cliente_id);
$limite = $builder->get()->getResultObject();
@ -340,7 +337,7 @@ class ClienteModel extends \App\Models\BaseModel
t2.nombre AS cliente_pais, t1.cp AS cliente_cp, t1.ciudad AS cliente_ciudad,
t3.nombre AS cliente_provincia, t1.credito_asegurado AS creditoAsegurado"
)
->where("t1.is_deleted", 0)
->where("t1.deleted_at", null)
->where("t1.id", $cliente_id);
$builder->join("lg_paises t2", "t1.pais_id = t2.id", "left");
$builder->join("lg_provincias t3", "t1.provincia_id = t3.id", "left");
@ -394,7 +391,7 @@ class ClienteModel extends \App\Models\BaseModel
"t1.nombre AS nombre"
)
->where("id", $id)
->where("is_deleted", 0);
->where("t1.deleted_at", null);
return $builder->get()->getResultObject()[0]->nombre;
} catch (\Exception $e) {
@ -409,7 +406,7 @@ class ClienteModel extends \App\Models\BaseModel
->select(
"t1.id AS id, t1.nombre AS name"
)
->where("is_deleted", 0);
->where("t1.deleted_at", null);
return empty($search)
? $builder->get()->getResultObject()
: $builder
@ -586,7 +583,7 @@ class ClienteModel extends \App\Models\BaseModel
$result['limite_credito'] = $this->db->table('clientes')
->select('limite_credito')
->where('id', $cliente_id)
->where('is_deleted', 0)
->where("deleted_at", null)
->get()
->getResultObject()[0]->limite_credito;
$result['limite_credito'] = round(floatval($result['limite_credito']), 2);

View File

@ -36,7 +36,6 @@ class ClientePlantillaPreciosLineasModel extends \App\Models\BaseModel
"tiempo_max",
"precio_hora",
"margen",
"is_deleted",
"deleted_at",
"created_at",
"updated_at",
@ -45,11 +44,12 @@ class ClientePlantillaPreciosLineasModel extends \App\Models\BaseModel
protected $returnType = "App\Entities\Clientes\ClientePlantillaPreciosLineasEntity";
protected $useTimestamps = true;
protected $useSoftDeletes = false;
protected $useSoftDeletes = true;
protected $createdField = "created_at";
protected $updatedField = "updated_at";
protected $deletedField = 'deleted_at';
public static $labelField = "plantilla_id";
@ -121,7 +121,6 @@ class ClientePlantillaPreciosLineasModel extends \App\Models\BaseModel
$this->db
->table($this->table . " t1")
->where('t1.plantilla_id', $plantilla_id)
->set('is_deleted', 1)
->set('deleted_at', $date_value)
->update();
@ -152,7 +151,7 @@ class ClientePlantillaPreciosLineasModel extends \App\Models\BaseModel
$builder->join("users t2", "t1.user_updated_id = t2.id", "left");
$builder->where('t1.is_deleted', 0);
$builder->where('t1.deleted_at', 0);
$builder->where('t1.plantilla_id', $plantilla_id);
if (empty($search))
@ -181,7 +180,7 @@ class ClientePlantillaPreciosLineasModel extends \App\Models\BaseModel
$rows = $this->db
->table($this->table)
->select("id, tiempo_min, tiempo_max")
->where("is_deleted", 0)
->where("deleted_at", null)
->where("tipo", $data["tipo"])
->where("tipo_maquina", $data["tipo_maquina"])
->where("tipo_impresion", $data["tipo_impresion"])

View File

@ -19,11 +19,12 @@ class ClientePlantillaPreciosModel extends \App\Models\BaseModel
protected $useAutoIncrement = true;
protected $allowedFields = ["nombre", "is_deleted", "deleted_at", "created_at", "updated_at"];
protected $allowedFields = ["nombre", "deleted_at", "created_at", "updated_at"];
protected $returnType = "App\Entities\Clientes\ClientePlantillaPreciosEntity";
protected $useTimestamps = true;
protected $useSoftDeletes = false;
protected $useSoftDeletes = true;
protected $deletedField = 'deleted_at';
protected $createdField = "created_at";
@ -61,7 +62,7 @@ class ClientePlantillaPreciosModel extends \App\Models\BaseModel
"t1.id as id, t1.nombre AS nombre"
);
$builder->where('t1.is_deleted', 0);
$builder->where('t1.deleted_at', null);
if (empty($search))
return $builder;

View File

@ -34,7 +34,6 @@ class ClientePreciosModel extends \App\Models\BaseModel
"tiempo_max",
"precio_hora",
"margen",
"is_deleted",
"deleted_at",
"created_at",
"updated_at",
@ -45,7 +44,8 @@ class ClientePreciosModel extends \App\Models\BaseModel
protected $returnType = "App\Entities\Clientes\ClientePreciosEntity";
protected $useTimestamps = true;
protected $useSoftDeletes = false;
protected $useSoftDeletes = true;
protected $deletedField = 'deleted_at';
protected $createdField = "created_at";
@ -140,7 +140,6 @@ class ClientePreciosModel extends \App\Models\BaseModel
$this->db
->table($this->table . " t1")
->where('cliente_id', $cliente_id)
->set('is_deleted', 1)
->set('deleted_at', $date_value)
->set('user_updated_id', $session->id_user)
->update();
@ -153,7 +152,7 @@ class ClientePreciosModel extends \App\Models\BaseModel
// Se borran los valores existentes para todos los clientes en una sola consulta
$modelCliente = model('App\Models\Clientes\ClienteModel');
$clientes = $modelCliente->select('id')->where('is_deleted', 0)->findAll();
$clientes = $modelCliente->select('id')->where('deleted_at', null)->findAll();
// Se borra la tabla
$this->db->table($this->table)->truncate();
@ -288,7 +287,7 @@ class ClientePreciosModel extends \App\Models\BaseModel
->table($this->table . " t1")
->select("t1.cliente_id AS id")
->where('t1.plantilla_id', $plantilla_id)
->where('t1.is_deleted', 0)
->where('t1.deleted_at', null)
->distinct()
->get()->getResultArray();
// Extraer solo los IDs de los clientes
@ -359,7 +358,7 @@ class ClientePreciosModel extends \App\Models\BaseModel
->where('tipo_impresion', $config->tipo_impresion)
->where('tiempo_min <=', $tiempo)
->where('tiempo_max >=', $tiempo)
->where('is_deleted', 0)
->where('deleted_at', null)
->get()->getResultObject();
if (count($values) > 0) {
@ -389,7 +388,7 @@ class ClientePreciosModel extends \App\Models\BaseModel
$builder->join("users t2", "t1.user_updated_id = t2.id", "left");
$builder->where('t1.is_deleted', 0);
$builder->where('t1.deleted_at', 0);
$builder->where('t1.cliente_id', $cliente_id);
if (empty($search))
@ -415,7 +414,7 @@ class ClientePreciosModel extends \App\Models\BaseModel
"t1.plantilla_id AS id, t2.nombre AS nombre"
);
$builder->where('t1.is_deleted', 0);
$builder->where('t1.deleted_at', null);
$builder->where('t1.cliente_id', $cliente_id);
$builder->join("cliente_plantilla_precios t2", "t1.plantilla_id = t2.id", "left");
$builder->limit(1);
@ -442,7 +441,7 @@ class ClientePreciosModel extends \App\Models\BaseModel
$rows = $this->db
->table($this->table)
->select("id, tiempo_min, tiempo_max")
->where("is_deleted", 0)
->where("deleted_at", null)
->where("tipo", $data["tipo"])
->where("tipo_maquina", $data["tipo_maquina"])
->where("tipo_impresion", $data["tipo_impresion"])
@ -476,7 +475,7 @@ class ClientePreciosModel extends \App\Models\BaseModel
$value = $this->db
->table($this->table)
->select("plantilla_id")
->where("is_deleted", 0)
->where("deleted_at", null)
->where("cliente_id", $cliente_id)
->limit(1)->get()->getResultObject();

View File

@ -26,7 +26,8 @@ class ClienteUsuariosModel extends ShieldUserModel
protected $returnType = "App\Entities\Usuarios\UserEntity";
protected $useTimestamps = true;
protected $useSoftDeletes = false;
protected $useSoftDeletes = true;
protected $deletedField = 'deleted_at';
protected $createdField = "created_at";

View File

@ -14,7 +14,6 @@ class FacturaLineaModel extends \App\Models\BaseModel {
'pedido_maquetacion_id',
'descripcion',
'cantidad',
'precio_unidad',
'iva',
'base',
'total_iva',
@ -38,9 +37,9 @@ class FacturaLineaModel extends \App\Models\BaseModel {
->select(
"t1.id AS id, t1.factura_id AS factura_id,
t1.pedido_linea_impresion_id AS pedido_linea_impresion_id, t1.pedido_maquetacion_id AS pedido_maquetacion_id,
t1.descripcion AS descripcion, t1.cantidad as cantidad, t1.precio_unidad AS precio_unidad, t1.iva AS iva,
t1.descripcion AS descripcion, t1.cantidad as cantidad, t1.iva AS iva,
t1.base AS base, t1.total_iva AS total_iva, t1.total AS total, t1.data AS data, t2.pedido_id AS pedido_id,
t3.total_aceptado AS total_aceptado, t4.tirada_flexible AS tirada_flexible, t4.descuento_tirada_flexible AS descuento_tirada_flexible,
t3.total_aceptado_revisado AS total_aceptado, t4.tirada_flexible AS tirada_flexible, t4.descuento_tirada_flexible AS descuento_tirada_flexible,
t6.cantidad AS cantidad_albaran"
)
->join("pedidos_linea t2", "t2.id = t1.pedido_linea_impresion_id", "left")
@ -89,7 +88,7 @@ class FacturaLineaModel extends \App\Models\BaseModel {
->select(
"t1.id AS id, t1.factura_id AS factura_id,
t1.pedido_linea_impresion_id AS pedido_linea_impresion_id, t1.pedido_maquetacion_id AS pedido_maquetacion_id,
t1.descripcion AS descripcion, t1.cantidad as cantidad, t1.precio_unidad AS precio_unidad, t1.iva AS iva,
t1.descripcion AS descripcion, t1.cantidad as cantidad, t1.iva AS iva,
t1.base AS base, t1.total_iva AS total_iva, t1.total AS total, t1.data AS data"
)
->where("t1.factura_id", $factura_id)

View File

@ -145,6 +145,27 @@ class FacturaModel extends \App\Models\BaseModel
return $builder;
}
public function presupuestoHasFacturaValidada($presupuesto_id = null)
{
if ($presupuesto_id == null) {
return false;
}
$result = $this->db->table($this->table . " t1")
->select("t1.id")
->join("facturas_lineas t2", "t2.factura_id = t1.id", "left")
->join("pedidos_linea t3", "t2.pedido_linea_impresion_id = t3.id", "left")
->where("t3.presupuesto_id", $presupuesto_id)
->where("t1.deleted_at IS NULL")
->where("t2.deleted_at IS NULL")
->where("t1.estado", "validada")
->get()
->getResultObject();
return !empty($result);
}
public function getSumatoriosFacturacionCliente($cliente_id = -1){
if($cliente_id == -1){

View File

@ -36,6 +36,8 @@ class PedidoLineaModel extends \App\Models\BaseModel
"user_updated_id",
"created_at",
"updated_at",
"cantidad",
"descripcion",
];
protected $returnType = "App\Entities\Pedidos\PedidoLineaEntity";

View File

@ -37,6 +37,7 @@ class PedidoModel extends \App\Models\BaseModel
"total_precio",
"total_tirada",
"estado",
"inaplazable",
"user_created_id",
"user_updated_id",
"user_validated_id",
@ -44,6 +45,11 @@ class PedidoModel extends \App\Models\BaseModel
"fecha_impresion",
"fecha_encuadernado",
"fecha_entrega_externo",
"fecha_entrega_real_change_user_id",
"fecha_impresion_change_user_id",
"fecha_encuadernado_change_user_id",
"fecha_entrega_externo_change_user_id",
"inaplazable_change_user_id",
"created_at",
"updated_at",
"validated_at",
@ -111,15 +117,28 @@ class PedidoModel extends \App\Models\BaseModel
$builder = $this->db
->table($this->table . " t1")
->select(
"t2.presupuesto_id"
"t2.presupuesto_id, t3.total_aceptado, t2.descripcion, t2.cantidad"
);
$builder->where("t1.id", $pedido_id);
$builder->join("pedidos_linea t2", "t2.pedido_id = t1.id", "left");
$builder->join("presupuestos t3", "t2.presupuesto_id = t3.id", "left");
$model_presupuesto = model("App\Models\Presupuestos\PresupuestoModel");
$lineasPresupuesto = [];
foreach ($builder->get()->getResultObject() as $row) {
array_push($lineasPresupuesto, $model_presupuesto->generarLineaPedido($row->presupuesto_id)[0]);
if($row->descripcion == null){
array_push($lineasPresupuesto, $model_presupuesto->generarLineaPedido($row->presupuesto_id)[0]);
}
else{
$presupuesto = (object) [
'numero' => $row->presupuesto_id,
'unidades' => $row->cantidad,
'total' => $row->total_aceptado,
'concepto' => $row->descripcion,
];
array_push($lineasPresupuesto, $presupuesto);
}
}
$builder->groupBy("t1.id");

View File

@ -1885,9 +1885,12 @@ class PresupuestoService extends BaseService
$pedido_id = $model_pedido->insert($data_pedido);
if ($pedido_id) {
$lineas_pedido = $model_presupuesto->generarLineaPedido($presupuesto_id)[0];
$data_pedido_linea = [
"pedido_id" => $pedido_id,
"presupuesto_id" => $presupuesto_id,
'cantidad' => $lineas_pedido->unidades,
'descripcion' => $lineas_pedido->concepto,
"ubicacion_id" => 1, // safetak por defecto
"user_created_id" => auth()->user()->id,
"user_updated_id" => auth()->user()->id,

View File

@ -2,7 +2,6 @@
namespace App\Services;
use App\Database\Migrations\ConfigVariablesApp;
use App\Entities\Clientes\ClienteEntity;
use App\Entities\Pedidos\PedidoEntity;
use App\Entities\Presupuestos\PresupuestoEntity;
@ -12,7 +11,6 @@ use App\Models\OrdenTrabajo\OrdenTrabajoDate;
use App\Models\OrdenTrabajo\OrdenTrabajoModel;
use App\Models\OrdenTrabajo\OrdenTrabajoTarea;
use App\Models\OrdenTrabajo\OrdenTrabajoUser;
use App\Models\Usuarios\UserModel;
use CodeIgniter\Config\BaseService;
use App\Entities\Configuracion\Maquina as MaquinaEntity;
use App\Entities\Produccion\OrdenTrabajoFileEntity;
@ -20,10 +18,10 @@ use App\Entities\Produccion\OrdenTrabajoTareaEntity;
use App\Models\Configuracion\ConfigVariableModel;
use App\Models\Configuracion\MaquinaModel;
use App\Models\OrdenTrabajo\OrdenTrabajoFileModel;
use App\Models\Usuarios\UserModel;
use CodeIgniter\Database\BaseBuilder;
use CodeIgniter\Database\BaseResult;
use CodeIgniter\Database\Exceptions\DatabaseException;
use CodeIgniter\Files\File;
use CodeIgniter\HTTP\Files\UploadedFile;
use CodeIgniter\I18n\Time;
use Exception;

View File

@ -591,29 +591,31 @@
<button id="convert2template" type="button" class="btn btn-secondary waves-effect waves-light float-start"><?= lang("ClientePrecios.convertir2plantilla")?></button>
</div>
</div>
<div class="table-responsive">
<table id="tableOfPrecios" class="table table-striped table-hover" style="width: 100%;">
<thead>
<tr>
<th>ID</th>
<th><?= lang('ClientePrecios.tipo') ?></th>
<th><?= lang('ClientePrecios.tipo_maquina') ?></th>
<th><?= lang('ClientePrecios.tipo_impresion') ?></th>
<th><?= lang('ClientePrecios.tiempo_min') ?></th>
<th><?= lang('ClientePrecios.tiempo_max') ?></th>
<th class="noFilter"><?= lang('ClientePrecios.precio_hora') ?></th>
<th class="noFilter"><?= lang('ClientePrecios.margen') ?></th>
<th class="noFilter"><?= lang('ClientePrecios.total_precio_hora') ?></th>
<th class="noFilter"><?= lang('ClientePrecios.user_updated_id') ?></th>
<th class="noFilter"><?= lang('ClientePrecios.updated_at') ?></th>
<th class="noFilter noVis">plantilla_id</th>
<th class="text-nowrap noFilter noVis" style="min-width:100px"><?= lang('Basic.global.Action') ?></th>
</tr>
</thead>
<tbody>
</tbody>
</table>
<table id="tableOfPrecios" class="table table-striped table-hover" style="width: 100%;">
<thead>
<tr>
<th>ID</th>
<th><?= lang('ClientePrecios.tipo') ?></th>
<th><?= lang('ClientePrecios.tipo_maquina') ?></th>
<th><?= lang('ClientePrecios.tipo_impresion') ?></th>
<th><?= lang('ClientePrecios.tiempo_min') ?></th>
<th><?= lang('ClientePrecios.tiempo_max') ?></th>
<th class="noFilter"><?= lang('ClientePrecios.precio_hora') ?></th>
<th class="noFilter"><?= lang('ClientePrecios.margen') ?></th>
<th class="noFilter"><?= lang('ClientePrecios.total_precio_hora') ?></th>
<th class="noFilter"><?= lang('ClientePrecios.user_updated_id') ?></th>
<th class="noFilter"><?= lang('ClientePrecios.updated_at') ?></th>
<th class="noFilter noVis">plantilla_id</th>
<th class="text-nowrap noFilter noVis" style="min-width:100px"><?= lang('Basic.global.Action') ?></th>
</tr>
</thead>
<tbody>
</tbody>
</table>
</div>
</div>
@ -637,10 +639,11 @@
<div class="tab-pane fade" id="domicilio-entrega" role="tabpanel">
<?= view("themes/vuexy/form/clientes/cliente/_clienteDireccionesForm") ?>
<table id="tableOfDireccionesEnvio" class="table dt-responsive dataTable" style="width: 100%;">
<thead>
<tr>
<th><?= lang('ClienteDirecciones.alias') ?></th>
<div class="table-responsive">
<table id="tableOfDireccionesEnvio" class="table dt-responsive dataTable" style="width: 100%;">
<thead>
<tr>
<th><?= lang('ClienteDirecciones.alias') ?></th>
<th><?= lang('ClienteDirecciones.att') ?></th>
<th><?= lang('ClienteDirecciones.email') ?></th>
<th><?= lang('ClienteDirecciones.direccion') ?></th>
@ -653,9 +656,10 @@
</tr>
</thead>
<tbody>
</tbody>
</table>
</tbody>
</table>
</div>
</div>
<div class="tab-pane fade" id="presupuestos" role="tabpanel">
@ -787,10 +791,7 @@ $(document).on('click', '.btn-remove', function(e) {
},{
"name": "deleted_at",
"type": "hidden"
},{
"name": "is_deleted",
"type": "hidden"
},
}
]
} );

View File

@ -13,7 +13,7 @@
</div><!--//.card-header -->
<form id="clienteForm" data-cliente="<?=$clienteEntity->id?>"
data-url="<?= auth()->user()->inGroup('cliente-admin') || auth()->user()->inGroup('cliente-editor') ?
'/presupuestos/presupuestocliente/edit/' : '/presupuestoadmin/edit//' ?>"
'/presupuestos/presupuestocliente/edit/' : '/presupuestoadmin/edit/' ?>"
method="post" class="card-body" action="<?= $formAction ?>">
<?= csrf_field() ?>
<div class="card-body">

View File

@ -121,6 +121,7 @@ $('#addNewPedidoImpresion').on('click', function(){
$('#pedidoImpresion').val(null).trigger('change');
// Se actualiza la tabla de lineas de factura
$('#tableOfLineasFactura').DataTable().clearPipeline().draw();
$('#tableOfLineasPagos').DataTable().clearPipeline().draw();
}
});
});

View File

@ -20,7 +20,6 @@
<th ></th>
<th style="width: 10%;"><?= lang('Facturas.unidades') ?></th>
<th ><?= lang('Facturas.concepto') ?></th>
<th style="width: 10%;"><?= lang('Facturas.precioUnidad') ?></th>
<th style="width: 10%;"><?= lang('Facturas.iva') ?></th>
<th style="width: 10%;"><?= lang('Facturas.subtotal') ?></th>
<th></th>
@ -31,26 +30,26 @@
</tbody>
<tfoot>
<tr>
<td colspan="9" style="text-align:right">Subtotal:</td>
<td id="subtotal-sum"></td>
<td colspan="8" style="text-align:right">Subtotal:</td>
<td class="autonumeric text-end" id="subtotal-sum"></td>
<td></td>
<td></td>
</tr>
<tr>
<td colspan="9" style="text-align:right">I.V.A.:</td>
<td id="total-iva-sum"></td>
<td colspan="8" style="text-align:right">I.V.A.:</td>
<td class="autonumeric text-end" id="total-iva-sum"></td>
<td></td>
<td></td>
</tr>
<tr>
<td colspan="9" style="text-align:right">Total:</td>
<td id="total-sum"></td>
<td colspan="8" style="text-align:right">Total:</td>
<td class="autonumeric text-end" id="total-sum"></td>
<td></td>
<td></td>
</tr>
<tr>
<td <?= ($facturaEntity->serie_id == 7 || $facturaEntity->serie_id == 9)? "style='display:none;'":"" ?> colspan="9" style="text-align:right">Pendiente de pago:</td>
<td <?= ($facturaEntity->serie_id == 7 || $facturaEntity->serie_id == 9)? "style='display:none;'":"" ?> id="pendiente-pago"></td>
<td <?= ($facturaEntity->serie_id == 7 || $facturaEntity->serie_id == 9)? "style='display:none;'":"" ?> colspan="8" style="text-align:right">Pendiente de pago:</td>
<td class="autonumeric text-end" <?= ($facturaEntity->serie_id == 7 || $facturaEntity->serie_id == 9)? "style='display:none;'":"" ?> id="pendiente-pago"></td>
<td></td>
<td></td>
</tr>
@ -79,55 +78,85 @@
<?=$this->section('additionalInlineJs') ?>
const actionBtns = function(data) {
// se comprueba si data es null
<?php if($facturaEntity->estado != 'borrador') :?>
if (data.pedido_id != null) {
return `
<div class="text-right py-0 align-middle">
<div class="row">
<button type="button" class="btn btn-sm btn-primary btn-view_pedido" data-id="${data.pedido_id}">Ver pedido</button>
</div>
</div>
`;
}
else
{
return ``;
}
<?php if ($facturaEntity->estado != 'borrador') : ?>
if (data.pedido_id != null) {
return `
<div class="text-right py-0 align-middle">
<div class="row">
<button type="button" class="btn btn-sm btn-primary btn-view_pedido" data-id="${data.pedido_id}">Ver pedido</button>
</div>
</div>
`;
} else {
return ``;
}
<?php else: ?>
if (data.pedido_id === null) {
return `
<td class="text-right py-0 align-middle">
<div class="row mb-2">
<div class="btn-group btn-group-sm">
<a href="javascript:void(0);"><i class="ti ti-trash ti-sm btn-delete mx-2" data-id="${data.id}"></i></a>
<span class="edit"><a href="javascript:void(0);"><i class="ti ti-pencil ti-sm btn-edit mx-2" data-id="${data.id}"></i></a></span>
<span class="cancel"></span>
if (data.pedido_id === null) {
return `
<div class="text-right py-0 align-middle">
<div class="row mb-2">
<div class="btn-group btn-group-sm">
<a href="javascript:void(0);"><i class="ti ti-trash ti-sm btn-delete mx-2" data-id="${data.id}"></i></a>
<span class="edit"><a href="javascript:void(0);"><i class="ti ti-pencil ti-sm btn-edit mx-2" data-id="${data.id}"></i></a></span>
<span class="cancel"></span>
</div>
</div>
</div>
</div>
</td>`;
}
else{
return `
<div class="text-right py-0 align-middle">
<div class="row mb-2 align-middle">
<div class="btn-group btn-group-sm">
<a href="javascript:void(0);"><i class="ti ti-trash ti-sm btn-delete mx-2" data-id="${data.id}"></i></a>
<span class="edit"><a href="javascript:void(0);"><i class="ti ti-pencil ti-sm btn-edit mx-2" data-id="${data.id}"></i></a></span>
<span class="cancel"></span>
`;
} else {
return `
<div class="text-right py-0 align-middle">
<div class="row mb-2 align-middle">
<div class="btn-group btn-group-sm">
<a href="javascript:void(0);"><i class="ti ti-trash ti-sm btn-delete mx-2" data-id="${data.id}"></i></a>
<span class="edit"><a href="javascript:void(0);"><i class="ti ti-pencil ti-sm btn-edit mx-2" data-id="${data.id}"></i></a></span>
<span class="cancel"></span>
</div>
</div>
<div class="row">
<button type="button" class="btn btn-sm btn-primary btn-view_pedido" data-id="${data.pedido_id}">Ver pedido</button>
</div>
</div>
</div>
<div class="row">
<button type="button" class="btn btn-sm btn-primary btn-view_pedido" data-id="${data.pedido_id}">Ver pedido</button>
</div>
</div>
`;
}
`;
}
<?php endif; ?>
};
const autoNumericSubtotal = new AutoNumeric('#subtotal-sum', 0, {
decimalPlaces: 2,
digitGroupSeparator: ',',
decimalCharacter: '.',
unformatOnSubmit: true,
decimalPlacesShownOnFocus: 2,
decimalPlacesShownOnBlur: 2,
});
const autoNumericIVA = new AutoNumeric('#total-iva-sum', 0, {
decimalPlaces: 2,
digitGroupSeparator: ',',
decimalCharacter: '.',
unformatOnSubmit: true,
decimalPlacesShownOnFocus: 2,
decimalPlacesShownOnBlur: 2,
});
const autoNumericTotal = new AutoNumeric('#total-sum', 0, {
decimalPlaces: 2,
digitGroupSeparator: ',',
decimalCharacter: '.',
unformatOnSubmit: true,
decimalPlacesShownOnFocus: 2,
decimalPlacesShownOnBlur: 2,
});
const autoNumericPendientePago = new AutoNumeric('#pendiente-pago', 0, {
decimalPlaces: 2,
digitGroupSeparator: ',',
decimalCharacter: '.',
unformatOnSubmit: true,
decimalPlacesShownOnFocus: 2,
decimalPlacesShownOnBlur: 2,
});
var editor_lineas = new $.fn.dataTable.Editor( {
ajax: {
@ -153,14 +182,6 @@ var editor_lineas = new $.fn.dataTable.Editor( {
rows: 5,
style: "height: 120px;"
}
}, {
name: "precio_unidad",
attr: {
type: "text",
name : "precio_unidad",
class :"autonumeric",
style: "min-width: 65px;"
}
}, {
name: "iva",
attr: {
@ -187,56 +208,52 @@ var editor_lineas = new $.fn.dataTable.Editor( {
var old_cantidad = 0;
editor_lineas.on('open', (event) => {
$("input.autonumeric").each(function () {
let autoNumericInstance = AutoNumeric.getAutoNumericElement(this)
if (autoNumericInstance) {
autoNumericInstance.remove()
$("input.autonumeric").each(function () {
let autoNumericInstance = AutoNumeric.getAutoNumericElement(this)
if (autoNumericInstance) {
autoNumericInstance.remove()
}
new AutoNumeric(this, {
decimalCharacter: ",",
digitGroupSeparator: ".",
allowDecimalPadding : 'floats',
decimalPlaces: 2,
unformatOnSubmit: true,
});
})
}
new AutoNumeric(this, {
decimalCharacter: ",",
digitGroupSeparator: ".",
allowDecimalPadding : 'floats',
decimalPlaces: 2,
unformatOnSubmit: true,
});
})
editor_lineas.on('preSubmit', (e, d, type) => {
if (d.data) {
Object.keys(d.data).forEach(function (key) {
// Find all elements with class .autonumeric
$("input.autonumeric").each(function () {
let autoNumericInstance = AutoNumeric.getAutoNumericElement(this)
if (autoNumericInstance) {
// Get raw value and update the corresponding field
let rawValue = autoNumericInstance.getNumericString();
d.data[key][this.name] = rawValue; // Ensure the correct name attribute is used
}
});
});
})
editor_lineas.on('preSubmit', (e, d, type) => {
if (d.data) {
if ( type === 'create'){
d.data[0]['factura_id'] = <?= $facturaEntity->id ?>;
d.data[0]['old_cantidad'] = null;
}
else if(type === 'edit' ) {
for (v in d.data){
d.data[v]['factura_id'] = <?= $facturaEntity->id ?>;
d.data[v]['old_cantidad'] = old_cantidad;
}
})
}
Object.keys(d.data).forEach(function (key) {
// Find all elements with class .autonumeric
$("input.autonumeric").each(function () {
let autoNumericInstance = AutoNumeric.getAutoNumericElement(this)
if (autoNumericInstance) {
// Get raw value and update the corresponding field
let rawValue = autoNumericInstance.getNumericString();
d.data[key][this.name] = rawValue; // Ensure the correct name attribute is used
}
});
});
}
})
editor_lineas.on( 'preEdit', function ( e, json, data, id ) {
old_cantidad = data.cantidad;
});
editor_lineas.on( 'preSubmit', function ( e, d, type ) {
if ( type === 'create'){
d.data[0]['factura_id'] = <?= $facturaEntity->id ?>;
d.data[0]['old_cantidad'] = null;
}
else if(type === 'edit' ) {
for (v in d.data){
d.data[v]['factura_id'] = <?= $facturaEntity->id ?>;
d.data[v]['old_cantidad'] = old_cantidad;
}
}
});
editor_lineas.on( 'postSubmit', function ( e, json, data, action ) {
@ -310,7 +327,7 @@ var tableLineas = $('#tableOfLineasFactura').DataTable({
<div class="row mt-2">
<div style="margin-top: auto;" class="col-md-12 col-lg-2 px-4">
<label for="total-aceptado_-${meta.row}">Total aceptado</label>
<input readonly style="max-width: 110px;" type="text" id="total-aceptado_${meta.row}" value="${row.total_aceptado}">
<input readonly class="autonumeric-datatable-lineas" style="max-width: 110px;" type="text" id="total-aceptado_${meta.row}" value="${row.total_aceptado}">
</div>
`;
@ -366,11 +383,10 @@ var tableLineas = $('#tableOfLineasFactura').DataTable({
}
}
},
{data: "precio_unidad",render : (d) => `<span class="autonumeric">${d}</span>`},
{data: "iva",render : (d) => `<span class="autonumeric">${d}</span>`},
{data: "base",render : (d) => `<span class="autonumeric">${d}</span>`},
{data: "total_iva",render : (d) => `<span class="autonumeric">${d}</span>`},
{data: "total",render : (d) => `<span class="autonumeric">${d}</span>`},
{data: "iva", className: "text-end", render : (d) => `<span class="autonumeric-facturas text-end">${d}</span>`},
{data: "base", className: "text-end", render : (d) => `<span class="autonumeric-facturas text-end">${d}</span>`},
{data: "total_iva", className: "text-end",render : (d) => `<span class="autonumeric-facturas text-end">${d}</span>`},
{data: "total", className: "text-end", render : (d) => `<span class="autonumeric-facturas text-end">${d}</span>`},
],
order: [[1, "asc"]],
dom: 't',
@ -391,94 +407,85 @@ var tableLineas = $('#tableOfLineasFactura').DataTable({
},
{
visible: false,
targets: [1, 2, 3, 4, 10, 11]
targets: [1, 2, 3, 4, 9, 10]
}
],
drawCallback: function() {
$(this.api().table().container()).find('table').css('width', '100%');
this.api().columns.adjust();
$('.autonumeric-datatable-lineas').each(function() {
if (!$(this).data('autoNumeric')) {
new AutoNumeric(this, {
decimalPlaces: 2,
digitGroupSeparator: '.',
decimalCharacter: ',',
unformatOnSubmit: true
});
}
});
$("span.autonumeric-facturas").each(function () {
let autoNumericInstance = AutoNumeric.getAutoNumericElement(this)
if(autoNumericInstance){
autoNumericInstance.remove()
}
new AutoNumeric(this, {
digitGroupSeparator: ".",
decimalCharacter: ",",
allowDecimalPadding : 'floats',
decimalPlaces: 2,
unformatOnSubmit: true,
decimalPlacesShownOnFocus: 2,
decimalPlacesShownOnBlur: 2,
allowDecimalPadding: true,
});
});
},
footerCallback: function (row, data, start, end, display) {
updateFooterLineas(this.api());
const table = this.api();
const totalSubtotal = table.column(8).data().reduce((a, b) => parseFloat(a) + parseFloat(b), 0);
const totalIVA = table.column(9).data().reduce((a, b) => parseFloat(a) + parseFloat(b), 0);
const totalTotal = table.column(10).data().reduce((a, b) => parseFloat(a) + parseFloat(b), 0);
autoNumericSubtotal.set(totalSubtotal);
autoNumericIVA.set(totalIVA);
autoNumericTotal.set(totalTotal);
var total_pagos = autoNumericTotalCobrado.getNumber();
var pendientePago = totalTotal - total_pagos;
if (isNaN(pendientePago)) pendientePago = 0;
autoNumericPendientePago.set(pendientePago);
$.ajax({
url: '<?= route_to('updateFacturaTotales', $facturaEntity->id) ?>',
method: 'POST',
data: {
base: totalSubtotal,
total: totalTotal,
total_pagos: total_pagos,
pendiente: pendientePago,
<?= csrf_token() ?? "token" ?> : <?= csrf_token() ?>v
}
}).done(function (data) {
if (data.estado_pago === 'pagada') {
$('#estado_pago_text').text('<?= lang('Facturas.pagada') ?>').css('color', 'green');
} else {
$('#estado_pago_text').text('<?= lang('Facturas.pendiente') ?>').css('color', 'red');
}
}).fail(function (jqXHR) {
popErrorAlert(jqXHR.responseJSON.messages.error);
});
}
});
function updateFooterLineas(table){
// Remove the formatting to get integer data for summation
var intVal = function (i) {
return typeof i === 'string' ?
i.replace(/[\$,]/g, '')*1 :
typeof i === 'number' ?
i : 0;
};
// Total over all pages
var totalSubtotal = table
.column(9)
.data()
.reduce(function (a, b) {
return intVal(a) + intVal(b);
}, 0);
var totalIVA = table
.column(10)
.data()
.reduce(function (a, b) {
return intVal(a) + intVal(b);
}, 0);
var totalTotal = table
.column(11)
.data()
.reduce(function (a, b) {
return intVal(a) + intVal(b);
}, 0);
// Update footer
$('#subtotal-sum').html(totalSubtotal.toFixed(2));
$('#total-iva-sum').html(totalIVA.toFixed(2));
$('#total-sum').html(totalTotal.toFixed(2));
// Assuming pendiente de pago is totalTotal - totalIVA for this example
<?php if($facturaEntity->estado == 'borrador') :?>
var pendientePago = totalTotal ;
var total_pagos = 0;
<?php else: ?>
var total_pagos = parseFloat($('#totalCobrado-sum').html()).toFixed(2);
var pendientePago = totalTotal - total_pagos;
<?php endif; ?>
if(isNaN(pendientePago)){
pendientePago = 0;
}
$('#pendiente-pago').html(pendientePago.toFixed(2));
$.ajax({
url: '<?= route_to('updateFacturaTotales', $facturaEntity->id) ?>',
method: 'POST',
data: {
base: totalSubtotal,
total: totalTotal,
total_pagos: total_pagos,
pendiente: pendientePago,
<?= csrf_token() ?? "token" ?> : <?= csrf_token() ?>v
}
}).done((data, textStatus, jqXHR) => {
if(data.estado_pago == 'pagada'){
$('#estado_pago_text').text('<?= lang('Facturas.pagada') ?>');
$('#estado_pago_text').css('color', 'green');
}
else{
$('#estado_pago_text').text('<?= lang('Facturas.pendiente') ?>');
$('#estado_pago_text').css('color', 'red');
}
}).fail((jqXHR, textStatus, errorThrown) => {
popErrorAlert(jqXHR.responseJSON.messages.error)
})
}
// Delete row
$(document).on('click', '.btn-delete', function(e) {
@ -510,6 +517,8 @@ function deleteConfirmedLinea(params){
<?= csrf_token() ?? "token" ?> : <?= csrf_token() ?>v
}
}).done((data, textStatus, jqXHR) => {
tablelineas.clearPipeline().footerCallback().draw();
$('#tableOfLineasPagos').DataTable().clearPipeline().footerCallback().draw();
}).fail((jqXHR, textStatus, errorThrown) => {
popErrorAlert(jqXHR.responseJSON.messages.error)
@ -577,7 +586,6 @@ $(document).on('click', '.btn-excedentes', function(e) {
pedido_id: pedido_id,
pedido_linea_impresion_id: pedido_linea_impresion_id,
pedido_linea_maquetacion_id: pedido_linea_maquetacion_id,
precio_unidad: row_data.precio_unidad,
descripcion: row_data.descripcion,
iva: row_data.iva,
descuento: row_data.descuento_tirada_flexible,

View File

@ -22,12 +22,12 @@
<tbody></tbody>
<tfoot>
<tr>
<td colspan="6" style="text-align:right">Total cobrado:</td>
<td><span id="totalCobrado-sum" class="autonumeric"></span></td>
<td colspan="6" class="text-end">Total cobrado:</td>
<td class="text-end"><span id="totalCobrado-sum" class="autonumeric text-end"></span></td>
</tr>
<tr>
<td colspan="6" style="text-align:right">Total pendiente:</td>
<td><span id="pendienteCobro-sum" class="autonumeric"></span></td>
<td colspan="6" class="text-end">Total pendiente:</td>
<td class="text-end"><span id="pendienteCobro-sum" class="autonumeric text-end"></span></td>
</tr>
</tfoot>
</table>
@ -73,7 +73,7 @@ const actionBtns_pagos = function(data) {
<?php endif; ?>
}
var editor_pagos = new $.fn.dataTable.Editor( {
const editor_pagos = new $.fn.dataTable.Editor( {
ajax: {
url: "<?= route_to('editorOfPagosFacturas') ?>",
headers: {
@ -99,8 +99,10 @@ var editor_pagos = new $.fn.dataTable.Editor( {
{
name: "total",
attr: {
style: "min-width: 65px;"
}
style: "min-width: 65px;",
class :"autonumeric",
name: 'total'
},
},
{
name: "fecha_pago_at",
@ -132,17 +134,48 @@ var editor_pagos = new $.fn.dataTable.Editor( {
]
});
editor_pagos.on('open',(event)=>{
$("input.autonumeric").each(function () {
let autoNumericInstance = AutoNumeric.getAutoNumericElement(this)
if(autoNumericInstance){
autoNumericInstance.remove()
}
new AutoNumeric(this, {
digitGroupSeparator: ".",
decimalCharacter: ",",
allowDecimalPadding : 'floats',
decimalPlaces: 2,
unformatOnSubmit: true,
decimalPlacesShownOnFocus: 2,
decimalPlacesShownOnBlur: 2,
});
})
})
editor_pagos.on( 'preSubmit', function ( e, d, type ) {
if ( type === 'create'){
d.data[0]['factura_id'] = <?= $facturaEntity->id ?>;
}
else if(type === 'edit' ) {
for (v in d.data){
d.data[v]['factura_id'] = <?= $facturaEntity->id ?>;
if (d.data) {
if ( type === 'create'){
d.data[0]['factura_id'] = <?= $facturaEntity->id ?>;
}
else if(type === 'edit' ) {
for (v in d.data){
d.data[v]['factura_id'] = <?= $facturaEntity->id ?>;
}
}
Object.keys(d.data).forEach(function (key) {
// Find all elements with class .autonumeric
$("input.autonumeric").each(function () {
let autoNumericInstance = AutoNumeric.getAutoNumericElement(this)
if (autoNumericInstance) {
// Get raw value and update the corresponding field
let rawValue = autoNumericInstance.getNumericString();
d.data[key][this.name] = rawValue; // Ensure the correct name attribute is used
}
});
});
}
});
@ -152,8 +185,26 @@ editor_pagos.on( 'postSubmit', function ( e, json, data, action ) {
yeniden(json.<?= csrf_token() ?>);
tablePagos.clearPipeline();
tablePagos.draw();
updateFooterLineas(tableLineas);
});
const autoNumericTotalCobrado = new AutoNumeric('#totalCobrado-sum', 0, {
decimalPlaces: 2,
digitGroupSeparator: ',',
decimalCharacter: '.',
unformatOnSubmit: true,
decimalPlacesShownOnFocus: 2,
decimalPlacesShownOnBlur: 2,
});
const autoNumericPendienteCobro = new AutoNumeric('#pendienteCobro-sum', 0, {
decimalPlaces: 2,
digitGroupSeparator: ',',
decimalCharacter: '.',
unformatOnSubmit: true,
decimalPlacesShownOnFocus: 2,
decimalPlacesShownOnBlur: 2,
});
var tablePagos = $('#tableOfLineasPagos').DataTable({
processing: true,
@ -193,7 +244,11 @@ var tablePagos = $('#tableOfLineasPagos').DataTable({
return data!='0000-00-00 00:00:00' ? moment(data).format('DD/MM/YYYY') : '';
}
},
{data: "total"},
{
data: "total",
className: "text-end",
render : (d) => `<span class="autonumeric-pagos text-end">${d}</span>`
},
],
order: [[1, "asc"]],
dom: 't',
@ -226,14 +281,27 @@ var tablePagos = $('#tableOfLineasPagos').DataTable({
},
],
drawCallback: function (settings) {
$("span.autonumeric-pagos").each(function () {
let autoNumericInstance = AutoNumeric.getAutoNumericElement(this)
if(autoNumericInstance){
autoNumericInstance.remove()
}
new AutoNumeric(this, {
digitGroupSeparator: ".",
decimalCharacter: ",",
allowDecimalPadding : 'floats',
decimalPlaces: 2,
unformatOnSubmit: true,
decimalPlacesShownOnFocus: 2,
decimalPlacesShownOnBlur: 2,
allowDecimalPadding: true,
});
});
},
footerCallback: function (row, data, start, end, display) {
var api = this.api();
var intVal = function (i) {
// Convertir a número o devolver 0 si no es válido
return typeof i === 'string' ? i.replace(/[\$,]/g, '')*1 : typeof i === 'number' ? i : 0;
};
var filas = [];
api.rows().every(function() {
var data = this.data();
@ -243,7 +311,7 @@ var tablePagos = $('#tableOfLineasPagos').DataTable({
});
var totalPagos = filas
.reduce(function(a, data) {
return a + intVal(data['total']); // Aquí asumimos que la columna 6 está en el índice 5
return parseFloat(a) + parseFloat(data['total']);
}, 0);
var filas = [];
@ -255,12 +323,12 @@ var tablePagos = $('#tableOfLineasPagos').DataTable({
});
var totalPendiente = filas
.reduce(function(a, data) {
return a + intVal(data['total']); // Aquí asumimos que la columna 6 está en el índice 5
return parseFloat(a) + parseFloat(data['total']);
}, 0);
// Update footer
$('#totalCobrado-sum').html(totalPagos.toFixed(2));
$('#pendienteCobro-sum').html(totalPendiente.toFixed(2));
autoNumericTotalCobrado.set(totalPagos);
autoNumericPendienteCobro.set(totalPendiente);
// call footerCallback of the other table
if (typeof tableLineas !== 'undefined') {
@ -269,71 +337,32 @@ var tablePagos = $('#tableOfLineasPagos').DataTable({
}
});
function updateFooterLineas(table){
// Remove the formatting to get integer data for summation
var intVal = function (i) {
return typeof i === 'string' ?
i.replace(/[\$,]/g, '')*1 :
typeof i === 'number' ?
i : 0;
};
// Total over all pages
var totalSubtotal = table
.column(9)
.data()
.reduce(function (a, b) {
return intVal(a) + intVal(b);
}, 0);
var totalIVA = table
.column(10)
.data()
.reduce(function (a, b) {
return intVal(a) + intVal(b);
}, 0);
var totalTotal = table
.column(11)
.data()
.reduce(function (a, b) {
return intVal(a) + intVal(b);
}, 0);
// Update footer
$('#subtotal-sum').html(totalSubtotal.toFixed(2));
$('#total-iva-sum').html(totalIVA.toFixed(2));
$('#total-sum').html(totalTotal.toFixed(2));
// Assuming pendiente de pago is totalTotal - totalIVA for this example
<?php if($facturaEntity->estado == 'borrador') :?>
var pendientePago = totalTotal ;
var total_pagos = 0;
<?php else: ?>
var total_pagos = parseFloat($('#totalCobrado-sum').html()).toFixed(2);
var pendientePago = totalTotal - total_pagos;
<?php endif; ?>
var total_pagos = autoNumericTotalCobrado.getNumber();
var pendientePago = autoNumericTotal.getNumber() - total_pagos;
// Se comprueba si pendientePago es un numero o NAN
if(isNaN(pendientePago)){
pendientePago = 0;
}
$('#pendiente-pago').html(pendientePago.toFixed(2));
autoNumericPendientePago.set(pendientePago);
$.ajax({
url: '<?= route_to('updateFacturaTotales', $facturaEntity->id) ?>',
method: 'POST',
data: {
base: totalSubtotal,
total: totalTotal,
base: autoNumericSubtotal.getNumber(),
total: autoNumericTotal.getNumber(),
total_pagos: total_pagos,
pendiente: pendientePago
}
}).done((data, textStatus, jqXHR) => {
if($('#pendiente-pago').html() == '0.00'){
if(autoNumericPendientePago.getNumber() == 0){
$('#addPagoRow').hide();
} else {
$('#validarFactura').show();
$('#addPagoRow').show();
}
if(data.estado_pago == 'pagada'){
$('#estado_pago_text').text('<?= lang('Facturas.pagada') ?>');

View File

@ -22,7 +22,7 @@
<?php endif; ?>
<?= view("themes/vuexy/form/facturas/_facturaLineasItems") ?>
<?php if($facturaEntity->estado !='borrador' && (strpos($facturaEntity->numero, "REC ") !== 0) ) : ?>
<?php if((strpos($facturaEntity->numero, "REC ") !== 0) ) : ?>
<?= view("themes/vuexy/form/facturas/_pagosFacturasItems") ?>
<?php endif; ?>
<?php if($facturaEntity->estado !='borrador' && (strpos($facturaEntity->numero, "REC ") === 0) ) : ?>
@ -38,6 +38,9 @@
name="validarFactura"
value="<?= lang("Facturas.validarFactura") ?>"
/>
<?php endif; ?>
<?php if($facturaEntity->showDeleteButton == true && $facturaEntity->estado !='validada') : ?>
<input type="button"
class="btn btn-danger float-start me-sm-3 me-1"
id="borrarFactura"

View File

@ -86,7 +86,7 @@
<label for="total_precio" class="form-label">
<?= lang('Pedidos.total_precio') ?>
</label>
<input readonly id="total_precio" name="total_precio" tabindex="1" maxLength="11" class="form-control" value="<?= old('total_precio', $pedidoEntity->total_precio) ?>" >
<input readonly id="total_precio" name="total_precio" tabindex="1" maxLength="11" class="form-control autonumeric" value="<?= old('total_precio', $pedidoEntity->total_precio) ?>" >
</div>
</div><!--//.mb-3 -->
@ -100,6 +100,7 @@
</div><!--//.mb-3 -->
</div>
</div> <!--//accordion-body -->
</div> <!--//accordionFechasTip-->
</div> <!--//card-->
@ -121,7 +122,8 @@
<label for="fecha_entrega_real" class="fecha-pedido form-label">
<?= lang('Pedidos.fecha_entrega_real') ?>
</label>
<input type="text" value="" id="fecha_entrega_real" name="fecha_entrega_real" tabindex="1" maxLength="11" class="form-control" value="<?= old('fecha_entrega_real', $pedidoEntity->fecha_entrega_real) ?>" >
<input type="text" value="" id="fecha_entrega_real" name="fecha_entrega_real" tabindex="1" maxLength="11" class="form-control inaplazable-date" value="<?= old('fecha_entrega_real', $pedidoEntity->fecha_entrega_real) ?>" >
<div id="fecha_entrega_real_change_user" class="form-text"><?= $pedidoEntity->fecha_entrega_real_change_user?></div>
</div>
</div>
<div class="col-md-12 col-lg-3 px-4">
@ -129,7 +131,8 @@
<label for="fecha_impresion" class="form-label">
<?= lang('Pedidos.fecha_impresion') ?>
</label>
<input type="text" id="fecha_impresion" name="fecha_impresion" tabindex="1" maxLength="11" class="fecha-pedido form-control" value="<?= old('fecha_impresion', $pedidoEntity->fecha_impresion) ?>" >
<input type="text" id="fecha_impresion" name="fecha_impresion" tabindex="1" maxLength="11" class="fecha-pedido form-control inaplazable-date" value="<?= old('fecha_impresion', $pedidoEntity->fecha_impresion) ?>" >
<div id="fecha_impresion_change_user" class="form-text"><?= $pedidoEntity->fecha_impresion_change_user?></div>
</div>
</div>
<div class="col-md-12 col-lg-3 px-4">
@ -137,7 +140,8 @@
<label for="fecha_encuadernado" class="form-label">
<?= lang('Pedidos.fecha_encuadernado') ?>
</label>
<input type="text" id="fecha_encuadernado" name="fecha_encuadernado" tabindex="1" maxLength="11" class="fecha-pedido form-control" value="<?= old('fecha_encuadernado', $pedidoEntity->fecha_encuadernado) ?>" >
<input type="text" id="fecha_encuadernado" name="fecha_encuadernado" tabindex="1" maxLength="11" class="fecha-pedido form-control inaplazable-date" value="<?= old('fecha_encuadernado', $pedidoEntity->fecha_encuadernado) ?>" >
<div id="fecha_encuadernado_change_user" class="form-text"><?= $pedidoEntity->fecha_encuadernado_change_user?></div>
</div>
</div>
<div class="col-md-12 col-lg-3 px-4">
@ -145,10 +149,25 @@
<label for="fecha_entrega_externo" class="form-label">
<?= lang('Pedidos.fecha_entrega_externo') ?>
</label>
<input type="text" id="fecha_entrega_externo" name="fecha_entrega_externo" tabindex="1" maxLength="11" class="fecha-pedido form-control" value="<?= old('fecha_entrega_externo', $pedidoEntity->fecha_entrega_externo) ?>" >
<input type="text" id="fecha_entrega_externo" name="fecha_entrega_externo" tabindex="1" maxLength="11" class="fecha-pedido form-control inaplazable-date" value="<?= old('fecha_entrega_externo', $pedidoEntity->fecha_entrega_externo) ?>" >
<div id="fecha_entrega_externo_change_user" class="form-text"><?= $pedidoEntity->fecha_entrega_externo_change_user?></div>
</div>
</div>
</div>
<div class="row">
<label class="switch switch-danger switch-lg mt-1">
<input type="checkbox" class="switch-input ot-preview" id="inaplazable" name="inaplazable" <?=$pedidoEntity->inaplazable?"checked":""?> />
<span class="switch-toggle-slider">
<span class="switch-on">
<i class="ti ti-alert-triangle"></i>
</span>
<span class="switch-off">
<i class="ti ti-x"></i>
</span>
</span>
<span class="switch-label fw-large">Inaplazable</span>
</label>
</div>
</div>
</div> <!--//accordionFechasTip-->
</div> <!--//card-->
@ -183,6 +202,24 @@
<?=$this->section('additionalInlineJs') ?>
document.getElementById('inaplazable').addEventListener('change', () => {
updateDate('inaplazable', $('#inaplazable').prop('checked') ? 1 : 0);
});
if(<?= $pedidoEntity->inaplazable?1:0 ?>){
$('.inaplazable-date').addClass('text-danger fw-bold');
}
const autonumericTotalPrecio = new AutoNumeric('#total_precio', {
decimalPlaces: 2,
digitGroupSeparator: '.',
decimalCharacter: ',',
allowDecimalPadding: true,
unformatOnSubmit: true,
});
$("#fecha_entrega_real").flatpickr({
defaultDate: <?= $pedidoEntity->fecha_entrega_real_text ? "'".$pedidoEntity->fecha_entrega_real_text."'" : 'null' ?>,
dateFormat: "d/m/Y",
@ -321,10 +358,21 @@ function updateDate(elementId, dateStr) {
data = {
<?= csrf_token() ?? "token" ?>: <?= csrf_token() ?>v,
};
var parts = dateStr.split('/');
var newFormat = parts[2] + '-' + parts[1] + '-' + parts[0]; // Asume dateStr en formato d/m/Y.
data[elementId] = newFormat;
if(elementId == 'inaplazable'){
data[elementId] = dateStr;
if(dateStr == 1){
$('.inaplazable-date').addClass('text-danger fw-bold');
}
else{
$('.inaplazable-date').removeClass('text-danger fw-bold');
}
}else{
var parts = dateStr.split('/');
var newFormat = parts[2] + '-' + parts[1] + '-' + parts[0]; // Asume dateStr en formato d/m/Y.
data[elementId] = newFormat;
}
var url = '<?= route_to('actualizarPedido', ':id') ?>';
url = url.replace(':id', id );
@ -336,11 +384,16 @@ function updateDate(elementId, dateStr) {
success: function(response){
if('error' in response){
if(response.error == 0){
for (const [key, value] of Object.entries(response)) {
if (key.endsWith('_change_user')) {
$("#" + key).html(value);
}
}
}
}
}
});
}
<?=$this->endSection() ?>

File diff suppressed because one or more lines are too long