New: Add hooks for project card

This commit is contained in:
Laurent Destailleur 2014-05-08 20:02:34 +02:00
parent 7bfbc4cbf3
commit 5923a754d1

View File

@ -71,9 +71,16 @@ $date_end=dol_mktime(0,0,0,GETPOST('projectendmonth','int'),GETPOST('projectendd
* Actions * Actions
*/ */
// Cancel $parameters=array('id'=>$socid, 'objcanvas'=>$objcanvas);
if (GETPOST("cancel") && ! empty($backtopage)) $reshook=$hookmanager->executeHooks('doActions',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks
$error=$hookmanager->error; $errors=array_merge($errors, (array) $hookmanager->errors);
if (empty($reshook))
{ {
// Cancel
if (GETPOST("cancel") && ! empty($backtopage))
{
if (GETPOST("comefromclone")==1) if (GETPOST("comefromclone")==1)
{ {
$result=$object->delete($user); $result=$object->delete($user);
@ -90,11 +97,11 @@ if (GETPOST("cancel") && ! empty($backtopage))
} }
header("Location: ".$backtopage); header("Location: ".$backtopage);
exit; exit;
} }
//if cancel and come from clone then delete the cloned project //if cancel and come from clone then delete the cloned project
if (GETPOST("cancel") && (GETPOST("comefromclone")==1)) if (GETPOST("cancel") && (GETPOST("comefromclone")==1))
{ {
$result=$object->delete($user); $result=$object->delete($user);
if ($result > 0) if ($result > 0)
{ {
@ -106,10 +113,10 @@ if (GETPOST("cancel") && (GETPOST("comefromclone")==1))
dol_syslog($object->error,LOG_DEBUG); dol_syslog($object->error,LOG_DEBUG);
$mesg='<div class="error">'.$langs->trans("CantRemoveProject").'</div>'; $mesg='<div class="error">'.$langs->trans("CantRemoveProject").'</div>';
} }
} }
if ($action == 'add' && $user->rights->projet->creer) if ($action == 'add' && $user->rights->projet->creer)
{ {
$error=0; $error=0;
if (empty($_POST["ref"])) if (empty($_POST["ref"]))
{ {
@ -177,10 +184,10 @@ if ($action == 'add' && $user->rights->projet->creer)
{ {
$action = 'create'; $action = 'create';
} }
} }
if ($action == 'update' && ! $_POST["cancel"] && $user->rights->projet->creer) if ($action == 'update' && ! $_POST["cancel"] && $user->rights->projet->creer)
{ {
$error=0; $error=0;
if (empty($ref)) if (empty($ref))
@ -255,11 +262,11 @@ if ($action == 'update' && ! $_POST["cancel"] && $user->rights->projet->creer)
if (GETPOST('socid','int') > 0) $object->societe->fetch(GETPOST('socid','int')); if (GETPOST('socid','int') > 0) $object->societe->fetch(GETPOST('socid','int'));
else unset($object->societe); else unset($object->societe);
} }
} }
// Build doc // Build doc
if ($action == 'builddoc' && $user->rights->projet->creer) if ($action == 'builddoc' && $user->rights->projet->creer)
{ {
// Save last template used to generate document // Save last template used to generate document
if (GETPOST('model')) $object->setDocModel($user, GETPOST('model','alpha')); if (GETPOST('model')) $object->setDocModel($user, GETPOST('model','alpha'));
@ -275,11 +282,11 @@ if ($action == 'builddoc' && $user->rights->projet->creer)
dol_print_error($db,$result); dol_print_error($db,$result);
exit; exit;
} }
} }
// Delete file in doc form // Delete file in doc form
if ($action == 'remove_file' && $user->rights->projet->creer) if ($action == 'remove_file' && $user->rights->projet->creer)
{ {
require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
if ($object->id > 0) if ($object->id > 0)
@ -291,38 +298,38 @@ if ($action == 'remove_file' && $user->rights->projet->creer)
if ($ret) setEventMessage($langs->trans("FileWasRemoved", GETPOST('urlfile'))); if ($ret) setEventMessage($langs->trans("FileWasRemoved", GETPOST('urlfile')));
else setEventMessage($langs->trans("ErrorFailToDeleteFile", GETPOST('urlfile')), 'errors'); else setEventMessage($langs->trans("ErrorFailToDeleteFile", GETPOST('urlfile')), 'errors');
} }
} }
if ($action == 'confirm_validate' && GETPOST('confirm') == 'yes') if ($action == 'confirm_validate' && GETPOST('confirm') == 'yes')
{ {
$result = $object->setValid($user); $result = $object->setValid($user);
if ($result <= 0) if ($result <= 0)
{ {
$mesg='<div class="error">'.$object->error.'</div>'; $mesg='<div class="error">'.$object->error.'</div>';
} }
} }
if ($action == 'confirm_close' && GETPOST('confirm') == 'yes') if ($action == 'confirm_close' && GETPOST('confirm') == 'yes')
{ {
$result = $object->setClose($user); $result = $object->setClose($user);
if ($result <= 0) if ($result <= 0)
{ {
$mesg='<div class="error">'.$object->error.'</div>'; $mesg='<div class="error">'.$object->error.'</div>';
} }
} }
if ($action == 'confirm_reopen' && GETPOST('confirm') == 'yes') if ($action == 'confirm_reopen' && GETPOST('confirm') == 'yes')
{ {
$result = $object->setValid($user); $result = $object->setValid($user);
if ($result <= 0) if ($result <= 0)
{ {
$mesg='<div class="error">'.$object->error.'</div>'; $mesg='<div class="error">'.$object->error.'</div>';
} }
} }
if ($action == 'confirm_delete' && GETPOST("confirm") == "yes" && $user->rights->projet->supprimer) if ($action == 'confirm_delete' && GETPOST("confirm") == "yes" && $user->rights->projet->supprimer)
{ {
$object->fetch($id); $object->fetch($id);
$result=$object->delete($user); $result=$object->delete($user);
if ($result > 0) if ($result > 0)
@ -335,10 +342,10 @@ if ($action == 'confirm_delete' && GETPOST("confirm") == "yes" && $user->rights-
dol_syslog($object->error,LOG_DEBUG); dol_syslog($object->error,LOG_DEBUG);
$mesg='<div class="error">'.$langs->trans("CantRemoveProject").'</div>'; $mesg='<div class="error">'.$langs->trans("CantRemoveProject").'</div>';
} }
} }
if ($action == 'confirm_clone' && $user->rights->projet->creer && GETPOST('confirm') == 'yes') if ($action == 'confirm_clone' && $user->rights->projet->creer && GETPOST('confirm') == 'yes')
{ {
$clone_contacts=GETPOST('clone_contacts')?1:0; $clone_contacts=GETPOST('clone_contacts')?1:0;
$clone_tasks=GETPOST('clone_tasks')?1:0; $clone_tasks=GETPOST('clone_tasks')?1:0;
$clone_project_files = GETPOST('clone_project_files') ? 1 : 0; $clone_project_files = GETPOST('clone_project_files') ? 1 : 0;
@ -355,6 +362,7 @@ if ($action == 'confirm_clone' && $user->rights->projet->creer && GETPOST('confi
$action='edit'; $action='edit';
$comefromclone=true; $comefromclone=true;
} }
}
} }
@ -768,6 +776,11 @@ else
print '</td></tr></table>'; print '</td></tr></table>';
} }
// Hook to add more things on page
$parameters=array();
$reshook=$hookmanager->executeHooks('mainCardTabAddMore',$parameters,$object,$action); // Note that $action and $object may have been modified by hook
} }
llxFooter(); llxFooter();