Merge branch 'main' into feat/ordenes-trabajo

This commit is contained in:
amazuecos
2024-12-05 20:32:32 +01:00
38 changed files with 2256 additions and 1093 deletions

View File

@ -394,6 +394,9 @@ $routes->group('clientes', ['namespace' => 'App\Controllers\Clientes'], function
$routes->group('clienteprecios', ['namespace' => 'App\Controllers\Clientes'], function ($routes) {
$routes->post('datatable', 'ClientePrecios::datatable', ['as' => 'dataTableOfClienteprecios']);
$routes->post('datatable_editor', 'ClientePrecios::datatable_editor', ['as' => 'editorOfClienteprecios']);
$routes->post('changeplantilla', 'ClientePrecios::updatePlantilla', ['as' => 'changePlantillaOfClienteprecios']);
$routes->get('getplantilla', 'ClientePrecios::getCurrentPlantilla', ['as' => 'getPlantillaOfClienteprecios']);
$routes->post('update', 'ClientePrecios::updatePlantilla', ['as' => 'updateClienteprecios']);
});
$routes->resource('clienteprecios', ['namespace' => 'App\Controllers\Clientes', 'controller' => 'ClientePrecios', 'except' => 'show,new,create,update']);
@ -403,11 +406,13 @@ $routes->group('clienteplantillaprecios', ['namespace' => 'App\Controllers\Clien
$routes->get('add', 'Clienteplantillaprecios::add', ['as' => 'newClienteplantillaprecios']);
$routes->post('add', 'Clienteplantillaprecios::add', ['as' => 'createClienteplantillaprecios']);
$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->post('datatable', 'Clienteplantillaprecios::datatable', ['as' => 'dataTableOfClientesplantillaprecios']);
$routes->post('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) {

View File

@ -1,4 +1,5 @@
<?php namespace App\Controllers\Clientes;
<?php
namespace App\Controllers\Clientes;
use App\Controllers\BaseResourceController;
@ -45,40 +46,36 @@ class ClientePrecios extends \App\Controllers\BaseResourceController
parent::initController($request, $response, $logger);
}
public function update($requestedId = null)
public function updatePlantilla()
{
if ($this->request->getPost()) :
if ($requestedId == null) :
return;
endif;
if ($this->request->isAJAX()) {
$postData = $this->request->getJSON();
$postData = $this->request->getPost();
$cliente_id = $postData['cliente_id'] ?? -1;
$plantilla_id = $postData['plantilla_id'] ?? -1;
$plantilla_id = $postData->plantilla_id ?? -1;
// Se ha actualizado un registro por lo que no es una plantilla
if($plantilla_id == -1){
$this->model->clean_plantilla_id($requestedId);
}
else if($requestedId== -1){ // actualizar todos los clientes que usan una plantilla
if ($plantilla_id == -1) {
$this->model->clean_plantilla_id($cliente_id);
} else if ($cliente_id == -1) { // actualizar todos los clientes que usan una plantilla
$this->model->update_from_plantilla($plantilla_id);
} else {
$this->model->copy_from_plantilla($cliente_id, $plantilla_id);
}
else{
$this->model->copy_from_plantilla($requestedId, $plantilla_id);
}
$newTokenHash = csrf_hash();
$csrfTokenName = csrf_token();
$data = [
$csrfTokenName => $newTokenHash
];
return $this->respond($data);
endif; // ($requestMethod === 'post')
} else {
return $this->failUnauthorized('Invalid request', 403);
}
}
@ -93,92 +90,114 @@ class ClientePrecios extends \App\Controllers\BaseResourceController
}
$start = $reqData['start'] ?? 0;
$length = $reqData['length'] ?? 5;
$requestedOrder = $reqData['order']['0']['column'] ?? 0;
$requestedOrder2 = $reqData['order']['1']['column'] ?? $requestedOrder;
$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;
$requestedOrder = $reqData['order'] ?? [];
$searchValues = get_filter_datatables_columns($reqData);
$cliente_id = $reqData['cliente_id'] ?? 0;
$resourceData = $this->model->getResource($cliente_id)
->orderBy($order, $dir)->orderBy($order2, $dir2)->orderBy($order3, $dir3)->orderBy($order4, $dir4)->orderBy($order5, $dir5)
->limit($length, $start)->get()->getResultObject();
$resourceData = $this->model->getResource($searchValues, $cliente_id);
foreach ($requestedOrder as $order) {
$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(
$resourceData,
$this->model->getResource($cliente_id)->countAllResults(),
$this->model->getResource($cliente_id)->countAllResults()
$this->model->getResource($searchValues, $cliente_id)->countAllResults(),
$this->model->getResource($searchValues, $cliente_id)->countAllResults()
));
} else {
return $this->failUnauthorized('Invalid request', 403);
}
}
public function datatable_editor() {
public function datatable_editor()
{
if ($this->request->isAJAX()) {
include(APPPATH . "ThirdParty/DatatablesEditor/DataTables.php");
// Build our Editor instance and process the data coming from _POST
$response = Editor::inst( $db, 'cliente_precios' )
$response = Editor::inst($db, 'cliente_precios')
->fields(
Field::inst( 'plantilla_id' ),
Field::inst( 'cliente_id' ),
Field::inst( 'tipo' ),
Field::inst( 'tipo_maquina' ),
Field::inst( 'tipo_impresion' ),
Field::inst( 'user_updated_id' ),
Field::inst( 'updated_at' ),
Field::inst( 'is_deleted' ),
Field::inst( 'tiempo_min' )
->getFormatter( 'Format::toDecimalChar')->setFormatter( 'Format::fromDecimalChar')
->validator( 'Validate::notEmpty',array(
'message' => lang('ClientePrecios.validation.required'))
Field::inst('plantilla_id'),
Field::inst('cliente_id'),
Field::inst('tipo'),
Field::inst('tipo_maquina'),
Field::inst('tipo_impresion'),
Field::inst('user_updated_id'),
Field::inst('updated_at'),
Field::inst('is_deleted'),
Field::inst('tiempo_min')
->getFormatter('Format::toDecimalChar')->setFormatter('Format::fromDecimalChar')
->validator(
'Validate::notEmpty',
array(
'message' => lang('ClientePrecios.validation.required')
)
)
->validator('Validate::numeric', array(
->validator(
'Validate::numeric',
array(
"decimal" => ',',
'message' => lang('ClientePrecios.validation.decimal'))
'message' => lang('ClientePrecios.validation.decimal')
)
),
Field::inst( 'tiempo_max' )
->getFormatter( 'Format::toDecimalChar')->setFormatter( 'Format::fromDecimalChar')
->validator( 'Validate::notEmpty',array(
'message' => lang('ClientePrecios.validation.required'))
Field::inst('tiempo_max')
->getFormatter('Format::toDecimalChar')->setFormatter('Format::fromDecimalChar')
->validator(
'Validate::notEmpty',
array(
'message' => lang('ClientePrecios.validation.required')
)
)
->validator('Validate::numeric', array(
"decimal" => ',',
'message' => lang('ClientePrecios.validation.decimal'))
),
Field::inst( 'precio_hora' )
->getFormatter( 'Format::toDecimalChar')->setFormatter( 'Format::fromDecimalChar')
->validator( 'Validate::notEmpty',array(
'message' => lang('ClientePrecios.validation.required'))
)
->validator('Validate::numeric', array(
"decimal" => ',',
'message' => lang('ClientePrecios.validation.decimal'))
),
Field::inst( 'margen' )
->getFormatter( 'Format::toDecimalChar')->setFormatter( 'Format::fromDecimalChar')
->validator( 'Validate::notEmpty',array(
'message' => lang('ClientePrecios.validation.required'))
)
->validator('Validate::numeric', array(
->validator(
'Validate::numeric',
array(
"decimal" => ',',
'message' => lang('ClientePrecios.validation.decimal'))
'message' => lang('ClientePrecios.validation.decimal')
)
),
Field::inst('precio_hora')
->getFormatter('Format::toDecimalChar')->setFormatter('Format::fromDecimalChar')
->validator(
'Validate::notEmpty',
array(
'message' => lang('ClientePrecios.validation.required')
)
)
->validator(
'Validate::numeric',
array(
"decimal" => ',',
'message' => lang('ClientePrecios.validation.decimal')
)
),
Field::inst('margen')
->getFormatter('Format::toDecimalChar')->setFormatter('Format::fromDecimalChar')
->validator(
'Validate::notEmpty',
array(
'message' => lang('ClientePrecios.validation.required')
)
)
->validator(
'Validate::numeric',
array(
"decimal" => ',',
'message' => lang('ClientePrecios.validation.decimal')
)
),
)
@ -203,21 +222,19 @@ class ClientePrecios extends \App\Controllers\BaseResourceController
}
})
->on('preCreate', function ($editor, &$values) {
$session = session();
$datetime = (new \CodeIgniter\I18n\Time("now"));
$editor
->field('user_updated_id')
->setValue($session->id_user);
->setValue(auth()->user()->id);
$editor
->field('updated_at')
->setValue($datetime->format('Y-m-d H:i:s'));
})
->on('preEdit', function ($editor, &$values) {
$session = session();
$datetime = (new \CodeIgniter\I18n\Time("now"));
$editor
->field('user_updated_id')
->setValue($session->id_user);
->setValue(auth()->user()->id);
$editor
->field('updated_at')
->setValue($datetime->format('Y-m-d H:i:s'));
@ -238,4 +255,16 @@ class ClientePrecios extends \App\Controllers\BaseResourceController
}
}
public function getCurrentPlantilla()
{
if ($this->request->isAJAX()) {
$cliente_id = $this->request->getGet('cliente_id');
$plantilla = $this->model->getPlantilla($cliente_id);
return $this->respond($plantilla);
} else {
return $this->failUnauthorized('Invalid request', 403);
}
}
}

View File

@ -1,4 +1,5 @@
<?php namespace App\Controllers\Clientes;
<?php
namespace App\Controllers\Clientes;
use App\Controllers\BaseResourceController;
@ -70,51 +71,48 @@ class Clienteplantillaprecios extends \App\Controllers\BaseResourceController
// plantilla desde la lista
public function update($requestedId = null)
{
if ($this->request->getPost()) :
if ($requestedId == null) :
return;
endif;
$model = model('App\Models\Clientes\ClientePlantillaPreciosLineasModel');
$model->delete_values($requestedId);
$newTokenHash = csrf_hash();
$csrfTokenName = csrf_token();
$data = [
$csrfTokenName => $newTokenHash
];
return $this->respond($data);
if ($requestedId == null):
return;
endif;
$model = model('App\Models\Clientes\ClientePlantillaPreciosLineasModel');
$model->delete_values($requestedId);
$newTokenHash = csrf_hash();
$csrfTokenName = csrf_token();
$data = [
$csrfTokenName => $newTokenHash
];
return $this->respond($data);
endif; // ($requestMethod === 'post')
}
public function add()
{
if ($this->request->getPost()) :
if ($this->request->getPost()):
$nullIfEmpty = true; // !(phpversion() >= '8.1');
$postData = $this->request->getPost();
$cliente_id = $postData['cliente_id'] ?? -1;
$from_client_data = $postData['from_client_data'] ?? 0;
$sanitizedData = $this->sanitized($postData, $nullIfEmpty);
// JJO
$sanitizedData['user_created_id'] = auth()->user()->id;
$noException = true;
if ($successfulResult = $this->canValidate()) : // if ($successfulResult = $this->validate($this->formValidationRules) ) :
if ($successfulResult = $this->canValidate()): // if ($successfulResult = $this->validate($this->formValidationRules) ) :
if ($this->canValidate()) :
if ($this->canValidate()):
try {
$successfulResult = $this->model->skipValidation(true)->save($sanitizedData);
} catch (\Exception $e) {
@ -126,24 +124,27 @@ class Clienteplantillaprecios extends \App\Controllers\BaseResourceController
$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
if ($from_client_data == 1) {
$thenRedirect = false;
} else {
$thenRedirect = true; // Change this to false if you want your user to stay on the form after submission
}
endif;
if ($noException && $successfulResult) :
if ($noException && $successfulResult):
$id = $this->model->db->insertID();
$message = lang('Basic.global.saveSuccess', [lang('Basic.global.record')]) . '.';
if($cliente_id != -1){
if ($cliente_id != -1) {
$modelLineas = model('App\Models\Clientes\ClientePlantillaPreciosLineasModel');
$modelLineas->copy_from_cliente($cliente_id, $id);
$modelClientePrecios = model('App\Models\Clientes\ClientePreciosModel');
$modelClientePrecios->set_plantilla_id($cliente_id, $id);
return ;
}
else{
if ($thenRedirect) :
if (!empty($this->indexRoute)) :
return $this->respond(['status' => 'success', 'id' => $id]);
} else {
if ($thenRedirect):
if (!empty($this->indexRoute)):
//return redirect()->to(route_to($this->indexRoute))->with('sweet-success', $message);
return redirect()->to(site_url('/clientes/clienteplantillaprecios/edit/' . $id))->with('message', $message);
else:
@ -171,35 +172,35 @@ class Clienteplantillaprecios extends \App\Controllers\BaseResourceController
{
if ($requestedId == null) :
if ($requestedId == null):
return $this->redirect2listView();
endif;
$id = filter_var($requestedId, FILTER_SANITIZE_URL);
$clientePlantillaPreciosEntity = $this->model->find($id);
if ($clientePlantillaPreciosEntity == false) :
if ($clientePlantillaPreciosEntity == false):
$message = lang('Basic.global.notFoundWithIdErr', [mb_strtolower(lang('Clientes.cliente')), $id]);
return $this->redirect2listView('sweet-error', $message);
endif;
if ($this->request->getPost()) :
if ($this->request->getPost()):
$nullIfEmpty = true; // !(phpversion() >= '8.1');
$postData = $this->request->getPost();
$sanitizedData = $this->sanitized($postData, $nullIfEmpty);
// JJO
$sanitizedData['user_updated_id'] = auth()->user()->id;
$noException = true;
if ($successfulResult = $this->canValidate()) : // if ($successfulResult = $this->validate($this->formValidationRules) ) :
if ($successfulResult = $this->canValidate()): // if ($successfulResult = $this->validate($this->formValidationRules) ) :
if ($this->canValidate()) :
if ($this->canValidate()):
try {
$successfulResult = $this->model->skipValidation(true)->update($id, $sanitizedData);
} catch (\Exception $e) {
@ -216,12 +217,12 @@ class Clienteplantillaprecios extends \App\Controllers\BaseResourceController
$thenRedirect = false;
endif;
if ($noException && $successfulResult) :
if ($noException && $successfulResult):
$id = $clientePlantillaPreciosEntity->id ?? $id;
$message = lang('Basic.global.updateSuccess', [lang('Basic.global.record')]) . '.';
if ($thenRedirect) :
if (!empty($this->indexRoute)) :
if ($thenRedirect):
if (!empty($this->indexRoute)):
return redirect()->to(route_to($this->indexRoute))->with('sweet-success', $message);
else:
return $this->redirect2listView('sweet-success', $message);
@ -236,7 +237,7 @@ class Clienteplantillaprecios extends \App\Controllers\BaseResourceController
//var_dump($clientePlantillaPreciosEntity); dd();
$this->viewData['clienteplantillapreciosEntity'] = $clientePlantillaPreciosEntity;
$this->viewData['formAction'] = route_to('updateClienteplantillaprecios', $id);
$this->viewData['boxTitle'] = lang('Basic.global.edit2') . ' ' . lang('Clientes.moduleTitle') . ' ' . lang('Basic.global.edit3');
@ -246,6 +247,23 @@ class Clienteplantillaprecios extends \App\Controllers\BaseResourceController
} // end function edit(...)
public function updatePlantillaEnCliente(){
if ($this->request->isAJAX()) {
$reqData = $this->request->getPost();
$plantilla_id = $reqData['plantilla_id'] ?? -1;
$model = model('App\Models\Clientes\ClientePreciosModel');
$model->update_plantilla_id($plantilla_id);
} else {
return $this->failUnauthorized('Invalid request', 403);
}
}
public function datatable()
{
if ($this->request->isAJAX()) {
@ -257,16 +275,16 @@ class Clienteplantillaprecios extends \App\Controllers\BaseResourceController
}
$start = $reqData['start'] ?? 0;
$length = $reqData['length'] ?? 5;
$search = $reqData['search']['value'];
$searchValues = get_filter_datatables_columns($reqData);
$requestedOrder = $reqData['order']['0']['column'] ?? 1;
$order = ClientePlantillaPreciosModel::SORTABLE[$requestedOrder > 0 ? $requestedOrder : 0];
$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(
$resourceData,
$this->model->getResource()->countAllResults(),
$this->model->getResource($search)->countAllResults()
$this->model->getResource($searchValues)->countAllResults()
));
} else {
return $this->failUnauthorized('Invalid request', 403);
@ -275,34 +293,32 @@ class Clienteplantillaprecios extends \App\Controllers\BaseResourceController
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;
try{
$menu = $this->model->getSelect2MenuItems($columns2select, $columns2select[1], $onlyActiveOnes, $searchStr, true);
$nonItem = new \stdClass;
$nonItem->id = '';
$nonItem->text = '- ' . lang('Basic.global.None') . ' -';
array_unshift($menu, $nonItem);
}
catch(Exception $e){
$menu = [];
$query = $this->model->builder()->select(
[
"id",
"nombre as name"
]
)->where("deleted_at", null);
if ($this->request->getGet("q")) {
$query->groupStart()
->orLike("cliente_plantilla_precios.nombre", $this->request->getGet("q"))
->groupEnd();
}
$newTokenHash = csrf_hash();
$csrfTokenName = csrf_token();
$data = [
'menu' => $menu,
$csrfTokenName => $newTokenHash
];
return $this->respond($data);
$items = $query->get()->getResultObject();
// add a custom item at the beginning
$customItem = new \stdClass;
$customItem->id = 0;
$customItem->name = "Personalizado";
array_unshift($items, $customItem);
return $this->response->setJSON($items);
} else {
return $this->failUnauthorized('Invalid request', 403);
}
}
}

View File

@ -93,31 +93,27 @@ class Clienteplantillaprecioslineas extends \App\Controllers\BaseResourceControl
}
$start = $reqData['start'] ?? 0;
$length = $reqData['length'] ?? 5;
$requestedOrder = $reqData['order']['0']['column'] ?? 0;
$requestedOrder2 = $reqData['order']['1']['column'] ?? $requestedOrder;
$requestedOrder3 = $reqData['order']['2']['column'] ?? $requestedOrder;
$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;
$requestedOrder = $reqData['order'] ?? [];
$searchValues = get_filter_datatables_columns($reqData);
$plantilla_id = $reqData['plantilla_id'] ?? 0;
$resourceData = $this->model->getResource($plantilla_id)
->orderBy($order, $dir)->orderBy($order2, $dir2)->orderBy($order3, $dir3)->orderBy($order4, $dir4)->orderBy($order5, $dir5)
->limit($length, $start)->get()->getResultObject();
$resourceData = $this->model->getResource($searchValues, $plantilla_id);
foreach ($requestedOrder as $order) {
$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(
$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 {
return $this->failUnauthorized('Invalid request', 403);
@ -138,6 +134,8 @@ class Clienteplantillaprecioslineas extends \App\Controllers\BaseResourceControl
Field::inst( 'tipo_maquina' ),
Field::inst( 'tipo_impresion' ),
Field::inst( 'user_updated_id' ),
Field::inst( 'deleted_at' ),
Field::inst( 'is_deleted' ),
Field::inst( 'updated_at' ),
Field::inst( 'tiempo_min' )
->getFormatter( 'Format::toDecimalChar')->setFormatter( 'Format::fromDecimalChar')
@ -201,21 +199,20 @@ class Clienteplantillaprecioslineas extends \App\Controllers\BaseResourceControl
}
})
->on('preCreate', function ($editor, &$values) {
$session = session();
$datetime = (new \CodeIgniter\I18n\Time("now"));
$editor
->field('user_updated_id')
->setValue($session->id_user);
->setValue(auth()->user()->id);
$editor
->field('updated_at')
->setValue($datetime->format('Y-m-d H:i:s'));
})
->on('preEdit', function ($editor, &$values) {
$session = session();
$datetime = (new \CodeIgniter\I18n\Time("now"));
$editor
->field('user_updated_id')
->setValue($session->id_user);
->setValue(auth()->user()->id);
$editor
->field('updated_at')
->setValue($datetime->format('Y-m-d H:i:s'));

View File

@ -298,13 +298,24 @@ class Papelesgenericos extends \App\Controllers\BaseResourceController
{
if ($this->request->isAJAX()) {
$tirada = goSanitize($this->request->getGet('tirada'))[0] ?? null;
$POD = null;
if($tirada != null){
$POD_value = model('App\Models\Configuracion\ConfiguracionSistemaModel')->getPOD();
if(intval($tirada) <= intval($POD_value)){
$POD = true;
}
else{
$POD = false;
}
}
$tipo = goSanitize($this->request->getGet('tipo'))[0];
$selected_papel = goSanitize($this->request->getGet('papel'))[0] ?? null;
$cubierta = goSanitize($this->request->getGet('cubierta'))[0] ?? 0;
$tapa_dura = goSanitize($this->request->getGet('tapa_dura'))[0] ?? null;
$menu = $this->model->getPapelCliente($tipo, $cubierta, $selected_papel, $tapa_dura, false);
$menu2 = $this->model->getPapelCliente($tipo, $cubierta, $selected_papel, $tapa_dura, true);
$menu = $this->model->getPapelCliente($tipo, $cubierta, $selected_papel, $tapa_dura, false, $POD);
$menu2 = $this->model->getPapelCliente($tipo, $cubierta, $selected_papel, $tapa_dura, true, $POD);
$newTokenHash = csrf_hash();
$csrfTokenName = csrf_token();
@ -325,10 +336,21 @@ class Papelesgenericos extends \App\Controllers\BaseResourceController
if ($this->request->isAJAX()) {
$tirada = goSanitize($this->request->getGet('tirada'))[0] ?? null;
$POD = null;
if($tirada != null){
$POD_value = model('App\Models\Configuracion\ConfiguracionSistemaModel')->getPOD();
if(intval($tirada) <= intval($POD_value)){
$POD = true;
}
else{
$POD = false;
}
}
$tipo = goSanitize($this->request->getGet('tipo'))[0];
$cubierta = goSanitize($this->request->getGet('cubierta'))[0] ?? 0;
$items = $this->model->getPapelCliente($tipo, $cubierta, null, true);
$items = $this->model->getPapelCliente($tipo, $cubierta, null, true, $POD);
$items = array_map(function ($item) {
return [
'id' => $item->id,

View File

@ -265,7 +265,7 @@ class Users extends \App\Controllers\GoBaseController
foreach ($chatDepartments as $chatDepartment) {
$this->chat_department_user_model->insert([
"user_id" => $id,
"chat_department_id" => $this->chat_department_model->where("name", $chatDepartment)->first()["id"]
"chat_department_id" => $this->chat_department_model->where("name", $chatDepartment)->first()->id
]);
}
$id = $user->id ?? $id;

View File

@ -21,9 +21,22 @@ class Language extends BaseController
public function getTranslation()
{
$translationFile = $this->request->getPost('translationFile');
$locale = $this->request->getPost('locale');
$path = "Language/{$locale}/$translationFile.php";
$lang = require APPPATH.$path;
return json_encode($lang);
$data = [];
if(is_array($translationFile)){
foreach($translationFile as $file){
$locale = $this->request->getPost('locale');
$path = "Language/{$locale}/$file.php";
$lang = require APPPATH.$path;
$data[$file] = $lang;
}
return json_encode($data);
}
else{
$locale = $this->request->getPost('locale');
$path = "Language/{$locale}/$translationFile.php";
$lang = require APPPATH.$path;
return json_encode($lang);
}
}
}

View File

@ -522,6 +522,11 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
'a_favor_fibra' => 1,
);
// Para POD siempre es HQ
if ($tirada[0] <= $POD) {
$isHq = true;
}
$input_data = array(
'uso' => 'interior',
'tipo_impresion_id' => $tipo_impresion_id,
@ -1509,6 +1514,11 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
$info['merma'] = $datosPedido->merma;
}
// Para POD siempre es HQ
if ($tirada[$t] <= $POD) {
$isHq = true;
}
$input_data = array(
'uso' => 'interior',
'tipo_impresion_id' => $tipo_impresion_id,

View File

@ -28,5 +28,6 @@ return [
"add_notification" => "Notificación",
"check_as_unviewed" => "Marcar como no leídos",
"add_notification_message" => "Envía a los usuarios añadidos una notificación con los mensajes presentes en el chat.",
"chat_title_presupuesto" => 'Presupuesto[{title,string,0}][{id}]'
"chat_title_presupuesto" => 'Presupuesto[{title,string,0}][{id}]',
"no_messages_notification" => 'No hay mensajes que revisar por el momento'
];

View File

@ -7,14 +7,16 @@ class ClientePlantillaPreciosLineasModel extends \App\Models\BaseModel
protected $table = "cliente_plantilla_precios_lineas";
const SORTABLE = [
0 => "t1.tipo",
1 => "t1.tipo_maquina",
2 => "t1.tipo_impresion",
3 => "t1.tiempo_min",
4 => "t1.tiempo_max",
5 => "t1.precio_hora",
6 => "t1.margen",
0 => "t1.id",
1 => "t1.tipo",
2 => "t1.tipo_maquina",
3 => "t1.tipo_impresion",
4 => "t1.tiempo_min",
5 => "t1.tiempo_max",
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){
$datetime = (new \CodeIgniter\I18n\Time("now"));
$date_value = $datetime->format('Y-m-d H:i:s');
$this->db
->table($this->table . " t1")
->where('t1.plantilla_id', $plantilla_id)
->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();
}
@ -127,14 +139,15 @@ class ClientePlantillaPreciosLineasModel extends \App\Models\BaseModel
*
* @return \CodeIgniter\Database\BaseBuilder
*/
public function getResource($plantilla_id = -1)
public function getResource($search = [], $plantilla_id = -1)
{
$builder = $this->db
->table($this->table . " t1")
->select(
"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.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");
@ -142,8 +155,19 @@ class ClientePlantillaPreciosLineasModel extends \App\Models\BaseModel
$builder->where('t1.is_deleted', 0);
$builder->where('t1.plantilla_id', $plantilla_id);
return $builder;
if (empty($search))
return $builder;
else {
$builder->groupStart();
foreach ($search as $col_search) {
if ($col_search[1] > 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){
@ -183,14 +207,13 @@ class ClientePlantillaPreciosLineasModel extends \App\Models\BaseModel
function copy_from_cliente($cliente_id = 0, $plantilla_id = 0){
$session = session();
$datetime = (new \CodeIgniter\I18n\Time("now"));
$date_value = $datetime->format('Y-m-d H:i:s');
// Se cargan los valores en la plantilla
$clientePreciosModel = model('App\Models\Clientes\ClientePreciosModel');
$values = $clientePreciosModel->getResource($cliente_id)->get()->getResultObject();
$values = $clientePreciosModel->getResource([], $cliente_id)->get()->getResultObject();
foreach ($values as $value) {
$this->db
->table($this->table . " t1")
@ -201,7 +224,7 @@ class ClientePlantillaPreciosLineasModel extends \App\Models\BaseModel
->set('tiempo_min', $value->tiempo_min)
->set('tiempo_max', $value->tiempo_max)
->set('margen', $value->margen)
->set('user_updated_id', $session->id_user)
->set('user_updated_id', auth()->user()->id)
->set('updated_at', $date_value)
->insert();
}

View File

@ -7,7 +7,8 @@ class ClientePlantillaPreciosModel extends \App\Models\BaseModel
protected $table = "cliente_plantilla_precios";
const SORTABLE = [
0 => "t1.nombre",
0 => "t1.id",
1 => "t1.nombre",
];
/**
@ -48,11 +49,11 @@ class ClientePlantillaPreciosModel extends \App\Models\BaseModel
/**
* Get resource data.
*
* @param string $search
* @param array $search
*
* @return \CodeIgniter\Database\BaseBuilder
*/
public function getResource(string $search = "", $cliente_id = -1)
public function getResource($search = [])
{
$builder = $this->db
->table($this->table . " t1")
@ -61,14 +62,17 @@ class ClientePlantillaPreciosModel extends \App\Models\BaseModel
);
$builder->where('t1.is_deleted', 0);
return empty($search)
? $builder
: $builder
->groupStart()
->like("t1.nombre", $search)
->groupEnd();
if (empty($search))
return $builder;
else {
$builder->groupStart();
foreach ($search as $col_search) {
$builder->like(self::SORTABLE[$col_search[0]], $col_search[2]);
}
$builder->groupEnd();
return $builder;
}
}
}

View File

@ -14,14 +14,14 @@ class ClientePreciosModel extends \App\Models\BaseModel
protected $useAutoIncrement = true;
const SORTABLE = [
0 => "t1.tipo",
1 => "t1.tipo_maquina",
2 => "t1.tipo_impresion",
3 => "t1.tiempo_min",
4 => "t1.tiempo_max",
5 => "t1.precio_hora",
6 => "t1.margen",
0 => "t1.id",
1 => "t1.tipo",
2 => "t1.tipo_maquina",
3 => "t1.tipo_impresion",
4 => "t1.tiempo_min",
5 => "t1.tiempo_max",
6 => "t1.precio_hora",
7 => "t1.margen",
];
protected $allowedFields = [
@ -153,7 +153,7 @@ class ClientePreciosModel extends \App\Models\BaseModel
// Se cargan los valores de la plantilla
$plantillaModel = model('App\Models\Clientes\ClientePlantillaPreciosLineasModel');
$values = $plantillaModel->getResource($plantilla_id)->get()->getResultObject();
$values = $plantillaModel->getResource([],$plantilla_id)->get()->getResultObject();
foreach ($values as $value) {
$this->db
->table($this->table . " t1")
@ -178,7 +178,6 @@ class ClientePreciosModel extends \App\Models\BaseModel
function update_from_plantilla($plantilla_id = 0){
$session = session();
$datetime = (new \CodeIgniter\I18n\Time("now"));
$date_value = $datetime->format('Y-m-d H:i:s');
@ -187,6 +186,7 @@ class ClientePreciosModel extends \App\Models\BaseModel
->table($this->table . " t1")
->select("t1.cliente_id AS id")
->where('t1.plantilla_id', $plantilla_id)
->where('t1.is_deleted', 0)
->distinct()
->get()->getResultObject();
@ -200,7 +200,7 @@ class ClientePreciosModel extends \App\Models\BaseModel
// Se cargan los valores de la plantilla
$plantillaModel = model('App\Models\Clientes\ClientePlantillaPreciosLineasModel');
$values = $plantillaModel->getResource($plantilla_id)->get()->getResultObject();
$values = $plantillaModel->getResource([], $plantilla_id)->get()->getResultObject();
foreach ($values as $value) {
$this->db
->table($this->table . " t1")
@ -215,7 +215,7 @@ class ClientePreciosModel extends \App\Models\BaseModel
->set('margen', $value->margen)
->set('user_updated_id', $value->user_updated_id)
->set('updated_at', $value->updated_at)
->set('user_created_id', $session->id_user)
->set('user_created_id', auth()->user()->id)
->set('created_at', $date_value)
->insert();
}
@ -256,7 +256,7 @@ class ClientePreciosModel extends \App\Models\BaseModel
*
* @return \CodeIgniter\Database\BaseBuilder
*/
public function getResource($cliente_id = -1)
public function getResource($search = [], $cliente_id = -1)
{
$builder = $this->db
->table($this->table . " t1")
@ -271,11 +271,43 @@ class ClientePreciosModel extends \App\Models\BaseModel
$builder->where('t1.is_deleted', 0);
$builder->where('t1.cliente_id', $cliente_id);
return $builder;
if (empty($search))
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 getPlantilla($cliente_id = -1){
$builder = $this->db
->table($this->table . " t1")
->select(
"t1.plantilla_id AS id, t2.nombre AS nombre"
);
$builder->where('t1.is_deleted', 0);
$builder->where('t1.cliente_id', $cliente_id);
$builder->join("cliente_plantilla_precios t2", "t1.plantilla_id = t2.id", "left");
$builder->limit(1);
$values = $builder->get()->getResultArray();
if(count($values)>0){
return $values[0];
}
return [];
}
public function checkIntervals($data = [], $id_linea = null, $cliente_id = null){

View File

@ -313,7 +313,7 @@ class PapelGenericoModel extends \App\Models\BaseModel
}
public function getPapelCliente($tipo, $is_cubierta = false, $selected_papel_id = null, $tapa_dura = null, $papel_especial = false)
public function getPapelCliente($tipo, $is_cubierta = false, $selected_papel_id = null, $tapa_dura = null, $papel_especial = false, $POD = null)
{
/*
1.-> Tipo impresion
@ -322,6 +322,13 @@ class PapelGenericoModel extends \App\Models\BaseModel
4.-> papeles genericos que aparecen en esos papeles impresion
*/
if ($POD == true && ($tipo == 'color' || $tipo == 'negro')) {
if($tipo == 'color')
$tipo = 'colorhq';
else if($tipo == 'negro')
$tipo = 'negrohq';
}
if ($selected_papel_id != null) {
$builder = $this->db
->table($this->table . " t1")
@ -404,6 +411,14 @@ class PapelGenericoModel extends \App\Models\BaseModel
if ($tipo == 'colorhq' || $tipo == 'negrohq') {
$builder->where("t2.rotativa", 0);
}
else{
if($POD == false){
$builder->where("t2.rotativa", 1);
}
else if ($POD == true){
$builder->where("t2.rotativa", 0);
}
}
if ($selected_papel_id != null)

View File

@ -523,6 +523,11 @@ class PresupuestoClienteService extends BaseService
$linea_rotativa = array_merge($linea_rotativa, $lineas);
}
}
$linea_rotativa = array_filter($linea_rotativa, function($item) {
return count($item['fields']['num_formas']) > 1;
});
if (count($linea_rotativa) > 0) {
usort(

View File

@ -639,11 +639,11 @@ class PresupuestoService extends BaseService
$calles = (new \App\Models\Configuracion\MaquinasCallesModel())->getCallesForMaquina($maquina->maquina_id, $h1_temp);
// Si son mas de 2 formas
if (count($calles) > 0)
$h1 = ($h1_temp * $anchoForCalculo + 2 * $calles[0]->externas + ($h1_temp - 1) * $calles[0]->internas < ($maquina->ancho)) ? $h1_temp : $h1_temp - 1;
$h1 = ($h1_temp * $anchoForCalculo + 2 * $calles[0]->externas + ($h1_temp - 1) * $calles[0]->internas < (floatval($maquina->ancho))) ? $h1_temp : $h1_temp - 1;
else
$h1 = $h1_temp;
$v1 = floor($maquina->alto_click / $altoForCalculo);
$v1 = floor(floatval($maquina->alto_click) / $altoForCalculo);
$formas_h = $h1 * $v1; //p1
}
// verticales
@ -651,10 +651,10 @@ class PresupuestoService extends BaseService
$calles = (new \App\Models\Configuracion\MaquinasCallesModel())->getCallesForMaquina($maquina->maquina_id, $h2_temp);
if (count($calles) > 0)
$h2 = ($h2_temp * $altoForCalculo + 2 * $calles[0]->externas + ($h2_temp - 1) * $calles[0]->internas < ($maquina->ancho)) ? $h2_temp : $h2_temp - 1;
$h2 = ($h2_temp * $altoForCalculo + 2 * $calles[0]->externas + ($h2_temp - 1) * $calles[0]->internas < (floatval($maquina->ancho))) ? $h2_temp : $h2_temp - 1;
else
$h2 = $h2_temp;
$v2 = floor($maquina->alto_click / $anchoForCalculo);
$v2 = floor(floatval($maquina->alto_click) / $anchoForCalculo);
$formas_v = $h2 * $v2; //p2
}
@ -1061,16 +1061,16 @@ class PresupuestoService extends BaseService
),
'cliente_id' => ($input_data['presupuesto'])->cliente_id,
'datosTipolog' => [
(object) array(
'negro' => $linea->rotativa_negro,
'cyan' => $linea->rotativa_cyan,
'magenta' => $linea->rotativa_magenta,
'amarillo' => $linea->rotativa_amarillo,
'cg' => $linea->rotativa_cg,
'gota_negro' => $linea->rotativa_gota_negro,
'gota_color' => $linea->rotativa_gota_color,
)
]
(object) array(
'negro' => $linea->rotativa_negro,
'cyan' => $linea->rotativa_cyan,
'magenta' => $linea->rotativa_magenta,
'amarillo' => $linea->rotativa_amarillo,
'cg' => $linea->rotativa_cg,
'gota_negro' => $linea->rotativa_gota_negro,
'gota_color' => $linea->rotativa_gota_color,
)
]
];
$comp_data = PresupuestoService::obtenerComparadorRotativa($datos);
@ -1816,7 +1816,7 @@ class PresupuestoService extends BaseService
}
if ($uso == 'cubierta' || $uso == 'sobrecubierta') {
$linea['fields']['dimension_desarrollo']['ancho'] = $datosPedido->anchoExteriores;
$linea['fields']['dimension_desarrollo']['alto'] = $datosPedido->altoExteriores;
}

View File

@ -561,7 +561,6 @@
<?php if ($formAction !== route_to('clienteAdd')){ ?>
<div class="tab-pane fade" id="tarifascliente" role="tabpanel">
<?= view("themes/vuexy/form/clientes/cliente/convert2templateModal") ?>
<div class='row'>
<div class="col-md-12 col-lg-4 px-4">
<div class="mb-3">
@ -584,6 +583,7 @@
<table id="tableOfPrecios" class="table table-striped table-hover" style="width: 100%;">
<thead>
<tr>
<th>ID</th>
<th><?= lang('ClientePrecios.tipo') ?></th>
<th><?= lang('ClientePrecios.tipo_maquina') ?></th>
<th><?= lang('ClientePrecios.tipo_impresion') ?></th>
@ -591,10 +591,10 @@
<th><?= lang('ClientePrecios.tiempo_max') ?></th>
<th><?= lang('ClientePrecios.precio_hora') ?></th>
<th><?= lang('ClientePrecios.margen') ?></th>
<th><?= lang('ClientePrecios.user_updated_id') ?></th>
<th><?= lang('ClientePrecios.updated_at') ?></th>
<th>plantilla_id</th>
<th class="text-nowrap" style="min-width:100px"><?= lang('Basic.global.Action') ?></th>
<th class="noFilter"><?= lang('ClientePrecios.user_updated_id') ?></th>
<th class="noFilter"><?= lang('ClientePrecios.updated_at') ?></th>
<th class="noFilter noVis">plantilla_id</th>
<th class="text-nowrap noFilter noVis" style="min-width:100px"><?= lang('Basic.global.Action') ?></th>
</tr>
</thead>
<tbody>
@ -880,345 +880,6 @@ $(document).on('click', '.btn-remove', function(e) {
<?=$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
}
});
const lastColNr_lineas = $('#tableOfPrecios').find("tr:first th").length - 1;
const actionBtns_lineas = 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>
`;
};
const tipo_linea = [
{label:'<?= lang('ClientePrecios.interior') ?>', value:'interior'},
{label:'<?= lang('ClientePrecios.cubierta') ?>', value: 'cubierta'},
{label:'<?= lang('ClientePrecios.sobrecubierta') ?>', value: 'sobrecubierta'}
];
const tipo_maquina = [
{label: '<?= lang('ClientePrecios.toner') ?>', value:'toner'},
{label: '<?= lang('ClientePrecios.inkjet') ?>', value:'inkjet'},
];
const tipo_impresion = [
{label: '<?= lang('ClientePrecios.negro') ?>', value:'negro'},
{label: '<?= lang('ClientePrecios.negrohq') ?>', value:'negrohq'},
{label: '<?= lang('ClientePrecios.color') ?>', value:'color'},
{label: '<?= lang('ClientePrecios.colorhq') ?>', value:'colorhq'},
];
var editorPrecios = new $.fn.dataTable.Editor( {
ajax: {
url: "<?= route_to('editorOfClienteprecios') ?>",
headers: {
<?= csrf_token() ?? "token" ?> : <?= csrf_token() ?>v,
},
},
table : "#tableOfPrecios",
idSrc: 'id',
fields: [ {
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"
}, {
name: "user_updated_id",
type:'hidden',
}, {
name: "updated_at",
type:'hidden',
}, {
"name": "plantilla_id",
"type": "hidden"
},{
"name": "cliente_id",
"type": "hidden"
},{
"name": "deleted_at",
"type": "hidden"
},{
"name": "is_deleted",
"type": "hidden"
},
]
} );
editorPrecios.on( 'preSubmit', function ( e, d, type ) {
if ( type === 'create'){
d.data[0]['cliente_id'] = id;
}
else if(type === 'edit' ) {
for (v in d.data){
d.data[v]['cliente_id'] = id;
}
}
});
editorPrecios.on( 'postSubmit', function ( e, json, data, action ) {
yeniden(json.<?= csrf_token() ?>);
});
editorPrecios.on( 'submitSuccess', function ( e, json, data, action ) {
theTablePrecios.clearPipeline();
theTablePrecios.draw();
});
editorPrecios.on ('postEdit', function ( e, json, data, action ) {
const domain = window.location.origin
fetch(domain + "/clientes/clienteprecios/update/" + id , {
method: "POST",
body: JSON.stringify({
<?= csrf_token() ?? "token" ?> : <?= csrf_token() ?>v
}),
headers: {
"Content-type": "application/json; charset=UTF-8"
}
})
})
editorPrecios.on ('postCreate', function ( e, json, data, action ) {
const domain = window.location.origin
fetch(domain + "/clientes/clienteprecios/update/" + id , {
method: "POST",
body: JSON.stringify({
<?= csrf_token() ?? "token" ?> : <?= csrf_token() ?>v
}),
headers: {
"Content-type": "application/json; charset=UTF-8"
}
})
})
var theTablePrecios = $('#tableOfPrecios').DataTable( {
serverSide: true,
processing: true,
autoWidth: true,
responsive: true,
lengthMenu: [ 10, 25, 50, 100],
order: [[ 0, "asc" ], [ 1, "asc" ], [ 2, "asc" ], [ 3, "asc" ]],
pageLength: 50,
lengthChange: true,
searching: false,
paging: true,
info: false,
dom: '<"mt-4"><"float-end"B><"float-start"l><t><"mt-4 mb-3"p>',
ajax : $.fn.dataTable.pipeline( {
url: '<?= route_to('dataTableOfClienteprecios') ?>',
data: {
cliente_id: id,
},
method: 'POST',
headers: {'X-Requested-With': 'XMLHttpRequest'},
async: true,
}),
columns: [
{ 'data': 'tipo' ,
'render': function ( data, type, row, meta ) {
if(data=='interior')
return '<?= lang('ClientePrecios.interior') ?>';
else if(data=='cubierta')
return '<?= lang('ClientePrecios.cubierta') ?>';
else if(data=='sobrecubierta')
return '<?= lang('ClientePrecios.sobrecubierta') ?>';
}
},
{ 'data': 'tipo_maquina',
'render': function ( data, type, row, meta ) {
if(data=='toner')
return '<?= lang('ClientePrecios.toner') ?>';
else if(data=='inkjet')
return '<?= lang('ClientePrecios.inkjet') ?>';
}
},
{ 'data': 'tipo_impresion',
'render': function ( data, type, row, meta ) {
if(data=='negro')
return '<?= lang('ClientePrecios.negro') ?>';
else if(data=='negrohq')
return '<?= lang('ClientePrecios.negrohq') ?>';
else if(data=='color')
return '<?= lang('ClientePrecios.color') ?>';
else if(data=='colorhq')
return '<?= lang('ClientePrecios.colorhq') ?>';
}
},
{ 'data': 'tiempo_min' },
{ 'data': 'tiempo_max' },
{ 'data': 'precio_hora' },
{ 'data': 'margen' },
{ 'data': 'user_updated_id',
'render': function ( data, type, row, meta ) {
return row.user_updated
}
},
{ 'data': 'updated_at' },
{ 'data': 'plantilla_id' },
{
data: actionBtns_lineas,
className: 'row-edit dt-center'
}
],
columnDefs: [
{
target: 9,
orderable: false,
visible: false,
searchable: false
},
{
orderable: false,
searchable: false,
targets: [lastColNr_lineas]
},
{"orderData": [ 0, 1 ], "targets": 0 },
],
language: {
url: "/themes/vuexy/vendor/libs/datatables-sk/plugins/i18n/es-ES.json"
},
buttons: [ {
className: 'btn btn-primary me-sm-3 me-1',
extend: "createInline",
editor: editorPrecios,
formOptions: {
submitTrigger: -1,
submitHtml: '<a href="javascript:void(0);"><i class="ti ti-device-floppy"></i></a>'
}
} ]
} );
const initPrecioTemplate = <?php echo json_encode($precioTemplate);?>;
if(initPrecioTemplate != null){
var newOption = new Option(initPrecioTemplate.label, initPrecioTemplate.value, false, false);
$('#plantillas').append(newOption);
}
// Activate an inline edit on click of a table cell
$('#tableOfPrecios').on( 'click', 'tbody span.edit', function (e) {
editorPrecios.inline(
theTablePrecios.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
$(document).on('click', '.btn-delete', function(e) {
$(".btn-remove").attr('data-id', $(this).attr('data-id'));
$(".btn-remove").attr('table-id', '#tableOfPrecios');
$(".btn-remove").attr('row', $(this).closest('tr')[0]._DT_RowIndex);
});
function delete_precio(dataId, row){
if ($.isNumeric(dataId)) {
editorPrecios
.create( false )
.edit( theTablePrecios.rows(row), false)
.set( 'deleted_at', new Date().toISOString().slice(0, 19).replace('T', ' ') )
.set( 'is_deleted', 1 )
.submit();
$('#confirm2delete').modal('toggle');
}
}
$('#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") ?>
/****************************************
Direcciones cliente

View File

@ -1,65 +0,0 @@
<div id="convert2Template" class="modal fade addModal">
<div class="modal-dialog modal-lg modal-simple">
<div class="modal-content">
<div class="modal-header">
<h4 id="labelTitleConfirmDialog" class="modal-title"><?= lang('ClientePrecios.convertir2plantilla') ?></h4>
</div>
<div class="modal-body">
<div id='error-nombre'></div>
<div class="mb-3">
<p><?= lang('ClientePrecios.convertir2plantillaText') ?></p>
<p><?= lang('ClientePrecios.convertir2plantillaText2') ?></p>
</div><!--//.mb-3 -->
<div class="mb-3">
<label for="nombre_plantilla" class="form-label">
<?= lang('ClientePrecios.nombrePlantilla') ?>
</label>
<input type="text" id="nombre_plantilla" maxLength="100" class="form-control new-address">
</div><!--//.mb-3 -->
</div>
<div class="modal-footer">
<button id="saveTemplate"
type="button"
class="btn btn-primary"
><?= lang('App.global_save') ?></button>
<button id="cancelTemplate"
type="button"
class="btn btn-default"
><?= lang('App.user_delete_btn_cancel') ?></button>
</div>
</div>
</div>
</div>
<?= $this->section("additionalInlineJs") ?>
$('#saveTemplate').on('click', function(){
if($('#nombre_plantilla').val().length == 0){
popErrorAlert('<?= lang('ClientePrecios.errors.error_nombre_template') ?>', 'error-nombre')
}
else{
data = new FormData();
data.append('cliente_id', id)
data.append('nombre', $('#nombre_plantilla').val())
data.append('<?= csrf_token() ?? "token" ?>', <?= csrf_token() ?>v)
fetch('<?= route_to("createClienteplantillaprecios");?>' , {
method: "POST",
body: data,
})
.then(data => {
$('#convert2Template').modal("hide");
var newOption = new Option($('#nombre_plantilla').val(), "", false, false);
$('#plantillas').append(newOption);
$('#nombre_plantilla').val("");
})
}
})
$('#cancelTemplate').on('click', function(){
$('#convert2Template').modal("hide");
})
<?=$this->endSection() ?>

View File

@ -1,6 +1,7 @@
<?= $this->include("themes/_commonPartialsBs/datatables") ?>
<?= $this->include("themes/_commonPartialsBs/select2bs5") ?>
<?= $this->include("themes/_commonPartialsBs/sweetalert") ?>
<?= $this->include('themes/_commonPartialsBs/_confirm2delete') ?>
<?=$this->extend('themes/vuexy/main/defaultlayout') ?>
<?= $this->section("content") ?>
@ -43,5 +44,8 @@
<?= $this->section("additionalExternalJs") ?>
<script src="<?= site_url("/themes/vuexy/vendor/libs/datatables-sk/plugins/buttons/buttons.colVis.min.js") ?>"></script>
<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/buttons/buttons.print.min.js") ?>"></script>
<script type="module" src="<?= site_url('assets/js/safekat/pages/cliente/cliente.js?'. 'token' . '='. (csrf_token() ?? "token")) ?>"></script>
<?= $this->endSection() ?>

View File

@ -16,12 +16,8 @@
<?= !empty($validation->getErrors()) ? $validation->listErrors("bootstrap_style") : "" ?>
<?= view("themes/vuexy/form/clientes/plantillaprecios/_ClienteplantillapreciosFormItems") ?>
<div class="pt-4">
<input
type="submit"
class="btn btn-primary float-start me-sm-3 me-1"
name="save"
value="<?= lang("Basic.global.Save") ?>"
/>
<input type="submit" 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"]) ?>
</div><!-- /.card-footer -->
@ -31,22 +27,32 @@
</div><!--//.row -->
<?php if(str_contains($formAction,'edit')): ?>
<?php if (str_contains($formAction, 'edit')): ?>
<div class="accordion mt-3" id="accordionPreciosLineas">
<div class="card accordion-item active">
<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>
</button>
</h2>
<div id="accordionTip1" class="accordion-collapse collapse show" data-bs-parent="#accordionPreciosLineas">
<div class="accordion-body">
<button id="btnApply" type="button" class="btn btn-primary d-none">
Guardar y aplicar a clientes
</button>
<button id="btnUndo" type="button" class="btn btn-secondary d-none">
Descartar cambios
</button>
<table id="tableOfPlantillasPreciosLineas" class="table table-striped table-hover" style="width: 100%;">
<thead>
<tr>
<th>ID</th>
<th><?= lang('ClientePrecios.tipo') ?></th>
<th><?= lang('ClientePrecios.tipo_maquina') ?></th>
<th><?= lang('ClientePrecios.tipo_impresion') ?></th>
@ -55,308 +61,51 @@
<th><?= lang('ClientePrecios.precio_hora') ?></th>
<th><?= lang('ClientePrecios.margen') ?></th>
<th><?= lang('ClientePrecios.user_updated_id') ?></th>
<th><?= lang('ClientePrecios.updated_at') ?></th>
<th class="text-nowrap" style="min-width:100px"><?= lang('Basic.global.Action') ?></th>
<th class="noFilter"><?= lang('ClientePrecios.updated_at') ?></th>
<th class="text-nowrap noFilter" style="min-width:100px"><?= lang('Basic.global.Action') ?>
</th>
</tr>
</thead>
<tbody>
</tbody>
</table>
</table>
</div>
</div>
</div>
</div> <!-- //.accordion -->
<?php endif; ?>
<?= $this->endSection() ?>
<?php if(str_contains($formAction,'edit')): ?>
<?=$this->section('additionalInlineJs') ?>
const lastColNr_lineas = $('#tableOfPlantillasPreciosLineas').find("tr:first th").length - 1;
const url = window.location.href;
const url_parts = url.split('/');
let id = -1;
if(url_parts[url_parts.length-2] == 'edit'){
id = url_parts[url_parts.length-1];
}
const actionBtns_lineas = 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>
`;
};
const tipo_linea = [
{label:'<?= lang('ClientePrecios.interior') ?>', value:'interior'},
{label:'<?= lang('ClientePrecios.cubierta') ?>', value: 'cubierta'},
{label:'<?= lang('ClientePrecios.sobrecubierta') ?>', value: 'sobrecubierta'}
];
const tipo_maquina = [
{label: '<?= lang('ClientePrecios.toner') ?>', value:'toner'},
{label: '<?= lang('ClientePrecios.inkjet') ?>', value:'inkjet'},
];
const tipo_impresion = [
{label: '<?= lang('ClientePrecios.negro') ?>', value:'negro'},
{label: '<?= lang('ClientePrecios.negrohq') ?>', value:'negrohq'},
{label: '<?= lang('ClientePrecios.color') ?>', value:'color'},
{label: '<?= lang('ClientePrecios.colorhq') ?>', value:'colorhq'},
];
var editor = new $.fn.dataTable.Editor( {
ajax: {
url: "<?= route_to('editorOfClienteplantillaprecioslineas') ?>",
headers: {
<?= csrf_token() ?? "token" ?> : <?= csrf_token() ?>v,
},
},
table : "#tableOfPlantillasPreciosLineas",
idSrc: 'id',
fields: [ {
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"
}, {
name: "user_updated_id",
type:'hidden',
}, {
name: "updated_at",
type:'hidden',
}, {
"name": "plantilla_id",
"type": "hidden"
},{
"name": "deleted_at",
"type": "hidden"
},{
"name": "is_deleted",
"type": "hidden"
},
]
} );
editor.on( 'preSubmit', function ( e, d, type ) {
if ( type === 'create'){
d.data[0]['plantilla_id'] = id;
}
else if(type === 'edit' ) {
for (v in d.data){
d.data[v]['plantilla_id'] = id;
}
}
});
editor.on( 'postSubmit', function ( e, json, data, action ) {
yeniden(json.<?= csrf_token() ?>);
const domain = window.location.origin
fetch(domain + "/clientes/clienteprecios/update/" + -1 , {
method: "POST",
body: JSON.stringify({
plantilla_id: id,
<?= csrf_token() ?? "token" ?> : <?= csrf_token() ?>v
}),
headers: {
"Content-type": "application/json; charset=UTF-8"
}
})
});
editor.on( 'submitSuccess', function ( e, json, data, action ) {
theTable.clearPipeline();
theTable.draw();
});
var theTable = $('#tableOfPlantillasPreciosLineas').DataTable( {
serverSide: true,
processing: true,
autoWidth: true,
responsive: true,
lengthMenu: [ 10, 25, 50, 100],
order: [[ 0, "asc" ], [ 1, "asc" ], [ 2, "asc" ], [ 3, "asc" ]],
pageLength: 50,
lengthChange: true,
searching: false,
paging: true,
info: false,
dom: '<"mt-4"><"float-end"B><"float-start"l><t><"mt-4 mb-3"p>',
ajax : $.fn.dataTable.pipeline( {
url: '<?= route_to('dataTableOfClientesplantillaprecioslineas') ?>',
data: {
plantilla_id: id,
},
method: 'POST',
headers: {'X-Requested-With': 'XMLHttpRequest'},
async: true,
}),
columns: [
{ 'data': 'tipo' ,
'render': function ( data, type, row, meta ) {
if(data=='interior')
return '<?= lang('ClientePrecios.interior') ?>';
else if(data=='cubierta')
return '<?= lang('ClientePrecios.cubierta') ?>';
else if(data=='sobrecubierta')
return '<?= lang('ClientePrecios.sobrecubierta') ?>';
}
},
{ 'data': 'tipo_maquina',
'render': function ( data, type, row, meta ) {
if(data=='toner')
return '<?= lang('ClientePrecios.toner') ?>';
else if(data=='inkjet')
return '<?= lang('ClientePrecios.inkjet') ?>';
}
},
{ 'data': 'tipo_impresion',
'render': function ( data, type, row, meta ) {
if(data=='negro')
return '<?= lang('ClientePrecios.negro') ?>';
else if(data=='negrohq')
return '<?= lang('ClientePrecios.negrohq') ?>';
else if(data=='color')
return '<?= lang('ClientePrecios.color') ?>';
else if(data=='colorhq')
return '<?= lang('ClientePrecios.colorhq') ?>';
}
},
{ 'data': 'tiempo_min' },
{ 'data': 'tiempo_max' },
{ 'data': 'precio_hora' },
{ 'data': 'margen' },
{ 'data': 'user_updated_id',
'render': function ( data, type, row, meta ) {
return row.user_updated
}
},
{ 'data': 'updated_at' },
{
data: actionBtns_lineas,
className: 'row-edit dt-center'
}
],
columnDefs: [
{
orderable: false,
searchable: false,
targets: [lastColNr_lineas]
},
{"orderData": [ 0, 1 ], "targets": 0 },
],
language: {
url: "/themes/vuexy/vendor/libs/datatables-sk/plugins/i18n/es-ES.json"
},
buttons: [
{
extend: 'collection',
text: 'Exportar',
buttons:[
'copy', 'csv', 'excel', 'print', {
extend: 'pdfHtml5',
orientation: 'landscape',
pageSize: 'A4'
}
]
},
{
className: 'btn btn-primary me-sm-3 me-1',
extend: "createInline",
editor: editor,
formOptions: {
submitTrigger: -1,
submitHtml: '<a href="javascript:void(0);"><i class="ti ti-device-floppy"></i></a>'
}
} ]
} );
// Activate an inline edit on click of a table cell
$('#tableOfPlantillasPreciosLineas').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
$(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/clienteplantillaprecioslineas/delete/${dataId}`,
method: 'GET',
}).done((data, textStatus, jqXHR) => {
$('#confirm2delete').modal('toggle');
theTable.clearPipeline();
theTable.row($(row)).invalidate().draw();
popSuccessAlert(data.msg ?? jqXHR.statusText);
}).fail((jqXHR, textStatus, errorThrown) => {
popErrorAlert(jqXHR.responseJSON.messages.error)
})
}
});
<?=$this->endSection() ?>
<?php endif; ?>
<?=$this->section('css') ?>
<link rel="stylesheet" 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->section('css') ?>
<link rel="stylesheet"
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->section('additionalExternalJs') ?>
<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.bootstrap5.min.js") ?>"></script>
<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/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>
<?=$this->endSection() ?>
<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.bootstrap5.min.js") ?>"></script>
<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/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() ?>

View File

@ -10,14 +10,16 @@
<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']); ?>
</div><!--//.card-header -->
<div class="card-body">
<?= csrf_field() ?>
<div class="card-body">
<?= view('themes/_commonPartialsBs/_alertBoxes'); ?>
<table id="tableOfClienteplantillaprecios" class="table table-striped table-hover using-exportable-data-table" style="width: 100%;">
<thead>
<tr>
<th>ID</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>
</thead>
<tbody>
@ -50,100 +52,6 @@
<script src="<?= site_url("/themes/vuexy/vendor/libs/datatables-sk/plugins/pdfmake/vfs_fonts.js") ?>"></script>
<script type="module" src="<?= site_url('assets/js/safekat/pages/plantillasTarifasCliente/list.js') ?>"></script>
<?=$this->endSection() ?>
<?=$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() ?>

View File

@ -63,7 +63,7 @@
</div>
<div
<div id="divExcluirRotativa"
class="col-sm-5 mb-3 d-flex flex-column align-items-center <?= (auth()->user()->inGroup('cliente-admin') || auth()->user()->inGroup('cliente-editor')) ? " d-none" : "" ?>">
<div class="form-check form-switch mb-2">
<input <?= (auth()->user()->inGroup('cliente-admin') || auth()->user()->inGroup('cliente-editor')) ? " hidden" : "" ?> class=" calcular-solapas calcular-presupuesto form-check-input" type="checkbox" id="excluirRotativa"

View File

@ -61,11 +61,11 @@
$selectedChatDepartments = isset($chatDepartmentUser) && is_array($chatDepartmentUser) ? $chatDepartmentUser : [];
$selectedKeywords = array_map(fn($chatDepartment) => $chatDepartment->name, $selectedChatDepartments);
foreach ($chatDepartments as $item) :
$isSelected = in_array($item["name"], $selectedKeywords) ? 'selected' : '';
$isSelected = in_array($item->name, $selectedKeywords) ? 'selected' : '';
?>
<option value="<?= $item["name"] ?>"
data-select2-id=<?= $item["name"] ?> <?= $isSelected ?>>
<?= $item["display"] ?>
<option value="<?= $item->name ?>"
data-select2-id=<?= $item->name ?> <?= $isSelected ?>>
<?= $item->display ?>
</option>
<?php endforeach; ?>
</select>

View File

@ -136,8 +136,9 @@ $picture = "/assets/img/default-user.png";
<div class="container-m-nx m-2">
<div class="sidebar-body">
<!-- Contacts -->
<h6 id="chat-message-notification-title"><?= lang("Chat.no_messages_notification") ?> </h6>
<ul class="list-unstyled chat-contact-list mb-0" id="chat-notification-list">
</ul>
</div>
</div>