<?php
// $Id: dynselectmodelestation.php,v 1.2 2008-04-01 15:02:15 fgiva Exp $
header('Content-type: text/html; charset=iso-8859-1');  
include ("../dyn/session.inc");
require_once "DB.php";
include_once ("../dyn/connexion.php");
$db=& DB :: connect($dsn, $db_option);
if (DB :: isError($db)) 
    die($db->getMessage());
$modele=$_POST["modele"];
$sql="select * from modelestation where idmodelestation=$modele";
$res = $db->query($sql);
if (DB :: isError($res))
    die($res->getMessage().$sql);
echo 'var o = null;';   
echo 'var sorg = document.forms["'.$_POST["form"].'"].elements["idorganisme"];';
echo 'var smod = document.forms["'.$_POST["form"].'"].elements["idmodele"];';   
echo 'var smar = document.forms["'.$_POST["form"].'"].elements["idmarque"];';   
echo 'var styp = document.forms["'.$_POST["form"].'"].elements["idtypestation"];';   
echo 'var ssys = document.forms["'.$_POST["form"].'"].elements["idsysteme"];';   
echo 'var tdat = document.forms["'.$_POST["form"].'"].elements["dateachat"];';   
echo 'var sfou = document.forms["'.$_POST["form"].'"].elements["idfournisseur"];';   
echo 'var tbc = document.forms["'.$_POST["form"].'"].elements["bc"];';   
echo 'var tgar = document.forms["'.$_POST["form"].'"].elements["garantie"];';   
while ($row=& $res->fetchRow(DB_FETCHMODE_ASSOC)){
  if ($row["idorganisme"]>0)
    echo 'sorg.value = '.$row["idorganisme"].';';
  if ($row["idmodele"]>0)
    echo 'smod.value = '.$row["idmodele"].';';   
  if ($row["idmarque"]>0)
    echo 'smar.value = '.$row["idmarque"].';';   
  if ($row["idtypestation"]>0)
    echo 'styp.value = '.$row["idtypestation"].';';   
  if ($row["idsysteme"]>0)
    echo 'ssys.value = '.$row["idsysteme"].';';
  $valTemp=$row["dateachat"];
  if ($formatDate=="AAAA-MM-JJ"){
    $valTemp=explode("-",$valTemp);
    $valTemp=$valTemp[2]."/".$valTemp[1]."/".$valTemp[0];
  }
  echo 'tdat.value = "'.$valTemp.'";';   
  if ($row["idfournisseur"]>0)
    echo 'sfou.value = '.$row["idfournisseur"].';';   
  if ($row["bc"])
    echo 'tbc.value = "'.$row["bc"].'";';   
  echo 'tgar.value = '.$row["garantie"].';';   
}
$res->free();
$db->disconnect();
?>