1 |
<?php |
<?php |
2 |
|
|
3 |
|
/* |
4 |
|
* Processes requests received via services which concern users. |
5 |
|
* |
6 |
|
* @author Mirna Limic <[email protected]> |
7 |
|
* Date: 18/10/2012 |
8 |
|
* |
9 |
|
* Follow-up: |
10 |
|
* Bugs: |
11 |
|
*/ |
12 |
|
|
13 |
|
include_once('../obj/dossier_message.class.php'); |
14 |
|
|
15 |
class MessagesManager extends MetierManager { |
class MessagesManager extends MetierManager { |
16 |
|
|
17 |
|
|
18 |
function __construct() { |
var $TYPE_COMPLETUDE_ACC = 'Mise à jour de complétude ERP ACC'; |
19 |
|
var $TYPE_COMPLETUDE_SECU = 'Mise à jour de complétude ERP SECU'; |
20 |
|
var $TYPE_QUALIFICATION_ERP = 'Mise à jour de qualification'; |
21 |
|
var $TYPE_DOSSIER_ENJEUX = 'Dossier à enjeux ERP'; |
22 |
|
|
23 |
|
/* |
24 |
|
* Constructor |
25 |
|
* |
26 |
|
* Calls its parent's constructor. |
27 |
|
*/ |
28 |
|
public function __construct() { |
29 |
parent::__construct(); |
parent::__construct(); |
30 |
|
$this->table = 'messages'; |
31 |
} |
} |
32 |
|
|
33 |
|
/* |
34 |
function __destruct() { |
* Destructor |
35 |
|
* |
36 |
|
* Calls its parent's destructor. |
37 |
|
*/ |
38 |
|
public function __destruct() { |
39 |
parent::__destruct(); |
parent::__destruct(); |
40 |
} |
} |
41 |
|
|
42 |
|
|
43 |
function completude_dossier_ACC($data) { |
|
44 |
|
public function generic(&$data, $type, $contenu_strs) { |
45 |
|
// check that the type of the message is good |
46 |
|
if ($data['type'] != $type) { |
47 |
|
$this->setMessage('Le type de message n\'est pas correct.'); |
48 |
|
return $this->BAD_DATA; |
49 |
|
} |
50 |
|
|
51 |
|
// verification que le dossier existe dans la BD |
52 |
|
$sql = "SELECT dossier FROM ".DB_PREFIXE."dossier"; |
53 |
|
$res = $this->db->query($sql); |
54 |
|
if ($this->checkDBError($res, 'Erreur lors de recuperation des dossiers')) { |
55 |
|
return $this->KO; |
56 |
|
} |
57 |
|
|
58 |
|
$this->dossiers = array(); |
59 |
|
while ($row =& $res->fetchRow(DB_FETCHMODE_ORDERED)) { |
60 |
|
$this->dossiers[$row[0]] = $row[1]; |
61 |
|
} |
62 |
|
$res->free(); |
63 |
|
|
64 |
|
// check that the decision received corresponds to a decision in DB |
65 |
|
if (!in_array($data['dossier_instruction'], array_keys($this->dossiers))) { |
66 |
|
$this->setMessage("Le dossier spécifié dans le message n'existe pas"); |
67 |
|
return $this->KO; |
68 |
|
} |
69 |
|
|
70 |
|
// create the object to hold the data to be stored in DB |
71 |
|
$this->metier_instance = new dossier_message("]", $this->db, 0); |
72 |
|
|
73 |
|
// check that the date is correct |
74 |
|
$date_db = null; |
75 |
|
if (!$this->timestampValid($data['date'], $date_db, true)) { |
76 |
|
$this->setMessage('Le date n\'est pas correct.'); |
77 |
|
return $this->BAD_DATA; |
78 |
|
} |
79 |
|
|
80 |
|
// check that the contenu contains all elements and prepare the |
81 |
|
// contenu |
82 |
|
$contenu = ''; |
83 |
|
$valid_contenu = true; |
84 |
|
foreach ($contenu_strs as $contenu_str => $possible_vals) { |
85 |
|
$value = $data['contenu'][$contenu_str]; |
86 |
|
if (empty($value)) { |
87 |
|
$valid_contenu = false; |
88 |
|
break; |
89 |
|
} |
90 |
|
if ($possible_vals && !in_array(strtolower($value), $possible_vals)) { |
91 |
|
$valid_contenu = false; |
92 |
|
break; |
93 |
|
} |
94 |
|
$contenu .= $contenu_str.' : '.$value.' |
95 |
|
'; // il faut que cette ligne soit comme ca pour que le \n est ajoute a la fin the $contenu |
96 |
|
} |
97 |
|
if ($valid_contenu === false) { |
98 |
|
$this->setMessage('Le contenu du message n\'est pas correct.'); |
99 |
|
return $this->BAD_DATA; |
100 |
|
} |
101 |
|
|
102 |
|
// do some data overwrite and duplication so that the array |
103 |
|
// contains the keys searched for |
104 |
|
$data['contenu'] = $contenu; |
105 |
|
$data['dossier'] = $data['dossier_instruction']; |
106 |
|
$data['date_emission'] = $date_db; // the date |
107 |
|
|
108 |
return $this->OK; |
return $this->OK; |
109 |
} |
} |
110 |
|
|
111 |
|
|
112 |
|
/* |
113 |
|
* Called when ERP wants to indicate if the dossier d'instruction |
114 |
|
* is complete with respect to services for handicapped persons. |
115 |
|
* |
116 |
|
* @param mixed $data The data received in the request. |
117 |
|
* @return string 'OK'. |
118 |
|
*/ |
119 |
|
public function completude_dossier_ACC($data) { |
120 |
|
|
121 |
|
$key_val_pairs = array('Complétude ERP ACC' => array('oui', 'non'), |
122 |
|
'Motivation Complétude ERP ACC' => null); |
123 |
|
$ret = $this->generic($data, |
124 |
|
$this->TYPE_COMPLETUDE_ACC, |
125 |
|
$key_val_pairs); |
126 |
|
|
127 |
|
if ($ret != $this->OK) { |
128 |
|
return $ret; |
129 |
|
} |
130 |
|
return parent::ajouter($data, |
131 |
|
"Mise à jour de complétude ERP ACC à été faite avec success", |
132 |
|
"Echec dans la mise à jour de complétude ERP ACC"); |
133 |
|
} |
134 |
|
|
135 |
function completude_dossier_SECU($data) { |
|
136 |
return $this->OK; |
/* |
137 |
|
* Called when ERP wants to indicate if the dossier d'instruction |
138 |
|
* is complete with respect to security (e.g. fire) regulations. |
139 |
|
* |
140 |
|
* @param mixed $data The data received in the request. |
141 |
|
* @return string 'OK'. |
142 |
|
*/ |
143 |
|
public function completude_dossier_SECU($data) { |
144 |
|
|
145 |
|
$key_val_pairs = array('Complétude ERP SECU' => array('oui', 'non'), |
146 |
|
'Motivation Complétude ERP SECU' => null); |
147 |
|
$ret = $this->generic($data, |
148 |
|
$this->TYPE_COMPLETUDE_SECU, |
149 |
|
$key_val_pairs); |
150 |
|
|
151 |
|
if ($ret != $this->OK) { |
152 |
|
return $ret; |
153 |
|
} |
154 |
|
return parent::ajouter($data, |
155 |
|
"Mise à jour de complétude ERP SECU à été faite avec success", |
156 |
|
"Echec dans la mise à jour de complétude ERP SECU"); |
157 |
} |
} |
158 |
|
|
159 |
|
|
160 |
function qualification_dossier($data) { |
/* |
161 |
return $this->OK; |
* Called when ERP wants to indicate if the dossier d'instruction |
162 |
|
* is an ERP dossier or not. |
163 |
|
* |
164 |
|
* @param mixed $data The data received in the request. |
165 |
|
* @return string 'OK'. |
166 |
|
*/ |
167 |
|
public function qualification_dossier($data) { |
168 |
|
$key_val_pairs = array('Confirmation ERP' => array('oui', 'non'), |
169 |
|
'Type de dossier ERP' => null, |
170 |
|
'Catégorie de dossier ERP' => null); |
171 |
|
$ret = $this->generic($data, |
172 |
|
$this->TYPE_QUALIFICATION_ERP, |
173 |
|
$key_val_pairs); |
174 |
|
|
175 |
|
if ($ret != $this->OK) { |
176 |
|
return $ret; |
177 |
|
} |
178 |
|
return parent::ajouter($data, |
179 |
|
"Mise à jour de la qualification ERP à été faite avec success", |
180 |
|
"Echec dans la mise à jour de la qualification ERP"); |
181 |
} |
} |
182 |
|
|
183 |
|
|
184 |
function dossier_enjeux($data) { |
/* |
185 |
return $this->OK; |
* Called when ERP wants to indicate if the dossier d'instruction |
186 |
|
* is important, i.e. dossier a enjeux. |
187 |
|
* |
188 |
|
* @param mixed $data The data received in the request. |
189 |
|
* @return string 'OK'. |
190 |
|
*/ |
191 |
|
public function dossier_enjeux($data) { |
192 |
|
$key_val_pairs = array('Dossier à enjeux ERP' => array('oui', 'non')); |
193 |
|
$ret = $this->generic($data, |
194 |
|
$this->TYPE_DOSSIER_ENJEUX, |
195 |
|
$key_val_pairs); |
196 |
|
|
197 |
|
if ($ret != $this->OK) { |
198 |
|
return $ret; |
199 |
|
} |
200 |
|
return parent::ajouter($data, |
201 |
|
"Mise à jour du dossier \"Dossier à enjeux ERP\" à été faite avec success", |
202 |
|
"Echec dans la mise à jour du dossier \"Dossier à enjeux ERP\""); |
203 |
} |
} |
204 |
|
|
205 |
} |
} |