41@phan-var-force ?string $permissiontoread
42@phan-var-force ?string $permissiontodelete
43@phan-var-force ?string $permissiontoclose
44@phan-var-force ?string $permissiontoapprove
45@phan-var-force ?int[] $toselect
46@phan-var-force ?string $diroutputmassaction
47@phan-var-force ?string $objectlabel
48@phan-var-force ?string $option
49@phan-var-force ?string $deliveryreceipt
54if (empty($objectclass) || empty($uploaddir)) {
55 dol_print_error(
null,
'include of actions_massactions.inc.php is done but var $objectclass or $uploaddir was not defined');
58if (empty($massaction)) {
65@phan-var-force "CommonObject"|"CommandeFournisseur"|"ConferenceOrBoothAttendee"|"Contrat"|"Contact"|"Expedition"|"ExpenseReport"|"Facture"|"FactureFournisseur"|"Fichinter"|"Holiday"|"Partnership"|"Project"|"Propal"|"Societe"|"SupplierProposal" $objectclass
66@phan-var-force string $massaction
67@phan-var-force string $uploaddir
72if (!empty($permtoread) && empty($permissiontoread)) {
73 $permissiontoread = $permtoread;
75if (!empty($permtocreate) && empty($permissiontoadd)) {
76 $permissiontoadd = $permtocreate;
78if (!empty($permtodelete) && empty($permissiontodelete)) {
79 $permissiontodelete = $permtodelete;
83$maxformassaction = (!
getDolGlobalString(
'MAIN_LIMIT_FOR_MASS_ACTIONS') ? 1000 : $conf->global->MAIN_LIMIT_FOR_MASS_ACTIONS);
84if ($massaction && is_array($toselect) && count($toselect) < 1) {
88if (!$error && isset($toselect) && is_array($toselect) && count($toselect) > $maxformassaction) {
89 setEventMessages($langs->trans(
'TooManyRecordForMassAction', $maxformassaction),
null,
'errors');
93if (!$error && $massaction ==
'confirm_presend' && !
GETPOST(
'sendmail')) {
94 $massaction =
'presend';
97if (!$error && $massaction ==
'confirm_presend') {
101 $langs->load(
"mails");
102 include_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
103 include_once DOL_DOCUMENT_ROOT.
'/core/lib/signature.lib.php';
105 $listofobjectid = array();
106 $listofobjectthirdparties = array();
107 $listofobjectcontacts = array();
108 $listofobjectref = array();
109 $contactidtosend = array();
110 $attachedfilesThirdpartyObj = array();
111 $oneemailperrecipient = (
GETPOSTINT(
'oneemailperrecipient') ? 1 : 0);
115 $objecttmp =
new $objectclass($db);
118 $thirdparty =
new Societe($db);
119 if ($objecttmp->element ==
'expensereport') {
120 $thirdparty =
new User($db);
121 } elseif ($objecttmp->element ==
'contact') {
122 $thirdparty =
new Contact($db);
123 } elseif ($objecttmp->element ==
'partnership' &&
getDolGlobalString(
'PARTNERSHIP_IS_MANAGED_FOR') ==
'member') {
125 } elseif ($objecttmp->element ==
'holiday') {
126 $thirdparty =
new User($db);
127 } elseif ($objecttmp->element ==
'conferenceorboothattendee') {
131 foreach ($toselect as $toselectid) {
132 $objecttmp =
new $objectclass($db);
133 '@phan-var-force CommonObject $objecttmp';
134 $result = $objecttmp->fetch($toselectid);
136 $listofobjectid[$toselectid] = $toselectid;
139 $tmpobjectid = ($objecttmp->fk_soc ? $objecttmp->fk_soc : $objecttmp->socid);
140 if ($objecttmp->element ==
'societe') {
141 '@phan-var-force Societe $objecttmp';
142 $tmpobjectid = $objecttmp->id;
143 } elseif ($objecttmp->element ==
'contact') {
144 '@phan-var-force Contact $objecttmp';
145 $tmpobjectid = $objecttmp->id;
146 } elseif ($objecttmp->element ==
'expensereport') {
147 '@phan-var-force ExpenseReport $objecttmp';
148 $tmpobjectid = $objecttmp->fk_user_author;
149 } elseif ($objecttmp->element ==
'partnership' &&
getDolGlobalString(
'PARTNERSHIP_IS_MANAGED_FOR') ==
'member') {
150 '@phan-var-force Partnership $objecttmp';
151 $tmpobjectid = $objecttmp->fk_member;
152 } elseif ($objecttmp->element ==
'holiday') {
153 '@phan-var-force Holiday $objecttmp';
154 $tmpobjectid = $objecttmp->fk_user;
155 } elseif ($objecttmp->element ==
'conferenceorboothattendee') {
156 '@phan-var-force ConferenceOrBoothAttendee $objecttmp';
157 $tmpobjectid = $objecttmp->id;
159 if (empty($tmpobjectid)) {
163 if ($objectclass ==
'Facture') {
164 '@phan-var-force Facture $objecttmp';
165 $tmparraycontact = array();
166 $tmparraycontact = $objecttmp->liste_contact(-1,
'external', 0,
'BILLING');
167 if (is_array($tmparraycontact) && count($tmparraycontact) > 0) {
168 foreach ($tmparraycontact as $data_email) {
169 $listofobjectcontacts[$toselectid][$data_email[
'id']] = $data_email[
'email'];
172 } elseif ($objectclass ==
'CommandeFournisseur') {
173 '@phan-var-force CommandeFournisseur $objecttmp';
174 $tmparraycontact = array();
175 $tmparraycontact = $objecttmp->liste_contact(-1,
'external', 0,
'CUSTOMER');
176 if (is_array($tmparraycontact) && count($tmparraycontact) > 0) {
177 foreach ($tmparraycontact as $data_email) {
178 $listofobjectcontacts[$toselectid][$data_email[
'id']] = $data_email[
'email'];
183 $listofobjectthirdparties[$tmpobjectid] = $tmpobjectid;
184 $listofobjectref[$tmpobjectid][$toselectid] = $objecttmp;
190 if (
GETPOST(
'fromtype',
'alpha') ===
'user' && empty($user->email)) {
193 $massaction =
'presend';
196 $receiver =
GETPOST(
'receiver',
'alphawithlgt');
197 if (!is_array($receiver)) {
198 if (empty($receiver) || $receiver ==
'-1') {
201 $receiver = array($receiver);
204 if (!trim(
GETPOST(
'sendto',
'alphawithlgt')) && count($receiver) == 0 && count($listofobjectthirdparties) == 1) {
206 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Recipient")),
null,
'warnings');
207 $massaction =
'presend';
210 if (!
GETPOST(
'subject',
'restricthtml')) {
212 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"MailTopic")),
null,
'warnings');
213 $massaction =
'presend';
218 foreach ($listofobjectthirdparties as $thirdpartyid) {
219 $result = $thirdparty->fetch($thirdpartyid);
232 if (trim(
GETPOST(
'sendto',
'alphawithlgt'))) {
234 $tmparray[] = trim(
GETPOST(
'sendto',
'alphawithlgt'));
236 if (count($receiver) > 0 && is_object($thirdparty)) {
237 foreach ($receiver as $key => $val) {
239 if ($val ==
'thirdparty') {
240 $tmparray[] = $thirdparty->name.
' <'.$thirdparty->email.
'>';
241 } elseif ($val && method_exists($thirdparty,
'contact_get_property')) {
242 $tmparray[] = $thirdparty->contact_get_property((
int) $val,
'email');
247 $sendto = implode(
',', $tmparray);
250 $receivercc =
GETPOST(
'receivercc',
'alphawithlgt');
251 if (!is_array($receivercc)) {
252 if ($receivercc ==
'-1') {
253 $receivercc = array();
255 $receivercc = array($receivercc);
259 if (trim(
GETPOST(
'sendtocc',
'alphawithlgt'))) {
260 $tmparray[] = trim(
GETPOST(
'sendtocc',
'alphawithlgt'));
262 if (count($receivercc) > 0) {
263 foreach ($receivercc as $key => $val) {
265 if ($val ==
'thirdparty') {
266 $tmparray[] = $thirdparty->name.
' <'.$thirdparty->email.
'>';
268 $tmparray[] = $thirdparty->contact_get_property((
int) $val,
'email');
273 $sendtocc = implode(
',', $tmparray);
276 $listofqualifiedobj = array();
277 $listofqualifiedref = array();
278 $thirdpartywithoutemail = array();
280 foreach ($listofobjectref[$thirdpartyid] as $objectid => $objectobj) {
283 $langs->load(
"errors");
285 $resaction .=
'<div class="error">'.$langs->trans(
'ErrorOnlyProposalNotDraftCanBeSentInMassAction', $objectobj->ref).
'</div><br>';
289 $langs->load(
"errors");
291 $resaction .=
'<div class="error">'.$langs->trans(
'ErrorOnlyOrderNotDraftCanBeSentInMassAction', $objectobj->ref).
'</div><br>';
295 $langs->load(
"errors");
297 $resaction .=
'<div class="error">'.$langs->trans(
'ErrorOnlyInvoiceValidatedCanBeSentInMassAction', $objectobj->ref).
'</div><br>';
302 if (empty($sendto)) {
303 if ($objectobj->element ==
'societe') {
304 $sendto = $objectobj->email;
305 } elseif ($objectobj->element ==
'expensereport') {
306 $fuser =
new User($db);
307 $fuser->fetch($objectobj->fk_user_author);
308 $sendto = $fuser->email;
309 } elseif ($objectobj->element ==
'contact') {
311 $fcontact->fetch($objectobj->id);
312 $sendto = $fcontact->email;
313 } elseif ($objectobj->element ==
'partnership' &&
getDolGlobalString(
'PARTNERSHIP_IS_MANAGED_FOR') ==
'member') {
315 $fadherent->fetch($objectobj->fk_member);
316 $sendto = $fadherent->email;
317 } elseif ($objectobj->element ==
'holiday') {
318 $fuser =
new User($db);
319 $fuser->fetch($objectobj->fk_user);
320 $sendto = $fuser->email;
321 } elseif ($objectobj->element ==
'facture' && !empty($listofobjectcontacts[$objectid])) {
322 $emails_to_sends = array();
323 $objectobj->fetch_thirdparty();
324 $contactidtosend = array();
325 foreach ($listofobjectcontacts[$objectid] as $contactemailid => $contactemailemail) {
326 $emails_to_sends[] = $objectobj->thirdparty->contact_get_property($contactemailid,
'email');
327 if (!in_array($contactemailid, $contactidtosend)) {
328 $contactidtosend[] = $contactemailid;
331 if (count($emails_to_sends) > 0) {
332 $sendto = implode(
',', $emails_to_sends);
334 } elseif ($objectobj->element ==
'order_supplier' && !empty($listofobjectcontacts[$objectid])) {
335 $emails_to_sends = array();
336 $objectobj->fetch_thirdparty();
337 $contactidtosend = array();
338 foreach ($listofobjectcontacts[$objectid] as $contactemailid => $contactemailemail) {
339 $emails_to_sends[] = $objectobj->thirdparty->contact_get_property($contactemailid,
'email');
340 if (!in_array($contactemailid, $contactidtosend)) {
341 $contactidtosend[] = $contactemailid;
344 if (count($emails_to_sends) > 0) {
345 $sendto = implode(
',', $emails_to_sends);
347 } elseif ($objectobj->element ==
'conferenceorboothattendee') {
348 $sendto = $objectobj->email;
350 $objectobj->fetch_thirdparty();
351 $sendto = $objectobj->thirdparty->email;
355 if (empty($sendto)) {
356 if ($objectobj->element ==
'societe') {
357 $objectobj->thirdparty = $objectobj;
362 if (empty($thirdpartywithoutemail[$objectobj->thirdparty->id])) {
363 $resaction .=
'<div class="error">'.$langs->trans(
'NoRecipientEmail', $objectobj->thirdparty->name).
'</div><br>';
365 dol_syslog(
'No recipient for thirdparty: '.$objectobj->thirdparty->name, LOG_WARNING);
366 $thirdpartywithoutemail[$objectobj->thirdparty->id] = 1;
370 if (
GETPOST(
'addmaindocfile')) {
377 $filedir = $uploaddir.
'/'.$subdir.dol_sanitizeFileName($objectobj->ref);
378 $filepath = $filedir.
'/'.$filename;
381 if ($objectobj->element ==
'invoice_supplier') {
382 $fileparams =
dol_most_recent_file($uploaddir.
'/'.
get_exdir($objectobj->id, 2, 0, 0, $objectobj, $objectobj->element).$objectobj->ref, preg_quote($objectobj->ref,
'/').
'([^\-])+');
383 $filepath = $fileparams[
'fullname'];
387 $filename_found =
'';
388 $filepath_found =
'';
389 $file_check_list = array();
390 $file_check_list[] = array(
394 if (
getDolGlobalString(
'MAIL_MASS_ACTION_ADD_LAST_IF_MAIN_DOC_NOT_FOUND') && !empty($objectobj->last_main_doc)) {
395 $file_check_list[] = array(
396 'name' => basename($objectobj->last_main_doc),
397 'path' => DOL_DATA_ROOT .
'/' . $objectobj->last_main_doc,
400 foreach ($file_check_list as $file_check_arr) {
402 $filename_found = $file_check_arr[
'name'];
403 $filepath_found = $file_check_arr[
'path'];
408 if ($filepath_found) {
410 $attachedfilesThirdpartyObj[$thirdpartyid][$objectid] = array(
411 'paths' => array($filepath_found),
412 'names' => array($filename_found),
417 $langs->load(
"errors");
418 foreach ($file_check_list as $file_check_arr) {
419 $resaction .=
'<div class="error">'.$langs->trans(
'ErrorCantReadFile', $file_check_arr[
'path']).
'</div><br>';
420 dol_syslog(
'Failed to read file: '.$file_check_arr[
'path'], LOG_WARNING);
427 $listofqualifiedobj[$objectid] = $objectobj;
428 $listofqualifiedref[$objectid] = $objectobj->ref;
435 if (count($listofqualifiedobj) > 0) {
436 $langs->load(
"commercial");
439 $fromtype =
GETPOST(
'fromtype');
440 if ($fromtype ===
'user') {
441 $from =
dol_string_nospecial($user->getFullName($langs),
' ', array(
",")).
' <'.$user->email.
'>';
442 } elseif ($fromtype ===
'company') {
444 } elseif (preg_match(
'/user_aliases_(\d+)/', $fromtype, $reg)) {
445 $tmp = explode(
',', $user->email_aliases);
446 $from = trim($tmp[((
int) $reg[1] - 1)]);
447 } elseif (preg_match(
'/global_aliases_(\d+)/', $fromtype, $reg)) {
449 $from = trim($tmp[((
int) $reg[1] - 1)]);
450 } elseif (preg_match(
'/senderprofile_(\d+)_(\d+)/', $fromtype, $reg)) {
451 $sql =
"SELECT rowid, label, email FROM ".MAIN_DB_PREFIX.
"c_email_senderprofile WHERE rowid = ".(int) $reg[1];
452 $resql = $db->query($sql);
453 $obj = $db->fetch_object($resql);
462 $subject =
GETPOST(
'subject',
'restricthtml');
463 $message =
GETPOST(
'message',
'restricthtml');
465 $sendtobcc =
GETPOST(
'sendtoccc');
466 if ($objectclass ==
'Propal') {
469 if ($objectclass ==
'Commande') {
472 if ($objectclass ==
'Facture') {
475 if ($objectclass ==
'SupplierProposal') {
476 $sendtobcc .= (!
getDolGlobalString(
'MAIN_MAIL_AUTOCOPY_SUPPLIER_PROPOSAL_TO') ?
'' : (($sendtobcc ?
", " :
"") .
getDolGlobalString(
'MAIN_MAIL_AUTOCOPY_SUPPLIER_PROPOSAL_TO')));
478 if ($objectclass ==
'CommandeFournisseur') {
481 if ($objectclass ==
'FactureFournisseur') {
484 if ($objectclass ==
'Project') {
490 $looparray = array();
491 if (!$oneemailperrecipient) {
492 $looparray = $listofqualifiedobj;
493 foreach ($looparray as $key => $objecttmp) {
494 $looparray[$key]->thirdparty = $thirdparty;
497 $objectforloop =
new $objectclass($db);
498 $objectforloop->thirdparty = $thirdparty;
499 $looparray[0] = $objectforloop;
502 dol_syslog(
"We have set an array of ".count($looparray).
" emails to send. oneemailperrecipient=".$oneemailperrecipient);
504 foreach ($looparray as $objectid => $objecttmp) {
506 if (isModEnabled(
'project') && method_exists($objecttmp,
'fetchProject') && is_null($objecttmp->project)) {
507 $objecttmp->fetchProject();
510 $substitutionarray[
'__ID__'] = ($oneemailperrecipient ? implode(
', ', array_keys($listofqualifiedobj)) : $objecttmp->id);
511 $substitutionarray[
'__REF__'] = ($oneemailperrecipient ? implode(
', ', $listofqualifiedref) : $objecttmp->
ref);
512 $substitutionarray[
'__EMAIL__'] = $thirdparty->email;
513 $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"/>';
515 $parameters = array(
'mode' =>
'formemail');
517 if (!empty($listofobjectthirdparties)) {
518 $parameters[
'listofobjectthirdparties'] = $listofobjectthirdparties;
520 if (!empty($listofobjectref)) {
521 $parameters[
'listofobjectref'] = $listofobjectref;
529 $attachedfiles = array(
'paths' => array(),
'names' => array(),
'mimes' => array());
530 if ($oneemailperrecipient) {
532 if (is_array($attachedfilesThirdpartyObj[$thirdparty->id]) && count($attachedfilesThirdpartyObj[$thirdparty->id])) {
533 foreach ($attachedfilesThirdpartyObj[$thirdparty->id] as $keyObjId => $objAttachedFiles) {
535 $attachedfiles = array(
536 'paths' => array_merge($attachedfiles[
'paths'], $objAttachedFiles[
'paths']),
537 'names' => array_merge($attachedfiles[
'names'], $objAttachedFiles[
'names']),
538 'mimes' => array_merge($attachedfiles[
'mimes'], $objAttachedFiles[
'mimes'])
542 } elseif (!empty($attachedfilesThirdpartyObj[$thirdparty->id][$objectid])) {
545 $attachedfiles = $attachedfilesThirdpartyObj[$thirdparty->id][$objectid];
548 $filepath = $attachedfiles[
'paths'];
549 $filename = $attachedfiles[
'names'];
550 $mimetype = $attachedfiles[
'mimes'];
553 if ($oneemailperrecipient) {
554 $trackid =
'thi'.$thirdparty->id;
555 if ($objecttmp->element ==
'expensereport') {
556 $trackid =
'use'.$thirdparty->id;
557 } elseif ($objecttmp->element ==
'contact') {
558 $trackid =
'ctc'.$thirdparty->id;
559 } elseif ($objecttmp->element ==
'holiday') {
560 $trackid =
'use'.$thirdparty->id;
563 $trackid = strtolower(get_class($objecttmp));
564 if (get_class($objecttmp) ==
'Contact') {
566 } elseif (get_class($objecttmp) ==
'Contrat') {
568 } elseif (get_class($objecttmp) ==
'Propal') {
570 } elseif (get_class($objecttmp) ==
'Commande') {
572 } elseif (get_class($objecttmp) ==
'Facture') {
574 } elseif (get_class($objecttmp) ==
'SupplierProposal') {
576 } elseif (get_class($objecttmp) ==
'CommandeFournisseur') {
578 } elseif (get_class($objecttmp) ==
'FactureFournisseur') {
582 $trackid .= $objecttmp->id;
588 if (empty($sendcontext)) {
589 $sendcontext =
'standard';
593 $vardir = $conf->user->dir_output.
"/".$user->id;
594 $upload_dir_tmp = $vardir.
'/temp';
597 require_once DOL_DOCUMENT_ROOT.
'/core/class/CMailFile.class.php';
598 $mailfile =
new CMailFile($subjectreplaced, $sendto, $from, $messagereplaced, $filepath, $mimetype, $filename, $sendtocc, $sendtobcc, $deliveryreceipt, -1,
'',
'', $trackid,
'', $sendcontext,
'', $upload_dir_tmp);
599 if ($mailfile->error) {
600 $resaction .=
'<div class="error">'.$mailfile->error.
'</div>';
602 $result = $mailfile->sendfile();
604 $resaction .= $langs->trans(
'MailSuccessfulySent', $mailfile->getValidAddress($mailfile->addr_from, 2), $mailfile->getValidAddress($mailfile->addr_to, 2)).
'<br>';
609 foreach ($listofqualifiedobj as $objid2 => $objectobj2) {
610 if ((!$oneemailperrecipient) && $objid2 != $objectid) {
614 dol_syslog(
"Try to insert email event into agenda for objid=".$objid2.
" => objectobj=".get_class($objectobj2));
623 $actionmsg = $langs->transnoentities(
'MailSentByTo', $from, $sendto);
626 $actionmsg =
dol_concatdesc($actionmsg, $langs->transnoentities(
'Bcc').
": ".$sendtocc);
628 $actionmsg =
dol_concatdesc($actionmsg, $langs->transnoentities(
'MailTopic').
": ".$subjectreplaced);
629 $actionmsg =
dol_concatdesc($actionmsg, $langs->transnoentities(
'TextUsedInTheMessageBody').
":");
635 $objectobj2->sendtoid = (empty($contactidtosend) ? 0 : $contactidtosend);
636 $objectobj2->actionmsg = $actionmsg;
637 $objectobj2->actionmsg2 = $actionmsg2;
638 $objectobj2->fk_element = $objid2;
639 $objectobj2->elementtype = $objectobj2->element;
641 $objectobj2->actionmsg2 = $subjectreplaced;
644 $triggername = strtoupper(get_class($objectobj2)).
'_SENTBYMAIL';
645 if ($triggername ==
'SOCIETE_SENTBYMAIL') {
646 $triggername =
'COMPANY_SENTBYMAIL';
648 if ($triggername ==
'CONTRAT_SENTBYMAIL') {
649 $triggername =
'CONTRACT_SENTBYMAIL';
651 if ($triggername ==
'COMMANDE_SENTBYMAIL') {
652 $triggername =
'ORDER_SENTBYMAIL';
654 if ($triggername ==
'FACTURE_SENTBYMAIL') {
655 $triggername =
'BILL_SENTBYMAIL';
657 if ($triggername ==
'EXPEDITION_SENTBYMAIL') {
658 $triggername =
'SHIPPING_SENTBYMAIL';
660 if ($triggername ==
'COMMANDEFOURNISSEUR_SENTBYMAIL') {
661 $triggername =
'ORDER_SUPPLIER_SENTBYMAIL';
663 if ($triggername ==
'FACTUREFOURNISSEUR_SENTBYMAIL') {
664 $triggername =
'BILL_SUPPLIER_SENTBYMAIL';
666 if ($triggername ==
'SUPPLIERPROPOSAL_SENTBYMAIL') {
667 $triggername =
'PROPOSAL_SUPPLIER_SENTBYMAIL';
669 if ($triggername ==
'PROJET_SENTBYMAIL') {
670 $triggername =
'PROJECT_SENTBYMAIL';
673 if (!empty($triggername)) {
675 $result = $objectobj2->call_trigger($triggername, $user);
683 dol_syslog(
"Error in trigger ".$triggername.
' '.$db->lasterror(), LOG_ERR);
690 $langs->load(
"other");
691 if ($mailfile->error) {
692 $resaction .= $langs->trans(
'ErrorFailedToSendMail', $from, $sendto);
693 $resaction .=
'<br><div class="error">'.$mailfile->error.
'</div>';
695 $resaction .=
'<div class="warning">No mail sent. Feature is disabled by option MAIN_DISABLE_ALL_MAILS</div>';
697 $resaction .= $langs->trans(
'ErrorFailedToSendMail', $from, $sendto) .
'<br><div class="error">(unhandled error)</div>';
705 $resaction .= ($resaction ?
'<br>' : $resaction);
706 $resaction .=
'<strong>'.$langs->trans(
"ResultOfMailSending").
':</strong><br>'.
"\n";
707 $resaction .= $langs->trans(
"NbSelected").
': '.count($toselect).
"\n<br>";
708 $resaction .= $langs->trans(
"NbIgnored").
': '.($nbignored ? $nbignored : 0).
"\n<br>";
709 $resaction .= $langs->trans(
"NbSent").
': '.($nbsent ? $nbsent : 0).
"\n<br>";
714 setEventMessages($langs->trans(
"EMailSentForNElements", $nbsent.
'/'.count($toselect)),
null,
'mesgs');
727if (!$error && $massaction ==
'cancelorders') {
732 $orders =
GETPOST(
'toselect',
'array');
733 foreach ($orders as $id_order) {
735 if ($cmd->fetch($id_order) <= 0) {
740 $langs->load(
'errors');
741 setEventMessages($langs->trans(
"ErrorObjectMustHaveStatusValidToBeCanceled", $cmd->ref),
null,
'errors');
746 $result = $cmd->cancel();
766if (!$error && $massaction ==
"builddoc" && $permissiontoread && !
GETPOST(
'button_search')) {
767 if (empty($diroutputmassaction)) {
768 dol_print_error(
null,
'include of actions_massactions.inc.php is done but var $diroutputmassaction was not defined');
772 require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
773 require_once DOL_DOCUMENT_ROOT.
'/core/lib/pdf.lib.php';
774 require_once DOL_DOCUMENT_ROOT.
'/core/lib/date.lib.php';
776 $objecttmp =
new $objectclass($db);
777 $listofobjectid = array();
778 $listofobjectthirdparties = array();
779 $listofobjectref = array();
780 foreach ($toselect as $toselectid) {
781 $objecttmp =
new $objectclass($db);
782 $result = $objecttmp->fetch($toselectid);
784 $listofobjectid[$toselectid] = $toselectid;
785 $thirdpartyid = !empty($objecttmp->fk_soc) ? $objecttmp->fk_soc : $objecttmp->socid;
786 $listofobjectthirdparties[$thirdpartyid] = $thirdpartyid;
787 $listofobjectref[$toselectid] = $objecttmp->ref;
791 $arrayofinclusion = array();
792 foreach ($listofobjectref as $tmppdf) {
795 foreach ($listofobjectref as $tmppdf) {
796 $arrayofinclusion[] =
'^'.preg_quote(
dol_sanitizeFileName($tmppdf),
'/').
'_[a-zA-Z0-9\-\_\'\&\.]+\.pdf$';
798 $listoffiles =
dol_dir_list($uploaddir,
'all', 1, implode(
'|', $arrayofinclusion),
'\.meta$|\.png',
'date', SORT_DESC, 0, 1);
803 foreach ($listofobjectref as $basename) {
805 foreach ($listoffiles as $filefound) {
806 if (strstr($filefound[
"name"], $basename)) {
807 $files[] = $filefound[
'fullname'];
814 $outputlangs = $langs;
817 $newlang =
GETPOST(
'lang_id',
'aZ09');
822 if (!empty($newlang)) {
824 $outputlangs->setDefaultLang($newlang);
833 $filename = preg_replace(
'/\s/',
'_', $filename);
836 if (in_array($objecttmp->element, array(
'facture',
'invoice_supplier')) && $search_status ==
Facture::STATUS_VALIDATED) {
837 if ($option ==
'late') {
844 $filename .=
'_'.$year;
847 $filename .=
'_'.$month;
850 if (count($files) > 0) {
852 $file = $diroutputmassaction.
'/'.$filename.
'_'.
dol_print_date($now,
'dayhourlog').
'.pdf';
855 foreach ($files as $f) {
856 $input_files .=
' '.escapeshellarg($f);
859 $cmd =
'pdftk '.$input_files.
' cat output '.escapeshellarg($file);
863 if (file_exists($file)) {
866 $langs->load(
"exports");
869 setEventMessages($langs->trans(
'ErrorPDFTkOutputFileNotFound'),
null,
'errors');
872 setEventMessages($langs->trans(
'NoPDFAvailableForDocGenAmongChecked'),
null,
'errors');
877 $page_largeur = $formatarray[
'width'];
878 $page_hauteur = $formatarray[
'height'];
879 $format = array($page_largeur, $page_hauteur);
883 if (class_exists(
'TCPDF')) {
884 $pdf->setPrintHeader(
false);
885 $pdf->setPrintFooter(
false);
890 $pdf->SetCompression(
false);
894 foreach ($files as $file) {
896 $pagecount = $pdf->setSourceFile($file);
897 for ($i = 1; $i <= $pagecount; $i++) {
898 $tplidx = $pdf->importPage($i);
899 $s = $pdf->getTemplatesize($tplidx);
900 $pdf->AddPage($s[
'h'] > $s[
'w'] ?
'P' :
'L');
901 $pdf->useTemplate($tplidx);
910 $filename = preg_replace(
'/\s/',
'_', $filename);
914 if (in_array($objecttmp->element, array(
'facture',
'invoice_supplier')) && $search_status ==
Facture::STATUS_VALIDATED) {
915 if ($option ==
'late') {
922 $filename .=
'_'.$year;
925 $filename .=
'_'.$month;
929 $file = $diroutputmassaction.
'/'.$filename.
'_'.
dol_print_date($now,
'dayhourlog').
'.pdf';
930 $pdf->Output($file,
'F');
933 $langs->load(
"exports");
936 setEventMessages($langs->trans(
'NoPDFAvailableForDocGenAmongChecked'),
null,
'errors');
942if ($action ==
'remove_file') {
943 require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
945 $langs->load(
"other");
946 $upload_dir = $diroutputmassaction;
947 $file = $upload_dir.
'/'.
GETPOST(
'file');
959if (!$error && $massaction ==
'validate' && $permissiontoadd) {
960 $objecttmp =
new $objectclass($db);
962 if (($objecttmp->element ==
'facture' || $objecttmp->element ==
'invoice') && isModEnabled(
'stock') &&
getDolGlobalString(
'STOCK_CALCULATE_ON_BILL')) {
963 $langs->load(
"errors");
964 setEventMessages($langs->trans(
'ErrorMassValidationNotAllowedWhenStockIncreaseOnAction'),
null,
'errors');
967 if ($objecttmp->element ==
'invoice_supplier' && isModEnabled(
'stock') &&
getDolGlobalString(
'STOCK_CALCULATE_ON_SUPPLIER_BILL')) {
968 $langs->load(
"errors");
969 setEventMessages($langs->trans(
'ErrorMassValidationNotAllowedWhenStockIncreaseOnAction'),
null,
'errors');
972 if ($objecttmp->element ==
'facture') {
975 $sql =
"SELECT rowid FROM ".MAIN_DB_PREFIX.
"facture";
976 $sql .=
" WHERE rowid IN (".$db->sanitize(implode(
",", $toselect)).
")";
977 $sql .=
" ORDER BY datef";
979 $resql = $db->query($sql);
982 while (!empty($arr = $db->fetch_row($resql))) {
983 $toselectnew[] = $arr[0];
985 $toselect = (empty($toselectnew)) ? $toselect : $toselectnew;
996 foreach ($toselect as $toselectid) {
997 $result = $objecttmp->fetch($toselectid);
999 if (method_exists($objecttmp,
'validate')) {
1000 $result = $objecttmp->validate($user);
1001 } elseif (method_exists($objecttmp,
'setValid')) {
1002 $result = $objecttmp->setValid($user);
1004 $objecttmp->error =
'No method validate or setValid on this object';
1008 $langs->load(
"errors");
1009 setEventMessages($langs->trans(
"ErrorObjectMustHaveStatusDraftToBeValidated", $objecttmp->ref),
null,
'errors');
1012 } elseif ($result < 0) {
1020 $outputlangs = $langs;
1023 $newlang =
GETPOST(
'lang_id',
'aZ09');
1025 if (
getDolGlobalInt(
'MAIN_MULTILANGS') && empty($newlang) && property_exists($objecttmp,
'thirdparty')) {
1026 if ((property_exists($objecttmp,
'socid') || property_exists($objecttmp,
'fk_soc')) && empty($objecttmp->thirdparty)) {
1027 $objecttmp->fetch_thirdparty();
1029 if (!empty($objecttmp->thirdparty)) {
1030 $newlang = $objecttmp->thirdparty->default_lang;
1033 if (!empty($newlang)) {
1034 $outputlangs =
new Translate(
"", $conf);
1035 $outputlangs->setDefaultLang($newlang);
1036 $outputlangs->load(
'products');
1038 $model = $objecttmp->model_pdf;
1039 $ret = $objecttmp->fetch($objecttmp->id);
1041 $hidedetails = !empty($hidedetails) ? $hidedetails : (
getDolGlobalString(
'MAIN_GENERATE_DOCUMENTS_HIDE_DETAILS') ? 1 : 0);
1042 $hidedesc = !empty($hidedesc) ? $hidedesc : (
getDolGlobalString(
'MAIN_GENERATE_DOCUMENTS_HIDE_DESC') ? 1 : 0);
1043 $hideref = !empty($hideref) ? $hideref : (
getDolGlobalString(
'MAIN_GENERATE_DOCUMENTS_HIDE_REF') ? 1 : 0);
1044 $moreparams = !empty($moreparams) ? $moreparams :
null;
1046 $result = $objecttmp->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref);
1064 setEventMessages($langs->trans(
"RecordModifiedSuccessfully"),
null,
'mesgs');
1074if (!$error && ($massaction ==
'delete' || ($action ==
'delete' && $confirm ==
'yes')) && $permissiontodelete) {
1077 $objecttmp =
new $objectclass($db);
1083 $unique_arr = array_unique($toselect);
1084 foreach ($unique_arr as $toselectid) {
1085 $result = $objecttmp->fetch($toselectid);
1089 $langs->load(
"errors");
1091 $TMsg[] =
'<div class="error">'.$langs->trans(
'ErrorOnlyDraftStatusCanBeDeletedInMassAction', $objecttmp->ref).
'</div><br>';
1095 if (method_exists($objecttmp,
'is_erasable') && $objecttmp->is_erasable() <= 0) {
1096 $langs->load(
"errors");
1098 $TMsg[] =
'<div class="error">'.$langs->trans(
'ErrorRecordHasChildren').
' '.$objecttmp->ref.
'</div><br>';
1103 $langs->load(
"errors");
1105 $TMsg[] =
'<div class="error">'.$langs->trans(
'ErrorLeaveRequestMustBeDraftCanceledOrRefusedToBeDeleted', $objecttmp->ref).
'</div><br>';
1109 if ($objectclass ==
"Task" && $objecttmp->hasChildren() > 0) {
1110 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"projet_task SET fk_task_parent = 0 WHERE fk_task_parent = ".((int) $objecttmp->id);
1111 $res = $db->query($sql);
1119 if ($objecttmp->element ==
'societe') {
1121 '@phan-var-force Societe $objecttmp';
1123 $result = $objecttmp->delete($objecttmp->id, $user, 1);
1125 $result = $objecttmp->delete($user);
1128 if (empty($result)) {
1129 $TMsg = array_merge($objecttmp->errors, $TMsg);
1130 } elseif ($result < 0) {
1144 if (empty($error)) {
1148 } elseif ($nbok > 0) {
1155 if (!empty($TMsg)) {
1170if (!$error && $massaction ==
'generate_doc' && $permissiontoread) {
1173@phan-var-force
'Commande'|
'CommandeFournisseur'|
'Contrat'|
'Expedition'|
'ExpenseReport'|
'Facture'|
'FactureFournisseur'|
'Fichinter'|
'Project'|
'Propal'|
'SupplierProposal' $objectclass
1178 foreach ($toselect as $toselectid) {
1179 $objecttmp =
new $objectclass($db);
1180 $result = $objecttmp->fetch($toselectid);
1182 $outputlangs = $langs;
1186 $newlang =
GETPOST(
'lang_id',
'aZ09');
1188 if (
getDolGlobalInt(
'MAIN_MULTILANGS') && empty($newlang) && isset($objecttmp->thirdparty->default_lang)) {
1189 $newlang = $objecttmp->thirdparty->default_lang;
1191 if (
getDolGlobalInt(
'MAIN_MULTILANGS') && empty($newlang) && isset($objecttmp->default_lang)) {
1192 $newlang = $objecttmp->default_lang;
1194 if (
getDolGlobalInt(
'MAIN_MULTILANGS') && empty($newlang) && empty($objecttmp->thirdparty)) {
1195 $objecttmp->fetch_thirdparty();
1196 $newlang = $objecttmp->thirdparty->default_lang;
1198 if (!empty($newlang)) {
1199 $outputlangs =
new Translate(
"", $conf);
1200 $outputlangs->setDefaultLang($newlang);
1204 if (empty($hidedetails)) {
1207 if (empty($hidedesc)) {
1210 if (empty($hideref)) {
1213 if (empty($moreparams)) {
1217 $result = $objecttmp->generateDocument($objecttmp->model_pdf, $outputlangs, $hidedetails, $hidedesc, $hideref, $moreparams);
1247if (!$error && ($action ==
'affecttag' && $confirm ==
'yes') && $permissiontoadd) {
1251 $affecttag_type =
GETPOST(
'affecttag_type',
'alpha');
1252 if (!empty($affecttag_type)) {
1253 $affecttag_type_array = explode(
',', $affecttag_type);
1257 if (!empty($affecttag_type_array)) {
1259 require_once DOL_DOCUMENT_ROOT.
'/categories/class/categorie.class.php';
1261 $to_affecttag_type_array = array();
1262 $categ_type_array = $categ->getMapList();
1263 foreach ($categ_type_array as $categdef) {
1264 if (in_array($categdef[
'code'], $affecttag_type_array)) {
1265 $to_affecttag_type_array[] = $categdef[
'code'];
1270 if (!empty($to_affecttag_type_array)) {
1271 foreach ($to_affecttag_type_array as $categ_type) {
1272 $contcats =
GETPOST(
'contcats_' . $categ_type,
'array');
1274 foreach ($toselect as $toselectid) {
1275 $result =
$object->fetch($toselectid);
1278 $result =
$object->setCategoriesCommon($contcats, $categ_type,
false);
1297 $toselect = array();
1303if (!$error && ($action ==
'updateprice' && $confirm ==
'yes') && $permissiontoadd) {
1304 '@phan-var-force Product|ProductCustomerPrice $obj';
1305 '@phan-var-force Product|ProductCustomerPrice $object';
1308 if (GETPOSTISSET(
'pricerate')) {
1310 if ($pricepercentage == 0) {
1313 foreach ($toselect as $toselectid) {
1314 $result =
$object->fetch($toselectid);
1317 if ($obj->price_base_type ==
'TTC') {
1318 $newprice =
$object->price_ttc * (100 + $pricepercentage) / 100;
1319 $minprice =
$object->price_min_ttc;
1321 $newprice =
$object->price * (100 + $pricepercentage) / 100;
1322 $minprice =
$object->price_min;
1324 $res =
$object->updatePrice($newprice, $obj->price_base_type, $user,
$object->tva_tx, $minprice, 0,
$object->tva_npr, 0, 0, array(),
$object->default_vat_code);
1344 $toselect = array();
1350if (!$error && ($action ==
'setsupervisor' && $confirm ==
'yes') && $permissiontoadd) {
1351 '@phan-var-force User $object';
1354 $supervisortoset =
GETPOSTINT(
'supervisortoset');
1355 if (!empty($supervisortoset)) {
1356 foreach ($toselect as $toselectid) {
1357 $result =
$object->fetch($toselectid);
1360 $object->fk_user = $supervisortoset;
1361 $res =
$object->update($user);
1381 $toselect = array();
1387if (!$error && ($action ==
'affectuser' && $confirm ==
'yes') && $permissiontoadd) {
1391 $usertoaffect =
GETPOST(
'usertoaffect');
1392 $projectrole =
GETPOST(
'projectrole');
1393 $tasksrole =
GETPOST(
'tasksrole');
1394 if (!empty($usertoaffect)) {
1395 foreach ($toselect as $toselectid) {
1396 $result =
$object->fetch($toselectid);
1399 $res =
$object->add_contact($usertoaffect, $projectrole,
'internal');
1401 $taskstatic =
new Task($db);
1402 $task_array = $taskstatic->getTasksArray(
null,
null,
$object->id, 0, 0);
1404 foreach ($task_array as $task) {
1405 $tasksToAffect =
new Task($db);
1406 $result = $tasksToAffect->fetch($task->id);
1408 $res = $tasksToAffect->add_contact($usertoaffect, $tasksrole,
'internal');
1432 $toselect = array();
1438if (!$error && ($massaction ==
'enable' || ($action ==
'enable' && $confirm ==
'yes')) && $permissiontoadd) {
1441 $objecttmp =
new $objectclass($db);
1443 foreach ($toselect as $toselectid) {
1444 $result = $objecttmp->fetch($toselectid);
1446 if (in_array($objecttmp->element, array(
'societe'))) {
1447 $result = $objecttmp->setStatut(1);
1475if (!$error && ($massaction ==
'disable' || ($action ==
'disable' && $confirm ==
'yes')) && $permissiontoadd) {
1478 $objecttmp =
new $objectclass($db);
1480 foreach ($toselect as $toselectid) {
1481 $result = $objecttmp->fetch($toselectid);
1483 if (in_array($objecttmp->element, array(
'societe'))) {
1484 $result = $objecttmp->setStatut(0);
1512if (!$error && $action ==
'confirm_edit_value_extrafields' && $confirm ==
'yes' && $permissiontoadd) {
1515 $objecttmp =
new $objectclass($db);
1517 $e->fetch_name_optionals_label($objecttmp->table_element);
1520 $extrafieldKeyToUpdate =
GETPOST(
'extrafield-key-to-update');
1523 foreach ($toselect as $toselectid) {
1525 $objecttmp =
new $objectclass($db);
1526 $result = $objecttmp->fetch($toselectid);
1529 $ret = $e->setOptionalsFromPost(
null, $objecttmp, $extrafieldKeyToUpdate);
1531 $objecttmp->insertExtraFields();
1555if (!$error && ($massaction ==
'affectcommercial' || ($action ==
'affectcommercial' && $confirm ==
'yes')) && $permissiontoadd) {
1558 $objecttmp =
new $objectclass($db);
1561 foreach ($toselect as $toselectid) {
1562 $result = $objecttmp->fetch($toselectid);
1564 if (in_array($objecttmp->element, array(
'societe'))) {
1565 $result = $objecttmp->setSalesRep(
GETPOST(
"commercial",
"alpha"));
1583 setEventMessages($langs->trans(
"CommercialsAffected", $nbok),
null,
'mesgs');
1593if (!$error && ($massaction ==
'unassigncommercial' || ($action ==
'unassigncommercial' && $confirm ==
'yes')) && $permissiontoadd) {
1596 $objecttmp =
new $objectclass($db);
1599 foreach ($toselect as $toselectid) {
1600 $result = $objecttmp->fetch($toselectid);
1602 if (in_array($objecttmp->element, array(
'societe'))) {
1603 $TCommercial =
GETPOST(
"commercial",
"alpha");
1604 if (is_array($TCommercial)) {
1605 foreach ($TCommercial as $commercial) {
1606 $result = $objecttmp->del_commercial($user, $commercial);
1626 setEventMessages($langs->trans(
"CommercialsDisaffected", $nbok),
null,
'mesgs');
1636if (!$error && ($massaction ==
'approveleave' || ($action ==
'approveleave' && $confirm ==
'yes')) && $permissiontoapprove) {
1639 $objecttmp =
new $objectclass($db);
1640 '@phan-var-force Holiday $objecttmp';
1642 foreach ($toselect as $toselectid) {
1643 $result = $objecttmp->fetch($toselectid);
1646 setEventMessages($langs->trans(
'StatusOfRefMustBe', $objecttmp->ref, $langs->transnoentitiesnoconv(
'Validated')),
null,
'warnings');
1649 if ($user->id == $objecttmp->fk_validator) {
1650 $objecttmp->oldcopy =
dol_clone($objecttmp, 2);
1652 $objecttmp->date_valid =
dol_now();
1653 $objecttmp->fk_user_valid = $user->id;
1655 $objecttmp->statut = $objecttmp->status;
1657 $verif = $objecttmp->approve($user);
1667 $nbopenedday =
num_open_day($objecttmp->date_debut_gmt, $objecttmp->date_fin_gmt, 0, 1, $objecttmp->halfday);
1668 $soldeActuel = $objecttmp->getCpforUser($objecttmp->fk_user, $objecttmp->fk_type);
1669 $newSolde = ($soldeActuel - $nbopenedday);
1672 $result = $objecttmp->addLogCP($user->id, $objecttmp->fk_user, $langs->transnoentitiesnoconv(
"Holidays"), $newSolde, $objecttmp->fk_type);
1679 $result = $objecttmp->updateSoldeCP($objecttmp->fk_user, $newSolde, $objecttmp->fk_type);
1688 $destinataire =
new User($db);
1689 $destinataire->fetch($objecttmp->fk_user);
1690 $emailTo = $destinataire->email;
1693 dol_syslog(
"User that request leave has no email, so we redirect directly to finished page without sending email");
1696 $expediteur =
new User($db);
1697 $expediteur->fetch($objecttmp->fk_validator);
1707 $subject = $societeName.
" - ".$langs->transnoentitiesnoconv(
"HolidaysValidated");
1710 $message = $langs->transnoentitiesnoconv(
"Hello").
" ".$destinataire->firstname.
",\n";
1713 $message .= $langs->transnoentities(
"HolidaysValidatedBody",
dol_print_date($objecttmp->date_debut,
'day'),
dol_print_date($objecttmp->date_fin,
'day')).
"\n";
1715 $message .=
"- ".$langs->transnoentitiesnoconv(
"ValidatedBy").
" : ".
dolGetFirstLastname($expediteur->firstname, $expediteur->lastname).
"\n";
1717 $message .=
"- ".$langs->transnoentitiesnoconv(
"Link").
" : ".$dolibarr_main_url_root.
"/holiday/card.php?id=".$objecttmp->id.
"\n\n";
1720 $trackid =
'leav'.$objecttmp->id;
1722 require_once DOL_DOCUMENT_ROOT.
'/core/class/CMailFile.class.php';
1723 $mail =
new CMailFile($subject, $emailTo, $emailFrom, $message, array(), array(), array(),
'',
'', 0, 0,
'',
'', $trackid);
1726 $result = $mail->sendfile();
1735 $langs->load(
"errors");
1736 setEventMessages($langs->trans(
'ErrorNotApproverForHoliday', $objecttmp->ref),
null,
'errors');
1748 } elseif ($nbok == 1) {
1757if (!$error && ($massaction ==
'increaseholiday' || ($action ==
'increaseholiday' && $confirm ==
'yes')) && $permissiontoapprove && is_array($toselect)) {
1758 '@phan-var-force Holiday $holiday';
1760 $objecttmp =
new $objectclass($db);
1762 $typeholiday =
GETPOST(
'typeholiday',
'alpha');
1765 if ($nbdaysholidays <= 0) {
1771 foreach ($toselect as $toselectid) {
1772 $balancecpuser = $objecttmp->getCPforUser($toselectid, $typeholiday);
1773 if (!empty($balancecpuser)) {
1774 $newnbdaysholidays = $nbdaysholidays + $balancecpuser;
1776 $newnbdaysholidays = $nbdaysholidays;
1778 $result = $holiday->addLogCP($user->id, $toselectid, $langs->transnoentitiesnoconv(
'ManualUpdate'), $newnbdaysholidays, $typeholiday);
1785 $objecttmp->updateSoldeCP($toselectid, $newnbdaysholidays, $typeholiday);
1798 setEventMessages($langs->trans(
"HolidayRecordsIncreased", $nbok),
null,
'mesgs');
1799 } elseif ($nbok == 1) {
1803 $toselect = array();
1810if (!$error && ($massaction ==
'clonetasks' || ($action ==
'clonetasks' && $confirm ==
'yes'))) {
1813 include_once DOL_DOCUMENT_ROOT.
'/projet/class/task.class.php';
1815 $origin_task =
new Task($db);
1816 $clone_task =
new Task($db);
1817 $newproject =
new Project($db);
1821 $iscontactofnewproject = 0;
1822 if (empty($newproject->public)) {
1823 $tmps = $newproject->getProjectsAuthorizedForUser($user, 0, 1, 0,
'(fk_statut:=:1)');
1824 $tmparray = explode(
',', $tmps);
1825 if (!in_array($newproject->id, $tmparray)) {
1826 $iscontactofnewproject = 1;
1831 $permisstiontoadd =
false;
1832 if ($user->hasRight(
'project',
'all',
'creer') || ($user->hasRight(
'project',
'creer') && ($newproject->public || $iscontactofnewproject))) {
1833 $permisstiontoadd =
true;
1836 if ($permisstiontoadd) {
1837 foreach (
GETPOST(
'selected') as $task) {
1838 $origin_task->fetch($task,
'', 0);
1843 require_once DOL_DOCUMENT_ROOT .
"/core/modules/project/task/" .
getDolGlobalString(
'PROJECT_TASK_ADDON') .
'.php';
1844 $modTask =
new $classnamemodtask();
1845 '@phan-var-force ModeleNumRefTask $modTask';
1846 $defaultref = $modTask->getNextValue(
null, $clone_task);
1850 $clone_task->fk_project =
GETPOSTINT(
'projectid');
1851 $clone_task->ref = $defaultref;
1852 $clone_task->label = $origin_task->label;
1853 $clone_task->description = $origin_task->description;
1854 $clone_task->planned_workload = $origin_task->planned_workload;
1855 $clone_task->fk_task_parent = $origin_task->fk_task_parent;
1856 $clone_task->date_c =
dol_now();
1857 $clone_task->date_start = $origin_task->date_start;
1858 $clone_task->date_end = $origin_task->date_end;
1859 $clone_task->progress = $origin_task->progress;
1862 $ret = $extrafields->setOptionalsFromPost(
null, $clone_task);
1864 $taskid = $clone_task->create($user);
1867 $result = $clone_task->add_contact(
GETPOSTINT(
"userid"),
'TASKEXECUTIVE',
'internal');
1870 if ($db->lasterrno() ==
'DB_ERROR_RECORD_ALREADY_EXISTS') {
1871 $langs->load(
"projects");
1873 $duplicate_code_error =
true;
1884 setEventMessages($langs->trans(
'NumberOfTasksCloned', $num),
null,
'mesgs');
1885 header(
"Location: ".DOL_URL_ROOT.
'/projet/tasks.php?id='.
GETPOSTINT(
'projectid'));
1893if (empty($toselect)) {
1896$parameters[
'toselect'] = &$toselect;
1897$parameters[
'uploaddir'] = $uploaddir;
1898$parameters[
'massaction'] = $massaction;
1899$parameters[
'diroutputmassaction'] = isset($diroutputmassaction) ? $diroutputmassaction :
null;
1901$reshook = $hookmanager->executeHooks(
'doMassActions', $parameters,
$object, $action);
if( $user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $object
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, $country_code='')
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)
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.
dolChmod($filepath, $newmask='')
Change mod of a file.
dol_now($mode='auto')
Return date for now.
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs=null, $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
dol_clone($object, $native=0)
Create a clone of instance of object (new instance with same value for each properties) With native =...
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.
GETPOSTFLOAT($paramname, $rounding='')
Return the value of a $_GET or $_POST supervariable, converted into float.
dol_sanitizeFileName($str, $newstr='_', $unaccent=1)
Clean a string to use it as a file name.
dol_print_error($db=null, $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
getCommonSubstitutionArray($outputlangs, $onlykey=0, $exclude=null, $object=null, $include=null)
Return array of possible common substitutions.
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
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)
Returns a hash (non reversible encryption) of a string.