Merge branch 'mod/direcciones_ferro_prototipo' into 'main'

funcionalidad completa de ferro prototipo en cliente a excepción de guardar...

See merge request jjimenez/safekat!876
This commit is contained in:
2025-07-04 11:11:33 +00:00
25 changed files with 1222 additions and 289 deletions

View File

@ -448,7 +448,9 @@ class Presupuestoadmin extends \App\Controllers\BaseResourceController
'retractilado' => model('App\Models\Configuracion\ConfigVariableModel')->getVariable('id_servicio_retractilado')->value, 'retractilado' => model('App\Models\Configuracion\ConfigVariableModel')->getVariable('id_servicio_retractilado')->value,
'retractilado5' => model('App\Models\Configuracion\ConfigVariableModel')->getVariable('id_servicio_retractilado5')->value, 'retractilado5' => model('App\Models\Configuracion\ConfigVariableModel')->getVariable('id_servicio_retractilado5')->value,
'ferro' => model('App\Models\Configuracion\ConfigVariableModel')->getVariable('id_servicio_ferro')->value, 'ferro' => model('App\Models\Configuracion\ConfigVariableModel')->getVariable('id_servicio_ferro')->value,
'ferro_2' => model('App\Models\Configuracion\ConfigVariableModel')->getVariable('id_servicio_ferro_2')->value,
'prototipo' => model('App\Models\Configuracion\ConfigVariableModel')->getVariable('id_servicio_prototipo')->value, 'prototipo' => model('App\Models\Configuracion\ConfigVariableModel')->getVariable('id_servicio_prototipo')->value,
'prototipo_2' => model('App\Models\Configuracion\ConfigVariableModel')->getVariable('id_servicio_prototipo_2')->value,
'solapas_grandes_cubierta' => model('App\Models\Configuracion\ConfigVariableModel')->getVariable('id_servicio_plegado_exceso_solapas_cubierta')->value, 'solapas_grandes_cubierta' => model('App\Models\Configuracion\ConfigVariableModel')->getVariable('id_servicio_plegado_exceso_solapas_cubierta')->value,
'solapas_grandes_sobrecubierta' => model('App\Models\Configuracion\ConfigVariableModel')->getVariable('id_servicio_plegado_exceso_solapas_sobrecubierta')->value, 'solapas_grandes_sobrecubierta' => model('App\Models\Configuracion\ConfigVariableModel')->getVariable('id_servicio_plegado_exceso_solapas_sobrecubierta')->value,
'solapas_grandes_faja' => model('App\Models\Configuracion\ConfigVariableModel')->getVariable('id_servicio_plegado_exceso_solapas_faja')->value, 'solapas_grandes_faja' => model('App\Models\Configuracion\ConfigVariableModel')->getVariable('id_servicio_plegado_exceso_solapas_faja')->value,
@ -565,7 +567,6 @@ class Presupuestoadmin extends \App\Controllers\BaseResourceController
$modelCliente = new ClienteModel(); $modelCliente = new ClienteModel();
$modelPapelGenerico = new PapelGenericoModel(); $modelPapelGenerico = new PapelGenericoModel();
$presupuesto = $this->model->find($id); $presupuesto = $this->model->find($id);
$data = []; $data = [];
if ($presupuesto) { if ($presupuesto) {
@ -630,7 +631,9 @@ class Presupuestoadmin extends \App\Controllers\BaseResourceController
$data['datosLibro']['acabadoFaja']['text'] = $modelAcabado->find($presupuesto->acabado_faja_id)->nombre; $data['datosLibro']['acabadoFaja']['text'] = $modelAcabado->find($presupuesto->acabado_faja_id)->nombre;
} }
$data['datosLibro']['prototipo'] = $presupuesto->prototipo; $data['datosLibro']['prototipo'] = $presupuesto->prototipo;
$data['datosLibro']['prototipo2'] = $this->hasPrototipo2($id);
$data['datosLibro']['ferro'] = $presupuesto->ferro; $data['datosLibro']['ferro'] = $presupuesto->ferro;
$data['datosLibro']['ferro2'] = $this->hasFerro2($id);
$data['datosLibro']['ferroDigital'] = $presupuesto->ferro_digital; $data['datosLibro']['ferroDigital'] = $presupuesto->ferro_digital;
$data['datosLibro']['marcapaginas'] = $presupuesto->marcapaginas; $data['datosLibro']['marcapaginas'] = $presupuesto->marcapaginas;
$data['datosLibro']['retractilado'] = $presupuesto->retractilado; $data['datosLibro']['retractilado'] = $presupuesto->retractilado;
@ -659,6 +662,21 @@ class Presupuestoadmin extends \App\Controllers\BaseResourceController
$data['direcciones'] = $this->obtenerDireccionesEnvio($id, $presupuesto->cliente_id); $data['direcciones'] = $this->obtenerDireccionesEnvio($id, $presupuesto->cliente_id);
} }
$data['direccionesFP'] = [];
$direccionFP1 = $this->obtenerDireccionesEnvio($id, $presupuesto->cliente_id, true, 1);
if(count($direccionFP1) > 0){
$data['direccionesFP']['fp1'] = $direccionFP1;
} else {
$data['direccionesFP']['fp1'] = [];
}
$direccionFP2 = $this->obtenerDireccionesEnvio($id, $presupuesto->cliente_id, true, 2);
if(count($direccionFP2) > 0){
$data['direccionesFP']['fp2'] = $direccionFP2;
} else {
$data['direccionesFP']['fp2'] = [];
}
$data['direccionesFP']['checkboxes'] = json_decode($presupuesto->getDireccionFPChecks());
$data['comentarios_cliente'] = $presupuesto->comentarios_cliente; $data['comentarios_cliente'] = $presupuesto->comentarios_cliente;
$data['comentarios_safekat'] = $presupuesto->comentarios_safekat; $data['comentarios_safekat'] = $presupuesto->comentarios_safekat;
$data['comentarios_pdf'] = $presupuesto->comentarios_pdf; $data['comentarios_pdf'] = $presupuesto->comentarios_pdf;
@ -1951,7 +1969,7 @@ class Presupuestoadmin extends \App\Controllers\BaseResourceController
return PresupuestoService::checkLineasEnvios($direccionesEnvio); return PresupuestoService::checkLineasEnvios($direccionesEnvio);
} }
protected function obtenerDireccionesEnvio($id, $cliente_id) protected function obtenerDireccionesEnvio($id, $cliente_id, $is_fp = false, $num_fp = 0)
{ {
$model = model('App\Models\Presupuestos\PresupuestoDireccionesModel'); $model = model('App\Models\Presupuestos\PresupuestoDireccionesModel');
$model_direcciones = model('App\Models\Clientes\ClienteDireccionesModel'); $model_direcciones = model('App\Models\Clientes\ClienteDireccionesModel');
@ -1959,10 +1977,38 @@ class Presupuestoadmin extends \App\Controllers\BaseResourceController
->join('lg_proveedores', 'presupuesto_direcciones.proveedor_id = lg_proveedores.id') ->join('lg_proveedores', 'presupuesto_direcciones.proveedor_id = lg_proveedores.id')
->join('lg_paises', 'presupuesto_direcciones.pais_id = lg_paises.id') ->join('lg_paises', 'presupuesto_direcciones.pais_id = lg_paises.id')
->select('presupuesto_direcciones.*, lg_proveedores.nombre AS proveedor, lg_paises.nombre AS pais') ->select('presupuesto_direcciones.*, lg_proveedores.nombre AS proveedor, lg_paises.nombre AS pais')
->where('presupuesto_id', $id)->findAll(); ->where('presupuesto_id', $id)
->where('is_ferro_prototipo', $is_fp);
if ($is_fp) {
$direcciones = $direcciones
->where('num_ferro_prototipo', $num_fp);
}
return $direcciones;
return $direcciones->findAll();
} }
protected function hasPrototipo2($presupuestoId){
$servicios = (new PresupuestoServiciosExtraModel())->getResource($presupuestoId)->get()->getResultObject();
$id_servicio = model('App\Models\Configuracion\ConfigVariableModel')->getVariable('id_servicio_prototipo_2')->value;
foreach ($servicios as $servicio) {
if ($servicio->tarifa_extra_id == $id_servicio) {
return true;
}
}
return false;
}
protected function hasFerro2($presupuestoId)
{
$servicios = (new PresupuestoServiciosExtraModel())->getResource($presupuestoId)->get()->getResultObject();
$id_servicio = model('App\Models\Configuracion\ConfigVariableModel')->getVariable('id_servicio_ferro_2')->value;
foreach ($servicios as $servicio) {
if ($servicio->tarifa_extra_id == $id_servicio) {
return true;
}
}
return false;
}
} }

View File

