<?php
/*
$Id: modelecomposant.class.php,v 1.1 2006-05-16 18:44:59 fgiva Exp $
*/
require_once ("formulaire.class.php");
require_once ("modeleelement.class.php");

class modelecomposant extends modeleelement {

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

function setvalF($val){
  parent::setvalF($val);
  switch ($this->nature) {
  case "cartemere":
    $this->valF['nbpci'] = $val['nbpci'];
    $this->valF['nbpcie'] = $val['nbpcie'];
    $this->valF['nbagp'] = $val['nbagp'];
    $this->valF['nbbank'] = $val['nbbank'];
    $this->valF['connecteur'] = $val['connecteur'];
    $this->valF['rank'] = 0;
    break;
  case "cartereseau":
    $this->valF['chemin'] = $val['chemin'];
    $this->valF['typecomp'] = $val['typecomp'];
    $this->valF['integre'] = $val['integre'];
    $this->valF['vitesse'] = $val['vitesse'];
    $this->valF['connecteur'] = $val['connecteur'];
    $this->valF['rank'] = 8;
    break;
  case "carteson":
    $this->valF['typecomp'] = $val['typecomp'];
    $this->valF['chemin'] = $val['chemin'];
    $this->valF['integre'] = $val['integre'];
    $this->valF['rank'] = 7;
    break;
  case "cartevideo":
    $this->valF['typecomp'] = $val['typecomp'];
    $this->valF['taille'] = $val['taille'];
    $this->valF['chemin'] = $val['chemin'];
    $this->valF['connecteur'] = $val['connecteur'];
    $this->valF['rank'] = 6;
    break;
  case "disquedur":
    $this->valF['taille'] = $val['taille'];
    $this->valF['vitesse'] = $val['vitesse'];
    $this->valF['connecteur'] = $val['connecteur'];
    $this->valF['format'] = $val['format'];
    $this->valF['rank'] = 3;
    break;
  case "lecteuroptique":
    $this->valF['connecteur'] = $val['connecteur'];
    $this->valF['typecomp'] = $val['typecomp'];
    $this->valF['vitesse'] = $val['vitesse'];
    $this->valF['integre'] = $val['integre'];
    $this->valF['rank'] = 4;
    break;
  case "memoire":
    $this->valF['frequence'] = $val['frequence'];
    $this->valF['typecomp'] = $val['typecomp'];
    $this->valF['taille'] = $val['taille'];
    $this->valF['rank'] = 2;
    break;
  case "processeur":
    $this->valF['connecteur'] = $val['connecteur'];
    $this->valF['frequence'] = $val['frequence'];
    $this->valF['vitesse'] = $val['vitesse'];
    $this->valF['taille'] = $val['taille'];
    $this->valF['nbbank'] = $val['nbbank'];
    $this->valF['rank'] = 1;
  }
}

function setType(&$form,$maj) {
  parent::setType($form,$maj);  //sans& 
  if ($maj < 2) { //ajouter et modifier
    switch ($this->nature) {
    case "cartemere":
      $form->setType('nbpci','text');
      $form->setType('nbpcie','text');
      $form->setType('nbagp','text');
      $form->setType('nbbank','text');
      $form->setType('connecteur','select');
      break;
    case "cartereseau":
      $form->setType('chemin','text');
      $form->setType('typecomp','select');
      $form->setType('vitesse','select');
      $form->setType('connecteur','select');
      break;
    case "carteson":
      $form->setType('typecomp','select');
      $form->setType('chemin','text');
      $form->setType('integre','select');
      break;
    case "cartevideo":
      $form->setType('typecomp','select');
      $form->setType('taille','text');
      $form->setType('chemin','text');
      $form->setType('connecteur','select');
      break;
    case "disquedur":
      $form->setType('taille','text');
      $form->setType('vitesse','select');
      $form->setType('connecteur','select');
      $form->setType('format','select');
      break;
    case "lecteuroptique":
      $form->setType('vitesse','select');
      $form->setType('connecteur','select');
      $form->setType('typecomp','select');
      $form->setType('integre','select');
      break;
    case "memoire":
      $form->setType('frequence','text');
      $form->setType('typecomp','select');
      $form->setType('taille','select');
      break;
    case "processeur":
      $form->setType('connecteur','select');
      $form->setType('frequence','text');
      $form->setType('vitesse','text');
      $form->setType('taille','text');
      $form->setType('nbbank','text');
    }
  }
}
    
function setSelect(&$form, $maj,$db,$debug) {
  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 "cartemere":
      $contenu=array();
      $contenu[0]=array('Inconnu','Socket7','Slot1','Socket370','Socket478','Socket479','Socket603','Socket604','Socket754','Socket775','Socket939','Socket940');
      $contenu[1]=array('Inconnu','Socket7','Slot1','Socket370','Socket478','Socket479','Socket603','Socket604','Socket754','Socket775','Socket939','Socket940');
      $form->setSelect("connecteur",$contenu);
      break;
    case "cartereseau":
      $contenu=array();
      $contenu[0]=array("Intégré","PCI","PCMIA");
      $contenu[1]=array("Intégré","PCI","PCMIA");
      $form->setSelect("connecteur",$contenu);
      $contenu=array();
      $contenu[0]=array("Ethernet","Ethernet 802.3","Bluetooth","Firewire","Wifi");
      $contenu[1]=array("Ethernet","Ethernet 802.3","Bluetooth","Firewire","Wifi");
      $form->setSelect("typecomp",$contenu);
      $contenu=array();
      $contenu[0]=array("10","11","54","100","1000");
      $contenu[1]=array("10","11","54","100","1000");
      $form->setSelect("vitesse",$contenu);
      break;
    case "carteson":
      $contenu=array();
      $contenu[0]=array("Inconnu","Realtek");
      $contenu[1]=array("Inconnu","Realtek");
      $form->setSelect("typecomp",$contenu);
      $form->setSelect("integre",$contenuON);
      break;
    case "cartevideo":
      $contenu=array();
      $contenu[0]=array("Intégré","PCI","AGP","PCI-E");
      $contenu[1]=array("Intégré","PCI","AGP","PCI-E");
      $form->setSelect("connecteur",$contenu);
      $contenu=array();
      $contenu[0]=array("Inconnu","ATI","NVIDIA","SIS");
      $contenu[1]=array("Inconnu","ATI","NVIDIA","SIS");
      $form->setSelect("typecomp",$contenu);
      break;
    case "disquedur":
      $contenu=array();
      $contenu[0]=array('4200','5400','7200','10000','15000');
      $contenu[1]=array('4200','5400','7200','10000','15000');
      $form->setSelect("vitesse",$contenu);
      $contenu=array();
      $contenu[0]=array("IDE","SCSI","SerialATA","SerialATA2","USB","USB2");
      $contenu[1]=array("IDE","SCSI","SerialATA","SerialATA2","USB","USB2");
      $form->setSelect("connecteur",$contenu);
      $contenu[0]=array("2.5","3.5","5.25");
      $contenu[1]=array("2.5","3.5","5.25");
      $form->setSelect("format",$contenu);
      break;
    case "lecteuroptique":
      $contenu=array();
      $contenu[0]=array('Inconnu','16X','24X','32X','40X','52X','32X24X32X','16X32X');
      $contenu[1]=array('Inconnu','16X','24X','32X','40X','52X','32X24X32X','16X32X');
      $form->setSelect("vitesse",$contenu);
      $contenu=array();
      $contenu[0]=array('CD','CDRW','CDRWDVD','DVD','DVDRW','DVDRWDual');
      $contenu[1]=array('CD','CDRW','CDRWDVD','DVD','DVDRW','DVDRWDual');
      $form->setSelect("typecomp",$contenu);
      $contenu=array();
      $contenu[0]=array('IDE','Firewire','USB','USB2');
      $contenu[1]=array('IDE','Firewire','USB','USB2');
      $form->setSelect("connecteur",$contenu);
      $form->setSelect("integre",$contenuON);
      break;
    case "memoire":
      $contenu=array();
      $contenu[0]=array('EDO','SDRAM','DDRAM','DDRAM2','RDRAM');
      $contenu[1]=array('EDO','SDRAM','DDRAM','DDRAM2','RDRAM');
      $form->setSelect("typecomp",$contenu);
      $contenu=array();
      $contenu[0]=array(8,16,32,64,128,256,512,1024,2048);
      $contenu[1]=array(8,16,32,64,128,256,512,1024,2048);
      $form->setSelect("taille",$contenu);
      break;
    case "processeur":
      $contenu=array();
      $contenu[0]=array('Inconnu','Socket7','Slot1','Socket370','Socket478','Socket479','Socket603','Socket604','Socket754','Socket775','Socket939','Socket940');
      $contenu[1]=array('Inconnu','Socket7','Slot1','Socket370','Socket478','Socket479','Socket603','Socket604','Socket754','Socket775','Socket939','Socket940');
      $form->setSelect("connecteur",$contenu);
    }
  }
}
    
