diff --git a/ci4/app/Controllers/Presupuestos/Cosidotapablanda.php b/ci4/app/Controllers/Presupuestos/Cosidotapablanda.php index f5a26275..fa04075c 100755 --- a/ci4/app/Controllers/Presupuestos/Cosidotapablanda.php +++ b/ci4/app/Controllers/Presupuestos/Cosidotapablanda.php @@ -1278,8 +1278,8 @@ class Cosidotapablanda extends \App\Controllers\BaseResourceController $input_data['is_duplicado'] = $presupuestoEntity->is_duplicado; if($presupuestoEntity->papel_formato_personalizado){ - $input_data['ancho'] = $presupuestoEntity->ancho; - $input_data['alto'] = $presupuestoEntity->alto; + $input_data['ancho'] = $presupuestoEntity->papel_formato_ancho ; + $input_data['alto'] = $presupuestoEntity->papel_formato_alto ; } else{ $model = model("App\Models\Configuracion\PapelFormatoModel"); diff --git a/ci4/app/Controllers/Presupuestos/Presupuestocliente.php b/ci4/app/Controllers/Presupuestos/Presupuestocliente.php index cb6faeae..68c93493 100755 --- a/ci4/app/Controllers/Presupuestos/Presupuestocliente.php +++ b/ci4/app/Controllers/Presupuestos/Presupuestocliente.php @@ -99,9 +99,16 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController // Se obtiene el cliente ID a partir del usuario de la sesion $model_user = model('App\Models\Usuarios\UserModel'); + $user = $model_user->find(auth()->user()->id); $clienteId = $user->cliente_id; + if (auth()->user()->inGroup('cliente-admin') || auth()->user()->inGroup('cliente-editor')) { + if ($clienteId === false || $clienteId === null) { + return $this->failNotFound('Su usuario no tiene asociado un cliente de Safekat. Póngase en contacto con el administrador.'); + } + } + $POD = model('App\Models\Configuracion\ConfiguracionSistemaModel')->getPOD(); $this->viewData['breadcrumb'] = [ @@ -139,6 +146,9 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController $user = $model_user->find(auth()->user()->id); if (auth()->user()->inGroup('cliente-admin') || auth()->user()->inGroup('cliente-editor')) { $clienteId = $user->cliente_id; + if ($clienteId === false || $clienteId === null) { + return $this->failNotFound('Su usuario no tiene asociado un cliente de Safekat. Póngase en contacto con el administrador.'); + } } else { $clienteId = $presupuestoEntity->cliente_id; } @@ -154,8 +164,9 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController if ($presupuestoEntity->is_duplicado) { $this->model->removeIsDuplicado($presupuestoEntity->id); } - + $this->viewData['presupuestoId'] = $presupuestoEntity->id; + $this->viewData['state'] = intval($presupuestoEntity->estado_id); $this->viewData['boxTitle'] = lang('Basic.global.edit2') . ' ' . $this->viewData['pageTitle'] . ' ' . lang('Basic.global.edit3'); return $this->displayForm(__METHOD__, $id); @@ -374,7 +385,7 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController if (array_key_exists('exception', $return_data)) { return $this->failServerError( $return_data['exception'] . ' - ' . - $return_data['file'] . ' - ' . $return_data['line'] + $return_data['file'] . ' - ' . $return_data['line'] ); } @@ -616,6 +627,7 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController $datosCabecera = $reqData['datosCabecera'] ?? []; $confirmar = $reqData['confirmar'] ?? 0; + $confirmar = intval($confirmar); $cliente_id = $reqData['clienteId'] ?? -1; @@ -918,17 +930,16 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController { if ($this->request->isAJAX()) { - $modelPapelGenerico = new PapelGenericoModel(); $modelPapelFormato = new PapelFormatoModel(); $modelCliente = new ClienteModel(); - $reqData = $this->request->getPost(); - + $presupuesto = $this->model->find($id); $data = []; if ($presupuesto) { $data['lc'] = $presupuesto->lomo_cubierta; $data['lsc'] = $presupuesto->lomo_sobrecubierta; + $data['state'] = intval($presupuesto->estado_id); $data['datosGenerales']['titulo'] = $presupuesto->titulo; $data['datosGenerales']['autor'] = $presupuesto->autor; $data['datosGenerales']['isbn'] = $presupuesto->isbn; @@ -995,6 +1006,11 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController $data['direcciones'] = $this->obtenerDireccionesEnvio($id, $presupuesto->cliente_id); + if(intval($presupuesto->estado_id) == 2){ + $data['resumen']['base'] = $presupuesto->total_aceptado; + $data['resumen']['precio_unidad'] = $presupuesto->total_precio_unidad; + } + $tiradas_alternativas = json_decode($presupuesto->tirada_alternativa_json_data); for ($i = 0; $i < count($tiradas_alternativas); $i++) { $tirada = $tiradas_alternativas[$i]; @@ -2134,7 +2150,8 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController $color = 'negro'; $model = model('App\Models\Presupuestos\PresupuestoLineaModel'); - $data = $model->where('presupuesto_id', $presupuestoId)->findAll();; + $data = $model->where('presupuesto_id', $presupuestoId)->findAll(); + ; foreach ($data as $linea) { if (strpos($linea->tipo, "hq") !== false) { // $linea->tipo contains the substring "hq" diff --git a/ci4/app/Controllers/Tarifas/Tarifaencuadernacionlineas.php b/ci4/app/Controllers/Tarifas/Tarifaencuadernacionlineas.php index 60545c9d..850225b9 100755 --- a/ci4/app/Controllers/Tarifas/Tarifaencuadernacionlineas.php +++ b/ci4/app/Controllers/Tarifas/Tarifaencuadernacionlineas.php @@ -1,4 +1,5 @@ -request->getPost()) : + + if ($this->request->getPost()): $nullIfEmpty = true; // !(phpversion() >= '8.1'); @@ -84,10 +85,10 @@ class Tarifaencuadernacionlineas extends \App\Controllers\BaseResourceController $sanitizedData = $this->sanitized($postData, $nullIfEmpty); $noException = true; - if ($successfulResult = $this->canValidate()) : // if ($successfulResult = $this->validate($this->formValidationRules) ) : + if ($successfulResult = $this->canValidate()): // if ($successfulResult = $this->validate($this->formValidationRules) ) : - if ($this->canValidate()) : + if ($this->canValidate()): try { $successfulResult = $this->model->skipValidation(true)->save($sanitizedData); } catch (\Exception $e) { @@ -101,14 +102,14 @@ class Tarifaencuadernacionlineas extends \App\Controllers\BaseResourceController $thenRedirect = true; // Change this to false if you want your user to stay on the form after submission endif; - if ($noException && $successfulResult) : + if ($noException && $successfulResult): $id = $this->model->db->insertID(); $message = lang('Basic.global.saveSuccess', [lang('Basic.global.record')]) . '.'; - if ($thenRedirect) : - if (!empty($this->indexRoute)) : + if ($thenRedirect): + if (!empty($this->indexRoute)): return redirect()->to(route_to($this->indexRoute))->with('sweet-success', $message); else: return $this->redirect2listView('sweet-success', $message); @@ -134,20 +135,20 @@ class Tarifaencuadernacionlineas extends \App\Controllers\BaseResourceController public function edit($requestedId = null) { - if ($requestedId == null) : + if ($requestedId == null): return $this->redirect2listView(); endif; $id = filter_var($requestedId, FILTER_SANITIZE_URL); $tarifaEncuadernacionLinea = $this->model->find($id); - if ($tarifaEncuadernacionLinea == false) : + if ($tarifaEncuadernacionLinea == false): $message = lang('Basic.global.notFoundWithIdErr', [mb_strtolower(lang('TarifaEncuadernacionLineas.tarifaencuadernacionLinea')), $id]); return $this->redirect2listView('sweet-error', $message); endif; - - if ($this->request->getPost()) : + + if ($this->request->getPost()): $nullIfEmpty = true; // !(phpversion() >= '8.1'); @@ -156,10 +157,10 @@ class Tarifaencuadernacionlineas extends \App\Controllers\BaseResourceController $sanitizedData = $this->sanitized($postData, $nullIfEmpty); $noException = true; - if ($successfulResult = $this->canValidate()) : // if ($successfulResult = $this->validate($this->formValidationRules) ) : + if ($successfulResult = $this->canValidate()): // if ($successfulResult = $this->validate($this->formValidationRules) ) : - if ($this->canValidate()) : + if ($this->canValidate()): try { $successfulResult = $this->model->skipValidation(true)->update($id, $sanitizedData); } catch (\Exception $e) { @@ -176,12 +177,12 @@ class Tarifaencuadernacionlineas extends \App\Controllers\BaseResourceController $thenRedirect = false; endif; - if ($noException && $successfulResult) : + if ($noException && $successfulResult): $id = $tarifaEncuadernacionLinea->id ?? $id; $message = lang('Basic.global.updateSuccess', [lang('Basic.global.record')]) . '.'; - if ($thenRedirect) : - if (!empty($this->indexRoute)) : + if ($thenRedirect): + if (!empty($this->indexRoute)): return redirect()->to(route_to($this->indexRoute))->with('sweet-success', $message); else: return $this->redirect2listView('sweet-success', $message); @@ -214,45 +215,90 @@ class Tarifaencuadernacionlineas extends \App\Controllers\BaseResourceController $response = Editor::inst($db, 'tarifa_encuadernacion_lineas') ->fields( Field::inst('paginas_libro_min') - ->validator('Validate::numeric', array( - 'message' => lang('TarifaAcabadoLineas.validation.paginas_libro_min.decimal')) + ->validator( + 'Validate::numeric', + array( + 'message' => lang('TarifaAcabadoLineas.validation.paginas_libro_min.decimal') + ) ) - ->validator('Validate::notEmpty', array( - 'message' => lang('TarifaAcabadoLineas.validation.paginas_libro_min.required')) + ->validator( + 'Validate::notEmpty', + array( + 'message' => lang('TarifaAcabadoLineas.validation.paginas_libro_min.required') + ) ), Field::inst('paginas_libro_max') - ->validator('Validate::numeric', array( - 'message' => lang('TarifaAcabadoLineas.validation.paginas_libro_max.decimal')) + ->validator( + 'Validate::numeric', + array( + 'message' => lang('TarifaAcabadoLineas.validation.paginas_libro_max.decimal') + ) ) - ->validator('Validate::notEmpty', array( - 'message' => lang('TarifaAcabadoLineas.validation.paginas_libro_max.required')) + ->validator( + 'Validate::notEmpty', + array( + 'message' => lang('TarifaAcabadoLineas.validation.paginas_libro_max.required') + ) ), Field::inst('precio_min') - ->getFormatter( 'Format::toDecimalChar')->setFormatter( 'Format::fromDecimalChar') - ->validator('Validate::numeric', array( + ->getFormatter('Format::toDecimalChar')->setFormatter('Format::fromDecimalChar') + ->validator( + 'Validate::numeric', + array( "decimal" => ',', - 'message' => lang('TarifaAcabadoLineas.validation.precio_min.decimal')) + 'message' => lang('TarifaAcabadoLineas.validation.precio_min.decimal') + ) ) - ->validator('Validate::notEmpty', array( - 'message' => lang('TarifaAcabadoLineas.validation.precio_min.required')) + ->validator( + 'Validate::notEmpty', + array( + 'message' => lang('TarifaAcabadoLineas.validation.precio_min.required') + ) ), Field::inst('precio_max') - ->getFormatter( 'Format::toDecimalChar')->setFormatter( 'Format::fromDecimalChar') - ->validator('Validate::numeric', array( + ->getFormatter('Format::toDecimalChar')->setFormatter('Format::fromDecimalChar') + ->validator( + 'Validate::numeric', + array( "decimal" => ',', - 'message' => lang('TarifaAcabadoLineas.validation.precio_max.decimal')) + 'message' => lang('TarifaAcabadoLineas.validation.precio_max.decimal') + ) ) - ->validator('Validate::notEmpty', array( - 'message' => lang('TarifaAcabadoLineas.validation.precio_max.required')) + ->validator( + 'Validate::notEmpty', + array( + 'message' => lang('TarifaAcabadoLineas.validation.precio_max.required') + ) + ), + Field::inst('total_min') + ->getFormatter('Format::toDecimalChar')->setFormatter('Format::fromDecimalChar') + ->validator( + 'Validate::numeric', + array( + "decimal" => ',', + 'message' => lang('TarifaEncuadernacionTiradas.validation.tirada_min.decimal') + ) + ) + ->validator( + 'Validate::notEmpty', + array( + 'message' => lang('TarifaEncuadernacionTiradas.validation.tirada_min.required') + ) ), Field::inst('margen') - ->getFormatter( 'Format::toDecimalChar')->setFormatter( 'Format::fromDecimalChar') - ->validator('Validate::numeric', array( + ->getFormatter('Format::toDecimalChar')->setFormatter('Format::fromDecimalChar') + ->validator( + 'Validate::numeric', + array( "decimal" => ',', - 'message' => lang('TarifaAcabadoLineas.validation.margen.decimal')) + 'message' => lang('TarifaAcabadoLineas.validation.margen.decimal') + ) ) - ->validator('Validate::notEmpty', array( - 'message' => lang('TarifaAcabadoLineas.validation.margen.required')) + ->validator( + 'Validate::notEmpty', + array( + 'message' => lang('TarifaAcabadoLineas.validation.margen.required') + ) ), Field::inst('tirada_encuadernacion_id'), Field::inst('user_created_id'), @@ -322,10 +368,10 @@ class Tarifaencuadernacionlineas extends \App\Controllers\BaseResourceController if ($this->request->isAJAX()) { $reqData = $this->request->getPost(); - + $cleandatatable = $reqData['cleandatatable'] ?? 0; - - if($cleandatatable){ + + if ($cleandatatable) { $tarifa_encuadernacion_id = $reqData['tarifa_encuadernacion_id'] ?? -1; @@ -338,11 +384,9 @@ class Tarifaencuadernacionlineas extends \App\Controllers\BaseResourceController $csrfTokenName => $newTokenHash ]; return $this->respond($data); - - } - else{ - + } else { + 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); diff --git a/ci4/app/Controllers/Tarifas/Tarifaencuadernacionlineashoras.php b/ci4/app/Controllers/Tarifas/Tarifaencuadernacionlineashoras.php index 7b306ebb..c3410e12 100755 --- a/ci4/app/Controllers/Tarifas/Tarifaencuadernacionlineashoras.php +++ b/ci4/app/Controllers/Tarifas/Tarifaencuadernacionlineashoras.php @@ -1,4 +1,5 @@ -request->getPost()) : + + if ($this->request->getPost()): $nullIfEmpty = true; // !(phpversion() >= '8.1'); @@ -82,10 +83,10 @@ class Tarifaencuadernacionlineashoras extends \App\Controllers\BaseResourceContr $sanitizedData = $this->sanitized($postData, $nullIfEmpty); $noException = true; - if ($successfulResult = $this->canValidate()) : // if ($successfulResult = $this->validate($this->formValidationRules) ) : + if ($successfulResult = $this->canValidate()): // if ($successfulResult = $this->validate($this->formValidationRules) ) : - if ($this->canValidate()) : + if ($this->canValidate()): try { $successfulResult = $this->model->skipValidation(true)->save($sanitizedData); } catch (\Exception $e) { @@ -99,14 +100,14 @@ class Tarifaencuadernacionlineashoras extends \App\Controllers\BaseResourceContr $thenRedirect = true; // Change this to false if you want your user to stay on the form after submission endif; - if ($noException && $successfulResult) : + if ($noException && $successfulResult): $id = $this->model->db->insertID(); $message = lang('Basic.global.saveSuccess', [lang('Basic.global.record')]) . '.'; - if ($thenRedirect) : - if (!empty($this->indexRoute)) : + if ($thenRedirect): + if (!empty($this->indexRoute)): return redirect()->to(route_to($this->indexRoute))->with('sweet-success', $message); else: return $this->redirect2listView('sweet-success', $message); @@ -134,20 +135,20 @@ class Tarifaencuadernacionlineashoras extends \App\Controllers\BaseResourceContr public function edit($requestedId = null) { - if ($requestedId == null) : + if ($requestedId == null): return $this->redirect2listView(); endif; $id = filter_var($requestedId, FILTER_SANITIZE_URL); $tarifaEncuadernacionLinea = $this->model->find($id); - if ($tarifaEncuadernacionLinea == false) : + if ($tarifaEncuadernacionLinea == false): $message = lang('Basic.global.notFoundWithIdErr', [mb_strtolower(lang('TarifaEncuadernacionLineas.tarifaencuadernacionLinea')), $id]); return $this->redirect2listView('sweet-error', $message); endif; - - if ($this->request->getPost()) : + + if ($this->request->getPost()): $nullIfEmpty = true; // !(phpversion() >= '8.1'); @@ -156,10 +157,10 @@ class Tarifaencuadernacionlineashoras extends \App\Controllers\BaseResourceContr $sanitizedData = $this->sanitized($postData, $nullIfEmpty); $noException = true; - if ($successfulResult = $this->canValidate()) : // if ($successfulResult = $this->validate($this->formValidationRules) ) : + if ($successfulResult = $this->canValidate()): // if ($successfulResult = $this->validate($this->formValidationRules) ) : - if ($this->canValidate()) : + if ($this->canValidate()): try { $successfulResult = $this->model->skipValidation(true)->update($id, $sanitizedData); } catch (\Exception $e) { @@ -176,12 +177,12 @@ class Tarifaencuadernacionlineashoras extends \App\Controllers\BaseResourceContr $thenRedirect = false; endif; - if ($noException && $successfulResult) : + if ($noException && $successfulResult): $id = $tarifaEncuadernacionLinea->id ?? $id; $message = lang('Basic.global.updateSuccess', [lang('Basic.global.record')]) . '.'; - if ($thenRedirect) : - if (!empty($this->indexRoute)) : + if ($thenRedirect): + if (!empty($this->indexRoute)): return redirect()->to(route_to($this->indexRoute))->with('sweet-success', $message); else: return $this->redirect2listView('sweet-success', $message); @@ -214,40 +215,79 @@ class Tarifaencuadernacionlineashoras extends \App\Controllers\BaseResourceContr $response = Editor::inst($db, 'tarifa_encuadernacion_lineas_horas') ->fields( Field::inst('tiempo_min') - ->getFormatter( 'Format::toDecimalChar')->setFormatter( 'Format::fromDecimalChar') - ->validator('Validate::numeric', array( + ->getFormatter('Format::toDecimalChar')->setFormatter('Format::fromDecimalChar') + ->validator( + 'Validate::numeric', + array( "decimal" => ',', - 'message' => lang('TarifaAcabadoLineas.validation.paginas_libro_min.decimal')) + 'message' => lang('TarifaAcabadoLineas.validation.paginas_libro_min.decimal') + ) ) - ->validator('Validate::notEmpty', array( - 'message' => lang('TarifaAcabadoLineas.validation.paginas_libro_min.required')) + ->validator( + 'Validate::notEmpty', + array( + 'message' => lang('TarifaAcabadoLineas.validation.paginas_libro_min.required') + ) ), Field::inst('tiempo_max') - ->getFormatter( 'Format::toDecimalChar')->setFormatter( 'Format::fromDecimalChar') - ->validator('Validate::numeric', array( + ->getFormatter('Format::toDecimalChar')->setFormatter('Format::fromDecimalChar') + ->validator( + 'Validate::numeric', + array( "decimal" => ',', - 'message' => lang('TarifaAcabadoLineas.validation.paginas_libro_max.decimal')) + 'message' => lang('TarifaAcabadoLineas.validation.paginas_libro_max.decimal') + ) ) - ->validator('Validate::notEmpty', array( - 'message' => lang('TarifaAcabadoLineas.validation.paginas_libro_max.required')) + ->validator( + 'Validate::notEmpty', + array( + 'message' => lang('TarifaAcabadoLineas.validation.paginas_libro_max.required') + ) ), Field::inst('precio_hora') - ->getFormatter( 'Format::toDecimalChar')->setFormatter( 'Format::fromDecimalChar') - ->validator('Validate::numeric', array( + ->getFormatter('Format::toDecimalChar')->setFormatter('Format::fromDecimalChar') + ->validator( + 'Validate::numeric', + array( "decimal" => ',', - 'message' => lang('TarifaAcabadoLineas.validation.precio_min.decimal')) + 'message' => lang('TarifaAcabadoLineas.validation.precio_min.decimal') + ) ) - ->validator('Validate::notEmpty', array( - 'message' => lang('TarifaAcabadoLineas.validation.precio_min.required')) + ->validator( + 'Validate::notEmpty', + array( + 'message' => lang('TarifaAcabadoLineas.validation.precio_min.required') + ) + ), + Field::inst('total_min') + ->getFormatter('Format::toDecimalChar')->setFormatter('Format::fromDecimalChar') + ->validator( + 'Validate::numeric', + array( + "decimal" => ',', + 'message' => lang('TarifaEncuadernacionTiradas.validation.tirada_min.decimal') + ) + ) + ->validator( + 'Validate::notEmpty', + array( + 'message' => lang('TarifaEncuadernacionTiradas.validation.tirada_min.required') + ) ), Field::inst('margen') - ->getFormatter( 'Format::toDecimalChar')->setFormatter( 'Format::fromDecimalChar') - ->validator('Validate::numeric', array( + ->getFormatter('Format::toDecimalChar')->setFormatter('Format::fromDecimalChar') + ->validator( + 'Validate::numeric', + array( "decimal" => ',', - 'message' => lang('TarifaAcabadoLineas.validation.margen.decimal')) + 'message' => lang('TarifaAcabadoLineas.validation.margen.decimal') + ) ) - ->validator('Validate::notEmpty', array( - 'message' => lang('TarifaAcabadoLineas.validation.margen.required')) + ->validator( + 'Validate::notEmpty', + array( + 'message' => lang('TarifaAcabadoLineas.validation.margen.required') + ) ), Field::inst('tirada_encuadernacion_id'), Field::inst('user_created_id'), @@ -314,10 +354,10 @@ class Tarifaencuadernacionlineashoras extends \App\Controllers\BaseResourceContr { if ($this->request->isAJAX()) { $reqData = $this->request->getPost(); - + $cleandatatable = $reqData['cleandatatable'] ?? 0; - - if($cleandatatable){ + + if ($cleandatatable) { $tarifa_encuadernacion_id = $reqData['tarifa_encuadernacion_id'] ?? -1; @@ -330,9 +370,8 @@ class Tarifaencuadernacionlineashoras extends \App\Controllers\BaseResourceContr $csrfTokenName => $newTokenHash ]; return $this->respond($data); - - } - else{ + + } else { 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); diff --git a/ci4/app/Controllers/Tarifas/Tarifaencuadernaciontiradas.php b/ci4/app/Controllers/Tarifas/Tarifaencuadernaciontiradas.php index d67b6565..4ad0710c 100755 --- a/ci4/app/Controllers/Tarifas/Tarifaencuadernaciontiradas.php +++ b/ci4/app/Controllers/Tarifas/Tarifaencuadernaciontiradas.php @@ -126,15 +126,6 @@ class Tarifaencuadernaciontiradas extends \App\Controllers\BaseResourceControlle ->validator('Validate::notEmpty', array( 'message' => lang('TarifaEncuadernacionTiradas.validation.tirada_min.required')) ), - Field::inst('precio_min') - ->getFormatter( 'Format::toDecimalChar')->setFormatter( 'Format::fromDecimalChar') - ->validator('Validate::numeric', array( - "decimal" => ',', - 'message' => lang('TarifaEncuadernacionTiradas.validation.tirada_min.decimal')) - ) - ->validator('Validate::notEmpty', array( - 'message' => lang('TarifaEncuadernacionTiradas.validation.tirada_min.required')) - ), Field::inst('proveedor_id') ->validator('Validate::notEmpty', array( 'message' => lang('TarifaEncuadernacionTiradas.validation.tirada_max.required')) diff --git a/ci4/app/Entities/Tarifas/TarifaEncuadernacionLinea.php b/ci4/app/Entities/Tarifas/TarifaEncuadernacionLinea.php index be10cf9c..6a72e00c 100755 --- a/ci4/app/Entities/Tarifas/TarifaEncuadernacionLinea.php +++ b/ci4/app/Entities/Tarifas/TarifaEncuadernacionLinea.php @@ -15,6 +15,7 @@ class TarifaEncuadernacionLinea extends \CodeIgniter\Entity\Entity "precio_max" => 0, "tirada_min" => 0, "tirada_max" => 0, + "total_min" => 0, "margen" => 0, "user_created_id" => 0, "user_updated_id" => 0, @@ -31,6 +32,7 @@ class TarifaEncuadernacionLinea extends \CodeIgniter\Entity\Entity "precio_max" => "float", "tirada_min" => "float", "tirada_max" => "float", + "total_min" => "float", "margen" => "float", "user_created_id" => "int", "user_updated_id" => "int", diff --git a/ci4/app/Entities/Tarifas/TarifaEncuadernacionLineaHoras.php b/ci4/app/Entities/Tarifas/TarifaEncuadernacionLineaHoras.php index 2f5d6f0a..23a93e1d 100755 --- a/ci4/app/Entities/Tarifas/TarifaEncuadernacionLineaHoras.php +++ b/ci4/app/Entities/Tarifas/TarifaEncuadernacionLineaHoras.php @@ -11,6 +11,7 @@ class TarifaEncuadernacionLineaHoras extends \CodeIgniter\Entity\Entity "tiempo_min" => 0, "tiempo_max" => 0, "precio_hora" => 0, + "total_min" => 0, "margen" => 0, "user_created_id" => 0, "user_updated_id" => 0, @@ -22,6 +23,7 @@ class TarifaEncuadernacionLineaHoras extends \CodeIgniter\Entity\Entity "tirada_encuadernacion_id" => "int", "tiempo_min" => "float", "tiempo_max" => "float", + "total_min" => "float", "precio_hora" => "float", "margen" => "float", "user_created_id" => "int", diff --git a/ci4/app/Entities/Tarifas/TarifaEncuadernacionTirada.php b/ci4/app/Entities/Tarifas/TarifaEncuadernacionTirada.php index 1a65fe07..91f35604 100755 --- a/ci4/app/Entities/Tarifas/TarifaEncuadernacionTirada.php +++ b/ci4/app/Entities/Tarifas/TarifaEncuadernacionTirada.php @@ -11,7 +11,6 @@ class TarifaEncuadernacionTirada extends \CodeIgniter\Entity\Entity "tirada_min" => 0, "tirada_max" => 0, "proveedor_id" => 0, - "precio_min" => 0, "importe_fijo" => 0, "user_created_id" => 0, "user_updated_id" => 0, @@ -24,7 +23,6 @@ class TarifaEncuadernacionTirada extends \CodeIgniter\Entity\Entity "tirada_min" => "float", "tirada_max" => "float", "proveedor_id" => "int", - "precio_min" => "float", "importe_fijo" => "float", "user_created_id" => "int", "user_updated_id" => "int", diff --git a/ci4/app/Models/Presupuestos/PresupuestoEncuadernacionesModel.php b/ci4/app/Models/Presupuestos/PresupuestoEncuadernacionesModel.php index f8af0109..956bbe77 100755 --- a/ci4/app/Models/Presupuestos/PresupuestoEncuadernacionesModel.php +++ b/ci4/app/Models/Presupuestos/PresupuestoEncuadernacionesModel.php @@ -267,7 +267,15 @@ class PresupuestoEncuadernacionesModel extends \App\Models\BaseModel $precio_total = floatval(1.0* $tarifa_proveedor->precio_hora* $tiempo) * (1+$tarifa_value[0]->margen/100.0); if (!$POD){ $precio_total += floatval($tarifa_proveedor->tarifa_importe_fijo); - } + } + + $tarifa_precio_min = floatval($tarifa_proveedor->tarifa_precio_min); + + if($tarifa_precio_min > $precio_total){ + $total = $total-($total * $margen/100.0); + $margen = round(100.0 * (floatval($$tarifa_precio_min) - $total) / floatval($$tarifa_precio_min), 0); + $total = floatval($$tarifa_precio_min); + } $result_data[0] = floatval($precio_total / $tirada); // Precio/unidad $result_data[1] = $precio_total; @@ -323,11 +331,12 @@ class PresupuestoEncuadernacionesModel extends \App\Models\BaseModel $total = $precio_unidad * $ejemplares; $margen = floatval($tarifa->margen); + $tarifa_precio_min = floatval($tarifa->tarifa_precio_min); - if($tarifa->tarifa_precio_min > $total){ + if($tarifa_precio_min > $total){ $total = $total-($total * $margen/100.0); - $margen = round(100.0 * (floatval($tarifa->tarifa_precio_min) - $total) / floatval($tarifa->tarifa_precio_min), 0); - $total = floatval($tarifa->tarifa_precio_min); + $margen = round(100.0 * (floatval($tarifa_precio_min) - $total) / floatval($tarifa_precio_min), 0); + $total = floatval($tarifa_precio_min); $precio_unidad = round(floatval($total / $ejemplares), 2); } diff --git a/ci4/app/Models/Tarifas/TarifaEncuadernacionLineaHorasModel.php b/ci4/app/Models/Tarifas/TarifaEncuadernacionLineaHorasModel.php index 976c8ade..d2c75a73 100755 --- a/ci4/app/Models/Tarifas/TarifaEncuadernacionLineaHorasModel.php +++ b/ci4/app/Models/Tarifas/TarifaEncuadernacionLineaHorasModel.php @@ -17,7 +17,8 @@ class TarifaEncuadernacionLineaHorasModel extends \App\Models\BaseModel 1 => "t1.tiempo_min", 2 => "t1.tiempo_max", 3 => "t1.precio_hora", - 4 => "t1.margen", + 4 => "t1.total_min", + 5 => "t1.margen", ]; protected $allowedFields = [ @@ -25,6 +26,7 @@ class TarifaEncuadernacionLineaHorasModel extends \App\Models\BaseModel "tiempo_min", "tiempo_max", "precio_hora", + "total_min", "margen", "user_created_id", "is_deleted", @@ -54,6 +56,10 @@ class TarifaEncuadernacionLineaHorasModel extends \App\Models\BaseModel "label" => "TarifaEncuadernacionLineas.precioHora", "rules" => "required|decimal", ], + "total_min" => [ + "label" => "TarifaEncuadernacionLineas.precioHora", + "rules" => "required|decimal", + ], "margen" => [ "label" => "TarifaEncuadernacionLineas.margen", "rules" => "required|decimal", @@ -73,6 +79,10 @@ class TarifaEncuadernacionLineaHorasModel extends \App\Models\BaseModel "decimal" => "TarifaEncuadernacionLineas.validation.tirada_max.decimal", "required" => "TarifaEncuadernacionLineas.validation.tirada_max.required", ], + "total_min" => [ + "decimal" => "TarifaEncuadernacionLineas.validation.tirada_max.decimal", + "required" => "TarifaEncuadernacionLineas.validation.tirada_max.required", + ], "margen" => [ "decimal" => "TarifaEncuadernacionLineas.validation.margen.decimal", "required" => "TarifaEncuadernacionLineas.validation.margen.required", @@ -92,7 +102,7 @@ class TarifaEncuadernacionLineaHorasModel extends \App\Models\BaseModel ->table($this->table . " t1") ->select( "t1.id AS id, t1.tirada_encuadernacion_id AS tirada_encuadernacion_id, t1.tiempo_min AS tiempo_min, - t1.tiempo_max AS tiempo_max, t1.precio_hora AS precio_hora, t1.margen AS margen, + t1.tiempo_max AS tiempo_max, t1.precio_hora AS precio_hora, t1.total_min AS total_min, t1.margen AS margen, t2.id AS tarifa_encuadernacion" ); //JJO diff --git a/ci4/app/Models/Tarifas/TarifaEncuadernacionLineaModel.php b/ci4/app/Models/Tarifas/TarifaEncuadernacionLineaModel.php index ff1f71d1..23bb6096 100755 --- a/ci4/app/Models/Tarifas/TarifaEncuadernacionLineaModel.php +++ b/ci4/app/Models/Tarifas/TarifaEncuadernacionLineaModel.php @@ -19,6 +19,8 @@ class TarifaEncuadernacionLineaModel extends \App\Models\BaseModel 3 => "t1.paginas_libro_max", 4 => "t1.precio_min", 5 => "t1.precio_max", + 6 => "t1.total_min", + 7 => "t1.margen", ]; protected $allowedFields = [ @@ -30,6 +32,8 @@ class TarifaEncuadernacionLineaModel extends \App\Models\BaseModel "precio_max", "tirada_min", "tirada_max", + "margen", + "total_min", "user_created_id", "is_deleted", @@ -62,6 +66,10 @@ class TarifaEncuadernacionLineaModel extends \App\Models\BaseModel "label" => "TarifaEncuadernacionLineas.tiradaMin", "rules" => "required|decimal", ], + "total_min" => [ + "label" => "TarifaEncuadernacionLineas.precioMin", + "rules" => "required|decimal", + ], "paginas_libro_max" => [ "label" => "TarifaEncuadernacionLineas.paginasMax", "rules" => "required|decimal", @@ -93,6 +101,10 @@ class TarifaEncuadernacionLineaModel extends \App\Models\BaseModel "decimal" => "TarifaEncuadernacionLineas.validation.tirada_min.decimal", "required" => "TarifaEncuadernacionLineas.validation.tirada_min.required", ], + "total_min" => [ + "decimal" => "TarifaEncuadernacionLineas.validation.precio_min.decimal", + "required" => "TarifaEncuadernacionLineas.validation.precio_min.required", + ], "paginas_libro_max" => [ "decimal" => "TarifaEncuadernacionLineas.validation.paginas_libro_max.decimal", "required" => "TarifaEncuadernacionLineas.validation.paginas_libro_max.required", @@ -120,7 +132,7 @@ class TarifaEncuadernacionLineaModel extends \App\Models\BaseModel ->table($this->table . " t1") ->select( "t1.id AS id, t1.tirada_encuadernacion_id AS tirada_encuadernacion_id, t1.paginas_libro_min AS paginas_libro_min, t1.paginas_libro_max AS paginas_libro_max, t1.precio_min AS precio_min, t1.precio_max AS precio_max, t1.tirada_min AS tirada_min, - t1.tirada_max AS tirada_max, t1.margen AS margen, t2.id AS tarifa_encuadernacion, t3.id AS dimensiones_id, t3.ancho_min, t3.ancho_max, , t3.alto_min, t3.alto_max, t3.descripcion as descripcion" + t1.tirada_max AS tirada_max, t1.total_min as total_min, t1.margen AS margen, t2.id AS tarifa_encuadernacion, t3.id AS dimensiones_id, t3.ancho_min, t3.ancho_max, , t3.alto_min, t3.alto_max, t3.descripcion as descripcion" ); //JJO $builder->where('tirada_encuadernacion_id', $tirada_encuadernacion_id); @@ -190,6 +202,7 @@ class TarifaEncuadernacionLineaModel extends \App\Models\BaseModel return $builder; } + public function removeAllEncuadernacionLineasForTarifa($tarifaId = -1, $datetime = null, $delete_flag=1){ diff --git a/ci4/app/Models/Tarifas/TarifaEncuadernacionModel.php b/ci4/app/Models/Tarifas/TarifaEncuadernacionModel.php index b014f83d..7ed9fa87 100755 --- a/ci4/app/Models/Tarifas/TarifaEncuadernacionModel.php +++ b/ci4/app/Models/Tarifas/TarifaEncuadernacionModel.php @@ -125,7 +125,7 @@ class TarifaEncuadernacionModel extends \App\Models\BaseModel $builder = $this->db ->table($this->table . " t1") ->select( - "t1.id AS tarifa_enc_id, t1.nombre AS tarifa_enc_nombre, t2.precio_min AS tarifa_precio_min, t2.importe_fijo AS tarifa_importe_fijo, + "t1.id AS tarifa_enc_id, t1.nombre AS tarifa_enc_nombre, t3.total_min AS tarifa_precio_min, t2.importe_fijo AS tarifa_importe_fijo, t2.id AS tarifa_tirada_id, t2.proveedor_id AS proveedor_id, t5.nombre AS proveedor_nombre, t2.tirada_min AS tirada_min, t2.tirada_max AS tirada_max, t3.id AS tarifa_linea_id, t3.paginas_libro_min AS paginas_min, t3.paginas_libro_max AS paginas_max, t3.precio_min AS precio_min, t3.precio_max AS precio_max, t3.margen AS margen, t4.ancho_min AS ancho_min, t4.ancho_max AS ancho_max, t4.alto_min AS alto_min, t4.alto_max AS alto_max" @@ -161,7 +161,7 @@ class TarifaEncuadernacionModel extends \App\Models\BaseModel $builder = $this->db ->table($this->table . " t1") ->select( - "t1.id AS tarifa_enc_id, t1.nombre AS tarifa_enc_nombre, t2.precio_min AS tarifa_precio_min, t2.importe_fijo AS tarifa_importe_fijo, + "t1.id AS tarifa_enc_id, t1.nombre AS tarifa_enc_nombre, t3.total_min AS tarifa_precio_min, t2.importe_fijo AS tarifa_importe_fijo, t2.id AS tarifa_tirada_id, t2.proveedor_id AS proveedor_id, t5.nombre AS proveedor_nombre, t2.tirada_min AS tirada_min, t2.tirada_max AS tirada_max, t3.id AS tarifa_linea_id, t3.tiempo_min AS tiempo_min, t3.tiempo_max AS tiempo_max, t3.precio_hora AS precio_hora, t3.margen AS margen" ) diff --git a/ci4/app/Models/Tarifas/TarifaEncuadernacionTiradaModel.php b/ci4/app/Models/Tarifas/TarifaEncuadernacionTiradaModel.php index ac795645..ba1a7a28 100755 --- a/ci4/app/Models/Tarifas/TarifaEncuadernacionTiradaModel.php +++ b/ci4/app/Models/Tarifas/TarifaEncuadernacionTiradaModel.php @@ -16,7 +16,6 @@ class TarifaEncuadernacionTiradaModel extends \App\Models\BaseModel 0 => "t3.nombre", 1 => "t1.tirada_min", 2 => "t1.tirada_max", - 3 => "t1.precio_min", 4 => "t1.importe_fijo", ]; @@ -25,7 +24,6 @@ class TarifaEncuadernacionTiradaModel extends \App\Models\BaseModel "tirada_min", "tirada_max", "proveedor_id", - "precio_min", "importe_fijo", "user_created_id", "user_updated_id", @@ -53,10 +51,6 @@ class TarifaEncuadernacionTiradaModel extends \App\Models\BaseModel "label" => "TarifaEncuadernacionTiradas.tiradaMin", "rules" => "required|integer", ], - "precio_min" => [ - "label" => "Tarifaencuadernacion.precioMin", - "rules" => "required|decimal", - ], "importe_fijo" => [ "label" => "Tarifaencuadernacion.importeFijo", "rules" => "required|decimal", @@ -72,10 +66,6 @@ class TarifaEncuadernacionTiradaModel extends \App\Models\BaseModel "integer" => "TarifaEncuadernacionTiradas.validation.tirada_min.integer", "required" => "TarifaEncuadernacionTiradas.validation.tirada_min.required", ], - "precio_min" => [ - "required" => "Tarifaencuadernacion.validation.precio_min.required", - "decimal" => "Tarifaencuadernacion.validation.precio_min.decimal", - ], "importe_fijo" => [ "required" => "Tarifaencuadernacion.validation.importe_fijo.required", "decimal" => "Tarifaencuadernacion.validation.importe_fijo.decimal", @@ -95,7 +85,7 @@ class TarifaEncuadernacionTiradaModel extends \App\Models\BaseModel ->table($this->table . " t1") ->select( "t1.id AS id, t1.tarifa_encuadernacion_id AS tarifa_encuadernacion_id, - t1.precio_min AS precio_min, t1.importe_fijo AS importe_fijo, + t1.importe_fijo AS importe_fijo, t1.tirada_min AS tirada_min, t1.tirada_max AS tirada_max, t3.nombre AS proveedor, t3.id AS proveedor_id, t2.id AS tarifa_encuadernacion" ); diff --git a/ci4/app/Views/themes/vuexy/form/presupuestos/cliente/items/_buttons.php b/ci4/app/Views/themes/vuexy/form/presupuestos/cliente/items/_buttons.php index a2ab40c9..aad9101e 100644 --- a/ci4/app/Views/themes/vuexy/form/presupuestos/cliente/items/_buttons.php +++ b/ci4/app/Views/themes/vuexy/form/presupuestos/cliente/items/_buttons.php @@ -1,30 +1,36 @@
-
+
-
-
- +
+
+ +
+ +
+ +
+ +
+
+ +
+ +
+ +
+ + + +
+ +
+ +
+ +
+ +
+
- -
-
- -
-
- -
-
- -
-
- -
- -
- -
-
- -
\ No newline at end of file diff --git a/ci4/app/Views/themes/vuexy/form/presupuestos/cliente/items/_datosGenerales.php b/ci4/app/Views/themes/vuexy/form/presupuestos/cliente/items/_datosGenerales.php index 4640397b..d3e013f8 100644 --- a/ci4/app/Views/themes/vuexy/form/presupuestos/cliente/items/_datosGenerales.php +++ b/ci4/app/Views/themes/vuexy/form/presupuestos/cliente/items/_datosGenerales.php @@ -16,14 +16,15 @@ - +
@@ -32,35 +33,44 @@ - +
- -
+ +
-
- user()->inGroup('cliente-admin') || auth()->user()->inGroup('cliente-editor'))? " hidden" : "" ?> + class="calcular-presupuesto form-check-input" type="checkbox" id="excluirRotativa" name="excluir_rotativa" value="1"> - +
diff --git a/ci4/app/Views/themes/vuexy/form/presupuestos/cliente/items/_resumen.php b/ci4/app/Views/themes/vuexy/form/presupuestos/cliente/items/_resumen.php index 1083ef86..7cdfa40f 100644 --- a/ci4/app/Views/themes/vuexy/form/presupuestos/cliente/items/_resumen.php +++ b/ci4/app/Views/themes/vuexy/form/presupuestos/cliente/items/_resumen.php @@ -182,4 +182,25 @@ + + +
+

Ficheros

+
+
+
+ Arrastre aquí los ficheros o haga click +
+
+ +
+
+
+ +
+ + \ No newline at end of file diff --git a/ci4/app/Views/themes/vuexy/form/presupuestos/cliente/viewPresupuestoclienteForm.php b/ci4/app/Views/themes/vuexy/form/presupuestos/cliente/viewPresupuestoclienteForm.php index fee3258d..e66e65b2 100644 --- a/ci4/app/Views/themes/vuexy/form/presupuestos/cliente/viewPresupuestoclienteForm.php +++ b/ci4/app/Views/themes/vuexy/form/presupuestos/cliente/viewPresupuestoclienteForm.php @@ -12,7 +12,7 @@
- +

@@ -29,7 +29,7 @@
-
+
class="step active titulos-menu" data-target="#datos-generales">
-
+
class="step titulos-menu" data-target="#interior-libro">
-
+
class="step titulos-menu" data-target="#cubierta-libro">
-
+
class="step titulos-menu" data-target="#direcciones-libro">
-
+