41if (empty($objectclass) || empty($uploaddir)) {
42 dol_print_error(
null,
'include of actions_massactions.inc.php is done but var $objectclass or $uploaddir was not defined');
45if (empty($massaction)) {
51if (!empty($permtoread) && empty($permissiontoread)) {
52 $permissiontoread = $permtoread;
54if (!empty($permtocreate) && empty($permissiontoadd)) {
55 $permissiontoadd = $permtocreate;
57if (!empty($permtodelete) && empty($permissiontodelete)) {
58 $permissiontodelete = $permtodelete;
62$maxformassaction = (!
getDolGlobalString(
'MAIN_LIMIT_FOR_MASS_ACTIONS') ? 1000 : $conf->global->MAIN_LIMIT_FOR_MASS_ACTIONS);
63if ($massaction && is_array($toselect) && count($toselect) < 1) {
67if (!$error && isset($toselect) && is_array($toselect) && count($toselect) > $maxformassaction) {
68 setEventMessages($langs->trans(
'TooManyRecordForMassAction', $maxformassaction),
null,
'errors');
72if (!$error && $massaction ==
'confirm_presend' && !
GETPOST(
'sendmail')) {
73 $massaction =
'presend';
75if (!$error && $massaction ==
'confirm_presend') {
79 $langs->load(
"mails");
80 include_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
81 include_once DOL_DOCUMENT_ROOT.
'/core/lib/signature.lib.php';
83 $listofobjectid = array();
84 $listofobjectthirdparties = array();
85 $listofobjectcontacts = array();
86 $listofobjectref = array();
87 $contactidtosend = array();
88 $attachedfilesThirdpartyObj = array();
89 $oneemailperrecipient = (
GETPOST(
'oneemailperrecipient',
'int') ? 1 : 0);
92 $objecttmp =
new $objectclass($db);
96 if ($objecttmp->element ==
'expensereport') {
97 $thirdparty =
new User($db);
98 } elseif ($objecttmp->element ==
'contact') {
100 } elseif ($objecttmp->element ==
'partnership' &&
getDolGlobalString(
'PARTNERSHIP_IS_MANAGED_FOR') ==
'member') {
102 } elseif ($objecttmp->element ==
'holiday') {
103 $thirdparty =
new User($db);
104 } elseif ($objecttmp->element ==
'conferenceorboothattendee') {
108 foreach ($toselect as $toselectid) {
109 $objecttmp =
new $objectclass($db);
110 $result = $objecttmp->fetch($toselectid);
112 $listofobjectid[$toselectid] = $toselectid;
113 $tmpobjectid = ($objecttmp->fk_soc ? $objecttmp->fk_soc : $objecttmp->socid);
114 if ($objecttmp->element ==
'societe') {
115 $tmpobjectid = $objecttmp->id;
116 } elseif ($objecttmp->element ==
'contact') {
117 $tmpobjectid = $objecttmp->id;
118 } elseif ($objecttmp->element ==
'expensereport') {
119 $tmpobjectid = $objecttmp->fk_user_author;
120 } elseif ($objecttmp->element ==
'partnership' &&
getDolGlobalString(
'PARTNERSHIP_IS_MANAGED_FOR') ==
'member') {
121 $tmpobjectid = $objecttmp->fk_member;
122 } elseif ($objecttmp->element ==
'holiday') {
123 $tmpobjectid = $objecttmp->fk_user;
124 } elseif ($objecttmp->element ==
'conferenceorboothattendee') {
125 $tmpobjectid = $objecttmp->id;
127 if (empty($tmpobjectid)) {
131 if ($objectclass ==
'Facture') {
132 $tmparraycontact = array();
133 $tmparraycontact = $objecttmp->liste_contact(-1,
'external', 0,
'BILLING');
134 if (is_array($tmparraycontact) && count($tmparraycontact) > 0) {
135 foreach ($tmparraycontact as $data_email) {
136 $listofobjectcontacts[$toselectid][$data_email[
'id']] = $data_email[
'email'];
139 } elseif ($objectclass ==
'CommandeFournisseur') {
140 $tmparraycontact = array();
141 $tmparraycontact = $objecttmp->liste_contact(-1,
'external', 0,
'CUSTOMER');
142 if (is_array($tmparraycontact) && count($tmparraycontact) > 0) {
143 foreach ($tmparraycontact as $data_email) {
144 $listofobjectcontacts[$toselectid][$data_email[
'id']] = $data_email[
'email'];
149 $listofobjectthirdparties[$tmpobjectid] = $tmpobjectid;
150 $listofobjectref[$tmpobjectid][$toselectid] = $objecttmp;
156 if (
GETPOST(
'fromtype',
'alpha') ===
'user' && empty($user->email)) {
159 $massaction =
'presend';
162 $receiver =
GETPOST(
'receiver',
'alphawithlgt');
163 if (!is_array($receiver)) {
164 if (empty($receiver) || $receiver ==
'-1') {
167 $receiver = array($receiver);
170 if (!trim($_POST[
'sendto']) && count($receiver) == 0 && count($listofobjectthirdparties) == 1) {
172 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Recipient")),
null,
'warnings');
173 $massaction =
'presend';
176 if (!
GETPOST(
'subject',
'restricthtml')) {
178 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"MailTopic")),
null,
'warnings');
179 $massaction =
'presend';
184 foreach ($listofobjectthirdparties as $thirdpartyid) {
185 $result = $thirdparty->fetch($thirdpartyid);
198 if (trim($_POST[
'sendto'])) {
200 $tmparray[] = trim(
GETPOST(
'sendto',
'alphawithlgt'));
202 if (count($receiver) > 0) {
203 foreach ($receiver as $key => $val) {
205 if ($val ==
'thirdparty') {
206 $tmparray[] = $thirdparty->name.
' <'.$thirdparty->email.
'>';
207 } elseif ($val && method_exists($thirdparty,
'contact_get_property')) {
208 $tmparray[] = $thirdparty->contact_get_property((
int) $val,
'email');
213 $sendto = implode(
',', $tmparray);
216 $receivercc =
GETPOST(
'receivercc',
'alphawithlgt');
217 if (!is_array($receivercc)) {
218 if ($receivercc ==
'-1') {
219 $receivercc = array();
221 $receivercc = array($receivercc);
225 if (trim($_POST[
'sendtocc'])) {
226 $tmparray[] = trim(
GETPOST(
'sendtocc',
'alphawithlgt'));
228 if (count($receivercc) > 0) {
229 foreach ($receivercc as $key => $val) {
231 if ($val ==
'thirdparty') {
232 $tmparray[] = $thirdparty->name.
' <'.$thirdparty->email.
'>';
234 $tmparray[] = $thirdparty->contact_get_property((
int) $val,
'email');
239 $sendtocc = implode(
',', $tmparray);
242 $listofqualifiedobj = array();
243 $listofqualifiedref = array();
244 $thirdpartywithoutemail = array();
246 foreach ($listofobjectref[$thirdpartyid] as $objectid => $objectobj) {
249 $langs->load(
"errors");
251 $resaction .=
'<div class="error">'.$langs->trans(
'ErrorOnlyProposalNotDraftCanBeSentInMassAction', $objectobj->ref).
'</div><br>';
255 $langs->load(
"errors");
257 $resaction .=
'<div class="error">'.$langs->trans(
'ErrorOnlyOrderNotDraftCanBeSentInMassAction', $objectobj->ref).
'</div><br>';
261 $langs->load(
"errors");
263 $resaction .=
'<div class="error">'.$langs->trans(
'ErrorOnlyInvoiceValidatedCanBeSentInMassAction', $objectobj->ref).
'</div><br>';
268 if (empty($sendto)) {
269 if ($objectobj->element ==
'societe') {
270 $sendto = $objectobj->email;
271 } elseif ($objectobj->element ==
'expensereport') {
272 $fuser =
new User($db);
273 $fuser->fetch($objectobj->fk_user_author);
274 $sendto = $fuser->email;
275 } elseif ($objectobj->element ==
'contact') {
277 $fcontact->fetch($objectobj->id);
278 $sendto = $fcontact->email;
279 } elseif ($objectobj->element ==
'partnership' &&
getDolGlobalString(
'PARTNERSHIP_IS_MANAGED_FOR') ==
'member') {
281 $fadherent->fetch($objectobj->fk_member);
282 $sendto = $fadherent->email;
283 } elseif ($objectobj->element ==
'holiday') {
284 $fuser =
new User($db);
285 $fuser->fetch($objectobj->fk_user);
286 $sendto = $fuser->email;
287 } elseif ($objectobj->element ==
'facture' && !empty($listofobjectcontacts[$objectid])) {
288 $emails_to_sends = array();
289 $objectobj->fetch_thirdparty();
290 $contactidtosend = array();
291 foreach ($listofobjectcontacts[$objectid] as $contactemailid => $contactemailemail) {
292 $emails_to_sends[] = $objectobj->thirdparty->contact_get_property($contactemailid,
'email');
293 if (!in_array($contactemailid, $contactidtosend)) {
294 $contactidtosend[] = $contactemailid;
297 if (count($emails_to_sends) > 0) {
298 $sendto = implode(
',', $emails_to_sends);
300 } elseif ($objectobj->element ==
'order_supplier' && !empty($listofobjectcontacts[$objectid])) {
301 $emails_to_sends = array();
302 $objectobj->fetch_thirdparty();
303 $contactidtosend = array();
304 foreach ($listofobjectcontacts[$objectid] as $contactemailid => $contactemailemail) {
305 $emails_to_sends[] = $objectobj->thirdparty->contact_get_property($contactemailid,
'email');
306 if (!in_array($contactemailid, $contactidtosend)) {
307 $contactidtosend[] = $contactemailid;
310 if (count($emails_to_sends) > 0) {
311 $sendto = implode(
',', $emails_to_sends);
313 } elseif ($objectobj->element ==
'conferenceorboothattendee') {
314 $sendto = $objectobj->email;
316 $objectobj->fetch_thirdparty();
317 $sendto = $objectobj->thirdparty->email;
321 if (empty($sendto)) {
322 if ($objectobj->element ==
'societe') {
323 $objectobj->thirdparty = $objectobj;
328 if (empty($thirdpartywithoutemail[$objectobj->thirdparty->id])) {
329 $resaction .=
'<div class="error">'.$langs->trans(
'NoRecipientEmail', $objectobj->thirdparty->name).
'</div><br>';
331 dol_syslog(
'No recipient for thirdparty: '.$objectobj->thirdparty->name, LOG_WARNING);
332 $thirdpartywithoutemail[$objectobj->thirdparty->id] = 1;
336 if (
GETPOST(
'addmaindocfile')) {
343 $filedir = $uploaddir.
'/'.$subdir.dol_sanitizeFileName($objectobj->ref);
344 $filepath = $filedir.
'/'.$filename;
347 if ($objectobj->element ==
'invoice_supplier') {
348 $fileparams =
dol_most_recent_file($uploaddir.
'/'.
get_exdir($objectobj->id, 2, 0, 0, $objectobj, $objectobj->element).$objectobj->ref, preg_quote($objectobj->ref,
'/').
'([^\-])+');
349 $filepath = $fileparams[
'fullname'];
353 $filename_found =
'';
354 $filepath_found =
'';
355 $file_check_list = array();
356 $file_check_list[] = array(
360 if (
getDolGlobalString(
'MAIL_MASS_ACTION_ADD_LAST_IF_MAIN_DOC_NOT_FOUND') && !empty($objectobj->last_main_doc)) {
361 $file_check_list[] = array(
362 'name' => basename($objectobj->last_main_doc),
363 'path' => DOL_DATA_ROOT .
'/' . $objectobj->last_main_doc,
366 foreach ($file_check_list as $file_check_arr) {
368 $filename_found = $file_check_arr[
'name'];
369 $filepath_found = $file_check_arr[
'path'];
374 if ($filepath_found) {
376 $attachedfilesThirdpartyObj[$thirdpartyid][$objectid] = array(
377 'paths'=>array($filepath_found),
378 'names'=>array($filename_found),
383 $langs->load(
"errors");
384 foreach ($file_check_list as $file_check_arr) {
385 $resaction .=
'<div class="error">'.$langs->trans(
'ErrorCantReadFile', $file_check_arr[
'path']).
'</div><br>';
386 dol_syslog(
'Failed to read file: '.$file_check_arr[
'path'], LOG_WARNING);
393 $listofqualifiedobj[$objectid] = $objectobj;
394 $listofqualifiedref[$objectid] = $objectobj->ref;
401 if (count($listofqualifiedobj) > 0) {
402 $langs->load(
"commercial");
405 $fromtype =
GETPOST(
'fromtype');
406 if ($fromtype ===
'user') {
407 $from =
dol_string_nospecial($user->getFullName($langs),
' ', array(
",")).
' <'.$user->email.
'>';
408 } elseif ($fromtype ===
'company') {
410 } elseif (preg_match(
'/user_aliases_(\d+)/', $fromtype, $reg)) {
411 $tmp = explode(
',', $user->email_aliases);
412 $from = trim($tmp[($reg[1] - 1)]);
413 } elseif (preg_match(
'/global_aliases_(\d+)/', $fromtype, $reg)) {
415 $from = trim($tmp[($reg[1] - 1)]);
416 } elseif (preg_match(
'/senderprofile_(\d+)_(\d+)/', $fromtype, $reg)) {
417 $sql =
"SELECT rowid, label, email FROM ".MAIN_DB_PREFIX.
"c_email_senderprofile WHERE rowid = ".(int) $reg[1];
418 $resql = $db->query($sql);
419 $obj = $db->fetch_object($resql);
428 $subject =
GETPOST(
'subject',
'restricthtml');
429 $message =
GETPOST(
'message',
'restricthtml');
431 $sendtobcc =
GETPOST(
'sendtoccc');
432 if ($objectclass ==
'Propal') {
435 if ($objectclass ==
'Commande') {
438 if ($objectclass ==
'Facture') {
441 if ($objectclass ==
'SupplierProposal') {
442 $sendtobcc .= (!
getDolGlobalString(
'MAIN_MAIL_AUTOCOPY_SUPPLIER_PROPOSAL_TO') ?
'' : (($sendtobcc ?
", " :
"") .
getDolGlobalString(
'MAIN_MAIL_AUTOCOPY_SUPPLIER_PROPOSAL_TO')));
444 if ($objectclass ==
'CommandeFournisseur') {
447 if ($objectclass ==
'FactureFournisseur') {
450 if ($objectclass ==
'Project') {
456 $looparray = array();
457 if (!$oneemailperrecipient) {
458 $looparray = $listofqualifiedobj;
459 foreach ($looparray as $key => $objecttmp) {
460 $looparray[$key]->thirdparty = $thirdparty;
463 $objectforloop =
new $objectclass($db);
464 $objectforloop->thirdparty = $thirdparty;
465 $looparray[0] = $objectforloop;
468 dol_syslog(
"We have set an array of ".count($looparray).
" emails to send. oneemailperrecipient=".$oneemailperrecipient);
470 foreach ($looparray as $objectid => $objecttmp) {
472 if (isModEnabled(
'project') && method_exists($objecttmp,
'fetch_projet') && is_null($objecttmp->project)) {
473 $objecttmp->fetch_projet();
476 $substitutionarray[
'__ID__'] = ($oneemailperrecipient ? join(
', ', array_keys($listofqualifiedobj)) : $objecttmp->id);
477 $substitutionarray[
'__REF__'] = ($oneemailperrecipient ? join(
', ', $listofqualifiedref) : $objecttmp->
ref);
478 $substitutionarray[
'__EMAIL__'] = $thirdparty->email;
479 $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"/>';
481 if ($oneemailperrecipient) {
482 $substitutionarray[
'__ONLINE_PAYMENT_URL__'] =
'';
483 $substitutionarray[
'__ONLINE_PAYMENT_TEXT_AND_URL__'] =
'';
486 $parameters = array(
'mode'=>
'formemail');
488 if (!empty($listofobjectthirdparties)) {
489 $parameters[
'listofobjectthirdparties'] = $listofobjectthirdparties;
491 if (!empty($listofobjectref)) {
492 $parameters[
'listofobjectref'] = $listofobjectref;
500 $attachedfiles = array(
'paths'=>array(),
'names'=>array(),
'mimes'=>array());
501 if ($oneemailperrecipient) {
503 if (is_array($attachedfilesThirdpartyObj[$thirdparty->id]) && count($attachedfilesThirdpartyObj[$thirdparty->id])) {
504 foreach ($attachedfilesThirdpartyObj[$thirdparty->id] as $keyObjId => $objAttachedFiles) {
506 $attachedfiles = array(
507 'paths'=>array_merge($attachedfiles[
'paths'], $objAttachedFiles[
'paths']),
508 'names'=>array_merge($attachedfiles[
'names'], $objAttachedFiles[
'names']),
509 'mimes'=>array_merge($attachedfiles[
'mimes'], $objAttachedFiles[
'mimes'])
513 } elseif (!empty($attachedfilesThirdpartyObj[$thirdparty->id][$objectid])) {
516 $attachedfiles = $attachedfilesThirdpartyObj[$thirdparty->id][$objectid];
519 $filepath = $attachedfiles[
'paths'];
520 $filename = $attachedfiles[
'names'];
521 $mimetype = $attachedfiles[
'mimes'];
524 if ($oneemailperrecipient) {
525 $trackid =
'thi'.$thirdparty->id;
526 if ($objecttmp->element ==
'expensereport') {
527 $trackid =
'use'.$thirdparty->id;
528 } elseif ($objecttmp->element ==
'contact') {
529 $trackid =
'ctc'.$thirdparty->id;
530 } elseif ($objecttmp->element ==
'holiday') {
531 $trackid =
'use'.$thirdparty->id;
534 $trackid = strtolower(get_class($objecttmp));
535 if (get_class($objecttmp) ==
'Contact') {
537 } elseif (get_class($objecttmp) ==
'Contrat') {
539 } elseif (get_class($objecttmp) ==
'Propal') {
541 } elseif (get_class($objecttmp) ==
'Commande') {
543 } elseif (get_class($objecttmp) ==
'Facture') {
545 } elseif (get_class($objecttmp) ==
'SupplierProposal') {
547 } elseif (get_class($objecttmp) ==
'CommandeFournisseur') {
549 } elseif (get_class($objecttmp) ==
'FactureFournisseur') {
553 $trackid .= $objecttmp->id;
559 if (empty($sendcontext)) {
560 $sendcontext =
'standard';
564 $vardir = $conf->user->dir_output.
"/".$user->id;
565 $upload_dir_tmp = $vardir.
'/temp';
568 require_once DOL_DOCUMENT_ROOT.
'/core/class/CMailFile.class.php';
569 $mailfile =
new CMailFile($subjectreplaced, $sendto, $from, $messagereplaced, $filepath, $mimetype, $filename, $sendtocc, $sendtobcc, $deliveryreceipt, -1,
'',
'', $trackid,
'', $sendcontext,
'', $upload_dir_tmp);
570 if ($mailfile->error) {
571 $resaction .=
'<div class="error">'.$mailfile->error.
'</div>';
573 $result = $mailfile->sendfile();
575 $resaction .= $langs->trans(
'MailSuccessfulySent', $mailfile->getValidAddress($mailfile->addr_from, 2), $mailfile->getValidAddress($mailfile->addr_to, 2)).
'<br>';
580 foreach ($listofqualifiedobj as $objid2 => $objectobj2) {
581 if ((!$oneemailperrecipient) && $objid2 != $objectid) {
585 dol_syslog(
"Try to insert email event into agenda for objid=".$objid2.
" => objectobj=".get_class($objectobj2));
594 $actionmsg = $langs->transnoentities(
'MailSentBy').
' '.$from.
' '.$langs->transnoentities(
'To').
' '.$sendto;
597 $actionmsg =
dol_concatdesc($actionmsg, $langs->transnoentities(
'Bcc').
": ".$sendtocc);
599 $actionmsg =
dol_concatdesc($actionmsg, $langs->transnoentities(
'MailTopic').
": ".$subjectreplaced);
600 $actionmsg =
dol_concatdesc($actionmsg, $langs->transnoentities(
'TextUsedInTheMessageBody').
":");
606 $objectobj2->sendtoid = (empty($contactidtosend) ? 0 : $contactidtosend);
607 $objectobj2->actionmsg = $actionmsg;
608 $objectobj2->actionmsg2 = $actionmsg2;
609 $objectobj2->fk_element = $objid2;
610 $objectobj2->elementtype = $objectobj2->element;
612 $objectobj2->actionmsg2 = $subjectreplaced;
615 $triggername = strtoupper(get_class($objectobj2)).
'_SENTBYMAIL';
616 if ($triggername ==
'SOCIETE_SENTBYMAIL') {
617 $triggername =
'COMPANY_SENTBYMAIL';
619 if ($triggername ==
'CONTRAT_SENTBYMAIL') {
620 $triggername =
'CONTRACT_SENTBYMAIL';
622 if ($triggername ==
'COMMANDE_SENTBYMAIL') {
623 $triggername =
'ORDER_SENTBYMAIL';
625 if ($triggername ==
'FACTURE_SENTBYMAIL') {
626 $triggername =
'BILL_SENTBYMAIL';
628 if ($triggername ==
'EXPEDITION_SENTBYMAIL') {
629 $triggername =
'SHIPPING_SENTBYMAIL';
631 if ($triggername ==
'COMMANDEFOURNISSEUR_SENTBYMAIL') {
632 $triggername =
'ORDER_SUPPLIER_SENTBYMAIL';
634 if ($triggername ==
'FACTUREFOURNISSEUR_SENTBYMAIL') {
635 $triggername =
'BILL_SUPPLIER_SENTBYMAIL';
637 if ($triggername ==
'SUPPLIERPROPOSAL_SENTBYMAIL') {
638 $triggername =
'PROPOSAL_SUPPLIER_SENTBYMAIL';
640 if ($triggername ==
'PROJET_SENTBYMAIL') {
641 $triggername =
'PROJECT_SENTBYMAIL';
644 if (!empty($triggername)) {
646 $result = $objectobj2->call_trigger($triggername, $user);
654 dol_syslog(
"Error in trigger ".$triggername.
' '.$db->lasterror(), LOG_ERR);
661 $langs->load(
"other");
662 if ($mailfile->error) {
663 $resaction .= $langs->trans(
'ErrorFailedToSendMail', $from, $sendto);
664 $resaction .=
'<br><div class="error">'.$mailfile->error.
'</div>';
666 $resaction .=
'<div class="warning">No mail sent. Feature is disabled by option MAIN_DISABLE_ALL_MAILS</div>';
668 $resaction .= $langs->trans(
'ErrorFailedToSendMail', $from, $sendto) .
'<br><div class="error">(unhandled error)</div>';
676 $resaction .= ($resaction ?
'<br>' : $resaction);
677 $resaction .=
'<strong>'.$langs->trans(
"ResultOfMailSending").
':</strong><br>'.
"\n";
678 $resaction .= $langs->trans(
"NbSelected").
': '.count($toselect).
"\n<br>";
679 $resaction .= $langs->trans(
"NbIgnored").
': '.($nbignored ? $nbignored : 0).
"\n<br>";
680 $resaction .= $langs->trans(
"NbSent").
': '.($nbsent ? $nbsent : 0).
"\n<br>";
685 setEventMessages($langs->trans(
"EMailSentForNElements", $nbsent.
'/'.count($toselect)),
null,
'mesgs');
698if (!$error && $massaction ==
'cancelorders') {
703 $orders =
GETPOST(
'toselect',
'array');
704 foreach ($orders as $id_order) {
706 if ($cmd->fetch($id_order) <= 0) {
711 $langs->load(
'errors');
712 setEventMessages($langs->trans(
"ErrorObjectMustHaveStatusValidToBeCanceled", $cmd->ref),
null,
'errors');
717 $result = $cmd->cancel();
741if (!$error && $massaction ==
"builddoc" && $permissiontoread && !
GETPOST(
'button_search')) {
742 if (empty($diroutputmassaction)) {
743 dol_print_error(
null,
'include of actions_massactions.inc.php is done but var $diroutputmassaction was not defined');
747 require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
748 require_once DOL_DOCUMENT_ROOT.
'/core/lib/pdf.lib.php';
749 require_once DOL_DOCUMENT_ROOT.
'/core/lib/date.lib.php';
751 $objecttmp =
new $objectclass($db);
752 $listofobjectid = array();
753 $listofobjectthirdparties = array();
754 $listofobjectref = array();
755 foreach ($toselect as $toselectid) {
756 $objecttmp =
new $objectclass($db);
757 $result = $objecttmp->fetch($toselectid);
759 $listofobjectid[$toselectid] = $toselectid;
760 $thirdpartyid = !empty($objecttmp->fk_soc) ? $objecttmp->fk_soc : $objecttmp->socid;
761 $listofobjectthirdparties[$thirdpartyid] = $thirdpartyid;
762 $listofobjectref[$toselectid] = $objecttmp->ref;
766 $arrayofinclusion = array();
767 foreach ($listofobjectref as $tmppdf) {
770 foreach ($listofobjectref as $tmppdf) {
771 $arrayofinclusion[] =
'^'.preg_quote(
dol_sanitizeFileName($tmppdf),
'/').
'_[a-zA-Z0-9\-\_\'\&\.]+\.pdf$';
773 $listoffiles =
dol_dir_list($uploaddir,
'all', 1, implode(
'|', $arrayofinclusion),
'\.meta$|\.png',
'date', SORT_DESC, 0,
true);
777 foreach ($listofobjectref as $basename) {
779 foreach ($listoffiles as $filefound) {
780 if (strstr($filefound[
"name"], $basename)) {
781 $files[] = $uploaddir.
'/'.$basename.
'/'.$filefound[
"name"];
788 $outputlangs = $langs;
791 $newlang =
GETPOST(
'lang_id',
'aZ09');
796 if (!empty($newlang)) {
798 $outputlangs->setDefaultLang($newlang);
807 $filename = preg_replace(
'/\s/',
'_', $filename);
810 if (in_array($objecttmp->element, array(
'facture',
'facture_fournisseur')) && $search_status ==
Facture::STATUS_VALIDATED) {
811 if ($option ==
'late') {
818 $filename .=
'_'.$year;
821 $filename .=
'_'.$month;
824 if (count($files) > 0) {
826 $file = $diroutputmassaction.
'/'.$filename.
'_'.
dol_print_date($now,
'dayhourlog').
'.pdf';
829 foreach ($files as $f) {
830 $input_files .=
' '.escapeshellarg($f);
833 $cmd =
'pdftk '.$input_files.
' cat output '.escapeshellarg($file);
837 if (file_exists($file)) {
840 $langs->load(
"exports");
843 setEventMessages($langs->trans(
'ErrorPDFTkOutputFileNotFound'),
null,
'errors');
846 setEventMessages($langs->trans(
'NoPDFAvailableForDocGenAmongChecked'),
null,
'errors');
851 $page_largeur = $formatarray[
'width'];
852 $page_hauteur = $formatarray[
'height'];
853 $format = array($page_largeur, $page_hauteur);
857 if (class_exists(
'TCPDF')) {
858 $pdf->setPrintHeader(
false);
859 $pdf->setPrintFooter(
false);
864 $pdf->SetCompression(
false);
868 foreach ($files as $file) {
870 $pagecount = $pdf->setSourceFile($file);
871 for ($i = 1; $i <= $pagecount; $i++) {
872 $tplidx = $pdf->importPage($i);
873 $s = $pdf->getTemplatesize($tplidx);
874 $pdf->AddPage($s[
'h'] > $s[
'w'] ?
'P' :
'L');
875 $pdf->useTemplate($tplidx);
884 $filename = preg_replace(
'/\s/',
'_', $filename);
887 if (in_array($objecttmp->element, array(
'facture',
'facture_fournisseur')) && $search_status ==
Facture::STATUS_VALIDATED) {
888 if ($option ==
'late') {
895 $filename .=
'_'.$year;
898 $filename .=
'_'.$month;
902 $file = $diroutputmassaction.
'/'.$filename.
'_'.
dol_print_date($now,
'dayhourlog').
'.pdf';
903 $pdf->Output($file,
'F');
906 $langs->load(
"exports");
909 setEventMessages($langs->trans(
'NoPDFAvailableForDocGenAmongChecked'),
null,
'errors');
915if ($action ==
'remove_file') {
916 require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
918 $langs->load(
"other");
919 $upload_dir = $diroutputmassaction;
920 $file = $upload_dir.
'/'.
GETPOST(
'file');
932if (!$error && $massaction ==
'validate' && $permissiontoadd) {
933 $objecttmp =
new $objectclass($db);
935 if (($objecttmp->element ==
'facture' || $objecttmp->element ==
'invoice') && isModEnabled(
'stock') &&
getDolGlobalString(
'STOCK_CALCULATE_ON_BILL')) {
936 $langs->load(
"errors");
937 setEventMessages($langs->trans(
'ErrorMassValidationNotAllowedWhenStockIncreaseOnAction'),
null,
'errors');
940 if ($objecttmp->element ==
'invoice_supplier' && isModEnabled(
'stock') &&
getDolGlobalString(
'STOCK_CALCULATE_ON_SUPPLIER_BILL')) {
941 $langs->load(
"errors");
942 setEventMessages($langs->trans(
'ErrorMassValidationNotAllowedWhenStockIncreaseOnAction'),
null,
'errors');
945 if ($objecttmp->element ==
'facture') {
948 $sql =
"SELECT rowid FROM ".MAIN_DB_PREFIX.
"facture";
949 $sql .=
" WHERE rowid IN (".$db->sanitize(implode(
",", $toselect)).
")";
950 $sql .=
" ORDER BY datef";
952 $resql = $db->query($sql);
955 while (!empty($arr = $db->fetch_row($resql))) {
956 $toselectnew[] = $arr[0];
958 $toselect = (empty($toselectnew)) ? $toselect : $toselectnew;
969 foreach ($toselect as $toselectid) {
970 $result = $objecttmp->fetch($toselectid);
972 if (method_exists($objecttmp,
'validate')) {
973 $result = $objecttmp->validate($user);
974 } elseif (method_exists($objecttmp,
'setValid')) {
975 $result = $objecttmp->setValid($user);
977 $objecttmp->error =
'No method validate or setValid on this object';
981 $langs->load(
"errors");
982 setEventMessages($langs->trans(
"ErrorObjectMustHaveStatusDraftToBeValidated", $objecttmp->ref),
null,
'errors');
985 } elseif ($result < 0) {
993 $outputlangs = $langs;
996 $newlang =
GETPOST(
'lang_id',
'aZ09');
998 if (
getDolGlobalInt(
'MAIN_MULTILANGS') && empty($newlang) && property_exists($objecttmp,
'thirdparty')) {
999 if ((property_exists($objecttmp,
'socid') || property_exists($objecttmp,
'fk_soc')) && empty($objecttmp->thirdparty)) {
1000 $objecttmp->fetch_thirdparty();
1002 if (!empty($objecttmp->thirdparty)) {
1003 $newlang = $objecttmp->thirdparty->default_lang;
1006 if (!empty($newlang)) {
1007 $outputlangs =
new Translate(
"", $conf);
1008 $outputlangs->setDefaultLang($newlang);
1009 $outputlangs->load(
'products');
1011 $model = $objecttmp->model_pdf;
1012 $ret = $objecttmp->fetch($objecttmp->id);
1015 $hidedetails = isset($hidedetails) ? $hidedetails : (
getDolGlobalString(
'MAIN_GENERATE_DOCUMENTS_HIDE_DETAILS') ? 1 : 0);
1016 $hidedesc = isset($hidedesc) ? $hidedesc : (
getDolGlobalString(
'MAIN_GENERATE_DOCUMENTS_HIDE_DESC') ? 1 : 0);
1017 $hideref = isset($hideref) ? $hideref : (
getDolGlobalString(
'MAIN_GENERATE_DOCUMENTS_HIDE_REF') ? 1 : 0);
1018 $moreparams = isset($moreparams) ? $moreparams :
null;
1020 $result = $objecttmp->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref);
1038 setEventMessages($langs->trans(
"RecordModifiedSuccessfully"),
null,
'mesgs');
1051if (!$error && ($massaction ==
'delete' || ($action ==
'delete' && $confirm ==
'yes')) && $permissiontodelete) {
1054 $objecttmp =
new $objectclass($db);
1059 $unique_arr = array_unique($toselect);
1060 foreach ($unique_arr as $toselectid) {
1061 $result = $objecttmp->fetch($toselectid);
1065 $langs->load(
"errors");
1067 $TMsg[] =
'<div class="error">'.$langs->trans(
'ErrorOnlyDraftStatusCanBeDeletedInMassAction', $objecttmp->ref).
'</div><br>';
1071 if (method_exists($objecttmp,
'is_erasable') && $objecttmp->is_erasable() <= 0) {
1072 $langs->load(
"errors");
1074 $TMsg[] =
'<div class="error">'.$langs->trans(
'ErrorRecordHasChildren').
' '.$objecttmp->ref.
'</div><br>';
1079 $langs->load(
"errors");
1081 $TMsg[] =
'<div class="error">'.$langs->trans(
'ErrorLeaveRequestMustBeDraftCanceledOrRefusedToBeDeleted', $objecttmp->ref).
'</div><br>';
1085 if ($objectclass ==
"Task" && $objecttmp->hasChildren() > 0) {
1086 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"projet_task SET fk_task_parent = 0 WHERE fk_task_parent = ".((int) $objecttmp->id);
1087 $res = $db->query($sql);
1095 if (in_array($objecttmp->element, array(
'societe',
'member'))) {
1096 $result = $objecttmp->delete($objecttmp->id, $user, 1);
1097 } elseif (in_array($objecttmp->element, array(
'action'))) {
1098 $result = $objecttmp->delete();
1100 $result = $objecttmp->delete($user);
1103 if (empty($result)) {
1104 $TMsg = array_merge($objecttmp->errors, $TMsg);
1105 } elseif ($result < 0) {
1119 if (empty($error)) {
1123 } elseif ($nbok > 0) {
1130 if (!empty($TMsg)) {
1145if (!$error && $massaction ==
'generate_doc' && $permissiontoread) {
1147 $objecttmp =
new $objectclass($db);
1149 foreach ($toselect as $toselectid) {
1150 $result = $objecttmp->fetch($toselectid);
1152 $outputlangs = $langs;
1156 $newlang =
GETPOST(
'lang_id',
'aZ09');
1158 if (
getDolGlobalInt(
'MAIN_MULTILANGS') && empty($newlang) && isset($objecttmp->thirdparty->default_lang)) {
1159 $newlang = $objecttmp->thirdparty->default_lang;
1161 if (
getDolGlobalInt(
'MAIN_MULTILANGS') && empty($newlang) && isset($objecttmp->default_lang)) {
1162 $newlang = $objecttmp->default_lang;
1164 if ($conf->global->MAIN_MULTILANGS && empty($newlang) && empty($objecttmp->thirdparty)) {
1165 $objecttmp->fetch_thirdparty();
1166 $newlang = $objecttmp->thirdparty->default_lang;
1168 if (!empty($newlang)) {
1169 $outputlangs =
new Translate(
"", $conf);
1170 $outputlangs->setDefaultLang($newlang);
1174 $hidedetails = isset($hidedetails) ? $hidedetails : (
getDolGlobalString(
'MAIN_GENERATE_DOCUMENTS_HIDE_DETAILS') ? 1 : 0);
1175 $hidedesc = isset($hidedesc) ? $hidedesc : (
getDolGlobalString(
'MAIN_GENERATE_DOCUMENTS_HIDE_DESC') ? 1 : 0);
1176 $hideref = isset($hideref) ? $hideref : (
getDolGlobalString(
'MAIN_GENERATE_DOCUMENTS_HIDE_REF') ? 1 : 0);
1177 $moreparams = isset($moreparams) ? $moreparams :
null;
1179 $result = $objecttmp->generateDocument($objecttmp->model_pdf, $outputlangs, $hidedetails, $hidedesc, $hideref, $moreparams);
1207if (!$error && ($action ==
'affecttag' && $confirm ==
'yes') && $permissiontoadd) {
1210 $affecttag_type=
GETPOST(
'affecttag_type',
'alpha');
1211 if (!empty($affecttag_type)) {
1212 $affecttag_type_array=explode(
',', $affecttag_type);
1216 if (!empty($affecttag_type_array)) {
1218 require_once DOL_DOCUMENT_ROOT.
'/categories/class/categorie.class.php';
1220 $to_affecttag_type_array=array();
1221 $categ_type_array=$categ->getMapList();
1222 foreach ($categ_type_array as $categdef) {
1223 if (in_array($categdef[
'code'], $affecttag_type_array)) {
1224 $to_affecttag_type_array[] = $categdef[
'code'];
1230 if (!empty($to_affecttag_type_array)) {
1231 foreach ($to_affecttag_type_array as $categ_type) {
1232 $contcats =
GETPOST(
'contcats_' . $categ_type,
'array');
1234 foreach ($toselect as $toselectid) {
1235 $result = $object->fetch($toselectid);
1238 $result = $object->setCategoriesCommon($contcats, $categ_type,
false);
1267if (!$error && ($action ==
'updateprice' && $confirm ==
'yes') && $permissiontoadd) {
1269 if (GETPOSTISSET(
'pricerate')) {
1270 $pricepercentage=
GETPOST(
'pricerate',
'int');
1271 if ($pricepercentage == 0) {
1274 foreach ($toselect as $toselectid) {
1275 $result = $object->fetch($toselectid);
1280 if ($object->price_base_type ==
'TTC') {
1281 $newprice = $object->price_ttc * (100 + $pricepercentage) / 100;
1282 $minprice = $object->price_min_ttc;
1284 $newprice = $object->price * (100 + $pricepercentage) / 100;
1285 $minprice = $object->price_min;
1287 $res = $object->updatePrice($newprice, $object->price_base_type, $user, $object->tva_tx, $minprice, 0, $object->tva_npr, 0, 0, array(), $object->default_vat_code);
1294 for ($level = 1; $level <=
getDolGlobalInt(
'PRODUIT_MULTIPRICES_LIMIT'); $level++) {
1295 if ($object->price_base_type ==
'TTC') {
1296 $newprice = $object->multiprices_ttc[$level] * (100 + $pricepercentage) / 100;
1297 $minprice = $object->multiprices_min_ttc[$level];
1299 $newprice = $object->multiprices[$level] * (100 + $pricepercentage) / 100;
1300 $minprice = $object->multiprices_min[$level];
1302 $res = $object->updatePrice($newprice, $object->price_base_type, $user, $object->tva_tx, $minprice, $level, $object->tva_npr, 0, 0, array(), $object->default_vat_code);
1328if (!$error && ($action ==
'setsupervisor' && $confirm ==
'yes') && $permissiontoadd) {
1330 $supervisortoset=
GETPOST(
'supervisortoset');
1331 if (!empty($supervisortoset)) {
1332 foreach ($toselect as $toselectid) {
1333 $result = $object->fetch($toselectid);
1336 $object->fk_user = $supervisortoset;
1337 $res = $object->update($user);
1367if (!$error && ($action ==
'affectuser' && $confirm ==
'yes') && $permissiontoadd) {
1370 $usertoaffect=
GETPOST(
'usertoaffect');
1371 $projectrole=
GETPOST(
'projectrole');
1372 $tasksrole=
GETPOST(
'tasksrole');
1373 if (!empty($usertoaffect)) {
1374 foreach ($toselect as $toselectid) {
1375 $result = $object->fetch($toselectid);
1378 $res = $object->add_contact($usertoaffect, $projectrole,
'internal');
1380 $taskstatic =
new Task($db);
1381 $task_array = $taskstatic->getTasksArray(0, 0, $object->id, 0, 0);
1383 foreach ($task_array as $task) {
1384 $tasksToAffect =
new Task($db);
1385 $result = $tasksToAffect->fetch($task->id);
1387 $res = $tasksToAffect->add_contact($usertoaffect, $tasksrole,
'internal');
1421if (!$error && ($massaction ==
'enable' || ($action ==
'enable' && $confirm ==
'yes')) && $permissiontoadd) {
1424 $objecttmp =
new $objectclass($db);
1426 foreach ($toselect as $toselectid) {
1427 $result = $objecttmp->fetch($toselectid);
1429 if (in_array($objecttmp->element, array(
'societe'))) {
1430 $result =$objecttmp->setStatut(1);
1458if (!$error && ($massaction ==
'disable' || ($action ==
'disable' && $confirm ==
'yes')) && $permissiontoadd) {
1461 $objecttmp =
new $objectclass($db);
1463 foreach ($toselect as $toselectid) {
1464 $result = $objecttmp->fetch($toselectid);
1466 if (in_array($objecttmp->element, array(
'societe'))) {
1467 $result =$objecttmp->setStatut(0);
1495if (!$error && $action ==
'confirm_edit_value_extrafields' && $confirm ==
'yes' && $permissiontoadd) {
1498 $objecttmp =
new $objectclass($db);
1500 $e->fetch_name_optionals_label($objecttmp->table_element);
1503 $extrafieldKeyToUpdate =
GETPOST(
'extrafield-key-to-update');
1506 foreach ($toselect as $toselectid) {
1508 $objecttmp =
new $objectclass($db);
1509 $result = $objecttmp->fetch($toselectid);
1512 $ret = $e->setOptionalsFromPost(
null, $objecttmp, $extrafieldKeyToUpdate);
1514 $objecttmp->insertExtraFields();
1538if (!$error && ($massaction ==
'affectcommercial' || ($action ==
'affectcommercial' && $confirm ==
'yes')) && $permissiontoadd) {
1541 $objecttmp =
new $objectclass($db);
1544 foreach ($toselect as $toselectid) {
1545 $result = $objecttmp->fetch($toselectid);
1547 if (in_array($objecttmp->element, array(
'societe'))) {
1548 $result = $objecttmp->setSalesRep(
GETPOST(
"commercial",
"alpha"));
1566 setEventMessages($langs->trans(
"CommercialsAffected", $nbok),
null,
'mesgs');
1577if (!$error && ($massaction ==
'approveleave' || ($action ==
'approveleave' && $confirm ==
'yes')) && $permissiontoapprove) {
1580 $objecttmp =
new $objectclass($db);
1582 foreach ($toselect as $toselectid) {
1583 $result = $objecttmp->fetch($toselectid);
1586 setEventMessages($langs->trans(
'StatusOfRefMustBe', $objecttmp->ref, $langs->transnoentitiesnoconv(
'Validated')),
null,
'warnings');
1589 if ($user->id == $objecttmp->fk_validator) {
1590 $objecttmp->oldcopy =
dol_clone($objecttmp);
1592 $objecttmp->date_valid =
dol_now();
1593 $objecttmp->fk_user_valid = $user->id;
1596 $verif = $objecttmp->approve($user);
1606 $nbopenedday =
num_open_day($objecttmp->date_debut_gmt, $objecttmp->date_fin_gmt, 0, 1, $objecttmp->halfday);
1607 $soldeActuel = $objecttmp->getCpforUser($objecttmp->fk_user, $objecttmp->fk_type);
1608 $newSolde = ($soldeActuel - $nbopenedday);
1611 $result = $objecttmp->addLogCP($user->id, $objecttmp->fk_user, $langs->transnoentitiesnoconv(
"Holidays"), $newSolde, $objecttmp->fk_type);
1618 $result = $objecttmp->updateSoldeCP($objecttmp->fk_user, $newSolde, $objecttmp->fk_type);
1627 $destinataire =
new User($db);
1628 $destinataire->fetch($objecttmp->fk_user);
1629 $emailTo = $destinataire->email;
1632 dol_syslog(
"User that request leave has no email, so we redirect directly to finished page without sending email");
1635 $expediteur =
new User($db);
1636 $expediteur->fetch($objecttmp->fk_validator);
1638 $emailFrom = $conf->global->MAIN_MAIL_EMAIL_FROM;
1641 $societeName = $conf->global->MAIN_INFO_SOCIETE_NOM;
1643 $societeName = $conf->global->MAIN_APPLICATION_TITLE;
1646 $subject = $societeName.
" - ".$langs->transnoentitiesnoconv(
"HolidaysValidated");
1649 $message = $langs->transnoentitiesnoconv(
"Hello").
" ".$destinataire->firstname.
",\n";
1652 $message .= $langs->transnoentities(
"HolidaysValidatedBody",
dol_print_date($objecttmp->date_debut,
'day'),
dol_print_date($objecttmp->date_fin,
'day')).
"\n";
1654 $message .=
"- ".$langs->transnoentitiesnoconv(
"ValidatedBy").
" : ".
dolGetFirstLastname($expediteur->firstname, $expediteur->lastname).
"\n";
1656 $message .=
"- ".$langs->transnoentitiesnoconv(
"Link").
" : ".$dolibarr_main_url_root.
"/holiday/card.php?id=".$objecttmp->id.
"\n\n";
1659 $trackid =
'leav'.$objecttmp->id;
1661 require_once DOL_DOCUMENT_ROOT.
'/core/class/CMailFile.class.php';
1662 $mail =
new CMailFile($subject, $emailTo, $emailFrom, $message, array(), array(), array(),
'',
'', 0, 0,
'',
'', $trackid);
1665 $result = $mail->sendfile();
1674 $langs->load(
"errors");
1675 setEventMessages($langs->trans(
'ErrorNotApproverForHoliday', $objecttmp->ref),
null,
'errors');
1687 } elseif ($nbok == 1) {
1696if (!$error && ($massaction ==
'increaseholiday' || ($action ==
'increaseholiday' && $confirm ==
'yes')) && $permissiontoapprove) {
1698 $objecttmp =
new $objectclass($db);
1700 $typeholiday =
GETPOST(
'typeholiday',
'alpha');
1701 $nbdaysholidays =
GETPOST(
'nbdaysholidays',
'double');
1703 if ($nbdaysholidays <= 0) {
1709 foreach ($toselect as $toselectid) {
1710 $balancecpuser = $objecttmp->getCPforUser($toselectid, $typeholiday);
1711 if (!empty($balancecpuser)) {
1712 $newnbdaysholidays = $nbdaysholidays + $balancecpuser;
1714 $newnbdaysholidays = $nbdaysholidays;
1716 $result = $holiday->addLogCP($user->id, $toselectid, $langs->transnoentitiesnoconv(
'ManualUpdate'), $newnbdaysholidays, $typeholiday);
1723 $objecttmp->updateSoldeCP($toselectid, $newnbdaysholidays, $typeholiday);
1736 setEventMessages($langs->trans(
"HolidayRecordsIncreased", $nbok),
null,
'mesgs');
1737 } elseif ($nbok == 1) {
1748if (!$error && ($massaction ==
'clonetasks' || ($action ==
'clonetasks' && $confirm ==
'yes'))) {
1753 $origin_task =
new Task($db);
1754 $clone_task =
new Task($db);
1756 foreach (
GETPOST(
'selected') as $task) {
1757 $origin_task->fetch($task, $ref =
'', $loadparentdata = 0);
1760 $obj = !
getDolGlobalString(
'PROJECT_TASK_ADDON') ?
'mod_task_simple' : $conf->global->PROJECT_TASK_ADDON;
1762 require_once DOL_DOCUMENT_ROOT .
"/core/modules/project/task/" .
getDolGlobalString(
'PROJECT_TASK_ADDON') .
'.php';
1763 $modTask =
new $obj();
1764 $defaultref = $modTask->getNextValue(0, $clone_task);
1768 $clone_task->fk_project =
GETPOST(
'projectid',
'int');
1769 $clone_task->ref = $defaultref;
1770 $clone_task->label = $origin_task->label;
1771 $clone_task->description = $origin_task->description;
1772 $clone_task->planned_workload = $origin_task->planned_workload;
1773 $clone_task->fk_task_parent = $origin_task->fk_task_parent;
1774 $clone_task->date_c =
dol_now();
1775 $clone_task->date_start = $origin_task->date_start;
1776 $clone_task->date_end = $origin_task->date_end;
1777 $clone_task->progress = $origin_task->progress;
1780 $ret = $extrafields->setOptionalsFromPost(
null, $clone_task);
1782 $taskid = $clone_task->create($user);
1785 $result = $clone_task->add_contact(
GETPOST(
"userid",
'int'),
'TASKEXECUTIVE',
'internal');
1788 if ($db->lasterrno() ==
'DB_ERROR_RECORD_ALREADY_EXISTS') {
1789 $langs->load(
"projects");
1791 $duplicate_code_error =
true;
1803 header(
"Refresh: 1;URL=".DOL_URL_ROOT.
'/projet/tasks.php?id=' .
GETPOST(
'projectid',
'int'));
1807$parameters[
'toselect'] = (empty($toselect) ? array() : $toselect);
1808$parameters[
'uploaddir'] = $uploaddir;
1809$parameters[
'massaction'] = $massaction;
1810$parameters[
'diroutputmassaction'] = isset($diroutputmassaction) ? $diroutputmassaction :
null;
1812$reshook = $hookmanager->executeHooks(
'doMassActions', $parameters, $object, $action);
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.
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_most_recent_file($dir, $regexfilter='', $excludefilter=array('(\.meta|_preview.*\.png) $', '^\.'), $nohook=false, $mode='')
Return file(s) into a directory (by default most recent)
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($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_mimetype($file, $default='application/octet-stream', $mode=0)
Return MIME type of a file from its name with extension.
dol_print_error($db='', $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
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)
Set event message in dol_events session object.
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs='', $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
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.
if(!function_exists( 'dol_getprefix')) dol_include_once($relpath, $classname='')
Make an include_once using default root and alternate root if it fails.
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.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0)
Set event messages in dol_events session object.
dol_sanitizeFileName($str, $newstr='_', $unaccent=1)
Clean a string to use it as a file name.
getCommonSubstitutionArray($outputlangs, $onlykey=0, $exclude=null, $object=null, $include=null)
Return array of possible common substitutions.
getDolGlobalString($key, $default='')
Return 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(Translate $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.