From f7f00597676afdd7f60ef05cf6b619082d7a9779 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 22 Sep 2014 20:16:58 +0200 Subject: [PATCH] Missing hook to add button on intervention Prepare to move location into resource Can select which king of contact show into contact tab. --- htdocs/comm/action/class/actioncomm.class.php | 5 +- htdocs/comm/action/fiche.php | 20 ++- htdocs/core/class/commonobject.class.php | 42 +++++- htdocs/core/class/extrafields.class.php | 2 +- htdocs/core/class/interfaces.class.php | 4 +- htdocs/core/tpl/contacts.tpl.php | 22 ++- htdocs/fichinter/contact.php | 3 + htdocs/fichinter/fiche.php | 139 +++++++++--------- 8 files changed, 153 insertions(+), 84 deletions(-) diff --git a/htdocs/comm/action/class/actioncomm.class.php b/htdocs/comm/action/class/actioncomm.class.php index 4fe49999111..e08f5518c1f 100644 --- a/htdocs/comm/action/class/actioncomm.class.php +++ b/htdocs/comm/action/class/actioncomm.class.php @@ -534,9 +534,11 @@ class ActionComm extends CommonObject * @param int $fk_element Id of element action is linked to * @param string $elementtype Type of element action is linked to * @param string $filter Other filter + * @param string $sortfield Sort on this field + * @param string $sortorder ASC or DESC * @return array or string Error string if KO, array with actions if OK */ - static function getActions($db, $socid=0, $fk_element=0, $elementtype='', $filter='') + static function getActions($db, $socid=0, $fk_element=0, $elementtype='', $filter='', $sortfield='', $sortorder='') { global $conf, $langs; @@ -552,6 +554,7 @@ class ActionComm extends CommonObject else $sql.= " AND a.fk_element = ".$fk_element." AND a.elementtype = '".$elementtype."'"; } if (! empty($filter)) $sql.= $filter; + if ($sortorder && $sortfield) $sql.=$db->order($sortfield, $sortorder); dol_syslog(get_class()."::getActions", LOG_DEBUG); $resql=$db->query($sql); diff --git a/htdocs/comm/action/fiche.php b/htdocs/comm/action/fiche.php index 929600512c7..46e420866a2 100644 --- a/htdocs/comm/action/fiche.php +++ b/htdocs/comm/action/fiche.php @@ -638,7 +638,10 @@ if ($action == 'create') print ''; // Location - print ''.$langs->trans("Location").''; + if (empty($conf->global->AGENDA_DISABLE_LOCATION)) + { + print ''.$langs->trans("Location").''; + } // Assigned to print ''.$langs->trans("ActionAffectedTo").''; @@ -888,7 +891,10 @@ if ($id > 0) print ''; // Location - print ''.$langs->trans("Location").''; + if (empty($conf->global->AGENDA_DISABLE_LOCATION)) + { + print ''.$langs->trans("Location").''; + } // Assigned to print ''.$langs->trans("ActionAffectedTo").''; @@ -1020,13 +1026,16 @@ if ($id > 0) // Full day event print ''.$langs->trans("EventOnFullDay").''.yn($object->fulldayevent).''; + $rowspan=4; + if (empty($conf->global->AGENDA_DISABLE_LOCATION)) $rowspan++; + // Date start print ''.$langs->trans("DateActionStart").''; if (! $object->fulldayevent) print dol_print_date($object->datep,'dayhour'); else print dol_print_date($object->datep,'day'); if ($object->percentage == 0 && $object->datep && $object->datep < ($now - $delay_warning)) print img_warning($langs->trans("Late")); print ''; - print ''."\n"; + print ''."\n"; print '
'; print ''; print ''; @@ -1079,7 +1088,10 @@ if ($id > 0) print ''; // Location - print ''.$langs->trans("Location").''.$object->location.''; + if (empty($conf->global->AGENDA_DISABLE_LOCATION)) + { + print ''.$langs->trans("Location").''.$object->location.''; + } // Assigned to print ''.$langs->trans("ActionAffectedTo").''; diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 1059d1af07d..82d838a30c8 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -2035,6 +2035,8 @@ abstract class CommonObject */ function setStatut($status,$elementId='',$elementType='') { + global $user,$langs,$conf; + $elementId = (!empty($elementId)?$elementId:$this->id); $elementTable = (!empty($elementType)?$elementType:$this->table_element); @@ -2050,9 +2052,36 @@ abstract class CommonObject dol_syslog(get_class($this)."::setStatut", LOG_DEBUG); if ($this->db->query($sql)) { - $this->db->commit(); - $this->statut = $status; - return 1; + if (! $error) + { + $trigkey=''; + if ($this->element == 'fichinter' && $status == 2) $trigkey='FICHINTER_CLASSIFYBILLED'; + + if ($trigkey) + { + // Appel des triggers + include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php'; + $interface=new Interfaces($this->db); + $result=$interface->run_triggers($trigkey,$this,$user,$langs,$conf); + if ($result < 0) { + $error++; $this->errors=$interface->errors; + } + // Fin appel triggers + } + } + + if (! $error) + { + $this->db->commit(); + $this->statut = $status; + return 1; + } + else + { + $this->db->rollback(); + dol_syslog(get_class($this)."::setStatus ".$this->error,LOG_ERR); + return -1; + } } else { @@ -2133,8 +2162,10 @@ abstract class CommonObject * @param array $optionsArray Array resulting of call of extrafields->fetch_name_optionals_label() * @return int <0 if error, 0 if no optionals to find nor found, 1 if a line is found and optional loaded */ - function fetch_optionals($rowid,$optionsArray='') + function fetch_optionals($rowid='',$optionsArray='') { + if (empty($rowid)) $rowid=$this->id; + if (! is_array($optionsArray)) { // optionsArray not already loaded, so we load it @@ -2143,7 +2174,6 @@ abstract class CommonObject $optionsArray = $extrafields->fetch_name_optionals_label($this->table_element); } - // Request to get complementary values if (count($optionsArray) > 0) { @@ -2170,7 +2200,7 @@ abstract class CommonObject if ($key != 'rowid' && $key != 'tms' && $key != 'fk_member' && ! is_int($key)) { // we can add this attribute to adherent object - $this->array_options["options_$key"]=$value; + $this->array_options["options_".$key]=$value; } } } diff --git a/htdocs/core/class/extrafields.class.php b/htdocs/core/class/extrafields.class.php index d5d16efc2e9..a25115be878 100644 --- a/htdocs/core/class/extrafields.class.php +++ b/htdocs/core/class/extrafields.class.php @@ -514,7 +514,7 @@ class ExtraFields /** - * Load array this->attribute_label + * Load array this->attribute_xxx like attribute_label, attribute_type, ... * * @param string $elementtype Type of element ('adherent', 'commande', societe', 'facture', 'propal', 'product', ...) * @param boolean $forceload Force load of extra fields whatever is option MAIN_EXTRAFIELDS_DISABLED diff --git a/htdocs/core/class/interfaces.class.php b/htdocs/core/class/interfaces.class.php index 50a9cced421..e441dbe5e96 100644 --- a/htdocs/core/class/interfaces.class.php +++ b/htdocs/core/class/interfaces.class.php @@ -60,7 +60,9 @@ class Interfaces // Check parameters if (! is_object($object) || ! is_object($conf)) // Error { - dol_syslog(get_class($this).'::run_triggers was called with wrong parameters action='.$action.' object='.is_object($object).' user='.is_object($user).' langs='.is_object($langs).' conf='.is_object($conf), LOG_ERR); + $this->error='function run_triggers called with wrong parameters action='.$action.' object='.is_object($object).' user='.is_object($user).' langs='.is_object($langs).' conf='.is_object($conf); + dol_syslog(get_class($this).'::run_triggers '.$this->error, LOG_ERR); + $this->errors[]=$this->error; return -1; } if (! is_object($user) || ! is_object($langs)) // Warning diff --git a/htdocs/core/tpl/contacts.tpl.php b/htdocs/core/tpl/contacts.tpl.php index 35849720e7d..fda7aa00832 100644 --- a/htdocs/core/tpl/contacts.tpl.php +++ b/htdocs/core/tpl/contacts.tpl.php @@ -60,9 +60,13 @@ $userstatic=new User($db);
 
