OpenConcerto

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

svn://code.openconcerto.org/openconcerto

Rev

Rev 19 | Rev 28 | 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.core.sales.quote.element;
15
 
16
import org.openconcerto.erp.config.ComptaPropsConfiguration;
17
import org.openconcerto.erp.config.Gestion;
18
import org.openconcerto.erp.core.common.element.ComptaSQLConfElement;
19
import org.openconcerto.erp.core.sales.invoice.component.SaisieVenteFactureSQLComponent;
20
import org.openconcerto.erp.core.sales.order.component.CommandeClientSQLComponent;
21
import org.openconcerto.erp.core.sales.quote.component.DevisSQLComponent;
19 ilm 22
import org.openconcerto.erp.core.supplychain.order.component.CommandeSQLComponent;
18 ilm 23
import org.openconcerto.sql.Configuration;
24
import org.openconcerto.sql.element.SQLComponent;
25
import org.openconcerto.sql.element.SQLElement;
26
import org.openconcerto.sql.model.SQLRowValues;
27
import org.openconcerto.sql.request.ListSQLRequest;
28
import org.openconcerto.sql.view.EditFrame;
29
 
30
import java.util.ArrayList;
31
import java.util.HashSet;
32
import java.util.List;
33
import java.util.Set;
34
 
35
import javax.swing.ImageIcon;
36
import javax.swing.JFrame;
37
 
38
public class DevisSQLElement extends ComptaSQLConfElement {
39
 
25 ilm 40
    public static final String TABLENAME = "DEVIS";
41
 
18 ilm 42
    public DevisSQLElement() {
25 ilm 43
        super(TABLENAME, "un devis", "devis");
18 ilm 44
    }
45
 
46
    protected List<String> getComboFields() {
47
        List<String> l = new ArrayList<String>();
48
        l.add("NUMERO");
49
        return l;
50
    }
51
 
52
    protected List<String> getListFields() {
53
        List<String> l = new ArrayList<String>();
54
        l.add("NUMERO");
55
        l.add("DATE");
56
        l.add("ID_CLIENT");
57
        l.add("OBJET");
58
        l.add("T_HT");
59
        l.add("T_TTC");
60
        l.add("INFOS");
61
        return l;
62
    }
63
 
64
    @Override
19 ilm 65
    public synchronized ListSQLRequest createListRequest() {
18 ilm 66
        return new ListSQLRequest(getTable(), getListFields()) {
67
            @Override
68
            protected void customizeToFetch(SQLRowValues graphToFetch) {
69
                super.customizeToFetch(graphToFetch);
70
                graphToFetch.put("ID_ETAT_DEVIS", null);
71
            }
72
        };
73
    }
74
 
75
    @Override
76
    protected Set<String> getChildren() {
77
        Set<String> set = new HashSet<String>();
78
        set.add("DEVIS_ELEMENT");
79
        return set;
80
    }
81
 
82
    @Override
83
    protected List<String> getPrivateFields() {
84
        List<String> s = new ArrayList<String>(1);
85
        s.add("ID_ADRESSE");
86
        return s;
87
    }
88
 
89
    /*
90
     * (non-Javadoc)
91
     *
92
     * @see org.openconcerto.devis.SQLElement#getComponent()
93
     */
94
    public SQLComponent createComponent() {
95
            return new DevisSQLComponent(this);
96
    }
97
 
98
    /**
99
     * Transfert d'un devis en facture
100
     *
101
     * @param devisID
102
     */
103
    public void transfertFacture(int devisID) {
104
 
105
        SQLElement elt = Configuration.getInstance().getDirectory().getElement("SAISIE_VENTE_FACTURE");
106
        EditFrame editFactureFrame = new EditFrame(elt);
107
        editFactureFrame.setIconImage(new ImageIcon(Gestion.class.getResource("frameicon.png")).getImage());
108
 
109
        SaisieVenteFactureSQLComponent comp = (SaisieVenteFactureSQLComponent) editFactureFrame.getSQLComponent();
110
 
111
        comp.setDefaults();
112
        comp.loadDevis(devisID);
113
 
114
        editFactureFrame.pack();
115
        editFactureFrame.setState(JFrame.NORMAL);
116
        editFactureFrame.setVisible(true);
117
    }
118
 
19 ilm 119
    // /**
120
    // * Transfert d'un devis en commande
121
    // *
122
    // * @param devisID
123
    // * @deprecated
124
    // */
125
    // public void transfertCommande(int devisID) {
126
    //
127
    // SQLElement elt = Configuration.getInstance().getDirectory().getElement("COMMANDE");
128
    // EditFrame editFactureFrame = new EditFrame(elt);
129
    // editFactureFrame.setIconImage(new
130
    // ImageIcon(Gestion.class.getResource("frameicon.png")).getImage());
131
    //
132
    // CommandeSQLComponent comp = (CommandeSQLComponent) editFactureFrame.getSQLComponent();
133
    //
134
    // comp.setDefaults();
135
    // comp.loadDevis(devisID);
136
    //
137
    // editFactureFrame.pack();
138
    // editFactureFrame.setState(JFrame.NORMAL);
139
    // editFactureFrame.setVisible(true);
140
    // }
141
 
18 ilm 142
    /**
143
     * Transfert d'un devis en commande
144
     *
145
     * @param devisID
146
     */
147
    public void transfertCommandeClient(int devisID) {
148
 
149
        SQLElement elt = Configuration.getInstance().getDirectory().getElement("COMMANDE_CLIENT");
150
        EditFrame editFactureFrame = new EditFrame(elt);
151
        editFactureFrame.setIconImage(new ImageIcon(Gestion.class.getResource("frameicon.png")).getImage());
152
 
153
        CommandeClientSQLComponent comp = (CommandeClientSQLComponent) editFactureFrame.getSQLComponent();
154
 
155
        comp.setDefaults();
156
        comp.loadDevis(devisID);
157
 
158
        editFactureFrame.pack();
159
        editFactureFrame.setState(JFrame.NORMAL);
160
        editFactureFrame.setVisible(true);
161
    }
162
 
163
}