OpenConcerto

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

svn://code.openconcerto.org/openconcerto

Rev

Rev 174 | Blame | Compare with Previous | Last modification | View Log | RSS feed

/*
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
 * 
 * Copyright 2011 OpenConcerto, by ILM Informatique. All rights reserved.
 * 
 * The contents of this file are subject to the terms of the GNU General Public License Version 3
 * only ("GPL"). You may not use this file except in compliance with the License. You can obtain a
 * copy of the License at http://www.gnu.org/licenses/gpl-3.0.html See the License for the specific
 * language governing permissions and limitations under the License.
 * 
 * When distributing the software, include this License Header Notice in each file.
 */
 
 package org.openconcerto.erp.core.humanresources.payroll.element;

import org.openconcerto.erp.core.common.element.ComptaSQLConfElement;
import org.openconcerto.sql.element.BaseSQLComponent;
import org.openconcerto.sql.element.SQLComponent;
import org.openconcerto.sql.sqlobject.ElementComboBox;
import org.openconcerto.ui.DefaultGridBagConstraints;
import org.openconcerto.ui.JDate;

import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashSet;
import java.util.List;
import java.util.Set;

import javax.swing.JLabel;
import javax.swing.JTextField;
import javax.swing.SwingConstants;

public class ContratSalarieSQLElement extends ComptaSQLConfElement {

    public ContratSalarieSQLElement() {
        super("CONTRAT_SALARIE", "un contrat salarié", "contrats salariés");
    }

    protected List<String> getListFields() {
        final List<String> l = new ArrayList<String>();
        l.add("NATURE");
        return l;
    }

    @Override
    public Set<String> getInsertOnlyFields() {
        Set<String> s = new HashSet<String>();
        s.add("DATE_MODIFICATION");
        return s;
    }

    protected List<String> getComboFields() {
        final List<String> l = new ArrayList<String>();
        l.add("NUMERO");
        l.add("DATE_DEBUT");
        return l;
    }

    @Override
    public boolean isPrivate() {
        return true;
    }

