diff --git a/.gitignore b/.gitignore index 2740fefd..1d34c84e 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,4 @@ ci4/.env .vscode/ -xdebug.log \ No newline at end of file +*xdebug*.log* \ No newline at end of file diff --git a/.idea/codeception.xml b/.idea/codeception.xml new file mode 100644 index 00000000..ed98e5ee --- /dev/null +++ b/.idea/codeception.xml @@ -0,0 +1,15 @@ + + + + + + \ No newline at end of file diff --git a/.idea/php.xml b/.idea/php.xml index ebe16728..d3a7a60e 100755 --- a/.idea/php.xml +++ b/.idea/php.xml @@ -55,6 +55,13 @@ + + + + + + + diff --git a/.idea/phpspec.xml b/.idea/phpspec.xml new file mode 100644 index 00000000..d39fc8c9 --- /dev/null +++ b/.idea/phpspec.xml @@ -0,0 +1,16 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/safekat.iml b/.idea/safekat.iml index 30e3cdd1..db9597c8 100755 --- a/.idea/safekat.iml +++ b/.idea/safekat.iml @@ -7,6 +7,13 @@ + + + + + + + diff --git a/ci4/app/Config/Routes.php b/ci4/app/Config/Routes.php index 9a7700d2..cddf323d 100644 --- a/ci4/app/Config/Routes.php +++ b/ci4/app/Config/Routes.php @@ -77,14 +77,7 @@ $routes->group('configuracion', ['namespace' => 'App\Controllers\Configuracion'] $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("variables", ["namespace" => 'App\Controllers\Configuracion'], function ($routes) { $routes->get('', 'ConfigVariables::index', ['as' => 'variablesIndex']); $routes->get('find/(:num)', 'ConfigVariables::get/$1', ['as' => 'variablesFind']); @@ -104,7 +97,6 @@ $routes->group('configuracion', ['namespace' => 'App\Controllers\Configuracion'] $routes->group('users', ['namespace' => 'App\Controllers\Configuracion'], function ($routes) { $routes->get('', 'Users::index', ['as' => 'userList']); - $routes->get('index', 'Users::index', ['as' => 'userIndex']); $routes->get('list', 'Users::index', ['as' => 'userList2']); $routes->get('add', 'Users::add', ['as' => 'newUser']); $routes->post('add', 'Users::add', ['as' => 'createUser']); @@ -113,8 +105,10 @@ $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->get('getMenuComerciales', 'Users::getMenuComerciales', ['as' => 'menuItemsComerciales']); }); +$routes->resource('users', ['namespace' => 'App\Controllers\Configuracion', 'controller' => 'Users', 'except' => 'show,new,create,update']); + $routes->group('group', ['namespace' => 'App\Controllers\Configuracion'], function ($routes) { $routes->get('', 'Group::index', ['as' => 'userGroupList']); @@ -221,6 +215,8 @@ $routes->group('papelesgenericos', ['namespace' => 'App\Controllers\Configuracio $routes->post('datatable', 'Papelesgenericos::datatable', ['as' => 'dataTableOfPapelesGenericos']); $routes->post('allmenuitems', 'Papelesgenericos::allItemsSelect', ['as' => 'select2ItemsOfPapelesGenericos']); $routes->post('menuitems', 'Papelesgenericos::menuItems', ['as' => 'menuItemsOfPapelesGenericos']); + $routes->get('getpapelcliente', 'Papelesgenericos::getPapelCliente', ['as' => 'getPapelCliente']); + $routes->get('selectpapelespecial', 'Papelesgenericos::selectPapelEspecial', ['as' => 'selectPapelEspecial']); }); $routes->resource('papelesgenericos', ['namespace' => 'App\Controllers\Configuracion', 'controller' => 'Papelesgenericos', 'except' => 'show,new,create,update']); @@ -332,10 +328,22 @@ $routes->group('comunidades-autonomas', ['namespace' => 'App\Controllers\Configu $routes->post('datatable', 'Comunidadesautonomas::datatable', ['as' => 'dataTableOfComunidadesAutonomas']); $routes->post('allmenuitems', 'Comunidadesautonomas::allItemsSelect', ['as' => 'select2ItemsOfComunidadesAutonomas']); $routes->post('menuitems', 'Comunidadesautonomas::menuItems', ['as' => 'menuItemsOfComunidadesAutonomas']); + $routes->get('menuitems2', 'Comunidadesautonomas::menuItems2', ['as' => 'menuItemsOfComunidadesAutonomas2']); }); $routes->resource('comunidades-autonomas', ['namespace' => 'App\Controllers\Configuracion', 'controller' => 'Comunidadesautonomas', 'except' => 'show,new,create,update']); +$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->get('menuitems', 'FormasPago::menuItems', ['as' => 'menuItemsOfFormasDePagos']); +}); +$routes->resource('formas-pago', ['namespace' => 'App\Controllers\Configuracion', 'controller' => 'FormasPago', 'except' => 'show,new,create,update']); + + $routes->group('paises', ['namespace' => 'App\Controllers\Configuracion'], function ($routes) { $routes->get('', 'Paises::index', ['as' => 'paisList']); $routes->get('add', 'Paises::add', ['as' => 'newPais']); @@ -346,6 +354,7 @@ $routes->group('paises', ['namespace' => 'App\Controllers\Configuracion'], funct $routes->post('datatable', 'Paises::datatable', ['as' => 'dataTableOfPaises']); $routes->post('allmenuitems', 'Paises::allItemsSelect', ['as' => 'select2ItemsOfPaises']); $routes->post('menuitems', 'Paises::menuItems', ['as' => 'menuItemsOfPaises']); + $routes->get('menuitems2', 'Paises::menuItems2', ['as' => 'menuItemsOfPaises2']); }); $routes->resource('paises', ['namespace' => 'App\Controllers\Configuracion', 'controller' => 'Paises', 'except' => 'show,new,create,update']); @@ -360,6 +369,7 @@ $routes->group('provincias', ['namespace' => 'App\Controllers\Configuracion'], f $routes->post('datatable', 'Provincias::datatable', ['as' => 'dataTableOfProvincias']); $routes->post('allmenuitems', 'Provincias::allItemsSelect', ['as' => 'select2ItemsOfProvincias']); $routes->post('menuitems', 'Provincias::menuItems', ['as' => 'menuItemsOfProvincias']); + $routes->get('menuitems2', 'Provincias::menuItems2', ['as' => 'menuItemsOfProvincias2']); }); $routes->resource('provincias', ['namespace' => 'App\Controllers\Configuracion', 'controller' => 'Provincias', 'except' => 'show,new,create,update']); @@ -420,18 +430,6 @@ $routes->group('misdirecciones', ['namespace' => 'App\Controllers\Clientes'], fu }); -$routes->group('formas-pagos', ['namespace' => 'App\Controllers\Configuracion'], function ($routes) { - $routes->get('', 'Formaspagos::index', ['as' => 'formaDePagoList']); - $routes->get('add', 'Formaspagos::add', ['as' => 'newFormaDePago']); - $routes->post('add', 'Formaspagos::add', ['as' => 'createFormaDePago']); - $routes->post('create', 'Formaspagos::create', ['as' => 'ajaxCreateFormaDePago']); - $routes->put('(:num)/update', 'Formaspagos::update/$1', ['as' => 'ajaxUpdateFormaDePago']); - $routes->post('(:num)/edit', 'Formaspagos::edit/$1', ['as' => 'updateFormaDePago']); - $routes->post('datatable', 'Formaspagos::datatable', ['as' => 'dataTableOfFormasDePagos']); - $routes->post('allmenuitems', 'Formaspagos::allItemsSelect', ['as' => 'select2ItemsOfFormasDePagos']); - $routes->post('menuitems', 'Formaspagos::menuItems', ['as' => 'menuItemsOfFormasDePagos']); -}); -$routes->resource('formas-pagos', ['namespace' => 'App\Controllers\Configuracion', 'controller' => 'Formaspagos', 'except' => 'show,new,create,update']); $routes->group('tarifasencuadernacion', ['namespace' => 'App\Controllers\Tarifas'], function ($routes) { $routes->get('', 'Tarifasencuadernacion::index', ['as' => 'tarifaEncuadernacionList']); @@ -556,20 +554,20 @@ $routes->group('clientedirecciones', ['namespace' => 'App\Controllers\Clientes'] $routes->resource('clientedirecciones', ['namespace' => 'App\Controllers\Clientes', 'controller' => 'Clientedirecciones', 'except' => 'show,new,create,update']); -$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']); - $routes->post('edit/(:num)', 'Cosidotapablanda::edit/$1', ['as' => 'updateCosidotapablanda']); - $routes->post('datatable', 'Cosidotapablanda::datatable', ['as' => 'dataTableOfCosidotapablanda']); - $routes->post('datatable_2', 'Cosidotapablanda::datatable_2', ['as' => 'updateDataOfCosidotapablanda']); - $routes->post('allmenuitems', 'Cosidotapablanda::allItemsSelect', ['as' => 'select2ItemsOfCosidotapablanda']); - $routes->post('menuitems', 'Cosidotapablanda::menuItems', ['as' => 'menuItemsOfCosidotapablanda']); +$routes->group('presupuestoadmin', ['namespace' => 'App\Controllers\Presupuestos'], function ($routes) { + $routes->get('list/(:num)', 'Presupuestoadmin::list/$1', ['as' => 'presupuestoAdminList']); // HOMOGENIZAR CON ARGS DINAMICOS!!! + $routes->get('add/(:num)', 'Presupuestoadmin::add/$1', ['as' => 'newPresupuestoAdmin']); + $routes->get('edit/(:any)', 'Presupuestoadmin::edit/$1', ['as' => 'editarPresupuestoAdmin']); + $routes->post('add/(:num)', 'Presupuestoadmin::add/$1', ['as' => 'createPresupuestoAdmin']); + $routes->post('create', 'Presupuestoadmin::create', ['as' => 'ajaxCreatePresupuestoAdmin']); + $routes->put('(:num)/update', 'Presupuestoadmin::update/$1', ['as' => 'ajaxUpdatePresupuestoAdmin']); + $routes->post('edit/(:num)', 'Presupuestoadmin::edit/$1', ['as' => 'updatePresupuestoAdmin']); + $routes->post('datatable', 'Presupuestoadmin::datatable', ['as' => 'dataTableOfPresupuestoAdmin']); + $routes->post('datatable_2', 'Presupuestoadmin::datatable_2', ['as' => 'updateDataOfPresupuestoAdmin']); + $routes->post('allmenuitems', 'Presupuestoadmin::allItemsSelect', ['as' => 'select2ItemsOfPresupuestoAdmin']); + $routes->post('menuitems', 'Presupuestoadmin::menuItems', ['as' => 'menuItemsOfPresupuestoAdmin']); }); -$routes->resource('cosidotapablanda', ['namespace' => 'App\Controllers\Presupuestos', 'controller' => 'Cosidotapablanda', 'except' => 'show,new,create,update']); +$routes->resource('presupuestoadmin', ['namespace' => 'App\Controllers\Presupuestos', 'controller' => 'Presupuestoadmin', 'except' => 'show,new,create,update']); $routes->group('presupuestocliente', ['namespace' => 'App\Controllers\Presupuestos'], function ($routes) { $routes->get('list', 'Presupuestocliente::list', ['as' => 'listaPresupuestos']); @@ -586,6 +584,7 @@ $routes->group('presupuestocliente', ['namespace' => 'App\Controllers\Presupuest $routes->get('cargar/(:num)', 'Presupuestocliente::cargar/$1', ['as' => 'cargarPresupuesto']); $routes->post('duplicarPresupuesto', 'Presupuestocliente::duplicarPresupuesto', ['as' => 'duplicarPresupuesto']); $routes->post('calcular', 'Presupuestocliente::calcular', ['as' => 'calcularPresupuesto']); + $routes->post('calcularsolapas', 'Presupuestocliente::calcularMaxSolapas', ['as' => 'calcularSolapas']); }); $routes->resource('presupuestocliente', ['namespace' => 'App\Controllers\Presupuestos', 'controller' => 'Presupuestocliente', 'except' => 'show,new,create,update']); @@ -762,9 +761,36 @@ $routes->group('mensajes', ['namespace' => 'App\Controllers\Mensajeria'], functi $routes->get('delete/(:num)', 'TarifaAcabados::delete/$1', ['as' => 'tarifaAcabadoDelete']); $routes->post('datatable', 'TarifaAcabados::datatable', ['as' => 'tarifaAcabadoDT']);*/ }); +}); +$routes->group('messages', ['namespace' => 'App\Controllers\Chat'], function ($routes) { + $routes->get('datatable', 'ChatController::datatable_messages', ['as' => 'getDatatableMessages']); + $routes->get('datatable/presupuesto', 'ChatController::datatable_presupuesto_messages', ['as' => 'getDatatablePresupuestoMessages']); + $routes->get('datatable/pedido', 'ChatController::datatable_pedido_messages', ['as' => 'getDatatablePedidoMessages']); + $routes->get('datatable/factura', 'ChatController::datatable_factura_messages', ['as' => 'getDatatableFacturaMessages']); + + $routes->post('direct', 'ChatController::store_new_direct_message', ['as' => 'storeNewDirectMessage']); + $routes->post('direct/client', 'ChatController::store_new_direct_message_client', ['as' => 'storeNewDirectMessageClient']); + + }); $routes->group('chat', ['namespace' => 'App\Controllers\Chat'], function ($routes) { + + $routes->get('direct/(:num)', 'ChatController::get_chat_direct_view/$1', ['as' => 'getChatDirectView']); + $routes->get('presupuesto/(:num)', 'ChatController::get_chat_presupuesto_view/$1', ['as' => 'getChatPresupuestoView']); + $routes->get('pedido/(:num)', 'ChatController::get_chat_pedido_view/$1', ['as' => 'getChatPedidoView']); + $routes->get('factura/(:num)', 'ChatController::get_chat_factura_view/$1', ['as' => 'getChatFacturaView']); + + $routes->get('direct/conversation/(:num)', 'ChatController::get_chat_direct/$1', ['as' => 'getChatDirect']); + $routes->get('direct/users/select/(:num)', 'ChatController::get_chat_direct_select_users/$1', ['as' => 'getChatDirectSelectUsers']); + $routes->get('direct/users/(:num)', 'ChatController::get_chat_direct_users', ['as' => 'getChatDirectUsers']); + $routes->post('direct/users/(:num)', 'ChatController::store_chat_direct_users/$1', ['as' => 'storeChatDirectUsers']); + $routes->get('direct/messages/(:num)', 'ChatController::get_chat_direct_messages/$1', ['as' => 'getChatDirectMessages']); + $routes->post('direct/messages/(:num)', 'ChatController::store_chat_direct_message/$1', ['as' => 'storeChatDirectMessages']); + $routes->post('direct/messages/unread/(:num)', 'ChatController::update_chat_direct_message_unread/$1', ['as' => 'updateChatDirectMessageUnread']); + + $routes->get('departments', 'ChatController::get_chat_departments', ['as' => 'getChatDepartments']); + $routes->get('departments/select', 'ChatController::get_chat_department_select', ['as' => 'getChatDepartmentSelect']); $routes->get('department/presupuesto/(:num)/(:num)', 'ChatController::get_chat_presupuesto/$1/$2', ['as' => 'getChatPresupuesto']); $routes->get('department/pedido/(:num)/(:num)', 'ChatController::get_chat_pedido/$1/$2', ['as' => 'getChatPedido']); $routes->get('department/factura/(:num)/(:num)', 'ChatController::get_chat_factura/$1/$2', ['as' => 'getChatFactura']); @@ -781,6 +807,8 @@ $routes->group('chat', ['namespace' => 'App\Controllers\Chat'], function ($route $routes->get('contact/(:num)/messages', 'ChatController::get_chat_internal_messages/$1', ['as' => 'getChatInternalMessages']); $routes->get('notifications', 'ChatController::get_chat_cliente/$1', ['as' => 'getChatCliente']); $routes->get('users/internal', 'ChatController::get_chat_users_internal', ['as' => 'getChatUsersInternal']); + $routes->get('users/all', 'ChatController::get_chat_users_all', ['as' => 'getChatUsersAll']); + $routes->post('hebra/presupuesto', 'ChatController::store_hebra_presupuesto', ['as' => 'storeHebraPresupuesto']); $routes->post('hebra/pedido', 'ChatController::store_hebra_pedido', ['as' => 'storeHebraPedido']); $routes->post('hebra/factura', 'ChatController::store_hebra_factura', ['as' => 'storeHebraFactura']); diff --git a/ci4/app/Config/Validation.php b/ci4/app/Config/Validation.php index a93a7146..cb05c77a 100755 --- a/ci4/app/Config/Validation.php +++ b/ci4/app/Config/Validation.php @@ -34,7 +34,7 @@ class Validation extends BaseConfig * @var array */ public array $templates = [ - 'list' => 'CodeIgniter\Validation\Views\list', + 'list' => 'CodeIgniter\Validation\Views\list', 'single' => 'CodeIgniter\Validation\Views\single', 'bootstrap_style' => 'themes/_commonPartialsBs/_form_validation_errors', ]; @@ -42,4 +42,6 @@ class Validation extends BaseConfig // -------------------------------------------------------------------- // Rules // -------------------------------------------------------------------- + + } diff --git a/ci4/app/Controllers/Chat/ChatController.php b/ci4/app/Controllers/Chat/ChatController.php index cad8ad6b..3526b6da 100644 --- a/ci4/app/Controllers/Chat/ChatController.php +++ b/ci4/app/Controllers/Chat/ChatController.php @@ -11,10 +11,13 @@ use App\Models\ChatNotification; use App\Models\ChatUser; use App\Models\Clientes\ClienteModel; use App\Models\Usuarios\UserModel; +use App\Services\MessageService; use CodeIgniter\HTTP\ResponseInterface; use CodeIgniter\HTTP\RequestInterface; use CodeIgniter\Log\Logger; use Psr\Log\LoggerInterface; +use Hermawan\DataTables\DataTable; +use CodeIgniter\I18n\Time; class ChatController extends BaseController { @@ -26,8 +29,8 @@ class ChatController extends BaseController protected ClienteModel $clienteModel; protected ChatUser $chatUserModel; protected ChatNotification $chatNotificationModel; - - + protected array $viewData; + protected static $viewPath = 'themes/vuexy/form/mensajes/'; public function initController( @@ -46,8 +49,6 @@ class ChatController extends BaseController $this->clienteModel = model(ClienteModel::class); $this->chatUserModel = model(ChatUser::class); $this->chatNotificationModel = model(ChatNotification::class); - - } public function index() {} public function get_chat_departments() @@ -56,6 +57,10 @@ class ChatController extends BaseController $data = $this->chatDeparmentModel->getChatDepartments(); return $this->response->setJSON($data); } + public function get_chat_department_select(){ + $query = $this->chatDeparmentModel->getChatDepartmentSelect($this->request->getGet("q")); + return $this->response->setJSON($query->get()->getResultObject()); + } public function get_chat_presupuesto(int $chat_department_id, int $presupuesto_id) { @@ -86,7 +91,6 @@ class ChatController extends BaseController $data["messages"] = $this->chatMessageModel->get_chat_messages($chat->id); $this->chatMessageModel->set_chat_department_messages_as_read($chat->id); $data["count"] = count($data["messages"]); - } $data["chat"] = $chat; return $this->response->setJSON($data); @@ -108,6 +112,76 @@ class ChatController extends BaseController $data["chat"] = $chat; return $this->response->setJSON($data); } + public function get_chat_direct_view($chat_id) + { + $chat = $this->chatModel->find($chat_id); + $this->viewData['breadcrumb'] = [ + ['title' => lang("Chat.chat"), 'route' => route_to("mensajeriaView"), 'active' => false], + ['title' => $chat->title, 'route' => 'javascript:void(0);', 'active' => true] + ]; + $this->viewData["chatId"] = $chat_id; + $auth_user = auth()->user(); + $this->chatModel->setAsViewedChatUserNotifications($chat_id, $auth_user->id); + $this->chatModel->setAsUnviewedChatUserMessages($chat_id, $auth_user->id); + + return view(static::$viewPath . 'messageChat', $this->viewData); + } + public function get_chat_presupuesto_view($chat_id) + { + $chat = $this->chatModel->find($chat_id); + $this->viewData['breadcrumb'] = [ + ['title' => lang("Chat.chat"), 'route' => route_to("mensajeriaView"), 'active' => false], + ['title' => $chat->title, 'route' => 'javascript:void(0);', 'active' => true] + ]; + $this->viewData["modelId"] = $chat->presupuesto_id; + $this->viewData["type"] = "presupuesto"; + $auth_user = auth()->user(); + $this->chatModel->setAsViewedChatUserNotifications($chat_id, $auth_user->id); + $this->chatModel->setAsUnviewedChatUserMessages($chat_id, $auth_user->id); + + if($chat->chat_department_id){ + return view(static::$viewPath . 'messageChatPresupuesto', $this->viewData); + }else{ + return view(static::$viewPath . 'messageChatInternal', $this->viewData); + } + } + public function get_chat_pedido_view($chat_id) + { + $chat = $this->chatModel->find($chat_id); + $this->viewData['breadcrumb'] = [ + ['title' => lang("Chat.chat"), 'route' => route_to("mensajeriaView"), 'active' => false], + ['title' => $chat->title, 'route' => 'javascript:void(0);', 'active' => true] + ]; + $this->viewData["modelId"] = $chat->pedido_id; + $this->viewData["type"] = "pedido"; + $auth_user = auth()->user(); + $this->chatModel->setAsViewedChatUserNotifications($chat_id, $auth_user->id); + $this->chatModel->setAsUnviewedChatUserMessages($chat_id, $auth_user->id); + if($chat->chat_department_id ){ + return view(static::$viewPath . 'messageChatPedido', $this->viewData); + }else{ + return view(static::$viewPath . 'messageChatInternal', $this->viewData); + } + } + public function get_chat_factura_view($chat_id) + { + $chat = $this->chatModel->find($chat_id); + $this->viewData['breadcrumb'] = [ + ['title' => lang("Chat.chat"), 'route' => route_to("mensajeriaView"), 'active' => false], + ['title' => $chat->title, 'route' => 'javascript:void(0);', 'active' => true] + ]; + $this->viewData["modelId"] = $chat->factura_id; + $this->viewData["type"] = "factura"; + $auth_user = auth()->user(); + $this->chatModel->setAsViewedChatUserNotifications($chat_id, $auth_user->id); + $this->chatModel->setAsUnviewedChatUserMessages($chat_id, $auth_user->id); + + if($chat->chat_department_id){ + return view(static::$viewPath . 'messageChatFactura', $this->viewData); + }else{ + return view(static::$viewPath . 'messageChatInternal', $this->viewData); + } + } public function get_chat(int $chat_id) { @@ -128,6 +202,12 @@ class ChatController extends BaseController } $chat_message_id = $this->chatMessageModel->insert(["chat_id" => $chatId, "sender_id" => auth()->user()->id, "message" => $data["message"]]); $dataResponse = $this->chatMessageModel->find($chat_message_id); + $chatDepartmentUsers = $this->chatDeparmentModel->getChatDepartmentUsers($data["chat_department_id"]); + foreach ($chatDepartmentUsers as $user) { + if ($user->id != auth()->user()->id) { + $this->chatNotificationModel->insert(["chat_message_id" => $chat_message_id, "user_id" => $user->id]); + } + } return $this->response->setJSON($dataResponse); } public function store_chat_message_pedido() @@ -143,6 +223,12 @@ class ChatController extends BaseController } $chat_message_id = $this->chatMessageModel->insert(["chat_id" => $chatId, "sender_id" => auth()->user()->id, "message" => $data["message"]]); $dataResponse = $this->chatMessageModel->find($chat_message_id); + $chatDepartmentUsers = $this->chatDeparmentModel->getChatDepartmentUsers($data["chat_department_id"]); + foreach ($chatDepartmentUsers as $user) { + if ($user->id != auth()->user()->id) { + $this->chatNotificationModel->insert(["chat_message_id" => $chat_message_id, "user_id" => $user->id]); + } + } return $this->response->setJSON($dataResponse); } public function store_chat_message_factura() @@ -158,6 +244,12 @@ class ChatController extends BaseController } $chat_message_id = $this->chatMessageModel->insert(["chat_id" => $chatId, "sender_id" => auth()->user()->id, "message" => $data["message"]]); $dataResponse = $this->chatMessageModel->find($chat_message_id); + $chatDepartmentUsers = $this->chatDeparmentModel->getChatDepartmentUsers($data["chat_department_id"]); + foreach ($chatDepartmentUsers as $user) { + if ($user->id != auth()->user()->id) { + $this->chatNotificationModel->insert(["chat_message_id" => $chat_message_id, "user_id" => $user->id]); + } + } return $this->response->setJSON($dataResponse); } public function store_chat_message_single() @@ -175,44 +267,46 @@ class ChatController extends BaseController "chat_id" => $chatId, "sender_id" => auth()->user()->id, "message" => $data["message"], - "receiver_id" => $data["receiver_id"] + "receiver_id" => $data["receiver_id"], ] ); + $this->chatNotificationModel->insert(["chat_message_id" => $chat_message_id, "user_id" => $data["receiver_id"]]); $dataResponse = $this->chatMessageModel->find($chat_message_id); return $this->response->setJSON($dataResponse); } public function get_chat_internal_contacts() { - if (auth()->user()->cliente_id) { - return $this->response->setJSON([]); + $auth_user = auth()->user(); + if ($auth_user->cliente_id) { + $users = $this->chatModel->getOpenChatCliente($auth_user->id); + } else { + $users = $this->userModel->builder() + ->whereNotIn("id", [$auth_user->id]) + ->where("deleted_at", null) + ->get()->getResultObject(); } - $users = $this->userModel->builder() - ->where("cliente_id", null) - ->whereNotIn("id", [auth()->user()->id]) - ->where("deleted_at", null) - ->get()->getResultObject(); foreach ($users as $user) { - $user->unreadMessages = $this->chatMessageModel->get_chat_unread_messages_count($user->id); + $user->unreadMessages = $this->chatMessageModel->get_chat_messages_count($user->id); } usort($users, fn($a, $b) => $a->unreadMessages < $b->unreadMessages); return $this->response->setJSON($users); } public function get_chat_internal_contact(int $user_id) { - if (auth()->user()->cliente_id) { - return $this->response->setJSON([]); - } + $auth_user = auth()->user(); + // if ($auth_user->cliente_id) { + // return $this->response->setJSON([]); + // } $users = $this->userModel->builder() - ->where("cliente_id", null) ->where("deleted_at", null) ->where("id", $user_id) ->get()->getFirstRow(); - $this->chatMessageModel->set_chat_messages_as_read($user_id); return $this->response->setJSON($users); } public function get_chat_internal_messages(int $user_id) { $conversation = $this->chatMessageModel->get_chat_contact_messages($user_id); + return $this->response->setJSON($conversation); } public function get_chat_cliente() @@ -223,6 +317,8 @@ class ChatController extends BaseController $data = $this->clienteModel->getClienteDataPresupuestoPedidoFactura($cliente_id); $response["totalMessages"] = 0; $response["chatFacturas"] = $this->chatModel->getClienteChatFacturas($data["facturas"]); + $mensajes_directos = $this->chatModel->getChatDirectMessageNotifications(); + foreach ($response["chatFacturas"] as $key => $value) { $response["totalMessages"] += $value->unreadMessages; } @@ -230,6 +326,10 @@ class ChatController extends BaseController foreach ($response["chatPresupuestos"] as $key => $value) { $response["totalMessages"] += $value->unreadMessages; } + foreach ($mensajes_directos as $value) { + $response["internals"][] = $value; + $response["totalMessages"] += $value->unreadMessages; + } $response["chatPedidos"] = $this->chatModel->getClienteChatPedidos($data["pedidos"]); foreach ($response["chatPedidos"] as $key => $value) { $response["totalMessages"] += $value->unreadMessages; @@ -238,9 +338,13 @@ class ChatController extends BaseController } else { $response["internals"] = $this->chatModel->getChatDepartmentNotifications(); $internal_notifications = $this->chatModel->getChatInternalNotifications(); + $mensajes_directos = $this->chatModel->getChatDirectMessageNotifications(); foreach ($internal_notifications as $value) { $response["internals"][] = $value; } + foreach ($mensajes_directos as $value) { + $response["internals"][] = $value; + } $response["totalMessages"] = 0; foreach ($response["internals"] as $key => $value) { $response["totalMessages"] += $value->unreadMessages; @@ -263,7 +367,26 @@ class ChatController extends BaseController ] )->where("cliente_id", null) ->where("deleted_at", null) - ->whereNotIn("id",[auth()->user()->id]); + ->whereNotIn("id", [auth()->user()->id]); + if ($this->request->getGet("q")) { + $query->groupStart() + ->orLike("users.username", $this->request->getGet("q")) + ->orLike("CONCAT(first_name,' ',last_name)", $this->request->getGet("q")) + ->groupEnd(); + } + + return $this->response->setJSON($query->get()->getResultObject()); + } + public function get_chat_users_all() + { + $query = $this->userModel->builder()->select( + [ + "id", + "CONCAT(first_name,' ',last_name,'(',username,')') as name" + ] + ) + ->where("deleted_at", null) + ->whereNotIn("id", [auth()->user()->id]); if ($this->request->getGet("q")) { $query->groupStart() ->orLike("users.username", $this->request->getGet("q")) @@ -275,6 +398,7 @@ class ChatController extends BaseController } public function store_hebra_presupuesto() { + $auth_user = auth()->user(); $bodyData = $this->request->getPost(); $chat_id = $this->chatModel->insert([ "presupuesto_id" => $bodyData["modelId"], @@ -283,17 +407,19 @@ class ChatController extends BaseController $chatMessageId = $this->chatMessageModel->insert([ "chat_id" => $chat_id, "message" => $bodyData["message"], - "sender_id" => auth()->user()->id + "sender_id" => $auth_user->id ]); - if(isset($bodyData["users"])){ - $chatUserData = array_map(fn($x) => ["user_id" => $x,"chat_id" => $chat_id],$bodyData["users"]); + if (isset($bodyData["users"])) { + $bodyData["users"][] = $auth_user->id; + $chatUserData = array_map(fn($x) => ["user_id" => $x, "chat_id" => $chat_id], $bodyData["users"]); $this->chatUserModel->insertBatch($chatUserData); foreach ($bodyData["users"] as $userId) { $this->chatNotificationModel->insert( - ["chat_message_id" => $chatMessageId,"user_id" => $userId]); + ["chat_message_id" => $chatMessageId, "user_id" => $userId] + ); } } - return $this->response->setJSON(["message" => "Hebra creada correctamente","status" => true]); + return $this->response->setJSON(["message" => "Hebra creada correctamente", "status" => true]); } public function store_hebra_pedido() @@ -309,15 +435,16 @@ class ChatController extends BaseController "message" => $bodyData["message"], "sender_id" => auth()->user()->id ]); - if(isset($bodyData["users"])){ - $chatUserData = array_map(fn($x) => ["user_id" => $x,"chat_id" => $chat_id],$bodyData["users"]); + if (isset($bodyData["users"])) { + $chatUserData = array_map(fn($x) => ["user_id" => $x, "chat_id" => $chat_id], $bodyData["users"]); $this->chatUserModel->insertBatch($chatUserData); foreach ($bodyData["users"] as $userId) { $this->chatNotificationModel->insert( - ["chat_message_id" => $chatMessageId,"user_id" => $userId]); + ["chat_message_id" => $chatMessageId, "user_id" => $userId] + ); } } - return $this->response->setJSON(["message" => "Hebra creada correctamente","status" => true]); + return $this->response->setJSON(["message" => "Hebra creada correctamente", "status" => true]); } public function store_hebra_factura() @@ -332,89 +459,242 @@ class ChatController extends BaseController "message" => $bodyData["message"], "sender_id" => auth()->user()->id ]); - if(isset($bodyData["users"])){ - $chatUserData = array_map(fn($x) => ["user_id" => $x,"chat_id" => $chat_id],$bodyData["users"]); + if (isset($bodyData["users"])) { + $chatUserData = array_map(fn($x) => ["user_id" => $x, "chat_id" => $chat_id], $bodyData["users"]); $this->chatUserModel->insertBatch($chatUserData); foreach ($bodyData["users"] as $userId) { $this->chatNotificationModel->insert( - ["chat_message_id" => $chatMessageId,"user_id" => $userId]); + ["chat_message_id" => $chatMessageId, "user_id" => $userId] + ); } } - return $this->response->setJSON(["message" => "Hebra creada correctamente","status" => true]); - + return $this->response->setJSON(["message" => "Hebra creada correctamente", "status" => true]); } public function update_hebra($chat_id) { $bodyData = $this->request->getPost(); - $chatMessageId = $this->chatMessageModel->insert([ + $chatMessageId = $this->chatMessageModel->insert([ "chat_id" => $chat_id, "message" => $bodyData["message"], "sender_id" => auth()->user()->id ]); - $actualUsers = $this->chatUserModel->builder()->select("user_id")->where("chat_id",$chat_id)->get()->getResultArray(); - $actualUsersArray = array_map(fn($x) => $x["user_id"],$actualUsers); + $actualUsers = $this->chatUserModel->builder()->select("user_id")->where("chat_id", $chat_id)->get()->getResultArray(); + $actualUsersArray = array_map(fn($x) => $x["user_id"], $actualUsers); foreach ($actualUsersArray as $key => $user_id) { $this->chatNotificationModel->insert( - ["chat_message_id" => $chatMessageId,"user_id" => $user_id]); + ["chat_message_id" => $chatMessageId, "user_id" => $user_id] + ); } - if(isset($bodyData["users"])){ + if (isset($bodyData["users"])) { foreach ($bodyData["users"] as $userId) { - if(in_array($userId,$actualUsersArray) == false){ - $chatUserData = ["user_id" => $userId,"chat_id" => $chat_id]; + if (in_array($userId, $actualUsersArray) == false) { + $chatUserData = ["user_id" => $userId, "chat_id" => $chat_id]; $this->chatUserModel->insert($chatUserData); - } $this->chatNotificationModel->insert( - ["chat_message_id" => $chatMessageId,"user_id" => $userId]); + ["chat_message_id" => $chatMessageId, "user_id" => $userId] + ); } } - return $this->response->setJSON(["message" => "Hebra actualizada correctamente","status" => true]); + return $this->response->setJSON(["message" => "Hebra actualizada correctamente", "status" => true]); } - public function get_hebra_presupuesto($presupuesto_id){ + public function get_hebra_presupuesto($presupuesto_id) + { $data = $this->chatModel->getPresupuestoHebras($presupuesto_id); $notifications = $this->chatModel->builder()->select([ "chat_notifications.id" ]) - ->join("chat_messages","chat_messages.chat_id = chats.id","left") - ->join("chat_notifications","chat_notifications.chat_message_id = chat_messages.id","left") - ->where("chats.presupuesto_id",$presupuesto_id) - ->where("chat_notifications.user_id",auth()->user()->id) - ->get()->getResultArray(); + ->join("chat_messages", "chat_messages.chat_id = chats.id", "left") + ->join("chat_notifications", "chat_notifications.chat_message_id = chat_messages.id", "left") + ->where("chats.presupuesto_id", $presupuesto_id) + ->where("chat_notifications.user_id", auth()->user()->id) + ->get()->getResultArray(); foreach ($notifications as $notification) { - $this->chatNotificationModel->update($notification["id"],["viewed" => true]); + $this->chatNotificationModel->update($notification["id"], ["viewed" => true]); } return $this->response->setJSON($data); } - public function get_hebra_pedido($pedido_id){ + public function get_hebra_pedido($pedido_id) + { $data = $this->chatModel->getPedidoHebras($pedido_id); $notifications = $this->chatModel->builder()->select([ "chat_notifications.id" ]) - ->join("chat_messages","chat_messages.chat_id = chats.id","left") - ->join("chat_notifications","chat_notifications.chat_message_id = chat_messages.id","left") - ->where("chats.pedido_id",$pedido_id) - ->where("chat_notifications.user_id",auth()->user()->id) - ->get()->getResultArray(); + ->join("chat_messages", "chat_messages.chat_id = chats.id", "left") + ->join("chat_notifications", "chat_notifications.chat_message_id = chat_messages.id", "left") + ->where("chats.pedido_id", $pedido_id) + ->where("chat_notifications.user_id", auth()->user()->id) + ->get()->getResultArray(); foreach ($notifications as $notification) { - $this->chatNotificationModel->update($notification["id"],["viewed" => true]); + $this->chatNotificationModel->update($notification["id"], ["viewed" => true]); } return $this->response->setJSON($data); } - public function get_hebra_factura($factura_id){ + public function get_hebra_factura($factura_id) + { $data = $this->chatModel->getFacturaHebras($factura_id); $notifications = $this->chatModel->builder()->select([ "chat_notifications.id" ]) - ->join("chat_messages","chat_messages.chat_id = chats.id","left") - ->join("chat_notifications","chat_notifications.chat_message_id = chat_messages.id","left") - ->where("chats.factura_id",$factura_id) - ->where("chat_notifications.user_id",auth()->user()->id) - ->get()->getResultArray(); + ->join("chat_messages", "chat_messages.chat_id = chats.id", "left") + ->join("chat_notifications", "chat_notifications.chat_message_id = chat_messages.id", "left") + ->where("chats.factura_id", $factura_id) + ->where("chat_notifications.user_id", auth()->user()->id) + ->get()->getResultArray(); foreach ($notifications as $notification) { - $this->chatNotificationModel->update($notification["id"],["viewed" => true]); + $this->chatNotificationModel->update($notification["id"], ["viewed" => true]); } return $this->response->setJSON($data); } + public function datatable_messages() + { + $auth_user_id = auth()->user()->id; + $query = $this->chatModel->getQueryDatatable($auth_user_id); + return DataTable::of($query) + ->edit('created_at', fn($q) => Time::createFromFormat('Y-m-d H:i:s', $q->created_at)->format("d/m/Y H:i")) + ->edit('updated_at', fn($q) => Time::createFromFormat('Y-m-d H:i:s', $q->updated_at)->format("d/m/Y H:i")) + ->add("creator", fn($q) => $this->chatModel->getChatFirstUser($q->id)->userFullName) + ->add("viewed", fn($q) => $this->chatModel->isMessageChatViewed($q->id, $auth_user_id)) + ->add("action", fn($q) => ["type" => "direct","modelId" => $q->id]) + ->toJson(true); + } + public function datatable_presupuesto_messages() + { + $auth_user_id = auth()->user()->id; + $query = $this->chatModel->getQueryDatatableMessagePresupuesto($auth_user_id); + return DataTable::of($query) + ->edit('created_at', fn($q) => $q->created_at ? Time::createFromFormat('Y-m-d H:i:s', $q->created_at)->format("d/m/Y H:i") : "") + ->edit('updated_at', fn($q) => $q->updated_at ? Time::createFromFormat('Y-m-d H:i:s', $q->updated_at)->format("d/m/Y H:i") : "") + ->add("creator", fn($q) => $this->chatModel->getChatFirstUser($q->id)->userFullName) + ->add("viewed", fn($q) => $this->chatModel->isMessageChatViewed($q->id, $auth_user_id)) + ->add("action", fn($q) => ["type" => "presupuesto","modelId" => $q->id]) + ->toJson(true); + } + public function datatable_pedido_messages() + { + $auth_user_id = auth()->user()->id; + $query = $this->chatModel->getQueryDatatableMessagePedido($auth_user_id); + return DataTable::of($query) + ->edit('created_at', fn($q) => $q->created_at ? Time::createFromFormat('Y-m-d H:i:s', $q->created_at)->format("d/m/Y H:i") : "") + ->edit('updated_at', fn($q) => $q->updated_at ? Time::createFromFormat('Y-m-d H:i:s', $q->updated_at)->format("d/m/Y H:i") : "") + ->add("creator", fn($q) => $this->chatModel->getChatFirstUser($q->id)->userFullName) + ->add("viewed", fn($q) => $this->chatModel->isMessageChatViewed($q->id, $auth_user_id)) + ->add("action", fn($q) => ["type" => "pedido","modelId" => $q->id]) + ->toJson(true); + } + public function datatable_factura_messages() + { + $auth_user_id = auth()->user()->id; + $query = $this->chatModel->getQueryDatatableMessageFactura($auth_user_id); + return DataTable::of($query) + ->edit('created_at', fn($q) => $q->created_at ? Time::createFromFormat('Y-m-d H:i:s', $q->created_at)->format("d/m/Y H:i") : "") + ->edit('updated_at', fn($q) => $q->updated_at ? Time::createFromFormat('Y-m-d H:i:s', $q->updated_at)->format("d/m/Y H:i") : "") + ->add("creator", fn($q) => $this->chatModel->getChatFirstUser($q->id)->userFullName) + ->add("viewed", fn($q) => $this->chatModel->isMessageChatViewed($q->id, $auth_user_id)) + ->add("action", fn($q) => ["type" => "factura","modelId" => $q->id]) + + ->toJson(true); + } + public function store_new_direct_message() + { + $bodyData = $this->request->getPost(); + $rules = [ + "title" => "required|string", + "message" => "required|string", + "users" => "required", + + ]; + if (!$this->validate($rules)) { + return $this->response->setStatusCode(400)->setJSON([ + 'message' => lang('App.global_alert_save_error'), + 'status' => 'error', + 'errors' => $this->validator->getErrors(), + ]); + } + $this->chatModel->createNewDirectChat(...$bodyData); + return $this->response->setJSON(["message" => lang("Chat.new_message_ok"), "status" => true]); + } + public function store_new_direct_message_client() + { + $bodyData = $this->request->getPost(); + $rules = [ + "title" => "required|string", + "message" => "required|string", + "chat_department_id" => "required", + + ]; + if (!$this->validate($rules)) { + return $this->response->setStatusCode(400)->setJSON([ + 'message' => lang('App.global_alert_save_error'), + 'status' => 'error', + 'errors' => $this->validator->getErrors(), + ]); + } + $users = $this->chatDeparmentModel->getChatDepartmentUsers($bodyData["chat_department_id"]); + $bodyData["users"] = array_map(fn($q) => $q->id,$users); + dd(1); + $this->chatModel->createNewDirectChat(...$bodyData); + return $this->response->setJSON(["message" => lang("Chat.new_message_ok"), "status" => true]); + } + public function get_chat_direct($chat_id) + { + $chatData = $this->chatModel->getChatDirect($chat_id); + return $this->response->setJSON($chatData); + } + public function get_chat_direct_select_users($chat_id) + { + $chat_users_id = $this->chatUserModel->getChatUserArrayId($chat_id); + + $query = $this->userModel->builder()->select( + [ + "id", + "CONCAT(first_name,' ',last_name,'(',username,')') as name" + ] + ) + ->where("deleted_at", null) + ->whereNotIn("id", $chat_users_id); + if ($this->request->getGet("q")) { + $query->groupStart() + ->orLike("users.username", $this->request->getGet("q")) + ->orLike("CONCAT(first_name,' ',last_name)", $this->request->getGet("q")) + ->groupEnd(); + } + + return $this->response->setJSON($query->get()->getResultObject()); + } + public function store_chat_direct_users($chat_id) + { + $bodyData = $this->request->getPost(); + $chat_users = []; + foreach ($bodyData["users"] as $user_id) { + $chat_users[] = ["chat_id" => $chat_id, "user_id" => $user_id]; + if ($bodyData["notification"]) { + $this->chatModel->createNotificationsToNewChatUser($chat_id, $user_id); + } + } + $this->chatUserModel->insertBatch($chat_users); + return $this->response->setJSON(["message" => "ok", "status" => true]); + } + public function store_chat_direct_message(int $chat_id) + { + $bodyData = $this->request->getPost(); + $auth_user = auth()->user(); + $bodyData["sender_id"] = $auth_user->id; + $chat_message_id = $this->chatMessageModel->insert($bodyData); + $users_id = $this->chatUserModel->getChatUserArrayId($chat_id); + foreach ($users_id as $user_id) { + if ($user_id != $auth_user->id) { + $this->chatNotificationModel->insert(["chat_message_id" => $chat_message_id, "user_id" => $user_id]); + } + }; + $message = $this->chatMessageModel->get_chat_message($chat_message_id); + return $this->response->setJSON($message); + } + public function update_chat_direct_message_unread($chat_id) + { + $this->chatModel->setAsUnviewedChatUserNotifications($chat_id, auth()->user()->id); + return $this->response->setJSON(["message" => "ok", "status" => true]); + } } diff --git a/ci4/app/Controllers/Clientes/Clientedirecciones.php b/ci4/app/Controllers/Clientes/Clientedirecciones.php index 872eeeca..2979bd10 100755 --- a/ci4/app/Controllers/Clientes/Clientedirecciones.php +++ b/ci4/app/Controllers/Clientes/Clientedirecciones.php @@ -234,6 +234,10 @@ class Clientedirecciones extends \App\Controllers\BaseResourceController try { $model = model('App\Models\Presupuestos\PresupuestoDireccionesModel'); $resourceData = $model->getDireccion($id); + if(count($resourceData) > 0){ + $resourceData[0]->direccionId = $id; + } + $response = (object)[ 'error' => false, 'data' => $resourceData diff --git a/ci4/app/Controllers/Configuracion/Comunidadesautonomas.php b/ci4/app/Controllers/Configuracion/Comunidadesautonomas.php index 86f8ae6b..141c29c1 100755 --- a/ci4/app/Controllers/Configuracion/Comunidadesautonomas.php +++ b/ci4/app/Controllers/Configuracion/Comunidadesautonomas.php @@ -271,6 +271,27 @@ class Comunidadesautonomas extends \App\Controllers\BaseResourceController } } + public function menuItems2() + { + if ($this->request->isAJAX()) { + $query = $this->model->builder()->select( + [ + "id", + "nombre as name" + ] + )->orderBy("nombre", "asc"); + if ($this->request->getGet("q")) { + $query->groupStart() + ->orLike("lg_comunidades_autonomas.nombre", $this->request->getGet("q")) + ->groupEnd(); + } + + return $this->response->setJSON($query->get()->getResultObject()); + } else { + return $this->failUnauthorized('Invalid request', 403); + } + } + protected function getPaisListItems($selId = null) { diff --git a/ci4/app/Controllers/Configuracion/FormasPago.php b/ci4/app/Controllers/Configuracion/FormasPago.php index a2867c59..9186a2af 100644 --- a/ci4/app/Controllers/Configuracion/FormasPago.php +++ b/ci4/app/Controllers/Configuracion/FormasPago.php @@ -230,25 +230,19 @@ class FormasPago extends \App\Controllers\BaseResourceController 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); + $query = $this->model->builder()->select( + [ + "id", + "nombre as name" + ] + )->orderBy("nombre", "asc"); + if ($this->request->getGet("q")) { + $query->groupStart() + ->orLike("formas_pago.nombre", $this->request->getGet("q")) + ->groupEnd(); + } - $newTokenHash = csrf_hash(); - $csrfTokenName = csrf_token(); - $data = [ - 'menu' => $menu, - $csrfTokenName => $newTokenHash - ]; - return $this->respond($data); + return $this->response->setJSON($query->get()->getResultObject()); } else { return $this->failUnauthorized('Invalid request', 403); } diff --git a/ci4/app/Controllers/Configuracion/Paises.php b/ci4/app/Controllers/Configuracion/Paises.php index 05383412..a9d8b5d1 100755 --- a/ci4/app/Controllers/Configuracion/Paises.php +++ b/ci4/app/Controllers/Configuracion/Paises.php @@ -269,4 +269,25 @@ class Paises extends \App\Controllers\BaseResourceController } } + public function menuItems2() + { + if ($this->request->isAJAX()) { + $query = $this->model->builder()->select( + [ + "id", + "nombre as name" + ] + )->orderBy("nombre", "asc"); + if ($this->request->getGet("q")) { + $query->groupStart() + ->orLike("lg_paises.nombre", $this->request->getGet("q")) + ->groupEnd(); + } + + return $this->response->setJSON($query->get()->getResultObject()); + } else { + return $this->failUnauthorized('Invalid request', 403); + } + } + } diff --git a/ci4/app/Controllers/Configuracion/Papelesgenericos.php b/ci4/app/Controllers/Configuracion/Papelesgenericos.php index d0b93c2b..628be5c4 100755 --- a/ci4/app/Controllers/Configuracion/Papelesgenericos.php +++ b/ci4/app/Controllers/Configuracion/Papelesgenericos.php @@ -156,8 +156,13 @@ class Papelesgenericos extends \App\Controllers\BaseResourceController if ($this->request->getPost('show_in_client') == null) { $sanitizedData['show_in_client'] = false; } - - + if ($this->request->getPost('show_in_client_special') == null) { + $sanitizedData['show_in_client_special'] = false; + } + + if($sanitizedData['show_in_client_special']){ + $sanitizedData['show_in_client'] = true; + } $noException = true; if ($successfulResult = $this->canValidate()) : // if ($successfulResult = $this->validate($this->formValidationRules) ) : @@ -288,4 +293,52 @@ class Papelesgenericos extends \App\Controllers\BaseResourceController return $this->failUnauthorized('Invalid request', 403); } } + + public function getPapelCliente() + { + if ($this->request->isAJAX()) { + + $tipo = goSanitize($this->request->getGet('tipo'))[0]; + $selected_papel = goSanitize($this->request->getGet('papel'))[0] ?? null; + $cubierta = goSanitize($this->request->getGet('cubierta'))[0] ?? 0; + $tapa_dura = goSanitize($this->request->getGet('tapa_dura'))[0] ?? null; + + $menu = $this->model->getPapelCliente($tipo, $cubierta, $selected_papel, $tapa_dura, false); + $menu2 = $this->model->getPapelCliente($tipo, $cubierta, $selected_papel, $tapa_dura, true); + + $newTokenHash = csrf_hash(); + $csrfTokenName = csrf_token(); + $data = [ + 'papeles' => $menu, + 'papeles_especiales' => $menu2, + $csrfTokenName => $newTokenHash + ]; + return $this->respond($data); + } else { + return $this->failUnauthorized('Invalid request', 403); + } + } + + + public function selectPapelEspecial() + { + + if ($this->request->isAJAX()) { + + $tipo = goSanitize($this->request->getGet('tipo'))[0]; + $cubierta = goSanitize($this->request->getGet('cubierta'))[0] ?? 0; + + $items = $this->model->getPapelCliente($tipo, $cubierta, null, true); + $items = array_map(function ($item) { + return [ + 'id' => $item->id, + 'name' => $item->nombre + ]; + }, $items); + return $this->response->setJSON($items); + + } else { + return $this->failUnauthorized('Invalid request', 403); + } + } } diff --git a/ci4/app/Controllers/Configuracion/Papelesimpresion.php b/ci4/app/Controllers/Configuracion/Papelesimpresion.php index 15f7160e..d3da2fad 100755 --- a/ci4/app/Controllers/Configuracion/Papelesimpresion.php +++ b/ci4/app/Controllers/Configuracion/Papelesimpresion.php @@ -175,7 +175,7 @@ class Papelesimpresion extends \App\Controllers\BaseResourceController if ($this->request->getPost()) : - $nullIfEmpty = true; // !(phpversion() >= '8.1'); + $nullIfEmpty = false; // !(phpversion() >= '8.1'); $postData = $this->request->getPost(); @@ -188,6 +188,9 @@ class Papelesimpresion extends \App\Controllers\BaseResourceController if ($this->request->getPost('defecto') == null) { $sanitizedData['defecto'] = false; } + if ($this->request->getPost('interior') == null) { + $sanitizedData['interior'] = false; + } if ($this->request->getPost('bn') == null) { $sanitizedData['bn'] = false; } @@ -197,6 +200,9 @@ class Papelesimpresion extends \App\Controllers\BaseResourceController if ($this->request->getPost('cubierta') == null) { $sanitizedData['cubierta'] = false; } + if ($this->request->getPost('use_for_tapa_dura') == null) { + $sanitizedData['use_for_tapa_dura'] = false; + } if ($this->request->getPost('sobrecubierta') == null) { $sanitizedData['sobrecubierta'] = false; } @@ -209,6 +215,12 @@ class Papelesimpresion extends \App\Controllers\BaseResourceController if ($this->request->getPost('inkjet') == null) { $sanitizedData['inkjet'] = false; } + if ($this->request->getPost('isActivo') == null) { + $sanitizedData['isActivo'] = false; + } + if ($this->request->getPost('use_in_client') == null) { + $sanitizedData['use_in_client'] = false; + } // Hay que asegurarse de que se quitan los consumos de tintas de rotativa // en caso de que se haya deseleccionado la opción rotativa diff --git a/ci4/app/Controllers/Configuracion/Provincias.php b/ci4/app/Controllers/Configuracion/Provincias.php index 573a4a39..ffbfa084 100755 --- a/ci4/app/Controllers/Configuracion/Provincias.php +++ b/ci4/app/Controllers/Configuracion/Provincias.php @@ -271,6 +271,27 @@ class Provincias extends \App\Controllers\BaseResourceController } } + public function menuItems2() + { + if ($this->request->isAJAX()) { + $query = $this->model->builder()->select( + [ + "id", + "nombre as name" + ] + )->orderBy("nombre", "asc"); + if ($this->request->getGet("q")) { + $query->groupStart() + ->orLike("lg_provincias.nombre", $this->request->getGet("q")) + ->groupEnd(); + } + + return $this->response->setJSON($query->get()->getResultObject()); + } else { + return $this->failUnauthorized('Invalid request', 403); + } + } + protected function getPaisListItems($selId = null) { diff --git a/ci4/app/Controllers/Configuracion/Users.php b/ci4/app/Controllers/Configuracion/Users.php index dcb8a140..82cf1422 100755 --- a/ci4/app/Controllers/Configuracion/Users.php +++ b/ci4/app/Controllers/Configuracion/Users.php @@ -20,7 +20,6 @@ class Users extends \App\Controllers\GoBaseController private ChatDeparmentUserModel $chat_department_user_model; - use \CodeIgniter\API\ResponseTrait; protected static $primaryModelName = 'App\Models\UserModel'; @@ -62,7 +61,7 @@ class Users extends \App\Controllers\GoBaseController $this->viewData['usingClientSideDataTable'] = true; $this->viewData['pageSubTitle'] = lang('Basic.global.ManageAllRecords', [lang('Users.user')]); $this->viewData['user_model'] = $this->user_model; - $this->viewData['userList2'] = auth()->getProvider()->findAll(); + $this->viewData['userList2'] = auth()->getProvider()->findAll(); parent::index(); } @@ -77,17 +76,17 @@ class Users extends \App\Controllers\GoBaseController // Obtener contraseña nueva si se ha introducido en texto plano if (empty($postData['new_pwd'])) { $postData['password'] = 'Safekat2024'; // Contraseña por defecto - }else{ + } else { $postData['password'] = $postData['new_pwd']; } + // Obtener los grupos a los que pertenece $currentGroups = $postData['group'] ?? []; $chatDepartments = $postData['chatDepartments'] ?? []; unset($postData['group']); unset($postData['chatDepartments']); - // Generar el nombre de usuario - $postData['username'] = strstr($postData['email'], '@', true); + // Marcar el username como NULL $sanitizedData = $this->sanitized($postData, true); $noException = true; @@ -99,33 +98,43 @@ class Users extends \App\Controllers\GoBaseController if ($this->canValidate()) : try { - $user = new User([ - '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); - if (strpos($e->getMessage(), 'correo duplicado') !== false) { - $this->viewData['errorMessage'] = "El correo electrónico ya está registrado en el sistema"; + // The Email is unique + if ($this->user_model->isEmailUnique($sanitizedData['email'])) { + + // Crear el usuario si pasa la validación + $user = new \CodeIgniter\Shield\Entities\User([ + 'username' => null, // If you don't have a username, be sure to set the value to null anyway, so that it passes CodeIgniter's empty data check + 'first_name' => $sanitizedData['first_name'], + 'last_name' => $sanitizedData['last_name'], + 'cliente_id' => $sanitizedData['cliente_id'], + 'comments' => $sanitizedData['comments'], + 'email' => $sanitizedData['email'], + 'password' => $sanitizedData['password'], + 'status' => $sanitizedData['status'] ?? 0, + 'active' => $sanitizedData['active'] ?? 0, + ]); + // Add the user to the system + $users->save($user); + $successfulResult = true; // Hacked + + } // Email is not unique! + else { + $this->viewData['errorMessage'] = "El correo '". $sanitizedData['email'] ."' ya está registrado en el sistema"; $this->session->setFlashdata('formErrors', $this->model->errors()); + $successfulResult = false; // Hacked } + } catch (\Exception $e) { + $noException = false; + $this->viewData['errorMessage'] = $e->getMessage(); } 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; + if ($noException && $successfulResult) : $id = $users->getInsertID(); @@ -137,12 +146,11 @@ class Users extends \App\Controllers\GoBaseController ]; $this->group_user_model->insert($group_user_data); } - $this->chat_department_user_model->where("user_id",$id)->delete(); - foreach($chatDepartments as $chatDepartment) - { + $this->chat_department_user_model->where("user_id", $id)->delete(); + foreach ($chatDepartments as $chatDepartment) { $this->chat_department_user_model->insert([ "user_id" => $id, - "chat_department_id" => $this->chat_department_model->where("name",$chatDepartment)->first()["id"] + "chat_department_id" => $this->chat_department_model->where("name", $chatDepartment)->first()["id"] ]); } @@ -199,7 +207,6 @@ class Users extends \App\Controllers\GoBaseController unset($postData['group']); unset($postData['chatDepartments']); - // 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']; @@ -254,12 +261,11 @@ class Users extends \App\Controllers\GoBaseController ]; $this->group_user_model->insert($group_user_data); } - $this->chat_department_user_model->where("user_id",$id)->delete(); - foreach($chatDepartments as $chatDepartment) - { + $this->chat_department_user_model->where("user_id", $id)->delete(); + foreach ($chatDepartments as $chatDepartment) { $this->chat_department_user_model->insert([ "user_id" => $id, - "chat_department_id" => $this->chat_department_model->where("name",$chatDepartment)->first()["id"] + "chat_department_id" => $this->chat_department_model->where("name", $chatDepartment)->first()["id"] ]); } $id = $user->id ?? $id; @@ -284,7 +290,7 @@ class Users extends \App\Controllers\GoBaseController $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['chatDepartments'] = $this->chat_department_model->select(["display","name","id as chatDepartmentId"])->findAll(); + $this->viewData['chatDepartments'] = $this->chat_department_model->select(["display", "name", "id as chatDepartmentId"])->findAll(); $this->viewData['chatDepartmentUser'] = $this->chat_department_user_model->getChatDepartmentUser($user->id); $this->viewData['boxTitle'] = lang('Basic.global.edit2') . ' ' . lang('Users.user') . ' ' . lang('Basic.global.edit3'); @@ -308,7 +314,7 @@ class Users extends \App\Controllers\GoBaseController endif; $users = auth()->getProvider(); - $users->delete($user->id); + $users->delete($user->id, true); $message = "Usuario eliminado correctamente"; return $this->redirect2listView('successMessage', $message); @@ -372,13 +378,7 @@ class Users extends \App\Controllers\GoBaseController if ($this->request->isAJAX()) { $comerciales = $this->model->getComerciales(); - $newTokenHash = csrf_hash(); - $csrfTokenName = csrf_token(); - $data = [ - 'menu' => $comerciales, - $csrfTokenName => $newTokenHash - ]; - return $this->respond($data); + return $this->respond($comerciales); } else { return $this->failUnauthorized('Invalid request', 403); } diff --git a/ci4/app/Controllers/Js_loader.php b/ci4/app/Controllers/Js_loader.php index 58b9aa02..e402c125 100755 --- a/ci4/app/Controllers/Js_loader.php +++ b/ci4/app/Controllers/Js_loader.php @@ -14,10 +14,10 @@ class Js_loader extends BaseController - function comparadorCosidoTapaBlanda_js() + function comparadorPresupuestoAdmin_js() { $this->response->setHeader('Content-Type', 'text/javascript'); - return view('themes/vuexy/form/presupuestos/cosidotapablanda/comparador.js'); + return view('themes/vuexy/form/presupuestos/admin/comparador.js'); } @@ -37,49 +37,49 @@ class Js_loader extends BaseController function datosLibro_js() { $this->response->setHeader('Content-Type', 'text/javascript'); - return view('themes/vuexy/form/presupuestos/cosidotapablanda/_datosLibroItems.js'); + return view('themes/vuexy/form/presupuestos/admin/_datosLibroItems.js'); } function previsualizador_js() { $this->response->setHeader('Content-Type', 'text/javascript'); - return view('themes/vuexy/form/presupuestos/cosidotapablanda/previews.js'); + return view('themes/vuexy/form/presupuestos/admin/previews.js'); } function lineasPresupuesto_js() { $this->response->setHeader('Content-Type', 'text/javascript'); - return view('themes/vuexy/form/presupuestos/cosidotapablanda/_lineasPresupuestoItems.js'); + return view('themes/vuexy/form/presupuestos/admin/_lineasPresupuestoItems.js'); } function tiradasAlternativas_js() { $this->response->setHeader('Content-Type', 'text/javascript'); - return view('themes/vuexy/form/presupuestos/cosidotapablanda/_tiradasAlternativasItems.js'); + return view('themes/vuexy/form/presupuestos/admin/_tiradasAlternativasItems.js'); } function datosServicios_js() { $this->response->setHeader('Content-Type', 'text/javascript'); - return view('themes/vuexy/form/presupuestos/cosidotapablanda/_datosServiciosItems.js'); + return view('themes/vuexy/form/presupuestos/admin/_datosServiciosItems.js'); } function datosEnvios_js() { $this->response->setHeader('Content-Type', 'text/javascript'); - return view('themes/vuexy/form/presupuestos/cosidotapablanda/_datosEnvios.js'); + return view('themes/vuexy/form/presupuestos/admin/_datosEnvios.js'); } function resumenPresupuestos_js() { $this->response->setHeader('Content-Type', 'text/javascript'); - return view('themes/vuexy/form/presupuestos/cosidotapablanda/_resumenPresupuestos.js'); + return view('themes/vuexy/form/presupuestos/admin/_resumenPresupuestos.js'); } function presupuestos_js() { $this->response->setHeader('Content-Type', 'text/javascript'); - return view('themes/vuexy/form/presupuestos/cosidotapablanda/_presupuestos.js'); + return view('themes/vuexy/form/presupuestos/admin/_presupuestos.js'); } function presupuestoCliente_js() diff --git a/ci4/app/Controllers/Pdf/PrintPresupuestos.php b/ci4/app/Controllers/Pdf/PrintPresupuestos.php index 03b372ee..fe16b597 100755 --- a/ci4/app/Controllers/Pdf/PrintPresupuestos.php +++ b/ci4/app/Controllers/Pdf/PrintPresupuestos.php @@ -56,8 +56,13 @@ class PrintPresupuestos extends BaseController $options->set('isRemoteEnabled', true); $dompdf = new \Dompdf\Dompdf($options); - // Contenido HTML del documento - $dompdf->loadHtml(view(getenv('theme.path').'pdfs/presupuesto', $data)); + // Metodo que funciona en el docker + $css = file_get_contents(getenv('theme.path'). 'css/pdf.presupuesto.css'); + $html = view(getenv('theme.path') . 'pdfs/presupuesto', $data); + $html = "" . $html; + $dompdf->loadHtml($html); + + //$dompdf->loadHtml(view(getenv('theme.path') . 'pdfs/presupuesto', $data)); // Establecer el tamaño del papel $dompdf->setPaper('A4', 'portrait'); diff --git a/ci4/app/Controllers/Presupuestos/Cosidotapablanda.php b/ci4/app/Controllers/Presupuestos/Presupuestoadmin.php old mode 100755 new mode 100644 similarity index 98% rename from ci4/app/Controllers/Presupuestos/Cosidotapablanda.php rename to ci4/app/Controllers/Presupuestos/Presupuestoadmin.php index fa04075c..36c8a103 --- a/ci4/app/Controllers/Presupuestos/Cosidotapablanda.php +++ b/ci4/app/Controllers/Presupuestos/Presupuestoadmin.php @@ -19,22 +19,22 @@ use App\Models\Presupuestos\PresupuestoServiciosExtraModel; use App\Services\PresupuestoService; use Exception; -class Cosidotapablanda extends \App\Controllers\BaseResourceController +class Presupuestoadmin extends \App\Controllers\BaseResourceController { protected $modelName = "PresupuestoModel"; protected $format = 'json'; - protected static $singularObjectName = 'Cosido Tapa Blanda'; - protected static $singularObjectNameCc = 'Cosidotapablanda'; - protected static $pluralObjectName = 'Cosidos Tapa Blanda'; - protected static $pluralObjectNameCc = 'cosidosTapaBlanda'; + protected static $singularObjectName = 'Presupuesto Admin'; + protected static $singularObjectNameCc = 'Presupuestoadmin'; + protected static $pluralObjectName = 'Presupuestos Admin'; + protected static $pluralObjectNameCc = 'PresupuestosAdmin'; - protected static $controllerSlug = 'cosidotapablanda'; + protected static $controllerSlug = 'presupuestoadmin'; - protected static $viewPath = 'themes/vuexy/form/presupuestos/cosidotapablanda/'; + protected static $viewPath = 'themes/vuexy/form/presupuestos/admin/'; - protected $indexRoute = 'cosidotapablandaList'; + protected $indexRoute = 'presupuestoadminList'; @@ -71,7 +71,7 @@ class Cosidotapablanda extends \App\Controllers\BaseResourceController $viewData = array_merge($this->viewData, $viewData); // merge any possible values from the parent controller class - return view(static::$viewPath . 'viewCosidotapablandaList', $viewData); + return view(static::$viewPath . 'viewPresupuestoAdminList', $viewData); } @@ -126,7 +126,7 @@ class Cosidotapablanda 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('presupuestos/cosidotapablanda/edit/' . $id))->with('sweet-success', $message); + return redirect()->to(site_url('presupuestoadmin/edit/' . $id))->with('sweet-success', $message); else : return $this->redirect2listView('sweet-success', $message); endif; @@ -151,7 +151,7 @@ class Cosidotapablanda extends \App\Controllers\BaseResourceController $this->viewData['POD'] = $this->getPOD(); - $this->viewData['formAction'] = route_to('createCosidotapablanda', $tipo_impresion_id); + $this->viewData['formAction'] = route_to('createPresupuestoAdmin', $tipo_impresion_id); $this->viewData = array_merge($this->viewData, $this->getStringsFromTipoImpresion($tipo_impresion_id)); @@ -387,7 +387,7 @@ class Cosidotapablanda extends \App\Controllers\BaseResourceController $this->viewData = array_merge($this->viewData, $this->getStringsFromTipoImpresion($presupuestoEntity->tipo_impresion_id)); - $this->viewData['formAction'] = route_to('updateCosidotapablanda', $id); + $this->viewData['formAction'] = route_to('updatePresupuestoAdmin', $id); // Si se ha llamado a esta funcion porque se ha duplicado el presupuesto // se actualiza la bbdd para que sólo ejecute algunas funciones una vez @@ -840,7 +840,7 @@ class Cosidotapablanda extends \App\Controllers\BaseResourceController // Breadcrumbs $viewData['breadcrumb'] = [ ['title' => lang("App.menu_presupuestos"), 'route' => "javascript:void(0);", 'active' => false], - ['title' => $breadcrumbTitle, 'route' => site_url('presupuestos/cosidotapablanda/list/' . $tipo_impresion_id), 'active' => true] + ['title' => $breadcrumbTitle, 'route' => site_url('presupuestoadmin/list/' . $tipo_impresion_id), 'active' => true] ]; return $viewData; diff --git a/ci4/app/Controllers/Presupuestos/Presupuestocliente.php b/ci4/app/Controllers/Presupuestos/Presupuestocliente.php index 04334561..f0ae65af 100755 --- a/ci4/app/Controllers/Presupuestos/Presupuestocliente.php +++ b/ci4/app/Controllers/Presupuestos/Presupuestocliente.php @@ -296,7 +296,6 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController $faja = $reqData['faja'] ?? []; $excluirRotativa = $reqData['excluirRotativa'] ?? 0; $excluirRotativa = intval($excluirRotativa); - $ivaReducido = intval($reqData['ivaReducido']) ?? 0; $direcciones = $reqData['direcciones'] ?? []; @@ -304,12 +303,12 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController $lomoRedondo = $cubierta['lomoRedondo'] ?? 0; if ($papelInteriorDiferente) { - $papel['negro'] = $modelPapelGenerico->getIdFromCode($interior['papelInterior']['negro']); - $papel['color'] = $modelPapelGenerico->getIdFromCode($interior['papelInterior']['color']); + $papel['negro'] = $modelPapelGenerico->where('id', $interior['papelInterior']['negro'])->first()->toArray(); + $papel['color'] = $modelPapelGenerico->where('id', $interior['papelInterior']['color'])->first()->toArray(); $gramaje['negro'] = intval($interior['gramajeInterior']['negro']); $gramaje['color'] = intval($interior['gramajeInterior']['color']); } else { - $papel = $modelPapelGenerico->getIdFromCode($interior['papelInterior']); + $papel = $modelPapelGenerico->where('id', $interior['papelInterior'])->first()->toArray(); $gramaje = intval($interior['gramajeInterior']); } // Interior @@ -325,10 +324,10 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController // Cubierta $cubierta = [ - 'papel_generico_cubierta' => $modelPapelGenerico->getIdFromCode($cubierta['papelCubierta']), + 'papel_generico_cubierta' => $modelPapelGenerico->where('id', $cubierta['papelCubierta'])->first()->toArray(), 'gramajeCubierta' => intval($cubierta['gramajeCubierta']), 'carasCubierta' => intval($cubierta['carasImpresion'] ?? 0), - 'solapasCubierta' => intval($cubierta['solapas'] ?? 0), + 'solapasCubierta' => intval($cubierta['solapas'] ?? 0) == 1 ? intval($cubierta['tamanioSolapas']) : 0, 'acabadosCubierta' => $cubierta['acabados'] ?? 0, 'lomoRedondo' => $lomoRedondo, ]; @@ -396,14 +395,16 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController for ($i = 0; $i < count($tirada); $i++) { $coste_envio = 0.0; + $primer_envio = false; foreach ($direcciones as $direccion) { $coste_direccion = $this->getCosteEnvio( $direccion['id'], $return_data['peso'][$i], - $direccion['unidades'], + !$primer_envio ? intval($tirada[$i]) : $direccion['unidades'], $direccion['entregaPalets'] == 'true' ? 1 : 0 )[0]; + $primer_envio = true; if (!property_exists($coste_direccion, 'coste')) { @@ -463,13 +464,101 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController return $this->respond($return_data); } catch (Exception $e) { - return $this->failServerError($e->getMessage()); + return $this->failServerError($e->getMessage() . ' - ' . $e->getFile() . ' - ' . $e->getLine()); } } else { return $this->failUnauthorized('Invalid request', 403); } } + + public function calcularMaxSolapas() + { + if ($this->request->isAJAX()) { + + $reqData = $this->request->getPost(); + $modelPapelGenerico = new PapelGenericoModel(); + + $POD = model('App\Models\Configuracion\ConfiguracionSistemaModel')->getPOD(); + + $cliente_id = $reqData['clienteId'] ?? -1; + + $tirada = $reqData['tirada'] ?? 0; + $tamanio = $reqData['tamanio']; + $paginas = $reqData['paginas'] ?? 0; + $paginas_color = $reqData['paginasColor'] ?? 0; + $papelInteriorDiferente = intval($reqData['papelInteriorDiferente']) ?? null; + $excluirRotativa = $reqData['excluirRotativa'] ?? 0; + $excluirRotativa = intval($excluirRotativa); + + $tipo = $reqData['tipo']; + $tipoCubierta = 'blanda'; // solapas sólo tapa blanda y sobre cubierta + + $isColor = intval($reqData['isColor']) ?? 0; + $isHq = intval($reqData['isHq']) ?? 0; + + $tipo_impresion_id = $this->getTipoImpresion($tipo, $tipoCubierta); + $is_cosido = (new TipoPresupuestoModel())->get_isCosido($tipo_impresion_id); + + $interior = $reqData['interior'] ?? []; + + if ($papelInteriorDiferente) { + $papel['negro'] = $modelPapelGenerico->where('id', $interior['papelInterior']['negro'])->first()->toArray(); + $papel['color'] = $modelPapelGenerico->where('id', $interior['papelInterior']['color'])->first()->toArray(); + $gramaje['negro'] = intval($interior['gramajeInterior']['negro']); + $gramaje['color'] = intval($interior['gramajeInterior']['color']); + } else { + $papel = $modelPapelGenerico->where('id', $interior['papelInterior'])->first()->toArray(); + $gramaje = intval($interior['gramajeInterior']); + } + + $datosPedido = (object) array( + 'paginas' => $paginas, + 'tirada' => $tirada[0], + 'merma' => $tirada[0] > $POD ? $this->calcular_merma($tirada[0], $POD) : 0, + 'ancho' => intval($tamanio['ancho']) ?? 100000, + 'alto' => intval($tamanio['alto']) ?? 100000, + 'isCosido' => $is_cosido, + 'a_favor_fibra' => 1, + ); + + $input_data = array( + 'uso' => 'interior', + 'tipo_impresion_id' => $tipo_impresion_id, + 'datosPedido' => $datosPedido, + 'papel_generico' => $papel, + 'gramaje' => $gramaje, + 'isColor' => $isColor, + 'isHq' => $isHq, + 'cliente_id' => $cliente_id, + 'paginas_color' => $paginas_color, + 'excluirRotativa' => $excluirRotativa, + 'papelInteriorDiferente' => $papelInteriorDiferente + ); + + $interior = PresupuestoClienteService::obtenerInterior($input_data); + if ($interior == null) { + return $this->failServerError('Error al calcular el interior'); + } + $anchoTotal = $interior[0]['mano']; + // le añadimos 2*ancho libro + $anchoTotal += 2 * $datosPedido->ancho; + // le añadimos los dobleces de las solapas + $anchoTotal += 6; + // le añadimos la sangre + $anchoTotal += PresupuestoService::SANGRE_FORMAS; + // 863 es el ancho máximo permitido por las máquinas + $maxSolapa = (865 - floor($anchoTotal)) / 2; + $maxSolapa = min($maxSolapa, 0.75 * $datosPedido->ancho); + return $this->respond($maxSolapa); + + } else { + return $this->failUnauthorized('Invalid request', 403); + } + + } + + public function getDireccionesCliente() { if ($this->request->isAJAX()) { @@ -487,6 +576,7 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController 'menu' => $data, $csrfTokenName => $newTokenHash ]); + } else { return $this->failUnauthorized('Invalid request', 403); } @@ -652,6 +742,11 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController $isHq = intval($reqData['isHq']) ?? 0; $prototipo = intval($reqData['prototipo']) ?? 0; + $ferro = intval($reqData['ferro']) ?? 0; + $ferroDigital = intval($reqData['ferroDigital']) ?? 0; + $marcapaginas = intval($reqData['marcapaginas']) ?? 0; + $retractilado = intval($reqData['retractilado']) ?? 0; + $retractilado5 = intval($reqData['retractilado5']) ?? 0; $interior = $reqData['interior'] ?? []; $cubierta = $reqData['cubierta'] ?? []; @@ -667,12 +762,12 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController $tipo_impresion_id = $this->getTipoImpresion($tipo, $cubierta['tipoCubierta']); if ($papelInteriorDiferente) { - $papel['negro'] = $modelPapelGenerico->getIdFromCode($interior['papelInterior']['negro']); - $papel['color'] = $modelPapelGenerico->getIdFromCode($interior['papelInterior']['color']); + $papel['negro'] = $modelPapelGenerico->where('id', $interior['papelInterior']['negro'])->first()->toArray(); + $papel['color'] = $modelPapelGenerico->where('id', $interior['papelInterior']['color'])->first()->toArray(); $gramaje['negro'] = intval($interior['gramajeInterior']['negro']); $gramaje['color'] = intval($interior['gramajeInterior']['color']); } else { - $papel = $modelPapelGenerico->getIdFromCode($interior['papelInterior']); + $papel = $modelPapelGenerico->where('id', $interior['papelInterior'])->first()->toArray(); $gramaje = intval($interior['gramajeInterior']); } // Interior @@ -690,10 +785,10 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController // Cubierta $cubierta = [ - 'papel_generico_cubierta' => $modelPapelGenerico->getIdFromCode($cubierta['papelCubierta']), + 'papel_generico_cubierta' => $modelPapelGenerico->where('id', $cubierta['papelCubierta'])->first()->toArray(), 'gramajeCubierta' => intval($cubierta['gramajeCubierta']), 'carasCubierta' => intval($cubierta['carasImpresion'] ?? 0), - 'solapasCubierta' => intval($cubierta['solapas'] ?? 0), + 'solapasCubierta' => intval($cubierta['solapas'] ?? 0) == 1 ? intval($cubierta['tamanioSolapas']) : 0, 'acabadosCubierta' => $cubierta['acabados'] ?? 0, 'lomoRedondo' => $cubierta['lomoRedondo'] ?? 0, 'cabezada' => $cubierta['cabezada'] ?? 'WHI', @@ -855,6 +950,11 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController } $datos_presupuesto['prototipo'] = $prototipo; + $datos_presupuesto['ferro'] = $ferro; + $datos_presupuesto['ferro_digital'] = $ferroDigital; + $datos_presupuesto['marcapaginas'] = $marcapaginas; + $datos_presupuesto['retractilado'] = $retractilado; + $datos_presupuesto['retractilado5'] = $retractilado5; $id = $model_presupuesto->insertarPresupuestoCliente( $id, @@ -902,6 +1002,9 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController } else if ($servicio->tarifa_id == 62) { // Servicios manipulado $this->guardarServicio($id, $servicio, 'manipulado'); + } else if ($servicio->tarifa_id == 73) { + // Servicios manipulado + $this->guardarServicio($id, $servicio, 'manipulado'); } } @@ -968,6 +1071,11 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController $data['datosGenerales']['tipo'] = $this->getTipoLibro($presupuesto->tipo_impresion_id ?? null); $data['datosGenerales']['prototipo'] = $presupuesto->prototipo; + $data['datosGenerales']['ferro'] = $presupuesto->ferro; + $data['datosGenerales']['ferroDigital'] = $presupuesto->ferro_digital; + $data['datosGenerales']['marcapaginas'] = $presupuesto->marcapaginas; + $data['datosGenerales']['retractilado'] = $presupuesto->retractilado; + $data['datosGenerales']['retractilado5'] = $presupuesto->retractilado5; $datos_papel = $this->obtenerDatosPapel($presupuesto->id); $data['interior'] = $datos_papel['interior'] ? $datos_papel['interior'] : []; @@ -997,6 +1105,9 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController $data['sobrecubierta']['solapas'] = $presupuesto->solapas_sobrecubierta ? 1 : 0; $data['sobrecubierta']['solapas_ancho'] = $presupuesto->solapas_ancho_sobrecubierta; $data['sobrecubierta']['plastificado'] = $modelAcabado->getCodeFromId($presupuesto->acabado_sobrecubierta_id); + if ($data['sobrecubierta']['plastificado'] == '') { + $data['sobrecubierta']['plastificado'] = 'NONE'; + } $data['guardas'] = array_key_exists('guardas', $datos_papel) ? $datos_papel['guardas'] : []; @@ -1272,7 +1383,7 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController $coste = 0; $margen = 0; - if ($data > 0) { + if (count($data) > 0) { $peso_envio = round(floatval($peso * $unidades / 1000.0)); // peso libro * unidades y se pasa a kilogramos $tarifas_envio = $modelTarifaEnvio->getTarifaEnvio($data[0]->pais_id, $data[0]->cp, $peso_envio, $entregaPieCalle ? 'palets' : 'cajas'); for ($i = 0; $i < count($tarifas_envio); $i++) { @@ -1780,6 +1891,9 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController 'solapas' => intval($solapasCubierta) > 0 ? 1 : 0, 'paginasCuadernillo' => $paginasCuadernillo, ]); + + + $costeServiciosDefecto = 0.0; foreach ($servDefecto as $servicio) { if ($servicio->total <= 0) { @@ -1813,6 +1927,14 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController } // Servicios + + + /* + 'retractilado' => 3, + 'prototipo' => 9, + */ + $serviciosAutomaticos = []; + $servicios = []; // se comprueba si $datos guardas es un array if (is_array($datos_guardas)) { if (count($datos_guardas) > 0) { @@ -1823,20 +1945,19 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController array_push($servicios, 62); // Plegado de guardas } } - - /* - 'retractilado' => 3, - 'prototipo' => 9, - */ - $serviciosAutomaticos = []; - $servicios = []; - if ($datos_entrada['cubierta']['acabadosCubierta']['retractilado'] === 'true') + if ($datos_entrada['servicios']['retractilado']) // acabado array_push($servicios, 3); - if ($datos_entrada['servicios']['prototipo']) + if ($datos_entrada['servicios']['retractilado5']) // acabado + array_push($servicios, 98); + if ($datos_entrada['servicios']['prototipo']) // extra array_push($servicios, 9); + if ($datos_entrada['servicios']['ferro']) // extra + array_push($servicios, 30); + /*if ($datos_entrada['servicios']['ferroDigital']) + array_push($servicios, 29);*/ // Es gratis foreach ($servicios as $servicio) { - if (intval($servicio) == 3) { + if (intval($servicio) == 3 || intval($servicio) == 98) { // Servicios acabado $resultado = PresupuestoCLienteService::getServiciosAcabados([ 'tarifa_id' => $servicio, @@ -1851,7 +1972,7 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController $errorModel->insertError( $datos_entrada['id'], auth()->user()->id, - 'No se puede obtener servicio con id 3', + 'No se puede obtener servicio con id ' . ((string) $servicio), $input_data ); $return_data = [ @@ -1867,8 +1988,8 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController $totalServicios += floatval($resultado[0]->total); $margenServicios += floatval($resultado[0]->total) * floatval($resultado[0]->margen) / 100.0; } - } else if (intval($servicio) == 9) { - // Prototipo + } else if (intval($servicio) == 9 || intval($servicio) == 30 || intval($servicio) == 29) { + // Extra $resultado = PresupuestoCLienteService::getServiciosExtra([ 'tarifa_id' => $servicio, ]); @@ -1879,7 +2000,7 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController $errorModel->insertError( $datos_entrada['id'], auth()->user()->id, - 'No se puede obtener servicio con id 9', + 'No se puede obtener servicio con id ' . ((string) $servicio), $input_data ); $return_data = [ @@ -1899,6 +2020,45 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController } } + // Plegado de solapas grandes + if ( + (intval($solapasCubierta) > 0 && intval($cubierta['dimension_desarrollo']['ancho']) > 630) || + (is_array($sobreCubierta) && ($sobreCubierta['solapas'] > 0 && intval($linea_sobrecubierta['dimension_desarrollo']['ancho']) > 630)) + ) { + + // Servicios acabado + $resultado = PresupuestoCLienteService::getServiciosManipulado([ + 'tarifa_id' => 73, + 'tirada' => $datosPedido->tirada, + 'POD' => $POD, + ]); + array_push($serviciosAutomaticos, $resultado[0]); + + if ($resultado[0]->total <= 0) { + + $errorModel = new ErrorPresupuesto(); + $errorModel->insertError( + $datos_entrada['id'], + auth()->user()->id, + 'No se puede obtener servicio de manupulado con id ' . ((string) $servicio), + $input_data + ); + $return_data = [ + 'errors' => (object) ([ + 'status' => 1 + ]), + ]; + return $return_data; + } + + $coste_servicios += floatval($resultado[0]->total); + if ($extra_info) { + $totalServicios += floatval($resultado[0]->total); + $margenServicios += floatval($resultado[0]->total) * floatval($resultado[0]->margen) / 100.0; + } + + } + array_push($precio_u, round(($costeInterior + $coste_cubierta + $coste_sobrecubierta + $costeServiciosDefecto + $coste_servicios) / $tirada[$t], 4)); array_push($peso, round($peso_interior + $peso_cubierta + $peso_sobrecubierta + $peso_guardas, 2)); @@ -2278,13 +2438,16 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController if ($linea->tipo == 'lp_bn' || $linea->tipo == 'lp_bnhq' || $linea->tipo == 'lp_rot_bn') { $return_data['interior']['negro']['tipo'] = $linea->tipo == 'lp_bn' || $linea->tipo == 'lp_rot_bn' ? 'negroEstandar' : 'negroPremium'; $return_data['interior']['negro']['papel'] = $modelPapelGenerico->getCodeFromId($linea->papel_id); + $return_data['interior']['negro']['papel']['id'] = $linea->papel_id; $return_data['interior']['negro']['gramaje'] = $linea->gramaje; } else if ($linea->tipo == 'lp_color' || $linea->tipo == 'lp_colorhq' || $linea->tipo == 'lp_rot_color') { $return_data['interior']['color']['tipo'] = $linea->tipo == 'lp_color' || $linea->tipo == 'lp_rot_color' ? 'colorEstandar' : 'colorPremium'; $return_data['interior']['color']['papel'] = $modelPapelGenerico->getCodeFromId($linea->papel_id); + $return_data['interior']['color']['papel']['id'] = $linea->papel_id; $return_data['interior']['color']['gramaje'] = $linea->gramaje; } else if ($linea->tipo == 'lp_cubierta') { $return_data['cubierta']['papel'] = $modelPapelGenerico->getCodeFromId($linea->papel_id); + $return_data['cubierta']['papel']['id'] = $linea->papel_id; $return_data['cubierta']['gramaje'] = $linea->gramaje; $return_data['cubierta']['paginas'] = $linea->paginas; } else if ($linea->tipo == 'lp_sobrecubierta') { diff --git a/ci4/app/Controllers/Tarifas/Tarifasenviosprecios.php b/ci4/app/Controllers/Tarifas/Tarifasenviosprecios.php index 7a190c0b..ff4ac800 100755 --- a/ci4/app/Controllers/Tarifas/Tarifasenviosprecios.php +++ b/ci4/app/Controllers/Tarifas/Tarifasenviosprecios.php @@ -1,4 +1,5 @@ -viewData['pageTitle'] = lang('TarifasEnviosPrecios.moduleTitle'); $this->viewData['usingSweetAlert'] = true; @@ -48,66 +51,68 @@ class Tarifasenviosprecios extends \App\Controllers\BaseResourceController { } - public function index() { - + public function index() + { + $viewData = [ - 'currentModule' => static::$controllerSlug, - 'pageSubTitle' => lang('Basic.global.ManageAllRecords', [lang('TarifasEnviosPrecios.tarifaEnvioPrecio')]), - 'tarifaEnvioPrecioEntity' => new TarifaEnvioPrecioEntity(), - 'usingServerSideDataTable' => true, - - ]; + 'currentModule' => static::$controllerSlug, + 'pageSubTitle' => lang('Basic.global.ManageAllRecords', [lang('TarifasEnviosPrecios.tarifaEnvioPrecio')]), + 'tarifaEnvioPrecioEntity' => new TarifaEnvioPrecioEntity(), + 'usingServerSideDataTable' => true, + + ]; $viewData = array_merge($this->viewData, $viewData); // merge any possible values from the parent controller class - return view(static::$viewPath.'viewTarifaEnvioPrecioList', $viewData); + return view(static::$viewPath . 'viewTarifaEnvioPrecioList', $viewData); } - public function add() { - - + public function add() + { - - if ($this->request->getPost()) : + + + + if ($this->request->getPost()): $nullIfEmpty = true; // !(phpversion() >= '8.1'); $postData = $this->request->getPost(); - - $sanitizedData = $this->sanitized($postData, $nullIfEmpty); + + $sanitizedData = $this->sanitized($postData, $nullIfEmpty); $noException = true; - if ($successfulResult = $this->canValidate()) : // if ($successfulResult = $this->validate($this->formValidationRules) ) : + if ($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', [mb_strtolower(lang('TarifasEnviosPrecios.tarifaEnvioPrecio'))]); - $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 + 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', [mb_strtolower(lang('TarifasEnviosPrecios.tarifaEnvioPrecio'))]); + $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) : + if ($noException && $successfulResult): $id = $this->model->db->insertID(); - $message = lang('Basic.global.saveSuccess', [mb_strtolower(lang('TarifasEnviosPrecios.tarifaEnvioPrecio'))]).'.'; - $message .= anchor( "admin/tarifasenviosprecios/{$id}/edit" , lang('Basic.global.continueEditing').'?'); + $message = lang('Basic.global.saveSuccess', [mb_strtolower(lang('TarifasEnviosPrecios.tarifaEnvioPrecio'))]) . '.'; + $message .= anchor("admin/tarifasenviosprecios/{$id}/edit", lang('Basic.global.continueEditing') . '?'); $message = ucfirst(str_replace("'", "\'", $message)); - if ($thenRedirect) : - if (!empty($this->indexRoute)) : - return redirect()->to(route_to( $this->indexRoute ) )->with('sweet-success', $message); + 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; @@ -120,97 +125,98 @@ class Tarifasenviosprecios extends \App\Controllers\BaseResourceController { endif; // ($requestMethod === 'post') $this->viewData['tarifaEnvioPrecioEntity'] = isset($sanitizedData) ? new TarifaEnvioPrecioEntity($sanitizedData) : new TarifaEnvioPrecioEntity(); - $this->viewData['tarifaEnvioList'] = $this->getTarifaEnvioListItems($tarifaEnvioPrecioEntity->tarifa_envio_id ?? null); - $this->viewData['proveedorList'] = $this->getProveedorListItems($tarifaEnvioPrecioEntity->proveedor_id ?? null); - $this->viewData['tipoEnvioList'] = $this->getTipoEnvioOptions(); + $this->viewData['tarifaEnvioList'] = $this->getTarifaEnvioListItems($tarifaEnvioPrecioEntity->tarifa_envio_id ?? null); + $this->viewData['proveedorList'] = $this->getProveedorListItems($tarifaEnvioPrecioEntity->proveedor_id ?? null); + $this->viewData['tipoEnvioList'] = $this->getTipoEnvioOptions(); $this->viewData['formAction'] = route_to('createTarifaEnvioPrecio'); - $this->viewData['boxTitle'] = lang('Basic.global.addNew').' '.lang('TarifasEnviosPrecios.moduleTitle').' '.lang('Basic.global.addNewSuffix'); - + $this->viewData['boxTitle'] = lang('Basic.global.addNew') . ' ' . lang('TarifasEnviosPrecios.moduleTitle') . ' ' . 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); $tarifaEnvioPrecioEntity = $this->model->find($id); - if ($tarifaEnvioPrecioEntity == false) : + if ($tarifaEnvioPrecioEntity == false): $message = lang('Basic.global.notFoundWithIdErr', [mb_strtolower(lang('TarifasEnviosPrecios.tarifaEnvioPrecio')), $id]); return $this->redirect2listView('sweet-error', $message); endif; - - if ($this->request->getPost()) : + + if ($this->request->getPost()): $nullIfEmpty = true; // !(phpversion() >= '8.1'); - + $postData = $this->request->getPost(); - - $sanitizedData = $this->sanitized($postData, $nullIfEmpty); + + $sanitizedData = $this->sanitized($postData, $nullIfEmpty); + - $noException = true; - if ($successfulResult = $this->canValidate()) : // if ($successfulResult = $this->validate($this->formValidationRules) ) : - - + 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('TarifasEnviosPrecios.tarifaEnvioPrecio'))]); - $this->session->setFlashdata('formErrors', $this->model->errors()); - - endif; - - $tarifaEnvioPrecioEntity->fill($sanitizedData); - $thenRedirect = true; + + 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('TarifasEnviosPrecios.tarifaEnvioPrecio'))]); + $this->session->setFlashdata('formErrors', $this->model->errors()); + + endif; + + $tarifaEnvioPrecioEntity->fill($sanitizedData); + + $thenRedirect = true; endif; - if ($noException && $successfulResult) : + if ($noException && $successfulResult): $id = $tarifaEnvioPrecioEntity->id ?? $id; - $message = lang('Basic.global.updateSuccess', [mb_strtolower(lang('TarifasEnviosPrecios.tarifaEnvioPrecio'))]).'.'; - $message .= anchor( "admin/tarifasenviosprecios/{$id}/edit" , lang('Basic.global.continueEditing').'?'); + $message = lang('Basic.global.updateSuccess', [mb_strtolower(lang('TarifasEnviosPrecios.tarifaEnvioPrecio'))]) . '.'; + $message .= anchor("admin/tarifasenviosprecios/{$id}/edit", lang('Basic.global.continueEditing') . '?'); $message = ucfirst(str_replace("'", "\'", $message)); - if ($thenRedirect) : - if (!empty($this->indexRoute)) : - return redirect()->to(route_to( $this->indexRoute ) )->with('sweet-success', $message); + 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['tarifaEnvioPrecioEntity'] = $tarifaEnvioPrecioEntity; - $this->viewData['tarifaEnvioList'] = $this->getTarifaEnvioListItems($tarifaEnvioPrecioEntity->tarifa_envio_id ?? null); - $this->viewData['proveedorList'] = $this->getProveedorListItems($tarifaEnvioPrecioEntity->proveedor_id ?? null); - $this->viewData['tipoEnvioList'] = $this->getTipoEnvioOptions(); + $this->viewData['tarifaEnvioList'] = $this->getTarifaEnvioListItems($tarifaEnvioPrecioEntity->tarifa_envio_id ?? null); + $this->viewData['proveedorList'] = $this->getProveedorListItems($tarifaEnvioPrecioEntity->proveedor_id ?? null); + $this->viewData['tipoEnvioList'] = $this->getTipoEnvioOptions(); + + $this->viewData['formAction'] = route_to('updateTarifaEnvioPrecio', $id); + + $this->viewData['boxTitle'] = lang('Basic.global.edit2') . ' ' . lang('TarifasEnviosPrecios.moduleTitle') . ' ' . lang('Basic.global.edit3'); - $this->viewData['formAction'] = route_to('updateTarifaEnvioPrecio', $id); - $this->viewData['boxTitle'] = lang('Basic.global.edit2').' '.lang('TarifasEnviosPrecios.moduleTitle').' '.lang('Basic.global.edit3'); - - return $this->displayForm(__METHOD__, $id); } // end function edit(...) - + public function datatable_editor() { @@ -222,62 +228,101 @@ class Tarifasenviosprecios extends \App\Controllers\BaseResourceController { $response = Editor::inst($db, 'tarifas_envios_precios') ->fields( Field::inst('tipo_envio') - ->validator('Validate::required', array( - 'message' => lang('TarifasEnviosPrecios.validation.tipo_envio.required')) - ), + ->validator( + 'Validate::required', + array( + 'message' => lang('TarifasEnviosPrecios.validation.tipo_envio.required') + ) + ), Field::inst('peso_min') - ->getFormatter( 'Format::toDecimalChar')->setFormatter( 'Format::fromDecimalChar') - ->validator('Validate::required', array( - 'message' => lang('TarifasEnviosPrecios.validation.peso_min.required')) + ->getFormatter('Format::toDecimalChar')->setFormatter('Format::fromDecimalChar') + ->validator( + 'Validate::required', + array( + 'message' => lang('TarifasEnviosPrecios.validation.peso_min.required') + ) ) - ->validator('Validate::numeric', array( + ->validator( + 'Validate::numeric', + array( "decimal" => ',', - 'message' => lang('TarifasEnviosPrecios.validation.peso_min.decimal')) + 'message' => lang('TarifasEnviosPrecios.validation.peso_min.decimal') + ) ), Field::inst('peso_max') - ->getFormatter( 'Format::toDecimalChar')->setFormatter( 'Format::fromDecimalChar') - ->validator('Validate::required', array( - 'message' => lang('TarifasEnviosPrecios.validation.peso_max.required')) + ->getFormatter('Format::toDecimalChar')->setFormatter('Format::fromDecimalChar') + ->validator( + 'Validate::required', + array( + 'message' => lang('TarifasEnviosPrecios.validation.peso_max.required') + ) ) - ->validator('Validate::numeric', array( + ->validator( + 'Validate::numeric', + array( "decimal" => ',', - 'message' => lang('TarifasEnviosPrecios.validation.peso_max.decimal')) + 'message' => lang('TarifasEnviosPrecios.validation.peso_max.decimal') + ) ), Field::inst('precio_min') - ->getFormatter( 'Format::toDecimalChar')->setFormatter( 'Format::fromDecimalChar') - ->validator('Validate::required', array( - 'message' => lang('TarifasEnviosPrecios.validation.precio.required')) + ->getFormatter('Format::toDecimalChar')->setFormatter('Format::fromDecimalChar') + ->validator( + 'Validate::required', + array( + 'message' => lang('TarifasEnviosPrecios.validation.precio.required') + ) ) - ->validator('Validate::numeric', array( - "decimal" => ',', - 'message' => lang('TarifasEnviosPrecios.validation.precio.decimal')) + ->validator( + 'Validate::numeric', + array( + "decimal" => ',', + 'message' => lang('TarifasEnviosPrecios.validation.precio.decimal') + ) ), Field::inst('precio_max') - ->getFormatter( 'Format::toDecimalChar')->setFormatter( 'Format::fromDecimalChar') - ->validator('Validate::required', array( - 'message' => lang('TarifasEnviosPrecios.validation.precio.required')) + ->getFormatter('Format::toDecimalChar')->setFormatter('Format::fromDecimalChar') + ->validator( + 'Validate::required', + array( + 'message' => lang('TarifasEnviosPrecios.validation.precio.required') + ) ) - ->validator('Validate::numeric', array( + ->validator( + 'Validate::numeric', + array( "decimal" => ',', - 'message' => lang('TarifasEnviosPrecios.validation.precio.decimal')) + 'message' => lang('TarifasEnviosPrecios.validation.precio.decimal') + ) ), Field::inst('precio_adicional') - ->getFormatter( 'Format::toDecimalChar')->setFormatter( 'Format::fromDecimalChar') - ->validator('Validate::required', array( - 'message' => lang('TarifasEnviosPrecios.validation.precio_adicional.required')) + ->getFormatter('Format::toDecimalChar')->setFormatter('Format::fromDecimalChar') + ->validator( + 'Validate::required', + array( + 'message' => lang('TarifasEnviosPrecios.validation.precio_adicional.required') + ) ) - ->validator('Validate::numeric', array( + ->validator( + 'Validate::numeric', + array( "decimal" => ',', - 'message' => lang('TarifasEnviosPrecios.validation.precio_adicional.decimal')) + 'message' => lang('TarifasEnviosPrecios.validation.precio_adicional.decimal') + ) ), Field::inst('margen') - ->getFormatter( 'Format::toDecimalChar')->setFormatter( 'Format::fromDecimalChar') - ->validator('Validate::required', array( - 'message' => lang('TarifasEnviosPrecios.validation.precio_adicional.required')) + ->getFormatter('Format::toDecimalChar')->setFormatter('Format::fromDecimalChar') + ->validator( + 'Validate::required', + array( + 'message' => lang('TarifasEnviosPrecios.validation.precio_adicional.required') + ) ) - ->validator('Validate::numeric', array( + ->validator( + 'Validate::numeric', + array( "decimal" => ',', - 'message' => lang('TarifasEnviosPrecios.validation.precio_adicional.decimal')) + 'message' => lang('TarifasEnviosPrecios.validation.precio_adicional.decimal') + ) ), Field::inst('tarifa_envio_id'), Field::inst('proveedor_id'), @@ -344,24 +389,35 @@ class Tarifasenviosprecios extends \App\Controllers\BaseResourceController { } - public function datatable() { + public function datatable() + { if ($this->request->isAJAX()) { $reqData = $this->request->getPost(); - if (!isset($reqData['draw']) || !isset($reqData['columns']) ) { + 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); + $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; + $requestedOrder2 = $reqData['order']['1']['column'] ?? $requestedOrder; + $requestedOrder3 = $reqData['order']['2']['column'] ?? $requestedOrder; $order = TarifaEnvioPrecioModel::SORTABLE[$requestedOrder > 0 ? $requestedOrder : 1]; + $order2 = TarifaEnvioPrecioModel::SORTABLE[$requestedOrder2 > 0 ? $requestedOrder2 : 1]; + $order3 = TarifaEnvioPrecioModel::SORTABLE[$requestedOrder3 > 0 ? $requestedOrder3 : 1]; $dir = $reqData['order']['0']['dir'] ?? 'asc'; + $dir2 = $reqData['order']['0']['dir'] ?? $dir; + $dir3 = $reqData['order']['0']['dir'] ?? $dir; + + $tarifa_envio_id = $reqData['tarifa_envio_id'] ?? -1; - $resourceData = $this->model->getResource($search, $tarifa_envio_id)->orderBy($order, $dir)->limit($length, $start)->get()->getResultObject(); + $resourceData = $this->model->getResource($search, $tarifa_envio_id) + ->orderBy($order, $dir)->orderBy($order2, $dir2)->orderBy($order3, $dir3) + ->limit($length, $start)->get()->getResultObject(); return $this->respond(Collection::datatable( $resourceData, @@ -373,15 +429,16 @@ class Tarifasenviosprecios extends \App\Controllers\BaseResourceController { } } - public function allItemsSelect() { + public function allItemsSelect() + { if ($this->request->isAJAX()) { $onlyActiveOnes = true; $reqVal = $this->request->getPost('val') ?? 'id'; - $menu = $this->model->getAllForMenu($reqVal.', tarifa_envio_id', 'tarifa_envio_id', $onlyActiveOnes, false); + $menu = $this->model->getAllForMenu($reqVal . ', tarifa_envio_id', 'tarifa_envio_id', $onlyActiveOnes, false); $nonItem = new \stdClass; $nonItem->id = ''; - $nonItem->tarifa_envio_id = '- '.lang('Basic.global.None').' -'; - array_unshift($menu , $nonItem); + $nonItem->tarifa_envio_id = '- ' . lang('Basic.global.None') . ' -'; + array_unshift($menu, $nonItem); $newTokenHash = csrf_hash(); $csrfTokenName = csrf_token(); @@ -395,7 +452,8 @@ class Tarifasenviosprecios extends \App\Controllers\BaseResourceController { } } - public function menuItems() { + public function menuItems() + { if ($this->request->isAJAX()) { $searchStr = goSanitize($this->request->getPost('searchTerm'))[0]; $reqId = goSanitize($this->request->getPost('id'))[0]; @@ -406,8 +464,8 @@ class Tarifasenviosprecios extends \App\Controllers\BaseResourceController { $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(); @@ -422,42 +480,45 @@ class Tarifasenviosprecios extends \App\Controllers\BaseResourceController { } - protected function getTarifaEnvioListItems($selId = null) { - $data = [''=>lang('Basic.global.pleaseSelectA', [mb_strtolower(lang('TarifasEnvios.tarifaEnvio'))])]; - if (!empty($selId)) : - $tarifaEnvioModel = model('App\Models\Tarifas\TarifaEnvioModel'); + protected function getTarifaEnvioListItems($selId = null) + { + $data = ['' => lang('Basic.global.pleaseSelectA', [mb_strtolower(lang('TarifasEnvios.tarifaEnvio'))])]; + if (!empty($selId)): + $tarifaEnvioModel = model('App\Models\Tarifas\TarifaEnvioModel'); $selOption = $tarifaEnvioModel->where('id', $selId)->findColumn('id'); - if (!empty($selOption)) : + if (!empty($selOption)): $data[$selId] = $selOption[0]; endif; endif; - return $data; - } + return $data; + } - protected function getProveedorListItems($selId = null) { - $data = [''=>lang('Basic.global.pleaseSelectA', [mb_strtolower(lang('LgProveedores.proveedor'))])]; - if (!empty($selId)) : - $proveedorModel = model('App\Models\compras\ProveedorModel'); + protected function getProveedorListItems($selId = null) + { + $data = ['' => lang('Basic.global.pleaseSelectA', [mb_strtolower(lang('LgProveedores.proveedor'))])]; + if (!empty($selId)): + $proveedorModel = model('App\Models\compras\ProveedorModel'); $selOption = $proveedorModel->where('id', $selId)->findColumn('id'); - if (!empty($selOption)) : + if (!empty($selOption)): $data[$selId] = $selOption[0]; endif; endif; - return $data; - } + return $data; + } - protected function getTipoEnvioOptions() { - $tipoEnvioOptions = [ - '' => lang('Basic.global.pleaseSelect'), - 'cajas' => 'cajas', - 'palets' => 'palets', - ]; - return $tipoEnvioOptions; - } + protected function getTipoEnvioOptions() + { + $tipoEnvioOptions = [ + '' => lang('Basic.global.pleaseSelect'), + 'cajas' => 'cajas', + 'palets' => 'palets', + ]; + return $tipoEnvioOptions; + } } diff --git a/ci4/app/Controllers/Utiles.php b/ci4/app/Controllers/Utiles.php new file mode 100644 index 00000000..c44a0aa8 --- /dev/null +++ b/ci4/app/Controllers/Utiles.php @@ -0,0 +1,320 @@ +where(['is_deleted' => 0])->findAll(); + + // Iterar sobre cada entidad + echo '
';
+        foreach ($results as $result) {
+            // Cada $result es una instancia de una entidad
+            print_r($result->toArray());  // Convierte la entidad a un array para imprimir sus valores
+        }
+        echo '
'; + } + + public function get_tarifa_encuadernacion($tarifaEncuadernacionId) + { + // Llamar a los modelos + $modelTE = model('App\Models\Tarifas\TarifaEncuadernacionModel'); + $modelTELineas = model('App\Models\Tarifas\TarifaEncuadernacionLineaModel'); + $modelTELineasHoras = model('App\Models\Tarifas\TarifaEncuadernacionLineaHorasModel'); + $modelTETiradas = model('App\Models\Tarifas\TarifaEncuadernacionTiradaModel'); + + + // Obtener el registro principal de tarifa_encuadernacion + $tarifas_encuadernacion = $modelTE->where([ + 'id' => $tarifaEncuadernacionId, + 'is_deleted' => 0 + ])->findAll(); + + // Verificar si se encontró la tarifa + if (empty($tarifas_encuadernacion)) { + echo "No se encontraron datos para la tarifa de encuadernación con ID: $tarifaEncuadernacionId."; + return; + } + + // Imprimir la tarifa de encuadernación principal + echo "

---------------------- DATO TARIFA ENCUADERNACION ----------------------

"; + foreach ($tarifas_encuadernacion as $tarifa_encuadernacion) { + echo "ID Tarifa: " . $tarifa_encuadernacion->id . "
"; + echo "Nombre: " . $tarifa_encuadernacion->nombre . "
"; + echo "
"; + } + + // Obtener las tiradas asociadas a esta tarifa de encuadernación + $tarifas_encuadernacion_tiradas = $modelTETiradas->where([ + 'tarifa_encuadernacion_id' => $tarifaEncuadernacionId, + 'is_deleted' => 0 + ])->findAll(); + + // Verificar si existen tiradas para la tarifa de encuadernación + if (empty($tarifas_encuadernacion_tiradas)) { + echo "No hay tiradas asociadas a esta tarifa de encuadernación."; + return; + } + + // Imprimir las tiradas asociadas + echo "

---------------------- DATO TARIFA ENCUADERNACION (TIRADAS) -------------

"; + foreach ($tarifas_encuadernacion_tiradas as $tarifa_encuadernacion_tirada) { + echo "ID Tirada: " . $tarifa_encuadernacion_tirada->id . "
"; + echo "Tirada Min: " . $tarifa_encuadernacion_tirada->tirada_min . "
"; + echo "Tirada Max: " . $tarifa_encuadernacion_tirada->tirada_max . "
"; + + // Obtener las líneas asociadas a esta tirada + $tarifas_encuadernacion_lineas = $modelTELineas->where([ + 'tirada_encuadernacion_id' => $tarifa_encuadernacion_tirada->id, + 'is_deleted' => 0 + ])->findAll(); + + // Verificar si existen líneas asociadas a la tirada + if (empty($tarifas_encuadernacion_lineas)) { + echo "No hay líneas asociadas a esta tirada de encuadernación.
"; + } else { + // Imprimir las líneas asociadas + echo "
    "; + foreach ($tarifas_encuadernacion_lineas as $tarifa_encuadernacion_linea) { + echo "
  • ID Línea: " . $tarifa_encuadernacion_linea->id . "
    "; + } + echo "
"; + } + + // Obtener las líneas y horas asociadas a esta tirada + $tarifas_encuadernacion_lineas_horas = $modelTELineasHoras->where([ + 'tirada_encuadernacion_id' => $tarifa_encuadernacion_tirada->id, + 'is_deleted' => 0 + ])->findAll(); + + // Verificar si existen líneas y horas asociadas a la tirada + if (empty($tarifas_encuadernacion_lineas_horas)) { + echo "No hay líneas y horas asociadas a esta tirada de encuadernación.
"; + } else { + // Imprimir las líneas asociadas + echo "
    "; + foreach ($tarifas_encuadernacion_lineas_horas as $tarifas_encuadernacion_linea_hora) { + echo "
  • ID Línea/Hora: " . $tarifas_encuadernacion_linea_hora->id . "
    "; + } + echo "
"; + } + + echo "
"; + } + + echo "

---------------------- FIN DE DATO TARIFA ENCUADERNACION ----------------------

"; + } + + public function delete_tarifa_encuadernacion($tarifaEncuadernacionId) + { + // Llamar a los modelos + $modelTE = model('App\Models\Tarifas\TarifaEncuadernacionModel'); + $modelTELineas = model('App\Models\Tarifas\TarifaEncuadernacionLineaModel'); + $modelTELineasHoras = model('App\Models\Tarifas\TarifaEncuadernacionLineaHorasModel'); + $modelTETiradas = model('App\Models\Tarifas\TarifaEncuadernacionTiradaModel'); + + // Obtener el registro principal de tarifa_encuadernacion + $tarifas_encuadernacion = $modelTE->where([ + 'id' => $tarifaEncuadernacionId, + 'is_deleted' => 0 + ])->findAll(); + + // Verificar si se encontró la tarifa + if (empty($tarifas_encuadernacion)) { + echo "No se encontró la tarifa de encuadernación con ID: $tarifaEncuadernacionId."; + return; + } + + // Iniciar eliminación de datos asociados + echo "Eliminando datos asociados a la tarifa de encuadernación ID: $tarifaEncuadernacionId...
"; + + // Eliminar las tiradas asociadas a la tarifa de encuadernación + $tarifas_encuadernacion_tiradas = $modelTETiradas->where([ + 'tarifa_encuadernacion_id' => $tarifaEncuadernacionId, + 'is_deleted' => 0 + ])->findAll(); + + if (!empty($tarifas_encuadernacion_tiradas)) { + foreach ($tarifas_encuadernacion_tiradas as $tarifa_encuadernacion_tirada) { + // Eliminar las líneas de horas asociadas a cada tirada + $tarifas_encuadernacion_lineas_horas = $modelTELineasHoras->where([ + 'tirada_encuadernacion_id' => $tarifa_encuadernacion_tirada->id, + 'is_deleted' => 0 + ])->findAll(); + + if (!empty($tarifas_encuadernacion_lineas_horas)) { + foreach ($tarifas_encuadernacion_lineas_horas as $tarifa_encuadernacion_linea_hora) { + $modelTELineasHoras->delete($tarifa_encuadernacion_linea_hora->id); // Eliminar la línea/hora + echo "===sk >-Eliminando Línea/Hora ID: " . $tarifa_encuadernacion_linea_hora->id . "
"; + } + } + + // Eliminar las líneas asociadas a cada tirada + $tarifas_encuadernacion_lineas = $modelTELineas->where([ + 'tirada_encuadernacion_id' => $tarifa_encuadernacion_tirada->id, + 'is_deleted' => 0 + ])->findAll(); + + if (!empty($tarifas_encuadernacion_lineas)) { + foreach ($tarifas_encuadernacion_lineas as $tarifa_encuadernacion_linea) { + $modelTELineas->delete($tarifa_encuadernacion_linea->id); // Eliminar la línea + echo "===>-Eliminando Línea ID: " . $tarifa_encuadernacion_linea->id . "
"; + } + } + + // Eliminar la tirada + $modelTETiradas->delete($tarifa_encuadernacion_tirada->id); // Eliminar la tirada + echo "=>-Eliminando Tirada ID: " . $tarifa_encuadernacion_tirada->id . "
"; + } + } + + echo " *** Proceso de eliminación completado. ***

"; + } + + public function clone_tarifa_encuadernacion($origenId, $destinoId) + { + // Llamar a los modelos + $modelTETiradas = model('App\Models\Tarifas\TarifaEncuadernacionTiradaModel'); + $modelTELineas = model('App\Models\Tarifas\TarifaEncuadernacionLineaModel'); + $modelTELineasHoras = model('App\Models\Tarifas\TarifaEncuadernacionLineaHorasModel'); + + // 1. Eliminar el contenido asociado de la tarifa destino + $this->delete_tarifa_encuadernacion($destinoId); + + // 2. Obtener las tiradas asociadas a la tarifa origen + $tiradasOrigen = $modelTETiradas->where([ + 'tarifa_encuadernacion_id' => $origenId, + 'is_deleted' => 0 + ])->findAll(); + + foreach ($tiradasOrigen as $tiradaOrigen) { + // Crear un nuevo registro para la tirada en la tarifa destino + $nuevaTirada = [ + 'tarifa_encuadernacion_id' => (int) $destinoId, + 'proveedor_id' => (int) $tiradaOrigen->proveedor_id, + 'importe_fijo' => (float) $tiradaOrigen->importe_fijo, + 'tirada_min' => (int) $tiradaOrigen->tirada_min, + 'tirada_max' => (int) $tiradaOrigen->tirada_max, + 'user_created_id' => (int) auth()->id(), + 'is_deleted' => 0 + ]; + + try { + $nuevaTiradaId = $modelTETiradas->insert($nuevaTirada); + if (!$nuevaTiradaId) { + throw new \Exception("Error al insertar el registro."); + } + echo "
==>+Tirada creada con ID: " . $nuevaTiradaId; + } catch (\Exception $e) { + echo "Error: " . $e->getMessage(); + } + + // 3. Clonar las líneas asociadas a esta tirada + $lineasOrigen = $modelTELineas->where([ + 'tirada_encuadernacion_id' => $tiradaOrigen->id, + 'is_deleted' => 0 + ])->findAll(); + + foreach ($lineasOrigen as $lineaOrigen) { + $nuevaLinea = [ + 'tirada_encuadernacion_id' => (int) $nuevaTiradaId, + 'paginas_libro_min' => (float) $lineaOrigen->paginas_libro_min, + 'paginas_libro_max' => (float) $lineaOrigen->paginas_libro_max, + 'dimensiones_id' => (int) $lineaOrigen->dimensiones_id, + 'precio_min' => (float) $lineaOrigen->precio_min, + 'precio_max' => (float) $lineaOrigen->precio_max, + 'tirada_min' => (float) $lineaOrigen->tirada_min, + 'tirada_max' => (float) $lineaOrigen->tirada_max, + 'total_min' => (float) $lineaOrigen->total_min, + 'margen' => (float) $lineaOrigen->margen, + 'user_created_id' => (int) auth()->id(), + 'is_deleted' => 0 + ]; + + try { + $nuevaLineaId = $modelTELineas->insert($nuevaLinea); + if (!$nuevaLineaId) { + throw new \Exception("Error al insertar el registro."); + } + echo "
====>+Linea creada con ID: " . $nuevaLineaId; + } catch (\Exception $e) { + echo "Error: " . $e->getMessage(); + } + + } + + // 4. Clonar las líneas y horas asociadas a esta tirada + $lineasHorasOrigen = $modelTELineasHoras->where([ + 'tirada_encuadernacion_id' => $tiradaOrigen->id, + 'is_deleted' => 0 + ])->findAll(); + + foreach ($lineasHorasOrigen as $lineaHoraOrigen) { + $nuevaLineaHora = [ + 'tirada_encuadernacion_id' => (int) $nuevaTiradaId, + 'tiempo_min' => (float) $lineaHoraOrigen->tiempo_min, + 'tiempo_max' => (float) $lineaHoraOrigen->tiempo_max, + 'precio_hora' => (float) $lineaHoraOrigen->precio_hora, + 'total_min' => (float) $lineaHoraOrigen->total_min, + 'margen' => (float) $lineaHoraOrigen->margen, + 'user_created_id' => (int) auth()->id(), + 'is_deleted' => 0 + ]; + + try { + $nuevaLineaHoraId = $modelTELineasHoras->insert($nuevaLineaHora); + if (!$nuevaLineaHoraId) { + throw new \Exception("Error al insertar el registro."); + } + echo "
====>+Linea/Hora creado con ID: " . $nuevaLineaHoraId; + } catch (\Exception $e) { + echo "Error: " . $e->getMessage(); + } + + } + } + + echo "
*** Proceso de clonacion completado. ***

"; + } + + + + + + +} diff --git a/ci4/app/Database/Migrations/2024-11-13-161331_CheckWebClientesPapeles.php b/ci4/app/Database/Migrations/2024-11-13-161331_CheckWebClientesPapeles.php new file mode 100644 index 00000000..56decb5f --- /dev/null +++ b/ci4/app/Database/Migrations/2024-11-13-161331_CheckWebClientesPapeles.php @@ -0,0 +1,27 @@ + [ + 'type' => 'TINYINT', + 'constraint' => 1, + 'null' => false, + 'default' => 0, + ], + ]; + + $this->forge->addColumn('lg_papel_impresion', $fields); + } + + public function down() + { + $this->forge->dropColumn('lg_papel_impresion', 'show_in_client'); + } +} diff --git a/ci4/app/Database/Migrations/2024-11-17-194547_ModifyNullableComercialSoporte.php b/ci4/app/Database/Migrations/2024-11-17-194547_ModifyNullableComercialSoporte.php new file mode 100644 index 00000000..0805fcf0 --- /dev/null +++ b/ci4/app/Database/Migrations/2024-11-17-194547_ModifyNullableComercialSoporte.php @@ -0,0 +1,37 @@ +forge->modifyColumn('clientes', [ + 'comercial_id' => [ + 'type' => 'int(10) unsigned', + 'null' => true, // Permitir valores NULL + ], + 'soporte_id' => [ + 'type' => 'int(10) unsigned', + 'null' => true, // Permitir valores NULL + ], + ]); + + } + + public function down() + { + $this->forge->modifyColumn('clientes', [ + 'comercial_id' => [ + 'type' => 'int(10) unsigned', + 'null' => false, + ], + 'soporte_id' => [ + 'type' => 'int(10) unsigned', + 'null' => false, + ], + ]); + } +} diff --git a/ci4/app/Database/Migrations/2024-11-19-185529_TicksPapeles.php b/ci4/app/Database/Migrations/2024-11-19-185529_TicksPapeles.php new file mode 100644 index 00000000..4972e2df --- /dev/null +++ b/ci4/app/Database/Migrations/2024-11-19-185529_TicksPapeles.php @@ -0,0 +1,40 @@ + [ + 'type' => 'TINYINT', + 'constraint' => 1, + 'null' => false, + 'default' => 0, + ], + ]; + + $this->forge->addColumn('lg_papel_generico', $fields); + + $fields = [ + 'show_in_client_special' => [ + 'type' => 'TINYINT', + 'constraint' => 1, + 'null' => false, + 'default' => 0, + ], + ]; + + $this->forge->addColumn('lg_papel_impresion', $fields); + } + + public function down() + { + $this->forge->dropColumn('lg_papel_generico', 'show_in_client_special'); + $this->forge->dropColumn('lg_papel_impresion', 'show_in_client_special'); + + } +} diff --git a/ci4/app/Database/Migrations/2024-11-20-162124_CambiarTicksPapelImpresion.php b/ci4/app/Database/Migrations/2024-11-20-162124_CambiarTicksPapelImpresion.php new file mode 100644 index 00000000..94f3f9ad --- /dev/null +++ b/ci4/app/Database/Migrations/2024-11-20-162124_CambiarTicksPapelImpresion.php @@ -0,0 +1,46 @@ + [ + 'type' => 'TINYINT', + 'constraint' => 1, + 'null' => false, + 'default' => 0, + ], + ]; + + $this->forge->addColumn('lg_papel_impresion', $fields); + $this->forge->dropColumn('lg_papel_impresion', 'show_in_client'); + $this->forge->dropColumn('lg_papel_impresion', 'show_in_client_special'); + } + + public function down() + { + $fields = [ + 'show_in_client_special' => [ + 'type' => 'TINYINT', + 'constraint' => 1, + 'null' => false, + 'default' => 0, + ], + 'show_in_client' => [ + 'type' => 'TINYINT', + 'constraint' => 1, + 'null' => false, + 'default' => 0, + ], + ]; + + $this->forge->addColumn('lg_papel_impresion', $fields); + $this->forge->dropColumn('lg_papel_impresion', 'use_in_client'); + + } +} diff --git a/ci4/app/Database/Migrations/2024-11-25-173558_AddTickInteriorPapelImpresion.php b/ci4/app/Database/Migrations/2024-11-25-173558_AddTickInteriorPapelImpresion.php new file mode 100644 index 00000000..85cc60d3 --- /dev/null +++ b/ci4/app/Database/Migrations/2024-11-25-173558_AddTickInteriorPapelImpresion.php @@ -0,0 +1,26 @@ + [ + 'type' => 'TINYINT', + 'constraint' => 1, + 'null' => false, + 'default' => 0, + ], + ]; + $this->forge->addColumn('lg_papel_impresion', $fields); + } + + public function down() + { + $this->forge->dropColumn('lg_papel_impresion', 'interior'); + } +} diff --git a/ci4/app/Database/Migrations/2024-11-27-105608_AddTickTapaDuraPapelImp.php b/ci4/app/Database/Migrations/2024-11-27-105608_AddTickTapaDuraPapelImp.php new file mode 100644 index 00000000..e5cc1b91 --- /dev/null +++ b/ci4/app/Database/Migrations/2024-11-27-105608_AddTickTapaDuraPapelImp.php @@ -0,0 +1,27 @@ + [ + 'type' => 'TINYINT', + 'constraint' => 1, + 'null' => false, + 'default' => 0, + ], + ]; + + $this->forge->addColumn('lg_papel_impresion', $fields); + } + + public function down() + { + $this->forge->dropColumn('lg_papel_impresion', 'use_for_tapa_dura'); + } +} diff --git a/ci4/app/Database/Seeds/MessageSeeder.php b/ci4/app/Database/Seeds/MessageSeeder.php new file mode 100644 index 00000000..d8d450ca --- /dev/null +++ b/ci4/app/Database/Seeds/MessageSeeder.php @@ -0,0 +1,52 @@ + "Message Test", + "messages" => [ + [ + "sender_id" => 1, + "receiver_id" => 127, + ], + [ + "sender_id" => 127, + "receiver_id" => 1, + ] + ] + ]; + $chatModel = model(ChatModel::class); + $chatMessageModel = model(ChatMessageModel::class); + $chatNotificationModel = model(ChatNotification::class); + $userModel = model(UserModel::class); + foreach (range(1,100) as $key => $value) { + $chat_id = $chatModel->insert(["title" => $data["title"]." ".$value]); + foreach ($data["messages"] as $key => $value) { + $first_name = $userModel->find($value["receiver_id"])?->first_name; + $chat_message_id = $chatMessageModel->insert([ + "chat_id" => $chat_id, + "sender_id" => $value["sender_id"], + "receiver_id" => $value["receiver_id"], + "message" => "Hola"." ".$first_name + ]); + $chatNotificationModel->insert([ + "chat_message_id" => $chat_message_id, + "user_id" => $value["receiver_id"] + ]); + } + } + } +} diff --git a/ci4/app/Entities/Configuracion/PapelGenerico.php b/ci4/app/Entities/Configuracion/PapelGenerico.php index 7203bca4..a6bc5faa 100755 --- a/ci4/app/Entities/Configuracion/PapelGenerico.php +++ b/ci4/app/Entities/Configuracion/PapelGenerico.php @@ -10,13 +10,15 @@ class PapelGenerico extends \CodeIgniter\Entity\Entity "nombre" => null, "code" => null, "code_ot" => null, - "show_in_client" => true, + "show_in_client" => false, + "show_in_client_special" => false, "is_deleted" => 0, "created_at" => null, "updated_at" => null, ]; protected $casts = [ "show_in_client" => "boolean", + "show_in_client_special" => "boolean", "is_deleted" => "int", ]; } diff --git a/ci4/app/Entities/Configuracion/PapelImpresion.php b/ci4/app/Entities/Configuracion/PapelImpresion.php index b2ef88ce..4d79a06e 100755 --- a/ci4/app/Entities/Configuracion/PapelImpresion.php +++ b/ci4/app/Entities/Configuracion/PapelImpresion.php @@ -15,6 +15,7 @@ class PapelImpresion extends \CodeIgniter\Entity\Entity "espesor" => 0.0, "gramaje" => null, "precio_tonelada" => null, + "interior" => true, "bn" => true, "color" => true, "cubierta" => false, @@ -22,6 +23,9 @@ class PapelImpresion extends \CodeIgniter\Entity\Entity "guardas" => false, "inkjet" => false, "rotativa" => false, + "isActivo" => true, + "use_in_client" => false, + "use_for_tapa_dura" => false, "is_deleted" => 0, "created_at" => null, "updated_at" => null, @@ -33,12 +37,16 @@ class PapelImpresion extends \CodeIgniter\Entity\Entity "espesor" => "float", "gramaje" => "float", "precio_tonelada" => "float", + "interior" => "boolean", "bn" => "boolean", "color" => "boolean", "cubierta" => "boolean", "sobrecubierta" => "boolean", "guardas" => "boolean", "rotativa" => "boolean", + "isActivo" => "boolean", + "use_in_client" => "boolean", + "use_for_tapa_dura" => "boolean", "is_deleted" => "int", ]; } diff --git a/ci4/app/Language/en/Presupuestos.php b/ci4/app/Language/en/Presupuestos.php index cce0c828..a0d07b78 100755 --- a/ci4/app/Language/en/Presupuestos.php +++ b/ci4/app/Language/en/Presupuestos.php @@ -6,7 +6,7 @@ return [ 'moduleTitleCosidoTB' => 'Budget for Softcover Stitched Book', 'moduleTitleFresadoTB' => 'Budget for Softcover Milling Book', - 'presupuestoCosidotapablandaList' => 'List of budgets for Softcover Stitched Books', + 'presupuestoPresupuestoAdminList' => 'List of budgets for Softcover Stitched Books', 'presupuestoFresadotapablandaList' => 'List of budgets for Milling Stitched Books', 'presupuesto' => 'Budget', @@ -51,7 +51,7 @@ return [ 'merma' => 'Weakening', 'mermacubierta' => 'Cover weakening', 'tipoImpresion' => 'Printing type', - 'papelesComparadorCosidoTapaBlanda' => 'Interior and cover papers', + 'papelesComparadorPresupuestoAdmin' => 'Interior and cover papers', 'posicionPagColor' => 'Color pages position', 'colorPageInstructions' => 'Enter the position of the color pages within the book. E.g., 3,5,7 or 4-10,20,155.', 'numeroPaginas' => 'Nº Pages', diff --git a/ci4/app/Language/en/Users.php b/ci4/app/Language/en/Users.php index 116d67bc..9ef06c32 100755 --- a/ci4/app/Language/en/Users.php +++ b/ci4/app/Language/en/Users.php @@ -15,7 +15,7 @@ return [ 'createdAt' => 'Created At', 'dateBirth' => 'Date Birth', 'email' => 'Email', - 'emailConfirmed' => 'Email Confirmed', + 'emailConfirmed' => 'Email Confirmed', 'firstName' => 'First Name', 'group' => 'Group', 'idUser' => 'ID User', diff --git a/ci4/app/Language/es/Chat.php b/ci4/app/Language/es/Chat.php index 3bc975c8..1aca873e 100644 --- a/ci4/app/Language/es/Chat.php +++ b/ci4/app/Language/es/Chat.php @@ -3,12 +3,30 @@ return [ "chat" => "Mensajería", "messages" => "Mensajes", + "message" => "Mensaje", "modal" => [ - "new_hebra" => "Nueva hebra", + "new_hebra" => "Nuevo hilo", "title" => "Título", "new_message" => "Nuevo mensaje", "new_receivers" => "Nuevos participantes", "btn_send" => "Enviar", "btn_send_update" => "Enviar" - ] + ], + "datatable_messages" => [ + "created_at" => "Fecha creación", + "updated_at" => "Fecha actualización", + "title" => "Título", + "creator" => "Creador", + "viewed" => "Leído", + + ], + "new_message_ok" => "Mensaje enviado correctamente", + "participants" => "Participantes", + "choose_department" => "Elige un departamento", + "new_participant" => "Añadir nuevos participantes", + "write_message_placeholder" => "Escriba aquí su mensaje...", + "add_notification" => "Notificación", + "check_as_unviewed" => "Marcar como no leídos", + "add_notification_message" => "Envía a los usuarios añadidos una notificación con los mensajes presentes en el chat.", + "chat_title_presupuesto" => 'Presupuesto[{title,string,0}][{id}]' ]; \ No newline at end of file diff --git a/ci4/app/Language/es/PapelGenerico.php b/ci4/app/Language/es/PapelGenerico.php index 08215a20..c38d8c1c 100755 --- a/ci4/app/Language/es/PapelGenerico.php +++ b/ci4/app/Language/es/PapelGenerico.php @@ -16,6 +16,7 @@ return [ 'papelGenericoList' => 'Lista Papeles Genéricos', 'papelesGenericos' => 'Papeles Genéricos', 'showInClient' => 'Mostrar en cliente', + 'showInClientSpecial' => 'Papel especial cliente', 'updatedAt' => 'Actualizado el', 'form_acordion_title' => 'Propiedades Papel Genérico', diff --git a/ci4/app/Language/es/PapelImpresion.php b/ci4/app/Language/es/PapelImpresion.php index 46cfe47b..939442db 100755 --- a/ci4/app/Language/es/PapelImpresion.php +++ b/ci4/app/Language/es/PapelImpresion.php @@ -5,10 +5,12 @@ return [ 'alto' => 'Alto', 'ancho' => 'Ancho', + 'interior' => 'Interior', 'bn' => 'B/N', 'color' => 'Color', 'createdAt' => 'Creado en', 'cubierta' => 'Cubierta', + 'use_for_tapa_dura' => 'Papel tapa dura', 'sobrecubierta' => 'Sobrecubierta', 'guardas' => 'Guardas', 'defecto' => 'Por defecto', @@ -35,6 +37,7 @@ return [ 'rotativa' => 'Rotativa', 'updatedAt' => 'Actualizado en', 'activo' => 'Activo?', + 'useInClient' => 'Usar en presup. cliente', 'userUpdateId' => 'ID usuario actualización', 'consumo_tintas_rotativas' => 'Consumo tintas', diff --git a/ci4/app/Language/es/Presupuestos.php b/ci4/app/Language/es/Presupuestos.php index d9217b5f..1fb887c2 100755 --- a/ci4/app/Language/es/Presupuestos.php +++ b/ci4/app/Language/es/Presupuestos.php @@ -17,7 +17,7 @@ return [ 'presupuestoFresadotapaduraList' => 'Lista presupuestos Libros Fresado Tapa Dura', 'presupuestoFresadotapablandaList' => 'Lista presupuestos Libros Fresado Tapa Blanda', 'presupuestoCosidotapaduraList' => 'Lista presupuestos Libros Cosido Tapa Dura', - 'presupuestoCosidotapablandaList' => 'Lista presupuestos Libros Cosido Tapa Blanda', + 'presupuestoPresupuestoAdminList' => 'Lista presupuestos Libros Cosido Tapa Blanda', 'presupuesto' => 'Presupuesto', 'presupuestos' => 'Presupuestos', @@ -80,7 +80,7 @@ return [ 'merma' => 'Merma', 'mermacubierta' => 'Merma cubierta', 'tipoImpresion' => 'Tipo de impresión', - 'papelesComparadorCosidoTapaBlanda' => 'Papeles interior y cubierta', + 'papelesComparadorPresupuestoAdmin' => 'Papeles interior y cubierta', 'posicionPagColor' => 'Posición páginas a color', 'papelDiferente' => 'Papel color y negro diferente', 'paginasColorConsecutivas' => 'Páginas color consecutivas', @@ -256,6 +256,7 @@ return [ // Placeholders 'formatoLibro' => "Formato libro", 'selectCliente' => "Seleccione cliente", + 'selectPapel' => "Seleccione papel", // Preview diff --git a/ci4/app/Language/es/RolesPermisos.php b/ci4/app/Language/es/RolesPermisos.php index d17f9cef..0df0eed0 100644 --- a/ci4/app/Language/es/RolesPermisos.php +++ b/ci4/app/Language/es/RolesPermisos.php @@ -19,6 +19,7 @@ return [ 'adminRolTooltip' => 'Permitir acceso completo al sistema', // System permissions + 'viewPermission' => 'Visualizar', 'createPermission' => 'Crear', 'editPermission' => 'Editar', 'deletePermission' => 'Eliminar', @@ -30,6 +31,10 @@ return [ 'direccionesSection' => 'Direcciones', 'presupuestoSection' => 'Presupuestos', 'presupuestoClienteSection' => 'Presupuestos', + 'pedidosActivosSection' => 'Activos', + 'pedidosFinalizadosSection' => 'Finalizados', + 'pedidosCanceladosSection' => 'Cancelados', + 'pedidosTodosSection' => 'Todos', 'tarifaPreimpresionSection' => 'Tarifas de preimpresión', 'tarifaManipuladoSection' => 'Tarifas de manipulado', 'tarifaAcabadoSection' => 'Tarifas de acabado', diff --git a/ci4/app/Models/Chat/ChatDeparmentModel.php b/ci4/app/Models/Chat/ChatDeparmentModel.php index e51f29ce..1681f814 100644 --- a/ci4/app/Models/Chat/ChatDeparmentModel.php +++ b/ci4/app/Models/Chat/ChatDeparmentModel.php @@ -10,7 +10,7 @@ class ChatDeparmentModel extends Model protected $table = 'chat_departments'; protected $primaryKey = 'id'; protected $useAutoIncrement = true; - protected $returnType = 'array'; + protected $returnType = 'object'; protected $useSoftDeletes = false; protected $protectFields = true; protected $allowedFields = [ @@ -53,9 +53,9 @@ class ChatDeparmentModel extends Model public function getChatDepartments(string $type = "general"): array { $userModel = model(UserModel::class); - $chatMessageModel = model(ChatMessageModel::class); + $chatModel = model(ChatModel::class); - $query = $this->db->table('chat_departments') + $query = $this->builder() ->select( [ @@ -63,7 +63,6 @@ class ChatDeparmentModel extends Model 'chat_departments.name', 'chat_departments.display', 'chat_department_users.user_id', - 'chats.id as chatId', ] ) ->join( @@ -71,30 +70,26 @@ class ChatDeparmentModel extends Model "chat_department_users.chat_department_id = chat_departments.id", 'left' ) - ->join("chats", "chats.chat_department_id = chat_departments.id", "left") ->join( "users", "chat_department_users.user_id = users.id", 'left' - )->join( - "chat_messages", - "chat_messages.chat_id = chats.id", - "left" ) ->where("chat_departments.type", $type); - if (auth()->user()->cliente_id == null) { - $query->where("chat_department_users.user_id", auth()->user()->id); - } + + + // if (auth()->user()->cliente_id == null) { + // $query->where("chat_department_users.user_id", auth()->user()->id); + // } $results = $query->get()->getResultArray(); // Create the desired structure $departments = []; - foreach ($results as $row) { $departmentName = $row['name']; - // If the department is not yet added to the array, initialize it if (!isset($departments[$departmentName])) { + $departments[$departmentName] = [ 'id' => $row['id'], 'name' => $row['name'], @@ -131,4 +126,21 @@ class ChatDeparmentModel extends Model ->get()->getResultObject(); return $result; } + public function getDisplay(int $chat_deparment_id) : string + { + return $this->find($chat_deparment_id)->display; + } + public function getChatDepartmentSelect(string $query = null) + { + $q = $this->builder()->select([ + "id", + "display as name", + "description" + ]); + if($query){ + $q->orLike("display",$query) + ->orLike("name",$query); + } + return $q; + } } diff --git a/ci4/app/Models/Chat/ChatMessageModel.php b/ci4/app/Models/Chat/ChatMessageModel.php index f87c1243..e0ee9a20 100644 --- a/ci4/app/Models/Chat/ChatMessageModel.php +++ b/ci4/app/Models/Chat/ChatMessageModel.php @@ -2,16 +2,18 @@ namespace App\Models\Chat; +use App\Models\ChatNotification; use App\Models\Usuarios\UserModel; use CodeIgniter\Model; +use CodeIgniter\Database\BaseBuilder; class ChatMessageModel extends Model { protected $table = 'chat_messages'; protected $primaryKey = 'id'; protected $useAutoIncrement = true; - protected $returnType = 'array'; - protected $useSoftDeletes = false; + protected $returnType = 'object'; + protected $useSoftDeletes = true; protected $protectFields = true; protected $allowedFields = [ "message", @@ -28,7 +30,7 @@ class ChatMessageModel extends Model protected array $castHandlers = []; // Dates - protected $useTimestamps = false; + protected $useTimestamps = true; protected $dateFormat = 'datetime'; protected $createdField = 'created_at'; protected $updatedField = 'updated_at'; @@ -71,11 +73,30 @@ class ChatMessageModel extends Model } return $messages; } + public function get_chat_message(int $chat_message_id): object + { + $user = model(UserModel::class); + $auth_user = auth()->user(); + $message = $this->find($chat_message_id); + $message->pos = $auth_user->id == $message->sender_id ? "right" : "left"; + if ($auth_user->id == $message->sender_id) { + $message->sender_first_name = $auth_user->first_name; + $message->sender_last_name = $auth_user->last_name; + + } else { + $sender_user = $user->find($message->sender_id); + $message->sender_first_name = $sender_user->first_name; + $message->sender_last_name = $sender_user->last_name; + } + return $message; + } public function get_chat_contact_messages(int $receiver_id): array { $conversationArray = []; $userModel = model(UserModel::class); + $chatNotificationModel = model(ChatNotification::class); $receiverUser = $userModel->find($receiver_id); + $chat_id = null; $messagesFromClient = $this->builder() ->where("sender_id", auth()->user()->id) ->where("receiver_id", $receiverUser->id) @@ -95,7 +116,9 @@ class ChatMessageModel extends Model $conversationArray[] = $message; } $dates = array(); + foreach ($conversationArray as $key => $row) { + $chatNotificationModel->builder()->set("viewed", true)->where("chat_message_id", $row->id)->where("user_id", auth()->user()->id)->update(); $dates[$key] = strtotime($row->created_at); } array_multisort($dates, SORT_ASC, $conversationArray); @@ -110,11 +133,32 @@ class ChatMessageModel extends Model ->where("receiver_id", auth()->user()->id)->countAllResults(); return $messagesFromReceiver; } + public function get_chat_department_messages_count(int $chat_id) : int + { + $chatDepartmentMessagesCount = $this->builder() + ->where("id",$chat_id) + ->countAllResults(); + return $chatDepartmentMessagesCount; + } + public function get_chat_messages_count(int $sender_id): int + { + $messagesFromReceiver = $this->builder() + ->groupStart() + ->where("sender_id", $sender_id) + ->where("receiver_id", auth()->user()->id) + ->orGroupStart() + ->where("receiver_id", $sender_id) + ->where("sender_id", auth()->user()->id) + ->groupEnd() + ->groupEnd() + ->countAllResults(); + return $messagesFromReceiver; + } public function set_chat_messages_as_read(int $sender_id): int { $messagesFromReceiver = $this->builder() ->set("viewed", true) - ->where("sender_id", $sender_id) + ->where("user_id", $sender_id) ->where("receiver_id", auth()->user()->id)->update(); return $messagesFromReceiver; } @@ -122,23 +166,32 @@ class ChatMessageModel extends Model { $chatDepartmentModel = model(ChatDeparmentModel::class); $chatModel = model(ChatModel::class); - - if(auth()->user()->cliente_id){ + $messagesFromReceiver = 0; + $auth_user = auth()->user(); + $chat_department_id = $chatModel->find($chat_id)->chat_department_id; + $users_in_chat = array_map(fn($x) => $x->id, $chatDepartmentModel->getChatDepartmentUsers($chat_department_id)); + if (auth()->user()->cliente_id) { + // Si el usuario es cliente, marca como leídos todos los mensajes exceptos los suyos $messagesFromReceiver = $this->builder() - ->set("viewed", true) - ->where("chat_id", $chat_id) - ->whereNotIn("sender_id", [auth()->user()->id])->update(); - }else{ - $chat_department_id = $chatModel->find($chat_id)->chat_department_id; - $users_in_chat = array_map(fn($x) => $x->id, $chatDepartmentModel->getChatDepartmentUsers($chat_department_id)); - $messagesFromReceiver = $this->builder() - ->set("viewed", true) - ->where("chat_id", $chat_id) - ->whereNotIn("sender_id", $users_in_chat) - ->update(); + ->set("viewed", true) + ->where("chat_id", $chat_id) + ->whereNotIn("sender_id", [$auth_user->id])->update(); + } else { + // Si el usuario no es cliente y está dentro de los usuarios de departamento + // marca como leido todos los mensajes, excepto los mensajes de los usuarios + // de dentro del departamento + if (in_array($auth_user->id, $users_in_chat) == true) { + // if (($key = array_search($auth_user->id, $users_in_chat)) !== false) { + // unset($users_in_chat[$key]); + // } + $messagesFromReceiver = $this->builder() + ->set("viewed", true) + ->where("chat_id", $chat_id) + ->whereNotIn("sender_id", $users_in_chat) + ->update(); + } } - + return $messagesFromReceiver; } - } diff --git a/ci4/app/Models/Chat/ChatModel.php b/ci4/app/Models/Chat/ChatModel.php index 29367da0..78628011 100644 --- a/ci4/app/Models/Chat/ChatModel.php +++ b/ci4/app/Models/Chat/ChatModel.php @@ -3,12 +3,13 @@ namespace App\Models\Chat; use App\Models\ChatNotification; +use App\Models\ChatUser; use App\Models\Facturas\FacturaModel; use App\Models\Pedidos\PedidoModel; use App\Models\Presupuestos\PresupuestoModel; use App\Models\Usuarios\UserModel; use CodeIgniter\Model; -use stdClass; +use CodeIgniter\Database\BaseBuilder; class ChatModel extends Model { @@ -16,7 +17,7 @@ class ChatModel extends Model protected $primaryKey = 'id'; protected $useAutoIncrement = true; protected $returnType = 'object'; - protected $useSoftDeletes = false; + protected $useSoftDeletes = true; protected $protectFields = true; protected $allowedFields = [ "pedido_id", @@ -33,7 +34,7 @@ class ChatModel extends Model protected array $castHandlers = []; // Dates - protected $useTimestamps = false; + protected $useTimestamps = true; protected $dateFormat = 'datetime'; protected $createdField = 'created_at'; protected $updatedField = 'updated_at'; @@ -80,35 +81,48 @@ class ChatModel extends Model { return $this->builder()->where("pedido_id", $pedido_id)->where("chat_department_id", $chat_department_id)->get()->getFirstRow(); } - public function getChatFactura(int $chat_department_id, int $factura_id) + public function getChatFactura(int $chat_department_id, int $factura_id) { return $this->builder()->where("factura_id", $factura_id)->where("chat_department_id", $chat_department_id)->get()->getFirstRow(); } public function createChatPresupuesto(int $chat_department_id, int $presupuesto_id): int { + $model = model(PresupuestoModel::class); + $chatDeparmentModel = model(ChatDeparmentModel::class); + $presupuesto = $model->find($presupuesto_id); return $this->insert([ + "title" => $presupuesto->titulo."[".$chatDeparmentModel->getDisplay($chat_department_id)."]", "presupuesto_id" => $presupuesto_id, "chat_department_id" => $chat_department_id ]); } - public function createChatPedido(int $chat_department_id, int $pedido_id) : int + public function createChatPedido(int $chat_department_id, int $pedido_id): int { - return $this->insert([ + $model = model(PedidoModel::class); + $chatDeparmentModel = model(ChatDeparmentModel::class); + $pedido = $model->getPedidoClientePresupuesto($pedido_id); + return $this->insert([ + "title" => "Pedido ".$pedido->titulo."[".$chatDeparmentModel->getDisplay($chat_department_id)."]", "pedido_id" => $pedido_id, "chat_department_id" => $chat_department_id ]); } - public function createChatFactura(int $chat_department_id, int $factura_id) : int + public function createChatFactura(int $chat_department_id, int $factura_id): int { + + $model = model(FacturaModel::class); + $chatDeparmentModel = model(ChatDeparmentModel::class); + $factura = $model->find($factura_id); return $this->insert([ + "title" => "Factura ".$factura->numero."[".$chatDeparmentModel->getDisplay($chat_department_id)."]", "factura_id" => $factura_id, "chat_department_id" => $chat_department_id ]); } - public function createChatSingle() : int + public function createChatSingle(): int { return $this->insert(["chat_department_id" => null]); } @@ -137,82 +151,82 @@ class ChatModel extends Model return $countChatPresupuesto > 0; } - public function getChatPedidosChat() : array + public function getChatPedidosChat(): array { $query = $this->db->table("chats") - ->select([ - "chats.id as chatId", - "chats.pedido_id as pedidoId", - "chats.chat_department_id as chatDepartmentId", - "chat_departments.display as chatDisplay", - "pedidos.id as title" - ]) - ->join("chat_departments","chat_departments.id = chats.chat_department_id","left") - ->join("pedidos","pedidos.id = chats.pedido_id","left") - ->get()->getResultObject(); + ->select([ + "chats.id as chatId", + "chats.pedido_id as pedidoId", + "chats.chat_department_id as chatDepartmentId", + "chat_departments.display as chatDisplay", + "pedidos.id as title" + ]) + ->join("chat_departments", "chat_departments.id = chats.chat_department_id", "left") + ->join("pedidos", "pedidos.id = chats.pedido_id", "left") + ->get()->getResultObject(); return $query; } - - public function getChatPresupuestosChat() : array + + public function getChatPresupuestosChat(): array { $query = $this->db->table("chats") - ->select([ - "chats.id as chatId", - "chats.pedido_id as pedidoId", - "chats.chat_department_id as chatDepartmentId", - "chat_departments.display as chatDisplay", - "presupuestos.titulo as title" - ]) - ->join("chat_departments","chat_departments.id = chats.chat_department_id","left") - ->join("presupuestos","presupuestos.id = chats.pedido_id","left") - ->get()->getResultObject(); + ->select([ + "chats.id as chatId", + "chats.pedido_id as pedidoId", + "chats.chat_department_id as chatDepartmentId", + "chat_departments.display as chatDisplay", + "presupuestos.titulo as title" + ]) + ->join("chat_departments", "chat_departments.id = chats.chat_department_id", "left") + ->join("presupuestos", "presupuestos.id = chats.pedido_id", "left") + ->get()->getResultObject(); return $query; } - public function getChatFacturasChat() : array + public function getChatFacturasChat(): array { $query = $this->db->table("chats") - ->select([ - "chats.id as chatId", - "chats.pedido_id as pedidoId", - "chats.chat_department_id as chatDepartmentId", - "chat_departments.display as chatDisplay", - "facturas.numero as title" - ]) - ->join("chat_departments","chat_departments.id = chats.chat_department_id","left") - ->join("facturas","facturas.id = chats.pedido_id","left") - ->get()->getResultObject(); + ->select([ + "chats.id as chatId", + "chats.pedido_id as pedidoId", + "chats.chat_department_id as chatDepartmentId", + "chat_departments.display as chatDisplay", + "facturas.numero as title" + ]) + ->join("chat_departments", "chat_departments.id = chats.chat_department_id", "left") + ->join("facturas", "facturas.id = chats.pedido_id", "left") + ->get()->getResultObject(); return $query; } - public function getChatSingleChat() : array + public function getChatSingleChat(): array { $query = $this->db->table("chats") - ->select([ - "chats.id as chatId", - "chats.chat_department_id as chatDepartmentId", - "chat_departments.display as chatDisplay", - "facturas.numero as title" - ]) - ->join("chat_departments","chat_departments.id = chats.chat_department_id","left") - ->join("facturas","facturas.id = chats.pedido_id","left") - ->get()->getResultObject(); + ->select([ + "chats.id as chatId", + "chats.chat_department_id as chatDepartmentId", + "chat_departments.display as chatDisplay", + "facturas.numero as title" + ]) + ->join("chat_departments", "chat_departments.id = chats.chat_department_id", "left") + ->join("facturas", "facturas.id = chats.pedido_id", "left") + ->get()->getResultObject(); return $query; } - public function getClienteChatPedidos(array $pedidos) : array + public function getClienteChatPedidos(array $pedidos): array { $q = $this->db->table("chats") - ->select([ - "chats.id as chatId", - "chats.pedido_id as pedidoId", - "chats.chat_department_id as chatDepartmentId", - "chat_departments.display as chatDisplay", - "pedidos.id as title" - ]) - ->join("chat_departments","chat_departments.id = chats.chat_department_id","left") - ->join("pedidos","pedidos.id = chats.pedido_id","left") - ->where('chats.chat_department_id is NOT NULL', NULL, FALSE); - if(count($pedidos)>0){ - $q->whereIn("pedidos.id",$pedidos); - }else{ + ->select([ + "chats.id as chatId", + "chats.pedido_id as pedidoId", + "chats.chat_department_id as chatDepartmentId", + "chat_departments.display as chatDisplay", + "pedidos.id as title" + ]) + ->join("chat_departments", "chat_departments.id = chats.chat_department_id", "left") + ->join("pedidos", "pedidos.id = chats.pedido_id", "left") + ->where('chats.chat_department_id is NOT NULL', NULL, FALSE); + if (count($pedidos) > 0) { + $q->whereIn("pedidos.id", $pedidos); + } else { return []; } $results = $q->get()->getResultObject(); @@ -221,32 +235,32 @@ class ChatModel extends Model foreach ($results as $row) { $messages = $chatMessageModel->get_chat_messages($row->chatId); foreach ($messages as $key => $message) { - if($message->sender_id != auth()->user()->id && $message->viewed == false){ + if ($message->sender_id != auth()->user()->id && $message->viewed == false) { $count++; } } - $row->uri = "/pedidos/edit/".$row->pedidoId; - $row->unreadMessages=$count; + $row->uri = "/pedidos/edit/" . $row->pedidoId; + $row->unreadMessages = $count; } return $results; } - public function getClienteChatFacturas(array $facturas) : array + public function getClienteChatFacturas(array $facturas): array { $q = $this->db->table("chats") - ->select([ - "chats.id as chatId", - "chats.factura_id as facturaId", - "chats.chat_department_id as chatDepartmentId", - "chat_departments.display as chatDisplay", - "facturas.numero as title" - ]) - ->join("chat_departments","chat_departments.id = chats.chat_department_id","left") - ->join("facturas","facturas.id = chats.factura_id","left") - ->where('chats.chat_department_id is NOT NULL', NULL, FALSE); + ->select([ + "chats.id as chatId", + "chats.factura_id as facturaId", + "chats.chat_department_id as chatDepartmentId", + "chat_departments.display as chatDisplay", + "facturas.numero as title" + ]) + ->join("chat_departments", "chat_departments.id = chats.chat_department_id", "left") + ->join("facturas", "facturas.id = chats.factura_id", "left") + ->where('chats.chat_department_id is NOT NULL', NULL, FALSE); - if(count($facturas)>0){ - $q->whereIn("facturas.id",$facturas); - }else{ + if (count($facturas) > 0) { + $q->whereIn("facturas.id", $facturas); + } else { return []; } $results = $q->get()->getResultObject(); @@ -255,32 +269,32 @@ class ChatModel extends Model foreach ($results as $row) { $messages = $chatMessageModel->get_chat_messages($row->chatId); foreach ($messages as $key => $message) { - if($message->sender_id != auth()->user()->id && $message->viewed == false){ + if ($message->sender_id != auth()->user()->id && $message->viewed == false) { $count++; } } - $row->uri = "/facturas/edit/".$row->facturaId; - $row->unreadMessages=$count; + $row->uri = "/facturas/edit/" . $row->facturaId; + $row->unreadMessages = $count; } return $results; } - public function getClienteChatPresupuestos(array $presupuestos) : array + public function getClienteChatPresupuestos(array $presupuestos): array { $q = $this->db->table("chats") - ->select([ - "chats.id as chatId", - "chats.presupuesto_id as presupuestoId", - "chats.chat_department_id as chatDepartmentId", - "chat_departments.display as chatDisplay", - "presupuestos.titulo as title" - ]) - ->join("chat_departments","chat_departments.id = chats.chat_department_id","left") - ->join("presupuestos","presupuestos.id = chats.presupuesto_id","left") - ->where('chats.chat_department_id is NOT NULL', NULL, FALSE); + ->select([ + "chats.id as chatId", + "chats.presupuesto_id as presupuestoId", + "chats.chat_department_id as chatDepartmentId", + "chat_departments.display as chatDisplay", + "presupuestos.titulo as title" + ]) + ->join("chat_departments", "chat_departments.id = chats.chat_department_id", "left") + ->join("presupuestos", "presupuestos.id = chats.presupuesto_id", "left") + ->where('chats.chat_department_id is NOT NULL', NULL, FALSE); - if(count($presupuestos)>0){ - $q->whereIn("presupuestos.id",$presupuestos); - }else{ + if (count($presupuestos) > 0) { + $q->whereIn("presupuestos.id", $presupuestos); + } else { return []; } $results = $q->get()->getResultObject(); @@ -288,15 +302,15 @@ class ChatModel extends Model $count = 0; foreach ($results as $row) { $messages = $chatMessageModel->get_chat_messages($row->chatId); - foreach ($messages as $key => $message ) { - if($message->sender_id != auth()->user()->id && $message->viewed == false){ + foreach ($messages as $key => $message) { + if ($message->sender_id != auth()->user()->id && $message->viewed == false) { $count++; } } - $row->uri = "/presupuestos/presupuestocliente/edit/".$row->presupuestoId; - $row->unreadMessages=$count; + $row->uri = "/presupuestos/presupuestocliente/edit/" . $row->presupuestoId; + $row->unreadMessages = $count; } - + return $results; } public function getChatDepartmentNotifications() @@ -308,55 +322,55 @@ class ChatModel extends Model $pedidoModel = model(PedidoModel::class); $q = $this->db->table("chats") - ->select([ - "chats.id as chatId", - "chats.pedido_id as pedidoId", - "chats.presupuesto_id as presupuestoId", - "chats.factura_id as facturaId", - "chats.presupuesto_id as presupuestoId", - "chats.chat_department_id as chatDepartmentId", - "chat_departments.display as chatDisplay", - ]) - ->join("chat_departments","chat_departments.id = chats.chat_department_id","left") - ->join("chat_department_users","chat_department_users.chat_department_id = chats.chat_department_id","left") - ->where("chat_department_users.user_id",auth()->user()->id); + ->select([ + "chats.id as chatId", + "chats.pedido_id as pedidoId", + "chats.presupuesto_id as presupuestoId", + "chats.factura_id as facturaId", + "chats.chat_department_id as chatDepartmentId", + "chat_departments.display as chatDisplay", + ]) + ->join("chat_departments", "chat_departments.id = chats.chat_department_id", "left") + ->join("chat_department_users", "chat_department_users.chat_department_id = chats.chat_department_id", "left") + ->where("chat_department_users.user_id", auth()->user()->id); $rows = $q->get()->getResultObject(); - - + + $auth_user = auth()->user(); foreach ($rows as $row) { $messages = $chatMessageModel->get_chat_messages($row->chatId); $count = 0; $chatDeparmentUsers = $chatDeparmentModel->getChatDepartmentUsers($row->chatDepartmentId); - $chatDeparmentUsersId = array_map(fn($x) => $x->id,$chatDeparmentUsers); + $chatDeparmentUsersId = array_map(fn($x) => $x->id, $chatDeparmentUsers); foreach ($messages as $m) { - if($m->viewed == false && $m->sender_id != auth()->user()->id && in_array($m->sender_id,$chatDeparmentUsersId) == false) + if ($m->viewed == false && $m->sender_id != auth()->user()->id && in_array($m->sender_id, $chatDeparmentUsersId) == false) $count++; } - if($row->presupuestoId){ + if ($row->presupuestoId) { $row->model = $presupuestoModel->find($row->presupuestoId); - $row->uri = "/presupuestos/cosidotapablanda/edit/".$row->presupuestoId; + if($auth_user->cliente_id){ + $row->uri = "/presupuestocliente/edit/" . $row->presupuestoId; + }else{ + $row->uri = "/presupuestoadmin/edit/" . $row->presupuestoId; + + } $row->title = $row->presupuestoId; $row->avatar = "PRE"; $row->unreadMessages = $count; - } - elseif($row->pedidoId){ + } elseif ($row->pedidoId) { $row->model = $pedidoModel->find($row->pedidoId); - $row->uri = "/pedidos/edit/".$row->pedidoId; + $row->uri = "/pedidos/edit/" . $row->pedidoId; $row->title = $row->pedidoId; $row->avatar = "P"; $row->unreadMessages = $count; - - } - elseif($row->facturaId){ + } elseif ($row->facturaId) { $row->model = $facturaModel->find($row->facturaId); - $row->uri = "/facturas/edit/".$row->facturaId; + $row->uri = "/facturas/edit/" . $row->facturaId; $row->avatar = "F"; $row->title = $row->facturaId; $row->unreadMessages = $count; } } return $rows; - } public function getChatInternalNotifications() { @@ -367,49 +381,97 @@ class ChatModel extends Model $chatNotificationModel = model(ChatNotification::class); $q = $this->db->table("chats") - ->select([ - "chats.id as chatId", - "chats.pedido_id as pedidoId", - "chats.presupuesto_id as presupuestoId", - "chats.factura_id as facturaId", - "chats.presupuesto_id as presupuestoId", - "chats.title as chatDisplay" - ]) - ->join("chat_messages","chat_messages.chat_id = chats.id","left") - ->join("chat_notifications","chat_notifications.chat_message_id = chat_messages.id","left") - ->where("chat_notifications.user_id",auth()->user()->id) - ->where("chat_notifications.viewed",false); + ->select([ + "chats.id as chatId", + "chats.chat_department_id as chatDepartmentId", + "chats.pedido_id as pedidoId", + "chats.presupuesto_id as presupuestoId", + "chats.factura_id as facturaId", + "chats.title as chatDisplay", + ]) + ->join("chat_messages", "chat_messages.chat_id = chats.id", "left") + ->join("chat_notifications", "chat_notifications.chat_message_id = chat_messages.id", "left") + ->where("chat_notifications.user_id", auth()->user()->id) + ->where("chat_notifications.viewed", false); + $auth_user = auth()->user(); $rows = $q->get()->getResultObject(); - + $rows_new = []; foreach ($rows as $row) { - if($row->presupuestoId){ + $row->unreadMessages = 0; + if ($row->presupuestoId) { $row->model = $presupuestoModel->find($row->presupuestoId); - $row->uri = "/presupuestos/cosidotapablanda/edit/".$row->presupuestoId; + if($auth_user->cliente_id){ + $row->uri = "/presupuestocliente/edit/" . $row->presupuestoId; + }else{ + $row->uri = "/presupuestoadmin/edit/" . $row->presupuestoId; + } $row->title = $row->presupuestoId; + if($row->chatDepartmentId){ + $row->chatDisplay = $row->model->titulo; + }else{ + $row->chatDisplay .="[INTERNAL]"; + } $row->avatar = "PRE"; $row->unreadMessages = $this->countUnreadMessagePresupuesto($row->presupuestoId); - } - elseif($row->pedidoId){ + $rows_new[] = $row; + } elseif ($row->pedidoId) { $row->model = $pedidoModel->find($row->pedidoId); - $row->uri = "/pedidos/edit/".$row->pedidoId; + $row->uri = "/pedidos/edit/" . $row->pedidoId; $row->title = $row->pedidoId; + if($row->chatDepartmentId){ + $row->chatDisplay .= "[INTERNAL]"; + } $row->avatar = "P"; $row->unreadMessages = $this->countUnreadMessagePedido($row->pedidoId); - - - } - elseif($row->facturaId){ + $rows_new[] = $row; + } elseif ($row->facturaId) { $row->model = $facturaModel->find($row->facturaId); - $row->uri = "/facturas/edit/".$row->facturaId; + $row->uri = "/facturas/edit/" . $row->facturaId; $row->avatar = "F"; + if($row->chatDepartmentId){ + $row->chatDisplay .= "[INTERNAL]"; + } $row->title = $row->facturaId; $row->unreadMessages = $this->countUnreadMessageFactura($row->facturaId); - + $rows_new[] = $row; } } - return $rows; + return $rows_new; } - public function getChatInternalHebraPresupuesto(int $chat_id,int $presupuesto_id) : array + public function getChatDirectMessageNotifications() + { + $chatMessageModel = model(ChatMessageModel::class); + $chatNotificationModel = model(ChatNotification::class); + + $q = $this->db->table("chats") + ->select([ + "chats.id as chatId", + "chats.title as chatDisplay", + "COUNT(chat_notifications.user_id) as unreadMessages" + ]) + ->join("chat_messages", "chat_messages.chat_id = chats.id", "left") + ->join("chat_notifications", "chat_notifications.chat_message_id = chat_messages.id", "left") + ->where("chats.presupuesto_id", null) + ->where("chats.chat_department_id", null) + ->where("chats.pedido_id", null) + ->where("chats.factura_id", null) + ->where("chat_notifications.viewed", false) + ->where("chat_notifications.user_id", auth()->user()->id); + $rows = $q->get()->getResultObject(); + $rows_new = []; + foreach ($rows as $row) { + if ($row->chatId) { + $row->model = []; + $row->uri = "/chat/direct/".$row->chatId; + $row->avatar = "MD"; + $row->title = "MD"; + // $row->chatDisplay = $this->getSenderIdFromChatMessage($row->chatId)?->username ?? "Unknown"; + $rows_new[] = $row; + } + } + return $rows_new; + } + public function getChatInternalHebraPresupuesto(int $chat_id, int $presupuesto_id): array { $data = []; @@ -420,17 +482,19 @@ class ChatModel extends Model "chat_messages.created_at", "CONCAT(users.first_name,' ',users.last_name) as senderFullName", ]) - ->join("chat_messages","chat_messages.chat_id = chats.id","left") - ->join("users","users.id = chat_messages.sender_id","left") - ->where("chats.id",$chat_id) - ->where("chats.presupuesto_id",$presupuesto_id); + ->join("chat_messages", "chat_messages.chat_id = chats.id", "left") + ->join("users", "users.id = chat_messages.sender_id", "left") + ->where("chats.id", $chat_id) + ->where("chats.presupuesto_id", $presupuesto_id); $data["chatId"] = $chat_id; $data["messages"] = $query->get()->getResultObject(); - $data["chatTitle"] = $this->find($chat_id)->title; + $data["chatTitle"] = "Presupuesto"."[".$presupuesto_id."] - "; + $data["chatTitle"].= $this->find($chat_id)->title; $data["users"] = $this->getChatUsers($chat_id); return $data; } - public function getChatInternalHebraPedido($chat_id,$pedido_id){ + public function getChatInternalHebraPedido($chat_id, $pedido_id) + { $data = []; $query = $this->builder()->select([ "chats.id as chatId", @@ -439,17 +503,19 @@ class ChatModel extends Model "chat_messages.created_at", "CONCAT(users.first_name,' ',users.last_name) as senderFullName", ]) - ->join("chat_messages","chat_messages.chat_id = chats.id","left") - ->join("users","users.id = chat_messages.sender_id","left") - ->where("chats.id",$chat_id) - ->where("chats.pedido_id",$pedido_id); + ->join("chat_messages", "chat_messages.chat_id = chats.id", "left") + ->join("users", "users.id = chat_messages.sender_id", "left") + ->where("chats.id", $chat_id) + ->where("chats.pedido_id", $pedido_id); $data["chatId"] = $chat_id; $data["messages"] = $query->get()->getResultObject(); - $data["chatTitle"] = $this->find($chat_id)->title; + $data["chatTitle"] = "Pedido"."[".$pedido_id."] - "; + $data["chatTitle"].= $this->find($chat_id)->title; $data["users"] = $this->getChatUsers($chat_id); return $data; } - public function getChatInternalHebraFactura($chat_id,$factura_id){ + public function getChatInternalHebraFactura($chat_id, $factura_id) + { $data = []; $query = $this->builder()->select([ "chats.id as chatId", @@ -458,13 +524,14 @@ class ChatModel extends Model "chat_messages.created_at", "CONCAT(users.first_name,' ',users.last_name) as senderFullName", ]) - ->join("chat_messages","chat_messages.chat_id = chats.id","left") - ->join("users","users.id = chat_messages.sender_id","left") - ->where("chats.id",$chat_id) - ->where("chats.factura_id",$factura_id); + ->join("chat_messages", "chat_messages.chat_id = chats.id", "left") + ->join("users", "users.id = chat_messages.sender_id", "left") + ->where("chats.id", $chat_id) + ->where("chats.factura_id", $factura_id); $data["chatId"] = $chat_id; $data["messages"] = $query->get()->getResultObject(); - $data["chatTitle"] = $this->find($chat_id)->title; + $data["chatTitle"] = "Factura"."[".$factura_id."] - "; + $data["chatTitle"].= $this->find($chat_id)->title; $data["users"] = $this->getChatUsers($chat_id); return $data; } @@ -474,71 +541,369 @@ class ChatModel extends Model "users.username", "CONCAT(users.first_name,' ',users.last_name) as userFullName", ]) - ->join("chat_users","chat_users.chat_id = chats.id") - ->join("users","users.id = chat_users.user_id","left") - ->where("chats.id",$chat_id); + ->join("chat_users", "chat_users.chat_id = chats.id") + ->join("users", "users.id = chat_users.user_id", "left") + ->where("chats.id", $chat_id); return $query->get()->getResultObject(); } - public function getPresupuestoHebras($presupuesto_id) : array + public function getPresupuestoHebras($presupuesto_id): array { $data = []; $chats = $this->builder()->select("chats.id as chatId") - ->where("chats.chat_department_id",null) - ->where("chats.presupuesto_id",$presupuesto_id)->get()->getResultObject(); + ->where("chats.chat_department_id", null) + ->where("chats.presupuesto_id", $presupuesto_id)->get()->getResultObject(); foreach ($chats as $chat) { - $data[$chat->chatId] = $this->getChatInternalHebraPresupuesto($chat->chatId,$presupuesto_id); - } + $data[$chat->chatId] = $this->getChatInternalHebraPresupuesto($chat->chatId, $presupuesto_id); + } return $data; } - public function getPedidoHebras($pedido_id) : array + public function getPedidoHebras($pedido_id): array { $data = []; $chats = $this->builder()->select("chats.id as chatId") - ->where("chats.chat_department_id",null) - ->where("chats.pedido_id",$pedido_id)->get()->getResultObject(); + ->where("chats.chat_department_id", null) + ->where("chats.pedido_id", $pedido_id)->get()->getResultObject(); foreach ($chats as $chat) { - $data[$chat->chatId] = $this->getChatInternalHebraPedido($chat->chatId,$pedido_id); - } + $data[$chat->chatId] = $this->getChatInternalHebraPedido($chat->chatId, $pedido_id); + } return $data; } - public function getFacturaHebras($factura_id) : array + public function getFacturaHebras($factura_id): array { $data = []; $chats = $this->builder()->select("chats.id as chatId") - ->where("chats.chat_department_id",null) - ->where("chats.factura_id",$factura_id)->get()->getResultObject(); + ->where("chats.chat_department_id", null) + ->where("chats.factura_id", $factura_id)->get()->getResultObject(); foreach ($chats as $chat) { - $data[$chat->chatId] = $this->getChatInternalHebraFactura($chat->chatId,$factura_id); - } + $data[$chat->chatId] = $this->getChatInternalHebraFactura($chat->chatId, $factura_id); + } return $data; } - public function countUnreadMessagePresupuesto($presupuesto_id) : int|string + public function countUnreadMessagePresupuesto($presupuesto_id): int|string { return $this->builder()->select() - ->join("chat_messages","chat_messages.chat_id = chats.id","left") - ->join("chat_notifications","chat_notifications.chat_message_id = chat_messages.id","left") - ->where("chats.presupuesto_id",$presupuesto_id) - ->where("chat_notifications.viewed",false) - ->where("chat_notifications.user_id",auth()->user()->id) - ->countAllResults(); + ->join("chat_messages", "chat_messages.chat_id = chats.id", "left") + ->join("chat_notifications", "chat_notifications.chat_message_id = chat_messages.id", "left") + ->where("chats.presupuesto_id", $presupuesto_id) + ->where("chat_notifications.viewed", false) + ->where("chat_notifications.user_id", auth()->user()->id) + ->countAllResults(); } - public function countUnreadMessagePedido($pedido_id) : int|string + public function countUnreadMessagePedido($pedido_id): int|string { return $this->builder()->select() - ->join("chat_messages","chat_messages.chat_id = chats.id","left") - ->join("chat_notifications","chat_notifications.chat_message_id = chat_messages.id","left") - ->where("chats.pedido_id",$pedido_id) - ->where("chat_notifications.viewed",false) - ->where("chat_notifications.user_id",auth()->user()->id) - ->countAllResults(); + ->join("chat_messages", "chat_messages.chat_id = chats.id", "left") + ->join("chat_notifications", "chat_notifications.chat_message_id = chat_messages.id", "left") + ->where("chats.pedido_id", $pedido_id) + ->where("chat_notifications.viewed", false) + ->where("chat_notifications.user_id", auth()->user()->id) + ->countAllResults(); } - public function countUnreadMessageFactura($factura_id) : int|string + public function countUnreadMessageFactura($factura_id): int|string { return $this->builder()->select() - ->join("chat_messages","chat_messages.chat_id = chats.id","left") - ->join("chat_notifications","chat_notifications.chat_message_id = chat_messages.id","left") - ->where("chats.factura_id",$factura_id) - ->where("chat_notifications.viewed",false) - ->where("chat_notifications.user_id",auth()->user()->id)->countAllResults(); + ->join("chat_messages", "chat_messages.chat_id = chats.id", "left") + ->join("chat_notifications", "chat_notifications.chat_message_id = chat_messages.id", "left") + ->where("chats.factura_id", $factura_id) + ->where("chat_notifications.viewed", false) + ->where("chat_notifications.user_id", auth()->user()->id)->countAllResults(); + } + public function countUnreadMessageDirectos(int $chat_id): int|string + { + return $this->builder()->select() + ->join("chat_messages", "chat_messages.chat_id = chats.id", "left") + ->join("chat_notifications", "chat_notifications.chat_message_id = chat_messages.id", "left") + ->where("chats.presupuesto_id", null) + ->where("chats.pedido_id", null) + ->where("chats.factura_id", null) + ->where("chats.chat_department_id", null) + ->where("chat_messages.chat_id", $chat_id) + ->where("chat_notifications.viewed", false) + ->where("chat_notifications.user_id", auth()->user()->id)->countAllResults(); + } + public function getSenderIdFromChatMessage(int $chat_id) + { + $first_message = $this->builder()->select() + ->join("chat_messages", "chat_messages.chat_id = chats.id", "left") + ->where("chats.presupuesto_id", null) + ->where("chats.pedido_id", null) + ->where("chats.factura_id", null) + ->where("chats.id", $chat_id) + ->where("chat_messages.receiver_id", auth()->user()->id)->get()->getFirstRow(); + $userModel = model(UserModel::class); + return $userModel->find($first_message->sender_id); + } + public function getOpenChatCliente(int $user_id): array + { + $q = $this->builder()->distinct()->select([ + "users.*" + ]) + ->join("chat_messages", "chat_messages.chat_id = chats.id", "left") + ->join("users", "users.id = chat_messages.sender_id", "left") + ->where("chat_messages.receiver_id", $user_id); + + return $q->get()->getResultObject(); + } + public function getChatDepartmentMessagesCount(int $chat_id, int $chat_department_id): int + { + $q = $this->builder()->select([ + "chat_messages.id" + ]) + ->join("chat_messages", "chat_messages.chat_id = chats.id", 'left') + ->where("chats.chat_department_id", $chat_department_id) + ->where("chats.id", $chat_id) + ->countAllResults(); + return $q; + } + public function getChatFirstUser(int $chat_id): object + { + $q = $this->builder()->select([ + "users.id", + "CONCAT(users.first_name,' ',users.last_name) as userFullName", + ]) + ->join("chat_messages", "chat_messages.chat_id = chats.id", 'left') + ->join("users", "users.id = chat_messages.sender_id", "left") + ->where("chats.id", $chat_id) + ->where("chat_messages.deleted_at", null) + ->orderBy("chat_messages.created_at", 'ASC'); + return $q->get()->getFirstRow(); + } + /** + * Check if all messages of a chat sended to an user have been viewed. + * + * @param integer $chat_id + * @param integer $user_id + * @return boolean True : All messages readed + */ + public function isMessageChatViewed(int $chat_id, int $user_id): bool + { + $q = $this->builder()->select(["chat_notifications.id"]) + ->join("chat_messages", "chat_messages.chat_id = chats.id", 'left') + ->join("chat_notifications", "chat_notifications.chat_message_id = chat_messages.id", 'left') + ->where("chats.id", $chat_id) + ->where("chat_notifications.user_id", $user_id) + ->where("chat_notifications.viewed", false); + $unread_messages_count = $q->countAllResults(); + if ($unread_messages_count > 0) { + $result = false; + } else { + $result = true; + } + return $result; + } + + public function getQueryDatatable(int $user_id): BaseBuilder + { + $query = $this->builder() + ->select([ + "chats.id", + "chats.created_at", + "chats.updated_at", + "chats.title", + ]) + ->join("chat_users","chat_users.chat_id = chats.id","left") + ->where("chat_department_id", null) + ->where("pedido_id", null) + ->where("presupuesto_id", null) + ->where("factura_id", null) + ->where("chat_users.user_id",$user_id) + ->orderBy("created_at", "DESC") + ->groupBy("chats.id"); + + return $query; + } + public function getQueryDatatableMessagePresupuesto(int $user_id): BaseBuilder + { + $query = $this->builder() + ->select([ + "chats.id", + "chats.created_at", + "chats.updated_at", + "chats.title", + ]) + ->join("chat_users","chats.id = chat_users.chat_id","left") + ->join("presupuestos","presupuestos.id = chats.presupuesto_id",'left') + ->where("presupuesto_id is NOT NULL", NULL, FALSE) + ->groupBy("chats.id"); + if(auth()->user()->inGroup("admin") == false){ + $query->where('presupuestos.cliente_id',auth()->user()->cliente_id) + ->where("chat_department_id is NOT NULL",NULL,FALSE); + } + $query->orderBy("created_at", "DESC"); + return $query; + } + public function getQueryDatatableMessagePedido(int $user_id): BaseBuilder + { + $query = $this->builder() + ->select([ + "chats.id", + "chats.created_at", + "chats.updated_at", + "chats.title", + ]) + ->join("chat_users","chat_users.chat_id = chats.id","left") + ->join("pedidos_linea","pedidos_linea.pedido_id = chats.pedido_id",'left') + ->join("presupuestos","presupuestos.id = pedidos_linea.presupuesto_id",'left') + ->where("chats.pedido_id is NOT NULL", NULL, FALSE) + ->groupBy("chats.id"); + if(auth()->user()->inGroup("admin") == false){ + $query->where('presupuestos.cliente_id',auth()->user()->cliente_id) + ->where("chat_department_id is NOT NULL",NULL,FALSE); + } + $query->orderBy("created_at", "DESC"); + return $query; + } + public function getQueryDatatableMessageFactura(int $user_id): BaseBuilder + { + $query = $this->builder() + ->select([ + "chats.id", + "chats.created_at", + "chats.updated_at", + "chats.title", + ]) + ->join("chat_users","chat_users.chat_id = chats.id","left") + ->join("facturas","facturas.id = chats.factura_id","left") + ->where("chats.factura_id is NOT NULL", NULL, FALSE) + ->groupBy("chats.id"); + if(auth()->user()->inGroup("admin") == false){ + if(auth()->user()->inGroup("admin") == false){ + $query->where('facturas.cliente_id',auth()->user()->cliente_id) + ->where("chat_department_id is NOT NULL",NULL,FALSE); + } + } + $query->orderBy("created_at", "DESC"); + return $query; + } + public function createNewDirectChat(string $title, string $message, array $users) + { + $chatMessageModel = model(ChatMessageModel::class); + $chatNotificationModel = model(ChatNotification::class); + $chatUserModel = model(ChatUser::class); + $auth_user_id = auth()->user()->id; + $chat_id = $this->insert(["title" => $title]); + $chat_message_id = $chatMessageModel->insert([ + "chat_id" => $chat_id, + "sender_id" => $auth_user_id, + "receiver_id" => null, + "message" => $message + ]); + $chatUserModel->insert(["chat_id" => $chat_id, "user_id" => $auth_user_id]); + foreach ($users as $key => $user_id) { + $chatUserModel->insert(["chat_id" => $chat_id, "user_id" => $user_id]); + $chatNotificationModel->insert(["chat_message_id" => $chat_message_id, "user_id" => $user_id]); + } + } + + /** + * Obtain users and messages from `chat_id` + * + * @param integer $chat_id + * @return array + * [ + * "chat" => object, + * "messages" => array , + * "users" => array + * ] + */ + public function getChatDirect(int $chat_id): array + { + $auth_user = auth()->user()->id; + $chat = $this->find($chat_id); + $chatNotificationModel = model(ChatNotification::class); + $query = $this->builder()->select([ + "users.*", + ]) + ->join("chat_users", "chat_users.chat_id = chats.id") + ->join("users", "users.id = chat_users.user_id", "left") + ->where("chats.id", $chat_id); + $users = $query->get()->getResultObject(); + $query = $this->builder()->select([ + "chat_messages.*", + "users.first_name as sender_first_name", + "users.last_name as sender_last_name", + + ]) + ->join("chat_messages", "chat_messages.chat_id = chats.id", "left") + ->join("users", "chat_messages.sender_id = users.id", "left") + ->where("chats.id", $chat_id); + + $messages = $query->get()->getResultObject(); + $validatedMessages = []; + foreach ($messages as $key => $message) { + $message->viewed = $chatNotificationModel->isChatMessageViewed($message->id); + if ($auth_user == $message->sender_id) { + $message->pos = 'right'; + $validatedMessages[] = $message; + } else { + $message->pos = 'left'; + $validatedMessages[] = $message; + } + } + $data = [ + "chat" => $chat, + "users" => $users, + "messages" => $validatedMessages + ]; + return $data; + } + public function setAsViewedChatUserNotifications(int $chat_id, int $user_id) + { + $query = $this->builder() + ->select("chat_messages.id") + ->join('chat_messages', 'chat_messages.chat_id = chats.id', 'left') + ->where('chat_messages.chat_id', $chat_id) + ->get()->getResultObject(); + $chat_messages_ids = array_map(fn($q) => $q->id, $query); + + $this->db->table("chat_notifications") + ->where("user_id", $user_id) + ->whereIn("chat_message_id", $chat_messages_ids) + ->update(["viewed" => true]); + + } + public function setAsViewedChatUserMessages(int $chat_id, int $user_id) + { + $this->db->table("chat_messages") + ->where('chat_id', $chat_id) + ->where('sender_id !=', $user_id) + ->update(["viewed" => true]); + + } + public function setAsUnviewedChatUserNotifications(int $chat_id, int $user_id) + { + $query = $this->builder() + ->select("chat_messages.id") + ->join('chat_messages', 'chat_messages.chat_id = chats.id', 'left') + ->where('chat_messages.chat_id', $chat_id) + ->get()->getResultObject(); + $chat_messages_ids = array_map(fn($q) => $q->id, $query); + + $this->db->table("chat_notifications") + ->where("user_id", $user_id) + ->whereIn("chat_message_id", $chat_messages_ids) + ->update(["viewed" => false]); + } + + public function setAsUnviewedChatUserMessages(int $chat_id, int $user_id) + { + $this->db->table("chat_messages") + ->where('chat_id', $chat_id) + ->where('sender_id !=', $user_id) + ->update(["viewed" => false]); + + } + public function createNotificationsToNewChatUser($chat_id,$user_id) + { + $query = $this->builder() + ->select("chat_messages.id") + ->join('chat_messages', 'chat_messages.chat_id = chats.id', 'left') + ->where('chat_messages.chat_id', $chat_id) + ->get()->getResultObject(); + $chat_notifications = array_map(fn($q) => ["chat_message_id" => $q->id,"user_id" => $user_id], $query); + $chatNotificationModel = model(ChatNotification::class); + $chatNotificationModel->insertBatch($chat_notifications); + + } } diff --git a/ci4/app/Models/ChatNotification.php b/ci4/app/Models/ChatNotification.php index fdbc6e2b..007f26c5 100644 --- a/ci4/app/Models/ChatNotification.php +++ b/ci4/app/Models/ChatNotification.php @@ -47,4 +47,16 @@ class ChatNotification extends Model protected $afterFind = []; protected $beforeDelete = []; protected $afterDelete = []; + + public function isChatMessageViewed(int $chat_message_id) : bool + { + $status = false; + $count = $this->where("chat_message_id",$chat_message_id)->where("viewed",false)->countAllResults(); + if($count>0){ + $status = false; + }else{ + $status = true; + } + return $status; + } } diff --git a/ci4/app/Models/ChatUser.php b/ci4/app/Models/ChatUser.php index 9e92163c..f51f989f 100644 --- a/ci4/app/Models/ChatUser.php +++ b/ci4/app/Models/ChatUser.php @@ -10,7 +10,7 @@ class ChatUser extends Model protected $primaryKey = 'id'; protected $useAutoIncrement = true; protected $returnType = 'array'; - protected $useSoftDeletes = false; + protected $useSoftDeletes = true; protected $protectFields = true; protected $allowedFields = [ "user_id", @@ -24,7 +24,7 @@ class ChatUser extends Model protected array $castHandlers = []; // Dates - protected $useTimestamps = false; + protected $useTimestamps = true; protected $dateFormat = 'datetime'; protected $createdField = 'created_at'; protected $updatedField = 'updated_at'; @@ -46,4 +46,12 @@ class ChatUser extends Model protected $afterFind = []; protected $beforeDelete = []; protected $afterDelete = []; + public function getChatUserArrayId(int $chat_id) : array + { + $queryResult = $this->builder() + ->select(['chat_users.user_id']) + ->where("chat_users.chat_id",$chat_id) + ->get()->getResultObject(); + return array_map(fn($q) => $q->user_id,$queryResult); + } } diff --git a/ci4/app/Models/Configuracion/PapelGenericoModel.php b/ci4/app/Models/Configuracion/PapelGenericoModel.php index 49f4a7a1..63f0403e 100755 --- a/ci4/app/Models/Configuracion/PapelGenericoModel.php +++ b/ci4/app/Models/Configuracion/PapelGenericoModel.php @@ -19,9 +19,10 @@ class PapelGenericoModel extends \App\Models\BaseModel 1 => "t1.code", 2 => "t1.code_ot", 3 => "t1.show_in_client", + 4 => "t1.show_in_client_special", ]; - protected $allowedFields = ["nombre", "code", "code_ot", "show_in_client", "deleted_at", "is_deleted"]; + protected $allowedFields = ["nombre", "code", "code_ot", "show_in_client", "show_in_client_special", "deleted_at", "is_deleted"]; protected $returnType = "App\Entities\Configuracion\PapelGenerico"; protected $useTimestamps = true; @@ -62,7 +63,8 @@ class PapelGenericoModel extends \App\Models\BaseModel ]; - public function getIdFromCode(string $code=""){ + public function getIdFromCode(string $code = "") + { $builder = $this->db ->table($this->table . " t1") ->select( @@ -77,7 +79,8 @@ class PapelGenericoModel extends \App\Models\BaseModel } - public function getCodeFromId($id=0){ + public function getCodeFromId($id = 0) + { $builder = $this->db ->table($this->table . " t1") ->select( @@ -104,23 +107,24 @@ class PapelGenericoModel extends \App\Models\BaseModel $builder = $this->db ->table($this->table . " t1") ->select( - "t1.id AS id, t1.nombre AS nombre, t1.code AS code, t1.code_ot AS code_ot, t1.show_in_client AS show_in_client" + "t1.id AS id, t1.nombre AS nombre, t1.code AS code, t1.code_ot AS code_ot, + t1.show_in_client AS show_in_client, t1.show_in_client_special AS show_in_client_special" ) ->where("is_deleted", 0); return empty($search) ? $builder : $builder - ->groupStart() - ->like("t1.id", $search) - ->orLike("t1.nombre", $search) - ->orLike("t1.code", $search) - ->orLike("t1.code_ot", $search) - ->orLike("t1.id", $search) - ->orLike("t1.nombre", $search) - ->orLike("t1.code", $search) - ->orLike("t1.code_ot", $search) - ->groupEnd(); + ->groupStart() + ->like("t1.id", $search) + ->orLike("t1.nombre", $search) + ->orLike("t1.code", $search) + ->orLike("t1.code_ot", $search) + ->orLike("t1.id", $search) + ->orLike("t1.nombre", $search) + ->orLike("t1.code", $search) + ->orLike("t1.code_ot", $search) + ->groupEnd(); } @@ -128,9 +132,9 @@ class PapelGenericoModel extends \App\Models\BaseModel { /* 1.-> Tipo impresion - 2.-> Maquina - 3.-> Papeles impresion asociados a esa maquina - 4.-> papeles genericos que aparecen en esos papeles impresion + 2.-> Maquina + 3.-> Papeles impresion asociados a esa maquina + 4.-> papeles genericos que aparecen en esos papeles impresion */ $builder = $this->db ->table($this->table . " t1") @@ -153,48 +157,48 @@ class PapelGenericoModel extends \App\Models\BaseModel ->where("t5.is_deleted", 0) ->where("t5.tipo", $tipo); - if($is_cubierta==true){ - - $builder->where("t2.cubierta", 1); - $builder->where("t5.uso", 'cubierta'); - } - - if($is_sobrecubierta==true){ - $builder->where("t2.sobrecubierta", 1); - $builder->where("t5.uso", 'sobrecubierta'); - } + if ($is_cubierta == true) { - if($is_cubierta==false && $is_sobrecubierta==false){ - $builder->where("t5.uso", 'interior'); - } + $builder->where("t2.cubierta", 1); + $builder->where("t5.uso", 'cubierta'); + } - if($is_guardas==true){ - $builder->where("t2.guardas", 1); - } + if ($is_sobrecubierta == true) { + $builder->where("t2.sobrecubierta", 1); + $builder->where("t5.uso", 'sobrecubierta'); + } - if($rotativa==true){ - $builder->where("t2.rotativa", 1); - } + if ($is_cubierta == false && $is_sobrecubierta == false) { + $builder->where("t5.uso", 'interior'); + } - if($mostrar_cliente!=null){ - $builder->where("t1.show_in_client", $mostrar_cliente); - } + if ($is_guardas == true) { + $builder->where("t2.guardas", 1); + } + + if ($rotativa == true) { + $builder->where("t2.rotativa", 1); + } + + if ($mostrar_cliente != null) { + $builder->where("t1.show_in_client", $mostrar_cliente); + } $data = $builder->orderBy("t1.nombre", "asc")->get()->getResultObject(); //var_dump($this->db->getLastQuery()); return $data; } - public function getGramajeComparador(string $papel_generico_nombre="", $uso="", $ejemplares=0) + public function getGramajeComparador(string $papel_generico_nombre = "", $uso = "", $ejemplares = 0) { - if($uso == 'cubierta' || $uso == 'sobrecubierta') + if ($uso == 'cubierta' || $uso == 'sobrecubierta') $tipo = 'colorhq'; else - $tipo=$uso; // color y colorhq valen para los dos - if($uso == 'bn') - $tipo="negro"; - if($uso == 'bnhq') - $tipo="negrohq"; + $tipo = $uso; // color y colorhq valen para los dos + if ($uso == 'bn') + $tipo = "negro"; + if ($uso == 'bnhq') + $tipo = "negrohq"; $builder = $this->db ->table($this->table . " t1") @@ -205,7 +209,7 @@ class PapelGenericoModel extends \App\Models\BaseModel ->join("lg_maquina_papel_impresion t3", "t3.papel_impresion_id = t2.id", "left") ->join("lg_maquinas t4", "t3.maquina_id = t4.id", "left") ->join("lg_maquinas_tarifas_impresion t5", "t5.maquina_id = t4.id", "left") - + ->where("t1.is_deleted", 0) ->where("t2.is_deleted", 0) ->where("t2.isActivo", 1) @@ -214,44 +218,43 @@ class PapelGenericoModel extends \App\Models\BaseModel ->where("t4.tipo", "impresion") ->where("t5.tipo", $tipo) ->where("t1.nombre", $papel_generico_nombre); - - $uso_tarifa = 'interior'; - if($uso == 'bn' || $uso == 'bnhq') - $builder->where("t2.bn", 1); - else if ($uso == 'color' || $uso == 'colorhq') - $builder->where("t2.color", 1); - else if ($uso == 'cubierta'){ - $uso_tarifa = 'cubierta'; - $builder->where("t2.cubierta", 1); - } - else if ($uso == 'sobrecubierta'){ - $uso_tarifa = 'sobrecubierta'; - $builder->where("t2.sobrecubierta", 1); - } + $uso_tarifa = 'interior'; - $builder->where("t5.uso", $uso_tarifa); + if ($uso == 'bn' || $uso == 'bnhq') + $builder->where("t2.bn", 1); + else if ($uso == 'color' || $uso == 'colorhq') + $builder->where("t2.color", 1); + else if ($uso == 'cubierta') { + $uso_tarifa = 'cubierta'; + $builder->where("t2.cubierta", 1); + } else if ($uso == 'sobrecubierta') { + $uso_tarifa = 'sobrecubierta'; + $builder->where("t2.sobrecubierta", 1); + } - $builder->where("t4.min <=", $ejemplares); - $builder->where("t4.max >=", $ejemplares); - - $values = $builder->orderBy("t2.gramaje", "asc")->get()->getResultObject(); - $id = 1; - foreach ($values as $value){ - $value->id = $id; - $id++; - } - $values_array = array_map( function( $value ) { - return $value->text; - }, $values ); - $unique_values = array_unique($values_array); - return array_values(array_intersect_key($values, $unique_values)); + $builder->where("t5.uso", $uso_tarifa); + + $builder->where("t4.min <=", $ejemplares); + $builder->where("t4.max >=", $ejemplares); + + $values = $builder->orderBy("t2.gramaje", "asc")->get()->getResultObject(); + $id = 1; + foreach ($values as $value) { + $value->id = $id; + $id++; + } + $values_array = array_map(function ($value) { + return $value->text; + }, $values); + $unique_values = array_unique($values_array); + return array_values(array_intersect_key($values, $unique_values)); } //tipo: negro, negrohq, color, colorhq //uso: interior, rotativa, cubierta, sobrecubierta - public function getGramajeLineasPresupuesto($papel_generico_id=0, $tipo="", $uso="") + public function getGramajeLineasPresupuesto($papel_generico_id = 0, $tipo = "", $uso = "") { $builder = $this->db ->table($this->table . " t1") @@ -262,7 +265,7 @@ class PapelGenericoModel extends \App\Models\BaseModel ->join("lg_maquina_papel_impresion t3", "t3.papel_impresion_id = t2.id", "left") ->join("lg_maquinas t4", "t3.maquina_id = t4.id", "left") ->join("lg_maquinas_tarifas_impresion t5", "t5.maquina_id = t4.id", "left") - + ->where("t1.is_deleted", 0) ->where("t2.is_deleted", 0) ->where("t2.isActivo", 1) @@ -272,42 +275,142 @@ class PapelGenericoModel extends \App\Models\BaseModel ->where("t5.tipo", $tipo) ->where("t1.id", $papel_generico_id); - $uso_tarifa = 'interior'; + $uso_tarifa = 'interior'; - if ($uso == 'cubierta'){ - $uso_tarifa = 'cubierta'; - $builder->where("t2.cubierta", 1); - } - else if ($uso == 'sobrecubierta'){ - $uso_tarifa = 'sobrecubierta'; - $builder->where("t2.sobrecubierta", 1); - } - else{ - if($tipo == 'negro' || $tipo == 'negrohq') - $builder->where("t2.bn", 1); - else if ($tipo == 'color' || $tipo == 'colorhq') - $builder->where("t2.color", 1); - } - - if($uso=='rotativa') - $builder->where("t2.rotativa", 1); - else - $builder->where("t2.rotativa", 0); + if ($uso == 'cubierta') { + $uso_tarifa = 'cubierta'; + $builder->where("t2.cubierta", 1); + } else if ($uso == 'sobrecubierta') { + $uso_tarifa = 'sobrecubierta'; + $builder->where("t2.sobrecubierta", 1); + } else { + if ($tipo == 'negro' || $tipo == 'negrohq') + $builder->where("t2.bn", 1); + else if ($tipo == 'color' || $tipo == 'colorhq') + $builder->where("t2.color", 1); + } - $builder->where("t5.uso", $uso_tarifa); - - - $values = $builder->orderBy("t2.gramaje", "asc")->get()->getResultObject(); - $id = 1; - foreach ($values as $value){ - $value->id = $id; - $id++; - } - $values_array = array_map( function( $value ) { - return $value->text; - }, $values ); - $unique_values = array_unique($values_array); - return array_values(array_intersect_key($values, $unique_values)); + if ($uso == 'rotativa') + $builder->where("t2.rotativa", 1); + else + $builder->where("t2.rotativa", 0); + + $builder->where("t5.uso", $uso_tarifa); + + + $values = $builder->orderBy("t2.gramaje", "asc")->get()->getResultObject(); + $id = 1; + foreach ($values as $value) { + $value->id = $id; + $id++; + } + $values_array = array_map(function ($value) { + return $value->text; + }, $values); + $unique_values = array_unique($values_array); + return array_values(array_intersect_key($values, $unique_values)); } + + + public function getPapelCliente($tipo, $is_cubierta = false, $selected_papel_id = null, $tapa_dura = null, $papel_especial = false) + { + /* + 1.-> Tipo impresion + 2.-> Maquina + 3.-> Papeles impresion asociados a esa maquina + 4.-> papeles genericos que aparecen en esos papeles impresion + */ + + if ($selected_papel_id != null) { + $builder = $this->db + ->table($this->table . " t1") + ->select( + "t2.gramaje as gramaje", + // for debug, t2.nombre AS nombre_papel_impresion, t4.nombre AS maquina_nombre, t5.uso AS tarifa_uso, t5.tipo AS tarifa_tipo" + ) + ->join("lg_papel_impresion t2", "t2.papel_generico_id = t1.id", "inner") + ->join("lg_maquina_papel_impresion t3", "t3.papel_impresion_id = t2.id", "inner") + ->join("lg_maquinas t4", "t3.maquina_id = t4.id", "inner") + ->join("lg_maquinas_tarifas_impresion t5", "t5.maquina_id = t4.id", "inner") + + ->where("t1.id", $selected_papel_id) + ->where("t1.is_deleted", 0) + ->where("t1.show_in_client", 1) + ->where("t2.is_deleted", 0) + ->where("t2.isActivo", 1) + ->where("t2.use_in_client", 1) + ->where("t3.active", 1) + ->where("t4.is_deleted", 0) + ->where("t4.tipo", "impresion") + ->where("t5.is_deleted", 0) + ->where("t5.tipo", $tipo) + ->distinct('t2.gramaje'); + } else { + $builder = $this->db + ->table($this->table . " t1") + ->select( + "t1.id as id, t1.nombre AS nombre", + // for debug, t2.nombre AS nombre_papel_impresion, t4.nombre AS maquina_nombre, t5.uso AS tarifa_uso, t5.tipo AS tarifa_tipo" + ) + ->join("lg_papel_impresion t2", "t2.papel_generico_id = t1.id", "inner") + ->join("lg_maquina_papel_impresion t3", "t3.papel_impresion_id = t2.id", "inner") + ->join("lg_maquinas t4", "t3.maquina_id = t4.id", "inner") + ->join("lg_maquinas_tarifas_impresion t5", "t5.maquina_id = t4.id", "inner") + + ->where("t1.is_deleted", 0) + ->where("t1.show_in_client", 1) + ->where("t2.is_deleted", 0) + ->where("t2.isActivo", 1) + ->where("t2.use_in_client", 1) + ->where("t3.active", 1) + ->where("t4.is_deleted", 0) + ->where("t4.tipo", "impresion") + ->where("t5.is_deleted", 0) + ->where("t5.tipo", $tipo) + ->distinct('t1.id'); + } + // Validación adicional para asegurar que t1.id esté presente en las combinaciones con t3.active = 1 + $builder->whereIn("t1.id", function ($subQuery) { + $subQuery->select("t1_inner.id") + ->from("lg_papel_generico t1_inner") + ->join("lg_papel_impresion t2_inner", "t2_inner.papel_generico_id = t1_inner.id", "inner") + ->join("lg_maquina_papel_impresion t3_inner", "t3_inner.papel_impresion_id = t2_inner.id", "inner") + ->where("t3_inner.active", 1); + }); + + if ($is_cubierta == true) { + $builder->where("t2.cubierta", 1); + $builder->where("t5.uso", 'cubierta'); + if($tapa_dura == true){ + $builder->where("t2.use_for_tapa_dura", 1); + } + } else { + $builder->where("t2.interior", 1); + $builder->where("t5.uso", 'interior'); + if ($tipo == 'negro' || $tipo == 'negrohq') + $builder->where("t2.bn", 1); + else if ($tipo == 'color' || $tipo == 'colorhq') + $builder->where("t2.color", 1); + } + + if ($papel_especial == true) { + $builder->where("t1.show_in_client_special", 1); + } + else{ + $builder->where("t1.show_in_client_special", 0); + } + + if ($tipo == 'colorhq' || $tipo == 'negrohq') { + $builder->where("t2.rotativa", 0); + } + + + if ($selected_papel_id != null) + $data = $builder->orderBy("t2.gramaje", "asc")->get()->getResultObject(); + else + $data = $builder->orderBy("t1.nombre", "asc")->get()->getResultObject(); + //$query = $this->db->getLastQuery(); + return $data; + } } diff --git a/ci4/app/Models/Configuracion/PapelImpresionModel.php b/ci4/app/Models/Configuracion/PapelImpresionModel.php index eac4807c..de9473b9 100755 --- a/ci4/app/Models/Configuracion/PapelImpresionModel.php +++ b/ci4/app/Models/Configuracion/PapelImpresionModel.php @@ -16,14 +16,17 @@ class PapelImpresionModel extends \App\Models\BaseModel 0 => "t1.nombre", 1 => "t2.nombre", 2 => "t1.gramaje", - 3 => "t1.bn", - 4 => "t1.color", - 5 => "t1.cubierta", - 6 => "t1.sobrecubierta", - 7 => "t1.guardas", - 8 => "t1.inkjet", - 9 => "t1.rotativa", - 10 => "t1.isActivo" + 3 => "t1.interior", + 4 => "t1.bn", + 5 => "t1.color", + 6 => "t1.cubierta", + 7 => "t1.use_for_tapa_dura", + 8 => "t1.sobrecubierta", + 9 => "t1.guardas", + 10 => "t1.inkjet", + 11 => "t1.rotativa", + 12 => "t1.isActivo", + 13 => "t1.use_in_client", ]; @@ -36,6 +39,7 @@ class PapelImpresionModel extends \App\Models\BaseModel "espesor", "gramaje", "precio_tonelada", + "interior", "bn", "color", "cubierta", @@ -44,6 +48,8 @@ class PapelImpresionModel extends \App\Models\BaseModel "inkjet", "rotativa", "isActivo", + "use_in_client", + "use_for_tapa_dura", "deleted_at", "is_deleted", "user_updated_id", @@ -141,23 +147,25 @@ class PapelImpresionModel extends \App\Models\BaseModel * * @return \CodeIgniter\Database\BaseBuilder */ - public function getResource(string $search = "", $generico_id=-1) + public function getResource(string $search = "", $generico_id = -1) { $builder = $this->db ->table($this->table . " t1") ->select( "t1.id AS id, t1.nombre AS nombre, t1.defecto AS defecto, t1.referencia AS referencia, t1.mano AS mano, - t1.espesor AS espesor, t1.gramaje AS gramaje, t1.precio_tonelada AS precio_tonelada, - t1.bn AS bn, t1.color AS color, t1.cubierta AS cubierta, t1.sobrecubierta AS sobrecubierta, t1.guardas AS guardas, + t1.espesor AS espesor, t1.gramaje AS gramaje, t1.interior AS interior, t1.precio_tonelada AS precio_tonelada, + t1.bn AS bn, t1.color AS color, t1.cubierta AS cubierta, t1.use_for_tapa_dura AS use_for_tapa_dura, + t1.sobrecubierta AS sobrecubierta, t1.guardas AS guardas, t1.inkjet AS inkjet, t1.rotativa AS rotativa, - t1.isActivo AS isActivo, t2.nombre AS papel_generico_id" + t1.isActivo AS isActivo, t2.nombre AS papel_generico_id, + t1.use_in_client AS use_in_client" ); - + $builder->join("lg_papel_generico t2", "t1.papel_generico_id = t2.id", "left"); $builder->where("t1.is_deleted", 0); $builder->where("t1.isActivo", 1); - if($generico_id>0){ - $builder->where("t1.papel_generico_id", $generico_id); + if ($generico_id > 0) { + $builder->where("t1.papel_generico_id", $generico_id); } return empty($search) @@ -177,29 +185,29 @@ class PapelImpresionModel extends \App\Models\BaseModel $builder = $this->db ->table($this->table . " t1") ->select( - "'".$maquina_id."'". " as maquina_id, t1.id AS papel_impresion_id, '0' as active" + "'" . $maquina_id . "'" . " as maquina_id, t1.id AS papel_impresion_id, '0' as active" ); - + $builder->where("t1.is_deleted", 0); $builder->where("t1.isActivo", 1); $isFirst = true; $where_str = ""; //Si hay tarifas... - if (!empty($tarifas)){ - foreach ($tarifas as $tarifa){ + if (!empty($tarifas)) { + foreach ($tarifas as $tarifa) { if (!$isFirst) $where_str .= ' OR '; - else{ + else { $isFirst = false; } if ($tarifa->uso == 'cubierta') $where_str .= "`t1`.`cubierta`=1"; else if ($tarifa->uso == 'sobrecubierta') $where_str .= "`t1`.`sobrecubierta`=1"; - else{ + else { if ($tarifa->tipo == 'negro' || $tarifa->tipo == 'negrohq') - $where_str .= "`t1`.`bn`=1 "; + $where_str .= "`t1`.`bn`=1 "; else $where_str .= "`t1`.`color`=1 "; } @@ -207,11 +215,11 @@ class PapelImpresionModel extends \App\Models\BaseModel $builder->where($where_str); } // si no hay tarifas no hay que devolver nada - else{ + else { // Se pone una condicion que no se puede dar $builder->where("t1.bn", 2); } - + return $builder; } @@ -224,43 +232,45 @@ class PapelImpresionModel extends \App\Models\BaseModel * * @return [type] */ - public function getIdPapelesImpresionForPresupuesto($papel_generico_id = null, $gramaje = null, $options=[]){ + public function getIdPapelesImpresionForPresupuesto($papel_generico_id = null, $gramaje = null, $options = []) + { $bn = array_key_exists('bn', $options) ? $options['bn'] : null; - $color = array_key_exists('color', $options)? $options['color'] : null; - $cubierta = array_key_exists('cubierta', $options)? $options['cubierta'] : null; - $sobrecubierta = array_key_exists('sobrecubierta', $options)? $options['sobrecubierta'] : null; - $guardas = array_key_exists('guardas', $options)? $options['guardas'] : null; - $rotativa = array_key_exists('rotativa', $options)? $options['rotativa'] : null; + $color = array_key_exists('color', $options) ? $options['color'] : null; + $cubierta = array_key_exists('cubierta', $options) ? $options['cubierta'] : null; + $sobrecubierta = array_key_exists('sobrecubierta', $options) ? $options['sobrecubierta'] : null; + $guardas = array_key_exists('guardas', $options) ? $options['guardas'] : null; + $rotativa = array_key_exists('rotativa', $options) ? $options['rotativa'] : null; $builder = $this->db ->table($this->table . " t1") ->distinct("t1.id") ->select( "t1.id AS id, t1.nombre AS nombre, t1.papel_generico_id AS papel_generico_id, - t1.gramaje as gramaje, t1.espesor AS espesor, t1.precio_tonelada AS precio_tonelada, t1.rotativa AS rotativa"); - + t1.gramaje as gramaje, t1.espesor AS espesor, t1.precio_tonelada AS precio_tonelada, t1.rotativa AS rotativa" + ); + $builder->where("t1.is_deleted", 0); $builder->where("t1.isActivo", 1); $builder->where("t1.papel_generico_id", $papel_generico_id); $builder->where("t1.gramaje", $gramaje); - - if(!is_null($bn)){ + + if (!is_null($bn)) { $builder->where("t1.bn", $bn); } - if(!is_null($color)){ + if (!is_null($color)) { $builder->where("t1.color", $color); } - if(!is_null($cubierta)){ + if (!is_null($cubierta)) { $builder->where("t1.cubierta", $cubierta); } - if(!is_null($sobrecubierta)){ + if (!is_null($sobrecubierta)) { $builder->where("t1.sobrecubierta", $sobrecubierta); } - if(!is_null($guardas)){ + if (!is_null($guardas)) { $builder->where("t1.guardas", $guardas); } - if(!is_null($rotativa)){ + if (!is_null($rotativa)) { $builder->where("t1.rotativa", $rotativa); } @@ -269,7 +279,8 @@ class PapelImpresionModel extends \App\Models\BaseModel //tipo: negro, negrohq, color, colorhq //uso: interior, rotativa, cubierta, sobrecubierta - public function getPapelesImpresionForMenu($papel_generico = null, $gramaje = null, $tipo = null, $uso=""){ + public function getPapelesImpresionForMenu($papel_generico = null, $gramaje = null, $tipo = null, $uso = "") + { $builder = $this->db ->table($this->table . " t1") ->distinct("t1.id") @@ -278,8 +289,9 @@ class PapelImpresionModel extends \App\Models\BaseModel ->join("lg_maquinas t4", "t3.maquina_id = t4.id", "left") ->join("lg_maquinas_tarifas_impresion t5", "t4.id = t5.maquina_id", "left") ->select( - "t1.id AS id, t1.nombre AS text"); - + "t1.id AS id, t1.nombre AS text" + ); + $builder->where("t1.is_deleted", 0); $builder->where("t1.isActivo", 1); $builder->where("t2.is_deleted", 0); @@ -288,7 +300,7 @@ class PapelImpresionModel extends \App\Models\BaseModel $builder->where("t4.tipo", 'impresion'); $builder->where("t5.is_deleted", 0); $builder->where("t5.tipo", $tipo); - + $builder->where("t2.id", $papel_generico); $builder->where("t1.gramaje", $gramaje); @@ -298,32 +310,35 @@ class PapelImpresionModel extends \App\Models\BaseModel $builder->where("t1.sobrecubierta", 1); else if ($uso == 'guardas') $builder->where("t1.guardas", 1); - else{ - if($tipo == 'negro' || $tipo == 'negrohq') + else { + if ($tipo == 'negro' || $tipo == 'negrohq') $builder->where("t1.bn", 1); else if ($tipo == 'color' || $tipo == 'colorhq') $builder->where("t1.color", 1); } - if($uso=='rotativa') + if ($uso == 'rotativa') $builder->where("t1.rotativa", 1); else $builder->where("t1.rotativa", 0); - + return $builder->orderBy("t1.id", "asc")->get()->getResultObject(); } - public function getNombre($id){ + public function getNombre($id) + { $builder = $this->db ->table($this->table . " t1") ->select( - "t1.nombre AS text"); - + "t1.nombre AS text" + ); + $builder->where("t1.id", $id); return $builder->orderBy("t1.id", "asc")->get()->getResultObject(); } - public function getPapelGenericoCode($papel_id = 0){ + public function getPapelGenericoCode($papel_id = 0) + { $builder = $this->db ->table($this->table . " t1") ->select("t2.code AS code") @@ -332,12 +347,13 @@ class PapelImpresionModel extends \App\Models\BaseModel ->where("t1.is_deleted", 0) ->where("t1.isActivo", 1) ->where("t2.is_deleted", 0); - + $result = $builder->get()->getResultObject(); - if(count($result) > 0){ + if (count($result) > 0) { return $result[0]->code; - } - else + } else return ""; } + + } diff --git a/ci4/app/Models/Presupuestos/PresupuestoEncuadernacionesModel.php b/ci4/app/Models/Presupuestos/PresupuestoEncuadernacionesModel.php index 956bbe77..7ce6c1c4 100755 --- a/ci4/app/Models/Presupuestos/PresupuestoEncuadernacionesModel.php +++ b/ci4/app/Models/Presupuestos/PresupuestoEncuadernacionesModel.php @@ -73,7 +73,7 @@ class PresupuestoEncuadernacionesModel extends \App\Models\BaseModel $result_array = []; foreach($tarifa_value as $tarifa_proveedor){ $precio_total = floatval(1.0* $tarifa_proveedor->precio_hora* $tiempo) * (1+$tarifa_value[0]->margen/100.0); - if (!$POD){ + if ($tirada>=$POD){ $precio_total += floatval($tarifa_proveedor->tarifa_importe_fijo); } @@ -248,7 +248,7 @@ class PresupuestoEncuadernacionesModel extends \App\Models\BaseModel return []; } - public function getPrecioTarifaHoras($tarifa_encuadernacion_id, $paginas, $tirada, $proveedor_id, $POD, $paginas_cuadernillo = null){ + public function getPrecioTarifaHoras($tarifa_encuadernacion_id, $paginas, $tirada, $proveedor_id, $POD, $paginas_cuadernillo = 32){ $modelTarifa = model('App\Models\Tarifas\TarifaEncuadernacionModel'); @@ -265,7 +265,7 @@ class PresupuestoEncuadernacionesModel extends \App\Models\BaseModel $ret_array = []; foreach($tarifa_value as $tarifa_proveedor){ $precio_total = floatval(1.0* $tarifa_proveedor->precio_hora* $tiempo) * (1+$tarifa_value[0]->margen/100.0); - if (!$POD){ + if ($tirada>=$POD){ $precio_total += floatval($tarifa_proveedor->tarifa_importe_fijo); } diff --git a/ci4/app/Models/Presupuestos/PresupuestoModel.php b/ci4/app/Models/Presupuestos/PresupuestoModel.php index f242d25e..974c29fa 100755 --- a/ci4/app/Models/Presupuestos/PresupuestoModel.php +++ b/ci4/app/Models/Presupuestos/PresupuestoModel.php @@ -404,11 +404,13 @@ class PresupuestoModel extends \App\Models\BaseModel 'cliente_id' => $data['clienteId'], 'tipo_impresion_id' => $data['tipo_impresion_id'], 'pais_id' => 1, - 'retractilado' => in_array("RETR", $data['cubierta']['acabadosCubierta']) ? 1 : 0, - 'retractilado5' => in_array(5, $data['servicios']) ? 1 : 0, + 'retractilado' => $data['retractilado'] ? 1 : 0, + 'retractilado5' => $data['retractilado5'] ? 1 : 0, 'guardas' => in_array(62, $data['servicios']) ? 1 : 0, 'faja_color' => in_array(16, $data['servicios']) ? 1 : 0, - 'ferro' => in_array(24, $data['servicios']) ? 1 : 0, + 'ferro' => $data['ferro'] ? 1 : 0, + 'ferro_digital' => $data['ferro_digital'] ? 1 : 0, + 'marcapaginas' => $data['marcapaginas'] ? 1 : 0, 'prototipo' => $data['prototipo'] ? 1 : 0, 'papel_formato_id' => is_null($papel_formato_id) ? 0 : $papel_formato_id->id, 'papel_formato_personalizado' => !$papel_formato_id ? 1 : 0, @@ -424,7 +426,7 @@ class PresupuestoModel extends \App\Models\BaseModel 'solapas' => $data['cubierta']['solapasCubierta'] == 0 ? 0 : 1, 'lomo_redondo' => $data['cubierta']['lomoRedondo'] == 0 ? 0 : 1, 'cabezada' => $data['cubierta']['cabezada'] == 0 ? 0 : 1, - 'solapas_ancho' => $data['cubierta']['solapasCubierta'] == 0 ? $data['cubierta']['solapasCubierta'] : 0, + 'solapas_ancho' => $data['cubierta']['solapasCubierta'] > 0 ? $data['cubierta']['solapasCubierta'] : 0, 'solapas_sobrecubierta' => !$data['sobrecubierta'] ? 0 : 1, 'solapas_ancho_sobrecubierta' => !$data['sobrecubierta'] ? 0 : $data['sobrecubierta']['solapas'], 'cosido' => $is_cosido, diff --git a/ci4/app/Models/Presupuestos/TipoPresupuestoServiciosDefectoModel.php b/ci4/app/Models/Presupuestos/TipoPresupuestoServiciosDefectoModel.php index 1cc1f9e9..8979b058 100755 --- a/ci4/app/Models/Presupuestos/TipoPresupuestoServiciosDefectoModel.php +++ b/ci4/app/Models/Presupuestos/TipoPresupuestoServiciosDefectoModel.php @@ -79,6 +79,7 @@ class TipoPresupuestoServiciosDefectoModel extends \App\Models\BaseModel $where = "(t1.solapas IS NULL OR t1.solapas='" . $solapas . "')"; $builder->where($where); + $builder->where("t1.is_deleted", 0); $builder->where("t2.is_deleted", 0); $builder->select("t1.tarifa_id AS tarifa_id, t2.nombre AS tarifa_nombre"); diff --git a/ci4/app/Models/UserModel.php b/ci4/app/Models/UserModel.php index ccc79a9c..3c2fe960 100644 --- a/ci4/app/Models/UserModel.php +++ b/ci4/app/Models/UserModel.php @@ -30,7 +30,6 @@ class UserModel extends ShieldUserModel protected $updatedField = 'updated_at'; protected $deletedField = 'deleted_at'; - protected $validationRules = [ "first_name" => "required|trim|max_length[150]", "last_name" => "required|trim|max_length[150]", @@ -66,7 +65,7 @@ class UserModel extends ShieldUserModel $builder = $this->db ->table("users" . " t1") ->select( - "t1.id AS id, CONCAT(t1.first_name, ' ', t1.last_name) AS text" + "t1.id AS id, CONCAT(t1.first_name, ' ', t1.last_name) AS name" ); $builder->where('t1.deleted_at', null); @@ -77,5 +76,19 @@ class UserModel extends ShieldUserModel } + // Método para comprobar si el email ya está registrado + public function isEmailUnique($email) + { + $builder = $this->db + ->table("auth_identities t1") // La tabla correcta + ->select("t1.secret AS email") + ->where('secret', $email); + + // Obtener resultados + $result = $builder->get()->getRow(); + + // Devuelve true si no se encuentra el correo (es único), false en caso contrario + return $result === null; + } } diff --git a/ci4/app/Models/Usuarios/UserModel.php b/ci4/app/Models/Usuarios/UserModel.php index 56b34f77..a4748d14 100755 --- a/ci4/app/Models/Usuarios/UserModel.php +++ b/ci4/app/Models/Usuarios/UserModel.php @@ -20,6 +20,7 @@ class UserModel extends \App\Models\BaseModel protected $allowedFields = [ "username", + "email", "first_name", "last_name", "client_id", diff --git a/ci4/app/Services/MessageService.php b/ci4/app/Services/MessageService.php new file mode 100644 index 00000000..8202257d --- /dev/null +++ b/ci4/app/Services/MessageService.php @@ -0,0 +1,14 @@ +paginas == $data['paginas_color']){ - if(count($plana[1]) > 2) - $total_plana += floatval($plana[1]['total_impresion']); - else - return -1; - } - - elseif (count($plana) > 0) { - if (count($plana[0]) > 2 && count($plana[1]) > 2) { - $total_plana = 0.0; - foreach ($plana as $linea) { - if (count($linea) > 0) - $total_plana += floatval($linea['total_impresion']); + if (count($plana) > 0) { + if ($data['datosPedido']->paginas == $data['paginas_color']) { + if (count($plana[1]) > 2) + $total_plana += floatval($plana[1]['total_impresion']); + else + return -1; + } else { + if (count($plana[0]) > 2 && count($plana[1]) > 2) { + $total_plana = 0.0; + foreach ($plana as $linea) { + if (count($linea) > 0) + $total_plana += floatval($linea['total_impresion']); + } } } } @@ -416,6 +416,17 @@ class PresupuestoClienteService extends BaseService return $values; } + public static function getServiciosManipuladoDefault($data) + { + + $tirada = $data['tirada'] ?? -1; + $anchoDesarrollo = $data['anchoDesarrollo'] ?? -1; + + /*$model = model('App\Models\Presupuestos\PresupuestoEncuadernacionesModel'); + $values = $model->initPresupuesto($tipo_impresion_id, $solapas, $tirada, $paginas, $ancho, $alto, $POD, $paginasCuadernillo);*/ + //return $values; + } + public static function getServiciosManipulado($data) { diff --git a/ci4/app/Services/PresupuestoService.php b/ci4/app/Services/PresupuestoService.php index a6c1074b..1aba14fd 100755 --- a/ci4/app/Services/PresupuestoService.php +++ b/ci4/app/Services/PresupuestoService.php @@ -1479,7 +1479,7 @@ class PresupuestoService extends BaseService // con el mismo proveedor else { if ($tarifaModel->isTarifaPorHoras($servicio->tarifa_encuadernado_id)) { - $paginas_cuadernillo = $servicio->paginas_por_cuadernillo ?? null; + $paginas_cuadernillo = $servicio->paginas_por_cuadernillo ?? 32; $nueva_tarifa = $model->getPrecioTarifaHoras( $servicio->tarifa_encuadernado_id, $input_data['paginas'], @@ -1815,6 +1815,12 @@ class PresupuestoService extends BaseService } } + if ($uso == 'cubierta' || $uso == 'sobrecubierta') { + + $linea['fields']['dimension_desarrollo']['ancho'] = $datosPedido->anchoExteriores; + $linea['fields']['dimension_desarrollo']['alto'] = $datosPedido->altoExteriores; + } + if (!array_key_exists('tipo_linea', $linea['fields'])) { if ($isColor) { if ($isHq) diff --git a/ci4/app/Views/themes/vuexy/components/alerts/alert.php b/ci4/app/Views/themes/vuexy/components/alerts/alert.php new file mode 100644 index 00000000..4741e898 --- /dev/null +++ b/ci4/app/Views/themes/vuexy/components/alerts/alert.php @@ -0,0 +1,11 @@ + \ No newline at end of file diff --git a/ci4/app/Views/themes/vuexy/components/chat_direct.php b/ci4/app/Views/themes/vuexy/components/chat_direct.php new file mode 100644 index 00000000..8a33235f --- /dev/null +++ b/ci4/app/Views/themes/vuexy/components/chat_direct.php @@ -0,0 +1,153 @@ +
+
+ +
+ + + +
+ + + +
+ + + +
+
+
+
+
+ +

+
+
+ +
+
+
+ +
+
+
+
+
+
+
+
+
+
+
+
+
+
    + + +
+
+ + +
+ + +
+
+
+
+ +
+ + +section('css') ?> + + +endSection() ?> + + + +section("additionalExternalJs") ?> + + +endSection() ?> \ No newline at end of file diff --git a/ci4/app/Views/themes/vuexy/components/chat_factura.php b/ci4/app/Views/themes/vuexy/components/chat_factura.php index 797d8aa0..f3e13cdf 100644 --- a/ci4/app/Views/themes/vuexy/components/chat_factura.php +++ b/ci4/app/Views/themes/vuexy/components/chat_factura.php @@ -1,4 +1,4 @@ -
+
@@ -30,9 +30,10 @@
    -
  • -
    No Chats Found
    -
  • +
    + +
    +
@@ -76,6 +77,15 @@
+
+
+
+
+
+
+
+
+
    @@ -112,6 +122,7 @@
section('css') ?> + endSection() ?> diff --git a/ci4/app/Views/themes/vuexy/components/chat_general.php b/ci4/app/Views/themes/vuexy/components/chat_general.php index af8ff7ef..26f403b8 100644 --- a/ci4/app/Views/themes/vuexy/components/chat_general.php +++ b/ci4/app/Views/themes/vuexy/components/chat_general.php @@ -37,14 +37,11 @@
@@ -75,9 +73,8 @@ class="avatar-initial rounded-circle bg-label-primary">P
-
Departamento Producción
- Consulta sobre el presupuesto - P001 +
+
@@ -87,13 +84,13 @@ aria-expanded="false"> - +
--> @@ -140,6 +137,7 @@ section('css') ?> + endSection() ?> diff --git a/ci4/app/Views/themes/vuexy/components/chat_pedido.php b/ci4/app/Views/themes/vuexy/components/chat_pedido.php index 03768365..64cb9c3c 100644 --- a/ci4/app/Views/themes/vuexy/components/chat_pedido.php +++ b/ci4/app/Views/themes/vuexy/components/chat_pedido.php @@ -1,4 +1,4 @@ -
+
@@ -31,9 +31,8 @@
    -
  • -
    No Chats Found
    -
  • + +
@@ -76,6 +75,15 @@
+
+
+
+
+
+
+
+
+
    @@ -113,6 +121,7 @@ section('css') ?> + endSection() ?> diff --git a/ci4/app/Views/themes/vuexy/components/chat_presupuesto.php b/ci4/app/Views/themes/vuexy/components/chat_presupuesto.php index 5a9bb075..76c30928 100644 --- a/ci4/app/Views/themes/vuexy/components/chat_presupuesto.php +++ b/ci4/app/Views/themes/vuexy/components/chat_presupuesto.php @@ -1,4 +1,4 @@ -
    +
    @@ -30,9 +30,8 @@
      -
    • -
      No Chats Found
      -
    • + +
    @@ -76,9 +75,17 @@
    +
    +
    +
    +
    +
    +
    +
    +
    +
      -
    @@ -112,6 +119,7 @@
    section('css') ?> + endSection() ?> diff --git a/ci4/app/Views/themes/vuexy/components/modals/modalAddNewChatParticipant.php b/ci4/app/Views/themes/vuexy/components/modals/modalAddNewChatParticipant.php new file mode 100644 index 00000000..e2f5e080 --- /dev/null +++ b/ci4/app/Views/themes/vuexy/components/modals/modalAddNewChatParticipant.php @@ -0,0 +1,42 @@ + + diff --git a/ci4/app/Views/themes/vuexy/form/clientes/cliente/viewClienteForm.php b/ci4/app/Views/themes/vuexy/form/clientes/cliente/viewClienteForm.php index ca21d53f..9c3eb039 100644 --- a/ci4/app/Views/themes/vuexy/form/clientes/cliente/viewClienteForm.php +++ b/ci4/app/Views/themes/vuexy/form/clientes/cliente/viewClienteForm.php @@ -34,201 +34,6 @@ endSection() ?> -section("additionalInlineJs") ?> - $(document).keypress(function (e) { - var key = e.which; - if(key == 13) // the enter key code - { e.preventDefault() - if($('#addressForm').hasClass('show')){ - $("#saveAdd").click(); - } - else if ($('#convert2Template').hasClass('show')){ - $("#saveTemplate").click(); - } - else{ - $('#saveForm').click(); - } - } - }); - - - $('#soporteId').select2({ - allowClear: false, - ajax: { - url: '', - type: 'post', - dataType: 'json', - - data: function (params) { - return { - id: 'id_user', - text: 'first_name', - searchTerm: params.term, - : v - }; - }, - delay: 60, - processResults: function (response) { - - yeniden(response.); - - return { - results: response.menu - }; - }, - - cache: true - } - }); - - $('#formaPagoId').select2({ - allowClear: false, - ajax: { - url: '', - type: 'post', - dataType: 'json', - - data: function (params) { - return { - id: 'id', - text: 'nombre', - searchTerm: params.term, - : v - }; - }, - delay: 60, - processResults: function (response) { - - yeniden(response.); - - return { - results: response.menu - }; - }, - - cache: true - } - }); - - $('#paisId').select2({ - allowClear: false, - ajax: { - url: '', - type: 'post', - dataType: 'json', - - data: function (params) { - return { - id: 'id', - text: 'nombre', - searchTerm: params.term, - : v - }; - }, - delay: 60, - processResults: function (response) { - - yeniden(response.); - - return { - results: response.menu - }; - }, - - cache: true - } - }); - - $('#provinciaId').select2({ - allowClear: false, - ajax: { - url: '', - type: 'post', - dataType: 'json', - - data: function (params) { - return { - id: 'id', - text: 'nombre', - searchTerm: params.term, - : v - }; - }, - delay: 60, - processResults: function (response) { - - yeniden(response.); - - return { - results: response.menu - }; - }, - - cache: true - } - }); - - $('#comunidadAutonomaId').select2({ - allowClear: false, - ajax: { - url: '', - type: 'post', - dataType: 'json', - - data: function (params) { - return { - id: 'id', - text: 'nombre', - searchTerm: params.term, - : v - }; - }, - delay: 60, - processResults: function (response) { - - yeniden(response.); - - return { - results: response.menu - }; - }, - - cache: true - } - }); - - $('#comercialId').select2({ - allowClear: false, - ajax: { - url: '', - type: 'post', - dataType: 'json', - - data: function (params) { - return { - id: 'id', - text: 'text', - searchTerm: params.term, - : v - }; - }, - delay: 60, - processResults: function (response) { - - yeniden(response.); - - return { - results: response.menu - }; - }, - - cache: true - } - }); - -endSection() ?> - - section('css') ?> "> @@ -236,3 +41,7 @@ endSection() ?> + +section("additionalExternalJs") ?> + +endSection() ?> \ No newline at end of file diff --git a/ci4/app/Views/themes/vuexy/form/clientes/plantillaprecios/viewClienteplantillapreciosForm.php b/ci4/app/Views/themes/vuexy/form/clientes/plantillaprecios/viewClienteplantillapreciosForm.php index 0407597d..d2c26e2f 100644 --- a/ci4/app/Views/themes/vuexy/form/clientes/plantillaprecios/viewClienteplantillapreciosForm.php +++ b/ci4/app/Views/themes/vuexy/form/clientes/plantillaprecios/viewClienteplantillapreciosForm.php @@ -278,14 +278,26 @@ language: { url: "/themes/vuexy/vendor/libs/datatables-sk/plugins/i18n/es-ES.json" }, - buttons: [ { - className: 'btn btn-primary me-sm-3 me-1', - extend: "createInline", - editor: editor, - formOptions: { - submitTrigger: -1, - submitHtml: '' - } + buttons: [ + { + extend: 'collection', + text: 'Exportar', + buttons:[ + 'copy', 'csv', 'excel', 'print', { + extend: 'pdfHtml5', + orientation: 'landscape', + pageSize: 'A4' + } + ] + }, + { + className: 'btn btn-primary me-sm-3 me-1', + extend: "createInline", + editor: editor, + formOptions: { + submitTrigger: -1, + submitHtml: '' + } } ] } ); diff --git a/ci4/app/Views/themes/vuexy/form/configuracion/papel/_papelGenericoFormItems.php b/ci4/app/Views/themes/vuexy/form/configuracion/papel/_papelGenericoFormItems.php index 6b1141e9..501b1124 100644 --- a/ci4/app/Views/themes/vuexy/form/configuracion/papel/_papelGenericoFormItems.php +++ b/ci4/app/Views/themes/vuexy/form/configuracion/papel/_papelGenericoFormItems.php @@ -1,36 +1,55 @@ -
    -
    -
    - - -
    +
    +
    +
    + + +
    -
    - - -
    +
    + + +
    -
    - - -
    +
    + + +
    -
    -
    +
    +
    - -
    -
    + + show_in_client_special == true ? 'disabled' : ''; ?> + show_in_client == true ? 'checked' : ''; ?>> -
    +
    +
    -
    \ No newline at end of file +
    +
    + + + show_in_client_special == true ? 'checked' : ''; ?>> + + +
    +
    + +
    + +
    \ No newline at end of file diff --git a/ci4/app/Views/themes/vuexy/form/configuracion/papel/_papelImpresionFormItems.php b/ci4/app/Views/themes/vuexy/form/configuracion/papel/_papelImpresionFormItems.php index 964e9916..5d0473d6 100644 --- a/ci4/app/Views/themes/vuexy/form/configuracion/papel/_papelImpresionFormItems.php +++ b/ci4/app/Views/themes/vuexy/form/configuracion/papel/_papelImpresionFormItems.php @@ -1,165 +1,213 @@ -
    -
    +
    +
    -
    - - -
    +
    + + +
    -
    - - -
    +
    + + +
    -
    - - -
    +
    + + +
    -
    - - -
    +
    + + +
    -
    +
    -
    -
    - - - $v) : ?> - - - -
    + $v): ?> + + + +
    -
    - - -
    +
    + + +
    -
    - - -
    +
    + + +
    -
    +
    -
+
-
-
-
-
+
+
+
+
- -
-
+ +
+
-
-
+
+
- -
-
+ +
+
-
-
+
+
- -
-
+ +
+
-
-
+
+
- -
-
+ +
+
-
-
+
+
- -
-
-
+ +
+
-
-
-
+
+
- -
-
+ +
+
-
-
+
+
+ + use_in_client == true ? 'checked' : ''; ?>> +
+
+
- -
-
+
+
+
-
-
+ +
+
- -
-
+
+
-
-
+ +
+
+ +
+
- -
-
-
-
\ No newline at end of file + +
+
+ +
+
+ + +
+
+ +
+
+ + +
+
+
+
\ No newline at end of file diff --git a/ci4/app/Views/themes/vuexy/form/configuracion/papel/viewPapelGenericoForm.php b/ci4/app/Views/themes/vuexy/form/configuracion/papel/viewPapelGenericoForm.php index b4b20718..0d231599 100644 --- a/ci4/app/Views/themes/vuexy/form/configuracion/papel/viewPapelGenericoForm.php +++ b/ci4/app/Views/themes/vuexy/form/configuracion/papel/viewPapelGenericoForm.php @@ -134,6 +134,16 @@ window.location.href = `/configuracion/papelesimpresion/edit/${$(this).attr('data-id')}`; }); + $('#showInClientSpecial').on('change', function() { + if($(this).is(':checked')) { + $('#showInClient').prop('disabled', true); + $('#showInClient').prop('checked', true); + } + else{ + $('#showInClient').prop('disabled', false); + } + }); + endSection() ?> diff --git a/ci4/app/Views/themes/vuexy/form/configuracion/papel/viewPapelGenericoList.php b/ci4/app/Views/themes/vuexy/form/configuracion/papel/viewPapelGenericoList.php index c3fd47da..8f8e0009 100644 --- a/ci4/app/Views/themes/vuexy/form/configuracion/papel/viewPapelGenericoList.php +++ b/ci4/app/Views/themes/vuexy/form/configuracion/papel/viewPapelGenericoList.php @@ -20,6 +20,7 @@ + @@ -90,13 +91,14 @@ { 'data': 'code' }, { 'data': 'code_ot' }, { 'data': 'show_in_client' }, + { 'data': 'show_in_client_special' }, { 'data': actionBtns } ] }); theTable.on( 'draw.dt', function () { - const boolCols = [3]; + const boolCols = [3, 4]; for (let coln of boolCols) { theTable.column(coln, { page: 'current' }).nodes().each( function (cell, i) { cell.innerHTML = cell.innerHTML == '1' ? '' : ''; diff --git a/ci4/app/Views/themes/vuexy/form/configuracion/papel/viewPapelImpresionForm.php b/ci4/app/Views/themes/vuexy/form/configuracion/papel/viewPapelImpresionForm.php index 4431ccbe..9c4c2abc 100644 --- a/ci4/app/Views/themes/vuexy/form/configuracion/papel/viewPapelImpresionForm.php +++ b/ci4/app/Views/themes/vuexy/form/configuracion/papel/viewPapelImpresionForm.php @@ -403,6 +403,16 @@ `; }; + $('#cubierta').on('change', function() { + if($(this).is(':checked')) { + $('#useForTapaDura').prop('disabled', false); + $('#useForTapaDura').prop('checked', false); + } + else{ + $('#useForTapaDura').prop('disabled', true); + } + }); + // Etiquetas para las tipologias const tipoTypes = [ @@ -757,7 +767,7 @@ } }) -endSection() ?> + endSection() ?> diff --git a/ci4/app/Views/themes/vuexy/form/configuracion/papel/viewPapelImpresionList.php b/ci4/app/Views/themes/vuexy/form/configuracion/papel/viewPapelImpresionList.php index 17736b94..5dcf2c20 100644 --- a/ci4/app/Views/themes/vuexy/form/configuracion/papel/viewPapelImpresionList.php +++ b/ci4/app/Views/themes/vuexy/form/configuracion/papel/viewPapelImpresionList.php @@ -21,14 +21,17 @@ + + + @@ -98,21 +101,24 @@ { 'data': 'nombre' }, { 'data': 'papel_generico_id' }, { 'data': 'gramaje' }, + { 'data': 'interior' }, { 'data': 'bn' }, { 'data': 'color' }, { 'data': 'cubierta' }, + { 'data': 'use_for_tapa_dura'}, { 'data': 'sobrecubierta' }, { 'data': 'guardas' }, { 'data': 'inkjet' }, { 'data': 'rotativa' }, { 'data': 'isActivo' }, + { 'data': 'use_in_client' }, { 'data': actionBtns } ] }); theTable.on( 'draw.dt', function () { - const boolCols = [3, 4, 5, 6, 7, 8, 9, 10]; + const boolCols = [3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13]; for (let coln of boolCols) { theTable.column(coln, { page: 'current' }).nodes().each( function (cell, i) { cell.innerHTML = cell.innerHTML == '1' ? '' : ''; diff --git a/ci4/app/Views/themes/vuexy/form/mensajes/mensajesView.php b/ci4/app/Views/themes/vuexy/form/mensajes/mensajesView.php index 594efa39..2288d375 100644 --- a/ci4/app/Views/themes/vuexy/form/mensajes/mensajesView.php +++ b/ci4/app/Views/themes/vuexy/form/mensajes/mensajesView.php @@ -1,10 +1,73 @@ -include("themes/_commonPartialsBs/select2bs5") ?> -include("themes/_commonPartialsBs/datatables") ?> +include('themes/_commonPartialsBs/select2bs5') ?> +include('themes/_commonPartialsBs/datatables') ?> +include('themes/_commonPartialsBs/_confirm2delete') ?> extend('themes/vuexy/main/defaultlayout') ?> + section('content'); ?> -
- null]) ?> +
+
+ +
+
+ + + +endSection() ?> +section('css') ?> + + + + + +endSection() ?> +section("additionalExternalJs") ?> + + + + endSection() ?> \ No newline at end of file diff --git a/ci4/app/Views/themes/vuexy/form/mensajes/messageChat.php b/ci4/app/Views/themes/vuexy/form/mensajes/messageChat.php new file mode 100644 index 00000000..4b6df88a --- /dev/null +++ b/ci4/app/Views/themes/vuexy/form/mensajes/messageChat.php @@ -0,0 +1,27 @@ +include('themes/_commonPartialsBs/select2bs5') ?> +include('themes/_commonPartialsBs/datatables') ?> +include('themes/_commonPartialsBs/_confirm2delete') ?> +extend('themes/vuexy/main/defaultlayout') ?> + + +section('content'); ?> + +
+ $chatId,"userId" => auth()->user()->id]) ?> +
+ + +endSection() ?> +section('css') ?> + + + + + +endSection() ?> +section("additionalExternalJs") ?> + + + + +endSection() ?> \ No newline at end of file diff --git a/ci4/app/Views/themes/vuexy/form/mensajes/messageChatFactura.php b/ci4/app/Views/themes/vuexy/form/mensajes/messageChatFactura.php new file mode 100644 index 00000000..ff05265c --- /dev/null +++ b/ci4/app/Views/themes/vuexy/form/mensajes/messageChatFactura.php @@ -0,0 +1,30 @@ +include('themes/_commonPartialsBs/select2bs5') ?> +include('themes/_commonPartialsBs/datatables') ?> +include('themes/_commonPartialsBs/_confirm2delete') ?> +extend('themes/vuexy/main/defaultlayout') ?> + + +section('content'); ?> + +
+ + + $modelId]) ?> + +
+ + +endSection() ?> +section('css') ?> + + + + + +endSection() ?> +section("additionalExternalJs") ?> + + + + +endSection() ?> \ No newline at end of file diff --git a/ci4/app/Views/themes/vuexy/form/mensajes/messageChatInternal.php b/ci4/app/Views/themes/vuexy/form/mensajes/messageChatInternal.php new file mode 100644 index 00000000..0152bb79 --- /dev/null +++ b/ci4/app/Views/themes/vuexy/form/mensajes/messageChatInternal.php @@ -0,0 +1,28 @@ +include('themes/_commonPartialsBs/select2bs5') ?> +include('themes/_commonPartialsBs/datatables') ?> +include('themes/_commonPartialsBs/_confirm2delete') ?> +extend('themes/vuexy/main/defaultlayout') ?> + + +section('content'); ?> + +
+ $modelId, "type" => $type]) ?> +
+ + +endSection() ?> +section('css') ?> + + + + + +endSection() ?> +section("additionalExternalJs") ?> + + + + + +endSection() ?> diff --git a/ci4/app/Views/themes/vuexy/form/mensajes/messageChatPedido.php b/ci4/app/Views/themes/vuexy/form/mensajes/messageChatPedido.php new file mode 100644 index 00000000..db0e52d1 --- /dev/null +++ b/ci4/app/Views/themes/vuexy/form/mensajes/messageChatPedido.php @@ -0,0 +1,27 @@ +include('themes/_commonPartialsBs/select2bs5') ?> +include('themes/_commonPartialsBs/datatables') ?> +include('themes/_commonPartialsBs/_confirm2delete') ?> +extend('themes/vuexy/main/defaultlayout') ?> + + +section('content'); ?> + +
+ $modelId]) ?> +
+ + +endSection() ?> +section('css') ?> + + + + + +endSection() ?> +section("additionalExternalJs") ?> + + + + +endSection() ?> \ No newline at end of file diff --git a/ci4/app/Views/themes/vuexy/form/mensajes/messageChatPresupuesto.php b/ci4/app/Views/themes/vuexy/form/mensajes/messageChatPresupuesto.php new file mode 100644 index 00000000..8eda11d4 --- /dev/null +++ b/ci4/app/Views/themes/vuexy/form/mensajes/messageChatPresupuesto.php @@ -0,0 +1,27 @@ +include('themes/_commonPartialsBs/select2bs5') ?> +include('themes/_commonPartialsBs/datatables') ?> +include('themes/_commonPartialsBs/_confirm2delete') ?> +extend('themes/vuexy/main/defaultlayout') ?> + + +section('content'); ?> + +
+ $modelId]) ?> +
+ + +endSection() ?> +section('css') ?> + + + + + +endSection() ?> +section("additionalExternalJs") ?> + + + + +endSection() ?> \ No newline at end of file diff --git a/ci4/app/Views/themes/vuexy/form/pedidos/_lineasItems.php b/ci4/app/Views/themes/vuexy/form/pedidos/_lineasItems.php index be7f622a..89399796 100644 --- a/ci4/app/Views/themes/vuexy/form/pedidos/_lineasItems.php +++ b/ci4/app/Views/themes/vuexy/form/pedidos/_lineasItems.php @@ -125,7 +125,7 @@ var tableOfLineasPedido = new DataTable('#tableOfLineasPedido',{ $(document).on('click', '.btn-view', function(e) { user()->inGroup('admin') || auth()->user()->inGroup('beta')): ?> - var url = ''; + var url = ''; var url = ''; diff --git a/ci4/app/Views/themes/vuexy/form/presupuestos/cosidotapablanda/_comentariosItems.php b/ci4/app/Views/themes/vuexy/form/presupuestos/admin/_comentariosItems.php similarity index 100% rename from ci4/app/Views/themes/vuexy/form/presupuestos/cosidotapablanda/_comentariosItems.php rename to ci4/app/Views/themes/vuexy/form/presupuestos/admin/_comentariosItems.php diff --git a/ci4/app/Views/themes/vuexy/form/presupuestos/cosidotapablanda/_datosEnvios.js b/ci4/app/Views/themes/vuexy/form/presupuestos/admin/_datosEnvios.js similarity index 100% rename from ci4/app/Views/themes/vuexy/form/presupuestos/cosidotapablanda/_datosEnvios.js rename to ci4/app/Views/themes/vuexy/form/presupuestos/admin/_datosEnvios.js diff --git a/ci4/app/Views/themes/vuexy/form/presupuestos/cosidotapablanda/_datosEnvios.php b/ci4/app/Views/themes/vuexy/form/presupuestos/admin/_datosEnvios.php similarity index 97% rename from ci4/app/Views/themes/vuexy/form/presupuestos/cosidotapablanda/_datosEnvios.php rename to ci4/app/Views/themes/vuexy/form/presupuestos/admin/_datosEnvios.php index 38ae8ce4..26a0f0b7 100644 --- a/ci4/app/Views/themes/vuexy/form/presupuestos/cosidotapablanda/_datosEnvios.php +++ b/ci4/app/Views/themes/vuexy/form/presupuestos/admin/_datosEnvios.php @@ -9,7 +9,7 @@
- +
diff --git a/ci4/app/Views/themes/vuexy/form/presupuestos/cosidotapablanda/_datosLibroItems.js b/ci4/app/Views/themes/vuexy/form/presupuestos/admin/_datosLibroItems.js similarity index 100% rename from ci4/app/Views/themes/vuexy/form/presupuestos/cosidotapablanda/_datosLibroItems.js rename to ci4/app/Views/themes/vuexy/form/presupuestos/admin/_datosLibroItems.js diff --git a/ci4/app/Views/themes/vuexy/form/presupuestos/cosidotapablanda/_datosLibroItems.php b/ci4/app/Views/themes/vuexy/form/presupuestos/admin/_datosLibroItems.php similarity index 100% rename from ci4/app/Views/themes/vuexy/form/presupuestos/cosidotapablanda/_datosLibroItems.php rename to ci4/app/Views/themes/vuexy/form/presupuestos/admin/_datosLibroItems.php diff --git a/ci4/app/Views/themes/vuexy/form/presupuestos/cosidotapablanda/_datosPresupuestoClienteItems.php b/ci4/app/Views/themes/vuexy/form/presupuestos/admin/_datosPresupuestoClienteItems.php similarity index 98% rename from ci4/app/Views/themes/vuexy/form/presupuestos/cosidotapablanda/_datosPresupuestoClienteItems.php rename to ci4/app/Views/themes/vuexy/form/presupuestos/admin/_datosPresupuestoClienteItems.php index 7c68175f..bf952469 100644 --- a/ci4/app/Views/themes/vuexy/form/presupuestos/cosidotapablanda/_datosPresupuestoClienteItems.php +++ b/ci4/app/Views/themes/vuexy/form/presupuestos/admin/_datosPresupuestoClienteItems.php @@ -45,7 +45,7 @@
-
+
@@ -587,7 +587,7 @@ allowClear: false, minimumResultsForSearch: Infinity, ajax: { - url: '', + url: '', type: 'post', dataType: 'json', @@ -620,7 +620,7 @@ allowClear: false, minimumResultsForSearch: Infinity, ajax: { - url: '', + url: '', type: 'post', dataType: 'json', @@ -658,7 +658,7 @@ allowClear: false, minimumResultsForSearch: Infinity, ajax: { - url: '', + url: '', type: 'post', dataType: 'json', @@ -687,7 +687,7 @@ allowClear: false, minimumResultsForSearch: Infinity, ajax: { - url: '', + url: '', type: 'post', data: function (params) { @@ -1104,7 +1104,7 @@ $.ajax({ type: "POST", - url: "/cosidotapablanda/datatable", + url: "/presupuestoadmin/datatable", data: datos, success: function (data) { @@ -1173,7 +1173,7 @@ $.ajax({ type: "POST", - url: "/cosidotapablanda/datatable", + url: "/presupuestoadmin/datatable", data: datos, success: function (data) { @@ -1252,7 +1252,7 @@ $.ajax({ type: "POST", - url: "/cosidotapablanda/datatable", + url: "/presupuestoadmin/datatable", data: datos, success: function (data) { @@ -1331,7 +1331,7 @@ $.ajax({ type: "POST", - url: "/cosidotapablanda/datatable", + url: "/presupuestoadmin/datatable", data: datos, success: function (data) { @@ -1412,7 +1412,7 @@ $.ajax({ type: "POST", - url: "/cosidotapablanda/datatable", + url: "/presupuestoadmin/datatable", data: datos, success: function (data) { @@ -1609,7 +1609,7 @@ allowClear: false, minimumResultsForSearch: Infinity, ajax: { - url: '', + url: '', type: 'post', dataType: 'json', @@ -1653,7 +1653,7 @@ allowClear: false, minimumResultsForSearch: Infinity, ajax: { - url: '', + url: '', type: 'post', dataType: 'json', @@ -1699,7 +1699,7 @@ allowClear: false, minimumResultsForSearch: Infinity, ajax: { - url: '', + url: '', type: 'post', dataType: 'json', @@ -1745,7 +1745,7 @@ allowClear: false, minimumResultsForSearch: Infinity, ajax: { - url: '', + url: '', type: 'post', dataType: 'json', @@ -1787,7 +1787,7 @@ allowClear: false, minimumResultsForSearch: Infinity, ajax: { - url: '', + url: '', type: 'post', dataType: 'json', @@ -1834,7 +1834,7 @@ allowClear: false, minimumResultsForSearch: Infinity, ajax: { - url: '', + url: '', type: 'post', dataType: 'json', diff --git a/ci4/app/Views/themes/vuexy/form/presupuestos/cosidotapablanda/_datosPresupuestoItems.php b/ci4/app/Views/themes/vuexy/form/presupuestos/admin/_datosPresupuestoItems.php similarity index 100% rename from ci4/app/Views/themes/vuexy/form/presupuestos/cosidotapablanda/_datosPresupuestoItems.php rename to ci4/app/Views/themes/vuexy/form/presupuestos/admin/_datosPresupuestoItems.php diff --git a/ci4/app/Views/themes/vuexy/form/presupuestos/cosidotapablanda/_datosServiciosItems.js b/ci4/app/Views/themes/vuexy/form/presupuestos/admin/_datosServiciosItems.js similarity index 99% rename from ci4/app/Views/themes/vuexy/form/presupuestos/cosidotapablanda/_datosServiciosItems.js rename to ci4/app/Views/themes/vuexy/form/presupuestos/admin/_datosServiciosItems.js index 788b269f..f1871aef 100644 --- a/ci4/app/Views/themes/vuexy/form/presupuestos/cosidotapablanda/_datosServiciosItems.js +++ b/ci4/app/Views/themes/vuexy/form/presupuestos/admin/_datosServiciosItems.js @@ -777,7 +777,7 @@ function convertirTiempo(horas){ // se convierte a formato hh:mm:ss const h = Math.floor(seconds / 3600); const minutos = Math.floor((seconds % 3600) / 60); - const segundos = seconds % 60; + const segundos = Math.round(seconds % 60, 0); return h + ':' + minutos + ':' + segundos; } else{ diff --git a/ci4/app/Views/themes/vuexy/form/presupuestos/cosidotapablanda/_datosServiciosItems.php b/ci4/app/Views/themes/vuexy/form/presupuestos/admin/_datosServiciosItems.php similarity index 99% rename from ci4/app/Views/themes/vuexy/form/presupuestos/cosidotapablanda/_datosServiciosItems.php rename to ci4/app/Views/themes/vuexy/form/presupuestos/admin/_datosServiciosItems.php index 12c35b60..d6fbe850 100644 --- a/ci4/app/Views/themes/vuexy/form/presupuestos/cosidotapablanda/_datosServiciosItems.php +++ b/ci4/app/Views/themes/vuexy/form/presupuestos/admin/_datosServiciosItems.php @@ -318,6 +318,8 @@ init_servicio_extra() + /* ELIMINADO PARA COMPROBAR EL MAXIMO DE SOLAPAS DESDE EL BACKEND + PENDIENTE $('.solapas_cubierta').on('change', function(){ const ancho_libro = getDimensionLibro().ancho; @@ -337,6 +339,7 @@ } $('#compGramajeCubierta').trigger('change') + }) @@ -360,5 +363,7 @@ $('#compGramajeSobrecubierta').trigger('change') }) + + */ endSection() ?> diff --git a/ci4/app/Views/themes/vuexy/form/presupuestos/cosidotapablanda/_lineasPresupuestoItems.js b/ci4/app/Views/themes/vuexy/form/presupuestos/admin/_lineasPresupuestoItems.js similarity index 98% rename from ci4/app/Views/themes/vuexy/form/presupuestos/cosidotapablanda/_lineasPresupuestoItems.js rename to ci4/app/Views/themes/vuexy/form/presupuestos/admin/_lineasPresupuestoItems.js index e49ed7ab..185aacd1 100644 --- a/ci4/app/Views/themes/vuexy/form/presupuestos/cosidotapablanda/_lineasPresupuestoItems.js +++ b/ci4/app/Views/themes/vuexy/form/presupuestos/admin/_lineasPresupuestoItems.js @@ -275,7 +275,7 @@ async function fill_bbdd_from_lp(presupuesto_id){ await $.ajax({ type: 'post', - url: window.routes_lp.updateDataOfCosidotapablanda, + url: window.routes_lp.updateDataOfPresupuestoAdmin, data: datos, dataType: 'json', @@ -1528,7 +1528,7 @@ async function set_lp_bn_gramaje(mantenerSeleccion = false){ await $.ajax({ type: 'post', - url: window.routes_lp.menuItemsOfCosidotapablanda, + url: window.routes_lp.menuItemsOfPresupuestoAdmin, beforeSend: function() { $('#lp_bn_gramaje').empty() }, @@ -1568,7 +1568,7 @@ async function set_lp_bn_papelImpresion(){ await $.ajax({ type: 'post', - url: window.routes_lp.menuItemsOfCosidotapablanda, + url: window.routes_lp.menuItemsOfPresupuestoAdmin, beforeSend: function() { $('#lp_bn_papelImpresion').empty() $('#lp_bn_maquina').empty() @@ -1604,7 +1604,7 @@ async function set_lp_bn_maquina(){ await $.ajax({ type: 'post', - url: window.routes_lp.menuItemsOfCosidotapablanda, + url: window.routes_lp.menuItemsOfPresupuestoAdmin, beforeSend: function() { $('#lp_bn_maquina').empty() clear_lp_bn(false) @@ -1676,7 +1676,7 @@ async function calcularPresupuesto_bn(input_data={}, updatedTipologias = false){ await $.ajax({ type: "POST", - url: "/cosidotapablanda/datatable", + url: "/presupuestoadmin/datatable", data: datos, success: function (data) { @@ -1903,7 +1903,7 @@ async function set_lp_color_gramaje(mantenerSeleccion = false){ await $.ajax({ type: 'post', - url: window.routes_lp.menuItemsOfCosidotapablanda, + url: window.routes_lp.menuItemsOfPresupuestoAdmin, beforeSend: function() { $('#lp_color_gramaje').empty() }, @@ -1941,7 +1941,7 @@ async function set_lp_color_papelImpresion(){ await $.ajax({ type: 'post', - url: window.routes_lp.menuItemsOfCosidotapablanda, + url: window.routes_lp.menuItemsOfPresupuestoAdmin, beforeSend: function() { $('#lp_color_papelImpresion').empty() $('#lp_color_maquina').empty() @@ -1977,7 +1977,7 @@ async function set_lp_color_maquina(){ await $.ajax({ type: 'post', - url: window.routes_lp.menuItemsOfCosidotapablanda, + url: window.routes_lp.menuItemsOfPresupuestoAdmin, beforeSend: function() { $('#lp_color_maquina').empty() clear_lp_color(false) @@ -2048,7 +2048,7 @@ async function calcularPresupuesto_color(input_data={}, updatedTipologias = fals await $.ajax({ type: "POST", - url: "/cosidotapablanda/datatable", + url: "/presupuestoadmin/datatable", data: datos, success: function (data) { @@ -2269,7 +2269,7 @@ async function set_lp_bnhq_gramaje(mantenerSeleccion = false){ await $.ajax({ type: 'post', - url: window.routes_lp.menuItemsOfCosidotapablanda, + url: window.routes_lp.menuItemsOfPresupuestoAdmin, beforeSend: function() { $('#lp_bnhq_gramaje').empty() }, @@ -2307,7 +2307,7 @@ async function set_lp_bnhq_papelImpresion(){ await $.ajax({ type: 'post', - url: window.routes_lp.menuItemsOfCosidotapablanda, + url: window.routes_lp.menuItemsOfPresupuestoAdmin, beforeSend: function() { $('#lp_bnhq_papelImpresion').empty() $('#lp_bnhq_maquina').empty() @@ -2343,7 +2343,7 @@ async function set_lp_bnhq_maquina(){ await $.ajax({ type: 'post', - url: window.routes_lp.menuItemsOfCosidotapablanda, + url: window.routes_lp.menuItemsOfPresupuestoAdmin, beforeSend: function() { $('#lp_bnhq_maquina').empty() clear_lp_bnhq(false) @@ -2484,7 +2484,7 @@ async function calcularPresupuesto_bnhq(input_data={}, updatedTipologias = false await $.ajax({ type: "POST", - url: "/cosidotapablanda/datatable", + url: "/presupuestoadmin/datatable", data: datos, success: function (data) { @@ -2633,7 +2633,7 @@ async function set_lp_colorhq_gramaje(mantenerSeleccion = false){ await $.ajax({ type: 'post', - url: window.routes_lp.menuItemsOfCosidotapablanda, + url: window.routes_lp.menuItemsOfPresupuestoAdmin, beforeSend: function() { $('#lp_colorhq_gramaje').empty() }, @@ -2671,7 +2671,7 @@ async function set_lp_colorhq_papelImpresion(){ await $.ajax({ type: 'post', - url: window.routes_lp.menuItemsOfCosidotapablanda, + url: window.routes_lp.menuItemsOfPresupuestoAdmin, beforeSend: function() { $('#lp_colorhq_papelImpresion').empty() $('#lp_colorhq_maquina').empty() @@ -2707,7 +2707,7 @@ async function set_lp_colorhq_maquina(){ await $.ajax({ type: 'post', - url: window.routes_lp.menuItemsOfCosidotapablanda, + url: window.routes_lp.menuItemsOfPresupuestoAdmin, beforeSend: function() { $('#lp_colorhq_maquina').empty() clear_lp_colorhq(false) @@ -2854,7 +2854,7 @@ async function calcularPresupuesto_colorhq(input_data={}, updatedTipologias = fa await $.ajax({ type: "POST", - url: "/cosidotapablanda/datatable", + url: "/presupuestoadmin/datatable", data: datos, success: function (data) { @@ -3004,7 +3004,7 @@ async function set_lp_rot_bn_gramaje(mantenerSeleccion = false){ await $.ajax({ type: 'post', - url: window.routes_lp.menuItemsOfCosidotapablanda, + url: window.routes_lp.menuItemsOfPresupuestoAdmin, beforeSend: function() { $('#lp_rot_bn_gramaje').empty() }, @@ -3042,7 +3042,7 @@ async function set_lp_rot_bn_papelImpresion(){ await $.ajax({ type: 'post', - url: window.routes_lp.menuItemsOfCosidotapablanda, + url: window.routes_lp.menuItemsOfPresupuestoAdmin, beforeSend: function() { $('#lp_rot_bn_papelImpresion').empty() $('#lp_rot_bn_maquina').empty() @@ -3077,7 +3077,7 @@ async function set_lp_rot_bn_maquina(){ await $.ajax({ type: 'post', - url: window.routes_lp.menuItemsOfCosidotapablanda, + url: window.routes_lp.menuItemsOfPresupuestoAdmin, beforeSend: function() { $('#lp_rot_bn_maquina').empty() clear_lp_rot_bn(false) @@ -3192,7 +3192,7 @@ async function calcularPresupuesto_rot_bn(fromComparador=false, updatedTipologia await $.ajax({ type: "POST", - url: "/cosidotapablanda/datatable", + url: "/presupuestoadmin/datatable", data: datos, success: function (data) { @@ -3376,7 +3376,7 @@ async function set_lp_rot_color_gramaje(mantenerSeleccion = false){ await $.ajax({ type: 'post', - url: window.routes_lp.menuItemsOfCosidotapablanda, + url: window.routes_lp.menuItemsOfPresupuestoAdmin, beforeSend: function() { $('#lp_rot_color_gramaje').empty() }, @@ -3414,7 +3414,7 @@ async function set_lp_rot_color_papelImpresion(){ await $.ajax({ type: 'post', - url: window.routes_lp.menuItemsOfCosidotapablanda, + url: window.routes_lp.menuItemsOfPresupuestoAdmin, beforeSend: function() { $('#lp_rot_color_papelImpresion').empty() $('#lp_rot_color_maquina').empty() @@ -3450,7 +3450,7 @@ async function set_lp_rot_color_maquina(){ await $.ajax({ type: 'post', - url: window.routes_lp.menuItemsOfCosidotapablanda, + url: window.routes_lp.menuItemsOfPresupuestoAdmin, beforeSend: function() { $('#lp_rot_color_maquina').empty() clear_lp_rot_color(false) @@ -3571,7 +3571,7 @@ async function calcularPresupuesto_rot_color(fromComparador=false, updatedTipolo await $.ajax({ type: "POST", - url: "/cosidotapablanda/datatable", + url: "/presupuestoadmin/datatable", data: datos, success: function (data) { @@ -3753,7 +3753,7 @@ async function set_lp_cubierta_gramaje(mantenerSeleccion = false){ await $.ajax({ type: 'post', - url: window.routes_lp.menuItemsOfCosidotapablanda, + url: window.routes_lp.menuItemsOfPresupuestoAdmin, beforeSend: function() { $('#lp_cubierta_gramaje').empty() }, @@ -3792,7 +3792,7 @@ async function set_lp_cubierta_papelImpresion(){ await $.ajax({ type: 'post', - url: window.routes_lp.menuItemsOfCosidotapablanda, + url: window.routes_lp.menuItemsOfPresupuestoAdmin, beforeSend: function() { $('#lp_cubierta_papelImpresion').empty() $('#lp_cubierta_maquina').empty() @@ -3829,7 +3829,7 @@ async function set_lp_cubierta_maquina(){ await $.ajax({ type: 'post', - url: window.routes_lp.menuItemsOfCosidotapablanda, + url: window.routes_lp.menuItemsOfPresupuestoAdmin, beforeSend: function() { $('#lp_cubierta_maquina').empty() clear_lp_cubierta(false) @@ -3919,7 +3919,7 @@ async function calcularPresupuesto_cubierta(fromComparador=false, input_data={}) await $.ajax({ type: "POST", - url: "/cosidotapablanda/datatable", + url: "/presupuestoadmin/datatable", data: datos, success: function (data) { @@ -4066,7 +4066,7 @@ async function set_lp_sobrecubierta_gramaje(mantenerSeleccion = false){ await $.ajax({ type: 'post', - url: window.routes_lp.menuItemsOfCosidotapablanda, + url: window.routes_lp.menuItemsOfPresupuestoAdmin, beforeSend: function() { $('#lp_sobrecubierta_gramaje').empty() }, @@ -4105,7 +4105,7 @@ async function set_lp_sobrecubierta_papelImpresion(){ await $.ajax({ type: 'post', - url: window.routes_lp.menuItemsOfCosidotapablanda, + url: window.routes_lp.menuItemsOfPresupuestoAdmin, beforeSend: function() { $('#lp_sobrecubierta_papelImpresion').empty() $('#lp_sobrecubierta_maquina').empty() @@ -4142,7 +4142,7 @@ async function set_lp_sobrecubierta_maquina(){ await $.ajax({ type: 'post', - url: window.routes_lp.menuItemsOfCosidotapablanda, + url: window.routes_lp.menuItemsOfPresupuestoAdmin, beforeSend: function() { $('#lp_sobrecubierta_maquina').empty() clear_lp_sobrecubierta(false) @@ -4215,7 +4215,7 @@ async function calcularPresupuesto_sobrecubierta(fromComparador=false, input_dat await $.ajax({ type: "POST", - url: "/cosidotapablanda/datatable", + url: "/presupuestoadmin/datatable", data: datos, success: function (data) { @@ -4436,7 +4436,7 @@ async function calcularPresupuesto_guardas(fromComparador=false, input_data={}){ await $.ajax({ type: "POST", - url: "/cosidotapablanda/datatable", + url: "/presupuestoadmin/datatable", data: datos, success: function (data) { @@ -4609,7 +4609,7 @@ async function set_lp_guardas_maquina(){ await $.ajax({ type: 'post', - url: window.routes_lp.menuItemsOfCosidotapablanda, + url: window.routes_lp.menuItemsOfPresupuestoAdmin, beforeSend: function() { $('#lp_guardas_maquina').empty() clear_lp_guardas(false) @@ -4640,7 +4640,7 @@ async function set_lp_guardas_papelImpresion(){ await $.ajax({ type: 'post', - url: window.routes_lp.menuItemsOfCosidotapablanda, + url: window.routes_lp.menuItemsOfPresupuestoAdmin, beforeSend: function() { $('#lp_guardas_papelImpresion').empty() $('#lp_guardas_maquina').empty() diff --git a/ci4/app/Views/themes/vuexy/form/presupuestos/cosidotapablanda/_lineasPresupuestoItems.php b/ci4/app/Views/themes/vuexy/form/presupuestos/admin/_lineasPresupuestoItems.php similarity index 97% rename from ci4/app/Views/themes/vuexy/form/presupuestos/cosidotapablanda/_lineasPresupuestoItems.php rename to ci4/app/Views/themes/vuexy/form/presupuestos/admin/_lineasPresupuestoItems.php index be3fab63..330ec907 100644 --- a/ci4/app/Views/themes/vuexy/form/presupuestos/cosidotapablanda/_lineasPresupuestoItems.php +++ b/ci4/app/Views/themes/vuexy/form/presupuestos/admin/_lineasPresupuestoItems.php @@ -90,8 +90,8 @@ window.papelGenericoRotativaColorList = ; window.routes_lp = { - menuItemsOfCosidotapablanda: '', - updateDataOfCosidotapablanda: '', + menuItemsOfPresupuestoAdmin: '', + updateDataOfPresupuestoAdmin: '', } diff --git a/ci4/app/Views/themes/vuexy/form/presupuestos/cosidotapablanda/_mensajeria.php b/ci4/app/Views/themes/vuexy/form/presupuestos/admin/_mensajeria.php similarity index 100% rename from ci4/app/Views/themes/vuexy/form/presupuestos/cosidotapablanda/_mensajeria.php rename to ci4/app/Views/themes/vuexy/form/presupuestos/admin/_mensajeria.php diff --git a/ci4/app/Views/themes/vuexy/form/presupuestos/cosidotapablanda/_presupuestoDireccionesForm.php b/ci4/app/Views/themes/vuexy/form/presupuestos/admin/_presupuestoDireccionesForm.php similarity index 100% rename from ci4/app/Views/themes/vuexy/form/presupuestos/cosidotapablanda/_presupuestoDireccionesForm.php rename to ci4/app/Views/themes/vuexy/form/presupuestos/admin/_presupuestoDireccionesForm.php diff --git a/ci4/app/Views/themes/vuexy/form/presupuestos/cosidotapablanda/_presupuestos.js b/ci4/app/Views/themes/vuexy/form/presupuestos/admin/_presupuestos.js similarity index 100% rename from ci4/app/Views/themes/vuexy/form/presupuestos/cosidotapablanda/_presupuestos.js rename to ci4/app/Views/themes/vuexy/form/presupuestos/admin/_presupuestos.js diff --git a/ci4/app/Views/themes/vuexy/form/presupuestos/cosidotapablanda/_previewItems.php b/ci4/app/Views/themes/vuexy/form/presupuestos/admin/_previewItems.php similarity index 100% rename from ci4/app/Views/themes/vuexy/form/presupuestos/cosidotapablanda/_previewItems.php rename to ci4/app/Views/themes/vuexy/form/presupuestos/admin/_previewItems.php diff --git a/ci4/app/Views/themes/vuexy/form/presupuestos/cosidotapablanda/_resumenPresupuestoItems.php b/ci4/app/Views/themes/vuexy/form/presupuestos/admin/_resumenPresupuestoItems.php similarity index 100% rename from ci4/app/Views/themes/vuexy/form/presupuestos/cosidotapablanda/_resumenPresupuestoItems.php rename to ci4/app/Views/themes/vuexy/form/presupuestos/admin/_resumenPresupuestoItems.php diff --git a/ci4/app/Views/themes/vuexy/form/presupuestos/cosidotapablanda/_resumenPresupuestos.js b/ci4/app/Views/themes/vuexy/form/presupuestos/admin/_resumenPresupuestos.js similarity index 100% rename from ci4/app/Views/themes/vuexy/form/presupuestos/cosidotapablanda/_resumenPresupuestos.js rename to ci4/app/Views/themes/vuexy/form/presupuestos/admin/_resumenPresupuestos.js diff --git a/ci4/app/Views/themes/vuexy/form/presupuestos/cosidotapablanda/_tiradasAlternativasItems.js b/ci4/app/Views/themes/vuexy/form/presupuestos/admin/_tiradasAlternativasItems.js similarity index 100% rename from ci4/app/Views/themes/vuexy/form/presupuestos/cosidotapablanda/_tiradasAlternativasItems.js rename to ci4/app/Views/themes/vuexy/form/presupuestos/admin/_tiradasAlternativasItems.js diff --git a/ci4/app/Views/themes/vuexy/form/presupuestos/cosidotapablanda/_tiradasAlternativasItems.php b/ci4/app/Views/themes/vuexy/form/presupuestos/admin/_tiradasAlternativasItems.php similarity index 100% rename from ci4/app/Views/themes/vuexy/form/presupuestos/cosidotapablanda/_tiradasAlternativasItems.php rename to ci4/app/Views/themes/vuexy/form/presupuestos/admin/_tiradasAlternativasItems.php diff --git a/ci4/app/Views/themes/vuexy/form/presupuestos/cosidotapablanda/comparador.js b/ci4/app/Views/themes/vuexy/form/presupuestos/admin/comparador.js similarity index 100% rename from ci4/app/Views/themes/vuexy/form/presupuestos/cosidotapablanda/comparador.js rename to ci4/app/Views/themes/vuexy/form/presupuestos/admin/comparador.js diff --git a/ci4/app/Views/themes/vuexy/form/presupuestos/cosidotapablanda/previews.js b/ci4/app/Views/themes/vuexy/form/presupuestos/admin/previews.js similarity index 100% rename from ci4/app/Views/themes/vuexy/form/presupuestos/cosidotapablanda/previews.js rename to ci4/app/Views/themes/vuexy/form/presupuestos/admin/previews.js diff --git a/ci4/app/Views/themes/vuexy/form/presupuestos/cosidotapablanda/viewCosidotapablandaList.php b/ci4/app/Views/themes/vuexy/form/presupuestos/admin/viewPresupuestoAdminList.php similarity index 97% rename from ci4/app/Views/themes/vuexy/form/presupuestos/cosidotapablanda/viewCosidotapablandaList.php rename to ci4/app/Views/themes/vuexy/form/presupuestos/admin/viewPresupuestoAdminList.php index ed0e0277..3b93c509 100644 --- a/ci4/app/Views/themes/vuexy/form/presupuestos/cosidotapablanda/viewCosidotapablandaList.php +++ b/ci4/app/Views/themes/vuexy/form/presupuestos/admin/viewPresupuestoAdminList.php @@ -10,7 +10,7 @@

- 'btn btn-primary ']); ?> + 'btn btn-primary ']); ?>
@@ -164,7 +164,7 @@ theTable = $('#tableOfPresupuestos').DataTable({ url: "/themes/vuexy/vendor/libs/datatables-sk/plugins/i18n/es-ES.json" }, ajax : $.fn.dataTable.pipeline( { - url: '', + url: '', data: function (d) { d.tipo_impresion_id = ''; }, @@ -231,7 +231,7 @@ theTable.on( 'draw.dt', function () { $(document).on('click', '.btn-edit', function(e) { - window.location.href = `/presupuestos/cosidotapablanda/edit/${$(this).attr('data-id')}/`; + window.location.href = `/presupuestoadmin/edit/${$(this).attr('data-id')}/`; }); @@ -245,7 +245,7 @@ $(document).on('click', '.btn-remove', function(e) { const row = $(this).closest('tr'); if ($.isNumeric(dataId)) { $.ajax({ - url: `/presupuestos/cosidotapablanda/delete/${dataId}`, + url: `/presupuestoadmin/delete/${dataId}`, method: 'GET', }).done((data, textStatus, jqXHR) => { $('#confirm2delete').modal('toggle'); diff --git a/ci4/app/Views/themes/vuexy/form/presupuestos/cosidotapablanda/viewCosidotapablandaForm.php b/ci4/app/Views/themes/vuexy/form/presupuestos/admin/viewPresupuestoadminForm.php similarity index 91% rename from ci4/app/Views/themes/vuexy/form/presupuestos/cosidotapablanda/viewCosidotapablandaForm.php rename to ci4/app/Views/themes/vuexy/form/presupuestos/admin/viewPresupuestoadminForm.php index ee9ed98d..9dfc18c8 100644 --- a/ci4/app/Views/themes/vuexy/form/presupuestos/cosidotapablanda/viewCosidotapablandaForm.php +++ b/ci4/app/Views/themes/vuexy/form/presupuestos/admin/viewPresupuestoadminForm.php @@ -25,18 +25,18 @@ value=""> - - + + - - - - - - + + + + + + $presupuestoId,"type" => "presupuesto"]) ?> - - + + @@ -57,7 +57,7 @@ value="" /> - "btn btn-secondary float-start",]) ?> + "btn btn-secondary float-start",]) ?>
@@ -98,7 +98,7 @@ asyncMessageDialog('', '', function() { $.ajax({ type: 'post', - url: '', + url: '', data: { tipo: 'duplicar', @@ -111,7 +111,7 @@ token=response.; yeniden(token); // redirect - new_location = '' + response.id + new_location = '' + response.id window.location.href = new_location; } }).fail(function (jqXHR, textStatus, error) { @@ -123,7 +123,7 @@ else{ $.ajax({ type: 'post', - url: '', + url: '', data: { tipo: 'duplicar', @@ -136,7 +136,7 @@ token=response.; yeniden(token); // redirect - new_location = '' + response.id + new_location = '' + response.id window.location.href = new_location; } }).fail(function (jqXHR, textStatus, error) { @@ -386,7 +386,7 @@ $('#bc-save').on( "click", function() { - + diff --git a/ci4/app/Views/themes/vuexy/form/presupuestos/buscador/viewBuscadorList.php b/ci4/app/Views/themes/vuexy/form/presupuestos/buscador/viewBuscadorList.php index f98cf37b..3d7ee781 100644 --- a/ci4/app/Views/themes/vuexy/form/presupuestos/buscador/viewBuscadorList.php +++ b/ci4/app/Views/themes/vuexy/form/presupuestos/buscador/viewBuscadorList.php @@ -289,9 +289,15 @@ theTable.on( 'draw.dt', function () { $(document).on('click', '.btn-edit', function(e) { - window.location.href = `/presupuestos/cosidotapablanda/edit/${$(this).attr('data-id')}/`; + window.location.href = `/presupuestoadmin/edit/${$(this).attr('data-id')}/`; }); +theTable.on('click', 'tr', function () { + var data = theTable.row(this).data(); + console.log(data); + var url = '/presupuestoadmin/edit/' + data['id']; + window.location.href = url; +}); $(document).on('click', '.btn-delete', function(e) { $(".btn-remove").attr('data-id', $(this).attr('data-id')); @@ -303,7 +309,7 @@ $(document).on('click', '.btn-remove', function(e) { const row = $(this).closest('tr'); if ($.isNumeric(dataId)) { $.ajax({ - url: `/presupuestos/cosidotapablanda/delete/${dataId}`, + url: `/presupuestoadmin/delete/${dataId}`, method: 'GET', }).done((data, textStatus, jqXHR) => { $('#confirm2delete').modal('toggle'); diff --git a/ci4/app/Views/themes/vuexy/form/presupuestos/cliente/disenioLibro.js b/ci4/app/Views/themes/vuexy/form/presupuestos/cliente/disenioLibro.js index 31c46e6a..11d9093a 100644 --- a/ci4/app/Views/themes/vuexy/form/presupuestos/cliente/disenioLibro.js +++ b/ci4/app/Views/themes/vuexy/form/presupuestos/cliente/disenioLibro.js @@ -684,7 +684,7 @@ async function calcularPresupuesto() { datos = Object.assign(datos, window.token_ajax) - $('#divTiradasPrecio').empty(); + $('.divTiradasPrecio').empty(); $('#loader').show(); $.ajax({ @@ -741,7 +741,7 @@ async function calcularPresupuesto() { $('#loader').hide(); - $('#divTiradasPrecio').empty(); + $('.divTiradasPrecio').empty(); if(!error){ @@ -768,7 +768,7 @@ async function calcularPresupuesto() { html += ''; html += '
'; - $('#divTiradasPrecio').append(html); + $('.divTiradasPrecio').append(html); } } @@ -783,7 +783,7 @@ async function calcularPresupuesto() { }, error: function (error) { $('#loader').hide(); - $('#divTiradasPrecio').empty(); + $('.divTiradasPrecio').empty(); } }); } \ No newline at end of file diff --git a/ci4/app/Views/themes/vuexy/form/presupuestos/cliente/items/_buttons.php b/ci4/app/Views/themes/vuexy/form/presupuestos/cliente/items/_buttons.php index eec86369..aad9101e 100644 --- a/ci4/app/Views/themes/vuexy/form/presupuestos/cliente/items/_buttons.php +++ b/ci4/app/Views/themes/vuexy/form/presupuestos/cliente/items/_buttons.php @@ -26,7 +26,7 @@ -
+
diff --git a/ci4/app/Views/themes/vuexy/form/presupuestos/cliente/items/_datosGenerales.php b/ci4/app/Views/themes/vuexy/form/presupuestos/cliente/items/_datosGenerales.php index d3e013f8..3f9997af 100644 --- a/ci4/app/Views/themes/vuexy/form/presupuestos/cliente/items/_datosGenerales.php +++ b/ci4/app/Views/themes/vuexy/form/presupuestos/cliente/items/_datosGenerales.php @@ -49,13 +49,12 @@
-
-
`; }; @@ -292,7 +292,12 @@ theTable = $('#tableOfPresupuestos').DataTable({ ] }); - +theTable.on('click', 'tr', function () { + var data = theTable.row(this).data(); + var url = '/presupuestos/presupuestocliente/edit/' + data['id']; + window.location.href = url; +}); + theTable.on( 'draw.dt', function () { const dateCols = [1]; diff --git a/ci4/app/Views/themes/vuexy/form/presupuestos/cliente/viewPresupuestoclienteForm.php b/ci4/app/Views/themes/vuexy/form/presupuestos/cliente/viewPresupuestoclienteForm.php index e66e65b2..a3126558 100644 --- a/ci4/app/Views/themes/vuexy/form/presupuestos/cliente/viewPresupuestoclienteForm.php +++ b/ci4/app/Views/themes/vuexy/form/presupuestos/cliente/viewPresupuestoclienteForm.php @@ -11,10 +11,13 @@ -
+
-

+ + +

+ getErrors()) ? $validation->listErrors("bootstrap_style") : "" ?> @@ -27,9 +30,27 @@
-
+
+ +
-
class="step active titulos-menu" data-target="#datos-generales"> + + + +
+ +
class="step active titulos-menu" data-target="#datos-generales">
-
class="step titulos-menu" data-target="#interior-libro"> +
class="step titulos-menu" data-target="#interior-libro">
-
class="step titulos-menu" data-target="#cubierta-libro"> +
class="step titulos-menu" data-target="#cubierta-libro">
-
class="step titulos-menu" data-target="#direcciones-libro"> +
class="step titulos-menu" data-target="#direcciones-libro">
diff --git a/ci4/app/Views/themes/vuexy/form/tarifas/encuadernacion/viewTarifaEncuadernacionForm.php b/ci4/app/Views/themes/vuexy/form/tarifas/encuadernacion/viewTarifaEncuadernacionForm.php index 9ca27bdd..31a06d68 100644 --- a/ci4/app/Views/themes/vuexy/form/tarifas/encuadernacion/viewTarifaEncuadernacionForm.php +++ b/ci4/app/Views/themes/vuexy/form/tarifas/encuadernacion/viewTarifaEncuadernacionForm.php @@ -388,29 +388,42 @@ language: { url: "/themes/vuexy/vendor/libs/datatables-sk/plugins/i18n/es-ES.json" }, - buttons: [ { - className: 'btn btn-primary float-end me-sm-3 me-1', - extend: "createInline", - editor: editor3, - formOptions: { - submitTrigger: -1, - submitHtml: '' - + buttons: [ + { + extend: 'collection', + text: 'Exportar', + buttons:[ + 'copy', 'csv', 'excel', 'print', { + extend: 'pdfHtml5', + orientation: 'landscape', + pageSize: 'A4' + } + ] }, - action: function ( e, dt, node, config ) { - if(selected_tirada_id == -1){ - popErrorAlert(""); - } - else{ - formOptions= { - submitTrigger: -1, - submitHtml: '' - - }; - editor3.inlineCreate(config.position, formOptions); - } - }, - } ] + { + className: 'btn btn-primary float-end me-sm-3 me-1', + extend: "createInline", + editor: editor3, + formOptions: { + submitTrigger: -1, + submitHtml: '' + + }, + action: function ( e, dt, node, config ) { + if(selected_tirada_id == -1){ + popErrorAlert(""); + } + else{ + formOptions= { + submitTrigger: -1, + submitHtml: '' + + }; + editor3.inlineCreate(config.position, formOptions); + } + }, + } + ] } ); @@ -581,29 +594,42 @@ language: { url: "/themes/vuexy/vendor/libs/datatables-sk/plugins/i18n/es-ES.json" }, - buttons: [ { - className: 'btn btn-primary float-end me-sm-3 me-1', - extend: "createInline", - editor: editor, - formOptions: { - submitTrigger: -1, - submitHtml: '' - + buttons: [ + { + extend: 'collection', + text: 'Exportar', + buttons:[ + 'copy', 'csv', 'excel', 'print', { + extend: 'pdfHtml5', + orientation: 'landscape', + pageSize: 'A4' + } + ] }, - action: function ( e, dt, node, config ) { - if(selected_tirada_id == -1){ - popErrorAlert(""); - } - else{ - formOptions= { - submitTrigger: -1, - submitHtml: '' - - }; - editor.inlineCreate(config.position, formOptions); - } - }, - } ] + { + className: 'btn btn-primary float-end me-sm-3 me-1', + extend: "createInline", + editor: editor, + formOptions: { + submitTrigger: -1, + submitHtml: '' + + }, + action: function ( e, dt, node, config ) { + if(selected_tirada_id == -1){ + popErrorAlert(""); + } + else{ + formOptions= { + submitTrigger: -1, + submitHtml: '' + + }; + editor.inlineCreate(config.position, formOptions); + } + }, + } + ] } ); @@ -733,7 +759,7 @@ select: true, info: false, dom: '<"mt-4"><"float-end"B><"float-start"l><"mt-4 mb-3"p>', - ajax : $.fn.dataTable.pipeline( { + ajax : $.fn.dataTable.pipeline( { url: '', data: { id_tarifaencuadernacion: id, @@ -768,13 +794,25 @@ language: { url: "/themes/vuexy/vendor/libs/datatables-sk/plugins/i18n/es-ES.json" }, - buttons: [ { - className: 'btn btn-primary float-end me-sm-3 me-1', - extend: "createInline", - editor: editor2, - formOptions: { - submitTrigger: -1, - submitHtml: '' + buttons: [ + { + extend: 'collection', + text: 'Exportar', + buttons:[ + 'copy', 'csv', 'excel', 'print', { + extend: 'pdfHtml5', + orientation: 'landscape', + pageSize: 'A4' + } + ] + }, + { + className: 'btn btn-primary float-end me-sm-3 me-1', + extend: "createInline", + editor: editor2, + formOptions: { + submitTrigger: -1, + submitHtml: '' } } ] } ); diff --git a/ci4/app/Views/themes/vuexy/form/tarifas/manipulado/viewTarifaManipuladoForm.php b/ci4/app/Views/themes/vuexy/form/tarifas/manipulado/viewTarifaManipuladoForm.php index c9b390f1..c7dc35c9 100644 --- a/ci4/app/Views/themes/vuexy/form/tarifas/manipulado/viewTarifaManipuladoForm.php +++ b/ci4/app/Views/themes/vuexy/form/tarifas/manipulado/viewTarifaManipuladoForm.php @@ -186,14 +186,26 @@ language: { url: "/themes/vuexy/vendor/libs/datatables-sk/plugins/i18n/es-ES.json" }, - buttons: [ { - className: 'btn btn-primary float-end me-sm-3 me-1', - extend: "createInline", - editor: editor, - formOptions: { - submitTrigger: -1, - submitHtml: '' - } + buttons: [ + { + extend: 'collection', + text: 'Exportar', + buttons:[ + 'copy', 'csv', 'excel', 'print', { + extend: 'pdfHtml5', + orientation: 'landscape', + pageSize: 'A4' + } + ] + }, + { + className: 'btn btn-primary float-end me-sm-3 me-1', + extend: "createInline", + editor: editor, + formOptions: { + submitTrigger: -1, + submitHtml: '' + } } ] } ); diff --git a/ci4/app/Views/themes/vuexy/form/test_js/test_js.js b/ci4/app/Views/themes/vuexy/form/test_js/test_js.js index 282ca8ac..c2df9850 100644 --- a/ci4/app/Views/themes/vuexy/form/test_js/test_js.js +++ b/ci4/app/Views/themes/vuexy/form/test_js/test_js.js @@ -3,7 +3,7 @@ /* -fetch("/presupuestos/cosidotapablanda/datatable", { +fetch("/presupuestoadmin/datatable", { method: 'POST', body: JSON.stringify(data), diff --git a/ci4/app/Views/themes/vuexy/form/test_js/viewTest.php b/ci4/app/Views/themes/vuexy/form/test_js/viewTest.php index 5d79d503..9fb473a3 100644 --- a/ci4/app/Views/themes/vuexy/form/test_js/viewTest.php +++ b/ci4/app/Views/themes/vuexy/form/test_js/viewTest.php @@ -21,7 +21,7 @@ $.ajax({ type:"POST", - url:"cosidotapablanda/datatable", + url:"presupuestoadmin/datatable", data:datos, // data recive un objeto con la informacion que se enviara al servidor success:function(data){ //success es una funcion que se utiliza si el servidor retorna informacion console.log(data) diff --git a/ci4/app/Views/themes/vuexy/form/user/viewUserForm.php b/ci4/app/Views/themes/vuexy/form/user/viewUserForm.php index 361861c4..88f037ad 100644 --- a/ci4/app/Views/themes/vuexy/form/user/viewUserForm.php +++ b/ci4/app/Views/themes/vuexy/form/user/viewUserForm.php @@ -21,7 +21,7 @@ name="save" value="" > - "btn btn-secondary"]) ?> + "btn btn-secondary"]) ?>
diff --git a/ci4/app/Views/themes/vuexy/form/user/viewUserList.php b/ci4/app/Views/themes/vuexy/form/user/viewUserList.php index b22a4c76..b6adb138 100644 --- a/ci4/app/Views/themes/vuexy/form/user/viewUserList.php +++ b/ci4/app/Views/themes/vuexy/form/user/viewUserList.php @@ -1,122 +1,59 @@ -include('themes/_commonPartialsBs/datatables') ?> -extend('themes/vuexy/main/defaultlayout') ?> -section('content'); ?> -
-
+include('themes/_commonPartialsBs/datatables') ?> +extend('themes/vuexy/main/defaultlayout') ?> +section('content'); ?> +
+
-
-
-

- 'btn btn-primary float-end']); ?> -
-
- +
+
+

+ 'btn btn-primary float-end']); ?> +
+
+ -
- +
- - - - - - - - - - - - - - - - - - - - */ ?> - - - - - - - - +
- first_name) || strlen($item->first_name) < 51 ? esc($item->first_name) : character_limiter(esc($item->first_name), 50) ?> - - last_name) || strlen($item->last_name) < 51 ? esc($item->last_name) : character_limiter(esc($item->last_name), 50) ?> -
+ + + + + + + + + + + + - + + - - getGroupsTitles($item->token)) || strlen($user_model->getGroupsTitles($item->token)) < 51 ? esc($user_model->getGroupsTitles($item->token)) : character_limiter($user_model->getGroupsTitles($item->token), 50) ?> - + + - - + + +
- email) ? "" : character_limiter(esc(lang($item->email)), 50) ?> + first_name) || strlen($item->first_name) < 51 ? esc($item->first_name) : character_limiter(esc($item->first_name), 50) ?> - last_active) ? '' : date('d/m/Y H:m:s', strtotime($item->last_active)) ?> + + last_name) || strlen($item->last_name) < 51 ? esc($item->last_name) : character_limiter(esc($item->last_name), 50) ?> + + getProvider()->findById($item->id)->email) ? "" : character_limiter(esc(auth()->getProvider()->findById($item->id)->email), 50) ?> + + last_active) ? '' : date('d/m/Y H:m:s', strtotime($item->last_active)) ?> + id), "", ['class' => 'text-body', 'data-id' => $item->id,]); ?> + ", ['class' => 'text-body', 'data-href' => route_to('deleteUser', $item->id), 'data-bs-toggle' => 'modal', 'data-bs-target' => '#confirm2delete']); ?> +
- mobile) || strlen($item->mobile) < 51 ? esc($item->mobile) : character_limiter(esc($item->mobile), 50) ?> - - email) ?> -
+
+ +
+
+
- - id), "", ['class'=>'text-body', 'data-id'=>$item->id,]); ?> - ", ['class'=>'text-body', 'data-href'=>route_to('deleteUser', $item->id), 'data-bs-toggle'=>'modal', 'data-bs-target'=>'#confirm2delete']); ?> - - - - - - - - - - - - -endSection() ?> \ No newline at end of file +endSection() ?> \ No newline at end of file diff --git a/ci4/app/Views/themes/vuexy/main/defaultlayout.php b/ci4/app/Views/themes/vuexy/main/defaultlayout.php index fb1927cd..40358745 100644 --- a/ci4/app/Views/themes/vuexy/main/defaultlayout.php +++ b/ci4/app/Views/themes/vuexy/main/defaultlayout.php @@ -147,18 +147,6 @@ $picture = "/assets/img/default-user.png"; - - + - user()->can('clientes.menu') || - auth()->user()->can('plantilla-tarifa.menu')) { - ?> + if ( + auth()->user()->can('clientes.menu') || + auth()->user()->can('plantilla-tarifa.menu') + ) { + ?> + - - - - +?> \ No newline at end of file diff --git a/ci4/app/Views/themes/vuexy/main/menus/mensajes_menu.php b/ci4/app/Views/themes/vuexy/main/menus/mensajes_menu.php index 44913967..7faa33da 100644 --- a/ci4/app/Views/themes/vuexy/main/menus/mensajes_menu.php +++ b/ci4/app/Views/themes/vuexy/main/menus/mensajes_menu.php @@ -2,7 +2,7 @@ /** * MENU MENSAJES */ -if (auth()->user()->inGroup('beta')) { +if (auth()->user()->inGroup('beta') || auth()->user()->inGroup('cliente-editor')) { ?> - \ No newline at end of file diff --git a/ci4/app/Views/themes/vuexy/main/menus/pedidos_menu.php b/ci4/app/Views/themes/vuexy/main/menus/pedidos_menu.php index 30c38ad4..7601ec50 100644 --- a/ci4/app/Views/themes/vuexy/main/menus/pedidos_menu.php +++ b/ci4/app/Views/themes/vuexy/main/menus/pedidos_menu.php @@ -2,7 +2,12 @@ /** * MENU PEDIDOS */ -if (auth()->user()->inGroup('beta')) { +if ( + auth()->user()->can('pedidos-activos.menu') || + auth()->user()->can('pedidos-finalizados.menu') || + auth()->user()->can('pedidos-cancelados.menu') || + auth()->user()->can('pedidos-todos.menu') +) { ?> \ No newline at end of file diff --git a/ci4/app/Views/themes/vuexy/main/menus/presupuesto_cliente_menu.php b/ci4/app/Views/themes/vuexy/main/menus/presupuesto_cliente_menu.php index 46359e42..4b367bfc 100644 --- a/ci4/app/Views/themes/vuexy/main/menus/presupuesto_cliente_menu.php +++ b/ci4/app/Views/themes/vuexy/main/menus/presupuesto_cliente_menu.php @@ -20,6 +20,15 @@ if (auth()->user()->inGroup('cliente-admin') ); ?> + user()->can('presupuesto-cliente.create')) { ?> + + - user()->can('presupuesto-cliente.create')) { ?> - - user()->can('presupuesto.menu')) {