1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101
| <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=Content-Type content="text/html; charset=windows-1252"></HEAD>
<BODY>
<?php
include_once 'fonctions.php';
require('connexion.php');
require('fonctions/DateFrMySQL.php');
$_params = $_GET + $_POST;
$fname = (isset($_params["file"])) ? $_params["file"]: "L_cs_dem_pat.rtf";
$id = (isset($_params["id"])) ? $_params["id"] : "171";
$dbprotect = mysql_connect($hostname_dbprotect, $username_dbprotect, $password_dbprotect) or trigger_error(mysql_error(),E_USER_ERROR);
mysql_select_db($database_dbprotect, $dbprotect) or die("Erreur SQL : $resultat<br/>".mysql_error());
// on écrit la requête sql
$sql = "SELECT id, Nom_du_patient, Prenom_du_patient, Date_de_naissance,
Date_de_demande, Medecin_suivant_le_patient_dans_le_service, demande_adressée_par, adressee_à,
service, nombres_de_pages, Etat, pole, Date_de_réponse, civilite, nom_ayant_droit, anciennete_dossier
FROM dossier_tbl
WHERE id=\"$id\" ";
$db_data = array ("id", "nom", "prenom", "ddn", "date_demande", "Medecin_suivant_le_patient_dans_le_service", "demandeur", "destinataire",
"nom_serv", "nombres_de_pages", "etat", "pole", "date_reponse", "civilite", "ayant_droit", "anciennete_dossier");
// ** Tableau de base pour la fusion **
$fusion = array (
"_nom_" => "",
"_prenom_" => "",
"_ddn_" => "",
"_date_demande_" => "",
"_Medecin_suivant_le_patient_dans_le_service_" => "",
"_demandeur_" => "",
"_nom_serv_" => "",
"_nombres_de_pages_"=> "",
"_etat_" => "",
"_pole_" => "",
"_date_reponse_" => "",
"_civilite_" => "",
"_ayant_droit_" => "",
"_anciennete_dossier_" => "",
"_documents_" => "",
"_chef_serv_" => "",
"_date_" => "",
);
// ** Remplissage du tableau de base **
$fusion["_nom_"] = "Patient";
$fusion["_prenom_"] = "pauvre";
$fusion["_ddn_"] = "00-00-0000";
$fusion["_date_demande_"] = jmma();
$fusion["_Medecin_suivant_le_patient_dans_le_service_"] = " ";
$fusion["_demandeur_"] = "aucun demandeur";
$fusion["_nom_serv_"] = "aucun service";
$fusion["_nombres_de_pages_"] = " ";
$fusion["_etat_"] = "en cour";
$fusion["_pole_"] = "Pole 0";
$fusion["_date_reponse_"] = jmma();
$fusion["_civilite_"] = "M.";
$fusion["_ayant_droit_"] = "ayantdroit";
$fusion["_anciennete_dossier_"] = "00-00-0000";
$fusion["_documents_"] = " ";
$fusion["_chef_serv_"] = "Lefebvre";
$fusion["_date_"] = jmma();
// ** Lecture et Insertion des données lues **
$selection = mysql_query($sql) or die('Erreur SQL !'.$sql.'<br>'.mysql_error());
if (is_array($selection))
if (count($selection) > 0)
{ $last = count($selection)-1;
$rec = $selection[$last];
for ($i = 0; ($i < count($rec)) && ($i < count($db_data)); $i++)
$fusion['_'.$db_data[$i].'_'] = $rec[$i];
}
// ** Génération et téléchargement du courrier **
$path_parts = pathinfo($fname);
$basename = $path_parts["basename"];
$basename = substr($basename, 0,
strlen($basename)-1-strlen($path_parts["extension"]));
$fsource = "./rtf/$basename.".$path_parts["extension"];
if (file_exists($fsource))
{ $texte = file_get_contents($fsource);
$texte = strtr ($texte, $fusion);
$fdest = "./envois/$basename"."_".date("ymd").".".$path_parts["extension"];
$f = fopen($fdest, 'w');
fwrite ($f, $texte);
fclose($f);
echo "<a href=\"$fdest\">imprimer le courrier</a>";
}
else echo "$fsource non trouvé";
?>
</BODY></HTML> |
Partager