mirror of
https://git.imnavajas.es/jjimenez/safekat.git
synced 2025-07-25 22:52:08 +00:00
terminadas modificaciones en tarifas acabado
This commit is contained in:
@ -5,6 +5,9 @@ use App\Entities\Tarifas\Acabados\TarifaAcabadoEntity;
|
||||
use App\Models\Collection;
|
||||
use App\Models\Tarifas\Acabados\TarifaAcabadoModel;
|
||||
|
||||
use App\Models\Compras\ProveedorModel;
|
||||
use App\Models\Compras\ProveedorTipoModel;
|
||||
|
||||
class TarifaAcabados extends BaseResourceController
|
||||
{
|
||||
|
||||
@ -219,6 +222,7 @@ class TarifaAcabados extends BaseResourceController
|
||||
$this->viewData['tarifaacabadoEntity'] = $tarifaacabadoEntity;
|
||||
|
||||
$this->viewData['formAction'] = route_to('updateTarifaAcabado', $id);
|
||||
$this->viewData['proveedores'] = $this->getProveedores();
|
||||
|
||||
$this->viewData['boxTitle'] = lang('Basic.global.edit2') . ' ' . lang('Tarifaacabado.moduleTitle') . ' ' . lang('Basic.global.edit3');
|
||||
|
||||
@ -305,4 +309,12 @@ class TarifaAcabados extends BaseResourceController
|
||||
}
|
||||
}
|
||||
|
||||
private function getProveedores(){
|
||||
$provTipoModel = new ProveedorTipoModel();
|
||||
$provModel = new ProveedorModel();
|
||||
|
||||
$tipoId = $provTipoModel->getTipoId("Acabados");
|
||||
return $provModel->getProvList($tipoId);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -213,13 +213,14 @@ class TarifaAcabadosLineas extends \App\Controllers\BaseResourceController
|
||||
|
||||
$id_TA = $reqData['id_tarifaacabado'] ?? -1;
|
||||
|
||||
$searchValues = get_filter_datatables_columns($reqData);
|
||||
|
||||
$resourceData = $this->model->getResource("", $id_TA)->orderBy($order, $dir)->limit($length, $start)->get()->getResultObject();
|
||||
$resourceData = $this->model->getResource($searchValues, $id_TA)->orderBy($order, $dir)->limit($length, $start)->get()->getResultObject();
|
||||
|
||||
return $this->respond(Collection::datatable(
|
||||
$resourceData,
|
||||
$this->model->getResource()->countAllResults(),
|
||||
$this->model->getResource($search, $id_TA)->countAllResults()
|
||||
$this->model->getResource($searchValues, $id_TA)->countAllResults()
|
||||
));
|
||||
} else {
|
||||
return $this->failUnauthorized('Invalid request', 403);
|
||||
@ -280,6 +281,7 @@ class TarifaAcabadosLineas extends \App\Controllers\BaseResourceController
|
||||
->validator('Validate::notEmpty', array(
|
||||
'message' => lang('TarifaAcabadoLineas.validation.margen.required'))
|
||||
),
|
||||
Field::inst('proveedor_id'),
|
||||
Field::inst('tarifa_acabado_id'),
|
||||
Field::inst('user_created_id'),
|
||||
Field::inst('created_at'),
|
||||
@ -297,6 +299,7 @@ class TarifaAcabadosLineas extends \App\Controllers\BaseResourceController
|
||||
|
||||
$process_data['tirada_min'] = $data['data'][$pkey]['tirada_min'];
|
||||
$process_data['tirada_max'] = $data['data'][$pkey]['tirada_max'];
|
||||
$process_data['proveedor_id'] = $data['data'][$pkey]['proveedor_id'];
|
||||
$response = $this->model->checkIntervals($process_data, $pkey, $data['data'][$pkey]['tarifa_acabado_id']);
|
||||
// No se pueden duplicar valores al crear o al editar
|
||||
if (!empty($response)) {
|
||||
|
||||
@ -8,6 +8,7 @@ class TarifaAcabadoLineaEntity extends \CodeIgniter\Entity\Entity
|
||||
protected $attributes = [
|
||||
"id" => null,
|
||||
"tarifa_acabado_id" => 0,
|
||||
"proveedor_id" => 0,
|
||||
"tirada_min" => 0,
|
||||
"tirada_max" => 0,
|
||||
"precio_min" => 0,
|
||||
@ -21,6 +22,7 @@ class TarifaAcabadoLineaEntity extends \CodeIgniter\Entity\Entity
|
||||
];
|
||||
protected $casts = [
|
||||
"tarifa_acabado_id" => "int",
|
||||
"proveedor_id" => "int",
|
||||
"tirada_min" => "int",
|
||||
"tirada_max" => "int",
|
||||
"precio_min" => "float",
|
||||
|
||||
@ -6,6 +6,7 @@ return [
|
||||
'id' => 'ID',
|
||||
'moduleTitle' => 'Finish rates Lines',
|
||||
'deleteLine' => 'the selected register',
|
||||
'proveedor' => 'Provider',
|
||||
'precioMax' => 'Max Price',
|
||||
'precioMin' => 'Min Price',
|
||||
'precioUnidad' => 'Price Unit',
|
||||
|
||||
@ -6,6 +6,7 @@ return [
|
||||
'id' => 'ID',
|
||||
'moduleTitle' => 'Tarifa Acabado Líneas',
|
||||
'deleteLine' => 'el registro seleccionado',
|
||||
'proveedor' => 'Proveedor',
|
||||
'precioMax' => 'Precio T. Mín',
|
||||
'precioMin' => 'Precio T. Máx',
|
||||
'precioUnidad' => 'Precio Unidad',
|
||||
|
||||
@ -13,6 +13,7 @@ return [
|
||||
'precioMax' => 'Precio T. Mín',
|
||||
'precioMin' => 'Precio T. Máx',
|
||||
'importeFijo' => 'Importe Fijo',
|
||||
'importeMin' => 'Importe mínimo',
|
||||
'tarifaencuadernacion' => 'Tarifa Encuadernación',
|
||||
'tarifaencuadernacionList' => 'Lista Tarifas Encuadernación',
|
||||
'tarifasencuadernacion' => 'Tarifas Encuadernación',
|
||||
|
||||
@ -1,6 +1,9 @@
|
||||
<?php
|
||||
namespace App\Models\Tarifas\Acabados;
|
||||
|
||||
use function PHPUnit\Framework\isNan;
|
||||
use function PHPUnit\Framework\isNull;
|
||||
|
||||
class TarifaAcabadoLineaModel extends \App\Models\BaseModel
|
||||
{
|
||||
protected $table = "tarifa_acabado_lineas";
|
||||
@ -13,14 +16,16 @@ class TarifaAcabadoLineaModel extends \App\Models\BaseModel
|
||||
protected $useAutoIncrement = true;
|
||||
|
||||
const SORTABLE = [
|
||||
0 => "t1.tirada_min",
|
||||
1 => "t1.tirada_max",
|
||||
0 => "t3.nombre",
|
||||
1 => "t1.tirada_min",
|
||||
2 => "t1.precio_min",
|
||||
3 => "t1.precio_max",
|
||||
4 => "t1.margen",
|
||||
3 => "t1.tirada_max",
|
||||
4 => "t1.precio_max",
|
||||
5 => "t1.margen",
|
||||
];
|
||||
|
||||
protected $allowedFields = [
|
||||
"proveedor_id",
|
||||
"tirada_min",
|
||||
"tirada_max",
|
||||
"precio_min",
|
||||
@ -126,12 +131,12 @@ class TarifaAcabadoLineaModel extends \App\Models\BaseModel
|
||||
*
|
||||
* @return \CodeIgniter\Database\BaseBuilder
|
||||
*/
|
||||
public function getResource(string $search = "", $tarifa_acabado_id = -1)
|
||||
public function getResource($search = [], $tarifa_acabado_id = -1)
|
||||
{
|
||||
$builder = $this->db
|
||||
->table($this->table . " t1")
|
||||
->select(
|
||||
"t1.id AS id, t1.tirada_min AS tirada_min, t1.tirada_max AS tirada_max, t1.precio_min AS precio_min, t1.precio_max AS precio_max, t1.margen AS margen, t2.id AS tarifa_acabado"
|
||||
"t1.id AS id, t1.proveedor_id AS proveedor_id, t3.nombre AS proveedor_nombre, t1.tirada_min AS tirada_min, t1.tirada_max AS tirada_max, t1.precio_min AS precio_min, t1.precio_max AS precio_max, t1.margen AS margen, t2.id AS tarifa_acabado"
|
||||
);
|
||||
|
||||
//JJO
|
||||
@ -139,21 +144,42 @@ class TarifaAcabadoLineaModel extends \App\Models\BaseModel
|
||||
$builder->where("t1.is_deleted", 0);
|
||||
|
||||
$builder->join("lg_tarifa_acabado t2", "t1.tarifa_acabado_id = t2.id", "left");
|
||||
$builder->join("lg_proveedores t3", "t1.proveedor_id = t3.id", "left");
|
||||
|
||||
|
||||
return empty($search)
|
||||
? $builder
|
||||
: $builder
|
||||
->groupStart()
|
||||
->like("t1.tirada_min", $search)
|
||||
->orLike("t1.tirada_max", $search)
|
||||
->orLike("t1.precio_min", $search)
|
||||
->orLike("t1.precio_max", $search)
|
||||
->orLike("t1.tirada_min", $search)
|
||||
->orLike("t1.tirada_max", $search)
|
||||
->orLike("t1.precio_min", $search)
|
||||
->orLike("t1.precio_max", $search)
|
||||
->groupEnd();
|
||||
if (empty($search))
|
||||
return $builder;
|
||||
else {
|
||||
$builder->groupStart();
|
||||
foreach ($search as $col_search) {
|
||||
if($col_search[0] != 0){
|
||||
$values = explode(",",$col_search[2]);
|
||||
$min_val = floatval($values[0]);
|
||||
$max_val = floatval($values[1]);
|
||||
if(!is_nan($min_val) && !is_null($min_val) && strlen($values[0]) > 0){
|
||||
$builder->where(self::SORTABLE[$col_search[0]] . " >=", $min_val);
|
||||
}
|
||||
if(!is_nan($max_val) && !is_null($max_val) && strlen($values[1]) > 0){
|
||||
$builder->where(self::SORTABLE[$col_search[0]] . " <", $max_val);
|
||||
}
|
||||
}
|
||||
else{
|
||||
$values = explode(",",$col_search[2]);
|
||||
if(count($values) > 1){
|
||||
foreach ($values as $value) {
|
||||
$builder->orWhere("t1.proveedor_id", $value);
|
||||
}
|
||||
}
|
||||
else{
|
||||
$builder->where("t1.proveedor_id", $col_search[2]);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
$builder->groupEnd();
|
||||
|
||||
return $builder;
|
||||
}
|
||||
}
|
||||
|
||||
public function findLineasForTarifaAcabado(int $tarifaacabado_id){
|
||||
@ -181,6 +207,7 @@ class TarifaAcabadoLineaModel extends \App\Models\BaseModel
|
||||
->select("id, tirada_min, tirada_max")
|
||||
->where("is_deleted", 0)
|
||||
->where("tarifa_acabado_id", $id_tarifa_acabado)
|
||||
->where("proveedor_id", $data["proveedor_id"])
|
||||
->get()->getResultObject();
|
||||
|
||||
|
||||
|
||||
@ -45,12 +45,13 @@
|
||||
<table id="tableOfTarifaacabadolineas" class="table table-striped table-hover" style="width: 100%;">
|
||||
<thead>
|
||||
<tr>
|
||||
<th><?= lang('TarifaAcabadoLineas.proveedor') ?></th>
|
||||
<th><?= lang('TarifaAcabadoLineas.tiradaMin') ?></th>
|
||||
<th><?= lang('TarifaAcabadoLineas.precioMax') ?></th>
|
||||
<th><?= lang('TarifaAcabadoLineas.tiradaMax') ?></th>
|
||||
<th><?= lang('TarifaAcabadoLineas.precioMin') ?></th>
|
||||
<th><?= lang('TarifaAcabadoLineas.margen') ?></th>
|
||||
<th style="min-width:100px"></th>
|
||||
<th class="noFilter" style="min-width:100px"></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@ -85,7 +86,7 @@
|
||||
};
|
||||
|
||||
|
||||
editor = new $.fn.dataTable.Editor( {
|
||||
var editor = new $.fn.dataTable.Editor( {
|
||||
ajax: {
|
||||
url: "<?= route_to('tarifaAcabadoLineasDTE') ?>",
|
||||
headers: {
|
||||
@ -94,7 +95,11 @@
|
||||
},
|
||||
table : "#tableOfTarifaacabadolineas",
|
||||
idSrc: 'id',
|
||||
fields: [ {
|
||||
fields: [
|
||||
{
|
||||
name: "proveedor_id",
|
||||
type: "select",
|
||||
}, {
|
||||
name: "tirada_min"
|
||||
}, {
|
||||
name: "precio_max"
|
||||
@ -107,6 +112,9 @@
|
||||
}, {
|
||||
"name": "tarifa_acabado_id",
|
||||
"type": "hidden"
|
||||
},{
|
||||
name: "proveedor_nombre",
|
||||
"type": "hidden"
|
||||
},{
|
||||
"name": "deleted_at",
|
||||
"type": "hidden"
|
||||
@ -117,6 +125,10 @@
|
||||
]
|
||||
} );
|
||||
|
||||
// Generación de la lista de proveedores (id, nombre) para encuadernación
|
||||
const suppliersList = <?php echo json_encode($proveedores); ?>;
|
||||
editor.field( 'proveedor_id' ).update( suppliersList );
|
||||
|
||||
editor.on( 'preSubmit', function ( e, d, type ) {
|
||||
if ( type === 'create'){
|
||||
d.data[0]['tarifa_acabado_id'] = id;
|
||||
@ -141,18 +153,94 @@
|
||||
});
|
||||
|
||||
|
||||
function searchProviders(){
|
||||
var values = [];
|
||||
$('#select_Proveedor').find(':selected').each(function () {
|
||||
values.push($(this).val());
|
||||
});
|
||||
theTable.column(0).search(values).draw();
|
||||
}
|
||||
|
||||
|
||||
// Setup - add a text input to each footer cell
|
||||
$('#tableOfTarifaacabadolineas thead tr').clone(true).appendTo('#tableOfTarifaacabadolineas thead');
|
||||
$('#tableOfTarifaacabadolineas thead tr:eq(1) th').each(function (i) {
|
||||
if (!$(this).hasClass("noFilter")) {
|
||||
var title = $(this).text();
|
||||
title = title.replace(/ /g, "_").replace(/\./g, "_");
|
||||
|
||||
|
||||
if(i==0){
|
||||
|
||||
// Agregar un selector en la primera columna
|
||||
$(this).html(`<select id=select_${title} class="form-control select2" style="min-width:100px;max-width:120px;font-size:0.8rem !important;"></select>`);
|
||||
|
||||
// Agregar opciones al selector
|
||||
var selector = $('select', this);
|
||||
const suppliersList = <?php echo json_encode($proveedores); ?>;
|
||||
//selector.append('<option value="">Todos</option>'); // Opción vacía
|
||||
for (j = 0; j < suppliersList.length; j++) {
|
||||
selector.append('<option value="' + suppliersList[j].value + '">' + suppliersList[j].label + '</option>');
|
||||
};
|
||||
|
||||
$('#select_' + title).select2({
|
||||
multiple: true,
|
||||
placeholder: ""
|
||||
});
|
||||
|
||||
|
||||
selector.bind('select2:select', searchProviders);
|
||||
selector.bind('select2:unselect', searchProviders);
|
||||
|
||||
$('#select_' + title).val("").trigger('change');
|
||||
|
||||
}
|
||||
else{
|
||||
|
||||
|
||||
$(this).html(`
|
||||
<div class='d-flex'>
|
||||
<input name=min_${title} id=min_${title} class="form-control" type='text' min='0' placeholder='Min' style='width: 80px;'/>
|
||||
<input name=max_${title} id=max_${title} class="form-control ml-1" type='text' min='0' placeholder='Max' style='width: 80px;'/>
|
||||
</div>
|
||||
`);
|
||||
|
||||
|
||||
|
||||
$('input', this).on('change clear', function () {
|
||||
var minInputValue = parseFloat($(`#min_${title}`).val()) || "";
|
||||
var maxInputValue = parseFloat($(`#max_${title}`).val()) || "";
|
||||
|
||||
|
||||
if (theTable.column(i).search() !== [minInputValue,maxInputValue]) {
|
||||
theTable
|
||||
.column(i)
|
||||
.search([minInputValue,maxInputValue])
|
||||
.draw();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
else {
|
||||
$(this).html('<span></span>');
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
var theTable = $('#tableOfTarifaacabadolineas').DataTable( {
|
||||
serverSide: true,
|
||||
orderCellsTop: true,
|
||||
serverSide: true,
|
||||
processing: true,
|
||||
autoWidth: true,
|
||||
responsive: true,
|
||||
fixedHeader: true,
|
||||
lengthMenu: [ 5, 10, 25],
|
||||
order: [[ 0, "asc" ], [ 1, "asc" ]],
|
||||
pageLength: 10,
|
||||
lengthChange: true,
|
||||
searching: false,
|
||||
paging: true,
|
||||
info: false,
|
||||
stateSave: false,
|
||||
dom: '<"mt-4"><"float-end"B><"float-start"l><t><"mt-4 mb-3"p>',
|
||||
ajax : $.fn.dataTable.pipeline( {
|
||||
url: '<?= route_to('tarifaAcabadoLineasDT') ?>',
|
||||
@ -164,6 +252,12 @@
|
||||
async: true,
|
||||
}),
|
||||
columns: [
|
||||
{ 'data': 'proveedor_id',
|
||||
render: function(data, type, row, meta) {
|
||||
var value = suppliersList.find(element => element.value === data);
|
||||
return value['label'];
|
||||
},
|
||||
},
|
||||
{ 'data': 'tirada_min' },
|
||||
{ 'data': 'precio_max' },
|
||||
{ 'data': 'tirada_max' },
|
||||
@ -180,7 +274,6 @@
|
||||
searchable: false,
|
||||
targets: [lastColNr]
|
||||
},
|
||||
{"orderData": [ 0, 1 ], "targets": 0 },
|
||||
|
||||
],
|
||||
language: {
|
||||
@ -244,6 +337,7 @@
|
||||
<?=$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") ?>">
|
||||
<link rel="stylesheet" href="<?= site_url("/themes/vuexy/vendor/libs/datatables-sk/plugins/fixedheader/fixedHeader.dataTables.min.css") ?>">
|
||||
<?=$this->endSection() ?>
|
||||
|
||||
|
||||
|
||||
@ -49,11 +49,11 @@
|
||||
<th><?= lang('TarifaEncuadernacionTiradas.proveedor') ?></th>
|
||||
<th><?= lang('TarifaEncuadernacionTiradas.tiradaMin') ?></th>
|
||||
<th><?= lang('TarifaEncuadernacionTiradas.tiradaMax') ?></th>
|
||||
<th><?= lang('Tarifaencuadernacion.precioMin') ?></th>
|
||||
<th><?= lang('Tarifaencuadernacion.importeMin') ?></th>
|
||||
<th><?= lang('Tarifaencuadernacion.importeFijo') ?></th>
|
||||
<th></th>
|
||||
</tr>
|
||||
</thead>
|
||||
</thead>
|
||||
<tbody>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
@ -75,6 +75,13 @@ if (
|
||||
</a>
|
||||
</li>
|
||||
<?php } ?>
|
||||
<?php if (auth()->user()->can('proveedores.menu')) { ?>
|
||||
<li class="menu-item">
|
||||
<a href="<?= route_to("proveedorList") ?>" class="menu-link">
|
||||
<?= lang("App.menu_proveedores") ?>
|
||||
</a>
|
||||
</li>
|
||||
<?php } ?>
|
||||
<?php if (auth()->user()->can('ubicaciones.menu')) { ?>
|
||||
<li class="menu-item">
|
||||
<a href="<?= route_to("ubicacionesList") ?>" class="menu-link">
|
||||
|
||||
Reference in New Issue
Block a user