2
0
forked from Wavyzz/dolibarr

Merge branch '12.0' of git@github.com:Dolibarr/dolibarr.git into develop

Conflicts:
	htdocs/variants/class/ProductCombination.class.php
This commit is contained in:
Laurent Destailleur
2020-05-23 15:37:00 +02:00
10 changed files with 124 additions and 116 deletions

View File

@@ -1025,7 +1025,7 @@ if (empty($reshook))
// Replacement invoice // Replacement invoice
if ($_POST['type'] == Facture::TYPE_REPLACEMENT) if ($_POST['type'] == Facture::TYPE_REPLACEMENT)
{ {
$dateinvoice = dol_mktime(12, 0, 0, $_POST['remonth'], $_POST['reday'], $_POST['reyear']); $dateinvoice = dol_mktime(12, 0, 0, GETPOST('remonth', 'int'), GETPOST('reday', 'int'), GETPOST('reyear', 'int'));
if (empty($dateinvoice)) if (empty($dateinvoice))
{ {
$error++; $error++;
@@ -1086,7 +1086,7 @@ if (empty($reshook))
$action = 'create'; $action = 'create';
} }
$dateinvoice = dol_mktime(12, 0, 0, $_POST['remonth'], $_POST['reday'], $_POST['reyear']); $dateinvoice = dol_mktime(12, 0, 0, GETPOST('remonth', 'int'), GETPOST('reday', 'int'), GETPOST('reyear', 'int'));
if (empty($dateinvoice)) if (empty($dateinvoice))
{ {
$error++; $error++;
@@ -1269,7 +1269,7 @@ if (empty($reshook))
// Standard invoice or Deposit invoice, created from a Predefined template invoice // Standard invoice or Deposit invoice, created from a Predefined template invoice
if (($_POST['type'] == Facture::TYPE_STANDARD || $_POST['type'] == Facture::TYPE_DEPOSIT) && GETPOST('fac_rec', 'int') > 0) if (($_POST['type'] == Facture::TYPE_STANDARD || $_POST['type'] == Facture::TYPE_DEPOSIT) && GETPOST('fac_rec', 'int') > 0)
{ {
$dateinvoice = dol_mktime(12, 0, 0, $_POST['remonth'], $_POST['reday'], $_POST['reyear']); $dateinvoice = dol_mktime(12, 0, 0, GETPOST('remonth', 'int'), GETPOST('reday', 'int'), GETPOST('reyear', 'int'));
if (empty($dateinvoice)) if (empty($dateinvoice))
{ {
$error++; $error++;
@@ -1320,7 +1320,7 @@ if (empty($reshook))
$action = 'create'; $action = 'create';
} }
$dateinvoice = dol_mktime(12, 0, 0, $_POST['remonth'], $_POST['reday'], $_POST['reyear']); $dateinvoice = dol_mktime(12, 0, 0, GETPOST('remonth', 'int'), GETPOST('reday', 'int'), GETPOST('reyear', 'int'));
if (empty($dateinvoice)) if (empty($dateinvoice))
{ {
$error++; $error++;
@@ -1745,7 +1745,7 @@ if (empty($reshook))
// Situation invoices // Situation invoices
if (GETPOST('type') == Facture::TYPE_SITUATION && (!empty($_POST['situations']))) if (GETPOST('type') == Facture::TYPE_SITUATION && (!empty($_POST['situations'])))
{ {
$datefacture = dol_mktime(12, 0, 0, $_POST['remonth'], $_POST['reday'], $_POST['reyear']); $datefacture = dol_mktime(12, 0, 0, GETPOST('remonth', 'int'), GETPOST('reday', 'int'), GETPOST('reyear', 'int'));
if (empty($datefacture)) { if (empty($datefacture)) {
$error++; $error++;
$mesg = $langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Date")); $mesg = $langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Date"));

View File

@@ -157,9 +157,14 @@ function dolSavePageContent($filetpl, Website $object, WebsitePage $objectpage)
$tplcontent .= '<meta name="description" content="'.dol_string_nohtmltag($objectpage->description, 0, 'UTF-8').'" />'."\n"; $tplcontent .= '<meta name="description" content="'.dol_string_nohtmltag($objectpage->description, 0, 'UTF-8').'" />'."\n";
$tplcontent .= '<meta name="generator" content="'.DOL_APPLICATION_TITLE.' '.DOL_VERSION.' (https://www.dolibarr.org)" />'."\n"; $tplcontent .= '<meta name="generator" content="'.DOL_APPLICATION_TITLE.' '.DOL_VERSION.' (https://www.dolibarr.org)" />'."\n";
$tplcontent .= '<meta name="dolibarr:pageid" content="'.dol_string_nohtmltag($objectpage->id).'" />'."\n"; $tplcontent .= '<meta name="dolibarr:pageid" content="'.dol_string_nohtmltag($objectpage->id).'" />'."\n";
// Add canonical reference
if ($object->virtualhost) {
$tplcontent .= '<link rel="canonical" href="'.(($objectpage->id == $object->fk_default_home) ? '/' : (($shortlangcode != substr($object->lang, 0, 2) ? '/'.$shortlangcode : '').'/'.$objectpage->pageurl.'.php')).'" />'."\n";
}
// Add translation reference (main language) // Add translation reference (main language)
if ($object->isMultiLang()) { if ($object->isMultiLang()) {
// Add myself // Add myself
$tplcontent .= '<?php if ($_SERVER["PHP_SELF"] == "/'.$objectpage->pageurl.'.php") { ?>'."\n";
$tplcontent .= '<link rel="alternate" hreflang="'.$shortlangcode.'" href="'.(($object->fk_default_home == $objectpage->id) ? '/' : (($shortlangcode != substr($object->lang, 0, 2) ? '/'.$shortlangcode : '')).'/'.$objectpage->pageurl.'.php').'" />'."\n"; $tplcontent .= '<link rel="alternate" hreflang="'.$shortlangcode.'" href="'.(($object->fk_default_home == $objectpage->id) ? '/' : (($shortlangcode != substr($object->lang, 0, 2) ? '/'.$shortlangcode : '')).'/'.$objectpage->pageurl.'.php').'" />'."\n";
// Add page "translation of" // Add page "translation of"
@@ -194,10 +199,7 @@ function dolSavePageContent($filetpl, Website $object, WebsitePage $objectpage)
} }
} }
else dol_print_error($db); else dol_print_error($db);
} $tplcontent .= '<?php } ?>'."\n";
// Add canonical reference
if ($object->virtualhost) {
$tplcontent .= '<link rel="canonical" href="'.(($objectpage->id == $object->fk_default_home) ? '/' : (($shortlangcode != substr($object->lang, 0, 2) ? '/'.$shortlangcode : '').'/'.$objectpage->pageurl.'.php')).'" />'."\n";
} }
// Add manifest.json on homepage // Add manifest.json on homepage
$tplcontent .= '<?php if ($website->use_manifest) { print \'<link rel="manifest" href="/manifest.json.php" />\'."\n"; } ?>'."\n"; $tplcontent .= '<?php if ($website->use_manifest) { print \'<link rel="manifest" href="/manifest.json.php" />\'."\n"; } ?>'."\n";

View File

@@ -1,6 +1,6 @@
<?php <?php
/* Copyright (C) 2018 Nicolas ZABOURI <info@inovea-conseil.com> /* Copyright (C) 2018 Nicolas ZABOURI <info@inovea-conseil.com>
* Copyright (C) 2018 Frédéric France <frederic.france@netlogic.fr> * Copyright (C) 2018-2020 Frédéric France <frederic.france@netlogic.fr>
* *
* This program is free software: you can redistribute it and/or modify * This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
@@ -482,7 +482,7 @@ class DataPolicyCron
while ($i < $num && !$error) while ($i < $num && !$error)
{ {
$obj = $db->fetch_object($resql); $obj = $this->db->fetch_object($resql);
$object->fetch($obj->rowid); $object->fetch($obj->rowid);
$object->id = $obj->rowid; $object->id = $obj->rowid;

View File

@@ -644,7 +644,7 @@ if (empty($reshook))
$ret = $extrafields->setOptionalsFromPost(null, $object); $ret = $extrafields->setOptionalsFromPost(null, $object);
if ($ret < 0) $error++; if ($ret < 0) $error++;
$datefacture = dol_mktime(12, 0, 0, $_POST['remonth'], $_POST['reday'], $_POST['reyear']); $datefacture = dol_mktime(12, 0, 0, GETPOST('remonth', 'int'), GETPOST('reday', 'int'), GETPOST('reyear', 'int'));
$datedue = dol_mktime(12, 0, 0, $_POST['echmonth'], $_POST['echday'], $_POST['echyear']); $datedue = dol_mktime(12, 0, 0, $_POST['echmonth'], $_POST['echday'], $_POST['echyear']);
// Replacement invoice // Replacement invoice
@@ -1758,7 +1758,7 @@ if ($action == 'create')
if (!empty($conf->global->MULTICURRENCY_USE_ORIGIN_TX) && !empty($objectsrc->multicurrency_tx)) $currency_tx = $objectsrc->multicurrency_tx; if (!empty($conf->global->MULTICURRENCY_USE_ORIGIN_TX) && !empty($objectsrc->multicurrency_tx)) $currency_tx = $objectsrc->multicurrency_tx;
} }
$datetmp = dol_mktime(12, 0, 0, $_POST['remonth'], $_POST['reday'], $_POST['reyear']); $datetmp = dol_mktime(12, 0, 0, GETPOST('remonth', 'int'), GETPOST('reday', 'int'), GETPOST('reyear', 'int'));
$dateinvoice = ($datetmp == '' ? (empty($conf->global->MAIN_AUTOFILL_DATE) ?-1 : '') : $datetmp); $dateinvoice = ($datetmp == '' ? (empty($conf->global->MAIN_AUTOFILL_DATE) ?-1 : '') : $datetmp);
$datetmp = dol_mktime(12, 0, 0, $_POST['echmonth'], $_POST['echday'], $_POST['echyear']); $datetmp = dol_mktime(12, 0, 0, $_POST['echmonth'], $_POST['echday'], $_POST['echyear']);
$datedue = ($datetmp == '' ?-1 : $datetmp); $datedue = ($datetmp == '' ?-1 : $datetmp);
@@ -1772,7 +1772,7 @@ if ($action == 'create')
$cond_reglement_id = $societe->cond_reglement_supplier_id; $cond_reglement_id = $societe->cond_reglement_supplier_id;
$mode_reglement_id = $societe->mode_reglement_supplier_id; $mode_reglement_id = $societe->mode_reglement_supplier_id;
$fk_account = $societe->fk_account; $fk_account = $societe->fk_account;
$datetmp = dol_mktime(12, 0, 0, $_POST['remonth'], $_POST['reday'], $_POST['reyear']); $datetmp = dol_mktime(12, 0, 0, GETPOST('remonth', 'int'), GETPOST('reday', 'int'), GETPOST('reyear', 'int'));
$dateinvoice = ($datetmp == '' ? (empty($conf->global->MAIN_AUTOFILL_DATE) ?-1 : '') : $datetmp); $dateinvoice = ($datetmp == '' ? (empty($conf->global->MAIN_AUTOFILL_DATE) ?-1 : '') : $datetmp);
$datetmp = dol_mktime(12, 0, 0, $_POST['echmonth'], $_POST['echday'], $_POST['echyear']); $datetmp = dol_mktime(12, 0, 0, $_POST['echmonth'], $_POST['echday'], $_POST['echyear']);
$datedue = ($datetmp == '' ?-1 : $datetmp); $datedue = ($datetmp == '' ?-1 : $datetmp);

View File

@@ -437,7 +437,7 @@ if (empty($conf->global->MAIN_DISABLE_GLOBAL_WORKBOARD)) {
if (!empty($conf->banque->enabled) && $user->rights->banque->lire && !$user->socid && empty($conf->global->BANK_DISABLE_CHECK_DEPOSIT)) { if (!empty($conf->banque->enabled) && $user->rights->banque->lire && !$user->socid && empty($conf->global->BANK_DISABLE_CHECK_DEPOSIT)) {
include_once DOL_DOCUMENT_ROOT.'/compta/paiement/cheque/class/remisecheque.class.php'; include_once DOL_DOCUMENT_ROOT.'/compta/paiement/cheque/class/remisecheque.class.php';
$board = new RemiseCheque($db); $board = new RemiseCheque($db);
$dashboardlines['RemiseCheque'] = $board->load_board($user); $dashboardlines[$board->element] = $board->load_board($user);
} }
// Number of foundation members // Number of foundation members
@@ -452,21 +452,21 @@ if (empty($conf->global->MAIN_DISABLE_GLOBAL_WORKBOARD)) {
if (!empty($conf->expensereport->enabled) && $user->rights->expensereport->approve) { if (!empty($conf->expensereport->enabled) && $user->rights->expensereport->approve) {
include_once DOL_DOCUMENT_ROOT.'/expensereport/class/expensereport.class.php'; include_once DOL_DOCUMENT_ROOT.'/expensereport/class/expensereport.class.php';
$board = new ExpenseReport($db); $board = new ExpenseReport($db);
$dashboardlines['ExpenseReport'] = $board->load_board($user, 'toapprove'); $dashboardlines[$board->element . '_toapprove'] = $board->load_board($user, 'toapprove');
} }
// Number of expense reports to pay // Number of expense reports to pay
if (!empty($conf->expensereport->enabled) && $user->rights->expensereport->to_paid) { if (!empty($conf->expensereport->enabled) && $user->rights->expensereport->to_paid) {
include_once DOL_DOCUMENT_ROOT.'/expensereport/class/expensereport.class.php'; include_once DOL_DOCUMENT_ROOT.'/expensereport/class/expensereport.class.php';
$board = new ExpenseReport($db); $board = new ExpenseReport($db);
$dashboardlines['ExpenseReport'] = $board->load_board($user, 'topay'); $dashboardlines[$board->element . '_topay'] = $board->load_board($user, 'topay');
} }
// Number of holidays to approve // Number of holidays to approve
if (!empty($conf->holiday->enabled) && $user->rights->holiday->approve) { if (!empty($conf->holiday->enabled) && $user->rights->holiday->approve) {
include_once DOL_DOCUMENT_ROOT.'/holiday/class/holiday.class.php'; include_once DOL_DOCUMENT_ROOT.'/holiday/class/holiday.class.php';
$board = new Holiday($db); $board = new Holiday($db);
$dashboardlines['Holiday'] = $board->load_board($user); $dashboardlines[$board->element] = $board->load_board($user);
} }
$object = new stdClass(); $object = new stdClass();
@@ -551,28 +551,28 @@ if (empty($conf->global->MAIN_DISABLE_GLOBAL_WORKBOARD)) {
array( array(
'groupName' => 'BankAccount', 'groupName' => 'BankAccount',
'stats' => 'stats' =>
array('bank_account', 'RemiseCheque'), array('bank_account', 'chequereceipt'),
), ),
'Adherent' => 'member' =>
array( array(
'groupName' => 'Members', 'groupName' => 'Members',
'globalStatsKey' => 'members', 'globalStatsKey' => 'members',
'stats' => 'stats' =>
array('member_shift', 'member_expired'), array('member_shift', 'member_expired'),
), ),
'ExpenseReport' => 'expensereport' =>
array( array(
'groupName' => 'ExpenseReport', 'groupName' => 'ExpenseReport',
'globalStatsKey' => 'expensereports', 'globalStatsKey' => 'expensereports',
'stats' => 'stats' =>
array('ExpenseReport'), array('expensereport_toapprove', 'expensereport_topay'),
), ),
'Holiday' => 'holiday' =>
array( array(
'groupName' => 'Holidays', 'groupName' => 'Holidays',
'globalStatsKey' => 'holidays', 'globalStatsKey' => 'holidays',
'stats' => 'stats' =>
array('Holiday'), array('holiday'),
), ),
); );

View File

@@ -252,6 +252,7 @@ ALTER TABLE llx_blockedlog ADD COLUMN object_version varchar(32) DEFAULT '';
ALTER TABLE llx_product_lot MODIFY COLUMN batch varchar(128); ALTER TABLE llx_product_lot MODIFY COLUMN batch varchar(128);
ALTER TABLE llx_product_batch MODIFY COLUMN batch varchar(128); ALTER TABLE llx_product_batch MODIFY COLUMN batch varchar(128);
ALTER TABLE llx_expeditiondet_batch MODIFY COLUMN batch varchar(128);
ALTER TABLE llx_commande_fournisseur_dispatch MODIFY COLUMN batch varchar(128); ALTER TABLE llx_commande_fournisseur_dispatch MODIFY COLUMN batch varchar(128);
ALTER TABLE llx_stock_mouvement MODIFY COLUMN batch varchar(128); ALTER TABLE llx_stock_mouvement MODIFY COLUMN batch varchar(128);
ALTER TABLE llx_mrp_production MODIFY COLUMN batch varchar(128); ALTER TABLE llx_mrp_production MODIFY COLUMN batch varchar(128);

View File

@@ -1,6 +1,6 @@
<?php <?php
/* Copyright (C) 2014-2018 Alexandre Spangaro <aspangaro@open-dsi.fr> /* Copyright (C) 2014-2018 Alexandre Spangaro <aspangaro@open-dsi.fr>
* Copyright (C) 2015-2018 Frederic France <frederic.france@netlogic.fr> * Copyright (C) 2015-2020 Frederic France <frederic.france@netlogic.fr>
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
@@ -40,6 +40,11 @@ class PaymentLoan extends CommonObject
*/ */
public $table_element = 'payment_loan'; public $table_element = 'payment_loan';
/**
* @var string String with name of icon for PaymentLoan
*/
public $picto = 'money-bill-alt';
/** /**
* @var int Loan ID * @var int Loan ID
*/ */

View File

@@ -235,7 +235,7 @@ if (GETPOSTISSET('THEME_AGRESSIVENESS_RATIO')) $conf->global->THEME_AGRESSIVENES
.bg-infobox-bank_account{ .bg-infobox-bank_account{
<?php echo $prefix; ?>color: <?php print colorAgressiveness('#b0a53e', $conf->global->THEME_AGRESSIVENESS_RATIO); ?> !important; <?php echo $prefix; ?>color: <?php print colorAgressiveness('#b0a53e', $conf->global->THEME_AGRESSIVENESS_RATIO); ?> !important;
} }
.bg-infobox-adherent{ .bg-infobox-adherent, .bg-infobox-member {
<?php echo $prefix; ?>color: <?php print colorAgressiveness('#79633f', $conf->global->THEME_AGRESSIVENESS_RATIO); ?> !important; <?php echo $prefix; ?>color: <?php print colorAgressiveness('#79633f', $conf->global->THEME_AGRESSIVENESS_RATIO); ?> !important;
} }
.bg-infobox-expensereport{ .bg-infobox-expensereport{
@@ -273,7 +273,7 @@ if (GETPOSTISSET('THEME_AGRESSIVENESS_RATIO')) $conf->global->THEME_AGRESSIVENES
.fa-dol-bank_account:before { .fa-dol-bank_account:before {
content: "\f19c"; content: "\f19c";
} }
.fa-dol-adherent:before { .fa-dol-member:before {
content: "\f0c0"; content: "\f0c0";
} }
.fa-dol-expensereport:before { .fa-dol-expensereport:before {

View File

@@ -34,7 +34,7 @@ if (!empty($conf->global->THEME_INFOBOX_COLOR_ON_BACKGROUND)) $prefix = 'backgro
.bg-infobox-bank_account{ .bg-infobox-bank_account{
<?php echo $prefix; ?>color: <?php print colorAgressiveness('#b0a53e', $conf->global->THEME_AGRESSIVENESS_RATIO); ?> !important; <?php echo $prefix; ?>color: <?php print colorAgressiveness('#b0a53e', $conf->global->THEME_AGRESSIVENESS_RATIO); ?> !important;
} }
.bg-infobox-adherent{ .bg-infobox-adherent, .bg-infobox-member{
<?php echo $prefix; ?>color: <?php print colorAgressiveness('#79633f', $conf->global->THEME_AGRESSIVENESS_RATIO); ?> !important; <?php echo $prefix; ?>color: <?php print colorAgressiveness('#79633f', $conf->global->THEME_AGRESSIVENESS_RATIO); ?> !important;
} }
.bg-infobox-expensereport{ .bg-infobox-expensereport{
@@ -258,7 +258,7 @@ if (GETPOSTISSET('THEME_AGRESSIVENESS_RATIO')) $conf->global->THEME_AGRESSIVENES
.bg-infobox-bank_account i.fa{ .bg-infobox-bank_account i.fa{
color: <?php print colorAgressiveness('#b0a53e', $conf->global->THEME_AGRESSIVENESS_RATIO); ?> !important; color: <?php print colorAgressiveness('#b0a53e', $conf->global->THEME_AGRESSIVENESS_RATIO); ?> !important;
} }
.bg-infobox-adherent i.fa{ .bg-infobox-adherent i.fa, .bg-infobox-member i.fa{
color: <?php print colorAgressiveness('#f39c12', $conf->global->THEME_AGRESSIVENESS_RATIO); ?> !important; color: <?php print colorAgressiveness('#f39c12', $conf->global->THEME_AGRESSIVENESS_RATIO); ?> !important;
} }
.bg-infobox-expensereport i.fa{ .bg-infobox-expensereport i.fa{
@@ -296,7 +296,7 @@ if (GETPOSTISSET('THEME_AGRESSIVENESS_RATIO')) $conf->global->THEME_AGRESSIVENES
.fa-dol-bank_account:before { .fa-dol-bank_account:before {
content: "\f19c"; content: "\f19c";
} }
.fa-dol-adherent:before { .fa-dol-member:before {
content: "\f0c0"; content: "\f0c0";
} }
.fa-dol-expensereport:before { .fa-dol-expensereport:before {

View File

@@ -71,12 +71,12 @@ class ProductCombination
*/ */
public $entity; public $entity;
/** /**
* Constructor * Constructor
* *
* @param DoliDB $db Database handler * @param DoliDB $db Database handler
*/ */
public function __construct(DoliDB $db) public function __construct(DoliDB $db)
{ {
global $conf; global $conf;
@@ -189,16 +189,16 @@ class ProductCombination
*/ */
public function countNbOfCombinationForFkProductParent($fk_product_parent) public function countNbOfCombinationForFkProductParent($fk_product_parent)
{ {
$nb = 0; $nb = 0;
$sql = "SELECT count(rowid) as nb FROM ".MAIN_DB_PREFIX."product_attribute_combination WHERE fk_product_parent = ".(int) $fk_product_parent." AND entity IN (".getEntity('product').")"; $sql = "SELECT count(rowid) as nb FROM ".MAIN_DB_PREFIX."product_attribute_combination WHERE fk_product_parent = ".(int) $fk_product_parent." AND entity IN (".getEntity('product').")";
$resql = $this->db->query($sql); $resql = $this->db->query($sql);
if ($resql) { if ($resql) {
$obj = $this->db->fetch_object($resql); $obj = $this->db->fetch_object($resql);
if ($obj) $nb = $obj->nb; if ($obj) $nb = $obj->nb;
} }
return $nb; return $nb;
} }
/** /**
@@ -326,20 +326,20 @@ class ProductCombination
$child = new Product($this->db); $child = new Product($this->db);
$child->fetch($this->fk_product_child); $child->fetch($this->fk_product_child);
$child->price_autogen = $parent->price_autogen; $child->price_autogen = $parent->price_autogen;
$child->weight = $parent->weight; $child->weight = $parent->weight;
if ($this->variation_weight) { // If we must add a delta on weight if ($this->variation_weight) { // If we must add a delta on weight
$child->weight = ($child->weight ? $child->weight : 0) + $this->variation_weight; $child->weight = ($child->weight ? $child->weight : 0) + $this->variation_weight;
} }
$child->weight_units = $parent->weight_units; $child->weight_units = $parent->weight_units;
// Don't update the child label if the user has already modified it. // Don't update the child label if the user has already modified it.
if ($child->label == $parent->label) { if ($child->label == $parent->label) {
// This will trigger only at variant creation time // This will trigger only at variant creation time
$varlabel = $this->getCombinationLabel($this->fk_product_child); $varlabel = $this->getCombinationLabel($this->fk_product_child);
$child->label = $parent->label.$varlabel;; $child->label = $parent->label.$varlabel;;
} }
if ($child->update($child->id, $user) > 0) { if ($child->update($child->id, $user) > 0) {
$new_vat = $parent->tva_tx; $new_vat = $parent->tva_tx;
@@ -536,9 +536,9 @@ WHERE c.fk_product_parent = ".(int) $productid." AND p.tosell = 1";
$newproduct->ref = $forced_refvar; $newproduct->ref = $forced_refvar;
} }
} else { } else {
$forced_refvar = false; $forced_refvar = false;
$existingProduct = false; $existingProduct = false;
$newproduct = clone $product; $newproduct = clone $product;
} }
//Final weight impact //Final weight impact
@@ -599,11 +599,11 @@ WHERE c.fk_product_parent = ".(int) $productid." AND p.tosell = 1";
} }
if ($forced_refvar === false) { if ($forced_refvar === false) {
if (isset($conf->global->PRODUIT_ATTRIBUTES_SEPARATOR)) { if (isset($conf->global->PRODUIT_ATTRIBUTES_SEPARATOR)) {
$newproduct->ref .= $conf->global->PRODUIT_ATTRIBUTES_SEPARATOR.$prodattrval->ref; $newproduct->ref .= $conf->global->PRODUIT_ATTRIBUTES_SEPARATOR.$prodattrval->ref;
} else { } else {
$newproduct->ref .= '_'.$prodattrval->ref; $newproduct->ref .= '_'.$prodattrval->ref;
} }
} }
//The first one should not contain a linebreak //The first one should not contain a linebreak
@@ -622,62 +622,62 @@ WHERE c.fk_product_parent = ".(int) $productid." AND p.tosell = 1";
// Now create the product // Now create the product
//print 'Create prod '.$newproduct->ref.'<br>'."\n"; //print 'Create prod '.$newproduct->ref.'<br>'."\n";
if ($existingProduct === false) { if ($existingProduct === false) {
//To avoid wrong information in price history log //To avoid wrong information in price history log
$newproduct->price = 0; $newproduct->price = 0;
$newproduct->price_ttc = 0; $newproduct->price_ttc = 0;
$newproduct->price_min = 0; $newproduct->price_min = 0;
$newproduct->price_min_ttc = 0; $newproduct->price_min_ttc = 0;
// A new variant must use a new barcode (not same product) // A new variant must use a new barcode (not same product)
$newproduct->barcode = -1; $newproduct->barcode = -1;
$result = $newproduct->create($user); $result = $newproduct->create($user);
if ($result < 0) if ($result < 0)
{ {
//In case the error is not related with an already existing product //In case the error is not related with an already existing product
if ($newproduct->error != 'ErrorProductAlreadyExists') { if ($newproduct->error != 'ErrorProductAlreadyExists') {
$this->error[] = $newproduct->error; $this->error[] = $newproduct->error;
$this->errors = $newproduct->errors; $this->errors = $newproduct->errors;
$db->rollback(); $db->rollback();
return -1; return -1;
} }
/** /**
* If there is an existing combination, then we update the prices and weight * If there is an existing combination, then we update the prices and weight
* Otherwise, we try adding a random number to the ref * Otherwise, we try adding a random number to the ref
*/ */
if ($newcomb->fk_product_child) { if ($newcomb->fk_product_child) {
$res = $newproduct->fetch($existingCombination->fk_product_child); $res = $newproduct->fetch($existingCombination->fk_product_child);
} else { } else {
$orig_prod_ref = $newproduct->ref; $orig_prod_ref = $newproduct->ref;
$i = 1; $i = 1;
do { do {
$newproduct->ref = $orig_prod_ref.$i; $newproduct->ref = $orig_prod_ref.$i;
$res = $newproduct->create($user); $res = $newproduct->create($user);
if ($newproduct->error != 'ErrorProductAlreadyExists') { if ($newproduct->error != 'ErrorProductAlreadyExists') {
$this->errors[] = $newproduct->error; $this->errors[] = $newproduct->error;
break; break;
} }
$i++; $i++;
} while ($res < 0); } while ($res < 0);
} }
if ($res < 0) { if ($res < 0) {
$db->rollback(); $db->rollback();
return -1; return -1;
} }
} }
} else { } else {
$result = $newproduct->update($newproduct->id, $user); $result = $newproduct->update($newproduct->id, $user);
if ($result < 0) if ($result < 0)
{ {
$db->rollback(); $db->rollback();
return -1; return -1;
} }
} }
$newcomb->fk_product_child = $newproduct->id; $newcomb->fk_product_child = $newproduct->id;
@@ -692,14 +692,14 @@ WHERE c.fk_product_parent = ".(int) $productid." AND p.tosell = 1";
return $newproduct->id; return $newproduct->id;
} }
/** /**
* Copies all product combinations from the origin product to the destination product * Copies all product combinations from the origin product to the destination product
* *
* @param User $user Object user * @param User $user Object user
* @param int $origProductId Origin product id * @param int $origProductId Origin product id
* @param Product $destProduct Destination product * @param Product $destProduct Destination product
* @return int >0 OK <0 KO * @return int >0 OK <0 KO
*/ */
public function copyAll(User $user, $origProductId, Product $destProduct) public function copyAll(User $user, $origProductId, Product $destProduct)
{ {
require_once DOL_DOCUMENT_ROOT.'/variants/class/ProductCombination2ValuePair.class.php'; require_once DOL_DOCUMENT_ROOT.'/variants/class/ProductCombination2ValuePair.class.php';
@@ -721,7 +721,7 @@ WHERE c.fk_product_parent = ".(int) $productid." AND p.tosell = 1";
$variations[$tmp_pc2v->fk_prod_attr] = $tmp_pc2v->fk_prod_attr_val; $variations[$tmp_pc2v->fk_prod_attr] = $tmp_pc2v->fk_prod_attr_val;
} }
if ($this->createProductCombination( if ($this->createProductCombination(
$user, $user,
$destProduct, $destProduct,
$variations, $variations,
@@ -729,7 +729,7 @@ WHERE c.fk_product_parent = ".(int) $productid." AND p.tosell = 1";
$combination->variation_price_percentage, $combination->variation_price_percentage,
$combination->variation_price, $combination->variation_price,
$combination->variation_weight $combination->variation_weight
) < 0) ) < 0)
{ {
return -1; return -1;
} }