OpenConcerto

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

svn://code.openconcerto.org/openconcerto

Rev

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

Rev 132 Rev 142
Line 14... Line 14...
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.config.ComptaPropsConfiguration;
16
import org.openconcerto.erp.config.ComptaPropsConfiguration;
17
import org.openconcerto.erp.core.common.element.ComptaSQLConfElement;
17
import org.openconcerto.erp.core.common.element.ComptaSQLConfElement;
18
import org.openconcerto.erp.core.customerrelationship.customer.report.FicheClientXmlSheet;
18
import org.openconcerto.erp.core.customerrelationship.customer.report.FicheClientXmlSheet;
-
 
19
import org.openconcerto.erp.preferences.GestionClientPreferencePanel;
19
import org.openconcerto.erp.preferences.PrinterNXProps;
20
import org.openconcerto.erp.preferences.PrinterNXProps;
20
import org.openconcerto.ql.LabelCreator;
21
import org.openconcerto.ql.LabelCreator;
21
import org.openconcerto.ql.QLPrinter;
22
import org.openconcerto.ql.QLPrinter;
22
import org.openconcerto.sql.Configuration;
23
import org.openconcerto.sql.Configuration;
23
import org.openconcerto.sql.element.SQLComponent;
24
import org.openconcerto.sql.element.SQLComponent;
24
import org.openconcerto.sql.model.SQLRowAccessor;
25
import org.openconcerto.sql.model.SQLRowAccessor;
25
import org.openconcerto.sql.model.SQLRowValues;
26
import org.openconcerto.sql.model.SQLRowValues;
-
 
27
import org.openconcerto.sql.preferences.SQLPreferences;
26
import org.openconcerto.sql.request.ListSQLRequest;
28
import org.openconcerto.sql.request.ListSQLRequest;
27
import org.openconcerto.sql.view.list.IListe;
29
import org.openconcerto.sql.view.list.IListe;
28
import org.openconcerto.sql.view.list.IListeAction.IListeEvent;
30
import org.openconcerto.sql.view.list.IListeAction.IListeEvent;
29
import org.openconcerto.sql.view.list.RowAction.PredicateRowAction;
31
import org.openconcerto.sql.view.list.RowAction.PredicateRowAction;
30
import org.openconcerto.ui.EmailComposer;
32
import org.openconcerto.ui.EmailComposer;
Line 47... Line 49...
47
                PredicateRowAction actionPrintLabel = new PredicateRowAction(new AbstractAction() {
49
                PredicateRowAction actionPrintLabel = new PredicateRowAction(new AbstractAction() {
48
 
50
 
49
                    @Override
51
                    @Override
50
                    public void actionPerformed(ActionEvent e) {
52
                    public void actionPerformed(ActionEvent e) {
51
                        final SQLRowAccessor row = IListe.get(e).fetchSelectedRow();
53
                        final SQLRowAccessor row = IListe.get(e).fetchSelectedRow();
52
                        final LabelCreator c = new LabelCreator(720);
-
 
53
                        c.setLeftMargin(10);
54
                        printLabel(row, property);
54
                        c.setTopMargin(10);
-
 
55
                        c.setDefaultFont(new Font("Verdana", Font.PLAIN, 50));
-
 
56
                        c.addLineBold(row.getString("NOM"));
-
 
57
                        final SQLRowAccessor foreignRow = row.getForeign("ID_ADRESSE");
-
 
58
                        final String string = foreignRow.getString("RUE");
-
 
59
                        String[] s = string.split("\n");
-
 
60
                        for (String string2 : s) {
-
 
61
                            c.addLineNormal(string2);
-
 
62
                        }
-
 
63
                        c.addLineNormal(foreignRow.getString("CODE_POSTAL") + " " + foreignRow.getString("VILLE"));
-
 
64
                        final QLPrinter prt = new QLPrinter(property);
-
 
65
                        try {
-
 
66
                            prt.print(c.getImage());
-
 
67
                        } catch (Exception ex) {
-
 
68
                            ex.printStackTrace();
-
 
69
                        }
-
 
70
                    }
55
                    }
71
                }, false, "customerrelationship.customer.label.print");
56
                }, false, "customerrelationship.customer.label.print");
