Example #1
0
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;
}
Example #2
0
     $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);
Example #3
0
function show_rub_form($id_bud, $id_rub = 0, $id_parent = 0)
{
    global $dbh, $msg, $charset;
    global $rub_form, $bt_add_lig;
    global $ptab;
    global $lig_rub, $lig_rub_img;
    global $mnt_rub_form;
    //Récuperation du budget
    if ($id_bud) {
        $bud = new budgets($id_bud);
    } else {
        die;
    }
    //Récupération entité
    $id_bibli = $bud->num_entite;
    $biblio = new entites($id_bibli);
    $head_form = "<div class='row'><label class='etiquette'>" . htmlentities($biblio->raison_sociale, ENT_QUOTES, $charset) . "</label></div>";
    //Affichage entete formulaire
    if (!$id_rub) {
        //création de rubrique
        $rub_form = str_replace('!!form_title!!', htmlentities($msg[acquisition_ajout_rub], ENT_QUOTES, $charset), $rub_form);
        //Affichage barre de navigation
        $nav_form .= "<a href=\"./admin.php?categ=acquisition&sub=budget&action=modif&id_bibli=" . $id_bibli . "&id_bud=" . $id_bud . "\" >" . $bud->libelle . "</a>";
        if ($id_parent) {
            $list_bar = rubriques::listAncetres($id_parent, TRUE);
            foreach ($list_bar as $value) {
                $nav_form .= "&nbsp;&gt;&nbsp;<a href=\"./admin.php?categ=acquisition&sub=budget&action=modif_rub&id_bud=" . $id_bud . "&id_rub=" . $value[0] . "&id_parent=" . $value[2] . "\" >" . htmlentities($value[1], ENT_QUOTES, $charset) . "</a>";
            }
        }
        $rub_form = str_replace('<!-- nav_form -->', $nav_form, $rub_form);
        $rub_form = str_replace('!!libelle!!', '', $rub_form);
        if ($bud->type_budget == TYP_BUD_RUB) {
            $rub_form = str_replace('<!-- lib_mnt -->', $mnt_rub_form[0], $rub_form);
            $mnt_rub = str_replace('!!mnt_rub!!', '0.00', $mnt_rub_form[1]);
            $rub_form = str_replace('<!-- montant -->', $mnt_rub, $rub_form);
            $rub_form = str_replace('!!lib_mnt!!', htmlentities($msg['acquisition_rub_mnt'], ENT_QUOTES, $charset), $rub_form);
        } else {
            $rub_form = str_replace('!!lib_mnt!!', '&nbsp;', $rub_form);
        }
        $label_ncp = "<label class='etiquette' for='ncp'>" . htmlentities($msg[acquisition_num_cp_compta], ENT_QUOTES, $charset) . "</label>";
        $rub_form = str_replace('<!-- label_ncp -->', $label_ncp, $rub_form);
        $ncp = "<input type='text' id='ncp' name='ncp' class='saisie-30em' style='text-align:right' value='' />";
        $rub_form = str_replace('!!ncp!!', $ncp, $rub_form);
        $rub_form = str_replace('!!comment!!', '', $rub_form);
        //Complément du bouton annuler
        if (!$id_parent) {
            $undo = "modif";
        } else {
            $undo = "modif_rub";
        }
        $rub_form = str_replace('!!undo!!', $undo, $rub_form);
        //complément du formulaire
        $rub_form = str_replace('!!id_bibli!!', $id_bibli, $rub_form);
        $rub_form = str_replace('!!id_bud!!', $id_bud, $rub_form);
        $rub_form = str_replace('!!id_rub!!', 0, $rub_form);
        $rub_form = str_replace('!!id_parent!!', $id_parent, $rub_form);
        //Affichage des autorisations
        autorisations($id_rub, $id_parent, $id_bud);
    } else {
        //modification de rubrique
        $rub_form = str_replace('!!form_title!!', htmlentities($msg[acquisition_modif_rub], ENT_QUOTES, $charset), $rub_form);
        //Récupération rubrique
        if ($id_rub) {
            $rub = new rubriques($id_rub);
        }
        //Affichage barre de navigation
        $nav_form .= "<a href=\"./admin.php?categ=acquisition&sub=budget&action=modif&id_bibli=" . $id_bibli . "&id_bud=" . $id_bud . "\" >" . $bud->libelle . "</a>";
        $list_bar = rubriques::listAncetres($id_rub, FALSE);
        foreach ($list_bar as $value) {
            $nav_form .= "&nbsp;&gt;&nbsp;<a href=\"./admin.php?categ=acquisition&sub=budget&action=modif_rub&id_bud=" . $id_bud . "&id_rub=" . $value[0] . "&id_parent=" . $value[2] . "\" >" . htmlentities($value[1], ENT_QUOTES, $charset) . "</a>";
        }
        $rub_form = str_replace('<!-- nav_form -->', $nav_form, $rub_form);
        $rub_form = str_replace('!!libelle!!', htmlentities($rub->libelle, ENT_QUOTES, $charset), $rub_form);
        if (!$bud->type_budget) {
            $rub_form = str_replace('!!lib_mnt!!', htmlentities($msg['acquisition_rub_mnt'], ENT_QUOTES, $charset), $rub_form);
            if (rubriques::countChilds($id_rub)) {
                $ncp = '&nbsp;';
                $aut = FALSE;
            } else {
                $rub_form = str_replace('<!-- lib_mnt -->', $mnt_rub_form[0], $rub_form);
                $mnt_rub = str_replace('!!mnt_rub!!', $rub->montant, $mnt_rub_form[1]);
                $rub_form = str_replace('<!-- montant -->', $mnt_rub, $rub_form);
                $label_ncp = "<label class='etiquette' for='ncp'>" . htmlentities($msg[acquisition_num_cp_compta], ENT_QUOTES, $charset) . "</label>";
                $ncp = "<input type='text' id='ncp' name='ncp' class='saisie-30em' style='text-align:right' value='" . $rub->num_cp_compta . "' />";
                $aut = TRUE;
            }
        } else {
            $rub_form = str_replace('!!lib_mnt!!', '&nbsp;', $rub_form);
            if (rubriques::countChilds($id_rub)) {
                $ncp = '&nbsp;';
                $aut = FALSE;
            } else {
                $label_ncp = "<label class='etiquette' for='ncp'>" . htmlentities($msg[acquisition_num_cp_compta], ENT_QUOTES, $charset) . "</label>";
                $ncp = "<input type='text' id='ncp' name='ncp' class='saisie-30em' style='text-align:right' value='" . $rub->num_cp_compta . "' />";
                $aut = TRUE;
            }
        }
        $rub_form = str_replace('<!-- label_ncp -->', $label_ncp, $rub_form);
        $rub_form = str_replace('!!ncp!!', $ncp, $rub_form);
        $rub_form = str_replace('!!comment!!', htmlentities($rub->commentaires, ENT_QUOTES, $charset), $rub_form);
        //complément du formulaire
        $rub_form = str_replace('!!id_rub!!', $id_rub, $rub_form);
        $rub_form = str_replace('!!id_parent!!', $id_parent, $rub_form);
        //affichage du bouton ajout rubrique si budget non clôturé
        if ($bud->statut != STA_BUD_CLO) {
            $bt_add_lig = str_replace('!!id_rub!!', '0', $bt_add_lig);
            $bt_add_lig = str_replace('!!id_parent!!', $id_rub, $bt_add_lig);
            $rub_form = str_replace('<!-- bouton_lig -->', $bt_add_lig, $rub_form);
        }
        //Complément du bouton annuler
        if (!$id_parent) {
            $undo = "modif";
        } else {
            $undo = "modif_rub";
        }
        $rub_form = str_replace('!!undo!!', $undo, $rub_form);
        //Affichage du bouton supprimer
        $rub_form = str_replace('<!-- bouton_sup -->', $ptab[1], $rub_form);
        print confirmation_delete("./admin.php?categ=acquisition&sub=budget&action=del_rub&id_bibli=" . $id_bibli . "&id_bud=" . $id_bud . "&id_parent=" . $id_parent . "&id_rub=");
        $rub_form = str_replace('!!id!!', $id_rub, $rub_form);
        $rub_form = str_replace('!!libelle_suppr!!', addslashes($rub->libelle), $rub_form);
        //Affichage rubriques budgetaires
        $q = budgets::listRubriques($id_bud, $id_rub);
        $list_n1 = mysql_query($q, $dbh);
        while ($row = mysql_fetch_object($list_n1)) {
            $rub_form = str_replace('<!-- rubriques -->', $lig_rub[0] . '<!-- rubriques -->', $rub_form);
            $rub_form = str_replace('<!-- marge -->', '', $rub_form);
            if (rubriques::countChilds($row->id_rubrique)) {
                $rub_form = str_replace('<!-- img_plus -->', $lig_rub_img, $rub_form);
            } else {
                $rub_form = str_replace('<!-- img_plus -->', '', $rub_form);
            }
            $rub_form = str_replace('!!id_rub!!', $row->id_rubrique, $rub_form);
            $rub_form = str_replace('!!id_parent!!', $row->num_parent, $rub_form);
            $rub_form = str_replace('!!lib_rub!!', $row->libelle, $rub_form);
            if (!$bud->type_budget) {
                $rub_form = str_replace('!!mnt!!', $row->montant, $rub_form);
            } else {
                $rub_form = str_replace('!!mnt!!', '&nbsp;', $rub_form);
            }
            $rub_form = str_replace('!!ncp!!', $row->num_cp_compta, $rub_form);
            $rub_form = str_replace('<!-- sous_rub -->', '<!-- sous_rub' . $row->id_rubrique . ' -->', $rub_form);
            afficheSousRubriques($id_bud, $row->id_rubrique, $rub_form, 1);
        }
        //complément du formulaire
        $rub_form = str_replace('!!id_bibli!!', $id_bibli, $rub_form);
        $rub_form = str_replace('!!id_bud!!', $id_bud, $rub_form);
        //Affichage des autorisations
        if ($aut) {
            autorisations($id_rub, $id_parent, $id_bud);
        }
    }
    print $head_form . $rub_form;
}
Example #4
0
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;
                }
            }
        }
    }
}
Example #5
0
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>";
    }
}