    /*
     * (non-Javadoc)
     * 
     * @see org.openconcerto.devis.SQLElement#getComponent()
     */
    public SQLComponent createComponent() {
        return new BaseSQLComponent(this) {

            public void addViews() {

                this.setLayout(new GridBagLayout());

                GridBagConstraints c = new DefaultGridBagConstraints();

                // Numero
                JLabel labelNumero = new JLabel(getLabelFor("NUMERO"));
                labelNumero.setHorizontalAlignment(SwingConstants.RIGHT);
                JTextField textNumero = new JTextField();

                this.add(labelNumero, c);
                c.gridx++;
                c.weightx = 1;
                this.add(textNumero, c);
                this.addRequiredSQLObject(textNumero, "NUMERO");

                c.gridy++;
                c.gridx = 0;
                // Nature
                JLabel labelNature = new JLabel(getLabelFor("NATURE"));
                labelNature.setHorizontalAlignment(SwingConstants.RIGHT);
                JTextField textNature = new JTextField();

                this.add(labelNature, c);
                c.gridx++;
                c.weightx = 1;
                c.gridwidth = 3;
                this.add(textNature, c);

                c.gridwidth = 1;
                // Catégorie socioprofessionnelle
                JLabel labelCatSocio = new JLabel(getLabelFor("ID_CODE_EMPLOI"));
                labelCatSocio.setHorizontalAlignment(SwingConstants.RIGHT);
                ElementComboBox selCodeCatSocio = new ElementComboBox();
                selCodeCatSocio.setInfoIconVisible(false);
                c.gridy++;
                c.gridx = 0;
                c.weightx = 0;
                this.add(labelCatSocio, c);
                c.gridx++;
                c.weightx = 1;
                this.add(selCodeCatSocio, c);

                JLabel complPCSLabel = new JLabel(getLabelFor("COMPLEMENT_PCS"));
                complPCSLabel.setHorizontalAlignment(SwingConstants.RIGHT);
                JTextField complPCS = new JTextField();
                c.gridx++;
                c.weightx = 0;
                this.add(complPCSLabel, c);
                c.gridx++;
                c.weightx = 1;
                this.add(complPCS, c);
                addView(complPCS, "COMPLEMENT_PCS");

                JLabel objetSpecLabel = new JLabel(getLabelFor("SPECTACLE_OBJET"));
                objetSpecLabel.setHorizontalAlignment(SwingConstants.RIGHT);
                JTextField objetSpec = new JTextField();
                c.gridy++;
                c.gridx = 0;
                c.weightx = 0;
                this.add(objetSpecLabel, c);
                c.gridx++;
                c.weightx = 1;
                this.add(objetSpec, c);
                addView(objetSpec, "SPECTACLE_OBJET");
                objetSpec.setEditable(false);

                JLabel jourContratLabel = new JLabel(getLabelFor("SPECTACLE_JOUR_CONTRAT"));
                jourContratLabel.setHorizontalAlignment(SwingConstants.RIGHT);
                JTextField jourContrat = new JTextField();
                c.gridx++;
                c.weightx = 0;
                this.add(jourContratLabel, c);
                c.gridx++;
                c.weightx = 1;
                this.add(jourContrat, c);
                addView(jourContrat, "SPECTACLE_JOUR_CONTRAT");
                jourContrat.setEditable(false);

                final ElementComboBox selCaractActivite = new ElementComboBox();
                selCaractActivite.setInfoIconVisible(false);
                this.addRequiredSQLObject(selCaractActivite, "ID_CODE_CARACT_ACTIVITE");
                selCaractActivite.addModelListener("wantedID", new PropertyChangeListener() {

                    @Override
                    public void propertyChange(PropertyChangeEvent evt) {
                        final boolean b = selCaractActivite.getSelectedRow() != null && selCaractActivite.getSelectedRow().getString("CODE").equals("04");
                        objetSpec.setEditable(b);
                        jourContrat.setEditable(b);
                        if (!b) {
                            objetSpec.setText("");
                            ;
                            jourContrat.setText("");
                        }
                    }
                });

                // Contrat de travail
                JLabel labelContratTravail = new JLabel(getLabelFor("ID_CODE_CONTRAT_TRAVAIL"));
                labelContratTravail.setHorizontalAlignment(SwingConstants.RIGHT);
                ElementComboBox selContratTravail = new ElementComboBox();
                selContratTravail.setInfoIconVisible(false);
                c.gridy++;
                c.gridx = 0;
                c.weightx = 0;
                this.add(labelContratTravail, c);
                c.gridx++;
                c.weightx = 1;
                this.add(selContratTravail, c);

                // Droit Contrat de travail
                JLabel labelDroitContrat = new JLabel(getLabelFor("ID_CODE_DROIT_CONTRAT"));
                labelDroitContrat.setHorizontalAlignment(SwingConstants.RIGHT);
                ElementComboBox selDroitContrat = new ElementComboBox();
                selDroitContrat.setInfoIconVisible(false);
                c.gridx++;
                c.weightx = 0;
                this.add(labelDroitContrat, c);
                c.gridx++;
                c.weightx = 1;
                this.add(selDroitContrat, c);

                // caracteristiques activité
                JLabel labelCaractActivite = new JLabel(getLabelFor("ID_CODE_CARACT_ACTIVITE"));
                labelCaractActivite.setHorizontalAlignment(SwingConstants.RIGHT);

                c.gridy++;
                c.gridx = 0;
                c.weightx = 0;
                this.add(labelCaractActivite, c);
                c.gridx++;
                c.weightx = 1;
                this.add(selCaractActivite, c);

                // Statut profesionnel
                JLabel labelStatutProf = new JLabel(getLabelFor("ID_CODE_STATUT_PROF"));
                labelStatutProf.setHorizontalAlignment(SwingConstants.RIGHT);
                ElementComboBox selStatutProf = new ElementComboBox();
                selStatutProf.setInfoIconVisible(false);
                c.gridx++;
                c.weightx = 0;
                this.add(labelStatutProf, c);
                c.gridx++;
                c.weightx = 1;
                this.add(selStatutProf, c);

                // Statut categoriel
                JLabel labelStatutCat = new JLabel(getLabelFor("ID_CODE_STATUT_CATEGORIEL"));
                labelStatutCat.setHorizontalAlignment(SwingConstants.RIGHT);
                ElementComboBox selStatutCat = new ElementComboBox();
                selStatutCat.setInfoIconVisible(false);
                c.gridy++;
                c.gridx = 0;
                c.weightx = 0;
                this.add(labelStatutCat, c);
                c.gridx++;
                c.weightx = 1;
                this.add(selStatutCat, c);

                // Statut categoriel
                JLabel labelStatutCatConv = new JLabel(getLabelFor("ID_CODE_STATUT_CAT_CONV"));
                labelStatutCatConv.setHorizontalAlignment(SwingConstants.RIGHT);
                ElementComboBox selStatutCatConv = new ElementComboBox();
                selStatutCatConv.setInfoIconVisible(false);
                c.gridx++;
                c.weightx = 0;
                this.add(labelStatutCatConv, c);
                c.gridx++;
                c.weightx = 1;
                this.add(selStatutCatConv, c);

                List<String> dsnFF = Arrays.asList("ID_CONTRAT_MODALITE_TEMPS", "ID_CONTRAT_REGIME_MALADIE", "ID_CONTRAT_REGIME_VIEILLESSE", "ID_CONTRAT_DETACHE_EXPATRIE",
                        "ID_CONTRAT_DISPOSITIF_POLITIQUE", "ID_CONTRAT_MOTIF_RECOURS");
                int p = 0;
                for (String ffName : dsnFF) {
                    JLabel labelFF = new JLabel(getLabelFor(ffName));
                    labelFF.setHorizontalAlignment(SwingConstants.RIGHT);
                    ElementComboBox selFF = new ElementComboBox();
                    selFF.setInfoIconVisible(false);
                    if (p % 2 == 0) {
                        c.gridy++;
                        c.gridx = 0;
                    } else {
                        c.gridx++;
                    }
                    p++;
                    c.weightx = 0;
                    this.add(labelFF, c);
                    c.gridx++;
                    c.weighty = 1;
                    c.weightx = 1;
                    this.add(selFF, c);
                    if (ffName.equals("ID_CONTRAT_MOTIF_RECOURS")) {
                        this.addSQLObject(selFF, ffName);
                    } else {
                        this.addRequiredSQLObject(selFF, ffName);
                    }
                }

                // Code Arrco, agirc retirés du contrat et ajoutés dans les caisses de cotisations

                // Code UGRR

                // JLabel labelCodeUGRR = new JLabel(getLabelFor("CODE_IRC_UGRR"));
                // labelCodeUGRR.setHorizontalAlignment(SwingConstants.RIGHT);
                // JTextField textCodeUGRR = new JTextField();
                // c.gridy++;
                // c.gridx = 0;
                // c.weightx = 0;
                // this.add(labelCodeUGRR, c);
                // c.gridx++;
                // c.weighty = 1;
                // c.weightx = 1;
                // this.add(textCodeUGRR, c);
                // addView(textCodeUGRR, "CODE_IRC_UGRR");
                //
                // JLabel labelNumUGRR = new JLabel(getLabelFor("NUMERO_RATTACHEMENT_UGRR"));
                // labelNumUGRR.setHorizontalAlignment(SwingConstants.RIGHT);
                // JTextField textNumUGRR = new JTextField();
                // c.gridy++;
                // c.gridx = 0;
                // c.weightx = 0;
                // this.add(labelNumUGRR, c);
                // c.gridx++;
                // c.weighty = 1;
                // c.weightx = 1;
                // this.add(textNumUGRR, c);
                // addView(textNumUGRR, "NUMERO_RATTACHEMENT_UGRR");
                //
                // // Code UGRC
                // JLabel labelCodeUGRC = new JLabel(getLabelFor("CODE_IRC_UGRC"));
                // labelCodeUGRC.setHorizontalAlignment(SwingConstants.RIGHT);
                // JTextField textCodeUGRC = new JTextField();
                // c.gridy++;
                // c.gridx = 0;
                // c.weightx = 0;
                // this.add(labelCodeUGRC, c);
                // c.gridx++;
                // c.weighty = 1;
                // c.weightx = 1;
                // this.add(textCodeUGRC, c);
                // addView(textCodeUGRC, "CODE_IRC_UGRC");
                //
                // JLabel labelNumUGRC = new JLabel(getLabelFor("NUMERO_RATTACHEMENT_UGRC"));
                // labelNumUGRC.setHorizontalAlignment(SwingConstants.RIGHT);
                // JTextField textNumUGRC = new JTextField();
                // c.gridy++;
                // c.gridx = 0;
                // c.weightx = 0;
                // this.add(labelNumUGRC, c);
                // c.gridx++;
                // c.weighty = 1;
                // c.weightx = 1;
                // this.add(textNumUGRC, c);
                // addView(textNumUGRC, "NUMERO_RATTACHEMENT_UGRC");
                //
                // // Retraite
                // JLabel labelCodeRetraite = new JLabel(getLabelFor("CODE_IRC_RETRAITE"));
                // labelCodeRetraite.setHorizontalAlignment(SwingConstants.RIGHT);
                // JTextField textCodeRetraite = new JTextField();
                // c.gridy++;
                // c.gridx = 0;
                // c.weightx = 0;
                // this.add(labelCodeRetraite, c);
                // c.gridx++;
                // c.weighty = 1;
                // c.weightx = 1;
                // this.add(textCodeRetraite, c);
                // addView(textCodeRetraite, "CODE_IRC_RETRAITE");
                //
                // JLabel labelNumRetraite = new
                // JLabel(getLabelFor("NUMERO_RATTACHEMENT_RETRAITE"));
                // labelNumRetraite.setHorizontalAlignment(SwingConstants.RIGHT);
                // JTextField textNumRetraite = new JTextField();
                // c.gridy++;
                // c.gridx = 0;
                // c.weightx = 0;
                // this.add(labelNumRetraite, c);
                // c.gridx++;
                // c.weighty = 1;
                // c.weightx = 1;
                // this.add(textNumRetraite, c);
                // addView(textNumRetraite, "NUMERO_RATTACHEMENT_RETRAITE");

                // JLabel labelCodeRegimeRetraite = new
                // JLabel(getLabelFor("CODE_REGIME_RETRAITE_DSN"));
                // labelCodeRegimeRetraite.setHorizontalAlignment(SwingConstants.RIGHT);
                // JTextField textCodeRegimeRetraite = new JTextField();
                // c.gridy++;
                // c.gridx = 0;
                // c.weightx = 0;
                // this.add(labelCodeRegimeRetraite, c);
                // c.gridx++;
                // c.weighty = 1;
                // c.weightx = 1;
                // this.add(textCodeRegimeRetraite, c);
                // addRequiredSQLObject(textCodeRegimeRetraite, "CODE_REGIME_RETRAITE_DSN");

                // JLabel labelDateModif = new JLabel(getLabelFor("DATE_MODIFICATION"));
                // labelDateModif.setHorizontalAlignment(SwingConstants.RIGHT);
                // JDate textDateModif = new JDate();
                // c.gridy++;
                // c.gridx = 0;
                // c.weightx = 0;
                // this.add(textDateModif, c);
                // c.gridx++;
                // c.weighty = 1;
                // c.weightx = 1;
                // this.add(textDateModif, c);
                // addSQLObject(textDateModif, "DATE_MODIFICATION");

                // JLabel labelCM = new JLabel(getLabelFor("ID_INFOS_SALARIE_PAYE_MODIFIE"));
                // labelCM.setHorizontalAlignment(SwingConstants.RIGHT);
                // ElementComboBox selCM = new ElementComboBox();
                // final SQLElement elementInfosPaye =
                // getDirectory().getElement("INFOS_SALARIE_PAYE");
                // selCM.init(elementInfosPaye, elementInfosPaye.createComboRequest());
                // selCM.setInfoIconVisible(false);
                // c.gridy++;
                // c.gridx = 0;
                // c.weightx = 0;
                // this.add(labelCM, c);
                // c.gridx++;
                // c.weighty = 1;
                // c.weightx = 1;
                // this.add(selCM, c);
                // this.addSQLObject(selCM, "ID_INFOS_SALARIE_PAYE_MODIFIE");

                JLabel labelDateDebut = new JLabel(getLabelFor("DATE_DEBUT"));
                labelDateDebut.setHorizontalAlignment(SwingConstants.RIGHT);
                JDate textDateDebut = new JDate();
                c.gridy++;
                c.gridx = 0;
                c.weightx = 0;
                this.add(labelDateDebut, c);
                c.gridx++;
                c.weightx = 1;
                this.add(textDateDebut, c);
                addSQLObject(textDateDebut, "DATE_DEBUT", REQ);

                JLabel labelDateFin = new JLabel(getLabelFor("DATE_PREV_FIN"));
                labelDateFin.setHorizontalAlignment(SwingConstants.RIGHT);
                JDate textDateFin = new JDate();
                c.gridx++;
                c.weightx = 0;
                this.add(labelDateFin, c);
                c.gridx++;
                c.weightx = 1;
                this.add(textDateFin, c);
                addSQLObject(textDateFin, "DATE_PREV_FIN");

                JLabel labelAmen = new JLabel(getLabelFor("ID_CODE_AMENAGEMENT_PARTIEL"));
                labelAmen.setHorizontalAlignment(SwingConstants.RIGHT);
                ElementComboBox selAmen = new ElementComboBox();
                selAmen.setInfoIconVisible(false);
                c.gridy++;
                c.gridx = 0;
                c.weightx = 0;
                this.add(labelAmen, c);
                c.gridx++;
                c.weightx = 1;
                this.add(selAmen, c);
                this.addSQLObject(selAmen, "ID_CODE_AMENAGEMENT_PARTIEL");

                JLabel labelSupsension = new JLabel(getLabelFor("ID_CODE_SUSPENSION"));
                labelSupsension.setHorizontalAlignment(SwingConstants.RIGHT);
                ElementComboBox selSupsension = new ElementComboBox();
                selSupsension.setInfoIconVisible(false);
                c.gridx++;
                c.weightx = 0;
                this.add(labelSupsension, c);
                c.gridx++;
                c.weightx = 1;
                this.add(selSupsension, c);
                this.addSQLObject(selSupsension, "ID_CODE_SUSPENSION");

                JLabel labelDateDebutSusp = new JLabel(getLabelFor("DATE_DEBUT_SUSPENSION"));
                labelDateDebutSusp.setHorizontalAlignment(SwingConstants.RIGHT);
                JDate textDateDebutSups = new JDate();
                c.gridy++;
                c.gridx = 0;
                c.weightx = 0;
                this.add(labelDateDebutSusp, c);
                c.gridx++;
                c.weightx = 1;
                this.add(textDateDebutSups, c);
                this.addSQLObject(textDateDebutSups, "DATE_DEBUT_SUSPENSION");

                JLabel labelDateFinSups = new JLabel(getLabelFor("DATE_FIN_SUSPENSION"));
                labelDateFinSups.setHorizontalAlignment(SwingConstants.RIGHT);
                JDate textDateFinSuspension = new JDate();
                c.gridx++;
                c.weightx = 0;
                this.add(labelDateFinSups, c);
                c.gridx++;
                c.weightx = 1;
                this.add(textDateFinSuspension, c);
                this.addSQLObject(textDateFinSuspension, "DATE_FIN_SUSPENSION");

                this.addRequiredSQLObject(selCodeCatSocio, "ID_CODE_EMPLOI");
                this.addRequiredSQLObject(selContratTravail, "ID_CODE_CONTRAT_TRAVAIL");
                this.addRequiredSQLObject(selDroitContrat, "ID_CODE_DROIT_CONTRAT");
                this.addRequiredSQLObject(selStatutProf, "ID_CODE_STATUT_PROF");
                this.addRequiredSQLObject(selStatutCat, "ID_CODE_STATUT_CATEGORIEL");
                this.addRequiredSQLObject(selStatutCatConv, "ID_CODE_STATUT_CAT_CONV");
                this.addRequiredSQLObject(textNature, "NATURE");
            }
        };
    }

    @Override
    protected String createCode() {
        return createCodeOfPackage() + ".contract.employe";
    }
}