mirror of
https://git.imnavajas.es/jjimenez/safekat.git
synced 2025-07-25 22:52:08 +00:00
Merge branch 'main' into 'mod/presupuesto_admin'
Main See merge request jjimenez/safekat!461
This commit is contained in:
@ -9,18 +9,18 @@ const SK_PERMISSION_MATRIX = [
|
|||||||
"plantilla-tarifa.edit",
|
"plantilla-tarifa.edit",
|
||||||
"plantilla-tarifa.delete",
|
"plantilla-tarifa.delete",
|
||||||
"plantilla-tarifa.menu",
|
"plantilla-tarifa.menu",
|
||||||
|
"perfil.create",
|
||||||
|
"perfil.edit",
|
||||||
|
"perfil.delete",
|
||||||
|
"perfil.menu",
|
||||||
"presupuesto.create",
|
"presupuesto.create",
|
||||||
"presupuesto.edit",
|
"presupuesto.edit",
|
||||||
"presupuesto.delete",
|
"presupuesto.delete",
|
||||||
"presupuesto.menu",
|
"presupuesto.menu",
|
||||||
"pedidos-activos.view",
|
"presupuesto-cliente.create",
|
||||||
"pedidos-activos.menu",
|
"presupuesto-cliente.edit",
|
||||||
"pedidos-finalizados.view",
|
"presupuesto-cliente.delete",
|
||||||
"pedidos-finalizados.menu",
|
"presupuesto-cliente.menu",
|
||||||
"pedidos-cancelados.view",
|
|
||||||
"pedidos-cancelados.menu",
|
|
||||||
"pedidos-todos.view",
|
|
||||||
"pedidos-todos.menu",
|
|
||||||
"tarifa-preimpresion.create",
|
"tarifa-preimpresion.create",
|
||||||
"tarifa-preimpresion.edit",
|
"tarifa-preimpresion.edit",
|
||||||
"tarifa-preimpresion.delete",
|
"tarifa-preimpresion.delete",
|
||||||
@ -41,6 +41,10 @@ const SK_PERMISSION_MATRIX = [
|
|||||||
"tarifa-envio.edit",
|
"tarifa-envio.edit",
|
||||||
"tarifa-envio.delete",
|
"tarifa-envio.delete",
|
||||||
"tarifa-envio.menu",
|
"tarifa-envio.menu",
|
||||||
|
"tarifa-extra.create",
|
||||||
|
"tarifa-extra.edit",
|
||||||
|
"tarifa-extra.delete",
|
||||||
|
"tarifa-extra.menu",
|
||||||
"proveedores.create",
|
"proveedores.create",
|
||||||
"proveedores.edit",
|
"proveedores.edit",
|
||||||
"proveedores.delete",
|
"proveedores.delete",
|
||||||
@ -57,6 +61,10 @@ const SK_PERMISSION_MATRIX = [
|
|||||||
"paises.edit",
|
"paises.edit",
|
||||||
"paises.delete",
|
"paises.delete",
|
||||||
"paises.menu",
|
"paises.menu",
|
||||||
|
"formas-pago.create",
|
||||||
|
"formas-pago.edit",
|
||||||
|
"formas-pago.delete",
|
||||||
|
"formas-pago.menu",
|
||||||
"maquinas.create",
|
"maquinas.create",
|
||||||
"maquinas.edit",
|
"maquinas.edit",
|
||||||
"maquinas.delete",
|
"maquinas.delete",
|
||||||
@ -81,12 +89,36 @@ const SK_PERMISSION_MATRIX = [
|
|||||||
"roles-permisos.edit",
|
"roles-permisos.edit",
|
||||||
"roles-permisos.delete",
|
"roles-permisos.delete",
|
||||||
"roles-permisos.menu",
|
"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" => [
|
"cliente-admin" => [
|
||||||
"pedidos-activos.view",
|
"perfil.edit",
|
||||||
"pedidos-activos.menu",
|
"perfil.menu",
|
||||||
|
"direcciones.create",
|
||||||
|
"direcciones.edit",
|
||||||
|
"direcciones.delete",
|
||||||
|
"direcciones.menu",
|
||||||
|
"presupuesto-cliente.create",
|
||||||
|
"presupuesto-cliente.edit",
|
||||||
|
"presupuesto-cliente.delete",
|
||||||
|
"presupuesto-cliente.menu",
|
||||||
],
|
],
|
||||||
"cliente-editor" => [
|
"cliente-editor" => [
|
||||||
|
"perfil.create",
|
||||||
|
"perfil.edit",
|
||||||
|
"perfil.delete",
|
||||||
|
"perfil.menu",
|
||||||
|
"direcciones.create",
|
||||||
|
"direcciones.edit",
|
||||||
|
"direcciones.delete",
|
||||||
|
"direcciones.menu",
|
||||||
"presupuesto-cliente.create",
|
"presupuesto-cliente.create",
|
||||||
"presupuesto-cliente.edit",
|
"presupuesto-cliente.edit",
|
||||||
"presupuesto-cliente.delete",
|
"presupuesto-cliente.delete",
|
||||||
@ -97,15 +129,8 @@ const SK_PERMISSION_MATRIX = [
|
|||||||
"token.menu",
|
"token.menu",
|
||||||
],
|
],
|
||||||
"produccion" => [
|
"produccion" => [
|
||||||
"clientes.create",
|
"token.token",
|
||||||
"clientes.edit",
|
"token.menu",
|
||||||
"clientes.menu",
|
|
||||||
"direcciones.create",
|
|
||||||
"direcciones.edit",
|
|
||||||
"direcciones.menu",
|
|
||||||
"presupuesto.create",
|
|
||||||
"presupuesto.edit",
|
|
||||||
"presupuesto.menu",
|
|
||||||
],
|
],
|
||||||
"maquina" => [
|
"maquina" => [
|
||||||
"token.token",
|
"token.token",
|
||||||
@ -138,18 +163,18 @@ const SK_PERMISSION_MATRIX = [
|
|||||||
"plantilla-tarifa.edit",
|
"plantilla-tarifa.edit",
|
||||||
"plantilla-tarifa.delete",
|
"plantilla-tarifa.delete",
|
||||||
"plantilla-tarifa.menu",
|
"plantilla-tarifa.menu",
|
||||||
|
"perfil.create",
|
||||||
|
"perfil.edit",
|
||||||
|
"perfil.delete",
|
||||||
|
"perfil.menu",
|
||||||
"presupuesto.create",
|
"presupuesto.create",
|
||||||
"presupuesto.edit",
|
"presupuesto.edit",
|
||||||
"presupuesto.delete",
|
"presupuesto.delete",
|
||||||
"presupuesto.menu",
|
"presupuesto.menu",
|
||||||
"pedidos-activos.view",
|
"presupuesto-cliente.create",
|
||||||
"pedidos-activos.menu",
|
"presupuesto-cliente.edit",
|
||||||
"pedidos-finalizados.view",
|
"presupuesto-cliente.delete",
|
||||||
"pedidos-finalizados.menu",
|
"presupuesto-cliente.menu",
|
||||||
"pedidos-cancelados.view",
|
|
||||||
"pedidos-cancelados.menu",
|
|
||||||
"pedidos-todos.view",
|
|
||||||
"pedidos-todos.menu",
|
|
||||||
"tarifa-preimpresion.create",
|
"tarifa-preimpresion.create",
|
||||||
"tarifa-preimpresion.edit",
|
"tarifa-preimpresion.edit",
|
||||||
"tarifa-preimpresion.delete",
|
"tarifa-preimpresion.delete",
|
||||||
@ -170,6 +195,10 @@ const SK_PERMISSION_MATRIX = [
|
|||||||
"tarifa-envio.edit",
|
"tarifa-envio.edit",
|
||||||
"tarifa-envio.delete",
|
"tarifa-envio.delete",
|
||||||
"tarifa-envio.menu",
|
"tarifa-envio.menu",
|
||||||
|
"tarifa-extra.create",
|
||||||
|
"tarifa-extra.edit",
|
||||||
|
"tarifa-extra.delete",
|
||||||
|
"tarifa-extra.menu",
|
||||||
"proveedores.create",
|
"proveedores.create",
|
||||||
"proveedores.edit",
|
"proveedores.edit",
|
||||||
"proveedores.delete",
|
"proveedores.delete",
|
||||||
@ -210,5 +239,13 @@ const SK_PERMISSION_MATRIX = [
|
|||||||
"roles-permisos.edit",
|
"roles-permisos.edit",
|
||||||
"roles-permisos.delete",
|
"roles-permisos.delete",
|
||||||
"roles-permisos.menu",
|
"roles-permisos.menu",
|
||||||
|
"ubicaciones.create",
|
||||||
|
"ubicaciones.edit",
|
||||||
|
"ubicaciones.delete",
|
||||||
|
"ubicaciones.menu",
|
||||||
|
"series-facturas.create",
|
||||||
|
"series-facturas.edit",
|
||||||
|
"series-facturas.delete",
|
||||||
|
"series-facturas.menu",
|
||||||
],
|
],
|
||||||
];
|
];
|
||||||
|
|||||||
@ -17,6 +17,10 @@ const SK_PERMISSIONS = [
|
|||||||
'presupuesto.edit' => 'Can edit',
|
'presupuesto.edit' => 'Can edit',
|
||||||
'presupuesto.delete' => 'Can delete',
|
'presupuesto.delete' => 'Can delete',
|
||||||
'presupuesto.menu' => 'Menu shall be visualize',
|
'presupuesto.menu' => 'Menu shall be visualize',
|
||||||
|
'presupuesto-cliente.create' => 'Can create',
|
||||||
|
'presupuesto-cliente.edit' => 'Can edit',
|
||||||
|
'presupuesto-cliente.delete' => 'Can delete',
|
||||||
|
'presupuesto-cliente.menu' => 'Menu shall be visualize',
|
||||||
'pedidos-activos.view' => 'Can view',
|
'pedidos-activos.view' => 'Can view',
|
||||||
'pedidos-activos.menu' => 'Menu shall be visualize',
|
'pedidos-activos.menu' => 'Menu shall be visualize',
|
||||||
'pedidos-finalizados.view' => 'Can view',
|
'pedidos-finalizados.view' => 'Can view',
|
||||||
|
|||||||
@ -26,12 +26,13 @@ class Test extends BaseController
|
|||||||
|
|
||||||
public function index()
|
public function index()
|
||||||
{
|
{
|
||||||
/*
|
$model = model("\App\Models\Clientes\ClientePreciosModel");
|
||||||
$model = model("\App\Models\Pedidos\PedidoLineaModel");
|
$model->debug_all_clientes_to_defecto();
|
||||||
$data = $model->obtenerLineasPedidoSinFacturar(999);
|
echo '<pre>';
|
||||||
*/
|
echo 'OK';
|
||||||
|
echo '</pre>';
|
||||||
|
|
||||||
xdebug_info();
|
//xdebug_info();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -39,7 +39,8 @@ class ClientePreciosModel extends \App\Models\BaseModel
|
|||||||
"created_at",
|
"created_at",
|
||||||
"updated_at",
|
"updated_at",
|
||||||
"user_created_id",
|
"user_created_id",
|
||||||
"user_updated_id"];
|
"user_updated_id"
|
||||||
|
];
|
||||||
|
|
||||||
protected $returnType = "App\Entities\Clientes\ClientePreciosEntity";
|
protected $returnType = "App\Entities\Clientes\ClientePreciosEntity";
|
||||||
|
|
||||||
@ -111,7 +112,8 @@ class ClientePreciosModel extends \App\Models\BaseModel
|
|||||||
],
|
],
|
||||||
];
|
];
|
||||||
|
|
||||||
function clean_plantilla_id($cliente_id = 0){
|
function clean_plantilla_id($cliente_id = 0)
|
||||||
|
{
|
||||||
$this->db
|
$this->db
|
||||||
->table($this->table . " t1")
|
->table($this->table . " t1")
|
||||||
->where('cliente_id', $cliente_id)
|
->where('cliente_id', $cliente_id)
|
||||||
@ -119,7 +121,8 @@ class ClientePreciosModel extends \App\Models\BaseModel
|
|||||||
->update();
|
->update();
|
||||||
}
|
}
|
||||||
|
|
||||||
function set_plantilla_id($cliente_id = 0, $plantilla_id = null){
|
function set_plantilla_id($cliente_id = 0, $plantilla_id = null)
|
||||||
|
{
|
||||||
$this->db
|
$this->db
|
||||||
->table($this->table . " t1")
|
->table($this->table . " t1")
|
||||||
->where('cliente_id', $cliente_id)
|
->where('cliente_id', $cliente_id)
|
||||||
@ -128,7 +131,8 @@ class ClientePreciosModel extends \App\Models\BaseModel
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function delete_values($cliente_id = 0){
|
function delete_values($cliente_id = 0)
|
||||||
|
{
|
||||||
$session = session();
|
$session = session();
|
||||||
$datetime = (new \CodeIgniter\I18n\Time("now"));
|
$datetime = (new \CodeIgniter\I18n\Time("now"));
|
||||||
$date_value = $datetime->format('Y-m-d H:i:s');
|
$date_value = $datetime->format('Y-m-d H:i:s');
|
||||||
@ -142,7 +146,63 @@ class ClientePreciosModel extends \App\Models\BaseModel
|
|||||||
->update();
|
->update();
|
||||||
}
|
}
|
||||||
|
|
||||||
function copy_from_plantilla($cliente_id = 0, $plantilla_id = 0){
|
|
||||||
|
function debug_all_clientes_to_defecto()
|
||||||
|
{
|
||||||
|
$plantilla_id = 5; // por defecto
|
||||||
|
// Se borran los valores existentes para todos los clientes en una sola consulta
|
||||||
|
|
||||||
|
$modelCliente = model('App\Models\Clientes\ClienteModel');
|
||||||
|
$clientes = $modelCliente->select('id')->where('is_deleted', 0)->findAll();
|
||||||
|
|
||||||
|
// Se borra la tabla
|
||||||
|
$this->db->table($this->table)->truncate();
|
||||||
|
|
||||||
|
|
||||||
|
// Preparar los datos para `insertBatch`
|
||||||
|
$data = [];
|
||||||
|
$date_value = date('Y-m-d H:i:s'); // Asume que $date_value es la fecha actual
|
||||||
|
$userId = auth()->user()->id; // ID del usuario actual
|
||||||
|
|
||||||
|
$plantillaModel = model('App\Models\Clientes\ClientePlantillaPreciosLineasModel');
|
||||||
|
$values = $plantillaModel->getResource([], $plantilla_id)->get()->getResultObject();
|
||||||
|
|
||||||
|
$batchSize = 1000;
|
||||||
|
$data = [];
|
||||||
|
|
||||||
|
foreach ($clientes as $index => $cliente) {
|
||||||
|
foreach ($values as $value) {
|
||||||
|
$data[] = [
|
||||||
|
'cliente_id' => $cliente->id,
|
||||||
|
'plantilla_id' => $plantilla_id,
|
||||||
|
'tipo' => $value->tipo,
|
||||||
|
'tipo_maquina' => $value->tipo_maquina,
|
||||||
|
'tipo_impresion' => $value->tipo_impresion,
|
||||||
|
'tiempo_min' => $value->tiempo_min,
|
||||||
|
'tiempo_max' => $value->tiempo_max,
|
||||||
|
'precio_hora' => $value->precio_hora,
|
||||||
|
'margen' => $value->margen,
|
||||||
|
'user_updated_id' => $value->user_updated_id,
|
||||||
|
'updated_at' => $value->updated_at,
|
||||||
|
'user_created_id' => $userId,
|
||||||
|
'created_at' => $date_value,
|
||||||
|
];
|
||||||
|
|
||||||
|
if (count($data) === $batchSize) {
|
||||||
|
$this->db->table($this->table)->insertBatch($data);
|
||||||
|
$data = [];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Insertar los datos restantes
|
||||||
|
if (!empty($data)) {
|
||||||
|
$this->db->table($this->table)->insertBatch($data);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function copy_from_plantilla($cliente_id = 0, $plantilla_id = 0)
|
||||||
|
{
|
||||||
|
|
||||||
$session = session();
|
$session = session();
|
||||||
$datetime = (new \CodeIgniter\I18n\Time("now"));
|
$datetime = (new \CodeIgniter\I18n\Time("now"));
|
||||||
@ -153,7 +213,8 @@ class ClientePreciosModel extends \App\Models\BaseModel
|
|||||||
|
|
||||||
// Se cargan los valores de la plantilla
|
// Se cargan los valores de la plantilla
|
||||||
$plantillaModel = model('App\Models\Clientes\ClientePlantillaPreciosLineasModel');
|
$plantillaModel = model('App\Models\Clientes\ClientePlantillaPreciosLineasModel');
|
||||||
$values = $plantillaModel->getResource([],$plantilla_id)->get()->getResultObject();
|
$values = $plantillaModel->getResource([], $plantilla_id)->get()->getResultObject();
|
||||||
|
|
||||||
foreach ($values as $value) {
|
foreach ($values as $value) {
|
||||||
$this->db
|
$this->db
|
||||||
->table($this->table . " t1")
|
->table($this->table . " t1")
|
||||||
@ -176,9 +237,10 @@ class ClientePreciosModel extends \App\Models\BaseModel
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function update_from_plantilla($plantilla_id = 0){
|
function update_from_plantilla($plantilla_id = 0)
|
||||||
|
{
|
||||||
|
|
||||||
$datetime = (new \CodeIgniter\I18n\Time("now"));
|
/*$datetime = (new \CodeIgniter\I18n\Time("now"));
|
||||||
$date_value = $datetime->format('Y-m-d H:i:s');
|
$date_value = $datetime->format('Y-m-d H:i:s');
|
||||||
|
|
||||||
// Se obtienen todos los id de clientes que usen esa tarifa
|
// Se obtienen todos los id de clientes que usen esa tarifa
|
||||||
@ -217,8 +279,65 @@ class ClientePreciosModel extends \App\Models\BaseModel
|
|||||||
->set('updated_at', $value->updated_at)
|
->set('updated_at', $value->updated_at)
|
||||||
->set('user_created_id', auth()->user()->id)
|
->set('user_created_id', auth()->user()->id)
|
||||||
->set('created_at', $date_value)
|
->set('created_at', $date_value)
|
||||||
->insert();
|
->insertBatch($values);
|
||||||
}
|
}
|
||||||
|
}*/
|
||||||
|
|
||||||
|
// Se borran los valores existentes para todos los clientes en una sola consulta
|
||||||
|
$clientes = $this->db
|
||||||
|
->table($this->table . " t1")
|
||||||
|
->select("t1.cliente_id AS id")
|
||||||
|
->where('t1.plantilla_id', $plantilla_id)
|
||||||
|
->where('t1.is_deleted', 0)
|
||||||
|
->distinct()
|
||||||
|
->get()->getResultArray();
|
||||||
|
// Extraer solo los IDs de los clientes
|
||||||
|
$clienteIds = array_map(fn($cliente) => $cliente['id'], $clientes);
|
||||||
|
|
||||||
|
// Borrar los valores existentes para esos clientes en una sola consulta
|
||||||
|
if (!empty($clienteIds)) {
|
||||||
|
$this->db->table($this->table)->whereIn('cliente_id', $clienteIds)->delete();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Preparar los datos para `insertBatch`
|
||||||
|
$data = [];
|
||||||
|
$date_value = date('Y-m-d H:i:s'); // Asume que $date_value es la fecha actual
|
||||||
|
$userId = auth()->user()->id; // ID del usuario actual
|
||||||
|
|
||||||
|
$plantillaModel = model('App\Models\Clientes\ClientePlantillaPreciosLineasModel');
|
||||||
|
$values = $plantillaModel->getResource([], $plantilla_id)->get()->getResultObject();
|
||||||
|
|
||||||
|
$batchSize = 1000;
|
||||||
|
$data = [];
|
||||||
|
|
||||||
|
foreach ($clientes as $cliente) {
|
||||||
|
foreach ($values as $value) {
|
||||||
|
$data[] = [
|
||||||
|
'cliente_id' => $cliente['id'],
|
||||||
|
'plantilla_id' => $plantilla_id,
|
||||||
|
'tipo' => $value->tipo,
|
||||||
|
'tipo_maquina' => $value->tipo_maquina,
|
||||||
|
'tipo_impresion' => $value->tipo_impresion,
|
||||||
|
'tiempo_min' => $value->tiempo_min,
|
||||||
|
'tiempo_max' => $value->tiempo_max,
|
||||||
|
'precio_hora' => $value->precio_hora,
|
||||||
|
'margen' => $value->margen,
|
||||||
|
'user_updated_id' => $value->user_updated_id,
|
||||||
|
'updated_at' => $value->updated_at,
|
||||||
|
'user_created_id' => $userId,
|
||||||
|
'created_at' => $date_value,
|
||||||
|
];
|
||||||
|
|
||||||
|
if (count($data) === $batchSize) {
|
||||||
|
$this->db->table($this->table)->insertBatch($data);
|
||||||
|
$data = [];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Insertar todos los datos de una vez
|
||||||
|
if (!empty($data)) {
|
||||||
|
$this->db->table($this->table)->insertBatch($data);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -227,7 +346,8 @@ class ClientePreciosModel extends \App\Models\BaseModel
|
|||||||
// - tipo_maquina: 'toner', 'inkjet'
|
// - tipo_maquina: 'toner', 'inkjet'
|
||||||
// - tipo_impresion: 'negro', 'color', 'negrohq', 'colorhq'
|
// - tipo_impresion: 'negro', 'color', 'negrohq', 'colorhq'
|
||||||
|
|
||||||
function get_precio_hora($cliente_id, $config, $tiempo){
|
function get_precio_hora($cliente_id, $config, $tiempo)
|
||||||
|
{
|
||||||
|
|
||||||
// Se cargan los valores de la plantilla
|
// Se cargan los valores de la plantilla
|
||||||
$values = $this->db
|
$values = $this->db
|
||||||
@ -242,7 +362,7 @@ class ClientePreciosModel extends \App\Models\BaseModel
|
|||||||
->where('is_deleted', 0)
|
->where('is_deleted', 0)
|
||||||
->get()->getResultObject();
|
->get()->getResultObject();
|
||||||
|
|
||||||
if(count($values)>0){
|
if (count($values) > 0) {
|
||||||
return [floatval(($values[0])->precio_hora), floatval(($values[0])->margen)];
|
return [floatval(($values[0])->precio_hora), floatval(($values[0])->margen)];
|
||||||
}
|
}
|
||||||
return [null, null];
|
return [null, null];
|
||||||
@ -287,7 +407,8 @@ class ClientePreciosModel extends \App\Models\BaseModel
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getPlantilla($cliente_id = -1){
|
public function getPlantilla($cliente_id = -1)
|
||||||
|
{
|
||||||
$builder = $this->db
|
$builder = $this->db
|
||||||
->table($this->table . " t1")
|
->table($this->table . " t1")
|
||||||
->select(
|
->select(
|
||||||
@ -300,7 +421,7 @@ class ClientePreciosModel extends \App\Models\BaseModel
|
|||||||
$builder->limit(1);
|
$builder->limit(1);
|
||||||
|
|
||||||
$values = $builder->get()->getResultArray();
|
$values = $builder->get()->getResultArray();
|
||||||
if(count($values)>0){
|
if (count($values) > 0) {
|
||||||
return $values[0];
|
return $values[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -309,11 +430,12 @@ class ClientePreciosModel extends \App\Models\BaseModel
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
public function checkIntervals($data = [], $id_linea = null, $cliente_id = null){
|
public function checkIntervals($data = [], $id_linea = null, $cliente_id = null)
|
||||||
|
{
|
||||||
|
|
||||||
helper('general');
|
helper('general');
|
||||||
|
|
||||||
if(floatval($data["tiempo_min"])>= floatval($data["tiempo_max"])){
|
if (floatval($data["tiempo_min"]) >= floatval($data["tiempo_max"])) {
|
||||||
return lang('ClientePrecios.errors.error_tiempo_range');
|
return lang('ClientePrecios.errors.error_tiempo_range');
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -329,13 +451,19 @@ class ClientePreciosModel extends \App\Models\BaseModel
|
|||||||
|
|
||||||
|
|
||||||
foreach ($rows as $row) {
|
foreach ($rows as $row) {
|
||||||
if (!is_null($id_linea)){
|
if (!is_null($id_linea)) {
|
||||||
if($row->id == $id_linea){
|
if ($row->id == $id_linea) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(check_overlap(floatval($data["tiempo_min"]), floatval($data["tiempo_max"]),
|
if (
|
||||||
$row->tiempo_min, $row->tiempo_max)){
|
check_overlap(
|
||||||
|
floatval($data["tiempo_min"]),
|
||||||
|
floatval($data["tiempo_max"]),
|
||||||
|
$row->tiempo_min,
|
||||||
|
$row->tiempo_max
|
||||||
|
)
|
||||||
|
) {
|
||||||
return lang('ClientePrecios.errors.error_tiempo_overlap');
|
return lang('ClientePrecios.errors.error_tiempo_overlap');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -343,7 +471,8 @@ class ClientePreciosModel extends \App\Models\BaseModel
|
|||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
public function get_plantilla_precios($cliente_id = -1){
|
public function get_plantilla_precios($cliente_id = -1)
|
||||||
|
{
|
||||||
$value = $this->db
|
$value = $this->db
|
||||||
->table($this->table)
|
->table($this->table)
|
||||||
->select("plantilla_id")
|
->select("plantilla_id")
|
||||||
@ -351,7 +480,7 @@ class ClientePreciosModel extends \App\Models\BaseModel
|
|||||||
->where("cliente_id", $cliente_id)
|
->where("cliente_id", $cliente_id)
|
||||||
->limit(1)->get()->getResultObject();
|
->limit(1)->get()->getResultObject();
|
||||||
|
|
||||||
if(count($value)>0){
|
if (count($value) > 0) {
|
||||||
return $value[0]->plantilla_id;
|
return $value[0]->plantilla_id;
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
|
|||||||
@ -10,9 +10,13 @@
|
|||||||
<div class="card-header">
|
<div class="card-header">
|
||||||
<h3 class="card-title"><?= $boxTitle ?? $pageTitle ?></h3>
|
<h3 class="card-title"><?= $boxTitle ?? $pageTitle ?></h3>
|
||||||
</div><!--//.card-header -->
|
</div><!--//.card-header -->
|
||||||
|
|
||||||
<form id="clientePlantillaPreciosForm" method="post" class="card-body" action="<?= $formAction ?>">
|
<form id="clientePlantillaPreciosForm" method="post" class="card-body" action="<?= $formAction ?>">
|
||||||
|
|
||||||
<?= csrf_field() ?>
|
<?= csrf_field() ?>
|
||||||
<?= view("themes/_commonPartialsBs/_alertBoxes") ?>
|
<?= view("themes/_commonPartialsBs/_alertBoxes") ?>
|
||||||
|
<?= view("themes/vuexy/form/presupuestos/cliente/loader") ?>
|
||||||
|
|
||||||
<?= !empty($validation->getErrors()) ? $validation->listErrors("bootstrap_style") : "" ?>
|
<?= !empty($validation->getErrors()) ? $validation->listErrors("bootstrap_style") : "" ?>
|
||||||
<?= view("themes/vuexy/form/clientes/plantillaprecios/_ClienteplantillapreciosFormItems") ?>
|
<?= view("themes/vuexy/form/clientes/plantillaprecios/_ClienteplantillapreciosFormItems") ?>
|
||||||
<div class="pt-4">
|
<div class="pt-4">
|
||||||
@ -84,6 +88,7 @@
|
|||||||
href="<?= site_url('themes/vuexy/css/datatables-editor/editor.dataTables.min.css') ?>">
|
href="<?= site_url('themes/vuexy/css/datatables-editor/editor.dataTables.min.css') ?>">
|
||||||
<link rel="stylesheet"
|
<link rel="stylesheet"
|
||||||
href="<?= site_url("/themes/vuexy/vendor/libs/datatables-sk/plugins/buttons/buttons.bootstrap5.min.css") ?>">
|
href="<?= site_url("/themes/vuexy/vendor/libs/datatables-sk/plugins/buttons/buttons.bootstrap5.min.css") ?>">
|
||||||
|
<link rel="stylesheet" href="<?= site_url('themes/vuexy/css/presupuestoCliente.css') ?>">
|
||||||
<?= $this->endSection() ?>
|
<?= $this->endSection() ?>
|
||||||
|
|
||||||
<?= $this->section('additionalExternalJs') ?>
|
<?= $this->section('additionalExternalJs') ?>
|
||||||
|
|||||||
@ -46,8 +46,6 @@ class ModalYesNo {
|
|||||||
$('#' + this.btnConfirmId).on('click', () => {
|
$('#' + this.btnConfirmId).on('click', () => {
|
||||||
|
|
||||||
self.callback(); // Llamar al callback que el usuario haya proporcionado
|
self.callback(); // Llamar al callback que el usuario haya proporcionado
|
||||||
$('#' + self.modalId).modal('hide');
|
|
||||||
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -242,8 +242,8 @@ class PlantillasTarifasClienteForm {
|
|||||||
|
|
||||||
const row = self.tablePlantilla.table.row('#' + json.data[0].id);
|
const row = self.tablePlantilla.table.row('#' + json.data[0].id);
|
||||||
|
|
||||||
if (row.length) {
|
if (json.data[0]) {
|
||||||
self.rowsCreated.push(row);
|
self.rowsCreated.push(json.data[0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
let rowNode = row.node();
|
let rowNode = row.node();
|
||||||
@ -263,9 +263,6 @@ class PlantillasTarifasClienteForm {
|
|||||||
|
|
||||||
let rowNode = row.node();
|
let rowNode = row.node();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Añadir una clase usando jQuery
|
// Añadir una clase usando jQuery
|
||||||
if (!$(rowNode).hasClass('row-created')) {
|
if (!$(rowNode).hasClass('row-created')) {
|
||||||
$(rowNode).addClass('row-edited');
|
$(rowNode).addClass('row-edited');
|
||||||
@ -298,8 +295,14 @@ class PlantillasTarifasClienteForm {
|
|||||||
if (index != -1) {
|
if (index != -1) {
|
||||||
self.rows[index] = data;
|
self.rows[index] = data;
|
||||||
}
|
}
|
||||||
if (self.rowsEdited.indexOf(row.id) == -1)
|
|
||||||
self.rowsEdited.push(row.id);
|
|
||||||
|
if (self.rowsEdited.some(row => row.id === data.id)) {
|
||||||
|
const index = self.rowsEdited.findIndex(row => row.id === data.id);
|
||||||
|
self.rowsEdited[index] = data;
|
||||||
|
} else {
|
||||||
|
self.rowsEdited.push(data);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -317,6 +320,12 @@ class PlantillasTarifasClienteForm {
|
|||||||
|
|
||||||
const self = this;
|
const self = this;
|
||||||
|
|
||||||
|
try {
|
||||||
|
|
||||||
|
self.modalYesNo.hide();
|
||||||
|
$('#loader').modal('show');
|
||||||
|
|
||||||
|
|
||||||
if (this.rowsEdited.length != 0) {
|
if (this.rowsEdited.length != 0) {
|
||||||
let error = self.#checkInterval(self.rowsEdited);
|
let error = self.#checkInterval(self.rowsEdited);
|
||||||
if (error) {
|
if (error) {
|
||||||
@ -331,7 +340,7 @@ class PlantillasTarifasClienteForm {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (this.rowsCreated.length != 0) {
|
if (this.rowsCreated.length != 0) {
|
||||||
let error = self.#checkInterval(self.rowsCreated.map(row => row.data()));
|
let error = self.#checkInterval(self.rowsCreated);
|
||||||
if (error) {
|
if (error) {
|
||||||
if (error == 1) {
|
if (error == 1) {
|
||||||
popErrorAlert('Hay filas CREADAS con el tiempo mínimo mayor que el tiempo máximo');
|
popErrorAlert('Hay filas CREADAS con el tiempo mínimo mayor que el tiempo máximo');
|
||||||
@ -361,13 +370,13 @@ class PlantillasTarifasClienteForm {
|
|||||||
|
|
||||||
if (this.rowsEdited.length != 0) {
|
if (this.rowsEdited.length != 0) {
|
||||||
|
|
||||||
let rowIds = this.rowsEdited.map(row => '#' + this.tablePlantilla.table.row(row).data().id);
|
let rowIds = this.rowsEdited.map(row => '#' + row.id);
|
||||||
let updatedFields = {};
|
let updatedFields = {};
|
||||||
|
|
||||||
// Iterar sobre las filas editadas y construir el objeto actualizado
|
// Iterar sobre las filas editadas y construir el objeto actualizado
|
||||||
this.rowsEdited.forEach(row2Edit => {
|
this.rowsEdited.forEach(row2Edit => {
|
||||||
|
|
||||||
const row = this.tablePlantilla.table.row(row2Edit).data();
|
const row = this.tablePlantilla.table.row('#' + row2Edit.id).data();
|
||||||
|
|
||||||
updatedFields['tipo'] = updatedFields['tipo'] || {};
|
updatedFields['tipo'] = updatedFields['tipo'] || {};
|
||||||
updatedFields['tipo'][row.id] = row.tipo;
|
updatedFields['tipo'][row.id] = row.tipo;
|
||||||
@ -464,18 +473,26 @@ class PlantillasTarifasClienteForm {
|
|||||||
|
|
||||||
self.tablePlantilla.table.clearPipeline();
|
self.tablePlantilla.table.clearPipeline();
|
||||||
self.tablePlantilla.table.draw(true);
|
self.tablePlantilla.table.draw(true);
|
||||||
|
$('#loader').modal('hide');
|
||||||
},
|
},
|
||||||
(error) => {
|
(error) => {
|
||||||
console.log(error);
|
console.log(error);
|
||||||
|
$('#loader').modal('hide');
|
||||||
}).post();
|
}).post();
|
||||||
|
|
||||||
|
|
||||||
},
|
},
|
||||||
(error) => {
|
(error) => {
|
||||||
console.log(error);
|
console.log(error);
|
||||||
|
$('#loader').modal('hide');
|
||||||
}
|
}
|
||||||
).post();
|
).post();
|
||||||
|
|
||||||
|
} catch (e) {
|
||||||
|
console.log(e);
|
||||||
|
$('#loader').modal('hide');
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user