NEW presend mass action in contact list

This commit is contained in:
VESSILLER 2022-11-16 15:58:00 +01:00
parent 2dc6fe9785
commit 53df25a966
3 changed files with 48 additions and 37 deletions

View File

@ -758,7 +758,7 @@ include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php';
// List of mass actions available // List of mass actions available
$arrayofmassactions = array( $arrayofmassactions = array(
// 'presend'=>img_picto('', 'email', 'class="pictofixedwidth"').$langs->trans("SendByMail"), 'presend' => img_picto('', 'email', 'class="pictofixedwidth"').$langs->trans("SendByMail"),
// 'builddoc'=>img_picto('', 'pdf', 'class="pictofixedwidth"').$langs->trans("PDFMerge"), // 'builddoc'=>img_picto('', 'pdf', 'class="pictofixedwidth"').$langs->trans("PDFMerge"),
); );
//if($user->rights->societe->creer) $arrayofmassactions['createbills']=$langs->trans("CreateInvoiceForThisCustomer"); //if($user->rights->societe->creer) $arrayofmassactions['createbills']=$langs->trans("CreateInvoiceForThisCustomer");

View File

@ -92,11 +92,11 @@ if (!$error && $massaction == 'confirm_presend') {
$objecttmp = new $objectclass($db); $objecttmp = new $objectclass($db);
if ($objecttmp->element == 'expensereport') { if ($objecttmp->element == 'expensereport') {
$thirdparty = new User($db); $thirdparty = new User($db);
} } elseif ($objecttmp->element == 'contact') {
if ($objecttmp->element == 'partnership' && getDolGlobalString('PARTNERSHIP_IS_MANAGED_FOR') == 'member') { $thirdparty = new Contact($db);
} elseif ($objecttmp->element == 'partnership' && getDolGlobalString('PARTNERSHIP_IS_MANAGED_FOR') == 'member') {
$thirdparty = new Adherent($db); $thirdparty = new Adherent($db);
} } elseif ($objecttmp->element == 'holiday') {
if ($objecttmp->element == 'holiday') {
$thirdparty = new User($db); $thirdparty = new User($db);
} }
@ -109,14 +109,13 @@ if (!$error && $massaction == 'confirm_presend') {
$thirdpartyid = ($objecttmp->fk_soc ? $objecttmp->fk_soc : $objecttmp->socid); $thirdpartyid = ($objecttmp->fk_soc ? $objecttmp->fk_soc : $objecttmp->socid);
if ($objecttmp->element == 'societe') { if ($objecttmp->element == 'societe') {
$thirdpartyid = $objecttmp->id; $thirdpartyid = $objecttmp->id;
} } elseif ($objecttmp->element == 'contact') {
if ($objecttmp->element == 'expensereport') { $thirdpartyid = $objecttmp->id;
} elseif ($objecttmp->element == 'expensereport') {
$thirdpartyid = $objecttmp->fk_user_author; $thirdpartyid = $objecttmp->fk_user_author;
} } elseif ($objecttmp->element == 'partnership' && getDolGlobalString('PARTNERSHIP_IS_MANAGED_FOR') == 'member') {
if ($objecttmp->element == 'partnership' && getDolGlobalString('PARTNERSHIP_IS_MANAGED_FOR') == 'member') {
$thirdpartyid = $objecttmp->fk_member; $thirdpartyid = $objecttmp->fk_member;
} } elseif ($objecttmp->element == 'holiday') {
if ($objecttmp->element == 'holiday') {
$thirdpartyid = $objecttmp->fk_user; $thirdpartyid = $objecttmp->fk_user;
} }
if (empty($thirdpartyid)) { if (empty($thirdpartyid)) {
@ -267,6 +266,10 @@ if (!$error && $massaction == 'confirm_presend') {
$fuser = new User($db); $fuser = new User($db);
$fuser->fetch($objectobj->fk_user_author); $fuser->fetch($objectobj->fk_user_author);
$sendto = $fuser->email; $sendto = $fuser->email;
} elseif ($objectobj->element == 'contact') {
$fcontact = new Contact($db);
$fcontact->fetch($objectobj->id);
$sendto = $fcontact->email;
} elseif ($objectobj->element == 'partnership' && getDolGlobalString('PARTNERSHIP_IS_MANAGED_FOR') == 'member') { } elseif ($objectobj->element == 'partnership' && getDolGlobalString('PARTNERSHIP_IS_MANAGED_FOR') == 'member') {
$fadherent = new Adherent($db); $fadherent = new Adherent($db);
$fadherent->fetch($objectobj->fk_member); $fadherent->fetch($objectobj->fk_member);
@ -509,31 +512,28 @@ if (!$error && $massaction == 'confirm_presend') {
$trackid = 'thi'.$thirdparty->id; $trackid = 'thi'.$thirdparty->id;
if ($objecttmp->element == 'expensereport') { if ($objecttmp->element == 'expensereport') {
$trackid = 'use'.$thirdparty->id; $trackid = 'use'.$thirdparty->id;
} } elseif ($objecttmp->element == 'contact') {
if ($objecttmp->element == 'holiday') { $trackid = 'ctc'.$thirdparty->id;
} elseif ($objecttmp->element == 'holiday') {
$trackid = 'use'.$thirdparty->id; $trackid = 'use'.$thirdparty->id;
} }
} else { } else {
$trackid = strtolower(get_class($objecttmp)); $trackid = strtolower(get_class($objecttmp));
if (get_class($objecttmp) == 'Contrat') { if (get_class($objecttmp) == 'Contact') {
$trackid = 'ctc';
} elseif (get_class($objecttmp) == 'Contrat') {
$trackid = 'con'; $trackid = 'con';
} } elseif (get_class($objecttmp) == 'Propal') {
if (get_class($objecttmp) == 'Propal') {
$trackid = 'pro'; $trackid = 'pro';
} } elseif (get_class($objecttmp) == 'Commande') {
if (get_class($objecttmp) == 'Commande') {
$trackid = 'ord'; $trackid = 'ord';
} } elseif (get_class($objecttmp) == 'Facture') {
if (get_class($objecttmp) == 'Facture') {
$trackid = 'inv'; $trackid = 'inv';
} } elseif (get_class($objecttmp) == 'Supplier_Proposal') {
if (get_class($objecttmp) == 'Supplier_Proposal') {
$trackid = 'spr'; $trackid = 'spr';
} } elseif (get_class($objecttmp) == 'CommandeFournisseur') {
if (get_class($objecttmp) == 'CommandeFournisseur') {
$trackid = 'sor'; $trackid = 'sor';
} } elseif (get_class($objecttmp) == 'FactureFournisseur') {
if (get_class($objecttmp) == 'FactureFournisseur') {
$trackid = 'sin'; $trackid = 'sin';
} }

View File

@ -167,8 +167,9 @@ if ($massaction == 'presend') {
$thirdpartyid = ($objecttmp->fk_soc ? $objecttmp->fk_soc : $objecttmp->socid); // For proposal, order, invoice, conferenceorbooth, ... $thirdpartyid = ($objecttmp->fk_soc ? $objecttmp->fk_soc : $objecttmp->socid); // For proposal, order, invoice, conferenceorbooth, ...
if (in_array($objecttmp->element, array('societe', 'conferenceorboothattendee'))) { if (in_array($objecttmp->element, array('societe', 'conferenceorboothattendee'))) {
$thirdpartyid = $objecttmp->id; $thirdpartyid = $objecttmp->id;
} } elseif ($objecttmp->element == 'contact') {
if ($objecttmp->element == 'expensereport') { $thirdpartyid = $objecttmp->id;
} elseif ($objecttmp->element == 'expensereport') {
$thirdpartyid = $objecttmp->fk_user_author; $thirdpartyid = $objecttmp->fk_user_author;
} }
if (empty($thirdpartyid)) { if (empty($thirdpartyid)) {
@ -205,6 +206,10 @@ if ($massaction == 'presend') {
$fuser = new User($db); $fuser = new User($db);
$fuser->fetch($thirdpartyid); $fuser->fetch($thirdpartyid);
$liste['thirdparty'] = $fuser->getFullName($langs)." <".$fuser->email.">"; $liste['thirdparty'] = $fuser->getFullName($langs)." <".$fuser->email.">";
} elseif ($objecttmp->element == 'contact') {
$fcontact = new Contact($db);
$fcontact->fetch($thirdpartyid);
$liste['contact'] = $fcontact->getFullName($langs)." <".$fcontact->email.">";
} elseif ($objecttmp->element == 'partnership' && getDolGlobalString('PARTNERSHIP_IS_MANAGED_FOR') == 'member') { } elseif ($objecttmp->element == 'partnership' && getDolGlobalString('PARTNERSHIP_IS_MANAGED_FOR') == 'member') {
$fadherent = new Adherent($db); $fadherent = new Adherent($db);
$fadherent->fetch($objecttmp->fk_member); $fadherent->fetch($objecttmp->fk_member);
@ -236,17 +241,23 @@ if ($massaction == 'presend') {
} else { } else {
$formmail->withtopic = 1; $formmail->withtopic = 1;
} }
$formmail->withfile = 1; // $formmail->withfile = 2 to allow to upload files is not yet supported in mass action if ($objecttmp->element == 'contact') {
// Add a checkbox "Attach also main document" $formmail->withfile = 0;
if (isset($withmaindocfilemail)) { $formmail->withmaindocfile = 0; // Add a checkbox "Attach also main document"
$formmail->withmaindocfile = $withmaindocfilemail; } else {
} else { // Do an automatic definition of $formmail->withmaindocfile $formmail->withfile = 1; // $formmail->withfile = 2 to allow to upload files is not yet supported in mass action
$formmail->withmaindocfile = 1; // Add a checkbox "Attach also main document"
if ($objecttmp->element != 'societe') { if (isset($withmaindocfilemail)) {
$formmail->withfile = '<span class="hideonsmartphone opacitymedium">'.$langs->trans("OnlyPDFattachmentSupported").'</span>'; $formmail->withmaindocfile = $withmaindocfilemail;
$formmail->withmaindocfile = -1; // Add a checkbox "Attach also main document" but not checked by default } else { // Do an automatic definition of $formmail->withmaindocfile
$formmail->withmaindocfile = 1;
if ($objecttmp->element != 'societe') {
$formmail->withfile = '<span class="hideonsmartphone opacitymedium">' . $langs->trans("OnlyPDFattachmentSupported") . '</span>';
$formmail->withmaindocfile = -1; // Add a checkbox "Attach also main document" but not checked by default
}
} }
} }
$formmail->withbody = 1; $formmail->withbody = 1;
$formmail->withdeliveryreceipt = 1; $formmail->withdeliveryreceipt = 1;
$formmail->withcancel = 1; $formmail->withcancel = 1;