mirror of
https://git.imnavajas.es/jjimenez/safekat.git
synced 2025-07-25 22:52:08 +00:00
terminados servicios extra
This commit is contained in:
@ -57,10 +57,10 @@ class ImprimelibrosApi extends ResourceController
|
||||
'precios' => $response['precio_u']
|
||||
]
|
||||
];
|
||||
} else {
|
||||
}else{
|
||||
$response = [
|
||||
'status' => 400,
|
||||
'error' => $response
|
||||
'error' => $response
|
||||
];
|
||||
|
||||
}
|
||||
@ -75,42 +75,23 @@ class ImprimelibrosApi extends ResourceController
|
||||
// Access the entire POST data
|
||||
$post_data = $this->request->getJSON(true);
|
||||
|
||||
//return $this->respond(var_dump($post_data));
|
||||
|
||||
// Instancia de presupuesto cliente
|
||||
$presupuestocliente = new Presupuestocliente();
|
||||
try {
|
||||
$response = $presupuestocliente->guardar($post_data);
|
||||
$response = $presupuestocliente->guardar($post_data);
|
||||
|
||||
// DEBUG LINE
|
||||
//return $this->respond($response);
|
||||
return $this->respond($response);
|
||||
|
||||
if (!isset($response['sk_id'])) {
|
||||
return $this->respond([
|
||||
'status' => 400,
|
||||
'error' => 'Missing sk_id',
|
||||
'message' => 'El identificador sk_id es requerido pero no se recibió.'
|
||||
], 400);
|
||||
}
|
||||
|
||||
$response = [
|
||||
'status' => 200,
|
||||
'error' => null,
|
||||
'data' => [
|
||||
'sk_id' => $response['sk_id'],
|
||||
'sk_url' => $response['sk_url'] ?? null
|
||||
]
|
||||
];
|
||||
|
||||
return $this->respond($response);
|
||||
|
||||
} catch (\Exception $e) {
|
||||
|
||||
return $this->respond([
|
||||
'status' => 500,
|
||||
'error' => 'Server error',
|
||||
'message' => 'Error inesperado durante el procesado'
|
||||
]);
|
||||
|
||||
}
|
||||
$response = [
|
||||
'status' => 200,
|
||||
'error' => null,
|
||||
'data' => [
|
||||
'tiradas' => $response['tiradas'],
|
||||
'precios' => $response['precio_u']
|
||||
]
|
||||
];
|
||||
return $this->respond($response);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -181,6 +181,8 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
|
||||
$this->viewData['state'] = intval($presupuestoEntity->estado_id);
|
||||
$this->viewData['boxTitle'] = lang('Basic.global.edit2') . ' ' . $this->viewData['pageTitle'] . ' ' . lang('Basic.global.edit3');
|
||||
|
||||
$this->viewData['serviciosExtra'] = $this->getServiciosExtra();
|
||||
|
||||
return $this->displayForm(__METHOD__, $id);
|
||||
} // end function edit(...)
|
||||
|
||||
@ -1243,6 +1245,37 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
|
||||
$borrar_antes = true;
|
||||
}
|
||||
|
||||
$servicio_ferro = (object) [
|
||||
'nombre' => 'ferro',
|
||||
'id' => model('App\Models\Configuracion\ConfigVariableModel')->getVariable('id_servicio_ferro')->value
|
||||
];
|
||||
|
||||
$servicio_ferro_digital = (object) [
|
||||
'nombre' => 'ferro_digital',
|
||||
'id' => model('App\Models\Configuracion\ConfigVariableModel')->getVariable('id_servicio_ferro_digital')->value
|
||||
];
|
||||
$servicio_prototipo = (object) [
|
||||
'nombre' => 'prototipo',
|
||||
'id' => model('App\Models\Configuracion\ConfigVariableModel')->getVariable('id_servicio_prototipo')->value
|
||||
];
|
||||
|
||||
|
||||
if(isset($resultado_presupuesto['values']['servicios_extra']))
|
||||
{
|
||||
foreach ($resultado_presupuesto['values']['servicios_extra'] as $servicio) {
|
||||
if($servicio->tarifa_id == $servicio_ferro->id){
|
||||
$ferro = 1;
|
||||
}
|
||||
else if($servicio->tarifa_id == $servicio_ferro_digital->id){
|
||||
$ferroDigital = 1;
|
||||
}
|
||||
else if($servicio->tarifa_id == $servicio_prototipo->id){
|
||||
$prototipo = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$datos_presupuesto['prototipo'] = $prototipo;
|
||||
$datos_presupuesto['ferro'] = $ferro;
|
||||
$datos_presupuesto['ferro_digital'] = $ferroDigital;
|
||||
@ -1354,14 +1387,7 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
|
||||
foreach ($resultado_presupuesto['values']['serviciosDefecto']['manipulado'] as $servicio) {
|
||||
$this->guardarServicio($id, $servicio, 'manipulado');
|
||||
}
|
||||
$servicio_ferro = (object) [
|
||||
'nombre' => 'ferro',
|
||||
'id' => model('App\Models\Configuracion\ConfigVariableModel')->getVariable('id_servicio_ferro')->value
|
||||
];
|
||||
$servicio_prototipo = (object) [
|
||||
'nombre' => 'prototipo',
|
||||
'id' => model('App\Models\Configuracion\ConfigVariableModel')->getVariable('id_servicio_prototipo')->value
|
||||
];
|
||||
|
||||
$servicio_retractilado = (object) [
|
||||
'nombre' => 'retractilado',
|
||||
'id' => model('App\Models\Configuracion\ConfigVariableModel')->getVariable('id_servicio_retractilado')->value
|
||||
@ -1399,6 +1425,11 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
|
||||
'id' => model('App\Models\Configuracion\ConfigVariableModel')->getVariable('id_servicio_plegado_exceso_solapas_faja')->value
|
||||
];
|
||||
|
||||
// Funcionalidad servicios extra
|
||||
foreach ($resultado_presupuesto['values']['servicios_extra'] as $servicio) {
|
||||
$this->guardarServicio($id, $servicio, 'extra');
|
||||
}
|
||||
|
||||
foreach ($resultado_presupuesto['values']['servicios_automaticos'] as $servicio) {
|
||||
if ($servicio->tarifa_id == $servicio_retractilado->id || $servicio->tarifa_id == $servicio_retractilado5->id) {
|
||||
// Servicios acabado
|
||||
@ -1501,6 +1532,10 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
|
||||
$data['datosGenerales']['retractilado'] = $presupuesto->retractilado;
|
||||
$data['datosGenerales']['retractilado5'] = $presupuesto->retractilado5;
|
||||
|
||||
$modelServiciosExtra = new PresupuestoServiciosExtraModel();
|
||||
$data['datosGenerales']['serviciosExtra'] = $modelServiciosExtra
|
||||
->where('presupuesto_id', $id)->findColumn('tarifa_extra_id');
|
||||
|
||||
$datos_papel = $this->obtenerDatosPapel($presupuesto->id);
|
||||
if (array_key_exists('interior', $datos_papel)) {
|
||||
$data['interior'] = $datos_papel['interior'];
|
||||
@ -1783,11 +1818,15 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
|
||||
|
||||
$data = [
|
||||
'presupuesto_id' => $presupuestoId,
|
||||
'tarifa_extra_id' => $servicio->tarifa_id,
|
||||
'tarifa_extra_id' => intval($servicio->tarifa_id),
|
||||
'precio' => round($servicio->precio, 2),
|
||||
'margen' => $servicio->margen,
|
||||
'margen' => floatval($servicio->margen),
|
||||
];
|
||||
$model->insert($data);
|
||||
$errors = null;
|
||||
|
||||
if (!$model->insert($data)) {
|
||||
$errors = $model->errors();
|
||||
}
|
||||
} else if ($tipo == 'acabado') {
|
||||
$model = new PresupuestoAcabadosModel();
|
||||
|
||||
@ -2637,13 +2676,13 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
|
||||
|
||||
if ($datos_entrada['servicios'] !== []) {
|
||||
|
||||
if ($datos_entrada['servicios']['retractilado']) // acabado
|
||||
if (isset($datos_entrada['servicios']['retractilado']) && $datos_entrada['servicios']['retractilado']) // acabado
|
||||
array_push($servicios, $servicio_retractilado);
|
||||
if ($datos_entrada['servicios']['retractilado5']) // acabado
|
||||
if (isset($datos_entrada['servicios']['retractilado5']) && $datos_entrada['servicios']['retractilado5']) // acabado
|
||||
array_push($servicios, $servicio_retractilado5);
|
||||
if ($datos_entrada['servicios']['prototipo']) // extra
|
||||
if (isset($datos_entrada['servicios']['prototipo']) && $datos_entrada['servicios']['prototipo']) // extra
|
||||
array_push($servicios, $servicio_prototipo);
|
||||
if ($datos_entrada['servicios']['ferro']) // extra
|
||||
if (isset($datos_entrada['servicios']['ferro']) && $datos_entrada['servicios']['ferro']) // extra
|
||||
array_push($servicios, $servicio_ferro);
|
||||
if ($solapasCubierta > 0)
|
||||
array_push($servicios, $servicio_solapas_cubierta);
|
||||
@ -2758,6 +2797,46 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
|
||||
}
|
||||
}
|
||||
|
||||
$serviciosExtra = [];
|
||||
// funcionalidad para los servicios extra añadidos por el usuario
|
||||
if($datos_entrada['servicios'] !== [] && isset($datos_entrada['servicios']['serviciosExtra']) &&
|
||||
$datos_entrada['servicios']['serviciosExtra'] !== []){
|
||||
|
||||
foreach($datos_entrada['servicios']['serviciosExtra'] as $servicio){
|
||||
$resultado = PresupuestoCLienteService::getServiciosExtra([
|
||||
'tarifa_id' => intval($servicio),
|
||||
]);
|
||||
|
||||
if ($resultado[0]->precio <= 0) {
|
||||
|
||||
$errorModel = new ErrorPresupuesto();
|
||||
$errorModel->insertError(
|
||||
$datos_entrada['id'],
|
||||
auth()->user()->id,
|
||||
'No se puede obtener servicio con id ' . ((string) $servicio),
|
||||
$input_data
|
||||
);
|
||||
$return_data = [
|
||||
'errors' => (object) ([
|
||||
'status' => 1
|
||||
]),
|
||||
];
|
||||
return $return_data;
|
||||
}
|
||||
|
||||
array_push($serviciosExtra, $resultado[0]);
|
||||
|
||||
$coste_servicios += round(floatval($resultado[0]->precio), 2);
|
||||
if ($extra_info) {
|
||||
$totalServicios += round(floatval($resultado[0]->precio), 2);
|
||||
$base = round(floatval($resultado[0]->precio / (1 + $resultado[0]->margen / 100.0)), 2);
|
||||
$base = round(floatval($base / $datosPedido->tirada), 2) * $datosPedido->tirada;
|
||||
$margenServicios += round(floatval($resultado[0]->precio - $base), 2);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// Plegado de solapas grandes
|
||||
if (intval($solapasCubierta) > 0 && intval($cubierta['dimension_desarrollo']['ancho']) > 630) {
|
||||
// Servicios manipulado
|
||||
@ -2925,6 +3004,7 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
|
||||
$return_data['values']['serviciosDefecto']['encuadernacion'] = $servDefectoEnc;
|
||||
$return_data['values']['serviciosDefecto']['manipulado'] = $servDefectoMan;
|
||||
$return_data['values']['servicios_automaticos'] = $serviciosAutomaticos;
|
||||
$return_data['values']['servicios_extra'] = $serviciosExtra;
|
||||
}
|
||||
}
|
||||
|
||||
@ -3434,4 +3514,22 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
|
||||
|
||||
return [$paginasNegro, $paginasColor];
|
||||
}
|
||||
|
||||
private function getServiciosExtra(){
|
||||
|
||||
$servicios = [];
|
||||
|
||||
$model = model('App\Models\Tarifas\TarifaextraModel');
|
||||
$data = $model->where('deleted_at', null)->where('mostrar_en_presupuesto_cliente', 1)->findAll();
|
||||
|
||||
foreach ($data as $servicio) {
|
||||
$id = "service_extra_" . $servicio->id;
|
||||
array_push($servicios,
|
||||
"<input class=\"calcular-presupuesto form-check-input\" type=\"checkbox\" id=\"{$id}\"
|
||||
name=\"{$id}\" value=\"1\" data-tarifa-id=\"{$servicio->id}\" data-tarifa-tipo=\"extra\">
|
||||
<label class=\"form-check-label\" for=\"{$id}\">{$servicio->nombre}</label>");
|
||||
}
|
||||
|
||||
return $servicios;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user