18 |
ilm |
1 |
/*
|
|
|
2 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
|
|
|
3 |
*
|
182 |
ilm |
4 |
* Copyright 2011-2019 OpenConcerto, by ILM Informatique. All rights reserved.
|
18 |
ilm |
5 |
*
|
|
|
6 |
* The contents of this file are subject to the terms of the GNU General Public License Version 3
|
|
|
7 |
* only ("GPL"). You may not use this file except in compliance with the License. You can obtain a
|
|
|
8 |
* copy of the License at http://www.gnu.org/licenses/gpl-3.0.html See the License for the specific
|
|
|
9 |
* language governing permissions and limitations under the License.
|
|
|
10 |
*
|
|
|
11 |
* When distributing the software, include this License Header Notice in each file.
|
|
|
12 |
*/
|
|
|
13 |
|
|
|
14 |
package org.openconcerto.erp.core.sales.invoice.ui;
|
|
|
15 |
|
|
|
16 |
import org.openconcerto.erp.core.finance.accounting.element.EcritureSQLElement;
|
|
|
17 |
import org.openconcerto.erp.core.finance.accounting.element.MouvementSQLElement;
|
|
|
18 |
import org.openconcerto.sql.Configuration;
|
|
|
19 |
import org.openconcerto.sql.element.SQLComponent;
|
|
|
20 |
import org.openconcerto.sql.element.SQLElement;
|
90 |
ilm |
21 |
import org.openconcerto.sql.model.SQLField;
|
18 |
ilm |
22 |
import org.openconcerto.sql.model.SQLRow;
|
|
|
23 |
import org.openconcerto.sql.model.SQLTable;
|
|
|
24 |
import org.openconcerto.sql.model.Where;
|
|
|
25 |
import org.openconcerto.sql.view.EditFrame;
|
|
|
26 |
import org.openconcerto.sql.view.ListeAddPanel;
|
19 |
ilm |
27 |
import org.openconcerto.sql.view.list.IListe;
|
18 |
ilm |
28 |
import org.openconcerto.sql.view.list.SQLTableModelColumn;
|
|
|
29 |
import org.openconcerto.sql.view.list.SQLTableModelColumnPath;
|
19 |
ilm |
30 |
import org.openconcerto.sql.view.list.SQLTableModelSource;
|
18 |
ilm |
31 |
|
|
|
32 |
import java.awt.event.ActionEvent;
|
73 |
ilm |
33 |
import java.util.Calendar;
|
|
|
34 |
import java.util.Date;
|
18 |
ilm |
35 |
|
|
|
36 |
import javax.swing.JButton;
|
|
|
37 |
import javax.swing.JTable;
|
90 |
ilm |
38 |
import javax.swing.table.TableColumn;
|
18 |
ilm |
39 |
|
19 |
ilm |
40 |
public class ListPanelEcheancesClients extends ListeAddPanel {
|
18 |
ilm |
41 |
|
|
|
42 |
// TODO Ajouter une légende dans liste echeance panel pour les couleurs du renderer
|
|
|
43 |
|
|
|
44 |
private EditFrame editFrame;
|
|
|
45 |
private boolean showRegCompta = false;
|
73 |
ilm |
46 |
private boolean onlyOld = false;
|
18 |
ilm |
47 |
|
|
|
48 |
public ListPanelEcheancesClients() {
|
73 |
ilm |
49 |
this(false);
|
19 |
ilm |
50 |
}
|
18 |
ilm |
51 |
|
73 |
ilm |
52 |
public ListPanelEcheancesClients(boolean onlyOld) {
|
|
|
53 |
this(Configuration.getInstance().getDirectory().getElement("ECHEANCE_CLIENT"), onlyOld);
|
|
|
54 |
}
|
|
|
55 |
|
|
|
56 |
private ListPanelEcheancesClients(final SQLElement elem, boolean onlyOld) {
|
19 |
ilm |
57 |
super(elem, new IListe(elem.getTableSource(true)));
|
73 |
ilm |
58 |
this.onlyOld = onlyOld;
|
18 |
ilm |
59 |
setListe();
|
|
|
60 |
}
|
|
|
61 |
|
|
|
62 |
public JTable getJTable() {
|
|
|
63 |
|
|
|
64 |
return this.getListe().getJTable();
|
|
|
65 |
}
|
|
|
66 |
|
|
|
67 |
public void setShowRegCompta(boolean b) {
|
|
|
68 |
this.showRegCompta = b;
|
|
|
69 |
setListe();
|
|
|
70 |
}
|
|
|
71 |
|
|
|
72 |
protected void handleAction(JButton source, ActionEvent e) {
|
|
|
73 |
if (source == this.buttonModifier) {
|
|
|
74 |
|
|
|
75 |
if (this.editFrame == null) {
|
|
|
76 |
this.editFrame = new EditFrame(this.element, EditFrame.MODIFICATION);
|
|
|
77 |
}
|
19 |
ilm |
78 |
this.editFrame.selectionId(this.getListe().getSelectedId());
|
18 |
ilm |
79 |
this.editFrame.pack();
|
|
|
80 |
this.editFrame.setVisible(true);
|
|
|
81 |
|
80 |
ilm |
82 |
SQLRow ecritureRow = Configuration.getInstance().getDirectory().getElement(EcritureSQLElement.class).getTable().getRow(this.getListe().getSelectedId());
|
18 |
ilm |
83 |
|
|
|
84 |
MouvementSQLElement.showSource(ecritureRow.getInt("ID_MOUVEMENT"));
|
|
|
85 |
|
|
|
86 |
} else {
|
|
|
87 |
|
|
|
88 |
super.handleAction(source, e);
|
|
|
89 |
}
|
|
|
90 |
}
|
|
|
91 |
|
|
|
92 |
private void setListe() {
|
73 |
ilm |
93 |
// FIXME : remove queries from AWT
|
|
|
94 |
final SQLTable elementEchT = getListe().getSource().getPrimaryTable();
|
182 |
ilm |
95 |
Where wNotRegle = new Where(elementEchT.getField("REGLE"), "=", Boolean.FALSE);
|
177 |
ilm |
96 |
|
73 |
ilm |
97 |
if (!showRegCompta) {
|
|
|
98 |
wNotRegle = wNotRegle.and(new Where(elementEchT.getField("REG_COMPTA"), "=", Boolean.FALSE));
|
|
|
99 |
}
|
|
|
100 |
if (onlyOld) {
|
|
|
101 |
Calendar c = Calendar.getInstance();
|
|
|
102 |
c.add(Calendar.DAY_OF_MONTH, -7);
|
|
|
103 |
Date date = c.getTime();
|
|
|
104 |
wNotRegle = wNotRegle.and(new Where(elementEchT.getField("DATE"), "<", date));
|
|
|
105 |
}
|
|
|
106 |
getListe().getRequest().setWhere(wNotRegle);
|
18 |
ilm |
107 |
|
90 |
ilm |
108 |
final ListEcheanceClientRenderer rend = new ListEcheanceClientRenderer(false);
|
|
|
109 |
final ListEcheanceClientRenderer rendDate = new ListEcheanceClientRenderer(true);
|
|
|
110 |
//
|
|
|
111 |
SQLTableModelColumn colDate = ListPanelEcheancesClients.this.getListe().getSource().getColumn(elementEchT.getField("DATE"));
|
|
|
112 |
int indexColDate = ListPanelEcheancesClients.this.getListe().getSource().getColumns().indexOf(colDate);
|
|
|
113 |
for (int i = 0; i < ListPanelEcheancesClients.this.getListe().getJTable().getColumnCount(); i++) {
|
|
|
114 |
if (ListPanelEcheancesClients.this.getListe().getJTable().getColumnClass(i) != Boolean.class) {
|
18 |
ilm |
115 |
|
90 |
ilm |
116 |
TableColumn col = ListPanelEcheancesClients.this.getListe().getJTable().getColumnModel().getColumn(i);
|
|
|
117 |
if (col.getModelIndex() == indexColDate) {
|
|
|
118 |
col.setCellRenderer(rendDate);
|
|
|
119 |
} else {
|
|
|
120 |
col.setCellRenderer(rend);
|
|
|
121 |
}
|
|
|
122 |
}
|
|
|
123 |
}
|
|
|
124 |
|
|
|
125 |
getListe().getSource().getColumn(elementEchT.getField("DATE")).setRenderer(rendDate);
|
73 |
ilm |
126 |
ListPanelEcheancesClients.this.buttonAjouter.setVisible(false);
|
|
|
127 |
ListPanelEcheancesClients.this.buttonEffacer.setVisible(false);
|
|
|
128 |
ListPanelEcheancesClients.this.buttonModifier.setVisible(false);
|
18 |
ilm |
129 |
|
73 |
ilm |
130 |
final SQLTableModelSource src = ListPanelEcheancesClients.this.getListe().getSource();
|
18 |
ilm |
131 |
|
151 |
ilm |
132 |
ListPanelEcheancesClients.this.getListe().setModificationAllowed(true);
|
18 |
ilm |
133 |
|
90 |
ilm |
134 |
SQLField fieldDateEch = elementEchT.getField("DATE");
|
73 |
ilm |
135 |
for (SQLTableModelColumn column : src.getColumns()) {
|
|
|
136 |
if (column.getClass().isAssignableFrom(SQLTableModelColumnPath.class)) {
|
|
|
137 |
((SQLTableModelColumnPath) column).setEditable(false);
|
|
|
138 |
}
|
90 |
ilm |
139 |
if (column.getFields().contains(fieldDateEch)) {
|
|
|
140 |
column.setRenderer(rendDate);
|
|
|
141 |
} else {
|
|
|
142 |
column.setRenderer(rend);
|
|
|
143 |
}
|
73 |
ilm |
144 |
}
|
18 |
ilm |
145 |
|
73 |
ilm |
146 |
((SQLTableModelColumnPath) src.getColumns(getElement().getTable().getField("INFOS")).iterator().next()).setEditable(true);
|
18 |
ilm |
147 |
|
|
|
148 |
}
|
|
|
149 |
|
|
|
150 |
@Override
|
|
|
151 |
public SQLComponent getModifComp() {
|
|
|
152 |
return null;
|
|
|
153 |
}
|
|
|
154 |
}
|