diff --git a/htdocs/product/agenda.php b/htdocs/product/agenda.php
index ec8a6dd4951..b595bd3b9cb 100644
--- a/htdocs/product/agenda.php
+++ b/htdocs/product/agenda.php
@@ -186,25 +186,16 @@ if ($id > 0 || $ref) {
$objcon = new stdClass();
$out = '';
- $permok = $user->rights->agenda->myactions->create;
- if ((!empty($objproduct->id) || !empty($objcon->id)) && $permok) {
- //$out.='id.'&percentage=-1';
- //$out.=$langs->trans("AddAnAction").' ';
- //$out.=img_picto($langs->trans("AddAnAction"),'filenew');
- //$out.="";
- }
-
-
- //print '
';
- //print '
';
-
-
$morehtmlcenter = '';
if (!empty($conf->agenda->enabled)) {
+ $permok = $user->rights->agenda->myactions->create;
+ if ((!empty($objproduct->id) || !empty($objcon->id)) && $permok) {
+ if (get_class($objproduct) == 'Product') {
+ $out .= '&prodid='.$objproduct->id.'&origin=product&originid='.$id;
+ }
+ $out .= (!empty($objcon->id) ? '&contactid='.$objcon->id : '').'&backtopage='.$_SERVER["PHP_SELF"].'?id='.$object->id.'&percentage=-1';
+ }
+
$linktocreatetimeBtnStatus = !empty($user->rights->agenda->myactions->create) || !empty($user->rights->agenda->allactions->create);
$morehtmlcenter = dolGetButtonTitle($langs->trans('AddAction'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/comm/action/card.php?action=create'.$out, '', $linktocreatetimeBtnStatus);
}