OpenConcerto

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

svn://code.openconcerto.org/openconcerto

Rev

Rev 19 | Rev 65 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
18 ilm 1
/*
2
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
3
 *
4
 * Copyright 2011 OpenConcerto, by ILM Informatique. All rights reserved.
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
 package org.openconcerto.erp.generationDoc.gestcomm;
15
 
16
import org.openconcerto.erp.config.ComptaPropsConfiguration;
17
import org.openconcerto.erp.generationDoc.AbstractJOOReportsSheet;
18
import org.openconcerto.sql.Configuration;
19
import org.openconcerto.sql.element.SQLElement;
20
import org.openconcerto.sql.model.SQLRow;
21
import org.openconcerto.sql.model.SQLTable;
22
 
23
import java.util.Date;
24
import java.util.HashMap;
25
import java.util.List;
26
import java.util.Map;
27
 
28
public class CourrierClientSheet extends AbstractJOOReportsSheet {
29
 
30
    private SQLRow rowCourrier;
31
 
25 ilm 32
    public static final String TEMPLATE_ID = "Courrier";
33
    public static final String TEMPLATE_PROPERTY_NAME = "LocationCourrier";
18 ilm 34
 
35
    public CourrierClientSheet(SQLRow row) {
36
        super();
37
        this.rowCourrier = row;
38
        Date d = (Date) this.rowCourrier.getObject("DATE");
39
        String year = yearFormat.format(d);
25 ilm 40
        init(year, "Courrier.odt", "CourrierPrinter");
18 ilm 41
    }
42
 
43
    /**
44
     * @return une Map contenant les valeurs à remplacer dans la template
45
     */
25 ilm 46
    protected Map<String, Object> createMap() {
18 ilm 47
 
48
        Map<String, Object> m = new HashMap<String, Object>();
49
 
50
        SQLElement elt = Configuration.getInstance().getDirectory().getElement("MODELE_COURRIER_CLIENT");
51
        SQLRow rowModele = elt.getTable().getRow(this.rowCourrier.getInt("ID_MODELE_COURRIER_CLIENT"));
52
        String contenu = rowModele.getString("CONTENU");
19 ilm 53
        m.put("Objet", this.rowCourrier.getString("NOM"));
18 ilm 54
        m.put("Date", dateFormat.format(this.rowCourrier.getDate("DATE").getTime()));
55
        int idAdresse = this.rowCourrier.getInt("ID_ADRESSE");
56
 
57
        if (idAdresse > 1) {
58
 
59
            SQLRow rowAdresseClient = this.rowCourrier.getForeignRow("ID_ADRESSE");
60
 
61
            m.put("clientNom", rowAdresseClient.getString("DEST"));
62
            m.put("clientAdresse", rowAdresseClient.getString("RUE"));
63
 
64
            m.put("codePostal", getVilleCP(rowAdresseClient.getString("VILLE")));
65
            String villeCli = getVille(rowAdresseClient.getString("VILLE"));
66
            final Object cedexCli = rowAdresseClient.getObject("CEDEX");
67
            final boolean hasCedexCli = rowAdresseClient.getBoolean("HAS_CEDEX");
68
 
69
            if (hasCedexCli) {
70
                villeCli += " CEDEX";
71
                if (cedexCli != null && cedexCli.toString().trim().length() > 0) {
72
                    villeCli += " " + cedexCli.toString().trim();
73
                }
74
            }
75
 
76
            m.put("ville", villeCli);
77
        }
78
        return m;
79
    }
80
 
81
    public String getFileName() {
25 ilm 82
        return "Courrier_" + this.rowCourrier.getString("NUMERO");
18 ilm 83
    }
84
 
85
}