function setLib(&$form,$maj) {
  parent::setLib($form,$maj);  //sans& 
  switch ($this->nature) {
  case "cartemere":
    $form->setLib('nbpci','Nb PCI');
    $form->setLib('nbpcie','Nb PCI-E');
    $form->setLib('nbagp','Nb AGP');
    $form->setLib('nbbank','Nb Banques');
    break;
  case "cartereseau":
  $form->setLib('chemin','Chemin pilote');
  $form->setLib('typecomp','Type');
    break;
  case "carteson":
    $form->setLib('typecomp','Chipset');
    $form->setLib('chemin','Chemin pilote');
    $form->setLib('integre','Intégré (carte mère)');
    break;
  case "cartevideo":
    $form->setLib('typecomp','Chipset');
    $form->setLib('chemin','Chemin pilote');
    $form->setLib('taille','Capacité');
    break;
  case "disquedur":
    $form->setLib('vitesse','Tours RPM');
    $form->setLib('taille','Capacité');
    break;
  case "lecteuroptique":
    $form->setLib('typecomp','Type');
    $form->setLib('integre','Graveur');
    break;
  case "memoire":
    $form->setLib('typecomp','Type');
    $form->setLib('taille','Capacité');
    break;
  case "processeur":
    $form->setLib('vitesse','Vitesse Bus');
    $form->setLib('taille','Cache L1');
    $form->setLib('nbbank','Cache L2');
  }
}
  
