Fix: Corrige pb envoi propal par mail.

This commit is contained in:
Laurent Destailleur 2005-06-25 13:38:28 +00:00
parent 47ae0fffb9
commit 3acef1fd50
2 changed files with 136 additions and 133 deletions

View File

@ -214,6 +214,7 @@ class FormMail
if ($this->param["models"]=='body') { $defaultmessage=$this->withbody; } if ($this->param["models"]=='body') { $defaultmessage=$this->withbody; }
if ($this->param["models"]=='facture_send') { $defaultmessage="Veuillez trouver ci-joint la facture __FACREF__\n\nCordialement\n\n"; } if ($this->param["models"]=='facture_send') { $defaultmessage="Veuillez trouver ci-joint la facture __FACREF__\n\nCordialement\n\n"; }
if ($this->param["models"]=='facture_relance') { $defaultmessage="Nous apportons à votre connaissance que la facture __FACREF__ ne semble pas avoir été réglée. La voici donc, pour rappel, en pièce jointe.\n\nCordialement\n\n"; } if ($this->param["models"]=='facture_relance') { $defaultmessage="Nous apportons à votre connaissance que la facture __FACREF__ ne semble pas avoir été réglée. La voici donc, pour rappel, en pièce jointe.\n\nCordialement\n\n"; }
if ($this->param["models"]=='propal_send') { $defaultmessage="Veuillez trouver ci-joint la proposition commercial __PROPREF__\n\nCordialement\n\n"; }
$defaultmessage=$this->make_substitutions($defaultmessage); $defaultmessage=$this->make_substitutions($defaultmessage);

View File

