OpenConcerto

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

svn://code.openconcerto.org/openconcerto

Rev

Rev 156 | Rev 177 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 156 Rev 174
Line 15... Line 15...
15
 
15
 
16
import org.openconcerto.erp.core.common.component.AdresseSQLComponent;
16
import org.openconcerto.erp.core.common.component.AdresseSQLComponent;
17
import org.openconcerto.erp.core.common.element.NumerotationAutoSQLElement;
17
import org.openconcerto.erp.core.common.element.NumerotationAutoSQLElement;
18
import org.openconcerto.erp.core.customerrelationship.customer.ui.AdresseClientItemTable;
18
import org.openconcerto.erp.core.customerrelationship.customer.ui.AdresseClientItemTable;
19
import org.openconcerto.erp.core.sales.product.element.ClientCodeArticleTable;
19
import org.openconcerto.erp.core.sales.product.element.ClientCodeArticleTable;
-
 
20
import org.openconcerto.erp.core.sales.product.ui.CustomerProductQtyPriceListTable;
20
import org.openconcerto.erp.preferences.ModeReglementDefautPrefPanel;
21
import org.openconcerto.erp.preferences.ModeReglementDefautPrefPanel;
21
import org.openconcerto.erp.utils.TM;
22
import org.openconcerto.erp.utils.TM;
22
import org.openconcerto.sql.Configuration;
23
import org.openconcerto.sql.Configuration;
23
import org.openconcerto.sql.element.ElementSQLObject;
24
import org.openconcerto.sql.element.ElementSQLObject;
24
import org.openconcerto.sql.element.GroupSQLComponent;
25
import org.openconcerto.sql.element.GroupSQLComponent;
Line 73... Line 74...
73
 
74
 
74
public class CustomerSQLComponent extends GroupSQLComponent {
75
public class CustomerSQLComponent extends GroupSQLComponent {
75
    private ContactItemTable table;
76
    private ContactItemTable table;
76
    private ClientCodeArticleTable tableCustomProduct;
77
    private ClientCodeArticleTable tableCustomProduct;
77
    private AdresseClientItemTable adresseTable = new AdresseClientItemTable();
78
    private AdresseClientItemTable adresseTable = new AdresseClientItemTable();
-
 
79
 
78
    private SQLTable contactTable = Configuration.getInstance().getDirectory().getElement("CONTACT").getTable();
80
    private SQLTable contactTable = Configuration.getInstance().getDirectory().getElement("CONTACT").getTable();
79
    private final SQLTable tableNum = getTable().getBase().getTable("NUMEROTATION_AUTO");
81
    private final SQLTable tableNum = getTable().getBase().getTable("NUMEROTATION_AUTO");
80
    private final JUniqueTextField code = new JUniqueTextField(20) {
82
    private final JUniqueTextField code = new JUniqueTextField(20) {
81
        @Override
83
        @Override
82
        public String getAutoRefreshNumber() {
84
        public String getAutoRefreshNumber() {
Line 86... Line 88...
86
                return null;
88
                return null;
87
            }
89
            }
88
        }
90
        }
89
    };
91
    };
90
 
92
 
-
 
93
    private CustomerProductQtyPriceListTable clienTarifTable = new CustomerProductQtyPriceListTable();
91
    private SQLRowValues defaultContactRowVals = new SQLRowValues(UndefinedRowValuesCache.getInstance().getDefaultRowValues(this.contactTable));
94
    private SQLRowValues defaultContactRowVals = new SQLRowValues(UndefinedRowValuesCache.getInstance().getDefaultRowValues(this.contactTable));
92
    private JCheckBox checkAdrLivraison, checkAdrFacturation;
95
    private JCheckBox checkAdrLivraison, checkAdrFacturation;
93
 
96
 
94
    public CustomerSQLComponent(SQLElement element) {
97
    public CustomerSQLComponent(SQLElement element) {
95
        super(element);
98
        super(element);
Line 165... Line 168...
165
            return new JDate(true);
168
            return new JDate(true);
166
        } else if (id.equals("customerrelationship.customer.contacts")) {
169
        } else if (id.equals("customerrelationship.customer.contacts")) {
167
            return this.table;
170
            return this.table;
168
        } else if (id.equals("customerrelationship.customer.customproduct")) {
171
        } else if (id.equals("customerrelationship.customer.customproduct")) {
169
            return this.tableCustomProduct;
172
            return this.tableCustomProduct;
-
 
173
        } else if (id.equals("customerrelationship.customer.customtarif")) {
-
 
174
            return this.clienTarifTable;
170
        } else if (id.equals("customerrelationship.customer.addresses")) {
175
        } else if (id.equals("customerrelationship.customer.addresses")) {
171
            return createAdressesComponent();
176
            return createAdressesComponent();
172
        } else if (id.equals("NOM")) {
177
        } else if (id.equals("NOM")) {
173
            return super.createEditor(id);
178
            return super.createEditor(id);
174
        }
179
        }
