mirror of
https://git.imnavajas.es/jjimenez/safekat.git
synced 2025-07-25 22:52:08 +00:00
terminadas tarifas cliente
This commit is contained in:
@ -1,4 +1,5 @@
|
||||
<?php namespace App\Controllers\Clientes;
|
||||
<?php
|
||||
namespace App\Controllers\Clientes;
|
||||
|
||||
|
||||
use App\Controllers\BaseResourceController;
|
||||
@ -45,40 +46,36 @@ class ClientePrecios extends \App\Controllers\BaseResourceController
|
||||
parent::initController($request, $response, $logger);
|
||||
}
|
||||
|
||||
public function update($requestedId = null)
|
||||
public function updatePlantilla()
|
||||
{
|
||||
|
||||
|
||||
if ($this->request->getPost()) :
|
||||
|
||||
if ($requestedId == null) :
|
||||
return;
|
||||
endif;
|
||||
if ($this->request->isAJAX()) {
|
||||
|
||||
$postData = $this->request->getJSON();
|
||||
$postData = $this->request->getPost();
|
||||
|
||||
$cliente_id = $postData['cliente_id'] ?? -1;
|
||||
$plantilla_id = $postData['plantilla_id'] ?? -1;
|
||||
|
||||
$plantilla_id = $postData->plantilla_id ?? -1;
|
||||
|
||||
// Se ha actualizado un registro por lo que no es una plantilla
|
||||
if($plantilla_id == -1){
|
||||
$this->model->clean_plantilla_id($requestedId);
|
||||
}
|
||||
else if($requestedId== -1){ // actualizar todos los clientes que usan una plantilla
|
||||
if ($plantilla_id == -1) {
|
||||
$this->model->clean_plantilla_id($cliente_id);
|
||||
} else if ($cliente_id == -1) { // actualizar todos los clientes que usan una plantilla
|
||||
$this->model->update_from_plantilla($plantilla_id);
|
||||
} else {
|
||||
$this->model->copy_from_plantilla($cliente_id, $plantilla_id);
|
||||
}
|
||||
else{
|
||||
$this->model->copy_from_plantilla($requestedId, $plantilla_id);
|
||||
}
|
||||
|
||||
|
||||
$newTokenHash = csrf_hash();
|
||||
$csrfTokenName = csrf_token();
|
||||
$data = [
|
||||
$csrfTokenName => $newTokenHash
|
||||
];
|
||||
|
||||
|
||||
return $this->respond($data);
|
||||
|
||||
endif; // ($requestMethod === 'post')
|
||||
} else {
|
||||
return $this->failUnauthorized('Invalid request', 403);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -106,11 +103,11 @@ class ClientePrecios extends \App\Controllers\BaseResourceController
|
||||
$dir = $reqData['order']['0']['dir'] ?? 'asc';
|
||||
$dir2 = $reqData['order']['1']['dir'] ?? $dir;
|
||||
$dir3 = $reqData['order']['2']['dir'] ?? $dir;
|
||||
$dir4= $reqData['order']['3']['dir'] ?? $dir;
|
||||
$dir5= $reqData['order']['4']['dir'] ?? $dir;
|
||||
$dir4 = $reqData['order']['3']['dir'] ?? $dir;
|
||||
$dir5 = $reqData['order']['4']['dir'] ?? $dir;
|
||||
|
||||
$searchValues = get_filter_datatables_columns($reqData);
|
||||
|
||||
|
||||
$cliente_id = $reqData['cliente_id'] ?? 0;
|
||||
|
||||
$resourceData = $this->model->getResource($searchValues, $cliente_id)
|
||||
@ -126,61 +123,86 @@ class ClientePrecios extends \App\Controllers\BaseResourceController
|
||||
}
|
||||
}
|
||||
|
||||
public function datatable_editor() {
|
||||
public function datatable_editor()
|
||||
{
|
||||
if ($this->request->isAJAX()) {
|
||||
|
||||
include(APPPATH . "ThirdParty/DatatablesEditor/DataTables.php");
|
||||
|
||||
|
||||
// Build our Editor instance and process the data coming from _POST
|
||||
$response = Editor::inst( $db, 'cliente_precios' )
|
||||
$response = Editor::inst($db, 'cliente_precios')
|
||||
->fields(
|
||||
Field::inst( 'plantilla_id' ),
|
||||
Field::inst( 'cliente_id' ),
|
||||
Field::inst( 'tipo' ),
|
||||
Field::inst( 'tipo_maquina' ),
|
||||
Field::inst( 'tipo_impresion' ),
|
||||
Field::inst( 'user_updated_id' ),
|
||||
Field::inst( 'updated_at' ),
|
||||
Field::inst( 'is_deleted' ),
|
||||
Field::inst( 'tiempo_min' )
|
||||
->getFormatter( 'Format::toDecimalChar')->setFormatter( 'Format::fromDecimalChar')
|
||||
->validator( 'Validate::notEmpty',array(
|
||||
'message' => lang('ClientePrecios.validation.required'))
|
||||
Field::inst('plantilla_id'),
|
||||
Field::inst('cliente_id'),
|
||||
Field::inst('tipo'),
|
||||
Field::inst('tipo_maquina'),
|
||||
Field::inst('tipo_impresion'),
|
||||
Field::inst('user_updated_id'),
|
||||
Field::inst('updated_at'),
|
||||
Field::inst('is_deleted'),
|
||||
Field::inst('tiempo_min')
|
||||
->getFormatter('Format::toDecimalChar')->setFormatter('Format::fromDecimalChar')
|
||||
->validator(
|
||||
'Validate::notEmpty',
|
||||
array(
|
||||
'message' => lang('ClientePrecios.validation.required')
|
||||
)
|
||||
)
|
||||
->validator('Validate::numeric', array(
|
||||
->validator(
|
||||
'Validate::numeric',
|
||||
array(
|
||||
"decimal" => ',',
|
||||
'message' => lang('ClientePrecios.validation.decimal'))
|
||||
'message' => lang('ClientePrecios.validation.decimal')
|
||||
)
|
||||
),
|
||||
|
||||
Field::inst( 'tiempo_max' )
|
||||
->getFormatter( 'Format::toDecimalChar')->setFormatter( 'Format::fromDecimalChar')
|
||||
->validator( 'Validate::notEmpty',array(
|
||||
'message' => lang('ClientePrecios.validation.required'))
|
||||
|
||||
Field::inst('tiempo_max')
|
||||
->getFormatter('Format::toDecimalChar')->setFormatter('Format::fromDecimalChar')
|
||||
->validator(
|
||||
'Validate::notEmpty',
|
||||
array(
|
||||
'message' => lang('ClientePrecios.validation.required')
|
||||
)
|
||||
)
|
||||
->validator('Validate::numeric', array(
|
||||
"decimal" => ',',
|
||||
'message' => lang('ClientePrecios.validation.decimal'))
|
||||
),
|
||||
|
||||
Field::inst( 'precio_hora' )
|
||||
->getFormatter( 'Format::toDecimalChar')->setFormatter( 'Format::fromDecimalChar')
|
||||
->validator( 'Validate::notEmpty',array(
|
||||
'message' => lang('ClientePrecios.validation.required'))
|
||||
)
|
||||
->validator('Validate::numeric', array(
|
||||
"decimal" => ',',
|
||||
'message' => lang('ClientePrecios.validation.decimal'))
|
||||
),
|
||||
|
||||
Field::inst( 'margen' )
|
||||
->getFormatter( 'Format::toDecimalChar')->setFormatter( 'Format::fromDecimalChar')
|
||||
->validator( 'Validate::notEmpty',array(
|
||||
'message' => lang('ClientePrecios.validation.required'))
|
||||
)
|
||||
->validator('Validate::numeric', array(
|
||||
->validator(
|
||||
'Validate::numeric',
|
||||
array(
|
||||
"decimal" => ',',
|
||||
'message' => lang('ClientePrecios.validation.decimal'))
|
||||
'message' => lang('ClientePrecios.validation.decimal')
|
||||
)
|
||||
),
|
||||
|
||||
Field::inst('precio_hora')
|
||||
->getFormatter('Format::toDecimalChar')->setFormatter('Format::fromDecimalChar')
|
||||
->validator(
|
||||
'Validate::notEmpty',
|
||||
array(
|
||||
'message' => lang('ClientePrecios.validation.required')
|
||||
)
|
||||
)
|
||||
->validator(
|
||||
'Validate::numeric',
|
||||
array(
|
||||
"decimal" => ',',
|
||||
'message' => lang('ClientePrecios.validation.decimal')
|
||||
)
|
||||
),
|
||||
|
||||
Field::inst('margen')
|
||||
->getFormatter('Format::toDecimalChar')->setFormatter('Format::fromDecimalChar')
|
||||
->validator(
|
||||
'Validate::notEmpty',
|
||||
array(
|
||||
'message' => lang('ClientePrecios.validation.required')
|
||||
)
|
||||
)
|
||||
->validator(
|
||||
'Validate::numeric',
|
||||
array(
|
||||
"decimal" => ',',
|
||||
'message' => lang('ClientePrecios.validation.decimal')
|
||||
)
|
||||
),
|
||||
|
||||
)
|
||||
@ -238,4 +260,16 @@ class ClientePrecios extends \App\Controllers\BaseResourceController
|
||||
}
|
||||
}
|
||||
|
||||
public function getCurrentPlantilla()
|
||||
{
|
||||
|
||||
if ($this->request->isAJAX()) {
|
||||
$cliente_id = $this->request->getGet('cliente_id');
|
||||
$plantilla = $this->model->getPlantilla($cliente_id);
|
||||
return $this->respond($plantilla);
|
||||
} else {
|
||||
return $this->failUnauthorized('Invalid request', 403);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user