function afficheSousRubriques($bud, $id_rub, &$form, $indent = 0) { global $dbh, $charset; global $view_lig_rub_form, $lig_rub_img, $lig_indent; global $acquisition_gestion_tva; switch ($acquisition_gestion_tva) { case '0': case '2': $htttc = htmlentities($msg['acquisition_ttc'], ENT_QUOTES, $charset); $k_htttc = 'ttc'; $k_htttc_autre = 'ht'; break; default: $htttc = htmlentities($msg['acquisition_ht'], ENT_QUOTES, $charset); $k_htttc = 'ht'; $k_htttc_autre = 'ttc'; break; } $id_bud = $bud->id_budget; $q = budgets::listRubriques($id_bud, $id_rub); $list_n = pmb_mysql_query($q, $dbh); while ($row = pmb_mysql_fetch_object($list_n)) { $form = str_replace('<!-- sous_rub' . $id_rub . ' -->', $view_lig_rub_form . '<!-- sous_rub' . $id_rub . ' -->', $form); $marge = ''; for ($i = 0; $i < $indent; $i++) { $marge .= $lig_indent; } $form = str_replace('<!-- marge -->', $marge, $form); $nb_sr = rubriques::countChilds($row->id_rubrique); if ($nb_sr) { $form = str_replace('<!-- img_plus -->', $lig_rub_img, $form); } else { $form = str_replace('<!-- img_plus -->', '', $form); } $form = str_replace('<!-- sous_rub -->', '<!-- sous_rub' . $row->id_rubrique . ' -->', $form); $form = str_replace('!!id_rub!!', $row->id_rubrique, $form); $form = str_replace('!!id_parent!!', $row->num_parent, $form); $libelle = htmlentities($row->libelle, ENT_QUOTES, $charset); $form = str_replace('!!lib_rub!!', $libelle, $form); //montant total $mnt['tot'][$k_htttc] = $row->montant; //montant a valider $mnt['ava'] = rubriques::calcAValider($row->id_rubrique); //montant engage $mnt['eng'] = rubriques::calcEngage($row->id_rubrique); //montant facture $mnt['fac'] = rubriques::calcFacture($row->id_rubrique); //montant paye $mnt['pay'] = rubriques::calcPaye($row->id_rubrique); //solde $mnt['sol'][$k_htttc] = $mnt['tot'][$k_htttc] - $mnt['eng'][$k_htttc]; $lib_mnt = array(); foreach ($mnt as $k => $v) { $lib_mnt[$k] = number_format($mnt[$k][$k_htttc], 2, '.', ' '); if ($acquisition_gestion_tva && $k != "tot" && $k != "sol") { $lib_mnt_autre[$k] = number_format($mnt[$k][$k_htttc_autre], 2, '.', ' '); } } if ($bud->type_budget == TYP_BUD_GLO) { $lib_mnt['tot'] = ' '; $lib_mnt['sol'] = ' '; } foreach ($lib_mnt as $k => $v) { if (!$acquisition_gestion_tva || !$lib_mnt_autre[$k]) { $form = str_replace('!!mnt_' . $k . '!!', $lib_mnt[$k], $form); } elseif ($acquisition_gestion_tva) { $form = str_replace('!!mnt_' . $k . '!!', $lib_mnt[$k] . "<br />" . $lib_mnt_autre[$k], $form); } } if ($nb_sr) { afficheSousRubriques($bud, $row->id_rubrique, $form, $indent + 1); } } }
function afficheSousRubriques($id_bud, $id_rub, &$form, $indent = 0) { global $dbh, $msg, $charset; global $lig_rub, $lig_rub_img, $lig_indent; $bud = new budgets($id_bud); $q = budgets::listRubriques($id_bud, $id_rub); $list_n = mysql_query($q, $dbh); while ($row = mysql_fetch_object($list_n)) { $form = str_replace('<!-- sous_rub' . $id_rub . ' -->', $lig_rub[0] . '<!-- sous_rub' . $id_rub . ' -->', $form); $marge = ''; for ($i = 0; $i < $indent; $i++) { $marge .= $lig_indent; } $form = str_replace('<!-- marge -->', $marge, $form); if (rubriques::countChilds($row->id_rubrique)) { $form = str_replace('<!-- img_plus -->', $lig_rub_img, $form); } else { $form = str_replace('<!-- img_plus -->', '', $form); } $form = str_replace('<!-- sous_rub -->', '<!-- sous_rub' . $row->id_rubrique . ' -->', $form); $form = str_replace('!!id_rub!!', $row->id_rubrique, $form); $form = str_replace('!!id_parent!!', $row->num_parent, $form); $form = str_replace('!!lib_rub!!', $row->libelle, $form); if ($bud->type_budget == TYP_BUD_RUB) { $form = str_replace('!!mnt!!', $row->montant, $form); } else { $form = str_replace('!!mnt!!', ' ', $form); } $form = str_replace('!!ncp!!', $row->num_cp_compta, $form); afficheSousRubriques($id_bud, $row->id_rubrique, $form, $indent + 1); } }