From aa7fdaf1949541f20ac55e94c8095fd2b7f85e59 Mon Sep 17 00:00:00 2001 From: Oarces DEV Date: Sat, 18 Feb 2023 03:23:45 +0100 Subject: [PATCH 1/4] Update card.php --- htdocs/salaries/card.php | 37 ++++++++++++++++++++++++++++--------- 1 file changed, 28 insertions(+), 9 deletions(-) diff --git a/htdocs/salaries/card.php b/htdocs/salaries/card.php index 42fecf28b37..fd1a7d8bae7 100644 --- a/htdocs/salaries/card.php +++ b/htdocs/salaries/card.php @@ -5,6 +5,8 @@ * Copyright (C) 2015 Charlie BENKE * Copyright (C) 2018-2022 Frédéric France * Copyright (C) 2021 Gauthier VERDOL + * Copyright (C) 2023 Maxime Nicolas + * Copyright (C) 2023 Benjamin GREMBI * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -148,6 +150,13 @@ if (empty($reshook)) { } $action = ''; } + // Actions to send emails + $triggersendname = 'COMPANY_SENTBYMAIL'; + $paramname = 'id'; + $mode = 'emailfromthirdparty'; + $trackid = 'thi'.$object->id; + include DOL_DOCUMENT_ROOT.'/core/actions_sendmails.inc.php'; + } // Link to a project @@ -382,7 +391,7 @@ if ($action == 'confirm_clone' && $confirm == 'yes' && ($user->rights->salaries- $object->id = $object->ref = null; if (GETPOST('amount', 'alphanohtml')) { - $object->amount = price2num(GETPOST('amount', 'alphanohtml'), 'MT', 2); + $object->amount = price2num(GETPOST('amount', 'alphanohtml'), 'MT', 2); } if (GETPOST('clone_label', 'alphanohtml')) { @@ -451,7 +460,6 @@ if (isModEnabled('project')) $formproject = new FormProjets($db); $title = $langs->trans('Salary')." - ".$object->ref; $help_url = ""; - llxHeader('', $title, $help_url); @@ -662,9 +670,9 @@ if ($action == 'create' && $permissiontoadd) { print ''; } - // View mode if ($id > 0) { $head = salaries_prepare_head($object); @@ -803,7 +810,7 @@ if ($id > 0) { $morehtmlref .= ''; } - $usercancreate = $permissiontoadd; + $usercancreate = $permissiontoadd; // Project if (isModEnabled('project')) { @@ -969,11 +976,8 @@ if ($id > 0) { while ($i < $num) { $objp = $db->fetch_object($resql); - print ''; - // Date - print ''; + print ''; print ''.img_object($langs->trans("Payment"), "payment").' '.$objp->rowid.''; - // Date print ''.dol_print_date($db->jdate($objp->dp), 'dayhour', 'tzuserrel')."\n"; $labeltype = $langs->trans("PaymentType".$objp->type_code) != ("PaymentType".$objp->type_code) ? $langs->trans("PaymentType".$objp->type_code) : $objp->paiement_type; print "".$labeltype.' '.$objp->num_payment."\n"; @@ -1046,6 +1050,17 @@ if ($id > 0) { print '
'."\n"; if ($action != 'edit') { + // Dynamic send mail button + $parameters = array(); + $reshook = $hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action); // Note that $action and $object may have been modified by hook + if (empty($reshook)) { + if (empty($user->socid)) { + $canSendMail = true; + + print dolGetButtonAction($langs->trans('SendMail'), '', 'default', $_SERVER['PHP_SELF'] . '?id=' . $object->id . '&action=presend'.'&token='.newToken().'&mode=init#formmailbeforetitle', '', $canSendMail, $params); + } + } + // Reopen if ($object->paye && $user->rights->salaries->write) { print dolGetButtonAction('', $langs->trans('ReOpen'), 'default', $_SERVER["PHP_SELF"].'?action=reopen&token='.newToken().'&id='.$object->id, ''); @@ -1137,6 +1152,10 @@ if ($id > 0) { $trackid = 'salary'.$object->id; include DOL_DOCUMENT_ROOT.'/core/tpl/card_presend.tpl.php'; + + // Hook to add more things on page + $parameters = array(); + $reshook = $hookmanager->executeHooks('salaryCardTabAddMore', $parameters, $object, $action); // Note that $action and $object may have been modified by hook } // End of page From 25634fbb50a78eeaf6c8c4d90f664aa689ee683e Mon Sep 17 00:00:00 2001 From: Oarces DEV Date: Sat, 18 Feb 2023 03:24:17 +0100 Subject: [PATCH 2/4] Update card_presend.tpl.php --- htdocs/core/tpl/card_presend.tpl.php | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/htdocs/core/tpl/card_presend.tpl.php b/htdocs/core/tpl/card_presend.tpl.php index 2393524e572..56350588410 100644 --- a/htdocs/core/tpl/card_presend.tpl.php +++ b/htdocs/core/tpl/card_presend.tpl.php @@ -1,6 +1,8 @@ - * Copyright (C) 2022 Charlene Benke +/* Copyright (C) 2017-2018 Laurent Destailleur + * Copyright (C) 2022 Charlene Benke + * Copyright (C) 2023 Maxime Nicolas + * Copyright (C) 2023 Benjamin GREMBI * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -129,7 +131,11 @@ if ($action == 'presend') { if ($formmail->fromtype === 'user') { $formmail->fromid = $user->id; } - + if ($object->element == 'salary' && !empty($conf->global->INVOICE_EMAIL_SENDER)) { + $formmail->frommail = $conf->global->SINVOICE_EMAIL_SENDER; + $formmail->fromname = (!empty($conf->global->INVOICE_EMAIL_SENDER_NAME) ? $conf->global->INVOICE_EMAIL_SENDER_NAME : ''); + $formmail->fromtype = 'special'; + } if ($object->element === 'facture' && !empty($conf->global->INVOICE_EMAIL_SENDER)) { $formmail->frommail = $conf->global->INVOICE_EMAIL_SENDER; $formmail->fromname = (!empty($conf->global->INVOICE_EMAIL_SENDER_NAME) ? $conf->global->INVOICE_EMAIL_SENDER_NAME : ''); @@ -194,6 +200,10 @@ if ($action == 'presend') { $liste['contact'] = $object->getFullName($outputlangs)." <".$object->email.">"; } elseif ($object->element == 'user' || $object->element == 'member') { $liste['thirdparty'] = $object->getFullName($outputlangs)." <".$object->email.">"; + } elseif ($object->element == 'salary') { + $fuser = new User($db); + $fuser->fetch($object->fk_user); + $liste['thirdparty'] = $fuser->getFullName($outputlangs)." <".$fuser->email.">"; } else { if (!empty($object->socid) && $object->socid > 0 && !is_object($object->thirdparty) && method_exists($object, 'fetch_thirdparty')) { $object->fetch_thirdparty(); From af8e6bfa617d84e5ad904e7fb0293c6dee0fe2fa Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Sat, 18 Feb 2023 02:26:38 +0000 Subject: [PATCH 3/4] Fixing style errors. --- htdocs/salaries/card.php | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/htdocs/salaries/card.php b/htdocs/salaries/card.php index fd1a7d8bae7..c0f4cd8f728 100644 --- a/htdocs/salaries/card.php +++ b/htdocs/salaries/card.php @@ -156,7 +156,6 @@ if (empty($reshook)) { $mode = 'emailfromthirdparty'; $trackid = 'thi'.$object->id; include DOL_DOCUMENT_ROOT.'/core/actions_sendmails.inc.php'; - } // Link to a project @@ -810,7 +809,7 @@ if ($id > 0) { $morehtmlref .= ''; } - $usercancreate = $permissiontoadd; + $usercancreate = $permissiontoadd; // Project if (isModEnabled('project')) { @@ -1053,13 +1052,13 @@ if ($id > 0) { // Dynamic send mail button $parameters = array(); $reshook = $hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action); // Note that $action and $object may have been modified by hook - if (empty($reshook)) { - if (empty($user->socid)) { - $canSendMail = true; + if (empty($reshook)) { + if (empty($user->socid)) { + $canSendMail = true; - print dolGetButtonAction($langs->trans('SendMail'), '', 'default', $_SERVER['PHP_SELF'] . '?id=' . $object->id . '&action=presend'.'&token='.newToken().'&mode=init#formmailbeforetitle', '', $canSendMail, $params); - } + print dolGetButtonAction($langs->trans('SendMail'), '', 'default', $_SERVER['PHP_SELF'] . '?id=' . $object->id . '&action=presend'.'&token='.newToken().'&mode=init#formmailbeforetitle', '', $canSendMail, $params); } + } // Reopen if ($object->paye && $user->rights->salaries->write) { From fa9493db3729f9475ea8a4a153063995dd75d63e Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 22 Feb 2023 01:54:06 +0100 Subject: [PATCH 4/4] Update card.php --- htdocs/salaries/card.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/htdocs/salaries/card.php b/htdocs/salaries/card.php index c0f4cd8f728..c5426864d39 100644 --- a/htdocs/salaries/card.php +++ b/htdocs/salaries/card.php @@ -669,9 +669,10 @@ if ($action == 'create' && $permissiontoadd) { print '