NEW: : add doActions hook method call in contract card
This commit is contained in:
parent
5d34f787a3
commit
e9bb296a4f
@ -97,12 +97,17 @@ $permissiondellink=$user->rights->contrat->creer; // Used by the include of acti
|
|||||||
* Actions
|
* Actions
|
||||||
*/
|
*/
|
||||||
|
|
||||||
include DOL_DOCUMENT_ROOT.'/core/actions_setnotes.inc.php'; // Must be include, not includ_once
|
$parameters = array('socid' => $socid);
|
||||||
|
$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
|
||||||
include DOL_DOCUMENT_ROOT.'/core/actions_dellink.inc.php'; // Must be include, not include_once
|
if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
|
||||||
|
if (empty($reshook))
|
||||||
if ($action == 'confirm_active' && $confirm == 'yes' && $user->rights->contrat->activer)
|
|
||||||
{
|
{
|
||||||
|
include DOL_DOCUMENT_ROOT.'/core/actions_setnotes.inc.php'; // Must be include, not includ_once
|
||||||
|
|
||||||
|
include DOL_DOCUMENT_ROOT.'/core/actions_dellink.inc.php'; // Must be include, not include_once
|
||||||
|
|
||||||
|
if ($action == 'confirm_active' && $confirm == 'yes' && $user->rights->contrat->activer)
|
||||||
|
{
|
||||||
$result = $object->active_line($user, GETPOST('ligne'), GETPOST('date'), GETPOST('dateend'), GETPOST('comment'));
|
$result = $object->active_line($user, GETPOST('ligne'), GETPOST('date'), GETPOST('dateend'), GETPOST('comment'));
|
||||||
|
|
||||||
if ($result > 0)
|
if ($result > 0)
|
||||||
@ -113,10 +118,10 @@ if ($action == 'confirm_active' && $confirm == 'yes' && $user->rights->contrat->
|
|||||||
else {
|
else {
|
||||||
setEventMessage($object->error,'errors');
|
setEventMessage($object->error,'errors');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
else if ($action == 'confirm_closeline' && $confirm == 'yes' && $user->rights->contrat->activer)
|
else if ($action == 'confirm_closeline' && $confirm == 'yes' && $user->rights->contrat->activer)
|
||||||
{
|
{
|
||||||
if (! GETPOST('dateend'))
|
if (! GETPOST('dateend'))
|
||||||
{
|
{
|
||||||
$error++;
|
$error++;
|
||||||
@ -130,15 +135,16 @@ else if ($action == 'confirm_closeline' && $confirm == 'yes' && $user->rights->c
|
|||||||
header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id);
|
header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id);
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
else {
|
else
|
||||||
|
{
|
||||||
setEventMessage($object->error,'errors');
|
setEventMessage($object->error,'errors');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Si ajout champ produit predefini
|
// Si ajout champ produit predefini
|
||||||
if (GETPOST('mode')=='predefined')
|
if (GETPOST('mode')=='predefined')
|
||||||
{
|
{
|
||||||
$date_start='';
|
$date_start='';
|
||||||
$date_end='';
|
$date_end='';
|
||||||
if (GETPOST('date_startmonth') && GETPOST('date_startday') && GETPOST('date_startyear'))
|
if (GETPOST('date_startmonth') && GETPOST('date_startday') && GETPOST('date_startyear'))
|
||||||
@ -149,11 +155,11 @@ if (GETPOST('mode')=='predefined')
|
|||||||
{
|
{
|
||||||
$date_end=dol_mktime(GETPOST('date_endhour'), GETPOST('date_endmin'), 0, GETPOST('date_endmonth'), GETPOST('date_endday'), GETPOST('date_endyear'));
|
$date_end=dol_mktime(GETPOST('date_endhour'), GETPOST('date_endmin'), 0, GETPOST('date_endmonth'), GETPOST('date_endday'), GETPOST('date_endyear'));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Si ajout champ produit libre
|
// Si ajout champ produit libre
|
||||||
if (GETPOST('mode')=='libre')
|
if (GETPOST('mode')=='libre')
|
||||||
{
|
{
|
||||||
$date_start_sl='';
|
$date_start_sl='';
|
||||||
$date_end_sl='';
|
$date_end_sl='';
|
||||||
if (GETPOST('date_start_slmonth') && GETPOST('date_start_slday') && GETPOST('date_start_slyear'))
|
if (GETPOST('date_start_slmonth') && GETPOST('date_start_slday') && GETPOST('date_start_slyear'))
|
||||||
@ -164,38 +170,38 @@ if (GETPOST('mode')=='libre')
|
|||||||
{
|
{
|
||||||
$date_end_sl=dol_mktime(GETPOST('date_end_slhour'), GETPOST('date_end_slmin'), 0, GETPOST('date_end_slmonth'), GETPOST('date_end_slday'), GETPOST('date_end_slyear'));
|
$date_end_sl=dol_mktime(GETPOST('date_end_slhour'), GETPOST('date_end_slmin'), 0, GETPOST('date_end_slmonth'), GETPOST('date_end_slday'), GETPOST('date_end_slyear'));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Param dates
|
// Param dates
|
||||||
$date_contrat='';
|
$date_contrat='';
|
||||||
$date_start_update='';
|
$date_start_update='';
|
||||||
$date_end_update='';
|
$date_end_update='';
|
||||||
$date_start_real_update='';
|
$date_start_real_update='';
|
||||||
$date_end_real_update='';
|
$date_end_real_update='';
|
||||||
if (GETPOST('date_start_updatemonth') && GETPOST('date_start_updateday') && GETPOST('date_start_updateyear'))
|
if (GETPOST('date_start_updatemonth') && GETPOST('date_start_updateday') && GETPOST('date_start_updateyear'))
|
||||||
{
|
{
|
||||||
$date_start_update=dol_mktime(GETPOST('date_start_updatehour'), GETPOST('date_start_updatemin'), 0, GETPOST('date_start_updatemonth'), GETPOST('date_start_updateday'), GETPOST('date_start_updateyear'));
|
$date_start_update=dol_mktime(GETPOST('date_start_updatehour'), GETPOST('date_start_updatemin'), 0, GETPOST('date_start_updatemonth'), GETPOST('date_start_updateday'), GETPOST('date_start_updateyear'));
|
||||||
}
|
}
|
||||||
if (GETPOST('date_end_updatemonth') && GETPOST('date_end_updateday') && GETPOST('date_end_updateyear'))
|
if (GETPOST('date_end_updatemonth') && GETPOST('date_end_updateday') && GETPOST('date_end_updateyear'))
|
||||||
{
|
{
|
||||||
$date_end_update=dol_mktime(GETPOST('date_end_updatehour'), GETPOST('date_end_updatemin'), 0, GETPOST('date_end_updatemonth'), GETPOST('date_end_updateday'), GETPOST('date_end_updateyear'));
|
$date_end_update=dol_mktime(GETPOST('date_end_updatehour'), GETPOST('date_end_updatemin'), 0, GETPOST('date_end_updatemonth'), GETPOST('date_end_updateday'), GETPOST('date_end_updateyear'));
|
||||||
}
|
}
|
||||||
if (GETPOST('date_start_real_updatemonth') && GETPOST('date_start_real_updateday') && GETPOST('date_start_real_updateyear'))
|
if (GETPOST('date_start_real_updatemonth') && GETPOST('date_start_real_updateday') && GETPOST('date_start_real_updateyear'))
|
||||||
{
|
{
|
||||||
$date_start_real_update=dol_mktime(GETPOST('date_start_real_updatehour'), GETPOST('date_start_real_updatemin'), 0, GETPOST('date_start_real_updatemonth'), GETPOST('date_start_real_updateday'), GETPOST('date_start_real_updateyear'));
|
$date_start_real_update=dol_mktime(GETPOST('date_start_real_updatehour'), GETPOST('date_start_real_updatemin'), 0, GETPOST('date_start_real_updatemonth'), GETPOST('date_start_real_updateday'), GETPOST('date_start_real_updateyear'));
|
||||||
}
|
}
|
||||||
if (GETPOST('date_end_real_updatemonth') && GETPOST('date_end_real_updateday') && GETPOST('date_end_real_updateyear'))
|
if (GETPOST('date_end_real_updatemonth') && GETPOST('date_end_real_updateday') && GETPOST('date_end_real_updateyear'))
|
||||||
{
|
{
|
||||||
$date_end_real_update=dol_mktime(GETPOST('date_end_real_updatehour'), GETPOST('date_end_real_updatemin'), 0, GETPOST('date_end_real_updatemonth'), GETPOST('date_end_real_updateday'), GETPOST('date_end_real_updateyear'));
|
$date_end_real_update=dol_mktime(GETPOST('date_end_real_updatehour'), GETPOST('date_end_real_updatemin'), 0, GETPOST('date_end_real_updatemonth'), GETPOST('date_end_real_updateday'), GETPOST('date_end_real_updateyear'));
|
||||||
}
|
}
|
||||||
if (GETPOST('remonth') && GETPOST('reday') && GETPOST('reyear'))
|
if (GETPOST('remonth') && GETPOST('reday') && GETPOST('reyear'))
|
||||||
{
|
{
|
||||||
$datecontrat = dol_mktime(GETPOST('rehour'), GETPOST('remin'), 0, GETPOST('remonth'), GETPOST('reday'), GETPOST('reyear'));
|
$datecontrat = dol_mktime(GETPOST('rehour'), GETPOST('remin'), 0, GETPOST('remonth'), GETPOST('reday'), GETPOST('reyear'));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add contract
|
// Add contract
|
||||||
if ($action == 'add' && $user->rights->contrat->creer)
|
if ($action == 'add' && $user->rights->contrat->creer)
|
||||||
{
|
{
|
||||||
// Check
|
// Check
|
||||||
if (empty($datecontrat))
|
if (empty($datecontrat))
|
||||||
{
|
{
|
||||||
@ -381,16 +387,16 @@ if ($action == 'add' && $user->rights->contrat->creer)
|
|||||||
$action='create';
|
$action='create';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
else if ($action == 'classin' && $user->rights->contrat->creer)
|
else if ($action == 'classin' && $user->rights->contrat->creer)
|
||||||
{
|
{
|
||||||
$object->setProject(GETPOST('projectid'));
|
$object->setProject(GETPOST('projectid'));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add a new line
|
// Add a new line
|
||||||
else if ($action == 'addline' && $user->rights->contrat->creer)
|
else if ($action == 'addline' && $user->rights->contrat->creer)
|
||||||
{
|
{
|
||||||
// Set if we used free entry or predefined product
|
// Set if we used free entry or predefined product
|
||||||
$predef='';
|
$predef='';
|
||||||
$product_desc=(GETPOST('dp_desc')?GETPOST('dp_desc'):'');
|
$product_desc=(GETPOST('dp_desc')?GETPOST('dp_desc'):'');
|
||||||
@ -608,10 +614,10 @@ else if ($action == 'addline' && $user->rights->contrat->creer)
|
|||||||
setEventMessage($object->error,'errors');
|
setEventMessage($object->error,'errors');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
else if ($action == 'updateligne' && $user->rights->contrat->creer && ! GETPOST('cancel'))
|
else if ($action == 'updateligne' && $user->rights->contrat->creer && ! GETPOST('cancel'))
|
||||||
{
|
{
|
||||||
$objectline = new ContratLigne($db);
|
$objectline = new ContratLigne($db);
|
||||||
if ($objectline->fetch(GETPOST('elrowid')))
|
if ($objectline->fetch(GETPOST('elrowid')))
|
||||||
{
|
{
|
||||||
@ -677,10 +683,10 @@ else if ($action == 'updateligne' && $user->rights->contrat->creer && ! GETPOST(
|
|||||||
{
|
{
|
||||||
setEventMessage($objectline->error,'errors');
|
setEventMessage($objectline->error,'errors');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
else if ($action == 'confirm_deleteline' && $confirm == 'yes' && $user->rights->contrat->creer)
|
else if ($action == 'confirm_deleteline' && $confirm == 'yes' && $user->rights->contrat->creer)
|
||||||
{
|
{
|
||||||
$result = $object->deleteline(GETPOST('lineid'),$user);
|
$result = $object->deleteline(GETPOST('lineid'),$user);
|
||||||
|
|
||||||
if ($result >= 0)
|
if ($result >= 0)
|
||||||
@ -692,21 +698,21 @@ else if ($action == 'confirm_deleteline' && $confirm == 'yes' && $user->rights->
|
|||||||
{
|
{
|
||||||
setEventMessage($object->error,'errors');
|
setEventMessage($object->error,'errors');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
else if ($action == 'confirm_valid' && $confirm == 'yes' && $user->rights->contrat->creer)
|
else if ($action == 'confirm_valid' && $confirm == 'yes' && $user->rights->contrat->creer)
|
||||||
{
|
{
|
||||||
$result = $object->validate($user);
|
$result = $object->validate($user);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Close all lines
|
// Close all lines
|
||||||
else if ($action == 'confirm_close' && $confirm == 'yes' && $user->rights->contrat->creer)
|
else if ($action == 'confirm_close' && $confirm == 'yes' && $user->rights->contrat->creer)
|
||||||
{
|
{
|
||||||
$object->cloture($user);
|
$object->cloture($user);
|
||||||
}
|
}
|
||||||
|
|
||||||
else if ($action == 'confirm_delete' && $confirm == 'yes' && $user->rights->contrat->supprimer)
|
else if ($action == 'confirm_delete' && $confirm == 'yes' && $user->rights->contrat->supprimer)
|
||||||
{
|
{
|
||||||
$result=$object->delete($user);
|
$result=$object->delete($user);
|
||||||
if ($result >= 0)
|
if ($result >= 0)
|
||||||
{
|
{
|
||||||
@ -717,10 +723,10 @@ else if ($action == 'confirm_delete' && $confirm == 'yes' && $user->rights->cont
|
|||||||
{
|
{
|
||||||
setEventMessage($object->error,'errors');
|
setEventMessage($object->error,'errors');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
else if ($action == 'confirm_move' && $confirm == 'yes' && $user->rights->contrat->creer)
|
else if ($action == 'confirm_move' && $confirm == 'yes' && $user->rights->contrat->creer)
|
||||||
{
|
{
|
||||||
if (GETPOST('newcid') > 0)
|
if (GETPOST('newcid') > 0)
|
||||||
{
|
{
|
||||||
$contractline = new ContratLigne($db);
|
$contractline = new ContratLigne($db);
|
||||||
@ -741,7 +747,7 @@ else if ($action == 'confirm_move' && $confirm == 'yes' && $user->rights->contra
|
|||||||
{
|
{
|
||||||
setEventMessage($langs->trans("ErrorFieldRequired",$langs->transnoentities("RefNewContract")),'errors');
|
setEventMessage($langs->trans("ErrorFieldRequired",$langs->transnoentities("RefNewContract")),'errors');
|
||||||
}
|
}
|
||||||
} else if ($action == 'update_extras') {
|
} else if ($action == 'update_extras') {
|
||||||
// Fill array 'array_options' with data from update form
|
// Fill array 'array_options' with data from update form
|
||||||
$extralabels = $extrafields->fetch_name_optionals_label($object->table_element);
|
$extralabels = $extrafields->fetch_name_optionals_label($object->table_element);
|
||||||
$ret = $extrafields->setOptionalsFromPost($extralabels, $object, GETPOST('attribute'));
|
$ret = $extrafields->setOptionalsFromPost($extralabels, $object, GETPOST('attribute'));
|
||||||
@ -761,7 +767,7 @@ else if ($action == 'confirm_move' && $confirm == 'yes' && $user->rights->contra
|
|||||||
$action = 'edit_extras';
|
$action = 'edit_extras';
|
||||||
setEventMessage($object->error,'errors');
|
setEventMessage($object->error,'errors');
|
||||||
}
|
}
|
||||||
} elseif ($action=='setref_supplier') {
|
} elseif ($action=='setref_supplier') {
|
||||||
$cancelbutton = GETPOST('cancel');
|
$cancelbutton = GETPOST('cancel');
|
||||||
|
|
||||||
if (!$cancelbutton) {
|
if (!$cancelbutton) {
|
||||||
@ -784,7 +790,7 @@ else if ($action == 'confirm_move' && $confirm == 'yes' && $user->rights->contra
|
|||||||
header("Location: " . $_SERVER['PHP_SELF'] . "?id=" . $id);
|
header("Location: " . $_SERVER['PHP_SELF'] . "?id=" . $id);
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
} elseif ($action=='setref') {
|
} elseif ($action=='setref') {
|
||||||
$cancelbutton = GETPOST('cancel');
|
$cancelbutton = GETPOST('cancel');
|
||||||
|
|
||||||
if (!$cancelbutton) {
|
if (!$cancelbutton) {
|
||||||
@ -806,10 +812,10 @@ else if ($action == 'confirm_move' && $confirm == 'yes' && $user->rights->contra
|
|||||||
header("Location: " . $_SERVER['PHP_SELF'] . "?id=" . $id);
|
header("Location: " . $_SERVER['PHP_SELF'] . "?id=" . $id);
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Generation doc (depuis lien ou depuis cartouche doc)
|
// Generation doc (depuis lien ou depuis cartouche doc)
|
||||||
else if ($action == 'builddoc' && $user->rights->contrat->creer) {
|
else if ($action == 'builddoc' && $user->rights->contrat->creer) {
|
||||||
if (GETPOST('model')) {
|
if (GETPOST('model')) {
|
||||||
$object->setDocModel($user, GETPOST('model'));
|
$object->setDocModel($user, GETPOST('model'));
|
||||||
}
|
}
|
||||||
@ -828,10 +834,10 @@ else if ($action == 'builddoc' && $user->rights->contrat->creer) {
|
|||||||
setEventMessages($object->error, $object->errors, 'errors');
|
setEventMessages($object->error, $object->errors, 'errors');
|
||||||
$action='';
|
$action='';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Remove file in doc form
|
// Remove file in doc form
|
||||||
else if ($action == 'remove_file' && $user->rights->contrat->creer) {
|
else if ($action == 'remove_file' && $user->rights->contrat->creer) {
|
||||||
if ($object->id > 0) {
|
if ($object->id > 0) {
|
||||||
require_once DOL_DOCUMENT_ROOT . '/core/lib/files.lib.php';
|
require_once DOL_DOCUMENT_ROOT . '/core/lib/files.lib.php';
|
||||||
|
|
||||||
@ -842,10 +848,10 @@ else if ($action == 'remove_file' && $user->rights->contrat->creer) {
|
|||||||
if ($ret) setEventMessage($langs->trans("FileWasRemoved", GETPOST('file')));
|
if ($ret) setEventMessage($langs->trans("FileWasRemoved", GETPOST('file')));
|
||||||
else setEventMessage($langs->trans("ErrorFailToDeleteFile", GETPOST('file')), 'errors');
|
else setEventMessage($langs->trans("ErrorFailToDeleteFile", GETPOST('file')), 'errors');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (! empty($conf->global->MAIN_DISABLE_CONTACTS_TAB) && $user->rights->contrat->creer)
|
if (! empty($conf->global->MAIN_DISABLE_CONTACTS_TAB) && $user->rights->contrat->creer)
|
||||||
{
|
{
|
||||||
if ($action == 'addcontact')
|
if ($action == 'addcontact')
|
||||||
{
|
{
|
||||||
$contactid = (GETPOST('userid') ? GETPOST('userid') : GETPOST('contactid'));
|
$contactid = (GETPOST('userid') ? GETPOST('userid') : GETPOST('contactid'));
|
||||||
@ -890,9 +896,9 @@ if (! empty($conf->global->MAIN_DISABLE_CONTACTS_TAB) && $user->rights->contrat-
|
|||||||
setEventMessage($object->error,'errors');
|
setEventMessage($object->error,'errors');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* View
|
* View
|
||||||
*/
|
*/
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user