mirror of
https://git.imnavajas.es/jjimenez/safekat.git
synced 2025-07-25 22:52:08 +00:00
trabajando en el edit
This commit is contained in:
@ -1128,18 +1128,21 @@ class Presupuestoadmin extends \App\Controllers\BaseResourceController
|
||||
$solapas = $this->request->getGet('solapas') ?? 0;
|
||||
$lomo = $this->request->getGet('lomo') ?? 0;
|
||||
|
||||
$anchoLibro = 2* $ancho + 2 * $solapas + $lomo;
|
||||
|
||||
$tipo = $this->request->getGet("tipo");
|
||||
|
||||
$uso = $this->request->getGet("uso") ?? 'interior';
|
||||
|
||||
$anchoLibro = $ancho;
|
||||
|
||||
$cubierta = false;
|
||||
if ($uso == 'cubierta') {
|
||||
$cubierta = true;
|
||||
$anchoLibro = 2* $ancho + 2 * $solapas + $lomo;
|
||||
}
|
||||
$sobrecubierta = false;
|
||||
if ($uso == 'sobrecubierta') {
|
||||
$sobrecubierta = true;
|
||||
$anchoLibro = 2* $ancho + 2 * $solapas + $lomo;
|
||||
}
|
||||
$guardas = false;
|
||||
if ($uso == 'guardas') {
|
||||
@ -1191,7 +1194,7 @@ class Presupuestoadmin extends \App\Controllers\BaseResourceController
|
||||
$solapas = $this->request->getGet('solapas') ?? 0;
|
||||
$lomo = $this->request->getGet('lomo') ?? 0;
|
||||
|
||||
$anchoLibro = 2* $ancho + 2 * $solapas + $lomo;
|
||||
$anchoLibro = $ancho;
|
||||
|
||||
$tipo_impresion_id = $this->request->getGet("tipo_impresion");
|
||||
$tapa_dura = model('App\Models\Configuracion\TipoPresupuestoModel')->get_isTapaDura(intval($tipo_impresion_id));
|
||||
@ -1202,10 +1205,12 @@ class Presupuestoadmin extends \App\Controllers\BaseResourceController
|
||||
$cubierta = false;
|
||||
if ($uso == 'cubierta') {
|
||||
$cubierta = true;
|
||||
$anchoLibro = 2* $ancho + 2 * $solapas + $lomo;
|
||||
}
|
||||
$sobrecubierta = false;
|
||||
if ($uso == 'sobrecubierta') {
|
||||
$sobrecubierta = true;
|
||||
$anchoLibro = 2* $ancho + 2 * $solapas + $lomo;
|
||||
}
|
||||
$guardas = false;
|
||||
if ($uso == 'guardas') {
|
||||
|
||||
@ -15,13 +15,13 @@ class ServiciosAcabado extends BaseResourceController
|
||||
protected $format = 'json';
|
||||
|
||||
protected static $singularObjectName = 'Servicio Acabado';
|
||||
protected static $singularObjectNameCc = 'servicioAcabado';
|
||||
protected static $singularObjectNameCc = 'serviciosAcabado';
|
||||
protected static $pluralObjectName = 'Servicios Acabado';
|
||||
protected static $pluralObjectNameCc = 'serviciosAcabado';
|
||||
|
||||
protected static $controllerSlug = 'serviciosacabado';
|
||||
|
||||
protected static $viewPath = 'themes/vuexy/form/tarifas/acabado/';
|
||||
protected static $viewPath = 'themes/vuexy/form/tarifas/acabado/';
|
||||
|
||||
protected $indexRoute = 'serviciosAcabadoList';
|
||||
|
||||
@ -31,12 +31,7 @@ class ServiciosAcabado extends BaseResourceController
|
||||
$this->viewData['pageTitle'] = lang('Servicioacabado.moduleTitle');
|
||||
$this->viewData['usingSweetAlert'] = true;
|
||||
|
||||
// Se indica que este controlador trabaja con soft_delete
|
||||
$this->soft_delete = true;
|
||||
// Se indica el flag para los ficheros borrados
|
||||
$this->delete_flag = 1;
|
||||
|
||||
//$this->viewData = ['usingServerSideDataTable' => true];
|
||||
$this->viewData = ['usingServerSideDataTable' => true];
|
||||
|
||||
// Breadcrumbs
|
||||
$this->viewData['breadcrumb'] = [
|
||||
@ -66,18 +61,162 @@ class ServiciosAcabado extends BaseResourceController
|
||||
return view(static::$viewPath . 'viewServiciosAcabadoList', $viewData);
|
||||
}
|
||||
|
||||
public function datatable(){
|
||||
|
||||
|
||||
public function edit($requestedId = null)
|
||||
{
|
||||
|
||||
checkPermission('tarifa-acabado.edit', $this->indexRoute);
|
||||
|
||||
if ($requestedId == null):
|
||||
return $this->redirect2listView();
|
||||
endif;
|
||||
$id = filter_var($requestedId, FILTER_SANITIZE_URL);
|
||||
$servicio = $this->model->find($id);
|
||||
|
||||
if ($servicio == false):
|
||||
$message = lang('Basic.global.notFoundWithIdErr', [mb_strtolower(lang('ServicioAcabado.servicioacabado')), $id]);
|
||||
return $this->redirect2listView('sweet-error', $message);
|
||||
endif;
|
||||
|
||||
if ($this->request->getPost()):
|
||||
|
||||
$nullIfEmpty = true; // !(phpversion() >= '8.1');
|
||||
|
||||
$postData = $this->request->getPost();
|
||||
|
||||
$sanitizedData = $this->sanitized($postData, $nullIfEmpty);
|
||||
|
||||
$sanitizedData['user_updated_id'] = auth()->user()->id;
|
||||
|
||||
if ($this->request->getPost('mostrar_en_presupuesto_cliente') == null) {
|
||||
$sanitizedData['mostrar_en_presupuesto'] = false;
|
||||
}
|
||||
|
||||
if ($this->request->getPost('acabado_cubierta') == null) {
|
||||
$sanitizedData['acabado_cubierta'] = false;
|
||||
}
|
||||
|
||||
if ($this->request->getPost('acabado_sobrecubierta') == null) {
|
||||
$sanitizedData['acabado_sobrecubierta'] = false;
|
||||
}
|
||||
|
||||
|
||||
$noException = true;
|
||||
if ($successfulResult = $this->canValidate()): // if ($successfulResult = $this->validate($this->formValidationRules) ) :
|
||||
|
||||
|
||||
if ($this->canValidate()):
|
||||
try {
|
||||
$successfulResult = $this->model->skipValidation(true)->update($id, $sanitizedData);
|
||||
} catch (\Exception $e) {
|
||||
$noException = false;
|
||||
$this->dealWithException($e);
|
||||
}
|
||||
else:
|
||||
$this->viewData['warningMessage'] = lang('Basic.global.formErr1', [mb_strtolower(lang('Tarifaacabado.tarifaacabado'))]);
|
||||
$this->session->setFlashdata('formErrors', $this->model->errors());
|
||||
|
||||
endif;
|
||||
|
||||
$servicio->fill($sanitizedData);
|
||||
|
||||
$thenRedirect = false;
|
||||
endif;
|
||||
|
||||
if ($noException && $successfulResult):
|
||||
$id = $servicio->id ?? $id;
|
||||
$message = lang('Basic.global.updateSuccess', [lang('Basic.global.record')]) . '.';
|
||||
|
||||
if ($thenRedirect):
|
||||
if (!empty($this->indexRoute)):
|
||||
return redirect()->to(route_to($this->indexRoute))->with('sweet-success', $message);
|
||||
else:
|
||||
return $this->redirect2listView('sweet-success', $message);
|
||||
endif;
|
||||
else:
|
||||
$this->session->setFlashData('sweet-success', $message);
|
||||
endif;
|
||||
|
||||
endif; // $noException && $successfulResult
|
||||
endif; // ($requestMethod === 'post')
|
||||
|
||||
$this->viewData['servicio'] = $servicio;
|
||||
$this->viewData['tarifasSeleccionadas'] = [1,2];
|
||||
|
||||
$this->viewData['formAction'] = route_to('updateServicioAcabado', $id);
|
||||
|
||||
$this->viewData['boxTitle'] = lang('Basic.global.edit2') . ' ' . lang('ServicioAcabado.moduleTitle') . ' ' . lang('Basic.global.edit3');
|
||||
|
||||
|
||||
return $this->displayForm(__METHOD__, $id);
|
||||
} // end function edit(...)
|
||||
|
||||
|
||||
public function datatable()
|
||||
{
|
||||
|
||||
$model = model(ServicioAcabadoModel::class);
|
||||
$q = $model->getDatatableQuery();
|
||||
//return $this->response->setJSON($q->get());
|
||||
return DataTable::of($q)
|
||||
->add("action", fn($q) => $q->id)
|
||||
->add("action", callback: function ($q) {
|
||||
return '<span class="edit"><a href="javascript:void(0);"><i class="ti ti-pencil ti-sm btn-edit mx-2" data-id="' . $q->id . '"></i></a></span>'
|
||||
. (auth()->user()->can("servicio-acabado.delete") ?
|
||||
'<span class="delete"><a href="javascript:void(0);"><i class="ti ti-trash ti-sm btn-delete mx-2" data-id="' . $q->id . '"></i></a></span>'
|
||||
: '');
|
||||
})
|
||||
->edit(
|
||||
"updated_at",
|
||||
fn($q) => Time::createFromFormat("Y-m-d H:i:s",$q->updated_at)->format("d/m/Y")
|
||||
)
|
||||
fn($q) => Time::createFromFormat("Y-m-d H:i:s", $q->updated_at)->format("d/m/Y")
|
||||
)
|
||||
->toJson(returnAsObject: true);
|
||||
}
|
||||
|
||||
public function getTarifasSeleccionadas()
|
||||
{
|
||||
$model = model("App\Models\Tarifas\Acabados\TarifaAcabadoModel");
|
||||
$ids = $this->request->getGet('ids');
|
||||
|
||||
if (empty($ids)) {
|
||||
return $this->response->setJSON([]);
|
||||
}
|
||||
|
||||
$query = $model->select('lg_tarifa_acabado.id, lg_tarifa_acabado.nombre')->whereIn('lg_tarifa_acabado.id', $ids);
|
||||
|
||||
$query->where('lg_tarifa_acabado.deleted_at', null);
|
||||
|
||||
$tarifas = $query->findAll();
|
||||
|
||||
return $this->response->setJSON($tarifas);
|
||||
}
|
||||
|
||||
public function getTarifas()
|
||||
{
|
||||
$model = model("App\Models\Tarifas\Acabados\TarifaAcabadoModel");
|
||||
|
||||
$search = $this->request->getGet('search'); // Obtiene el parámetro de búsqueda
|
||||
|
||||
$acabado_cubierta = $this->request->getGet('acabado_cubierta');
|
||||
$acabado_sobrecubierta = $this->request->getGet('acabado_sobrecubierta');
|
||||
|
||||
$query = $model->select('lg_tarifa_acabado.id, lg_tarifa_acabado.nombre');
|
||||
|
||||
if (!empty($search)) {
|
||||
$query->like('lg_tarifa_acabado.nombre', $search);
|
||||
}
|
||||
|
||||
if($acabado_cubierta){
|
||||
$query->where('lg_tarifa_acabado.acabado_cubierta', $acabado_cubierta);
|
||||
}
|
||||
if($acabado_sobrecubierta){
|
||||
$query->where('lg_tarifa_acabado.acabado_sobrecubierta', $acabado_sobrecubierta);
|
||||
}
|
||||
|
||||
$query->where('lg_tarifa_acabado.deleted_at', null);
|
||||
|
||||
$tarifas = $query->findAll();
|
||||
|
||||
return $this->response->setJSON($tarifas);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user