$show_form=true; if (isset($_POST["bouton"]) && $_POST["bouton"]=="Confirmer") { require_once("form_validation.php"); $validator = new FormValidator(); $validator->addValidation("dateDebut","req","Merci de saisir une date de début"); $validator->addValidation("dateFin","req","Merci de saisir une date de fin"); $validator->addValidation("societe","req","Merci de saisir une société"); $validator->addValidation("nomContact","req","Merci de saisir un nom"); $validator->addValidation("emailContact","email","L'adresse email doit être valide"); $validator->addValidation("emailContact","req","Merci de saisir un email"); //$validator->addValidation("phoneContact","req","Merci de saisir un numéro de téléphone"); if($validator->ValidateForm()) { require_once 'Zend/Loader.php'; Zend_Loader::loadClass('Zend_Gdata'); Zend_Loader::loadClass('Zend_Gdata_ClientLogin'); Zend_Loader::loadClass('Zend_Gdata_Calendar'); $service = Zend_Gdata_Calendar::AUTH_SERVICE_NAME; $user = "joarbraz@gmail.com"; $pass = ""; $client = Zend_Gdata_ClientLogin::getHttpClient($user, $pass, $service); $service = new Zend_Gdata_Calendar($client); $nomContact = $_POST["nomContact"]; $emailContact = $_POST["emailContact"]; if (isset($_POST["phoneContact"]) && $_POST["phoneContact"]!='') { $phoneContact = $_POST["phoneContact"]; } else { $phoneContact = "non renseigné"; } if (isset($_POST["commentaire"]) && $_POST["commentaire"]!='') { $commentaire = $_POST["commentaire"]; } else { $commentaire = "non renseigné"; } $societe = $_POST["societe"]; $details = "Entreprise : ".$societe.", Contact : ".$nomContact.", Email : ".$emailContact.", Téléphone : ".$phoneContact.", Commentaire : ".$commentaire; $dateDebut = substr($_POST["dateDebut"],6,4)."-".substr($_POST["dateDebut"],3,2)."-".substr($_POST["dateDebut"],0,2); // conversion au format Y-m-d $duree = $_POST["duree"]; $dateFin = substr($_POST["dateFin"],6,4)."-".substr($_POST["dateFin"],3,2)."-".substr($_POST["dateFin"],0,2); // conversion au format Y-m-d switch ($duree) { case "all" : $heureDebut = "07:00"; $heureFin = "15:00"; break; case "am" : $heureDebut = "07:00"; $heureFin = "10:30"; break; case "pm" : $heureDebut = "11:30"; $heureFin = "15:00"; break; } // Create a new entry using the calendar service's magic factory method $event= $service->newEventEntry(); $event->title = $service->newTitle("Option Formation"); $event->where = array($service->newWhere("Rouen")); $event->content = $service->newContent($details); // Set the date using RFC 3339 format. $startDate = $dateDebut; $startTime = $heureDebut; $endDate = $dateFin; $endTime = $heureFin; $tzOffset = "-01"; $when = $service->newWhen(); $when->startTime = "{$startDate}T{$startTime}:00.000{$tzOffset}:00"; $when->endTime = "{$endDate}T{$endTime}:00.000{$tzOffset}:00"; $event->when = array($when); $uri = "http://www.google.com/calendar/feeds/j5o65hm1g2pe58u6h1k7if3gpc%40group.calendar.google.com/private/full"; if($newEvent = $service->insertEvent($event,$uri)) { $headers = 'From: "".$nomContact."" <'.$emailContact.'>'."\n"; $headers .= 'Reply-To: <'.$emailContact.'>'."\n"; $headers .='Content-Type: text/plain; charset="iso-8859-1"'."\n"; $headers .='Content-Transfer-Encoding: 8bit'; $email_content = "Du : ".$_POST['dateDebut']." au ".$_POST['dateFin']."\n"; $email_content .= "Société : ".$societe."\n"; $email_content .= "Nom du contact : ".$nomContact."\n"; $email_content .= "Email : ".$emailContact."\n"; $email_content .= "Téléphone : ".$phoneContact."\n"; $email_content .= "Commentaire : ".$commentaire."\n"; $email_content .= "Voir l'agenda : https://www.google.com/calendar/embed?src=j5o65hm1g2pe58u6h1k7if3gpc%40group.calendar.google.com&ctz=Europe/Paris "; mail("joarbraz@gmail.com","Demande de réservation de ".$societe,$email_content,$headers); $msg = "
Votre demande a bien été prise en compte. Je vous contacterai prochainement pour valider cette réservation.
"; $msg .= ""; } else { $msg = "