OpenConcerto

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

svn://code.openconcerto.org/openconcerto

Rev

Rev 180 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
41 ilm 1
/*
2
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
3
 *
182 ilm 4
 * Copyright 2011-2019 OpenConcerto, by ILM Informatique. All rights reserved.
41 ilm 5
 *
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
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.
10
 *
11
 * When distributing the software, include this License Header Notice in each file.
12
 */
13
 
14
 /*
15
 * Créé le 20 janv. 2012
16
 */
17
package org.openconcerto.erp.core.supplychain.supplier.component;
18
 
19
import org.openconcerto.erp.config.ComptaPropsConfiguration;
63 ilm 20
import org.openconcerto.erp.core.common.element.ComptaSQLConfElement;
41 ilm 21
import org.openconcerto.erp.core.customerrelationship.customer.element.ContactItemTable;
22
import org.openconcerto.erp.core.finance.accounting.element.ComptePCESQLElement;
23
import org.openconcerto.erp.model.ISQLCompteSelector;
24
import org.openconcerto.erp.preferences.ModeReglementDefautPrefPanel;
25
import org.openconcerto.sql.Configuration;
26
import org.openconcerto.sql.element.BaseSQLComponent;
27
import org.openconcerto.sql.element.ElementSQLObject;
28
import org.openconcerto.sql.element.SQLElement;
61 ilm 29
import org.openconcerto.sql.model.SQLBackgroundTableCache;
41 ilm 30
import org.openconcerto.sql.model.SQLBase;
31
import org.openconcerto.sql.model.SQLRow;
32
import org.openconcerto.sql.model.SQLRowAccessor;
33
import org.openconcerto.sql.model.SQLRowValues;
34
import org.openconcerto.sql.model.SQLTable;
35
import org.openconcerto.sql.model.UndefinedRowValuesCache;
36
import org.openconcerto.sql.sqlobject.ElementComboBox;
37
import org.openconcerto.sql.sqlobject.SQLTextCombo;
38
import org.openconcerto.ui.DefaultGridBagConstraints;
39
import org.openconcerto.ui.FormLayouter;
40
import org.openconcerto.ui.TitledSeparator;
41
import org.openconcerto.ui.component.ITextArea;
93 ilm 42
import org.openconcerto.ui.component.InteractionMode;
41 ilm 43
 
94 ilm 44
import java.awt.Dimension;
45
import java.awt.GridBagConstraints;
46
import java.awt.GridBagLayout;
47
import java.awt.event.ActionListener;
48
import java.sql.SQLException;
49
 
50
import javax.swing.JCheckBox;
51
import javax.swing.JLabel;
52
import javax.swing.JPanel;
53
import javax.swing.JScrollPane;
54
import javax.swing.JTabbedPane;
55
import javax.swing.JTextField;
56
import javax.swing.SwingConstants;
57
 
