mirror of
https://git.imnavajas.es/jjimenez/safekat.git
synced 2025-07-25 22:52:08 +00:00
feat : duplicar papel impresion con relaciones
This commit is contained in:
@ -22,6 +22,7 @@ use
|
||||
|
||||
|
||||
use App\Models\Collection;
|
||||
use CodeIgniter\Validation\Validation;
|
||||
|
||||
|
||||
|
||||
@ -35,7 +36,6 @@ use App\Models\Configuracion\PapelImpresionTipologiaModel;
|
||||
use App\Models\Configuracion\MaquinasPapelesImpresionModel;
|
||||
use App\Models\Configuracion\MaquinaModel;
|
||||
|
||||
|
||||
class Papelesimpresion extends \App\Controllers\BaseResourceController
|
||||
{
|
||||
|
||||
@ -52,6 +52,7 @@ class Papelesimpresion extends \App\Controllers\BaseResourceController
|
||||
protected static $viewPath = 'themes/vuexy/form/configuracion/papel/';
|
||||
|
||||
protected $indexRoute = 'papelImpresionList';
|
||||
protected Validation $validation;
|
||||
|
||||
public function initController(\CodeIgniter\HTTP\RequestInterface $request, \CodeIgniter\HTTP\ResponseInterface $response, \Psr\Log\LoggerInterface $logger)
|
||||
{
|
||||
@ -66,6 +67,7 @@ class Papelesimpresion extends \App\Controllers\BaseResourceController
|
||||
$this->delete_flag = 1;
|
||||
|
||||
$this->tpModel = new PapelImpresionTipologiaModel();
|
||||
$this->validation = service("validation");
|
||||
|
||||
// Breadcrumbs
|
||||
$this->viewData['breadcrumb'] = [
|
||||
@ -443,4 +445,27 @@ class Papelesimpresion extends \App\Controllers\BaseResourceController
|
||||
$ma_pa_model->updateRows($active_values);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Duplica el papel impresion y sus relaciones
|
||||
*
|
||||
* @param int $papel_impresion_id
|
||||
* @return Response
|
||||
*/
|
||||
public function duplicate( int $papel_impresion_id)
|
||||
{
|
||||
$bodyData = $this->request->getPost();
|
||||
$validated = $this->validation->run($bodyData, "papel_impresion_duplicate");
|
||||
if($validated){
|
||||
$papelImpresionEntity = $this->model->find($papel_impresion_id);
|
||||
$papelImpresionService = service('papel_impresion');
|
||||
$duplicated = $papelImpresionService
|
||||
->setPapelImpresionEntity($papelImpresionEntity)
|
||||
->duplicate($bodyData["name"]);
|
||||
return $this->response->setJSON(["data" => $duplicated]);
|
||||
|
||||
}else{
|
||||
return $this->response->setJSON(["errors" => $this->validation->getErrors()])->setStatusCode(400);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user