diff --git a/ci4/.gitignore b/ci4/.gitignore index 11abea69..04d2d70d 100755 --- a/ci4/.gitignore +++ b/ci4/.gitignore @@ -41,7 +41,7 @@ $RECYCLE.BIN/ #------------------------- # These should never be under version control, # as it poses a security risk. -.env +.env* .vagrant Vagrantfile @@ -125,3 +125,5 @@ nb-configuration.xml /phpunit*.xml /.phpunit.*.cache + +xdebug.log \ No newline at end of file diff --git a/ci4/app/Config/Routes.php b/ci4/app/Config/Routes.php index 0fb09796..09900984 100755 --- a/ci4/app/Config/Routes.php +++ b/ci4/app/Config/Routes.php @@ -104,6 +104,20 @@ $routes->group('tarifapreimpresion', ['namespace' => 'App\Controllers\Tarifas'], }); +$routes->group('tarifaextra', ['namespace' => 'App\Controllers\Tarifas'], function ($routes) { + $routes->get('', 'Tarifaextra::index', ['as' => 'tarifaextraList']); + $routes->get('index', 'Tarifaextra::index', ['as' => 'tarifaextraIndex']); + $routes->get('list', 'Tarifaextra::index', ['as' => 'tarifaextraList2']); + $routes->get('add', 'Tarifaextra::add', ['as' => 'newTarifaextra']); + $routes->post('add', 'Tarifaextra::add', ['as' => 'createTarifaextra']); + $routes->get('edit/(:num)', 'Tarifaextra::edit/$1', ['as' => 'editTarifaextra']); + $routes->post('edit/(:num)', 'Tarifaextra::edit/$1', ['as' => 'updateTarifaextra']); + $routes->get('delete/(:num)', 'Tarifaextra::delete/$1', ['as' => 'deleteTarifaextra']); + $routes->post('allmenuitems', 'Tarifaextra::allItemsSelect', ['as' => 'select2ItemsOfTarifasextra']); + $routes->post('menuitems', 'Tarifaextra::menuItems', ['as' => 'menuItemsOfTarifasextra']); +}); + + $routes->group('tarifasmanipulado', ['namespace' => 'App\Controllers\Tarifas'], function ($routes) { $routes->get('', 'Tarifasmanipulado::index', ['as' => 'tarifaManipuladoList']); $routes->get('add', 'Tarifasmanipulado::add', ['as' => 'newTarifaManipulado']); @@ -550,6 +564,11 @@ $routes->group('serviciospreimpresiones', ['namespace' => 'App\Controllers\Presu $routes->post('edit/(:num)', 'Presupuestopreimpresiones::edit/$1', ['as' => 'updatePresupuestopreimpresiones']); }); +$routes->group('serviciosextra', ['namespace' => 'App\Controllers\Presupuestos'], function ($routes) { + $routes->post('datatable', 'Presupuestoserviciosextra::datatable', ['as' => 'dataTableOfPresupuestoServiciosExtra']); + $routes->post('edit/(:num)', 'Presupuestoserviciosextra::edit/$1', ['as' => 'updatePresupuestoServiciosExtra']); +}); + $routes->group('presupuestodirecciones', ['namespace' => 'App\Controllers\Presupuestos'], function ($routes) { $routes->post('datatable', 'Presupuestodirecciones::datatable', ['as' => 'dataTableOfPresupuestoDirecciones']); $routes->post('datatable_2', 'Presupuestodirecciones::datatable_2', ['as' => 'processDataDirecciones']); diff --git a/ci4/app/Controllers/Presupuestos/Cosidotapablanda.php b/ci4/app/Controllers/Presupuestos/Cosidotapablanda.php index cfb50c23..6bdfefa3 100755 --- a/ci4/app/Controllers/Presupuestos/Cosidotapablanda.php +++ b/ci4/app/Controllers/Presupuestos/Cosidotapablanda.php @@ -17,6 +17,7 @@ use App\Models\Presupuestos\PresupuestoEncuadernacionesModel; use App\Models\Presupuestos\PresupuestoAcabadosModel; use App\Models\Presupuestos\PresupuestoManipuladosModel; use App\Models\Presupuestos\PresupuestoPreimpresionesModel; +use App\Models\Presupuestos\PresupuestoServiciosExtraModel; use App\Services\PresupuestoService; use App\Models\Configuracion\PapelImpresionModel; @@ -356,10 +357,10 @@ class Cosidotapablanda extends \App\Controllers\GoBaseResourceController // Servicios $this->viewData['serviciosPreimpresion'] = $this->getServiciosPreimpresion(); - $this->viewData['serviciosPreimpresion'] = $this->getServiciosPreimpresion(); $this->viewData['serviciosEncuadernacion'] = $this->getServiciosEncuadernacion(); $this->viewData['serviciosManipulado'] = $this->getServiciosManipulado(); $this->viewData['serviciosAcabado'] = $this->getServiciosAcabado(); + $this->viewData['serviciosExtra'] = $this->getServiciosExtra(); [$cambios_en_servicios, $servicios] = $this->getLineasServicios($presupuestoEntity); $this->viewData['presupuestoEntity']->cambios_servicios=$cambios_en_servicios; @@ -368,6 +369,7 @@ class Cosidotapablanda extends \App\Controllers\GoBaseResourceController $this->viewData['serviciosAcabadosList'] = $servicios->serviciosAcabado; $this->viewData['serviciosManipuladoList'] = $servicios->serviciosManipulado; $this->viewData['serviciosPreimpresionList'] = $servicios->serviciosPreimpresion; + $this->viewData['serviciosExtraList'] = $servicios->serviciosExtra; // Direciones presupuesto [$cambios_en_direcciones, $this->viewData['direccionesList']] = $this->getLineasDirecciones($presupuestoEntity); @@ -459,6 +461,10 @@ class Cosidotapablanda extends \App\Controllers\GoBaseResourceController $model = new PresupuestoManipuladosModel(); $model->where("presupuesto_id", $id)->delete(); + // Se borran los servicios extra + $model = new PresupuestoServiciosExtraModel(); + $model->where("presupuesto_id", $id)->delete(); + // $message = lang('Basic.global.deleteSuccess', [$objName]); IMN commented $message = lang('Basic.global.deleteSuccess', [lang('Basic.global.record')]); $response = $this->respondDeleted(['id' => $id, 'msg' => $message]); @@ -889,6 +895,12 @@ class Cosidotapablanda extends \App\Controllers\GoBaseResourceController $preimpresion->presupuesto_id = $new_id; $presupuestoPreimpresionesModel->insert($preimpresion); } + + $presupuestoServiciosExtraModel = model('App\Models\Presupuestos\PresupuestoServiciosExtraModel'); + foreach ($presupuestoServiciosExtraModel->where('presupuesto_id', $presupuesto->id)->findAll() as $servicioExtra) { + $servicioExtra->presupuesto_id = $new_id; + $presupuestoServiciosExtraModel->insert($preimpresion); + } $presupuestoDireccionesModel = model('App\Models\Presupuestos\PresupuestoDireccionesModel'); foreach ($presupuestoDireccionesModel->where('presupuesto_id', $presupuesto->id)->findAll() as $direccion) { @@ -1189,6 +1201,17 @@ class Cosidotapablanda extends \App\Controllers\GoBaseResourceController return $data; } + protected function getServiciosExtra() + { + $model = model('App\Models\Tarifas\TarifaextraModel'); + $data = $model->getServiciosExtraSelector(); + array_unshift($data, (object)array( + "value" => 0, + "label" => lang('Basic.global.pleaseSelectA', [mb_strtolower(lang('Presupuestos.servicioExtra'))]) + )); + return $data; + } + protected function getServiciosEncuadernacion() { $model = model('App\Models\Tarifas\TarifaEncuadernacionModel'); @@ -1246,6 +1269,7 @@ class Cosidotapablanda extends \App\Controllers\GoBaseResourceController $serviciosPresupuesto->serviciosPreimpresion = (new PresupuestoPreimpresionesModel())->getResource($presupuestoEntity->id)->get()->getResultObject(); $serviciosPresupuesto->serviciosEncuadernacion = (new PresupuestoEncuadernacionesModel())->getResource($presupuestoEntity->id)->get()->getResultObject(); $serviciosPresupuesto->serviciosManipulado = (new PresupuestoManipuladosModel())->getResource($presupuestoEntity->id)->get()->getResultObject(); + $serviciosPresupuesto->serviciosExtra = (new PresupuestoServiciosExtraModel())->getResource($presupuestoEntity->id)->get()->getResultObject(); $input_data = []; $input_data['presupuesto_id'] = $presupuestoEntity->id; diff --git a/ci4/app/Controllers/Presupuestos/Presupuestoserviciosextra.php b/ci4/app/Controllers/Presupuestos/Presupuestoserviciosextra.php new file mode 100755 index 00000000..d365f278 --- /dev/null +++ b/ci4/app/Controllers/Presupuestos/Presupuestoserviciosextra.php @@ -0,0 +1,113 @@ +request->getJSON(); + $tarifas = array_column($postData->datos, 'tarifa_id'); + if(count($tarifas)>0){ + $this->model->deleteServiciosNotInArray($requestedId, $tarifas); + } + else{ + $this->model->deleteAllServicios($requestedId); + } + + if(count($tarifas)>0){ + $this->model->updateTarifas($requestedId, $postData->datos); + } + + $newTokenHash = csrf_hash(); + $csrfTokenName = csrf_token(); + $data = [ + $csrfTokenName => $newTokenHash + ]; + + return $this->respond($data); + } + + public function update($requestedId = null) + { + + if ($requestedId == null) : + return; + endif; + + $postData = $this->request->getJSON(); + $tarifas = array_column($postData->datos, 'tarifa_id'); + $result = []; + + if(count($tarifas)>0){ + foreach ($tarifas as $tarifa){ + $values = $this->model->getPrecioTarifa($tarifa); + array_push($result, $values); + } + } + + $newTokenHash = csrf_hash(); + $csrfTokenName = csrf_token(); + $data = [ + 'lines' => $result, + $csrfTokenName => $newTokenHash + ]; + + return $this->respond($data); + } + + public function datatable() + { + if ($this->request->isAJAX()) { + $reqData = $this->request->getPost(); + + $tarifa_extra_id = $reqData['tarifa_extra_id'] ?? 0; + + $newTokenHash = csrf_hash(); + $csrfTokenName = csrf_token(); + + $values = $this->model->getPrecioTarifa($tarifa_extra_id); + + $data = [ + 'values' => $values, + $csrfTokenName => $newTokenHash + ]; + + return $this->respond($data); + + } else { + return $this->failUnauthorized('Invalid request', 403); + } + } + +} diff --git a/ci4/app/Controllers/Tarifas/Tarifaextra.php b/ci4/app/Controllers/Tarifas/Tarifaextra.php new file mode 100755 index 00000000..c7379197 --- /dev/null +++ b/ci4/app/Controllers/Tarifas/Tarifaextra.php @@ -0,0 +1,248 @@ +viewData['pageTitle'] = lang('Tarifaextra.moduleTitle'); + // Se indica que este controlador trabaja con soft_delete + $this->soft_delete = true; + // Se indica el flag para los ficheros borrados + $this->delete_flag = 1; + + // Breadcrumbs + $this->viewData['breadcrumb'] = [ + ['title' => lang("App.menu_tarifas"), 'route' => "javascript:void(0);", 'active' => false], + ['title' => lang("App.menu_tarifaextra"), 'route' => site_url('tarifas/tarifaextra'), 'active' => true] + ]; + + parent::initController($request, $response, $logger); + + } + + public function index() + { + + $this->viewData['usingClientSideDataTable'] = true; + + $this->viewData['pageSubTitle'] = lang('Basic.global.ManageAllRecords', [lang('Tarifaextra.tarifaextra')]); + parent::index(); + + } + + public function add() + { + + + $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('mostrar_en_presupuesto') == null) { + $sanitizedData['mostrar_en_presupuesto'] = false; + } + + $noException = true; + if ($successfulResult = $this->canValidate()) : // if ($successfulResult = $this->validate($this->formValidationRules) ) : + + + if ($this->canValidate()) : + try { + $successfulResult = $this->model->skipValidation(true)->save($sanitizedData); + } catch (\Exception $e) { + $noException = false; + $this->dealWithException($e); + } + else: + $this->viewData['errorMessage'] = lang('Basic.global.formErr1', [lang('Basic.global.record')]); + $this->session->setFlashdata('formErrors', $this->model->errors()); + endif; + + $thenRedirect = true; // Change this to false if you want your user to stay on the form after submission + endif; + if ($noException && $successfulResult) : + + $id = $this->model->db->insertID(); + + $message = lang('Basic.global.saveSuccess', [lang('Basic.global.record')]) . '.'; + + if ($thenRedirect) : + if (!empty($this->indexRoute)) : + return redirect()->to(route_to($this->indexRoute))->with('successMessage', $message); + else: + return $this->redirect2listView('successMessage', $message); + endif; + else: + $this->session->setFlashData('sweet-success', $message); + endif; + + endif; // $noException && $successfulResult + + endif; // ($requestMethod === 'post') + + $this->viewData['tarifaextraEntity'] = isset($sanitizedData) ? new TarifaextraEntity($sanitizedData) : new TarifaextraEntity(); + + $this->viewData['formAction'] = route_to('createTarifaextra'); + + $this->viewData['boxTitle'] = lang('Basic.global.addNew') . ' ' . lang('Tarifaextra.tarifaextra') . ' ' . 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); + $tarifaextraEntity = $this->model->find($id); + + if ($tarifaextraEntity == false) : + $message = lang('Basic.global.notFoundWithIdErr', [mb_strtolower(lang('Tarifaextra.tarifaextra')), $id]); + return $this->redirect2listView('errorMessage', $message); + endif; + + $requestMethod = $this->request->getMethod(); + + if ($requestMethod === 'post') : + + $nullIfEmpty = true; // !(phpversion() >= '8.1'); + + $postData = $this->request->getPost(); + $sanitizedData = $this->sanitized($postData, $nullIfEmpty); + + // JJO + if (isset($this->model->user_updated_id)) { + $sanitizedData['user_updated_id'] = $session->id_user; + } + if ($this->request->getPost('mostrar_en_presupuesto') == null) { + $sanitizedData['mostrar_en_presupuesto'] = false; + } + + $noException = true; + if ($successfulResult = $this->canValidate()) : // if ($successfulResult = $this->validate($this->formValidationRules) ) : + if ($this->canValidate()) : + try { + $successfulResult = $this->model->skipValidation(true)->update($id, $sanitizedData); + } catch (\Exception $e) { + $noException = false; + $this->dealWithException($e); + } + else: + $this->viewData['warningMessage'] = lang('Basic.global.formErr1', [mb_strtolower(lang('Tarifaextra.tarifaextra'))]); + $this->session->setFlashdata('formErrors', $this->model->errors()); + + endif; + + $tarifaextraEntity->fill($sanitizedData); + + $thenRedirect = false; + endif; + if ($noException && $successfulResult) : + $id = $tarifaextraEntity->id ?? $id; + $message = lang('Basic.global.updateSuccess', [lang('Basic.global.record')]) . '.'; + + if ($thenRedirect) : + if (!empty($this->indexRoute)) : + return redirect()->to(route_to($this->indexRoute))->with('successMessage', $message); + else: + return $this->redirect2listView('successMessage', $message); + endif; + else: + $this->session->setFlashData('sweet-success', $message); + endif; + + endif; // $noException && $successfulResult + endif; // ($requestMethod === 'post') + + $this->viewData['tarifaextraEntity'] = $tarifaextraEntity; + + $this->viewData['formAction'] = route_to('updateTarifaextra', $id); + + $this->viewData['boxTitle'] = lang('Basic.global.edit2') . ' ' . lang('Tarifaextra.tarifaextra') . ' ' . lang('Basic.global.edit3'); + + + return $this->displayForm(__METHOD__, $id); + } // end function edit(...) + + + public function allItemsSelect() + { + if ($this->request->isAJAX()) { + $onlyActiveOnes = true; + $reqVal = $this->request->getPost('val') ?? 'id'; + $menu = $this->model->getAllForMenu($reqVal . ', nombre', 'nombre', $onlyActiveOnes, false); + $nonItem = new \stdClass; + $nonItem->id = ''; + $nonItem->nombre = '- ' . lang('Basic.global.None') . ' -'; + array_unshift($menu, $nonItem); + + $newTokenHash = csrf_hash(); + $csrfTokenName = csrf_token(); + $data = [ + 'menu' => $menu, + $csrfTokenName => $newTokenHash + ]; + return $this->respond($data); + } else { + return $this->failUnauthorized('Invalid request', 403); + } + } + + public function menuItems() + { + if ($this->request->isAJAX()) { + $searchStr = goSanitize($this->request->getPost('searchTerm'))[0]; + $reqId = goSanitize($this->request->getPost('id'))[0]; + $reqText = goSanitize($this->request->getPost('text'))[0]; + $onlyActiveOnes = false; + $columns2select = [$reqId ?? 'id', $reqText ?? 'nombre']; + $onlyActiveOnes = false; + $menu = $this->model->getSelect2MenuItems($columns2select, $columns2select[1], $onlyActiveOnes, $searchStr); + $nonItem = new \stdClass; + $nonItem->id = ''; + $nonItem->text = '- ' . lang('Basic.global.None') . ' -'; + array_unshift($menu, $nonItem); + + $newTokenHash = csrf_hash(); + $csrfTokenName = csrf_token(); + $data = [ + 'menu' => $menu, + $csrfTokenName => $newTokenHash + ]; + return $this->respond($data); + } else { + return $this->failUnauthorized('Invalid request', 403); + } + } + +} diff --git a/ci4/app/Entities/Presupuestos/PresupuestoServiciosExtraEntity.php b/ci4/app/Entities/Presupuestos/PresupuestoServiciosExtraEntity.php new file mode 100755 index 00000000..68b12931 --- /dev/null +++ b/ci4/app/Entities/Presupuestos/PresupuestoServiciosExtraEntity.php @@ -0,0 +1,23 @@ + null, + "presupuesto_id" => null, + "tarifa_extra_id" => null, + "precio_total" => null, + "margen" => null, + "created_at" => null, + "updated_at" => null, + ]; + protected $casts = [ + "presupuesto_id" => "int", + "tarifa_extra_id" => "int", + "precio_total" => "float", + "margen" => "float", + ]; +} diff --git a/ci4/app/Entities/Tarifas/TarifaextraEntity.php b/ci4/app/Entities/Tarifas/TarifaextraEntity.php new file mode 100755 index 00000000..2ff79cd9 --- /dev/null +++ b/ci4/app/Entities/Tarifas/TarifaextraEntity.php @@ -0,0 +1,33 @@ + null, + "nombre" => null, + "precio" => null, + "precio_min" => 0, + "importe_fijo" => 0, + "margen" => 0, + "mostrar_en_presupuesto" => 1, + "user_created_id" => 1, + "user_update_id" => 1, + "is_deleted" => 0, + "deleted_at" => null, + "created_at" => null, + "updated_at" => null, + ]; + protected $casts = [ + "precio" => "float", + "precio_min" => "float", + "importe_fijo" => "float", + "margen" => "float", + "mostrar_en_presupuesto" => "int", + "user_created_id" => "int", + "user_update_id" => "int", + "is_deleted" => "int", + ]; +} diff --git a/ci4/app/Language/es/App.php b/ci4/app/Language/es/App.php index 2cd814c2..ed5cb4c1 100755 --- a/ci4/app/Language/es/App.php +++ b/ci4/app/Language/es/App.php @@ -781,6 +781,7 @@ return [ "menu_tarifas" => "Tarifas", "menu_tarifapreimpresion" => "Preimpresión", + "menu_tarifaextra" => "Serv. Extra", "menu_tarifamanipulado" => "Manipulado", "menu_tarifaencuadernacion" => "Encuadernación", "menu_tarifapapelcompra" => "Papel compra", diff --git a/ci4/app/Language/es/Presupuestos.php b/ci4/app/Language/es/Presupuestos.php index 92130f08..740f6724 100755 --- a/ci4/app/Language/es/Presupuestos.php +++ b/ci4/app/Language/es/Presupuestos.php @@ -182,11 +182,13 @@ return [ 'servicioAcabado' => 'Servicio de acabado', 'servicioPreimpresion' => 'Servicio de preimpresión', + 'servicioExtra' => 'Servicio extra', 'servicioEncuadernado' => 'Servicio de encuadernación', 'servicioEncuadernadoList' => 'Servicios de encuadernación', 'servicioAcabadoList' => 'Servicios de acabado', 'servicioManipuladoList' => 'Servicios de manipulado', 'servicioPreimpresionList' => 'Servicios de preimpresion', + 'servicioExtraList' => 'Servicios extra', 'servicioManipulado' => 'Servicio de manipulado', 'comentarios' => 'Comentarios', diff --git a/ci4/app/Language/es/Tarifaextra.php b/ci4/app/Language/es/Tarifaextra.php new file mode 100755 index 00000000..67fd257d --- /dev/null +++ b/ci4/app/Language/es/Tarifaextra.php @@ -0,0 +1,50 @@ + 'Creado en', + 'deletedAt' => 'Borrado en', + 'id' => 'ID', + 'moduleTitle' => 'Tarifas Servicios Extra', + 'nombre' => 'Nombre', + 'precio' => 'Precio', + 'precioMin' => 'Precio Mínimo', + 'importeFijo' => 'Importe Fijo', + 'mostrar_en_presupuesto' => 'Mostrar en presupuesto', + 'margen' => 'Margen', + 'tarifaextra' => 'Tarifa Servicios Extra', + 'tarifaextraList' => 'Lista Tarifas Servicios Extra', + 'tarifasextra' => 'Tarifas Servicios Extra', + 'updatedAt' => 'Actualizado en', + 'userCreatedId' => 'ID Usuario \"Creado en\"', + 'userUpdateId' => 'ID Usuario \"Actualizado en\"', + 'validation' => [ + 'nombre' => [ + 'max_length' => 'El campo {field} no puede exceder {param} caracteres en longitud.', + 'required' => 'El campo {field} es obligatorio.', + + ], + + 'precio' => [ + 'decimal' => 'El campo {field} debe contener un número decimal.', + 'required' => 'El campo {field} es obligatorio.', + + ], + + 'user_created_id' => [ + 'integer' => 'El campo {field} debe contener un número entero.', + 'required' => 'El campo {field} es obligatorio.', + + ], + + 'user_update_id' => [ + 'integer' => 'El campo {field} debe contener un número entero.', + 'required' => 'El campo {field} es obligatorio.', + + ], + + + ], + + +]; \ No newline at end of file diff --git a/ci4/app/Models/Presupuestos/PresupuestoEncuadernacionesModel.php b/ci4/app/Models/Presupuestos/PresupuestoEncuadernacionesModel.php index 57ab549d..dc64be41 100755 --- a/ci4/app/Models/Presupuestos/PresupuestoEncuadernacionesModel.php +++ b/ci4/app/Models/Presupuestos/PresupuestoEncuadernacionesModel.php @@ -353,7 +353,7 @@ class PresupuestoEncuadernacionesModel extends \App\Models\GoBaseModel ->table($this->table . " t1") ->where('presupuesto_id', $presupuesto_id) ->where('tarifa_encuadernado_id', $tarifa->tarifa_id) - ->set('proveedor_id', $proveedor, false) + ->set('proveedor_id', $proveedor) ->set('precio_unidad', $tarifa->precio_unidad) ->set('precio_total', $tarifa->precio_total) ->set('margen', $tarifa->margen) diff --git a/ci4/app/Models/Presupuestos/PresupuestoServiciosExtraModel.php b/ci4/app/Models/Presupuestos/PresupuestoServiciosExtraModel.php new file mode 100755 index 00000000..76916a8e --- /dev/null +++ b/ci4/app/Models/Presupuestos/PresupuestoServiciosExtraModel.php @@ -0,0 +1,158 @@ + "t2.nombre", + 1 => "t1.precio_unidad", + 2 => "t1.precio_total" + ]; + + protected $allowedFields = ["presupuesto_id", "tarifa_extra_id", "nombre", "precio_total", "precio_unidad", "margen"]; + protected $returnType = "App\Entities\Presupuestos\PresupuestoServiciosExtraEntity"; + + protected $useTimestamps = true; + protected $useSoftDeletes = false; + + protected $createdField = "created_at"; + protected $updatedField = "updated_at"; + + public static $labelField = "nombre"; + + protected $validationRules = [ + "precio_total" => [ + "label" => "Presupuestos.precioTotal", + "rules" => "decimal|required", + ], + ]; + + protected $validationMessages = [ + "precio_total" => [ + "decimal" => "Presupuestos.validation.decimal", + "requerido" => "Presupuestos.validation.decimal", + ], + ]; + + + public function getPrecioTarifa($tarifa_extra_id){ + + $modelTarifa = model('App\Models\Tarifas\TarifaextraModel'); + $tarifa_value = $modelTarifa->getTarifaPresupuestoExtra($tarifa_extra_id); + if (count($tarifa_value)>0) { + + $result_data = $this->calcularTarifa($tarifa_value[0]); + $ret_array[] = (object)[ + 'tarifa_id'=> $tarifa_value[0]->tarifa_extra_id, + 'tarifa_nombre'=> $tarifa_value[0]->tarifa_extra_nombre, + 'precio'=> $result_data[0], + 'margen'=> $result_data[1], + ]; + return $ret_array; + } + else{ + $ret_array[] = (object)[ + 'tarifa_id'=> $tarifa_extra_id, + 'tarifa_nombre'=> $modelTarifa->getNombreTarifaPreimpresion($tarifa_extra_id)[0]->nombre, + 'precio' => 0, + 'margen' => 0, + ]; + return $ret_array; + } + return []; + } + + private function calcularTarifa($tarifa){ + + $precio = floatval($tarifa->precio); + $precio = $precio * (1+ floatval($tarifa->margen)/100.0); + $margen = $tarifa->margen; + + return [$precio, $margen]; + } + + public function deleteAllServicios($presupuesto_id){ + + $this->db + ->table($this->table . " t1") + ->where('presupuesto_id', $presupuesto_id) + ->delete(); + } + + public function deleteServiciosNotInArray($presupuesto_id, $tarifas_id){ + + $builder = $this->db + ->table($this->table . " t1"); + $builder->where('presupuesto_id', $presupuesto_id); + foreach($tarifas_id as $id){ + $builder->where('tarifa_extra_id !=', $id); + } + $builder->delete(); + } + + public function updateTarifas($presupuesto_id, $tarifas){ + + foreach($tarifas as $tarifa){ + + $builder = $this->db + ->table($this->table . " t1"); + $builder->select("id"); + $builder->where('presupuesto_id', $presupuesto_id); + $builder->where('tarifa_extra_id', $tarifa->tarifa_id); + $result = $builder->get()->getResultObject(); + if(count($result)>0){ + + $this->db + ->table($this->table . " t1") + ->where('presupuesto_id', $presupuesto_id) + ->where('tarifa_extra_id', $tarifa->tarifa_id) + ->set('precio', $tarifa->precio) + ->set('margen', $tarifa->margen) + ->update(); + + + } + else{ + $this->db + ->table($this->table . " t1") + ->set('presupuesto_id', $presupuesto_id) + ->set('tarifa_extra_id', $tarifa->tarifa_id) + ->set('precio', $tarifa->precio) + ->set('margen', $tarifa->margen) + ->insert(); + } + } + } + + + /** + * Get resource data. + * + * @param string $search + * + * @return \CodeIgniter\Database\BaseBuilder + */ + public function getResource($presupuesto_id = -1) + { + $builder = $this->db + ->table($this->table . " t1") + ->select( + "t1.id AS id, t1.tarifa_extra_id AS tarifa_extra_id, t1.precio AS precio, t1.margen AS margen, t2.nombre AS nombre" + ); + + $builder->where('t1.presupuesto_id', $presupuesto_id); + $builder->join("tarifa_extra t2", "t1.tarifa_extra_id = t2.id", "left"); + + return $builder; + } +} diff --git a/ci4/app/Models/Tarifas/TarifaextraModel.php b/ci4/app/Models/Tarifas/TarifaextraModel.php new file mode 100755 index 00000000..9e122b97 --- /dev/null +++ b/ci4/app/Models/Tarifas/TarifaextraModel.php @@ -0,0 +1,130 @@ + [ + "label" => "Tarifaextra.nombre", + "rules" => "trim|required|max_length[255]", + ], + "precio" => [ + "label" => "Tarifaextra.precio", + "rules" => "required|decimal", + ], + "precio_min" => [ + "label" => "Tarifaextra.precioMin", + "rules" => "required|decimal", + ], + "importe_fijo" => [ + "label" => "Tarifaextra.importeFijo", + "rules" => "required|decimal", + ], + "margen" => [ + "label" => "Tarifaextra.margen", + "rules" => "required|decimal", + ], + ]; + + protected $validationMessages = [ + "nombre" => [ + "max_length" => "Tarifaextra.validation.nombre.max_length", + "required" => "Tarifaextra.validation.nombre.required", + ], + "precio" => [ + "decimal" => "Tarifaextra.validation.precio.decimal", + "required" => "Tarifaextra.validation.precio.required", + ], + "precio_min" => [ + "required" => "Tarifaextra.validation.precio_min.required", + "decimal" => "Tarifaextra.validation.precio_min.decimal", + ], + "importe_fijo" => [ + "required" => "Tarifaextra.validation.importe_fijo.required", + "decimal" => "Tarifaextra.validation.importe_fijo.decimal", + ], + "margen" => [ + "required" => "Tarifaextra.validation.margen.required", + "decimal" => "Tarifaextra.validation.margen.decimal", + ], + ]; + + public function getServiciosExtraSelector() + { + /* + Todos los servicios de extra activas que se pueden usar en presupuestos + */ + $builder = $this->db + ->table($this->table . " t1") + ->select( + "t1.id as value, t1.nombre AS label" + ) + ->where("t1.is_deleted", 0) + ->where("t1.mostrar_en_presupuesto", 1); + + return $builder->orderBy("t1.nombre", "asc")->get()->getResultObject(); + } + + public function getTarifaPresupuestoExtra($tarifa_id){ + + $builder = $this->db + ->table($this->table . " t1") + ->select( + "t1.id AS tarifa_extra_id, t1.nombre AS tarifa_extra_nombre, t1.precio AS precio, t1.margen AS margen" + ) + ->where("t1.is_deleted", 0); + //->where("t1.mostrar_en_presupuesto", 1) + + $builder->where('t1.id =', $tarifa_id); + + return $builder->get()->getResultObject(); + } + + public function getNombreTarifaExtra($id=-1) + { + /* + Todos los servicios de encuadernacion activas que se pueden usar en presupuestos + */ + $builder = $this->db + ->table($this->table . " t1") + ->select( + "t1.nombre AS nombre" + ) + ->where("t1.id", $id) + ->where("t1.is_deleted", 0); + + return $builder->orderBy("t1.nombre", "asc")->get()->getResultObject(); + } + +} diff --git a/ci4/app/Services/PresupuestoService.php b/ci4/app/Services/PresupuestoService.php index 8fca1f9a..c9afc8b1 100755 --- a/ci4/app/Services/PresupuestoService.php +++ b/ci4/app/Services/PresupuestoService.php @@ -1232,6 +1232,8 @@ class PresupuestoService extends BaseService $opciones_papel = PresupuestoService::get_opciones_papel('interior', $isColor); if($linea->tipo == 'lp_guardas'){ + $data['uso'] = 'guardas'; + $tipo = 'colorhq'; $data['datosPedido']->paginas_impresion = $linea->paginas_impresion; // Para el caso de Fresado y Cosido tapa dura, las guardas son un diptico // y hay que imprimirlas como "cosido" (dos hojas pegadas). En el caso de espiral @@ -1335,7 +1337,7 @@ class PresupuestoService extends BaseService $cambio_en_servicios = $cambio_en_servicios? $cambio_en_servicios: $cambio; } - // Los servicios de preimpresion se dejan tal y como esten + // Los servicios de preimpresion y los extra se dejan tal y como esten return [$cambio_en_servicios, $servicios]; } diff --git a/ci4/app/Views/themes/backend/vuexy/form/presupuestos/cosidotapablanda/_datosServiciosItems.js b/ci4/app/Views/themes/backend/vuexy/form/presupuestos/cosidotapablanda/_datosServiciosItems.js index bbfef9bf..e4c137bc 100644 --- a/ci4/app/Views/themes/backend/vuexy/form/presupuestos/cosidotapablanda/_datosServiciosItems.js +++ b/ci4/app/Views/themes/backend/vuexy/form/presupuestos/cosidotapablanda/_datosServiciosItems.js @@ -8,6 +8,7 @@ $('.nav-servicios button').on('shown.bs.tab', function(){ $("#tableOfServiciosPreimpresion").DataTable().columns.adjust(); $("#tableOfServiciosManipulado").DataTable().columns.adjust(); $("#tableOfServiciosAcabado").DataTable().columns.adjust(); + $("#tableOfServiciosExtra").DataTable().columns.adjust(); }) @@ -37,6 +38,9 @@ $(document).on('click', '.btn-delete-serv', function(e) { else if($(this).closest('table').attr('id').includes('tableOfServiciosPreimpresion')){ table = "tableOfServiciosPreimpresion"; } + else if($(this).closest('table').attr('id').includes('tableOfServiciosExtra')){ + table = "tableOfServiciosExtra"; + } else{ table = ""; } @@ -60,6 +64,7 @@ $(document).on('click', '.btn-delete-serv', function(e) { check_serv_acabado_error() check_serv_preimpresion_error() check_serv_manipulado_error() + check_serv_extra_error() updatePresupuesto({ update_lineas: false, update_servicios: false, @@ -77,6 +82,7 @@ function save_servicios(){ var datosEnc = get_datos_encuadernacion() var datosManipulado = get_datos_manipulado() var datosPreimpresion = get_datos_preimpresion() + var datosServiciosExtra = get_datos_serviciosextra() const domain = window.location.origin @@ -135,7 +141,21 @@ function save_servicios(){ .then(response => response.json()) .then(data => { yeniden(data[window.csrf_token]); - }) + }) + ) + + .then( + fetch(domain + "/presupuestos/presupuestoserviciosextra/edit/" + id , { + method: "POST", + body: JSON.stringify(Object.assign({datos: datosServiciosExtra}, window.token_ajax)), + headers: { + "Content-type": "application/json; charset=UTF-8" + } + }) + .then(response => response.json()) + .then(data => { + yeniden(data[window.csrf_token]); + }) ) } @@ -156,6 +176,16 @@ var tableServiciosAcabado = new DataTable('#tableOfServiciosAcabado',{ }, }); +tableServiciosAcabado.on('draw', function(){ + + updatePresupuesto({ + update_lineas: false, + update_servicios: false, + update_envios: false, + update_resumen: true, + update_tiradas_alternativas: true}) +}) + function init_servicio_acabado(){ $('#add_servicio_acabado_list').select2({ @@ -190,15 +220,7 @@ function init_servicio_acabado(){ update_resumen: true, update_tiradas_alternativas: true}) }) - - updatePresupuesto({ - update_lineas: false, - update_servicios: false, - update_envios: false, - update_resumen: true, - update_tiradas_alternativas: true - }) - + }) check_serv_acabado_error() } @@ -273,16 +295,6 @@ function get_tarifas_acabado(tarifa_id = -1, uso=null){ }) }); - if(data.values.lenght > 0){ - //updateTotales(false, true, false) - updatePresupuesto({ - update_lineas: false, - update_servicios: false, - update_envios: false, - update_resumen: true, - update_tiradas_alternativas: true - }) - } check_serv_acabado_error() yeniden(data[window.csrf_token]); @@ -479,6 +491,14 @@ var tableServiciosEnc = new DataTable('#tableOfServiciosEncuadernacion',{ }, }); +tableServiciosEnc.on('draw', function(){ + updatePresupuesto({ + update_lineas: false, + update_servicios: false, + update_envios: false, + update_resumen: true, + update_tiradas_alternativas: true}) +}) function init_servicio_encuadernado(){ @@ -560,14 +580,6 @@ function init_servicio_encuadernado(){ }); $('#proveedor_enc_' + element.tarifa_encuadernado_id).on('change', proveedor_enc_event) }); - - updatePresupuesto({ - update_lineas: false, - update_servicios: false, - update_envios: false, - update_resumen: true, - update_tiradas_alternativas: true - }) check_serv_enc_error() } @@ -602,13 +614,6 @@ function proveedor_enc_event(){ $('#precio_total_encuadernado_' + datos.tarifa_encuadernacion_id).val(parseFloat(data.values[0].total).toFixed(2)) $('#enc_margen_' + datos.tarifa_encuadernacion_id).val(parseFloat(data.values[0].margen).toFixed(2)) - updatePresupuesto({ - update_lineas: false, - update_servicios: false, - update_envios: false, - update_resumen: true, - update_tiradas_alternativas: true - }) yeniden(data[window.csrf_token]); return true; }, @@ -746,17 +751,6 @@ async function get_tarifas_enc(tipo=null, tarifa_id = -1){ }); - - if(data.values.lenght > 0){ - - updatePresupuesto({ - update_lineas: false, - update_servicios: false, - update_envios: false, - update_resumen: true, - update_tiradas_alternativas: true - }) - } check_serv_enc_error() yeniden(data[window.csrf_token]); return true; @@ -781,6 +775,8 @@ $('#insertar_serv_enc').on('click', function(){ } check_serv_enc_error() }) + + function get_datos_encuadernacion(){ var datosEnc = [] @@ -882,6 +878,15 @@ var tableServiciosManipulado = new DataTable('#tableOfServiciosManipulado',{ }, }); +tableServiciosManipulado.on('draw', function(){ + updatePresupuesto({ + update_lineas: false, + update_servicios: false, + update_envios: false, + update_resumen: true, + update_tiradas_alternativas: true}) +}) + function init_servicio_manipulado(){ $('#add_servicio_manipulado_list').select2({ @@ -989,17 +994,6 @@ async function get_tarifas_manipulado(tipo=null, tarifa_id = -1){ update_tiradas_alternativas: true}) }) }); - - if(data.values.lenght > 0){ - - updatePresupuesto({ - update_lineas: false, - update_servicios: false, - update_envios: false, - update_resumen: true, - update_tiradas_alternativas: true - }) - } check_serv_manipulado_error() yeniden(data[window.csrf_token]); return true; @@ -1133,6 +1127,15 @@ var tableServiciosPreimpresion = new DataTable('#tableOfServiciosPreimpresion',{ } }); +tableServiciosPreimpresion.on('draw', function(){ + updatePresupuesto({ + update_lineas: false, + update_servicios: false, + update_envios: false, + update_resumen: true, + update_tiradas_alternativas: true}) +}) + function init_servicio_preimpresion(){ @@ -1163,14 +1166,6 @@ function init_servicio_preimpresion(){ }) }) - - updatePresupuesto({ - update_lineas: false, - update_servicios: false, - update_envios: false, - update_resumen: true, - update_tiradas_alternativas: true - }) check_serv_preimpresion_error() } @@ -1207,7 +1202,7 @@ function get_tarifas_preimpresion(tarifa_id = -1){ $.ajax({ type: "POST", - url: window.routes_servicios.dataTableOfPresupuestoPreimpresiones, + url: window.routes_servicios.dataTableOfPresupuestoPreimpresion, data: datos, success: function (data) { @@ -1231,17 +1226,6 @@ function get_tarifas_preimpresion(tarifa_id = -1){ }) }); - - if(data.values.lenght > 0){ - - updatePresupuesto({ - update_lineas: false, - update_servicios: false, - update_envios: false, - update_resumen: true, - update_tiradas_alternativas: true - }) - } check_serv_preimpresion_error() yeniden(data[window.csrf_token]); return true; @@ -1375,6 +1359,225 @@ async function get_servPreimpresion_tiradasAlternativas(){ } + + + +/**************************************************************************************** + * Seccion para los servicios extra + ***************************************************************************************/ +var tableServiciosExtra = new DataTable('#tableOfServiciosExtra',{ + scrollX: true, + searching: false, + paging: false, + info: false, + ordering: false, + responsive: true, + select: false, + language: { + url: "/themes/vuexy/vendor/libs/datatables-sk/plugins/i18n/es-ES.json" + } +}); + +tableServiciosExtra.on('draw', function(){ + updatePresupuesto({ + update_lineas: false, + update_servicios: false, + update_envios: false, + update_resumen: true, + update_tiradas_alternativas: true}) +}) + +function init_servicio_extra(){ + + + $('#add_servicio_extra_list').select2({ + allowClear: false, + minimumResultsForSearch: -1, + placeholder: window.Presupuestos.servicioextraList + }) + + window.serviciosextraList.forEach((element) =>{ + + tableServiciosExtra.row.add([ + element.tarifa_extra_id, + element.nombre, + '', + '', + '' + ]).draw(false) + + $('#precio_servicioextra_' + element.tarifa_extra_id).on('change', function(){ + updatePresupuesto({ + update_lineas: false, + update_servicios: false, + update_envios: false, + update_resumen: true, + update_tiradas_alternativas: true}) + }) + + }) + check_serv_extra_error() +} + +function check_serv_extra_error(){ + + var htmlString = ''; + + $('#tableOfServiciosExtra tr').each(function(){ + + if(parseFloat($(this).find('td:eq(2) input').val()) == '0'){ + htmlString = ` + `; + } + }) + $('#serv-preimpresion-error').html(htmlString) +} + +function get_tarifas_extra(tarifa_id = -1){ + + var datos = { + tarifa_extra_id : tarifa_id, + }; + datos = Object.assign(datos, window.token_ajax) + + + $.ajax({ + type: "POST", + url: window.routes_servicios.dataTableOfPresupuestoServiciosExtra, + data: datos, + success: function (data) { + + data.values.forEach((row) => { + + tableServiciosExtra.row.add([ + row.tarifa_id, + row.tarifa_nombre, + '', + '', + '' + ]).draw(false) + + $('#precio_servicioextra_' + row.tarifa_id).on('change', function(){ + updatePresupuesto({ + update_lineas: false, + update_servicios: false, + update_envios: false, + update_resumen: true, + update_tiradas_alternativas: true}) + }) + + }); + check_serv_extra_error() + yeniden(data[window.csrf_token]); + return true; + }, + error: function(e){ + return false; + } + }) + return false; +} + + +$('#insertar_serv_extra').on('click', function(){ + const tarifa_text = $('#add_servicio_extra_list').select2('data')[0].text.trim() + + if( $('#add_servicio_extra_list').select2('data')[0].text.trim().length > 0){ + if($('#tableOfServiciosExtra tr > td:contains(' + tarifa_text + ')').length == 0) + get_tarifas_extra($('#add_servicio_extra_list').select2('data')[0].id); + else{ + popErrorAlert(window.Presupuestos.errores.error_servicios_duplicados, 'serv-extra-alert') + } + } + check_serv_extra_error() +}) + + +function get_datos_serviciosextra(){ + + var datosServiciosExtra = [] + if($("#tableOfServiciosExtra").DataTable().rows().count()>0){ + + $("#tableOfServiciosExtra tr").each(function (index,tr) { + var values = {} + $(this).find("td").each(function (index2) { + + switch (index2) { + case 0: + values['tarifa_id'] = $(this).text() + break + case 2: + values['precio'] = $(this).children(":first").val() + break + case 3: + values['margen'] = $(this).text() + break + } + }) + if(Object.keys(values).length>0) + datosServiciosExtra.push(values) + }) + } + + return datosServiciosExtra; +} + + +async function get_servExtra_tiradasAlternativas(){ + + const url = window.location.href; + const url_parts = url.split('/'); + var id = -1; + if(url_parts[url_parts.length-2] == 'edit'){ + id = url_parts[url_parts.length-1]; + } + + var serviciosExtra ={ + coste: 0.0, + margen: 0.0, + } + var json_data = { + datos: get_datos_serviciosextra(), + POD: $('#POD').val() + } + if(json_data.datos.length>0){ + + json_data = Object.assign(json_data, window.token_ajax); + + await fetch(window.location.origin + "/presupuestos/presupuestoserviciosextra/update/" + id , { + method: "POST", + body: JSON.stringify(json_data), + headers: { + "Content-type": "application/json; charset=UTF-8" + } + }) + .then(response => response.json()) + .then(data => { + //const values = await response.json(); + yeniden(data[window.csrf_token]); + data.lines.forEach((line) => { + serviciosExtra.coste += parseFloat(line[0].precio); + serviciosExtra.margen += parseFloat(line[0].precio)*parseFloat(line[0].margen)/100.0; + }); + + }); + } + return serviciosExtra; +} + + +/**************************************************************************************** + * Seccion para "otros" + ***************************************************************************************/ async function actualizar_servicios(update_preimpresion=false){ const domain = window.location.origin @@ -1425,6 +1628,11 @@ async function actualizar_servicios(update_preimpresion=false){ datos_json_preimpresion = Object.assign(datos_json_preimpresion, window.token_ajax); + var datos_json_serviciosextra = { + datos: get_datos_serviciosextra(), + } + datos_json_preimpresion = Object.assign(datos_json_preimpresion, window.token_ajax); + fetch(domain + "/presupuestos/presupuestoacabados/update/" + id , { method: "POST", body: JSON.stringify(datos_json_acabados), @@ -1507,6 +1715,26 @@ async function actualizar_servicios(update_preimpresion=false){ yeniden(data[window.csrf_token]); }) } + }).then(function(){ + if(update_preimpresion){ + fetch(domain + "/presupuestos/presupuestoserviciosextra/update/" + id , { + method: "POST", + body: JSON.stringify(datos_json_serviciosextra), + headers: { + "Content-type": "application/json; charset=UTF-8" + } + }) + .then(response => response.json()) + .then(data => { + + data.lines.forEach((line) => { + $('#precio_serviciosextra_' + line[0].tarifa_id).val(parseFloat(line[0].total).toFixed(2)) + $('#serviciosextra_margen_' + line[0].tarifa_id).val(parseFloat(line[0].margen).toFixed(2)) + }); + check_serv_preimpresion_error(); + yeniden(data[window.csrf_token]); + }) + } }) ) ) @@ -1531,4 +1759,4 @@ function popAlert(message, alertClass, alertIcon, containerId = 'sk-alert'){ $('#' + containerId).fadeOut("slow"); }, 5000); }); -} \ No newline at end of file +} diff --git a/ci4/app/Views/themes/backend/vuexy/form/presupuestos/cosidotapablanda/_datosServiciosItems.php b/ci4/app/Views/themes/backend/vuexy/form/presupuestos/cosidotapablanda/_datosServiciosItems.php index fb3c516c..985791d3 100755 --- a/ci4/app/Views/themes/backend/vuexy/form/presupuestos/cosidotapablanda/_datosServiciosItems.php +++ b/ci4/app/Views/themes/backend/vuexy/form/presupuestos/cosidotapablanda/_datosServiciosItems.php @@ -66,6 +66,18 @@ +
@@ -221,6 +233,42 @@
+
+
+
+
+
+ + + + + + + + + + + + +
+
+
+ +
+
+ +
+ +
+
+
@@ -243,12 +291,15 @@ window.serviciospreimpresionList = ; + window.serviciosextraList = ; + window.routes_servicios = { dataTableOfPresupuestoAcabados: "", dataTableOfPresupuestoPreimpresion: "", dataTableOfPresupuestoEncuadernaciones: "", dataTableOfPresupuestoManipulados: "", menuItemsOfPresupuestoEncuadernaciones: '', + dataTableOfPresupuestoServiciosExtra: "", } init_servicio_acabado() @@ -258,5 +309,7 @@ init_servicio_manipulado() init_servicio_preimpresion() + + init_servicio_extra() endSection() ?> diff --git a/ci4/app/Views/themes/backend/vuexy/form/presupuestos/cosidotapablanda/_resumenPresupuestos.js b/ci4/app/Views/themes/backend/vuexy/form/presupuestos/cosidotapablanda/_resumenPresupuestos.js index bb4473b4..0f6837b5 100644 --- a/ci4/app/Views/themes/backend/vuexy/form/presupuestos/cosidotapablanda/_resumenPresupuestos.js +++ b/ci4/app/Views/themes/backend/vuexy/form/presupuestos/cosidotapablanda/_resumenPresupuestos.js @@ -114,6 +114,17 @@ function updateTotales(updateLP=true, updateServicios=true, updateEnvio=true){ }) } + if ( typeof $("#tableOfServiciosExtra").DataTable() !== 'undefined' && $("#tableOfServiciosExtra").DataTable().rows().count() > 0){ + + $('#tableOfServiciosExtra tbody tr').each(function(){ + var currentRow = $(this).closest("tr"); + var subId = $('#tableOfServiciosExtra').DataTable().cell(currentRow,0).node().innerHTML; + var total = parseFloat($('#precio_servicioextra_' + subId)[0].value) + totalServicios += total + margenServicios += (total*parseFloat($('#servicioextra_margen_' + subId)[0].innerHTML)/100.0) + }) + } + if ( typeof $("#tableOfServiciosManipulado").DataTable() !== 'undefined' && $("#tableOfServiciosManipulado").DataTable().rows().count() > 0){ $('#tableOfServiciosManipulado tbody tr').each(function(){ diff --git a/ci4/app/Views/themes/backend/vuexy/form/presupuestos/cosidotapablanda/_tiradasAlternativasItems.js b/ci4/app/Views/themes/backend/vuexy/form/presupuestos/cosidotapablanda/_tiradasAlternativasItems.js index 1727ee66..5314410f 100644 --- a/ci4/app/Views/themes/backend/vuexy/form/presupuestos/cosidotapablanda/_tiradasAlternativasItems.js +++ b/ci4/app/Views/themes/backend/vuexy/form/presupuestos/cosidotapablanda/_tiradasAlternativasItems.js @@ -143,6 +143,10 @@ async function add_tirada_alternativa(tirada_alt) { costes_servicios += parseFloat(valuePreimpresion.coste); margen_servicios += parseFloat(valuePreimpresion.margen); + const valueServiciosExtra = await get_servExtra_tiradasAlternativas(parseInt(datos.tirada)); + costes_servicios += parseFloat(valueServiciosExtra.coste); + margen_servicios += parseFloat(valueServiciosExtra.margen); + //console.log('coste preimpresion ('+ datos.tirada +'): ' + valuePreimpresion.coste); const valueTransporte = await get_coste_envio_tiradasAlternativas(parseInt(datos.tirada)); 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 e5a4c17c..71c11fdb 100755 --- a/ci4/app/Views/themes/backend/vuexy/form/presupuestos/cosidotapablanda/viewCosidotapablandaForm.php +++ b/ci4/app/Views/themes/backend/vuexy/form/presupuestos/cosidotapablanda/viewCosidotapablandaForm.php @@ -84,14 +84,16 @@ } }) + const domain = window.location.origin + const url = window.location.href; + const url_parts = url.split('/'); + var id = -1; + if(url_parts[url_parts.length-2] == 'edit'){ + id = url_parts[url_parts.length-1]; + } + if(gotaNegro){ - const domain = window.location.origin - const url = window.location.href; - const url_parts = url.split('/'); - var id = -1; - if(url_parts[url_parts.length-2] == 'edit'){ - id = url_parts[url_parts.length-1]; - } + asyncMessageDialog('', '', function() { $.ajax({ type: 'post', @@ -117,6 +119,30 @@ }); }) } + else{ + $.ajax({ + type: 'post', + url: '', + + data: { + tipo: 'duplicar', + presupuesto_id: id, + : v + }, + dataType: 'json', + success:function(response){ + + token=response.; + yeniden(token); + // redirect + new_location = '' + response.id + window.location.href = new_location; + } + }).fail(function (jqXHR, textStatus, error) { + // Handle error here + console.log(jqXHR) + }); + } }); @@ -365,14 +391,14 @@ + + + - - - endSection() ?> diff --git a/ci4/app/Views/themes/backend/vuexy/form/tarifas/extra/_tarifaextraFormItems.php b/ci4/app/Views/themes/backend/vuexy/form/tarifas/extra/_tarifaextraFormItems.php new file mode 100755 index 00000000..7980c60e --- /dev/null +++ b/ci4/app/Views/themes/backend/vuexy/form/tarifas/extra/_tarifaextraFormItems.php @@ -0,0 +1,93 @@ +
+
+
+ + +
+ +
+ + +
+ +
+ + +
+ +
+ + +
+ +
+ + +
+ + +
+
+ mostrar_en_presupuesto == true ? 'checked' : ''; ?> + > + +
+
+ +
+ +
\ No newline at end of file diff --git a/ci4/app/Views/themes/backend/vuexy/form/tarifas/extra/viewTarifaextraForm.php b/ci4/app/Views/themes/backend/vuexy/form/tarifas/extra/viewTarifaextraForm.php new file mode 100755 index 00000000..f121efc4 --- /dev/null +++ b/ci4/app/Views/themes/backend/vuexy/form/tarifas/extra/viewTarifaextraForm.php @@ -0,0 +1,30 @@ +include("themes/_commonPartialsBs/select2bs5") ?> +include("themes/_commonPartialsBs/sweetalert") ?> +extend('themes/backend/vuexy/main/defaultlayout') ?> +section("content") ?> +
+
+
+
+

+
+
+ + + getErrors()) ? $validation->listErrors("bootstrap_style") : "" ?> + +
+ " + /> + "btn btn-secondary"]) ?> + +
+
+
+
+
+endSection() ?> diff --git a/ci4/app/Views/themes/backend/vuexy/form/tarifas/extra/viewTarifaextraList.php b/ci4/app/Views/themes/backend/vuexy/form/tarifas/extra/viewTarifaextraList.php new file mode 100755 index 00000000..592d7dd0 --- /dev/null +++ b/ci4/app/Views/themes/backend/vuexy/form/tarifas/extra/viewTarifaextraList.php @@ -0,0 +1,120 @@ +include('themes/_commonPartialsBs/datatables') ?> +extend('themes/backend/vuexy/main/defaultlayout') ?> +section('content'); ?> +
+
+ +
+
+

+ 'btn btn-primary float-end']); ?> +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ nombre) || strlen($item->nombre) < 51 ? esc($item->nombre) : character_limiter(esc($item->nombre), 50) ?> + + precio) ?> + + precio_min) ?> + + importe_fijo) ?> + + margen) ?> + + mostrar_en_presupuesto)==1?'':"" ?> + + id), "", ['class'=>'text-body', 'data-id'=>$item->id,]); ?> + ", ['class'=>'text-body', 'data-href'=>route_to('deleteTarifaextra', $item->id), 'data-bs-toggle'=>'modal', 'data-bs-target'=>'#confirm2delete']); ?> +
+
+ +
+
+
+ +endSection() ?> + +section('css') ?> + "> +endSection() ?> + + +section('additionalExternalJs') ?> + + + + + + + + + + +endSection() ?> + +section('additionalInlineJs') ?> + + const lastColNr2 = $(".using-exportable-data-table").find("tr:first th").length - 1; + theTable = $('.using-exportable-data-table').DataTable({ + "responsive": true, + "paging": true, + "lengthMenu": [ 5, 10, 25, 50, 75, 100, 250, 500, 1000, 2500 ], + "pageLength": 50, + "lengthChange": true, + "searching": true, + "ordering": true, + "info": true, + "dom": 'lfBrtip', // 'lfBrtip', // you can try different layout combinations by uncommenting one or the other + // "dom": '<"top"lf><"clear">rt<"bottom"ipB><"clear">', // remember to comment this line if you uncomment the above + "buttons": [ + 'copy', 'csv', 'excel', 'print', { + extend: 'pdfHtml5', + orientation: 'landscape', + pageSize: 'A4' + } + ], + "autoWidth": true, + "scrollX": true, + "stateSave": true, + "language": { + url: "/themes/vuexy/vendor/libs/datatables-sk/plugins/i18n/es-ES.json" + }, + "columnDefs": [ + { + orderable: false, + searchable: false, + targets: [lastColNr2] + } + ] + }); +endSection() ?> \ No newline at end of file diff --git a/ci4/app/Views/themes/backend/vuexy/main/menu.php b/ci4/app/Views/themes/backend/vuexy/main/menu.php index b5184543..b747c669 100755 --- a/ci4/app/Views/themes/backend/vuexy/main/menu.php +++ b/ci4/app/Views/themes/backend/vuexy/main/menu.php @@ -1,4 +1,4 @@ - +