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");
if (! dol_strlen($modele)) {
if (! dol_strlen($modele))
{
$modele = 'crabe';
$thisTypeConfName = 'FACTURE_ADDON_PDF_'.$this->type;
$modele = 'crabe';
$thisTypeConfName = 'FACTURE_ADDON_PDF_'.$type;
if ($this->modelpdf) {
$modele = $this->modelpdf;
}elseif (! empty($conf->global->{'FACTURE_ADDON_PDF_'.$this->type})){
$modele = $conf->global->{'FACTURE_ADDON_PDF_'.$this->type} ;
}elseif (! empty($conf->global->FACTURE_ADDON_PDF)) {
$modele = $conf->global->FACTURE_ADDON_PDF;
}
if ($this->modelpdf) {
$modele = $this->modelpdf;
} elseif (! empty($conf->global->$thisTypeConfName)) {
$modele = $conf->global->$thisTypeConfName;
} elseif (! empty($conf->global->FACTURE_ADDON_PDF)) {
$modele = $conf->global->FACTURE_ADDON_PDF;
}
}
$modelpath = "core/modules/facture/doc/";

View File

@ -299,7 +299,7 @@ class Product extends CommonObject
/**
* @deprecated
* @see ref_supplier
* @see $ref_supplier
*/
public $ref_fourn;
public $ref_supplier;
@ -3282,7 +3282,7 @@ class Product extends CommonObject
*
* @param int $fromId Id product source
* @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)
{
@ -4025,7 +4025,7 @@ class Product extends CommonObject
* 'warehouseclosed' = Load stock from closed warehouses only,
* 'warehouseinternal' = Load stock from warehouses for internal correction/transfer only
* @return int < 0 if KO, > 0 if OK
* @see load_virtual_stock, getBatchInfo
* @see load_virtual_stock(), loadBatchInfo()
*/
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.
* 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
* @see load_stock, getBatchInfo
* @see load_stock(), loadBatchInfo()
*/
function load_virtual_stock()
{
// phpcs:enable
global $conf, $hookmanager, $action;
function load_virtual_stock()
{
// phpcs:enable
global $conf, $hookmanager, $action;
$stock_commande_client=0;
$stock_commande_fournisseur=0;
$stock_sending_client=0;
$stock_reception_fournisseur=0;
$stock_commande_client=0;
$stock_commande_fournisseur=0;
$stock_sending_client=0;
$stock_reception_fournisseur=0;
if (! empty($conf->commande->enabled))
{
$result=$this->load_stats_commande(0,'1,2', 1);
if ($result < 0) dol_print_error($this->db,$this->error);
$stock_commande_client=$this->stats_commande['qty'];
}
if (! empty($conf->expedition->enabled))
{
$result=$this->load_stats_sending(0,'1,2', 1);
if ($result < 0) dol_print_error($this->db,$this->error);
$stock_sending_client=$this->stats_expedition['qty'];
}
if (! empty($conf->fournisseur->enabled))
{
$result=$this->load_stats_commande_fournisseur(0,'1,2,3,4', 1);
if ($result < 0) dol_print_error($this->db,$this->error);
$stock_commande_fournisseur=$this->stats_commande_fournisseur['qty'];
if (! empty($conf->commande->enabled))
{
$result=$this->load_stats_commande(0,'1,2', 1);
if ($result < 0) dol_print_error($this->db,$this->error);
$stock_commande_client=$this->stats_commande['qty'];
}
if (! empty($conf->expedition->enabled))
{
$result=$this->load_stats_sending(0,'1,2', 1);
if ($result < 0) dol_print_error($this->db,$this->error);
$stock_sending_client=$this->stats_expedition['qty'];
}
if (! empty($conf->fournisseur->enabled))
{
$result=$this->load_stats_commande_fournisseur(0,'1,2,3,4', 1);
if ($result < 0) dol_print_error($this->db,$this->error);
$stock_commande_fournisseur=$this->stats_commande_fournisseur['qty'];
$result=$this->load_stats_reception(0,'4', 1);
if ($result < 0) dol_print_error($this->db,$this->error);
$stock_reception_fournisseur=$this->stats_reception['qty'];
}
$result=$this->load_stats_reception(0,'4', 1);
if ($result < 0) dol_print_error($this->db,$this->error);
$stock_reception_fournisseur=$this->stats_reception['qty'];
}
// Stock decrease mode
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;
}
if (! empty($conf->global->STOCK_CALCULATE_ON_VALIDATE_ORDER)) {
$this->stock_theorique=$this->stock_reel;
}
if (! empty($conf->global->STOCK_CALCULATE_ON_BILL)) {
$this->stock_theorique=$this->stock_reel-$stock_commande_client;
}
// Stock Increase mode
if (! empty($conf->global->STOCK_CALCULATE_ON_SUPPLIER_DISPATCH_ORDER)) {
$this->stock_theorique+=$stock_commande_fournisseur-$stock_reception_fournisseur;
}
if (! empty($conf->global->STOCK_CALCULATE_ON_SUPPLIER_VALIDATE_ORDER)) {
$this->stock_theorique-=$stock_reception_fournisseur;
}
if (! empty($conf->global->STOCK_CALCULATE_ON_SUPPLIER_BILL)) {
$this->stock_theorique+=$stock_commande_fournisseur-$stock_reception_fournisseur;
}
// Stock decrease mode
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;
}
if (! empty($conf->global->STOCK_CALCULATE_ON_VALIDATE_ORDER)) {
$this->stock_theorique=$this->stock_reel;
}
if (! empty($conf->global->STOCK_CALCULATE_ON_BILL)) {
$this->stock_theorique=$this->stock_reel-$stock_commande_client;
}
// Stock Increase mode
if (! empty($conf->global->STOCK_CALCULATE_ON_SUPPLIER_DISPATCH_ORDER)) {
$this->stock_theorique+=$stock_commande_fournisseur-$stock_reception_fournisseur;
}
if (! empty($conf->global->STOCK_CALCULATE_ON_SUPPLIER_VALIDATE_ORDER)) {
$this->stock_theorique-=$stock_reception_fournisseur;
}
if (! empty($conf->global->STOCK_CALCULATE_ON_SUPPLIER_BILL)) {
$this->stock_theorique+=$stock_commande_fournisseur-$stock_reception_fournisseur;
}
if (! is_object($hookmanager)) {
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
$reshook=$hookmanager->executeHooks('loadvirtualstock', $parameters, $this, $action);
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
* @return array Array with record into product_batch
* @see load_stock, load_virtual_stock
* @see load_stock(), load_virtual_stock()
*/
function loadBatchInfo($batch)
{
@ -4769,51 +4771,51 @@ class Product extends CommonObject
}
}
/**
* Load information for tab info
*
* @param int $id Id of thirdparty to load
* @return void
*/
function info($id)
{
$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.= " FROM ".MAIN_DB_PREFIX.$this->table_element." as p";
$sql.= " WHERE p.rowid = ".$id;
/**
* Load information for tab info
*
* @param int $id Id of thirdparty to load
* @return void
*/
function info($id)
{
$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.= " FROM ".MAIN_DB_PREFIX.$this->table_element." as p";
$sql.= " WHERE p.rowid = ".$id;
$result=$this->db->query($sql);
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
$result=$this->db->query($sql);
if ($result)
{
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);
}
}
}