Fix phpcs
This commit is contained in:
parent
504a67daee
commit
25fa83bd06
@ -1,10 +1,11 @@
|
|||||||
<?php
|
<?php
|
||||||
/* Copyright (C) 2005-2017 Laurent Destailleur <eldy@users.sourceforge.net>
|
/*
|
||||||
* Copyright (C) 2009-2017 Regis Houssin <regis.houssin@inodbox.com>
|
* Copyright (C) 2005-2017 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||||
* Copyright (C) 2011-2014 Juanjo Menent <jmenent@2byte.es>
|
* Copyright (C) 2009-2017 Regis Houssin <regis.houssin@inodbox.com>
|
||||||
* Copyright (C) 2013 Cedric GROSS <c.gross@kreiz-it.fr>
|
* Copyright (C) 2011-2014 Juanjo Menent <jmenent@2byte.es>
|
||||||
* Copyright (C) 2014 Marcos García <marcosgdf@gmail.com>
|
* Copyright (C) 2013 Cedric GROSS <c.gross@kreiz-it.fr>
|
||||||
* Copyright (C) 2015 Bahfir Abbes <bafbes@gmail.com>
|
* Copyright (C) 2014 Marcos García <marcosgdf@gmail.com>
|
||||||
|
* Copyright (C) 2015 Bahfir Abbes <bafbes@gmail.com>
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* This program is free software; you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
@ -13,7 +14,7 @@
|
|||||||
*
|
*
|
||||||
* This program is distributed in the hope that it will be useful,
|
* This program is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* GNU General Public License for more details.
|
* GNU General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
@ -21,29 +22,31 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \file htdocs/core/triggers/interface_90_modSociete_ContactRoles.class.php
|
* \file htdocs/core/triggers/interface_90_modSociete_ContactRoles.class.php
|
||||||
* \ingroup agenda
|
* \ingroup agenda
|
||||||
* \brief Trigger file for company - contactroles
|
* \brief Trigger file for company - contactroles
|
||||||
*/
|
*/
|
||||||
|
require_once DOL_DOCUMENT_ROOT . '/core/triggers/dolibarrtriggers.class.php';
|
||||||
require_once DOL_DOCUMENT_ROOT.'/core/triggers/dolibarrtriggers.class.php';
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class of triggered functions for agenda module
|
* Class of triggered functions for agenda module
|
||||||
*/
|
*/
|
||||||
class InterfaceContactRoles extends DolibarrTriggers
|
class InterfaceContactRoles extends DolibarrTriggers
|
||||||
{
|
{
|
||||||
|
|
||||||
public $family = 'agenda';
|
public $family = 'agenda';
|
||||||
|
|
||||||
public $description = "Triggers of this module auto link contact to company.";
|
public $description = "Triggers of this module auto link contact to company.";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Version of the trigger
|
* Version of the trigger
|
||||||
|
*
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
public $version = self::VERSION_DOLIBARR;
|
public $version = self::VERSION_DOLIBARR;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
*
|
||||||
* @var string Image of the trigger
|
* @var string Image of the trigger
|
||||||
*/
|
*/
|
||||||
public $picto = 'action';
|
public $picto = 'action';
|
||||||
@ -53,65 +56,61 @@ class InterfaceContactRoles extends DolibarrTriggers
|
|||||||
* All functions "runTrigger" are triggered if file is inside directory htdocs/core/triggers or htdocs/module/code/triggers (and declared)
|
* All functions "runTrigger" are triggered if file is inside directory htdocs/core/triggers or htdocs/module/code/triggers (and declared)
|
||||||
*
|
*
|
||||||
* Following properties may be set before calling trigger. The may be completed by this trigger to be used for writing the event into database:
|
* Following properties may be set before calling trigger. The may be completed by this trigger to be used for writing the event into database:
|
||||||
* $object->socid or $object->fk_soc(id of thirdparty)
|
* $object->socid or $object->fk_soc(id of thirdparty)
|
||||||
* $object->element (element type of object)
|
* $object->element (element type of object)
|
||||||
*
|
*
|
||||||
* @param string $action Event action code
|
* @param string $action Event action code
|
||||||
* @param Object $object Object
|
* @param Object $object Object
|
||||||
* @param User $user Object user
|
* @param User $user Object user
|
||||||
* @param Translate $langs Object langs
|
* @param Translate $langs Object langs
|
||||||
* @param conf $conf Object conf
|
* @param conf $conf Object conf
|
||||||
* @return int <0 if KO, 0 if no triggered ran, >0 if OK
|
* @return int <0 if KO, 0 if no triggered ran, >0 if OK
|
||||||
*/
|
*/
|
||||||
public function runTrigger($action, $object, User $user, Translate $langs, Conf $conf)
|
public function runTrigger($action, $object, User $user, Translate $langs, Conf $conf)
|
||||||
{
|
{
|
||||||
|
|
||||||
if ($action === 'PROPAL_CREATE' || $action === 'ORDER_CREATE' || $action === 'BILL_CREATE'
|
if ($action === 'PROPAL_CREATE' || $action === 'ORDER_CREATE' || $action === 'BILL_CREATE'
|
||||||
|| $action === 'ORDER_SUPPLIER_CREATE' || $action === 'BILL_SUPPLIER_CREATE' || $action === 'PROPOSAL_SUPPLIER_CREATE'
|
|| $action === 'ORDER_SUPPLIER_CREATE' || $action === 'BILL_SUPPLIER_CREATE' || $action === 'PROPOSAL_SUPPLIER_CREATE'
|
||||||
|| $action === 'CONTRACT_CREATE' || $action === 'FICHINTER_CREATE' || $action === 'PROJECT_CREATE' || $action === 'TICKET_CREATE') {
|
|| $action === 'CONTRACT_CREATE' || $action === 'FICHINTER_CREATE' || $action === 'PROJECT_CREATE' || $action === 'TICKET_CREATE') {
|
||||||
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
|
dol_syslog("Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id);
|
||||||
|
|
||||||
$socid = (property_exists($object, 'socid') ? $object->socid : $object->fk_soc);
|
$socid = (property_exists($object, 'socid') ? $object->socid : $object->fk_soc);
|
||||||
|
|
||||||
if (! empty($socid) && $socid > 0) {
|
if (! empty($socid) && $socid > 0) {
|
||||||
require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php';
|
require_once DOL_DOCUMENT_ROOT . '/contact/class/contact.class.php';
|
||||||
$contactdefault = new Contact($this->db);
|
$contactdefault = new Contact($this->db);
|
||||||
$contactdefault->socid = $socid;
|
$contactdefault->socid = $socid;
|
||||||
$TContact = $contactdefault->getContactRoles($object->element);
|
$TContact = $contactdefault->getContactRoles($object->element);
|
||||||
|
|
||||||
if (is_array($TContact) && ! empty($TContact))
|
if (is_array($TContact) && ! empty($TContact)) {
|
||||||
{
|
$TContactAlreadyLinked = array();
|
||||||
$TContactAlreadyLinked = array();
|
if ($object->id > 0) {
|
||||||
if ($object->id > 0)
|
$cloneFrom = dol_clone($object, 1);
|
||||||
{
|
|
||||||
/* $class = get_class($object);
|
|
||||||
$cloneFrom = new $class($this->db);
|
|
||||||
$r = $cloneFrom->fetch($object->id); */
|
|
||||||
$cloneFrom = dol_clone($object, 1);
|
|
||||||
|
|
||||||
if (!empty($cloneFrom->id)) {
|
if (! empty($cloneFrom->id)) {
|
||||||
$TContactAlreadyLinked = array_merge($cloneFrom->liste_contact(-1, 'external'), $cloneFrom->liste_contact(-1, 'internal'));
|
$TContactAlreadyLinked = array_merge($cloneFrom->liste_contact(- 1, 'external'), $cloneFrom->liste_contact(- 1, 'internal'));
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
foreach($TContact as $i => $infos) {
|
foreach ($TContact as $i => $infos) {
|
||||||
foreach ($TContactAlreadyLinked as $contactData) {
|
foreach ($TContactAlreadyLinked as $contactData) {
|
||||||
if ($contactData['id'] == $infos['fk_socpeople'] && $contactData['fk_c_type_contact'] == $infos['type_contact']) unset($TContact[$i]);
|
if ($contactData['id'] == $infos['fk_socpeople'] && $contactData['fk_c_type_contact'] == $infos['type_contact'])
|
||||||
}
|
unset($TContact[$i]);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
$nb = 0;
|
$nb = 0;
|
||||||
foreach($TContact as $infos) {
|
foreach ($TContact as $infos) {
|
||||||
$res = $object->add_contact($infos['fk_socpeople'], $infos['type_contact']);
|
$res = $object->add_contact($infos['fk_socpeople'], $infos['type_contact']);
|
||||||
if ($res > 0) $nb++;
|
if ($res > 0)
|
||||||
}
|
$nb ++;
|
||||||
|
}
|
||||||
|
|
||||||
if($nb > 0) {
|
if ($nb > 0) {
|
||||||
setEventMessages($langs->trans('ContactAddedAutomatically', $nb), null, 'mesgs');
|
setEventMessages($langs->trans('ContactAddedAutomatically', $nb), null, 'mesgs');
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return 0;
|
}
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user