diff --git a/htdocs/admin/system/filecheck.php b/htdocs/admin/system/filecheck.php
index a110e19b172..94d8909e063 100644
--- a/htdocs/admin/system/filecheck.php
+++ b/htdocs/admin/system/filecheck.php
@@ -339,8 +339,8 @@ if (! $error && $xml)
$out.='
'.$i.' | ' . "\n";
$out.=''.$file['filename'];
if (! preg_match('/^win/i', PHP_OS)) {
- $htmltext=$langs->trans("YouCanDeleteFileOnServerWith", 'rm '.DOL_DOCUMENT_ROOT.'/'.$file['filename']);
- $out.=' '.$form->textwithpicto('', $htmltext, 1, 'help', '', 0, 2, 'helprm');
+ $htmltext=$langs->trans("YouCanDeleteFileOnServerWith", 'rm '.DOL_DOCUMENT_ROOT.$file['filename']); // The slash is included int file['filename']
+ $out.=' '.$form->textwithpicto('', $htmltext, 1, 'help', '', 0, 2, 'helprm'.$i);
}
$out.=' | ' . "\n";
$out.=''.$file['expectedmd5'].' | ' . "\n";
diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php
index 0f1b420f66e..01ef8b4c7c3 100644
--- a/htdocs/compta/facture/card.php
+++ b/htdocs/compta/facture/card.php
@@ -1131,7 +1131,7 @@ if (empty($reshook))
// Source facture
$object->fac_rec = GETPOST('fac_rec', 'int');
- $id = $object->create($user); // This include recopy of links from recurring invoice and invoice lines
+ $id = $object->create($user); // This include recopy of links from recurring invoice and recurring invoice lines
}
}
diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php
index 5e2db021f83..7b34ad4e895 100644
--- a/htdocs/compta/facture/class/facture.class.php
+++ b/htdocs/compta/facture/class/facture.class.php
@@ -723,7 +723,7 @@ class Facture extends CommonInvoice
}
/*
- * Insert lines of predefined invoices
+ * Insert lines of template invoices
*/
if (! $error && $this->fac_rec > 0)
{
@@ -749,7 +749,32 @@ class Facture extends CommonInvoice
$localtax1_tx = $_facrec->lines[$i]->localtax1_tx;
$localtax2_tx = $_facrec->lines[$i]->localtax2_tx;
- $result_insert = $this->addline(
+ $fk_product_fournisseur_price = empty($_facrec->lines[$i]->fk_product_fournisseur_price)?null:$_facrec->lines[$i]->fk_product_fournisseur_price;
+ $buyprice = empty($_facrec->lines[$i]->buyprice)?0:$_facrec->lines[$i]->buyprice;
+ // If buyprice not defined from template invoice, we try to guess the best value
+ if (! $buyprice && $_facrec->lines[$i]->fk_product > 0)
+ {
+ require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.product.class.php';
+ $producttmp = new ProductFournisseur($this->db);
+ $producttmp->fetch($_facrec->lines[$i]->fk_product);
+
+ // If margin module defined on costprice, we try the costprice
+ // If not defined or if module margin defined and pmp and stock module enabled, we try pmp price
+ // else we get the best supplier price
+ if ($conf->global->MARGIN_TYPE == 'costprice' && ! empty($producttmp->cost_price)) $buyprice = $producttmp->cost_price;
+ elseif (! empty($conf->stock->enabled) && ($conf->global->MARGIN_TYPE == 'costprice' || $conf->global->MARGIN_TYPE == 'pmp') && ! empty($producttmp->pmp)) $buyprice = $producttmp->pmp;
+ else {
+ if ($producttmp->find_min_price_product_fournisseur($_facrec->lines[$i]->fk_product) > 0)
+ {
+ if ($producttmp->product_fourn_price_id > 0)
+ {
+ $buyprice = price2num($producttmp->fourn_unitprice * (1 - $producttmp->fourn_remise_percent/100) + $producttmp->fourn_remise, 'MU');
+ }
+ }
+ }
+ }
+
+ $result_insert = $this->addline(
$_facrec->lines[$i]->desc,
$_facrec->lines[$i]->subprice,
$_facrec->lines[$i]->qty,
@@ -771,8 +796,8 @@ class Facture extends CommonInvoice
'',
0,
0,
- null,
- 0,
+ $fk_product_fournisseur_price,
+ $buyprice,
$_facrec->lines[$i]->label,
empty($_facrec->lines[$i]->array_options)?null:$_facrec->lines[$i]->array_options,
$_facrec->lines[$i]->situation_percent,
@@ -4273,9 +4298,9 @@ class Facture extends CommonInvoice
/**
* Function used to replace a thirdparty id with another one.
*
- * @param DoliDB $db Database handler
- * @param int $origin_id Old thirdparty id
- * @param int $dest_id New thirdparty id
+ * @param DoliDB $db Database handler
+ * @param int $origin_id Old thirdparty id
+ * @param int $dest_id New thirdparty id
* @return bool
*/
public static function replaceThirdparty(DoliDB $db, $origin_id, $dest_id)
diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php
index f6232fd9394..e962e59264c 100644
--- a/htdocs/core/class/commonobject.class.php
+++ b/htdocs/core/class/commonobject.class.php
@@ -6378,6 +6378,7 @@ abstract class CommonObject
}
if (($mode == 'create' || $mode == 'edit') && abs($visibility) != 1 && abs($visibility) != 3) continue; // <> -1 and <> 1 and <> 3 = not visible on forms, only on list
+ elseif($mode == 'view' && empty($visibility)) continue;
if (empty($perms)) continue;
// Load language if required
diff --git a/htdocs/install/upgrade2.php b/htdocs/install/upgrade2.php
index 1b3a69306eb..45b5f8fe95c 100644
--- a/htdocs/install/upgrade2.php
+++ b/htdocs/install/upgrade2.php
@@ -186,7 +186,7 @@ if (! GETPOST('action', 'aZ09') || preg_match('/upgrade/i', GETPOST('action', 'a
{
// Current version is $conf->global->MAIN_VERSION_LAST_UPGRADE
// Version to install is DOL_VERSION
- $dolibarrlastupgradeversionarray=preg_split('/[\.-]/', isset($conf->global->MAIN_VERSION_LAST_UPGRADE)?$conf->global->MAIN_VERSION_LAST_UPGRADE:$conf->global->MAIN_VERSION_LAST_INSTALL);
+ $dolibarrlastupgradeversionarray=preg_split('/[\.-]/', isset($conf->global->MAIN_VERSION_LAST_UPGRADE)?$conf->global->MAIN_VERSION_LAST_UPGRADE:(isset($conf->global->MAIN_VERSION_LAST_INSTALL)?$conf->global->MAIN_VERSION_LAST_INSTALL:''));
// Chaque action de migration doit renvoyer une ligne sur 4 colonnes avec
// dans la 1ere colonne, la description de l'action a faire
diff --git a/htdocs/langs/en_US/blockedlog.lang b/htdocs/langs/en_US/blockedlog.lang
index 6cc85024843..cff8f7d657b 100644
--- a/htdocs/langs/en_US/blockedlog.lang
+++ b/htdocs/langs/en_US/blockedlog.lang
@@ -14,9 +14,9 @@ OkCheckFingerprintValidityButChainIsKo=Archived log seems valid compared to prev
AddedByAuthority=Stored into remote authority
NotAddedByAuthorityYet=Not yet stored into remote authority
ShowDetails=Show stored details
-logPAYMENT_VARIOUS_CREATE=Payment (not assigned to invoice) created
-logPAYMENT_VARIOUS_MODIFY=Payment (not assigned to invoice) modified
-logPAYMENT_VARIOUS_DELETE=Payment (not assigned to invoice) logical deletion
+logPAYMENT_VARIOUS_CREATE=Payment (not assigned to an invoice) created
+logPAYMENT_VARIOUS_MODIFY=Payment (not assigned to an invoice) modified
+logPAYMENT_VARIOUS_DELETE=Payment (not assigned to an invoice) logical deletion
logPAYMENT_ADD_TO_BANK=Payment added to bank
logPAYMENT_CUSTOMER_CREATE=Customer payment created
logPAYMENT_CUSTOMER_DELETE=Customer payment logical deletion
diff --git a/htdocs/product/class/product.class.php b/htdocs/product/class/product.class.php
index 9ef3ba450cf..0721016a8aa 100644
--- a/htdocs/product/class/product.class.php
+++ b/htdocs/product/class/product.class.php
@@ -1561,7 +1561,7 @@ class Product extends CommonObject
* @param Societe $thirdparty_buyer Buyer
* @param int $pqp Id of product per price if a selection was done of such a price
* @return array Array of price information
- * @see get_buyprice()
+ * @see get_buyprice(), find_min_price_product_fournisseur()
*/
public function getSellPrice($thirdparty_seller, $thirdparty_buyer, $pqp = 0)
{
@@ -1672,8 +1672,8 @@ class Product extends CommonObject
* @param int $product_id Filter on a particular product id
* @param string $fourn_ref Filter on a supplier price ref. 'none' to exclude ref in search.
* @param int $fk_soc If of supplier
- * @return int <-1 if KO, -1 if qty not enough, 0 if OK but nothing found, id_product if OK and found. May also initialize some properties like (->ref_supplier, buyprice, fourn_pu, vatrate_supplier...)
- * @see getSellPrice()
+ * @return int <-1 if KO, -1 if qty not enough, 0 if OK but nothing found, id_product if OK and found. May also initialize some properties like (->ref_supplier, buyprice, fourn_pu, vatrate_supplier...)
+ * @see getSellPrice(), find_min_price_product_fournisseur()
*/
public function get_buyprice($prodfournprice, $qty, $product_id = 0, $fourn_ref = '', $fk_soc = 0)
{