40if (empty($objectclass) || empty($uploaddir)) {
41 dol_print_error(
null,
'include of actions_massactions.inc.php is done but var $objectclass or $uploaddir was not defined');
44if (empty($massaction)) {
50if (!empty($permtoread) && empty($permissiontoread)) {
51 $permissiontoread = $permtoread;
53if (!empty($permtocreate) && empty($permissiontoadd)) {
54 $permissiontoadd = $permtocreate;
56if (!empty($permtodelete) && empty($permissiontodelete)) {
57 $permissiontodelete = $permtodelete;
61$maxformassaction = (!
getDolGlobalString(
'MAIN_LIMIT_FOR_MASS_ACTIONS') ? 1000 : $conf->global->MAIN_LIMIT_FOR_MASS_ACTIONS);
62if ($massaction && is_array($toselect) && count($toselect) < 1) {
66if (!$error && isset($toselect) && is_array($toselect) && count($toselect) > $maxformassaction) {
67 setEventMessages($langs->trans(
'TooManyRecordForMassAction', $maxformassaction),
null,
'errors');
71if (!$error && $massaction ==
'confirm_presend' && !
GETPOST(
'sendmail')) {
72 $massaction =
'presend';
74if (!$error && $massaction ==
'confirm_presend') {
78 $langs->load(
"mails");
79 include_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
80 include_once DOL_DOCUMENT_ROOT.
'/core/lib/signature.lib.php';
82 $listofobjectid = array();
83 $listofobjectthirdparties = array();
84 $listofobjectcontacts = array();
85 $listofobjectref = array();
86 $contactidtosend = array();
87 $attachedfilesThirdpartyObj = array();
88 $oneemailperrecipient = (
GETPOST(
'oneemailperrecipient',
'int') ? 1 : 0);
91 $objecttmp =
new $objectclass($db);
95 if ($objecttmp->element ==
'expensereport') {
96 $thirdparty =
new User($db);
97 } elseif ($objecttmp->element ==
'contact') {
99 } elseif ($objecttmp->element ==
'partnership' &&
getDolGlobalString(
'PARTNERSHIP_IS_MANAGED_FOR') ==
'member') {
101 } elseif ($objecttmp->element ==
'holiday') {
102 $thirdparty =
new User($db);
103 } elseif ($objecttmp->element ==
'conferenceorboothattendee') {
107 foreach ($toselect as $toselectid) {
108 $objecttmp =
new $objectclass($db);
109 $result = $objecttmp->fetch($toselectid);
111 $listofobjectid[$toselectid] = $toselectid;
112 $tmpobjectid = ($objecttmp->fk_soc ? $objecttmp->fk_soc : $objecttmp->socid);
113 if ($objecttmp->element ==
'societe') {
114 $tmpobjectid = $objecttmp->id;
115 } elseif ($objecttmp->element ==
'contact') {
116 $tmpobjectid = $objecttmp->id;
117 } elseif ($objecttmp->element ==
'expensereport') {
118 $tmpobjectid = $objecttmp->fk_user_author;
119 } elseif ($objecttmp->element ==
'partnership' &&
getDolGlobalString(
'PARTNERSHIP_IS_MANAGED_FOR') ==
'member') {
120 $tmpobjectid = $objecttmp->fk_member;
121 } elseif ($objecttmp->element ==
'holiday') {
122 $tmpobjectid = $objecttmp->fk_user;
123 } elseif ($objecttmp->element ==
'conferenceorboothattendee') {
124 $tmpobjectid = $objecttmp->id;
126 if (empty($tmpobjectid)) {
130 if ($objectclass ==
'Facture') {
131 $tmparraycontact = array();
132 $tmparraycontact = $objecttmp->liste_contact(-1,
'external', 0,
'BILLING');
133 if (is_array($tmparraycontact) && count($tmparraycontact) > 0) {
134 foreach ($tmparraycontact as $data_email) {
135 $listofobjectcontacts[$toselectid][$data_email[
'id']] = $data_email[
'email'];
138 } elseif ($objectclass ==
'CommandeFournisseur') {
139 $tmparraycontact = array();
140 $tmparraycontact = $objecttmp->liste_contact(-1,
'external', 0,
'CUSTOMER');
141 if (is_array($tmparraycontact) && count($tmparraycontact) > 0) {
142 foreach ($tmparraycontact as $data_email) {
143 $listofobjectcontacts[$toselectid][$data_email[
'id']] = $data_email[
'email'];
148 $listofobjectthirdparties[$tmpobjectid] = $tmpobjectid;
149 $listofobjectref[$tmpobjectid][$toselectid] = $objecttmp;
155 if (
GETPOST(
'fromtype',
'alpha') ===
'user' && empty($user->email)) {
158 $massaction =
'presend';
161 $receiver =
GETPOST(
'receiver',
'alphawithlgt');
162 if (!is_array($receiver)) {
163 if (empty($receiver) || $receiver ==
'-1') {
166 $receiver = array($receiver);
169 if (!trim($_POST[
'sendto']) && count($receiver) == 0 && count($listofobjectthirdparties) == 1) {
171 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Recipient")),
null,
'warnings');
172 $massaction =
'presend';
175 if (!
GETPOST(
'subject',
'restricthtml')) {
177 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"MailTopic")),
null,
'warnings');
178 $massaction =
'presend';
183 foreach ($listofobjectthirdparties as $thirdpartyid) {
184 $result = $thirdparty->fetch($thirdpartyid);
197 if (trim($_POST[
'sendto'])) {
199 $tmparray[] = trim(
GETPOST(
'sendto',
'alphawithlgt'));
201 if (count($receiver) > 0) {
202 foreach ($receiver as $key => $val) {
204 if ($val ==
'thirdparty') {
205 $tmparray[] = $thirdparty->name.
' <'.$thirdparty->email.
'>';
206 } elseif ($val && method_exists($thirdparty,
'contact_get_property')) {
207 $tmparray[] = $thirdparty->contact_get_property((
int) $val,
'email');
212 $sendto = implode(
',', $tmparray);
215 $receivercc =
GETPOST(
'receivercc',
'alphawithlgt');
216 if (!is_array($receivercc)) {
217 if ($receivercc ==
'-1') {
218 $receivercc = array();
220 $receivercc = array($receivercc);
224 if (trim($_POST[
'sendtocc'])) {
225 $tmparray[] = trim(
GETPOST(
'sendtocc',
'alphawithlgt'));
227 if (count($receivercc) > 0) {
228 foreach ($receivercc as $key => $val) {
230 if ($val ==
'thirdparty') {
231 $tmparray[] = $thirdparty->name.
' <'.$thirdparty->email.
'>';
233 $tmparray[] = $thirdparty->contact_get_property((
int) $val,
'email');
238 $sendtocc = implode(
',', $tmparray);
241 $listofqualifiedobj = array();
242 $listofqualifiedref = array();
243 $thirdpartywithoutemail = array();
245 foreach ($listofobjectref[$thirdpartyid] as $objectid => $objectobj) {
248 $langs->load(
"errors");
250 $resaction .=
'<div class="error">'.$langs->trans(
'ErrorOnlyProposalNotDraftCanBeSentInMassAction', $objectobj->ref).
'</div><br>';
254 $langs->load(
"errors");
256 $resaction .=
'<div class="error">'.$langs->trans(
'ErrorOnlyOrderNotDraftCanBeSentInMassAction', $objectobj->ref).
'</div><br>';
260 $langs->load(
"errors");
262 $resaction .=
'<div class="error">'.$langs->trans(
'ErrorOnlyInvoiceValidatedCanBeSentInMassAction', $objectobj->ref).
'</div><br>';
267 if (empty($sendto)) {
268 if ($objectobj->element ==
'societe') {
269 $sendto = $objectobj->email;
270 } elseif ($objectobj->element ==
'expensereport') {
271 $fuser =
new User($db);
272 $fuser->fetch($objectobj->fk_user_author);
273 $sendto = $fuser->email;
274 } elseif ($objectobj->element ==
'contact') {
276 $fcontact->fetch($objectobj->id);
277 $sendto = $fcontact->email;
278 } elseif ($objectobj->element ==
'partnership' &&
getDolGlobalString(
'PARTNERSHIP_IS_MANAGED_FOR') ==
'member') {
280 $fadherent->fetch($objectobj->fk_member);
281 $sendto = $fadherent->email;
282 } elseif ($objectobj->element ==
'holiday') {
283 $fuser =
new User($db);
284 $fuser->fetch($objectobj->fk_user);
285 $sendto = $fuser->email;
286 } elseif ($objectobj->element ==
'facture' && !empty($listofobjectcontacts[$objectid])) {
287 $emails_to_sends = array();
288 $objectobj->fetch_thirdparty();
289 $contactidtosend = array();
290 foreach ($listofobjectcontacts[$objectid] as $contactemailid => $contactemailemail) {
291 $emails_to_sends[] = $objectobj->thirdparty->contact_get_property($contactemailid,
'email');
292 if (!in_array($contactemailid, $contactidtosend)) {
293 $contactidtosend[] = $contactemailid;
296 if (count($emails_to_sends) > 0) {
297 $sendto = implode(
',', $emails_to_sends);
299 } elseif ($objectobj->element ==
'order_supplier' && !empty($listofobjectcontacts[$objectid])) {
300 $emails_to_sends = array();
301 $objectobj->fetch_thirdparty();
302 $contactidtosend = array();
303 foreach ($listofobjectcontacts[$objectid] as $contactemailid => $contactemailemail) {
304 $emails_to_sends[] = $objectobj->thirdparty->contact_get_property($contactemailid,
'email');
305 if (!in_array($contactemailid, $contactidtosend)) {
306 $contactidtosend[] = $contactemailid;
309 if (count($emails_to_sends) > 0) {
310 $sendto = implode(
',', $emails_to_sends);
312 } elseif ($objectobj->element ==
'conferenceorboothattendee') {
313 $sendto = $objectobj->email;
315 $objectobj->fetch_thirdparty();
316 $sendto = $objectobj->thirdparty->email;
320 if (empty($sendto)) {
321 if ($objectobj->element ==
'societe') {
322 $objectobj->thirdparty = $objectobj;
327 if (empty($thirdpartywithoutemail[$objectobj->thirdparty->id])) {
328 $resaction .=
'<div class="error">'.$langs->trans(
'NoRecipientEmail', $objectobj->thirdparty->name).
'</div><br>';
330 dol_syslog(
'No recipient for thirdparty: '.$objectobj->thirdparty->name, LOG_WARNING);
331 $thirdpartywithoutemail[$objectobj->thirdparty->id] = 1;
335 if (
GETPOST(
'addmaindocfile')) {
342 $filedir = $uploaddir.
'/'.$subdir.dol_sanitizeFileName($objectobj->ref);
343 $filepath = $filedir.
'/'.$filename;
346 if ($objectobj->element ==
'invoice_supplier') {
347 $fileparams =
dol_most_recent_file($uploaddir.
'/'.
get_exdir($objectobj->id, 2, 0, 0, $objectobj, $objectobj->element).$objectobj->ref, preg_quote($objectobj->ref,
'/').
'([^\-])+');
348 $filepath = $fileparams[
'fullname'];
352 $filename_found =
'';
353 $filepath_found =
'';
354 $file_check_list = array();
355 $file_check_list[] = array(
359 if (
getDolGlobalString(
'MAIL_MASS_ACTION_ADD_LAST_IF_MAIN_DOC_NOT_FOUND') && !empty($objectobj->last_main_doc)) {
360 $file_check_list[] = array(
361 'name' => basename($objectobj->last_main_doc),
362 'path' => DOL_DATA_ROOT .
'/' . $objectobj->last_main_doc,
365 foreach ($file_check_list as $file_check_arr) {
367 $filename_found = $file_check_arr[
'name'];
368 $filepath_found = $file_check_arr[
'path'];
373 if ($filepath_found) {
375 $attachedfilesThirdpartyObj[$thirdpartyid][$objectid] = array(
376 'paths'=>array($filepath_found),
377 'names'=>array($filename_found),
382 $langs->load(
"errors");
383 foreach ($file_check_list as $file_check_arr) {
384 $resaction .=
'<div class="error">'.$langs->trans(
'ErrorCantReadFile', $file_check_arr[
'path']).
'</div><br>';
385 dol_syslog(
'Failed to read file: '.$file_check_arr[
'path'], LOG_WARNING);
392 $listofqualifiedobj[$objectid] = $objectobj;
393 $listofqualifiedref[$objectid] = $objectobj->ref;
400 if (count($listofqualifiedobj) > 0) {
401 $langs->load(
"commercial");
404 $fromtype =
GETPOST(
'fromtype');
405 if ($fromtype ===
'user') {
406 $from =
dol_string_nospecial($user->getFullName($langs),
' ', array(
",")).
' <'.$user->email.
'>';
407 } elseif ($fromtype ===
'company') {
409 } elseif (preg_match(
'/user_aliases_(\d+)/', $fromtype, $reg)) {
410 $tmp = explode(
',', $user->email_aliases);
411 $from = trim($tmp[($reg[1] - 1)]);
412 } elseif (preg_match(
'/global_aliases_(\d+)/', $fromtype, $reg)) {
414 $from = trim($tmp[($reg[1] - 1)]);
415 } elseif (preg_match(
'/senderprofile_(\d+)_(\d+)/', $fromtype, $reg)) {
416 $sql =
"SELECT rowid, label, email FROM ".MAIN_DB_PREFIX.
"c_email_senderprofile WHERE rowid = ".(int) $reg[1];
417 $resql = $db->query($sql);
418 $obj = $db->fetch_object($resql);
427 $subject =
GETPOST(
'subject',
'restricthtml');
428 $message =
GETPOST(
'message',
'restricthtml');
430 $sendtobcc =
GETPOST(
'sendtoccc');
431 if ($objectclass ==
'Propal') {
434 if ($objectclass ==
'Commande') {
437 if ($objectclass ==
'Facture') {
440 if ($objectclass ==
'SupplierProposal') {
441 $sendtobcc .= (!
getDolGlobalString(
'MAIN_MAIL_AUTOCOPY_SUPPLIER_PROPOSAL_TO') ?
'' : (($sendtobcc ?
", " :
"") .
getDolGlobalString(
'MAIN_MAIL_AUTOCOPY_SUPPLIER_PROPOSAL_TO')));
443 if ($objectclass ==
'CommandeFournisseur') {
446 if ($objectclass ==
'FactureFournisseur') {
449 if ($objectclass ==
'Project') {
455 $looparray = array();
456 if (!$oneemailperrecipient) {
457 $looparray = $listofqualifiedobj;
458 foreach ($looparray as $key => $objecttmp) {
459 $looparray[$key]->thirdparty = $thirdparty;
462 $objectforloop =
new $objectclass($db);
463 $objectforloop->thirdparty = $thirdparty;
464 $looparray[0] = $objectforloop;
467 dol_syslog(
"We have set an array of ".count($looparray).
" emails to send. oneemailperrecipient=".$oneemailperrecipient);
469 foreach ($looparray as $objectid => $objecttmp) {
471 if (isModEnabled(
'project') && method_exists($objecttmp,
'fetch_projet') && is_null($objecttmp->project)) {
472 $objecttmp->fetch_projet();
475 $substitutionarray[
'__ID__'] = ($oneemailperrecipient ? join(
', ', array_keys($listofqualifiedobj)) : $objecttmp->id);
476 $substitutionarray[
'__REF__'] = ($oneemailperrecipient ? join(
', ', $listofqualifiedref) : $objecttmp->
ref);
477 $substitutionarray[
'__EMAIL__'] = $thirdparty->email;
478 $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"/>';
480 if ($oneemailperrecipient) {
481 $substitutionarray[
'__ONLINE_PAYMENT_URL__'] =
'';
482 $substitutionarray[
'__ONLINE_PAYMENT_TEXT_AND_URL__'] =
'';
485 $parameters = array(
'mode'=>
'formemail');
487 if (!empty($listofobjectthirdparties)) {
488 $parameters[
'listofobjectthirdparties'] = $listofobjectthirdparties;
490 if (!empty($listofobjectref)) {
491 $parameters[
'listofobjectref'] = $listofobjectref;
499 $attachedfiles = array(
'paths'=>array(),
'names'=>array(),
'mimes'=>array());
500 if ($oneemailperrecipient) {
502 if (is_array($attachedfilesThirdpartyObj[$thirdparty->id]) && count($attachedfilesThirdpartyObj[$thirdparty->id])) {
503 foreach ($attachedfilesThirdpartyObj[$thirdparty->id] as $keyObjId => $objAttachedFiles) {
505 $attachedfiles = array(
506 'paths'=>array_merge($attachedfiles[
'paths'], $objAttachedFiles[
'paths']),
507 'names'=>array_merge($attachedfiles[
'names'], $objAttachedFiles[
'names']),
508 'mimes'=>array_merge($attachedfiles[
'mimes'], $objAttachedFiles[
'mimes'])
512 } elseif (!empty($attachedfilesThirdpartyObj[$thirdparty->id][$objectid])) {
515 $attachedfiles = $attachedfilesThirdpartyObj[$thirdparty->id][$objectid];
518 $filepath = $attachedfiles[
'paths'];
519 $filename = $attachedfiles[
'names'];
520 $mimetype = $attachedfiles[
'mimes'];
523 if ($oneemailperrecipient) {
524 $trackid =
'thi'.$thirdparty->id;
525 if ($objecttmp->element ==
'expensereport') {
526 $trackid =
'use'.$thirdparty->id;
527 } elseif ($objecttmp->element ==
'contact') {
528 $trackid =
'ctc'.$thirdparty->id;
529 } elseif ($objecttmp->element ==
'holiday') {
530 $trackid =
'use'.$thirdparty->id;
533 $trackid = strtolower(get_class($objecttmp));
534 if (get_class($objecttmp) ==
'Contact') {
536 } elseif (get_class($objecttmp) ==
'Contrat') {
538 } elseif (get_class($objecttmp) ==
'Propal') {
540 } elseif (get_class($objecttmp) ==
'Commande') {
542 } elseif (get_class($objecttmp) ==
'Facture') {
544 } elseif (get_class($objecttmp) ==
'SupplierProposal') {
546 } elseif (get_class($objecttmp) ==
'CommandeFournisseur') {
548 } elseif (get_class($objecttmp) ==
'FactureFournisseur') {
552 $trackid .= $objecttmp->id;
558 if (empty($sendcontext)) {
559 $sendcontext =
'standard';
563 $vardir = $conf->user->dir_output.
"/".$user->id;
564 $upload_dir_tmp = $vardir.
'/temp';
567 require_once DOL_DOCUMENT_ROOT.
'/core/class/CMailFile.class.php';
568 $mailfile =
new CMailFile($subjectreplaced, $sendto, $from, $messagereplaced, $filepath, $mimetype, $filename, $sendtocc, $sendtobcc, $deliveryreceipt, -1,
'',
'', $trackid,
'', $sendcontext,
'', $upload_dir_tmp);
569 if ($mailfile->error) {
570 $resaction .=
'<div class="error">'.$mailfile->error.
'</div>';
572 $result = $mailfile->sendfile();
574 $resaction .= $langs->trans(
'MailSuccessfulySent', $mailfile->getValidAddress($mailfile->addr_from, 2), $mailfile->getValidAddress($mailfile->addr_to, 2)).
'<br>';
579 foreach ($listofqualifiedobj as $objid2 => $objectobj2) {
580 if ((!$oneemailperrecipient) && $objid2 != $objectid) {
584 dol_syslog(
"Try to insert email event into agenda for objid=".$objid2.
" => objectobj=".get_class($objectobj2));
593 $actionmsg = $langs->transnoentities(
'MailSentBy').
' '.$from.
' '.$langs->transnoentities(
'To').
' '.$sendto;
596 $actionmsg =
dol_concatdesc($actionmsg, $langs->transnoentities(
'Bcc').
": ".$sendtocc);
598 $actionmsg =
dol_concatdesc($actionmsg, $langs->transnoentities(
'MailTopic').
": ".$subjectreplaced);
599 $actionmsg =
dol_concatdesc($actionmsg, $langs->transnoentities(
'TextUsedInTheMessageBody').
":");
605 $objectobj2->sendtoid = (empty($contactidtosend) ? 0 : $contactidtosend);
606 $objectobj2->actionmsg = $actionmsg;
607 $objectobj2->actionmsg2 = $actionmsg2;
608 $objectobj2->fk_element = $objid2;
609 $objectobj2->elementtype = $objectobj2->element;
611 $objectobj2->actionmsg2 = $subjectreplaced;
614 $triggername = strtoupper(get_class($objectobj2)).
'_SENTBYMAIL';
615 if ($triggername ==
'SOCIETE_SENTBYMAIL') {
616 $triggername =
'COMPANY_SENTBYMAIL';
618 if ($triggername ==
'CONTRAT_SENTBYMAIL') {
619 $triggername =
'CONTRACT_SENTBYMAIL';
621 if ($triggername ==
'COMMANDE_SENTBYMAIL') {
622 $triggername =
'ORDER_SENTBYMAIL';
624 if ($triggername ==
'FACTURE_SENTBYMAIL') {
625 $triggername =
'BILL_SENTBYMAIL';
627 if ($triggername ==
'EXPEDITION_SENTBYMAIL') {
628 $triggername =
'SHIPPING_SENTBYMAIL';
630 if ($triggername ==
'COMMANDEFOURNISSEUR_SENTBYMAIL') {
631 $triggername =
'ORDER_SUPPLIER_SENTBYMAIL';
633 if ($triggername ==
'FACTUREFOURNISSEUR_SENTBYMAIL') {
634 $triggername =
'BILL_SUPPLIER_SENTBYMAIL';
636 if ($triggername ==
'SUPPLIERPROPOSAL_SENTBYMAIL') {
637 $triggername =
'PROPOSAL_SUPPLIER_SENTBYMAIL';
639 if ($triggername ==
'PROJET_SENTBYMAIL') {
640 $triggername =
'PROJECT_SENTBYMAIL';
643 if (!empty($triggername)) {
645 $result = $objectobj2->call_trigger($triggername, $user);
653 dol_syslog(
"Error in trigger ".$triggername.
' '.$db->lasterror(), LOG_ERR);
660 $langs->load(
"other");
661 if ($mailfile->error) {
662 $resaction .= $langs->trans(
'ErrorFailedToSendMail', $from, $sendto);
663 $resaction .=
'<br><div class="error">'.$mailfile->error.
'</div>';
665 $resaction .=
'<div class="warning">No mail sent. Feature is disabled by option MAIN_DISABLE_ALL_MAILS</div>';
667 $resaction .= $langs->trans(
'ErrorFailedToSendMail', $from, $sendto) .
'<br><div class="error">(unhandled error)</div>';
675 $resaction .= ($resaction ?
'<br>' : $resaction);
676 $resaction .=
'<strong>'.$langs->trans(
"ResultOfMailSending").
':</strong><br>'.
"\n";
677 $resaction .= $langs->trans(
"NbSelected").
': '.count($toselect).
"\n<br>";
678 $resaction .= $langs->trans(
"NbIgnored").
': '.($nbignored ? $nbignored : 0).
"\n<br>";
679 $resaction .= $langs->trans(
"NbSent").
': '.($nbsent ? $nbsent : 0).
"\n<br>";
684 setEventMessages($langs->trans(
"EMailSentForNElements", $nbsent.
'/'.count($toselect)),
null,
'mesgs');
697if (!$error && $massaction ==
'cancelorders') {
702 $orders =
GETPOST(
'toselect',
'array');
703 foreach ($orders as $id_order) {
705 if ($cmd->fetch($id_order) <= 0) {
710 $langs->load(
'errors');
711 setEventMessages($langs->trans(
"ErrorObjectMustHaveStatusValidToBeCanceled", $cmd->ref),
null,
'errors');
716 $result = $cmd->cancel();
740if (!$error && $massaction ==
"builddoc" && $permissiontoread && !
GETPOST(
'button_search')) {
741 if (empty($diroutputmassaction)) {
742 dol_print_error(
null,
'include of actions_massactions.inc.php is done but var $diroutputmassaction was not defined');
746 require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
747 require_once DOL_DOCUMENT_ROOT.
'/core/lib/pdf.lib.php';
748 require_once DOL_DOCUMENT_ROOT.
'/core/lib/date.lib.php';
750 $objecttmp =
new $objectclass($db);
751 $listofobjectid = array();
752 $listofobjectthirdparties = array();
753 $listofobjectref = array();
754 foreach ($toselect as $toselectid) {
755 $objecttmp =
new $objectclass($db);
756 $result = $objecttmp->fetch($toselectid);
758 $listofobjectid[$toselectid] = $toselectid;
759 $thirdpartyid = !empty($objecttmp->fk_soc) ? $objecttmp->fk_soc : $objecttmp->socid;
760 $listofobjectthirdparties[$thirdpartyid] = $thirdpartyid;
761 $listofobjectref[$toselectid] = $objecttmp->ref;
765 $arrayofinclusion = array();
766 foreach ($listofobjectref as $tmppdf) {
769 foreach ($listofobjectref as $tmppdf) {
770 $arrayofinclusion[] =
'^'.preg_quote(
dol_sanitizeFileName($tmppdf),
'/').
'_[a-zA-Z0-9\-\_\'\&\.]+\.pdf$';
772 $listoffiles =
dol_dir_list($uploaddir,
'all', 1, implode(
'|', $arrayofinclusion),
'\.meta$|\.png',
'date', SORT_DESC, 0,
true);
776 foreach ($listofobjectref as $basename) {
778 foreach ($listoffiles as $filefound) {
779 if (strstr($filefound[
"name"], $basename)) {
780 $files[] = $uploaddir.
'/'.$basename.
'/'.$filefound[
"name"];
787 $outputlangs = $langs;
790 $newlang =
GETPOST(
'lang_id',
'aZ09');
795 if (!empty($newlang)) {
797 $outputlangs->setDefaultLang($newlang);
806 $filename = preg_replace(
'/\s/',
'_', $filename);
809 if (in_array($objecttmp->element, array(
'facture',
'facture_fournisseur')) && $search_status ==
Facture::STATUS_VALIDATED) {
810 if ($option ==
'late') {
817 $filename .=
'_'.$year;
820 $filename .=
'_'.$month;
823 if (count($files) > 0) {
825 $file = $diroutputmassaction.
'/'.$filename.
'_'.
dol_print_date($now,
'dayhourlog').
'.pdf';
828 foreach ($files as $f) {
829 $input_files .=
' '.escapeshellarg($f);
832 $cmd =
'pdftk '.$input_files.
' cat output '.escapeshellarg($file);
836 if (file_exists($file)) {
839 $langs->load(
"exports");
842 setEventMessages($langs->trans(
'ErrorPDFTkOutputFileNotFound'),
null,
'errors');
845 setEventMessages($langs->trans(
'NoPDFAvailableForDocGenAmongChecked'),
null,
'errors');
850 $page_largeur = $formatarray[
'width'];
851 $page_hauteur = $formatarray[
'height'];
852 $format = array($page_largeur, $page_hauteur);
856 if (class_exists(
'TCPDF')) {
857 $pdf->setPrintHeader(
false);
858 $pdf->setPrintFooter(
false);
863 $pdf->SetCompression(
false);
867 foreach ($files as $file) {
869 $pagecount = $pdf->setSourceFile($file);
870 for ($i = 1; $i <= $pagecount; $i++) {
871 $tplidx = $pdf->importPage($i);
872 $s = $pdf->getTemplatesize($tplidx);
873 $pdf->AddPage($s[
'h'] > $s[
'w'] ?
'P' :
'L');
874 $pdf->useTemplate($tplidx);
883 $filename = preg_replace(
'/\s/',
'_', $filename);
886 if (in_array($objecttmp->element, array(
'facture',
'facture_fournisseur')) && $search_status ==
Facture::STATUS_VALIDATED) {
887 if ($option ==
'late') {
894 $filename .=
'_'.$year;
897 $filename .=
'_'.$month;
901 $file = $diroutputmassaction.
'/'.$filename.
'_'.
dol_print_date($now,
'dayhourlog').
'.pdf';
902 $pdf->Output($file,
'F');
905 $langs->load(
"exports");
908 setEventMessages($langs->trans(
'NoPDFAvailableForDocGenAmongChecked'),
null,
'errors');
914if ($action ==
'remove_file') {
915 require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
917 $langs->load(
"other");
918 $upload_dir = $diroutputmassaction;
919 $file = $upload_dir.
'/'.
GETPOST(
'file');
931if (!$error && $massaction ==
'validate' && $permissiontoadd) {
932 $objecttmp =
new $objectclass($db);
934 if (($objecttmp->element ==
'facture' || $objecttmp->element ==
'invoice') && isModEnabled(
'stock') &&
getDolGlobalString(
'STOCK_CALCULATE_ON_BILL')) {
935 $langs->load(
"errors");
936 setEventMessages($langs->trans(
'ErrorMassValidationNotAllowedWhenStockIncreaseOnAction'),
null,
'errors');
939 if ($objecttmp->element ==
'invoice_supplier' && isModEnabled(
'stock') &&
getDolGlobalString(
'STOCK_CALCULATE_ON_SUPPLIER_BILL')) {
940 $langs->load(
"errors");
941 setEventMessages($langs->trans(
'ErrorMassValidationNotAllowedWhenStockIncreaseOnAction'),
null,
'errors');
944 if ($objecttmp->element ==
'facture') {
947 $sql =
"SELECT rowid FROM ".MAIN_DB_PREFIX.
"facture";
948 $sql .=
" WHERE rowid IN (".$db->sanitize(implode(
",", $toselect)).
")";
949 $sql .=
" ORDER BY datef";
951 $resql = $db->query($sql);
954 while (!empty($arr = $db->fetch_row($resql))) {
955 $toselectnew[] = $arr[0];
957 $toselect = (empty($toselectnew)) ? $toselect : $toselectnew;
968 foreach ($toselect as $toselectid) {
969 $result = $objecttmp->fetch($toselectid);
971 if (method_exists($objecttmp,
'validate')) {
972 $result = $objecttmp->validate($user);
973 } elseif (method_exists($objecttmp,
'setValid')) {
974 $result = $objecttmp->setValid($user);
976 $objecttmp->error =
'No method validate or setValid on this object';
980 $langs->load(
"errors");
981 setEventMessages($langs->trans(
"ErrorObjectMustHaveStatusDraftToBeValidated", $objecttmp->ref),
null,
'errors');
984 } elseif ($result < 0) {
992 $outputlangs = $langs;
995 $newlang =
GETPOST(
'lang_id',
'aZ09');
997 if (
getDolGlobalInt(
'MAIN_MULTILANGS') && empty($newlang) && property_exists($objecttmp,
'thirdparty')) {
998 if ((property_exists($objecttmp,
'socid') || property_exists($objecttmp,
'fk_soc')) && empty($objecttmp->thirdparty)) {
999 $objecttmp->fetch_thirdparty();
1001 if (!empty($objecttmp->thirdparty)) {
1002 $newlang = $objecttmp->thirdparty->default_lang;
1005 if (!empty($newlang)) {
1006 $outputlangs =
new Translate(
"", $conf);
1007 $outputlangs->setDefaultLang($newlang);
1008 $outputlangs->load(
'products');
1010 $model = $objecttmp->model_pdf;
1011 $ret = $objecttmp->fetch($objecttmp->id);
1013 $hidedetails = !empty($hidedetails) ? $hidedetails : (
getDolGlobalString(
'MAIN_GENERATE_DOCUMENTS_HIDE_DETAILS') ? 1 : 0);
1014 $hidedesc = !empty($hidedesc) ? $hidedesc : (
getDolGlobalString(
'MAIN_GENERATE_DOCUMENTS_HIDE_DESC') ? 1 : 0);
1015 $hideref = !empty($hideref) ? $hideref : (
getDolGlobalString(
'MAIN_GENERATE_DOCUMENTS_HIDE_REF') ? 1 : 0);
1016 $moreparams = !empty($moreparams) ? $moreparams :
null;
1018 $result = $objecttmp->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref);
1036 setEventMessages($langs->trans(
"RecordModifiedSuccessfully"),
null,
'mesgs');
1049if (!$error && ($massaction ==
'delete' || ($action ==
'delete' && $confirm ==
'yes')) && $permissiontodelete) {
1052 $objecttmp =
new $objectclass($db);
1057 $unique_arr = array_unique($toselect);
1058 foreach ($unique_arr as $toselectid) {
1059 $result = $objecttmp->fetch($toselectid);
1063 $langs->load(
"errors");
1065 $TMsg[] =
'<div class="error">'.$langs->trans(
'ErrorOnlyDraftStatusCanBeDeletedInMassAction', $objecttmp->ref).
'</div><br>';
1069 if (method_exists($objecttmp,
'is_erasable') && $objecttmp->is_erasable() <= 0) {
1070 $langs->load(
"errors");
1072 $TMsg[] =
'<div class="error">'.$langs->trans(
'ErrorRecordHasChildren').
' '.$objecttmp->ref.
'</div><br>';
1077 $langs->load(
"errors");
1079 $TMsg[] =
'<div class="error">'.$langs->trans(
'ErrorLeaveRequestMustBeDraftCanceledOrRefusedToBeDeleted', $objecttmp->ref).
'</div><br>';
1083 if ($objectclass ==
"Task" && $objecttmp->hasChildren() > 0) {
1084 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"projet_task SET fk_task_parent = 0 WHERE fk_task_parent = ".((int) $objecttmp->id);
1085 $res = $db->query($sql);
1093 if (in_array($objecttmp->element, array(
'societe',
'member'))) {
1094 $result = $objecttmp->delete($objecttmp->id, $user, 1);
1095 } elseif (in_array($objecttmp->element, array(
'action'))) {
1096 $result = $objecttmp->delete();
1098 $result = $objecttmp->delete($user);
1101 if (empty($result)) {
1102 $TMsg = array_merge($objecttmp->errors, $TMsg);
1103 } elseif ($result < 0) {
1117 if (empty($error)) {
1121 } elseif ($nbok > 0) {
1128 if (!empty($TMsg)) {
1143if (!$error && $massaction ==
'generate_doc' && $permissiontoread) {
1145 $objecttmp =
new $objectclass($db);
1147 foreach ($toselect as $toselectid) {
1148 $result = $objecttmp->fetch($toselectid);
1150 $outputlangs = $langs;
1154 $newlang =
GETPOST(
'lang_id',
'aZ09');
1156 if (
getDolGlobalInt(
'MAIN_MULTILANGS') && empty($newlang) && isset($objecttmp->thirdparty->default_lang)) {
1157 $newlang = $objecttmp->thirdparty->default_lang;
1159 if (
getDolGlobalInt(
'MAIN_MULTILANGS') && empty($newlang) && isset($objecttmp->default_lang)) {
1160 $newlang = $objecttmp->default_lang;
1162 if ($conf->global->MAIN_MULTILANGS && empty($newlang) && empty($objecttmp->thirdparty)) {
1163 $objecttmp->fetch_thirdparty();
1164 $newlang = $objecttmp->thirdparty->default_lang;
1166 if (!empty($newlang)) {
1167 $outputlangs =
new Translate(
"", $conf);
1168 $outputlangs->setDefaultLang($newlang);
1172 if (empty($hidedetails)) {
1175 if (empty($hidedesc)) {
1178 if (empty($hideref)) {
1181 if (empty($moreparams)) {
1185 $result = $objecttmp->generateDocument($objecttmp->model_pdf, $outputlangs, $hidedetails, $hidedesc, $hideref, $moreparams);
1213if (!$error && ($action ==
'affecttag' && $confirm ==
'yes') && $permissiontoadd) {
1216 $affecttag_type=
GETPOST(
'affecttag_type',
'alpha');
1217 if (!empty($affecttag_type)) {
1218 $affecttag_type_array=explode(
',', $affecttag_type);
1222 if (!empty($affecttag_type_array)) {
1224 require_once DOL_DOCUMENT_ROOT.
'/categories/class/categorie.class.php';
1226 $to_affecttag_type_array=array();
1227 $categ_type_array=$categ->getMapList();
1228 foreach ($categ_type_array as $categdef) {
1229 if (in_array($categdef[
'code'], $affecttag_type_array)) {
1230 $to_affecttag_type_array[] = $categdef[
'code'];
1236 if (!empty($to_affecttag_type_array)) {
1237 foreach ($to_affecttag_type_array as $categ_type) {
1238 $contcats =
GETPOST(
'contcats_' . $categ_type,
'array');
1240 foreach ($toselect as $toselectid) {
1241 $result = $object->fetch($toselectid);
1244 $result = $object->setCategoriesCommon($contcats, $categ_type,
false);
1273if (!$error && ($action ==
'updateprice' && $confirm ==
'yes') && $permissiontoadd) {
1275 if (GETPOSTISSET(
'pricerate')) {
1276 $pricepercentage=
GETPOST(
'pricerate',
'int');
1277 if ($pricepercentage == 0) {
1280 foreach ($toselect as $toselectid) {
1281 $result = $object->fetch($toselectid);
1284 if ($obj->price_base_type ==
'TTC') {
1285 $newprice = $object->price_ttc * (100 + $pricepercentage) / 100;
1286 $minprice = $object->price_min_ttc;
1288 $newprice = $object->price * (100 + $pricepercentage) / 100;
1289 $minprice = $object->price_min;
1291 $res = $object->updatePrice($newprice, $obj->price_base_type, $user, $object->tva_tx, $minprice, 0, $object->tva_npr, 0, 0, array(), $object->default_vat_code);
1317if (!$error && ($action ==
'setsupervisor' && $confirm ==
'yes') && $permissiontoadd) {
1319 $supervisortoset=
GETPOST(
'supervisortoset');
1320 if (!empty($supervisortoset)) {
1321 foreach ($toselect as $toselectid) {
1322 $result = $object->fetch($toselectid);
1325 $object->fk_user = $supervisortoset;
1326 $res = $object->update($user);
1356if (!$error && ($action ==
'affectuser' && $confirm ==
'yes') && $permissiontoadd) {
1359 $usertoaffect=
GETPOST(
'usertoaffect');
1360 $projectrole=
GETPOST(
'projectrole');
1361 $tasksrole=
GETPOST(
'tasksrole');
1362 if (!empty($usertoaffect)) {
1363 foreach ($toselect as $toselectid) {
1364 $result = $object->fetch($toselectid);
1367 $res = $object->add_contact($usertoaffect, $projectrole,
'internal');
1369 $taskstatic =
new Task($db);
1370 $task_array = $taskstatic->getTasksArray(0, 0, $object->id, 0, 0);
1372 foreach ($task_array as $task) {
1373 $tasksToAffect =
new Task($db);
1374 $result = $tasksToAffect->fetch($task->id);
1376 $res = $tasksToAffect->add_contact($usertoaffect, $tasksrole,
'internal');
1410if (!$error && ($massaction ==
'enable' || ($action ==
'enable' && $confirm ==
'yes')) && $permissiontoadd) {
1413 $objecttmp =
new $objectclass($db);
1415 foreach ($toselect as $toselectid) {
1416 $result = $objecttmp->fetch($toselectid);
1418 if (in_array($objecttmp->element, array(
'societe'))) {
1419 $result =$objecttmp->setStatut(1);
1447if (!$error && ($massaction ==
'disable' || ($action ==
'disable' && $confirm ==
'yes')) && $permissiontoadd) {
1450 $objecttmp =
new $objectclass($db);
1452 foreach ($toselect as $toselectid) {
1453 $result = $objecttmp->fetch($toselectid);
1455 if (in_array($objecttmp->element, array(
'societe'))) {
1456 $result =$objecttmp->setStatut(0);
1484if (!$error && $action ==
'confirm_edit_value_extrafields' && $confirm ==
'yes' && $permissiontoadd) {
1487 $objecttmp =
new $objectclass($db);
1489 $e->fetch_name_optionals_label($objecttmp->table_element);
1492 $extrafieldKeyToUpdate =
GETPOST(
'extrafield-key-to-update');
1495 foreach ($toselect as $toselectid) {
1497 $objecttmp =
new $objectclass($db);
1498 $result = $objecttmp->fetch($toselectid);
1501 $ret = $e->setOptionalsFromPost(
null, $objecttmp, $extrafieldKeyToUpdate);
1503 $objecttmp->insertExtraFields();
1527if (!$error && ($massaction ==
'affectcommercial' || ($action ==
'affectcommercial' && $confirm ==
'yes')) && $permissiontoadd) {
1530 $objecttmp =
new $objectclass($db);
1533 foreach ($toselect as $toselectid) {
1534 $result = $objecttmp->fetch($toselectid);
1536 if (in_array($objecttmp->element, array(
'societe'))) {
1537 $result = $objecttmp->setSalesRep(
GETPOST(
"commercial",
"alpha"));
1555 setEventMessages($langs->trans(
"CommercialsAffected", $nbok),
null,
'mesgs');
1566if (!$error && ($massaction ==
'approveleave' || ($action ==
'approveleave' && $confirm ==
'yes')) && $permissiontoapprove) {
1569 $objecttmp =
new $objectclass($db);
1571 foreach ($toselect as $toselectid) {
1572 $result = $objecttmp->fetch($toselectid);
1575 setEventMessages($langs->trans(
'StatusOfRefMustBe', $objecttmp->ref, $langs->transnoentitiesnoconv(
'Validated')),
null,
'warnings');
1578 if ($user->id == $objecttmp->fk_validator) {
1579 $objecttmp->oldcopy =
dol_clone($objecttmp);
1581 $objecttmp->date_valid =
dol_now();
1582 $objecttmp->fk_user_valid = $user->id;
1585 $verif = $objecttmp->approve($user);
1595 $nbopenedday =
num_open_day($objecttmp->date_debut_gmt, $objecttmp->date_fin_gmt, 0, 1, $objecttmp->halfday);
1596 $soldeActuel = $objecttmp->getCpforUser($objecttmp->fk_user, $objecttmp->fk_type);
1597 $newSolde = ($soldeActuel - $nbopenedday);
1600 $result = $objecttmp->addLogCP($user->id, $objecttmp->fk_user, $langs->transnoentitiesnoconv(
"Holidays"), $newSolde, $objecttmp->fk_type);
1607 $result = $objecttmp->updateSoldeCP($objecttmp->fk_user, $newSolde, $objecttmp->fk_type);
1616 $destinataire =
new User($db);
1617 $destinataire->fetch($objecttmp->fk_user);
1618 $emailTo = $destinataire->email;
1621 dol_syslog(
"User that request leave has no email, so we redirect directly to finished page without sending email");
1624 $expediteur =
new User($db);
1625 $expediteur->fetch($objecttmp->fk_validator);
1627 $emailFrom = $conf->global->MAIN_MAIL_EMAIL_FROM;
1630 $societeName = $conf->global->MAIN_INFO_SOCIETE_NOM;
1632 $societeName = $conf->global->MAIN_APPLICATION_TITLE;
1635 $subject = $societeName.
" - ".$langs->transnoentitiesnoconv(
"HolidaysValidated");
1638 $message = $langs->transnoentitiesnoconv(
"Hello").
" ".$destinataire->firstname.
",\n";
1641 $message .= $langs->transnoentities(
"HolidaysValidatedBody",
dol_print_date($objecttmp->date_debut,
'day'),
dol_print_date($objecttmp->date_fin,
'day')).
"\n";
1643 $message .=
"- ".$langs->transnoentitiesnoconv(
"ValidatedBy").
" : ".
dolGetFirstLastname($expediteur->firstname, $expediteur->lastname).
"\n";
1645 $message .=
"- ".$langs->transnoentitiesnoconv(
"Link").
" : ".$dolibarr_main_url_root.
"/holiday/card.php?id=".$objecttmp->id.
"\n\n";
1648 $trackid =
'leav'.$objecttmp->id;
1650 require_once DOL_DOCUMENT_ROOT.
'/core/class/CMailFile.class.php';
1651 $mail =
new CMailFile($subject, $emailTo, $emailFrom, $message, array(), array(), array(),
'',
'', 0, 0,
'',
'', $trackid);
1654 $result = $mail->sendfile();
1663 $langs->load(
"errors");
1664 setEventMessages($langs->trans(
'ErrorNotApproverForHoliday', $objecttmp->ref),
null,
'errors');
1676 } elseif ($nbok == 1) {
1685if (!$error && ($massaction ==
'increaseholiday' || ($action ==
'increaseholiday' && $confirm ==
'yes')) && $permissiontoapprove) {
1687 $objecttmp =
new $objectclass($db);
1689 $typeholiday =
GETPOST(
'typeholiday',
'alpha');
1690 $nbdaysholidays =
GETPOST(
'nbdaysholidays',
'double');
1692 if ($nbdaysholidays <= 0) {
1698 foreach ($toselect as $toselectid) {
1699 $balancecpuser = $objecttmp->getCPforUser($toselectid, $typeholiday);
1700 if (!empty($balancecpuser)) {
1701 $newnbdaysholidays = $nbdaysholidays + $balancecpuser;
1703 $newnbdaysholidays = $nbdaysholidays;
1705 $result = $holiday->addLogCP($user->id, $toselectid, $langs->transnoentitiesnoconv(
'ManualUpdate'), $newnbdaysholidays, $typeholiday);
1712 $objecttmp->updateSoldeCP($toselectid, $newnbdaysholidays, $typeholiday);
1725 setEventMessages($langs->trans(
"HolidayRecordsIncreased", $nbok),
null,
'mesgs');
1726 } elseif ($nbok == 1) {
1737if (!$error && ($massaction ==
'clonetasks' || ($action ==
'clonetasks' && $confirm ==
'yes'))) {
1742 $origin_task =
new Task($db);
1743 $clone_task =
new Task($db);
1745 foreach (
GETPOST(
'selected') as $task) {
1746 $origin_task->fetch($task, $ref =
'', $loadparentdata = 0);
1749 $obj = !
getDolGlobalString(
'PROJECT_TASK_ADDON') ?
'mod_task_simple' : $conf->global->PROJECT_TASK_ADDON;
1751 require_once DOL_DOCUMENT_ROOT .
"/core/modules/project/task/" .
getDolGlobalString(
'PROJECT_TASK_ADDON') .
'.php';
1752 $modTask =
new $obj();
1753 $defaultref = $modTask->getNextValue(0, $clone_task);
1757 $clone_task->fk_project =
GETPOST(
'projectid',
'int');
1758 $clone_task->ref = $defaultref;
1759 $clone_task->label = $origin_task->label;
1760 $clone_task->description = $origin_task->description;
1761 $clone_task->planned_workload = $origin_task->planned_workload;
1762 $clone_task->fk_task_parent = $origin_task->fk_task_parent;
1763 $clone_task->date_c =
dol_now();
1764 $clone_task->date_start = $origin_task->date_start;
1765 $clone_task->date_end = $origin_task->date_end;
1766 $clone_task->progress = $origin_task->progress;
1769 $ret = $extrafields->setOptionalsFromPost(
null, $clone_task);
1771 $taskid = $clone_task->create($user);
1774 $result = $clone_task->add_contact(
GETPOST(
"userid",
'int'),
'TASKEXECUTIVE',
'internal');
1777 if ($db->lasterrno() ==
'DB_ERROR_RECORD_ALREADY_EXISTS') {
1778 $langs->load(
"projects");
1780 $duplicate_code_error =
true;
1792 header(
"Refresh: 1;URL=".DOL_URL_ROOT.
'/projet/tasks.php?id=' .
GETPOST(
'projectid',
'int'));
1796$parameters[
'toselect'] = (empty($toselect) ? array() : $toselect);
1797$parameters[
'uploaddir'] = $uploaddir;
1798$parameters[
'massaction'] = $massaction;
1799$parameters[
'diroutputmassaction'] = isset($diroutputmassaction) ? $diroutputmassaction :
null;
1801$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.