diff --git a/ci4/app/Config/Routes.php b/ci4/app/Config/Routes.php index 47312296..a64fb69b 100644 --- a/ci4/app/Config/Routes.php +++ b/ci4/app/Config/Routes.php @@ -471,8 +471,9 @@ $routes->group('cosidotapablanda', ['namespace' => 'App\Controllers\Presupuestos $routes->post('add', 'Cosidotapablanda::add', ['as' => 'createCosidotapablanda']); $routes->post('create', 'Cosidotapablanda::create', ['as' => 'ajaxCreateCosidotapablanda']); $routes->put('(:num)/update', 'Cosidotapablanda::update/$1', ['as' => 'ajaxUpdateCosidotapablanda']); - $routes->post('(:num)/edit', 'Cosidotapablanda::edit/$1', ['as' => 'updateCosidotapablanda']); + $routes->post('edit/(:num)', 'Cosidotapablanda::edit/$1', ['as' => 'updateCosidotapablanda']); $routes->post('datatable', 'Cosidotapablanda::datatable', ['as' => 'dataTableOfCosidotapablanda']); + $routes->post('datatable_2', 'Cosidotapablanda::datatable_2', ['as' => 'updateDataOfCosidotapablanda']); $routes->post('allmenuitems', 'Cosidotapablanda::allItemsSelect', ['as' => 'select2ItemsOfCosidotapablanda']); $routes->post('menuitems', 'Cosidotapablanda::menuItems', ['as' => 'menuItemsOfCosidotapablanda']); }); diff --git a/ci4/app/Controllers/Clientes/Cliente.php b/ci4/app/Controllers/Clientes/Cliente.php index dc4ac6cb..f91714e1 100644 --- a/ci4/app/Controllers/Clientes/Cliente.php +++ b/ci4/app/Controllers/Clientes/Cliente.php @@ -312,11 +312,16 @@ class Cliente extends \App\Controllers\GoBaseResourceController $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); + try{ + $menu = $this->model->getSelect2MenuItems($columns2select, $columns2select[1], $onlyActiveOnes, $searchStr); + $nonItem = new \stdClass; + $nonItem->id = ''; + $nonItem->text = '- ' . lang('Basic.global.None') . ' -'; + array_unshift($menu, $nonItem); + } + catch(Exception $e){ + $menu = []; + } $newTokenHash = csrf_hash(); $csrfTokenName = csrf_token(); diff --git a/ci4/app/Controllers/GoBaseResourceController.php b/ci4/app/Controllers/GoBaseResourceController.php index 86433d87..8b210d98 100644 --- a/ci4/app/Controllers/GoBaseResourceController.php +++ b/ci4/app/Controllers/GoBaseResourceController.php @@ -255,18 +255,28 @@ abstract class GoBaseResourceController extends \CodeIgniter\RESTful\ResourceCon /** * Convenience method to validate form submission + * JJO: Se le añade las reglas y los mensajes custom * @return bool */ - protected function canValidate() + protected function canValidate($customValidationRules = null, $customValidationMessages = null) { - $validationRules = $this->model->validationRules ?? $this->formValidationRules ?? null; - + if($customValidationRules == null){ + $validationRules = $this->model->validationRules ?? $this->formValidationRules ?? null; + } + else{ + $validationRules = $customValidationRules; + } if ($validationRules == null) { return true; } - $validationErrorMessages = $this->model->validationMessages ?? $this->formValidationErrorMessagess ?? null;; + if($customValidationMessages == null){ + $validationErrorMessages = $this->model->validationMessages ?? $this->formValidationErrorMessagess ?? null;; + } + else{ + $validationErrorMessages = $customValidationMessages; + } if ($validationErrorMessages != null) { $valid = $this->validate($validationRules, $validationErrorMessages); diff --git a/ci4/app/Controllers/Presupuestos/Cosidotapablanda.php b/ci4/app/Controllers/Presupuestos/Cosidotapablanda.php index fa2e1b64..33f3924f 100644 --- a/ci4/app/Controllers/Presupuestos/Cosidotapablanda.php +++ b/ci4/app/Controllers/Presupuestos/Cosidotapablanda.php @@ -14,7 +14,7 @@ use App\Services\PresupuestoService; use App\Models\Configuracion\PapelImpresionModel; use App\Models\Configuracion\MaquinaModel; use App\Models\Configuracion\MaquinasTarifasImpresionModel; - +use Exception; class Cosidotapablanda extends \App\Controllers\GoBaseResourceController { @@ -96,10 +96,9 @@ class Cosidotapablanda extends \App\Controllers\GoBaseResourceController $sanitizedData['user_created_id'] = $session->id_user; $noException = true; - if ($successfulResult = $this->canValidate()) : // if ($successfulResult = $this->validate($this->formValidationRules) ) : + if ($successfulResult = $this->canValidate($this->model->validationRulesAdd, $this->model->validationMessagesAdd)) : // if ($successfulResult = $this->validate($this->formValidationRules) ) : - - if ($this->canValidate()) : + if ($this->canValidate($this->model->validationRulesAdd, $this->model->validationMessagesAdd)) : try { $successfulResult = $this->model->skipValidation(true)->save($sanitizedData); } catch (\Exception $e) { @@ -117,6 +116,9 @@ class Cosidotapablanda extends \App\Controllers\GoBaseResourceController $id = $this->model->db->insertID(); + $lp_model = model('App\Models\Presupuestos\PresupuestoLineaModel'); + $lp_model->createForPresupuesto($id); + $message = lang('Basic.global.saveSuccess', [lang('Basic.global.record')]) . '.'; if ($thenRedirect) : @@ -135,6 +137,126 @@ class Cosidotapablanda extends \App\Controllers\GoBaseResourceController endif; // ($requestMethod === 'post') $this->viewData['presupuestoEntity'] = isset($sanitizedData) ? new PresupuestoEntity($sanitizedData) : new PresupuestoEntity(); + $this->viewData['clienteList'] = $this->getClienteListItems($presupuestoEntity->cliente_id ?? null); + $this->viewData['incReiList'] = array('incidencia' => lang('Presupuestos.incidencia'), 'reimpresion' => lang('Presupuestos.reimpresion'), 'sin_cargo' => lang('Presupuestos.sinCargo')); + $this->viewData['paisList'] = $this->getPaisListItems(); + + $this->viewData['tipo_impresion_id'] = 4; // Cosido tapa blanda JJO + + $this->viewData['formAction'] = route_to('createCosidotapablanda'); + + $this->viewData['boxTitle'] = lang('Basic.global.addNew') . ' ' . lang('Presupuestos.moduleTitleCosidoTB') . ' ' . 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); + $presupuestoEntity = $this->model->find($id); + + if ($presupuestoEntity == false) : + $message = lang('Basic.global.notFoundWithIdErr', [mb_strtolower(lang('Presupuestos.presupuesto')), $id]); + return $this->redirect2listView('sweet-error', $message); + endif; + + $requestMethod = $this->request->getMethod(); + + if ($requestMethod === 'post') : + + $nullIfEmpty = true; // !(phpversion() >= '8.1'); + + $postData = $this->request->getPost(); + + $postData['updated_at'] = gmdate('Y-m-d H:m:s', time()); + + $sanitizedData = $this->sanitized($postData, $nullIfEmpty); + + // 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('Presupuestos.presupuesto'))]); + $this->session->setFlashdata('formErrors', $this->model->errors()); + + endif; + + $presupuestoEntity->fill($sanitizedData); + + $thenRedirect = false; + endif; + if ($noException && $successfulResult) : + $id = $presupuestoEntity->id ?? $id; + $message = lang('Basic.global.updateSuccess', [mb_strtolower(lang('Presupuestos.presupuesto'))]) . '.'; + // $message .= anchor("admin/presupuestos/{$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 : + if ($this->request->isAJAX()) { + $newTokenHash = csrf_hash(); + $csrfTokenName = csrf_token(); + $data = [ + 'mensaje' => $message, + $csrfTokenName => $newTokenHash + ]; + return $this->respond($data); + } + else{ + return $this->redirect2listView('sweet-success', $message); + } + + endif; + else : + if ($this->request->isAJAX()) { + $newTokenHash = csrf_hash(); + $csrfTokenName = csrf_token(); + $data = [ + 'mensaje' => $message, + $csrfTokenName => $newTokenHash + ]; + return $this->respond($data); + } + else{ + $this->session->setFlashData('sweet-success', $message); + } + endif; + + endif; // $noException && $successfulResult + endif; // ($requestMethod === 'post') + + + $this->viewData['presupuestoEntity'] = $presupuestoEntity; + + if(!is_null($presupuestoEntity->comparador_json_data)) + $this->viewData['comp_data'] = json_decode($presupuestoEntity->comparador_json_data); + else + $this->viewData['comp_data'] = ""; + + $this->viewData['clienteList'] = $this->getClienteListItems($presupuestoEntity->cliente_id ?? null); + $this->viewData['paisList'] = $this->getPaisListItems(); + $this->viewData['clienteList'] = $this->getClienteListItems($presupuestoEntity->cliente_id ?? null); $this->viewData['incReiList'] = array('incidencia' => lang('Presupuestos.incidencia'), 'reimpresion' => lang('Presupuestos.reimpresion'), 'sin_cargo' => lang('Presupuestos.sinCargo')); $this->viewData['paisList'] = $this->getPaisListItems(); @@ -148,209 +270,20 @@ class Cosidotapablanda extends \App\Controllers\GoBaseResourceController $this->viewData['papelGenericoRotativaNegroList'] = $this->getPapelGenericoRotativaNegro(); $this->viewData['papelGenericoRotativaColorList'] = $this->getPapelGenericoRotativaColor(); + // Lineas Presupuesto + $this->viewData['lineasPresupuesto'] = $this->getLineasPresupuestoActivas($id); + // Tarifas $this->viewData['serviciosPreimpresion'] = $this->getServiciosPreimpresion(); $this->viewData['serviciosEncuadernacion'] = $this->getServiciosEncuadernacion(); $this->viewData['serviciosAcabado'] = $this->getServiciosAcabado(); $this->viewData['serviciosManipulado'] = $this->getServiciosManipulado(); - $this->viewData['formAction'] = route_to('createCosidotapablanda'); + $this->viewData['tipo_impresion_id'] = 4; // Cosido tapa blanda JJO - $this->viewData['boxTitle'] = lang('Basic.global.addNew') . ' ' . lang('Presupuestos.moduleTitleCosidoTB') . ' ' . lang('Basic.global.addNewSuffix'); + $this->viewData['formAction'] = route_to('updateCosidotapablanda', $id); - /* TEST JS LOADER */ - //$this->viewData['global_js_variables'] = array('jsVarTest' => "'Hola Jaime'"); - - 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); - $presupuestoEntity = $this->model->find($id); - - if ($presupuestoEntity == false) : - $message = lang('Basic.global.notFoundWithIdErr', [mb_strtolower(lang('Presupuestos.presupuesto')), $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('recoger_en_taller') == null) { - $sanitizedData['recoger_en_taller'] = false; - } - if ($this->request->getPost('ferro') == null) { - $sanitizedData['ferro'] = false; - } - if ($this->request->getPost('ferro_digital') == null) { - $sanitizedData['ferro_digital'] = false; - } - if ($this->request->getPost('marcapaginas') == null) { - $sanitizedData['marcapaginas'] = false; - } - if ($this->request->getPost('papel_formato_personalizado') == null) { - $sanitizedData['papel_formato_personalizado'] = false; - } - if ($this->request->getPost('solapas') == null) { - $sanitizedData['solapas'] = false; - } - if ($this->request->getPost('cosido') == null) { - $sanitizedData['cosido'] = false; - } - if ($this->request->getPost('cubiertas') == null) { - $sanitizedData['cubiertas'] = false; - } - if ($this->request->getPost('imagenes_bn_interior') == null) { - $sanitizedData['imagenes_bn_interior'] = false; - } - if ($this->request->getPost('en_produccion') == null) { - $sanitizedData['en_produccion'] = false; - } - if ($this->request->getPost('en_espera') == null) { - $sanitizedData['en_espera'] = false; - } - if ($this->request->getPost('modo_comparador') == null) { - $sanitizedData['modo_comparador'] = false; - } - if ($this->request->getPost('paginas_negro_hq') == null) { - $sanitizedData['paginas_negro_hq'] = false; - } - if ($this->request->getPost('paginas_negro_check_papel_total') == null) { - $sanitizedData['paginas_negro_check_papel_total'] = false; - } - if ($this->request->getPost('paginas_negro_check_impresion_total') == null) { - $sanitizedData['paginas_negro_check_impresion_total'] = false; - } - if ($this->request->getPost('paginas_color_check_papel_total') == null) { - $sanitizedData['paginas_color_check_papel_total'] = false; - } - if ($this->request->getPost('paginas_color_check_impresion_total') == null) { - $sanitizedData['paginas_color_check_impresion_total'] = false; - } - if ($this->request->getPost('paginas_portada_check_papel_total') == null) { - $sanitizedData['paginas_portada_check_papel_total'] = false; - } - if ($this->request->getPost('paginas_portada_check_impresion_total') == null) { - $sanitizedData['paginas_portada_check_impresion_total'] = false; - } - if ($this->request->getPost('paginas_cubierta_papel_impresion_id') == null) { - $sanitizedData['paginas_cubierta_papel_impresion_id'] = false; - } - if ($this->request->getPost('paginas_cubierta_check_papel_total') == null) { - $sanitizedData['paginas_cubierta_check_papel_total'] = false; - } - if ($this->request->getPost('paginas_cubierta_check_impresion_total') == null) { - $sanitizedData['paginas_cubierta_check_impresion_total'] = false; - } - if ($this->request->getPost('isDig') == null) { - $sanitizedData['isDig'] = false; - } - if ($this->request->getPost('envios_recoge_cliente') == null) { - $sanitizedData['envios_recoge_cliente'] = false; - } - if ($this->request->getPost('fecha_entrega_real_aviso') == null) { - $sanitizedData['fecha_entrega_real_aviso'] = 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('Presupuestos.presupuesto'))]); - $this->session->setFlashdata('formErrors', $this->model->errors()); - - endif; - - $presupuestoEntity->fill($sanitizedData); - - $thenRedirect = true; - endif; - if ($noException && $successfulResult) : - $id = $presupuestoEntity->id ?? $id; - $message = lang('Basic.global.updateSuccess', [mb_strtolower(lang('Presupuestos.presupuesto'))]) . '.'; - $message .= anchor("admin/presupuestos/{$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['presupuestoEntity'] = $presupuestoEntity; - $this->viewData['clienteList'] = $this->getClienteListItems($presupuestoEntity->cliente_id ?? null); - $this->viewData['formaPagoList'] = $this->getFormaPagoListItems(); - $this->viewData['tiposImpresionList'] = $this->getTiposImpresionListItems($presupuestoEntity->tipo_impresion_id ?? null); - $this->viewData['tipologiasLibroList'] = $this->getTipologiasLibroListItems($presupuestoEntity->tipologia_id ?? null); - $this->viewData['paisList'] = $this->getPaisListItems(); - $this->viewData['ubicacionLibroList'] = $this->getUbicacionLibroListItems($presupuestoEntity->ubicacion_id ?? null); - $this->viewData['presupuestoEstadoList'] = $this->getPresupuestoEstadoListItems($presupuestoEntity->estado_id ?? null); - $this->viewData['papelFormatoList'] = $this->getPapelFormatoListItems($presupuestoEntity->papel_formato_id ?? null); - $this->viewData['papelGenericoList'] = $this->getPapelGenericoListItems($presupuestoEntity->paginas_negro_papel_id ?? null); - $this->viewData['papelImpresionList'] = $this->getPapelImpresionListItems($presupuestoEntity->paginas_negro_papel_impresion_id ?? null); - $this->viewData['maquinaList'] = $this->getMaquinaListItems($presupuestoEntity->paginas_negro_maquina_id ?? null); - $this->viewData['maquinasTarifasImpresionList'] = $this->getMaquinasTarifasImpresionListItems($presupuestoEntity->paginas_negro_tarifa_impresion_id ?? null); - $this->viewData['papelGenericoList2'] = $this->getPapelGenericoListItems2($presupuestoEntity->paginas_color_papel_id ?? null); - $this->viewData['papelImpresionList2'] = $this->getPapelImpresionListItems2($presupuestoEntity->paginas_color_papel_impresion_id ?? null); - $this->viewData['maquinaList2'] = $this->getMaquinaListItems2($presupuestoEntity->paginas_color_maquina_id ?? null); - $this->viewData['maquinasTarifasImpresionList2'] = $this->getMaquinasTarifasImpresionListItems2($presupuestoEntity->paginas_color_tarifa_impresion_id ?? null); - $this->viewData['papelGenericoList3'] = $this->getPapelGenericoListItems3($presupuestoEntity->paginas_portada_papel_id ?? null); - $this->viewData['papelImpresionList3'] = $this->getPapelImpresionListItems3($presupuestoEntity->paginas_portada_papel_impresion_id ?? null); - $this->viewData['maquinaList3'] = $this->getMaquinaListItems3($presupuestoEntity->paginas_portada_maquina_id ?? null); - $this->viewData['maquinasTarifasImpresionList3'] = $this->getMaquinasTarifasImpresionListItems3($presupuestoEntity->paginas_portada_tarifa_impresion_id ?? null); - $this->viewData['papelGenericoList4'] = $this->getPapelGenericoListItems4($presupuestoEntity->paginas_cubierta_papel_id ?? null); - $this->viewData['papelImpresionList4'] = $this->getPapelImpresionListItems4($presupuestoEntity->paginas_cubierta_papel_impresion_id ?? null); - $this->viewData['maquinaList4'] = $this->getMaquinaListItems4($presupuestoEntity->paginas_cubierta_maquina_id ?? null); - $this->viewData['maquinasTarifasImpresionList4'] = $this->getMaquinasTarifasImpresionListItems4($presupuestoEntity->paginas_cubierta_tarifa_impresion_id ?? null); - $this->viewData['userList'] = $this->getUserListItems($presupuestoEntity->total_confirmado_user_id ?? null); - $this->viewData['userList2'] = $this->getUserListItems2($presupuestoEntity->aprobado_user_id ?? null); - $this->viewData['userList3'] = $this->getUserListItems3($presupuestoEntity->pedido_espera_user_id ?? null); - $this->viewData['paginasCubiertaList'] = $this->getPaginasCubiertaOptions(); - $this->viewData['paginasPortadaList'] = $this->getPaginasPortadaOptions(); - - $this->viewData['papelGenericoNegroList'] = $this->getPapelGenericoNegro(); - $this->viewData['papelGenericoNegroHQList'] = $this->getPapelGenericoNegroHQ(); - $this->viewData['papelGenericoColorList'] = $this->getPapelGenericoColor(); - $this->viewData['papelGenericoColorHQList'] = $this->getPapelGenericoColorHQ(); - $this->viewData['papelGenericoCubiertaList'] = $this->getPapelGenericoCubierta(); - $this->viewData['papelGenericoSobrecubiertaList'] = $this->getPapelGenericoSobreCubierta(); - - $this->viewData['formAction'] = route_to('updatePresupuesto', $id); - - $this->viewData['boxTitle'] = lang('Basic.global.edit2') . ' ' . lang('Presupuestos.moduleTitle') . ' ' . lang('Basic.global.edit3'); + $this->viewData['boxTitle'] = lang('Basic.global.edit2') . ' ' . lang('Presupuestos.moduleTitleCosidoTB') . ' ' . lang('Basic.global.edit3'); return $this->displayForm(__METHOD__, $id); @@ -520,6 +453,50 @@ class Cosidotapablanda extends \App\Controllers\GoBaseResourceController } } + + public function datatable_2() + { + if ($this->request->isAJAX()) { + $reqData = $this->request->getPost(); + + $tipo = $reqData['tipo'] ?? ''; + + if($tipo=='lineasPresupuesto'){ + + $datos = $reqData['datos'] ?? null; + $presupuesto_id = $reqData['presupuesto_id'] ?? -1; + + /*foreach($datos as $key=>$linea){ + $datos[$key]['papel_id'] = $datos[$key]['papel_id'] ?? -1; + }*/ + + + if($datos != null){ + $this->updateLineasPresupuestoActivas($presupuesto_id, $datos); + } + $newTokenHash = csrf_hash(); + $csrfTokenName = csrf_token(); + $data = [ + $csrfTokenName => $newTokenHash + ]; + + return $this->respond($data); + } + + $newTokenHash = csrf_hash(); + $csrfTokenName = csrf_token(); + $data = [ + $csrfTokenName => $newTokenHash + ]; + + return $this->respond($data); + + } else { + return $this->failUnauthorized('Invalid request', 403); + } + } + + public function getCompIntData($uso, $datosPedido, $papel_generico, $gramaje, $isColor, $isHq) { $tipo = $isColor? ($isHq?'colorhq':'color'): ($isHq?'negrohq':'negro'); @@ -578,11 +555,14 @@ class Cosidotapablanda extends \App\Controllers\GoBaseResourceController foreach ($maquinas as $maquina) { $tarifamodel = new MaquinasTarifasImpresionModel(); - $tarifa = $tarifamodel->getTarifa($maquina->maquina_id, $uso, $tipo); + [$tarifaId, $tarifa] = $tarifamodel->getTarifa($maquina->maquina_id, $uso, $tipo); if(!is_float($tarifa)){ continue; } $linea = PresupuestoService::getCostesLinea($uso, $datosPedido, $maquina, $papel, $opciones_papel, $tarifa); + if(array_key_exists('error', $linea)) + continue; + $linea['fields']['tarifa_impresion_id'] = $tarifaId; $linea['fields']['maquina'] = $maquina->maquina; $linea['fields']['maquina_id'] = $maquina->maquina_id; $linea['fields']['maquina_velocidad'] = $maquina->velocidad; @@ -686,7 +666,7 @@ class Cosidotapablanda extends \App\Controllers\GoBaseResourceController $parametrosRotativa->a_favor_fibra = $i; $tarifamodel = new MaquinasTarifasImpresionModel(); - $tarifa = $tarifamodel->getTarifa($maquina->maquina_id, $uso, is_array($tipo)?'color':$tipo); + [$tarifaId, $tarifa] = $tarifamodel->getTarifa($maquina->maquina_id, $uso, is_array($tipo)?'color':$tipo); if(!is_float($tarifa)){ continue; } @@ -695,6 +675,9 @@ class Cosidotapablanda extends \App\Controllers\GoBaseResourceController $linea['fields'] = PresupuestoService::getCostesLineaRotativa($maquina, $papel, $datosPedido, $parametrosRotativa); $precio_pliego_impresion = PresupuestoService::getPrecioPliego($maquina, $papel, $datosPedido->paginas); + + $linea['fields']['tarifa_impresion_id'] = $tarifaId; + $linea['fields']['precios_pliegos'] = $precio_pliego_impresion; $linea['fields']['precio_libro'] = $linea['fields']['pliegos_libro'] * $precio_pliego_impresion; @@ -767,86 +750,96 @@ class Cosidotapablanda extends \App\Controllers\GoBaseResourceController if ($this->request->isAJAX()) { $reqData = $this->request->getPost(); + try{ - $tipo = $reqData['tipo'] ?? null; - $uso = $reqData['uso'] ?? null; - $datos = $reqData['datos'] ?? null; - //$searchStr = goSanitize($this->request->getPost('searchTerm'))[0]; + $tipo = $reqData['tipo'] ?? null; + $uso = $reqData['uso'] ?? null; + $datos = $reqData['datos'] ?? null; + //$searchStr = goSanitize($this->request->getPost('searchTerm'))[0]; - $newTokenHash = csrf_hash(); - $csrfTokenName = csrf_token(); + $newTokenHash = csrf_hash(); + $csrfTokenName = csrf_token(); - if ($tipo == 'gramaje') { - // En este caso contiene el nombre del papel generico - $model = new PapelGenericoModel(); - $menu = $model->getGramajeComparador($datos, $uso ); + if ($tipo == 'gramaje') { + // En este caso contiene el nombre del papel generico + $model = new PapelGenericoModel(); + $menu = $model->getGramajeComparador($datos, $uso ); - $data = [ - 'menu' => $menu, - $csrfTokenName => $newTokenHash - ]; - } - elseif ($tipo == 'gramajeLineasPresupuesto') { - $tipoLinea = $reqData['tipoLinea'] ?? null; - // En este caso contiene el id del papel generico - $model = new PapelGenericoModel(); - $menu = $model->getGramajeLineasPresupuesto($datos, $tipoLinea, $uso ); + $data = [ + 'menu' => $menu, + $csrfTokenName => $newTokenHash + ]; + } + elseif ($tipo == 'gramajeLineasPresupuesto') { + $tipoLinea = $reqData['tipoLinea'] ?? null; + // En este caso contiene el id del papel generico + $model = new PapelGenericoModel(); + $menu = $model->getGramajeLineasPresupuesto($datos, $tipoLinea, $uso ); - $data = [ - 'menu' => $menu, - $csrfTokenName => $newTokenHash - ]; - } - elseif ($tipo == 'papelImpresion') { - $gramaje = $reqData['gramaje'] ?? null; - $tipoLinea = $reqData['tipoLinea'] ?? null; - // En este caso contiene el nombre del papel generico - // Uso: negro, negrohq, color, colorhq, rot_bn, rot_color, - $model = new PapelImpresionModel(); - $menu = $model->getPapelesImpresionForMenu($datos, $gramaje, $tipoLinea, $uso ); + $data = [ + 'menu' => $menu, + $csrfTokenName => $newTokenHash + ]; + } + elseif ($tipo == 'papelImpresion') { + $gramaje = $reqData['gramaje'] ?? null; + $tipoLinea = $reqData['tipoLinea'] ?? null; + // En este caso contiene el nombre del papel generico + // Uso: negro, negrohq, color, colorhq, rot_bn, rot_color, + $model = new PapelImpresionModel(); + $menu = $model->getPapelesImpresionForMenu($datos, $gramaje, $tipoLinea, $uso ); - $data = [ - 'menu' => $menu, - $csrfTokenName => $newTokenHash - ]; - } - - elseif ($tipo == 'maquina') { - $is_rotativa = $reqData['is_rotativa'] ?? null; - $papel_impresion = $reqData['papel_impresion'] ?? null; - $tipo_linea = $reqData['tipoLinea'] ?? null; - $ancho = $reqData['ancho'] ?? null; - $alto = $reqData['alto'] ?? null; - // Datos contiene la tirada - // uso: negro, negrohq, color, colorhq, - $uso_tarifa = $reqData['uso_tarifa'] ?? 'interior'; - $model = new MaquinaModel(); - $maquinas = $model->getMaquinaImpresionForPresupuesto($is_rotativa, $uso, $uso_tarifa ,$datos, $papel_impresion ); - $menu = []; - foreach ($maquinas as $maquina){ - - $formas = PresupuestoService::getNumFormasPlana($tipo_linea, $maquina, floatval($ancho), floatval($alto), true); - - if($formas['num_formas'] != 'n/a'){ - array_push($menu, $maquina); - } + $data = [ + 'menu' => $menu, + $csrfTokenName => $newTokenHash + ]; } - $data = [ - 'menu' => $menu, - $csrfTokenName => $newTokenHash - ]; - } + elseif ($tipo == 'maquina') { + $is_rotativa = $reqData['is_rotativa'] ?? null; + $papel_impresion = $reqData['papel_impresion'] ?? null; + $tipo_linea = $reqData['tipoLinea'] ?? null; + $ancho = $reqData['ancho'] ?? null; + $alto = $reqData['alto'] ?? null; + // Datos contiene la tirada + // uso: negro, negrohq, color, colorhq, + $uso_tarifa = $reqData['uso_tarifa'] ?? 'interior'; + $model = new MaquinaModel(); + $maquinas = $model->getMaquinaImpresionForPresupuesto($is_rotativa, $uso, $uso_tarifa ,$datos, $papel_impresion ); + $menu = []; + foreach ($maquinas as $maquina){ + + $formas = PresupuestoService::getNumFormasPlana($tipo_linea, $maquina, floatval($ancho), floatval($alto), true); + + if($formas['num_formas'] != 'n/a'){ + array_push($menu, $maquina); + } + } - else{ - + $data = [ + 'menu' => $menu, + $csrfTokenName => $newTokenHash + ]; + } + + else{ + + $data = [ + 'tipo' => $tipo, + $csrfTokenName => $newTokenHash + ]; + } + } + catch(Exception $e){ $data = [ - 'tipo' => $tipo, + 'error' => $e, $csrfTokenName => $newTokenHash ]; } - - return $this->respond($data); + finally{ + return $this->respond($data); + } + } else { return $this->failUnauthorized('Invalid request', 403); } @@ -880,6 +873,7 @@ class Cosidotapablanda extends \App\Controllers\GoBaseResourceController { $papelFormatoModel = model('App\Models\Configuracion\PapelFormatoModel'); $data = $papelFormatoModel->getElementsForMenu(); + array_shift($data); array_unshift($data, (object)['id' => '', 'tamanio' => lang('Basic.global.pleaseSelectA', [mb_strtolower(lang('Presupuestos.papelFormatoId'))])]); return $data; } @@ -1017,7 +1011,26 @@ class Cosidotapablanda extends \App\Controllers\GoBaseResourceController return $data; } + protected function getLineasPresupuestoActivas($presupuesto_id) + { + $model = model('App\Models\Presupuestos\PresupuestoLineaModel'); + $data = $model->getLineasPresupuesto($presupuesto_id); + $papel_imp_model = model('App\Models\Configuracion\PapelImpresionModel'); + $maquina_model = model('App\Models\Configuracion\MaquinaModel'); + + foreach($data as $linea){ + $linea->papel_impresion_nombre = $papel_imp_model->getNombre($linea->papel_impresion_id)[0]->text; + $linea->maquina_nombre = $maquina_model->getNombre($linea->maquina_id)[0]->text; + } + return $data; + } + + protected function updateLineasPresupuestoActivas($presupuesto_id, $datos) + { + $model = model('App\Models\Presupuestos\PresupuestoLineaModel'); + return $model->updateLineasPresupuesto($presupuesto_id, $datos); + } } diff --git a/ci4/app/Controllers/Test.php b/ci4/app/Controllers/Test.php index f6f20f20..66a1e000 100644 --- a/ci4/app/Controllers/Test.php +++ b/ci4/app/Controllers/Test.php @@ -17,7 +17,34 @@ class Test extends BaseController public function index() { - $this->testLineasIntPlana(); + $this->getLP(); + } + + public function timeToSeconds(){ + $time = '99:59:59'; + + $time_parts = explode(":", $time); + $seconds = $time_parts[2] + $time_parts[1] * 60 + $time_parts[0] * 3600; + echo "Time in seconds: " . $seconds; + } + + public function getLP(){ + $lp_model = model('App\Models\Presupuestos\PresupuestoLineaModel'); + $data = $lp_model->getLineasPresupuesto(8); + $papel_imp_model = model('App\Models\Configuracion\PapelImpresionModel'); + $maquina_model = model('App\Models\Configuracion\MaquinaModel'); + foreach($data as $linea){ + $linea->papel_impresion_id = $papel_imp_model->getValue_Nombre($linea->papel_impresion_id)[0]; + $linea->maquina_id = $maquina_model->getValue_Nombre($linea->maquina_id)[0]; + var_dump($linea->papel_impresion_id); + var_dump($linea->maquina_id); + } + + } + + public function createLP(){ + $lp_model = model('App\Models\Presupuestos\PresupuestoLineaModel'); + $lp_model->createForPresupuesto(8); } public function getPapelesHQ(){ diff --git a/ci4/app/Entities/Presupuestos/PresupuestoEntity.php b/ci4/app/Entities/Presupuestos/PresupuestoEntity.php index bbe09e43..9d29fe8d 100644 --- a/ci4/app/Entities/Presupuestos/PresupuestoEntity.php +++ b/ci4/app/Entities/Presupuestos/PresupuestoEntity.php @@ -176,6 +176,8 @@ class PresupuestoEntity extends \CodeIgniter\Entity\Entity "deleted_at" => null, "created_at" => null, "updated_at" => null, + "comp_tipo_impresion" => null, + "comp_pos_paginas_color" => null, ]; protected $casts = [ "version" => "int", diff --git a/ci4/app/Entities/Presupuestos/PresupuestoLineaEntity.php b/ci4/app/Entities/Presupuestos/PresupuestoLineaEntity.php new file mode 100644 index 00000000..603cd868 --- /dev/null +++ b/ci4/app/Entities/Presupuestos/PresupuestoLineaEntity.php @@ -0,0 +1,127 @@ + null, + "presupuesto_id" => null, + "tipo" => null, + "paginas" => 0, + "paginas_color_posicion" => null, + "solapas_ancho" => 0.0, + "papel_id" => null, + "papel_impresion_id" => null, + "formas" => null, + "gramaje" => null, + "pliegos_libro" => null, + "pliegos_pedido" => null, + "pliegos_precio" => null, + "libro" => null, + "pedido" => null, + "mano" => null, + "peso" => null, + "maquina_id" => null, + "tarifa_impresion_id" => null, + "click" => null, + "precio" => null, + "rotativa_impresion" => null, + "rotativa_pag_color" => 0, + "rotativa_set_values" => false, + "rotativa_negro" => 0.0, + "rotativa_cyan" => 0.0, + "rotativa_magenta" => 0.0, + "rotativa_amarillo" => 0.0, + "rotativa_gota_negro" => 0.0, + "rotativa_gota_color" => 0.0, + "rotativa_saturacion" => 100.0, + "rotativa_a_favor_fibra" => true, + "rotativa_mxm" => null, + "rotativa_area_paginas" => null, + "rotativa_num_gotas_negro" => 0, + "rotativa_num_gotas_cyan" => 0, + "rotativa_num_gotas_magenta" => 0, + "rotativa_num_gotas_amarillo" => 0, + "rotativa_peso_gotas_negro" => 0, + "rotativa_peso_gotas_cyan" => 0, + "rotativa_peso_gotas_magenta" => 0, + "rotativa_peso_gotas_amarillo" => 0, + "rotativa_precio_pag_negro" => null, + "rotativa_precio_pag_color" => null, + "rotativa_factor_altura" => null, + "rotativa_factor_anchura" => null, + "rotativa_pag_por_pliego" => null, + "rotativa_metros_libro" => null, + "rotativa_metros_total" => null, + "rotativa_clicks_libro" => null, + "rotativa_clicks_total" => null, + "rotativa_precio_tinta" => null, + "rotativa_total_impresion" => null, + "rotativa_velocidad_corte" => 0, + "rotativa_tiempo_corte" => 0, + "rotativa_precio_hora_corte" => 0, + "rotativa_total_corte" => 0, + "isActiva" => false, + "check_impresion_total" => false, + "check_papel_total" => false, + ]; + protected $casts = [ + "presupuesto_id" => "int", + "paginas" => "int", + "solapas_ancho" => "float", + "papel_id" => "?int", + "papel_impresion_id" => "?int", + "gramaje" => "?float", + "pliegos_libro" => "?float", + "pliegos_pedido" => "?float", + "pliegos_precio" => "?float", + "libro" => "?float", + "pedido" => "?float", + "mano" => "?float", + "peso" => "?float", + "maquina_id" => "?int", + "tarifa_impresion_id" => "?int", + "click" => "?float", + "precio" => "?float", + "rotativa_pag_color" => "int", + "rotativa_set_values" => "boolean", + "rotativa_negro" => "float", + "rotativa_cyan" => "float", + "rotativa_magenta" => "float", + "rotativa_amarillo" => "float", + "rotativa_gota_negro" => "float", + "rotativa_gota_color" => "float", + "rotativa_saturacion" => "float", + "rotativa_a_favor_fibra" => "boolean", + "rotativa_mxm" => "?float", + "rotativa_area_paginas" => "float", + "rotativa_num_gotas_negro" => "float", + "rotativa_num_gotas_cyan" => "float", + "rotativa_num_gotas_magenta" => "float", + "rotativa_num_gotas_amarillo" => "float", + "rotativa_peso_gotas_negro" => "float", + "rotativa_peso_gotas_cyan" => "float", + "rotativa_peso_gotas_magenta" => "float", + "rotativa_peso_gotas_amarillo" => "float", + "rotativa_precio_pag_negro" => "float", + "rotativa_precio_pag_color" => "float", + "rotativa_factor_altura" => "float", + "rotativa_factor_anchura" => "float", + "rotativa_pag_por_pliego" => "float", + "rotativa_metros_libro" => "float", + "rotativa_metros_total" => "float", + "rotativa_clicks_libro" => "float", + "rotativa_clicks_total" => "float", + "rotativa_precio_tinta" => "float", + "rotativa_total_impresion" => "float", + "rotativa_velocidad_corte" => "float", + "rotativa_tiempo_corte" => "float", + "rotativa_precio_hora_corte" => "float", + "rotativa_total_corte" => "float", + "isActiva" => "boolean", + "check_impresion_total" => "boolean", + "check_papel_total" => "boolean", + ]; +} diff --git a/ci4/app/Language/en/Presupuestos.php b/ci4/app/Language/en/Presupuestos.php index a928c11a..aa954702 100644 --- a/ci4/app/Language/en/Presupuestos.php +++ b/ci4/app/Language/en/Presupuestos.php @@ -22,7 +22,8 @@ return [ 'incRei' => 'Incident \ Reprint', 'paginas' => 'Pages', 'tirada' => 'Print', - 'totalPapelPedido' => 'Total paper budget', + 'totalPedido' => 'Total paper budget', + 'totalPresupuesto' => 'Total Budget', 'presupuestoEstado' => 'State', 'presupuestoEstadoBorrador' => 'Draft', 'presupuestoEstadoAceptado' => 'Acepted', @@ -141,6 +142,13 @@ return [ 'addLineaPresupuesto' => 'Add line...', + 'validation' => [ + 'decimal' => 'The {field} field must contain a decimal number.', + 'integer' => 'The {field} field must contain an integer.', + 'requerido' => 'The {field} field is required.', + 'max_length' => 'The {field} field cannot exceed {param} characters in length.', + ], + 'errores' => [ 'paginas' => 'The field pages must be greater than zero', 'tiradas' => 'The field print must be greater than zero', @@ -333,7 +341,9 @@ return [ 'catalogo_id' => [ 'integer' => 'The {field} field must contain an integer.', - + 'decimal' => 'The {field} field must contain a decimal number.', + 'max_length' => 'The {field} field cannot exceed {param} characters in length.', + 'required' => 'The {field} field is required.', ], 'causa_cancelacion' => [ diff --git a/ci4/app/Language/es/Presupuestos.php b/ci4/app/Language/es/Presupuestos.php index 8339ceb2..b71dd428 100644 --- a/ci4/app/Language/es/Presupuestos.php +++ b/ci4/app/Language/es/Presupuestos.php @@ -21,7 +21,8 @@ return [ 'incRei' => 'Incidencia \ Reimpresión', 'paginas' => 'Paginas', 'tirada' => 'Tirada', - 'totalPedido' => 'Total Presupuesto', + 'totalPedido' => 'Total Pedido', + 'totalPresupuesto' => 'Total Presupuesto', 'presupuestoEstado' => 'Estado', 'presupuestoEstadoBorrador' => 'Borrador', 'presupuestoEstadoAceptado' => 'Aceptado', @@ -166,7 +167,8 @@ return [ 'validation' => [ 'decimal' => 'El campo {field} debe contener un número decimal.', - 'requerido' => 'El campo {field} esta requerido.', + 'integer' => 'El campo {field} debe contener un número entero.', + 'requerido' => 'El campo {field} es obligatorio.', 'max_length' => 'El campo {field} no puede exceder los {param} caracteres de longitud.', ], diff --git a/ci4/app/Models/Configuracion/MaquinaModel.php b/ci4/app/Models/Configuracion/MaquinaModel.php index d7988a1b..e43752b4 100644 --- a/ci4/app/Models/Configuracion/MaquinaModel.php +++ b/ci4/app/Models/Configuracion/MaquinaModel.php @@ -380,5 +380,17 @@ class MaquinaModel extends \App\Models\GoBaseModel } return $builder->orderBy("t1.id", "asc")->get()->getResultObject(); + + } + + public function getNombre($id){ + $builder = $this->db + ->table($this->table . " t1") + ->select( + "t1.nombre AS text"); + + $builder->where("t1.id", $id); + + return $builder->orderBy("t1.id", "asc")->get()->getResultObject(); } } diff --git a/ci4/app/Models/Configuracion/MaquinasTarifasImpresionModel.php b/ci4/app/Models/Configuracion/MaquinasTarifasImpresionModel.php index 2dc1c9f7..cde4df78 100644 --- a/ci4/app/Models/Configuracion/MaquinasTarifasImpresionModel.php +++ b/ci4/app/Models/Configuracion/MaquinasTarifasImpresionModel.php @@ -124,7 +124,7 @@ class MaquinasTarifasImpresionModel extends \App\Models\GoBaseModel $builder = $this->db ->table($this->table . " t1") ->select( - "t1.precio AS precio" + "t1.id AS id, t1.precio AS precio" ); //JJO @@ -135,7 +135,7 @@ class MaquinasTarifasImpresionModel extends \App\Models\GoBaseModel $tarifas = $builder->get()->getResultArray(); if (count($tarifas)>0){ - return floatval($tarifas[0]['precio']); + return [$tarifas[0]['id'], floatval($tarifas[0]['precio'])]; } return $tarifas; } diff --git a/ci4/app/Models/Configuracion/PapelImpresionModel.php b/ci4/app/Models/Configuracion/PapelImpresionModel.php index 7e0cacc9..44ef9a8d 100644 --- a/ci4/app/Models/Configuracion/PapelImpresionModel.php +++ b/ci4/app/Models/Configuracion/PapelImpresionModel.php @@ -300,4 +300,15 @@ class PapelImpresionModel extends \App\Models\GoBaseModel return $builder->orderBy("t1.id", "asc")->get()->getResultObject(); } + + public function getNombre($id){ + $builder = $this->db + ->table($this->table . " t1") + ->select( + "t1.nombre AS text"); + + $builder->where("t1.id", $id); + + return $builder->orderBy("t1.id", "asc")->get()->getResultObject(); + } } diff --git a/ci4/app/Models/Presupuestos/PresupuestoLineaModel.php b/ci4/app/Models/Presupuestos/PresupuestoLineaModel.php new file mode 100644 index 00000000..96fd96ba --- /dev/null +++ b/ci4/app/Models/Presupuestos/PresupuestoLineaModel.php @@ -0,0 +1,344 @@ + [ + "label" => "PresupuestoLineas.click", + "rules" => "decimal|permit_empty", + ], + "formas" => [ + "label" => "PresupuestoLineas.formas", + "rules" => "trim|max_length[16313]", + ], + "gramaje" => [ + "label" => "PresupuestoLineas.gramaje", + "rules" => "decimal|permit_empty", + ], + "libro" => [ + "label" => "PresupuestoLineas.libro", + "rules" => "decimal|permit_empty", + ], + "mano" => [ + "label" => "PresupuestoLineas.mano", + "rules" => "decimal|permit_empty", + ], + "paginas" => [ + "label" => "PresupuestoLineas.paginas", + "rules" => "required|integer", + ], + "paginas_color_posicion" => [ + "label" => "PresupuestoLineas.paginasColorPosicion", + "rules" => "trim|max_length[16313]", + ], + "pedido" => [ + "label" => "PresupuestoLineas.pedido", + "rules" => "decimal|permit_empty", + ], + "peso" => [ + "label" => "PresupuestoLineas.peso", + "rules" => "decimal|permit_empty", + ], + "pliegos_libro" => [ + "label" => "PresupuestoLineas.pliegosLibro", + "rules" => "decimal|permit_empty", + ], + "pliegos_pedido" => [ + "label" => "PresupuestoLineas.pliegosPedido", + "rules" => "decimal|permit_empty", + ], + "pliegos_precio" => [ + "label" => "PresupuestoLineas.pliegosPrecio", + "rules" => "decimal|permit_empty", + ], + "precio" => [ + "label" => "PresupuestoLineas.precio", + "rules" => "decimal|permit_empty", + ], + "rotativa_amarillo" => [ + "label" => "PresupuestoLineas.rotativaAmarillo", + "rules" => "required|decimal", + ], + "rotativa_area_paginas" => [ + "label" => "PresupuestoLineas.rotativaAreaPaginas", + "rules" => "required|decimal", + ], + "rotativa_clicks_libro" => [ + "label" => "PresupuestoLineas.rotativaClicksLibro", + "rules" => "required|decimal", + ], + "rotativa_clicks_total" => [ + "label" => "PresupuestoLineas.rotativaClicksTotal", + "rules" => "required|decimal", + ], + "rotativa_cyan" => [ + "label" => "PresupuestoLineas.rotativaCyan", + "rules" => "required|decimal", + ], + "rotativa_factor_altura" => [ + "label" => "PresupuestoLineas.rotativaFactorAltura", + "rules" => "required|decimal", + ], + "rotativa_factor_anchura" => [ + "label" => "PresupuestoLineas.rotativaFactorAnchura", + "rules" => "required|decimal", + ], + "rotativa_gota_color" => [ + "label" => "PresupuestoLineas.rotativaGotaColor", + "rules" => "required|decimal", + ], + "rotativa_gota_negro" => [ + "label" => "PresupuestoLineas.rotativaGotaNegro", + "rules" => "required|decimal", + ], + "rotativa_impresion" => [ + "label" => "PresupuestoLineas.rotativaImpresion", + "rules" => "required|in_list[negro,color]", + ], + "rotativa_magenta" => [ + "label" => "PresupuestoLineas.rotativaMagenta", + "rules" => "required|decimal", + ], + "rotativa_metros_libro" => [ + "label" => "PresupuestoLineas.rotativaMetrosLibro", + "rules" => "required|decimal", + ], + "rotativa_metros_total" => [ + "label" => "PresupuestoLineas.rotativaMetrosTotal", + "rules" => "required|decimal", + ], + "rotativa_mxm" => [ + "label" => "PresupuestoLineas.rotativaMxm", + "rules" => "decimal|permit_empty", + ], + "rotativa_negro" => [ + "label" => "PresupuestoLineas.rotativaNegro", + "rules" => "required|decimal", + ], + "rotativa_num_gotas_amarillo" => [ + "label" => "PresupuestoLineas.rotativaNumGotasAmarillo", + "rules" => "required|decimal", + ], + "rotativa_num_gotas_cyan" => [ + "label" => "PresupuestoLineas.rotativaNumGotasCyan", + "rules" => "required|decimal", + ], + "rotativa_num_gotas_magenta" => [ + "label" => "PresupuestoLineas.rotativaNumGotasMagenta", + "rules" => "required|decimal", + ], + "rotativa_num_gotas_negro" => [ + "label" => "PresupuestoLineas.rotativaNumGotasNegro", + "rules" => "required|decimal", + ], + "rotativa_pag_color" => [ + "label" => "PresupuestoLineas.rotativaPagColor", + "rules" => "required|integer", + ], + "rotativa_pag_por_pliego" => [ + "label" => "PresupuestoLineas.rotativaPagPorPliego", + "rules" => "required|decimal", + ], + "rotativa_peso_gotas_amarillo" => [ + "label" => "PresupuestoLineas.rotativaPesoGotasAmarillo", + "rules" => "required|decimal", + ], + "rotativa_peso_gotas_cyan" => [ + "label" => "PresupuestoLineas.rotativaPesoGotasCyan", + "rules" => "required|decimal", + ], + "rotativa_peso_gotas_magenta" => [ + "label" => "PresupuestoLineas.rotativaPesoGotasMagenta", + "rules" => "required|decimal", + ], + "rotativa_peso_gotas_negro" => [ + "label" => "PresupuestoLineas.rotativaPesoGotasNegro", + "rules" => "required|decimal", + ], + "rotativa_precio_hora_corte" => [ + "label" => "PresupuestoLineas.rotativaPrecioHoraCorte", + "rules" => "required|decimal", + ], + "rotativa_precio_pag_color" => [ + "label" => "PresupuestoLineas.rotativaPrecioPagColor", + "rules" => "required|decimal", + ], + "rotativa_precio_pag_negro" => [ + "label" => "PresupuestoLineas.rotativaPrecioPagNegro", + "rules" => "required|decimal", + ], + "rotativa_precio_tinta" => [ + "label" => "PresupuestoLineas.rotativaPrecioTinta", + "rules" => "required|decimal", + ], + "rotativa_saturacion" => [ + "label" => "PresupuestoLineas.rotativaSaturacion", + "rules" => "required|decimal", + ], + "rotativa_tiempo_corte" => [ + "label" => "PresupuestoLineas.rotativaTiempoCorte", + "rules" => "required|decimal", + ], + "rotativa_total_corte" => [ + "label" => "PresupuestoLineas.rotativaTotalCorte", + "rules" => "required|decimal", + ], + "rotativa_total_impresion" => [ + "label" => "PresupuestoLineas.rotativaTotalImpresion", + "rules" => "required|decimal", + ], + "rotativa_velocidad_corte" => [ + "label" => "PresupuestoLineas.rotativaVelocidadCorte", + "rules" => "required|decimal", + ], + "solapas_ancho" => [ + "label" => "PresupuestoLineas.solapasAncho", + "rules" => "required|decimal", + ], + "tipo" => [ + "label" => "PresupuestoLineas.tipo", + "rules" => "required|in_list[bn,bnhq,color,colorhq,cubierta,sobrecubierta,rot_bn,rot_color]", + ], + ]; + + + public function findAllWithAllRelations(string $selcols = "*", int $limit = null, int $offset = 0) + { + $sql = + "SELECT t1." . + $selcols . + ", t2.id AS presupuesto, t3.nombre AS papel, t4.nombre AS papel_impresion, t5.nombre AS maquina, t6.tipo AS tarifa_impresion FROM " . + $this->table . + " t1 LEFT JOIN presupuestos t2 ON t1.presupuesto_id = t2.id LEFT JOIN lg_papel_generico t3 ON t1.papel_id = t3.id LEFT JOIN lg_papel_impresion t4 ON t1.papel_impresion_id = t4.id LEFT JOIN lg_maquinas t5 ON t1.maquina_id = t5.id LEFT JOIN lg_maquinas_tarifas_impresion t6 ON t1.tarifa_impresion_id = t6.id"; + if (!is_null($limit) && intval($limit) > 0) { + $sql .= " LIMIT " . intval($limit); + } + + if (!is_null($offset) && intval($offset) > 0) { + $sql .= " OFFSET " . intval($offset); + } + + $query = $this->db->query($sql); + $result = $query->getResultObject(); + return $result; + } + + public function createForPresupuesto($presupuesto_id){ + + $tipos = ['bn','bnhq','color','colorhq','cubierta','sobrecubierta','rot_bn','rot_color']; + foreach($tipos as $tipo){ + $builder = $this->db + ->table($this->table . " t1"); + $data = [ + 'presupuesto_id' => $presupuesto_id, + 'tipo' => $tipo, + ]; + + $builder->insert($data); + } + } + + public function getLineasPresupuesto($presupuesto_id = -1) + { + $builder = $this->db + ->table($this->table . " t1") + ->select( + "*" + ) + ->where("t1.presupuesto_id", $presupuesto_id) + ->where("t1.isActiva", 1); + + + return $builder->orderBy("t1.id", "asc")->get()->getResultObject(); + } + + public function updateLineasPresupuesto($presupuesto_id = -1, $datos=[]) + { + foreach($datos as $linea){ + + $this->db + ->table($this->table . " t1") + ->where("t1.presupuesto_id", $presupuesto_id) + ->where("t1.tipo", $linea["tipo"]) + ->update($linea); + } + + } +} + + diff --git a/ci4/app/Models/Presupuestos/PresupuestoModel.php b/ci4/app/Models/Presupuestos/PresupuestoModel.php index 3bdc5f1b..285ef003 100644 --- a/ci4/app/Models/Presupuestos/PresupuestoModel.php +++ b/ci4/app/Models/Presupuestos/PresupuestoModel.php @@ -194,6 +194,8 @@ class PresupuestoModel extends \App\Models\GoBaseModel "pedido_espera_fecha", "pedido_espera_user_id", "is_deleted", + "comp_tipo_impresion", + "comp_pos_paginas_color", ]; protected $returnType = "App\Entities\Presupuestos\PresupuestoEntity"; @@ -206,810 +208,76 @@ class PresupuestoModel extends \App\Models\GoBaseModel public static $labelField = "titulo"; - protected $validationRules = [ - "aprobado_at" => [ - "label" => "Presupuestos.aprobadoAt", - "rules" => "valid_date|permit_empty", - ], - "aprobado_json_data" => [ - "label" => "Presupuestos.aprobadoJsonData", - "rules" => "trim|max_length[16313]", - ], + protected $validationRulesAdd = [ "autor" => [ "label" => "Presupuestos.autor", "rules" => "trim|required|max_length[150]", ], - "base_imponible" => [ - "label" => "Presupuestos.baseImponible", - "rules" => "decimal|permit_empty", - ], - "catalogo_id" => [ - "label" => "Presupuestos.catalogoId", - "rules" => "integer|permit_empty", - ], - "causa_cancelacion" => [ - "label" => "Presupuestos.causaCancelacion", - "rules" => "trim|max_length[16313]", - ], - "coleccion" => [ - "label" => "Presupuestos.coleccion", - "rules" => "trim|max_length[255]", - ], - "comentarios_cliente" => [ - "label" => "Presupuestos.comentarios_cliente", - "rules" => "trim|required|max_length[16313]", - ], - "comentarios_pdf" => [ - "label" => "Presupuestos.comentariosPdf", - "rules" => "trim|required|max_length[16313]", - ], - "comentarios_safekat" => [ - "label" => "Presupuestos.comentariosSafekat", - "rules" => "trim|required|max_length[16313]", - ], - "comentarios_tarifa" => [ - "label" => "Presupuestos.comentariosTarifa", - "rules" => "trim|required|max_length[16313]", - ], - "comentarios_produccion" => [ - "label" => "Presupuestos.comentariosProduccion", - "rules" => "trim|required|max_length[16313]", - ], - "comparador_json_data" => [ - "label" => "Presupuestos.comparadorJsonData", - "rules" => "trim|max_length[16313]", - ], - "sobrecubiertas_ancho" => [ - "label" => "Presupuestos.sobrecubiertasAncho", - "rules" => "required|decimal", - ], - "descuento" => [ - "label" => "Presupuestos.descuento", - "rules" => "required|decimal", - ], - "fecha_encuardenado_at" => [ - "label" => "Presupuestos.fechaEncuardenadoAt", - "rules" => "valid_date|permit_empty", - ], - "fecha_entrega_real_at" => [ - "label" => "Presupuestos.fechaEntregaRealAt", - "rules" => "valid_date|permit_empty", - ], - "fecha_externo_at" => [ - "label" => "Presupuestos.fechaExternoAt", - "rules" => "valid_date|permit_empty", - ], - "fecha_ferro_subido_at" => [ - "label" => "Presupuestos.fechaFerroSubidoAt", - "rules" => "valid_date|permit_empty", - ], - "fecha_impresion_at" => [ - "label" => "Presupuestos.fechaImpresionAt", - "rules" => "valid_date|permit_empty", - ], - "forzar_total" => [ - "label" => "Presupuestos.forzarTotal", - "rules" => "required|decimal", + "titulo" => [ + "label" => "Presupuestos.titulo", + "rules" => "trim|required|max_length[30]", ], "inc_rei" => [ "label" => "Presupuestos.incRei", "rules" => "integer|permit_empty", ], - "is_deleted" => [ - "label" => "Presupuestos.isDeleted", - "rules" => "required|integer", - ], - "isbn" => [ - "label" => "Presupuestos.isbn", - "rules" => "trim|max_length[50]", - ], - "lomo" => [ - "label" => "Presupuestos.lomo", - "rules" => "integer|permit_empty", - ], - "margen" => [ - "label" => "Presupuestos.margen", - "rules" => "decimal|permit_empty", - ], - "margen_extra" => [ - "label" => "Presupuestos.margenExtra", - "rules" => "required|decimal", - ], - "margen_manual" => [ - "label" => "Presupuestos.margenManual", - "rules" => "decimal|permit_empty", - ], - "merma" => [ - "label" => "Presupuestos.merma", - "rules" => "required|decimal", - ], - "merma_portada" => [ - "label" => "Presupuestos.mermaPortada", - "rules" => "required|decimal", + "coleccion" => [ + "label" => "Presupuestos.incRei", + "rules" => "trim|max_length[255]", ], "numero_edicion" => [ "label" => "Presupuestos.numeroEdicion", "rules" => "trim|max_length[50]", ], - "paginas" => [ - "label" => "Presupuestos.paginas", - "rules" => "required|integer", + "isbn" => [ + "label" => "Presupuestos.isbn", + "rules" => "trim|max_length[50]", ], - "paginas_color" => [ - "label" => "Presupuestos.paginasColor", - "rules" => "integer|permit_empty", + "pais_id" => [ + "label" => "Presupuestos.paisId", + "rules" => "required|integer|greater_than[0]", ], - "paginas_color_click" => [ - "label" => "Presupuestos.paginasColorClick", - "rules" => "decimal|permit_empty", - ], - "paginas_color_forma_id" => [ - "label" => "Presupuestos.paginasColorFormaId", - "rules" => "integer|permit_empty", - ], - "paginas_color_gramaje" => [ - "label" => "Presupuestos.paginasColorGramaje", - "rules" => "decimal|permit_empty", - ], - "paginas_color_libro" => [ - "label" => "Presupuestos.paginasColorLibro", - "rules" => "decimal|permit_empty", - ], - "paginas_color_mano" => [ - "label" => "Presupuestos.paginasColorMano", - "rules" => "decimal|permit_empty", - ], - "paginas_color_pedido" => [ - "label" => "Presupuestos.paginasColorPedido", - "rules" => "decimal|permit_empty", - ], - "paginas_color_peso" => [ - "label" => "Presupuestos.paginasColorPeso", - "rules" => "decimal|permit_empty", - ], - "paginas_color_pliegos_libro" => [ - "label" => "Presupuestos.paginasColorPliegosLibro", - "rules" => "decimal|permit_empty", - ], - "paginas_color_pliegos_pedido" => [ - "label" => "Presupuestos.paginasColorPliegosPedido", - "rules" => "decimal|permit_empty", - ], - "paginas_color_pliegos_precio" => [ - "label" => "Presupuestos.paginasColorPliegosPrecio", - "rules" => "decimal|permit_empty", - ], - "paginas_color_posicion" => [ - "label" => "Presupuestos.paginasColorPosicion", - "rules" => "trim|max_length[16313]", - ], - "paginas_color_precio" => [ - "label" => "Presupuestos.paginasColorPrecio", - "rules" => "decimal|permit_empty", - ], - "paginas_sobrecubierta" => [ - "label" => "Presupuestos.paginasCubierta", - "rules" => "required|in_list[4x0,4x4]", - ], - "paginas_sobrecubierta_click" => [ - "label" => "Presupuestos.paginasCubiertaClick", - "rules" => "decimal|permit_empty", - ], - "paginas_sobrecubierta_forma_id" => [ - "label" => "Presupuestos.paginasCubiertaFormaId", - "rules" => "integer|permit_empty", - ], - "paginas_sobrecubierta_gramaje" => [ - "label" => "Presupuestos.paginasCubiertaGramaje", - "rules" => "decimal|permit_empty", - ], - "paginas_sobrecubierta_libro" => [ - "label" => "Presupuestos.paginasCubiertaLibro", - "rules" => "decimal|permit_empty", - ], - "paginas_sobrecubierta_mano" => [ - "label" => "Presupuestos.paginasCubiertaMano", - "rules" => "decimal|permit_empty", - ], - "paginas_sobrecubierta_pedido" => [ - "label" => "Presupuestos.paginasCubiertaPedido", - "rules" => "decimal|permit_empty", - ], - "paginas_sobrecubierta_peso" => [ - "label" => "Presupuestos.paginasCubiertaPeso", - "rules" => "decimal|permit_empty", - ], - "paginas_sobrecubierta_pliegos_libro" => [ - "label" => "Presupuestos.paginasCubiertaPliegosLibro", - "rules" => "decimal|permit_empty", - ], - "paginas_sobrecubierta_pliegos_pedido" => [ - "label" => "Presupuestos.paginasCubiertaPliegosPedido", - "rules" => "decimal|permit_empty", - ], - "paginas_sobrecubierta_pliegos_precio" => [ - "label" => "Presupuestos.paginasCubiertaPliegosPrecio", - "rules" => "decimal|permit_empty", - ], - "paginas_sobrecubierta_precio" => [ - "label" => "Presupuestos.paginasCubiertaPrecio", - "rules" => "decimal|permit_empty", - ], - "paginas_negro" => [ - "label" => "Presupuestos.paginasNegro", - "rules" => "integer|permit_empty", - ], - "paginas_negro_click" => [ - "label" => "Presupuestos.paginasNegroClick", - "rules" => "decimal|permit_empty", - ], - "paginas_negro_forma_id" => [ - "label" => "Presupuestos.paginasNegroFormaId", - "rules" => "integer|permit_empty", - ], - "paginas_negro_gramaje" => [ - "label" => "Presupuestos.paginasNegroGramaje", - "rules" => "decimal|permit_empty", - ], - "paginas_negro_libro" => [ - "label" => "Presupuestos.paginasNegroLibro", - "rules" => "decimal|permit_empty", - ], - "paginas_negro_mano" => [ - "label" => "Presupuestos.paginasNegroMano", - "rules" => "decimal|permit_empty", - ], - "paginas_negro_pedido" => [ - "label" => "Presupuestos.paginasNegroPedido", - "rules" => "decimal|permit_empty", - ], - "paginas_negro_peso" => [ - "label" => "Presupuestos.paginasNegroPeso", - "rules" => "decimal|permit_empty", - ], - "paginas_negro_pliegos_libro" => [ - "label" => "Presupuestos.paginasNegroPliegosLibro", - "rules" => "decimal|permit_empty", - ], - "paginas_negro_pliegos_pedido" => [ - "label" => "Presupuestos.paginasNegroPliegosPedido", - "rules" => "decimal|permit_empty", - ], - "paginas_negro_pliegos_precio" => [ - "label" => "Presupuestos.paginasNegroPliegosPrecio", - "rules" => "decimal|permit_empty", - ], - "paginas_negro_precio" => [ - "label" => "Presupuestos.paginasNegroPrecio", - "rules" => "decimal|permit_empty", - ], - "paginas_cubierta" => [ - "label" => "Presupuestos.paginasPortada", - "rules" => "required|in_list[4x0,4x4]", - ], - "paginas_cubierta_click" => [ - "label" => "Presupuestos.paginasPortadaClick", - "rules" => "decimal|permit_empty", - ], - "paginas_cubierta_forma_id" => [ - "label" => "Presupuestos.paginasPortadaFormaId", - "rules" => "integer|permit_empty", - ], - "paginas_cubierta_gramaje" => [ - "label" => "Presupuestos.paginasPortadaGramaje", - "rules" => "decimal|permit_empty", - ], - "paginas_cubierta_libro" => [ - "label" => "Presupuestos.paginasPortadaLibro", - "rules" => "decimal|permit_empty", - ], - "paginas_cubierta_mano" => [ - "label" => "Presupuestos.paginasPortadaMano", - "rules" => "decimal|permit_empty", - ], - "paginas_cubierta_pedido" => [ - "label" => "Presupuestos.paginasPortadaPedido", - "rules" => "required|decimal", - ], - "paginas_cubierta_peso" => [ - "label" => "Presupuestos.paginasPortadaPeso", - "rules" => "decimal|permit_empty", - ], - "paginas_cubierta_pliegos_libro" => [ - "label" => "Presupuestos.paginasPortadaPliegosLibro", - "rules" => "decimal|permit_empty", - ], - "paginas_cubierta_pliegos_pedido" => [ - "label" => "Presupuestos.paginasPortadaPliegosPedido", - "rules" => "decimal|permit_empty", - ], - "paginas_cubierta_pliegos_precio" => [ - "label" => "Presupuestos.paginasPortadaPliegosPrecio", - "rules" => "decimal|permit_empty", - ], - "paginas_cubierta_precio" => [ - "label" => "Presupuestos.paginasPortadaPrecio", - "rules" => "decimal|permit_empty", - ], - "papel_formato_alto" => [ - "label" => "Presupuestos.papelFormatoAlto", - "rules" => "decimal|permit_empty", - ], - "papel_formato_ancho" => [ - "label" => "Presupuestos.papelFormatoAncho", - "rules" => "decimal|permit_empty", - ], - "pedido_espera_fecha" => [ - "label" => "Presupuestos.pedidoEsperaFecha", - "rules" => "valid_date|permit_empty", + "cliente_id" => [ + "label" => "Presupuestos.clienteId", + "rules" => "required|integer|greater_than[0]", ], "referencia_cliente" => [ "label" => "Presupuestos.referenciaCliente", - "rules" => "trim|required|max_length[100]", - ], - "responsable" => [ - "label" => "Presupuestos.responsable", - "rules" => "trim|max_length[32]", - ], - "serie_id" => [ - "label" => "Presupuestos.serieId", - "rules" => "integer|permit_empty", - ], - "solapas_ancho" => [ - "label" => "Presupuestos.solapasAncho", - "rules" => "required|decimal", - ], - "tarifa_cliente_id" => [ - "label" => "Presupuestos.tarifaClienteId", - "rules" => "integer|permit_empty", - ], - "tirada" => [ - "label" => "Presupuestos.tirada", - "rules" => "required|integer", - ], - "tirada_alternativa_json_data" => [ - "label" => "Presupuestos.tiradaAlternativaJsonData", - "rules" => "trim|max_length[16313]", - ], - "titulo" => [ - "label" => "Presupuestos.titulo", - "rules" => "trim|required|max_length[300]", - ], - "total" => [ - "label" => "Presupuestos.total", - "rules" => "decimal|permit_empty", - ], - "total_acabado" => [ - "label" => "Presupuestos.totalAcabado", - "rules" => "decimal|permit_empty", - ], - "total_calculado" => [ - "label" => "Presupuestos.totalCalculado", - "rules" => "decimal|permit_empty", - ], - "total_click" => [ - "label" => "Presupuestos.totalClick", - "rules" => "decimal|permit_empty", - ], - "total_confirmado" => [ - "label" => "Presupuestos.totalConfirmado", - "rules" => "decimal|permit_empty", - ], - "total_confirmado_update_at" => [ - "label" => "Presupuestos.totalConfirmadoUpdateAt", - "rules" => "valid_date|permit_empty", - ], - "total_descuento" => [ - "label" => "Presupuestos.totalDescuento", - "rules" => "decimal|permit_empty", - ], - "total_envios" => [ - "label" => "Presupuestos.totalEnvios", - "rules" => "decimal|permit_empty", - ], - "total_manipulado" => [ - "label" => "Presupuestos.totalManipulado", - "rules" => "decimal|permit_empty", - ], - "total_margen" => [ - "label" => "Presupuestos.totalMargen", - "rules" => "decimal|permit_empty", - ], - "total_margen_extra" => [ - "label" => "Presupuestos.totalMargenExtra", - "rules" => "decimal|permit_empty", - ], - "total_pedido" => [ - "label" => "Presupuestos.totalPedido", - "rules" => "decimal|permit_empty", - ], - "total_peso" => [ - "label" => "Presupuestos.totalPeso", - "rules" => "decimal|permit_empty", - ], - "total_preimpresion" => [ - "label" => "Presupuestos.totalPreimpresion", - "rules" => "decimal|permit_empty", - ], - "total_preimpresion_margen" => [ - "label" => "Presupuestos.totalPreimpresionMargen", - "rules" => "decimal|permit_empty", - ], - "total_presupuesto" => [ - "label" => "Presupuestos.totalPresupuesto", - "rules" => "decimal|permit_empty", - ], - "user_created_id" => [ - "label" => "Presupuestos.userCreatedId", - "rules" => "required|integer", - ], - "user_update_id" => [ - "label" => "Presupuestos.userUpdateId", - "rules" => "integer|permit_empty", - ], - "version" => [ - "label" => "Presupuestos.version", - "rules" => "required|integer", + "rules" => "trim|max_length[100]", ], ]; - protected $validationMessages = [ - "aprobado_at" => [ - "valid_date" => "Presupuestos.validation.aprobado_at.valid_date", - ], - "aprobado_json_data" => [ - "max_length" => "Presupuestos.validation.aprobado_json_data.max_length", - ], + protected $validationMessagesAdd = [ "autor" => [ - "max_length" => "Presupuestos.validation.autor.max_length", - "required" => "Presupuestos.validation.autor.required", - ], - "base_imponible" => [ - "decimal" => "Presupuestos.validation.base_imponible.decimal", - ], - "catalogo_id" => [ - "integer" => "Presupuestos.validation.catalogo_id.integer", - ], - "causa_cancelacion" => [ - "max_length" => "Presupuestos.validation.causa_cancelacion.max_length", - ], - "coleccion" => [ - "max_length" => "Presupuestos.validation.coleccion.max_length", - ], - "comentarios_cliente" => [ "max_length" => "Presupuestos.validation.max_length", - "required" => "Presupuestos.validation.required", - ], - "comentarios_pdf" => [ - "max_length" => "Presupuestos.validation.max_length", - "required" => "Presupuestos.validation.required", - ], - "comentarios_safekat" => [ - "max_length" => "Presupuestos.validation.max_length", - "required" => "Presupuestos.validation.required", - ], - "comentarios_tarifa" => [ - "max_length" => "Presupuestos.validation.max_length", - "required" => "Presupuestos.validation.required", - ], - "comentarios_produccion" => [ - "max_length" => "Presupuestos.validation.max_length", - "required" => "Presupuestos.validation.required", - ], - "comparador_json_data" => [ - "max_length" => "Presupuestos.validation.comparador_json_data.max_length", - ], - "sobrecubiertas_ancho" => [ - "decimal" => "Presupuestos.validation.sobrecubiertas_ancho.decimal", - "required" => "Presupuestos.validation.sobrecubiertas_ancho.required", - ], - "descuento" => [ - "decimal" => "Presupuestos.validation.descuento.decimal", - "required" => "Presupuestos.validation.descuento.required", - ], - "fecha_encuardenado_at" => [ - "valid_date" => "Presupuestos.validation.fecha_encuardenado_at.valid_date", - ], - "fecha_entrega_real_at" => [ - "valid_date" => "Presupuestos.validation.fecha_entrega_real_at.valid_date", - ], - "fecha_externo_at" => [ - "valid_date" => "Presupuestos.validation.fecha_externo_at.valid_date", - ], - "fecha_ferro_subido_at" => [ - "valid_date" => "Presupuestos.validation.fecha_ferro_subido_at.valid_date", - ], - "fecha_impresion_at" => [ - "valid_date" => "Presupuestos.validation.fecha_impresion_at.valid_date", - ], - "forzar_total" => [ - "decimal" => "Presupuestos.validation.forzar_total.decimal", - "required" => "Presupuestos.validation.forzar_total.required", - ], - "inc_rei" => [ - "integer" => "Presupuestos.validation.inc_rei.integer", - ], - "is_deleted" => [ - "integer" => "Presupuestos.validation.is_deleted.integer", - "required" => "Presupuestos.validation.is_deleted.required", - ], - "isbn" => [ - "max_length" => "Presupuestos.validation.isbn.max_length", - ], - "lomo" => [ - "integer" => "Presupuestos.validation.lomo.integer", - ], - "margen" => [ - "decimal" => "Presupuestos.validation.margen.decimal", - ], - "margen_extra" => [ - "decimal" => "Presupuestos.validation.margen_extra.decimal", - "required" => "Presupuestos.validation.margen_extra.required", - ], - "margen_manual" => [ - "decimal" => "Presupuestos.validation.margen_manual.decimal", - ], - "merma" => [ - "decimal" => "Presupuestos.validation.merma.decimal", - "required" => "Presupuestos.validation.merma.required", - ], - "merma_portada" => [ - "decimal" => "Presupuestos.validation.merma_portada.decimal", - "required" => "Presupuestos.validation.merma_portada.required", - ], - "numero_edicion" => [ - "max_length" => "Presupuestos.validation.numero_edicion.max_length", - ], - "paginas" => [ - "integer" => "Presupuestos.validation.paginas.integer", - "required" => "Presupuestos.validation.paginas.required", - ], - "paginas_color" => [ - "integer" => "Presupuestos.validation.paginas_color.integer", - ], - "paginas_color_click" => [ - "decimal" => "Presupuestos.validation.paginas_color_click.decimal", - ], - "paginas_color_forma_id" => [ - "integer" => "Presupuestos.validation.paginas_color_forma_id.integer", - ], - "paginas_color_gramaje" => [ - "decimal" => "Presupuestos.validation.paginas_color_gramaje.decimal", - ], - "paginas_color_libro" => [ - "decimal" => "Presupuestos.validation.paginas_color_libro.decimal", - ], - "paginas_color_mano" => [ - "decimal" => "Presupuestos.validation.paginas_color_mano.decimal", - ], - "paginas_color_pedido" => [ - "decimal" => "Presupuestos.validation.paginas_color_pedido.decimal", - ], - "paginas_color_peso" => [ - "decimal" => "Presupuestos.validation.paginas_color_peso.decimal", - ], - "paginas_color_pliegos_libro" => [ - "decimal" => "Presupuestos.validation.paginas_color_pliegos_libro.decimal", - ], - "paginas_color_pliegos_pedido" => [ - "decimal" => "Presupuestos.validation.paginas_color_pliegos_pedido.decimal", - ], - "paginas_color_pliegos_precio" => [ - "decimal" => "Presupuestos.validation.paginas_color_pliegos_precio.decimal", - ], - "paginas_color_posicion" => [ - "max_length" => "Presupuestos.validation.paginas_color_posicion.max_length", - ], - "paginas_color_precio" => [ - "decimal" => "Presupuestos.validation.paginas_color_precio.decimal", - ], - "paginas_sobrecubierta" => [ - "in_list" => "Presupuestos.validation.paginas_sobrecubierta.in_list", - "required" => "Presupuestos.validation.paginas_sobrecubierta.required", - ], - "paginas_sobrecubierta_click" => [ - "decimal" => "Presupuestos.validation.paginas_sobrecubierta_click.decimal", - ], - "paginas_sobrecubierta_forma_id" => [ - "integer" => "Presupuestos.validation.paginas_sobrecubierta_forma_id.integer", - ], - "paginas_sobrecubierta_gramaje" => [ - "decimal" => "Presupuestos.validation.paginas_sobrecubierta_gramaje.decimal", - ], - "paginas_sobrecubierta_libro" => [ - "decimal" => "Presupuestos.validation.paginas_sobrecubierta_libro.decimal", - ], - "paginas_sobrecubierta_mano" => [ - "decimal" => "Presupuestos.validation.paginas_sobrecubierta_mano.decimal", - ], - "paginas_sobrecubierta_pedido" => [ - "decimal" => "Presupuestos.validation.paginas_sobrecubierta_pedido.decimal", - ], - "paginas_sobrecubierta_peso" => [ - "decimal" => "Presupuestos.validation.paginas_sobrecubierta_peso.decimal", - ], - "paginas_sobrecubierta_pliegos_libro" => [ - "decimal" => "Presupuestos.validation.paginas_sobrecubierta_pliegos_libro.decimal", - ], - "paginas_sobrecubierta_pliegos_pedido" => [ - "decimal" => "Presupuestos.validation.paginas_sobrecubierta_pliegos_pedido.decimal", - ], - "paginas_sobrecubierta_pliegos_precio" => [ - "decimal" => "Presupuestos.validation.paginas_sobrecubierta_pliegos_precio.decimal", - ], - "paginas_sobrecubierta_precio" => [ - "decimal" => "Presupuestos.validation.paginas_sobrecubierta_precio.decimal", - ], - "paginas_negro" => [ - "integer" => "Presupuestos.validation.paginas_negro.integer", - ], - "paginas_negro_click" => [ - "decimal" => "Presupuestos.validation.paginas_negro_click.decimal", - ], - "paginas_negro_forma_id" => [ - "integer" => "Presupuestos.validation.paginas_negro_forma_id.integer", - ], - "paginas_negro_gramaje" => [ - "decimal" => "Presupuestos.validation.paginas_negro_gramaje.decimal", - ], - "paginas_negro_libro" => [ - "decimal" => "Presupuestos.validation.paginas_negro_libro.decimal", - ], - "paginas_negro_mano" => [ - "decimal" => "Presupuestos.validation.paginas_negro_mano.decimal", - ], - "paginas_negro_pedido" => [ - "decimal" => "Presupuestos.validation.paginas_negro_pedido.decimal", - ], - "paginas_negro_peso" => [ - "decimal" => "Presupuestos.validation.paginas_negro_peso.decimal", - ], - "paginas_negro_pliegos_libro" => [ - "decimal" => "Presupuestos.validation.paginas_negro_pliegos_libro.decimal", - ], - "paginas_negro_pliegos_pedido" => [ - "decimal" => "Presupuestos.validation.paginas_negro_pliegos_pedido.decimal", - ], - "paginas_negro_pliegos_precio" => [ - "decimal" => "Presupuestos.validation.paginas_negro_pliegos_precio.decimal", - ], - "paginas_negro_precio" => [ - "decimal" => "Presupuestos.validation.paginas_negro_precio.decimal", - ], - "paginas_cubierta" => [ - "in_list" => "Presupuestos.validation.paginas_cubierta.in_list", - "required" => "Presupuestos.validation.paginas_cubierta.required", - ], - "paginas_cubierta_click" => [ - "decimal" => "Presupuestos.validation.paginas_cubierta_click.decimal", - ], - "paginas_cubierta_forma_id" => [ - "integer" => "Presupuestos.validation.paginas_cubierta_forma_id.integer", - ], - "paginas_cubierta_gramaje" => [ - "decimal" => "Presupuestos.validation.paginas_cubierta_gramaje.decimal", - ], - "paginas_cubierta_libro" => [ - "decimal" => "Presupuestos.validation.paginas_cubierta_libro.decimal", - ], - "paginas_cubierta_mano" => [ - "decimal" => "Presupuestos.validation.paginas_cubierta_mano.decimal", - ], - "paginas_cubierta_pedido" => [ - "decimal" => "Presupuestos.validation.paginas_cubierta_pedido.decimal", - "required" => "Presupuestos.validation.paginas_cubierta_pedido.required", - ], - "paginas_cubierta_peso" => [ - "decimal" => "Presupuestos.validation.paginas_cubierta_peso.decimal", - ], - "paginas_cubierta_pliegos_libro" => [ - "decimal" => "Presupuestos.validation.paginas_cubierta_pliegos_libro.decimal", - ], - "paginas_cubierta_pliegos_pedido" => [ - "decimal" => "Presupuestos.validation.paginas_cubierta_pliegos_pedido.decimal", - ], - "paginas_cubierta_pliegos_precio" => [ - "decimal" => "Presupuestos.validation.paginas_cubierta_pliegos_precio.decimal", - ], - "paginas_cubierta_precio" => [ - "decimal" => "Presupuestos.validation.paginas_cubierta_precio.decimal", - ], - "papel_formato_alto" => [ - "decimal" => "Presupuestos.validation.papel_formato_alto.decimal", - ], - "papel_formato_ancho" => [ - "decimal" => "Presupuestos.validation.papel_formato_ancho.decimal", - ], - "pedido_espera_fecha" => [ - "valid_date" => "Presupuestos.validation.pedido_espera_fecha.valid_date", - ], - "referencia_cliente" => [ - "max_length" => "Presupuestos.validation.referencia_cliente.max_length", - "required" => "Presupuestos.validation.referencia_cliente.required", - ], - "responsable" => [ - "max_length" => "Presupuestos.validation.responsable.max_length", - ], - "serie_id" => [ - "integer" => "Presupuestos.validation.serie_id.integer", - ], - "solapas_ancho" => [ - "decimal" => "Presupuestos.validation.solapas_ancho.decimal", - "required" => "Presupuestos.validation.solapas_ancho.required", - ], - "tarifa_cliente_id" => [ - "integer" => "Presupuestos.validation.tarifa_cliente_id.integer", - ], - "tirada" => [ - "integer" => "Presupuestos.validation.tirada.integer", - "required" => "Presupuestos.validation.tirada.required", - ], - "tirada_alternativa_json_data" => [ - "max_length" => "Presupuestos.validation.tirada_alternativa_json_data.max_length", + "required" => "Presupuestos.validation.requerido", ], "titulo" => [ - "max_length" => "Presupuestos.validation.titulo.max_length", - "required" => "Presupuestos.validation.titulo.required", + "max_length" => "Presupuestos.validation.max_length", + "required" => "Presupuestos.validation.requerido", ], - "total" => [ - "decimal" => "Presupuestos.validation.total.decimal", + "inc_rei" => [ + "integer" => "Presupuestos.validation.integer", + ], - "total_acabado" => [ - "decimal" => "Presupuestos.validation.total_acabado.decimal", + "coleccion" => [ + "max_length" => "Presupuestos.validation.max_length", ], - "total_calculado" => [ - "decimal" => "Presupuestos.validation.total_calculado.decimal", + "numero_edicion" => [ + "max_length" => "Presupuestos.validation.max_length", ], - "total_click" => [ - "decimal" => "Presupuestos.validation.total_click.decimal", + "isbn" => [ + "max_length" => "Presupuestos.validation.max_length", ], - "total_confirmado" => [ - "decimal" => "Presupuestos.validation.total_confirmado.decimal", + "pais_id" => [ + "required" => "Presupuestos.validation.requerido", ], - "total_confirmado_update_at" => [ - "valid_date" => "Presupuestos.validation.total_confirmado_update_at.valid_date", - ], - "total_descuento" => [ - "decimal" => "Presupuestos.validation.total_descuento.decimal", - ], - "total_envios" => [ - "decimal" => "Presupuestos.validation.total_envios.decimal", - ], - "total_manipulado" => [ - "decimal" => "Presupuestos.validation.total_manipulado.decimal", - ], - "total_margen" => [ - "decimal" => "Presupuestos.validation.total_margen.decimal", - ], - "total_margen_extra" => [ - "decimal" => "Presupuestos.validation.total_margen_extra.decimal", - ], - "total_pedido" => [ - "decimal" => "Presupuestos.validation.total_pedido.decimal", - ], - "total_peso" => [ - "decimal" => "Presupuestos.validation.total_peso.decimal", - ], - "total_preimpresion" => [ - "decimal" => "Presupuestos.validation.total_preimpresion.decimal", - ], - "total_preimpresion_margen" => [ - "decimal" => "Presupuestos.validation.total_preimpresion_margen.decimal", - ], - "total_presupuesto" => [ - "decimal" => "Presupuestos.validation.total_presupuesto.decimal", - ], - "user_created_id" => [ - "integer" => "Presupuestos.validation.user_created_id.integer", - "required" => "Presupuestos.validation.user_created_id.required", - ], - "user_update_id" => [ - "integer" => "Presupuestos.validation.user_update_id.integer", - ], - "version" => [ - "integer" => "Presupuestos.validation.version.integer", - "required" => "Presupuestos.validation.version.required", + "cliente_id" => [ + "required" => "Presupuestos.validation.requerido", ], + "referencia_cliente" => [ + "max_length" => "Presupuestos.validation.max_length", + ], ]; public function findAllWithAllRelations(string $selcols = "*", int $limit = null, int $offset = 0) { @@ -1047,13 +315,15 @@ class PresupuestoModel extends \App\Models\GoBaseModel "t1.id AS id, t1.created_at AS fecha, t2.nombre AS cliente, CONCAT(t3.first_name, ' ', t3.last_name) AS comercial, t1.titulo AS titulo, t5.nombre AS pais, t1.inc_rei AS inc_rei, t1.paginas AS paginas, t1.tirada AS tirada, - t1.total_pedido AS total_pedido, t6.estado AS estado" + t1.total_pedido AS total_pedido, t1.total_presupuesto AS total_presupuesto, t6.estado AS estado" ); $builder->join("clientes t2", "t1.cliente_id = t2.id", "left"); $builder->join("auth_user t3", "t1.user_update_id = t3.id_user", "left"); $builder->join("lg_paises t5", "t1.pais_id = t5.id", "left"); $builder->join("presupuesto_estados t6", "t1.estado_id = t6.id", "left"); + $builder->where("t1.is_deleted", 0); + return empty($search) ? $builder : $builder diff --git a/ci4/app/Views/themes/backend/vuexy/form/presupuestos/cosidotapablanda/_comentariosItems.php b/ci4/app/Views/themes/backend/vuexy/form/presupuestos/cosidotapablanda/_comentariosItems.php index 53970be9..7a765f42 100644 --- a/ci4/app/Views/themes/backend/vuexy/form/presupuestos/cosidotapablanda/_comentariosItems.php +++ b/ci4/app/Views/themes/backend/vuexy/form/presupuestos/cosidotapablanda/_comentariosItems.php @@ -95,7 +95,7 @@ rows="3" id="comentariosCliente" name="comentarios_cliente" - required style="height: 10em;" + style="height: 10em;" class="form-control">comentarios_cliente) ?> @@ -110,7 +110,6 @@ rows="3" id="comentariosSafekat" name="comentarios_safekat" - required style="height: 10em;" class="form-control">comentarios_safekat) ?> @@ -127,7 +126,7 @@ rows="3" id="comentariosPdf" name="comentarios_pdf" - required style="height: 10em;" + style="height: 10em;" class="form-control">comentarios_pdf) ?> @@ -143,7 +142,6 @@ rows="3" id="comentariosProduccion" name="comentarios_produccion" - required style="height: 10em;" class="form-control">comentarios_produccion) ?> diff --git a/ci4/app/Views/themes/backend/vuexy/form/presupuestos/cosidotapablanda/_datosLibroItems.php b/ci4/app/Views/themes/backend/vuexy/form/presupuestos/cosidotapablanda/_datosLibroItems.php index 52a47e14..d53937ef 100644 --- a/ci4/app/Views/themes/backend/vuexy/form/presupuestos/cosidotapablanda/_datosLibroItems.php +++ b/ci4/app/Views/themes/backend/vuexy/form/presupuestos/cosidotapablanda/_datosLibroItems.php @@ -116,7 +116,11 @@ - + + + + +section("additionalInlineJs") ?> +$('#papelFormatoPersonalizado').on("click",function(){ + var checkbox = document.getElementById('papelFormatoPersonalizado'); + if(checkbox.checked == true){ + document.getElementById("papelFormatoAncho").style.display = "block"; + document.getElementById("papelFormatoAlto").style.display = "block"; + $('#papelFormatoId').next(".select2-container").hide(); + $('#papelFormatoId').val('').change(); + document.getElementById("label_papelFormatoId").innerHTML = + " (" + + " x )*"; + } + else{ + document.getElementById("papelFormatoAncho").value= ""; + document.getElementById("papelFormatoAlto").value= ""; + document.getElementById("papelFormatoAncho").style.display = "none"; + document.getElementById("papelFormatoAlto").style.display = "none"; + $('#papelFormatoId').next(".select2-container").show(); + document.getElementById("label_papelFormatoId").innerHTML = + "*"; + } +}); + +endSection() ?> diff --git a/ci4/app/Views/themes/backend/vuexy/form/presupuestos/cosidotapablanda/_datosPresupuestoClienteItems.php b/ci4/app/Views/themes/backend/vuexy/form/presupuestos/cosidotapablanda/_datosPresupuestoClienteItems.php index d66cd0a2..7084ed91 100644 --- a/ci4/app/Views/themes/backend/vuexy/form/presupuestos/cosidotapablanda/_datosPresupuestoClienteItems.php +++ b/ci4/app/Views/themes/backend/vuexy/form/presupuestos/cosidotapablanda/_datosPresupuestoClienteItems.php @@ -13,6 +13,8 @@
+ +
@@ -20,17 +22,17 @@
- + - - - @@ -72,10 +74,10 @@

- +
- $v) : ?>
- +
+
+
+
@@ -425,4 +427,1046 @@
- \ No newline at end of file + + + + + + +section("additionalInlineJs") ?> + + autosize($('#compCalPaginasColor')); + + function init_comparador() { + $('#tipoImpresion').select2({ + allowClear: false, + }); + + $('#compPapelNegro').select2({ + allowClear: false, + }); + + $('#compGramajeNegro').select2({ + allowClear: false, + }); + + $('#compPapelNegrohq').select2({ + allowClear: false, + }); + + $('#compGramajeNegrohq').select2({ + allowClear: false, + }); + + $('#compPapelColor').select2({ + allowClear: false, + }); + + $('#compPapelColorhq').select2({ + allowClear: false, + }); + + $('#compGramajeColor').select2({ + allowClear: false, + }); + + $('#compGramajeColorhq').select2({ + allowClear: false, + }); + + $('#compPapelCubierta').select2({ + allowClear: false, + }); + + $('#compGramajeCubierta').select2({ + allowClear: false, + }); + + $('#encuadernacion').select2({ + allowClear: false, + }); + + $('#compCarasCubierta').select2({ + allowClear: false, + minimumResultsForSearch: Infinity, + }); + + $('#papelFormatoId').select2({ + allowClear: false, + }); + + updatePapelesComparador(); + const paginasColor = document.getElementById('compCalPaginasColor'); + if (paginasColor.value.length > 0) { + computarPaginasColor(paginasColor.value); + } + + var comp_data = + + try{ + $("#compPapelNegro").val(parseInt(comp_data.bn.papel_id)).trigger('change'); + + try{ + var newState = new Option(comp_data.bn.gramaje, comp_data.bn.gramaje, true, true); + // Append it to the select + $("#compGramajeNegro").append(newState).trigger('change'); + $('#compGramajeNegro').prop('disabled', false); + }catch(e){} + }catch(e){} + + try{ + $("#compPapelNegrohq").val(parseInt(comp_data.bnhq.papel_id)).trigger('change'); + + try{ + var newState = new Option(comp_data.bnhq.gramaje, comp_data.bnhq.gramaje, true, true); + // Append it to the select + $("#compGramajeNegrohq").append(newState).trigger('change'); + $('#compGramajeNegrohq').prop('disabled', false); + }catch(e){} + }catch(e){} + + try{ + $("#compPapelColor").val(parseInt(comp_data.color.papel_id)).trigger('change'); + + try{ + var newState = new Option(comp_data.color.gramaje, comp_data.color.gramaje, true, true); + // Append it to the select + $("#compGramajeColor").append(newState).trigger('change'); + $('#compGramajeColor').prop('disabled', false); + }catch(e){} + }catch(e){} + + try{ + $("#compPapelColorhq").val(parseInt(comp_data.colorhq.papel_id)).trigger('change'); + + try{ + var newState = new Option(comp_data.colorhq.gramaje, comp_data.colorhq.gramaje, true, true); + // Append it to the select + $("#compGramajeColorhq").append(newState).trigger('change'); + $('#compGramajeColorhq').prop('disabled', false); + }catch(e){} + }catch(e){} + + try{ + $("#compCarasCubierta").val(parseInt(comp_data.cubierta.paginas)).trigger('select2:select'); + try{ + $("#compPapelCubierta").val(parseInt(comp_data.cubierta.papel_id)).trigger('select2:select'); + + try{ + var newState = new Option(comp_data.cubierta.gramaje, comp_data.cubierta.gramaje, true, true); + // Append it to the select + $("#compGramajeCubierta").append(newState).trigger('change'); + $('#compGramajeCubierta').prop('disabled', false); + }catch(e){} + }catch(e){} + }catch(e){} + + var timp = 'comp_tipo_impresion; ?>' + switch(timp){ + case 'negro': + checkComparadorInt(false,false) + break; + case 'negrohq': + checkComparadorInt(false,true) + break; + case 'color': + checkComparadorInt(true,false) + break; + case 'colorhq': + checkComparadorInt(true,true) + break; + default: + break; + } + + computarPaginasColor($('#compPosPaginasColor').val()); + + } + + var tableCompIntPlana = new DataTable('#tableCompIntPlana',{ + scrollX: true, + searching: false, + paging: false, + info: false, + ordering: false, + responsive: true, + select: false, + language: { + url: "//cdn.datatables.net/plug-ins/1.13.4/i18n/i18n ?>.json" + }, + columns: [ + { 'data': 'tipo', + 'render': function ( data, type, row, meta ) { + if(data=='bn') + return ''; + else if(data=='bnhq') + return ''; + else if(data=='color') + return ''; + else if(data=='colorhq') + return ''; + } + }, + { 'data': 'paginas' }, + { 'data': 'papel' }, + { 'data': 'gramaje' }, + { 'data': 'marca' }, + { 'data': 'maquina' }, + { 'data': 'numeroPliegos' }, + { 'data': 'pliegosPedido' }, + { 'data': 'precioPliego' }, + { 'data': 'libro' }, + { 'data': 'totalPapelPedido' }, + { 'data': 'lomo' }, + { 'data': 'peso' }, + { 'data': 'click' }, + { 'data': 'totalClicks' }, + { 'data': 'total' }, + { 'data': 'maquinaId'}, + { 'data': 'maquinaVelocidad'}, + { 'data': 'tiempoMaquina'}, + { 'data': 'papelGenericoId'}, + { 'data': 'papelImpresionId'}, + { 'data': 'tarifa_impresion_id'} + ], + columnDefs: [ + { + target: [16,17,18,19,20,21], + visible: false, + searchable: false + }, + ] + }); + + + var tableCompIntRotativa = new DataTable('#tableCompIntRotativa',{ + scrollX: true, + searching: false, + paging: false, + info: false, + ordering: false, + responsive: true, + select: false, + language: { + url: "//cdn.datatables.net/plug-ins/1.13.4/i18n/i18n ?>.json" + }, + columns: [ + { 'data': 'tipo', + 'render': function ( data, type, row, meta ) { + if(data=='rotativa') + return ''; + } + }, + { 'data': 'paginas' }, + { 'data': 'papel' }, + { 'data': 'gramaje' }, + { 'data': 'marca' }, + { 'data': 'aFavorFibra', + 'render': function(data, type, row, meta){ + if(data=='si') + return ''; + else if(data=='no') + return ''; + } + }, + { 'data': 'maquina' }, + { 'data': 'numeroPliegos' }, + { 'data': 'pliegosPedido' }, + { 'data': 'precioPliego' }, + { 'data': 'libro' }, + { 'data': 'totalPapelPedido' }, + { 'data': 'lomo' }, + { 'data': 'peso' }, + { 'data': 'click' }, + { 'data': 'totalClicks' }, + { 'data': 'precioPagNegro' }, + { 'data': 'precioPagColor' }, + { 'data': 'totalTinta' }, + { 'data': 'totalCorte' }, + { 'data': 'total' }, + { 'data': 'maquinaId'}, + { 'data': 'maquinaVelocidad'}, + { 'data': 'tiempoMaquina'}, + { 'data': 'papelGenericoId'}, + { 'data': 'papelImpresionId'}, + { 'data': 'paginasColor'}, + { 'data': 'tarifa_impresion_id'} + ], + columnDefs: [ + { + target: [21,22,23,24,25,26,27], + visible: false, + searchable: false + }, + ] + }); + + var tableCompCubierta = new DataTable('#tableCompCubierta',{ + scrollX: true, + searching: false, + paging: false, + info: false, + ordering: false, + responsive: true, + select: false, + language: { + url: "//cdn.datatables.net/plug-ins/1.13.4/i18n/i18n ?>.json" + }, + columns: [ + { 'data': 'tipo', + 'render': function ( data, type, row, meta ) { + if(data=='cubierta') + return ''; + else if(data=='sobrecubierta') + return ''; + } + }, + { 'data': 'paginas' }, + { 'data': 'papel' }, + { 'data': 'gramaje' }, + { 'data': 'marca' }, + { 'data': 'maquina' }, + { 'data': 'numeroPliegos' }, + { 'data': 'pliegosPedido' }, + { 'data': 'precioPliego' }, + { 'data': 'libro' }, + { 'data': 'totalPapelPedido' }, + { 'data': 'lomo' }, + { 'data': 'peso' }, + { 'data': 'click' }, + { 'data': 'totalClicks' }, + { 'data': 'total' }, + { 'data': 'maquinaId'}, + { 'data': 'maquinaVelocidad'}, + { 'data': 'tiempoMaquina'}, + { 'data': 'papelGenericoId'}, + { 'data': 'papelImpresionId'}, + { 'data': 'tarifa_impresion_id'} + ], + columnDefs: [ + { + target: [16,17,18,19,20,21], + visible: false, + searchable: false + }, + ] + }); + + $('.comp_negro_items').on('change', function (e) { + + checkComparadorInt(false,false); + }); + + $('.comp_negrohq_items').on('change', function (e) { + + checkComparadorInt(false, true); + }); + + $('.comp_color_items').on('change', function (e) { + + checkComparadorInt(true, false); + }); + + $('.comp_colorhq_items').on('change', function (e) { + checkComparadorInt(true, true); + }); + + async function getLineasIntPlana(is_color, is_hq){ + + const dimension = getDimensionLibro(); + + let datos = { + type: 'interior', + color: is_color?1:0, + hq: is_hq?1:0, + paginas: parseInt($(''+ elementos.paginas).val()), + tirada: parseInt($('#tirada').val()), + merma: parseInt($('#merma').val()), + ancho: dimension.ancho, + alto: dimension.alto, + papel_generico_id: $(''+ elementos.papel).select2('data')[0].id, + papel_generico: $(''+ elementos.papel).select2('data')[0].text.trim(), + gramaje: $(''+ elementos.gramaje).select2('data')[0].text.trim() , + : v + }; + + $.ajax({ + type: "POST", + url: "/cosidotapablanda/datatable", + data: datos, + success: function (data) { + + clearIntLineas(is_color); + + if(data.lineas.length >0){ + + fillIntPlana(data, is_color, is_hq); + selectIntLineas(); + $('#title_int_plana').html('' + ' (' + tableCompIntPlana.rows().count() + ')'); + $('#insertarPlanaBtn').removeClass('d-none') + } + else{ + $('#title_int_plana').html(''); + $('#insertarPlanaBtn').addClass('d-none') + $('#total_comp_plana').html('0.00'); + } + yeniden(data.); + return true; + }, + error: function(e){ + return false; + } + }) + return false; + } + + async function getLineasIntRot(is_hq){ + + const dimension = getDimensionLibro(); + + // Rotativa solo negro o color (no hq) + if ( is_hq==false){ + + if(checkInputsForRotativa()){ + + let datos = { + type: 'interior_rot', + paginas: parseInt($('#paginas').val()), + paginas_negro: parseInt($('#compPaginasNegro').val()), + paginas_color: parseInt($('#compPaginasColor').val()), + tirada: parseInt($('#tirada').val()), + merma: parseInt($('#merma').val()), + ancho: dimension.ancho, + alto: dimension.alto, + // el papel y el gramaje se coge del negro (siempre estará) + papel_generico_id: $('#compPapelNegro').select2('data')[0].id, + papel_generico: $('#compPapelNegro').select2('data')[0].text.trim(), + gramaje: $('#compGramajeNegro').select2('data')[0].text.trim() , + : v + }; + + $.ajax({ + type: "POST", + url: "/cosidotapablanda/datatable", + data: datos, + success: function (data) { + + clearIntRot(); + + if(data.lineas.length >0){ + + fillIntRot(data); + selectIntRotLineas(); + $('#title_int_rot').html('' + ' (' + tableCompIntRotativa.rows().count() + ')'); + $('#insertarRotativaBtn').removeClass('d-none') + } + else{ + $('#title_int_rot').html(''); + $('#insertarRotativaBtn').addClass('d-none') + $('#total_comp_rot').html('0.00') + + } + yeniden(data.); + return true; + }, + error: function(e){ + return false; + } + }) + } + } + return false; + } + + $('.comp_cubierta_items').on('change', function (){ + + if ($('#compCarasCubierta').select2('data').length > 0 && + $('#compPapelCubierta').select2('data').length > 0 && + $('#compGramajeCubierta').select2('data').length > 0 ){ + + const dimension = getDimensionLibro(); + + let datos = { + type: 'cubierta', + paginas: parseInt($('#compCarasCubierta').select2('data')[0].id), + tirada: parseInt($('#tirada').val()), + merma: parseInt($('#mermacubierta').val()), + color: 1, + ancho: dimension.ancho, + alto: dimension.alto, + solapas: $('#solapas').is(':checked')?1:0, + solapas_ancho: parseInt($('#solapas_ancho').val()), + papel_generico_id: $('#compPapelCubierta').select2('data')[0].id, + papel_generico: $('#compPapelCubierta').select2('data')[0].text.trim(), + gramaje: $('#compGramajeCubierta').select2('data')[0].text.trim() , + : v + }; + + $.ajax({ + type: "POST", + url: "/cosidotapablanda/datatable", + data: datos, + success: function (data) { + + clearCubierta(); + + if(data.lineas.length >0){ + + fillCubierta(data); + selectCubiertaLineas(); + $('#title_cubierta').html('' + ' (' + tableCompCubierta.rows().count() + ')'); + $('#insertarCubiertaBtn').removeClass('d-none') + + } + else{ + $('#title_cubierta').html(''); + $('#insertarCubiertaBtn').addClass('d-none') + $('#total_comp_cubierta').html('0.00') + + } + yeniden(data.); + return true; + }, + error: function(e){ + return false; + } + }) + } + + else{ + clearCubierta(); + } + }); + + + $('#tipoImpresion').on("change", function () { + updatePapelesComparador(); + + $('#title_int_rot').html(''); + $('#title_int_plana').html(''); + $('#paginas').change(); + + $('#tableCompIntRotativa').DataTable().clear().draw(); + $('#total_comp_rot').html("0.00"); + + $('#tableCompIntPlana').DataTable().clear().draw(); + $('#total_comp_plana').html("0.00"); + + }); + + + $('.comp_negro_items').on('change', function (e) { + + checkComparadorInt(false,false); + }); + + $('.comp_negrohq_items').on('change', function (e) { + + checkComparadorInt(false, true); + }); + + $('.comp_color_items').on('change', function (e) { + + checkComparadorInt(true, false); + }); + + $('.comp_colorhq_items').on('change', function (e) { + checkComparadorInt(true, true); + }); + + async function getLineasIntPlana(is_color, is_hq){ + + const dimension = getDimensionLibro(); + + let datos = { + type: 'interior', + color: is_color?1:0, + hq: is_hq?1:0, + paginas: parseInt($(''+ elementos.paginas).val()), + tirada: parseInt($('#tirada').val()), + merma: parseInt($('#merma').val()), + ancho: dimension.ancho, + alto: dimension.alto, + papel_generico_id: $(''+ elementos.papel).select2('data')[0].id, + papel_generico: $(''+ elementos.papel).select2('data')[0].text.trim(), + gramaje: $(''+ elementos.gramaje).select2('data')[0].text.trim() , + : v + }; + + $.ajax({ + type: "POST", + url: "/cosidotapablanda/datatable", + data: datos, + success: function (data) { + + clearIntLineas(is_color); + + if(data.lineas.length >0){ + + fillIntPlana(data, is_color, is_hq); + selectIntLineas(); + $('#title_int_plana').html('' + ' (' + tableCompIntPlana.rows().count() + ')'); + $('#insertarPlanaBtn').removeClass('d-none') + } + else{ + $('#title_int_plana').html(''); + $('#insertarPlanaBtn').addClass('d-none') + $('#total_comp_plana').html('0.00'); + } + yeniden(data.); + return true; + }, + error: function(e){ + return false; + } + }) + return false; + } + + async function getLineasIntRot(is_hq){ + + const dimension = getDimensionLibro(); + + // Rotativa solo negro o color (no hq) + if ( is_hq==false){ + + if(checkInputsForRotativa()){ + + let datos = { + type: 'interior_rot', + paginas: parseInt($('#paginas').val()), + paginas_negro: parseInt($('#compPaginasNegro').val()), + paginas_color: parseInt($('#compPaginasColor').val()), + tirada: parseInt($('#tirada').val()), + merma: parseInt($('#merma').val()), + ancho: dimension.ancho, + alto: dimension.alto, + // el papel y el gramaje se coge del negro (siempre estará) + papel_generico_id: $('#compPapelNegro').select2('data')[0].id, + papel_generico: $('#compPapelNegro').select2('data')[0].text.trim(), + gramaje: $('#compGramajeNegro').select2('data')[0].text.trim() , + : v + }; + + $.ajax({ + type: "POST", + url: "/cosidotapablanda/datatable", + data: datos, + success: function (data) { + + clearIntRot(); + + if(data.lineas.length >0){ + + fillIntRot(data); + selectIntRotLineas(); + $('#title_int_rot').html('' + ' (' + tableCompIntRotativa.rows().count() + ')'); + $('#insertarRotativaBtn').removeClass('d-none') + } + else{ + $('#title_int_rot').html(''); + $('#insertarRotativaBtn').addClass('d-none') + $('#total_comp_rot').html('0.00') + + } + yeniden(data.); + return true; + }, + error: function(e){ + return false; + } + }) + } + } + return false; + } + + + $('.comp_cubierta_items').on('change', function (){ + + if ($('#compCarasCubierta').select2('data').length > 0 && + $('#compPapelCubierta').select2('data').length > 0 && + $('#compGramajeCubierta').select2('data').length > 0 ){ + + const dimension = getDimensionLibro(); + + let datos = { + type: 'cubierta', + paginas: parseInt($('#compCarasCubierta').select2('data')[0].id), + tirada: parseInt($('#tirada').val()), + merma: parseInt($('#mermacubierta').val()), + color: 1, + ancho: dimension.ancho, + alto: dimension.alto, + solapas: $('#solapas').is(':checked')?1:0, + solapas_ancho: parseInt($('#solapas_ancho').val()), + papel_generico_id: $('#compPapelCubierta').select2('data')[0].id, + papel_generico: $('#compPapelCubierta').select2('data')[0].text.trim(), + gramaje: $('#compGramajeCubierta').select2('data')[0].text.trim() , + : v + }; + + $.ajax({ + type: "POST", + url: "/cosidotapablanda/datatable", + data: datos, + success: function (data) { + + clearCubierta(); + + if(data.lineas.length >0){ + + fillCubierta(data); + selectCubiertaLineas(); + $('#title_cubierta').html('' + ' (' + tableCompCubierta.rows().count() + ')'); + $('#insertarCubiertaBtn').removeClass('d-none') + + } + else{ + $('#title_cubierta').html(''); + $('#insertarCubiertaBtn').addClass('d-none') + $('#total_comp_cubierta').html('0.00') + + } + yeniden(data.); + return true; + }, + error: function(e){ + return false; + } + }) + } + + else{ + clearCubierta(); + } + }); + + + $('#tipoImpresion').on("change", function () { + updatePapelesComparador(); + $('#title_int_rot').html(''); + $('#title_int_plana').html(''); + $('#paginas').change(); + + + if (($('#tipoImpresion').select2('data')[0].id == 'negro' || + $('#tipoImpresion').select2('data')[0].id == 'color')){ + + $('#tableCompIntRotativa').DataTable().clear().draw(); + $('#total_comp_rot').html("0.00"); + + if( $('#tableCompIntPlana').DataTable().rows().count() > 0 && + $('#tableCompIntPlana').DataTable().cell(0, 0).data().includes('hq')) { + + $('#tableCompIntPlana').DataTable().clear().draw(); + $('#total_comp_plana').html("0.00"); + } + + } + else if (($('#tipoImpresion').select2('data')[0].id == 'negrohq' || + $('#tipoImpresion').select2('data')[0].id == 'colorhq')){ + + $('#tableCompIntRotativa').DataTable().clear().draw(); + $('#total_comp_rot').html("0.00"); + + if($('#tableCompIntPlana').DataTable().rows().count() > 0 && + !$('#tableCompIntPlana').DataTable().cell(0, 0).data().includes('hq')) { + + $('#tableCompIntPlana').DataTable().clear().draw(); + $('#total_comp_plana').html("0.00"); + } + } + }); + + + function checkComparadorInt(is_color, is_hq) { + + try{ + + clearIntLineas(is_color); + clearIntRot(); + $('#title_int_rot').html(''); + $('#title_int_plana').html(''); + + elementos = getIDsComparador(is_color, is_hq) + + if ($(''+ elementos.papel).select2('data').length > 0 && + $(''+ elementos.gramaje).select2('data').length > 0 && + parseInt($(''+ elementos.paginas).val()) > 0 && + checkDatosPedidoForComp()) { + + getLineasIntPlana(is_color, is_hq).then((result) =>{ + // Para rotativa, si es color el papel y el gramaje tiene que ser igual + if(!is_color) + { + getLineasIntRot(is_hq); + } + else + { + if(!is_hq){ + if ($('#compPapelNegro').select2('data')>0 && $('#compPapelColor').select2('data')>0 && + $('#compGramajeNegro').select2('data')>0 && $('#compGramajeColor').select2('data')>0) + { + if(($('#compPapelNegro').select2('data')[0].id == $('#compPapelColor').select2('data')[0].id && + $('#compGramajeNegro').select2('data')[0].text.trim() == $('#compGramajeColor').select2('data')[0].text.trim())) + { + getLineasIntRot(is_hq); + } + else + { + $('#errorComRot').html(''); + } + } + } + } + }); + } + }catch(e){} + } + + + $('#compPapelNegro').on('select2:select', function (e){ + + if($('#compPapelNegro').select2('data')[0].id=='0'){ + $('#compGramajeNegro').val('').change(); + $('#compGramajeNegro').prop('disabled', true); + } + + else{ + $('#insertarPlanaBtn').addClass('d-none') + $('#insertarRotativaBtn').addClass('d-none') + $('#total_comp_plana').html('0.00') + $('#total_comp_rot').html('0.00') + $('#compGramajeNegro').val('').change(); + $('#compGramajeNegro').empty().trigger("change"); + $('#compGramajeNegro').prop('disabled', false); + $('#compGramajeNegro').select2({ + allowClear: false, + minimumResultsForSearch: Infinity, + ajax: { + url: '', + type: 'post', + dataType: 'json', + + data: function (params) { + return { + tipo: 'gramaje', + uso: 'bn', + datos: $('#compPapelNegro').select2('data')[0].text.trim() , + : v + }; + }, + delay: 60, + processResults: function (response) { + yeniden(response.); + return { + results: response.menu + }; + }, + cache: true + } + }); + } + }); + + $('#compPapelNegrohq').on('select2:select', function (e){ + + if($('#compPapelNegrohq').select2('data')[0].id=='0'){ + $('#compGramajeNegrohq').val('').change(); + $('#compGramajeNegrohq').prop('disabled', true); + } + else{ + $('#insertarPlanaBtn').addClass('d-none') + $('#insertarRotativaBtn').addClass('d-none') + $('#total_comp_plana').html('0.00') + $('#total_comp_rot').html('0.00') + $('#compGramajeNegrohq').empty().trigger("change"); + $('#compGramajeNegrohq').prop('disabled', false); + $('#compGramajeNegrohq').select2({ + allowClear: false, + minimumResultsForSearch: Infinity, + ajax: { + url: '', + type: 'post', + dataType: 'json', + + data: function (params) { + return { + tipo: 'gramaje', + uso: 'bnhq', + datos: $('#compPapelNegrohq').select2('data')[0].text.trim() , + : v + }; + }, + delay: 60, + processResults: function (response) { + yeniden(response.); + return { + results: response.menu + }; + }, + cache: true + } + }); + } + }); + + + $('#compPapelColor').on('select2:select', function (e){ + + if($('#compPapelColor').select2('data')[0].id=='0'){ + $('#compGramajeColor').val('').change(); + $('#compGramajeColor').prop('disabled', true); + } + else{ + $('#insertarPlanaBtn').addClass('d-none') + $('#insertarRotativaBtn').addClass('d-none') + $('#total_comp_plana').html('0.00') + $('#total_comp_rot').html('0.00') + $('#compGramajeColor').empty().trigger("change"); + $('#compGramajeColor').prop('disabled', false); + $('#compPapelColor').find('option[value="0"]').remove(); + $('#compGramajeColor').select2({ + allowClear: false, + minimumResultsForSearch: Infinity, + ajax: { + url: '', + type: 'post', + dataType: 'json', + + data: function (params) { + return { + tipo: 'gramaje', + uso: 'color', + datos: $('#compPapelColor').select2('data')[0].text.trim() , + : v + }; + }, + delay: 60, + processResults: function (response) { + yeniden(response.); + return { + results: response.menu + }; + }, + cache: true + } + }); + } + }); + + + $('#compPapelColorhq').on('select2:select', function (e){ + + if($('#compPapelColorhq').select2('data')[0].id=='0'){ + $('#compGramajeColorhq').val('').change(); + $('#compGramajeColorhq').prop('disabled', true); + } + else{ + $('#insertarPlanaBtn').addClass('d-none') + $('#insertarRotativaBtn').addClass('d-none') + $('#total_comp_plana').html('0.00') + $('#total_comp_rot').html('0.00') + $('#compGramajeColorhq').empty().trigger("change"); + $('#compGramajeColorhq').prop('disabled', false); + $('#compPapelColorhq').find('option[value="0"]').remove(); + $('#compGramajeColorhq').select2({ + allowClear: false, + minimumResultsForSearch: Infinity, + ajax: { + url: '', + type: 'post', + dataType: 'json', + + data: function (params) { + return { + tipo: 'gramaje', + uso: 'colorhq', + datos: $('#compPapelColorhq').select2('data')[0].text.trim() , + : v + }; + }, + delay: 60, + processResults: function (response) { + yeniden(response.); + return { + results: response.menu + }; + }, + cache: true + } + }); + } + }); + + $('#compPapelCubierta').on('select2:select', function (e){ + if($('#compPapelCubierta').select2('data')[0].id=='0'){ + $('#compGramajeCubierta').val('').change(); + $('#compGramajeCubierta').prop('disabled', true); + } + else{ + $('#insertarCubiertaBtn').addClass('d-none') + $('#total_comp_cubierta').html('0.00') + $('#compGramajeCubierta').val('').trigger('change'); + $('#compGramajeCubierta').prop('disabled', false); + $('#compPapelCubierta').find('option[value="0"]').remove(); + $('#compGramajeCubierta').select2({ + allowClear: false, + minimumResultsForSearch: Infinity, + ajax: { + url: '', + type: 'post', + dataType: 'json', + + data: function (params) { + return { + tipo: 'gramaje', + uso: 'cubierta', + datos: $('#compPapelCubierta').select2('data')[0].text.trim() , + : v + }; + }, + delay: 60, + processResults: function (response) { + yeniden(response.); + return { + results: response.menu + }; + }, + cache: true + } + }); + } + }); + + + function checkDatosPedidoForComp() { + + const dimension = getDimensionLibro(); + + if (parseInt($('#paginas').val()) <= 0){ + popErrorAlert('', 'divAlarmasComparador'); + return false; + } + if (parseInt($('#tirada').val()) <= 0){ + popErrorAlert('', 'divAlarmasComparador'); + return false; + } + if('ancho' in dimension && 'alto' in dimension){ + + if(dimension.alto < 60 || dimension.ancho < 60 || isNaN(dimension.alto) || isNaN(dimension.ancho) ){ + popErrorAlert('', 'divAlarmasComparador'); + return false; + } + } + else{ + popErrorAlert('', 'divAlarmasComparador'); + return false; + } + return true; + } + + init_comparador(); + +endSection() ?> \ No newline at end of file diff --git a/ci4/app/Views/themes/backend/vuexy/form/presupuestos/cosidotapablanda/_datosPresupuestoItems.php b/ci4/app/Views/themes/backend/vuexy/form/presupuestos/cosidotapablanda/_datosPresupuestoItems.php index 8429d740..f0d3dd22 100644 --- a/ci4/app/Views/themes/backend/vuexy/form/presupuestos/cosidotapablanda/_datosPresupuestoItems.php +++ b/ci4/app/Views/themes/backend/vuexy/form/presupuestos/cosidotapablanda/_datosPresupuestoItems.php @@ -25,7 +25,11 @@ - "> + + "> + + "> + @@ -34,7 +38,10 @@ - + @@ -47,7 +54,7 @@ $v) : ?> - + @@ -83,6 +84,7 @@ + @@ -126,6 +128,7 @@ + @@ -170,6 +173,7 @@ + @@ -213,6 +217,7 @@ + @@ -263,7 +268,7 @@
- +
@@ -462,6 +467,7 @@ + @@ -513,7 +519,7 @@
- +
@@ -710,6 +716,7 @@ + @@ -1276,16 +1284,8 @@ function fill_lp_bn(row, fromComparator=false){ $('#lp_bn_maquina').append(``); - $('#lp_bn_tiempo').val(row.tiempoMaquina) - $('#lp_bn_numeroPliegos').val(isNaN(parseFloat(row.numeroPliegos)) ? "" : parseFloat(row.numeroPliegos).toFixed(2)) - $('#lp_bn_pliegosPedido').val(isNaN(parseFloat(row.pliegosPedido)) ? "" : parseFloat(row.pliegosPedido).toFixed(2)) - $('#lp_bn_precioPliego').val(isNaN(parseFloat(row.precioPliego)) ? "" : parseFloat(row.precioPliego).toFixed(6)) - $('#lp_bn_libro').val(isNaN(parseFloat(row.libro)) ? "" : parseFloat(row.libro).toFixed(2)) - $('#lp_bn_totalPapelPedido').val(isNaN(parseFloat(row.totalPapelPedido)) ? "" : parseFloat(row.totalPapelPedido).toFixed(2)) - $('#lp_bn_lomo').val(isNaN(parseFloat(row.lomo)) ? "" : parseFloat(row.lomo).toFixed(2)) - $('#lp_bn_peso').val(isNaN(parseFloat(row.peso)) ? "" : parseFloat(row.peso).toFixed(2)) - $('#lp_bn_click').val(isNaN(parseFloat(row.click)) ? "" : parseFloat(row.click).toFixed(6)) - $('#lp_bn_totalClicks').val(isNaN(parseFloat(row.totalClicks)) ? "" : parseFloat(row.totalClicks).toFixed(2)) + + calcularPresupuesto_bn(false) } else{ // Si viene de hacerlo a mano... @@ -1299,6 +1299,8 @@ function fill_lp_bn(row, fromComparator=false){ $('#lp_bn_peso').val(isNaN(parseFloat(row.peso)) ? "" : parseFloat(row.peso).toFixed(2)) $('#lp_bn_click').val(isNaN(parseFloat(row.precio_click)) ? "" : parseFloat(row.precio_click).toFixed(6)) $('#lp_bn_totalClicks').val(isNaN(parseFloat(row.precio_click_pedido)) ? "" : parseFloat(row.precio_click_pedido).toFixed(2)) + + $('#lp_bn_tarifa_impresion_id').val(isNaN(parseInt(row.tarifa_impresion_id)) ? "" : parseInt(row.tarifa_impresion_id)) } @@ -1508,16 +1510,8 @@ function fill_lp_color(row, fromComparator=false){ $('#lp_color_maquina').append(``); - $('#lp_color_tiempo').val(row.tiempoMaquina) - $('#lp_color_numeroPliegos').val(isNaN(parseFloat(row.numeroPliegos)) ? "" : parseFloat(row.numeroPliegos).toFixed(2)) - $('#lp_color_pliegosPedido').val(isNaN(parseFloat(row.pliegosPedido)) ? "" : parseFloat(row.pliegosPedido).toFixed(2)) - $('#lp_color_precioPliego').val(isNaN(parseFloat(row.precioPliego)) ? "" : parseFloat(row.precioPliego).toFixed(6)) - $('#lp_color_libro').val(isNaN(parseFloat(row.libro)) ? "" : parseFloat(row.libro).toFixed(2)) - $('#lp_color_totalPapelPedido').val(isNaN(parseFloat(row.totalPapelPedido)) ? "" : parseFloat(row.totalPapelPedido).toFixed(2)) - $('#lp_color_lomo').val(isNaN(parseFloat(row.lomo)) ? "" : parseFloat(row.lomo).toFixed(2)) - $('#lp_color_peso').val(isNaN(parseFloat(row.peso)) ? "" : parseFloat(row.peso).toFixed(2)) - $('#lp_color_click').val(isNaN(parseFloat(row.click)) ? "" : parseFloat(row.click).toFixed(6)) - $('#lp_color_totalClicks').val(isNaN(parseFloat(row.totalClicks)) ? "" : parseFloat(row.totalClicks).toFixed(2)) + + calcularPresupuesto_color(false) } else{ // Si viene de hacerlo a mano... @@ -1531,6 +1525,8 @@ function fill_lp_color(row, fromComparator=false){ $('#lp_color_peso').val(isNaN(parseFloat(row.peso)) ? "" : parseFloat(row.peso).toFixed(2)) $('#lp_color_click').val(isNaN(parseFloat(row.precio_click)) ? "" : parseFloat(row.precio_click).toFixed(6)) $('#lp_color_totalClicks').val(isNaN(parseFloat(row.precio_click_pedido)) ? "" : parseFloat(row.precio_click_pedido).toFixed(2)) + + $('#lp_color_tarifa_impresion_id').val(isNaN(parseInt(row.tarifa_impresion_id)) ? "" : parseInt(row.tarifa_impresion_id)) } @@ -1739,16 +1735,8 @@ function fill_lp_bnhq(row, fromComparator=false){ $('#lp_bnhq_maquina').append(``); - $('#lp_bnhq_tiempo').val(row.tiempoMaquina) - $('#lp_bnhq_numeroPliegos').val(isNaN(parseFloat(row.numeroPliegos)) ? "" : parseFloat(row.numeroPliegos).toFixed(2)) - $('#lp_bnhq_pliegosPedido').val(isNaN(parseFloat(row.pliegosPedido)) ? "" : parseFloat(row.pliegosPedido).toFixed(2)) - $('#lp_bnhq_precioPliego').val(isNaN(parseFloat(row.precioPliego)) ? "" : parseFloat(row.precioPliego).toFixed(6)) - $('#lp_bnhq_libro').val(isNaN(parseFloat(row.libro)) ? "" : parseFloat(row.libro).toFixed(2)) - $('#lp_bnhq_totalPapelPedido').val(isNaN(parseFloat(row.totalPapelPedido)) ? "" : parseFloat(row.totalPapelPedido).toFixed(2)) - $('#lp_bnhq_lomo').val(isNaN(parseFloat(row.lomo)) ? "" : parseFloat(row.lomo).toFixed(2)) - $('#lp_bnhq_peso').val(isNaN(parseFloat(row.peso)) ? "" : parseFloat(row.peso).toFixed(2)) - $('#lp_bnhq_click').val(isNaN(parseFloat(row.click)) ? "" : parseFloat(row.click).toFixed(6)) - $('#lp_bnhq_totalClicks').val(isNaN(parseFloat(row.totalClicks)) ? "" : parseFloat(row.totalClicks).toFixed(2)) + + calcularPresupuesto_bnhq(false) } else{ // Si viene de hacerlo a mano... @@ -1762,6 +1750,8 @@ function fill_lp_bnhq(row, fromComparator=false){ $('#lp_bnhq_peso').val(isNaN(parseFloat(row.peso)) ? "" : parseFloat(row.peso).toFixed(2)) $('#lp_bnhq_click').val(isNaN(parseFloat(row.precio_click)) ? "" : parseFloat(row.precio_click).toFixed(6)) $('#lp_bnhq_totalClicks').val(isNaN(parseFloat(row.precio_click_pedido)) ? "" : parseFloat(row.precio_click_pedido).toFixed(2)) + + $('#lp_bnhq_tarifa_impresion_id').val(isNaN(parseInt(row.tarifa_impresion_id)) ? "" : parseInt(row.tarifa_impresion_id)) } @@ -1972,16 +1962,8 @@ function fill_lp_colorhq(row, fromComparator=false){ $('#lp_colorhq_maquina').append(``); - $('#lp_colorhq_tiempo').val(row.tiempoMaquina) - $('#lp_colorhq_numeroPliegos').val(isNaN(parseFloat(row.numeroPliegos)) ? "" : parseFloat(row.numeroPliegos).toFixed(2)) - $('#lp_colorhq_pliegosPedido').val(isNaN(parseFloat(row.pliegosPedido)) ? "" : parseFloat(row.pliegosPedido).toFixed(2)) - $('#lp_colorhq_precioPliego').val(isNaN(parseFloat(row.precioPliego)) ? "" : parseFloat(row.precioPliego).toFixed(6)) - $('#lp_colorhq_libro').val(isNaN(parseFloat(row.libro)) ? "" : parseFloat(row.libro).toFixed(2)) - $('#lp_colorhq_totalPapelPedido').val(isNaN(parseFloat(row.totalPapelPedido)) ? "" : parseFloat(row.totalPapelPedido).toFixed(2)) - $('#lp_colorhq_lomo').val(isNaN(parseFloat(row.lomo)) ? "" : parseFloat(row.lomo).toFixed(2)) - $('#lp_colorhq_peso').val(isNaN(parseFloat(row.peso)) ? "" : parseFloat(row.peso).toFixed(2)) - $('#lp_colorhq_click').val(isNaN(parseFloat(row.click)) ? "" : parseFloat(row.click).toFixed(6)) - $('#lp_colorhq_totalClicks').val(isNaN(parseFloat(row.totalClicks)) ? "" : parseFloat(row.totalClicks).toFixed(2)) + + calcularPresupuesto_colorhq(row, false) } else{ // Si viene de hacerlo a mano... @@ -1995,6 +1977,8 @@ function fill_lp_colorhq(row, fromComparator=false){ $('#lp_colorhq_peso').val(isNaN(parseFloat(row.peso)) ? "" : parseFloat(row.peso).toFixed(2)) $('#lp_colorhq_click').val(isNaN(parseFloat(row.precio_click)) ? "" : parseFloat(row.precio_click).toFixed(6)) $('#lp_colorhq_totalClicks').val(isNaN(parseFloat(row.precio_click_pedido)) ? "" : parseFloat(row.precio_click_pedido).toFixed(2)) + + $('#lp_colorhq_tarifa_impresion_id').val(isNaN(parseInt(row.tarifa_impresion_id)) ? "" : parseInt(row.tarifa_impresion_id)) } @@ -2326,6 +2310,8 @@ function fill_lp_rot_bn(row, fromComparador=false){ $('#lp_rot_bn_gTintaCyanPed').val(isNaN(parseFloat(row.peso_gotas_cyan_pedido)) ? "" : parseFloat(row.peso_gotas_cyan_pedido).toFixed(2)) $('#lp_rot_bn_gTintaMagentaPed').val(isNaN(parseFloat(row.peso_gotas_magenta_pedido)) ? "" : parseFloat(row.peso_gotas_magenta_pedido).toFixed(2)) $('#lp_rot_bn_gTintaAmarilloPed').val(isNaN(parseFloat(row.peso_gotas_amarillo_pedido)) ? "" : parseFloat(row.peso_gotas_amarillo_pedido).toFixed(2)) + + $('#lp_rot_bn_tarifa_impresion_id').val(isNaN(parseInt(row.tarifa_impresion_id)) ? "" : parseInt(row.tarifa_impresion_id)) } @@ -2665,6 +2651,10 @@ function fill_lp_rot_color(row, fromComparador=false){ $('#lp_rot_color_gTintaCyanPed').val(isNaN(parseFloat(row.peso_gotas_cyan_pedido)) ? "" : parseFloat(row.peso_gotas_cyan_pedido).toFixed(2)) $('#lp_rot_color_gTintaMagentaPed').val(isNaN(parseFloat(row.peso_gotas_magenta_pedido)) ? "" : parseFloat(row.peso_gotas_magenta_pedido).toFixed(2)) $('#lp_rot_color_gTintaAmarilloPed').val(isNaN(parseFloat(row.peso_gotas_amarillo_pedido)) ? "" : parseFloat(row.peso_gotas_amarillo_pedido).toFixed(2)) + + $('#lp_rot_color_numPagColor').val(row.paginas_color) + + $('#lp_rot_color_tarifa_impresion_id').val(isNaN(parseInt(row.tarifa_impresion_id)) ? "" : parseInt(row.tarifa_impresion_id)) } @@ -2678,6 +2668,20 @@ function fill_lp_rot_color(row, fromComparador=false){ section("additionalInlineJs") ?> +var tableLineasPresupuesto = new DataTable('#tableLineasPresupuesto',{ + scrollX: true, + searching: false, + paging: false, + info: false, + ordering: false, + responsive: true, + select: false, + language: { + url: "//cdn.datatables.net/plug-ins/1.13.4/i18n/i18n ?>.json" + }, + +}); + async function set_lp_cubierta_gramaje(){ await $.ajax({ @@ -2907,11 +2911,230 @@ function fill_lp_cubierta(row, fromComparador=false){ $('#lp_cubierta_click').val(isNaN(parseFloat(row.precio_click)) ? "" : parseFloat(row.precio_click).toFixed(6)) $('#lp_cubierta_totalClicks').val(isNaN(parseFloat(row.precio_click_pedido)) ? "" : parseFloat(row.precio_click_pedido).toFixed(2)) $('#lp_cubierta_totalLinea').val(isNaN(parseFloat(row.total_impresion)) ? "" : parseFloat(row.total_impresion).toFixed(2)) - - } + $('#lp_cubierta_impresion_id').val(isNaN(parseInt(row.tarifa_impresion_id))) ? "" : parseInt(row.tarifa_impresion_id) + $('#lp_cubierta_tarifa_impresion_id').val(isNaN(parseInt(row.tarifa_impresion_id)) ? "" : parseInt(row.tarifa_impresion_id)) + } $('.lp_cubierta').css('display', '') $("#tableLineasPresupuesto").DataTable().columns.adjust(); } + + +fill_lp_from_bbdd() + +function fill_lp_from_bbdd(){ + + const lineasPresupuestoList = ; + lineasPresupuestoList.forEach(function(lp) { + + $('#lp_' + lp.tipo + '_paginas').val(lp.paginas) + + $( '#lp_' + lp.tipo + '_papel').val(lp.papel_id) + $( '#lp_' + lp.tipo + '_gramaje').html(lp.gramaje); + $( '#lp_' + lp.tipo + '_gramaje').append(new Option(parseFloat(lp.gramaje).toFixed(0), lp.gramaje)) + $( '#lp_' + lp.tipo + '_papelImpresion').append(new Option(lp.papel_impresion_nombre, lp.papel_impresion_id)) + $( '#lp_' + lp.tipo + '_maquina').append(new Option(lp.maquina_nombre, lp.maquina_id)) + + + var date = new Date(0); + date.setSeconds(lp.tiempo_maquina); // specify value for SECONDS here + var timeString = date.toISOString().substring(11, 19); + $('#lp_' + lp.tipo + '_tiempo').val(timeString) + + $('#lp_' + lp.tipo + '_numeroPliegos').val(isNaN(parseFloat(lp.pliegos_libro)) ? "" : parseFloat(lp.pliegos_libro).toFixed(2)) + $('#lp_' + lp.tipo + '_pliegosPedido').val(isNaN(parseFloat(lp.pliegos_pedido)) ? "" : parseFloat(lp.pliegos_pedido).toFixed(2)) + $('#lp_' + lp.tipo + '_precioPliego').val(isNaN(parseFloat(lp.pliegos_precio)) ? "" : parseFloat(lp.pliegos_precio).toFixed(6)) + $('#lp_' + lp.tipo + '_libro').val(isNaN(parseFloat(lp.libro)) ? "" : parseFloat(lp.libro).toFixed(2)) + $('#lp_' + lp.tipo + '_totalPapelPedido').val(isNaN(parseFloat(lp.total_papel_pedido)) ? "" : parseFloat(lp.total_papel_pedido).toFixed(2)) + $('#lp_' + lp.tipo + '_lomo').val(isNaN(parseFloat(lp.mano)) ? "" : parseFloat(lp.mano).toFixed(2)) + $('#lp_' + lp.tipo + '_peso').val(isNaN(parseFloat(lp.peso)) ? "" : parseFloat(lp.peso).toFixed(2)) + $('#lp_' + lp.tipo + '_click').val(isNaN(parseFloat(lp.precio_click)) ? "" : parseFloat(lp.precio_click).toFixed(6)) + $('#lp_' + lp.tipo + '_totalClicks').val(isNaN(parseFloat(lp.precio_click_pedido)) ? "" : parseFloat(lp.precio_click_pedido).toFixed(2)) + + $('#lp_' + lp.tipo + '_checkPapel').prop('checked', lp.check_papel_total==0?false:true) + $('#lp_' + lp.tipo + '_checkClicks').prop('checked', lp.check_impresion_total==0?false:true) + + $('#lp_' + lp.tipo + '_tarifa_impresion_id').val(isNaN(parseInt(lp.tarifa_impresion_id)) ? "" : parseInt(lp.tarifa_impresion_id)) + + if(lp.tipo == 'rot_bn' ||lp.tipo == 'rot_color'){ + + $('#lp_' + lp.tipo + '_numPagColor').val(isNaN(parseFloat(lp.rotativa_pag_color)) ? "" : parseFloat(lp.rotativa_pag_color).toFixed(0)) + $('#lp_' + lp.tipo + '_totalLinea').val(isNaN(parseFloat(lp.rotativa_total_impresion)) ? "" : parseFloat(lp.rotativa_total_impresion).toFixed(2)) + $('#lp_' + lp.tipo + '_aFavorFibra').prop('checked', lp.rotativa_a_favor_fibra==0?false:true) + + $('#lp_' + lp.tipo + '_cobNegro').val(isNaN(parseFloat(lp.rotativa_negro)) ? "" : parseFloat(lp.rotativa_negro).toFixed(0)) + $('#lp_' + lp.tipo + '_cobCyan').val(isNaN(parseFloat(lp.rotativa_cyan)) ? "" : parseFloat(lp.rotativa_cyan).toFixed(0)) + $('#lp_' + lp.tipo + '_cobMagenta').val(isNaN(parseFloat(lp.rotativa_magenta)) ? "" : parseFloat(lp.rotativa_magenta).toFixed(0)) + $('#lp_' + lp.tipo + '_cobAmarillo').val(isNaN(parseFloat(lp.rotativa_amarillo)) ? "" : parseFloat(lp.rotativa_amarillo).toFixed(0)) + $('#lp_' + lp.tipo + '_gotaNegro').val(isNaN(parseFloat(lp.rotativa_gota_negro)) ? "" : parseFloat(lp.rotativa_gota_negro).toFixed(0)) + $('#lp_' + lp.tipo + '_gotaColor').val(isNaN(parseFloat(lp.rotativa_gota_color)) ? "" : parseFloat(lp.rotativa_gota_color).toFixed(0)) + + $('#lp_' + lp.tipo + '_metrosMinuto').val(isNaN(parseFloat(lp.rotativa_mxm)) ? "" : parseFloat(lp.rotativa_mxm).toFixed(2)) + $('#lp_' + lp.tipo + '_resolucion').val(isNaN(parseFloat(lp.rotativa_resolucion)) ? "" : parseFloat(lp.rotativa_resolucion).toFixed(0)) + $('#lp_' + lp.tipo + '_areaPaginas').val(isNaN(parseFloat(lp.rotativa_area_paginas)) ? "" : parseFloat(lp.rotativa_area_paginas).toFixed(2)) + + $('#lp_' + lp.tipo + '_gotasNegro').val(isNaN(parseFloat(lp.rotativa_num_gotas_negro)) ? "" : parseFloat(lp.rotativa_num_gotas_negro).toFixed(0)) + $('#lp_' + lp.tipo + '_gotasCyan').val(isNaN(parseFloat(lp.rotativa_num_gotas_cyan)) ? "" : parseFloat(lp.rotativa_num_gotas_cyan).toFixed(0)) + $('#lp_' + lp.tipo + '_gotasMagenta').val(isNaN(parseFloat(lp.rotativa_num_gotas_magenta)) ? "" : parseFloat(lp.rotativa_num_gotas_magenta).toFixed(0)) + $('#lp_' + lp.tipo + '_gotasAmarillo').val(isNaN(parseFloat(lp.rotativa_num_gotas_amarillo)) ? "" : parseFloat(lp.rotativa_num_gotas_amarillo).toFixed(0)) + + $('#lp_' + lp.tipo + '_precioPagNegro').val(isNaN(parseFloat(lp.rotativa_precio_pag_negro)) ? "" : parseFloat(lp.rotativa_precio_pag_negro).toFixed(6)) + $('#lp_' + lp.tipo + '_precioPagColor').val(isNaN(parseFloat(lp.rotativa_precio_pag_color)) ? "" : parseFloat(lp.rotativa_precio_pag_color).toFixed(6)) + $('#lp_' + lp.tipo + '_factorAltura').val(isNaN(parseFloat(lp.rotativa_factor_altura)) ? "" : parseFloat(lp.rotativa_factor_altura).toFixed(2)) + $('#lp_' + lp.tipo + '_factorAnchura').val(isNaN(parseFloat(lp.rotativa_factor_anchura)) ? "" : parseFloat(lp.rotativa_factor_anchura).toFixed(2)) + $('#lp_' + lp.tipo + '_paginasPliego').val(isNaN(parseFloat(lp.rotativa_pag_por_pliego)) ? "" : parseFloat(lp.rotativa_pag_por_pliego).toFixed(2)) + + $('#lp_' + lp.tipo + '_metrosPapelLibro').val(isNaN(parseFloat(lp.rotativa_metros_libro)) ? "" : parseFloat(lp.rotativa_metros_libro).toFixed(2)) + $('#lp_' + lp.tipo + '_metrosPapelTotal').val(isNaN(parseFloat(lp.rotativa_metros_total)) ? "" : parseFloat(lp.rotativa_metros_total).toFixed(2)) + $('#lp_' + lp.tipo + '_clicksLibro').val(isNaN(parseFloat(lp.rotativa_clicks_libro)) ? "" : parseFloat(lp.rotativa_clicks_libro).toFixed(0)) + $('#lp_' + lp.tipo + '_gTintaNegro').val(isNaN(parseFloat(lp.rotativa_peso_gotas_negro)) ? "" : parseFloat(lp.rotativa_peso_gotas_negro).toFixed(2)) + $('#lp_' + lp.tipo + '_gTintaCyan').val(isNaN(parseFloat(lp.rotativa_peso_gotas_cyan)) ? "" : parseFloat(lp.rotativa_peso_gotas_cyan).toFixed(2)) + $('#lp_' + lp.tipo + '_gTintaMagenta').val(isNaN(parseFloat(lp.rotativa_peso_gotas_magenta)) ? "" : parseFloat(lp.rotativa_peso_gotas_magenta).toFixed(2)) + $('#lp_' + lp.tipo + '_gTintaAmarillo').val(isNaN(parseFloat(lp.rotativa_peso_gotas_amarillo)) ? "" : parseFloat(lp.rotativa_peso_gotas_amarillo).toFixed(2)) + $('#lp_' + lp.tipo + '_clicksPedido').val(isNaN(parseFloat(lp.rotativa_clicks_total)) ? "" : parseFloat(lp.rotativa_clicks_total).toFixed(0)) + $('#lp_' + lp.tipo + '_totalClicksPedido').val(isNaN(parseFloat(lp.precio_click_pedido)) ? "" : parseFloat(lp.precio_click_pedido).toFixed(2)) + $('#lp_' + lp.tipo + '_totalTinta').val(isNaN(parseFloat(lp.rotativa_precio_tinta)) ? "" : parseFloat(lp.rotativa_precio_tinta).toFixed(2)) + $('#lp_' + lp.tipo + '_totalCorte').val(isNaN(parseFloat(lp.rotativa_total_corte)) ? "" : parseFloat(lp.rotativa_total_corte).toFixed(2)) + $('#lp_' + lp.tipo + '_totalImpresion').val(isNaN(parseFloat(lp.rotativa_total_impresion)) ? "" : parseFloat(lp.rotativa_total_impresion).toFixed(2)) + + $('#lp_' + lp.tipo + '_velocidadCorte').val(isNaN(parseFloat(lp.rotativa_velocidad_corte)) ? "" : parseFloat(lp.rotativa_velocidad_corte).toFixed(2)) + $('#lp_' + lp.tipo + '_precioHoraCorte').val(isNaN(parseFloat(lp.rotativa_precio_hora_corte)) ? "" : parseFloat(lp.rotativa_precio_hora_corte).toFixed(2)) + $('#lp_' + lp.tipo + '_tiempoCorte').val(isNaN(parseFloat(lp.rotativa_tiempo_corte)) ? "" : parseFloat(lp.rotativa_tiempo_corte).toFixed(2)) + $('#lp_' + lp.tipo + '_gTintaNegroPed').val(isNaN(parseFloat(lp.rotativa_peso_gotas_negro_pedido)) ? "" : parseFloat(lp.rotativa_peso_gotas_negro_pedido).toFixed(2)) + $('#lp_' + lp.tipo + '_gTintaCyanPed').val(isNaN(parseFloat(lp.rotativa_peso_gotas_cyan_pedido)) ? "" : parseFloat(lp.rotativa_peso_gotas_cyan_pedido).toFixed(2)) + $('#lp_' + lp.tipo + '_gTintaMagentaPed').val(isNaN(parseFloat(lp.rotativa_peso_gotas_magenta_pedido)) ? "" : parseFloat(lp.rotativa_peso_gotas_magenta_pedido).toFixed(2)) + $('#lp_' + lp.tipo + '_gTintaAmarilloPed').val(isNaN(parseFloat(lp.rotativa_peso_gotas_amarillo_pedido)) ? "" : parseFloat(lp.rotativa_peso_gotas_amarillo_pedido).toFixed(2)) + } + + $('.lp_' + lp.tipo).css('display', '') + + }) + + $("#tableLineasPresupuesto").DataTable().draw(); +} + + +async function fill_bbdd_from_lp(presupuesto_id){ + + const tiposLineas = ['bn','bnhq','color','colorhq','cubierta','rot_bn','rot_color']; + data=[]; + tiposLineas.forEach(function(tipo_lp) { + + if($('#lp_' + tipo_lp).css('display') != 'none'){ + + + let t_maq_str = $('#lp_' + tipo_lp + '_tiempo').val().split(':'); // split it at the colons + let t_maq = 0 + if(t_maq_str.length == 3) + t_maq = (+t_maq_str[0]) * 3600 + (+t_maq_str[1]) * 60 + (+t_maq_str[2]); + + linea_data = { + presupuesto_id: presupuesto_id, + tipo: tipo_lp, + paginas: $('#lp_' + tipo_lp + '_paginas').val(), + papel_id: $( '#lp_' + tipo_lp + '_papel').val(), + gramaje: $( '#lp_' + tipo_lp + '_gramaje option:selected' ).text().trim(), + papel_impresion_id: $( '#lp_' + tipo_lp + '_papelImpresion').val(), + maquina_id: $( '#lp_' + tipo_lp + '_maquina').val(), + tiempo_maquina: t_maq, + pliegos_libro: $('#lp_' + tipo_lp + '_numeroPliegos').val(), + pliegos_pedido: $('#lp_' + tipo_lp + '_pliegosPedido').val(), + pliegos_precio: $('#lp_' + tipo_lp + '_precioPliego').val(), + libro: $('#lp_' + tipo_lp + '_libro').val(), + total_papel_pedido: $('#lp_' + tipo_lp + '_totalPapelPedido').val(), + mano: $('#lp_' + tipo_lp + '_lomo').val(), + peso: $('#lp_' + tipo_lp + '_peso').val(), + precio_click: $('#lp_' + tipo_lp + '_click').val(), + precio_click_pedido: $('#lp_' + tipo_lp + '_totalClicks').val(), + check_papel_total: $('#lp_' + tipo_lp + '_checkPapel').is(":checked")?1:0, + check_impresion_total: $('#lp_' + tipo_lp + '_checkClicks').is(":checked")?1:0, + tarifa_impresion_id: $('#lp_' + tipo_lp + '_tarifa_impresion_id').val(), + isActiva: 1, + } + + if(tipo_lp == 'rot_bn' || tipo_lp == 'rot_color'){ + + linea_data.rotativa_pag_color = $('#lp_' + tipo_lp +'_numPagColor').val() + linea_data.rotativa_total_impresion = $('#lp_' + tipo_lp + '_totalLinea').val() + linea_data.rotativa_a_favor_fibra = $('#lp_' + tipo_lp + '_aFavorFibra').is(":checked")?1:0 + linea_data.rotativa_negro = $('#lp_' + tipo_lp + '_cobNegro').val() + linea_data.rotativa_cyan = $('#lp_' + tipo_lp + '_cobCyan').val() + linea_data.rotativa_magenta = $('#lp_' + tipo_lp + '_cobMagenta').val() + linea_data.rotativa_amarillo = $('#lp_' + tipo_lp + '_cobAmarillo').val() + linea_data.rotativa_gota_negro = $('#lp_' + tipo_lp + '_gotaNegro').val() + linea_data.rotativa_gota_color = $('#lp_' + tipo_lp + '_gotaColor').val() + + linea_data.rotativa_mxm = $('#lp_' + tipo_lp + '_metrosMinuto').val() + linea_data.rotativa_resolucion = $('#lp_' + tipo_lp + '_resolucion').val() + linea_data.rotativa_area_paginas = $('#lp_' + tipo_lp + '_areaPaginas').val() + + linea_data.rotativa_num_gotas_negro = $('#lp_' + tipo_lp + '_gotasNegro').val() + linea_data.rotativa_num_gotas_cyan = $('#lp_' + tipo_lp + '_gotasCyan').val() + linea_data.rotativa_num_gotas_magenta = $('#lp_' + tipo_lp + '_gotasMagenta').val() + linea_data.rotativa_num_gotas_amarillo = $('#lp_' + tipo_lp + '_gotasAmarillo').val() + + linea_data.rotativa_precio_pag_negro = $('#lp_' + tipo_lp + '_precioPagNegro').val() + linea_data.rotativa_precio_pag_color = $('#lp_' + tipo_lp + '_precioPagColor').val() + linea_data.rotativa_factor_altura = $('#lp_' + tipo_lp + '_factorAltura').val() + linea_data.rotativa_factor_anchura = $('#lp_' + tipo_lp + '_factorAnchura').val() + linea_data.rotativa_pag_por_pliego = $('#lp_' + tipo_lp + '_paginasPliego').val() + + linea_data.rotativa_metros_libro = $('#lp_' + tipo_lp + '_metrosPapelLibro').val() + linea_data.rotativa_metros_total = $('#lp_' + tipo_lp + '_metrosPapelTotal').val() + linea_data.rotativa_clicks_libro = $('#lp_' + tipo_lp + '_clicksLibro').val() + linea_data.rotativa_peso_gotas_negro = $('#lp_' + tipo_lp + '_gTintaNegro').val() + linea_data.rotativa_peso_gotas_cyan = $('#lp_' + tipo_lp + '_gTintaCyan').val() + linea_data.rotativa_peso_gotas_magenta = $('#lp_' + tipo_lp + '_gTintaMagenta').val() + linea_data.rotativa_peso_gotas_amarillo = $('#lp_' + tipo_lp + '_gTintaAmarillo').val() + linea_data.rotativa_clicks_total = $('#lp_' + tipo_lp + '_clicksPedido').val() + linea_data.precio_click_pedido = $('#lp_' + tipo_lp + '_totalClicksPedido').val() + linea_data.rotativa_precio_tinta = $('#lp_' + tipo_lp + '_totalTinta').val() + linea_data.rotativa_total_corte = $('#lp_' + tipo_lp + '_totalCorte').val() + linea_data.rotativa_total_impresion = $('#lp_' + tipo_lp + '_totalImpresion').val() + + linea_data.rotativa_velocidad_corte = $('#lp_' + tipo_lp + '_velocidadCorte').val() + linea_data.rotativa_precio_hora_corte = $('#lp_' + tipo_lp + '_precioHoraCorte').val() + linea_data.rotativa_tiempo_corte = $('#lp_' + tipo_lp + '_tiempoCorte').val() + linea_data.rotativa_peso_gotas_negro_pedido = $('#lp_' + tipo_lp + '_gTintaNegroPed').val() + linea_data.rotativa_peso_gotas_cyan_pedido = $('#lp_' + tipo_lp + '_gTintaCyanPed').val() + linea_data.rotativa_peso_gotas_magenta_pedido = $('#lp_' + tipo_lp + '_gTintaMagentaPed').val() + linea_data.rotativa_peso_gotas_amarillo_pedido = $('#lp_' + tipo_lp + '_gTintaAmarilloPed').val() + + } + data.push(linea_data) + } + else{ + data.push({ + presupuesto_id: presupuesto_id, + tipo: tipo_lp, + isActiva: 0, + }) + } + }) + + await $.ajax({ + type: 'post', + url: '', + + data: { + tipo: 'lineasPresupuesto', + datos: data, + presupuesto_id: presupuesto_id, + : v + }, + dataType: 'json', + success:function(response){ + + token=response.; + yeniden(token); + } + }).fail(function (jqXHR, textStatus, error) { + // Handle error here + console.log(jqXHR) + }); +} + + + endSection() ?> \ No newline at end of file diff --git a/ci4/app/Views/themes/backend/vuexy/form/presupuestos/cosidotapablanda/comparador.js b/ci4/app/Views/themes/backend/vuexy/form/presupuestos/cosidotapablanda/comparador.js index 70093224..68e3b497 100644 --- a/ci4/app/Views/themes/backend/vuexy/form/presupuestos/cosidotapablanda/comparador.js +++ b/ci4/app/Views/themes/backend/vuexy/form/presupuestos/cosidotapablanda/comparador.js @@ -176,6 +176,7 @@ function getRowFromLineaInt(tipo, linea) { 'tiempoMaquina': linea.fields.tiempo_maquina, 'papelGenericoId': linea.fields.papel_generico_id, 'papelImpresionId': linea.fields.papel_impresion_id, + 'tarifa_impresion_id': linea.fields.tarifa_impresion_id, } } @@ -209,6 +210,7 @@ function getRowFromLineaRot(linea) { 'papelGenericoId': linea.fields.papel_generico_id, 'papelImpresionId': linea.fields.papel_impresion_id, 'paginasColor': linea.fields.paginas_color, + 'tarifa_impresion_id': linea.fields.tarifa_impresion_id, } } @@ -216,15 +218,6 @@ function getRowFromLineaRot(linea) { -function init_comparador() { - updatePapelesComparador(); - const paginasColor = document.getElementById('compCalPaginasColor'); - if (paginasColor.value.length > 0) { - computarPaginasColor(paginasColor.value); - } -} - - function computarPaginasColor(string) { var numbers = []; @@ -294,7 +287,6 @@ function updatePapelesComparador() { Array.from(elements_colorhq).forEach(element => { element.style.display = "none"; }); - clearNegro(); break; case "negrohq": @@ -348,12 +340,6 @@ function updatePapelesComparador() { } } -function clearNegro() { - document.getElementById('compPaginasNegro').value = 0; - $('#compGramajeNegro').val('').change(); - $('#compGramajeNegro').prop('disabled', true); - $('#compPapelNegro').val('data', { id: '0' }); -} function clearIntLineas(is_color){ @@ -573,13 +559,104 @@ function fillCubierta(data, is_color, is_hq){ }) } -function clearCompTable(clearNegro=true,clearColor=false,clearCubierta=false){ - if(clearNegro){ - - } +function clearCompTable(){ $('#insertarPlanaBtn').addClass('d-none') $('#insertarRotativaBtn').addClass('d-none') $('#total_comp_plana').html('0.00') $('#total_comp_rot').html('0.00') } + +function generateCompJSON(){ + + data = {} + + if( $('#tipoImpresion').select2('data')[0].id == 'negro' || $('#tipoImpresion').select2('data')[0].id == 'color') + { + try{ + bn_obj = { + "bn":{ + 'paginas': $('#compPaginasNegro').val(), + 'papel_id': $('#compPapelNegro').select2('data')[0].id, + 'gramaje': $('#compGramajeNegro').select2('data')[0].text.trim(), + } + } + } + catch (e){ + bn_obj = {} + } + $.extend( data, bn_obj ); + } + + if( $('#tipoImpresion').select2('data')[0].id == 'negrohq' || $('#tipoImpresion').select2('data')[0].id == 'colorhq') + { + try{ + bnhq_obj = { + "bnhq":{ + 'paginas': $('#compPaginasNegrohq').val(), + 'papel_id': $('#compPapelNegrohq').select2('data')[0].id, + 'gramaje': $('#compGramajeNegrohq').select2('data')[0].text.trim(), + } + } + } + catch (e){ + bnhq_obj = {} + } + $.extend( data, bnhq_obj ); + } + + if($('#tipoImpresion').select2('data')[0].id == 'color') + { + try{ + color_obj = { + "color":{ + 'paginas': $('#compPaginasColor').val(), + 'papel_id': $('#compPapelColor').select2('data')[0].id, + 'gramaje': $('#compGramajeColor').select2('data')[0].text.trim(), + }, + } + } + catch (e){ + color_obj = {} + } + $.extend( data, color_obj ); + + } + + + if($('#tipoImpresion').select2('data')[0].id == 'colorhq') + { + try{ + colorhq_obj = { + "colorhq":{ + 'paginas': $('#compPaginasColorhq').val(), + 'papel_id': $('#compPapelColorhq').select2('data')[0].id, + 'gramaje': $('#compGramajeColorhq').select2('data')[0].text.trim(), + }, + } + } + catch (e){ + colorhq_obj = {} + } + $.extend( data, colorhq_obj ); + } + + + try{ + cubierta_obj = { + "cubierta":{ + 'paginas': $('#compCarasCubierta').select2('data')[0].id, + 'papel_id': $('#compPapelCubierta').select2('data')[0].id, + 'gramaje': $('#compGramajeCubierta').select2('data')[0].text.trim(), + }, + } + } + catch (e){ + cubierta_obj = {} + } + + $.extend( data, cubierta_obj ); + + data_str = JSON.stringify(data) + $('#comparador_json_data').val(data_str) +} \ No newline at end of file diff --git a/ci4/app/Views/themes/backend/vuexy/form/presupuestos/cosidotapablanda/viewCosidotapablandaForm.php b/ci4/app/Views/themes/backend/vuexy/form/presupuestos/cosidotapablanda/viewCosidotapablandaForm.php index 5e9f843b..2256d1bd 100644 --- a/ci4/app/Views/themes/backend/vuexy/form/presupuestos/cosidotapablanda/viewCosidotapablandaForm.php +++ b/ci4/app/Views/themes/backend/vuexy/form/presupuestos/cosidotapablanda/viewCosidotapablandaForm.php @@ -16,21 +16,28 @@ getErrors()) ? $validation->listErrors("bootstrap_style") : "" ?> + - - - - - - + + + + + + + + + +
" /> - "btn btn-dark float-start me-sm-3 me-1",]) ?> - "btn btn-info float-start me-sm-3 me-1",]) ?> + + "btn btn-dark float-start me-sm-3 me-1",]) ?> + "btn btn-info float-start me-sm-3 me-1",]) ?> + "btn btn-secondary float-start",]) ?>
@@ -84,990 +91,49 @@ allowClear: false, }); - $('#papelFormatoId').select2({ - allowClear: false, - }); - - $('#tipoImpresion').select2({ - allowClear: false, - }); - - $('#compPapelNegro').select2({ - allowClear: false, - }); - - $('#compGramajeNegro').select2({ - allowClear: false, - }); - - $('#compPapelNegrohq').select2({ - allowClear: false, - }); - - $('#compGramajeNegrohq').select2({ - allowClear: false, - }); - - $('#compPapelColor').select2({ - allowClear: false, - }); - - $('#compPapelColorhq').select2({ - allowClear: false, - }); - - $('#compGramajeColor').select2({ - allowClear: false, - }); - - $('#compGramajeColorhq').select2({ - allowClear: false, - }); - - $('#compPapelCubierta').select2({ - allowClear: false, - }); - - $('#compGramajeCubierta').select2({ - allowClear: false, - }); - - $('#encuadernacion').select2({ - allowClear: false, - }); - - $('#compCarasCubierta').select2({ - allowClear: false, - minimumResultsForSearch: Infinity, - }); - + + endSection() ?> + - + + section("additionalInlineJs") ?> - autosize($('#compCalPaginasColor')); - - $('#papelFormatoPersonalizado').on("click",function(){ - var checkbox = document.getElementById('papelFormatoPersonalizado'); - if(checkbox.checked == true){ - document.getElementById("papelFormatoAncho").style.display = "block"; - document.getElementById("papelFormatoAlto").style.display = "block"; - $('#papelFormatoId').next(".select2-container").hide(); - $('#papelFormatoId').val('').change(); - document.getElementById("label_papelFormatoId").innerHTML = - " (" + - " x )*"; - } - else{ - document.getElementById("papelFormatoAncho").value= ""; - document.getElementById("papelFormatoAlto").value= ""; - document.getElementById("papelFormatoAncho").style.display = "none"; - document.getElementById("papelFormatoAlto").style.display = "none"; - $('#papelFormatoId').next(".select2-container").show(); - document.getElementById("label_papelFormatoId").innerHTML = - "*"; - } - }); - - - init_comparador(); - - - var tableCompIntPlana = new DataTable('#tableCompIntPlana',{ - scrollX: true, - searching: false, - paging: false, - info: false, - ordering: false, - responsive: true, - select: false, - language: { - url: "//cdn.datatables.net/plug-ins/1.13.4/i18n/i18n ?>.json" - }, - columns: [ - { 'data': 'tipo', - 'render': function ( data, type, row, meta ) { - if(data=='bn') - return ''; - else if(data=='bnhq') - return ''; - else if(data=='color') - return ''; - else if(data=='colorhq') - return ''; - } - }, - { 'data': 'paginas' }, - { 'data': 'papel' }, - { 'data': 'gramaje' }, - { 'data': 'marca' }, - { 'data': 'maquina' }, - { 'data': 'numeroPliegos' }, - { 'data': 'pliegosPedido' }, - { 'data': 'precioPliego' }, - { 'data': 'libro' }, - { 'data': 'totalPapelPedido' }, - { 'data': 'lomo' }, - { 'data': 'peso' }, - { 'data': 'click' }, - { 'data': 'totalClicks' }, - { 'data': 'total' }, - { 'data': 'maquinaId'}, - { 'data': 'maquinaVelocidad'}, - { 'data': 'tiempoMaquina'}, - { 'data': 'papelGenericoId'}, - { 'data': 'papelImpresionId'} - ], - columnDefs: [ - { - target: [16,17,18,19,20], - visible: false, - searchable: false - }, - ] - }); - - - var tableCompIntRotativa = new DataTable('#tableCompIntRotativa',{ - scrollX: true, - searching: false, - paging: false, - info: false, - ordering: false, - responsive: true, - select: false, - language: { - url: "//cdn.datatables.net/plug-ins/1.13.4/i18n/i18n ?>.json" - }, - columns: [ - { 'data': 'tipo', - 'render': function ( data, type, row, meta ) { - if(data=='rotativa') - return ''; - } - }, - { 'data': 'paginas' }, - { 'data': 'papel' }, - { 'data': 'gramaje' }, - { 'data': 'marca' }, - { 'data': 'aFavorFibra', - 'render': function(data, type, row, meta){ - if(data=='si') - return ''; - else if(data=='no') - return ''; - } - }, - { 'data': 'maquina' }, - { 'data': 'numeroPliegos' }, - { 'data': 'pliegosPedido' }, - { 'data': 'precioPliego' }, - { 'data': 'libro' }, - { 'data': 'totalPapelPedido' }, - { 'data': 'lomo' }, - { 'data': 'peso' }, - { 'data': 'click' }, - { 'data': 'totalClicks' }, - { 'data': 'precioPagNegro' }, - { 'data': 'precioPagColor' }, - { 'data': 'totalTinta' }, - { 'data': 'totalCorte' }, - { 'data': 'total' }, - { 'data': 'maquinaId'}, - { 'data': 'maquinaVelocidad'}, - { 'data': 'tiempoMaquina'}, - { 'data': 'papelGenericoId'}, - { 'data': 'papelImpresionId'}, - { 'data': 'paginasColor'}, - ], - columnDefs: [ - { - target: [21,22,23,24,25,26], - visible: false, - searchable: false - }, - ] - }); - - var tableCompCubierta = new DataTable('#tableCompCubierta',{ - scrollX: true, - searching: false, - paging: false, - info: false, - ordering: false, - responsive: true, - select: false, - language: { - url: "//cdn.datatables.net/plug-ins/1.13.4/i18n/i18n ?>.json" - }, - columns: [ - { 'data': 'tipo', - 'render': function ( data, type, row, meta ) { - if(data=='cubierta') - return ''; - else if(data=='sobrecubierta') - return ''; - } - }, - { 'data': 'paginas' }, - { 'data': 'papel' }, - { 'data': 'gramaje' }, - { 'data': 'marca' }, - { 'data': 'maquina' }, - { 'data': 'numeroPliegos' }, - { 'data': 'pliegosPedido' }, - { 'data': 'precioPliego' }, - { 'data': 'libro' }, - { 'data': 'totalPapelPedido' }, - { 'data': 'lomo' }, - { 'data': 'peso' }, - { 'data': 'click' }, - { 'data': 'totalClicks' }, - { 'data': 'total' }, - { 'data': 'maquinaId'}, - { 'data': 'maquinaVelocidad'}, - { 'data': 'tiempoMaquina'}, - { 'data': 'papelGenericoId'}, - { 'data': 'papelImpresionId'} - ], - columnDefs: [ - { - target: [16,17,18,19,20], - visible: false, - searchable: false - }, - ] - }); - - const papelGenericoNegroList = ; - - - var tableLineasPresupuesto = new DataTable('#tableLineasPresupuesto',{ - scrollX: true, - searching: false, - paging: false, - info: false, - ordering: false, - responsive: true, - select: false, - language: { - url: "//cdn.datatables.net/plug-ins/1.13.4/i18n/i18n ?>.json" - }, - - }); - - - $('.comp_negro_items').on('change', function (e) { - - checkComparadorInt(false,false); - }); - - $('.comp_negrohq_items').on('change', function (e) { - - checkComparadorInt(false, true); - }); - - $('.comp_color_items').on('change', function (e) { - - checkComparadorInt(true, false); - }); - - $('.comp_colorhq_items').on('change', function (e) { - checkComparadorInt(true, true); - }); - - async function getLineasIntPlana(is_color, is_hq){ - - const dimension = getDimensionLibro(); - - let datos = { - type: 'interior', - color: is_color?1:0, - hq: is_hq?1:0, - paginas: parseInt($(''+ elementos.paginas).val()), - tirada: parseInt($('#tirada').val()), - merma: parseInt($('#merma').val()), - ancho: dimension.ancho, - alto: dimension.alto, - papel_generico_id: $(''+ elementos.papel).select2('data')[0].id, - papel_generico: $(''+ elementos.papel).select2('data')[0].text.trim(), - gramaje: $(''+ elementos.gramaje).select2('data')[0].text.trim() , - : v - }; +if(url_parts[url_parts.length-2] == 'edit'){ + id = url_parts[url_parts.length-1]; +} +else{ + id = -1; +} +$('#presupuestoForm').on( "submit", function( event ) { + event.preventDefault(); + $.when(fill_bbdd_from_lp(id).then(function (data, textStatus, jqXHR){ + generateCompJSON() + form = $('#presupuestoForm').serialize() $.ajax({ type: "POST", - url: "/cosidotapablanda/datatable", - data: datos, + url: "", + data: form, success: function (data) { - - clearIntLineas(is_color); - - if(data.lineas.length >0){ - - fillIntPlana(data, is_color, is_hq); - selectIntLineas(); - $('#title_int_plana').html('' + ' (' + tableCompIntPlana.rows().count() + ')'); - $('#insertarPlanaBtn').removeClass('d-none') - } - else{ - $('#title_int_plana').html(''); - $('#insertarPlanaBtn').addClass('d-none') - $('#total_comp_plana').html('0.00'); - } - yeniden(data.); - return true; - }, - error: function(e){ - return false; + yeniden(data.) + popSuccessAlert(data.mensaje) } - }) - return false; - } - - async function getLineasIntRot(is_hq){ - - const dimension = getDimensionLibro(); - - // Rotativa solo negro o color (no hq) - if ( is_hq==false){ - - if(checkInputsForRotativa()){ + }).fail(function (jqXHR, textStatus, error) { + // Handle error here + console.log(jqXHR) + });; + })) - let datos = { - type: 'interior_rot', - paginas: parseInt($('#paginas').val()), - paginas_negro: parseInt($('#compPaginasNegro').val()), - paginas_color: parseInt($('#compPaginasColor').val()), - tirada: parseInt($('#tirada').val()), - merma: parseInt($('#merma').val()), - ancho: dimension.ancho, - alto: dimension.alto, - // el papel y el gramaje se coge del negro (siempre estará) - papel_generico_id: $('#compPapelNegro').select2('data')[0].id, - papel_generico: $('#compPapelNegro').select2('data')[0].text.trim(), - gramaje: $('#compGramajeNegro').select2('data')[0].text.trim() , - : v - }; - - $.ajax({ - type: "POST", - url: "/cosidotapablanda/datatable", - data: datos, - success: function (data) { - - clearIntRot(); - - if(data.lineas.length >0){ - - fillIntRot(data); - selectIntRotLineas(); - $('#title_int_rot').html('' + ' (' + tableCompIntRotativa.rows().count() + ')'); - $('#insertarRotativaBtn').removeClass('d-none') - } - else{ - $('#title_int_rot').html(''); - $('#insertarRotativaBtn').addClass('d-none') - $('#total_comp_rot').html('0.00') - - } - yeniden(data.); - return true; - }, - error: function(e){ - return false; - } - }) - } - } - return false; - } - - $('.comp_cubierta_items').on('change', function (){ - - if ($('#compCarasCubierta').select2('data').length > 0 && - $('#compPapelCubierta').select2('data').length > 0 && - $('#compGramajeCubierta').select2('data').length > 0 ){ - - const dimension = getDimensionLibro(); - - let datos = { - type: 'cubierta', - paginas: parseInt($('#compCarasCubierta').select2('data')[0].id), - tirada: parseInt($('#tirada').val()), - merma: parseInt($('#mermacubierta').val()), - color: 1, - ancho: dimension.ancho, - alto: dimension.alto, - solapas: $('#solapas').is(':checked')?1:0, - solapas_ancho: parseInt($('#solapas_ancho').val()), - papel_generico_id: $('#compPapelCubierta').select2('data')[0].id, - papel_generico: $('#compPapelCubierta').select2('data')[0].text.trim(), - gramaje: $('#compGramajeCubierta').select2('data')[0].text.trim() , - : v - }; - - $.ajax({ - type: "POST", - url: "/cosidotapablanda/datatable", - data: datos, - success: function (data) { - - clearCubierta(); - - if(data.lineas.length >0){ - - fillCubierta(data); - selectCubiertaLineas(); - $('#title_cubierta').html('' + ' (' + tableCompCubierta.rows().count() + ')'); - $('#insertarCubiertaBtn').removeClass('d-none') - - } - else{ - $('#title_cubierta').html(''); - $('#insertarCubiertaBtn').addClass('d-none') - $('#total_comp_cubierta').html('0.00') - - } - yeniden(data.); - return true; - }, - error: function(e){ - return false; - } - }) - } - - else{ - clearCubierta(); - } - }); - - - $('#tipoImpresion').on("change", function () { - updatePapelesComparador(); - - $('#title_int_rot').html(''); - $('#title_int_plana').html(''); - $('#paginas').change(); - - $('#tableCompIntRotativa').DataTable().clear().draw(); - $('#total_comp_rot').html("0.00"); - - $('#tableCompIntPlana').DataTable().clear().draw(); - $('#total_comp_plana').html("0.00"); - - }); - - - $('.comp_negro_items').on('change', function (e) { - - checkComparadorInt(false,false); - }); - - $('.comp_negrohq_items').on('change', function (e) { - - checkComparadorInt(false, true); - }); - - $('.comp_color_items').on('change', function (e) { - - checkComparadorInt(true, false); - }); - - $('.comp_colorhq_items').on('change', function (e) { - checkComparadorInt(true, true); - }); - - async function getLineasIntPlana(is_color, is_hq){ - - const dimension = getDimensionLibro(); - - let datos = { - type: 'interior', - color: is_color?1:0, - hq: is_hq?1:0, - paginas: parseInt($(''+ elementos.paginas).val()), - tirada: parseInt($('#tirada').val()), - merma: parseInt($('#merma').val()), - ancho: dimension.ancho, - alto: dimension.alto, - papel_generico_id: $(''+ elementos.papel).select2('data')[0].id, - papel_generico: $(''+ elementos.papel).select2('data')[0].text.trim(), - gramaje: $(''+ elementos.gramaje).select2('data')[0].text.trim() , - : v - }; - - $.ajax({ - type: "POST", - url: "/cosidotapablanda/datatable", - data: datos, - success: function (data) { - - clearIntLineas(is_color); - - if(data.lineas.length >0){ - - fillIntPlana(data, is_color, is_hq); - selectIntLineas(); - $('#title_int_plana').html('' + ' (' + tableCompIntPlana.rows().count() + ')'); - $('#insertarPlanaBtn').removeClass('d-none') - } - else{ - $('#title_int_plana').html(''); - $('#insertarPlanaBtn').addClass('d-none') - $('#total_comp_plana').html('0.00'); - } - yeniden(data.); - return true; - }, - error: function(e){ - return false; - } - }) - return false; - } - - async function getLineasIntRot(is_hq){ - - const dimension = getDimensionLibro(); - - // Rotativa solo negro o color (no hq) - if ( is_hq==false){ - - if(checkInputsForRotativa()){ - - let datos = { - type: 'interior_rot', - paginas: parseInt($('#paginas').val()), - paginas_negro: parseInt($('#compPaginasNegro').val()), - paginas_color: parseInt($('#compPaginasColor').val()), - tirada: parseInt($('#tirada').val()), - merma: parseInt($('#merma').val()), - ancho: dimension.ancho, - alto: dimension.alto, - // el papel y el gramaje se coge del negro (siempre estará) - papel_generico_id: $('#compPapelNegro').select2('data')[0].id, - papel_generico: $('#compPapelNegro').select2('data')[0].text.trim(), - gramaje: $('#compGramajeNegro').select2('data')[0].text.trim() , - : v - }; - - $.ajax({ - type: "POST", - url: "/cosidotapablanda/datatable", - data: datos, - success: function (data) { - - clearIntRot(); - - if(data.lineas.length >0){ - - fillIntRot(data); - selectIntRotLineas(); - $('#title_int_rot').html('' + ' (' + tableCompIntRotativa.rows().count() + ')'); - $('#insertarRotativaBtn').removeClass('d-none') - } - else{ - $('#title_int_rot').html(''); - $('#insertarRotativaBtn').addClass('d-none') - $('#total_comp_rot').html('0.00') - - } - yeniden(data.); - return true; - }, - error: function(e){ - return false; - } - }) - } - } - return false; - } - - - $('.comp_cubierta_items').on('change', function (){ - - if ($('#compCarasCubierta').select2('data').length > 0 && - $('#compPapelCubierta').select2('data').length > 0 && - $('#compGramajeCubierta').select2('data').length > 0 ){ - - const dimension = getDimensionLibro(); - - let datos = { - type: 'cubierta', - paginas: parseInt($('#compCarasCubierta').select2('data')[0].id), - tirada: parseInt($('#tirada').val()), - merma: parseInt($('#mermacubierta').val()), - color: 1, - ancho: dimension.ancho, - alto: dimension.alto, - solapas: $('#solapas').is(':checked')?1:0, - solapas_ancho: parseInt($('#solapas_ancho').val()), - papel_generico_id: $('#compPapelCubierta').select2('data')[0].id, - papel_generico: $('#compPapelCubierta').select2('data')[0].text.trim(), - gramaje: $('#compGramajeCubierta').select2('data')[0].text.trim() , - : v - }; - - $.ajax({ - type: "POST", - url: "/cosidotapablanda/datatable", - data: datos, - success: function (data) { - - clearCubierta(); - - if(data.lineas.length >0){ - - fillCubierta(data); - selectCubiertaLineas(); - $('#title_cubierta').html('' + ' (' + tableCompCubierta.rows().count() + ')'); - $('#insertarCubiertaBtn').removeClass('d-none') - - } - else{ - $('#title_cubierta').html(''); - $('#insertarCubiertaBtn').addClass('d-none') - $('#total_comp_cubierta').html('0.00') - - } - yeniden(data.); - return true; - }, - error: function(e){ - return false; - } - }) - } - - else{ - clearCubierta(); - } - }); - - - $('#tipoImpresion').on("change", function () { - updatePapelesComparador(); - $('#title_int_rot').html(''); - $('#title_int_plana').html(''); - $('#paginas').change(); - - - if (($('#tipoImpresion').select2('data')[0].id == 'negro' || - $('#tipoImpresion').select2('data')[0].id == 'color')){ - - $('#tableCompIntRotativa').DataTable().clear().draw(); - $('#total_comp_rot').html("0.00"); - - if( $('#tableCompIntPlana').DataTable().rows().count() > 0 && - $('#tableCompIntPlana').DataTable().cell(0, 0).data().includes('hq')) { - - $('#tableCompIntPlana').DataTable().clear().draw(); - $('#total_comp_plana').html("0.00"); - } - - } - else if (($('#tipoImpresion').select2('data')[0].id == 'negrohq' || - $('#tipoImpresion').select2('data')[0].id == 'colorhq')){ - - $('#tableCompIntRotativa').DataTable().clear().draw(); - $('#total_comp_rot').html("0.00"); - - if($('#tableCompIntPlana').DataTable().rows().count() > 0 && - !$('#tableCompIntPlana').DataTable().cell(0, 0).data().includes('hq')) { - - $('#tableCompIntPlana').DataTable().clear().draw(); - $('#total_comp_plana').html("0.00"); - } - } - }); - - - function checkComparadorInt(is_color, is_hq) { - - clearIntLineas(is_color); - clearIntRot(); - $('#title_int_rot').html(''); - $('#title_int_plana').html(''); - - elementos = getIDsComparador(is_color, is_hq) - - if ($(''+ elementos.papel).select2('data').length > 0 && - $(''+ elementos.gramaje).select2('data').length > 0 && - parseInt($(''+ elementos.paginas).val()) > 0 && - checkDatosPedidoForComp()) { - - getLineasIntPlana(is_color, is_hq).then((result) =>{ - // Para rotativa, si es color el papel y el gramaje tiene que ser igual - if(!is_color) - { - getLineasIntRot(is_hq); - } - else - { - if(($('#compPapelNegro').select2('data')[0].id == $('#compPapelColor').select2('data')[0].id && - $('#compGramajeNegro').select2('data')[0].text.trim() == $('#compGramajeColor').select2('data')[0].text.trim())) - { - getLineasIntRot(is_hq); - } - else - { - $('#errorComRot').html(''); - } - } - }); - } - } - - - $('#compPapelNegro').on('select2:select', function (e){ - - if($('#compPapelNegro').select2('data')[0].id=='0'){ - $('#compGramajeNegro').val('').change(); - $('#compGramajeNegro').prop('disabled', true); - } - - else{ - $('#insertarPlanaBtn').addClass('d-none') - $('#insertarRotativaBtn').addClass('d-none') - $('#total_comp_plana').html('0.00') - $('#total_comp_rot').html('0.00') - $('#compGramajeNegro').val('').change(); - $('#compGramajeNegro').empty().trigger("change"); - $('#compGramajeNegro').prop('disabled', false); - $('#compGramajeNegro').select2({ - allowClear: false, - minimumResultsForSearch: Infinity, - ajax: { - url: '', - type: 'post', - dataType: 'json', - - data: function (params) { - return { - tipo: 'gramaje', - uso: 'bn', - datos: $('#compPapelNegro').select2('data')[0].text.trim() , - : v - }; - }, - delay: 60, - processResults: function (response) { - yeniden(response.); - return { - results: response.menu - }; - }, - cache: true - } - }); - } - }); - - $('#compPapelNegrohq').on('select2:select', function (e){ - - if($('#compPapelNegrohq').select2('data')[0].id=='0'){ - $('#compGramajeNegrohq').val('').change(); - $('#compGramajeNegrohq').prop('disabled', true); - } - else{ - $('#insertarPlanaBtn').addClass('d-none') - $('#insertarRotativaBtn').addClass('d-none') - $('#total_comp_plana').html('0.00') - $('#total_comp_rot').html('0.00') - $('#compGramajeNegrohq').empty().trigger("change"); - $('#compGramajeNegrohq').prop('disabled', false); - $('#compGramajeNegrohq').select2({ - allowClear: false, - minimumResultsForSearch: Infinity, - ajax: { - url: '', - type: 'post', - dataType: 'json', - - data: function (params) { - return { - tipo: 'gramaje', - uso: 'bnhq', - datos: $('#compPapelNegrohq').select2('data')[0].text.trim() , - : v - }; - }, - delay: 60, - processResults: function (response) { - yeniden(response.); - return { - results: response.menu - }; - }, - cache: true - } - }); - } - }); - - - $('#compPapelColor').on('select2:select', function (e){ - - if($('#compPapelColor').select2('data')[0].id=='0'){ - $('#compGramajeColor').val('').change(); - $('#compGramajeColor').prop('disabled', true); - } - else{ - $('#insertarPlanaBtn').addClass('d-none') - $('#insertarRotativaBtn').addClass('d-none') - $('#total_comp_plana').html('0.00') - $('#total_comp_rot').html('0.00') - $('#compGramajeColor').empty().trigger("change"); - $('#compGramajeColor').prop('disabled', false); - $('#compPapelColor').find('option[value="0"]').remove(); - $('#compGramajeColor').select2({ - allowClear: false, - minimumResultsForSearch: Infinity, - ajax: { - url: '', - type: 'post', - dataType: 'json', - - data: function (params) { - return { - tipo: 'gramaje', - uso: 'color', - datos: $('#compPapelColor').select2('data')[0].text.trim() , - : v - }; - }, - delay: 60, - processResults: function (response) { - yeniden(response.); - return { - results: response.menu - }; - }, - cache: true - } - }); - } - }); - - - $('#compPapelColorhq').on('select2:select', function (e){ - - if($('#compPapelColorhq').select2('data')[0].id=='0'){ - $('#compGramajeColorhq').val('').change(); - $('#compGramajeColorhq').prop('disabled', true); - } - else{ - $('#insertarPlanaBtn').addClass('d-none') - $('#insertarRotativaBtn').addClass('d-none') - $('#total_comp_plana').html('0.00') - $('#total_comp_rot').html('0.00') - $('#compGramajeColorhq').empty().trigger("change"); - $('#compGramajeColorhq').prop('disabled', false); - $('#compPapelColorhq').find('option[value="0"]').remove(); - $('#compGramajeColorhq').select2({ - allowClear: false, - minimumResultsForSearch: Infinity, - ajax: { - url: '', - type: 'post', - dataType: 'json', - - data: function (params) { - return { - tipo: 'gramaje', - uso: 'colorhq', - datos: $('#compPapelColorhq').select2('data')[0].text.trim() , - : v - }; - }, - delay: 60, - processResults: function (response) { - yeniden(response.); - return { - results: response.menu - }; - }, - cache: true - } - }); - } - }); - - $('#compPapelCubierta').on('select2:select', function (e){ - if($('#compPapelCubierta').select2('data')[0].id=='0'){ - $('#compGramajeCubierta').val('').change(); - $('#compGramajeCubierta').prop('disabled', true); - } - else{ - $('#insertarCubiertaBtn').addClass('d-none') - $('#total_comp_cubierta').html('0.00') - $('#compGramajeCubierta').val('').trigger('change'); - $('#compGramajeCubierta').prop('disabled', false); - $('#compPapelCubierta').find('option[value="0"]').remove(); - $('#compGramajeCubierta').select2({ - allowClear: false, - minimumResultsForSearch: Infinity, - ajax: { - url: '', - type: 'post', - dataType: 'json', - - data: function (params) { - return { - tipo: 'gramaje', - uso: 'cubierta', - datos: $('#compPapelCubierta').select2('data')[0].text.trim() , - : v - }; - }, - delay: 60, - processResults: function (response) { - yeniden(response.); - return { - results: response.menu - }; - }, - cache: true - } - }); - } - }); - - - function checkDatosPedidoForComp() { - - const dimension = getDimensionLibro(); - - if (parseInt($('#paginas').val()) <= 0){ - popErrorAlert('', 'divAlarmasComparador'); - return false; - } - if (parseInt($('#tirada').val()) <= 0){ - popErrorAlert('', 'divAlarmasComparador'); - return false; - } - if('ancho' in dimension && 'alto' in dimension){ - - if(dimension.alto < 60 || dimension.ancho < 60 || isNaN(dimension.alto) || isNaN(dimension.ancho) ){ - popErrorAlert('', 'divAlarmasComparador'); - return false; - } - } - else{ - popErrorAlert('', 'divAlarmasComparador'); - return false; - } - return true; - } + return false; //stop the actual form post !important! +}); endSection() ?> + @@ -1087,5 +153,7 @@ - + + + endSection() ?> diff --git a/ci4/app/Views/themes/backend/vuexy/form/presupuestos/cosidotapablanda/viewCosidotapablandaList.php b/ci4/app/Views/themes/backend/vuexy/form/presupuestos/cosidotapablanda/viewCosidotapablandaList.php index 0deb4f39..ea91cb8f 100644 --- a/ci4/app/Views/themes/backend/vuexy/form/presupuestos/cosidotapablanda/viewCosidotapablandaList.php +++ b/ci4/app/Views/themes/backend/vuexy/form/presupuestos/cosidotapablanda/viewCosidotapablandaList.php @@ -27,7 +27,7 @@ - + @@ -104,8 +104,15 @@ { 'data': 'inc_rei' }, { 'data': 'paginas' }, { 'data': 'tirada' }, - { 'data': 'total_pedido' }, - { 'data': 'estado' }, + { 'data': 'total_presupuesto' }, + { 'data': 'estado' , + 'render': function ( data, type, row, meta ) { + if(data=='borrador') + return ''; + else if(data=='aceptado') + return ''; + } + }, { 'data': actionBtns } ] });