Missing hook to add button on intervention

Prepare to move location into resource
Can select which king of contact show into contact tab.
This commit is contained in:
Laurent Destailleur 2014-09-22 20:16:58 +02:00
parent cec7464410
commit f7f0059767
8 changed files with 153 additions and 84 deletions

View File

@ -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);

View File

@ -638,7 +638,10 @@ if ($action == 'create')
print '</td></tr>';
// Location
print '<tr><td>'.$langs->trans("Location").'</td><td colspan="3"><input type="text" name="location" size="50" value="'.(GETPOST('location')?GETPOST('location'):$object->location).'"></td></tr>';
if (empty($conf->global->AGENDA_DISABLE_LOCATION))
{
print '<tr><td>'.$langs->trans("Location").'</td><td colspan="3"><input type="text" name="location" size="50" value="'.(GETPOST('location')?GETPOST('location'):$object->location).'"></td></tr>';
}
// Assigned to
print '<tr><td class="nowrap">'.$langs->trans("ActionAffectedTo").'</td><td>';
@ -888,7 +891,10 @@ if ($id > 0)
print '</td></tr>';
// Location
print '<tr><td>'.$langs->trans("Location").'</td><td colspan="3"><input type="text" name="location" size="50" value="'.$object->location.'"></td></tr>';
if (empty($conf->global->AGENDA_DISABLE_LOCATION))
{
print '<tr><td>'.$langs->trans("Location").'</td><td colspan="3"><input type="text" name="location" size="50" value="'.$object->location.'"></td></tr>';
}
// Assigned to
print '<tr><td class="nowrap">'.$langs->trans("ActionAffectedTo").'</td><td colspan="3">';
@ -1020,13 +1026,16 @@ if ($id > 0)
// Full day event
print '<tr><td>'.$langs->trans("EventOnFullDay").'</td><td colspan="3">'.yn($object->fulldayevent).'</td></tr>';
$rowspan=4;
if (empty($conf->global->AGENDA_DISABLE_LOCATION)) $rowspan++;
// Date start
print '<tr><td width="30%">'.$langs->trans("DateActionStart").'</td><td colspan="2">';
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 '</td>';
print '<td rowspan="5" align="center" valign="middle" width="180">'."\n";
print '<td rowspan="'.$rowspan.'" align="center" valign="middle" width="180">'."\n";
print '<form name="listactionsfiltermonth" action="'.DOL_URL_ROOT.'/comm/action/index.php" method="POST">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print '<input type="hidden" name="action" value="show_month">';
@ -1079,7 +1088,10 @@ if ($id > 0)
print '</td></tr>';
// Location
print '<tr><td>'.$langs->trans("Location").'</td><td colspan="2">'.$object->location.'</td></tr>';
if (empty($conf->global->AGENDA_DISABLE_LOCATION))
{
print '<tr><td>'.$langs->trans("Location").'</td><td colspan="2">'.$object->location.'</td></tr>';
}
// Assigned to
print '<tr><td width="30%" class="nowrap">'.$langs->trans("ActionAffectedTo").'</td><td>';

View File

@ -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;
}
}
}

View File

@ -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

View File

@ -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

View File