72
                actionPrintLabel.setPredicate(IListeEvent.getSingleSelectionPredicate());
57
                actionPrintLabel.setPredicate(IListeEvent.getSingleSelectionPredicate());
73
                getRowActions().add(actionPrintLabel);
58
                getRowActions().add(actionPrintLabel);
74
            }
59
            }
Line 96... Line 81...
96
        }, true, "customerrelationship.customer.email.send");
81
        }, true, "customerrelationship.customer.email.send");
97
        action.setPredicate(IListeEvent.getNonEmptySelectionPredicate());
82
        action.setPredicate(IListeEvent.getNonEmptySelectionPredicate());
98
        getRowActions().add(action);
83
        getRowActions().add(action);
99
    }
84
    }
100
 
85
 
-
 
86
    public void printLabel(SQLRowAccessor row, String qlPrinterProperty) {
-
 
87
        final LabelCreator c = new LabelCreator(720);
-
 
88
        c.setLeftMargin(10);
-
 
89
        c.setTopMargin(10);
-
 
90
        c.setDefaultFont(new Font("Verdana", Font.PLAIN, 50));
-
 
91
        c.addLineBold(row.getString("NOM"));
-
 
92
        final SQLRowAccessor foreignRow = row.asRow().getForeign("ID_ADRESSE");
-
 
93
        final String string = foreignRow.getString("RUE");
-
 
94
        String[] s = string.split("\n");
-
 
95
        for (String string2 : s) {
-
 
96
            c.addLineNormal(string2);
-
 
97
        }
-
 
98
        c.addLineNormal(foreignRow.getString("CODE_POSTAL") + " " + foreignRow.getString("VILLE"));
-
 
99
 
-
 
100
        final String pays = foreignRow.getString("PAYS");
-
 
101
        if (pays != null && pays.trim().length() > 0 && !pays.equalsIgnoreCase(ComptaPropsConfiguration.getInstanceCompta().getRowSociete().getForeignRow("ID_ADRESSE_COMMON").getString("PAYS"))) {
-
 
102
            c.addLineNormal(pays);
-
 
103
        }
-
 
104
 
-
 
105
        final QLPrinter prt = new QLPrinter(qlPrinterProperty);
-
 
106
        try {
-
 
107
            prt.print(c.getImage());
-
 
108
        } catch (Exception ex) {
-
 
109
            ex.printStackTrace();
-
 
110
        }
-
 
111
    }
-
 
112
 
101
    protected void sendMail(List<SQLRowValues> l) {
113
    protected void sendMail(List<SQLRowValues> l) {
102
 
114
 
103
        String mail = "";
115
        String mail = "";
104
            for (SQLRowAccessor rowCli : l) {
116
            for (SQLRowAccessor rowCli : l) {
105
                String string = rowCli.getString("MAIL");
117
                String string = rowCli.getString("MAIL");
Line 153... Line 165...
153
        if (getTable().getFieldsName().contains("LOCALISATION")) {
165
        if (getTable().getFieldsName().contains("LOCALISATION")) {
154
            l.add("LOCALISATION");
166
            l.add("LOCALISATION");
155
        } else {
167
        } else {
156
            l.add("CODE");
168
            l.add("CODE");
157
        }
169
        }
-
 
170
        SQLPreferences prefs = SQLPreferences.getMemCached(getTable().getDBRoot());
-
 
171
        if (prefs.getBoolean(GestionClientPreferencePanel.DISPLAY_CLIENT_PCE, false)) {
-
 
172
            l.add("ID_COMPTE_PCE");
-
 
173
        }
158
        return l;
174
        return l;
159
    }
175
    }
160
 
176
 
161
    /*
177
    /*
162
     * (non-Javadoc)
178
     * (non-Javadoc)