99 |
|
|
100 |
$res = $this->db->query($sql); |
$res = $this->db->query($sql); |
101 |
// In case of error |
// In case of error |
102 |
if (database::isError($res, true)) { |
if ($this->checkDBError($res, 'Erreur lors de mise à jour')) { |
|
//print ' ERROR in SELECTION '; |
|
103 |
return $this->KO; |
return $this->KO; |
104 |
} |
} |
105 |
|
|
106 |
$ids = array(); |
$ids = array(); |
107 |
while ($row =& $res->fetchRow(DB_FETCHMODE_ORDERED)) { |
while ($row =& $res->fetchRow(DB_FETCHMODE_ORDERED)) { |
|
//print '$row'.$row; |
|
108 |
$ids[] = $row[0]; |
$ids[] = $row[0]; |
109 |
} |
} |
110 |
$res->free(); |
$res->free(); |
112 |
// if there are no consultations that need to have |
// if there are no consultations that need to have |
113 |
// their state set to Favorable, return OK |
// their state set to Favorable, return OK |
114 |
if (count($ids) == 0) { |
if (count($ids) == 0) { |
115 |
return $this->OK; |
$this->setMessage("Aucune mise à jour"); |
116 |
|
return $this->NA; |
117 |
} |
} |
118 |
|
|
119 |
// get the idenfier of the evaluation: 'Favorable' |
// get the idenfier of the evaluation: 'Favorable' |
120 |
$sql = "SELECT avis_consultation FROM avis_consultation WHERE ". |
$sql = "SELECT avis_consultation FROM avis_consultation WHERE ". |
121 |
"libelle = 'Favorable'"; |
"libelle = 'Tacite'"; |
122 |
$res = $this->db->query($sql); |
$res = $this->db->query($sql); |
123 |
if (database::isError($res, true)) { |
if ($this->checkDBError($res, 'Erreur lors de mise à jour')) { |
|
$res->free(); |
|
124 |
return $this->KO; |
return $this->KO; |
125 |
} |
} |
126 |
|
|
127 |
$favorable = -1; |
$favorable = -1; |
128 |
while ($row =& $res->fetchRow(DB_FETCHMODE_ORDERED)) { |
while ($row =& $res->fetchRow(DB_FETCHMODE_ORDERED)) { |
129 |
$favorable = $row[0]; |
$favorable = $row[0]; |
132 |
|
|
133 |
// if we did not find the evaluation 'Favorable', return error |
// if we did not find the evaluation 'Favorable', return error |
134 |
if ($favorable < 0) { |
if ($favorable < 0) { |
135 |
|
$this->setMessage("'Favorable' n'est pas présent ". |
136 |
|
"dans la columne : avis_consultation.libelle"); |
137 |
return $this->KO; |
return $this->KO; |
138 |
} |
} |
139 |
|
|
140 |
// update the consultation table to set the 'Favorable' evaluation for |
// update the consultation table to set the 'Favorable' evaluation for |
141 |
// the pertinent consultations |
// the pertinent consultations |
142 |
$fields = array('avis_consultation' => $favorable); |
$fields = array('avis_consultation' => $favorable); |
143 |
$res = $this->db->autoExecute($table_name, $fields, DB_AUTOQUERY_UPDATE, |
$res = $this->db->autoExecute($table_name, $fields, DB_AUTOQUERY_UPDATE, |
144 |
'consultation IN ('.implode(',', $ids).')'); |
'consultation IN ('.implode(',', $ids).')'); |
145 |
if (database::isError($res, true)) { |
if ($this->checkDBError($res, 'Erreur lors de mise à jour')) { |
|
$res->free(); |
|
146 |
return $this->KO; |
return $this->KO; |
147 |
} |
} |
148 |
|
|
149 |
return $this->OK; |
// $res->getDebugInfo(), $res->getMessage() |
150 |
|
$this->setMessage('Il y a eu '.count($ids).' demandes de consultations dont '. |
151 |
|
'l\'avis été passé à Tacite'); |
152 |
|
return $this->OK; |
153 |
} |
} |
154 |
|
|
155 |
} |
} |
156 |
|
|
157 |
|
|
158 |
|
|
159 |
?> |
?> |