- - +
" /> @@ -77,7 +81,13 @@ $userstatic=new User($db);
">
- +
" /> @@ -109,7 +119,8 @@ $userstatic=new User($db);
- +
trans("Source"); ?>
@@ -123,7 +134,8 @@ $userstatic=new User($db); element == 'shipping' && is_object($objectsrc)) $tmpobject=$objectsrc; diff --git a/htdocs/fichinter/contact.php b/htdocs/fichinter/contact.php index 8f540dd2ebd..b0f9ada3af7 100644 --- a/htdocs/fichinter/contact.php +++ b/htdocs/fichinter/contact.php @@ -144,6 +144,9 @@ if ($id > 0 || ! empty($ref)) print '
'; + if (! empty($conf->global->FICHINTER_HIDE_ADD_CONTACT_USER)) $hideaddcontactforuser=1; + if (! empty($conf->global->FICHINTER_HIDE_ADD_CONTACT_THIPARTY)) $hideaddcontactforthirdparty=1; + // Contacts lines include DOL_DOCUMENT_ROOT.'/core/tpl/contacts.tpl.php'; } diff --git a/htdocs/fichinter/fiche.php b/htdocs/fichinter/fiche.php index edd5372471e..56848fcb0bf 100644 --- a/htdocs/fichinter/fiche.php +++ b/htdocs/fichinter/fiche.php @@ -513,7 +513,7 @@ else if ($action == 'classifybilled' && $user->rights->ficheinter->creer) } else { - $mesg='
'.$object->error.'
'; + setEventMessages($object->error, $object->errors, 'errors'); } } @@ -1611,93 +1611,100 @@ else if ($id > 0 || ! empty($ref)) /* * Actions buttons */ + print '
'; - if ($user->societe_id == 0) + $parameters = array(); + $reshook = $hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action); // Note that $action and $object may have been + // modified by hook + if (empty($reshook)) { - if ($action != 'editdescription' && ($action != 'presend')) + if ($user->societe_id == 0) { - // Validate - if ($object->statut == 0 && $user->rights->ficheinter->creer && (count($object->lines) > 0 || ! empty($conf->global->FICHINTER_DISABLE_DETAILS))) + if ($action != 'editdescription' && ($action != 'presend')) { - print ''; - } - - // Modify - if ($object->statut == 1 && $user->rights->ficheinter->creer) - { - print ''; - } - - // Send - if ($object->statut > 0) - { - if (empty($conf->global->MAIN_USE_ADVANCED_PERMS) || $user->rights->ficheinter->ficheinter_advance->send) + // Validate + if ($object->statut == 0 && $user->rights->ficheinter->creer && (count($object->lines) > 0 || ! empty($conf->global->FICHINTER_DISABLE_DETAILS))) { - print ''; + print ''; } - else print ''; - } - // Event agenda - if (! empty($conf->global->FICHINTER_ADDLINK_TO_EVENT)) - { - if (! empty($conf->agenda->enabled) && $object->statut > 0) + // Modify + if ($object->statut == 1 && $user->rights->ficheinter->creer) { - $langs->load("agenda"); + print ''; + } + + // Send + if ($object->statut > 0) + { + if (empty($conf->global->MAIN_USE_ADVANCED_PERMS) || $user->rights->ficheinter->ficheinter_advance->send) + { + print ''; + } + else print ''; + } + + // Event agenda + if (! empty($conf->global->FICHINTER_ADDLINK_TO_EVENT)) + { + if (! empty($conf->agenda->enabled) && $object->statut > 0) + { + $langs->load("agenda"); + if ($object->statut < 2) + { + if ($user->rights->agenda->myactions->create) print ''; + else print ''; + } + } + } + + // Proposal + if (! empty($conf->propal->enabled) && $object->statut > 0) + { + $langs->load("propal"); if ($object->statut < 2) { - if ($user->rights->agenda->myactions->create) print ''; - else print ''; + if ($user->rights->propal->creer) print ''; + else print ''; } } - } - // Proposal - if (! empty($conf->propal->enabled) && $object->statut > 0) - { - $langs->load("propal"); - if ($object->statut < 2) + // Invoicing + if (! empty($conf->facture->enabled) && $object->statut > 0) { - if ($user->rights->propal->creer) print ''; - else print ''; - } - } - - // Invoicing - if (! empty($conf->facture->enabled) && $object->statut > 0) - { - $langs->load("bills"); - if ($object->statut < 2) - { - if ($user->rights->facture->creer) print ''; - else print ''; - } - - if (! empty($conf->global->FICHINTER_CLASSIFY_BILLED)) - { - if ($object->statut != 2) + $langs->load("bills"); + if ($object->statut < 2) { - print ''; + if ($user->rights->facture->creer) print ''; + else print ''; } - else + + if (! empty($conf->global->FICHINTER_CLASSIFY_BILLED)) { - print ''; + if ($object->statut != 2) + { + print ''; + } + else + { + print ''; + } } } - } - // Delete - if (($object->statut == 0 && $user->rights->ficheinter->creer) || $user->rights->ficheinter->supprimer) - { - print ''; - } + // Delete + if (($object->statut == 0 && $user->rights->ficheinter->creer) || $user->rights->ficheinter->supprimer) + { + print ''; + } + } } }