mirror of
https://git.imnavajas.es/jjimenez/safekat.git
synced 2025-07-25 22:52:08 +00:00
Merge branch 'feat/presu_cliente_pass_id' into 'main'
Feat/presu cliente pass See merge request jjimenez/safekat!279
This commit is contained in:
@ -9,10 +9,18 @@ const SK_PERMISSION_MATRIX = [
|
||||
"plantilla-tarifa.edit",
|
||||
"plantilla-tarifa.delete",
|
||||
"plantilla-tarifa.menu",
|
||||
"perfil.create",
|
||||
"perfil.edit",
|
||||
"perfil.delete",
|
||||
"perfil.menu",
|
||||
"presupuesto.create",
|
||||
"presupuesto.edit",
|
||||
"presupuesto.delete",
|
||||
"presupuesto.menu",
|
||||
"presupuesto-cliente.create",
|
||||
"presupuesto-cliente.edit",
|
||||
"presupuesto-cliente.delete",
|
||||
"presupuesto-cliente.menu",
|
||||
"tarifa-preimpresion.create",
|
||||
"tarifa-preimpresion.edit",
|
||||
"tarifa-preimpresion.delete",
|
||||
@ -73,22 +81,28 @@ const SK_PERMISSION_MATRIX = [
|
||||
"roles-permisos.edit",
|
||||
"roles-permisos.delete",
|
||||
"roles-permisos.menu",
|
||||
"ubicaciones.create",
|
||||
"ubicaciones.edit",
|
||||
"ubicaciones.delete",
|
||||
"ubicaciones.menu",
|
||||
"series-facturas.create",
|
||||
"series-facturas.edit",
|
||||
"series-facturas.delete",
|
||||
"series-facturas.menu",
|
||||
],
|
||||
"cliente-admin" => [
|
||||
"perfil.edit",
|
||||
"perfil.menu",
|
||||
"presupuesto-cliente.create",
|
||||
"presupuesto-cliente.edit",
|
||||
"presupuesto-cliente.delete",
|
||||
"presupuesto-cliente.menu",
|
||||
"usuarios.create",
|
||||
"usuarios.edit",
|
||||
"usuarios.delete",
|
||||
"usuarios.menu",
|
||||
],
|
||||
"cliente-editor" => [
|
||||
"presupuesto.create",
|
||||
"presupuesto.edit",
|
||||
"presupuesto.delete",
|
||||
"presupuesto.menu",
|
||||
"presupuesto-cliente.create",
|
||||
"presupuesto-cliente.edit",
|
||||
"presupuesto-cliente.delete",
|
||||
"presupuesto-cliente.menu",
|
||||
],
|
||||
"comercial" => [
|
||||
"token.token",
|
||||
|
||||
@ -9,6 +9,10 @@ const SK_PERMISSIONS = [
|
||||
'plantilla-tarifa.edit' => 'Can edit',
|
||||
'plantilla-tarifa.delete' => 'Can delete',
|
||||
'plantilla-tarifa.menu' => 'Menu shall be visualize',
|
||||
'perfil.create' => 'Can create',
|
||||
'perfil.edit' => 'Can edit',
|
||||
'perfil.delete' => 'Can delete',
|
||||
'perfil.menu' => 'Menu shall be visualize',
|
||||
'presupuesto.create' => 'Can create',
|
||||
'presupuesto.edit' => 'Can edit',
|
||||
'presupuesto.delete' => 'Can delete',
|
||||
@ -77,4 +81,12 @@ const SK_PERMISSIONS = [
|
||||
'roles-permisos.edit' => 'Can edit',
|
||||
'roles-permisos.delete' => 'Can delete',
|
||||
'roles-permisos.menu' => 'Menu shall be visualize',
|
||||
'ubicaciones.create' => 'Can create',
|
||||
'ubicaciones.edit' => 'Can edit',
|
||||
'ubicaciones.delete' => 'Can delete',
|
||||
'ubicaciones.menu' => 'Menu shall be visualize',
|
||||
'series-facturas.create' => 'Can create',
|
||||
'series-facturas.edit' => 'Can edit',
|
||||
'series-facturas.delete' => 'Can delete',
|
||||
'series-facturas.menu' => 'Menu shall be visualize',
|
||||
];
|
||||
|
||||
@ -72,9 +72,11 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
|
||||
'pageTitle' => lang('Presupuestos.presupuestos'),
|
||||
];
|
||||
|
||||
|
||||
if (auth()->user()->inGroup('cliente-admin') || auth()->user()->inGroup('cliente-editor')) {
|
||||
$clienteId = 999; // Fijo hasta desarollar clientes usuarios
|
||||
// Se obtiene el cliente ID a partir del usuario de la sesion
|
||||
$model_user = model('App\Models\Usuarios\UserModel');
|
||||
$user = $model_user->find(auth()->user()->id);
|
||||
$clienteId = $user->cliente_id;
|
||||
} else {
|
||||
$clienteId = 0;
|
||||
}
|
||||
@ -87,8 +89,10 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
|
||||
public function add()
|
||||
{
|
||||
// Se obtiene el cliente ID a partir del usuario de la sesion
|
||||
$clienteId = 999; // Fijo hasta desarollar clientes usuarios
|
||||
|
||||
$model_user = model('App\Models\Usuarios\UserModel');
|
||||
$user = $model_user->find(auth()->user()->id);
|
||||
$clienteId = $user->cliente_id;
|
||||
|
||||
$presupuestoEntity = isset($sanitizedData) ? new PresupuestoEntity($sanitizedData) : new PresupuestoEntity();
|
||||
$presupuestoEntity->clienteId = $clienteId;
|
||||
|
||||
@ -111,10 +115,9 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
|
||||
|
||||
$datosPresupuesto->tipo_libro = "";
|
||||
$datosPresupuesto->color_impresion = 'negro';
|
||||
$datosPresupuesto->calidad_impresion = 'estandar';
|
||||
$datosPresupuesto->tapa = 'blanda';
|
||||
|
||||
$datosPresupuesto->clienteList = $this->getClienteListItems($presupuestoEntity->cliente_id ?? null);
|
||||
$datosPresupuesto->clienteList = $this->getClienteListItems($clienteId ?? null);
|
||||
$presupuestoEntity->estado_id = 1;
|
||||
|
||||
$this->viewData['formAction'] = 'add';
|
||||
@ -123,6 +126,7 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
|
||||
|
||||
$this->viewData['presupuestoEntity'] = $presupuestoEntity;
|
||||
$this->viewData['datosPresupuesto'] = $datosPresupuesto;
|
||||
$this->viewData['clienteId'] = $clienteId;
|
||||
|
||||
$this->viewData['boxTitle'] = lang('Basic.global.addNew') . ' ' . $this->viewData['pageTitle'] . ' ' . lang('Basic.global.addNewSuffix');
|
||||
|
||||
@ -132,7 +136,6 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
|
||||
|
||||
public function edit($requestedId = null)
|
||||
{
|
||||
|
||||
if ($requestedId == null) :
|
||||
return $this->redirect2listView();
|
||||
endif;
|
||||
@ -144,6 +147,11 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
|
||||
return $this->redirect2listView('sweet-error', $message);
|
||||
endif;
|
||||
|
||||
// Se obtiene el cliente ID a partir del usuario de la sesion
|
||||
$model_user = model('App\Models\Usuarios\UserModel');
|
||||
$user = $model_user->find(auth()->user()->id);
|
||||
$clienteId = $user->cliente_id;
|
||||
|
||||
$datosPresupuesto = (object)array();
|
||||
$datosPresupuesto->POD = model('App\Models\Configuracion\ConfiguracionSistemaModel')->getPOD();
|
||||
$datosPresupuesto->paisList = model('App\Models\Configuracion\PaisModel')->getAllForMenu('id, nombre', 'nombre', true);
|
||||
@ -162,7 +170,7 @@ 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 =
|
||||
$this->getTipoInterior($presupuestoEntity->id ?? null);
|
||||
$datosPresupuesto->tapa = $this->getTapa($presupuestoEntity->tipo_impresion_id ?? null);
|
||||
|
||||
@ -184,6 +192,7 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
|
||||
|
||||
$this->viewData['presupuestoEntity'] = $presupuestoEntity;
|
||||
$this->viewData['datosPresupuesto'] = $datosPresupuesto;
|
||||
$this->viewData['clienteId'] = $clienteId;
|
||||
|
||||
// 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
|
||||
@ -280,7 +289,7 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
|
||||
if ($this->request->isAJAX()) {
|
||||
$reqData = $this->request->getPost();
|
||||
|
||||
$clienteId = $reqData['clienteId'] ?? 0;
|
||||
$clienteId = $reqData['cliente'] ?? 0;
|
||||
|
||||
if (!isset($reqData['draw']) || !isset($reqData['columns'])) {
|
||||
$errstr = 'No data available in response to this specific request.';
|
||||
@ -684,6 +693,14 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
|
||||
$unidades_calculo,
|
||||
$direccion['tipo'] == 'cajas' ? 0 : 1
|
||||
);
|
||||
|
||||
if (count($coste_envio) > 0) {
|
||||
$coste = floatval($coste_envio[0]->coste);
|
||||
$margen = ($coste * floatval($coste_envio[0]->margen)) / 100.0;
|
||||
$coste -= $margen;
|
||||
$resultado_presupuesto['info']['totales'][$i]['coste_envio'] += $coste;
|
||||
$resultado_presupuesto['info']['totales'][$i]['margen_envio'] += $margen;
|
||||
}
|
||||
}
|
||||
catch(Exception $e){
|
||||
return $this->respond([
|
||||
@ -692,14 +709,6 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
|
||||
$csrfTokenName => $newTokenHash
|
||||
]);
|
||||
}
|
||||
|
||||
if (count($coste_envio) > 0) {
|
||||
$coste = floatval($coste_envio[0]->coste);
|
||||
$margen = ($coste * floatval($coste_envio[0]->margen)) / 100.0;
|
||||
$coste -= $margen;
|
||||
$resultado_presupuesto['info']['totales'][$i]['coste_envio'] += $coste;
|
||||
$resultado_presupuesto['info']['totales'][$i]['margen_envio'] += $margen;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -773,10 +782,14 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
|
||||
if ($servicio->tarifa_id == 3 || $servicio->tarifa_id == 5 || $servicio->tarifa_id == 16) {
|
||||
// Servicios acabado
|
||||
$this->guardarServicio($id, $servicio, 'acabado');
|
||||
} else if ($servicio->tarifa_id == 24 || $servicio->tarifa_id == 9) {
|
||||
} else if ($servicio->tarifa_id == 24 ) {
|
||||
// Servicios preimpresion
|
||||
$this->guardarServicio($id, $servicio, 'preimpresion');
|
||||
} else if ($servicio->tarifa_id == 9) {
|
||||
// Servicios extra
|
||||
$this->guardarServicio($id, $servicio, 'extra');
|
||||
} else if ($servicio->tarifa_id == 62) {
|
||||
}
|
||||
else if ($servicio->tarifa_id == 62) {
|
||||
// Servicios manipulado
|
||||
$this->guardarServicio($id, $servicio, 'manipulado');
|
||||
}
|
||||
@ -1466,7 +1479,22 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
|
||||
$totalServicios += floatval($resultado[0]->total);
|
||||
$margenServicios += floatval($resultado[0]->total) * floatval($resultado[0]->margen) / 100.0;
|
||||
}
|
||||
} else if (intval($servicio) == 24 || intval($servicio) == 9) {
|
||||
} else if (intval($servicio) == 24) {
|
||||
// Servicios preimpresion (Ferro)
|
||||
$resultado = PresupuestoCLienteService::getServiciosPreimpresion([
|
||||
'tarifa_id' => $servicio,
|
||||
]);
|
||||
array_push($serviciosAutomaticos, $resultado[0]);
|
||||
if ($resultado[0]->precio <= 0)
|
||||
$error->servicios = lang('Presupuestos.errores.errorPresupuesto');
|
||||
|
||||
$coste_servicios += floatval($resultado[0]->precio);
|
||||
if ($extra_info) {
|
||||
$totalServicios += floatval($resultado[0]->precio);
|
||||
$margenServicios += floatval($resultado[0]->precio) * floatval($resultado[0]->margen) / 100.0;
|
||||
}
|
||||
}
|
||||
if(intval($servicio) == 9) {
|
||||
// Servicios preimpresion
|
||||
$resultado = PresupuestoCLienteService::getServiciosExtra([
|
||||
'tarifa_id' => $servicio,
|
||||
@ -1743,7 +1771,17 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
|
||||
$color = 'color';
|
||||
}
|
||||
}
|
||||
return [$color, $calidad];
|
||||
|
||||
$tipo = "negro";
|
||||
|
||||
if($calidad == 'premium' && $color=='negro')
|
||||
$tipo = "negroHq";
|
||||
else if ($calidad == 'estandar' && $color=='color')
|
||||
$tipo = "color";
|
||||
else if ($calidad == 'premium' && $color=='color')
|
||||
$tipo = "colorHq";
|
||||
|
||||
return $tipo;
|
||||
}
|
||||
|
||||
protected function getTapa($tipo_impresion_id)
|
||||
|
||||
@ -59,6 +59,7 @@ return [
|
||||
'numeroEdicion' => 'Número de edición',
|
||||
'isbn' => 'ISBN',
|
||||
'referenciaCliente' => 'Referencia del cliente',
|
||||
'referenciaCliente2' => 'Referencia',
|
||||
'papelFormatoId' => "Tamaño",
|
||||
'papelFormatoPersonalizado' => 'Tamaño personalizado',
|
||||
'papelFormatoAncho' => 'Ancho',
|
||||
|
||||
@ -34,7 +34,6 @@ class PresupuestoModel extends \App\Models\BaseModel
|
||||
0 => "t1.id",
|
||||
1 => "t1.updated_at",
|
||||
2 => "t7.codigo",
|
||||
3 => "t2.nombre",
|
||||
4 => "t1.titulo",
|
||||
5 => "t1.paginas",
|
||||
6 => "t1.tirada",
|
||||
|
||||
@ -63,7 +63,7 @@ class PresupuestoServiciosExtraModel extends \App\Models\BaseModel
|
||||
else{
|
||||
$ret_array[] = (object)[
|
||||
'tarifa_id'=> $tarifa_extra_id,
|
||||
'tarifa_nombre'=> $modelTarifa->getNombreTarifaPreimpresion($tarifa_extra_id)[0]->nombre,
|
||||
'tarifa_nombre'=> $modelTarifa->getNombreTarifaExtra($tarifa_extra_id)[0]->nombre,
|
||||
'precio' => 0,
|
||||
'margen' => 0,
|
||||
];
|
||||
|
||||
@ -3,7 +3,7 @@ namespace App\Models\Usuarios;
|
||||
|
||||
class UserModel extends \App\Models\BaseModel
|
||||
{
|
||||
protected $table = "auth_user";
|
||||
protected $table = "users";
|
||||
|
||||
/**
|
||||
* Whether primary key uses auto increment.
|
||||
@ -16,29 +16,21 @@ class UserModel extends \App\Models\BaseModel
|
||||
protected $createdField = 'created_at';
|
||||
protected $updatedField = 'updated_at';
|
||||
|
||||
protected $primaryKey = "id_user";
|
||||
protected $primaryKey = "id";
|
||||
|
||||
protected $allowedFields = [
|
||||
"group",
|
||||
"username",
|
||||
"first_name",
|
||||
"last_name",
|
||||
"date_birth",
|
||||
"address",
|
||||
"city",
|
||||
"state",
|
||||
"country",
|
||||
"zip_code",
|
||||
"mobile",
|
||||
"email",
|
||||
"password",
|
||||
"last_ip",
|
||||
"last_access",
|
||||
"picture",
|
||||
"language",
|
||||
"blocked",
|
||||
"email_confirmed",
|
||||
"client_id",
|
||||
"status",
|
||||
"token",
|
||||
"status_message",
|
||||
"active",
|
||||
"country",
|
||||
"last_active",
|
||||
"created_at",
|
||||
"updated_at",
|
||||
"deleted_at",
|
||||
];
|
||||
protected $returnType = "App\Entities\Usuarios\UserEntity";
|
||||
|
||||
|
||||
@ -16,7 +16,7 @@
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-sm-6 mb-3">
|
||||
<div class="col-sm-6 mb-3" <?= $clienteId != 0 ?' style="display:none;"':''?>>
|
||||
<label for="clienteId" class="form-label">
|
||||
<?= lang('Presupuestos.clienteId') ?>*
|
||||
</label>
|
||||
@ -24,7 +24,7 @@
|
||||
|
||||
<?php if (isset($datosPresupuesto->clienteList) && is_array($datosPresupuesto->clienteList) && !empty($datosPresupuesto->clienteList)) :
|
||||
foreach ($datosPresupuesto->clienteList as $k => $v) : ?>
|
||||
<option value="<?= $k ?>" <?= $k == $presupuestoEntity->cliente_id ? ' selected' : '' ?>>
|
||||
<option value="<?= $k ?>" <?= $k == $clienteId ? ' selected' : '' ?>>
|
||||
<?= $v ?>
|
||||
</option>
|
||||
<?php endforeach;
|
||||
@ -35,7 +35,11 @@
|
||||
|
||||
<div class="col-sm-6 mb-3">
|
||||
<label for="referenciaCliente" class="form-label">
|
||||
<?= lang('Presupuestos.referenciaCliente') ?>
|
||||
<?php if($clienteId == 0): ?>
|
||||
<?= lang('Presupuestos.referenciaCliente') ?>
|
||||
<?php else: ?>
|
||||
<?= lang('Presupuestos.referenciaCliente2') ?>
|
||||
<?php endif; ?>
|
||||
</label>
|
||||
<input type="text" id="referenciaCliente" name="referencia_cliente" maxLength="100" class="form-control" value="<?= old('referencia_cliente', $presupuestoEntity->referencia_cliente) ?>">
|
||||
</div>
|
||||
@ -82,33 +86,35 @@
|
||||
<div>No puede mezclar tiradas mayores de 30 unidades con tiradas menores de 30 unidades</div>
|
||||
</div>
|
||||
|
||||
<div class="col-sm-3 mb-3">
|
||||
<label for="tirada" class="form-label">
|
||||
<?= lang('Presupuestos.tirada') ?> 1
|
||||
</label>
|
||||
<input type="number" class="calcular-presupuesto" id="tirada" name="tirada" maxLength="8" step="1" class="form-control" value="<?= old(0, $presupuestoEntity->tirada) ?>">
|
||||
</div><!--//.mb-3 -->
|
||||
<div class="row">
|
||||
<div class="col-sm-3 mb-3">
|
||||
<label for="tirada" class="form-label">
|
||||
<?= lang('Presupuestos.tirada') ?> 1
|
||||
</label>
|
||||
<input type="number" class="calcular-presupuesto" id="tirada" name="tirada" maxLength="8" step="1" class="form-control" value="<?= old(0, $presupuestoEntity->tirada) ?>">
|
||||
</div><!--//.mb-3 -->
|
||||
|
||||
<div class="col-sm-3 mb-3">
|
||||
<label for="tirada2" class="form-label">
|
||||
<?= lang('Presupuestos.tirada') ?> 2
|
||||
</label>
|
||||
<input type="number" class="calcular-presupuesto" id="tirada2" name="tirada2" maxLength="8" step="1" class="form-control" value="<?= old(0, $presupuestoEntity->tirada2) ?>">
|
||||
</div><!--//.mb-3 -->
|
||||
<div class="col-sm-3 mb-3">
|
||||
<label for="tirada2" class="form-label">
|
||||
<?= lang('Presupuestos.tirada') ?> 2
|
||||
</label>
|
||||
<input type="number" class="calcular-presupuesto" id="tirada2" name="tirada2" maxLength="8" step="1" class="form-control" value="<?= old(0, $presupuestoEntity->tirada2) ?>">
|
||||
</div><!--//.mb-3 -->
|
||||
|
||||
<div class="col-sm-3 mb-3">
|
||||
<label for="tirada3" class="form-label">
|
||||
<?= lang('Presupuestos.tirada') ?> 3
|
||||
</label>
|
||||
<input type="number" class="calcular-presupuesto" id="tirada3" name="tirada3" maxLength="8" step="1" class="form-control" value="<?= old(0, $presupuestoEntity->tirada3) ?>">
|
||||
</div><!--//.mb-3 -->
|
||||
<div class="col-sm-3 mb-3">
|
||||
<label for="tirada3" class="form-label">
|
||||
<?= lang('Presupuestos.tirada') ?> 3
|
||||
</label>
|
||||
<input type="number" class="calcular-presupuesto" id="tirada3" name="tirada3" maxLength="8" step="1" class="form-control" value="<?= old(0, $presupuestoEntity->tirada3) ?>">
|
||||
</div><!--//.mb-3 -->
|
||||
|
||||
<div class="col-sm-3 mb-3">
|
||||
<label for="tirada4" class="form-label">
|
||||
<?= lang('Presupuestos.tirada') ?> 4
|
||||
</label>
|
||||
<input type="number" class="calcular-presupuesto" id="tirada4" name="tirada4" maxLength="8" step="1" class="form-control" value="<?= old(0, $presupuestoEntity->tirada4) ?>">
|
||||
</div><!--//.mb-3 -->
|
||||
<div class="col-sm-3 mb-3">
|
||||
<label for="tirada4" class="form-label">
|
||||
<?= lang('Presupuestos.tirada') ?> 4
|
||||
</label>
|
||||
<input type="number" class="calcular-presupuesto" id="tirada4" name="tirada4" maxLength="8" step="1" class="form-control" value="<?= old(0, $presupuestoEntity->tirada4) ?>">
|
||||
</div><!--//.mb-3 -->
|
||||
</div> <!--//.row -->
|
||||
|
||||
</div> <!--//.row -->
|
||||
|
||||
@ -177,33 +183,64 @@
|
||||
</div>
|
||||
|
||||
<h6> Color del interior </h6>
|
||||
<div class="row">
|
||||
|
||||
<div class="col col-sm-2 d-flex justify-content-center">
|
||||
<div id="colorNegroDiv" class="form-check change-tipo-impresion custom-option-color custom-option custom-option-image custom-option-image-radio">
|
||||
<label class="form-check-label custom-option-content" for="colorNegro">
|
||||
<span class="custom-option-body">
|
||||
<img style="height:120px;width:120px" src="<?= site_url("assets/img/grises.png") ?>" alt="">
|
||||
</span>
|
||||
</label>
|
||||
<input name="colorNegro" class="form-check-input calcular-presupuesto" type="radio" value="colorNegro" id="colorNegro"
|
||||
<?php echo ($datosPresupuesto->color_impresion == 'negro' ? ' checked=""': ''); ?> >
|
||||
<div class="row-color">
|
||||
|
||||
<div class="row mb-2 col-sm-6">
|
||||
|
||||
<div class="container col col-sm-3 d-flex justify-content-center">
|
||||
<div id="colorNegroDiv" class="form-check change-tipo-impresion custom-option-color custom-option custom-option-image custom-option-image-radio">
|
||||
<label class="form-check-label custom-option-content" for="colorNegro">
|
||||
<span class="custom-option-body">
|
||||
<img style="height:150px;width:240px" src="<?= site_url("assets/img/bn.png") ?>" alt="">
|
||||
</span>
|
||||
</label>
|
||||
<input name="colorNegro" class="form-check-input calcular-presupuesto" type="radio" value="colorNegro" id="colorNegro"
|
||||
<?php echo ($datosPresupuesto->color_impresion == 'negro' ? ' checked=""': ''); ?> >
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="col col-sm-2 d-flex justify-content-center">
|
||||
<div id="colorColorDiv" class="form-check change-tipo-impresion custom-option-color custom-option custom-option-image custom-option-image-radio">
|
||||
<label class="form-check-label custom-option-content" for="colorColor">
|
||||
<span class="custom-option-body">
|
||||
<img style="height:120px;width:120px" src="<?= site_url("assets/img//gamacolor.png") ?>" alt="">
|
||||
</span>
|
||||
</label>
|
||||
<input name="colorColor" class="form-check-input calcular-presupuesto" type="radio" value="colorColor" id="colorColor"
|
||||
<?php echo ($datosPresupuesto->color_impresion == 'color' ? ' checked=""': ''); ?> >
|
||||
<div class="container col col-sm-3 d-flex justify-content-center">
|
||||
<div id="colorNegroHqDiv" class="form-check change-tipo-impresion custom-option-color custom-option custom-option-image custom-option-image-radio">
|
||||
<label class="form-check-label custom-option-content" for="colorNegroHq">
|
||||
<span class="custom-option-body">
|
||||
<img style="height:150px;width:240px" src="<?= site_url("assets/img//bn_hq.png") ?>" alt="">
|
||||
</span>
|
||||
</label>
|
||||
<input name="colorNegroHq" class="form-check-input calcular-presupuesto" type="radio" value="colorNegroHq" id="colorNegroHq"
|
||||
<?php echo ($datosPresupuesto->color_impresion == 'negroHq' ? ' checked=""': ''); ?> >
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div> <!--//.row -->
|
||||
</div> <!--//.row -->
|
||||
<div class="row col-sm-6">
|
||||
|
||||
<div class="container col col-sm-3 d-flex justify-content-center">
|
||||
<div id="colorColorDiv" class="form-check change-tipo-impresion custom-option-color custom-option custom-option-image custom-option-image-radio">
|
||||
<label class="form-check-label custom-option-content" for="colorColor">
|
||||
<span class="custom-option-body">
|
||||
<img style="height:150px;width:240px" src="<?= site_url("assets/img/color.png") ?>" alt="">
|
||||
</span>
|
||||
</label>
|
||||
<input name="colorColor" class="form-check-input calcular-presupuesto" type="radio" value="colorColor" id="colorColor"
|
||||
<?php echo ($datosPresupuesto->color_impresion == 'color' ? ' checked=""': ''); ?> >
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="container col col-sm-3 d-flex justify-content-center">
|
||||
<div id="colorColorHqDiv" class="form-check change-tipo-impresion custom-option-color custom-option custom-option-image custom-option-image-radio">
|
||||
<label class="form-check-label custom-option-content" for="colorColorHq">
|
||||
<span class="custom-option-body">
|
||||
<img style="height:150px;width:240px" src="<?= site_url("assets/img//color_hq.png") ?>" alt="">
|
||||
</span>
|
||||
</label>
|
||||
<input name="colorColorHq" class="form-check-input calcular-presupuesto" type="radio" value="colorColorHq" id="colorColorHq"
|
||||
<?php echo ($datosPresupuesto->color_impresion == 'colorHq' ? ' checked=""': ''); ?> >
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div> <!--//.row -->
|
||||
</div> <!--//.row-color -->
|
||||
|
||||
<div id="pagColorDiv" class="row">
|
||||
<div class="col-sm-3 mb-3">
|
||||
@ -214,36 +251,6 @@
|
||||
</div><!--//.mb-3 -->
|
||||
</div>
|
||||
|
||||
<h6> Calidad </h6>
|
||||
<div class="row">
|
||||
|
||||
<div class="col-sm-3 mb-md-0 mb-2">
|
||||
<div id="calidadEstandarDiv" class="form-check change-tipo-impresion custom-option custom-option-calidad custom-option-basic
|
||||
<?php echo ($datosPresupuesto->calidad_impresion == 'estandar' ? ' checked"': '"'); ?> >
|
||||
<label class="form-check-label custom-option-content" for="calidadEstandar">
|
||||
<input name="calidadEstandar" class="form-check-input calcular-presupuesto" type="radio" value="" id="calidadEstandar"
|
||||
<?php echo ($datosPresupuesto->calidad_impresion == 'estandar' ? ' checked=""': ''); ?> >
|
||||
<span class="custom-option-header">
|
||||
<span class="h6 mb-0">Estándar</span>
|
||||
</span>
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-sm-3">
|
||||
<div id="calidadPremiumDiv" class="form-check change-tipo-impresion custom-option custom-option-calidad custom-option-basic"
|
||||
<?php echo ($datosPresupuesto->calidad_impresion == 'premium' ? ' checked"': '"'); ?> >
|
||||
<label class="form-check-label custom-option-content" for="calidadPremium">
|
||||
<input name="calidadPremium" class="form-check-input calcular-presupuesto" type="radio" value="" id="calidadPremium"
|
||||
<?php echo ($datosPresupuesto->calidad_impresion == 'premium' ? ' checked=""': ''); ?> >
|
||||
<span class="custom-option-header">
|
||||
<span class="h6 mb-0">Premium</span>
|
||||
</span>
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div> <!--//.row -->
|
||||
|
||||
<h6> Papel </h6>
|
||||
<div class="row">
|
||||
|
||||
@ -262,7 +269,7 @@
|
||||
|
||||
|
||||
<h6> Opciones extra </h6>
|
||||
<div class="row">
|
||||
<div class="row" <?= $clienteId != 0 ?' style="display:none;"':' '?>>
|
||||
<div class="col-sm-3 mb-3 d-flex align-items-end">
|
||||
<div class="form-check form-switch mb-2">
|
||||
<input class="form-check-input calcular-presupuesto" type="checkbox" id="excluirRotativa" name="excluir_rotativa" value="0" <?= $presupuestoEntity->excluir_rotativa == true ? 'checked' : ''; ?>>
|
||||
|
||||
@ -71,7 +71,7 @@ function updateColorCheck(el) {
|
||||
if (el.checked) {
|
||||
// If custom option element is radio, remove checked from the siblings (closest `.row`)
|
||||
if (el.type === 'radio') {
|
||||
const customRadioOptionList = [].slice.call(el.closest('.row').querySelectorAll('.custom-option-color'))
|
||||
const customRadioOptionList = [].slice.call(el.closest('.row-color').querySelectorAll('.custom-option-color'))
|
||||
customRadioOptionList.map(function (customRadioOptionEL) {
|
||||
customRadioOptionEL.closest('.custom-option-color').classList.remove('checked')
|
||||
})
|
||||
@ -79,11 +79,27 @@ function updateColorCheck(el) {
|
||||
el.closest('.custom-option-color').classList.add('checked')
|
||||
if (el.closest('.custom-option-color').id == 'colorNegroDiv') {
|
||||
$('#colorNegro').prop('checked', true);
|
||||
$('#colorNegroHq').prop('checked', false);
|
||||
$('#colorColor').prop('checked', false);
|
||||
$('#colorColorHq').prop('checked', false);
|
||||
}
|
||||
else if (el.closest('.custom-option-color').id == 'colorNegroHqDiv') {
|
||||
$('#colorNegro').prop('checked', false);
|
||||
$('#colorNegroHq').prop('checked', true);
|
||||
$('#colorColor').prop('checked', false);
|
||||
$('#colorColorHq').prop('checked', false);
|
||||
}
|
||||
else if (el.closest('.custom-option-color').id == 'colorColorDiv') {
|
||||
$('#colorNegro').prop('checked', false);
|
||||
$('#colorNegroHq').prop('checked', false);
|
||||
$('#colorColor').prop('checked', true);
|
||||
$('#colorColorHq').prop('checked', false);
|
||||
}
|
||||
else {
|
||||
$('#colorNegro').prop('checked', false);
|
||||
$('#colorColor').prop('checked', true);
|
||||
$('#colorNegroHq').prop('checked', false);
|
||||
$('#colorColor').prop('checked', false);
|
||||
$('#colorColorHq').prop('checked', true);
|
||||
}
|
||||
|
||||
} else {
|
||||
@ -92,44 +108,6 @@ function updateColorCheck(el) {
|
||||
}
|
||||
|
||||
|
||||
function initCalidadCheck() {
|
||||
const _this = this
|
||||
|
||||
const calidadOptionList = [].slice.call(document.querySelectorAll('.custom-option-calidad .form-check-input'))
|
||||
calidadOptionList.map(function (customOptionEL) {
|
||||
// Update custom options check on page load
|
||||
_this.updateCalidadCheck(customOptionEL)
|
||||
|
||||
// Update custom options check on click
|
||||
customOptionEL.addEventListener('click', e => {
|
||||
_this.updateCalidadCheck(customOptionEL)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
function updateCalidadCheck(el) {
|
||||
if (el.checked) {
|
||||
// If custom option element is radio, remove checked from the siblings (closest `.row`)
|
||||
if (el.type === 'radio') {
|
||||
const customRadioOptionList = [].slice.call(el.closest('.row').querySelectorAll('.custom-option-calidad'))
|
||||
customRadioOptionList.map(function (customRadioOptionEL) {
|
||||
customRadioOptionEL.closest('.custom-option-calidad').classList.remove('checked')
|
||||
})
|
||||
}
|
||||
el.closest('.custom-option-calidad').classList.add('checked')
|
||||
if (el.closest('.custom-option-calidad').id == 'calidadEstandarDiv') {
|
||||
$('#calidadEstandar').prop('checked', true);
|
||||
$('#calidadPremium').prop('checked', false);
|
||||
}
|
||||
else {
|
||||
$('#calidadEstandar').prop('checked', false);
|
||||
$('#calidadPremium').prop('checked', true);
|
||||
}
|
||||
} else {
|
||||
el.closest('.custom-option-calidad').classList.remove('checked')
|
||||
}
|
||||
}
|
||||
|
||||
$('#enableSobrecubierta').on('change', function () {
|
||||
if ($(this).is(":checked")) {
|
||||
$('.enable-sobrecubierta').show();
|
||||
@ -147,7 +125,6 @@ $('#enableSobrecubierta').on('change', function () {
|
||||
function initDisenioLibro() {
|
||||
initTapaCheck();
|
||||
initColorCheck();
|
||||
initCalidadCheck();
|
||||
|
||||
$('.elementos-libro').trigger('change');
|
||||
$('.change-tipo-impresion').trigger('change');
|
||||
@ -180,8 +157,12 @@ function initDisenioLibro() {
|
||||
|
||||
$('.change-tipo-impresion').on('change', function () {
|
||||
|
||||
isColor = $('#colorNegroDiv').hasClass('checked') ? false : true;
|
||||
isHq = $('#calidadEstandarDiv').hasClass('checked') ? false : true;
|
||||
let isColor = false;
|
||||
if($('#colorColorDiv').hasClass('checked') || $('#colorColorHqDiv').hasClass('checked'))
|
||||
isColor = true;
|
||||
let isHq = false;
|
||||
if($('#colorNegroDiv').hasClass('checked') || $('#colorColorHqDiv').hasClass('checked'))
|
||||
isHq = true;
|
||||
|
||||
//si es color hay que mostrar el numero de paginas a color
|
||||
if (isColor) {
|
||||
@ -238,8 +219,13 @@ $('#tirada').on('change', function () {
|
||||
|
||||
|
||||
$('#papelInterior').on('change', function () {
|
||||
isColor = $('#colorNegroDiv').hasClass('checked') ? false : true;
|
||||
isHq = $('#calidadEstandarDiv').hasClass('checked') ? false : true;
|
||||
|
||||
let isColor = false;
|
||||
if($('#colorColorDiv').hasClass('checked') || $('#colorColorHqDiv').hasClass('checked'))
|
||||
isColor = true;
|
||||
let isHq = false;
|
||||
if($('#colorNegroDiv').hasClass('checked') || $('#colorColorHqDiv').hasClass('checked'))
|
||||
isHq = true;
|
||||
|
||||
if ($('#papelInterior option:selected').val() != undefined) {
|
||||
var uso = 'bn';
|
||||
@ -293,8 +279,8 @@ $('#papelInterior').on('change', function () {
|
||||
|
||||
|
||||
$('#papelCubierta').on('change', function () {
|
||||
isColor = true;
|
||||
isHq = true;
|
||||
let isColor = true;
|
||||
let isHq = true;
|
||||
|
||||
if ($('#papelCubierta option:selected').val() != undefined) {
|
||||
var uso = 'cubierta';
|
||||
@ -331,8 +317,8 @@ $('#papelCubierta').on('change', function () {
|
||||
|
||||
|
||||
$('#papelSobrecubierta').on('change', function () {
|
||||
isColor = true;
|
||||
isHq = true;
|
||||
let isColor = true;
|
||||
let isHq = true;
|
||||
|
||||
if ($('#papelSobrecubierta option:selected').val() != undefined) {
|
||||
var uso = 'sobrecubierta';
|
||||
@ -616,6 +602,13 @@ $('#clienteId').on('select2:change', function () {
|
||||
|
||||
async function calcularPresupuesto() {
|
||||
|
||||
let isColor = false;
|
||||
if($('#colorColorDiv').hasClass('checked') || $('#colorColorHqDiv').hasClass('checked'))
|
||||
isColor = true;
|
||||
let isHq = false;
|
||||
if($('#colorNegroDiv').hasClass('checked') || $('#colorColorHqDiv').hasClass('checked'))
|
||||
isHq = true;
|
||||
|
||||
if(!comprobarTiradasPOD()){
|
||||
$('#errorTiradas').show();
|
||||
return;
|
||||
@ -639,8 +632,8 @@ async function calcularPresupuesto() {
|
||||
paginasColor: $('#paginasColor').val(),
|
||||
tipo: $('.custom-option-tipo.checked').attr('id').replace('Div', ''),
|
||||
tapa: $('#tapaDura').is(':checked') ? 'dura' : 'blanda',
|
||||
isColor: $('#colorNegroDiv').hasClass('checked') ? 0 : 1,
|
||||
isHq: $('#calidadEstandarDiv').hasClass('checked') ? 0 : 1,
|
||||
isColor: isColor ? 1 : 0,
|
||||
isHq: isHq ? 1 : 0,
|
||||
papelInterior: $('#papelInterior option:selected').val(),
|
||||
papelInteriorNombre: $('#papelInterior option:selected').text().trim(),
|
||||
gramajeInterior: $('#gramajeInterior option:selected').text(),
|
||||
|
||||
@ -19,9 +19,11 @@ function generarResumen(){
|
||||
$('#resumenFerro').text('Ferro: ' + (($('#ferro').is(':checked'))?'Sí':'No'));
|
||||
|
||||
$('#tipoImpresion').text('Impresión: ' +
|
||||
($('#colorNegroDiv').hasClass('checked')?'Negro ':'Color ') +
|
||||
($('#calidadEstandarDiv').hasClass('checked')?'Estándar': 'Premium'));
|
||||
if($('#colorNegroDiv').hasClass('checked')){
|
||||
($('#colorNegroDiv').hasClass('checked')?'Negro estándar':
|
||||
$('#colorNegroHqDiv').hasClass('checked')?'Negro premium':
|
||||
$('#colorColorDiv').hasClass('checked')?'Color estándar':'Color premium'));
|
||||
|
||||
if($('#colorNegroDiv').hasClass('checked') || $('#colorNegroHqDiv').hasClass('checked')){
|
||||
$('#pResumenPaginasColor').hide();
|
||||
}
|
||||
else{
|
||||
@ -176,6 +178,13 @@ $('#btnBack').on('click', function() {
|
||||
});
|
||||
|
||||
function finalizarPresupuesto(confirmar){
|
||||
|
||||
let isColor = false;
|
||||
if($('#colorColorDiv').hasClass('checked') || $('#colorColorHqDiv').hasClass('checked'))
|
||||
isColor = true;
|
||||
let isHq = false;
|
||||
if($('#colorNegroDiv').hasClass('checked') || $('#colorColorHqDiv').hasClass('checked'))
|
||||
isHq = true;
|
||||
|
||||
const paths = window.location.pathname.split("/").filter(path => path !== "");
|
||||
let id=0;
|
||||
@ -195,8 +204,8 @@ function finalizarPresupuesto(confirmar){
|
||||
paginasColor: $('#paginasColor').val(),
|
||||
tipo: $('.custom-option-tipo.checked').attr('id').replace('Div', ''),
|
||||
tapa: $('#tapaDura').is(':checked') ? 'dura' : 'blanda',
|
||||
isColor: $('#colorNegroDiv').hasClass('checked') ? 0 : 1,
|
||||
isHq: $('#calidadEstandarDiv').hasClass('checked') ? 0 : 1,
|
||||
isColor: isColor,
|
||||
isHq: isHq,
|
||||
papelInterior: $('#papelInterior option:selected').val(),
|
||||
papelInteriorNombre: $('#papelInterior option:selected').text().trim(),
|
||||
gramajeInterior: $('#gramajeInterior option:selected').text(),
|
||||
@ -279,13 +288,12 @@ function finalizarPresupuesto(confirmar){
|
||||
data: datos,
|
||||
success: function(response) {
|
||||
|
||||
if(confirmar){
|
||||
if(Object.keys(response).length > 0) {
|
||||
if(response.status > 0){
|
||||
window.location.href = response.url + '/' + response.status;
|
||||
}
|
||||
|
||||
if(Object.keys(response).length > 0) {
|
||||
if(response.status > 0){
|
||||
if(confirmar || window.location.href.includes("add"))
|
||||
window.location.href = response.url + '/' + response.status;
|
||||
}
|
||||
|
||||
}
|
||||
$('#loader').hide();
|
||||
|
||||
|
||||
@ -50,13 +50,21 @@
|
||||
|
||||
const lastColNr = $('#tableOfPresupuestos').find("tr:first th").length - 1;
|
||||
const actionBtns = function(data) {
|
||||
return `
|
||||
<td class="text-right py-0 align-middle">
|
||||
<div class="btn-group btn-group-sm">
|
||||
<a href="javascript:void(0);"><i class="ti ti-pencil ti-sm btn-edit mx-2" data-id="${data.id}"></i></a>
|
||||
<a href="javascript:void(0);"><i class="ti ti-trash ti-sm btn-delete mx-2" data-id="${data.id}" data-bs-toggle="modal" data-bs-target="#confirm2delete"></i></a>
|
||||
</div>
|
||||
</td>`;
|
||||
if(data.estado == 'borrador')
|
||||
return `
|
||||
<td class="text-right py-0 align-middle">
|
||||
<div class="btn-group btn-group-sm">
|
||||
<a href="javascript:void(0);"><i class="ti ti-pencil ti-sm btn-edit mx-2" data-id="${data.id}"></i></a>
|
||||
<a href="javascript:void(0);"><i class="ti ti-trash ti-sm btn-delete mx-2" data-id="${data.id}" data-bs-toggle="modal" data-bs-target="#confirm2delete"></i></a>
|
||||
</div>
|
||||
</td>`;
|
||||
else
|
||||
return `
|
||||
<td class="text-right py-0 align-middle">
|
||||
<div class="btn-group btn-group-sm">
|
||||
<a href="javascript:void(0);"><i class="ti ti-pencil ti-sm btn-edit mx-2" data-id="${data.id}"></i></a>
|
||||
</div>
|
||||
</td>`;
|
||||
};
|
||||
|
||||
// Setup - add a text input to each footer cell
|
||||
@ -212,12 +220,6 @@ theTable = $('#tableOfPresupuestos').DataTable({
|
||||
searchable: false,
|
||||
targets: [lastColNr]
|
||||
},
|
||||
<?php if (auth()->user()->inGroup('cliente-admin') || auth()->user()->inGroup('cliente-editor')): ?>
|
||||
{
|
||||
target: 3,
|
||||
visible: false
|
||||
}
|
||||
<?php endif; ?>
|
||||
],
|
||||
|
||||
columns : [
|
||||
@ -270,8 +272,9 @@ theTable = $('#tableOfPresupuestos').DataTable({
|
||||
}
|
||||
},
|
||||
},
|
||||
|
||||
{ 'data': 'cliente'},
|
||||
<?php if ($clienteId == 0): ?>
|
||||
{ 'data': 'cliente'},
|
||||
<?php endif; ?>
|
||||
|
||||
{ 'data': 'titulo' },
|
||||
{ 'data': 'paginas' },
|
||||
@ -293,7 +296,11 @@ theTable = $('#tableOfPresupuestos').DataTable({
|
||||
theTable.on( 'draw.dt', function () {
|
||||
|
||||
const dateCols = [1];
|
||||
<?php if ($clienteId == 0): ?>
|
||||
const priceCols = [7];
|
||||
<?php else: ?>
|
||||
const priceCols = [6];
|
||||
<?php endif; ?>
|
||||
|
||||
for (let coln of dateCols) {
|
||||
theTable.column(coln, { page: 'current' }).nodes().each( function (cell, i) {
|
||||
|
||||
@ -51,13 +51,23 @@
|
||||
|
||||
const lastColNr = $('#tableOfPresupuestos').find("tr:first th").length - 1;
|
||||
const actionBtns = function(data) {
|
||||
return `
|
||||
<td class="text-right py-0 align-middle">
|
||||
<div class="btn-group btn-group-sm">
|
||||
<a href="javascript:void(0);"><i class="ti ti-pencil ti-sm btn-edit mx-2" data-id="${data.id}"></i></a>
|
||||
<a href="javascript:void(0);"><i class="ti ti-trash ti-sm btn-delete mx-2" data-id="${data.id}" data-bs-toggle="modal" data-bs-target="#confirm2delete"></i></a>
|
||||
</div>
|
||||
</td>`;
|
||||
if (data.estado == 'aceptado') {
|
||||
return `
|
||||
<td class="text-right py-0 align-middle">
|
||||
<div class="btn-group btn-group-sm">
|
||||
<a href="javascript:void(0);"><i class="ti ti-pencil ti-sm btn-edit mx-2" data-id="${data.id}"></i></a>
|
||||
</div>
|
||||
</td>`;
|
||||
}
|
||||
else{
|
||||
return `
|
||||
<td class="text-right py-0 align-middle">
|
||||
<div class="btn-group btn-group-sm">
|
||||
<a href="javascript:void(0);"><i class="ti ti-pencil ti-sm btn-edit mx-2" data-id="${data.id}"></i></a>
|
||||
<a href="javascript:void(0);"><i class="ti ti-trash ti-sm btn-delete mx-2" data-id="${data.id}" data-bs-toggle="modal" data-bs-target="#confirm2delete"></i></a>
|
||||
</div>
|
||||
</td>`;
|
||||
}
|
||||
};
|
||||
|
||||
// Setup - add a text input to each footer cell
|
||||
|
||||
BIN
httpdocs/assets/img/bn.png
Normal file
BIN
httpdocs/assets/img/bn.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 156 KiB |
BIN
httpdocs/assets/img/bn_hq.png
Normal file
BIN
httpdocs/assets/img/bn_hq.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 172 KiB |
BIN
httpdocs/assets/img/color.png
Normal file
BIN
httpdocs/assets/img/color.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 92 KiB |
BIN
httpdocs/assets/img/color_hq.png
Normal file
BIN
httpdocs/assets/img/color_hq.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 155 KiB |
Reference in New Issue
Block a user