mirror of
https://git.imnavajas.es/jjimenez/safekat.git
synced 2025-07-25 22:52:08 +00:00
Avance en Servicios de acabado
This commit is contained in:
@ -479,6 +479,13 @@ $routes->group('cosidotapablanda', ['namespace' => 'App\Controllers\Presupuestos
|
||||
});
|
||||
$routes->resource('cosidotapablanda', ['namespace' => 'App\Controllers\Presupuestos', 'controller' => 'Cosidotapablanda', 'except' => 'show,new,create,update']);
|
||||
|
||||
$routes->group('serviciospresupuesto', ['namespace' => 'App\Controllers\Presupuestos'], function ($routes) {
|
||||
$routes->post('datatable', 'PresupuestoAcabados::datatable', ['as' => 'dataTableOfPresupuestoAcabados']);
|
||||
$routes->post('datatable_editor', 'PresupuestoAcabados::datatable_editor', ['as' => 'editorOfPresupuestoAcabados']);
|
||||
});
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* --------------------------------------------------------------------
|
||||
* Additional Routing
|
||||
|
||||
@ -733,8 +733,8 @@ class Cosidotapablanda extends \App\Controllers\GoBaseResourceController
|
||||
$model = model('App\Models\Tarifas\TarifaacabadoModel');
|
||||
$data = $model->getServiciosAcabadoSelector();
|
||||
array_unshift($data, (object)array(
|
||||
"id" => 0,
|
||||
"nombre" => lang('Basic.global.pleaseSelectA', [mb_strtolower(lang('Presupuestos.servicioAcabado'))])
|
||||
"value" => 0,
|
||||
"label" => lang('Basic.global.pleaseSelectA', [mb_strtolower(lang('Presupuestos.servicioAcabado'))])
|
||||
));
|
||||
return $data;
|
||||
}
|
||||
|
||||
@ -28,182 +28,24 @@ class PresupuestoAcabados extends \App\Controllers\GoBaseResourceController
|
||||
protected $modelName = PresupuestoAcabadoModel::class;
|
||||
protected $format = 'json';
|
||||
|
||||
protected static $singularObjectName = 'Contacto de cliente';
|
||||
protected static $singularObjectNameCc = 'contactoDeCliente';
|
||||
protected static $pluralObjectName = 'Contactos de cliente';
|
||||
protected static $pluralObjectNameCc = 'contactosDeCliente';
|
||||
protected static $singularObjectName = 'Presupuesto acabado';
|
||||
protected static $singularObjectNameCc = 'presupuestoAcabado';
|
||||
protected static $pluralObjectName = 'Presupuestos acabado';
|
||||
protected static $pluralObjectNameCc = 'presupuestosAcabado';
|
||||
|
||||
protected static $controllerSlug = 'presupuesto-acabados';
|
||||
|
||||
protected static $viewPath = 'themes/backend/vuexy/form/clientes/contactos/';
|
||||
protected static $viewPath = 'themes/backend/vuexy/form/presupuestos/';
|
||||
|
||||
protected $indexRoute = 'contactoDeClienteList';
|
||||
|
||||
|
||||
public function initController(\CodeIgniter\HTTP\RequestInterface $request, \CodeIgniter\HTTP\ResponseInterface $response, \Psr\Log\LoggerInterface $logger)
|
||||
{
|
||||
$this->viewData['pageTitle'] = lang('ClienteContactos.moduleTitle');
|
||||
$this->viewData['usingSweetAlert'] = true;
|
||||
parent::initController($request, $response, $logger);
|
||||
}
|
||||
|
||||
|
||||
public function index()
|
||||
{
|
||||
|
||||
$viewData = [
|
||||
'currentModule' => static::$controllerSlug,
|
||||
'pageSubTitle' => lang('Basic.global.ManageAllRecords', [lang('ClienteContactos.contactoDeCliente')]),
|
||||
'clienteContactoEntity' => new ClienteContactoEntity(),
|
||||
'usingServerSideDataTable' => true,
|
||||
|
||||
];
|
||||
|
||||
$viewData = array_merge($this->viewData, $viewData); // merge any possible values from the parent controller class
|
||||
|
||||
return view(static::$viewPath . 'viewContactoDeClienteList', $viewData);
|
||||
}
|
||||
|
||||
|
||||
public function add()
|
||||
{
|
||||
|
||||
|
||||
$requestMethod = $this->request->getMethod();
|
||||
|
||||
if ($requestMethod === 'post') :
|
||||
|
||||
$nullIfEmpty = true; // !(phpversion() >= '8.1');
|
||||
|
||||
$postData = $this->request->getPost();
|
||||
|
||||
$sanitizedData = $this->sanitized($postData, $nullIfEmpty);
|
||||
|
||||
|
||||
$noException = true;
|
||||
if ($successfulResult = $this->canValidate()) : // if ($successfulResult = $this->validate($this->formValidationRules) ) :
|
||||
|
||||
|
||||
if ($this->canValidate()) :
|
||||
try {
|
||||
$successfulResult = $this->model->skipValidation(true)->save($sanitizedData);
|
||||
} catch (\Exception $e) {
|
||||
$noException = false;
|
||||
$this->dealWithException($e);
|
||||
}
|
||||
else:
|
||||
$this->viewData['errorMessage'] = lang('Basic.global.formErr1', [lang('Basic.global.record')]);
|
||||
$this->session->setFlashdata('formErrors', $this->model->errors());
|
||||
endif;
|
||||
|
||||
$thenRedirect = true; // Change this to false if you want your user to stay on the form after submission
|
||||
endif;
|
||||
if ($noException && $successfulResult) :
|
||||
|
||||
$id = $this->model->db->insertID();
|
||||
|
||||
$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);
|
||||
else:
|
||||
return $this->redirect2listView('sweet-success', $message);
|
||||
endif;
|
||||
else:
|
||||
$this->session->setFlashData('sweet-success', $message);
|
||||
endif;
|
||||
|
||||
endif; // $noException && $successfulResult
|
||||
|
||||
endif; // ($requestMethod === 'post')
|
||||
|
||||
$this->viewData['clienteContactoEntity'] = isset($sanitizedData) ? new ClienteContactoEntity($sanitizedData) : new ClienteContactoEntity();
|
||||
$this->viewData['clienteList'] = $this->getClienteListItems($clienteContactoEntity->cliente_id ?? null);
|
||||
|
||||
$this->viewData['formAction'] = route_to('createContactoDeCliente');
|
||||
|
||||
$this->viewData['boxTitle'] = lang('Basic.global.addNew') . ' ' . lang('ClienteContactos.moduleTitle') . ' ' . lang('Basic.global.addNewSuffix');
|
||||
|
||||
|
||||
return $this->displayForm(__METHOD__);
|
||||
} // end function add()
|
||||
|
||||
public function edit($requestedId = null)
|
||||
{
|
||||
|
||||
if ($requestedId == null) :
|
||||
return $this->redirect2listView();
|
||||
endif;
|
||||
$id = filter_var($requestedId, FILTER_SANITIZE_URL);
|
||||
$clienteContactoEntity = $this->model->find($id);
|
||||
|
||||
if ($clienteContactoEntity == false) :
|
||||
$message = lang('Basic.global.notFoundWithIdErr', [mb_strtolower(lang('ClienteContactos.contactoDeCliente')), $id]);
|
||||
return $this->redirect2listView('sweet-error', $message);
|
||||
endif;
|
||||
|
||||
$requestMethod = $this->request->getMethod();
|
||||
|
||||
if ($requestMethod === 'post') :
|
||||
|
||||
$nullIfEmpty = true; // !(phpversion() >= '8.1');
|
||||
|
||||
$postData = $this->request->getPost();
|
||||
|
||||
$sanitizedData = $this->sanitized($postData, $nullIfEmpty);
|
||||
|
||||
|
||||
$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('ClienteContactos.contactoDeCliente'))]);
|
||||
$this->session->setFlashdata('formErrors', $this->model->errors());
|
||||
|
||||
endif;
|
||||
|
||||
$clienteContactoEntity->fill($sanitizedData);
|
||||
|
||||
$thenRedirect = false;
|
||||
endif;
|
||||
if ($noException && $successfulResult) :
|
||||
$id = $clienteContactoEntity->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['clienteContactoEntity'] = $clienteContactoEntity;
|
||||
$this->viewData['clienteList'] = $this->getClienteListItems($clienteContactoEntity->cliente_id ?? null);
|
||||
|
||||
$this->viewData['formAction'] = route_to('updateContactoDeCliente', $id);
|
||||
|
||||
$this->viewData['boxTitle'] = lang('Basic.global.edit2') . ' ' . lang('ClienteContactos.moduleTitle') . ' ' . lang('Basic.global.edit3');
|
||||
|
||||
|
||||
return $this->displayForm(__METHOD__, $id);
|
||||
} // end function edit(...)
|
||||
|
||||
|
||||
public function datatable()
|
||||
{
|
||||
if ($this->request->isAJAX()) {
|
||||
@ -217,24 +59,17 @@ class PresupuestoAcabados extends \App\Controllers\GoBaseResourceController
|
||||
$length = $reqData['length'] ?? 5;
|
||||
$search = $reqData['search']['value'];
|
||||
$requestedOrder = $reqData['order']['0']['column'] ?? 1;
|
||||
$order = ClienteContactoModel::SORTABLE[$requestedOrder >= 0 ? $requestedOrder : 1];
|
||||
$order = PresupuestoAcabadoModel::SORTABLE[$requestedOrder >= 0 ? $requestedOrder : 1];
|
||||
$dir = $reqData['order']['0']['dir'] ?? 'asc';
|
||||
|
||||
$id_C = $reqData['id_cliente'] ?? -1;
|
||||
$id_P = $reqData['id_presupuesto'] ?? -1;
|
||||
|
||||
$resourceData = $this->model->getResource("", $id_C)->orderBy($order, $dir)->limit($length, $start)->get()->getResultObject();
|
||||
|
||||
/*$resourceData = $this->model->getResource($search)->orderBy($order, $dir)->limit($length, $start)->get()->getResultObject();
|
||||
foreach ($resourceData as $item) :
|
||||
if (isset($item->apellidos) && strlen($item->apellidos) > 100) :
|
||||
$item->apellidos = character_limiter($item->apellidos, 100);
|
||||
endif;
|
||||
endforeach;*/
|
||||
$resourceData = $this->model->getResource("", $id_P)->orderBy($order, $dir)->limit($length, $start)->get()->getResultObject();
|
||||
|
||||
return $this->respond(Collection::datatable(
|
||||
$resourceData,
|
||||
$this->model->getResource()->countAllResults(),
|
||||
$this->model->getResource("", $id_C)->countAllResults()
|
||||
$this->model->getResource("", $id_P)->countAllResults()
|
||||
));
|
||||
} else {
|
||||
return $this->failUnauthorized('Invalid request', 403);
|
||||
@ -247,30 +82,22 @@ class PresupuestoAcabados extends \App\Controllers\GoBaseResourceController
|
||||
include(APPPATH . "ThirdParty/DatatablesEditor/DataTables.php");
|
||||
|
||||
// Build our Editor instance and process the data coming from _POST
|
||||
$response = Editor::inst( $db, 'cliente_contactos' )
|
||||
$response = Editor::inst( $db, 'presupuesto_acabados' )
|
||||
->fields(
|
||||
Field::inst( 'nombre' )
|
||||
->validator( 'Validate::notEmpty',array(
|
||||
'message' => 'Falta nombre' )
|
||||
'message' => 'Selecciones servicios de acabado' )
|
||||
),
|
||||
Field::inst( 'apellidos' )
|
||||
Field::inst( 'precio_unitario' )
|
||||
->validator( 'Validate::notEmpty',array(
|
||||
'message' => 'Falta apellidos' )
|
||||
),
|
||||
Field::inst( 'cargo' )
|
||||
Field::inst( 'precio_total' )
|
||||
->validator( 'Validate::notEmpty',array(
|
||||
'message' => 'Falta cargp' )
|
||||
),
|
||||
Field::inst( 'telefono' )
|
||||
->validator( 'Validate::notEmpty',array(
|
||||
'message' => 'Falta telefono' )
|
||||
),
|
||||
Field::inst( 'email' )
|
||||
->validator( 'Validate::notEmpty',array(
|
||||
'message' => 'Falta email' )
|
||||
),
|
||||
|
||||
Field::inst( 'cliente_id' ),
|
||||
Field::inst( 'presupuesto_id' ),
|
||||
|
||||
)
|
||||
->validator( function($editor, $action, $data){
|
||||
@ -299,69 +126,6 @@ class PresupuestoAcabados extends \App\Controllers\GoBaseResourceController
|
||||
}
|
||||
}
|
||||
|
||||
public function allItemsSelect()
|
||||
{
|
||||
if ($this->request->isAJAX()) {
|
||||
$onlyActiveOnes = true;
|
||||
$reqVal = $this->request->getPost('val') ?? 'id';
|
||||
$menu = $this->model->getAllForMenu($reqVal . ', nombre', 'nombre', $onlyActiveOnes, false);
|
||||
$nonItem = new \stdClass;
|
||||
$nonItem->id = '';
|
||||
$nonItem->nombre = '- ' . lang('Basic.global.None') . ' -';
|
||||
array_unshift($menu, $nonItem);
|
||||
|
||||
$newTokenHash = csrf_hash();
|
||||
$csrfTokenName = csrf_token();
|
||||
$data = [
|
||||
'menu' => $menu,
|
||||
$csrfTokenName => $newTokenHash
|
||||
];
|
||||
return $this->respond($data);
|
||||
} else {
|
||||
return $this->failUnauthorized('Invalid request', 403);
|
||||
}
|
||||
}
|
||||
|
||||
public function menuItems()
|
||||
{
|
||||
if ($this->request->isAJAX()) {
|
||||
$searchStr = goSanitize($this->request->getPost('searchTerm'))[0];
|
||||
$reqId = goSanitize($this->request->getPost('id'))[0];
|
||||
$reqText = goSanitize($this->request->getPost('text'))[0];
|
||||
$onlyActiveOnes = false;
|
||||
$columns2select = [$reqId ?? 'id', $reqText ?? 'nombre'];
|
||||
$onlyActiveOnes = false;
|
||||
$menu = $this->model->getSelect2MenuItems($columns2select, $columns2select[1], $onlyActiveOnes, $searchStr);
|
||||
$nonItem = new \stdClass;
|
||||
$nonItem->id = '';
|
||||
$nonItem->text = '- ' . lang('Basic.global.None') . ' -';
|
||||
array_unshift($menu, $nonItem);
|
||||
|
||||
$newTokenHash = csrf_hash();
|
||||
$csrfTokenName = csrf_token();
|
||||
$data = [
|
||||
'menu' => $menu,
|
||||
$csrfTokenName => $newTokenHash
|
||||
];
|
||||
return $this->respond($data);
|
||||
} else {
|
||||
return $this->failUnauthorized('Invalid request', 403);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
protected function getClienteListItems($selId = null)
|
||||
{
|
||||
$data = ['' => lang('Basic.global.pleaseSelectA', [mb_strtolower(lang('Clientes.cliente'))])];
|
||||
if (!empty($selId)) :
|
||||
$clienteModel = model('App\Models\Clientes\ClienteModel');
|
||||
|
||||
$selOption = $clienteModel->where('id', $selId)->findColumn('nombre');
|
||||
if (!empty($selOption)) :
|
||||
$data[$selId] = $selOption[0];
|
||||
endif;
|
||||
endif;
|
||||
return $data;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -1,35 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Controllers\Tarifas;
|
||||
use App\Controllers\BaseController;
|
||||
|
||||
|
||||
class Tarifaenvio extends BaseController
|
||||
{
|
||||
function __construct()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public function index()
|
||||
{
|
||||
echo 'Tarifa envio';
|
||||
}
|
||||
|
||||
public function delete()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public function add()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public function edit()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -9,18 +9,15 @@ class PresupuestoAcabadosEntity extends \CodeIgniter\Entity\Entity
|
||||
"id" => null,
|
||||
"presupuesto_id" => null,
|
||||
"tarifa_acabado_id" => null,
|
||||
"nombre" => null,
|
||||
"precio" => null,
|
||||
"precio_unidad" => null,
|
||||
"tirada" => null,
|
||||
"precio_total" => null,
|
||||
"created_at" => null,
|
||||
"updated_at" => null,
|
||||
];
|
||||
protected $casts = [
|
||||
"presupuesto_id" => "int",
|
||||
"tarifa_acabado_id" => "int",
|
||||
"precio" => "float",
|
||||
"precio_unidad" => "float",
|
||||
"tirada" => "int",
|
||||
"precio_total" => "float",
|
||||
];
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@ -12,7 +12,7 @@ return [
|
||||
'precioMin' => 'Precio Mínimo',
|
||||
'importeFijo' => 'Importe Fijo',
|
||||
'mostrar_en_presupuesto' => 'Mostrar en presupuesto',
|
||||
'tarifaacabado' => 'Tarifas Acabado',
|
||||
'tarifaacabado' => 'Tarifa Acabado',
|
||||
'tarifaacabadoList' => 'Lista Tarifas Acabado',
|
||||
'tarifasacabado' => 'Tarifas Acabado',
|
||||
'updatedAt' => 'Actualizado en',
|
||||
|
||||
@ -14,9 +14,9 @@ class PresupuestoAcabadoModel extends \App\Models\GoBaseModel
|
||||
protected $useAutoIncrement = true;
|
||||
|
||||
const SORTABLE = [
|
||||
0 => "t1.nombre",
|
||||
1 => "t1.precio",
|
||||
2 => "t1.precio_unidad"
|
||||
0 => "t2.nombre",
|
||||
1 => "t1.precio_unidad",
|
||||
2 => "t1.precio_total"
|
||||
];
|
||||
|
||||
protected $allowedFields = ["presupuesto_id", "tarifa_acabado_id", "nombre", "precio", "precio_unidad"];
|
||||
@ -31,38 +31,19 @@ class PresupuestoAcabadoModel extends \App\Models\GoBaseModel
|
||||
public static $labelField = "nombre";
|
||||
|
||||
protected $validationRules = [
|
||||
"precio" => [
|
||||
"label" => "ClienteContactos.precio",
|
||||
"rules" => "trim|max_length[100]",
|
||||
"precio_total" => [
|
||||
"label" => "Presupuestos.precioTotal",
|
||||
"rules" => "decimal|required",
|
||||
],
|
||||
];
|
||||
|
||||
protected $validationMessages = [
|
||||
"precio" => [
|
||||
"max_length" => "ClienteContactos.validation.apellidos.max_length",
|
||||
"precio_total" => [
|
||||
"decimal" => "Presupuestos.validation.decimal",
|
||||
"requerido" => "Presupuestos.validation.decimal",
|
||||
],
|
||||
];
|
||||
|
||||
public function findAllWithClientes(string $selcols = "*", int $limit = null, int $offset = 0)
|
||||
{
|
||||
$sql =
|
||||
"SELECT t1." .
|
||||
$selcols .
|
||||
", t2.nombre AS cliente_id FROM " .
|
||||
$this->table .
|
||||
" t1 LEFT JOIN clientes t2 ON t1.cliente_id = t2.id";
|
||||
if (!is_null($limit) && intval($limit) > 0) {
|
||||
$sql .= " LIMIT " . $limit;
|
||||
}
|
||||
|
||||
if (!is_null($offset) && intval($offset) > 0) {
|
||||
$sql .= " OFFSET " . $offset;
|
||||
}
|
||||
|
||||
$query = $this->db->query($sql);
|
||||
$result = $query->getResultObject();
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get resource data.
|
||||
@ -76,21 +57,19 @@ class PresupuestoAcabadoModel extends \App\Models\GoBaseModel
|
||||
$builder = $this->db
|
||||
->table($this->table . " t1")
|
||||
->select(
|
||||
"t1.id AS id, t1.cargo AS cargo, t1.nombre AS nombre, t1.apellidos AS apellidos, t1.telefono AS telefono, t1.email AS email, t1.cliente_id AS cliente_id"
|
||||
"t1.id AS id, t1.tarifa_acabado_id AS tarifa_acabado_id, t1.precio_unidad AS precio_unidad, t1.precio_total AS precio_total, t2.nombre AS nombre"
|
||||
);
|
||||
|
||||
$builder->where('t1.presupuesto_id', $presupuesto_id);
|
||||
$builder->join("presupuestos t2", "t1.presupuesto_id = t2.id", "left");
|
||||
$builder->join("lg_tarifa_acabado t2", "t1.tarifa_acabado_id = t2.id", "left");
|
||||
|
||||
return empty($search)
|
||||
? $builder
|
||||
: $builder
|
||||
->groupStart()
|
||||
->like("t1.nombre", $search)
|
||||
->orLike("t1.nombre", $search)
|
||||
->orLike("t1.apellidos", $search)
|
||||
->orLike("t1.telefono", $search)
|
||||
->orLike("t1.email", $search)
|
||||
->like("t2.nombre", $search)
|
||||
->orlike("t1.precio_unidad", $search)
|
||||
->orLike("t1.precio_total", $search)
|
||||
->groupEnd();
|
||||
}
|
||||
}
|
||||
|
||||
@ -103,7 +103,7 @@ class TarifaacabadoModel extends \App\Models\GoBaseModel
|
||||
$builder = $this->db
|
||||
->table($this->table . " t1")
|
||||
->select(
|
||||
"t1.id as id, t1.nombre AS nombre"
|
||||
"t1.id as value, t1.nombre AS label"
|
||||
)
|
||||
->where("t1.is_deleted", 0)
|
||||
->where("t1.mostrar_en_presupuesto", 1);
|
||||
|
||||
@ -247,7 +247,7 @@
|
||||
<div class="card accordion-item active">
|
||||
<h2 class="accordion-header" id="headingOne">
|
||||
<button id="accordion-button-int-plana" type="button" class="accordion-button" data-bs-toggle="collapse" data-bs-target="#accordionCompInteriorPlanaTip" aria-expanded="false" aria-controls="accordionCompInteriorPlanaTip">
|
||||
<h6><?= lang("Presupuestos.compInteriorPlana") ?></h4>
|
||||
<h4><?= lang("Presupuestos.compInteriorPlana") ?></h4>
|
||||
</button>
|
||||
</h2>
|
||||
|
||||
@ -301,7 +301,7 @@
|
||||
<div class="card accordion-item active">
|
||||
<h2 class="accordion-header" id="headingTwo">
|
||||
<button type="button" class="accordion-button" data-bs-toggle="collapse" data-bs-target="#accordionCompInteriorRotativaTip" aria-expanded="false" aria-controls="accordionCompInteriorRotativaTip">
|
||||
<h6><?= lang("Presupuestos.compInteriorRotativa") ?></h4>
|
||||
<h4><?= lang("Presupuestos.compInteriorRotativa") ?></h4>
|
||||
</button>
|
||||
</h2>
|
||||
|
||||
@ -353,7 +353,7 @@
|
||||
<div class="card accordion-item active">
|
||||
<h2 class="accordion-header" id="headingThree">
|
||||
<button type="button" class="accordion-button" data-bs-toggle="collapse" data-bs-target="#accordionCompCubiertaSobrecubiertaTip" aria-expanded="false" aria-controls="accordionCompCubiertaSobrecubiertaTip">
|
||||
<h6><?= lang("Presupuestos.cubierta") ?></h4>
|
||||
<h4><?= lang("Presupuestos.cubierta") ?></h4>
|
||||
</button>
|
||||
</h2>
|
||||
|
||||
|
||||
@ -64,7 +64,18 @@
|
||||
</ul>
|
||||
<div class="tab-content">
|
||||
<div class="tab-pane fade show active" id="servicios-acabado" role="tabpanel">
|
||||
<h3>Proximanente</h3>
|
||||
<table id="tableOfServiciosAcabado" class="table table-striped table-hover" style="width: 100%;">
|
||||
<thead>
|
||||
<tr>
|
||||
<th><?= lang('Tarifaacabado.tarifaacabado') ?></th>
|
||||
<th><?= lang('Presupuestos.precioUnidad') ?></th>
|
||||
<th><?= lang('Presupuestos.precioTotal') ?></th>
|
||||
<th class="text-nowrap"><?= lang('Basic.global.Action') ?></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
<div class="tab-pane fade" id="servicios-preimpresion" role="tabpanel">
|
||||
@ -85,4 +96,185 @@
|
||||
</div> <!-- //.accordion-body -->
|
||||
</div> <!-- //.accordion-collapse -->
|
||||
</div> <!-- //.accordion-item -->
|
||||
</div> <!-- //.accordion -->
|
||||
</div> <!-- //.accordion -->
|
||||
|
||||
|
||||
|
||||
|
||||
<!------------------------------------------------------->
|
||||
<!-- Código JS comportamiento tabla servicios acabado. -->
|
||||
<!------------------------------------------------------->
|
||||
<?= $this->section("additionalInlineJs") ?>
|
||||
|
||||
const lastColNr = $('#tableOfServiciosAcabado').find("tr:first th").length - 1;
|
||||
const url = window.location.href;
|
||||
const url_parts = url.split('/');
|
||||
if(url_parts[url_parts.length-2] == 'edit'){
|
||||
id = url_parts[url_parts.length-1];
|
||||
}
|
||||
else{
|
||||
id = 200000; // id=-1
|
||||
}
|
||||
|
||||
const actionBtns = function(data) {
|
||||
return `
|
||||
<span class="edit"><a href="javascript:void(0);"><i class="ti ti-pencil ti-sm btn-edit mx-2" data-id="${data.id}"></i></a></span>
|
||||
<a href="javascript:void(0);"><i class="ti ti-trash ti-sm btn-delete mx-2" data-id="${data.id}" data-bs-toggle="modal" data-bs-target="#confirm2delete"></i></a>
|
||||
<span class="cancel"></span>
|
||||
`;
|
||||
};
|
||||
|
||||
editor = new $.fn.dataTable.Editor( {
|
||||
ajax: {
|
||||
url: "<?= route_to('editorOfPresupuestoAcabados') ?>",
|
||||
headers: {
|
||||
<?= csrf_token() ?? "token" ?> : <?= csrf_token() ?>v,
|
||||
},
|
||||
},
|
||||
table : "#tableOfServiciosAcabado",
|
||||
idSrc: 'id',
|
||||
fields: [ {
|
||||
"name": "tarifa_acabado_id",
|
||||
"type": "select"
|
||||
}, {
|
||||
"name": "precio_unitario"
|
||||
}, {
|
||||
"name": "precio_total"
|
||||
}, {
|
||||
"name": "presupuesto_id",
|
||||
"type": "hidden"
|
||||
},
|
||||
]
|
||||
} );
|
||||
|
||||
// Generación de la lista de servicios de acabado (id, nombre)
|
||||
const acabadosList = <?php echo json_encode($serviciosAcabado); ?>;
|
||||
editor.field( 'tarifa_acabado_id' ).update( acabadosList );
|
||||
|
||||
editor.on( 'preSubmit', function ( e, d, type ) {
|
||||
if ( type === 'create'){
|
||||
d.data[0]['presupuesto_id'] = id;
|
||||
}
|
||||
else if(type === 'edit' ) {
|
||||
for (v in d.data){
|
||||
d.data[v]['presupuesto_id'] = id;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
editor.on( 'postSubmit', function ( e, json, data, action ) {
|
||||
yeniden(json.<?= csrf_token() ?>);
|
||||
});
|
||||
|
||||
editor.on( 'submitSuccess', function ( e, json, data, action ) {
|
||||
theTable.clearPipeline();
|
||||
theTable.draw();
|
||||
});
|
||||
|
||||
// Activate an inline edit on click of a table cell
|
||||
$('#tableOfServiciosAcabado').on( 'click', 'tbody span.edit', function (e) {
|
||||
editor.inline(
|
||||
theTable.cells(this.parentNode.parentNode, '*').nodes(),
|
||||
{
|
||||
cancelHtml: '<a href="javascript:void(0);"><i class="ti ti-x"></i></a>',
|
||||
cancelTrigger: 'span.cancel',
|
||||
submitHtml: '<a href="javascript:void(0);"><i class="ti ti-device-floppy"></i></a>',
|
||||
submitTrigger: 'span.edit',
|
||||
submit: 'allIfChanged'
|
||||
}
|
||||
);
|
||||
} );
|
||||
|
||||
|
||||
// Delete row
|
||||
$('#tableOfServiciosAcabado').on( 'click', 'tbody span.remove', function (e) {
|
||||
|
||||
Swal.fire({
|
||||
title: '<?= lang('Basic.global.sweet.sureToDeleteTitle', [mb_strtolower(lang('Basic.global.sweet.line'))]) ?>',
|
||||
text: '<?= lang('Basic.global.sweet.sureToDeleteText') ?>',
|
||||
icon: 'warning',
|
||||
showCancelButton: true,
|
||||
confirmButtonColor: '#3085d6',
|
||||
confirmButtonText: '<?= lang('Basic.global.sweet.deleteConfirmationButton') ?>',
|
||||
cancelButtonText: '<?= lang('Basic.global.Cancel') ?>',
|
||||
cancelButtonColor: '#d33'
|
||||
})
|
||||
.then((result) => {
|
||||
const dataId = $(this).data('id');
|
||||
const row = $(this).closest('tr');
|
||||
if (result.value) {
|
||||
editor
|
||||
.create( false )
|
||||
.edit( this.parentNode, false)
|
||||
.set( 'deleted_at', new Date().toISOString().slice(0, 19).replace('T', ' ') )
|
||||
.set( 'is_deleted', 1 )
|
||||
.submit();
|
||||
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
var theTable = $('#tableOfServiciosAcabado').DataTable( {
|
||||
serverSide: true,
|
||||
processing: true,
|
||||
autoWidth: true,
|
||||
responsive: true,
|
||||
lengthMenu: [ 5, 10, 25],
|
||||
order: [[ 0, "asc" ], [ 1, "asc" ]],
|
||||
pageLength: 10,
|
||||
lengthChange: true,
|
||||
searching: false,
|
||||
paging: true,
|
||||
info: false,
|
||||
dom: '<"mt-4"><"float-start"l><t><"mt-4 mb-3"p>',
|
||||
ajax : $.fn.dataTable.pipeline( {
|
||||
url: '<?= route_to('dataTableOfPresupuestoAcabados') ?>',
|
||||
data: {
|
||||
id_presupuesto: id,
|
||||
},
|
||||
method: 'POST',
|
||||
headers: {'X-Requested-With': 'XMLHttpRequest'},
|
||||
async: true,
|
||||
}),
|
||||
columns: [
|
||||
{'data': 'tarifa_acabado_id',
|
||||
render: function(data, type, row, meta) {
|
||||
var value = acabadosList.find(element => element.value === data);
|
||||
return value['label'];
|
||||
},
|
||||
},
|
||||
{ 'data': 'precio_unidad' },
|
||||
{ 'data': 'precio_total' },
|
||||
{
|
||||
data: actionBtns,
|
||||
className: 'row-edit dt-center'
|
||||
}
|
||||
],
|
||||
columnDefs: [
|
||||
{
|
||||
orderable: false,
|
||||
searchable: false,
|
||||
targets: [lastColNr]
|
||||
},
|
||||
{
|
||||
"orderData": [ 0, 1 ],
|
||||
"targets": 0
|
||||
},
|
||||
|
||||
],
|
||||
language: {
|
||||
url: "//cdn.datatables.net/plug-ins/1.13.4/i18n/<?= config('Basics')->i18n ?>.json"
|
||||
},
|
||||
buttons: [ {
|
||||
className: 'btn btn-primary float-end me-sm-3 me-1',
|
||||
extend: "createInline",
|
||||
editor: editor,
|
||||
formOptions: {
|
||||
submitTrigger: -1,
|
||||
submitHtml: '<i class="ti ti-device-floppy"/>'
|
||||
}
|
||||
} ]
|
||||
} );
|
||||
|
||||
<?= $this->endSection() ?>
|
||||
|
||||
|
||||
@ -477,11 +477,9 @@
|
||||
<?= $this->endSection() ?>
|
||||
|
||||
<?=$this->section('css') ?>
|
||||
|
||||
<link rel="stylesheet" href="<?= site_url('themes/vuexy/css/datatables-editor/editor.dataTables.min.css') ?>">
|
||||
<link rel="stylesheet" href="https://cdn.datatables.net/buttons/2.2.3/css/buttons.bootstrap5.min.css">
|
||||
<link rel="stylesheet" href="<?= site_url('themes/vuexy/css/sk-datatables.css') ?>">
|
||||
|
||||
<?=$this->endSection() ?>
|
||||
|
||||
<?= $this->section('additionalExternalJs') ?>
|
||||
@ -493,6 +491,8 @@
|
||||
<?= $this->section('additionalExternalJs') ?>
|
||||
<script src="https://cdn.datatables.net/buttons/2.2.3/js/dataTables.buttons.min.js"></script>
|
||||
<script src="https://cdn.datatables.net/buttons/2.2.3/js/buttons.bootstrap5.min.js"></script>
|
||||
<script src="https://cdn.datatables.net/select/1.7.0/js/dataTables.select.min.js"></script>
|
||||
<script src="https://cdn.datatables.net/buttons/2.2.3/js/buttons.html5.min.js"></script>
|
||||
<script src="https://cdn.datatables.net/buttons/2.2.3/js/buttons.print.min.js"></script>
|
||||
<script src="<?= site_url('themes/vuexy/js/datatables-editor/dataTables.editor.min.js') ?>"></script>
|
||||
<?=$this->endSection() ?>
|
||||
Reference in New Issue
Block a user