Fix: Il fallait générer 2 fois le document quand on changeait de modèle

This commit is contained in:
Laurent Destailleur 2006-07-13 14:31:41 +00:00
parent 0cb701b682
commit ceb10ce850
3 changed files with 72 additions and 69 deletions

View File

@ -933,30 +933,32 @@ class Commande extends CommonObject
} }
} }
/*
* /**
* * \brief Positionne modele derniere generation
* * \param user Objet use qui modifie
*/ * \param modelpdf Nom du modele
*/
function set_pdf_model($user, $modelpdf) function set_pdf_model($user, $modelpdf)
{ {
if ($user->rights->commande->creer) if ($user->rights->commande->creer)
{ {
$sql = "UPDATE ".MAIN_DB_PREFIX."commande SET model_pdf = '$modelpdf'"; $sql = "UPDATE ".MAIN_DB_PREFIX."commande SET model_pdf = '$modelpdf'";
$sql .= " WHERE rowid = $this->id AND fk_statut < 2 ;"; $sql .= " WHERE rowid = $this->id AND fk_statut < 2 ;";
if ($this->db->query($sql) ) if ($this->db->query($sql) )
{ {
return 1; $this->modelpdf=$modelpdf;
} return 1;
else }
{ else
dolibarr_print_error($this->db); {
return 0; dolibarr_print_error($this->db);
} return 0;
} }
} }
}
/** /**
* \brief Reinitialise le tableau lignes * \brief Reinitialise le tableau lignes

View File

@ -1030,31 +1030,31 @@ class Facture extends CommonObject
} }
} }
/*
*
*
*
*/
function set_pdf_model($user, $modelpdf) /**
{ * \brief Positionne modele derniere generation
if ($user->rights->facture->creer) * \param user Objet use qui modifie
{ * \param modelpdf Nom du modele
*/
function set_pdf_model($user, $modelpdf)
{
if ($user->rights->facture->creer)
{
$sql = "UPDATE ".MAIN_DB_PREFIX."facture SET model_pdf = '$modelpdf'";
$sql .= " WHERE rowid = $this->id AND fk_statut < 2 ;";
$sql = "UPDATE ".MAIN_DB_PREFIX."facture SET model_pdf = '$modelpdf'"; if ($this->db->query($sql) )
$sql .= " WHERE rowid = $this->id AND fk_statut < 2 ;"; {
$this->modelpdf=$modelpdf;
if ($this->db->query($sql) ) return 1;
{ }
return 1; else
} {
else dolibarr_print_error($this->db);
{ return 0;
dolibarr_print_error($this->db); }
return 0; }
} }
}
}
/** /**
* \brief Ajoute un produit dans les tableaux products, products_qty, products_date_start|end * \brief Ajoute un produit dans les tableaux products, products_qty, products_date_start|end

View File

@ -780,29 +780,30 @@ class CommandeFournisseur extends Commande
} }
/** /**
* * \brief Positionne modele derniere generation
* * \param user Objet use qui modifie
* * \param modelpdf Nom du modele
*/ */
function set_pdf_model($user, $modelpdf) function set_pdf_model($user, $modelpdf)
{ {
if ($user->rights->fournisseur->commande->creer) if ($user->rights->fournisseur->commande->creer)
{ {
$sql = "UPDATE ".MAIN_DB_PREFIX."commande_fournisseur SET model_pdf = '$modelpdf'"; $sql = "UPDATE ".MAIN_DB_PREFIX."commande_fournisseur SET model_pdf = '$modelpdf'";
$sql .= " WHERE rowid = $this->id AND fk_statut = 0 ;"; $sql .= " WHERE rowid = $this->id AND fk_statut = 0 ;";
if ($this->db->query($sql) ) if ($this->db->query($sql) )
{ {
return 1; $this->modelpdf=$modelpdf;
} return 1;
else }
{ else
dolibarr_print_error($this->db); {
return 0; dolibarr_print_error($this->db);
} return 0;
} }
} }
}
/** /**