mirror of
https://git.imnavajas.es/jjimenez/safekat.git
synced 2025-07-25 22:52:08 +00:00
falta guardar tiradas
This commit is contained in:
@ -17,6 +17,8 @@ use App\Models\Presupuestos\PresupuestoServiciosExtraModel;
|
||||
use App\Services\PresupuestoClienteService;
|
||||
use Exception;
|
||||
|
||||
use function PHPUnit\Framework\containsOnly;
|
||||
|
||||
class Presupuestocliente extends \App\Controllers\BaseResourceController
|
||||
{
|
||||
protected $modelName = "PresupuestoModel";
|
||||
@ -669,7 +671,7 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
|
||||
'servicios' => $servicios,
|
||||
);
|
||||
|
||||
$return_data = $this->calcular_presupuesto($datos_presupuesto);
|
||||
$return_data = $this->calcular_presupuesto($datos_presupuesto, true); //TRUE FOR DEBUG
|
||||
array_merge($return_data, [$csrfTokenName => $newTokenHash]);
|
||||
|
||||
return $this->respond($return_data);
|
||||
@ -713,41 +715,8 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
|
||||
$peso = $reqData['peso'] ?? 0;
|
||||
$unidades = $reqData['unidades'] ?? 0;
|
||||
$entregaPieCalle = $reqData['entregaPieCalle'] ?? 0;
|
||||
$model = model('App\Models\Clientes\ClienteDireccionesModel');
|
||||
$data = $model->getDireccion($direccionId);
|
||||
|
||||
$modelTarifaEnvio = model('App\Models\Tarifas\TarifaEnvioModel');
|
||||
$coste = 0;
|
||||
if ($data > 0) {
|
||||
$tarifas_envio = $modelTarifaEnvio->getTarifaEnvio($data[0]->pais_id, $peso, $unidades, $entregaPieCalle ? 'palets' : 'cajas');
|
||||
for ($i = 0; $i < count($tarifas_envio); $i++) {
|
||||
if ($peso > $tarifas_envio[$i]->peso_max) {
|
||||
$tarifas_envio[$i]->precio = number_format($tarifas_envio[$i]->peso_min + ($peso - $tarifas_envio[$i]->peso_min) * $tarifas_envio[$i]->precio_adicional, 2);
|
||||
}
|
||||
// si no se calcula linealmente
|
||||
else {
|
||||
$m = (($tarifas_envio[$i]->precio_max - $tarifas_envio[$i]->precio_min) / ($tarifas_envio[$i]->peso_max - $tarifas_envio[$i]->peso_min));
|
||||
$b = $tarifas_envio[$i]->precio_max - $m * $tarifas_envio[$i]->peso_max;
|
||||
$tarifas_envio[$i]->precio = number_format($m * $peso + $b, 2);
|
||||
}
|
||||
$tarifas_envio[$i]->margen = $tarifas_envio[$i]->margen;
|
||||
}
|
||||
|
||||
if (count($tarifas_envio) > 1) {
|
||||
$tarifa_final = array_reduce($tarifas_envio, function ($previous, $current) {
|
||||
return $current->precio < $previous->precio ? $current : $previous;
|
||||
});
|
||||
$coste = $tarifa_final->precio;
|
||||
} else {
|
||||
if (count($tarifas_envio) > 0)
|
||||
$coste = $tarifas_envio[0]->precio;
|
||||
}
|
||||
}
|
||||
if (count($data) > 0) {
|
||||
$data[0]->coste = $coste;
|
||||
$data[0]->tipo = $entregaPieCalle ? 'palets' : 'cajas';
|
||||
}
|
||||
|
||||
$data = $this->calcular_coste_envio($direccionId, $peso, $unidades, $entregaPieCalle);
|
||||
|
||||
return $this->respond([
|
||||
'data' => $data,
|
||||
@ -786,7 +755,6 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
|
||||
|
||||
$menu = $model->getMenuDirecciones($data['cliente_id']);
|
||||
|
||||
|
||||
return $this->respond([
|
||||
'data' => $menu,
|
||||
$csrfTokenName => $newTokenHash
|
||||
@ -809,6 +777,7 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
|
||||
|
||||
$tirada = $reqData['datos_libro']['tirada'] ?? 0;
|
||||
$selected_tirada = $reqData['tirada'] ?? 0;
|
||||
$peso_libro = $reqData['peso'] ?? 0;
|
||||
$tamanio = $reqData['datos_libro']['tamanio'];
|
||||
$tipo_impresion_id = $this->getTipoImpresion($reqData['datos_libro']['tipo'], $reqData['datos_libro']['tapa']);
|
||||
$cliente_id = $reqData['datos_libro']['clienteId'] ?? -1;
|
||||
@ -842,6 +811,7 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
|
||||
$datos_guardas = $reqData['datos_libro']['guardas'] ?? 0;
|
||||
|
||||
$servicios = $reqData['datos_libro']['servicios'] ?? [];
|
||||
$iva_reducido = $reqData['iva_reducido'];
|
||||
|
||||
$datos_presupuesto = array(
|
||||
'tirada' => $tirada,
|
||||
@ -890,14 +860,100 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
|
||||
]);
|
||||
}
|
||||
|
||||
//$model_presupuesto = new PresupuestoModel();
|
||||
//$id = $model_presupuesto->insertarPresupuestoCliente($selected_tirada, $datos_presupuesto, $datosCabecera, $resultado_presupuesto['info']);
|
||||
|
||||
$iva_reducido = $reqData['iva_reducido'];
|
||||
|
||||
foreach ($reqData['direcciones'] as $direccion){
|
||||
$this->guardarLineaEnvio($id, $direccion);
|
||||
for ($i=0; $i<count($tirada); $i++) {
|
||||
|
||||
$resultado_presupuesto['totales'][$i]['coste_envio'] = 0.0;
|
||||
$resultado_presupuesto['totales'][$i]['margen_envio'] = 0.0;
|
||||
|
||||
foreach ($reqData['direcciones'] as $direccion){
|
||||
|
||||
$proporcion = intval($direccion['unidades'])/$selected_tirada*100.0;
|
||||
$unidades_calculo = floor($tirada[$i] * $proporcion / 100.0);
|
||||
$peso_calculo = $peso_libro / $selected_tirada * $unidades_calculo;
|
||||
$coste_envio = $this->calcular_coste_envio(
|
||||
$direccion['id'], $peso_calculo, $unidades_calculo, $direccion['tipo']=='cajas'?0:1);
|
||||
if(count($coste_envio)> 0){
|
||||
$coste = $coste_envio[0]->coste;
|
||||
$margen = ($coste_envio[0]->coste * $coste_envio[0]->margen)/100.0;
|
||||
$coste -= $margen;
|
||||
$resultado_presupuesto['totales'][$i]['coste_envio'] += $coste;
|
||||
$resultado_presupuesto['totales'][$i]['margen_envio'] += $margen;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$model_presupuesto = new PresupuestoModel();
|
||||
$tiradas_alternativas = [];
|
||||
$resumen_totales = [];
|
||||
for ($i=0; $i<count($tirada); $i++) {
|
||||
if($tirada[$i] != $selected_tirada){
|
||||
|
||||
$coste_total = $resultado_presupuesto['totales'][$i]['totalImpresion'] + $resultado_presupuesto['totales'][$i]['totalPapel'] +
|
||||
$resultado_presupuesto['totales'][$i]['margenImpresion'] + $resultado_presupuesto['totales'][$i]['margenPapel'];
|
||||
$coste_envio = $resultado_presupuesto['totales'][$i]['coste_envio'] + $resultado_presupuesto['totales'][$i]['margen_envio'];
|
||||
$margen_total = round(($resultado_presupuesto['totales'][$i]['margenImpresion'] +
|
||||
$resultado_presupuesto['totales'][$i]['margenPapel'] +
|
||||
$resultado_presupuesto['totales'][$i]['margen_envio'])/($coste_total+$coste_envio)*100.0, 2);
|
||||
$total_pedido =round(($coste_total + $resumen_totales['totalServicios']+$resumen_totales['margenServicios'] + $coste_envio), 2);
|
||||
$precio_u = round(($coste_total + $resumen_totales['totalServicios']+$resumen_totales['margenServicios'] + $coste_envio)/$tirada[$i], 4);
|
||||
|
||||
array_push($tiradas_alternativas, (object)array(
|
||||
'tirada' => $tirada[$i],
|
||||
'coste_impresion' => round($coste_total, 2),
|
||||
'coste_envio' => $coste_envio,
|
||||
'margen' => $margen_total,
|
||||
'total_pedido' => $total_pedido,
|
||||
'precio_unidad' => $precio_u,
|
||||
));
|
||||
}
|
||||
else{
|
||||
$resumen_totales = $resultado_presupuesto['totales'][$i];
|
||||
}
|
||||
}
|
||||
|
||||
$id = $model_presupuesto->insertarPresupuestoCliente(
|
||||
$selected_tirada, $datos_presupuesto, $datosCabecera, $resultado_presupuesto['info'],
|
||||
$resumen_totales, $iva_reducido, $tiradas_alternativas);
|
||||
|
||||
|
||||
// Lineas Presupuesto
|
||||
/*
|
||||
foreach ($resultado_presupuesto['info']['interior'] as $linea){
|
||||
|
||||
if(count($linea) > 0)
|
||||
$this->guardarLineaPresupuesto($id, $linea);
|
||||
}
|
||||
if(count($resultado_presupuesto['info']['cubierta']) > 0)
|
||||
$this->guardarLineaPresupuesto($id, $resultado_presupuesto['info']['cubierta']);
|
||||
if(count($resultado_presupuesto['info']['sobrecubierta']) > 0)
|
||||
$this->guardarLineaPresupuesto($id, $resultado_presupuesto['info']['sobrecubierta']);
|
||||
if(count($resultado_presupuesto['info']['guardas']) > 0)
|
||||
$this->guardarLineaPresupuesto($id, $resultado_presupuesto['info']['guardas']);
|
||||
|
||||
// Servicios
|
||||
foreach ($resultado_presupuesto['info']['serviciosDefecto'] as $servicio){
|
||||
$this->guardarServicio($id, $servicio, 'encuadernacion');
|
||||
}
|
||||
foreach ($resultado_presupuesto['info']['servicios_automaticos'] as $servicio){
|
||||
if ($servicio->tarifa_id == 3 || $servicio->tarifa_id == 5 || $servicio->tarifa_id == 16) {
|
||||
// Servicios acabado
|
||||
$this->guardarServicio($id, $servicio, 'acabado');
|
||||
|
||||
} else if ($servicio->tarifa_id == 24 || $servicio->tarifa_id == 9) {
|
||||
// Servicios extra
|
||||
$this->guardarServicio($id, $servicio, 'extra');
|
||||
|
||||
} else if ($servicio->tarifa_id == 62) {
|
||||
// Servicios manipulado
|
||||
$this->guardarServicio($id, $servicio, 'manipulado');
|
||||
}
|
||||
}
|
||||
*/
|
||||
foreach ($reqData['direcciones'] as $direccion){
|
||||
$this->guardarLineaEnvio($id, $direccion, $peso_libro);
|
||||
}
|
||||
|
||||
|
||||
return $this->respond([
|
||||
'value' => $id,
|
||||
@ -915,10 +971,133 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
|
||||
* Funciones auxiliares
|
||||
*
|
||||
**********************/
|
||||
protected function guardarLineaEnvio($presupuestoId, $direccion){
|
||||
protected function guardarLineaPresupuesto($presupuestoId, $linea){
|
||||
|
||||
$model = new PresupuestoLineaModel();
|
||||
$model->insertLPFromBackend($presupuestoId, $linea);
|
||||
}
|
||||
|
||||
|
||||
protected function guardarLineaEnvio($presupuestoId, $direccion, $peso_libro){
|
||||
|
||||
$data = $this->calcular_coste_envio($direccion['id'], $peso_libro, $direccion['unidades'], $direccion['tipo']=='cajas'?0:1);
|
||||
if(count($data)>0){
|
||||
$data[0]->presupuesto_id = $presupuestoId;
|
||||
$data[0]->tarifa_id = $data[0]->id;
|
||||
unset($data[0]->id);
|
||||
$data[0]->precio = $data[0]->coste;
|
||||
unset($data[0]->coste);
|
||||
$data[0]->entregaPieCalle = $direccion['tipo']=='cajas'?0:1;
|
||||
unset($data[0]->tipo);
|
||||
$model = new PresupuestoDireccionesModel();
|
||||
$model->insert($data[0]);
|
||||
}
|
||||
}
|
||||
|
||||
protected function guardarTiradas($presupuestoId, $direccion){
|
||||
|
||||
}
|
||||
|
||||
protected function guardarServicio($presupuestoId, $servicio, $tipo){
|
||||
|
||||
if($tipo == 'encuadernacion'){
|
||||
$model = new PresupuestoEncuadernacionesModel();
|
||||
|
||||
$data = [
|
||||
'presupuesto_id' => $presupuestoId,
|
||||
'tarifa_encuadernado_id' => $servicio->tarifa_id,
|
||||
'proveedor_id' => $servicio->proveedor_id,
|
||||
'tiempo' => $servicio->tiempo,
|
||||
'precio_total' => $servicio->total,
|
||||
'precio_unidad' => $servicio->precio_unidad,
|
||||
'margen' => $servicio->margen,
|
||||
];
|
||||
$model->insert($data);
|
||||
}
|
||||
else if($tipo == 'extra'){
|
||||
$model = new PresupuestoServiciosExtraModel();
|
||||
|
||||
$data = [
|
||||
'presupuesto_id' => $presupuestoId,
|
||||
'tarifa_extra_id' => $servicio->tarifa_id,
|
||||
'precio_total' => $servicio->total,
|
||||
'precio_unidad' => $servicio->precio_unidad,
|
||||
'margen' => $servicio->margen,
|
||||
];
|
||||
$model->insert($data);
|
||||
}
|
||||
else if($tipo == 'acabado'){
|
||||
$model = new PresupuestoAcabadosModel();
|
||||
|
||||
$data = [
|
||||
'presupuesto_id' => $presupuestoId,
|
||||
'tarifa_acabado_id' => $servicio->tarifa_id,
|
||||
'precio_total' => $servicio->total,
|
||||
'precio_unidad' => $servicio->precio_unidad,
|
||||
'margen' => $servicio->margen,
|
||||
];
|
||||
$model->insert($data);
|
||||
}
|
||||
else if($tipo == 'manipulado'){
|
||||
$model = new PresupuestoManipuladosModel();
|
||||
|
||||
$data = [
|
||||
'presupuesto_id' => $presupuestoId,
|
||||
'tarifa_manipulado_id' => $servicio->tarifa_id,
|
||||
'precio_total' => $servicio->total,
|
||||
'precio_unidad' => $servicio->precio_unidad,
|
||||
'margen' => $servicio->margen,
|
||||
];
|
||||
$model->insert($data);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
protected function calcular_coste_envio($direccionId, $peso, $unidades, $entregaPieCalle){
|
||||
|
||||
$model = model('App\Models\Clientes\ClienteDireccionesModel');
|
||||
$data = $model->getDireccion($direccionId);
|
||||
|
||||
$modelTarifaEnvio = model('App\Models\Tarifas\TarifaEnvioModel');
|
||||
$coste = 0;
|
||||
$margen = 0;
|
||||
|
||||
if ($data > 0) {
|
||||
$peso_envio = $peso * $unidades / 1000.0; // peso libro * unidades y se pasa a gramos
|
||||
$tarifas_envio = $modelTarifaEnvio->getTarifaEnvio($data[0]->pais_id, $data[0]->cp, $peso_envio, $entregaPieCalle ? 'palets' : 'cajas');
|
||||
for ($i = 0; $i < count($tarifas_envio); $i++) {
|
||||
if ($peso > $tarifas_envio[$i]->peso_max) {
|
||||
$tarifas_envio[$i]->precio = number_format($tarifas_envio[$i]->peso_min + ($peso - $tarifas_envio[$i]->peso_min) * $tarifas_envio[$i]->precio_adicional, 2);
|
||||
}
|
||||
// si no se calcula linealmente
|
||||
else {
|
||||
$m = (($tarifas_envio[$i]->precio_max - $tarifas_envio[$i]->precio_min) / ($tarifas_envio[$i]->peso_max - $tarifas_envio[$i]->peso_min));
|
||||
$b = $tarifas_envio[$i]->precio_max - $m * $tarifas_envio[$i]->peso_max;
|
||||
$tarifas_envio[$i]->precio = number_format($m * $peso + $b, 2);
|
||||
}
|
||||
$margen = $tarifas_envio[$i]->margen;
|
||||
}
|
||||
|
||||
if (count($tarifas_envio) > 1) {
|
||||
$tarifa_final = array_reduce($tarifas_envio, function ($previous, $current) {
|
||||
return $current->precio < $previous->precio ? $current : $previous;
|
||||
});
|
||||
$coste = $tarifa_final->precio;
|
||||
} else {
|
||||
if (count($tarifas_envio) > 0)
|
||||
$coste = $tarifas_envio[0]->precio;
|
||||
}
|
||||
}
|
||||
if (count($data) > 0) {
|
||||
$data[0]->coste = $coste;
|
||||
$data[0]->tipo = $entregaPieCalle ? 'palets' : 'cajas';
|
||||
$data[0]->margen = $margen;
|
||||
$data[0]->proveedor = $tarifas_envio[0]->proveedor;
|
||||
$data[0]->proveedor_id = $tarifas_envio[0]->proveedor_id;
|
||||
}
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
protected function calcular_presupuesto($datos_entrada , $extra_info =false)
|
||||
{
|
||||
@ -1285,7 +1464,7 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
|
||||
foreach ($servicios as $servicio) {
|
||||
if (intval($servicio) == 3 || intval($servicio) == 5 || intval($servicio) == 16) {
|
||||
// Servicios acabado
|
||||
$resultado = PresupuestoCLienteService::getServiciosManipulado([
|
||||
$resultado = PresupuestoCLienteService::getServiciosAcabados([
|
||||
'tarifa_id' => $servicio,
|
||||
'tirada' => $datosPedido->tirada,
|
||||
'POD' => $POD,
|
||||
@ -1364,7 +1543,6 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$return_data = [
|
||||
'errors' => $error,
|
||||
'total_lp' => $costeInterior + $coste_cubierta + $coste_sobrecubierta,
|
||||
@ -1377,20 +1555,20 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
|
||||
'peso' => $peso,
|
||||
'lomo_cubierta' => $lomo,
|
||||
'lomo_sobrecubierta'=> $lomo_sobrecubierta,
|
||||
'totales' => $totales,
|
||||
|
||||
'interior' => $interior,
|
||||
'cubierta' => $cubierta,
|
||||
'sobrecubierta' => $linea_sobrecubierta,
|
||||
'guardas' => $guardas,
|
||||
'serviciosDefecto' => $servDefecto,
|
||||
'servicios_automaticos' => $serviciosAutomaticos,
|
||||
];
|
||||
|
||||
if($extra_info){
|
||||
$info['lomo_cubierta'] = $lomo;
|
||||
$info['lomo_sobrecubierta'] = $lomo_sobrecubierta;
|
||||
$return_data['info'] = $info;
|
||||
$return_data['info']['interior'] = $interior;
|
||||
$return_data['info']['cubierta'] = $cubierta;
|
||||
$return_data['info']['sobrecubierta'] = $linea_sobrecubierta;
|
||||
$return_data['info']['guardas'] = $guardas;
|
||||
$return_data['info']['serviciosDefecto'] = $servDefecto;
|
||||
$return_data['info']['servicios_automaticos'] = $serviciosAutomaticos;
|
||||
|
||||
$return_data['totales'] = $totales;
|
||||
}
|
||||
return $return_data;
|
||||
|
||||
|
||||
@ -9,6 +9,7 @@ class PresupuestoEncuadernacionesEntity extends \CodeIgniter\Entity\Entity
|
||||
"id" => null,
|
||||
"presupuesto_id" => null,
|
||||
"tarifa_encuadernado_id" => null,
|
||||
"proveedor_id" => null,
|
||||
"precio_unidad" => null,
|
||||
"tiempo" => null,
|
||||
"precio_total" => null,
|
||||
@ -19,6 +20,7 @@ class PresupuestoEncuadernacionesEntity extends \CodeIgniter\Entity\Entity
|
||||
protected $casts = [
|
||||
"presupuesto_id" => "int",
|
||||
"tarifa_encuadernado_id" => "int",
|
||||
"proveedor_id" => "int",
|
||||
"precio_unidad" => "float",
|
||||
"tiempo" => "float",
|
||||
"precio_total" => "float",
|
||||
|
||||
@ -85,6 +85,8 @@ class PresupuestoEntity extends \CodeIgniter\Entity\Entity
|
||||
"total_precio_unidad" => null,
|
||||
"total_factor" => null,
|
||||
"total_factor_ponderado" => null,
|
||||
'total_aceptado' => null,
|
||||
'iva_reducido' => null,
|
||||
"acabado_cubierta_id" => null,
|
||||
"acabado_sobrecubierta_id" => null,
|
||||
"is_duplicado" => false,
|
||||
@ -124,7 +126,6 @@ class PresupuestoEntity extends \CodeIgniter\Entity\Entity
|
||||
"merma_cubierta" => "float",
|
||||
"lomo_cubierta" => "?float",
|
||||
"lomo_sobrecubierta" => "?float",
|
||||
"total_presupuesto" => "?float",
|
||||
"envios_recoge_cliente" => "boolean",
|
||||
"aprobado_user_id" => "?int",
|
||||
"is_deleted" => "int",
|
||||
@ -148,6 +149,8 @@ class PresupuestoEntity extends \CodeIgniter\Entity\Entity
|
||||
"total_precio_unidad" => "?float",
|
||||
"total_factor" => "?float",
|
||||
"total_factor_ponderado" => "?float",
|
||||
'total_aceptado' => "?float",
|
||||
'iva_reducido' => "?boolean",
|
||||
"acabado_cubierta_id" => "int",
|
||||
"acabado_sobrecubierta_id" => "int",
|
||||
"is_duplicado" => "boolean",
|
||||
|
||||
@ -21,7 +21,7 @@ class PresupuestoEncuadernacionesModel extends \App\Models\BaseModel
|
||||
4 => "t1.precio_total"
|
||||
];
|
||||
|
||||
protected $allowedFields = ["presupuesto_id", "tarifa_encuadernado_id", "nombre", "precio_total", "precio_unidad", "margen"];
|
||||
protected $allowedFields = ["presupuesto_id", "tarifa_encuadernado_id", "proveedor_id", "nombre", "precio_total", "precio_unidad", "tiempo", "margen"];
|
||||
protected $returnType = "App\Entities\Presupuestos\PresupuestoEncuadernacionesEntity";
|
||||
|
||||
protected $useTimestamps = true;
|
||||
|
||||
@ -12,7 +12,7 @@ class PresupuestoLineaModel extends \App\Models\BaseModel
|
||||
* @var bool
|
||||
*/
|
||||
protected $useAutoIncrement = true;
|
||||
|
||||
|
||||
protected $allowedFields = [
|
||||
"presupuesto_id",
|
||||
"tipo",
|
||||
@ -339,18 +339,18 @@ class PresupuestoLineaModel extends \App\Models\BaseModel
|
||||
|
||||
public function updatePreciosLineasPresupuesto($id_linea, $new_linea)
|
||||
{
|
||||
$rot_total_impresion = $new_linea['fields']['precio_click_pedido']??0.0 +
|
||||
$new_linea['fields']['precio_tinta']??0.0+$new_linea['fields']['total_Corte']??0.0;
|
||||
|
||||
$rot_total_impresion = $new_linea['fields']['precio_click_pedido'] ?? 0.0 +
|
||||
$new_linea['fields']['precio_tinta'] ?? 0.0 + $new_linea['fields']['total_Corte'] ?? 0.0;
|
||||
|
||||
$data = [
|
||||
"pliegos_precio" => $new_linea['fields']['precios_pliegos'],
|
||||
"libro" => $new_linea['fields']['precio_libro'],
|
||||
"total_papel_pedido" => round($new_linea['fields']['precio_pedido'], 2),
|
||||
"margen_papel_pedido" => round($new_linea['fields']['margen_papel_pedido'], 2),
|
||||
"mano" => $new_linea['fields']['mano'],
|
||||
"precio_click" => round($new_linea['fields']['precio_click'], 6),
|
||||
"precio_click_pedido" => round($new_linea['fields']['precio_click_pedido'], 2),
|
||||
"margen_click_pedido" => round($new_linea['fields']['margen_click_pedido'], 2),
|
||||
"precio_click" => round($new_linea['fields']['precio_click'], 6),
|
||||
"precio_click_pedido" => round($new_linea['fields']['precio_click_pedido'], 2),
|
||||
"margen_click_pedido" => round($new_linea['fields']['margen_click_pedido'], 2),
|
||||
"tiempo_maquina" => strtotime($new_linea['fields']['tiempo_maquina']) - strtotime('TODAY'),
|
||||
"tarifa_impresion_id" => $new_linea['fields']['tarifa_impresion_id'],
|
||||
"rotativa_total_impresion" => $rot_total_impresion,
|
||||
@ -387,16 +387,16 @@ class PresupuestoLineaModel extends \App\Models\BaseModel
|
||||
"rotativa_tiempo_corte" => $new_linea['fields']['tiempo_corte'] ?? 0,
|
||||
"rotativa_precio_hora_corte" => $new_linea['fields']['precio_hora_corte'] ?? 0,
|
||||
"rotativa_total_corte" => $new_linea['fields']['total_corte'] ?? 0,
|
||||
"horas_maquina" => round($new_linea['fields']['horas_maquina'],4),
|
||||
"horas_maquina" => round($new_linea['fields']['horas_maquina'], 4),
|
||||
"precio_hora" => $new_linea['fields']['precio_hora'] ?? 0,
|
||||
"precio_impresion" => $new_linea['fields']['precio_impresion_horas'] ?? 0,
|
||||
"total_linea" => round($new_linea['fields']['total_impresion'], 2) ?? 0,
|
||||
"margen_impresion" => $new_linea['fields']['margen_impresion_horas'] ?? 0,
|
||||
];
|
||||
|
||||
if(array_key_exists('datosTipologias', $new_linea['fields'])){
|
||||
if (array_key_exists('datosTipologias', $new_linea['fields'])) {
|
||||
$data += [
|
||||
"rotativa_negro" => $new_linea['fields']['datosTipologias']->negro ?? 0,
|
||||
"rotativa_negro" => $new_linea['fields']['datosTipologias']->negro ?? 0,
|
||||
"rotativa_cyan" => $new_linea['fields']['datosTipologias']->cyan ?? 0,
|
||||
"rotativa_magenta" => $new_linea['fields']['datosTipologias']->magenta ?? 0,
|
||||
"rotativa_amarillo" => $new_linea['fields']['datosTipologias']->amarillo ?? 0,
|
||||
@ -404,7 +404,7 @@ class PresupuestoLineaModel extends \App\Models\BaseModel
|
||||
"rotativa_gota_negro" => $new_linea['fields']['datosTipologias']->gota_negro ?? 0,
|
||||
"rotativa_gota_color" => $new_linea['fields']['datosTipologias']->gota_color
|
||||
];
|
||||
}
|
||||
}
|
||||
$this->db
|
||||
->table($this->table . " t1")
|
||||
->where('id', $id_linea)
|
||||
@ -414,73 +414,115 @@ class PresupuestoLineaModel extends \App\Models\BaseModel
|
||||
|
||||
public function insertLPFromBackend($presupuesto_id, $new_linea)
|
||||
{
|
||||
$rot_total_impresion = $new_linea['fields']['precio_click_pedido']??0.0 +
|
||||
$new_linea['fields']['precio_tinta']??0.0+$new_linea['fields']['total_Corte']??0.0;
|
||||
|
||||
$rot_total_impresion = $new_linea['precio_click_pedido'] ?? 0.0 +
|
||||
$new_linea['precio_tinta'] ?? 0.0 + $new_linea['total_Corte'] ?? 0.0;
|
||||
|
||||
$formas = json_encode(array(
|
||||
'maquina_ancho'=> $new_linea['dimensiones_maquina'][0],
|
||||
'maquina_alto' => $new_linea['dimensiones_maquina'][1],
|
||||
'maquina_impresion_ancho'=> $new_linea['dimensiones_maquina_impresion'][0],
|
||||
'maquina_impresion_alto' => $new_linea['dimensiones_maquina_impresion'][1],
|
||||
'formas' => $new_linea['num_formas']['value'],
|
||||
'formas_v'=> $new_linea['num_formas']['num_formas_verticales'],
|
||||
'formas_h'=> $new_linea['num_formas']['num_formas_horizontales'],
|
||||
'formas_orientacion'=> $new_linea['num_formas']['posicion_formas']
|
||||
));
|
||||
|
||||
sscanf($new_linea['tiempo_maquina'], "%d:%d:%d", $hours, $minutes, $seconds);
|
||||
$tiempo = isset($seconds) ? $hours * 3600 + $minutes * 60 + $seconds : $hours * 60 + $minutes;
|
||||
|
||||
$data = [
|
||||
'presupuesto_id' => $presupuesto_id,
|
||||
"pliegos_precio" => $new_linea['fields']['precios_pliegos'],
|
||||
"libro" => $new_linea['fields']['precio_libro'],
|
||||
"total_papel_pedido" => round($new_linea['fields']['precio_pedido'], 2),
|
||||
"margen_papel_pedido" => round($new_linea['fields']['margen_papel_pedido'], 2),
|
||||
"mano" => $new_linea['fields']['mano'],
|
||||
"precio_click" => round($new_linea['fields']['precio_click'], 6),
|
||||
"precio_click_pedido" => round($new_linea['fields']['precio_click_pedido'], 2),
|
||||
"margen_click_pedido" => round($new_linea['fields']['margen_click_pedido'], 2),
|
||||
"tiempo_maquina" => strtotime($new_linea['fields']['tiempo_maquina']) - strtotime('TODAY'),
|
||||
"tarifa_impresion_id" => $new_linea['fields']['tarifa_impresion_id'],
|
||||
"rotativa_total_impresion" => $rot_total_impresion,
|
||||
"rotativa_a_favor_fibra" => $new_linea['fields']['a_favor_fibra'] ?? 0,
|
||||
"rotativa_mxm" => $new_linea['fields']['maquina_velocidad'] ?? 0,
|
||||
"rotativa_resolucion" => $new_linea['fields']['resolucion'] ?? 0,
|
||||
"rotativa_area_paginas" => $new_linea['fields']['superficie'] ?? 0,
|
||||
"rotativa_num_gotas_negro" => $new_linea['fields']['num_gotas_negro'] ?? 0,
|
||||
"rotativa_num_gotas_cyan" => $new_linea['fields']['num_gotas_cyan'] ?? 0,
|
||||
"rotativa_num_gotas_magenta" => $new_linea['fields']['num_gotas_magenta'] ?? 0,
|
||||
"rotativa_num_gotas_amarillo" => $new_linea['fields']['num_gotas_amarillo'] ?? 0,
|
||||
"rotativa_num_gotas_cg" => $new_linea['fields']['num_gotas_cg'] ?? 0,
|
||||
"rotativa_peso_gotas_negro" => $new_linea["fields"]["peso_gotas_negro"] ?? 0,
|
||||
"rotativa_peso_gotas_cyan" => $new_linea['fields']['peso_gotas_cyan'] ?? 0,
|
||||
"rotativa_peso_gotas_magenta" => $new_linea['fields']['peso_gotas_magenta'] ?? 0,
|
||||
"rotativa_peso_gotas_amarillo" => $new_linea['fields']['peso_gotas_amarillo'] ?? 0,
|
||||
"rotativa_peso_gotas_cg" => $new_linea['fields']['peso_gotas_cg'] ?? 0,
|
||||
"rotativa_peso_gotas_negro_pedido" => $new_linea["fields"]["peso_gotas_negro_pedido"] ?? 0,
|
||||
"rotativa_peso_gotas_cyan_pedido" => $new_linea["fields"]["peso_gotas_cyan_pedido"] ?? 0,
|
||||
"rotativa_peso_gotas_magenta_pedido" => $new_linea["fields"]["peso_gotas_magenta_pedido"] ?? 0,
|
||||
"rotativa_peso_gotas_amarillo_pedido" => $new_linea["fields"]["peso_gotas_amarillo_pedido"] ?? 0,
|
||||
"rotativa_peso_gotas_cg_pedido" => $new_linea["fields"]["peso_gotas_cg_pedido"] ?? 0,
|
||||
"rotativa_precio_pag_negro" => $new_linea['fields']['precio_pagina_negro'] ?? 0,
|
||||
"rotativa_precio_pag_color" => $new_linea['fields']['precio_pagina_color'] ?? 0,
|
||||
"rotativa_factor_altura" => $new_linea['fields']['factor_altura'] ?? 0,
|
||||
"rotativa_factor_anchura" => $new_linea['fields']['factor_anchura'] ?? 0,
|
||||
"rotativa_pag_por_pliego" => $new_linea['fields']['paginas_por_pliego'] ?? 0,
|
||||
"rotativa_metros_libro" => $new_linea['fields']['metros_papel_libro'] ?? 0,
|
||||
"rotativa_metros_total" => $new_linea['fields']['metros_papel_total'] ?? 0,
|
||||
"rotativa_clicks_libro" => $new_linea['fields']['clicks_libro'] ?? 0,
|
||||
"rotativa_clicks_total" => $new_linea['fields']['clicks_pedido'] ?? 0,
|
||||
"rotativa_precio_tinta" => $new_linea['fields']['precio_tinta'] ?? 0,
|
||||
"rotativa_velocidad_corte" => $new_linea['fields']['velocidad_corte'] ?? 0,
|
||||
"rotativa_tiempo_corte" => $new_linea['fields']['tiempo_corte'] ?? 0,
|
||||
"rotativa_precio_hora_corte" => $new_linea['fields']['precio_hora_corte'] ?? 0,
|
||||
"rotativa_total_corte" => $new_linea['fields']['total_corte'] ?? 0,
|
||||
"horas_maquina" => round($new_linea['fields']['horas_maquina'],4),
|
||||
"precio_hora" => $new_linea['fields']['precio_hora'] ?? 0,
|
||||
"precio_impresion" => $new_linea['fields']['precio_impresion_horas'] ?? 0,
|
||||
"total_linea" => round($new_linea['fields']['total_impresion'], 2) ?? 0,
|
||||
"margen_impresion" => $new_linea['fields']['margen_impresion_horas'] ?? 0,
|
||||
'tipo' => $new_linea['tipo_linea'],
|
||||
'paginas' => $new_linea['paginas'],
|
||||
'papel_id' => $new_linea['papel_generico_id'],
|
||||
'papel_impresion_id' => $new_linea['papel_impresion_id'],
|
||||
'formas' => $formas,
|
||||
'gramaje' => $new_linea['gramaje'],
|
||||
'pliegos_libro' => $new_linea['pliegos_libro'],
|
||||
'pliegos_pedido' => $new_linea['pliegos_pedido'],
|
||||
'pliegos_precio' => $new_linea['precios_pliegos'],
|
||||
'libro' => $new_linea['precio_libro'],
|
||||
'total_papel_pedido' => $new_linea['precio_pedido'],
|
||||
'margen_papel_pedido' => $new_linea['margen_papel_pedido'],
|
||||
'mano' => $new_linea['mano'],
|
||||
'peso' => $new_linea['peso'],
|
||||
'check_papel_total' => 1,
|
||||
'check_impresion_total' => 1,
|
||||
'maquina_id' => $new_linea['maquina_id'],
|
||||
'tiempo_maquina' => $tiempo,
|
||||
'tarifa_impresion_id' => $new_linea['tarifa_impresion_id'],
|
||||
'precio_click' => $new_linea['precio_click'],
|
||||
'precio_click_pedido' => $new_linea['precio_click_pedido'],
|
||||
'maquina' => $new_linea['maquina'],
|
||||
'papel_impresion' => $new_linea['papel_impresion'],
|
||||
'maquina_tipo' => $new_linea['tipo_maquina'],
|
||||
'horas_maquina' => $new_linea['horas_maquina'],
|
||||
'precio_hora' => $new_linea['precio_hora'],
|
||||
'precio_impresion' => $new_linea['precio_impresion_horas'],
|
||||
'total_linea' => $new_linea['total_impresion'],
|
||||
'margen_impresion' => $new_linea['margen_impresion_horas'],
|
||||
'margen_click_pedido' => $new_linea['margen_click_pedido'],
|
||||
];
|
||||
|
||||
if(array_key_exists('datosTipologias', $new_linea['fields'])){
|
||||
if($new_linea['tipo_maquina'] =='inkjet'){
|
||||
$data += [
|
||||
"rotativa_negro" => $new_linea['fields']['datosTipologias']->negro ?? 0,
|
||||
"rotativa_cyan" => $new_linea['fields']['datosTipologias']->cyan ?? 0,
|
||||
"rotativa_magenta" => $new_linea['fields']['datosTipologias']->magenta ?? 0,
|
||||
"rotativa_amarillo" => $new_linea['fields']['datosTipologias']->amarillo ?? 0,
|
||||
"rotativa_cg" => $new_linea['fields']['datosTipologias']->cg ?? 0,
|
||||
"rotativa_gota_negro" => $new_linea['fields']['datosTipologias']->gota_negro ?? 0,
|
||||
"rotativa_gota_color" => $new_linea['fields']['datosTipologias']->gota_color
|
||||
'rotativa_total_impresion' => $rot_total_impresion,
|
||||
|
||||
'rotativa_negro' => $new_linea['datosTipologias']->negro ?? 0,
|
||||
'rotativa_cyan' => $new_linea['datosTipologias']->cyan ?? 0,
|
||||
'rotativa_magenta' => $new_linea['datosTipologias']->magenta ?? 0,
|
||||
'rotativa_amarillo' => $new_linea['datosTipologias']->amarillo ?? 0,
|
||||
'rotativa_cg' => $new_linea['datosTipologias']->cg ?? 0,
|
||||
'rotativa_gota_negro' => $new_linea['datosTipologias']->gota_negro ?? 0,
|
||||
'rotativa_gota_color' => $new_linea['datosTipologias']->gota_color ?? 0,
|
||||
|
||||
'rotativa_num_gotas_negro' => $new_linea['num_gotas_negro'] ?? 0,
|
||||
'rotativa_num_gotas_cyan' => $new_linea['num_gotas_cyan'] ?? 0,
|
||||
'rotativa_num_gotas_magenta' => $new_linea['num_gotas_magenta'] ?? 0,
|
||||
'rotativa_num_gotas_amarillo' => $new_linea['num_gotas_amarillo'] ?? 0,
|
||||
'rotativa_num_gotas_cg' => $new_linea['num_gotas_cg'] ?? 0,
|
||||
'rotativa_peso_gotas_negro' => $new_linea['peso_gotas_negro'] ?? 0,
|
||||
'rotativa_peso_gotas_cyan' => $new_linea['peso_gotas_cyan'] ?? 0,
|
||||
'rotativa_peso_gotas_magenta' => $new_linea['peso_gotas_magenta'] ?? 0,
|
||||
'rotativa_peso_gotas_amarillo' => $new_linea['peso_gotas_amarillo'] ?? 0,
|
||||
'rotativa_peso_gotas_cg' => $new_linea['peso_gotas_cg'] ?? 0,
|
||||
'rotativa_peso_gotas_negro_pedido' => $new_linea['peso_gotas_negro_pedido'] ?? 0,
|
||||
'rotativa_peso_gotas_cyan_pedido' => $new_linea['peso_gotas_cyan_pedido'] ?? 0,
|
||||
'rotativa_peso_gotas_magenta_pedido' => $new_linea['peso_gotas_magenta_pedido'] ?? 0,
|
||||
'rotativa_peso_gotas_amarillo_pedido' => $new_linea['peso_gotas_amarillo_pedido'] ?? 0,
|
||||
'rotativa_peso_gotas_cg_pedido' => $new_linea['peso_gotas_cg_pedido'] ?? 0,
|
||||
|
||||
'rotativa_pag_color' => $new_linea['paginas_color'],
|
||||
'rotativa_resolucion' => $new_linea['resolucion'],
|
||||
'rotativa_area_paginas' => $new_linea['superficie'],
|
||||
'rotativa_precio_pag_negro' => $new_linea['precio_pagina_negro'],
|
||||
'rotativa_precio_pag_color' => $new_linea['precio_pagina_color'],
|
||||
'rotativa_factor_altura' => $new_linea['factor_altura'],
|
||||
'rotativa_factor_anchura' => $new_linea['factor_anchura'],
|
||||
'rotativa_pag_por_pliego' => $new_linea['paginas_por_pliego'],
|
||||
'rotativa_clicks_libro' => $new_linea['clicks_libro'],
|
||||
'rotativa_clicks_total' => $new_linea['clicks_pedido'],
|
||||
'rotativa_precio_tinta' => $new_linea['precio_tinta'],
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
if (strpos($new_linea['tipo_linea'], 'rot') !== false) {
|
||||
$data += [
|
||||
'rotativa_mxm' => $new_linea['maquina_velocidad'],
|
||||
'rotativa_metros_libro' => $new_linea['metros_papel_libro'],
|
||||
'rotativa_metros_total' => $new_linea['metros_papel_total'],
|
||||
'rotativa_velocidad_corte' => $new_linea['velocidad_corte'],
|
||||
'rotativa_precio_hora_corte' => $new_linea['precio_hora_corte'],
|
||||
'rotativa_tiempo_corte' => $new_linea['tiempo_corte'],
|
||||
'rotativa_total_corte' => $new_linea['total_corte'],
|
||||
'rotativa_a_favor_fibra' => $new_linea['a_favor_fibra']
|
||||
];
|
||||
}
|
||||
|
||||
if($new_linea['tipo_linea'] =='lp_guardas')
|
||||
array_push($data, ['paginas_impresion' => $new_linea['paginas_impresion']]);
|
||||
|
||||
return $this->db
|
||||
->table($this->table . " t1")
|
||||
->set($data)
|
||||
@ -507,7 +549,6 @@ class PresupuestoLineaModel extends \App\Models\BaseModel
|
||||
->where("t1.presupuesto_id", $presupuesto_id)
|
||||
->insert($linea);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public function getResourceByNForPdf($presupuesto_id = -1)
|
||||
@ -574,9 +615,4 @@ class PresupuestoLineaModel extends \App\Models\BaseModel
|
||||
->insert($linea);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -106,6 +106,8 @@ class PresupuestoModel extends \App\Models\BaseModel
|
||||
"total_precio_unidad",
|
||||
"total_factor",
|
||||
"total_factor_ponderado",
|
||||
'total_aceptado',
|
||||
'iva_reducido',
|
||||
"acabado_cubierta_id",
|
||||
"acabado_sobrecubierta_id",
|
||||
"is_duplicado"
|
||||
@ -311,7 +313,7 @@ class PresupuestoModel extends \App\Models\BaseModel
|
||||
return $builder;
|
||||
}
|
||||
|
||||
function insertarPresupuestoCliente($tirada, $data, $data_cabecera, $extra_info)
|
||||
function insertarPresupuestoCliente($tirada, $data, $data_cabecera, $extra_info, $resumen_totales, $iva_reducido, $tiradas_alternativas)
|
||||
{
|
||||
|
||||
helper('date');
|
||||
@ -321,6 +323,11 @@ class PresupuestoModel extends \App\Models\BaseModel
|
||||
|
||||
$is_cosido = (new TipoPresupuestoModel())->get_isCosido($data['tipo_impresion_id']);
|
||||
|
||||
$totalCostes = $resumen_totales['totalPapel'] + $resumen_totales['totalImpresion'] +
|
||||
$resumen_totales['totalServicios']+$resumen_totales['coste_envio'];
|
||||
$totalMargenes = $resumen_totales['margenPapel'] + $resumen_totales['margenImpresion'] +
|
||||
$resumen_totales['margenServicios'] + $resumen_totales['margen_envio'];
|
||||
|
||||
$fields = [
|
||||
'cliente_id' => $data['clienteId'],
|
||||
'tipo_impresion_id' => $data['tipo_impresion_id'],
|
||||
@ -361,29 +368,33 @@ class PresupuestoModel extends \App\Models\BaseModel
|
||||
'created_at' => date('Y-m-d H:i:s', now()),
|
||||
'updated_at' => date('Y-m-d H:i:s', now()),
|
||||
|
||||
'tirada_alternativa_json_data' => null,
|
||||
'tirada_alternativa_json_data' => json_encode($tiradas_alternativas),
|
||||
|
||||
'total_presupuesto' => 0,
|
||||
'total_coste_papel' => 0,
|
||||
'total_margen_papel' => 0,
|
||||
'total_margenPercent_papel' => 0,
|
||||
'total_coste_impresion' => 0,
|
||||
'total_margen_impresion' => 0,
|
||||
'total_margenPercent_impresion' => 0,
|
||||
'total_coste_servicios' => 0,
|
||||
'total_margen_servicios' => 0,
|
||||
'total_margenPercent_servicios' => 0,
|
||||
'total_coste_envios' => 0,
|
||||
'total_margen_envios' => 0,
|
||||
'total_costes' => 0,
|
||||
'total_margenes' => 0,
|
||||
'total_antes_descuento' => 0,
|
||||
'total_coste_papel' => round($resumen_totales['totalPapel'], 2),
|
||||
'total_margen_papel' => round($resumen_totales['margenPapel'], 2),
|
||||
'total_margenPercent_papel' => round($resumen_totales['porcentajeMargenPapel'], 0),
|
||||
'total_coste_impresion' => round($resumen_totales['totalImpresion'], 2),
|
||||
'total_margen_impresion' => round($resumen_totales['margenImpresion'], 2),
|
||||
'total_margenPercent_impresion' => round($resumen_totales['porcentajeMargenImpresion'], 0),
|
||||
'total_coste_servicios' => round($resumen_totales['totalServicios'], 2),
|
||||
'total_margen_servicios' => round($resumen_totales['margenServicios'], 2),
|
||||
'total_margenPercent_servicios' => round($resumen_totales['porcentajeMargenServicios'], 2),
|
||||
'total_coste_envios' => round($resumen_totales['coste_envio'], 2),
|
||||
'total_margen_envios' => round($resumen_totales['margen_envio'], 2),
|
||||
'total_costes' => round($totalCostes, 2),
|
||||
'total_margenes' => round($totalMargenes, 2),
|
||||
|
||||
'total_antes_descuento' => round($totalCostes + $totalMargenes, 2),
|
||||
'total_descuento' => 0,
|
||||
'total_descuentoPercent' => 0,
|
||||
'total_precio_unidad' => 0,
|
||||
|
||||
'total_factor' => 0,
|
||||
'total_factor_ponderado' => 0,
|
||||
'total_precio_unidad' => round(($totalCostes + $totalMargenes)/$tirada, 4),
|
||||
'total_presupuesto' => round($totalCostes + $totalMargenes, 2),
|
||||
|
||||
'total_factor' => round(($totalCostes + $totalMargenes-$resumen_totales['coste_envio']-$resumen_totales['margen_envio'])/$resumen_totales['sumForFactor'], 2),
|
||||
'total_factor_ponderado' => round(($totalCostes + $totalMargenes-$resumen_totales['coste_envio']-$resumen_totales['margen_envio'])/$resumen_totales['sumForFactorPonderado'], 2),
|
||||
|
||||
'iva_reducido' => $iva_reducido,
|
||||
|
||||
];
|
||||
|
||||
|
||||
@ -19,7 +19,7 @@ class PresupuestoServiciosExtraModel extends \App\Models\BaseModel
|
||||
2 => "t1.precio_total"
|
||||
];
|
||||
|
||||
protected $allowedFields = ["presupuesto_id", "tarifa_extra_id", "nombre", "precio_total", "precio_unidad", "margen"];
|
||||
protected $allowedFields = ["presupuesto_id", "tarifa_extra_id", "precio_total", "precio_unidad", "margen"];
|
||||
protected $returnType = "App\Entities\Presupuestos\PresupuestoServiciosExtraEntity";
|
||||
|
||||
protected $useTimestamps = true;
|
||||
|
||||
@ -41,7 +41,7 @@ class PresupuestoClienteService extends BaseService
|
||||
}
|
||||
|
||||
$total_rotativa = -1;
|
||||
if (!$data['excluirRotativa'] && count($rotativa) > 0) {
|
||||
if (!$data['excluirRotativa'] && count($rotativa) > 0 && $rotativa['num_formas']['posicion_formas'] != 'n/a') {
|
||||
$total_rotativa = floatval($rotativa['total_impresion']);
|
||||
}
|
||||
if ($total_plana < 0 && $total_rotativa < 0)
|
||||
|
||||
@ -155,7 +155,7 @@ $('#insertarDireccion').on('click', function() {
|
||||
success: function(response) {
|
||||
if(response.data.length > 0) {
|
||||
let html = '';
|
||||
html += '<div id="envioId' + response.data[0].id + '" t= ' +response.data[0].tipo + '" p= ' +response.data[0].coste + ' class="row mb-3">';
|
||||
html += '<div id="envioId' + response.data[0].id + '" t="' +response.data[0].tipo + '" p= ' +response.data[0].coste + ' class="row mb-3">';
|
||||
html += '<div class="col-sm-5 form-check custom-option custom-option-basic checked">';
|
||||
html += '<label class="form-check-label custom-option-content" for="customRadioAddress1">';
|
||||
html += '<span class="custom-option-header mb-2">';
|
||||
@ -322,6 +322,7 @@ function getDireccionesEnvio(){
|
||||
const unidades = parseInt($(elements[index]).find('div label span span').text().split(' ')[0]);
|
||||
const id = $(elements[index]).attr('id').replace('envioId', '');
|
||||
const tipo = $(elements[index]).attr('t');
|
||||
|
||||
direcciones.push({
|
||||
unidades: unidades,
|
||||
id: id,
|
||||
|
||||
@ -670,42 +670,47 @@ async function calcularPresupuesto() {
|
||||
data: datos,
|
||||
success: function (response) {
|
||||
error = false;
|
||||
if(response.errors.interior.length > 0){
|
||||
$('#errorInterior').show();
|
||||
error = true;
|
||||
}
|
||||
else
|
||||
$('#errorInterior').hide();
|
||||
if(response.errors.cubierta.length > 0){
|
||||
$('#errorCubierta').show();
|
||||
error = true;
|
||||
}
|
||||
else
|
||||
$('#errorCubierta').hide();
|
||||
try{
|
||||
|
||||
if(response.errors.sobrecubierta.length > 0){
|
||||
$('#errorSobrecubierta').show();
|
||||
|
||||
if(response.errors.interior.length > 0){
|
||||
$('#errorInterior').show();
|
||||
error = true;
|
||||
}
|
||||
else
|
||||
$('#errorInterior').hide();
|
||||
if(response.errors.cubierta.length > 0){
|
||||
$('#errorCubierta').show();
|
||||
error = true;
|
||||
}
|
||||
else
|
||||
$('#errorSobrecubierta').hide();
|
||||
|
||||
$('#errorCubierta').hide();
|
||||
|
||||
if(response.errors.guardas.length > 0){
|
||||
$('#errorGuardas').show();
|
||||
error = true;
|
||||
}
|
||||
else
|
||||
$('#errorGuardas').hide();
|
||||
|
||||
if(response.errors.servicios.length > 0 || response.errors.serviciosDefecto.length > 0){
|
||||
error = true;
|
||||
$('#errorGeneral').show();
|
||||
}
|
||||
else{
|
||||
$('#errorGeneral').hide();
|
||||
}
|
||||
if(response.errors.sobrecubierta.length > 0){
|
||||
$('#errorSobrecubierta').show();
|
||||
error = true;
|
||||
}
|
||||
else
|
||||
$('#errorSobrecubierta').hide();
|
||||
|
||||
|
||||
if(response.errors.guardas.length > 0){
|
||||
$('#errorGuardas').show();
|
||||
error = true;
|
||||
}
|
||||
else
|
||||
$('#errorGuardas').hide();
|
||||
|
||||
if(response.errors.servicios.length > 0 || response.errors.serviciosDefecto.length > 0){
|
||||
error = true;
|
||||
$('#errorGeneral').show();
|
||||
}
|
||||
else{
|
||||
$('#errorGeneral').hide();
|
||||
}
|
||||
}
|
||||
catch(error){
|
||||
}
|
||||
console.log(response);
|
||||
$('#loader').hide();
|
||||
|
||||
|
||||
@ -185,21 +185,25 @@ $('#btnSave').on('click', function() {
|
||||
|
||||
const seleccion = $('.custom-option-tiradasDirecciones.checked');
|
||||
let tirada = 0;
|
||||
let peso_libro = 0;
|
||||
if(seleccion.length != 0) {
|
||||
|
||||
const element_tirada =($(seleccion[0]).find('label input')[0]);
|
||||
const number = element_tirada.id.match(/\d+$/);
|
||||
if (number.length != 0) {
|
||||
tirada = parseInt($('#tiradaDireccionesValue' + number[0]).text());
|
||||
peso_libro = ($(seleccion[0])).find('label input').attr('peso');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
let direcciones = getDireccionesEnvio();
|
||||
datos = {
|
||||
datos_libro : datos_libro,
|
||||
datos_cabecera: datos_cabecera,
|
||||
direcciones: direcciones,
|
||||
tirada: tirada,
|
||||
peso: peso_libro,
|
||||
iva_reducido: $('#ivaReducido').val()==1?1:0,
|
||||
},
|
||||
datos = Object.assign(datos, window.token_ajax)
|
||||
|
||||
Reference in New Issue
Block a user