Merge branch '12.0' of git@github.com:Dolibarr/dolibarr.git into develop
This commit is contained in:
commit
d40f90fecb
@ -181,6 +181,7 @@ $limit = 5;
|
|||||||
$sql = "SELECT p.rowid, p.ref, p.amount, p.datec, p.statut";
|
$sql = "SELECT p.rowid, p.ref, p.amount, p.datec, p.statut";
|
||||||
$sql .= " FROM ".MAIN_DB_PREFIX."prelevement_bons as p";
|
$sql .= " FROM ".MAIN_DB_PREFIX."prelevement_bons as p";
|
||||||
$sql .= " WHERE p.type = 'debit-order'";
|
$sql .= " WHERE p.type = 'debit-order'";
|
||||||
|
$sql .= " AND entity IN (" . getEntity('prelevement') . ")";
|
||||||
$sql .= " ORDER BY datec DESC";
|
$sql .= " ORDER BY datec DESC";
|
||||||
$sql .= $db->plimit($limit);
|
$sql .= $db->plimit($limit);
|
||||||
|
|
||||||
|
|||||||
@ -559,7 +559,7 @@ if (empty($reshook))
|
|||||||
|
|
||||||
// Links with users
|
// Links with users
|
||||||
$salesreps = GETPOST('commercial', 'array');
|
$salesreps = GETPOST('commercial', 'array');
|
||||||
$result = $object->setSalesRep($salesreps);
|
$result = $object->setSalesRep($salesreps, true);
|
||||||
if ($result < 0)
|
if ($result < 0)
|
||||||
{
|
{
|
||||||
$error++;
|
$error++;
|
||||||
|
|||||||
@ -4278,9 +4278,10 @@ class Societe extends CommonObject
|
|||||||
* Sets sales representatives of the thirdparty
|
* Sets sales representatives of the thirdparty
|
||||||
*
|
*
|
||||||
* @param int[]|int $salesrep User ID or array of user IDs
|
* @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
|
* @return int <0 if KO, >0 if OK
|
||||||
*/
|
*/
|
||||||
public function setSalesRep($salesrep)
|
public function setSalesRep($salesrep, $onlyAdd = false)
|
||||||
{
|
{
|
||||||
global $user;
|
global $user;
|
||||||
|
|
||||||
@ -4289,16 +4290,18 @@ class Societe extends CommonObject
|
|||||||
$salesrep = array($salesrep);
|
$salesrep = array($salesrep);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get current users
|
|
||||||
$existing = $this->getSalesRepresentatives($user, 1);
|
|
||||||
|
|
||||||
// Diff
|
$to_del = array(); // Nothing to delete
|
||||||
if (is_array($existing)) {
|
$to_add = $salesrep;
|
||||||
$to_del = array_diff($existing, $salesrep);
|
if ($onlyAdd === false) {
|
||||||
$to_add = array_diff($salesrep, $existing);
|
// Get current users
|
||||||
} else {
|
$existing = $this->getSalesRepresentatives($user, 1);
|
||||||
$to_del = array(); // Nothing to delete
|
|
||||||
$to_add = $salesrep;
|
// Diff
|
||||||
|
if (is_array($existing)) {
|
||||||
|
$to_del = array_diff($existing, $salesrep);
|
||||||
|
$to_add = array_diff($salesrep, $existing);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$error = 0;
|
$error = 0;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user