/[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 540 by mlimic, Fri Oct 26 15:45:51 2012 UTC
# Line 92  class MaintenanceManager extends MetierM Line 92  class MaintenanceManager extends MetierM
92       * @return OK on success or not applicable, KO on DB error       * @return OK on success or not applicable, KO on DB error
93       */       */
94      public function updateConsultationsStates($data) {      public function updateConsultationsStates($data) {
95          $table_name = 'consultation';          $table_name = 'test';
96          $sql = "SELECT consultation FROM $table_name WHERE ".          $sql = "SELECT consultation FROM $table_name WHERE ".
97              " date_limite < DATE '". date('Y-m-d', time()) .              " date_limite < DATE '". date('Y-m-d', time()) .
98              "' AND date_retour IS NULL AND avis_consultation IS NULL";              "' AND date_retour IS NULL AND avis_consultation IS NULL";
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)) {
             //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("No updates to make.");
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 = 'Favorable'";
122          $res = $this->db->query($sql);          $res = $this->db->query($sql);
123          if (database::isError($res, true)) {          if ($this->checkDBError($res)) {
             $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("String 'Favorable' is not present ".
136                             "in column 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)) {
             $res->free();  
146              return $this->KO;              return $this->KO;
147          }          }
148            
149          return $this->OK;              // $res->getDebugInfo(), $res->getMessage()
150            $this->setMessage('Evaluation (avis) of '.count($ids).
151                    ' requests for consultation was set to "Tacite".');
152            return $this->OK;
153      }      }
154    
155  }  }
156    
157    
158    
159  ?>  ?>

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

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26