NEW: make unicity for user assigned(responsible) on ticket from anyways
This commit is contained in:
parent
0ba7af0f68
commit
ce651ff4f9
@ -8113,7 +8113,7 @@ function dol_getIdFromCode($db, $key, $tablename, $fieldkey = 'code', $fieldid =
|
|||||||
if (!empty($entityfilter)) {
|
if (!empty($entityfilter)) {
|
||||||
$sql .= " AND entity IN (".getEntity($tablename).")";
|
$sql .= " AND entity IN (".getEntity($tablename).")";
|
||||||
}
|
}
|
||||||
|
print $sql;
|
||||||
$resql = $db->query($sql);
|
$resql = $db->query($sql);
|
||||||
if ($resql) {
|
if ($resql) {
|
||||||
$obj = $db->fetch_object($resql);
|
$obj = $db->fetch_object($resql);
|
||||||
|
|||||||
@ -85,8 +85,33 @@ if ($action == 'addcontact' && $user->rights->ticket->write) {
|
|||||||
if ($result > 0 && ($id > 0 || (!empty($track_id)))) {
|
if ($result > 0 && ($id > 0 || (!empty($track_id)))) {
|
||||||
$contactid = (GETPOST('userid', 'int') ? GETPOST('userid', 'int') : GETPOST('contactid', 'int'));
|
$contactid = (GETPOST('userid', 'int') ? GETPOST('userid', 'int') : GETPOST('contactid', 'int'));
|
||||||
$typeid = (GETPOST('typecontact') ? GETPOST('typecontact') : GETPOST('type'));
|
$typeid = (GETPOST('typecontact') ? GETPOST('typecontact') : GETPOST('type'));
|
||||||
|
|
||||||
|
$error = 0;
|
||||||
|
|
||||||
|
$codecontact = dol_getIdFromCode($db, $typeid, 'c_type_contact', 'rowid', 'code');
|
||||||
|
if ($codecontact=='SUPPORTTEC') {
|
||||||
|
$internal_contacts = $object->listeContact(-1, 'internal', 0, 'SUPPORTTEC');
|
||||||
|
foreach ($internal_contacts as $key => $contact) {
|
||||||
|
if ($contact['id'] !== $contactid) {
|
||||||
|
//print "user à effacer : ".$useroriginassign;
|
||||||
|
$result = $object->delete_contact($contact['rowid']);
|
||||||
|
if ($result<0) {
|
||||||
|
$error ++;
|
||||||
|
setEventMessages($object->error, $object->errors, 'errors');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$ret = $object->assignUser($user, $contactid);
|
||||||
|
if ($ret < 0) {
|
||||||
|
$error ++;
|
||||||
|
setEventMessages($object->error, $object->errors, 'errors');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (empty($error)) {
|
||||||
$result = $object->add_contact($contactid, $typeid, GETPOST("source", 'aZ09'));
|
$result = $object->add_contact($contactid, $typeid, GETPOST("source", 'aZ09'));
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if ($result >= 0) {
|
if ($result >= 0) {
|
||||||
Header("Location: ".$url_page_current."?id=".$object->id);
|
Header("Location: ".$url_page_current."?id=".$object->id);
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user