function verifier(){
  // obligatoire
  parent::verifier(); 
  switch ($this->nature) {
  case "cartemere":
    if (!is_numeric($this->valF['nbpci'])){
      $this->correct=false;
      $this->msg= $this->msg."<br>Numérique obligatoire";
    }
    if (!is_numeric($this->valF['nbpcie'])){
      $this->correct=false;
      $this->msg= $this->msg."<br>Numérique obligatoire";
    }
    if (!is_numeric($this->valF['nbagp'])){
      $this->correct=false;
      $this->msg= $this->msg."<br>Numérique obligatoire";
    }
    if (!is_numeric($this->valF['nbbank'])){
      $this->correct=false;
      $this->msg= $this->msg."<br>Numérique obligatoire";
    }
    break;
  case "cartevideo":
  case "disquedur":
    if (!is_numeric($this->valF['taille'])){
      $this->correct=false;
      $this->msg= $this->msg."<br>Numérique obligatoire";
    }
    break;
  case "memoire":
    if (!is_numeric($this->valF['frequence'])){
      $this->correct=false;
      $this->msg= $this->msg."<br>Numérique obligatoire";
    }
    break;
  case "processeur":
    if (!is_numeric($this->valF['frequence'])){
      $this->correct=false;
      $this->msg= $this->msg."<br>Numérique obligatoire";
    }
    if (!is_numeric($this->valF['vitesse'])){
      $this->correct=false;
      $this->msg= $this->msg."<br>Numérique obligatoire";
    }
    if (!is_numeric($this->valF['taille'])){
      $this->correct=false;
      $this->msg= $this->msg."<br>Numérique obligatoire";
    }
    if (!is_numeric($this->valF['nbbank'])){
      $this->correct=false;
      $this->msg= $this->msg."<br>Numérique obligatoire";
    }
  }
}

}// fin de classe
?>