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:
@ -41,22 +41,17 @@ const SK_PERMISSION_MATRIX = [
|
|||||||
"tarifa-acabado.edit",
|
"tarifa-acabado.edit",
|
||||||
"tarifa-acabado.delete",
|
"tarifa-acabado.delete",
|
||||||
"tarifa-acabado.menu",
|
"tarifa-acabado.menu",
|
||||||
"servicio-acabado.create",
|
|
||||||
"servicio-acabado.edit",
|
|
||||||
"servicio-acabado.delete",
|
|
||||||
"servicio-acabado.menu",
|
|
||||||
"tarifa-encuadernacion.create",
|
"tarifa-encuadernacion.create",
|
||||||
"tarifa-encuadernacion.edit",
|
"tarifa-encuadernacion.edit",
|
||||||
"tarifa-encuadernacion.delete",
|
"tarifa-encuadernacion.delete",
|
||||||
"tarifa-encuadernacion.menu",
|
"tarifa-encuadernacion.menu",
|
||||||
"tarifa-extra.create",
|
|
||||||
"tarifa-extra.edit",
|
|
||||||
"tarifa-extra.delete",
|
|
||||||
"tarifa-extra.menu",
|
|
||||||
"tarifa-envio.create",
|
"tarifa-envio.create",
|
||||||
"tarifa-envio.edit",
|
"tarifa-envio.edit",
|
||||||
"tarifa-envio.delete",
|
"tarifa-envio.delete",
|
||||||
"tarifa-envio.menu",
|
"tarifa-envio.menu",
|
||||||
|
"servicio-acabado.create",
|
||||||
|
"servicio-acabado.delete",
|
||||||
|
"servicio-acabado.menu",
|
||||||
"proveedores.create",
|
"proveedores.create",
|
||||||
"proveedores.edit",
|
"proveedores.edit",
|
||||||
"proveedores.delete",
|
"proveedores.delete",
|
||||||
|
|||||||
@ -41,10 +41,6 @@ const SK_PERMISSIONS = [
|
|||||||
'tarifa-acabado.edit' => 'Can edit',
|
'tarifa-acabado.edit' => 'Can edit',
|
||||||
'tarifa-acabado.delete' => 'Can delete',
|
'tarifa-acabado.delete' => 'Can delete',
|
||||||
'tarifa-acabado.menu' => 'Menu shall be visualize',
|
'tarifa-acabado.menu' => 'Menu shall be visualize',
|
||||||
'servicio-acabado.create' => 'Can create',
|
|
||||||
'servicio-acabado.edit' => 'Can edit',
|
|
||||||
'servicio-acabado.delete' => 'Can delete',
|
|
||||||
'servicio-acabado.menu' => 'Menu shall be visualize',
|
|
||||||
'tarifa-encuadernacion.create' => 'Can create',
|
'tarifa-encuadernacion.create' => 'Can create',
|
||||||
'tarifa-encuadernacion.edit' => 'Can edit',
|
'tarifa-encuadernacion.edit' => 'Can edit',
|
||||||
'tarifa-encuadernacion.delete' => 'Can delete',
|
'tarifa-encuadernacion.delete' => 'Can delete',
|
||||||
@ -57,6 +53,10 @@ const SK_PERMISSIONS = [
|
|||||||
'tarifa-envio.edit' => 'Can edit',
|
'tarifa-envio.edit' => 'Can edit',
|
||||||
'tarifa-envio.delete' => 'Can delete',
|
'tarifa-envio.delete' => 'Can delete',
|
||||||
'tarifa-envio.menu' => 'Menu shall be visualize',
|
'tarifa-envio.menu' => 'Menu shall be visualize',
|
||||||
|
'servicio-acabado.create' => 'Can create',
|
||||||
|
'servicio-acabado.edit' => 'Can edit',
|
||||||
|
'servicio-acabado.delete' => 'Can delete',
|
||||||
|
'servicio-acabado.menu' => 'Menu shall be visualize',
|
||||||
'proveedores.create' => 'Can create',
|
'proveedores.create' => 'Can create',
|
||||||
'proveedores.edit' => 'Can edit',
|
'proveedores.edit' => 'Can edit',
|
||||||
'proveedores.delete' => 'Can delete',
|
'proveedores.delete' => 'Can delete',
|
||||||
|
|||||||
@ -215,8 +215,9 @@ $routes->group('serviciosacabado', ['namespace' => 'App\Controllers\Tarifas\Acab
|
|||||||
$routes->post('add', 'ServiciosAcabado::add', ['as' => 'createServicioAcabado']);
|
$routes->post('add', 'ServiciosAcabado::add', ['as' => 'createServicioAcabado']);
|
||||||
$routes->get('edit/(:num)', 'ServiciosAcabado::edit/$1', ['as' => 'editServicioAcabado']);
|
$routes->get('edit/(:num)', 'ServiciosAcabado::edit/$1', ['as' => 'editServicioAcabado']);
|
||||||
$routes->post('edit/(:num)', 'ServiciosAcabado::edit/$1', ['as' => 'updateServicioAcabado']);
|
$routes->post('edit/(:num)', 'ServiciosAcabado::edit/$1', ['as' => 'updateServicioAcabado']);
|
||||||
$routes->post('edit/(:num)', 'ServiciosAcabado::edit/$1', ['as' => 'updateServicioAcabado']);
|
|
||||||
$routes->get('datatable', 'ServiciosAcabado::datatable');
|
$routes->get('datatable', 'ServiciosAcabado::datatable');
|
||||||
|
$routes->get('getselectedtarifas', 'ServiciosAcabado::getTarifasSeleccionadas');
|
||||||
|
$routes->get('gettarifas', 'ServiciosAcabado::getTarifas');
|
||||||
});
|
});
|
||||||
$routes->resource('tarifasmanipulado', ['namespace' => 'App\Controllers\Tarifas\Acabados', 'controller' => 'ServiciosAcabado', 'except' => 'show,new,create,update']);
|
$routes->resource('tarifasmanipulado', ['namespace' => 'App\Controllers\Tarifas\Acabados', 'controller' => 'ServiciosAcabado', 'except' => 'show,new,create,update']);
|
||||||
|
|
||||||
|
|||||||
@ -1128,18 +1128,21 @@ class Presupuestoadmin extends \App\Controllers\BaseResourceController
|
|||||||
$solapas = $this->request->getGet('solapas') ?? 0;
|
$solapas = $this->request->getGet('solapas') ?? 0;
|
||||||
$lomo = $this->request->getGet('lomo') ?? 0;
|
$lomo = $this->request->getGet('lomo') ?? 0;
|
||||||
|
|
||||||
$anchoLibro = 2* $ancho + 2 * $solapas + $lomo;
|
|
||||||
|
|
||||||
$tipo = $this->request->getGet("tipo");
|
$tipo = $this->request->getGet("tipo");
|
||||||
|
|
||||||
$uso = $this->request->getGet("uso") ?? 'interior';
|
$uso = $this->request->getGet("uso") ?? 'interior';
|
||||||
|
|
||||||
|
$anchoLibro = $ancho;
|
||||||
|
|
||||||
$cubierta = false;
|
$cubierta = false;
|
||||||
if ($uso == 'cubierta') {
|
if ($uso == 'cubierta') {
|
||||||
$cubierta = true;
|
$cubierta = true;
|
||||||
|
$anchoLibro = 2* $ancho + 2 * $solapas + $lomo;
|
||||||
}
|
}
|
||||||
$sobrecubierta = false;
|
$sobrecubierta = false;
|
||||||
if ($uso == 'sobrecubierta') {
|
if ($uso == 'sobrecubierta') {
|
||||||
$sobrecubierta = true;
|
$sobrecubierta = true;
|
||||||
|
$anchoLibro = 2* $ancho + 2 * $solapas + $lomo;
|
||||||
}
|
}
|
||||||
$guardas = false;
|
$guardas = false;
|
||||||
if ($uso == 'guardas') {
|
if ($uso == 'guardas') {
|
||||||
@ -1191,7 +1194,7 @@ class Presupuestoadmin extends \App\Controllers\BaseResourceController
|
|||||||
$solapas = $this->request->getGet('solapas') ?? 0;
|
$solapas = $this->request->getGet('solapas') ?? 0;
|
||||||
$lomo = $this->request->getGet('lomo') ?? 0;
|
$lomo = $this->request->getGet('lomo') ?? 0;
|
||||||
|
|
||||||
$anchoLibro = 2* $ancho + 2 * $solapas + $lomo;
|
$anchoLibro = $ancho;
|
||||||
|
|
||||||
$tipo_impresion_id = $this->request->getGet("tipo_impresion");
|
$tipo_impresion_id = $this->request->getGet("tipo_impresion");
|
||||||
$tapa_dura = model('App\Models\Configuracion\TipoPresupuestoModel')->get_isTapaDura(intval($tipo_impresion_id));
|
$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;
|
$cubierta = false;
|
||||||
if ($uso == 'cubierta') {
|
if ($uso == 'cubierta') {
|
||||||
$cubierta = true;
|
$cubierta = true;
|
||||||
|
$anchoLibro = 2* $ancho + 2 * $solapas + $lomo;
|
||||||
}
|
}
|
||||||
$sobrecubierta = false;
|
$sobrecubierta = false;
|
||||||
if ($uso == 'sobrecubierta') {
|
if ($uso == 'sobrecubierta') {
|
||||||
$sobrecubierta = true;
|
$sobrecubierta = true;
|
||||||
|
$anchoLibro = 2* $ancho + 2 * $solapas + $lomo;
|
||||||
}
|
}
|
||||||
$guardas = false;
|
$guardas = false;
|
||||||
if ($uso == 'guardas') {
|
if ($uso == 'guardas') {
|
||||||
|
|||||||
@ -15,13 +15,13 @@ class ServiciosAcabado extends BaseResourceController
|
|||||||
protected $format = 'json';
|
protected $format = 'json';
|
||||||
|
|
||||||
protected static $singularObjectName = 'Servicio Acabado';
|
protected static $singularObjectName = 'Servicio Acabado';
|
||||||
protected static $singularObjectNameCc = 'servicioAcabado';
|
protected static $singularObjectNameCc = 'serviciosAcabado';
|
||||||
protected static $pluralObjectName = 'Servicios Acabado';
|
protected static $pluralObjectName = 'Servicios Acabado';
|
||||||
protected static $pluralObjectNameCc = 'serviciosAcabado';
|
protected static $pluralObjectNameCc = 'serviciosAcabado';
|
||||||
|
|
||||||
protected static $controllerSlug = 'serviciosacabado';
|
protected static $controllerSlug = 'serviciosacabado';
|
||||||
|
|
||||||
protected static $viewPath = 'themes/vuexy/form/tarifas/acabado/';
|
protected static $viewPath = 'themes/vuexy/form/tarifas/acabado/';
|
||||||
|
|
||||||
protected $indexRoute = 'serviciosAcabadoList';
|
protected $indexRoute = 'serviciosAcabadoList';
|
||||||
|
|
||||||
@ -31,12 +31,7 @@ class ServiciosAcabado extends BaseResourceController
|
|||||||
$this->viewData['pageTitle'] = lang('Servicioacabado.moduleTitle');
|
$this->viewData['pageTitle'] = lang('Servicioacabado.moduleTitle');
|
||||||
$this->viewData['usingSweetAlert'] = true;
|
$this->viewData['usingSweetAlert'] = true;
|
||||||
|
|
||||||
// Se indica que este controlador trabaja con soft_delete
|
$this->viewData = ['usingServerSideDataTable' => true];
|
||||||
$this->soft_delete = true;
|
|
||||||
// Se indica el flag para los ficheros borrados
|
|
||||||
$this->delete_flag = 1;
|
|
||||||
|
|
||||||
//$this->viewData = ['usingServerSideDataTable' => true];
|
|
||||||
|
|
||||||
// Breadcrumbs
|
// Breadcrumbs
|
||||||
$this->viewData['breadcrumb'] = [
|
$this->viewData['breadcrumb'] = [
|
||||||
@ -66,18 +61,162 @@ class ServiciosAcabado extends BaseResourceController
|
|||||||
return view(static::$viewPath . 'viewServiciosAcabadoList', $viewData);
|
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);
|
$model = model(ServicioAcabadoModel::class);
|
||||||
$q = $model->getDatatableQuery();
|
$q = $model->getDatatableQuery();
|
||||||
//return $this->response->setJSON($q->get());
|
//return $this->response->setJSON($q->get());
|
||||||
return DataTable::of($q)
|
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(
|
->edit(
|
||||||
"updated_at",
|
"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);
|
->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);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -797,7 +797,7 @@ return [
|
|||||||
"menu_tarifamanipulado" => "Manipulado",
|
"menu_tarifamanipulado" => "Manipulado",
|
||||||
"menu_tarifaencuadernacion" => "Encuadernación",
|
"menu_tarifaencuadernacion" => "Encuadernación",
|
||||||
"menu_tarifapapelcompra" => "Papel compra",
|
"menu_tarifapapelcompra" => "Papel compra",
|
||||||
"menu_serviciosAcabado" => "Servicios acabado",
|
"menu_Servicioacabado" => "Servicios acabado",
|
||||||
"menu_tarifaacabado" => "Acabado",
|
"menu_tarifaacabado" => "Acabado",
|
||||||
"menu_tarifapapeldefecto" => "Papel defecto",
|
"menu_tarifapapeldefecto" => "Papel defecto",
|
||||||
"menu_tarifaenvio" => "Envío",
|
"menu_tarifaenvio" => "Envío",
|
||||||
|
|||||||
@ -0,0 +1,100 @@
|
|||||||
|
<?= $this->include("themes/_commonPartialsBs/select2bs5") ?>
|
||||||
|
<?= $this->include("themes/_commonPartialsBs/sweetalert") ?>
|
||||||
|
<?= $this->extend('themes/vuexy/main/defaultlayout') ?>
|
||||||
|
|
||||||
|
<?= $this->section("content") ?>
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-12">
|
||||||
|
<div class="card card-info">
|
||||||
|
<div class="card-header">
|
||||||
|
<h3 class="card-title"><?= $boxTitle ?? $pageTitle ?></h3>
|
||||||
|
</div><!--//.card-header -->
|
||||||
|
<form id="servicioAcabadoForm" class="card-body" method="post" action="<?= $formAction ?>">
|
||||||
|
<?= csrf_field() ?>
|
||||||
|
<?= view("themes/_commonPartialsBs/_alertBoxes") ?>
|
||||||
|
<?= !empty($validation->getErrors()) ? $validation->listErrors("bootstrap_style") : "" ?>
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-md-12 col-lg-12 px-4">
|
||||||
|
<div class="mb-3">
|
||||||
|
<label for="nombre" class="form-label">
|
||||||
|
<?= lang('ServicioAcabado.nombre') ?>*
|
||||||
|
</label>
|
||||||
|
<input type="text" id="nombre" name="nombre" maxLength="255" class="form-control"
|
||||||
|
value="<?= old('nombre', $servicio->nombre) ?>">
|
||||||
|
</div><!--//.mb-3 -->
|
||||||
|
|
||||||
|
<div class="row">
|
||||||
|
<span class="mb-3">Seleccione si es servicio cubierta o sobrecubierta (o ambos) antes de
|
||||||
|
seleccionar las tarifas asociadas. Al cambiar estas opciones, se borrará la
|
||||||
|
selección.</span>
|
||||||
|
<div class="mb-3">
|
||||||
|
<div class="form-check col-md-3">
|
||||||
|
<label for="acabado_cubierta" class="form-check-label">
|
||||||
|
<input type="checkbox" id="acabado_cubierta" name="acabado_cubierta" value="1"
|
||||||
|
class="form-check-input" <?= $servicio->acabado_cubierta == true ? 'checked' : ''; ?>>
|
||||||
|
<?= lang('ServicioAcabado.servicio_cubierta') ?>
|
||||||
|
</label>
|
||||||
|
</div><!--//.form-check -->
|
||||||
|
|
||||||
|
<div class="form-check col-md-3">
|
||||||
|
<label for="acabado_sobrecubierta" class="form-check-label">
|
||||||
|
<input type="checkbox" id="acabado_sobrecubierta" name="acabado_sobrecubierta"
|
||||||
|
value="1" class="form-check-input" <?= $servicio->acabado_sobrecubierta == true ? 'checked' : ''; ?>>
|
||||||
|
<?= lang('ServicioAcabado.servicio_sobrecubierta') ?>
|
||||||
|
</label>
|
||||||
|
</div><!--//.form-check -->
|
||||||
|
|
||||||
|
<div class="form-check col-md-3">
|
||||||
|
<label for="mostrar_en_presupuesto_cliente" class="form-check-label">
|
||||||
|
<input type="checkbox" id="mostrar_en_presupuesto_cliente"
|
||||||
|
name="mostrar_en_presupuesto_cliente" value="1" class="form-check-input"
|
||||||
|
<?= $servicio->mostrar_en_presupuesto_cliente == true ? 'checked' : ''; ?>>
|
||||||
|
<?= lang('Tarifaencuadernacion.mostrar_en_presupuesto_cliente') ?>
|
||||||
|
</label>
|
||||||
|
</div><!--//.form-check -->
|
||||||
|
</div><!--//.mb-3 -->
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="mb-3">
|
||||||
|
<div class="form-group">
|
||||||
|
<label for="tarifas" class="form-label">
|
||||||
|
<?= lang('Tarifaacabado.tarifasacabado') ?></label>
|
||||||
|
<select id="tarifas" name="tarifasAcabado[]" multiple="multiple"
|
||||||
|
class="form-control select2"
|
||||||
|
data-selected='<?= json_encode($tarifasSeleccionadas) ?>'></select>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
<div class="mb-3">
|
||||||
|
<label for="comentarios" class="form-label">
|
||||||
|
<?= lang('ServicioAcabado.comentarios') ?>
|
||||||
|
</label>
|
||||||
|
<textarea id="comentarios" name="comentarios" rows="5" cols="10"
|
||||||
|
class="form-control"><?= old('comentarios', $servicio->comentarios) ?></textarea>
|
||||||
|
</div><!--//.mb-3 -->
|
||||||
|
|
||||||
|
|
||||||
|
</div><!--//.col -->
|
||||||
|
|
||||||
|
</div><!-- //.row -->
|
||||||
|
|
||||||
|
<div class="pt-4">
|
||||||
|
<?php if (auth()->user()->can('tarifa-acabado.edit')): ?>
|
||||||
|
<input type="submit" class="btn btn-primary float-start me-sm-3 me-1" name="save"
|
||||||
|
value="<?= lang("Basic.global.Save") ?>" />
|
||||||
|
<?php endif; ?>
|
||||||
|
<?= anchor(route_to("serviciosAcabadoList"), lang("Basic.global.Cancel"), ["class" => "btn btn-secondary float-start"]) ?>
|
||||||
|
</div><!-- /.card-footer -->
|
||||||
|
</form>
|
||||||
|
</div><!-- //.card -->
|
||||||
|
</div><!--//.col -->
|
||||||
|
</div><!--//.row -->
|
||||||
|
|
||||||
|
<?= $this->endSection() ?>
|
||||||
|
|
||||||
|
<?= $this->section('additionalExternalJs') ?>
|
||||||
|
|
||||||
|
<script type="module" src="<?= site_url("/assets/js/safekat/pages/tarifas/serviciosAcabado/edit.js") ?>"></script>
|
||||||
|
|
||||||
|
<?= $this->endSection() ?>
|
||||||
@ -8,7 +8,9 @@
|
|||||||
<div class="card card-info">
|
<div class="card card-info">
|
||||||
<div class="card-header">
|
<div class="card-header">
|
||||||
<h3 class="card-title"><?= lang('ServicioAcabado.servicioscabadoList') ?></h3>
|
<h3 class="card-title"><?= lang('ServicioAcabado.servicioscabadoList') ?></h3>
|
||||||
<?= anchor(route_to('newServicioAcabado'), lang('Basic.global.addNew') . ' ' . lang('ServicioAcabado.servicioacabado'), ['class' => 'btn btn-primary float-end']); ?>
|
<?php if(auth()->user()->can('servicio-acabado.create')): ?>
|
||||||
|
<?= anchor(route_to('newServicioAcabado'), lang('Basic.global.addNew') . ' ' . lang('ServicioAcabado.servicioacabado'), ['class' => 'btn btn-primary float-end']); ?>
|
||||||
|
<?php endif; ?>
|
||||||
</div><!--//.card-header -->
|
</div><!--//.card-header -->
|
||||||
<div class="card-body">
|
<div class="card-body">
|
||||||
<?= view('themes/_commonPartialsBs/_alertBoxes'); ?>
|
<?= view('themes/_commonPartialsBs/_alertBoxes'); ?>
|
||||||
|
|||||||
@ -0,0 +1,78 @@
|
|||||||
|
import Ajax from '../../../components/ajax.js';
|
||||||
|
|
||||||
|
|
||||||
|
class editServiciosAcabado {
|
||||||
|
|
||||||
|
constructor() {
|
||||||
|
|
||||||
|
this.selectElement = $('#tarifas');
|
||||||
|
this.acabado_cubierta = $('#acabado_cubierta');
|
||||||
|
this.acabado_sobrecubierta = $('#acabado_sobrecubierta');
|
||||||
|
this.tarifasSeleccionadas = JSON.parse(this.selectElement.attr('data-selected') || '[]');
|
||||||
|
}
|
||||||
|
|
||||||
|
init() {
|
||||||
|
|
||||||
|
const self = this;
|
||||||
|
|
||||||
|
this.selectElement.select2({
|
||||||
|
placeholder: "Selecciona tarifas...",
|
||||||
|
allowClear: true,
|
||||||
|
ajax: {
|
||||||
|
url: "/serviciosacabado/gettarifas",
|
||||||
|
type: "GET",
|
||||||
|
dataType: "json",
|
||||||
|
delay: 250,
|
||||||
|
data: function (params) {
|
||||||
|
return {
|
||||||
|
id: window.location.pathname.split('/').pop(),
|
||||||
|
search: params.term ,
|
||||||
|
acabado_cubierta: self.acabado_cubierta.prop('checked')?1:0,
|
||||||
|
acabado_sobrecubierta: self.acabado_sobrecubierta.prop('checked')?1:0
|
||||||
|
};
|
||||||
|
},
|
||||||
|
processResults: function (data) {
|
||||||
|
return {
|
||||||
|
results: data.map(item => ({
|
||||||
|
id: item.id,
|
||||||
|
text: item.nombre
|
||||||
|
}))
|
||||||
|
};
|
||||||
|
},
|
||||||
|
cache: true
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// Si hay tarifas preseleccionadas, cargarlas manualmente
|
||||||
|
if (this.tarifasSeleccionadas.length > 0) {
|
||||||
|
$.ajax({
|
||||||
|
url: "/serviciosacabado/getselectedtarifas",
|
||||||
|
type: "GET",
|
||||||
|
dataType: "json",
|
||||||
|
data: { ids: self.tarifasSeleccionadas },
|
||||||
|
success: (data) => {
|
||||||
|
let tarifasPreseleccionadas = data.map(item => ({
|
||||||
|
id: item.id,
|
||||||
|
text: item.nombre
|
||||||
|
}));
|
||||||
|
|
||||||
|
self.selectElement.append(
|
||||||
|
tarifasPreseleccionadas.map(item =>
|
||||||
|
new Option(item.text, item.id, true, true)
|
||||||
|
)
|
||||||
|
).trigger("change");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
$(function () {
|
||||||
|
new editServiciosAcabado().init();
|
||||||
|
})
|
||||||
|
|
||||||
|
export default editServiciosAcabado;
|
||||||
@ -1,25 +1,58 @@
|
|||||||
class listServiciosAcabado{
|
import Ajax from '../../../components/ajax.js';
|
||||||
|
import ConfirmDeleteModal from '../../../components/ConfirmDeleteModal.js';
|
||||||
|
|
||||||
constructor(){}
|
class listServiciosAcabado {
|
||||||
|
|
||||||
init(){
|
constructor() {
|
||||||
|
|
||||||
|
this.deleteModal = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
init() {
|
||||||
|
const self = this;
|
||||||
|
|
||||||
this.table = $('#tableOfServiciosAcabado');
|
this.table = $('#tableOfServiciosAcabado');
|
||||||
|
|
||||||
this.datatableColumns = [
|
this.datatableColumns = [
|
||||||
{ data: 'id', searchable: true, sortable: true, width: "10%" },
|
{ data: 'id', searchable: true, sortable: true, width: "10%" },
|
||||||
{ data: 'nombre', searchable: true, sortable: true, width: "40%" },
|
{ data: 'nombre', searchable: true, sortable: true, width: "40%" },
|
||||||
{ data: 'acabado_cubierta', sortable: true, width: "10%", render: this.#renderBoolCell.bind(this) },
|
{ data: 'acabado_cubierta', sortable: true, width: "10%", render: this.#renderBoolCell.bind(this) },
|
||||||
{ data: 'acabado_sobrecubierta', sortable: false, width: "10%", render: this.#renderBoolCell.bind(this) },
|
{ data: 'acabado_sobrecubierta', sortable: false, width: "10%", render: this.#renderBoolCell.bind(this) },
|
||||||
{ data: 'mostrar_en_presupuesto_cliente', searchable: false, sortable: true, width: "1exit0%", render: this.#renderBoolCell.bind(this) },
|
{ data: 'mostrar_en_presupuesto_cliente', searchable: false, sortable: true, width: "1exit0%", render: this.#renderBoolCell.bind(this) },
|
||||||
{ data: 'user_updated', searchable: true, sortable: true },
|
{ data: 'user_updated', searchable: true, sortable: true },
|
||||||
{ data: 'updated_at', searchable: false, sortable: true },
|
{ data: 'updated_at', searchable: false, sortable: true },
|
||||||
{
|
{
|
||||||
data: 'action', searchable: false, sortable: false, width: "10%", render: this.#renderActionCell.bind(this)
|
data: 'action', searchable: false, sortable: false, width: "10%"
|
||||||
},
|
},
|
||||||
]
|
]
|
||||||
|
|
||||||
this.initDatatableTareas();
|
this.initDatatableTareas();
|
||||||
|
|
||||||
|
this.deleteModal = new ConfirmDeleteModal('tarifascliente');
|
||||||
|
this.deleteModal.init();
|
||||||
|
|
||||||
|
this.table.on('click', '.btn-delete', function (e) {
|
||||||
|
|
||||||
|
self.deleteModal.setData($(this).attr('data-id'));
|
||||||
|
self.deleteModal.show(() => {
|
||||||
|
if ($.isNumeric(self.deleteModal.getData())) {
|
||||||
|
new Ajax(
|
||||||
|
'/serviciosacabado/delete/' + self.deleteModal.getData(),
|
||||||
|
{},
|
||||||
|
{},
|
||||||
|
(response) => {
|
||||||
|
if (response.id) {
|
||||||
|
self.datatableTareas.ajax.reload();
|
||||||
|
popSuccessAlert(response.msg);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
).get();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
this.table.on('click', '.btn-edit', function (e) {
|
||||||
|
window.location.href = '/serviciosacabado/edit/' + $(this).attr('data-id');
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
initDatatableTareas() {
|
initDatatableTareas() {
|
||||||
@ -34,7 +67,7 @@ class listServiciosAcabado{
|
|||||||
bottomEnd: 'paging'
|
bottomEnd: 'paging'
|
||||||
},
|
},
|
||||||
serverSide: true,
|
serverSide: true,
|
||||||
responsive : true,
|
responsive: true,
|
||||||
pageLength: 25,
|
pageLength: 25,
|
||||||
language: {
|
language: {
|
||||||
url: "/themes/vuexy/vendor/libs/datatables-sk/plugins/i18n/es-ES.json"
|
url: "/themes/vuexy/vendor/libs/datatables-sk/plugins/i18n/es-ES.json"
|
||||||
@ -44,14 +77,6 @@ class listServiciosAcabado{
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
#renderActionCell(d, t) {
|
|
||||||
|
|
||||||
let cell = `<div class="d-flex justify-content-start align-items-center gap-1">
|
|
||||||
<span class="edit"><a href="javascript:void(0);"><i class="ti ti-pencil ti-sm btn-edit mx-2" data-id="${d.id}"></i></a></span>
|
|
||||||
<a href="javascript:void(0);"><i class="ti ti-trash ti-sm btn-delete} mx-2" data-id="${d.id}"></i></a>
|
|
||||||
</div>`
|
|
||||||
return cell;
|
|
||||||
}
|
|
||||||
|
|
||||||
#renderBoolCell(d, t) {
|
#renderBoolCell(d, t) {
|
||||||
|
|
||||||
@ -62,7 +87,7 @@ class listServiciosAcabado{
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
$(function() {
|
$(function () {
|
||||||
new listServiciosAcabado().init();
|
new listServiciosAcabado().init();
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user