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

This commit is contained in:
Laurent Destailleur 2019-10-07 10:42:49 +02:00
commit ecd7d1208d
10 changed files with 48 additions and 35 deletions

View File

@ -1622,7 +1622,7 @@ if ($id > 0)
// Type // Type
if (! empty($conf->global->AGENDA_USE_EVENT_TYPE)) if (! empty($conf->global->AGENDA_USE_EVENT_TYPE))
{ {
print '<tr><td class="titlefield">'.$langs->trans("Type").'</td><td colspan="3">'.$object->type.'</td></tr>'; print '<tr><td class="titlefield">'.$langs->trans("Type").'</td><td colspan="3">'.$langs->trans($object->type).'</td></tr>';
} }
// Full day event // Full day event

View File

@ -2077,7 +2077,7 @@ class Contrat extends CommonObject
* Return list of line rowid * Return list of line rowid
* *
* @param int $statut Status of lines to get * @param int $statut Status of lines to get
* @return array Array of line's rowid * @return array|int Array of line's rowid or <0 if error
*/ */
public function array_detail($statut = -1) public function array_detail($statut = -1)
{ {
@ -2114,7 +2114,7 @@ class Contrat extends CommonObject
* Return list of other contracts for same company than current contract * Return list of other contracts for same company than current contract
* *
* @param string $option 'all' or 'others' * @param string $option 'all' or 'others'
* @return array Array of contracts id * @return array|int Array of contracts id or <0 if error
*/ */
public function getListOfContracts($option = 'all') public function getListOfContracts($option = 'all')
{ {

View File

@ -96,7 +96,7 @@ class ModelNumRefHolidays
public function info() public function info()
{ {
global $langs; global $langs;
$langs->load("holidays"); $langs->load("holiday");
return $langs->trans("NoDescription"); return $langs->trans("NoDescription");
} }
@ -108,7 +108,7 @@ class ModelNumRefHolidays
public function getExample() public function getExample()
{ {
global $langs; global $langs;
$langs->load("holidays"); $langs->load("holiday");
return $langs->trans("NoExample"); return $langs->trans("NoExample");
} }

View File

@ -509,12 +509,12 @@ class ImportCsv extends ModeleImports
} }
$classinstance=new $class($this->db); $classinstance=new $class($this->db);
// Try the fetch from code or ref // Try the fetch from code or ref
call_user_func_array(array($classinstance, $method), array('', $units, $newval)); call_user_func_array(array($classinstance, $method), array('', '', $newval, $units));
$this->cacheconvert[$file.'_'.$class.'_'.$method.'_'.$units][$newval]=$classinstance->code; $this->cacheconvert[$file.'_'.$class.'_'.$method.'_'.$units][$newval]=$classinstance->id;
//print 'We have made a '.$class.'->'.$method.' to get id from code '.$newval.'. '; //print 'We have made a '.$class.'->'.$method.' to get id from code '.$newval.'. ';
if ($classinstance->code != '') // id may be 0, it is a found value if ($classinstance->id != '') // id may be 0, it is a found value
{ {
$newval=$classinstance->code; $newval=$classinstance->id;
} }
else else
{ {

View File

@ -536,12 +536,12 @@ class ImportXlsx extends ModeleImports
} }
$classinstance=new $class($this->db); $classinstance=new $class($this->db);
// Try the fetch from code or ref // Try the fetch from code or ref
call_user_func_array(array($classinstance, $method), array('', $units, '', $newval)); call_user_func_array(array($classinstance, $method), array('', '', $newval, $units));
$this->cacheconvert[$file.'_'.$class.'_'.$method.'_'.$units][$newval]=$classinstance->code; $this->cacheconvert[$file.'_'.$class.'_'.$method.'_'.$units][$newval]=$classinstance->id;
//print 'We have made a '.$class.'->'.$method.' to get id from code '.$newval.'. '; //print 'We have made a '.$class.'->'.$method.' to get id from code '.$newval.'. ';
if ($classinstance->code != '') // id may be 0, it is a found value if ($classinstance->id != '') // id may be 0, it is a found value
{ {
$newval=$classinstance->code; $newval=$classinstance->id;
} }
else else
{ {

View File

@ -354,6 +354,7 @@ class modProduct extends DolibarrModules
'p.note_public' => "PublicNote",//public note 'p.note_public' => "PublicNote",//public note
'p.note' => "PrivateNote",//private note 'p.note' => "PrivateNote",//private note
'p.customcode' => 'CustomCode', 'p.customcode' => 'CustomCode',
'p.fk_country' => 'CountryCode',
'p.price' => "SellingPriceHT",//without 'p.price' => "SellingPriceHT",//without
'p.price_min' => "MinPrice", 'p.price_min' => "MinPrice",
'p.price_ttc' => "SellingPriceTTC",//with tax 'p.price_ttc' => "SellingPriceTTC",//with tax
@ -441,8 +442,15 @@ class modProduct extends DolibarrModules
'method' => 'fetch', 'method' => 'fetch',
'units' => 'volume', 'units' => 'volume',
'dict' => 'DictionaryMeasuringUnits' 'dict' => 'DictionaryMeasuringUnits'
) ),
);*/ 'p.fk_country' => array(
'rule' => 'fetchidfromcodeid',
'classfile' => '/core/class/ccountry.class.php',
'class' => 'Ccountry',
'method' => 'fetch',
'dict' => 'DictionaryCountry'
)
);
if (! empty($conf->fournisseur->enabled) || !empty($conf->margin->enabled)) $this->import_fields_array[$r]=array_merge($this->import_fields_array[$r], array('p.cost_price'=>'CostPrice')); if (! empty($conf->fournisseur->enabled) || !empty($conf->margin->enabled)) $this->import_fields_array[$r]=array_merge($this->import_fields_array[$r], array('p.cost_price'=>'CostPrice'));
if (is_object($mysoc) && $mysoc->useNPR()) $this->import_fields_array[$r]=array_merge($this->import_fields_array[$r], array('p.recuperableonly'=>'NPR')); if (is_object($mysoc) && $mysoc->useNPR()) $this->import_fields_array[$r]=array_merge($this->import_fields_array[$r], array('p.recuperableonly'=>'NPR'));
@ -486,6 +494,7 @@ class modProduct extends DolibarrModules
'p.note_public' => "a public note (free text)", 'p.note_public' => "a public note (free text)",
'p.note' => "a private note (free text)", 'p.note' => "a private note (free text)",
'p.customcode' => 'customs code', 'p.customcode' => 'customs code',
'p.fk_country' => 'FR',
'p.price' => "price ex-vat eg. 100", 'p.price' => "price ex-vat eg. 100",
'p.price_min' => "price ex-vat eg. 100", 'p.price_min' => "price ex-vat eg. 100",
'p.price_ttc' => "price inc-vat eg. 110", 'p.price_ttc' => "price inc-vat eg. 110",

