OpenConcerto

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

svn://code.openconcerto.org/openconcerto

Rev

Rev 156 | Go to most recent revision | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 156 Rev 180
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 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.
10
 * 
10
 * 
11
 * When distributing the software, include this License Header Notice in each file.
11
 * When distributing the software, include this License Header Notice in each file.
12
 */
12
 */
13
 
13
 
14
 package org.openconcerto.erp.core.customerrelationship.customer.element;
14
 package org.openconcerto.erp.core.customerrelationship.customer.element;
15
 
15
 
16
import org.openconcerto.erp.core.edm.AttachmentAction;
16
import org.openconcerto.erp.core.edm.AttachmentAction;
17
import org.openconcerto.erp.core.reports.history.ui.HistoriqueClientFrame;
17
import org.openconcerto.erp.core.reports.history.ui.HistoriqueClientFrame;
-
 
18
import org.openconcerto.erp.preferences.GestionCommercialeGlobalPreferencePanel;
18
import org.openconcerto.sql.element.GlobalMapper;
19
import org.openconcerto.sql.element.GlobalMapper;
19
import org.openconcerto.sql.element.GroupSQLComponent;
20
import org.openconcerto.sql.element.GroupSQLComponent;
20
import org.openconcerto.sql.element.SQLComponent;
21
import org.openconcerto.sql.element.SQLComponent;
21
import org.openconcerto.sql.model.SQLRowAccessor;
22
import org.openconcerto.sql.model.SQLRowAccessor;
-
 
23
import org.openconcerto.sql.preferences.SQLPreferences;
22
import org.openconcerto.sql.request.SQLFieldTranslator;
24
import org.openconcerto.sql.request.SQLFieldTranslator;
23
import org.openconcerto.sql.view.list.IListe;
25
import org.openconcerto.sql.view.list.IListe;
24
import org.openconcerto.sql.view.list.IListeAction.IListeEvent;
26
import org.openconcerto.sql.view.list.IListeAction.IListeEvent;
25
import org.openconcerto.sql.view.list.RowAction.PredicateRowAction;
27
import org.openconcerto.sql.view.list.RowAction.PredicateRowAction;
26
import org.openconcerto.ui.light.LightUIElement;
28
import org.openconcerto.ui.light.LightUIElement;
27
import org.openconcerto.ui.light.LightUILine;
29
import org.openconcerto.ui.light.LightUILine;
28
import org.openconcerto.ui.light.LightUIPanel;
30
import org.openconcerto.ui.light.LightUIPanel;
29
import org.openconcerto.ui.light.SimpleTextLine;
31
import org.openconcerto.ui.light.SimpleTextLine;
30
 
32
 
31
import java.awt.event.ActionEvent;
33
import java.awt.event.ActionEvent;
32
import java.util.List;
34
import java.util.List;
33
 
35
 
34
import javax.swing.AbstractAction;
36
import javax.swing.AbstractAction;
35
 
37
 
