OpenConcerto

Dépôt officiel du code source de l'ERP OpenConcerto
sonarqube

svn://code.openconcerto.org/openconcerto

Rev

Rev 146 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
75 ilm 1
package org.openconcerto.modules.project;
2
 
3
import java.awt.Color;
152 ilm 4
import java.awt.GridBagConstraints;
5
import java.awt.GridBagLayout;
75 ilm 6
import java.awt.event.ActionEvent;
152 ilm 7
import java.awt.event.ActionListener;
8
import java.beans.PropertyChangeEvent;
9
import java.beans.PropertyChangeListener;
75 ilm 10
import java.io.IOException;
152 ilm 11
import java.math.BigDecimal;
12
import java.math.RoundingMode;
75 ilm 13
import java.sql.SQLException;
97 ilm 14
import java.util.ArrayList;
75 ilm 15
import java.util.Arrays;
16
import java.util.Collection;
17
import java.util.Date;
18
import java.util.List;
19
import java.util.Map;
20
import java.util.Set;
21
 
22
import javax.swing.AbstractAction;
152 ilm 23
import javax.swing.JButton;
75 ilm 24
import javax.swing.JComponent;
25
import javax.swing.JFrame;
152 ilm 26
import javax.swing.JLabel;
97 ilm 27
import javax.swing.JOptionPane;
152 ilm 28
import javax.swing.JPanel;
75 ilm 29
import javax.swing.JScrollPane;
97 ilm 30
import javax.swing.SwingUtilities;
75 ilm 31
 
32
import org.openconcerto.erp.action.CreateFrameAbstractAction;
97 ilm 33
import org.openconcerto.erp.config.ComptaPropsConfiguration;
75 ilm 34
import org.openconcerto.erp.config.MainFrame;
35
import org.openconcerto.erp.core.common.element.NumerotationAutoSQLElement;
36
import org.openconcerto.erp.core.sales.invoice.ui.SaisieVenteFactureItemTable;
37
import org.openconcerto.erp.core.sales.order.ui.CommandeClientItemTable;
38
import org.openconcerto.erp.core.sales.quote.component.DevisSQLComponent;
39
import org.openconcerto.erp.core.sales.quote.element.DevisSQLElement;
40
import org.openconcerto.erp.core.sales.quote.element.EtatDevisSQLElement;
41
import org.openconcerto.erp.core.sales.quote.report.DevisXmlSheet;
42
import org.openconcerto.erp.generationEcritures.GenerationMvtSaisieVenteFacture;
43
import org.openconcerto.erp.generationEcritures.provider.AccountingRecordsProvider;
44
import org.openconcerto.erp.generationEcritures.provider.AccountingRecordsProviderManager;
45
import org.openconcerto.erp.model.MouseSheetXmlListeListener;
46
import org.openconcerto.erp.modules.AbstractModule;
47
import org.openconcerto.erp.modules.AlterTableRestricted;
48
import org.openconcerto.erp.modules.ComponentsContext;
49
import org.openconcerto.erp.modules.DBContext;
50
import org.openconcerto.erp.modules.MenuContext;
51
import org.openconcerto.erp.modules.ModuleFactory;
52
import org.openconcerto.modules.project.element.ProjectSQLElement;
53
import org.openconcerto.modules.project.element.ProjectStateSQLElement;
54
import org.openconcerto.modules.project.element.ProjectTypeSQLElement;
55
import org.openconcerto.sql.Configuration;
56
import org.openconcerto.sql.element.SQLComponent;
57
import org.openconcerto.sql.element.SQLElement;
58
import org.openconcerto.sql.element.SQLElementDirectory;
59
import org.openconcerto.sql.model.DBRoot;
60
import org.openconcerto.sql.model.FieldPath;
61
import org.openconcerto.sql.model.SQLRow;
62
import org.openconcerto.sql.model.SQLRowAccessor;
63
import org.openconcerto.sql.model.SQLRowValues;
152 ilm 64
import org.openconcerto.sql.model.SQLRowValuesListFetcher;
75 ilm 65
import org.openconcerto.sql.model.SQLSelect;
152 ilm 66
import org.openconcerto.sql.model.SQLSelectJoin;
75 ilm 67
import org.openconcerto.sql.model.SQLTable;
97 ilm 68
import org.openconcerto.sql.model.SQLTableEvent;
69
import org.openconcerto.sql.model.SQLTableEvent.Mode;
70
import org.openconcerto.sql.model.SQLTableModifiedListener;
75 ilm 71
import org.openconcerto.sql.model.Where;
128 ilm 72
import org.openconcerto.sql.model.graph.Link.Direction;
75 ilm 73
import org.openconcerto.sql.model.graph.Path;
152 ilm 74
import org.openconcerto.sql.request.ComboSQLRequest;
75
import org.openconcerto.sql.sqlobject.SQLRequestComboBox;
146 ilm 76
import org.openconcerto.sql.utils.AlterTable;
75 ilm 77
import org.openconcerto.sql.utils.SQLCreateTable;
78
import org.openconcerto.sql.view.EditFrame;
152 ilm 79
import org.openconcerto.sql.view.EditPanel.EditMode;
75 ilm 80
import org.openconcerto.sql.view.IListFrame;
81
import org.openconcerto.sql.view.ListeAddPanel;
82
import org.openconcerto.sql.view.column.ColumnFooterRenderer;
83
import org.openconcerto.sql.view.column.ColumnPanel;
84
import org.openconcerto.sql.view.column.ColumnPanelFetcher;
85
import org.openconcerto.sql.view.column.ColumnRowRenderer;
86
import org.openconcerto.sql.view.list.BaseSQLTableModelColumn;
87
import org.openconcerto.sql.view.list.IListe;
88
import org.openconcerto.sql.view.list.RowAction;
152 ilm 89
import org.openconcerto.ui.DefaultGridBagConstraints;
90
import org.openconcerto.ui.FrameUtil;
91
import org.openconcerto.ui.PanelFrame;
75 ilm 92
import org.openconcerto.utils.CollectionUtils;
97 ilm 93
import org.openconcerto.utils.ExceptionHandler;
75 ilm 94
import org.openconcerto.utils.Tuple2;
152 ilm 95
import org.openconcerto.utils.cc.IExnClosure;
75 ilm 96
import org.openconcerto.utils.cc.ITransformer;
97
import org.openconcerto.utils.i18n.TranslationManager;
98
 
