<?php
/**
* MiniClick
* Gestionnaire de tableau collaboratif
* Copyright (C) 2006 Guillaume Monet <gm@ibreizh.net>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 
*
* @package miniclick
* @version 5.0.0
*/
session_start();
?>
<html>
<body onload="check_selected()">
<titre>Choix</titre>
<link rel="stylesheet" type="text/css" href="css/tableau.css"  />
<script type="text/javascript">

	
	
	function test(){
		window.opener.document.getElementById("<? echo $_GET[id];?>").value = "";
		var inpNodes = document.getElementsByTagName('input');
		for(var i in inpNodes){
			var inp = inpNodes[i];
			if ( inp.type == 'checkbox'){
				if(inp.checked == true){
					if(inp.id != "allcheck"){
						var cellname = ""+inp.name;
						cellname = cellname.replace(/CK/,"");
						window.opener.document.getElementById("<? echo $_GET[id];?>").value += cellname+";";
						var semid = "";
                				semid = window.opener.document.getElementById("<? echo $_GET[id];?>").alt;
				                window.opener.document.getElementById(semid).value="ON";
					}
				}
			}
		}
		window.close();
	}

	function check_selected(){
		var chaine = window.opener.document.getElementById("<? echo $_GET[id];?>").value;
		var inpNodes = chaine.split(";");	
		var part_num=0;
		while (part_num < inpNodes.length-1){
			var cellid = ""+inpNodes[part_num]+"CK";
			document.getElementById(""+cellid).checked = true;
			part_num+=1;
			display_checkbox_picture(""+cellid);
		}
	}
</script>
<?
include("table_include.php");
include("connection/connection.php");
mysql_connect ($host,$user,$pass);
$base = mysql_select_db($db);
if(!$base){
        die("Impossible de se connecter  la base");
}
if($_SESSION['societe']!=""){
	$_GET['where'] = "Societe_Id like '%".$_SESSION['societe']."%'";
}
create_defaut_config("CLIENT");
init_table("CLIENT");

?>
<input type="button" name="bout" value="Valider" onClick="javascript:test()"> 
</body>
</html>