mirror of
https://git.imnavajas.es/jjimenez/safekat.git
synced 2025-07-25 22:52:08 +00:00
terminado plantillas
This commit is contained in:
@ -445,12 +445,12 @@ class Cliente extends \App\Controllers\GoBaseResourceController
|
||||
$modelPreciosCliente = model('App\Models\Clientes\ClientePreciosModel');
|
||||
$plantilla_id = $modelPreciosCliente->get_plantilla_precios($cliente_id);
|
||||
if (is_null($plantilla_id)){
|
||||
return [];
|
||||
return null;
|
||||
}
|
||||
$modelPlantillaPreciosCliente = model('App\Models\Clientes\ClientePlantillaPreciosModel');
|
||||
$plantilla = $modelPlantillaPreciosCliente->find($plantilla_id);
|
||||
$plantilla = $modelPlantillaPreciosCliente->where("id", $plantilla_id)->where("is_deleted", 0)->first();
|
||||
if ($plantilla == false){
|
||||
return [];
|
||||
return null;
|
||||
}
|
||||
else{
|
||||
return (object)array(
|
||||
|
||||
@ -66,6 +66,32 @@ class Clienteplantillaprecios extends \App\Controllers\GoBaseResourceController
|
||||
}
|
||||
|
||||
|
||||
// Este metodo aqui se usa para poner el is_deleted a 1 cuando se borra una
|
||||
// plantilla desde la lista
|
||||
public function update($requestedId = null)
|
||||
{
|
||||
$requestMethod = $this->request->getMethod();
|
||||
|
||||
if ($requestMethod === 'post') :
|
||||
|
||||
if ($requestedId == null) :
|
||||
return;
|
||||
endif;
|
||||
$model = model('App\Models\Clientes\ClientePlantillaPreciosLineasModel');
|
||||
$model->delete_values($requestedId);
|
||||
|
||||
$newTokenHash = csrf_hash();
|
||||
$csrfTokenName = csrf_token();
|
||||
$data = [
|
||||
$csrfTokenName => $newTokenHash
|
||||
];
|
||||
|
||||
return $this->respond($data);
|
||||
|
||||
endif; // ($requestMethod === 'post')
|
||||
}
|
||||
|
||||
|
||||
public function add()
|
||||
{
|
||||
// JJO
|
||||
@ -79,6 +105,8 @@ class Clienteplantillaprecios extends \App\Controllers\GoBaseResourceController
|
||||
|
||||
$postData = $this->request->getPost();
|
||||
|
||||
$cliente_id = $postData['cliente_id'] ?? -1;
|
||||
|
||||
$sanitizedData = $this->sanitized($postData, $nullIfEmpty);
|
||||
|
||||
// JJO
|
||||
@ -108,16 +136,25 @@ class Clienteplantillaprecios extends \App\Controllers\GoBaseResourceController
|
||||
|
||||
$message = lang('Basic.global.saveSuccess', [lang('Basic.global.record')]) . '.';
|
||||
|
||||
if ($thenRedirect) :
|
||||
if (!empty($this->indexRoute)) :
|
||||
//return redirect()->to(route_to($this->indexRoute))->with('sweet-success', $message);
|
||||
return redirect()->to(site_url('/clientes/clientesplantillaprecios/edit/' . $id))->with('message', $message);
|
||||
if($cliente_id != -1){
|
||||
$modelLineas = model('App\Models\Clientes\ClientePlantillaPreciosLineasModel');
|
||||
$modelLineas->copy_from_cliente($cliente_id, $id);
|
||||
$modelClientePrecios = model('App\Models\Clientes\ClientePreciosModel');
|
||||
$modelClientePrecios->set_plantilla_id($cliente_id, $id);
|
||||
return ;
|
||||
}
|
||||
else{
|
||||
if ($thenRedirect) :
|
||||
if (!empty($this->indexRoute)) :
|
||||
//return redirect()->to(route_to($this->indexRoute))->with('sweet-success', $message);
|
||||
return redirect()->to(site_url('/clientes/clienteplantillaprecios/edit/' . $id))->with('message', $message);
|
||||
else:
|
||||
return $this->redirect2listView('sweet-success', $message);
|
||||
endif;
|
||||
else:
|
||||
return $this->redirect2listView('sweet-success', $message);
|
||||
$this->session->setFlashData('sweet-success', $message);
|
||||
endif;
|
||||
else:
|
||||
$this->session->setFlashData('sweet-success', $message);
|
||||
endif;
|
||||
}
|
||||
|
||||
endif; // $noException && $successfulResult
|
||||
|
||||
|
||||
@ -47,6 +47,39 @@ class Clienteplantillaprecioslineas extends \App\Controllers\GoBaseResourceContr
|
||||
}
|
||||
|
||||
|
||||
public function update($requestedId = null){
|
||||
|
||||
$requestMethod = $this->request->getMethod();
|
||||
|
||||
if ($requestMethod === 'post') :
|
||||
|
||||
if ($requestedId == null) :
|
||||
return;
|
||||
endif;
|
||||
|
||||
$postData = $this->request->getJSON();
|
||||
|
||||
$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{
|
||||
$this->model->copy_from_plantilla($requestedId, $plantilla_id);
|
||||
}
|
||||
|
||||
$newTokenHash = csrf_hash();
|
||||
$csrfTokenName = csrf_token();
|
||||
$data = [
|
||||
$csrfTokenName => $newTokenHash
|
||||
];
|
||||
|
||||
return $this->respond($data);
|
||||
|
||||
endif; // ($requestMethod === 'post')
|
||||
|
||||
}
|
||||
|
||||
|
||||
public function datatable()
|
||||
|
||||
@ -45,7 +45,6 @@ class ClientePrecios extends \App\Controllers\GoBaseResourceController
|
||||
parent::initController($request, $response, $logger);
|
||||
}
|
||||
|
||||
|
||||
public function update($requestedId = null)
|
||||
{
|
||||
$requestMethod = $this->request->getMethod();
|
||||
@ -80,10 +79,6 @@ class ClientePrecios extends \App\Controllers\GoBaseResourceController
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public function datatable()
|
||||
{
|
||||
if ($this->request->isAJAX()) {
|
||||
@ -136,6 +131,7 @@ class ClientePrecios extends \App\Controllers\GoBaseResourceController
|
||||
$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' ),
|
||||
@ -215,9 +211,6 @@ class ClientePrecios extends \App\Controllers\GoBaseResourceController
|
||||
->field('updated_at')
|
||||
->setValue($datetime->format('Y-m-d H:i:s'));
|
||||
})
|
||||
->on('postCreate', function ($editor,$id, $values, $row ) {
|
||||
$this->model->clean_plantilla_id($values['cliente_id']);
|
||||
})
|
||||
->debug(true)
|
||||
->process($_POST)
|
||||
->data();
|
||||
|
||||
Reference in New Issue
Block a user