@ -412,6 +412,7 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
} }
} }
} }
$lomo = round($lomo, 2); $lomo = round($lomo, 2);
$errors = [ $errors = [
'status' => 0, 'status' => 0,
@ -719,7 +720,11 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
} }
} }
// Se suma el coste de envío a cada precio unidad
for ($i = 0; $i < count($tirada); $i++) {
if($return_data['coste_envio'] && isset($return_data['coste_envio'][$i]) && $return_data['coste_envio'][$i] > 0)
$return_data['precio_u'][$i] = round(floatval($return_data['precio_u'][$i]) + $return_data['coste_envio'][$i]/$tirada[$i], 4);
}
if ($this->request) { if ($this->request) {
if ($this->request->isAJAX()) if ($this->request->isAJAX())
@ -1381,6 +1386,13 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
$datos_presupuesto['faja'] = $faja; $datos_presupuesto['faja'] = $faja;
$reqData['datosCabecera'] ?? [];
$datos_presupuesto['direcciones_fp_checks'] = $reqData['direcciones_fp_checks'] ?? (object)[
'addFP1isAddMain' => "false",
'addFP2isAddMain' => "false",
'addFP2isaddFP1' => "false"
];
$id = $model_presupuesto->insertarPresupuestoCliente( $id = $model_presupuesto->insertarPresupuestoCliente(
$id, $id,
$selected_tirada, $selected_tirada,
@ -1561,11 +1573,11 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
} }
if (count($direccionesFP1) > 0) { if (count($direccionesFP1) > 0) {
$this->guardarLineaEnvio($id, $direccionesFP1, $peso_libro, true); $this->guardarLineaEnvio($id, $direccionesFP1, $peso_libro, true, true, 1);
} }
if (count($direccionesFP2) > 0) { if (count($direccionesFP2) > 0) {
$this->guardarLineaEnvio($id, $direccionesFP2, $peso_libro, true); $this->guardarLineaEnvio($id, $direccionesFP2, $peso_libro, true, true, 2);
} }
if ($confirmar) { if ($confirmar) {
@ -1708,6 +1720,13 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
$data['direcciones'] = $this->obtenerDireccionesEnvio($id); $data['direcciones'] = $this->obtenerDireccionesEnvio($id);
} }
$direccionesFerroPrototipo = $this->obtenerDireccionesEnvioFerro($id);
if($direccionesFerroPrototipo && count($direccionesFerroPrototipo) > 0) {
$data['direccionesFerroPrototipo'] = $direccionesFerroPrototipo;
}
$data['direccionesFPChecks'] = $presupuesto->getDireccionFPChecks();
if (intval($presupuesto->estado_id) == 2) { if (intval($presupuesto->estado_id) == 2) {
$data['resumen']['base'] = $presupuesto->total_antes_descuento; $data['resumen']['base'] = $presupuesto->total_antes_descuento;
$data['resumen']['total_envio'] = round( $data['resumen']['total_envio'] = round(
@ -1871,7 +1890,7 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
} }
protected function guardarLineaEnvio($presupuestoId, $direccion, $peso_libro, $coste_cero = false) protected function guardarLineaEnvio($presupuestoId, $direccion, $peso_libro, $coste_cero = false, $is_ferro_prototipo = false, $num_ferro_prototipo = 0)
{ {
$unidades = intval($direccion['unidades']); $unidades = intval($direccion['unidades']);
@ -1893,6 +1912,10 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
unset($data->id); unset($data->id);
if($coste_cero) { if($coste_cero) {
$data->coste = 0; $data->coste = 0;
if($is_ferro_prototipo){
$data->is_ferro_prototipo = 1;
$data->num_ferro_prototipo = $num_ferro_prototipo;
}
} else { } else {
$data->precio = $data->coste; $data->precio = $data->coste;
} }
@ -3426,7 +3449,7 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
{ {
$model = model('App\Models\Presupuestos\PresupuestoDireccionesModel'); $model = model('App\Models\Presupuestos\PresupuestoDireccionesModel');
$direcciones = $model->where('presupuesto_id', $id) $direcciones = $model->where('presupuesto_id', $id)
->where('is_ferro_prototipo', 0)->asArray()->findAll(); ->where('is_ferro_prototipo', 1)->get()->getResultArray();
return $direcciones; return $direcciones;
} }

View File

@ -55,6 +55,7 @@ class Presupuestodirecciones extends \App\Controllers\BaseResourceController
$proveedor_id = $reqData['proveedor_id'] ?? ""; $proveedor_id = $reqData['proveedor_id'] ?? "";
$entregaPieCalle = $reqData['entregaPieCalle'] ?? 0; $entregaPieCalle = $reqData['entregaPieCalle'] ?? 0;
$is_ferro_prototipo = $reqData['is_ferro_prototipo'] ?? 0; $is_ferro_prototipo = $reqData['is_ferro_prototipo'] ?? 0;
$num_ferro_prototipo = $reqData['num_ferro_prototipo'] ?? 0;
$data = [ $data = [
"presupuesto_id" => $presupuesto_id, "presupuesto_id" => $presupuesto_id,
@ -74,7 +75,8 @@ class Presupuestodirecciones extends \App\Controllers\BaseResourceController
"proveedor" => $proveedor, "proveedor" => $proveedor,
"proveedor_id" => $proveedor_id, "proveedor_id" => $proveedor_id,
"entregaPieCalle" => $entregaPieCalle, "entregaPieCalle" => $entregaPieCalle,
"is_ferro_prototipo" => $is_ferro_prototipo "is_ferro_prototipo" => $is_ferro_prototipo,
"num_ferro_prototipo" => $num_ferro_prototipo
]; ];
$response = $this->model->insert($data); $response = $this->model->insert($data);

View File

@ -0,0 +1,24 @@
<?php
namespace App\Database\Migrations;
use CodeIgniter\Database\Migration;
class ConfigDireccionesFerroPrototipo extends Migration
{
public function up()
{
$this->forge->addColumn('presupuestos', [
'direcciones_fp_checks' => [
'type' => 'JSON',
'null' => false,
'default' => '{"addFP1isAddMain": "0", "addFP2isAddMain": "0", "addFP2isaddFP1": "0"}',
'comment' => 'valores de los checks de las direcciones ferro/prototipo',
],
]);
}
public function down()
{
$this->forge->dropColumn('presupuestos', 'direcciones_fp_checks');
}
}

View File

@ -0,0 +1,25 @@
<?php
namespace App\Database\Migrations;
use CodeIgniter\Database\Migration;
class AumentoLomoFijo extends Migration
{
public function up()
{
$this->db->table('config_variables_app')->insert([
'name' => 'aumento_fijo_lomo_interior',
'value' => '1.3',
'description' => 'Aumento fijo del lomo interior por cola (se añade en el interior)',
'created_at' => date('Y-m-d H:i:s')
]);
}
public function down()
{
// Borrar los nuevos campos
$this->db->table('config_variables_app')->whereIn('name', [
'aumento_fijo_lomo_interior'
])->delete();
}
}

View File

@ -0,0 +1,33 @@
<?php
namespace App\Database\Migrations;
use CodeIgniter\Database\Migration;
class FerroPrototipo2 extends Migration
{
public function up()
{
$this->db->table('config_variables_app')->insert([
'name' => 'id_servicio_ferro_2',
'value' => '31',
'description' => 'D del servicio extra "ferro (2 unidades)" que aparece en los presupuestos',
'created_at' => date('Y-m-d H:i:s')
]);
$this->db->table('config_variables_app')->insert([
'name' => 'id_servicio_prototipo_2',
'value' => '28',
'description' => 'D del servicio extra "Prototipo (2 unidades)" que aparece en los presupuestos',
'created_at' => date('Y-m-d H:i:s')
]);
}
public function down()
{
// Borrar los nuevos campos
$this->db->table('config_variables_app')->whereIn('name', [
'id_servicio_ferro_2',
'id_servicio_prototipo_2'
])->delete();
}
}

View File

@ -117,6 +117,12 @@ class PresupuestoEntity extends \CodeIgniter\Entity\Entity
'lomo_redondo' => null, 'lomo_redondo' => null,
'cabezada' => null, 'cabezada' => null,
'envio_base' => null, 'envio_base' => null,
'direcciones_fp_checks' => [
'addFP1isAddMain' => "false",
'addFP2isAddMain' => "false",
'addFP2isaddFP1' => "false"
],
]; ];
protected $casts = [ protected $casts = [
"cliente_id" => "int", "cliente_id" => "int",
@ -190,6 +196,7 @@ class PresupuestoEntity extends \CodeIgniter\Entity\Entity
'papel_interior_diferente' => "boolean", 'papel_interior_diferente' => "boolean",
'paginasCuadernillo' => "int", 'paginasCuadernillo' => "int",
'lomo_redondo' => "boolean", 'lomo_redondo' => "boolean",
'direcciones_fp_checks' => 'json',
]; ];
/** /**
* Devuelve la entity con un campo `presupuesto_lineas` con las lineas de presupuesto asociadas * Devuelve la entity con un campo `presupuesto_lineas` con las lineas de presupuesto asociadas
@ -326,4 +333,15 @@ class PresupuestoEntity extends \CodeIgniter\Entity\Entity
} }
return $tipo_presupuesto; return $tipo_presupuesto;
} }
public function getDireccionFPChecks()
{
return $this->attributes['direcciones_fp_checks'] ?? [];
}
public function setDireccionFPChecks($value)
{
$this->attributes['direcciones_fp_checks'] = is_array($value) ? json_encode($value) : $value;
return $this;
}
} }

View File

@ -757,7 +757,7 @@ return [
"menu_tarifaextra" => "Serv. Extra", "menu_tarifaextra" => "Serv. Extra",
"menu_tarifamanipulado" => "Manipulado", "menu_tarifamanipulado" => "Manipulado",
"menu_tarifaencuadernacion" => "Encuadernación", "menu_tarifaencuadernacion" => "Encuadernación",
"menu_tarifapapelcompra" => "Papel compra", "menu_tarifapapelcompra" => "Papel impresión",
"menu_servicioAcabado" => "Servicios acabado", "menu_servicioAcabado" => "Servicios acabado",
"menu_tarifaacabado" => "Acabado", "menu_tarifaacabado" => "Acabado",
"menu_tarifapapeldefecto" => "Papel defecto", "menu_tarifapapeldefecto" => "Papel defecto",

View File

@ -80,8 +80,10 @@ return [
'acabadoFaja' => 'Acabado Faja', 'acabadoFaja' => 'Acabado Faja',
'cosido' => 'Cosido', 'cosido' => 'Cosido',
'ferro' => 'Ferro', 'ferro' => 'Ferro',
'ferro_2' => 'Ferro (2 uds.)',
'ferroDigital' => 'Ferro Digital', 'ferroDigital' => 'Ferro Digital',
'prototipo' => 'Prototipo', 'prototipo' => 'Prototipo',
'prototipo_2' => 'Prototipo (2 uds.)',
'imagenesBnInterior' => 'Imágenes B/N interior', 'imagenesBnInterior' => 'Imágenes B/N interior',
'recogerEnTaller' => 'Recoger en taller', 'recogerEnTaller' => 'Recoger en taller',
'marcapaginas' => 'Marcapáginas', 'marcapaginas' => 'Marcapáginas',
@ -305,7 +307,7 @@ return [
'previewSobrecubierta' => 'Configuración del papel: Sobrecubierta', 'previewSobrecubierta' => 'Configuración del papel: Sobrecubierta',
'previewFaja' => 'Configuración del papel: Faja', 'previewFaja' => 'Configuración del papel: Faja',
'previewPapelGenerico' => 'Papel Genérico', 'previewPapelGenerico' => 'Papel Genérico',
'previewPapelCompra' => 'Papel de Compra', 'previewPapelCompra' => 'Papel Impresión',
'previewAreaImpresion' => 'Área de Impresión', 'previewAreaImpresion' => 'Área de Impresión',
'previewPosicionFormas' => 'Posición de Formas', 'previewPosicionFormas' => 'Posición de Formas',
'previewDetalles' => 'Detalles del trabajo', 'previewDetalles' => 'Detalles del trabajo',
@ -436,6 +438,9 @@ return [
'paginas_multiplo_4' => 'El número total de páginas para <b>cosido</b> y <b>grapado</b> debe ser múltiplo de 4', 'paginas_multiplo_4' => 'El número total de páginas para <b>cosido</b> y <b>grapado</b> debe ser múltiplo de 4',
'paginas_pares' => 'El número de páginas debe ser par', 'paginas_pares' => 'El número de páginas debe ser par',
'extras_cubierta' => 'Rellene todos los campos', 'extras_cubierta' => 'Rellene todos los campos',
'error_sameAddPrincipal_FP' => 'Debe añadir al menos una dirección en el envío para usarla',
'error_sameAddFP1' => 'Debe añadir al menos una dirección en el envío del primer ferro para usarla.'
], ],
'errores' => [ 'errores' => [
@ -463,6 +468,7 @@ return [
Por favor, disminuya el número de páginas o el gramaje del papel para que sea encuadernable.", Por favor, disminuya el número de páginas o el gramaje del papel para que sea encuadernable.",
'error_lomo_minimo' => "No se pueden encuadernar libros {0} con un lomo interior inferior a {1} mm. El lomo actual es de {2} mm. <br> 'error_lomo_minimo' => "No se pueden encuadernar libros {0} con un lomo interior inferior a {1} mm. El lomo actual es de {2} mm. <br>
Por favor, aumente el número de páginas o el gramaje del papel para que sea encuadernable.", Por favor, aumente el número de páginas o el gramaje del papel para que sea encuadernable.",
'error_direccion_principal_no_encontrada' => 'No se ha encontrado la dirección en las direcciones del cliente. Por favor, añádala antes de marcar esta opción.',
], ],
'resize_preview' => 'Refrescar vista esquema' 'resize_preview' => 'Refrescar vista esquema'

View File

@ -139,6 +139,7 @@ class PresupuestoModel extends \App\Models\BaseModel
'lomo_redondo', 'lomo_redondo',
'cabezada', 'cabezada',
'envio_base', 'envio_base',
'direcciones_fp_checks',
]; ];
protected $returnType = "App\Entities\Presupuestos\PresupuestoEntity"; protected $returnType = "App\Entities\Presupuestos\PresupuestoEntity";
@ -535,6 +536,8 @@ class PresupuestoModel extends \App\Models\BaseModel
'iva_reducido' => $iva_reducido, 'iva_reducido' => $iva_reducido,
'excluir_rotativa' => $excluir_rotativa, 'excluir_rotativa' => $excluir_rotativa,
'direcciones_fp_checks' => $data['direcciones_fp_checks'] ? json_encode($data['direcciones_fp_checks']) : null,
]; ];
/* Actualizacion */ /* Actualizacion */
if ($id != 0) { if ($id != 0) {

View File

@ -386,6 +386,7 @@ class PresupuestoService extends BaseService
$precio_pedido = $precio_libro * ($datosPedido->tirada + $datosPedido->merma); $precio_pedido = $precio_libro * ($datosPedido->tirada + $datosPedido->merma);
$mano = PresupuestoService::computeLomoInterior($datosPedido->paginas, $papel_impresion->espesor); $mano = PresupuestoService::computeLomoInterior($datosPedido->paginas, $papel_impresion->espesor);
$mano += floatval(model('App\Models\Configuracion\ConfigVariableModel')->getVariable('aumento_fijo_lomo_interior')->value);
// peso // peso
$peso = PresupuestoService::computePeso( $peso = PresupuestoService::computePeso(
@ -515,6 +516,7 @@ class PresupuestoService extends BaseService
$data['total_corte'] = round(($data['tiempo_corte'] / 60.0) * $maquina->precio_hora_corte, 2); $data['total_corte'] = round(($data['tiempo_corte'] / 60.0) * $maquina->precio_hora_corte, 2);
$data['mano'] = PresupuestoService::computeLomoInterior($datosPedido->paginas, $papel_impresion->espesor); $data['mano'] = PresupuestoService::computeLomoInterior($datosPedido->paginas, $papel_impresion->espesor);
$data['mano'] += floatval(model('App\Models\Configuracion\ConfigVariableModel')->getVariable('aumento_fijo_lomo_interior')->value);
// ($paginas / 2.0) * (($gramaje / 1000.0) * $papel_compra->mano); // ($paginas / 2.0) * (($gramaje / 1000.0) * $papel_compra->mano);
// peso // peso

View File

@ -1,69 +1,207 @@
<div class="accordion accordion-bordered mt-3" id="accordionEnvios"> <div class="accordion accordion-bordered mt-3" id="accordionEnvios">
<div class="card accordion-item active"> <div class="card accordion-item active">
<h2 class="accordion-header" id="headingOne"> <h2 class="accordion-header" id="headingOne">
<button type="button" class="accordion-button" data-bs-toggle="collapse" data-bs-target="#accordionEnviosTip" aria-expanded="false" aria-controls="accordionEnviosTip"> <button type="button" class="accordion-button" data-bs-toggle="collapse"
data-bs-target="#accordionEnviosTip" aria-expanded="false" aria-controls="accordionEnviosTip">
<h4><?= lang("Presupuestos.envios") ?></h4> <h4><?= lang("Presupuestos.envios") ?></h4>
</button> </button>
</h2> </h2>
<div id="accordionEnviosTip" class="accordion-collapse collapse show" data-bs-parent="#accordionEnvios"> <div id="accordionEnviosTip" class="accordion-collapse collapse show" data-bs-parent="#accordionEnvios">
<div class="accordion-body"> <div class="accordion-body">
<div id='alert-envios'></div> <div> <!-- Direcciones envio -->
<?= view("themes/vuexy/form/presupuestos/admin/_presupuestoDireccionesForm") ?> <div id='alert-envios'></div>
<div class='row'> <?= view("themes/vuexy/form/presupuestos/admin/_presupuestoDireccionesForm") ?>
<div class='col-md-12 col-lg-4 px-4 py-2'> <div class='row'>
<label for='envio_base' class='form-label'> <div class='col-md-12 col-lg-4 px-4 py-2'>
Envio base <label for='envio_base' class='form-label'>
</label> Envio base
<input readonly type='text' class='form-control' id='envio_base' name='envio_base' value='<?= $presupuestoEntity->envio_base ?>' /> </label>
<input readonly type='text' class='form-control' id='envio_base' name='envio_base'
value='<?= $presupuestoEntity->envio_base ?>' />
</div>
</div>
<div id='rowTable' class='row'>
<table id="tableOfDireccionesEnvio"
class="table comparator-table dt-responsive dataTable px-2 update-resumen-presupuesto"
style="width: 95%;">
<thead>
<tr>
<th class="lp-header">TARIFA ID</th>
<th class="lp-header"><?= lang('PresupuestosDirecciones.cantidad') ?></th>
<th class="lp-header"><?= lang('PresupuestosDirecciones.peso') ?></th>
<th class="lp-header"><?= lang('PresupuestosDirecciones.att') ?></th>
<th class="lp-header"><?= lang('PresupuestosDirecciones.email') ?></th>
<th class="lp-header"><?= lang('PresupuestosDirecciones.direccion') ?></th>
<th class="lp-header"><?= lang('PresupuestosDirecciones.cp') ?></th>
<th class="lp-header"><?= lang('PresupuestosDirecciones.municipio') ?></th>
<th class="lp-header"><?= lang('PresupuestosDirecciones.pais') ?></th>
<th class="lp-header">pais_id</th>
<th class="lp-header"><?= lang('PresupuestosDirecciones.telefono') ?></th>
<th class="lp-header"><?= lang('PresupuestosDirecciones.proveedor') ?></th>
<th class="lp-header">Proveedor_id</th>
<th class="lp-header"><?= lang('PresupuestosDirecciones.costePrecio') ?></th>
<th class="lp-header"><?= lang('Tarifaacabado.margen') ?></th>
<th class="lp-header">Pallets?</th>
<th style="min-width:120px !important;" class="lp-header">
<?= lang('Basic.global.Action') ?>
</th>
</tr>
</thead>
<tbody>
</tbody>
</table>
</div> </div>
</div> <div class="row">
<div id='rowTable' class='row'> <div class="col-md-12 col-lg-4 px-4 py-2">
<table id="tableOfDireccionesEnvio" class="table comparator-table dt-responsive dataTable px-2 update-resumen-presupuesto" style="width: 95%;"> <input class="form-check-input" type="checkbox" id="recoger_en_taller"
<thead> name="recoger_en_taller" value="1" <?= $presupuestoEntity->recoger_en_taller == true ? 'checked' : ''; ?>>
<tr> <label class="form-check-label"
<th class="lp-header">TARIFA ID</th> for="recoger_en_taller"><?= lang('Presupuestos.recogerEnTaller') ?></label>
<th class="lp-header"><?= lang('PresupuestosDirecciones.cantidad') ?></th> </div>
<th class="lp-header"><?= lang('PresupuestosDirecciones.peso') ?></th>
<th class="lp-header"><?= lang('PresupuestosDirecciones.att') ?></th>
<th class="lp-header"><?= lang('PresupuestosDirecciones.email') ?></th>
<th class="lp-header"><?= lang('PresupuestosDirecciones.direccion') ?></th>
<th class="lp-header"><?= lang('PresupuestosDirecciones.cp') ?></th>
<th class="lp-header"><?= lang('PresupuestosDirecciones.municipio') ?></th>
<th class="lp-header"><?= lang('PresupuestosDirecciones.pais') ?></th>
<th class="lp-header">pais_id</th>
<th class="lp-header"><?= lang('PresupuestosDirecciones.telefono') ?></th>
<th class="lp-header"><?= lang('PresupuestosDirecciones.proveedor') ?></th>
<th class="lp-header">Proveedor_id</th>
<th class="lp-header"><?= lang('PresupuestosDirecciones.costePrecio') ?></th>
<th class="lp-header"><?= lang('Tarifaacabado.margen') ?></th>
<th class="lp-header">Pallets?</th>
<th class="lp-header">Ferro o Prototipo?</th>
<th style="min-width:120px !important;" class="lp-header"><?= lang('Basic.global.Action') ?></th>
</tr>
</thead>
<tbody>
</tbody>
</table>
</div>
<div class="row">
<div class="col-md-12 col-lg-4 px-4 py-2">
<input class="form-check-input" type="checkbox" id="recoger_en_taller" name="recoger_en_taller" value="1" <?= $presupuestoEntity->recoger_en_taller == true ? 'checked' : ''; ?> >
<label class="form-check-label" for="recoger_en_taller"><?= lang('Presupuestos.recogerEnTaller') ?></label>
</div> </div>
</div>
<div id="rowInsertar" class="row"> <div id="rowInsertar" class="row">
<div class="col-md-12 col-lg-4 px-4 py-2"> <div class="col-md-12 col-lg-4 px-4 py-2">
<button id="insertar_direccion" type="button" class="btn btn-secondary waves-effect waves-light float-start"><?= lang("Presupuestos.insertar")?></button> <button id="insertar_direccion" type="button"
class="btn btn-secondary waves-effect waves-light float-start"><?= lang("Presupuestos.insertar") ?></button>
</div>
</div> </div>
</div>
</div> <!-- //.Direcciones envio -->
<div id="div-envio-fp-1" class="mt-3 datos-envio-fp-1"> <!-- Direcciones envio fp 1 -->
<div class="divider divider-dark text-start mb-1">
<div class="divider-text">
<h6>
Dirección de envío ferro/prototipo
</h6>
</div>
</div>
<div id='alert-envio-fp1'></div>
<div id='rowTable' class='row'>
<table id="tableOfDireccionesEnvioFP1"
class="table comparator-table dt-responsive dataTable px-2 update-resumen-presupuesto"
style="width: 95%;">
<thead>
<tr>
<th class="lp-header">TARIFA ID</th>
<th class="lp-header"><?= lang('PresupuestosDirecciones.cantidad') ?></th>
<th class="lp-header"><?= lang('PresupuestosDirecciones.peso') ?></th>
<th class="lp-header"><?= lang('PresupuestosDirecciones.att') ?></th>
<th class="lp-header"><?= lang('PresupuestosDirecciones.email') ?></th>
<th class="lp-header"><?= lang('PresupuestosDirecciones.direccion') ?></th>
<th class="lp-header"><?= lang('PresupuestosDirecciones.cp') ?></th>
<th class="lp-header"><?= lang('PresupuestosDirecciones.municipio') ?></th>
<th class="lp-header"><?= lang('PresupuestosDirecciones.pais') ?></th>
<th class="lp-header">pais_id</th>
<th class="lp-header"><?= lang('PresupuestosDirecciones.telefono') ?></th>
<th class="lp-header"><?= lang('PresupuestosDirecciones.proveedor') ?></th>
<th class="lp-header">Proveedor_id</th>
<th class="lp-header"><?= lang('PresupuestosDirecciones.costePrecio') ?></th>
<th class="lp-header"><?= lang('Tarifaacabado.margen') ?></th>
<th class="lp-header">Pallets?</th>
<th style="min-width:120px !important;" class="lp-header">
<?= lang('Basic.global.Action') ?>
</th>
</tr>
</thead>
<tbody>
</tbody>
</table>
</div>
<div class="row">
<div class="col-md-12 col-lg-4 px-4 py-2">
<input class="form-check-input check-direccion-fp" type="checkbox" id="sameAddPrincipalFP1"
name="sameAddPrincipalFP1" value="1" >
<label class="form-check-label"
for="sameAddPrincipalFP1"><?= lang('PresupuestosDirecciones.sameAddPrincipal') ?></label>
</div>
</div>
<div id="rowInsertarEnvioFP1" class="row datos-envio-fp-1">
<div class="col-md-12 col-lg-4 px-4 py-2">
<button id="insertar_direccion_fp1" type="button"
class="btn btn-secondary waves-effect waves-light float-start"><?= lang("Presupuestos.insertar") ?></button>
</div>
</div>
</div> <!-- //.Direcciones envio fp1-->
<div id="div-envio-fp-2" class="mt-3 datos-envio-fp-2"> <!-- Direcciones envio fp 2 -->
<div class="divider divider-dark text-start mb-1">
<div class="divider-text">
<h6>
Dirección de envío ferro/prototipo 2
</h6>
</div>
</div>
<div id='alert-envio-fp2'></div>
<div id='rowTable' class='row'>
<table id="tableOfDireccionesEnvioFP2"
class="table comparator-table dt-responsive dataTable px-2 update-resumen-presupuesto"
style="width: 95%;">
<thead>
<tr>
<th class="lp-header">TARIFA ID</th>
<th class="lp-header"><?= lang('PresupuestosDirecciones.cantidad') ?></th>
<th class="lp-header"><?= lang('PresupuestosDirecciones.peso') ?></th>
<th class="lp-header"><?= lang('PresupuestosDirecciones.att') ?></th>
<th class="lp-header"><?= lang('PresupuestosDirecciones.email') ?></th>
<th class="lp-header"><?= lang('PresupuestosDirecciones.direccion') ?></th>
<th class="lp-header"><?= lang('PresupuestosDirecciones.cp') ?></th>
<th class="lp-header"><?= lang('PresupuestosDirecciones.municipio') ?></th>
<th class="lp-header"><?= lang('PresupuestosDirecciones.pais') ?></th>
<th class="lp-header">pais_id</th>
<th class="lp-header"><?= lang('PresupuestosDirecciones.telefono') ?></th>
<th class="lp-header"><?= lang('PresupuestosDirecciones.proveedor') ?></th>
<th class="lp-header">Proveedor_id</th>
<th class="lp-header"><?= lang('PresupuestosDirecciones.costePrecio') ?></th>
<th class="lp-header"><?= lang('Tarifaacabado.margen') ?></th>
<th class="lp-header">Pallets?</th>
<th style="min-width:120px !important;" class="lp-header">
<?= lang('Basic.global.Action') ?>
</th>
</tr>
</thead>
<tbody>
</tbody>
</table>
</div>
<div class="row d-flex justify-content-start">
<div class="col-auto px-2 py-2">
<input class="form-check-input check-direccion-fp-2" type="checkbox" id="sameAddPrincipalFP2"
name="sameAddPrincipalFP2" value="1" >
<label class="form-check-label"
for="sameAddPrincipalFP2"><?= lang('PresupuestosDirecciones.sameAddPrincipal') ?></label>
</div>
<div class="col-auto px-2 py-2">
<input class="form-check-input check-direccion-fp-2" type="checkbox" id="sameAddFP1" name="sameAddFP1" value="1"
>
<label class="form-check-label"
for="sameAddFP1"><?= lang('PresupuestosDirecciones.sameAddFP1') ?></label>
</div>
</div>
<div id="rowInsertarEnvioFP2" class="row datos-envio-fp-2">
<div class="col-md-12 col-lg-4 px-4 py-2">
<button id="insertar_direccion_fp2" type="button"
class="btn btn-secondary waves-effect waves-light float-start"><?= lang("Presupuestos.insertar") ?></button>
</div>
</div>
</div> <!-- //.Direcciones envio fp2-->
</div> <!-- //.accordion-body --> </div> <!-- //.accordion-body -->
</div> <!-- //.accordion-collapse --> </div> <!-- //.accordion-collapse -->
</div> <!-- //.accordion-item --> </div> <!-- //.accordion-item -->
</div> <!-- //.accordion --> </div> <!-- //.accordion -->

View File

@ -303,11 +303,20 @@
</label> </label>
</div><!--//.form-check --> </div><!--//.form-check -->
</div><!--//.mb-3 --> </div><!--//.mb-3 -->
<div class="mb-3">
</div><!--//.mb-3 -->
</div><!--//.col --> </div><!--//.col -->
<div class="col-md-12 col-lg-3 px-4">
<div class="mb-3">
<div class="form-check">
<label for="prototipo_2" class="form-check-label">
<input type="checkbox" id="prototipo_2" name="prototipo_2" value="1"
class="form-check-input" service="extra"
service-id=<?= $serviciosAutomaticos['prototipo_2'] ?>>
<?= lang('Presupuestos.prototipo_2') ?>
</label>
</div><!--//.form-check -->
</div><!--//.mb-3 -->
</div><!--//.col -->
</div> </div>
@ -326,6 +335,18 @@
</div><!--//.mb-3 --> </div><!--//.mb-3 -->
</div><!--//.col --> </div><!--//.col -->
<div class="col-md-12 col-lg-3 px-4">
<div class="mb-3">
<div class="form-check">
<label for="ferro_2" class="form-check-label">
<input type="checkbox" id="ferro_2" name="ferro_2" value="1" class="form-check-input"
service="extra" service-id=<?= $serviciosAutomaticos['ferro_2'] ?>>
<?= lang('Presupuestos.ferro_2') ?>
</label>
</div><!--//.form-check -->
</div><!--//.mb-3 -->
</div><!--//.col -->
<div class="col-md-12 col-lg-3 px-4"> <div class="col-md-12 col-lg-3 px-4">
<div class="mb-3"> <div class="mb-3">

View File

@ -1,4 +1,4 @@
<div id="addressForm" action='create' class="modal fade addModal"> <div id="addressForm" action='create' data-table="" class="modal fade addModal">
<div class="modal-dialog modal-lg modal-simple"> <div class="modal-dialog modal-lg modal-simple">
<div class="modal-content"> <div class="modal-content">
<div class="modal-header"> <div class="modal-header">
@ -9,14 +9,6 @@
<div id='error-tarifa'></div> <div id='error-tarifa'></div>
<div class="mb-3" id="direccionFerroProto">
<label for="dirFerroProto" class="form-label">
Dirección Ferro o Prototipo
</label>
<input type="checkbox" id="dirFerroProto" class="form-check-input">
</div><!--//.mb-3 -->
<div class="mb-3"> <div class="mb-3">
<label for="add_clientedAdd" class="form-label"> <label for="add_clientedAdd" class="form-label">
<?= lang('PresupuestosDirecciones.clientedAdd') ?>* <?= lang('PresupuestosDirecciones.clientedAdd') ?>*

View File

@ -155,7 +155,7 @@
<!-- Configuraciones --> <!-- Configuraciones -->
<div class="row g-3 mb-3"> <div class="row g-3 mb-3">
<div class="col-12"> <div class="col-12">
<a id="pv_bn_pg" href="#" sk-url="<?= str_replace('/0', '', route_to('updatePapelGenerico', 0)); ?>" target="_blank"> <a id="pv_bn_pg" href="#" sk-url="<?= str_replace('0', '', route_to('updatePapelGenerico', 0)); ?>" target="_blank">
<div class="d-grid"> <div class="d-grid">
<button type="button" class="btn btn-label-primary"> <button type="button" class="btn btn-label-primary">
<?= lang("Presupuestos.previewPapelGenerico") ?> <?= lang("Presupuestos.previewPapelGenerico") ?>
@ -164,7 +164,7 @@
</a> </a>
</div> </div>
<div class="col-12"> <div class="col-12">
<a id="pv_bn_pi" href="#" sk-url="<?= str_replace('/0', '', route_to('updatePapelImpresion', 0)); ?>" target="_blank"> <a id="pv_bn_pi" href="#" sk-url="<?= str_replace('0', '', route_to('updatePapelImpresion', 0)); ?>" target="_blank">
<div class="d-grid"> <div class="d-grid">
<button type="button" class="btn btn-label-primary"> <button type="button" class="btn btn-label-primary">
<?= lang("Presupuestos.previewPapelCompra") ?> <?= lang("Presupuestos.previewPapelCompra") ?>
@ -173,7 +173,7 @@
</a> </a>
</div> </div>
<div class="col-12"> <div class="col-12">
<a id="pv_bn_mi" href="#" sk-url="<?= str_replace('/0', '', route_to('updateMaquina', 0)); ?>" target="_blank"> <a id="pv_bn_mi" href="#" sk-url="<?= str_replace('0', '', route_to('updateMaquina', 0)); ?>" target="_blank">
<div class="d-grid"> <div class="d-grid">
<button type="button" class="btn btn-label-primary"> <button type="button" class="btn btn-label-primary">
<?= lang("Presupuestos.previewAreaImpresion") ?> <?= lang("Presupuestos.previewAreaImpresion") ?>
@ -237,7 +237,7 @@
<!-- Configuraciones --> <!-- Configuraciones -->
<div class="row g-3 mb-3"> <div class="row g-3 mb-3">
<div class="col-12"> <div class="col-12">
<a id="pv_bnhq_pg" href="#" sk-url="<?= str_replace('/0', '', route_to('updatePapelGenerico', 0)); ?>" target="_blank"> <a id="pv_bnhq_pg" href="#" sk-url="<?= str_replace('0', '', route_to('updatePapelGenerico', 0)); ?>" target="_blank">
<div class="d-grid"> <div class="d-grid">
<button type="button" class="btn btn-label-primary"> <button type="button" class="btn btn-label-primary">
<?= lang("Presupuestos.previewPapelGenerico") ?> <?= lang("Presupuestos.previewPapelGenerico") ?>
@ -246,7 +246,7 @@
</a> </a>
</div> </div>
<div class="col-12"> <div class="col-12">
<a id="pv_bnhq_pi" href="#" sk-url="<?= str_replace('/0', '', route_to('updatePapelImpresion', 0)); ?>" target="_blank"> <a id="pv_bnhq_pi" href="#" sk-url="<?= str_replace('0', '', route_to('updatePapelImpresion', 0)); ?>" target="_blank">
<div class="d-grid"> <div class="d-grid">
<button type="button" class="btn btn-label-primary"> <button type="button" class="btn btn-label-primary">
<?= lang("Presupuestos.previewPapelCompra") ?> <?= lang("Presupuestos.previewPapelCompra") ?>
@ -255,7 +255,7 @@
</a> </a>
</div> </div>
<div class="col-12"> <div class="col-12">
<a id="pv_bnhq_mi" href="#" sk-url="<?= str_replace('/0', '', route_to('updateMaquina', 0)); ?>" target="_blank"> <a id="pv_bnhq_mi" href="#" sk-url="<?= str_replace('0', '', route_to('updateMaquina', 0)); ?>" target="_blank">
<div class="d-grid"> <div class="d-grid">
<button type="button" class="btn btn-label-primary"> <button type="button" class="btn btn-label-primary">
<?= lang("Presupuestos.previewAreaImpresion") ?> <?= lang("Presupuestos.previewAreaImpresion") ?>
@ -319,7 +319,7 @@
<!-- Configuraciones --> <!-- Configuraciones -->
<div class="row g-3 mb-3"> <div class="row g-3 mb-3">
<div class="col-12"> <div class="col-12">
<a id="pv_color_pg" href="#" sk-url="<?= str_replace('/0', '', route_to('updatePapelGenerico', 0)); ?>" target="_blank"> <a id="pv_color_pg" href="#" sk-url="<?= str_replace('0', '', route_to('updatePapelGenerico', 0)); ?>" target="_blank">
<div class="d-grid"> <div class="d-grid">
<button type="button" class="btn btn-label-primary"> <button type="button" class="btn btn-label-primary">
<?= lang("Presupuestos.previewPapelGenerico") ?> <?= lang("Presupuestos.previewPapelGenerico") ?>
@ -328,7 +328,7 @@
</a> </a>
</div> </div>
<div class="col-12"> <div class="col-12">
<a id="pv_color_pi" href="#" sk-url="<?= str_replace('/0', '', route_to('updatePapelImpresion', 0)); ?>" target="_blank"> <a id="pv_color_pi" href="#" sk-url="<?= str_replace('0', '', route_to('updatePapelImpresion', 0)); ?>" target="_blank">
<div class="d-grid"> <div class="d-grid">
<button type="button" class="btn btn-label-primary"> <button type="button" class="btn btn-label-primary">
<?= lang("Presupuestos.previewPapelCompra") ?> <?= lang("Presupuestos.previewPapelCompra") ?>
@ -337,7 +337,7 @@
</a> </a>
</div> </div>
<div class="col-12"> <div class="col-12">
<a id="pv_color_mi" href="#" sk-url="<?= str_replace('/0', '', route_to('updateMaquina', 0)); ?>" target="_blank"> <a id="pv_color_mi" href="#" sk-url="<?= str_replace('0', '', route_to('updateMaquina', 0)); ?>" target="_blank">
<div class="d-grid"> <div class="d-grid">
<button type="button" class="btn btn-label-primary"> <button type="button" class="btn btn-label-primary">
<?= lang("Presupuestos.previewAreaImpresion") ?> <?= lang("Presupuestos.previewAreaImpresion") ?>
@ -401,7 +401,7 @@
<!-- Configuraciones --> <!-- Configuraciones -->
<div class="row g-3 mb-3"> <div class="row g-3 mb-3">
<div class="col-12"> <div class="col-12">
<a id="pv_colorhq_pg" href="#" sk-url="<?= str_replace('/0', '', route_to('updatePapelGenerico', 0)); ?>" target="_blank"> <a id="pv_colorhq_pg" href="#" sk-url="<?= str_replace('0', '', route_to('updatePapelGenerico', 0)); ?>" target="_blank">
<div class="d-grid"> <div class="d-grid">
<button type="button" class="btn btn-label-primary"> <button type="button" class="btn btn-label-primary">
<?= lang("Presupuestos.previewPapelGenerico") ?> <?= lang("Presupuestos.previewPapelGenerico") ?>
@ -410,7 +410,7 @@
</a> </a>
</div> </div>
<div class="col-12"> <div class="col-12">
<a id="pv_colorhq_pi" href="#" sk-url="<?= str_replace('/0', '', route_to('updatePapelImpresion', 0)); ?>" target="_blank"> <a id="pv_colorhq_pi" href="#" sk-url="<?= str_replace('0', '', route_to('updatePapelImpresion', 0)); ?>" target="_blank">
<div class="d-grid"> <div class="d-grid">
<button type="button" class="btn btn-label-primary"> <button type="button" class="btn btn-label-primary">
<?= lang("Presupuestos.previewPapelCompra") ?> <?= lang("Presupuestos.previewPapelCompra") ?>
@ -419,7 +419,7 @@
</a> </a>
</div> </div>
<div class="col-12"> <div class="col-12">
<a id="pv_colorhq_mi" href="#" sk-url="<?= str_replace('/0', '', route_to('updateMaquina', 0)); ?>" target="_blank"> <a id="pv_colorhq_mi" href="#" sk-url="<?= str_replace('0', '', route_to('updateMaquina', 0)); ?>" target="_blank">
<div class="d-grid"> <div class="d-grid">
<button type="button" class="btn btn-label-primary"> <button type="button" class="btn btn-label-primary">
<?= lang("Presupuestos.previewAreaImpresion") ?> <?= lang("Presupuestos.previewAreaImpresion") ?>
@ -485,7 +485,7 @@
<!-- Configuraciones --> <!-- Configuraciones -->
<div class="row g-3 mb-3"> <div class="row g-3 mb-3">
<div class="col-12"> <div class="col-12">
<a id="pv_rot_bn_pg" href="#" sk-url="<?= str_replace('/0', '', route_to('updatePapelGenerico', 0)); ?>" target="_blank"> <a id="pv_rot_bn_pg" href="#" sk-url="<?= str_replace('0', '', route_to('updatePapelGenerico', 0)); ?>" target="_blank">
<div class="d-grid"> <div class="d-grid">
<button type="button" class="btn btn-label-primary"> <button type="button" class="btn btn-label-primary">
<?= lang("Presupuestos.previewPapelGenerico") ?> <?= lang("Presupuestos.previewPapelGenerico") ?>
@ -494,7 +494,7 @@
</a> </a>
</div> </div>
<div class="col-12"> <div class="col-12">
<a id="pv_rot_bn_pi" href="#" sk-url="<?= str_replace('/0', '', route_to('updatePapelImpresion', 0)); ?>" target="_blank"> <a id="pv_rot_bn_pi" href="#" sk-url="<?= str_replace('0', '', route_to('updatePapelImpresion', 0)); ?>" target="_blank">
<div class="d-grid"> <div class="d-grid">
<button type="button" class="btn btn-label-primary"> <button type="button" class="btn btn-label-primary">
<?= lang("Presupuestos.previewPapelCompra") ?> <?= lang("Presupuestos.previewPapelCompra") ?>
@ -503,7 +503,7 @@
</a> </a>
</div> </div>
<div class="col-12"> <div class="col-12">
<a id="pv_rot_bn_mi" href="#" sk-url="<?= str_replace('/0', '', route_to('updateMaquina', 0)); ?>" target="_blank"> <a id="pv_rot_bn_mi" href="#" sk-url="<?= str_replace('0', '', route_to('updateMaquina', 0)); ?>" target="_blank">
<div class="d-grid"> <div class="d-grid">
<button type="button" class="btn btn-label-primary"> <button type="button" class="btn btn-label-primary">
<?= lang("Presupuestos.previewAreaImpresion") ?> <?= lang("Presupuestos.previewAreaImpresion") ?>
@ -565,7 +565,7 @@
<!-- Configuraciones --> <!-- Configuraciones -->
<div class="row g-3 mb-3"> <div class="row g-3 mb-3">
<div class="col-12"> <div class="col-12">
<a id="pv_rot_color_pg" href="#" sk-url="<?= str_replace('/0', '', route_to('updatePapelGenerico', 0)); ?>" target="_blank"> <a id="pv_rot_color_pg" href="#" sk-url="<?= str_replace('0', '', route_to('updatePapelGenerico', 0)); ?>" target="_blank">
<div class="d-grid"> <div class="d-grid">
<button type="button" class="btn btn-label-primary"> <button type="button" class="btn btn-label-primary">
<?= lang("Presupuestos.previewPapelGenerico") ?> <?= lang("Presupuestos.previewPapelGenerico") ?>
@ -574,7 +574,7 @@
</a> </a>
</div> </div>
<div class="col-12"> <div class="col-12">
<a id="pv_rot_color_pi" href="#" sk-url="<?= str_replace('/0', '', route_to('updatePapelImpresion', 0)); ?>" target="_blank"> <a id="pv_rot_color_pi" href="#" sk-url="<?= str_replace('0', '', route_to('updatePapelImpresion', 0)); ?>" target="_blank">
<div class="d-grid"> <div class="d-grid">
<button type="button" class="btn btn-label-primary"> <button type="button" class="btn btn-label-primary">
<?= lang("Presupuestos.previewPapelCompra") ?> <?= lang("Presupuestos.previewPapelCompra") ?>
@ -583,7 +583,7 @@
</a> </a>
</div> </div>
<div class="col-12"> <div class="col-12">
<a id="pv_rot_color_mi" href="#" sk-url="<?= str_replace('/0', '', route_to('updateMaquina', 0)); ?>" target="_blank"> <a id="pv_rot_color_mi" href="#" sk-url="<?= str_replace('0', '', route_to('updateMaquina', 0)); ?>" target="_blank">
<div class="d-grid"> <div class="d-grid">
<button type="button" <button type="button"
class="btn btn-label-primary"> class="btn btn-label-primary">
@ -646,7 +646,7 @@
<!-- Configuraciones --> <!-- Configuraciones -->
<div class="row g-3 mb-3"> <div class="row g-3 mb-3">
<div class="col-12"> <div class="col-12">
<a id="pv_guardas_pg" href="#" sk-url="<?= str_replace('/0', '', route_to('updatePapelGenerico', 0)); ?>" target="_blank"> <a id="pv_guardas_pg" href="#" sk-url="<?= str_replace('0', '', route_to('updatePapelGenerico', 0)); ?>" target="_blank">
<div class="d-grid"> <div class="d-grid">
<button type="button" class="btn btn-label-primary"> <button type="button" class="btn btn-label-primary">
<?= lang("Presupuestos.previewPapelGenerico") ?> <?= lang("Presupuestos.previewPapelGenerico") ?>
@ -655,7 +655,7 @@
</a> </a>
</div> </div>
<div class="col-12"> <div class="col-12">
<a id="pv_guardas_pi" href="#" sk-url="<?= str_replace('/0', '', route_to('updatePapelImpresion', 0)); ?>" target="_blank"> <a id="pv_guardas_pi" href="#" sk-url="<?= str_replace('0', '', route_to('updatePapelImpresion', 0)); ?>" target="_blank">
<div class="d-grid"> <div class="d-grid">
<button type="button" class="btn btn-label-primary"> <button type="button" class="btn btn-label-primary">
<?= lang("Presupuestos.previewPapelCompra") ?> <?= lang("Presupuestos.previewPapelCompra") ?>
@ -664,7 +664,7 @@
</a> </a>
</div> </div>
<div class="col-12"> <div class="col-12">
<a id="pv_guardas_mi" href="#" sk-url="<?= str_replace('/0', '', route_to('updateMaquina', 0)); ?>" target="_blank"> <a id="pv_guardas_mi" href="#" sk-url="<?= str_replace('0', '', route_to('updateMaquina', 0)); ?>" target="_blank">
<div class="d-grid"> <div class="d-grid">
<button type="button" class="btn btn-label-primary"> <button type="button" class="btn btn-label-primary">
<?= lang("Presupuestos.previewAreaImpresion") ?> <?= lang("Presupuestos.previewAreaImpresion") ?>
@ -728,7 +728,7 @@
<!-- Configuraciones --> <!-- Configuraciones -->
<div class="row g-3 mb-3"> <div class="row g-3 mb-3">
<div class="col-12"> <div class="col-12">
<a id="pv_cubierta_pg" href="#" sk-url="<?= str_replace('/0', '', route_to('updatePapelGenerico', 0)); ?>" target="_blank"> <a id="pv_cubierta_pg" href="#" sk-url="<?= str_replace('0', '', route_to('updatePapelGenerico', 0)); ?>" target="_blank">
<div class="d-grid"> <div class="d-grid">
<button type="button" class="btn btn-label-primary"> <button type="button" class="btn btn-label-primary">
<?= lang("Presupuestos.previewPapelGenerico") ?> <?= lang("Presupuestos.previewPapelGenerico") ?>
@ -737,7 +737,7 @@
</a> </a>
</div> </div>
<div class="col-12"> <div class="col-12">
<a id="pv_cubierta_pi" href="#" sk-url="<?= str_replace('/0', '', route_to('updatePapelImpresion', 0)); ?>" target="_blank"> <a id="pv_cubierta_pi" href="#" sk-url="<?= str_replace('0', '', route_to('updatePapelImpresion', 0)); ?>" target="_blank">
<div class="d-grid"> <div class="d-grid">
<button type="button" class="btn btn-label-primary"> <button type="button" class="btn btn-label-primary">
<?= lang("Presupuestos.previewPapelCompra") ?> <?= lang("Presupuestos.previewPapelCompra") ?>
@ -746,7 +746,7 @@
</a> </a>
</div> </div>
<div class="col-12"> <div class="col-12">
<a id="pv_cubierta_mi" href="#" sk-url="<?= str_replace('/0', '', route_to('updateMaquina', 0)); ?>" target="_blank"> <a id="pv_cubierta_mi" href="#" sk-url="<?= str_replace('0', '', route_to('updateMaquina', 0)); ?>" target="_blank">
<div class="d-grid"> <div class="d-grid">
<button type="button" class="btn btn-label-primary"> <button type="button" class="btn btn-label-primary">
<?= lang("Presupuestos.previewAreaImpresion") ?> <?= lang("Presupuestos.previewAreaImpresion") ?>
@ -813,7 +813,7 @@
<!-- Configuraciones --> <!-- Configuraciones -->
<div class="row g-3 mb-3"> <div class="row g-3 mb-3">
<div class="col-12"> <div class="col-12">
<a id="pv_ec_pg" href="#" sk-url="<?= str_replace('/0', '', route_to('updatePapelGenerico', 0)); ?>" target="_blank"> <a id="pv_ec_pg" href="#" sk-url="<?= str_replace('0', '', route_to('updatePapelGenerico', 0)); ?>" target="_blank">
<div class="d-grid"> <div class="d-grid">
<button type="button" class="btn btn-label-primary"> <button type="button" class="btn btn-label-primary">
<?= lang("Presupuestos.previewPapelGenerico") ?> <?= lang("Presupuestos.previewPapelGenerico") ?>
@ -822,7 +822,7 @@
</a> </a>
</div> </div>
<div class="col-12"> <div class="col-12">
<a id="pv_ec_pi" href="#" sk-url="<?= str_replace('/0', '', route_to('updatePapelImpresion', 0)); ?>" target="_blank"> <a id="pv_ec_pi" href="#" sk-url="<?= str_replace('0', '', route_to('updatePapelImpresion', 0)); ?>" target="_blank">
<div class="d-grid"> <div class="d-grid">
<button type="button" class="btn btn-label-primary"> <button type="button" class="btn btn-label-primary">
<?= lang("Presupuestos.previewPapelCompra") ?> <?= lang("Presupuestos.previewPapelCompra") ?>
@ -831,7 +831,7 @@
</a> </a>
</div> </div>
<div class="col-12"> <div class="col-12">
<a id="pv_ec_mi" href="#" sk-url="<?= str_replace('/0', '', route_to('updateMaquina', 0)); ?>" target="_blank"> <a id="pv_ec_mi" href="#" sk-url="<?= str_replace('0', '', route_to('updateMaquina', 0)); ?>" target="_blank">
<div class="d-grid"> <div class="d-grid">
<button type="button" class="btn btn-label-primary"> <button type="button" class="btn btn-label-primary">
<?= lang("Presupuestos.previewAreaImpresion") ?> <?= lang("Presupuestos.previewAreaImpresion") ?>
@ -882,7 +882,7 @@
<!-- Configuraciones --> <!-- Configuraciones -->
<div class="row g-3 mb-3"> <div class="row g-3 mb-3">
<div class="col-12"> <div class="col-12">
<a id="pv_sobrecubierta_pg" href="#" sk-url="<?= str_replace('/0', '', route_to('updatePapelGenerico', 0)); ?>" target="_blank"> <a id="pv_sobrecubierta_pg" href="#" sk-url="<?= str_replace('0', '', route_to('updatePapelGenerico', 0)); ?>" target="_blank">
<div class="d-grid"> <div class="d-grid">
<button type="button" class="btn btn-label-primary"> <button type="button" class="btn btn-label-primary">
<?= lang("Presupuestos.previewPapelGenerico") ?> <?= lang("Presupuestos.previewPapelGenerico") ?>
@ -891,7 +891,7 @@
</a> </a>
</div> </div>
<div class="col-12"> <div class="col-12">
<a id="pv_sobrecubierta_pi" href="#" sk-url="<?= str_replace('/0', '', route_to('updatePapelImpresion', 0)); ?>" target="_blank"> <a id="pv_sobrecubierta_pi" href="#" sk-url="<?= str_replace('0', '', route_to('updatePapelImpresion', 0)); ?>" target="_blank">
<div class="d-grid"> <div class="d-grid">
<button type="button" class="btn btn-label-primary"> <button type="button" class="btn btn-label-primary">
<?= lang("Presupuestos.previewPapelCompra") ?> <?= lang("Presupuestos.previewPapelCompra") ?>
@ -900,7 +900,7 @@
</a> </a>
</div> </div>
<div class="col-12"> <div class="col-12">
<a id="pv_sobrecubierta_mi" href="#" sk-url="<?= str_replace('/0', '', route_to('updateMaquina', 0)); ?>" target="_blank"> <a id="pv_sobrecubierta_mi" href="#" sk-url="<?= str_replace('0', '', route_to('updateMaquina', 0)); ?>" target="_blank">
<div class="d-grid"> <div class="d-grid">
<button type="button" class="btn btn-label-primary"> <button type="button" class="btn btn-label-primary">
<?= lang("Presupuestos.previewAreaImpresion") ?> <?= lang("Presupuestos.previewAreaImpresion") ?>
@ -963,7 +963,7 @@
<!-- Configuraciones --> <!-- Configuraciones -->
<div class="row g-3 mb-3"> <div class="row g-3 mb-3">
<div class="col-12"> <div class="col-12">
<a id="pv_faja_pg" href="#" sk-url="<?= str_replace('/0', '', route_to('updatePapelGenerico', 0)); ?>" target="_blank"> <a id="pv_faja_pg" href="#" sk-url="<?= str_replace('0', '', route_to('updatePapelGenerico', 0)); ?>" target="_blank">
<div class="d-grid"> <div class="d-grid">
<button type="button" class="btn btn-label-primary"> <button type="button" class="btn btn-label-primary">
<?= lang("Presupuestos.previewPapelGenerico") ?> <?= lang("Presupuestos.previewPapelGenerico") ?>
@ -972,7 +972,7 @@
</a> </a>
</div> </div>
<div class="col-12"> <div class="col-12">
<a id="pv_faja_pi" href="#" sk-url="<?= str_replace('/0', '', route_to('updatePapelImpresion', 0)); ?>" target="_blank"> <a id="pv_faja_pi" href="#" sk-url="<?= str_replace('0', '', route_to('updatePapelImpresion', 0)); ?>" target="_blank">
<div class="d-grid"> <div class="d-grid">
<button type="button" class="btn btn-label-primary"> <button type="button" class="btn btn-label-primary">
<?= lang("Presupuestos.previewPapelCompra") ?> <?= lang("Presupuestos.previewPapelCompra") ?>
@ -981,7 +981,7 @@
</a> </a>
</div> </div>
<div class="col-12"> <div class="col-12">
<a id="pv_faja_mi" href="#" sk-url="<?= str_replace('/0', '', route_to('updateMaquina', 0)); ?>" target="_blank"> <a id="pv_faja_mi" href="#" sk-url="<?= str_replace('0', '', route_to('updateMaquina', 0)); ?>" target="_blank">
<div class="d-grid"> <div class="d-grid">
<button type="button" class="btn btn-label-primary"> <button type="button" class="btn btn-label-primary">
<?= lang("Presupuestos.previewAreaImpresion") ?> <?= lang("Presupuestos.previewAreaImpresion") ?>

View File

@ -228,6 +228,7 @@
<!-------------------------------------------> <!------------------------------------------->
<?= $this->section("additionalInlineJs") ?> <?= $this->section("additionalInlineJs") ?>
$(document).keypress(function(e) { $(document).keypress(function(e) {
var key = e.which; var key = e.which;
if (key == 13) // the enter key code if (key == 13) // the enter key code

View File

@ -68,6 +68,9 @@
</div> </div>
</div> </div>
<div id="sk-alert-ferro-prototipo1">
</div>
<div id="direccionesFerroPrototipo" class="row col-sm-12 mb-5 justify-content-center d-none"> <div id="direccionesFerroPrototipo" class="row col-sm-12 mb-5 justify-content-center d-none">
<div class="col-sm-8 mb-3 d-flex flex-column align-items-center"> <div class="col-sm-8 mb-3 d-flex flex-column align-items-center">
<h3 class="mb-1 fw-bold"> Dirección de envío ferro/prototipo</h3> <h3 class="mb-1 fw-bold"> Dirección de envío ferro/prototipo</h3>
@ -101,11 +104,14 @@
</div> </div>
<div id="divDireccionesFerroPrototipo" <div id="divDireccionesFerroPrototipo"
class="calcular-presupuesto col-sm-12 d-flex flex-column align-items-center div-direcciones-ferro-prototipo"> class="col-sm-12 d-flex flex-column align-items-center div-direcciones-ferro-prototipo">
</div> </div>
</div> </div>
<div id="sk-alert-ferro-prototipo2">
</div>
<div id="direccionesFerroPrototipo2" class="row col-sm-12 mb-5 justify-content-center d-none"> <div id="direccionesFerroPrototipo2" class="row col-sm-12 mb-5 justify-content-center d-none">
<div class="col-sm-8 mb-3 d-flex flex-column align-items-center"> <div class="col-sm-8 mb-3 d-flex flex-column align-items-center">
<h3 class="mb-1 fw-bold"> Dirección de envío ferro/prototipo 2</h3> <h3 class="mb-1 fw-bold"> Dirección de envío ferro/prototipo 2</h3>
@ -146,7 +152,7 @@
</div> </div>
<div id="divDireccionesFerroPrototipo2" <div id="divDireccionesFerroPrototipo2"
class="calcular-presupuesto col-sm-12 d-flex flex-column align-items-center div-direcciones-ferro-prototipo"> class="col-sm-12 d-flex flex-column align-items-center div-direcciones-ferro-prototipo">
</div> </div>
</div> </div>

View File

@ -59,6 +59,7 @@ class Ajax {
error: this.error error: this.error
}) })
} }
getPromise() { getPromise() {
if (this.jqXHR) { if (this.jqXHR) {
this.jqXHR.abort(); this.jqXHR.abort();
@ -71,7 +72,7 @@ class Ajax {
data: this.data, data: this.data,
headers: this.headers, headers: this.headers,
success: (response) => { success: (response) => {
if (this.success) this.success(response); if (this.success) this.success(response);
resolve(response); resolve(response);
}, },
error: (xhr) => { error: (xhr) => {

View File

@ -325,6 +325,12 @@ class PresupuestoAdminEdit {
datos.tirada_alternativa_json_data = this.tiradasAlternativas.generate_json_tiradas(); datos.tirada_alternativa_json_data = this.tiradasAlternativas.generate_json_tiradas();
datos.direcciones_fp_checks = JSON.stringify({
"addFP1isAddMain": $('#sameAddPrincipalFP1').prop('checked')? "1":"0",
"addFP2isAddMain": $('#sameAddPrincipalFP2').prop('checked')? "1":"0",
"addFP2isaddFP1": $('#sameAddFP1').prop('checked')? "1":"0",
});
return datos; return datos;
} }
@ -404,7 +410,9 @@ class PresupuestoAdminEdit {
const totalAceptadoRevisado = response.data.total_aceptado_revisado != null ? const totalAceptadoRevisado = response.data.total_aceptado_revisado != null ?
response.data.total_aceptado_revisado : response.data.resumen.total_aceptado; response.data.total_aceptado_revisado : response.data.resumen.total_aceptado;
AutoNumeric.getAutoNumericElement($('#total_aceptado_revisado')[0]).set(totalAceptadoRevisado); if((!isNaN(totalAceptadoRevisado) && totalAceptadoRevisado !== null) || totalAceptadoRevisado === 0) {
AutoNumeric.getAutoNumericElement($('#total_aceptado_revisado')[0]).set(totalAceptadoRevisado);
}
$('#aprobado_by_at').html(response.data.aprobado_by_at); $('#aprobado_by_at').html(response.data.aprobado_by_at);
@ -421,7 +429,7 @@ class PresupuestoAdminEdit {
self.lineasPresupuesto.cargarDatos(response.data.lineasPresupuesto); self.lineasPresupuesto.cargarDatos(response.data.lineasPresupuesto);
self.servicios.cargar(response.data.servicios); self.servicios.cargar(response.data.servicios);
self.envios.cargar(response.data.direcciones); self.envios.cargar(response.data.direcciones, response.data.direccionesFP);
self.comparador.cargarDatos(response.data.comparador); self.comparador.cargarDatos(response.data.comparador);

View File

@ -1,5 +1,5 @@
import ClassSelect from '../../../components/select2.js';
import { getToken } from '../../../common/common.js'; import { getToken } from '../../../common/common.js';
import ClassSelect from '../../../components/select2.js';
class DatosLibro { class DatosLibro {
@ -63,7 +63,9 @@ class DatosLibro {
this.retractilado = this.domItem.find('#retractilado'); this.retractilado = this.domItem.find('#retractilado');
this.retractilado5 = this.domItem.find('#retractilado5'); this.retractilado5 = this.domItem.find('#retractilado5');
this.prototipo = this.domItem.find('#prototipo'); this.prototipo = this.domItem.find('#prototipo');
this.prototipo_2 = this.domItem.find('#prototipo_2');
this.ferro = this.domItem.find('#ferro'); this.ferro = this.domItem.find('#ferro');
this.ferro_2 = this.domItem.find('#ferro_2');
this.ferroDigital = this.domItem.find('#ferroDigital'); this.ferroDigital = this.domItem.find('#ferroDigital');
this.marcapaginas = this.domItem.find('#marcapaginas'); this.marcapaginas = this.domItem.find('#marcapaginas');
@ -157,7 +159,9 @@ class DatosLibro {
this.retractilado.on('change', this.checkRetractilado.bind(this)); this.retractilado.on('change', this.checkRetractilado.bind(this));
this.retractilado5.on('change', this.checkRetractilado.bind(this)); this.retractilado5.on('change', this.checkRetractilado.bind(this));
this.ferro.on('change', this.changeFerro.bind(this)); this.ferro.on('change', this.changeFerro.bind(this));
this.ferro_2.on('change', this.changeFerro2.bind(this));
this.prototipo.on('change', this.changePrototipo.bind(this)); this.prototipo.on('change', this.changePrototipo.bind(this));
this.prototipo_2.on('change', this.changePrototipo2.bind(this));
this.ferroDigital.on('change', this.changeFerroDigital.bind(this)); this.ferroDigital.on('change', this.changeFerroDigital.bind(this));
this.tamanio.item.on('select2:select', this.changeFormato.bind(this)); this.tamanio.item.on('select2:select', this.changeFormato.bind(this));
@ -190,7 +194,7 @@ class DatosLibro {
changeFaja() { changeFaja() {
if (this._bloqueoCambioFaja) return; if (this._bloqueoCambioFaja) return;
this._bloqueoCambioFaja = true; this._bloqueoCambioFaja = true;
if (this.faja.prop('checked')) { if (this.faja.prop('checked')) {
this.div_faja.removeClass('d-none'); this.div_faja.removeClass('d-none');
@ -246,6 +250,20 @@ class DatosLibro {
if (this.ferro.prop('checked')) { if (this.ferro.prop('checked')) {
$(document).trigger('add-servicio-lineas', 'ferro'); $(document).trigger('add-servicio-lineas', 'ferro');
this.ferro_2.prop('checked', false);
$(document).trigger('remove-servicio-lineas', 'ferro_2');
this.prototipo.prop('checked', false);
$(document).trigger('remove-servicio-lineas', 'prototipo_2');
this.prototipo_2.prop('checked', false);
$(document).trigger('remove-servicio-lineas', 'prototipo');
$('.datos-envio-fp-1').removeClass('d-none');
$('.datos-envio-fp-2').addClass('d-none');
$('.check-direccion-fp').prop('checked', false);
$('.check-direccion-fp-2').prop('checked', false);
const table_2 = $('#tableOfDireccionesEnvioFP2').DataTable();
table_2.clear().draw();
const table = $('#tableOfDireccionesEnvioFP1').DataTable();
table.columns.adjust().draw();
$(document).trigger('update-presupuesto', { $(document).trigger('update-presupuesto', {
update_lineas: false, update_lineas: false,
update_servicios: false, update_servicios: false,
@ -256,25 +274,63 @@ class DatosLibro {
} }
else { else {
$(document).trigger('remove-servicio-lineas', 'ferro'); $(document).trigger('remove-servicio-lineas', 'ferro');
if (!this.prototipo.prop('checked')) { const table = $('#tableOfDireccionesEnvioFP1').DataTable();
const table = $('#tableOfDireccionesEnvio').DataTable(); table.clear().draw();
const rows = table.rows().data(); $('.datos-envio-fp-1').addClass('d-none');
for (let i = 0; i < rows.length; i++) { $(document).trigger('update-presupuesto', {
const rowData = rows[i]; update_lineas: false,
if (rowData.is_ferro_prototipo == 1) { update_servicios: false,
table.rows(i).remove(); update_envios: true,
table.draw(); update_resumen: true,
break; update_tiradas_alternativas: true
} });
} }
$(document).trigger('update-presupuesto', { }
update_lineas: false,
update_servicios: false, changeFerro2() {
update_envios: true,
update_resumen: true, if (this.cargando)
update_tiradas_alternativas: true return;
});
} if (this.ferro_2.prop('checked')) {
$(document).trigger('add-servicio-lineas', 'ferro_2');
this.ferro.prop('checked', false);
$(document).trigger('remove-servicio-lineas', 'ferro');
this.prototipo.prop('checked', false);
$(document).trigger('remove-servicio-lineas', 'prototipo_2');
this.prototipo_2.prop('checked', false);
$(document).trigger('remove-servicio-lineas', 'prototipo');
$('.datos-envio-fp-1').removeClass('d-none');
$('.datos-envio-fp-2').removeClass('d-none');
$('.check-direccion-fp').prop('checked', false);
$('.check-direccion-fp-2').prop('checked', false);
const table = $('#tableOfDireccionesEnvioFP1').DataTable();
table.columns.adjust().draw();
const table_2 = $('#tableOfDireccionesEnvioFP2').DataTable();
table_2.columns.adjust().draw();
$(document).trigger('update-presupuesto', {
update_lineas: false,
update_servicios: false,
update_envios: true,
update_resumen: false,
update_tiradas_alternativas: false
});
}
else {
$(document).trigger('remove-servicio-lineas', 'ferro_2');
const table = $('#tableOfDireccionesEnvioFP1').DataTable();
table.clear().draw();
const table_2 = $('#tableOfDireccionesEnvioFP2').DataTable();
table_2.clear().draw();
$('.datos-envio-fp-1').addClass('d-none');
$('.datos-envio-fp-2').addClass('d-none');
$(document).trigger('update-presupuesto', {
update_lineas: false,
update_servicios: false,
update_envios: true,
update_resumen: true,
update_tiradas_alternativas: true
});
} }
} }
@ -298,6 +354,21 @@ class DatosLibro {
if (this.prototipo.prop('checked')) { if (this.prototipo.prop('checked')) {
$(document).trigger('add-servicio-lineas', 'prototipo'); $(document).trigger('add-servicio-lineas', 'prototipo');
this.ferro.prop('checked', false);
$(document).trigger('remove-servicio-lineas', 'ferro');
this.ferro_2.prop('checked', false);
$(document).trigger('remove-servicio-lineas', 'ferro_2');
this.prototipo_2.prop('checked', false);
$(document).trigger('remove-servicio-lineas', 'prototipo_2');
$('.datos-envio-fp-1').removeClass('d-none');
$('.datos-envio-fp-2').addClass('d-none');
$('.check-direccion-fp').prop('checked', false);
$('.check-direccion-fp-2').prop('checked', false);
const table = $('#tableOfDireccionesEnvioFP1').DataTable();
table.columns.adjust().draw();
const table_2 = $('#tableOfDireccionesEnvioFP2').DataTable();
table_2.clear().draw();
table_2.columns.adjust().draw();
$(document).trigger('update-presupuesto', { $(document).trigger('update-presupuesto', {
update_lineas: false, update_lineas: false,
update_servicios: false, update_servicios: false,
@ -308,28 +379,64 @@ class DatosLibro {
} }
else { else {
$(document).trigger('remove-servicio-lineas', 'prototipo'); $(document).trigger('remove-servicio-lineas', 'prototipo');
if (!this.ferro.prop('checked')) { const table = $('#tableOfDireccionesEnvioFP1').DataTable();
const table = $('#tableOfDireccionesEnvio').DataTable(); table.clear().draw();
const rows = table.rows().data(); $('.datos-envio-fp-1').addClass('d-none');
for (let i = 0; i < rows.length; i++) { $(document).trigger('update-presupuesto', {
const rowData = rows[i]; update_lineas: false,
if (rowData.is_ferro_prototipo == 1) { update_servicios: false,
table.rows(i).remove(); update_envios: true,
table.draw(); update_resumen: true,
break; update_tiradas_alternativas: true
} });
}
$(document).trigger('update-presupuesto', {
update_lineas: false,
update_servicios: false,
update_envios: true,
update_resumen: true,
update_tiradas_alternativas: true
});
}
} }
} }
changePrototipo2() {
if (this.cargando)
return;
if (this.prototipo_2.prop('checked')) {
$(document).trigger('add-servicio-lineas', 'prototipo_2');
this.ferro.prop('checked', false);
$(document).trigger('remove-servicio-lineas', 'ferro');
this.ferro_2.prop('checked', false);
$(document).trigger('remove-servicio-lineas', 'ferro_2');
this.prototipo.prop('checked', false);
$(document).trigger('remove-servicio-lineas', 'prototipo');
$('.datos-envio-fp-1').removeClass('d-none');
$('.datos-envio-fp-2').removeClass('d-none');
const table = $('#tableOfDireccionesEnvioFP1').DataTable();
table.columns.adjust().draw();
const table_2 = $('#tableOfDireccionesEnvioFP2').DataTable();
table_2.columns.adjust().draw();
$('.check-direccion-fp-2').prop('checked', false);
$(document).trigger('update-presupuesto', {
update_lineas: false,
update_servicios: false,
update_envios: true,
update_resumen: false,
update_tiradas_alternativas: false
});
}
else {
$(document).trigger('remove-servicio-lineas', 'prototipo_2');
const table = $('#tableOfDireccionesEnvioFP1').DataTable();
table.clear().draw();
const table_2 = $('#tableOfDireccionesEnvioFP2').DataTable();
table_2.clear().draw();
$('.datos-envio-fp-1').addClass('d-none');
$('.datos-envio-fp-2').addClass('d-none');
$(document).trigger('update-presupuesto', {
update_lineas: false,
update_servicios: false,
update_envios: true,
update_resumen: true,
update_tiradas_alternativas: true
});
}
}
checkRetractilado(event) { checkRetractilado(event) {
@ -587,6 +694,8 @@ class DatosLibro {
this.actualizarLimitesPaginas(); this.actualizarLimitesPaginas();
} }
this.calcularSolapas();
} }
updateComparador() { updateComparador() {
@ -763,7 +872,9 @@ class DatosLibro {
this.retractilado.prop('checked', datos.retractilado); this.retractilado.prop('checked', datos.retractilado);
this.retractilado5.prop('checked', datos.retractilado5); this.retractilado5.prop('checked', datos.retractilado5);
this.prototipo.prop('checked', datos.prototipo); this.prototipo.prop('checked', datos.prototipo);
this.prototipo_2.prop('checked', datos.prototipo2);
this.ferro.prop('checked', datos.ferro); this.ferro.prop('checked', datos.ferro);
this.ferro_2.prop('checked', datos.ferro2);
this.ferroDigital.prop('checked', datos.ferroDigital); this.ferroDigital.prop('checked', datos.ferroDigital);
this.marcapaginas.prop('checked', datos.marcapaginas); this.marcapaginas.prop('checked', datos.marcapaginas);
} }

View File

@ -14,11 +14,15 @@ class Envios {
this.recogerTaller = $('#recoger_en_taller'); this.recogerTaller = $('#recoger_en_taller');
this.table = null; this.table = null;
this.tableFP1 = null;
this.tableFP2 = null;
this.direccionesClienteForm = new ClassSelect($('#add_clientedAdd'), '/misdirecciones/getSelect2', 'Seleccione una direccion', false, {}); this.direccionesClienteForm = new ClassSelect($('#add_clientedAdd'), '/misdirecciones/getSelect2', 'Seleccione una direccion', false, {});
this.paisesClienteForm = new ClassSelect($('#add_pais_id'), '/configuracion/paises/menuitems2', 'Seleccione país', false, {}); this.paisesClienteForm = new ClassSelect($('#add_pais_id'), '/configuracion/paises/menuitems2', 'Seleccione país', false, {});
this.modalYesNo = null; this.modalYesNo = null;
this.insertarEnvio = $('#insertar_direccion'); this.insertarEnvio = $('#insertar_direccion');
this.insertarEnvioFP1 = $('#insertar_direccion_fp1');
this.insertarEnvioFP2 = $('#insertar_direccion_fp2');
this.actionBtns_direcciones = function (data) { this.actionBtns_direcciones = function (data) {
return ` return `
@ -71,7 +75,6 @@ class Envios {
}, },
{ 'data': 'margen', render: function (data, type, row) { return Math.round(data) } }, { 'data': 'margen', render: function (data, type, row) { return Math.round(data) } },
{ 'data': 'entregaPieCalle' }, { 'data': 'entregaPieCalle' },
{ 'data': 'is_ferro_prototipo' },
{ {
data: function (row, type, set, meta) { data: function (row, type, set, meta) {
return ` return `
@ -79,7 +82,7 @@ class Envios {
<a href="javascript:void(0);"><i class="ti ti-trash ti-sm tiradas-alternativas btn-delete-envio mx-2"></i></a> <a href="javascript:void(0);"><i class="ti ti-trash ti-sm tiradas-alternativas btn-delete-envio mx-2"></i></a>
`; `;
}, },
className: 'row-edit dt-center' className: 'row-edit'
} }
], ],
columnDefs: [ columnDefs: [
@ -87,10 +90,12 @@ class Envios {
{ {
orderable: false, orderable: false,
searchable: false, searchable: false,
// all columns
targets: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14], targets: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14],
//targets: [$('#tableOfDireccionesEnvio').find("tr:first th").length - 1]
}, },
{
targets: '_all', // Targets all columns
className: 'dt-center' // Adds the 'dt-center' class
}
], ],
language: { language: {
url: "/themes/vuexy/vendor/libs/datatables-sk/plugins/i18n/es-ES.json" url: "/themes/vuexy/vendor/libs/datatables-sk/plugins/i18n/es-ES.json"
@ -98,7 +103,7 @@ class Envios {
drawCallback: function (settings) { drawCallback: function (settings) {
const boolCols = [15, 16]; const boolCols = [15];
for (let coln of boolCols) { for (let coln of boolCols) {
self.table.column(coln, { page: 'current' }).nodes().each(function (cell, i) { self.table.column(coln, { page: 'current' }).nodes().each(function (cell, i) {
cell.innerHTML = cell.innerHTML == '1' ? '<i class="ti ti-check"></i>' : ''; cell.innerHTML = cell.innerHTML == '1' ? '<i class="ti ti-check"></i>' : '';
@ -115,20 +120,188 @@ class Envios {
$("#costeEnvios").text(total.toFixed(2) + "€" || "0€"); $("#costeEnvios").text(total.toFixed(2) + "€" || "0€");
self.check_unidades_enviadas(null, self.recogerTaller.prop('checked')); self.check_unidades_enviadas(null, self.recogerTaller.prop('checked'));
this.api().columns.adjust();
}
});
this.tableFP1 = $('#tableOfDireccionesEnvioFP1').DataTable({
draw: 5,
serverSide: false,
processing: true,
autoWidth: true,
responsive: true,
pageLength: 20,
lengthChange: false,
searching: false,
paging: false,
info: false,
scrollX: true,
ordering: false,
columns: [
{ 'data': 'tarifa_id' },
{ 'data': 'cantidad' },
{ 'data': 'peso' },
{ 'data': 'att' },
{ 'data': 'email' },
{ 'data': 'direccion' },
{ 'data': 'cp' },
{ 'data': 'municipio' },
{ 'data': 'pais' },
{ 'data': 'pais_id', visible: false },
{ 'data': 'telefono' },
{ 'data': 'proveedor' },
{ 'data': 'proveedor_id', visible: false },
{
'data': 'precio', render: function (data, type, row) {
let coste = parseFloat(data).toFixed(2);
let precio = parseFloat(data * (1 + row.margen / 100.0)).toFixed(2);
return coste + "/" + precio;
}
},
{ 'data': 'margen', render: function (data, type, row) { return Math.round(data) } },
{ 'data': 'entregaPieCalle' },
{
data: function (row, type, set, meta) {
return `
<a href="javascript:void(0);"><i class="ti ti-trash ti-sm tiradas-alternativas btn-delete-envio mx-2"></i></a>
`;
},
className: 'row-edit'
}
],
columnDefs: [
{
orderable: false,
searchable: false,
targets: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14],
},
{
targets: '_all', // Targets all columns
className: 'dt-center' // Adds the 'dt-center' class
}
],
language: {
url: "/themes/vuexy/vendor/libs/datatables-sk/plugins/i18n/es-ES.json"
},
drawCallback: function (settings) {
const boolCols = [15];
for (let coln of boolCols) {
self.tableFP1.column(coln, { page: 'current' }).nodes().each(function (cell, i) {
cell.innerHTML = cell.innerHTML == '1' ? '<i class="ti ti-check"></i>' : '';
});
}
this.api().columns.adjust();
if (self.tableFP1.rows().count() > 0) {
$('#rowInsertarEnvioFP1').addClass('d-none');
} else {
$('#rowInsertarEnvioFP1').removeClass('d-none');
}
}
});
this.tableFP2 = $('#tableOfDireccionesEnvioFP2').DataTable({
draw: 5,
serverSide: false,
processing: true,
autoWidth: true,
responsive: true,
pageLength: 20,
lengthChange: false,
searching: false,
paging: false,
info: false,
scrollX: true,
ordering: false,
columns: [
{ 'data': 'tarifa_id' },
{ 'data': 'cantidad' },
{ 'data': 'peso' },
{ 'data': 'att' },
{ 'data': 'email' },
{ 'data': 'direccion' },
{ 'data': 'cp' },
{ 'data': 'municipio' },
{ 'data': 'pais' },
{ 'data': 'pais_id', visible: false },
{ 'data': 'telefono' },
{ 'data': 'proveedor' },
{ 'data': 'proveedor_id', visible: false },
{
'data': 'precio', render: function (data, type, row) {
let coste = parseFloat(data).toFixed(2);
let precio = parseFloat(data * (1 + row.margen / 100.0)).toFixed(2);
return coste + "/" + precio;
}
},
{ 'data': 'margen', render: function (data, type, row) { return Math.round(data) } },
{ 'data': 'entregaPieCalle' },
{
data: function (row, type, set, meta) {
return `
<a href="javascript:void(0);"><i class="ti ti-trash ti-sm tiradas-alternativas btn-delete-envio mx-2"></i></a>
`;
},
className: 'row-edit dt-center'
}
],
columnDefs: [
{
orderable: false,
searchable: false,
targets: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14],
},
{
targets: '_all', // Targets all columns
className: 'dt-center' // Adds the 'dt-center' class
}
],
language: {
url: "/themes/vuexy/vendor/libs/datatables-sk/plugins/i18n/es-ES.json"
},
drawCallback: function (settings) {
const boolCols = [15];
for (let coln of boolCols) {
self.tableFP2.column(coln, { page: 'current' }).nodes().each(function (cell, i) {
cell.innerHTML = cell.innerHTML == '1' ? '<i class="ti ti-check"></i>' : '';
});
}
this.api().columns.adjust();
if (self.tableFP2.rows().count() > 0) {
$('#rowInsertarEnvioFP2').addClass('d-none');
} else {
$('#rowInsertarEnvioFP2').removeClass('d-none');
}
} }
}); });
$(document).on('click', '.btn-delete-envio', function () { $(document).on('click', '.btn-delete-envio', function () {
const rowId = $(this).closest('td').parent()[0].sectionRowIndex; const rowId = $(this).closest('td').parent()[0].sectionRowIndex;
self.table.row(rowId).remove().draw(); const table = $(this).closest('table').DataTable();
$(document).trigger('update-presupuesto', { table.row(rowId).remove().draw();
update_lineas: false, if (table.table().node().id == 'tableOfDireccionesEnvios') {
update_servicios: false, $(document).trigger('update-presupuesto', {
update_envios: false, update_lineas: false,
update_resumen: true, update_servicios: false,
update_tiradas_alternativas: true update_envios: false,
}); update_resumen: true,
update_tiradas_alternativas: true
});
}
else if (table.table().node().id == 'tableOfDireccionesEnvioFP1') {
$('#rowInsertarEnvioFP1').removeClass('d-none');
}
else if (table.table().node().id == 'tableOfDireccionesEnvioFP2') {
$('#rowInsertarEnvioFP2').removeClass('d-none');
}
}); });
$(document).on('click', '.btn-edit-envio', function () { $(document).on('click', '.btn-edit-envio', function () {
@ -165,19 +338,7 @@ class Envios {
$('#add_telefono').val(data.telefono) $('#add_telefono').val(data.telefono)
$('#add_cantidad').val(data.cantidad) $('#add_cantidad').val(data.cantidad)
$('#add_entregaPieCalle').prop('checked', data.entregaPieCalle == 1 ? true : false) $('#add_entregaPieCalle').prop('checked', data.entregaPieCalle == 1 ? true : false)
$('#dirFerroProto').prop('checked', data.is_ferro_prototipo == 1 ? true : false)
if (data.is_ferro_prototipo == 1) {
$('#add_cantidad').val(1);
$('#add_cantidad').attr('disabled', true);
$('#dirFerroProto').prop('disabled', true);
$('#direccionFerroProto').removeClass('d-none');
}
else {
$('#add_cantidad').attr('disabled', false);
$('#dirFerroProto').prop('disabled', false);
$('#direccionFerroProto').addClass('d-none');
}
self.direccionesClienteForm.setParams({ 'cliente_id': () => $("#clienteId").select2('data')[0].id }); self.direccionesClienteForm.setParams({ 'cliente_id': () => $("#clienteId").select2('data')[0].id });
self.direccionesClienteForm.init(); self.direccionesClienteForm.init();
@ -215,6 +376,8 @@ class Envios {
this.insertarEnvio.on('click', this.addEnvio.bind(this)); this.insertarEnvio.on('click', this.addEnvio.bind(this));
this.insertarEnvioFP1.on('click', this.addEnvio.bind(this, 'fp1'));
this.insertarEnvioFP2.on('click', this.addEnvio.bind(this, 'fp2'));
this.initFormularioDireccionEnvio(); this.initFormularioDireccionEnvio();
@ -225,12 +388,17 @@ class Envios {
$(document).trigger('update-envios-completed'); $(document).trigger('update-envios-completed');
}); });
$(document).on('ckeck-lineas-envios', this.check_unidades_enviadas.bind(this)); $(document).on('ckeck-lineas-envios', this.check_unidades_enviadas.bind(this));
$('#sameAddPrincipalFP1').on('change', this.sameAddPrincipalFP1.bind(this));
$('#sameAddPrincipalFP2').on('change', this.sameAddPrincipalFP2.bind(this));
$('#sameAddFP1').on('change', this.sameAddFP1.bind(this));
} }
addEnvio() { addEnvio(table = '') {
$("#addressForm").attr('action', 'create'); $("#addressForm").attr('action', 'create');
let newAddDialog = $("#addressForm"); let newAddDialog = $("#addressForm");
this.direccionesClienteForm.setParams({ 'cliente_id': () => $("#clienteId").select2('data')[0].id }); this.direccionesClienteForm.setParams({ 'cliente_id': () => $("#clienteId").select2('data')[0].id });
this.direccionesClienteForm.init(); this.direccionesClienteForm.init();
@ -243,34 +411,27 @@ class Envios {
}) })
let cantidad_total = 0; let cantidad_total = 0;
let hasFerroPrototipo = false;
$('#tableOfDireccionesEnvio').DataTable().rows().every(function (rowIdx, tableLoop, rowLoop) { $('#tableOfDireccionesEnvio').DataTable().rows().every(function (rowIdx, tableLoop, rowLoop) {
let data = this.data(); let data = this.data();
if (data.is_ferro_prototipo == 0) cantidad_total += parseInt(data.cantidad);
cantidad_total += parseInt(data.cantidad);
else
hasFerroPrototipo = true;
}); });
const restante = parseInt($('#tirada').val()) - cantidad_total; const restante = parseInt($('#tirada').val()) - cantidad_total;
$('#add_cantidad').attr('max-value', restante); $('#add_cantidad').attr('max-value', restante);
$('#add_cantidad').val(restante > 0 ? restante : 0); $('#add_cantidad').val(restante > 0 ? restante : 0);
if (hasFerroPrototipo) {
$('#dirFerroProto').prop('checked', false); if (table != '') {
$('#direccionFerroProto').addClass('d-none'); $("#addressForm").attr('data-table', table);
$('#add_cantidad').attr('disabled', false); $('#add_entregaPieCalle').prop('disabled', true);
$('#add_cantidad').val(1);
$('#add_cantidad').prop('disabled', true);
} }
else { else {
if (restante == 0) { $("#addressForm").attr('data-table', '');
$('#direccionFerroProto').removeClass('d-none'); $('#add_entregaPieCalle').prop('disabled', false);
$('#dirFerroProto').prop('checked', true); $('#add_cantidad').prop('disabled', false);
$('#dirFerroProto').prop('disabled', true);
$('#add_cantidad').attr('disabled', true);
$('#add_cantidad').val(1);
}
} }
newAddDialog.modal('show'); newAddDialog.modal('show');
} }
@ -316,18 +477,66 @@ class Envios {
proveedor: data.proveedor, proveedor: data.proveedor,
proveedor_id: data.proveedor_id, proveedor_id: data.proveedor_id,
entregaPieCalle: data.entregaPieCalle, entregaPieCalle: data.entregaPieCalle,
is_ferro_prototipo: data.is_ferro_prototipo,
}) })
}); });
await $('#tableOfDireccionesEnvioFP1').DataTable().rows().every(async function (rowIdx, tableLoop, rowLoop) {
}) var data = this.data();
await $.post('/presupuestos/presupuestodirecciones/add',
{
presupuesto_id: id,
tarifa_id: data.tarifa_id,
cantidad: data.cantidad,
peso: data.peso,
att: data.att,
email: data.email,
direccion: data.direccion,
pais_id: data.pais_id,
provincia: data.provincia,
municipio: data.municipio,
cp: data.cp,
telefono: data.telefono,
precio: data.precio,
margen: data.margen,
proveedor: data.proveedor,
proveedor_id: data.proveedor_id,
entregaPieCalle: data.entregaPieCalle,
is_ferro_prototipo: 1,
num_ferro_prototipo: 1
})
});
await $('#tableOfDireccionesEnvioFP2').DataTable().rows().every(async function (rowIdx, tableLoop, rowLoop) {
var data = this.data();
await $.post('/presupuestos/presupuestodirecciones/add',
{
presupuesto_id: id,
tarifa_id: data.tarifa_id,
cantidad: data.cantidad,
peso: data.peso,
att: data.att,
email: data.email,
direccion: data.direccion,
pais_id: data.pais_id,
provincia: data.provincia,
municipio: data.municipio,
cp: data.cp,
telefono: data.telefono,
precio: data.precio,
margen: data.margen,
proveedor: data.proveedor,
proveedor_id: data.proveedor_id,
entregaPieCalle: data.entregaPieCalle,
is_ferro_prototipo: 1,
num_ferro_prototipo: 2
})
});
});
} }
async updateTiradaBase() { async updateTiradaBase() {
if($('#noEnvioBase').val() == 1) if ($('#noEnvioBase').val() == 1)
return; return;
const self = this; const self = this;
@ -421,13 +630,12 @@ class Envios {
'precio': datos_tarifa.precio.toFixed(2), 'precio': datos_tarifa.precio.toFixed(2),
'margen': datos_tarifa.margen, 'margen': datos_tarifa.margen,
'entregaPieCalle': rowData.entregaPieCalle, 'entregaPieCalle': rowData.entregaPieCalle,
'is_ferro_prototipo': rowData.is_ferro_prototipo,
'actionBtns_direcciones': self.actionBtns_direcciones, 'actionBtns_direcciones': self.actionBtns_direcciones,
}) })
.draw(); .draw();
self.check_unidades_enviadas(null,null); self.check_unidades_enviadas(null, null);
$(document).trigger('update-presupuesto', { $(document).trigger('update-presupuesto', {
update_lineas: false, update_lineas: false,
@ -528,6 +736,7 @@ class Envios {
$('#add_telefono').val(""); $('#add_telefono').val("");
$('#add_saveDirection').prop('checked', false) $('#add_saveDirection').prop('checked', false)
$('#add_entregaPieCalle').prop('checked', false) $('#add_entregaPieCalle').prop('checked', false)
$('#addressForm').attr('data-table', '');
}); });
$('#cancelAdd').on('click', function () { $('#cancelAdd').on('click', function () {
@ -591,34 +800,86 @@ class Envios {
tarifa_final.cantidad = parseInt($('#add_cantidad').val()) tarifa_final.cantidad = parseInt($('#add_cantidad').val())
tarifa_final.peso = peso_envio tarifa_final.peso = peso_envio
const sourceTable = $('#addressForm').attr('data-table');
self.table.row if (sourceTable === '') {
.add({ self.table.row
'tarifa_id': tarifa_final.id, .add({
'cantidad': tarifa_final.cantidad, 'tarifa_id': tarifa_final.id,
'peso': tarifa_final.peso.toFixed(3), 'cantidad': tarifa_final.cantidad,
'att': $('#add_att').val(), 'peso': tarifa_final.peso.toFixed(3),
'email': $('#add_email').val(), 'att': $('#add_att').val(),
'direccion': $('#add_direccion').val(), 'email': $('#add_email').val(),
'cp': $('#add_cp').val(), 'direccion': $('#add_direccion').val(),
'municipio': $('#add_municipio').val(), 'cp': $('#add_cp').val(),
'provincia': $('#add_provincia').val(), 'municipio': $('#add_municipio').val(),
'pais_id': $('#add_pais_id').select2('data')[0].id, 'provincia': $('#add_provincia').val(),
'pais': $('#add_pais_id').select2('data')[0].text, 'pais_id': $('#add_pais_id').select2('data')[0].id,
'telefono': $('#add_telefono').val(), 'pais': $('#add_pais_id').select2('data')[0].text,
'proveedor': tarifa_final.proveedor, 'telefono': $('#add_telefono').val(),
'proveedor_id': tarifa_final.proveedor_id, 'proveedor': tarifa_final.proveedor,
'precio': tarifa_final.precio, 'proveedor_id': tarifa_final.proveedor_id,
'margen': tarifa_final.margen, 'precio': tarifa_final.precio,
'entregaPieCalle': $('#add_entregaPieCalle').is(":checked") ? 1 : 0, 'margen': tarifa_final.margen,
'is_ferro_prototipo': $('#dirFerroProto').is(":checked") ? 1 : 0, 'entregaPieCalle': $('#add_entregaPieCalle').is(":checked") ? 1 : 0,
'actionBtns_direcciones': ` 'actionBtns_direcciones': `
<span class="edit-add"><a href="javascript:void(0);"><i class="ti ti-pencil ti-sm btn-edit-envio mx-2"></i></a></span> <span class="edit-add"><a href="javascript:void(0);"><i class="ti ti-pencil ti-sm btn-edit-envio mx-2"></i></a></span>
<a href="javascript:void(0);"><i class="ti ti-trash ti-sm tiradas-alternativas btn-delete-envio mx-2"></i></a> <a href="javascript:void(0);"><i class="ti ti-trash ti-sm tiradas-alternativas btn-delete-envio mx-2"></i></a>
`, `,
}) })
.draw(); .draw();
}
else if (sourceTable === 'fp1') {
self.tableFP1.row
.add({
'tarifa_id': tarifa_final.id,
'cantidad': tarifa_final.cantidad,
'peso': tarifa_final.peso.toFixed(3),
'att': $('#add_att').val(),
'email': $('#add_email').val(),
'direccion': $('#add_direccion').val(),
'cp': $('#add_cp').val(),
'municipio': $('#add_municipio').val(),
'provincia': $('#add_provincia').val(),
'pais_id': $('#add_pais_id').select2('data')[0].id,
'pais': $('#add_pais_id').select2('data')[0].text,
'telefono': $('#add_telefono').val(),
'proveedor': tarifa_final.proveedor,
'proveedor_id': tarifa_final.proveedor_id,
'precio': 0,
'margen': 0,
'entregaPieCalle': 0,
'actionBtns_direcciones': `
<a href="javascript:void(0);"><i class="ti ti-trash ti-sm tiradas-alternativas btn-delete-envio mx-2"></i></a>
`,
})
.draw();
}
else {
self.tableFP2.row
.add({
'tarifa_id': tarifa_final.id,
'cantidad': tarifa_final.cantidad,
'peso': tarifa_final.peso.toFixed(3),
'att': $('#add_att').val(),
'email': $('#add_email').val(),
'direccion': $('#add_direccion').val(),
'cp': $('#add_cp').val(),
'municipio': $('#add_municipio').val(),
'provincia': $('#add_provincia').val(),
'pais_id': $('#add_pais_id').select2('data')[0].id,
'pais': $('#add_pais_id').select2('data')[0].text,
'telefono': $('#add_telefono').val(),
'proveedor': tarifa_final.proveedor,
'proveedor_id': tarifa_final.proveedor_id,
'precio': 0,
'margen': 0,
'entregaPieCalle': 0,
'actionBtns_direcciones': `
<a href="javascript:void(0);"><i class="ti ti-trash ti-sm tiradas-alternativas btn-delete-envio mx-2"></i></a>
`,
})
.draw();
}
// Se guarda la dirección // Se guarda la dirección
if ($('#add_saveDirection').is(":checked") && if ($('#add_saveDirection').is(":checked") &&
@ -703,13 +964,26 @@ class Envios {
return returnValue return returnValue
} }
cargar(datos) { cargar(datos, datosFP) {
if (datos.entrega_taller) { if (datos.entrega_taller) {
this.recogerTaller.prop('checked', true); this.recogerTaller.prop('checked', true);
} }
else { else {
this.table.rows.add(datos).draw(); this.table.rows.add(datos).draw();
} }
if (datosFP.fp1.length > 0) {
this.tableFP1.rows.add(datosFP.fp1).draw();
$('#rowInsertarEnvioFP1').addClass('d-none');
}
if (datosFP.fp2.length > 0) {
this.tableFP2.rows.add(datosFP.fp2).draw();
$('#rowInsertarEnvioFP2').addClass('d-none');
}
if(datosFP.checkboxes){
$('#sameAddPrincipalFP1').prop('checked', datosFP.checkboxes.addFP1isAddMain == "1"? true: false);
$('#sameAddPrincipalFP2').prop('checked', datosFP.checkboxes.addFP2isAddMain == "1"? true: false);
$('#sameAddFP1').prop('checked', datosFP.checkboxes.addFP2isaddFP1 == "1"? true: false);
}
} }
check_unidades_enviadas(event, recogerTaller = null) { check_unidades_enviadas(event, recogerTaller = null) {
@ -719,12 +993,8 @@ class Envios {
} }
let cantidad_total = 0 let cantidad_total = 0
let hasFerroPrototipo = false
this.table.rows().every(function (rowIdx, tableLoop, rowLoop) { this.table.rows().every(function (rowIdx, tableLoop, rowLoop) {
if (this.data().is_ferro_prototipo == 0) cantidad_total += parseInt(this.data().cantidad);
cantidad_total += parseInt(this.data().cantidad);
else
hasFerroPrototipo = true;
}); });
const tirada = parseInt($('#tirada').val()); const tirada = parseInt($('#tirada').val());
@ -745,14 +1015,59 @@ class Envios {
this.insertarEnvio.removeClass('d-none'); this.insertarEnvio.removeClass('d-none');
return false; return false;
} }
if (($('#ferro').is(':checked') || $('#prototipo').is(':checked')) && !hasFerroPrototipo)
this.insertarEnvio.removeClass('d-none');
else
this.insertarEnvio.addClass('d-none');
$('#alert-envios').html(htmlString); $('#alert-envios').html(htmlString);
return true; return true;
} }
sameAddPrincipalFP1() {
this.tableFP1.clear().draw();
if ($('#sameAddPrincipalFP1').prop('checked')) {
if (this.table.rows().count() > 0) {
let data = this.table.row(0).data();
data.cantidad = 1; // Set unidades to 1
data.precio = 0;
data.margen = 0;
data.peso = this.get_peso_libro() / 1000;
this.tableFP1.row.add(data).draw();
}
}
}
sameAddPrincipalFP2() {
$('#sameAddFP1').prop('checked', false);
this.tableFP2.clear().draw();
if ($('#sameAddPrincipalFP2').prop('checked')) {
if (this.table.rows().count() > 0) {
let data = this.table.row(0).data();
data.cantidad = 1; // Set unidades to 1
data.precio = 0;
data.margen = 0;
data.peso = this.get_peso_libro() / 1000;
this.tableFP2.row.add(data).draw();
}
}
}
sameAddFP1() {
this.tableFP2.clear().draw();
$('#sameAddPrincipalFP2').prop('checked', false);
if ($('#sameAddFP1').prop('checked')) {
if (this.tableFP1.rows().count() > 0) {
let data = this.tableFP1.row(0).data();
data.cantidad = 1; // Set unidades to 1
data.precio = 0;
data.margen = 0;
data.peso = this.get_peso_libro() / 1000;
this.tableFP2.row.add(data).draw();
}
}
}
} }
export default Envios; export default Envios;

View File

@ -119,6 +119,11 @@ class Servicios {
if (!this.checkServiceInTable(this.serviciosExtra.table, id)) if (!this.checkServiceInTable(this.serviciosExtra.table, id))
this.serviciosExtra.getPresupuestoExtra(id); this.serviciosExtra.getPresupuestoExtra(id);
} }
else if (servicio == 'ferro_2') {
const id = $('#ferro_2').attr('service-id');
if (!this.checkServiceInTable(this.serviciosExtra.table, id))
this.serviciosExtra.getPresupuestoExtra(id);
}
else if (servicio == 'ferroDigital') { else if (servicio == 'ferroDigital') {
const id = $('#ferroDigital').attr('service-id'); const id = $('#ferroDigital').attr('service-id');
if (!this.checkServiceInTable(this.serviciosExtra.table, id)) if (!this.checkServiceInTable(this.serviciosExtra.table, id))
@ -129,6 +134,11 @@ class Servicios {
if (!this.checkServiceInTable(this.serviciosExtra.table, id)) if (!this.checkServiceInTable(this.serviciosExtra.table, id))
this.serviciosExtra.getPresupuestoExtra(id); this.serviciosExtra.getPresupuestoExtra(id);
} }
else if (servicio == 'prototipo_2') {
const id = $('#prototipo_2').attr('service-id');
if (!this.checkServiceInTable(this.serviciosExtra.table, id))
this.serviciosExtra.getPresupuestoExtra(id);
}
else if (servicio == 'retractilado') { else if (servicio == 'retractilado') {
const id = $('#retractilado').attr('service-id'); const id = $('#retractilado').attr('service-id');
if (!this.checkServiceInTable(this.serviciosAcabado.table, id)) if (!this.checkServiceInTable(this.serviciosAcabado.table, id))
@ -201,8 +211,18 @@ class Servicios {
} }
}); });
} }
else if (servicio == 'ferro_2') {
if (servicio == 'ferroDigital') { const id = $('#ferro_2').attr('service-id');
this.serviciosExtra.table.rows().every(function () {
let data = this.data();
if (data.tarifa_id == id) {
this.remove();
self.serviciosExtra.table.draw();
return;
}
});
}
else if (servicio == 'ferroDigital') {
const id = $('#ferroDigital').attr('service-id'); const id = $('#ferroDigital').attr('service-id');
this.serviciosExtra.table.rows().every(function () { this.serviciosExtra.table.rows().every(function () {
let data = this.data(); let data = this.data();
@ -225,6 +245,17 @@ class Servicios {
} }
}); });
} }
else if (servicio == 'prototipo_2') {
const id = $('#prototipo_2').attr('service-id');
this.serviciosExtra.table.rows().every(function () {
var data = this.data();
if (data.tarifa_id == id) {
this.remove();
self.serviciosExtra.table.draw();
return;
}
});
}
else if (servicio == 'retractilado') { else if (servicio == 'retractilado') {
const id = $('#retractilado').attr('service-id'); const id = $('#retractilado').attr('service-id');
for (let i = this.serviciosAcabado.table.rows().count(); i >= 0; i--) { for (let i = this.serviciosAcabado.table.rows().count(); i >= 0; i--) {

View File

@ -105,27 +105,26 @@ class DatosGenerales {
// check ferro y prototipo // check ferro y prototipo
this.domItem.on('change', 'input[type="checkbox"][data-tarifa-extra-excluyente="1"]', (e) => { this.domItem.on('change', 'input[type="checkbox"][data-tarifa-extra-excluyente="1"]', (e) => {
if (!this.cargando) {
const current = $(e.target);
if (current.is(':checked')) { const current = $(e.target);
this.domItem.find('input[type="checkbox"][data-tarifa-extra-excluyente="1"]')
.not(current)
.prop('checked', false);
if ((current.data('tarifa-nombre')?.toString().toLowerCase() || '').includes('2')) { if (current.is(':checked')) {
$('#direccionesFerroPrototipo2').removeClass('d-none'); this.domItem.find('input[type="checkbox"][data-tarifa-extra-excluyente="1"]')
} .not(current)
$('#direccionesFerroPrototipo').removeClass('d-none'); .prop('checked', false);
if ((current.data('tarifa-nombre')?.toString().toLowerCase() || '').includes('2')) {
$('#direccionesFerroPrototipo2').removeClass('d-none');
} }
else { $('#direccionesFerroPrototipo').removeClass('d-none');
if (this.domItem.find('input[type="checkbox"][data-tarifa-extra-excluyente="1"]').prop('checked').length === 0) { }
else {
if (this.domItem.find('input[type="checkbox"][data-tarifa-extra-excluyente="1"]').prop('checked').length === 0) {
$('#direccionesFerroPrototipo').addClass('d-none'); $('#direccionesFerroPrototipo').addClass('d-none');
$('#divDireccionesFerroPrototipo').empty(); $('#divDireccionesFerroPrototipo').empty();
$('#direccionesFerroPrototipo2').addClass('d-none'); $('#direccionesFerroPrototipo2').addClass('d-none');
$('#divDireccionesFerroPrototipo2').empty(); $('#divDireccionesFerroPrototipo2').empty();
}
} }
} }
}); });
@ -597,6 +596,7 @@ class DatosGenerales {
if (datos.serviciosExtra.includes(tarifaId)) { if (datos.serviciosExtra.includes(tarifaId)) {
$(this).prop('checked', true); $(this).prop('checked', true);
$(this).trigger('change');
} }
}); });
} }
@ -769,7 +769,7 @@ class DatosGenerales {
} }
// Para recalcular el presupuesto // Para recalcular el presupuesto
$('#paginas').trigger('change'); $('.input-paginas').trigger('change');
} }
#handlePaginas() { #handlePaginas() {

View File

@ -105,7 +105,7 @@ class Direcciones {
cargarDatos(datos, datosGenerales) { cargarDatos(datos, datosGenerales, direccionesFP = [], direccionesFPChecks = {}) {
self = this; self = this;
@ -130,7 +130,6 @@ class Direcciones {
}); });
}, 0); }, 0);
$('#tiradaEnvios-' + datosGenerales.selectedTirada).trigger('click'); $('#tiradaEnvios-' + datosGenerales.selectedTirada).trigger('click');
if (datos.entrega_taller == 1) { if (datos.entrega_taller == 1) {
@ -174,6 +173,41 @@ class Direcciones {
this.direcciones.push(tarjeta); this.direcciones.push(tarjeta);
} }
} }
if (direccionesFP.length > 0) {
direccionesFP.forEach(element => {
let divId = "dirEnvio-fp-" + element.num_ferro_prototipo;
let containerId = element.num_ferro_prototipo == 1 ? "#divDireccionesFerroPrototipo" : "#divDireccionesFerroPrototipo2";
let tarjeta = new tarjetaDireccion(containerId,
divId, element, true, element.num_ferro_prototipo);
tarjeta.setUnidades(1);
tarjeta.setEntregaPalets(0);
tarjeta.card.find('.direccion-eliminar').on('click', (event) => {
this.#deleteDireccionFP(event, element.num_ferro_prototipo);
$('.div-direcciones-fp' + element.num_ferro_prototipo).removeClass('d-none');
});
$(containerId).append(tarjeta.card);
if (element.num_ferro_prototipo == 1) {
this.direccionesFP1.push(tarjeta);
}
else {
this.direccionesFP2.push(tarjeta);
}
$('.div-direcciones-fp' + element.num_ferro_prototipo).addClass('d-none');
});
}
if (direccionesFPChecks.addFP1isAddMain && direccionesFPChecks.addFP1isAddMain === "true") {
this.sameAddPrincipalFP1.prop('checked', true);
}
if (direccionesFPChecks.addFP2isFP1 && direccionesFPChecks.addFP2isFP1 === "true") {
this.sameAddFP1.prop('checked', true);
}
else if (direccionesFPChecks.addFP2isAddMain && direccionesFPChecks.addFP2isAddMain === "true") {
this.sameAddPrincipalFP2.prop('checked', true);
}
} catch (e) { } catch (e) {
console.error(e); console.error(e);
$('#loader').modal('hide'); $('#loader').modal('hide');
@ -342,6 +376,10 @@ class Direcciones {
} }
} }
this.#addTarjetaDireccion(this.divDirecciones, this.direcciones, divId, id, unidades, entregaPalets); this.#addTarjetaDireccion(this.divDirecciones, this.direcciones, divId, id, unidades, entregaPalets);
this.calcularPresupuesto = true;
this.divDirecciones.trigger('change');
} catch (e) { } catch (e) {
console.error(e); console.error(e);
@ -356,10 +394,10 @@ class Direcciones {
try { try {
let id = 0; let id = 0;
if( num_ferroPrototipo === 1) { if (num_ferroPrototipo === 1) {
id = this.direccionesClienteFP1.getVal(); id = this.direccionesClienteFP1.getVal();
} }
if( num_ferroPrototipo === 2) { if (num_ferroPrototipo === 2) {
id = this.direccionesClienteFP2.getVal(); id = this.direccionesClienteFP2.getVal();
} }
let unidades = 1; let unidades = 1;
@ -369,16 +407,23 @@ class Direcciones {
let divId = "dirEnvio-FP-" + num_ferroPrototipo; let divId = "dirEnvio-FP-" + num_ferroPrototipo;
let containerId = num_ferroPrototipo === 1 ? "#divDireccionesFerroPrototipo" : "#divDireccionesFerroPrototipo2"; let containerId = num_ferroPrototipo === 1 ? "#divDireccionesFerroPrototipo" : "#divDireccionesFerroPrototipo2";
let arrayName = num_ferroPrototipo === 1 ? this.direccionesFP1 : this.direccionesFP2;
if (num_ferroPrototipo === 1) {
this.direccionesFP1 = [];
}
if (num_ferroPrototipo === 2) {
this.direccionesFP2 = [];
}
this.#addTarjetaDireccion( this.#addTarjetaDireccion(
$(containerId), $(containerId),
arrayName, num_ferroPrototipo === 1 ? this.direccionesFP1 : this.direccionesFP2,
divId, divId,
id, id,
1, false, true, num_ferroPrototipo); 1, false, true, num_ferroPrototipo);
$('.div-direcciones-fp' + num_ferroPrototipo).addClass('d-none'); $('.div-direcciones-fp' + num_ferroPrototipo).addClass('d-none');
$('#loader').modal('hide');
} catch (e) { } catch (e) {
console.error(e); console.error(e);
@ -403,6 +448,31 @@ class Direcciones {
$('#loader').modal('show'); $('#loader').modal('show');
if (id == null || id <= 0 || id == undefined || id === 'undefined' || id === '') {
$('#loader').modal('hide');
Swal.fire({
title: 'Error',
text: window.translations["errores"].error_direccion_principal_no_encontrada,
icon: 'error',
showCancelButton: false,
confirmButtonColor: '#3085d6',
confirmButtonText: 'Ok',
customClass: {
confirmButton: 'btn btn-primary me-1',
},
buttonsStyling: false
});
if(numFerroPrototipo === 1) {
this.sameAddPrincipalFP1.prop('checked', false);
this.sameAddPrincipalFP1.trigger('change');
}
if(numFerroPrototipo === 2) {
this.sameAddPrincipalFP2.prop('checked', false);
this.sameAddPrincipalFP2.trigger('change');
}
return;
}
const ajaxGetDireccion = new Ajax('/misdirecciones/get/' + id, {}, {}, null, null); const ajaxGetDireccion = new Ajax('/misdirecciones/get/' + id, {}, {}, null, null);
const response = await ajaxGetDireccion.getPromise(); const response = await ajaxGetDireccion.getPromise();
@ -432,6 +502,7 @@ class Direcciones {
container.append(tarjeta.card); container.append(tarjeta.card);
addArray.push(tarjeta); addArray.push(tarjeta);
container.trigger('change'); container.trigger('change');
$('#loader').modal('hide');
} catch (err) { } catch (err) {
console.error('Error en petición Ajax:', err); console.error('Error en petición Ajax:', err);
@ -500,6 +571,21 @@ class Direcciones {
tarjeta.remove(); tarjeta.remove();
this.divDirecciones.trigger('change'); this.divDirecciones.trigger('change');
if (this.direcciones.length === 0) {
if (this.sameAddPrincipalFP1.is(':checked')) {
this.sameAddPrincipalFP1.prop('checked', false);
this.sameAddPrincipalFP1.trigger('change');
}
if (this.sameAddPrincipalFP2.is(':checked')) {
this.sameAddPrincipalFP2.prop('checked', false);
this.sameAddPrincipalFP2.trigger('change');
}
}
this.calcularPresupuesto = true;
this.divDirecciones.trigger('change');
} }
#deleteDireccionFP(event, num_ferroPrototipo = 1) { #deleteDireccionFP(event, num_ferroPrototipo = 1) {
@ -512,12 +598,18 @@ class Direcciones {
this.direccionesFP1 = []; this.direccionesFP1 = [];
this.sameAddPrincipalFP1.prop('checked', false); this.sameAddPrincipalFP1.prop('checked', false);
$('#divDireccionesFerroPrototipo1').trigger('change'); $('#divDireccionesFerroPrototipo1').trigger('change');
if (this.sameAddFP1.is(':checked')) {
this.sameAddFP1.prop('checked', false);
this.sameAddFP1.trigger('change');
}
$('.div-direcciones-fp1').removeClass('d-none');
} }
if (num_ferroPrototipo === 2) { if (num_ferroPrototipo === 2) {
this.direccionesFP2 = []; this.direccionesFP2 = [];
this.sameAddPrincipalFP2.prop('checked', false); this.sameAddPrincipalFP2.prop('checked', false);
this.sameAddFP1.prop('checked', false); this.sameAddFP1.prop('checked', false);
$('#divDireccionesFerroPrototipo2').trigger('change'); $('#divDireccionesFerroPrototipo2').trigger('change');
$('.div-direcciones-fp2').removeClass('d-none');
} }
tarjeta.remove(); tarjeta.remove();
@ -542,7 +634,10 @@ class Direcciones {
$('#divDireccionesFerroPrototipo').removeClass('d-none'); $('#divDireccionesFerroPrototipo').removeClass('d-none');
} }
else { else {
// mostrar alerta de que no hay direcciones popErrorAlert(window.translations["validation"].error_sameAddPrincipal_FP,
'sk-alert-ferro-prototipo1', true);
this.sameAddPrincipalFP1.prop('checked', false);
$('#divDireccionesFerroPrototipo').empty();
} }
} }
@ -556,13 +651,13 @@ class Direcciones {
#handleSameAddPrincipalFP2() { #handleSameAddPrincipalFP2() {
if (this.sameAddPrincipalFP2.is(':checked')) { if (this.sameAddPrincipalFP2.is(':checked')) {
if(this.sameAddFP1.is(':checked')) { if (this.sameAddFP1.is(':checked')) {
this.sameAddFP1.prop('checked', false); this.sameAddFP1.prop('checked', false);
} }
$('.div-direcciones-fp2').addClass('d-none'); $('.div-direcciones-fp2').addClass('d-none');
$('#divDireccionesFerroPrototipo2').empty(); $('#divDireccionesFerroPrototipo2').empty();
if (this.direcciones.length > 0) { if (this.direcciones.length > 0) {
let data = this.direcciones[0].getDireccion(); let data = this.direcciones[0].getDireccion();
this.direccionesFP2 = []; this.direccionesFP2 = [];
this.#addTarjetaDireccion( this.#addTarjetaDireccion(
@ -574,7 +669,10 @@ class Direcciones {
$('#divDireccionesFerroPrototipo2').removeClass('d-none'); $('#divDireccionesFerroPrototipo2').removeClass('d-none');
} }
else { else {
// mostrar alerta de que no hay direcciones popErrorAlert(window.translations["validation"].error_sameAddPrincipal_FP,
'sk-alert-ferro-prototipo2', true);
this.sameAddPrincipalFP2.prop('checked', false);
$('#divDireccionesFerroPrototipo2').empty();
} }
} }
@ -588,7 +686,7 @@ class Direcciones {
#handleSameAddFP1() { #handleSameAddFP1() {
if (this.sameAddFP1.is(':checked')) { if (this.sameAddFP1.is(':checked')) {
if(this.sameAddPrincipalFP2.is(':checked')) { if (this.sameAddPrincipalFP2.is(':checked')) {
this.sameAddPrincipalFP2.prop('checked', false); this.sameAddPrincipalFP2.prop('checked', false);
} }
$('.div-direcciones-fp2').addClass('d-none'); $('.div-direcciones-fp2').addClass('d-none');
@ -597,7 +695,7 @@ class Direcciones {
let data = this.direccionesFP1[0].getDireccion(); let data = this.direccionesFP1[0].getDireccion();
this.direccionesFP1 = []; this.direccionesFP2 = [];
this.#addTarjetaDireccion( this.#addTarjetaDireccion(
$("#divDireccionesFerroPrototipo2"), $("#divDireccionesFerroPrototipo2"),
this.direccionesFP2, this.direccionesFP2,
@ -608,7 +706,10 @@ class Direcciones {
$('#divDireccionesFerroPrototipo2').removeClass('d-none'); $('#divDireccionesFerroPrototipo2').removeClass('d-none');
} }
else { else {
// mostrar alerta de que no hay direcciones popErrorAlert(window.translations["validation"].error_sameAddFP1,
'sk-alert-ferro-prototipo2', true);
this.sameAddFP1.prop('checked', false);
$('#divDireccionesFerroPrototipo2').empty();
} }
} }
@ -626,6 +727,14 @@ class Direcciones {
else else
return null; return null;
} }
getDireccionesFPChecks() {
return {
addFP1isAddMain: this.sameAddPrincipalFP1.is(':checked'),
addFP2isAddMain: this.sameAddPrincipalFP2.is(':checked'),
addFP2isFP1: this.sameAddFP1.is(':checked')
};
}
} }

View File

@ -135,10 +135,10 @@ class PresupuestoCliente {
} }
calcularSolapas() { calcularSolapas(exclude_guardas = false) {
/* Solapas Max */ /* Solapas Max */
this.#getDatos(false, true); this.#getDatos(false, true, exclude_guardas);
if (Object.values(this.datos).every(this.#isValidDataForm)) { if (Object.values(this.datos).every(this.#isValidDataForm)) {
new Ajax('/presupuestocliente/calcularsolapas', new Ajax('/presupuestocliente/calcularsolapas',
this.datos, this.datos,
@ -199,6 +199,7 @@ class PresupuestoCliente {
if(!this.datosGenerales.validate(false)) { if(!this.datosGenerales.validate(false)) {
return; return;
} }
break; break;
case 'interior-libro': case 'interior-libro':
@ -372,6 +373,14 @@ class PresupuestoCliente {
break; break;
case 'interior-libro': case 'interior-libro':
this.calcularSolapas(true);
this.btnPrev.removeClass('d-none');
this.btnNext.removeClass('d-none');
this.btnSave.removeClass('d-none');
this.btnDuplicate.addClass('d-none');
this.btnPrint.addClass('d-none');
this.btnConfirm.addClass('d-none');
break;
case 'cubierta-libro': case 'cubierta-libro':
case 'direcciones-libro': case 'direcciones-libro':
this.btnPrev.removeClass('d-none'); this.btnPrev.removeClass('d-none');
@ -623,9 +632,9 @@ class PresupuestoCliente {
case 1: case 1:
this.disenioInterior.validate(); this.disenioInterior.validate();
this.calcularSolapas(true);
break; break;
case 2: case 2:
this.disenioCubierta.validate(); this.disenioCubierta.validate();
break; break;
@ -675,6 +684,12 @@ class PresupuestoCliente {
if (datos_to_check.direcciones) { if (datos_to_check.direcciones) {
delete datos_to_check.direcciones; delete datos_to_check.direcciones;
} }
if (datos_to_check.direccionesFP1) {
delete datos_to_check.direccionesFP1;
}
if (datos_to_check.direccionesFP2) {
delete datos_to_check.direccionesFP2;
}
if (datos_to_check.posPaginasColor == "" || datos_to_check.posPaginasColor == null) { if (datos_to_check.posPaginasColor == "" || datos_to_check.posPaginasColor == null) {
delete datos_to_check.posPaginasColor; delete datos_to_check.posPaginasColor;
} }
@ -689,7 +704,7 @@ class PresupuestoCliente {
} }
#getDatos(save = false, calcularSolapas = false) { #getDatos(save = false, calcularSolapas = false, exclude_guardas = false) {
this.datos = { this.datos = {
@ -719,7 +734,8 @@ class PresupuestoCliente {
this.datos.selectedTirada = this.direcciones.getSelectedTirada(); this.datos.selectedTirada = this.direcciones.getSelectedTirada();
} }
this.datos.guardas = this.disenioCubierta.getGuardas(); if(!exclude_guardas)
this.datos.guardas = this.disenioCubierta.getGuardas();
if (calcularSolapas) { if (calcularSolapas) {
return; return;
@ -795,17 +811,15 @@ class PresupuestoCliente {
} }
if( this.direcciones.direccionesFP1.length > 0) { if( this.direcciones.direccionesFP1.length > 0) {
this.datos.direccionesFP1 = this.direcciones.direccionesFP1.map((direccion) => { this.datos.direccionesFP1 = this.direcciones.direccionesFP1[0].getFormData();
return direccion.getFormData();
});
} }
if( this.direcciones.direccionesFP2.length > 0) { if( this.direcciones.direccionesFP2.length > 0) {
this.datos.direccionesFP2 = this.direcciones.direccionesFP2.map((direccion) => { this.datos.direccionesFP2 = this.direcciones.direccionesFP2[0].getFormData();
return direccion.getFormData();
});
} }
this.datos.direcciones_fp_checks = this.direcciones.getDireccionesFPChecks();
if (save) { if (save) {
this.datos.datosCabecera = { this.datos.datosCabecera = {
titulo: this.datosGenerales.titulo.val(), titulo: this.datosGenerales.titulo.val(),
@ -844,7 +858,11 @@ class PresupuestoCliente {
self.datosGenerales.cargarDatos(response.data.datosGenerales); self.datosGenerales.cargarDatos(response.data.datosGenerales);
self.direcciones.handleChangeCliente(); self.direcciones.handleChangeCliente();
self.direcciones.cargarDatos(response.data.direcciones, response.data.datosGenerales); self.direcciones.cargarDatos(response.data.direcciones, response.data.datosGenerales,
(response.data.direccionesFerroPrototipo && response.data.direccionesFerroPrototipo.length > 0) ?
response.data.direccionesFerroPrototipo : [] ,
response.data.direccionesFPChecks && response.data.direccionesFPChecks.length > 0 ? JSON.parse(response.data.direccionesFPChecks) : {}
);
try { try {
self.disenioInterior.cargarDatos(response.data.interior, response.data.datosGenerales.papelInteriorDiferente); self.disenioInterior.cargarDatos(response.data.interior, response.data.datosGenerales.papelInteriorDiferente);