Example #1
0
 static function maj($num_parent = 0, $calcul = TRUE)
 {
     global $dbh;
     if ($calcul) {
         if ($num_parent) {
             $q = "select sum(montant) from rubriques where num_parent = '" . $num_parent . "' ";
             $r = mysql_query($q, $dbh);
             $total = mysql_result($r, 0, 0);
             $parent = new rubriques($num_parent);
             $parent->montant = $total;
             $parent->num_cp_compta = '';
             $parent->autorisations = '';
             $parent->save();
             rubriques::maj($parent->num_parent);
         }
     } else {
         if ($num_parent) {
             $parent = new rubriques($num_parent);
             $parent->num_cp_compta = '';
             $parent->autorisations = '';
             $parent->save();
             rubriques::maj($parent->num_parent, FALSE);
         }
     }
 }
Example #2
0
 case 'del_rub':
     if ($id_rub) {
         $rub = new rubriques($id_rub);
         $total1 = rubriques::hasLignes($id_rub);
         $total2 = rubriques::countChilds($id_rub);
         if ($total1 == 0 && $total2 == 0) {
             rubriques::delete($id_rub);
             $bud = new budgets($id_bud);
             if ($bud->type_budget == TYP_BUD_RUB) {
                 //màj des rubriques supérieures
                 rubriques::maj($id_parent, TRUE);
                 //recalcul du montant global de budget
                 budgets::calcMontant($id_bud);
             } else {
                 //màj des rubriques supérieures sans recalcul
                 rubriques::maj($id_parent, FALSE);
             }
             if ($id_parent) {
                 $rub_parent = new rubriques($id_parent);
                 show_rub_form($id_bud, $id_parent, $rub_parent->num_parent);
             } else {
                 show_budg_form($id_bibli, $id_bud);
             }
         } else {
             $msg_suppr_err = $msg[acquisition_rub_used];
             if ($total1) {
                 $msg_suppr_err .= "<br />- " . $msg[acquisition_rub_used_lg];
             }
             if ($total2) {
                 $msg_suppr_err .= "<br />- " . $msg[acquisition_rub_used_childs];
             }