<?php 
if ((!isset($_POST["req"])) || ($_POST["req"]!="print")){
	include ("header.php");
	echo '

	<form action="publipostage.php" method="post" target="_blank"><br />
	<font class="title">&nbsp;&nbsp;Publipostage</font><br/><br/>
	
	<table border="0" cellpadding="5" cellspacing="0">
	<tr>
		<td align="right">Civilité</td>
		<td><select name="civilite">';
		foreach ($CLIENTS["civilite"] as $key=>$value) {
			echo '<option value="'.$key.'">'.$value;
			}
		echo '</select></td>
	</tr>
	<tr>
		<td align="right">Nom</td>
		<td><input type="text" name="nom" size="31" maxlength="255"></td>
	</tr>
	<tr>
		<td align="right">Prénom</td>
		<td><input type="text" name="prenom" size="31" maxlength="255"></td>
	</tr>
	<tr>
		<td align="right">Adresse Hors Corse 1</td>
		<td><input type="text" name="adresse_hc_1" size="31" maxlength="255"></td>
	</tr>
	<tr>
		<td align="right">Adresse Hors Corse 2</td>
		<td><input type="text" name="adresse_hc_2" size="31" maxlength="255"></td>
	</tr>
	<tr>
		<td align="right">Adresse Hors Corse 3</td>
		<td><input type="text" name="adresse_hc_3" size="31" maxlength="255"></td>
	</tr>
	<tr>
		<td align="right">Code Postal Hors Corse</td>
		<td><input type="text" name="code_postal_hc" size="31" maxlength="255"></td>
	</tr>
	<tr>
		<td align="right">Ville Hors Corse</td>
		<td><input type="text" name="ville_hc" size="31" maxlength="255"></td>
	</tr>
	<tr>
		<td align="right">Pays Hors Corse</td>
		<td><input type="text" name="pays_hc" size="31" maxlength="255"></td>
	</tr>
	<tr>
		<td align="right">Adresse Corse 1</td>
		<td><input type="text" name="adresse_c_1" size="31" maxlength="255"></td>
	</tr>
	<tr>
		<td align="right">Adresse Corse 2</td>
		<td><input type="text" name="adresse_c_2" size="31" maxlength="255"></td>
	</tr>
	<tr>
		<td align="right">Adresse Corse 3</td>
		<td><input type="text" name="adresse_c_3" size="31" maxlength="255"></td>
	</tr>
		<tr>
		<td align="right">Code Postal Corse</td>
		<td><input type="text" name="code_postal_c" size="31" maxlength="255"></td>
	</tr>
	<tr>
		<td align="right">Ville Corse</td>
		<td><input type="text" name="ville_c" size="31" maxlength="255"></td>
	</tr>
	<tr>
		<td><input type="hidden" name="req" value="print"></td>
		<td><input type="submit" value="Générer les courriers"></td>
	</tr>
	</table>	
	
	</form>
	';
	include("footer.php");
	}

else {
	include("../master.php");
	echo '<html>
			<head>
			<style>
			table, body, div, span {
			font-family: Eras Light ITC;
				font-size:14px;
				color:black;
				line-height:16px;
				text-align:justify;
				}
			</style>
			</head>
			<body>
			';
	$error=0;
	
	foreach ($_POST as $key=>$value) {
		if (is_array($value)) foreach ($value as $akey=>$avalue) ${$key}[$akey]=strtoupper(stripslashes($avalue));
		else ${$key}=strtoupper(stripslashes($value));
		if ($key!="adresse_hc_2" && $key!="adresse_hc_3" && $key!="adresse_c_2" && $key!="adresse_c_3" && trim($value)==""){
			echo "Tous les champs sont obligatoires !<br /><br />";
			$error=1;
			break;
			}
		}
		
	
	if ($error!=1){
		$titre=$CLIENTS["civilite"][$civilite];
		echo '<div style="page-break-after: always;">';
		include("../courriers/publipostage_lettre1.php");	
		echo '</div>
		<div style="page-break-after: always;">';
		include("../courriers/publipostage_fax.php");	
		echo '</div>
		<div style="page-break-after: always;">';
		include("../courriers/publipostage_lettre2.php");	
		echo '</div>
		<div>';
		include("../courriers/publipostage_lettre3.php");	
		echo '</div>';
		}
	echo '</body></html>';
	}

?>