This commit is contained in:
Laurent Destailleur 2015-09-16 22:04:03 +02:00
parent 7d8013b371
commit 313d9ddacd
5 changed files with 30 additions and 14 deletions

View File

@ -445,6 +445,7 @@ if ($id == 11)
$langs->load("interventions");
$elementList = array(
'' => '',
'societe' => $langs->trans('ThirdParty'),
// 'proposal' => $langs->trans('Proposal'),
// 'order' => $langs->trans('Order'),
// 'invoice' => $langs->trans('Bill'),

View File

@ -1165,8 +1165,10 @@ if (empty($reshook))
if (! $error && ! empty($conf->global->MAIN_DISABLE_CONTACTS_TAB) && $user->rights->commande->creer) {
if ($action == 'addcontact') {
if (! $error && ! empty($conf->global->MAIN_DISABLE_CONTACTS_TAB) && $user->rights->commande->creer)
{
if ($action == 'addcontact')
{
if ($object->id > 0) {
$contactid = (GETPOST('userid') ? GETPOST('userid') : GETPOST('contactid'));
$result = $object->add_contact($contactid, GETPOST('type'), GETPOST('source'));
@ -1186,7 +1188,8 @@ if (empty($reshook))
}
// bascule du statut d'un contact
else if ($action == 'swapstatut') {
else if ($action == 'swapstatut')
{
if ($object->id > 0) {
$result = $object->swapContactStatus(GETPOST('ligne'));
} else {
@ -1195,7 +1198,8 @@ if (empty($reshook))
}
// Efface un contact
else if ($action == 'deletecontact') {
else if ($action == 'deletecontact')
{
$result = $object->delete_contact($lineid);
if ($result >= 0) {

View File

@ -452,13 +452,15 @@ abstract class CommonObject
// Check parameters
if ($fk_socpeople <= 0)
{
$this->error=$langs->trans("ErrorWrongValueForParameter","1");
$langs->load("errors");
$this->error=$langs->trans("ErrorWrongValueForParameterX","1");
dol_syslog(get_class($this)."::add_contact ".$this->error,LOG_ERR);
return -1;
}
if (! $type_contact)
{
$this->error=$langs->trans("ErrorWrongValueForParameter","2");
$langs->load("errors");
$this->error=$langs->trans("ErrorWrongValueForParameterX","2");
dol_syslog(get_class($this)."::add_contact ".$this->error,LOG_ERR);
return -2;
}
@ -486,7 +488,7 @@ abstract class CommonObject
}
$datecreate = dol_now();
$this->db->begin();
// Insertion dans la base
@ -504,7 +506,11 @@ abstract class CommonObject
if (! $notrigger)
{
$result=$this->call_trigger(strtoupper($this->element).'_ADD_CONTACT', $user);
if ($result < 0) { $this->db->rollback(); return -1; }
if ($result < 0)
{
$this->db->rollback();
return -1;
}
}
$this->db->commit();

View File

@ -72,7 +72,12 @@ $userstatic=new User($db);
<div class="nowrap tagtd"><?php echo img_object('','user').' '.$langs->trans("Users"); ?></div>
<div class="tagtd"><?php echo $conf->global->MAIN_INFO_SOCIETE_NOM; ?></div>
<div class="tagtd maxwidthonsmartphone"><?php echo $form->select_dolusers($user->id, 'userid', 0, (! empty($userAlreadySelected)?$userAlreadySelected:null), 0, null, null, 0, 56); ?></div>
<div class="tagtd maxwidthonsmartphone"><?php echo $formcompany->selectTypeContact($object, '', 'type','internal'); ?></div>
<div class="tagtd maxwidthonsmartphone">
<?php
$tmpobject=$object;
if ($object->element == 'shipping' && is_object($objectsrc)) $tmpobject=$objectsrc;
echo $formcompany->selectTypeContact($tmpobject, '', 'type','internal');
?></div>
<div class="tagtd">&nbsp;</div>
<div class="tagtd" align="right"><input type="submit" class="button" value="<?php echo $langs->trans("Add"); ?>"></div>
</form>

View File

@ -77,7 +77,7 @@ if ($action == 'addcontact' && $user->rights->expedition->creer)
{
if ($result > 0 && $id > 0)
{
$result = $objectsrc->add_contact($_POST["contactid"], $_POST["type"], $_POST["source"]);
$result = $objectsrc->add_contact(GETPOST('userid') ? GETPOST('userid') : GETPOST('contactid'), $_POST["type"], $_POST["source"]);
}
if ($result >= 0)
@ -87,14 +87,15 @@ if ($action == 'addcontact' && $user->rights->expedition->creer)
}
else
{
if ($objectsrc->error == 'DB_ERROR_RECORD_ALREADY_EXISTS') {
if ($objectsrc->error == 'DB_ERROR_RECORD_ALREADY_EXISTS')
{
$langs->load("errors");
$mesg = $langs->trans("ErrorThisContactIsAlreadyDefinedAsThisType");
} else {
$mesg = $objectsrc->error;
$mesgs = $objectsrc->errors;
}
setEventMessage($mesg, 'errors');
setEventMessages($mesg, $mesgs, 'errors');
}
}
@ -236,7 +237,6 @@ if ($id > 0 || ! empty($ref))
// Lignes de contacts
echo '<br>';
// Contacts lines (modules that overwrite templates must declare this into descriptor)
$dirtpls=array_merge($conf->modules_parts['tpl'],array('/core/tpl'));
foreach($dirtpls as $reldir)