<?php
/**
 *
 *
 * @package opencimetiere
 * @version SVN : $Id$
 */

//
require_once "../gen/obj/courrier.class.php";

class courrier extends courrier_gen {

    function courrier($id, &$db, $debug) {
        //
        $this->constructeur($id, $db, $debug);
        // XXX Modifier la base de données en conséquence ?
        $this->required_field[] = "lettretype";
    }

    function setType(&$form,$maj) {
        //
        parent::setType($form,$maj);
        // Affichage de l'id de la table dans tous les cas
        $form->setType('courrier', 'hiddenstatic');
        // On cache l'id de l'emplacement dans tous les cas
        $form->setType('emplacement', 'hidden');
        //
        if ($maj == 0 || $maj == 1) {
            $form->setType('lettretype', 'select');
        }
        //
        if ($maj == 3) {
            $form->setType('lettretype', 'selectstatic');
        }
    }

    function setValsousformulaire(&$form,$maj,$validation,$idxformulaire,$retourformulaire,$typeformulaire,&$db,$DEBUG=null){
        //
        parent::setValsousformulaire($form, $maj, $validation, $idxformulaire, $retourformulaire, $typeformulaire, $db, $DEBUG);
        //
        if ($validation == 0) {
            //
            if ($maj == 0) {
                // Affichage de l'id de la table avec la valeur [...]
                $form->setVal('courrier', "[...]");
                // 
                $form->setVal('emplacement', $idxformulaire);
                //
                $form->setVal('datecourrier', date('Y-m-d'));
            }
        }
    }

    function setSelect(&$form, $maj,$db,$debug) {
        //
        parent::setSelect($form, $maj,$db,$debug);
        //
        if(file_exists ("../sql/".$db->phptype."/".$this->table.".form.inc.php")) {
            include ("../sql/".$db->phptype."/".$this->table.".form.inc.php");
        } elseif(file_exists ("../sql/".$db->phptype."/".$this->table.".form.inc")) {
            include ("../sql/".$db->phptype."/".$this->table.".form.inc");
        }
        //
        $this->init_select($form, $db, $maj, $debug, "lettretype",
                           $sql_om_lettretype, $sql_om_lettretype_by_id, false);
    }

    function setLib(&$form,$maj) {
        //
        parent::setLib($form,$maj);
        //
        $form->setLib('courrier', _("id"));
    }

   function setLayout(&$form, $maj) {
        //
        $bloc_global_width_full = "span12";
        $bloc_global_width_half = "span6";

        //// CONTAINER GLOBAL - START
        $this->form->setBloc("courrier", "D", "", "emplacement-form travaux-form form-action-".$maj);

        //// LIGNE ID - START
        $this->form->setBloc("courrier", "D", "", "row-fluid");
            //// BLOC ID - START
            $this->form->setBloc("courrier", "D", "", $bloc_global_width_full." emplacement-bloc emplacement-bloc-identification ");
                //// BLOC ID - START
                $this->form->setBloc("courrier", "D", "", "span12");
                $this->form->setBloc("emplacement", "F");
                //// BLOC ID - END
            $this->form->setBloc("emplacement", "F");
            //// BLOC ID - END
        $this->form->setBloc("emplacement", "F");
        //// LIGNE ID - END

        //// CONTAINER GLOBAL - END
        $this->form->setBloc("complement", "F");
    }

}

?>
