This commit is contained in:
Laurent Destailleur 2011-07-04 09:36:29 +00:00
parent aad939a270
commit 7936cd8dea
7 changed files with 399 additions and 378 deletions

View File

@ -23,7 +23,7 @@
* \file htdocs/comm/action/class/actioncomm.class.php * \file htdocs/comm/action/class/actioncomm.class.php
* \ingroup commercial * \ingroup commercial
* \brief File of class to manage agenda events (actions) * \brief File of class to manage agenda events (actions)
* \version $Id: actioncomm.class.php,v 1.41 2011/06/30 07:52:43 eldy Exp $ * \version $Id: actioncomm.class.php,v 1.42 2011/07/04 09:36:29 eldy Exp $
*/ */
require_once(DOL_DOCUMENT_ROOT.'/comm/action/class/cactioncomm.class.php'); require_once(DOL_DOCUMENT_ROOT.'/comm/action/class/cactioncomm.class.php');
require_once(DOL_DOCUMENT_ROOT.'/core/class/commonobject.class.php'); require_once(DOL_DOCUMENT_ROOT.'/core/class/commonobject.class.php');
@ -391,8 +391,10 @@ class ActionComm extends CommonObject
/** /**
* Load all objects with filters * Load all objects with filters
* @param socid Filter by thirdparty * @param socid Filter by thirdparty
* @param filter Other filter * @param fk_element Id of element action is linked to
* @param elementtype Type of element action is linked to
* @param filter Other filter
*/ */
function getActions($socid=0, $fk_element=0, $elementtype='', $filter='') function getActions($socid=0, $fk_element=0, $elementtype='', $filter='')
{ {
@ -603,7 +605,7 @@ class ActionComm extends CommonObject
* Utilise $this->id, $this->code et $this->label * Utilise $this->id, $this->code et $this->label
* @param withpicto 0=Pas de picto, 1=Inclut le picto dans le lien, 2=Picto seul * @param withpicto 0=Pas de picto, 1=Inclut le picto dans le lien, 2=Picto seul
* @param maxlength Nombre de caracteres max dans libelle * @param maxlength Nombre de caracteres max dans libelle
* @param class Force style class on a link * @param classname Force style class on a link
* @param option ''=Link to action,'birthday'=Link to contact * @param option ''=Link to action,'birthday'=Link to contact
* @return string Chaine avec URL * @return string Chaine avec URL
*/ */

View File

@ -25,7 +25,7 @@
* \file htdocs/commande/class/commande.class.php * \file htdocs/commande/class/commande.class.php
* \ingroup commande * \ingroup commande
* \brief Fichier des classes de commandes * \brief Fichier des classes de commandes
* \version $Id: commande.class.php,v 1.116 2011/06/30 13:27:20 hregis Exp $ * \version $Id: commande.class.php,v 1.117 2011/07/04 09:36:29 eldy Exp $
*/ */
require_once(DOL_DOCUMENT_ROOT."/core/class/commonobject.class.php"); require_once(DOL_DOCUMENT_ROOT."/core/class/commonobject.class.php");
require_once(DOL_DOCUMENT_ROOT."/product/class/product.class.php"); require_once(DOL_DOCUMENT_ROOT."/product/class/product.class.php");
@ -177,7 +177,7 @@ class Commande extends CommonObject
function valid($user) function valid($user)
{ {
global $conf,$langs; global $conf,$langs;
require_once(DOL_DOCUMENT_ROOT."/lib/files.lib.php"); require_once(DOL_DOCUMENT_ROOT."/lib/files.lib.php");
$error=0; $error=0;
@ -239,7 +239,7 @@ class Commande extends CommonObject
if ($result >= 0 && $conf->stock->enabled && $conf->global->STOCK_CALCULATE_ON_VALIDATE_ORDER == 1) if ($result >= 0 && $conf->stock->enabled && $conf->global->STOCK_CALCULATE_ON_VALIDATE_ORDER == 1)
{ {
require_once(DOL_DOCUMENT_ROOT."/product/stock/class/mouvementstock.class.php"); require_once(DOL_DOCUMENT_ROOT."/product/stock/class/mouvementstock.class.php");
$langs->load("agenda"); $langs->load("agenda");
// Loop on each line // Loop on each line
for ($i = 0 ; $i < sizeof($this->lines) ; $i++) for ($i = 0 ; $i < sizeof($this->lines) ; $i++)
@ -347,7 +347,7 @@ class Commande extends CommonObject
if ($conf->stock->enabled && $conf->global->STOCK_CALCULATE_ON_VALIDATE_ORDER == 1) if ($conf->stock->enabled && $conf->global->STOCK_CALCULATE_ON_VALIDATE_ORDER == 1)
{ {
require_once(DOL_DOCUMENT_ROOT."/product/stock/class/mouvementstock.class.php"); require_once(DOL_DOCUMENT_ROOT."/product/stock/class/mouvementstock.class.php");
$langs->load("agenda"); $langs->load("agenda");
for ($i = 0 ; $i < sizeof($this->lines) ; $i++) for ($i = 0 ; $i < sizeof($this->lines) ; $i++)
{ {
@ -402,7 +402,7 @@ class Commande extends CommonObject
if ($this->statut != 3) if ($this->statut != 3)
{ {
return 0; return 0;
} }
$this->db->begin(); $this->db->begin();
@ -451,13 +451,13 @@ class Commande extends CommonObject
function cloture($user) function cloture($user)
{ {
global $conf; global $conf;
$error=0; $error=0;
if ($user->rights->commande->valider) if ($user->rights->commande->valider)
{ {
$this->db->begin(); $this->db->begin();
$now=dol_now(); $now=dol_now();
$sql = 'UPDATE '.MAIN_DB_PREFIX.'commande'; $sql = 'UPDATE '.MAIN_DB_PREFIX.'commande';
$sql.= ' SET fk_statut = 3,'; $sql.= ' SET fk_statut = 3,';
@ -476,21 +476,21 @@ class Commande extends CommonObject
if (! $error) if (! $error)
{ {
$this->db->commit(); $this->db->commit();
return 1; return 1;
} }
else else
{ {
$this->db->rollback(); $this->db->rollback();
return -1; return -1;
} }
} }
else else
{ {
$this->error=$this->db->lasterror(); $this->error=$this->db->lasterror();
dol_syslog($this->error, LOG_ERR); dol_syslog($this->error, LOG_ERR);
$this->db->rollback(); $this->db->rollback();
return -1; return -1;
} }
} }
@ -523,7 +523,7 @@ class Commande extends CommonObject
if ($conf->stock->enabled && $conf->global->STOCK_CALCULATE_ON_VALIDATE_ORDER == 1) if ($conf->stock->enabled && $conf->global->STOCK_CALCULATE_ON_VALIDATE_ORDER == 1)
{ {
require_once(DOL_DOCUMENT_ROOT."/product/stock/class/mouvementstock.class.php"); require_once(DOL_DOCUMENT_ROOT."/product/stock/class/mouvementstock.class.php");
$langs->load("agenda"); $langs->load("agenda");
if ($this->lines[$i]->fk_product > 0) if ($this->lines[$i]->fk_product > 0)
{ {
@ -570,9 +570,10 @@ class Commande extends CommonObject
/** /**
* Create order * Create order
* @param user Objet user that make creation * Note that this->ref can be set or empty. If empty, we will use "(PROV)"
* @return int <0 if KO, >0 if OK * @param user Objet user that make creation
* remarks this->ref can be set or empty. If empty, we will use "(PROV)" * @param notrigger Disable all triggers
* @return int <0 if KO, >0 if OK
*/ */
function create($user, $notrigger=0) function create($user, $notrigger=0)
{ {
@ -694,7 +695,7 @@ class Commande extends CommonObject
{ {
if ($this->id) if ($this->id)
{ {
$this->ref="(PROV".$this->id.")"; $this->ref="(PROV".$this->id.")";
// Add linked object // Add linked object
if ($this->origin && $this->origin_id) if ($this->origin && $this->origin_id)
@ -825,23 +826,23 @@ class Commande extends CommonObject
if (! $error) if (! $error)
{ {
// Hook of thirdparty module // Hook of thirdparty module
if (! empty($object->hooks)) if (! empty($object->hooks))
{ {
foreach($object->hooks as $hook) foreach($object->hooks as $hook)
{ {
if (! empty($hook['modules'])) if (! empty($hook['modules']))
{ {
foreach($hook['modules'] as $module) foreach($hook['modules'] as $module)
{ {
if (method_exists($module,'createfrom')) if (method_exists($module,'createfrom'))
{ {
$result = $module->createfrom($objFrom,$result,$object->element); $result = $module->createfrom($objFrom,$result,$object->element);
if ($result < 0) $error++; if ($result < 0) $error++;
} }
} }
} }
} }
} }
// Appel des triggers // Appel des triggers
include_once(DOL_DOCUMENT_ROOT . "/core/class/interfaces.class.php"); include_once(DOL_DOCUMENT_ROOT . "/core/class/interfaces.class.php");
@ -865,103 +866,103 @@ class Commande extends CommonObject
} }
/** /**
* Load an object from a proposal and create a new order into database * Load an object from a proposal and create a new order into database
* @param object Object source * @param object Object source
* @param invertdetail Reverse sign of amounts for lines * @param invertdetail Reverse sign of amounts for lines
* @return int <0 if KO, 0 if nothing done, 1 if OK * @return int <0 if KO, 0 if nothing done, 1 if OK
*/ */
function createFromProposal($object,$invertdetail=0) function createFromProposal($object,$invertdetail=0)
{ {
global $conf,$user,$langs; global $conf,$user,$langs;
$error=0; $error=0;
// Signed proposal // Signed proposal
if ($object->statut == 2) if ($object->statut == 2)
{ {
$this->date_commande = dol_now(); $this->date_commande = dol_now();
$this->source = 0; $this->source = 0;
for ($i = 0 ; $i < sizeof($object->lines) ; $i++) for ($i = 0 ; $i < sizeof($object->lines) ; $i++)
{ {
$line = new OrderLine($this->db); $line = new OrderLine($this->db);
$line->libelle = $object->lines[$i]->libelle; $line->libelle = $object->lines[$i]->libelle;
$line->desc = $object->lines[$i]->desc; $line->desc = $object->lines[$i]->desc;
$line->price = $object->lines[$i]->price; $line->price = $object->lines[$i]->price;
$line->subprice = $object->lines[$i]->subprice; $line->subprice = $object->lines[$i]->subprice;
$line->tva_tx = $object->lines[$i]->tva_tx; $line->tva_tx = $object->lines[$i]->tva_tx;
$line->localtax1_tx = $object->lines[$i]->localtax1_tx; $line->localtax1_tx = $object->lines[$i]->localtax1_tx;
$line->localtax2_tx = $object->lines[$i]->localtax2_tx; $line->localtax2_tx = $object->lines[$i]->localtax2_tx;
$line->qty = $object->lines[$i]->qty; $line->qty = $object->lines[$i]->qty;
$line->fk_remise_except = $object->lines[$i]->fk_remise_except; $line->fk_remise_except = $object->lines[$i]->fk_remise_except;
$line->remise_percent = $object->lines[$i]->remise_percent; $line->remise_percent = $object->lines[$i]->remise_percent;
$line->fk_product = $object->lines[$i]->fk_product; $line->fk_product = $object->lines[$i]->fk_product;
$line->info_bits = $object->lines[$i]->info_bits; $line->info_bits = $object->lines[$i]->info_bits;
$line->product_type = $object->lines[$i]->product_type; $line->product_type = $object->lines[$i]->product_type;
$line->rang = $object->lines[$i]->rang; $line->rang = $object->lines[$i]->rang;
$line->special_code = $object->lines[$i]->special_code; $line->special_code = $object->lines[$i]->special_code;
$line->fk_parent_line = $object->lines[$i]->fk_parent_line; $line->fk_parent_line = $object->lines[$i]->fk_parent_line;
$this->lines[$i] = $line; $this->lines[$i] = $line;
} }
$this->socid = $object->socid; $this->socid = $object->socid;
$this->fk_project = $object->fk_project; $this->fk_project = $object->fk_project;
$this->cond_reglement_id = $object->cond_reglement_id; $this->cond_reglement_id = $object->cond_reglement_id;
$this->mode_reglement_id = $object->mode_reglement_id; $this->mode_reglement_id = $object->mode_reglement_id;
$this->availability_id = $object->availability_id; $this->availability_id = $object->availability_id;
$this->demand_reason_id = $object->demand_reason_id; $this->demand_reason_id = $object->demand_reason_id;
$this->date_livraison = $object->date_livraison; $this->date_livraison = $object->date_livraison;
$this->fk_delivery_address = $object->fk_delivery_address; $this->fk_delivery_address = $object->fk_delivery_address;
$this->contact_id = $object->contactid; $this->contact_id = $object->contactid;
$this->ref_client = $object->ref_client; $this->ref_client = $object->ref_client;
$this->note = $object->note; $this->note = $object->note;
$this->note_public = $object->note_public; $this->note_public = $object->note_public;
$this->origin = $object->element; $this->origin = $object->element;
$this->origin_id = $object->id; $this->origin_id = $object->id;
$ret = $this->create($user); $ret = $this->create($user);
if ($ret > 0) if ($ret > 0)
{ {
// Hook of thirdparty module // Hook of thirdparty module
if (! empty($object->hooks)) if (! empty($object->hooks))
{ {
foreach($object->hooks as $hook) foreach($object->hooks as $hook)
{ {
if (! empty($hook['modules'])) if (! empty($hook['modules']))
{ {
foreach($hook['modules'] as $module) foreach($hook['modules'] as $module)
{ {
if (method_exists($module,'createfrom')) if (method_exists($module,'createfrom'))
{ {
$result = $module->createfrom($object,$ret,$this->element); $result = $module->createfrom($object,$ret,$this->element);
if ($result < 0) $error++; if ($result < 0) $error++;
} }
} }
} }
} }
} }
if (! $error) if (! $error)
{ {
// Ne pas passer par la commande provisoire // Ne pas passer par la commande provisoire
if ($conf->global->COMMANDE_VALID_AFTER_CLOSE_PROPAL == 1) if ($conf->global->COMMANDE_VALID_AFTER_CLOSE_PROPAL == 1)
{ {
$this->fetch($ret); $this->fetch($ret);
$this->valid($user); $this->valid($user);
} }
return 1; return 1;
} }
else return -1; else return -1;
} }
else return -1; else return -1;
} }
else return 0; else return 0;
} }
/** /**
@ -998,13 +999,13 @@ class Commande extends CommonObject
// Clean parameters // Clean parameters
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; if (empty($rang)) $rang=0;
if (empty($txtva)) $txtva=0; if (empty($txtva)) $txtva=0;
if (empty($txlocaltax1)) $txlocaltax1=0; if (empty($txlocaltax1)) $txlocaltax1=0;
if (empty($txlocaltax2)) $txlocaltax2=0; if (empty($txlocaltax2)) $txlocaltax2=0;
if (empty($fk_parent_line) || $fk_parent_line < 0) $fk_parent_line=0; if (empty($fk_parent_line) || $fk_parent_line < 0) $fk_parent_line=0;
$remise_percent=price2num($remise_percent); $remise_percent=price2num($remise_percent);
$qty=price2num($qty); $qty=price2num($qty);
@ -1124,12 +1125,12 @@ class Commande extends CommonObject
/** /**
* Add line into array * Add line into array
* $this->client doit etre charge * $this->client doit etre charge
* @param idproduct Id du produit a ajouter * @param idproduct Id du produit a ajouter
* @param qty Quantite * @param qty Quantite
* @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 remise_percent Remise relative effectuee sur le produit
* @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_start Start date of the line - Added by Matelli (See http://matelli.fr/showcases/patchs-dolibarr/add-dates-in-order-lines.html)
* @remise_percent remise_percent Remise relative effectuee sur le produit * @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 * @return void
* TODO Remplacer les appels a cette fonction par generation objet Ligne * TODO Remplacer les appels a cette fonction par generation objet Ligne
* insere dans tableau $this->products * insere dans tableau $this->products
*/ */
@ -1202,7 +1203,7 @@ class Commande extends CommonObject
* @param id Id of object to load * @param id Id of object to load
* @param ref Ref of object * @param ref Ref of object
* @param ref_ext External reference of object * @param ref_ext External reference of object
* @param ref_int Internal reference of other object * @param ref_int Internal reference of other object
* @return int >0 if OK, <0 if KO * @return int >0 if OK, <0 if KO
*/ */
function fetch($id, $ref='', $ref_ext='', $ref_int='') function fetch($id, $ref='', $ref_ext='', $ref_int='')
@ -1231,9 +1232,9 @@ class Commande extends CommonObject
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."element_element as el ON el.fk_target = c.rowid AND el.targettype = '".$this->element."'"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."element_element as el ON el.fk_target = c.rowid AND el.targettype = '".$this->element."'";
$sql.= " WHERE c.entity = ".$conf->entity; $sql.= " WHERE c.entity = ".$conf->entity;
if ($id) $sql.= " AND c.rowid=".$id; if ($id) $sql.= " AND c.rowid=".$id;
if ($ref) $sql.= " AND c.ref='".$this->db->escape($ref)."'"; if ($ref) $sql.= " AND c.ref='".$this->db->escape($ref)."'";
if ($ref_ext) $sql.= " AND c.ref_ext='".$this->db->escape($ref_ext)."'"; if ($ref_ext) $sql.= " AND c.ref_ext='".$this->db->escape($ref_ext)."'";
if ($ref_int) $sql.= " AND c.ref_int='".$this->db->escape($ref_int)."'"; if ($ref_int) $sql.= " AND c.ref_int='".$this->db->escape($ref_int)."'";
dol_syslog("Commande::fetch sql=".$sql, LOG_DEBUG); dol_syslog("Commande::fetch sql=".$sql, LOG_DEBUG);
$result = $this->db->query($sql) ; $result = $this->db->query($sql) ;
@ -1330,9 +1331,9 @@ class Commande extends CommonObject
/** /**
* \brief Ajout d'une ligne remise fixe dans la commande, en base * Ajout d'une ligne remise fixe dans la commande, en base
* \param idremise Id de la remise fixe * @param idremise Id de la remise fixe
* \return int >0 si ok, <0 si ko * @return int >0 si ok, <0 si ko
*/ */
function insert_discount($idremise) function insert_discount($idremise)
{ {
@ -1405,9 +1406,9 @@ class Commande extends CommonObject
/** /**
* \brief Reinitialize array lignes * Load array lines
* \param only_product Return only physical products * @param only_product Return only physical products
* \return int <0 if KO, >0 if OK * @return int <0 if KO, >0 if OK
*/ */
function fetch_lines($only_product=0) function fetch_lines($only_product=0)
{ {
@ -1558,12 +1559,12 @@ class Commande extends CommonObject
*/ */
function nb_expedition() function nb_expedition()
{ {
$sql = 'SELECT count(*)'; $sql = 'SELECT count(*)';
$sql.= ' FROM '.MAIN_DB_PREFIX.'expedition as e'; $sql.= ' FROM '.MAIN_DB_PREFIX.'expedition as e';
$sql.= ', '.MAIN_DB_PREFIX.'element_element as el'; $sql.= ', '.MAIN_DB_PREFIX.'element_element as el';
$sql.= ' WHERE el.fk_source = '.$this->id; $sql.= ' WHERE el.fk_source = '.$this->id;
$sql.= " AND el.fk_target = e.rowid"; $sql.= " AND el.fk_target = e.rowid";
$sql.= " AND el.targettype = 'shipping'"; $sql.= " AND el.targettype = 'shipping'";
$resql = $this->db->query($sql); $resql = $this->db->query($sql);
if ($resql) if ($resql)
@ -1571,7 +1572,7 @@ class Commande extends CommonObject
$row = $this->db->fetch_row($resql); $row = $this->db->fetch_row($resql);
return $row[0]; return $row[0];
} }
else dol_print_error($this->db); else dol_print_error($this->db);
} }
/** /**
@ -1588,10 +1589,10 @@ class Commande extends CommonObject
} }
/** /**
* \brief Renvoie un tableau avec les stocks restant par produit * Renvoie un tableau avec les stocks restant par produit
* \param filtre_statut Filtre sur statut * @param filtre_statut Filtre sur statut
* \return int 0 si OK, <0 si KO * @return int 0 si OK, <0 si KO
* \todo FONCTION NON FINIE A FINIR * TODO FONCTION NON FINIE A FINIR
*/ */
function stock_array($filtre_statut=-1) function stock_array($filtre_statut=-1)
{ {
@ -1625,9 +1626,9 @@ class Commande extends CommonObject
} }
/** /**
* \brief Supprime une ligne de la commande * Delete an order line
* \param idligne Id de la ligne a supprimer * @param lineid Id of line to delete
* \return int >0 si ok, 0 si rien a supprimer, <0 si ko * @return int >0 if OK, 0 if nothing to do, <0 if KO
*/ */
function deleteline($lineid) function deleteline($lineid)
{ {
@ -1700,10 +1701,10 @@ class Commande extends CommonObject
} }
/** /**
* \brief Applique une remise relative * Applique une remise relative
* \param user User qui positionne la remise * @param user User qui positionne la remise
* \param remise * @param remise
* \return int <0 si ko, >0 si ok * @return int <0 if KO, >0 if OK
*/ */
function set_remise($user, $remise) function set_remise($user, $remise)
{ {
@ -1733,10 +1734,10 @@ class Commande extends CommonObject
/** /**
* \brief Applique une remise absolue * Applique une remise absolue
* \param user User qui positionne la remise * @param user User qui positionne la remise
* \param remise * @param remise
* \return int <0 si ko, >0 si ok * @return int <0 if KO, >0 if OK
*/ */
function set_remise_absolue($user, $remise) function set_remise_absolue($user, $remise)
{ {
@ -1769,8 +1770,8 @@ class Commande extends CommonObject
/** /**
* Set the order date * Set the order date
* @param user Object user * @param user Object user making change
* @param date_livraison Date delivery * @param date Date
* @return int <0 if KO, >0 if OK * @return int <0 if KO, >0 if OK
*/ */
function set_date($user, $date) function set_date($user, $date)
@ -1802,10 +1803,10 @@ class Commande extends CommonObject
} }
/** /**
* \brief Set the planned delivery date * Set the planned delivery date
* \param user Objet utilisateur qui modifie * @param user Objet utilisateur qui modifie
* \param date_livraison Date de livraison * @param date_livraison Date de livraison
* \return int <0 si ko, >0 si ok * @return int <0 si ko, >0 si ok
*/ */
function set_date_livraison($user, $date_livraison) function set_date_livraison($user, $date_livraison)
{ {
@ -1836,10 +1837,10 @@ class Commande extends CommonObject
} }
/** /**
* \brief Definit une adresse de livraison * Set address
* \param user Objet utilisateur qui modifie * @param user Object user making change
* \param adresse_livraison Adresse de livraison * @param fk_address Adress of delivery
* \return int <0 si ko, >0 si ok * @return int <0 ig KO, >0 if Ok
*/ */
function set_adresse_livraison($user, $fk_address) function set_adresse_livraison($user, $fk_address)
{ {
@ -1862,11 +1863,11 @@ class Commande extends CommonObject
} }
} }
/** /**
* \brief Set delivery * Set availability
* \param user Objet utilisateur qui modifie * @param user Object user making change
* \param delivery delai de livraison * @param id If of availability delay
* \return int <0 si ko, >0 si ok * @return int <0 if KO, >0 if OK
*/ */
function set_availability($user, $id) function set_availability($user, $id)
{ {
@ -1891,10 +1892,10 @@ class Commande extends CommonObject
} }
/** /**
* \brief Set source of demand * Set source of demand
* \param user Objet utilisateur qui modifie * @param user Object user making change
* \param delivery delai de livraison * @param id Id of source
* \return int <0 si ko, >0 si ok * @return int <0 if KO, >0 if OK
*/ */
function set_demand_reason($user, $id) function set_demand_reason($user, $id)
{ {
@ -1935,7 +1936,7 @@ class Commande extends CommonObject
$sql.= " WHERE c.entity = ".$conf->entity; $sql.= " WHERE c.entity = ".$conf->entity;
$sql.= " AND c.fk_soc = s.rowid"; $sql.= " AND c.fk_soc = s.rowid";
if ($brouillon) $sql.= " AND c.fk_statut = 0"; if ($brouillon) $sql.= " AND c.fk_statut = 0";
if ($user) $sql.= " AND c.fk_user_author <> ".$user->id; if ($user) $sql.= " AND c.fk_user_author <> ".$user->id;
$sql .= " ORDER BY c.date_commande DESC"; $sql .= " ORDER BY c.date_commande DESC";
$result=$this->db->query($sql); $result=$this->db->query($sql);
@ -1963,9 +1964,9 @@ class Commande extends CommonObject
} }
/** /**
* \brief 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 * @param cond_reglement_id Id de la nouvelle condition de reglement
* \return int >0 si ok, <0 si ko * @return int >0 if OK, <0 if KO
*/ */
function cond_reglement($cond_reglement_id) function cond_reglement($cond_reglement_id)
{ {
@ -2029,10 +2030,10 @@ class Commande extends CommonObject
} }
} }
/** /**
* \brief Change le delai de livraison * Change le delai de livraison
* \param mode Id du nouveau mode * @param availability_id Id du nouveau mode
* \return int >0 si ok, <0 si ko * @return int >0 if OK, <0 if KO
*/ */
function availability($availability_id) function availability($availability_id)
{ {
@ -2177,7 +2178,7 @@ class Commande extends CommonObject
*/ */
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) 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)
{ {
global $conf; global $conf;
dol_syslog("CustomerOrder::UpdateLine $rowid, $desc, $pu, $qty, $remise_percent, $txtva, $txlocaltax1, $txlocaltax2, $price_base_type, $info_bits, $date_start, $date_end, $type"); dol_syslog("CustomerOrder::UpdateLine $rowid, $desc, $pu, $qty, $remise_percent, $txtva, $txlocaltax1, $txlocaltax2, $price_base_type, $info_bits, $date_start, $date_end, $type");
include_once(DOL_DOCUMENT_ROOT.'/lib/price.lib.php'); include_once(DOL_DOCUMENT_ROOT.'/lib/price.lib.php');
@ -2280,14 +2281,14 @@ class Commande extends CommonObject
/** /**
* \brief Delete the customer order * Delete the customer order
* \user User object * @param user User object
* \return int <=0 if KO, >0 if OK * @return int <=0 if KO, >0 if OK
*/ */
function delete($user) function delete($user)
{ {
global $conf, $langs; global $conf, $langs;
require_once(DOL_DOCUMENT_ROOT."/lib/files.lib.php"); require_once(DOL_DOCUMENT_ROOT."/lib/files.lib.php");
$err = 0; $err = 0;
@ -2380,9 +2381,9 @@ 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 * @param user Objet user
* @return int <0 if KO, >0 if OK * @return int <0 if KO, >0 if OK
*/ */
function load_board($user) function load_board($user)
{ {
@ -2515,10 +2516,12 @@ class Commande extends CommonObject
/** /**
* Return clicable link of object (with eventually picto) * Return clicable link of object (with eventually picto)
* @param withpicto Add picto into link * @param withpicto Add picto into link
* @param option Where point the link * @param option Where point the link
* @return string String with URL * @param max Max length to show
* @param short Use short labels
* @return string String with URL
*/ */
function getNomUrl($withpicto=0,$option=0,$max=0,$short=0) function getNomUrl($withpicto=0,$option=0,$max=0,$short=0)
{ {
@ -2887,9 +2890,9 @@ class OrderLine
$this->rang = $objp->rang; $this->rang = $objp->rang;
$this->ref = $objp->product_ref; // deprecated $this->ref = $objp->product_ref; // deprecated
$this->product_ref = $objp->product_ref; $this->product_ref = $objp->product_ref;
$this->libelle = $objp->product_libelle; // deprecated $this->libelle = $objp->product_libelle; // deprecated
$this->product_label = $objp->product_libelle; $this->product_label = $objp->product_libelle;
$this->product_desc = $objp->product_desc; $this->product_desc = $objp->product_desc;
$this->date_start = $this->db->jdate($objp->date_start); $this->date_start = $this->db->jdate($objp->date_start);
@ -2951,17 +2954,17 @@ class OrderLine
if (empty($this->localtax2_tx)) $this->localtax2_tx=0; if (empty($this->localtax2_tx)) $this->localtax2_tx=0;
if (empty($this->total_localtax1)) $this->total_localtax1=0; if (empty($this->total_localtax1)) $this->total_localtax1=0;
if (empty($this->total_localtax2)) $this->total_localtax2=0; if (empty($this->total_localtax2)) $this->total_localtax2=0;
if (empty($this->rang)) $this->rang=0; if (empty($this->rang)) $this->rang=0;
if (empty($this->remise)) $this->remise=0; if (empty($this->remise)) $this->remise=0;
if (empty($this->remise_percent)) $this->remise_percent=0; if (empty($this->remise_percent)) $this->remise_percent=0;
if (empty($this->info_bits)) $this->info_bits=0; if (empty($this->info_bits)) $this->info_bits=0;
if (empty($this->special_code)) $this->special_code=0; if (empty($this->special_code)) $this->special_code=0;
if (empty($this->fk_parent_line)) $this->fk_parent_line=0; if (empty($this->fk_parent_line)) $this->fk_parent_line=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();
// 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

@ -25,7 +25,7 @@
* \file htdocs/contact/class/contact.class.php * \file htdocs/contact/class/contact.class.php
* \ingroup societe * \ingroup societe
* \brief File of contacts class * \brief File of contacts class
* \version $Id$ * \version $Id: contact.class.php,v 1.30 2011/07/04 09:36:29 eldy Exp $
*/ */
require_once(DOL_DOCUMENT_ROOT ."/core/class/commonobject.class.php"); require_once(DOL_DOCUMENT_ROOT ."/core/class/commonobject.class.php");
@ -83,7 +83,6 @@ class Contact extends CommonObject
/** /**
* Constructor of class Contact * Constructor of class Contact
* @param DB Habler d'acces base * @param DB Habler d'acces base
* @param id Id contact
*/ */
function Contact($DB) function Contact($DB)
{ {
@ -583,7 +582,7 @@ class Contact extends CommonObject
} }
/* /**
* \brief Charge le nombre d'elements auquel est lie ce contact * \brief Charge le nombre d'elements auquel est lie ce contact
* ref_facturation * ref_facturation
* ref_contrat * ref_contrat
@ -626,9 +625,10 @@ class Contact extends CommonObject
} }
} }
/* /**
* \brief Efface le contact de la base * Efface le contact de la base
* \return int <0 si ko, >0 si ok * @param notrigger Disable all trigger
* @return int <0 if KO, >0 if OK
*/ */
function delete($notrigger=0) function delete($notrigger=0)
{ {

View File

@ -22,7 +22,7 @@
* \file htdocs/core/class/commonobject.class.php * \file htdocs/core/class/commonobject.class.php
* \ingroup core * \ingroup core
* \brief File of parent class of all other business classes (invoices, contracts, proposals, orders, ...) * \brief File of parent class of all other business classes (invoices, contracts, proposals, orders, ...)
* \version $Id: commonobject.class.php,v 1.143 2011/07/01 23:05:39 eldy Exp $ * \version $Id: commonobject.class.php,v 1.144 2011/07/04 09:36:29 eldy Exp $
*/ */
@ -78,11 +78,12 @@ class CommonObject
} }
/** /**
* \brief Add a link between element $this->element and a contact * Add a link between element $this->element and a contact
* \param fk_socpeople Id of contact to link * @param fk_socpeople Id of contact to link
* \param type_contact Type of contact (code or id) * @param type_contact Type of contact (code or id)
* \param source external=Contact extern (llx_socpeople), internal=Contact intern (llx_user) * @param source external=Contact extern (llx_socpeople), internal=Contact intern (llx_user)
* \return int <0 if KO, >0 if OK * @param notrigger Disable all triggers
* @return int <0 if KO, >0 if OK
*/ */
function add_contact($fk_socpeople, $type_contact, $source='external',$notrigger=0) function add_contact($fk_socpeople, $type_contact, $source='external',$notrigger=0)
{ {
@ -168,11 +169,11 @@ class CommonObject
} }
/** /**
* \brief Update a link to contact line * Update a link to contact line
* \param rowid Id of line contact-element * @param rowid Id of line contact-element
* \param statut New status of link * @param statut New status of link
* \param type_contact_id Id of contact type * @param type_contact_id Id of contact type
* \return int <0 if KO, >= 0 if OK * @return int <0 if KO, >= 0 if OK
*/ */
function update_contact($rowid, $statut, $type_contact_id) function update_contact($rowid, $statut, $type_contact_id)
{ {
@ -194,9 +195,10 @@ class CommonObject
} }
/** /**
* \brief Delete a link to contact line * Delete a link to contact line
* \param rowid Id of link line to delete * @param rowid Id of contact link line to delete
* \return statur >0 si ok, <0 si ko * @param notrigger Disable all triggers
* @return int >0 if OK, <0 if KO
*/ */
function delete_contact($rowid,$notrigger=0) function delete_contact($rowid,$notrigger=0)
{ {
@ -1321,8 +1323,8 @@ class CommonObject
/** /**
* Set statut of an object * Set statut of an object
* @param statut Statut to set * @param statut Statut to set
* @param elementid Id of element to force (use this->id by default) * @param elementId Id of element to force (use this->id by default)
* @param elementtype Type of element to force (use ->this->element by default) * @param elementType Type of element to force (use ->this->element by default)
* @return int <0 if ko, >0 if ok * @return int <0 if ko, >0 if ok
*/ */
function setStatut($statut,$elementId='',$elementType='') function setStatut($statut,$elementId='',$elementType='')
@ -1664,6 +1666,8 @@ class CommonObject
* TODO Edit templates to use global variables and include them directly in controller call * TODO Edit templates to use global variables and include them directly in controller call
* But for the moment we don't know if it's possible as we keep a method available on overloaded objects. * But for the moment we don't know if it's possible as we keep a method available on overloaded objects.
* @param $dateSelector 1=Show also date range input fields * @param $dateSelector 1=Show also date range input fields
* @param $seller Object thirdparty who sell
* @param $buyer Object thirdparty who buy
*/ */
function formAddPredefinedProduct($dateSelector,$seller,$buyer) function formAddPredefinedProduct($dateSelector,$seller,$buyer)
{ {
@ -1699,10 +1703,11 @@ class CommonObject
* TODO Move this into an output class file (htmlline.class.php) * TODO Move this into an output class file (htmlline.class.php)
* If lines are into a template, title must also be into a template * If lines are into a template, title must also be into a template
* But for the moment we don't know if it'st possible as we keep a method available on overloaded objects. * But for the moment we don't know if it'st possible as we keep a method available on overloaded objects.
* @param $seller Object of seller third party * @param $action Action code
* @param $buyer Object of buyer third party * @param $seller Object of seller third party
* @param $selected Object line selected * @param $buyer Object of buyer third party
* @param $dateSelector 1=Show also date range input fields * @param $selected Object line selected
* @param $dateSelector 1=Show also date range input fields
*/ */
function printObjectLines($action='viewline',$seller,$buyer,$selected=0,$dateSelector=0) function printObjectLines($action='viewline',$seller,$buyer,$selected=0,$dateSelector=0)
{ {

View File

@ -25,7 +25,7 @@
* \file htdocs/fourn/class/fournisseur.commande.class.php * \file htdocs/fourn/class/fournisseur.commande.class.php
* \ingroup fournisseur,commande * \ingroup fournisseur,commande
* \brief File of class to manage suppliers orders * \brief File of class to manage suppliers orders
* \version $Id$ * \version $Id: fournisseur.commande.class.php,v 1.47 2011/07/04 09:36:29 eldy Exp $
*/ */
require_once(DOL_DOCUMENT_ROOT."/product/class/product.class.php"); require_once(DOL_DOCUMENT_ROOT."/product/class/product.class.php");
@ -49,27 +49,27 @@ class CommandeFournisseur extends Commande
var $ismultientitymanaged = 1; // 0=No test on entity, 1=Test with field entity, 2=Test with link by societe var $ismultientitymanaged = 1; // 0=No test on entity, 1=Test with field entity, 2=Test with link by societe
var $ref; // TODO deprecated var $ref; // TODO deprecated
var $product_ref; var $product_ref;
var $ref_supplier; var $ref_supplier;
var $brouillon; var $brouillon;
var $statut; // 0=Draft -> 1=Validated -> 2=Approved -> 3=Process runing -> 4=Received partially -> 5=Received totally -> (reopen) 4=Received partially var $statut; // 0=Draft -> 1=Validated -> 2=Approved -> 3=Process runing -> 4=Received partially -> 5=Received totally -> (reopen) 4=Received partially
// -> 7=Canceled/Never received -> (reopen) 3=Process runing // -> 7=Canceled/Never received -> (reopen) 3=Process runing
// -> 6=Canceled -> (reopen) 2=Approved // -> 6=Canceled -> (reopen) 2=Approved
// -> 9=Refused -> (reopen) 1=Validated // -> 9=Refused -> (reopen) 1=Validated
var $socid; var $socid;
var $fourn_id; var $fourn_id;
var $date; var $date;
var $date_commande; var $date_commande;
var $total_ht; var $total_ht;
var $total_tva; var $total_tva;
var $total_localtax1; // Total Local tax 1 var $total_localtax1; // Total Local tax 1
var $total_localtax2; // Total Local tax 2 var $total_localtax2; // Total Local tax 2
var $total_ttc; var $total_ttc;
var $source; var $source;
var $note; var $note;
var $note_public; var $note_public;
var $model_pdf; var $model_pdf;
var $fk_project; var $fk_project;
var $cond_reglement_id; var $cond_reglement_id;
var $cond_reglement_code; var $cond_reglement_code;
var $mode_reglement_id; var $mode_reglement_id;
@ -247,7 +247,7 @@ class CommandeFournisseur extends Commande
* @param user User making action * @param user User making action
* @param statut Status of order * @param statut Status of order
* @param datelog Date of change * @param datelog Date of change
* @param comment Comment * @param comment Comment
* @return int <0 if KO, >0 if OK * @return int <0 if KO, >0 if OK
*/ */
function log($user, $statut, $datelog, $comment='') function log($user, $statut, $datelog, $comment='')
@ -278,7 +278,7 @@ class CommandeFournisseur extends Commande
function valid($user) function valid($user)
{ {
global $langs,$conf; global $langs,$conf;
require_once(DOL_DOCUMENT_ROOT."/lib/files.lib.php"); require_once(DOL_DOCUMENT_ROOT."/lib/files.lib.php");
$error=0; $error=0;
@ -479,18 +479,18 @@ class CommandeFournisseur extends Commande
global $langs; global $langs;
$langs->load('orders'); $langs->load('orders');
// List of language codes for status // List of language codes for status
$statutshort[0] = 'StatusOrderDraftShort'; $statutshort[0] = 'StatusOrderDraftShort';
$statutshort[1] = 'StatusOrderValidatedShort'; $statutshort[1] = 'StatusOrderValidatedShort';
$statutshort[2] = 'StatusOrderApprovedShort'; $statutshort[2] = 'StatusOrderApprovedShort';
$statutshort[3] = 'StatusOrderOnProcessShort'; $statutshort[3] = 'StatusOrderOnProcessShort';
$statutshort[4] = 'StatusOrderReceivedPartiallyShort'; $statutshort[4] = 'StatusOrderReceivedPartiallyShort';
$statutshort[5] = 'StatusOrderReceivedAllShort'; $statutshort[5] = 'StatusOrderReceivedAllShort';
$statutshort[6] = 'StatusOrderCanceledShort'; $statutshort[6] = 'StatusOrderCanceledShort';
$statutshort[7] = 'StatusOrderCanceledShort'; $statutshort[7] = 'StatusOrderCanceledShort';
$statutshort[9] = 'StatusOrderRefusedShort'; $statutshort[9] = 'StatusOrderRefusedShort';
if ($mode == 0) if ($mode == 0)
{ {
return $langs->trans($this->statuts[$statut]); return $langs->trans($this->statuts[$statut]);
} }
@ -618,6 +618,7 @@ class CommandeFournisseur extends Commande
/** /**
* Accept an order * Accept an order
* @param user Object user * @param user Object user
* @return int <0 if KO, >0 if OK
*/ */
function approve($user) function approve($user)
{ {
@ -647,7 +648,7 @@ class CommandeFournisseur extends Commande
for ($i = 0 ; $i < sizeof($this->lines) ; $i++) for ($i = 0 ; $i < sizeof($this->lines) ; $i++)
{ {
// Product with reference // Product with reference
if ($this->lines[$i]->fk_product > 0) if ($this->lines[$i]->fk_product > 0)
{ {
$mouvP = new MouvementStock($this->db); $mouvP = new MouvementStock($this->db);
// We decrement stock of product (and sub-products) // We decrement stock of product (and sub-products)
@ -739,9 +740,9 @@ class CommandeFournisseur extends Commande
} }
/** /**
* Cancel an approved order * Cancel an approved order.
* L'annulation se fait apres l'approbation
* @param user User making action * @param user User making action
* @remarks L'annulation se fait apres l'approbation
*/ */
function Cancel($user) function Cancel($user)
{ {
@ -800,6 +801,11 @@ class CommandeFournisseur extends Commande
/** /**
* Send a supplier order to supplier * Send a supplier order to supplier
* @param user User making change
* @param date Date
* @param methode Method
* @param comment Comment
* @return int <0 if KO, >0 if OK
*/ */
function commande($user, $date, $methode, $comment='') function commande($user, $date, $methode, $comment='')
{ {
@ -912,14 +918,14 @@ class CommandeFournisseur extends Commande
/** /**
* Add order line * Add order line
* @param desc Description * @param desc Description
* @param pu Unit price * @param pu_ht Unit price
* @param qty Quantity * @param qty Quantity
* @param txtva Taux tva * @param txtva Taux tva
* @param txlocaltax1 Localtax1 tax * @param txlocaltax1 Localtax1 tax
* @param txlocaltax2 Localtax2 tax * @param txlocaltax2 Localtax2 tax
* @param fk_product Id produit * @param fk_product Id produit
* @param fk_prod_fourn_price Id supplier price * @param fk_prod_fourn_price Id supplier price
* @param fournref Supplier reference * @param fourn_ref Supplier reference
* @param remise_percent Remise * @param remise_percent Remise
* @param price_base_type HT or TTC * @param price_base_type HT or TTC
* @param pu_ttc Unit price TTC * @param pu_ttc Unit price TTC
@ -1117,13 +1123,13 @@ class CommandeFournisseur extends Commande
$mouv = new MouvementStock($this->db); $mouv = new MouvementStock($this->db);
if ($product > 0) if ($product > 0)
{ {
$result=$mouv->reception($user, $product, $entrepot, $qty, $price, $comment); $result=$mouv->reception($user, $product, $entrepot, $qty, $price, $comment);
if ($result < 0) if ($result < 0)
{ {
$this->error=$mouv->error; $this->error=$mouv->error;
dol_syslog("CommandeFournisseur::DispatchProduct ".$this->error, LOG_ERR); dol_syslog("CommandeFournisseur::DispatchProduct ".$this->error, LOG_ERR);
$error++; $error++;
} }
} }
$i++; $i++;
} }
@ -1159,15 +1165,15 @@ class CommandeFournisseur extends Commande
dol_syslog("Fournisseur.commande.class::deleteline sql=".$sql); dol_syslog("Fournisseur.commande.class::deleteline sql=".$sql);
if ($resql) if ($resql)
{ {
$result=$this->update_price(); $result=$this->update_price();
return 0; return 0;
} }
else else
{ {
$this->error=$this->db->error(); $this->error=$this->db->error();
return -1; return -1;
} }
} }
else else
{ {
@ -1176,8 +1182,8 @@ class CommandeFournisseur extends Commande
} }
/** /**
* \brief Delete an order * Delete an order
* \return int <0 if KO, >0 if OK * @return int <0 if KO, >0 if OK
*/ */
function delete() function delete()
{ {
@ -1229,8 +1235,7 @@ class CommandeFournisseur extends Commande
} }
/** /**
* * Return list of order methods
*
*/ */
function get_methodes_commande() function get_methodes_commande()
{ {
@ -1295,8 +1300,8 @@ class CommandeFournisseur extends Commande
/** /**
* Change le mode de reglement * Change le mode de reglement
* @param mode Id du nouveau mode * @param mode_reglement_id Id du nouveau mode
* @return int >0 si ok, <0 si ko * @return int >0 if OK, <0 if KO
*/ */
function mode_reglement($mode_reglement_id) function mode_reglement($mode_reglement_id)
{ {
@ -1331,6 +1336,7 @@ class CommandeFournisseur extends Commande
* @param user User that input data * @param user User that input data
* @param date Date of reception * @param date Date of reception
* @param type Type of receipt * @param type Type of receipt
* @param comment Comment
*/ */
function Livraison($user, $date, $type, $comment) function Livraison($user, $date, $type, $comment)
{ {
@ -1388,7 +1394,8 @@ class CommandeFournisseur extends Commande
/** /**
* Cree la commande depuis une propale existante * Cree la commande depuis une propale existante
* @param user Utilisateur qui cree * @param user Utilisateur qui cree
* @param propale_id id de la propale qui sert de modele * @param idc Id de la propale qui sert de modele
* @param comclientid Id thirdparty
*/ */
function updateFromCommandeClient($user, $idc, $comclientid) function updateFromCommandeClient($user, $idc, $comclientid)
{ {
@ -1425,8 +1432,12 @@ class CommandeFournisseur extends Commande
/** /**
* Met a jour les notes * Update notes
* @return int <0 si ko, >=0 si ok * @param user
* @param note
* @param note_public
* @return int <0 if KO, >=0 if OK
* TODO Use instead update_note_public and update_note
*/ */
function UpdateNote($user, $note, $note_public) function UpdateNote($user, $note, $note_public)
{ {
@ -1457,10 +1468,8 @@ class CommandeFournisseur extends Commande
return $result ; return $result ;
} }
/* /**
* * Get list of user that can approve an order
*
*
*/ */
function ReadApprobators() function ReadApprobators()
{ {
@ -1500,6 +1509,7 @@ class CommandeFournisseur extends Commande
/** /**
* Tag order with a particular status * Tag order with a particular status
* @param user Object user that change status * @param user Object user that change status
* @param status New status
* @return int <0 if KO, >0 if OK * @return int <0 if KO, >0 if OK
*/ */
function setStatus($user,$status) function setStatus($user,$status)
@ -1688,7 +1698,7 @@ class CommandeFournisseur extends Commande
$this->specimen=1; $this->specimen=1;
$this->socid = 1; $this->socid = 1;
$this->date = time(); $this->date = time();
$this->date_commande = time(); $this->date_commande = time();
$this->date_lim_reglement=$this->date+3600*24*30; $this->date_lim_reglement=$this->date+3600*24*30;
$this->cond_reglement_code = 'RECEP'; $this->cond_reglement_code = 'RECEP';
$this->mode_reglement_code = 'CHQ'; $this->mode_reglement_code = 'CHQ';
@ -1703,14 +1713,14 @@ class CommandeFournisseur extends Commande
$line->desc=$langs->trans("Description")." ".$xnbp; $line->desc=$langs->trans("Description")." ".$xnbp;
$line->qty=1; $line->qty=1;
$line->subprice=100; $line->subprice=100;
$line->price=100; $line->price=100;
$line->tva_tx=19.6; $line->tva_tx=19.6;
$line->localtax1_tx=0; $line->localtax1_tx=0;
$line->localtax2_tx=0; $line->localtax2_tx=0;
$line->remise_percent=10; $line->remise_percent=10;
$line->total_ht=90; $line->total_ht=90;
$line->total_ttc=107.64; // 90 * 1.196 $line->total_ttc=107.64; // 90 * 1.196
$line->total_tva=17.64; $line->total_tva=17.64;
$line->ref_fourn='SUPPLIER_REF_'.$xnbp; $line->ref_fourn='SUPPLIER_REF_'.$xnbp;
$prodid = rand(1, $num_prods); $prodid = rand(1, $num_prods);
$line->fk_product=$prodids[$prodid]; $line->fk_product=$prodids[$prodid];
@ -1726,48 +1736,48 @@ class CommandeFournisseur extends Commande
$this->total_ttc = $xnbp*119.6; $this->total_ttc = $xnbp*119.6;
} }
/** /**
* Load indicators for dashboard (this->nbtodo and this->nbtodolate) * Load indicators for dashboard (this->nbtodo and this->nbtodolate)
* @param user Objet user * @param user Objet user
* @return int <0 if KO, >0 if OK * @return int <0 if KO, >0 if OK
*/ */
function load_board($user) function load_board($user)
{ {
global $conf, $user; global $conf, $user;
$now=gmmktime(); $now=gmmktime();
$this->nbtodo=$this->nbtodolate=0; $this->nbtodo=$this->nbtodolate=0;
$clause = " WHERE"; $clause = " WHERE";
$sql = "SELECT c.rowid, c.date_creation as datec, c.fk_statut"; $sql = "SELECT c.rowid, c.date_creation as datec, c.fk_statut";
$sql.= " FROM ".MAIN_DB_PREFIX."commande_fournisseur as c"; $sql.= " FROM ".MAIN_DB_PREFIX."commande_fournisseur as c";
if (!$user->rights->societe->client->voir && !$user->societe_id) if (!$user->rights->societe->client->voir && !$user->societe_id)
{ {
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON c.fk_soc = sc.fk_soc"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON c.fk_soc = sc.fk_soc";
$sql.= " WHERE sc.fk_user = " .$user->id; $sql.= " WHERE sc.fk_user = " .$user->id;
$clause = " AND"; $clause = " AND";
} }
$sql.= $clause." c.entity = ".$conf->entity; $sql.= $clause." c.entity = ".$conf->entity;
$sql.= " AND (c.fk_statut BETWEEN 1 AND 2)"; $sql.= " AND (c.fk_statut BETWEEN 1 AND 2)";
if ($user->societe_id) $sql.=" AND c.fk_soc = ".$user->societe_id; if ($user->societe_id) $sql.=" AND c.fk_soc = ".$user->societe_id;
$resql=$this->db->query($sql); $resql=$this->db->query($sql);
if ($resql) if ($resql)
{ {
while ($obj=$this->db->fetch_object($resql)) while ($obj=$this->db->fetch_object($resql))
{ {
$this->nbtodo++; $this->nbtodo++;
if ($obj->fk_statut != 3 && $this->db->jdate($obj->datec) < ($now - $conf->commande->fournisseur->warning_delay)) $this->nbtodolate++; if ($obj->fk_statut != 3 && $this->db->jdate($obj->datec) < ($now - $conf->commande->fournisseur->warning_delay)) $this->nbtodolate++;
} }
return 1; return 1;
} }
else else
{ {
$this->error=$this->db->error(); $this->error=$this->db->error();
return -1; return -1;
} }
} }
} }

View File

@ -25,7 +25,7 @@
/** /**
* \file htdocs/lib/CMailFile.class.php * \file htdocs/lib/CMailFile.class.php
* \brief File of class to send emails (with attachments or not) * \brief File of class to send emails (with attachments or not)
* \version $Id: CMailFile.class.php,v 1.142 2011/07/02 16:48:31 eldy Exp $ * \version $Id: CMailFile.class.php,v 1.143 2011/07/04 09:36:29 eldy Exp $
* \author Dan Potter. * \author Dan Potter.
* \author Eric Seigne * \author Eric Seigne
* \author Laurent Destailleur. * \author Laurent Destailleur.
@ -86,20 +86,20 @@ class CMailFile
/** /**
* \brief CMailFile * CMailFile
* \param subject Topic/Subject of mail * @param subject Topic/Subject of mail
* \param to Recipients emails (RFC 2822: "Nom prenom <email>[, ...]" ou "email[, ...]" ou "<email>[, ...]") * @param to Recipients emails (RFC 2822: "Nom prenom <email>[, ...]" ou "email[, ...]" ou "<email>[, ...]")
* \param from Sender email (RFC 2822: "Nom prenom <email>[, ...]" ou "email[, ...]" ou "<email>[, ...]") * @param from Sender email (RFC 2822: "Nom prenom <email>[, ...]" ou "email[, ...]" ou "<email>[, ...]")
* \param msg Message * @param msg Message
* \param filename_list List of files to attach (full path of filename on file system) * @param filename_list List of files to attach (full path of filename on file system)
* \param mimetype_list List of MIME type of attached files * @param mimetype_list List of MIME type of attached files
* \param mimefilename_list List of attached file name in message * @param mimefilename_list List of attached file name in message
* \param addr_cc Email cc * @param addr_cc Email cc
* \param addr_bcc Email bcc * @param addr_bcc Email bcc
* \param deliveryreceipt Ask a delivery receipt * @param deliveryreceipt Ask a delivery receipt
* \param msgishtml 1=String IS already html, 0=String IS NOT html, -1=Unknown need autodetection * @param msgishtml 1=String IS already html, 0=String IS NOT html, -1=Unknown need autodetection
* \param error_to Email errors * @param errors_to Email errors
* \param css Css option * @param css Css option
*/ */
function CMailFile($subject,$to,$from,$msg, function CMailFile($subject,$to,$from,$msg,
$filename_list=array(),$mimetype_list=array(),$mimefilename_list=array(), $filename_list=array(),$mimetype_list=array(),$mimefilename_list=array(),
@ -781,9 +781,8 @@ class CMailFile
/** /**
* Try to create a socket connection * Try to create a socket connection
* * @param $host Add ssl:// for SSL/TLS.
* @param $host. Add ssl:// for SSL/TLS. * @param $port Example: 25, 465
* @param $port. Example: 25, 465
* @return Socket id if ok, 0 if KO * @return Socket id if ok, 0 if KO
*/ */
function check_server_port($host,$port) function check_server_port($host,$port)
@ -939,7 +938,6 @@ class CMailFile
/** /**
* Return an address for SMTP protocol * Return an address for SMTP protocol
*
* @param adresses Example: 'John Doe <john@doe.com>' or 'john@doe.com' * @param adresses Example: 'John Doe <john@doe.com>' or 'john@doe.com'
* @param format 0=Auto, 1=emails with <>, 2=emails without <> * @param format 0=Auto, 1=emails with <>, 2=emails without <>
* @param encode 1=Encode name to RFC2822 * @param encode 1=Encode name to RFC2822

View File

@ -25,7 +25,7 @@
/** /**
* \file htdocs/lib/CSMSFile.class.php * \file htdocs/lib/CSMSFile.class.php
* \brief File of class to send sms * \brief File of class to send sms
* \version $Id$ * \version $Id: CSMSFile.class.php,v 1.4 2011/07/04 09:36:29 eldy Exp $
* \author Laurent Destailleur. * \author Laurent Destailleur.
*/ */
@ -54,6 +54,9 @@ class CSMSFile
* @param from Sender SMS * @param from Sender SMS
* @param msg Message * @param msg Message
* @param deliveryreceipt Ask a delivery receipt * @param deliveryreceipt Ask a delivery receipt
* @param deferred Deferred or not
* @param priority Priority
* @param class Class
*/ */
function CSMSFile($to,$from,$msg,$deliveryreceipt=0,$deferred=0,$priority=3,$class=1) function CSMSFile($to,$from,$msg,$deliveryreceipt=0,$deferred=0,$priority=3,$class=1)
{ {