OpenConcerto

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

svn://code.openconcerto.org/openconcerto

Rev

Rev 128 | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 128 Rev 170
Line 6... Line 6...
6
import java.util.List;
6
import java.util.List;
7
import java.util.Set;
7
import java.util.Set;
8
 
8
 
9
import javax.swing.SwingUtilities;
9
import javax.swing.SwingUtilities;
10
 
10
 
-
 
11
import org.openconcerto.erp.config.ComptaPropsConfiguration;
11
import org.openconcerto.erp.core.common.element.ComptaSQLConfElement;
12
import org.openconcerto.erp.core.common.element.ComptaSQLConfElement;
12
import org.openconcerto.erp.core.common.element.NumerotationAutoSQLElement;
13
import org.openconcerto.erp.core.common.element.NumerotationAutoSQLElement;
13
import org.openconcerto.sql.Configuration;
14
import org.openconcerto.sql.Configuration;
14
import org.openconcerto.sql.element.SQLComponent;
15
import org.openconcerto.sql.element.SQLComponent;
15
import org.openconcerto.sql.element.UISQLComponent;
16
import org.openconcerto.sql.element.UISQLComponent;
16
import org.openconcerto.sql.model.SQLRow;
17
import org.openconcerto.sql.model.SQLRow;
17
import org.openconcerto.sql.model.SQLRowAccessor;
18
import org.openconcerto.sql.model.SQLRowAccessor;
18
import org.openconcerto.sql.model.SQLRowValues;
19
import org.openconcerto.sql.model.SQLRowValues;
-
 
20
import org.openconcerto.sql.model.SQLSelect;
19
import org.openconcerto.sql.model.SQLTable;
21
import org.openconcerto.sql.model.SQLTable;
-
 
22
import org.openconcerto.sql.model.Where;
-
 
23
import org.openconcerto.sql.request.ComboSQLRequest;
20
import org.openconcerto.sql.sqlobject.ElementComboBox;
24
import org.openconcerto.sql.sqlobject.ElementComboBox;
21
import org.openconcerto.sql.sqlobject.JUniqueTextField;
25
import org.openconcerto.sql.sqlobject.JUniqueTextField;
22
import org.openconcerto.sql.view.EditFrame;
26
import org.openconcerto.sql.view.EditFrame;
23
import org.openconcerto.ui.JDate;
27
import org.openconcerto.ui.JDate;
24
import org.openconcerto.ui.component.ITextArea;
28
import org.openconcerto.ui.component.ITextArea;
25
import org.openconcerto.utils.ExceptionHandler;
29
import org.openconcerto.utils.ExceptionHandler;
26
import org.openconcerto.utils.ListMap;
30
import org.openconcerto.utils.ListMap;
-
 
31
import org.openconcerto.utils.cc.ITransformer;
27
 
32
 
28
public class ProjectSQLElement extends ComptaSQLConfElement {
33
public class ProjectSQLElement extends ComptaSQLConfElement {
29
 
34
 
30
    public ProjectSQLElement() {
35
    public ProjectSQLElement() {
31
        super("AFFAIRE", "une affaire", "affaires");
36
        super("AFFAIRE", "une affaire", "affaires");
Line 33... Line 38...
33
 
38
 
34
    @Override
39
    @Override
35
    protected List<String> getListFields() {
40
    protected List<String> getListFields() {
36
        final List<String> l = new ArrayList<String>();
41
        final List<String> l = new ArrayList<String>();
37
        l.add("ID_CLIENT");
42
        l.add("ID_CLIENT");
-
 
43
        if (getTable().contains("ID_SOCIETE_COMMON")) {
-
 
44
            l.add("ID_SOCIETE_COMMON");
-
 
45
        }
38
        l.add("ID_TYPE_AFFAIRE");
46
        l.add("ID_TYPE_AFFAIRE");
39
        l.add("NUMERO");
47
        l.add("NUMERO");
40
        l.add("ID_ETAT_AFFAIRE");
48
        l.add("ID_ETAT_AFFAIRE");
41
        l.add("ID_COMMERCIAL");
49
        l.add("ID_COMMERCIAL");
42
        l.add("INFOS");
50
        l.add("INFOS");
43
        return l;
51
        return l;
44
    }
52
    }
45
 
53
 
-
 
54
    protected void _initComboRequest(ComboSQLRequest req) {
-
 
55
        super._initComboRequest(req);
-
 
56
        if (getTable().contains("ID_SOCIETE_COMMON")) {
-
 
57
            final ComptaPropsConfiguration comptaPropsConfiguration = ((ComptaPropsConfiguration) Configuration.getInstance());
-
 
58
            final int socID = comptaPropsConfiguration.getSocieteID();
-
 
59
            req.setSelectTransf(new ITransformer<SQLSelect, SQLSelect>() {
-
 
60
 
-
 
61
                @Override
-
 
62
                public SQLSelect transformChecked(SQLSelect input) {
-
 
63
                    Where w = new Where(getTable().getField("ID_SOCIETE_COMMON"), "=", (Object) null).or(new Where(getTable().getField("ID_SOCIETE_COMMON"), "=", 1))
-
 
64
                            .or(new Where(getTable().getField("ID_SOCIETE_COMMON"), "=", socID));
-
 
65
 
-
 
66
                    input.andWhere(w);
-
 
67
                    return input;
-
 
68
                }
-
 
69
            });
-
 
70
        }
-
 
71
    }
-
 
72
 
46
    @Override
73
    @Override
47
    protected List<String> getComboFields() {
74
    protected List<String> getComboFields() {
48
        final List<String> l = new ArrayList<String>();
75
        final List<String> l = new ArrayList<String>();
49
        l.add("NUMERO");
76
        l.add("NUMERO");
50
        l.add("ID_CLIENT");
77
        l.add("ID_CLIENT");
Line 75... Line 102...
75
                this.addView(this.field, "NUMERO", "1");
102
                this.addView(this.field, "NUMERO", "1");
76
                this.addView(new JDate(true), "DATE", "1");
103
                this.addView(new JDate(true), "DATE", "1");
77
                this.addView("ID_CLIENT", "1;" + REQ);
104
                this.addView("ID_CLIENT", "1;" + REQ);
78
                this.addView("ID_COMMERCIAL", "1");
105
                this.addView("ID_COMMERCIAL", "1");
79
                this.addView("ID_DEVIS", "1");
106
                this.addView("ID_DEVIS", "1");
80
 
-
 
-
 
107
                if (getTable().contains("ID_SOCIETE_COMMON")) {
-
 
108
                    this.addView("ID_SOCIETE_COMMON", "1");
-
 
109
                }
81
                this.addView("ID_TYPE_AFFAIRE", "1;left");
110
                this.addView("ID_TYPE_AFFAIRE", "1;left");
82
                final ElementComboBox boxEtatAffaire = new ElementComboBox();
111
                final ElementComboBox boxEtatAffaire = new ElementComboBox();
83
                this.addView(boxEtatAffaire, "ID_ETAT_AFFAIRE", "1;left;" + REQ);
112
                this.addView(boxEtatAffaire, "ID_ETAT_AFFAIRE", "1;left;" + REQ);
84
                this.addView(new ITextArea(), "INFOS", "2");
113
                this.addView(new ITextArea(), "INFOS", "2");
85
 
114