<?php
$DEBUG=0;

$serie=15;
$ent = "Réseau <img src='../img/fleche_droite.png' align='bottom'  border='0'> Télécom";
switch ($nat) {
  case 'interv':
  $ent.=" en intervention";
  break;
  case 'intervclo':
  $ent.=" interventions cloturées";
}
if ($nat=="interv" || $nat=="intervclo")
  $ico="../img/intervention.png";
else
  $ico = "../img/voipphone.png";
$edition="";
$fiche="peripherique";
if ($nat=="interv" || $nat=="intervclo") {
       $href[0]['lien']= "#";
       $href[0]['id']= "";
       $href[0]['lib']= "";
}
if ($nat=="interv" || $nat=="intervclo") {
       $href[2]['lien']= "#";
       $href[2]['id']= "";
       $href[2]['lib']= "";
}
$href[3]['lien'] = "../pdf/pdfetat.php?obj=".$fiche."&idx=";
$href[3]['id']= "";
// * custom *
if(file_exists("../dyn/custom/img/ico_pdf.png")) {
   $href[3]['lib']= "<img src='../dyn/custom/img/ico_pdf.png' border=0>";
}
else {
   $href[3]['lib']= "<img src='../img/ico_pdf.png' border=0>";
} 
$hiddenid=1;
if ($nat=="interv" || $nat=="intervclo") {
   $table="element as e left join intervention as i on e.idelement=i.idperipherique left join personnel as p1 on i.iddemandeur=p1.idutilisateur inner join etatintervention as et on i.idetatintervention=et.idetat
   inner join typeintervention as ty on i.idtype=ty.idtype inner join modeleelement as me on e.idmodele=me.idmodele left join service on e.idservice=service.idservice";
   $champAffiche=array("idelement as id","numero as Inventaire","nomelement as N_Tel","libmodele","libservice","numserie","libtype as type","concat(p1.nom,' ',p1.prenom) as demandeur","dateouverture","observations","libetat");
   $champRecherche=array("numero","nomelement","libmodele","libservice","numserie","nom","prenom","dateouverture");
   $tri= " order by dateouverture desc,e.numero";
} else {
  $table="element inner join modeleelement on element.idmodele=modeleelement.idmodele left join personnel on element.idutilisateur=personnel.idutilisateur left join service
  on element.idservice=service.idservice left join batiment on element.idbatiment=batiment.idbatiment inner join etatmateriel on element.idetatelement=etatmateriel.idetat";
  $champAffiche=array("idelement as id","numero as Inventaire","nomelement as N_Tel","concat(nom,' ',prenom) as nom","libmodele","libservice","libbatiment","numserie","dateatelier","libetat");
  $champRecherche=array("numero","nomelement","nom","prenom","libservice","libbatiment","libmodele","numserie","libetat");
  $tri= " order by nom,prenom,libservice,libbatiment,libmodele,numserie";
}
//
/*$table="element inner join modeleelement on element.idmodele=modeleelement.idmodele left join personnel
on element.idutilisateur=personnel.idutilisateur inner join service on element.idservice=service.idservice 
left join batiment on element.idbatiment=batiment.idbatiment";
$champAffiche=array("idelement as id","numero","concat(nom,' ',prenom) as nom","libservice","nature","libmodele","libbatiment","nomelement as N_Tel");
$champRecherche=array("numero","nom","libservice","nature","libmodele","libbatiment");
$tri= " order by nom,nature";*/
switch ($nat) {
  case 'interv':
  $selection=" where classe = 'telecom' and i.idetatintervention in (1,2)";
  break;
  case 'intervclo':
  $selection=" where classe = 'telecom' and i.idetatintervention = 3";
  break;
  default:
  $selection="where classe = 'telecom'";
}
if (isset($idx)) { //soustabdyn
  if ($obj=="modeletelecom") { //modeletelecom
    $selection .= " and element.idmodele = ".$idx;
  } else {
    if ($obj=="personnel") { //soustab de personnel
      $selection .= " and element.idutilisateur = ".$idx;  
    } else if ($obj=="service") {  //service
      $selection .= " and element.idservice = ".$idx;  
    } else if ($obj=="batiment") { //batiment
      $selection .= " and element.idbatiment = ".$idx;  
    }
  }
}
// sous formulaire
$sousformulaire=array("intervention");
$sousformulaire_class="sousformulaire"; // dans cg => voir customs ???
$soustab="onglet";
?>