OpenConcerto

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

svn://code.openconcerto.org/openconcerto

Rev

Blame | Last modification | View Log | RSS feed

/*
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
 * 
 * Copyright 2011-2019 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.SQLRequestComboBox;
import org.openconcerto.ui.DefaultGridBagConstraints;
import org.openconcerto.ui.JDate;
import org.openconcerto.utils.ListMap;

import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.util.ArrayList;
import java.util.List;

import javax.swing.BorderFactory;
import javax.swing.JLabel;
import javax.swing.JPanel;

public class ArretChomageIntemperieSQLElement extends ComptaSQLConfElement {

    public ArretChomageIntemperieSQLElement() {
        super("ARRET_CHOMAGE_INTEMPERIE", "un arrêt chômage ou intempéries", "arrêts chômages ou intempéries");
    }

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

    protected List<String> getComboFields() {
        final List<String> l = new ArrayList<String>();
        l.add("ID_INFOS_SALARIE_PAYE");
        l.add("ID_CODE_AMENAGEMENT_PARTIEL");
        l.add("DATE_DEBUT_SUSPENSION");
        l.add("DATE_FIN_SUSPENSION");
        return l;
    }

    @Override
    public ListMap<String, String> getShowAs() {

        ListMap<String, String> map = new ListMap<String, String>();
        map.addAll(null, "ID_INFOS_SALARIE_PAYE", "ID_CODE_AMENAGEMENT_PARTIEL", "DATE_DEBUT_SUSPENSION", "DATE_FIN_SUSPENSION");
        map.addAll("ID_INFOS_SALARIE_PAYE", "ID_CONTRAT_SALARIE");
        map.addAll("ID_CODE_AMENAGEMENT_PARTIEL", "CODE");

        return map;
    }

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

            public void addViews() {

                this.setLayout(new GridBagLayout());
                final GridBagConstraints c = new DefaultGridBagConstraints();

                /***********************************************************************************
                 * Renseignements
                 **********************************************************************************/
                JPanel panelInfos = new JPanel();
                panelInfos.setBorder(BorderFactory.createTitledBorder("Renseignements (S21.G00.65)"));
                panelInfos.setLayout(new GridBagLayout());

                // Nom
                JLabel labelContratSalarie = new JLabel(getLabelFor("ID_INFOS_SALARIE_PAYE"));
                SQLRequestComboBox textContratSalarie = new SQLRequestComboBox();
                // c.gridx++;
                c.weightx = 0;
                panelInfos.add(labelContratSalarie, c);
                c.gridx++;
                c.weightx = 1;
                panelInfos.add(textContratSalarie, c);
                this.addView(textContratSalarie, "ID_INFOS_SALARIE_PAYE", REQ);
                c.weightx = 0;

                // Ref
                JLabel labelMotif = new JLabel(getLabelFor("ID_CODE_AMENAGEMENT_PARTIEL"));
                SQLRequestComboBox comboMotif = new SQLRequestComboBox();
                c.gridx = 0;
                c.gridy++;
                panelInfos.add(labelMotif, c);
                c.gridx++;
                c.weightx = 1;
                panelInfos.add(comboMotif, c);
                this.addView(comboMotif, "ID_CODE_AMENAGEMENT_PARTIEL", REQ);
                c.weightx = 0;

                // Nom
                JLabel labelCodeSuspension = new JLabel(getLabelFor("ID_CODE_SUSPENSION"));
                SQLRequestComboBox textCodeSupension = new SQLRequestComboBox();
                c.gridx++;
                c.weightx = 0;
                panelInfos.add(labelCodeSuspension, c);
                c.gridx++;
                c.weightx = 1;
                panelInfos.add(textCodeSupension, c);
                this.addView(textCodeSupension, "ID_CODE_SUSPENSION", REQ);

                // Deb
                JLabel labelDateDeb = new JLabel(getLabelFor("DATE_DEBUT_SUSPENSION"));
                JDate dateDeb = new JDate();
                c.gridx = 0;
                c.gridy++;
                c.weightx = 0;
                panelInfos.add(labelDateDeb, c);
                c.gridx++;
                c.weightx = 1;
                panelInfos.add(dateDeb, c);
                this.addSQLObject(dateDeb, "DATE_DEBUT_SUSPENSION", REQ);
                c.weightx = 0;
                // Fin
                JLabel labelDateFin = new JLabel(getLabelFor("DATE_FIN_SUSPENSION"));
                JDate dateFin = new JDate();
                c.gridx++;
                panelInfos.add(labelDateFin, c);
                c.gridx++;
                c.weightx = 1;
                panelInfos.add(dateFin, c);
                this.addSQLObject(dateFin, "DATE_FIN_SUSPENSION", REQ);

                c.gridx = 0;
                c.gridy++;
                c.fill = GridBagConstraints.BOTH;
                c.weightx = 1;
                c.weighty = 1;
                this.add(panelInfos, c);

            }

        };
    }

    @Override
    protected String createCodeSuffix() {
        return ".suspension.contract";
    }

}