Example #1
0
function sup_liv($id_liv, $id_cde)
{
    $cde = new actes($id_cde);
    $cde->statut = $cde->statut & ~STA_ACT_REC | STA_ACT_ENC;
    //Statut commande = soldé->en cours
    $cde->update_statut();
    actes::delete($id_liv);
    liens_actes::delete($id_liv);
}
Example #2
0
     $y_footer = $pos_footer[0];
 }
 if (!$pos_footer[1]) {
     $fs_footer = '8';
 } else {
     $fs_footer = $pos_footer[1];
 }
 //---------------------------------------------------------------------------------------------------------------------
 $taille_doc = array($largeur_page, $hauteur_page);
 $w = $largeur_page - $marge_gauche - $marge_droite;
 $ourPDF = new $fpdf($orient_page, 'mm', $taille_doc);
 $ourPDF->Open();
 $ourPDF->SetMargins($marge_gauche, $marge_haut, $marge_droite);
 //On récupère les infos de la facture
 $fac = new actes($id_fac);
 $lignes = actes::getLignes($id_fac);
 $bibli = new entites($fac->num_entite);
 $coord_fac = new coordonnees($fac->num_contact_fact);
 $fou = new entites($fac->num_fournisseur);
 $coord_fou = entites::get_coordonnees($fac->num_fournisseur, '1');
 $coord_fou = mysql_fetch_object($coord_fou);
 $id_cde = liens_actes::getParent($id_fac);
 $cde = new actes($id_cde);
 $ourPDF->addPage();
 $ourPDF->setFont($pmb_pdf_font);
 //Affichage date
 $date = formatdate(today());
 $ourPDF->setFontSize($fs_date);
 $ourPDF->SetXY($x_date, $y_date);
 $ourPDF->Cell($l_date, $h_date, $date, 0, 0, 'L', 0);
 //Affichage raison sociale
