mirror of
https://git.imnavajas.es/jjimenez/safekat.git
synced 2025-07-25 22:52:08 +00:00
terminado
This commit is contained in:
@ -396,6 +396,7 @@ $routes->group('clienteprecios', ['namespace' => 'App\Controllers\Clientes'], fu
|
||||
$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']);
|
||||
|
||||
|
||||
@ -247,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()) {
|
||||
|
||||
@ -134,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')
|
||||
@ -197,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'));
|
||||
|
||||
@ -160,7 +160,7 @@ class ClientePlantillaPreciosLineasModel extends \App\Models\BaseModel
|
||||
else {
|
||||
$builder->groupStart();
|
||||
foreach ($search as $col_search) {
|
||||
if ($col_search[0] > 0 && $col_search[0] < 4)
|
||||
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]);
|
||||
|
||||
@ -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();
|
||||
}
|
||||
|
||||
@ -42,9 +42,13 @@
|
||||
<div id="accordionTip1" class="accordion-collapse collapse show" data-bs-parent="#accordionPreciosLineas">
|
||||
<div class="accordion-body">
|
||||
|
||||
<button id="applyChanges" type="button" class="btn btn-primary">
|
||||
<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>
|
||||
|
||||
Reference in New Issue
Block a user