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 $parameters = array(
'mode'=>
'formemail');
482 if (!empty($listofobjectthirdparties)) {
483 $parameters[
'listofobjectthirdparties'] = $listofobjectthirdparties;
485 if (!empty($listofobjectref)) {
486 $parameters[
'listofobjectref'] = $listofobjectref;
494 $attachedfiles = array(
'paths'=>array(),
'names'=>array(),
'mimes'=>array());
495 if ($oneemailperrecipient) {
497 if (is_array($attachedfilesThirdpartyObj[$thirdparty->id]) && count($attachedfilesThirdpartyObj[$thirdparty->id])) {
498 foreach ($attachedfilesThirdpartyObj[$thirdparty->id] as $keyObjId => $objAttachedFiles) {
500 $attachedfiles = array(
501 'paths'=>array_merge($attachedfiles[
'paths'], $objAttachedFiles[
'paths']),
502 'names'=>array_merge($attachedfiles[
'names'], $objAttachedFiles[
'names']),
503 'mimes'=>array_merge($attachedfiles[
'mimes'], $objAttachedFiles[
'mimes'])
507 } elseif (!empty($attachedfilesThirdpartyObj[$thirdparty->id][$objectid])) {
510 $attachedfiles = $attachedfilesThirdpartyObj[$thirdparty->id][$objectid];
513 $filepath = $attachedfiles[
'paths'];
514 $filename = $attachedfiles[
'names'];
515 $mimetype = $attachedfiles[
'mimes'];
518 if ($oneemailperrecipient) {
519 $trackid =
'thi'.$thirdparty->id;
520 if ($objecttmp->element ==
'expensereport') {
521 $trackid =
'use'.$thirdparty->id;
522 } elseif ($objecttmp->element ==
'contact') {
523 $trackid =
'ctc'.$thirdparty->id;
524 } elseif ($objecttmp->element ==
'holiday') {
525 $trackid =
'use'.$thirdparty->id;
528 $trackid = strtolower(get_class($objecttmp));
529 if (get_class($objecttmp) ==
'Contact') {
531 } elseif (get_class($objecttmp) ==
'Contrat') {
533 } elseif (get_class($objecttmp) ==
'Propal') {
535 } elseif (get_class($objecttmp) ==
'Commande') {
537 } elseif (get_class($objecttmp) ==
'Facture') {
539 } elseif (get_class($objecttmp) ==
'SupplierProposal') {
541 } elseif (get_class($objecttmp) ==
'CommandeFournisseur') {
543 } elseif (get_class($objecttmp) ==
'FactureFournisseur') {
547 $trackid .= $objecttmp->id;
553 if (empty($sendcontext)) {
554 $sendcontext =
'standard';
558 $vardir = $conf->user->dir_output.
"/".$user->id;
559 $upload_dir_tmp = $vardir.
'/temp';
562 require_once DOL_DOCUMENT_ROOT.
'/core/class/CMailFile.class.php';
563 $mailfile =
new CMailFile($subjectreplaced, $sendto, $from, $messagereplaced, $filepath, $mimetype, $filename, $sendtocc, $sendtobcc, $deliveryreceipt, -1,
'',
'', $trackid,
'', $sendcontext,
'', $upload_dir_tmp);
564 if ($mailfile->error) {
565 $resaction .=
'<div class="error">'.$mailfile->error.
'</div>';
567 $result = $mailfile->sendfile();
569 $resaction .= $langs->trans(
'MailSuccessfulySent', $mailfile->getValidAddress($mailfile->addr_from, 2), $mailfile->getValidAddress($mailfile->addr_to, 2)).
'<br>';
574 foreach ($listofqualifiedobj as $objid2 => $objectobj2) {
575 if ((!$oneemailperrecipient) && $objid2 != $objectid) {
579 dol_syslog(
"Try to insert email event into agenda for objid=".$objid2.
" => objectobj=".get_class($objectobj2));
588 $actionmsg = $langs->transnoentities(
'MailSentBy').
' '.$from.
' '.$langs->transnoentities(
'To').
' '.$sendto;
591 $actionmsg =
dol_concatdesc($actionmsg, $langs->transnoentities(
'Bcc').
": ".$sendtocc);
593 $actionmsg =
dol_concatdesc($actionmsg, $langs->transnoentities(
'MailTopic').
": ".$subjectreplaced);
594 $actionmsg =
dol_concatdesc($actionmsg, $langs->transnoentities(
'TextUsedInTheMessageBody').
":");
600 $objectobj2->sendtoid = (empty($contactidtosend) ? 0 : $contactidtosend);
601 $objectobj2->actionmsg = $actionmsg;
602 $objectobj2->actionmsg2 = $actionmsg2;
603 $objectobj2->fk_element = $objid2;
604 $objectobj2->elementtype = $objectobj2->element;
606 $objectobj2->actionmsg2 = $subjectreplaced;
609 $triggername = strtoupper(get_class($objectobj2)).
'_SENTBYMAIL';
610 if ($triggername ==
'SOCIETE_SENTBYMAIL') {
611 $triggername =
'COMPANY_SENTBYMAIL';
613 if ($triggername ==
'CONTRAT_SENTBYMAIL') {
614 $triggername =
'CONTRACT_SENTBYMAIL';
616 if ($triggername ==
'COMMANDE_SENTBYMAIL') {
617 $triggername =
'ORDER_SENTBYMAIL';
619 if ($triggername ==
'FACTURE_SENTBYMAIL') {
620 $triggername =
'BILL_SENTBYMAIL';
622 if ($triggername ==
'EXPEDITION_SENTBYMAIL') {
623 $triggername =
'SHIPPING_SENTBYMAIL';
625 if ($triggername ==
'COMMANDEFOURNISSEUR_SENTBYMAIL') {
626 $triggername =
'ORDER_SUPPLIER_SENTBYMAIL';
628 if ($triggername ==
'FACTUREFOURNISSEUR_SENTBYMAIL') {
629 $triggername =
'BILL_SUPPLIER_SENTBYMAIL';
631 if ($triggername ==
'SUPPLIERPROPOSAL_SENTBYMAIL') {
632 $triggername =
'PROPOSAL_SUPPLIER_SENTBYMAIL';
634 if ($triggername ==
'PROJET_SENTBYMAIL') {
635 $triggername =
'PROJECT_SENTBYMAIL';
638 if (!empty($triggername)) {
640 $result = $objectobj2->call_trigger($triggername, $user);
648 dol_syslog(
"Error in trigger ".$triggername.
' '.$db->lasterror(), LOG_ERR);
655 $langs->load(
"other");
656 if ($mailfile->error) {
657 $resaction .= $langs->trans(
'ErrorFailedToSendMail', $from, $sendto);
658 $resaction .=
'<br><div class="error">'.$mailfile->error.
'</div>';
660 $resaction .=
'<div class="warning">No mail sent. Feature is disabled by option MAIN_DISABLE_ALL_MAILS</div>';
662 $resaction .= $langs->trans(
'ErrorFailedToSendMail', $from, $sendto) .
'<br><div class="error">(unhandled error)</div>';
670 $resaction .= ($resaction ?
'<br>' : $resaction);
671 $resaction .=
'<strong>'.$langs->trans(
"ResultOfMailSending").
':</strong><br>'.
"\n";
672 $resaction .= $langs->trans(
"NbSelected").
': '.count($toselect).
"\n<br>";
673 $resaction .= $langs->trans(
"NbIgnored").
': '.($nbignored ? $nbignored : 0).
"\n<br>";
674 $resaction .= $langs->trans(
"NbSent").
': '.($nbsent ? $nbsent : 0).
"\n<br>";
679 setEventMessages($langs->trans(
"EMailSentForNElements", $nbsent.
'/'.count($toselect)),
null,
'mesgs');
692if (!$error && $massaction ==
'cancelorders') {
697 $orders =
GETPOST(
'toselect',
'array');
698 foreach ($orders as $id_order) {
700 if ($cmd->fetch($id_order) <= 0) {
705 $langs->load(
'errors');
706 setEventMessages($langs->trans(
"ErrorObjectMustHaveStatusValidToBeCanceled", $cmd->ref),
null,
'errors');
711 $result = $cmd->cancel();
735if (!$error && $massaction ==
"builddoc" && $permissiontoread && !
GETPOST(
'button_search')) {
736 if (empty($diroutputmassaction)) {
737 dol_print_error(
null,
'include of actions_massactions.inc.php is done but var $diroutputmassaction was not defined');
741 require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
742 require_once DOL_DOCUMENT_ROOT.
'/core/lib/pdf.lib.php';
743 require_once DOL_DOCUMENT_ROOT.
'/core/lib/date.lib.php';
745 $objecttmp =
new $objectclass($db);
746 $listofobjectid = array();
747 $listofobjectthirdparties = array();
748 $listofobjectref = array();
749 foreach ($toselect as $toselectid) {
750 $objecttmp =
new $objectclass($db);
751 $result = $objecttmp->fetch($toselectid);
753 $listofobjectid[$toselectid] = $toselectid;
754 $thirdpartyid = !empty($objecttmp->fk_soc) ? $objecttmp->fk_soc : $objecttmp->socid;
755 $listofobjectthirdparties[$thirdpartyid] = $thirdpartyid;
756 $listofobjectref[$toselectid] = $objecttmp->ref;
760 $arrayofinclusion = array();
761 foreach ($listofobjectref as $tmppdf) {
764 foreach ($listofobjectref as $tmppdf) {
765 $arrayofinclusion[] =
'^'.preg_quote(
dol_sanitizeFileName($tmppdf),
'/').
'_[a-zA-Z0-9\-\_\'\&\.]+\.pdf$';
767 $listoffiles =
dol_dir_list($uploaddir,
'all', 1, implode(
'|', $arrayofinclusion),
'\.meta$|\.png',
'date', SORT_DESC, 0,
true);
771 foreach ($listofobjectref as $basename) {
773 foreach ($listoffiles as $filefound) {
774 if (strstr($filefound[
"name"], $basename)) {
775 $files[] = $uploaddir.
'/'.$basename.
'/'.$filefound[
"name"];
782 $outputlangs = $langs;
785 $newlang =
GETPOST(
'lang_id',
'aZ09');
790 if (!empty($newlang)) {
792 $outputlangs->setDefaultLang($newlang);
801 $filename = preg_replace(
'/\s/',
'_', $filename);
804 if (in_array($objecttmp->element, array(
'facture',
'facture_fournisseur')) && $search_status ==
Facture::STATUS_VALIDATED) {
805 if ($option ==
'late') {
812 $filename .=
'_'.$year;
815 $filename .=
'_'.$month;
818 if (count($files) > 0) {
820 $file = $diroutputmassaction.
'/'.$filename.
'_'.
dol_print_date($now,
'dayhourlog').
'.pdf';
823 foreach ($files as $f) {
824 $input_files .=
' '.escapeshellarg($f);
827 $cmd =
'pdftk '.$input_files.
' cat output '.escapeshellarg($file);
831 if (file_exists($file)) {
834 $langs->load(
"exports");
837 setEventMessages($langs->trans(
'ErrorPDFTkOutputFileNotFound'),
null,
'errors');
840 setEventMessages($langs->trans(
'NoPDFAvailableForDocGenAmongChecked'),
null,
'errors');
845 $page_largeur = $formatarray[
'width'];
846 $page_hauteur = $formatarray[
'height'];
847 $format = array($page_largeur, $page_hauteur);
851 if (class_exists(
'TCPDF')) {
852 $pdf->setPrintHeader(
false);
853 $pdf->setPrintFooter(
false);
858 $pdf->SetCompression(
false);
862 foreach ($files as $file) {
864 $pagecount = $pdf->setSourceFile($file);
865 for ($i = 1; $i <= $pagecount; $i++) {
866 $tplidx = $pdf->importPage($i);
867 $s = $pdf->getTemplatesize($tplidx);
868 $pdf->AddPage($s[
'h'] > $s[
'w'] ?
'P' :
'L');
869 $pdf->useTemplate($tplidx);
878 $filename = preg_replace(
'/\s/',
'_', $filename);
881 if (in_array($objecttmp->element, array(
'facture',
'facture_fournisseur')) && $search_status ==
Facture::STATUS_VALIDATED) {
882 if ($option ==
'late') {
889 $filename .=
'_'.$year;
892 $filename .=
'_'.$month;
896 $file = $diroutputmassaction.
'/'.$filename.
'_'.
dol_print_date($now,
'dayhourlog').
'.pdf';
897 $pdf->Output($file,
'F');
900 $langs->load(
"exports");
903 setEventMessages($langs->trans(
'NoPDFAvailableForDocGenAmongChecked'),
null,
'errors');
909if ($action ==
'remove_file') {
910 require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
912 $langs->load(
"other");
913 $upload_dir = $diroutputmassaction;
914 $file = $upload_dir.
'/'.
GETPOST(
'file');
926if (!$error && $massaction ==
'validate' && $permissiontoadd) {
927 $objecttmp =
new $objectclass($db);
929 if (($objecttmp->element ==
'facture' || $objecttmp->element ==
'invoice') && isModEnabled(
'stock') &&
getDolGlobalString(
'STOCK_CALCULATE_ON_BILL')) {
930 $langs->load(
"errors");
931 setEventMessages($langs->trans(
'ErrorMassValidationNotAllowedWhenStockIncreaseOnAction'),
null,
'errors');
934 if ($objecttmp->element ==
'invoice_supplier' && isModEnabled(
'stock') &&
getDolGlobalString(
'STOCK_CALCULATE_ON_SUPPLIER_BILL')) {
935 $langs->load(
"errors");
936 setEventMessages($langs->trans(
'ErrorMassValidationNotAllowedWhenStockIncreaseOnAction'),
null,
'errors');
939 if ($objecttmp->element ==
'facture') {
942 $sql =
"SELECT rowid FROM ".MAIN_DB_PREFIX.
"facture";
943 $sql .=
" WHERE rowid IN (".$db->sanitize(implode(
",", $toselect)).
")";
944 $sql .=
" ORDER BY datef";
946 $resql = $db->query($sql);
949 while (!empty($arr = $db->fetch_row($resql))) {
950 $toselectnew[] = $arr[0];
952 $toselect = (empty($toselectnew)) ? $toselect : $toselectnew;
963 foreach ($toselect as $toselectid) {
964 $result = $objecttmp->fetch($toselectid);
966 if (method_exists($objecttmp,
'validate')) {
967 $result = $objecttmp->validate($user);
968 } elseif (method_exists($objecttmp,
'setValid')) {
969 $result = $objecttmp->setValid($user);
971 $objecttmp->error =
'No method validate or setValid on this object';
975 $langs->load(
"errors");
976 setEventMessages($langs->trans(
"ErrorObjectMustHaveStatusDraftToBeValidated", $objecttmp->ref),
null,
'errors');
979 } elseif ($result < 0) {
987 $outputlangs = $langs;
990 $newlang =
GETPOST(
'lang_id',
'aZ09');
992 if (
getDolGlobalInt(
'MAIN_MULTILANGS') && empty($newlang) && property_exists($objecttmp,
'thirdparty')) {
993 if ((property_exists($objecttmp,
'socid') || property_exists($objecttmp,
'fk_soc')) && empty($objecttmp->thirdparty)) {
994 $objecttmp->fetch_thirdparty();
996 if (!empty($objecttmp->thirdparty)) {
997 $newlang = $objecttmp->thirdparty->default_lang;
1000 if (!empty($newlang)) {
1001 $outputlangs =
new Translate(
"", $conf);
1002 $outputlangs->setDefaultLang($newlang);
1003 $outputlangs->load(
'products');
1005 $model = $objecttmp->model_pdf;
1006 $ret = $objecttmp->fetch($objecttmp->id);
1008 $hidedetails = !empty($hidedetails) ? $hidedetails : (
getDolGlobalString(
'MAIN_GENERATE_DOCUMENTS_HIDE_DETAILS') ? 1 : 0);
1009 $hidedesc = !empty($hidedesc) ? $hidedesc : (
getDolGlobalString(
'MAIN_GENERATE_DOCUMENTS_HIDE_DESC') ? 1 : 0);
1010 $hideref = !empty($hideref) ? $hideref : (
getDolGlobalString(
'MAIN_GENERATE_DOCUMENTS_HIDE_REF') ? 1 : 0);
1011 $moreparams = !empty($moreparams) ? $moreparams :
null;
1013 $result = $objecttmp->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref);
1031 setEventMessages($langs->trans(
"RecordModifiedSuccessfully"),
null,
'mesgs');
1044if (!$error && ($massaction ==
'delete' || ($action ==
'delete' && $confirm ==
'yes')) && $permissiontodelete) {
1047 $objecttmp =
new $objectclass($db);
1052 $unique_arr = array_unique($toselect);
1053 foreach ($unique_arr as $toselectid) {
1054 $result = $objecttmp->fetch($toselectid);
1058 $langs->load(
"errors");
1060 $TMsg[] =
'<div class="error">'.$langs->trans(
'ErrorOnlyDraftStatusCanBeDeletedInMassAction', $objecttmp->ref).
'</div><br>';
1064 if (method_exists($objecttmp,
'is_erasable') && $objecttmp->is_erasable() <= 0) {
1065 $langs->load(
"errors");
1067 $TMsg[] =
'<div class="error">'.$langs->trans(
'ErrorRecordHasChildren').
' '.$objecttmp->ref.
'</div><br>';
1072 $langs->load(
"errors");
1074 $TMsg[] =
'<div class="error">'.$langs->trans(
'ErrorLeaveRequestMustBeDraftCanceledOrRefusedToBeDeleted', $objecttmp->ref).
'</div><br>';
1078 if ($objectclass ==
"Task" && $objecttmp->hasChildren() > 0) {
1079 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"projet_task SET fk_task_parent = 0 WHERE fk_task_parent = ".((int) $objecttmp->id);
1080 $res = $db->query($sql);
1088 if (in_array($objecttmp->element, array(
'societe',
'member'))) {
1089 $result = $objecttmp->delete($objecttmp->id, $user, 1);
1090 } elseif (in_array($objecttmp->element, array(
'action'))) {
1091 $result = $objecttmp->delete();
1093 $result = $objecttmp->delete($user);
1096 if (empty($result)) {
1097 $TMsg = array_merge($objecttmp->errors, $TMsg);
1098 } elseif ($result < 0) {
1112 if (empty($error)) {
1116 } elseif ($nbok > 0) {
1123 if (!empty($TMsg)) {
1138if (!$error && $massaction ==
'generate_doc' && $permissiontoread) {
1140 $objecttmp =
new $objectclass($db);
1142 foreach ($toselect as $toselectid) {
1143 $result = $objecttmp->fetch($toselectid);
1145 $outputlangs = $langs;
1149 $newlang =
GETPOST(
'lang_id',
'aZ09');
1151 if (
getDolGlobalInt(
'MAIN_MULTILANGS') && empty($newlang) && isset($objecttmp->thirdparty->default_lang)) {
1152 $newlang = $objecttmp->thirdparty->default_lang;
1154 if (
getDolGlobalInt(
'MAIN_MULTILANGS') && empty($newlang) && isset($objecttmp->default_lang)) {
1155 $newlang = $objecttmp->default_lang;
1157 if ($conf->global->MAIN_MULTILANGS && empty($newlang) && empty($objecttmp->thirdparty)) {
1158 $objecttmp->fetch_thirdparty();
1159 $newlang = $objecttmp->thirdparty->default_lang;
1161 if (!empty($newlang)) {
1162 $outputlangs =
new Translate(
"", $conf);
1163 $outputlangs->setDefaultLang($newlang);
1167 if (empty($hidedetails)) {
1170 if (empty($hidedesc)) {
1173 if (empty($hideref)) {
1176 if (empty($moreparams)) {
1180 $result = $objecttmp->generateDocument($objecttmp->model_pdf, $outputlangs, $hidedetails, $hidedesc, $hideref, $moreparams);
1208if (!$error && ($action ==
'affecttag' && $confirm ==
'yes') && $permissiontoadd) {
1211 $affecttag_type=
GETPOST(
'affecttag_type',
'alpha');
1212 if (!empty($affecttag_type)) {
1213 $affecttag_type_array=explode(
',', $affecttag_type);
1217 if (!empty($affecttag_type_array)) {
1219 require_once DOL_DOCUMENT_ROOT.
'/categories/class/categorie.class.php';
1221 $to_affecttag_type_array=array();
1222 $categ_type_array=$categ->getMapList();
1223 foreach ($categ_type_array as $categdef) {
1224 if (in_array($categdef[
'code'], $affecttag_type_array)) {
1225 $to_affecttag_type_array[] = $categdef[
'code'];
1231 if (!empty($to_affecttag_type_array)) {
1232 foreach ($to_affecttag_type_array as $categ_type) {
1233 $contcats =
GETPOST(
'contcats_' . $categ_type,
'array');
1235 foreach ($toselect as $toselectid) {
1236 $result = $object->fetch($toselectid);
1239 $result = $object->setCategoriesCommon($contcats, $categ_type,
false);
1268if (!$error && ($action ==
'updateprice' && $confirm ==
'yes') && $permissiontoadd) {
1270 if (GETPOSTISSET(
'pricerate')) {
1271 $pricepercentage=
GETPOST(
'pricerate',
'int');
1272 if ($pricepercentage == 0) {
1275 foreach ($toselect as $toselectid) {
1276 $result = $object->fetch($toselectid);
1279 if ($obj->price_base_type ==
'TTC') {
1280 $newprice = $object->price_ttc * (100 + $pricepercentage) / 100;
1281 $minprice = $object->price_min_ttc;
1283 $newprice = $object->price * (100 + $pricepercentage) / 100;
1284 $minprice = $object->price_min;
1286 $res = $object->updatePrice($newprice, $obj->price_base_type, $user, $object->tva_tx, $minprice, 0, $object->tva_npr, 0, 0, array(), $object->default_vat_code);
1312if (!$error && ($action ==
'setsupervisor' && $confirm ==
'yes') && $permissiontoadd) {
1314 $supervisortoset=
GETPOST(
'supervisortoset');
1315 if (!empty($supervisortoset)) {
1316 foreach ($toselect as $toselectid) {
1317 $result = $object->fetch($toselectid);
1320 $object->fk_user = $supervisortoset;
1321 $res = $object->update($user);
1351if (!$error && ($action ==
'affectuser' && $confirm ==
'yes') && $permissiontoadd) {
1354 $usertoaffect=
GETPOST(
'usertoaffect');
1355 $projectrole=
GETPOST(
'projectrole');
1356 $tasksrole=
GETPOST(
'tasksrole');
1357 if (!empty($usertoaffect)) {
1358 foreach ($toselect as $toselectid) {
1359 $result = $object->fetch($toselectid);
1362 $res = $object->add_contact($usertoaffect, $projectrole,
'internal');
1364 $taskstatic =
new Task($db);
1365 $task_array = $taskstatic->getTasksArray(0, 0, $object->id, 0, 0);
1367 foreach ($task_array as $task) {
1368 $tasksToAffect =
new Task($db);
1369 $result = $tasksToAffect->fetch($task->id);
1371 $res = $tasksToAffect->add_contact($usertoaffect, $tasksrole,
'internal');
1405if (!$error && ($massaction ==
'enable' || ($action ==
'enable' && $confirm ==
'yes')) && $permissiontoadd) {
1408 $objecttmp =
new $objectclass($db);
1410 foreach ($toselect as $toselectid) {
1411 $result = $objecttmp->fetch($toselectid);
1413 if (in_array($objecttmp->element, array(
'societe'))) {
1414 $result =$objecttmp->setStatut(1);
1442if (!$error && ($massaction ==
'disable' || ($action ==
'disable' && $confirm ==
'yes')) && $permissiontoadd) {
1445 $objecttmp =
new $objectclass($db);
1447 foreach ($toselect as $toselectid) {
1448 $result = $objecttmp->fetch($toselectid);
1450 if (in_array($objecttmp->element, array(
'societe'))) {
1451 $result =$objecttmp->setStatut(0);
1479if (!$error && $action ==
'confirm_edit_value_extrafields' && $confirm ==
'yes' && $permissiontoadd) {
1482 $objecttmp =
new $objectclass($db);
1484 $e->fetch_name_optionals_label($objecttmp->table_element);
1487 $extrafieldKeyToUpdate =
GETPOST(
'extrafield-key-to-update');
1490 foreach ($toselect as $toselectid) {
1492 $objecttmp =
new $objectclass($db);
1493 $result = $objecttmp->fetch($toselectid);
1496 $ret = $e->setOptionalsFromPost(
null, $objecttmp, $extrafieldKeyToUpdate);
1498 $objecttmp->insertExtraFields();
1522if (!$error && ($massaction ==
'affectcommercial' || ($action ==
'affectcommercial' && $confirm ==
'yes')) && $permissiontoadd) {
1525 $objecttmp =
new $objectclass($db);
1528 foreach ($toselect as $toselectid) {
1529 $result = $objecttmp->fetch($toselectid);
1531 if (in_array($objecttmp->element, array(
'societe'))) {
1532 $result = $objecttmp->setSalesRep(
GETPOST(
"commercial",
"alpha"));
1550 setEventMessages($langs->trans(
"CommercialsAffected", $nbok),
null,
'mesgs');
1561if (!$error && ($massaction ==
'approveleave' || ($action ==
'approveleave' && $confirm ==
'yes')) && $permissiontoapprove) {
1564 $objecttmp =
new $objectclass($db);
1566 foreach ($toselect as $toselectid) {
1567 $result = $objecttmp->fetch($toselectid);
1570 setEventMessages($langs->trans(
'StatusOfRefMustBe', $objecttmp->ref, $langs->transnoentitiesnoconv(
'Validated')),
null,
'warnings');
1573 if ($user->id == $objecttmp->fk_validator) {
1574 $objecttmp->oldcopy =
dol_clone($objecttmp);
1576 $objecttmp->date_valid =
dol_now();
1577 $objecttmp->fk_user_valid = $user->id;
1580 $verif = $objecttmp->approve($user);
1590 $nbopenedday =
num_open_day($objecttmp->date_debut_gmt, $objecttmp->date_fin_gmt, 0, 1, $objecttmp->halfday);
1591 $soldeActuel = $objecttmp->getCpforUser($objecttmp->fk_user, $objecttmp->fk_type);
1592 $newSolde = ($soldeActuel - $nbopenedday);
1595 $result = $objecttmp->addLogCP($user->id, $objecttmp->fk_user, $langs->transnoentitiesnoconv(
"Holidays"), $newSolde, $objecttmp->fk_type);
1602 $result = $objecttmp->updateSoldeCP($objecttmp->fk_user, $newSolde, $objecttmp->fk_type);
1611 $destinataire =
new User($db);
1612 $destinataire->fetch($objecttmp->fk_user);
1613 $emailTo = $destinataire->email;
1616 dol_syslog(
"User that request leave has no email, so we redirect directly to finished page without sending email");
1619 $expediteur =
new User($db);
1620 $expediteur->fetch($objecttmp->fk_validator);
1622 $emailFrom = $conf->global->MAIN_MAIL_EMAIL_FROM;
1625 $societeName = $conf->global->MAIN_INFO_SOCIETE_NOM;
1627 $societeName = $conf->global->MAIN_APPLICATION_TITLE;
1630 $subject = $societeName.
" - ".$langs->transnoentitiesnoconv(
"HolidaysValidated");
1633 $message = $langs->transnoentitiesnoconv(
"Hello").
" ".$destinataire->firstname.
",\n";
1636 $message .= $langs->transnoentities(
"HolidaysValidatedBody",
dol_print_date($objecttmp->date_debut,
'day'),
dol_print_date($objecttmp->date_fin,
'day')).
"\n";
1638 $message .=
"- ".$langs->transnoentitiesnoconv(
"ValidatedBy").
" : ".
dolGetFirstLastname($expediteur->firstname, $expediteur->lastname).
"\n";
1640 $message .=
"- ".$langs->transnoentitiesnoconv(
"Link").
" : ".$dolibarr_main_url_root.
"/holiday/card.php?id=".$objecttmp->id.
"\n\n";
1643 $trackid =
'leav'.$objecttmp->id;
1645 require_once DOL_DOCUMENT_ROOT.
'/core/class/CMailFile.class.php';
1646 $mail =
new CMailFile($subject, $emailTo, $emailFrom, $message, array(), array(), array(),
'',
'', 0, 0,
'',
'', $trackid);
1649 $result = $mail->sendfile();
1658 $langs->load(
"errors");
1659 setEventMessages($langs->trans(
'ErrorNotApproverForHoliday', $objecttmp->ref),
null,
'errors');
1671 } elseif ($nbok == 1) {
1680if (!$error && ($massaction ==
'increaseholiday' || ($action ==
'increaseholiday' && $confirm ==
'yes')) && $permissiontoapprove) {
1682 $objecttmp =
new $objectclass($db);
1684 $typeholiday =
GETPOST(
'typeholiday',
'alpha');
1685 $nbdaysholidays =
GETPOST(
'nbdaysholidays',
'double');
1687 if ($nbdaysholidays <= 0) {
1693 foreach ($toselect as $toselectid) {
1694 $balancecpuser = $objecttmp->getCPforUser($toselectid, $typeholiday);
1695 if (!empty($balancecpuser)) {
1696 $newnbdaysholidays = $nbdaysholidays + $balancecpuser;
1698 $newnbdaysholidays = $nbdaysholidays;
1700 $result = $holiday->addLogCP($user->id, $toselectid, $langs->transnoentitiesnoconv(
'ManualUpdate'), $newnbdaysholidays, $typeholiday);
1707 $objecttmp->updateSoldeCP($toselectid, $newnbdaysholidays, $typeholiday);
1720 setEventMessages($langs->trans(
"HolidayRecordsIncreased", $nbok),
null,
'mesgs');
1721 } elseif ($nbok == 1) {
1732if (!$error && ($massaction ==
'clonetasks' || ($action ==
'clonetasks' && $confirm ==
'yes'))) {
1737 $origin_task =
new Task($db);
1738 $clone_task =
new Task($db);
1740 foreach (
GETPOST(
'selected') as $task) {
1741 $origin_task->fetch($task, $ref =
'', $loadparentdata = 0);
1744 $obj = !
getDolGlobalString(
'PROJECT_TASK_ADDON') ?
'mod_task_simple' : $conf->global->PROJECT_TASK_ADDON;
1746 require_once DOL_DOCUMENT_ROOT .
"/core/modules/project/task/" .
getDolGlobalString(
'PROJECT_TASK_ADDON') .
'.php';
1747 $modTask =
new $obj();
1748 $defaultref = $modTask->getNextValue(0, $clone_task);
1752 $clone_task->fk_project =
GETPOST(
'projectid',
'int');
1753 $clone_task->ref = $defaultref;
1754 $clone_task->label = $origin_task->label;
1755 $clone_task->description = $origin_task->description;
1756 $clone_task->planned_workload = $origin_task->planned_workload;
1757 $clone_task->fk_task_parent = $origin_task->fk_task_parent;
1758 $clone_task->date_c =
dol_now();
1759 $clone_task->date_start = $origin_task->date_start;
1760 $clone_task->date_end = $origin_task->date_end;
1761 $clone_task->progress = $origin_task->progress;
1764 $ret = $extrafields->setOptionalsFromPost(
null, $clone_task);
1766 $taskid = $clone_task->create($user);
1769 $result = $clone_task->add_contact(
GETPOST(
"userid",
'int'),
'TASKEXECUTIVE',
'internal');
1772 if ($db->lasterrno() ==
'DB_ERROR_RECORD_ALREADY_EXISTS') {
1773 $langs->load(
"projects");
1775 $duplicate_code_error =
true;
1787 header(
"Refresh: 1;URL=".DOL_URL_ROOT.
'/projet/tasks.php?id=' .
GETPOST(
'projectid',
'int'));
1791$parameters[
'toselect'] = (empty($toselect) ? array() : $toselect);
1792$parameters[
'uploaddir'] = $uploaddir;
1793$parameters[
'massaction'] = $massaction;
1794$parameters[
'diroutputmassaction'] = isset($diroutputmassaction) ? $diroutputmassaction :
null;
1796$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.