Example #3
0
         break;
     case "deflt3rubrique":
         $q = "select 0,'" . addslashes($msg['deflt3none']) . "' union ";
         $q .= "select id_rubrique, concat(budgets.libelle,':',rubriques.libelle) from rubriques join budgets on num_budget=id_budget order by 2 ";
         break;
     case "deflt3dev_statut":
         $t = actes::getStatelist(TYP_ACT_DEV);
         break;
     case "deflt3cde_statut":
         $t = actes::getStatelist(TYP_ACT_CDE);
         break;
     case "deflt3liv_statut":
         $t = actes::getStatelist(TYP_ACT_LIV);
         break;
     case "deflt3fac_statut":
         $t = actes::getStatelist(TYP_ACT_FAC);
         break;
     case "deflt3sug_statut":
         $m = new suggestions_map();
         $t = $m->getStateList();
         break;
     case 'deflt3lgstatcde':
     case 'deflt3lgstatdev':
         $q = lgstat::getList('QUERY');
         break;
     case 'deflt3receptsugstat':
         $m = new suggestions_map();
         $t = $m->getStateList('ORDERED', TRUE);
         break;
 }
 if ($q) {
Example #4
0
function arc_dev_list()
{
    global $chk;
    if (is_array($chk)) {
        foreach ($chk as $id_dev) {
            $dev = new actes($id_dev);
            if ($dev->type_acte == TYP_ACT_DEV) {
                $dev->statut = $dev->statut | STA_ACT_ARC;
                $dev->update_statut();
            }
        }
    }
}
Example #5
0
 function delete($id_acte = 0)
 {
     global $dbh;
     if (!$id_acte) {
         $id_acte = $this->id_acte;
     }
     actes::deleteLignes($id_acte);
     liens_actes::delete($id_acte);
     $q = "delete from actes where id_acte = '" . $id_acte . "' ";
     mysql_query($q, $dbh);
     audit::delete_audit(AUDIT_ACQUIS, $id_acte);
 }
Example #6
0
function pay_fac_list()
{
    global $chk;
    if (is_array($chk)) {
        foreach ($chk as $id_fac) {
            $fac = new actes($id_fac);
            if ($fac->type_acte == TYP_ACT_FAC && ($fac->statut = STA_ACT_REC)) {
                $fac->statut = STA_ACT_PAY;
                $fac->update_statut();
                //La commande correspondante est-elle entierement payee
                $id_cde = liens_actes::getParent($id_fac);
                $tab_pay = liens_actes::getChilds($id_cde, TYP_ACT_FAC);
                $paye = true;
                while ($row_pay = pmb_mysql_fetch_object($tab_pay)) {
                    if (($row_pay->statut & STA_ACT_PAY) != STA_ACT_PAY) {
                        $paye = false;
                        break;
                    }
                }
                if ($paye) {
                    $cde = new actes($id_cde);
                    $cde->statut = $cde->statut | STA_ACT_PAY;
                    $cde->update_statut();
                }
            }
        }
    }
}
Example #7
0
 static function delete($id_exercice = 0)
 {
     global $dbh;
     if (!$id_exercice) {
         return;
     }
     //Suppression des actes
     //TODO Voir suppression du lien entre actes et exercices
     $res_actes = actes::listByExercice($id_exercice);
     while ($row = mysql_fetch_object($res_actes)) {
         actes::delete($row->id_acte);
     }
     //Suppression des budgets
     $res_budgets = budgets::listByExercice($id_exercice);
     while ($row = mysql_fetch_object($res_budgets)) {
         budgets::delete($row->id_budget);
     }
     //Suppression de l'exercice
     $q = "delete from exercices where id_exercice = '" . $id_exercice . "' ";
     mysql_query($q, $dbh);
 }
Example #8
0
function update_fac($statut = 0)
{
    global $id_bibli, $id_cde, $id_fac, $comment, $ref;
    global $max_lig, $max_lig_fac, $id_lig, $id_prod, $code, $lib, $prix, $typ, $tva, $rem, $rub, $fac;
    global $date_pay, $num_pay, $devise;
    $tab_fac = array();
    //Tableau des lignes facturées
    //Les lignes restant à facturer sont reprises dans le tableau si la qté facturée est >0
    for ($i = 1; $i <= $max_lig; $i++) {
        if ($fac[$i]) {
            $tab_fac[$i]['id_lig'] = $id_lig[$i];
            $tab_fac[$i]['id_prod'] = $id_prod[$i];
            $tab_fac[$i]['code'] = $code[$i];
            $tab_fac[$i]['lib'] = $lib[$i];
            $tab_fac[$i]['prix'] = round($prix[$i], 2);
            $tab_fac[$i]['typ'] = $typ[$i];
            $tab_fac[$i]['tva'] = $tva[$i];
            $tab_fac[$i]['rem'] = round($rem[$i], 2);
            $tab_fac[$i]['rub'] = $rub[$i];
            $tab_fac[$i]['fac'] = $fac[$i];
        }
    }
    //Les quantités facturées des lignes déjà facturées sont reportées dans le tableau si l'identifiant de ligne existe
    //et que les prix, types de produits, remises et budgets sont égaux
    //Sinon une nouvelle ligne est créée
    for ($i; $i <= $max_lig + $max_lig_fac; $i++) {
        $deja = false;
        for ($j = 1; $j <= $max_lig; $j++) {
            //Y a-t'il une ligne deja créée
            if ($tab_fac[$j]['id_lig'] == $id_lig[$i] && $tab_fac[$j]['prix'] == $prix[$i] && $tab_fac[$j]['typ'] == $typ[$i] && $tab_fac[$j]['rem'] == $rem[$i] && $tab_fac[$j]['rub'] == $rub[$i]) {
                //Si oui, on rajoute la quantité reçue dans le tableau
                $tab_fac[$j]['fac'] = $tab_fac[$j]['fac'] + $fac[$i];
                $deja = true;
                break;
            }
        }
        if (!$deja) {
            //Sinon, on crée la ligne dans le tableau
            $tab_fac[$i]['id_lig'] = $id_lig[$i];
            $tab_fac[$i]['id_prod'] = $id_prod[$i];
            $tab_fac[$i]['code'] = $code[$i];
            $tab_fac[$i]['lib'] = $lib[$i];
            $tab_fac[$i]['prix'] = round($prix[$i], 2);
            $tab_fac[$i]['typ'] = $typ[$i];
            $tab_fac[$i]['tva'] = $tva[$i];
            $tab_fac[$i]['rem'] = round($rem[$i], 2);
            $tab_fac[$i]['rub'] = $rub[$i];
            $tab_fac[$i]['fac'] = $fac[$i];
        }
    }
    //Récupération de la commande
    $cde = new actes($id_cde);
    if (!$id_fac) {
        //Création de la facture
        $factu = new actes();
        $factu->date_acte = today();
        $factu->type_acte = TYP_ACT_FAC;
        if ($statut) {
            $factu->statut = $statut;
        } else {
            $factu->statut = STA_ACT_REC;
        }
        $factu->num_entite = $cde->num_entite;
        $factu->num_fournisseur = $cde->num_fournisseur;
        $factu->num_contact_livr = $cde->num_contact_livr;
        $factu->num_contact_fact = $cde->num_contact_fact;
        $factu->num_exercice = $cde->num_exercice;
        $factu->commentaires = $comment;
        $factu->reference = $ref;
        $factu->devise = $devise;
        if ($date_pay != '') {
            $factu->date_paiement = extraitdate($date_pay);
        }
        $factu->num_paiement = $num_pay;
        $factu->calc();
        $factu->save();
        $id_fac = $factu->id_acte;
        //création des liens entre actes
        $la = new liens_actes($id_cde, $id_fac);
    } else {
        //Modification de la facture
        $factu = new actes($id_fac);
        $factu->numero = addslashes($factu->numero);
        $factu->commentaires = trim($comment);
        $factu->reference = trim($ref);
        if ($date_pay != '') {
            $factu->date_paiement = extraitdate($date_pay);
        }
        $factu->num_paiement = trim($num_pay);
        if ($statut) {
            $factu->statut = $statut;
        }
        $factu->devise = trim($devise);
        $factu->save();
    }
    //Suppression des lignes de facture précédemment enregistrées
    actes::deleteLignes($id_fac);
    //Création des lignes de facture
    foreach ($tab_fac as $key => $value) {
        $lig_cde = new lignes_actes($tab_fac[$key]['id_lig']);
        $lig_fac = new lignes_actes();
        $lig_fac->num_acte = $factu->id_acte;
        $lig_fac->lig_ref = $lig_cde->id_ligne;
        $lig_fac->num_produit = $lig_cde->num_produit;
        $lig_fac->code = addslashes($lig_cde->code);
        $lig_fac->libelle = addslashes($lig_cde->libelle);
        $lig_fac->num_acquisition = $lig_cde->num_acquisition;
        $lig_fac->num_type = $lig_cde->num_type;
        $lig_fac->prix = $tab_fac[$key]['prix'];
        $lig_fac->tva = $tab_fac[$key]['tva'];
        $lig_fac->remise = $tab_fac[$key]['rem'];
        $lig_fac->num_rubrique = $tab_fac[$key]['rub'];
        $lig_fac->nb = $tab_fac[$key]['fac'];
        $lig_fac->date_cre = today();
        $lig_fac->save();
    }
    //La commande est-elle entièrement facturée
    $tab_cde = actes::getLignes($id_cde);
    $facture = true;
    while ($row_cde = mysql_fetch_object($tab_cde)) {
        $tab_fac = lignes_actes::getFactures($row_cde->id_ligne);
        $nb_fac = 0;
        while ($row_fac = mysql_fetch_object($tab_fac)) {
            $nb_fac = $nb_fac + $row_fac->nb;
        }
        if ($row_cde->nb > $nb_fac) {
            $facture = false;
            break;
        }
    }
    if ($facture) {
        //Pas de reste à facturer >>Statut commande=facturée
        $cde->statut = $cde->statut | STA_ACT_FAC;
        //Si de plus toutes les factures sont payées, Statut commande=payé
        $tab_pay = liens_actes::getChilds($id_cde, TYP_ACT_FAC);
        $paye = true;
        while ($row_pay = mysql_fetch_object($tab_pay)) {
            if (($row_pay->statut & STA_ACT_PAY) != STA_ACT_PAY) {
                $paye = false;
                break;
            }
        }
        if ($paye) {
            $cde->statut = $cde->statut | STA_ACT_PAY;
        }
    } else {
        //Sinon, la commande repasse en statut en cours
        $cde->statut = $cde->statut & ~(STA_ACT_FAC | STA_ACT_PAY);
    }
    $cde->update_statut();
}
 function doLettre($id_bibli, $id_cde)
 {
     global $msg, $acquisition_gestion_tva;
     //On récupère les infos de la commande
     $cde = new actes($id_cde);
     $lignes = actes::getLignes($id_cde);
     $bib = new entites($cde->num_entite);
     $coord_liv = new coordonnees($cde->num_contact_livr);
     $coord_fac = new coordonnees($cde->num_contact_fact);
     $fou = new entites($cde->num_fournisseur);
     $coord_fou = entites::get_coordonnees($cde->num_fournisseur, '1');
     $coord_fou = pmb_mysql_fetch_object($coord_fou);
     $this->PDF->AddPage();
     $this->PDF->npage = 1;
     //Affichage logo
     if ($bib->logo != '') {
         $this->PDF->Image($bib->logo, $this->x_logo, $this->y_logo, $this->l_logo, $this->h_logo);
     }
     //Affichage raison sociale
     $raison = $bib->raison_sociale;
     $this->PDF->setFontSize($this->fs_raison);
     $this->PDF->SetXY($this->x_raison, $this->y_raison);
     $this->PDF->MultiCell($this->l_raison, $this->h_raison, $raison, 0, 'L', 0);
     //Affichage date $ville
     $ville_end = stripos($coord_fac->ville, "cedex");
     if ($ville_end !== false) {
         $ville = trim(substr($coord_fac->ville, 0, $ville_end));
     } else {
         $ville = $coord_fac->ville;
     }
     if ($cde->date_valid != '0000-00-00') {
         $date = $ville . $this->sep_ville_date . format_date($cde->date_valid);
     } else {
         $date = $ville . $this->sep_ville_date . format_date($cde->date_acte);
     }
     $this->PDF->setFontSize($this->fs_date);
     $this->PDF->SetXY($this->x_date, $this->y_date);
     $this->PDF->Cell($this->l_date, $this->h_date, $date, 0, 0, 'L', 0);
     //Affichage coordonnees fournisseur
     //si pas de raison sociale définie, on reprend le libellé
     //si il y a une raison sociale, pas besoin
     if ($fou->raison_sociale != '') {
         $adr_fou = $fou->raison_sociale . "\n";
     } else {
         $adr_fou = $coord_fou->libelle . "\n";
     }
     if ($coord_fou->adr1 != '') {
         $adr_fou .= $coord_fou->adr1 . "\n";
     }
     if ($coord_fou->adr2 != '') {
         $adr_fou .= $coord_fou->adr2 . "\n";
     }
     if ($coord_fou->cp != '') {
         $adr_fou .= $coord_fou->cp . " ";
     }
     if ($coord_fou->ville != '') {
         $adr_fou .= $coord_fou->ville . "\n\n";
     }
     if ($coord_fou->contact != '') {
         $adr_fou .= $coord_fou->contact;
     }
     $this->PDF->setFontSize($this->fs_adr_fou);
     $this->PDF->SetXY($this->x_adr_fou, $this->y_adr_fou);
     $this->PDF->MultiCell($this->l_adr_fou, $this->h_adr_fou, $adr_fou, 0, 'L', 0);
     //Affichage adresse facturation
     $adr_fac = $this->text_adr_fac . "\n";
     if ($coord_fac->libelle != '') {
         $adr_fac .= $coord_fac->libelle . "\n";
     }
     if ($coord_fac->adr1 != '') {
         $adr_fac .= $coord_fac->adr1 . "\n";
     }
     if ($coord_fac->adr2 != '') {
         $adr_fac .= $coord_fac->adr2 . "\n";
     }
     if ($coord_fac->cp != '') {
         $adr_fac .= $coord_fac->cp . " ";
     }
     if ($coord_fac->ville != '') {
         $adr_fac .= $coord_fac->ville . "\n";
     }
     if ($coord_fac->tel1 != '') {
         $adr_fac .= $this->text_adr_fac_tel . " " . $coord_fac->tel1 . "\n";
     }
     if ($coord_fac->tel2 != '') {
         $adr_fac .= $this->text_adr_fac_tel2 . " " . $coord_fac->tel2 . "\n";
     }
     if ($coord_fac->fax != '') {
         $adr_fac .= $this->text_adr_fac_fax . " " . $coord_fac->fax . "\n";
     }
     if ($coord_fac->email != '') {
         $adr_fac .= $this->text_adr_fac_email . " " . $coord_fac->email . "\n";
     }
     if ($bib->tva) {
         $adr_fac .= $msg["acquisition_tva"] . ": " . $bib->tva . "\n";
     }
     $this->PDF->setFontSize($this->fs_adr_fac);
     $this->PDF->SetXY($this->x_adr_fac, $this->y_adr_fac);
     $this->PDF->MultiCell($this->l_adr_fac, $this->h_adr_fac, $adr_fac, 1, 'L', 0);
     //Affichage adresse livraison
     $adr_liv = '';
     if ($coord_liv->libelle != '') {
         $adr_liv .= $coord_liv->libelle . "\n";
     }
     if ($coord_liv->adr1 != '') {
         $adr_liv .= $coord_liv->adr1 . "\n";
     }
     if ($coord_liv->adr2 != '') {
         $adr_liv .= $coord_liv->adr2 . "\n";
     }
     if ($coord_liv->cp != '') {
         $adr_liv .= $coord_liv->cp . " ";
     }
     if ($coord_liv->ville != '') {
         $adr_liv .= $coord_liv->ville . "\n";
     }
     if ($coord_liv->tel1 != '') {
         $adr_liv .= $this->text_adr_liv_tel . " " . $coord_liv->tel1 . "\n";
     }
     if ($coord_liv->tel2 != '') {
         $adr_liv .= $this->text_adr_liv_tel2 . " " . $coord_liv->tel2 . "\n";
     }
     if ($coord_liv->email != '') {
         $adr_liv .= $this->text_adr_liv_email . " " . $coord_liv->email . "\n";
     }
     if ($adr_liv != '') {
         $adr_liv = $this->text_adr_liv . "\n" . $adr_liv;
         $this->PDF->setFontSize($this->fs_adr_liv);
         $this->PDF->SetXY($this->x_adr_liv, $this->y_adr_liv);
         $this->PDF->MultiCell($this->l_adr_liv, $this->h_adr_liv, $adr_liv, 1, 'L', 0);
     }
     //Affichage tiret pliage
     $this->PDF->Line(0, 105, 3, 105);
     $this->y = $this->PDF->GetY();
     $this->PDF->Ln();
     $this->PDF->Ln();
     //Affichage numero client
     $numero_cli = $this->text_num_cli . " " . $fou->num_cp_client;
     $this->PDF->SetFontSize($this->fs_num);
     $this->PDF->SetXY($this->x_num, $this->y_num);
     $this->PDF->Cell($this->l_num_cli, $this->h_num, $numero_cli, 0, 0, 'L', 0);
     $this->PDF->Ln();
     //Affichage numero commande
     $numero = $this->text_num . $cde->numero;
     $this->PDF->SetFontSize($this->fs_num);
     $this->PDF->Cell($this->l_num, $this->h_num, $numero, 0, 0, 'L', 0);
     $this->PDF->Ln();
     //Affichage reference
     if ($cde->reference != '') {
         $ref = $this->text_ref . $cde->reference;
         $this->PDF->SetFontSize($this->fs);
         $this->PDF->Cell($this->w, $this->h_tab, $ref, 0, 0, 'L', 0);
         $this->PDF->Ln();
         $this->PDF->Ln();
     }
     //Affichage texte before + commentaires
     if ($cde->commentaires_i != '') {
         if ($this->text_before != '') {
             $this->text_before .= "\n\n";
         }
         $this->text_before .= $cde->commentaires_i;
     }
     if ($this->text_before != '') {
         $this->PDF->SetFontSize($this->fs);
         $this->PDF->MultiCell($this->w, $this->h_tab, $this->text_before, 0, 'J', 0);
     }
     //Affichage lignes commandes
     $this->PDF->SetAutoPageBreak(false);
     $this->PDF->AliasNbPages();
     $this->PDF->SetFontSize($this->fs_tab);
     $this->PDF->SetFillColor(230);
     $this->y = $this->PDF->GetY();
     $this->PDF->SetXY($this->x_tab, $this->y);
     $tab_mnt = array();
     $i = 0;
     while ($row = pmb_mysql_fetch_object($lignes)) {
         $typ = new types_produits($row->num_type);
         $col1 = $typ->libelle;
         if ($row->code) {
             $col1 .= "\n" . $row->code;
         }
         $col2 = $row->libelle;
         $col3 = $row->nb;
         $col4 = number_format(round($row->prix, 2), 2, '.', '') . " " . $cde->devise;
         if ($acquisition_gestion_tva) {
             $col4 .= "\n" . number_format(round($row->tva, 2), 2, '.', '') . " %";
         }
         $col4 .= "\n" . number_format(round($row->remise, 2), 2, '.', '') . " %";
         $col5 = '';
         if ($row->date_ech != '0000-00-00') {
             $col5 = formatdate($row->date_ech);
         }
         if ($row->num_rubrique) {
             $rub = new rubriques($row->num_rubrique);
             if ($rub->num_cp_compta) {
                 $col5 .= "\n\n" . $rub->num_cp_compta;
             }
         }
         //Est ce qu'on dépasse ?
         $this->h = $this->h_tab * max($this->PDF->NbLines($this->w_col1, $col1), $this->PDF->NbLines($this->w_col2, $col2), $this->PDF->NbLines($this->w_col3, $col3), $this->PDF->NbLines($this->w_col4, $col4), $this->PDF->NbLines($this->w_col5, $col5));
         $this->s = $this->y + $this->h;
         if (!$this->p_header) {
             $this->s = $this->s + $this->h_header;
         }
         //Si oui, chgt page
         if ($this->s > $this->hauteur_page - $this->marge_bas - $this->fs_footer) {
             $this->PDF->AddPage();
             $this->y = $this->y_tab;
             $this->p_header = false;
         }
         if (!$this->p_header) {
             $this->doEntete();
             $this->y += $this->h_header;
         }
         $this->p_header = true;
         $this->PDF->SetXY($this->x_col1, $this->y);
         $this->PDF->Rect($this->x_col1, $this->y, $this->w_col1, $this->h);
         $this->PDF->MultiCell($this->w_col1, $this->h_tab, $col1, 0, 'L');
         $this->PDF->SetXY($this->x_col2, $this->y);
         $this->PDF->Rect($this->x_col2, $this->y, $this->w_col2, $this->h);
         $this->PDF->MultiCell($this->w_col2, $this->h_tab, $col2, 0, 'L');
         $this->PDF->SetXY($this->x_col3, $this->y);
         $this->PDF->Rect($this->x_col3, $this->y, $this->w_col3, $this->h);
         $this->PDF->MultiCell($this->w_col3, $this->h_tab, $col3, 0, 'R');
         $this->PDF->SetXY($this->x_col4, $this->y);
         $this->PDF->Rect($this->x_col4, $this->y, $this->w_col4, $this->h);
         $this->PDF->MultiCell($this->w_col4, $this->h_tab, $col4, 0, 'R');
         $this->PDF->SetXY($this->x_col5, $this->y);
         $this->PDF->Rect($this->x_col5, $this->y, $this->w_col5, $this->h);
         $this->PDF->MultiCell($this->w_col5, $this->h_tab, $col5, 0, 'R');
         $this->y += $this->h;
         $tab_mnt[$i]['q'] = $row->nb;
         $tab_mnt[$i]['p'] = $row->prix;
         $tab_mnt[$i]['r'] = $row->remise;
         $tab_mnt[$i]['t'] = $row->tva;
         $i++;
     }
     $this->PDF->SetAutoPageBreak(true, $this->marge_bas);
     $this->PDF->SetX($this->marge_gauche);
     $this->PDF->SetY($this->y);
     $this->PDF->SetFontSize($this->fs);
     $this->PDF->Ln();
     //affichage des montants ht, ttc, tva
     $tab_tot = calc($tab_mnt, 2);
     $this->y = $this->PDF->GetY();
     if ($acquisition_gestion_tva) {
         $this->h = $this->h_tot * 3;
     } else {
         $this->h = $this->h_tot;
     }
     $this->s = $this->y + $this->h;
     if ($this->s > $this->hauteur_page - $this->marge_bas) {
         $this->PDF->AddPage();
         $this->PDF->SetXY($this->x_tot, $this->marge_haut);
         $this->y = $this->PDF->GetY();
     }
     if ($acquisition_gestion_tva) {
         $this->PDF->Cell($this->l_tot, $this->h_tot, $msg['acquisition_total_ht'], 1, 0, 'L', 0);
         $this->PDF->Cell($this->l_tot, $this->h_tot, number_format($tab_tot['ht'], 2, '.', '') . " " . $cde->devise, 1, 1, 'R', 0);
         $this->PDF->Cell($this->l_tot, $this->h_tot, $msg['acquisition_tva'], 1, 0, 'L', 0);
         $this->PDF->Cell($this->l_tot, $this->h_tot, number_format($tab_tot['tva'], 2, '.', '') . " " . $cde->devise, 1, 1, 'R', 0);
     }
     $this->PDF->Cell($this->l_tot, $this->h_tot, $msg['acquisition_total_ttc'], 1, 0, 'L', 0);
     $this->PDF->Cell($this->l_tot, $this->h_tot, number_format($tab_tot['ttc'], 2, '.', '') . " " . $cde->devise, 1, 1, 'R', 0);
     $this->PDF->Ln();
     //Affichage conditions de paiement
     $text_paiement = $msg['acquisition_mode_pai'];
     if ($fou->num_paiement) {
         $pai = new paiements($fou->num_paiement);
         $text_paiement .= "{$pai->libelle}";
         $this->PDF->MultiCell($this->w, $this->h_tab, $text_paiement, 0, 'L', 0);
         $this->PDF->Ln();
     }
     //Affichage texte after
     if ($this->text_after != '') {
         $this->PDF->MultiCell($this->w, $this->h_tab, $this->text_after, 0, 'J', 0);
         $this->PDF->Ln();
     }
     //Affichage signature
     $this->PDF->Ln();
     $this->PDF->SetFontSize($this->fs_sign);
     $this->PDF->SetX($this->x_sign);
     $this->PDF->MultiCell($this->l_sign, $this->h_sign, $this->text_sign, 0, 'L', 0);
 }
Example #10
0
 function doLettre($id_bibli, $id_dev)
 {
     global $msg, $pmb_pdf_font;
     //On récupère les infos du devis
     $dev = new actes($id_dev);
     $lignes = actes::getLignes($id_dev);
     $bib = new entites($dev->num_entite);
     $coord_liv = new coordonnees($dev->num_contact_livr);
     $coord_fac = new coordonnees($dev->num_contact_fact);
     $fou = new entites($dev->num_fournisseur);
     $coord_fou = entites::get_coordonnees($dev->num_fournisseur, '1');
     $coord_fou = mysql_fetch_object($coord_fou);
     $this->PDF->AddPage();
     $this->PDF->setFont($pmb_pdf_font);
     $this->PDF->npage = 1;
     //Affichage logo
     if ($bib->logo != '') {
         $this->PDF->Image($bib->logo, $this->x_logo, $this->y_logo, $this->l_logo, $this->h_logo);
     }
     //Affichage raison sociale
     $raison = $bib->raison_sociale;
     $this->PDF->setFontSize($this->fs_raison);
     $this->PDF->SetXY($this->x_raison, $this->y_raison);
     $this->PDF->MultiCell($this->l_raison, $this->h_raison, $raison, 0, 'L', 0);
     //Affichage date $ville
     $ville_end = stripos($coord_fac->ville, "cedex");
     if ($ville_end !== false) {
         $ville = trim(substr($coord_fac->ville, 0, $ville_end));
     } else {
         $ville = $coord_fac->ville;
     }
     $date = $ville . $this->sep_ville_date . format_date($dev->date_acte);
     $this->PDF->setFontSize($this->fs_date);
     $this->PDF->SetXY($this->x_date, $this->y_date);
     $this->PDF->Cell($this->l_date, $this->h_date, $date, 0, 0, 'L', 0);
     //Affichage coordonnees fournisseur
     //si pas de raison sociale définie, on reprend le libellé
     //si il y a une raison sociale, pas besoin
     if ($fou->raison_sociale != '') {
         $adr_fou = $fou->raison_sociale . "\n";
     } else {
         $adr_fou = $coord_fou->libelle . "\n";
     }
     if ($coord_fou->adr1 != '') {
         $adr_fou .= $coord_fou->adr1 . "\n";
     }
     if ($coord_fou->adr2 != '') {
         $adr_fou .= $coord_fou->adr2 . "\n";
     }
     if ($coord_fou->cp != '') {
         $adr_fou .= $coord_fou->cp . " ";
     }
     if ($coord_fou->ville != '') {
         $adr_fou .= $coord_fou->ville . "\n\n";
     }
     if ($coord_fou->contact != '') {
         $adr_fou .= $coord_fou->contact;
     }
     $this->PDF->setFontSize($this->fs_adr_fou);
     $this->PDF->SetXY($this->x_adr_fou, $this->y_adr_fou);
     $this->PDF->MultiCell($this->l_adr_fou, $this->h_adr_fou, $adr_fou, 0, 'L', 0);
     //Affichage adresse facturation
     $adr_fac = $this->text_adr_fac . "\n";
     if ($coord_fac->libelle != '') {
         $adr_fac .= $coord_fac->libelle . "\n";
     }
     if ($coord_fac->adr1 != '') {
         $adr_fac .= $coord_fac->adr1 . "\n";
     }
     if ($coord_fac->adr2 != '') {
         $adr_fac .= $coord_fac->adr2 . "\n";
     }
     if ($coord_fac->cp != '') {
         $adr_fac .= $coord_fac->cp . " ";
     }
     if ($coord_fac->ville != '') {
         $adr_fac .= $coord_fac->ville . "\n";
     }
     if ($coord_fac->tel1 != '') {
         $adr_fac .= $this->text_adr_fac_tel . " " . $coord_fac->tel1 . "\n";
     }
     if ($coord_fac->tel2 != '') {
         $adr_fac .= $this->text_adr_fac_tel2 . " " . $coord_fac->tel2 . "\n";
     }
     if ($coord_fac->fax != '') {
         $adr_fac .= $this->text_adr_fac_fax . " " . $coord_fac->fax . "\n";
     }
     if ($coord_fac->email != '') {
         $adr_fac .= $this->text_adr_fac_email . " " . $coord_fac->email . "\n";
     }
     $this->PDF->setFontSize($this->fs_adr_fac);
     $this->PDF->SetXY($this->x_adr_fac, $this->y_adr_fac);
     $this->PDF->MultiCell($this->l_adr_fac, $this->h_adr_fac, $adr_fac, 1, 'L', 0);
     //Affichage adresse livraison
     $adr_liv = '';
     if ($coord_liv->libelle != '') {
         $adr_liv .= $coord_liv->libelle . "\n";
     }
     if ($coord_liv->adr1 != '') {
         $adr_liv .= $coord_liv->adr1 . "\n";
     }
     if ($coord_liv->adr2 != '') {
         $adr_liv .= $coord_liv->adr2 . "\n";
     }
     if ($coord_liv->cp != '') {
         $adr_liv .= $coord_liv->cp . " ";
     }
     if ($coord_liv->ville != '') {
         $adr_liv .= $coord_liv->ville . "\n";
     }
     if ($coord_liv->tel1 != '') {
         $adr_liv .= $this->text_adr_liv_tel . " " . $coord_liv->tel1 . "\n";
     }
     if ($coord_liv->tel2 != '') {
         $adr_liv .= $this->text_adr_liv_tel2 . " " . $coord_liv->tel2 . "\n";
     }
     if ($adr_liv != '') {
         $adr_liv = $this->text_adr_liv . "\n" . $adr_liv;
         $this->PDF->setFontSize($this->fs_adr_liv);
         $this->PDF->SetXY($this->x_adr_liv, $this->y_adr_liv);
         $this->PDF->MultiCell($this->l_adr_liv, $this->h_adr_liv, $adr_liv, 1, 'L', 0);
     }
     //Affichage tiret pliage
     $this->PDF->Line(0, 105, 3, 105);
     //Affichage numero devis
     $numero = $this->text_num . $dev->numero;
     $this->PDF->SetFontSize($this->fs_num);
     $this->PDF->Cell($this->l_num, $this->h_num, $numero, 0, 0, 'L', 0);
     $this->PDF->Ln();
     //Affichage texte before + commentaires
     if ($dev->commentaires_i != '') {
         if ($this->text_before != '') {
             $this->text_before .= "\n\n";
         }
         $this->text_before .= $dev->commentaires_i;
     }
     if ($this->text_before != '') {
         $this->PDF->SetFontSize($this->fs);
         $this->PDF->MultiCell($this->w, $this->h_tab, $this->text_before, 0, 'J', 0);
         $this->PDF->Ln();
     }
     //Affichage lignes devis
     $this->PDF->SetAutoPageBreak(false);
     $this->PDF->AliasNbPages();
     $this->PDF->SetFontSize($this->fs_tab);
     $this->PDF->SetFillColor(230);
     $this->y = $this->PDF->GetY();
     $this->PDF->SetXY($this->x_tab, $this->y);
     $this->x_code = $this->x_tab;
     $this->w_code = round($this->w * 20 / 100);
     $this->x_lib = $this->x_code + $this->w_code;
     $this->w_lib = round($this->w * 60 / 100);
     $this->x_qte = $this->x_lib + $this->w_lib;
     $this->w_qte = round($this->w * 10 / 100);
     $this->doEntete();
     while ($row = mysql_fetch_object($lignes)) {
         $typ = new types_produits($row->num_type);
         $col1 = $typ->libelle . "\n" . $row->code;
         $this->h = $this->h_tab * max($this->PDF->NbLines($this->w_code, $col1), $this->PDF->NbLines($this->w_lib, $row->libelle), $this->PDF->NbLines($this->w_qte, $row->nb));
         $this->s = $this->y + $this->h;
         if ($this->s > $this->hauteur_page - $this->marge_bas) {
             $this->PDF->AddPage();
             $this->PDF->SetXY($this->x_tab, $this->y_tab);
             $this->y = $this->PDF->GetY();
             $this->doEntete();
         }
         $this->PDF->SetXY($this->x_code, $this->y);
         $this->PDF->Rect($this->x_code, $this->y, $this->w_code, $this->h);
         $this->PDF->MultiCell($this->w_code, $this->h_tab, $col1, 0, 'L');
         $this->PDF->SetXY($this->x_lib, $this->y);
         $this->PDF->Rect($this->x_lib, $this->y, $this->w_lib, $this->h);
         $this->PDF->MultiCell($this->w_lib, $this->h_tab, $row->libelle, 0, 'L');
         $this->PDF->SetXY($this->x_qte, $this->y);
         $this->PDF->Rect($this->x_qte, $this->y, $this->w_qte, $this->h);
         $this->PDF->MultiCell($this->w_qte, $this->h_tab, $row->nb, 0, 'L');
         $this->y = $this->y + $this->h;
     }
     $this->PDF->SetAutoPageBreak(true, $this->marge_bas);
     $this->PDF->SetX($this->marge_gauche);
     $this->PDF->SetY($this->y);
     $this->PDF->SetFontSize($this->fs);
     $this->PDF->Ln();
     //Affichage texte after
     if ($this->text_after != '') {
         $this->PDF->MultiCell($this->w, $this->h_tab, $this->text_after, 0, 'J', 0);
         $this->PDF->Ln();
     }
     //Affichage signature
     $this->PDF->Ln();
     $this->PDF->SetFontSize($this->fs_sign);
     $this->PDF->SetX($this->x_sign);
     $this->PDF->MultiCell($this->l_sign, $this->h_sign, $this->text_sign, 0, 'L', 0);
 }
Example #11
0
 protected function get_user_param_form($field)
 {
     global $msg, $dbh, $charset;
     global ${$field};
     global $location_user_section;
     $field_deb = substr($field, 0, 6);
     // 		$html="
     // 		<script type='text/javascript'>
     // 			function dashboard_save_params(name,value){
     // 				var req= new http_request();
     // 				req.request('./ajax.php?module=".$this->module."&categ=dashboard&sub=save_quick_params',1,'".$field."='+value,1,dashboard_params_saved);
     // 			}
     // 		</script>";
     $html = "";
     switch ($field_deb) {
         case "deflt_":
             if ($field == "deflt_styles") {
                 $html_style = "\n\t\t\t\t\t\t<div class='row'>\n\t\t\t\t\t\t\t<div class='colonne60'>" . $msg[$field] . "&nbsp;:&nbsp;\n\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t<div class='colonne_suite'>" . make_user_style_combo(${$field}) . "\n\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t</div>\n";
             } elseif ($field == "deflt_docs_location") {
                 //visibilité des exemplaires
                 if ($pmb_droits_explr_localises && $usr->explr_visible_mod) {
                     $where_clause_explr = "idlocation in (" . $usr->explr_visible_mod . ") and";
                 } else {
                     $where_clause_explr = "";
                 }
                 $selector = gen_liste("select distinct idlocation, location_libelle from docs_location, docsloc_section where {$where_clause_explr} num_location=idlocation order by 2 ", "idlocation", "location_libelle", 'form_' . $field, "dashboard_calcule_section(this);", ${$field}, "", "", "", "", 0);
                 $html .= "\n\t\t\t\t\t\t<div class='row'>\n\t\t\t\t\t\t\t<div class='colonne60'>" . $msg[$field] . "&nbsp;:&nbsp;\n\t\t\t\t\t\t\t</div>\n\n\t\t\t\t\t\t\t<div class='colonne_suite'>" . $selector . "\n\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t</div>\n";
                 //localisation de l'utilisateur pour le calcul de la section
                 $location_user_section = ${$field};
             } elseif ($field == "deflt_collstate_location") {
                 $selector = gen_liste("select distinct idlocation, location_libelle from docs_location order by 2 ", "idlocation", "location_libelle", 'form_' . $field, "", ${$field}, "", "", "0", $msg["all_location"], 0);
                 $html .= "\n\t\t\t\t\t\t<div class='row'><div class='colonne60'>" . $msg[$field] . "&nbsp;:&nbsp;</div>\n\n\t\t\t\t\t\t<div class='colonne_suite'>" . $selector . "</div></div>\n";
             } elseif ($field == "deflt_resas_location") {
                 $selector = gen_liste("select distinct idlocation, location_libelle from docs_location order by 2 ", "idlocation", "location_libelle", 'form_' . $field, "", ${$field}, "", "", "0", $msg["all_location"], 0);
                 $html .= "\n\t\t\t\t\t\t<div class='row'><div class='colonne60'>" . $msg[$field] . "&nbsp;:&nbsp;</div>\n\n\t\t\t\t\t\t<div class='colonne_suite'>" . $selector . "</div></div>\n";
             } elseif ($field == "deflt_docs_section") {
                 // calcul des sections
                 $selector = "";
                 if (!$location_user_section) {
                     $location_user_section = $deflt_docs_location;
                 }
                 if ($pmb_droits_explr_localises && $usr->explr_visible_mod) {
                     $where_clause_explr = "where idlocation in (" . $usr->explr_visible_mod . ")";
                 } else {
                     $where_clause_explr = "";
                 }
                 $rqtloc = "SELECT idlocation FROM docs_location {$where_clause_explr} order by location_libelle";
                 $resloc = mysql_query($rqtloc, $dbh);
                 while ($loc = mysql_fetch_object($resloc)) {
                     $requete = "SELECT idsection, section_libelle FROM docs_section, docsloc_section where idsection=num_section and num_location='{$loc->idlocation}' order by section_libelle";
                     $result = mysql_query($requete, $dbh);
                     $nbr_lignes = mysql_num_rows($result);
                     if ($nbr_lignes) {
                         if ($loc->idlocation == $location_user_section) {
                             $selector .= "<div id=\"dashboard_docloc_section" . $loc->idlocation . "\" style=\"display:block\">\r\n";
                         } else {
                             $selector .= "<div id=\"dashboard_docloc_section" . $loc->idlocation . "\" style=\"display:none\">\r\n";
                         }
                         $selector .= "<select name='f_ex_section" . $loc->idlocation . "' id='f_ex_section" . $loc->idlocation . "'>\r\n";
                         while ($line = mysql_fetch_row($result)) {
                             $selector .= "<option value='{$line['0']}' ";
                             $selector .= $line[0] == ${$field} ? "selected='selected' >" : '>';
                             $selector .= htmlentities($line[1], ENT_QUOTES, $charset) . '</option>\\r\\n';
                         }
                         $selector .= '</select></div>';
                     }
                 }
                 $html .= "\n\t\t\t\t\t\t<div class='row'>\n\t\t\t\t\t\t\t<div class='colonne60'>" . $msg[$field] . "&nbsp;:&nbsp;\n\t\t\t\t\t\t\t</div>\n\n\t\t\t\t\t\t\t<div class='colonne_suite'>" . $selector . "\n\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t</div>\n";
             } elseif ($field == "deflt_upload_repertoire") {
                 $selector = "";
                 $requpload = "select repertoire_id, repertoire_nom from upload_repertoire";
                 $resupload = mysql_query($requpload, $dbh);
                 $selector .= "<div id='upload_section'>";
                 $selector .= "<select name='form_deflt_upload_repertoire'>";
                 $selector .= "<option value='0'>" . $msg[upload_repertoire_sql] . "</option>";
                 while ($repupload = mysql_fetch_object($resupload)) {
                     $selector .= "<option value='" . $repupload->repertoire_id . "' ";
                     if (${$field} == $repupload->repertoire_id) {
                         $selector .= "selected='selected' ";
                     }
                     $selector .= ">";
                     $selector .= htmlentities($repupload->repertoire_nom, ENT_QUOTES, $charset) . "</option>";
                 }
                 $selector .= "</select></div>";
                 $html .= "\n\t\t\t\t\t\t\t<div class='row'>\n\t\t\t\t\t\t\t\t<div class='colonne60'>" . $msg[$field] . "&nbsp;:&nbsp;\n\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t\t<div class='colonne_suite'>" . $selector . "\n\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t</div>";
             } elseif ($field == "deflt_import_thesaurus") {
                 $requete = "select * from thesaurus order by 2";
                 $resultat_liste = mysql_query($requete, $dbh);
                 $nb_liste = mysql_num_rows($resultat_liste);
                 if ($nb_liste == 0) {
                     $html .= "";
                 } else {
                     $html .= "\n\t\t\t\t\t\t\t<div class='row'>\n\t\t\t\t\t\t\t\t<div class='colonne60'>" . $msg[$field] . "&nbsp;:&nbsp;\n\t\t\t\t\t\t\t\t</div>\n\n\t\t\t\t\t\t\t\t<div class='colonne_suite'>\n\t\t\t\t\t\t\t\t\t<select class='saisie-30em' name=\"form_" . $field . "\">";
                     $j = 0;
                     while ($j < $nb_liste) {
                         $liste_values = mysql_fetch_row($resultat_liste);
                         $html .= "<option value=\"" . $liste_values[0] . "\" ";
                         if (${$field} == $liste_values[0]) {
                             $html .= "selected='selected' ";
                         }
                         $html .= ">" . $liste_values[1] . "</option>\n";
                         $j++;
                     }
                     $html .= "</select>\n\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t</div>\n";
                 }
             } elseif ($field == "deflt_short_loan_activate") {
                 $html .= "<div class='row'><div class='colonne60'>" . $msg[$field] . "</div>\n\n\t\t\t\t\t\t\t<div class='colonne_suite'>\n\t\t\t\t\t\t\t<input type='checkbox' class='checkbox'";
                 if (${$field} == 1) {
                     $html .= " checked";
                 }
                 $html .= " value='1' name='form_{$field}'></div></div>\n";
             } elseif ($field == "deflt_cashdesk") {
                 $requete = "select * from cashdesk order by cashdesk_name";
                 $resultat_liste = mysql_query($requete, $dbh);
                 $nb_liste = mysql_num_rows($resultat_liste);
                 if ($nb_liste == 0) {
                     $html .= "";
                 } else {
                     // 						$html.="
                     // 							<div class='row'>
                     // 								<div class='colonne60'>".$msg[$field]."&nbsp;:&nbsp;
                     // 								</div>\n
                     // 								<div class='colonne_suite'>
                     // 									<select class='saisie-30em' name=\"form_".$field."\" onchange='dashboard_save_params(this.name,this.value)'>";
                     $html .= "\n\t\t\t\t\t\t\t<div class='row'>\n\t\t\t\t\t\t\t\t<div class='colonne60'>" . $msg[$field] . "&nbsp;:&nbsp;\n\t\t\t\t\t\t\t\t</div>\n\n\t\t\t\t\t\t\t\t<div class='colonne_suite'>\n\t\t\t\t\t\t\t\t\t<select class='saisie-30em' name=\"form_" . $field . "\">";
                     $j = 0;
                     while ($j < $nb_liste) {
                         $liste_values = mysql_fetch_object($resultat_liste);
                         $html .= "<option value=\"" . $liste_values->cashdesk_id . "\" ";
                         if (${$field} == $liste_values->cashdesk_id) {
                             $html .= "selected";
                         }
                         $html .= ">" . htmlentities($liste_values->cashdesk_name, ENT_QUOTES, $charset) . "</option>\n";
                         $j++;
                     }
                     $html .= "</select>\n\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t</div>\n";
                 }
             } else {
                 $deflt_table = substr($field, 6);
                 if ($deflt_table == "integration_notice_statut") {
                     $deflt_table = "notice_statut";
                 }
                 switch ($field) {
                     case "deflt_entites":
                         $requete = "select id_entite, raison_sociale from " . $deflt_table . " where type_entite='1' order by 2 ";
                         break;
                     case "deflt_exercices":
                         $requete = "select id_exercice, libelle from " . $deflt_table . " order by 2 ";
                         break;
                     case "deflt_rubriques":
                         $requete = "select id_rubrique, concat(budgets.libelle,':', rubriques.libelle) from " . $deflt_table . " join budgets on num_budget=id_budget order by 2 ";
                         break;
                     default:
                         $requete = "select * from " . $deflt_table . " order by 2";
                         break;
                 }
                 $resultat_liste = mysql_query($requete, $dbh);
                 $nb_liste = mysql_num_rows($resultat_liste);
                 if ($nb_liste == 0) {
                     $html .= "";
                 } else {
                     $html .= "\n\t\t\t\t\t\t\t<div class='row'>\n\t\t\t\t\t\t\t\t<div class='colonne60'>" . $msg[$field] . "&nbsp;:&nbsp;\n\t\t\t\t\t\t\t\t</div>\n\n\t\t\t\t\t\t\t\t<div class='colonne_suite'>\n\t\t\t\t\t\t\t\t\t<select class='saisie-30em' name=\"form_" . $field . "\">";
                     $j = 0;
                     while ($j < $nb_liste) {
                         $liste_values = mysql_fetch_row($resultat_liste);
                         $html .= "<option value=\"" . $liste_values[0] . "\" ";
                         if (${$field} == $liste_values[0]) {
                             $html .= "selected='selected' ";
                         }
                         $html .= ">" . $liste_values[1] . "</option>\n";
                         $j++;
                     }
                     $html .= "</select>\n\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t</div>\n";
                 }
             }
             break;
         case "param_":
             if ($field == "param_allloc") {
                 $html = "<div class='row'><div class='colonne60'>" . $msg[$field] . "</div>\n\n\t\t\t\t\t\t<div class='colonne_suite'>\n\t\t\t\t\t\t<input type='checkbox' class='checkbox'";
                 if (${$field} == 1) {
                     $html .= " checked";
                 }
                 $html .= " value='1' name='form_{$field}'></div></div>\n";
             } else {
                 $html .= "<div class='row'>";
                 //if (strpos($msg[$field],'<br />')) $param_user .= "<br />";
                 $html .= "<input type='checkbox' class='checkbox'";
                 if (${$field} == 1) {
                     $html .= " checked";
                 }
                 $html .= " value='1' name='form_{$field}'>\n\n\t\t\t\t\t\t{$msg[$field]}\n\t\t\t\t\t\t</div>\n";
             }
             break;
         case "value_":
             switch ($field) {
                 case "value_deflt_fonction":
                     $flist = new marc_list('function');
                     $f = $flist->table[${$field}];
                     $html .= "<div class='row'><div class='colonne60'>\n\t\t\t\t\t\t{$msg[$field]}&nbsp;:&nbsp;</div>\n\n\t\t\t\t\t\t<div class='colonne_suite'>\n\t\t\t\t\t\t<input type='text' class='saisie-30emr' id='form_value_deflt_fonction_libelle' name='form_value_deflt_fonction_libelle' value='" . htmlentities($f, ENT_QUOTES, $charset) . "' />\n\t\t\t\t\t\t<input type='button' class='bouton_small' value='" . $msg['parcourir'] . "' onclick=\"openPopUp('./select.php?what=function&caller=userform&p1=form_value_deflt_fonction&p2=form_value_deflt_fonction_libelle', 'select_func0', 400, 400, -2, -2, 'scrollbars=yes, toolbar=no, dependent=yes, resizable=yes')\" />\n\t\t\t\t\t\t<input type='button' class='bouton_small' value='X' onclick=\"this.form.elements['form_value_deflt_fonction'].value='';this.form.elements['form_value_deflt_fonction_libelle'].value='';return false;\" />\n\t\t\t\t\t\t<input type='hidden' name='form_value_deflt_fonction' id='form_value_deflt_fonction' value=\"\${$field}\" />\n\t\t\t\t\t\t</div></div><br />";
                     break;
                 case "value_deflt_lang":
                     $llist = new marc_list('lang');
                     $l = $llist->table[${$field}];
                     $html .= "<div class='row'><div class='colonne60'>\n\t\t\t\t\t\t{$msg[$field]}&nbsp;:&nbsp;</div>\n\n\t\t\t\t\t\t<div class='colonne_suite'>\n\t\t\t\t\t\t<input type='text' class='saisie-30emr' id='form_value_deflt_lang_libelle' name='form_value_deflt_lang_libelle' value='" . htmlentities($l, ENT_QUOTES, $charset) . "' />\n\t\t\t\t\t\t<input type='button' class='bouton_small' value='" . $msg['parcourir'] . "' onclick=\"openPopUp('./select.php?what=lang&caller=userform&p1=form_value_deflt_lang&p2=form_value_deflt_lang_libelle', 'select_lang', 400, 400, -2, -2, 'scrollbars=yes, toolbar=no, dependent=yes, resizable=yes')\" />\n\t\t\t\t\t\t<input type='button' class='bouton_small' value='X' onclick=\"this.form.elements['form_value_deflt_lang'].value='';this.form.elements['form_value_deflt_lang_libelle'].value='';return false;\" />\n\t\t\t\t\t\t<input type='hidden' name='form_value_deflt_lang' id='form_value_deflt_lang' value=\"\${$field}\" />\n\t\t\t\t\t\t</div></div><br />";
                     break;
                 case "value_deflt_relation":
                 case "value_deflt_relation_serial":
                 case "value_deflt_relation_bulletin":
                 case "value_deflt_relation_analysis":
                     $html .= "<div class='row'><div class='colonne60'>\n\t\t\t\t\t\t{$msg[$field]}&nbsp;:&nbsp;</div>\n\n\t\t\t\t\t\t<div class='colonne_suite'>";
                     $liste_type_relation_down = new marc_list("relationtypedown");
                     $liste_type_relation_up = new marc_list("relationtypeup");
                     $liste_type_relation_both = array();
                     foreach ($liste_type_relation_up->table as $key_up => $val_up) {
                         foreach ($liste_type_relation_down->table as $key_down => $val_down) {
                             if ($val_up == $val_down) {
                                 $liste_type_relation_both[$key_down] = $val_down;
                                 unset($liste_type_relation_down->table[$key_down]);
                                 unset($liste_type_relation_up->table[$key_up]);
                             }
                         }
                     }
                     $html .= "<select onchange='' name='form_" . $field . "' size='1'>\n\t\t\t\t\t\t<optgroup class='erreur' label='{$msg['notice_lien_montant']}'>";
                     foreach ($liste_type_relation_up->table as $key => $val) {
                         if ($key . '-up' == ${$field}) {
                             $html .= '<option  style="color:#000000" value="' . $key . '-up" selected="selected">' . $val . '</option>';
                         } else {
                             $html .= '<option  style="color:#000000" value="' . $key . '-up">' . $val . '</option>';
                         }
                     }
                     $html .= "</optgroup>\n\t\t\t\t\t\t<optgroup class='erreur' label='{$msg['notice_lien_descendant']}'>";
                     foreach ($liste_type_relation_down->table as $key => $val) {
                         if ($key . '-down' == ${$field}) {
                             $html .= '<option  style="color:#000000" value="' . $key . '-down" selected="selected" >' . $val . '</option>';
                         } else {
                             $html .= '<option  style="color:#000000" value="' . $key . '-down">' . $val . '</option>';
                         }
                     }
                     $html .= "</optgroup>\n\t\t\t\t\t\t<optgroup class='erreur' label='{$msg['notice_lien_symetrique']}'>";
                     foreach ($liste_type_relation_both as $key => $val) {
                         if ($key . '-down' == ${$field}) {
                             $html .= '<option  style="color:#000000" value="' . $key . '-down" selected="selected" >' . $val . '</option>';
                         } else {
                             $html .= '<option  style="color:#000000" value="' . $key . '-down">' . $val . '</option>';
                         }
                     }
                     $html .= "</optgroup>\n\t\t\t\t\t\t</select>";
                     $html .= "</div></div><br />";
                     break;
                 default:
                     $html .= "<div class='row'><div class='colonne60'>\n\t\t\t\t\t\t{$msg[$field]}&nbsp;:&nbsp;</div>\n\n\t\t\t\t\t\t<div class='colonne_suite'>\n\t\t\t\t\t\t<input type='text' class='saisie-20em' name='form_{$field}' value='" . htmlentities(${$field}, ENT_QUOTES, $charset) . "' />\n\t\t\t\t\t\t</div></div><br />";
                     break;
             }
             break;
         case "deflt2":
             if ($field == "deflt2docs_location") {
                 // localisation des lecteurs
                 $deflt_table = substr($field, 6);
                 $requete = "select * from " . $deflt_table . " order by 2";
                 $resultat_liste = mysql_query($requete, $dbh);
                 $nb_liste = mysql_num_rows($resultat_liste);
                 if ($nb_liste == 0) {
                     $html .= "";
                 } else {
                     $html .= "\n\t\t\t\t\t\t\t<div class='row'><div class='colonne60'>" . $msg[$field] . "&nbsp;:&nbsp;</div>\n";
                     $html .= "\n\t\t\t\t\t\t\t<div class='colonne_suite'>\n\t\t\t\t\t\t\t<select class='saisie-30em' name=\"form_" . $field . "\">";
                     $j = 0;
                     while ($j < $nb_liste) {
                         $liste_values = mysql_fetch_row($resultat_liste);
                         $html .= "<option value=\"" . $liste_values[0] . "\" ";
                         if (${$field} == $liste_values[0]) {
                             $html .= "selected='selected' ";
                         }
                         $html .= ">" . $liste_values[1] . "</option>\n";
                         $j++;
                     }
                     $html .= "</select></div></div>!!param_allloc!!<br />\n";
                 }
             } else {
                 $deflt_table = substr($field, 6);
                 $requete = "select * from " . $deflt_table . " order by 2 ";
                 $resultat_liste = mysql_query($requete, $dbh);
                 $nb_liste = mysql_numrows($resultat_liste);
                 if ($nb_liste == 0) {
                     $html .= "";
                 } else {
                     $html .= "\n\t\t\t\t\t\t\t\t<div class='row'><div class='colonne60'>" . $msg[$field] . "&nbsp;:&nbsp;</div>\n";
                     $html .= "\n\t\t\t\t\t\t\t\t<div class='colonne_suite'>\n\t\t\t\t\t\t\t\t\t<select class='saisie-30em' name=\"form_" . $field . "\">";
                     $j = 0;
                     while ($j < $nb_liste) {
                         $liste_values = mysql_fetch_row($resultat_liste);
                         $html .= "<option value=\"" . $liste_values[0] . "\" ";
                         if (${$field} == $liste_values[0]) {
                             $html .= "selected='selected' ";
                         }
                         $html .= ">" . $liste_values[1] . "</option>\n";
                         $j++;
                     }
                     $html .= "</select></div></div>\n";
                 }
             }
             break;
         case "xmlta_":
             switch ($field) {
                 case "xmlta_indexation_lang":
                     $langues = new XMLlist("{$include_path}/messages/languages.xml");
                     $langues->analyser();
                     $clang = $langues->table;
                     $combo = "<select name='form_" . $field . "' id='form_" . $field . "' class='saisie-20em' >";
                     if (!${$field}) {
                         $combo .= "<option value='' selected>--</option>";
                     } else {
                         $combo .= "<option value='' >--</option>";
                     }
                     while (list($cle, $value) = each($clang)) {
                         // arabe seulement si on est en utf-8
                         if ($charset != 'utf-8' and $user_lang != 'ar' or $charset == 'utf-8') {
                             if (strcmp($cle, ${$field}) != 0) {
                                 $combo .= "<option value='{$cle}'>{$value} ({$cle})</option>";
                             } else {
                                 $combo .= "<option value='{$cle}' selected>{$value} ({$cle})</option>";
                             }
                         }
                     }
                     $combo .= "</select>";
                     $html .= "\n\t\t\t\t\t\t<div class='row'><div class='colonne60'>" . $msg[$field] . "&nbsp;:&nbsp;</div>\n";
                     $html .= "\n\t\t\t\t\t\t<div class='colonne_suite'>{$combo}</div></div>\n";
                     break;
                 case "xmlta_doctype_serial":
                     $html .= "\n\t\t\t\t\t\t\t<div class='row'><div class='colonne60'>" . $msg[$field] . "&nbsp;:&nbsp;</div>\n";
                     $html .= "\n\t\t\t\t\t\t\t<div class='colonne_suite'>";
                     $select_doc = new marc_select("doctype", "form_" . $field, ${$field}, "");
                     $html .= $select_doc->display;
                     $html .= "</div></div>\n";
                     break;
                 case "xmlta_doctype_bulletin":
                 case "xmlta_doctype_analysis":
                     $html .= "\n\t\t\t\t\t\t\t<div class='row'><div class='colonne60'>" . $msg[$field] . "&nbsp;:&nbsp;</div>\n";
                     $html .= "\n\t\t\t\t\t\t\t<div class='colonne_suite'>";
                     $select_doc = new marc_select("doctype", "form_" . $field, ${$field}, "", "0", $msg[$field . "_parent"]);
                     $html .= $select_doc->display;
                     $html .= "</div></div>\n";
                     break;
                 default:
                     $deflt_table = substr($field, 6);
                     $html .= "\n\t\t\t\t\t\t\t<div class='row'><div class='colonne60'>" . $msg[$field] . "&nbsp;:&nbsp;</div>\n";
                     $html .= "\n\t\t\t\t\t\t\t<div class='colonne_suite'>";
                     $select_doc = new marc_select("{$deflt_table}", "form_" . $field, ${$field}, "");
                     $html .= $select_doc->display;
                     $html .= "</div></div>\n";
                     break;
             }
         case "deflt3":
             $q = '';
             $t = array();
             switch ($field) {
                 case "deflt3bibli":
                     $q = "select 0,'" . addslashes($msg['deflt3none']) . "' union ";
                     $q .= "select id_entite, raison_sociale from entites where type_entite='1' order by 2 ";
                     break;
                 case "deflt3exercice":
                     $q = "select 0,'" . addslashes($msg['deflt3none']) . "' union ";
                     $q .= "select id_exercice, libelle from exercices order by 2 ";
                     break;
                 case "deflt3rubrique":
                     $q = "select 0,'" . addslashes($msg['deflt3none']) . "' union ";
                     $q .= "select id_rubrique, concat(budgets.libelle,':', rubriques.libelle) from rubriques join budgets on num_budget=id_budget order by 2 ";
                     break;
                 case "deflt3dev_statut":
                     $t = actes::getStatelist(TYP_ACT_DEV);
                     break;
                 case "deflt3cde_statut":
                     $t = actes::getStatelist(TYP_ACT_CDE);
                     break;
                 case "deflt3liv_statut":
                     $t = actes::getStatelist(TYP_ACT_LIV);
                     break;
                 case "deflt3fac_statut":
                     $t = actes::getStatelist(TYP_ACT_FAC);
                     break;
                 case "deflt3sug_statut":
                     $m = new suggestions_map();
                     $t = $m->getStateList();
                     break;
                 case 'deflt3lgstatcde':
                 case 'deflt3lgstatdev':
                     $q = lgstat::getList('QUERY');
                     break;
                 case 'deflt3receptsugstat':
                     $m = new suggestions_map();
                     $t = $m->getStateList('ORDERED', TRUE);
                     break;
             }
             if ($q) {
                 $r = mysql_query($q, $dbh);
                 $nb = mysql_num_rows($r);
                 while ($row = mysql_fetch_row($r)) {
                     $t[$row[0]] = $row[1];
                 }
             }
             if (count($t)) {
                 $html .= "<div class='row'><div class='colonne60'>" . $msg[$field] . "&nbsp;:&nbsp;</div>\n";
                 $html .= "<div class='colonne_suite'><select class='saisie-30em' name=\"form_" . $field . "\">";
                 foreach ($t as $k => $v) {
                     $html .= "<option value=\"" . $k . "\" ";
                     if (${$field} == $k) {
                         $html .= "selected='selected' ";
                     }
                     $html .= ">" . htmlentities($v, ENT_QUOTES, $charset) . "</option>\n";
                 }
                 $html .= "</select></div></div><br />\n";
             }
             break;
         case "speci_":
             $speci_func = substr($field, 6);
             eval('$speci_user.= get_' . $speci_func . '($id, $$field, $i, \'userform\');');
             break;
         case "explr_":
             ${$field} = ${$field};
             break;
         default:
             break;
     }
     switch ($field) {
         case "deflt2docs_location":
             $html = str_replace("!!param_allloc!!", self::get_user_param_form("param_allloc"), $html);
             break;
     }
     return $html;
 }
Example #12
0
     $y_footer = $pos_footer[0];
 }
 if (!$pos_footer[1]) {
     $fs_footer = '8';
 } else {
     $fs_footer = $pos_footer[1];
 }
 //---------------------------------------------------------------------------------------------------------------------
 $taille_doc = array($largeur_page, $hauteur_page);
 $w = $largeur_page - $marge_gauche - $marge_droite;
 $ourPDF = new $fpdf($orient_page, 'mm', $taille_doc);
 $ourPDF->Open();
 $ourPDF->SetMargins($marge_gauche, $marge_haut, $marge_droite);
 //On récupère les infos de la livraison
 $liv = new actes($id_liv);
 $lignes = actes::getLignes($id_liv);
 $bibli = new entites($liv->num_entite);
 $coord_liv = new coordonnees($liv->num_contact_livr);
 $fou = new entites($liv->num_fournisseur);
 $coord_fou = entites::get_coordonnees($liv->num_fournisseur, '1');
 $coord_fou = mysql_fetch_object($coord_fou);
 $id_cde = liens_actes::getParent($id_liv);
 $cde = new actes($id_cde);
 $ourPDF->addPage();
 $ourPDF->setFont($pmb_pdf_font);
 //Affichage date
 $date = formatdate(today());
 $ourPDF->setFontSize($fs_date);
 $ourPDF->SetXY($x_date, $y_date);
 $ourPDF->Cell($l_date, $h_date, $date, 0, 0, 'L', 0);
 //Affichage raison sociale
