public static function printAnnuaire(){ // connexion à la BD $con = connect_db(); //requete de selection $requete = $con->query(" SELECT CONCAT(personnel.nomsPersonnel,' ',personnel.prenomsPersonnel) AS noms, personnel.tutellePersonnel AS tutelle, personnel.corpsPersonnel AS corps, personnel.gradePersonnel AS grade, personnel.fonctionPersonnel AS fonction, personnel.photoPersonnel AS photo, contact.phone_mtn1 AS mtn1, contact.phone_mtn2 AS mtn2, contact.phone_orange1 AS orange1, contact.phone_orange2 AS orange2, contact.phone_nexttel1 AS nexttel1, contact.phone_nexttel2 AS nexttel2, contact.phone_ctphone AS ctphone, contact.phone_bureau AS bureau, contact.phone_avaya AS avaya, contact.indicatif_er AS indicatif_er, service.libelleService AS libelleService, service.tutelleService AS tutelleService FROM personnel, contact, service WHERE personnel.idPersonnel = contact.idPersonnel AND service.idService = personnel.idService ORDER BY service.tutelleService ASC "); $reports ="
"; // on recupère le resultat de la requete while($value = $requete->fetch()){ $mtn1 = (!empty($value['mtn1']))? "{$value['mtn1']}" : ""; $mtn2 = (!empty($value['mtn2']))? "{$value['mtn2']}" : ""; $orange1 = (!empty($value['orange1']))? "{$value['orange1']}" : ""; $orange2 = (!empty($value['orange2']))? "{$value['orange2']}" : ""; $nexttel1 = (!empty($value['nexttel1']))? "{$value['nexttel1']}" : ""; $nexttel2 = (!empty($value['nexttel2']))? "{$value['nexttel2']}" : ""; $ctphone = (!empty($value['ctphone']))? "{$value['ctphone']}" : ""; $bureau = (!empty($value['bureau']))? "{$value['bureau']}" : ""; $avaya = (!empty($value['avaya']))? "{$value['avaya']}" : ""; $indicatif = (!empty($value['indicatif_er']))? "{$value['indicatif_er']}" : ""; $reports .= "

". utf8_encode(strtoupper($value['noms']))."
". utf8_encode(strtoupper($value['grade']))."
". utf8_encode(strtoupper($value['tutelleService']))."
". utf8_encode(strtoupper($value['libelleService']))."
". utf8_encode(strtoupper($value['fonction']))."

Coordonnées téléphoniques

$mtn1 $mtn2
$orange1 $orange2
$nexttel1 $nexttel2
$ctphone $bureau
$avaya
$indicatif
"; } $reports .= "
"; $path = "tmp/annuaire-".rand(99, 99999999).".pdf"; include_once '../mycontacts/prince.php'; $prince = new Prince("/usr/bin/prince"); $prince->setHTML(true); $prince->addStyleSheet("themes/print-style.css"); $pdf = $prince->convert_string_to_file($reports, $path); // on vérifie que la fiche a été créée $exist = (!$pdf)? "" : $path; $targetPath = $_SERVER['DOCUMENT_ROOT']."/".$path; chmod($targetPath, "0777"); session_start(); $_SESSION["annuaire"] = $path; echo json_encode($exist); }