OpenConcerto

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

svn://code.openconcerto.org/openconcerto

Rev

Rev 177 | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 177 Rev 180
Line 16... Line 16...
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.finance.accounting.element.ComptePCESQLElement;
19
import org.openconcerto.erp.core.finance.accounting.element.ComptePCESQLElement;
20
import org.openconcerto.erp.core.sales.product.element.ClientCodeArticleTable;
20
import org.openconcerto.erp.core.sales.product.element.ClientCodeArticleTable;
-
 
21
import org.openconcerto.erp.core.sales.product.ui.CustomerProductFamilyQtyPriceListTable;
21
import org.openconcerto.erp.core.sales.product.ui.CustomerProductQtyPriceListTable;
22
import org.openconcerto.erp.core.sales.product.ui.CustomerProductQtyPriceListTable;
22
import org.openconcerto.erp.preferences.GestionCommercialeGlobalPreferencePanel;
23
import org.openconcerto.erp.preferences.GestionCommercialeGlobalPreferencePanel;
23
import org.openconcerto.erp.preferences.ModeReglementDefautPrefPanel;
24
import org.openconcerto.erp.preferences.ModeReglementDefautPrefPanel;
24
import org.openconcerto.erp.utils.TM;
25
import org.openconcerto.erp.utils.TM;
25
import org.openconcerto.sql.Configuration;
26
import org.openconcerto.sql.Configuration;
Line 40... Line 41...
40
import org.openconcerto.sql.ui.textmenu.TextFieldWithMenuItemsTableFetcher;
41
import org.openconcerto.sql.ui.textmenu.TextFieldWithMenuItemsTableFetcher;
41
import org.openconcerto.sql.ui.textmenu.TextFieldWithWebBrowsing;
42
import org.openconcerto.sql.ui.textmenu.TextFieldWithWebBrowsing;
42
import org.openconcerto.sql.view.EditFrame;
43
import org.openconcerto.sql.view.EditFrame;
43
import org.openconcerto.sql.view.EditPanel.EditMode;
44
import org.openconcerto.sql.view.EditPanel.EditMode;
44
import org.openconcerto.sql.view.IListFrame;
45
import org.openconcerto.sql.view.IListFrame;
-
 
46
import org.openconcerto.sql.view.IListPanel;
45
import org.openconcerto.sql.view.ListeAddPanel;
47
import org.openconcerto.sql.view.ListeAddPanel;
-
 
48
import org.openconcerto.sql.view.list.IListe;
-
 
49
import org.openconcerto.sql.view.list.SQLTableModelSource;
46
import org.openconcerto.ui.DefaultGridBagConstraints;
50
import org.openconcerto.ui.DefaultGridBagConstraints;
47
import org.openconcerto.ui.FrameUtil;
51
import org.openconcerto.ui.FrameUtil;
48
import org.openconcerto.ui.JDate;
52
import org.openconcerto.ui.JDate;
49
import org.openconcerto.ui.JLabelBold;
53
import org.openconcerto.ui.JLabelBold;
50
import org.openconcerto.ui.component.ComboLockedMode;
54
import org.openconcerto.ui.component.ComboLockedMode;
Line 63... Line 67...
63
import java.util.HashSet;
67
import java.util.HashSet;
64
import java.util.Set;
68
import java.util.Set;
65
 
69
 
66
import javax.swing.AbstractAction;
70
import javax.swing.AbstractAction;
67
import javax.swing.Icon;
71
import javax.swing.Icon;
-
 
72
import javax.swing.JButton;
68
import javax.swing.JCheckBox;
73
import javax.swing.JCheckBox;
69
import javax.swing.JComponent;
74
import javax.swing.JComponent;
70
import javax.swing.JLabel;
75
import javax.swing.JLabel;
71
import javax.swing.JOptionPane;
76
import javax.swing.JOptionPane;
72
import javax.swing.JPanel;
77
import javax.swing.JPanel;
Line 93... Line 98...
93
            }
98
            }
94
        }
99
        }
95
    };
100
    };
96
 
101
 
97
    private CustomerProductQtyPriceListTable clienTarifTable = new CustomerProductQtyPriceListTable();
102
    private CustomerProductQtyPriceListTable clienTarifTable = new CustomerProductQtyPriceListTable();
-
 
103
    private CustomerProductFamilyQtyPriceListTable clienFamilleTarifTable = new CustomerProductFamilyQtyPriceListTable();
