<?php
$DEBUG=0;

$serie=15;
$ent = "Bureautique  <img src='../img/fleche_droite.png' align='bottom'  border='0'> Copieur";
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/copieur.png";
$edition="";
$hiddenid=1;
$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>";
         } 

//
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("e.idelement as id","e.numero as periph","me.libmodele","libservice","e.numserie","libtype as type","concat(p1.nom,' ',p1.prenom) as demandeur","dateouverture","observations","libetat");
    $champRecherche=array("e.numero","me.libmodele","libservice","e.numserie","nom","prenom","observations","dateouverture");
    $tri= " order by dateouverture desc,e.numero";
    $selection="where nature = 'copieur'"; // and element.idetatelement=1";
} else {
    $table="element inner join modeleelement on element.idmodele=modeleelement.idmodele left join tcpip on element.idelement=tcpip.idperipherique inner join service on element.idservice=service.idservice";
    $champAffiche=array("element.idelement as id","numero","libservice","nomelement as nom","adresseip","libmodele");
    $champRecherche=array("numero","libmodele","libservice","nomelement","adresseip");
    $tri= " order by libservice,numero";
    $selection="where nature = 'copieur' and element.idservice > 0 and (isnull(ipmaitre) or ipmaitre='v')";
}
switch ($nat) {
  case 'interv':
  $selection.=" and i.idetatintervention in (1,2)";
  break;
  case 'intervclo':
  $selection.=" and i.idetatintervention = 3";
}
if (isset($idx)) { //soustabdyn
  if (strstr($obj,"modele")) { //modelecopieur
    $selection .= " and element.idmodele = ".$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("tcpip","intervention");
$sousformulaire_class="sousformulaire"; // dans cg => voir customs ???
$soustab="onglet";
?>