2
0
forked from Wavyzz/dolibarr

Qual: Uniformize code

This commit is contained in:
Juanjo Menent
2011-12-16 12:47:23 +01:00
parent 81535dc868
commit 83bef28418
2 changed files with 205 additions and 174 deletions

View File

@@ -112,13 +112,14 @@ class Commande extends CommonObject
$this->products = array();
}
/**
* \brief Renvoie la reference de commande suivante non utilisee en fonction du module
* de numerotation actif defini dans COMMANDE_ADDON
* \param soc objet societe
* \return string reference libre pour la commande
*/
/**
* Returns the reference to the following non used Order depending on the active numbering module
* defined into COMMANDE_ADDON
*
* @param Societe $soc Object thirdparty
* @return string Order free reference
*/
function getNextNumRef($soc)
{
global $db, $langs, $conf;
@@ -165,11 +166,11 @@ class Commande extends CommonObject
/**
* Validate order
* Validate order
*
* @param User $user User making status change
* @param int $idwarehouse Id of warehouse to use for stock decrease
* @return int <=0 if OK, >0 if KO
* @param User $user User making status change
* @param int $idwarehouse Id of warehouse to use for stock decrease
* @return int <=0 if OK, >0 if KO
*/
function valid($user, $idwarehouse=0)
{
@@ -393,10 +394,11 @@ class Commande extends CommonObject
/**
* Tag the order as validated (opened)
* Function used when order is reopend after being closed.
* @param user Object user that change status
* @return int <0 if KO, 0 if nothing is done, >0 if OK
* Tag the order as validated (opened)
* Function used when order is reopend after being closed.
*
* @param User $user Object user that change status
* @return int <0 if KO, 0 if nothing is done, >0 if OK
*/
function set_reopen($user)
{
@@ -447,8 +449,8 @@ class Commande extends CommonObject
/**
* Close order
*
* @param user Objet user that close
* @return int <0 if KO, >0 if OK
* @param User $user Objet user that close
* @return int <0 if KO, >0 if OK
*/
function cloture($user)
{
@@ -577,11 +579,12 @@ class Commande extends CommonObject
}
/**
* Create order
* Note that this->ref can be set or empty. If empty, we will use "(PROV)"
* @param user Objet user that make creation
* @param notrigger Disable all triggers
* @return int <0 if KO, >0 if OK
* Create order
* Note that this->ref can be set or empty. If empty, we will use "(PROV)"
*
* @param User $user Objet user that make creation
* @param int notrigger Disable all triggers
* @return int <0 if KO, >0 if OK
*/
function create($user, $notrigger=0)
{
@@ -767,11 +770,11 @@ class Commande extends CommonObject
/**
* Load an object from its id and create a new one in database
* Load an object from its id and create a new one in database
*
* @param int $socid Id of thirdparty
* @param HookManager $hookmanager Hook manager instance
* @return int New id of clone
* @param int $socid Id of thirdparty
* @param HookManager $hookmanager Hook manager instance
* @return int New id of clone
*/
function createFromClone($socid=0,$hookmanager=false)
{
@@ -940,30 +943,33 @@ class Commande extends CommonObject
/**
* Add an order line into database (linked to product/service or not)
* @param commandeid Id of line
* @param desc Description of line
* @param pu_ht Unit price (without tax)
* @param qty Quantite
* @param txtva Taux de tva force, sinon -1
* @param txlocaltax1 Local tax 1 rate
* @param txlocaltax2 Local tax 2 rate
* @param fk_product Id du produit/service predefini
* @param remise_percent Pourcentage de remise de la ligne
* @param info_bits Bits de type de lignes
* @param fk_remise_except Id remise
* @param price_base_type HT or 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_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 rang Position of line
* @return int >0 if OK, <0 if KO
* @see add_product
* 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)
* et le desc doit deja avoir la bonne valeur (a l'appelant de gerer le multilangue)
* Add an order line into database (linked to product/service or not)
*
* @param int $commandeid Id of line
* @param string $desc Description of line
* @param double $pu_ht Unit price (without tax)
* @param double $qty Quantite
* @param double $txtva Taux de tva force, sinon -1
* @param double $txlocaltax1 Local tax 1 rate
* @param double $txlocaltax2 Local tax 2 rate
* @param int $fk_product Id du produit/service predefini
* @param double $remise_percent Pourcentage de remise de la ligne
* @param int $info_bits Bits de type de lignes
* @param int $fk_remise_except Id remise
* @param string $price_base_type HT or TTC
* @param double $pu_ttc Prix unitaire TTC
* @param timestamp $date_start Start date of the line - Added by Matelli (See http://matelli.fr/showcases/patchs-dolibarr/add-dates-in-order-lines.html)
* @param timestamp $date_end End date of the line - Added by Matelli (See http://matelli.fr/showcases/patchs-dolibarr/add-dates-in-order-lines.html)
* @param int $type Type of line (0=product, 1=service)
* @param int $rang Position of line
* @return int >0 if OK, <0 if KO
*
* @see add_product
*
* 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)
* et le desc doit deja avoir la bonne valeur (a l'appelant de gerer le multilangue)
*/
function addline($commandeid, $desc, $pu_ht, $qty, $txtva, $txlocaltax1=0, $txlocaltax2=0, $fk_product=0, $remise_percent=0, $info_bits=0, $fk_remise_except=0, $price_base_type='HT', $pu_ttc=0, $date_start='', $date_end='', $type=0, $rang=-1, $special_code=0, $fk_parent_line=0)
{
@@ -1097,16 +1103,18 @@ class Commande extends CommonObject
/**
* Add line into array
* $this->client doit etre charge
* @param idproduct Id du produit a ajouter
* @param qty Quantite
* @param remise_percent Remise relative effectuee sur le produit
* @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)
* @return void
* TODO Remplacer les appels a cette fonction par generation objet Ligne
* insere dans tableau $this->products
* Add line into array
* $this->client must be loaded
*
* @param int $idproduct Product Id
* @param double $qty Quantity
* @param double $remise_percent Product discount relative
* @param timestamp $date_start Start date of the line - Added by Matelli (See http://matelli.fr/showcases/patchs-dolibarr/add-dates-in-order-lines.html)
* @param timestamp $date_end End date of the line - Added by Matelli (See http://matelli.fr/showcases/patchs-dolibarr/add-dates-in-order-lines.html)
* @return void
*
* TODO Remplacer les appels a cette fonction par generation objet Ligne
* insere dans tableau $this->products
*/
function add_product($idproduct, $qty, $remise_percent=0, $date_start='', $date_end='')
{
@@ -1175,11 +1183,12 @@ class Commande extends CommonObject
/**
* Get object and lines from database
* @param id Id of object to load
* @param ref Ref of object
* @param ref_ext External reference of object
* @param ref_int Internal reference of other object
* @return int >0 if OK, <0 if KO
*
* @param int $id Id of object to load
* @param string $ref Ref of object
* @param string $ref_ext External reference of object
* @param string $ref_int Internal reference of other object
* @return int >0 if OK, <0 if KO
*/
function fetch($id, $ref='', $ref_ext='', $ref_int='')
{
@@ -1306,9 +1315,10 @@ class Commande extends CommonObject
/**
* Ajout d'une ligne remise fixe dans la commande, en base
* @param idremise Id de la remise fixe
* @return int >0 si ok, <0 si ko
* Adding line of fixed discount in the order in DB
*
* @param int $idremise Id de la remise fixe
* @return int >0 si ok, <0 si ko
*/
function insert_discount($idremise)
{
@@ -1381,9 +1391,10 @@ class Commande extends CommonObject
/**
* Load array lines
* @param only_product Return only physical products
* @return int <0 if KO, >0 if OK
* Load array lines
*
* @param int $only_product Return only physical products
* @return int <0 if KO, >0 if OK
*/
function fetch_lines($only_product=0)
{
@@ -1467,8 +1478,9 @@ class Commande extends CommonObject
/**
* Return number of line with type product.
* @return int <0 if KO, Nbr of product lines if OK
* Return number of line with type product.
*
* @return int <0 if KO, Nbr of product lines if OK
*/
function getNbOfProductsLines()
{
@@ -1481,10 +1493,12 @@ class Commande extends CommonObject
}
/**
* Load array this->expeditions of nb of products sent by line in order
* @param filtre_statut Filter on status
* @return int <0 if KO, Nb of lines found if OK
* TODO deprecated, move to Shipping class
* Load array this->expeditions of nb of products sent by line in order
*
* @param int $filtre_statut Filter on status
* @return int <0 if KO, Nb of lines found if OK
*
* TODO deprecated, move to Shipping class
*/
function loadExpeditions($filtre_statut=-1)
{
@@ -1529,7 +1543,8 @@ class Commande extends CommonObject
}
/**
* Renvoie un tableau avec nombre de lignes d'expeditions
* Returns a array with expeditions lines number
*
* TODO deprecated, move to Shipping class
*/
function nb_expedition()
@@ -1551,10 +1566,12 @@ class Commande extends CommonObject
}
/**
* Renvoie un tableau avec les livraisons par ligne
* @param filtre_statut Filtre sur statut
* @return int 0 si OK, <0 si KO
* TODO deprecated, move to Shipping class
* Return a array with sendings by line
*
* @param int $filtre_statut Filtre sur statut
* @return int 0 si OK, <0 si KO
*
* TODO deprecated, move to Shipping class
*/
function livraison_array($filtre_statut=-1)
{
@@ -1564,10 +1581,12 @@ class Commande extends CommonObject
}
/**
* Renvoie un tableau avec les stocks restant par produit
* @param filtre_statut Filtre sur statut
* @return int 0 si OK, <0 si KO
* TODO FONCTION NON FINIE A FINIR
* Return a array with the pending stock by product
*
* @param int $filtre_statut Filtre sur statut
* @return int 0 si OK, <0 si KO
*
* TODO FONCTION NON FINIE A FINIR
*/
function stock_array($filtre_statut=-1)
{
@@ -1603,8 +1622,9 @@ class Commande extends CommonObject
/**
* Delete an order line
* @param lineid Id of line to delete
* @return int >0 if OK, 0 if nothing to do, <0 if KO
*
* @param int $lineid Id of line to delete
* @return int >0 if OK, 0 if nothing to do, <0 if KO
*/
function deleteline($lineid)
{
@@ -1747,11 +1767,11 @@ class Commande extends CommonObject
/**
* Set the order date
* Set the order date
*
* @param user Object user making change
* @param date Date
* @return int <0 if KO, >0 if OK
* @param User $user Object user making change
* @param timestamp $date Date
* @return int <0 if KO, >0 if OK
*/
function set_date($user, $date)
{
@@ -1782,11 +1802,11 @@ class Commande extends CommonObject
}
/**
* Set the planned delivery date
* Set the planned delivery date
*
* @param user Objet utilisateur qui modifie
* @param date_livraison Date de livraison
* @return int <0 si ko, >0 si ok
* @param User $user Objet utilisateur qui modifie
* @param timestamp $date_livraison Date de livraison
* @return int <0 si ko, >0 si ok
*/
function set_date_livraison($user, $date_livraison)
{
@@ -1817,11 +1837,11 @@ class Commande extends CommonObject
}
/**
* Set address
* Set address
*
* @param user Object user making change
* @param fk_address Adress of delivery
* @return int <0 ig KO, >0 if Ok
* @param User $user Object user making change
* @param int $fk_address Adress of delivery
* @return int <0 ig KO, >0 if Ok
*/
function set_adresse_livraison($user, $fk_address)
{
@@ -1845,11 +1865,11 @@ class Commande extends CommonObject
}
/**
* Set availability
* Set availability
*
* @param user Object user making change
* @param id If of availability delay
* @return int <0 if KO, >0 if OK
* @param User $user Object user making change
* @param int $id If of availability delay
* @return int <0 if KO, >0 if OK
*/
function set_availability($user, $id)
{
@@ -1874,11 +1894,11 @@ class Commande extends CommonObject
}
/**
* Set source of demand
* Set source of demand
*
* @param user Object user making change
* @param id Id of source
* @return int <0 if KO, >0 if OK
* @param User $user Object user making change
* @param int $id Id of source
* @return int <0 if KO, >0 if OK
*/
function set_demand_reason($user, $id)
{
@@ -1905,9 +1925,9 @@ class Commande extends CommonObject
/**
* Return list of orders (eventuelly filtered on a user) into an array
*
* @param brouillon 0=non brouillon, 1=brouillon
* @param user Objet user de filtre
* @return int -1 if KO, array with result if OK
* @param int $brouillon 0=non brouillon, 1=brouillon
* @param User $user Objet user de filtre
* @return int -1 if KO, array with result if OK
*/
function liste_array($brouillon=0, $user='')
{
@@ -1948,10 +1968,10 @@ class Commande extends CommonObject
}
/**
* Change les conditions de reglement de la commande
* Change les conditions de reglement de la commande
*
* @param cond_reglement_id Id de la nouvelle condition de reglement
* @return int >0 if OK, <0 if KO
* @param int $cond_reglement_id Id de la nouvelle condition de reglement
* @return int >0 if OK, <0 if KO
*/
function cond_reglement($cond_reglement_id)
{
@@ -1985,8 +2005,8 @@ class Commande extends CommonObject
/**
* Change le mode de reglement
*
* @param mode Id du nouveau mode
* @return int >0 si ok, <0 si ko
* @param int $mode Id du nouveau mode
* @return int >0 si ok, <0 si ko
*/
function mode_reglement($mode_reglement_id)
{
@@ -2017,9 +2037,10 @@ class Commande extends CommonObject
}
/**
* Change le delai de livraison
* @param availability_id Id du nouveau mode
* @return int >0 if OK, <0 if KO
* Change le delai de livraison
*
* @param int $availability_id Id du nouveau mode
* @return int >0 if OK, <0 if KO
*/
function availability($availability_id)
{
@@ -2050,9 +2071,10 @@ class Commande extends CommonObject
}
/**
* \brief Change la source de la demande
* \param mode Id du nouveau mode
* \return int >0 si ok, <0 si ko
* Change la source de la demande
*
* @param int $demand_reason_id Id of new demand
* @return int >0 if ok, <0 if ko
*/
function demand_reason($demand_reason_id)
{
@@ -2083,10 +2105,10 @@ class Commande extends CommonObject
}
/**
* \brief Set customer ref
* \param user User that make change
* \param ref_client Customer ref
* \return int <0 if KO, >0 if OK
* Set customer ref
* @param User $user User that make change
* @param string $ref_client Customer ref
* @return int <0 if KO, >0 if OK
*/
function set_ref_client($user, $ref_client)
{
@@ -2118,8 +2140,9 @@ class Commande extends CommonObject
/**
* \brief Classe la commande comme facturee
* \return int <0 si ko, >0 si ok
* Classify the order as invoiced
*
* @return int <0 if ko, >0 if ok
*/
function classer_facturee()
{
@@ -2148,20 +2171,20 @@ class Commande extends CommonObject
/**
* Update a line in database
*
* @param rowid Id of line to update
* @param desc Description de la ligne
* @param pu Prix unitaire
* @param qty Quantity
* @param remise_percent Pourcentage de remise de la ligne
* @param tva_tx Taux TVA
* @param txlocaltax1 Local tax 1 rate
* @param txlocaltax2 Local tax 2 rate
* @param price_base_type HT or TTC
* @param info_bits Miscellaneous informations on line
* @param date_start Start date of the line
* @param date_end End date of the line
* @param type Type of line (0=product, 1=service)
* @return int < 0 if KO, > 0 if OK
* @param int $rowid Id of line to update
* @param string $desc Description de la ligne
* @param double $pu Prix unitaire
* @param double $qty Quantity
* @param double $remise_percent Pourcentage de remise de la ligne
* @param double $tva_tx Taux TVA
* @param double $txlocaltax1 Local tax 1 rate
* @param double $txlocaltax2 Local tax 2 rate
* @param string $price_base_type HT or TTC
* @param int $info_bits Miscellaneous informations on line
* @param timestamp $date_start Start date of the line
* @param timestamp $date_end End date of the line
* @param int $type Type of line (0=product, 1=service)
* @return int < 0 if KO, > 0 if OK
*/
function updateline($rowid, $desc, $pu, $qty, $remise_percent=0, $txtva, $txlocaltax1=0,$txlocaltax2=0, $price_base_type='HT', $info_bits=0, $date_start='', $date_end='', $type=0, $fk_parent_line=0, $skip_update_total=0)
{
@@ -2379,10 +2402,10 @@ class Commande extends CommonObject
/**
* Load indicators for dashboard (this->nbtodo and this->nbtodolate)
* Load indicators for dashboard (this->nbtodo and this->nbtodolate)
*
* @param user Objet user
* @return int <0 if KO, >0 if OK
* @param User $user Object user
* @return int <0 if KO, >0 if OK
*/
function load_board($user)
{
@@ -2423,8 +2446,9 @@ class Commande extends CommonObject
}
/**
* \brief Return source label of order
* \return string Label
* Return source label of order
*
* @return string Label
*/
function getLabelSource()
{
@@ -2437,9 +2461,10 @@ class Commande extends CommonObject
}
/**
* \brief Retourne le libelle du statut de la commande
* \param mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long, 5=Libelle court + Picto
* \return string Libelle
* Return status label of Order
*
* @param int $mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long, 5=Libelle court + Picto
* @return string Libelle
*/
function getLibStatut($mode)
{
@@ -2447,11 +2472,12 @@ class Commande extends CommonObject
}
/**
* Renvoi le libelle d'un statut donne
* @param statut Id statut
* @param facturee Si facturee
* @param mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long, 5=Libelle court + Picto
* @return string Label of status
* Return label of status
*
* @param int $statut Id statut
* @param int $facturee if invoiced
* @param int $mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long, 5=Libelle court + Picto
* @return string Label of status
*/
function LibStatut($statut,$facturee,$mode)
{
@@ -2515,12 +2541,13 @@ class Commande extends CommonObject
/**
* Return clicable link of object (with eventually picto)
* @param withpicto Add picto into link
* @param option Where point the link
* @param max Max length to show
* @param short Use short labels
* @return string String with URL
* Return clicable link of object (with eventually picto)
*
* @param int $withpicto Add picto into link
* @param int $option Where point the link
* @param int $max Max length to show
* @param int $short Use short labels
* @return string String with URL
*/
function getNomUrl($withpicto=0,$option=0,$max=0,$short=0)
{
@@ -2547,8 +2574,9 @@ class Commande extends CommonObject
/**
* \brief Charge les informations d'ordre info dans l'objet commande
* \param id Id de la commande a charger
* Charge les informations d'ordre info dans l'objet commande
*
* @param int $id Id of order
*/
function info($id)
{
@@ -2687,9 +2715,9 @@ class Commande extends CommonObject
/**
* Charge indicateurs this->nb de tableau de bord
* Charge indicateurs this->nb de tableau de bord
*
* @return int <0 si ko, >0 si ok
* @return int <0 si ko, >0 si ok
*/
function load_state_board()
{
@@ -2728,6 +2756,8 @@ class Commande extends CommonObject
/**
* Return an array of order lines
*
* @return array Lines of order
*/
function getLinesArray()
{
@@ -2851,7 +2881,7 @@ class OrderLine
/**
* Constructor
*
* @param DB handler d'acces base de donnee
* @param DoliDB $DB handler d'acces base de donnee
*/
function OrderLine($DB)
{
@@ -2955,10 +2985,10 @@ class OrderLine
}
/**
* Insert line into database
* Insert line into database
*
* @param notrigger 1 = disable triggers
* @return int <0 if KO, >0 if OK
* @param int $notrigger 1 = disable triggers
* @return int <0 if KO, >0 if OK
*/
function insert($notrigger=0)
{
@@ -3055,9 +3085,10 @@ class OrderLine
}
/**
* Mise a jour de l'objet ligne de commande en base
* Update the line object into db
*
* @return int <0 si ko, >0 si ok
* @param int $notrigger 1 = disable triggers
* @return int <0 si ko, >0 si ok
*/
function update($notrigger=0)
{
@@ -3137,9 +3168,9 @@ class OrderLine
}
/**
* Mise a jour de l'objet ligne de commande en base
* Update totals of order into database
*
* @return int <0 si ko, >0 si ok
* @return int <0 if ko, >0 if ok
*/
function update_total()
{