77@phan-var-force ?string $permissiontoread
78@phan-var-force ?string $permissiontodelete
79@phan-var-force ?string $permissiontoclose
80@phan-var-force ?string $permissiontoapprove
81@phan-var-force ?int[] $toselect
82@phan-var-force ?string $diroutputmassaction
83@phan-var-force ?string $objectlabel
84@phan-var-force ?string $option
85@phan-var-force int $deliveryreceipt
86@phan-var-force ?array<string,mixed> $moreparams
91if (empty($objectclass) || empty($uploaddir)) {
92 dol_print_error(
null,
'include of actions_massactions.inc.php is done but var $objectclass or $uploaddir was not defined');
95if (empty($massaction)) {
101@phan-var-force "CommonObject"|"CommandeFournisseur"|"ConferenceOrBoothAttendee"|"Contrat"|"Contact"|"Expedition"|"ExpenseReport"|"Facture"|"FactureFournisseur"|"Fichinter"|"Holiday"|"Partnership"|"Project"|"Propal"|"Societe"|"SupplierProposal" $objectclass
102@phan-var-force string $massaction
103@phan-var-force string $uploaddir
108if (!empty($permtoread) && empty($permissiontoread)) {
109 $permissiontoread = $permtoread;
111if (!empty($permtocreate) && empty($permissiontoadd)) {
112 $permissiontoadd = $permtocreate;
114if (!empty($permtodelete) && empty($permissiontodelete)) {
115 $permissiontodelete = $permtodelete;
119$maxformassaction =
getDolGlobalInt(
'MAIN_LIMIT_FOR_MASS_ACTIONS', 1000);
120if ($massaction && is_array($toselect) && count($toselect) < 1) {
124if (!$error && isset($toselect) && is_array($toselect) && count($toselect) > $maxformassaction) {
125 setEventMessages($langs->trans(
'TooManyRecordForMassAction', $maxformassaction),
null,
'errors');
129if (!$error && $massaction ==
'confirm_presend' && !
GETPOST(
'sendmail')) {
130 $massaction =
'presend';
133if (!$error && $massaction ==
'confirm_presend') {
137 $langs->load(
"mails");
138 include_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
139 include_once DOL_DOCUMENT_ROOT.
'/core/lib/signature.lib.php';
141 $listofobjectid = array();
142 $listofobjectthirdparties = array();
143 $listofobjectcontacts = array();
144 $listofobjectref = array();
145 $contactidtosend = array();
146 $attachedfilesThirdpartyObj = array();
147 $oneemailperrecipient = (
GETPOSTINT(
'oneemailperrecipient') ? 1 : 0);
151 $objecttmp =
new $objectclass($db);
154 $thirdparty =
new Societe($db);
155 if ($objecttmp->element ==
'expensereport') {
156 $thirdparty =
new User($db);
157 } elseif ($objecttmp->element ==
'contact') {
158 $thirdparty =
new Contact($db);
159 } elseif ($objecttmp->element ==
'partnership' &&
getDolGlobalString(
'PARTNERSHIP_IS_MANAGED_FOR') ==
'member') {
161 } elseif ($objecttmp->element ==
'holiday') {
162 $thirdparty =
new User($db);
163 } elseif ($objecttmp->element ==
'conferenceorboothattendee') {
167 foreach ($toselect as $toselectid) {
168 $objecttmp =
new $objectclass($db);
169 '@phan-var-force CommonObject $objecttmp';
171 $result = $objecttmp->fetch($toselectid);
173 $listofobjectid[$toselectid] = $toselectid;
176 $tmpobjectid = ($objecttmp->fk_soc ? $objecttmp->fk_soc : $objecttmp->socid);
177 if ($objecttmp->element ==
'societe') {
178 '@phan-var-force Societe $objecttmp';
180 $tmpobjectid = $objecttmp->id;
181 } elseif ($objecttmp->element ==
'contact') {
182 '@phan-var-force Contact $objecttmp';
184 $tmpobjectid = $objecttmp->id;
185 } elseif ($objecttmp->element ==
'expensereport') {
186 '@phan-var-force ExpenseReport $objecttmp';
188 $tmpobjectid = $objecttmp->fk_user_author;
189 } elseif ($objecttmp->element ==
'partnership' &&
getDolGlobalString(
'PARTNERSHIP_IS_MANAGED_FOR') ==
'member') {
190 '@phan-var-force Partnership $objecttmp';
192 $tmpobjectid = $objecttmp->fk_member;
193 } elseif ($objecttmp->element ==
'holiday') {
194 '@phan-var-force Holiday $objecttmp';
196 $tmpobjectid = $objecttmp->fk_user;
197 } elseif ($objecttmp->element ==
'conferenceorboothattendee') {
198 '@phan-var-force ConferenceOrBoothAttendee $objecttmp';
200 $tmpobjectid = $objecttmp->id;
202 if (empty($tmpobjectid)) {
206 if ($objectclass ==
'Facture') {
207 '@phan-var-force Facture $objecttmp';
209 $tmparraycontact = array();
210 $tmparraycontact = $objecttmp->liste_contact(-1,
'external', 0,
'BILLING');
211 if (is_array($tmparraycontact) && count($tmparraycontact) > 0) {
212 foreach ($tmparraycontact as $data_email) {
213 $listofobjectcontacts[$toselectid][$data_email[
'id']] = $data_email[
'email'];
216 } elseif ($objectclass ==
'CommandeFournisseur') {
217 '@phan-var-force CommandeFournisseur $objecttmp';
219 $tmparraycontact = array();
220 $tmparraycontact = $objecttmp->liste_contact(-1,
'external', 0,
'CUSTOMER');
221 if (is_array($tmparraycontact) && count($tmparraycontact) > 0) {
222 foreach ($tmparraycontact as $data_email) {
223 $listofobjectcontacts[$toselectid][$data_email[
'id']] = $data_email[
'email'];
228 $listofobjectthirdparties[$tmpobjectid] = $tmpobjectid;
229 $listofobjectref[$tmpobjectid][$toselectid] = $objecttmp;
235 if (
GETPOST(
'fromtype',
'alpha') ===
'user' && empty($user->email)) {
238 $massaction =
'presend';
241 $receiver =
GETPOST(
'receiver',
'alphawithlgt');
242 if (!is_array($receiver)) {
243 if (empty($receiver) || $receiver ==
'-1') {
246 $receiver = array($receiver);
249 if (!trim(
GETPOST(
'sendto',
'alphawithlgt')) && count($receiver) == 0 && count($listofobjectthirdparties) == 1) {
251 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"MailRecipient")),
null,
'warnings');
252 $massaction =
'presend';
255 if (!
GETPOST(
'subject',
'restricthtml')) {
257 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"MailTopic")),
null,
'warnings');
258 $massaction =
'presend';
263 foreach ($listofobjectthirdparties as $thirdpartyid) {
264 $result = $thirdparty->fetch($thirdpartyid);
277 if (trim(
GETPOST(
'sendto',
'alphawithlgt'))) {
279 $tmparray[] = trim(
GETPOST(
'sendto',
'alphawithlgt'));
281 if (count($receiver) > 0 && is_object($thirdparty)) {
282 foreach ($receiver as $key => $val) {
284 if ($val ==
'thirdparty') {
285 $tmparray[] = $thirdparty->name.
' <'.$thirdparty->email.
'>';
286 } elseif ($val && method_exists($thirdparty,
'contact_get_property')) {
287 $tmparray[] = $thirdparty->contact_get_property((
int) $val,
'email');
292 $sendto = implode(
',', $tmparray);
295 $receivercc =
GETPOST(
'receivercc',
'alphawithlgt');
296 if (!is_array($receivercc)) {
297 if ($receivercc ==
'-1') {
298 $receivercc = array();
300 $receivercc = array($receivercc);
304 if (trim(
GETPOST(
'sendtocc',
'alphawithlgt'))) {
305 $tmparray[] = trim(
GETPOST(
'sendtocc',
'alphawithlgt'));
307 if (count($receivercc) > 0) {
308 foreach ($receivercc as $key => $val) {
310 if ($val ==
'thirdparty') {
311 $tmparray[] = $thirdparty->name.
' <'.$thirdparty->email.
'>';
313 $tmparray[] = $thirdparty->contact_get_property((
int) $val,
'email');
318 $sendtocc = implode(
',', $tmparray);
321 $listofqualifiedobj = array();
322 $listofqualifiedref = array();
323 $thirdpartywithoutemail = array();
325 foreach ($listofobjectref[$thirdpartyid] as $objectid => $objectobj) {
332 $langs->load(
"errors");
334 $resaction .=
'<div class="error">'.$langs->trans(
'ErrorOnlyProposalNotDraftCanBeSentInMassAction', $objectobj->ref).
'</div><br>';
338 $langs->load(
"errors");
340 $resaction .=
'<div class="error">'.$langs->trans(
'ErrorOnlyOrderNotDraftCanBeSentInMassAction', $objectobj->ref).
'</div><br>';
344 $langs->load(
"errors");
346 $resaction .=
'<div class="error">'.$langs->trans(
'ErrorOnlyInvoiceValidatedCanBeSentInMassAction', $objectobj->ref).
'</div><br>';
351 if (empty($sendto)) {
352 if ($objectobj->element ==
'societe') {
353 $sendto = $objectobj->email;
354 } elseif ($objectobj->element ==
'expensereport') {
355 $fuser =
new User($db);
356 $fuser->fetch($objectobj->fk_user_author);
357 $sendto = $fuser->email;
358 } elseif ($objectobj->element ==
'contact') {
360 $fcontact->fetch($objectobj->id);
361 $sendto = $fcontact->email;
362 } elseif ($objectobj->element ==
'partnership' &&
getDolGlobalString(
'PARTNERSHIP_IS_MANAGED_FOR') ==
'member') {
364 $fadherent->fetch($objectobj->fk_member);
365 $sendto = $fadherent->email;
366 } elseif ($objectobj->element ==
'holiday') {
367 $fuser =
new User($db);
368 $fuser->fetch($objectobj->fk_user);
369 $sendto = $fuser->email;
370 } elseif ($objectobj->element ==
'facture' && !empty($listofobjectcontacts[$objectid])) {
371 $emails_to_sends = array();
372 $objectobj->fetch_thirdparty();
373 $contactidtosend = array();
374 foreach ($listofobjectcontacts[$objectid] as $contactemailid => $contactemailemail) {
375 $emails_to_sends[] = $objectobj->thirdparty->contact_get_property($contactemailid,
'email');
376 if (!in_array($contactemailid, $contactidtosend)) {
377 $contactidtosend[] = $contactemailid;
380 if (count($emails_to_sends) > 0) {
381 $sendto = implode(
',', $emails_to_sends);
383 } elseif ($objectobj->element ==
'order_supplier' && !empty($listofobjectcontacts[$objectid])) {
384 $emails_to_sends = array();
385 $objectobj->fetch_thirdparty();
386 $contactidtosend = array();
387 foreach ($listofobjectcontacts[$objectid] as $contactemailid => $contactemailemail) {
388 $emails_to_sends[] = $objectobj->thirdparty->contact_get_property($contactemailid,
'email');
389 if (!in_array($contactemailid, $contactidtosend)) {
390 $contactidtosend[] = $contactemailid;
393 if (count($emails_to_sends) > 0) {
394 $sendto = implode(
',', $emails_to_sends);
396 } elseif ($objectobj->element ==
'conferenceorboothattendee') {
397 $sendto = $objectobj->email;
399 $objectobj->fetch_thirdparty();
400 $sendto = $objectobj->thirdparty->email;
404 if (empty($sendto)) {
405 if ($objectobj->element ==
'societe') {
407 $objectobj->thirdparty = $objectobj;
412 if (empty($thirdpartywithoutemail[$objectobj->thirdparty->id])) {
413 $resaction .=
'<div class="error">'.$langs->trans(
'NoRecipientEmail', $objectobj->thirdparty->name).
'</div><br>';
415 dol_syslog(
'No recipient for thirdparty: '.$objectobj->thirdparty->name, LOG_WARNING);
416 $thirdpartywithoutemail[$objectobj->thirdparty->id] = 1;
420 if (
GETPOST(
'addmaindocfile')) {
427 $filedir = $uploaddir.
'/'.$subdir.dol_sanitizeFileName($objectobj->ref);
428 $filepath = $filedir.
'/'.$filename;
431 if ($objectobj->element ==
'invoice_supplier') {
432 $fileparams =
dol_most_recent_file($uploaddir.
'/'.
get_exdir($objectobj->id, 2, 0, 0, $objectobj, $objectobj->element).$objectobj->ref, preg_quote($objectobj->ref,
'/').
'([^\-])+');
433 $filepath = $fileparams[
'fullname'];
437 $filename_found =
'';
438 $filepath_found =
'';
439 $file_check_list = array();
440 $file_check_list[] = array(
444 if (
getDolGlobalString(
'MAIL_MASS_ACTION_ADD_LAST_IF_MAIN_DOC_NOT_FOUND') && !empty($objectobj->last_main_doc)) {
445 $file_check_list[] = array(
446 'name' => basename($objectobj->last_main_doc),
447 'path' => DOL_DATA_ROOT .
'/' . $objectobj->last_main_doc,
450 foreach ($file_check_list as $file_check_arr) {
452 $filename_found = $file_check_arr[
'name'];
453 $filepath_found = $file_check_arr[
'path'];
458 if ($filepath_found) {
460 $attachedfilesThirdpartyObj[$thirdpartyid][$objectid] = array(
461 'paths' => array($filepath_found),
462 'names' => array($filename_found),
467 $langs->load(
"errors");
468 foreach ($file_check_list as $file_check_arr) {
469 $resaction .=
'<div class="error">'.$langs->trans(
'ErrorCantReadFile', $file_check_arr[
'path']).
'</div><br>';
470 dol_syslog(
'Failed to read file: '.$file_check_arr[
'path'], LOG_WARNING);
477 $listofqualifiedobj[$objectid] = $objectobj;
478 $listofqualifiedref[$objectid] = $objectobj->ref;
485 if (count($listofqualifiedobj) > 0) {
486 $langs->load(
"commercial");
490 $fromtype =
GETPOST(
'fromtype');
491 if ($fromtype ===
'user') {
492 $from =
dol_string_nospecial($user->getFullName($langs),
' ', array(
",")).
' <'.$user->email.
'>';
493 } elseif ($fromtype ===
'company') {
495 } elseif (preg_match(
'/user_aliases_(\d+)/', $fromtype, $reg)) {
496 $tmp = explode(
',', $user->email_aliases);
497 $from = trim($tmp[((
int) $reg[1] - 1)]);
498 } elseif (preg_match(
'/global_aliases_(\d+)/', $fromtype, $reg)) {
500 $from = trim($tmp[((
int) $reg[1] - 1)]);
501 } elseif (preg_match(
'/senderprofile_(\d+)_(\d+)/', $fromtype, $reg)) {
502 $sql =
"SELECT rowid, label, email FROM ".MAIN_DB_PREFIX.
"c_email_senderprofile WHERE rowid = ".(int) $reg[1];
503 $resql = $db->query($sql);
504 $obj = $db->fetch_object($resql);
513 $subject =
GETPOST(
'subject',
'restricthtml');
514 $message =
GETPOST(
'message',
'restricthtml');
516 $sendtobcc =
GETPOST(
'sendtoccc');
517 if ($objectclass ==
'Propal') {
520 if ($objectclass ==
'Commande') {
523 if ($objectclass ==
'Facture') {
526 if ($objectclass ==
'SupplierProposal') {
527 $sendtobcc .= (!
getDolGlobalString(
'MAIN_MAIL_AUTOCOPY_SUPPLIER_PROPOSAL_TO') ?
'' : (($sendtobcc ?
", " :
"") .
getDolGlobalString(
'MAIN_MAIL_AUTOCOPY_SUPPLIER_PROPOSAL_TO')));
529 if ($objectclass ==
'CommandeFournisseur') {
532 if ($objectclass ==
'FactureFournisseur') {
535 if ($objectclass ==
'Project') {
541 $looparray = array();
542 if (!$oneemailperrecipient) {
543 $looparray = $listofqualifiedobj;
544 foreach ($looparray as $key => $objecttmp) {
545 $looparray[$key]->thirdparty = $thirdparty;
548 $objectforloop =
new $objectclass($db);
549 $objectforloop->thirdparty = $thirdparty;
550 $looparray[0] = $objectforloop;
553 dol_syslog(
"We have set an array of ".count($looparray).
" emails to send. oneemailperrecipient=".$oneemailperrecipient);
555 foreach ($looparray as $objectid => $objecttmp) {
557 if (
isModEnabled(
'project') && method_exists($objecttmp,
'fetchProject') && is_null($objecttmp->project)) {
558 $objecttmp->fetchProject();
560 $substitutionarray = getCommonSubstitutionArray($langs, 0,
null, $objecttmp);
561 $substitutionarray[
'__ID__'] = ($oneemailperrecipient ? implode(
', ', array_keys($listofqualifiedobj)) : $objecttmp->id);
562 $substitutionarray[
'__REF__'] = ($oneemailperrecipient ? implode(
', ', $listofqualifiedref) : $objecttmp->
ref);
563 $substitutionarray[
'__EMAIL__'] = $thirdparty->email;
564 $substitutionarray[
'__CHECK_READ__'] =
'<img src="'.DOL_MAIN_URL_ROOT.
'/public/emailing/mailing-read.php?tag=undefined&securitykey='.
dol_hash(
getDolGlobalString(
'MAILING_EMAIL_UNSUBSCRIBE_KEY').
"-undefined",
'md5').
'" width="1" height="1" style="width:1px;height:1px" border="0"/>';
566 if ($oneemailperrecipient) {
567 $substitutionarray[
'__ONLINE_PAYMENT_URL__'] =
'';
568 $substitutionarray[
'__ONLINE_PAYMENT_TEXT_AND_URL__'] =
'';
571 $parameters = array(
'mode' =>
'formemail');
573 if (!empty($listofobjectthirdparties)) {
574 $parameters[
'listofobjectthirdparties'] = $listofobjectthirdparties;
576 if (!empty($listofobjectref)) {
577 $parameters[
'listofobjectref'] = $listofobjectref;
585 $attachedfiles = array(
'paths' => array(),
'names' => array(),
'mimes' => array());
586 if ($oneemailperrecipient) {
588 if (is_array($attachedfilesThirdpartyObj[$thirdparty->id]) && count($attachedfilesThirdpartyObj[$thirdparty->id])) {
589 foreach ($attachedfilesThirdpartyObj[$thirdparty->id] as $keyObjId => $objAttachedFiles) {
591 $attachedfiles = array(
592 'paths' => array_merge($attachedfiles[
'paths'], $objAttachedFiles[
'paths']),
593 'names' => array_merge($attachedfiles[
'names'], $objAttachedFiles[
'names']),
594 'mimes' => array_merge($attachedfiles[
'mimes'], $objAttachedFiles[
'mimes'])
598 } elseif (!empty($attachedfilesThirdpartyObj[$thirdparty->id][$objectid])) {
601 $attachedfiles = $attachedfilesThirdpartyObj[$thirdparty->id][$objectid];
604 $filepath = $attachedfiles[
'paths'];
605 $filename = $attachedfiles[
'names'];
606 $mimetype = $attachedfiles[
'mimes'];
609 if ($oneemailperrecipient) {
610 $trackid =
'thi'.$thirdparty->id;
611 if ($objecttmp->element ==
'expensereport') {
612 $trackid =
'use'.$thirdparty->id;
613 } elseif ($objecttmp->element ==
'contact') {
614 $trackid =
'ctc'.$thirdparty->id;
615 } elseif ($objecttmp->element ==
'holiday') {
616 $trackid =
'use'.$thirdparty->id;
619 $trackid = strtolower(get_class($objecttmp));
620 if (get_class($objecttmp) ==
'Contact') {
622 } elseif (get_class($objecttmp) ==
'Contrat') {
624 } elseif (get_class($objecttmp) ==
'Propal') {
626 } elseif (get_class($objecttmp) ==
'Commande') {
628 } elseif (get_class($objecttmp) ==
'Facture') {
630 } elseif (get_class($objecttmp) ==
'SupplierProposal') {
632 } elseif (get_class($objecttmp) ==
'CommandeFournisseur') {
634 } elseif (get_class($objecttmp) ==
'FactureFournisseur') {
638 $trackid .= $objecttmp->id;
644 if (empty($sendcontext)) {
645 $sendcontext =
'standard';
649 $vardir = $conf->user->dir_output.
"/".$user->id;
650 $upload_dir_tmp = $vardir.
'/temp';
653 require_once DOL_DOCUMENT_ROOT.
'/core/class/CMailFile.class.php';
654 $mailfile =
new CMailFile($subjectreplaced, (
string) $sendto, $from, $messagereplaced, $filepath, $mimetype, $filename, $sendtocc, $sendtobcc, (
int) $deliveryreceipt, -1,
'',
'', $trackid,
'', $sendcontext,
'', $upload_dir_tmp);
655 if ($mailfile->error) {
656 $resaction .=
'<div class="error">'.$mailfile->error.
'</div>';
658 $result = $mailfile->sendfile();
660 $resaction .= $langs->trans(
'MailSuccessfulySent', $mailfile->getValidAddress($mailfile->addr_from, 2), $mailfile->getValidAddress($mailfile->addr_to, 2)).
'<br>';
665 foreach ($listofqualifiedobj as $objid2 => $objectobj2) {
666 if ((!$oneemailperrecipient) && $objid2 != $objectid) {
670 dol_syslog(
"Try to insert email event into agenda for objid=".$objid2.
" => objectobj=".get_class($objectobj2));
679 $actionmsg = $langs->transnoentities(
'MailSentByTo', $from, (
string) $sendto);
682 $actionmsg =
dol_concatdesc($actionmsg, $langs->transnoentities(
'Bcc').
": ".$sendtocc);
684 $actionmsg =
dol_concatdesc($actionmsg, $langs->transnoentities(
'MailTopic').
": ".$subjectreplaced);
685 $actionmsg =
dol_concatdesc($actionmsg, $langs->transnoentities(
'TextUsedInTheMessageBody').
":");
691 $objectobj2->sendtoid = (empty($contactidtosend) ? 0 : $contactidtosend);
692 $objectobj2->actionmsg = $actionmsg;
693 $objectobj2->actionmsg2 = $actionmsg2;
694 $objectobj2->fk_element = $objid2;
695 $objectobj2->elementtype = $objectobj2->element;
697 $objectobj2->actionmsg2 = $subjectreplaced;
700 $triggername = strtoupper(get_class($objectobj2)).
'_SENTBYMAIL';
701 if ($triggername ==
'SOCIETE_SENTBYMAIL') {
702 $triggername =
'COMPANY_SENTBYMAIL';
704 if ($triggername ==
'CONTRAT_SENTBYMAIL') {
705 $triggername =
'CONTRACT_SENTBYMAIL';
707 if ($triggername ==
'COMMANDE_SENTBYMAIL') {
708 $triggername =
'ORDER_SENTBYMAIL';
710 if ($triggername ==
'FACTURE_SENTBYMAIL') {
711 $triggername =
'BILL_SENTBYMAIL';
713 if ($triggername ==
'EXPEDITION_SENTBYMAIL') {
714 $triggername =
'SHIPPING_SENTBYMAIL';
716 if ($triggername ==
'COMMANDEFOURNISSEUR_SENTBYMAIL') {
717 $triggername =
'ORDER_SUPPLIER_SENTBYMAIL';
719 if ($triggername ==
'FACTUREFOURNISSEUR_SENTBYMAIL') {
720 $triggername =
'BILL_SUPPLIER_SENTBYMAIL';
722 if ($triggername ==
'SUPPLIERPROPOSAL_SENTBYMAIL') {
723 $triggername =
'PROPOSAL_SUPPLIER_SENTBYMAIL';
725 if ($triggername ==
'PROJET_SENTBYMAIL') {
726 $triggername =
'PROJECT_SENTBYMAIL';
729 if (!empty($triggername)) {
731 $result = $objectobj2->call_trigger($triggername, $user);
739 dol_syslog(
"Error in trigger ".$triggername.
' '.$db->lasterror(), LOG_ERR);
746 $langs->load(
"other");
747 if ($mailfile->error) {
748 $resaction .= $langs->trans(
'ErrorFailedToSendMail', $from, (
string) $sendto);
749 $resaction .=
'<br><div class="error">'.$mailfile->error.
'</div>';
751 $resaction .=
'<div class="warning">No mail sent. Feature is disabled by option MAIN_DISABLE_ALL_MAILS</div>';
753 $resaction .= $langs->trans(
'ErrorFailedToSendMail', $from, (
string) $sendto) .
'<br><div class="error">(unhandled error)</div>';
761 $resaction .= ($resaction ?
'<br>' : $resaction);
762 $resaction .=
'<strong>'.$langs->trans(
"ResultOfMailSending").
':</strong><br>'.
"\n";
763 $resaction .= $langs->trans(
"NbSelected").
': '.count($toselect).
"\n<br>";
764 $resaction .= $langs->trans(
"NbIgnored").
': '.($nbignored ? $nbignored : 0).
"\n<br>";
765 $resaction .= $langs->trans(
"NbSent").
': '.($nbsent ? $nbsent : 0).
"\n<br>";
770 setEventMessages($langs->trans(
"EMailSentForNElements", $nbsent.
'/'.count($toselect)),
null,
'mesgs');
783if (!$error && $massaction ==
'cancelorders') {
788 $orders =
GETPOST(
'toselect',
'array:int');
789 foreach ($orders as $id_order) {
791 if ($cmd->fetch($id_order) <= 0) {
796 $langs->load(
'errors');
797 setEventMessages($langs->trans(
"ErrorObjectMustHaveStatusValidToBeCanceled", $cmd->ref),
null,
'errors');
802 $result = $cmd->cancel($user);
822if (!$error && $massaction ==
"builddoc" && $permissiontoread && !
GETPOST(
'button_search')) {
823 if (empty($diroutputmassaction)) {
824 dol_print_error(
null,
'include of actions_massactions.inc.php is done but var $diroutputmassaction was not defined');
828 require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
829 require_once DOL_DOCUMENT_ROOT.
'/core/lib/pdf.lib.php';
830 require_once DOL_DOCUMENT_ROOT.
'/core/lib/date.lib.php';
832 $objecttmp =
new $objectclass($db);
833 $listofobjectid = array();
834 $listofobjectthirdparties = array();
835 $listofobjectref = array();
836 foreach ($toselect as $toselectid) {
837 $objecttmp =
new $objectclass($db);
838 $result = $objecttmp->fetch($toselectid);
840 $listofobjectid[$toselectid] = $toselectid;
841 $thirdpartyid = !empty($objecttmp->fk_soc) ? $objecttmp->fk_soc : $objecttmp->socid;
842 $listofobjectthirdparties[$thirdpartyid] = $thirdpartyid;
843 $listofobjectref[$toselectid] = $objecttmp->ref;
847 $arrayofinclusion = array();
849 'listofobjectref' => $listofobjectref,
850 'arrayofinclusion' => &$arrayofinclusion,
852 $reshook = $hookmanager->executeHooks(
'updateSearchRegexToMergeDoc', $parameters,
$object, $action);
854 if (empty($reshook)) {
855 foreach ($listofobjectref as $tmppdf) {
858 foreach ($listofobjectref as $tmppdf) {
859 $arrayofinclusion[] =
'^'.preg_quote(
dol_sanitizeFileName($tmppdf),
'/').
'_[\w\-\'\&\.]+\.pdf$';
863 $listoffiles =
dol_dir_list($uploaddir,
'all', 1, $arrayofinclusion,
'\.meta$|\.png$',
'date', SORT_DESC, 0, 1);
865 dol_syslog(
"Found ".count($listoffiles).
" files");
870 foreach ($listofobjectref as $basename) {
872 foreach ($listoffiles as $filefound) {
873 if (strstr($filefound[
"name"], $basename)) {
874 $files[] = $filefound[
'fullname'];
881 $outputlangs = $langs;
884 $newlang =
GETPOST(
'lang_id',
'aZ09');
889 if (!empty($newlang)) {
891 $outputlangs->setDefaultLang($newlang);
900 $filename = preg_replace(
'/\s/',
'_', $filename);
903 if (in_array($objecttmp->element, array(
'facture',
'invoice_supplier')) && $search_status ==
Facture::STATUS_VALIDATED) {
904 if ($option ==
'late') {
911 $filename .=
'_'.$year;
914 $filename .=
'_'.$month;
917 if (count($files) > 0) {
919 $file = $diroutputmassaction.
'/'.$filename.
'_'.
dol_print_date($now,
'dayhourlog').
'.pdf';
922 foreach ($files as $f) {
923 $input_files .=
' '.escapeshellarg($f);
926 $cmd =
'pdftk '.$input_files.
' cat output '.escapeshellarg($file);
930 if (file_exists($file)) {
933 $langs->load(
"exports");
936 setEventMessages($langs->trans(
'ErrorPDFTkOutputFileNotFound'),
null,
'errors');
939 setEventMessages($langs->trans(
'NoPDFAvailableForDocGenAmongChecked'),
null,
'errors');
944 $page_largeur = $formatarray[
'width'];
945 $page_hauteur = $formatarray[
'height'];
946 $format = array($page_largeur, $page_hauteur);
950 if (class_exists(
'TCPDF')) {
951 $pdf->setPrintHeader(
false);
952 $pdf->setPrintFooter(
false);
957 $pdf->SetCompression(
false);
962 foreach ($files as $file) {
964 $pagecount = $pdf->setSourceFile($file);
965 for ($i = 1; $i <= $pagecount; $i++) {
966 $tplidx = $pdf->importPage($i);
967 $s = $pdf->getTemplatesize($tplidx);
968 $pdf->AddPage($s[
'h'] > $s[
'w'] ?
'P' :
'L');
969 $pdf->useTemplate($tplidx);
978 $filename = preg_replace(
'/\s/',
'_', $filename);
982 if (in_array($objecttmp->element, array(
'facture',
'invoice_supplier')) && $search_status ==
Facture::STATUS_VALIDATED) {
983 if ($option ==
'late') {
990 $filename .=
'_'.$year;
992 if (!empty($month)) {
993 $filename .=
'_'.$month;
997 $file = $diroutputmassaction.
'/'.$filename.
'_'.
dol_print_date($now,
'dayhourlog').
'.pdf';
998 $pdf->Output($file,
'F');
1001 $langs->load(
"exports");
1004 setEventMessages($langs->trans(
'NoPDFAvailableForDocGenAmongChecked'),
null,
'errors');
1010if ($action ==
'remove_file') {
1011 require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
1013 $langs->load(
"other");
1014 $upload_dir = $diroutputmassaction;
1015 $file = $upload_dir.
'/'.
GETPOST(
'file');
1027if (!$error && $massaction ==
'validate' && $permissiontoadd) {
1028 $objecttmp =
new $objectclass($db);
1030 if (($objecttmp->element ==
'facture' || $objecttmp->element ==
'invoice') &&
isModEnabled(
'stock') &&
getDolGlobalString(
'STOCK_CALCULATE_ON_BILL')) {
1031 $langs->load(
"errors");
1032 setEventMessages($langs->trans(
'ErrorMassValidationNotAllowedWhenStockIncreaseOnAction'),
null,
'errors');
1036 $langs->load(
"errors");
1037 setEventMessages($langs->trans(
'ErrorMassValidationNotAllowedWhenStockIncreaseOnAction'),
null,
'errors');
1040 if ($objecttmp->element ==
'facture') {
1043 $sql =
"SELECT rowid FROM ".MAIN_DB_PREFIX.
"facture";
1044 $sql .=
" WHERE rowid IN (".$db->sanitize(implode(
",", $toselect)).
")";
1045 $sql .=
" ORDER BY datef";
1047 $resql = $db->query($sql);
1050 while (!empty($arr = $db->fetch_row($resql))) {
1051 $toselectnew[] = $arr[0];
1053 $toselect = (empty($toselectnew)) ? $toselect : $toselectnew;
1067 $perrecordtransaction = (int)
getDolGlobalInt(
'MAIN_MASSVALIDATE_'.strtoupper($objectclass).
'_NO_GLOBAL_TRANSACTION');
1068 if (!$perrecordtransaction) {
1073 foreach ($toselect as $toselectid) {
1074 if ($perrecordtransaction) {
1077 $result = $objecttmp->fetch($toselectid);
1079 if (method_exists($objecttmp,
'validate')) {
1080 $result = $objecttmp->validate($user);
1081 } elseif (method_exists($objecttmp,
'setValid')) {
1082 $result = $objecttmp->setValid($user);
1084 $objecttmp->error =
'No method validate or setValid on this object';
1088 $langs->load(
"errors");
1089 setEventMessages($langs->trans(
"ErrorObjectMustHaveStatusDraftToBeValidated", $objecttmp->ref),
null,
'errors');
1091 if ($perrecordtransaction) {
1095 } elseif ($result < 0) {
1098 if ($perrecordtransaction) {
1106 $outputlangs = $langs;
1109 $newlang =
GETPOST(
'lang_id',
'aZ09');
1111 if (
getDolGlobalInt(
'MAIN_MULTILANGS') && empty($newlang) && property_exists($objecttmp,
'thirdparty')) {
1112 if ((property_exists($objecttmp,
'socid') || property_exists($objecttmp,
'fk_soc')) && empty($objecttmp->thirdparty)) {
1113 $objecttmp->fetch_thirdparty();
1115 if (!empty($objecttmp->thirdparty)) {
1116 $newlang = $objecttmp->thirdparty->default_lang;
1119 if (!empty($newlang)) {
1120 $outputlangs =
new Translate(
"", $conf);
1121 $outputlangs->setDefaultLang($newlang);
1122 $outputlangs->load(
'products');
1124 $model = $objecttmp->model_pdf;
1125 $ret = $objecttmp->fetch($objecttmp->id);
1128 $hidedetails = isset($hidedetails) ? $hidedetails : (
getDolGlobalString(
'MAIN_GENERATE_DOCUMENTS_HIDE_DETAILS') ? 1 : 0);
1129 $hidedesc = isset($hidedesc) ? $hidedesc : (
getDolGlobalString(
'MAIN_GENERATE_DOCUMENTS_HIDE_DESC') ? 1 : 0);
1130 $hideref = isset($hideref) ? $hideref : (
getDolGlobalString(
'MAIN_GENERATE_DOCUMENTS_HIDE_REF') ? 1 : 0);
1131 $moreparams = isset($moreparams) ? $moreparams :
null;
1133 $result = $objecttmp->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref, $moreparams);
1139 if ($perrecordtransaction) {
1146 if ($perrecordtransaction) {
1157 setEventMessages($langs->trans(
"RecordModifiedSuccessfully"),
null,
'mesgs');
1159 if (!$perrecordtransaction) {
1162 } elseif (!$perrecordtransaction) {
1169if (!$error && ($massaction ==
'delete' || ($action ==
'delete' && $confirm ==
'yes')) && $permissiontodelete) {
1172 $objecttmp =
new $objectclass($db);
1178 $unique_arr = array_unique($toselect);
1179 foreach ($unique_arr as $toselectid) {
1180 $result = $objecttmp->fetch($toselectid);
1184 $langs->load(
"errors");
1186 $TMsg[] =
'<div class="error">'.$langs->trans(
'ErrorOnlyDraftStatusCanBeDeletedInMassAction', $objecttmp->ref).
'</div><br>';
1190 if (method_exists($objecttmp,
'is_erasable') && $objecttmp->is_erasable() <= 0) {
1191 $langs->load(
"errors");
1193 $TMsg[] =
'<div class="error">'.$langs->trans(
'ErrorRecordHasChildren').
' '.$objecttmp->ref.
'</div><br>';
1198 $langs->load(
"errors");
1200 $TMsg[] =
'<div class="error">'.$langs->trans(
'ErrorLeaveRequestMustBeDraftCanceledOrRefusedToBeDeleted', $objecttmp->ref).
'</div><br>';
1204 if ($objectclass ==
"Task" && $objecttmp->hasChildren() > 0) {
1205 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"projet_task SET fk_task_parent = 0 WHERE fk_task_parent = ".((int) $objecttmp->id);
1206 $res = $db->query($sql);
1214 if ($objecttmp->element ==
'societe') {
1216 '@phan-var-force Societe $objecttmp';
1218 $result = $objecttmp->delete($objecttmp->id, $user, 1);
1220 $objecttmp->oldcopy =
dol_clone($objecttmp);
1221 $result = $objecttmp->delete($user);
1224 if (empty($result)) {
1225 $TMsg = array_merge($objecttmp->errors, $TMsg);
1226 } elseif ($result < 0) {
1240 if (empty($error)) {
1244 } elseif ($nbok > 0) {
1251 if (!empty($TMsg)) {
1266if (!$error && $massaction ==
'generate_doc' && $permissiontoread) {
1269@phan-var-force
'Commande'|
'CommandeFournisseur'|
'Contrat'|
'Expedition'|
'ExpenseReport'|
'Facture'|
'FactureFournisseur'|
'Fichinter'|
'Project'|
'Propal'|
'SupplierProposal' $objectclass
1275 $objecttmp =
new $objectclass($db);
1277 foreach ($toselect as $toselectid) {
1278 $objecttmp->thirdparty =
null;
1279 $result = $objecttmp->fetch($toselectid);
1282 $outputlangs = $langs;
1286 $newlang =
GETPOST(
'lang_id',
'aZ09');
1288 if (
getDolGlobalInt(
'MAIN_MULTILANGS') && empty($newlang) && isset($objecttmp->thirdparty->default_lang)) {
1289 $newlang = $objecttmp->thirdparty->default_lang;
1291 if (
getDolGlobalInt(
'MAIN_MULTILANGS') && empty($newlang) && isset($objecttmp->default_lang)) {
1292 $newlang = $objecttmp->default_lang;
1294 if (
getDolGlobalInt(
'MAIN_MULTILANGS') && empty($newlang) && empty($objecttmp->thirdparty)) {
1295 $objecttmp->fetch_thirdparty();
1296 $newlang = $objecttmp->thirdparty->default_lang;
1298 if (!empty($newlang)) {
1299 $outputlangs =
new Translate(
"", $conf);
1300 $outputlangs->setDefaultLang($newlang);
1304 $hidedetails = isset($hidedetails) ? $hidedetails : (
getDolGlobalString(
'MAIN_GENERATE_DOCUMENTS_HIDE_DETAILS') ? 1 : 0);
1305 $hidedesc = isset($hidedesc) ? $hidedesc : (
getDolGlobalString(
'MAIN_GENERATE_DOCUMENTS_HIDE_DESC') ? 1 : 0);
1306 $hideref = isset($hideref) ? $hideref : (
getDolGlobalString(
'MAIN_GENERATE_DOCUMENTS_HIDE_REF') ? 1 : 0);
1307 $moreparams = isset($moreparams) ? $moreparams :
null;
1309 $result = $objecttmp->generateDocument($objecttmp->model_pdf, $outputlangs, $hidedetails, $hidedesc, $hideref, $moreparams);
1337if (!$error && ($action ==
'affecttag' && $confirm ==
'yes') && $permissiontoadd) {
1341 $affecttag_type =
GETPOST(
'affecttag_type',
'alpha');
1342 if (!empty($affecttag_type)) {
1343 $affecttag_type_array = explode(
',', $affecttag_type);
1347 if (!empty($affecttag_type_array)) {
1349 require_once DOL_DOCUMENT_ROOT.
'/categories/class/categorie.class.php';
1351 $to_affecttag_type_array = array();
1352 $categ_type_array = $categ->getMapList();
1353 foreach ($categ_type_array as $categdef) {
1354 if (in_array($categdef[
'code'], $affecttag_type_array)) {
1355 $to_affecttag_type_array[] = $categdef[
'code'];
1360 if (!empty($to_affecttag_type_array)) {
1361 foreach ($to_affecttag_type_array as $categ_type) {
1362 $contcats =
GETPOST(
'contcats_' . $categ_type,
'array');
1364 foreach ($toselect as $toselectid) {
1365 $result =
$object->fetch($toselectid);
1368 $result =
$object->setCategoriesCommon($contcats, $categ_type,
false);
1387 $toselect = array();
1393if (!$error && ($action ==
'updateprice' && $confirm ==
'yes') && $permissiontoadd) {
1394 '@phan-var-force Product|ProductCustomerPrice $obj';
1395 '@phan-var-force Product|ProductCustomerPrice $object';
1398 if (GETPOSTISSET(
'pricerate')) {
1400 if ($pricepercentage == 0) {
1403 foreach ($toselect as $toselectid) {
1404 $result =
$object->fetch($toselectid);
1409 if (
$object->price_base_type ==
'TTC') {
1410 $newprice =
$object->price_ttc * (100 + $pricepercentage) / 100;
1411 $minprice =
$object->price_min_ttc;
1413 $newprice =
$object->price * (100 + $pricepercentage) / 100;
1414 $minprice =
$object->price_min;
1416 $res =
$object->updatePrice($newprice,
$object->price_base_type, $user,
$object->tva_tx, $minprice, 0,
$object->tva_npr, 0, 0, array(),
$object->default_vat_code);
1424 for ($level = 1; $level <= $maxlevel; $level++) {
1425 if (
$object->price_base_type ==
'TTC') {
1426 $newprice =
$object->multiprices_ttc[$level] * (100 + $pricepercentage) / 100;
1427 $minprice =
$object->multiprices_min_ttc[$level];
1429 $newprice =
$object->multiprices[$level] * (100 + $pricepercentage) / 100;
1430 $minprice =
$object->multiprices_min[$level];
1432 $res =
$object->updatePrice($newprice,
$object->price_base_type, $user,
$object->tva_tx, $minprice, $level,
$object->tva_npr, 0, 0, array(),
$object->default_vat_code);
1452 $toselect = array();
1458if (!$error && ($action ==
'setsupervisor' && $confirm ==
'yes') && $permissiontoadd) {
1459 '@phan-var-force User $object';
1462 $supervisortoset =
GETPOSTINT(
'supervisortoset');
1463 if (!empty($supervisortoset)) {
1464 foreach ($toselect as $toselectid) {
1465 $result =
$object->fetch($toselectid);
1468 $object->fk_user = $supervisortoset;
1469 $res =
$object->update($user);
1489 $toselect = array();
1495if (!$error && ($action ==
'affectuser' && $confirm ==
'yes') && $permissiontoadd) {
1500 $projectrole =
GETPOST(
'projectrole');
1501 $tasksrole =
GETPOST(
'tasksrole');
1502 if (!empty($usertoaffect)) {
1503 foreach ($toselect as $toselectid) {
1504 $result =
$object->fetch($toselectid);
1507 $res =
$object->add_contact($usertoaffect, $projectrole,
'internal');
1509 $taskstatic =
new Task($db);
1510 $task_array = $taskstatic->getTasksArray(
null,
null,
$object->id, 0, 0);
1512 foreach ($task_array as $task) {
1513 $tasksToAffect =
new Task($db);
1514 $result = $tasksToAffect->fetch($task->id);
1516 $res = $tasksToAffect->add_contact($usertoaffect, $tasksrole,
'internal');
1540 $toselect = array();
1546if (!$error && ($massaction ==
'enable' || ($action ==
'enable' && $confirm ==
'yes')) && $permissiontoadd) {
1549 $objecttmp =
new $objectclass($db);
1551 foreach ($toselect as $toselectid) {
1552 $result = $objecttmp->fetch($toselectid);
1554 if (in_array($objecttmp->element, array(
'societe'))) {
1555 $result = $objecttmp->setStatut(1);
1583if (!$error && ($massaction ==
'disable' || ($action ==
'disable' && $confirm ==
'yes')) && $permissiontoadd) {
1586 $objecttmp =
new $objectclass($db);
1588 foreach ($toselect as $toselectid) {
1589 $result = $objecttmp->fetch($toselectid);
1591 if (in_array($objecttmp->element, array(
'societe'))) {
1592 $result = $objecttmp->setStatut(0);
1620if (!$error && $action ==
'confirm_edit_value_extrafields' && $confirm ==
'yes' && $permissiontoadd) {
1623 $objecttmp =
new $objectclass($db);
1625 $e->fetch_name_optionals_label($objecttmp->table_element);
1628 $extrafieldKeyToUpdate =
GETPOST(
'extrafield-key-to-update');
1631 foreach ($toselect as $toselectid) {
1633 $objecttmp =
new $objectclass($db);
1634 $result = $objecttmp->fetch($toselectid);
1637 $ret = $e->setOptionalsFromPost(
null, $objecttmp, $extrafieldKeyToUpdate);
1639 $objecttmp->insertExtraFields();
1663if (!$error && ($massaction ==
'assignsalerepresentative' || ($action ==
'assignsalerepresentative' && $confirm ==
'yes')) && $permissiontoadd) {
1666 $objecttmp =
new $objectclass($db);
1669 foreach ($toselect as $toselectid) {
1670 $result = $objecttmp->fetch($toselectid);
1672 if (in_array($objecttmp->element, array(
'societe'))) {
1673 $result = $objecttmp->setSalesRep(
GETPOST(
"commercial",
"alpha"));
1691 setEventMessages($langs->trans(
"CommercialsAffected", $nbok),
null,
'mesgs');
1701if (!$error && ($massaction ==
'unassigncommercial' || ($action ==
'unassigncommercial' && $confirm ==
'yes')) && $permissiontoadd) {
1704 $objecttmp =
new $objectclass($db);
1707 foreach ($toselect as $toselectid) {
1708 $result = $objecttmp->fetch($toselectid);
1710 if (in_array($objecttmp->element, array(
'societe'))) {
1711 $TCommercial =
GETPOST(
"commercial",
"alpha");
1712 if (is_array($TCommercial)) {
1713 foreach ($TCommercial as $commercial) {
1714 $result = $objecttmp->del_commercial($user, $commercial);
1734 setEventMessages($langs->trans(
"CommercialsDisaffected", $nbok),
null,
'mesgs');
1744if (!$error && ($massaction ==
'approveleave' || ($action ==
'approveleave' && $confirm ==
'yes')) && $permissiontoapprove) {
1747 $objecttmp =
new $objectclass($db);
1748 '@phan-var-force Holiday $objecttmp';
1750 foreach ($toselect as $toselectid) {
1751 $result = $objecttmp->fetch($toselectid);
1754 setEventMessages($langs->trans(
'StatusOfRefMustBe', $objecttmp->ref, $langs->transnoentitiesnoconv(
'Validated')),
null,
'warnings');
1757 if ($user->id == $objecttmp->fk_validator) {
1758 $objecttmp->oldcopy =
dol_clone($objecttmp, 2);
1760 $objecttmp->date_valid =
dol_now();
1761 $objecttmp->fk_user_valid = $user->id;
1762 $objecttmp->date_approval =
dol_now();
1763 $objecttmp->fk_user_approve = $user->id;
1765 $objecttmp->statut = $objecttmp->status;
1767 $verif = $objecttmp->approve($user);
1776 $tmpUser =
new User($db);
1777 $result = $tmpUser->fetch($objecttmp->fk_user);
1780 $nbopenedday =
num_open_day($objecttmp->date_debut_gmt, $objecttmp->date_fin_gmt, 0, 1, $objecttmp->halfday, $tmpUser->country_id);
1781 $soldeActuel = $objecttmp->getCpforUser($objecttmp->fk_user, $objecttmp->fk_type);
1782 $newSolde = ($soldeActuel - $nbopenedday);
1785 $result = $objecttmp->addLogCP($user->id, $objecttmp->fk_user, $langs->transnoentitiesnoconv(
"Holidays"), $newSolde, $objecttmp->fk_type);
1792 $result = $objecttmp->updateSoldeCP($objecttmp->fk_user, $newSolde, $objecttmp->fk_type);
1801 $destinataire =
new User($db);
1802 $destinataire->fetch($objecttmp->fk_user);
1803 $emailTo = $destinataire->email;
1806 dol_syslog(
"User that request leave has no email, so we redirect directly to finished page without sending email");
1809 $expediteur =
new User($db);
1810 $expediteur->fetch($objecttmp->fk_validator);
1820 $subject = $societeName.
" - ".$langs->transnoentitiesnoconv(
"HolidaysValidated");
1823 $message = $langs->transnoentitiesnoconv(
"Hello").
" ".$destinataire->firstname.
",\n";
1826 $message .= $langs->transnoentities(
"HolidaysValidatedBody",
dol_print_date($objecttmp->date_debut,
'day'),
dol_print_date($objecttmp->date_fin,
'day')).
"\n";
1828 $message .=
"- ".$langs->transnoentitiesnoconv(
"ValidatedBy").
" : ".
dolGetFirstLastname($expediteur->firstname, $expediteur->lastname).
"\n";
1830 $message .=
"- ".$langs->transnoentitiesnoconv(
"Link").
" : ".
$dolibarr_main_url_root.
"/holiday/card.php?id=".$objecttmp->id.
"\n\n";
1833 $trackid =
'leav'.$objecttmp->id;
1835 require_once DOL_DOCUMENT_ROOT.
'/core/class/CMailFile.class.php';
1836 $mail =
new CMailFile($subject, $emailTo, $emailFrom, $message, array(), array(), array(),
'',
'', 0, 0,
'',
'', $trackid);
1839 $result = $mail->sendfile();
1848 $langs->load(
"errors");
1849 setEventMessages($langs->trans(
'ErrorNotApproverForHoliday', $objecttmp->ref),
null,
'errors');
1861 } elseif ($nbok == 1) {
1870if (!$error && ($massaction ==
'increaseholiday' || ($action ==
'increaseholiday' && $confirm ==
'yes')) && $permissiontoapprove && is_array($toselect)) {
1871 '@phan-var-force Holiday $holiday';
1874 $objecttmp =
new $objectclass($db);
1879 if ($nbdaysholidays <= 0) {
1885 foreach ($toselect as $toselectid) {
1886 $balancecpuser = $objecttmp->getCPforUser($toselectid, $typeholiday);
1887 if (!empty($balancecpuser)) {
1888 $newnbdaysholidays = $nbdaysholidays + $balancecpuser;
1890 $newnbdaysholidays = $nbdaysholidays;
1892 $result = $holiday->addLogCP($user->id, $toselectid, $langs->transnoentitiesnoconv(
'ManualUpdate'), $newnbdaysholidays, $typeholiday);
1899 $objecttmp->updateSoldeCP($toselectid, $newnbdaysholidays, $typeholiday);
1912 setEventMessages($langs->trans(
"HolidayRecordsIncreased", $nbok),
null,
'mesgs');
1913 } elseif ($nbok == 1) {
1917 $toselect = array();
1924if (!$error && ($massaction ==
'clonetasks' || ($action ==
'clonetasks' && $confirm ==
'yes'))) {
1927 include_once DOL_DOCUMENT_ROOT.
'/projet/class/task.class.php';
1929 $origin_task =
new Task($db);
1930 $clone_task =
new Task($db);
1931 $newproject =
new Project($db);
1935 $iscontactofnewproject = 0;
1936 if (empty($newproject->public)) {
1937 $tmps = $newproject->getProjectsAuthorizedForUser($user, 0, 1, 0,
'(fk_statut:=:1)');
1938 $tmparray = explode(
',', $tmps);
1939 if (!in_array($newproject->id, $tmparray)) {
1940 $iscontactofnewproject = 1;
1945 $permisstiontoadd =
false;
1946 if ($user->hasRight(
'project',
'all',
'creer') || ($user->hasRight(
'project',
'creer') && ($newproject->public || $iscontactofnewproject))) {
1947 $permisstiontoadd =
true;
1950 if ($permisstiontoadd) {
1951 foreach (
GETPOST(
'selected') as $task) {
1952 $origin_task->fetch($task,
'', 0);
1957 require_once DOL_DOCUMENT_ROOT .
"/core/modules/project/task/" .
getDolGlobalString(
'PROJECT_TASK_ADDON') .
'.php';
1958 $modTask =
new $classnamemodtask();
1959 '@phan-var-force ModeleNumRefTask $modTask';
1961 $defaultref = $modTask->getNextValue(
null, $clone_task);
1965 $clone_task->fk_project =
GETPOSTINT(
'projectid');
1966 $clone_task->ref = $defaultref;
1967 $clone_task->label = $origin_task->label;
1968 $clone_task->description = $origin_task->description;
1969 $clone_task->planned_workload = $origin_task->planned_workload;
1970 $clone_task->fk_task_parent = $origin_task->fk_task_parent;
1971 $clone_task->date_c =
dol_now();
1972 $clone_task->date_start = $origin_task->date_start;
1973 $clone_task->date_end = $origin_task->date_end;
1974 $clone_task->progress = $origin_task->progress;
1977 $ret = $extrafields->setOptionalsFromPost(
null, $clone_task);
1979 $taskid = $clone_task->create($user);
1982 $result = $clone_task->add_contact(
GETPOSTINT(
"userid"),
'TASKEXECUTIVE',
'internal');
1985 if ($db->lasterrno() ==
'DB_ERROR_RECORD_ALREADY_EXISTS') {
1986 $langs->load(
"projects");
1988 $duplicate_code_error =
true;
1999 setEventMessages($langs->trans(
'NumberOfTasksCloned', $num),
null,
'mesgs');
2000 header(
"Location: ".DOL_URL_ROOT.
'/projet/tasks.php?id='.
GETPOSTINT(
'projectid'));
2008if (empty($toselect)) {
2011$parameters[
'toselect'] = &$toselect;
2012$parameters[
'uploaddir'] = $uploaddir;
2013$parameters[
'massaction'] = $massaction;
2014$parameters[
'diroutputmassaction'] = isset($diroutputmassaction) ? $diroutputmassaction :
null;
2017$reshook = $hookmanager->executeHooks(
'doMassActions', $parameters,
$object, $action);
if(! $sortfield) if(! $sortorder) $object
global $dolibarr_main_url_root
Class to manage members of a foundation.
Class to send emails (with attachments or not) Usage: $mailfile = new CMailFile($subject,...
Class to manage categories.
Class to manage customers orders.
const STATUS_DRAFT
Draft status.
const STATUS_VALIDATED
Validated status.
Class for ConferenceOrBoothAttendee.
const STATUS_DRAFT
Draft status.
const STATUS_VALIDATED
Validated (need to be paid)
const STATUS_VALIDATED
Validated status.
const STATUS_DRAFT
Draft status.
const STATUS_REFUSED
Refused.
const STATUS_CANCELED
Canceled.
const STATUS_APPROVED
Approved.
Class to manage projects.
const STATUS_DRAFT
Draft status.
Class to manage third parties objects (customers, suppliers, prospects...)
Class to manage translations.
Class to manage Dolibarr users.
num_open_day($timestampStart, $timestampEnd, $inhour=0, $lastday=0, $halfday=0, $countryCodeOrId='')
Function to return number of working days (and text of units) between two dates (working days)
dol_delete_file($file, $disableglob=0, $nophperrors=0, $nohook=0, $object=null, $allowdotdot=false, $indexdatabase=1, $nolog=0)
Remove a file or several files with a mask.
dol_is_file($pathoffile)
Return if path is a file.
dol_dir_list($utf8_path, $types="all", $recursive=0, $filter="", $excludefilter=null, $sortcriteria="name", $sortorder=SORT_ASC, $mode=0, $nohook=0, $relativename="", $donotfollowsymlinks=0, $nbsecondsold=0)
Scan a directory and return a list of files/directories.
dol_most_recent_file($dir, $regexfilter='', $excludefilter=array('(\.meta|_preview.*\.png) $', '^\.'), $nohook=0, $mode=0)
Return file(s) into a directory (by default most recent)
dol_now($mode='gmt')
Return date for now.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0, $attop=0)
Set event messages in dol_events session object.
dol_mimetype($file, $default='application/octet-stream', $mode=0)
Return MIME type of a file from its name with extension.
GETPOSTINT($paramname, $method=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
dol_string_nospecial($str, $newstr='_', $badcharstoreplace='', $badcharstoremove='', $keepspaces=0)
Clean a string from all punctuation characters to use it as a ref or login.
setEventMessage($mesgs, $style='mesgs', $noduplicate=0, $attop=0)
Set event message in dol_events session object.
dol_sanitizeFileName($str, $newstr='_', $unaccent=1, $includequotes=0, $allowdash=0)
Clean a string to use it as a file name.
dolChmod($filepath, $newmask='')
Change mod of a file.
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
GETPOSTFLOAT($paramname, $rounding='', $option=2)
Return the value of a $_GET or $_POST supervariable, converted into float.
dolGetFirstLastname($firstname, $lastname, $nameorder=-1)
Return firstname and lastname in correct order.
dol_concatdesc($text1, $text2, $forxml=false, $invert=false)
Concat 2 descriptions with a new line between them (second operand after first one with appropriate n...
complete_substitutions_array(&$substitutionarray, $outputlangs, $object=null, $parameters=null, $callfunc="completesubstitutionarray")
Complete the $substitutionarray with more entries coming from external module that had set the "subst...
make_substitutions($text, $substitutionarray, $outputlangs=null, $converttextinhtmlifnecessary=0)
Make substitution into a text string, replacing keys with vals from $substitutionarray (oldval=>newva...
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
dol_clone($srcobject, $native=2)
Create a clone of instance of object (new instance with same value for each properties) With native =...
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs=null, $encodetooutput=false, $decorate=0)
Output date in a string format according to outputlangs (or langs if not defined).
dol_print_error($db=null, $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
isModEnabled($module)
Is Dolibarr module enabled.
get_exdir($num, $level, $alpha, $withoutslash, $object, $modulepart='')
Return a path to have a the directory according to object where files are stored.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
dol_mkdir($dir, $dataroot='', $newmask='')
Creation of a directory (this can create recursive subdir)
pdf_getFormat($outputlangs=null, $mode='setup')
Return array with format properties of default PDF format.
pdf_getPDFFont($outputlangs)
Return font name to use for PDF generation.
pdf_getInstance($format='', $metric='mm', $pagetype='P')
Return a PDF instance object.
dol_hash($chain, $type='0', $nosalt=0, $mode=0)
Returns a hash (non reversible encryption) of a string.