Changeset 3100


Ignore:
Timestamp:
Feb 24, 2013, 11:12:37 PM (7 years ago)
Author:
roux
Message:

fix delete section only when really empty

File:
1 edited

Legend:

Unmodified
Added
Removed
  • cpc/trunk/project/lib/task/moveSeanceTask.class.php

    r2336 r3100  
    105105    self::updateCounts($good, $ni, $nc);
    106106    self::setMinDate($seance, $good);
    107     if ($bad->nb_interventions - $ni < 1) {
     107    $n_inters = Doctrine_Query::create()->select('count(i.id) as ct')->from('Intervention i')->leftJoin('i.Section s')->where('s.id = ? OR s.section_id = ?', array($bad->id, $bad->id))->fetchArray();
     108    if (!$n_inters || $n_inters[0]['ct'] < 1) {
    108109      $query = Doctrine_Query::create()
    109110        ->delete('Section s')
     
    111112      if (!$query->execute())
    112113        print "Impossible de supprimer la section vide N°$bad->id : $bad->titre_complet";
    113       #else print "Section vide N°$bad->id : $bad->titre_complet supprimée";
     114      else print "  -> Section vide N°$bad->id : $bad->titre_complet supprimée\n";
    114115    } else self::updateCounts($bad, -$ni, -$nc);
    115116  }
Note: See TracChangeset for help on using the changeset viewer.