36
public class CustomerSQLElement extends ClientNormalSQLElement {
38
public class CustomerSQLElement extends ClientNormalSQLElement {
37
 
39
 
38
    public CustomerSQLElement() {
40
    public CustomerSQLElement() {
39
        super();
41
        super();
40
        final CustomerGroup group = new CustomerGroup();
42
        final CustomerGroup group = new CustomerGroup();
41
        GlobalMapper.getInstance().map(CustomerGroup.ID, group);
43
        GlobalMapper.getInstance().map(CustomerGroup.ID, group);
42
        setDefaultGroup(group);
44
        setDefaultGroup(group);
43
 
45
 
44
        PredicateRowAction actionAttachment = new PredicateRowAction(new AttachmentAction().getAction(), true);
46
        PredicateRowAction actionAttachment = new PredicateRowAction(new AttachmentAction().getAction(), true);
45
        actionAttachment.setPredicate(IListeEvent.getSingleSelectionPredicate());
47
        actionAttachment.setPredicate(IListeEvent.getSingleSelectionPredicate());
46
        getRowActions().add(actionAttachment);
48
        getRowActions().add(actionAttachment);
47
 
49
 
48
        PredicateRowAction actionHistory = new PredicateRowAction(new AbstractAction("Historique client") {
50
        PredicateRowAction actionHistory = new PredicateRowAction(new AbstractAction("Historique client") {
49
 
51
 
50
            @Override
52
            @Override
51
            public void actionPerformed(ActionEvent e) {
53
            public void actionPerformed(ActionEvent e) {
52
                HistoriqueClientFrame histoFrame = new HistoriqueClientFrame();
54
                HistoriqueClientFrame histoFrame = new HistoriqueClientFrame();
53
                int idClient = IListe.get(e).getSelectedId();
55
                int idClient = IListe.get(e).getSelectedId();
54
                histoFrame.selectId(idClient);
56
                histoFrame.selectId(idClient);
55
                histoFrame.setVisible(true);
57
                histoFrame.setVisible(true);
56
            }
58
            }
57
        }, true);
59
        }, true);
58
        actionHistory.setPredicate(IListeEvent.getSingleSelectionPredicate());
60
        actionHistory.setPredicate(IListeEvent.getSingleSelectionPredicate());
59
        getRowActions().add(actionHistory);
61
        getRowActions().add(actionHistory);
60
 
62
 
61
    }
63
    }
62
 
64
 
63
    @Override
65
    @Override
64
    public SQLComponent createComponent() {
66
    public SQLComponent createComponent() {
65
        final GroupSQLComponent c = new CustomerSQLComponent(this);
67
        final GroupSQLComponent c = new CustomerSQLComponent(this);
66
        c.startTabGroupAfter("customerrelationship.customer.identifier");
68
        c.startTabGroupAfter("customerrelationship.customer.identifier");
67
        return c;
69
        return c;
68
    }
70
    }
69
 
71
 
70
    @Override
72
    @Override
71
    protected List<String> getListFields() {
73
    protected List<String> getListFields() {
72
        final List<String> fields = super.getListFields();
74
        final List<String> fields = super.getListFields();
73
        if (getTable().contains("GROUPE")) {
75
        if (getTable().contains("GROUPE")) {
74
            fields.add("GROUPE");
76
            fields.add("GROUPE");
75
        }
77
        }
-
 
78
        SQLPreferences prefs = new SQLPreferences(getTable().getDBRoot());
-
 
79
 
-
 
80
        if (prefs.getBoolean(GestionCommercialeGlobalPreferencePanel.CATEGORIE_COMPTABLE_SPEC, false)) {
-
 
81
            fields.add("ID_CATEGORIE_COMPTABLE");
-
 
82
        }
76
        fields.add("SOLDE_COMPTE");
83
        fields.add("SOLDE_COMPTE");
77
        fields.add("REMIND_DATE");
84
        fields.add("REMIND_DATE");
78
        fields.add("OBSOLETE");
85
        fields.add("OBSOLETE");
79
        return fields;
86
        return fields;
80
    }
87
    }
81
 
88
 
82
    @Override
89
    @Override
83
    protected void fillDataPanel(final String sessionToken, final List<SQLRowAccessor> selection, final LightUIPanel dataPanel) {
90
    protected void fillDataPanel(final String sessionToken, final List<SQLRowAccessor> selection, final LightUIPanel dataPanel) {
84
        final SQLFieldTranslator translator = this.getDirectory().getTranslator();
91
        final SQLFieldTranslator translator = this.getDirectory().getTranslator();
85
        final SQLRowAccessor sqlRow = selection.get(0);
92
        final SQLRowAccessor sqlRow = selection.get(0);
86
 
93
 
87
        final int rowId = sqlRow.getID();
94
        final int rowId = sqlRow.getID();
88
        final LightUILine mainLine = new LightUILine();
95
        final LightUILine mainLine = new LightUILine();
89
        final LightUIPanel mainLinePanel = new LightUIPanel(dataPanel.getId() + ".main.line." + rowId);
96
        final LightUIPanel mainLinePanel = new LightUIPanel(dataPanel.getId() + ".main.line." + rowId);
90
        mainLinePanel.setWeightX(1);
97
        mainLinePanel.setWeightX(1);
91
 
98
 
92
        final SimpleTextLine spacer = new SimpleTextLine("", true, LightUIElement.HALIGN_LEFT, 2);
99
        final SimpleTextLine spacer = new SimpleTextLine("", true, LightUIElement.HALIGN_LEFT, 2);
93
        spacer.setMarginBottom(4);
100
        spacer.setMarginBottom(4);
94
 
101
 
95
        String name = sqlRow.getString("NOM");
102
        String name = sqlRow.getString("NOM");
96
 
103
 
97
        mainLinePanel.addChild(new SimpleTextLine(name, true, LightUIElement.HALIGN_LEFT));
104
        mainLinePanel.addChild(new SimpleTextLine(name, true, LightUIElement.HALIGN_LEFT));
98
 
105
 
99
        final SimpleTextLine titleSituationContact = new SimpleTextLine("Coordonnées du client", true, LightUIElement.HALIGN_LEFT, 2);
106
        final SimpleTextLine titleSituationContact = new SimpleTextLine("Coordonnées du client", true, LightUIElement.HALIGN_LEFT, 2);
100
        titleSituationContact.setMarginTop(10);
107
        titleSituationContact.setMarginTop(10);
101
        mainLinePanel.addChild(titleSituationContact);
108
        mainLinePanel.addChild(titleSituationContact);
102
 
109
 
103
        addFieldToPanel("TEL", mainLinePanel, sqlRow, translator, true, "non renseigné");
110
        addFieldToPanel("TEL", mainLinePanel, sqlRow, translator, true, "non renseigné");
104
        addFieldToPanel("MAIL", mainLinePanel, sqlRow, translator, true, "non renseigné");
111
        addFieldToPanel("MAIL", mainLinePanel, sqlRow, translator, true, "non renseigné");
105
 
112
 
106
        mainLine.addChild(mainLinePanel);
113
        mainLine.addChild(mainLinePanel);
107
        dataPanel.addChild(mainLine);
114
        dataPanel.addChild(mainLine);
108
    }
115
    }
109
 
116
 
110
}
117
}