@ -354,140 +354,142 @@ class Propal
* \brief Recupère de la base les caractéristiques d'une propale * \brief Recupère de la base les caractéristiques d'une propale
* \param rowid id de la propal à récupérer * \param rowid id de la propal à récupérer
*/ */
function fetch($rowid)
function fetch($rowid)
{ {
$sql = "SELECT ref,total,price,remise,tva,fk_soc,fk_soc_contact,".$this->db->pdate("datep")."as dp,".$this->db->pdate("fin_validite")."as dfv, model_pdf, note, fk_projet, fk_statut, remise_percent, fk_user_author";
$sql .= ", c.label as statut_label";
$sql .= " FROM ".MAIN_DB_PREFIX."propal";
$sql .= "," . MAIN_DB_PREFIX."c_propalst as c";
$sql .= " WHERE rowid=$rowid AND fk_statut = c.id";
$sql = "SELECT ref,total,price,remise,tva,fk_soc,fk_soc_contact,".$this->db->pdate("datep")."as dp,".$this->db->pdate("fin_validite")."as dfv, model_pdf, note, fk_projet, fk_statut, remise_percent, fk_user_author"; $resql=$this->db->query($sql);
$sql .= ", c.label as statut_label"; if ($resql)
$sql .= " FROM ".MAIN_DB_PREFIX."propal"; {
$sql .= "," . MAIN_DB_PREFIX."c_propalst as c"; if ($this->db->num_rows($resql))
$sql .= " WHERE rowid=$rowid AND fk_statut = c.id"; {
$obj = $this->db->fetch_object($resql);
if ($this->db->query($sql) ) $this->id = $rowid;
{
if ($this->db->num_rows())
{
$obj = $this->db->fetch_object();
$this->id = $rowid; $this->datep = $obj->dp;
$this->datep = $obj->dp; $this->fin_validite = $obj->dfv;
$this->fin_validite = $obj->dfv; $this->date = $obj->dp;
$this->date = $obj->dp; $this->ref = $obj->ref;
$this->ref = $obj->ref; $this->price = $obj->price;
$this->price = $obj->price; $this->remise = $obj->remise;
$this->remise = $obj->remise; $this->remise_percent = $obj->remise_percent;
$this->remise_percent = $obj->remise_percent; $this->total = $obj->total;
$this->total = $obj->total; $this->total_ht = $obj->price;
$this->total_ht = $obj->price; $this->total_tva = $obj->tva;
$this->total_tva = $obj->tva; $this->total_ttc = $obj->total;
$this->total_ttc = $obj->total; $this->socidp = $obj->fk_soc;
$this->socidp = $obj->fk_soc; $this->soc_id = $obj->fk_soc;
$this->soc_id = $obj->fk_soc; $this->projetidp = $obj->fk_projet;
$this->projetidp = $obj->fk_projet; $this->contactid = $obj->fk_soc_contact;
$this->contactid = $obj->fk_soc_contact; $this->modelpdf = $obj->model_pdf;
$this->modelpdf = $obj->model_pdf; $this->note = $obj->note;
$this->note = $obj->note; $this->statut = $obj->fk_statut;
$this->statut = $obj->fk_statut; $this->statut_libelle = $obj->statut_label;
$this->statut_libelle = $obj->statut_label;
$this->user_author_id = $obj->fk_user_author; $this->user_author_id = $obj->fk_user_author;
if ($obj->fk_statut == 0) if ($obj->fk_statut == 0)
{ {
$this->brouillon = 1; $this->brouillon = 1;
} }
$this->lignes = array(); $this->lignes = array();
$this->db->free(); $this->db->free();
$this->ref_url = '<a href="'.DOL_URL_ROOT.'/comm/propal.php?propalid='.$this->id.'">'.$this->ref.'</a>'; $this->ref_url = '<a href="'.DOL_URL_ROOT.'/comm/propal.php?propalid='.$this->id.'">'.$this->ref.'</a>';
/* /*
* Lignes produits * Lignes produits
*/ */
$sql = "SELECT p.rowid, p.label, p.description, p.ref, d.price, d.tva_tx, d.qty, d.remise_percent, d.subprice"; $sql = "SELECT p.rowid, p.label, p.description, p.ref, d.price, d.tva_tx, d.qty, d.remise_percent, d.subprice";
$sql .= " FROM ".MAIN_DB_PREFIX."propaldet as d, ".MAIN_DB_PREFIX."product as p"; $sql .= " FROM ".MAIN_DB_PREFIX."propaldet as d, ".MAIN_DB_PREFIX."product as p";
$sql .= " WHERE d.fk_propal = ".$this->id ." AND d.fk_product = p.rowid ORDER by d.rowid ASC"; $sql .= " WHERE d.fk_propal = ".$this->id ." AND d.fk_product = p.rowid ORDER by d.rowid ASC";
$result = $this->db->query($sql); $result = $this->db->query($sql);
if ($result) if ($result)
{ {
$num = $this->db->num_rows(); $num = $this->db->num_rows($result);
$i = 0; $i = 0;
while ($i < $num) while ($i < $num)
{ {
$objp = $this->db->fetch_object(); $objp = $this->db->fetch_object($result);
$ligne = new PropaleLigne(); $ligne = new PropaleLigne();
$ligne->libelle = stripslashes($objp->label); $ligne->libelle = stripslashes($objp->label);
$ligne->desc = stripslashes($objp->description); $ligne->desc = stripslashes($objp->description);
$ligne->qty = $objp->qty; $ligne->qty = $objp->qty;
$ligne->ref = $objp->ref; $ligne->ref = $objp->ref;
$ligne->tva_tx = $objp->tva_tx; $ligne->tva_tx = $objp->tva_tx;
$ligne->subprice = $objp->subprice; $ligne->subprice = $objp->subprice;
$ligne->remise_percent = $objp->remise_percent; $ligne->remise_percent = $objp->remise_percent;
$ligne->price = $objp->price; $ligne->price = $objp->price;
$ligne->product_id = $objp->rowid; $ligne->product_id = $objp->rowid;
$this->lignes[$i] = $ligne; $this->lignes[$i] = $ligne;
$i++; $i++;
} }
$this->db->free(); $this->db->free($result);
} }
else else
{ {
dolibarr_print_error($this->db); dolibarr_print_error($this->db);
} return -1;
}
/* /*
* Lignes génériques * Lignes propales
*/ */
$sql = "SELECT d.qty, d.description, d.price, d.subprice, d.tva_tx, d.rowid, d.remise_percent"; $sql = "SELECT d.qty, d.description, d.price, d.subprice, d.tva_tx, d.rowid, d.remise_percent";
$sql .= " FROM ".MAIN_DB_PREFIX."propaldet as d"; $sql .= " FROM ".MAIN_DB_PREFIX."propaldet as d";
$sql .= " WHERE d.fk_propal = ".$this->id ." AND d.fk_product = 0"; $sql .= " WHERE d.fk_propal = ".$this->id ." AND d.fk_product = 0";
$result = $this->db->query($sql); $result = $this->db->query($sql);
if ($result) if ($result)
{ {
$num = $this->db->num_rows(); $num = $this->db->num_rows($result);
$j = 0; $j = 0;
while ($j < $num) while ($j < $num)
{ {
$objp = $this->db->fetch_object(); $objp = $this->db->fetch_object($result);
$ligne = new PropaleLigne(); $ligne = new PropaleLigne();
$ligne->libelle = stripslashes($objp->description); $ligne->libelle = stripslashes($objp->description);
$ligne->desc = stripslashes($objp->description); $ligne->desc = stripslashes($objp->description);
$ligne->qty = $objp->qty; $ligne->qty = $objp->qty;
$ligne->ref = $objp->ref; $ligne->ref = $objp->ref;
$ligne->tva_tx = $objp->tva_tx; $ligne->tva_tx = $objp->tva_tx;
$ligne->subprice = $objp->subprice; $ligne->subprice = $objp->subprice;
$ligne->remise_percent = $objp->remise_percent; $ligne->remise_percent = $objp->remise_percent;
$ligne->price = $objp->price; $ligne->price = $objp->price;
$ligne->product_id = 0; $ligne->product_id = 0;
$this->lignes[$i] = $ligne; $this->lignes[$i] = $ligne;
$i++; $i++;
$j++; $j++;
} }
$this->db->free(); $this->db->free($result);
} }
else else
{ {
dolibarr_print_error($this->db); dolibarr_print_error($this->db);
} return -1;
} }
return 1; }
} return 1;
else }
{ else
dolibarr_print_error($this->db); {
return 0; dolibarr_print_error($this->db);
} return -1;
}
} }
/* /*