<?php
/*
$Id: modeleperipherique.class.php,v 1.4 2008-02-27 09:44:31 fgiva Exp $
*/
require_once ("formulaire.class.php");
require_once ("modeleelement.class.php");

class modeleperipherique extends modeleelement {

function modeleperipherique($id,&$db,$DEBUG,$nature) {
  $this->constructeur($id,$db,$DEBUG);
  $this->nature=$nature;
  $this->classe="peripherique";
} // fin constructeur

function setvalF($val){
  parent::setvalF($val);
  switch ($this->nature) {
  case "appareilphoto":
    $this->valF['format'] = $val['format'];
    $this->valF['taille'] = $val['taille'];
    $this->valF['integre'] = $val['integre'];
    break;
  case "clavier":
    $this->valF['typecomp'] = $val['typecomp'];
    $this->valF['reseau'] = $val['reseau'];
    break;
  case "copieur":
    $this->valF['couleur'] = $val['couleur'];
    $this->valF['reseau'] = "v";
    break;
  case "ecran":
    $this->valF['integre'] = $val['integre'];
  case "enceintes":
  case "memoireflash":
  case "disqueext":
  case "hubusb":
    $this->valF['taille'] = $val['taille'];
    $this->valF['typecomp'] = $val['typecomp'];
    break;
  case "imprimante":
    $this->valF['typecomp'] = $val['typecomp'];
    $this->valF['couleur'] = $val['couleur'];
    $this->valF['reseau'] = $val['reseau'];
  case "scanner":
    $this->valF['format'] = $val['format'];
  case "tablette":
    $this->valF['connecteur'] = $val['connecteur'];
    break;
  case "lecteurzip":
    $this->valF['connecteur'] = $val['connecteur'];
    $this->valF['taille'] = $val['taille'];
    $this->valF['format'] = $val['format'];
    break;
  case "organiseur":
    $this->valF['taille'] = $val['taille'];
    $this->valF['connecteur'] = $val['connecteur'];
    $this->valF['frequence'] = $val['frequence'];
    $this->valF['vitesse'] = $val['vitesse'];
    break;
  case "souris":
    $this->valF['typecomp'] = $val['typecomp'];
    $this->valF['connecteur'] = $val['connecteur'];
    $this->valF['integre'] = $val['integre'];
  case "stationaccueil":
  case "lecteurcarte":
    $this->valF['typecomp'] = $val['typecomp'];
    break;
  }
}

function setType(&$form,$maj) {
  parent::setType($form,$maj);  //sans& 
  if ($maj < 2) { //ajouter et modifier
    switch ($this->nature) {
    case "appareilphoto":
      $form->setType('format','select');
      $form->setType('taille','select');
      $form->setType('integre','select');
      break;
    case "clavier":
    case "lecteurcarte":
      $form->setType('typecomp','select');
      break;
    case "copieur":
      $form->setType('couleur', 'select');
      break;
    case "ecran":
      $form->setType('integre','select');
    case "memoireflash":
    case "hubusb":
      $form->setType('taille','select');
      $form->setType('typecomp','select');
      break;    
    case "enceintes":
    case "disqueext":
      $form->setType('taille','text');
      $form->setType('typecomp','select');
      break;    
    case "imprimante":
      $form->setType('typecomp','select');
      $form->setType('couleur','select');
      $form->setType('reseau','select');
    case "scanner":
      $form->setType('connecteur','select');
    case "tablette":
      $form->setType('format','select');
      break;    
    case "lecteurzip":
      $form->setType('taille','select');
      $form->setType('connecteur','select');
      $form->setType('format','select');
      break;    
    case "organiseur":
      $form->setType('taille','select');
      $form->setType('connecteur','select');
      $form->setType('frequence','select');
      $form->setType('vitesse','select');
      break;    
    case "souris":
      $form->setType('typecomp','select');
      $form->setType('connecteur','select');
      $form->setType('integre','select');
    case "stationaccueil":
      $form->setType('typecomp','select');
      break;    
    }
  }
}

function setSelect(&$form, $maj,$db,$debug) {
//  include ("../dyn/connexion.php");
//  include ("../sql/".$dsn['phptype']."/".$this->table.".form.inc");
  parent::setSelect($form, $maj,$db,$debug);  //sans& 
  if($maj<2){
    $contenuON=array();
    $contenuON[0]=array('f','v');
    $contenuON[1]=array('Non','Oui');
    switch ($this->nature) {
    case "appareilphoto":
      $contenu=array();
      $contenu[0]=array('SD','CF','MS','XD','MC');
      $contenu[1]=array('SD Card','CompactFlash','Memory Stick','XD Card','Multimedia Card');
      $form->setSelect("format",$contenu);
      $contenu=array();
      $contenu[0]=array(1,2,3,4,5,6,7,8);
      $contenu[1]=array('1','2','3','4','5','6','7','8');
      $form->setSelect("taille",$contenu);
      $form->setSelect("integre",$contenuON);
      break;
    case "clavier":
      $contenu=array();
      $contenu[0]=array('PS2','DIN','Sans fil','USB');
      $contenu[1]=array('PS2','DIN','Sans fil','USB');
      $form->setSelect("typecomp",$contenu);
      break;
    case "copieur":
      $form->setSelect("couleur",$contenuON);
      break;
    case "ecran":
      $contenu=array();
      $contenu[0]=array('CRT','LCD');
      $contenu[1]=array('CRT','LCD');
      $form->setSelect("typecomp",$contenu);
      $contenu=array();
      $contenu[0]=array(14,15,17,19,21);
      $contenu[1]=array('14','15','17','19','21');
      $form->setSelect("taille",$contenu);
      $form->setSelect("integre",$contenuON);
      break;    
    case "enceintes":
      $contenu=array();
      $contenu[0]=array('Haut-parleurs','Pied Multimédia');
      $contenu[1]=array('Haut-parleurs','Pied Multimédia');
      $form->setSelect("typecomp",$contenu);
      break;    
    case "imprimante":
      $contenu=array();
      $contenu[0]=array('Encre','Laser','Traceur');
      $contenu[1]=array('Encre','Laser','Traceur');
      $form->setSelect("typecomp",$contenu);
      $form->setSelect("couleur",$contenuON);
      $form->setSelect("reseau",$contenuON);
    case "scanner":
      $contenu=array();
      $contenu[0]=array('USB','DB15','USB-DB15');
      $contenu[1]=array('USB','DB15','USB-DB15');
      $form->setSelect("connecteur",$contenu);
    case "tablette":
      $contenu=array();
      $contenu[0]=array('A4','A3','A2','A1');
      $contenu[1]=array('A4','A3','A2','A1');
      $form->setSelect("format",$contenu);
      break;    
    case "lecteurcarte":
      $contenu=array();
      $contenu[0]=array('Tous','SD Card','CompactFlash','Memory Stick','XD Card','Multimedia Card');
      $contenu[1]=array('Tous','SD Card','CompactFlash','Memory Stick','XD Card','Multimedia Card');
      $form->setSelect("typecomp",$contenu);
      break;
    case "lecteurzip":
      $contenu=array();
      $contenu[0]=array(100,250,500,750);
      $contenu[1]=array(100,250,500,750);
      $form->setSelect("taille",$contenu);
      $contenu=array();
      $contenu[0]=array('DB15','IDE','Firewire','USB','USB2');
      $contenu[1]=array('DB15','IDE','Firewire','USB','USB2');
      $form->setSelect("connecteur",$contenu);
      $contenu=array();
      $contenu[0]=array('3.5','5.25');
      $contenu[1]=array('3.5','5.25');
      $form->setSelect("format",$contenu);
      break;    
    case "disqueext":
      $contenu=array();
      $contenu[0]=array('DisqueEthernet','DisqueUSB');
      $contenu[1]=array('DisqueEthernet','DisqueUSB');
      $form->setSelect("typecomp",$contenu);
      break;
    case "memoireflash":
      $contenu=array();
      $contenu[0]=array('CleUSB','CleUSB2','Bluetooth','Wifi','SD Card','CompactFlash','Memory Stick','XD Card','Multimedia Card');
      $contenu[1]=array('CleUSB','CleUSB2','Bluetooth','Wifi','SD Card','CompactFlash','Memory Stick','XD Card','Multimedia Card');
      $form->setSelect("typecomp",$contenu);
      $contenu=array();
      $contenu[0]=array(32,64,128,256,512,1024,2048,4096);
      $contenu[1]=array(32,64,128,256,512,1024,2048,4096);
      $form->setSelect("taille",$contenu);
      break;    
    case "organiseur":
      $contenu=array();
      $contenu[0]=array(0,266,300,312,333,366,400,416);
      $contenu[1]=array(0,266,300,312,333,366,400,416);
      $form->setSelect("frequence",$contenu);
      $contenu=array();
      $contenu[0]=array(0,16,32,64,128,256);
      $contenu[1]=array(0,16,32,64,128,256);
      $form->setSelect("taille",$contenu);
      $contenu=array();
      $contenu[0]=array(0,16,32,64,128,256);
      $contenu[1]=array(0,16,32,64,128,256);
      $form->setSelect("vitesse",$contenu);
      $contenu=array();
      $contenu[0]=array('USB','USB2','WiFi','Bluetooth');
      $contenu[1]=array('USB','USB2','WiFi','Bluetooth');
      $form->setSelect("connecteur",$contenu);
      break;    
    case "souris":
      $contenu=array();
      $contenu[0]=array('Boule','Optique');
      $contenu[1]=array('Boule','Optique');
      $form->setSelect("typecomp",$contenu);
      $contenu=array();
      $contenu[0]=array('PS2','DB9','Sans fil','USB');
      $contenu[1]=array('PS2','DB9','Sans fil','USB');
      $form->setSelect("connecteur",$contenu);
      $form->setSelect("integre",$contenuON);
      break;    
    case "stationaccueil":
      $contenu=array();
      $contenu[0]=array('PDA','Portable','APN');
      $contenu[1]=array('PDA','Portable','APN');
      $form->setSelect("typecomp",$contenu);
      break;    
    case "hubusb":
      $contenu=array();
      $contenu[0]=array('USB','USB2','FireWire');
      $contenu[1]=array('USB','USB2','FireWire');
      $form->setSelect("typecomp",$contenu);
      $contenu=array();
      $contenu[0]=array(2,3,4,5,6,7,8);
      $contenu[1]=array('2','3','4','5','6','7','8');
      $form->setSelect("taille",$contenu);
      break;    
    }
  }
}
    
function setLib(&$form,$maj) {
  parent::setLib($form,$maj);  //sans& 
  switch ($this->nature) {
  case "appareilphoto":
    $form->setLib('format','Mémoire flash');
    $form->setLib('taille','Megapixel(s)');
    $form->setLib('integre','Batterie');
    break;
  case "ecran":
    $form->setLib('integre','Haut-parleurs');
    break;  
  case "enceintes":
    $form->setLib('taille','Puissance');
    break;  
  case "lecteurzip":
  case "memoireflash":
    $form->setLib('taille','Capacité');
    break;  
  case "disqueext":
    $form->setLib('taille','Taille (Go)');
    break;  
  case "organiseur":
    $form->setLib('taille','RAM Mo');
    $form->setLib('vitesse','ROM Mo');
    break;  
  case "souris":
    $form->setLib('integre','Roulette');
    break;  
  case "hubusb":
    $form->setLib('taille','Nb ports');
    break;  
  }
}

function verifier(){
  // obligatoire
  parent::verifier(); 
  switch ($this->nature) {
  case "enceintes":
    if (!is_numeric($this->valF['taille'])){
      $this->correct=false;
      $this->msg= $this->msg."<br>Numérique obligatoire";
    }
    break;
  }
}

}// fin de classe
?>