Qual: Uniformize code

Doc: Doxygen
This commit is contained in:
Laurent Destailleur 2010-08-18 07:28:12 +00:00
parent b7da077da6
commit fdc13a2480
4 changed files with 163 additions and 144 deletions

View File

@ -266,7 +266,7 @@ class Propal extends CommonObject
} }
/** /**
* \brief Add new line in database * Add a proposal line into database (linked to product/service or not)
* \param propalid Id de la propale * \param propalid Id de la propale
* \param desc Description de la ligne * \param desc Description de la ligne
* \param pu_ht Prix unitaire * \param pu_ht Prix unitaire
@ -279,8 +279,10 @@ class Propal extends CommonObject
* \param price_base_type HT or TTC * \param price_base_type HT or TTC
* \param pu_ttc Prix unitaire TTC * \param pu_ttc Prix unitaire TTC
* \param info_bits Bits de type de lignes * \param info_bits Bits de type de lignes
* \param type Type of line (product, service)
* \param rang Position of line
* \return int >0 if OK, <0 if KO * \return int >0 if OK, <0 if KO
* \see add_product * @see add_product
* \remarks Les parametres sont deja cense etre juste et avec valeurs finales a l'appel * \remarks Les parametres sont deja cense etre juste et avec valeurs finales a l'appel
* de cette methode. Aussi, pour le taux tva, il doit deja avoir ete defini * de cette methode. Aussi, pour le taux tva, il doit deja avoir ete defini
* par l'appelant par la methode get_default_tva(societe_vendeuse,societe_acheteuse,'',produit) * par l'appelant par la methode get_default_tva(societe_vendeuse,societe_acheteuse,'',produit)
@ -293,28 +295,35 @@ class Propal extends CommonObject
dol_syslog("Propal::Addline propalid=$propalid, desc=$desc, pu_ht=$pu_ht, qty=$qty, txtva=$txtva, fk_product=$fk_product, remise_except=$remise_percent, price_base_type=$price_base_type, pu_ttc=$pu_ttc, info_bits=$info_bits, type=$type"); dol_syslog("Propal::Addline propalid=$propalid, desc=$desc, pu_ht=$pu_ht, qty=$qty, txtva=$txtva, fk_product=$fk_product, remise_except=$remise_percent, price_base_type=$price_base_type, pu_ttc=$pu_ttc, info_bits=$info_bits, type=$type");
include_once(DOL_DOCUMENT_ROOT.'/lib/price.lib.php'); include_once(DOL_DOCUMENT_ROOT.'/lib/price.lib.php');
// Clean parameters
if (empty($remise_percent)) $remise_percent=0;
if (empty($qty)) $qty=0;
if (empty($info_bits)) $info_bits=0;
if (empty($rang)) $rang=0;
$remise_percent=price2num($remise_percent);
$qty=price2num($qty);
$pu_ht=price2num($pu_ht);
$pu_ttc=price2num($pu_ttc);
$txtva=price2num($txtva);
$txlocaltax1=price2num($txlocaltax1);
$txlocaltax2=price2num($txlocaltax2);
if ($price_base_type=='HT')
{
$pu=$pu_ht;
}
else
{
$pu=$pu_ttc;
}
// Check parameters
if ($type < 0) return -1;
if ($this->statut == 0) if ($this->statut == 0)
{ {
$this->db->begin(); $this->db->begin();
// Clean parameters
$remise_percent=price2num($remise_percent);
$qty=price2num($qty);
if (empty($qty)) $qty=0; // If qty=''
$pu_ht=price2num($pu_ht);
$pu_ttc=price2num($pu_ttc);
$txtva=price2num($txtva);
$txlocaltax1=price2num($txlocaltax1);
$txlocaltax2=price2num($txlocaltax2);
if ($price_base_type=='HT')
{
$pu=$pu_ht;
}
else
{
$pu=$pu_ttc;
}
// Calcul du total TTC et de la TVA pour la ligne a partir de // Calcul du total TTC et de la TVA pour la ligne a partir de
// qty, pu, remise_percent et txtva // qty, pu, remise_percent et txtva
// TRES IMPORTANT: C'est au moment de l'insertion ligne qu'on doit stocker // TRES IMPORTANT: C'est au moment de l'insertion ligne qu'on doit stocker
@ -423,29 +432,18 @@ class Propal extends CommonObject
dol_syslog("Propal::UpdateLine $rowid, $pu, $qty, $remise_percent, $txtva, $desc, $price_base_type, $info_bits"); dol_syslog("Propal::UpdateLine $rowid, $pu, $qty, $remise_percent, $txtva, $desc, $price_base_type, $info_bits");
include_once(DOL_DOCUMENT_ROOT.'/lib/price.lib.php'); include_once(DOL_DOCUMENT_ROOT.'/lib/price.lib.php');
// Clean parameters
$remise_percent=price2num($remise_percent);
$qty=price2num($qty);
$pu = price2num($pu);
$txtva = price2num($txtva);
$txlocaltax1=price2num($txlocaltax1);
$txlocaltax2=price2num($txlocaltax2);
if ($this->statut == 0) if ($this->statut == 0)
{ {
$this->db->begin(); $this->db->begin();
// Nettoyage param<61>tres
$remise_percent=price2num($remise_percent);
$qty=price2num($qty);
/*
if ($conf->global->PROPALE_USE_OPTION_LINE && !$qty)
{
$qty=0;
$remise_percent=0;
}
else if (! $qty)
{
$qty=1;
}
*/
$pu = price2num($pu);
$txtva = price2num($txtva);
$txlocaltax1=price2num($txlocaltax1);
$txlocaltax2=price2num($txlocaltax2);
// Calcul du total TTC et de la TVA pour la ligne a partir de // Calcul du total TTC et de la TVA pour la ligne a partir de
// qty, pu, remise_percent et txtva // qty, pu, remise_percent et txtva
// TRES IMPORTANT: C'est au moment de l'insertion ligne qu'on doit stocker // TRES IMPORTANT: C'est au moment de l'insertion ligne qu'on doit stocker
@ -502,7 +500,7 @@ class Propal extends CommonObject
// Fin appel triggers // Fin appel triggers
} }
$this->db->commit(); $this->db->commit();
return $result; return $result;
} }
else else
@ -1414,7 +1412,7 @@ class Propal extends CommonObject
* \param limit For pagination * \param limit For pagination
* \param offset For pagination * \param offset For pagination
* \param sortfield Sort criteria * \param sortfield Sort criteria
* \param sortorder Sort order * \param sortorder Sort order
* \return int -1 if KO, array with result if OK * \return int -1 if KO, array with result if OK
*/ */
function liste_array($shortlist=0, $draft=0, $notcurrentuser=0, $socid=0, $limit=0, $offset=0, $sortfield='p.datep', $sortorder='DESC') function liste_array($shortlist=0, $draft=0, $notcurrentuser=0, $socid=0, $limit=0, $offset=0, $sortfield='p.datep', $sortorder='DESC')
@ -1463,7 +1461,7 @@ class Propal extends CommonObject
} }
else else
{ {
dol_print_error($this->db); dol_print_error($this->db);
return -1; return -1;
} }
} }
@ -2260,19 +2258,23 @@ class PropaleLigne
*/ */
function insert() function insert()
{ {
global $conf; global $conf;
dol_syslog("PropaleLigne::insert rang=".$this->rang); dol_syslog("PropaleLigne::insert rang=".$this->rang);
$this->db->begin();
// Clean parameters // Clean parameters
if (! $this->remise) $this->remise=0;
if (! $this->remise_percent) $this->remise_percent=0;
if (! $this->info_bits) $this->info_bits=0;
if (empty($this->tva_tx)) $this->tva_tx=0; if (empty($this->tva_tx)) $this->tva_tx=0;
if (empty($this->localtax1_tx)) $this->localtax1_tx=0;
if (empty($this->localtax2_tx)) $this->localtax2_tx=0;
if (empty($this->rang)) $this->rang=0;
if (empty($this->remise)) $this->remise=0;
if (empty($this->remise_percent)) $this->remise_percent=0;
if (empty($this->info_bits)) $this->info_bits=0;
// Check parameters // Check parameters
if ($this->type < 0) return -1; if ($this->product_type < 0) return -1;
$this->db->begin();
// Insert line into database // Insert line into database
$sql = 'INSERT INTO '.MAIN_DB_PREFIX.'propaldet'; $sql = 'INSERT INTO '.MAIN_DB_PREFIX.'propaldet';

View File

@ -804,27 +804,28 @@ class Commande extends CommonObject
/** /**
* \brief Add a line * Add an order line into database (linked to product/service or not)
* \param commandeid Id de la commande * @param commandeid Id of line
* \param desc Description de la ligne * @param desc Description of line
* \param pu_ht Prix unitaire HT * @param pu_ht Unit price (without tax)
* \param qty Quantite * @param qty Quantite
* \param txtva Taux de tva force, sinon -1 * @param txtva Taux de tva force, sinon -1
* \param txlocaltax1 Local tax 1 rate * @param txlocaltax1 Local tax 1 rate
* \param txlocaltax2 Local tax 2 rate * @param txlocaltax2 Local tax 2 rate
* \param fk_product Id du produit/service predefini * @param fk_product Id du produit/service predefini
* \param remise_percent Pourcentage de remise de la ligne * @param remise_percent Pourcentage de remise de la ligne
* \param info_bits Bits de type de lignes * @param info_bits Bits de type de lignes
* \param fk_remise_except Id remise * @param fk_remise_except Id remise
* \param price_base_type HT or TTC * @param price_base_type HT or TTC
* \param pu_ttc Prix unitaire TTC * @param pu_ttc Prix unitaire TTC
* \param date_start Start date of the line - Added by Matelli (See http://matelli.fr/showcases/patchs-dolibarr/add-dates-in-order-lines.html) * @param date_start Start date of the line - Added by Matelli (See http://matelli.fr/showcases/patchs-dolibarr/add-dates-in-order-lines.html)
* \param date_end End date of the line - Added by Matelli (See http://matelli.fr/showcases/patchs-dolibarr/add-dates-in-order-lines.html) * @param date_end End date of the line - Added by Matelli (See http://matelli.fr/showcases/patchs-dolibarr/add-dates-in-order-lines.html)
* \param type Type of line (0=product, 1=service) * @param type Type of line (0=product, 1=service)
* \return int >0 si ok, <0 si ko * @param rang Position of line
* \see add_product * @return int >0 si ok, <0 si ko
* \remarks Les parametres sont deja cense etre juste et avec valeurs finales a l'appel * @see add_product
* de cette methode. Aussi, pour le taux tva, il doit deja avoir ete defini * @remarks Les parametres sont deja cense etre juste et avec valeurs finales a l'appel
* de cette methode. Aussi, pour le taux tva, il doit deja avoir ete defini
* par l'appelant par la methode get_default_tva(societe_vendeuse,societe_acheteuse,produit) * par l'appelant par la methode get_default_tva(societe_vendeuse,societe_acheteuse,produit)
* et le desc doit deja avoir la bonne valeur (a l'appelant de gerer le multilangue) * et le desc doit deja avoir la bonne valeur (a l'appelant de gerer le multilangue)
*/ */
@ -838,6 +839,7 @@ class Commande extends CommonObject
if (empty($remise_percent)) $remise_percent=0; if (empty($remise_percent)) $remise_percent=0;
if (empty($qty)) $qty=0; if (empty($qty)) $qty=0;
if (empty($info_bits)) $info_bits=0; if (empty($info_bits)) $info_bits=0;
if (empty($rang)) $rang=0;
$remise_percent=price2num($remise_percent); $remise_percent=price2num($remise_percent);
$qty=price2num($qty); $qty=price2num($qty);
@ -2624,8 +2626,15 @@ class OrderLine
if (empty($this->tva_tx)) $this->tva_tx=0; if (empty($this->tva_tx)) $this->tva_tx=0;
if (empty($this->localtax1_tx)) $this->localtax1_tx=0; if (empty($this->localtax1_tx)) $this->localtax1_tx=0;
if (empty($this->localtax2_tx)) $this->localtax2_tx=0; if (empty($this->localtax2_tx)) $this->localtax2_tx=0;
if (empty($this->rang)) $this->rang=0;
if (empty($this->remise)) $this->remise=0;
if (empty($this->remise_percent)) $this->remise_percent=0;
if (empty($this->info_bits)) $this->info_bits=0;
$this->db->begin(); // Check parameters
if ($this->product_type < 0) return -1;
$this->db->begin();
// Insertion dans base de la ligne // Insertion dans base de la ligne
$sql = 'INSERT INTO '.MAIN_DB_PREFIX.'commandedet'; $sql = 'INSERT INTO '.MAIN_DB_PREFIX.'commandedet';

View File

@ -1565,7 +1565,7 @@ class Facture extends CommonObject
/** /**
* \brief Add an invoice line into database (linked to product/service or not) * Add an invoice line into database (linked to product/service or not)
* \param facid Id de la facture * \param facid Id de la facture
* \param desc Description de la ligne * \param desc Description de la ligne
* \param pu_ht Prix unitaire HT * \param pu_ht Prix unitaire HT
@ -1583,6 +1583,7 @@ class Facture extends CommonObject
* \param price_base_type HT or TTC * \param price_base_type HT or TTC
* \param pu_ttc Prix unitaire TTC * \param pu_ttc Prix unitaire TTC
* \param type Type of line (0=product, 1=service) * \param type Type of line (0=product, 1=service)
* \param rang Position of line
* \return int >0 if OK, <0 if KO * \return int >0 if OK, <0 if KO
* \remarks Les parametres sont deja cense etre juste et avec valeurs finales a l'appel * \remarks Les parametres sont deja cense etre juste et avec valeurs finales a l'appel
* de cette methode. Aussi, pour le taux tva, il doit deja avoir ete defini * de cette methode. Aussi, pour le taux tva, il doit deja avoir ete defini
@ -1594,6 +1595,30 @@ class Facture extends CommonObject
dol_syslog("Facture::Addline facid=$facid,desc=$desc,pu_ht=$pu_ht,qty=$qty,txtva=$txtva, txlocaltax1=$txlocaltax1, txlocaltax2=$txlocaltax2, fk_product=$fk_product,remise_percent=$remise_percent,date_start=$date_start,date_end=$date_end,ventil=$ventil,info_bits=$info_bits,fk_remise_except=$fk_remise_except,price_base_type=$price_base_type,pu_ttc=$pu_ttc,type=$type", LOG_DEBUG); dol_syslog("Facture::Addline facid=$facid,desc=$desc,pu_ht=$pu_ht,qty=$qty,txtva=$txtva, txlocaltax1=$txlocaltax1, txlocaltax2=$txlocaltax2, fk_product=$fk_product,remise_percent=$remise_percent,date_start=$date_start,date_end=$date_end,ventil=$ventil,info_bits=$info_bits,fk_remise_except=$fk_remise_except,price_base_type=$price_base_type,pu_ttc=$pu_ttc,type=$type", LOG_DEBUG);
include_once(DOL_DOCUMENT_ROOT.'/lib/price.lib.php'); include_once(DOL_DOCUMENT_ROOT.'/lib/price.lib.php');
// Clean parameters
if (empty($remise_percent)) $remise_percent=0;
if (empty($qty)) $qty=0;
if (empty($info_bits)) $info_bits=0;
if (empty($rang)) $rang=0;
if (empty($ventil)) $ventil=0;
$remise_percent=price2num($remise_percent);
$qty=price2num($qty);
$pu_ht=price2num($pu_ht);
$pu_ttc=price2num($pu_ttc);
$txtva=price2num($txtva);
$txlocaltax1=price2num($txlocaltax1);
$txlocaltax2=price2num($txlocaltax2);
if ($price_base_type=='HT')
{
$pu=$pu_ht;
}
else
{
$pu=$pu_ttc;
}
// Check parameters // Check parameters
if ($type < 0) return -1; if ($type < 0) return -1;
@ -1601,28 +1626,6 @@ class Facture extends CommonObject
{ {
$this->db->begin(); $this->db->begin();
// Clean parameters
if (empty($remise_percent)) $remise_percent=0;
if (empty($qty)) $qty=0;
if (empty($ventil)) $ventil=0;
if (empty($info_bits)) $info_bits=0;
$remise_percent=price2num($remise_percent);
$qty=price2num($qty);
$pu_ht=price2num($pu_ht);
$pu_ttc=price2num($pu_ttc);
$txtva=price2num($txtva);
$txlocaltax1=price2num($txlocaltax1);
$txlocaltax2=price2num($txlocaltax2);
if ($price_base_type=='HT')
{
$pu=$pu_ht;
}
else
{
$pu=$pu_ttc;
}
// Calcul du total TTC et de la TVA pour la ligne a partir de // Calcul du total TTC et de la TVA pour la ligne a partir de
// qty, pu, remise_percent et txtva // qty, pu, remise_percent et txtva
// TRES IMPORTANT: C'est au moment de l'insertion ligne qu'on doit stocker // TRES IMPORTANT: C'est au moment de l'insertion ligne qu'on doit stocker
@ -2640,8 +2643,8 @@ class Facture extends CommonObject
$sql.= ' WHERE fk_facture = '.$this->id; $sql.= ' WHERE fk_facture = '.$this->id;
$sql.= ' AND traite = 0'; $sql.= ' AND traite = 0';
$resql=$this->db->query($sql); $resql=$this->db->query($sql);
if ($resql) if ($resql)
{ {
$row = $this->db->fetch_row($resql); $row = $this->db->fetch_row($resql);
if ($row[0] == 0) if ($row[0] == 0)
@ -3024,16 +3027,20 @@ class FactureLigne
dol_syslog("FactureLigne::Insert rang=".$this->rang, LOG_DEBUG); dol_syslog("FactureLigne::Insert rang=".$this->rang, LOG_DEBUG);
// Clean parameters // Clean parameters
$this->desc=trim($this->desc); $this->desc=trim($this->desc);
if (empty($this->subprice)) $this->subprice=0; if (empty($this->tva_tx)) $this->tva_tx=0;
if (empty($this->price)) $this->price=0; if (empty($this->localtax1_tx)) $this->localtax1_tx=0;
if (empty($this->tva_tx)) $this->tva_tx=0; if (empty($this->localtax2_tx)) $this->localtax2_tx=0;
if (empty($this->localtax1_tx)) $this->localtax1_tx=0; if (empty($this->rang)) $this->rang=0;
if (empty($this->localtax2_tx)) $this->localtax2_tx=0; if (empty($this->remise)) $this->remise=0;
if (empty($this->remise_percent)) $this->remise_percent=0;
if (empty($this->info_bits)) $this->info_bits=0;
if (empty($this->subprice)) $this->subprice=0;
if (empty($this->price)) $this->price=0;
// Check parameters // Check parameters
if ($this->product_type < 0) return -1; if ($this->product_type < 0) return -1;
$this->db->begin(); $this->db->begin();

View File

@ -802,7 +802,8 @@ class CommonObject
} }
/** /**
* \brief Get max value for rang * Get max value used for position of line (rang)
* @result int Max value of rang in table of lines
*/ */
function line_max() function line_max()
{ {