OpenConcerto

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

svn://code.openconcerto.org/openconcerto

Rev

Rev 142 | Rev 174 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 142 Rev 156
Line 24... Line 24...
24
import org.openconcerto.sql.element.SQLElement;
24
import org.openconcerto.sql.element.SQLElement;
25
import org.openconcerto.sql.model.SQLField;
25
import org.openconcerto.sql.model.SQLField;
26
import org.openconcerto.sql.model.SQLRow;
26
import org.openconcerto.sql.model.SQLRow;
27
import org.openconcerto.sql.model.SQLRowAccessor;
27
import org.openconcerto.sql.model.SQLRowAccessor;
28
import org.openconcerto.sql.model.SQLRowValues;
28
import org.openconcerto.sql.model.SQLRowValues;
-
 
29
import org.openconcerto.sql.model.SQLRowValuesListFetcher;
29
import org.openconcerto.sql.model.SQLTable;
30
import org.openconcerto.sql.model.SQLTable;
-
 
31
import org.openconcerto.sql.model.Where;
30
import org.openconcerto.sql.preferences.SQLPreferences;
32
import org.openconcerto.sql.preferences.SQLPreferences;
31
import org.openconcerto.sql.view.list.AutoCompletionManager;
33
import org.openconcerto.sql.view.list.AutoCompletionManager;
32
import org.openconcerto.sql.view.list.RowValuesTable;
34
import org.openconcerto.sql.view.list.RowValuesTable;
33
import org.openconcerto.sql.view.list.RowValuesTableControlPanel;
35
import org.openconcerto.sql.view.list.RowValuesTableControlPanel;
34
import org.openconcerto.sql.view.list.RowValuesTableModel;
36
import org.openconcerto.sql.view.list.RowValuesTableModel;
Line 67... Line 69...
67
    protected SQLTableElement tableElementTotalDevise;
69
    protected SQLTableElement tableElementTotalDevise;
68
    protected SQLTableElement service, qte, ha;
70
    protected SQLTableElement service, qte, ha;
69
    protected SQLTableElement tableElementPoidsTotal;
71
    protected SQLTableElement tableElementPoidsTotal;
70
    protected SQLTableElement tableElementEcoID, tableElementEco, tableElementEcoTotal;
72
    protected SQLTableElement tableElementEcoID, tableElementEco, tableElementEcoTotal;
71
    protected SQLTableElement prebilan;
73
    protected SQLTableElement prebilan;
-
 
74
    protected SQLRowAccessor rowCatComptable;
72
    private RowValuesTableModel model;
75
    private RowValuesTableModel model;
73
    protected SQLRowValues defaultRowVals;
76
    protected SQLRowValues defaultRowVals;
74
    private List<JButton> buttons = null;
77
    private List<JButton> buttons = null;
75
    protected RowValuesTableControlPanel control = null;
78
    protected RowValuesTableControlPanel control = null;
76
    private SQLRowAccessor tarif = null;
79
    private SQLRowAccessor tarif = null;
Line 89... Line 92...
89
        this.buttons = buttons;
92
        this.buttons = buttons;
90
        init();
93
        init();
91
        uiInit();
94
        uiInit();
92
    }
95
    }
93
 
96
 
-
 
97
    public void setRowCatComptable(SQLRowAccessor rowCatComptable) {
-
 
98
        this.rowCatComptable = rowCatComptable;
-
 
99
    }
-
 
100
 
94
    /**
101
    /**
95
     * 
102
     * 
96
     */
103
     */
97
    abstract protected void init();
104
    abstract protected void init();
98
 
105
 
Line 260... Line 267...
260
 
267
 
261
        final boolean modeAvance = DefaultNXProps.getInstance().getBooleanValue("ArticleModeVenteAvance", false);
268
        final boolean modeAvance = DefaultNXProps.getInstance().getBooleanValue("ArticleModeVenteAvance", false);
262
        SQLPreferences prefs = SQLPreferences.getMemCached(tableArticle.getDBRoot());
269
        SQLPreferences prefs = SQLPreferences.getMemCached(tableArticle.getDBRoot());
263
        final boolean createArticle = prefs.getBoolean(GestionArticleGlobalPreferencePanel.CREATE_ARTICLE_AUTO, true);
270
        final boolean createArticle = prefs.getBoolean(GestionArticleGlobalPreferencePanel.CREATE_ARTICLE_AUTO, true);
264
 
271
 
-
 
