35 if ($massaction ==
'predeletedraft') {
36 print
$form->formconfirm($_SERVER[
"PHP_SELF"], $langs->trans(
"ConfirmMassDraftDeletion"), $langs->trans(
"ConfirmMassDeletionQuestion", count($toselect)),
"delete",
null,
'', 0, 200, 500, 1);
39 if ($massaction ==
'predelete') {
40 print
$form->formconfirm($_SERVER[
"PHP_SELF"], $langs->trans(
"ConfirmMassDeletion"), $langs->trans(
"ConfirmMassDeletionQuestion", count($toselect)),
"delete",
null,
'', 0, 200, 500, 1);
43 if ($massaction ==
'preaffecttag' &&
isModEnabled(
'category')) {
44 require_once DOL_DOCUMENT_ROOT.
'/categories/class/categorie.class.php';
46 $categ_types = array();
47 $categ_type_array = $categ->getMapList();
48 foreach ($categ_type_array as $categdef) {
50 if (isset($object) && $categdef[
'obj_table'] == $object->table_element) {
51 if (!array_key_exists($categdef[
'code'], $categ_types)) {
52 $categ_types[$categdef[
'code']] = array(
'code'=>$categdef[
'code'],
'label'=>$langs->trans($categdef[
'obj_class']));
55 if (isset($objecttmp) && $categdef[
'obj_table'] == $objecttmp->table_element) {
56 if (!array_key_exists($categdef[
'code'], $categ_types)) {
57 $categ_types[$categdef[
'code']] = array(
'code'=>$categdef[
'code'],
'label'=>$langs->trans($categdef[
'obj_class']));
62 $formquestion = array();
63 if (!empty($categ_types)) {
64 foreach ($categ_types as $categ_type) {
65 $cate_arbo =
$form->select_all_categories($categ_type[
'code'],
null,
'parent',
null,
null, 1);
66 $formquestion[] = array(
'type' =>
'other',
67 'name' =>
'affecttag_'.$categ_type[
'code'],
68 'label' => $langs->trans(
"Tag").
' '.$categ_type[
'label'],
69 'value' =>
$form->multiselectarray(
'contcats_'.$categ_type[
'code'], $cate_arbo,
GETPOST(
'contcats_'.$categ_type[
'code'],
'array'),
null,
null,
null,
null,
'60%'));
71 $formquestion[] = array(
'type' =>
'other',
72 'name' =>
'affecttag_type',
74 'value' =>
'<input type="hidden" name="affecttag_type" id="affecttag_type" value="'.implode(
",", array_keys($categ_types)).
'"/>');
75 print
$form->formconfirm($_SERVER[
"PHP_SELF"], $langs->trans(
"ConfirmAffectTag"), $langs->trans(
"ConfirmAffectTagQuestion", count($toselect)),
"affecttag", $formquestion, 1, 0, 200, 500, 1);
81 if ($massaction ==
'presend') {
82 $langs->load(
"mails");
84 $listofselectedid = array();
85 $listofselectedrecipientobjid = array();
86 $listofselectedref = array();
88 if (!
GETPOST(
'cancel',
'alpha')) {
89 foreach ($arrayofselected as $toselectid) {
90 $result = $objecttmp->fetch($toselectid);
92 $listofselectedid[$toselectid] = $toselectid;
93 $thirdpartyid = ($objecttmp->fk_soc ? $objecttmp->fk_soc : $objecttmp->socid);
94 if (in_array($objecttmp->element, array(
'societe',
'conferenceorboothattendee'))) {
95 $thirdpartyid = $objecttmp->id;
97 if ($objecttmp->element ==
'expensereport') {
98 $thirdpartyid = $objecttmp->fk_user_author;
100 if (empty($thirdpartyid)) {
104 $listofselectedrecipientobjid[$thirdpartyid] = $thirdpartyid;
106 $listofselectedref[$thirdpartyid][$toselectid] = $objecttmp->ref;
111 print
'<input type="hidden" name="massaction" value="confirm_presend">';
116 include_once DOL_DOCUMENT_ROOT.
'/core/class/html.formmail.class.php';
118 $formmail->withform = -1;
119 $formmail->fromtype = (
GETPOST(
'fromtype') ?
GETPOST(
'fromtype') : (!empty($conf->global->MAIN_MAIL_DEFAULT_FROMTYPE) ? $conf->global->MAIN_MAIL_DEFAULT_FROMTYPE :
'user'));
121 if ($formmail->fromtype ===
'user') {
122 $formmail->fromid = $user->id;
124 $formmail->trackid = $trackid;
125 $formmail->withfrom = 1;
126 $liste = $langs->trans(
"AllRecipientSelected", count($arrayofselected));
127 if (count($listofselectedrecipientobjid) == 1) {
129 $thirdpartyid = array_shift($listofselectedrecipientobjid);
130 if ($objecttmp->element ==
'expensereport') {
131 $fuser =
new User($db);
132 $fuser->fetch($thirdpartyid);
133 $liste[
'thirdparty'] = $fuser->getFullName($langs).
" <".$fuser->email.
">";
134 } elseif ($objecttmp->element ==
'partnership' &&
getDolGlobalString(
'PARTNERSHIP_IS_MANAGED_FOR') ==
'member') {
136 $fadherent->fetch($objecttmp->fk_member);
137 $liste[
'member'] = $fadherent->getFullName($langs).
" <".$fadherent->email.
">";
140 $soc->fetch($thirdpartyid);
141 foreach ($soc->thirdparty_and_contact_email_array(1) as $key => $value) {
142 $liste[$key] = $value;
145 $formmail->withtoreadonly = 0;
147 $formmail->withtoreadonly = 1;
151 $formmail->withoptiononeemailperrecipient = ((count($listofselectedref) == 1 && count(reset($listofselectedref)) == 1) || empty($liste)) ? 0 : (
GETPOST(
'oneemailperrecipient',
'int') ? 1 : -1);
152 if (in_array($objecttmp->element, array(
'conferenceorboothattendee'))) {
153 $formmail->withoptiononeemailperrecipient = 0;
156 $formmail->withto = empty($liste) ? (
GETPOST(
'sendto',
'alpha') ?
GETPOST(
'sendto',
'alpha') : array()) : $liste;
157 $formmail->withtofree = empty($liste) ? 1 : 0;
158 $formmail->withtocc = 1;
159 $formmail->withtoccc = $conf->global->MAIN_EMAIL_USECCC;
160 if (!empty($topicmail)) {
161 $formmail->withtopic = $langs->transnoentities($topicmail,
'__REF__',
'__REF_CLIENT__');
163 $formmail->withtopic = 1;
165 $formmail->withfile = 1;
167 if (isset($withmaindocfilemail)) {
168 $formmail->withmaindocfile = $withmaindocfilemail;
170 $formmail->withmaindocfile = 1;
171 if ($objecttmp->element !=
'societe') {
172 $formmail->withfile =
'<span class="hideonsmartphone opacitymedium">'.$langs->trans(
"OnlyPDFattachmentSupported").
'</span>';
173 $formmail->withmaindocfile = -1;
176 $formmail->withbody = 1;
177 $formmail->withdeliveryreceipt = 1;
178 $formmail->withcancel = 1;
183 $substitutionarray[
'__EMAIL__'] = $sendto;
184 $substitutionarray[
'__CHECK_READ__'] = (is_object($object) && is_object($object->thirdparty)) ?
'<img src="'.DOL_MAIN_URL_ROOT.
'/public/emailing/mailing-read.php?tag='.urlencode($object->thirdparty->tag).
'&securitykey='.urlencode($conf->global->MAILING_EMAIL_UNSUBSCRIBE_KEY).
'" width="1" height="1" style="width:1px;height:1px" border="0"/>' :
'';
185 $substitutionarray[
'__PERSONALIZED__'] =
'';
186 $substitutionarray[
'__CONTACTCIVNAME__'] =
'';
189 'mode' =>
'formemail'
194 $formmail->substit = $substitutionarray;
197 $formmail->param[
'action'] = $action;
198 $formmail->param[
'models'] = $modelmail;
199 $formmail->param[
'models_id'] =
GETPOST(
'modelmailselected',
'int') ?
GETPOST(
'modelmailselected',
'int') :
'-1';
200 $formmail->param[
'id'] = join(
',', $arrayofselected);
202 if (!empty($conf->global->MAILING_LIMIT_SENDBYWEB) && count($listofselectedrecipientobjid) > $conf->global->MAILING_LIMIT_SENDBYWEB) {
203 $langs->load(
"errors");
204 print
img_warning().
' '.$langs->trans(
'WarningNumberOfRecipientIsRestrictedInMassAction', $conf->global->MAILING_LIMIT_SENDBYWEB);
205 print
' - <a href="javascript: window.history.go(-1)">'.$langs->trans(
"GoBack").
'</a>';
206 $arrayofmassactions = array();
208 print $formmail->get_form();
214 if ($massaction ==
'edit_extrafields') {
215 require_once DOL_DOCUMENT_ROOT.
'/core/class/extrafields.class.php';
216 $elementtype = $objecttmp->element;
220 $extrafields->fetch_name_optionals_label($elementtype);
221 $extrafields_list = $extrafields->attributes[$elementtype][
'label'];
223 $formquestion = array();
224 if (!empty($extrafields_list)) {
225 $myParamExtra = $object->showOptionals($extrafields,
'create');
227 foreach ($extrafields_list as $extraKey => $extraLabel) {
228 $extrafields_list[$extraKey] = $langs->trans($extraLabel);
231 $formquestion[] = array(
233 'value' =>
$form->selectarray(
'extrafield-key-to-update', $extrafields_list,
GETPOST(
'extrafield-key-to-update'), 1)
237 $outputShowOutputFields =
'<div class="extrafields-inputs">';
239 foreach ($extrafields_list as $extraKey => $extraLabel) {
240 $outputShowOutputFields.=
'<div class="mass-action-extrafield" data-extrafield="'.$extraKey.
'" style="display:none;" >';
241 $outputShowOutputFields.=
'<br><span>'. $langs->trans(
'NewValue').
'</span>';
242 $outputShowOutputFields.= $extrafields->showInputField($extraKey,
'',
'', $keysuffix,
'', 0, $objecttmp->id, $objecttmp->table_element);
243 $outputShowOutputFields.=
'</div>';
245 $outputShowOutputFields.=
'<script>
247 $("#extrafield-key-to-update").on(\'change\',function(){
248 let selectedExtrtafield = $(this).val();
249 if($(".extrafields-inputs .product_extras_"+selectedExtrtafield) != undefined){
250 $(".mass-action-extrafield").hide();
251 $(".mass-action-extrafield[data-extrafield=" + selectedExtrtafield + "]").show();
256 $outputShowOutputFields.=
'</div>';
260 $formquestion[] = array(
262 'value' => $outputShowOutputFields
265 print
$form->formconfirm($_SERVER[
"PHP_SELF"], $langs->trans(
"ConfirmEditExtrafield"), $langs->trans(
"ConfirmEditExtrafieldQuestion", count($toselect)),
"confirm_edit_value_extrafields", $formquestion, 1, 0, 200, 500, 1);
271 if ($massaction ==
'preenable') {
272 print
$form->formconfirm($_SERVER[
"PHP_SELF"], $langs->trans(
"ConfirmMassEnabling"), $langs->trans(
"ConfirmMassEnablingQuestion", count($toselect)),
"enable",
null,
'yes', 0, 200, 500, 1);
274 if ($massaction ==
'predisable') {
275 print
$form->formconfirm($_SERVER[
"PHP_SELF"], $langs->trans(
"ConfirmMassDisabling"), $langs->trans(
"ConfirmMassDisablingQuestion", count($toselect)),
"disable",
null,
'', 0, 200, 500, 1);
277 if ($massaction ==
'presetcommercial') {
278 $formquestion = array();
279 $userlist =
$form->select_dolusers(
'',
'', 0,
null, 0,
'',
'', 0, 0, 0,
'AND u.statut = 1', 0,
'',
'', 0, 1);
280 $formquestion[] = array(
'type' =>
'other',
281 'name' =>
'affectedcommercial',
282 'label' =>
$form->editfieldkey(
'AllocateCommercial',
'commercial_id',
'', $object, 0),
283 'value' =>
$form->multiselectarray(
'commercial', $userlist,
null, 0, 0,
'quatrevingtpercent widthcentpercentminusx', 0, 0,
'',
'',
'', 1));
284 print
$form->formconfirm($_SERVER[
"PHP_SELF"], $langs->trans(
"ConfirmAllocateCommercial"), $langs->trans(
"ConfirmAllocateCommercialQuestion", count($toselect)),
"affectcommercial", $formquestion, 1, 0, 200, 500, 1);
286 if ($massaction ==
'preapproveleave') {
287 print
$form->formconfirm($_SERVER[
"PHP_SELF"], $langs->trans(
"ConfirmMassLeaveApproval"), $langs->trans(
"ConfirmMassLeaveApprovalQuestion", count($toselect)),
"approveleave",
null,
'yes', 0, 200, 500, 1);
292 'toselect' => $toselect,
293 'uploaddir' => isset($uploaddir) ? $uploaddir :
null
296 $reshook = $hookmanager->executeHooks(
'doPreMassActions', $parameters, $object, $action);
300 print $hookmanager->resPrint;