Example #13
0
function delete_cde_list()
{
    global $chk;
    if (is_array($chk)) {
        foreach ($chk as $id_cde) {
            $cde = new actes($id_cde);
            if ($cde->type_acte == TYP_ACT_CDE && $cde->statut == STA_ACT_AVA) {
                $cde->delete();
            }
        }
    }
}
Example #14
0
function undo()
{
    global $id_lig, $previous;
    $error = false;
    if (!$id_lig) {
        return $error;
    }
    if (!$previous) {
        return $error;
    }
    $tp = unserialize(rawurldecode(stripslashes($previous)));
    if (!is_array($tp) || !count($tp)) {
        $previous = 0;
        return $error;
    }
    $id_liv = array_pop($tp);
    if (count($tp)) {
        $previous = addslashes(rawurlencode(serialize($tp)));
    } else {
        $previous = 0;
    }
    $lg_liv = new lignes_actes($id_liv);
    if (!$lg_liv->id_ligne) {
        return $error;
    }
    $liv = new actes($lg_liv->num_acte);
    if (!$liv->id_acte) {
        return $error;
    }
    $id_cde = liens_actes::getOrder($id_liv);
    $lg_liv->delete();
    $r = actes::getLignes($lg_liv->num_acte);
    if (mysql_num_rows($r) == 0) {
        $liv->delete();
    }
    $cde = new actes($id_cde);
    $cde->statut = $cde->statut & !STA_ACT_AVA & !STA_ACT_REC & !STA_ACT_ARC | STA_ACT_ENC;
    $cde->update_statut();
    return !$error;
}
Example #15
0
function update_liv()
{
    global $id_bibli, $id_cde, $id_liv, $comment, $ref;
    global $max_lig, $max_lig_liv, $id_lig, $id_prod, $code, $rec;
    global $acquisition_email_sugg;
    $tab_liv = array();
    //Tableau des lignes livrées
    //Les lignes restant à livrer sont reprises dans la tableau si la qté reçue est >0
    for ($i = 1; $i <= $max_lig; $i++) {
        if ($rec[$i]) {
            $tab_liv[$i]['id_lig'] = $id_lig[$i];
            $tab_liv[$i]['rec'] = $rec[$i];
        }
    }
    //Les quantités recues des lignes déjà livrées sont reportées dans le tableau si l'identifiant de ligne existe
    //Sinon une nouvelle ligne est créée
    for ($i; $i <= $max_lig + $max_lig_liv; $i++) {
        $deja = false;
        for ($j = 1; $j <= $max_lig; $j++) {
            //Y a-t'il une ligne deja créée
            if ($tab_liv[$j]['id_lig'] == $id_lig[$i]) {
                //Si oui, on rajoute la quantité reçue dans le tableau
                $tab_liv[$j]['rec'] = $tab_liv[$j]['rec'] + $rec[$i];
                $deja = true;
                break;
            }
        }
        if (!$deja) {
            //Sinon, on crée la ligne dans le tableau
            $tab_liv[$i]['id_lig'] = $id_lig[$i];
            $tab_liv[$i]['rec'] = $rec[$i];
        }
    }
    //Récupération de la commande
    $cde = new actes($id_cde);
    if (!$id_liv) {
        //Création du bon de livraison
        $liv = new actes();
        $liv->date_acte = today();
        $liv->type_acte = '2';
        $liv->statut = '4';
        //Statut BL = recu
        $liv->num_entite = $cde->num_entite;
        $liv->num_fournisseur = $cde->num_fournisseur;
        $liv->num_contact_livr = $cde->num_contact_livr;
        $liv->num_contact_fact = $cde->num_contact_fact;
        $liv->num_exercice = $cde->num_exercice;
        $liv->commentaires = $comment;
        $liv->reference = $ref;
        $liv->calc();
        $liv->save();
        $id_liv = $liv->id_acte;
        //création des liens entre actes
        $la = new liens_actes($id_cde, $id_liv);
    } else {
        //Modification du bon de livraison
        $liv = new actes($id_liv);
        $liv->numero = addslashes($liv->numero);
        $liv->commentaires = trim($comment);
        $liv->reference = trim($ref);
        $liv->save();
    }
    //Suppression des lignes de livraisons précédemment enregistrées
    actes::deleteLignes($id_liv);
    $sug_map = new suggestions_map();
    //Création des lignes de livraison
    foreach ($tab_liv as $key => $value) {
        $lig_cde = new lignes_actes($tab_liv[$key]['id_lig']);
        $lig_liv = new lignes_actes();
        $lig_liv->num_acte = $liv->id_acte;
        $lig_liv->lig_ref = $lig_cde->id_ligne;
        $lig_liv->num_acquisition = $lig_cde->num_acquisition;
        $lig_liv->num_rubrique = $lig_cde->num_rubrique;
        $lig_liv->num_produit = $lig_cde->num_produit;
        $lig_liv->num_type = $lig_cde->num_type;
        $lig_liv->libelle = addslashes($lig_cde->libelle);
        $lig_liv->code = addslashes($lig_cde->code);
        $lig_liv->prix = $lig_cde->prix;
        $lig_liv->tva = $lig_cde->tva;
        $lig_liv->remise = $lig_cde->remise;
        $lig_liv->nb = $tab_liv[$key]['rec'];
        $lig_liv->date_cre = today();
        $lig_liv->save();
        if ($lig_cde->num_acquisition != 0) {
            $sug = array();
            $sug[] = $lig_cde->num_acquisition;
            $sug_map->doTransition('RECEIVED', $sug);
        }
    }
    //La commande est-elle soldée
    $tab_cde = actes::getLignes($id_cde);
    $solde = true;
    while ($row_cde = mysql_fetch_object($tab_cde)) {
        if ($row_cde->type_ligne == 3) {
            // Frais, non livrables
        } else {
            $tab_liv = lignes_actes::getLivraisons($row_cde->id_ligne);
            $nb_liv = 0;
            while ($row_liv = mysql_fetch_object($tab_liv)) {
                $nb_liv = $nb_liv + $row_liv->nb;
            }
            if ($row_cde->nb > $nb_liv) {
                $solde = false;
                break;
            }
        }
    }
    if ($solde) {
        $cde->statut = $cde->statut & ~2 | 4;
        // Cde soldée >> Statut commande = en cours->soldé
    }
    $cde->update_statut();
}