Skip to content

Commit 35586fc

Browse files
author
Carlos Garcia
committed
Pequeñas mejoras al código de los controladores.
1 parent d860bc4 commit 35586fc

File tree

3 files changed

+38
-45
lines changed

3 files changed

+38
-45
lines changed

Core/Controller/ListFacturaCliente.php

Lines changed: 13 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?php
22
/**
33
* This file is part of FacturaScripts
4-
* Copyright (C) 2017-2024 Carlos Garcia Gomez <carlos@facturascripts.com>
4+
* Copyright (C) 2017-2025 Carlos Garcia Gomez <carlos@facturascripts.com>
55
*
66
* This program is free software: you can redistribute it and/or modify
77
* it under the terms of the GNU Lesser General Public License as
@@ -48,7 +48,7 @@ public function getPageData(): array
4848
return $data;
4949
}
5050

51-
protected function createViews()
51+
protected function createViews(): void
5252
{
5353
// listado de facturas de cliente
5454
$this->createViewSales('ListFacturaCliente', 'FacturaCliente', 'invoices');
@@ -68,15 +68,16 @@ protected function createViews()
6868
$this->createViewRefunds();
6969
}
7070

71-
protected function createViewReceipts(string $viewName = 'ListReciboCliente')
71+
protected function createViewReceipts(string $viewName = 'ListReciboCliente'): void
7272
{
7373
$this->addView($viewName, 'ReciboCliente', 'receipts', 'fa-solid fa-dollar-sign')
7474
->addOrderBy(['codcliente'], 'customer-code')
7575
->addOrderBy(['fecha', 'idrecibo'], 'date')
7676
->addOrderBy(['fechapago'], 'payment-date')
7777
->addOrderBy(['vencimiento'], 'expiration', 2)
7878
->addOrderBy(['importe'], 'amount')
79-
->addSearchFields(['codigofactura', 'observaciones']);
79+
->addSearchFields(['codigofactura', 'observaciones'])
80+
->setSettings('btnNew', false);
8081

8182
// filtros
8283
$this->addFilterPeriod($viewName, 'expiration', 'expiration', 'vencimiento');
@@ -105,17 +106,16 @@ protected function createViewReceipts(string $viewName = 'ListReciboCliente')
105106

106107
// botones
107108
$this->addButtonPayReceipt($viewName);
108-
109-
// desactivamos el botón nuevo
110-
$this->setSettings($viewName, 'btnNew', false);
111109
}
112110

113-
protected function createViewRefunds(string $viewName = 'ListFacturaCliente-rect')
111+
protected function createViewRefunds(string $viewName = 'ListFacturaCliente-rect'): void
114112
{
115113
$this->addView($viewName, 'FacturaCliente', 'refunds', 'fa-solid fa-share-square')
116114
->addSearchFields(['codigo', 'codigorect', 'numero2', 'observaciones'])
117115
->addOrderBy(['fecha', 'idfactura'], 'date', 2)
118-
->addOrderBy(['total'], 'total');
116+
->addOrderBy(['total'], 'total')
117+
->disableColumn('original', false)
118+
->setSettings('btnNew', false);
119119

120120
// filtro de fecha
121121
$this->addFilterPeriod($viewName, 'date', 'period', 'fecha');
@@ -127,19 +127,15 @@ protected function createViewRefunds(string $viewName = 'ListFacturaCliente-rect
127127
'where' => [new DataBaseWhere('idfacturarect', null, 'IS NOT')]
128128
]
129129
]);
130-
131-
// desactivamos el botón nuevo
132-
$this->setSettings($viewName, 'btnNew', false);
133-
134-
// mostramos la columna original
135-
$this->views[$viewName]->disableColumn('original', false);
136130
}
137131

138-
protected function createViewSales(string $viewName, string $modelName, string $label)
132+
protected function createViewSales(string $viewName, string $modelName, string $label): void
139133
{
140134
parent::createViewSales($viewName, $modelName, $label);
141135

142-
$this->addSearchFields($viewName, ['codigorect']);
136+
$this->listView($viewName)
137+
->addOrderBy(['idfactura'], 'id')
138+
->addSearchFields(['codigorect']);
143139

144140
// filtros
145141
$i18n = Tools::lang();

Core/Controller/ListFacturaProveedor.php

Lines changed: 23 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?php
22
/**
33
* This file is part of FacturaScripts
4-
* Copyright (C) 2017-2023 Carlos Garcia Gomez <carlos@facturascripts.com>
4+
* Copyright (C) 2017-2025 Carlos Garcia Gomez <carlos@facturascripts.com>
55
*
66
* This program is free software: you can redistribute it and/or modify
77
* it under the terms of the GNU Lesser General Public License as
@@ -45,7 +45,7 @@ public function getPageData(): array
4545
return $data;
4646
}
4747

48-
protected function createViews()
48+
protected function createViews(): void
4949
{
5050
// listado de facturas de proveedor
5151
$this->createViewPurchases('ListFacturaProveedor', 'FacturaProveedor', 'invoices');
@@ -65,10 +65,13 @@ protected function createViews()
6565
$this->createViewRefunds();
6666
}
6767

68-
protected function createViewPurchases(string $viewName, string $modelName, string $label)
68+
protected function createViewPurchases(string $viewName, string $modelName, string $label): void
6969
{
7070
parent::createViewPurchases($viewName, $modelName, $label);
71-
$this->addSearchFields($viewName, ['codigorect']);
71+
72+
$this->listView($viewName)
73+
->addOrderBy(['idfactura'], 'id')
74+
->addSearchFields(['codigorect']);
7275

7376
// filtros
7477
$i18n = Tools::lang();
@@ -94,15 +97,16 @@ protected function createViewPurchases(string $viewName, string $modelName, stri
9497
}
9598
}
9699

97-
protected function createViewReceipts(string $viewName = 'ListReciboProveedor')
100+
protected function createViewReceipts(string $viewName = 'ListReciboProveedor'): void
98101
{
99-
$this->addView($viewName, 'ReciboProveedor', 'receipts', 'fa-solid fa-dollar-sign');
100-
$this->addOrderBy($viewName, ['codproveedor'], 'supplier-code');
101-
$this->addOrderBy($viewName, ['fecha', 'idrecibo'], 'date');
102-
$this->addOrderBy($viewName, ['fechapago'], 'payment-date');
103-
$this->addOrderBy($viewName, ['vencimiento'], 'expiration', 2);
104-
$this->addOrderBy($viewName, ['importe'], 'amount');
105-
$this->addSearchFields($viewName, ['codigofactura', 'observaciones']);
102+
$this->addView($viewName, 'ReciboProveedor', 'receipts', 'fa-solid fa-dollar-sign')
103+
->addOrderBy(['codproveedor'], 'supplier-code')
104+
->addOrderBy(['fecha', 'idrecibo'], 'date')
105+
->addOrderBy(['fechapago'], 'payment-date')
106+
->addOrderBy(['vencimiento'], 'expiration', 2)
107+
->addOrderBy(['importe'], 'amount')
108+
->addSearchFields(['codigofactura', 'observaciones'])
109+
->setSettings('btnNew', false);
106110

107111
// filtros
108112
$this->addFilterPeriod($viewName, 'expiration', 'expiration', 'vencimiento');
@@ -131,17 +135,16 @@ protected function createViewReceipts(string $viewName = 'ListReciboProveedor')
131135

132136
// botones
133137
$this->addButtonPayReceipt($viewName);
134-
135-
// desactivamos el botón nuevo
136-
$this->setSettings($viewName, 'btnNew', false);
137138
}
138139

139-
protected function createViewRefunds(string $viewName = 'ListFacturaProveedor-rect')
140+
protected function createViewRefunds(string $viewName = 'ListFacturaProveedor-rect'): void
140141
{
141-
$this->addView($viewName, 'FacturaProveedor', 'refunds', 'fa-solid fa-share-square');
142-
$this->addSearchFields($viewName, ['codigo', 'codigorect', 'numproveedor', 'observaciones']);
143-
$this->addOrderBy($viewName, ['fecha', 'idfactura'], 'date', 2);
144-
$this->addOrderBy($viewName, ['total'], 'total');
142+
$this->addView($viewName, 'FacturaProveedor', 'refunds', 'fa-solid fa-share-square')
143+
->addSearchFields(['codigo', 'codigorect', 'numproveedor', 'observaciones'])
144+
->addOrderBy(['fecha', 'idfactura'], 'date', 2)
145+
->addOrderBy(['total'], 'total')
146+
->disableColumn('original', false)
147+
->setSettings('btnNew', false);
145148

146149
// filtro de fecha
147150
$this->addFilterPeriod($viewName, 'date', 'period', 'fecha');
@@ -153,12 +156,6 @@ protected function createViewRefunds(string $viewName = 'ListFacturaProveedor-re
153156
'where' => [new DataBaseWhere('idfacturarect', null, 'IS NOT')]
154157
]
155158
]);
156-
157-
// desactivamos el botón nuevo
158-
$this->setSettings($viewName, 'btnNew', false);
159-
160-
// mostramos la columna original
161-
$this->views[$viewName]->disableColumn('original', false);
162159
}
163160

164161
/**

Core/Lib/ExtendedController/ListBusinessDocument.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ protected function createViewLines(string $viewName, string $modelName): void
163163
$this->setSettings($viewName, 'megasearch', false);
164164
}
165165

166-
protected function createViewPurchases(string $viewName, string $modelName, string $label)
166+
protected function createViewPurchases(string $viewName, string $modelName, string $label): void
167167
{
168168
$this->addView($viewName, $modelName, $label, 'fa-solid fa-copy')
169169
->addOrderBy(['codigo'], 'code')
@@ -183,7 +183,7 @@ protected function createViewPurchases(string $viewName, string $modelName, stri
183183
$this->addColorStatus($viewName, $modelName);
184184
}
185185

186-
protected function createViewSales(string $viewName, string $modelName, string $label)
186+
protected function createViewSales(string $viewName, string $modelName, string $label): void
187187
{
188188
$this->addView($viewName, $modelName, $label, 'fa-solid fa-copy')
189189
->addOrderBy(['codigo'], 'code')

0 commit comments

Comments
 (0)