/[openfoncier]/trunk/services/metier/maintenancemanager.php
ViewVC logotype

Diff of /trunk/services/metier/maintenancemanager.php

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 537 by mlimic, Thu Oct 25 16:31:52 2012 UTC revision 559 by mlimic, Tue Oct 30 17:05:34 2012 UTC
# Line 99  class MaintenanceManager extends MetierM Line 99  class MaintenanceManager extends MetierM
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();
# Line 114  class MaintenanceManager extends MetierM Line 112  class MaintenanceManager extends MetierM
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];
# Line 133  class MaintenanceManager extends MetierM Line 132  class MaintenanceManager extends MetierM
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  ?>  ?>

Legend:
Removed from v.537  
changed lines
  Added in v.559

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26