98
    private SQLRowValues defaultContactRowVals = new SQLRowValues(UndefinedRowValuesCache.getInstance().getDefaultRowValues(this.contactTable));
104
    private SQLRowValues defaultContactRowVals = new SQLRowValues(UndefinedRowValuesCache.getInstance().getDefaultRowValues(this.contactTable));
99
    private JCheckBox checkAdrLivraison, checkAdrFacturation;
105
    private JCheckBox checkAdrLivraison, checkAdrFacturation;
-
 
106
    private IListPanel agencePanel;
100
 
107
 
101
    public CustomerSQLComponent(SQLElement element) {
108
    public CustomerSQLComponent(SQLElement element) {
102
        super(element);
109
        super(element);
103
        this.table = new ContactItemTable(this.defaultContactRowVals);
110
        this.table = new ContactItemTable(this.defaultContactRowVals);
104
        this.tableCustomProduct = new ClientCodeArticleTable();
111
        this.tableCustomProduct = new ClientCodeArticleTable();
Line 170... Line 177...
170
            return new JTextField(20);
177
            return new JTextField(20);
171
        } else if (id.equals("DATE")) {
178
        } else if (id.equals("DATE")) {
172
            return new JDate(true);
179
            return new JDate(true);
173
        } else if (id.equals("customerrelationship.customer.contacts")) {
180
        } else if (id.equals("customerrelationship.customer.contacts")) {
174
            return this.table;
181
            return this.table;
-
 
182
        } else if (id.equals("customerrelationship.customer.agencies")) {
-
 
183
            SQLElement elementAgence = getElement().getDirectory().getElement("AGENCE");
-
 
184
            SQLTableModelSource source = elementAgence.createTableSource(Where.FALSE);
-
 
185
            this.agencePanel = new ListeAddPanel(elementAgence, new IListe(source)) {
-
 
186
                @Override
-
 
187
                protected void handleAction(JButton source, ActionEvent evt) {
-
 
188
                    if (source == this.buttonAjouter) {
-
 
189
                        if (getMode() == Mode.MODIFICATION && getSelectedID() != SQLRow.NONEXISTANT_ID) {
-
 
190
                            SQLRowValues rowValsAgency = new SQLRowValues(elementAgence.getTable());
-
 
191
                            rowValsAgency.put("ID_CLIENT", getSelectedID());
-
 
192
                            this.getCreateFrame().getSQLComponent().select(rowValsAgency);
-
 
193
                        }
-
 
194
                        FrameUtil.show(this.getCreateFrame());
-
 
195
                    } else {
-
 
196
                        super.handleAction(source, evt);
-
 
197
                    }
-
 
198
                }
-
 
199
            };
-
 
200
            if (getMode() == Mode.INSERTION || getMode() == Mode.READ_ONLY) {
-
 
201
                this.agencePanel.getButtonAdd().setEnabled(false);
-
 
202
            }
-
 
203
            return this.agencePanel;
175
        } else if (id.equals("customerrelationship.customer.customproduct")) {
204
        } else if (id.equals("customerrelationship.customer.customproduct")) {
176
            return this.tableCustomProduct;
205
            return this.tableCustomProduct;
177
        } else if (id.equals("customerrelationship.customer.customtarif")) {
206
        } else if (id.equals("customerrelationship.customer.customtarif")) {
178
            return this.clienTarifTable;
207
            return this.clienTarifTable;
-
 
208
        } else if (id.equals("customerrelationship.customer.customfamilytarif")) {
-
 
209
            return this.clienFamilleTarifTable;
179
        } else if (id.equals("customerrelationship.customer.addresses")) {
210
        } else if (id.equals("customerrelationship.customer.addresses")) {
180
            return createAdressesComponent();
211
            return createAdressesComponent();
181
        } else if (id.equals("NOM")) {
212
        } else if (id.equals("NOM")) {
182
            return super.createEditor(id);
213
            return super.createEditor(id);
183
        }
214
        }
