Merge remote-tracking branch 'upstream/develop' into develop

# Conflicts:
#	htdocs/product/class/product.class.php
This commit is contained in:
Juanjo Menent 2018-10-15 13:40:42 +02:00
commit 194b3478f3
2 changed files with 115 additions and 113 deletions

View File

@ -4116,18 +4116,18 @@ class Facture extends CommonInvoice
$langs->load("bills"); $langs->load("bills");
if (! dol_strlen($modele)) { if (! dol_strlen($modele))
{
$modele = 'crabe';
$thisTypeConfName = 'FACTURE_ADDON_PDF_'.$this->type;
$modele = 'crabe'; if ($this->modelpdf) {
$thisTypeConfName = 'FACTURE_ADDON_PDF_'.$type; $modele = $this->modelpdf;
} elseif (! empty($conf->global->$thisTypeConfName)) {
if ($this->modelpdf) { $modele = $conf->global->$thisTypeConfName;
$modele = $this->modelpdf; } elseif (! empty($conf->global->FACTURE_ADDON_PDF)) {
}elseif (! empty($conf->global->{'FACTURE_ADDON_PDF_'.$this->type})){ $modele = $conf->global->FACTURE_ADDON_PDF;
$modele = $conf->global->{'FACTURE_ADDON_PDF_'.$this->type} ; }
}elseif (! empty($conf->global->FACTURE_ADDON_PDF)) {
$modele = $conf->global->FACTURE_ADDON_PDF;
}
} }
$modelpath = "core/modules/facture/doc/"; $modelpath = "core/modules/facture/doc/";

View File

