Esempio n. 1
0
function show_list_rel($id_bibli, $id_fou)
{
    global $msg, $charset;
    global $histrel_form, $histrel_hrow_form, $histrel_row_form;
    global $acquisition_gestion_tva;
    $tab_rel = array();
    if ($id_fou) {
        $tab_rel = lignes_actes::getRelancesBySupplier($id_fou);
    }
    $form = $histrel_form;
    $form = str_replace('!!form_title!!', htmlentities($msg['acquisition_hist_rel_fou'], ENT_QUOTES, $charset), $form);
    $bibli = new entites($id_bibli);
    $form = str_replace('!!id!!', $id_fou, $form);
    $form = str_replace('!!id_bibli!!', $id_bibli, $form);
    $form = str_replace('!!lib_bibli!!', htmlentities($bibli->raison_sociale, ENT_QUOTES, $charset), $form);
    $fourn = new entites($id_fou);
    $form = str_replace('!!raison!!', htmlentities($fourn->raison_sociale, ENT_QUOTES, $charset), $form);
    $date_rel = '';
    $lg_form = '';
    $i = 0;
    foreach ($tab_rel as $k => $rel) {
        $i++;
        if ($rel[date_rel] != $date_rel) {
            $date_rel = $rel['date_rel'];
            $form = str_replace('<!-- relances -->', $lg_form . '<!-- relances -->', $form);
            $lg_form = $histrel_hrow_form;
            $lg_form = str_replace('!!lib_rel!!', htmlentities(sprintf($msg['acquisition_hist_rel_du'], $date_rel), ENT_QUOTES, $charset), $lg_form);
        }
        $lg_form = str_replace('<!-- lignes -->', $histrel_row_form . '<!-- lignes -->', $lg_form);
        $lg_form = str_replace('!!numero!!', htmlentities($rel['numero'], ENT_QUOTES, $charset), $lg_form);
        $lg_form = str_replace('!!code!!', htmlentities($rel['code'], ENT_QUOTES, $charset), $lg_form);
        $lg_form = str_replace('!!lib!!', nl2br(htmlentities($rel['libelle'], ENT_QUOTES, $charset)), $lg_form);
        $lg_form = str_replace('!!qte!!', htmlentities($rel['nb'], ENT_QUOTES, $charset), $lg_form);
        $lg_form = str_replace('!!prix!!', htmlentities($rel['prix'], ENT_QUOTES, $charset), $lg_form);
        if ($rel['num_type']) {
            $tp = new types_produits($rel['num_type']);
            $lg_form = str_replace('!!lib_typ!!', htmlentities($tp->libelle, ENT_QUOTES, $charset), $lg_form);
        } else {
            $lg_form = str_replace('!!lib_typ!!', '', $lg_form);
        }
        if ($acquisition_gestion_tva) {
            $lg_form = str_replace('!!tva!!', $rel['tva'], $lg_form);
        }
        $lg_form = str_replace('!!rem!!', $rel['remise'], $lg_form);
        if ($rel['num_rubrique']) {
            $rub = new rubriques($rel['num_rubrique']);
            $lg_form = str_replace('!!lib_rub!!', htmlentities($rub->libelle, ENT_QUOTES, $charset), $lg_form);
        } else {
            $lg_form = str_replace('!!lib_rub!!', '', $lg_form);
        }
        $lg_stat = new lgstat($rel['statut']);
        $lg_form = str_replace('!!lgstat!!', htmlentities($lg_stat->libelle, ENT_QUOTES, $charset), $lg_form);
        $lg_form = str_replace('!!comment_lg!!', nl2br(htmlentities($rel['commentaires_gestion'], ENT_QUOTES, $charset)), $lg_form);
        $lg_form = str_replace('!!comment_lo!!', nl2br(htmlentities($rel['commentaires_opac'], ENT_QUOTES, $charset)), $lg_form);
        $lg_form = str_replace('!!no!!', $i, $lg_form);
        $lg_form = str_replace('!!id_lig!!', $rel['num_ligne'], $lg_form);
    }
    $form = str_replace('<!-- relances -->', $lg_form, $form);
    print $form;
}
Esempio n. 2
0
function update_dev()
{
    global $id_bibli, $id_dev, $num_dev, $statut;
    global $id_fou;
    global $id_adr_liv, $id_adr_fac;
    global $comment, $comment_i, $ref, $devise;
    global $code, $lib, $qte, $prix, $typ, $tva, $rem, $id_sug, $id_lig, $typ_lig, $id_prod;
    global $acquisition_gestion_tva;
    //Recuperation des lignes valides
    $tab_lig = array();
    if (count($id_lig)) {
        foreach ($id_lig as $k => $v) {
            $code[$k] = trim($code[$k]);
            $lib[$k] = trim($lib[$k]);
            if ($code[$k] != '' || $lib[$k] != '') {
                $tab_lig[$k] = $v;
            }
        }
    }
    if (!$id_dev) {
        //Creation de devis
        $dev = new actes();
        $dev->type_acte = TYP_ACT_DEV;
        $dev->num_entite = $id_bibli;
        /*$num_dev=trim($num_dev);
        		if ($num_dev!='') {
        			$dev->numero=$num_dev;
        		} else {
        			$dev->calc();
        		}*/
        $dev->statut = STA_ACT_ENC;
        $dev->num_fournisseur = $id_fou;
        $dev->num_contact_livr = $id_adr_liv;
        $dev->num_contact_fact = $id_adr_fac;
        $dev->commentaires = trim($comment);
        $dev->commentaires_i = trim($comment_i);
        $dev->reference = trim($ref);
        $dev->devise = trim($devise);
        $dev->save();
        $id_dev = $dev->id_acte;
        //Creation des lignes de devis
        foreach ($tab_lig as $k => $v) {
            $lig_dev = new lignes_actes();
            $lig_dev->type_ligne = $typ_lig[$k];
            $lig_dev->num_acte = $id_dev;
            $lig_dev->num_produit = $id_prod[$k];
            $lig_dev->num_acquisition = $id_sug[$k];
            $lig_dev->num_type = $typ[$k];
            $lig_dev->code = $code[$k];
            $lig_dev->libelle = $lib[$k];
            $lig_dev->prix = $prix[$k];
            if ($acquisition_gestion_tva) {
                $lig_dev->tva = $tva[$k];
            } else {
                $lig_dev->tva = '0.00';
            }
            $lig_dev->remise = $rem[$k];
            $lig_dev->nb = round($qte[$k]);
            $lig_dev->date_cre = today();
            $lig_dev->save();
        }
        //Mise à jour du statut des suggestions et envoi email suivi de suggestion
        $sug_map = new suggestions_map();
        $sug_map->doTransition('ESTIMATED', $id_sug);
    } else {
        //Modification de devis
        $dev = new actes($id_dev);
        /*$num_dev=trim($num_dev);
        		if ($num_dev!='') {
        			$dev->numero=$num_dev;
        		} else {
        			$dev->numero=addslashes($dev->numero);
        		}*/
        $old_statut = $dev->statut & ~STA_ACT_ARC;
        if ($old_statut != STA_ACT_ENC && $old_statut != STA_ACT_REC) {
            $old_statut = STA_ACT_ENC;
        }
        if ($statut == STA_ACT_ARC) {
            $rec_statut = $old_statut | STA_ACT_ARC;
        } else {
            $rec_statut = $statut;
        }
        $dev->statut = $rec_statut;
        $dev->num_fournisseur = $id_fou;
        $dev->num_contact_livr = $id_adr_liv;
        $dev->num_contact_fact = $id_adr_fac;
        $dev->commentaires = trim($comment);
        $dev->commentaires_i = trim($comment_i);
        $dev->reference = trim($ref);
        $dev->devise = trim($devise);
        $dev->save();
        //maj des lignes de devis
        foreach ($tab_lig as $k => $v) {
            $lig_dev = new lignes_actes($v);
            $lig_dev->type_ligne = $typ_lig[$k];
            $lig_dev->num_acte = $id_dev;
            $lig_dev->num_produit = $id_prod[$k];
            $lig_dev->num_acquisition = $id_sug[$k];
            $lig_dev->num_type = $typ[$k];
            $lig_dev->code = $code[$k];
            $lig_dev->libelle = $lib[$k];
            $lig_dev->prix = $prix[$k];
            if ($acquisition_gestion_tva) {
                $lig_dev->tva = $tva[$k];
            } else {
                $lig_dev->tva = '0.00';
            }
            $lig_dev->remise = $rem[$k];
            $lig_dev->nb = round($qte[$k]);
            $lig_dev->date_cre = today();
            $lig_dev->save();
            if ($v == 0) {
                $tab_lig[$k] = $lig_dev->id_ligne;
            }
        }
        //suppression des lignes non reprises
        $dev->cleanLignes($id_dev, $tab_lig);
    }
}
 function doLettre(&$bib, &$bib_coord, &$fou, &$fou_coord, &$tab_act)
 {
     global $msg;
     $this->sect =& $this->RTF->addSection();
     //$this->RTF->footers[] = $this->msg_footer;
     $tab1 = $this->sect->addTable();
     $tab1->addRows(1, 0);
     $tab1->addColumnsList(array($this->x_raison - $this->x_logo, $this->x_date - $this->x_raison, $this->largeur_page - $this->marge_droite - $this->x_date));
     //$this->PDF->npage = 1;
     //Affichage logo
     if ($bib->logo != '') {
         $par_logo = new ParFormat();
         $tab1->addImageToCell(1, 1, $bib->logo, new ParFormat(), $this->l_logo, $this->h_logo);
     }
     //Affichage raison sociale
     $raison = $this->RTF->to_utf8($bib->raison_sociale);
     $par_raison = new ParFormat();
     $tab1->writeToCell(1, 2, $raison, $this->fonts['raison'], $par_raison);
     //Affichage date ville
     $ville_end = stripos($bib_coord->ville, "cedex");
     if ($ville_end !== false) {
         $ville = trim(substr($bib_coord->ville, 0, $ville_end));
     } else {
         $ville = $bib_coord->ville;
     }
     $date = $ville . $this->sep_ville_date . format_date(today());
     $date = $this->RTF->to_utf8($date);
     $par_ville = new ParFormat();
     $tab1->writeToCell(1, 3, $date, $this->fonts['date'], $par_ville);
     $this->sect->writeText('', $this->fonts['standard'], new parFormat());
     $tab2 = $this->sect->addTable();
     $tab2->addRows(1, 0);
     $tab2->addColumnsList(array($this->l_adr_rel - $this->x_adr_rel, $this->x_adr_fou - $this->l_adr_rel - $this->x_adr_rel, $this->largeur_page - $this->x_adr_fou));
     //Affichage adresse bibliotheque
     $adr_rel = '';
     if ($bib_coord->libelle != '') {
         $adr_rel .= $bib_coord->libelle . "\r\n";
     }
     if ($bib_coord->adr1 != '') {
         $adr_rel .= $bib_coord->adr1 . "\r\n";
     }
     if ($bib_coord->adr2 != '') {
         $adr_rel .= $bib_coord->adr2 . "\r\n";
     }
     if ($bib_coord->cp != '') {
         $adr_rel .= $bib_coord->cp . " ";
     }
     if ($bib_coord->ville != '') {
         $adr_rel .= $bib_coord->ville . "\r\n";
     }
     if ($bib_coord->tel1 != '') {
         $adr_rel .= $this->text_adr_tel . " " . $bib_coord->tel1 . "\r\n";
     }
     if ($bib_coord->fax != '') {
         $adr_rel .= $this->text_adr_fax . " " . $bib_coord->fax . "\r\n";
     }
     if ($bib_coord->email != '') {
         $adr_rel .= $this->text_adr_email . " " . $bib_coord->email . "\r\n";
     }
     $adr_rel = $this->RTF->to_utf8($adr_rel);
     $par_adr_rel = new parFormat();
     $tab2->writeToCell(1, 1, $adr_rel, $this->fonts['adr_rel'], $par_adr_rel);
     //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 . "\r\n";
     } else {
         $adr_fou = $coord_fou->libelle . "\r\n";
     }
     if ($fou_coord->adr1 != '') {
         $adr_fou .= $fou_coord->adr1 . "\r\n";
     }
     if ($fou_coord->adr2 != '') {
         $adr_fou .= $fou_coord->adr2 . "\r\n";
     }
     if ($fou_coord->cp != '') {
         $adr_fou .= $fou_coord->cp . " ";
     }
     if ($fou_coord->ville != '') {
         $adr_fou .= $fou_coord->ville . "\r\n\r\n";
     }
     if ($fou_coord->contact != '') {
         $adr_fou .= $fou_coord->contact;
     }
     $adr_fou = $this->RTF->to_utf8($adr_fou);
     $par_adr_fou = new parFormat();
     $tab2->writeToCell(1, 3, $adr_fou, $this->fonts['adr_fou'], $par_adr_fou);
     //Affichage numero client
     $numero_cli = $this->RTF->to_utf8($this->text_num_cli . " " . $fou->num_cp_client);
     $par_numero_cli = new parFormat();
     $par_numero_cli->setSpaceAfter(10);
     $this->sect->writeText($numero_cli, $this->fonts['num_cli'], $par_numero_cli);
     //Affichage titre
     $text_titre = $this->RTF->to_utf8($this->text_titre);
     $par_titre = new parFormat();
     $par_titre->setSpaceAfter(10);
     $par_titre->setIndentLeft($this->x_titre - $this->marge_gauche);
     $this->sect->writeText($text_titre, $this->fonts['titre'], $par_titre);
     //Affichage texte before
     if ($this->text_before != '') {
         $text_before = $this->RTF->to_utf8($this->text_before);
         $par_before = new parFormat();
         $this->sect->writeText($text_before, $this->fonts['standard'], $par_before);
     }
     //Affichage des lignes de relances
     foreach ($tab_act as $id_act => $tab_lig) {
         $this->p_header = false;
         $act = new actes($id_act);
         $this->text_num_ech = $this->text_num . ' ' . $act->numero;
         if ($act->date_ech != '0000-00-00') {
             $this->text_num_ech .= ' ' . sprintf($this->text_ech, format_date($act->date_ech));
         }
         $this->doEntete();
         foreach ($tab_lig as $id_lig) {
             $lig = new lignes_actes($id_lig);
             $typ = new types_produits($lig->num_type);
             $col1 = $typ->libelle;
             if ($lig->code) {
                 $col1 .= "\r\n" . $lig->code;
             }
             $col2 = $lig->libelle;
             $col3 = $lig->nb;
             $col4 = $lig->getNbDelivered();
             $col5 = $col3 - $col4;
             $this->tab->addRows(1, 0);
             $this->tab->addColumnsList(array($this->w_col1, $this->w_col2, $this->w_col3, $this->w_col4, $this->w_col5));
             $border_format = new BorderFormat(0.5, "#000000");
             $txt_col1 = $this->RTF->to_utf8($col1);
             $par_col1 = new parFormat();
             $this->tab->writeToCell($this->row, 1, $txt_col1, $this->fonts['standard'], $par_col1);
             $txt_col2 = $this->RTF->to_utf8($col2);
             $par_col2 = new parFormat();
             $this->tab->writeToCell($this->row, 2, $txt_col2, $this->fonts['standard'], $par_col2);
             $txt_col3 = $this->RTF->to_utf8($col3);
             $par_col3 = new parFormat();
             $this->tab->writeToCell($this->row, 3, $txt_col3, $this->fonts['standard'], $par_col3);
             $txt_col4 = $this->RTF->to_utf8($col4);
             $par_col4 = new parFormat();
             $this->tab->writeToCell($this->row, 4, $txt_col4, $this->fonts['standard'], $par_col4);
             $txt_col5 = $this->RTF->to_utf8($col5);
             $par_col5 = new parFormat();
             $this->tab->writeToCell($this->row, 5, $txt_col5, $this->fonts['standard'], $par_col5);
             $this->tab->setBordersOfCells($border_format, 1, 1, $this->row, 5);
             $this->row++;
         }
     }
     //Affichage texte after
     if ($this->text_after != '') {
         $text_after = $this->RTF->to_utf8($this->text_after);
         $par_after = new parFormat();
         $this->sect->writeText($text_after, $this->fonts['standard'], $par_after);
     }
     //Affichage signature
     $text_sign = $this->RTF->to_utf8($this->text_sign);
     $par_sign = new parFormat();
     $par_sign->setSpaceBefore(10);
     $par_sign->setIndentLeft($this->x_sign - $this->marge_gauche);
     $this->sect->writeText($text_sign, $this->fonts['sign'], $par_sign);
     $this->sect->insertPageBreak();
 }
