<?php
// mysql_func.php                      */
//* Fonctions   php & mysql           */
//*--------------------------------  */
//* Jean Loup RELIER (c)2012-2017   */
//* ------------------------------ */

function DateSemaine() {
if ((isset($jour))&&(isset($mois))&&(isset($annee))&&($jour!='')&&($annee!='')&&($mois!=''))
	{$jour= $_GET['jour']; $mois= $_GET['mois']; $annee= $_GET['annee'];}
	else {$jour=date('d'); $mois=date('m'); $annee=date('Y');}
$semaine = date("W", mktime(0,0,0,$mois,$jour,$annee));
return $semaine ;
}

function DateFr($datereleve) {
$jour = array("Dimanche","Lundi","Mardi","Mercredi","Jeudi","Vendredi","Samei"); 
$mois = array("","Janvier","Février","Mars","Avril","Mai","Juin","Juillet","Août","Septembre","Octobre","Novembre","Décembre"); 
$datefr = $jour[date("w",strtotime($datereleve))]." ".date("d",strtotime($datereleve))." ".$mois[date("n",strtotime($datereleve))]." ".date("Y",strtotime($datereleve)); 
return $datefr ;
}

function DateFra($datereleve) {
$DateFra=date("d-m-Y", strtotime($datereleve));
return $DateFra ;
}

function verif_email1 ($email){
   $Syntaxe='#^[\w.-]+@[\w.-]+\.[a-zA-Z]{2,6}$#';
   if(preg_match($Syntaxe,$email))
      return true;
   else
     return false;
}

function Reload_page (){

        header("Location:".$_SERVER['PHP_SELF']);
        exit;  
}

// fonction AfficheMessErr()
// Affiche les messages d'erreur
function AfficheMessErr( $message ){
   printf("<BLOCKQUOTE><BLOCKQUOTE><BLOCKQUOTE><H3><FONT color=\"#cc0000\">
        %s</FONT></H3></BLOCKQUOTE></BLOCKQUOTE></BLOCKQUOTE>\n", $message);
}

function CodeBarrePlu ($CodeBarre) {
$Cb_plu = substr($CodeBarre, 2, 5) ;
$Cb_plu = number_format($Cb_plu, 0, ',', ' ')	;
Return 	$Cb_plu  ;
}


function CodeBarrePoids ($CodeBarre) {
$Cb_Poids = substr($CodeBarre, 7, 5) ;     
$Cb_Poids = number_format(round($Cb_Poids/1000, 3), 3, '.', ' ')	;	
Return 	$Cb_Poids  ;
}


function Menu_CSD($ordre) {
echo "<center>";
Echo "<table id='tableausoft'>";
Echo "<tr><td>";
switch ($ordre) {
    case 1:
		echo "<b>Nouveau</b><b> | </b>";
		echo "<a href=''><b>Consulter</b></a><b> | </b>";
		echo "<a href=''><b>Supprimer</b></a><b> | </b>";
		echo "<a href=''><b>Modifier</b></a>";
		echo "<tr></td>";
		echo "</table>";
		echo "/<center>";
        break;
    case 2:
        echo "<a href=''><b>Nouveau</b></a><b> | </b>";
		echo "<b>Consulter</b><b> | </b>";
		echo "<a href=''><b>Supprimer</b></a><b> | </b>";
		echo "<a href=''><b>Modifier</b></a>";
		echo "</td>";
		echo "</table>";
		echo "/<center>";
        break;
    case 3:
		echo "<a href=''><b>Nouveau</b></a><b> | </b>";
		echo "<a href=''><b>Consulter</b></a><b> | </b>";
		echo "<b>Supprimer</b><b> | </b>";
		echo "<a href=''><b>Modifier</b></a>";
		echo "<tr></td>";
		echo "</table>";
    echo "/<center>";
        break;
	case 4:
        echo "<a href=''><b>Nouveau</b></a><b> | </b>";
		echo "<a href=''><b>Consulter</b></a><b> | </b>";
		echo "<a href=''><b>Supprimer</b></a><b> | </b>";
		echo "<b>Modifier</b>";
		echo "<tr></td>";
		echo "</table>";
		echo "/<center>";
        break;
	}

}


function EnvoiMail($nom,$email,$cpostal,$ville,$messageSite,$MailSite) {

	 $headers = 'From: '.$MailSite.'<'.$MailSite.'>'."\n"; 
     $headers .= 'Return-Path: <'.$MailSite.'>'."\n"; 
     $headers .='Content-Type: text/html; charset="UTF-8"'."\n"; 
     $headers .='Content-Transfer-Encoding: 8bit'; 
	 
     $message ='<html><head><title>Message Mail</title></head>';
	 $message .='<body>Une Demande de contact<br>De : Mr Ou Mme '.$nom.'<br>';
	 $message .='<br>Adresse :'.$cpostal.' Ville :'.$ville.'<br>';
	 $message .='<br>Adresse Mail :'.$email.'<br>';
	 $message .='<br>Son Message est :<br>';
	 $message .='<br>'.$messageSite.'</body></html>'; 

     if(mail($email, "Sujet", $message, $headers)) { 
	 imap_mail($email, "Demande de contact", $message, $headers);
	 imap_mail($MailSite, "Demande de contact", $message, $headers);	
		    return 1;
    } else {
			return 0;
	}
} 
?>
