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); } } }
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); } } }
$requete .= "order by lib limit 20"; $origine = "SQL"; break; case 'rubriques': // $param1 : id_entite // $param2 : id_exercice require_once $class_path . '/rubriques.class.php'; $array_selector = array(); $requete = "select budgets.libelle as lib_bud, rubriques.* from budgets, rubriques left join rubriques as rubriques2 on rubriques.id_rubrique=rubriques2.num_parent "; $requete .= "where budgets.statut = '1' and budgets.num_entite = '" . $param1 . "' and budgets.num_exercice = '" . $param2 . "' and rubriques.num_budget = budgets.id_budget and rubriques2.num_parent is NULL "; $requete .= "and rubriques.autorisations like(' %" . SESSuserid . "% ') "; $requete .= "and rubriques.libelle like '" . addslashes($start) . "%' "; $requete .= "order by budgets.libelle, rubriques.id_rubrique "; $res = pmb_mysql_query($requete); while ($row = pmb_mysql_fetch_object($res)) { $tab_rub = rubriques::listAncetres($row->id_rubrique, true); $lib_rub = ''; foreach ($tab_rub as $dummykey => $value) { $lib_rub .= htmlentities($value[1], ENT_QUOTES, $charset); if ($value[0] != $row->id_rubrique) { $lib_rub .= ":"; } } $array_selector[$row->id_rubrique] = htmlentities($row->lib_bud, ENT_QUOTES, $charset) . ":" . $lib_rub; } $origine = "ARRAY"; break; case 'perso_notices': require_once $class_path . '/parametres_perso.class.php'; $p_perso = new parametres_perso('notices'); $array_selector = $p_perso->get_ajax_list($persofield, $start);
function select_rub($id_cde, $id_rubrique = 0) { global $msg, $charset; global $select_rub; $cde = new actes($id_cde); if ($cde->statut >= STA_ACT_ARC) { //Commande archivée, facture non modifiable $lig_rub = $select_rub[1]; if (!$id_rubrique) { $id_rubrique = 0; $lib_rub = ''; } else { $rub = new rubriques($id_rubrique); $bud = new budgets($rub->num_budget); $lib_bud = $bud->libelle; $tab_rub = rubriques::listAncetres($id_rubrique, true); $lib_rub = $lib_bud . ':'; foreach ($tab_rub as $value) { $lib_rub .= htmlentities($value[1], ENT_QUOTES, $charset); if ($value[0] != $id_rubrique) { $lib_rub .= ":"; } } } $lig_rub = str_replace('!!id_rub!!', $id_rubrique, $lig_rub); $lig_rub = str_replace('!!lib_rub!!', $lib_rub, $lig_rub); } else { //Commande non archivée, modification des rubriques possible if (!$id_rubrique) { //Pas de rubrique sélectionnée $lig_rub = $select_rub[0]; $lig_rub = str_replace('!!id_rub!!', 0, $lig_rub); $lig_rub = str_replace('!!lib_rub!!', '', $lig_rub); } else { //Rubrique selectionnée $user_userid = getCurrentUserId(); $rub = new rubriques($id_rubrique); $bud = new budgets($rub->num_budget); if (!rubriques::getAutorisations($id_rubrique, $user_userid)) { //L'utilisateur n'a pas de droits sur la rubrique $lig_rub = $select_rub[1]; } else { //L'utilisateur à des droits sur la rubrique $lig_rub = $select_rub[0]; } $lig_rub = str_replace('!!id_rub!!', $rub->id_rubrique, $lig_rub); $lib_bud = htmlentities($bud->libelle, ENT_QUOTES, $charset); $tab_rub = rubriques::listAncetres($id_rubrique, true); $lib_rub = $lib_bud . ':'; foreach ($tab_rub as $value) { $lib_rub .= htmlentities($value[1], ENT_QUOTES, $charset); if ($value[0] != $id_rubrique) { $lib_rub .= ":"; } } $lig_rub = str_replace('!!lib_rub!!', $lib_rub, $lig_rub); } } return $lig_rub; }
function verif_bud() { global $msg; global $max_lig; global $qte, $prix, $rem, $rub; global $error, $error_msg; global $acquisition_budget; if ($acquisition_budget) { $tot_rub = array(); $tot_bud = array(); for ($i = 1; $i <= $max_lig; $i++) { $tot_rub[$rub[$i]] = 0; } //récupère le total de la commande par rubrique for ($i = 1; $i <= $max_lig; $i++) { $tot_rub[$rub[$i]] = $tot_rub[$rub[$i]] + $qte[$i] * $prix[$i] * (1 - $rem[$i] / 100); } //récupère le total de la commande par budget foreach ($tot_rub as $key => $value) { $r = new rubriques($key); if (!array_key_exists($r->num_budget, $tot_bud)) { $tot_bud[$r->num_budget] = 0; } $tot_bud[$r->num_budget] = $tot_bud[$r->num_budget] + $value; } //Vérifie que les budgets affectés par rubrique ne sont pas dépassés foreach ($tot_rub as $key => $value) { $r = new rubriques($key); $b = new budgets($r->num_budget); if ($b->type_budget == TYP_BUD_RUB) { //Budget affecté par rubrique $mnt_rub = $r->montant; $eng_rub = rubriques::calcEngagement($key) + $value; //Budget rubrique dépassé ? if ($eng_rub > $mnt_rub) { $error = true; $tab_rub = rubriques::listAncetres($key, true); $lib_rub = $b->libelle . ":"; foreach ($tab_rub as $value) { $lib_rub .= $value[1]; if ($value[0] != $key) { $lib_rub .= ":"; } } $error_msg = $msg['acquisition_rub'] . " :\\n\\n " . $lib_rub . "\\n\\n" . $msg['acquisition_act_bud_dep']; break; } } } //Vérifie que les budgets affectés globalement ne sont pas dépassés foreach ($tot_bud as $key => $value) { $b = new budgets($key); if ($b->type_budget == TYP_BUD_GLO) { $mnt_bud = $b->montant_global; $eng_bud = budgets::calcEngagement($b->id_budget) + $value; //Budget dépassé ? if ($eng_bud > $mnt_bud) { $error = true; $error_msg = $msg['acquisition_act_tab_bud'] . " : " . $b->libelle . "\\n\\n" . $msg['acquisition_act_bud_dep']; break; } } } } }
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); } }
function show_results($dbh, $nbr_lignes = 0, $page = 0) { global $nb_per_page; global $base_url; global $caller; global $charset; global $msg; global $id_bibli, $id_exer; global $acquisition_budget_show_all; global $elt_query; // on récupére le nombre de lignes qui vont bien $nbr_lignes = entites::countRubriquesFinales($id_bibli, $id_exer, true, $elt_query); if (!$page) { $page = 1; } $debut = ($page - 1) * $nb_per_page; if ($nbr_lignes) { // on lance la vraie requête if (!$acquisition_budget_show_all) { $res = entites::listRubriquesFinales($id_bibli, $id_exer, true, $debut, $nb_per_page, $elt_query); } else { $res = entites::listRubriquesFinales($id_bibli, $id_exer, true, 0, 0, $elt_query); } $id_bud = 0; print "<div class=\"row\"><table><tr><th>" . htmlentities($msg['acquisition_rub'], ENT_QUOTES, $charset) . "</th><th>" . htmlentities($msg['acquisition_rub_sol'], ENT_QUOTES, $charset) . "</th></tr>"; while ($row = mysql_fetch_object($res)) { $new_id_bud = $row->num_budget; if ($new_id_bud != $id_bud) { $id_bud = $new_id_bud; print pmb_bidi("<tr><td>" . htmlentities($row->lib_bud, ENT_QUOTES, $charset) . "</td>"); if ($row->type_budget) { $aff_glo = true; $mnt = $row->montant_global; $cal = budgets::calcEngagement($id_bud); if ($cal > $mnt) { $sol = 0; } else { $sol = $mnt - $cal; } $sol = number_format($sol, 2, '.', ''); if ($cal > $mnt * ($row->seuil_alerte / 100)) { $alert = true; } else { $alert = false; } } else { $aff_glo = false; } print "<td></td></tr>"; } $tab_rub = rubriques::listAncetres($row->id_rubrique, true); $lib_rub = ''; $lib_rub_no_html = ""; foreach ($tab_rub as $dummykey => $value) { $lib_rub .= htmlentities($value[1], ENT_QUOTES, $charset); $lib_rub_no_html .= $value[1]; if ($value[0] != $row->id_rubrique) { $lib_rub .= ":"; } } if (!$aff_glo) { $mnt = $row->montant; $cal = rubriques::calcEngagement($row->id_rubrique); if ($cal > $mnt) { $sol = 0; } else { $sol = $mnt - $cal; } $sol = number_format($sol, 2, '.', ''); if ($cal >= $mnt * ($row->seuil_alerte / 100)) { $alert = true; } else { $alert = false; } } if ($alert) { $cl = "class='erreur' "; } else { $cl = ''; } print "<tr><td><div class='child_tab'>"; print pmb_bidi("\n\t\t\t<a href='#' onclick=\"set_parent('{$caller}', '{$row->id_rubrique}', '" . htmlentities(addslashes($row->lib_bud . ":" . $lib_rub_no_html), ENT_QUOTES, $charset) . "' )\" ><span " . $cl . ">" . $lib_rub . "</span></a>\n\t\t\t</div></td><td style='text-align:right;'><span " . $cl . ">" . $sol . "</span></td></tr>"); } print "</table>"; mysql_free_result($res); // affichage pagination print "<hr /><div align='center'>"; if (!$acquisition_budget_show_all) { $base_url .= "&elt_query=" . $elt_query; $nav_bar = aff_pagination($base_url, $nbr_lignes, $nb_per_page, $page, 10, true, true); print $nav_bar; } print "</div></div>"; } }
static function duplicate($id_budget = 0) { global $dbh; $new_bud = new budgets($id_budget); $new_bud->id_budget = 0; $lib = $new_bud->libelle . '_'; $l_lib = strlen($lib); $q = "select if(max(substring(libelle, " . $l_lib . "+1)) is null, 1, max(substring(libelle, " . $l_lib . "+1))+1) from budgets "; $q .= "where substring(libelle, 1, " . $l_lib . ") = '" . addslashes($lib) . "' "; $q .= "and substring(libelle, " . $l_lib . "+1) regexp '^[0-9]+\$' "; $r = mysql_query($q, $dbh); $n = mysql_result($r, 0, 0); $new_bud->libelle = $lib . $n; $new_bud->statut = STA_BUD_PRE; $new_bud->save(); $id_new_bud = $new_bud->id_budget; $q = budgets::listAllRubriques($id_budget); $r = mysql_query($q, $dbh); $tab_p = array(); while ($obj = mysql_fetch_object($r)) { $new_rub = new rubriques($obj->id_rubrique); $new_rub->num_budget = $id_new_bud; $new_rub->id_rubrique = 0; if ($obj->num_parent) { $new_rub->num_parent = $tab_p[$obj->num_parent]; } $new_rub->save(); $id_new_rub = $new_rub->id_rubrique; $tab_p[$obj->id_rubrique] = $id_new_rub; } return $id_new_bud; }
function show_list_recept() { global $msg, $charset, $dbh, $tab_bib; global $recept_search_form, $recept_list_form, $recept_search_form_suite, $recept_hrow_form, $recept_row_form, $sel_fou_form, $sel_dem_form, $sel_rub_form, $sel_date_form; global $bt_app, $bt_rel, $bt_chk, $link_not, $link_bull, $link_art, $link_sug, $bt_cat; global $user_userid; global $lgstat_filter, $deflt3lgstatcde; global $id_bibli, $id_exer; global $f_fou_code, $f_dem_code, $t_dem, $f_rub_code; global $cde_query, $all_query, $recept_query; global $chk_dev; global $lgstat_all, $comment_lg_all, $comment_lo_all; global $page, $nb_per_page, $nbr_lignes, $last_param; global $date_inf, $date_sup; //verifications if (!$id_bibli) { $id_bibli = entites::getSessionBibliID(); } if (!$id_bibli) { $id_bibli = $tab_bib[0][0]; } entites::setSessionBibliId($id_bibli); $id_exer = exercices::getSessionExerciceId($id_bibli, $id_exer); //Affichage form de recherche $titre = htmlentities($msg['recherche'] . ' : ' . $msg['acquisition_recept'], ENT_QUOTES, $charset); $recept_form = $recept_search_form; $recept_form = str_replace('!!form_title!!', $titre, $recept_form); $serialized_search = rawurlencode(serialize(array('id_bibli' => $id_bibli, 'id_exer' => $id_exer, 'f_fou_code' => $f_fou_code, 'f_dem_code' => $f_dem_code, 't_dem' => $t_dem, 'f_rub_code' => $f_rub_code, 'cde_query' => stripslashes($cde_query), 'all_query' => stripslashes($all_query), 'chk_dev' => $chk_dev, 'lgstat_filter' => $lgstat_filter))); $recept_form = str_replace('!!serialized_search!!', $serialized_search, $recept_form); //Affichage selecteur etablissement $sel_bibli = entites::getBibliHtmlSelect(SESSuserid, $id_bibli, FALSE, array('class' => 'saisie-50em', 'id' => 'id_bibli', 'name' => 'id_bibli', 'onChange' => 'submit();')); $recept_form = str_replace('<!-- sel_bibli -->', $sel_bibli, $recept_form); //Affichage selecteur exercice $sel_exer = exercices::getHtmlSelect($id_bibli, $id_exer, FALSE, array('id' => 'id_exer', 'name' => 'id_exer', 'onChange' => 'submit();')); $recept_form = str_replace('<!-- sel_exer -->', $sel_exer, $recept_form); //Affichage fournisseurs $i = 0; $tab_fou2 = array(); if (is_array($f_fou_code) && count($f_fou_code)) { $tab_fou = entites::getRaisonSociale($f_fou_code, $id_bibli); foreach ($f_fou_code as $v) { if ($v && $tab_fou[$v]) { $tab_fou2[$v] = $tab_fou[$v]; if ($i > 0) { $recept_form = str_replace('<!-- sel_fou -->', $sel_fou_form . '<!-- sel_fou -->', $recept_form); $recept_form = str_replace('!!i!!', $i, $recept_form); } $recept_form = str_replace('!!f_fou_code!!', $v, $recept_form); $recept_form = str_replace('!!f_fou!!', htmlentities($tab_fou[$v], ENT_QUOTES, $charset), $recept_form); $i++; } } $recept_form = str_replace('!!max_fou!!', $i > 0 ? $i : '1', $recept_form); } if (!$i) { $recept_form = str_replace('!!f_fou_code!!', '0', $recept_form); $recept_form = str_replace('!!f_fou!!', '', $recept_form); $recept_form = str_replace('!!max_fou!!', '1', $recept_form); } //Affichage demandeurs $i = 0; $tab_empr = array(); $tab_user = array(); if (is_array($f_dem_code) && count($f_dem_code) && is_array($t_dem) && count($t_dem)) { foreach ($f_dem_code as $k => $v) { if ($t_dem[$k]) { $tab_empr[] = $v; } else { $tab_user[] = $v; } } $tab_empr = emprunteur::getName($tab_empr); $tab_user = getUserName($tab_user); foreach ($f_dem_code as $k => $v) { if ($v && ($t_dem[$k] === '0' && $tab_user[$v] || $t_dem[$k] === '1' && $tab_empr[$v])) { if ($i > 0) { $recept_form = str_replace('<!-- sel_dem -->', $sel_dem_form . '<!-- sel_dem -->', $recept_form); $recept_form = str_replace('!!i!!', $i, $recept_form); } $recept_form = str_replace('!!f_dem_code!!', $v, $recept_form); $recept_form = str_replace('!!t_dem!!', $t_dem[$k], $recept_form); if ($t_dem[$k]) { $recept_form = str_replace('!!f_dem!!', htmlentities($tab_empr[$v], ENT_QUOTES, $charset), $recept_form); } else { $recept_form = str_replace('!!f_dem!!', htmlentities($tab_user[$v], ENT_QUOTES, $charset), $recept_form); } $i++; } } $recept_form = str_replace('!!max_dem!!', $i > 0 ? $i : '1', $recept_form); } if (!$i) { $recept_form = str_replace('!!f_dem_code!!', '0', $recept_form); $recept_form = str_replace('!!t_dem!!', '0', $recept_form); $recept_form = str_replace('!!f_dem!!', '', $recept_form); $recept_form = str_replace('!!max_dem!!', '1', $recept_form); } //Affichage rubriques budgetaires $i = 0; $tab_rub2 = array(); if (is_array($f_rub_code) && count($f_rub_code)) { $tab_rub = rubriques::getLibelle($f_rub_code, $id_bibli, $id_exer, SESSuserid); foreach ($f_rub_code as $v) { if ($v && $tab_rub[$v]) { $tab_rub2[$v] = $tab_rub[$v]; if ($i > 0) { $recept_form = str_replace('<!-- sel_rub -->', $sel_rub_form . '<!-- sel_rub -->', $recept_form); $recept_form = str_replace('!!i!!', $i, $recept_form); } $recept_form = str_replace('!!f_rub_code!!', $v, $recept_form); $recept_form = str_replace('!!f_rub!!', htmlentities($tab_rub[$v], ENT_QUOTES, $charset), $recept_form); $i++; } } $recept_form = str_replace('!!max_rub!!', $i > 0 ? $i : '1', $recept_form); } if (!$i) { $recept_form = str_replace('!!f_rub_code!!', '0', $recept_form); $recept_form = str_replace('!!f_rub!!', '', $recept_form); $recept_form = str_replace('!!max_rub!!', '1', $recept_form); } //Affichage zone commande if (!isset($chk_dev)) { $chk_dev = TYP_ACT_CDE; } if ($chk_dev) { $recept_form = str_replace('!!dev_checked!!', "checked='checked'", $recept_form); $recept_form = str_replace('!!cde_checked!!', '', $recept_form); } else { $recept_form = str_replace('!!dev_checked!!', '', $recept_form); $recept_form = str_replace('!!cde_checked!!', "checked='checked'", $recept_form); } $recept_form = str_replace('!!cde_query!!', htmlentities(stripslashes($cde_query), ENT_QUOTES, $charset), $recept_form); //Affichage selecteur dates $sel_date_form[0] = str_replace('!!msg!!', htmlentities($msg['acquisition_recept_date'], ENT_QUOTES, $charset), $sel_date_form[0]); if ($date_inf) { $date_inf_lib = formatdate($date_inf); } else { $date_inf_lib = $msg['parperso_nodate']; } $sel_date_form[1] = str_replace('!!date_inf!!', $date_inf, $sel_date_form[1]); $sel_date_form[1] = str_replace('!!date_inf_lib!!', $date_inf_lib, $sel_date_form[1]); if ($date_sup) { $date_sup_lib = formatdate($date_sup); } else { $date_sup_lib = $msg['parperso_nodate']; } $sel_date_form[2] = str_replace('!!date_sup!!', $date_sup, $sel_date_form[2]); $sel_date_form[2] = str_replace('!!date_sup_lib!!', $date_sup_lib, $sel_date_form[2]); $sel_date_form[0] = sprintf($sel_date_form[0], $sel_date_form[1], $sel_date_form[2]); $recept_form = str_replace('<!-- sel_date -->', $sel_date_form[0], $recept_form); //Creation selecteur statut de lignes de commandes if (!(is_array($lgstat_filter) && count($lgstat_filter))) { $lgstat_filter = array(0 => $deflt3lgstatcde); } $sel_lgstat = lgstat::getHtmlSelect($lgstat_filter, FALSE, array('id' => 'lgstat_filter[]', 'name' => 'lgstat_filter[]', 'multiple' => 'multiple', 'size' => '5')); $recept_form = str_replace('<!-- sel_lgstat -->', $sel_lgstat, $recept_form); //Affichage zone tous les champs $recept_form = str_replace('!!all_query!!', htmlentities(stripslashes($all_query), ENT_QUOTES, $charset), $recept_form); //Prise en compte du formulaire de recherche // nombre de références par pages if (!$nb_per_page) { $nb_per_page = 10; } if (!$page) { $page = 1; } $debut = ($page - 1) * $nb_per_page; //La recherche ici $recept = new receptions($id_bibli, $id_exer); //filtre $filtres = $recept->setFiltres(array_keys($tab_fou2), array_keys($tab_empr), array_keys($tab_user), array_keys($tab_rub2), $chk_dev, $cde_query, $lgstat_filter, $date_inf, $date_sup); // comptage if (!$nbr_lignes) { $nbr_lignes = $recept->calcNbLignes($all_query); $err = $recept->getError(); } // liste if ($nbr_lignes) { $t_list = $recept->getLignes(); //Affichage des lignes $recept_form .= $recept_list_form; //Affichage zone de reception $recept_form = str_replace('!!recept_query!!', htmlentities(stripslashes($recept_query), ENT_QUOTES, $charset), $recept_form); $tab_aff = array(); $lgstat_form = lgstat::getHtmlSelect(array(0 => 0), FALSE, array('id' => 'sel_lgstat_!!id_lig!!', 'onchange' => 'recept_upd_lgstat(this.getAttribute("id"));')); $act_form = ''; $i = 1; foreach ($t_list as $id_acte => $t_row) { //Affichage lignes à recevoir foreach ($t_row as $id_ligne => $row) { if (!in_array($id_acte, $tab_aff)) { array_push($tab_aff, $id_acte); $recept_form = str_replace('<!-- actes -->', $act_form . '<!-- actes -->', $recept_form); $act_form = str_replace('!!lib_acte!!', htmlentities($msg['acquisition_recept_fou'], ENT_QUOTES, $charset) . " <a href=\"./acquisition.php?categ=ach&sub=fourn&action=modif&id_bibli=" . $id_bibli . '&id=' . $row['num_fournisseur'] . "\">" . htmlentities($row['raison_sociale'], ENT_QUOTES, $charset) . "</a>" . ' ' . (htmlentities($row['type_acte'] ? $msg['acquisition_act_num_dev'] : $msg['acquisition_act_num_cde'], ENT_QUOTES, $charset) . "<a href=\"./acquisition.php?categ=ach&sub=" . ($row['type_acte'] ? 'devi' : 'cmde') . "&action=modif&id_bibli=" . $id_bibli . ($row['type_acte'] ? '&id_dev=' : '&id_cde=') . $id_acte . "\">" . htmlentities($row['numero'], ENT_QUOTES, $charset) . "</a>") . ' ' . htmlentities($msg['653'], ENT_QUOTES, $charset) . ' ' . formatdate($row['date_acte']), $recept_hrow_form); } $row_form = $recept_row_form; $row_form = str_replace('!!code!!', htmlentities($row['code'], ENT_QUOTES, $charset), $row_form); $row_form = str_replace('!!lib!!', nl2br(htmlentities($row['libelle'], ENT_QUOTES, $charset)), $row_form); $row_form = str_replace('!!qte_cde!!', $row['nb_cde'], $row_form); $row_form = str_replace('!!qte_liv!!', $row['nb_liv'], $row_form); $row_form = str_replace('!!qte_sol!!', $row['nb_sol'], $row_form); $lgstat_row_form = str_replace("value='" . $row['statut'] . "'", "value='" . $row['statut'] . "' selected='selected' ", $lgstat_form); $row_form = str_replace('!!lgstat!!', $lgstat_row_form, $row_form); $row_form = str_replace('!!comment_lg!!', nl2br(htmlentities($row['commentaires_gestion'], ENT_QUOTES, $charset)), $row_form); $row_form = str_replace('!!comment_lo!!', nl2br(htmlentities($row['commentaires_opac'], ENT_QUOTES, $charset)), $row_form); $row_form = str_replace('!!id_lig!!', $id_ligne, $row_form); $row_form = str_replace('!!typ_lig!!', $row['type_ligne'], $row_form); if ($row['num_produit']) { switch ($row['type_ligne']) { case '1': //notice $row_form = str_replace('<!-- link_cat -->', $link_not, $row_form); break; case '2': //bulletin $row_form = str_replace('<!-- link_cat -->', $link_bull, $row_form); break; case '5': //article $id_bull = analysis::getBulletinIdFromAnalysisId($row['num_produit']); if ($id_bull) { $row_form = str_replace('<!-- link_cat -->', $link_art, $row_form); $row_form = str_replace('!!id_bull!!', $id_bull, $row_form); } break; default: break; } } else { $tmp_bt_cat = str_replace('!!id_lig!!', $id_ligne, $bt_cat); $row_form = str_replace('<!-- bt_cat -->', $tmp_bt_cat, $row_form); } if ($row['num_acquisition']) { $row_form = str_replace('<!-- link_sug -->', $link_sug, $row_form); $row_form = str_replace('!!id_sug!!', $row['num_acquisition'], $row_form); } $row_form = str_replace('!!id_prod!!', $row['num_produit'], $row_form); $row_form = str_replace('!!no!!', $i, $row_form); $tab_rel = array(); $tab_rel = lignes_actes::getRelances($id_ligne); $row_form = str_replace('!!nb_relances!!', htmlentities(sprintf($msg['acquisition_recept_hist'], count($tab_rel)), ENT_QUOTES, $charset), $row_form); if (count($tab_rel)) { $row_form = str_replace('<!-- relances -->', implode(' - ', $tab_rel), $row_form); } $act_form = str_replace('<!-- lignes -->', $row_form . '<!-- lignes -->', $act_form); $i++; } } $recept_form = str_replace('<!-- actes -->', $act_form . '<!-- actes -->', $recept_form); $recept_form = str_replace('!!max_no!!', $i * 1 - 1, $recept_form); //Affichage commentaires $recept_form = str_replace('!!comment_lg_all!!', htmlentities(stripslashes($comment_lg_all), ENT_QUOTES, $charset), $recept_form); $recept_form = str_replace('!!comment_lo_all!!', htmlentities(stripslashes($comment_lo_all), ENT_QUOTES, $charset), $recept_form); //boutons $lgstat_all = lgstat::getHtmlSelect(array(0 => 0), $msg['acquisition_recept_lgstat_none'], array('id' => 'sel_lgstat_all', 'name' => 'sel_lgstat_all')); $recept_form = str_replace('<!-- sel_lgstat_all -->', $lgstat_all, $recept_form); $recept_form = str_replace('<!-- bt_app -->', $bt_app, $recept_form); $recept_form = str_replace('<!-- bt_rel -->', $bt_rel, $recept_form); $recept_form = str_replace('<!-- bt_chk -->', $bt_chk, $recept_form); //Barre de navigation /* if (!$last_param) { $nav_bar = aff_pagination ($url_base, $nbr_lignes, $nb_per_page, $page, 10, true, true) ; } else { $nav_bar = ""; } $recept_form=str_replace('<!-- nav_bar -->', $nav_bar,$recept_form); */ $recept_form .= $recept_search_form_suite; print $recept_form; } elseif ($err) { //erreur dans la recherche $recept_form .= $recept_search_form_suite; print $recept_form; print $err; } else { // pas de resultat $recept_form .= $recept_search_form_suite; print $recept_form; $cle = array(); if ($cde_query) { $cle[] = htmlentities($msg['acquisition_recept_act_search'] . ' ' . stripslashes($cde_query), ENT_QUOTES, $charset); } if ($all_query) { $cle[] = htmlentities($msg['acquisition_recept_global_search'] . ' ' . stripslashes($all_query), ENT_QUOTES, $charset); } error_message($msg['acquisition_recept_rech'], str_replace('!!cle!!', implode(',', $cle), $msg['acquisition_recept_rech_error']), 0); } }