99
public final class Module extends AbstractModule {
100
 
101
    public static final String PROJECT_TABLENAME = "AFFAIRE";
152 ilm 102
    private List<String> listTableAffaire = Arrays.asList("DEMANDE_PRIX", "BON_RECEPTION", "DEMANDE_ACHAT_ELEMENT", "SAISIE_VENTE_FACTURE", "AVOIR_CLIENT", "BON_DE_LIVRAISON", "COMMANDE_CLIENT",
103
            "DEVIS", "COMMANDE", "SAISIE_ACHAT", "AVOIR_FOURNISSEUR");
75 ilm 104
 
105
    public Module(ModuleFactory f) throws IOException {
106
        super(f);
107
 
108
    }
109
 
110
    @Override
152 ilm 111
    protected void install(DBContext ctxt) throws SQLException, IOException {
75 ilm 112
        super.install(ctxt);
113
 
114
        if (ctxt.getLastInstalledVersion() == null) {
115
 
116
            if (ctxt.getRoot().getTable(PROJECT_TABLENAME) == null) {
117
                final SQLCreateTable createTableEtatAff = ctxt.getCreateTable("ETAT_AFFAIRE");
118
                createTableEtatAff.addVarCharColumn("NOM", 128);
119
 
120
                final SQLCreateTable createTableType = ctxt.getCreateTable("TYPE_AFFAIRE");
121
                createTableType.addVarCharColumn("NOM", 256);
122
 
123
                // AFFAIRE
124
                final SQLCreateTable createTable = ctxt.getCreateTable(PROJECT_TABLENAME);
125
                createTable.addVarCharColumn("NUMERO", 256);
126
                createTable.addVarCharColumn("NOM", 1024);
127
                createTable.addVarCharColumn("INFOS", 1024);
128
                createTable.addForeignColumn("ID_CLIENT", ctxt.getRoot().getTable("CLIENT"));
129
                createTable.addForeignColumn("ID_DEVIS", ctxt.getRoot().getTable("DEVIS"));
130
                createTable.addColumn("DATE", "date");
131
                createTable.addForeignColumn("ID_COMMERCIAL", ctxt.getRoot().getTable("COMMERCIAL"));
132
                createTable.addForeignColumn("ID_ETAT_AFFAIRE", createTableEtatAff);
133
                createTable.addForeignColumn("ID_TYPE_AFFAIRE", createTableType);
134
 
135
                for (String table : this.listTableAffaire) {
136
                    SQLTable tableDevis = ctxt.getRoot().getTable(table);
137
                    if (!tableDevis.getFieldsName().contains("ID_AFFAIRE")) {
138
                        AlterTableRestricted alter = ctxt.getAlterTable(table);
139
                        alter.addForeignColumn("ID_AFFAIRE", createTable);
140
                    }
141
                }
152 ilm 142
 
143
                ctxt.manipulateData(new IExnClosure<DBRoot, SQLException>() {
144
 
75 ilm 145
                    @Override
152 ilm 146
                    public void executeChecked(DBRoot input) throws SQLException {
75 ilm 147
                        // Undefined Affaire
148
                        SQLTable tableAff = input.getTable(PROJECT_TABLENAME);
149
                        SQLRowValues rowVals = new SQLRowValues(tableAff);
152 ilm 150
                        rowVals.insert();
75 ilm 151
 
152
                        // Etat Affaire
153
                        SQLTable tableTypeAffaire = input.getTable("TYPE_AFFAIRE");
154
                        rowVals = new SQLRowValues(tableTypeAffaire);
152 ilm 155
                        rowVals.put("NOM", "Indéfini");
156
                        rowVals.insert();
75 ilm 157
 
158
                        // Etat Affaire
159
                        SQLTable tableEtatAffaire = input.getTable("ETAT_AFFAIRE");
160
                        rowVals = new SQLRowValues(tableEtatAffaire);
152 ilm 161
                        rowVals.put("NOM", "Indéfini");
162
                        rowVals.insert();
75 ilm 163
 
152 ilm 164
                        rowVals.clear();
165
                        rowVals.put("NOM", "A traiter");
166
                        rowVals.insert();
75 ilm 167
 
152 ilm 168
                        rowVals.clear();
169
                        rowVals.put("NOM", "En cours");
170
                        rowVals.insert();
75 ilm 171
 
152 ilm 172
                        rowVals.clear();
173
                        rowVals.put("NOM", "Traitement terminé");
174
                        rowVals.insert();
75 ilm 175
 
152 ilm 176
                        rowVals.clear();
177
                        rowVals.put("NOM", "A facturer");
178
                        rowVals.insert();
75 ilm 179
 
152 ilm 180
                        rowVals.clear();
181
                        rowVals.put("NOM", "Dossier clos");
182
                        rowVals.insert();
75 ilm 183
                    }
184
                });
152 ilm 185
 
75 ilm 186
            }
187
        }
188
 
189
    }
190
 
191
    @Override
192
    protected void setupElements(final SQLElementDirectory dir) {
193
        super.setupElements(dir);
194
        TranslationManager.getInstance().addTranslationStreamFromClass(this.getClass());
195
        dir.addSQLElement(ProjectSQLElement.class);
196
        dir.addSQLElement(ProjectStateSQLElement.class);
197
        dir.addSQLElement(ProjectTypeSQLElement.class);
198
 
199
        final SQLElement element = dir.getElement("DEVIS");
200
        DevisSQLElement eltDevis = dir.getElement(DevisSQLElement.class);
201
        eltDevis.getRowActions().clear();
202
 
203
        eltDevis.addListColumn(new BaseSQLTableModelColumn("Temps Total", Double.class) {
204
 
205
            SQLTable tableDevisElt = Configuration.getInstance().getDirectory().getElement("DEVIS_ELEMENT").getTable();
206
 
207
            @Override
208
            protected Object show_(SQLRowAccessor r) {
209
 
210
                Collection<? extends SQLRowAccessor> rows = r.getReferentRows(tableDevisElt);
211
                double time = 0;
212
                for (SQLRowAccessor sqlRowAccessor : rows) {
213
                    time += OrderColumnRowRenderer.getHours(sqlRowAccessor);
214
                }
215
                return time;
216
            }
217
 
218
            @Override
219
            public Set<FieldPath> getPaths() {
220
                SQLTable table = Configuration.getInstance().getDirectory().getElement("DEVIS").getTable();
88 ilm 221
                Path p = new Path(table).add(tableDevisElt.getField("ID_DEVIS"));
75 ilm 222
 
88 ilm 223
                Path p2 = new Path(table).add(tableDevisElt.getField("ID_DEVIS")).addForeignField("ID_UNITE_VENTE");
75 ilm 224
                return CollectionUtils.createSet(new FieldPath(p, "QTE"), new FieldPath(p, "QTE_UNITAIRE"), new FieldPath(p2, "CODE"));
225
            }
226
        });
227
 
228
        // Transfert vers facture
229
        RowAction factureAction = eltDevis.getDevis2FactureAction();
230
        eltDevis.getRowActions().add(factureAction);
231
 
232
        // Transfert vers commande
233
        RowAction commandeAction = eltDevis.getDevis2CmdCliAction();
234
        eltDevis.getRowActions().add(commandeAction);
235
 
236
        // Marqué accepté
237
        RowAction accepteAction = getAcceptAction();
238
        eltDevis.getRowActions().add(accepteAction);
239
 
240
        // Marqué accepté
241
        RowAction refuseAction = eltDevis.getRefuseAction();
242
        eltDevis.getRowActions().add(refuseAction);
243
 
244
        // // Dupliquer
245
        RowAction cloneAction = eltDevis.getCloneAction();
246
        eltDevis.getRowActions().add(cloneAction);
247
 
248
        MouseSheetXmlListeListener mouseSheetXmlListeListener = new MouseSheetXmlListeListener(DevisXmlSheet.class);
249
        mouseSheetXmlListeListener.setGenerateHeader(true);
250
        mouseSheetXmlListeListener.setShowHeader(true);
251
        eltDevis.getRowActions().addAll(mouseSheetXmlListeListener.getRowActions());
252
 
253
        element.addComponentFactory(SQLElement.DEFAULT_COMP_ID, new ITransformer<Tuple2<SQLElement, String>, SQLComponent>() {
254
 
255
            @Override
256
            public SQLComponent transformChecked(Tuple2<SQLElement, String> input) {
257
                return new DevisSQLComponent(element) {
258
 
259
                    public int insert(SQLRow order) {
260
                        int id = super.insert(order);
261
                        checkAffaire(id);
262
                        return id;
263
                    }
264
 
265
                    public void update() {
266
                        super.update();
267
                        checkAffaire(getSelectedID());
268
                    }
269
 
270
                };
271
            }
272
        });
273
 
274
        final SQLElement elementCmd = dir.getElement("COMMANDE_CLIENT");
275
        elementCmd.addListColumn(new BaseSQLTableModelColumn("Temps Total", Double.class) {
276
 
277
            SQLTable tableCmdElt = dir.getElement("COMMANDE_CLIENT_ELEMENT").getTable();
278
 
279
            @Override
280
            protected Object show_(SQLRowAccessor r) {
281
 
282
                Collection<? extends SQLRowAccessor> rows = r.getReferentRows(tableCmdElt);
283
                double time = 0;
284
                for (SQLRowAccessor sqlRowAccessor : rows) {
285
                    time += OrderColumnRowRenderer.getHours(sqlRowAccessor);
286
                }
287
                return time;
288
            }
289
 
290
            @Override
291
            public Set<FieldPath> getPaths() {
292
                final SQLTable table = elementCmd.getTable();
88 ilm 293
                final Path p = new Path(table).add(tableCmdElt.getField("ID_COMMANDE_CLIENT"));
294
                final Path p2 = new Path(table).add(tableCmdElt.getField("ID_COMMANDE_CLIENT")).addForeignField("ID_UNITE_VENTE");
75 ilm 295
                return CollectionUtils.createSet(new FieldPath(p, "QTE"), new FieldPath(p, "QTE_UNITAIRE"), new FieldPath(p2, "CODE"));
296
            }
297
        });
298
 
299
        NumerotationAutoSQLElement.addClass(ProjectSQLElement.class, PROJECT_TABLENAME);
300
 
128 ilm 301
        for (String tableName : this.listTableAffaire) {
302
            if (!tableName.equalsIgnoreCase("DEVIS")) {
303
                final SQLElement elt = dir.getElement(tableName);
146 ilm 304
                if (elt == null) {
305
                    JOptionPane.showMessageDialog(null, "Table " + tableName + " manquante");
306
                    continue;
307
                }
128 ilm 308
                RowAction action = new RowAction(new AbstractAction("Historique affaire") {
309
                    @Override
310
                    public void actionPerformed(ActionEvent e) {
311
                        ProjectHistory histo = new ProjectHistory();
312
                        histo.getHistoriquePanel().selectIDinJList(IListe.get(e).getSelectedRow().getForeignID("ID_AFFAIRE"));
313
                        histo.getFrame().setVisible(true);
314
                    }
315
                }, false) {
152 ilm 316
 
128 ilm 317
                    @Override
318
                    public boolean enabledFor(IListeEvent evt) {
319
                        if (evt.getSelectedRows().size() == 1) {
320
                            SQLRowAccessor r = evt.getSelectedRow();
321
                            return !r.isForeignEmpty("ID_AFFAIRE");
322
                        }
323
                        return false;
324
                    }
325
                };
326
 
327
                elt.getRowActions().add(action);
328
                elt.addListColumn(new BaseSQLTableModelColumn("Affaire", String.class) {
329
 
330
                    @Override
331
                    protected Object show_(SQLRowAccessor r) {
332
                        if (!r.isForeignEmpty("ID_AFFAIRE") && r.getForeign("ID_AFFAIRE") != null) {
333
                            return r.getForeign("ID_AFFAIRE").getString("NUMERO");
334
                        } else {
335
                            return "";
336
                        }
337
                    }
338
 
339
                    @Override
340
                    public Set<FieldPath> getPaths() {
341
                        SQLTable table = elt.getTable();
342
                        Path p = new Path(table).add(table.getField("ID_AFFAIRE"));
343
                        return CollectionUtils.createSet(new FieldPath(p, "NUMERO"));
344
                    }
345
                });
346
            }
347
        }
348
 
349
        final SQLElement elt = dir.getElement("DEVIS");
350
        RowAction action = new RowAction(new AbstractAction("Historique affaire") {
351
            @Override
352
            public void actionPerformed(ActionEvent e) {
353
                ProjectHistory histo = new ProjectHistory();
354
                SQLRowAccessor selectedRow = IListe.get(e).getSelectedRow();
355
                Collection<? extends SQLRowAccessor> l = selectedRow.getReferentRows(selectedRow.getTable().getTable("AFFAIRE"));
356
                histo.getHistoriquePanel().selectIDinJList(l.iterator().next().getID());
357
                histo.getFrame().setVisible(true);
358
            }
359
        }, false) {
152 ilm 360
 
128 ilm 361
            @Override
362
            public boolean enabledFor(IListeEvent evt) {
363
                if (evt.getSelectedRows().size() == 1) {
364
                    SQLRowAccessor r = evt.getSelectedRow();
365
                    Collection<? extends SQLRowAccessor> l = r.getReferentRows(r.getTable().getTable("AFFAIRE"));
366
                    return l.size() > 0;
367
                }
368
                return false;
369
            }
370
        };
371
 
372
        elt.getRowActions().add(action);
373
 
374
        elt.addListColumn(new BaseSQLTableModelColumn("Affaire", String.class) {
375
 
376
            @Override
377
            protected Object show_(SQLRowAccessor r) {
378
                Collection<? extends SQLRowAccessor> rows = r.getReferentRows(elt.getTable().getTable("AFFAIRE"));
379
                if (rows.size() == 1) {
380
                    return rows.iterator().next().getString("NUMERO");
381
                } else {
382
                    return "";
383
                }
384
            }
385
 
386
            @Override
387
            public Set<FieldPath> getPaths() {
388
                SQLTable table = elt.getTable();
389
                Path p = new Path(table).add(table.getTable("AFFAIRE"), Direction.REFERENT);
390
                return CollectionUtils.createSet(new FieldPath(p, "NUMERO"));
391
            }
392
        });
152 ilm 393
        new CmdToBrSQLInjector();
75 ilm 394
        new QuoteToOrderSQLInjector();
395
        new QuoteToInvoiceSQLInjector();
396
        new OrderToInvoiceSQLInjector();
397
    }
398
 
152 ilm 399
    public static JFrame checkAffaire(int id) {
400
        return checkAffaire(id, true);
401
    }
402
 
403
    public static JFrame checkAffaire(int id, final boolean createCommandeClient) {
75 ilm 404
        final SQLTable tableDevis = Configuration.getInstance().getRoot().findTable("DEVIS");
405
        final SQLTable tableNum = Configuration.getInstance().getRoot().findTable("NUMEROTATION_AUTO");
406
        final SQLRow row = tableDevis.getRow(id);
407
        final SQLRow rowAffaire = row.getForeign("ID_AFFAIRE");
408
        if (rowAffaire == null || rowAffaire.isUndefined()) {
409
            if (row.getInt("ID_ETAT_DEVIS") == EtatDevisSQLElement.ACCEPTE) {
410
                // FIXME Vérifier si le devis n'est pas déjà rattaché à une affaire
411
 
152 ilm 412
                JPanel p = new JPanel(new GridBagLayout());
413
                GridBagConstraints c = new DefaultGridBagConstraints();
414
                c.gridwidth = GridBagConstraints.REMAINDER;
415
                p.add(new JLabel("Voulez vous intégrer ce devis sur une affaire existante?"), c);
416
                c.gridy++;
417
                c.gridwidth = 1;
418
                p.add(new JLabel("Rattacher à l'affaire : "), c);
419
                c.gridx++;
420
                final SQLRequestComboBox box = new SQLRequestComboBox();
421
                final ComboSQLRequest comboRequest = Configuration.getInstance().getDirectory().getElement("AFFAIRE").getComboRequest(true);
422
                Where w = new Where(comboRequest.getPrimaryTable().getField("ID_CLIENT"), "=", row.getForeignID("ID_CLIENT"));
423
                comboRequest.setWhere(w);
424
                box.uiInit(comboRequest);
425
                p.add(box, c);
426
                c.gridy++;
427
                c.gridx = 0;
428
                final JButton buttonApply = new JButton("Appliquer");
429
                JButton buttonAnnuler = new JButton("Nouvelle affaire");
430
                p.add(buttonApply, c);
431
                buttonApply.setEnabled(false);
432
                box.addValueListener(new PropertyChangeListener() {
75 ilm 433
 
152 ilm 434
                    @Override
435
                    public void propertyChange(PropertyChangeEvent evt) {
436
                        buttonApply.setEnabled(box.getSelectedRow() != null);
75 ilm 437
 
152 ilm 438
                    }
439
                });
440
                c.gridx++;
441
                p.add(buttonAnnuler, c);
442
                final PanelFrame f = new PanelFrame(p, "Affection d'un devis à une affaire");
75 ilm 443
 
152 ilm 444
                buttonAnnuler.addActionListener(new ActionListener() {
75 ilm 445
 
152 ilm 446
                    @Override
447
                    public void actionPerformed(ActionEvent ae) {
448
                        f.dispose();
449
                        final SQLTable table = tableDevis.getTable(PROJECT_TABLENAME);
450
                        final SQLRowValues rowVals = new SQLRowValues(table);
451
 
452
                        final String nextNumero = NumerotationAutoSQLElement.getNextNumero(ProjectSQLElement.class);
453
                        rowVals.put("NUMERO", nextNumero);
454
 
455
                        // incrémentation du numéro auto
456
                        final SQLRowValues rowValsNum = new SQLRowValues(tableNum);
457
                        int val = tableNum.getRow(2).getInt(NumerotationAutoSQLElement.getLabelNumberFor(ProjectSQLElement.class));
458
                        val++;
459
                        rowValsNum.put(NumerotationAutoSQLElement.getLabelNumberFor(ProjectSQLElement.class), new Integer(val));
460
                        try {
461
                            rowValsNum.update(2);
462
                        } catch (final SQLException e) {
463
                            e.printStackTrace();
464
                        }
465
 
466
                        rowVals.put("ID_DEVIS", row.getID());
467
                        rowVals.put("ID_CLIENT", row.getObject("ID_CLIENT"));
468
                        rowVals.put("ID_COMMERCIAL", row.getObject("ID_COMMERCIAL"));
469
                        rowVals.put("DATE", new Date());
470
                        rowVals.put("ID_ETAT_AFFAIRE", ProjectStateSQLElement.EN_COURS);
471
 
472
                        SQLRowValues rowValsDevis = row.asRowValues();
473
                        rowValsDevis.put("ID_AFFAIRE", rowVals);
474
 
475
                        try {
476
                            int id = rowVals.commit().getID();
477
                            row.fetchValues();
478
                            if (createCommandeClient) {
479
                                Configuration.getInstance().getDirectory().getElement(DevisSQLElement.class).transfertCommandeClient(Arrays.asList(row.asRowValues()));
480
                                EditFrame frame = new EditFrame(Configuration.getInstance().getDirectory().getElement("AFFAIRE"), EditMode.MODIFICATION);
481
                                frame.selectionId(id);
482
                                FrameUtil.showPacked(frame);
483
                            }
484
                        } catch (SQLException exn) {
485
                            // TODO Bloc catch auto-généré
486
                            exn.printStackTrace();
487
                        }
488
                    }
489
                });
490
 
491
                buttonApply.addActionListener(new ActionListener() {
492
 
493
                    @Override
494
                    public void actionPerformed(ActionEvent e) {
495
                        f.dispose();
496
 
497
                        SQLRowValues rowValsDevis = row.asRowValues();
498
                        rowValsDevis.put("ID_AFFAIRE", box.getSelectedId());
499
 
500
                        try {
501
                            rowValsDevis.commit();
502
                        } catch (SQLException exn) {
503
                            // TODO Bloc catch auto-généré
504
                            exn.printStackTrace();
505
                        }
506
                    }
507
                });
508
                FrameUtil.show(f);
509
                return f;
75 ilm 510
            }
146 ilm 511
 
512
        } else if (row.getInt("ID_ETAT_DEVIS") != EtatDevisSQLElement.ACCEPTE) {
75 ilm 513
            SQLRowValues rowVals = rowAffaire.asRowValues();
514
            rowVals.putEmptyLink("ID_DEVIS");
515
            try {
516
                rowVals.update();
517
            } catch (SQLException exn) {
518
                exn.printStackTrace();
519
            }
520
        }
152 ilm 521
        return null;
75 ilm 522
    }
523
 
97 ilm 524
    List<Integer> idsAsked = new ArrayList<Integer>();
525
 
526
    public void checkProjectState(final SQLRowAccessor rowFact) {
527
        if (!rowFact.isForeignEmpty("ID_AFFAIRE")) {
528
            final SQLRowAccessor rowAff = rowFact.getForeign("ID_AFFAIRE");
529
 
530
            if (rowAff.getInt("ID_ETAT_AFFAIRE") < ProjectStateSQLElement.DOSSIER_CLOS) {
531
 
532
                SQLSelect sel = new SQLSelect();
533
                final SQLTable tableVF = rowFact.getTable();
534
                sel.addSelect(tableVF.getField("T_TTC"), "SUM");
535
                Where w = new Where(tableVF.getField("ID_AFFAIRE"), "=", rowAff.getID());
536
                sel.setWhere(w);
537
 
538
                Number total = (Number) tableVF.getDBSystemRoot().getDataSource().executeScalar(sel.asString());
539
 
540
                long devis = rowAff.getForeign("ID_DEVIS").getLong("T_TTC");
541
                if (devis == total.longValue()) {
542
                    if (!idsAsked.contains(rowFact.getID())) {
543
                        idsAsked.add(rowFact.getID());
544
                        SwingUtilities.invokeLater(new Runnable() {
545
 
546
                            @Override
547
                            public void run() {
548
                                int a = JOptionPane.showConfirmDialog(null, "Voulez vous passer l'affaire " + rowAff.getString("NUMERO") + " dans l'état \"Dossier Clos\"?", "Affaire 100% facturée",
549
                                        JOptionPane.YES_NO_OPTION);
550
                                if (a == JOptionPane.YES_OPTION) {
551
                                    SQLRowValues rowVals = rowAff.createEmptyUpdateRow();
552
                                    rowVals.put("ID_ETAT_AFFAIRE", ProjectStateSQLElement.DOSSIER_CLOS);
553
                                    try {
554
                                        rowVals.commit();
555
                                    } catch (SQLException e) {
556
                                        ExceptionHandler.handle("Erreur lors de la mise à jour de l'état de l'affaire", e);
557
                                    }
558
                                }
559
                                idsAsked.remove(Integer.valueOf(rowFact.getID()));
560
                            }
561
                        });
562
                    }
563
                }
564
 
565
            }
566
        }
567
    }
568
 
75 ilm 569
    public RowAction getAcceptAction() {
570
        return new RowAction(new AbstractAction() {
571
            public void actionPerformed(ActionEvent e) {
88 ilm 572
                SQLRow selectedRow = IListe.get(e).getSelectedRow().asRow();
75 ilm 573
                SQLRowValues rowVals = selectedRow.createEmptyUpdateRow();
574
                rowVals.put("ID_ETAT_DEVIS", EtatDevisSQLElement.ACCEPTE);
575
                try {
576
                    rowVals.update();
577
                } catch (SQLException e1) {
578
                    e1.printStackTrace();
579
                }
580
                selectedRow.getTable().fireTableModified(selectedRow.getID());
581
                checkAffaire(selectedRow.getID());
582
            }
583
        }, false, "project.accept") {
152 ilm 584
 
97 ilm 585
            public boolean enabledFor(List<SQLRowValues> selection) {
75 ilm 586
                if (selection != null && selection.size() == 1) {
587
                    if (selection.get(0).getInt("ID_ETAT_DEVIS") == EtatDevisSQLElement.EN_ATTENTE) {
588
                        return true;
589
                    }
590
                }
591
                return false;
592
            };
152 ilm 593
 
75 ilm 594
        };
595
    }
596
 
597
    @Override
598
    protected void setupComponents(final ComponentsContext ctxt) {
152 ilm 599
 
146 ilm 600
        DBRoot root = ComptaPropsConfiguration.getInstanceCompta().getRootSociete();
152 ilm 601
        List<String> table2check = Arrays.asList("BON_RECEPTION", "DEMANDE_PRIX", "DEMANDE_ACHAT_ELEMENT");
146 ilm 602
        for (String table : table2check) {
603
            if (root.contains(table)) {
604
                SQLTable tableCR = root.getTable(table);
605
                if (!tableCR.contains("ID_AFFAIRE")) {
606
                    try {
607
                        AlterTable alt = new AlterTable(tableCR);
608
                        alt.addForeignColumn("ID_AFFAIRE", root.getTable("AFFAIRE"));
609
                        root.getDBSystemRoot().getDataSource().execute(alt.asString());
610
                        String s = "INSERT INTO " + root.getTable("FWK_MODULE_METADATA").getSQLName().quote()
611
                                + "(\"MODULE_NAME\",\"TABLE\",\"FIELD\",\"KEY\",\"MODULE_VERSION\") VALUES('org.openconcerto.modules.project','" + table + "','ID_AFFAIRE',true,10000)";
612
                        root.getDBSystemRoot().getDataSource().execute(s);
613
                        root.getSchema().updateVersion();
614
                        root.refetchTable(tableCR.getName());
615
                    } catch (SQLException e) {
616
                        e.printStackTrace();
617
                    }
618
                }
619
            }
620
        }
152 ilm 621
 
75 ilm 622
        for (String table : this.listTableAffaire) {
623
            if (!table.equalsIgnoreCase("DEVIS"))
624
                ctxt.putAdditionalField(table, "ID_AFFAIRE");
625
        }
146 ilm 626
 
75 ilm 627
    }
628
 
629
    @Override
630
    protected void setupMenu(final MenuContext ctxt) {
631
        ctxt.addMenuItem(new CreateFrameAbstractAction("Liste des affaires") {
632
            @Override
633
            public JFrame createFrame() {
634
                IListFrame frame = new IListFrame(new ListeAddPanel(ctxt.getElement(PROJECT_TABLENAME)));
635
                return frame;
636
            }
637
        }, MainFrame.LIST_MENU);
638
        ctxt.addMenuItem(new CreateFrameAbstractAction("Historique des affaires") {
639
            @Override
640
            public JFrame createFrame() {
641
                ProjectHistory histo = new ProjectHistory();
642
 
643
                return histo.getFrame();
644
            }
645
        }, MainFrame.LIST_MENU);
646
 
647
        ctxt.addMenuItem(new CreateFrameAbstractAction("Saisie affaire") {
648
            @Override
649
            public JFrame createFrame() {
650
                return new EditFrame(ctxt.getElement(PROJECT_TABLENAME));
651
            }
652
        }, MainFrame.CREATE_MENU);
653
 
152 ilm 654
        addMenuImportExport(ctxt);
146 ilm 655
 
75 ilm 656
    }
657
 
152 ilm 658
    private void addMenuImportExport(final MenuContext ctxt) {
659
        ////
660
 
661
        ctxt.addMenuItem(new AbstractAction("Export Affaire") {
662
            @Override
663
            public void actionPerformed(ActionEvent e) {
664
                ProjectImportExport importExport = new ProjectImportExport(ctxt.getElement("AFFAIRE").getTable().getDBRoot());
665
                importExport.export();
666
            }
667
        }, MainFrame.HELP_MENU);
668
 
669
        ctxt.addMenuItem(new AbstractAction("Import Affaire") {
670
            @Override
671
            public void actionPerformed(ActionEvent e) {
672
                ProjectImportExport importExport = new ProjectImportExport(ctxt.getElement("AFFAIRE").getTable().getDBRoot());
673
                importExport.importProjects();
674
            }
675
        }, MainFrame.HELP_MENU);
676
 
677
        ctxt.addMenuItem(new AbstractAction("Fix ID_AFFAIRE") {
678
            @Override
679
            public void actionPerformed(ActionEvent e) {
680
                {
681
                    SQLTable tableCmd = ctxt.getElement("COMMANDE_CLIENT").getTable();
682
                    SQLSelect selBadCmd = new SQLSelect();
683
                    selBadCmd.addSelect(tableCmd.getKey());
684
                    selBadCmd.addSelect(tableCmd.getField("ID_AFFAIRE"));
685
                    SQLSelectJoin joinTR = selBadCmd.addBackwardJoin("RIGHT", "tr", tableCmd.getTable().getTable("TR_DEVIS").getField("ID_COMMANDE_CLIENT"), null);
686
                    SQLSelectJoin joinDevis = selBadCmd.addJoin("LEFT", joinTR.getJoinedTable().getField("ID_DEVIS"));
687
                    SQLSelectJoin joinAff = selBadCmd.addBackwardJoin("LEFT", "aff", tableCmd.getTable().getTable("AFFAIRE").getField("ID_DEVIS"), null);
688
                    selBadCmd.addSelect(joinAff.getJoinedTable().getKey());
689
 
690
                    selBadCmd.setWhere(Where.isNull(tableCmd.getField("ID_AFFAIRE")));
691
                    System.err.println(selBadCmd.asString());
692
 
693
                    List<Object[]> result = (List<Object[]>) tableCmd.getDBSystemRoot().getDataSource().executeA(selBadCmd.asString());
694
                    try {
695
                        for (Object[] objects : result) {
696
                            if (objects[2] != null && objects[2].toString().trim().length() > 0)
697
                                tableCmd.getRow(((Number) objects[0]).intValue()).createEmptyUpdateRow().put("ID_AFFAIRE", ((Number) objects[2]).intValue()).commit();
698
                        }
699
                    } catch (SQLException e1) {
700
                        // TODO Auto-generated catch block
701
                        e1.printStackTrace();
702
                    }
703
 
704
                    // List<SQLRow> list = SQLRowListRSH.execute(selBadVF);
705
                }
706
                {
707
                    SQLTable tableVF = ctxt.getElement("SAISIE_VENTE_FACTURE").getTable();
708
                    SQLSelect selBadVF = new SQLSelect();
709
                    selBadVF.addSelect(tableVF.getKey());
710
                    selBadVF.addSelect(tableVF.getField("ID_AFFAIRE"));
711
                    SQLSelectJoin joinTR = selBadVF.addBackwardJoin("RIGHT", "tr", tableVF.getTable().getTable("TR_COMMANDE_CLIENT").getField("ID_SAISIE_VENTE_FACTURE"), null);
712
                    SQLSelectJoin joinCmd = selBadVF.addJoin("LEFT", joinTR.getJoinedTable().getField("ID_COMMANDE_CLIENT"));
713
                    selBadVF.addSelect(joinCmd.getJoinedTable().getField("ID_AFFAIRE"));
714
 
715
                    selBadVF.setWhere(Where.isNull(tableVF.getField("ID_AFFAIRE")));
716
                    System.err.println(selBadVF.asString());
717
                    List<Object[]> result = (List<Object[]>) tableVF.getDBSystemRoot().getDataSource().executeA(selBadVF.asString());
718
                    try {
719
                        for (Object[] objects : result) {
720
                            if (objects[2] != null && objects[2].toString().trim().length() > 0)
721
                                tableVF.getRow(((Number) objects[0]).intValue()).createEmptyUpdateRow().put("ID_AFFAIRE", ((Number) objects[2]).intValue()).commit();
722
                        }
723
                    } catch (SQLException e1) {
724
                        // TODO Auto-generated catch block
725
                        e1.printStackTrace();
726
                    }
727
                }
728
            }
729
        }, MainFrame.CREATE_MENU);
730
 
731
        ctxt.addMenuItem(new AbstractAction("Recalcul Total achat facture prorata") {
732
            @Override
733
            public void actionPerformed(ActionEvent e) {
734
 
735
                {
736
                    final SQLTable table = ctxt.getElement("SAISIE_VENTE_FACTURE").getTable();
737
                    SQLRowValues rowValsFact = new SQLRowValues(table);
738
                    rowValsFact.putNulls("SOLDE", "PARTIAL", "T_HA", "T_HT");
739
 
740
                    final SQLTable tableCmd = ctxt.getElement("COMMANDE_CLIENT").getTable();
741
                    SQLRowValues rowValsCmd = new SQLRowValues(tableCmd);
742
                    rowValsCmd.putNulls("T_HT");
743
 
744
                    final SQLTable tableCmdElt = ctxt.getElement("COMMANDE_CLIENT_ELEMENT").getTable();
745
                    SQLRowValues rowValsCmdElt = new SQLRowValues(tableCmdElt);
746
                    rowValsCmdElt.put("ID_COMMANDE_CLIENT", rowValsCmd);
747
                    rowValsCmdElt.putNulls("T_PA_HT", "NIVEAU");
748
 
749
                    final SQLTable tableTR = table.getTable("TR_COMMANDE_CLIENT");
750
                    SQLRowValues rowValsTR = new SQLRowValues(tableTR);
751
                    rowValsTR.put("ID_SAISIE_VENTE_FACTURE", rowValsFact);
752
                    rowValsTR.put("ID_COMMANDE_CLIENT", rowValsCmd);
753
 
754
                    SQLRowValuesListFetcher fetcher = SQLRowValuesListFetcher.create(rowValsFact);
755
                    fetcher.appendSelTransf(new ITransformer<SQLSelect, SQLSelect>() {
756
                        @Override
757
                        public SQLSelect transformChecked(SQLSelect input) {
758
                            Where w = new Where(table.getField("SOLDE"), "=", Boolean.TRUE);
759
                            w = w.or(new Where(table.getField("PARTIAL"), "=", Boolean.TRUE));
760
                            input.setWhere(w);
761
                            return input;
762
                        }
763
                    });
764
 
765
                    List<SQLRowValues> rowVals = fetcher.fetch();
766
 
767
                    for (SQLRowValues sqlRowValues : rowVals) {
768
                        // Recuperation de la commande
769
                        final Collection<SQLRowValues> referentRows = sqlRowValues.getReferentRows(tableTR);
770
                        if (!referentRows.isEmpty()) {
771
                            SQLRowAccessor rowTR = referentRows.iterator().next();
772
                            SQLRowAccessor rowCmd = rowTR.getForeign("ID_COMMANDE_CLIENT");
773
                            final long htCmd = rowCmd.getLong("T_HT");
774
                            if (htCmd != 0) {
775
 
776
                                BigDecimal totalHA = BigDecimal.ZERO;
777
                                Collection<? extends SQLRowAccessor> elt = rowCmd.getReferentRows(tableCmdElt);
778
                                for (SQLRowAccessor sqlRowAccessor : elt) {
779
                                    if (sqlRowAccessor.getInt("NIVEAU") == 1) {
780
                                        totalHA = totalHA.add(sqlRowAccessor.getBigDecimal("T_PA_HT"));
781
                                    }
782
                                }
783
                                BigDecimal prorata = new BigDecimal((double) sqlRowValues.getLong("T_HT") / (double) htCmd);
784
                                try {
785
                                    sqlRowValues.createEmptyUpdateRow().put("T_HA", totalHA.multiply(prorata).movePointRight(2).setScale(0, RoundingMode.HALF_UP).longValue()).update();
786
                                } catch (SQLException e1) {
787
                                    e1.printStackTrace();
788
                                }
789
                            }
790
                        }
791
                    }
792
                }
793
            }
794
        }, MainFrame.CREATE_MENU);
795
    }
796
 
75 ilm 797
    @Override
798
    protected void start() {
146 ilm 799
 
75 ilm 800
        final JComponent quoteComponent = createQuotePanel();
801
        final JComponent orderComponent = createOrderPanel();
802
        MainFrame.getInstance().getTabbedPane().addTab("Commandes en cours", orderComponent);
803
        MainFrame.getInstance().getTabbedPane().addTab("Devis en attente", quoteComponent);
804
        MainFrame.getInstance().getTabbedPane().addTab("Affaires", new ListeAddPanel(Configuration.getInstance().getDirectory().getElement(PROJECT_TABLENAME)));
805
        // Fix for classic XP Theme
806
        quoteComponent.setOpaque(true);
807
        quoteComponent.setBackground(Color.WHITE);
808
        orderComponent.setOpaque(true);
809
        orderComponent.setBackground(Color.WHITE);
810
        // Select first tab
811
        MainFrame.getInstance().getTabbedPane().setSelectedIndex(1);
812
 
813
        CommandeClientItemTable.getVisibilityMap().put("POURCENT_ACOMPTE", Boolean.TRUE);
814
        SaisieVenteFactureItemTable.getVisibilityMap().put("POURCENT_ACOMPTE", Boolean.TRUE);
815
        AccountingRecordsProvider p = new AccountingRecordsProvider() {
816
 
817
            @Override
818
            public void putLabel(SQLRowAccessor rowSource, Map<String, Object> values) {
819
                values.put("NOM", "Fact. vente " + rowSource.getString("NUMERO"));
820
            }
821
 
822
            @Override
823
            public void putPieceLabel(SQLRowAccessor rowSource, SQLRowValues rowValsPiece) {
824
                rowValsPiece.put("NOM", rowSource.getString("NUMERO"));
825
            }
826
        };
827
        AccountingRecordsProviderManager.put(GenerationMvtSaisieVenteFacture.ID, p);
97 ilm 828
 
829
        final SQLTable tableFact = ComptaPropsConfiguration.getInstanceCompta().getRootSociete().getTable("SAISIE_VENTE_FACTURE");
830
 
831
        tableFact.addTableModifiedListener(new SQLTableModifiedListener() {
832
 
833
            @Override
834
            public void tableModified(SQLTableEvent evt) {
835
                if (evt.getMode() == Mode.ROW_ADDED || evt.getMode() == Mode.ROW_UPDATED) {
836
                    checkProjectState(evt.getRow());
837
                }
838
            }
839
        });
75 ilm 840
    }
841
 
842
    private JComponent createQuotePanel() {
843
        ColumnRowRenderer cRenderer = new QuoteColumnRowRenderer();
844
        ColumnFooterRenderer fRenderer = new QuoteColumnFooterRenderer();
845
        final ColumnPanel columnPanel = new ColumnPanel(220, cRenderer, fRenderer);
846
        columnPanel.setOpaque(false);
847
        final SQLElement element = Configuration.getInstance().getDirectory().getElement("DEVIS_ELEMENT");
88 ilm 848
        Path p = Path.get(element.getTable()).addForeignField("ID_ARTICLE").addForeignField("ID_FAMILLE_ARTICLE");
75 ilm 849
 
850
        SQLRowValues values = new SQLRowValues(element.getTable());
851
        values.put("NOM", null);
852
        values.put("T_PV_HT", null);
853
        SQLRowValues rowValsClient = new SQLRowValues(element.getTable().getTable("CLIENT"));
854
        rowValsClient.put("NOM", null);
855
        final SQLTable tableDevis = element.getTable().getTable("DEVIS");
856
        SQLRowValues rowValsDevis = new SQLRowValues(tableDevis);
857
        rowValsDevis.put("NUMERO", null);
858
        rowValsDevis.put("DATE", null);
859
        rowValsDevis.put("T_HT", null);
860
 
861
        rowValsDevis.put("ID_CLIENT", rowValsClient);
862
        values.put("ID_DEVIS", rowValsDevis);
863
        SQLRowValues rowValsUnite = new SQLRowValues(element.getTable().getTable("UNITE_VENTE"));
864
        rowValsUnite.put("CODE", null);
865
        values.put("ID_UNITE_VENTE", rowValsUnite);
866
        values.put("QTE", null);
867
        values.put("QTE_UNITAIRE", null);
868
 
869
        ITransformer<SQLSelect, SQLSelect> t = new ITransformer<SQLSelect, SQLSelect>() {
870
            @Override
871
            public SQLSelect transformChecked(SQLSelect input) {
872
                input.andWhere(new Where(input.getAlias(tableDevis.getField("ID_ETAT_DEVIS")), "=", EtatDevisSQLElement.EN_ATTENTE));
873
                return input;
874
            }
875
        };
876
        final ColumnPanelFetcher projectFetcher = new ColumnPanelFetcher(values, new FieldPath(p, "NOM"), t);
877
        columnPanel.setHeaderRenderer(new TotalHeaderRenderer());
878
        columnPanel.setFetch(projectFetcher);
879
 
880
        final JScrollPane comp = new JScrollPane(columnPanel);
881
        comp.setBorder(null);
882
        comp.getViewport().setOpaque(false);
883
        return comp;
884
    }
885
 
886
    private JComponent createOrderPanel() {
887
        ColumnRowRenderer cRenderer = new OrderColumnRowRenderer();
888
        ColumnFooterRenderer fRenderer = new OrderColumnFooterRenderer();
889
        final ColumnPanel columnPanel = new ColumnPanel(220, cRenderer, fRenderer);
890
        columnPanel.setOpaque(false);
891
        final SQLElement element = Configuration.getInstance().getDirectory().getElement("COMMANDE_CLIENT_ELEMENT");
892
        final SQLTable tableOrder = element.getTable();
88 ilm 893
        Path p = Path.get(tableOrder).addForeignField("ID_ARTICLE").addForeignField("ID_FAMILLE_ARTICLE");
75 ilm 894
 
895
        SQLRowValues values = new SQLRowValues(tableOrder);
896
        values.put("NOM", null);
897
        values.put("T_PV_HT", null);
898
        SQLRowValues rowValsClient = new SQLRowValues(tableOrder.getTable("CLIENT"));
899
        rowValsClient.put("NOM", null);
900
        SQLRowValues rowValsCmd = new SQLRowValues(tableOrder.getTable("COMMANDE_CLIENT"));
901
        rowValsCmd.put("NUMERO", null);
902
        rowValsCmd.put("DATE", null);
903
        rowValsCmd.put("T_HT", null);
904
 
905
        rowValsCmd.put("ID_CLIENT", rowValsClient);
906
        values.put("ID_COMMANDE_CLIENT", rowValsCmd);
907
        SQLRowValues rowValsUnite = new SQLRowValues(tableOrder.getTable("UNITE_VENTE"));
908
        rowValsUnite.put("CODE", null);
909
        values.put("ID_UNITE_VENTE", rowValsUnite);
910
        values.put("QTE", null);
911
        values.put("QTE_UNITAIRE", null);
912
 
913
        final SQLTable tableAffaire = tableOrder.getTable(PROJECT_TABLENAME);
914
        SQLRowValues rowValsAffaire = new SQLRowValues(tableAffaire);
915
        rowValsAffaire.put("NUMERO", null);
916
        rowValsAffaire.put("DATE", null);
917
        rowValsCmd.put("ID_AFFAIRE", rowValsAffaire);
918
 
919
        if (tableOrder.getDBRoot().contains("AFFAIRE_TEMPS")) {
920
            final SQLTable tableAffaireTemps = tableOrder.getTable("AFFAIRE_TEMPS");
921
            SQLRowValues rowValsAffaireTemps = new SQLRowValues(tableAffaireTemps);
922
            rowValsAffaireTemps.put("TEMPS", null);
923
            rowValsAffaireTemps.put("ID_COMMANDE_CLIENT_ELEMENT", values);
924
        }
925
        ITransformer<SQLSelect, SQLSelect> t = new ITransformer<SQLSelect, SQLSelect>() {
926
            @Override
927
            public SQLSelect transformChecked(SQLSelect input) {
928
                input.andWhere(new Where(input.getAlias(tableAffaire.getField("ID_ETAT_AFFAIRE")), "=", ProjectStateSQLElement.EN_COURS));
929
                return input;
930
            }
931
        };
932
        final ColumnPanelFetcher projectFetcher = new ColumnPanelFetcher(values, new FieldPath(p, "NOM"), t);
933
        columnPanel.setHeaderRenderer(new TotalHeaderRenderer());
934
        columnPanel.setFetch(projectFetcher);
935
        final JScrollPane comp = new JScrollPane(columnPanel);
936
        comp.setBorder(null);
937
        comp.getViewport().setOpaque(false);
938
        return comp;
939
    }
940
 
941
    @Override
942
    protected void stop() {
943
    }
944
}