mirror of
https://git.imnavajas.es/jjimenez/safekat.git
synced 2025-07-25 22:52:08 +00:00
trabajando en presupuestos servicios extra
This commit is contained in:
@ -17,6 +17,7 @@ use App\Models\Presupuestos\PresupuestoEncuadernacionesModel;
|
||||
use App\Models\Presupuestos\PresupuestoAcabadosModel;
|
||||
use App\Models\Presupuestos\PresupuestoManipuladosModel;
|
||||
use App\Models\Presupuestos\PresupuestoPreimpresionesModel;
|
||||
use App\Models\Presupuestos\PresupuestoServiciosExtraModel;
|
||||
|
||||
use App\Services\PresupuestoService;
|
||||
use App\Models\Configuracion\PapelImpresionModel;
|
||||
@ -356,10 +357,10 @@ class Cosidotapablanda extends \App\Controllers\GoBaseResourceController
|
||||
|
||||
// Servicios
|
||||
$this->viewData['serviciosPreimpresion'] = $this->getServiciosPreimpresion();
|
||||
$this->viewData['serviciosPreimpresion'] = $this->getServiciosPreimpresion();
|
||||
$this->viewData['serviciosEncuadernacion'] = $this->getServiciosEncuadernacion();
|
||||
$this->viewData['serviciosManipulado'] = $this->getServiciosManipulado();
|
||||
$this->viewData['serviciosAcabado'] = $this->getServiciosAcabado();
|
||||
$this->viewData['serviciosExtra'] = $this->getServiciosExtra();
|
||||
|
||||
[$cambios_en_servicios, $servicios] = $this->getLineasServicios($presupuestoEntity);
|
||||
$this->viewData['presupuestoEntity']->cambios_servicios=$cambios_en_servicios;
|
||||
@ -368,6 +369,7 @@ class Cosidotapablanda extends \App\Controllers\GoBaseResourceController
|
||||
$this->viewData['serviciosAcabadosList'] = $servicios->serviciosAcabado;
|
||||
$this->viewData['serviciosManipuladoList'] = $servicios->serviciosManipulado;
|
||||
$this->viewData['serviciosPreimpresionList'] = $servicios->serviciosPreimpresion;
|
||||
$this->viewData['serviciosExtraList'] = $servicios->serviciosExtra;
|
||||
|
||||
// Direciones presupuesto
|
||||
[$cambios_en_direcciones, $this->viewData['direccionesList']] = $this->getLineasDirecciones($presupuestoEntity);
|
||||
@ -459,6 +461,10 @@ class Cosidotapablanda extends \App\Controllers\GoBaseResourceController
|
||||
$model = new PresupuestoManipuladosModel();
|
||||
$model->where("presupuesto_id", $id)->delete();
|
||||
|
||||
// Se borran los servicios extra
|
||||
$model = new PresupuestoServiciosExtraModel();
|
||||
$model->where("presupuesto_id", $id)->delete();
|
||||
|
||||
// $message = lang('Basic.global.deleteSuccess', [$objName]); IMN commented
|
||||
$message = lang('Basic.global.deleteSuccess', [lang('Basic.global.record')]);
|
||||
$response = $this->respondDeleted(['id' => $id, 'msg' => $message]);
|
||||
@ -889,6 +895,12 @@ class Cosidotapablanda extends \App\Controllers\GoBaseResourceController
|
||||
$preimpresion->presupuesto_id = $new_id;
|
||||
$presupuestoPreimpresionesModel->insert($preimpresion);
|
||||
}
|
||||
|
||||
$presupuestoServiciosExtraModel = model('App\Models\Presupuestos\PresupuestoServiciosExtraModel');
|
||||
foreach ($presupuestoServiciosExtraModel->where('presupuesto_id', $presupuesto->id)->findAll() as $servicioExtra) {
|
||||
$servicioExtra->presupuesto_id = $new_id;
|
||||
$presupuestoServiciosExtraModel->insert($preimpresion);
|
||||
}
|
||||
|
||||
$presupuestoDireccionesModel = model('App\Models\Presupuestos\PresupuestoDireccionesModel');
|
||||
foreach ($presupuestoDireccionesModel->where('presupuesto_id', $presupuesto->id)->findAll() as $direccion) {
|
||||
@ -1189,6 +1201,17 @@ class Cosidotapablanda extends \App\Controllers\GoBaseResourceController
|
||||
return $data;
|
||||
}
|
||||
|
||||
protected function getServiciosExtra()
|
||||
{
|
||||
$model = model('App\Models\Tarifas\TarifaextraModel');
|
||||
$data = $model->getServiciosExtraSelector();
|
||||
array_unshift($data, (object)array(
|
||||
"value" => 0,
|
||||
"label" => lang('Basic.global.pleaseSelectA', [mb_strtolower(lang('Presupuestos.servicioExtra'))])
|
||||
));
|
||||
return $data;
|
||||
}
|
||||
|
||||
protected function getServiciosEncuadernacion()
|
||||
{
|
||||
$model = model('App\Models\Tarifas\TarifaEncuadernacionModel');
|
||||
@ -1246,6 +1269,7 @@ class Cosidotapablanda extends \App\Controllers\GoBaseResourceController
|
||||
$serviciosPresupuesto->serviciosPreimpresion = (new PresupuestoPreimpresionesModel())->getResource($presupuestoEntity->id)->get()->getResultObject();
|
||||
$serviciosPresupuesto->serviciosEncuadernacion = (new PresupuestoEncuadernacionesModel())->getResource($presupuestoEntity->id)->get()->getResultObject();
|
||||
$serviciosPresupuesto->serviciosManipulado = (new PresupuestoManipuladosModel())->getResource($presupuestoEntity->id)->get()->getResultObject();
|
||||
$serviciosPresupuesto->serviciosExtra = (new PresupuestoServiciosExtraModel())->getResource($presupuestoEntity->id)->get()->getResultObject();
|
||||
|
||||
$input_data = [];
|
||||
$input_data['presupuesto_id'] = $presupuestoEntity->id;
|
||||
|
||||
113
ci4/app/Controllers/Presupuestos/Presupuestoserviciosextra.php
Executable file
113
ci4/app/Controllers/Presupuestos/Presupuestoserviciosextra.php
Executable file
@ -0,0 +1,113 @@
|
||||
<?php namespace App\Controllers\Presupuestos;
|
||||
|
||||
|
||||
use App\Models\Collection;
|
||||
|
||||
use App\Models\Presupuestos\PresupuestoServiciosExtraModel;
|
||||
|
||||
|
||||
class Presupuestoserviciosextra extends \App\Controllers\GoBaseResourceController
|
||||
{
|
||||
|
||||
protected $modelName = PresupuestoServiciosExtraModel::class;
|
||||
protected $format = 'json';
|
||||
|
||||
protected static $singularObjectName = 'Presupuesto extra';
|
||||
protected static $singularObjectNameCc = 'presupuestoPreimpresion';
|
||||
protected static $pluralObjectName = 'Presupuestos extra';
|
||||
protected static $pluralObjectNameCc = 'presupuestosPreimpresion';
|
||||
|
||||
protected static $controllerSlug = 'presupuesto-servicios-extra';
|
||||
|
||||
protected static $viewPath = 'themes/backend/vuexy/form/presupuestos/';
|
||||
|
||||
|
||||
|
||||
public function initController(\CodeIgniter\HTTP\RequestInterface $request, \CodeIgniter\HTTP\ResponseInterface $response, \Psr\Log\LoggerInterface $logger)
|
||||
{
|
||||
parent::initController($request, $response, $logger);
|
||||
}
|
||||
|
||||
|
||||
public function edit($requestedId = null)
|
||||
{
|
||||
|
||||
if ($requestedId == null) :
|
||||
return;
|
||||
endif;
|
||||
|
||||
$postData = $this->request->getJSON();
|
||||
$tarifas = array_column($postData->datos, 'tarifa_id');
|
||||
if(count($tarifas)>0){
|
||||
$this->model->deleteServiciosNotInArray($requestedId, $tarifas);
|
||||
}
|
||||
else{
|
||||
$this->model->deleteAllServicios($requestedId);
|
||||
}
|
||||
|
||||
if(count($tarifas)>0){
|
||||
$this->model->updateTarifas($requestedId, $postData->datos);
|
||||
}
|
||||
|
||||
$newTokenHash = csrf_hash();
|
||||
$csrfTokenName = csrf_token();
|
||||
$data = [
|
||||
$csrfTokenName => $newTokenHash
|
||||
];
|
||||
|
||||
return $this->respond($data);
|
||||
}
|
||||
|
||||
public function update($requestedId = null)
|
||||
{
|
||||
|
||||
if ($requestedId == null) :
|
||||
return;
|
||||
endif;
|
||||
|
||||
$postData = $this->request->getJSON();
|
||||
$tarifas = array_column($postData->datos, 'tarifa_id');
|
||||
$result = [];
|
||||
|
||||
if(count($tarifas)>0){
|
||||
foreach ($tarifas as $tarifa){
|
||||
$values = $this->model->getPrecioTarifa($tarifa);
|
||||
array_push($result, $values);
|
||||
}
|
||||
}
|
||||
|
||||
$newTokenHash = csrf_hash();
|
||||
$csrfTokenName = csrf_token();
|
||||
$data = [
|
||||
'lines' => $result,
|
||||
$csrfTokenName => $newTokenHash
|
||||
];
|
||||
|
||||
return $this->respond($data);
|
||||
}
|
||||
|
||||
public function datatable()
|
||||
{
|
||||
if ($this->request->isAJAX()) {
|
||||
$reqData = $this->request->getPost();
|
||||
|
||||
$tarifa_extra_id = $reqData['tarifa_extra_id'] ?? 0;
|
||||
|
||||
$newTokenHash = csrf_hash();
|
||||
$csrfTokenName = csrf_token();
|
||||
|
||||
$values = $this->model->getPrecioTarifa($tarifa_extra_id);
|
||||
|
||||
$data = [
|
||||
'values' => $values,
|
||||
$csrfTokenName => $newTokenHash
|
||||
];
|
||||
|
||||
return $this->respond($data);
|
||||
|
||||
} else {
|
||||
return $this->failUnauthorized('Invalid request', 403);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user