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

Conflicts:
	htdocs/compta/prelevement/index.php
This commit is contained in:
Laurent Destailleur 2020-08-27 22:00:10 +02:00
commit ad63434f3e
3 changed files with 15 additions and 11 deletions

View File

@ -185,6 +185,7 @@ $limit = 5;
$sql = "SELECT p.rowid, p.ref, p.amount, p.datec, p.statut";
$sql .= " FROM ".MAIN_DB_PREFIX."prelevement_bons as p";
$sql .= " WHERE p.type = 'debit-order'";
$sql .= " AND entity IN (" . getEntity('prelevement') . ")";
$sql .= " ORDER BY datec DESC";
$sql .= $db->plimit($limit);

View File

@ -566,7 +566,7 @@ if (empty($reshook))
// Links with users
$salesreps = GETPOST('commercial', 'array');
$result = $object->setSalesRep($salesreps);
$result = $object->setSalesRep($salesreps, true);
if ($result < 0)
{
$error++;

View File

@ -4398,9 +4398,10 @@ class Societe extends CommonObject
* Sets sales representatives of the thirdparty
*
* @param int[]|int $salesrep User ID or array of user IDs
* @param bool $onlyAdd Only add (no delete before)
* @return int <0 if KO, >0 if OK
*/
public function setSalesRep($salesrep)
public function setSalesRep($salesrep, $onlyAdd = false)
{
global $user;
@ -4409,16 +4410,18 @@ class Societe extends CommonObject
$salesrep = array($salesrep);
}
// Get current users
$existing = $this->getSalesRepresentatives($user, 1);
// Diff
if (is_array($existing)) {
$to_del = array_diff($existing, $salesrep);
$to_add = array_diff($salesrep, $existing);
} else {
$to_del = array(); // Nothing to delete
$to_add = $salesrep;
$to_del = array(); // Nothing to delete
$to_add = $salesrep;
if ($onlyAdd === false) {
// Get current users
$existing = $this->getSalesRepresentatives($user, 1);
// Diff
if (is_array($existing)) {
$to_del = array_diff($existing, $salesrep);
$to_add = array_diff($salesrep, $existing);
}
}
$error = 0;