diff --git a/ci4/app/Config/Routes.php b/ci4/app/Config/Routes.php index 6a551a25..441371f2 100755 --- a/ci4/app/Config/Routes.php +++ b/ci4/app/Config/Routes.php @@ -494,7 +494,6 @@ $routes->resource('cosidotapablanda', ['namespace' => 'App\Controllers\Presupue $routes->group('serviciosacabados', ['namespace' => 'App\Controllers\Presupuestos'], function ($routes) { $routes->post('datatable', 'Presupuestoacabados::datatable', ['as' => 'dataTableOfPresupuestoAcabados']); - $routes->get('delete/(:num)', 'Presupuestoacabados::delete/$1', ['as' => 'deletePresupuestoAcabado']); $routes->post('edit/(:num)', 'Presupuestoacabados::edit/$1', ['as' => 'updatePresupuestoacabados']); }); @@ -507,13 +506,13 @@ $routes->group('serviciosencuadernaciones', ['namespace' => 'App\Controllers\Pre }); $routes->group('serviciosmanipulados', ['namespace' => 'App\Controllers\Presupuestos'], function ($routes) { - $routes->post('datatable', 'PresupuestoManipulados::datatable', ['as' => 'dataTableOfPresupuestoManipulados']); - $routes->post('datatable_editor', 'PresupuestoManipulados::datatable_editor', ['as' => 'editorOfPresupuestoManipulados']); + $routes->post('datatable', 'Presupuestomanipulados::datatable', ['as' => 'dataTableOfPresupuestoManipulados']); + $routes->post('edit/(:num)', 'Presupuestomanipulados::edit/$1', ['as' => 'updatePresupuestomanipulados']); }); $routes->group('serviciospreimpresiones', ['namespace' => 'App\Controllers\Presupuestos'], function ($routes) { - $routes->post('datatable', 'PresupuestoPreimpresiones::datatable', ['as' => 'dataTableOfPresupuestoPreimpresiones']); - $routes->post('datatable_editor', 'PresupuestoPreimpresiones::datatable_editor', ['as' => 'editorOfPresupuestoPreimpresiones']); + $routes->post('datatable', 'Presupuestopreimpresiones::datatable', ['as' => 'dataTableOfPresupuestoPreimpresiones']); + $routes->post('edit/(:num)', 'Presupuestopreimpresiones::edit/$1', ['as' => 'updatePresupuestopreimpresiones']); }); $routes->group('printpresupuestos', ['namespace' => 'App\Controllers\Pdf'], function ($routes) { diff --git a/ci4/app/Controllers/Presupuestos/Cosidotapablanda.php b/ci4/app/Controllers/Presupuestos/Cosidotapablanda.php index f4812f10..f90eb06b 100755 --- a/ci4/app/Controllers/Presupuestos/Cosidotapablanda.php +++ b/ci4/app/Controllers/Presupuestos/Cosidotapablanda.php @@ -12,6 +12,8 @@ use App\Models\Presupuestos\PresupuestoModel; use App\Models\Presupuestos\PresupuestoEncuadernacionesModel; use App\Models\Presupuestos\PresupuestoAcabadosModel; +use App\Models\Presupuestos\PresupuestoManipuladosModel; +use App\Models\Presupuestos\PresupuestoPreimpresionesModel; use App\Services\PresupuestoService; use App\Models\Configuracion\PapelImpresionModel; @@ -284,6 +286,8 @@ class Cosidotapablanda extends \App\Controllers\GoBaseResourceController $this->viewData['serviciosManipulado'] = $this->getServiciosManipulado(); $this->viewData['serviciosEncuadernacionList'] = (new PresupuestoEncuadernacionesModel())->getResource($id)->get()->getResultObject(); $this->viewData['serviciosAcabadosList'] = (new PresupuestoAcabadosModel())->getResource($id)->get()->getResultObject(); + $this->viewData['serviciosManipuladoList'] = (new PresupuestoManipuladosModel())->getResource($id)->get()->getResultObject(); + $this->viewData['serviciosPreimpresionList'] = (new PresupuestoPreimpresionesModel())->getResource($id)->get()->getResultObject(); $this->viewData['POD'] = $this->getPOD(); diff --git a/ci4/app/Controllers/Presupuestos/PresupuestoManipulados.php b/ci4/app/Controllers/Presupuestos/PresupuestoManipulados.php deleted file mode 100755 index 4dcfed56..00000000 --- a/ci4/app/Controllers/Presupuestos/PresupuestoManipulados.php +++ /dev/null @@ -1,123 +0,0 @@ -request->isAJAX()) { - $reqData = $this->request->getPost(); - if (!isset($reqData['draw']) || !isset($reqData['columns'])) { - $errstr = 'No data available in response to this specific request.'; - $response = $this->respond(Collection::datatable([], 0, 0, $errstr), 400, $errstr); - return $response; - } - $start = $reqData['start'] ?? 0; - $length = $reqData['length'] ?? 5; - $requestedOrder = $reqData['order']['0']['column'] ?? 1; - $order = PresupuestoManipuladosModel::SORTABLE[$requestedOrder >= 0 ? $requestedOrder : 1]; - $dir = $reqData['order']['0']['dir'] ?? 'asc'; - - $id_P = $reqData['id_presupuesto'] ?? -1; - - $resourceData = $this->model->getResource($id_P)->orderBy($order, $dir)->limit($length, $start)->get()->getResultObject(); - - return $this->respond(Collection::datatable( - $resourceData, - $this->model->getResource()->countAllResults(), - $this->model->getResource($id_P)->countAllResults() - )); - } else { - return $this->failUnauthorized('Invalid request', 403); - } - } - - public function datatable_editor() { - if ($this->request->isAJAX()) { - - include(APPPATH . "ThirdParty/DatatablesEditor/DataTables.php"); - - // Build our Editor instance and process the data coming from _POST - $response = Editor::inst( $db, 'presupuesto_manipulados' ) - ->fields( - Field::inst( 'tarifa_manipulado_id' ) - ->validator( 'Validate::notEmpty',array( - 'message' => 'Selecciones servicios de acabado' ) - ), - Field::inst( 'precio_unidad' ) - ->validator( 'Validate::notEmpty',array( - 'message' => 'Falta precio unitario' ) - ), - Field::inst( 'precio_total' ) - ->validator( 'Validate::notEmpty',array( - 'message' => 'Falta precio total' ) - ), - - Field::inst( 'presupuesto_id' ), - - ) - ->validator( function($editor, $action, $data){ - if ($action === Editor::ACTION_CREATE || $action === Editor::ACTION_EDIT){ - //return $response; - /*foreach ($data['data'] as $pkey => $values ){ - // No se pueden duplicar valores al crear o al editar - if (!empty($response)){ - return $response; - } - }*/ - } - }) - ->debug(true) - ->process( $_POST ) - ->data(); - - $newTokenHash = csrf_hash(); - $csrfTokenName = csrf_token(); - - $response[$csrfTokenName] = $newTokenHash; - - echo json_encode($response); - - } else { - return $this->failUnauthorized('Invalid request', 403); - } - } - - - -} diff --git a/ci4/app/Controllers/Presupuestos/PresupuestoPreimpresiones.php b/ci4/app/Controllers/Presupuestos/PresupuestoPreimpresiones.php deleted file mode 100755 index 7142c642..00000000 --- a/ci4/app/Controllers/Presupuestos/PresupuestoPreimpresiones.php +++ /dev/null @@ -1,117 +0,0 @@ -request->isAJAX()) { - $reqData = $this->request->getPost(); - if (!isset($reqData['draw']) || !isset($reqData['columns'])) { - $errstr = 'No data available in response to this specific request.'; - $response = $this->respond(Collection::datatable([], 0, 0, $errstr), 400, $errstr); - return $response; - } - $start = $reqData['start'] ?? 0; - $length = $reqData['length'] ?? 5; - $requestedOrder = $reqData['order']['0']['column'] ?? 1; - $order = PresupuestoPreimpresionesModel::SORTABLE[$requestedOrder >= 0 ? $requestedOrder : 1]; - $dir = $reqData['order']['0']['dir'] ?? 'asc'; - - $id_P = $reqData['id_presupuesto'] ?? -1; - - $resourceData = $this->model->getResource($id_P)->orderBy($order, $dir)->limit(50, $start)->get()->getResultObject(); - - return $this->respond(Collection::datatable( - $resourceData, - $this->model->getResource()->countAllResults(), - $this->model->getResource($id_P)->countAllResults() - )); - } else { - return $this->failUnauthorized('Invalid request', 403); - } - } - - public function datatable_editor() { - if ($this->request->isAJAX()) { - - include(APPPATH . "ThirdParty/DatatablesEditor/DataTables.php"); - - // Build our Editor instance and process the data coming from _POST - $response = Editor::inst( $db, 'presupuesto_preimpresiones' ) - ->fields( - Field::inst( 'tarifa_preimpresion_id' ) - ->validator( 'Validate::notEmpty',array( - 'message' => 'Selecciones servicios de acabado' ) - ), - Field::inst( 'precio_unidad' ) - ->validator( 'Validate::notEmpty',array( - 'message' => 'Falta precio unitario' ) - ), - Field::inst( 'precio_total' ) - ->validator( 'Validate::notEmpty',array( - 'message' => 'Falta precio total' ) - ), - - Field::inst( 'presupuesto_id' ), - - ) - ->validator( function($editor, $action, $data){ - if ($action === Editor::ACTION_CREATE || $action === Editor::ACTION_EDIT){ - //return $response; - /*foreach ($data['data'] as $pkey => $values ){ - // No se pueden duplicar valores al crear o al editar - if (!empty($response)){ - return $response; - } - }*/ - } - }) - ->debug(true) - ->process( $_POST ) - ->data(); - - $newTokenHash = csrf_hash(); - $csrfTokenName = csrf_token(); - - $response[$csrfTokenName] = $newTokenHash; - - echo json_encode($response); - - } else { - return $this->failUnauthorized('Invalid request', 403); - } - } - - - -} diff --git a/ci4/app/Controllers/Presupuestos/Presupuestoacabados.php b/ci4/app/Controllers/Presupuestos/Presupuestoacabados.php index c451649a..84c46feb 100755 --- a/ci4/app/Controllers/Presupuestos/Presupuestoacabados.php +++ b/ci4/app/Controllers/Presupuestos/Presupuestoacabados.php @@ -7,9 +7,7 @@ use App\Models\Collection; use App\Models\Presupuestos\PresupuestoAcabadosModel; -use DataTables\Editor; -use DataTables\Editor\Field; -use DataTables\Editor\Validate; + class Presupuestoacabados extends \App\Controllers\GoBaseResourceController diff --git a/ci4/app/Controllers/Presupuestos/Presupuestomanipulados.php b/ci4/app/Controllers/Presupuestos/Presupuestomanipulados.php new file mode 100755 index 00000000..db77861b --- /dev/null +++ b/ci4/app/Controllers/Presupuestos/Presupuestomanipulados.php @@ -0,0 +1,89 @@ +request->getJSON(); + $tarifas = array_column($postData->datos, 'tarifa_id'); + if(count($tarifas)>0){ + $this->model->deleteServiciosNotInArray($requestedId, $tarifas); + } + else{ + $this->model->deleteAllServicios($requestedId); + } + + $this->model->updateTarifas($requestedId, $postData->datos); + + $newTokenHash = csrf_hash(); + $csrfTokenName = csrf_token(); + $data = [ + $csrfTokenName => $newTokenHash + ]; + + return $this->respond($data); + } + + public function datatable() + { + if ($this->request->isAJAX()) { + $reqData = $this->request->getPost(); + + $tarifa_manipulado_id = $reqData['tarifa_manipulado_id'] ?? 0; + $tirada = $reqData['tirada'] ?? 0; + $POD = $reqData['POD'] ?? 0; + + $newTokenHash = csrf_hash(); + $csrfTokenName = csrf_token(); + + $values = $this->model->getPrecioTarifa($tarifa_manipulado_id, $tirada, $POD); + + $data = [ + 'values' => $values, + $csrfTokenName => $newTokenHash + ]; + + return $this->respond($data); + + } else { + return $this->failUnauthorized('Invalid request', 403); + } + } + +} diff --git a/ci4/app/Controllers/Presupuestos/Presupuestopreimpresiones.php b/ci4/app/Controllers/Presupuestos/Presupuestopreimpresiones.php new file mode 100755 index 00000000..2c9a1e6f --- /dev/null +++ b/ci4/app/Controllers/Presupuestos/Presupuestopreimpresiones.php @@ -0,0 +1,83 @@ +request->getJSON(); + $tarifas = array_column($postData->datos, 'tarifa_id'); + if(count($tarifas)>0){ + $this->model->deleteServiciosNotInArray($requestedId, $tarifas); + } + else{ + $this->model->deleteAllServicios($requestedId); + } + + $this->model->updateTarifas($requestedId, $postData->datos); + + $newTokenHash = csrf_hash(); + $csrfTokenName = csrf_token(); + $data = [ + $csrfTokenName => $newTokenHash + ]; + + return $this->respond($data); + } + + public function datatable() + { + if ($this->request->isAJAX()) { + $reqData = $this->request->getPost(); + + $tarifa_preimpresion_id = $reqData['tarifa_preimpresion_id'] ?? 0; + + $newTokenHash = csrf_hash(); + $csrfTokenName = csrf_token(); + + $values = $this->model->getPrecioTarifa($tarifa_preimpresion_id); + + $data = [ + 'values' => $values, + $csrfTokenName => $newTokenHash + ]; + + return $this->respond($data); + + } else { + return $this->failUnauthorized('Invalid request', 403); + } + } + +} diff --git a/ci4/app/Controllers/Tarifas/Tarifaencuadernacionlineashoras.php b/ci4/app/Controllers/Tarifas/Tarifaencuadernacionlineashoras.php old mode 100644 new mode 100755 diff --git a/ci4/app/Entities/Tarifas/TarifaEncuadernacionLineaHoras.php b/ci4/app/Entities/Tarifas/TarifaEncuadernacionLineaHoras.php old mode 100644 new mode 100755 diff --git a/ci4/app/Entities/Tarifas/TarifapreimpresionEntity.php b/ci4/app/Entities/Tarifas/TarifapreimpresionEntity.php index 7c3f9d0a..3f749913 100755 --- a/ci4/app/Entities/Tarifas/TarifapreimpresionEntity.php +++ b/ci4/app/Entities/Tarifas/TarifapreimpresionEntity.php @@ -8,7 +8,7 @@ class TarifapreimpresionEntity extends \CodeIgniter\Entity\Entity protected $attributes = [ "id" => null, "nombre" => null, - "precio_pagina" => null, + "precio" => null, "precio_min" => 0, "importe_fijo" => 0, "margen" => 0, @@ -21,7 +21,7 @@ class TarifapreimpresionEntity extends \CodeIgniter\Entity\Entity "updated_at" => null, ]; protected $casts = [ - "precio_pagina" => "float", + "precio" => "float", "precio_min" => "float", "importe_fijo" => "float", "margen" => "float", diff --git a/ci4/app/Language/en/Tarifapreimpresion.php b/ci4/app/Language/en/Tarifapreimpresion.php index 5d3070bc..6afb8095 100755 --- a/ci4/app/Language/en/Tarifapreimpresion.php +++ b/ci4/app/Language/en/Tarifapreimpresion.php @@ -8,7 +8,7 @@ return [ 'id' => 'ID', 'moduleTitle' => 'Preprinting rates', 'nombre' => 'Name', - 'precio' => 'Price per page', + 'precio' => 'Price', 'precioMin' => 'Min Price', 'importeFijo' => 'Fixed amount', 'margen' => 'Margin', diff --git a/ci4/app/Language/es/Presupuestos.php b/ci4/app/Language/es/Presupuestos.php index 2f711d42..d1a3b96f 100755 --- a/ci4/app/Language/es/Presupuestos.php +++ b/ci4/app/Language/es/Presupuestos.php @@ -153,6 +153,8 @@ return [ 'servicioEncuadernado' => 'Servicio de encuadernación', 'servicioEncuadernadoList' => 'Servicios de encuadernación', 'servicioAcabadoList' => 'Servicios de acabado', + 'servicioManipuladoList' => 'Servicios de manipulado', + 'servicioPreimpresionList' => 'Servicios de preimpresion', 'servicioManipulado' => 'Servicio de manipulado', 'comentarios' => 'Comentarios', @@ -168,6 +170,7 @@ return [ 'confirmar' => 'Confirmar presupuesto', // Servicios + 'precio' => 'Precio', 'precioUnidad' => 'Precio unitario', 'precioTotal' => 'Precio total', 'serviciosEncDefault' => 'Servicios Enc. por defecto', diff --git a/ci4/app/Language/es/Tarifapreimpresion.php b/ci4/app/Language/es/Tarifapreimpresion.php index 5107424b..d8be90cb 100755 --- a/ci4/app/Language/es/Tarifapreimpresion.php +++ b/ci4/app/Language/es/Tarifapreimpresion.php @@ -7,7 +7,7 @@ return [ 'id' => 'ID', 'moduleTitle' => 'Tarifas Preimpresión', 'nombre' => 'Nombre', - 'precio' => 'Precio/página', + 'precio' => 'Precio', 'precioMin' => 'Precio Mínimo', 'importeFijo' => 'Importe Fijo', 'mostrar_en_presupuesto' => 'Mostrar en presupuesto', diff --git a/ci4/app/Models/Presupuestos/PresupuestoManipuladosModel.php b/ci4/app/Models/Presupuestos/PresupuestoManipuladosModel.php index e45976e8..7bdadf3e 100755 --- a/ci4/app/Models/Presupuestos/PresupuestoManipuladosModel.php +++ b/ci4/app/Models/Presupuestos/PresupuestoManipuladosModel.php @@ -45,6 +45,101 @@ class PresupuestoManipuladosModel extends \App\Models\GoBaseModel ]; + public function getPrecioTarifa($tarifa_manipulado_id, $tirada, $POD){ + + $modelTarifa = model('App\Models\Tarifas\TarifaManipuladoModel'); + $tarifa_value = $modelTarifa->getTarifaPresupuestoManipulado($tarifa_manipulado_id, $tirada); + if (count($tarifa_value)>0) { + + $result_data = $this->calcularTarifa($tarifa_value[0], $tirada, $POD<$tirada?false:true); + $ret_array[] = (object)[ + 'tarifa_id'=> $tarifa_value[0]->tarifa_manipulado_id, + 'tarifa_nombre'=> $tarifa_value[0]->tarifa_manipulado_nombre, + 'precio_unidad'=> $result_data[0], + 'total'=> $result_data[1], + ]; + return $ret_array; + } + else{ + $ret_array[] = (object)[ + 'tarifa_id'=> $tarifa_manipulado_id, + 'tarifa_nombre'=> $modelTarifa->getNombreTarifaManipulado($tarifa_manipulado_id)[0]->nombre, + 'precio_unidad' => 0, + 'total'=> 0, + ]; + return $ret_array; + } + return []; + } + + private function calcularTarifa($tarifa, $tirada, $is_POD=false){ + + $precio_unidad = floatval($tarifa->precio_min) - (floatval($tarifa->precio_min) - floatval($tarifa->precio_max))/($tarifa->tirada_max - $tarifa->tirada_min) * ($tirada - $tarifa->tirada_min); + if ($tirada > $tarifa->tirada_max) + $precio_unidad = $tarifa->precio_max; + $precio_unidad = $precio_unidad* (1+ floatval($tarifa->margen)/100.0); + + $total = $precio_unidad * $tirada; + + if (!$is_POD){ + $total += floatval($tarifa->tarifa_importe_fijo); + } + + return [$precio_unidad, $total]; + } + + 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_manipulado_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_manipulado_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_manipulado_id', $tarifa->tarifa_id) + ->set('precio_unidad', $tarifa->precio_unidad) + ->set('precio_total', $tarifa->precio_total) + ->update(); + + + } + else{ + $this->db + ->table($this->table . " t1") + ->set('presupuesto_id', $presupuesto_id) + ->set('tarifa_manipulado_id', $tarifa->tarifa_id) + ->set('precio_unidad', $tarifa->precio_unidad) + ->set('precio_total', $tarifa->precio_total) + ->insert(); + } + } + } + /** * Get resource data. * diff --git a/ci4/app/Models/Presupuestos/PresupuestoPreimpresionesModel.php b/ci4/app/Models/Presupuestos/PresupuestoPreimpresionesModel.php index 2cc3627b..65089ebc 100755 --- a/ci4/app/Models/Presupuestos/PresupuestoPreimpresionesModel.php +++ b/ci4/app/Models/Presupuestos/PresupuestoPreimpresionesModel.php @@ -45,6 +45,90 @@ class PresupuestoPreimpresionesModel extends \App\Models\GoBaseModel ]; + public function getPrecioTarifa($tarifa_preimpresion_id){ + + $modelTarifa = model('App\Models\Tarifas\TarifapreimpresionModel'); + $tarifa_value = $modelTarifa->getTarifaPresupuestoPreimpresion($tarifa_preimpresion_id); + if (count($tarifa_value)>0) { + + $result_data = $this->calcularTarifa($tarifa_value[0]); + $ret_array[] = (object)[ + 'tarifa_id'=> $tarifa_value[0]->tarifa_preimpresion_id, + 'tarifa_nombre'=> $tarifa_value[0]->tarifa_preimpresion_nombre, + 'precio'=> $result_data, + ]; + return $ret_array; + } + else{ + $ret_array[] = (object)[ + 'tarifa_id'=> $tarifa_preimpresion_id, + 'tarifa_nombre'=> $modelTarifa->getNombreTarifaPreimpresion($tarifa_preimpresion_id)[0]->nombre, + 'precio' => 0, + ]; + return $ret_array; + } + return []; + } + + private function calcularTarifa($tarifa){ + + $precio = floatval($tarifa->precio); + $precio = $precio * (1+ floatval($tarifa->margen)/100.0); + + return $precio; + } + + 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_preimpresion_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_preimpresion_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_preimpresion_id', $tarifa->tarifa_id) + ->set('precio', $tarifa->precio) + ->update(); + + + } + else{ + $this->db + ->table($this->table . " t1") + ->set('presupuesto_id', $presupuesto_id) + ->set('tarifa_preimpresion_id', $tarifa->tarifa_id) + ->set('precio', $tarifa->precio) + ->insert(); + } + } + } + + /** * Get resource data. * @@ -57,7 +141,7 @@ class PresupuestoPreimpresionesModel extends \App\Models\GoBaseModel $builder = $this->db ->table($this->table . " t1") ->select( - "t1.id AS id, t1.tarifa_preimpresion_id AS tarifa_preimpresion_id, t1.precio_unidad AS precio_unidad, t1.precio_total AS precio_total, t2.nombre AS nombre" + "t1.id AS id, t1.tarifa_preimpresion_id AS tarifa_preimpresion_id, t1.precio AS precio, t2.nombre AS nombre" ); $builder->where('t1.presupuesto_id', $presupuesto_id); diff --git a/ci4/app/Models/Tarifas/TarifaEncuadernacionLineaHorasModel.php b/ci4/app/Models/Tarifas/TarifaEncuadernacionLineaHorasModel.php old mode 100644 new mode 100755 diff --git a/ci4/app/Models/Tarifas/TarifaManipuladoModel.php b/ci4/app/Models/Tarifas/TarifaManipuladoModel.php index 33c1607f..320c43cf 100755 --- a/ci4/app/Models/Tarifas/TarifaManipuladoModel.php +++ b/ci4/app/Models/Tarifas/TarifaManipuladoModel.php @@ -109,4 +109,41 @@ class TarifaManipuladoModel extends \App\Models\GoBaseModel return $builder->orderBy("t1.nombre", "asc")->get()->getResultObject(); } + + public function getTarifaPresupuestoManipulado($tarifa_id, $tirada){ + + $builder = $this->db + ->table($this->table . " t1") + ->select( + "t1.id AS tarifa_manipulado_id, t1.nombre AS tarifa_manipulado_nombre, t1.precio_min AS tarifa_precio_min, t1.importe_fijo AS tarifa_importe_fijo, + t2.id AS tarifa_linea_id, t2.tirada_min AS tirada_min, t2.tirada_max AS tirada_max, + t2.precio_min AS precio_min, t2.precio_max AS precio_max, t2.margen AS margen" + ) + ->join("tarifa_manipulado_lineas t2", "t1.id = t2.tarifa_manipulado_id", "left") + ->where("t1.is_deleted", 0) + //->where("t1.mostrar_en_presupuesto", 1) + ->where("t2.is_deleted", 0); + + $builder->where('t1.id =', $tarifa_id); + $builder->where('t2.tirada_min <=', $tirada); + $builder->where('t2.tirada_max >', $tirada); + + return $builder->get()->getResultObject(); + } + + public function getNombreTarifaManipulado($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/Models/Tarifas/TarifapreimpresionModel.php b/ci4/app/Models/Tarifas/TarifapreimpresionModel.php index 7d94e40d..78082d7b 100755 --- a/ci4/app/Models/Tarifas/TarifapreimpresionModel.php +++ b/ci4/app/Models/Tarifas/TarifapreimpresionModel.php @@ -14,7 +14,7 @@ class TarifapreimpresionModel extends \App\Models\GoBaseModel protected $allowedFields = [ "nombre", - "precio_pagina", + "precio", "precio_min", "importe_fijo", "margen", @@ -39,7 +39,7 @@ class TarifapreimpresionModel extends \App\Models\GoBaseModel "label" => "Tarifapreimpresion.nombre", "rules" => "trim|required|max_length[255]", ], - "precio_pagina" => [ + "precio" => [ "label" => "Tarifapreimpresion.precio", "rules" => "required|decimal", ], @@ -62,7 +62,7 @@ class TarifapreimpresionModel extends \App\Models\GoBaseModel "max_length" => "Tarifapreimpresion.validation.nombre.max_length", "required" => "Tarifapreimpresion.validation.nombre.required", ], - "precio_pagina" => [ + "precio" => [ "decimal" => "Tarifapreimpresion.validation.precio.decimal", "required" => "Tarifapreimpresion.validation.precio.required", ], @@ -96,5 +96,35 @@ class TarifapreimpresionModel extends \App\Models\GoBaseModel return $builder->orderBy("t1.nombre", "asc")->get()->getResultObject(); } + public function getTarifaPresupuestoPreimpresion($tarifa_id){ + + $builder = $this->db + ->table($this->table . " t1") + ->select( + "t1.id AS tarifa_preimpresion_id, t1.nombre AS tarifa_preimpresion_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 getNombreTarifaPreimpresion($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/Views/themes/backend/vuexy/form/presupuestos/cosidotapablanda/_datosServiciosItems.php b/ci4/app/Views/themes/backend/vuexy/form/presupuestos/cosidotapablanda/_datosServiciosItems.php index e2acac24..00ba3c86 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 @@ -83,7 +83,7 @@
-