272
        if (createArticle) {
-
 
273
 
-
 
274
            SQLRowValues rowValsToFetch = new SQLRowValues(eltArticleTable.getTable());
-
 
275
            rowValsToFetch.putNulls(eltArticleTable.getTable().getFieldsName());
-
 
276
            SQLRowValuesListFetcher fetcher = SQLRowValuesListFetcher.create(rowValsToFetch);
-
 
277
            Where w = new Where(eltArticleTable.getTable().getField("CODE"), "!=", "");
-
 
278
            w = w.and(new Where(eltArticleTable.getTable().getField("NOM"), "!=", ""));
-
 
279
            Where w2 = new Where(eltArticleTable.getTable().getField("ID_ARTICLE"), "!=", tableArticle.getUndefinedID());
-
 
280
            w2 = w2.or(new Where(eltArticleTable.getTable().getField("ID_ARTICLE"), "!=", (Object) null));
-
 
281
            final List<SQLRowValues> resultNonAssigned = fetcher.fetch(w.and(w2).and(new Where(eltArticleTable.getTable().getForeignKeys(eltSource.getTable()).iterator().next(), "=", id)));
-
 
282
 
265
        // On récupére les articles qui composent la table
283
            // On récupére les articles qui composent la table
-
 
284
            // final List<SQLRow> listElts =
266
        final List<SQLRow> listElts = eltSource.getTable().getRow(id).getReferentRows(eltArticleTable.getTable());
285
            // eltSource.getTable().getRow(id).getReferentRows(eltArticleTable.getTable());
267
        final SQLRowValues rowArticle = new SQLRowValues(tableArticle);
286
            final SQLRowValues rowArticle = new SQLRowValues(tableArticle);
268
        final Set<SQLField> fields = tableArticle.getFields();
287
            final Set<SQLField> fields = tableArticle.getFields();
269
 
288
 
270
        for (final SQLRow rowElt : listElts) {
289
            for (final SQLRowAccessor rowElt : resultNonAssigned) {
271
            // final SQLRow foreignRow = rowElt.getForeignRow("ID_ARTICLE");
290
                // final SQLRow foreignRow = rowElt.getForeignRow("ID_ARTICLE");
272
            // if (foreignRow == null || foreignRow.isUndefined()) {
291
                // if (foreignRow == null || foreignRow.isUndefined()) {
273
            final Set<String> fieldsName = rowElt.getTable().getFieldsName();
292
                final Set<String> fieldsName = rowElt.getTable().getFieldsName();
274
            // on récupére l'article qui lui correspond
293
                // on récupére l'article qui lui correspond
275
 
294
 
Line 295... Line 314...
295
                    ExceptionHandler.handle("Erreur lors de l'affectation de l'article crée!", e);
314
                        ExceptionHandler.handle("Erreur lors de l'affectation de l'article crée!", e);
296
                }
315
                    }
297
            }
316
                }
298
            // ReferenceArticleSQLElement.getIdForCNM(rowArticle, true);
317
                // ReferenceArticleSQLElement.getIdForCNM(rowArticle, true);
299
        }
318
            }
-
 
319
        }
300
        // }
320
        // }
301
    }
321
    }
302
 
322
 
303
 
323
 
304
    public SQLRowValues getDefaultRowValues() {
324
    public SQLRowValues getDefaultRowValues() {
Line 478... Line 498...
478
            Set<String> fieldsFrom = m.getFieldsFrom();
498
            Set<String> fieldsFrom = m.getFieldsFrom();
479
            fieldsFrom.remove("POURCENT_REMISE");
499
            fieldsFrom.remove("POURCENT_REMISE");
480
            for (int i = eltsList.size() - 1; i >= 0; i--) {
500
            for (int i = eltsList.size() - 1; i >= 0; i--) {
481
                SQLRowAccessor sqlRowArticleChildElement = eltsList.get(i);
501
                SQLRowAccessor sqlRowArticleChildElement = eltsList.get(i);
482
                final SQLRowAccessor foreignArticleChild = sqlRowArticleChildElement.getForeign("ID_ARTICLE");
502
                final SQLRowAccessor foreignArticleChild = sqlRowArticleChildElement.getForeign("ID_ARTICLE");
-
 
503
                if (foreignArticleChild != null && !foreignArticleChild.isUndefined()) {
483
                final SQLRowValues row2Insert = new SQLRowValues(this.model.getDefaultRowValues());
504
                    final SQLRowValues row2Insert = new SQLRowValues(this.model.getDefaultRowValues());
484
 
505
 
485
                m.fillRowValues(foreignArticleChild, fieldsFrom, row2Insert);
506
                    m.fillRowValues(foreignArticleChild, fieldsFrom, row2Insert);
486
 
507
 
487
                // Fill prix total
508
                    // Fill prix total
Line 550... Line 571...
550
                    }
571
                        }
551
                }
572
                    }
552
                Map<String, Integer> allStyleByName = getSQLElement().getDirectory().getElement(StyleSQLElement.class).getAllStyleByName();
573
                    Map<String, Integer> allStyleByName = getSQLElement().getDirectory().getElement(StyleSQLElement.class).getAllStyleByName();
553
                row2Insert.put("ID_STYLE", allStyleByName.get("Composant"));
574
                    row2Insert.put("ID_STYLE", allStyleByName.get("Composant"));
554
                this.model.addRowAt(index + 1, row2Insert);
575
                    this.model.addRowAt(index + 1, row2Insert);
555
 
-
 
-
 
576
                }
556
            }
577
            }
557
        }
578
        }
558
    }
579
    }
559
 
580
 
560
    protected List<AbstractAction> getAdditionnalMouseAction(final int rowIndex) {
581
    protected List<AbstractAction> getAdditionnalMouseAction(final int rowIndex) {