Line 251... Line 282...
251
    public void update() {
282
    public void update() {
252
        super.update();
283
        super.update();
253
        final int selectedID = getSelectedID();
284
        final int selectedID = getSelectedID();
254
        this.table.updateField("ID_CLIENT", selectedID);
285
        this.table.updateField("ID_CLIENT", selectedID);
255
        this.clienTarifTable.updateField("ID_CLIENT", selectedID);
286
        this.clienTarifTable.updateField("ID_CLIENT", selectedID);
-
 
287
        this.clienFamilleTarifTable.updateField("ID_CLIENT", selectedID);
256
        this.tableCustomProduct.updateField("ID_CLIENT", selectedID);
288
        this.tableCustomProduct.updateField("ID_CLIENT", selectedID);
257
        this.adresseTable.updateField("ID_CLIENT", selectedID);
289
        this.adresseTable.updateField("ID_CLIENT", selectedID);
258
    }
290
    }
259
 
291
 
260
    @Override
292
    @Override
Line 263... Line 295...
263
        this.checkAdrLivraison.setSelected(r == null || !r.getFields().contains("ID_ADRESSE_L") || r.isForeignEmpty("ID_ADRESSE_L"));
295
        this.checkAdrLivraison.setSelected(r == null || !r.getFields().contains("ID_ADRESSE_L") || r.isForeignEmpty("ID_ADRESSE_L"));
264
        this.checkAdrFacturation.setSelected(r == null || !r.getFields().contains("ID_ADRESSE_F") || r.isForeignEmpty("ID_ADRESSE_F"));
296
        this.checkAdrFacturation.setSelected(r == null || !r.getFields().contains("ID_ADRESSE_F") || r.isForeignEmpty("ID_ADRESSE_F"));
265
        if (r != null) {
297
        if (r != null) {
266
            this.table.insertFrom("ID_CLIENT", r.asRowValues());
298
            this.table.insertFrom("ID_CLIENT", r.asRowValues());
267
            this.clienTarifTable.insertFrom("ID_CLIENT", r.asRowValues());
299
            this.clienTarifTable.insertFrom("ID_CLIENT", r.asRowValues());
-
 
300
            this.clienFamilleTarifTable.insertFrom("ID_CLIENT", r.asRowValues());
268
            this.tableCustomProduct.insertFrom("ID_CLIENT", r.asRowValues());
301
            this.tableCustomProduct.insertFrom("ID_CLIENT", r.asRowValues());
269
            this.adresseTable.insertFrom("ID_CLIENT", r.asRowValues());
302
            this.adresseTable.insertFrom("ID_CLIENT", r.asRowValues());
270
        }
303
        }
-
 
304
        if (r != null && r.hasID()) {
-
 
305
            this.agencePanel.getListe().getRequest().setWhere(new Where(this.agencePanel.getListe().getRequest().getPrimaryTable().getField("ID_CLIENT"), "=", r.getID()));
-
 
306
        } else {
-
 
307
            this.agencePanel.getListe().getRequest().setWhere(Where.FALSE);
-
 
308
        }
271
    }
309
    }
272
 
310
 
273
    @Override
311
    @Override
274
    public int insert(SQLRow order) {
312
    public int insert(SQLRow order) {
275
        int id;
313
        int id;
Line 302... Line 340...
302
                frame.getPanel().setAlwaysVisible(true);
340
                frame.getPanel().setAlwaysVisible(true);
303
            }
341
            }
304
        } else {
342
        } else {
305
            id = super.insert(order);
343
            id = super.insert(order);
306
            this.table.updateField("ID_CLIENT", id);
344
            this.table.updateField("ID_CLIENT", id);
-
 
345
            this.clienTarifTable.updateField("ID_CLIENT", id);
-
 
346
            this.clienFamilleTarifTable.updateField("ID_CLIENT", id);
307
            this.tableCustomProduct.updateField("ID_CLIENT", id);
347
            this.tableCustomProduct.updateField("ID_CLIENT", id);
308
            this.clienTarifTable.updateField("ID_CLIENT", id);
348
            this.clienTarifTable.updateField("ID_CLIENT", id);
309
            this.adresseTable.updateField("ID_CLIENT", id);
349
            this.adresseTable.updateField("ID_CLIENT", id);
310
            if (NumerotationAutoSQLElement.getNextNumero(getElement().getClass()).equalsIgnoreCase(this.code.getText().trim())) {
350
            if (NumerotationAutoSQLElement.getNextNumero(getElement().getClass()).equalsIgnoreCase(this.code.getText().trim())) {
311
                SQLRowValues rowVals = new SQLRowValues(this.tableNum);
351
                SQLRowValues rowVals = new SQLRowValues(this.tableNum);