Fix combo to add contact and status of contact on popup

This commit is contained in:
Laurent Destailleur 2020-11-30 15:18:58 +01:00
parent 00ad6df395
commit 958893228a
23 changed files with 58 additions and 36 deletions

View File

@ -503,7 +503,10 @@ if ($nboftargetok) {
$ret=`rm -f $BUILDROOT/$PROJECT/htdocs/install/mysql/README`; $ret=`rm -f $BUILDROOT/$PROJECT/htdocs/install/mysql/README`;
$ret=`rm -f $BUILDROOT/$PROJECT/htdocs/install/pgsql/README`; $ret=`rm -f $BUILDROOT/$PROJECT/htdocs/install/pgsql/README`;
$ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/install/mssql`; $ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/install/mssql`;
$ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/install/sqlite3`;
$ret=`rm -fr $BUILDROOT/$PROJECT/node_modules`;
$ret=`rm -fr $BUILDROOT/$PROJECT/dev/ansible`; $ret=`rm -fr $BUILDROOT/$PROJECT/dev/ansible`;
$ret=`rm -fr $BUILDROOT/$PROJECT/dev/codesniffer`; $ret=`rm -fr $BUILDROOT/$PROJECT/dev/codesniffer`;

View File

@ -547,9 +547,8 @@ if (empty($reshook))
if ($id > 0) if ($id > 0)
{ {
// Insertion contact par defaut si defini // Insert default contacts if defined
if (GETPOST('contactid') > 0) if (GETPOST('contactid') > 0) {
{
$result = $object->add_contact(GETPOST('contactid'), 'CUSTOMER', 'external'); $result = $object->add_contact(GETPOST('contactid'), 'CUSTOMER', 'external');
if ($result < 0) if ($result < 0)
{ {
@ -1344,7 +1343,8 @@ if (empty($reshook))
{ {
if ($object->id > 0) { if ($object->id > 0) {
$contactid = (GETPOST('userid') ? GETPOST('userid') : GETPOST('contactid')); $contactid = (GETPOST('userid') ? GETPOST('userid') : GETPOST('contactid'));
$result = $object->add_contact($contactid, $_POST["type"], $_POST["source"]); $typeid = (GETPOST('typecontact') ? GETPOST('typecontact') : GETPOST('type'));
$result = $object->add_contact($contactid, $typeid, GETPOST("source", 'aZ09'));
} }
if ($result >= 0) { if ($result >= 0) {

View File

@ -79,7 +79,8 @@ if ($action == 'addcontact' && $user->rights->propale->creer)
if ($object->id > 0) if ($object->id > 0)
{ {
$contactid = (GETPOST('userid', 'int') ? GETPOST('userid', 'int') : GETPOST('contactid', 'int')); $contactid = (GETPOST('userid', 'int') ? GETPOST('userid', 'int') : GETPOST('contactid', 'int'));
$result = $object->add_contact($contactid, $_POST["type"], $_POST["source"]); $typeid = (GETPOST('typecontact') ? GETPOST('typecontact') : GETPOST('type'));
$result = $object->add_contact($contactid, $typeid, GETPOST("source", 'aZ09'));
} }
if ($result >= 0) if ($result >= 0)

View File

@ -459,8 +459,7 @@ if (empty($reshook))
// Insert default contacts if defined // Insert default contacts if defined
if ($object_id > 0) if ($object_id > 0)
{ {
if (GETPOST('contactid', 'int')) if (GETPOST('contactid', 'int')) {
{
$result = $object->add_contact(GETPOST('contactid', 'int'), 'CUSTOMER', 'external'); $result = $object->add_contact(GETPOST('contactid', 'int'), 'CUSTOMER', 'external');
if ($result < 0) { if ($result < 0) {
setEventMessages($langs->trans("ErrorFailedToAddContact"), null, 'errors'); setEventMessages($langs->trans("ErrorFailedToAddContact"), null, 'errors');
@ -1367,7 +1366,8 @@ if (empty($reshook))
{ {
if ($object->id > 0) { if ($object->id > 0) {
$contactid = (GETPOST('userid') ? GETPOST('userid') : GETPOST('contactid')); $contactid = (GETPOST('userid') ? GETPOST('userid') : GETPOST('contactid'));
$result = $object->add_contact($contactid, GETPOST('type'), GETPOST('source')); $typeid = (GETPOST('typecontact') ? GETPOST('typecontact') : GETPOST('type'));
$result = $object->add_contact($contactid, $typeid, GETPOST("source", 'aZ09'));
} }
if ($result >= 0) { if ($result >= 0) {

View File

@ -56,7 +56,8 @@ if ($action == 'addcontact' && $user->rights->commande->creer)
if ($result > 0 && $id > 0) if ($result > 0 && $id > 0)
{ {
$contactid = (GETPOST('userid', 'int') ? GETPOST('userid', 'int') : GETPOST('contactid', 'int')); $contactid = (GETPOST('userid', 'int') ? GETPOST('userid', 'int') : GETPOST('contactid', 'int'));
$result = $object->add_contact($contactid, $_POST["type"], $_POST["source"]); $typeid = (GETPOST('typecontact') ? GETPOST('typecontact') : GETPOST('type'));
$result = $object->add_contact($contactid, $typeid, GETPOST("source", 'aZ09'));
} }
if ($result >= 0) if ($result >= 0)

View File

@ -2664,7 +2664,8 @@ if (empty($reshook))
if ($result > 0 && $id > 0) { if ($result > 0 && $id > 0) {
$contactid = (GETPOST('userid') ? GETPOST('userid') : GETPOST('contactid')); $contactid = (GETPOST('userid') ? GETPOST('userid') : GETPOST('contactid'));
$result = $object->add_contact($contactid, $_POST["type"], $_POST["source"]); $typeid = (GETPOST('typecontact') ? GETPOST('typecontact') : GETPOST('type'));
$result = $object->add_contact($contactid, $typeid, GETPOST("source", 'aZ09'));
} }
if ($result >= 0) { if ($result >= 0) {

View File

@ -62,7 +62,8 @@ if ($action == 'addcontact' && $user->rights->facture->creer)
if ($result > 0 && $id > 0) if ($result > 0 && $id > 0)
{ {
$contactid = (GETPOST('userid') ? GETPOST('userid', 'int') : GETPOST('contactid', 'int')); $contactid = (GETPOST('userid') ? GETPOST('userid', 'int') : GETPOST('contactid', 'int'));
$result = $object->add_contact($contactid, $_POST["type"], $_POST["source"]); $typeid = (GETPOST('typecontact') ? GETPOST('typecontact') : GETPOST('type'));
$result = $object->add_contact($contactid, $typeid, GETPOST("source", 'aZ09'));
} }
if ($result >= 0) if ($result >= 0)

View File

@ -946,7 +946,8 @@ if (empty($reshook))
if ($action == 'addcontact') if ($action == 'addcontact')
{ {
$contactid = (GETPOST('userid') ? GETPOST('userid') : GETPOST('contactid')); $contactid = (GETPOST('userid') ? GETPOST('userid') : GETPOST('contactid'));
$result = $object->add_contact($contactid, GETPOST('type'), GETPOST('source')); $typeid = (GETPOST('typecontact') ? GETPOST('typecontact') : GETPOST('type'));
$result = $object->add_contact($contactid, $typeid, GETPOST("source", 'aZ09'));
if ($result >= 0) if ($result >= 0)
{ {

View File

@ -63,7 +63,8 @@ if ($action == 'addcontact' && $user->rights->contrat->creer)
if ($result > 0 && $id > 0) if ($result > 0 && $id > 0)
{ {
$contactid = (GETPOST('userid') ? GETPOST('userid') : GETPOST('contactid')); $contactid = (GETPOST('userid') ? GETPOST('userid') : GETPOST('contactid'));
$result = $object->add_contact($contactid, $_POST["type"], $_POST["source"]); $typeid = (GETPOST('typecontact') ? GETPOST('typecontact') : GETPOST('type'));
$result = $object->add_contact($contactid, $typeid, GETPOST("source", 'aZ09'));
} }
if ($result >= 0) if ($result >= 0)

View File

@ -936,11 +936,11 @@ abstract class CommonObject
/** /**
* Add a link between element $this->element and a contact * Add a link between element $this->element and a contact
* *
* @param int $fk_socpeople Id of thirdparty contact (if source = 'external') or id of user (if souce = 'internal') to link * @param int $fk_socpeople Id of thirdparty contact (if source = 'external') or id of user (if souce = 'internal') to link
* @param int $type_contact Type of contact (code or id). Must be id or code found into table llx_c_type_contact. For example: SALESREPFOLL * @param int|string $type_contact Type of contact (code or id). Must be id or code found into table llx_c_type_contact. For example: SALESREPFOLL
* @param string $source external=Contact extern (llx_socpeople), internal=Contact intern (llx_user) * @param string $source external=Contact extern (llx_socpeople), internal=Contact intern (llx_user)
* @param int $notrigger Disable all triggers * @param int $notrigger Disable all triggers
* @return int <0 if KO, >0 if OK * @return int <0 if KO, >0 if OK
*/ */
public function add_contact($fk_socpeople, $type_contact, $source = 'external', $notrigger = 0) public function add_contact($fk_socpeople, $type_contact, $source = 'external', $notrigger = 0)
{ {

View File

@ -155,7 +155,7 @@ if ($permission)
<?php <?php
$tmpobject = $object; $tmpobject = $object;
if (($object->element == 'shipping' || $object->element == 'reception') && is_object($objectsrc)) $tmpobject = $objectsrc; if (($object->element == 'shipping' || $object->element == 'reception') && is_object($objectsrc)) $tmpobject = $objectsrc;
$formcompany->selectTypeContact($tmpobject, $preselectedtypeofcontact, 'type', 'external', 'position', 0, 'minwidth100imp'); $formcompany->selectTypeContact($tmpobject, $preselectedtypeofcontact, 'typecontact', 'external', 'position', 0, 'minwidth100imp');
?> ?>
</div> </div>
<div class="tagtd noborderbottom">&nbsp;</div> <div class="tagtd noborderbottom">&nbsp;</div>

View File

@ -734,7 +734,8 @@ if (empty($reshook))
if ($result > 0 && $id > 0) if ($result > 0 && $id > 0)
{ {
$contactid = (GETPOST('userid', 'int') ? GETPOST('userid', 'int') : GETPOST('contactid', 'int')); $contactid = (GETPOST('userid', 'int') ? GETPOST('userid', 'int') : GETPOST('contactid', 'int'));
$result = $object->add_contact($contactid, GETPOST('type', 'int'), GETPOST('source', 'alpha')); $typeid = (GETPOST('typecontact') ? GETPOST('typecontact') : GETPOST('type'));
$result = $object->add_contact($contactid, $typeid, GETPOST("source", 'aZ09'));
} }
if ($result >= 0) if ($result >= 0)

View File

@ -59,7 +59,8 @@ if ($action == 'addcontact' && $user->rights->ficheinter->creer)
if ($result > 0 && $id > 0) if ($result > 0 && $id > 0)
{ {
$contactid = (GETPOST('userid', 'int') ? GETPOST('userid', 'int') : GETPOST('contactid', 'int')); $contactid = (GETPOST('userid', 'int') ? GETPOST('userid', 'int') : GETPOST('contactid', 'int'));
$result = $object->add_contact($contactid, GETPOST('type', 'int'), GETPOST('source', 'alpha')); $typeid = (GETPOST('typecontact') ? GETPOST('typecontact') : GETPOST('type'));
$result = $object->add_contact($contactid, $typeid, GETPOST("source", 'aZ09'));
} }
if ($result >= 0) if ($result >= 0)

View File

@ -1432,7 +1432,8 @@ if (empty($reshook))
if ($object->id > 0) if ($object->id > 0)
{ {
$contactid = (GETPOST('userid') ? GETPOST('userid') : GETPOST('contactid')); $contactid = (GETPOST('userid') ? GETPOST('userid') : GETPOST('contactid'));
$result = $object->add_contact($contactid, $_POST["type"], $_POST["source"]); $typeid = (GETPOST('typecontact') ? GETPOST('typecontact') : GETPOST('type'));
$result = $object->add_contact($contactid, $typeid, GETPOST("source", 'aZ09'));
} }
if ($result >= 0) if ($result >= 0)

View File

@ -58,7 +58,8 @@ if ($action == 'addcontact' && $user->rights->fournisseur->commande->creer)
if ($result > 0 && $id > 0) if ($result > 0 && $id > 0)
{ {
$contactid = (GETPOST('userid') ? GETPOST('userid') : GETPOST('contactid')); $contactid = (GETPOST('userid') ? GETPOST('userid') : GETPOST('contactid'));
$result = $object->add_contact($contactid, $_POST["type"], $_POST["source"]); $typeid = (GETPOST('typecontact') ? GETPOST('typecontact') : GETPOST('type'));
$result = $object->add_contact($contactid, $typeid, GETPOST("source", 'aZ09'));
} }
if ($result >= 0) if ($result >= 0)

View File

@ -1604,7 +1604,8 @@ if (empty($reshook))
if ($result > 0 && $id > 0) if ($result > 0 && $id > 0)
{ {
$contactid = (GETPOST('userid') ? GETPOST('userid') : GETPOST('contactid')); $contactid = (GETPOST('userid') ? GETPOST('userid') : GETPOST('contactid'));
$result = $object->add_contact($contactid, $_POST["type"], $_POST["source"]); $typeid = (GETPOST('typecontact') ? GETPOST('typecontact') : GETPOST('type'));
$result = $object->add_contact($contactid, $typeid, GETPOST("source", 'aZ09'));
} }
if ($result >= 0) if ($result >= 0)

View File

@ -58,7 +58,8 @@ if ($action == 'addcontact' && $user->rights->fournisseur->facture->creer)
if ($result > 0 && $id > 0) if ($result > 0 && $id > 0)
{ {
$contactid = (GETPOST('userid') ? GETPOST('userid') : GETPOST('contactid')); $contactid = (GETPOST('userid') ? GETPOST('userid') : GETPOST('contactid'));
$result = $object->add_contact($contactid, $_POST["type"], $_POST["source"]); $typeid = (GETPOST('typecontact') ? GETPOST('typecontact') : GETPOST('type'));
$result = $object->add_contact($contactid, $typeid, GETPOST("source", 'aZ09'));
} }
if ($result >= 0) if ($result >= 0)

View File

@ -66,7 +66,8 @@ if ($action == 'addcontact' && $user->rights->projet->creer)
if ($result > 0 && $id > 0) if ($result > 0 && $id > 0)
{ {
$contactid = (GETPOST('userid') ? GETPOST('userid', 'int') : GETPOST('contactid', 'int')); $contactid = (GETPOST('userid') ? GETPOST('userid', 'int') : GETPOST('contactid', 'int'));
$result = $object->add_contact($contactid, $_POST["type"], $_POST["source"]); $typeid = (GETPOST('typecontact') ? GETPOST('typecontact') : GETPOST('type'));
$result = $object->add_contact($contactid, $typeid, GETPOST("source", 'aZ09'));
} }
if ($result >= 0) if ($result >= 0)

View File

@ -72,11 +72,13 @@ if ($action == 'addcontact' && $user->rights->projet->creer)
$contactsofproject = $projectstatic->getListContactId('internal'); $contactsofproject = $projectstatic->getListContactId('internal');
foreach ($contactsofproject as $key => $val) foreach ($contactsofproject as $key => $val)
{ {
$result = $object->add_contact($val, GETPOST("type"), GETPOST("source")); $typeid = (GETPOST('typecontact') ? GETPOST('typecontact') : GETPOST('type'));
$result = $object->add_contact($val, $type, GETPOST("source", 'aZ09'));
} }
} }
} else { } else {
$result = $object->add_contact($idfortaskuser, GETPOST("type"), GETPOST("source")); $typeid = (GETPOST('typecontact') ? GETPOST('typecontact') : GETPOST('type'));
$result = $object->add_contact($idfortaskuser, $typeid, GETPOST("source", 'aZ09'));
} }
} }
@ -449,6 +451,7 @@ if ($id > 0 || !empty($ref))
foreach (array('internal', 'external') as $source) foreach (array('internal', 'external') as $source)
{ {
$tab = $object->liste_contact(-1, $source); $tab = $object->liste_contact(-1, $source);
$num = count($tab); $num = count($tab);
$i = 0; $i = 0;
@ -489,7 +492,7 @@ if ($id > 0 || !empty($ref))
$userstatic->photo = $tab[$i]['photo']; $userstatic->photo = $tab[$i]['photo'];
$userstatic->login = $tab[$i]['login']; $userstatic->login = $tab[$i]['login'];
$userstatic->email = $tab[$i]['email']; $userstatic->email = $tab[$i]['email'];
$userstatic->statut = $tab[$i]['statucontact']; $userstatic->statut = $tab[$i]['statuscontact'];
print $userstatic->getNomUrl(-1); print $userstatic->getNomUrl(-1);
} }
@ -499,8 +502,7 @@ if ($id > 0 || !empty($ref))
$contactstatic->lastname = $tab[$i]['lastname']; $contactstatic->lastname = $tab[$i]['lastname'];
$contactstatic->firstname = $tab[$i]['firstname']; $contactstatic->firstname = $tab[$i]['firstname'];
$contactstatic->email = $tab[$i]['email']; $contactstatic->email = $tab[$i]['email'];
$contactstatic->statut = $tab[$i]['statucontact']; $contactstatic->statut = $tab[$i]['statuscontact'];
print $contactstatic->getNomUrl(1); print $contactstatic->getNomUrl(1);
} }
print '</td>'; print '</td>';

View File

@ -55,7 +55,8 @@ if ($action == 'addcontact' && $user->rights->resource->write)
if ($result > 0 && $id > 0) if ($result > 0 && $id > 0)
{ {
$contactid = (GETPOST('userid', 'int') ? GETPOST('userid', 'int') : GETPOST('contactid', 'int')); $contactid = (GETPOST('userid', 'int') ? GETPOST('userid', 'int') : GETPOST('contactid', 'int'));
$result = $object->add_contact($contactid, GETPOST('type', 'int'), GETPOST('source', 'alpha')); $typeid = (GETPOST('typecontact') ? GETPOST('typecontact') : GETPOST('type'));
$result = $object->add_contact($contactid, $typeid, GETPOST("source", 'aZ09'));
} }
if ($result >= 0) if ($result >= 0)

View File

@ -71,7 +71,8 @@ if ($action == 'addcontact' && $user->rights->societe->creer)
if ($result > 0 && $id > 0) if ($result > 0 && $id > 0)
{ {
$contactid = (GETPOST('userid', 'int') ? GETPOST('userid', 'int') : GETPOST('contactid', 'int')); $contactid = (GETPOST('userid', 'int') ? GETPOST('userid', 'int') : GETPOST('contactid', 'int'));
$result = $object->add_contact($contactid, $_POST["type"], $_POST["source"]); $typeid = (GETPOST('typecontact') ? GETPOST('typecontact') : GETPOST('type'));
$result = $object->add_contact($contactid, $typeid, GETPOST("source", 'aZ09'));
} }
if ($result >= 0) if ($result >= 0)

View File

@ -194,7 +194,8 @@ if (empty($reshook)) {
$type_contact = GETPOST("type", 'alpha'); $type_contact = GETPOST("type", 'alpha');
if ($contactid > 0 && $type_contact) { if ($contactid > 0 && $type_contact) {
$result = $object->add_contact($contactid, GETPOST("type"), 'external'); $typeid = (GETPOST('typecontact') ? GETPOST('typecontact') : GETPOST('type'));
$result = $object->add_contact($contactid, $typeid, 'external');
} }
// altairis: link ticket to project // altairis: link ticket to project

View File

@ -71,7 +71,8 @@ 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'));
$result = $object->add_contact($contactid, $type, $source); $typeid = (GETPOST('typecontact') ? GETPOST('typecontact') : GETPOST('type'));
$result = $object->add_contact($contactid, $typeid, GETPOST("source", 'aZ09'));
} }
if ($result >= 0) { if ($result >= 0) {