mirror of
https://git.imnavajas.es/jjimenez/safekat.git
synced 2025-07-25 22:52:08 +00:00
filtros columna en pedidos hecho
This commit is contained in:
@ -14,12 +14,20 @@ class PedidoLineaModel extends \App\Models\BaseModel
|
||||
protected $useAutoIncrement = true;
|
||||
|
||||
const SORTABLE = [
|
||||
0 => "t1.id",
|
||||
1 => "t1.estado",
|
||||
2 => "t1.total_precio",
|
||||
3 => "t1.total_tirada",
|
||||
0 => "t2.id",
|
||||
1 => "t2.updated_at",
|
||||
2 => "t2.fecha_entrega_real",
|
||||
3 => "t4.nombre",
|
||||
4 => "CONCAT(t5.first_name, ' ', t5.last_name)",
|
||||
5 => "t3.titulo",
|
||||
6 => "t6.nombre",
|
||||
7 => "t3.inc_rei",
|
||||
8 => "t3.paginas",
|
||||
9 => "t3.tirada",
|
||||
10 => "t3.total_aceptado",
|
||||
11 => "t2.estado"
|
||||
];
|
||||
|
||||
|
||||
protected $allowedFields = [
|
||||
"pedido_id",
|
||||
"presupuesto_id",
|
||||
@ -40,7 +48,7 @@ class PedidoLineaModel extends \App\Models\BaseModel
|
||||
public static $labelField = "id";
|
||||
|
||||
|
||||
public function getResource(string $search = "", $estado="")
|
||||
public function getResource($search = [], $estado="")
|
||||
{
|
||||
$builder = $this->db
|
||||
->table($this->table . " t1")
|
||||
@ -67,14 +75,22 @@ class PedidoLineaModel extends \App\Models\BaseModel
|
||||
}
|
||||
}
|
||||
|
||||
// Falta implementar la busqueda por grupos
|
||||
return empty($search)
|
||||
? $builder
|
||||
: $builder
|
||||
->groupStart()
|
||||
->like("t1.id", $search)
|
||||
->orLike("t1.id", $search)
|
||||
->groupEnd();
|
||||
if (empty($search))
|
||||
return $builder;
|
||||
else {
|
||||
$builder->groupStart();
|
||||
foreach ($search as $col_search) {
|
||||
if ($col_search[0] != 1 && $col_search[0] != 2)
|
||||
$builder->like(self::SORTABLE[$col_search[0]], $col_search[2]);
|
||||
else {
|
||||
$dates = explode(" ", $col_search[2]);
|
||||
$builder->where(self::SORTABLE[$col_search[0]] . ">=", $dates[0]);
|
||||
$builder->where(self::SORTABLE[$col_search[0]] . "<=", $dates[1]);
|
||||
}
|
||||
}
|
||||
$builder->groupEnd();
|
||||
return $builder;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -17,7 +17,7 @@
|
||||
<tr>
|
||||
<th><?= lang('Pedidos.id') ?></th>
|
||||
<th><?= lang('Pedidos.fecha') ?></th>
|
||||
<th class='noFilter'><?= lang('Pedidos.fecha_entrega') ?></th>
|
||||
<th><?= lang('Pedidos.fecha_entrega') ?></th>
|
||||
<th><?= lang('Pedidos.cliente') ?></th>
|
||||
<th><?= lang('Pedidos.comercial') ?></th>
|
||||
<th><?= lang('Pedidos.titulo') ?></th>
|
||||
@ -27,7 +27,7 @@
|
||||
<th><?= lang('Pedidos.tiradas') ?></th>
|
||||
<th><?= lang('Pedidos.total_presupuesto') ?></th>
|
||||
<th><?= lang('Pedidos.estado') ?></th>
|
||||
<th class="text-nowrap"><?= lang('Basic.global.Action') ?></th>
|
||||
<th class="noFilter text-nowrap"><?= lang('Basic.global.Action') ?></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@ -62,9 +62,10 @@ $('#tableOfPedidos thead tr').clone(true).appendTo('#tableOfPedidos thead');
|
||||
$('#tableOfPedidos thead tr:eq(1) th').each(function (i) {
|
||||
if (!$(this).hasClass("noFilter")) {
|
||||
var title = $(this).text();
|
||||
if(i==1){
|
||||
$(this).html('<input id="bs-rangepicker-range" type="text" class="form-control " style="min-width:100px;max-width:120px;font-size:0.8rem !important;" />');
|
||||
var bsRangePickerRange = $('#bs-rangepicker-range')
|
||||
if(i==1 || i==2){
|
||||
name = 'bs-rangepicker-range_' + i;
|
||||
$(this).html('<input id="'+name+'" type="text" class="form-control " style="min-width:100px;max-width:120px;font-size:0.8rem !important;" />');
|
||||
var bsRangePickerRange = $('#' + name);
|
||||
bsRangePickerRange.daterangepicker({
|
||||
ranges: {
|
||||
'<?= lang('datePicker.hoy') ?>': [moment(), moment()],
|
||||
@ -106,6 +107,27 @@ $('#tableOfPedidos thead tr:eq(1) th').each(function (i) {
|
||||
});
|
||||
|
||||
}
|
||||
else if (i == 11) {
|
||||
// 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="validacion"><?= lang('Pedidos.validacion') ?></option>');
|
||||
selector.append('<option value="produccion"><?= lang('Pedidos.produccion') ?></option>');
|
||||
selector.append('<option value="finalizado"><?= lang('Pedidos.finalizado') ?></option>');
|
||||
selector.append('<option value="enviado"><?= lang('Pedidos.enviado') ?></option>');
|
||||
selector.append('<option value="cancelado"><?= lang('Pedidos.cancelado') ?></option>');
|
||||
|
||||
selector.on('change', function () {
|
||||
var val = $.fn.dataTable.util.escapeRegex(
|
||||
$(this).val()
|
||||
);
|
||||
theTable.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;" />');
|
||||
|
||||
@ -212,15 +234,9 @@ $('#tableOfPedidos thead tr:eq(1) th').each(function (i) {
|
||||
});
|
||||
|
||||
theTable.on( 'draw.dt', function () {
|
||||
//const boolCols = [];
|
||||
const dateCols = [1];
|
||||
const dateCols = [1,2];
|
||||
const priceCols = [10];
|
||||
/*for (let coln of boolCols) {
|
||||
theTable.column(coln, { page: 'current' }).nodes().each( function (cell, i) {
|
||||
cell.innerHTML = cell.innerHTML == '1' ? '<i class="ti ti-check"></i>' : '';
|
||||
});
|
||||
}*/
|
||||
|
||||
|
||||
for (let coln of dateCols) {
|
||||
theTable.column(coln, { page: 'current' }).nodes().each( function (cell, i) {
|
||||
const datestr = cell.innerHTML;
|
||||
|
||||
Reference in New Issue
Block a user