<?php
//$Id: grade.class.php,v 1.5 2008-07-29 14:00:45 jbastide Exp $
include ("../dyn/var.inc");
require_once ($path_om."formulairedyn.class.php");
require_once ($path_om."dbformdyn.class.php");
//
class grade extends dbForm
{
    var $table = "grade";
    var $clePrimaire = "grade";
    var $typeCle = "A";

    function grade ($id, $db, $debug)
    {
        $this -> constructeur ($id, $db, $debug);
    } // grade ($id, $db, $debug)

    function verifier ()
    {
        $this -> correct = True;
        $imgv="";
        $f="&nbsp!&nbsp;&nbsp;&nbsp;&nbsp;";
        $imgv="<img src='../img/punaise.png' align='middle'  border='0'>";
        if ($this -> valF ['grade'] == ""){
            $this -> correct = false;
            $this -> msg = $this -> msg .$imgv.$this->lang("code")."&nbsp;".$this->lang("grade")."&nbsp".$this->lang("obligatoire").$f;
        }
        if ($this -> valF ['libelle'] == ""){
            $this -> correct = false;
            $this -> msg = $this -> msg .$imgv.$this->lang("nom")."&nbsp;".$this->lang("grade")."&nbsp".$this->lang("obligatoire").$f;
        }
    } // verifier ()



    function setType (&$form, $maj) 
    {
        if ($maj < 2){
            // Ajout
            if ($maj == 1){
                $form -> setType ('grade', 'hiddenstatic');
                // Modification
            }
        }else{
            $form -> setType ('grade', 'hiddenstatic');
            // Suppression
        }
    } // setType (&$form, $maj) 
function cleSecondaire($id,$db,$val,$debug) {
$this->rechercheAgent($id,$db,$debug) ;
}


function rechercheAgent($id,$db,$debug){
    $this->correct=True;
    $imgv="";
    $f="&nbsp!&nbsp;&nbsp;&nbsp;&nbsp;";
    $imgv="<img src='../img/punaise.png' align='middle'  border='0'>";
    $sql = "select * from agent where grade ='".$id."'";
    $res = $db->query($sql);
    if($debug==1) echo $sql;
    if (DB :: isError($res))
       die($res->getMessage(). " => Echec  ".$sql);
    else{
        $nbligne=$res->numrows();
        $this->msg = $this->msg.$imgv."&nbsp;".$this->lang("il_y_a")."&nbsp;<font class='parametre'>&nbsp;".$nbligne."&nbsp;</font>&nbsp;".
        $this->lang("enregistrement")."&nbsp;".$this->lang("en_lien")."&nbsp;".$this->lang("avec")."&nbsp;".$this->lang("table")." \"agent\" ".$this->lang("pour")."&nbsp;".$this->lang("le")."&nbsp;".$this->lang("grade")."&nbsp; [".
        $id."]".$f."<br>";
        if ($nbligne>0)
           $this->correct=false;
    }
}
}
?>