diff --git a/ci4/app/Config/Routes.php b/ci4/app/Config/Routes.php index cf5efcbf..8af1cf19 100644 --- a/ci4/app/Config/Routes.php +++ b/ci4/app/Config/Routes.php @@ -224,6 +224,43 @@ $routes->group('tarifaacabadolineas', ['namespace' => 'App\Controllers\Tarifas'] $routes->resource('tarifaacabadolineas', ['namespace' => 'App\Controllers\Tarifas', 'controller' => 'Tarifaacabadolineas', 'except' => 'show,new,create,update']); +$routes->group('maquinas', ['namespace' => 'App\Controllers\Configuracion'], function ($routes) { + $routes->get('', 'Maquinas::index', ['as' => 'maquinaList']); + $routes->get('add', 'Maquinas::add', ['as' => 'newMaquina']); + $routes->post('add', 'Maquinas::add', ['as' => 'createMaquina']); + $routes->post('create', 'Maquinas::create', ['as' => 'ajaxCreateMaquina']); + $routes->put('update/(:num)', 'Maquinas::update/$1', ['as' => 'ajaxUpdateMaquina']); + $routes->post('edit/(:num)', 'Maquinas::edit/$1', ['as' => 'updateMaquina']); + $routes->post('datatable', 'Maquinas::datatable', ['as' => 'dataTableOfMaquinas']); + $routes->post('allmenuitems', 'Maquinas::allItemsSelect', ['as' => 'select2ItemsOfMaquinas']); + $routes->post('menuitems', 'Maquinas::menuItems', ['as' => 'menuItemsOfMaquinas']); +}); +$routes->resource('maquinas', ['namespace' => 'App\Controllers\Configuracion', 'controller' => 'Maquinas', 'except' => 'show,new,create,update']); + + +$routes->group('maquinastarifasimpresion', ['namespace' => 'App\Controllers\Configuracion'], function ($routes) { + $routes->get('', 'Maquinastarifasimpresion::index', ['as' => 'maquinasTarifaImpresionList']); + $routes->get('add', 'Maquinastarifasimpresion::add', ['as' => 'newMaquinasTarifaImpresion']); + $routes->post('add', 'Maquinastarifasimpresion::add', ['as' => 'createMaquinasTarifaImpresion']); + $routes->post('create', 'Maquinastarifasimpresion::create', ['as' => 'ajaxCreateMaquinasTarifaImpresion']); + $routes->put('(:num)/update', 'Maquinastarifasimpresion::update/$1', ['as' => 'ajaxUpdateMaquinasTarifaImpresion']); + $routes->post('(:num)/edit', 'Maquinastarifasimpresion::edit/$1', ['as' => 'updateMaquinasTarifaImpresion']); + $routes->post('datatable_editor', 'Maquinastarifasimpresion::datatable_editor', ['as' => 'editorOfMaquinasTarifaImpresion']); + $routes->post('datatable', 'Maquinastarifasimpresion::datatable', ['as' => 'dataTableOfMaquinasTarifasImpresion']); + $routes->post('allmenuitems', 'Maquinastarifasimpresion::allItemsSelect', ['as' => 'select2ItemsOfMaquinasTarifasImpresion']); + $routes->post('menuitems', 'Maquinastarifasimpresion::menuItems', ['as' => 'menuItemsOfMaquinasTarifasImpresion']); +}); +$routes->resource('maquinastarifasimpresion', ['namespace' => 'App\Controllers\Configuracion', 'controller' => 'Maquinastarifasimpresion', 'except' => 'show,new,create,update']); + +$routes->group('maquinaspapelesimpresion', ['namespace' => 'App\Controllers\Configuracion'], function ($routes) { + $routes->post('datatable', 'Maquinaspapelesimpresion::datatable', ['as' => 'dataTableOfMaquinasPapelesImpresion']); + $routes->post('datatable_editor', 'Maquinaspapelesimpresion::datatable_editor', ['as' => 'editorOfMaquinasPapelImpresion']); + $routes->post('updateTableOnChange', 'Maquinaspapelesimpresion::updateTableOnChange', ['as' => 'updateMaquinaPapelOnTarifasChange']); +}); +$routes->resource('maquinastarifasimpresion', ['namespace' => 'App\Controllers\Configuracion', 'controller' => 'Maquinastarifasimpresion', 'except' => 'show,new,create,update']); + + + $routes->group('profile', ['namespace' => 'App\Controllers'], function ($routes) { $routes->get('', 'Profile::index', ['as' => 'profileList']); $routes->get('index', 'Profile::index', ['as' => 'profileIndex']); diff --git a/ci4/app/Controllers/Configuracion/Maquina.php b/ci4/app/Controllers/Configuracion/Maquina.php deleted file mode 100644 index 2af78cb9..00000000 --- a/ci4/app/Controllers/Configuracion/Maquina.php +++ /dev/null @@ -1,35 +0,0 @@ -viewData['pageTitle'] = lang('Maquinas.moduleTitle'); + $this->viewData['usingSweetAlert'] = true; + + // Se indica que este controlador trabaja con soft_delete + $this->soft_delete = true; + // Se indica el flag para los ficheros borrados + $this->delete_flag = 1; + + $this->viewData = ['usingServerSideDataTable' => true]; // JJO + + parent::initController($request, $response, $logger); + } + + + public function index() { + + $viewData = [ + 'currentModule' => static::$controllerSlug, + 'pageSubTitle' => lang('Basic.global.ManageAllRecords', [lang('Maquinas.maquina')]), + 'maquina' => new Maquina(), + 'usingServerSideDataTable' => true, + + ]; + + $viewData = array_merge($this->viewData, $viewData); // merge any possible values from the parent controller class + + return view(static::$viewPath.'viewMaquinaList', $viewData); + } + + + public function add() { + + // JJO + $session = session(); + + $requestMethod = $this->request->getMethod(); + + if ($requestMethod === 'post') : + + $nullIfEmpty = true; // !(phpversion() >= '8.1'); + + $postData = $this->request->getPost(); + + $sanitizedData = $this->sanitized($postData, $nullIfEmpty); + + // JJO + $sanitizedData['user_created_id'] = $session->id_user; + + $noException = true; + 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('Maquinas.maquina'))]); + $this->session->setFlashdata('formErrors', $this->model->errors()); + endif; + + $thenRedirect = true; // Change this to false if you want your user to stay on the form after submission + endif; + if ($noException && $successfulResult) : + + $id = $this->model->db->insertID(); + + $message = lang('Basic.global.saveSuccess', [mb_strtolower(lang('Maquinas.maquina'))]).'.'; + $message .= anchor( "maquinas/{$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); + return redirect()->to(site_url('configuracion/maquinas/edit/'.$id))->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['maquina'] = isset($sanitizedData) ? new Maquina($sanitizedData) : new Maquina(); + $this->viewData['maquinaList'] = $this->getMaquinaListItems($maquina->padre_id ?? null); + $this->viewData['tipoList'] = $this->getTipoOptions(); + + $this->viewData['formAction'] = route_to('createMaquina'); + + $this->viewData['boxTitle'] = lang('Basic.global.addNew').' '.lang('Maquinas.moduleTitle').' '.lang('Basic.global.addNewSuffix'); + + + return $this->displayForm(__METHOD__); + } // end function add() + + public function edit($requestedId = null) { + + // JJO + $session = session(); + + if ($requestedId == null) : + return $this->redirect2listView(); + endif; + $id = filter_var($requestedId, FILTER_SANITIZE_URL); + $maquina = $this->model->find($id); + + if ($maquina == false) : + $message = lang('Basic.global.notFoundWithIdErr', [mb_strtolower(lang('Maquinas.maquina')), $id]); + return $this->redirect2listView('sweet-error', $message); + endif; + + $requestMethod = $this->request->getMethod(); + + if ($requestMethod === 'post') : + + $nullIfEmpty = true; // !(phpversion() >= '8.1'); + + $postData = $this->request->getPost(); + + $sanitizedData = $this->sanitized($postData, $nullIfEmpty); + if ($this->request->getPost('is_padre') == null ) { + $sanitizedData['is_padre'] = false; + } + if ($this->request->getPost('is_rotativa') == null ) { + $sanitizedData['is_rotativa'] = false; + } + if ($this->request->getPost('is_tinta') == null ) { + $sanitizedData['is_tinta'] = false; + } + + // JJO + $sanitizedData['user_updated_id'] = $session->id_user; + $noException = true; + if ($successfulResult = $this->canValidate()) : // if ($successfulResult = $this->validate($this->formValidationRules) ) : + + if ($this->canValidate()) : + try { + $successfulResult = $this->model->skipValidation(true)->update($id, $sanitizedData); + } catch (\Exception $e) { + $noException = false; + $this->dealWithException($e); + } + else: + $this->viewData['warningMessage'] = lang('Basic.global.formErr1', [mb_strtolower(lang('Maquinas.maquina'))]); + $this->session->setFlashdata('formErrors', $this->model->errors()); + + endif; + + $maquina->fill($sanitizedData); + + $thenRedirect = true; + endif; + if ($noException && $successfulResult) : + $id = $maquina->id ?? $id; + $message = lang('Basic.global.updateSuccess', [mb_strtolower(lang('Maquinas.maquina'))]).'.'; + $message .= anchor( "maquinas/{$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); + else: + return $this->redirect2listView('sweet-success', $message); + endif; + else: + $this->session->setFlashData('sweet-success', $message); + endif; + + endif; // $noException && $successfulResult + endif; // ($requestMethod === 'post') + + $this->viewData['maquina'] = $maquina; + $this->viewData['maquinaList'] = $this->getMaquinaListItems($maquina->padre_id ?? null); + $this->viewData['tipoList'] = $this->getTipoOptions(); + + $this->viewData['formAction'] = route_to('updateMaquina', $id); + + $this->viewData['boxTitle'] = lang('Basic.global.edit2').' '.lang('Maquinas.moduleTitle').' '.lang('Basic.global.edit3'); + + + return $this->displayForm(__METHOD__, $id); + } // end function edit(...) + + + + public function datatable() { + if ($this->request->isAJAX()) { + $reqData = $this->request->getPost(); + if (!isset($reqData['draw']) || !isset($reqData['columns']) ) { + $errstr = 'No data available in response to this specific request.'; + $response = $this->respond(Collection::datatable( [], 0, 0, $errstr ), 400, $errstr); + return $response; + } + $start = $reqData['start'] ?? 0; + $length = $reqData['length'] ?? 5; + $search = $reqData['search']['value']; + $requestedOrder = $reqData['order']['0']['column'] ?? 1; + $order = MaquinaModel::SORTABLE[$requestedOrder >= 0 ? $requestedOrder : 1]; + $dir = $reqData['order']['0']['dir'] ?? 'asc'; + + $resourceData = $this->model->getResource($search)->orderBy($order, $dir)->limit($length, $start)->get()->getResultObject(); + foreach ($resourceData as $item) : + if (isset($item->observaciones) && strlen($item->observaciones) > 100) : + $item->observaciones = character_limiter($item->observaciones, 100); + endif; + endforeach; + + return $this->respond(Collection::datatable( + $resourceData, + $this->model->getResource()->countAllResults(), + $this->model->getResource($search)->countAllResults() + )); + } else { + return $this->failUnauthorized('Invalid request', 403); + } + } + + public function allItemsSelect() { + if ($this->request->isAJAX()) { + $onlyActiveOnes = true; + $reqVal = $this->request->getPost('val') ?? 'id'; + $menu = $this->model->getAllForMenu($reqVal.', nombre', 'nombre', $onlyActiveOnes, false); + $nonItem = new \stdClass; + $nonItem->id = ''; + $nonItem->nombre = '- '.lang('Basic.global.None').' -'; + array_unshift($menu , $nonItem); + + $newTokenHash = csrf_hash(); + $csrfTokenName = csrf_token(); + $data = [ + 'menu' => $menu, + $csrfTokenName => $newTokenHash + ]; + return $this->respond($data); + } else { + return $this->failUnauthorized('Invalid request', 403); + } + } + + public function menuItems() { + if ($this->request->isAJAX()) { + $searchStr = goSanitize($this->request->getPost('searchTerm'))[0]; + $reqId = goSanitize($this->request->getPost('id'))[0]; + $reqText = goSanitize($this->request->getPost('text'))[0]; + $onlyActiveOnes = false; + $columns2select = [$reqId ?? 'id', $reqText ?? 'nombre']; + $onlyActiveOnes = false; + $menu = $this->model->getSelect2MenuItems($columns2select, $columns2select[1], $onlyActiveOnes, $searchStr); + $nonItem = new \stdClass; + $nonItem->id = ''; + $nonItem->text = '- '.lang('Basic.global.None').' -'; + array_unshift($menu , $nonItem); + + $newTokenHash = csrf_hash(); + $csrfTokenName = csrf_token(); + $data = [ + 'menu' => $menu, + $csrfTokenName => $newTokenHash + ]; + return $this->respond($data); + } else { + return $this->failUnauthorized('Invalid request', 403); + } + } + + + protected function getMaquinaListItems($selId = null) { + $data = [''=>lang('Basic.global.pleaseSelectA', [mb_strtolower(lang('Maquinas.maquina'))])]; + if (!empty($selId)) : + $maquinaModel = model('App\Models\Configuracion\MaquinaModel'); + + $selOption = $maquinaModel->where('id', $selId)->findColumn('nombre'); + if (!empty($selOption)) : + $data[$selId] = $selOption[0]; + endif; + endif; + return $data; + } + + + protected function getTipoOptions() { + $tipoOptions = [ + '' => lang('Basic.global.pleaseSelect'), + 'impresion' => 'impresion', + 'manipulado' => 'manipulado', + 'acabado' => 'acabado', + ]; + return $tipoOptions; + } + + +} diff --git a/ci4/app/Controllers/Configuracion/Maquinaspapelesimpresion.php b/ci4/app/Controllers/Configuracion/Maquinaspapelesimpresion.php new file mode 100644 index 00000000..c7202768 --- /dev/null +++ b/ci4/app/Controllers/Configuracion/Maquinaspapelesimpresion.php @@ -0,0 +1,203 @@ +viewData['pageTitle'] = ''; + $this->viewData['usingSweetAlert'] = true; + parent::initController($request, $response, $logger); + } + + + public function index() { + + $viewData = [ + 'currentModule' => static::$controllerSlug, + 'pageSubTitle' => '', + 'maquinasTarifasImpresion' => new Maquinaspapelesimpresion(), + 'usingServerSideDataTable' => true, + + ]; + + } + + public function datatable() { + if ($this->request->isAJAX()) { + + // modelos usados + $tarifa_model = new MaquinasTarifasImpresionModel(); + + $reqData = $this->request->getPost(); + if (!isset($reqData['draw']) || !isset($reqData['columns']) ) { + $errstr = 'No data available in response to this specific request.'; + $response = $this->respond(Collection::datatable( [], 0, 0, $errstr ), 400, $errstr); + return $response; + } + $start = $reqData['start'] ?? 0; + $length = $reqData['length'] ?? 5; + $search = $reqData['search']['value']; + $requestedOrder = $reqData['order']['0']['column'] ?? 1; + $order = MaquinasPapelesImpresionModel::SORTABLE[$requestedOrder >= 0 ? $requestedOrder : 1]; + $dir = $reqData['order']['0']['dir'] ?? 'asc'; + + $maquina_id = $reqData['maquina_id'] ?? -1; + // Para saber si el papel que se tiene que mostrar es para rotativa + $isRotativa= $reqData['isRotativa'] ?? 0; + + // Se obtienen las líneas de las tarifas seleccionadas para esta máquina + $tarifas = $tarifa_model->getResource("", $maquina_id)->get()->getResultObject(); + + $resourceData = $this->model->getResource($search, $isRotativa, $tarifas, $maquina_id)->orderBy($order, $dir)->limit($length, $start)->get()->getResultObject(); + + return $this->respond(Collection::datatable( + $resourceData, + $this->model->getResource()->countAllResults(), + $this->model->getResource($search, $isRotativa, $tarifas, $maquina_id)->countAllResults() + )); + } else { + return $this->failUnauthorized('Invalid request', 403); + } + } + + public function updateTableOnChange(){ + + if ($this->request->isAJAX()) { + + $reqData = $this->request->getPost(); + + $maquina_id = $reqData['maquina_id'] ?? -1; + // Para saber si el papel que se tiene que mostrar es para rotativa + $isRotativa= $reqData['isRotativa'] ?? 0; + + // modelos usados + $tarifa_model = new MaquinasTarifasImpresionModel(); + $papelimpresion_model = new PapelImpresionModel(); + + $tarifas = $tarifa_model->getResource("", $maquina_id)->get()->getResultObject(); + + // 1- Se obtienen los papeles que hay seleccionados (de la tabla lg_maquina_papel_impresion y que coincidan con las tarifas actuales) + $initData = $this->model->getInitData($isRotativa, $tarifas, $maquina_id); + // 2- Se cuentan los resultados. Si no hay coincidencias, hay que crear la tabla pivote con todos los papeles que cumplan la + // condición de las tarifas y con la columna active a 0. Si hay coincidencias, se guardan los activos en un array + $selected_papers = $initData->countAllResults(); + $active_values = []; + if($selected_papers > 0){ + $active_values = $this->model->getInitData($isRotativa, $tarifas, $maquina_id)->get()->getResult('array'); + } + // Primero se borran las filas con la maquina_id de la tabla pivote + $this->model->deleteRows($maquina_id); + + // Se insertan en la tabla pivote los resultados de los papeles que cumplan con las tarifas con el campo active = 0 + $data = $papelimpresion_model->getIdPapelesImpresion($maquina_id, $tarifas)->get()->getResult('array'); + $this->model->insertRows($data); + + // Se actualizan los activos que había en caso de que los hubiera + if(count($active_values)>0){ + $this->model->updateRows($active_values); + } + + $newTokenHash = csrf_hash(); + $csrfTokenName = csrf_token(); + + $response[$csrfTokenName] = $newTokenHash; + + echo json_encode($response); + + } else { + return $this->failUnauthorized('Invalid request', 403); + } + } + + public function datatable_editor() { + if ($this->request->isAJAX()) { + + $reqData = $this->request->getPost(); + if($reqData['action'] =='edit'){ + + $rec_data = $reqData['data']; + $key = array_key_first($rec_data); + $maquina_id = $rec_data[$key]['maquina_id'] ?? -1; + $papel_id = $rec_data[$key]['papel_impresion_id'] ?? -1; + $active = $rec_data[$key]['active'] ?? -1; + $gramaje = $rec_data[$key]['gramaje'] ?? -1; + + $data = [ + 'maquina_id' => $maquina_id, + 'papel_impresion_id' => $papel_id, + 'active' => $active, + ]; + + // Se checkea que no haya otro papel con ese gramaje seleccionado y que la accion sea activar ese papel + if($this->model->getPapelActivo($maquina_id, $gramaje)->countAllResults() != 0 && intval($active)==1){ + $response['error']= lang('MaquinasPapelImpresion.gramaje_duplicado');; + $ret_vals = [ + 'DT_RowId' => 'row_'. $papel_id, + 'maquina_id' => $maquina_id, + 'papel_impresion_id' => $papel_id, + 'active' => '0', + ]; + $response['data'] = $ret_vals; + } + else{ + $this->model->updateRows([$data]); + } + + $newTokenHash = csrf_hash(); + $csrfTokenName = csrf_token(); + + $response[$csrfTokenName] = $newTokenHash; + + echo json_encode($response); + + } + else{ + return $this->failUnauthorized('Invalid request', 403); + } + } else { + return $this->failUnauthorized('Invalid request', 403); + } + } + + +} diff --git a/ci4/app/Controllers/Configuracion/Maquinastarifasimpresion.php b/ci4/app/Controllers/Configuracion/Maquinastarifasimpresion.php new file mode 100644 index 00000000..4dfaeb1c --- /dev/null +++ b/ci4/app/Controllers/Configuracion/Maquinastarifasimpresion.php @@ -0,0 +1,426 @@ +viewData['pageTitle'] = lang('MaquinasTarifasImpresions.moduleTitle'); + $this->viewData['usingSweetAlert'] = true; + parent::initController($request, $response, $logger); + } + + + public function index() { + + $viewData = [ + 'currentModule' => static::$controllerSlug, + 'pageSubTitle' => lang('Basic.global.ManageAllRecords', [lang('MaquinasTarifasImpresions.maquinasTarifaImpresion')]), + 'maquinasTarifasImpresion' => new MaquinasTarifasImpresion(), + 'usingServerSideDataTable' => true, + + ]; + + $viewData = array_merge($this->viewData, $viewData); // merge any possible values from the parent controller class + + return view(static::$viewPath.'viewMaquinasTarifaImpresionList', $viewData); + } + + + public function add() { + + + + $requestMethod = $this->request->getMethod(); + + if ($requestMethod === 'post') : + + $nullIfEmpty = true; // !(phpversion() >= '8.1'); + + $postData = $this->request->getPost(); + + $sanitizedData = $this->sanitized($postData, $nullIfEmpty); + + + $noException = true; + 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('MaquinasTarifasImpresions.maquinasTarifaImpresion'))]); + $this->session->setFlashdata('formErrors', $this->model->errors()); + endif; + + $thenRedirect = true; // Change this to false if you want your user to stay on the form after submission + endif; + if ($noException && $successfulResult) : + + $id = $this->model->db->insertID(); + + $message = lang('Basic.global.saveSuccess', [mb_strtolower(lang('MaquinasTarifasImpresions.maquinasTarifaImpresion'))]).'.'; + $message .= anchor( "maquinastarifasimpresion/{$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); + else: + return $this->redirect2listView('sweet-success', $message); + endif; + else: + $this->session->setFlashData('sweet-success', $message); + endif; + + endif; // $noException && $successfulResult + + endif; // ($requestMethod === 'post') + + $this->viewData['maquinasTarifasImpresion'] = isset($sanitizedData) ? new MaquinasTarifasImpresion($sanitizedData) : new MaquinasTarifasImpresion(); + $this->viewData['maquinaList'] = $this->getMaquinaListItems($maquinasTarifasImpresion->maquina_id ?? null); + $this->viewData['tipoList'] = $this->getTipoOptions(); + + $this->viewData['formAction'] = route_to('createMaquinasTarifaImpresion'); + + $this->viewData['boxTitle'] = lang('Basic.global.addNew').' '.lang('MaquinasTarifasImpresions.moduleTitle').' '.lang('Basic.global.addNewSuffix'); + + + return $this->displayForm(__METHOD__); + } // end function add() + + public function edit($requestedId = null) { + + if ($requestedId == null) : + return $this->redirect2listView(); + endif; + $id = filter_var($requestedId, FILTER_SANITIZE_URL); + $maquinasTarifasImpresion = $this->model->find($id); + + if ($maquinasTarifasImpresion == false) : + $message = lang('Basic.global.notFoundWithIdErr', [mb_strtolower(lang('MaquinasTarifasImpresions.maquinasTarifaImpresion')), $id]); + return $this->redirect2listView('sweet-error', $message); + endif; + + $requestMethod = $this->request->getMethod(); + + if ($requestMethod === 'post') : + + $nullIfEmpty = true; // !(phpversion() >= '8.1'); + + $postData = $this->request->getPost(); + + $sanitizedData = $this->sanitized($postData, $nullIfEmpty); +if ($this->request->getPost('predeterminado') == null ) { + $sanitizedData['predeterminado'] = false; + } + + + + $noException = true; + if ($successfulResult = $this->canValidate()) : // if ($successfulResult = $this->validate($this->formValidationRules) ) : + + + + if ($this->canValidate()) : + try { + $successfulResult = $this->model->skipValidation(true)->update($id, $sanitizedData); + } catch (\Exception $e) { + $noException = false; + $this->dealWithException($e); + } + else: + $this->viewData['warningMessage'] = lang('Basic.global.formErr1', [mb_strtolower(lang('MaquinasTarifasImpresions.maquinasTarifaImpresion'))]); + $this->session->setFlashdata('formErrors', $this->model->errors()); + + endif; + + $maquinasTarifasImpresion->fill($sanitizedData); + + $thenRedirect = true; + endif; + if ($noException && $successfulResult) : + $id = $maquinasTarifasImpresion->id ?? $id; + $message = lang('Basic.global.updateSuccess', [mb_strtolower(lang('MaquinasTarifasImpresions.maquinasTarifaImpresion'))]).'.'; + $message .= anchor( "maquinastarifasimpresion/{$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); + else: + return $this->redirect2listView('sweet-success', $message); + endif; + else: + $this->session->setFlashData('sweet-success', $message); + endif; + + endif; // $noException && $successfulResult + endif; // ($requestMethod === 'post') + + $this->viewData['maquinasTarifasImpresion'] = $maquinasTarifasImpresion; + $this->viewData['maquinaList'] = $this->getMaquinaListItems($maquinasTarifasImpresion->maquina_id ?? null); + $this->viewData['tipoList'] = $this->getTipoOptions(); + + $this->viewData['formAction'] = route_to('updateMaquinasTarifaImpresion', $id); + + $this->viewData['boxTitle'] = lang('Basic.global.edit2').' '.lang('MaquinasTarifasImpresions.moduleTitle').' '.lang('Basic.global.edit3'); + + + return $this->displayForm(__METHOD__, $id); + } // end function edit(...) + + + public function datatable_editor() { + if ($this->request->isAJAX()) { + + include(APPPATH . "ThirdParty/DatatablesEditor/DataTables.php"); + + // Build our Editor instance and process the data coming from _POST + $response = Editor::inst( $db, 'lg_maquinas_tarifas_impresion' ) + ->fields( + Field::inst( 'uso' ) + ->validator( 'Validate::notEmpty',array( + 'message' => lang('MaquinasTarifasImpresions.validation.uso.required') ) + ), + Field::inst( 'tipo' ) + ->validator( 'Validate::notEmpty',array( + 'message' => lang('MaquinasTarifasImpresions.validation.tipo.required') ) + ), + Field::inst( 'precio' ) + ->validator( 'Validate::numeric', array( + 'message' => lang('MaquinasTarifasImpresions.validation.precio.decimal') ) + ) + ->validator( 'Validate::notEmpty',array( + 'message' => lang('MaquinasTarifasImpresions.validation.tipo.required') ) + ), + Field::inst( 'maquina_id' ), + Field::inst( 'user_created_id' ), + Field::inst( 'created_at' ), + Field::inst( 'user_updated_id' ), + Field::inst( 'updated_at' ), + Field::inst( 'is_deleted' ), + Field::inst( 'deleted_at' ), + + ) + ->validator( function($editor, $action, $data){ + if ($action === Editor::ACTION_CREATE || $action === Editor::ACTION_EDIT){ + foreach ($data['data'] as $pkey => $values ){ + // Si no se quiere borrar... + if($data['data'][$pkey]['is_deleted'] != 1) + { + // Cubierta y sobrecubierta sólo pueden ser en color + if($values['uso'] != 'interior' && $values['tipo'] != 'color'){ + return lang('MaquinasTarifasImpresions.validation.cubierta_sobrecubierta_color'); + } + + // No se pueden duplicar valores al crear + if($action === Editor::ACTION_CREATE){ + $builder = $this->model->select('*') + ->where(array( + 'maquina_id'=> $values['maquina_id'], + 'tipo'=> $values['tipo'], + 'uso'=> $values['uso'], + 'is_deleted'=> 0)); + + if ($builder->countAllResults() >= 1){ + if(($action === Editor::ACTION_EDIT && $builder->get()->getFirstRow()->id != $pkey) + || $action === Editor::ACTION_CREATE) + return lang('MaquinasTarifasImpresions.validation.duplicated_uso_tipo'); + + } + } + } + } + } + }) + ->on( 'preCreate', function ( $editor, &$values ) { + $session = session(); + $datetime = (new \CodeIgniter\I18n\Time("now")); + $editor + ->field( 'user_created_id' ) + ->setValue( $session->id_user ); + $editor + ->field( 'created_at' ) + ->setValue( $datetime->format('Y-m-d H:i:s') ); + } ) + ->on( 'preEdit', function ( $editor, &$values ) { + $session = session(); + $datetime = (new \CodeIgniter\I18n\Time("now")); + $editor + ->field( 'user_updated_id' ) + ->setValue( $session->id_user ); + $editor + ->field( 'updated_at' ) + ->setValue( $datetime->format('Y-m-d H:i:s') ); + } ) + ->debug(true) + ->process( $_POST ) + ->data(); + + + /*// if unique key is set in DB + if(isset($response['error'])){ + if(str_contains($response['error'], "tirada_min_tirada_max") && + str_contains($response['error'], "Duplicate entry ")){ + $response['error'] = lang('TarifaAcabadoLineas.validation.duplicated_tirada'); + } + }*/ + $newTokenHash = csrf_hash(); + $csrfTokenName = csrf_token(); + + $response[$csrfTokenName] = $newTokenHash; + + echo json_encode($response); + + } else { + return $this->failUnauthorized('Invalid request', 403); + } + } + + public function datatable() { + if ($this->request->isAJAX()) { + $reqData = $this->request->getPost(); + if (!isset($reqData['draw']) || !isset($reqData['columns']) ) { + $errstr = 'No data available in response to this specific request.'; + $response = $this->respond(Collection::datatable( [], 0, 0, $errstr ), 400, $errstr); + return $response; + } + $start = $reqData['start'] ?? 0; + $length = $reqData['length'] ?? 5; + $search = $reqData['search']['value']; + $requestedOrder = $reqData['order']['0']['column'] ?? 1; + $order = MaquinasTarifasImpresionModel::SORTABLE[$requestedOrder > 0 ? $requestedOrder : 1]; + $dir = $reqData['order']['0']['dir'] ?? 'asc'; + + $id_M = $reqData['id_maquina'] ?? -1; + + $resourceData = $this->model->getResource("", $id_M)->orderBy($order, $dir)->limit($length, $start)->get()->getResultObject(); + + return $this->respond(Collection::datatable( + $resourceData, + $this->model->getResource()->countAllResults(), + $this->model->getResource($search, $id_M)->countAllResults() + )); + } else { + return $this->failUnauthorized('Invalid request', 403); + } + } + + public function allItemsSelect() { + if ($this->request->isAJAX()) { + $onlyActiveOnes = true; + $reqVal = $this->request->getPost('val') ?? 'id'; + $menu = $this->model->getAllForMenu($reqVal.', maquina_id', 'maquina_id', $onlyActiveOnes, false); + $nonItem = new \stdClass; + $nonItem->id = ''; + $nonItem->maquina_id = '- '.lang('Basic.global.None').' -'; + array_unshift($menu , $nonItem); + + $newTokenHash = csrf_hash(); + $csrfTokenName = csrf_token(); + $data = [ + 'menu' => $menu, + $csrfTokenName => $newTokenHash + ]; + return $this->respond($data); + } else { + return $this->failUnauthorized('Invalid request', 403); + } + } + + public function menuItems() { + if ($this->request->isAJAX()) { + $searchStr = goSanitize($this->request->getPost('searchTerm'))[0]; + $reqId = goSanitize($this->request->getPost('id'))[0]; + $reqText = goSanitize($this->request->getPost('text'))[0]; + $onlyActiveOnes = false; + $columns2select = [$reqId ?? 'id', $reqText ?? 'maquina_id']; + $onlyActiveOnes = false; + $menu = $this->model->getSelect2MenuItems($columns2select, $columns2select[1], $onlyActiveOnes, $searchStr); + $nonItem = new \stdClass; + $nonItem->id = ''; + $nonItem->text = '- '.lang('Basic.global.None').' -'; + array_unshift($menu , $nonItem); + + $newTokenHash = csrf_hash(); + $csrfTokenName = csrf_token(); + $data = [ + 'menu' => $menu, + $csrfTokenName => $newTokenHash + ]; + return $this->respond($data); + } else { + return $this->failUnauthorized('Invalid request', 403); + } + } + + + protected function getMaquinaListItems($selId = null) { + $data = [''=>lang('Basic.global.pleaseSelectA', [mb_strtolower(lang('Maquinas.maquina'))])]; + if (!empty($selId)) : + $maquinaModel = model('App\Models\Configuracion\MaquinaModel'); + + $selOption = $maquinaModel->where('id', $selId)->findColumn('nombre'); + if (!empty($selOption)) : + $data[$selId] = $selOption[0]; + endif; + endif; + return $data; + } + + + protected function getTipoOptions() { + $tipoOptions = [ + '' => lang('Basic.global.pleaseSelect'), + 'negro' => 'negro', + 'color' => 'color', + 'negrohq' => 'negrohq', + 'bicolor' => 'bicolor', + ]; + return $tipoOptions; + } + + +} diff --git a/ci4/app/Controllers/Tarifas/Tarifasmanipulado.php b/ci4/app/Controllers/Tarifas/Tarifasmanipulado.php index 3a4184a1..897959e4 100644 --- a/ci4/app/Controllers/Tarifas/Tarifasmanipulado.php +++ b/ci4/app/Controllers/Tarifas/Tarifasmanipulado.php @@ -127,7 +127,7 @@ class Tarifasmanipulado extends \App\Controllers\GoBaseResourceController { $this->viewData['tarifaManipuladoEntity'] = isset($sanitizedData) ? new TarifaManipuladoEntity($sanitizedData) : new TarifaManipuladoEntity(); - $this->viewData['formAction'] = route_to('createTarifaManipulado'); + $this->viewData['formAction'] = site_url('configuracion/maquinas/add');//route_to('createTarifaManipulado'); $this->viewData['boxTitle'] = lang('Basic.global.addNew').' '.lang('Tarifamanipulado.moduleTitle').' '.lang('Basic.global.addNewSuffix'); @@ -163,7 +163,7 @@ class Tarifasmanipulado extends \App\Controllers\GoBaseResourceController { // JJO if(isset($this->model->user_update_id)){ - $sanitizedData['user_update_id'] = $session->id_user; + $sanitizedData['user_updated_id'] = $session->id_user; } $noException = true; diff --git a/ci4/app/Controllers/Test.php b/ci4/app/Controllers/Test.php index aa44a832..04f3b0b2 100644 --- a/ci4/app/Controllers/Test.php +++ b/ci4/app/Controllers/Test.php @@ -18,8 +18,8 @@ class Test extends BaseController /* $papel = new Papelesimpresion(); var_dump($papel->datatablePG());*/ - return redirect()->to(site_url('tarifas/tarifaacabado/edit/'. 30))->with('sweet-success', 'OK'); - //return redirect()->to('https://sk-jjo.imnavajas.es/tarifas/tarifaacabado/edit/30'); + $session = session(); + var_dump($session->id_user); } } \ No newline at end of file diff --git a/ci4/app/Entities/Configuracion/Maquina.php b/ci4/app/Entities/Configuracion/Maquina.php new file mode 100644 index 00000000..2a4953dc --- /dev/null +++ b/ci4/app/Entities/Configuracion/Maquina.php @@ -0,0 +1,65 @@ + null, + "nombre" => null, + "is_padre" => false, + "tipo" => null, + "velocidad" => 0.0, + "ancho" => null, + "alto" => null, + "ancho_impresion" => 0.0, + "alto_impresion" => 0.0, + "alto_click" => 0.0, + "padre_id" => null, + "min" => 1, + "max" => 1000000, + "duracion_jornada" => 8, + "orden_planning" => 1, + "is_rotativa" => false, + "precio_tinta_negro" => 0.0, + "is_tinta" => false, + "precio_tinta_color" => 0.0, + "velocidad_corte" => 0.0, + "precio_hora_corte" => 0.0, + "metrosxminuto" => null, + "forzar_num_formas_horizontales_portada" => null, + "forzar_num_formas_verticales_portada" => null, + "observaciones" => null, + "is_deleted" => 0, + "created_at" => null, + "updated_at" => null, + "user_created_id" => 0, + "user_updated_id" => 0, + ]; + protected $casts = [ + "is_padre" => "boolean", + "velocidad" => "float", + "ancho" => "?float", + "alto" => "?float", + "ancho_impresion" => "float", + "alto_impresion" => "float", + "alto_click" => "float", + "padre_id" => "?int", + "min" => "int", + "max" => "int", + "duracion_jornada" => "int", + "orden_planning" => "int", + "is_rotativa" => "boolean", + "precio_tinta_negro" => "float", + "is_tinta" => "boolean", + "precio_tinta_color" => "float", + "velocidad_corte" => "float", + "precio_hora_corte" => "float", + "forzar_num_formas_horizontales_portada" => "?int", + "forzar_num_formas_verticales_portada" => "?int", + "is_deleted" => "int", + "user_created_id" => "int", + "user_updated_id" => "int", + ]; +} diff --git a/ci4/app/Entities/Configuracion/MaquinasPapelesImpresionEntity.php b/ci4/app/Entities/Configuracion/MaquinasPapelesImpresionEntity.php new file mode 100644 index 00000000..7c659702 --- /dev/null +++ b/ci4/app/Entities/Configuracion/MaquinasPapelesImpresionEntity.php @@ -0,0 +1,18 @@ + null, + "papel_impresion_id" => null, + "active" => null, + ]; + protected $casts = [ + "maquina_id" => "int", + "papel_impresion_id" => "int", + "active" => "int", + ]; +} \ No newline at end of file diff --git a/ci4/app/Entities/Configuracion/MaquinasTarifasImpresionEntity.php b/ci4/app/Entities/Configuracion/MaquinasTarifasImpresionEntity.php new file mode 100644 index 00000000..f0a49f25 --- /dev/null +++ b/ci4/app/Entities/Configuracion/MaquinasTarifasImpresionEntity.php @@ -0,0 +1,27 @@ + null, + "maquina_id" => null, + "tipo" => null, + "precio" => null, + "uso" => null, + "user_created_id" => 0, + "user_updated_id" => 0, + "is_deleted" => 0, + "created_at" => null, + "updated_at" => null, + ]; + protected $casts = [ + "maquina_id" => "int", + "precio" => "float", + "user_created_id" => "int", + "user_updated_id" => "int", + "is_deleted" => "int", + ]; +} diff --git a/ci4/app/Entities/Configuracion/PapelImpresion.php b/ci4/app/Entities/Configuracion/PapelImpresion.php index a68402f0..0e890e9a 100644 --- a/ci4/app/Entities/Configuracion/PapelImpresion.php +++ b/ci4/app/Entities/Configuracion/PapelImpresion.php @@ -22,8 +22,8 @@ class PapelImpresion extends \CodeIgniter\Entity\Entity "precio_pliego" => null, "bn" => true, "color" => true, - "portada" => false, "cubierta" => false, + "sobrecubierta" => false, "rotativa" => false, "is_deleted" => 0, "created_at" => null, @@ -42,8 +42,8 @@ class PapelImpresion extends \CodeIgniter\Entity\Entity "precio_pliego" => "float", "bn" => "boolean", "color" => "boolean", - "portada" => "boolean", "cubierta" => "boolean", + "sobrecubierta" => "boolean", "rotativa" => "boolean", "is_deleted" => "int", ]; diff --git a/ci4/app/Filters/LoginAuthFilter.php b/ci4/app/Filters/LoginAuthFilter.php index 5beffba7..a5be0f94 100644 --- a/ci4/app/Filters/LoginAuthFilter.php +++ b/ci4/app/Filters/LoginAuthFilter.php @@ -143,6 +143,8 @@ class LoginAuthFilter implements FilterInterface 'Viewmode', 'GoBaseController', 'GoBaseResourceController', + 'Maquinaspapelesimpresion', + 'Maquinastarifasimpresion', 'My', 'Usuarios', 'Notification' // PARA LA DEMO ]; diff --git a/ci4/app/Language/en/Basic.php b/ci4/app/Language/en/Basic.php index 21d74320..9162821a 100644 --- a/ci4/app/Language/en/Basic.php +++ b/ci4/app/Language/en/Basic.php @@ -80,10 +80,12 @@ return [ 'text' => 'This action cannot be undone.', 'title' => 'Are you sure?', 'maxRowsReached' => 'No more lines can be added.', - 'line' => 'the line' + 'line' => 'the line', + 'error_tittle' => 'Error', ], 'ok' => 'Ok', 'wait' => 'Wait', + 'yes' => 'Yes', ], diff --git a/ci4/app/Language/en/Maquinas.php b/ci4/app/Language/en/Maquinas.php new file mode 100644 index 00000000..ca28974c --- /dev/null +++ b/ci4/app/Language/en/Maquinas.php @@ -0,0 +1,165 @@ + 'finish', + 'alto' => 'Height', + 'altoClick' => 'Height Click', + 'altoImpresion' => 'Height Printing', + 'ancho' => 'Width', + 'anchoImpresion' => 'Width Printing', + 'createdAt' => 'Created At', + 'deletedAt' => 'Deleted At', + 'duracionJornada' => 'Working day duration', + 'forzarNumFormasHorizontalesPortada' => 'Force Number of Shapes Horizontal Cover', + 'forzarNumFormasVerticalesPortada' => 'Force Number of Shapes Vertical Cover', + 'id' => 'ID', + 'impresion' => 'Printing', + 'isDeleted' => 'Is Deleted', + 'isPadre' => 'Use for variant', + 'isRotativa' => 'Is Rotary?', + 'isTinta' => 'Is Ink', + 'manipulado' => 'handling', + 'maquina' => 'Machine', + 'maquinaList' => 'Maniches List', + 'maquinas' => 'Machines', + 'max' => 'Max POD', + 'metrosxminuto' => 'Meters x minute', + 'min' => 'Min POD', + 'moduleTitle' => 'Machines', + 'nombre' => 'Name', + 'observaciones' => 'Remarks', + 'ordenPlanning' => 'Planning order', + 'padreId' => 'Variante', + 'precioHoraCorte' => 'Price Hour cut', + 'precioTintaColor' => 'Price Ink Colour', + 'precioTintaNegro' => 'Price Ink black', + 'tipo' => 'Type', + 'updatedAt' => 'Updated At', + 'userCreatedId' => 'User Created ID', + 'userUpdatedId' => 'User Updated ID', + 'velocidad' => 'Speed', + 'velocidadCorte' => 'Cut speed', + 'validation' => [ + 'alto' => [ + 'decimal' => 'The {field} field must contain a decimal number.', + + ], + + 'ancho' => [ + 'decimal' => 'The {field} field must contain a decimal number.', + + ], + + 'forzar_num_formas_horizontales_portada' => [ + 'integer' => 'The {field} field must contain an integer.', + + ], + + 'forzar_num_formas_verticales_portada' => [ + 'integer' => 'The {field} field must contain an integer.', + + ], + + 'alto_click' => [ + 'decimal' => 'The {field} field must contain a decimal number.', + 'required' => 'The {field} field is required.', + + ], + + 'alto_impresion' => [ + 'decimal' => 'The {field} field must contain a decimal number.', + 'required' => 'The {field} field is required.', + + ], + + 'ancho_impresion' => [ + 'decimal' => 'The {field} field must contain a decimal number.', + 'required' => 'The {field} field is required.', + + ], + + 'duracion_jornada' => [ + 'integer' => 'The {field} field must contain an integer.', + 'required' => 'The {field} field is required.', + + ], + + 'max' => [ + 'integer' => 'The {field} field must contain an integer.', + 'required' => 'The {field} field is required.', + + ], + + 'metrosxminuto' => [ + 'max_length' => 'The {field} field cannot exceed {param} characters in length.', + 'required' => 'The {field} field is required.', + + ], + + 'min' => [ + 'integer' => 'The {field} field must contain an integer.', + 'required' => 'The {field} field is required.', + + ], + + 'nombre' => [ + 'max_length' => 'The {field} field cannot exceed {param} characters in length.', + 'required' => 'The {field} field is required.', + + ], + + 'observaciones' => [ + 'max_length' => 'The {field} field cannot exceed {param} characters in length.', + 'required' => 'The {field} field is required.', + + ], + + 'orden_planning' => [ + 'integer' => 'The {field} field must contain an integer.', + 'required' => 'The {field} field is required.', + + ], + + 'precio_hora_corte' => [ + 'decimal' => 'The {field} field must contain a decimal number.', + 'required' => 'The {field} field is required.', + + ], + + 'precio_tinta_color' => [ + 'decimal' => 'The {field} field must contain a decimal number.', + 'required' => 'The {field} field is required.', + + ], + + 'precio_tinta_negro' => [ + 'decimal' => 'The {field} field must contain a decimal number.', + 'required' => 'The {field} field is required.', + + ], + + 'tipo' => [ + 'in_list' => 'The {field} field must be one of: {param}.', + 'required' => 'The {field} field is required.', + + ], + + 'velocidad' => [ + 'decimal' => 'The {field} field must contain a decimal number.', + 'required' => 'The {field} field is required.', + + ], + + 'velocidad_corte' => [ + 'decimal' => 'The {field} field must contain a decimal number.', + 'required' => 'The {field} field is required.', + + ], + + + ], + + +]; \ No newline at end of file diff --git a/ci4/app/Language/en/MaquinasPapelImpresion.php b/ci4/app/Language/en/MaquinasPapelImpresion.php new file mode 100644 index 00000000..b16a906e --- /dev/null +++ b/ci4/app/Language/en/MaquinasPapelImpresion.php @@ -0,0 +1,10 @@ + 'Active', + 'gramaje_duplicado' => 'It can not be selected two pieces of paper with the same grammage', + 'sureToChangeRotativaTitle' => 'Are you sure to change this option?', + 'sureToChangeRotativaText' => 'This operation can\'t undone and the paper list will change.', +]; \ No newline at end of file diff --git a/ci4/app/Language/en/MaquinasTarifasImpresions.php b/ci4/app/Language/en/MaquinasTarifasImpresions.php new file mode 100644 index 00000000..0cff47a2 --- /dev/null +++ b/ci4/app/Language/en/MaquinasTarifasImpresions.php @@ -0,0 +1,54 @@ + 'Created At', + 'deletedAt' => 'Deleted At', + 'id' => 'ID', + 'isDeleted' => 'Is Deleted', + 'maquinaId' => 'Machine', + 'maquinasTarifaImpresion' => 'Printing rate', + 'maquinasTarifaImpresionList' => 'Printing rate List', + 'maquinasTarifasImpresion' => 'Printing rates', + 'maquinastarifasimpresion' => 'Printing rates', + 'moduleTitle' => 'Machine printing rates', + 'precio' => 'Price', + 'predeterminado' => 'Default', + 'tipo' => 'Type', + 'updatedAt' => 'Updated At', + 'userCreatedId' => 'User Created ID', + 'userUpdatedId' => 'User Updated ID', + 'uso' => 'Use', + 'interior' => 'Inside', + 'cubierta' => 'Cover', + 'sobrecubierta' => 'Dust jacket', + 'negro' => 'Black', + 'color' => 'Color', + 'negrohq' => 'Black HQ', + 'bicolor' => 'Bicolor', + 'validation' => [ + 'duplicated_uso_tipo' => "Duplicate line (the combination 'use' and 'type' already exists)", + 'cubierta_sobrecubierta_color' => "Cover and dust jacket only allow 'color' type", + 'tipo' => [ + 'in_list' => 'The {field} field must be one of: {param}.', + 'required' => 'Required field.', + ], + + 'precio' => [ + 'decimal' => 'The {field} field must contain a decimal number.', + 'required' => 'Required field.', + + ], + + 'uso' => [ + 'in_list' => 'The {field} field must be one of: {param}.', + 'required' => 'Required field.', + + ], + + + ], + + +]; \ No newline at end of file diff --git a/ci4/app/Language/en/PapelImpresion.php b/ci4/app/Language/en/PapelImpresion.php index 7cfd6d48..605450be 100644 --- a/ci4/app/Language/en/PapelImpresion.php +++ b/ci4/app/Language/en/PapelImpresion.php @@ -9,6 +9,7 @@ return [ 'color' => 'Colour', 'createdAt' => 'Created At', 'cubierta' => 'Cover', + 'sobrecubierta' => 'Dust jacket', 'defecto' => 'Default', 'deletedAt' => 'Deleted At', 'espesor' => 'Thickness', @@ -25,12 +26,12 @@ return [ 'papelesImpresion' => 'Print papers', 'papelesimpresion' => 'Print papers', 'pesoPorPliego' => 'Weight per sheet', - 'portada' => 'Cover', 'precioPliego' => 'Sheet price', 'precioTonelada' => 'Ton price', 'referencia' => 'Reference', 'rotativa' => 'Rotary', 'updatedAt' => 'Updated At', + 'activo' => 'Active?', 'userUpdateId' => 'User Update ID', 'consumo_tintas_rotativas' => 'Rotary ink consumption', diff --git a/ci4/app/Language/es/Basic.php b/ci4/app/Language/es/Basic.php index 8b004acc..aac5351d 100644 --- a/ci4/app/Language/es/Basic.php +++ b/ci4/app/Language/es/Basic.php @@ -80,11 +80,12 @@ return [ 'text' => 'Esta acción no se puede deshacer.', 'title' => 'Está seguro?', 'maxRowsReached' => 'No se pueden añadir más líneas.', - 'line' => 'la línea' - + 'line' => 'la línea', + 'error_tittle' => 'Error', ], 'ok' => 'Ok', 'wait' => 'Espere', + 'yes' => 'Si', ], diff --git a/ci4/app/Language/es/Maquinas.php b/ci4/app/Language/es/Maquinas.php new file mode 100644 index 00000000..733d17d3 --- /dev/null +++ b/ci4/app/Language/es/Maquinas.php @@ -0,0 +1,165 @@ + 'acabado', + 'alto' => 'Alto', + 'altoClick' => 'Alto Click', + 'altoImpresion' => 'Alto Impresion', + 'ancho' => 'Ancho', + 'anchoImpresion' => 'Ancho Impresion', + 'createdAt' => 'Created At', + 'deletedAt' => 'Deleted At', + 'duracionJornada' => 'Duracion Jornada', + 'forzarNumFormasHorizontalesPortada' => 'Forzar Num Formas Horizontales Portada', + 'forzarNumFormasVerticalesPortada' => 'Forzar Num Formas Verticales Portada', + 'id' => 'ID', + 'impresion' => 'impresion', + 'isDeleted' => 'Is Deleted', + 'isPadre' => 'Usar para variante?', + 'isRotativa' => 'Es Rotativa?', + 'isTinta' => 'Es Tinta?', + 'manipulado' => 'manipulado', + 'maquina' => 'Maquina', + 'maquinaList' => 'Lista Máquinas', + 'maquinas' => 'Máquinas', + 'max' => 'POD Max', + 'metrosxminuto' => 'Metros x minuto', + 'min' => 'POD Min', + 'moduleTitle' => 'Máquinas', + 'nombre' => 'Nombre', + 'observaciones' => 'Observaciones', + 'ordenPlanning' => 'Orden Planning', + 'padreId' => 'Variante', + 'precioHoraCorte' => 'Precio Hora Corte', + 'precioTintaColor' => 'Precio Tinta Color', + 'precioTintaNegro' => 'Precio Tinta Negro', + 'tipo' => 'Tipo', + 'updatedAt' => 'Updated At', + 'userCreatedId' => 'User Created ID', + 'userUpdatedId' => 'User Updated ID', + 'velocidad' => 'Velocidad', + 'velocidadCorte' => 'Velocidad Corte', + 'validation' => [ + 'alto' => [ + 'decimal' => 'El campo {field} debe contener un número decimal.', + + ], + + 'ancho' => [ + 'decimal' => 'El campo {field} debe contener un número decimal.', + + ], + + 'forzar_num_formas_horizontales_portada' => [ + 'integer' => 'El campo {field} debe contener un número entero.', + + ], + + 'forzar_num_formas_verticales_portada' => [ + 'integer' => 'El campo {field} debe contener un número entero.', + + ], + + 'alto_click' => [ + 'decimal' => 'El campo {field} debe contener un número decimal.', + 'required' => 'El campo {field} es obligatorio.', + + ], + + 'alto_impresion' => [ + 'decimal' => 'El campo {field} debe contener un número decimal.', + 'required' => 'El campo {field} es obligatorio.', + + ], + + 'ancho_impresion' => [ + 'decimal' => 'El campo {field} debe contener un número decimal.', + 'required' => 'El campo {field} es obligatorio.', + + ], + + 'duracion_jornada' => [ + 'integer' => 'El campo {field} debe contener un número entero.', + 'required' => 'El campo {field} es obligatorio.', + + ], + + 'max' => [ + 'integer' => 'El campo {field} debe contener un número entero.', + 'required' => 'El campo {field} es obligatorio.', + + ], + + 'metrosxminuto' => [ + 'max_length' => 'El campo {field} no puede exeder de {param} caracteres de longitud.', + 'required' => 'El campo {field} es obligatorio.', + + ], + + 'min' => [ + 'integer' => 'El campo {field} debe contener un número entero.', + 'required' => 'El campo {field} es obligatorio.', + + ], + + 'nombre' => [ + 'max_length' => 'El campo {field} no puede exeder de {param} caracteres de longitud.', + 'required' => 'El campo {field} es obligatorio.', + + ], + + 'observaciones' => [ + 'max_length' => 'El campo {field} no puede exeder de {param} caracteres de longitud.', + 'required' => 'El campo {field} es obligatorio.', + + ], + + 'orden_planning' => [ + 'integer' => 'El campo {field} debe contener un número entero.', + 'required' => 'El campo {field} es obligatorio.', + + ], + + 'precio_hora_corte' => [ + 'decimal' => 'El campo {field} debe contener un número decimal.', + 'required' => 'El campo {field} es obligatorio.', + + ], + + 'precio_tinta_color' => [ + 'decimal' => 'El campo {field} debe contener un número decimal.', + 'required' => 'El campo {field} es obligatorio.', + + ], + + 'precio_tinta_negro' => [ + 'decimal' => 'El campo {field} debe contener un número decimal.', + 'required' => 'El campo {field} es obligatorio.', + + ], + + 'tipo' => [ + 'in_list' => 'El campo {field} debe ser uno uno de: {param}.', + 'required' => 'El campo {field} es obligatorio.', + + ], + + 'velocidad' => [ + 'decimal' => 'El campo {field} debe contener un número decimal.', + 'required' => 'El campo {field} es obligatorio.', + + ], + + 'velocidad_corte' => [ + 'decimal' => 'El campo {field} debe contener un número decimal.', + 'required' => 'El campo {field} es obligatorio.', + + ], + + + ], + + +]; \ No newline at end of file diff --git a/ci4/app/Language/es/MaquinasPapelImpresion.php b/ci4/app/Language/es/MaquinasPapelImpresion.php new file mode 100644 index 00000000..a9bc0ce8 --- /dev/null +++ b/ci4/app/Language/es/MaquinasPapelImpresion.php @@ -0,0 +1,10 @@ + 'Activo', + 'gramaje_duplicado' => 'No se pueden seleccionar dos papeles con el mismo gramaje', + 'sureToChangeRotativaTitle' => 'Está seguro de cambiar esta opción?', + 'sureToChangeRotativaText' => 'Está operación no se puede deshacer y cambiará la lista de papeles.', +]; \ No newline at end of file diff --git a/ci4/app/Language/es/MaquinasTarifasImpresions.php b/ci4/app/Language/es/MaquinasTarifasImpresions.php new file mode 100644 index 00000000..e7deb3eb --- /dev/null +++ b/ci4/app/Language/es/MaquinasTarifasImpresions.php @@ -0,0 +1,55 @@ + 'Created At', + 'deletedAt' => 'Deleted At', + 'id' => 'ID', + 'isDeleted' => 'Is Deleted', + 'maquinaId' => 'Maquina', + 'maquinasTarifaImpresion' => 'Tarifa Impresion Máquinas ', + 'maquinasTarifaImpresionList' => 'Lista Tarifas Impresion Máquinas', + 'maquinasTarifasImpresion' => 'Tarifas Impresion Máquinas', + 'maquinastarifasimpresion' => 'Tarifas Impresion Máquinas', + 'moduleTitle' => 'Tarifas Impresion máquina', + 'precio' => 'Precio', + 'predeterminado' => 'Predeterminado', + 'tipo' => 'Tipo', + 'updatedAt' => 'Updated At', + 'userCreatedId' => 'User Created ID', + 'userUpdatedId' => 'User Updated ID', + 'uso' => 'Uso', + 'interior' => 'Interior', + 'cubierta' => 'Cubierta', + 'sobrecubierta' => 'Sobrecubierta', + 'negro' => 'Negro', + 'color' => 'Color', + 'negrohq' => 'Negro HQ', + 'bicolor' => 'Bicolor', + 'validation' => [ + 'duplicated_uso_tipo' => "Línea duplicada (la combinación 'uso' y 'tipo' ya existe)", + 'cubierta_sobrecubierta_color' => "Cubierta y sobrecubierta solo permiten tipo 'color'", + 'tipo' => [ + 'in_list' => 'El campo {field} debe contener uno de: {param}.', + 'required' => 'Campo obligatorio.', + + ], + + 'precio' => [ + 'decimal' => 'El campo {field} debe contener un número decimal.', + 'required' => 'Campo obligatorio.', + + ], + + 'uso' => [ + 'max_length' => 'El campo {field} no puede exceder de {param} caracteres de longitud.', + 'required' => 'Campo obligatorio.', + + ], + + + ], + + +]; \ No newline at end of file diff --git a/ci4/app/Language/es/PapelImpresion.php b/ci4/app/Language/es/PapelImpresion.php index 766a61e1..7e22e308 100644 --- a/ci4/app/Language/es/PapelImpresion.php +++ b/ci4/app/Language/es/PapelImpresion.php @@ -9,6 +9,7 @@ return [ 'color' => 'Color', 'createdAt' => 'Creado en', 'cubierta' => 'Cubierta', + 'sobrecubierta' => 'Sobrecubierta', 'defecto' => 'Por defecto', 'deletedAt' => 'Borrado en', 'espesor' => 'Espesor', @@ -25,12 +26,12 @@ return [ 'papelesImpresion' => 'Papeles Impresión', 'papelesimpresion' => 'Papeles Impresión', 'pesoPorPliego' => 'Peso Por Pliego', - 'portada' => 'Portada', 'precioPliego' => 'Precio Pliego', 'precioTonelada' => 'Precio Tonelada', 'referencia' => 'Referencia', 'rotativa' => 'Rotativa', 'updatedAt' => 'Actualizado en', + 'activo' => 'Activo?', 'userUpdateId' => 'ID usuario actualización', 'consumo_tintas_rotativas' => 'Consumo tintas rotativas', diff --git a/ci4/app/Models/Configuracion/MaquinaModel.php b/ci4/app/Models/Configuracion/MaquinaModel.php new file mode 100644 index 00000000..78540f6e --- /dev/null +++ b/ci4/app/Models/Configuracion/MaquinaModel.php @@ -0,0 +1,325 @@ + "t1.id", + 0 => "t1.nombre", + 1 => "t2.nombre", + 2 => "t1.tipo", + 3 => "t1.velocidad", + 4 => "t1.duracion_jornada", + 5 => "t1.ancho", + 6 => "t1.alto", + 7 => "t1.ancho_impresion", + 8 => "t1.alto_impresion", + 9 => "t1.orden_planning", + 10 => "t1.min", + 11 => "t1.max", + + + ]; + + protected $allowedFields = [ + "nombre", + "is_padre", + "tipo", + "velocidad", + "ancho", + "alto", + "ancho_impresion", + "alto_impresion", + "alto_click", + "padre_id", + "min", + "max", + "duracion_jornada", + "orden_planning", + "is_rotativa", + "precio_tinta_negro", + "is_tinta", + "precio_tinta_color", + "velocidad_corte", + "precio_hora_corte", + "metrosxminuto", + "forzar_num_formas_horizontales_portada", + "forzar_num_formas_verticales_portada", + "observaciones", + "deleted_at", + "is_deleted", + "user_created_id", + "user_updated_id" + ]; + protected $returnType = "App\Entities\Configuracion\Maquina"; + + protected $useTimestamps = true; + protected $useSoftDeletes = false; + + protected $createdField = "created_at"; + + public static $labelField = "nombre"; + + protected $validationRules = [ + "alto" => [ + "label" => "Maquinas.alto", + "rules" => "required|decimal", + ], + "alto_click" => [ + "label" => "Maquinas.altoClick", + "rules" => "required|decimal", + ], + "alto_impresion" => [ + "label" => "Maquinas.altoImpresion", + "rules" => "required|decimal", + ], + "ancho" => [ + "label" => "Maquinas.ancho", + "rules" => "required|decimal", + ], + "ancho_impresion" => [ + "label" => "Maquinas.anchoImpresion", + "rules" => "required|decimal", + ], + "duracion_jornada" => [ + "label" => "Maquinas.duracionJornada", + "rules" => "required|integer", + ], + "forzar_num_formas_horizontales_portada" => [ + "label" => "Maquinas.forzarNumFormasHorizontalesPortada", + "rules" => "integer|permit_empty", + ], + "forzar_num_formas_verticales_portada" => [ + "label" => "Maquinas.forzarNumFormasVerticalesPortada", + "rules" => "integer|permit_empty", + ], + "max" => [ + "label" => "Maquinas.max", + "rules" => "required|integer", + ], + "metrosxminuto" => [ + "label" => "Maquinas.metrosxminuto", + "rules" => "max_length[31]", + ], + "min" => [ + "label" => "Maquinas.min", + "rules" => "required|integer", + ], + "nombre" => [ + "label" => "Maquinas.nombre", + "rules" => "trim|required|max_length[255]", + ], + "observaciones" => [ + "label" => "Maquinas.observaciones", + "rules" => "trim|max_length[16313]", + ], + "orden_planning" => [ + "label" => "Maquinas.ordenPlanning", + "rules" => "required|integer", + ], + "precio_hora_corte" => [ + "label" => "Maquinas.precioHoraCorte", + "rules" => "decimal", + ], + "precio_tinta_color" => [ + "label" => "Maquinas.precioTintaColor", + "rules" => "decimal", + ], + "precio_tinta_negro" => [ + "label" => "Maquinas.precioTintaNegro", + "rules" => "decimal", + ], + "tipo" => [ + "label" => "Maquinas.tipo", + "rules" => "required|in_list[impresion,manipulado,acabado]", + ], + "velocidad" => [ + "label" => "Maquinas.velocidad", + "rules" => "required|decimal", + ], + "velocidad_corte" => [ + "label" => "Maquinas.velocidadCorte", + "rules" => "decimal", + ], + ]; + + protected $validationMessages = [ + "alto" => [ + "decimal" => "Maquinas.validation.alto.decimal", + ], + "alto_click" => [ + "decimal" => "Maquinas.validation.alto_click.decimal", + "required" => "Maquinas.validation.alto_click.required", + ], + "alto_impresion" => [ + "decimal" => "Maquinas.validation.alto_impresion.decimal", + "required" => "Maquinas.validation.alto_impresion.required", + ], + "ancho" => [ + "decimal" => "Maquinas.validation.ancho.decimal", + ], + "ancho_impresion" => [ + "decimal" => "Maquinas.validation.ancho_impresion.decimal", + "required" => "Maquinas.validation.ancho_impresion.required", + ], + "duracion_jornada" => [ + "integer" => "Maquinas.validation.duracion_jornada.integer", + "required" => "Maquinas.validation.duracion_jornada.required", + ], + "forzar_num_formas_horizontales_portada" => [ + "integer" => "Maquinas.validation.forzar_num_formas_horizontales_portada.integer", + ], + "forzar_num_formas_verticales_portada" => [ + "integer" => "Maquinas.validation.forzar_num_formas_verticales_portada.integer", + ], + "max" => [ + "integer" => "Maquinas.validation.max.integer", + "required" => "Maquinas.validation.max.required", + ], + "metrosxminuto" => [ + "max_length" => "Maquinas.validation.metrosxminuto.max_length", + "required" => "Maquinas.validation.metrosxminuto.required", + ], + "min" => [ + "integer" => "Maquinas.validation.min.integer", + "required" => "Maquinas.validation.min.required", + ], + "nombre" => [ + "max_length" => "Maquinas.validation.nombre.max_length", + "required" => "Maquinas.validation.nombre.required", + ], + "observaciones" => [ + "max_length" => "Maquinas.validation.observaciones.max_length", + "required" => "Maquinas.validation.observaciones.required", + ], + "orden_planning" => [ + "integer" => "Maquinas.validation.orden_planning.integer", + "required" => "Maquinas.validation.orden_planning.required", + ], + "precio_hora_corte" => [ + "decimal" => "Maquinas.validation.precio_hora_corte.decimal", + "required" => "Maquinas.validation.precio_hora_corte.required", + ], + "precio_tinta_color" => [ + "decimal" => "Maquinas.validation.precio_tinta_color.decimal", + "required" => "Maquinas.validation.precio_tinta_color.required", + ], + "precio_tinta_negro" => [ + "decimal" => "Maquinas.validation.precio_tinta_negro.decimal", + "required" => "Maquinas.validation.precio_tinta_negro.required", + ], + "tipo" => [ + "in_list" => "Maquinas.validation.tipo.in_list", + "required" => "Maquinas.validation.tipo.required", + ], + "velocidad" => [ + "decimal" => "Maquinas.validation.velocidad.decimal", + "required" => "Maquinas.validation.velocidad.required", + ], + "velocidad_corte" => [ + "decimal" => "Maquinas.validation.velocidad_corte.decimal", + "required" => "Maquinas.validation.velocidad_corte.required", + ], + ]; + + public function findAllWithMaquinas(string $selcols = "*", int $limit = null, int $offset = 0) + { + $sql = + "SELECT t1." . + $selcols . + ", t2.nombre AS padre FROM " . + $this->table . + " t1 LEFT JOIN lg_maquinas t2 ON t1.padre_id = t2.id"; + if (!is_null($limit) && intval($limit) > 0) { + $sql .= " LIMIT " . $limit; + } + + if (!is_null($offset) && intval($offset) > 0) { + $sql .= " OFFSET " . $offset; + } + + $query = $this->db->query($sql); + $result = $query->getResultObject(); + return $result; + } + + /** + * Get resource data. + * + * @param string $search + * + * @return \CodeIgniter\Database\BaseBuilder + */ + public function getResource(string $search = "") + { + $builder = $this->db + ->table($this->table . " t1") + ->select( + "t1.id AS id, t1.nombre AS nombre, t1.is_padre AS is_padre, t1.tipo AS tipo, t1.velocidad AS velocidad, t1.ancho AS ancho, t1.alto AS alto, t1.ancho_impresion AS ancho_impresion, t1.alto_impresion AS alto_impresion, t1.alto_click AS alto_click, t1.min AS min, t1.max AS max, t1.duracion_jornada AS duracion_jornada, t1.orden_planning AS orden_planning, t1.is_rotativa AS is_rotativa, t1.precio_tinta_negro AS precio_tinta_negro, t1.is_tinta AS is_tinta, t1.precio_tinta_color AS precio_tinta_color, t1.velocidad_corte AS velocidad_corte, t1.precio_hora_corte AS precio_hora_corte, t1.metrosxminuto AS metrosxminuto, t1.forzar_num_formas_horizontales_portada AS forzar_num_formas_horizontales_portada, t1.forzar_num_formas_verticales_portada AS forzar_num_formas_verticales_portada, t1.observaciones AS observaciones, t2.nombre AS padre" + ); + $builder->join("lg_maquinas t2", "t1.padre_id = t2.id", "left"); + + //JJO + $builder->where("t1.is_deleted", 0); + + return empty($search) + ? $builder + : $builder + ->groupStart() + ->like("t1.id", $search) + ->orLike("t1.nombre", $search) + ->orLike("t1.tipo", $search) + ->orLike("t1.velocidad", $search) + ->orLike("t1.ancho", $search) + ->orLike("t1.alto", $search) + ->orLike("t1.ancho_impresion", $search) + ->orLike("t1.alto_impresion", $search) + ->orLike("t1.alto_click", $search) + ->orLike("t1.min", $search) + ->orLike("t1.max", $search) + ->orLike("t1.duracion_jornada", $search) + ->orLike("t1.orden_planning", $search) + ->orLike("t1.precio_tinta_negro", $search) + ->orLike("t1.precio_tinta_color", $search) + ->orLike("t1.velocidad_corte", $search) + ->orLike("t1.precio_hora_corte", $search) + ->orLike("t1.metrosxminuto", $search) + ->orLike("t1.forzar_num_formas_horizontales_portada", $search) + ->orLike("t1.forzar_num_formas_verticales_portada", $search) + ->orLike("t1.observaciones", $search) + ->orLike("t2.id", $search) + ->orLike("t1.id", $search) + ->orLike("t1.nombre", $search) + ->orLike("t1.tipo", $search) + ->orLike("t1.velocidad", $search) + ->orLike("t1.ancho", $search) + ->orLike("t1.alto", $search) + ->orLike("t1.ancho_impresion", $search) + ->orLike("t1.alto_impresion", $search) + ->orLike("t1.alto_click", $search) + ->orLike("t1.padre_id", $search) + ->orLike("t1.min", $search) + ->orLike("t1.max", $search) + ->orLike("t1.duracion_jornada", $search) + ->orLike("t1.orden_planning", $search) + ->orLike("t1.precio_tinta_negro", $search) + ->orLike("t1.precio_tinta_color", $search) + ->orLike("t1.velocidad_corte", $search) + ->orLike("t1.precio_hora_corte", $search) + ->orLike("t1.metrosxminuto", $search) + ->orLike("t1.forzar_num_formas_horizontales_portada", $search) + ->orLike("t1.forzar_num_formas_verticales_portada", $search) + ->orLike("t1.observaciones", $search) + ->orLike("t2.nombre", $search) + ->groupEnd(); + } +} diff --git a/ci4/app/Models/Configuracion/MaquinasPapelesImpresionModel.php b/ci4/app/Models/Configuracion/MaquinasPapelesImpresionModel.php new file mode 100644 index 00000000..81b5e042 --- /dev/null +++ b/ci4/app/Models/Configuracion/MaquinasPapelesImpresionModel.php @@ -0,0 +1,196 @@ + "t1.active", + 1 => "t4.nombre", + 2 => "t3.nombre", + 3 => "t3.gramaje", + 4 => "t3.bn", + 5 => "t3.color", + 6 => "t3.cubierta", + 7 => "t3.sobrecubierta", + 8 => "t3.rotativa", + ]; + + protected $allowedFields = ["maquina_id", "papel_impresion_id", "active"]; + protected $returnType = "App\Entities\Configuracion\MaquinasPapelesImpresionEntity"; + + + /** + * Get resource data. + * + * @param string $search + * + * @return \CodeIgniter\Database\BaseBuilder + */ + public function getResource(string $search = "", $isRotativa = 0, $tarifas = [], $maquina_id = -1) + { + $builder = $this->db + ->table($this->table . " t1") + ->select( + "t1.maquina_id AS maquina_id, t1.papel_impresion_id AS papel_impresion_id, t1.active AS active, t2.nombre AS maquina, + t3.nombre AS papel_impresion, t3.gramaje AS gramaje, , t3.bn AS bn, t3.color AS color, t3.cubierta AS cubierta, , t3.sobrecubierta AS sobrecubierta, + t3.rotativa AS rotativa, t4.nombre as papel_generico" + ) + ->join("lg_papel_impresion t3", "t1.papel_impresion_id = t3.id", "left") + ->join("lg_maquinas t2", "t1.maquina_id = t2.id", "left") + ->join("lg_papel_generico t4", "t3.papel_generico_id = t4.id", "left"); + + $builder->where("t1.maquina_id", $maquina_id); + $builder->where("t2.is_deleted", 0); + $builder->where("t3.is_deleted", 0); + $builder->where("t4.is_deleted", 0); + $builder->where("t3.isActivo", 1); + + $builder->where("t3.rotativa", $isRotativa); + + $isFirst = true; + $where_str = "("; + //Si hay tarifas... + if (!empty($tarifas)){ + foreach ($tarifas as $tarifa){ + + if (!$isFirst) + $where_str .= ' OR '; + else{ + $isFirst = false; + } + if ($tarifa->uso == 'cubierta') + $where_str .= "t3.cubierta=1"; + else if ($tarifa->uso == 'sobrecubierta') + $where_str .= "t3.sobrecubierta=1"; + else{ + if ($tarifa->tipo == 'negro' || $tarifa->tipo == 'negrohq') + $where_str .= "t3.bn=1"; + else + $where_str .= "t3.color=1"; + } + } + $where_str .= ")"; + $builder->where(new RawSql($where_str)); + } + // si no hay tarifas no hay que devolver nada + else{ + // Se pone una condicion que no se puede dar + $builder->where("t3.bn", 2); + } + + + return empty($search) + ? $builder + : $builder + ->groupStart() + ->like("t2.nombre", $search) + ->orLike("t3.nombre", $search) + ->groupEnd(); + } + + public function getInitData($isRotativa = 0, $tarifas = [], $maquina_id = -1) + { + $builder = $this->db + ->table($this->table . " t1") + ->select( + "t1.*" + ); + + $builder->join("lg_papel_impresion t2", "t1.papel_impresion_id = t2.id", "left"); + + $builder->where("t1.maquina_id", $maquina_id); + $builder->where("t2.is_deleted", 0); + $builder->where("t2.isActivo", 1); + $builder->where("t2.rotativa", $isRotativa); + $builder->where("t1.active", 1); + + $isFirst = true; + $where_str = "("; + //Si hay tarifas... + if (!empty($tarifas)){ + foreach ($tarifas as $tarifa){ + if (!$isFirst) + $where_str .= ' OR '; + else{ + $isFirst = false; + } + if ($tarifa->uso == 'cubierta') + $where_str .= "`t2`.`cubierta`=1"; + else if ($tarifa->uso == 'sobrecubierta') + $where_str .= "`t2`.`sobrecubierta`=1"; + else{ + if ($tarifa->tipo == 'negro' || $tarifa->tipo == 'negrohq') + $where_str .= "`t2`.`bn`=1 "; + else + $where_str .= "`t2`.`color`=1 "; + } + } + $where_str .= ")"; + $builder->where($where_str); + } + // si no hay tarifas no hay que devolver nada + else{ + // Se pone una condicion que no se puede dar + $builder->where("t2.bn", 2); + } + + return $builder; + } + + // Funcion para consultar los papeles activos con un gramaje + // determinado seleccionados para una máquina + public function getPapelActivo($maquina_id=-1, $gramaje=-1){ + $builder = $this->db + ->table($this->table . " t1") + ->select( + "t1.*" + ); + $builder->join("lg_papel_impresion t2", "t1.papel_impresion_id = t2.id", "left"); + + $builder->where('t1.active', 1); + $builder->where('t1.maquina_id', $maquina_id); + $builder->where('t2.gramaje', $gramaje); + + return $builder; + } + + + // Funcion que borra todos los registros de una máquina determinada + public function deleteRows($maquina_id = -1){ + $this->db + ->table($this->table . " t1") + ->where("maquina_id", $maquina_id) + ->delete(); + } + + + // Funcion que inserta valores en la tabla + public function insertRows($values = []){ + if (!empty($values)){ + $this->db->table($this->table)->insertBatch($values); + } + } + + // Funcion que actualiza valores en la tabla + public function updateRows($values = []){ + if (!empty($values)){ + foreach($values as $value){ + $builder = $this->db->table($this->table)->where('maquina_id', $value['maquina_id']); + $builder->where('papel_impresion_id', $value['papel_impresion_id']); + $builder->update($value); + } + + } + } +} diff --git a/ci4/app/Models/Configuracion/MaquinasTarifasImpresionModel.php b/ci4/app/Models/Configuracion/MaquinasTarifasImpresionModel.php new file mode 100644 index 00000000..baa68e59 --- /dev/null +++ b/ci4/app/Models/Configuracion/MaquinasTarifasImpresionModel.php @@ -0,0 +1,119 @@ + "t1.tipo", + 2 => "t1.uso", + 3 => "t1.precio", + ]; + + protected $allowedFields = ["maquina_id", "tipo", "precio", "uso", "user_created_id", "user_updated_id", "is_deleted", "deleted_at", "created_at", "updated_at"]; + protected $returnType = "App\Entities\Configuracion\MaquinasTarifasImpresionEntity"; + + protected $useTimestamps = true; + protected $useSoftDeletes = false; + + protected $createdField = "created_at"; + + protected $updatedField = "updated_at"; + + public static $labelField = "maquina_id"; + + protected $validationRules = [ + "precio" => [ + "label" => "MaquinasTarifasImpresions.precio", + "rules" => "required|decimal", + ], + "tipo" => [ + "label" => "MaquinasTarifasImpresions.tipo", + "rules" => "permit_empty|in_list[negro,color,negrohq,bicolor]", + ], + "uso" => [ + "label" => "MaquinasTarifasImpresions.uso", + "rules" => "trim|required|max_length[255]", + ], + ]; + + protected $validationMessages = [ + "precio" => [ + "decimal" => "MaquinasTarifasImpresions.validation.precio.decimal", + "required" => "MaquinasTarifasImpresions.validation.precio.required", + ], + "tipo" => [ + "in_list" => "MaquinasTarifasImpresions.validation.tipo.in_list", + ], + "uso" => [ + "max_length" => "MaquinasTarifasImpresions.validation.uso.max_length", + "required" => "MaquinasTarifasImpresions.validation.uso.required", + ], + ]; + + public function findAllWithMaquinas(string $selcols = "*", int $limit = null, int $offset = 0) + { + $sql = + "SELECT t1." . + $selcols . + ", t2.nombre AS maquina FROM " . + $this->table . + " t1 LEFT JOIN lg_maquinas t2 ON t1.maquina_id = t2.id"; + if (!is_null($limit) && intval($limit) > 0) { + $sql .= " LIMIT " . $limit; + } + + if (!is_null($offset) && intval($offset) > 0) { + $sql .= " OFFSET " . $offset; + } + + $query = $this->db->query($sql); + $result = $query->getResultObject(); + return $result; + } + + /** + * Get resource data. + * + * @param string $search + * + * @return \CodeIgniter\Database\BaseBuilder + */ + public function getResource(string $search = "", $maquina_id=-1) + { + $builder = $this->db + ->table($this->table . " t1") + ->select( + "t1.id AS id, t1.tipo AS tipo, t1.precio AS precio, t1.uso AS uso" + ); + + //JJO + $builder->where('maquina_id', $maquina_id); + $builder->where("t1.is_deleted", 0); + + $builder->join("lg_maquinas t2", "t1.maquina_id = t2.id", "left"); + + return empty($search) + ? $builder + : $builder + ->groupStart() + ->like("t1.id", $search) + ->orLike("t1.tipo", $search) + ->orLike("t1.precio", $search) + ->orLike("t1.uso", $search) + ->orLike("t1.id", $search) + ->orLike("t1.maquina_id", $search) + ->orLike("t1.tipo", $search) + ->orLike("t1.precio", $search) + ->orLike("t1.uso", $search) + ->groupEnd(); + } +} diff --git a/ci4/app/Models/Configuracion/PapelImpresionModel.php b/ci4/app/Models/Configuracion/PapelImpresionModel.php index 377ea3b4..7e71af37 100644 --- a/ci4/app/Models/Configuracion/PapelImpresionModel.php +++ b/ci4/app/Models/Configuracion/PapelImpresionModel.php @@ -63,9 +63,10 @@ class PapelImpresionModel extends \App\Models\GoBaseModel "precio_pliego", "bn", "color", - "portada", "cubierta", + "sobrecubierta", "rotativa", + "isActivo", "deleted_at", "is_deleted", "user_update_id", @@ -83,95 +84,95 @@ class PapelImpresionModel extends \App\Models\GoBaseModel protected $validationRules = [ "alto" => [ - "label" => "PapelImpresions.alto", + "label" => "PapelImpresion.alto", "rules" => "required|decimal", ], "ancho" => [ - "label" => "PapelImpresions.ancho", + "label" => "PapelImpresion.ancho", "rules" => "required|decimal", ], "espesor" => [ - "label" => "PapelImpresions.espesor", + "label" => "PapelImpresion.espesor", "rules" => "required|decimal", ], "gramaje" => [ - "label" => "PapelImpresions.gramaje", + "label" => "PapelImpresion.gramaje", "rules" => "required|decimal", ], "mano" => [ - "label" => "PapelImpresions.mano", + "label" => "PapelImpresion.mano", "rules" => "required|decimal", ], "margen" => [ - "label" => "PapelImpresions.margen", + "label" => "PapelImpresion.margen", "rules" => "required|max_length[31]", ], "nombre" => [ - "label" => "PapelImpresions.nombre", + "label" => "PapelImpresion.nombre", "rules" => "trim|required|max_length[255]", ], "peso_por_pliego" => [ - "label" => "PapelImpresions.pesoPorPliego", + "label" => "PapelImpresion.pesoPorPliego", "rules" => "required|decimal", ], "precio_pliego" => [ - "label" => "PapelImpresions.precioPliego", + "label" => "PapelImpresion.precioPliego", "rules" => "required|decimal", ], "precio_tonelada" => [ - "label" => "PapelImpresions.precioTonelada", + "label" => "PapelImpresion.precioTonelada", "rules" => "required|decimal", ], "referencia" => [ - "label" => "PapelImpresions.referencia", - "rules" => "trim|required|max_length[13]", + "label" => "PapelImpresion.referencia", + "rules" => "trim|max_length[13]", ], ]; protected $validationMessages = [ "alto" => [ - "decimal" => "PapelImpresions.validation.alto.decimal", - "required" => "PapelImpresions.validation.alto.required", + "decimal" => "PapelImpresion.validation.alto.decimal", + "required" => "PapelImpresion.validation.alto.required", ], "ancho" => [ - "decimal" => "PapelImpresions.validation.ancho.decimal", - "required" => "PapelImpresions.validation.ancho.required", + "decimal" => "PapelImpresion.validation.ancho.decimal", + "required" => "PapelImpresion.validation.ancho.required", ], "espesor" => [ - "decimal" => "PapelImpresions.validation.espesor.decimal", - "required" => "PapelImpresions.validation.espesor.required", + "decimal" => "PapelImpresion.validation.espesor.decimal", + "required" => "PapelImpresion.validation.espesor.required", ], "gramaje" => [ - "decimal" => "PapelImpresions.validation.gramaje.decimal", - "required" => "PapelImpresions.validation.gramaje.required", + "decimal" => "PapelImpresion.validation.gramaje.decimal", + "required" => "PapelImpresion.validation.gramaje.required", ], "mano" => [ - "decimal" => "PapelImpresions.validation.mano.decimal", - "required" => "PapelImpresions.validation.mano.required", + "decimal" => "PapelImpresion.validation.mano.decimal", + "required" => "PapelImpresion.validation.mano.required", ], "margen" => [ - "max_length" => "PapelImpresions.validation.margen.max_length", - "required" => "PapelImpresions.validation.margen.required", + "max_length" => "PapelImpresion.validation.margen.max_length", + "required" => "PapelImpresion.validation.margen.required", ], "nombre" => [ - "max_length" => "PapelImpresions.validation.nombre.max_length", - "required" => "PapelImpresions.validation.nombre.required", + "max_length" => "PapelImpresion.validation.nombre.max_length", + "required" => "PapelImpresion.validation.nombre.required", ], "peso_por_pliego" => [ - "decimal" => "PapelImpresions.validation.peso_por_pliego.decimal", - "required" => "PapelImpresions.validation.peso_por_pliego.required", + "decimal" => "PapelImpresion.validation.peso_por_pliego.decimal", + "required" => "PapelImpresion.validation.peso_por_pliego.required", ], "precio_pliego" => [ - "decimal" => "PapelImpresions.validation.precio_pliego.decimal", - "required" => "PapelImpresions.validation.precio_pliego.required", + "decimal" => "PapelImpresion.validation.precio_pliego.decimal", + "required" => "PapelImpresion.validation.precio_pliego.required", ], "precio_tonelada" => [ - "decimal" => "PapelImpresions.validation.precio_tonelada.decimal", - "required" => "PapelImpresions.validation.precio_tonelada.required", + "decimal" => "PapelImpresion.validation.precio_tonelada.decimal", + "required" => "PapelImpresion.validation.precio_tonelada.required", ], "referencia" => [ - "max_length" => "PapelImpresions.validation.referencia.max_length", - "required" => "PapelImpresions.validation.referencia.required", + "max_length" => "PapelImpresion.validation.referencia.max_length", + //"required" => "PapelImpresion.validation.referencia.required", ], ]; @@ -208,11 +209,12 @@ class PapelImpresionModel extends \App\Models\GoBaseModel $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.ancho AS ancho, t1.alto AS alto, t1.mano AS mano, t1.espesor AS espesor, t1.gramaje AS gramaje, t1.precio_tonelada AS precio_tonelada, t1.margen AS margen, t1.peso_por_pliego AS peso_por_pliego, t1.precio_pliego AS precio_pliego, t1.bn AS bn, t1.color AS color, t1.portada AS portada, t1.cubierta AS cubierta, t1.rotativa AS rotativa, t2.nombre AS papel_generico_id" + "t1.id AS id, t1.nombre AS nombre, t1.defecto AS defecto, t1.referencia AS referencia, t1.ancho AS ancho, t1.alto AS alto, t1.mano AS mano, t1.espesor AS espesor, t1.gramaje AS gramaje, t1.precio_tonelada AS precio_tonelada, t1.margen AS margen, t1.peso_por_pliego AS peso_por_pliego, t1.precio_pliego AS precio_pliego, t1.bn AS bn, t1.color AS color, t1.cubierta AS cubierta, t1.sobrecubierta AS sobrecubierta, t1.rotativa AS rotativa, t1.isActivo AS isActivo, t2.nombre AS papel_generico_id" ); $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); } @@ -228,4 +230,47 @@ class PapelImpresionModel extends \App\Models\GoBaseModel ->orLike("t2.nombre", $search) ->groupEnd(); } + + public function getIdPapelesImpresion($maquina_id = -1, $tarifas = []) + { + $builder = $this->db + ->table($this->table . " t1") + ->select( + "'".$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 (!$isFirst) + $where_str .= ' OR '; + else{ + $isFirst = false; + } + if ($tarifa->uso == 'cubierta') + $where_str .= "`t1`.`cubierta`=1"; + else if ($tarifa->uso == 'sobrecubierta') + $where_str .= "`t1`.`sobrecubierta`=1"; + else{ + if ($tarifa->tipo == 'negro' || $tarifa->tipo == 'negrohq') + $where_str .= "`t1`.`bn`=1 "; + else + $where_str .= "`t1`.`color`=1 "; + } + } + $builder->where($where_str); + } + // si no hay tarifas no hay que devolver nada + else{ + // Se pone una condicion que no se puede dar + $builder->where("t1.bn", 2); + } + + return $builder; + } } diff --git a/ci4/app/Models/Tarifas/TarifaManipuladoModel.php b/ci4/app/Models/Tarifas/TarifaManipuladoModel.php index 97e95c09..35322769 100644 --- a/ci4/app/Models/Tarifas/TarifaManipuladoModel.php +++ b/ci4/app/Models/Tarifas/TarifaManipuladoModel.php @@ -21,7 +21,7 @@ class TarifaManipuladoModel extends \App\Models\GoBaseModel "deleted_at", "is_deleted", "user_created_id", - "user_update_id" + "user_updated_id" ]; protected $returnType = "App\Entities\Tarifas\TarifaManipuladoEntity"; diff --git a/ci4/app/Views/themes/backend/vuexy/form/configuracion/maquinas/_maquinaFormItems.php b/ci4/app/Views/themes/backend/vuexy/form/configuracion/maquinas/_maquinaFormItems.php new file mode 100644 index 00000000..fc9df714 --- /dev/null +++ b/ci4/app/Views/themes/backend/vuexy/form/configuracion/maquinas/_maquinaFormItems.php @@ -0,0 +1,299 @@ +
+
+ +
+ +
+
+ + +
+
+ +
+
+ + +
+
+ +
+
+ + +
+
+ +
+
+ + +
+
+ +
+
+ + +
+
+ +
+ + +
+ +
+
+ + +
+
+ +
+
+ + +
+
+ +
+
+ + +
+
+ +
+
+ + +
+
+ +
+
+ + +
+
+ +
+ + + +
+ +
+
+ + +
+
+ +
+
+ + +
+
+ +
+
+ + +
+
+ +
+
+ + +
+
+ +
+
+ +
+ +
+
+
+ +
+
+ +
+ +
+
+
+ +
+
+ +
+ +
+
+
+ + +
+ + +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ + +
+ +
+ +
+ +
+ +
+ + is_rotativa== false): ?> + + +
\ No newline at end of file diff --git a/ci4/app/Views/themes/backend/vuexy/form/configuracion/maquinas/viewMaquinaForm.php b/ci4/app/Views/themes/backend/vuexy/form/configuracion/maquinas/viewMaquinaForm.php new file mode 100644 index 00000000..224ae1a2 --- /dev/null +++ b/ci4/app/Views/themes/backend/vuexy/form/configuracion/maquinas/viewMaquinaForm.php @@ -0,0 +1,576 @@ +include("themes/_commonPartialsBs/datatables") ?> +include("themes/_commonPartialsBs/select2bs5") ?> +include("themes/_commonPartialsBs/sweetalert") ?> +extend('themes/backend/vuexy/main/defaultlayout') ?> +section("content") ?> +
+
+
+
+

+
+
+ +
+ + getErrors()) ? $validation->listErrors("bootstrap_style") : "" ?> + +
+ +
+
+
+
+ + + + +
+
+

+ +

+ +
+
+ + + + + + + + + + + + + +
+
+
+
+
+ + + + +
+
+

+ +

+ +
+
+ + + + + + + + + + + + + + + + + + +
+
+
+
+
+ + + +endSection() ?> + + +section("additionalInlineJs") ?> + + function watch(j) { + return new Proxy(JSON.parse ('{"watch":' + j + '}'), { + set: function(target, property, value) { + target[property] = value; + $('#tableOfPapelesImpresion').DataTable().ajax.reload(null,false); + theTable2.clearPipeline(); + theTable2.draw(); + + } + }); + } + + isRotativa = watch(0); + + + $(document).ready(function () { + if($(this).is(':checked')){ + + $("#datosRotativa").show(); + } + }); + + $('#isRotativa').on("click",function(el){ + + Swal.fire({ + title: '', + text: '', + icon: 'warning', + showCancelButton: true, + confirmButtonColor: '#3085d6', + confirmButtonText: '', + cancelButtonText: '', + cancelButtonColor: '#d33' + }) + .then((result) => { + if (result.value) { + + if($(this).is(':checked')){ + isRotativa.watch = 1; + $("#datosRotativa").show(); + }else{ + document.getElementById("precioTintaNegro").value = null; + document.getElementById("precioTintaColor").value = null; + document.getElementById("velocidadCorte").value = null; + document.getElementById("precioHoraCorte").value = null; + document.getElementById("metrosxminuto").value = null; + $("#datosRotativa").hide(); + isRotativa.watch = 0; + } + + theTable2.clearPipeline(); + theTable2.draw(); + yeniden(response.); + } + }); + }); + + $('#isPadre').on("click",function(el){ + if($(this).is(':checked')){ + + $("#selectVariante").show(); + }else{ + + $("#padreId").select2('val', -1); + $("#selectVariante").hide(); + } + }); + + $('#padreId').select2({ + theme: 'bootstrap-5', + 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 + }, + + }); + + const lastColNr = $('#tableOfTarifamanipuladolineas').find("tr:first th").length - 1; + const url = window.location.href; + const url_parts = url.split('/'); + if(url_parts[url_parts.length-2] == 'edit'){ + id = url_parts[url_parts.length-1]; + } + else{ + id = -1; + } + + const actionBtns = function(data) { + return ` + + + + `; + }; + + + usoTypes = [ + {label:'', value:'interior'}, + {label:'', value: 'cubierta'}, + {label:'', value: 'sobrecubierta'} + ]; + + tipoTypes = [ + {label:'', value:'negro'}, + {label:'', value: 'negrohq'}, + {label:'', value: 'bicolor'}, + {label:'', value: 'color'} + ]; + + editor = new $.fn.dataTable.Editor( { + ajax: { + url: "", + headers: { + : v, + }, + }, + table : "#tableOfMaquinastarifasimpresion", + idSrc: 'id', + fields: [ { + name: "uso", + type: "select", + options: usoTypes + }, { + name: "tipo", + type: "select", + options: tipoTypes + }, { + name: "precio", + attr: { + type: "number" + } + }, { + "name": "maquina_id", + "type": "hidden" + },{ + "name": "deleted_at", + "type": "hidden" + },{ + "name": "is_deleted", + "type": "hidden" + }, + ] + } ); + + + editor.on( 'preSubmit', function ( e, d, type ) { + if ( type === 'create'){ + d.data[0]['maquina_id'] = id; + } + else if(type === 'edit' ) { + for (v in d.data){ + d.data[v]['maquina_id'] = id; + } + } + }); + + + editor.on( 'postSubmit', function ( e, json, data, action ) { + + yeniden(json.); + + setTimeout(() => { + console.log("1 Segundo esperado") + }, 1000); + $.ajax({ + url: '', + data: { + maquina_id: id, + isRotativa: isRotativa.watch, + : v, + }, + method: 'POST', + headers: {'X-Requested-With': 'XMLHttpRequest'}, + success:function(response){ + + token=JSON.parse(response).; + yeniden(token); + + theTable.clearPipeline(); + theTable.draw(); + + theTable2.clearPipeline(); + theTable2.draw(); + } + }); + }); + + + editor2 = new $.fn.dataTable.Editor( { + ajax: { + url: "", + headers: { + : v, + }, + }, + table : "#tableOfPapelesImpresion", + idSrc: 'papel_impresion_id', + fields: [ + { + name: "active", + type: "checkbox", + separator: "|", + ipOpts: [ + { label: '', value: 1 } + ] + },{ + "name": "papel_impresion_id", + "type": "hidden" + },{ + "name": "gramaje", + "type": "hidden" + },{ + "name": "maquina_id", + "type": "hidden" + } + ] + } ); + + editor2.on( 'postSubmit', function ( e, json, data, action ) { + yeniden(json.); + if(json.error){ + document.getElementById("check_" + json.data.papel_impresion_id).checked = false; + Swal.fire({ + icon: 'error', + title: '', + text: json.error, + }); + } + }); + + + var theTable = $('#tableOfMaquinastarifasimpresion').DataTable( { + serverSide: true, + processing: true, + autoWidth: true, + responsive: true, + order: [[ 1, "asc" ]], + pageLength: 5, + lengthChange: false, + searching: false, + paging: true, + info: false, + dom: "Blt", + ajax : $.fn.dataTable.pipeline( { + url: '', + data: { + id_maquina: id, + }, + method: 'POST', + headers: {'X-Requested-With': 'XMLHttpRequest'}, + async: true, + }), + columns: [ + { 'data': 'uso', "render": function ( data, type, row, meta ) { + if(data=='interior') + return ''; + else if (data=='cubierta') + return ''; + else if (data=='sobrecubierta') + return ''; + } + }, + { 'data': 'tipo', "render": function ( data, type, row, meta ) { + if(data=='negro') + return ''; + else if (data=='negrohq') + return ''; + else if (data=='bicolor') + return ''; + else if (data=='color') + return ''; + } + }, + { 'data': 'precio' }, + { + data: actionBtns, + className: 'row-edit dt-center' + } + + ], + columnDefs: [ + { + orderable: false, + searchable: false, + targets: [lastColNr] + }, + {"orderData": [ 0, 1 ], "targets": 0 }, + + ], + language: { + url: "//cdn.datatables.net/plug-ins/1.13.4/i18n/i18n ?>.json" + }, + buttons: [ { + className: 'btn btn-primary float-end me-sm-3 me-1', + extend: "createInline", + editor: editor, + formOptions: { + submitTrigger: -1, + submitHtml: '' + } + } ] + } ); + + + var theTable2 = $('#tableOfPapelesImpresion').DataTable( { + serverSide: true, + processing: true, + autoWidth: true, + responsive: true, + lengthMenu: [ 5, 10, 25], + order: [[ 1, "asc" ]], + pageLength: 10, + lengthChange: true, + searching: true, + paging: true, + info: true, + dom: "lftp", + ajax : $.fn.dataTable.pipeline( { + url: '', + data: function (d) { + d.maquina_id = id; + d.isRotativa = isRotativa.watch; + d.webguard_token = ''; + }, + method: 'POST', + headers: {'X-Requested-With': 'XMLHttpRequest'}, + async: true, + }), + columns: [ + { 'data': 'active', + render: function (data, type, row) { + if (type === 'display') { + return ''; + } + return data; + }, + className: 'dt-body-center' + }, + { 'data': 'papel_generico'}, + { 'data': 'papel_impresion'}, + { 'data': 'gramaje'}, + { 'data': 'bn'}, + { 'data': 'color'}, + { 'data': 'cubierta'}, + { 'data': 'sobrecubierta'}, + { 'data': 'rotativa'} + ], + rowCallback: function (row, data) { + // Set the checked state of the checkbox in the table + $('input.editor-active', row).prop('checked', data.active == 1); + }, + language: { + url: "//cdn.datatables.net/plug-ins/1.13.4/i18n/i18n ?>.json" + }, + columnDefs: [ + { + searchable: false, + targets: [0,3,4,5,6,7,8] + } + ], + } ); + + + // Cuando se clica en un checkbox hacer submit en el editor + theTable2.on( 'change', 'input.editor-active', function () { + editor2 + .edit( $(this).closest('tr'), false ) + .set( 'active', $(this).prop( 'checked' ) ? 1 : 0 ) + .submit(); + } ); + + + // Activate an inline edit on click of a table cell + $('#tableOfMaquinastarifasimpresion').on( 'click', 'tbody span.edit', function (e) { + editor.inline( + theTable.cells(this.parentNode.parentNode, '*').nodes(), + { + cancelHtml: '', + cancelTrigger: 'span.cancel', + submitHtml: '', + submitTrigger: 'span.edit', + submit: 'allIfChanged' + } + ); + } ); + + theTable2.on( 'draw.dt', function () { + const boolCols = [4, 5, 6, 7, 8]; + for (let coln of boolCols) { + theTable2.column(coln, { page: 'current' }).nodes().each( function (cell, i) { + cell.innerHTML = cell.innerHTML == '1' ? '' : ''; + }); + } + }); + + // Delete row + $('#tableOfMaquinastarifasimpresion').on( 'click', 'tbody span.remove', function (e) { + + Swal.fire({ + title: '', + text: '', + icon: 'warning', + showCancelButton: true, + confirmButtonColor: '#3085d6', + confirmButtonText: '', + cancelButtonText: '', + cancelButtonColor: '#d33' + }) + .then((result) => { + const dataId = $(this).data('id'); + const row = $(this).closest('tr'); + if (result.value) { + editor + .create( false ) + .edit( this.parentNode, false) + .set( 'deleted_at', new Date().toISOString().slice(0, 19).replace('T', ' ') ) + .set( 'is_deleted', 1 ) + .submit(); + } + }); + }); + + + + +endSection() ?> + +section('css') ?> + + + +endSection() ?> + + +section('additionalExternalJs') ?> + + + + + + + + + + + + +endSection() ?> \ No newline at end of file diff --git a/ci4/app/Views/themes/backend/vuexy/form/configuracion/maquinas/viewMaquinaList.php b/ci4/app/Views/themes/backend/vuexy/form/configuracion/maquinas/viewMaquinaList.php new file mode 100644 index 00000000..35bc43c0 --- /dev/null +++ b/ci4/app/Views/themes/backend/vuexy/form/configuracion/maquinas/viewMaquinaList.php @@ -0,0 +1,190 @@ +include('themes/_commonPartialsBs/select2bs5') ?> +include('themes/_commonPartialsBs/datatables') ?> +include('themes/_commonPartialsBs/sweetalert') ?> +extend('themes/backend/vuexy/main/defaultlayout') ?> +section('content'); ?> +
+
+ +
+
+

+ 'btn btn-primary float-end']); ?> +
+
+ + + + + + + + + + + + + + + + + + + + + + + +
+
+ +
+
+
+ +endSection() ?> + + +section('additionalInlineJs') ?> + + const lastColNr = $('#tableOfMaquinas').find("tr:first th").length - 1; + const actionBtns = function(data) { + return ` +
+ + +
+ `; + }; + theTable = $('#tableOfMaquinas').DataTable({ + processing: true, + serverSide: true, + autoWidth: true, + responsive: true, + scrollX: true, + lengthMenu: [ 5, 10, 25, 50, 75, 100, 250, 500, 1000, 2500 ], + pageLength: 10, + lengthChange: true, + "dom": 'lfBrtip', + "buttons": [ + 'copy', 'csv', 'excel', 'print', { + extend: 'pdfHtml5', + orientation: 'landscape', + pageSize: 'A4' + } + ], + stateSave: true, + order: [[0, 'asc']], + language: { + url: "//cdn.datatables.net/plug-ins/1.13.4/i18n/i18n ?>.json" + }, + ajax : $.fn.dataTable.pipeline( { + url: '', + method: 'POST', + headers: {'X-Requested-With': 'XMLHttpRequest'}, + async: true, + }), + columnDefs: [ + { + orderable: false, + searchable: false, + targets: [lastColNr] + } + ], + columns : [ + { 'data': 'nombre' }, + { 'data': 'padre' }, + { 'data': 'tipo' }, + { 'data': 'velocidad' }, + { 'data': 'duracion_jornada' }, + { 'data': 'ancho' }, + { 'data': 'alto' }, + { 'data': 'ancho_impresion' }, + { 'data': 'alto_impresion' }, + { 'data': 'orden_planning' }, + { 'data': 'min' }, + { 'data': 'max' }, + { 'data': actionBtns } + ] + }); + + + theTable.on( 'draw.dt', function () { + const boolCols = []; + for (let coln of boolCols) { + theTable.column(coln, { page: 'current' }).nodes().each( function (cell, i) { + cell.innerHTML = cell.innerHTML == '1' ? '' : ''; + }); + } + + }); + +$(document).on('click', '.btn-edit', function(e) { + //window.location.href = `/${$(this).attr('data-id')}/edit`; + window.location.href = `/configuracion/maquinas/edit/${$(this).attr('data-id')}`; + }); + +$(document).on('click', '.btn-delete', function(e) { + Swal.fire({ + title: '', + text: '', + icon: 'warning', + showCancelButton: true, + confirmButtonColor: '#3085d6', + confirmButtonText: '', + cancelButtonText: '', + cancelButtonColor: '#d33' + }) + .then((result) => { + const dataId = $(this).data('id'); + const row = $(this).closest('tr'); + if (result.value) { + $.ajax({ + //url: `/${dataId}`, + //method: 'DELETE', + url: `/configuracion/maquinas/delete/${dataId}`, + method: 'GET', + }).done((data, textStatus, jqXHR) => { + Toast.fire({ + icon: 'success', + title: data.msg ?? jqXHR.statusText, + }); + + theTable.clearPipeline(); + theTable.row($(row)).invalidate().draw(); + }).fail((jqXHR, textStatus, errorThrown) => { + Toast.fire({ + icon: 'error', + title: jqXHR.responseJSON.messages.error, + }); + }) + } + }); + }); + + + + +endSection() ?> + + +section('css') ?> + +endSection() ?> + + +section('additionalExternalJs') ?> + + + + + + + + + + +endSection() ?> + diff --git a/ci4/app/Views/themes/backend/vuexy/form/configuracion/papel/_papelImpresionFormItems.php b/ci4/app/Views/themes/backend/vuexy/form/configuracion/papel/_papelImpresionFormItems.php index c88cce57..30633eab 100644 --- a/ci4/app/Views/themes/backend/vuexy/form/configuracion/papel/_papelImpresionFormItems.php +++ b/ci4/app/Views/themes/backend/vuexy/form/configuracion/papel/_papelImpresionFormItems.php @@ -10,9 +10,9 @@
- +
@@ -56,9 +56,9 @@
-
@@ -73,6 +73,16 @@
+
+
+ + +
+
+ @@ -142,9 +152,9 @@
-
diff --git a/ci4/app/Views/themes/backend/vuexy/form/configuracion/papel/viewPapelImpresionList.php b/ci4/app/Views/themes/backend/vuexy/form/configuracion/papel/viewPapelImpresionList.php index 4609724e..dbfbe5ae 100644 --- a/ci4/app/Views/themes/backend/vuexy/form/configuracion/papel/viewPapelImpresionList.php +++ b/ci4/app/Views/themes/backend/vuexy/form/configuracion/papel/viewPapelImpresionList.php @@ -22,9 +22,10 @@ - + + @@ -96,16 +97,17 @@ { 'data': 'gramaje' }, { 'data': 'bn' }, { 'data': 'color' }, - { 'data': 'portada' }, { 'data': 'cubierta' }, + { 'data': 'sobrecubierta' }, { 'data': 'rotativa' }, + { 'data': 'isActivo' }, { 'data': actionBtns } ] }); theTable.on( 'draw.dt', function () { - const boolCols = [3, 4, 5, 6, 7]; + const boolCols = [3, 4, 5, 6, 7, 8]; for (let coln of boolCols) { theTable.column(coln, { page: 'current' }).nodes().each( function (cell, i) { cell.innerHTML = cell.innerHTML == '1' ? '' : '';