Esempio n. 4
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();
}
    die("no access");
}
switch ($quoifaire) {
    case 'get_comment':
    case 'upd_comment':
        require_once "{$class_path}/lignes_actes.class.php";
        $pos = strrpos($id, '_');
        $typ_com = substr($id, 0, $pos);
        $id_lig = substr($id, $pos + 1);
        $la = new lignes_actes($id_lig);
        break;
    case 'upd_lgstat':
        require_once "{$class_path}/lignes_actes.class.php";
        $pos = strrpos($id, '_');
        $id_lig = substr($id, $pos + 1);
        $la = new lignes_actes($id_lig);
        $la->updateFields(array(0 => $la->id_ligne), array('statut' => $lgstat));
        break;
    default:
        break;
}
switch ($quoifaire) {
    case 'get_comment':
        switch ($typ_com) {
            case 'comment_lg':
                ajax_http_send_response($la->commentaires_gestion);
                break;
            case 'comment_lo':
                ajax_http_send_response($la->commentaires_opac);
                break;
            default:
Esempio n. 6
0
function update_cde()
{
    global $id_bibli, $id_exer, $id_cde, $num_cde, $nom_acte, $id_dev, $statut;
    global $id_fou;
    global $id_adr_liv, $id_adr_fac;
    global $comment, $comment_i, $ref, $date_pay, $num_pay, $date_liv, $devise;
    global $code, $lib, $qte, $prix, $typ, $tva, $rem, $rub, $id_sug, $id_lig, $typ_lig, $id_prod;
    global $acquisition_gestion_tva;
    global $action;
    global $force_debit;
    global $lg_statut, $comment_lg, $comment_lo;
    if (!$id_cde) {
        //Creation de commande
        $cde = new actes();
        $cde->type_acte = TYP_ACT_CDE;
        $cde->num_entite = $id_bibli;
        $cde->num_exercice = $id_exer;
        /*$num_cde=trim($num_cde);
        		if ($num_cde!='') {
        			$cde->numero=$num_cde;
        		} else {
        			$cde->calc();
        		}*/
        $cde->nom_acte = trim($nom_acte);
        if ($action == 'valid') {
            $cde->statut = STA_ACT_ENC;
        } else {
            $cde->statut = STA_ACT_AVA;
        }
        $cde->num_fournisseur = $id_fou;
        $cde->num_contact_livr = $id_adr_liv;
        $cde->num_contact_fact = $id_adr_fac;
        $cde->commentaires = trim($comment);
        $cde->commentaires_i = trim($comment_i);
        $cde->reference = trim($ref);
        $cde->date_paiement = $date_pay;
        $cde->num_paiement = trim($num_pay);
        $cde->date_ech = $date_liv;
        $cde->devise = trim($devise);
        $cde->save();
        $id_cde = $cde->id_acte;
        //creation des liens entre actes
        if ($id_dev) {
            $la = new liens_actes($id_dev, $id_cde);
        }
        //Recuperation des lignes valides
        $tab_lig = array();
        if (count($id_lig)) {
            foreach ($id_lig as $k => $v) {
                $code[$k] = trim($code[$k]);
                $lib[$k] = trim($lib[$k]);
                $comment_lg[$k] = trim($comment_lg[$k]);
                $comment_lo[$k] = trim($comment_lo[$k]);
                if ($code[$k] != '' || $lib[$k] != '') {
                    $tab_lig[$k] = $v;
                }
            }
        }
        //creation des lignes de commande
        foreach ($tab_lig as $k => $v) {
            $lig_cde = new lignes_actes();
            $lig_cde->type_ligne = $typ_lig[$k];
            $lig_cde->num_acte = $id_cde;
            $lig_cde->num_rubrique = $rub[$k];
            $lig_cde->num_produit = $id_prod[$k];
            $lig_cde->num_acquisition = $id_sug[$k];
            $lig_cde->num_type = $typ[$k];
            $lig_cde->code = trim($code[$k]);
            $lig_cde->libelle = trim($lib[$k]);
            $lig_cde->prix = $prix[$k];
            if ($acquisition_gestion_tva) {
                $lig_cde->tva = $tva[$k];
            } else {
                $lig_cde->tva = '0.00';
            }
            $lig_cde->debit_tva = $force_debit[$k];
            $lig_cde->remise = $rem[$k];
            $lig_cde->nb = round($qte[$k]);
            $lig_cde->date_ech = $date_liv;
            $lig_cde->date_cre = today();
            $lig_cde->statut = $lg_statut[$k];
            $lig_cde->commentaires_gestion = $comment_lg[$k];
            $lig_cde->commentaires_opac = $comment_lo[$k];
            $lig_cde->save();
        }
        //Mise à jour du statut des suggestions et envoi email suivi de suggestion
        $sug_map = new suggestions_map();
        $sug_map->doTransition('ORDERED', $id_sug);
    } else {
        //modification de commande
        $cde = new actes($id_cde);
        $old_statut = $statut;
        if ($old_statut != STA_ACT_ENC) {
            //Commande a valider
            /*$num_cde=trim($num_cde);
            		if ($num_cde!='') {
            			$cde->numero=$num_cde;
            		} else {
            			$cde->numero=addslashes($cde->numero);
            		}*/
            $cde->nom_acte = trim($nom_acte);
            if ($action == 'valid') {
                $cde->date_valid = date("Y-m-d");
                $cde->statut = STA_ACT_ENC;
                //Statut commande = A valider->en cours
            }
            $cde->num_fournisseur = $id_fou;
            $cde->num_contact_livr = $id_adr_liv;
            $cde->num_contact_fact = $id_adr_fac;
            $cde->commentaires = trim($comment);
            $cde->commentaires_i = trim($comment_i);
            $cde->reference = trim($ref);
            $cde->date_paiement = $date_pay;
            $cde->num_paiement = trim($num_pay);
            $cde->date_ech = $date_liv;
            $cde->devise = trim($devise);
            $cde->save();
            //Recuperation des lignes valides
            $tab_lig = array();
            if (count($id_lig)) {
                foreach ($id_lig as $k => $v) {
                    $code[$k] = trim($code[$k]);
                    $lib[$k] = trim($lib[$k]);
                    $comment_lg[$k] = trim($comment_lg[$k]);
                    $comment_lo[$k] = trim($comment_lo[$k]);
                    if ($code[$k] != '' || $lib[$k] != '') {
                        $tab_lig[$k] = $v;
                    }
                }
            }
            //maj des lignes de commande
            foreach ($tab_lig as $k => $v) {
                $lig_cde = new lignes_actes($v);
                $lig_cde->type_ligne = $typ_lig[$k];
                $lig_cde->num_acte = $id_cde;
                $lig_cde->num_rubrique = $rub[$k];
                $lig_cde->num_produit = $id_prod[$k];
                $lig_cde->num_acquisition = $id_sug[$k];
                $lig_cde->num_type = $typ[$k];
                $lig_cde->code = trim($code[$k]);
                $lig_cde->libelle = trim($lib[$k]);
                $lig_cde->prix = $prix[$k];
                if ($acquisition_gestion_tva) {
                    $lig_cde->tva = $tva[$k];
                } else {
                    $lig_cde->tva = '0.00';
                }
                $lig_cde->debit_tva = $force_debit[$k];
                $lig_cde->remise = $rem[$k];
                $lig_cde->nb = round($qte[$k]);
                $lig_cde->date_ech = $date_liv;
                $lig_cde->date_cre = today();
                $lig_cde->statut = $lg_statut[$k];
                $lig_cde->commentaires_gestion = $comment_lg[$k];
                $lig_cde->commentaires_opac = $comment_lo[$k];
                $lig_cde->save();
                if ($v == 0) {
                    $tab_lig[$k] = $lig_cde->id_ligne;
                }
            }
            //suppression des lignes non reprises
            $cde->cleanLignes($id_cde, $tab_lig);
        } else {
            //Commande validee
            $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();
            //Recuperation des lignes
            $tab_lig = array();
            if (count($id_lig)) {
                foreach ($id_lig as $k => $v) {
                    $comment_lg[$k] = trim($comment_lg[$k]);
                    $comment_lo[$k] = trim($comment_lo[$k]);
                    $tab_lig[$k] = $v;
                }
            }
            //maj des lignes de commande
            foreach ($tab_lig as $k => $v) {
                $lig_cde = new lignes_actes($v);
                $lig_cde->code = addslashes($lig_cde->code);
                $lig_cde->libelle = addslashes($lig_cde->libelle);
                $lig_cde->statut = $lg_statut[$k];
                $lig_cde->commentaires_gestion = $comment_lg[$k];
                $lig_cde->commentaires_opac = $comment_lo[$k];
                $lig_cde->save();
            }
        }
    }
}
Esempio n. 7
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;
}
Esempio n. 8
0
function record()
{
    global $pmb_notice_controle_doublons;
    global $recept_cat_error_form;
    global $integre, $serialized_post, $existant_notice_id, $existant_b_level, $existant_h_level, $signature, $id_lig, $serialized_search;
    $recorded = false;
    switch ($integre) {
        case 'new':
            $unserialized_post = unserialize(rawurldecode(stripslashes($serialized_post)));
            foreach ($unserialized_post as $key => $val) {
                if (get_magic_quotes_gpc()) {
                    $GLOBALS[$key] = $val;
                } else {
                    add_sl($val);
                    $GLOBALS[$key] = $val;
                }
                global ${$key};
            }
            $z = new z3950_notice("form");
            $z->signature = $signature;
            $ret = $z->insert_in_database();
            $notice_id = $ret[1];
            $recorded = true;
            break;
        case 'existant':
            $notice_id = $existant_notice_id;
            $b_level = $existant_b_level;
            $h_level = $existant_h_level;
            $recorded = true;
            break;
        default:
            $duplicate = array();
            $signature = '';
            $r = object;
            if ($pmb_notice_controle_doublons != 0) {
                $sign = new notice_doublon(true);
                $signature = $sign->gen_signature();
                $r = $sign->getDuplicate();
            }
            if ($r->notice_id) {
                if ($r->niveau_biblio == 'a' && $r->niveau_hierar == 2) {
                    //article
                    $serial = new serial_display($r->notice_id, 6, '', '', '', '', '', 0, 2, 1, 0, 1, 0, 0, '', 0);
                    $notice_display = $serial->result;
                } elseif ($r->niveau_biblio == 'm' && $r->niveau_hierar == 0) {
                    //monographie
                    $display = new mono_display($r->notice_id, 6, '', 1, '', '', '', 0, 2, 1, 1, '', 0, 0, 1, 0);
                    $notice_display = $display->result;
                }
                $form = $recept_cat_error_form;
                $form = str_replace('!!serialized_post!!', rawurlencode(serialize($_POST)), $form);
                $form = str_replace('!!existant_notice_id!!', $r->notice_id, $form);
                $form = str_replace('!!existant_b_level!!', $r->niveau_biblio, $form);
                $form = str_replace('!!existant_h_level!!', $r->niveau_hierar, $form);
                $form = str_replace('!!signature!!', $signature, $form);
                $form = str_replace('!!id_lig!!', $id_lig, $form);
                $form = str_replace('!!serialized_search!!', stripslashes($serialized_search), $form);
                $form = str_replace('<!-- notice_display -->', $notice_display, $form);
                print $form;
                return false;
            } else {
                $z = new z3950_notice("form");
                $z->signature = $signature;
                $ret = $z->insert_in_database();
                $notice_id = $ret[1];
                $recorded = true;
            }
            break;
    }
    if ($recorded) {
        global $id_bibli, $id_exer, $f_fou_code, $f_dem_code, $t_dem, $f_rub_code, $cde_query, $all_query, $chk_dev, $lgstat_filter;
        $unserialized_search = unserialize(rawurldecode(stripslashes($serialized_search)));
        $id_bibli = $unserialized_search['id_bibli'];
        $id_exer = $unserialized_search['id_exer'];
        $f_fou_code = $unserialized_search['f_fou_code'];
        $f_dem_code = $unserialized_search['f_dem_code'];
        $t_dem = $unserialized_search['t_dem'];
        $f_rub_code = $unserialized_search['f_rub_code'];
        $cde_query = $unserialized_search['cde_query'];
        $all_query = $unserialized_search['all_query'];
        $chk_dev = $unserialized_search['chk_dev'];
        $lgstat_filter = $unserialized_search['lgstat_filter'];
        if ($notice_id) {
            $typ_lig = 1;
            if ($b_level == 'a' && $h_level == 2) {
                $typ_lig = 5;
            }
            lignes_actes::updateFields(array(0 => $id_lig), array('num_produit' => $notice_id, 'type_ligne' => $typ_lig));
        }
    }
    return $recorded;
}
Esempio n. 9
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();
}