mirror of
https://git.imnavajas.es/jjimenez/safekat.git
synced 2025-07-25 22:52:08 +00:00
falta sumar envios
This commit is contained in:
@ -105,5 +105,11 @@ class Js_loader extends BaseController
|
||||
$this->response->setHeader('Content-Type', 'text/javascript');
|
||||
return view('themes/vuexy/form/presupuestos/cliente/direcciones.js');
|
||||
}
|
||||
|
||||
function presupuestoClienteResumen_js()
|
||||
{
|
||||
$this->response->setHeader('Content-Type', 'text/javascript');
|
||||
return view('themes/vuexy/form/presupuestos/cliente/resumen.js');
|
||||
}
|
||||
}
|
||||
|
||||
@ -607,7 +607,7 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
|
||||
$newTokenHash = csrf_hash();
|
||||
$csrfTokenName = csrf_token();
|
||||
|
||||
$error =(object)[
|
||||
$error = (object)[
|
||||
'interior' => "",
|
||||
'cubierta' => "",
|
||||
'sobrecubierta' => "",
|
||||
@ -624,8 +624,9 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
|
||||
$tamanio = $reqData['tamanio'];
|
||||
$tipo_impresion_id = $this->getTipoImpresion($reqData['tipo'], $reqData['tapa']);
|
||||
$precio_u = [];
|
||||
$peso = [];
|
||||
|
||||
for($t=0; $t<count($tirada); $t++){
|
||||
for ($t = 0; $t < count($tirada); $t++) {
|
||||
$tirada[$t] = intval($tirada[$t]);
|
||||
|
||||
$paginas_color = intval($reqData['paginasColor']) ?? 0;
|
||||
@ -664,9 +665,11 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
|
||||
$interior = PresupuestoClienteService::obtenerInterior($input_data);
|
||||
|
||||
$costeInterior = 0.0;
|
||||
$peso_interior = 0.0;
|
||||
foreach ($interior as $linea) {
|
||||
if (count($linea) > 0) {
|
||||
$costeInterior += floatval($linea['total_impresion']);
|
||||
$peso_interior += floatval($linea['peso']);
|
||||
}
|
||||
}
|
||||
|
||||
@ -689,9 +692,11 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
|
||||
}
|
||||
|
||||
$costeInterior = 0.0;
|
||||
$peso_interior = 0.0;
|
||||
foreach ($interior as $linea) {
|
||||
if (count($linea) > 0) {
|
||||
$costeInterior += floatval($linea['total_impresion']);
|
||||
$peso_interior += floatval($linea['peso']);
|
||||
}
|
||||
}
|
||||
|
||||
@ -711,7 +716,7 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
|
||||
$input_data['datosPedido']->paginas = intval($reqData['carasCubierta'] ?? 0);
|
||||
$input_data['paginas_color'] = intval($reqData['carasCubierta'] ?? 0);
|
||||
$input_data['datosPedido']->solapas_ancho = intval($reqData['solapasCubierta'] ?? 0);
|
||||
$input_data['datosPedido']->solapas = $input_data['datosPedido']->solapas_ancho>0 ? 1 : 0;
|
||||
$input_data['datosPedido']->solapas = $input_data['datosPedido']->solapas_ancho > 0 ? 1 : 0;
|
||||
$input_data['datosPedido']->lomo = $this->calcular_lomo($interior, 0);
|
||||
$input_data['isColor'] = 1;
|
||||
$input_data['isHq'] = 1;
|
||||
@ -719,32 +724,35 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
|
||||
|
||||
$cubierta = PresupuestoClienteService::obtenerCubierta($input_data);
|
||||
$coste_cubierta = 0.0;
|
||||
$peso_cubierta = 0.0;
|
||||
if (count($cubierta) > 0) {
|
||||
$coste_cubierta += floatval($cubierta['total_impresion']);
|
||||
$peso_cubierta += floatval($cubierta['peso']);
|
||||
}
|
||||
if($coste_cubierta <= 0)
|
||||
if ($coste_cubierta <= 0)
|
||||
$error->cubierta = lang('Presupuestos.errores.noCubiertaSobrecubierta');
|
||||
else
|
||||
$error->cubierta = "";
|
||||
|
||||
$tarifaAcabadoCubierta = intval($reqData['acabadoCubierta'] ?? 0);
|
||||
$acabadoCubierta = [];
|
||||
if($tarifaAcabadoCubierta > 0){
|
||||
if ($tarifaAcabadoCubierta > 0) {
|
||||
$model = model('App\Models\Presupuestos\PresupuestoAcabadosModel');
|
||||
$acabadoCubierta = $model->getPrecioTarifa($tarifaAcabadoCubierta, $datosPedido->tirada, $POD);
|
||||
}
|
||||
if(count($acabadoCubierta) > 0){
|
||||
if($acabadoCubierta[0]->total <= 0 )
|
||||
if (count($acabadoCubierta) > 0) {
|
||||
if ($acabadoCubierta[0]->total <= 0)
|
||||
$error->servicios = lang('Presupuestos.errores.errorPresupuesto');
|
||||
$coste_servicios += floatval($acabadoCubierta[0]->total);
|
||||
}
|
||||
|
||||
// Sobrecubierta
|
||||
$coste_sobrecubierta = 0.0;
|
||||
$peso_sobrecubierta = 0.0;
|
||||
$linea_sobrecubierta = [];
|
||||
$acabadoSobrecubierta = [];
|
||||
$sobreCubierta = $reqData["sobrecubierta"] ?? null;
|
||||
if(!is_null($sobreCubierta)){
|
||||
if (!is_null($sobreCubierta)) {
|
||||
|
||||
$papel_generico = [
|
||||
'id' => $sobreCubierta['papel'] ?? 0,
|
||||
@ -755,7 +763,7 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
|
||||
$input_data['datosPedido']->paginas = 4;
|
||||
$input_data['paginas_color'] = 4;
|
||||
$input_data['datosPedido']->solapas_ancho = intval($sobreCubierta['solapas'] ?? 0);
|
||||
$input_data['datosPedido']->solapas = $input_data['datosPedido']->solapas_ancho>0 ? 1 : 0;
|
||||
$input_data['datosPedido']->solapas = $input_data['datosPedido']->solapas_ancho > 0 ? 1 : 0;
|
||||
$input_data['datosPedido']->lomo = $this->calcular_lomo([$cubierta], $input_data['datosPedido']->lomo);
|
||||
$input_data['isColor'] = 1;
|
||||
$input_data['isHq'] = 1;
|
||||
@ -765,20 +773,21 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
|
||||
|
||||
if (count($linea_sobrecubierta) > 0) {
|
||||
$coste_sobrecubierta += floatval($linea_sobrecubierta['total_impresion']);
|
||||
$peso_sobrecubierta += floatval($linea_sobrecubierta['peso']);
|
||||
}
|
||||
if($coste_sobrecubierta <= 0)
|
||||
if ($coste_sobrecubierta <= 0)
|
||||
$error->sobrecubierta = lang('Presupuestos.errores.noCubiertaSobrecubierta');
|
||||
else
|
||||
$error->sobrecubierta = "";
|
||||
|
||||
$tarifaAcabadoSobrecubierta = intval(strlen($sobreCubierta['acabado'])==0 ? 0:$sobreCubierta['acabado']);
|
||||
$tarifaAcabadoSobrecubierta = intval(strlen($sobreCubierta['acabado']) == 0 ? 0 : $sobreCubierta['acabado']);
|
||||
$acabadoSobrecubierta = [];
|
||||
if($tarifaAcabadoSobrecubierta > 0){
|
||||
if ($tarifaAcabadoSobrecubierta > 0) {
|
||||
$model = model('App\Models\Presupuestos\PresupuestoAcabadosModel');
|
||||
$acabadoSobrecubierta = $model->getPrecioTarifa($tarifaAcabadoSobrecubierta, $datosPedido->tirada, $POD);
|
||||
}
|
||||
if(count($acabadoSobrecubierta) > 0){
|
||||
if($acabadoSobrecubierta[0]->total <= 0 )
|
||||
if (count($acabadoSobrecubierta) > 0) {
|
||||
if ($acabadoSobrecubierta[0]->total <= 0)
|
||||
$error->servicios = lang('Presupuestos.errores.errorPresupuesto');
|
||||
$coste_servicios += floatval($acabadoSobrecubierta[0]->total);
|
||||
}
|
||||
@ -786,7 +795,9 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
|
||||
|
||||
//Guardas
|
||||
$guardas = [];
|
||||
if($reqData['guardas'] ?? 0 > 0){
|
||||
$peso_guardas = 0.0;
|
||||
$coste_guardas = 0.0;
|
||||
if ($reqData['guardas'] ?? 0 > 0) {
|
||||
|
||||
$guardas = $reqData['guardas'];
|
||||
$papel_generico = [
|
||||
@ -814,11 +825,12 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
|
||||
}
|
||||
|
||||
$guardas = PresupuestoClienteService::obtenerGuardas($input_data);
|
||||
$coste_guardas = 0.0;
|
||||
|
||||
if (count($guardas) > 0) {
|
||||
$coste_guardas += floatval($guardas['total_impresion']);
|
||||
$peso_guardas += floatval($guardas['peso']);
|
||||
}
|
||||
if($coste_guardas <= 0)
|
||||
if ($coste_guardas <= 0)
|
||||
$error->guardas = lang('Presupuestos.errores.noGuardas');
|
||||
else
|
||||
$error->guardas = "";
|
||||
@ -832,11 +844,11 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
|
||||
'ancho' => $datosPedido->ancho,
|
||||
'alto' => $datosPedido->alto,
|
||||
'POD' => $POD,
|
||||
'solapas' => intval($reqData['solapasCubierta'] ?? 0)>0?1:0,
|
||||
'solapas' => intval($reqData['solapasCubierta'] ?? 0) > 0 ? 1 : 0,
|
||||
]);
|
||||
$costeServiciosDefecto = 0.0;
|
||||
foreach ($servDefecto as $servicio) {
|
||||
if($servicio->total <= 0 )
|
||||
if ($servicio->total <= 0)
|
||||
$error->serviciosDefecto = lang('Presupuestos.errores.errorPresupuesto');
|
||||
|
||||
$costeServiciosDefecto += floatval($servicio->total);
|
||||
@ -844,7 +856,7 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
|
||||
|
||||
// Servicios
|
||||
$servicios = $reqData['servicios'] ?? [];
|
||||
if($reqData['guardas'] ?? 0 > 0){
|
||||
if ($reqData['guardas'] ?? 0 > 0) {
|
||||
array_push($servicios, 62); // Plegado de guardas
|
||||
}
|
||||
/*
|
||||
@ -857,9 +869,8 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
|
||||
*/
|
||||
$serviciosAutomaticos = [];
|
||||
|
||||
foreach($servicios as $servicio){
|
||||
if(intval($servicio) == 3 || intval($servicio) == 5 || intval($servicio) == 16)
|
||||
{
|
||||
foreach ($servicios as $servicio) {
|
||||
if (intval($servicio) == 3 || intval($servicio) == 5 || intval($servicio) == 16) {
|
||||
// Servicios acabado
|
||||
$resultado = PresupuestoCLienteService::getServiciosManipulado([
|
||||
'tarifa_id' => $servicio,
|
||||
@ -867,26 +878,21 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
|
||||
'POD' => $POD,
|
||||
]);
|
||||
array_push($serviciosAutomaticos, $resultado[0]);
|
||||
if($resultado[0]->total <= 0 )
|
||||
if ($resultado[0]->total <= 0)
|
||||
$error->servicios = lang('Presupuestos.errores.errorPresupuesto');
|
||||
|
||||
$coste_servicios += floatval($resultado[0]->total);
|
||||
|
||||
}
|
||||
else if (intval($servicio) == 24 || intval($servicio) == 9 )
|
||||
{
|
||||
} else if (intval($servicio) == 24 || intval($servicio) == 9) {
|
||||
// Servicios preimpresion
|
||||
$resultado = PresupuestoCLienteService::getServiciosExtra([
|
||||
'tarifa_id' => $servicio,
|
||||
]);
|
||||
array_push($serviciosAutomaticos, $resultado[0]);
|
||||
if($resultado[0]->precio <= 0 )
|
||||
if ($resultado[0]->precio <= 0)
|
||||
$error->servicios = lang('Presupuestos.errores.errorPresupuesto');
|
||||
|
||||
$coste_servicios += floatval($resultado[0]->precio);
|
||||
}
|
||||
else if (intval($servicio) == 62)
|
||||
{
|
||||
} else if (intval($servicio) == 62) {
|
||||
// Servicios manipulado
|
||||
$resultado = PresupuestoCLienteService::getServiciosManipulado([
|
||||
'tarifa_id' => $servicio,
|
||||
@ -894,16 +900,17 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
|
||||
'POD' => $POD,
|
||||
]);
|
||||
array_push($serviciosAutomaticos, $resultado[0]);
|
||||
if($resultado[0]->total <= 0 )
|
||||
if ($resultado[0]->total <= 0)
|
||||
$error->servicios = lang('Presupuestos.errores.errorPresupuesto');
|
||||
|
||||
$coste_servicios += floatval($resultado[0]->total);
|
||||
}
|
||||
}
|
||||
|
||||
array_push($precio_u, round(($costeInterior + $coste_cubierta + $coste_sobrecubierta + $costeServiciosDefecto + $coste_servicios)/$tirada[$t], 4));
|
||||
foreach($error as $err){
|
||||
if($err != "")
|
||||
array_push($precio_u, round(($costeInterior + $coste_cubierta + $coste_sobrecubierta + $costeServiciosDefecto + $coste_servicios) / $tirada[$t], 4));
|
||||
array_push($peso, round($peso_interior + $peso_cubierta + $peso_sobrecubierta + $peso_guardas, 2));
|
||||
foreach ($error as $err) {
|
||||
if ($err != "")
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -911,13 +918,14 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
|
||||
|
||||
$return_data = [
|
||||
'errors' => $error,
|
||||
'total_lp' => $costeInterior+$coste_cubierta+$coste_sobrecubierta,
|
||||
'total_lp' => $costeInterior + $coste_cubierta + $coste_sobrecubierta,
|
||||
'acabadoCubierta' => $acabadoCubierta,
|
||||
'acabadoSobrecubierta' => $acabadoSobrecubierta,
|
||||
'total_servicios_defecto' => $costeServiciosDefecto,
|
||||
'total_servicios_automaticos' => $coste_servicios,
|
||||
'tiradas' => $tirada,
|
||||
'precio_u' => $precio_u,
|
||||
'peso' => $peso,
|
||||
|
||||
'interior' => $interior,
|
||||
'cubierta' => $cubierta,
|
||||
@ -935,7 +943,8 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
|
||||
}
|
||||
}
|
||||
|
||||
public function getDireccionesCliente(){
|
||||
public function getDireccionesCliente()
|
||||
{
|
||||
if ($this->request->isAJAX()) {
|
||||
|
||||
$newTokenHash = csrf_hash();
|
||||
@ -948,7 +957,7 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
|
||||
array_unshift($data, ['id' => 0, 'text' => 'Agregar nueva dirección']);
|
||||
|
||||
return $this->respond([
|
||||
'menu'=>$data,
|
||||
'menu' => $data,
|
||||
$csrfTokenName => $newTokenHash
|
||||
]);
|
||||
} else {
|
||||
@ -956,7 +965,8 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
|
||||
}
|
||||
}
|
||||
|
||||
public function getDatosDireccion(){
|
||||
public function getDatosDireccion()
|
||||
{
|
||||
|
||||
if ($this->request->isAJAX()) {
|
||||
|
||||
@ -965,12 +975,44 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
|
||||
|
||||
$reqData = $this->request->getPost();
|
||||
$direccionId = $reqData['id'] ?? 0;
|
||||
$peso = $reqData['peso'] ?? 0;
|
||||
$unidades = $reqData['unidades'] ?? 0;
|
||||
$model = model('App\Models\Clientes\ClienteDireccionesModel');
|
||||
$data = $model->getDireccion($direccionId);
|
||||
|
||||
$modelTarifaEnvio = model('App\Models\Tarifas\TarifaEnvioModel');
|
||||
$coste = 0;
|
||||
if ($data > 0) {
|
||||
$tarifas_envio = $modelTarifaEnvio->getTarifaEnvio($data[0]->pais_id, $peso, $unidades, 'cajas');
|
||||
for ($i = 0; $i < count($tarifas_envio); $i++) {
|
||||
if ($peso > $tarifas_envio[$i]->peso_max) {
|
||||
$tarifas_envio[$i]->precio = number_format($tarifas_envio[$i]->peso_min + ($peso - $data[$i]->peso_min) * $data[$i]->precio_adicional, 2);
|
||||
}
|
||||
// si no se calcula linealmente
|
||||
else {
|
||||
$m = (($tarifas_envio[$i]->precio_max - $tarifas_envio[$i]->precio_min) / ($tarifas_envio[$i]->peso_max - $tarifas_envio[$i]->peso_min));
|
||||
$b = $tarifas_envio[$i]->precio_max - $m * $tarifas_envio[$i]->peso_max;
|
||||
$tarifas_envio[$i]->precio = number_format($m * $peso + $b, 2);
|
||||
}
|
||||
$tarifas_envio[$i]->margen = $tarifas_envio[$i]->margen;
|
||||
}
|
||||
|
||||
if(count($tarifas_envio) > 1){
|
||||
$tarifa_final = array_reduce($tarifas_envio, function ($previous, $current) {
|
||||
return $current->precio < $previous->precio ? $current : $previous;
|
||||
});
|
||||
$coste = $tarifa_final->precio;
|
||||
}
|
||||
else{
|
||||
$coste = $tarifas_envio[0]->precio;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
$data[0]->coste = $coste;
|
||||
|
||||
return $this->respond([
|
||||
'data'=>$data,
|
||||
'data' => $data,
|
||||
$csrfTokenName => $newTokenHash
|
||||
]);
|
||||
} else {
|
||||
@ -978,7 +1020,8 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
|
||||
}
|
||||
}
|
||||
|
||||
public function getNuevaDireccion(){
|
||||
public function getNuevaDireccion()
|
||||
{
|
||||
|
||||
if ($this->request->isAJAX()) {
|
||||
|
||||
@ -1007,7 +1050,7 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
|
||||
|
||||
|
||||
return $this->respond([
|
||||
'data'=>$menu,
|
||||
'data' => $menu,
|
||||
$csrfTokenName => $newTokenHash
|
||||
]);
|
||||
} else {
|
||||
@ -1021,7 +1064,8 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
|
||||
* Funciones auxiliares
|
||||
*
|
||||
**********************/
|
||||
protected function calcular_lomo($lineas, $lomo_inicial){
|
||||
protected function calcular_lomo($lineas, $lomo_inicial)
|
||||
{
|
||||
$lomo = $lomo_inicial;
|
||||
foreach ($lineas as $linea) {
|
||||
if (count($linea) > 0) {
|
||||
|
||||
@ -1,40 +1,47 @@
|
||||
<div class="col-12 pb-2">
|
||||
<div class="row mb-3">
|
||||
<div class="col-sm-6">
|
||||
<h3>Resumen</h3>
|
||||
<h4>Libro</h4>
|
||||
<p>Rústica cosido tapa blanda</p>
|
||||
<p>Número de páginas: 200</p>
|
||||
<p>Tirada: 200</p>
|
||||
<p>Prototipo: NO</p>
|
||||
<div class="col-sm-6">
|
||||
<h5 class="mb-1">Libro</h5>
|
||||
<p class="mb-0"><small id="tipoLibro">Rústica cosido tapa blanda</small></p>
|
||||
<p class="mb-0"><small id="resumenTamanio">Tamaño: 100x100</small></p>
|
||||
<p class="mb-0"><small id="resumenPaginas">Número de páginas: 200</small></p>
|
||||
<p class="mb-0"><small id="resumenTirada">Tirada: 200</small></p>
|
||||
<p class="mb-0"><small id="resumenPrototipo">Prototipo: NO</small></p>
|
||||
<p class="mb-3"><small id="resumenFerro">Ferro: NO</small></p>
|
||||
|
||||
<h4>Interior</h4>
|
||||
<p>Impresion: Negro premium</p>
|
||||
<p>Páginas a color: 100</p>
|
||||
<p>Papel: Blanco Offset 70gr/m^2</p>
|
||||
<h5 class="mb-1">Interior</h5>
|
||||
<p class="mb-0"><small id="tipoImpresion">Impresion: Negro premium</small></p>
|
||||
<p id="pResumenPaginasColor" class="mb-0" style="display:none"><small id="resumenPaginasColor">Páginas a color: 100</small></p>
|
||||
<p class="mb-3"><small id="resumenPapelInterior">Papel: Blanco Offset 70gr/m²</small></p>
|
||||
|
||||
<h4>Cubierta</h4>
|
||||
<p>Papel: Blanco Offset 70gr/m^2</p>
|
||||
<p>Impresión: 1 cara</p>
|
||||
<h5 class="mb-1">Cubierta</h5>
|
||||
<p class="mb-0"><small id="resumenPapelCubierta">Papel: Blanco Offset 70gr/m²</small></p>
|
||||
<p class="mb-0"><small id="resumenCarasCubierta">Impresión: 1 cara</small></p>
|
||||
<p class="mb-0"><small id="resumenSolapasCubierta">Solapas: 25mm</small></p>
|
||||
<p class="mb-3"><small id="resumenAcabadoCubierta">Acabado: Ninguno</small></p>
|
||||
|
||||
<h4>Sobrecubierta</h4>
|
||||
<p>Papel: Blanco Offset 70gr/m^2</p>
|
||||
<p>Impresión: sin impresion</p>
|
||||
<h5 class="mb-1 resumen-sobrecubierta">Sobrecubierta</h5>
|
||||
<p class="mb-0 resumen-sobrecubierta"><small id="resumenPapelSobrecubierta">Papel: Blanco Offset 70gr/m<sup>2</sup></small></p>
|
||||
<p class="mb-0 resumen-sobrecubierta"><small id="resumenSolapasCubierta">Ancho solapas: 25mm</small></p>
|
||||
<p class="mb-3 resumen-sobrecubierta"><small id="resumenAcabadoCubierta">Acabado: Ninguno</small></p>
|
||||
|
||||
<h4>Guardas</h4>
|
||||
<p>Papel: Blanco Offset 70gr/m^2</p>
|
||||
<p>Impresión: 1 cara</p>
|
||||
<h5 class="mb-1 resumen-guardas">Guardas</h5>
|
||||
<p class="mb-0 resumen-guardas"><small id="resumenGuardasPapel">Papel: Blanco Offset 70gr/m<sup>2</sup></small></p>
|
||||
<p class="mb-3 resumen-guardas"><small id="resumenGuardasCaras">Impresión: 1 cara</small></p>
|
||||
|
||||
<h4>Extras</h4>
|
||||
<p>Retractilado de 5</p>
|
||||
<h5 class="mb-1 resumen-extras">Extras</h5>
|
||||
<p class="mb-0 resumen-extras" id="resumenRetractilado1"><small>Retractilado individual</small></p>
|
||||
<p class="mb-0 resumen-extras" id="resumenRetractilado5"><small>Retractilado de 5</small></p>
|
||||
<p class="mb-0 resumen-extras" id="resumenFajaColor"><small>Imprimir faja a color</small></p>
|
||||
</div>
|
||||
|
||||
<div class="col-sm-6">
|
||||
<h6>Coste impresion: 100€</h6>
|
||||
<h6>Coste impresion (4% IVA): 104€</h6>
|
||||
<h6>Precio unidad (I.V.A. incl): 10.4€</h6>
|
||||
<h6>Coste Envío: 30€</h6>
|
||||
<h6>Total (I.V.A. inc.): 134€</h6>
|
||||
<h4 id="resumenTotal" class="mb-1">Total: 100€</h4>
|
||||
<h6 id="resumenPrecioU" class="mb-0">10.4€/ud</h6>
|
||||
<h6 id="resumenTotalIVA"class="mb-0">Coste impresion (4% IVA): 104€</h6>
|
||||
<h6 id="resumenEnvio" class="mb-1">Envío: 30€</h6>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@ -33,12 +33,13 @@ function initTiradasDirecciones() {
|
||||
let tirada_id = "ud_tiradaPrecio" + i;
|
||||
let total_id = "tot_tiradaPrecio" + i;
|
||||
let precio_u_id = "pu_tiradaPrecio" + i;
|
||||
let peso = $('#' + id).attr('peso');
|
||||
|
||||
let html = '';
|
||||
html += '<div class="col-sm-3">';
|
||||
html += '<div class="form-check custom-option custom-option-basic custom-option-tiradasDirecciones' + (i==1?' checked':'')+ ' ">';
|
||||
html += '<label class="form-check-label custom-option-content" for="tiradaEnvios' + i + '">';
|
||||
html += '<input name="' + id + '" class="form-check-input" type="radio" value="" id="' + id + '">';
|
||||
html += '<input name=env_"' + id + '" peso="' + peso + '" class="form-check-input" type="radio" value="" id="env_' + id + '">';
|
||||
html += '<span class="custom-option-header">';
|
||||
html += '<span id="tiradaDireccionesValue' + i + '" class="h6 mb-0">' + $('#' + tirada_id).text().split(' ')[0] + '</span>';
|
||||
html += '<span class="text-muted">' + $('#' + total_id).text() + '</span>';
|
||||
@ -131,7 +132,9 @@ $('#insertarDireccion').on('click', function() {
|
||||
if(total + unidades <= tirada) {
|
||||
|
||||
data = {
|
||||
id: $('#direcciones').val()
|
||||
id: $('#direcciones').val(),
|
||||
peso: $('#env_tiradaPrecio' + number[0]).attr('peso'),
|
||||
unidades: unidades
|
||||
},
|
||||
data = Object.assign(data, window.token_ajax)
|
||||
|
||||
@ -142,7 +145,7 @@ $('#insertarDireccion').on('click', function() {
|
||||
success: function(response) {
|
||||
if(response.data.length > 0) {
|
||||
let html = '';
|
||||
html += '<div id="envioId' + response.data[0].id + '" class="row mb-3">';
|
||||
html += '<div id="envioId' + response.data[0].id + '" p= ' +response.data[0].coste + ' class="row mb-3">';
|
||||
html += '<div class="col-sm-5 form-check custom-option custom-option-basic checked">';
|
||||
html += '<label class="form-check-label custom-option-content" for="customRadioAddress1">';
|
||||
html += '<span class="custom-option-header mb-2">';
|
||||
|
||||
@ -708,11 +708,9 @@ async function calcularPresupuesto() {
|
||||
|
||||
console.log(response);
|
||||
$('#loader').hide();
|
||||
if(error){
|
||||
|
||||
$('#divTiradasPrecio').empty();
|
||||
|
||||
}
|
||||
else{
|
||||
$('#precios').show();
|
||||
|
||||
for (i = 0; i < response.tiradas.length; i++) {
|
||||
@ -722,7 +720,7 @@ async function calcularPresupuesto() {
|
||||
let html = '';
|
||||
|
||||
|
||||
html += '<div id="' + label + '" class="list-group" >';
|
||||
html += '<div id="' + label + '" peso="' +response.peso[i]+ '" class="list-group" >';
|
||||
html += '<a href="javascript:void(0);" class="list-group-item list-group-item-action">';
|
||||
html += '<div class="li-wrapper d-flex justify-content-start align-items-center" >';
|
||||
html += '<div class="list-content">';
|
||||
@ -736,7 +734,6 @@ async function calcularPresupuesto() {
|
||||
|
||||
$('#divTiradasPrecio').append(html);
|
||||
}
|
||||
}
|
||||
},
|
||||
error: function (error) {
|
||||
$('#loader').hide();
|
||||
|
||||
@ -237,10 +237,16 @@
|
||||
submitButton: new FormValidation.plugins.SubmitButton()
|
||||
}
|
||||
}).on('core.form.valid', function () {
|
||||
if(validarEnvio())
|
||||
if(validarEnvio()){
|
||||
generarResumen();
|
||||
validationStepper.next();
|
||||
}
|
||||
else{
|
||||
$('#errorDirecciones').text('El número de unidades supera la tirada seleccionada.');
|
||||
let text = "El número de unidades enviadas no coincie con la tirada seleccionada.";
|
||||
if($('#prototipo').is(':checked')) {
|
||||
text += "<br>(Tenga en cuenta que se ha seleccionado la opción de prototipo)";
|
||||
}
|
||||
$('#errorDirecciones').text(text);
|
||||
$('#errorDirecciones').show();
|
||||
}
|
||||
});
|
||||
@ -303,6 +309,10 @@
|
||||
break;
|
||||
|
||||
case 3:
|
||||
validationStepper.previous();
|
||||
break;
|
||||
|
||||
case 2:
|
||||
for (let i = 0; i < 4; i++) {
|
||||
let id = "tiradaPrecio" + i;
|
||||
if ($('#' + id).length > 0) {
|
||||
@ -312,10 +322,6 @@
|
||||
validationStepper.previous();
|
||||
break;
|
||||
|
||||
case 2:
|
||||
validationStepper.previous();
|
||||
break;
|
||||
|
||||
case 1:
|
||||
validationStepper.previous();
|
||||
break;
|
||||
|
||||
107
ci4/app/Views/themes/vuexy/form/presupuestos/cliente/resumen.js
Normal file
107
ci4/app/Views/themes/vuexy/form/presupuestos/cliente/resumen.js
Normal file
@ -0,0 +1,107 @@
|
||||
function generarResumen(){
|
||||
$('#tipoLibro').text($('#tituloDisenioLibro').text() + ' tapa ' + (($('#tapaBlandaInnerDiv').hasClass('checked'))?'blanda':'dura'));
|
||||
$('#resumenTamanio').text('Dimensiones: ' + getDimensionLibro().ancho + 'x' + getDimensionLibro().alto + 'mm');
|
||||
$('#resumenPaginas').text('Páginas: '+ $('#paginas').val() + ' páginas');
|
||||
|
||||
const seleccion = $('.custom-option-tiradasDirecciones.checked');
|
||||
let tirada = 0;
|
||||
if(seleccion.length != 0) {
|
||||
|
||||
const element_tirada =($(seleccion[0]).find('label input')[0]);
|
||||
const number = element_tirada.id.match(/\d+$/);
|
||||
if (number.length != 0) {
|
||||
tirada = parseInt($('#tiradaDireccionesValue' + number[0]).text());
|
||||
}
|
||||
}
|
||||
$('#resumenTirada').text('Tirada: '+ tirada + ' unidades');
|
||||
|
||||
$('#resumenPrototipo').text('Prototipo: ' + (($('#prototipo').is(':checked'))?'Sí':'No'));
|
||||
$('#resumenFerro').text('Ferro: ' + (($('#ferro').is(':checked'))?'Sí':'No'));
|
||||
|
||||
$('#tipoImpresion').text('Impresión: ' +
|
||||
($('#colorNegroDiv').hasClass('checked')?'Negro ':'Color ') +
|
||||
($('#calidadEstandarDiv').hasClass('checked')?'Estándar': 'Premium'));
|
||||
if($('#colorNegroDiv').hasClass('checked')){
|
||||
$('#pResumenPaginasColor').hide();
|
||||
}
|
||||
else{
|
||||
$('#pResumenPaginasColor').show();
|
||||
$('#resumenPaginasColor').text($('#paginasColor').val());
|
||||
}
|
||||
$('#resumenPapelInterior').text($('#papelInterior option:selected').text().trim() + ' ' +
|
||||
$('#gramajeInterior option:selected').text() + 'gr/m²');
|
||||
|
||||
let papelCubierta = $('#papelCubierta option:selected').text().trim() + ' ' +
|
||||
$('#gramajeCubierta option:selected').text();
|
||||
papelCubierta += 'gr/m<sup>2</sup>';
|
||||
$('#resumenPapelCubierta').text(papelCubierta);
|
||||
$('#resumenCarasCubierta').text('Impresión: ' + $('#carasCubierta option:selected').text())
|
||||
$('#resumenAcabadoCubierta').text('Acabado: ' + $('#acabadosCubierta option:selected').text())
|
||||
if ($('#solapasCubierta').is(':checked')) {
|
||||
$('#resumenSolapasCubierta').text('Solapas: ' + $('#anchoSolapasCubierta').val())
|
||||
}
|
||||
else{
|
||||
$('#resumenSolapasCubierta').text('Solapas: No')
|
||||
}
|
||||
|
||||
if ($('.enable-sobrecubierta').is(':visible')) {
|
||||
$(".resumen-sobrecubierta").show();
|
||||
$('#resumenPapelCubierta').text($('#papelSobrecubierta option:selected').text().trim() + ' ' +
|
||||
$('#gramajeSobrecubierta option:selected').text() + 'gr/m²');
|
||||
$('#resumenAcabadoSobrecubierta').text('Acabado: ' + $('#acabadosSobrecubierta option:selected').text())
|
||||
$('#resumenSolapasSobrecubierta').text('Solapas: ' + $('#anchoSolapasSobrecubierta').val())
|
||||
|
||||
}
|
||||
else{
|
||||
$(".resumen-sobrecubierta").hide();
|
||||
}
|
||||
|
||||
if ($('.guardas').is(':visible')) {
|
||||
$(".resumen-guardas").show();
|
||||
$('#resumenGuardasPapel').text($('#papelGuardas option:selected').text().trim() + ' ' + '170gr/m²');
|
||||
$('#resumenGuardasCaras').text('Impresión: ' + $('#impresionGuardas option:selected').text())
|
||||
}
|
||||
else{
|
||||
$(".resumen-guardas").hide();
|
||||
}
|
||||
|
||||
|
||||
if($('#retractilado').is(':checked') || $('#retractilado5').is(':checked') || $('#fajaColor').is(':checked')){
|
||||
|
||||
$('.resumen-extras').show();
|
||||
$('#retractilado').is(':checked')?$('#resumenRetractilado1').show():$('#resumenRetractilado1').hide();
|
||||
$('#retractilado5').is(':checked')?$('#resumenRetractilado5').show():$('#resumenRetractilado5').hide();
|
||||
$('#fajaColor').is(':checked')?$('#resumenFajaColor').show():$('#resumenFajaColor').hide();
|
||||
}
|
||||
else{
|
||||
$('.resumen-extras').hide();
|
||||
}
|
||||
|
||||
for (i = 1; i <= 4; i++) {
|
||||
let id = "tiradaPrecio" + i;
|
||||
if ($('#' + id).length > 0) {
|
||||
|
||||
let tirada_id = "ud_tiradaPrecio" + i;
|
||||
if(parseInt($('#' + tirada_id).text().replace(' ud.', '')) != tirada){
|
||||
continue;
|
||||
}
|
||||
|
||||
let total_id = "tot_tiradaPrecio" + i;
|
||||
let precio_u_id = "pu_tiradaPrecio" + i;
|
||||
|
||||
$('#resumenTotal').text($('#' + total_id).text());
|
||||
$('#resumenPrecioU').text($('#' + precio_u_id).text());
|
||||
let total = parseFloat($('#' + total_id).text().replace('€', '').replace('Total: ', ''));
|
||||
let total_iva = 0.0;
|
||||
if($('#ivaReducido').val() == '1'){
|
||||
total_iva = total * 1.04;
|
||||
}
|
||||
else{
|
||||
total_iva = total * 1.21;
|
||||
}
|
||||
$('#resumenTotalIVA').text('Total (I.V.A. ' + (($('#ivaReducido').val() == '1')?'4':'21') + '%): ' + total_iva.toFixed(2) + '€');
|
||||
$('resumenEnvio').text('Envío: ' + '30' + '€');
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@ -144,18 +144,18 @@
|
||||
|
||||
</div>
|
||||
<div class="col-12 d-flex justify-content-between mt-4">
|
||||
<div class="col-6 flex-row">
|
||||
<div class="col-6 d-flex flex-row">
|
||||
<button class="btn btn-label-secondary btn-prev waves-effect">
|
||||
<i class="ti ti-arrow-left ti-xs me-sm-1 me-0"></i>
|
||||
<span class="align-middle d-sm-inline-block d-none">Anterior</span>
|
||||
</button>
|
||||
</div>
|
||||
<div class="col-6 flex-row-reverse">
|
||||
<button class="btn btn-primary btn-submit waves-effect waves-light">
|
||||
<div class="col-6 d-flex flex-row-reverse">
|
||||
<button class="btn btn-primary btn-submit waves-effect waves-light ml-2">
|
||||
<span class="align-middle d-sm-inline-block d-none me-sm-1">Guardar</span>
|
||||
<i class="ti ti-arrow-right ti-xs"></i>
|
||||
</button>
|
||||
<button class="btn btn-success btn-submit btn-next waves-effect waves-light">
|
||||
<button class="btn btn-success btn-submit btn-next mx-2 waves-effect waves-light">
|
||||
<span class="align-middle d-sm-inline-block d-none me-sm-1">Confirmar</span><i class="ti ti-check ti-xs"></i>
|
||||
</button>
|
||||
</div>
|
||||
@ -166,12 +166,8 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
</div><!--//.col -->
|
||||
<div class="pt-4">
|
||||
<input type="submit" class="btn btn-primary float-start me-sm-3 me-1" name="save" id="saveForm" value="<?= lang("Basic.global.Save") ?>" />
|
||||
</div>
|
||||
|
||||
</div><!--//.row -->
|
||||
<?= view("themes/_commonPartialsBs/_modalConfirmDialog") ?>
|
||||
<?= view("themes/_commonPartialsBs/_modalMessageDialog") ?>
|
||||
@ -243,4 +239,5 @@ initDisenioLibro();
|
||||
<script src="<?= site_url('js_loader/presupuestoClienteTipoLibro_js') ?>"></script>
|
||||
<script src="<?= site_url('js_loader/presupuestoClienteDisenioLibro_js') ?>"></script>
|
||||
<script src="<?= site_url('js_loader/presupuestoClienteDirecciones_js') ?>"></script>
|
||||
<script src="<?= site_url('js_loader/presupuestoClienteResumen_js') ?>"></script>
|
||||
<?= $this->endSection() ?>
|
||||
25497
xdebug.log
25497
xdebug.log
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user