añadidos presupuestos en cliente

This commit is contained in:
2025-03-31 20:42:14 +02:00
parent fb2d12e318
commit 3cb512d93a
14 changed files with 497 additions and 84 deletions

View File

@ -659,6 +659,9 @@ $routes->group('presupuestoadmin', ['namespace' => 'App\Controllers\Presupuestos
$routes->get('maquinas', 'Presupuestoadmin::getMaquinas');
$routes->post('getlinea', 'Presupuestoadmin::getLineaPresupuesto');
$routes->post('clone', 'Presupuestoadmin::datatable_2');
$routes->get('presupuestosCliente', 'Presupuestoadmin::tablaClienteForm');
$routes->get('getSumCliente/(:num)', 'Presupuestoadmin::obtenerTotalPresupuestosCliente/$1');
});
$routes->resource('presupuestoadmin', ['namespace' => 'App\Controllers\Presupuestos', 'controller' => 'Presupuestoadmin', 'except' => 'show,new,create,update']);

View File

@ -10,7 +10,6 @@ use App\Services\PedidoXMLService;
use App\Services\ProductionService;
use Hermawan\DataTables\DataTable;
use CodeIgniter\I18n\Time;
use Error;
class Pedido extends \App\Controllers\BaseResourceController
{
@ -382,13 +381,13 @@ class Pedido extends \App\Controllers\BaseResourceController
$q = $this->model->getPedidosClienteForm($clienteId);
/*$searchValue = $this->request->getGet('fecha') ?? '';
$searchValue = $this->request->getGet('fecha') ?? '';
if (!empty($searchValue)) {
// Extraer las fechas del formato "YYYY-MM-DD|YYYY-MM-DD"
$dates = explode('|', $searchValue);
if (count($dates) == 2) {
$q->where('created_at >=', $dates[0] . ' 00:00:00')
->where('created_at <=', $dates[1] . ' 23:59:59');
$q->where('p.created_at >=', $dates[0] . ' 00:00:00')
->where('p.created_at <=', $dates[1] . ' 23:59:59');
}
}
$searchValue = $this->request->getGet('fecha_entrega') ?? '';
@ -396,10 +395,10 @@ class Pedido extends \App\Controllers\BaseResourceController
// Extraer las fechas del formato "YYYY-MM-DD|YYYY-MM-DD"
$dates = explode('|', $searchValue);
if (count($dates) == 2) {
$q->where('fecha_entrega_real >=', $dates[0] . ' 00:00:00')
->where('fecha_entrega_real <=', $dates[1] . ' 23:59:59');
$q->where('p.fecha_entrega_real >=', $dates[0] . ' 00:00:00')
->where('p.fecha_entrega_real <=', $dates[1] . ' 23:59:59');
}
}*/
}
$result = DataTable::of($q)

View File

