コード例 #1
0
ファイル: devis.inc.php プロジェクト: noble82/proyectos-ULS
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);
    }
}
コード例 #2
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();
            }
        }
    }
}