@ -299,7 +299,7 @@ class Product extends CommonObject
/** /**
* @deprecated * @deprecated
* @see ref_supplier * @see $ref_supplier
*/ */
public $ref_fourn; public $ref_fourn;
public $ref_supplier; public $ref_supplier;
@ -3282,7 +3282,7 @@ class Product extends CommonObject
* *
* @param int $fromId Id product source * @param int $fromId Id product source
* @param int $toId Id product target * @param int $toId Id product target
* @return nt < 0 if KO, > 0 if OK * @return int < 0 if KO, > 0 if OK
*/ */
function clone_price($fromId, $toId) function clone_price($fromId, $toId)
{ {
@ -4025,7 +4025,7 @@ class Product extends CommonObject
* 'warehouseclosed' = Load stock from closed warehouses only, * 'warehouseclosed' = Load stock from closed warehouses only,
* 'warehouseinternal' = Load stock from warehouses for internal correction/transfer only * 'warehouseinternal' = Load stock from warehouses for internal correction/transfer only
* @return int < 0 if KO, > 0 if OK * @return int < 0 if KO, > 0 if OK
* @see load_virtual_stock, getBatchInfo * @see load_virtual_stock(), loadBatchInfo()
*/ */
function load_stock($option='') function load_stock($option='')
{ {
@ -4094,67 +4094,67 @@ class Product extends CommonObject
} }
} }
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/** /**
* Load value ->stock_theorique of a product. Property this->id must be defined. * Load value ->stock_theorique of a product. Property this->id must be defined.
* This function need a lot of load. If you use it on list, use a cache to execute it one for each product id. * This function need a lot of load. If you use it on list, use a cache to execute it one for each product id.
* *
* @return int < 0 if KO, > 0 if OK * @return int < 0 if KO, > 0 if OK
* @see load_stock, getBatchInfo * @see load_stock(), loadBatchInfo()
*/ */
function load_virtual_stock() function load_virtual_stock()
{ {
// phpcs:enable // phpcs:enable
global $conf, $hookmanager, $action; global $conf, $hookmanager, $action;
$stock_commande_client=0; $stock_commande_client=0;
$stock_commande_fournisseur=0; $stock_commande_fournisseur=0;
$stock_sending_client=0; $stock_sending_client=0;
$stock_reception_fournisseur=0; $stock_reception_fournisseur=0;
if (! empty($conf->commande->enabled)) if (! empty($conf->commande->enabled))
{ {
$result=$this->load_stats_commande(0,'1,2', 1); $result=$this->load_stats_commande(0,'1,2', 1);
if ($result < 0) dol_print_error($this->db,$this->error); if ($result < 0) dol_print_error($this->db,$this->error);
$stock_commande_client=$this->stats_commande['qty']; $stock_commande_client=$this->stats_commande['qty'];
} }
if (! empty($conf->expedition->enabled)) if (! empty($conf->expedition->enabled))
{ {
$result=$this->load_stats_sending(0,'1,2', 1); $result=$this->load_stats_sending(0,'1,2', 1);
if ($result < 0) dol_print_error($this->db,$this->error); if ($result < 0) dol_print_error($this->db,$this->error);
$stock_sending_client=$this->stats_expedition['qty']; $stock_sending_client=$this->stats_expedition['qty'];
} }
if (! empty($conf->fournisseur->enabled)) if (! empty($conf->fournisseur->enabled))
{ {
$result=$this->load_stats_commande_fournisseur(0,'1,2,3,4', 1); $result=$this->load_stats_commande_fournisseur(0,'1,2,3,4', 1);
if ($result < 0) dol_print_error($this->db,$this->error); if ($result < 0) dol_print_error($this->db,$this->error);
$stock_commande_fournisseur=$this->stats_commande_fournisseur['qty']; $stock_commande_fournisseur=$this->stats_commande_fournisseur['qty'];
$result=$this->load_stats_reception(0,'4', 1); $result=$this->load_stats_reception(0,'4', 1);
if ($result < 0) dol_print_error($this->db,$this->error); if ($result < 0) dol_print_error($this->db,$this->error);
$stock_reception_fournisseur=$this->stats_reception['qty']; $stock_reception_fournisseur=$this->stats_reception['qty'];
} }
// Stock decrease mode // Stock decrease mode
if (! empty($conf->global->STOCK_CALCULATE_ON_SHIPMENT) || ! empty($conf->global->STOCK_CALCULATE_ON_SHIPMENT_CLOSE)) { if (! empty($conf->global->STOCK_CALCULATE_ON_SHIPMENT) || ! empty($conf->global->STOCK_CALCULATE_ON_SHIPMENT_CLOSE)) {
$this->stock_theorique=$this->stock_reel-$stock_commande_client+$stock_sending_client; $this->stock_theorique=$this->stock_reel-$stock_commande_client+$stock_sending_client;
} }
if (! empty($conf->global->STOCK_CALCULATE_ON_VALIDATE_ORDER)) { if (! empty($conf->global->STOCK_CALCULATE_ON_VALIDATE_ORDER)) {
$this->stock_theorique=$this->stock_reel; $this->stock_theorique=$this->stock_reel;
} }
if (! empty($conf->global->STOCK_CALCULATE_ON_BILL)) { if (! empty($conf->global->STOCK_CALCULATE_ON_BILL)) {
$this->stock_theorique=$this->stock_reel-$stock_commande_client; $this->stock_theorique=$this->stock_reel-$stock_commande_client;
} }
// Stock Increase mode // Stock Increase mode
if (! empty($conf->global->STOCK_CALCULATE_ON_SUPPLIER_DISPATCH_ORDER)) { if (! empty($conf->global->STOCK_CALCULATE_ON_SUPPLIER_DISPATCH_ORDER)) {
$this->stock_theorique+=$stock_commande_fournisseur-$stock_reception_fournisseur; $this->stock_theorique+=$stock_commande_fournisseur-$stock_reception_fournisseur;
} }
if (! empty($conf->global->STOCK_CALCULATE_ON_SUPPLIER_VALIDATE_ORDER)) { if (! empty($conf->global->STOCK_CALCULATE_ON_SUPPLIER_VALIDATE_ORDER)) {
$this->stock_theorique-=$stock_reception_fournisseur; $this->stock_theorique-=$stock_reception_fournisseur;
} }
if (! empty($conf->global->STOCK_CALCULATE_ON_SUPPLIER_BILL)) { if (! empty($conf->global->STOCK_CALCULATE_ON_SUPPLIER_BILL)) {
$this->stock_theorique+=$stock_commande_fournisseur-$stock_reception_fournisseur; $this->stock_theorique+=$stock_commande_fournisseur-$stock_reception_fournisseur;
} }
if (! is_object($hookmanager)) { if (! is_object($hookmanager)) {
include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'; include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php';
@ -4165,7 +4165,9 @@ class Product extends CommonObject
// Note that $action and $object may have been modified by some hooks // Note that $action and $object may have been modified by some hooks
$reshook=$hookmanager->executeHooks('loadvirtualstock', $parameters, $this, $action); $reshook=$hookmanager->executeHooks('loadvirtualstock', $parameters, $this, $action);
if ($reshook > 0) $this->stock_theorique = $hookmanager->resArray['stock_theorique']; if ($reshook > 0) $this->stock_theorique = $hookmanager->resArray['stock_theorique'];
}
return 1;
}
/** /**
@ -4173,7 +4175,7 @@ class Product extends CommonObject
* *
* @param string $batch Lot/serial number * @param string $batch Lot/serial number
* @return array Array with record into product_batch * @return array Array with record into product_batch
* @see load_stock, load_virtual_stock * @see load_stock(), load_virtual_stock()
*/ */
function loadBatchInfo($batch) function loadBatchInfo($batch)
{ {
@ -4769,51 +4771,51 @@ class Product extends CommonObject
} }
} }
/** /**
* Load information for tab info * Load information for tab info
* *
* @param int $id Id of thirdparty to load * @param int $id Id of thirdparty to load
* @return void * @return void
*/ */
function info($id) function info($id)
{ {
$sql = "SELECT p.rowid, p.ref, p.datec as date_creation, p.tms as date_modification,"; $sql = "SELECT p.rowid, p.ref, p.datec as date_creation, p.tms as date_modification,";
$sql.= " p.fk_user_author, p.fk_user_modif"; $sql.= " p.fk_user_author, p.fk_user_modif";
$sql.= " FROM ".MAIN_DB_PREFIX.$this->table_element." as p"; $sql.= " FROM ".MAIN_DB_PREFIX.$this->table_element." as p";
$sql.= " WHERE p.rowid = ".$id; $sql.= " WHERE p.rowid = ".$id;
$result=$this->db->query($sql); $result=$this->db->query($sql);
if ($result) if ($result)
{
if ($this->db->num_rows($result))
{
$obj = $this->db->fetch_object($result);
$this->id = $obj->rowid;
if ($obj->fk_user_author) {
$cuser = new User($this->db);
$cuser->fetch($obj->fk_user_author);
$this->user_creation = $cuser;
}
if ($obj->fk_user_modif) {
$muser = new User($this->db);
$muser->fetch($obj->fk_user_modif);
$this->user_modification = $muser;
}
$this->ref = $obj->ref;
$this->date_creation = $this->db->jdate($obj->date_creation);
$this->date_modification = $this->db->jdate($obj->date_modification);
}
$this->db->free($result);
}
else
{ {
dol_print_error($this->db); if ($this->db->num_rows($result))
} {
} $obj = $this->db->fetch_object($result);
}
$this->id = $obj->rowid;
if ($obj->fk_user_author) {
$cuser = new User($this->db);
$cuser->fetch($obj->fk_user_author);
$this->user_creation = $cuser;
}
if ($obj->fk_user_modif) {
$muser = new User($this->db);
$muser->fetch($obj->fk_user_modif);
$this->user_modification = $muser;
}
$this->ref = $obj->ref;
$this->date_creation = $this->db->jdate($obj->date_creation);
$this->date_modification = $this->db->jdate($obj->date_modification);
}
$this->db->free($result);
}
else
{
dol_print_error($this->db);
}
}
}