Пример #1
0
 function remove()
 {
     if ($this->id >= 500000) {
         throw new Exception(_('Catégorie verrouillée '));
     }
     $remain = 0;
     /* get all the card */
     $aFiche = fiche::get_fiche_def($this->cn, $this->id);
     if ($aFiche != null) {
         /* check if the card is used */
         foreach ($aFiche as $dfiche) {
             $fiche = new Fiche($this->cn, $dfiche['f_id']);
             /* if the card is not used then remove it otherwise increment remains */
             if ($fiche->is_used() == false) {
                 $fiche->delete();
             } else {
                 $remain++;
             }
         }
     }
     /* if remains == 0 then remove cat */
     if ($remain == 0) {
         $sql = 'delete from jnt_fic_attr where fd_id=$1';
         $this->cn->exec_sql($sql, array($this->id));
         $sql = 'delete from fiche_def where fd_id=$1';
         $this->cn->exec_sql($sql, array($this->id));
     }
     return $remain;
 }