Line 241... Line 246...
241
    @Override
246
    @Override
242
    public void update() {
247
    public void update() {
243
        super.update();
248
        super.update();
244
        final int selectedID = getSelectedID();
249
        final int selectedID = getSelectedID();
245
        this.table.updateField("ID_CLIENT", selectedID);
250
        this.table.updateField("ID_CLIENT", selectedID);
-
 
251
        this.clienTarifTable.updateField("ID_CLIENT", selectedID);
246
        this.tableCustomProduct.updateField("ID_CLIENT", selectedID);
252
        this.tableCustomProduct.updateField("ID_CLIENT", selectedID);
247
        this.adresseTable.updateField("ID_CLIENT", selectedID);
253
        this.adresseTable.updateField("ID_CLIENT", selectedID);
248
    }
254
    }
249
 
255
 
250
    @Override
256
    @Override
Line 252... Line 258...
252
        super.select(r);
258
        super.select(r);
253
        this.checkAdrLivraison.setSelected(r == null || !r.getFields().contains("ID_ADRESSE_L") || r.isForeignEmpty("ID_ADRESSE_L"));
259
        this.checkAdrLivraison.setSelected(r == null || !r.getFields().contains("ID_ADRESSE_L") || r.isForeignEmpty("ID_ADRESSE_L"));
254
        this.checkAdrFacturation.setSelected(r == null || !r.getFields().contains("ID_ADRESSE_F") || r.isForeignEmpty("ID_ADRESSE_F"));
260
        this.checkAdrFacturation.setSelected(r == null || !r.getFields().contains("ID_ADRESSE_F") || r.isForeignEmpty("ID_ADRESSE_F"));
255
        if (r != null) {
261
        if (r != null) {
256
            this.table.insertFrom("ID_CLIENT", r.asRowValues());
262
            this.table.insertFrom("ID_CLIENT", r.asRowValues());
-
 
263
            this.clienTarifTable.insertFrom("ID_CLIENT", r.asRowValues());
257
            this.tableCustomProduct.insertFrom("ID_CLIENT", r.asRowValues());
264
            this.tableCustomProduct.insertFrom("ID_CLIENT", r.asRowValues());
258
            this.adresseTable.insertFrom("ID_CLIENT", r.asRowValues());
265
            this.adresseTable.insertFrom("ID_CLIENT", r.asRowValues());
259
        }
266
        }
260
    }
267
    }
261
 
268
 
Line 292... Line 299...
292
            }
299
            }
293
        } else {
300
        } else {
294
            id = super.insert(order);
301
            id = super.insert(order);
295
            this.table.updateField("ID_CLIENT", id);
302
            this.table.updateField("ID_CLIENT", id);
296
            this.tableCustomProduct.updateField("ID_CLIENT", id);
303
            this.tableCustomProduct.updateField("ID_CLIENT", id);
-
 
304
            this.clienTarifTable.updateField("ID_CLIENT", id);
297
            this.adresseTable.updateField("ID_CLIENT", id);
305
            this.adresseTable.updateField("ID_CLIENT", id);
298
            if (NumerotationAutoSQLElement.getNextNumero(getElement().getClass()).equalsIgnoreCase(this.code.getText().trim())) {
306
            if (NumerotationAutoSQLElement.getNextNumero(getElement().getClass()).equalsIgnoreCase(this.code.getText().trim())) {
299
                SQLRowValues rowVals = new SQLRowValues(this.tableNum);
307
                SQLRowValues rowVals = new SQLRowValues(this.tableNum);
300
                final SQLRow rowNumAuto = this.tableNum.getRow(2);
308
                final SQLRow rowNumAuto = this.tableNum.getRow(2);
301
                if (rowNumAuto.getObject("CLIENT_START") != null) {
309
                if (rowNumAuto.getObject("CLIENT_START") != null) {