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 = "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 .= ", c.label as statut_label"; $sql .= " FROM ".MAIN_DB_PREFIX."propal";
$sql .= " FROM ".MAIN_DB_PREFIX."propal"; $sql .= "," . MAIN_DB_PREFIX."c_propalst as c";
$sql .= "," . MAIN_DB_PREFIX."c_propalst as c"; $sql .= " WHERE rowid=$rowid AND fk_statut = c.id";
$sql .= " WHERE rowid=$rowid AND fk_statut = c.id";
$resql=$this->db->query($sql);
if ($this->db->query($sql) ) if ($resql)
{ {
if ($this->db->num_rows()) if ($this->db->num_rows($resql))
{ {
$obj = $this->db->fetch_object(); $obj = $this->db->fetch_object($resql);
$this->id = $rowid; $this->id = $rowid;
$this->datep = $obj->dp;
$this->fin_validite = $obj->dfv; $this->datep = $obj->dp;
$this->date = $obj->dp; $this->fin_validite = $obj->dfv;
$this->ref = $obj->ref; $this->date = $obj->dp;
$this->price = $obj->price; $this->ref = $obj->ref;
$this->remise = $obj->remise; $this->price = $obj->price;
$this->remise_percent = $obj->remise_percent; $this->remise = $obj->remise;
$this->total = $obj->total; $this->remise_percent = $obj->remise_percent;
$this->total_ht = $obj->price; $this->total = $obj->total;
$this->total_tva = $obj->tva; $this->total_ht = $obj->price;
$this->total_ttc = $obj->total; $this->total_tva = $obj->tva;
$this->socidp = $obj->fk_soc; $this->total_ttc = $obj->total;
$this->soc_id = $obj->fk_soc; $this->socidp = $obj->fk_soc;
$this->projetidp = $obj->fk_projet; $this->soc_id = $obj->fk_soc;
$this->contactid = $obj->fk_soc_contact; $this->projetidp = $obj->fk_projet;
$this->modelpdf = $obj->model_pdf; $this->contactid = $obj->fk_soc_contact;
$this->note = $obj->note; $this->modelpdf = $obj->model_pdf;
$this->statut = $obj->fk_statut; $this->note = $obj->note;
$this->statut_libelle = $obj->statut_label; $this->statut = $obj->fk_statut;
$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->db->free(); $this->lignes = array();
$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 .= " FROM ".MAIN_DB_PREFIX."propaldet as d, ".MAIN_DB_PREFIX."product as p"; $sql = "SELECT p.rowid, p.label, p.description, p.ref, d.price, d.tva_tx, d.qty, d.remise_percent, d.subprice";
$sql .= " WHERE d.fk_propal = ".$this->id ." AND d.fk_product = p.rowid ORDER by d.rowid ASC"; $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";
$result = $this->db->query($sql);
if ($result) $result = $this->db->query($sql);
{ if ($result)
$num = $this->db->num_rows(); {
$i = 0; $num = $this->db->num_rows($result);
$i = 0;
while ($i < $num)
{ while ($i < $num)
$objp = $this->db->fetch_object(); {
$objp = $this->db->fetch_object($result);
$ligne = new PropaleLigne();
$ligne->libelle = stripslashes($objp->label); $ligne = new PropaleLigne();
$ligne->desc = stripslashes($objp->description); $ligne->libelle = stripslashes($objp->label);
$ligne->qty = $objp->qty; $ligne->desc = stripslashes($objp->description);
$ligne->ref = $objp->ref; $ligne->qty = $objp->qty;
$ligne->tva_tx = $objp->tva_tx; $ligne->ref = $objp->ref;
$ligne->subprice = $objp->subprice; $ligne->tva_tx = $objp->tva_tx;
$ligne->remise_percent = $objp->remise_percent; $ligne->subprice = $objp->subprice;
$ligne->price = $objp->price; $ligne->remise_percent = $objp->remise_percent;
$ligne->product_id = $objp->rowid; $ligne->price = $objp->price;
$ligne->product_id = $objp->rowid;
$this->lignes[$i] = $ligne;
$i++; $this->lignes[$i] = $ligne;
} $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
*/ /*
$sql = "SELECT d.qty, d.description, d.price, d.subprice, d.tva_tx, d.rowid, d.remise_percent"; * Lignes propales
$sql .= " FROM ".MAIN_DB_PREFIX."propaldet as d"; */
$sql .= " WHERE d.fk_propal = ".$this->id ." AND d.fk_product = 0"; $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";
$result = $this->db->query($sql); $sql .= " WHERE d.fk_propal = ".$this->id ." AND d.fk_product = 0";
if ($result)
{ $result = $this->db->query($sql);
$num = $this->db->num_rows(); if ($result)
$j = 0; {
$num = $this->db->num_rows($result);
while ($j < $num) $j = 0;
{
$objp = $this->db->fetch_object(); while ($j < $num)
$ligne = new PropaleLigne(); {
$ligne->libelle = stripslashes($objp->description); $objp = $this->db->fetch_object($result);
$ligne->desc = stripslashes($objp->description); $ligne = new PropaleLigne();
$ligne->qty = $objp->qty; $ligne->libelle = stripslashes($objp->description);
$ligne->ref = $objp->ref; $ligne->desc = stripslashes($objp->description);
$ligne->tva_tx = $objp->tva_tx; $ligne->qty = $objp->qty;
$ligne->subprice = $objp->subprice; $ligne->ref = $objp->ref;
$ligne->remise_percent = $objp->remise_percent; $ligne->tva_tx = $objp->tva_tx;
$ligne->price = $objp->price; $ligne->subprice = $objp->subprice;
$ligne->product_id = 0; $ligne->remise_percent = $objp->remise_percent;
$ligne->price = $objp->price;
$this->lignes[$i] = $ligne; $ligne->product_id = 0;
$i++;
$j++; $this->lignes[$i] = $ligne;
} $i++;
$j++;
$this->db->free(); }
}
else $this->db->free($result);
{ }
dolibarr_print_error($this->db); else
} {
} dolibarr_print_error($this->db);
return 1; return -1;
} }
else }
{ return 1;
dolibarr_print_error($this->db); }
return 0; else
} {
dolibarr_print_error($this->db);
return -1;
}
} }
/* /*