<?php
$DEBUG=0;
$serie=20;
$ent="Bureautique <img src='../img/fleche_droite.png' align='bottom'  border='0'> Stations ";
switch ($nat) {
  case 'mairie':
  $ent.="Mairie";
  break;
  case 'interco':
  $ent.="Interco";
  break;
  case 'ecoles':
  $ent.="Ecoles";
  break;
  case 'stock':
  $ent.="non affectées";
  break;
  case 'interv':
  $ent.="en intervention";
  break;
  case 'intervclo':
  $ent.="interventions cloturées";
}
if ($nat=="interv" || $nat=="intervclo")
  $ico="../img/intervention.png";
else
  $ico="../img/station.png";
$edition="";
$fiche="station";
if ($nat=="stock" || $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>";
} 
/*         $href[4]['lien'] = "../wmi/audit.php?idstation=";
         $href[4]['id']= "";
         // * custom *
         if(file_exists("../dyn/custom/img/intervention.png")) {
            $href[4]['lib']= "<img src='../dyn/custom/img/intervention.png' border=0>";
         }
         else {
            $href[4]['lib']= "<img src='../img/intervention.png' border=0>";
         } */
//
$hiddenid=1;
if ($nat=="interv" || $nat=="intervclo") {
  $table="station as s left join intervention as i on s.idstation=i.idstation 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
 left join service on s.idservice=service.idservice left join batiment on s.idbatiment=batiment.idbatiment";
  $champAffiche=array("s.idstation as id","s.numero as station","libtype as type","concat(p1.nom,' ',p1.prenom) as demandeur","libbatiment","libservice","dateouverture","observations as observations_________________________","libetat");
  $champRecherche=array("s.numero","nom","prenom","libservice","libbatiment","dateouverture","observations");
} else {
  $table="station left join personnel on station.idutilisateur=personnel.idutilisateur left join service
on station.idservice=service.idservice left join batiment on station.idbatiment=batiment.idbatiment 
left join tcpip on station.idstation=tcpip.idstation left join modeleelement on station.idsysteme=
modeleelement.idmodele left join organisme on station.idorganisme=organisme.idorganisme";
  $champAffiche=array("station.idstation as id","station.numero","nomstation","adresseip as reseau","ipecole as local","concat(nom,' ',prenom) as nom"
, "libservice as service_lieu","libbatiment as batiment","libmodele as systeme","station.datescan","liborganisme as organisme","station.dateatelier as install_stock");
  $champRecherche=array("station.numero","nomstation","nom","prenom","libservice","libbatiment","libmodele","adresseip","station.datescan","liborganisme","station.dateatelier");
}
switch ($nat) {
  case 'mairie':
  $tri= " order by nom,numero";
  $selection=" where (isnull(tcpip.ipmaitre) or tcpip.ipmaitre='v') and idetatstation=1 and organisme.liborganisme ='ville'";
  $sousformulaire=array("composant","logiciel","peripheriquestation","tcpip","intervention");
  break;
  case 'interco':
  $tri= " order by nom,numero";
  $selection=" where (isnull(tcpip.ipmaitre) or tcpip.ipmaitre='v') and idetatstation=1 and organisme.liborganisme ='interco'";
  $sousformulaire=array("composant","logiciel","peripheriquestation","tcpip","intervention");
  break;
  case 'ecoles':
  $tri= " order by libbatiment, station.numero";
  $selection=" where (isnull(tcpip.ipmaitre) or tcpip.ipmaitre='v') and idetatstation=1 and organisme.liborganisme ='ecoles'";
  $sousformulaire=array("composant","logiciel","peripheriquestation","intervention");
  break;
  case 'stock':
  $tri= " order by numero";
  $selection=" where idetatstation>1 and (isnull(tcpip.ipmaitre) or tcpip.ipmaitre='v')";
  $sousformulaire=array("composant","peripheriquestation","intervention");
  break;
  case 'interv':
  $tri= " order by dateouverture desc,s.numero";
  $selection=" where i.idetatintervention in (1,2)";
  $sousformulaire=array("composant","logiciel","peripheriquestation","tcpip","intervention");
  break;  
  case 'intervclo':
  $tri= " order by dateouverture desc,s.numero";
  $selection=" where i.idetatintervention = 3";
  $sousformulaire=array("composant","logiciel","peripheriquestation","tcpip","intervention");
  break;  
  default:
  $tri= " order by numero";
  $selection=" where (isnull(tcpip.ipmaitre) or tcpip.ipmaitre='v')";
  $sousformulaire=array("composant","logiciel","peripheriquestation","tcpip","intervention");
}
if (isset($idx)) { //soustabdyn
  if (strstr($obj,"modele")) { //soustab de modele...
    if ($nat=="systeme") {  //modelelogiciel(systeme)
      $selection .= " and station.idsysteme = ".$idx;
    } else {  //autre modele...
      $table.=", element";
      $selection .= " and station.idstation=element.idstation and element.idmodele = ".$idx;
      if (strstr($obj,"modeleperipherique")) { //soustab de modeleperipherique
         $champAffiche=array("station.idstation as id","station.numero","nomstation","adresseip as reseau","ipecole as local","concat(nom,' ',prenom) as nom"
       , "libservice as service_lieu","libbatiment as batiment","libmodele as systeme","liborganisme","element.numserie");
         $champRecherche=array("station.numero","nomstation","nom","prenom","libservice","libbatiment","libmodele","adresseip","element.numserie");
      }
    }
  } else {  //soustab de personnel, service ou batiment
    if ($obj=="personnel")
      $selection .= " and station.idutilisateur = ".$idx;  
    else if ($obj=="service")
      $selection .= " and station.idservice = ".$idx;  
    else if ($obj=="batiment")
      $selection .= " and station.idbatiment = ".$idx;  
  }
}// sous formulaire
//dans cg => voir customs ???
$sousformulaire_class="sousformulaire"; 
$soustab="onglet";
?>