mirror of
https://git.imnavajas.es/jjimenez/safekat.git
synced 2025-07-25 22:52:08 +00:00
Merge branch 'feat/listados_cliente_form' into 'main'
Feat/listados cliente form See merge request jjimenez/safekat!630
This commit is contained in:
@ -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']);
|
||||
|
||||
@ -757,6 +760,8 @@ $routes->group('pedidos', ['namespace' => 'App\Controllers\Pedidos'], function (
|
||||
$routes->post('insertfactura', 'Pedido::addFactura');
|
||||
$routes->get('xml/(:num)', 'Pedido::get_xml_pedido/$1', ['as' => 'getXMLPedido']);
|
||||
$routes->post('produccion/(:num)', 'Pedido::to_produccion/$1', ['as' => 'toProduccion']);
|
||||
$routes->get('pedidosCliente', 'Pedido::tablaClienteForm');
|
||||
$routes->get('getSumCliente/(:num)', 'Pedido::obtenerTotalPedidosCliente/$1');
|
||||
});
|
||||
$routes->resource('pedidos', ['namespace' => 'App\Controllers\Pedidos', 'controller' => 'Pedido', 'except' => 'show,new,create,update']);
|
||||
|
||||
@ -797,6 +802,7 @@ $routes->group('facturas', ['namespace' => 'App\Controllers\Facturacion'], funct
|
||||
$routes->post('datatablePagos/(:any)', 'FacturasPagos::datatable/$1', ['as' => 'dataTableOfPagosFacturas']);
|
||||
$routes->post('editorPagos', 'FacturasPagos::datatable_editor', ['as' => 'editorOfPagosFacturas']);
|
||||
$routes->post('datatablePedidos', 'Facturas::datatablePedidos', ['as' => 'dataTableOfFacturasPedido']);
|
||||
$routes->get('getdatoscliente/(:any)', 'Facturas::getDatosFacturacionClienteForm/$1');
|
||||
});
|
||||
|
||||
|
||||
|
||||
@ -236,13 +236,16 @@ class Facturas extends \App\Controllers\BaseResourceController
|
||||
public function datatable()
|
||||
{
|
||||
|
||||
$dataForClienteForm = false;
|
||||
if (auth()->user()->inGroup('cliente-admin') || auth()->user()->inGroup('cliente-editor')) {
|
||||
// Se obtiene el cliente ID a partir del usuario de la sesion
|
||||
$model_user = model('App\Models\Usuarios\UserModel');
|
||||
$user = $model_user->find(auth()->user()->id);
|
||||
$clienteId = $user->cliente_id;
|
||||
} else {
|
||||
$clienteId = -1;
|
||||
$temp = $this->request->getGet('cliente_id');
|
||||
$clienteId = ($temp && $temp != null && $temp != "") ? $temp : -1;
|
||||
$dataForClienteForm = ($temp && $temp != null && $temp != "") ? true : false;
|
||||
}
|
||||
|
||||
$model = model(FacturaModel::class);
|
||||
@ -342,8 +345,10 @@ class Facturas extends \App\Controllers\BaseResourceController
|
||||
if ($clienteId != -1) {
|
||||
$result->hide('cliente');
|
||||
$result->hide('creditoAsegurado');
|
||||
$result->hide('estado');
|
||||
$result->hide('estado_pago');
|
||||
if(!$dataForClienteForm){
|
||||
$result->hide('estado');
|
||||
$result->hide('estado_pago');
|
||||
}
|
||||
$result->hide('forma_pago');
|
||||
$result->hide('vencimiento');
|
||||
$result->hide('dias_vencimiento');
|
||||
@ -352,6 +357,11 @@ class Facturas extends \App\Controllers\BaseResourceController
|
||||
return $result->toJson(returnAsObject: true);
|
||||
}
|
||||
|
||||
public function getDatosFacturacionClienteForm($cliente_id){
|
||||
|
||||
return $this->respond($this->model->getSumatoriosFacturacionCliente($cliente_id));
|
||||
}
|
||||
|
||||
|
||||
public function datatablePedidos()
|
||||
{
|
||||
|
||||
@ -8,6 +8,8 @@ use App\Models\Collection;
|
||||
use App\Models\Pedidos\PedidoModel;
|
||||
use App\Services\PedidoXMLService;
|
||||
use App\Services\ProductionService;
|
||||
use Hermawan\DataTables\DataTable;
|
||||
use CodeIgniter\I18n\Time;
|
||||
|
||||
class Pedido extends \App\Controllers\BaseResourceController
|
||||
{
|
||||
@ -34,6 +36,7 @@ class Pedido extends \App\Controllers\BaseResourceController
|
||||
$this->viewData['breadcrumb'] = [
|
||||
['title' => lang("App.menu_pedidos"), 'route' => "javascript:void(0);", 'active' => false],
|
||||
];
|
||||
helper("time");
|
||||
|
||||
parent::initController($request, $response, $logger);
|
||||
|
||||
@ -371,6 +374,96 @@ class Pedido extends \App\Controllers\BaseResourceController
|
||||
}
|
||||
}
|
||||
|
||||
public function tablaClienteForm()
|
||||
{
|
||||
|
||||
$clienteId = $this->request->getGet('cliente_id') ?? -1;
|
||||
|
||||
$q = $this->model->getPedidosClienteForm($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');
|
||||
}
|
||||
}
|
||||
$searchValue = $this->request->getGet('fecha_entrega') ?? '';
|
||||
if (!empty($searchValue)) {
|
||||
// Extraer las fechas del formato "YYYY-MM-DD|YYYY-MM-DD"
|
||||
$dates = explode('|', $searchValue);
|
||||
if (count($dates) == 2) {
|
||||
$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)
|
||||
->edit(
|
||||
'fecha',
|
||||
fn($q) => $q->fecha?Time::createFromFormat("Y-m-d H:i:s", $q->fecha)->format("d/m/Y"):""
|
||||
)
|
||||
->edit(
|
||||
'fecha_entrega',
|
||||
fn($q) => $q->fecha_entrega?Time::createFromFormat("Y-m-d H:i:s", $q->fecha_entrega)->format("d/m/Y"):""
|
||||
)
|
||||
->edit(
|
||||
"estado",
|
||||
function ($row, $meta) {
|
||||
switch ($row->estado) {
|
||||
case "validacion":
|
||||
return lang('Pedidos.validacion');
|
||||
case "produccion":
|
||||
return lang('Pedidos.produccion');
|
||||
case "finalizado":
|
||||
return lang('Pedidos.finalizado');
|
||||
case "enviado":
|
||||
return lang('Pedidos.enviado');
|
||||
case "cancelado":
|
||||
return lang('Pedidos.cancelado');
|
||||
default:
|
||||
return '--'; // Debug
|
||||
}
|
||||
}
|
||||
)
|
||||
->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 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]);
|
||||
}
|
||||
|
||||
|
||||
public function obtenerPedidosForFacturas(){
|
||||
if ($this->request->isAJAX()) {
|
||||
|
||||
@ -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'))])];
|
||||
|
||||
@ -74,6 +74,9 @@ return [
|
||||
"ejemplares" => "Ejemplares",
|
||||
"addPago" => "Añadir Pago",
|
||||
"facturaPagada" => "Factura rectificativa ya abonada",
|
||||
|
||||
"acumuladoFacturacion" => "Acumulado Facturación",
|
||||
"totalPendientePago" => "Pendiente de pago",
|
||||
|
||||
'errors' => [
|
||||
'requiredFields' => 'Los campos marcados con * son obligatorios',
|
||||
|
||||
@ -16,6 +16,7 @@ return [
|
||||
'estado' => 'Estado',
|
||||
'importePendiente' => 'Importe Pendiente',
|
||||
|
||||
'todos' => 'Todos',
|
||||
'validacion' => 'Validación',
|
||||
'produccion' => 'Producción',
|
||||
'finalizado' => 'Finalizado',
|
||||
@ -82,6 +83,10 @@ return [
|
||||
|
||||
'showTotal' => 'Mostrar totales',
|
||||
|
||||
'pedidosImpresion' => 'Pedidos impresión',
|
||||
'pedidosMaquetacion' => 'Pedidos maquetación',
|
||||
'pedidosTotal' => 'Total en pedidos',
|
||||
|
||||
'validation' => [
|
||||
'errorCantidadAlbaranes' => 'Total en albaranes {0} no coincide con la tirada {1}',
|
||||
|
||||
|
||||
@ -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',
|
||||
|
||||
@ -145,6 +145,40 @@ class FacturaModel extends \App\Models\BaseModel
|
||||
return $builder;
|
||||
}
|
||||
|
||||
public function getSumatoriosFacturacionCliente($cliente_id = -1){
|
||||
|
||||
if($cliente_id == -1){
|
||||
return [
|
||||
'total_facturacion' => 0,
|
||||
'total_pendiente' => 0
|
||||
];
|
||||
}
|
||||
|
||||
$result = [];
|
||||
$data = $this->db->table('facturas f')
|
||||
->select('sum(f.total) as total')
|
||||
->where('f.cliente_id', $cliente_id)
|
||||
->where('f.deleted_at IS NULL')
|
||||
->where('f.estado', 'validada')
|
||||
->get()
|
||||
->getResultObject();
|
||||
$result['total_facturacion'] =
|
||||
round(floatval(($data && $data[0]->total != null) ? $data[0]->total : 0), 2);
|
||||
|
||||
$data = $this->db->table('facturas f')
|
||||
->select('sum(f.pendiente) as pendiente')
|
||||
->where('f.cliente_id', $cliente_id)
|
||||
->where('f.deleted_at IS NULL')
|
||||
->where('f.estado', 'validada')
|
||||
->where('f.estado_pago', 'pendiente')
|
||||
->get()
|
||||
->getResultObject();
|
||||
$result['total_pendiente'] =
|
||||
round(floatval(($data && $data[0]->pendiente != null) ? $data[0]->pendiente : 0), 2);
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get resource data for creating PDFs.
|
||||
|
||||
@ -232,6 +232,20 @@ class PedidoModel extends \App\Models\BaseModel
|
||||
return $presupuesto_ficheros;
|
||||
}
|
||||
|
||||
|
||||
public function getPedidosClienteForm($cliente_id = -1){
|
||||
$builder = $this->db
|
||||
->table($this->table . " p")
|
||||
->select('p.id, p.created_at as fecha, p.fecha_entrega_real as fecha_entrega,
|
||||
pr.paginas as paginas, p.total_tirada, p.total_precio, p.estado')
|
||||
->join('pedidos_linea pl', 'pl.pedido_id = p.id', 'left')
|
||||
->join('presupuestos pr', 'pr.id = pl.presupuesto_id', 'left')
|
||||
//->where('pr.deleted_at IS NULL')
|
||||
->where('pr.cliente_id', $cliente_id)
|
||||
->groupBy('p.id');
|
||||
return $builder;
|
||||
}
|
||||
|
||||
/**
|
||||
* Crea una orden de trabajo asociada al pedido
|
||||
*
|
||||
|
||||
@ -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)
|
||||
{
|
||||
|
||||
|
||||
@ -56,19 +56,19 @@
|
||||
<li class="nav-item">
|
||||
<button
|
||||
type="button"
|
||||
class="nav-link"
|
||||
class="nav-link presupuestos-btn"
|
||||
role="tab"
|
||||
data-bs-toggle="tab"
|
||||
data-bs-target="#facturacion"
|
||||
aria-controls="facturacion"
|
||||
data-bs-target="#presupuestos"
|
||||
aria-controls="presupuestos"
|
||||
aria-selected="false">
|
||||
Facturación
|
||||
Presupuestos
|
||||
</button>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<button
|
||||
type="button"
|
||||
class="nav-link"
|
||||
class="nav-link pedidos-btn"
|
||||
role="tab"
|
||||
data-bs-toggle="tab"
|
||||
data-bs-target="#pedidos"
|
||||
@ -77,6 +77,18 @@
|
||||
Pedidos
|
||||
</button>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<button
|
||||
type="button"
|
||||
class="nav-link facturacion-btn"
|
||||
role="tab"
|
||||
data-bs-toggle="tab"
|
||||
data-bs-target="#facturacion"
|
||||
aria-controls="facturacion"
|
||||
aria-selected="false">
|
||||
Facturación
|
||||
</button>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<button
|
||||
type="button"
|
||||
@ -645,12 +657,16 @@
|
||||
</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">
|
||||
<h3>Proximanente</h3>
|
||||
<?= view("themes/vuexy/form/clientes/cliente/_facturacionClienteItems") ?>
|
||||
</div>
|
||||
|
||||
<div class="tab-pane fade" id="pedidos" role="tabpanel">
|
||||
<h3>Proximanente</h3>
|
||||
<?= view("themes/vuexy/form/clientes/cliente/_pedidosClienteItems") ?>
|
||||
</div>
|
||||
|
||||
<div class="tab-pane fade" id="usuarios" role="tabpanel">
|
||||
@ -910,7 +926,6 @@ const actionBtns_add = function(data) {
|
||||
`;
|
||||
};
|
||||
|
||||
|
||||
function saveAdd_callback(){
|
||||
if($('#addressForm').attr('action')=='create'){
|
||||
editorAddress
|
||||
@ -1127,9 +1142,11 @@ function delete_direccion_envio(dataId){
|
||||
<link rel="stylesheet" href="<?= site_url('themes/vuexy/css/datatables-editor/editor.bootstrap5.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-bs5/datatables.bootstrap5.css") ?>">
|
||||
<link rel="stylesheet" href="<?= site_url('themes/vuexy/vendor/libs/bootstrap-daterangepicker/bootstrap-daterangepicker.css') ?>" />
|
||||
<?=$this->endSection() ?>
|
||||
|
||||
<?= $this->section('additionalExternalJs') ?>
|
||||
<script src="<?= site_url('themes/vuexy/vendor/libs/bootstrap-daterangepicker/bootstrap-daterangepicker.js') ?>"></script>
|
||||
<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>
|
||||
@ -1138,6 +1155,7 @@ function delete_direccion_envio(dataId){
|
||||
<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>
|
||||
<script type="module" src="<?= site_url("assets/js/safekat/pages/cliente/clienteFacturacion.js") ?>"></script>
|
||||
<?=$this->endSection() ?>
|
||||
<?php } ?>
|
||||
|
||||
|
||||
@ -0,0 +1,55 @@
|
||||
<div class="row">
|
||||
<div class="col-2">
|
||||
|
||||
<div class="form-group">
|
||||
<label for="acumuladoFacturacion"><?= lang('Facturas.acumuladoFacturacion') ?></label>
|
||||
<input readonly type="text" class="form-control autonumeric-currency-totales" id="acumuladoFacturacion" name="acumulado_facturacion">
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="totalPendientePago"><?= lang('Facturas.totalPendientePago') ?></label>
|
||||
<input readonly type="text" class="form-control autonumeric-currency-totales" id="totalPendientePago" name="numero_factura">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<table id="tableOfFacturasCliente" class="table table-striped table-hover" style="width: 100%;">
|
||||
<thead>
|
||||
<tr>
|
||||
<th><?= lang('Facturas.numeroFactura') ?></th>
|
||||
<th><?= lang('Facturas.fechaFactura') ?></th>
|
||||
<th><?= lang('Facturas.total') ?></th>
|
||||
<th><?= lang('Facturas.estado') ?></th>
|
||||
<th><?= lang('Facturas.estadoPago') ?></th>
|
||||
<th class="text-nowrap"><?= lang('Basic.global.Action') ?></th>
|
||||
</tr>
|
||||
<tr>
|
||||
<th><input type="text" class="form-control factura-filter" name="numero"></th>
|
||||
<th>
|
||||
<input id="fechaFactura" type="text" class="form-control factura-filter" name="fecha_factura_at">
|
||||
</th>
|
||||
<th></th>
|
||||
<th>
|
||||
<?php if(!auth()->user()->inGroup('cliente-admin') && !auth()->user()->inGroup('cliente-editor')): ?>
|
||||
<select class="form-control factura-filter-select" name="estado">
|
||||
<option value=""><?= lang('Facturas.todos') ?></option>
|
||||
<option value="borrador"><?= lang('Facturas.borrador') ?></option>
|
||||
<option value="validada"><?= lang('Facturas.validada') ?></option>
|
||||
</select>
|
||||
<?php endif; ?>
|
||||
</th>
|
||||
<th>
|
||||
<select class="form-control factura-filter-select" name="estado_pago">
|
||||
<option value=""><?= lang('Facturas.todos') ?></option>
|
||||
<option value="pendiente"><?= lang('Facturas.pendiente') ?></option>
|
||||
<option value="pagada"><?= lang('Facturas.pagada') ?></option>
|
||||
<option value="insolvente"><?= lang('Facturas.insolvente') ?></option>
|
||||
</select>
|
||||
</th>
|
||||
<th></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
@ -0,0 +1,64 @@
|
||||
<div class="row">
|
||||
<div class="col-2">
|
||||
|
||||
<div class="form-group">
|
||||
<label for="pedidosImpresion"><?= lang('Pedidos.pedidosImpresion') ?></label>
|
||||
<input readonly type="text" class="form-control autonumeric-currency-totales" id="pedidosImpresion"
|
||||
name="pedidos_impresion">
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="pedidosMaquetacion"><?= lang('Pedidos.pedidosMaquetacion') ?></label>
|
||||
<input readonly type="text" class="form-control autonumeric-currency-totales" id="pedidosMaquetacion"
|
||||
name="pedidos_maquetacion">
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="totalPedidos" class="fw-bold"><?= lang('Pedidos.pedidosTotal') ?></label>
|
||||
<input readonly type="text" class="form-control fw-bold autonumeric-currency-totales" id="totalPedidos"
|
||||
name="total_pedidos">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<table id="tableOfPedidosCliente" class="table table-striped table-hover" style="width: 100%;">
|
||||
<thead>
|
||||
<tr>
|
||||
<th><?= lang('Pedidos.id') ?></th>
|
||||
<th><?= lang('Pedidos.fecha') ?></th>
|
||||
<th><?= lang('Pedidos.fecha_entrega') ?></th>
|
||||
<th class='noFilter'><?= lang('Pedidos.num_paginas') ?></th>
|
||||
<th class='totalizador'><?= lang('Pedidos.tiradas') ?></th>
|
||||
<th class='totalizador'><?= lang('Pedidos.total_presupuesto') ?></th>
|
||||
<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>
|
||||
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
@ -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>
|
||||
@ -11,7 +11,10 @@
|
||||
<div class="card-header">
|
||||
<h3 class="card-title"><?= $boxTitle ?? $pageTitle ?></h3>
|
||||
</div><!--//.card-header -->
|
||||
<form id="clienteForm" 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") ?>
|
||||
|
||||
@ -1,6 +1,9 @@
|
||||
import ClassSelect from '../../components/select2.js';
|
||||
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';
|
||||
|
||||
@ -23,6 +26,13 @@ class Cliente {
|
||||
|
||||
init() {
|
||||
|
||||
AutoNumeric.multiple('.autonumeric-currency-totales',
|
||||
{ decimalPlaces: 2,
|
||||
currencySymbol: '€',
|
||||
currencySymbolPlacement: 's',
|
||||
digitGroupSeparator: '.',
|
||||
decimalCharacter: ',' });
|
||||
|
||||
// Fuerza el foco en el campo de búsqueda de select2
|
||||
$(document).on('select2:open', () => {
|
||||
document.querySelector('.select2-search__field').focus();
|
||||
@ -55,12 +65,17 @@ class Cliente {
|
||||
}
|
||||
});
|
||||
|
||||
(new ClienteFacturacion()).init();
|
||||
(new ClientePedidos()).init();
|
||||
(new ClientePresupuestos()).init();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
document.addEventListener('DOMContentLoaded', function () {
|
||||
|
||||
|
||||
const dropdown = document.querySelector(".dropdown-language");
|
||||
const activeItem = dropdown.querySelector(".dropdown-menu .dropdown-item");
|
||||
let locale = 'es';
|
||||
@ -68,7 +83,7 @@ document.addEventListener('DOMContentLoaded', function () {
|
||||
locale = activeItem.getAttribute("data-language");
|
||||
}
|
||||
|
||||
new Ajax('/translate/getTranslation', { locale: locale, translationFile: ['ClienteContactos', 'ClientePrecios'] }, {},
|
||||
new Ajax('/translate/getTranslation', { locale: locale, translationFile: ['ClienteContactos', 'ClientePrecios', 'datePicker'] }, {},
|
||||
function(translations) {
|
||||
window.language = JSON.parse(translations);
|
||||
new Cliente().init();
|
||||
|
||||
156
httpdocs/assets/js/safekat/pages/cliente/clienteFacturacion.js
Normal file
156
httpdocs/assets/js/safekat/pages/cliente/clienteFacturacion.js
Normal file
@ -0,0 +1,156 @@
|
||||
import Ajax from "../../components/ajax.js";
|
||||
|
||||
class ClienteFacturacion {
|
||||
constructor() {
|
||||
|
||||
this.bsRangePickerRange = $('#' + 'fechaFactura');
|
||||
this.clienteId = $('#clienteForm').attr('data-cliente');
|
||||
}
|
||||
|
||||
init() {
|
||||
|
||||
const self = this;
|
||||
|
||||
// select button with data-bs-target="#facturacion"
|
||||
$(document).on('click', '.facturacion-btn', function (e) {
|
||||
e.preventDefault();
|
||||
$('#tableOfFacturasCliente').DataTable().columns.adjust().draw();
|
||||
$(this).tab('show');
|
||||
});
|
||||
|
||||
$(document).on('click', '.btn-edit', function (e) {
|
||||
window.location.href = '/facturas/edit/' + $(this).attr('data-id');
|
||||
});
|
||||
|
||||
const lastColNr = $('#tableOfFacturasCliente').find("tr:first th").length - 1;
|
||||
|
||||
let datatableColumns = [];
|
||||
|
||||
datatableColumns = [
|
||||
{ 'data': 'numero' },
|
||||
{ 'data': 'fecha_factura_at', searchable: false },
|
||||
{ 'data': 'total', render: (d) => `<span class="autonumeric">${d}</span>` },
|
||||
{ 'data': 'estado' },
|
||||
{ 'data': 'estado_pago' },
|
||||
{ 'data': 'action' }
|
||||
];
|
||||
|
||||
$('#tableOfFacturasCliente').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, 'asc']],
|
||||
language: {
|
||||
url: "/themes/vuexy/vendor/libs/datatables-sk/plugins/i18n/es-ES.json"
|
||||
},
|
||||
ajax: {
|
||||
url: '/facturas/datatable',
|
||||
type: 'GET',
|
||||
data: function (d) {
|
||||
d.cliente_id = self.clienteId;
|
||||
d.fecha_factura = self.getDate();
|
||||
}
|
||||
},
|
||||
columnDefs: [
|
||||
{
|
||||
orderable: false,
|
||||
searchable: false,
|
||||
targets: [lastColNr]
|
||||
},
|
||||
],
|
||||
columns: datatableColumns,
|
||||
});
|
||||
|
||||
$(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();
|
||||
});
|
||||
|
||||
new Ajax('/facturas/getdatoscliente/'+ this.clienteId,
|
||||
{},
|
||||
{},
|
||||
function (response) {
|
||||
AutoNumeric.getAutoNumericElement('#acumuladoFacturacion').set(response.total_facturacion);
|
||||
AutoNumeric.getAutoNumericElement('#totalPendientePago').set(response.total_pendiente);
|
||||
},
|
||||
function (error) {
|
||||
console.log("Error data:", error);
|
||||
}).get();
|
||||
}
|
||||
|
||||
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;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
export default ClienteFacturacion;
|
||||
202
httpdocs/assets/js/safekat/pages/cliente/clientePedidos.js
Normal file
202
httpdocs/assets/js/safekat/pages/cliente/clientePedidos.js
Normal file
@ -0,0 +1,202 @@
|
||||
import Ajax from "../../components/ajax.js";
|
||||
|
||||
class ClientePedidos {
|
||||
constructor() {
|
||||
|
||||
this.clienteId = $('#clienteForm').attr('data-cliente');
|
||||
this.fecha = $('#fechaPedido_filter');
|
||||
this.fechaEntrega = $('#fechaEntrega_filter');
|
||||
}
|
||||
|
||||
init() {
|
||||
|
||||
const self = this;
|
||||
|
||||
$(document).on('click', '.pedidos-btn', function (e) {
|
||||
e.preventDefault();
|
||||
$('#tableOfPedidosCliente').DataTable().columns.adjust().draw();
|
||||
$(this).tab('show');
|
||||
});
|
||||
|
||||
$(document).on('click', '.btn-edit', function (e) {
|
||||
window.location.href = '/pedidos/edit/' + $(this).attr('data-id');
|
||||
});
|
||||
|
||||
const lastColNr = $('#tableOfPedidosCliente').find("tr:first th").length - 1;
|
||||
|
||||
let datatableColumns = [];
|
||||
|
||||
datatableColumns = [
|
||||
{ 'data': 'id' },
|
||||
{ 'data': 'fecha' },
|
||||
{ 'data': 'fecha_entrega' },
|
||||
{ 'data': 'paginas', searchable: false },
|
||||
{ 'data': 'total_tirada', searchable: false },
|
||||
{ 'data': 'total_precio', searchable: false },
|
||||
{ 'data': 'estado' },
|
||||
{ 'data': 'action' }
|
||||
];
|
||||
|
||||
$('#tableOfPedidosCliente').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: '/pedidos/pedidosCliente',
|
||||
type: 'GET',
|
||||
data: function (d) {
|
||||
d.cliente_id = self.clienteId;
|
||||
d.fecha = self.getDate(self.fecha);
|
||||
d.fecha_entrega = self.getDate(self.fechaEntrega);
|
||||
}
|
||||
},
|
||||
columnDefs: [
|
||||
{
|
||||
orderable: false,
|
||||
searchable: false,
|
||||
targets: [lastColNr]
|
||||
},
|
||||
],
|
||||
columns: datatableColumns,
|
||||
});
|
||||
|
||||
new Ajax('/pedidos/getSumCliente/' + this.clienteId,
|
||||
{},
|
||||
{},
|
||||
function (response) {
|
||||
if (response.status == 'success') {
|
||||
AutoNumeric.getAutoNumericElement('#pedidosImpresion').set(response.totales['total_impresion']);
|
||||
AutoNumeric.getAutoNumericElement('#pedidosMaquetacion').set(response.totales['total_maquetacion']);
|
||||
AutoNumeric.getAutoNumericElement('#totalPedidos').set(response.totales['total']);
|
||||
}
|
||||
else {
|
||||
console.log("Error data:", response);
|
||||
}
|
||||
|
||||
},
|
||||
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();
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
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 ClientePedidos;
|
||||
161
httpdocs/assets/js/safekat/pages/cliente/clientePresupuestos.js
Normal file
161
httpdocs/assets/js/safekat/pages/cliente/clientePresupuestos.js
Normal 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;
|
||||
Reference in New Issue
Block a user