@ -60,9 +60,13 @@ $userstatic=new User($db);
<div class="tagtd">&nbsp;</div>
</form>
<?php $var=false; ?>
<?php
$var=true;
if (empty($hideaddcontactforuser))
{
$var=!$var;
?>
<form class="tagtr impair" action="<?php echo $_SERVER["PHP_SELF"].'?id='.$object->id; ?>" method="POST">
<input type="hidden" name="token" value="<?php echo $_SESSION['newtoken']; ?>" />
<input type="hidden" name="id" value="<?php echo $object->id; ?>" />
@ -77,7 +81,13 @@ $userstatic=new User($db);
<div class="tagtd" align="right"><input type="submit" class="button" value="<?php echo $langs->trans("Add"); ?>"></div>
</form>
<?php $var=!$var; ?>
<?php
}
if (empty($hideaddcontactforthirdparty))
{
$var=!$var;
?>
<form class="tagtr pair" action="<?php echo $_SERVER["PHP_SELF"].'?id='.$object->id; ?>" method="POST">
<input type="hidden" name="token" value="<?php echo $_SESSION['newtoken']; ?>" />
@ -109,7 +119,8 @@ $userstatic=new User($db);
</div>
</form>
<?php } ?>
<?php }
} ?>
<form class="tagtr liste_titre">
<div class="tagtd"><?php echo $langs->trans("Source"); ?></div>
@ -123,7 +134,8 @@ $userstatic=new User($db);
<?php $var=true; ?>
<?php
foreach(array('internal','external') as $source) {
$arrayofsource=array('internal','external'); // Show both link to user and thirdparties contacts
foreach($arrayofsource as $source) {
$tmpobject=$object;
if ($object->element == 'shipping' && is_object($objectsrc)) $tmpobject=$objectsrc;

View File

@ -144,6 +144,9 @@ if ($id > 0 || ! empty($ref))
print '<br>';
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';
}

View File

@ -513,7 +513,7 @@ else if ($action == 'classifybilled' && $user->rights->ficheinter->creer)
}
else
{
$mesg='<div class="error">'.$object->error.'</div>';
setEventMessages($object->error, $object->errors, 'errors');
}
}
@ -1611,93 +1611,100 @@ else if ($id > 0 || ! empty($ref))
/*
* Actions buttons
*/
print '<div class="tabsAction">';
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 '<div class="inline-block divButAction"><a class="butAction" href="fiche.php?id='.$object->id.'&action=validate"';
print '>'.$langs->trans("Valid").'</a></div>';
}
// Modify
if ($object->statut == 1 && $user->rights->ficheinter->creer)
{
print '<div class="inline-block divButAction"><a class="butAction" href="fiche.php?id='.$object->id.'&action=modify">';
if (empty($conf->global->FICHINTER_DISABLE_DETAILS)) print $langs->trans("Modify");
else print $langs->trans("SetToDraft");
print '</a></div>';
}
// 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 '<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=presend&amp;mode=init">'.$langs->trans('SendByMail').'</a></div>';
print '<div class="inline-block divButAction"><a class="butAction" href="fiche.php?id='.$object->id.'&action=validate"';
print '>'.$langs->trans("Valid").'</a></div>';
}
else print '<div class="inline-block divButAction"><a class="butActionRefused" href="#">'.$langs->trans('SendByMail').'</a></div>';
}
// 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 '<div class="inline-block divButAction"><a class="butAction" href="fiche.php?id='.$object->id.'&action=modify">';
if (empty($conf->global->FICHINTER_DISABLE_DETAILS)) print $langs->trans("Modify");
else print $langs->trans("SetToDraft");
print '</a></div>';
}
// Send
if ($object->statut > 0)
{
if (empty($conf->global->MAIN_USE_ADVANCED_PERMS) || $user->rights->ficheinter->ficheinter_advance->send)
{
print '<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=presend&amp;mode=init">'.$langs->trans('SendByMail').'</a></div>';
}
else print '<div class="inline-block divButAction"><a class="butActionRefused" href="#">'.$langs->trans('SendByMail').'</a></div>';
}
// 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 '<div class="inline-block divButAction"><a class="butAction" href="'.DOL_URL_ROOT.'/comm/action/fiche.php?action=create&amp;origin='.$object->element.'&amp;originid='.$object->id.'&amp;socid='.$object->socid.'&amp;backtopage='.urlencode($_SERVER["PHP_SELF"].'?id='.$object->id).'">'.$langs->trans("AddEvent").'</a></div>';
else print '<div class="inline-block divButAction"><a class="butActionRefused" href="#" title="'.$langs->trans("NotEnoughPermissions").'">'.$langs->trans("AddEvent").'</a></div>';
}
}
}
// Proposal
if (! empty($conf->propal->enabled) && $object->statut > 0)
{
$langs->load("propal");
if ($object->statut < 2)
{
if ($user->rights->agenda->myactions->create) print '<div class="inline-block divButAction"><a class="butAction" href="'.DOL_URL_ROOT.'/comm/action/fiche.php?action=create&amp;origin='.$object->element.'&amp;originid='.$object->id.'&amp;socid='.$object->socid.'&amp;backtopage='.urlencode($_SERVER["PHP_SELF"].'?id='.$object->id).'">'.$langs->trans("AddEvent").'</a></div>';
else print '<div class="inline-block divButAction"><a class="butActionRefused" href="#" title="'.$langs->trans("NotEnoughPermissions").'">'.$langs->trans("AddEvent").'</a></div>';
if ($user->rights->propal->creer) print '<div class="inline-block divButAction"><a class="butAction" href="'.DOL_URL_ROOT.'/comm/propal.php?action=create&amp;origin='.$object->element.'&amp;originid='.$object->id.'&amp;socid='.$object->socid.'">'.$langs->trans("AddProp").'</a></div>';
else print '<div class="inline-block divButAction"><a class="butActionRefused" href="#" title="'.$langs->trans("NotEnoughPermissions").'">'.$langs->trans("AddProp").'</a></div>';
}
}
}
// 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 '<div class="inline-block divButAction"><a class="butAction" href="'.DOL_URL_ROOT.'/comm/propal.php?action=create&amp;origin='.$object->element.'&amp;originid='.$object->id.'&amp;socid='.$object->socid.'">'.$langs->trans("AddProp").'</a></div>';
else print '<div class="inline-block divButAction"><a class="butActionRefused" href="#" title="'.$langs->trans("NotEnoughPermissions").'">'.$langs->trans("AddProp").'</a></div>';
}
}
// Invoicing
if (! empty($conf->facture->enabled) && $object->statut > 0)
{
$langs->load("bills");
if ($object->statut < 2)
{
if ($user->rights->facture->creer) print '<div class="inline-block divButAction"><a class="butAction" href="'.DOL_URL_ROOT.'/compta/facture.php?action=create&amp;origin='.$object->element.'&amp;originid='.$object->id.'&amp;socid='.$object->socid.'">'.$langs->trans("CreateBill").'</a></div>';
else print '<div class="inline-block divButAction"><a class="butActionRefused" href="#" title="'.$langs->trans("NotEnoughPermissions").'">'.$langs->trans("CreateBill").'</a></div>';
}
if (! empty($conf->global->FICHINTER_CLASSIFY_BILLED))
{
if ($object->statut != 2)
$langs->load("bills");
if ($object->statut < 2)
{
print '<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=classifybilled">'.$langs->trans("InterventionClassifyBilled").'</a></div>';
if ($user->rights->facture->creer) print '<div class="inline-block divButAction"><a class="butAction" href="'.DOL_URL_ROOT.'/compta/facture.php?action=create&amp;origin='.$object->element.'&amp;originid='.$object->id.'&amp;socid='.$object->socid.'">'.$langs->trans("CreateBill").'</a></div>';
else print '<div class="inline-block divButAction"><a class="butActionRefused" href="#" title="'.$langs->trans("NotEnoughPermissions").'">'.$langs->trans("CreateBill").'</a></div>';
}
else
if (! empty($conf->global->FICHINTER_CLASSIFY_BILLED))
{
print '<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=classifyunbilled">'.$langs->trans("InterventionClassifyUnBilled").'</a></div>';
if ($object->statut != 2)
{
print '<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=classifybilled">'.$langs->trans("InterventionClassifyBilled").'</a></div>';
}
else
{
print '<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=classifyunbilled">'.$langs->trans("InterventionClassifyUnBilled").'</a></div>';
}
}
}
}
// Delete
if (($object->statut == 0 && $user->rights->ficheinter->creer) || $user->rights->ficheinter->supprimer)
{
print '<div class="inline-block divButAction"><a class="butActionDelete" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=delete"';
print '>'.$langs->trans('Delete').'</a></div>';
}
// Delete
if (($object->statut == 0 && $user->rights->ficheinter->creer) || $user->rights->ficheinter->supprimer)
{
print '<div class="inline-block divButAction"><a class="butActionDelete" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=delete"';
print '>'.$langs->trans('Delete').'</a></div>';
}
}
}
}