1 |
<?php |
2 |
/** |
3 |
* Ce script permet de mettre un texte de la bible dans un formulaire instruction |
4 |
* champs file d'un formulaire - automatique |
5 |
* |
6 |
* @package openfoncier |
7 |
* @version SVN : $Id$ |
8 |
*/ |
9 |
|
10 |
// |
11 |
require_once "../obj/utils.class.php"; |
12 |
$f = new utils("nohtml"); |
13 |
$f->disableLog(); |
14 |
|
15 |
$formatDate="AAAA-MM-JJ"; |
16 |
|
17 |
// Récupération des paramètres |
18 |
$idx = $f->get_submitted_get_value('idx'); |
19 |
$evenement = $f->get_submitted_get_value('ev'); |
20 |
// Initialisation de la variable de retour |
21 |
$retour['complement_om_html'] = ''; |
22 |
$retour['complement2_om_html'] = ''; |
23 |
// Vérification d'une consultation liée à l'événement |
24 |
$consultation = $f->db->getOne( |
25 |
"select consultation from ".DB_PREFIXE."evenement where evenement=".$evenement |
26 |
); |
27 |
$f->isDatabaseError($consultation); |
28 |
// Si consultation liée, récupération du retour d'avis |
29 |
if($consultation=='Oui'){ |
30 |
$sql="select date_retour,avis_consultation.libelle as avis_consultation, |
31 |
service.libelle as service |
32 |
from ".DB_PREFIXE."consultation inner join ".DB_PREFIXE."service |
33 |
on consultation.service =service.service |
34 |
left join ".DB_PREFIXE."avis_consultation on |
35 |
consultation.avis_consultation = avis_consultation.avis_consultation |
36 |
where dossier ='".$idx."'"; |
37 |
$res = $f->db->query($sql); |
38 |
$f->isDatabaseError($res); |
39 |
// Récupération des consultations |
40 |
while ($row=& $res->fetchRow(DB_FETCHMODE_ASSOC)){ |
41 |
$correct=false; |
42 |
// date retour |
43 |
if ($row['date_retour']<>""){ |
44 |
if ($formatDate=="AAAA-MM-JJ"){ |
45 |
$date = explode("-", $row['date_retour']); |
46 |
// controle de date |
47 |
if (count($date) == 3 and |
48 |
checkdate($date[1], $date[2], $date[0])) { |
49 |
$date_retour_f= $date[2]."/".$date[1]."/".$date[0]; |
50 |
$correct=true; |
51 |
}else{ |
52 |
$msg= $msg."<br>La date ".$row['date_retour']." n'est pas une date."; |
53 |
$correct=false; |
54 |
} |
55 |
} |
56 |
} |
57 |
// |
58 |
$temp="Vu l'avis ".$row['avis_consultation']." du service ".$row['service']; |
59 |
if($correct == true){ |
60 |
$temp=$temp." du ".$date_retour_f; |
61 |
} |
62 |
// Concaténation des retours d'avis de consultation |
63 |
$retour['complement_om_html'] .= $temp; |
64 |
} // while |
65 |
|
66 |
} // consultation |
67 |
// Récupération des bibles automatiques pour le champ complement_om_html |
68 |
$retour['complement_om_html'] .= getBible($f, $evenement, $idx, '1'); |
69 |
// Récupération des bibles automatiques pour le champ complement2_om_html |
70 |
$retour['complement2_om_html'] .= getBible($f, $evenement, $idx, '2'); |
71 |
|
72 |
|
73 |
|
74 |
echo json_encode($retour); |
75 |
|
76 |
/** |
77 |
* Récupération des éléments de bible. |
78 |
* |
79 |
* @param utils $f handler de om_application |
80 |
* @param integer $event id de l'événement |
81 |
* @param string $idx id du dossier |
82 |
* @param integer $compnb numéro du champ complement |
83 |
* |
84 |
* @return string Chaîne de texte à insérer dans le champ complement |
85 |
*/ |
86 |
function getBible($f, $event, $idx, $compnb) { |
87 |
$sql = "SELECT * FROM ".DB_PREFIXE."bible |
88 |
LEFT OUTER JOIN ".DB_PREFIXE."dossier_autorisation_type |
89 |
ON bible.dossier_autorisation_type= |
90 |
dossier_autorisation_type.dossier_autorisation_type |
91 |
WHERE evenement =".$event." and |
92 |
complement=".$compnb." and |
93 |
automatique='Oui' and |
94 |
(dossier_autorisation_type.code ='".substr($idx, 0, 2)."' or |
95 |
bible.dossier_autorisation_type IS NULL)"; |
96 |
|
97 |
$res = $f->db->query($sql); |
98 |
$f->isDatabaseError($res); |
99 |
$temp = ""; |
100 |
while ($row=& $res->fetchRow(DB_FETCHMODE_ASSOC)){ |
101 |
// Remplacement des retours à la ligne par des br |
102 |
$temp .= preg_replace( |
103 |
'#(\\\r|\\\r\\\n|\\\n)#', '<br/>', $row['contenu'] |
104 |
); |
105 |
} // fin while |
106 |
return $temp; |
107 |
} |
108 |
?> |