View File

@ -37,7 +37,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/holiday.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
// Load translation files required by the page // Load translation files required by the page
$langs->loadLangs(array('other', 'holidays', 'companies')); $langs->loadLangs(array('other', 'holiday', 'companies'));
$id = GETPOST('id', 'int'); $id = GETPOST('id', 'int');
$ref = GETPOST('ref', 'alpha'); $ref = GETPOST('ref', 'alpha');
@ -48,8 +48,6 @@ $confirm = GETPOST('confirm', 'alpha');
if ($user->societe_id) $socid=$user->societe_id; if ($user->societe_id) $socid=$user->societe_id;
$result = restrictedArea($user, 'holiday', $id, 'holiday'); $result = restrictedArea($user, 'holiday', $id, 'holiday');
$langs->load("holiday");
// Get parameters // Get parameters
$sortfield = GETPOST('sortfield', 'alpha'); $sortfield = GETPOST('sortfield', 'alpha');
$sortorder = GETPOST('sortorder', 'alpha'); $sortorder = GETPOST('sortorder', 'alpha');

View File

@ -36,7 +36,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/usergroups.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/usergroups.lib.php';
// Load translation files required by the page // Load translation files required by the page
$langs->loadLangs(array('users', 'holidays', 'hrm')); $langs->loadLangs(array('users', 'holiday', 'hrm'));
// Protection if external user // Protection if external user
if ($user->societe_id > 0) accessforbidden(); if ($user->societe_id > 0) accessforbidden();

View File

@ -301,7 +301,7 @@ if (empty($user->societe_id) && empty($conf->global->MAIN_DISABLE_GLOBAL_BOXSTAT
"supplier_proposal", "supplier_proposal",
"projects", "projects",
"trips", "trips",
"holidays", "holiday",
"donations" "donations"
); );

View File

@ -15,10 +15,11 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>. * along with this program. If not, see <https://www.gnu.org/licenses/>.
*/ */
use Luracast\Restler\RestException; use Luracast\Restler\RestException;
require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php';
require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.product.class.php';
require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';
/** /**
* API class for products * API class for products
@ -41,6 +42,11 @@ class Products extends DolibarrApi
*/ */
public $product; public $product;
/**
* @var ProductFournisseur $productsupplier {@type ProductFournisseur}
*/
public $productsupplier;
/** /**
* Constructor * Constructor
*/ */
@ -49,6 +55,7 @@ class Products extends DolibarrApi
global $db, $conf; global $db, $conf;
$this->db = $db; $this->db = $db;
$this->product = new Product($this->db); $this->product = new Product($this->db);
$this->productsupplier = new ProductFournisseur($this->db);
} }
/** /**
@ -475,7 +482,7 @@ class Products extends DolibarrApi
* *
* @url DELETE {id}/purchase_prices/{priceid} * @url DELETE {id}/purchase_prices/{priceid}
* *
* @return array * @return int
* *
* @throws 401 * @throws 401
* @throws 404 * @throws 404
@ -494,13 +501,13 @@ class Products extends DolibarrApi
if(! DolibarrApi::_checkAccessToResource('product', $this->product->id)) { if(! DolibarrApi::_checkAccessToResource('product', $this->product->id)) {
throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
} }
$resultsupplier = 0;
if($result) { if ($result) {
$this->product = new ProductFournisseur($this->db); $this->productsupplier->fetch($id);
$this->product->fetch($id); $resultsupplier = $this->product->remove_product_fournisseur_price($priceid);
} }
return $this->product->remove_product_fournisseur_price($priceid); return $resultsupplier;
} }
/** /**
@ -632,16 +639,15 @@ class Products extends DolibarrApi
} }
if ($includestockdata) { if ($includestockdata) {
$this->product->load_stock(); $this->product->load_stock();
} }
if($result) { if ($result) {
$this->product = new ProductFournisseur($this->db); $this->productsupplier->fetch($id, $ref);
$this->product->fetch($id, $ref); $this->productsupplier->list_product_fournisseur_price($id, '', '', 0, 0);
$this->product->list_product_fournisseur_price($id, '', '', 0, 0);
} }
return $this->_cleanObjectDatas($this->product); return $this->_cleanObjectDatas($this->productsupplier);
} }
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore