OpenConcerto

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

svn://code.openconcerto.org/openconcerto

Rev

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

Rev 144 Rev 182
Line 1... Line 1...
1
/*
1
/*
2
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
2
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
3
 * 
3
 * 
4
 * Copyright 2011 OpenConcerto, by ILM Informatique. All rights reserved.
4
 * Copyright 2011-2019 OpenConcerto, by ILM Informatique. All rights reserved.
5
 * 
5
 * 
6
 * The contents of this file are subject to the terms of the GNU General Public License Version 3
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
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
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.
9
 * language governing permissions and limitations under the License.
Line 21... Line 21...
21
import org.openconcerto.erp.core.common.element.NumerotationAutoSQLElement;
21
import org.openconcerto.erp.core.common.element.NumerotationAutoSQLElement;
22
import org.openconcerto.erp.panel.PanelOOSQLComponent;
22
import org.openconcerto.erp.panel.PanelOOSQLComponent;
23
import org.openconcerto.sql.Configuration;
23
import org.openconcerto.sql.Configuration;
24
import org.openconcerto.sql.element.ElementSQLObject;
24
import org.openconcerto.sql.element.ElementSQLObject;
25
import org.openconcerto.sql.element.SQLElement;
25
import org.openconcerto.sql.element.SQLElement;
-
 
26
import org.openconcerto.sql.model.SQLBackgroundTableCache;
26
import org.openconcerto.sql.model.SQLRow;
27
import org.openconcerto.sql.model.SQLRow;
27
import org.openconcerto.sql.model.SQLRowAccessor;
28
import org.openconcerto.sql.model.SQLRowAccessor;
28
import org.openconcerto.sql.model.SQLRowValues;
29
import org.openconcerto.sql.model.SQLRowValues;
29
import org.openconcerto.sql.model.SQLTable;
30
import org.openconcerto.sql.model.SQLTable;
30
import org.openconcerto.sql.sqlobject.ElementComboBox;
31
import org.openconcerto.sql.sqlobject.ElementComboBox;
31
import org.openconcerto.sql.sqlobject.JUniqueTextField;
32
import org.openconcerto.sql.sqlobject.JUniqueTextField;
32
import org.openconcerto.sql.ui.RadioButtons;
33
import org.openconcerto.sql.ui.RadioButtons;
-
 
34
import org.openconcerto.sql.users.UserManager;
33
import org.openconcerto.sql.view.EditFrame;
35
import org.openconcerto.sql.view.EditFrame;
34
import org.openconcerto.sql.view.list.RowValuesTable;
36
import org.openconcerto.sql.view.list.RowValuesTable;
35
import org.openconcerto.ui.DefaultGridBagConstraints;
37
import org.openconcerto.ui.DefaultGridBagConstraints;
36
import org.openconcerto.ui.FormLayouter;
38
import org.openconcerto.ui.FormLayouter;
37
import org.openconcerto.ui.JDate;
39
import org.openconcerto.ui.JDate;
Line 181... Line 183...
181
        // c.gridx++;
183
        // c.gridx++;
182
        // c.weightx = 1;
184
        // c.weightx = 1;
183
        // this.add(boxEtat, c);
185
        // this.add(boxEtat, c);
184
        // this.addView(boxEtat, "ID_ETAT_DEMANDE_PRIX");
186
        // this.addView(boxEtat, "ID_ETAT_DEMANDE_PRIX");
185
 
187
 
-
 
188
        c.gridx = 0;
-
 
189
        c.gridy++;
-
 
190
        c.weightx = 0;
-
 
191
        this.add(new JLabel(getLabelFor("ID_COMMERCIAL"), SwingConstants.RIGHT), c);
-
 
192
        c.gridx++;
-
 
193
        c.weightx = 1;
-
 
194
        final ElementComboBox boxCom = new ElementComboBox();
-
 
195
        this.add(boxCom, c);
-
 
196
        this.addView(boxCom, "ID_COMMERCIAL", REQ);
-
 
197
 
186
        c.weightx = 0;
198
        c.weightx = 0;
187
        c.gridheight = 1;
199
        c.gridheight = 1;
188
        c.gridx = 0;
200
        c.gridx = 0;
189
        c.gridy++;
201
        c.gridy++;
190
        c.anchor = GridBagConstraints.WEST;
202
        c.anchor = GridBagConstraints.WEST;
Line 468... Line 480...
468
            this.table.updateField("ID_DEMANDE_PRIX", idCommande);
480
            this.table.updateField("ID_DEMANDE_PRIX", idCommande);
469
            // Création des articles
481
            // Création des articles
470
            // this.table.createArticle(idCommande, this.getElement());
482
            // this.table.createArticle(idCommande, this.getElement());
471
 
483
 
472
            // generation du document
484
            // generation du document
-
 
485
            final SQLRow row = getTable().getRow(idCommande);
473
            DemandePrixSheetXML sheet = new DemandePrixSheetXML(getTable().getRow(idCommande));
486
            DemandePrixSheetXML sheet = new DemandePrixSheetXML(row);
474
            sheet.createDocumentAsynchronous();
487
            sheet.createDocumentAsynchronous();
475
            sheet.showPrintAndExportAsynchronous(true, false, true);
488
            sheet.showPrintAndExportAsynchronous(true, false, true, getElement(), row);
476
 
489
 
477
            // incrémentation du numéro auto
490
            // incrémentation du numéro auto
478
            if (NumerotationAutoSQLElement.getNextNumero(DemandePrixSQLElement.class).equalsIgnoreCase(this.field.getText().trim())) {
491
            if (NumerotationAutoSQLElement.getNextNumero(DemandePrixSQLElement.class).equalsIgnoreCase(this.field.getText().trim())) {
479
                SQLTable tableNum = Configuration.getInstance().getRoot().findTable("NUMEROTATION_AUTO");
492
                SQLTable tableNum = Configuration.getInstance().getRoot().findTable("NUMEROTATION_AUTO");
480
                SQLRowValues rowVals = new SQLRowValues(tableNum);
493
                SQLRowValues rowVals = new SQLRowValues(tableNum);
Line 520... Line 533...
520
        // this.table.createArticle(getSelectedID(), this.getElement());
533
        // this.table.createArticle(getSelectedID(), this.getElement());
521
        this.table.updateField("ID_DEMANDE_PRIX", getSelectedID());
534
        this.table.updateField("ID_DEMANDE_PRIX", getSelectedID());
522
        DemandeAchatItemSQLElement elt = getElement().getDirectory().getElement(DemandeAchatItemSQLElement.class);
535
        DemandeAchatItemSQLElement elt = getElement().getDirectory().getElement(DemandeAchatItemSQLElement.class);
523
        elt.updateStatus(getTable(), getTable().getTable("DEMANDE_PRIX_ELEMENT"), getSelectedID());
536
        elt.updateStatus(getTable(), getTable().getTable("DEMANDE_PRIX_ELEMENT"), getSelectedID());
524
 
537
 
-
 
538
        final SQLRow row = getTable().getRow(getSelectedID());
525
        DemandePrixSheetXML sheet = new DemandePrixSheetXML(getTable().getRow(getSelectedID()));
539
        DemandePrixSheetXML sheet = new DemandePrixSheetXML(row);
526
        sheet.createDocumentAsynchronous();
540
        sheet.createDocumentAsynchronous();
527
        sheet.showPrintAndExportAsynchronous(true, false, true);
541
        sheet.showPrintAndExportAsynchronous(true, false, true, getElement(), row);
528
 
542
 
529
    }
543
    }
530
 
544
 
531
    @Override
545
    @Override
532
    protected SQLRowValues createDefaults() {
546
    protected SQLRowValues createDefaults() {
533
        SQLRowValues rowVals = new SQLRowValues(getTable());
547
        SQLRowValues rowVals = new SQLRowValues(getTable());
534
        rowVals.put("NUMERO", NumerotationAutoSQLElement.getNextNumero(DemandePrixSQLElement.class));
548
        rowVals.put("NUMERO", NumerotationAutoSQLElement.getNextNumero(DemandePrixSQLElement.class));
-
 
549
        SQLElement eltComm = getElement().getForeignElement("ID_COMMERCIAL");
-
 
550
        int idUser = UserManager.getInstance().getCurrentUserID();
-
 
551
 
-
 
552
        SQLRow rowsComm = SQLBackgroundTableCache.getInstance().getCacheForTable(eltComm.getTable()).getFirstRowContains(idUser, eltComm.getTable().getField("ID_USER_COMMON"));
-
 
553
 
-
 
554
        if (rowsComm != null) {
-
 
555
            rowVals.put("ID_COMMERCIAL", rowsComm.getID());
-
 
556
        }
-
 
557
 
535
        if (getTable().getUndefinedID() == SQLRow.NONEXISTANT_ID) {
558
        if (getTable().getUndefinedID() == SQLRow.NONEXISTANT_ID) {
536
            rowVals.put("ID_ETAT_DEMANDE_PRIX", EtatDemandePrixSQLElement.EN_ATTENTE);
559
            rowVals.put("ID_ETAT_DEMANDE_PRIX", EtatDemandePrixSQLElement.EN_ATTENTE);
537
        } else {
560
        } else {
538
            SQLRow rowUndef = getTable().getRow(getTable().getUndefinedID());
561
            SQLRow rowUndef = getTable().getRow(getTable().getUndefinedID());
539
            SQLRow foreign = rowUndef.getForeign("ID_ETAT_DEMANDE_PRIX");
562
            SQLRow foreign = rowUndef.getForeign("ID_ETAT_DEMANDE_PRIX");