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(
"Recipient")),
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) {
328 $langs->load(
"errors");
330 $resaction .=
'<div class="error">'.$langs->trans(
'ErrorOnlyProposalNotDraftCanBeSentInMassAction', $objectobj->ref).
'</div><br>';
334 $langs->load(
"errors");
336 $resaction .=
'<div class="error">'.$langs->trans(
'ErrorOnlyOrderNotDraftCanBeSentInMassAction', $objectobj->ref).
'</div><br>';
340 $langs->load(
"errors");
342 $resaction .=
'<div class="error">'.$langs->trans(
'ErrorOnlyInvoiceValidatedCanBeSentInMassAction', $objectobj->ref).
'</div><br>';
347 if (empty($sendto)) {
348 if ($objectobj->element ==
'societe') {
349 $sendto = $objectobj->email;
350 } elseif ($objectobj->element ==
'expensereport') {
351 $fuser =
new User($db);
352 $fuser->fetch($objectobj->fk_user_author);
353 $sendto = $fuser->email;
354 } elseif ($objectobj->element ==
'contact') {
356 $fcontact->fetch($objectobj->id);
357 $sendto = $fcontact->email;
358 } elseif ($objectobj->element ==
'partnership' &&
getDolGlobalString(
'PARTNERSHIP_IS_MANAGED_FOR') ==
'member') {
360 $fadherent->fetch($objectobj->fk_member);
361 $sendto = $fadherent->email;
362 } elseif ($objectobj->element ==
'holiday') {
363 $fuser =
new User($db);
364 $fuser->fetch($objectobj->fk_user);
365 $sendto = $fuser->email;
366 } elseif ($objectobj->element ==
'facture' && !empty($listofobjectcontacts[$objectid])) {
367 $emails_to_sends = array();
368 $objectobj->fetch_thirdparty();
369 $contactidtosend = array();
370 foreach ($listofobjectcontacts[$objectid] as $contactemailid => $contactemailemail) {
371 $emails_to_sends[] = $objectobj->thirdparty->contact_get_property($contactemailid,
'email');
372 if (!in_array($contactemailid, $contactidtosend)) {
373 $contactidtosend[] = $contactemailid;
376 if (count($emails_to_sends) > 0) {
377 $sendto = implode(
',', $emails_to_sends);
379 } elseif ($objectobj->element ==
'order_supplier' && !empty($listofobjectcontacts[$objectid])) {
380 $emails_to_sends = array();
381 $objectobj->fetch_thirdparty();
382 $contactidtosend = array();
383 foreach ($listofobjectcontacts[$objectid] as $contactemailid => $contactemailemail) {
384 $emails_to_sends[] = $objectobj->thirdparty->contact_get_property($contactemailid,
'email');
385 if (!in_array($contactemailid, $contactidtosend)) {
386 $contactidtosend[] = $contactemailid;
389 if (count($emails_to_sends) > 0) {
390 $sendto = implode(
',', $emails_to_sends);
392 } elseif ($objectobj->element ==
'conferenceorboothattendee') {
393 $sendto = $objectobj->email;
395 $objectobj->fetch_thirdparty();
396 $sendto = $objectobj->thirdparty->email;
400 if (empty($sendto)) {
401 if ($objectobj->element ==
'societe') {
403 $objectobj->thirdparty = $objectobj;
408 if (empty($thirdpartywithoutemail[$objectobj->thirdparty->id])) {
409 $resaction .=
'<div class="error">'.$langs->trans(
'NoRecipientEmail', $objectobj->thirdparty->name).
'</div><br>';
411 dol_syslog(
'No recipient for thirdparty: '.$objectobj->thirdparty->name, LOG_WARNING);
412 $thirdpartywithoutemail[$objectobj->thirdparty->id] = 1;
416 if (
GETPOST(
'addmaindocfile')) {
423 $filedir = $uploaddir.
'/'.$subdir.dol_sanitizeFileName($objectobj->ref);
424 $filepath = $filedir.
'/'.$filename;
427 if ($objectobj->element ==
'invoice_supplier') {
428 $fileparams =
dol_most_recent_file($uploaddir.
'/'.
get_exdir($objectobj->id, 2, 0, 0, $objectobj, $objectobj->element).$objectobj->ref, preg_quote($objectobj->ref,
'/').
'([^\-])+');
429 $filepath = $fileparams[
'fullname'];
433 $filename_found =
'';
434 $filepath_found =
'';
435 $file_check_list = array();
436 $file_check_list[] = array(
440 if (
getDolGlobalString(
'MAIL_MASS_ACTION_ADD_LAST_IF_MAIN_DOC_NOT_FOUND') && !empty($objectobj->last_main_doc)) {
441 $file_check_list[] = array(
442 'name' => basename($objectobj->last_main_doc),
443 'path' => DOL_DATA_ROOT .
'/' . $objectobj->last_main_doc,
446 foreach ($file_check_list as $file_check_arr) {
448 $filename_found = $file_check_arr[
'name'];
449 $filepath_found = $file_check_arr[
'path'];
454 if ($filepath_found) {
456 $attachedfilesThirdpartyObj[$thirdpartyid][$objectid] = array(
457 'paths' => array($filepath_found),
458 'names' => array($filename_found),
463 $langs->load(
"errors");
464 foreach ($file_check_list as $file_check_arr) {
465 $resaction .=
'<div class="error">'.$langs->trans(
'ErrorCantReadFile', $file_check_arr[
'path']).
'</div><br>';
466 dol_syslog(
'Failed to read file: '.$file_check_arr[
'path'], LOG_WARNING);
473 $listofqualifiedobj[$objectid] = $objectobj;
474 $listofqualifiedref[$objectid] = $objectobj->ref;
481 if (count($listofqualifiedobj) > 0) {
482 $langs->load(
"commercial");
485 $fromtype =
GETPOST(
'fromtype');
486 if ($fromtype ===
'user') {
487 $from =
dol_string_nospecial($user->getFullName($langs),
' ', array(
",")).
' <'.$user->email.
'>';
488 } elseif ($fromtype ===
'company') {
490 } elseif (preg_match(
'/user_aliases_(\d+)/', $fromtype, $reg)) {
491 $tmp = explode(
',', $user->email_aliases);
492 $from = trim($tmp[((
int) $reg[1] - 1)]);
493 } elseif (preg_match(
'/global_aliases_(\d+)/', $fromtype, $reg)) {
495 $from = trim($tmp[((
int) $reg[1] - 1)]);
496 } elseif (preg_match(
'/senderprofile_(\d+)_(\d+)/', $fromtype, $reg)) {
497 $sql =
"SELECT rowid, label, email FROM ".MAIN_DB_PREFIX.
"c_email_senderprofile WHERE rowid = ".(int) $reg[1];
498 $resql = $db->query($sql);
499 $obj = $db->fetch_object($resql);
508 $subject =
GETPOST(
'subject',
'restricthtml');
509 $message =
GETPOST(
'message',
'restricthtml');
511 $sendtobcc =
GETPOST(
'sendtoccc');
512 if ($objectclass ==
'Propal') {
515 if ($objectclass ==
'Commande') {
518 if ($objectclass ==
'Facture') {
521 if ($objectclass ==
'SupplierProposal') {
522 $sendtobcc .= (!
getDolGlobalString(
'MAIN_MAIL_AUTOCOPY_SUPPLIER_PROPOSAL_TO') ?
'' : (($sendtobcc ?
", " :
"") .
getDolGlobalString(
'MAIN_MAIL_AUTOCOPY_SUPPLIER_PROPOSAL_TO')));
524 if ($objectclass ==
'CommandeFournisseur') {
527 if ($objectclass ==
'FactureFournisseur') {
530 if ($objectclass ==
'Project') {
536 $looparray = array();
537 if (!$oneemailperrecipient) {
538 $looparray = $listofqualifiedobj;
539 foreach ($looparray as $key => $objecttmp) {
540 $looparray[$key]->thirdparty = $thirdparty;
543 $objectforloop =
new $objectclass($db);
544 $objectforloop->thirdparty = $thirdparty;
545 $looparray[0] = $objectforloop;
548 dol_syslog(
"We have set an array of ".count($looparray).
" emails to send. oneemailperrecipient=".$oneemailperrecipient);
550 foreach ($looparray as $objectid => $objecttmp) {
552 if (isModEnabled(
'project') && method_exists($objecttmp,
'fetchProject') && is_null($objecttmp->project)) {
553 $objecttmp->fetchProject();
555 $substitutionarray = getCommonSubstitutionArray($langs, 0,
null, $objecttmp);
556 $substitutionarray[
'__ID__'] = ($oneemailperrecipient ? implode(
', ', array_keys($listofqualifiedobj)) : $objecttmp->id);
557 $substitutionarray[
'__REF__'] = ($oneemailperrecipient ? implode(
', ', $listofqualifiedref) : $objecttmp->
ref);
558 $substitutionarray[
'__EMAIL__'] = $thirdparty->email;
559 $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"/>';
561 if ($oneemailperrecipient) {
562 $substitutionarray[
'__ONLINE_PAYMENT_URL__'] =
'';
563 $substitutionarray[
'__ONLINE_PAYMENT_TEXT_AND_URL__'] =
'';
566 $parameters = array(
'mode' =>
'formemail');
568 if (!empty($listofobjectthirdparties)) {
569 $parameters[
'listofobjectthirdparties'] = $listofobjectthirdparties;
571 if (!empty($listofobjectref)) {
572 $parameters[
'listofobjectref'] = $listofobjectref;
580 $attachedfiles = array(
'paths' => array(),
'names' => array(),
'mimes' => array());
581 if ($oneemailperrecipient) {
583 if (is_array($attachedfilesThirdpartyObj[$thirdparty->id]) && count($attachedfilesThirdpartyObj[$thirdparty->id])) {
584 foreach ($attachedfilesThirdpartyObj[$thirdparty->id] as $keyObjId => $objAttachedFiles) {
586 $attachedfiles = array(
587 'paths' => array_merge($attachedfiles[
'paths'], $objAttachedFiles[
'paths']),
588 'names' => array_merge($attachedfiles[
'names'], $objAttachedFiles[
'names']),
589 'mimes' => array_merge($attachedfiles[
'mimes'], $objAttachedFiles[
'mimes'])
593 } elseif (!empty($attachedfilesThirdpartyObj[$thirdparty->id][$objectid])) {
596 $attachedfiles = $attachedfilesThirdpartyObj[$thirdparty->id][$objectid];
599 $filepath = $attachedfiles[
'paths'];
600 $filename = $attachedfiles[
'names'];
601 $mimetype = $attachedfiles[
'mimes'];
604 if ($oneemailperrecipient) {
605 $trackid =
'thi'.$thirdparty->id;
606 if ($objecttmp->element ==
'expensereport') {
607 $trackid =
'use'.$thirdparty->id;
608 } elseif ($objecttmp->element ==
'contact') {
609 $trackid =
'ctc'.$thirdparty->id;
610 } elseif ($objecttmp->element ==
'holiday') {
611 $trackid =
'use'.$thirdparty->id;
614 $trackid = strtolower(get_class($objecttmp));
615 if (get_class($objecttmp) ==
'Contact') {
617 } elseif (get_class($objecttmp) ==
'Contrat') {
619 } elseif (get_class($objecttmp) ==
'Propal') {
621 } elseif (get_class($objecttmp) ==
'Commande') {
623 } elseif (get_class($objecttmp) ==
'Facture') {
625 } elseif (get_class($objecttmp) ==
'SupplierProposal') {
627 } elseif (get_class($objecttmp) ==
'CommandeFournisseur') {
629 } elseif (get_class($objecttmp) ==
'FactureFournisseur') {
633 $trackid .= $objecttmp->id;
639 if (empty($sendcontext)) {
640 $sendcontext =
'standard';
644 $vardir =
$conf->user->dir_output.
"/".$user->id;
645 $upload_dir_tmp = $vardir.
'/temp';
648 require_once DOL_DOCUMENT_ROOT.
'/core/class/CMailFile.class.php';
649 $mailfile =
new CMailFile($subjectreplaced, (
string) $sendto, $from, $messagereplaced, $filepath, $mimetype, $filename, $sendtocc, $sendtobcc, (
int) $deliveryreceipt, -1,
'',
'', $trackid,
'', $sendcontext,
'', $upload_dir_tmp);
650 if ($mailfile->error) {
651 $resaction .=
'<div class="error">'.$mailfile->error.
'</div>';
653 $result = $mailfile->sendfile();
655 $resaction .= $langs->trans(
'MailSuccessfulySent', $mailfile->getValidAddress($mailfile->addr_from, 2), $mailfile->getValidAddress($mailfile->addr_to, 2)).
'<br>';
660 foreach ($listofqualifiedobj as $objid2 => $objectobj2) {
661 if ((!$oneemailperrecipient) && $objid2 != $objectid) {
665 dol_syslog(
"Try to insert email event into agenda for objid=".$objid2.
" => objectobj=".get_class($objectobj2));
674 $actionmsg = $langs->transnoentities(
'MailSentByTo', $from, (
string) $sendto);
677 $actionmsg =
dol_concatdesc($actionmsg, $langs->transnoentities(
'Bcc').
": ".$sendtocc);
679 $actionmsg =
dol_concatdesc($actionmsg, $langs->transnoentities(
'MailTopic').
": ".$subjectreplaced);
680 $actionmsg =
dol_concatdesc($actionmsg, $langs->transnoentities(
'TextUsedInTheMessageBody').
":");
686 $objectobj2->sendtoid = (empty($contactidtosend) ? 0 : $contactidtosend);
687 $objectobj2->actionmsg = $actionmsg;
688 $objectobj2->actionmsg2 = $actionmsg2;
689 $objectobj2->fk_element = $objid2;
690 $objectobj2->elementtype = $objectobj2->element;
692 $objectobj2->actionmsg2 = $subjectreplaced;
695 $triggername = strtoupper(get_class($objectobj2)).
'_SENTBYMAIL';
696 if ($triggername ==
'SOCIETE_SENTBYMAIL') {
697 $triggername =
'COMPANY_SENTBYMAIL';
699 if ($triggername ==
'CONTRAT_SENTBYMAIL') {
700 $triggername =
'CONTRACT_SENTBYMAIL';
702 if ($triggername ==
'COMMANDE_SENTBYMAIL') {
703 $triggername =
'ORDER_SENTBYMAIL';
705 if ($triggername ==
'FACTURE_SENTBYMAIL') {
706 $triggername =
'BILL_SENTBYMAIL';
708 if ($triggername ==
'EXPEDITION_SENTBYMAIL') {
709 $triggername =
'SHIPPING_SENTBYMAIL';
711 if ($triggername ==
'COMMANDEFOURNISSEUR_SENTBYMAIL') {
712 $triggername =
'ORDER_SUPPLIER_SENTBYMAIL';
714 if ($triggername ==
'FACTUREFOURNISSEUR_SENTBYMAIL') {
715 $triggername =
'BILL_SUPPLIER_SENTBYMAIL';
717 if ($triggername ==
'SUPPLIERPROPOSAL_SENTBYMAIL') {
718 $triggername =
'PROPOSAL_SUPPLIER_SENTBYMAIL';
720 if ($triggername ==
'PROJET_SENTBYMAIL') {
721 $triggername =
'PROJECT_SENTBYMAIL';
724 if (!empty($triggername)) {
726 $result = $objectobj2->call_trigger($triggername, $user);
734 dol_syslog(
"Error in trigger ".$triggername.
' '.$db->lasterror(), LOG_ERR);
741 $langs->load(
"other");
742 if ($mailfile->error) {
743 $resaction .= $langs->trans(
'ErrorFailedToSendMail', $from, (
string) $sendto);
744 $resaction .=
'<br><div class="error">'.$mailfile->error.
'</div>';
746 $resaction .=
'<div class="warning">No mail sent. Feature is disabled by option MAIN_DISABLE_ALL_MAILS</div>';
748 $resaction .= $langs->trans(
'ErrorFailedToSendMail', $from, (
string) $sendto) .
'<br><div class="error">(unhandled error)</div>';
756 $resaction .= ($resaction ?
'<br>' : $resaction);
757 $resaction .=
'<strong>'.$langs->trans(
"ResultOfMailSending").
':</strong><br>'.
"\n";
758 $resaction .= $langs->trans(
"NbSelected").
': '.count($toselect).
"\n<br>";
759 $resaction .= $langs->trans(
"NbIgnored").
': '.($nbignored ? $nbignored : 0).
"\n<br>";
760 $resaction .= $langs->trans(
"NbSent").
': '.($nbsent ? $nbsent : 0).
"\n<br>";
765 setEventMessages($langs->trans(
"EMailSentForNElements", $nbsent.
'/'.count($toselect)),
null,
'mesgs');
778if (!$error && $massaction ==
'cancelorders') {
783 $orders =
GETPOST(
'toselect',
'array');
784 foreach ($orders as $id_order) {
786 if ($cmd->fetch($id_order) <= 0) {
791 $langs->load(
'errors');
792 setEventMessages($langs->trans(
"ErrorObjectMustHaveStatusValidToBeCanceled", $cmd->ref),
null,
'errors');
797 $result = $cmd->cancel();
817if (!$error && $massaction ==
"builddoc" && $permissiontoread && !
GETPOST(
'button_search')) {
818 if (empty($diroutputmassaction)) {
819 dol_print_error(
null,
'include of actions_massactions.inc.php is done but var $diroutputmassaction was not defined');
823 require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
824 require_once DOL_DOCUMENT_ROOT.
'/core/lib/pdf.lib.php';
825 require_once DOL_DOCUMENT_ROOT.
'/core/lib/date.lib.php';
827 $objecttmp =
new $objectclass($db);
828 $listofobjectid = array();
829 $listofobjectthirdparties = array();
830 $listofobjectref = array();
831 foreach ($toselect as $toselectid) {
832 $objecttmp =
new $objectclass($db);
833 $result = $objecttmp->fetch($toselectid);
835 $listofobjectid[$toselectid] = $toselectid;
836 $thirdpartyid = !empty($objecttmp->fk_soc) ? $objecttmp->fk_soc : $objecttmp->socid;
837 $listofobjectthirdparties[$thirdpartyid] = $thirdpartyid;
838 $listofobjectref[$toselectid] = $objecttmp->ref;
842 $arrayofinclusion = array();
843 foreach ($listofobjectref as $tmppdf) {
846 foreach ($listofobjectref as $tmppdf) {
847 $arrayofinclusion[] =
'^'.preg_quote(
dol_sanitizeFileName($tmppdf),
'/').
'_[a-zA-Z0-9\-\_\'\&\.]+\.pdf$';
850 $listoffiles =
dol_dir_list($uploaddir,
'all', 1, $arrayofinclusion,
'\.meta$|\.png$',
'date', SORT_DESC, 0, 1);
852 dol_syslog(
"Found ".count($listoffiles).
" files");
857 foreach ($listofobjectref as $basename) {
859 foreach ($listoffiles as $filefound) {
860 if (strstr($filefound[
"name"], $basename)) {
861 $files[] = $filefound[
'fullname'];
868 $outputlangs = $langs;
871 $newlang =
GETPOST(
'lang_id',
'aZ09');
876 if (!empty($newlang)) {
878 $outputlangs->setDefaultLang($newlang);
887 $filename = preg_replace(
'/\s/',
'_', $filename);
890 if (in_array($objecttmp->element, array(
'facture',
'invoice_supplier')) && $search_status ==
Facture::STATUS_VALIDATED) {
891 if ($option ==
'late') {
898 $filename .=
'_'.$year;
901 $filename .=
'_'.$month;
904 if (count($files) > 0) {
906 $file = $diroutputmassaction.
'/'.$filename.
'_'.
dol_print_date($now,
'dayhourlog').
'.pdf';
909 foreach ($files as $f) {
910 $input_files .=
' '.escapeshellarg($f);
913 $cmd =
'pdftk '.$input_files.
' cat output '.escapeshellarg($file);
917 if (file_exists($file)) {
920 $langs->load(
"exports");
923 setEventMessages($langs->trans(
'ErrorPDFTkOutputFileNotFound'),
null,
'errors');
926 setEventMessages($langs->trans(
'NoPDFAvailableForDocGenAmongChecked'),
null,
'errors');
931 $page_largeur = $formatarray[
'width'];
932 $page_hauteur = $formatarray[
'height'];
933 $format = array($page_largeur, $page_hauteur);
937 if (class_exists(
'TCPDF')) {
938 $pdf->setPrintHeader(
false);
939 $pdf->setPrintFooter(
false);
944 $pdf->SetCompression(
false);
949 foreach ($files as $file) {
951 $pagecount = $pdf->setSourceFile($file);
952 for ($i = 1; $i <= $pagecount; $i++) {
953 $tplidx = $pdf->importPage($i);
954 $s = $pdf->getTemplatesize($tplidx);
955 $pdf->AddPage($s[
'h'] > $s[
'w'] ?
'P' :
'L');
956 $pdf->useTemplate($tplidx);
965 $filename = preg_replace(
'/\s/',
'_', $filename);
969 if (in_array($objecttmp->element, array(
'facture',
'invoice_supplier')) && $search_status ==
Facture::STATUS_VALIDATED) {
970 if ($option ==
'late') {
977 $filename .=
'_'.$year;
979 if (!empty($month)) {
980 $filename .=
'_'.$month;
984 $file = $diroutputmassaction.
'/'.$filename.
'_'.
dol_print_date($now,
'dayhourlog').
'.pdf';
985 $pdf->Output($file,
'F');
988 $langs->load(
"exports");
991 setEventMessages($langs->trans(
'NoPDFAvailableForDocGenAmongChecked'),
null,
'errors');
997if ($action ==
'remove_file') {
998 require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
1000 $langs->load(
"other");
1001 $upload_dir = $diroutputmassaction;
1002 $file = $upload_dir.
'/'.
GETPOST(
'file');
1014if (!$error && $massaction ==
'validate' && $permissiontoadd) {
1015 $objecttmp =
new $objectclass($db);
1017 if (($objecttmp->element ==
'facture' || $objecttmp->element ==
'invoice') && isModEnabled(
'stock') &&
getDolGlobalString(
'STOCK_CALCULATE_ON_BILL')) {
1018 $langs->load(
"errors");
1019 setEventMessages($langs->trans(
'ErrorMassValidationNotAllowedWhenStockIncreaseOnAction'),
null,
'errors');
1022 if ($objecttmp->element ==
'invoice_supplier' && isModEnabled(
'stock') &&
getDolGlobalString(
'STOCK_CALCULATE_ON_SUPPLIER_BILL')) {
1023 $langs->load(
"errors");
1024 setEventMessages($langs->trans(
'ErrorMassValidationNotAllowedWhenStockIncreaseOnAction'),
null,
'errors');
1027 if ($objecttmp->element ==
'facture') {
1030 $sql =
"SELECT rowid FROM ".MAIN_DB_PREFIX.
"facture";
1031 $sql .=
" WHERE rowid IN (".$db->sanitize(implode(
",", $toselect)).
")";
1032 $sql .=
" ORDER BY datef";
1034 $resql = $db->query($sql);
1037 while (!empty($arr = $db->fetch_row($resql))) {
1038 $toselectnew[] = $arr[0];
1040 $toselect = (empty($toselectnew)) ? $toselect : $toselectnew;
1051 foreach ($toselect as $toselectid) {
1052 $result = $objecttmp->fetch($toselectid);
1054 if (method_exists($objecttmp,
'validate')) {
1055 $result = $objecttmp->validate($user);
1056 } elseif (method_exists($objecttmp,
'setValid')) {
1057 $result = $objecttmp->setValid($user);
1059 $objecttmp->error =
'No method validate or setValid on this object';
1063 $langs->load(
"errors");
1064 setEventMessages($langs->trans(
"ErrorObjectMustHaveStatusDraftToBeValidated", $objecttmp->ref),
null,
'errors');
1067 } elseif ($result < 0) {
1075 $outputlangs = $langs;
1078 $newlang =
GETPOST(
'lang_id',
'aZ09');
1080 if (
getDolGlobalInt(
'MAIN_MULTILANGS') && empty($newlang) && property_exists($objecttmp,
'thirdparty')) {
1081 if ((property_exists($objecttmp,
'socid') || property_exists($objecttmp,
'fk_soc')) && empty($objecttmp->thirdparty)) {
1082 $objecttmp->fetch_thirdparty();
1084 if (!empty($objecttmp->thirdparty)) {
1085 $newlang = $objecttmp->thirdparty->default_lang;
1088 if (!empty($newlang)) {
1090 $outputlangs->setDefaultLang($newlang);
1091 $outputlangs->load(
'products');
1093 $model = $objecttmp->model_pdf;
1094 $ret = $objecttmp->fetch($objecttmp->id);
1097 $hidedetails = isset($hidedetails) ? $hidedetails : (
getDolGlobalString(
'MAIN_GENERATE_DOCUMENTS_HIDE_DETAILS') ? 1 : 0);
1098 $hidedesc = isset($hidedesc) ? $hidedesc : (
getDolGlobalString(
'MAIN_GENERATE_DOCUMENTS_HIDE_DESC') ? 1 : 0);
1099 $hideref = isset($hideref) ? $hideref : (
getDolGlobalString(
'MAIN_GENERATE_DOCUMENTS_HIDE_REF') ? 1 : 0);
1100 $moreparams = isset($moreparams) ? $moreparams :
null;
1102 $result = $objecttmp->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref, $moreparams);
1120 setEventMessages($langs->trans(
"RecordModifiedSuccessfully"),
null,
'mesgs');
1130if (!$error && ($massaction ==
'delete' || ($action ==
'delete' && $confirm ==
'yes')) && $permissiontodelete) {
1133 $objecttmp =
new $objectclass($db);
1139 $unique_arr = array_unique($toselect);
1140 foreach ($unique_arr as $toselectid) {
1141 $result = $objecttmp->fetch($toselectid);
1145 $langs->load(
"errors");
1147 $TMsg[] =
'<div class="error">'.$langs->trans(
'ErrorOnlyDraftStatusCanBeDeletedInMassAction', $objecttmp->ref).
'</div><br>';
1151 if (method_exists($objecttmp,
'is_erasable') && $objecttmp->is_erasable() <= 0) {
1152 $langs->load(
"errors");
1154 $TMsg[] =
'<div class="error">'.$langs->trans(
'ErrorRecordHasChildren').
' '.$objecttmp->ref.
'</div><br>';
1159 $langs->load(
"errors");
1161 $TMsg[] =
'<div class="error">'.$langs->trans(
'ErrorLeaveRequestMustBeDraftCanceledOrRefusedToBeDeleted', $objecttmp->ref).
'</div><br>';
1165 if ($objectclass ==
"Task" && $objecttmp->hasChildren() > 0) {
1166 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"projet_task SET fk_task_parent = 0 WHERE fk_task_parent = ".((int) $objecttmp->id);
1167 $res = $db->query($sql);
1175 if ($objecttmp->element ==
'societe') {
1177 '@phan-var-force Societe $objecttmp';
1179 $result = $objecttmp->delete($objecttmp->id, $user, 1);
1181 $result = $objecttmp->delete($user);
1184 if (empty($result)) {
1185 $TMsg = array_merge($objecttmp->errors, $TMsg);
1186 } elseif ($result < 0) {
1200 if (empty($error)) {
1204 } elseif ($nbok > 0) {
1211 if (!empty($TMsg)) {
1226if (!$error && $massaction ==
'generate_doc' && $permissiontoread) {
1229@phan-var-force
'Commande'|
'CommandeFournisseur'|
'Contrat'|
'Expedition'|
'ExpenseReport'|
'Facture'|
'FactureFournisseur'|
'Fichinter'|
'Project'|
'Propal'|
'SupplierProposal' $objectclass
1235 $objecttmp =
new $objectclass($db);
1237 foreach ($toselect as $toselectid) {
1238 $objecttmp->thirdparty =
null;
1239 $result = $objecttmp->fetch($toselectid);
1242 $outputlangs = $langs;
1246 $newlang =
GETPOST(
'lang_id',
'aZ09');
1248 if (
getDolGlobalInt(
'MAIN_MULTILANGS') && empty($newlang) && isset($objecttmp->thirdparty->default_lang)) {
1249 $newlang = $objecttmp->thirdparty->default_lang;
1251 if (
getDolGlobalInt(
'MAIN_MULTILANGS') && empty($newlang) && isset($objecttmp->default_lang)) {
1252 $newlang = $objecttmp->default_lang;
1254 if (
getDolGlobalInt(
'MAIN_MULTILANGS') && empty($newlang) && empty($objecttmp->thirdparty)) {
1255 $objecttmp->fetch_thirdparty();
1256 $newlang = $objecttmp->thirdparty->default_lang;
1258 if (!empty($newlang)) {
1260 $outputlangs->setDefaultLang($newlang);
1264 $hidedetails = isset($hidedetails) ? $hidedetails : (
getDolGlobalString(
'MAIN_GENERATE_DOCUMENTS_HIDE_DETAILS') ? 1 : 0);
1265 $hidedesc = isset($hidedesc) ? $hidedesc : (
getDolGlobalString(
'MAIN_GENERATE_DOCUMENTS_HIDE_DESC') ? 1 : 0);
1266 $hideref = isset($hideref) ? $hideref : (
getDolGlobalString(
'MAIN_GENERATE_DOCUMENTS_HIDE_REF') ? 1 : 0);
1267 $moreparams = isset($moreparams) ? $moreparams :
null;
1269 $result = $objecttmp->generateDocument($objecttmp->model_pdf, $outputlangs, $hidedetails, $hidedesc, $hideref, $moreparams);
1297if (!$error && ($action ==
'affecttag' && $confirm ==
'yes') && $permissiontoadd) {
1301 $affecttag_type =
GETPOST(
'affecttag_type',
'alpha');
1302 if (!empty($affecttag_type)) {
1303 $affecttag_type_array = explode(
',', $affecttag_type);
1307 if (!empty($affecttag_type_array)) {
1309 require_once DOL_DOCUMENT_ROOT.
'/categories/class/categorie.class.php';
1311 $to_affecttag_type_array = array();
1312 $categ_type_array = $categ->getMapList();
1313 foreach ($categ_type_array as $categdef) {
1314 if (in_array($categdef[
'code'], $affecttag_type_array)) {
1315 $to_affecttag_type_array[] = $categdef[
'code'];
1320 if (!empty($to_affecttag_type_array)) {
1321 foreach ($to_affecttag_type_array as $categ_type) {
1322 $contcats =
GETPOST(
'contcats_' . $categ_type,
'array');
1324 foreach ($toselect as $toselectid) {
1325 $result =
$object->fetch($toselectid);
1328 $result =
$object->setCategoriesCommon($contcats, $categ_type,
false);
1347 $toselect = array();
1353if (!$error && ($action ==
'updateprice' && $confirm ==
'yes') && $permissiontoadd) {
1354 '@phan-var-force Product|ProductCustomerPrice $obj';
1355 '@phan-var-force Product|ProductCustomerPrice $object';
1358 if (GETPOSTISSET(
'pricerate')) {
1360 if ($pricepercentage == 0) {
1363 foreach ($toselect as $toselectid) {
1364 $result =
$object->fetch($toselectid);
1369 if (
$object->price_base_type ==
'TTC') {
1370 $newprice =
$object->price_ttc * (100 + $pricepercentage) / 100;
1371 $minprice =
$object->price_min_ttc;
1373 $newprice =
$object->price * (100 + $pricepercentage) / 100;
1374 $minprice =
$object->price_min;
1376 $res =
$object->updatePrice($newprice,
$object->price_base_type, $user,
$object->tva_tx, $minprice, 0,
$object->tva_npr, 0, 0, array(),
$object->default_vat_code);
1384 for ($level = 1; $level <= $maxlevel; $level++) {
1385 if (
$object->price_base_type ==
'TTC') {
1386 $newprice =
$object->multiprices_ttc[$level] * (100 + $pricepercentage) / 100;
1387 $minprice =
$object->multiprices_min_ttc[$level];
1389 $newprice =
$object->multiprices[$level] * (100 + $pricepercentage) / 100;
1390 $minprice =
$object->multiprices_min[$level];
1392 $res =
$object->updatePrice($newprice,
$object->price_base_type, $user,
$object->tva_tx, $minprice, $level,
$object->tva_npr, 0, 0, array(),
$object->default_vat_code);
1412 $toselect = array();
1418if (!$error && ($action ==
'setsupervisor' && $confirm ==
'yes') && $permissiontoadd) {
1419 '@phan-var-force User $object';
1422 $supervisortoset =
GETPOSTINT(
'supervisortoset');
1423 if (!empty($supervisortoset)) {
1424 foreach ($toselect as $toselectid) {
1425 $result =
$object->fetch($toselectid);
1428 $object->fk_user = $supervisortoset;
1429 $res =
$object->update($user);
1449 $toselect = array();
1455if (!$error && ($action ==
'affectuser' && $confirm ==
'yes') && $permissiontoadd) {
1460 $projectrole =
GETPOST(
'projectrole');
1461 $tasksrole =
GETPOST(
'tasksrole');
1462 if (!empty($usertoaffect)) {
1463 foreach ($toselect as $toselectid) {
1464 $result =
$object->fetch($toselectid);
1467 $res =
$object->add_contact($usertoaffect, $projectrole,
'internal');
1469 $taskstatic =
new Task($db);
1470 $task_array = $taskstatic->getTasksArray(
null,
null,
$object->id, 0, 0);
1472 foreach ($task_array as $task) {
1473 $tasksToAffect =
new Task($db);
1474 $result = $tasksToAffect->fetch($task->id);
1476 $res = $tasksToAffect->add_contact($usertoaffect, $tasksrole,
'internal');
1500 $toselect = array();
1506if (!$error && ($massaction ==
'enable' || ($action ==
'enable' && $confirm ==
'yes')) && $permissiontoadd) {
1509 $objecttmp =
new $objectclass($db);
1511 foreach ($toselect as $toselectid) {
1512 $result = $objecttmp->fetch($toselectid);
1514 if (in_array($objecttmp->element, array(
'societe'))) {
1515 $result = $objecttmp->setStatut(1);
1543if (!$error && ($massaction ==
'disable' || ($action ==
'disable' && $confirm ==
'yes')) && $permissiontoadd) {
1546 $objecttmp =
new $objectclass($db);
1548 foreach ($toselect as $toselectid) {
1549 $result = $objecttmp->fetch($toselectid);
1551 if (in_array($objecttmp->element, array(
'societe'))) {
1552 $result = $objecttmp->setStatut(0);
1580if (!$error && $action ==
'confirm_edit_value_extrafields' && $confirm ==
'yes' && $permissiontoadd) {
1583 $objecttmp =
new $objectclass($db);
1585 $e->fetch_name_optionals_label($objecttmp->table_element);
1588 $extrafieldKeyToUpdate =
GETPOST(
'extrafield-key-to-update');
1591 foreach ($toselect as $toselectid) {
1593 $objecttmp =
new $objectclass($db);
1594 $result = $objecttmp->fetch($toselectid);
1597 $ret = $e->setOptionalsFromPost(
null, $objecttmp, $extrafieldKeyToUpdate);
1599 $objecttmp->insertExtraFields();
1623if (!$error && ($massaction ==
'assignsalerepresentative' || ($action ==
'assignsalerepresentative' && $confirm ==
'yes')) && $permissiontoadd) {
1626 $objecttmp =
new $objectclass($db);
1629 foreach ($toselect as $toselectid) {
1630 $result = $objecttmp->fetch($toselectid);
1632 if (in_array($objecttmp->element, array(
'societe'))) {
1633 $result = $objecttmp->setSalesRep(
GETPOST(
"commercial",
"alpha"));
1651 setEventMessages($langs->trans(
"CommercialsAffected", $nbok),
null,
'mesgs');
1661if (!$error && ($massaction ==
'unassigncommercial' || ($action ==
'unassigncommercial' && $confirm ==
'yes')) && $permissiontoadd) {
1664 $objecttmp =
new $objectclass($db);
1667 foreach ($toselect as $toselectid) {
1668 $result = $objecttmp->fetch($toselectid);
1670 if (in_array($objecttmp->element, array(
'societe'))) {
1671 $TCommercial =
GETPOST(
"commercial",
"alpha");
1672 if (is_array($TCommercial)) {
1673 foreach ($TCommercial as $commercial) {
1674 $result = $objecttmp->del_commercial($user, $commercial);
1694 setEventMessages($langs->trans(
"CommercialsDisaffected", $nbok),
null,
'mesgs');
1704if (!$error && ($massaction ==
'approveleave' || ($action ==
'approveleave' && $confirm ==
'yes')) && $permissiontoapprove) {
1707 $objecttmp =
new $objectclass($db);
1708 '@phan-var-force Holiday $objecttmp';
1710 foreach ($toselect as $toselectid) {
1711 $result = $objecttmp->fetch($toselectid);
1714 setEventMessages($langs->trans(
'StatusOfRefMustBe', $objecttmp->ref, $langs->transnoentitiesnoconv(
'Validated')),
null,
'warnings');
1717 if ($user->id == $objecttmp->fk_validator) {
1718 $objecttmp->oldcopy =
dol_clone($objecttmp, 2);
1720 $objecttmp->date_valid =
dol_now();
1721 $objecttmp->fk_user_valid = $user->id;
1722 $objecttmp->date_approval =
dol_now();
1723 $objecttmp->fk_user_approve = $user->id;
1725 $objecttmp->statut = $objecttmp->status;
1727 $verif = $objecttmp->approve($user);
1737 $nbopenedday =
num_open_day($objecttmp->date_debut_gmt, $objecttmp->date_fin_gmt, 0, 1, $objecttmp->halfday);
1738 $soldeActuel = $objecttmp->getCpforUser($objecttmp->fk_user, $objecttmp->fk_type);
1739 $newSolde = ($soldeActuel - $nbopenedday);
1742 $result = $objecttmp->addLogCP($user->id, $objecttmp->fk_user, $langs->transnoentitiesnoconv(
"Holidays"), $newSolde, $objecttmp->fk_type);
1749 $result = $objecttmp->updateSoldeCP($objecttmp->fk_user, $newSolde, $objecttmp->fk_type);
1758 $destinataire =
new User($db);
1759 $destinataire->fetch($objecttmp->fk_user);
1760 $emailTo = $destinataire->email;
1763 dol_syslog(
"User that request leave has no email, so we redirect directly to finished page without sending email");
1766 $expediteur =
new User($db);
1767 $expediteur->fetch($objecttmp->fk_validator);
1777 $subject = $societeName.
" - ".$langs->transnoentitiesnoconv(
"HolidaysValidated");
1780 $message = $langs->transnoentitiesnoconv(
"Hello").
" ".$destinataire->firstname.
",\n";
1783 $message .= $langs->transnoentities(
"HolidaysValidatedBody",
dol_print_date($objecttmp->date_debut,
'day'),
dol_print_date($objecttmp->date_fin,
'day')).
"\n";
1785 $message .=
"- ".$langs->transnoentitiesnoconv(
"ValidatedBy").
" : ".
dolGetFirstLastname($expediteur->firstname, $expediteur->lastname).
"\n";
1787 $message .=
"- ".$langs->transnoentitiesnoconv(
"Link").
" : ".
$dolibarr_main_url_root.
"/holiday/card.php?id=".$objecttmp->id.
"\n\n";
1790 $trackid =
'leav'.$objecttmp->id;
1792 require_once DOL_DOCUMENT_ROOT.
'/core/class/CMailFile.class.php';
1793 $mail =
new CMailFile($subject, $emailTo, $emailFrom, $message, array(), array(), array(),
'',
'', 0, 0,
'',
'', $trackid);
1796 $result = $mail->sendfile();
1805 $langs->load(
"errors");
1806 setEventMessages($langs->trans(
'ErrorNotApproverForHoliday', $objecttmp->ref),
null,
'errors');
1818 } elseif ($nbok == 1) {
1827if (!$error && ($massaction ==
'increaseholiday' || ($action ==
'increaseholiday' && $confirm ==
'yes')) && $permissiontoapprove && is_array($toselect)) {
1828 '@phan-var-force Holiday $holiday';
1830 $objecttmp =
new $objectclass($db);
1835 if ($nbdaysholidays <= 0) {
1841 foreach ($toselect as $toselectid) {
1842 $balancecpuser = $objecttmp->getCPforUser($toselectid, $typeholiday);
1843 if (!empty($balancecpuser)) {
1844 $newnbdaysholidays = $nbdaysholidays + $balancecpuser;
1846 $newnbdaysholidays = $nbdaysholidays;
1848 $result = $holiday->addLogCP($user->id, $toselectid, $langs->transnoentitiesnoconv(
'ManualUpdate'), $newnbdaysholidays, $typeholiday);
1855 $objecttmp->updateSoldeCP($toselectid, $newnbdaysholidays, $typeholiday);
1868 setEventMessages($langs->trans(
"HolidayRecordsIncreased", $nbok),
null,
'mesgs');
1869 } elseif ($nbok == 1) {
1873 $toselect = array();
1880if (!$error && ($massaction ==
'clonetasks' || ($action ==
'clonetasks' && $confirm ==
'yes'))) {
1883 include_once DOL_DOCUMENT_ROOT.
'/projet/class/task.class.php';
1885 $origin_task =
new Task($db);
1886 $clone_task =
new Task($db);
1887 $newproject =
new Project($db);
1891 $iscontactofnewproject = 0;
1892 if (empty($newproject->public)) {
1893 $tmps = $newproject->getProjectsAuthorizedForUser($user, 0, 1, 0,
'(fk_statut:=:1)');
1894 $tmparray = explode(
',', $tmps);
1895 if (!in_array($newproject->id, $tmparray)) {
1896 $iscontactofnewproject = 1;
1901 $permisstiontoadd =
false;
1902 if ($user->hasRight(
'project',
'all',
'creer') || ($user->hasRight(
'project',
'creer') && ($newproject->public || $iscontactofnewproject))) {
1903 $permisstiontoadd =
true;
1906 if ($permisstiontoadd) {
1907 foreach (
GETPOST(
'selected') as $task) {
1908 $origin_task->fetch($task,
'', 0);
1913 require_once DOL_DOCUMENT_ROOT .
"/core/modules/project/task/" .
getDolGlobalString(
'PROJECT_TASK_ADDON') .
'.php';
1914 $modTask =
new $classnamemodtask();
1915 '@phan-var-force ModeleNumRefTask $modTask';
1916 $defaultref = $modTask->getNextValue(
null, $clone_task);
1920 $clone_task->fk_project =
GETPOSTINT(
'projectid');
1921 $clone_task->ref = $defaultref;
1922 $clone_task->label = $origin_task->label;
1923 $clone_task->description = $origin_task->description;
1924 $clone_task->planned_workload = $origin_task->planned_workload;
1925 $clone_task->fk_task_parent = $origin_task->fk_task_parent;
1926 $clone_task->date_c =
dol_now();
1927 $clone_task->date_start = $origin_task->date_start;
1928 $clone_task->date_end = $origin_task->date_end;
1929 $clone_task->progress = $origin_task->progress;
1932 $ret = $extrafields->setOptionalsFromPost(
null, $clone_task);
1934 $taskid = $clone_task->create($user);
1937 $result = $clone_task->add_contact(
GETPOSTINT(
"userid"),
'TASKEXECUTIVE',
'internal');
1940 if ($db->lasterrno() ==
'DB_ERROR_RECORD_ALREADY_EXISTS') {
1941 $langs->load(
"projects");
1943 $duplicate_code_error =
true;
1954 setEventMessages($langs->trans(
'NumberOfTasksCloned', $num),
null,
'mesgs');
1955 header(
"Location: ".DOL_URL_ROOT.
'/projet/tasks.php?id='.
GETPOSTINT(
'projectid'));
1963if (empty($toselect)) {
1966$parameters[
'toselect'] = &$toselect;
1967$parameters[
'uploaddir'] = $uploaddir;
1968$parameters[
'massaction'] = $massaction;
1969$parameters[
'diroutputmassaction'] = isset($diroutputmassaction) ? $diroutputmassaction :
null;
1972$reshook = $hookmanager->executeHooks(
'doMassActions', $parameters,
$object, $action);
if( $user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $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, $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).
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_clone($object, $native=2)
Create a clone of instance of object (new instance with same value for each properties) With native =...
dol_print_error($db=null, $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
dol_sanitizeFileName($str, $newstr='_', $unaccent=1, $includequotes=0)
Clean a string to use it as a file name.
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)
global $conf
The following vars must be defined: $type2label $form $conf, $lang, The following vars may also be de...
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.