mirror of
https://git.imnavajas.es/jjimenez/safekat.git
synced 2025-07-25 22:52:08 +00:00
trabajando en editar plantillas
This commit is contained in:
@ -405,11 +405,13 @@ $routes->group('clienteplantillaprecios', ['namespace' => 'App\Controllers\Clien
|
|||||||
$routes->get('add', 'Clienteplantillaprecios::add', ['as' => 'newClienteplantillaprecios']);
|
$routes->get('add', 'Clienteplantillaprecios::add', ['as' => 'newClienteplantillaprecios']);
|
||||||
$routes->post('add', 'Clienteplantillaprecios::add', ['as' => 'createClienteplantillaprecios']);
|
$routes->post('add', 'Clienteplantillaprecios::add', ['as' => 'createClienteplantillaprecios']);
|
||||||
$routes->post('edit/(:num)', 'Clienteplantillaprecios::edit/$1', ['as' => 'updateClienteplantillaprecios']);
|
$routes->post('edit/(:num)', 'Clienteplantillaprecios::edit/$1', ['as' => 'updateClienteplantillaprecios']);
|
||||||
|
$routes->get('edit/(:num)', 'Clienteplantillaprecios::edit/$1', ['as' => 'updateClienteplantillaprecios']);
|
||||||
$routes->get('delete/(:num)', 'Clienteplantillaprecios::delete/$1', ['as' => 'deleteClienteplantillaprecios']);
|
$routes->get('delete/(:num)', 'Clienteplantillaprecios::delete/$1', ['as' => 'deleteClienteplantillaprecios']);
|
||||||
$routes->post('datatable', 'Clienteplantillaprecios::datatable', ['as' => 'dataTableOfClientesplantillaprecios']);
|
$routes->post('datatable', 'Clienteplantillaprecios::datatable', ['as' => 'dataTableOfClientesplantillaprecios']);
|
||||||
$routes->get('menuitems', 'Clienteplantillaprecios::menuItems', ['as' => 'menuItemsOfClienteplantillaprecios']);
|
$routes->get('menuitems', 'Clienteplantillaprecios::menuItems', ['as' => 'menuItemsOfClienteplantillaprecios']);
|
||||||
|
$routes->post('update/(:num)', 'Clienteplantillaprecios::update/$1', ['as' => 'updateClienteplantillaprecios']);
|
||||||
});
|
});
|
||||||
$routes->resource('clienteplantillaprecios', ['namespace' => 'App\Controllers\Clientes', 'controller' => 'Clienteplantillaprecios', 'except' => 'show,new,create,update']);
|
$routes->resource('clienteplantillaprecios', ['namespace' => 'App\Controllers\Clientes', 'controller' => 'Clienteplantillaprecios', 'except' => 'show,new,create']);
|
||||||
|
|
||||||
|
|
||||||
$routes->group('clienteplantillaprecioslineas', ['namespace' => 'App\Controllers\Clientes'], function ($routes) {
|
$routes->group('clienteplantillaprecioslineas', ['namespace' => 'App\Controllers\Clientes'], function ($routes) {
|
||||||
|
|||||||
@ -90,29 +90,24 @@ class ClientePrecios extends \App\Controllers\BaseResourceController
|
|||||||
}
|
}
|
||||||
$start = $reqData['start'] ?? 0;
|
$start = $reqData['start'] ?? 0;
|
||||||
$length = $reqData['length'] ?? 5;
|
$length = $reqData['length'] ?? 5;
|
||||||
$requestedOrder = $reqData['order']['0']['column'] ?? 0;
|
|
||||||
$requestedOrder2 = $reqData['order']['1']['column'] ?? $requestedOrder;
|
$requestedOrder = $reqData['order'] ?? [];
|
||||||
$requestedOrder3 = $reqData['order']['2']['column'] ?? $requestedOrder;
|
|
||||||
$requestedOrder4 = $reqData['order']['3']['column'] ?? $requestedOrder;
|
|
||||||
$requestedOrder5 = $reqData['order']['4']['column'] ?? $requestedOrder;
|
|
||||||
$order = ClientePreciosModel::SORTABLE[$requestedOrder > 0 ? $requestedOrder : 0];
|
|
||||||
$order2 = ClientePreciosModel::SORTABLE[$requestedOrder2 >= 0 ? $requestedOrder2 : $requestedOrder];
|
|
||||||
$order3 = ClientePreciosModel::SORTABLE[$requestedOrder3 >= 0 ? $requestedOrder3 : $requestedOrder];
|
|
||||||
$order4 = ClientePreciosModel::SORTABLE[$requestedOrder4 >= 0 ? $requestedOrder4 : $requestedOrder];
|
|
||||||
$order5 = ClientePreciosModel::SORTABLE[$requestedOrder4 >= 0 ? $requestedOrder5 : $requestedOrder];
|
|
||||||
$dir = $reqData['order']['0']['dir'] ?? 'asc';
|
|
||||||
$dir2 = $reqData['order']['1']['dir'] ?? $dir;
|
|
||||||
$dir3 = $reqData['order']['2']['dir'] ?? $dir;
|
|
||||||
$dir4 = $reqData['order']['3']['dir'] ?? $dir;
|
|
||||||
$dir5 = $reqData['order']['4']['dir'] ?? $dir;
|
|
||||||
|
|
||||||
$searchValues = get_filter_datatables_columns($reqData);
|
$searchValues = get_filter_datatables_columns($reqData);
|
||||||
|
|
||||||
$cliente_id = $reqData['cliente_id'] ?? 0;
|
$cliente_id = $reqData['cliente_id'] ?? 0;
|
||||||
|
|
||||||
$resourceData = $this->model->getResource($searchValues, $cliente_id)
|
$resourceData = $this->model->getResource($searchValues, $cliente_id);
|
||||||
->orderBy($order, $dir)->orderBy($order2, $dir2)->orderBy($order3, $dir3)->orderBy($order4, $dir4)->orderBy($order5, $dir5)
|
foreach ($requestedOrder as $order) {
|
||||||
->limit($length, $start)->get()->getResultObject();
|
$column = $order['column'] ?? 0;
|
||||||
|
$dir = $order['dir'] ?? 'asc';
|
||||||
|
$orderColumn = ClientePreciosModel::SORTABLE[$column] ?? null;
|
||||||
|
if ($orderColumn) {
|
||||||
|
$resourceData->orderBy($orderColumn, $dir);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$resourceData = $resourceData->limit($length, $start)->get()->getResultObject();
|
||||||
|
|
||||||
return $this->respond(Collection::datatable(
|
return $this->respond(Collection::datatable(
|
||||||
$resourceData,
|
$resourceData,
|
||||||
$this->model->getResource($searchValues, $cliente_id)->countAllResults(),
|
$this->model->getResource($searchValues, $cliente_id)->countAllResults(),
|
||||||
|
|||||||
@ -72,9 +72,6 @@ class Clienteplantillaprecios extends \App\Controllers\BaseResourceController
|
|||||||
public function update($requestedId = null)
|
public function update($requestedId = null)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
if ($this->request->getPost()):
|
|
||||||
|
|
||||||
if ($requestedId == null):
|
if ($requestedId == null):
|
||||||
return;
|
return;
|
||||||
endif;
|
endif;
|
||||||
@ -89,7 +86,6 @@ class Clienteplantillaprecios extends \App\Controllers\BaseResourceController
|
|||||||
|
|
||||||
return $this->respond($data);
|
return $this->respond($data);
|
||||||
|
|
||||||
endif; // ($requestMethod === 'post')
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -262,16 +258,16 @@ class Clienteplantillaprecios extends \App\Controllers\BaseResourceController
|
|||||||
}
|
}
|
||||||
$start = $reqData['start'] ?? 0;
|
$start = $reqData['start'] ?? 0;
|
||||||
$length = $reqData['length'] ?? 5;
|
$length = $reqData['length'] ?? 5;
|
||||||
$search = $reqData['search']['value'];
|
$searchValues = get_filter_datatables_columns($reqData);
|
||||||
$requestedOrder = $reqData['order']['0']['column'] ?? 1;
|
$requestedOrder = $reqData['order']['0']['column'] ?? 1;
|
||||||
$order = ClientePlantillaPreciosModel::SORTABLE[$requestedOrder > 0 ? $requestedOrder : 0];
|
$order = ClientePlantillaPreciosModel::SORTABLE[$requestedOrder > 0 ? $requestedOrder : 0];
|
||||||
$dir = $reqData['order']['0']['dir'] ?? 'asc';
|
$dir = $reqData['order']['0']['dir'] ?? 'asc';
|
||||||
|
|
||||||
$resourceData = $this->model->getResource($search)->orderBy($order, $dir)->limit($length, $start)->get()->getResultObject();
|
$resourceData = $this->model->getResource($searchValues)->orderBy($order, $dir)->limit($length, $start)->get()->getResultObject();
|
||||||
return $this->respond(Collection::datatable(
|
return $this->respond(Collection::datatable(
|
||||||
$resourceData,
|
$resourceData,
|
||||||
$this->model->getResource()->countAllResults(),
|
$this->model->getResource()->countAllResults(),
|
||||||
$this->model->getResource($search)->countAllResults()
|
$this->model->getResource($searchValues)->countAllResults()
|
||||||
));
|
));
|
||||||
} else {
|
} else {
|
||||||
return $this->failUnauthorized('Invalid request', 403);
|
return $this->failUnauthorized('Invalid request', 403);
|
||||||
|
|||||||
@ -93,31 +93,27 @@ class Clienteplantillaprecioslineas extends \App\Controllers\BaseResourceControl
|
|||||||
}
|
}
|
||||||
$start = $reqData['start'] ?? 0;
|
$start = $reqData['start'] ?? 0;
|
||||||
$length = $reqData['length'] ?? 5;
|
$length = $reqData['length'] ?? 5;
|
||||||
$requestedOrder = $reqData['order']['0']['column'] ?? 0;
|
|
||||||
$requestedOrder2 = $reqData['order']['1']['column'] ?? $requestedOrder;
|
$requestedOrder = $reqData['order'] ?? [];
|
||||||
$requestedOrder3 = $reqData['order']['2']['column'] ?? $requestedOrder;
|
$searchValues = get_filter_datatables_columns($reqData);
|
||||||
$requestedOrder4 = $reqData['order']['3']['column'] ?? $requestedOrder;
|
|
||||||
$requestedOrder5 = $reqData['order']['4']['column'] ?? $requestedOrder;
|
|
||||||
$order = ClientePlantillaPreciosLineasModel::SORTABLE[$requestedOrder > 0 ? $requestedOrder : 0];
|
|
||||||
$order2 = ClientePlantillaPreciosLineasModel::SORTABLE[$requestedOrder2 >= 0 ? $requestedOrder2 : $requestedOrder];
|
|
||||||
$order3 = ClientePlantillaPreciosLineasModel::SORTABLE[$requestedOrder3 >= 0 ? $requestedOrder3 : $requestedOrder];
|
|
||||||
$order4 = ClientePlantillaPreciosLineasModel::SORTABLE[$requestedOrder4 >= 0 ? $requestedOrder4 : $requestedOrder];
|
|
||||||
$order5 = ClientePlantillaPreciosLineasModel::SORTABLE[$requestedOrder4 >= 0 ? $requestedOrder5 : $requestedOrder];
|
|
||||||
$dir = $reqData['order']['0']['dir'] ?? 'asc';
|
|
||||||
$dir2 = $reqData['order']['1']['dir'] ?? $dir;
|
|
||||||
$dir3 = $reqData['order']['2']['dir'] ?? $dir;
|
|
||||||
$dir4= $reqData['order']['3']['dir'] ?? $dir;
|
|
||||||
$dir5= $reqData['order']['4']['dir'] ?? $dir;
|
|
||||||
|
|
||||||
$plantilla_id = $reqData['plantilla_id'] ?? 0;
|
$plantilla_id = $reqData['plantilla_id'] ?? 0;
|
||||||
|
|
||||||
$resourceData = $this->model->getResource($plantilla_id)
|
$resourceData = $this->model->getResource($searchValues, $plantilla_id);
|
||||||
->orderBy($order, $dir)->orderBy($order2, $dir2)->orderBy($order3, $dir3)->orderBy($order4, $dir4)->orderBy($order5, $dir5)
|
foreach ($requestedOrder as $order) {
|
||||||
->limit($length, $start)->get()->getResultObject();
|
$column = $order['column'] ?? 0;
|
||||||
|
$dir = $order['dir'] ?? 'asc';
|
||||||
|
$orderColumn = ClientePlantillaPreciosLineasModel::SORTABLE[$column] ?? null;
|
||||||
|
if ($orderColumn) {
|
||||||
|
$resourceData->orderBy($orderColumn, $dir);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$resourceData = $resourceData->limit($length, $start)->get()->getResultObject();
|
||||||
|
|
||||||
return $this->respond(Collection::datatable(
|
return $this->respond(Collection::datatable(
|
||||||
$resourceData,
|
$resourceData,
|
||||||
$this->model->getResource($plantilla_id)->countAllResults(),
|
$this->model->getResource([], $plantilla_id)->countAllResults(),
|
||||||
$this->model->getResource($plantilla_id)->countAllResults()
|
$this->model->getResource($searchValues, $plantilla_id)->countAllResults()
|
||||||
));
|
));
|
||||||
} else {
|
} else {
|
||||||
return $this->failUnauthorized('Invalid request', 403);
|
return $this->failUnauthorized('Invalid request', 403);
|
||||||
|
|||||||
@ -7,14 +7,16 @@ class ClientePlantillaPreciosLineasModel extends \App\Models\BaseModel
|
|||||||
protected $table = "cliente_plantilla_precios_lineas";
|
protected $table = "cliente_plantilla_precios_lineas";
|
||||||
|
|
||||||
const SORTABLE = [
|
const SORTABLE = [
|
||||||
0 => "t1.tipo",
|
0 => "t1.id",
|
||||||
1 => "t1.tipo_maquina",
|
1 => "t1.tipo",
|
||||||
2 => "t1.tipo_impresion",
|
2 => "t1.tipo_maquina",
|
||||||
3 => "t1.tiempo_min",
|
3 => "t1.tipo_impresion",
|
||||||
4 => "t1.tiempo_max",
|
4 => "t1.tiempo_min",
|
||||||
5 => "t1.precio_hora",
|
5 => "t1.tiempo_max",
|
||||||
6 => "t1.margen",
|
6 => "t1.precio_hora",
|
||||||
|
7 => "t1.margen",
|
||||||
|
8 => "CONCAT(t2.first_name, ' ', t2.last_name)",
|
||||||
|
9 => "t1.updated_at",
|
||||||
];
|
];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -113,10 +115,20 @@ class ClientePlantillaPreciosLineasModel extends \App\Models\BaseModel
|
|||||||
|
|
||||||
|
|
||||||
function delete_values($plantilla_id = 0){
|
function delete_values($plantilla_id = 0){
|
||||||
|
$datetime = (new \CodeIgniter\I18n\Time("now"));
|
||||||
|
$date_value = $datetime->format('Y-m-d H:i:s');
|
||||||
|
|
||||||
$this->db
|
$this->db
|
||||||
->table($this->table . " t1")
|
->table($this->table . " t1")
|
||||||
->where('t1.plantilla_id', $plantilla_id)
|
->where('t1.plantilla_id', $plantilla_id)
|
||||||
->set('is_deleted', 1)
|
->set('is_deleted', 1)
|
||||||
|
->set('deleted_at', $date_value)
|
||||||
|
->update();
|
||||||
|
|
||||||
|
$this->db
|
||||||
|
->table('cliente_precios' . " t1")
|
||||||
|
->where('t1.plantilla_id', $plantilla_id)
|
||||||
|
->set('plantilla_id', null)
|
||||||
->update();
|
->update();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -127,14 +139,15 @@ class ClientePlantillaPreciosLineasModel extends \App\Models\BaseModel
|
|||||||
*
|
*
|
||||||
* @return \CodeIgniter\Database\BaseBuilder
|
* @return \CodeIgniter\Database\BaseBuilder
|
||||||
*/
|
*/
|
||||||
public function getResource($plantilla_id = -1)
|
public function getResource($search = [], $plantilla_id = -1)
|
||||||
{
|
{
|
||||||
$builder = $this->db
|
$builder = $this->db
|
||||||
->table($this->table . " t1")
|
->table($this->table . " t1")
|
||||||
->select(
|
->select(
|
||||||
"t1.id as id, t1.tipo AS tipo, t1.tipo_maquina AS tipo_maquina, t1.tipo_impresion AS tipo_impresion,
|
"t1.id as id, t1.tipo AS tipo, t1.tipo_maquina AS tipo_maquina, t1.tipo_impresion AS tipo_impresion,
|
||||||
t1.tiempo_min AS tiempo_min, t1.tiempo_max AS tiempo_max, t1.precio_hora AS precio_hora, t1.margen AS margen,
|
t1.tiempo_min AS tiempo_min, t1.tiempo_max AS tiempo_max, t1.precio_hora AS precio_hora, t1.margen AS margen,
|
||||||
t1.user_updated_id AS user_updated_id, t1.updated_at AS updated_at, CONCAT(t2.first_name, ' ', t2.last_name) AS user_updated"
|
t1.user_updated_id AS user_updated_id, t1.updated_at AS updated_at, CONCAT(t2.first_name, ' ', t2.last_name) AS user_updated,
|
||||||
|
t1.id AS DT_RowId"
|
||||||
);
|
);
|
||||||
|
|
||||||
$builder->join("users t2", "t1.user_updated_id = t2.id", "left");
|
$builder->join("users t2", "t1.user_updated_id = t2.id", "left");
|
||||||
@ -142,8 +155,19 @@ class ClientePlantillaPreciosLineasModel extends \App\Models\BaseModel
|
|||||||
$builder->where('t1.is_deleted', 0);
|
$builder->where('t1.is_deleted', 0);
|
||||||
$builder->where('t1.plantilla_id', $plantilla_id);
|
$builder->where('t1.plantilla_id', $plantilla_id);
|
||||||
|
|
||||||
|
if (empty($search))
|
||||||
return $builder;
|
return $builder;
|
||||||
|
else {
|
||||||
|
$builder->groupStart();
|
||||||
|
foreach ($search as $col_search) {
|
||||||
|
if ($col_search[0] > 0 && $col_search[0] < 4)
|
||||||
|
$builder->where(self::SORTABLE[$col_search[0]], $col_search[2]);
|
||||||
|
else
|
||||||
|
$builder->like(self::SORTABLE[$col_search[0]], $col_search[2]);
|
||||||
|
}
|
||||||
|
$builder->groupEnd();
|
||||||
|
return $builder;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function checkIntervals($data = [], $id_linea = null, $plantilla_id = null){
|
public function checkIntervals($data = [], $id_linea = null, $plantilla_id = null){
|
||||||
|
|||||||
@ -7,7 +7,8 @@ class ClientePlantillaPreciosModel extends \App\Models\BaseModel
|
|||||||
protected $table = "cliente_plantilla_precios";
|
protected $table = "cliente_plantilla_precios";
|
||||||
|
|
||||||
const SORTABLE = [
|
const SORTABLE = [
|
||||||
0 => "t1.nombre",
|
0 => "t1.id",
|
||||||
|
1 => "t1.nombre",
|
||||||
];
|
];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -48,11 +49,11 @@ class ClientePlantillaPreciosModel extends \App\Models\BaseModel
|
|||||||
/**
|
/**
|
||||||
* Get resource data.
|
* Get resource data.
|
||||||
*
|
*
|
||||||
* @param string $search
|
* @param array $search
|
||||||
*
|
*
|
||||||
* @return \CodeIgniter\Database\BaseBuilder
|
* @return \CodeIgniter\Database\BaseBuilder
|
||||||
*/
|
*/
|
||||||
public function getResource(string $search = "", $cliente_id = -1)
|
public function getResource($search = [])
|
||||||
{
|
{
|
||||||
$builder = $this->db
|
$builder = $this->db
|
||||||
->table($this->table . " t1")
|
->table($this->table . " t1")
|
||||||
@ -62,13 +63,16 @@ class ClientePlantillaPreciosModel extends \App\Models\BaseModel
|
|||||||
|
|
||||||
$builder->where('t1.is_deleted', 0);
|
$builder->where('t1.is_deleted', 0);
|
||||||
|
|
||||||
|
if (empty($search))
|
||||||
return empty($search)
|
return $builder;
|
||||||
? $builder
|
else {
|
||||||
: $builder
|
$builder->groupStart();
|
||||||
->groupStart()
|
foreach ($search as $col_search) {
|
||||||
->like("t1.nombre", $search)
|
$builder->like(self::SORTABLE[$col_search[0]], $col_search[2]);
|
||||||
->groupEnd();
|
}
|
||||||
|
$builder->groupEnd();
|
||||||
|
return $builder;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -880,74 +880,6 @@ $(document).on('click', '.btn-remove', function(e) {
|
|||||||
<?=$this->endSection() ?>
|
<?=$this->endSection() ?>
|
||||||
|
|
||||||
|
|
||||||
<?= $this->section("additionalInlineJs") ?>
|
|
||||||
/**************************************
|
|
||||||
Tarifas cliente
|
|
||||||
***************************************/
|
|
||||||
/*
|
|
||||||
$('#plantillas').select2({
|
|
||||||
allowClear: false,
|
|
||||||
ajax: {
|
|
||||||
url: '<?= route_to("menuItemsOfClienteplantillaprecios") ?>',
|
|
||||||
type: 'post',
|
|
||||||
dataType: 'json',
|
|
||||||
|
|
||||||
data: function (params) {
|
|
||||||
return {
|
|
||||||
id: 'id',
|
|
||||||
text: 'nombre',
|
|
||||||
searchTerm: params.term,
|
|
||||||
<?= csrf_token() ?? "token" ?> : <?= csrf_token() ?>v
|
|
||||||
};
|
|
||||||
},
|
|
||||||
delay: 60,
|
|
||||||
processResults: function (response) {
|
|
||||||
|
|
||||||
yeniden(response.<?= csrf_token() ?>);
|
|
||||||
|
|
||||||
return {
|
|
||||||
results: response.menu
|
|
||||||
};
|
|
||||||
},
|
|
||||||
|
|
||||||
cache: true
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
$('#plantillas').on('change.select2', function(){
|
|
||||||
const data = $('#plantillas').select2('data');
|
|
||||||
if(data.length>0){
|
|
||||||
const domain = window.location.origin
|
|
||||||
fetch(domain + "/clientes/clienteprecios/update/" + id , {
|
|
||||||
method: "POST",
|
|
||||||
body: JSON.stringify({
|
|
||||||
plantilla_id: data[0].id,
|
|
||||||
<?= csrf_token() ?? "token" ?> : <?= csrf_token() ?>v
|
|
||||||
}),
|
|
||||||
headers: {
|
|
||||||
"Content-type": "application/json; charset=UTF-8"
|
|
||||||
}
|
|
||||||
}).then(function(){
|
|
||||||
theTablePrecios.clearPipeline();
|
|
||||||
theTablePrecios.draw();
|
|
||||||
})
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
});
|
|
||||||
|
|
||||||
|
|
||||||
$('#convert2template').on('click', function(){
|
|
||||||
var newAddDialog = $('#convert2Template')
|
|
||||||
newAddDialog.modal("show");
|
|
||||||
|
|
||||||
})
|
|
||||||
|
|
||||||
<?= $this->endSection() ?>
|
|
||||||
|
|
||||||
|
|
||||||
<?= $this->section("additionalInlineJs") ?>
|
<?= $this->section("additionalInlineJs") ?>
|
||||||
/****************************************
|
/****************************************
|
||||||
Direcciones cliente
|
Direcciones cliente
|
||||||
|
|||||||
@ -16,12 +16,8 @@
|
|||||||
<?= !empty($validation->getErrors()) ? $validation->listErrors("bootstrap_style") : "" ?>
|
<?= !empty($validation->getErrors()) ? $validation->listErrors("bootstrap_style") : "" ?>
|
||||||
<?= view("themes/vuexy/form/clientes/plantillaprecios/_ClienteplantillapreciosFormItems") ?>
|
<?= view("themes/vuexy/form/clientes/plantillaprecios/_ClienteplantillapreciosFormItems") ?>
|
||||||
<div class="pt-4">
|
<div class="pt-4">
|
||||||
<input
|
<input type="submit" class="btn btn-primary float-start me-sm-3 me-1" name="save"
|
||||||
type="submit"
|
value="<?= lang("Basic.global.Save") ?>" />
|
||||||
class="btn btn-primary float-start me-sm-3 me-1"
|
|
||||||
name="save"
|
|
||||||
value="<?= lang("Basic.global.Save") ?>"
|
|
||||||
/>
|
|
||||||
<?= anchor(route_to("clienteplantillapreciosList"), lang("Basic.global.Cancel"), ["class" => "btn btn-secondary"]) ?>
|
<?= anchor(route_to("clienteplantillapreciosList"), lang("Basic.global.Cancel"), ["class" => "btn btn-secondary"]) ?>
|
||||||
|
|
||||||
</div><!-- /.card-footer -->
|
</div><!-- /.card-footer -->
|
||||||
@ -34,9 +30,11 @@
|
|||||||
<?php if (str_contains($formAction, 'edit')): ?>
|
<?php if (str_contains($formAction, 'edit')): ?>
|
||||||
|
|
||||||
<div class="accordion mt-3" id="accordionPreciosLineas">
|
<div class="accordion mt-3" id="accordionPreciosLineas">
|
||||||
|
|
||||||
<div class="card accordion-item active">
|
<div class="card accordion-item active">
|
||||||
<h2 class="accordion-header" id="headingOne">
|
<h2 class="accordion-header" id="headingOne">
|
||||||
<button type="button" class="accordion-button" data-bs-toggle="collapse" data-bs-target="#accordionTip1" aria-expanded="false" aria-controls="accordionTip1">
|
<button type="button" class="accordion-button" data-bs-toggle="collapse" data-bs-target="#accordionTip1"
|
||||||
|
aria-expanded="false" aria-controls="accordionTip1">
|
||||||
<h3><?= lang("MaquinasTarifasImpresions.moduleTitle") ?></h3>
|
<h3><?= lang("MaquinasTarifasImpresions.moduleTitle") ?></h3>
|
||||||
</button>
|
</button>
|
||||||
</h2>
|
</h2>
|
||||||
@ -44,9 +42,13 @@
|
|||||||
<div id="accordionTip1" class="accordion-collapse collapse show" data-bs-parent="#accordionPreciosLineas">
|
<div id="accordionTip1" class="accordion-collapse collapse show" data-bs-parent="#accordionPreciosLineas">
|
||||||
<div class="accordion-body">
|
<div class="accordion-body">
|
||||||
|
|
||||||
|
<button type="button" class="btn btn-primary d-none">
|
||||||
|
Guardar y aplicar a clientes
|
||||||
|
</button>
|
||||||
<table id="tableOfPlantillasPreciosLineas" class="table table-striped table-hover" style="width: 100%;">
|
<table id="tableOfPlantillasPreciosLineas" class="table table-striped table-hover" style="width: 100%;">
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
|
<th>ID</th>
|
||||||
<th><?= lang('ClientePrecios.tipo') ?></th>
|
<th><?= lang('ClientePrecios.tipo') ?></th>
|
||||||
<th><?= lang('ClientePrecios.tipo_maquina') ?></th>
|
<th><?= lang('ClientePrecios.tipo_maquina') ?></th>
|
||||||
<th><?= lang('ClientePrecios.tipo_impresion') ?></th>
|
<th><?= lang('ClientePrecios.tipo_impresion') ?></th>
|
||||||
@ -55,8 +57,9 @@
|
|||||||
<th><?= lang('ClientePrecios.precio_hora') ?></th>
|
<th><?= lang('ClientePrecios.precio_hora') ?></th>
|
||||||
<th><?= lang('ClientePrecios.margen') ?></th>
|
<th><?= lang('ClientePrecios.margen') ?></th>
|
||||||
<th><?= lang('ClientePrecios.user_updated_id') ?></th>
|
<th><?= lang('ClientePrecios.user_updated_id') ?></th>
|
||||||
<th><?= lang('ClientePrecios.updated_at') ?></th>
|
<th class="noFilter"><?= lang('ClientePrecios.updated_at') ?></th>
|
||||||
<th class="text-nowrap" style="min-width:100px"><?= lang('Basic.global.Action') ?></th>
|
<th class="text-nowrap noFilter" style="min-width:100px"><?= lang('Basic.global.Action') ?>
|
||||||
|
</th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
@ -74,7 +77,7 @@
|
|||||||
|
|
||||||
<?php if (str_contains($formAction, 'edit')): ?>
|
<?php if (str_contains($formAction, 'edit')): ?>
|
||||||
<?= $this->section('additionalInlineJs') ?>
|
<?= $this->section('additionalInlineJs') ?>
|
||||||
|
/*
|
||||||
const lastColNr_lineas = $('#tableOfPlantillasPreciosLineas').find("tr:first th").length - 1;
|
const lastColNr_lineas = $('#tableOfPlantillasPreciosLineas').find("tr:first th").length - 1;
|
||||||
|
|
||||||
const url = window.location.href;
|
const url = window.location.href;
|
||||||
@ -87,8 +90,10 @@
|
|||||||
|
|
||||||
const actionBtns_lineas = function(data) {
|
const actionBtns_lineas = function(data) {
|
||||||
return `
|
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>
|
<span class="edit"><a href="javascript:void(0);"><i class="ti ti-pencil ti-sm btn-edit mx-2"
|
||||||
<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>
|
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>
|
<span class="cancel"></span>
|
||||||
`;
|
`;
|
||||||
};
|
};
|
||||||
@ -210,7 +215,8 @@
|
|||||||
searching: false,
|
searching: false,
|
||||||
paging: true,
|
paging: true,
|
||||||
info: false,
|
info: false,
|
||||||
dom: '<"mt-4"><"float-end"B><"float-start"l><t><"mt-4 mb-3"p>',
|
dom: '<"mt-4"><"float-end"B><"float-start"l>
|
||||||
|
<t><"mt-4 mb-3"p>',
|
||||||
ajax : $.fn.dataTable.pipeline( {
|
ajax : $.fn.dataTable.pipeline( {
|
||||||
url: '<?= route_to('dataTableOfClientesplantillaprecioslineas') ?>',
|
url: '<?= route_to('dataTableOfClientesplantillaprecioslineas') ?>',
|
||||||
data: {
|
data: {
|
||||||
@ -340,23 +346,38 @@
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
*/
|
||||||
<?= $this->endSection() ?>
|
<?= $this->endSection() ?>
|
||||||
|
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
|
|
||||||
<?= $this->section('css') ?>
|
<?= $this->section('css') ?>
|
||||||
<link rel="stylesheet" href="<?= site_url('themes/vuexy/css/datatables-editor/editor.dataTables.min.css') ?>">
|
<link rel="stylesheet"
|
||||||
<link rel="stylesheet" href="<?= site_url("/themes/vuexy/vendor/libs/datatables-sk/plugins/buttons/buttons.bootstrap5.min.css") ?>">
|
href="<?= site_url('themes/vuexy/css/datatables-editor/editor.dataTables.min.css') ?>">
|
||||||
|
<link rel="stylesheet"
|
||||||
|
href="<?= site_url("/themes/vuexy/vendor/libs/datatables-sk/plugins/buttons/buttons.bootstrap5.min.css") ?>">
|
||||||
<?= $this->endSection() ?>
|
<?= $this->endSection() ?>
|
||||||
|
|
||||||
<?= $this->section('additionalExternalJs') ?>
|
<?= $this->section('additionalExternalJs') ?>
|
||||||
<script src="<?= site_url("/themes/vuexy/vendor/libs/datatables-sk/plugins/buttons/dataTables.buttons.min.js") ?>"></script>
|
<script
|
||||||
<script src="<?= site_url("/themes/vuexy/vendor/libs/datatables-sk/plugins/buttons/buttons.bootstrap5.min.js") ?>"></script>
|
src="<?= site_url("/themes/vuexy/vendor/libs/datatables-sk/plugins/buttons/dataTables.buttons.min.js") ?>"></script>
|
||||||
<script src="<?= site_url("/themes/vuexy/vendor/libs/datatables-sk/plugins/buttons/buttons.html5.min.js") ?>"></script>
|
<script
|
||||||
<script src="<?= site_url("/themes/vuexy/vendor/libs/datatables-sk/plugins/buttons/buttons.print.min.js") ?>"></script>
|
src="<?= site_url("/themes/vuexy/vendor/libs/datatables-sk/plugins/buttons/buttons.bootstrap5.min.js") ?>"></script>
|
||||||
<script src="<?= site_url("/themes/vuexy/vendor/libs/datatables-sk/plugins/jszip/jszip.min.js") ?>"></script>
|
<script
|
||||||
<script src="<?= site_url("/themes/vuexy/vendor/libs/datatables-sk/plugins/pdfmake/pdfmake.min.js") ?>" crossorigin="anonymous" referrerpolicy="no-referrer"></script>
|
src="<?= site_url("/themes/vuexy/vendor/libs/datatables-sk/plugins/buttons/buttons.html5.min.js") ?>"></script>
|
||||||
<script src="<?= site_url("/themes/vuexy/vendor/libs/datatables-sk/plugins/pdfmake/vfs_fonts.js") ?>"></script>
|
<script
|
||||||
<script src="<?= site_url('themes/vuexy/js/datatables-editor/dataTables.editor.min.js') ?>"></script>
|
src="<?= site_url("/themes/vuexy/vendor/libs/datatables-sk/plugins/buttons/buttons.print.min.js") ?>"></script>
|
||||||
|
<script
|
||||||
|
src="<?= site_url("/themes/vuexy/vendor/libs/datatables-sk/plugins/jszip/jszip.min.js") ?>"></script>
|
||||||
|
<script
|
||||||
|
src="<?= site_url("/themes/vuexy/vendor/libs/datatables-sk/plugins/pdfmake/pdfmake.min.js") ?>"
|
||||||
|
crossorigin="anonymous" referrerpolicy="no-referrer"></script>
|
||||||
|
<script
|
||||||
|
src="<?= site_url("/themes/vuexy/vendor/libs/datatables-sk/plugins/pdfmake/vfs_fonts.js") ?>"></script>
|
||||||
|
<script
|
||||||
|
src="<?= site_url('themes/vuexy/js/datatables-editor/dataTables.editor.min.js') ?>"></script>
|
||||||
|
<?php if (str_contains($formAction, 'edit')): ?>
|
||||||
|
<script type="module"
|
||||||
|
src="<?= site_url('assets/js/safekat/pages/plantillasTarifasCliente/edit.js') ?>"></script>
|
||||||
|
<?php endif; ?>
|
||||||
<?= $this->endSection() ?>
|
<?= $this->endSection() ?>
|
||||||
|
|
||||||
|
|||||||
@ -10,14 +10,16 @@
|
|||||||
<h3 class="card-title"><?=lang('ClientePrecios.plantillaPrecios_list') ?></h3>
|
<h3 class="card-title"><?=lang('ClientePrecios.plantillaPrecios_list') ?></h3>
|
||||||
<?=anchor(route_to('newClienteplantillaprecios'), lang('Basic.global.addNew').' '.lang('ClientePrecios.plantillaPrecios_name'), ['class'=>'btn btn-primary float-end']); ?>
|
<?=anchor(route_to('newClienteplantillaprecios'), lang('Basic.global.addNew').' '.lang('ClientePrecios.plantillaPrecios_name'), ['class'=>'btn btn-primary float-end']); ?>
|
||||||
</div><!--//.card-header -->
|
</div><!--//.card-header -->
|
||||||
|
<?= csrf_field() ?>
|
||||||
<div class="card-body">
|
<div class="card-body">
|
||||||
<?= view('themes/_commonPartialsBs/_alertBoxes'); ?>
|
<?= view('themes/_commonPartialsBs/_alertBoxes'); ?>
|
||||||
|
|
||||||
<table id="tableOfClienteplantillaprecios" class="table table-striped table-hover using-exportable-data-table" style="width: 100%;">
|
<table id="tableOfClienteplantillaprecios" class="table table-striped table-hover using-exportable-data-table" style="width: 100%;">
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
|
<th>ID</th>
|
||||||
<th><?= lang('ClientePrecios.nombre') ?></th>
|
<th><?= lang('ClientePrecios.nombre') ?></th>
|
||||||
<th class="text-nowrap"><?= lang('Basic.global.Action') ?></th>
|
<th class="noFilter text-nowrap"><?= lang('Basic.global.Action') ?></th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
@ -50,100 +52,6 @@
|
|||||||
|
|
||||||
<script src="<?= site_url("/themes/vuexy/vendor/libs/datatables-sk/plugins/pdfmake/vfs_fonts.js") ?>"></script>
|
<script src="<?= site_url("/themes/vuexy/vendor/libs/datatables-sk/plugins/pdfmake/vfs_fonts.js") ?>"></script>
|
||||||
|
|
||||||
<?=$this->endSection() ?>
|
<script type="module" src="<?= site_url('assets/js/safekat/pages/plantillasTarifasCliente/list.js') ?>"></script>
|
||||||
|
|
||||||
<?=$this->section('additionalInlineJs') ?>
|
|
||||||
|
|
||||||
const lastColNr2 = $(".using-exportable-data-table").find("tr:first th").length - 1;
|
|
||||||
const actionBtns2 = 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>
|
|
||||||
`;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
$(document).on('click', '.btn-edit', function(e) {
|
|
||||||
window.location.href = `/clientes/clienteplantillaprecios/edit/${$(this).attr('data-id')}`;
|
|
||||||
});
|
|
||||||
|
|
||||||
|
|
||||||
// Delete row
|
|
||||||
$(document).on('click', '.btn-delete', function(e) {
|
|
||||||
$(".btn-remove").attr('data-id', $(this).attr('data-id'));
|
|
||||||
});
|
|
||||||
|
|
||||||
$(document).on('click', '.btn-remove', function(e) {
|
|
||||||
const dataId = $(this).attr('data-id');
|
|
||||||
const row = $(this).closest('tr');
|
|
||||||
if ($.isNumeric(dataId)) {
|
|
||||||
|
|
||||||
$.ajax({
|
|
||||||
url: `/clientes/clienteplantillaprecios/delete/${dataId}`,
|
|
||||||
method: 'GET',
|
|
||||||
}).done((data, textStatus, jqXHR) => {
|
|
||||||
$('#confirm2delete').modal('toggle');
|
|
||||||
tablePLantillaPrecios.clearPipeline();
|
|
||||||
tablePLantillaPrecios.row($(row)).invalidate().draw();
|
|
||||||
|
|
||||||
// Se borran las lineas asociadas
|
|
||||||
const domain = window.location.origin
|
|
||||||
fetch(domain + "/clientes/clienteplantillaprecios/update/" + dataId , {
|
|
||||||
method: "POST",
|
|
||||||
body: JSON.stringify({
|
|
||||||
<?= csrf_token() ?? "token" ?> : <?= csrf_token() ?>v
|
|
||||||
}),
|
|
||||||
headers: {
|
|
||||||
"Content-type": "application/json; charset=UTF-8"
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
popSuccessAlert(data.msg ?? jqXHR.statusText);
|
|
||||||
}).fail((jqXHR, textStatus, errorThrown) => {
|
|
||||||
popErrorAlert(jqXHR.responseJSON.messages.error)
|
|
||||||
});
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
|
|
||||||
var tablePLantillaPrecios = $('#tableOfClienteplantillaprecios').DataTable( {
|
|
||||||
serverSide: true,
|
|
||||||
processing: true,
|
|
||||||
autoWidth: true,
|
|
||||||
responsive: true,
|
|
||||||
lengthMenu: [ 5, 10, 25, 50, 75, 100, 250],
|
|
||||||
order: [[ 0, "asc" ]],
|
|
||||||
pageLength: 25,
|
|
||||||
lengthChange: true,
|
|
||||||
searching: true,
|
|
||||||
paging: true,
|
|
||||||
info: true,
|
|
||||||
stateSave: true,
|
|
||||||
dom: "lftp",
|
|
||||||
ajax : $.fn.dataTable.pipeline( {
|
|
||||||
url: '<?= route_to('dataTableOfClientesplantillaprecios') ?>',
|
|
||||||
method: 'POST',
|
|
||||||
headers: {'X-Requested-With': 'XMLHttpRequest'},
|
|
||||||
async: true,
|
|
||||||
}),
|
|
||||||
columns: [
|
|
||||||
{ data: 'nombre'},
|
|
||||||
{ data: actionBtns2,
|
|
||||||
className: 'row-edit dt-center'}
|
|
||||||
],
|
|
||||||
columnDefs: [
|
|
||||||
{
|
|
||||||
orderable: false,
|
|
||||||
targets: [lastColNr2]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
searchable: false,
|
|
||||||
targets: [lastColNr2]
|
|
||||||
}
|
|
||||||
],
|
|
||||||
language: {
|
|
||||||
url: "/themes/vuexy/vendor/libs/datatables-sk/plugins/i18n/es-ES.json"
|
|
||||||
}
|
|
||||||
} );
|
|
||||||
<?=$this->endSection() ?>
|
<?=$this->endSection() ?>
|
||||||
@ -61,11 +61,11 @@
|
|||||||
$selectedChatDepartments = isset($chatDepartmentUser) && is_array($chatDepartmentUser) ? $chatDepartmentUser : [];
|
$selectedChatDepartments = isset($chatDepartmentUser) && is_array($chatDepartmentUser) ? $chatDepartmentUser : [];
|
||||||
$selectedKeywords = array_map(fn($chatDepartment) => $chatDepartment->name, $selectedChatDepartments);
|
$selectedKeywords = array_map(fn($chatDepartment) => $chatDepartment->name, $selectedChatDepartments);
|
||||||
foreach ($chatDepartments as $item) :
|
foreach ($chatDepartments as $item) :
|
||||||
$isSelected = in_array($item["name"], $selectedKeywords) ? 'selected' : '';
|
$isSelected = in_array($item->name, $selectedKeywords) ? 'selected' : '';
|
||||||
?>
|
?>
|
||||||
<option value="<?= $item["name"] ?>"
|
<option value="<?= $item->name ?>"
|
||||||
data-select2-id=<?= $item["name"] ?> <?= $isSelected ?>>
|
data-select2-id=<?= $item->name ?> <?= $isSelected ?>>
|
||||||
<?= $item["display"] ?>
|
<?= $item->display ?>
|
||||||
</option>
|
</option>
|
||||||
<?php endforeach; ?>
|
<?php endforeach; ?>
|
||||||
</select>
|
</select>
|
||||||
|
|||||||
@ -4,6 +4,8 @@ let Table = function (
|
|||||||
url,
|
url,
|
||||||
columns,
|
columns,
|
||||||
data,
|
data,
|
||||||
|
row_id = "DT_RowId",
|
||||||
|
|
||||||
language = "es-ES") {
|
language = "es-ES") {
|
||||||
|
|
||||||
this.domItem = domItem;
|
this.domItem = domItem;
|
||||||
@ -11,6 +13,7 @@ let Table = function (
|
|||||||
this.url = url;
|
this.url = url;
|
||||||
this.columns = columns;
|
this.columns = columns;
|
||||||
this.data = data;
|
this.data = data;
|
||||||
|
this.row_id = row_id;
|
||||||
this.language = language;
|
this.language = language;
|
||||||
|
|
||||||
this.table = null;
|
this.table = null;
|
||||||
@ -24,6 +27,7 @@ let Table = function (
|
|||||||
actions = ['view', 'edit', 'delete', 'cancel'],
|
actions = ['view', 'edit', 'delete', 'cancel'],
|
||||||
order = [[0, 'asc']],
|
order = [[0, 'asc']],
|
||||||
buttonsExport = true,
|
buttonsExport = true,
|
||||||
|
colVisibility = true,
|
||||||
buttonNewWithEditor = false,
|
buttonNewWithEditor = false,
|
||||||
editor = null,
|
editor = null,
|
||||||
booleanColumns = [],
|
booleanColumns = [],
|
||||||
@ -53,11 +57,6 @@ let Table = function (
|
|||||||
let buttons = [];
|
let buttons = [];
|
||||||
if (buttonsExport) {
|
if (buttonsExport) {
|
||||||
buttons = [
|
buttons = [
|
||||||
{
|
|
||||||
extend: 'colvis',
|
|
||||||
columns: ':not(.noVis)',
|
|
||||||
|
|
||||||
},
|
|
||||||
'copy', 'csv', 'excel', 'print', {
|
'copy', 'csv', 'excel', 'print', {
|
||||||
extend: 'pdfHtml5',
|
extend: 'pdfHtml5',
|
||||||
orientation: 'landscape',
|
orientation: 'landscape',
|
||||||
@ -65,6 +64,13 @@ let Table = function (
|
|||||||
}
|
}
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
if(colVisibility){
|
||||||
|
buttons.unshift({
|
||||||
|
extend: 'colvis',
|
||||||
|
columns: ':not(.noVis)',
|
||||||
|
|
||||||
|
})
|
||||||
|
}
|
||||||
if (buttonNewWithEditor) {
|
if (buttonNewWithEditor) {
|
||||||
buttons.push(
|
buttons.push(
|
||||||
{
|
{
|
||||||
@ -91,6 +97,7 @@ let Table = function (
|
|||||||
order: order,
|
order: order,
|
||||||
orderCellsTop: true,
|
orderCellsTop: true,
|
||||||
fixedHeader: true,
|
fixedHeader: true,
|
||||||
|
rowId: row_id,
|
||||||
dom: dom,
|
dom: dom,
|
||||||
ajax: $.fn.dataTable.pipeline({
|
ajax: $.fn.dataTable.pipeline({
|
||||||
url: this.url,
|
url: this.url,
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
let TableEditor = function (
|
let TableEditor = function (
|
||||||
table,
|
table,
|
||||||
url,
|
url = "",
|
||||||
headers,
|
headers,
|
||||||
idSrc,
|
idSrc,
|
||||||
fields) {
|
fields) {
|
||||||
@ -16,6 +16,15 @@ let TableEditor = function (
|
|||||||
|
|
||||||
this.init = function () {
|
this.init = function () {
|
||||||
|
|
||||||
|
if (url == "") {
|
||||||
|
this.editor = new $.fn.dataTable.Editor({
|
||||||
|
table: table,
|
||||||
|
idSrc: idSrc,
|
||||||
|
fields: fields,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
else {
|
||||||
this.editor = new $.fn.dataTable.Editor({
|
this.editor = new $.fn.dataTable.Editor({
|
||||||
ajax: {
|
ajax: {
|
||||||
url: url,
|
url: url,
|
||||||
@ -25,6 +34,8 @@ let TableEditor = function (
|
|||||||
idSrc: idSrc,
|
idSrc: idSrc,
|
||||||
fields: fields,
|
fields: fields,
|
||||||
});
|
});
|
||||||
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -267,6 +267,28 @@ class tarifasClienteView {
|
|||||||
|
|
||||||
#changePlantilla() {
|
#changePlantilla() {
|
||||||
|
|
||||||
|
self = this;
|
||||||
|
const data = $('#plantillas').select2('data');
|
||||||
|
if (data.length > 0) {
|
||||||
|
const id = data[0].id;
|
||||||
|
new Ajax(
|
||||||
|
'/clienteprecios/changeplantilla',
|
||||||
|
{
|
||||||
|
'cliente_id': self.clienteId,
|
||||||
|
'plantilla_id': id,
|
||||||
|
[this.csrf_token]: this.csrf_hash
|
||||||
|
},
|
||||||
|
{},
|
||||||
|
() => {
|
||||||
|
self.tableTarifas.table.clearPipeline();
|
||||||
|
self.tableTarifas.table.draw();
|
||||||
|
},
|
||||||
|
(error) => {
|
||||||
|
console.log(error);
|
||||||
|
}
|
||||||
|
).post();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -0,0 +1,433 @@
|
|||||||
|
import Table from '../../components/table.js';
|
||||||
|
import TableEditor from '../../components/tableEditor.js';
|
||||||
|
import ConfirmDeleteModal from '../../components/ConfirmDeleteModal.js';
|
||||||
|
import Ajax from '../../components/ajax.js';
|
||||||
|
import { getToken } from '../../common/common.js';
|
||||||
|
|
||||||
|
class PlantillasTarifasClienteForm {
|
||||||
|
|
||||||
|
constructor() {
|
||||||
|
|
||||||
|
this.domItem = $('.card-body');
|
||||||
|
|
||||||
|
this.plantillaId = window.location.href.split("/").pop();
|
||||||
|
|
||||||
|
this.csrf_token = getToken();
|
||||||
|
this.csrf_hash = $('#mainContainer').find('input[name="' + this.csrf_token + '"]').val();
|
||||||
|
|
||||||
|
this.tablePlantilla = null;
|
||||||
|
this.deleteModal = null;
|
||||||
|
|
||||||
|
this.localEditor = null;
|
||||||
|
this.ajaxEditor = null;
|
||||||
|
|
||||||
|
this.changedRows = [];
|
||||||
|
}
|
||||||
|
|
||||||
|
init() {
|
||||||
|
|
||||||
|
const self = this;
|
||||||
|
|
||||||
|
this.headerSearcher();
|
||||||
|
|
||||||
|
this.deleteModal = new ConfirmDeleteModal('plantillasTarifasCliente');
|
||||||
|
this.deleteModal.init();
|
||||||
|
|
||||||
|
this.#initTable();
|
||||||
|
|
||||||
|
this.#initEditor();
|
||||||
|
|
||||||
|
// Editar en linea la fila
|
||||||
|
this.tablePlantilla.table.on('click', 'tbody span.edit', function (e) {
|
||||||
|
|
||||||
|
const row = $(this).closest('tr');
|
||||||
|
|
||||||
|
// Iniciar la edición en línea para todas las celdas de la fila
|
||||||
|
self.localEditor.editor.inline(
|
||||||
|
self.tablePlantilla.table.cells(row, '*').nodes(),
|
||||||
|
{
|
||||||
|
cancelHtml: '<a href="javascript:void(0);"><i class="ti ti-x"></i></a>',
|
||||||
|
submitHtml: '<a href="javascript:void(0);"><i class="ti ti-device-floppy"></i></a>',
|
||||||
|
cancelTrigger: row.find('span.cancel')[0],
|
||||||
|
submitTrigger: row.find('span.edit')[0],
|
||||||
|
submit: 'allIfChanged'
|
||||||
|
}
|
||||||
|
);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#initEditor() {
|
||||||
|
|
||||||
|
const self = this;
|
||||||
|
|
||||||
|
const tipo_linea = [
|
||||||
|
{ label: window.language.ClientePrecios.interior, value: 'interior' },
|
||||||
|
{ label: window.language.ClientePrecios.cubierta, value: 'cubierta' },
|
||||||
|
{ label: window.language.ClientePrecios.sobrecubierta, value: 'sobrecubierta' }
|
||||||
|
];
|
||||||
|
|
||||||
|
const tipo_maquina = [
|
||||||
|
{ label: window.language.ClientePrecios.toner, value: 'toner' },
|
||||||
|
{ label: window.language.ClientePrecios.inkjet, value: 'inkjet' },
|
||||||
|
];
|
||||||
|
|
||||||
|
const tipo_impresion = [
|
||||||
|
{ label: window.language.ClientePrecios.negro, value: 'negro' },
|
||||||
|
{ label: window.language.ClientePrecios.negrohq, value: 'negrohq' },
|
||||||
|
{ label: window.language.ClientePrecios.color, value: 'color' },
|
||||||
|
{ label: window.language.ClientePrecios.colorhq, value: 'colorhq' },
|
||||||
|
];
|
||||||
|
|
||||||
|
const editorFields = [
|
||||||
|
{
|
||||||
|
name: "id",
|
||||||
|
type: "readonly"
|
||||||
|
}, {
|
||||||
|
name: "tipo",
|
||||||
|
type: "select",
|
||||||
|
options: tipo_linea
|
||||||
|
}, {
|
||||||
|
name: "tipo_maquina",
|
||||||
|
type: "select",
|
||||||
|
options: tipo_maquina
|
||||||
|
}, {
|
||||||
|
name: "tipo_impresion",
|
||||||
|
type: "select",
|
||||||
|
options: tipo_impresion
|
||||||
|
}, {
|
||||||
|
name: "tiempo_min"
|
||||||
|
}, {
|
||||||
|
name: "tiempo_max"
|
||||||
|
}, {
|
||||||
|
name: "precio_hora"
|
||||||
|
}, {
|
||||||
|
name: "margen"
|
||||||
|
},
|
||||||
|
];
|
||||||
|
this.localEditor = new TableEditor(
|
||||||
|
$('#tableOfPlantillasPreciosLineas'),
|
||||||
|
'',
|
||||||
|
{},
|
||||||
|
'id',
|
||||||
|
editorFields);
|
||||||
|
|
||||||
|
this.localEditor.init();
|
||||||
|
|
||||||
|
this.ajaxEditor = new TableEditor(
|
||||||
|
$('#tableOfPlantillasPreciosLineas'),
|
||||||
|
'/clienteplantillaprecioslineas/datatable_editor',
|
||||||
|
{ [this.csrf_token]: this.csrf_hash },
|
||||||
|
'id',
|
||||||
|
editorFields);
|
||||||
|
|
||||||
|
this.ajaxEditor.init();
|
||||||
|
|
||||||
|
|
||||||
|
this.localEditor.editor.on('postEdit', function (e, json, data) {
|
||||||
|
|
||||||
|
/*console.log(self.tablePlantilla.table.row(0).data());
|
||||||
|
self.tablePlantilla.table.rows().every( function ( rowIdx ) {
|
||||||
|
var rowData = this.data();
|
||||||
|
if(rowData.id == data.id){
|
||||||
|
self.tablePlantilla.table.row(rowIdx).data({
|
||||||
|
id: data.id,
|
||||||
|
tipo: 'interior', // 'interior', 'cubierta', etc.
|
||||||
|
tipo_maquina: 'toner', // 'toner', 'inkjet'
|
||||||
|
tipo_impresion: 'negro', // 'negro', 'color', etc.
|
||||||
|
tiempo_min: 0,
|
||||||
|
tiempo_max: 1,
|
||||||
|
precio_hora: 1,
|
||||||
|
margen: 100,
|
||||||
|
user_updated: 'yo',
|
||||||
|
updated_at: '200000'
|
||||||
|
}).draw(false);
|
||||||
|
}
|
||||||
|
})
|
||||||
|
//self.tablePlantilla.table.row(0).data(data2).draw(false);
|
||||||
|
|
||||||
|
/*self.tablePlantilla.table.row(0).data({
|
||||||
|
id: 1,
|
||||||
|
tipo: 'interior', // 'interior', 'cubierta', etc.
|
||||||
|
tipo_maquina: 'toner', // 'toner', 'inkjet'
|
||||||
|
tipo_impresion: 'negro', // 'negro', 'color', etc.
|
||||||
|
tiempo_min: 0,
|
||||||
|
tiempo_max: 1,
|
||||||
|
precio_hora: 1,
|
||||||
|
margen: 100,
|
||||||
|
user_updated: 'yo',
|
||||||
|
updated_at: '200000'
|
||||||
|
}).draw(false);*/
|
||||||
|
let row = self.tablePlantilla.table.row('#' + data.id);
|
||||||
|
if (row.length) {
|
||||||
|
console.log('Data:', data)
|
||||||
|
let rowData = row.data();
|
||||||
|
console.log('Datos de la fila:', rowData);
|
||||||
|
|
||||||
|
// Actualizar los datos de la fila
|
||||||
|
self.tablePlantilla.table.row('#' + data.id).data({
|
||||||
|
id: data.id,
|
||||||
|
tipo: data.tipo,
|
||||||
|
tipo_maquina: data.tipo_maquina,
|
||||||
|
tipo_impresion: data.tipo_impresion,
|
||||||
|
tiempo_min: data.tiempo_min,
|
||||||
|
tiempo_max: data.tiempo_max,
|
||||||
|
precio_hora: data.precio_hora,
|
||||||
|
margen: "150",
|
||||||
|
user_updated_id: data.user_updated_id,
|
||||||
|
user_updated: data.user_updated,
|
||||||
|
updated_at: data.updated_at
|
||||||
|
}).draw(true); // Usar invalidate() si es necesario
|
||||||
|
rowData = row.data();
|
||||||
|
console.log('Datos de la fila actualizados:', rowData);
|
||||||
|
} else {
|
||||||
|
console.warn('No se encontró la fila con ID row_' + data.id);
|
||||||
|
}
|
||||||
|
/*
|
||||||
|
if (row.length > 0) {
|
||||||
|
self.tablePlantilla.table.row(row[0]).data({
|
||||||
|
id: data.id,
|
||||||
|
tipo: data.tipo, // 'interior', 'cubierta', etc.
|
||||||
|
tipo_maquina: data.tipo_maquina, // 'toner', 'inkjet'
|
||||||
|
tipo_impresion: data.tipo_impresion, // 'negro', 'color', etc.
|
||||||
|
tiempo_min: data.tiempo_min,
|
||||||
|
tiempo_max: data.tiempo_max,
|
||||||
|
precio_hora: data.precio_hora,
|
||||||
|
margen: data.margen,
|
||||||
|
user_updated: data.user_updated,
|
||||||
|
updated_at: data.updated_at
|
||||||
|
}).invalidate().draw(false);
|
||||||
|
|
||||||
|
console.log('---');
|
||||||
|
console.log(self.tablePlantilla.table.row(row[0]).data())
|
||||||
|
}*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// check if this id exists
|
||||||
|
if (!self.changedRows.includes(data.id))
|
||||||
|
self.changedRows.push(data.id);
|
||||||
|
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
/*
|
||||||
|
this.editorTarifas.editor.on('preSubmit', function (e, d, type) {
|
||||||
|
if (type === 'create') {
|
||||||
|
d.data[0]['cliente_id'] = self.clienteId;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
this.editorTarifas.editor.on('submitSuccess', function (e, json, data, action) {
|
||||||
|
|
||||||
|
self.tablePlantilla.table.clearPipeline();
|
||||||
|
self.tablePlantilla.table.draw();
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
this.editorTarifas.editor.on('postEdit', function (e, json, data, action) {
|
||||||
|
self.#borrarPlantillaTarifa(self.clienteId);
|
||||||
|
self.selectorPlantilla.offChange();
|
||||||
|
self.selectorPlantilla.setOption(0, 'Personalizado');
|
||||||
|
self.selectorPlantilla.onChange(self.#changePlantilla.bind(this));
|
||||||
|
})
|
||||||
|
|
||||||
|
this.editorTarifas.editor.on('postCreate', function (e, json, data, action) {
|
||||||
|
self.#borrarPlantillaTarifa(self.clienteId);
|
||||||
|
self.selectorPlantilla.offChange();
|
||||||
|
self.selectorPlantilla.setOption(0, 'Personalizado');
|
||||||
|
self.selectorPlantilla.onChange(self.#changePlantilla.bind(this));
|
||||||
|
})
|
||||||
|
|
||||||
|
this.editorTarifas.editor.on('postCancel', function (e, json, data) {
|
||||||
|
// Restaurar botones de acción por fila
|
||||||
|
self.tablePlantilla.table.rows().nodes().each(function (node) {
|
||||||
|
$(node).find('span.edit').removeClass('d-none');
|
||||||
|
$(node).find('span.cancel, span.submit').addClass('d-none');
|
||||||
|
});
|
||||||
|
});*/
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#initTable() {
|
||||||
|
|
||||||
|
const self = this;
|
||||||
|
|
||||||
|
const columns =
|
||||||
|
[
|
||||||
|
{ 'data': 'id' },
|
||||||
|
{
|
||||||
|
'data': 'tipo',
|
||||||
|
'render': function (data, type, row, meta) {
|
||||||
|
if (data == 'interior')
|
||||||
|
return window.language.ClientePrecios.interior;
|
||||||
|
else if (data == 'cubierta')
|
||||||
|
return window.language.ClientePrecios.cubierta;
|
||||||
|
else if (data == 'sobrecubierta')
|
||||||
|
return window.language.ClientePrecios.sobrecubierta;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
'data': 'tipo_maquina',
|
||||||
|
'render': function (data, type, row, meta) {
|
||||||
|
if (data == 'toner')
|
||||||
|
return window.language.ClientePrecios.toner;
|
||||||
|
else if (data == 'inkjet')
|
||||||
|
return window.language.ClientePrecios.inkjet;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
'data': 'tipo_impresion',
|
||||||
|
'render': function (data, type, row, meta) {
|
||||||
|
if (data == 'negro')
|
||||||
|
return window.language.ClientePrecios.negro;
|
||||||
|
else if (data == 'negrohq')
|
||||||
|
return window.language.ClientePrecios.negrohq;
|
||||||
|
else if (data == 'color')
|
||||||
|
return window.language.ClientePrecios.color;
|
||||||
|
else if (data == 'colorhq')
|
||||||
|
return window.language.ClientePrecios.colorhq;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{ 'data': 'tiempo_min' },
|
||||||
|
{ 'data': 'tiempo_max' },
|
||||||
|
{ 'data': 'precio_hora' },
|
||||||
|
{ 'data': 'margen' },
|
||||||
|
{ 'data': 'user_updated' },
|
||||||
|
{ 'data': 'updated_at' },
|
||||||
|
|
||||||
|
];
|
||||||
|
|
||||||
|
const actions = ['edit', 'delete', 'cancel'];
|
||||||
|
|
||||||
|
this.tablePlantilla = new Table(
|
||||||
|
$('#tableOfPlantillasPreciosLineas'),
|
||||||
|
'plantillaTarifasCliente',
|
||||||
|
'/clienteplantillaprecioslineas/datatable',
|
||||||
|
columns,
|
||||||
|
[
|
||||||
|
{ name: 'plantilla_id', value: this.plantillaId }
|
||||||
|
],'id'
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
this.tablePlantilla.init({
|
||||||
|
actions: actions,
|
||||||
|
colVisibility: false,
|
||||||
|
buttonsExport: true,
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
this.tablePlantilla.table.on('init.dt', function () {
|
||||||
|
self.tablePlantilla.table.page.len(50).draw();
|
||||||
|
});
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
headerSearcher() {
|
||||||
|
|
||||||
|
const self = this;
|
||||||
|
|
||||||
|
$('#tableOfPlantillasPreciosLineas thead tr').clone(false).appendTo('#tableOfPlantillasPreciosLineas thead');
|
||||||
|
$('#tableOfPlantillasPreciosLineas thead tr:eq(1) th').each(function (i) {
|
||||||
|
|
||||||
|
if (!$(this).hasClass("noFilter")) {
|
||||||
|
|
||||||
|
if (i == 1) {
|
||||||
|
|
||||||
|
// Agregar un selector en la segunda columna
|
||||||
|
$(this).html('<select class="form-control" style="min-width:100px;max-width:120px;font-size:0.8rem !important;"></select>');
|
||||||
|
|
||||||
|
// Agregar opciones al selector
|
||||||
|
var selector = $('select', this);
|
||||||
|
selector.append('<option value="">Todos</option>'); // Opción vacía
|
||||||
|
selector.append('<option value="interior">Interior</option>');
|
||||||
|
selector.append('<option value="cubierta">Cubierta</option>');
|
||||||
|
selector.append('<option value="sobrecubierta">Sobrecubierta</option>');
|
||||||
|
|
||||||
|
selector.on('change', function () {
|
||||||
|
var val = $.fn.dataTable.util.escapeRegex(
|
||||||
|
$(this).val()
|
||||||
|
);
|
||||||
|
self.tablePlantilla.table.column(i).search(val).draw();
|
||||||
|
});
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
else if (i == 2) {
|
||||||
|
// Agregar un selector en la tercera columna
|
||||||
|
$(this).html('<select class="form-control" style="min-width:100px;max-width:120px;font-size:0.8rem !important;"></select>');
|
||||||
|
|
||||||
|
// Agregar opciones al selector
|
||||||
|
var selector = $('select', this);
|
||||||
|
selector.append('<option value="">Todos</option>'); // Opción vacía
|
||||||
|
selector.append('<option value="toner">Toner</option>');
|
||||||
|
selector.append('<option value="inkjet">Inkjet</option>');
|
||||||
|
|
||||||
|
selector.on('change', function () {
|
||||||
|
var val = $.fn.dataTable.util.escapeRegex(
|
||||||
|
$(this).val()
|
||||||
|
);
|
||||||
|
self.tablePlantilla.table.column(i).search(val).draw();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
else if (i == 3) {
|
||||||
|
// Agregar un selector en la cuarta columna
|
||||||
|
$(this).html('<select class="form-control" style="min-width:100px;max-width:120px;font-size:0.8rem !important;"></select>');
|
||||||
|
|
||||||
|
// Agregar opciones al selector
|
||||||
|
var selector = $('select', this);
|
||||||
|
selector.append('<option value="">Todos</option>'); // Opción vacía
|
||||||
|
selector.append('<option value="negro">' + window.language.ClientePrecios.negro + '</option>');
|
||||||
|
selector.append('<option value="color">' + window.language.ClientePrecios.color + '</option>');
|
||||||
|
selector.append('<option value="negrohq">' + window.language.ClientePrecios.negrohq + '</option>');
|
||||||
|
selector.append('<option value="colorhq">' + window.language.ClientePrecios.colorhq + '</option>');
|
||||||
|
|
||||||
|
selector.on('change', function () {
|
||||||
|
var val = $.fn.dataTable.util.escapeRegex(
|
||||||
|
$(this).val()
|
||||||
|
);
|
||||||
|
self.tablePlantilla.table.column(i).search(val).draw();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$(this).html('<input type="text" class="form-control " style="min-width:100px;max-width:120px;font-size:0.8rem !important;" />');
|
||||||
|
|
||||||
|
$('input', this).on('change clear', function () {
|
||||||
|
if (self.tablePlantilla.table.column(i).search() !== this.value) {
|
||||||
|
self.tablePlantilla.table
|
||||||
|
.column(i)
|
||||||
|
.search(this.value)
|
||||||
|
.draw();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$(this).html('<span></span>');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
document.addEventListener('DOMContentLoaded', function () {
|
||||||
|
|
||||||
|
const locale = document.querySelector('meta[name="locale"]').getAttribute('content');
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
new Ajax('/translate/getTranslation', { locale: locale, translationFile: ['ClientePrecios'] }, {},
|
||||||
|
function (translations) {
|
||||||
|
window.language = JSON.parse(translations);
|
||||||
|
new PlantillasTarifasClienteForm().init();
|
||||||
|
},
|
||||||
|
function (error) {
|
||||||
|
console.log("Error getting translations:", error);
|
||||||
|
}
|
||||||
|
).post();
|
||||||
|
|
||||||
|
});
|
||||||
@ -0,0 +1,153 @@
|
|||||||
|
import Table from '../../components/table.js';
|
||||||
|
import ConfirmDeleteModal from '../../components/ConfirmDeleteModal.js';
|
||||||
|
import Ajax from '../../components/ajax.js';
|
||||||
|
import { getToken } from '../../common/common.js';
|
||||||
|
|
||||||
|
class PlantillasTarifasClienteList {
|
||||||
|
|
||||||
|
constructor() {
|
||||||
|
|
||||||
|
this.domItem = $('.card-body');
|
||||||
|
|
||||||
|
this.csrf_token = getToken();
|
||||||
|
this.csrf_hash = $('#mainContainer').find('input[name="' + this.csrf_token + '"]').val();
|
||||||
|
|
||||||
|
this.tablePlantillas = null;
|
||||||
|
this.deleteModal = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
init() {
|
||||||
|
|
||||||
|
const self = this;
|
||||||
|
|
||||||
|
this.headerSearcher();
|
||||||
|
|
||||||
|
this.deleteModal = new ConfirmDeleteModal('plantillasTarifasCliente');
|
||||||
|
this.deleteModal.init();
|
||||||
|
|
||||||
|
this.#initTable();
|
||||||
|
|
||||||
|
// Editar en linea la fila
|
||||||
|
this.tablePlantillas.table.on('click', '.btn-edit-' + this.tablePlantillas.getAlias(), function (e) {
|
||||||
|
|
||||||
|
const dataId = $(this).attr('data-id');
|
||||||
|
|
||||||
|
if (!Number.isNaN(Number(dataId))) {
|
||||||
|
window.location.href = '/clienteplantillaprecios/edit/' + dataId;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
// Eliminar la fila
|
||||||
|
this.tablePlantillas.table.on('click', '.btn-delete-' + this.tablePlantillas.getAlias(), function (e) {
|
||||||
|
const row = $(this).closest('tr')[0]._DT_RowIndex;
|
||||||
|
const dataId = $(this).attr('data-id');
|
||||||
|
self.deleteModal.setData($(this).attr('data-id'));
|
||||||
|
self.deleteModal.show(() => {
|
||||||
|
|
||||||
|
if (!Number.isNaN(Number(self.deleteModal.getData()))) {
|
||||||
|
|
||||||
|
new Ajax(
|
||||||
|
'/clienteplantillaprecios/delete/' + dataId,
|
||||||
|
{
|
||||||
|
|
||||||
|
},
|
||||||
|
{},
|
||||||
|
(data, textStatus, jqXHR) => {
|
||||||
|
|
||||||
|
self.tablePlantillas.table.clearPipeline();
|
||||||
|
self.tablePlantillas.table.row($(row)).invalidate().draw();
|
||||||
|
|
||||||
|
// Se borran las lineas asociadas
|
||||||
|
new Ajax(
|
||||||
|
"/clientes/clienteplantillaprecios/update/" + dataId,
|
||||||
|
{
|
||||||
|
[this.csrf_token]: this.csrf_hash
|
||||||
|
},
|
||||||
|
{},
|
||||||
|
() => { },
|
||||||
|
(error) => {
|
||||||
|
console.log(error);
|
||||||
|
}).post();
|
||||||
|
|
||||||
|
popSuccessAlert(data.msg ?? jqXHR.statusText);
|
||||||
|
},
|
||||||
|
(error) => {
|
||||||
|
console.log(error);
|
||||||
|
}
|
||||||
|
|
||||||
|
).get();
|
||||||
|
self.deleteModal.hide();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
#initTable() {
|
||||||
|
|
||||||
|
const self = this;
|
||||||
|
|
||||||
|
const columns = [
|
||||||
|
{ 'data': 'id' },
|
||||||
|
{ 'data': 'nombre' },
|
||||||
|
|
||||||
|
];
|
||||||
|
|
||||||
|
const actions = ['edit', 'delete'];
|
||||||
|
|
||||||
|
this.tablePlantillas = new Table(
|
||||||
|
$('#tableOfClienteplantillaprecios'),
|
||||||
|
'plantillasTarifasCliente',
|
||||||
|
'/clienteplantillaprecios/datatable',
|
||||||
|
columns,
|
||||||
|
[]
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
this.tablePlantillas.init({
|
||||||
|
actions: actions,
|
||||||
|
colVisibility: false,
|
||||||
|
buttonsExport: true,
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
this.tablePlantillas.table.on('init.dt', function () {
|
||||||
|
self.tablePlantillas.table.page.len(50).draw();
|
||||||
|
});
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
headerSearcher() {
|
||||||
|
|
||||||
|
const self = this;
|
||||||
|
|
||||||
|
$('#tableOfClienteplantillaprecios thead tr').clone(false).appendTo('#tableOfClienteplantillaprecios thead');
|
||||||
|
$('#tableOfClienteplantillaprecios thead tr:eq(1) th').each(function (i) {
|
||||||
|
|
||||||
|
if (!$(this).hasClass("noFilter")) {
|
||||||
|
|
||||||
|
$(this).html('<input type="text" class="form-control " style="min-width:100px;max-width:500px;font-size:0.8rem !important;" />');
|
||||||
|
|
||||||
|
$('input', this).on('change clear', function () {
|
||||||
|
if (self.tablePlantillas.table.column(i).search() !== this.value) {
|
||||||
|
self.tablePlantillas.table
|
||||||
|
.column(i)
|
||||||
|
.search(this.value)
|
||||||
|
.draw();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$(this).html('<span></span>');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
document.addEventListener('DOMContentLoaded', function () {
|
||||||
|
|
||||||
|
new PlantillasTarifasClienteList().init();
|
||||||
|
});
|
||||||
Reference in New Issue
Block a user