Meilleure gestion erreur sur propales

This commit is contained in:
Laurent Destailleur 2005-09-04 13:10:43 +00:00
parent 96db11b011
commit e34a5b3da9

View File

@ -156,14 +156,20 @@ class Propal
} }
else else
{ {
$this->error=$this->db->error();
return -1; return -1;
} }
} }
else else
{ {
$this->error=$this->db->error();
return -2; return -2;
} }
} }
else
{
return -3;
}
} }
@ -285,16 +291,16 @@ class Propal
$this->client = $client; $this->client = $client;
} }
/* /**
* * \brief Supprime une ligne de detail
* * \param idligne Id de la ligne detail à supprimer
* \return int >0 si ok, <0 si ko
*/ */
function delete_product($idligne) function delete_product($idligne)
{ {
if ($this->statut == 0) if ($this->statut == 0)
{ {
$sql = "DELETE FROM ".MAIN_DB_PREFIX."propaldet WHERE rowid = $idligne"; $sql = "DELETE FROM ".MAIN_DB_PREFIX."propaldet WHERE rowid = ".$idligne;
if ($this->db->query($sql) ) if ($this->db->query($sql) )
{ {
@ -304,9 +310,13 @@ class Propal
} }
else else
{ {
return 0; return -1;
} }
} }
else
{
return -2;
}
} }
/** /**
@ -351,10 +361,13 @@ class Propal
$this->products_qty[$i], $this->products_qty[$i],
$this->products_remise_percent[$i]); $this->products_remise_percent[$i]);
} }
/* /*
* *
*/ */
$this->update_price(); $this->update_price();
/* /*
* Affectation au projet * Affectation au projet
*/ */
@ -381,10 +394,8 @@ class Propal
/** /**
* \brief Mets à jour le prix total de la proposition * \brief Mets à jour le prix total de la proposition
* * \return int <0 si ko, >0 si ok
*
*/ */
function update_price() function update_price()
{ {
include_once DOL_DOCUMENT_ROOT . "/lib/price.lib.php"; include_once DOL_DOCUMENT_ROOT . "/lib/price.lib.php";
@ -413,9 +424,8 @@ class Propal
$this->total_ht = $calculs[0]; $this->total_ht = $calculs[0];
$this->total_tva = $calculs[1]; $this->total_tva = $calculs[1];
$this->total_ttc = $calculs[2]; $this->total_ttc = $calculs[2];
/*
* // Met a jour en base
*/
$sql = "UPDATE ".MAIN_DB_PREFIX."propal SET"; $sql = "UPDATE ".MAIN_DB_PREFIX."propal SET";
$sql .= " price='". ereg_replace(",",".",$this->total_ht)."'"; $sql .= " price='". ereg_replace(",",".",$this->total_ht)."'";
$sql .= ", tva='". ereg_replace(",",".",$this->total_tva)."'"; $sql .= ", tva='". ereg_replace(",",".",$this->total_tva)."'";
@ -429,13 +439,13 @@ class Propal
} }
else else
{ {
print "Erreur mise à jour du prix<p>".$sql; $this->error=$this->db->error();
return -1; return -1;
} }
} }
/* /**
* \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
*/ */
@ -586,12 +596,11 @@ class Propal
} }
} }
/* /*
*
* *
* *
*/ */
function valid($user) function valid($user)
{ {
if ($user->rights->propale->valider) if ($user->rights->propale->valider)