mirror of
https://git.imnavajas.es/jjimenez/safekat.git
synced 2025-07-25 22:52:08 +00:00
Compare commits
170 Commits
bug/presup
...
feat/busca
| Author | SHA1 | Date | |
|---|---|---|---|
| 4e40d2e8f4 | |||
| 1f09a1c603 | |||
| 1afa6bc520 | |||
| e1a72e7874 | |||
| b908c5b5bf | |||
| f278f821b6 | |||
| e2289030db | |||
| 49314e166d | |||
| 1e347cc7d6 | |||
| 597330adb7 | |||
| 8c91be99c3 | |||
| b9f28c5ee8 | |||
| d702b5aa92 | |||
| 21a955d4d2 | |||
| 50334186f2 | |||
| 996cafeb65 | |||
| 2734a94983 | |||
| 242feffe7f | |||
| d8eefcf1b7 | |||
| 1170852209 | |||
| ec8288e6e4 | |||
| a8f8c4851a | |||
| 1ad6fe93b7 | |||
| b95930dcc2 | |||
| d39a8a4e0b | |||
| 42d21c9ca1 | |||
| 74b722903f | |||
| c5867d25b5 | |||
| 8ea0ab13c0 | |||
| 4255b74f33 | |||
| 3d6aa77993 | |||
| d4373a401f | |||
| 7318e4bd7c | |||
| d193ba0b5f | |||
| 3f1165f323 | |||
| 17aa1cf51e | |||
| 6dd6622b35 | |||
| 8f2e99863d | |||
| 38d3592461 | |||
| 7813cf744b | |||
| 1c0be4f96f | |||
| 4c33167764 | |||
| 99e9bf51a6 | |||
| 5f03a3dfda | |||
| 0b6ce06c96 | |||
| 67fbc2589f | |||
| 57688a5310 | |||
| 944f92f3b0 | |||
| ad266dd14f | |||
| 722748aba4 | |||
| ad26a70aed | |||
| 159c4a6ce1 | |||
| ce7ba82bda | |||
| 955fa05666 | |||
| e18368e647 | |||
| b6420b7b8a | |||
| 078205b552 | |||
| 2b7b12fde7 | |||
| 5605a88846 | |||
| c7d8d0c5cc | |||
| a06efc5736 | |||
| 95ca383215 | |||
| d1495534e0 | |||
| 514711c5c2 | |||
| c8e3dfd873 | |||
| 108899c796 | |||
| 1fb9977094 | |||
| ca901b14f3 | |||
| fcaacfbb5d | |||
| 2d0732c218 | |||
| 20702a47f8 | |||
| 5e876f07fb | |||
| e235165499 | |||
| c476c9a938 | |||
| 1fa4e1cd9c | |||
| 52633ef695 | |||
| 2147452125 | |||
| 57194b5dd3 | |||
| 8335c458ed | |||
| aed64581c9 | |||
| e6e46c84e7 | |||
| 4686e5040e | |||
| 953b07497d | |||
| 17e9f8e52f | |||
| 31565ff6dd | |||
| 2f1f6f9631 | |||
| 3171c32283 | |||
| 4076fff844 | |||
| 87e6b029e2 | |||
| 3e0443927c | |||
| ef7cbf853b | |||
| c9d8875392 | |||
| d7de7b0778 | |||
| 40279095a3 | |||
| 324d4774f3 | |||
| 405afd0cf1 | |||
| b1734e169b | |||
| 02ba5d75d1 | |||
| e491172b28 | |||
| 3f876a0b81 | |||
| 8aa7751060 | |||
| 22deda2aea | |||
| 2143660cf6 | |||
| e5004e762a | |||
| 720346e8e3 | |||
| bc85572610 | |||
| 8815319577 | |||
| 38abbe22a7 | |||
| aac17468c3 | |||
| 94cf67a47f | |||
| 120e46f994 | |||
| af6780b36c | |||
| d2f5b77f16 | |||
| db3ada3830 | |||
| 552ef89cd7 | |||
| 5ee6a2c97e | |||
| dd65b1fd88 | |||
| 96a1faf97a | |||
| 673a903c75 | |||
| c588936f00 | |||
| 1453140005 | |||
| 7e68ec5948 | |||
| 7e878c00b2 | |||
| 51d4f988cc | |||
| 78126f6549 | |||
| 8833999e8d | |||
| b4bddaea6a | |||
| 9ee559fd2f | |||
| 3151d95ec2 | |||
| 234006783c | |||
| 1146929beb | |||
| 1d969e5c9f | |||
| ce753ef926 | |||
| 42b213922c | |||
| 3119005688 | |||
| 84e1bc8d27 | |||
| 0b5741de7c | |||
| 56c828f387 | |||
| ef2649c3fd | |||
| 9e0ff7501e | |||
| 9a98ffd6e6 | |||
| 667a2ab679 | |||
| e4f6295597 | |||
| 1063c95fc0 | |||
| b036e2ce32 | |||
| a3962da518 | |||
| e2c8cb0f7c | |||
| 3d80216780 | |||
| d205fb7c6b | |||
| 7ad551238d | |||
| 889ad57adc | |||
| 44c5595173 | |||
| 77c284c9b4 | |||
| 2364edb684 | |||
| 3cb756a42f | |||
| 8b1114dc7f | |||
| 75df199c5d | |||
| 5d80eacb3f | |||
| 6d31cbe33e | |||
| 0ac3414a95 | |||
| e3e21d2b1e | |||
| 79d89b9718 | |||
| 1741d6cd60 | |||
| 6c748a8a2d | |||
| efa327fb48 | |||
| b110fd063c | |||
| fdb1fe77db | |||
| 0c78f0af7a | |||
| 4a12aad3dc | |||
| 745474a37f |
2
.gitignore
vendored
2
.gitignore
vendored
@ -1,4 +1,4 @@
|
||||
ci4/.env
|
||||
.vscode/
|
||||
|
||||
./xdebug.log
|
||||
xdebug.log
|
||||
@ -13,6 +13,7 @@ declare(strict_types=1);
|
||||
|
||||
namespace Config;
|
||||
|
||||
use App\Entities\Usuarios\UsersEntity;
|
||||
use App\Models\UserModel;
|
||||
use CodeIgniter\Shield\Authentication\Passwords\ValidationRules;
|
||||
use CodeIgniter\Shield\Config\Auth as ShieldAuth;
|
||||
|
||||
@ -9,14 +9,18 @@ const SK_PERMISSION_MATRIX = [
|
||||
"plantilla-tarifa.edit",
|
||||
"plantilla-tarifa.delete",
|
||||
"plantilla-tarifa.menu",
|
||||
"perfil.create",
|
||||
"perfil.edit",
|
||||
"perfil.delete",
|
||||
"perfil.menu",
|
||||
"presupuesto.create",
|
||||
"presupuesto.edit",
|
||||
"presupuesto.delete",
|
||||
"presupuesto.menu",
|
||||
"tarifa-preimpresion.create",
|
||||
"tarifa-preimpresion.edit",
|
||||
"tarifa-preimpresion.delete",
|
||||
"tarifa-preimpresion.menu",
|
||||
"presupuesto-cliente.create",
|
||||
"presupuesto-cliente.edit",
|
||||
"presupuesto-cliente.delete",
|
||||
"presupuesto-cliente.menu",
|
||||
"tarifa-manipulado.create",
|
||||
"tarifa-manipulado.edit",
|
||||
"tarifa-manipulado.delete",
|
||||
@ -33,6 +37,10 @@ const SK_PERMISSION_MATRIX = [
|
||||
"tarifa-envio.edit",
|
||||
"tarifa-envio.delete",
|
||||
"tarifa-envio.menu",
|
||||
"tarifa-extra.create",
|
||||
"tarifa-extra.edit",
|
||||
"tarifa-extra.delete",
|
||||
"tarifa-extra.menu",
|
||||
"proveedores.create",
|
||||
"proveedores.edit",
|
||||
"proveedores.delete",
|
||||
@ -73,62 +81,28 @@ const SK_PERMISSION_MATRIX = [
|
||||
"roles-permisos.edit",
|
||||
"roles-permisos.delete",
|
||||
"roles-permisos.menu",
|
||||
"ubicaciones.create",
|
||||
"ubicaciones.edit",
|
||||
"ubicaciones.delete",
|
||||
"ubicaciones.menu",
|
||||
"series-facturas.create",
|
||||
"series-facturas.edit",
|
||||
"series-facturas.delete",
|
||||
"series-facturas.menu",
|
||||
],
|
||||
"cliente-admin" => [
|
||||
"clientes.create",
|
||||
"clientes.edit",
|
||||
"clientes.delete",
|
||||
"clientes.menu",
|
||||
"presupuesto.create",
|
||||
"presupuesto.edit",
|
||||
"presupuesto.delete",
|
||||
"presupuesto.menu",
|
||||
"perfil.edit",
|
||||
"perfil.menu",
|
||||
"presupuesto-cliente.create",
|
||||
"presupuesto-cliente.edit",
|
||||
"presupuesto-cliente.delete",
|
||||
"presupuesto-cliente.menu",
|
||||
],
|
||||
"cliente-editor" => [
|
||||
"clientes.create",
|
||||
"clientes.edit",
|
||||
"clientes.delete",
|
||||
"clientes.menu",
|
||||
"plantilla-tarifa.create",
|
||||
"plantilla-tarifa.edit",
|
||||
"plantilla-tarifa.delete",
|
||||
"plantilla-tarifa.menu",
|
||||
"presupuesto.create",
|
||||
"presupuesto.edit",
|
||||
"presupuesto.delete",
|
||||
"presupuesto.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-envio.create",
|
||||
"tarifa-envio.edit",
|
||||
"tarifa-envio.delete",
|
||||
"tarifa-envio.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",
|
||||
"presupuesto-cliente.create",
|
||||
"presupuesto-cliente.edit",
|
||||
"presupuesto-cliente.delete",
|
||||
"presupuesto-cliente.menu",
|
||||
],
|
||||
"comercial" => [
|
||||
"token.token",
|
||||
|
||||
@ -1,28 +0,0 @@
|
||||
<?php
|
||||
const SK_PERMISSION_MATRIX = [
|
||||
"superadmin"=> [
|
||||
"admin.*",
|
||||
"users.*",
|
||||
"beta.*"
|
||||
],
|
||||
"admin"=> [
|
||||
"admin.access",
|
||||
"users.create",
|
||||
"users.edit",
|
||||
"users.delete",
|
||||
"beta.access"
|
||||
],
|
||||
"developer"=> [
|
||||
"admin.access",
|
||||
"admin.settings",
|
||||
"users.create",
|
||||
"users.edit",
|
||||
"beta.access"
|
||||
],
|
||||
"user"=> [
|
||||
"users.list"
|
||||
],
|
||||
"beta"=> [
|
||||
"beta.access"
|
||||
]
|
||||
];
|
||||
@ -9,10 +9,18 @@ const SK_PERMISSIONS = [
|
||||
'plantilla-tarifa.edit' => 'Can edit',
|
||||
'plantilla-tarifa.delete' => 'Can delete',
|
||||
'plantilla-tarifa.menu' => 'Menu shall be visualize',
|
||||
'perfil.create' => 'Can create',
|
||||
'perfil.edit' => 'Can edit',
|
||||
'perfil.delete' => 'Can delete',
|
||||
'perfil.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',
|
||||
'tarifa-preimpresion.create' => 'Can create',
|
||||
'tarifa-preimpresion.edit' => 'Can edit',
|
||||
'tarifa-preimpresion.delete' => 'Can delete',
|
||||
@ -33,6 +41,10 @@ const SK_PERMISSIONS = [
|
||||
'tarifa-envio.edit' => 'Can edit',
|
||||
'tarifa-envio.delete' => 'Can delete',
|
||||
'tarifa-envio.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',
|
||||
'proveedores.create' => 'Can create',
|
||||
'proveedores.edit' => 'Can edit',
|
||||
'proveedores.delete' => 'Can delete',
|
||||
@ -73,4 +85,12 @@ const SK_PERMISSIONS = [
|
||||
'roles-permisos.edit' => 'Can edit',
|
||||
'roles-permisos.delete' => 'Can delete',
|
||||
'roles-permisos.menu' => 'Menu shall be visualize',
|
||||
'ubicaciones.create' => 'Can create',
|
||||
'ubicaciones.edit' => 'Can edit',
|
||||
'ubicaciones.delete' => 'Can delete',
|
||||
'ubicaciones.menu' => 'Menu shall be visualize',
|
||||
'series-facturas.create' => 'Can create',
|
||||
'series-facturas.edit' => 'Can edit',
|
||||
'series-facturas.delete' => 'Can delete',
|
||||
'series-facturas.menu' => 'Menu shall be visualize',
|
||||
];
|
||||
|
||||
@ -1,11 +0,0 @@
|
||||
<?php
|
||||
const SK_PERMISSIONS = [
|
||||
'admin.access' => 'Can access the sites admin area',
|
||||
'admin.settings' => 'Can access the main site settings',
|
||||
'users.manage-admins' => 'Can manage other admins',
|
||||
'users.list' => 'Can list user stuff',
|
||||
'users.create' => 'Can create new non-admin users',
|
||||
'users.edit' => 'Can edit existing non-admin users',
|
||||
'users.delete' => 'Can delete existing non-admin users',
|
||||
'beta.access' => 'Can access beta-level features',
|
||||
];
|
||||
@ -1,23 +0,0 @@
|
||||
<?php
|
||||
const SK_ROLES = [
|
||||
'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.',
|
||||
],
|
||||
];
|
||||
142
ci4/app/Config/Routes.php
Executable file → Normal file
142
ci4/app/Config/Routes.php
Executable file → Normal file
@ -33,7 +33,7 @@ $routes->group('settings', ['namespace' => 'App\Controllers\Sistema'], function
|
||||
* --------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/* Rutas para configuraciones */
|
||||
/* Rutas para tarifas */
|
||||
$routes->group('tarifas', ['namespace' => 'App\Controllers\Tarifas'], function ($routes) {
|
||||
|
||||
/* Cliente */
|
||||
@ -54,6 +54,41 @@ $routes->group('tarifas', ['namespace' => 'App\Controllers\Tarifas'], function (
|
||||
|
||||
});
|
||||
|
||||
/* Rutas para configuraciones */
|
||||
$routes->group('configuracion', ['namespace' => 'App\Controllers\Configuracion'], function ($routes) {
|
||||
|
||||
/* Ubicaciones */
|
||||
$routes->group('ubicaciones', ['namespace' => 'App\Controllers\Configuracion'], function ($routes) {
|
||||
|
||||
$routes->get('', 'Ubicaciones::index', ['as' => 'ubicacionesList']);
|
||||
$routes->match(['get', 'post'], 'add', 'Ubicaciones::add', ['as' => 'ubicacionesAdd']);
|
||||
$routes->match(['get', 'post'], 'edit/(:num)', 'Ubicaciones::edit/$1', ['as' => 'ubicacionesEdit']);
|
||||
$routes->get('delete/(:num)', 'Ubicaciones::delete/$1', ['as' => 'ubicacionesDelete']);
|
||||
$routes->post('datatable', 'Ubicaciones::datatable', ['as' => 'ubicacionesDT']);
|
||||
|
||||
});
|
||||
|
||||
/* Series Factura */
|
||||
$routes->group('series-facturas', ['namespace' => 'App\Controllers\Configuracion'], function ($routes) {
|
||||
$routes->get('', 'SeriesFacturas::index', ['as' => 'seriesFacturasList']);
|
||||
$routes->match(['get', 'post'], 'add', 'SeriesFacturas::add', ['as' => 'seriesFacturasAdd']);
|
||||
$routes->match(['get', 'post'], 'edit/(:num)', 'SeriesFacturas::edit/$1', ['as' => 'seriesFacturasEdit']);
|
||||
$routes->get('delete/(:num)', 'SeriesFacturas::delete/$1', ['as' => 'seriesFacturasDelete']);
|
||||
$routes->post('datatable', 'SeriesFacturas::datatable', ['as' => 'seriesFacturasDT']);
|
||||
$routes->post('menuitemsFacturas', 'SeriesFacturas::menuItemsFacturas', ['as' => 'menuItemsOfSeriesFacturas']);
|
||||
});
|
||||
|
||||
/* Formas de Pago */
|
||||
$routes->group('formas-pago', ['namespace' => 'App\Controllers\Configuracion'], function ($routes) {
|
||||
$routes->get('', 'FormasPago::index', ['as' => 'formasPagoList']);
|
||||
$routes->match(['get', 'post'], 'add', 'FormasPago::add', ['as' => 'formasPagoAdd']);
|
||||
$routes->match(['get', 'post'], 'edit/(:num)', 'FormasPago::edit/$1', ['as' => 'formasPagoEdit']);
|
||||
$routes->get('delete/(:num)', 'FormasPago::delete/$1', ['as' => 'formasPagoDelete']);
|
||||
$routes->post('datatable', 'FormasPago::datatable', ['as' => 'formasPagoDT']);
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
|
||||
$routes->group('users', ['namespace' => 'App\Controllers\Configuracion'], function ($routes) {
|
||||
$routes->get('', 'Users::index', ['as' => 'userList']);
|
||||
@ -66,6 +101,7 @@ $routes->group('users', ['namespace' => 'App\Controllers\Configuracion'], functi
|
||||
$routes->get('delete/(:num)', 'Users::delete/$1', ['as' => 'deleteUser']);
|
||||
$routes->post('allmenuitems', 'Users::allItemsSelect', ['as' => 'select2ItemsOfUsers']);
|
||||
$routes->post('menuitems', 'Users::menuItems', ['as' => 'menuItemsOfUsers']);
|
||||
$routes->post('getMenuComerciales', 'Users::getMenuComerciales', ['as' => 'menuItemsComerciales']);
|
||||
});
|
||||
|
||||
$routes->group('group', ['namespace' => 'App\Controllers\Configuracion'], function ($routes) {
|
||||
@ -322,6 +358,7 @@ $routes->group('clientes', ['namespace' => 'App\Controllers\Clientes'], function
|
||||
/* Cliente */
|
||||
$routes->group('cliente', ['namespace' => 'App\Controllers\Clientes'], function ($routes) {
|
||||
$routes->get('', 'Cliente::index', ['as' => 'clienteList']);
|
||||
$routes->get('edit/(:num)', 'Cliente::edit/$1', ['as' => 'editarCliente']);
|
||||
$routes->match(['get', 'post'], 'add', 'Cliente::add', ['as' => 'clienteAdd']);
|
||||
$routes->match(['get', 'post'], 'edit/(:num)', 'Cliente::edit/$1', ['as' => 'clienteEdit']);
|
||||
$routes->get('delete/(:num)', 'Cliente::delete/$1', ['as' => 'clienteDelete']);
|
||||
@ -354,10 +391,10 @@ $routes->group('clientes', ['namespace' => 'App\Controllers\Clientes'], function
|
||||
$routes->resource('cliente', ['namespace' => 'App\Controllers\Clientes', 'controller' => 'Cliente', 'except' => 'show,new,create,update']);*/
|
||||
|
||||
$routes->group('clienteprecios', ['namespace' => 'App\Controllers\Clientes'], function ($routes) {
|
||||
$routes->post('datatable', 'Clienteprecios::datatable', ['as' => 'dataTableOfClienteprecios']);
|
||||
$routes->post('datatable_editor', 'Clienteprecios::datatable_editor', ['as' => 'editorOfClienteprecios']);
|
||||
$routes->post('datatable', 'ClientePrecios::datatable', ['as' => 'dataTableOfClienteprecios']);
|
||||
$routes->post('datatable_editor', 'ClientePrecios::datatable_editor', ['as' => 'editorOfClienteprecios']);
|
||||
});
|
||||
$routes->resource('clienteprecios', ['namespace' => 'App\Controllers\Clientes', 'controller' => 'Clienteprecios', 'except' => 'show,new,create,update']);
|
||||
$routes->resource('clienteprecios', ['namespace' => 'App\Controllers\Clientes', 'controller' => 'ClientePrecios', 'except' => 'show,new,create,update']);
|
||||
|
||||
|
||||
$routes->group('clienteplantillaprecios', ['namespace' => 'App\Controllers\Clientes'], function ($routes) {
|
||||
@ -522,6 +559,7 @@ $routes->resource('clientedirecciones', ['namespace' => 'App\Controllers\Cliente
|
||||
$routes->group('cosidotapablanda', ['namespace' => 'App\Controllers\Presupuestos'], function ($routes) {
|
||||
$routes->get('list/(:num)', 'Cosidotapablanda::list/$1', ['as' => 'cosidotapablandaList']); // HOMOGENIZAR CON ARGS DINAMICOS!!!
|
||||
$routes->get('add/(:num)', 'Cosidotapablanda::add/$1', ['as' => 'newCosidotapablanda']);
|
||||
$routes->get('edit/(:any)', 'Cosidotapablanda::edit/$1', ['as' => 'editarPresupuesto']);
|
||||
$routes->post('add/(:num)', 'Cosidotapablanda::add/$1', ['as' => 'createCosidotapablanda']);
|
||||
$routes->post('create', 'Cosidotapablanda::create', ['as' => 'ajaxCreateCosidotapablanda']);
|
||||
$routes->put('(:num)/update', 'Cosidotapablanda::update/$1', ['as' => 'ajaxUpdateCosidotapablanda']);
|
||||
@ -534,21 +572,25 @@ $routes->group('cosidotapablanda', ['namespace' => 'App\Controllers\Presupuestos
|
||||
$routes->resource('cosidotapablanda', ['namespace' => 'App\Controllers\Presupuestos', 'controller' => 'Cosidotapablanda', 'except' => 'show,new,create,update']);
|
||||
|
||||
$routes->group('presupuestocliente', ['namespace' => 'App\Controllers\Presupuestos'], function ($routes) {
|
||||
$routes->get('list/(:num)', 'Presupuestocliente::list/$1', ['as' => 'listarPresupuestoCliente']); // HOMOGENIZAR CON ARGS DINAMICOS!!!
|
||||
$routes->get('list', 'Presupuestocliente::list', ['as' => 'listaPresupuestos']);
|
||||
$routes->post('datatable', 'Presupuestocliente::datatable', ['as' => 'datatableOfPresupuestos']);
|
||||
$routes->get('add', 'Presupuestocliente::add', ['as' => 'nuevoPresupuestoCliente']);
|
||||
$routes->post('add', 'Presupuestocliente::add', ['as' => 'crearPresupuestoCliente']);
|
||||
$routes->post('edit/(:num)', 'Presupuestocliente::edit/$1', ['as' => 'editarPresupuestoCliente']);
|
||||
$routes->post('datatable', 'Cosidotapablanda::datatable', ['as' => 'tablaPresupuestosCliente']);
|
||||
$routes->get('edit/(:any)', 'Presupuestocliente::edit/$1', ['as' => 'editarPresupuestoCliente2']);
|
||||
$routes->post('getgramaje', 'Presupuestocliente::getGramaje', ['as' => 'obtenerGramaje']);
|
||||
$routes->post('presupuesto', 'Presupuestocliente::presupuesto', ['as' => 'presupuestoCliente']);
|
||||
$routes->post('getDireccionesCliente', 'Presupuestocliente::getDireccionesCliente', ['as' => 'getDirecciones']);
|
||||
$routes->post('getDatosDireccion', 'Presupuestocliente::getDatosDireccion', ['as' => 'getDatosDireccion']);
|
||||
$routes->post('getNuevaDireccion', 'Presupuestocliente::getNuevaDireccion', ['as' => 'nuevaDireccion']);
|
||||
$routes->post('guardarPresupuesto', 'Presupuestocliente::guardarPresupuesto', ['as' => 'guardarPresupuesto']);
|
||||
$routes->post('duplicarPresupuesto', 'Presupuestocliente::duplicarPresupuesto', ['as' => 'duplicarPresupuesto']);
|
||||
});
|
||||
$routes->resource('presupuestocliente', ['namespace' => 'App\Controllers\Presupuestos', 'controller' => 'Presupuestocliente', 'except' => 'show,new,create,update']);
|
||||
|
||||
$routes->group('serviciosacabados', ['namespace' => 'App\Controllers\Presupuestos'], function ($routes) {
|
||||
$routes->post('datatable', 'Presupuestoacabados::datatable', ['as' => 'dataTableOfPresupuestoAcabados']);
|
||||
$routes->post('menuitems', 'Presupuestoacabados::menuItems', ['as' => 'menuItemsOfPresupuestoAcabados']);
|
||||
$routes->post('edit/(:num)', 'Presupuestoacabados::edit/$1', ['as' => 'updatePresupuestoacabados']);
|
||||
});
|
||||
|
||||
@ -585,6 +627,60 @@ $routes->group('presupuestotiradasalternativas', ['namespace' => 'App\Controller
|
||||
$routes->post('datatable_2', 'Presupuestotiradasalternativas::datatable_2', ['as' => 'getTiradaData']);
|
||||
});
|
||||
|
||||
$routes->group('pedidos', ['namespace' => 'App\Controllers\Pedidos'], function ($routes) {
|
||||
$routes->get('list', 'Pedido::todos', ['as' => 'listaPresupuestos']);
|
||||
$routes->get('listActivos', 'Pedido::activos', ['as' => 'listaPresupuestosActivos']);
|
||||
$routes->get('listFinalizados', 'Pedido::finalizados', ['as' => 'listaFinalizados']);
|
||||
$routes->get('listCancelados', 'Pedido::cancelados', ['as' => 'listaCancelados']);
|
||||
$routes->post('datatable', 'Pedido::datatable', ['as' => 'dataTableOfPedidos']);
|
||||
$routes->get('add', 'Pedido::add', ['as' => 'nuevoPedido']);
|
||||
$routes->post('add', 'Pedido::add', ['as' => 'crearPedido']);
|
||||
$routes->get('edit/(:any)', 'Pedido::edit/$1', ['as' => 'editarPedido']);
|
||||
$routes->post('getlineas', 'Pedido::getLineas', ['as' => 'tablaLineasPedido']);
|
||||
$routes->post('cambiarestado', 'Pedido::cambiarEstado', ['as' => 'cambiarEstadoPedido']);
|
||||
$routes->post('update/(:any)', 'Pedido::update/$1', ['as' => 'actualizarPedido']);
|
||||
|
||||
});
|
||||
$routes->resource('pedidos', ['namespace' => 'App\Controllers\Pedidos', 'controller' => 'Pedido', 'except' => 'show,new,create,update']);
|
||||
|
||||
|
||||
$routes->group('albaranes', ['namespace' => 'App\Controllers\Pedidos'], function ($routes) {
|
||||
$routes->post('add', 'Albaran::add', ['as' => 'crearAlbaranesPedido']);
|
||||
$routes->post('update/(:any)', 'Albaran::update/$1', ['as' => 'actualizarAlbaran']);
|
||||
$routes->post('updateLinea/(:any)', 'Albaran::updateLinea/$1', ['as' => 'actualizarLineaAlbaran']);
|
||||
$routes->post('deletelinea', 'Albaran::borrarlinea', ['as' => 'borrarAlbaranLinea']);
|
||||
$routes->get('delete/(:any)', 'Albaran::delete/$1', ['as' => 'borrarAlbaran']);
|
||||
$routes->get('getalbaranes/(:any)', 'Albaran::getAlbaranes/$1', ['as' => 'getAlbaranes']);
|
||||
$routes->get('nuevalinea/(:any)', 'Albaran::addLinea/$1', ['as' => 'addAlbaranLinea']);
|
||||
$routes->post('nuevalinea/(:any)', 'Albaran::addLinea/$1', ['as' => 'addIVA']);
|
||||
});
|
||||
$routes->resource('albaranes', ['namespace' => 'App\Controllers\Pedidos', 'controller' => 'Albaran', 'except' => 'show,new,create,update']);
|
||||
|
||||
|
||||
$routes->group('facturas', ['namespace' => 'App\Controllers\Facturacion'], function ($routes) {
|
||||
|
||||
$routes->get('list', 'Facturas::list', ['as' => 'facturasList']);
|
||||
$routes->post('datatable', 'Facturas::datatable', ['as' => 'dataTableOfFacturas']);
|
||||
$routes->get('add', 'Facturas::add', ['as' => 'newFactura']);
|
||||
$routes->post('add', 'Facturas::add', ['as' => 'createFactura']);
|
||||
$routes->get('edit/(:any)', 'Facturas::edit/$1', ['as' => 'editarFactura']);
|
||||
$routes->get('validar/(:any)', 'Facturas::validar/$1', ['as' => 'validarFactura']);
|
||||
$routes->post('update/(:any)', 'Facturas::update/$1', ['as' => 'actualizarFactura']);
|
||||
$routes->post('duplicate/(:any)', 'Facturas::duplicate/$1', ['as' => 'duplicarFactura']);
|
||||
$routes->post('datatable/(:any)', 'FacturasLineas::datatable/$1', ['as' => 'dataTableOfLineasFacturas']);
|
||||
$routes->post('menuPedidosPendientes/(:num)', 'Facturas::menuPedidosPendientes/$1', ['as' => 'menuPedidosPendientesImpresion']);
|
||||
$routes->post('addLineaPedidoImpresion/(:num)', 'Facturas::addLineaPedidoImpresion/$1', ['as' => 'addLineaPedidoImpresion2Factura']);
|
||||
$routes->post('addExcedentes/(:any)', 'Facturas::addExcedentes/$1', ['as' => 'addLineaExcedentes']);
|
||||
$routes->get('deleteLinea/(:any)', 'FacturasLineas::deleteLinea/$1', ['as' => 'deleteLineaFactura']);
|
||||
$routes->get('delete/(:any)', 'Facturas::delete/$1', ['as' => 'borrarFactura']);
|
||||
$routes->post('deleteFacturaLineaPedido', 'Facturas::deleteLineaPedidoImpresion', ['as' => 'deleteLineaPedidoImpresion']);
|
||||
$routes->post('editorLineas', 'FacturasLineas::datatable_editor', ['as' => 'editorOfLineasFacturas']);
|
||||
$routes->post('updateTotales/(:any)', 'Facturas::updateTotales/$1', ['as' => 'updateFacturaTotales']);
|
||||
$routes->post('updateCabecera/(:any)', 'Facturas::updateCabecera/$1', ['as' => 'updateCabecera']);
|
||||
$routes->post('datatablePagos/(:any)', 'FacturasPagos::datatable/$1', ['as' => 'dataTableOfPagosFacturas']);
|
||||
$routes->post('editorPagos', 'FacturasPagos::datatable_editor', ['as' => 'editorOfPagosFacturas']);
|
||||
$routes->post('datatablePedidos', 'Facturas::datatablePedidos', ['as' => 'dataTableOfFacturasPedido']);
|
||||
});
|
||||
|
||||
|
||||
$routes->group(
|
||||
@ -596,6 +692,40 @@ $routes->group(
|
||||
}
|
||||
);
|
||||
|
||||
$routes->group(
|
||||
'print-albaran',
|
||||
['namespace' => 'App\Controllers\Pdf'],
|
||||
function ($routes) {
|
||||
$routes->get('index/(:num)', 'PrintAlbaranes::index/$1', ['as' => 'viewAlbaranPDF']);
|
||||
$routes->get('generar/(:num)', 'PrintAlbaranes::generar/$1', ['as' => 'albaranToPdf']);
|
||||
}
|
||||
);
|
||||
|
||||
$routes->group(
|
||||
'print-factura',
|
||||
['namespace' => 'App\Controllers\Pdf'],
|
||||
function ($routes) {
|
||||
$routes->get('index/(:num)', 'PrintFacturas::index/$1', ['as' => 'viewFacturaPDF']);
|
||||
$routes->get('generar/(:num)', 'PrintFacturas::generar/$1', ['as' => 'facturaToPdf']);
|
||||
}
|
||||
);
|
||||
|
||||
$routes->group(
|
||||
'export-giros',
|
||||
['namespace' => 'App\Controllers\Excel'],
|
||||
function ($routes) {
|
||||
$routes->get('generar/(:num)', 'PrintGiros::generateExcel/$1', ['as' => 'girosToExcel']);
|
||||
}
|
||||
);
|
||||
|
||||
$routes->group(
|
||||
'export-lineas',
|
||||
['namespace' => 'App\Controllers\Excel'],
|
||||
function ($routes) {
|
||||
$routes->get('generar/(:num)', 'PrintLineas::generateExcel/$1', ['as' => 'lineasToExcel']);
|
||||
}
|
||||
);
|
||||
|
||||
$routes->group(
|
||||
'buscadorpresupuestos',
|
||||
['namespace' => 'App\Controllers\Presupuestos'],
|
||||
|
||||
@ -37,7 +37,7 @@ class BaseController extends Controller
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $helpers = ['general', 'go_common'];
|
||||
protected $helpers = ['general', 'go_common', 'rbac'];
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
|
||||
@ -43,23 +43,23 @@ abstract class BaseResourceController extends \CodeIgniter\RESTful\ResourceContr
|
||||
*/
|
||||
protected static $pluralObjectName;
|
||||
|
||||
/**
|
||||
/**
|
||||
* Path for the views directory for the extending view controller
|
||||
*
|
||||
* @var string
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected static $viewPath;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* JJO: Variable para indicar si el controlador hace soft_delete o no
|
||||
*
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
public $soft_delete = false;
|
||||
/**
|
||||
* JJO: Variable quién puede ver los registros borrados
|
||||
*
|
||||
*
|
||||
* 0 -> Not Deleted
|
||||
* 1 -> Soft Deleted, shows up in lists of deleted items for management users
|
||||
* 2 -> Soft Deleted, does not show up for any user except admin users
|
||||
@ -85,7 +85,7 @@ abstract class BaseResourceController extends \CodeIgniter\RESTful\ResourceContr
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $helpers = ['session', 'go_common', 'form', 'text', 'general']; //JJO
|
||||
protected $helpers = ['session', 'go_common', 'form', 'text', 'general', 'rbac']; //JJO
|
||||
|
||||
/**
|
||||
* Initializer method.
|
||||
@ -123,7 +123,7 @@ abstract class BaseResourceController extends \CodeIgniter\RESTful\ResourceContr
|
||||
$this->viewData['usingSweetAlert'] = true;
|
||||
|
||||
$this->viewData['viewPath'] = static::$viewPath;
|
||||
|
||||
|
||||
$this->viewData['currentLocale'] = $this->request->getLocale();
|
||||
|
||||
/* IMN */
|
||||
@ -159,7 +159,7 @@ abstract class BaseResourceController extends \CodeIgniter\RESTful\ResourceContr
|
||||
}
|
||||
|
||||
if (!isset($this->viewData['formAction'])) {
|
||||
$this->viewData['formAction'] = base_url(strtolower($this->viewData['currentModule']) . '/' . $formActionSuffix . '/' . $action );
|
||||
$this->viewData['formAction'] = base_url(strtolower($this->viewData['currentModule']) . '/' . $formActionSuffix . '/' . $action);
|
||||
}
|
||||
|
||||
if ((!isset($this->viewData['boxTitle']) || empty($this->viewData['boxTitle'])) && isset(static::$singularObjectName) && !empty(static::$singularObjectName)) {
|
||||
@ -223,29 +223,28 @@ abstract class BaseResourceController extends \CodeIgniter\RESTful\ResourceContr
|
||||
public function delete($id = null)
|
||||
{
|
||||
if (!empty(static::$pluralObjectNameCc) && !empty(static::$singularObjectNameCc)) {
|
||||
$objName = mb_strtolower(lang(ucfirst(static::$pluralObjectNameCc).'.'.static::$singularObjectNameCc));
|
||||
$objName = mb_strtolower(lang(ucfirst(static::$pluralObjectNameCc) . '.' . static::$singularObjectNameCc));
|
||||
} else {
|
||||
$objName = lang('Basic.global.record');
|
||||
}
|
||||
|
||||
if (!$this->soft_delete){
|
||||
|
||||
if (!$this->soft_delete) {
|
||||
|
||||
if (!$this->model->delete($id)) {
|
||||
return $this->failNotFound(lang('Basic.global.deleteError', [$objName]));
|
||||
}
|
||||
}
|
||||
else{
|
||||
} else {
|
||||
$datetime = (new \CodeIgniter\I18n\Time("now"));
|
||||
$rawResult = $this->model->where('id',$id)
|
||||
->set(['deleted_at' => $datetime->format('Y-m-d H:i:s'),
|
||||
'is_deleted' => $this->delete_flag])
|
||||
$rawResult = $this->model->where('id', $id)
|
||||
->set(['deleted_at' => $datetime->format('Y-m-d H:i:s'),
|
||||
'is_deleted' => $this->delete_flag])
|
||||
->update();
|
||||
if (!$rawResult) {
|
||||
return $this->failNotFound(lang('Basic.global.deleteError', [$objName]));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
// $message = lang('Basic.global.deleteSuccess', [$objName]); IMN commented
|
||||
$message = lang('Basic.global.deleteSuccess', [lang('Basic.global.record')]);
|
||||
$response = $this->respondDeleted(['id' => $id, 'msg' => $message]);
|
||||
@ -261,20 +260,18 @@ abstract class BaseResourceController extends \CodeIgniter\RESTful\ResourceContr
|
||||
protected function canValidate($customValidationRules = null, $customValidationMessages = null)
|
||||
{
|
||||
|
||||
if($customValidationRules == null){
|
||||
if ($customValidationRules == null) {
|
||||
$validationRules = $this->model->validationRules ?? $this->formValidationRules ?? null;
|
||||
}
|
||||
else{
|
||||
} else {
|
||||
$validationRules = $customValidationRules;
|
||||
}
|
||||
if ($validationRules == null) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if($customValidationMessages == null){
|
||||
$validationErrorMessages = $this->model->validationMessages ?? $this->formValidationErrorMessagess ?? null;;
|
||||
}
|
||||
else{
|
||||
if ($customValidationMessages == null) {
|
||||
$validationErrorMessages = $this->model->validationMessages ?? $this->formValidationErrorMessagess ?? null;;
|
||||
} else {
|
||||
$validationErrorMessages = $customValidationMessages;
|
||||
}
|
||||
|
||||
@ -283,7 +280,7 @@ abstract class BaseResourceController extends \CodeIgniter\RESTful\ResourceContr
|
||||
} else {
|
||||
$valid = $this->validate($validationRules);
|
||||
}
|
||||
|
||||
|
||||
$this->validationErrors = $valid ? '' : $this->validator->getErrors();
|
||||
|
||||
/*
|
||||
@ -303,7 +300,8 @@ abstract class BaseResourceController extends \CodeIgniter\RESTful\ResourceContr
|
||||
* @param array|null $postData
|
||||
* @return array
|
||||
*/
|
||||
protected function sanitized(array $postData = null, bool $nullIfEmpty = false) {
|
||||
protected function sanitized(array $postData = null, bool $nullIfEmpty = false)
|
||||
{
|
||||
if ($postData == null) {
|
||||
$postData = $this->request->getPost();
|
||||
}
|
||||
@ -317,7 +315,7 @@ abstract class BaseResourceController extends \CodeIgniter\RESTful\ResourceContr
|
||||
}
|
||||
return $sanitizedData;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Custom fail method needed when CSRF token regeneration is on in security settings
|
||||
* @param string|array $messages
|
||||
@ -326,15 +324,15 @@ abstract class BaseResourceController extends \CodeIgniter\RESTful\ResourceContr
|
||||
* @param string $customMessage
|
||||
* @return mixed
|
||||
*/
|
||||
protected function failWithNewToken($messages, int $status = 400, string $code = null, string $customMessage = '') {
|
||||
protected function failWithNewToken($messages, int $status = 400, string $code = null, string $customMessage = '')
|
||||
{
|
||||
|
||||
if (! is_array($messages))
|
||||
{
|
||||
if (!is_array($messages)) {
|
||||
$messages = ['error' => $messages];
|
||||
}
|
||||
$response = [
|
||||
'status' => $status,
|
||||
'error' => $status,
|
||||
'status' => $status,
|
||||
'error' => $status,
|
||||
'messages' => $messages,
|
||||
csrf_token() => csrf_hash()
|
||||
];
|
||||
@ -360,7 +358,8 @@ abstract class BaseResourceController extends \CodeIgniter\RESTful\ResourceContr
|
||||
* Convenience method for common exception handling
|
||||
* @param \Exception $e
|
||||
*/
|
||||
protected function dealWithException(\Exception $e) {
|
||||
protected function dealWithException(\Exception $e)
|
||||
{
|
||||
// using another try / catch block to prevent to avoid CodeIgniter bug throwing trivial exceptions for querying DB errors
|
||||
try {
|
||||
$query = $this->model->db->getLastQuery();
|
||||
@ -368,16 +367,16 @@ abstract class BaseResourceController extends \CodeIgniter\RESTful\ResourceContr
|
||||
$dbError = $this->model->db->error();
|
||||
$userFriendlyErrMsg = lang('Basic.global.persistErr1', [static::$singularObjectNameCc]);
|
||||
if (isset($dbError['code']) && $dbError['code'] == 1062) :
|
||||
$userFriendlyErrMsg .= PHP_EOL.lang('Basic.global.persistDuplErr', [static::$singularObjectNameCc]);
|
||||
$userFriendlyErrMsg .= PHP_EOL . lang('Basic.global.persistDuplErr', [static::$singularObjectNameCc]);
|
||||
endif;
|
||||
// $userFriendlyErrMsg = str_replace("'", "\'", $userFriendlyErrMsg); // Uncomment if experiencing unescaped single quote errors
|
||||
log_message('error', $userFriendlyErrMsg.PHP_EOL.$e->getMessage().PHP_EOL.$queryStr);
|
||||
log_message('error', $userFriendlyErrMsg . PHP_EOL . $e->getMessage() . PHP_EOL . $queryStr);
|
||||
if (isset($dbError['message']) && !empty($dbError['message'])) :
|
||||
log_message('error', $dbError['code'].' : '.$dbError['message']);
|
||||
log_message('error', $dbError['code'] . ' : ' . $dbError['message']);
|
||||
endif;
|
||||
$this->viewData['errorMessage'] = $userFriendlyErrMsg;
|
||||
} catch (\Exception $e2) {
|
||||
log_message('debug', 'You can probably safely ignore this: In attempt to check DB errors, CodeIgniter threw: '.PHP_EOL.$e2->getMessage());
|
||||
log_message('debug', 'You can probably safely ignore this: In attempt to check DB errors, CodeIgniter threw: ' . PHP_EOL . $e2->getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -312,10 +312,6 @@ class Cliente extends \App\Controllers\BaseResourceController
|
||||
$onlyActiveOnes = false;
|
||||
try{
|
||||
$menu = $this->model->getSelect2MenuItems($columns2select, $columns2select[1], $onlyActiveOnes, $searchStr);
|
||||
$nonItem = new \stdClass;
|
||||
$nonItem->id = '';
|
||||
$nonItem->text = '- ' . lang('Basic.global.None') . ' -';
|
||||
array_unshift($menu, $nonItem);
|
||||
}
|
||||
catch(Exception $e){
|
||||
$menu = [];
|
||||
@ -399,7 +395,7 @@ class Cliente extends \App\Controllers\BaseResourceController
|
||||
|
||||
protected function getFormaDePagoListItems($selId = null)
|
||||
{
|
||||
$data = ['' => lang('Basic.global.pleaseSelectA', [mb_strtolower(lang('FormasPagoes.formaDePago'))])];
|
||||
$data = ['' => lang('Basic.global.pleaseSelectA', [mb_strtolower(lang('FormasPago.formaDePago'))])];
|
||||
if (!empty($selId)) :
|
||||
$formaPagoModel = model('App\Models\Configuracion\FormaPagoModel');
|
||||
|
||||
|
||||
55
ci4/app/Controllers/Configuracion/Formaspagos.php → ci4/app/Controllers/Configuracion/FormasPago.php
Executable file → Normal file
55
ci4/app/Controllers/Configuracion/Formaspagos.php → ci4/app/Controllers/Configuracion/FormasPago.php
Executable file → Normal file
@ -9,7 +9,7 @@ use App\Entities\Configuracion\FormaPagoEntity;
|
||||
|
||||
use App\Models\Configuracion\FormaPagoModel;
|
||||
|
||||
class Formaspagos extends \App\Controllers\BaseResourceController
|
||||
class FormasPago extends \App\Controllers\BaseResourceController
|
||||
{
|
||||
|
||||
protected $modelName = FormaPagoModel::class;
|
||||
@ -22,15 +22,22 @@ class Formaspagos extends \App\Controllers\BaseResourceController
|
||||
|
||||
protected static $controllerSlug = 'formas-pagos';
|
||||
|
||||
protected static $viewPath = 'themes/vuexy/form/configuracion/formasPagoViews/';
|
||||
protected static $viewPath = 'themes/vuexy/form/configuracion/formas-pago/';
|
||||
|
||||
protected $indexRoute = 'formaDePagoList';
|
||||
|
||||
|
||||
public function initController(\CodeIgniter\HTTP\RequestInterface $request, \CodeIgniter\HTTP\ResponseInterface $response, \Psr\Log\LoggerInterface $logger)
|
||||
{
|
||||
$this->viewData['pageTitle'] = lang('FormasPagoes.moduleTitle');
|
||||
$this->viewData['pageTitle'] = lang('FormasPago.moduleTitle');
|
||||
$this->viewData['usingSweetAlert'] = true;
|
||||
|
||||
// Breadcrumbs (IMN)
|
||||
$this->viewData['breadcrumb'] = [
|
||||
['title' => lang("App.menu_configuration"), 'route' => "javascript:void(0);", 'active' => false],
|
||||
['title' => lang("App.menu_formas_pago"), 'route' => route_to('formasPagoList'), 'active' => true]
|
||||
];
|
||||
|
||||
parent::initController($request, $response, $logger);
|
||||
}
|
||||
|
||||
@ -40,7 +47,7 @@ class Formaspagos extends \App\Controllers\BaseResourceController
|
||||
|
||||
$viewData = [
|
||||
'currentModule' => static::$controllerSlug,
|
||||
'pageSubTitle' => lang('Basic.global.ManageAllRecords', [lang('FormasPagoes.formaDePago')]),
|
||||
'pageSubTitle' => lang('Basic.global.ManageAllRecords', [lang('FormasPago.formaDePago')]),
|
||||
'formaPagoEntity' => new FormaPagoEntity(),
|
||||
'usingServerSideDataTable' => true,
|
||||
|
||||
@ -55,22 +62,15 @@ class Formaspagos extends \App\Controllers\BaseResourceController
|
||||
public function add()
|
||||
{
|
||||
|
||||
|
||||
|
||||
|
||||
if ($this->request->getPost()) :
|
||||
|
||||
$nullIfEmpty = true; // !(phpversion() >= '8.1');
|
||||
|
||||
$postData = $this->request->getPost();
|
||||
|
||||
$sanitizedData = $this->sanitized($postData, $nullIfEmpty);
|
||||
|
||||
$sanitizedData = $this->sanitized($postData, true);
|
||||
|
||||
$noException = true;
|
||||
if ($successfulResult = $this->canValidate()) : // if ($successfulResult = $this->validate($this->formValidationRules) ) :
|
||||
|
||||
|
||||
if ($this->canValidate()) :
|
||||
try {
|
||||
$successfulResult = $this->model->skipValidation(true)->save($sanitizedData);
|
||||
@ -93,7 +93,8 @@ class Formaspagos extends \App\Controllers\BaseResourceController
|
||||
|
||||
if ($thenRedirect) :
|
||||
if (!empty($this->indexRoute)) :
|
||||
return redirect()->to(route_to($this->indexRoute))->with('sweet-success', $message);
|
||||
return redirect()->to(site_url('/configuracion/formas-pago/edit/' . $id))->with('sweet-success', $message);
|
||||
//return redirect()->to(route_to($this->indexRoute))->with('sweet-success', $message);
|
||||
else:
|
||||
return $this->redirect2listView('sweet-success', $message);
|
||||
endif;
|
||||
@ -106,11 +107,8 @@ class Formaspagos extends \App\Controllers\BaseResourceController
|
||||
endif; // ($requestMethod === 'post')
|
||||
|
||||
$this->viewData['formaPagoEntity'] = isset($sanitizedData) ? new FormaPagoEntity($sanitizedData) : new FormaPagoEntity();
|
||||
|
||||
$this->viewData['formAction'] = route_to('createFormaDePago');
|
||||
|
||||
$this->viewData['boxTitle'] = lang('Basic.global.addNew') . ' ' . lang('FormasPagoes.moduleTitle') . ' ' . lang('Basic.global.addNewSuffix');
|
||||
|
||||
$this->viewData['formAction'] = route_to('formasPagoAdd');
|
||||
$this->viewData['boxTitle'] = lang('Basic.global.addNew') . ' ' . lang('FormasPago.moduleTitle') . ' ' . lang('Basic.global.addNewSuffix');
|
||||
|
||||
return $this->displayForm(__METHOD__);
|
||||
} // end function add()
|
||||
@ -125,25 +123,18 @@ class Formaspagos extends \App\Controllers\BaseResourceController
|
||||
$formaPagoEntity = $this->model->find($id);
|
||||
|
||||
if ($formaPagoEntity == false) :
|
||||
$message = lang('Basic.global.notFoundWithIdErr', [mb_strtolower(lang('FormasPagoes.formaDePago')), $id]);
|
||||
$message = lang('Basic.global.notFoundWithIdErr', [mb_strtolower(lang('FormasPago.formaDePago')), $id]);
|
||||
return $this->redirect2listView('sweet-error', $message);
|
||||
endif;
|
||||
|
||||
|
||||
|
||||
if ($this->request->getPost()) :
|
||||
|
||||
$nullIfEmpty = true; // !(phpversion() >= '8.1');
|
||||
|
||||
$postData = $this->request->getPost();
|
||||
|
||||
$sanitizedData = $this->sanitized($postData, $nullIfEmpty);
|
||||
|
||||
$sanitizedData = $this->sanitized($postData, true);
|
||||
|
||||
$noException = true;
|
||||
if ($successfulResult = $this->canValidate()) : // if ($successfulResult = $this->validate($this->formValidationRules) ) :
|
||||
|
||||
|
||||
if ($this->canValidate()) :
|
||||
try {
|
||||
$successfulResult = $this->model->skipValidation(true)->update($id, $sanitizedData);
|
||||
@ -152,13 +143,12 @@ class Formaspagos extends \App\Controllers\BaseResourceController
|
||||
$this->dealWithException($e);
|
||||
}
|
||||
else:
|
||||
$this->viewData['warningMessage'] = lang('Basic.global.formErr1', [mb_strtolower(lang('FormasPagoes.formaDePago'))]);
|
||||
$this->viewData['warningMessage'] = lang('Basic.global.formErr1', [mb_strtolower(lang('FormasPago.formaDePago'))]);
|
||||
$this->session->setFlashdata('formErrors', $this->model->errors());
|
||||
|
||||
endif;
|
||||
|
||||
$formaPagoEntity->fill($sanitizedData);
|
||||
|
||||
$thenRedirect = false;
|
||||
endif;
|
||||
if ($noException && $successfulResult) :
|
||||
@ -179,11 +169,8 @@ class Formaspagos extends \App\Controllers\BaseResourceController
|
||||
endif; // ($requestMethod === 'post')
|
||||
|
||||
$this->viewData['formaPagoEntity'] = $formaPagoEntity;
|
||||
|
||||
$this->viewData['formAction'] = route_to('updateFormaDePago', $id);
|
||||
|
||||
$this->viewData['boxTitle'] = lang('Basic.global.edit2') . ' ' . lang('FormasPagoes.moduleTitle') . ' ' . lang('Basic.global.edit3');
|
||||
|
||||
$this->viewData['formAction'] = route_to('formasPagoEdit', $id);
|
||||
$this->viewData['boxTitle'] = lang('Basic.global.edit2') . ' ' . lang('FormasPago.moduleTitle') . ' ' . lang('Basic.global.edit3');
|
||||
|
||||
return $this->displayForm(__METHOD__, $id);
|
||||
} // end function edit(...)
|
||||
268
ci4/app/Controllers/Configuracion/SeriesFacturas.php
Normal file
268
ci4/app/Controllers/Configuracion/SeriesFacturas.php
Normal file
@ -0,0 +1,268 @@
|
||||
<?php namespace App\Controllers\Configuracion;
|
||||
|
||||
use App\Controllers\BaseResourceController;
|
||||
use App\Models\Collection;
|
||||
use App\Entities\Configuracion\SeriesFacturasEntity;
|
||||
use App\Models\Configuracion\SeriesFacturasModel;
|
||||
|
||||
class SeriesFacturas extends BaseResourceController
|
||||
{
|
||||
|
||||
protected $modelName = SeriesFacturasModel::class;
|
||||
protected $format = 'json';
|
||||
|
||||
protected static $singularObjectName = 'Series Facturas';
|
||||
protected static $singularObjectNameCc = 'seriesFacturas';
|
||||
protected static $pluralObjectName = 'Series Facturas';
|
||||
protected static $pluralObjectNameCc = 'seriesFacturas';
|
||||
|
||||
protected static $controllerSlug = 'ubicaciones';
|
||||
|
||||
protected static $viewPath = 'themes/vuexy/form/configuracion/series-facturas/';
|
||||
|
||||
protected $indexRoute = 'seriesFacturasList';
|
||||
|
||||
|
||||
public function initController(\CodeIgniter\HTTP\RequestInterface $request, \CodeIgniter\HTTP\ResponseInterface $response, \Psr\Log\LoggerInterface $logger)
|
||||
{
|
||||
$this->viewData['pageTitle'] = lang('SeriesFacturas.moduleTitle');
|
||||
$this->viewData['usingSweetAlert'] = true;
|
||||
|
||||
// Breadcrumbs (IMN)
|
||||
$this->viewData['breadcrumb'] = [
|
||||
['title' => lang("App.menu_configuration"), 'route' => "javascript:void(0);", 'active' => false],
|
||||
['title' => lang("App.menu_series_facturas"), 'route' => route_to('seriesFacturasList'), 'active' => true]
|
||||
];
|
||||
|
||||
parent::initController($request, $response, $logger);
|
||||
}
|
||||
|
||||
|
||||
public function index()
|
||||
{
|
||||
|
||||
$viewData = [
|
||||
'currentModule' => static::$controllerSlug,
|
||||
'pageSubTitle' => lang('Basic.global.ManageAllRecords', [lang('SeriesFacturas.moduleTitle')]),
|
||||
'seriesFacturasEntity' => new SeriesFacturasEntity(),
|
||||
'usingServerSideDataTable' => true,
|
||||
|
||||
];
|
||||
|
||||
$viewData = array_merge($this->viewData, $viewData); // merge any possible values from the parent controller class
|
||||
|
||||
return view(static::$viewPath . 'viewSeriesFacturasList', $viewData);
|
||||
}
|
||||
|
||||
|
||||
public function add()
|
||||
{
|
||||
if ($this->request->getPost()) :
|
||||
|
||||
$postData = $this->request->getPost();
|
||||
|
||||
$sanitizedData = $this->sanitized($postData, true);
|
||||
|
||||
$noException = true;
|
||||
if ($successfulResult = $this->canValidate()) :
|
||||
|
||||
if ($this->canValidate()) :
|
||||
try {
|
||||
$successfulResult = $this->model->skipValidation(true)->save($sanitizedData);
|
||||
} catch (\Exception $e) {
|
||||
$noException = false;
|
||||
$this->dealWithException($e);
|
||||
}
|
||||
else:
|
||||
$this->viewData['errorMessage'] = lang('Basic.global.formErr1', [lang('Basic.global.record')]);
|
||||
$this->session->setFlashdata('formErrors', $this->model->errors());
|
||||
endif;
|
||||
|
||||
$thenRedirect = true; // Change this to false if you want your user to stay on the form after submission
|
||||
endif;
|
||||
if ($noException && $successfulResult) :
|
||||
|
||||
$id = $this->model->db->insertID();
|
||||
|
||||
$message = lang('Basic.global.saveSuccess', [lang('Basic.global.record')]) . '.';
|
||||
|
||||
if ($thenRedirect) :
|
||||
if (!empty($this->indexRoute)) :
|
||||
return redirect()->to(route_to($this->indexRoute))->with('sweet-success', $message);
|
||||
else:
|
||||
return $this->redirect2listView('sweet-success', $message);
|
||||
endif;
|
||||
else:
|
||||
$this->session->setFlashData('sweet-success', $message);
|
||||
endif;
|
||||
|
||||
endif; // $noException && $successfulResult
|
||||
|
||||
endif; // ($requestMethod === 'post')
|
||||
|
||||
$this->viewData['seriesFacturasEntity'] = isset($sanitizedData) ? new SeriesFacturasEntity($sanitizedData) : new SeriesFacturasEntity();
|
||||
$this->viewData['formAction'] = route_to('seriesFacturasAdd');
|
||||
$this->viewData['boxTitle'] = lang('Basic.global.addNew') . ' ' . lang('SeriesFacturas.moduleTitle') . ' ' . lang('Basic.global.addNewSuffix');
|
||||
|
||||
return $this->displayForm(__METHOD__);
|
||||
} // end function add()
|
||||
|
||||
public function edit($requestedId = null)
|
||||
{
|
||||
|
||||
if ($requestedId == null) :
|
||||
return $this->redirect2listView();
|
||||
endif;
|
||||
$id = filter_var($requestedId, FILTER_SANITIZE_URL);
|
||||
$seriesFacturasEntity = $this->model->find($id);
|
||||
|
||||
if ($seriesFacturasEntity == false) :
|
||||
$message = lang('Basic.global.notFoundWithIdErr', [mb_strtolower(lang('SeriesFacturas.moduleTitle')), $id]);
|
||||
return $this->redirect2listView('sweet-error', $message);
|
||||
endif;
|
||||
|
||||
if ($this->request->getPost()) :
|
||||
|
||||
$postData = $this->request->getPost();
|
||||
$sanitizedData = $this->sanitized($postData, true);
|
||||
if ($this->request->getPost('show_erp') == null) {
|
||||
$sanitizedData['show_erp'] = false;
|
||||
}
|
||||
|
||||
$noException = true;
|
||||
if ($successfulResult = $this->canValidate()) : // if ($successfulResult = $this->validate($this->formValidationRules) ) :
|
||||
|
||||
if ($this->canValidate()) :
|
||||
try {
|
||||
$successfulResult = $this->model->skipValidation(true)->update($id, $sanitizedData);
|
||||
} catch (\Exception $e) {
|
||||
$noException = false;
|
||||
$this->dealWithException($e);
|
||||
}
|
||||
else:
|
||||
$this->viewData['warningMessage'] = lang('Basic.global.formErr1', [mb_strtolower(lang('SeriesFacturas.moduleTitle'))]);
|
||||
$this->session->setFlashdata('formErrors', $this->model->errors());
|
||||
|
||||
endif;
|
||||
|
||||
$seriesFacturasEntity->fill($sanitizedData);
|
||||
$thenRedirect = false;
|
||||
endif;
|
||||
if ($noException && $successfulResult) :
|
||||
$id = $seriesFacturasEntity->id ?? $id;
|
||||
$message = lang('Basic.global.updateSuccess', [lang('Basic.global.record')]) . '.';
|
||||
|
||||
if ($thenRedirect) :
|
||||
if (!empty($this->indexRoute)) :
|
||||
return redirect()->to(route_to($this->indexRoute))->with('sweet-success', $message);
|
||||
else:
|
||||
return $this->redirect2listView('sweet-success', $message);
|
||||
endif;
|
||||
else:
|
||||
$this->session->setFlashData('sweet-success', $message);
|
||||
endif;
|
||||
|
||||
endif; // $noException && $successfulResult
|
||||
endif; // ($requestMethod === 'post')
|
||||
|
||||
$this->viewData['seriesFacturasEntity'] = $seriesFacturasEntity;
|
||||
$this->viewData['formAction'] = route_to('seriesFacturasEdit', $id);
|
||||
$this->viewData['boxTitle'] = lang('Basic.global.edit2') . ' ' . lang('SeriesFacturas.moduleTitle') . ' ' . lang('Basic.global.edit3');
|
||||
|
||||
return $this->displayForm(__METHOD__, $id);
|
||||
} // end function edit(...)
|
||||
|
||||
|
||||
public function datatable()
|
||||
{
|
||||
if ($this->request->isAJAX()) {
|
||||
$reqData = $this->request->getPost();
|
||||
if (!isset($reqData['draw']) || !isset($reqData['columns'])) {
|
||||
$errstr = 'No data available in response to this specific request.';
|
||||
$response = $this->respond(Collection::datatable([], 0, 0, $errstr), 400, $errstr);
|
||||
return $response;
|
||||
}
|
||||
$start = $reqData['start'] ?? 0;
|
||||
$length = $reqData['length'] ?? 5;
|
||||
$search = $reqData['search']['value'];
|
||||
$requestedOrder = $reqData['order']['0']['column'] ?? 1;
|
||||
$order = SeriesFacturasModel::SORTABLE[$requestedOrder > 0 ? $requestedOrder : 1];
|
||||
$dir = $reqData['order']['0']['dir'] ?? 'asc';
|
||||
|
||||
$resourceData = $this->model->getResource($search)->orderBy($order, $dir)->limit($length, $start)->get()->getResultObject();
|
||||
|
||||
return $this->respond(Collection::datatable(
|
||||
$resourceData,
|
||||
$this->model->getResource()->countAllResults(),
|
||||
$this->model->getResource($search)->countAllResults()
|
||||
));
|
||||
} else {
|
||||
return $this->failUnauthorized('Invalid request', 403);
|
||||
}
|
||||
}
|
||||
|
||||
public function allItemsSelect()
|
||||
{
|
||||
if ($this->request->isAJAX()) {
|
||||
$onlyActiveOnes = true;
|
||||
$reqVal = $this->request->getPost('val') ?? 'id';
|
||||
$menu = $this->model->getAllForMenu($reqVal . ', nombre', 'nombre', $onlyActiveOnes, false);
|
||||
$nonItem = new \stdClass;
|
||||
$nonItem->id = '';
|
||||
$nonItem->nombre = '- ' . lang('Basic.global.None') . ' -';
|
||||
array_unshift($menu, $nonItem);
|
||||
|
||||
$newTokenHash = csrf_hash();
|
||||
$csrfTokenName = csrf_token();
|
||||
$data = [
|
||||
'menu' => $menu,
|
||||
$csrfTokenName => $newTokenHash
|
||||
];
|
||||
return $this->respond($data);
|
||||
} else {
|
||||
return $this->failUnauthorized('Invalid request', 403);
|
||||
}
|
||||
}
|
||||
|
||||
public function menuItems()
|
||||
{
|
||||
if ($this->request->isAJAX()) {
|
||||
$searchStr = goSanitize($this->request->getPost('searchTerm'))[0];
|
||||
$reqId = goSanitize($this->request->getPost('id'))[0];
|
||||
$reqText = goSanitize($this->request->getPost('text'))[0];
|
||||
$onlyActiveOnes = false;
|
||||
$columns2select = [$reqId ?? 'id', $reqText ?? 'nombre'];
|
||||
$onlyActiveOnes = false;
|
||||
$menu = $this->model->getSelect2MenuItems($columns2select, $columns2select[1], $onlyActiveOnes, $searchStr);
|
||||
$nonItem = new \stdClass;
|
||||
|
||||
$newTokenHash = csrf_hash();
|
||||
$csrfTokenName = csrf_token();
|
||||
$data = [
|
||||
'menu' => $menu,
|
||||
$csrfTokenName => $newTokenHash
|
||||
];
|
||||
return $this->respond($data);
|
||||
} else {
|
||||
return $this->failUnauthorized('Invalid request', 403);
|
||||
}
|
||||
}
|
||||
|
||||
public function menuItemsFacturas()
|
||||
{
|
||||
if ($this->request->isAJAX()) {
|
||||
$menu = $this->model->getMenuItemsFacturas();
|
||||
|
||||
$newTokenHash = csrf_hash();
|
||||
$csrfTokenName = csrf_token();
|
||||
$data = [
|
||||
'menu' => $menu,
|
||||
$csrfTokenName => $newTokenHash
|
||||
];
|
||||
return $this->respond($data);
|
||||
} else {
|
||||
return $this->failUnauthorized('Invalid request', 403);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
257
ci4/app/Controllers/Configuracion/Ubicaciones.php
Normal file
257
ci4/app/Controllers/Configuracion/Ubicaciones.php
Normal file
@ -0,0 +1,257 @@
|
||||
<?php namespace App\Controllers\Configuracion;
|
||||
|
||||
use App\Controllers\BaseResourceController;
|
||||
use App\Models\Collection;
|
||||
use App\Entities\Configuracion\UbicacionesEntity;
|
||||
use App\Models\Configuracion\UbicacionesModel;
|
||||
|
||||
class Ubicaciones extends BaseResourceController
|
||||
{
|
||||
|
||||
protected $modelName = UbicacionesModel::class;
|
||||
protected $format = 'json';
|
||||
|
||||
protected static $singularObjectName = 'Ubicaciones';
|
||||
protected static $singularObjectNameCc = 'ubicaciones';
|
||||
protected static $pluralObjectName = 'Ubicaciones';
|
||||
protected static $pluralObjectNameCc = 'ubicaciones';
|
||||
|
||||
protected static $controllerSlug = 'ubicaciones';
|
||||
|
||||
protected static $viewPath = 'themes/vuexy/form/configuracion/ubicaciones/';
|
||||
|
||||
protected $indexRoute = 'ubicacionesList';
|
||||
|
||||
|
||||
public function initController(\CodeIgniter\HTTP\RequestInterface $request, \CodeIgniter\HTTP\ResponseInterface $response, \Psr\Log\LoggerInterface $logger)
|
||||
{
|
||||
$this->viewData['pageTitle'] = lang('Ubicaciones.moduleTitle');
|
||||
$this->viewData['usingSweetAlert'] = true;
|
||||
|
||||
// Breadcrumbs (IMN)
|
||||
$this->viewData['breadcrumb'] = [
|
||||
['title' => lang("App.menu_configuration"), 'route' => "javascript:void(0);", 'active' => false],
|
||||
['title' => lang("App.menu_ubicaciones"), 'route' => route_to('ubicacionesList'), 'active' => true]
|
||||
];
|
||||
|
||||
parent::initController($request, $response, $logger);
|
||||
}
|
||||
|
||||
|
||||
public function index()
|
||||
{
|
||||
|
||||
$viewData = [
|
||||
'currentModule' => static::$controllerSlug,
|
||||
'pageSubTitle' => lang('Basic.global.ManageAllRecords', [lang('Ubicaciones.pais')]),
|
||||
'ubicacionesEntity' => new UbicacionesEntity(),
|
||||
'usingServerSideDataTable' => true,
|
||||
|
||||
];
|
||||
|
||||
$viewData = array_merge($this->viewData, $viewData); // merge any possible values from the parent controller class
|
||||
|
||||
return view(static::$viewPath . 'viewUbicacionesList', $viewData);
|
||||
}
|
||||
|
||||
|
||||
public function add()
|
||||
{
|
||||
if ($this->request->getPost()) :
|
||||
|
||||
$postData = $this->request->getPost();
|
||||
|
||||
$sanitizedData = $this->sanitized($postData, true);
|
||||
|
||||
$noException = true;
|
||||
if ($successfulResult = $this->canValidate()) :
|
||||
|
||||
|
||||
if ($this->canValidate()) :
|
||||
try {
|
||||
$successfulResult = $this->model->skipValidation(true)->save($sanitizedData);
|
||||
} catch (\Exception $e) {
|
||||
$noException = false;
|
||||
$this->dealWithException($e);
|
||||
}
|
||||
else:
|
||||
$this->viewData['errorMessage'] = lang('Basic.global.formErr1', [lang('Basic.global.record')]);
|
||||
$this->session->setFlashdata('formErrors', $this->model->errors());
|
||||
endif;
|
||||
|
||||
$thenRedirect = true; // Change this to false if you want your user to stay on the form after submission
|
||||
endif;
|
||||
if ($noException && $successfulResult) :
|
||||
|
||||
$id = $this->model->db->insertID();
|
||||
|
||||
$message = lang('Basic.global.saveSuccess', [lang('Basic.global.record')]) . '.';
|
||||
|
||||
if ($thenRedirect) :
|
||||
if (!empty($this->indexRoute)) :
|
||||
return redirect()->to(route_to($this->indexRoute))->with('sweet-success', $message);
|
||||
else:
|
||||
return $this->redirect2listView('sweet-success', $message);
|
||||
endif;
|
||||
else:
|
||||
$this->session->setFlashData('sweet-success', $message);
|
||||
endif;
|
||||
|
||||
endif; // $noException && $successfulResult
|
||||
|
||||
endif; // ($requestMethod === 'post')
|
||||
|
||||
$this->viewData['ubicacionesEntity'] = isset($sanitizedData) ? new UbicacionesEntity($sanitizedData) : new UbicacionesEntity();
|
||||
$this->viewData['formAction'] = route_to('ubicacionesAdd');
|
||||
$this->viewData['boxTitle'] = lang('Basic.global.addNew') . ' ' . lang('Ubicaciones.moduleTitle') . ' ' . lang('Basic.global.addNewSuffix');
|
||||
|
||||
|
||||
return $this->displayForm(__METHOD__);
|
||||
} // end function add()
|
||||
|
||||
public function edit($requestedId = null)
|
||||
{
|
||||
|
||||
if ($requestedId == null) :
|
||||
return $this->redirect2listView();
|
||||
endif;
|
||||
$id = filter_var($requestedId, FILTER_SANITIZE_URL);
|
||||
$ubicacionesEntity = $this->model->find($id);
|
||||
|
||||
if ($ubicacionesEntity == false) :
|
||||
$message = lang('Basic.global.notFoundWithIdErr', [mb_strtolower(lang('Ubicaciones.moduleTitle')), $id]);
|
||||
return $this->redirect2listView('sweet-error', $message);
|
||||
endif;
|
||||
|
||||
if ($this->request->getPost()) :
|
||||
|
||||
$postData = $this->request->getPost();
|
||||
|
||||
$sanitizedData = $this->sanitized($postData, true);
|
||||
if ($this->request->getPost('show_erp') == null) {
|
||||
$sanitizedData['show_erp'] = false;
|
||||
}
|
||||
|
||||
$noException = true;
|
||||
if ($successfulResult = $this->canValidate()) : // if ($successfulResult = $this->validate($this->formValidationRules) ) :
|
||||
|
||||
if ($this->canValidate()) :
|
||||
try {
|
||||
$successfulResult = $this->model->skipValidation(true)->update($id, $sanitizedData);
|
||||
} catch (\Exception $e) {
|
||||
$noException = false;
|
||||
$this->dealWithException($e);
|
||||
}
|
||||
else:
|
||||
$this->viewData['warningMessage'] = lang('Basic.global.formErr1', [mb_strtolower(lang('Ubicaciones.moduleTitle'))]);
|
||||
$this->session->setFlashdata('formErrors', $this->model->errors());
|
||||
|
||||
endif;
|
||||
|
||||
$ubicacionesEntity->fill($sanitizedData);
|
||||
$thenRedirect = false;
|
||||
endif;
|
||||
if ($noException && $successfulResult) :
|
||||
$id = $ubicacionesEntity->id ?? $id;
|
||||
$message = lang('Basic.global.updateSuccess', [lang('Basic.global.record')]) . '.';
|
||||
|
||||
if ($thenRedirect) :
|
||||
if (!empty($this->indexRoute)) :
|
||||
return redirect()->to(route_to($this->indexRoute))->with('sweet-success', $message);
|
||||
else:
|
||||
return $this->redirect2listView('sweet-success', $message);
|
||||
endif;
|
||||
else:
|
||||
$this->session->setFlashData('sweet-success', $message);
|
||||
endif;
|
||||
|
||||
endif; // $noException && $successfulResult
|
||||
endif; // ($requestMethod === 'post')
|
||||
|
||||
$this->viewData['ubicacionesEntity'] = $ubicacionesEntity;
|
||||
$this->viewData['formAction'] = route_to('ubicacionesEdit', $id);
|
||||
$this->viewData['boxTitle'] = lang('Basic.global.edit2') . ' ' . lang('Ubicaciones.moduleTitle') . ' ' . lang('Basic.global.edit3');
|
||||
|
||||
return $this->displayForm(__METHOD__, $id);
|
||||
} // end function edit(...)
|
||||
|
||||
|
||||
public function datatable()
|
||||
{
|
||||
if ($this->request->isAJAX()) {
|
||||
$reqData = $this->request->getPost();
|
||||
if (!isset($reqData['draw']) || !isset($reqData['columns'])) {
|
||||
$errstr = 'No data available in response to this specific request.';
|
||||
$response = $this->respond(Collection::datatable([], 0, 0, $errstr), 400, $errstr);
|
||||
return $response;
|
||||
}
|
||||
$start = $reqData['start'] ?? 0;
|
||||
$length = $reqData['length'] ?? 5;
|
||||
$search = $reqData['search']['value'];
|
||||
$requestedOrder = $reqData['order']['0']['column'] ?? 1;
|
||||
$order = UbicacionesModel::SORTABLE[$requestedOrder > 0 ? $requestedOrder : 1];
|
||||
$dir = $reqData['order']['0']['dir'] ?? 'asc';
|
||||
|
||||
$resourceData = $this->model->getResource($search)->orderBy($order, $dir)->limit($length, $start)->get()->getResultObject();
|
||||
|
||||
return $this->respond(Collection::datatable(
|
||||
$resourceData,
|
||||
$this->model->getResource()->countAllResults(),
|
||||
$this->model->getResource($search)->countAllResults()
|
||||
));
|
||||
} else {
|
||||
return $this->failUnauthorized('Invalid request', 403);
|
||||
}
|
||||
}
|
||||
|
||||
public function allItemsSelect()
|
||||
{
|
||||
if ($this->request->isAJAX()) {
|
||||
$onlyActiveOnes = true;
|
||||
$reqVal = $this->request->getPost('val') ?? 'id';
|
||||
$menu = $this->model->getAllForMenu($reqVal . ', nombre', 'nombre', $onlyActiveOnes, false);
|
||||
$nonItem = new \stdClass;
|
||||
$nonItem->id = '';
|
||||
$nonItem->nombre = '- ' . lang('Basic.global.None') . ' -';
|
||||
array_unshift($menu, $nonItem);
|
||||
|
||||
$newTokenHash = csrf_hash();
|
||||
$csrfTokenName = csrf_token();
|
||||
$data = [
|
||||
'menu' => $menu,
|
||||
$csrfTokenName => $newTokenHash
|
||||
];
|
||||
return $this->respond($data);
|
||||
} else {
|
||||
return $this->failUnauthorized('Invalid request', 403);
|
||||
}
|
||||
}
|
||||
|
||||
public function menuItems()
|
||||
{
|
||||
if ($this->request->isAJAX()) {
|
||||
$searchStr = goSanitize($this->request->getPost('searchTerm'))[0];
|
||||
$reqId = goSanitize($this->request->getPost('id'))[0];
|
||||
$reqText = goSanitize($this->request->getPost('text'))[0];
|
||||
$onlyActiveOnes = false;
|
||||
$columns2select = [$reqId ?? 'id', $reqText ?? 'nombre'];
|
||||
$onlyActiveOnes = false;
|
||||
$menu = $this->model->getSelect2MenuItems($columns2select, $columns2select[1], $onlyActiveOnes, $searchStr);
|
||||
$nonItem = new \stdClass;
|
||||
$nonItem->id = '';
|
||||
$nonItem->text = '- ' . lang('Basic.global.None') . ' -';
|
||||
array_unshift($menu, $nonItem);
|
||||
|
||||
$newTokenHash = csrf_hash();
|
||||
$csrfTokenName = csrf_token();
|
||||
$data = [
|
||||
'menu' => $menu,
|
||||
$csrfTokenName => $newTokenHash
|
||||
];
|
||||
return $this->respond($data);
|
||||
} else {
|
||||
return $this->failUnauthorized('Invalid request', 403);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@ -1,4 +1,4 @@
|
||||
<?php namespace App\Controllers\Configuracion;
|
||||
<?php namespace App\Controllers\Configuracion;
|
||||
|
||||
|
||||
use App\Entities\Usuarios\UserEntity;
|
||||
@ -8,15 +8,17 @@ use App\Models\Usuarios\GroupModel;
|
||||
use App\Models\UserModel;
|
||||
use App\Models\Usuarios\GroupsUsersModel;
|
||||
use CodeIgniter\Shield\Entities\User;
|
||||
use function PHPUnit\Framework\isNull;
|
||||
|
||||
class Users extends \App\Controllers\GoBaseController {
|
||||
class Users extends \App\Controllers\GoBaseController
|
||||
{
|
||||
|
||||
private $group_model;
|
||||
private $group_user_model;
|
||||
private $user_model;
|
||||
|
||||
|
||||
use \CodeIgniter\API\ResponseTrait;
|
||||
use \CodeIgniter\API\ResponseTrait;
|
||||
|
||||
protected static $primaryModelName = 'App\Models\UserModel';
|
||||
|
||||
@ -29,9 +31,9 @@ class Users extends \App\Controllers\GoBaseController {
|
||||
|
||||
protected $indexRoute = 'userList';
|
||||
|
||||
|
||||
|
||||
public function initController(\CodeIgniter\HTTP\RequestInterface $request, \CodeIgniter\HTTP\ResponseInterface $response, \Psr\Log\LoggerInterface $logger) {
|
||||
public function initController(\CodeIgniter\HTTP\RequestInterface $request, \CodeIgniter\HTTP\ResponseInterface $response, \Psr\Log\LoggerInterface $logger)
|
||||
{
|
||||
|
||||
$this->group_model = new GroupModel();
|
||||
$this->group_user_model = new GroupsUsersModel();
|
||||
@ -46,71 +48,88 @@ class Users extends \App\Controllers\GoBaseController {
|
||||
];
|
||||
|
||||
parent::initController($request, $response, $logger);
|
||||
|
||||
|
||||
}
|
||||
|
||||
public function index() {
|
||||
|
||||
public function index()
|
||||
{
|
||||
$this->viewData['usingClientSideDataTable'] = true;
|
||||
$this->viewData['pageSubTitle'] = lang('Basic.global.ManageAllRecords', [lang('Users.user')]);
|
||||
$this->viewData['pageSubTitle'] = lang('Basic.global.ManageAllRecords', [lang('Users.user')]);
|
||||
$this->viewData['user_model'] = $this->user_model;
|
||||
$this->viewData['userList2'] = auth()->getProvider()->findAll();
|
||||
|
||||
parent::index();
|
||||
|
||||
}
|
||||
|
||||
public function add() {
|
||||
public function add()
|
||||
{
|
||||
|
||||
if ($this->request->getPost()) :
|
||||
|
||||
$postData = $this->request->getPost();
|
||||
|
||||
$currentGroups = $postData['group']??[];
|
||||
// Obtener contraseña nueva si se ha introducido en texto plano
|
||||
if (empty($postData['new_pwd'])) {
|
||||
$postData['password'] = 'Safekat2024'; // Contraseña por defecto
|
||||
}else{
|
||||
$postData['password'] = $postData['new_pwd'];
|
||||
}
|
||||
// Obtener los grupos a los que pertenece
|
||||
$currentGroups = $postData['group'] ?? [];
|
||||
unset($postData['group']);
|
||||
|
||||
$sanitizedData = $this->sanitized($postData, true);
|
||||
// Generar el nombre de usuario
|
||||
$postData['username'] = strstr($postData['email'], '@', true);
|
||||
$sanitizedData = $this->sanitized($postData, true);
|
||||
|
||||
$noException = true;
|
||||
|
||||
// Obtener proveedor de usuarios
|
||||
$users = auth()->getProvider();
|
||||
|
||||
if ($successfulResult = $this->canValidate()) : // if ($successfulResult = $this->validate($this->formValidationRules) ) :
|
||||
|
||||
if ($this->canValidate()) :
|
||||
try {
|
||||
if ($successfulResult = $this->canValidate()) :
|
||||
if ($this->canValidate()) :
|
||||
try {
|
||||
|
||||
$user = new User([
|
||||
'username' => strstr($sanitizedData['email'], '@', true),
|
||||
'email' => $sanitizedData['email'],
|
||||
'password' => 'Safekat2024',
|
||||
'username' => $sanitizedData['username'],
|
||||
'first_name' => $sanitizedData['first_name'],
|
||||
'last_name' => $sanitizedData['last_name'],
|
||||
'email' => $sanitizedData['email'],
|
||||
'password' => $sanitizedData['password'],
|
||||
'status' => $sanitizedData['status'] ?? 0,
|
||||
'active' => $sanitizedData['active'] ?? 0,
|
||||
]);
|
||||
$users->save($user);
|
||||
$successfulResult = true; // Hacked
|
||||
} catch (\Exception $e) {
|
||||
$noException = false;
|
||||
$this->dealWithException($e);
|
||||
}
|
||||
else:
|
||||
$this->viewData['errorMessage'] = lang('Basic.global.formErr1', [mb_strtolower(lang('Users.user'))]);
|
||||
$successfulResult = true; // Hacked
|
||||
} catch (\Exception $e) {
|
||||
$noException = false;
|
||||
//$this->dealWithException($e);
|
||||
if (strpos($e->getMessage(), 'correo duplicado') !== false) {
|
||||
$this->viewData['errorMessage'] = "El correo electrónico ya está registrado en el sistema";
|
||||
$this->session->setFlashdata('formErrors', $this->model->errors());
|
||||
}
|
||||
|
||||
}
|
||||
else:
|
||||
$this->viewData['errorMessage'] = lang('Basic.global.formErr1', [mb_strtolower(lang('Users.user'))]);
|
||||
$this->session->setFlashdata('formErrors', $this->model->errors());
|
||||
endif;
|
||||
|
||||
$thenRedirect = true; // Change this to false if you want your user to stay on the form after submission
|
||||
endif;
|
||||
|
||||
$thenRedirect = true; // Change this to false if you want your user to stay on the form after submission
|
||||
endif;
|
||||
if ($noException && $successfulResult) :
|
||||
|
||||
$id = $users->getInsertID();
|
||||
$this->group_user_model->where('user_id', $user->id)->delete();
|
||||
foreach($currentGroups as $group){
|
||||
$this->group_user_model->where('user_id', $id)->delete();
|
||||
foreach ($currentGroups as $group) {
|
||||
$group_user_data = [
|
||||
'user_id' => $user->id,
|
||||
'user_id' => $id,
|
||||
'group' => $group
|
||||
];
|
||||
$this->group_user_model->insert($group_user_data);
|
||||
}
|
||||
|
||||
$message = lang('Basic.global.saveSuccess', [mb_strtolower(lang('Users.user'))]) . 'Downloads';
|
||||
$message .= anchor(route_to('editUser', $id), lang('Basic.global.continueEditing').'?');
|
||||
$message = lang('Basic.global.saveSuccess', [mb_strtolower(lang('Users.user'))]) . '.';
|
||||
$message = ucfirst(str_replace("'", "\'", $message));
|
||||
|
||||
if ($thenRedirect) :
|
||||
@ -128,75 +147,95 @@ class Users extends \App\Controllers\GoBaseController {
|
||||
endif; // ($requestMethod === 'post')
|
||||
|
||||
$this->viewData['user'] = isset($sanitizedData) ? new UserEntity($sanitizedData) : new UserEntity();
|
||||
$this->viewData['clienteList'] = $this->getClienteListItems();
|
||||
$this->viewData['formAction'] = route_to('createUser');
|
||||
$this->viewData['groups'] = $this->group_model->select('keyword, title')->findAll();
|
||||
$this->viewData['boxTitle'] = lang('Basic.global.addNew') .lang('Users.user').' '.lang('Basic.global.addNewSuffix');
|
||||
|
||||
$this->viewData['boxTitle'] = lang('Basic.global.addNew') . ' ' . lang('Users.user') . ' ' . lang('Basic.global.addNewSuffix');
|
||||
|
||||
|
||||
return $this->displayForm(__METHOD__);
|
||||
} // end function add()
|
||||
|
||||
public function edit($requestedId = null) {
|
||||
|
||||
if ($requestedId == null) :
|
||||
public function edit($requestedId = null)
|
||||
{
|
||||
if ($requestedId == null) {
|
||||
return $this->redirect2listView();
|
||||
endif;
|
||||
}
|
||||
|
||||
$id = filter_var($requestedId, FILTER_SANITIZE_URL);
|
||||
$user = $this->model->find($id);
|
||||
$users = auth()->getProvider();
|
||||
$user = $users->findById($id);
|
||||
|
||||
if ($user == false) :
|
||||
$message = lang('Basic.global.notFoundWithIdErr', [mb_strtolower(lang('Users.user')), $id]);
|
||||
return $this->redirect2listView('errorMessage', $message);
|
||||
endif;
|
||||
|
||||
|
||||
if ($this->request->getPost()) :
|
||||
|
||||
$postData = $this->request->getPost();
|
||||
|
||||
$currentGroups = $postData['group'];
|
||||
$currentGroups = $postData['group'] ?? [];
|
||||
unset($postData['group']);
|
||||
|
||||
// Obtener contraseña nueva si se ha introducido en texto plano
|
||||
// Obtener contraseña nueva si se ha introducido en texto plano
|
||||
if (!empty($postData['new_pwd'])) {
|
||||
$postData['password'] = $postData['new_pwd'];
|
||||
}
|
||||
|
||||
$sanitizedData = $this->sanitized($postData, true);
|
||||
|
||||
if ($this->request->getPost('status') == 0 ) {
|
||||
if ($this->request->getPost('status') == 0) {
|
||||
$sanitizedData['status'] = null;
|
||||
}
|
||||
|
||||
$noException = true;
|
||||
if ($successfulResult = $this->canValidate()) : // if ($successfulResult = $this->validate($this->formValidationRules) ) :
|
||||
if ($successfulResult = $this->canValidate()) :
|
||||
|
||||
if ($this->canValidate()) :
|
||||
try {
|
||||
$successfulResult = $this->model->skipValidation(true)->update($id, $sanitizedData);
|
||||
} catch (\Exception $e) {
|
||||
$noException = false;
|
||||
$this->dealWithException($e);
|
||||
}
|
||||
else:
|
||||
$this->viewData['warningMessage'] = lang('Basic.global.formErr1', [mb_strtolower(lang('Users.user'))]);
|
||||
$this->session->setFlashdata('formErrors', $this->model->errors());
|
||||
|
||||
endif;
|
||||
if ($this->canValidate()) :
|
||||
try {
|
||||
|
||||
$user->fill($sanitizedData);
|
||||
$thenRedirect = false;
|
||||
if (in_array('cliente-editor', $currentGroups) || in_array('cliente-administrador', $currentGroups)) {
|
||||
if (!array_key_exists('cliente_id', $sanitizedData) || is_null($sanitizedData['cliente_id'])) {
|
||||
$this->viewData['errorMessage'] = lang('Users.errors.cliente_sin_clienteID');
|
||||
$this->session->setFlashdata('formErrors', $this->model->errors());
|
||||
$successfulResult = false;
|
||||
} else {
|
||||
$successfulResult = $this->model->skipValidation(true)->update($id, $sanitizedData);
|
||||
}
|
||||
} else {
|
||||
$successfulResult = $this->model->skipValidation(true)->update($id, $sanitizedData);
|
||||
}
|
||||
|
||||
} catch (\Exception $e) {
|
||||
$noException = false;
|
||||
$this->dealWithException($e);
|
||||
}
|
||||
else:
|
||||
$this->viewData['warningMessage'] = lang('Basic.global.formErr1', [mb_strtolower(lang('Users.user'))]);
|
||||
$this->session->setFlashdata('formErrors', $this->model->errors());
|
||||
|
||||
endif;
|
||||
|
||||
$user->fill($sanitizedData);
|
||||
$users->save($user);
|
||||
$thenRedirect = false;
|
||||
|
||||
endif;
|
||||
if ($noException && $successfulResult) :
|
||||
|
||||
$this->group_user_model->where('user_id', $user->id)->delete();
|
||||
foreach($currentGroups as $group){
|
||||
foreach ($currentGroups as $group) {
|
||||
$group_user_data = [
|
||||
'user_id' => $user->id,
|
||||
'group' => $group
|
||||
];
|
||||
$this->group_user_model->insert($group_user_data);
|
||||
}
|
||||
|
||||
|
||||
$id = $user->id ?? $id;
|
||||
$message = lang('Basic.global.updateSuccess', [mb_strtolower(lang('Users.user'))]) . 'Downloads';
|
||||
$message .= anchor(route_to('editUser', $id), lang('Basic.global.continueEditing').'?');
|
||||
$message = lang('Basic.global.updateSuccess', [mb_strtolower(lang('Users.user'))]) . '.';
|
||||
$message = ucfirst(str_replace("'", "\'", $message));
|
||||
|
||||
if ($thenRedirect) :
|
||||
@ -208,21 +247,23 @@ class Users extends \App\Controllers\GoBaseController {
|
||||
else:
|
||||
$this->session->setFlashData('sweet-success', $message);
|
||||
endif;
|
||||
|
||||
|
||||
endif; // $noException && $successfulResult
|
||||
endif; // ($requestMethod === 'post')
|
||||
|
||||
$this->viewData['user'] = $user;
|
||||
$this->viewData['clienteList'] = $this->getClienteListItems($user->cliente_id);
|
||||
$this->viewData['formAction'] = route_to('updateUser', $id);
|
||||
$this->viewData['selectedGroups'] = $this->group_model->getUsersRoles($requestedId);
|
||||
$this->viewData['groups'] = $this->group_model->select('keyword, title')->findAll();
|
||||
$this->viewData['boxTitle'] = lang('Basic.global.edit2') .lang('Users.user').' '.lang('Basic.global.edit3');
|
||||
$this->viewData['boxTitle'] = lang('Basic.global.edit2') . ' ' . lang('Users.user') . ' ' . lang('Basic.global.edit3');
|
||||
|
||||
return $this->displayForm(__METHOD__, $id);
|
||||
} // end function edit(...)
|
||||
|
||||
|
||||
public function delete($requestedId = null, bool $deletePermanently = true) {
|
||||
public function delete($requestedId = null, bool $deletePermanently = true)
|
||||
{
|
||||
|
||||
if ($requestedId == null) :
|
||||
return $this->redirect2listView();
|
||||
@ -237,26 +278,25 @@ class Users extends \App\Controllers\GoBaseController {
|
||||
endif;
|
||||
|
||||
$users = auth()->getProvider();
|
||||
$users->delete($user->id, $deletePermanently);
|
||||
$users->delete($user->id);
|
||||
|
||||
$message = "Usuario eliminado correctamente";
|
||||
return $this->redirect2listView('successMessage', $message);
|
||||
|
||||
|
||||
|
||||
} // end function delete(...)
|
||||
|
||||
|
||||
|
||||
public function allItemsSelect() {
|
||||
|
||||
public function allItemsSelect()
|
||||
{
|
||||
if ($this->request->isAJAX()) {
|
||||
$onlyActiveOnes = true;
|
||||
$reqVal = $this->request->getPost('val') ?? 'id_user';
|
||||
$menu = $this->model->getAllForMenu($reqVal.', first_name', 'first_name', $onlyActiveOnes, false);
|
||||
$menu = $this->model->getAllForMenu($reqVal . ', first_name', 'first_name', $onlyActiveOnes, false);
|
||||
$nonItem = new \stdClass;
|
||||
$nonItem->id_user = '';
|
||||
$nonItem->first_name = '- '.lang('Basic.global.None').' -';
|
||||
array_unshift($menu , $nonItem);
|
||||
$nonItem->first_name = '- ' . lang('Basic.global.None') . ' -';
|
||||
array_unshift($menu, $nonItem);
|
||||
|
||||
$newTokenHash = csrf_hash();
|
||||
$csrfTokenName = csrf_token();
|
||||
@ -269,8 +309,9 @@ class Users extends \App\Controllers\GoBaseController {
|
||||
return $this->failUnauthorized('Invalid request', 403);
|
||||
}
|
||||
}
|
||||
|
||||
public function menuItems() {
|
||||
|
||||
public function menuItems()
|
||||
{
|
||||
if ($this->request->isAJAX()) {
|
||||
$searchStr = goSanitize($this->request->getPost('searchTerm'))[0];
|
||||
$reqId = goSanitize($this->request->getPost('id'))[0];
|
||||
@ -281,8 +322,8 @@ class Users extends \App\Controllers\GoBaseController {
|
||||
$menu = $this->model->getSelect2MenuItems($columns2select, $columns2select[1], $onlyActiveOnes, $searchStr);
|
||||
$nonItem = new \stdClass;
|
||||
$nonItem->id = '';
|
||||
$nonItem->text = '- '.lang('Basic.global.None').' -';
|
||||
array_unshift($menu , $nonItem);
|
||||
$nonItem->text = '- ' . lang('Basic.global.None') . ' -';
|
||||
array_unshift($menu, $nonItem);
|
||||
|
||||
$newTokenHash = csrf_hash();
|
||||
$csrfTokenName = csrf_token();
|
||||
@ -296,14 +337,46 @@ class Users extends \App\Controllers\GoBaseController {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
protected function getPaisListItems() {
|
||||
$data = [''=>lang('Basic.global.pleaseSelectA', [mb_strtolower(lang('Pais.pais'))])];
|
||||
public function getMenuComerciales()
|
||||
{
|
||||
if ($this->request->isAJAX()) {
|
||||
$comerciales = $this->model->getComerciales();
|
||||
|
||||
$newTokenHash = csrf_hash();
|
||||
$csrfTokenName = csrf_token();
|
||||
$data = [
|
||||
'menu' => $comerciales,
|
||||
$csrfTokenName => $newTokenHash
|
||||
];
|
||||
return $this->respond($data);
|
||||
} else {
|
||||
return $this->failUnauthorized('Invalid request', 403);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
protected function getPaisListItems()
|
||||
{
|
||||
$data = ['' => lang('Basic.global.pleaseSelectA', [mb_strtolower(lang('Pais.pais'))])];
|
||||
$paisModel = model('App\Models\Configuracion\PaisModel');
|
||||
|
||||
$registers = $paisModel->findAll();
|
||||
|
||||
return $registers;
|
||||
}
|
||||
|
||||
return $registers;
|
||||
}
|
||||
|
||||
protected function getClienteListItems($selId = null)
|
||||
{
|
||||
$data = ['' => ""];
|
||||
if (!empty($selId)) :
|
||||
$clienteModel = model('App\Models\Clientes\ClienteModel');
|
||||
|
||||
$selOption = $clienteModel->where('id', $selId)->findColumn('nombre');
|
||||
if (!empty($selOption)) :
|
||||
$data[$selId] = $selOption[0];
|
||||
endif;
|
||||
endif;
|
||||
return $data;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
82
ci4/app/Controllers/Excel/PrintGiros.php
Normal file
82
ci4/app/Controllers/Excel/PrintGiros.php
Normal file
@ -0,0 +1,82 @@
|
||||
<?php
|
||||
|
||||
namespace App\Controllers\Excel;
|
||||
|
||||
use App\Controllers\BaseController;
|
||||
use PhpOffice\PhpSpreadsheet\Spreadsheet;
|
||||
use PhpOffice\PhpSpreadsheet\Writer\Xlsx;
|
||||
|
||||
|
||||
class PrintGiros extends BaseController
|
||||
{
|
||||
public function generateExcel($factura_id = null)
|
||||
{
|
||||
// AQUI CREAR LAS CONSULTAS A LA BBDD, QUIZAS HAYA QUE CREARLO O COMO POST O COMO QUERY AJAX
|
||||
|
||||
// Crear un nuevo Spreadsheet
|
||||
$spreadsheet = new Spreadsheet();
|
||||
$sheet = $spreadsheet->getActiveSheet();
|
||||
|
||||
// Especificar encabezados
|
||||
$headers = [
|
||||
'BIC (SWIFT)*',
|
||||
'FECHA FIRMA MANDATO*',
|
||||
'IBAN*',
|
||||
'IMPORTE*',
|
||||
'NOMBRE*',
|
||||
'PAIS*',
|
||||
'REFERENCIA DEL ADEUDO (REFADEUDO)*',
|
||||
'REFERENCIA*',
|
||||
'REFERENCIA DEL MANDATO (REMANDATO)*',
|
||||
'RESIDENTE*',
|
||||
'TIPO DE ADEUDO*',
|
||||
'FECHA DE COBRO*',
|
||||
'DIAS*'
|
||||
];
|
||||
|
||||
// Establecer los encabezados en la primera fila
|
||||
$column = 'A';
|
||||
foreach ($headers as $header) {
|
||||
$sheet->setCellValue($column . '1', $header);
|
||||
$column++;
|
||||
}
|
||||
|
||||
// Generar datos dummy
|
||||
$dummyData = [
|
||||
['ABCDEF12', '2024-01-01', 'ES1234567890123456789012', 100.50, 'John Doe', 'Spain', 'REF001', '12345', 'MAND001', 'Yes', 'Type1', '2024-02-01', 30],
|
||||
['GHIJKL34', '2024-02-01', 'ES9876543210987654321098', 200.75, 'Jane Smith', 'France', 'REF002', '67890', 'MAND002', 'No', 'Type2', '2024-03-01', 60],
|
||||
// Añade más datos dummy según sea necesario
|
||||
];
|
||||
|
||||
// Rellenar las filas con datos dummy
|
||||
$rowNumber = 2; // Empezar en la segunda fila
|
||||
foreach ($dummyData as $row) {
|
||||
$column = 'A';
|
||||
foreach ($row as $cell) {
|
||||
$sheet->setCellValue($column . $rowNumber, $cell);
|
||||
$column++;
|
||||
}
|
||||
$rowNumber++;
|
||||
}
|
||||
|
||||
// Ajustar automáticamente el tamaño de las columnas
|
||||
foreach (range('A', $column) as $col) {
|
||||
$sheet->getColumnDimension($col)->setAutoSize(true);
|
||||
}
|
||||
|
||||
// Crear un escritor para guardar el archivo
|
||||
$writer = new Xlsx($spreadsheet);
|
||||
|
||||
// Configurar la respuesta para descarga
|
||||
$fileName = 'giros_reporte.xlsx';
|
||||
header('Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet');
|
||||
header('Content-Disposition: attachment;filename="' . $fileName . '"');
|
||||
header('Cache-Control: max-age=0');
|
||||
|
||||
// Escribir el archivo a la salida
|
||||
$writer->save('php://output');
|
||||
exit;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
70
ci4/app/Controllers/Excel/PrintLineas.php
Normal file
70
ci4/app/Controllers/Excel/PrintLineas.php
Normal file
@ -0,0 +1,70 @@
|
||||
<?php
|
||||
|
||||
namespace App\Controllers\Excel;
|
||||
|
||||
use App\Controllers\BaseController;
|
||||
use PhpOffice\PhpSpreadsheet\Spreadsheet;
|
||||
use PhpOffice\PhpSpreadsheet\Writer\Xlsx;
|
||||
|
||||
|
||||
class PrintLineas extends BaseController
|
||||
{
|
||||
public function generateExcel($factura_id = null)
|
||||
{
|
||||
|
||||
// Modelos
|
||||
$lineasFacturaModel = model('App\Models\Facturas\FacturaLineaModel');
|
||||
$infoLineasFactura = $lineasFacturaModel->getResourceForExcel($factura_id)->get()->getResultObject();
|
||||
|
||||
|
||||
// Crear un nuevo Spreadsheet
|
||||
$spreadsheet = new Spreadsheet();
|
||||
$sheet = $spreadsheet->getActiveSheet();
|
||||
|
||||
// Especificar encabezados
|
||||
$headers = [
|
||||
'Factura',
|
||||
'ID Pedido',
|
||||
'Ref. Cliente',
|
||||
'Base'
|
||||
];
|
||||
|
||||
// Establecer los encabezados en la primera fila
|
||||
$column = 'A';
|
||||
foreach ($headers as $header) {
|
||||
$sheet->setCellValue($column . '1', $header);
|
||||
$column++;
|
||||
}
|
||||
|
||||
// Rellenar las filas con datos
|
||||
$rowNumber = 2; // Empezar en la segunda fila
|
||||
foreach ($infoLineasFactura as $infoLineaFactura) {
|
||||
$column = 'A';
|
||||
foreach ($infoLineaFactura as $cell) {
|
||||
$sheet->setCellValue($column . $rowNumber, $cell);
|
||||
$column++;
|
||||
}
|
||||
$rowNumber++;
|
||||
}
|
||||
|
||||
// Ajustar automáticamente el tamaño de las columnas
|
||||
foreach (range('A', $column) as $col) {
|
||||
$sheet->getColumnDimension($col)->setAutoSize(true);
|
||||
}
|
||||
|
||||
// Crear un escritor para guardar el archivo
|
||||
$writer = new Xlsx($spreadsheet);
|
||||
|
||||
// Configurar la respuesta para descarga
|
||||
$fileName = 'lineas-pedido.xlsx';
|
||||
header('Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet');
|
||||
header('Content-Disposition: attachment;filename="' . $fileName . '"');
|
||||
header('Cache-Control: max-age=0');
|
||||
|
||||
// Escribir el archivo a la salida
|
||||
$writer->save('php://output');
|
||||
exit;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@ -1,30 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Controllers\Facturacion;
|
||||
use App\Controllers\BaseController;
|
||||
|
||||
|
||||
class Albaran extends BaseController
|
||||
{
|
||||
function __construct()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public function index()
|
||||
{
|
||||
echo 'Albaran';
|
||||
}
|
||||
|
||||
public function delete()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public function export()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -1,41 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Controllers\Facturacion;
|
||||
use App\Controllers\BaseController;
|
||||
|
||||
|
||||
class Factura extends BaseController
|
||||
{
|
||||
function __construct()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public function index()
|
||||
{
|
||||
echo 'Facturas';
|
||||
}
|
||||
|
||||
public function nueva()
|
||||
{
|
||||
echo 'Nueva Factura';
|
||||
}
|
||||
|
||||
public function vencimiento()
|
||||
{
|
||||
echo 'Vencimiento Factura';
|
||||
}
|
||||
|
||||
|
||||
public function delete()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public function export()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
692
ci4/app/Controllers/Facturacion/Facturas.php
Executable file
692
ci4/app/Controllers/Facturacion/Facturas.php
Executable file
@ -0,0 +1,692 @@
|
||||
<?php
|
||||
|
||||
namespace App\Controllers\Facturacion;
|
||||
|
||||
use App\Models\Facturas\FacturaModel;
|
||||
use App\Entities\Facturas\FacturaEntity;
|
||||
use App\Models\Clientes\ClienteModel;
|
||||
use App\Models\Collection;
|
||||
|
||||
|
||||
class Facturas extends \App\Controllers\BaseResourceController
|
||||
{
|
||||
protected $modelName = FacturaModel::class;
|
||||
protected $format = 'json';
|
||||
|
||||
protected static $singularObjectNameCc = 'factura';
|
||||
protected static $singularObjectName = 'Factura';
|
||||
protected static $pluralObjectName = 'Facturas';
|
||||
protected static $controllerSlug = 'factura';
|
||||
|
||||
protected static $viewPath = 'themes/vuexy/form/facturas/';
|
||||
|
||||
protected $indexRoute = 'facturaList';
|
||||
|
||||
public function initController(\CodeIgniter\HTTP\RequestInterface $request, \CodeIgniter\HTTP\ResponseInterface $response, \Psr\Log\LoggerInterface $logger)
|
||||
{
|
||||
$this->viewData['pageTitle'] = lang('Facturas.facturas');
|
||||
// Se indica que este controlador trabaja con soft_delete
|
||||
|
||||
$this->viewData = ['usingServerSideDataTable' => true];
|
||||
|
||||
// Breadcrumbs
|
||||
$this->viewData['breadcrumb'] = [
|
||||
['title' => lang("App.menu_facturas"), 'route' => "javascript:void(0);", 'active' => false],
|
||||
];
|
||||
|
||||
parent::initController($request, $response, $logger);
|
||||
|
||||
}
|
||||
|
||||
public function index()
|
||||
{
|
||||
|
||||
$this->viewData['usingClientSideDataTable'] = true;
|
||||
|
||||
$this->viewData['pageSubTitle'] = lang('Basic.global.ManageAllRecords', [lang('Tarifaextra.tarifaextra')]);
|
||||
parent::index();
|
||||
}
|
||||
|
||||
|
||||
public function list()
|
||||
{
|
||||
|
||||
$viewData = [
|
||||
'currentModule' => static::$controllerSlug,
|
||||
'pageSubTitle' => lang('Basic.global.ManageAllRecords', [lang('Facturas.facturas')]),
|
||||
'usingServerSideDataTable' => true,
|
||||
'pageTitle' => lang('Facturas.facturas'),
|
||||
['title' => lang("App.menu_facturas"), 'route' => site_url('facturas/list'), 'active' => true]
|
||||
];
|
||||
|
||||
$viewData['breadcrumb'] = [
|
||||
['title' => lang("App.menu_facturas"), 'route' => "javascript:void(0);", 'active' => false],
|
||||
['title' => lang("Facturas.facturaList"), 'route' => "javascript:void(0);", 'active' => true]
|
||||
];
|
||||
|
||||
return view(static::$viewPath . 'viewFacturasList', $viewData);
|
||||
}
|
||||
|
||||
|
||||
public function add()
|
||||
{
|
||||
if ($this->request->getPost()) :
|
||||
|
||||
$nullIfEmpty = true; // !(phpversion() >= '8.1');
|
||||
|
||||
$postData = $this->request->getPost();
|
||||
|
||||
$noException = true;
|
||||
$allData = true;
|
||||
|
||||
if( !isset($postData['cliente_id']) || !isset($postData['serie_id']) ) {
|
||||
|
||||
$this->viewData['errorMessage'] = lang('Facturas.errors.requiredFields');
|
||||
$this->session->setFlashdata('formErrors', $this->model->errors());
|
||||
|
||||
$allData = false;
|
||||
$noException = false;
|
||||
}
|
||||
|
||||
try {
|
||||
$clienteModel = model('App\Models\Clientes\ClienteModel');
|
||||
$datosCliente = $clienteModel->getClienteDataFacturas($postData['cliente_id']);
|
||||
if(count($datosCliente)>0){
|
||||
// add array data datosCliente to postData
|
||||
$postData = array_merge($postData, $datosCliente[0]);
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
$noException = false;
|
||||
$this->dealWithException($e);
|
||||
}
|
||||
|
||||
|
||||
$sanitizedData = $this->sanitized($postData, $nullIfEmpty);
|
||||
|
||||
$sanitizedData['user_updated_id'] = auth()->user()->id;
|
||||
$sanitizedData['user_created_id'] = auth()->user()->id;
|
||||
|
||||
if ($allData && $successfulResult = $this->canValidate()) : // if ($successfulResult = $this->validate($this->formValidationRules) ) :
|
||||
|
||||
|
||||
if ($this->canValidate()) :
|
||||
try {
|
||||
$successfulResult = $this->model->skipValidation(true)->save($sanitizedData);
|
||||
} catch (\Exception $e) {
|
||||
$noException = false;
|
||||
$this->dealWithException($e);
|
||||
}
|
||||
else:
|
||||
$this->viewData['errorMessage'] = lang('Basic.global.formErr1', [lang('Basic.global.record')]);
|
||||
$this->session->setFlashdata('formErrors', $this->model->errors());
|
||||
endif;
|
||||
|
||||
endif;
|
||||
if ($noException && $successfulResult) :
|
||||
|
||||
$id = $this->model->db->insertID();
|
||||
|
||||
$message = lang('Basic.global.saveSuccess', [lang('Basic.global.record')]) . '.';
|
||||
|
||||
return redirect()->to(route_to('editarFactura', $id))->with('sweet-success', $message);
|
||||
|
||||
|
||||
endif; // $noException && $successfulResult
|
||||
|
||||
endif; // ($requestMethod === 'post')
|
||||
|
||||
$this->viewData['factura'] = isset($sanitizedData) ? new FacturaEntity($sanitizedData) : new FacturaEntity();
|
||||
|
||||
$this->viewData['formAction'] = route_to('createFactura');
|
||||
|
||||
$this->viewData['boxTitle'] = lang('Basic.global.addNew') . ' ' . lang('Facturas.facturas') . ' ' . lang('Basic.global.addNewSuffix');
|
||||
|
||||
|
||||
helper('form');
|
||||
|
||||
$this->viewData['breadcrumb'] = [
|
||||
['title' => lang("App.menu_facturas"), 'route' => "javascript:void(0);", 'active' => false],
|
||||
['title' => lang("Facturas.facturaList"), 'route' => route_to('facturasList'), 'active' => true]
|
||||
];
|
||||
|
||||
$this->viewData['usingSelect2'] = true;
|
||||
|
||||
$validation = \Config\Services::validation();
|
||||
|
||||
$this->viewData['validation'] = $validation;
|
||||
|
||||
$viewFilePath = static::$viewPath . 'viewAddFactura';
|
||||
|
||||
return view($viewFilePath, $this->viewData);
|
||||
} // end function add()
|
||||
|
||||
|
||||
public function edit($id=null){
|
||||
|
||||
if ($id == null) :
|
||||
return $this->redirect2listView();
|
||||
endif;
|
||||
$id = filter_var($id, FILTER_SANITIZE_URL);
|
||||
$factura = $this->model->find($id);
|
||||
|
||||
if ($factura == false) :
|
||||
$message = lang('Basic.global.notFoundWithIdErr', [mb_strtolower(lang('Facturas.factura')), $id]);
|
||||
return $this->redirect2listView('sweet-error', $message);
|
||||
endif;
|
||||
|
||||
|
||||
$this->obtenerDatosFormulario($factura);
|
||||
|
||||
$this->viewData['breadcrumb'] = [
|
||||
['title' => lang("App.menu_facturas"), 'route' => "javascript:void(0);", 'active' => false],
|
||||
['title' => lang("Facturas.facturaList"), 'route' => route_to('facturasList'), 'active' => true]
|
||||
];
|
||||
|
||||
$this->viewData['facturaEntity'] = $factura;
|
||||
|
||||
$this->viewData['boxTitle'] = lang('Basic.global.edit2') . ' ' . lang('Facturas.factura') . ' ' . lang('Basic.global.edit3');
|
||||
|
||||
return $this->displayForm(__METHOD__, $id);
|
||||
}
|
||||
|
||||
public function datatable(){
|
||||
|
||||
if ($this->request->isAJAX()) {
|
||||
|
||||
$reqData = $this->request->getPost();
|
||||
if (!isset($reqData['draw']) || !isset($reqData['columns']) ) {
|
||||
$errstr = 'No data available in response to this specific request.';
|
||||
$response = $this->respond(Collection::datatable( [], 0, 0, $errstr ), 400, $errstr);
|
||||
return $response;
|
||||
}
|
||||
$start = $reqData['start'] ?? 0;
|
||||
$length = $reqData['length'] ?? 5;
|
||||
$search = $reqData['search']['value'];
|
||||
$requestedOrder = $reqData['order']['0']['column'] ?? 0;
|
||||
$order = FacturaModel::SORTABLE[$requestedOrder >= 0 ? $requestedOrder : 0];
|
||||
$dir = $reqData['order']['0']['dir'] ?? 'asc';
|
||||
|
||||
$resourceData = $this->model->getResource($search)->orderBy($order, $dir)->limit($length, $start)->get()->getResultObject();
|
||||
|
||||
return $this->respond(Collection::datatable(
|
||||
$resourceData,
|
||||
$this->model->getResource("")->countAllResults(),
|
||||
$this->model->getResource($search)->countAllResults()
|
||||
));
|
||||
} else {
|
||||
return $this->failUnauthorized('Invalid request', 403);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public function datatablePedidos(){
|
||||
|
||||
if ($this->request->isAJAX()) {
|
||||
|
||||
$reqData = $this->request->getPost();
|
||||
if (!isset($reqData['draw']) || !isset($reqData['columns']) ) {
|
||||
$errstr = 'No data available in response to this specific request.';
|
||||
$response = $this->respond(Collection::datatable( [], 0, 0, $errstr ), 400, $errstr);
|
||||
return $response;
|
||||
}
|
||||
$start = $reqData['start'] ?? 0;
|
||||
$length = $reqData['length'] ?? 5;
|
||||
$search = $reqData['search']['value'];
|
||||
$requestedOrder = $reqData['order']['0']['column'] ?? 0;
|
||||
$order = FacturaModel::SORTABLE_PEDIDOS[$requestedOrder >= 0 ? $requestedOrder : 0];
|
||||
$dir = $reqData['order']['0']['dir'] ?? 'asc';
|
||||
|
||||
$pedido_id = $reqData['pedido_id'] ?? 0;
|
||||
|
||||
$resourceData = $this->model->getResourcePedidos($pedido_id)->orderBy($order, $dir)->limit($length, $start)->get()->getResultObject();
|
||||
|
||||
return $this->respond(Collection::datatable(
|
||||
$resourceData,
|
||||
$this->model->getResourcePedidos($pedido_id)->countAllResults(),
|
||||
$this->model->getResourcePedidos($pedido_id)->countAllResults()
|
||||
));
|
||||
} else {
|
||||
return $this->failUnauthorized('Invalid request', 403);
|
||||
}
|
||||
}
|
||||
|
||||
public function update($id = null){
|
||||
|
||||
if ($this->request->isAJAX()) {
|
||||
$newTokenHash = csrf_hash();
|
||||
$csrfTokenName = csrf_token();
|
||||
|
||||
if ($id == null) :
|
||||
$data = [
|
||||
'error' => 2,
|
||||
$csrfTokenName => $newTokenHash
|
||||
];
|
||||
return $this->respond($data);
|
||||
endif;
|
||||
$id = filter_var($id, FILTER_SANITIZE_URL);
|
||||
$facturaEntity = $this->model->find($id);
|
||||
|
||||
if ($facturaEntity == false) :
|
||||
$message = lang('Basic.global.notFoundWithIdErr', [mb_strtolower(lang('Factura.factura')), $id]);
|
||||
$data = [
|
||||
'error' => $message,
|
||||
$csrfTokenName => $newTokenHash
|
||||
];
|
||||
return $this->respond($data);
|
||||
endif;
|
||||
|
||||
if ($this->request->getPost()) :
|
||||
|
||||
$nullIfEmpty = true; // !(phpversion() >= '8.1');
|
||||
|
||||
$postData = $this->request->getPost();
|
||||
|
||||
$sanitizedData = $this->sanitized($postData, $nullIfEmpty);
|
||||
|
||||
// JJO
|
||||
$sanitizedData['user_updated_id'] = auth()->user()->id;
|
||||
|
||||
$noException = true;
|
||||
if ($successfulResult = $this->canValidate()) : // if ($successfulResult = $this->validate($this->formValidationRules) ) :
|
||||
|
||||
if ($this->canValidate()) :
|
||||
try {
|
||||
$successfulResult = $this->model->skipValidation(true)->update($id, $sanitizedData);
|
||||
} catch (\Exception $e) {
|
||||
$noException = false;
|
||||
$this->dealWithException($e);
|
||||
}
|
||||
else:
|
||||
$this->viewData['warningMessage'] = lang('Basic.global.formErr1', [mb_strtolower(lang('Facturas.factura'))]);
|
||||
$this->session->setFlashdata('formErrors', $this->model->errors());
|
||||
|
||||
endif;
|
||||
|
||||
$facturaEntity->fill($sanitizedData);
|
||||
|
||||
endif;
|
||||
if ($noException && $successfulResult) :
|
||||
$id = $facturaEntity->id ?? $id;
|
||||
$message = lang('Basic.global.updateSuccess', [lang('Basic.global.record')]) . '.';
|
||||
|
||||
$data = [
|
||||
'error' => 0,
|
||||
$csrfTokenName => $newTokenHash
|
||||
];
|
||||
return $this->respond($data);
|
||||
|
||||
endif; // $noException && $successfulResult
|
||||
endif; // ($requestMethod === 'post')
|
||||
|
||||
$data = [
|
||||
'error' => 1,
|
||||
$csrfTokenName => $newTokenHash
|
||||
];
|
||||
return $this->respond($data);
|
||||
}
|
||||
else {
|
||||
return $this->failUnauthorized('Invalid request', 403);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public function menuPedidosPendientes($cliente_id){
|
||||
|
||||
if ($this->request->isAJAX()) {
|
||||
$model = model('\App\Models\Pedidos\PedidoLineaModel');
|
||||
|
||||
$pedidos = [];
|
||||
try{
|
||||
$pedidos = $model->obtenerLineasPedidoSinFacturar($cliente_id);
|
||||
}
|
||||
catch(Exception $e){
|
||||
|
||||
}
|
||||
|
||||
$newTokenHash = csrf_hash();
|
||||
$csrfTokenName = csrf_token();
|
||||
$data = [
|
||||
'menu' => $pedidos,
|
||||
$csrfTokenName => $newTokenHash
|
||||
];
|
||||
return $this->respond($data);
|
||||
}
|
||||
else {
|
||||
return $this->failUnauthorized('Invalid request', 403);
|
||||
}
|
||||
}
|
||||
|
||||
public function duplicate($factura_id = 0){
|
||||
if($this->request->isAJAX()){
|
||||
|
||||
$factura_origen = $this->model->find($factura_id);
|
||||
// se quita la key "id" del objeto
|
||||
unset($factura_origen->id);
|
||||
$factura_origen->estado = 'borrador';
|
||||
$factura_origen->estado_pago = 'pendiente';
|
||||
$factura_origen->base = 0;
|
||||
$factura_origen->total = 0;
|
||||
$factura_origen->pendiente = 0;
|
||||
$factura_origen->total_pagos = 0;
|
||||
$factura_origen->user_created_id = auth()->user()->id;
|
||||
$factura_origen->user_updated_id = null;
|
||||
|
||||
$this->model->insert($factura_origen);
|
||||
$id = $this->model->getInsertID();
|
||||
|
||||
$newTokenHash = csrf_hash();
|
||||
$csrfTokenName = csrf_token();
|
||||
$data = [
|
||||
'id' => $id,
|
||||
$csrfTokenName => $newTokenHash
|
||||
];
|
||||
return $this->respond($data);
|
||||
|
||||
}else{
|
||||
return $this->failUnauthorized('Invalid request', 403);
|
||||
}
|
||||
}
|
||||
|
||||
public function updateTotales($factura_id = 0){
|
||||
if($this->request->isAJAX()){
|
||||
|
||||
$postData = $this->request->getPost();
|
||||
|
||||
$pendiente = $postData['pendiente'] ?? 0;
|
||||
$total = $postData['total'] ?? 0;
|
||||
|
||||
$data = [
|
||||
'base' => $postData['base'] ?? 0,
|
||||
'total' => $total,
|
||||
'pendiente' => $pendiente,
|
||||
'total_pagos' => $postData['total_pagos'] ?? 0,
|
||||
'user_updated_id' => auth()->user()->id,
|
||||
'estado_pago' => (intval($pendiente)==0 && intval($total)!=0) ? 'pagada' : 'pendiente',
|
||||
];
|
||||
|
||||
$newTokenHash = csrf_hash();
|
||||
$csrfTokenName = csrf_token();
|
||||
$data_ret = [
|
||||
$csrfTokenName => $newTokenHash
|
||||
];
|
||||
|
||||
if($factura_id == 0){
|
||||
return $this->respond($data_ret);
|
||||
}
|
||||
|
||||
$data_ret['estado_pago'] = $data['estado_pago'];
|
||||
$model = model('\App\Models\Facturas\FacturaModel');
|
||||
$model->update($factura_id, $data);
|
||||
|
||||
return $this->respond($data_ret);
|
||||
}
|
||||
else {
|
||||
return $this->failUnauthorized('Invalid request', 403);
|
||||
}
|
||||
}
|
||||
|
||||
public function addExcedentes($factura_id){
|
||||
|
||||
if ($this->request->isAJAX()) {
|
||||
$model_factura_linea = model('\App\Models\Facturas\FacturaLineaModel');
|
||||
|
||||
$postData = $this->request->getPost();
|
||||
$cantidad = $postData['cantidad'] ?? 0;
|
||||
$precio_unidad = $postData['precio_unidad'] ?? 0;
|
||||
$iva = $postData['iva'] ?? 0;
|
||||
$descripcion = $postData['descripcion'] ?? '';
|
||||
$descuento = $postData['descuento'] ?? 0;
|
||||
$pedido_linea_impresion_id = $postData['pedido_linea_impresion_id'] ?? null;
|
||||
$pedido_linea_maquetacion_id = $postData['pedido_linea_maquetacion_id'] ?? null;
|
||||
$pedido_id = $postData['pedido_id'] ?? 0;
|
||||
|
||||
$nuevo_precio_unidad = round($precio_unidad*(100-floatval($descuento))/100, 4);
|
||||
$base = round($cantidad * $nuevo_precio_unidad, 2);
|
||||
$total_iva = round($base * $iva / 100, 2);
|
||||
|
||||
$data = (object)[
|
||||
'factura_id'=>$factura_id,
|
||||
'pedido_linea_impresion_id'=>$pedido_linea_impresion_id,
|
||||
'pedido_linea_maquetacion_id'=>$pedido_linea_maquetacion_id,
|
||||
'descripcion'=>$newString = preg_replace_callback('/Impresión de (\d+) ejemplares/', function ($matches) use ($cantidad) {
|
||||
return 'Impresión de ' . $cantidad . ' ejemplares';
|
||||
}, $descripcion),
|
||||
'cantidad'=>$cantidad,
|
||||
'precio_unidad'=> $nuevo_precio_unidad,
|
||||
'iva' => $iva,
|
||||
'base' => $base,
|
||||
'total_iva' => $total_iva,
|
||||
'total' => round($base + $total_iva, 2),
|
||||
'user_updated_id' => auth()->user()->id,
|
||||
];
|
||||
|
||||
$model_factura_linea->insert($data);
|
||||
|
||||
$newTokenHash = csrf_hash();
|
||||
$csrfTokenName = csrf_token();
|
||||
$data_ret = [
|
||||
$csrfTokenName => $newTokenHash
|
||||
];
|
||||
return $this->respond($data_ret);
|
||||
}
|
||||
else {
|
||||
return $this->failUnauthorized('Invalid request', 403);
|
||||
}
|
||||
}
|
||||
|
||||
public function addLineaPedidoImpresion($factura_id){
|
||||
|
||||
if ($this->request->isAJAX()) {
|
||||
$model_pedido_linea = model('\App\Models\Pedidos\PedidoLineaModel');
|
||||
$model_presupuesto = model('\App\Models\Presupuestos\PresupuestoModel');
|
||||
$model_factura_linea = model('\App\Models\Facturas\FacturaLineaModel');
|
||||
|
||||
try{
|
||||
$pedido_linea_id = $this->request->getPost('lineaPedido') ?? 0;
|
||||
$linea = $model_pedido_linea->find($pedido_linea_id);
|
||||
|
||||
$factura = $this->model->find($factura_id);
|
||||
|
||||
if($factura){
|
||||
|
||||
if($linea){
|
||||
$presupuesto = $model_presupuesto->find($linea->presupuesto_id);
|
||||
|
||||
if($presupuesto){
|
||||
// Se añade la linea de factura
|
||||
$descripcion = $model_presupuesto->generarLineaPedido($presupuesto->id, true, $linea->pedido_id);
|
||||
$cantidad = intval($presupuesto->tirada) - intval($this->model->getCantidadLineaPedidoFacturada($linea->id));
|
||||
$base = $cantidad * floatval($presupuesto->total_precio_unidad);
|
||||
$base = round($base, 2);
|
||||
$total_iva = $base * ($presupuesto->iva_reducido==1 ? 0.04 : 0.21);
|
||||
// se redondea a dos decimales
|
||||
$total_iva = round($total_iva, 2);
|
||||
$total = $base + $total_iva;
|
||||
|
||||
$data = (object)[
|
||||
'factura_id'=>$factura_id,
|
||||
'pedido_linea_impresion_id'=>$linea->pedido_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,
|
||||
'total' => $total,
|
||||
'user_updated_id' => auth()->user()->id,
|
||||
];
|
||||
|
||||
$model_factura_linea->insert($data);
|
||||
|
||||
$id = $model_factura_linea->getInsertID();
|
||||
|
||||
if($id){
|
||||
|
||||
$model_factura_linea->addFacturaPedidoLinea($factura_id, $linea->id, $cantidad);
|
||||
|
||||
$newTokenHash = csrf_hash();
|
||||
$csrfTokenName = csrf_token();
|
||||
$data = [
|
||||
'error' => 0,
|
||||
'id' => $id,
|
||||
$csrfTokenName => $newTokenHash
|
||||
];
|
||||
return $this->respond($data);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch(Exception $e){
|
||||
|
||||
}
|
||||
|
||||
$newTokenHash = csrf_hash();
|
||||
$csrfTokenName = csrf_token();
|
||||
$data = [
|
||||
$csrfTokenName => $newTokenHash
|
||||
];
|
||||
return $this->respond($data);
|
||||
}
|
||||
else {
|
||||
return $this->failUnauthorized('Invalid request', 403);
|
||||
}
|
||||
}
|
||||
|
||||
public function deleteLineaPedidoImpresion(){
|
||||
|
||||
if ($this->request->isAJAX()) {
|
||||
|
||||
$postData = $this->request->getPost();
|
||||
$factura_id = $postData['factura_id'] ?? 0;
|
||||
$linea_id = $postData['linea_id'] ?? 0;
|
||||
$cantidad = $postData['cantidad'] ?? 0;
|
||||
|
||||
$model_factura_linea = model('\App\Models\Facturas\FacturaLineaModel');
|
||||
$model_factura_linea->deleteFacturasLineasPedido($factura_id, $linea_id, $cantidad);
|
||||
|
||||
$newTokenHash = csrf_hash();
|
||||
$csrfTokenName = csrf_token();
|
||||
$data = [
|
||||
$csrfTokenName => $newTokenHash
|
||||
];
|
||||
return $this->respond($data);
|
||||
}
|
||||
else {
|
||||
return $this->failUnauthorized('Invalid request', 403);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public function validar($factura_id){
|
||||
|
||||
if($this->request->isAJAX()){
|
||||
|
||||
$factura = $this->model->find($factura_id);
|
||||
|
||||
if($factura){
|
||||
$model_series = model('\App\Models\Configuracion\SeriesFacturasModel');
|
||||
$numero = $model_series->getSerieNumerada($factura->serie_id);
|
||||
|
||||
$data = [
|
||||
'estado' => 'validada',
|
||||
'numero' => $numero,
|
||||
'user_updated_id' => auth()->user()->id,
|
||||
];
|
||||
|
||||
if((strpos($numero, "REC ") === 0)){
|
||||
$data['estado_pago'] = 'pagada';
|
||||
}
|
||||
|
||||
$this->model->update($factura_id, $data);
|
||||
}
|
||||
|
||||
|
||||
$newTokenHash = csrf_hash();
|
||||
$csrfTokenName = csrf_token();
|
||||
$data = [
|
||||
$csrfTokenName => $newTokenHash
|
||||
];
|
||||
return $this->respond($data);
|
||||
}
|
||||
else {
|
||||
return $this->failUnauthorized('Invalid request', 403);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public function updateCabecera($factura_id){
|
||||
|
||||
if($this->request->isAJAX()){
|
||||
if($factura_id == 0){
|
||||
return;
|
||||
}
|
||||
$factura = $this->model->find($factura_id);
|
||||
if($factura){
|
||||
$postData = $this->request->getPost();
|
||||
|
||||
$dataName = $postData['name'] ?? '';
|
||||
$dataValue = $postData['value'] ?? '';
|
||||
|
||||
if($dataName == 'factura_rectificativa_id'){
|
||||
// se actualiza la factura donde el campo 'numero' sea igual al valor de $dataValue. El campo a actualizar es 'factura_rectificada_id'
|
||||
$factura_rectificada = $this->model->where('numero', $dataValue)->first();
|
||||
if($factura_rectificada){
|
||||
$data2 = [
|
||||
'factura_rectificada_id' => $factura->numero,
|
||||
'user_updated_id' => auth()->user()->id,
|
||||
];
|
||||
$this->model->update($factura_rectificada->id, $data2);
|
||||
}
|
||||
}
|
||||
|
||||
$data = [
|
||||
$dataName => $dataValue,
|
||||
'user_updated_id' => auth()->user()->id,
|
||||
];
|
||||
|
||||
$this->model->update($factura_id, $data);
|
||||
|
||||
$newTokenHash = csrf_hash();
|
||||
$csrfTokenName = csrf_token();
|
||||
$data = [
|
||||
$csrfTokenName => $newTokenHash
|
||||
];
|
||||
return $this->respond($data);
|
||||
}
|
||||
}
|
||||
else {
|
||||
return $this->failUnauthorized('Invalid request', 403);
|
||||
}
|
||||
}
|
||||
|
||||
/*************************************
|
||||
* FUNCIONES AUXILIARES
|
||||
************************************/
|
||||
|
||||
private function obtenerDatosFormulario(&$factura){
|
||||
|
||||
if($factura->estado == 'borrador'){
|
||||
$serieModel = model('App\Models\Configuracion\SeriesFacturasModel');
|
||||
$serie = $serieModel->find($factura->serie_id);
|
||||
if($serie){
|
||||
$factura->numero = str_replace("{numero}", $serie->next, $serie->formato);
|
||||
}
|
||||
}
|
||||
|
||||
$clienteModel = model('App\Models\Clientes\ClienteModel');
|
||||
$cliente = $clienteModel->find($factura->cliente_id);
|
||||
$factura->cliente_alias = $cliente->alias;
|
||||
|
||||
$serieModel = model('App\Models\Configuracion\SeriesFacturasModel');
|
||||
$serie = $serieModel->find($factura->serie_id);
|
||||
$factura->serie_nombre = $serie->nombre;
|
||||
|
||||
$formaPagoModel = model('App\Models\Configuracion\FormaPagoModel');
|
||||
$factura->formas_pago = $formaPagoModel->getMenuItems();
|
||||
|
||||
$factura->fecha_factura_at_text = $factura->fecha_factura_at ? date('d/m/Y', strtotime($factura->fecha_factura_at)) : '';
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
228
ci4/app/Controllers/Facturacion/FacturasLineas.php
Normal file
228
ci4/app/Controllers/Facturacion/FacturasLineas.php
Normal file
@ -0,0 +1,228 @@
|
||||
<?php
|
||||
|
||||
namespace App\Controllers\Facturacion;
|
||||
|
||||
use App\Models\Facturas\FacturaLineaModel;
|
||||
use App\Models\Collection;
|
||||
use DataTables\Editor;
|
||||
use DataTables\Editor\Field;
|
||||
use DataTables\Editor\Validate;
|
||||
|
||||
class FacturasLineas extends \App\Controllers\BaseResourceController
|
||||
{
|
||||
protected $modelName = FacturaLineaModel::class;
|
||||
protected $format = 'json';
|
||||
|
||||
protected static $controllerSlug = 'factura-lineas';
|
||||
|
||||
|
||||
public function datatable($factura_id = null){
|
||||
|
||||
if ($this->request->isAJAX() && $factura_id != null) {
|
||||
|
||||
$reqData = $this->request->getPost();
|
||||
if (!isset($reqData['draw']) || !isset($reqData['columns']) ) {
|
||||
$errstr = 'No data available in response to this specific request.';
|
||||
$response = $this->respond(Collection::datatable( [], 0, 0, $errstr ), 400, $errstr);
|
||||
return $response;
|
||||
}
|
||||
$start = $reqData['start'] ?? 0;
|
||||
$length = $reqData['length'] ?? 5;
|
||||
$search = $reqData['search']['value'];
|
||||
$requestedOrder = $reqData['order']['0']['column'] ?? 0;
|
||||
//$order = FacturaModel::SORTABLE[$requestedOrder >= 0 ? $requestedOrder : 0];
|
||||
$dir = $reqData['order']['0']['dir'] ?? 'asc';
|
||||
|
||||
$resourceData = $this->model->getResource($factura_id)->orderBy(1, $dir)->limit($length, $start)->get()->getResultObject();
|
||||
|
||||
return $this->respond(Collection::datatable(
|
||||
$resourceData,
|
||||
$this->model->getResource($factura_id)->countAllResults(),
|
||||
$this->model->getResource($factura_id)->countAllResults()
|
||||
));
|
||||
} else {
|
||||
return $this->failUnauthorized('Invalid request', 403);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public function deleteLinea($factura_linea_id = 0){
|
||||
|
||||
if (!empty(static::$pluralObjectNameCc) && !empty(static::$singularObjectNameCc)) {
|
||||
$objName = mb_strtolower(lang(ucfirst(static::$pluralObjectNameCc).'.'.static::$singularObjectNameCc));
|
||||
} else {
|
||||
$objName = lang('Basic.global.record');
|
||||
}
|
||||
|
||||
if($factura_linea_id == 0){
|
||||
return $this->failNotFound(lang('Basic.global.deleteError', [$objName]));
|
||||
}
|
||||
|
||||
$facturaLinea = $this->model->find($factura_linea_id);
|
||||
if($facturaLinea == null){
|
||||
return $this->failNotFound(lang('Basic.global.deleteError', [$objName]));
|
||||
}
|
||||
|
||||
if($facturaLinea->pedido_linea_impresion_id != null){
|
||||
$this->model->deleteFacturasLineasPedido($facturaLinea->factura_id, $facturaLinea->pedido_linea_impresion_id, $facturaLinea->cantidad);
|
||||
}
|
||||
|
||||
if($facturaLinea->pedido_maquetacion_id != null){
|
||||
//$this->model->deleteFacturasLineasPedido($facturaLinea->factura_id, $facturaLinea->pedido_maquetacion_id, $facturaLinea->cantidad);
|
||||
}
|
||||
|
||||
$facturaLinea = $this->model->delete($factura_linea_id);
|
||||
$message = lang('Basic.global.deleteSuccess', [lang('Basic.global.record')]);
|
||||
$response = $this->respondDeleted(['id' => $factura_linea_id, 'msg' => $message]);
|
||||
return $response;
|
||||
}
|
||||
|
||||
|
||||
public function datatable_editor() {
|
||||
if ($this->request->isAJAX()) {
|
||||
|
||||
include(APPPATH . "ThirdParty/DatatablesEditor/DataTables.php");
|
||||
|
||||
// Build our Editor instance and process the data coming from _POST
|
||||
$response = Editor::inst( $db, 'facturas_lineas' )
|
||||
->fields(
|
||||
Field::inst( 'id' ),
|
||||
Field::inst( 'base' ),
|
||||
Field::inst( 'total_iva' ),
|
||||
Field::inst( 'total' ),
|
||||
Field::inst( 'cantidad' )
|
||||
->validator('Validate::numeric', array(
|
||||
'message' => lang('Facturas.validation.numerico'))
|
||||
)
|
||||
->validator('Validate::notEmpty', array(
|
||||
'message' => lang('Facturas.validation.requerido'))
|
||||
),
|
||||
Field::inst( 'descripcion' )
|
||||
->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'))
|
||||
)
|
||||
->validator('Validate::notEmpty', array(
|
||||
'message' => lang('Facturas.validation.requerido'))
|
||||
),
|
||||
Field::inst( 'pedido_linea_impresion_id' )
|
||||
->setFormatter(function($val, $data, $opts) {
|
||||
return $val === '' ? null : $val;
|
||||
}),
|
||||
Field::inst( 'factura_id' ),
|
||||
Field::inst( 'user_updated_id' ),
|
||||
)
|
||||
->on('preCreate', function ($editor, &$values) {
|
||||
$totales = $this->generate_totales(
|
||||
$values['factura_id'],
|
||||
$values['pedido_linea_impresion_id'],
|
||||
$values['precio_unidad'],
|
||||
$values['iva'],
|
||||
$values['cantidad'],
|
||||
$values['old_cantidad']);
|
||||
$editor
|
||||
->field('user_updated_id')
|
||||
->setValue(auth()->user()->id);
|
||||
$editor
|
||||
->field('base')
|
||||
->setValue($totales['base']);
|
||||
$editor
|
||||
->field('total_iva')
|
||||
->setValue($totales['total_iva']);
|
||||
$editor
|
||||
->field('total')
|
||||
->setValue($totales['total']);
|
||||
$editor
|
||||
->field('user_updated_id')
|
||||
->setValue(auth()->user()->id);
|
||||
})
|
||||
->on('preEdit', function ($editor, $id, &$values) {
|
||||
$totales = $this->generate_totales(
|
||||
$values['factura_id'],
|
||||
$values['pedido_linea_impresion_id'],
|
||||
$values['precio_unidad'],
|
||||
$values['iva'],
|
||||
$values['cantidad'],
|
||||
$values['old_cantidad']);
|
||||
$editor
|
||||
->field('factura_id')
|
||||
->setValue($values['factura_id']);
|
||||
$editor
|
||||
->field('pedido_linea_impresion_id')
|
||||
->setValue(null);
|
||||
$editor
|
||||
->field('pedido_maquetacion_id')
|
||||
->setValue(null);
|
||||
$editor
|
||||
->field('user_updated_id')
|
||||
->setValue(auth()->user()->id);
|
||||
$editor
|
||||
->field('base')
|
||||
->setValue($totales['base']);
|
||||
$editor
|
||||
->field('total_iva')
|
||||
->setValue($totales['total_iva']);
|
||||
$editor
|
||||
->field('total')
|
||||
->setValue($totales['total']);
|
||||
})
|
||||
->debug(true)
|
||||
->process($_POST)
|
||||
->data();
|
||||
|
||||
$newTokenHash = csrf_hash();
|
||||
$csrfTokenName = csrf_token();
|
||||
|
||||
$response[$csrfTokenName] = $newTokenHash;
|
||||
|
||||
echo json_encode($response);
|
||||
|
||||
} else {
|
||||
return $this->failUnauthorized('Invalid request', 403);
|
||||
}
|
||||
}
|
||||
|
||||
public function updateTotalesFactura($factura_id = 0){
|
||||
if($factura_id == 0){
|
||||
return;
|
||||
}
|
||||
|
||||
$model = model('\App\Models\Facturas\FacturaModel');
|
||||
$model->updateTotales($factura_id);
|
||||
}
|
||||
|
||||
private function generate_totales($factura_id, $pedido_linea_id, $precio_unidad, $iva, $cantidad, $old_cantidad)
|
||||
{
|
||||
|
||||
// si es una linea que se refiere a pedido
|
||||
if ($pedido_linea_id != null && $factura_id != null) {
|
||||
// se actualiza la cantidad de la linea de pedido en la tabla pivote facturas_pedidos_lineas
|
||||
$this->model->updateFacturaPedidoLinea($factura_id, $pedido_linea_id, $old_cantidad, $cantidad);
|
||||
}
|
||||
|
||||
// se calcula y se actualiza el subtotal, total_iva y total
|
||||
// redondeando a 4 decimales el precio_unidad y a dos el resto
|
||||
$base = round($precio_unidad * $cantidad, 2);
|
||||
$total_iva = round($base * $iva / 100, 2);
|
||||
$total = round($base + $total_iva, 2);
|
||||
$values = [];
|
||||
$values['base'] = $base;
|
||||
$values['total_iva'] = $total_iva;
|
||||
$values['total'] = $total;
|
||||
|
||||
return $values;
|
||||
}
|
||||
}
|
||||
|
||||
142
ci4/app/Controllers/Facturacion/FacturasPagos.php
Normal file
142
ci4/app/Controllers/Facturacion/FacturasPagos.php
Normal file
@ -0,0 +1,142 @@
|
||||
<?php
|
||||
|
||||
namespace App\Controllers\Facturacion;
|
||||
|
||||
use App\Models\Facturas\FacturaPagoModel;
|
||||
use App\Models\Collection;
|
||||
use DataTables\Editor;
|
||||
use DataTables\Editor\Field;
|
||||
use DataTables\Editor\Validate;
|
||||
use DataTables\Editor\Format;
|
||||
|
||||
class FacturasPagos extends \App\Controllers\BaseResourceController
|
||||
{
|
||||
protected $modelName = FacturaPagoModel::class;
|
||||
protected $format = 'json';
|
||||
|
||||
protected static $controllerSlug = 'factura-pagos';
|
||||
|
||||
|
||||
public function datatable($factura_id = null){
|
||||
|
||||
if ($this->request->isAJAX() && $factura_id != null) {
|
||||
|
||||
$reqData = $this->request->getPost();
|
||||
if (!isset($reqData['draw']) || !isset($reqData['columns']) ) {
|
||||
$errstr = 'No data available in response to this specific request.';
|
||||
$response = $this->respond(Collection::datatable( [], 0, 0, $errstr ), 400, $errstr);
|
||||
return $response;
|
||||
}
|
||||
$start = $reqData['start'] ?? 0;
|
||||
$length = $reqData['length'] ?? 5;
|
||||
$search = $reqData['search']['value'];
|
||||
$requestedOrder = $reqData['order']['0']['column'] ?? 0;
|
||||
//$order = FacturaModel::SORTABLE[$requestedOrder >= 0 ? $requestedOrder : 0];
|
||||
$dir = $reqData['order']['0']['dir'] ?? 'asc';
|
||||
|
||||
$resourceData = $this->model->getResource($factura_id)->orderBy(1, $dir)->limit($length, $start)->get()->getResultObject();
|
||||
|
||||
return $this->respond(Collection::datatable(
|
||||
$resourceData,
|
||||
$this->model->getResource($factura_id)->countAllResults(),
|
||||
$this->model->getResource($factura_id)->countAllResults()
|
||||
));
|
||||
} else {
|
||||
return $this->failUnauthorized('Invalid request', 403);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public function datatable_editor() {
|
||||
if ($this->request->isAJAX()) {
|
||||
|
||||
include(APPPATH . "ThirdParty/DatatablesEditor/DataTables.php");
|
||||
|
||||
// Build our Editor instance and process the data coming from _POST
|
||||
$response = Editor::inst( $db, 'facturas_pagos' )
|
||||
->fields(
|
||||
Field::inst( 'id' ),
|
||||
Field::inst( 'forma_pago_id' ),
|
||||
Field::inst( 'notes' )
|
||||
->validator('Validate::notEmpty', array(
|
||||
'message' => lang('Facturas.validation.requerido'))
|
||||
),
|
||||
Field::inst( 'fecha_pago_at' )
|
||||
->validator( Validate::dateFormat( 'Y-m-d H:i:s' ) )
|
||||
->getFormatter( Format::dateSqlToFormat( 'Y-m-d H:i:s' ) )
|
||||
->setFormatter( Format::dateFormatToSql( 'Y-m-d H:i:s' ) ),
|
||||
Field::inst( 'fecha_vencimiento_at' )
|
||||
->validator( Validate::dateFormat( 'Y-m-d H:i:s' ) )
|
||||
->getFormatter( Format::dateSqlToFormat( 'Y-m-d H:i:s' ) )
|
||||
->setFormatter( Format::dateFormatToSql( 'Y-m-d H:i:s' ) ),
|
||||
Field::inst( 'total' )
|
||||
->validator('Validate::numeric', array(
|
||||
'message' => lang('Facturas.validation.numerico'))
|
||||
)
|
||||
->validator('Validate::notEmpty', array(
|
||||
'message' => lang('Facturas.validation.requerido'))
|
||||
),
|
||||
Field::inst( 'factura_id' ),
|
||||
Field::inst( 'user_updated_id' ),
|
||||
)
|
||||
->on('preCreate', function ($editor, &$values) {
|
||||
/*
|
||||
$editor
|
||||
->field('user_updated_id')
|
||||
->setValue(auth()->user()->id);
|
||||
$editor
|
||||
->field('base')
|
||||
->setValue($totales['base']);
|
||||
$editor
|
||||
->field('total_iva')
|
||||
->setValue($totales['total_iva']);
|
||||
$editor
|
||||
->field('total')
|
||||
->setValue($totales['total']);
|
||||
$editor
|
||||
->field('user_updated_id')
|
||||
->setValue(auth()->user()->id);
|
||||
*/
|
||||
})
|
||||
->on('preEdit', function ($editor, $id, &$values) {
|
||||
/*
|
||||
$editor
|
||||
->field('factura_id')
|
||||
->setValue($values['factura_id']);
|
||||
$editor
|
||||
->field('pedido_linea_impresion_id')
|
||||
->setValue(null);
|
||||
$editor
|
||||
->field('pedido_maquetacion_id')
|
||||
->setValue(null);
|
||||
$editor
|
||||
->field('user_updated_id')
|
||||
->setValue(auth()->user()->id);
|
||||
$editor
|
||||
->field('base')
|
||||
->setValue($totales['base']);
|
||||
$editor
|
||||
->field('total_iva')
|
||||
->setValue($totales['total_iva']);
|
||||
$editor
|
||||
->field('total')
|
||||
->setValue($totales['total']);
|
||||
*/
|
||||
})
|
||||
->debug(true)
|
||||
->process($_POST)
|
||||
->data();
|
||||
|
||||
$newTokenHash = csrf_hash();
|
||||
$csrfTokenName = csrf_token();
|
||||
|
||||
$response[$csrfTokenName] = $newTokenHash;
|
||||
|
||||
echo json_encode($response);
|
||||
|
||||
} else {
|
||||
return $this->failUnauthorized('Invalid request', 403);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@ -139,7 +139,7 @@ abstract class GoBaseController extends Controller {
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $helpers = ['session', 'go_common', 'text', 'general','jwt']; //JJO
|
||||
protected $helpers = ['session', 'go_common', 'text', 'general','jwt', 'rbac']; //JJO
|
||||
|
||||
public static $queries = [];
|
||||
|
||||
|
||||
@ -17,7 +17,7 @@ class Home extends BaseController
|
||||
public function index()
|
||||
{
|
||||
|
||||
echo view(getenv('theme.path') . 'main/defaultlayout');
|
||||
echo view(getenv('theme.path') . 'form/home/viewHome');
|
||||
|
||||
}
|
||||
|
||||
|
||||
66
ci4/app/Controllers/Pdf/PrintAlbaranes.php
Normal file
66
ci4/app/Controllers/Pdf/PrintAlbaranes.php
Normal file
@ -0,0 +1,66 @@
|
||||
<?php
|
||||
|
||||
namespace App\Controllers\Pdf;
|
||||
|
||||
use App\Controllers\BaseController;
|
||||
|
||||
|
||||
class PrintAlbaranes extends BaseController
|
||||
{
|
||||
|
||||
public function index($albaran_id)
|
||||
{
|
||||
|
||||
$albaranModel = model('App\Models\Pedidos\AlbaranModel');
|
||||
$lineasAlbaranModel = model('App\Models\Pedidos\AlbaranLineaModel');
|
||||
|
||||
$data['albaran'] = $albaranModel->getResourceForPdf($albaran_id)->get()->getRow();
|
||||
$data['albaranLineas'] = $lineasAlbaranModel->getResourceForPdf($albaran_id)->get()->getResultObject();
|
||||
|
||||
|
||||
return view(getenv('theme.path') . 'pdfs/albaran', $data);
|
||||
}
|
||||
|
||||
public function generar($albaran_id)
|
||||
{
|
||||
|
||||
// Cargar modelos
|
||||
$albaranModel = model('App\Models\Pedidos\AlbaranModel');
|
||||
$lineasAlbaranModel = model('App\Models\Pedidos\AlbaranLineaModel');
|
||||
|
||||
// Informacion del presupuesto
|
||||
$data['albaran'] = $albaranModel->getResourceForPdf($albaran_id)->get()->getRow();
|
||||
$data['albaranLineas'] = $lineasAlbaranModel->getResourceForPdf($albaran_id)->get()->getResultObject();
|
||||
|
||||
|
||||
// Crear una instancia de Dompdf
|
||||
$options = new \Dompdf\Options();
|
||||
$options->set('isHtml5ParserEnabled', true);
|
||||
$options->set('isPhpEnabled', true);
|
||||
$options->set('isRemoteEnabled', true);
|
||||
$dompdf = new \Dompdf\Dompdf($options);
|
||||
|
||||
// Contenido HTML del documento
|
||||
$dompdf->loadHtml(view(getenv('theme.path').'pdfs/albaran', $data));
|
||||
|
||||
// Establecer el tamaño del papel
|
||||
$dompdf->setPaper('A4', 'portrait');
|
||||
|
||||
// Renderizar el PDF
|
||||
$dompdf->render();
|
||||
|
||||
// Obtener el contenido generado
|
||||
$output = $dompdf->output();
|
||||
|
||||
// Establecer las cabeceras para visualizar en lugar de descargar
|
||||
$file_name = "presupuesto-$albaran_id.pdf";
|
||||
return $this->response
|
||||
->setStatusCode(200)
|
||||
->setHeader('Content-Type', 'application/pdf')
|
||||
->setHeader('Content-Disposition', 'inline; filename="' . $file_name . '"')
|
||||
->setHeader('Cache-Control', 'private, max-age=0, must-revalidate')
|
||||
->setHeader('Pragma', 'public')
|
||||
->setHeader('Content-Length', strlen($output))
|
||||
->setBody($output);
|
||||
}
|
||||
}
|
||||
65
ci4/app/Controllers/Pdf/PrintFacturas.php
Normal file
65
ci4/app/Controllers/Pdf/PrintFacturas.php
Normal file
@ -0,0 +1,65 @@
|
||||
<?php
|
||||
|
||||
namespace App\Controllers\Pdf;
|
||||
|
||||
use App\Controllers\BaseController;
|
||||
|
||||
|
||||
class PrintFacturas extends BaseController
|
||||
{
|
||||
|
||||
public function index($id_factura)
|
||||
{
|
||||
|
||||
$facturaModel = model('App\Models\Facturas\FacturaModel');
|
||||
$lineasFacturaModel = model('App\Models\Facturas\FacturaLineaModel');
|
||||
$data['factura'] = $facturaModel->getResourceForPdf($id_factura)->get()->getRow();
|
||||
$data['lineas_factura'] = $lineasFacturaModel->getResourceForPdf($id_factura)->get()->getResultObject();
|
||||
$data['resumen_por_iva'] = $lineasFacturaModel->getResourceResumenIVAsForPdf($id_factura)->get()->getResultObject();
|
||||
|
||||
return view(getenv('theme.path') . 'pdfs/factura', $data);
|
||||
}
|
||||
|
||||
public function generar($id_factura)
|
||||
{
|
||||
|
||||
// Cargar modelos
|
||||
$facturaModel = model('App\Models\Facturas\FacturaModel');
|
||||
$lineasFacturaModel = model('App\Models\Facturas\FacturaLineaModel');
|
||||
|
||||
// Informacion del presupuesto
|
||||
$data['factura'] = $facturaModel->getResourceForPdf($id_factura)->get()->getRow();
|
||||
$data['lineas_factura'] = $lineasFacturaModel->getResourceForPdf($id_factura)->get()->getResultObject();
|
||||
$data['resumen_por_iva'] = $lineasFacturaModel->getResourceResumenIVAsForPdf($id_factura)->get()->getResultObject();
|
||||
|
||||
// Crear una instancia de Dompdf
|
||||
$options = new \Dompdf\Options();
|
||||
$options->set('isHtml5ParserEnabled', true);
|
||||
$options->set('isPhpEnabled', true);
|
||||
$options->set('isRemoteEnabled', true);
|
||||
$dompdf = new \Dompdf\Dompdf($options);
|
||||
|
||||
// Contenido HTML del documento
|
||||
$dompdf->loadHtml(view(getenv('theme.path').'pdfs/factura', $data));
|
||||
|
||||
// Establecer el tamaño del papel
|
||||
$dompdf->setPaper('A4', 'portrait');
|
||||
|
||||
// Renderizar el PDF
|
||||
$dompdf->render();
|
||||
|
||||
// Obtener el contenido generado
|
||||
$output = $dompdf->output();
|
||||
|
||||
// Establecer las cabeceras para visualizar en lugar de descargar
|
||||
$file_name = $data['factura']->numero . ".pdf";
|
||||
return $this->response
|
||||
->setStatusCode(200)
|
||||
->setHeader('Content-Type', 'application/pdf')
|
||||
->setHeader('Content-Disposition', 'inline; filename="' . $file_name . '"')
|
||||
->setHeader('Cache-Control', 'private, max-age=0, must-revalidate')
|
||||
->setHeader('Pragma', 'public')
|
||||
->setHeader('Content-Length', strlen($output))
|
||||
->setBody($output);
|
||||
}
|
||||
}
|
||||
388
ci4/app/Controllers/Pedidos/Albaran.php
Normal file
388
ci4/app/Controllers/Pedidos/Albaran.php
Normal file
@ -0,0 +1,388 @@
|
||||
<?php
|
||||
|
||||
namespace App\Controllers\Pedidos;
|
||||
use App\Entities\Pedidos\AlbaranEntity;
|
||||
use App\Models\Pedidos\AlbaranModel;
|
||||
|
||||
|
||||
class Albaran extends \App\Controllers\BaseResourceController
|
||||
{
|
||||
protected $modelName = AlbaranModel::class;
|
||||
protected $format = 'json';
|
||||
|
||||
protected static $singularObjectNameCc = 'albaran';
|
||||
protected static $singularObjectName = 'Albaran';
|
||||
protected static $pluralObjectName = 'Albaranes';
|
||||
protected static $controllerSlug = 'albaran';
|
||||
|
||||
public function initController(\CodeIgniter\HTTP\RequestInterface $request, \CodeIgniter\HTTP\ResponseInterface $response, \Psr\Log\LoggerInterface $logger)
|
||||
{
|
||||
parent::initController($request, $response, $logger);
|
||||
}
|
||||
|
||||
public function index()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public function delete($id = null)
|
||||
{
|
||||
if ($this->request->isAJAX()) {
|
||||
|
||||
$newTokenHash = csrf_hash();
|
||||
$csrfTokenName = csrf_token();
|
||||
|
||||
$model_linea = model('App\Models\Pedidos\AlbaranLineaModel');
|
||||
$model_linea->where('albaran_id', $id)->delete();
|
||||
|
||||
$this->model->where('id', $id)->delete();
|
||||
|
||||
$data = [
|
||||
'error' => 0,
|
||||
$csrfTokenName => $newTokenHash
|
||||
];
|
||||
return $this->respond($data);
|
||||
}
|
||||
else {
|
||||
return $this->failUnauthorized('Invalid request', 403);
|
||||
}
|
||||
}
|
||||
|
||||
public function addLinea($albaran_id){
|
||||
|
||||
if ($this->request->isAJAX()) {
|
||||
|
||||
$model_linea = model('App\Models\Pedidos\AlbaranLineaModel');
|
||||
$newTokenHash = csrf_hash();
|
||||
$csrfTokenName = csrf_token();
|
||||
|
||||
// si es un post, es el iva
|
||||
if($this->request->getPost()){
|
||||
$reqData = $this->request->getPost();
|
||||
$albaran_id = $reqData['albaran_id'] ?? 0;
|
||||
|
||||
$albaran = $this->model->find($albaran_id);
|
||||
if($albaran == false){
|
||||
$data = [
|
||||
'error' => 'Albaran no encontrado',
|
||||
$csrfTokenName => $newTokenHash
|
||||
];
|
||||
return $this->respond($data);
|
||||
}
|
||||
$presupuesto_model = model('App\Models\Presupuestos\PresupuestoModel');
|
||||
$presupuesto = $presupuesto_model->find($albaran->presupuesto_id);
|
||||
if($presupuesto == false){
|
||||
$data = [
|
||||
'error' => 'Presupuesto no encontrado',
|
||||
$csrfTokenName => $newTokenHash
|
||||
];
|
||||
return $this->respond($data);
|
||||
}
|
||||
$iva_reducido = $presupuesto->iva_reducido;
|
||||
$lineas = $model_linea->where('albaran_id', $albaran_id)->findAll();
|
||||
$total = 0;
|
||||
foreach($lineas as $linea){
|
||||
$total += $linea->total;
|
||||
}
|
||||
$iva = $iva_reducido? $total * 4.0 / 100: $total * 21.0 / 100;
|
||||
$data_linea= [
|
||||
'albaran_id' => $albaran_id,
|
||||
'titulo' => $iva_reducido?lang('Pedidos.iva4'):lang('Pedidos.iva21'),
|
||||
'cantidad' => 1,
|
||||
'precio_unidad' => round($iva,2),
|
||||
'total' => round($iva,2),
|
||||
'user_created_id' => auth()->user()->id,
|
||||
'user_updated_id' => auth()->user()->id
|
||||
];
|
||||
$id_linea = $model_linea->insert($data_linea);
|
||||
$linea = $model_linea->find($id_linea);
|
||||
$data = [
|
||||
'error' => 0,
|
||||
'data' => $linea,
|
||||
$csrfTokenName => $newTokenHash
|
||||
];
|
||||
return $this->respond($data);
|
||||
}
|
||||
else{
|
||||
$linea = [
|
||||
'albaran_id' => $albaran_id,
|
||||
'user_created_id' => auth()->user()->id,
|
||||
'user_updated_id' => auth()->user()->id
|
||||
];
|
||||
$id_linea = $model_linea->insert($linea);
|
||||
$data = $model_linea->find($id_linea);
|
||||
|
||||
$data = [
|
||||
'error' => 0,
|
||||
'data' => $data,
|
||||
$csrfTokenName => $newTokenHash
|
||||
];
|
||||
return $this->respond($data);
|
||||
}
|
||||
}
|
||||
else {
|
||||
return $this->failUnauthorized('Invalid request', 403);
|
||||
}
|
||||
}
|
||||
|
||||
public function add()
|
||||
{
|
||||
if ($this->request->isAJAX()) {
|
||||
|
||||
$user = auth()->user()->id;
|
||||
|
||||
$newTokenHash = csrf_hash();
|
||||
$csrfTokenName = csrf_token();
|
||||
|
||||
$reqData = $this->request->getPost();
|
||||
$pedido_id = $reqData['pedido_id'] ?? 0;
|
||||
$presupuestos_id = $reqData['presupuestos_id'] ?? 0;
|
||||
|
||||
$return_data = $this->model->generarAlbaranes($pedido_id, $presupuestos_id, $user);
|
||||
$data = [
|
||||
'data' => $return_data,
|
||||
$csrfTokenName => $newTokenHash
|
||||
];
|
||||
|
||||
return $this->respond($data);
|
||||
|
||||
}
|
||||
else {
|
||||
return $this->failUnauthorized('Invalid request', 403);
|
||||
}
|
||||
}
|
||||
|
||||
public function update($id = null){
|
||||
|
||||
if ($this->request->isAJAX()) {
|
||||
$newTokenHash = csrf_hash();
|
||||
$csrfTokenName = csrf_token();
|
||||
|
||||
if ($id == null) :
|
||||
$data = [
|
||||
'error' => 2,
|
||||
$csrfTokenName => $newTokenHash
|
||||
];
|
||||
return $this->respond($data);
|
||||
endif;
|
||||
$id = filter_var($id, FILTER_SANITIZE_URL);
|
||||
$albaranEntity = $this->model->find($id);
|
||||
|
||||
if ($albaranEntity == false) :
|
||||
$message = lang('Basic.global.notFoundWithIdErr', [mb_strtolower(lang('Pedidos.albaran')), $id]);
|
||||
$data = [
|
||||
'error' => $message,
|
||||
$csrfTokenName => $newTokenHash
|
||||
];
|
||||
return $this->respond($data);
|
||||
endif;
|
||||
|
||||
if ($this->request->getPost()) :
|
||||
|
||||
$nullIfEmpty = true; // !(phpversion() >= '8.1');
|
||||
|
||||
$postData = $this->request->getPost();
|
||||
|
||||
$sanitizedData = $this->sanitized($postData, $nullIfEmpty);
|
||||
|
||||
// JJO
|
||||
$sanitizedData['user_updated_id'] = auth()->user()->id;
|
||||
|
||||
$noException = true;
|
||||
if ($successfulResult = $this->canValidate()) : // if ($successfulResult = $this->validate($this->formValidationRules) ) :
|
||||
|
||||
if ($this->canValidate()) :
|
||||
try {
|
||||
$successfulResult = $this->model->skipValidation(true)->update($id, $sanitizedData);
|
||||
} catch (\Exception $e) {
|
||||
$noException = false;
|
||||
$this->dealWithException($e);
|
||||
}
|
||||
else:
|
||||
$this->viewData['warningMessage'] = lang('Basic.global.formErr1', [mb_strtolower(lang('Pedidos.albaran'))]);
|
||||
$this->session->setFlashdata('formErrors', $this->model->errors());
|
||||
|
||||
endif;
|
||||
|
||||
$albaranEntity->fill($sanitizedData);
|
||||
|
||||
endif;
|
||||
if ($noException && $successfulResult) :
|
||||
$id = $albaranEntity->id ?? $id;
|
||||
$message = lang('Basic.global.updateSuccess', [lang('Basic.global.record')]) . '.';
|
||||
|
||||
$data = [
|
||||
'error' => 0,
|
||||
$csrfTokenName => $newTokenHash
|
||||
];
|
||||
return $this->respond($data);
|
||||
|
||||
endif; // $noException && $successfulResult
|
||||
endif; // ($requestMethod === 'post')
|
||||
|
||||
$data = [
|
||||
'error' => 1,
|
||||
$csrfTokenName => $newTokenHash
|
||||
];
|
||||
return $this->respond($data);
|
||||
}
|
||||
else {
|
||||
return $this->failUnauthorized('Invalid request', 403);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public function updateLinea($id = null){
|
||||
|
||||
if ($this->request->isAJAX()) {
|
||||
|
||||
$model_linea = model('App\Models\Pedidos\AlbaranLineaModel');
|
||||
$newTokenHash = csrf_hash();
|
||||
$csrfTokenName = csrf_token();
|
||||
|
||||
if ($id == null) :
|
||||
$data = [
|
||||
'error' => 2,
|
||||
$csrfTokenName => $newTokenHash
|
||||
];
|
||||
return $this->respond($data);
|
||||
endif;
|
||||
$id = filter_var($id, FILTER_SANITIZE_URL);
|
||||
$albaranEntity = $model_linea->find($id);
|
||||
|
||||
if ($albaranEntity == false) :
|
||||
$message = lang('Basic.global.notFoundWithIdErr', [mb_strtolower(lang('Pedidos.albaran')), $id]);
|
||||
$data = [
|
||||
'error' => $message,
|
||||
$csrfTokenName => $newTokenHash
|
||||
];
|
||||
return $this->respond($data);
|
||||
endif;
|
||||
|
||||
if ($this->request->getPost()) :
|
||||
|
||||
$nullIfEmpty = true; // !(phpversion() >= '8.1');
|
||||
|
||||
$postData = $this->request->getPost();
|
||||
|
||||
$sanitizedData = $this->sanitized($postData, $nullIfEmpty);
|
||||
|
||||
// JJO
|
||||
$sanitizedData['user_updated_id'] = auth()->user()->id;
|
||||
|
||||
$noException = true;
|
||||
if ($successfulResult = $this->canValidate()) : // if ($successfulResult = $this->validate($this->formValidationRules) ) :
|
||||
|
||||
if ($this->canValidate()) :
|
||||
try {
|
||||
$successfulResult = $model_linea->skipValidation(true)->update($id, $sanitizedData);
|
||||
} catch (\Exception $e) {
|
||||
$noException = false;
|
||||
$this->dealWithException($e);
|
||||
}
|
||||
else:
|
||||
$this->viewData['warningMessage'] = lang('Basic.global.formErr1', [mb_strtolower(lang('Pedidos.albaran'))]);
|
||||
$this->session->setFlashdata('formErrors', $model_linea->errors());
|
||||
|
||||
endif;
|
||||
|
||||
$albaranEntity->fill($sanitizedData);
|
||||
|
||||
endif;
|
||||
if ($noException && $successfulResult) :
|
||||
$id = $albaranEntity->id ?? $id;
|
||||
$message = lang('Basic.global.updateSuccess', [lang('Basic.global.record')]) . '.';
|
||||
|
||||
$data = [
|
||||
'error' => 0,
|
||||
$csrfTokenName => $newTokenHash
|
||||
];
|
||||
return $this->respond($data);
|
||||
|
||||
endif; // $noException && $successfulResult
|
||||
endif; // ($requestMethod === 'post')
|
||||
|
||||
$data = [
|
||||
'error' => 1,
|
||||
$csrfTokenName => $newTokenHash
|
||||
];
|
||||
return $this->respond($data);
|
||||
}
|
||||
else {
|
||||
return $this->failUnauthorized('Invalid request', 403);
|
||||
}
|
||||
}
|
||||
|
||||
public function borrarLinea(){
|
||||
if ($this->request->isAJAX()) {
|
||||
|
||||
$model_linea = model('App\Models\Pedidos\AlbaranLineaModel');
|
||||
$newTokenHash = csrf_hash();
|
||||
$csrfTokenName = csrf_token();
|
||||
|
||||
$reqData = $this->request->getPost();
|
||||
$id = $reqData['id'] ?? 0;
|
||||
$id = filter_var($id, FILTER_SANITIZE_URL);
|
||||
$albaranLineaEntity = $model_linea->find($id);
|
||||
|
||||
if ($albaranLineaEntity == false) :
|
||||
$message = lang('Basic.global.notFoundWithIdErr', [mb_strtolower(lang('Pedidos.albaran')), $id]);
|
||||
$message = lang('Basic.global.notFoundWithIdErr', [mb_strtolower(lang('Pedidos.albaran')), $id]);
|
||||
$data = [
|
||||
'error' => $message,
|
||||
$csrfTokenName => $newTokenHash
|
||||
];
|
||||
return $this->respond($data);
|
||||
endif;
|
||||
|
||||
$successfulResult = $model_linea->skipValidation(true)->update($id, ['deleted_at' => date('Y-m-d H:i:s')]);
|
||||
|
||||
if ($successfulResult) :
|
||||
$data = [
|
||||
'error' => 0,
|
||||
$csrfTokenName => $newTokenHash
|
||||
];
|
||||
else:
|
||||
$data = [
|
||||
'error' => 1,
|
||||
$csrfTokenName => $newTokenHash
|
||||
];
|
||||
endif;
|
||||
return $this->respond($data);
|
||||
}
|
||||
else {
|
||||
return $this->failUnauthorized('Invalid request', 403);
|
||||
}
|
||||
}
|
||||
|
||||
public function getAlbaranes($pedido_id = null){
|
||||
if ($this->request->isAJAX()) {
|
||||
|
||||
$model_linea = model('App\Models\Pedidos\AlbaranLineaModel');
|
||||
$newTokenHash = csrf_hash();
|
||||
$csrfTokenName = csrf_token();
|
||||
|
||||
$returnData = [];
|
||||
$albaranes = $this->model->asArray()->where('pedido_id', $pedido_id)->findAll();
|
||||
|
||||
foreach($albaranes as $albaran){
|
||||
$albaran['fecha_albaran'] = $albaran['updated_at'];
|
||||
array_push($returnData,
|
||||
[
|
||||
'albaran' => $albaran,
|
||||
'lineas' => $model_linea->asArray()->where('albaran_id', $albaran['id'])->findAll()]
|
||||
);
|
||||
}
|
||||
|
||||
$data = [
|
||||
'data' => $returnData,
|
||||
$csrfTokenName => $newTokenHash
|
||||
];
|
||||
return $this->respond($data);
|
||||
}
|
||||
else {
|
||||
return $this->failUnauthorized('Invalid request', 403);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -2,54 +2,330 @@
|
||||
|
||||
namespace App\Controllers\Pedidos;
|
||||
use App\Controllers\BaseController;
|
||||
use App\Entities\Pedidos\PedidoEntity;
|
||||
use App\Models\Collection;
|
||||
use App\Models\Pedidos\PedidoModel;
|
||||
|
||||
|
||||
class Pedido extends BaseController
|
||||
class Pedido extends \App\Controllers\BaseResourceController
|
||||
{
|
||||
function __construct()
|
||||
{
|
||||
|
||||
protected $modelName = PedidoModel::class;
|
||||
protected $format = 'json';
|
||||
|
||||
protected static $singularObjectNameCc = 'pedido';
|
||||
protected static $singularObjectName = 'Pedido';
|
||||
protected static $pluralObjectName = 'Pedidos';
|
||||
protected static $controllerSlug = 'pedido';
|
||||
|
||||
protected static $viewPath = 'themes/vuexy/form/pedidos/';
|
||||
|
||||
protected $indexRoute = 'pedidoList';
|
||||
|
||||
|
||||
public function initController(\CodeIgniter\HTTP\RequestInterface $request, \CodeIgniter\HTTP\ResponseInterface $response, \Psr\Log\LoggerInterface $logger)
|
||||
{
|
||||
$this->viewData['pageTitle'] = lang('Pedidos.moduleTitle');
|
||||
// Se indica que este controlador trabaja con soft_delete
|
||||
|
||||
$this->viewData = ['usingServerSideDataTable' => true];
|
||||
|
||||
// Breadcrumbs
|
||||
$this->viewData['breadcrumb'] = [
|
||||
['title' => lang("App.menu_pedidos"), 'route' => "javascript:void(0);", 'active' => false],
|
||||
];
|
||||
|
||||
parent::initController($request, $response, $logger);
|
||||
|
||||
}
|
||||
|
||||
public function index()
|
||||
{
|
||||
echo 'Pedidos';
|
||||
|
||||
$this->viewData['usingClientSideDataTable'] = true;
|
||||
|
||||
$this->viewData['pageSubTitle'] = lang('Basic.global.ManageAllRecords', [lang('Tarifaextra.tarifaextra')]);
|
||||
parent::index();
|
||||
|
||||
}
|
||||
|
||||
public function activos()
|
||||
{
|
||||
echo 'Pedidos Activos';
|
||||
$viewData = [
|
||||
'currentModule' => static::$controllerSlug,
|
||||
'pageSubTitle' => lang('Basic.global.ManageAllRecords', [lang('Pedidos.pedido')]),
|
||||
'presupuestoEntity' => new PedidoEntity(),
|
||||
'usingServerSideDataTable' => true,
|
||||
'pageTitle' => lang('Pedidos.Pedidos'),
|
||||
'estadoPedidos' => 'activo',
|
||||
['title' => lang("App.menu_pedidos"), 'route' => site_url('pedidos/todos'), 'active' => true]
|
||||
];
|
||||
|
||||
return view(static::$viewPath . 'viewPedidosList', $viewData);
|
||||
}
|
||||
|
||||
public function finalizados()
|
||||
{
|
||||
echo 'Pedidos Finalizados';
|
||||
$viewData = [
|
||||
'currentModule' => static::$controllerSlug,
|
||||
'pageSubTitle' => lang('Basic.global.ManageAllRecords', [lang('Pedidos.pedido')]),
|
||||
'presupuestoEntity' => new PedidoEntity(),
|
||||
'usingServerSideDataTable' => true,
|
||||
'pageTitle' => lang('Pedidos.Pedidos'),
|
||||
'estadoPedidos' => 'finalizado',
|
||||
['title' => lang("App.menu_pedidos"), 'route' => site_url('pedidos/todos'), 'active' => true]
|
||||
];
|
||||
|
||||
return view(static::$viewPath . 'viewPedidosList', $viewData);
|
||||
}
|
||||
|
||||
public function cancelados()
|
||||
{
|
||||
echo 'Pedidos Cancelados';
|
||||
$viewData = [
|
||||
'currentModule' => static::$controllerSlug,
|
||||
'pageSubTitle' => lang('Basic.global.ManageAllRecords', [lang('Pedidos.pedido')]),
|
||||
'presupuestoEntity' => new PedidoEntity(),
|
||||
'usingServerSideDataTable' => true,
|
||||
'pageTitle' => lang('Pedidos.Pedidos'),
|
||||
'estadoPedidos' => 'cancelado',
|
||||
['title' => lang("App.menu_pedidos"), 'route' => site_url('pedidos/todos'), 'active' => true]
|
||||
];
|
||||
|
||||
return view(static::$viewPath . 'viewPedidosList', $viewData);
|
||||
}
|
||||
|
||||
public function manuales()
|
||||
public function todos()
|
||||
{
|
||||
echo 'Pedidos Manuales';
|
||||
|
||||
$viewData = [
|
||||
'currentModule' => static::$controllerSlug,
|
||||
'pageSubTitle' => lang('Basic.global.ManageAllRecords', [lang('Pedidos.pedido')]),
|
||||
'presupuestoEntity' => new PedidoEntity(),
|
||||
'usingServerSideDataTable' => true,
|
||||
'pageTitle' => lang('Pedidos.Pedidos'),
|
||||
'estadoPedidos' => 'todos',
|
||||
['title' => lang("App.menu_pedidos"), 'route' => site_url('pedidos/todos'), 'active' => true]
|
||||
];
|
||||
|
||||
return view(static::$viewPath . 'viewPedidosList', $viewData);
|
||||
|
||||
}
|
||||
|
||||
// public function delete_files()
|
||||
// {
|
||||
//
|
||||
// }
|
||||
//
|
||||
// public function pedidos_maquetacion()
|
||||
// {
|
||||
//
|
||||
// }
|
||||
//
|
||||
// public function pedidos_prestashop()
|
||||
// {
|
||||
//
|
||||
// }
|
||||
public function cambiarEstado(){
|
||||
if($this->request->isAJAX()){
|
||||
|
||||
$id = $this->request->getPost('id');
|
||||
$estado = $this->request->getPost('estado');
|
||||
|
||||
$this->model->where('id', $id)->set(['estado' => $estado])->update();
|
||||
return $this->respond(['status' => 'success', 'message' => lang('Basic.global.success')]);
|
||||
}else{
|
||||
return $this->failUnauthorized('Invalid request', 403);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public function update($id = null){
|
||||
|
||||
if ($this->request->isAJAX()) {
|
||||
$newTokenHash = csrf_hash();
|
||||
$csrfTokenName = csrf_token();
|
||||
|
||||
if ($id == null) :
|
||||
$data = [
|
||||
'error' => 2,
|
||||
$csrfTokenName => $newTokenHash
|
||||
];
|
||||
return $this->respond($data);
|
||||
endif;
|
||||
$id = filter_var($id, FILTER_SANITIZE_URL);
|
||||
$pedidoEntity = $this->model->find($id);
|
||||
|
||||
if ($pedidoEntity == false) :
|
||||
$message = lang('Basic.global.notFoundWithIdErr', [mb_strtolower(lang('Pedidos.pedido')), $id]);
|
||||
$data = [
|
||||
'error' => $message,
|
||||
$csrfTokenName => $newTokenHash
|
||||
];
|
||||
return $this->respond($data);
|
||||
endif;
|
||||
|
||||
if ($this->request->getPost()) :
|
||||
|
||||
$nullIfEmpty = true; // !(phpversion() >= '8.1');
|
||||
|
||||
$postData = $this->request->getPost();
|
||||
|
||||
$sanitizedData = $this->sanitized($postData, $nullIfEmpty);
|
||||
|
||||
// JJO
|
||||
$sanitizedData['user_updated_id'] = auth()->user()->id;
|
||||
|
||||
$noException = true;
|
||||
if ($successfulResult = $this->canValidate()) : // if ($successfulResult = $this->validate($this->formValidationRules) ) :
|
||||
|
||||
if ($this->canValidate()) :
|
||||
try {
|
||||
$successfulResult = $this->model->skipValidation(true)->update($id, $sanitizedData);
|
||||
} catch (\Exception $e) {
|
||||
$noException = false;
|
||||
$this->dealWithException($e);
|
||||
}
|
||||
else:
|
||||
$this->viewData['warningMessage'] = lang('Basic.global.formErr1', [mb_strtolower(lang('Pedidos.albaran'))]);
|
||||
$this->session->setFlashdata('formErrors', $this->model->errors());
|
||||
|
||||
endif;
|
||||
|
||||
$pedidoEntity->fill($sanitizedData);
|
||||
|
||||
endif;
|
||||
if ($noException && $successfulResult) :
|
||||
$id = $pedidoEntity->id ?? $id;
|
||||
$message = lang('Basic.global.updateSuccess', [lang('Basic.global.record')]) . '.';
|
||||
|
||||
$data = [
|
||||
'error' => 0,
|
||||
$csrfTokenName => $newTokenHash
|
||||
];
|
||||
return $this->respond($data);
|
||||
|
||||
endif; // $noException && $successfulResult
|
||||
endif; // ($requestMethod === 'post')
|
||||
|
||||
$data = [
|
||||
'error' => 1,
|
||||
$csrfTokenName => $newTokenHash
|
||||
];
|
||||
return $this->respond($data);
|
||||
}
|
||||
else {
|
||||
return $this->failUnauthorized('Invalid request', 403);
|
||||
}
|
||||
}
|
||||
|
||||
public function edit($id=null){
|
||||
|
||||
if ($id == null) :
|
||||
return $this->redirect2listView();
|
||||
endif;
|
||||
$id = filter_var($id, FILTER_SANITIZE_URL);
|
||||
$pedidoEntity = $this->model->find($id);
|
||||
|
||||
if ($pedidoEntity == false) :
|
||||
$message = lang('Basic.global.notFoundWithIdErr', [mb_strtolower(lang('Pedidos.pedido')), $id]);
|
||||
return $this->redirect2listView('sweet-error', $message);
|
||||
endif;
|
||||
|
||||
$this->obtenerDatosFormulario($pedidoEntity);
|
||||
|
||||
$this->viewData['pedidoEntity'] = $pedidoEntity;
|
||||
|
||||
|
||||
$this->viewData['boxTitle'] = lang('Basic.global.edit2') . ' ' . lang('Pedidos.moduleTitle') . ' ' . lang('Basic.global.edit3');
|
||||
|
||||
return $this->displayForm(__METHOD__, $id);
|
||||
}
|
||||
|
||||
public function datatable(){
|
||||
|
||||
if ($this->request->isAJAX()) {
|
||||
|
||||
$reqData = $this->request->getPost();
|
||||
if (!isset($reqData['draw']) || !isset($reqData['columns']) ) {
|
||||
$errstr = 'No data available in response to this specific request.';
|
||||
$response = $this->respond(Collection::datatable( [], 0, 0, $errstr ), 400, $errstr);
|
||||
return $response;
|
||||
}
|
||||
$start = $reqData['start'] ?? 0;
|
||||
$length = $reqData['length'] ?? 5;
|
||||
$search = $reqData['search']['value'];
|
||||
$requestedOrder = $reqData['order']['0']['column'] ?? 0;
|
||||
$order = PedidoModel::SORTABLE_TODOS[$requestedOrder >= 0 ? $requestedOrder : 0];
|
||||
$dir = $reqData['order']['0']['dir'] ?? 'asc';
|
||||
$estado = $reqData['estado'] ?? 'todos';
|
||||
if($estado == 'todos') $estado = '';
|
||||
|
||||
$showTotal = $reqData['showTotal'] ?? false;
|
||||
|
||||
$searchValues = get_filter_datatables_columns($reqData);
|
||||
|
||||
$model_linea = model('\App\Models\Pedidos\PedidoLineaModel');
|
||||
$resourceData = $model_linea->getResource($searchValues, $estado)->orderBy($order, $dir)->limit($length, $start)->get()->getResultObject();
|
||||
$totalTirada = $model_linea->getSumOfTirada($searchValues, $estado, $start, $length);
|
||||
$total = $model_linea->getSumOfTotalAceptado($searchValues, $estado, $start, $length);
|
||||
$total2 = 0;
|
||||
if($showTotal){
|
||||
$total2 = $model_linea->getTotalOfTotalAceptado();
|
||||
}
|
||||
|
||||
if($total2 != 0){
|
||||
$total = "" . $total . " \n(" . $total2 . ")";
|
||||
}
|
||||
return $this->respond(Collection::datatable(
|
||||
$resourceData,
|
||||
$model_linea->getResource("", $estado)->countAllResults(),
|
||||
$model_linea->getResource($searchValues, $estado)->countAllResults(),
|
||||
"",
|
||||
[
|
||||
'total_tirada' => $totalTirada,
|
||||
'total' => $total
|
||||
]
|
||||
));
|
||||
} else {
|
||||
return $this->failUnauthorized('Invalid request', 403);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public function obtenerPedidosForFacturas(){
|
||||
if ($this->request->isAJAX()) {
|
||||
$reqData = $this->request->getPost();
|
||||
$start = $reqData['start'] ?? 0;
|
||||
}
|
||||
else {
|
||||
return $this->failUnauthorized('Invalid request', 403);
|
||||
}
|
||||
}
|
||||
|
||||
public function getlineas(){
|
||||
if ($this->request->isAJAX()) {
|
||||
|
||||
$reqData = $this->request->getPost();
|
||||
if (!isset($reqData['draw']) || !isset($reqData['columns']) ) {
|
||||
$errstr = 'No data available in response to this specific request.';
|
||||
$response = $this->respond(Collection::datatable( [], 0, 0, $errstr ), 400, $errstr);
|
||||
return $response;
|
||||
}
|
||||
|
||||
$id = $reqData['pedido_id'] ?? 0;
|
||||
$resourceData = $this->model->obtenerLineasPedido($id);
|
||||
|
||||
return $this->respond(Collection::datatable(
|
||||
$resourceData,
|
||||
count($resourceData),
|
||||
count($resourceData)
|
||||
));
|
||||
} else {
|
||||
return $this->failUnauthorized('Invalid request', 403);
|
||||
}
|
||||
}
|
||||
|
||||
private function obtenerDatosFormulario(&$pedidoEntity){
|
||||
|
||||
$datos = $this->model->obtenerDatosForm($pedidoEntity->id);
|
||||
|
||||
$pedidoEntity->estadoText = lang('Pedidos.' . $pedidoEntity->estado);
|
||||
|
||||
if(count($datos) > 0){
|
||||
$pedidoEntity->cliente = $datos[0]->cliente;
|
||||
$pedidoEntity->cliente_id = $datos[0]->cliente_id;
|
||||
$pedidoEntity->comercial = $datos[0]->comercial;
|
||||
}
|
||||
|
||||
$pedidoEntity->fecha_entrega_real_text = $pedidoEntity->fecha_entrega_real ? date('d/m/Y', strtotime($pedidoEntity->fecha_entrega_real)) : '';
|
||||
$pedidoEntity->fecha_impresion_text = $pedidoEntity->fecha_impresion ? date('d/m/Y', strtotime($pedidoEntity->fecha_impresion)) : '';
|
||||
$pedidoEntity->fecha_encuadernado_text = $pedidoEntity->fecha_encuadernado ? date('d/m/Y', strtotime($pedidoEntity->fecha_encuadernado)) : '';
|
||||
$pedidoEntity->fecha_entrega_externo_text = $pedidoEntity->fecha_entrega_externo ? date('d/m/Y', strtotime($pedidoEntity->fecha_entrega_externo)) : '';
|
||||
}
|
||||
}
|
||||
|
||||
@ -97,11 +97,11 @@ class Buscador extends \App\Controllers\BaseResourceController
|
||||
$order1 = PresupuestoModel::SORTABLE[$requestedOrder1 >= 0 ? $requestedOrder1 : 0];
|
||||
$dir1 = $reqData['order']['0']['dir'] ?? 'asc';
|
||||
$requestedOrder2 = $reqData['order']['1']['column'] ?? 0;
|
||||
$order2 = PresupuestoModel::SORTABLE[$requestedOrder2 >= 0 ? $requestedOrder1 : 0];
|
||||
$dir2 = $reqData['order']['0']['dir'] ?? 'asc';
|
||||
$order2 = PresupuestoModel::SORTABLE[$requestedOrder2 >= 0 ? $requestedOrder2 : 0];
|
||||
$dir2 = $reqData['order']['1']['dir'] ?? 'asc';
|
||||
$requestedOrder3 = $reqData['order']['2']['column'] ?? 0;
|
||||
$order3 = PresupuestoModel::SORTABLE[$requestedOrder3 >= 0 ? $requestedOrder1 : 0];
|
||||
$dir3 = $reqData['order']['0']['dir'] ?? 'asc';
|
||||
$order3 = PresupuestoModel::SORTABLE[$requestedOrder3 >= 0 ? $requestedOrder3 : 0];
|
||||
$dir3 = $reqData['order']['2']['dir'] ?? 'asc';
|
||||
|
||||
$searchValues = get_filter_datatables_columns($reqData);
|
||||
|
||||
@ -111,7 +111,7 @@ class Buscador extends \App\Controllers\BaseResourceController
|
||||
return $this->respond(Collection::datatable(
|
||||
$resourceData,
|
||||
$this->model->getResource("")->countAllResults(),
|
||||
$this->model->getResource($search)->countAllResults()
|
||||
$this->model->getResource($searchValues)->countAllResults()
|
||||
));
|
||||
} else {
|
||||
return $this->failUnauthorized('Invalid request', 403);
|
||||
|
||||
@ -295,6 +295,12 @@ class Cosidotapablanda extends \App\Controllers\BaseResourceController
|
||||
endif;
|
||||
else :
|
||||
if ($this->request->isAJAX()) {
|
||||
|
||||
if($presupuestoEntity->estado_id==1 && $presupuestoEntity->confirmar==1){
|
||||
$this->model->confirmarPresupuesto($id);
|
||||
PresupuestoService::crearPedido($id);
|
||||
}
|
||||
|
||||
$newTokenHash = csrf_hash();
|
||||
$csrfTokenName = csrf_token();
|
||||
$data = [
|
||||
@ -861,6 +867,7 @@ class Cosidotapablanda extends \App\Controllers\BaseResourceController
|
||||
$presupuesto = $this->model->find($id);
|
||||
$presupuesto->titulo = $presupuesto->titulo .' - ' . lang('Presupuestos.duplicado');
|
||||
$presupuesto->is_duplicado = 1;
|
||||
$presupuesto->estado_id = 1;
|
||||
$new_id = $this->model->insert($presupuesto);
|
||||
|
||||
$presupuestoAcabadosModel = model('App\Models\Presupuestos\PresupuestoAcabadosModel');
|
||||
|
||||
@ -99,12 +99,13 @@ class Presupuestoacabados extends \App\Controllers\BaseResourceController
|
||||
|
||||
$tarifa_acabado_id = $reqData['tarifa_acabado_id'] ?? 0;
|
||||
$tirada = $reqData['tirada'] ?? 0;
|
||||
$proveedor_id = $reqData['proveedor_id'] ?? -1;
|
||||
$POD = $reqData['POD'] ?? 0;
|
||||
|
||||
$newTokenHash = csrf_hash();
|
||||
$csrfTokenName = csrf_token();
|
||||
|
||||
$values = $this->model->getPrecioTarifa($tarifa_acabado_id, $tirada, $POD);
|
||||
$values = $this->model->getPrecioTarifa($tarifa_acabado_id, $tirada, $proveedor_id, $POD);
|
||||
|
||||
$data = [
|
||||
'values' => $values,
|
||||
@ -119,4 +120,39 @@ class Presupuestoacabados extends \App\Controllers\BaseResourceController
|
||||
}
|
||||
|
||||
|
||||
public function menuItems()
|
||||
{
|
||||
if ($this->request->isAJAX()) {
|
||||
|
||||
$reqData = $this->request->getPost();
|
||||
try{
|
||||
|
||||
$tarifa_id = $reqData['tarifa_id'] ?? -1;
|
||||
$tirada = $reqData['tirada'] ?? 0;
|
||||
|
||||
$newTokenHash = csrf_hash();
|
||||
$csrfTokenName = csrf_token();
|
||||
|
||||
$menu = $this->model->getProveedoresForSelector($tarifa_id, $tirada);
|
||||
|
||||
$data = [
|
||||
'menu' => $menu,
|
||||
$csrfTokenName => $newTokenHash
|
||||
];
|
||||
|
||||
}
|
||||
catch(Exception $e){
|
||||
$data = [
|
||||
'error' => $e,
|
||||
$csrfTokenName => $newTokenHash
|
||||
];
|
||||
}
|
||||
finally{
|
||||
return $this->respond($data);
|
||||
}
|
||||
|
||||
} else {
|
||||
return $this->failUnauthorized('Invalid request', 403);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@ -118,6 +118,7 @@ class Presupuestoencuadernaciones extends \App\Controllers\BaseResourceControlle
|
||||
$alto = $reqData['alto'] ?? 0;
|
||||
|
||||
$POD = $reqData['POD'] ?? 0;
|
||||
$paginas_cuadernillo = $reqData['paginas_por_cuadernillo'] ?? null;
|
||||
|
||||
$newTokenHash = csrf_hash();
|
||||
$csrfTokenName = csrf_token();
|
||||
@ -125,7 +126,7 @@ class Presupuestoencuadernaciones extends \App\Controllers\BaseResourceControlle
|
||||
$tarifaModel = model('App\Models\Tarifas\TarifaEncuadernacionModel');
|
||||
if(is_null($tipo)){
|
||||
if($tarifaModel->isTarifaPorHoras($tarifa_encuadernacion_id)){
|
||||
$values = $this->model->getPrecioTarifaHoras($tarifa_encuadernacion_id, $paginas, $tirada, $proveedor_id, $POD);
|
||||
$values = $this->model->getPrecioTarifaHoras($tarifa_encuadernacion_id, $paginas, $tirada, $proveedor_id, $POD, $paginas_cuadernillo);
|
||||
}else{
|
||||
$values = $this->model->getPrecioTarifa($tarifa_encuadernacion_id, $paginas, $tirada, $ancho, $alto, $proveedor_id, $POD);
|
||||
}
|
||||
|
||||
@ -7,91 +7,81 @@ use App\Models\UserModel;
|
||||
|
||||
class Profile extends BaseController
|
||||
{
|
||||
private $user_model;
|
||||
private $id_user;
|
||||
|
||||
|
||||
function __construct()
|
||||
{
|
||||
$this->user_model = new UserModel();
|
||||
$this->id_user = auth()->user()->id;
|
||||
|
||||
}
|
||||
|
||||
public function index()
|
||||
{
|
||||
helper('file');
|
||||
helper('form');
|
||||
helper('text');
|
||||
|
||||
$data['title'] = [
|
||||
'module' => lang("App.profile_title"),
|
||||
'page' => lang("App.profile_subtitle"),
|
||||
'icon' => 'fas fa-user'
|
||||
];
|
||||
|
||||
$data['breadcrumb'] = [
|
||||
['title' => lang("App.menu_dashboard"), 'route' => "/home", 'active' => false],
|
||||
['title' => lang("App.profile_title"), 'route' => "", 'active' => true]
|
||||
];
|
||||
|
||||
$data['btn_return'] = [
|
||||
'title' => lang("App.global_come_back"),
|
||||
'route' => '/',
|
||||
'class' => 'btn btn-dark mr-1',
|
||||
'icon' => 'fas fa-angle-left'
|
||||
];
|
||||
// Get the User Provider (UserModel by default)
|
||||
$users = auth()->getProvider();
|
||||
|
||||
$data['btn_submit'] = [
|
||||
'title' => lang("App.global_save"),
|
||||
'route' => '',
|
||||
'class' => 'btn btn-primary mr-1',
|
||||
'icon' => 'fas fa-save'
|
||||
];
|
||||
// Find by the user_id
|
||||
$data['obj'] = $users->findById(auth()->id());
|
||||
|
||||
$session = session();
|
||||
|
||||
$data['obj'] = $this->user_model->where('id', $this->id_user)->first();
|
||||
|
||||
|
||||
echo view(getenv('theme.path') . 'form/profile/index', $data);
|
||||
echo view(getenv('theme.path') . 'form/profile/profileDetails', $data);
|
||||
|
||||
}
|
||||
|
||||
public function store()
|
||||
{
|
||||
|
||||
$session = session();
|
||||
helper('form');
|
||||
|
||||
$rules = [
|
||||
'first_name' => 'required',
|
||||
'last_name' => 'required',
|
||||
'new_pwd' => 'permit_empty|min_length[8]',
|
||||
'new_pwd_confirm' => 'required_with[new_pwd]|matches[new_pwd]'
|
||||
];
|
||||
|
||||
// Definir los mensajes de error personalizados
|
||||
$rules_error = [
|
||||
'first_name' => ['required' => lang("App.profile_rules_first_name_r")],
|
||||
'last_name' => ['required' => lang("App.profile_rules_last_name_r")],
|
||||
'new_pwd' => ['min_length' => lang("App.profile_rules_password_m")],
|
||||
'new_pwd_confirm' => [
|
||||
'matches' => lang("App.profile_rules_password_confirm_m")
|
||||
]
|
||||
];
|
||||
|
||||
|
||||
if ($this->validate($rules ?? [], $rules_error ?? [])) {
|
||||
if (!empty($this->id_user)) {
|
||||
$this->user_model->save([
|
||||
'id' => $this->id_user,
|
||||
'first_name' => $this->request->getPost('first_name'),
|
||||
'last_name' => $this->request->getPost('last_name')
|
||||
]);
|
||||
$session->setFlashdata('sweet', ['success', lang("App.global_alert_save_success")]);
|
||||
} else {
|
||||
$session->setFlashdata('sweet', ['error', lang("App.global_alert_save_error")]);
|
||||
}
|
||||
} else {
|
||||
|
||||
$session->setFlashdata('error', 'error');
|
||||
return $this->index();
|
||||
// Validar la entrada
|
||||
if (!$this->validate($rules, $rules_error)) {
|
||||
// Si la validación falla, redirigir de vuelta con errores
|
||||
return redirect()->back()->withInput()->with('errors', $this->validator->getErrors());
|
||||
}
|
||||
|
||||
return redirect()->to('/profile');
|
||||
// Obtener los valores de los campos
|
||||
$firstName = $this->request->getPost('first_name');
|
||||
$lastName = $this->request->getPost('last_name');
|
||||
$newPwd = $this->request->getPost('new_pwd');
|
||||
|
||||
$update_data = [
|
||||
'first_name' => $firstName,
|
||||
'last_name' => $lastName,
|
||||
'password' => $newPwd,
|
||||
];
|
||||
|
||||
if(empty($newPwd)){
|
||||
unset($update_data['password']);
|
||||
}
|
||||
|
||||
// Aquí debes obtener el usuario actual, por ejemplo, desde la sesión
|
||||
$users = auth()->getProvider();
|
||||
$user = $users->findById(auth()->id());
|
||||
$user->fill($update_data);
|
||||
$users->save($user);
|
||||
|
||||
// Redirigir con un mensaje de éxito
|
||||
return redirect()->back()->with('success', lang('App.profile_updated_successfully'));
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
35
ci4/app/Controllers/Sistema/Intranet.php
Normal file
35
ci4/app/Controllers/Sistema/Intranet.php
Normal file
@ -0,0 +1,35 @@
|
||||
<?php
|
||||
|
||||
namespace App\Controllers\Sistema;
|
||||
|
||||
use CodeIgniter\Controller;
|
||||
|
||||
class Intranet extends Controller
|
||||
{
|
||||
|
||||
function presupuestos($resource_name)
|
||||
{
|
||||
helper('file');
|
||||
|
||||
$resource_path = WRITEPATH . 'uploads/presupuestos/' . $resource_name;
|
||||
|
||||
if (file_exists($resource_path)) {
|
||||
// Get the mime type of the file
|
||||
$mime_type = mime_content_type($resource_path);
|
||||
|
||||
// Get an instance of the Response class
|
||||
$response = service('response');
|
||||
|
||||
// Set the content type
|
||||
$response->setContentType($mime_type);
|
||||
|
||||
// Set the output
|
||||
$response->setBody(file_get_contents($resource_path));
|
||||
|
||||
// Send the response to the browser
|
||||
$response->send();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@ -5,6 +5,10 @@ use App\Entities\Tarifas\Acabados\TarifaAcabadoEntity;
|
||||
use App\Models\Collection;
|
||||
use App\Models\Tarifas\Acabados\TarifaAcabadoModel;
|
||||
|
||||
use App\Models\Compras\ProveedorModel;
|
||||
use App\Models\Compras\ProveedorTipoModel;
|
||||
|
||||
|
||||
class TarifaAcabados extends BaseResourceController
|
||||
{
|
||||
|
||||
@ -48,6 +52,8 @@ class TarifaAcabados extends BaseResourceController
|
||||
public function index()
|
||||
{
|
||||
|
||||
checkPermission('tarifa-acabado.menu');
|
||||
|
||||
$viewData = [
|
||||
'currentModule' => static::$controllerSlug,
|
||||
'pageSubTitle' => lang('Basic.global.ManageAllRecords', [lang('Tarifaacabado.tarifaacabado')]),
|
||||
@ -64,6 +70,8 @@ class TarifaAcabados extends BaseResourceController
|
||||
public function add()
|
||||
{
|
||||
|
||||
checkPermission('tarifa-acabado.create', $this->indexRoute);
|
||||
|
||||
if ($this->request->getPost()) :
|
||||
|
||||
$nullIfEmpty = true; // !(phpversion() >= '8.1');
|
||||
@ -133,8 +141,10 @@ class TarifaAcabados extends BaseResourceController
|
||||
return $this->displayForm(__METHOD__);
|
||||
} // end function add()
|
||||
|
||||
public function edit($requestedId = null) {
|
||||
public function edit($requestedId = null)
|
||||
{
|
||||
|
||||
checkPermission('tarifa-acabado.edit', $this->indexRoute);
|
||||
|
||||
if ($requestedId == null) :
|
||||
return $this->redirect2listView();
|
||||
@ -211,6 +221,7 @@ class TarifaAcabados extends BaseResourceController
|
||||
endif; // ($requestMethod === 'post')
|
||||
|
||||
$this->viewData['tarifaacabadoEntity'] = $tarifaacabadoEntity;
|
||||
$this->viewData['proveedores'] = $this->getProveedores();
|
||||
|
||||
$this->viewData['formAction'] = route_to('updateTarifaAcabado', $id);
|
||||
|
||||
@ -299,4 +310,12 @@ class TarifaAcabados extends BaseResourceController
|
||||
}
|
||||
}
|
||||
|
||||
private function getProveedores(){
|
||||
$provTipoModel = new ProveedorTipoModel();
|
||||
$provModel = new ProveedorModel();
|
||||
|
||||
$tipoId = $provTipoModel->getTipoId("Acabados");
|
||||
return $provModel->getProvList($tipoId);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -213,13 +213,14 @@ class TarifaAcabadosLineas extends \App\Controllers\BaseResourceController
|
||||
|
||||
$id_TA = $reqData['id_tarifaacabado'] ?? -1;
|
||||
|
||||
$searchValues = get_filter_datatables_columns($reqData);
|
||||
|
||||
$resourceData = $this->model->getResource("", $id_TA)->orderBy($order, $dir)->limit($length, $start)->get()->getResultObject();
|
||||
|
||||
$resourceData = $this->model->getResource($searchValues, $id_TA)->orderBy($order, $dir)->limit($length, $start)->get()->getResultObject();
|
||||
|
||||
return $this->respond(Collection::datatable(
|
||||
$resourceData,
|
||||
$this->model->getResource()->countAllResults(),
|
||||
$this->model->getResource($search, $id_TA)->countAllResults()
|
||||
$this->model->getResource($searchValues, $id_TA)->countAllResults()
|
||||
));
|
||||
} else {
|
||||
return $this->failUnauthorized('Invalid request', 403);
|
||||
@ -280,6 +281,7 @@ class TarifaAcabadosLineas extends \App\Controllers\BaseResourceController
|
||||
->validator('Validate::notEmpty', array(
|
||||
'message' => lang('TarifaAcabadoLineas.validation.margen.required'))
|
||||
),
|
||||
Field::inst('proveedor_id'),
|
||||
Field::inst('tarifa_acabado_id'),
|
||||
Field::inst('user_created_id'),
|
||||
Field::inst('created_at'),
|
||||
@ -297,6 +299,7 @@ class TarifaAcabadosLineas extends \App\Controllers\BaseResourceController
|
||||
|
||||
$process_data['tirada_min'] = $data['data'][$pkey]['tirada_min'];
|
||||
$process_data['tirada_max'] = $data['data'][$pkey]['tirada_max'];
|
||||
$process_data['proveedor_id'] = $data['data'][$pkey]['proveedor_id'];
|
||||
$response = $this->model->checkIntervals($process_data, $pkey, $data['data'][$pkey]['tarifa_acabado_id']);
|
||||
// No se pueden duplicar valores al crear o al editar
|
||||
if (!empty($response)) {
|
||||
|
||||
@ -40,6 +40,7 @@ class Tarifaextra extends \App\Controllers\GoBaseController
|
||||
|
||||
public function index()
|
||||
{
|
||||
checkPermission('tarifa-extra.menu');
|
||||
|
||||
$this->viewData['usingClientSideDataTable'] = true;
|
||||
|
||||
@ -51,8 +52,7 @@ class Tarifaextra extends \App\Controllers\GoBaseController
|
||||
public function add()
|
||||
{
|
||||
|
||||
|
||||
|
||||
checkPermission('tarifa-extra.create', $this->indexRoute);
|
||||
|
||||
if ($this->request->getPost()) :
|
||||
|
||||
@ -117,6 +117,7 @@ class Tarifaextra extends \App\Controllers\GoBaseController
|
||||
public function edit($requestedId = null)
|
||||
{
|
||||
|
||||
checkPermission('tarifa-extra.edit', $this->indexRoute);
|
||||
|
||||
if ($requestedId == null) :
|
||||
return $this->redirect2listView();
|
||||
@ -129,14 +130,10 @@ class Tarifaextra extends \App\Controllers\GoBaseController
|
||||
return $this->redirect2listView('errorMessage', $message);
|
||||
endif;
|
||||
|
||||
|
||||
|
||||
if ($this->request->getPost()) :
|
||||
|
||||
$nullIfEmpty = true; // !(phpversion() >= '8.1');
|
||||
|
||||
$postData = $this->request->getPost();
|
||||
$sanitizedData = $this->sanitized($postData, $nullIfEmpty);
|
||||
$sanitizedData = $this->sanitized($postData, true);
|
||||
|
||||
// JJO
|
||||
if (isset($this->model->user_updated_id)) {
|
||||
@ -192,7 +189,6 @@ class Tarifaextra extends \App\Controllers\GoBaseController
|
||||
return $this->displayForm(__METHOD__, $id);
|
||||
} // end function edit(...)
|
||||
|
||||
|
||||
public function allItemsSelect()
|
||||
{
|
||||
if ($this->request->isAJAX()) {
|
||||
|
||||
@ -1,35 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Controllers\Tarifas;
|
||||
use App\Controllers\BaseController;
|
||||
|
||||
|
||||
class Tarifaimpresion extends BaseController
|
||||
{
|
||||
function __construct()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public function index()
|
||||
{
|
||||
echo 'Tarifa impresion';
|
||||
}
|
||||
|
||||
public function delete()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public function add()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public function edit()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -1,35 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Controllers\Tarifas;
|
||||
use App\Controllers\BaseController;
|
||||
|
||||
|
||||
class Tarifapapelcompra extends BaseController
|
||||
{
|
||||
function __construct()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public function index()
|
||||
{
|
||||
echo 'Tarifa papel compra';
|
||||
}
|
||||
|
||||
public function delete()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public function add()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public function edit()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -1,35 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Controllers\Tarifas;
|
||||
use App\Controllers\BaseController;
|
||||
|
||||
|
||||
class Tarifapapeldefecto extends BaseController
|
||||
{
|
||||
function __construct()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public function index()
|
||||
{
|
||||
echo 'Tarifa papel defecto';
|
||||
}
|
||||
|
||||
public function delete()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public function add()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public function edit()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -40,19 +40,17 @@ class Tarifapreimpresion extends \App\Controllers\GoBaseController
|
||||
|
||||
public function index()
|
||||
{
|
||||
checkPermission('tarifa-preimpresion.menu');
|
||||
|
||||
$this->viewData['usingClientSideDataTable'] = true;
|
||||
|
||||
$this->viewData['pageSubTitle'] = lang('Basic.global.ManageAllRecords', [lang('Tarifapreimpresion.tarifapreimpresion')]);
|
||||
parent::index();
|
||||
|
||||
}
|
||||
|
||||
public function add()
|
||||
{
|
||||
|
||||
|
||||
|
||||
checkPermission('tarifa-preimpresion.create', $this->indexRoute);
|
||||
|
||||
if ($this->request->getPost()) :
|
||||
|
||||
@ -117,6 +115,7 @@ class Tarifapreimpresion extends \App\Controllers\GoBaseController
|
||||
public function edit($requestedId = null)
|
||||
{
|
||||
|
||||
checkPermission('tarifa-preimpresion.edit', $this->indexRoute);
|
||||
|
||||
if ($requestedId == null) :
|
||||
return $this->redirect2listView();
|
||||
|
||||
@ -55,6 +55,8 @@ class Tarifasencuadernacion extends \App\Controllers\BaseResourceController
|
||||
|
||||
public function index()
|
||||
{
|
||||
// Check if the user is allowed to list items
|
||||
checkPermission('tarifa-encuadernacion.menu');
|
||||
|
||||
$viewData = [
|
||||
'currentModule' => static::$controllerSlug,
|
||||
@ -73,8 +75,7 @@ class Tarifasencuadernacion extends \App\Controllers\BaseResourceController
|
||||
public function add()
|
||||
{
|
||||
|
||||
|
||||
|
||||
checkPermission('tarifa-encuadernacion.create', $this->indexRoute);
|
||||
|
||||
if ($this->request->getPost()) :
|
||||
|
||||
@ -157,6 +158,7 @@ class Tarifasencuadernacion extends \App\Controllers\BaseResourceController
|
||||
public function edit($requestedId = null)
|
||||
{
|
||||
|
||||
checkPermission('tarifa-encuadernacion.edit', $this->indexRoute);
|
||||
|
||||
if ($requestedId == null) :
|
||||
return $this->redirect2listView();
|
||||
@ -248,6 +250,12 @@ class Tarifasencuadernacion extends \App\Controllers\BaseResourceController
|
||||
return $this->displayForm(__METHOD__, $id);
|
||||
} // end function edit(...)
|
||||
|
||||
/*public function delete($id =null){
|
||||
if (!auth()->user()->can('tarifa-encuadernacion.delete')) {
|
||||
return $this->fail('No tiene permisos');
|
||||
}
|
||||
parent::delete($id);
|
||||
}*/
|
||||
|
||||
public function datatable()
|
||||
{
|
||||
|
||||
@ -55,7 +55,10 @@ class Tarifasenvios extends \App\Controllers\BaseResourceController {
|
||||
|
||||
|
||||
public function index() {
|
||||
|
||||
|
||||
// Check if the user is allowed to list items
|
||||
checkPermission('tarifa-envio.menu');
|
||||
|
||||
$viewData = [
|
||||
'currentModule' => static::$controllerSlug,
|
||||
'pageSubTitle' => lang('Basic.global.ManageAllRecords', [lang('TarifasEnvios.tarifaEnvio')]),
|
||||
@ -71,9 +74,8 @@ class Tarifasenvios extends \App\Controllers\BaseResourceController {
|
||||
|
||||
|
||||
public function add() {
|
||||
|
||||
|
||||
|
||||
checkPermission('tarifa-envio.create', $this->indexRoute);
|
||||
|
||||
if ($this->request->getPost()) :
|
||||
|
||||
@ -142,6 +144,8 @@ class Tarifasenvios extends \App\Controllers\BaseResourceController {
|
||||
|
||||
public function edit($requestedId = null) {
|
||||
|
||||
checkPermission('tarifa-envio.edit', $this->indexRoute);
|
||||
|
||||
|
||||
if ($requestedId == null) :
|
||||
return $this->redirect2listView();
|
||||
@ -227,6 +231,10 @@ class Tarifasenvios extends \App\Controllers\BaseResourceController {
|
||||
// JJO
|
||||
public function delete($id = null)
|
||||
{
|
||||
/*if (!auth()->user()->can('tarifa-envio.delete')) {
|
||||
return $this->fail('Error');
|
||||
}*/
|
||||
|
||||
if (!empty(static::$pluralObjectNameCc) && !empty(static::$singularObjectNameCc)) {
|
||||
$objName = mb_strtolower(lang(ucfirst(static::$pluralObjectNameCc).'.'.static::$singularObjectNameCc));
|
||||
} else {
|
||||
@ -242,7 +250,6 @@ class Tarifasenvios extends \App\Controllers\BaseResourceController {
|
||||
else{
|
||||
$datetime = (new \CodeIgniter\I18n\Time("now"));
|
||||
|
||||
|
||||
$zonaModel = new TarifaEnvioZonaModel();
|
||||
$zonaResult = $zonaModel->removeAllZonasLineas($id, $datetime, $this->delete_flag);
|
||||
|
||||
|
||||
@ -51,6 +51,8 @@ class Tarifasmanipulado extends \App\Controllers\BaseResourceController
|
||||
|
||||
public function index()
|
||||
{
|
||||
// Check if the user is allowed to list items
|
||||
checkPermission('tarifa-manipulado.menu');
|
||||
|
||||
$viewData = [
|
||||
'currentModule' => static::$controllerSlug,
|
||||
@ -69,8 +71,7 @@ class Tarifasmanipulado extends \App\Controllers\BaseResourceController
|
||||
public function add()
|
||||
{
|
||||
|
||||
|
||||
|
||||
checkPermission('tarifa-manipulado.create', $this->indexRoute);
|
||||
|
||||
if ($this->request->getPost()) :
|
||||
|
||||
@ -140,6 +141,7 @@ class Tarifasmanipulado extends \App\Controllers\BaseResourceController
|
||||
public function edit($requestedId = null)
|
||||
{
|
||||
|
||||
checkPermission('tarifa-manipulado.edit', $this->indexRoute);
|
||||
|
||||
if ($requestedId == null) :
|
||||
return $this->redirect2listView();
|
||||
@ -151,16 +153,13 @@ class Tarifasmanipulado extends \App\Controllers\BaseResourceController
|
||||
$message = lang('Basic.global.notFoundWithIdErr', [mb_strtolower(lang('Tarifamanipulado.tarifamanipulado')), $id]);
|
||||
return $this->redirect2listView('sweet-error', $message);
|
||||
endif;
|
||||
|
||||
|
||||
|
||||
if ($this->request->getPost()) :
|
||||
|
||||
$nullIfEmpty = true; // !(phpversion() >= '8.1');
|
||||
|
||||
$postData = $this->request->getPost();
|
||||
|
||||
$sanitizedData = $this->sanitized($postData, $nullIfEmpty);
|
||||
$sanitizedData = $this->sanitized($postData, true);
|
||||
|
||||
// JJO
|
||||
if (isset($this->model->user_updated_id)) {
|
||||
|
||||
@ -20,24 +20,61 @@ class Test extends BaseController
|
||||
|
||||
public function index()
|
||||
{
|
||||
helper('rbac');
|
||||
/*
|
||||
$model = model("\App\Models\Pedidos\PedidoLineaModel");
|
||||
$data = $model->obtenerLineasPedidoSinFacturar(999);
|
||||
*/
|
||||
|
||||
var_dump(auth()->user()->can('plantilla-tarifa.menu'));
|
||||
|
||||
//$user = auth()->user();
|
||||
|
||||
generate_php_permissions_constant();
|
||||
|
||||
//echo generate_php_permissions_matrix_constant();
|
||||
|
||||
//$user->syncGroups('admin');
|
||||
|
||||
//var_dump($user->can('token.menu'));
|
||||
xdebug_info();
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
private function clonar_tarifa_encuadernacion($teOrigen, $teDestino){
|
||||
|
||||
$tet_model = model('App\Models\Tarifas\TarifaEncuadernacionTiradaModel');
|
||||
$tel_model = model('App\Models\Tarifas\TarifaEncuadernacionLineaModel');
|
||||
|
||||
$tarifasTiradas = $tet_model->asObject()->where('tarifa_encuadernacion_id',$teOrigen)->findAll();
|
||||
|
||||
foreach ($tarifasTiradas as $tarifasTirada){
|
||||
|
||||
echo "--->" . $tarifasTirada->id . "<br>";
|
||||
|
||||
$tarifasLineas = $tel_model->asObject()->where('tirada_encuadernacion_id',$tarifasTirada->id)->findAll();
|
||||
|
||||
// Prepare the data
|
||||
unset($tarifasTirada->id);
|
||||
$tarifasTirada->tarifa_encuadernacion_id = $teDestino;
|
||||
$tarifasTirada->created_at = date('Y-m-d H:i:s');
|
||||
$tarifasTirada->updated_at = date('Y-m-d H:i:s');
|
||||
//var_dump($tarifasTirada);
|
||||
|
||||
// Insert it
|
||||
$tet_model->insert($tarifasTirada);
|
||||
$inserted_id = $tet_model->insertID();
|
||||
|
||||
foreach ($tarifasLineas as $tarifasLinea){
|
||||
|
||||
echo "------>" . $tarifasLinea->id . "<br>";
|
||||
|
||||
// Prepare the data
|
||||
unset($tarifasLinea->id);
|
||||
$tarifasLinea->tirada_encuadernacion_id = $inserted_id;
|
||||
$tarifasLinea->created_at = date('Y-m-d H:i:s');
|
||||
$tarifasLinea->updated_at = date('Y-m-d H:i:s');
|
||||
//var_dump($tarifasLinea);
|
||||
|
||||
// Insert it
|
||||
$tel_model->insert($tarifasLinea);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
private function test_get_tirada_alt($tirada, $merma, $tipo_impresion_id,
|
||||
$json_data, $cliente_id, $ancho, $alto,
|
||||
|
||||
21
ci4/app/Entities/Configuracion/SeriesFacturasEntity.php
Normal file
21
ci4/app/Entities/Configuracion/SeriesFacturasEntity.php
Normal file
@ -0,0 +1,21 @@
|
||||
<?php
|
||||
namespace App\Entities\Configuracion;
|
||||
|
||||
use CodeIgniter\Entity;
|
||||
|
||||
class SeriesFacturasEntity extends \CodeIgniter\Entity\Entity
|
||||
{
|
||||
protected $attributes = [
|
||||
'id' => null,
|
||||
'nombre' => null,
|
||||
'tipo' => 'facturacion', // default value
|
||||
'formato' => null,
|
||||
'next' => 1, // default value
|
||||
'grupo' => 0, // default value
|
||||
'created_at' => null, // default value
|
||||
'updated_at' => null, // default value
|
||||
];
|
||||
protected $casts = [
|
||||
|
||||
];
|
||||
}
|
||||
16
ci4/app/Entities/Configuracion/UbicacionesEntity.php
Normal file
16
ci4/app/Entities/Configuracion/UbicacionesEntity.php
Normal file
@ -0,0 +1,16 @@
|
||||
<?php
|
||||
namespace App\Entities\Configuracion;
|
||||
|
||||
use CodeIgniter\Entity;
|
||||
|
||||
class UbicacionesEntity extends \CodeIgniter\Entity\Entity
|
||||
{
|
||||
protected $attributes = [
|
||||
'id' => null,
|
||||
'nombre' => null,
|
||||
'deleted_at' => null, // default value
|
||||
];
|
||||
protected $casts = [
|
||||
|
||||
];
|
||||
}
|
||||
51
ci4/app/Entities/Facturas/FacturaEntity.php
Normal file
51
ci4/app/Entities/Facturas/FacturaEntity.php
Normal file
@ -0,0 +1,51 @@
|
||||
<?php
|
||||
|
||||
namespace App\Entities\Facturas;
|
||||
|
||||
|
||||
class FacturaEntity extends \CodeIgniter\Entity\Entity
|
||||
{
|
||||
protected $attributes = [
|
||||
'id' => null,
|
||||
'pedido_id' => null,
|
||||
'factura_rectificada_id' => null,
|
||||
'factura_rectificativa_id' => null,
|
||||
'cliente_id' => null,
|
||||
'serie_id' => null,
|
||||
'numero' => null,
|
||||
'estado' => null,
|
||||
'estado_pago' => null,
|
||||
'fecha_factura_at' => null,
|
||||
'notas' => null,
|
||||
'base' => null,
|
||||
'total' => null,
|
||||
'pendiente' => null,
|
||||
'total_pagos' => null,
|
||||
'creditoAsegurado' => null,
|
||||
'cliente_nombre' => null,
|
||||
'cliente_address' => null,
|
||||
'cliente_cif' => null,
|
||||
'cliente_pais' => null,
|
||||
'cliente_cp' => null,
|
||||
'cliente_ciudad' => null,
|
||||
'cliente_provincia' => null,
|
||||
'created_at' => null,
|
||||
'updated_at' => null,
|
||||
'deleted_at' => null,
|
||||
'user_created_id' => null,
|
||||
'user_updated_id' => null,
|
||||
];
|
||||
|
||||
protected $casts = [
|
||||
'id' => 'int',
|
||||
'pedido_id' => 'int',
|
||||
'cliente_id' => 'int',
|
||||
'serie_id' => 'int',
|
||||
'base' => 'float',
|
||||
'total' => 'float',
|
||||
'pendiente' => 'float',
|
||||
'total_pagos' => 'float',
|
||||
'creditoAsegurado' => 'float',
|
||||
];
|
||||
|
||||
}
|
||||
39
ci4/app/Entities/Facturas/FacturaLineaEntity.php
Normal file
39
ci4/app/Entities/Facturas/FacturaLineaEntity.php
Normal file
@ -0,0 +1,39 @@
|
||||
<?php
|
||||
|
||||
namespace App\Entities\Facturas;
|
||||
|
||||
|
||||
class FacturaLineaEntity extends \CodeIgniter\Entity\Entity
|
||||
{
|
||||
protected $attributes = [
|
||||
'id' => null,
|
||||
'factura_id' => null,
|
||||
'pedido_linea_impresion_id' => null,
|
||||
'pedido_maquetacion_id' => null,
|
||||
'descripcion' => null,
|
||||
'cantidad' => null,
|
||||
'precio_unidad' => null,
|
||||
'iva' => null,
|
||||
'base' => null,
|
||||
'total_iva' => null,
|
||||
'total' => null,
|
||||
'data' => null,
|
||||
'deleted_at' => null,
|
||||
'user_updated_id' => null,
|
||||
|
||||
];
|
||||
|
||||
protected $casts = [
|
||||
'id' => 'int',
|
||||
'factura_id' => 'int',
|
||||
'pedido_linea_impresion_id' => 'int',
|
||||
'pedido_maquetacion_id' => 'int',
|
||||
'cantidad' => 'float',
|
||||
'precio_unidad' => 'float',
|
||||
'iva' => 'float',
|
||||
'base' => 'float',
|
||||
'total_iva' => 'float',
|
||||
'total' => 'float',
|
||||
];
|
||||
|
||||
}
|
||||
28
ci4/app/Entities/Facturas/FacturaPagoEntity.php
Normal file
28
ci4/app/Entities/Facturas/FacturaPagoEntity.php
Normal file
@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
namespace App\Entities\Facturas;
|
||||
|
||||
|
||||
class FacturaPagoEntity extends \CodeIgniter\Entity\Entity
|
||||
{
|
||||
protected $attributes = [
|
||||
'id' => null,
|
||||
'factura_id' => null,
|
||||
'notes' => null,
|
||||
'fecha_pago_at' => null,
|
||||
'fecha_vencimiento_at' => null,
|
||||
'forma_pago_id' => null,
|
||||
'total' => null,
|
||||
'deleted_at' => null,
|
||||
'user_updated_id' => null,
|
||||
|
||||
];
|
||||
|
||||
protected $casts = [
|
||||
'id' => 'int',
|
||||
'factura_id' => 'int',
|
||||
'forma_pago_id' => 'int',
|
||||
'total' => 'float',
|
||||
];
|
||||
|
||||
}
|
||||
46
ci4/app/Entities/Pedidos/AlbaranEntity.php
Normal file
46
ci4/app/Entities/Pedidos/AlbaranEntity.php
Normal file
@ -0,0 +1,46 @@
|
||||
<?php
|
||||
namespace App\Entities\Pedidos;
|
||||
|
||||
use CodeIgniter\Entity;
|
||||
|
||||
class AlbaranEntity extends \CodeIgniter\Entity\Entity
|
||||
{
|
||||
protected $attributes = [
|
||||
'id' => null,
|
||||
'pedido_id' => null,
|
||||
'presupuesto_id' => null,
|
||||
'presupuesto_direccion_id' => null,
|
||||
'cliente_id' => null,
|
||||
'serie_id' => null,
|
||||
'numero_albaran' => null,
|
||||
'mostrar_precios' => null,
|
||||
'total' => null,
|
||||
'direccion_albaran' => null,
|
||||
'att_albaran' => null,
|
||||
'user_created_id' => null,
|
||||
'user_updated_id' => null,
|
||||
'created_at' => null,
|
||||
'updated_at' => null,
|
||||
'deleted_at' => null,
|
||||
];
|
||||
|
||||
protected $dates = ['created_at', 'updated_at', 'deleted_at'];
|
||||
|
||||
protected $casts = [
|
||||
'id' => 'integer',
|
||||
'pedido_id' => '?integer',
|
||||
'presupuesto_id' => '?integer',
|
||||
'presupuesto_direccion_id' => '?integer',
|
||||
'cliente_id' => '?integer',
|
||||
'serie_id' => '?integer',
|
||||
'numero_albaran' => '?string',
|
||||
'mostrar_precios' => '?boolean',
|
||||
'total' => 'float',
|
||||
'direccion_albaran' => '?string',
|
||||
'att_albaran' => '?string',
|
||||
'user_created_id' => 'integer',
|
||||
'user_updated_id' => 'integer',
|
||||
];
|
||||
|
||||
// Agrega tus métodos personalizados aquí
|
||||
}
|
||||
40
ci4/app/Entities/Pedidos/AlbaranLineaEntity.php
Normal file
40
ci4/app/Entities/Pedidos/AlbaranLineaEntity.php
Normal file
@ -0,0 +1,40 @@
|
||||
<?php
|
||||
namespace App\Entities\Pedidos;
|
||||
|
||||
use CodeIgniter\Entity;
|
||||
|
||||
class AlbaranLineaEntity extends \CodeIgniter\Entity\Entity
|
||||
{
|
||||
protected $attributes = [
|
||||
'id' => null,
|
||||
'albaran_id' => null,
|
||||
'titulo' => null,
|
||||
'isbn' => null,
|
||||
'ref_cliente' => null,
|
||||
'cantidad' => null,
|
||||
'cajas' => null,
|
||||
'ejemplares_por_caja' => null,
|
||||
'precio_unidad' => null,
|
||||
'total' => null,
|
||||
'user_created_id' => null,
|
||||
'user_updated_id' => null,
|
||||
'created_at' => null,
|
||||
'updated_at' => null,
|
||||
'deleted_at' => null,
|
||||
];
|
||||
|
||||
protected $casts = [
|
||||
'id' => 'integer',
|
||||
'albaran_id' => '?integer',
|
||||
'titulo' => 'string',
|
||||
'isbn' => '?string',
|
||||
'ref_cliente' => '?string',
|
||||
'cantidad' => '?integer',
|
||||
'cajas' => '?integer',
|
||||
'ejemplares_por_caja' => '?integer',
|
||||
'precio_unidad' => 'float',
|
||||
'total' => 'float',
|
||||
'user_created_id' => 'integer',
|
||||
'user_updated_id' => 'integer',
|
||||
];
|
||||
}
|
||||
30
ci4/app/Entities/Pedidos/PedidoEntity.php
Normal file
30
ci4/app/Entities/Pedidos/PedidoEntity.php
Normal file
@ -0,0 +1,30 @@
|
||||
<?php
|
||||
namespace App\Entities\Pedidos;
|
||||
|
||||
use CodeIgniter\Entity;
|
||||
|
||||
class PedidoEntity extends \CodeIgniter\Entity\Entity
|
||||
{
|
||||
protected $attributes = [
|
||||
"id" => null,
|
||||
"total_precio" => null,
|
||||
"total_tirada" => null,
|
||||
"estado" => null,
|
||||
"user_created_id" => null,
|
||||
"user_updated_id" => null,
|
||||
"user_validated_id" => null,
|
||||
"fecha_entrega_real" => null,
|
||||
"fecha_impresion" => null,
|
||||
"fecha_encuadernado" => null,
|
||||
"fecha_entrega_externo" => null,
|
||||
"created_at" => null,
|
||||
"updated_at" => null,
|
||||
"validated_at" => null,
|
||||
];
|
||||
|
||||
|
||||
protected $casts = [
|
||||
"total_precio" => "float",
|
||||
"total_tirada" => "float",
|
||||
];
|
||||
}
|
||||
25
ci4/app/Entities/Pedidos/PedidoLineaEntity.php
Normal file
25
ci4/app/Entities/Pedidos/PedidoLineaEntity.php
Normal file
@ -0,0 +1,25 @@
|
||||
<?php
|
||||
namespace App\Entities\Pedidos;
|
||||
|
||||
use CodeIgniter\Entity;
|
||||
|
||||
class PedidoLineaEntity extends \CodeIgniter\Entity\Entity
|
||||
{
|
||||
protected $attributes = [
|
||||
"id" => null,
|
||||
"pedido_id" => null,
|
||||
"presupuesto_id" => null,
|
||||
"ubicacion_id" => null,
|
||||
"user_created_id" => null,
|
||||
"user_updated_id" => null,
|
||||
"created_at" => null,
|
||||
"updated_at" => null,
|
||||
];
|
||||
|
||||
|
||||
protected $casts = [
|
||||
"pedido_id" => "int",
|
||||
"presupuesto_id" => "int",
|
||||
"ubicacion_id" => "int",
|
||||
];
|
||||
}
|
||||
@ -9,6 +9,7 @@ class PresupuestoAcabadosEntity extends \CodeIgniter\Entity\Entity
|
||||
"id" => null,
|
||||
"presupuesto_id" => null,
|
||||
"tarifa_acabado_id" => null,
|
||||
"proveedor_id" => null,
|
||||
"precio_unidad" => null,
|
||||
"precio_total" => null,
|
||||
"margen" => null,
|
||||
@ -20,6 +21,7 @@ class PresupuestoAcabadosEntity extends \CodeIgniter\Entity\Entity
|
||||
protected $casts = [
|
||||
"presupuesto_id" => "int",
|
||||
"tarifa_acabado_id" => "int",
|
||||
"proveedor_id" => "int",
|
||||
"precio_unidad" => "float",
|
||||
"precio_total" => "float",
|
||||
"margen" => "float",
|
||||
|
||||
@ -9,7 +9,9 @@ class PresupuestoEncuadernacionesEntity extends \CodeIgniter\Entity\Entity
|
||||
"id" => null,
|
||||
"presupuesto_id" => null,
|
||||
"tarifa_encuadernado_id" => null,
|
||||
"proveedor_id" => null,
|
||||
"precio_unidad" => null,
|
||||
"paginas_por_cuadernillo" => null,
|
||||
"tiempo" => null,
|
||||
"precio_total" => null,
|
||||
"margen" => null,
|
||||
@ -19,7 +21,9 @@ class PresupuestoEncuadernacionesEntity extends \CodeIgniter\Entity\Entity
|
||||
protected $casts = [
|
||||
"presupuesto_id" => "int",
|
||||
"tarifa_encuadernado_id" => "int",
|
||||
"proveedor_id" => "int",
|
||||
"precio_unidad" => "float",
|
||||
"paginas_por_cuadernillo" => "int",
|
||||
"tiempo" => "float",
|
||||
"precio_total" => "float",
|
||||
"margen" => "float",
|
||||
|
||||
@ -81,10 +81,12 @@ class PresupuestoEntity extends \CodeIgniter\Entity\Entity
|
||||
"total_antes_descuento" => null,
|
||||
"total_descuento" => null,
|
||||
"total_descuentoPercent" => null,
|
||||
"total_presupuesto" => null,
|
||||
"total_precio_unidad" => null,
|
||||
"total_factor" => null,
|
||||
"total_factor_ponderado" => null,
|
||||
'total_aceptado' => null,
|
||||
'iva_reducido' => null,
|
||||
'excluir_rotativa' => null,
|
||||
"acabado_cubierta_id" => null,
|
||||
"acabado_sobrecubierta_id" => null,
|
||||
"is_duplicado" => false,
|
||||
@ -124,7 +126,6 @@ class PresupuestoEntity extends \CodeIgniter\Entity\Entity
|
||||
"merma_cubierta" => "float",
|
||||
"lomo_cubierta" => "?float",
|
||||
"lomo_sobrecubierta" => "?float",
|
||||
"total_presupuesto" => "?float",
|
||||
"envios_recoge_cliente" => "boolean",
|
||||
"aprobado_user_id" => "?int",
|
||||
"is_deleted" => "int",
|
||||
@ -148,6 +149,9 @@ class PresupuestoEntity extends \CodeIgniter\Entity\Entity
|
||||
"total_precio_unidad" => "?float",
|
||||
"total_factor" => "?float",
|
||||
"total_factor_ponderado" => "?float",
|
||||
'total_aceptado' => "?float",
|
||||
'iva_reducido' => "?boolean",
|
||||
'excluir_rotativa' => "?boolean",
|
||||
"acabado_cubierta_id" => "int",
|
||||
"acabado_sobrecubierta_id" => "int",
|
||||
"is_duplicado" => "boolean",
|
||||
|
||||
19
ci4/app/Entities/Presupuestos/PresupuestoFicheroEntity.php
Normal file
19
ci4/app/Entities/Presupuestos/PresupuestoFicheroEntity.php
Normal file
@ -0,0 +1,19 @@
|
||||
<?php
|
||||
namespace App\Entities\Presupuestos;
|
||||
|
||||
use CodeIgniter\Entity;
|
||||
|
||||
class PresupuestoFicheroEntity extends \CodeIgniter\Entity\Entity
|
||||
{
|
||||
protected $attributes = [
|
||||
"id" => null,
|
||||
"presupuesto_id" => null,
|
||||
"nombre" => null,
|
||||
"file_path" => null,
|
||||
"upload_by" => null,
|
||||
"upload_at" => null,
|
||||
];
|
||||
protected $casts = [
|
||||
"presupuesto_id" => "int",
|
||||
];
|
||||
}
|
||||
@ -8,6 +8,7 @@ class TarifaAcabadoLineaEntity extends \CodeIgniter\Entity\Entity
|
||||
protected $attributes = [
|
||||
"id" => null,
|
||||
"tarifa_acabado_id" => 0,
|
||||
"proveedor_id" => 0,
|
||||
"tirada_min" => 0,
|
||||
"tirada_max" => 0,
|
||||
"precio_min" => 0,
|
||||
@ -21,6 +22,7 @@ class TarifaAcabadoLineaEntity extends \CodeIgniter\Entity\Entity
|
||||
];
|
||||
protected $casts = [
|
||||
"tarifa_acabado_id" => "int",
|
||||
"proveedor_id" => "int",
|
||||
"tirada_min" => "int",
|
||||
"tirada_max" => "int",
|
||||
"precio_min" => "float",
|
||||
|
||||
@ -6,49 +6,43 @@ use CodeIgniter\Entity;
|
||||
class UserEntity extends \CodeIgniter\Entity\Entity
|
||||
{
|
||||
protected $attributes = [
|
||||
"id_user" => null,
|
||||
"id" => null,
|
||||
"first_name" => null,
|
||||
"last_name" => null,
|
||||
"date_birth" => null,
|
||||
"address" => "",
|
||||
"city" => "",
|
||||
"state" => "",
|
||||
"country" => "",
|
||||
"zip_code" => "",
|
||||
"mobile" => null,
|
||||
"email" => null,
|
||||
"password" => null,
|
||||
"last_ip" => null,
|
||||
"last_access" => null,
|
||||
"picture" => "/assets/img/default-user.png",
|
||||
"language" => null,
|
||||
"tfa" => false,
|
||||
"tfa_secret" => "",
|
||||
"tfa_code" => "",
|
||||
"blocked" => null,
|
||||
"email_confirmed" => 0,
|
||||
"token" => null,
|
||||
"status" => false,
|
||||
"cliente_id" => null,
|
||||
"status" => null,
|
||||
"status_message" => null,
|
||||
'active' => null,
|
||||
"last_active" => null,
|
||||
"created_at" => null,
|
||||
"updated_at" => null,
|
||||
"deleted_at" => null,
|
||||
|
||||
];
|
||||
protected $casts = [
|
||||
"tfa" => "boolean",
|
||||
"email_confirmed" => "int",
|
||||
"status" => "boolean",
|
||||
"id" => "int",
|
||||
"cliente_id" => "int",
|
||||
"active" => "boolean",
|
||||
];
|
||||
|
||||
/**
|
||||
* Returns a full name: "first last"
|
||||
* Get the full name of the user
|
||||
*
|
||||
* @return string
|
||||
* If the first name and last name are available, the full name is generated as "{first name} {last name}".
|
||||
* If the first name or last name is missing, only the available name is used.
|
||||
* If both the first name and last name are missing, the username is used as the full name.
|
||||
*
|
||||
* @return string The full name of the user
|
||||
*/
|
||||
public function getFullName()
|
||||
{
|
||||
$fullName =
|
||||
(!empty($this->attributes["first_name"]) ? trim($this->attributes["first_name"]) . " " : "") .
|
||||
(!empty($this->attributes["last_name"]) ? trim($this->attributes["last_name"]) : "");
|
||||
$name = empty($fullName) ? $this->attributes["username"] : $fullName;
|
||||
return $name;
|
||||
$firstName = trim($this->attributes["first_name"] ?? "");
|
||||
$lastName = trim($this->attributes["last_name"] ?? "");
|
||||
$fullName = $firstName . ' ' . $lastName;
|
||||
$fullName = trim($fullName); // In case first name is empty, this will remove the leading space
|
||||
|
||||
// Use the username attribute if the full name is still empty after trimming
|
||||
return $fullName ?: $this->attributes["username"];
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@ -1,16 +1,30 @@
|
||||
<?php
|
||||
namespace App\Entities\Usuarios;
|
||||
|
||||
use CodeIgniter\Entity;
|
||||
use CodeIgniter\Shield\Entities\User;
|
||||
|
||||
class UsersEntity extends User
|
||||
{
|
||||
protected $attributes = [
|
||||
"first_name" => null,
|
||||
"last_name" => null
|
||||
'first_name' => null,
|
||||
'last_name'=> null,
|
||||
'cliente_id' => null,
|
||||
'comments' => null,
|
||||
];
|
||||
protected $casts = [
|
||||
|
||||
"cliente_id" => "int",
|
||||
];
|
||||
|
||||
public function getFullName()
|
||||
{
|
||||
$firstName = trim($this->attributes["first_name"] ?? "");
|
||||
$lastName = trim($this->attributes["last_name"] ?? "");
|
||||
$fullName = $firstName . ' ' . $lastName;
|
||||
$fullName = trim($fullName); // In case first name is empty, this will remove the leading space
|
||||
|
||||
// Use the username attribute if the full name is still empty after trimming
|
||||
return $fullName ?: $this->attributes["username"];
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -2,6 +2,7 @@
|
||||
|
||||
use App\Models\Usuarios\GroupModel;
|
||||
use App\Models\Usuarios\PermisosModel;
|
||||
use CodeIgniter\HTTP\RedirectResponse;
|
||||
|
||||
if (!function_exists('generate_php_roles_constant')) {
|
||||
function generate_php_roles_constant()
|
||||
@ -94,3 +95,28 @@ if (!function_exists('generate_php_permissions_matrix_constant')) {
|
||||
|
||||
|
||||
|
||||
|
||||
if (!function_exists('checkPermission')) {
|
||||
/**
|
||||
* Checks if the user has the required permission and redirects accordingly.
|
||||
*
|
||||
* @param string $sectionPermission The permission to check.
|
||||
* @param string|null $redirectRoute The route to redirect to if the permission is not granted.
|
||||
* @return RedirectResponse|null Redirect response if the user does not have permission, null otherwise.
|
||||
*/
|
||||
function checkPermission(string $sectionPermission, string $redirectRoute = null)
|
||||
{
|
||||
$session = \Config\Services::session();
|
||||
$response = \Config\Services::response();
|
||||
|
||||
if (!auth()->user()->can($sectionPermission)) {
|
||||
$session->setFlashdata('errorMessage', "No tiene permisos de acceso");
|
||||
|
||||
$route = $redirectRoute ?? 'home';
|
||||
return $response->redirect(route_to($route));
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -679,7 +679,7 @@ return [
|
||||
"menu_calendario" => "Calendar",
|
||||
"menu_paises" => "Countries",
|
||||
"menu_correo" => "Mail",
|
||||
"menu_formaspago" => "Payment methods",
|
||||
"menu_formas_pago" => "Payment methods",
|
||||
"menu_imposiciones" => "Impositions",
|
||||
"menu_maquina" => "Machines",
|
||||
"menu_papelgenerico" => "Generic paper",
|
||||
@ -731,7 +731,7 @@ return [
|
||||
"menu_pedidos_activos" => "Actives",
|
||||
"menu_pedidos_finalizados" => "Finished",
|
||||
"menu_pedidos_cancelados" => "Cancelled",
|
||||
"menu_pedidos_manuales" => "Manual",
|
||||
"menu_pedidos_todos" => "All",
|
||||
|
||||
"menu_presupuestos" => "Budgets",
|
||||
"menu_presupuesto" => "Books",
|
||||
|
||||
@ -12,6 +12,7 @@ return [
|
||||
'Close' => 'Close',
|
||||
'Dashboard' => 'Dashboard',
|
||||
'Delete' => 'Delete',
|
||||
'Acept' => 'Acept',
|
||||
'Clone' => 'Clone',
|
||||
'Print' => 'Print',
|
||||
'Error' => 'Error',
|
||||
@ -88,6 +89,7 @@ return [
|
||||
'ok' => 'Ok',
|
||||
'wait' => 'Wait',
|
||||
'yes' => 'Yes',
|
||||
'back' => 'Back',
|
||||
],
|
||||
|
||||
|
||||
|
||||
84
ci4/app/Language/en/Facturas.php
Normal file
84
ci4/app/Language/en/Facturas.php
Normal file
@ -0,0 +1,84 @@
|
||||
<?php
|
||||
|
||||
return [
|
||||
'id' => 'ID',
|
||||
'factura' => 'Invoice',
|
||||
'facturaList' => 'Invoice List',
|
||||
'facturas' => 'Invoices',
|
||||
'facturasList' => 'List of Invoices',
|
||||
'numeroFactura' => 'Number',
|
||||
'idFactura' => 'ID',
|
||||
'fechaFactura' => 'Date',
|
||||
'cliente' => 'Client',
|
||||
'base' => 'Base',
|
||||
'total' => 'Total',
|
||||
'pendiente' => 'Pending',
|
||||
'credito' => 'Credit',
|
||||
'estado' => 'Status',
|
||||
'estadoPago' => 'Payment Status',
|
||||
'formaPago' => 'Payment Method',
|
||||
'vencimiento' => 'Due Date',
|
||||
'dias' => 'Days',
|
||||
'serieFacturacion' => 'Billing Series',
|
||||
'creditoAsegurado' => 'Secured Credit',
|
||||
'facturaRectificada' => 'Rectified Invoice',
|
||||
'facturaRectificativa' => 'Rectifying Invoice',
|
||||
'razonSocial' => 'Business Name',
|
||||
'cif' => 'Tax ID',
|
||||
'direccion' => 'Address',
|
||||
'cp' => 'Postal Code',
|
||||
'pais' => 'Country',
|
||||
'localidad' => 'Town',
|
||||
'provincia' => 'Province',
|
||||
'pasarBorrador' => 'Move to Draft',
|
||||
'exportarLineas' => 'Export Lines',
|
||||
'duplicar' => 'Duplicate',
|
||||
'pedidos' => 'Orders',
|
||||
'titulo' => 'Title',
|
||||
'tirada' => 'Print Run',
|
||||
'lineas' => 'Lines',
|
||||
'unidades' => 'Units',
|
||||
'concepto' => 'Concept',
|
||||
'precioUnidad' => '€/u',
|
||||
'iva' => 'VAT',
|
||||
'subtotal' => 'Subtotal',
|
||||
'pendientePago' => 'Outstanding Payment',
|
||||
'rectificativa' => 'Rectifying',
|
||||
'facturaYaRectificada' => 'Already Rectified Invoice',
|
||||
'imprimir' => 'Print',
|
||||
'validada' => 'Validated',
|
||||
'borrador' => 'Draft',
|
||||
'pagada' => 'Paid',
|
||||
'insolvente' => 'Insolvent',
|
||||
'cheque' => 'Check',
|
||||
'compensada' => 'Compensated',
|
||||
'confirming' => 'Confirming',
|
||||
'giroDocimiliado' => 'Direct Debit',
|
||||
'pagare' => 'Promissory Note',
|
||||
'transferencia' => 'Transfer',
|
||||
'datosFactura' => 'Invoice Data',
|
||||
'addPedidosImpresion' => 'Add Print Orders',
|
||||
'addPedidosMaquetacion' => 'Add Layout Orders',
|
||||
'peiddoImpresion' => 'Print Order',
|
||||
'peiddoMaquetacion' => 'Layout Order',
|
||||
'nuevaLinea' => 'New Line',
|
||||
'validarFactura' => 'Validate Invoice',
|
||||
'borrarFactura' => 'Delete Invoice',
|
||||
'imprimirFactura' => 'Print',
|
||||
'pagos' => 'Payments',
|
||||
'notas' => 'Notes',
|
||||
'fechaVencimiento' => 'Due Date',
|
||||
"fechaCobro" => "Collection Date",
|
||||
"cantidad" => "Quantity",
|
||||
"addPago" => "Add Payment",
|
||||
"facturaPagada" => "Rectifying Invoice already paid",
|
||||
|
||||
'errors' => [
|
||||
'requiredFields' => 'Fields marked with * are required',
|
||||
],
|
||||
'validation' => [
|
||||
'numerico' => 'Must be numeric',
|
||||
'requerido' => 'Required',
|
||||
'decimal' => 'Must be decimal',
|
||||
],
|
||||
];
|
||||
1
ci4/app/Language/en/FormasPagoes.php → ci4/app/Language/en/FormasPago.php
Executable file → Normal file
1
ci4/app/Language/en/FormasPagoes.php → ci4/app/Language/en/FormasPago.php
Executable file → Normal file
@ -11,7 +11,6 @@ return [
|
||||
'formasDePagos' => 'Formas de Pagos',
|
||||
'formasPago' => 'Formas Pago',
|
||||
'formasPagoList' => 'Formas Pago List',
|
||||
'formasPagoes' => 'Formas Pagoes',
|
||||
'id' => 'ID',
|
||||
'moduleTitle' => 'Formas Pagoes',
|
||||
'nombre' => 'Nombre',
|
||||
86
ci4/app/Language/en/Pedidos.php
Normal file
86
ci4/app/Language/en/Pedidos.php
Normal file
@ -0,0 +1,86 @@
|
||||
<?php
|
||||
|
||||
|
||||
|
||||
return [
|
||||
'id' => 'Number',
|
||||
'fecha' => 'Date',
|
||||
'fecha_entrega' => 'Delivery Date',
|
||||
'cliente' => 'Client',
|
||||
'comercial' => 'Commercial',
|
||||
'titulo' => 'Title',
|
||||
'ubicacion' => 'Location',
|
||||
'inc_rei' => 'Inc/Rei', // This seems to be a specific term, left as is
|
||||
'num_paginas' => 'Number of Pages',
|
||||
'tiradas' => 'Print Runs',
|
||||
'total_presupuesto' => 'Total Budget',
|
||||
'estado' => 'Status',
|
||||
|
||||
'validacion' => 'Validation',
|
||||
'produccion' => 'Production',
|
||||
'finalizado' => 'Finished',
|
||||
'enviado' => 'Sent',
|
||||
'cancelado' => 'Cancelled',
|
||||
|
||||
'datosPedido' => 'Order Details',
|
||||
|
||||
'totales' => 'Totales',
|
||||
'total_precio' => 'Total price',
|
||||
"total_tirada" => 'Total print',
|
||||
|
||||
'fechas' => "Dates",
|
||||
'fecha_entrega_real' => 'Actual Delivery Date',
|
||||
'fecha_impresion' => 'Printing Date',
|
||||
'fecha_encuadernado' => 'Binding Date',
|
||||
'fecha_entrega_externo' => 'External Delivery Date',
|
||||
|
||||
'lineas' => 'Lines',
|
||||
'unidades' => "Units",
|
||||
'concepto' => "Concept",
|
||||
'total' => "Total",
|
||||
'presupuesto' => 'Budget',
|
||||
|
||||
'moduleTitle' => 'Orders',
|
||||
'pedido' => 'Order',
|
||||
'pedidos' => 'Orders',
|
||||
'pedidosList' => 'Orders List',
|
||||
|
||||
'cancelar' => 'Cancel',
|
||||
'finalizar' => 'Finish',
|
||||
|
||||
'unaCara' => '1 side',
|
||||
'dosCaras' => '2 sides',
|
||||
|
||||
'lineasTemplates' =>[
|
||||
'presupuesto' => '[BUDGET %s] ',
|
||||
'pedido' => '[ORDER %s] ',
|
||||
'libro' => "Printing of %s copies of %s pages.\nTitle: %s. Author: %s. ISBN: %s.Size: %smm.\n",
|
||||
'libro_linea_interior' => "%s black pages on %s paper of %s grams",
|
||||
'libro_linea_cubierta' => "\nCover printed on %s on %s paper of %s grams",
|
||||
'libro_linea_sobrecubierta' => "\nDust jacket on %s paper of %s grams",
|
||||
'libro_solapas' => " with flaps of %smm.",
|
||||
'libro_encuadernacion' => "\nType of binding: %s"
|
||||
],
|
||||
|
||||
'albaranes' => 'Delivery Notes',
|
||||
'albaran' => 'Delivery Note',
|
||||
'generarAlbaranes' => 'Generate delivery notes',
|
||||
'borrarAlbaranes' => 'Delete delivery notes',
|
||||
'att' => "Att",
|
||||
'direccion' => 'Address',
|
||||
'borrarAlbaran' => 'Delete delivery note',
|
||||
'imprimirAlbaran' => 'Print',
|
||||
'nuevaLinea' => 'New line',
|
||||
'addIva' => "Add VAT",
|
||||
'mostrarPrecios' => 'Show prices',
|
||||
'iva4' => "4,00 % VAT",
|
||||
'iva21' => "21,00 % VAT",
|
||||
|
||||
'facturas' => 'Invoices',
|
||||
|
||||
'showTotal' => 'Show totals',
|
||||
|
||||
'validation' => [
|
||||
|
||||
],
|
||||
];
|
||||
@ -6,6 +6,7 @@ return [
|
||||
'id' => 'ID',
|
||||
'moduleTitle' => 'Finish rates Lines',
|
||||
'deleteLine' => 'the selected register',
|
||||
'proveedor' => 'Provider',
|
||||
'precioMax' => 'Max Price',
|
||||
'precioMin' => 'Min Price',
|
||||
'precioUnidad' => 'Price Unit',
|
||||
|
||||
@ -38,6 +38,23 @@ return [
|
||||
'userList' => 'User List',
|
||||
'users' => 'Users',
|
||||
'zipCode' => 'Zip Code',
|
||||
|
||||
'admin' => 'Administrator',
|
||||
'cliente-admin' => 'Client administrator',
|
||||
'cliente-editor' => 'Client editor',
|
||||
'comercial' => 'Commercial',
|
||||
'produccion' => 'Production',
|
||||
'maquina' => 'Machine',
|
||||
'maquetador' => 'Layout designer',
|
||||
'director' => 'Director',
|
||||
'contabilidad' => 'Accounting',
|
||||
'editor' => 'Editor',
|
||||
'beta' => 'Beta',
|
||||
|
||||
'errors' => [
|
||||
'cliente_sin_clienteID' => 'The user must have a client assigned when using any client role.',
|
||||
],
|
||||
|
||||
'validation' => [
|
||||
'address' => [
|
||||
'max_length' => 'The {field} field cannot exceed {param} characters in length.',
|
||||
|
||||
@ -137,9 +137,9 @@ return [
|
||||
"profile_mobile" => "Teléfono Móvil",
|
||||
"profile_mobile_ph" => "Escriba su número de celular",
|
||||
"profile_password" => "Cambiar Contraseña",
|
||||
"profile_password_ph" => "Escribe tu contraseña",
|
||||
"profile_confirm_password" => "Confirmar seña",
|
||||
"profile_confirm_password_ph" => "Confirma tu contraseña anterior",
|
||||
"profile_password_ph" => "Escribe nueva contraseña para cambiarla",
|
||||
"profile_confirm_password" => "Confirmar contraseña",
|
||||
"profile_confirm_password_ph" => "Confirma tu contraseña anterior para cambiarla",
|
||||
"profile_date_birth" => "Fecha de Nacimiento",
|
||||
"profile_date_birth_ph" => "Seleccionar fecha de nacimiento",
|
||||
"profile_address" => "Dirección",
|
||||
@ -673,6 +673,7 @@ return [
|
||||
|
||||
"menu_clientes" => "Clientes",
|
||||
"menu_plantillas_tarifas_clientes" => "Plantillas Tarifas",
|
||||
"menu_perfil_clientes" => "Perfil",
|
||||
"menu_cliente" => "Cliente",
|
||||
"menu_clientes_nuevo" => "Nuevo",
|
||||
"menu_tarifacliente" => "Tarifas",
|
||||
@ -681,13 +682,14 @@ return [
|
||||
"menu_calendario" => "Calendario",
|
||||
"menu_paises" => "Paises",
|
||||
"menu_correo" => "Correo",
|
||||
"menu_formaspago" => "Metodos de pago",
|
||||
"menu_formas_pago" => "Formas de pago",
|
||||
"menu_imposiciones" => "Imposiciones",
|
||||
"menu_maquina" => "Maquinas",
|
||||
"menu_maquina_defecto" => "Maquinas por defecto",
|
||||
"menu_papelgenerico" => "Papel generico",
|
||||
"menu_papelimpresion" => "Papel impresión",
|
||||
"menu_seriefactura" => "Series facturas",
|
||||
"menu_series_facturas" => "Series facturas",
|
||||
"menu_ubicaciones" => "Ubicaciones",
|
||||
"menu_serviciocliente" => "Servicio cliente",
|
||||
"menu_tamanioformatos" => "Tamaño formatos",
|
||||
"menu_tamaniolibros" => "Tamaño libros",
|
||||
@ -737,9 +739,10 @@ return [
|
||||
"menu_pedidos_activos" => "Activos",
|
||||
"menu_pedidos_finalizados" => "Finalizados",
|
||||
"menu_pedidos_cancelados" => "Cancelados",
|
||||
"menu_pedidos_manuales" => "Manuales",
|
||||
"menu_pedidos_todos" => "Todos",
|
||||
|
||||
"menu_presupuestos" => "Presupuestos",
|
||||
"menu_presupuestos_clientes" => "Presupuestos (Clientes)",
|
||||
"menu_presupuesto" => "Libros",
|
||||
"menu_presupuesto_buscador" => "Buscador",
|
||||
"menu_libros" => "Libros",
|
||||
|
||||
@ -14,8 +14,7 @@ return [
|
||||
'Clone' => 'Duplicar',
|
||||
'Dashboard' => 'Panel de control',
|
||||
'Delete' => 'Borrar',
|
||||
'Clone' => 'Duplicar',
|
||||
'Print' => 'Imprimir',
|
||||
'Acept' => 'Aceptar',
|
||||
'Error' => 'Error',
|
||||
'Groups' => 'Grupos',
|
||||
'Home' => 'Inicio',
|
||||
@ -90,6 +89,8 @@ return [
|
||||
'ok' => 'Ok',
|
||||
'wait' => 'Espere',
|
||||
'yes' => 'Si',
|
||||
'no' => 'No',
|
||||
'back' => 'Volver',
|
||||
|
||||
],
|
||||
|
||||
|
||||
85
ci4/app/Language/es/Facturas.php
Normal file
85
ci4/app/Language/es/Facturas.php
Normal file
@ -0,0 +1,85 @@
|
||||
<?php
|
||||
|
||||
return [
|
||||
'id' => 'ID',
|
||||
'factura' => 'Factura',
|
||||
'facturaList' => 'Listado de Facturas',
|
||||
'facturas' => 'Facturas',
|
||||
'facturasList' => 'Listado de Facturas',
|
||||
'numeroFactura' => 'Número',
|
||||
'idFactura' => 'ID',
|
||||
'fechaFactura' => 'Fecha',
|
||||
'cliente' => 'Cliente',
|
||||
'base' => 'Base',
|
||||
'total' => 'Total',
|
||||
'pendiente' => 'Pendiente',
|
||||
'credito' => 'Crédito',
|
||||
'estado' => 'Estado',
|
||||
'estadoPago' => 'Estado Pago',
|
||||
'formaPago' => 'Forma Pago',
|
||||
'vencimiento' => 'Vencimiento',
|
||||
'dias' => 'Días',
|
||||
'serieFacturacion' => 'Serie facturación',
|
||||
'creditoAsegurado' => 'Crédito asegurado',
|
||||
'facturaRectificada' => 'Factura rectificada',
|
||||
'facturaRectificativa' => 'Factura rectificativa',
|
||||
'razonSocial' => 'Razón Social',
|
||||
'cif' => 'CIF',
|
||||
'direccion' => 'Dirección',
|
||||
'cp' => 'CP',
|
||||
'pais' => 'País',
|
||||
'localidad' => 'Localidad',
|
||||
'provincia' => 'Provincia',
|
||||
'pasarBorrador' => 'Pasar a borrador',
|
||||
'exportarLineas' => 'Exportar líneas',
|
||||
'duplicar' => 'Duplicar',
|
||||
'pedidos' => 'Pedidos',
|
||||
'titulo' => 'Título',
|
||||
'tirada' => 'Tirada',
|
||||
'lineas' => 'Líneas',
|
||||
'unidades' => 'Unidades',
|
||||
'concepto' => 'Concepto',
|
||||
'precioUnidad' => '€/u',
|
||||
'iva' => 'IVA',
|
||||
'subtotal' => 'Subtotal',
|
||||
'pendientePago' => 'Pendiente Pago',
|
||||
'rectificativa' => 'Rectificativa',
|
||||
'facturaYaRectificada' => 'Factura ya rectificada',
|
||||
'imprimir' => 'Imprimir',
|
||||
'validada' => 'Validada',
|
||||
'borrador' => 'Borrador',
|
||||
'pagada' => 'Pagada',
|
||||
'insolvente' => 'Insolvente',
|
||||
'cheque' => 'Cheque',
|
||||
'compensada' => 'Compensada',
|
||||
'confirming' => 'Confirming',
|
||||
'giroDomiciliado' => 'Giro domiciliado',
|
||||
'pagare' => 'Pagaré',
|
||||
'transferencia' => 'Transferencia',
|
||||
'datosFactura' => 'Datos Factura',
|
||||
'addPedidosImpresion' => 'Añadir Pedidos Impresión',
|
||||
'addPedidosMaquetacion' => 'Añadir Pedidos Maquetación',
|
||||
'pedidoImpresion' => 'Pedido Impresión',
|
||||
'pedidoMaquetacion' => 'Pedido Maquetación',
|
||||
'nuevaLinea' => 'Nueva Línea',
|
||||
'validarFactura' => 'Validar Factura',
|
||||
'borrarFactura' => 'Borrar Factura',
|
||||
'imprimirFactura' => 'Imprimir',
|
||||
'pagos' => 'Pagos',
|
||||
'notas' => 'Notas',
|
||||
"fechaVencimiento" => "Fecha Vencimiento",
|
||||
"fechaCobro" => "Fecha Cobro",
|
||||
"cantidad" => "Cantidad",
|
||||
"addPago" => "Añadir Pago",
|
||||
"facturaPagada" => "Factura rectificativa ya abonada",
|
||||
|
||||
'errors' => [
|
||||
'requiredFields' => 'Los campos marcados con * son obligatorios',
|
||||
],
|
||||
'validation' => [
|
||||
"requerido" => "El campo es obligatorio.",
|
||||
"numerico" => "El campo debe ser numérico.",
|
||||
"decimal" => "El campo debe ser decimal.",
|
||||
]
|
||||
|
||||
];
|
||||
88
ci4/app/Language/es/Pedidos.php
Normal file
88
ci4/app/Language/es/Pedidos.php
Normal file
@ -0,0 +1,88 @@
|
||||
<?php
|
||||
|
||||
|
||||
return [
|
||||
'id' => 'Número',
|
||||
'fecha' => 'Fecha',
|
||||
'fecha_entrega' => 'Fecha <br>Entrega',
|
||||
'cliente' => 'Cliente',
|
||||
'comercial' => 'Comercial',
|
||||
'titulo' => 'Título',
|
||||
'ubicacion' => 'Ubicación',
|
||||
'inc_rei' => 'Inc/Rei',
|
||||
'num_paginas' => 'Nº Páginas',
|
||||
'tiradas' => 'Tiradas',
|
||||
'total_presupuesto' => 'Total',
|
||||
'estado' => 'Estado',
|
||||
|
||||
'validacion' => 'Validación',
|
||||
'produccion' => 'Producción',
|
||||
'finalizado' => 'Finalizado',
|
||||
'enviado' => 'Enviado',
|
||||
'cancelado' => 'Cancelado',
|
||||
|
||||
'datosPedido' => 'Datos del pedido',
|
||||
|
||||
'totales' => 'Totales',
|
||||
'total_precio' => 'Total precio',
|
||||
"total_tirada" => 'Total tirada',
|
||||
|
||||
'fechas' => "Fechas",
|
||||
'fecha_entrega_real' => "Fecha entrega real",
|
||||
'fecha_impresion' => "Fecha impresion",
|
||||
'fecha_encuadernado' => "Fecha encuadernado",
|
||||
'fecha_entrega_externo' => "Fecha entrega externo",
|
||||
|
||||
'lineas' => 'Líneas pedido',
|
||||
'unidades' => "Unidades",
|
||||
'concepto' => "Concepto",
|
||||
'total' => "Total",
|
||||
'presupuesto' => 'Presupuesto',
|
||||
|
||||
'moduleTitle' => 'Pedidos',
|
||||
'pedido' => 'Pedido',
|
||||
'pedidos' => 'Pedidos',
|
||||
'pedidosList' => 'Lista de Pedidos',
|
||||
|
||||
'cancelar' => 'Cancelar',
|
||||
'finalizar' => 'Finalizar',
|
||||
|
||||
'unaCara' => '1 cara',
|
||||
'dosCaras' => '2 caras',
|
||||
|
||||
'lineasTemplates' =>[
|
||||
'presupuesto' => '[PRESUPUESTO %s] ',
|
||||
'pedido' => '[PEDIDO %s] ',
|
||||
'libro' => "Impresión de %s ejemplares de %s páginas.\nTítulo: %s. Autor: %s. ISBN: %s.Tamaño: %smm.\n",
|
||||
'libro_linea_interior' => "%s páginas en negro sobre papel %s de %s gramos",
|
||||
'libro_linea_cubierta' => "\nCubierta impresa a %s sobre papel %s de %s gramos",
|
||||
'libro_linea_sobrecubierta' => "\nSobrecubierta sobre papel %s de %s gramos",
|
||||
'libro_solapas' => " con solapas de %smm." ,
|
||||
'libro_encuadernacion' => "\nTipo de encuadernación: %s"
|
||||
],
|
||||
|
||||
'albaranes' => 'Albaranes',
|
||||
'albaran' => 'Albarán',
|
||||
'generarAlbaranes' => 'Generar albaranes',
|
||||
'borrarAlbaranes' => 'Borrar albaranes',
|
||||
'att' => "Att",
|
||||
'direccion' => 'Direccion',
|
||||
'borrarAlbaran' => 'Borrar albarán',
|
||||
'imprimirAlbaran' => 'Imprimir',
|
||||
'nuevaLinea' => 'Nueva línea',
|
||||
'addIva' => "Añadir IVA",
|
||||
'mostrarPrecios' => 'Mostrar precios',
|
||||
'iva4' => "4,00 % IVA",
|
||||
'iva21' => "21,00 % IVA",
|
||||
|
||||
|
||||
'facturas' => 'Facturas',
|
||||
|
||||
'showTotal' => 'Mostrar totales',
|
||||
|
||||
'validation' => [
|
||||
|
||||
],
|
||||
|
||||
|
||||
];
|
||||
@ -19,6 +19,7 @@ return [
|
||||
'presupuestoCosidotapaduraList' => 'Lista presupuestos Libros Cosido Tapa Dura',
|
||||
'presupuestoCosidotapablandaList' => 'Lista presupuestos Libros Cosido Tapa Blanda',
|
||||
'presupuesto' => 'Presupuesto',
|
||||
'presupuestos' => 'Presupuestos',
|
||||
|
||||
'libroCosidoTapaBlanda' => "Cosido Tapa Blanda",
|
||||
'libroCosidoTapaDura' => "Cosido Tapa Dura",
|
||||
@ -58,6 +59,7 @@ return [
|
||||
'numeroEdicion' => 'Número de edición',
|
||||
'isbn' => 'ISBN',
|
||||
'referenciaCliente' => 'Referencia del cliente',
|
||||
'referenciaCliente2' => 'Referencia',
|
||||
'papelFormatoId' => "Tamaño",
|
||||
'papelFormatoPersonalizado' => 'Tamaño personalizado',
|
||||
'papelFormatoAncho' => 'Ancho',
|
||||
@ -206,6 +208,9 @@ return [
|
||||
|
||||
'resumen' => 'Resumen del presupuesto',
|
||||
'confirmar' => 'Confirmar presupuesto',
|
||||
'confirmado' => 'Presupuesto confirmado',
|
||||
|
||||
'totalAceptado' => 'Total aceptado',
|
||||
|
||||
// Preview
|
||||
'preview' => 'Previsualización de configuraciones',
|
||||
@ -242,6 +247,7 @@ return [
|
||||
'precio' => 'Precio',
|
||||
'precioUnidad' => 'Precio unidad',
|
||||
'tiempo' => 'Tiempo',
|
||||
"paginasCuadernillo" => "Páginas/cuadernillo",
|
||||
'precioTotal' => 'Precio total',
|
||||
'serviciosDefault' => 'Servicios por defecto',
|
||||
'tarifa' => 'Tarifa',
|
||||
@ -275,6 +281,17 @@ return [
|
||||
'actualizacionSolapasCubierta' => 'El tamaño de las solapas de la cubierta se ha actualizado debido a que supera el máximo permitido (este valor depende del ancho del libro y del número de páginas).',
|
||||
'actualizacionSolapasSobrecubierta' => 'El tamaño de las solapas de la sobrecubierta se ha actualizado debido a que supera el máximo permitido (este valor depende del ancho del libro y del número de páginas).',
|
||||
|
||||
'titulos' => [
|
||||
'libroFresadoTapaDura' => 'Rústica Fresado tapa dura',
|
||||
'libroFresadoTapaBlanda' => 'Rústica Fresado tapa blanda',
|
||||
'libroCosidoTapaDura' => 'Rústica Cosido tapa dura',
|
||||
'libroCosidoTapaBlanda' => 'Rústica Cosido tapa blanda',
|
||||
'libroEspiralTapaDura' => 'Espiral tapa dura',
|
||||
'libroEspiralTapaBlanda' => 'Espiral tapa blanda',
|
||||
'libroWireoTapaDura' => 'Wire-o tapa dura',
|
||||
'libroWireoTapaBlanda' => 'Wire-o tapa blanda',
|
||||
'libroGrapado' => 'Grapado',
|
||||
],
|
||||
|
||||
'validation' => [
|
||||
'decimal' => 'El campo {field} debe contener un número decimal.',
|
||||
|
||||
@ -26,20 +26,26 @@ return [
|
||||
// System sections
|
||||
'clientesSection' => 'Clientes',
|
||||
'plantillaTarifaSection' => 'Plantilla de tarifas',
|
||||
'perfilSection' => 'Perfil',
|
||||
'presupuestoSection' => 'Presupuestos',
|
||||
'presupuestoClienteSection' => 'Presupuestos',
|
||||
'tarifaPreimpresionSection' => 'Tarifas de preimpresión',
|
||||
'tarifaManipuladoSection' => 'Tarifas de manipulado',
|
||||
'tarifaAcabadoSection' => 'Tarifas de acabado',
|
||||
'tarifaEncuadernacionSection' => 'Tarifas de encuadernación',
|
||||
'tarifaEnvioSection' => 'Tarifas de envio',
|
||||
'tarifaExtraSection' => 'Tarifas extra',
|
||||
'proveedoresSection' => 'Proveedores',
|
||||
'paisesSection' => 'Países',
|
||||
'formasPagoSection' => 'Formas de Pago',
|
||||
'maquinasSection' => 'Máquinas',
|
||||
'maquinasDefectoSection' => 'Máquinas por defecto',
|
||||
'papelGenericoSection' => 'Papel genérico',
|
||||
'papelImpresionSection' => 'Papel impresión',
|
||||
'usuariosSection' => 'Usuarios',
|
||||
'rolesPermisosSection' => 'Roles y permisos',
|
||||
'ubicacionesSection' => 'Ubicaciones',
|
||||
'seriesFacturasSection' => 'Series facturas',
|
||||
'ajustesSection' => 'Ajustes',
|
||||
'actividadSection' => 'Accesos',
|
||||
|
||||
|
||||
24
ci4/app/Language/es/SeriesFacturas.php
Normal file
24
ci4/app/Language/es/SeriesFacturas.php
Normal file
@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
|
||||
return [
|
||||
'id' => 'ID',
|
||||
'moduleTitle' => 'Series Facturas',
|
||||
'nombre' => 'Nombre',
|
||||
'tipo' => 'Tipo',
|
||||
'formato' => 'Formato',
|
||||
'next' => 'Próxima',
|
||||
'grupo' => 'Grupo',
|
||||
'validation' => [
|
||||
'id' => [
|
||||
'max_length' => 'El campo {field} no puede exceder {param} caracteres en longitud.',
|
||||
],
|
||||
|
||||
'nombre' => [
|
||||
'max_length' => 'El campo {field} no puede exceder {param} caracteres en longitud.',
|
||||
'required' => 'El campo {field} es obligatorio.',
|
||||
],
|
||||
|
||||
],
|
||||
|
||||
];
|
||||
@ -6,8 +6,9 @@ return [
|
||||
'id' => 'ID',
|
||||
'moduleTitle' => 'Tarifa Acabado Líneas',
|
||||
'deleteLine' => 'el registro seleccionado',
|
||||
'precioMax' => 'Precio Max',
|
||||
'precioMin' => 'Precio Min',
|
||||
'proveedor' => 'Proveedor',
|
||||
'precioMax' => 'Precio T. Mín',
|
||||
'precioMin' => 'Precio T. Máx',
|
||||
'precioUnidad' => 'Precio Unidad',
|
||||
'tiradaMax' => 'Tirada Max',
|
||||
'tiradaMin' => 'Tirada Min',
|
||||
|
||||
@ -6,8 +6,8 @@ return [
|
||||
'id' => 'ID',
|
||||
'moduleTitle' => 'Tarifa Manipulado Lineas',
|
||||
'deleteLine' => 'el registro seleccionado',
|
||||
'precioMax' => 'Precio Max',
|
||||
'precioMin' => 'Precio Min',
|
||||
'precioMax' => 'Precio T. Mín',
|
||||
'precioMin' => 'Precio T. Máx',
|
||||
'precioUnidad' => 'Precio Unidad',
|
||||
'tiradaMax' => 'Tirada Max',
|
||||
'tiradaMin' => 'Tirada Min',
|
||||
|
||||
@ -10,9 +10,10 @@ return [
|
||||
'id' => 'ID',
|
||||
'moduleTitle' => 'Tarifas Encuadernación',
|
||||
'nombre' => 'Nombre',
|
||||
'precioMax' => 'Precio Max',
|
||||
'precioMin' => 'Precio Min',
|
||||
'precioMax' => 'Precio T. Mín',
|
||||
'precioMin' => 'Precio T. Máx',
|
||||
'importeFijo' => 'Importe Fijo',
|
||||
'importeMin' => 'Importe mínimo',
|
||||
'tarifaencuadernacion' => 'Tarifa Encuadernación',
|
||||
'tarifaencuadernacionList' => 'Lista Tarifas Encuadernación',
|
||||
'tarifasencuadernacion' => 'Tarifas Encuadernación',
|
||||
|
||||
@ -10,8 +10,8 @@ return [
|
||||
'id' => 'ID',
|
||||
'moduleTitle' => 'Tarifas Manipulado',
|
||||
'nombre' => 'Nombre',
|
||||
'precioMax' => 'Precio Max',
|
||||
'precioMin' => 'Precio Min',
|
||||
'precioMax' => 'Precio T. Mín',
|
||||
'precioMin' => 'Precio T. Máx',
|
||||
'importeFijo' => 'Importe Fijo',
|
||||
'mostrar_en_presupuesto' => 'Mostrar en presupuesto',
|
||||
'tarifamanipulado' => 'Tarifa Manipulado',
|
||||
|
||||
21
ci4/app/Language/es/Ubicaciones.php
Normal file
21
ci4/app/Language/es/Ubicaciones.php
Normal file
@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
|
||||
|
||||
return [
|
||||
'id' => 'ID',
|
||||
'moduleTitle' => 'Ubicaciones',
|
||||
'nombre' => 'Nombre',
|
||||
'validation' => [
|
||||
'id' => [
|
||||
'max_length' => 'El campo {field} no puede exceder {param} caracteres en longitud.',
|
||||
],
|
||||
|
||||
'nombre' => [
|
||||
'max_length' => 'El campo {field} no puede exceder {param} caracteres en longitud.',
|
||||
'required' => 'El campo {field} es obligatorio.',
|
||||
],
|
||||
|
||||
],
|
||||
|
||||
];
|
||||
@ -38,6 +38,23 @@ return [
|
||||
'userList' => 'Lista de usuarios',
|
||||
'users' => 'Usuarios',
|
||||
'zipCode' => 'Código postal',
|
||||
|
||||
'admin' => 'Administrador',
|
||||
'cliente-admin' => 'Cliente administrador',
|
||||
'cliente-editor' => 'Cliente editor',
|
||||
'comercial' => 'Comercial',
|
||||
'produccion' => 'Producción',
|
||||
'maquina' => 'Máquina',
|
||||
'maquetador' => 'Maquetador',
|
||||
'director' => 'Director',
|
||||
'contabilidad' => 'Contabilidad',
|
||||
'editor' => 'Editor',
|
||||
'beta' => 'Beta',
|
||||
|
||||
'errors' => [
|
||||
'cliente_sin_clienteID' => 'El usuario debe de tener un cliente asignado cuando se usa algún rol de cliente.',
|
||||
],
|
||||
|
||||
'validation' => [
|
||||
'address' => [
|
||||
'max_length' => 'El campo {field} no puede exceder {param} caracteres en longitud.',
|
||||
@ -136,18 +153,6 @@ return [
|
||||
|
||||
],
|
||||
|
||||
'tfa_code' => [
|
||||
'max_length' => 'El campo {field} no puede exceder {param} caracteres en longitud.',
|
||||
'required' => 'El campo {field} es obligatorio.',
|
||||
|
||||
],
|
||||
|
||||
'tfa_secret' => [
|
||||
'max_length' => 'El campo {field} no puede exceder {param} caracteres en longitud.',
|
||||
'required' => 'El campo {field} es obligatorio.',
|
||||
|
||||
],
|
||||
|
||||
'email' => [
|
||||
'max_length' => 'El campo {field} no puede exceder {param} caracteres en longitud.',
|
||||
'required' => 'El campo {field} es obligatorio.',
|
||||
|
||||
@ -141,6 +141,25 @@ class ClienteDireccionesModel extends \App\Models\BaseModel
|
||||
|
||||
return $builder->get()->getResultObject();
|
||||
}
|
||||
|
||||
public function getIdForPresupuestoCliente($cliente_id = -1, $att = "", $email = "", $direccion = "", $cp = "", $pais_id = -1, $telefono = "")
|
||||
{
|
||||
$builder = $this->db
|
||||
->table($this->table . " t1")
|
||||
->select("t1.id AS id")
|
||||
->where("t1.cliente_id", $cliente_id)
|
||||
->where("t1.att", $att)
|
||||
->where("t1.email", $email)
|
||||
->where("t1.direccion", $direccion)
|
||||
->where("t1.cp", $cp)
|
||||
->where("t1.pais_id", $pais_id)
|
||||
->where("t1.telefono", $telefono)
|
||||
->limit(1);
|
||||
|
||||
|
||||
return $builder->get()->getResultObject();
|
||||
}
|
||||
|
||||
|
||||
|
||||
public function getMenuDirecciones($cliente_id=-1){
|
||||
|
||||
@ -257,7 +257,7 @@ class ClienteModel extends \App\Models\BaseModel
|
||||
LEFT JOIN lg_paises t4 ON t1.pais_id = t4.id
|
||||
LEFT JOIN users t5 ON t1.comercial_id = t5.id
|
||||
LEFT JOIN users t6 ON t1.soporte_id = t6.id
|
||||
LEFT JOIN lg_formas_pago t7 ON t1.forma_pago_id = t7.id";
|
||||
LEFT JOIN formas_pago t7 ON t1.forma_pago_id = t7.id";
|
||||
if (!is_null($limit) && intval($limit) > 0) {
|
||||
$sql .= " LIMIT " . intval($limit);
|
||||
}
|
||||
@ -287,7 +287,7 @@ class ClienteModel extends \App\Models\BaseModel
|
||||
)
|
||||
->where("is_deleted", 0);;
|
||||
$builder->join("users t5", "t1.comercial_id = t5.id", "left");
|
||||
$builder->join("lg_formas_pago t7", "t1.forma_pago_id = t7.id", "left");
|
||||
$builder->join("formas_pago t7", "t1.forma_pago_id = t7.id", "left");
|
||||
|
||||
|
||||
return empty($search)
|
||||
@ -308,4 +308,28 @@ class ClienteModel extends \App\Models\BaseModel
|
||||
->orLike("t7.nombre", $search)
|
||||
->groupEnd();
|
||||
}
|
||||
|
||||
/*
|
||||
TO-DO: Implementar la lógica de negocio para el crédito disponible
|
||||
*/
|
||||
public function creditoDisponible($cliente_id){
|
||||
return true;
|
||||
}
|
||||
|
||||
public function getClienteDataFacturas($cliente_id){
|
||||
$builder = $this->db
|
||||
->table($this->table . " t1")
|
||||
->select(
|
||||
"
|
||||
t1.nombre AS cliente_nombre, t1.direccion AS cliente_address, t1.cif AS cliente_cif,
|
||||
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.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");
|
||||
|
||||
return $builder->get()->getResultArray();
|
||||
}
|
||||
}
|
||||
|
||||
@ -15,7 +15,7 @@ class Collection
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function datatable(array $data, int $recordsTotal, int $recordsFiltered, string $error = null)
|
||||
public static function datatable(array $data, int $recordsTotal, int $recordsFiltered, string $error = null, $extra_data = [])
|
||||
{
|
||||
$draw = 1;
|
||||
$req = service('request');
|
||||
@ -38,6 +38,10 @@ class Collection
|
||||
$response['error'] = $error;
|
||||
}
|
||||
|
||||
if (count($extra_data)>0) {
|
||||
$response['extra'] = $extra_data;
|
||||
}
|
||||
|
||||
return $response;
|
||||
}
|
||||
}
|
||||
@ -3,7 +3,7 @@ namespace App\Models\Configuracion;
|
||||
|
||||
class FormaPagoModel extends \App\Models\BaseModel
|
||||
{
|
||||
protected $table = "lg_formas_pago";
|
||||
protected $table = "formas_pago";
|
||||
|
||||
/**
|
||||
* Whether primary key uses auto increment.
|
||||
@ -15,8 +15,6 @@ class FormaPagoModel extends \App\Models\BaseModel
|
||||
const SORTABLE = [
|
||||
1 => "t1.id",
|
||||
2 => "t1.nombre",
|
||||
3 => "t1.created_at",
|
||||
4 => "t1.updated_at",
|
||||
];
|
||||
|
||||
protected $allowedFields = ["nombre"];
|
||||
@ -26,18 +24,30 @@ class FormaPagoModel extends \App\Models\BaseModel
|
||||
|
||||
protected $validationRules = [
|
||||
"nombre" => [
|
||||
"label" => "FormasPagoes.nombre",
|
||||
"label" => "FormasPago.nombre",
|
||||
"rules" => "trim|required|max_length[255]",
|
||||
],
|
||||
];
|
||||
|
||||
protected $validationMessages = [
|
||||
"nombre" => [
|
||||
"max_length" => "FormasPagoes.validation.nombre.max_length",
|
||||
"required" => "FormasPagoes.validation.nombre.required",
|
||||
"max_length" => "FormasPago.validation.nombre.max_length",
|
||||
"required" => "FormasPago.validation.nombre.required",
|
||||
],
|
||||
];
|
||||
|
||||
public function getMenuItems(){
|
||||
$items = $this->findAll();
|
||||
$menuItems = [];
|
||||
foreach ($items as $item) {
|
||||
$menuItems[] = [
|
||||
"value" => $item->id,
|
||||
"label" => $item->nombre,
|
||||
];
|
||||
}
|
||||
return $menuItems;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get resource data.
|
||||
*
|
||||
@ -49,7 +59,7 @@ class FormaPagoModel extends \App\Models\BaseModel
|
||||
{
|
||||
$builder = $this->db
|
||||
->table($this->table . " t1")
|
||||
->select("t1.id AS id, t1.nombre AS nombre, t1.created_at AS created_at, t1.updated_at AS updated_at");
|
||||
->select("t1.id AS id, t1.nombre AS nombre");
|
||||
|
||||
return empty($search)
|
||||
? $builder
|
||||
@ -57,12 +67,6 @@ class FormaPagoModel extends \App\Models\BaseModel
|
||||
->groupStart()
|
||||
->like("t1.id", $search)
|
||||
->orLike("t1.nombre", $search)
|
||||
->orLike("t1.created_at", $search)
|
||||
->orLike("t1.updated_at", $search)
|
||||
->orLike("t1.id", $search)
|
||||
->orLike("t1.nombre", $search)
|
||||
->orLike("t1.created_at", $search)
|
||||
->orLike("t1.updated_at", $search)
|
||||
->groupEnd();
|
||||
}
|
||||
}
|
||||
|
||||
126
ci4/app/Models/Configuracion/SeriesFacturasModel.php
Normal file
126
ci4/app/Models/Configuracion/SeriesFacturasModel.php
Normal file
@ -0,0 +1,126 @@
|
||||
<?php
|
||||
namespace App\Models\Configuracion;
|
||||
|
||||
class SeriesFacturasModel extends \App\Models\BaseModel
|
||||
{
|
||||
protected $table = "series";
|
||||
|
||||
/**
|
||||
* Whether primary key uses auto increment.
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
protected $useAutoIncrement = true;
|
||||
|
||||
const SORTABLE = [
|
||||
1 => "t1.id",
|
||||
2 => "t1.nombre",
|
||||
3 => "t1.tipo",
|
||||
4 => "t1.formato",
|
||||
5 => "t1.next",
|
||||
6 => "t1.grupo"
|
||||
];
|
||||
|
||||
protected $allowedFields = ["nombre", "tipo", "formato", "next", "grupo"];
|
||||
protected $returnType = "App\Entities\Configuracion\SeriesFacturasEntity";
|
||||
|
||||
public static $labelField = "nombre";
|
||||
|
||||
protected $validationRules = [
|
||||
"nombre" => [
|
||||
"label" => "SeriesFacturas.nombre",
|
||||
"rules" => "trim|required|max_length[255]",
|
||||
],
|
||||
"tipo" => [
|
||||
"label" => "SeriesFacturas.tipo",
|
||||
"rules" => "required",
|
||||
],
|
||||
"formato" => [
|
||||
"label" => "SeriesFacturas.nombre",
|
||||
"rules" => "trim|required|max_length[255]",
|
||||
],
|
||||
"next" => [
|
||||
"label" => "SeriesFacturas.next",
|
||||
"rules" => "required",
|
||||
]
|
||||
];
|
||||
|
||||
protected $validationMessages = [
|
||||
"nombre" => [
|
||||
"max_length" => "SeriesFacturas.validation.nombre.max_length",
|
||||
"required" => "SeriesFacturas.validation.nombre.required",
|
||||
],
|
||||
"tipo" => [
|
||||
"required" => "SeriesFacturas.validation.tipo.required",
|
||||
],
|
||||
"formato" => [
|
||||
"max_length" => "SeriesFacturas.validation.formato.max_length",
|
||||
"required" => "SeriesFacturas.validation.formato.required",
|
||||
],
|
||||
"next" => [
|
||||
"required" => "SeriesFacturas.validation.next.required",
|
||||
],
|
||||
|
||||
];
|
||||
|
||||
/**
|
||||
* Get resource data.
|
||||
*
|
||||
* @param string $search
|
||||
*
|
||||
* @return \CodeIgniter\Database\BaseBuilder
|
||||
*/
|
||||
public function getResource(string $search = "")
|
||||
{
|
||||
$builder = $this->db
|
||||
->table($this->table . " t1")
|
||||
->select(
|
||||
"t1.id AS id, t1.nombre AS nombre, t1.tipo AS tipo, t1.formato AS formato,
|
||||
t1.next AS next, t1.grupo AS grupo"
|
||||
);
|
||||
|
||||
return empty($search)
|
||||
? $builder
|
||||
: $builder
|
||||
->groupStart()
|
||||
->like("t1.id", $search)
|
||||
->orLike("t1.nombre", $search)
|
||||
->orLike("t1.tipo", $search)
|
||||
->orLike("t1.formato", $search)
|
||||
->orLike("t1.next", $search)
|
||||
->orLike("t1.grupo", $search)
|
||||
->groupEnd();
|
||||
}
|
||||
|
||||
public function getMenuItemsFacturas(){
|
||||
|
||||
$resultSorting = $this->getPrimaryKeyName();
|
||||
|
||||
$id = 'id AS id';
|
||||
$text = 'nombre AS text';
|
||||
|
||||
$queryBuilder = $this->db->table($this->table);
|
||||
$queryBuilder->select([$id, $text]);
|
||||
$queryBuilder->where('tipo', 'facturacion');
|
||||
$queryBuilder->where('grupo', '1');
|
||||
$queryBuilder->orderBy($resultSorting);
|
||||
$result = $queryBuilder->get()->getResult();
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
public function getSerieNumerada($id)
|
||||
{
|
||||
$number = $this->db->table($this->table)
|
||||
->select("next, formato")
|
||||
->where("id", $id)
|
||||
->get()->getFirstRow();
|
||||
|
||||
$this->db->table($this->table)
|
||||
->where("id", $id)
|
||||
->set("next", $number->next + 1, false)
|
||||
->update();
|
||||
|
||||
return str_replace("{number}", $number->next, $number->formato);
|
||||
}
|
||||
}
|
||||
62
ci4/app/Models/Configuracion/UbicacionesModel.php
Normal file
62
ci4/app/Models/Configuracion/UbicacionesModel.php
Normal file
@ -0,0 +1,62 @@
|
||||
<?php
|
||||
namespace App\Models\Configuracion;
|
||||
|
||||
class UbicacionesModel extends \App\Models\BaseModel
|
||||
{
|
||||
protected $table = "ubicaciones";
|
||||
|
||||
/**
|
||||
* Whether primary key uses auto increment.
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
protected $useAutoIncrement = true;
|
||||
|
||||
const SORTABLE = [
|
||||
1 => "t1.id",
|
||||
2 => "t1.nombre"
|
||||
];
|
||||
|
||||
protected $allowedFields = ["nombre"];
|
||||
protected $returnType = "App\Entities\Configuracion\UbicacionesEntity";
|
||||
|
||||
public static $labelField = "nombre";
|
||||
|
||||
protected $validationRules = [
|
||||
"nombre" => [
|
||||
"label" => "Paises.nombre",
|
||||
"rules" => "trim|required|max_length[255]",
|
||||
]
|
||||
];
|
||||
|
||||
protected $validationMessages = [
|
||||
"nombre" => [
|
||||
"max_length" => "Paises.validation.nombre.max_length",
|
||||
"required" => "Paises.validation.nombre.required",
|
||||
]
|
||||
];
|
||||
|
||||
/**
|
||||
* Get resource data.
|
||||
*
|
||||
* @param string $search
|
||||
*
|
||||
* @return \CodeIgniter\Database\BaseBuilder
|
||||
*/
|
||||
public function getResource(string $search = "")
|
||||
{
|
||||
$builder = $this->db
|
||||
->table($this->table . " t1")
|
||||
->select(
|
||||
"t1.id AS id, t1.nombre AS nombre"
|
||||
);
|
||||
|
||||
return empty($search)
|
||||
? $builder
|
||||
: $builder
|
||||
->groupStart()
|
||||
->like("t1.id", $search)
|
||||
->orLike("t1.nombre", $search)
|
||||
->groupEnd();
|
||||
}
|
||||
}
|
||||
171
ci4/app/Models/Facturas/FacturaLineaModel.php
Normal file
171
ci4/app/Models/Facturas/FacturaLineaModel.php
Normal file
@ -0,0 +1,171 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Facturas;
|
||||
|
||||
|
||||
class FacturaLineaModel extends \App\Models\BaseModel {
|
||||
|
||||
protected $table = 'facturas_lineas';
|
||||
|
||||
// Lista de columnas basada en los campos de la tabla, para asignación masiva
|
||||
protected $allowedFields = [
|
||||
'factura_id',
|
||||
'pedido_linea_impresion_id',
|
||||
'pedido_maquetacion_id',
|
||||
'descripcion',
|
||||
'cantidad',
|
||||
'precio_unidad',
|
||||
'iva',
|
||||
'base',
|
||||
'total_iva',
|
||||
'total',
|
||||
'data',
|
||||
'deleted_at',
|
||||
'user_updated_id'
|
||||
];
|
||||
|
||||
protected $returnType = "App\Entities\Facturas\FacturaLineaEntity";
|
||||
|
||||
protected $useTimestamps = false;
|
||||
protected $useSoftDeletes = true;
|
||||
|
||||
public static $labelField = "id";
|
||||
|
||||
public function getResource($factura_id)
|
||||
{
|
||||
$builder = $this->db
|
||||
->table($this->table . " t1")
|
||||
->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.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,
|
||||
t6.cantidad AS cantidad_albaran"
|
||||
)
|
||||
->join("pedidos_linea t2", "t2.id = t1.pedido_linea_impresion_id", "left")
|
||||
->join("presupuestos t3", "t3.id = t2.presupuesto_id", "left")
|
||||
->join("clientes t4", "t4.id = t3.cliente_id", "left")
|
||||
->join("albaranes t5", "t5.pedido_id = t2.pedido_id", "left")
|
||||
->join("albaranes_lineas t6", "t6.albaran_id = t5.id", "left")
|
||||
->where("t1.factura_id", $factura_id)
|
||||
->where("t1.deleted_at", null);
|
||||
|
||||
return $builder;
|
||||
}
|
||||
|
||||
|
||||
public function getResourceResumenIVAsForPdf($factura_id = -1)
|
||||
{
|
||||
$builder = $this->db
|
||||
->table($this->table . " t1")
|
||||
->select(
|
||||
"t1.iva,
|
||||
ROUND(SUM(t1.base), 2) AS base,
|
||||
ROUND(SUM(t1.total_iva), 2) AS total_iva,
|
||||
ROUND(SUM(t1.total), 2) AS total"
|
||||
)
|
||||
->where("t1.factura_id", $factura_id)
|
||||
->where("t1.deleted_at", null)
|
||||
->groupBy('t1.iva')
|
||||
->orderBy('t1.iva', 'ASC'); // Ordena por iva en forma ascendente
|
||||
|
||||
return $builder;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get resource data for creating PDFs.
|
||||
*
|
||||
* @param string $search
|
||||
*
|
||||
* @return \CodeIgniter\Database\BaseBuilder
|
||||
*/
|
||||
public function getResourceForPdf($factura_id = -1)
|
||||
{
|
||||
$builder = $this->db
|
||||
->table($this->table . " t1")
|
||||
->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.base AS base, t1.total_iva AS total_iva, t1.total AS total, t1.data AS data"
|
||||
)
|
||||
->where("t1.factura_id", $factura_id)
|
||||
->where("t1.deleted_at", null);
|
||||
|
||||
return $builder;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get resource data for creating PDFs.
|
||||
*
|
||||
* @param string $search
|
||||
*
|
||||
* @return \CodeIgniter\Database\BaseBuilder
|
||||
*/
|
||||
public function getResourceForExcel($factura_id = -1)
|
||||
{
|
||||
$builder = $this->db
|
||||
->table($this->table . " t1")
|
||||
->select(
|
||||
"t2.numero AS ref_factura,
|
||||
t3.pedido_id AS pedido_id,
|
||||
t4.referencia_cliente AS referencia_cliente,
|
||||
t1.base AS base"
|
||||
)
|
||||
->join("facturas t2", "t2.id = t1.factura_id", "left")
|
||||
->join("pedidos_linea t3", "t3.id = t1.pedido_linea_impresion_id", "left")
|
||||
->join("presupuestos t4", "t4.id = t3.presupuesto_id", "left")
|
||||
->where("t1.factura_id", $factura_id)
|
||||
->where("t1.deleted_at", null);
|
||||
|
||||
return $builder;
|
||||
}
|
||||
|
||||
|
||||
public function addFacturaPedidoLinea($factura_id, $pedido_linea_id, $cantidad)
|
||||
{
|
||||
$data = [
|
||||
"factura_id" => $factura_id,
|
||||
"pedido_linea_id" => $pedido_linea_id,
|
||||
"cantidad" => $cantidad
|
||||
];
|
||||
|
||||
return $this->db->table("facturas_pedidos_lineas")->insert($data);
|
||||
}
|
||||
|
||||
public function deleteFacturasLineasPedido($factura_id, $pedido_linea_id, $cantidad){
|
||||
|
||||
$this->db->table("facturas_pedidos_lineas")
|
||||
->where("factura_id", $factura_id)
|
||||
->where("pedido_linea_id", $pedido_linea_id)
|
||||
->where("cantidad", $cantidad)
|
||||
->delete();
|
||||
}
|
||||
|
||||
public function updateFacturaPedidoLinea($factura_id, $pedido_linea_id, $cantidad, $cantidad_new)
|
||||
{
|
||||
// Obtener la ID del registro que queremos actualizar
|
||||
$record = $this->db->table("facturas_pedidos_lineas")
|
||||
->select('id')
|
||||
->where("factura_id", $factura_id)
|
||||
->where("pedido_linea_id", $pedido_linea_id)
|
||||
->where("cantidad", $cantidad)
|
||||
->limit(1)
|
||||
->get()
|
||||
->getRow();
|
||||
|
||||
// Si existe el registro
|
||||
if ($record) {
|
||||
$data = [
|
||||
"cantidad" => $cantidad_new
|
||||
];
|
||||
|
||||
// Actualizar el registro especificado por su ID
|
||||
$this->db->table("facturas_pedidos_lineas")
|
||||
->where("id", $record->id)
|
||||
->update($data);
|
||||
}
|
||||
}
|
||||
}
|
||||
182
ci4/app/Models/Facturas/FacturaModel.php
Normal file
182
ci4/app/Models/Facturas/FacturaModel.php
Normal file
@ -0,0 +1,182 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Facturas;
|
||||
|
||||
class FacturaModel extends \App\Models\BaseModel {
|
||||
|
||||
protected $table = 'facturas';
|
||||
|
||||
protected $useAutoIncrement = true;
|
||||
|
||||
const SORTABLE = [
|
||||
0 => "t1.id",
|
||||
1 => "t1.numero",
|
||||
2 => "t1.fecha_factura_at",
|
||||
3 => "t2.nombre",
|
||||
4 => "t1.base",
|
||||
5 => "t1.total",
|
||||
6 => "t1.pendiente",
|
||||
7 => "t1.creditoAsegurado",
|
||||
8 => "t1.estado",
|
||||
9 => "t1.estado_pago",
|
||||
10 => "t4.nombre",
|
||||
11 => "DAFEDIFF(days, NOW(), t3.fecha_vencimiento_at)",
|
||||
];
|
||||
|
||||
const SORTABLE_PEDIDOS = [
|
||||
1 => "t1.numero",
|
||||
2 => "t2.nombre",
|
||||
3 => "t1.estado",
|
||||
4 => "t1.fecha_factura_at",
|
||||
5 => "t1.total",
|
||||
];
|
||||
|
||||
// Lista de columnas basada en los campos de la tabla, para asignación masiva
|
||||
protected $allowedFields = [
|
||||
'pedido_id',
|
||||
'factura_rectificada_id',
|
||||
'factura_rectificativa_id',
|
||||
'cliente_id',
|
||||
'serie_id',
|
||||
'numero',
|
||||
'estado',
|
||||
'estado_pago',
|
||||
'fecha_factura_at',
|
||||
'notas',
|
||||
'base',
|
||||
'total',
|
||||
'pendiente',
|
||||
'total_pagos',
|
||||
'creditoAsegurado',
|
||||
'cliente_nombre',
|
||||
'cliente_address',
|
||||
'cliente_cif',
|
||||
'cliente_pais',
|
||||
'cliente_cp',
|
||||
'cliente_ciudad',
|
||||
'cliente_provincia',
|
||||
'created_at',
|
||||
'updated_at',
|
||||
'deleted_at',
|
||||
'user_created_id',
|
||||
'user_updated_id'
|
||||
];
|
||||
|
||||
protected $returnType = "App\Entities\Facturas\FacturaEntity";
|
||||
|
||||
protected $useTimestamps = true;
|
||||
protected $useSoftDeletes = true;
|
||||
|
||||
protected $createdField = "created_at";
|
||||
protected $updatedField = "updated_at";
|
||||
|
||||
public static $labelField = "id";
|
||||
|
||||
public function getResource(string $search = "")
|
||||
{
|
||||
$builder = $this->db
|
||||
->table($this->table . " t1")
|
||||
->select(
|
||||
"t1.id AS id, t1.numero AS numero, DATE_FORMAT(t1.fecha_factura_at, '%d/%m/%Y') AS fecha_factura_at,
|
||||
t2.nombre AS cliente, t1.base AS base, t1.total AS total, t1.pendiente AS pendiente,
|
||||
t1.creditoAsegurado AS creditoAsegurado, t1.estado AS estado, t1.estado_pago AS estado_pago,
|
||||
GROUP_CONCAT(DISTINCT t4.nombre ORDER BY t4.nombre ASC SEPARATOR ', ') AS forma_pago,
|
||||
DATE_FORMAT(MIN(CASE WHEN t3.fecha_vencimiento_at != '0000-00-00 00:00:00' THEN t3.fecha_vencimiento_at ELSE NULL END), '%d/%m/%Y') AS vencimiento,
|
||||
t2.vencimiento AS dias_vencimiento"
|
||||
);
|
||||
|
||||
$builder->join("clientes t2", "t2.id = t1.cliente_id", "left");
|
||||
$builder->join("facturas_pagos t3", "t3.factura_id = t1.id", "left");
|
||||
$builder->join("formas_pago t4", "t3.forma_pago_id = t4.id", "left");
|
||||
|
||||
$builder->where("t1.deleted_at IS NULL");
|
||||
$builder->groupBy("t1.id"); // Agrupa por id de la factura
|
||||
|
||||
return empty($search)
|
||||
? $builder
|
||||
: $builder
|
||||
->groupStart()
|
||||
->like("t1.id", $search)
|
||||
->orLike("t1.id", $search)
|
||||
->groupEnd();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get resource data for creating PDFs.
|
||||
*
|
||||
* @param string $search
|
||||
*
|
||||
* @return \CodeIgniter\Database\BaseBuilder
|
||||
*/
|
||||
public function getResourceForPdf($factura_id = -1)
|
||||
{
|
||||
$builder = $this->db
|
||||
->table($this->table . " t1")
|
||||
->select(
|
||||
"t1.id AS id, t1.numero AS numero, DATE_FORMAT(t1.fecha_factura_at, '%d/%m/%Y') AS fecha_factura_at,
|
||||
t1.base AS base, t1.total AS total, t1.pendiente AS pendiente,
|
||||
t1.creditoAsegurado AS creditoAsegurado, t1.estado AS estado, t1.estado_pago AS estado_pago,
|
||||
t4.nombre AS forma_pago,
|
||||
DATE_FORMAT(MIN(CASE WHEN t3.fecha_vencimiento_at != '0000-00-00 00:00:00' THEN t3.fecha_vencimiento_at ELSE NULL END), '%d/%m/%Y') AS vencimiento,
|
||||
t2.nombre AS cliente, t2.direccion AS cliente_direccion, t2.ciudad AS cliente_ciudad,
|
||||
t2.cp AS cliente_cp, t2.cif AS cliente_cif, t2.vencimiento AS dias_vencimiento, t2.ccc AS cliente_ccc,
|
||||
t5.nombre AS cliente_pais"
|
||||
);
|
||||
|
||||
$builder->join("clientes t2", "t2.id = t1.cliente_id", "left");
|
||||
$builder->join("facturas_pagos t3", "t3.factura_id = t1.id", "left");
|
||||
$builder->join("formas_pago t4", "t3.forma_pago_id = t4.id", "left");
|
||||
$builder->join("lg_paises t5", "t2.pais_id = t5.id", "left");
|
||||
|
||||
$builder->where("t1.id", $factura_id);
|
||||
$builder->where("t1.deleted_at IS NULL");
|
||||
$builder->groupBy("t1.id"); // Agrupa por id de la factura
|
||||
|
||||
return $builder;
|
||||
}
|
||||
|
||||
|
||||
public function getResourcePedidos($pedido_id)
|
||||
{
|
||||
$builder = $this->db
|
||||
->table($this->table . " t1")
|
||||
->select(
|
||||
"t1.id AS id, t1.numero AS numero, t2.nombre AS serie, t1.estado AS estado,
|
||||
DATE_FORMAT(t1.fecha_factura_at, '%d/%m/%Y') AS fecha_factura_at, t1.total AS total"
|
||||
);
|
||||
|
||||
$builder->join("series t2", "t2.id = t1.serie_id", "left");
|
||||
$builder->join("facturas_lineas t3", "t1.id = t3.factura_id", "left");
|
||||
$builder->join("facturas_pedidos_lineas t4", "t1.id = t4.factura_id", "left");
|
||||
$builder->join("pedidos_linea t5", "t4.pedido_linea_id = t5.id", "left");
|
||||
$builder->join("pedidos t6", "t5.pedido_id = t6.id", "left");
|
||||
|
||||
$builder->where("t1.deleted_at IS NULL");
|
||||
$builder->where("t6.id", $pedido_id);
|
||||
|
||||
$builder->groupBy("t1.id"); // Agrupa por id de la factura
|
||||
|
||||
return $builder;
|
||||
}
|
||||
|
||||
public function getCantidadLineaPedidoFacturada($linea_pedido_id)
|
||||
{
|
||||
$builder = $this->db
|
||||
->table("facturas_pedidos_lineas t1")
|
||||
->select("SUM(t1.cantidad) AS cantidad")
|
||||
->where("t1.pedido_linea_id", $linea_pedido_id);
|
||||
|
||||
return $builder->get()->getRow()->cantidad;
|
||||
}
|
||||
|
||||
public function deleteFacturasLineasPedido($factura_id, $pedido_linea_id, $cantidad)
|
||||
{
|
||||
$this->db->table("facturas_pedidos_lineas")
|
||||
->where("factura_id", $factura_id)
|
||||
->where("pedido_linea_id", $pedido_linea_id)
|
||||
->where("cantidad", $cantidad)
|
||||
->delete();
|
||||
}
|
||||
|
||||
}
|
||||
42
ci4/app/Models/Facturas/FacturaPagoModel.php
Normal file
42
ci4/app/Models/Facturas/FacturaPagoModel.php
Normal file
@ -0,0 +1,42 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Facturas;
|
||||
|
||||
class FacturaPagoModel extends \App\Models\BaseModel {
|
||||
|
||||
protected $table = 'facturas_pagos';
|
||||
|
||||
protected $allowedFields = [
|
||||
'factura_id',
|
||||
'notes',
|
||||
'fecha_pago_at',
|
||||
'fecha_vencimiento_at',
|
||||
'forma_pago_id',
|
||||
'total',
|
||||
'deleted_at',
|
||||
'user_updated_id'
|
||||
];
|
||||
|
||||
protected $returnType = "App\Entities\Facturas\FacturaPagoEntity";
|
||||
|
||||
protected $useTimestamps = false;
|
||||
protected $useSoftDeletes = true;
|
||||
|
||||
public static $labelField = "id";
|
||||
|
||||
public function getResource($factura_id)
|
||||
{
|
||||
$builder = $this->db
|
||||
->table($this->table . " t1")
|
||||
->select(
|
||||
"t1.id AS id, t1.factura_id AS factura_id,
|
||||
t1.notes AS notes, t1.fecha_pago_at AS fecha_pago_at, t1.fecha_vencimiento_at AS fecha_vencimiento_at,
|
||||
t1.forma_pago_id AS forma_pago_id, t2.nombre as forma_pago, t1.total AS total"
|
||||
)
|
||||
->join("formas_pago t2", "t2.id = t1.forma_pago_id", "left")
|
||||
->where("t1.factura_id", $factura_id)
|
||||
->where("t1.deleted_at", null);
|
||||
|
||||
return $builder;
|
||||
}
|
||||
}
|
||||
66
ci4/app/Models/Pedidos/AlbaranLineaModel.php
Normal file
66
ci4/app/Models/Pedidos/AlbaranLineaModel.php
Normal file
@ -0,0 +1,66 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Pedidos;
|
||||
|
||||
class AlbaranLineaModel extends \App\Models\BaseModel
|
||||
{
|
||||
protected $table = "albaranes_lineas";
|
||||
|
||||
/**
|
||||
* Whether primary key uses auto increment.
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
protected $useAutoIncrement = true;
|
||||
|
||||
protected $primaryKey = 'id';
|
||||
protected $returnType = 'App\Entities\Pedidos\AlbaranLineaEntity';
|
||||
protected $allowedFields = [
|
||||
'albaran_id',
|
||||
'titulo',
|
||||
'isbn',
|
||||
'ref_cliente',
|
||||
'cantidad',
|
||||
'cajas',
|
||||
'ejemplares_por_caja',
|
||||
'precio_unidad',
|
||||
'total',
|
||||
'user_created_id',
|
||||
'user_updated_id',
|
||||
'created_at',
|
||||
'updated_at',
|
||||
'deleted_at',
|
||||
];
|
||||
|
||||
protected $useSoftDeletes = true;
|
||||
protected $useTimestamps = true;
|
||||
protected $createdField = 'created_at';
|
||||
protected $updatedField = 'updated_at';
|
||||
protected $deletedField = 'deleted_at';
|
||||
|
||||
/**
|
||||
* Get resource data for creating PDFs.
|
||||
*
|
||||
* @param string $search
|
||||
*
|
||||
* @return \CodeIgniter\Database\BaseBuilder
|
||||
*/
|
||||
public function getResourceForPdf($albaran_id = -1)
|
||||
{
|
||||
$builder = $this->db
|
||||
|
||||
->table($this->table . " t1")
|
||||
->select(
|
||||
"t1.id AS id, t1.albaran_id AS albaran_id, t1.titulo AS titulo, t1.isbn AS isbn,
|
||||
t1.ref_cliente AS ref_cliente, t1.cantidad AS cantidad, t1.cajas AS cajas,
|
||||
t1.ejemplares_por_caja AS ejemplares_por_caja, t1.precio_unidad AS precio_unidad,
|
||||
t1.total AS total"
|
||||
);
|
||||
|
||||
$builder->where("t1.deleted_at IS NULL");
|
||||
$builder->where("t1.albaran_id", $albaran_id);
|
||||
|
||||
return $builder;
|
||||
}
|
||||
|
||||
}
|
||||
142
ci4/app/Models/Pedidos/AlbaranModel.php
Normal file
142
ci4/app/Models/Pedidos/AlbaranModel.php
Normal file
@ -0,0 +1,142 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Pedidos;
|
||||
|
||||
|
||||
|
||||
class AlbaranModel extends \App\Models\BaseModel
|
||||
{
|
||||
protected $table = "albaranes";
|
||||
|
||||
/**
|
||||
* Whether primary key uses auto increment.
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
protected $useAutoIncrement = true;
|
||||
|
||||
protected $primaryKey = 'id';
|
||||
protected $returnType = 'App\Entities\Pedidos\AlbaranEntity';
|
||||
protected $allowedFields = [
|
||||
'pedido_id',
|
||||
'presupuesto_id',
|
||||
'presupuesto_direccion_id',
|
||||
'cliente_id',
|
||||
'serie_id',
|
||||
'numero_albaran',
|
||||
'mostrar_precios',
|
||||
'total',
|
||||
'direccion_albaran',
|
||||
'att_albaran',
|
||||
'user_created_id',
|
||||
'user_updated_id',
|
||||
'created_at',
|
||||
'updated_at',
|
||||
'deleted_at',
|
||||
];
|
||||
|
||||
protected $useSoftDeletes = true;
|
||||
protected $useTimestamps = true;
|
||||
protected $createdField = 'created_at';
|
||||
protected $updatedField = 'updated_at';
|
||||
protected $deletedField = 'deleted_at';
|
||||
|
||||
public function generarAlbaranes($pedido_id, $presupuestos_id, $user_id){
|
||||
|
||||
$model_presupuesto = model('App\Models\Presupuestos\PresupuestoModel');
|
||||
$model_presupuesto_direcciones = model('App\Models\Presupuestos\PresupuestoDireccionesModel');
|
||||
$model_series = model('App\Models\Configuracion\SeriesFacturasModel');
|
||||
|
||||
$presupuestos = $model_presupuesto->find($presupuestos_id);
|
||||
|
||||
$return_data = [];
|
||||
|
||||
foreach ($presupuestos as $presupuesto) {
|
||||
|
||||
$envios = $model_presupuesto_direcciones->where('presupuesto_id', $presupuesto->id)->findAll();
|
||||
foreach($envios as $envio){
|
||||
|
||||
// calculo precio_unidad
|
||||
$precio_unidad = $presupuesto->total_aceptado/$presupuesto->tirada;
|
||||
|
||||
$albaran_linea = [];
|
||||
$albaran_linea = [
|
||||
'titulo' => $presupuesto->titulo,
|
||||
'isbn' => $presupuesto->isbn,
|
||||
'ref_cliente' => $presupuesto->ref_cliente,
|
||||
'cantidad' => $envio->cantidad,
|
||||
'cajas' => 1,
|
||||
'ejemplares_por_caja' => $envio->cantidad,
|
||||
'precio_unidad' => $precio_unidad,
|
||||
'total' => $precio_unidad * $envio->cantidad,
|
||||
'user_created_id' => $user_id,
|
||||
'user_updated_id' => $user_id,
|
||||
];
|
||||
|
||||
|
||||
$serie = $model_series->find(11);
|
||||
$numero_albaran = str_replace('{number}', $serie->next, $serie->formato);
|
||||
$numero_albaran = str_replace( '{year}', date("Y"), $numero_albaran);
|
||||
|
||||
$serie->next = $serie->next + 1;
|
||||
$model_series->save($serie);
|
||||
|
||||
$albaran = [
|
||||
'pedido_id' => $pedido_id,
|
||||
'presupuesto_id' => $presupuesto->id,
|
||||
'presupuesto_direccion_id' => $envio->id,
|
||||
'cliente_id' => $presupuesto->cliente_id,
|
||||
'serie_id' => 11, // Serie de albaranes
|
||||
'numero_albaran' => $numero_albaran,
|
||||
'mostrar_precios' => 0,
|
||||
'total' => $albaran_linea['total'],
|
||||
'direccion_albaran' => $envio->direccion,
|
||||
'att_albaran' => $envio->att,
|
||||
'user_created_id' => $user_id,
|
||||
'user_updated_id' => $user_id,
|
||||
'fecha_albaran' => date('d/m/Y'),
|
||||
];
|
||||
|
||||
$id_albaran = $this->insert($albaran);
|
||||
$model_albaran_linea = model('App\Models\Pedidos\AlbaranLineaModel');
|
||||
$albaran['id'] = $id_albaran;
|
||||
$albaran_linea['albaran_id'] = $id_albaran;
|
||||
$id_albaran_linea =$model_albaran_linea->insert($albaran_linea);
|
||||
$albaran_linea['id'] = $id_albaran_linea;
|
||||
|
||||
array_push($return_data, ["albaran"=>$albaran, "lineas" =>[$albaran_linea]]);
|
||||
}
|
||||
}
|
||||
|
||||
return $return_data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get resource data for creating PDFs.
|
||||
*
|
||||
* @param string $search
|
||||
*
|
||||
* @return \CodeIgniter\Database\BaseBuilder
|
||||
*/
|
||||
public function getResourceForPdf($albaran_id = -1)
|
||||
{
|
||||
$builder = $this->db
|
||||
|
||||
->table($this->table . " t1")
|
||||
->select(
|
||||
"t1.id AS id, t1.pedido_id AS pedido_id, t1.presupuesto_id AS presupuesto_id,
|
||||
t1.presupuesto_direccion_id AS presupuesto_direccion_id, t1.cliente_id AS cliente_id,
|
||||
t1.serie_id AS serie_id, t1.numero_albaran AS numero_albaran, t1.mostrar_precios AS mostrar_precios,
|
||||
t1.total AS total, t1.direccion_albaran AS direccion_albaran, t1.att_albaran AS att_albaran,
|
||||
t1.user_created_id AS user_created_id, t1.user_updated_id AS user_updated_id,
|
||||
t1.created_at AS created_at, t1.updated_at AS updated_at,
|
||||
t2.nombre AS cliente"
|
||||
);
|
||||
$builder->join("clientes t2", "t1.cliente_id = t2.id", "left");
|
||||
|
||||
$builder->where("t1.deleted_at IS NULL");
|
||||
$builder->where("t1.id", $albaran_id);
|
||||
|
||||
return $builder;
|
||||
}
|
||||
}
|
||||
220
ci4/app/Models/Pedidos/PedidoLineaModel.php
Normal file
220
ci4/app/Models/Pedidos/PedidoLineaModel.php
Normal file
@ -0,0 +1,220 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Pedidos;
|
||||
|
||||
class PedidoLineaModel extends \App\Models\BaseModel
|
||||
{
|
||||
protected $table = "pedidos_linea";
|
||||
|
||||
/**
|
||||
* Whether primary key uses auto increment.
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
protected $useAutoIncrement = true;
|
||||
|
||||
const SORTABLE = [
|
||||
0 => "t2.id",
|
||||
1 => "t2.updated_at",
|
||||
2 => "t2.fecha_entrega_real",
|
||||
3 => "t4.nombre",
|
||||
4 => "CONCAT(t5.first_name, ' ', t5.last_name)",
|
||||
5 => "t3.titulo",
|
||||
6 => "t6.nombre",
|
||||
7 => "t3.inc_rei",
|
||||
8 => "t3.paginas",
|
||||
9 => "t3.tirada",
|
||||
10 => "t3.total_aceptado",
|
||||
11 => "t2.estado"
|
||||
];
|
||||
|
||||
protected $allowedFields = [
|
||||
"pedido_id",
|
||||
"presupuesto_id",
|
||||
"ubicacion_id",
|
||||
"user_created_id",
|
||||
"user_updated_id",
|
||||
"created_at",
|
||||
"updated_at",
|
||||
];
|
||||
protected $returnType = "App\Entities\Pedidos\PedidoLineaEntity";
|
||||
|
||||
protected $useTimestamps = true;
|
||||
protected $useSoftDeletes = false;
|
||||
|
||||
protected $createdField = "created_at";
|
||||
protected $updatedField = "updated_at";
|
||||
|
||||
public static $labelField = "id";
|
||||
|
||||
|
||||
public function getResource($search = [], $estado="")
|
||||
{
|
||||
$builder = $this->db
|
||||
->table($this->table . " t1")
|
||||
->select(
|
||||
"t2.id AS id, t2.updated_at AS fecha, t2.fecha_entrega_real AS fecha_entrega,
|
||||
t4.nombre AS cliente, CONCAT(t5.first_name, ' ', t5.last_name) AS comercial,
|
||||
t3.titulo AS titulo, t6.nombre AS ubicacion, t3.inc_rei AS inc_rei,
|
||||
t3.paginas AS paginas, t3.tirada AS tirada, t3.total_aceptado AS total_presupuesto,
|
||||
t2.estado AS estado"
|
||||
);
|
||||
|
||||
$builder->join("pedidos t2", "t2.id = t1.pedido_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($estado != "") {
|
||||
if($estado == "activo") {
|
||||
$sql = "t2.estado = 'validacion' OR t2.estado = 'produccion'";
|
||||
$builder->where($sql);
|
||||
} else {
|
||||
$builder->where("t2.estado", $estado);
|
||||
}
|
||||
}
|
||||
|
||||
if (empty($search))
|
||||
return $builder;
|
||||
else {
|
||||
$builder->groupStart();
|
||||
foreach ($search as $col_search) {
|
||||
if ($col_search[0] != 1 && $col_search[0] != 2)
|
||||
$builder->like(self::SORTABLE[$col_search[0]], $col_search[2]);
|
||||
else {
|
||||
$dates = explode(" ", $col_search[2]);
|
||||
$builder->where(self::SORTABLE[$col_search[0]] . ">=", $dates[0]);
|
||||
$builder->where(self::SORTABLE[$col_search[0]] . "<=", $dates[1]);
|
||||
}
|
||||
}
|
||||
$builder->groupEnd();
|
||||
return $builder;
|
||||
}
|
||||
}
|
||||
|
||||
public function getSumOfTirada(array $search, $estado = '', $start = 0, $length = 5)
|
||||
{
|
||||
|
||||
$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");
|
||||
|
||||
|
||||
|
||||
// Aplica los filtros de búsqueda y estado
|
||||
if (!empty($search)) {
|
||||
$builder->groupStart();
|
||||
foreach ($search as $col_search) {
|
||||
if ($col_search[0] != 1 && $col_search[0] != 2)
|
||||
$builder->like(self::SORTABLE[$col_search[0]], $col_search[2]);
|
||||
else {
|
||||
$dates = explode(" ", $col_search[2]);
|
||||
$builder->where(self::SORTABLE[$col_search[0]] . ">=", $dates[0]);
|
||||
$builder->where(self::SORTABLE[$col_search[0]] . "<=", $dates[1]);
|
||||
}
|
||||
}
|
||||
$builder->groupEnd();
|
||||
}
|
||||
|
||||
if ($estado !== '') {
|
||||
$builder->where('estado', $estado);
|
||||
}
|
||||
|
||||
// Aplicar el orden y el límite
|
||||
$builder->limit($length, $start);
|
||||
|
||||
return $builder->get()->getRow()->total_tirada;
|
||||
}
|
||||
|
||||
public function getSumOfTotalAceptado(array $search, $estado = '', $start = 0, $length = 5)
|
||||
{
|
||||
|
||||
$builder = $this->db
|
||||
->table($this->table . " t1")
|
||||
->selectSum('t3.total_aceptado', 'total');
|
||||
|
||||
$builder->join("pedidos t2", "t2.id = t1.pedido_id", "left");
|
||||
$builder->join("presupuestos t3", "t1.presupuesto_id = t3.id", "left");
|
||||
|
||||
|
||||
|
||||
// Aplica los filtros de búsqueda y estado
|
||||
if (!empty($search)) {
|
||||
$builder->groupStart();
|
||||
foreach ($search as $col_search) {
|
||||
if ($col_search[0] != 1 && $col_search[0] != 2)
|
||||
$builder->like(self::SORTABLE[$col_search[0]], $col_search[2]);
|
||||
else {
|
||||
$dates = explode(" ", $col_search[2]);
|
||||
$builder->where(self::SORTABLE[$col_search[0]] . ">=", $dates[0]);
|
||||
$builder->where(self::SORTABLE[$col_search[0]] . "<=", $dates[1]);
|
||||
}
|
||||
}
|
||||
$builder->groupEnd();
|
||||
}
|
||||
|
||||
if ($estado !== '') {
|
||||
$builder->where('estado', $estado);
|
||||
}
|
||||
|
||||
// Aplicar el orden y el límite
|
||||
$builder
|
||||
->limit($length, $start);
|
||||
|
||||
return $builder->get()->getRow()->total;
|
||||
}
|
||||
|
||||
public function getTotalOfTotalAceptado()
|
||||
{
|
||||
|
||||
$builder = $this->db
|
||||
->table($this->table . " t1")
|
||||
->selectSum('t3.total_aceptado', 'total');
|
||||
|
||||
$builder->join("pedidos t2", "t2.id = t1.pedido_id", "left");
|
||||
$builder->join("presupuestos t3", "t1.presupuesto_id = t3.id", "left");
|
||||
|
||||
|
||||
return $builder->get()->getRow()->total;
|
||||
}
|
||||
|
||||
public function obtenerLineasPedidoSinFacturar($cliente_id) {
|
||||
$resultaArray = [];
|
||||
|
||||
$subquery = $this->db
|
||||
->table('facturas_pedidos_lineas')
|
||||
->select('pedido_linea_id, SUM(cantidad) AS total_cantidad')
|
||||
->groupBy('pedido_linea_id')
|
||||
->getCompiledSelect();
|
||||
|
||||
$builder = $this->db
|
||||
->table($this->table . " t1")
|
||||
->select("t1.id AS id, t1.pedido_id AS pedido_id, t3.titulo AS titulo, t4.codigo AS tipo_impresion")
|
||||
->join("pedidos t2", "t2.id = t1.pedido_id", "left")
|
||||
->join("presupuestos t3", "t3.id = t1.presupuesto_id", "left")
|
||||
->join("tipos_presupuestos t4", "t4.id = t3.tipo_impresion_id", "left")
|
||||
->join("($subquery) fpl", "fpl.pedido_linea_id = t1.id", "left")
|
||||
->where("t3.cliente_id", $cliente_id)
|
||||
->where("t2.estado", "finalizado")
|
||||
->where("(t3.tirada > IFNULL(fpl.total_cantidad, 0))");
|
||||
|
||||
// Ejecutar la consulta y devolver resultados
|
||||
$query = $builder->get();
|
||||
$data = $query->getResult();
|
||||
|
||||
foreach($data as $register) {
|
||||
$item = (object)[
|
||||
'id' => $register->id,
|
||||
'text' => '['. lang('Pedidos.pedido') . ' ' . $register->pedido_id . '] ' . $register->titulo . ' - ' . lang('Presupuestos.' . $register->tipo_impresion),
|
||||
];
|
||||
array_push($resultaArray, $item);
|
||||
}
|
||||
|
||||
return $resultaArray;
|
||||
}
|
||||
|
||||
}
|
||||
88
ci4/app/Models/Pedidos/PedidoModel.php
Normal file
88
ci4/app/Models/Pedidos/PedidoModel.php
Normal file
@ -0,0 +1,88 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Pedidos;
|
||||
|
||||
class PedidoModel extends \App\Models\BaseModel
|
||||
{
|
||||
protected $table = "pedidos";
|
||||
|
||||
/**
|
||||
* Whether primary key uses auto increment.
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
protected $useAutoIncrement = true;
|
||||
|
||||
const SORTABLE_TODOS = [
|
||||
0 => "t1.id",
|
||||
1 => "t1.updated_at",
|
||||
2 => "t1.fecha_entrega_real",
|
||||
3 => "t4.nombre",
|
||||
4 => "t5.first_name",
|
||||
5 => "t3.titulo",
|
||||
6 => "t6.ubicacion",
|
||||
7 => "t3.inc_rei",
|
||||
8 => "t3.paginas",
|
||||
9 => "t3.tirada",
|
||||
10 => "t3.total_aceptado",
|
||||
11 => "t1.estado"
|
||||
];
|
||||
|
||||
protected $allowedFields = [
|
||||
"total_precio",
|
||||
"total_tirada",
|
||||
"estado",
|
||||
"user_created_id",
|
||||
"user_updated_id",
|
||||
"user_validated_id",
|
||||
"fecha_entrega_real",
|
||||
"fecha_impresion",
|
||||
"fecha_encuadernado",
|
||||
"fecha_entrega_externo",
|
||||
"created_at",
|
||||
"updated_at",
|
||||
"validated_at",
|
||||
];
|
||||
protected $returnType = "App\Entities\Pedidos\PedidoEntity";
|
||||
|
||||
protected $useTimestamps = true;
|
||||
protected $useSoftDeletes = false;
|
||||
|
||||
protected $createdField = "created_at";
|
||||
protected $updatedField = "updated_at";
|
||||
|
||||
public static $labelField = "id";
|
||||
|
||||
public function obtenerDatosForm($pedido_id){
|
||||
$builder = $this->db
|
||||
->table($this->table . " t1")
|
||||
->select(
|
||||
"t4.id AS cliente_id, t4.nombre AS cliente, CONCAT(t5.first_name, ' ', t5.last_name) AS comercial");
|
||||
|
||||
$builder->join("pedidos_linea t2", "t2.pedido_id = t1.id", "left");
|
||||
$builder->join("presupuestos t3", "t2.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");
|
||||
|
||||
|
||||
return $builder->get()->getResultObject();
|
||||
}
|
||||
|
||||
public function obtenerLineasPedido($pedido_id){
|
||||
$builder = $this->db
|
||||
->table($this->table . " t1")
|
||||
->select(
|
||||
"t2.presupuesto_id"
|
||||
);
|
||||
$builder->where("t1.id", $pedido_id);
|
||||
$builder->join("pedidos_linea t2", "t2.pedido_id = t1.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]);
|
||||
}
|
||||
|
||||
return $lineasPresupuesto;
|
||||
}
|
||||
}
|
||||
@ -17,11 +17,12 @@ class PresupuestoAcabadosModel extends \App\Models\BaseModel
|
||||
|
||||
const SORTABLE = [
|
||||
0 => "t2.nombre",
|
||||
1 => "t1.precio_unidad",
|
||||
2 => "t1.precio_total"
|
||||
1 => "t1.proveedor_id",
|
||||
2 => "t1.precio_unidad",
|
||||
3 => "t1.precio_total"
|
||||
];
|
||||
|
||||
protected $allowedFields = ["presupuesto_id", "tarifa_acabado_id", "nombre", "precio_total", "precio_unidad", "margen", "cubierta", "sobrecubierta"];
|
||||
protected $allowedFields = ["presupuesto_id", "tarifa_acabado_id", "proveedor_id", "nombre", "precio_total", "precio_unidad", "margen", "cubierta", "sobrecubierta"];
|
||||
protected $returnType = "App\Entities\Presupuestos\PresupuestoAcabadosEntity";
|
||||
|
||||
protected $useTimestamps = true;
|
||||
@ -46,10 +47,29 @@ class PresupuestoAcabadosModel extends \App\Models\BaseModel
|
||||
],
|
||||
];
|
||||
|
||||
public function getPrecioTarifa($tarifa_acabado_id, $tirada, $POD){
|
||||
|
||||
public function getProveedoresForSelector($tarifa_acabado_id, $tirada){
|
||||
|
||||
$proveedores = [];
|
||||
$modelTarifa = model('App\Models\Tarifas\Acabados\TarifaAcabadoModel');
|
||||
|
||||
$tarifa_value = $modelTarifa->getTarifaPresupuestoAcabado($tarifa_acabado_id, $tirada);
|
||||
|
||||
if (count($tarifa_value)>0) {
|
||||
foreach($tarifa_value as $tarifa)
|
||||
array_push($proveedores,
|
||||
(object)[
|
||||
'id'=> $tarifa->proveedor_id,
|
||||
'text'=> $tarifa->proveedor_nombre,
|
||||
]);
|
||||
}
|
||||
return $proveedores;
|
||||
}
|
||||
|
||||
public function getPrecioTarifa($tarifa_acabado_id, $tirada, $proveedor_id, $POD){
|
||||
|
||||
$modelTarifa = model('App\Models\Tarifas\Acabados\TarifaAcabadoModel');
|
||||
$tarifa_value = $modelTarifa->getTarifaPresupuestoAcabado($tarifa_acabado_id, $tirada);
|
||||
$tarifa_value = $modelTarifa->getTarifaPresupuestoAcabado($tarifa_acabado_id, $tirada, $proveedor_id);
|
||||
if (count($tarifa_value)>0) {
|
||||
|
||||
$result_data = $this->calcularTarifa($tarifa_value[0], $tirada, $POD<$tirada?false:true);
|
||||
@ -59,6 +79,8 @@ class PresupuestoAcabadosModel extends \App\Models\BaseModel
|
||||
'precio_unidad'=> $result_data[0],
|
||||
'total'=> $result_data[1],
|
||||
'margen'=> $result_data[2],
|
||||
'proveedor' => $tarifa_value[0]->proveedor_nombre,
|
||||
'proveedor_id' => $tarifa_value[0]->proveedor_id,
|
||||
];
|
||||
return $ret_array;
|
||||
}
|
||||
@ -119,6 +141,8 @@ class PresupuestoAcabadosModel extends \App\Models\BaseModel
|
||||
|
||||
foreach($tarifas as $tarifa){
|
||||
|
||||
$proveedor = $tarifa->proveedor_id=='undefined'?'NULL':$tarifa->proveedor_id;
|
||||
|
||||
$builder = $this->db
|
||||
->table($this->table . " t1");
|
||||
$builder->select("id");
|
||||
@ -132,6 +156,7 @@ class PresupuestoAcabadosModel extends \App\Models\BaseModel
|
||||
->table($this->table . " t1")
|
||||
->where('presupuesto_id', $presupuesto_id)
|
||||
->where('tarifa_acabado_id', $tarifa->tarifa_id)
|
||||
->set('proveedor_id', $proveedor)
|
||||
->set('precio_unidad', $tarifa->precio_unidad)
|
||||
->set('precio_total', $tarifa->precio_total)
|
||||
->set('margen', $tarifa->margen)
|
||||
@ -146,6 +171,7 @@ class PresupuestoAcabadosModel extends \App\Models\BaseModel
|
||||
->table($this->table . " t1")
|
||||
->set('presupuesto_id', $presupuesto_id)
|
||||
->set('tarifa_acabado_id', $tarifa->tarifa_id)
|
||||
->set('proveedor_id', $proveedor, false)
|
||||
->set('precio_unidad', $tarifa->precio_unidad)
|
||||
->set('precio_total', $tarifa->precio_total)
|
||||
->set('margen', $tarifa->margen)
|
||||
@ -169,11 +195,13 @@ class PresupuestoAcabadosModel extends \App\Models\BaseModel
|
||||
->table($this->table . " t1")
|
||||
->select(
|
||||
"t1.id AS id, t1.tarifa_acabado_id AS tarifa_acabado_id, t1.precio_unidad AS precio_unidad,
|
||||
t1.precio_total AS precio_total, t1.margen AS margen, t2.nombre AS nombre, t1.cubierta AS cubierta, t1.sobrecubierta AS sobrecubierta"
|
||||
t1.precio_total AS precio_total, t1.margen AS margen, t2.nombre AS nombre, t1.cubierta AS cubierta, t1.sobrecubierta AS sobrecubierta,
|
||||
t1.proveedor_id AS proveedor_id, t3.nombre AS proveedor,"
|
||||
);
|
||||
|
||||
$builder->where('t1.presupuesto_id', $presupuesto_id);
|
||||
$builder->join("lg_tarifa_acabado t2", "t1.tarifa_acabado_id = t2.id", "left");
|
||||
$builder->join("lg_proveedores t3", "t1.proveedor_id = t3.id", "left");
|
||||
|
||||
return $builder;
|
||||
}
|
||||
|
||||
@ -21,7 +21,7 @@ class PresupuestoEncuadernacionesModel extends \App\Models\BaseModel
|
||||
4 => "t1.precio_total"
|
||||
];
|
||||
|
||||
protected $allowedFields = ["presupuesto_id", "tarifa_encuadernado_id", "nombre", "precio_total", "precio_unidad", "margen"];
|
||||
protected $allowedFields = ["presupuesto_id", "tarifa_encuadernado_id", "proveedor_id", "nombre", "precio_total", "precio_unidad", "paginas_por_cuadernillo", "tiempo", "margen"];
|
||||
protected $returnType = "App\Entities\Presupuestos\PresupuestoEncuadernacionesEntity";
|
||||
|
||||
protected $useTimestamps = true;
|
||||
@ -48,7 +48,7 @@ class PresupuestoEncuadernacionesModel extends \App\Models\BaseModel
|
||||
|
||||
|
||||
|
||||
public function initPresupuesto($tipo_presupuesto, $solapas, $tirada, $paginas, $ancho, $alto, $POD){
|
||||
public function initPresupuesto($tipo_presupuesto, $solapas, $tirada, $paginas, $ancho, $alto, $POD, $paginasCuadernillo = 32){
|
||||
|
||||
$model = model('App\Models\Presupuestos\TipoPresupuestoServiciosDefectoModel');
|
||||
$tarifas_procesar = $model->get_tarifas($tipo_presupuesto, $solapas, "encuadernacion");
|
||||
@ -60,7 +60,12 @@ class PresupuestoEncuadernacionesModel extends \App\Models\BaseModel
|
||||
|
||||
if($modelTarifa->isTarifaPorHoras($tarifa['tarifa_id'])){
|
||||
|
||||
$tiempo = $this->calcularTiempo(16, $paginas, $tirada); // ID fija. Cambiar cuando se metan maquinas de corte. Velocidad en minutos
|
||||
if($tarifa['tarifa_id'] == 2 || $tarifa['tarifa_id'] == 14){ // Rústica cosido hilo vegetal y Rústica cosido hilo vegetal solapas
|
||||
$tiempo = $this->calcularTiempoCosido(16, $paginas, $tirada, $paginasCuadernillo); // ID fija. Cambiar cuando se metan maquinas de corte. Velocidad en minutos
|
||||
}
|
||||
else{
|
||||
$tiempo = $this->calcularTiempo(16, $paginas, $tirada); // ID fija. Cambiar cuando se metan maquinas de corte. Velocidad en minutos
|
||||
}
|
||||
|
||||
$tarifa_value = $modelTarifa->getTarifaPresupuestoEncuadernacionHoras($tarifa['tarifa_id'], $tiempo, $tirada);
|
||||
if (count($tarifa_value)>0) {
|
||||
@ -76,8 +81,7 @@ class PresupuestoEncuadernacionesModel extends \App\Models\BaseModel
|
||||
$result_data[1] = $precio_total;
|
||||
$result_data[2] = $tarifa_proveedor->margen ; // margen
|
||||
|
||||
array_push($result_array,
|
||||
(object)[
|
||||
$datos = [
|
||||
'tarifa_id'=> $tarifa['tarifa_id'],
|
||||
'tarifa_nombre'=> $tarifa_proveedor->tarifa_enc_nombre,
|
||||
'precio_unidad'=> $result_data[0],
|
||||
@ -86,7 +90,14 @@ class PresupuestoEncuadernacionesModel extends \App\Models\BaseModel
|
||||
'margen' => $result_data[2],
|
||||
'proveedor' => $tarifa_proveedor->proveedor_nombre,
|
||||
'proveedor_id' => $tarifa_proveedor->proveedor_id,
|
||||
]);
|
||||
];
|
||||
|
||||
if($tarifa['tarifa_id'] == 2 || $tarifa['tarifa_id'] == 14){
|
||||
$datos['paginas_por_cuadernillo'] = $paginasCuadernillo;
|
||||
}
|
||||
|
||||
array_push($result_array,
|
||||
(object)$datos);
|
||||
}
|
||||
|
||||
usort($result_array, function($a, $b) {
|
||||
@ -237,11 +248,16 @@ class PresupuestoEncuadernacionesModel extends \App\Models\BaseModel
|
||||
return [];
|
||||
}
|
||||
|
||||
public function getPrecioTarifaHoras($tarifa_encuadernacion_id, $paginas, $tirada, $proveedor_id, $POD){
|
||||
public function getPrecioTarifaHoras($tarifa_encuadernacion_id, $paginas, $tirada, $proveedor_id, $POD, $paginas_cuadernillo = null){
|
||||
|
||||
$modelTarifa = model('App\Models\Tarifas\TarifaEncuadernacionModel');
|
||||
|
||||
$tiempo = $this->calcularTiempo(16, $paginas, $tirada); // ID fija. Cambiar cuando se metan maquinas de corte. Velocidad en minutos
|
||||
if($tarifa_encuadernacion_id == 2 || $tarifa_encuadernacion_id == 14){ // Rústica cosido hilo vegetal y Rústica cosido hilo vegetal solapas
|
||||
$tiempo = $this->calcularTiempoCosido(16, $paginas, $tirada, $paginas_cuadernillo); // ID fija. Cambiar cuando se metan maquinas de corte. Velocidad en minutos
|
||||
}
|
||||
else{
|
||||
$tiempo = $this->calcularTiempo(16, $paginas, $tirada); // ID fija. Cambiar cuando se metan maquinas de corte. Velocidad en minutos
|
||||
}
|
||||
|
||||
$tarifa_value = $modelTarifa->getTarifaPresupuestoEncuadernacionHoras($tarifa_encuadernacion_id, $tiempo, $tirada, $proveedor_id);
|
||||
if (count($tarifa_value)>0) {
|
||||
@ -256,6 +272,7 @@ class PresupuestoEncuadernacionesModel extends \App\Models\BaseModel
|
||||
$result_data[0] = floatval($precio_total / $tirada); // Precio/unidad
|
||||
$result_data[1] = $precio_total;
|
||||
$result_data[2] = $tarifa_proveedor->margen ; // margen
|
||||
|
||||
|
||||
array_push($ret_array,
|
||||
(object)[
|
||||
@ -263,6 +280,7 @@ class PresupuestoEncuadernacionesModel extends \App\Models\BaseModel
|
||||
'tarifa_nombre'=> $tarifa_proveedor->tarifa_enc_nombre,
|
||||
'precio_unidad'=> $result_data[0],
|
||||
'tiempo' => $tiempo,
|
||||
'paginas_por_cuadernillo' => $paginas_cuadernillo,
|
||||
'total'=> $result_data[1],
|
||||
'margen' => $result_data[2],
|
||||
'proveedor' => $tarifa_proveedor->proveedor_nombre,
|
||||
@ -287,6 +305,7 @@ class PresupuestoEncuadernacionesModel extends \App\Models\BaseModel
|
||||
'proveedor' => lang('Presupuestos.no_disponible'),
|
||||
'precio_unidad'=> 0,
|
||||
'tiempo' => null,
|
||||
'paginas_por_cuadernillo' => null,
|
||||
'total'=> 0,
|
||||
'margen' => 0,
|
||||
];
|
||||
@ -355,6 +374,7 @@ class PresupuestoEncuadernacionesModel extends \App\Models\BaseModel
|
||||
$builder->where('presupuesto_id', $presupuesto_id);
|
||||
$builder->where('tarifa_encuadernado_id', $tarifa->tarifa_id);
|
||||
$result = $builder->get()->getResultObject();
|
||||
$paginas_cuadernillo = $tarifa->paginas_por_cuadernillo??null;
|
||||
if(count($result)>0){
|
||||
$this->db
|
||||
->table($this->table . " t1")
|
||||
@ -365,6 +385,7 @@ class PresupuestoEncuadernacionesModel extends \App\Models\BaseModel
|
||||
->set('tiempo', $tarifa->tiempo)
|
||||
->set('precio_total', $tarifa->precio_total)
|
||||
->set('margen', $tarifa->margen)
|
||||
->set('paginas_por_cuadernillo', $paginas_cuadernillo)
|
||||
->update();
|
||||
|
||||
|
||||
@ -397,7 +418,8 @@ class PresupuestoEncuadernacionesModel extends \App\Models\BaseModel
|
||||
->table($this->table . " t1")
|
||||
->select(
|
||||
"t1.id AS id, t1.tarifa_encuadernado_id AS tarifa_encuadernado_id, t1.precio_unidad AS precio_unidad, t1.tiempo AS tiempo,
|
||||
t1.precio_total AS precio_total, t1.margen AS margen, t2.nombre AS nombre, t1.proveedor_id AS proveedor_id, t3.nombre AS proveedor"
|
||||
t1.precio_total AS precio_total, t1.margen AS margen, t2.nombre AS nombre, t1.proveedor_id AS proveedor_id, t3.nombre AS proveedor,
|
||||
t1.paginas_por_cuadernillo AS paginas_por_cuadernillo"
|
||||
);
|
||||
|
||||
$builder->where('t1.presupuesto_id', $presupuesto_id);
|
||||
@ -415,4 +437,13 @@ class PresupuestoEncuadernacionesModel extends \App\Models\BaseModel
|
||||
$velocidad = $maquinaModel->getVelocidad($maquina_id);
|
||||
return round($cuadernillos_pedido/($velocidad*60.0), 2);
|
||||
}
|
||||
|
||||
private function calcularTiempoCosido($maquina_id, $paginas, $tirada, $cuadernillos_por_pagina = 32){
|
||||
|
||||
$maquinaModel = model("App\Models\Configuracion\MaquinaModel");
|
||||
$velocidad = $maquinaModel->getVelocidad($maquina_id); // cuadernillos por minuto
|
||||
$cuadernillos_libro = ceil($paginas/intval($cuadernillos_por_pagina));
|
||||
$cuadernillos_pedido = $cuadernillos_libro*$tirada;
|
||||
return round($cuadernillos_pedido/($velocidad*60.0), 2); // tiempo en segundos
|
||||
}
|
||||
}
|
||||
|
||||
89
ci4/app/Models/Presupuestos/PresupuestoFicheroModel.php
Normal file
89
ci4/app/Models/Presupuestos/PresupuestoFicheroModel.php
Normal file
@ -0,0 +1,89 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Presupuestos;
|
||||
|
||||
class PresupuestoFicheroModel extends \App\Models\BaseModel
|
||||
{
|
||||
protected $table = "presupuesto_ficheros";
|
||||
|
||||
|
||||
/**
|
||||
* Whether primary key uses auto increment.
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
protected $useAutoIncrement = true;
|
||||
|
||||
|
||||
protected $allowedFields = ["presupuesto_id", "nombre", "file_path", "upload_by", "upload_at"];
|
||||
protected $returnType = "App\Entities\Presupuestos\PresupuestoFicheroEntity";
|
||||
|
||||
protected $useTimestamps = false;
|
||||
protected $useSoftDeletes = false;
|
||||
|
||||
public static $labelField = "nombre";
|
||||
|
||||
|
||||
public function saveFileInBBDD($presupuesto_id, $filename, $extension ,$user_id) {
|
||||
try{
|
||||
$new_filename = $this->generateFileHash($filename) . '.' . $extension;
|
||||
|
||||
$this->db->table($this->table . " t1")
|
||||
->set('presupuesto_id', $presupuesto_id)
|
||||
->set('nombre', $filename)
|
||||
->set('file_path', WRITEPATH . 'uploads/presupuestos/' . $new_filename)
|
||||
->set('upload_by', $user_id)
|
||||
->set('upload_at', date('Y-m-d H:i:s'))
|
||||
->insert();
|
||||
|
||||
return $new_filename;
|
||||
} catch (\Exception $e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public function deleteFiles($presupuesto_id, $old_files = []){
|
||||
|
||||
$files = $this->db
|
||||
->table($this->table . " t1")
|
||||
->where('presupuesto_id', $presupuesto_id)->get()->getResult();
|
||||
if($files){
|
||||
foreach($files as $file){
|
||||
|
||||
// se comprueba que el $file->nombre no sea igual a ninguno de los elementos del array $old_files
|
||||
if (!in_array($file->nombre, $old_files)) {
|
||||
if (file_exists($file->file_path)) {
|
||||
unlink($file->file_path);
|
||||
}
|
||||
|
||||
$this->db
|
||||
->table($this->table . " t1")
|
||||
->where('presupuesto_id', $presupuesto_id)
|
||||
->where('nombre', $file->nombre)
|
||||
->delete();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public function getFiles($presupuesto_id){
|
||||
return $this->db
|
||||
->table($this->table . " t1")
|
||||
->where('presupuesto_id', $presupuesto_id)->get()->getResult();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Función para convertir el nombre y extensión de un fichero en un hash único
|
||||
* usando cifrado simétrico.
|
||||
*
|
||||
* @param string $filename Nombre del fichero con extensión
|
||||
* @return string Hash encriptado del fichero
|
||||
*/
|
||||
private function generateFileHash($filename) {
|
||||
return hash('sha256', $filename);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@ -12,7 +12,7 @@ class PresupuestoLineaModel extends \App\Models\BaseModel
|
||||
* @var bool
|
||||
*/
|
||||
protected $useAutoIncrement = true;
|
||||
|
||||
|
||||
protected $allowedFields = [
|
||||
"presupuesto_id",
|
||||
"tipo",
|
||||
@ -339,18 +339,18 @@ class PresupuestoLineaModel extends \App\Models\BaseModel
|
||||
|
||||
public function updatePreciosLineasPresupuesto($id_linea, $new_linea)
|
||||
{
|
||||
$rot_total_impresion = $new_linea['fields']['precio_click_pedido']??0.0 +
|
||||
$new_linea['fields']['precio_tinta']??0.0+$new_linea['fields']['total_Corte']??0.0;
|
||||
|
||||
$rot_total_impresion = $new_linea['fields']['precio_click_pedido'] ?? 0.0 +
|
||||
$new_linea['fields']['precio_tinta'] ?? 0.0 + $new_linea['fields']['total_Corte'] ?? 0.0;
|
||||
|
||||
$data = [
|
||||
"pliegos_precio" => $new_linea['fields']['precios_pliegos'],
|
||||
"libro" => $new_linea['fields']['precio_libro'],
|
||||
"total_papel_pedido" => round($new_linea['fields']['precio_pedido'], 2),
|
||||
"margen_papel_pedido" => round($new_linea['fields']['margen_papel_pedido'], 2),
|
||||
"mano" => $new_linea['fields']['mano'],
|
||||
"precio_click" => round($new_linea['fields']['precio_click'], 6),
|
||||
"precio_click_pedido" => round($new_linea['fields']['precio_click_pedido'], 2),
|
||||
"margen_click_pedido" => round($new_linea['fields']['margen_click_pedido'], 2),
|
||||
"precio_click" => round($new_linea['fields']['precio_click'], 6),
|
||||
"precio_click_pedido" => round($new_linea['fields']['precio_click_pedido'], 2),
|
||||
"margen_click_pedido" => round($new_linea['fields']['margen_click_pedido'], 2),
|
||||
"tiempo_maquina" => strtotime($new_linea['fields']['tiempo_maquina']) - strtotime('TODAY'),
|
||||
"tarifa_impresion_id" => $new_linea['fields']['tarifa_impresion_id'],
|
||||
"rotativa_total_impresion" => $rot_total_impresion,
|
||||
@ -387,16 +387,16 @@ class PresupuestoLineaModel extends \App\Models\BaseModel
|
||||
"rotativa_tiempo_corte" => $new_linea['fields']['tiempo_corte'] ?? 0,
|
||||
"rotativa_precio_hora_corte" => $new_linea['fields']['precio_hora_corte'] ?? 0,
|
||||
"rotativa_total_corte" => $new_linea['fields']['total_corte'] ?? 0,
|
||||
"horas_maquina" => round($new_linea['fields']['horas_maquina'],4),
|
||||
"horas_maquina" => round($new_linea['fields']['horas_maquina'], 4),
|
||||
"precio_hora" => $new_linea['fields']['precio_hora'] ?? 0,
|
||||
"precio_impresion" => $new_linea['fields']['precio_impresion_horas'] ?? 0,
|
||||
"total_linea" => round($new_linea['fields']['total_impresion'], 2) ?? 0,
|
||||
"margen_impresion" => $new_linea['fields']['margen_impresion_horas'] ?? 0,
|
||||
];
|
||||
|
||||
if(array_key_exists('datosTipologias', $new_linea['fields'])){
|
||||
if (array_key_exists('datosTipologias', $new_linea['fields'])) {
|
||||
$data += [
|
||||
"rotativa_negro" => $new_linea['fields']['datosTipologias']->negro ?? 0,
|
||||
"rotativa_negro" => $new_linea['fields']['datosTipologias']->negro ?? 0,
|
||||
"rotativa_cyan" => $new_linea['fields']['datosTipologias']->cyan ?? 0,
|
||||
"rotativa_magenta" => $new_linea['fields']['datosTipologias']->magenta ?? 0,
|
||||
"rotativa_amarillo" => $new_linea['fields']['datosTipologias']->amarillo ?? 0,
|
||||
@ -404,7 +404,7 @@ class PresupuestoLineaModel extends \App\Models\BaseModel
|
||||
"rotativa_gota_negro" => $new_linea['fields']['datosTipologias']->gota_negro ?? 0,
|
||||
"rotativa_gota_color" => $new_linea['fields']['datosTipologias']->gota_color
|
||||
];
|
||||
}
|
||||
}
|
||||
$this->db
|
||||
->table($this->table . " t1")
|
||||
->where('id', $id_linea)
|
||||
@ -412,6 +412,124 @@ class PresupuestoLineaModel extends \App\Models\BaseModel
|
||||
->update();
|
||||
}
|
||||
|
||||
public function insertLPFromBackend($presupuesto_id, $new_linea)
|
||||
{
|
||||
$rot_total_impresion = $new_linea['precio_click_pedido'] ?? 0.0 +
|
||||
$new_linea['precio_tinta'] ?? 0.0 + $new_linea['total_Corte'] ?? 0.0;
|
||||
|
||||
$formas = json_encode(array(
|
||||
'maquina_ancho'=> $new_linea['dimensiones_maquina'][0],
|
||||
'maquina_alto' => $new_linea['dimensiones_maquina'][1],
|
||||
'maquina_impresion_ancho'=> $new_linea['dimensiones_maquina_impresion'][0],
|
||||
'maquina_impresion_alto' => $new_linea['dimensiones_maquina_impresion'][1],
|
||||
'formas' => $new_linea['num_formas']['value'],
|
||||
'formas_v'=> $new_linea['num_formas']['num_formas_verticales'],
|
||||
'formas_h'=> $new_linea['num_formas']['num_formas_horizontales'],
|
||||
'formas_orientacion'=> $new_linea['num_formas']['posicion_formas']
|
||||
));
|
||||
|
||||
sscanf($new_linea['tiempo_maquina'], "%d:%d:%d", $hours, $minutes, $seconds);
|
||||
$tiempo = isset($seconds) ? $hours * 3600 + $minutes * 60 + $seconds : $hours * 60 + $minutes;
|
||||
|
||||
$data = [
|
||||
'presupuesto_id' => $presupuesto_id,
|
||||
'tipo' => $new_linea['tipo_linea'],
|
||||
'paginas' => $new_linea['paginas'],
|
||||
'papel_id' => $new_linea['papel_generico_id'],
|
||||
'papel_impresion_id' => $new_linea['papel_impresion_id'],
|
||||
'formas' => $formas,
|
||||
'gramaje' => $new_linea['gramaje'],
|
||||
'pliegos_libro' => $new_linea['pliegos_libro'],
|
||||
'pliegos_pedido' => $new_linea['pliegos_pedido'],
|
||||
'pliegos_precio' => $new_linea['precios_pliegos'],
|
||||
'libro' => $new_linea['precio_libro'],
|
||||
'total_papel_pedido' => $new_linea['precio_pedido'],
|
||||
'margen_papel_pedido' => $new_linea['margen_papel_pedido'],
|
||||
'mano' => $new_linea['mano'],
|
||||
'peso' => $new_linea['peso'],
|
||||
'check_papel_total' => 1,
|
||||
'check_impresion_total' => 1,
|
||||
'maquina_id' => $new_linea['maquina_id'],
|
||||
'tiempo_maquina' => $tiempo,
|
||||
'tarifa_impresion_id' => $new_linea['tarifa_impresion_id'],
|
||||
'precio_click' => $new_linea['precio_click'],
|
||||
'precio_click_pedido' => $new_linea['precio_click_pedido'],
|
||||
'maquina' => $new_linea['maquina'],
|
||||
'papel_impresion' => $new_linea['papel_impresion'],
|
||||
'maquina_tipo' => $new_linea['tipo_maquina'],
|
||||
'horas_maquina' => $new_linea['horas_maquina'],
|
||||
'precio_hora' => $new_linea['precio_hora'],
|
||||
'precio_impresion' => $new_linea['precio_impresion_horas'],
|
||||
'total_linea' => $new_linea['total_impresion'],
|
||||
'margen_impresion' => $new_linea['margen_impresion_horas'],
|
||||
'margen_click_pedido' => $new_linea['margen_click_pedido'],
|
||||
];
|
||||
|
||||
if($new_linea['tipo_maquina'] =='inkjet'){
|
||||
$data += [
|
||||
'rotativa_total_impresion' => $rot_total_impresion,
|
||||
|
||||
'rotativa_negro' => $new_linea['datosTipologias']->negro ?? 0,
|
||||
'rotativa_cyan' => $new_linea['datosTipologias']->cyan ?? 0,
|
||||
'rotativa_magenta' => $new_linea['datosTipologias']->magenta ?? 0,
|
||||
'rotativa_amarillo' => $new_linea['datosTipologias']->amarillo ?? 0,
|
||||
'rotativa_cg' => $new_linea['datosTipologias']->cg ?? 0,
|
||||
'rotativa_gota_negro' => $new_linea['datosTipologias']->gota_negro ?? 0,
|
||||
'rotativa_gota_color' => $new_linea['datosTipologias']->gota_color ?? 0,
|
||||
|
||||
'rotativa_num_gotas_negro' => $new_linea['num_gotas_negro'] ?? 0,
|
||||
'rotativa_num_gotas_cyan' => $new_linea['num_gotas_cyan'] ?? 0,
|
||||
'rotativa_num_gotas_magenta' => $new_linea['num_gotas_magenta'] ?? 0,
|
||||
'rotativa_num_gotas_amarillo' => $new_linea['num_gotas_amarillo'] ?? 0,
|
||||
'rotativa_num_gotas_cg' => $new_linea['num_gotas_cg'] ?? 0,
|
||||
'rotativa_peso_gotas_negro' => $new_linea['peso_gotas_negro'] ?? 0,
|
||||
'rotativa_peso_gotas_cyan' => $new_linea['peso_gotas_cyan'] ?? 0,
|
||||
'rotativa_peso_gotas_magenta' => $new_linea['peso_gotas_magenta'] ?? 0,
|
||||
'rotativa_peso_gotas_amarillo' => $new_linea['peso_gotas_amarillo'] ?? 0,
|
||||
'rotativa_peso_gotas_cg' => $new_linea['peso_gotas_cg'] ?? 0,
|
||||
'rotativa_peso_gotas_negro_pedido' => $new_linea['peso_gotas_negro_pedido'] ?? 0,
|
||||
'rotativa_peso_gotas_cyan_pedido' => $new_linea['peso_gotas_cyan_pedido'] ?? 0,
|
||||
'rotativa_peso_gotas_magenta_pedido' => $new_linea['peso_gotas_magenta_pedido'] ?? 0,
|
||||
'rotativa_peso_gotas_amarillo_pedido' => $new_linea['peso_gotas_amarillo_pedido'] ?? 0,
|
||||
'rotativa_peso_gotas_cg_pedido' => $new_linea['peso_gotas_cg_pedido'] ?? 0,
|
||||
|
||||
'rotativa_pag_color' => $new_linea['paginas_color'],
|
||||
'rotativa_resolucion' => $new_linea['resolucion'],
|
||||
'rotativa_area_paginas' => $new_linea['superficie'],
|
||||
'rotativa_precio_pag_negro' => $new_linea['precio_pagina_negro'],
|
||||
'rotativa_precio_pag_color' => $new_linea['precio_pagina_color'],
|
||||
'rotativa_factor_altura' => $new_linea['factor_altura'],
|
||||
'rotativa_factor_anchura' => $new_linea['factor_anchura'],
|
||||
'rotativa_pag_por_pliego' => $new_linea['paginas_por_pliego'],
|
||||
'rotativa_clicks_libro' => $new_linea['clicks_libro'],
|
||||
'rotativa_clicks_total' => $new_linea['clicks_pedido'],
|
||||
'rotativa_precio_tinta' => $new_linea['precio_tinta'],
|
||||
'rotativa_mxm' => $new_linea['maquina_velocidad'],
|
||||
];
|
||||
}
|
||||
|
||||
if (strpos($new_linea['tipo_linea'], 'rot') !== false) {
|
||||
$data += [
|
||||
'rotativa_metros_libro' => $new_linea['metros_papel_libro'],
|
||||
'rotativa_metros_total' => $new_linea['metros_papel_total'],
|
||||
'rotativa_velocidad_corte' => $new_linea['velocidad_corte'],
|
||||
'rotativa_precio_hora_corte' => $new_linea['precio_hora_corte'],
|
||||
'rotativa_tiempo_corte' => $new_linea['tiempo_corte'],
|
||||
'rotativa_total_corte' => $new_linea['total_corte'],
|
||||
'rotativa_a_favor_fibra' => $new_linea['a_favor_fibra']
|
||||
];
|
||||
}
|
||||
|
||||
if($new_linea['tipo_linea'] =='lp_guardas')
|
||||
$data = array_merge($data, ['paginas_impresion' => $new_linea['paginas_impresion']]);
|
||||
|
||||
return $this->db
|
||||
->table($this->table . " t1")
|
||||
->set($data)
|
||||
->insert();
|
||||
}
|
||||
|
||||
|
||||
public function deleteLineasPresupuesto($presupuesto_id)
|
||||
{
|
||||
$this->db
|
||||
@ -431,7 +549,6 @@ class PresupuestoLineaModel extends \App\Models\BaseModel
|
||||
->where("t1.presupuesto_id", $presupuesto_id)
|
||||
->insert($linea);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public function getResourceByNForPdf($presupuesto_id = -1)
|
||||
@ -498,9 +615,4 @@ class PresupuestoLineaModel extends \App\Models\BaseModel
|
||||
->insert($linea);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user