Changeset 2591 for cpc/trunk/project
- Timestamp:
- Jan 9, 2012, 5:58:18 PM (9 years ago)
- Location:
- cpc/trunk/project/lib
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
cpc/trunk/project/lib/model/doctrine/Intervention.class.php
r2422 r2591 59 59 public function setSeance($type, $date, $heure, $session, $commission = null) { 60 60 $this->setType($type); 61 if ($type == 'commission') { 62 $commission = Doctrine::getTable('Organisme')->findOneByNomOrCreateIt($commission, 'parlementaire'); 63 $seance = $commission->getSeanceByDateAndMomentOrCreateIt($date, $heure, $session); 64 $commission->free(); 65 } else{ 66 $seance = Doctrine::getTable('Seance')->findOneOrCreateIt('hemicycle', $date, $heure, $session); 67 } 61 $seance = Doctrine::getTable('Seance')->getOrCreateItFromSeanceArgs($type, $date, $heure, $session, $commission); 68 62 $id = $this->_set('seance_id', $seance->id); 69 63 $seance->free(); -
cpc/trunk/project/lib/model/doctrine/Seance.class.php
r2336 r2591 120 120 } 121 121 122 public function deleteInterventions() { 123 if ($this->countComments()) { 124 throw new Exception('Il existe des commentaires'); 125 } 126 foreach (Doctrine::getTable('Intervention')->createQuery('i')->where('i.seance_id = ?', $this->id)->execute() as $i) { 127 $i->delete(); 128 } 129 } 130 131 public function countComments() { 132 $interventions = Doctrine::getTable('Intervention')->createQuery('i')->where('i.seance_id = ?', $this->id)->select('i.id')->fetchArray(); 133 return Doctrine::getTable('Commentaire')->createQuery('c')->whereIN('object_id', $interventions)->andWhere('object_type = ?', 'Intervention')->count(); 134 } 135 122 136 public function getTitre($miniature = 0, $hemicycle = 0, $ref = '') { 123 137 $titre = ''; -
cpc/trunk/project/lib/model/doctrine/SeanceTable.class.php
r1254 r2591 5 5 class SeanceTable extends Doctrine_Table 6 6 { 7 public function getFromSeanceArgs($type, $date, $heure, $session, $commission = null) { 8 if ($type == 'commission') { 9 $commission = Doctrine::getTable('Organisme')->findOneByNomOrCreateIt($commission, 'parlementaire'); 10 return $commission->getSeanceByDateAndMoment($date, $heure, $session); 11 } 12 return Doctrine::getTable('Seance')->findOneByTypeDateHeureSession('hemicycle', $date, $heure, $session); 13 } 14 15 public function getOrCreateItFromSeanceArgs($type, $date, $heure, $session, $commission = null) { 16 if ($type == 'commission') { 17 $commission = Doctrine::getTable('Organisme')->findOneByNomOrCreateIt($commission, 'parlementaire'); 18 return $commission->getSeanceByDateAndMomentOrCreateIt($date, $heure, $session); 19 } 20 return Doctrine::getTable('Seance')->findOneOrCreateIt('hemicycle', $date, $heure, $session); 21 } 22 23 public function findOneByTypeDateHeureSession($type, $date, $heure, $session) { 24 return $this->createQuery('s')->where('type = ?', $type)->andWhere('date = ?', $date)->andWhere('moment = ?', $heure)->fetchOne(); 25 } 26 7 27 public function findOneOrCreateIt($type, $date, $heure, $session) { 8 $s = $this->createQuery('s')->where('type = ?', $type)->andWhere('date = ?', $date)->andWhere('moment = ?', $heure)->fetchOne();28 $s = findOneByTypeDateHeureSession($type, $date, $heure, $session); 9 29 if (!$s) { 10 30 if ($type != 'hemicycle') -
cpc/trunk/project/lib/task/loadCommissionTask.class.php
r890 r2591 24 24 continue; 25 25 echo "$dir$file\n"; 26 $first = 1; 26 27 foreach(file($dir.$file) as $line) { 27 28 $json = json_decode($line); … … 37 38 } 38 39 40 if ($first) { #On teste si la séance existe déjà. 41 $first = 0; 42 $seance = Doctrine::getTable('Seance')->getFromSeanceArgs('commission', $json->date, $json->heure, $json->session, $json->commission); 43 if ($seance) { 44 try { 45 $seance->deleteInterventions(); 46 }catch(Exception $e) { 47 echo "ERROR: Séance exists (".$e->getMessage().")\n"; 48 continue 2; 49 } 50 } 51 } 39 52 40 53 $id = md5($json->intervention.$json->date.$json->heure.$json->commission); … … 53 66 } 54 67 $intervention->save(); 55 68 $intervention->free(); 56 69 } 57 70 unlink($dir.$file);
Note: See TracChangeset
for help on using the changeset viewer.