@ -20,6 +20,8 @@ use App\Models\Presupuestos\PresupuestoPreimpresionesModel;
use App\Models\Presupuestos\PresupuestoServiciosExtraModel;
use App\Services\PresupuestoService;
use App\Services\PresupuestoClienteService;
use Hermawan\DataTables\DataTable;
use CodeIgniter\I18n\Time;
use Exception;
class Presupuestoadmin extends \App\Controllers\BaseResourceController
@ -1684,6 +1686,91 @@ class Presupuestoadmin extends \App\Controllers\BaseResourceController
}
public function tablaClienteForm()
{
$clienteId = $this->request->getGet('cliente_id') ?? -1;
$q = $this->model->getPresupuestosClienteForm($clienteId);
$searchValue = $this->request->getGet('fecha') ?? '';
if (!empty($searchValue)) {
// Extraer las fechas del formato "YYYY-MM-DD|YYYY-MM-DD"
$dates = explode('|', $searchValue);
if (count($dates) == 2) {
$q->where('p.created_at >=', $dates[0] . ' 00:00:00')
->where('p.created_at <=', $dates[1] . ' 23:59:59');
}
}
$result = DataTable::of($q)
->edit(
'fecha',
fn($q) => $q->fecha?Time::createFromFormat("Y-m-d H:i:s", $q->fecha)->format("d/m/Y"):""
)
->edit(
'estado', fn($q) => match ($q->estado) {
"1" => lang('Presupuestos.borrador'),
"2" => lang('Presupuestos.confirmado'),
default => '--'
}
)->add("action", callback: function ($q) {
return '
<div class="btn-group btn-group-sm">
<a href="javascript:void(0);"><i class="ti ti-eye ti-sm btn-edit mx-2" data-id="' . $q->id . '"></i></a>
</div>
';
});
return $result->toJson(returnAsObject: true) ;
}
public function obtenerTotalPresupuestosCliente($cliente_id){
$error = false;
$result = [
'total_impresion' => 0,
'total_maquetacion' => 0,
];
$data = $this->model
->where('presupuestos.cliente_id', $cliente_id)
->select('SUM(presupuestos.total_aceptado) as total')
->groupBy('presupuestos.cliente_id')->get()->getResultObject();
if(count($data) > 0){
$result['total_impresion'] = round(floatval($data[0]->total), 2);
}
else{
$error = true;
}
$result['total'] = $result['total_impresion'] + $result['total_maquetacion'];
return $this->respond(['status' => $error?'error':'success', 'totales' => $result]);
}
public function obtenerTotalPedidosCliente($cliente_id){
$error = false;
$result = [
'total_impresion' => 0,
'total_maquetacion' => 0,
];
$data = $this->model
->where('presupuestos.cliente_id', $cliente_id)->whereNotIn('pedidos.estado', ['cancelado'])
->select('SUM(pedidos.total_precio) as total')
->join('pedidos_linea', 'pedidos_linea.pedido_id = pedidos.id')
->join('presupuestos', 'presupuestos.id = pedidos_linea.presupuesto_id')
->groupBy('presupuestos.cliente_id')->get()->getResultObject();
if(count($data) > 0){
$result['total_impresion'] = round(floatval($data[0]->total), 2);
}
else{
$error = true;
}
$result['total'] = $result['total_impresion'] + $result['total_maquetacion'];
return $this->respond(['status' => $error?'error':'success', 'totales' => $result]);
}
protected function getClienteListItems($selId = null)
{
$data = ['' => lang('Basic.global.pleaseSelectA', [mb_strtolower(lang('Clientes.cliente'))])];

View File

@ -16,6 +16,7 @@ return [
'estado' => 'Estado',
'importePendiente' => 'Importe Pendiente',
'todos' => 'Todos',
'validacion' => 'Validación',
'produccion' => 'Producción',
'finalizado' => 'Finalizado',

View File

@ -349,6 +349,16 @@ return [
'cubiertaSinAcabado' => 'Cubierta sin acabado',
'cubiertaSinAcabadoText' => 'La falta de plastificado en la cubierta puede comprometer su calidad, ya que aumenta el riesgo de agrietamiento en los pliegues o hendidos, afectando su apariencia y resistencia',
'presupuestosImpresion' => 'Presupuestos impresión',
'presupuestosMaquetacion' => 'Presupuestos maquetación',
'presupuestosTotal' => 'Total presupuestos',
'fecha' => 'Fecha',
'estado' => 'Estado',
'todos' => 'Todos',
'borrador' => 'Borrador',
'confirmado' => 'Confirmado',
'files' => 'Ficheros',
'titulos' => [
'libroFresadoTapaDura' => 'Rústica Fresado tapa dura',

View File

@ -242,7 +242,6 @@ class PedidoModel extends \App\Models\BaseModel
->join('presupuestos pr', 'pr.id = pl.presupuesto_id', 'left')
//->where('pr.deleted_at IS NULL')
->where('pr.cliente_id', $cliente_id)
->orderBy('p.created_at', 'DESC')
->groupBy('p.id');
return $builder;
}

View File

@ -713,6 +713,19 @@ class PresupuestoModel extends \App\Models\BaseModel
$servicios['extra'] = $queryExtras->get()->getResultObject();
return $servicios;
}
public function getPresupuestosClienteForm($cliente_id = -1){
$builder = $this->db
->table($this->table . " pr")
->select('pr.id, pr.created_at as fecha, CONCAT(u.first_name, " ", u.last_name) AS comercial, pr.titulo,
pr.paginas as paginas, pr.tirada, pr.total_aceptado as total, pr.estado_id as estado')
->join ("clientes c", "pr.cliente_id = c.id", "left")
->join("users u", "c.comercial_id= u.id", "left")
->where('pr.cliente_id', $cliente_id)
->groupBy('pr.id');
return $builder;
}
private function generarConceptoLineasPresupuestoLibro($lineas, $presupuesto)
{

View File

@ -53,6 +53,18 @@
Domicilio de Entrega
</button>
</li>
<li class="nav-item">
<button
type="button"
class="nav-link presupuestos-btn"
role="tab"
data-bs-toggle="tab"
data-bs-target="#presupuestos"
aria-controls="presupuestos"
aria-selected="false">
Presupuestos
</button>
</li>
<li class="nav-item">
<button
type="button"
@ -645,6 +657,10 @@
</table>
</div>
<div class="tab-pane fade" id="presupuestos" role="tabpanel">
<?= view("themes/vuexy/form/clientes/cliente/_presupuestosClienteItems") ?>
</div>
<div class="tab-pane fade" id="facturacion" role="tabpanel">
<?= view("themes/vuexy/form/clientes/cliente/_facturacionClienteItems") ?>
</div>

View File

@ -32,6 +32,30 @@
<th><?= lang('Pedidos.estado') ?></th>
<th class="noFilter text-nowrap"><?= lang('Basic.global.Action') ?></th>
</tr>
<tr>
<th><input type="text" class="form-control pedido-filter" name="id"></th>
<th><input id="fechaPedido_filter" type="text" class="form-control"
name="created_at">
</th>
<th><input id="fechaEntrega_filter" type="text" class="form-control"
name="fecha_entrega_at">
</th>
<th></th>
<th></th>
<th></th>
<th>
<select class="form-control pedido-filter-select" name="estado">
<option value=""><?= lang('Pedidos.todos')?></option>
<option value="validacion"><?= lang('Pedidos.validacion') ?></option>
<option value="produccion"><?= lang('Pedidos.produccion') ?></option>
<option value="finalizado"><?= lang('Pedidos.finalizado') ?></option>
<option value="enviado"><?= lang('Pedidos.enviado') ?></option>
<option value="cancelado"><?= lang('Pedidos.cancelado') ?></option>
</select>
</th>
<th></th>
</tr>
</thead>
<tbody>

View File

@ -0,0 +1,61 @@
<div class="row">
<div class="col-2">
<div class="form-group">
<label for="presupuestosImpresion"><?= lang('Presupuestos.presupuestosImpresion') ?></label>
<input readonly type="text" class="form-control autonumeric-currency-totales" id="presupuestosImpresion"
name="presupuestos_impresion">
</div>
<div class="form-group">
<label for="presupuestosMaquetacion"><?= lang('Presupuestos.presupuestosMaquetacion') ?></label>
<input readonly type="text" class="form-control autonumeric-currency-totales" id="presupuestosMaquetacion"
name="presupuestos_maquetacion">
</div>
<div class="form-group">
<label for="totalPresupuestos" class="fw-bold"><?= lang('Presupuestos.presupuestosTotal') ?></label>
<input readonly type="text" class="form-control fw-bold autonumeric-currency-totales" id="totalPresupuestos"
name="total_presupuestos">
</div>
</div>
</div>
<div class="row">
<table id="tableOfPresupuestosCliente" class="table table-striped table-hover" style="width: 100%;">
<thead>
<tr>
<th style="width: 10%;"><?= lang('Presupuestos.id') ?></th>
<th style="width: 10%;"><?= lang('Presupuestos.fecha') ?></th>
<th style="width: 12%;"><?= lang('Presupuestos.comercial') ?></th>
<th style="width: 18%;"><?= lang('Presupuestos.titulo') ?></th>
<th style="width: 10%;"><?= lang('Presupuestos.paginas') ?></th>
<th style="width: 10%;"><?= lang('Presupuestos.tirada') ?></th>
<th style="width: 10%;"><?= lang('Presupuestos.total') ?></th>
<th style="width: 10%;"><?= lang('Presupuestos.estado') ?></th>
<th style="width: 10%;" class="noFilter text-nowrap"><?= lang('Basic.global.Action') ?></th>
</tr>
<tr>
<th><input type="text" class="form-control presupuesto-filter" name="id"></th>
<th><input id="fechaPresupuesto_filter" type="text" class="form-control"
name="created_at">
</th>
<th><input type="text" class="form-control presupuesto-filter" name="comercial"></th>
<th><input type="text" class="form-control presupuesto-filter" name="titulo"></th>
<th></th>
<th></th>
<th></th>
<th>
<select class="form-control presupuesto-filter-select" name="estado">
<option value=""><?= lang('Presupuestos.todos')?></option>
<option value="1"><?= lang('Presupuestos.borrador') ?></option>
<option value="2"><?= lang('Presupuestos.confirmado') ?></option>
</select>
</th>
<th></th>
</tr>
</thead>
<tbody>
</tbody>
</table>
</div>

View File

@ -11,7 +11,10 @@
<div class="card-header">
<h3 class="card-title"><?= $boxTitle ?? $pageTitle ?></h3>
</div><!--//.card-header -->
<form id="clienteForm" data-cliente="<?=$clienteEntity->id?>" method="post" class="card-body" action="<?= $formAction ?>">
<form id="clienteForm" data-cliente="<?=$clienteEntity->id?>"
data-url="<?= auth()->user()->inGroup('cliente-admin') || auth()->user()->inGroup('cliente-editor') ?
'/presupuestos/presupuestocliente/edit/' : '/presupuestoadmin/edit//' ?>"
method="post" class="card-body" action="<?= $formAction ?>">
<?= csrf_field() ?>
<div class="card-body">
<?= view("themes/_commonPartialsBs/_alertBoxes") ?>

View File

@ -3,6 +3,7 @@ import tarifasClienteView from './tarifasCliente.js';
import ClienteUsuarios from './clienteUsuarios.js';
import ClienteFacturacion from './clienteFacturacion.js';
import ClientePedidos from './clientePedidos.js';
import ClientePresupuestos from './clientePresupuestos.js';
import Ajax from '../../components/ajax.js';
@ -66,6 +67,7 @@ class Cliente {
(new ClienteFacturacion()).init();
(new ClientePedidos()).init();
(new ClientePresupuestos()).init();
}

View File

@ -4,6 +4,8 @@ class ClientePedidos {
constructor() {
this.clienteId = $('#clienteForm').attr('data-cliente');
this.fecha = $('#fechaPedido_filter');
this.fechaEntrega = $('#fechaEntrega_filter');
}
init() {
@ -54,8 +56,8 @@ class ClientePedidos {
type: 'GET',
data: function (d) {
d.cliente_id = self.clienteId;
d.fecha = "";//self.getDate();
d.fecha_entrega = "";//self.getDate();
d.fecha = self.getDate(self.fecha);
d.fecha_entrega = self.getDate(self.fechaEntrega);
}
},
columnDefs: [
@ -85,81 +87,113 @@ class ClientePedidos {
function (error) {
console.log("Error data:", error);
}).get();
$(document).on("change", ".pedido-filter-select", (event) => {
let columnName = $(event.currentTarget).attr("name");
let columnIndex = $('#tableOfPedidosCliente').DataTable().columns().eq(0).filter(function (index) {
return $('#tableOfPedidosCliente').DataTable().column(index).dataSrc() === columnName;
})[0];
$('#tableOfPedidosCliente').DataTable().column(columnIndex).search($(event.currentTarget).val()).draw();
});
$(document).on("keyup", ".pedido-filter", (event) => {
let columnName = $(event.currentTarget).attr("name");
let columnIndex = $('#tableOfPedidosCliente').DataTable().columns().eq(0).filter(function (index) {
return $('#tableOfPedidosCliente').DataTable().column(index).dataSrc() === columnName;
})[0];
$('#tableOfPedidosCliente').DataTable().column(columnIndex).search($(event.currentTarget).val()).draw()
})
this.fecha.daterangepicker({
ranges: {
[window.language.datePicker.hoy]: [moment(), moment()],
[window.language.datePicker.ayer]: [moment().subtract(1, 'days'), moment().subtract(1, 'days')],
[window.language.datePicker.ultimos7]: [moment().subtract(6, 'days'), moment()],
[window.language.datePicker.ultimos30]: [moment().subtract(29, 'days'), moment()],
[window.language.datePicker.esteMes]: [moment().startOf('month'), moment().endOf('month')],
[window.language.datePicker.ultimoMes]: [moment().subtract(1, 'month').startOf('month'), moment().subtract(1, 'month').endOf('month')]
},
opens: 'right',
language: window.language.datePickerLocale,
"locale": {
"customRangeLabel": window.language.datePicker.rangoPersonalizado,
"format": "YYYY-MM-DD",
"separator": " ",
"applyLabel": window.language.datePicker.aplicar,
"cancelLabel": window.language.datePicker.limpiar,
},
"alwaysShowCalendars": true,
autoUpdateInput: false,
});
this.fecha.on('apply.daterangepicker', function (ev, picker) {
$(this).val(picker.startDate.format('DD/MM/YYYY') + ' ' + picker.endDate.format('DD/MM/YYYY'));
let table = $('#tableOfPedidosCliente').DataTable();
table.column(1).draw();
});
this.fecha.on('cancel.daterangepicker', function (ev, picker) {
$(this).val('');
$('#tableOfPedidosCliente').DataTable().column(1).search('').draw();
});
this.fechaEntrega.daterangepicker({
ranges: {
[window.language.datePicker.hoy]: [moment(), moment()],
[window.language.datePicker.ayer]: [moment().subtract(1, 'days'), moment().subtract(1, 'days')],
[window.language.datePicker.ultimos7]: [moment().subtract(6, 'days'), moment()],
[window.language.datePicker.ultimos30]: [moment().subtract(29, 'days'), moment()],
[window.language.datePicker.esteMes]: [moment().startOf('month'), moment().endOf('month')],
[window.language.datePicker.ultimoMes]: [moment().subtract(1, 'month').startOf('month'), moment().subtract(1, 'month').endOf('month')]
},
opens: 'right',
language: window.language.datePickerLocale,
"locale": {
"customRangeLabel": window.language.datePicker.rangoPersonalizado,
"format": "YYYY-MM-DD",
"separator": " ",
"applyLabel": window.language.datePicker.aplicar,
"cancelLabel": window.language.datePicker.limpiar,
},
"alwaysShowCalendars": true,
autoUpdateInput: false,
});
this.fechaEntrega.on('apply.daterangepicker', function (ev, picker) {
$(this).val(picker.startDate.format('DD/MM/YYYY') + ' ' + picker.endDate.format('DD/MM/YYYY'));
let table = $('#tableOfPedidosCliente').DataTable();
table.column(2).draw();
});
this.fechaEntrega.on('cancel.daterangepicker', function (ev, picker) {
$(this).val('');
$('#tableOfPedidosCliente').DataTable().column(2).search('').draw();
});
}
/*
$(document).on("keyup", ".factura-filter", (event) => {
//console.log(this.datatablePlanningRot.column($(event.currentTarget).attr("name")))
let columnName = $(event.currentTarget).attr("name");
let columnIndex = $('#tableOfFacturasCliente').DataTable().columns().eq(0).filter(function (index) {
return $('#tableOfFacturasCliente').DataTable().column(index).dataSrc() === columnName;
})[0];
$('#tableOfFacturasCliente').DataTable().column(columnIndex).search($(event.currentTarget).val()).draw()
})
$(document).on("change", ".factura-filter-select", (event) => {
let columnName = $(event.currentTarget).attr("name");
let columnIndex = $('#tableOfFacturasCliente').DataTable().columns().eq(0).filter(function (index) {
return $('#tableOfFacturasCliente').DataTable().column(index).dataSrc() === columnName;
})[0];
$('#tableOfFacturasCliente').DataTable().column(columnIndex).search($(event.currentTarget).val()).draw();
});
this.bsRangePickerRange.daterangepicker({
ranges: {
[window.language.datePicker.hoy]: [moment(), moment()],
[window.language.datePicker.ayer]: [moment().subtract(1, 'days'), moment().subtract(1, 'days')],
[window.language.datePicker.ultimos7]: [moment().subtract(6, 'days'), moment()],
[window.language.datePicker.ultimos30]: [moment().subtract(29, 'days'), moment()],
[window.language.datePicker.esteMes]: [moment().startOf('month'), moment().endOf('month')],
[window.language.datePicker.ultimoMes]: [moment().subtract(1, 'month').startOf('month'), moment().subtract(1, 'month').endOf('month')]
},
opens: 'right',
language: window.language.datePickerLocale,
"locale": {
"customRangeLabel": window.language.datePicker.rangoPersonalizado,
"format": "YYYY-MM-DD",
"separator": " ",
"applyLabel": window.language.datePicker.aplicar,
"cancelLabel": window.language.datePicker.limpiar,
},
"alwaysShowCalendars": true,
autoUpdateInput: false,
});
this.bsRangePickerRange.on('apply.daterangepicker', function(ev, picker) {
$(this).val(picker.startDate.format('DD/MM/YYYY') + ' ' + picker.endDate.format('DD/MM/YYYY'));
let table = $('#tableOfFacturasCliente').DataTable();
table.column(2).draw();
});
this.bsRangePickerRange.on('cancel.daterangepicker', function(ev, picker) {
$(this).val('');
$('#tableOfFacturasCliente').DataTable().column(2).search('').draw();
});
getDate(datepicker) {
let picker = datepicker.data('daterangepicker');
if (!picker || !picker.startDate || !picker.endDate || datepicker.val() == '') {
return '';
}
getDate() {
let picker = this.bsRangePickerRange.data('daterangepicker');
if (!picker || !picker.startDate || !picker.endDate || $('#fechaFactura').val() == '') {
return '';
}
let startDate = picker.startDate.format('YYYY-MM-DD');
let endDate = picker.endDate.format('YYYY-MM-DD');
return startDate + "|" + endDate;
}
*/
let startDate = picker.startDate.format('YYYY-MM-DD');
let endDate = picker.endDate.format('YYYY-MM-DD');
return startDate + "|" + endDate;
}

View File

@ -0,0 +1,161 @@
import Ajax from "../../components/ajax.js";
class ClientePresupuestos {
constructor() {
this.clienteId = $('#clienteForm').attr('data-cliente');
this.fecha = $('#fechaPresupuesto_filter');
}
init() {
const self = this;
$(document).on('click', '.presupuestos-btn', function (e) {
e.preventDefault();
$('#tableOfPresupuestosCliente').DataTable().columns.adjust().draw();
$(this).tab('show');
});
$(document).on('click', '.btn-edit', function (e) {
window.location.href = $('#clienteForm').attr('data-url'); + $(this).attr('data-id');
});
const lastColNr = $('#tableOfPresupuestosCliente').find("tr:first th").length - 1;
let datatableColumns = [];
datatableColumns = [
{ 'data': 'id' },
{ 'data': 'fecha' },
{ 'data': 'comercial' },
{ 'data': 'titulo', orderable: false },
{ 'data': 'paginas', searchable: false },
{ 'data': 'tirada', searchable: false },
{ 'data': 'total', searchable: false },
{ 'data': 'estado' },
{ 'data': 'action' }
];
$('#tableOfPresupuestosCliente').DataTable({
processing: true,
serverSide: true,
autoWidth: true,
responsive: true,
scrollX: true,
orderCellsTop: true,
lengthMenu: [5, 10, 25, 50, 75, 100, 250, 500, 1000, 2500],
pageLength: 250,
"dom": 'lBrtip',
order: [[0, 'desc']],
language: {
url: "/themes/vuexy/vendor/libs/datatables-sk/plugins/i18n/es-ES.json"
},
ajax: {
url: '/presupuestoadmin/presupuestosCliente',
type: 'GET',
data: function (d) {
d.cliente_id = self.clienteId;
d.fecha = self.getDate(self.fecha);
}
},
columnDefs: [
{
orderable: false,
searchable: false,
targets: [lastColNr]
},
],
columns: datatableColumns,
});
new Ajax('/presupuestoadmin/getSumCliente/' + this.clienteId,
{},
{},
function (response) {
if (response.status == 'success') {
AutoNumeric.getAutoNumericElement('#presupuestosImpresion').set(response.totales['total_impresion']);
AutoNumeric.getAutoNumericElement('#presupuestosMaquetacion').set(response.totales['total_maquetacion']);
AutoNumeric.getAutoNumericElement('#totalPresupuestos').set(response.totales['total']);
}
else {
console.log("Error data:", response);
}
},
function (error) {
console.log("Error data:", error);
}).get();
$(document).on("change", ".presupuesto-filter-select", (event) => {
let columnName = $(event.currentTarget).attr("name");
let columnIndex = $('#tableOfPresupuestosCliente').DataTable().columns().eq(0).filter(function (index) {
return $('#tableOfPresupuestosCliente').DataTable().column(index).dataSrc() === columnName;
})[0];
$('#tableOfPresupuestosCliente').DataTable().column(columnIndex).search($(event.currentTarget).val()).draw();
});
$(document).on("keyup", ".presupuesto-filter", (event) => {
let columnName = $(event.currentTarget).attr("name");
let columnIndex = $('#tableOfPresupuestosCliente').DataTable().columns().eq(0).filter(function (index) {
return $('#tableOfPresupuestosCliente').DataTable().column(index).dataSrc() === columnName;
})[0];
$('#tableOfPresupuestosCliente').DataTable().column(columnIndex).search($(event.currentTarget).val()).draw()
})
this.fecha.daterangepicker({
ranges: {
[window.language.datePicker.hoy]: [moment(), moment()],
[window.language.datePicker.ayer]: [moment().subtract(1, 'days'), moment().subtract(1, 'days')],
[window.language.datePicker.ultimos7]: [moment().subtract(6, 'days'), moment()],
[window.language.datePicker.ultimos30]: [moment().subtract(29, 'days'), moment()],
[window.language.datePicker.esteMes]: [moment().startOf('month'), moment().endOf('month')],
[window.language.datePicker.ultimoMes]: [moment().subtract(1, 'month').startOf('month'), moment().subtract(1, 'month').endOf('month')]
},
opens: 'right',
language: window.language.datePickerLocale,
"locale": {
"customRangeLabel": window.language.datePicker.rangoPersonalizado,
"format": "YYYY-MM-DD",
"separator": " ",
"applyLabel": window.language.datePicker.aplicar,
"cancelLabel": window.language.datePicker.limpiar,
},
"alwaysShowCalendars": true,
autoUpdateInput: false,
});
this.fecha.on('apply.daterangepicker', function (ev, picker) {
$(this).val(picker.startDate.format('DD/MM/YYYY') + ' ' + picker.endDate.format('DD/MM/YYYY'));
let table = $('#tableOfPresupuestosCliente').DataTable();
table.column(1).draw();
});
this.fecha.on('cancel.daterangepicker', function (ev, picker) {
$(this).val('');
$('#tableOfPresupuestosCliente').DataTable().column(1).search('').draw();
});
}
getDate(datepicker) {
let picker = datepicker.data('daterangepicker');
if (!picker || !picker.startDate || !picker.endDate || datepicker.val() == '') {
return '';
}
let startDate = picker.startDate.format('YYYY-MM-DD');
let endDate = picker.endDate.format('YYYY-MM-DD');
return startDate + "|" + endDate;
}
}
export default ClientePresupuestos;