<?php
/*
$Id: reseau.class.php,v 1.5 2008-04-04 14:58:42 fgiva Exp $
*/
require_once ("formulaire.class.php");
require_once ("peripherique.class.php");

class reseau extends peripherique {

function reseau($id,&$db,$DEBUG) {
$this->constructeur($id,$db,$DEBUG);
} // fin constructeur

function setVal(&$form,$maj,$validation,&$db){
include ("../dyn/connexion.php");
include ("../sql/".$dsn['phptype']."/".$this->table.".form.inc");
parent::setVal($form,$maj,$validation,$db);
if ($maj == 0){
  if ($validation==0) {
    //numero imposé non modifiable
    $form->setVal('numero', $this->numero);  
  }
} 
}

function setvalF($val){
  parent::setvalF($val);
  $this->valF['numero'] = $val['numero'];  //ajout 
  $this->valF['nomelement'] = $val['nomelement'];
  $this->valF['idbatiment'] = $val['idbatiment'];        //
  $this->valF['adressemac'] = $val['adressemac'];
}

function setType(&$form,$maj) {
  parent::setType($form,$maj); 
  $form->setType('numero', 'hiddenstatic'); //numero obligatoire et non personnalisable
  if ($maj < 2) { //ajouter et modifier  
    $form->setType('nomelement', 'text');
    $form->setType('idbatiment', 'select');
    $form->setType('adressemac', 'text');
  }
}

function setSelect(&$form, $maj,$db,$debug) {
  include ("../dyn/connexion.php");
  include ("../sql/".$dsn['phptype']."/".$this->table.".form.inc");
  parent::setSelect($form, $maj,$db,$debug);
  if($maj<2){
    if ($maj==0) {
      $contenu="";                                 
      $contenu[0]=$modele[0][get_class($this)];  
      $contenu[1]=$modele[1][get_class($this)];  
      $form->setSelect("typeelement",$contenu);
    }
/*    if ($maj==1) {  //si maj à 1 seulement (car sinon typeelement="")
      $modeleelement=$this->val[array_search('typeelement', $this->champs)];
      $sql= str_replace("%MODELE%",$modeleelement,$sql_autremodele);
      $form->setSelect("idmodele",$this->selectArray($db,$sql,0," Choisir un modèle"));
    }*/
    $form->setSelect("idbatiment",$this->selectArray($db,$sql_batiment,0," Aucun"));
  }
}

function setLib(&$form,$maj) {
  parent::setLib($form,$maj);
  $form->setLib('nomelement','Nom Element');
  $form->setLib('idbatiment','Batiment');
  $form->setLib('adressemac','Adresse MAC');
}

function verifier(&$db){
  parent::verifier($db);
  // obligatoire
  if($this->valF['numserie']=="") { //en plus du numero imposé
    $this->correct=false;
    $this->msg= $this->msg."<br>NoSérie obligatoire";
  }
  if ($this->valF['idbatiment']==0 && $this->valF['idetatelement']==1){
     $this->correct=false;
     $this->msg= $this->msg."<br>Batiment obligatoire";
  }
}//verifier
 
function setRegroupe(&$form,$maj,&$db,$idx){
  parent::setRegroupe($form,$maj,$db,$idx);
  if ($maj<2) {
    $form->setRegroupe('idbatiment','D','Affectation');
    $form->setRegroupe('idetatelement','F','');
  }
  $form->setRegroupe('nomelement','D','Options');
  $form->setRegroupe('adressemac','F','');
}
}// fin de classe
?>