<?php include ("../master.php");
if (!is_collaborateur()) kick_me("login.php");
$path_info=pathinfo($_SERVER["SCRIPT_NAME"]);
$my_file=$path_info["basename"];

$contrat=false;
$sinistre=false;
$client=false;
$devis=false;
$documentation=false;
$publipostage=false;


	if ($my_file=="contrat.php") {
	$contrat=true;
	$GLOBAL_TITRE="[Co] ";
	}
elseif ($my_file=="sinistre.php") {
	$sinistre=true;
	$GLOBAL_TITRE="[S] ";
	}
elseif ($my_file=="client.php") {
	$client=true;
	$GLOBAL_TITRE="[Cl] ";
	}
elseif ($my_file=="devis.php") {
	$devis=true;
	$GLOBAL_TITRE="[D] ";
	}
elseif ($my_file=="documentation.php") {
	$documentation=true;
	$GLOBAL_TITRE="[Doc] ";
	}
elseif ($my_file=="publipostage.php") {
	$publipostage=true;
	$GLOBAL_TITRE="[P] ";
	}

$color1="#AED536";
$color2="#AAAAAA";
?>

<head>
    <link rel="stylesheet" href="../style/axa.css">
</head>

<body bgcolor="#ffffff" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
    <script>
        window.name = "admin_axa";

    </script>
    <center>
        <table cellpadding="0" cellspacing="0" border="0" width="900">
            <tr>
                <td valign="top" width="100%" height="40" align="left" bgcolor="#ffffff">
                    <br />
                    <table cellpadding="0" cellspacing="0" border="0" height="20" width="100%">
                        <tr>
                            <td width="1%"></td>
                            <td width="69%">
                                <table cellpadding="4" cellspacing="1" border="0" height="20" bgcolor="#777777">
                                    <tr>
                                        <td onclick="location.href='contrat.php?req=liste&incomplet=1'" style="padding-left:10px; padding-right:10px; cursor:pointer;cursor:hand;" align="center" bgcolor="<?php echo (($contrat)?$color1:$color2); ?>"><a class="white" href="contrat.php?req=liste&incomplet=1"><img src="../images/admin/contrat.gif" align="absmiddle" border="0"><b>Contrats</b></a></td>
                                        <td onclick="location.href='client.php'" style="padding-left:10px; padding-right:10px; cursor:pointer;cursor:hand;" align="center" bgcolor="<?php echo (($client)?$color1:$color2); ?>"><a class="white" href="client.php"><img src="../images/admin/client.gif" align="absmiddle" border="0"><b>Clients</b></a></td>
                                        <td onclick="location.href='sinistre.php?req=liste&clos=0'" style="padding-left:10px; padding-right:10px; cursor:pointer;cursor:hand;" align="center" bgcolor="<?php echo (($sinistre)?$color1:$color2); ?>"><a class="white" href="sinistre.php?req=liste&clos=0"><img src="../images/admin/sinistre.gif" align="absmiddle" border="0" style="margin-right:2px;"><b>Sinitres</b></a></td>
                                        <td onclick="location.href='devis.php'" style="padding-left:10px; padding-right:10px; cursor:pointer;cursor:hand;" align="center" bgcolor="<?php echo (($devis)?$color1:$color2); ?>"><a class="white" href="devis.php"><img src="../images/admin/devis.gif" align="absmiddle" border="0"><b>Devis</b></a></td>
                                        <td onclick="location.href='publipostage.php'" style="padding-left:10px; padding-right:10px; cursor:pointer;cursor:hand;" align="center" bgcolor="<?php echo (($publipostage)?$color1:$color2); ?>"><a class="white" href="publipostage.php"><img src="../images/admin/relance_0.gif" align="absmiddle" border="0" style="margin-right:1px;"><b>POOL CORSE</b></a></td>
                                        <td onclick="location.href='documentation.php'" style="padding-left:10px; padding-right:10px; cursor:pointer;cursor:hand;" align="center" bgcolor="<?php echo (($documentation)?$color1:$color2); ?>"><a class="white" href="documentation.php"><img src="../images/admin/documentation.gif" align="absmiddle" border="0" style="margin-right:1px;"><b>Documents</b></a></td>

                                    </tr>
                                </table>
                            </td>
                            <td width="29%" align="right" valign="bottom">
                                <table cellpadding="1" cellspacing="1" border="0" height="12" bgcolor="black">
                                    <tr bgcolor="#dddddd">
                                        <td bgcolor="#ffffff">
                                            <font class="sub">&nbsp;<b>Collaborateurs</b> /
                                                <?php echo $_SESSION["SS_user_nom"];?>
                                            </font>
                                        </td>
                                        <td onclick="location.href='client.php'" style="cursor:pointer;cursor:hand;" width="60" align="center"><a class="sub" href="deconnexion.php"><b>D&eacute;connexion</b></a></td>
                                    </tr>
                                </table>
                            </td>
                            <td width="1%"></td>
                        </tr>
                    </table>

                    <table cellpadding="4" cellspacing="1" border="0" height="20" width="100%" bgcolor="#777777">
                        <tr bgcolor="<?php echo $color1;?>">
                            <td width="100%" height="38">
                                <table cellpadding="0" cellspacing="0" border="0" height="30">
                                    <tr>
                                        <?php if ($contrat){ ?>
                                        <td width="60">
                                            <select onchange="if (this.options[this.selectedIndex].value!='') location.href='contrat.php?req=addone&type='+this.options[this.selectedIndex].value+'<?php
		if (isset($_GET[" id_client "])){
			echo "&id_client=".$_GET[" id_client "];
			$add_more=" &agrave; ce client ";
			}
		else $add_more=" ";		
		?>';">
		<option value="">Ajouter un contrat<?php echo $add_more; ?>
		<option value="4">AUTOMOBILE
		<option value="10">HABITATION
		<option value="24">GAV
		<option value="16">PROTECTION JURIDIQUE
		<option value="14">MULTI-PROFESSIONNELS
		<option value="25">BANQUE
		<option value="18">CHASSE
		<option value="13">MULTI IMMEUBLES
		<option value="15">PLAISANCE
		<option value="22">EPARGNE
		<?php
		$type_done=array(4, 10, 24, 16, 14, 25, 18, 13, 15, 22); 
		$result=mysql_query("SELECT id, titre FROM contrats_type ORDER BY nom", $link);
		while ($row=mysql_fetch_array($result)){
			if (!in_array($row["id"], $type_done))
				echo '<option value="'.$row["id"].'">'.$row["titre"];
			}
		?>
		</select></td>
                                        <td width="100" align="center">
                                            <select onchange="if (this.options[this.selectedIndex].value!='') location.href='contrat.php?req=liste'+this.options[this.selectedIndex].value;">
		<option value="&incomplet=0" <?php echo ((!isset($_GET["incomplet"]) || $_GET["incomplet"]=="0")?"SELECTED":""); ?>>Tous
		<option value="&incomplet=1" <?php echo ((isset($_GET["incomplet"]) && $_GET["incomplet"]=="1")?"SELECTED":""); ?>>Incomplets
		<option value="&resilie=1" <?php echo ((isset($_GET["resilie"]) && $_GET["resilie"]=="1")?"SELECTED":""); ?>>Résiliés
		</select>
                                        </td>

                                        <td width="80" align="center">
                                            <td width="100" align="left">
                                                <font class="white">Scanné</font>
                                                <select onchange="if (this.options[this.selectedIndex].value!='') location.href='contrat.php?req=liste'+this.options[this.selectedIndex].value;">
		<option value="&scan=0" <?php echo ((!isset($_GET["scan"]) || $_GET["scan"]=="0")?"SELECTED":""); ?>>Oui
		<option value="&scan=1" <?php echo ((isset($_GET["scan"]) && $_GET["scan"]=="1")?"SELECTED":""); ?>>Non
		<option value="&scan=-1" <?php echo ((isset($_GET["scan"]) && $_GET["scan"]=="-1")?"SELECTED":""); ?>>Tous
		</select>
                                            </td>


                                            <td class="white" width="130" align="center"><a class="white" href="print_all.php" target="_blank">Imprimer les relances</a>
                                            </td>
                                            <td class="white" width="280" align="right">
                                                <form action="contrat.php" method="get" id="filtre" name="filtre">
                                                    <input type="hidden" id="req" name="req" value="liste">
                                                    <div id="filtre_titre" name="filtre_titre" class="white" style="display:inline;">
                                                        <?php
			$filtre_titre="";
			if(isset($_GET["id_axa"]) && $_GET["id_axa"]!="") $filtre_titre="Contrat #";
			if(isset($_GET["id_client"]) && $_GET["id_client"]!="") $filtre_titre="Client #";
			echo $filtre_titre;?>
                                                    </div>&nbsp;<input type="texte" id="id_axa" name="id_axa" size="20" value="<?php 
			if(isset($_GET[" id_axa "]) && $_GET["id_axa "]!=" ") echo html($_GET["id_axa "]);
			if(isset($_GET["id_client "]) && $_GET["id_client "]!=" ") echo html($_GET["id_client "]);
			?>">
                                                    <img alt="Lister ce contrat" src="../images/admin/contrat.gif" border="0" align="absmiddle" style="cursor:hand; cursor:pointer;" onmouseover="document.getElementById('filtre_titre').innerText='Contrat #';" //onmouseout="document.getElementById('filtre_titre').innerText='<?php echo $filtre_titre;?>';" onclick="document.getElementById('filtre').submit();">
                                                    <img alt="Modifier ce contrat" src="../images/admin/mod.gif" border="0" align="absmiddle" style="cursor:hand; cursor:pointer;" onmouseover="document.getElementById('filtre_titre').innerText='Contrat #';" onmouseout="document.getElementById('filtre_titre').innerText='<?php echo $filtre_titre;?>';" onclick="if (document.getElementById('req').value='mod') document.getElementById('filtre').submit();">
                                                    <img alt="Lister tous les contrats de ce client" src="../images/admin/filtre.gif" border="0" align="absmiddle" style="cursor:hand; cursor:pointer;" onmouseover="document.getElementById('filtre_titre').innerText='Client #';" onmouseout="document.getElementById('filtre_titre').innerText='<?php echo $filtre_titre;?>';" onclick="if ((document.getElementById('id_axa').name='id_client') && (document.getElementById('id_axa').id='id_client')) document.getElementById('filtre').submit();">
                                                    <img alt="Rechercher ce client" src="../images/admin/client_search.gif" border="0" align="absmiddle" style="cursor:hand; cursor:pointer;" onmouseover="document.getElementById('filtre_titre').innerText='Rechercher';" onmouseout="document.getElementById('filtre_titre').innerText='<?php echo $filtre_titre;?>';" onclick="if ((document.getElementById('req').value='search') && (document.getElementById('filtre').action='client.php')) document.getElementById('filtre').submit();">

                                                </form>
                                            </td>


                                            <?php } elseif ($client){ ?>
                                            <td width="100"><a class="white" href="client.php?req=addone">Ajouter un client</a></td>

                                            <td width="610" align="right" class="white">
                                                <form action="client.php" method="get" id="filtre" name="filtre">
                                                    <input type="hidden" id="req" name="req" value="search">
                                                    <div id="filtre_titre" name="filtre_titre" class="white" style="display:inline;">
                                                        <?php
			$filtre_titre="";
			if(isset($_GET["id_axa"]) && $_GET["id_axa"]!="") $filtre_titre="Client #";
			if(isset($_GET["req"]) && $_GET["req"]=="search") $filtre_titre="Rechercher";
			
			echo $filtre_titre;?>
                                                    </div>&nbsp;<input type="texte" id="id_axa" name="id_axa" size="20" value="<?php 
			if(isset($_GET[" id_axa "]) && $_GET["id_axa "]!=" ")  echo html(trim(stripslashes(urldecode($_GET["id_axa "]))));
			?>">
                                                    <img alt="Rechercher ce client" src="../images/admin/client_search.gif" border="0" align="absmiddle" style="cursor:hand; cursor:pointer;" onmouseover="document.getElementById('filtre_titre').innerText='Rechercher';" onmouseout="document.getElementById('filtre_titre').innerText='<?php echo $filtre_titre;?>';" onclick="if (document.getElementById('req').value='search') document.getElementById('filtre').submit();">
                                                    <img alt="Modifier ce client" src="../images/admin/mod.gif" border="0" align="absmiddle" style="cursor:hand; cursor:pointer;" onmouseover="document.getElementById('filtre_titre').innerText='Client #';" onmouseout="document.getElementById('filtre_titre').innerText='<?php echo $filtre_titre;?>';" onclick="if (document.getElementById('req').value='mod') document.getElementById('filtre').submit();">
                                                </form>
                                            </td>

                                            <?php } elseif ($sinistre){ ?>
                                            <td width="110"><a class="white" href="sinistre.php?req=addone">Ajouter un sinistre</a></td>
                                            <td width="150" align="right">
                                                <select onchange="location.href='sinistre.php?req=liste<?php echo ((isset($_GET[" gere "]))?"&gere=".$_GET[" gere "]:" "); ?>&clos='+this.options[this.selectedIndex].value;">
		<option value="" <?php echo ((isset($_GET["clos"]) && $_GET["clos"]=="")?"SELECTED":""); ?>>Tous les sinistres
		<option value="-1" <?php echo ((isset($_GET["clos"]) && $_GET["clos"]=="-1")?"SELECTED":""); ?>>Sinistres à relancer
		<option value="0" <?php echo ((isset($_GET["clos"]) && $_GET["clos"]=="0")?"SELECTED":""); ?>>Sinistres non clos
		<option value="1" <?php echo ((isset($_GET["clos"]) && $_GET["clos"]=="1")?"SELECTED":""); ?>>Sinistres clos
		</select>
                                            </td>
                                            <td width="200" align="left">
                                                <font class="white">&nbsp;&nbsp;Gérés par</font>
                                                <select onchange="location.href='sinistre.php?req=liste<?php echo ((isset($_GET[" clos "]))?"&clos=".$_GET[" clos "]:" "); ?>&gere='+this.options[this.selectedIndex].value;">
		<option value="" <?php echo ((isset($_GET["gere"]) && $_GET["gere"]=="")?"SELECTED":""); ?>>Indifférent
		<option value="1" <?php echo ((isset($_GET["gere"]) && $_GET["gere"]=="1")?"SELECTED":""); ?>>Compagnie
		<option value="0" <?php echo ((isset($_GET["gere"]) && $_GET["gere"]=="0")?"SELECTED":""); ?>>Agence
		</select>
                                            </td>
                                            <td width="150" class="white">
                                                <form action="sinistre.php" method="get" name="sinistre_contrat">
                                                    <input type="hidden" id="req" name="req" value="liste"> #
                                                    <input type="texte" id="id_axa" name="id_axa" size="15" value="<?php echo ((isset($_GET[" id_axa "]) && $_GET["req "]=="liste ")?html($_GET["id_axa "]):" ");?>">
                                                    <img style="cursor:hand; cursor:pointer;" alt="Lister les sinistres relatifs à ce contrat" src="../images/admin/contrat.gif" border="0" align="absmiddle" onclick="document.sinistre_contrat.submit();">

                                                </form>
                                            </td>

                                            <td width="150" align="right" class="white">
                                                <form action="sinistre.php" method="get" name="sinistre_id">
                                                    <input type="hidden" id="req" name="req" value="mod"> #
                                                    <input type="texte" id="id_axa" name="id_axa" size="15" value="<?php echo ((isset($_GET[" id_axa "]) && $_GET["req "]=="mod ")?html($_GET["id_axa "]):" ");?>">
                                                    <img style="cursor:hand; cursor:pointer;" alt="Modifier ce sinistre" src="../images/admin/sinistre.gif" border="0" align="absmiddle" onclick="document.sinistre_id.submit();">

                                                </form>
                                            </td>

                                            <?php } elseif ($devis){ ?>
                                            <td width="400">
                                                <select onchange="if (this.options[this.selectedIndex].value!='') location.href='devis.php?req=liste&apporteur='+this.options[this.selectedIndex].value;">
		<option value="" <?php echo ((isset($_GET["apporteur"]) && $_GET["apporteur"]==="")?"SELECTED":""); ?>>Tous les devis
		<option value="0" <?php echo ((isset($_GET["apporteur"]) && $_GET["apporteur"]==="0")?"SELECTED":""); ?>>Public uniquement
		<option value="-1" <?php echo ((isset($_GET["apporteur"]) && $_GET["apporteur"]=="-1")?"SELECTED":""); ?>>Apporteurs uniquement
		<?php 
		$result=mysql_query("SELECT id, nom, prenom, type FROM utilisateurs ORDER BY type DESC, nom ASC ", $link);
		while ($row=mysql_fetch_array($result)){
			echo '<option value="'.$row["id"].'" '.((isset($_GET["apporteur"]) && $_GET["apporteur"]==$row["id"])?"SELECTED":"").'>['.$USERS["type"][$row["type"]].'] '.strtoupper($row["nom"])." ".ucwords($row["prenom"]);
			}
			?>
		</select>
                                            </td>
                                            <td width="300" align="right" class="white">
                                                <form action="devis.php" method="get">
                                                    <input type="hidden" id="req" name="req" value="mod"> #
                                                    <input type="texte" id="id_axa" name="id_axa" size="4"><input type="submit" value="Modifier" style="height:20px">
                                                </form>
                                            </td>

                                            <?php } elseif ($documentation){ ?>
                                            <?php } ?>

                                    </tr>
                                </table>
                                </td>
                        </tr>
                    </table>


            </tr>
            <tr>
                <td valign="top" width="100%">
                    <table cellpadding="0" cellspacing="1" border="0" width="100%" bgcolor="#777777">
                        <td valign="top" width="100%" bgcolor="#ffffff">
