mirror of
https://git.imnavajas.es/jjimenez/safekat.git
synced 2025-07-25 22:52:08 +00:00
Merge branch 'dev/editar_presu_cliente' into 'main'
Dev/editar presu cliente See merge request jjimenez/safekat!253
This commit is contained in:
@ -74,7 +74,7 @@ const SK_PERMISSION_MATRIX = [
|
||||
"roles-permisos.delete",
|
||||
"roles-permisos.menu",
|
||||
],
|
||||
"cliente-admin" => [
|
||||
"cliente" => [
|
||||
"clientes.create",
|
||||
"clientes.edit",
|
||||
"clientes.delete",
|
||||
@ -84,52 +84,6 @@ const SK_PERMISSION_MATRIX = [
|
||||
"presupuesto.delete",
|
||||
"presupuesto.menu",
|
||||
],
|
||||
"cliente-editor" => [
|
||||
"clientes.create",
|
||||
"clientes.edit",
|
||||
"clientes.delete",
|
||||
"clientes.menu",
|
||||
"plantilla-tarifa.create",
|
||||
"plantilla-tarifa.edit",
|
||||
"plantilla-tarifa.delete",
|
||||
"plantilla-tarifa.menu",
|
||||
"presupuesto.create",
|
||||
"presupuesto.edit",
|
||||
"presupuesto.delete",
|
||||
"presupuesto.menu",
|
||||
"tarifa-preimpresion.create",
|
||||
"tarifa-preimpresion.edit",
|
||||
"tarifa-preimpresion.delete",
|
||||
"tarifa-preimpresion.menu",
|
||||
"tarifa-manipulado.create",
|
||||
"tarifa-manipulado.edit",
|
||||
"tarifa-manipulado.delete",
|
||||
"tarifa-manipulado.menu",
|
||||
"tarifa-acabado.create",
|
||||
"tarifa-acabado.edit",
|
||||
"tarifa-acabado.delete",
|
||||
"tarifa-acabado.menu",
|
||||
"tarifa-encuadernacion.create",
|
||||
"tarifa-encuadernacion.edit",
|
||||
"tarifa-encuadernacion.delete",
|
||||
"tarifa-encuadernacion.menu",
|
||||
"tarifa-envio.create",
|
||||
"tarifa-envio.edit",
|
||||
"tarifa-envio.delete",
|
||||
"tarifa-envio.menu",
|
||||
"proveedores.create",
|
||||
"proveedores.edit",
|
||||
"proveedores.delete",
|
||||
"proveedores.menu",
|
||||
"ajustes.create",
|
||||
"ajustes.edit",
|
||||
"ajustes.delete",
|
||||
"ajustes.menu",
|
||||
"actividad.create",
|
||||
"actividad.edit",
|
||||
"actividad.delete",
|
||||
"actividad.menu",
|
||||
],
|
||||
"comercial" => [
|
||||
"token.token",
|
||||
"token.menu",
|
||||
@ -205,5 +159,33 @@ const SK_PERMISSION_MATRIX = [
|
||||
"actividad.edit",
|
||||
"actividad.delete",
|
||||
"actividad.menu",
|
||||
"paises.create",
|
||||
"paises.edit",
|
||||
"paises.delete",
|
||||
"paises.menu",
|
||||
"maquinas.create",
|
||||
"maquinas.edit",
|
||||
"maquinas.delete",
|
||||
"maquinas.menu",
|
||||
"maquinas-defecto.create",
|
||||
"maquinas-defecto.edit",
|
||||
"maquinas-defecto.delete",
|
||||
"maquinas-defecto.menu",
|
||||
"papel-generico.create",
|
||||
"papel-generico.edit",
|
||||
"papel-generico.delete",
|
||||
"papel-generico.menu",
|
||||
"papel-impresion.create",
|
||||
"papel-impresion.edit",
|
||||
"papel-impresion.delete",
|
||||
"papel-impresion.menu",
|
||||
"usuarios.create",
|
||||
"usuarios.edit",
|
||||
"usuarios.delete",
|
||||
"usuarios.menu",
|
||||
"roles-permisos.create",
|
||||
"roles-permisos.edit",
|
||||
"roles-permisos.delete",
|
||||
"roles-permisos.menu",
|
||||
],
|
||||
];
|
||||
|
||||
@ -5,13 +5,9 @@ const SK_ROLES = [
|
||||
'title' => 'Administrador',
|
||||
'description' => '',
|
||||
],
|
||||
'cliente-admin' => [
|
||||
'title' => 'Cliente administrador',
|
||||
'description' => 'Rol de cliente con permisos de administración',
|
||||
],
|
||||
'cliente-editor' => [
|
||||
'title' => 'Cliente editor',
|
||||
'description' => 'Rol de cliente con permisos de edición',
|
||||
'cliente' => [
|
||||
'title' => 'Cliente',
|
||||
'description' => 'Rol de cliente',
|
||||
],
|
||||
'comercial' => [
|
||||
'title' => 'Comercial',
|
||||
|
||||
@ -545,6 +545,7 @@ $routes->group('presupuestocliente', ['namespace' => 'App\Controllers\Presupuest
|
||||
$routes->post('getDatosDireccion', 'Presupuestocliente::getDatosDireccion', ['as' => 'getDatosDireccion']);
|
||||
$routes->post('getNuevaDireccion', 'Presupuestocliente::getNuevaDireccion', ['as' => 'nuevaDireccion']);
|
||||
$routes->post('guardarPresupuesto', 'Presupuestocliente::guardarPresupuesto', ['as' => 'guardarPresupuesto']);
|
||||
$routes->post('duplicarPresupuesto', 'Presupuestocliente::duplicarPresupuesto', ['as' => 'duplicarPresupuesto']);
|
||||
});
|
||||
$routes->resource('presupuestocliente', ['namespace' => 'App\Controllers\Presupuestos', 'controller' => 'Presupuestocliente', 'except' => 'show,new,create,update']);
|
||||
|
||||
|
||||
@ -861,6 +861,7 @@ class Cosidotapablanda extends \App\Controllers\BaseResourceController
|
||||
$presupuesto = $this->model->find($id);
|
||||
$presupuesto->titulo = $presupuesto->titulo .' - ' . lang('Presupuestos.duplicado');
|
||||
$presupuesto->is_duplicado = 1;
|
||||
$presupuesto->estado_id = 1;
|
||||
$new_id = $this->model->insert($presupuesto);
|
||||
|
||||
$presupuestoAcabadosModel = model('App\Models\Presupuestos\PresupuestoAcabadosModel');
|
||||
|
||||
@ -158,22 +158,32 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
|
||||
$datosPresupuesto->acabadosSobrecubierta = $this->getAcabadosSobrecubierta();
|
||||
|
||||
$datosPresupuesto->tipo_libro = $this->getTipoLibro($presupuestoEntity->tipo_impresion_id ?? null);
|
||||
[$datosPresupuesto->color_impresion, $datosPresupuesto->calidad_impresion] =
|
||||
[$datosPresupuesto->color_impresion, $datosPresupuesto->calidad_impresion] =
|
||||
$this->getTipoInterior($presupuestoEntity->id ?? null);
|
||||
$datosPresupuesto->tapa = $this->getTapa($presupuestoEntity->tipo_impresion_id ?? null);
|
||||
|
||||
$datosPresupuesto->clienteList = $this->getClienteListItems($presupuestoEntity->cliente_id ?? null);
|
||||
|
||||
$this->obtenerTiradas($presupuestoEntity);
|
||||
$this->obtenerDatosPapel($presupuestoEntity);
|
||||
$this->obtenerPaginasColor($presupuestoEntity);
|
||||
$this->obtenerDireccionesEnvio($presupuestoEntity);
|
||||
|
||||
// Si el presupuesto está confirmado, se generan los datos del resumen
|
||||
if($presupuestoEntity->estado_id == 2){
|
||||
$this->generarResumen($presupuestoEntity);
|
||||
}
|
||||
|
||||
$this->viewData['formAction'] = route_to('updateCosidotapablanda', $id);
|
||||
|
||||
$this->viewData['paisList'] = $this->getPaisListItems();
|
||||
|
||||
$this->viewData['presupuestoEntity'] = $presupuestoEntity;
|
||||
$this->viewData['datosPresupuesto'] = $datosPresupuesto;
|
||||
|
||||
|
||||
// Si se ha llamado a esta funcion porque se ha duplicado el presupuesto
|
||||
// se actualiza la bbdd para que sólo ejecute algunas funciones una vez
|
||||
if($presupuestoEntity->is_duplicado){
|
||||
if ($presupuestoEntity->is_duplicado) {
|
||||
$this->model->removeIsDuplicado($presupuestoEntity->id);
|
||||
}
|
||||
|
||||
@ -217,33 +227,7 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
|
||||
}
|
||||
}
|
||||
|
||||
// Se borran las lineas de presupuesto
|
||||
$model = new PresupuestoLineaModel();
|
||||
$model->where("presupuesto_id", $id)->delete();
|
||||
|
||||
// Se borran las direcciones de presupuesto
|
||||
$model = new PresupuestoDireccionesModel();
|
||||
$model->where("presupuesto_id", $id)->delete();
|
||||
|
||||
// Se borran los servicios de acabado
|
||||
$model = new PresupuestoAcabadosModel();
|
||||
$model->where("presupuesto_id", $id)->delete();
|
||||
|
||||
// Se borran los servicios de preimpresion
|
||||
$model = new PresupuestoPreimpresionesModel();
|
||||
$model->where("presupuesto_id", $id)->delete();
|
||||
|
||||
// Se borran los servicios de encuadernacion
|
||||
$model = new PresupuestoEncuadernacionesModel();
|
||||
$model->where("presupuesto_id", $id)->delete();
|
||||
|
||||
// Se borran los servicios de manipulado
|
||||
$model = new PresupuestoManipuladosModel();
|
||||
$model->where("presupuesto_id", $id)->delete();
|
||||
|
||||
// Se borran los servicios extra
|
||||
$model = new PresupuestoServiciosExtraModel();
|
||||
$model->where("presupuesto_id", $id)->delete();
|
||||
$this->borrarRelacionesPresupuesto($id);
|
||||
|
||||
// $message = lang('Basic.global.deleteSuccess', [$objName]); IMN commented
|
||||
$message = lang('Basic.global.deleteSuccess', [lang('Basic.global.record')]);
|
||||
@ -251,6 +235,7 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
|
||||
return $response;
|
||||
}
|
||||
|
||||
|
||||
public function getGramaje()
|
||||
{
|
||||
if ($this->request->isAJAX()) {
|
||||
@ -369,7 +354,7 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
|
||||
$sobreCubierta = $reqData["sobrecubierta"] ?? null;
|
||||
|
||||
// Guardas
|
||||
$datos_guardas = $reqData['guardas'] ?? 0;
|
||||
$datos_guardas = $reqData['guardas'] ?? [];
|
||||
|
||||
$servicios = $reqData['servicios'] ?? [];
|
||||
|
||||
@ -493,6 +478,91 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
|
||||
}
|
||||
}
|
||||
|
||||
public function duplicarPresupuesto(){
|
||||
if ($this->request->isAJAX()) {
|
||||
|
||||
$reqData = $this->request->getPost();
|
||||
|
||||
$newTokenHash = csrf_hash();
|
||||
$csrfTokenName = csrf_token();
|
||||
|
||||
$id = $reqData['id'] ?? 0;
|
||||
|
||||
if($id > 0){
|
||||
try{
|
||||
|
||||
$presupuesto = $this->model->find($id);
|
||||
$presupuesto->titulo = $presupuesto->titulo .' - ' . lang('Presupuestos.duplicado');
|
||||
$presupuesto->is_duplicado = 1;
|
||||
$presupuesto->estado_id = 1;
|
||||
$new_id = $this->model->insert($presupuesto);
|
||||
|
||||
$presupuestoAcabadosModel = model('App\Models\Presupuestos\PresupuestoAcabadosModel');
|
||||
foreach ($presupuestoAcabadosModel->where('presupuesto_id', $presupuesto->id)->findAll() as $acabado) {
|
||||
$acabado->presupuesto_id = $new_id;
|
||||
$presupuestoAcabadosModel->insert($acabado);
|
||||
}
|
||||
|
||||
$presupuestoEncuadernacionesModel = model('App\Models\Presupuestos\PresupuestoEncuadernacionesModel');
|
||||
foreach ($presupuestoEncuadernacionesModel->where('presupuesto_id', $presupuesto->id)->findAll() as $encuadernacion) {
|
||||
$encuadernacion->presupuesto_id = $new_id;
|
||||
$presupuestoEncuadernacionesModel->insert($encuadernacion);
|
||||
}
|
||||
|
||||
$presupuestoManipuladosModel = model('App\Models\Presupuestos\PresupuestoManipuladosModel');
|
||||
foreach ($presupuestoManipuladosModel->where('presupuesto_id', $presupuesto->id)->findAll() as $manipulado) {
|
||||
$manipulado->presupuesto_id = $new_id;
|
||||
$presupuestoManipuladosModel->insert($manipulado);
|
||||
}
|
||||
|
||||
$presupuestoPreimpresionesModel = model('App\Models\Presupuestos\PresupuestoPreimpresionesModel');
|
||||
foreach ($presupuestoPreimpresionesModel->where('presupuesto_id', $presupuesto->id)->findAll() as $preimpresion) {
|
||||
$preimpresion->presupuesto_id = $new_id;
|
||||
$presupuestoPreimpresionesModel->insert($preimpresion);
|
||||
}
|
||||
|
||||
$presupuestoServiciosExtraModel = model('App\Models\Presupuestos\PresupuestoServiciosExtraModel');
|
||||
foreach ($presupuestoServiciosExtraModel->where('presupuesto_id', $presupuesto->id)->findAll() as $servicioExtra) {
|
||||
$servicioExtra->presupuesto_id = $new_id;
|
||||
$presupuestoServiciosExtraModel->insert($preimpresion);
|
||||
}
|
||||
|
||||
$presupuestoDireccionesModel = model('App\Models\Presupuestos\PresupuestoDireccionesModel');
|
||||
foreach ($presupuestoDireccionesModel->where('presupuesto_id', $presupuesto->id)->findAll() as $direccion) {
|
||||
$direccion->presupuesto_id = $new_id;
|
||||
$presupuestoDireccionesModel->insert($direccion);
|
||||
}
|
||||
|
||||
$presupuestoLineaModel = model('App\Models\Presupuestos\PresupuestoLineaModel');
|
||||
$presupuestoLineaModel->duplicateLineasPresupuesto($presupuesto->id, $new_id);
|
||||
|
||||
return $this->respond([
|
||||
'success' => true,
|
||||
'id' => $new_id,
|
||||
$csrfTokenName => $newTokenHash
|
||||
]);
|
||||
|
||||
}catch(\Exception $e){
|
||||
return $this->respond([
|
||||
'success' => false,
|
||||
'message' => $e->getMessage(),
|
||||
$csrfTokenName => $newTokenHash
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
return $this->respond([
|
||||
'success' => false,
|
||||
'message' => "No existe el presupuesto",
|
||||
$csrfTokenName => $newTokenHash
|
||||
|
||||
]);
|
||||
|
||||
} else {
|
||||
return $this->failUnauthorized('Invalid request', 403);
|
||||
}
|
||||
}
|
||||
|
||||
public function guardarPresupuesto()
|
||||
{
|
||||
if ($this->request->isAJAX()) {
|
||||
@ -504,6 +574,9 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
|
||||
|
||||
$confirmar = $reqData['confirmar'] ?? 0;
|
||||
|
||||
$id = $reqData['id'] ?? 0;
|
||||
$id = intval($id);
|
||||
|
||||
$datosCabecera = $reqData['datos_cabecera'] ?? [];
|
||||
|
||||
$tirada = $reqData['datos_libro']['tirada'] ?? 0;
|
||||
@ -600,12 +673,22 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
|
||||
|
||||
$proporcion = intval($direccion['unidades']) / $selected_tirada * 100.0;
|
||||
$unidades_calculo = floor($tirada[$i] * $proporcion / 100.0);
|
||||
$coste_envio = $this->calcular_coste_envio(
|
||||
$direccion['id'],
|
||||
$peso_libro,
|
||||
$unidades_calculo,
|
||||
$direccion['tipo'] == 'cajas' ? 0 : 1
|
||||
);
|
||||
try{
|
||||
$coste_envio = $this->calcular_coste_envio(
|
||||
$direccion['id'],
|
||||
$peso_libro,
|
||||
$unidades_calculo,
|
||||
$direccion['tipo'] == 'cajas' ? 0 : 1
|
||||
);
|
||||
}
|
||||
catch(Exception $e){
|
||||
return $this->respond([
|
||||
'status' => -1,
|
||||
'message' => "Error al calcular el coste de envío (¿las direcciones están guardadas?)",
|
||||
$csrfTokenName => $newTokenHash
|
||||
]);
|
||||
}
|
||||
|
||||
if (count($coste_envio) > 0) {
|
||||
$coste = floatval($coste_envio[0]->coste);
|
||||
$margen = ($coste * floatval($coste_envio[0]->margen)) / 100.0;
|
||||
@ -644,17 +727,28 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
|
||||
}
|
||||
}
|
||||
|
||||
$borrar_antes = false;
|
||||
if ($id != 0) {
|
||||
$borrar_antes = true;
|
||||
}
|
||||
|
||||
$id = $model_presupuesto->insertarPresupuestoCliente(
|
||||
$id,
|
||||
$selected_tirada,
|
||||
$datos_presupuesto,
|
||||
$datosCabecera,
|
||||
$resultado_presupuesto['info'],
|
||||
$resumen_totales,
|
||||
$iva_reducido,
|
||||
$excluirRotativa,
|
||||
$tiradas_alternativas
|
||||
);
|
||||
|
||||
// Lineas Presupuesto
|
||||
if ($borrar_antes && $id > 0) {
|
||||
$this->borrarRelacionesPresupuesto($id);
|
||||
}
|
||||
|
||||
foreach ($resultado_presupuesto['info']['interior'] as $linea) {
|
||||
|
||||
if (count($linea) > 0)
|
||||
@ -688,7 +782,7 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
|
||||
$this->guardarLineaEnvio($id, $direccion, $peso_libro);
|
||||
}
|
||||
|
||||
if($confirmar == 1){
|
||||
if ($confirmar) {
|
||||
$model_presupuesto->confirmarPresupuesto($id);
|
||||
}
|
||||
|
||||
@ -709,6 +803,37 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
|
||||
* Funciones auxiliares
|
||||
*
|
||||
**********************/
|
||||
protected function borrarRelacionesPresupuesto($id)
|
||||
{
|
||||
// Se borran las lineas de presupuesto
|
||||
$model = new PresupuestoLineaModel();
|
||||
$model->where("presupuesto_id", $id)->delete();
|
||||
|
||||
// Se borran las direcciones de presupuesto
|
||||
$model = new PresupuestoDireccionesModel();
|
||||
$model->where("presupuesto_id", $id)->delete();
|
||||
|
||||
// Se borran los servicios de acabado
|
||||
$model = new PresupuestoAcabadosModel();
|
||||
$model->where("presupuesto_id", $id)->delete();
|
||||
|
||||
// Se borran los servicios de preimpresion
|
||||
$model = new PresupuestoPreimpresionesModel();
|
||||
$model->where("presupuesto_id", $id)->delete();
|
||||
|
||||
// Se borran los servicios de encuadernacion
|
||||
$model = new PresupuestoEncuadernacionesModel();
|
||||
$model->where("presupuesto_id", $id)->delete();
|
||||
|
||||
// Se borran los servicios de manipulado
|
||||
$model = new PresupuestoManipuladosModel();
|
||||
$model->where("presupuesto_id", $id)->delete();
|
||||
|
||||
// Se borran los servicios extra
|
||||
$model = new PresupuestoServiciosExtraModel();
|
||||
$model->where("presupuesto_id", $id)->delete();
|
||||
}
|
||||
|
||||
protected function guardarLineaPresupuesto($presupuestoId, $linea)
|
||||
{
|
||||
|
||||
@ -880,7 +1005,7 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
|
||||
$sobreCubierta = $datos_entrada["sobrecubierta"] ?? null;
|
||||
|
||||
// Guardas
|
||||
$datos_guardas = $datos_entrada['guardas'] ?? [];
|
||||
$datos_guardas = $datos_entrada['datos_guardas'] ?? [];
|
||||
|
||||
// Servicios
|
||||
$servicios = $datos_entrada['servicios'] ?? [];
|
||||
@ -929,6 +1054,7 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
|
||||
'ancho' => intval($tamanio['ancho']) ?? 100000,
|
||||
'alto' => intval($tamanio['alto']) ?? 100000,
|
||||
'isCosido' => $is_cosido,
|
||||
'a_favor_fibra' => 1,
|
||||
);
|
||||
if ($extra_info) {
|
||||
$info['merma'] = $datosPedido->merma;
|
||||
@ -1046,7 +1172,7 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
|
||||
if ($extra_info) {
|
||||
|
||||
$this->calcular_coste_linea(
|
||||
$linea,
|
||||
$cubierta,
|
||||
$totalPapel,
|
||||
$margenPapel,
|
||||
$sumForFactor,
|
||||
@ -1080,11 +1206,11 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
|
||||
$lomo_sobrecubierta = 0.0;
|
||||
if (!is_null($sobreCubierta)) {
|
||||
|
||||
$papel_generico = [
|
||||
$papel_generico_sobrecubierta = [
|
||||
'id' => $sobreCubierta['papel'] ?? 0,
|
||||
'nombre' => $sobreCubierta['papel_nombre'] ?? "",
|
||||
];
|
||||
$input_data['papel_generico'] = $papel_generico;
|
||||
$input_data['papel_generico'] = $papel_generico_sobrecubierta;
|
||||
$input_data['gramaje'] = $sobreCubierta['gramaje'] ?? 0;
|
||||
$input_data['datosPedido']->paginas = 4;
|
||||
$input_data['paginas_color'] = 4;
|
||||
@ -1103,7 +1229,7 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
|
||||
if ($extra_info) {
|
||||
|
||||
$this->calcular_coste_linea(
|
||||
$linea,
|
||||
$linea_sobrecubierta,
|
||||
$totalPapel,
|
||||
$margenPapel,
|
||||
$sumForFactor,
|
||||
@ -1136,57 +1262,57 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
|
||||
$guardas = [];
|
||||
$peso_guardas = 0.0;
|
||||
$coste_guardas = 0.0;
|
||||
if($datos_guardas != 0){
|
||||
if (count($datos_guardas) != 0) {
|
||||
|
||||
if (count($datos_guardas) != 0) {
|
||||
$guardas = $datos_guardas;
|
||||
$papel_generico_guardas = [
|
||||
'id' => $datos_guardas['papel'] ?? 0,
|
||||
'nombre' => $datos_guardas['nombre'] ?? "",
|
||||
];
|
||||
$input_data['papel_generico'] = $papel_generico_guardas;
|
||||
$input_data['gramaje'] = $datos_guardas['gramaje'] ?? 0;
|
||||
$input_data['datosPedido']->paginas = 8;
|
||||
$input_data['paginas_color'] = 8;
|
||||
$input_data['datosPedido']->paginas_impresion = $datos_guardas['caras'] ?? 0;
|
||||
$input_data['datosPedido']->solapas_ancho = 0;
|
||||
$input_data['datosPedido']->solapas = 0;
|
||||
$input_data['isColor'] = 1;
|
||||
$input_data['isHq'] = 1;
|
||||
$input_data['uso'] = 'guardas';
|
||||
|
||||
$guardas = $datos_guardas;
|
||||
$papel_generico = [
|
||||
'id' => $datos_guardas['papel'] ?? 0,
|
||||
'nombre' => $datos_guardas['nombre'] ?? "",
|
||||
];
|
||||
$input_data['papel_generico'] = $papel_generico;
|
||||
$input_data['gramaje'] = $datos_guardas['gramaje'] ?? 0;
|
||||
$input_data['datosPedido']->paginas = 8;
|
||||
$input_data['paginas_color'] = 8;
|
||||
$input_data['datosPedido']->paginas_impresion = $datos_guardas['caras'] ?? 0;
|
||||
$input_data['datosPedido']->solapas_ancho = 0;
|
||||
$input_data['datosPedido']->solapas = 0;
|
||||
$input_data['isColor'] = 1;
|
||||
$input_data['isHq'] = 1;
|
||||
$input_data['uso'] = 'guardas';
|
||||
|
||||
// Para el caso de Fresado y Cosido tapa dura, las guardas son un diptico
|
||||
// y hay que imprimirlas como "cosido" (dos hojas pegadas). En el caso de espiral
|
||||
// o wire-o tapa dura, las guardas se imprimen como hojas sueltas
|
||||
if ($tipo_impresion_id == 1 || $tipo_impresion_id == 3) {
|
||||
$input_data['datosPedido']->isCosido = true;
|
||||
} else if ($tipo_impresion_id == 5 || $tipo_impresion_id == 7) {
|
||||
$input_data['datosPedido']->isCosido = false;
|
||||
}
|
||||
|
||||
$guardas = PresupuestoClienteService::obtenerGuardas($input_data);
|
||||
|
||||
if (count($guardas) > 0) {
|
||||
$coste_guardas += floatval($guardas['total_impresion']);
|
||||
$peso_guardas += floatval($guardas['peso']);
|
||||
if ($extra_info) {
|
||||
|
||||
$this->calcular_coste_linea(
|
||||
$linea,
|
||||
$totalPapel,
|
||||
$margenPapel,
|
||||
$sumForFactor,
|
||||
$totalImpresion,
|
||||
$margenImpresion
|
||||
);
|
||||
// Para el caso de Fresado y Cosido tapa dura, las guardas son un diptico
|
||||
// y hay que imprimirlas como "cosido" (dos hojas pegadas). En el caso de espiral
|
||||
// o wire-o tapa dura, las guardas se imprimen como hojas sueltas
|
||||
if ($tipo_impresion_id == 1 || $tipo_impresion_id == 3) {
|
||||
$input_data['datosPedido']->isCosido = true;
|
||||
} else if ($tipo_impresion_id == 5 || $tipo_impresion_id == 7) {
|
||||
$input_data['datosPedido']->isCosido = false;
|
||||
}
|
||||
}
|
||||
if ($coste_guardas <= 0)
|
||||
$error->guardas = lang('Presupuestos.errores.noGuardas');
|
||||
else
|
||||
$error->guardas = "";
|
||||
}
|
||||
|
||||
$guardas = PresupuestoClienteService::obtenerGuardas($input_data);
|
||||
|
||||
if (count($guardas) > 0) {
|
||||
$coste_guardas += floatval($guardas['total_impresion']);
|
||||
$peso_guardas += floatval($guardas['peso']);
|
||||
if ($extra_info) {
|
||||
|
||||
$this->calcular_coste_linea(
|
||||
$guardas,
|
||||
$totalPapel,
|
||||
$margenPapel,
|
||||
$sumForFactor,
|
||||
$totalImpresion,
|
||||
$margenImpresion
|
||||
);
|
||||
}
|
||||
}
|
||||
if ($coste_guardas <= 0)
|
||||
$error->guardas = lang('Presupuestos.errores.noGuardas');
|
||||
else
|
||||
$error->guardas = "";
|
||||
}
|
||||
}
|
||||
if ($extra_info) {
|
||||
$totalPapel -= $margenPapel;
|
||||
$totalImpresion -= $margenImpresion;
|
||||
@ -1263,8 +1389,8 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
|
||||
|
||||
$coste_servicios += floatval($resultado[0]->precio);
|
||||
if ($extra_info) {
|
||||
$totalServicios += floatval($resultado[0]->total);
|
||||
$margenServicios += floatval($resultado[0]->total) * floatval($resultado[0]->margen) / 100.0;
|
||||
$totalServicios += floatval($resultado[0]->precio);
|
||||
$margenServicios += floatval($resultado[0]->precio) * floatval($resultado[0]->margen) / 100.0;
|
||||
}
|
||||
} else if (intval($servicio) == 62) {
|
||||
// Servicios manipulado
|
||||
@ -1317,7 +1443,7 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
|
||||
));
|
||||
}
|
||||
|
||||
if ($extra_info && $tirada[$t] == $selected_tirada) {
|
||||
if ($extra_info) { // && $tirada[$t] == $selected_tirada) {
|
||||
|
||||
$info['lomo_cubierta'] = $lomo;
|
||||
$info['lomo_sobrecubierta'] = $lomo_sobrecubierta;
|
||||
@ -1369,8 +1495,10 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
|
||||
|
||||
if ($linea['tipo_maquina'] == 'inkjet') {
|
||||
$totalImpresion += $linea['precio_tinta'];
|
||||
$totalImpresion += $linea['total_corte'];
|
||||
$sumForFactor += $linea['total_corte'];
|
||||
if (array_key_exists('total_corte', $linea)) {
|
||||
$totalImpresion += $linea['total_corte'];
|
||||
$sumForFactor += $linea['total_corte'];
|
||||
}
|
||||
}
|
||||
$margenImpresion += $linea['margen_impresion_horas'];
|
||||
$margenImpresion += $linea['margen_click_pedido'];
|
||||
@ -1495,54 +1623,239 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
protected function getTipoLibro($tipo_impresion_id){
|
||||
if($tipo_impresion_id == 1 || $tipo_impresion_id == 2){
|
||||
|
||||
protected function getTipoLibro($tipo_impresion_id)
|
||||
{
|
||||
if ($tipo_impresion_id == 1 || $tipo_impresion_id == 2) {
|
||||
return 'fresado';
|
||||
}
|
||||
else if ($tipo_impresion_id == 3 || $tipo_impresion_id == 4){
|
||||
} else if ($tipo_impresion_id == 3 || $tipo_impresion_id == 4) {
|
||||
return 'cosido';
|
||||
}
|
||||
else if ($tipo_impresion_id == 5 || $tipo_impresion_id == 6){
|
||||
} else if ($tipo_impresion_id == 5 || $tipo_impresion_id == 6) {
|
||||
return 'espiral';
|
||||
}
|
||||
else if ($tipo_impresion_id == 7 || $tipo_impresion_id == 8){
|
||||
} else if ($tipo_impresion_id == 7 || $tipo_impresion_id == 8) {
|
||||
return 'wireo';
|
||||
}
|
||||
else if ($tipo_impresion_id == 21){
|
||||
} else if ($tipo_impresion_id == 21) {
|
||||
return 'grapado';
|
||||
}
|
||||
else
|
||||
} else
|
||||
return '';
|
||||
}
|
||||
protected function getTipoInterior($presupuestoId){
|
||||
protected function getTipoInterior($presupuestoId)
|
||||
{
|
||||
|
||||
$calidad = 'estandar';
|
||||
$color = 'negro';
|
||||
|
||||
$model = model('App\Models\Presupuestos\PresupuestoLineaModel');
|
||||
$data = $model->where('presupuestoId', $presupuestoId)->findAll();;
|
||||
foreach($data as $linea){
|
||||
$data = $model->where('presupuesto_id', $presupuestoId)->findAll();;
|
||||
foreach ($data as $linea) {
|
||||
|
||||
if (strpos($linea->tipo, "hq") !== false) { // $linea->tipo contains the substring "hq"
|
||||
$calidad='premium';
|
||||
$calidad = 'premium';
|
||||
}
|
||||
if (strpos($linea->tipo, "hq") !== false) { // $linea->tipo contains the substring "hq"
|
||||
$color='color';
|
||||
if (strpos($linea->tipo, "color") !== false) { // $linea->tipo contains the substring "color"
|
||||
$color = 'color';
|
||||
}
|
||||
}
|
||||
return [$color, $calidad];
|
||||
|
||||
}
|
||||
|
||||
protected function getTapa($tipo_impresion_id ){
|
||||
|
||||
|
||||
protected function getTapa($tipo_impresion_id)
|
||||
{
|
||||
|
||||
$tapa = 'blanda';
|
||||
|
||||
if($tipo_impresion_id == 1 || $tipo_impresion_id == 3 ||
|
||||
$tipo_impresion_id == 5 || $tipo_impresion_id == 7)
|
||||
if (
|
||||
$tipo_impresion_id == 1 || $tipo_impresion_id == 3 ||
|
||||
$tipo_impresion_id == 5 || $tipo_impresion_id == 7
|
||||
)
|
||||
$tapa = 'dura';
|
||||
|
||||
|
||||
return $tapa;
|
||||
}
|
||||
|
||||
protected function obtenerPaginasColor($presupuestoEntity)
|
||||
{
|
||||
$comparador_data = json_decode($presupuestoEntity->comparador_json_data);
|
||||
if (property_exists($comparador_data, 'color')) {
|
||||
$presupuestoEntity->paginasColor = $comparador_data->color->paginas;
|
||||
}
|
||||
if (property_exists($comparador_data, 'colorhq')) {
|
||||
$presupuestoEntity->paginasColor = $comparador_data->colorhq->paginas;
|
||||
} else {
|
||||
$presupuestoEntity->paginasColor = 0;
|
||||
}
|
||||
}
|
||||
|
||||
protected function obtenerTiradas($presupuestoEntity)
|
||||
{
|
||||
|
||||
$tiradas_alternativas = json_decode($presupuestoEntity->tirada_alternativa_json_data, true);
|
||||
$tiradas = array();
|
||||
array_push($tiradas, $presupuestoEntity->tirada);
|
||||
if (!is_null($tiradas_alternativas)) {
|
||||
if (count($tiradas_alternativas) > 0) {
|
||||
foreach ($tiradas_alternativas as $tirada) {
|
||||
array_push($tiradas, intval($tirada['tirada']));
|
||||
}
|
||||
}
|
||||
}
|
||||
sort($tiradas);
|
||||
$presupuestoEntity->selected_tirada = $presupuestoEntity->tirada;
|
||||
for ($i = 0; $i < count($tiradas); $i++) {
|
||||
$key = 'tirada' . ($i == 0 ? '' : strval($i + 1));
|
||||
$presupuestoEntity->$key = $tiradas[$i];
|
||||
}
|
||||
}
|
||||
|
||||
protected function obtenerDireccionesEnvio($presupuestoEntity)
|
||||
{
|
||||
$model = model('App\Models\Presupuestos\PresupuestoDireccionesModel');
|
||||
$model_direcciones = model('App\Models\Clientes\ClienteDireccionesModel');
|
||||
$model_pais = model('App\Models\Configuracion\PaisModel');
|
||||
$direcciones = $model->where('presupuesto_id', $presupuestoEntity->id)->findAll();
|
||||
|
||||
$result = [];
|
||||
$temp = [];
|
||||
for ($i=0; $i<count($direcciones); $i++) {
|
||||
$direccion_id = $model_direcciones->getIdForPresupuestoCliente(
|
||||
$presupuestoEntity->cliente_id,
|
||||
$direcciones[$i]->att,
|
||||
$direcciones[$i]->email,
|
||||
$direcciones[$i]->direccion,
|
||||
$direcciones[$i]->cp,
|
||||
$direcciones[$i]->pais_id,
|
||||
$direcciones[$i]->telefono);
|
||||
if(count($direccion_id) > 0) {
|
||||
$temp = $direcciones[$i]->toArray();
|
||||
$temp['pais'] = $model_pais->where('id', $direcciones[$i]->pais_id)->first()->nombre;
|
||||
$temp['direccion_id'] = $direccion_id[0]->id;
|
||||
array_push($result, $temp);
|
||||
}
|
||||
}
|
||||
if(count($result) > 0)
|
||||
$presupuestoEntity->direcciones_envio = $result;
|
||||
}
|
||||
|
||||
protected function obtenerDatosPapel($presupuestoEntity)
|
||||
{
|
||||
|
||||
$id = $presupuestoEntity->id;
|
||||
|
||||
$model = model('App\Models\Presupuestos\PresupuestoLineaModel');
|
||||
$data = $model->where('presupuesto_id', $id)->findAll();
|
||||
if (count($data) > 0) {
|
||||
foreach ($data as $linea) {
|
||||
// Se coje el primer papel que se encuentre para el interior
|
||||
// para presupuestos del cliente sólo se escoje un papel para el interior
|
||||
if (strpos($linea->tipo, "bn") !== false || strpos($linea->tipo, "color") !== false) {
|
||||
$presupuestoEntity->papel_interior = $linea->papel_id;
|
||||
$presupuestoEntity->gramaje_interior = $linea->gramaje;
|
||||
}
|
||||
// Si es cubierta
|
||||
else if (strpos($linea->tipo, "cubierta") !== false && strpos($linea->tipo, "sobrecubierta") === false) {
|
||||
$presupuestoEntity->papel_cubierta = $linea->papel_id;
|
||||
$presupuestoEntity->gramaje_cubierta = $linea->gramaje;
|
||||
$presupuestoEntity->paginas_cubierta = $linea->paginas;
|
||||
}
|
||||
// Si es sobrecubierta
|
||||
else if (strpos($linea->tipo, "sobrecubierta") !== false) {
|
||||
$presupuestoEntity->papel_sobrecubierta = $linea->papel_id;
|
||||
$presupuestoEntity->gramaje_sobrecubierta = $linea->gramaje;
|
||||
$presupuestoEntity->paginas_sobrecubierta = $linea->paginas;
|
||||
}
|
||||
// Si es guardas
|
||||
else if (strpos($linea->tipo, "guardas") !== false) {
|
||||
$presupuestoEntity->papel_guardas = $linea->papel_id;
|
||||
$presupuestoEntity->paginas_guardas = $linea->paginas;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected function generarResumen($presupuestoEntity){
|
||||
|
||||
$presupuestoEntity->resumen = (object)[
|
||||
'titulo' => $this->generarTitulo($presupuestoEntity),
|
||||
'tamanio' => $this->obtenerTamanio($presupuestoEntity),
|
||||
'tipo_impresion' => $this->obtenerTipoImpresion($presupuestoEntity)
|
||||
];
|
||||
|
||||
$model_papelGenerico = model('App\Models\Configuracion\PapelGenericoModel');
|
||||
if(!is_null($presupuestoEntity->papel_interior)){
|
||||
$nombre = $model_papelGenerico->where('id', $presupuestoEntity->papel_interior)->first()->nombre;
|
||||
if($nombre != null)
|
||||
$presupuestoEntity->papel_interior_nombre = $nombre;
|
||||
}
|
||||
if(!is_null($presupuestoEntity->papel_cubierta)){
|
||||
$nombre = $model_papelGenerico->where('id', $presupuestoEntity->papel_interior)->first()->nombre;
|
||||
if($nombre != null)
|
||||
$presupuestoEntity->papel_cubierta_nombre = $nombre;
|
||||
}
|
||||
if(!is_null($presupuestoEntity->papel_sobrecubierta)){
|
||||
$nombre = $model_papelGenerico->where('id', $presupuestoEntity->papel_sobrecubierta)->first()->nombre;
|
||||
if($nombre != null)
|
||||
$presupuestoEntity->papel_sobrecubierta_nombre = $nombre;
|
||||
}
|
||||
if(!is_null($presupuestoEntity->papel_guardas)){
|
||||
$nombre = $model_papelGenerico->where('id', $presupuestoEntity->papel_guardas)->first()->nombre;
|
||||
if($nombre != null)
|
||||
$presupuestoEntity->papel_guardas_nombre = $nombre;
|
||||
}
|
||||
}
|
||||
|
||||
protected function generarTitulo($presupuestoEntity){
|
||||
|
||||
$model = model('App\Models\Configuracion\TipoPresupuestoModel');
|
||||
$codigo = $model->where('id', $presupuestoEntity->tipo_impresion_id)->first()->codigo;
|
||||
$titulo = lang('Presupuestos.titulos.'.$codigo);
|
||||
return $titulo;
|
||||
}
|
||||
|
||||
protected function obtenerTamanio($presupuestoEntity){
|
||||
|
||||
$ancho = 0;
|
||||
$alto = 0;
|
||||
|
||||
$model = model('App\Models\Presupuestos\PresupuestoModel');
|
||||
$data = $model->where('id', $presupuestoEntity->id)->first();
|
||||
|
||||
if($data != null){
|
||||
if($data->papel_formato_personalizado == 0){
|
||||
|
||||
$model_papel_formato = model('App\Models\Configuracion\PapelFormatoModel');
|
||||
$data_papel_formato = $model_papel_formato->where('id', $data->papel_formato_id)->first();
|
||||
$ancho = $data_papel_formato->ancho;
|
||||
$alto = $data_papel_formato->alto;
|
||||
}
|
||||
else{
|
||||
$ancho = $data->papel_formato_ancho;
|
||||
$alto = $data->papel_formato_alto;
|
||||
}
|
||||
}
|
||||
|
||||
return $ancho . "x" . $alto;
|
||||
}
|
||||
|
||||
protected function obtenerTipoImpresion($presupuestoEntity){
|
||||
|
||||
$id = $presupuestoEntity->id;
|
||||
|
||||
$isColor = false;
|
||||
$isHq = false;
|
||||
|
||||
$model = model('App\Models\Presupuestos\PresupuestoLineaModel');
|
||||
$data = $model->where('presupuesto_id', $id)->findAll();
|
||||
if (count($data) > 0) {
|
||||
foreach ($data as $linea) {
|
||||
if (strpos($linea->tipo, "hq") !== false) {
|
||||
$isHq = true;
|
||||
}
|
||||
if (strpos($linea->tipo, "color") !== false) {
|
||||
$isColor = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
$tipo = "" . ($isColor ? "Color" : "Negro") . " " . ($isHq ? "premium" : "estándar");
|
||||
return $tipo;
|
||||
}
|
||||
}
|
||||
|
||||
@ -276,6 +276,17 @@ return [
|
||||
'actualizacionSolapasCubierta' => 'El tamaño de las solapas de la cubierta se ha actualizado debido a que supera el máximo permitido (este valor depende del ancho del libro y del número de páginas).',
|
||||
'actualizacionSolapasSobrecubierta' => 'El tamaño de las solapas de la sobrecubierta se ha actualizado debido a que supera el máximo permitido (este valor depende del ancho del libro y del número de páginas).',
|
||||
|
||||
'titulos' => [
|
||||
'libroFresadoTapaDura' => 'Rústica Fresado tapa dura',
|
||||
'libroFresadoTapaBlanda' => 'Rústica Fresado tapa blanda',
|
||||
'libroCosidoTapaDura' => 'Rústica Cosido tapa dura',
|
||||
'libroCosidoTapaBlanda' => 'Rústica Cosido tapa blanda',
|
||||
'libroEspiralTapaDura' => 'Espiral tapa dura',
|
||||
'libroEspiralTapaBlanda' => 'Espiral tapa blanda',
|
||||
'libroWireoTapaDura' => 'Wire-o tapa dura',
|
||||
'libroWireoTapaBlanda' => 'Wire-o tapa blanda',
|
||||
'libroGrapado' => 'Grapado',
|
||||
],
|
||||
|
||||
'validation' => [
|
||||
'decimal' => 'El campo {field} debe contener un número decimal.',
|
||||
|
||||
@ -141,6 +141,25 @@ class ClienteDireccionesModel extends \App\Models\BaseModel
|
||||
|
||||
return $builder->get()->getResultObject();
|
||||
}
|
||||
|
||||
public function getIdForPresupuestoCliente($cliente_id = -1, $att = "", $email = "", $direccion = "", $cp = "", $pais_id = -1, $telefono = "")
|
||||
{
|
||||
$builder = $this->db
|
||||
->table($this->table . " t1")
|
||||
->select("t1.id AS id")
|
||||
->where("t1.cliente_id", $cliente_id)
|
||||
->where("t1.att", $att)
|
||||
->where("t1.email", $email)
|
||||
->where("t1.direccion", $direccion)
|
||||
->where("t1.cp", $cp)
|
||||
->where("t1.pais_id", $pais_id)
|
||||
->where("t1.telefono", $telefono)
|
||||
->limit(1);
|
||||
|
||||
|
||||
return $builder->get()->getResultObject();
|
||||
}
|
||||
|
||||
|
||||
|
||||
public function getMenuDirecciones($cliente_id=-1){
|
||||
|
||||
@ -504,12 +504,12 @@ class PresupuestoLineaModel extends \App\Models\BaseModel
|
||||
'rotativa_clicks_libro' => $new_linea['clicks_libro'],
|
||||
'rotativa_clicks_total' => $new_linea['clicks_pedido'],
|
||||
'rotativa_precio_tinta' => $new_linea['precio_tinta'],
|
||||
'rotativa_mxm' => $new_linea['maquina_velocidad'],
|
||||
];
|
||||
}
|
||||
|
||||
if (strpos($new_linea['tipo_linea'], 'rot') !== false) {
|
||||
$data += [
|
||||
'rotativa_mxm' => $new_linea['maquina_velocidad'],
|
||||
'rotativa_metros_libro' => $new_linea['metros_papel_libro'],
|
||||
'rotativa_metros_total' => $new_linea['metros_papel_total'],
|
||||
'rotativa_velocidad_corte' => $new_linea['velocidad_corte'],
|
||||
@ -521,7 +521,7 @@ class PresupuestoLineaModel extends \App\Models\BaseModel
|
||||
}
|
||||
|
||||
if($new_linea['tipo_linea'] =='lp_guardas')
|
||||
array_push($data, ['paginas_impresion' => $new_linea['paginas_impresion']]);
|
||||
$data = array_merge($data, ['paginas_impresion' => $new_linea['paginas_impresion']]);
|
||||
|
||||
return $this->db
|
||||
->table($this->table . " t1")
|
||||
|
||||
@ -372,11 +372,11 @@ class PresupuestoModel extends \App\Models\BaseModel
|
||||
$this->db
|
||||
->table($this->table . " t1")
|
||||
->where('t1.id', $presupuesto_id)
|
||||
->set('t1.estado', 2)
|
||||
->set('t1.estado_id', 2)
|
||||
->update();
|
||||
}
|
||||
|
||||
function insertarPresupuestoCliente($tirada, $data, $data_cabecera, $extra_info, $resumen_totales, $iva_reducido, $tiradas_alternativas)
|
||||
function insertarPresupuestoCliente($id, $tirada, $data, $data_cabecera, $extra_info, $resumen_totales, $iva_reducido, $excluir_rotativa, $tiradas_alternativas)
|
||||
{
|
||||
|
||||
helper('date');
|
||||
@ -459,11 +459,22 @@ class PresupuestoModel extends \App\Models\BaseModel
|
||||
'total_factor_ponderado' => round(($totalCostes + $totalMargenes-$resumen_totales['coste_envio']-$resumen_totales['margen_envio'])/$resumen_totales['sumForFactorPonderado'], 2),
|
||||
|
||||
'iva_reducido' => $iva_reducido,
|
||||
'excluir_rotativa' => $excluir_rotativa,
|
||||
|
||||
];
|
||||
if($id != 0){
|
||||
$fields['id'] = $id;
|
||||
$fields['updated_at'] = date('Y-m-d H:i:s', now());
|
||||
}
|
||||
|
||||
$this->db->table($this->table)->insert($fields);
|
||||
return $this->db->insertID();
|
||||
if($id != 0){
|
||||
$this->db->table($this->table)->where('id', $id)->update($fields);
|
||||
return $id;
|
||||
}
|
||||
else{
|
||||
$this->db->table($this->table)->insert($fields);
|
||||
return $this->db->insertID();
|
||||
}
|
||||
}
|
||||
|
||||
private function generateJson($data)
|
||||
|
||||
@ -243,7 +243,6 @@ class PresupuestoClienteService extends BaseService
|
||||
|
||||
$paginas_negro = $datosPedido->paginas - $paginas_color;
|
||||
|
||||
|
||||
$linea_negro_plana = [];
|
||||
$linea_color_plana = [];
|
||||
|
||||
@ -290,6 +289,7 @@ class PresupuestoClienteService extends BaseService
|
||||
// Color
|
||||
if ($paginas_color > 0) {
|
||||
|
||||
$datosPedido->paginas = $paginas_color;
|
||||
for ($i = 0; $i < 2; $i++) {
|
||||
|
||||
$lineas = PresupuestoService::obtenerComparadorPlana([
|
||||
@ -322,7 +322,7 @@ class PresupuestoClienteService extends BaseService
|
||||
}
|
||||
);
|
||||
$linea_color_plana = $linea_color_plana[0]['fields'];
|
||||
$linea_negro_plana['tipo_linea'] = $isHq ? 'lp_colorhq' : 'lp_color';
|
||||
$linea_color_plana['tipo_linea'] = $isHq ? 'lp_colorhq' : 'lp_color';
|
||||
}
|
||||
}
|
||||
return [$linea_negro_plana, $linea_color_plana];
|
||||
|
||||
@ -807,8 +807,8 @@ class PresupuestoService extends BaseService
|
||||
{
|
||||
try {
|
||||
|
||||
if ($precioClick > 0 && $velocidadMaquina > 0)
|
||||
$minutos = (1.0 * $totalClicks / $precioClick) / $velocidadMaquina;
|
||||
if (floatval($precioClick) > 0 && floatval($velocidadMaquina) > 0)
|
||||
$minutos = (1.0 * floatval($totalClicks) / floatval($precioClick)) / floatval($velocidadMaquina);
|
||||
else
|
||||
$minutos = 0;
|
||||
|
||||
@ -822,8 +822,8 @@ class PresupuestoService extends BaseService
|
||||
{
|
||||
try {
|
||||
|
||||
if ($precioClick > 0 && $velocidadMaquina > 0)
|
||||
$horas = (1.0 * $totalClicks / $precioClick) / $velocidadMaquina / 60.0;
|
||||
if (floatval($precioClick) > 0 && floatval($velocidadMaquina) > 0)
|
||||
$horas = (1.0 * floatval($totalClicks) / floatval($precioClick)) / floatval($velocidadMaquina) / 60.0;
|
||||
else
|
||||
$horas = 0;
|
||||
|
||||
@ -1767,6 +1767,20 @@ class PresupuestoService extends BaseService
|
||||
if(empty($linea))
|
||||
continue;
|
||||
|
||||
if(!array_key_exists('tipo_linea', $linea['fields'])){
|
||||
if($isColor){
|
||||
if($isHq)
|
||||
$linea['fields']['tipo_linea'] = 'lp_colorhq';
|
||||
else
|
||||
$linea['fields']['tipo_linea'] = 'lp_color';
|
||||
}
|
||||
else{
|
||||
if($isHq)
|
||||
$linea['fields']['tipo_linea'] = 'lp_bnhq';
|
||||
else
|
||||
$linea['fields']['tipo_linea'] = 'lp_bn';
|
||||
}
|
||||
}
|
||||
array_push($lineas, $linea);
|
||||
}
|
||||
}
|
||||
|
||||
@ -32,13 +32,14 @@
|
||||
</div>
|
||||
|
||||
<div id="divDirecciones" class="col-12 pb-2">
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?= $this->section("additionalInlineJs") ?>
|
||||
|
||||
window.direcciones = <?= json_encode($presupuestoEntity->direcciones_envio) ?>;
|
||||
window.direcciones_sel_tirada = <?= json_encode($presupuestoEntity->selected_tirada) ?>;
|
||||
window.routes_direcciones = {
|
||||
direcciones: "<?= route_to('getDirecciones') ?>",
|
||||
getDatos: "<?= route_to('getDatosDireccion') ?>",
|
||||
|
||||
@ -210,7 +210,7 @@
|
||||
<label for="paginasColor" class="form-label">
|
||||
Páginas a color
|
||||
</label>
|
||||
<input type="number" class="calcular-presupuesto" id="paginasColor" name="paginasColor" maxLength="8" step="1" class="form-control" value="">
|
||||
<input type="number" class="calcular-presupuesto" id="paginasColor" name="paginasColor" maxLength="8" step="1" class="form-control" value="<?= old(0, $presupuestoEntity->paginasColor) ?>">
|
||||
</div><!--//.mb-3 -->
|
||||
</div>
|
||||
|
||||
@ -311,10 +311,10 @@
|
||||
<div class="col-sm-4 mb-md-0 mb-2">
|
||||
<label for="carasCubierta" class="form-label">Caras impresas cubierta</label>
|
||||
<select id="carasCubierta" name="carasCubierta" class="form-control select2bs2 calcular-presupuesto" style="width: 100%;">
|
||||
<option value="2">
|
||||
<option value="2" <?php echo $presupuestoEntity->paginas_cubierta==2?'selected':''?> >
|
||||
<p><?= lang('Presupuestos.unaCara') ?></p>
|
||||
</option>
|
||||
<option value="4">
|
||||
<option value="4" <?php echo $presupuestoEntity->paginas_cubierta==4?'selected':''?>>
|
||||
<p><?= lang('Presupuestos.dosCaras') ?></p>
|
||||
</option>
|
||||
</select>
|
||||
@ -329,14 +329,14 @@
|
||||
|
||||
<div class="col-sm-3 mb-md-0 mb-2 d-flex align-items-end">
|
||||
<div class="form-check form-switch mb-2">
|
||||
<input class="form-check-input calcular-presupuesto" type="checkbox" id="solapasCubierta" name="solapasCubierta" value="0">
|
||||
<input class="form-check-input" type="checkbox" id="solapasCubierta" name="solapasCubierta" value="0" <?= $presupuestoEntity->solapas == true ? 'checked' : ''; ?>>
|
||||
<label class="form-check-label" for="solapasCubierta">Solapas cubierta</label>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="tamanioSolapasCubierta" class="col-sm-3 mb-md-0 mb-2" style="display: none;">
|
||||
<div id="tamanioSolapasCubierta" class="col-sm-3 mb-md-0 mb-2" <?= $presupuestoEntity->solapas == true ? '' : 'style="display: none;"'; ?>>
|
||||
<label for="anchoSolapasCubierta" class="form-label">Tamaño</label>
|
||||
<input type="number" id="anchoSolapasCubierta" name="anchoSolapasCubierta" maxLength="8" step="1" class="form-control calcular-presupuesto" value="">
|
||||
<input type="number" id="anchoSolapasCubierta" name="anchoSolapasCubierta" maxLength="8" step="1" class="form-control calcular-presupuesto" value="<?= old(0, $presupuestoEntity->solapas_ancho) ?>">
|
||||
</div>
|
||||
|
||||
</div>
|
||||
@ -373,13 +373,23 @@
|
||||
<div class="row sobrecubierta">
|
||||
<div class="col-sm-3 mb-md-0 mb-2 d-flex align-items-end">
|
||||
<div class="form-check form-switch mb-2">
|
||||
<input class="form-check-input" type="checkbox" id="enableSobrecubierta" name="enableSobrecubierta" value="0">
|
||||
<input class="form-check-input" type="checkbox" id="enableSobrecubierta" name="enableSobrecubierta" value="0"
|
||||
<?php if (isset($presupuestoEntity->papel_sobrecubierta) && $presupuestoEntity->papel_sobrecubierta>0) :
|
||||
echo 'checked';
|
||||
endif; ?>
|
||||
>
|
||||
<label class="form-check-label" for="enableSobrecubierta">Añadir sobrecubierta</label>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<h6 class="sobrecubierta enable-sobrecubierta" style="display: none;"> Papel </h6>
|
||||
<h6 class="sobrecubierta enable-sobrecubierta"
|
||||
<?php if (isset($presupuestoEntity->papel_sobrecubierta) && $presupuestoEntity->papel_sobrecubierta>0) :
|
||||
echo '';
|
||||
else:
|
||||
echo 'style="display: none;"';
|
||||
endif; ?>
|
||||
> Papel </h6>
|
||||
<div class="row sobrecubierta enable-sobrecubierta">
|
||||
|
||||
<div class="col-sm-4 mb-md-0 mb-2">
|
||||
@ -403,18 +413,36 @@
|
||||
|
||||
</div>
|
||||
|
||||
<h6 class="sobrecubierta enable-sobrecubierta" style="display: none;"> Opciones extra </h6>
|
||||
<h6 class="sobrecubierta enable-sobrecubierta"
|
||||
<?php if (isset($presupuestoEntity->papel_sobrecubierta) && $presupuestoEntity->papel_sobrecubierta>0) :
|
||||
echo '';
|
||||
else:
|
||||
echo 'style="display: none;"';
|
||||
endif; ?>
|
||||
> Opciones extra </h6>
|
||||
|
||||
<div class="row sobrecubierta enable-sobrecubierta" style="display: none;">
|
||||
<div class="row sobrecubierta enable-sobrecubierta"
|
||||
<?php if (isset($presupuestoEntity->papel_sobrecubierta) && $presupuestoEntity->papel_sobrecubierta>0) :
|
||||
echo '';
|
||||
else:
|
||||
echo 'style="display: none;"';
|
||||
endif; ?>
|
||||
>
|
||||
|
||||
<div id="tamanioSolapasSobrecubierta" class="col-sm-3 mb-md-0 mb-2"">
|
||||
<label for="anchoSolapasSobrecubierta" class="form-label">Tamaño</label>
|
||||
<input type="number" id="anchoSolapasSobrecubierta" name="anchoSolapasSobrecubierta" maxLength="8" step="1" class="form-control input-sobrecubierta calcular-presupuesto" value="">
|
||||
<label for="anchoSolapasSobrecubierta" class="form-label">Tamaño solapas</label>
|
||||
<input type="number" id="anchoSolapasSobrecubierta" name="anchoSolapasSobrecubierta" maxLength="8" step="1" class="form-control input-sobrecubierta calcular-presupuesto" value="<?= old(0, $presupuestoEntity->solapas_ancho_sobrecubierta) ?>">
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="row sobrecubierta enable-sobrecubierta" style="display: none;">
|
||||
<div class="row sobrecubierta enable-sobrecubierta"
|
||||
<?php if (isset($presupuestoEntity->papel_sobrecubierta) && $presupuestoEntity->papel_sobrecubierta>0) :
|
||||
echo '';
|
||||
else:
|
||||
echo 'style="display: none;"';
|
||||
endif; ?>
|
||||
>
|
||||
|
||||
<div class="col-sm-4 mb-md-0 mb-2">
|
||||
<label for="acabadosSobrecubierta" class="form-label">Acabados sobrecubierta</label>
|
||||
@ -443,17 +471,23 @@
|
||||
<div>No existe combinación con las opciones seleccionadas. Pruebe con otro papel/gramaje</div>
|
||||
</div>
|
||||
|
||||
<div class="row guardas">
|
||||
<div id="divGuardas" class="row guardas">
|
||||
<div class="col-sm-4 mb-md-0 mb-2">
|
||||
<label for="impresionGuardas" class="form-label">Impresión de guardas</label>
|
||||
<select id="impresionGuardas" name="impresionGuardas" class="form-control select2bs2 comp_guardas_items calcular-presupuesto" style="width: 100%;">
|
||||
<option value="0">
|
||||
<option value="0"
|
||||
<?php echo ((!isset($presupuestoEntity->paginas_guardas) || $presupuestoEntity->paginas_guardas==0) ? 'selected' : ''); ?>
|
||||
>
|
||||
<p><?= lang('Presupuestos.sinImpresion') ?></p>
|
||||
</option>
|
||||
<option value="4">
|
||||
<option value="4"
|
||||
<?php echo ($presupuestoEntity->paginas_guardas==4 ? 'selected' : ''); ?>
|
||||
>
|
||||
<p><?= lang('Presupuestos.unaCara') ?></p>
|
||||
</option>
|
||||
<option value="8">
|
||||
<option value="8"
|
||||
<?php echo ($presupuestoEntity->paginas_guardas==8 ? 'selected' : ''); ?>
|
||||
>
|
||||
<p><?= lang('Presupuestos.dosCaras') ?></p>
|
||||
</option>
|
||||
</select>
|
||||
@ -466,7 +500,7 @@
|
||||
<select id="papelGuardas" name="papelGuardas" class="form-control select2bs2 calcular-presupuesto" style="width: 100%;">
|
||||
<?php if (isset($datosPresupuesto->papelGuardas) && is_array($datosPresupuesto->papelGuardas) && !empty($datosPresupuesto->papelGuardas)) :
|
||||
foreach ($datosPresupuesto->papelGuardas as $k => $v) : ?>
|
||||
<option value="<?= $v->id ?>">
|
||||
<option value="<?= $v->id ?>" <? echo ($v->id==$presupuestoEntity->papel_guardas?'selected':'');?> >
|
||||
<?= $v->nombre ?>
|
||||
</option>
|
||||
<?php endforeach;
|
||||
@ -557,10 +591,10 @@
|
||||
<div class="col-sm-2 mb-md-0 mb-2">
|
||||
<label for="ivaReducido" class="form-label">I.V.A. reducido</label>
|
||||
<select id="ivaReducido" name="ivaReducido" class="form-control select2bs2 calcular-presupuesto" style="width: 100%;">
|
||||
<option value="1">
|
||||
<option value="1" <?= $presupuestoEntity->iva_reducido == 1? 'selected':''?> >
|
||||
<p><?= lang('SI') ?></p>
|
||||
</option>
|
||||
<option value="0">
|
||||
<option value="0" <?= $presupuestoEntity->iva_reducido == 0? 'selected':''?> >
|
||||
<p><?= lang('NO') ?></p>
|
||||
</option>
|
||||
</select>
|
||||
@ -576,6 +610,14 @@
|
||||
<?= $this->section("additionalInlineJs") ?>
|
||||
|
||||
|
||||
window.datosDisenioLibro = {
|
||||
papel_interior: <?php echo $presupuestoEntity->papel_interior ? $presupuestoEntity->papel_interior : 'null'; ?>,
|
||||
gramaje_interior: <?php echo $presupuestoEntity->gramaje_interior ? $presupuestoEntity->gramaje_interior : 'null'; ?>,
|
||||
papel_cubierta: <?php echo $presupuestoEntity->papel_cubierta ? $presupuestoEntity->papel_cubierta : 'null'; ?>,
|
||||
gramaje_cubierta: <?php echo $presupuestoEntity->gramaje_cubierta ? $presupuestoEntity->gramaje_cubierta : 'null'; ?>,
|
||||
papel_sobrecubierta: <?php echo $presupuestoEntity->papel_sobrecubierta ? $presupuestoEntity->papel_sobrecubierta : 'null'; ?>,
|
||||
gramaje_sobrecubierta: <?php echo $presupuestoEntity->gramaje_sobrecubierta ? $presupuestoEntity->gramaje_sobrecubierta : 'null'; ?>,
|
||||
}
|
||||
window.routes_disenio_libro = {
|
||||
obtenerGramaje: "<?= route_to('obtenerGramaje') ?>",
|
||||
presupuestoCliente: "<?= route_to('presupuestoCliente') ?>",
|
||||
|
||||
@ -1,46 +1,110 @@
|
||||
<div class="col-12 pb-2">
|
||||
<div class="row mb-3">
|
||||
<?php if($presupuestoEntity->estado_id==2): ?>
|
||||
<h2>PRESUPUESTO ACEPTADO</h2>
|
||||
<input type="hidden" id="lomo_cubierta" value=<?php echo $presupuestoEntity->lomo_cubierta ?>>
|
||||
<br>
|
||||
<?php endif; ?>
|
||||
<h3>Resumen</h3>
|
||||
<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>
|
||||
<p class="mb-0"><small id="tipoLibro"><?php echo (isset($presupuestoEntity->resumen->titulo)?$presupuestoEntity->resumen->titulo:'') ?></small></p>
|
||||
<p class="mb-0"><small id="resumenTamanio">Tamaño: <?php echo (isset($presupuestoEntity->resumen->tamanio)?$presupuestoEntity->resumen->tamanio:'') ?></small></p>
|
||||
<p class="mb-0"><small id="resumenPaginas">Número de páginas: <?php echo $presupuestoEntity->paginas ?></small></p>
|
||||
<p class="mb-0"><small id="resumenTirada">Tirada: <?php echo $presupuestoEntity->tirada ?></small></p>
|
||||
<p class="mb-0"><small id="resumenPrototipo">Prototipo: <?php echo ($presupuestoEntity->prototipo?'SI':'NO') ?></small></p>
|
||||
<p class="mb-3"><small id="resumenFerro">Ferro: <?php echo ($presupuestoEntity->ferro?'SI':'NO') ?></small></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>
|
||||
<p class="mb-0"><small id="tipoImpresion">Impresion:
|
||||
<?php echo (isset($presupuestoEntity->resumen->tipo_impresion)?$presupuestoEntity->resumen->tipo_impresion:'') ?>
|
||||
</small></p>
|
||||
<p id="pResumenPaginasColor" class="mb-0" <?php echo ($presupuestoEntity->paginasColor==0?'style="display:none"':'')?>>
|
||||
<small id="resumenPaginasColor">Páginas a color: <?php echo $presupuestoEntity->paginasColor?></small></p>
|
||||
<p class="mb-3"><small id="resumenPapelInterior">Papel:
|
||||
<?php echo (isset($presupuestoEntity->papel_interior_nombre)?$presupuestoEntity->papel_interior_nombre:'') ?>
|
||||
<?php echo (isset($presupuestoEntity->gramaje_interior)?$presupuestoEntity->gramaje_interior:'') ?>gr/m²</small></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>
|
||||
<p class="mb-0"><small id="resumenPapelCubierta">Papel:
|
||||
<?php echo (isset($presupuestoEntity->papel_cubierta_nombre)?$presupuestoEntity->papel_cubierta_nombre:''); ?>
|
||||
<?php echo (isset($presupuestoEntity->gramaje_cubierta)?$presupuestoEntity->gramaje_cubierta:''); ?>gr/m²</small></p>
|
||||
<p class="mb-0"><small id="resumenCarasCubierta">Impresión: <?php echo ($presupuestoEntity->paginas_cubierta==2?"1 cara":"2 caras");?></small></p>
|
||||
<?php if($presupuestoEntity->solapas_ancho>0 || $presupuestoEntity->estado_id==1): ?>
|
||||
<p class="mb-0"><small id="resumenSolapasCubierta">Solapas: <?php echo $presupuestoEntity->solapas_ancho;?>mm</small></p>
|
||||
<?php endif; ?>
|
||||
<?php if($presupuestoEntity->acabado_cubierta_id>0 || $presupuestoEntity->estado_id==1): ?>
|
||||
<p class="mb-3"><small id="resumenAcabadoCubierta">Acabado:
|
||||
<?php if (isset($datosPresupuesto->acabadosCubierta) && is_array($datosPresupuesto->acabadosCubierta) && !empty($datosPresupuesto->acabadosCubierta)) :
|
||||
foreach ($datosPresupuesto->acabadosCubierta as $acabado) :
|
||||
if ($acabado->id == $presupuestoEntity->acabado_cubierta_id):
|
||||
echo $acabado->label;
|
||||
endif;
|
||||
endforeach;
|
||||
endif; ?>
|
||||
</small></p>
|
||||
<?php endif; ?>
|
||||
|
||||
<h5 class="mb-1 resumen-sobrecubierta">Sobrecubierta</h5>
|
||||
<p class="mb-0 resumen-sobrecubierta"><small id="resumenPapelSobrecubierta">Papel: Blanco Offset
|
||||
70gr/m²</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>
|
||||
<?php if($presupuestoEntity->papel_sobrecubierta || $presupuestoEntity->estado_id==1): ?>
|
||||
<h5 class="mb-1 resumen-sobrecubierta">Sobrecubierta</h5>
|
||||
<p class="mb-0 resumen-sobrecubierta"><small id="resumenPapelSobrecubierta">Papel:
|
||||
<?php echo (isset($presupuestoEntity->papel_sobrecubierta_nombre)?$presupuestoEntity->papel_sobrecubierta_nombre:'') ?>
|
||||
<?php echo (isset($presupuestoEntity->gramaje_sobrecubierta)?$presupuestoEntity->gramaje_sobrecubierta:'') ?>gr/m²</small></p>
|
||||
<?php if($presupuestoEntity->solapas_ancho_sobrecubierta>0 || $presupuestoEntity->estado_id==1): ?>
|
||||
<p class="mb-0 resumen-sobrecubierta"><small id="resumenSolapasCubierta">Ancho solapas: <?php echo $presupuestoEntity->solapas_ancho_sobrecubierta;?>mm</small></p>
|
||||
<?php endif; ?>
|
||||
<p class="mb-3 resumen-sobrecubierta"><small id="resumenAcabadoSobrecubierta">Acabado:
|
||||
<?php if (isset($datosPresupuesto->acabadosSobrecubierta) && is_array($datosPresupuesto->acabadosSobrecubierta) && !empty($datosPresupuesto->acabadosSobrecubierta)) :
|
||||
foreach ($datosPresupuesto->acabadosSobrecubierta as $acabado) :
|
||||
if ($acabado->id == $presupuestoEntity->acabado_sobrecubierta_id):
|
||||
echo $acabado->label;
|
||||
endif;
|
||||
endforeach;
|
||||
endif; ?>
|
||||
</small></p>
|
||||
<?php endif; ?>
|
||||
|
||||
<h5 class="mb-1 resumen-guardas">Guardas</h5>
|
||||
<p class="mb-0 resumen-guardas"><small id="resumenGuardasPapel">Papel: Blanco Offset 70gr/m²</small></p>
|
||||
<p class="mb-3 resumen-guardas"><small id="resumenGuardasCaras">Impresión: 1 cara</small></p>
|
||||
<?php if($presupuestoEntity->papel_guardas || $presupuestoEntity->estado_id==1): ?>
|
||||
<h5 class="mb-1 resumen-guardas">Guardas</h5>
|
||||
<p class="mb-0 resumen-guardas"><small id="resumenGuardasPapel">Papel:
|
||||
<?php echo (isset($presupuestoEntity->papel_guardas_nombre)?$presupuestoEntity->papel_guardas_nombre:''); ?>
|
||||
170gr/m²</small></p>
|
||||
<p class="mb-3 resumen-guardas"><small id="resumenGuardasCaras">Impresión:
|
||||
<?php if(!isset($presupuestoEntity->paginas_guardas) || $presupuestoEntity->paginas_guardas==0):
|
||||
echo "Sin impresion";
|
||||
elseif($presupuestoEntity->paginas_guardas==4):
|
||||
echo "1 cara";
|
||||
else:
|
||||
echo "2 caras";
|
||||
endif; ?></small></p>
|
||||
<?php endif; ?>
|
||||
|
||||
<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>
|
||||
<?php if($presupuestoEntity->retractiladol || $presupuestoEntity->retractilado5 || $presupuestoEntity->faja_color || $presupuestoEntity->estado_id==1): ?>
|
||||
<h5 class="mb-1 resumen-extras">Extras</h5>
|
||||
<?php endif; ?>
|
||||
<?php if($presupuestoEntity->retractiladol): ?>
|
||||
<p class="mb-0 resumen-extras" id="resumenRetractilado1"><small>Retractilado individual</small></p>
|
||||
<?php elseif ($presupuestoEntity->retractilado5): ?>
|
||||
<p class="mb-0 resumen-extras" id="resumenRetractilado5"><small>Retractilado de 5</small></p>
|
||||
<?php elseif ($presupuestoEntity->faja_color): ?>
|
||||
<p class="mb-0 resumen-extras" id="resumenFajaColor"><small>Imprimir faja a color</small></p>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
|
||||
<div class="col-sm-6">
|
||||
<h4 id="resumenTotalIVA" class="mb-1">Total: 100€</h4>
|
||||
<h6 id="resumenPrecioU" class="mb-0">10.4€/ud</h6>
|
||||
|
||||
<?php if($presupuestoEntity->estado_id==2):
|
||||
$total = $presupuestoEntity->total_aceptado;
|
||||
$iva = $presupuestoEntity->iva_reducido?1.04:1.21;
|
||||
$total *= $iva;
|
||||
$total_unidad = $total / $presupuestoEntity->tirada;
|
||||
echo '<h4 id="resumenTotalIVA" class="mb-1">Total: ' . round($total, 2) . '€</h4>';
|
||||
echo '<h6 id="resumenPrecioU" class="mb-0">' . round($total_unidad, 4) . '€/ud</h6>'
|
||||
?>
|
||||
<?php else: ?>
|
||||
<h4 id="resumenTotalIVA" class="mb-1">Total: 100€</h4>
|
||||
<h6 id="resumenPrecioU" class="mb-0">10.4€/ud</h6>
|
||||
<?php endif; ?>
|
||||
<div id="shape-container">
|
||||
<div id="thumbnail_ec_shape" style="width:350px;height:300px;margin:2.5% auto;"></div>
|
||||
<div class="d-flex justify-content-center">
|
||||
@ -52,6 +116,39 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<?php if($presupuestoEntity->estado_id==2):
|
||||
echo '<div class="row mb-3">';
|
||||
echo '<h3>Direcciones de envío</h3>';
|
||||
echo '<div class="col-sm-6">';
|
||||
if(isset($presupuestoEntity->direcciones_envio)):
|
||||
foreach ($presupuestoEntity->direcciones_envio as $direccion):
|
||||
echo '<div class="row mb-3">';
|
||||
echo '<div class="col-sm-5 form-check custom-option custom-option-basic checked">';
|
||||
echo '<label class="form-check-label custom-option-content">';
|
||||
echo '<span class="custom-option-header mb-2">';
|
||||
echo '<h6 class="fw-semibold mb-0">' . $direccion['att'] . '</h6>';
|
||||
echo '<span class="badge bg-label-primary">' . $direccion['cantidad'] . ' unidades</span>';
|
||||
echo '</span>';
|
||||
echo '<span class="custom-option-body">';
|
||||
echo '<small>' . $direccion['direccion'] . '</small><br>';
|
||||
echo '<small>' . $direccion['cp'] . '</small><br>';
|
||||
echo '<small>' . $direccion['municipio'] .', ' . $direccion['pais'] . '</small><br>';
|
||||
echo '<small>' . $direccion['telefono'] . '</small><br>';
|
||||
echo '<small>' . $direccion['email'] . '</small><br>';
|
||||
if($direccion['entregaPieCalle'] == 1){
|
||||
echo '<small><i>Envío en palets</i></small><br>';
|
||||
}
|
||||
echo '<hr class="my-2">';
|
||||
echo '</span>';
|
||||
echo '</label>';
|
||||
echo '</div>';
|
||||
echo '</div>';
|
||||
endforeach;
|
||||
endif;
|
||||
|
||||
echo '</div>';
|
||||
echo '</div>';
|
||||
endif; ?>
|
||||
</div>
|
||||
|
||||
<!-- Modal -->
|
||||
@ -75,8 +172,17 @@
|
||||
|
||||
|
||||
<?= $this->section("additionalInlineJs") ?>
|
||||
|
||||
window.estado = <?= $presupuestoEntity->estado_id ?>;
|
||||
window.tirada = <?= $presupuestoEntity->selected_tirada ?>;
|
||||
window.total = <?= $presupuestoEntity->total_aceptado ?>;
|
||||
window.total_unidad = <?= $presupuestoEntity->total_precio_unidad ?>;
|
||||
window.iva_reducido= <?= $presupuestoEntity->iva_reducido ?>;
|
||||
window.routes_resumen = {
|
||||
guardarPresupuesto: "<?= route_to('guardarPresupuesto') ?>",
|
||||
guardarPresupuesto: "<?= route_to('guardarPresupuesto') ?>",
|
||||
duplicarPresupuesto: "<?= route_to('duplicarPresupuesto') ?>",
|
||||
}
|
||||
<?= $this->endSection() ?>
|
||||
|
||||
if(<?php echo $presupuestoEntity->estado_id?>==2)
|
||||
previewEsquemaCubierta(true);
|
||||
|
||||
<?= $this->endSection() ?>
|
||||
|
||||
@ -2,7 +2,8 @@ function initDirecciones() {
|
||||
data = {
|
||||
id: $('#clienteId').val()
|
||||
},
|
||||
data = Object.assign(data, window.token_ajax)
|
||||
data = Object.assign(data, window.token_ajax);
|
||||
$('#errorDirecciones').hide();
|
||||
|
||||
$.ajax({
|
||||
url: window.routes_direcciones.direcciones,
|
||||
@ -23,6 +24,7 @@ function initDirecciones() {
|
||||
|
||||
function initTiradasDirecciones() {
|
||||
const _this = this
|
||||
let sel_index = 1;
|
||||
|
||||
$('#containerTiradasEnvios').empty();
|
||||
|
||||
@ -53,10 +55,16 @@ function initTiradasDirecciones() {
|
||||
|
||||
$('#containerTiradasEnvios').append(html);
|
||||
|
||||
if(parseInt($('#' + tirada_id).text().split(' ')[0]) == window.direcciones_sel_tirada){
|
||||
sel_index = i;
|
||||
}
|
||||
|
||||
$('#' + id).hide();
|
||||
}
|
||||
$('#env_tiradaPrecio1').trigger('click');
|
||||
}
|
||||
$(('#env_tiradaPrecio' + sel_index)).trigger('click');
|
||||
|
||||
cargarDirecciones();
|
||||
|
||||
const tiradasDireccionesList = [].slice.call(document.querySelectorAll('.custom-option-tiradasDirecciones .form-check-input'))
|
||||
tiradasDireccionesList.map(function (customOptionEL) {
|
||||
@ -70,6 +78,48 @@ function initTiradasDirecciones() {
|
||||
})
|
||||
}
|
||||
|
||||
function cargarDirecciones(){
|
||||
$('#loader').show();
|
||||
$('#divDirecciones').empty();
|
||||
|
||||
if(window.direcciones == null){
|
||||
$('#loader').hide();
|
||||
return;
|
||||
}
|
||||
for(let i=0; i<window.direcciones.length; i++){
|
||||
const tipo = window.direcciones[i].entregaPieCalle == 1?'palets':'cajas';
|
||||
let html = '';
|
||||
html += '<div id="envioId' + window.direcciones[i].direccion_id + '" t="' + tipo + '" p= ' +window.direcciones[i].precio + ' 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">';
|
||||
html += '<h6 class="fw-semibold mb-0">' + window.direcciones[i].att + '</h6>';
|
||||
html += '<span class="badge bg-label-primary">' + window.direcciones[i].cantidad + ' unidades</span>';
|
||||
html += '</span>';
|
||||
html += '<span class="custom-option-body">';
|
||||
html += '<small>' + window.direcciones[i].direccion + '</small><br>';
|
||||
html += '<small>' + window.direcciones[i].cp + '</small><br>';
|
||||
html += '<small>' + window.direcciones[i].municipio +', ' + window.direcciones[i].pais + '</small><br>';
|
||||
html += '<small>' + window.direcciones[i].telefono + '</small><br>';
|
||||
html += '<small>' + window.direcciones[i].email + '</small><br>';
|
||||
if(tipo == 'palets'){
|
||||
html += '<small><i>Envío en palets</i></small><br>';
|
||||
}
|
||||
html += '<hr class="my-2">';
|
||||
html += '<span class="d-flex">';
|
||||
html += '<a class="eliminar-direccion" href="javascript:void(0)">Eliminar</a>';
|
||||
html += '</span>';
|
||||
html += '</span>';
|
||||
html += '</label>';
|
||||
html += '</div>';
|
||||
html += '</div>';
|
||||
|
||||
$('#divDirecciones').append(html);
|
||||
$('#errorDirecciones').hide();
|
||||
$('#loader').hide();
|
||||
}
|
||||
}
|
||||
|
||||
function updateTiradasDireccionesCheck(el) {
|
||||
if (el.checked) {
|
||||
// If custom option element is radio, remove checked from the siblings (closest `.row`)
|
||||
@ -168,6 +218,9 @@ $('#insertarDireccion').on('click', function() {
|
||||
html += '<small>' + response.data[0].municipio +', ' + response.data[0].pais + '</small><br>';
|
||||
html += '<small>' + response.data[0].telefono + '</small><br>';
|
||||
html += '<small>' + response.data[0].email + '</small><br>';
|
||||
if(response.data[0].tipo == 'palets'){
|
||||
html += '<small><i>Envío en palets</i></small><br>';
|
||||
}
|
||||
html += '<hr class="my-2">';
|
||||
html += '<span class="d-flex">';
|
||||
html += '<a class="eliminar-direccion" href="javascript:void(0)">Eliminar</a>';
|
||||
|
||||
@ -153,8 +153,27 @@ function initDisenioLibro() {
|
||||
$('.change-tipo-impresion').trigger('change');
|
||||
|
||||
$('#papelInterior').trigger('change');
|
||||
$('#papelInterior').val(window.datosDisenioLibro.papel_interior);
|
||||
$('#gramajeInterior').append($('<option>', {
|
||||
value: window.datosDisenioLibro.gramaje_interior,
|
||||
text: window.datosDisenioLibro.gramaje_interior
|
||||
}));
|
||||
$('#gramajeInterior').val(window.datosDisenioLibro.gramaje_interior);
|
||||
$('#papelCubierta').val('').trigger('change');
|
||||
$('#papelCubierta').val(window.datosDisenioLibro.papel_cubierta);
|
||||
$('#gramajeCubierta').append($('<option>', {
|
||||
value: window.datosDisenioLibro.gramaje_cubierta,
|
||||
text: window.datosDisenioLibro.gramaje_cubierta
|
||||
}));
|
||||
$('#gramajeCubierta').val(window.datosDisenioLibro.gramaje_cubierta);
|
||||
|
||||
$('#papelSobrecubierta').val('').trigger('change');
|
||||
$('#papelSobrecubierta').val(window.datosDisenioLibro.papel_sobrecubierta);
|
||||
$('#gramajeSobrecubierta').append($('<option>', {
|
||||
value: window.datosDisenioLibro.gramaje_sobrecubierta,
|
||||
text: window.datosDisenioLibro.gramaje_sobrecubierta
|
||||
}));
|
||||
$('#gramajeSobrecubierta').val(window.datosDisenioLibro.gramaje_sobrecubierta);
|
||||
|
||||
$('#enableSobrecubierta').trigger('change');
|
||||
}
|
||||
@ -253,12 +272,16 @@ $('#papelInterior').on('change', function () {
|
||||
data: datos,
|
||||
success: function (response) {
|
||||
|
||||
$('#gramajeInterior').empty();
|
||||
$(response.menu).each(function (index, element) {
|
||||
$('#gramajeInterior').append($("<option />").val(element.id).text(element.text));
|
||||
});
|
||||
if(response.menu){
|
||||
|
||||
if (valInterior != undefined)
|
||||
$('#gramajeInterior').empty();
|
||||
$(response.menu).each(function (index, element) {
|
||||
$('#gramajeInterior').append($("<option />").val(element.id).text(element.text));
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
if (valInterior != undefined && valInterior != '')
|
||||
$('#gramajeInterior option[value=' + valInterior + ']').prop('selected', true).trigger('change');
|
||||
else
|
||||
$('#gramajeInterior').val('').trigger('change');
|
||||
@ -297,7 +320,7 @@ $('#papelCubierta').on('change', function () {
|
||||
$('#gramajeCubierta').append($("<option />").val(element.id).text(element.text));
|
||||
});
|
||||
|
||||
if (valCubierta != undefined)
|
||||
if (valCubierta != undefined && valCubierta != '')
|
||||
$('#gramajeCubierta option[value=' + valCubierta + ']').prop('selected', true).trigger('change');
|
||||
else
|
||||
$('#gramajeCubierta').val('').trigger('change');
|
||||
@ -634,7 +657,7 @@ async function calcularPresupuesto() {
|
||||
}
|
||||
|
||||
// Si hay sobrecubierta
|
||||
if ($('.enable-sobrecubierta').is(':visible')) {
|
||||
if ($('#enableSobrecubierta').is(':checked')) {
|
||||
if($('#papelSobrecubierta option:selected').val()>0 && $('#gramajeSobrecubierta option:selected').val()>0){
|
||||
|
||||
datos.sobrecubierta = {
|
||||
@ -648,7 +671,7 @@ async function calcularPresupuesto() {
|
||||
}
|
||||
}
|
||||
|
||||
if ($('.guardas').is(':visible')) {
|
||||
if ($('#divGuardas').is(':visible')) {
|
||||
datos.guardas = {
|
||||
papel: $('#papelGuardas option:selected').val(),
|
||||
papel_nombre: $('#papelGuardas option:selected').text().trim(),
|
||||
@ -668,6 +691,7 @@ async function calcularPresupuesto() {
|
||||
data: datos,
|
||||
success: function (response) {
|
||||
error = false;
|
||||
$('#errorGeneral').hide();
|
||||
try{
|
||||
|
||||
|
||||
@ -714,30 +738,35 @@ async function calcularPresupuesto() {
|
||||
|
||||
$('#divTiradasPrecio').empty();
|
||||
|
||||
$('#lomo_cubierta').val(response.lomo_cubierta);
|
||||
if(!error){
|
||||
|
||||
$('#precios').show();
|
||||
$('#lomo_cubierta').val(response.lomo_cubierta);
|
||||
|
||||
for (i = 0; i < response.tiradas.length; i++) {
|
||||
const total = (parseFloat(response.precio_u[i]) * parseInt(response.tiradas[i])).toFixed(2) ;
|
||||
const label = "tiradaPrecio" + parseInt(i+1);
|
||||
$('#precios').show();
|
||||
|
||||
let html = '';
|
||||
if(response.tiradas){
|
||||
for (i = 0; i < response.tiradas.length; i++) {
|
||||
const total = (parseFloat(response.precio_u[i]) * parseInt(response.tiradas[i])).toFixed(2) ;
|
||||
const label = "tiradaPrecio" + parseInt(i+1);
|
||||
|
||||
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">';
|
||||
html += '<h7 id="ud_' + label + '" class="mb-1">' + (response.tiradas[i] + ' ud.') + '</h7>';
|
||||
html += '<h6 id="tot_' + label + '" class="mb-1">' + ('Total: ' + total + '€') + '</h6>';
|
||||
html += '<h7 id="pu_' + label + '" class="mb-1">' + (response.precio_u[i] + '€/ud') + '</h7>';
|
||||
html += '</div>';
|
||||
html += '</div>'
|
||||
html += '</a>';
|
||||
html += '</div>';
|
||||
let html = '';
|
||||
|
||||
$('#divTiradasPrecio').append(html);
|
||||
}
|
||||
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">';
|
||||
html += '<h7 id="ud_' + label + '" class="mb-1">' + (response.tiradas[i] + ' ud.') + '</h7>';
|
||||
html += '<h6 id="tot_' + label + '" class="mb-1">' + ('Total: ' + total + '€') + '</h6>';
|
||||
html += '<h7 id="pu_' + label + '" class="mb-1">' + (response.precio_u[i] + '€/ud') + '</h7>';
|
||||
html += '</div>';
|
||||
html += '</div>'
|
||||
html += '</a>';
|
||||
html += '</div>';
|
||||
|
||||
$('#divTiradasPrecio').append(html);
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
error: function (error) {
|
||||
$('#loader').hide();
|
||||
|
||||
@ -38,303 +38,306 @@
|
||||
});
|
||||
|
||||
// Deal Details
|
||||
const FormValidation2 = FormValidation.formValidation(clientePresupuestoWizardFormStep2, {
|
||||
fields: {
|
||||
},
|
||||
plugins: {
|
||||
trigger: new FormValidation.plugins.Trigger(),
|
||||
bootstrap5: new FormValidation.plugins.Bootstrap5({
|
||||
// Use this for enabling/changing valid/invalid class
|
||||
// eleInvalidClass: '',
|
||||
eleValidClass: '',
|
||||
rowSelector: '.col-sm-3'
|
||||
}),
|
||||
autoFocus: new FormValidation.plugins.AutoFocus(),
|
||||
submitButton: new FormValidation.plugins.SubmitButton()
|
||||
}
|
||||
}).on('core.form.valid', function () {
|
||||
// Jump to the next step when all fields in the current step are valid
|
||||
validationStepper.next();
|
||||
});
|
||||
|
||||
// Deal Usage
|
||||
const FormValidation3 = FormValidation.formValidation(clientePresupuestoWizardFormStep3, {
|
||||
fields: {
|
||||
titulo: {
|
||||
validators: {
|
||||
notEmpty: {
|
||||
message: window.Presupuestos.validation.requerido_short
|
||||
},
|
||||
}
|
||||
if(clientePresupuestoWizardFormStep2 !== null){
|
||||
const FormValidation2 = FormValidation.formValidation(clientePresupuestoWizardFormStep2, {
|
||||
fields: {
|
||||
},
|
||||
clienteId: {
|
||||
validators: {
|
||||
callback: {
|
||||
message: window.Presupuestos.validation.cliente,
|
||||
callback: function (input) {
|
||||
// Get the selected options
|
||||
const options = $("#clienteId").select2('data');
|
||||
const hasValidOption = options.some(option => parseInt(option.id) > 0);
|
||||
return options !== null && options.length > 0 && hasValidOption;
|
||||
},
|
||||
}
|
||||
}
|
||||
},
|
||||
tirada: {
|
||||
validators: {
|
||||
callback: {
|
||||
message: window.Presupuestos.validation.integer_greatherThan_0,
|
||||
callback: function (input) {
|
||||
const value = $("#tirada").val();
|
||||
return value.length > 0 && Number.isInteger(parseInt(value)) && parseInt(value) > 0;
|
||||
},
|
||||
}
|
||||
}
|
||||
},
|
||||
paginas: {
|
||||
validators: {
|
||||
callback: {
|
||||
message: window.Presupuestos.validation.integer_greatherThan_0,
|
||||
callback: function (input) {
|
||||
const value = $("#paginas").val();
|
||||
return value.length > 0 && Number.isInteger(parseInt(value)) && parseInt(value) > 0;
|
||||
},
|
||||
}
|
||||
}
|
||||
},
|
||||
paginasColor: {
|
||||
validators: {
|
||||
callback: {
|
||||
message: window.Presupuestos.validation.integer_greatherThan_0,
|
||||
callback: function (input) {
|
||||
if ($('#pagColorDiv').is(':hidden'))
|
||||
return true;
|
||||
else {
|
||||
const value = $("#paginasColor").val();
|
||||
return value.length > 0 && Number.isInteger(parseInt(value)) && parseInt(value) > 0;
|
||||
}
|
||||
},
|
||||
}
|
||||
}
|
||||
},
|
||||
gramajeInterior: {
|
||||
validators: {
|
||||
callback: {
|
||||
callback: function (input) {
|
||||
const value = $("#tirada").val();
|
||||
if ($('#gramajeInterior option:selected').text().length == 0) {
|
||||
if(value.length > 0 && Number.isInteger(parseInt(value)) && parseInt(value) > 0){
|
||||
return {
|
||||
valid: false,
|
||||
message: window.Presupuestos.validation.sin_gramaje,
|
||||
}
|
||||
}
|
||||
return {
|
||||
valid: value.length > 0 && Number.isInteger(parseInt(value)) && parseInt(value) > 0,
|
||||
message: window.Presupuestos.validation.tirada_no_valida,
|
||||
}
|
||||
}
|
||||
return true;
|
||||
},
|
||||
},
|
||||
}
|
||||
},
|
||||
gramajeCubierta: {
|
||||
validators: {
|
||||
callback: {
|
||||
message: window.Presupuestos.validation.tirada_no_valida,
|
||||
callback: function (input) {
|
||||
const value = $("#tirada").val();
|
||||
if ($('#gramajeCubierta option:selected').text().length == 0) {
|
||||
return value.length > 0 && Number.isInteger(parseInt(value)) && parseInt(value) > 0;
|
||||
}
|
||||
return true;
|
||||
},
|
||||
},
|
||||
callback: {
|
||||
message: window.Presupuestos.validation.sin_gramaje,
|
||||
callback: function (input) {
|
||||
if ($('#gramajeCubierta option:selected').text().length == 0) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
},
|
||||
}
|
||||
}
|
||||
},
|
||||
gramajeSobrecubierta: {
|
||||
validators: {
|
||||
callback: {
|
||||
message: window.Presupuestos.validation.tirada_no_valida,
|
||||
callback: function (input) {
|
||||
const value = $("#tirada").val();
|
||||
if ($('#gramajeSobrecubierta option:selected').text().length == 0) {
|
||||
return value.length > 0 && Number.isInteger(parseInt(value)) && parseInt(value) > 0;
|
||||
}
|
||||
return true;
|
||||
},
|
||||
}
|
||||
}
|
||||
},
|
||||
},
|
||||
plugins: {
|
||||
trigger: new FormValidation.plugins.Trigger(),
|
||||
bootstrap5: new FormValidation.plugins.Bootstrap5({
|
||||
// Use this for enabling/changing valid/invalid class
|
||||
// eleInvalidClass: '',
|
||||
eleValidClass: '',
|
||||
rowSelector: function (field, ele) {
|
||||
// field is the field name
|
||||
// ele is the field element
|
||||
switch (field) {
|
||||
case 'gramajeInterior':
|
||||
case 'gramajeCubierta':
|
||||
case 'gramajeSobrecubierta':
|
||||
return '.col-sm-2';
|
||||
|
||||
case 'titulo':
|
||||
return '.col-sm-12';
|
||||
|
||||
case 'clienteId':
|
||||
return '.col-sm-6';
|
||||
|
||||
default:
|
||||
return '.col-sm-3';
|
||||
}
|
||||
}
|
||||
}),
|
||||
autoFocus: new FormValidation.plugins.AutoFocus(),
|
||||
submitButton: new FormValidation.plugins.SubmitButton()
|
||||
}
|
||||
}).on('core.form.valid', function () {
|
||||
validationStepper.next();
|
||||
initDirecciones();
|
||||
initTiradasDirecciones();
|
||||
});
|
||||
|
||||
const tirada = $('#tirada');
|
||||
tirada.on('change', function () {
|
||||
// Revalidate the clienteId field when an option is chosen
|
||||
FormValidation2.revalidateField('gramajeInterior');
|
||||
FormValidation2.revalidateField('gramajeCubierta');
|
||||
FormValidation2.revalidateField('gramajeSobrecubierta');
|
||||
});
|
||||
|
||||
// Direcciones
|
||||
const FormValidation4 = FormValidation.formValidation(clientePresupuestoWizardFormStep4, {
|
||||
fields: {
|
||||
|
||||
},
|
||||
plugins: {
|
||||
trigger: new FormValidation.plugins.Trigger(),
|
||||
bootstrap5: new FormValidation.plugins.Bootstrap5({
|
||||
// Use this for enabling/changing valid/invalid class
|
||||
// eleInvalidClass: '',
|
||||
eleValidClass: '',
|
||||
rowSelector: '.col-md-12'
|
||||
}),
|
||||
autoFocus: new FormValidation.plugins.AutoFocus(),
|
||||
submitButton: new FormValidation.plugins.SubmitButton()
|
||||
}
|
||||
}).on('core.form.valid', function () {
|
||||
if(validarEnvio()){
|
||||
generarResumen();
|
||||
validationStepper.next();
|
||||
}
|
||||
else{
|
||||
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();
|
||||
}
|
||||
});
|
||||
|
||||
// Deal Usage
|
||||
const FormValidation5 = FormValidation.formValidation(clientePresupuestoWizardFormStep5, {
|
||||
fields: {
|
||||
// * Validate the fields here based on your requirements
|
||||
},
|
||||
plugins: {
|
||||
trigger: new FormValidation.plugins.Trigger(),
|
||||
bootstrap5: new FormValidation.plugins.Bootstrap5({
|
||||
// Use this for enabling/changing valid/invalid class
|
||||
// eleInvalidClass: '',
|
||||
eleValidClass: '',
|
||||
rowSelector: '.col-md-12'
|
||||
}),
|
||||
autoFocus: new FormValidation.plugins.AutoFocus(),
|
||||
submitButton: new FormValidation.plugins.SubmitButton()
|
||||
}
|
||||
}).on('core.form.valid', function () {
|
||||
// You can submit the form
|
||||
// clientePresupuestoWizardForm.submit()
|
||||
// or send the form data to server via an Ajax request
|
||||
// To make the demo simple, I just placed an alert
|
||||
alert('Submitted..!!');
|
||||
});
|
||||
|
||||
clientePresupuestoWizardNext.forEach(item => {
|
||||
item.addEventListener('click', event => {
|
||||
// When click the Next button, we will validate the current step
|
||||
switch (validationStepper._currentIndex) {
|
||||
case 0:
|
||||
FormValidation2.validate();
|
||||
break;
|
||||
|
||||
case 1:
|
||||
FormValidation3.validate();
|
||||
break;
|
||||
|
||||
case 2:
|
||||
FormValidation4.validate();
|
||||
break;
|
||||
|
||||
case 3:
|
||||
FormValidation5.validate();
|
||||
break;
|
||||
|
||||
default:
|
||||
validationStepper.next();
|
||||
break;
|
||||
plugins: {
|
||||
trigger: new FormValidation.plugins.Trigger(),
|
||||
bootstrap5: new FormValidation.plugins.Bootstrap5({
|
||||
// Use this for enabling/changing valid/invalid class
|
||||
// eleInvalidClass: '',
|
||||
eleValidClass: '',
|
||||
rowSelector: '.col-sm-3'
|
||||
}),
|
||||
autoFocus: new FormValidation.plugins.AutoFocus(),
|
||||
submitButton: new FormValidation.plugins.SubmitButton()
|
||||
}
|
||||
}).on('core.form.valid', function () {
|
||||
// Jump to the next step when all fields in the current step are valid
|
||||
validationStepper.next();
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
clientePresupuestoWizardPrev.forEach(item => {
|
||||
item.addEventListener('click', event => {
|
||||
switch (validationStepper._currentIndex) {
|
||||
case 4:
|
||||
validationStepper.previous();
|
||||
break;
|
||||
|
||||
case 3:
|
||||
validationStepper.previous();
|
||||
break;
|
||||
|
||||
case 2:
|
||||
for (let i = 0; i < 4; i++) {
|
||||
let id = "tiradaPrecio" + i;
|
||||
if ($('#' + id).length > 0) {
|
||||
$('#' + id).show();
|
||||
// Deal Usage
|
||||
const FormValidation3 = FormValidation.formValidation(clientePresupuestoWizardFormStep3, {
|
||||
fields: {
|
||||
titulo: {
|
||||
validators: {
|
||||
notEmpty: {
|
||||
message: window.Presupuestos.validation.requerido_short
|
||||
},
|
||||
}
|
||||
},
|
||||
clienteId: {
|
||||
validators: {
|
||||
callback: {
|
||||
message: window.Presupuestos.validation.cliente,
|
||||
callback: function (input) {
|
||||
// Get the selected options
|
||||
const options = $("#clienteId").select2('data');
|
||||
const hasValidOption = options.some(option => parseInt(option.id) > 0);
|
||||
return options !== null && options.length > 0 && hasValidOption;
|
||||
},
|
||||
}
|
||||
}
|
||||
validationStepper.previous();
|
||||
break;
|
||||
},
|
||||
tirada: {
|
||||
validators: {
|
||||
callback: {
|
||||
message: window.Presupuestos.validation.integer_greatherThan_0,
|
||||
callback: function (input) {
|
||||
const value = $("#tirada").val();
|
||||
return value.length > 0 && Number.isInteger(parseInt(value)) && parseInt(value) > 0;
|
||||
},
|
||||
}
|
||||
}
|
||||
},
|
||||
paginas: {
|
||||
validators: {
|
||||
callback: {
|
||||
message: window.Presupuestos.validation.integer_greatherThan_0,
|
||||
callback: function (input) {
|
||||
const value = $("#paginas").val();
|
||||
return value.length > 0 && Number.isInteger(parseInt(value)) && parseInt(value) > 0;
|
||||
},
|
||||
}
|
||||
}
|
||||
},
|
||||
paginasColor: {
|
||||
validators: {
|
||||
callback: {
|
||||
message: window.Presupuestos.validation.integer_greatherThan_0,
|
||||
callback: function (input) {
|
||||
if ($('#pagColorDiv').is(':hidden'))
|
||||
return true;
|
||||
else {
|
||||
const value = $("#paginasColor").val();
|
||||
return value.length > 0 && Number.isInteger(parseInt(value)) && parseInt(value) > 0;
|
||||
}
|
||||
},
|
||||
}
|
||||
}
|
||||
},
|
||||
gramajeInterior: {
|
||||
validators: {
|
||||
callback: {
|
||||
callback: function (input) {
|
||||
const value = $("#tirada").val();
|
||||
if ($('#gramajeInterior option:selected').text().length == 0) {
|
||||
if(value.length > 0 && Number.isInteger(parseInt(value)) && parseInt(value) > 0){
|
||||
return {
|
||||
valid: false,
|
||||
message: window.Presupuestos.validation.sin_gramaje,
|
||||
}
|
||||
}
|
||||
return {
|
||||
valid: value.length > 0 && Number.isInteger(parseInt(value)) && parseInt(value) > 0,
|
||||
message: window.Presupuestos.validation.tirada_no_valida,
|
||||
}
|
||||
}
|
||||
return true;
|
||||
},
|
||||
},
|
||||
}
|
||||
},
|
||||
gramajeCubierta: {
|
||||
validators: {
|
||||
callback: {
|
||||
message: window.Presupuestos.validation.tirada_no_valida,
|
||||
callback: function (input) {
|
||||
const value = $("#tirada").val();
|
||||
if ($('#gramajeCubierta option:selected').text().length == 0) {
|
||||
return value.length > 0 && Number.isInteger(parseInt(value)) && parseInt(value) > 0;
|
||||
}
|
||||
return true;
|
||||
},
|
||||
},
|
||||
callback: {
|
||||
message: window.Presupuestos.validation.sin_gramaje,
|
||||
callback: function (input) {
|
||||
if ($('#gramajeCubierta option:selected').text().length == 0) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
},
|
||||
}
|
||||
}
|
||||
},
|
||||
gramajeSobrecubierta: {
|
||||
validators: {
|
||||
callback: {
|
||||
message: window.Presupuestos.validation.tirada_no_valida,
|
||||
callback: function (input) {
|
||||
const value = $("#tirada").val();
|
||||
if ($('#gramajeSobrecubierta option:selected').text().length == 0) {
|
||||
return value.length > 0 && Number.isInteger(parseInt(value)) && parseInt(value) > 0;
|
||||
}
|
||||
return true;
|
||||
},
|
||||
}
|
||||
}
|
||||
},
|
||||
},
|
||||
plugins: {
|
||||
trigger: new FormValidation.plugins.Trigger(),
|
||||
bootstrap5: new FormValidation.plugins.Bootstrap5({
|
||||
// Use this for enabling/changing valid/invalid class
|
||||
// eleInvalidClass: '',
|
||||
eleValidClass: '',
|
||||
rowSelector: function (field, ele) {
|
||||
// field is the field name
|
||||
// ele is the field element
|
||||
switch (field) {
|
||||
case 'gramajeInterior':
|
||||
case 'gramajeCubierta':
|
||||
case 'gramajeSobrecubierta':
|
||||
return '.col-sm-2';
|
||||
|
||||
case 1:
|
||||
validationStepper.previous();
|
||||
break;
|
||||
case 'titulo':
|
||||
return '.col-sm-12';
|
||||
|
||||
case 0:
|
||||
window.location.href = document.location.origin + '/presupuestocliente/list';
|
||||
case 'clienteId':
|
||||
return '.col-sm-6';
|
||||
|
||||
default:
|
||||
break;
|
||||
default:
|
||||
return '.col-sm-3';
|
||||
}
|
||||
}
|
||||
}),
|
||||
autoFocus: new FormValidation.plugins.AutoFocus(),
|
||||
submitButton: new FormValidation.plugins.SubmitButton()
|
||||
}
|
||||
}).on('core.form.valid', function () {
|
||||
validationStepper.next();
|
||||
initDirecciones();
|
||||
initTiradasDirecciones();
|
||||
});
|
||||
|
||||
const tirada = $('#tirada');
|
||||
tirada.on('change', function () {
|
||||
// Revalidate the clienteId field when an option is chosen
|
||||
FormValidation2.revalidateField('gramajeInterior');
|
||||
FormValidation2.revalidateField('gramajeCubierta');
|
||||
FormValidation2.revalidateField('gramajeSobrecubierta');
|
||||
});
|
||||
|
||||
// Direcciones
|
||||
const FormValidation4 = FormValidation.formValidation(clientePresupuestoWizardFormStep4, {
|
||||
fields: {
|
||||
|
||||
},
|
||||
plugins: {
|
||||
trigger: new FormValidation.plugins.Trigger(),
|
||||
bootstrap5: new FormValidation.plugins.Bootstrap5({
|
||||
// Use this for enabling/changing valid/invalid class
|
||||
// eleInvalidClass: '',
|
||||
eleValidClass: '',
|
||||
rowSelector: '.col-md-12'
|
||||
}),
|
||||
autoFocus: new FormValidation.plugins.AutoFocus(),
|
||||
submitButton: new FormValidation.plugins.SubmitButton()
|
||||
}
|
||||
}).on('core.form.valid', function () {
|
||||
if(validarEnvio()){
|
||||
generarResumen();
|
||||
validationStepper.next();
|
||||
}
|
||||
else{
|
||||
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();
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
// Deal Usage
|
||||
const FormValidation5 = FormValidation.formValidation(clientePresupuestoWizardFormStep5, {
|
||||
fields: {
|
||||
// * Validate the fields here based on your requirements
|
||||
},
|
||||
plugins: {
|
||||
trigger: new FormValidation.plugins.Trigger(),
|
||||
bootstrap5: new FormValidation.plugins.Bootstrap5({
|
||||
// Use this for enabling/changing valid/invalid class
|
||||
// eleInvalidClass: '',
|
||||
eleValidClass: '',
|
||||
rowSelector: '.col-md-12'
|
||||
}),
|
||||
autoFocus: new FormValidation.plugins.AutoFocus(),
|
||||
submitButton: new FormValidation.plugins.SubmitButton()
|
||||
}
|
||||
}).on('core.form.valid', function () {
|
||||
// You can submit the form
|
||||
// clientePresupuestoWizardForm.submit()
|
||||
// or send the form data to server via an Ajax request
|
||||
// To make the demo simple, I just placed an alert
|
||||
//alert('Submitted..!!');
|
||||
});
|
||||
|
||||
clientePresupuestoWizardNext.forEach(item => {
|
||||
item.addEventListener('click', event => {
|
||||
// When click the Next button, we will validate the current step
|
||||
switch (validationStepper._currentIndex) {
|
||||
case 0:
|
||||
FormValidation2.validate();
|
||||
break;
|
||||
|
||||
case 1:
|
||||
FormValidation3.validate();
|
||||
break;
|
||||
|
||||
case 2:
|
||||
FormValidation4.validate();
|
||||
break;
|
||||
|
||||
case 3:
|
||||
FormValidation5.validate();
|
||||
break;
|
||||
|
||||
default:
|
||||
validationStepper.next();
|
||||
break;
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
clientePresupuestoWizardPrev.forEach(item => {
|
||||
item.addEventListener('click', event => {
|
||||
switch (validationStepper._currentIndex) {
|
||||
case 4:
|
||||
validationStepper.previous();
|
||||
break;
|
||||
|
||||
case 3:
|
||||
validationStepper.previous();
|
||||
break;
|
||||
|
||||
case 2:
|
||||
for (let i = 0; i < 4; i++) {
|
||||
let id = "tiradaPrecio" + i;
|
||||
if ($('#' + id).length > 0) {
|
||||
$('#' + id).show();
|
||||
}
|
||||
}
|
||||
validationStepper.previous();
|
||||
break;
|
||||
|
||||
case 1:
|
||||
validationStepper.previous();
|
||||
break;
|
||||
|
||||
case 0:
|
||||
window.location.href = document.location.origin + '/presupuestocliente/list';
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
})();
|
||||
|
||||
|
||||
@ -12,22 +12,44 @@ $(document).on('shown.bs.modal', function (e) {
|
||||
|
||||
function previewEsquemaCubierta(isThumbnail = false) {
|
||||
|
||||
if ($('#cosidoDiv').hasClass('checked') || $("#fresadoDiv").hasClass('checked')) {
|
||||
console.log("Cosido/Fresado");
|
||||
if ($("#tapaBlanda").is(":checked")) {
|
||||
portadaTapaBlanda(isThumbnail);
|
||||
} else if ($("#tapaDura").is(":checked")) {
|
||||
portadaTapaDura(isThumbnail);3
|
||||
if($('#cosidoDiv').length){
|
||||
|
||||
if ($('#cosidoDiv').hasClass('checked') || $("#fresadoDiv").hasClass('checked')) {
|
||||
//console.log("Cosido/Fresado");
|
||||
if ($("#tapaBlanda").is(":checked")) {
|
||||
portadaTapaBlanda(isThumbnail);
|
||||
} else if ($("#tapaDura").is(":checked")) {
|
||||
portadaTapaDura(isThumbnail);
|
||||
}
|
||||
} else if ($('#espiralDiv').hasClass('checked') || $('#wireoDiv').hasClass('checked')) {
|
||||
//console.log("Espiral/Wireo");
|
||||
if ($("#tapaBlanda").is(":checked")) {
|
||||
portadaEspiral(isThumbnail, false);
|
||||
} else if ($("#tapaDura").is(":checked")) {
|
||||
portadaEspiral(isThumbnail, true);
|
||||
}
|
||||
} else if ($('#grapadoDiv').hasClass('checked')) {
|
||||
portadaGrapado(isThumbnail);
|
||||
}
|
||||
} else if ($('#espiralDiv').hasClass('checked') || $('#wireoDiv').hasClass('checked')) {
|
||||
console.log("Espiral/Wireo");
|
||||
if ($("#tapaBlanda").is(":checked")) {
|
||||
portadaEspiral(isThumbnail, false);
|
||||
} else if ($("#tapaDura").is(":checked")) {
|
||||
portadaEspiral(isThumbnail, true);
|
||||
}
|
||||
else{
|
||||
let titulo = $('#tipoLibro').text().toLowerCase();
|
||||
if(titulo.includes("cosido") || titulo.includes("fresado")){
|
||||
if(titulo.includes("dura"))
|
||||
portadaTapaDura(isThumbnail);
|
||||
else{
|
||||
portadaTapaBlanda(isThumbnail);
|
||||
}
|
||||
}
|
||||
else if (titulo.includes("espiral") || titulo.includes("wire-o")){
|
||||
if(titulo.includes("dura"))
|
||||
portadaEspiral(isThumbnail, true);
|
||||
else
|
||||
portadaEspiral(isThumbnail, false);
|
||||
}
|
||||
else if (titulo.includes("grapado")){
|
||||
portadaGrapado(isThumbnail);
|
||||
}
|
||||
} else if ($('#grapadoDiv').hasClass('checked')) {
|
||||
portadaGrapado(isThumbnail);
|
||||
}
|
||||
|
||||
|
||||
@ -772,12 +794,23 @@ function portadaGrapado(isThumbnail = false) {
|
||||
|
||||
function getObjetoToPreview() {
|
||||
|
||||
pvObj = {
|
||||
lomoLibro: $('#lomo_cubierta').val() === '' ? parseFloat('0.0') : parseFloat($('#lomo_cubierta').val()),
|
||||
anchoSolapa: $('#solapasCubierta').is(':checked') ? parseFloat($('#anchoSolapasCubierta').val()) : parseFloat(0),
|
||||
altoLibro: getDimensionLibro().alto,
|
||||
anchoLibro: getDimensionLibro().ancho
|
||||
};
|
||||
console.log(pvObj);
|
||||
if($('#cosidoDiv').length){
|
||||
pvObj = {
|
||||
lomoLibro: $('#lomo_cubierta').val() === '' ? parseFloat('0.0') : parseFloat($('#lomo_cubierta').val()),
|
||||
anchoSolapa: $('#solapasCubierta').is(':checked') ? parseFloat($('#anchoSolapasCubierta').val()) : parseFloat(0),
|
||||
altoLibro: getDimensionLibro().alto,
|
||||
anchoLibro: getDimensionLibro().ancho
|
||||
};
|
||||
} else {
|
||||
let tamanio = $('#resumenTamanio').text().split(' ')[1].split('x');
|
||||
let solapas = parseInt($('#resumenSolapasCubierta').length ? $('#resumenSolapasCubierta').text().split(' ')[1].replace("mm", '') : 0);
|
||||
pvObj = {
|
||||
lomoLibro: $('#lomo_cubierta').val() === '' ? parseFloat('0.0') : parseFloat($('#lomo_cubierta').val()),
|
||||
anchoSolapa: solapas,
|
||||
altoLibro: parseInt(tamanio[1]),
|
||||
anchoLibro: parseInt(tamanio[0])
|
||||
};
|
||||
}
|
||||
//console.log(pvObj);
|
||||
|
||||
}
|
||||
|
||||
@ -44,7 +44,7 @@ function generarResumen(){
|
||||
$('#resumenSolapasCubierta').text('Solapas: No')
|
||||
}
|
||||
|
||||
if ($('.enable-sobrecubierta').is(':visible')) {
|
||||
if ($('#enableSobrecubierta').is(':checked')) {
|
||||
$(".resumen-sobrecubierta").show();
|
||||
$('#resumenPapelCubierta').text($('#papelSobrecubierta option:selected').text().trim() + ' ' +
|
||||
$('#gramajeSobrecubierta option:selected').text() + 'gr/m²');
|
||||
@ -56,7 +56,8 @@ function generarResumen(){
|
||||
$(".resumen-sobrecubierta").hide();
|
||||
}
|
||||
|
||||
if ($('.guardas').is(':visible')) {
|
||||
if ($('#divGuardas').css('display') != 'none') {
|
||||
|
||||
$(".resumen-guardas").show();
|
||||
$('#resumenGuardasPapel').text($('#papelGuardas option:selected').text().trim() + ' ' + '170gr/m²');
|
||||
$('#resumenGuardasCaras').text('Impresión: ' + $('#impresionGuardas option:selected').text())
|
||||
@ -77,32 +78,44 @@ function generarResumen(){
|
||||
$('.resumen-extras').hide();
|
||||
}
|
||||
|
||||
for (i = 1; i <= 4; i++) {
|
||||
let id = "tiradaPrecio" + i;
|
||||
if ($('#' + id).length > 0) {
|
||||
if(window.estado==1){
|
||||
for (i = 1; i <= 4; i++) {
|
||||
let id = "tiradaPrecio" + i;
|
||||
if ($('#' + id).length > 0) {
|
||||
|
||||
const envio = getTotalEnvio();
|
||||
|
||||
let tirada_id = "ud_tiradaPrecio" + i;
|
||||
if(parseInt($('#' + tirada_id).text().replace(' ud.', '')) != tirada){
|
||||
continue;
|
||||
}
|
||||
const envio = getTotalEnvio();
|
||||
|
||||
let tirada_id = "ud_tiradaPrecio" + i;
|
||||
if(parseInt($('#' + tirada_id).text().replace(' ud.', '')) != tirada){
|
||||
continue;
|
||||
}
|
||||
|
||||
let total_id = "tot_tiradaPrecio" + i;
|
||||
|
||||
let total = parseFloat($('#' + total_id).text().replace('€', '').replace('Total: ', '')) + envio;
|
||||
let total_iva = 0.0;
|
||||
if($('#ivaReducido').val() == '1'){
|
||||
total_iva = total * 1.04;
|
||||
let total_id = "tot_tiradaPrecio" + i;
|
||||
|
||||
let total = parseFloat($('#' + total_id).text().replace('€', '').replace('Total: ', '')) + envio;
|
||||
let total_iva = 0.0;
|
||||
if($('#ivaReducido').val() == '1'){
|
||||
total_iva = total * 1.04;
|
||||
}
|
||||
else{
|
||||
total_iva = total * 1.21;
|
||||
}
|
||||
const precio_u = total_iva/tirada;
|
||||
$('#resumenTotalIVA').text('Total (I.V.A. ' + (($('#ivaReducido').val() == '1')?'4':'21') + '%): ' + total_iva.toFixed(2) + '€');
|
||||
$('#resumenPrecioU').text(precio_u.toFixed(4) + '€/ud');
|
||||
}
|
||||
else{
|
||||
total_iva = total * 1.21;
|
||||
}
|
||||
const precio_u = total_iva/tirada;
|
||||
$('#resumenTotalIVA').text('Total (I.V.A. ' + (($('#ivaReducido').val() == '1')?'4':'21') + '%): ' + total_iva.toFixed(2) + '€');
|
||||
$('#resumenPrecioU').text(precio_u.toFixed(4) + '€/ud');
|
||||
}
|
||||
}
|
||||
else{
|
||||
let iva = 1.04;
|
||||
if(window.iva_reducido == 0){
|
||||
iva = 1.21;
|
||||
}
|
||||
let total = window.total*iva;
|
||||
let p_unidad = total/window.tirada;
|
||||
$('#resumenTotalIVA').text('Total (I.V.A. ' + (total.toFixed(2)) + '€');
|
||||
$('#resumenPrecioU').text(p_unidad.toFixed(4) + '€/ud');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -133,12 +146,54 @@ $('#btnConfirm').on('click', function() {
|
||||
|
||||
});
|
||||
|
||||
$('#btnDuplicar').on('click', function() {
|
||||
|
||||
const paths = window.location.pathname.split("/").filter(path => path !== "");
|
||||
let id=0;
|
||||
if(paths.length > 0 && paths[paths.length - 2] == 'edit'){
|
||||
id=paths[paths.length - 1];
|
||||
}
|
||||
datos = {
|
||||
id: id,
|
||||
}
|
||||
datos = Object.assign(datos, window.token_ajax)
|
||||
|
||||
$('#loader').show();
|
||||
|
||||
$.ajax({
|
||||
url: window.routes_resumen.duplicarPresupuesto,
|
||||
type: 'POST',
|
||||
data: datos,
|
||||
success: function(response) {
|
||||
|
||||
if(Object.keys(response).length > 0) {
|
||||
if(response.success){
|
||||
$('#loader').hide();
|
||||
window.location.href = document.location.origin + '/presupuestos/presupuestocliente/edit/' + response.id;
|
||||
}
|
||||
}
|
||||
$('#loader').hide();
|
||||
|
||||
},
|
||||
error: function() {
|
||||
$('#loader').hide();
|
||||
},
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
$('#btnBack').on('click', function() {
|
||||
window.location.href = document.location.origin + '/presupuestocliente/list';
|
||||
});
|
||||
|
||||
function finalizarPresupuesto(confirmar){
|
||||
|
||||
const paths = window.location.pathname.split("/").filter(path => path !== "");
|
||||
let id=0;
|
||||
if(paths.length > 0 && paths[paths.length - 2] == 'edit'){
|
||||
id=paths[paths.length - 1];
|
||||
}
|
||||
|
||||
let servicios = [];
|
||||
$('.servicio-extra:checked').each(function () {
|
||||
servicios.push($(this).attr('serv_id'));
|
||||
@ -171,7 +226,7 @@ function finalizarPresupuesto(confirmar){
|
||||
}
|
||||
|
||||
// Si hay sobrecubierta
|
||||
if ($('.enable-sobrecubierta').is(':visible')) {
|
||||
if ($('#enableSobrecubierta').is(':checked')) {
|
||||
if($('#papelSobrecubierta option:selected').val()>0 && $('#gramajeSobrecubierta option:selected').val()>0){
|
||||
|
||||
datos_libro.sobrecubierta = {
|
||||
@ -181,11 +236,11 @@ function finalizarPresupuesto(confirmar){
|
||||
acabado: $('#acabadosSobrecubierta').val()
|
||||
}
|
||||
|
||||
datos.sobrecubierta.solapas = $('#anchoSolapasSobrecubierta').val()
|
||||
datos_libro.sobrecubierta.solapas = $('#anchoSolapasSobrecubierta').val()
|
||||
}
|
||||
}
|
||||
|
||||
if ($('.guardas').is(':visible')) {
|
||||
if ($('#divGuardas').css('display') != 'none') {
|
||||
datos_libro.guardas = {
|
||||
papel: $('#papelGuardas option:selected').val(),
|
||||
papel_nombre: $('#papelGuardas option:selected').text().trim(),
|
||||
@ -215,13 +270,14 @@ function finalizarPresupuesto(confirmar){
|
||||
|
||||
let direcciones = getDireccionesEnvio();
|
||||
datos = {
|
||||
id: id,
|
||||
datos_libro : datos_libro,
|
||||
datos_cabecera: datos_cabecera,
|
||||
direcciones: direcciones,
|
||||
tirada: tirada,
|
||||
peso: peso_libro,
|
||||
iva_reducido: $('#ivaReducido').val()==1?1:0,
|
||||
confirmar: confirmar,
|
||||
confirmar: confirmar?1:0,
|
||||
},
|
||||
|
||||
datos = Object.assign(datos, window.token_ajax)
|
||||
|
||||
@ -172,7 +172,7 @@ theTable = $('#tableOfPresupuestos').DataTable({
|
||||
}
|
||||
],
|
||||
stateSave: false,
|
||||
order: [[1, 'asc']],
|
||||
order: [[1, 'desc']],
|
||||
language: {
|
||||
url: "/themes/vuexy/vendor/libs/datatables-sk/plugins/i18n/es-ES.json"
|
||||
},
|
||||
|
||||
@ -19,7 +19,8 @@
|
||||
<!-- Create Deal Wizard -->
|
||||
<div id="wizard-presupuesto-cliente" class="bs-stepper vertical mt-2 linear">
|
||||
<div class="bs-stepper-header">
|
||||
|
||||
|
||||
<?php if($presupuestoEntity->estado_id==1): ?>
|
||||
<div class="step active" data-target="#tipo-libro">
|
||||
<button type="button" class="step-trigger" aria-selected="false" disabled="disabled">
|
||||
<span class="bs-stepper-circle"><i class="ti ti-book ti-sm"></i></span>
|
||||
@ -52,6 +53,7 @@
|
||||
</button>
|
||||
</div>
|
||||
<div class="line"></div>
|
||||
<?php endif; ?>
|
||||
|
||||
<div class="step" data-target="#resumen-libro">
|
||||
<button type="button" class="step-trigger" aria-selected="false" disabled="disabled">
|
||||
@ -80,7 +82,9 @@
|
||||
|
||||
|
||||
<!-- Tipo Libro -->
|
||||
<?php if($presupuestoEntity->estado_id==1): ?>
|
||||
<div id="tipo-libro" class="content active dstepper-block fv-plugins-bootstrap5 fv-plugins-framework">
|
||||
|
||||
<div class="row g-3">
|
||||
|
||||
<?= view("themes/vuexy/form/presupuestos/cliente/_tipoLibroItems") ?>
|
||||
@ -135,6 +139,7 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
|
||||
<!-- Review & Complete -->
|
||||
<div id="resumen-libro" class="content fv-plugins-bootstrap5 fv-plugins-framework">
|
||||
@ -145,10 +150,12 @@
|
||||
</div>
|
||||
<div class="col-12 d-flex justify-content-between mt-4">
|
||||
<div class="col-6 d-flex flex-row">
|
||||
<?php if ($presupuestoEntity->estado_id == 1) : ?>
|
||||
<button class="btn btn-primary btn-prev waves-effect waves-light">
|
||||
<i class="ti ti-arrow-left ti-xs me-sm-1 me-0"></i>
|
||||
<span class="align-middle d-sm-inline-block d-none me-sm-1">Anterior</span>
|
||||
</button>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
<div class="col-6 d-flex flex-row-reverse">
|
||||
<?php if ($presupuestoEntity->estado_id == 1) : ?>
|
||||
@ -156,7 +163,7 @@
|
||||
<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 id="btnConfirm" class="btn btn-success btn-submit btn-next mx-2 waves-effect waves-light">
|
||||
<button id="btnConfirm" class="btn btn-success btn-submit btn-next mx-2 waves-effect waves-light ml-2">
|
||||
<span class="align-middle d-sm-inline-block d-none me-sm-1">Confirmar</span><i class="ti ti-check ti-xs"></i>
|
||||
</button>
|
||||
<?php else: ?>
|
||||
@ -164,6 +171,11 @@
|
||||
<span class="align-middle d-sm-inline-block d-none me-sm-1">Volver</span><i class="ti ti-check ti-xs"></i>
|
||||
</button>
|
||||
<?php endif; ?>
|
||||
<button id="btnDuplicar" 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">Duplicar</span>
|
||||
<i class="ti ti-copy ti-xs"></i>
|
||||
</button>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@ -214,7 +226,9 @@ $('#clienteId').select2({
|
||||
}
|
||||
});
|
||||
|
||||
initDisenioLibro();
|
||||
if(<?= $presupuestoEntity->estado_id ?>==1){
|
||||
initDisenioLibro();
|
||||
}
|
||||
<?= $this->endSection() ?>
|
||||
|
||||
|
||||
|
||||
BIN
vscode-extensions.txt
Normal file
BIN
vscode-extensions.txt
Normal file
Binary file not shown.
117464
xdebug.log
117464
xdebug.log
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user