41 ilm 58
public class FournisseurSQLComponent extends BaseSQLComponent {
59
 
60
    public FournisseurSQLComponent(SQLElement elt) {
61
        super(elt);
62
    }
63
 
64
    JCheckBox checkEnlevement;
65
    ElementSQLObject comp2;
66
    TitledSeparator sep2;
67
    private ContactItemTable table;
68
    private SQLTable contactTable = Configuration.getInstance().getDirectory().getElement("CONTACT_FOURNISSEUR").getTable();
69
    private SQLRowValues defaultContactRowVals = new SQLRowValues(UndefinedRowValuesCache.getInstance().getDefaultRowValues(this.contactTable));
70
 
71
    public void addViews() {
72
        this.setLayout(new GridBagLayout());
73
        final GridBagConstraints c = new DefaultGridBagConstraints();
74
 
75
        // Code
80 ilm 76
        JLabel labelCode = new JLabel("Code", SwingConstants.RIGHT);
41 ilm 77
        JTextField textCode = new JTextField();
78
        c.gridx = 0;
79
        c.gridy++;
80
        c.weightx = 0;
81
        c.weighty = 0;
82
        this.add(labelCode, c);
83
        c.gridx++;
84
        c.weightx = 0.5;
85
        this.add(textCode, c);
86
 
87
        c.gridy++;
88
        c.gridx = 0;
89
        c.weightx = 0;
90
        // Raison sociale
80 ilm 91
        JLabel labelRS = new JLabel("Forme juridique", SwingConstants.RIGHT);
41 ilm 92
        SQLTextCombo textType = new SQLTextCombo();
93
        JTextField textNom = new JTextField();
94
 
95
        this.add(labelRS, c);
96
        c.gridx++;
97
        c.weightx = 0.5;
98
        this.add(textType, c);
99
 
100
        // Tel
80 ilm 101
        JLabel labelTel = new JLabel(getLabelFor("TEL"), SwingConstants.RIGHT);
102
        JTextField textTel = new JTextField(15);
41 ilm 103
        c.gridx++;
104
        c.weightx = 0;
105
        c.weighty = 0;
80 ilm 106
 
41 ilm 107
        this.add(labelTel, c);
108
        c.gridx++;
80 ilm 109
 
41 ilm 110
        c.weightx = 0.5;
111
        this.add(textTel, c);
112
 
113
        // Nom
114
        c.gridy++;
115
        c.gridx = 0;
116
        c.weightx = 0;
117
        String fieldNom = "NOM";
118
        if (getTable().contains("NOM_SOCIETE")) {
119
            fieldNom = "NOM_SOCIETE";
120
        }
80 ilm 121
        this.add(new JLabel(getLabelFor(fieldNom), SwingConstants.RIGHT), c);
41 ilm 122
        c.gridx++;
80 ilm 123
 
41 ilm 124
        c.weightx = 0.5;
125
        this.add(textNom, c);
126
        this.addRequiredSQLObject(textNom, fieldNom);
127
 
128
        // Fax
129
        c.gridx++;
130
        c.weightx = 0;
80 ilm 131
        this.add(new JLabel(getLabelFor("FAX"), SwingConstants.RIGHT), c);
41 ilm 132
        c.gridx++;
80 ilm 133
 
41 ilm 134
        c.weightx = 0.5;
135
        JTextField textFax = new JTextField();
136
        this.add(textFax, c);
137
 
138
        // Mail
139
        c.gridy++;
140
        c.gridx = 0;
141
        c.weightx = 0;
80 ilm 142
        c.gridwidth = 1;
143
        this.add(new JLabel(getLabelFor("MAIL"), SwingConstants.RIGHT), c);
41 ilm 144
        c.gridx++;
80 ilm 145
 
41 ilm 146
        c.weightx = 0.5;
147
        JTextField textMail = new JTextField();
148
        this.add(textMail, c);
149
        this.addView(textMail, "MAIL");
150
 
151
        // Tel P
152
        c.gridx++;
153
        c.weightx = 0;
80 ilm 154
 
155
        this.add(new JLabel(getLabelFor("TEL_P"), SwingConstants.RIGHT), c);
41 ilm 156
        c.gridx++;
157
        c.weightx = 0.5;
158
        JTextField textTelP = new JTextField();
159
        this.add(textTelP, c);
160
        this.addView(textTelP, "TEL_P");
161
        // Langue
162
        c.gridy++;
163
        c.gridx = 0;
164
        c.weightx = 0;
80 ilm 165
        this.add(new JLabel(getLabelFor("ID_LANGUE"), SwingConstants.RIGHT), c);
41 ilm 166
        c.gridx++;
167
        c.weightx = 0.5;
168
        ElementComboBox langue = new ElementComboBox(true, 35);
169
        this.add(langue, c);
170
        this.addView(langue, "ID_LANGUE");
171
 
172
        // Resp
173
        c.gridx++;
174
        c.weightx = 0;
80 ilm 175
        this.add(new JLabel(getLabelFor("RESPONSABLE"), SwingConstants.RIGHT), c);
41 ilm 176
        c.gridx++;
177
        c.weightx = 0.5;
178
        JTextField textResp = new JTextField();
179
        this.add(textResp, c);
180
        this.addView(textResp, "RESPONSABLE");
144 ilm 181
 
182
        // Siret
183
        c.gridy++;
184
        c.gridx = 0;
185
        c.weightx = 0;
186
        this.add(new JLabel(getLabelFor("SIRET"), SwingConstants.RIGHT), c);
187
        c.gridx++;
188
        c.weightx = 0.5;
189
        JTextField textSiret = new JTextField();
190
        ;
191
        this.add(textSiret, c);
192
        this.addView(textSiret, "SIRET");
193
 
194
        // tva
195
        c.gridx++;
196
        c.weightx = 0;
197
        this.add(new JLabel(getLabelFor("NUMERO_TVA"), SwingConstants.RIGHT), c);
198
        c.gridx++;
199
        c.weightx = 0.5;
200
        JTextField textNumeroTVA = new JTextField();
201
        this.add(textNumeroTVA, c);
202
        this.addView(textNumeroTVA, "NUMERO_TVA");
203
 
80 ilm 204
        c.gridx = 1;
41 ilm 205
        c.gridy++;
206
        JCheckBox boxUE = new JCheckBox(getLabelFor("UE"));
207
        this.add(boxUE, c);
208
 
83 ilm 209
        if (getTable().contains("ID_DEVISE")) {
210
            c.gridx++;
211
            c.weightx = 0;
212
            this.add(new JLabel(getLabelFor("ID_DEVISE"), SwingConstants.RIGHT), c);
213
            c.gridx++;
214
            c.weightx = 0.5;
215
            ElementComboBox devise = new ElementComboBox(true, 35);
216
            this.add(devise, c);
217
            this.addView(devise, "ID_DEVISE");
218
        }
219
 
182 ilm 220
        if (getTable().contains("CONDITIONS_PORT")) {
221
            // Conditions frais port
222
            c.gridy++;
223
            c.gridx = 0;
224
            c.weightx = 0;
225
            this.add(new JLabel(getLabelFor("CONDITIONS_PORT"), SwingConstants.RIGHT), c);
226
            c.gridx++;
227
            c.weightx = 0.5;
228
            JTextField textCondPort = new JTextField();
229
 
230
            this.add(textCondPort, c);
231
            this.addView(textCondPort, "CONDITIONS_PORT");
232
        }
233
 
94 ilm 234
        if (getTable().contains("ALG_REGISTRE")) {
235
            c.gridy++;
236
            c.gridx = 0;
237
            c.weightx = 0;
238
            this.add(new JLabel(getLabelFor("ALG_REGISTRE"), SwingConstants.RIGHT), c);
239
            c.gridx++;
240
            c.weightx = 1;
241
            JTextField fieldRegistre = new JTextField(20);
242
            this.add(fieldRegistre, c);
243
            this.addView(fieldRegistre, "ALG_REGISTRE");
244
 
245
            c.gridx++;
246
            c.weightx = 0;
247
            this.add(new JLabel(getLabelFor("ALG_MATRICULE"), SwingConstants.RIGHT), c);
248
            c.gridx++;
249
            c.weightx = 1;
250
            JTextField fieldMatricule = new JTextField(20);
251
            this.add(fieldMatricule, c);
252
            this.addView(fieldMatricule, "ALG_MATRICULE");
253
 
254
            c.gridy++;
255
            c.gridx = 0;
256
            c.weightx = 0;
257
            this.add(new JLabel(getLabelFor("ALG_ARTICLE"), SwingConstants.RIGHT), c);
258
            c.gridx++;
259
            c.weightx = 1;
260
            JTextField fieldArticle = new JTextField(20);
261
            this.add(fieldArticle, c);
262
            this.addView(fieldArticle, "ALG_ARTICLE");
263
        }
264
 
41 ilm 265
        // Champ Module
266
        c.gridx = 0;
267
        c.gridy++;
268
        c.gridwidth = GridBagConstraints.REMAINDER;
63 ilm 269
        final JPanel addP = ComptaSQLConfElement.createAdditionalPanel();
41 ilm 270
        this.setAdditionalFieldsPanel(new FormLayouter(addP, 2));
271
        this.add(addP, c);
272
 
94 ilm 273
        // Tabbed
274
        JTabbedPane tabbedPane = new JTabbedPane();
275
 
41 ilm 276
        JPanel panelAdresse = new JPanel(new GridBagLayout());
132 ilm 277
        panelAdresse.setOpaque(false);
41 ilm 278
        GridBagConstraints cAdr = new DefaultGridBagConstraints();
279
        // Adresse
280
        TitledSeparator sep = new TitledSeparator("Adresse");
132 ilm 281
        sep.setOpaque(false);
41 ilm 282
        panelAdresse.add(sep, cAdr);
283
 
284
        this.sep2 = new TitledSeparator("Adresse d'enlévement");
132 ilm 285
        this.sep2.setOpaque(false);
41 ilm 286
        cAdr.gridx = GridBagConstraints.RELATIVE;
287
        panelAdresse.add(this.sep2, cAdr);
288
 
289
        //
290
 
291
        this.addView("ID_ADRESSE", REQ + ";" + DEC + ";" + SEP);
292
 
293
        cAdr.gridy++;
94 ilm 294
        cAdr.fill = GridBagConstraints.HORIZONTAL;
295
        cAdr.weightx = 1;
132 ilm 296
        final ElementSQLObject view = (ElementSQLObject) this.getView("ID_ADRESSE");
297
        view.setOpaque(false);
298
        panelAdresse.add(view, cAdr);
41 ilm 299
 
300
        // Selection de 2eme adresse
301
        this.addView("ID_ADRESSE_E", DEC);
302
        cAdr.gridx = GridBagConstraints.RELATIVE;
303
        this.comp2 = (ElementSQLObject) this.getView("ID_ADRESSE_E");
304
        this.comp2.setCreated(true);
132 ilm 305
        this.comp2.setOpaque(false);
41 ilm 306
        panelAdresse.add(this.comp2, cAdr);
307
 
308
        this.checkEnlevement = new JCheckBox("Adresse d'enlèvement identique");
132 ilm 309
        this.checkEnlevement.setOpaque(false);
94 ilm 310
        cAdr.gridx = 0;
311
        cAdr.gridy++;
312
        cAdr.gridwidth = GridBagConstraints.REMAINDER;
313
        panelAdresse.add(this.checkEnlevement, cAdr);
314
        tabbedPane.add("Adresses", panelAdresse);
41 ilm 315
 
316
        this.checkEnlevement.setSelected(true);
317
        this.sep2.setVisible(false);
318
        this.checkEnlevement.addActionListener(new ActionListener() {
319
 
320
            public void actionPerformed(java.awt.event.ActionEvent e) {
321
                System.out.println("Click");
322
                if (checkEnlevement.isSelected()) {
323
                    System.out.println("Mode 1");
93 ilm 324
                    comp2.setEditable(InteractionMode.DISABLED);
41 ilm 325
                    comp2.setCreated(false);
326
                    sep2.setVisible(false);
327
                } else {
328
                    System.out.println("Mode 2");
93 ilm 329
                    comp2.setEditable(InteractionMode.READ_WRITE);
41 ilm 330
                    comp2.setCreated(true);
331
                    sep2.setVisible(true);
332
                }
333
            };
334
        });
335
 
336
        // Contact
94 ilm 337
        JPanel panelContact = new JPanel(new GridBagLayout());
149 ilm 338
        panelContact.setOpaque(false);
41 ilm 339
        this.table = new ContactItemTable(this.defaultContactRowVals);
149 ilm 340
        this.table.setOpaque(false);
41 ilm 341
        this.table.setPreferredSize(new Dimension(this.table.getSize().width, 150));
94 ilm 342
        GridBagConstraints cContact = new DefaultGridBagConstraints();
343
        cContact.fill = GridBagConstraints.BOTH;
344
        cContact.weightx = 1;
345
        cContact.weighty = 1;
346
        panelContact.add(this.table, cContact);
347
        tabbedPane.add("Contacts", panelContact);
41 ilm 348
        c.gridx = 0;
349
        c.gridy++;
149 ilm 350
        c.anchor = GridBagConstraints.NORTHWEST;
41 ilm 351
        c.fill = GridBagConstraints.BOTH;
352
        c.gridwidth = GridBagConstraints.REMAINDER;
94 ilm 353
        this.add(tabbedPane, c);
41 ilm 354
 
149 ilm 355
        // Mode de réglement
41 ilm 356
        TitledSeparator reglSep = new TitledSeparator(getLabelFor("ID_MODE_REGLEMENT"));
149 ilm 357
        c.gridwidth = 2;
41 ilm 358
        c.gridy++;
359
        c.gridx = 0;
360
        this.add(reglSep, c);
361
 
362
        c.gridy++;
363
        c.gridx = 0;
80 ilm 364
        c.fill = GridBagConstraints.NONE;
41 ilm 365
        this.addView("ID_MODE_REGLEMENT", REQ + ";" + DEC + ";" + SEP);
366
        ElementSQLObject eltModeRegl = (ElementSQLObject) this.getView("ID_MODE_REGLEMENT");
367
        this.add(eltModeRegl, c);
368
 
149 ilm 369
        //
370
        {
371
            c.gridx = 2;
372
            c.gridy--;
373
            c.gridwidth = 2;
374
            c.fill = GridBagConstraints.BOTH;
375
            TitledSeparator ribSep = new TitledSeparator("Coordonnées bancaires");
376
 
377
            this.add(ribSep, c);
378
 
379
            final JPanel pCoordonneesBancaires = new JPanel();
380
            pCoordonneesBancaires.setLayout(new GridBagLayout());
381
            GridBagConstraints c2 = new DefaultGridBagConstraints();
382
 
383
            c2.gridy++;
384
            // IBAN
385
            JLabel labelIBAN = new JLabel("IBAN", SwingConstants.RIGHT);
386
            JTextField textIBAN = new JTextField(40);
387
            c2.weightx = 0;
388
            pCoordonneesBancaires.add(labelIBAN, c2);
389
            c2.gridx++;
390
            c2.weightx = 1;
391
            pCoordonneesBancaires.add(textIBAN, c2);
392
 
393
            // BIC
394
            JLabel labelBIC = new JLabel("BIC", SwingConstants.RIGHT);
180 ilm 395
            JTextField textBIC = new JTextField(20);
149 ilm 396
            c2.gridx = 0;
397
            c2.gridy++;
398
            c2.weightx = 0;
399
            pCoordonneesBancaires.add(labelBIC, c2);
400
            c2.gridx++;
401
            c2.weightx = 1;
402
            c2.fill = GridBagConstraints.NONE;
403
            pCoordonneesBancaires.add(textBIC, c2);
404
            c.gridy++;
405
            c.fill = GridBagConstraints.HORIZONTAL;
406
            this.add(pCoordonneesBancaires, c);
407
 
408
            this.addView(textIBAN, "IBAN");
409
            this.addView(textBIC, "BIC");
410
        }
41 ilm 411
        // Compte associé
412
 
413
        c.gridx = 0;
414
        c.gridy++;
415
        c.weightx = 1;
416
        c.weighty = 0;
80 ilm 417
        c.fill = GridBagConstraints.HORIZONTAL;
41 ilm 418
        c.gridwidth = GridBagConstraints.REMAINDER;
80 ilm 419
        TitledSeparator sepCompteCharge = new TitledSeparator("Comptes associés");
420
        this.add(sepCompteCharge, c);
41 ilm 421
 
80 ilm 422
        final JPanel panel = new JPanel(new GridBagLayout());
423
        final GridBagConstraints c2 = new DefaultGridBagConstraints();
424
        panel.add(new JLabel("Compte fournisseur associé", SwingConstants.RIGHT), c2);
41 ilm 425
        ISQLCompteSelector compteSel = new ISQLCompteSelector(true);
426
        c2.gridx++;
427
        c2.weightx = 1;
428
        panel.add(compteSel, c2);
80 ilm 429
        c2.gridx = 0;
430
        c2.gridy++;
431
        c2.weightx = 0;
432
        panel.add(new JLabel(getLabelFor("ID_COMPTE_PCE_CHARGE"), SwingConstants.RIGHT), c2);
433
        ISQLCompteSelector compteSelCharge = new ISQLCompteSelector(true);
434
        c2.gridx++;
435
        c2.weightx = 1;
436
        panel.add(compteSelCharge, c2);
61 ilm 437
        addView(compteSelCharge, "ID_COMPTE_PCE_CHARGE");
438
 
439
        c.gridwidth = GridBagConstraints.REMAINDER;
440
        c.gridy++;
441
        c.gridx = 0;
442
        c.weightx = 1;
443
        c.anchor = GridBagConstraints.NORTHWEST;
80 ilm 444
        this.add(panel, c);
61 ilm 445
 
149 ilm 446
        c.gridwidth = 1;
447
        c.gridy++;
448
        c.gridx = 0;
449
        c.weightx = 1;
450
        c.anchor = GridBagConstraints.NORTHWEST;
451
 
41 ilm 452
        // INfos
453
        c.gridx = 0;
454
        c.gridy++;
455
        c.gridheight = 1;
456
        c.weightx = 1;
457
        c.anchor = GridBagConstraints.WEST;
458
        c.gridwidth = GridBagConstraints.REMAINDER;
459
        this.add(new TitledSeparator(getLabelFor("INFOS")), c);
460
 
461
        c.gridy++;
462
        c.weightx = 1;
463
        c.weighty = 1;
464
        c.fill = GridBagConstraints.BOTH;
465
        ITextArea infos = new ITextArea();
466
        final JScrollPane scrollPane = new JScrollPane(infos);
467
        scrollPane.setBorder(null);
468
        this.add(scrollPane, c);
469
        this.addView(infos, "INFOS");
470
 
471
        this.addSQLObject(textType, "TYPE");
472
 
473
        this.addSQLObject(textCode, "CODE");
474
        this.addSQLObject(textTel, "TEL");
475
        this.addSQLObject(textFax, "FAX");
476
        this.addSQLObject(boxUE, "UE");
477
        this.addRequiredSQLObject(compteSel, "ID_COMPTE_PCE");
478
        // this.addRequiredPrivateForeignField(adresse,"ID_ADRESSE");
479
 
480
        // this.addSQLObject(adresse, "VILLE");
481
        /***********************************************************************************
482
         * this.addSQLObject(new JTextField(), "NUMERO_CANTON"); this.addSQLObject(new JTextField(),
483
         * "NUMERO_COMMUNE");
484
         */
485
 
486
        // Select Compte fournisseur par defaut
487
        final SQLBase base = ((ComptaPropsConfiguration) Configuration.getInstance()).getSQLBaseSociete();
488
        final SQLTable tablePrefCompte = base.getTable("PREFS_COMPTE");
489
        final SQLRow rowPrefsCompte = tablePrefCompte.getRow(2);
490
        int idCompteFourn = rowPrefsCompte.getInt("ID_COMPTE_PCE_FOURNISSEUR");
491
        if (idCompteFourn <= 1) {
492
            try {
493
                idCompteFourn = ComptePCESQLElement.getIdComptePceDefault("Fournisseurs");
494
            } catch (Exception e) {
495
                e.printStackTrace();
496
            }
497
        }
498
 
499
        compteSel.setValue(idCompteFourn);
500
    }
501
 
502
    @Override
503
    public void select(SQLRowAccessor r) {
504
        if (r != null && r.isForeignEmpty("ID_ADRESSE_E")) {
505
            this.checkEnlevement.setSelected(true);
93 ilm 506
            this.comp2.setEditable(InteractionMode.DISABLED);
41 ilm 507
            this.comp2.setCreated(false);
508
            this.sep2.setVisible(false);
509
        } else {
510
            this.checkEnlevement.setSelected(false);
93 ilm 511
            this.comp2.setEditable(InteractionMode.READ_WRITE);
41 ilm 512
            this.comp2.setCreated(true);
513
            this.sep2.setVisible(true);
514
        }
515
 
516
        if (r != null) {
73 ilm 517
            this.table.insertFrom("ID_" + this.getTable().getName(), r.asRowValues());
41 ilm 518
            this.defaultContactRowVals.put("TEL_DIRECT", r.getString("TEL"));
519
            this.defaultContactRowVals.put("FAX", r.getString("FAX"));
520
        }
521
 
522
        super.select(r);
523
    }
524
 
525
    @Override
526
    public void update() {
527
        // TODO Raccord de méthode auto-généré
528
        super.update();
529
        this.table.updateField("ID_" + this.getTable().getName(), getSelectedID());
530
    }
531
 
532
    @Override
533
    public int insert(SQLRow order) {
534
        // TODO Raccord de méthode auto-généré
535
        int id = super.insert(order);
536
        this.table.updateField("ID_" + this.getTable().getName(), id);
537
        return id;
538
    }
539
 
540
    @Override
541
    protected SQLRowValues createDefaults() {
542
        SQLRowValues vals = new SQLRowValues(this.getTable());
543
        SQLRowAccessor r;
544
        this.checkEnlevement.setSelected(true);
545
        this.sep2.setVisible(false);
546
        try {
547
            r = ModeReglementDefautPrefPanel.getDefaultRow(false);
548
            SQLElement eltModeReglement = Configuration.getInstance().getDirectory().getElement("MODE_REGLEMENT");
549
            if (r.getID() > 1) {
550
                SQLRowValues rowVals = eltModeReglement.createCopy(r.getID());
551
                System.err.println(rowVals.getInt("ID_TYPE_REGLEMENT"));
552
                vals.put("ID_MODE_REGLEMENT", rowVals);
553
            }
554
        } catch (SQLException e) {
555
            System.err.println("Impossible de sélectionner le mode de règlement par défaut du client.");
556
            e.printStackTrace();
557
        }
61 ilm 558
 
559
        // Select Compte charge par defaut
560
        final SQLTable tablePrefCompte = getTable().getTable("PREFS_COMPTE");
561
        final SQLRow rowPrefsCompte = SQLBackgroundTableCache.getInstance().getCacheForTable(tablePrefCompte).getRowFromId(2);
562
        // compte Achat
563
        int idCompteAchat = rowPrefsCompte.getInt("ID_COMPTE_PCE_ACHAT");
564
        if (idCompteAchat <= 1) {
565
            try {
566
                idCompteAchat = ComptePCESQLElement.getIdComptePceDefault("Achats");
567
            } catch (Exception e) {
568
                e.printStackTrace();
569
            }
570
        }
571
        vals.put("ID_COMPTE_PCE_CHARGE", idCompteAchat);
41 ilm 572
        return vals;
573
    }
574
 
575
}