<?php
	require_once('../common/scripts/connect.inc.php');
	require_once('../common/scripts/template.inc.php');



 $id=$_POST[id];

// on récupère les equip_id de notre mimichant dans un tableau
 $equipId=pg_query($dbconn,"select equip_id from equipements where char_id = $id"); 


// pour chaque equip_id
 $template = new Template(".");
 $template->set_file("inventaire", "inventaire.tpl");
 $template->set_block("inventaire", "INVENTAIRE","Inventaire");
 $cpt =0;
 while($valeurId=pg_fetch_array($equipId)){
 $cpt++;
	$idArme=pg_query($dbconn,"select obj_id from equipements where equip_id ='$valeurId[0]'"); 
	$idArme=pg_fetch_array($idArme);
	$template->set_var("IDARME",$idArme[0]);
	$objName=pg_query($dbconn,"select obj_name from objects where obj_id ='$idArme[0]'"); 
	$name=pg_fetch_array($objName);
	$template->set_var("NAMEARME",$name[0]);
	$image=$name[0];
	$template->set_var("IMAGE",$image);
	$equip=pg_query($dbconn,"select obj_equip from equipements where equip_id ='$valeurId[0]'"); 
	$equip = pg_fetch_array($equip);
	//informations de l'arme
	$infoArme=pg_query($dbconn,"select obj_infos from objects where obj_id ='$idArme[0]'");
	$infoArme=pg_fetch_row($infoArme);
	$template->set_var("INFOARME",$infoArme[0]);
	$template->set_var("EQUIPID",$valeurId[0]);
	$template->set_var("MIMIID",$id);
	if ($equip[0]=='t'){
		$template->set_var("EQUIP",'sac');
		
	}
	else{
		$template->set_var("EQUIP",'sacBarre');
	}
	
	if($cpt%2==0)$template->set_var("inventaireLigne","ligne1");
	else $template->set_var("inventaireLigne","ligne2");
 $template->parse("Inventaire","INVENTAIRE",true);
 }

	
 $template->parse("output","inventaire");
 $template->p("output");
?>
