コード例 #1
0
ファイル: devis.inc.php プロジェクト: noble82/proyectos-ULS
function show_lig_dev($id_dev)
{
    global $charset;
    global $acquisition_gestion_tva;
    global $modif_dev_row_form;
    $form = "";
    $i = 0;
    if (!$id_dev) {
        $t = array(0 => $i, $form);
        return $t;
    }
    $lignes = actes::getLignes($id_dev);
    while ($row = pmb_mysql_fetch_object($lignes)) {
        $i++;
        $form .= $modif_dev_row_form;
        $form = str_replace('!!no!!', $i, $form);
        $form = str_replace('!!code!!', htmlentities($row->code, ENT_QUOTES, $charset), $form);
        $form = str_replace('!!lib!!', htmlentities($row->libelle, ENT_QUOTES, $charset), $form);
        $form = str_replace('!!qte!!', $row->nb, $form);
        $form = str_replace('!!prix!!', $row->prix, $form);
        if ($row->num_type) {
            $tp = new types_produits($row->num_type);
            $form = str_replace('!!typ!!', $tp->id_produit, $form);
            $form = str_replace('!!lib_typ!!', htmlentities($tp->libelle, ENT_QUOTES, $charset), $form);
        } else {
            $form = str_replace('!!typ!!', '0', $form);
            $form = str_replace('!!lib_typ!!', '', $form);
        }
        if ($acquisition_gestion_tva) {
            $form = str_replace('!!tva!!', $row->tva, $form);
        }
        $form = str_replace('!!rem!!', $row->remise, $form);
        $form = str_replace('!!id_sug!!', $row->num_acquisition, $form);
        $form = str_replace('!!id_lig!!', $row->id_ligne, $form);
        $form = str_replace('!!typ_lig!!', $row->type_ligne, $form);
        $form = str_replace('!!id_prod!!', $row->num_produit, $form);
    }
    $t = array(0 => $i, 1 => $form);
    return $t;
}
コード例 #2
0
ファイル: lettre-facture.inc.php プロジェクト: bouchra012/PMB
     $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
コード例 #3
0
ファイル: lettre_devis.class.php プロジェクト: bouchra012/PMB
 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);
 }
コード例 #4
0
ファイル: frame_facture.php プロジェクト: bouchra012/PMB
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();
}
コード例 #5
0
 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);
 }
コード例 #6
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
コード例 #7
0
function sold_cde()
{
    global $id_cde, $comment, $ref, $date_pay, $num_pay;
    if (!$id_cde) {
        return;
    }
    $cde = new actes($id_cde);
    //Commande considérée comme soldée
    $cde->statut = $cde->statut & ~STA_ACT_ENC;
    $cde->statut = $cde->statut | STA_ACT_REC;
    //Les quantites livrees sur la commande sont-elles entierement facturees
    //Si oui statut commande >> facture
    $tab_cde = actes::getLignes($id_cde);
    $facture = true;
    while ($row_cde = pmb_mysql_fetch_object($tab_cde)) {
        $tab_liv = lignes_actes::getLivraisons($row_cde->id_ligne);
        $tab_fac = lignes_actes::getFactures($row_cde->id_ligne);
        $nb_liv = 0;
        while ($row_liv = pmb_mysql_fetch_object($tab_liv)) {
            $nb_liv = $nb_liv + $row_liv->nb;
        }
        $nb_fac = 0;
        while ($row_fac = pmb_mysql_fetch_object($tab_fac)) {
            $nb_fac = $nb_fac + $row_fac->nb;
        }
        if ($nb_liv > $nb_fac) {
            $facture = false;
            break;
        }
    }
    if ($facture) {
        $cde->statut = $cde->statut | STA_ACT_FAC;
        //Pas de reste à facturer >>Statut commande = facturée
        //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 = pmb_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 {
        $cde->statut = $cde->statut & ~STA_ACT_FAC;
        //Reste à facturer >>Statut commande = non facturée
    }
    $cde->numero = addslashes($cde->numero);
    $cde->commentaires = trim($comment);
    $cde->commentaires_i = addslashes($cde->commentaires_i);
    $cde->reference = trim($ref);
    $cde->date_paiement = $date_pay;
    $cde->num_paiement = trim($num_pay);
    $cde->devise = addslashes($cde->devise);
    $cde->save();
}
コード例 #8
0
ファイル: receptions_frame.php プロジェクト: bouchra012/PMB
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;
}
コード例 #9
0
ファイル: frame_livraison.php プロジェクト: bouchra012/PMB
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();
}