Exemple #1
0
     if (!$id_bud) {
         if (!$sel_typ) {
             $bu->type_budget = TYP_BUD_RUB;
             //Affectation par rubriques
             $bu->montant_global = 0;
         } else {
             $bu->type_budget = TYP_BUD_GLO;
             //Affectation globale
             $bu->montant_global = $mnt_bud;
         }
     } else {
         if ($bu->type_budget == TYP_BUD_GLO) {
             $bu->montant_global = $mnt_bud;
         }
     }
     $bu->save();
     if ($id_bud) {
         show_list_budg($id_bibli);
     } else {
         show_budg_form($id_bibli, $bu->id_budget);
     }
     break;
 case 'del':
     if ($id_bud) {
         $budg = new budgets($id_bud);
         $total1 = budgets::hasLignes($id_bud);
         $total2 = budgets::countRubriques($id_bud);
         if ($total1 == 0 && $total2 == 0) {
             budgets::delete($id_bud);
             show_list_budg($id_bibli);
         } else {
Exemple #2
0
 static function calcMontant($id_budget = 0)
 {
     global $dbh;
     if ($id_budget) {
         $q = "select sum(montant) from rubriques where num_budget = '" . $id_budget . "' and num_parent = '0' ";
         $r = mysql_query($q, $dbh);
         $total = mysql_result($r, 0, 0);
         $budget = new budgets($id_budget);
         $budget->montant_global = $total;
         $budget->save();
     }
 }