40 if (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');
44 if (empty($massaction)) {
50 if (!empty($permtoread) && empty($permissiontoread)) {
51 $permissiontoread = $permtoread;
53 if (!empty($permtocreate) && empty($permissiontoadd)) {
54 $permissiontoadd = $permtocreate;
56 if (!empty($permtodelete) && empty($permissiontodelete)) {
57 $permissiontodelete = $permtodelete;
61 $maxformassaction = (empty($conf->global->MAIN_LIMIT_FOR_MASS_ACTIONS) ? 1000 : $conf->global->MAIN_LIMIT_FOR_MASS_ACTIONS);
62 if ($massaction && is_array($toselect) && count($toselect) < 1) {
66 if (!$error && isset($toselect) && is_array($toselect) && count($toselect) > $maxformassaction) {
67 setEventMessages($langs->trans(
'TooManyRecordForMassAction', $maxformassaction),
null,
'errors');
71 if (!$error && $massaction ==
'confirm_presend' && !
GETPOST(
'sendmail')) {
72 $massaction =
'presend';
74 if (!$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);
93 $objecttmp =
new $objectclass($db);
94 if ($objecttmp->element ==
'expensereport') {
95 $thirdparty =
new User($db);
96 } elseif ($objecttmp->element ==
'contact') {
98 } elseif ($objecttmp->element ==
'partnership' &&
getDolGlobalString(
'PARTNERSHIP_IS_MANAGED_FOR') ==
'member') {
100 } elseif ($objecttmp->element ==
'holiday') {
101 $thirdparty =
new User($db);
104 foreach ($toselect as $toselectid) {
105 $objecttmp =
new $objectclass($db);
106 $result = $objecttmp->fetch($toselectid);
108 $listofobjectid[$toselectid] = $toselectid;
110 $thirdpartyid = ($objecttmp->fk_soc ? $objecttmp->fk_soc : $objecttmp->socid);
111 if ($objecttmp->element ==
'societe') {
112 $thirdpartyid = $objecttmp->id;
113 } elseif ($objecttmp->element ==
'contact') {
114 $thirdpartyid = $objecttmp->id;
115 } elseif ($objecttmp->element ==
'expensereport') {
116 $thirdpartyid = $objecttmp->fk_user_author;
117 } elseif ($objecttmp->element ==
'partnership' &&
getDolGlobalString(
'PARTNERSHIP_IS_MANAGED_FOR') ==
'member') {
118 $thirdpartyid = $objecttmp->fk_member;
119 } elseif ($objecttmp->element ==
'holiday') {
120 $thirdpartyid = $objecttmp->fk_user;
122 if (empty($thirdpartyid)) {
126 if ($objectclass ==
'Facture') {
127 $tmparraycontact = array();
128 $tmparraycontact = $objecttmp->liste_contact(-1,
'external', 0,
'BILLING');
129 if (is_array($tmparraycontact) && count($tmparraycontact) > 0) {
130 foreach ($tmparraycontact as $data_email) {
131 $listofobjectcontacts[$toselectid][$data_email[
'id']] = $data_email[
'email'];
134 } elseif ($objectclass ==
'CommandeFournisseur') {
135 $tmparraycontact = array();
136 $tmparraycontact = $objecttmp->liste_contact(-1,
'external', 0,
'CUSTOMER');
137 if (is_array($tmparraycontact) && count($tmparraycontact) > 0) {
138 foreach ($tmparraycontact as $data_email) {
139 $listofobjectcontacts[$toselectid][$data_email[
'id']] = $data_email[
'email'];
144 $listofobjectthirdparties[$thirdpartyid] = $thirdpartyid;
145 $listofobjectref[$thirdpartyid][$toselectid] = $objecttmp;
151 if (
GETPOST(
'fromtype',
'alpha') ===
'user' && empty($user->email)) {
154 $massaction =
'presend';
157 $receiver =
GETPOST(
'receiver',
'alphawithlgt');
158 if (!is_array($receiver)) {
159 if (empty($receiver) || $receiver ==
'-1') {
162 $receiver = array($receiver);
165 if (!trim($_POST[
'sendto']) && count($receiver) == 0 && count($listofobjectthirdparties) == 1) {
167 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Recipient")),
null,
'warnings');
168 $massaction =
'presend';
171 if (!
GETPOST(
'subject',
'restricthtml')) {
173 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"MailTopic")),
null,
'warnings');
174 $massaction =
'presend';
179 foreach ($listofobjectthirdparties as $thirdpartyid) {
180 $result = $thirdparty->fetch($thirdpartyid);
193 if (trim($_POST[
'sendto'])) {
195 $tmparray[] = trim(
GETPOST(
'sendto',
'alphawithlgt'));
197 if (count($receiver) > 0) {
198 foreach ($receiver as $key => $val) {
200 if ($val ==
'thirdparty') {
201 $tmparray[] = $thirdparty->name.
' <'.$thirdparty->email.
'>';
202 } elseif ($val && method_exists($thirdparty,
'contact_get_property')) {
203 $tmparray[] = $thirdparty->contact_get_property((
int) $val,
'email');
208 $sendto = implode(
',', $tmparray);
211 $receivercc =
GETPOST(
'receivercc',
'alphawithlgt');
212 if (!is_array($receivercc)) {
213 if ($receivercc ==
'-1') {
214 $receivercc = array();
216 $receivercc = array($receivercc);
220 if (trim($_POST[
'sendtocc'])) {
221 $tmparray[] = trim(
GETPOST(
'sendtocc',
'alphawithlgt'));
223 if (count($receivercc) > 0) {
224 foreach ($receivercc as $key => $val) {
226 if ($val ==
'thirdparty') {
227 $tmparray[] = $thirdparty->name.
' <'.$thirdparty->email.
'>';
229 $tmparray[] = $thirdparty->contact_get_property((
int) $val,
'email');
234 $sendtocc = implode(
',', $tmparray);
237 $listofqualifiedobj = array();
238 $listofqualifiedref = array();
239 $thirdpartywithoutemail = array();
241 foreach ($listofobjectref[$thirdpartyid] as $objectid => $objectobj) {
244 $langs->load(
"errors");
246 $resaction .=
'<div class="error">'.$langs->trans(
'ErrorOnlyProposalNotDraftCanBeSentInMassAction', $objectobj->ref).
'</div><br>';
250 $langs->load(
"errors");
252 $resaction .=
'<div class="error">'.$langs->trans(
'ErrorOnlyOrderNotDraftCanBeSentInMassAction', $objectobj->ref).
'</div><br>';
256 $langs->load(
"errors");
258 $resaction .=
'<div class="error">'.$langs->trans(
'ErrorOnlyInvoiceValidatedCanBeSentInMassAction', $objectobj->ref).
'</div><br>';
263 if (empty($sendto)) {
264 if ($objectobj->element ==
'societe') {
265 $sendto = $objectobj->email;
266 } elseif ($objectobj->element ==
'expensereport') {
267 $fuser =
new User($db);
268 $fuser->fetch($objectobj->fk_user_author);
269 $sendto = $fuser->email;
270 } elseif ($objectobj->element ==
'contact') {
272 $fcontact->fetch($objectobj->id);
273 $sendto = $fcontact->email;
274 } elseif ($objectobj->element ==
'partnership' &&
getDolGlobalString(
'PARTNERSHIP_IS_MANAGED_FOR') ==
'member') {
276 $fadherent->fetch($objectobj->fk_member);
277 $sendto = $fadherent->email;
278 } elseif ($objectobj->element ==
'holiday') {
279 $fuser =
new User($db);
280 $fuser->fetch($objectobj->fk_user);
281 $sendto = $fuser->email;
282 } elseif ($objectobj->element ==
'facture' && !empty($listofobjectcontacts[$objectid])) {
283 $emails_to_sends = array();
284 $objectobj->fetch_thirdparty();
285 $contactidtosend = array();
286 foreach ($listofobjectcontacts[$objectid] as $contactemailid => $contactemailemail) {
287 $emails_to_sends[] = $objectobj->thirdparty->contact_get_property($contactemailid,
'email');
288 if (!in_array($contactemailid, $contactidtosend)) {
289 $contactidtosend[] = $contactemailid;
292 if (count($emails_to_sends) > 0) {
293 $sendto = implode(
',', $emails_to_sends);
295 } elseif ($objectobj->element ==
'order_supplier' && !empty($listofobjectcontacts[$objectid])) {
296 $emails_to_sends = array();
297 $objectobj->fetch_thirdparty();
298 $contactidtosend = array();
299 foreach ($listofobjectcontacts[$objectid] as $contactemailid => $contactemailemail) {
300 $emails_to_sends[] = $objectobj->thirdparty->contact_get_property($contactemailid,
'email');
301 if (!in_array($contactemailid, $contactidtosend)) {
302 $contactidtosend[] = $contactemailid;
305 if (count($emails_to_sends) > 0) {
306 $sendto = implode(
',', $emails_to_sends);
309 $objectobj->fetch_thirdparty();
310 $sendto = $objectobj->thirdparty->email;
314 if (empty($sendto)) {
315 if ($objectobj->element ==
'societe') {
316 $objectobj->thirdparty = $objectobj;
321 if (empty($thirdpartywithoutemail[$objectobj->thirdparty->id])) {
322 $resaction .=
'<div class="error">'.$langs->trans(
'NoRecipientEmail', $objectobj->thirdparty->name).
'</div><br>';
324 dol_syslog(
'No recipient for thirdparty: '.$objectobj->thirdparty->name, LOG_WARNING);
325 $thirdpartywithoutemail[$objectobj->thirdparty->id] = 1;
329 if (
GETPOST(
'addmaindocfile')) {
336 $filedir = $uploaddir.
'/'.$subdir.dol_sanitizeFileName($objectobj->ref);
337 $filepath = $filedir.
'/'.$filename;
340 if ($objectobj->element ==
'invoice_supplier') {
341 $fileparams =
dol_most_recent_file($uploaddir.
'/'.
get_exdir($objectobj->id, 2, 0, 0, $objectobj, $objectobj->element).$objectobj->ref, preg_quote($objectobj->ref,
'/').
'([^\-])+');
342 $filepath = $fileparams[
'fullname'];
346 $filename_found =
'';
347 $filepath_found =
'';
348 $file_check_list = array();
349 $file_check_list[] = array(
353 if (!empty($conf->global->MAIL_MASS_ACTION_ADD_LAST_IF_MAIN_DOC_NOT_FOUND) && !empty($objectobj->last_main_doc)) {
354 $file_check_list[] = array(
355 'name' => basename($objectobj->last_main_doc),
356 'path' => DOL_DATA_ROOT .
'/' . $objectobj->last_main_doc,
359 foreach ($file_check_list as $file_check_arr) {
361 $filename_found = $file_check_arr[
'name'];
362 $filepath_found = $file_check_arr[
'path'];
367 if ($filepath_found) {
369 $attachedfilesThirdpartyObj[$thirdpartyid][$objectid] = array(
370 'paths'=>array($filepath_found),
371 'names'=>array($filename_found),
376 $langs->load(
"errors");
377 foreach ($file_check_list as $file_check_arr) {
378 $resaction .=
'<div class="error">'.$langs->trans(
'ErrorCantReadFile', $file_check_arr[
'path']).
'</div><br>';
379 dol_syslog(
'Failed to read file: '.$file_check_arr[
'path'], LOG_WARNING);
386 $listofqualifiedobj[$objectid] = $objectobj;
387 $listofqualifiedref[$objectid] = $objectobj->ref;
394 if (count($listofqualifiedobj) > 0) {
395 $langs->load(
"commercial");
398 $fromtype =
GETPOST(
'fromtype');
399 if ($fromtype ===
'user') {
400 $from =
dol_string_nospecial($user->getFullName($langs),
' ', array(
",")).
' <'.$user->email.
'>';
401 } elseif ($fromtype ===
'company') {
402 $from = $conf->global->MAIN_INFO_SOCIETE_NOM.
' <'.$conf->global->MAIN_INFO_SOCIETE_MAIL.
'>';
403 } elseif (preg_match(
'/user_aliases_(\d+)/', $fromtype, $reg)) {
404 $tmp = explode(
',', $user->email_aliases);
405 $from = trim($tmp[($reg[1] - 1)]);
406 } elseif (preg_match(
'/global_aliases_(\d+)/', $fromtype, $reg)) {
407 $tmp = explode(
',', $conf->global->MAIN_INFO_SOCIETE_MAIL_ALIASES);
408 $from = trim($tmp[($reg[1] - 1)]);
409 } elseif (preg_match(
'/senderprofile_(\d+)_(\d+)/', $fromtype, $reg)) {
410 $sql =
"SELECT rowid, label, email FROM ".MAIN_DB_PREFIX.
"c_email_senderprofile WHERE rowid = ".(int) $reg[1];
411 $resql = $db->query($sql);
412 $obj = $db->fetch_object(
$resql);
421 $subject =
GETPOST(
'subject',
'restricthtml');
422 $message =
GETPOST(
'message',
'restricthtml');
424 $sendtobcc =
GETPOST(
'sendtoccc');
425 if ($objectclass ==
'Propal') {
426 $sendtobcc .= (empty($conf->global->MAIN_MAIL_AUTOCOPY_PROPOSAL_TO) ?
'' : (($sendtobcc ?
", " :
"").$conf->global->MAIN_MAIL_AUTOCOPY_PROPOSAL_TO));
428 if ($objectclass ==
'Commande') {
429 $sendtobcc .= (empty($conf->global->MAIN_MAIL_AUTOCOPY_ORDER_TO) ?
'' : (($sendtobcc ?
", " :
"").$conf->global->MAIN_MAIL_AUTOCOPY_ORDER_TO));
431 if ($objectclass ==
'Facture') {
432 $sendtobcc .= (empty($conf->global->MAIN_MAIL_AUTOCOPY_INVOICE_TO) ?
'' : (($sendtobcc ?
", " :
"").$conf->global->MAIN_MAIL_AUTOCOPY_INVOICE_TO));
434 if ($objectclass ==
'Supplier_Proposal') {
435 $sendtobcc .= (empty($conf->global->MAIN_MAIL_AUTOCOPY_SUPPLIER_PROPOSAL_TO) ?
'' : (($sendtobcc ?
", " :
"").$conf->global->MAIN_MAIL_AUTOCOPY_SUPPLIER_PROPOSAL_TO));
437 if ($objectclass ==
'CommandeFournisseur') {
438 $sendtobcc .= (empty($conf->global->MAIN_MAIL_AUTOCOPY_SUPPLIER_ORDER_TO) ?
'' : (($sendtobcc ?
", " :
"").$conf->global->MAIN_MAIL_AUTOCOPY_SUPPLIER_ORDER_TO));
440 if ($objectclass ==
'FactureFournisseur') {
441 $sendtobcc .= (empty($conf->global->MAIN_MAIL_AUTOCOPY_SUPPLIER_INVOICE_TO) ?
'' : (($sendtobcc ?
", " :
"").$conf->global->MAIN_MAIL_AUTOCOPY_SUPPLIER_INVOICE_TO));
443 if ($objectclass ==
'Project') {
444 $sendtobcc .= (empty($conf->global->MAIN_MAIL_AUTOCOPY_PROJECT_TO) ?
'' : (($sendtobcc ?
", " :
"").$conf->global->MAIN_MAIL_AUTOCOPY_PROJECT_TO));
449 $looparray = array();
450 if (!$oneemailperrecipient) {
451 $looparray = $listofqualifiedobj;
452 foreach ($looparray as $key => $objecttmp) {
453 $looparray[$key]->thirdparty = $thirdparty;
456 $objectforloop =
new $objectclass($db);
457 $objectforloop->thirdparty = $thirdparty;
458 $looparray[0] = $objectforloop;
461 dol_syslog(
"We have set an array of ".count($looparray).
" emails to send. oneemailperrecipient=".$oneemailperrecipient);
463 foreach ($looparray as $objectid => $objecttmp) {
465 if (
isModEnabled(
'project') && method_exists($objecttmp,
'fetch_projet') && is_null($objecttmp->project)) {
466 $objecttmp->fetch_projet();
469 $substitutionarray[
'__ID__'] = ($oneemailperrecipient ? join(
', ', array_keys($listofqualifiedobj)) : $objecttmp->id);
470 $substitutionarray[
'__REF__'] = ($oneemailperrecipient ? join(
', ', $listofqualifiedref) : $objecttmp->
ref);
471 $substitutionarray[
'__EMAIL__'] = $thirdparty->email;
472 $substitutionarray[
'__CHECK_READ__'] =
'<img src="'.DOL_MAIN_URL_ROOT.
'/public/emailing/mailing-read.php?tag='.urlencode($thirdparty->tag).
'&securitykey='.urlencode($conf->global->MAILING_EMAIL_UNSUBSCRIBE_KEY).
'" width="1" height="1" style="width:1px;height:1px" border="0"/>';
474 $parameters = array(
'mode'=>
'formemail');
476 if (!empty($listofobjectthirdparties)) {
477 $parameters[
'listofobjectthirdparties'] = $listofobjectthirdparties;
479 if (!empty($listofobjectref)) {
480 $parameters[
'listofobjectref'] = $listofobjectref;
488 $attachedfiles = array(
'paths'=>array(),
'names'=>array(),
'mimes'=>array());
489 if ($oneemailperrecipient) {
491 if (is_array($attachedfilesThirdpartyObj[$thirdparty->id]) && count($attachedfilesThirdpartyObj[$thirdparty->id])) {
492 foreach ($attachedfilesThirdpartyObj[$thirdparty->id] as $keyObjId => $objAttachedFiles) {
494 $attachedfiles = array(
495 'paths'=>array_merge($attachedfiles[
'paths'], $objAttachedFiles[
'paths']),
496 'names'=>array_merge($attachedfiles[
'names'], $objAttachedFiles[
'names']),
497 'mimes'=>array_merge($attachedfiles[
'mimes'], $objAttachedFiles[
'mimes'])
501 } elseif (!empty($attachedfilesThirdpartyObj[$thirdparty->id][$objectid])) {
504 $attachedfiles = $attachedfilesThirdpartyObj[$thirdparty->id][$objectid];
507 $filepath = $attachedfiles[
'paths'];
508 $filename = $attachedfiles[
'names'];
509 $mimetype = $attachedfiles[
'mimes'];
512 if ($oneemailperrecipient) {
513 $trackid =
'thi'.$thirdparty->id;
514 if ($objecttmp->element ==
'expensereport') {
515 $trackid =
'use'.$thirdparty->id;
516 } elseif ($objecttmp->element ==
'contact') {
517 $trackid =
'ctc'.$thirdparty->id;
518 } elseif ($objecttmp->element ==
'holiday') {
519 $trackid =
'use'.$thirdparty->id;
522 $trackid = strtolower(get_class($objecttmp));
523 if (get_class($objecttmp) ==
'Contact') {
525 } elseif (get_class($objecttmp) ==
'Contrat') {
527 } elseif (get_class($objecttmp) ==
'Propal') {
529 } elseif (get_class($objecttmp) ==
'Commande') {
531 } elseif (get_class($objecttmp) ==
'Facture') {
533 } elseif (get_class($objecttmp) ==
'Supplier_Proposal') {
535 } elseif (get_class($objecttmp) ==
'CommandeFournisseur') {
537 } elseif (get_class($objecttmp) ==
'FactureFournisseur') {
541 $trackid .= $objecttmp->id;
547 if (empty($sendcontext)) {
548 $sendcontext =
'standard';
552 require_once DOL_DOCUMENT_ROOT.
'/core/class/CMailFile.class.php';
553 $mailfile =
new CMailFile($subjectreplaced, $sendto, $from, $messagereplaced, $filepath, $mimetype, $filename, $sendtocc, $sendtobcc, $deliveryreceipt, -1,
'',
'', $trackid,
'', $sendcontext);
554 if ($mailfile->error) {
555 $resaction .=
'<div class="error">'.$mailfile->error.
'</div>';
557 $result = $mailfile->sendfile();
559 $resaction .= $langs->trans(
'MailSuccessfulySent', $mailfile->getValidAddress($from, 2), $mailfile->getValidAddress($sendto, 2)).
'<br>';
564 foreach ($listofqualifiedobj as $objid2 => $objectobj2) {
565 if ((!$oneemailperrecipient) && $objid2 != $objectid) {
569 dol_syslog(
"Try to insert email event into agenda for objid=".$objid2.
" => objectobj=".get_class($objectobj2));
578 $actionmsg = $langs->transnoentities(
'MailSentBy').
' '.$from.
' '.$langs->transnoentities(
'To').
' '.$sendto;
581 $actionmsg =
dol_concatdesc($actionmsg, $langs->transnoentities(
'Bcc').
": ".$sendtocc);
583 $actionmsg =
dol_concatdesc($actionmsg, $langs->transnoentities(
'MailTopic').
": ".$subjectreplaced);
584 $actionmsg =
dol_concatdesc($actionmsg, $langs->transnoentities(
'TextUsedInTheMessageBody').
":");
590 $objectobj2->sendtoid = (empty($contactidtosend) ? 0 : $contactidtosend);
591 $objectobj2->actionmsg = $actionmsg;
592 $objectobj2->actionmsg2 = $actionmsg2;
593 $objectobj2->fk_element = $objid2;
594 $objectobj2->elementtype = $objectobj2->element;
595 if (!empty($conf->global->MAIN_MAIL_REPLACE_EVENT_TITLE_BY_EMAIL_SUBJECT)) {
596 $objectobj2->actionmsg2 = $subjectreplaced;
599 $triggername = strtoupper(get_class($objectobj2)).
'_SENTBYMAIL';
600 if ($triggername ==
'SOCIETE_SENTBYMAIL') {
601 $triggername =
'COMPANY_SENTBYMAIL';
603 if ($triggername ==
'CONTRAT_SENTBYMAIL') {
604 $triggername =
'CONTRACT_SENTBYMAIL';
606 if ($triggername ==
'COMMANDE_SENTBYMAIL') {
607 $triggername =
'ORDER_SENTBYMAIL';
609 if ($triggername ==
'FACTURE_SENTBYMAIL') {
610 $triggername =
'BILL_SENTBYMAIL';
612 if ($triggername ==
'EXPEDITION_SENTBYMAIL') {
613 $triggername =
'SHIPPING_SENTBYMAIL';
615 if ($triggername ==
'COMMANDEFOURNISSEUR_SENTBYMAIL') {
616 $triggername =
'ORDER_SUPPLIER_SENTBYMAIL';
618 if ($triggername ==
'FACTUREFOURNISSEUR_SENTBYMAIL') {
619 $triggername =
'BILL_SUPPLIER_SENTBYMAIL';
621 if ($triggername ==
'SUPPLIERPROPOSAL_SENTBYMAIL') {
622 $triggername =
'PROPOSAL_SUPPLIER_SENTBYMAIL';
624 if ($triggername ==
'PROJET_SENTBYMAIL') {
625 $triggername =
'PROJECT_SENTBYMAIL';
628 if (!empty($triggername)) {
630 $result = $objectobj2->call_trigger($triggername, $user);
638 dol_syslog(
"Error in trigger ".$triggername.
' '.$db->lasterror(), LOG_ERR);
645 $langs->load(
"other");
646 if ($mailfile->error) {
647 $resaction .= $langs->trans(
'ErrorFailedToSendMail', $from, $sendto);
648 $resaction .=
'<br><div class="error">'.$mailfile->error.
'</div>';
649 } elseif (!empty($conf->global->MAIN_DISABLE_ALL_MAILS)) {
650 $resaction .=
'<div class="warning">No mail sent. Feature is disabled by option MAIN_DISABLE_ALL_MAILS</div>';
652 $resaction .= $langs->trans(
'ErrorFailedToSendMail', $from, $sendto) .
'<br><div class="error">(unhandled error)</div>';
660 $resaction .= ($resaction ?
'<br>' : $resaction);
661 $resaction .=
'<strong>'.$langs->trans(
"ResultOfMailSending").
':</strong><br>'.
"\n";
662 $resaction .= $langs->trans(
"NbSelected").
': '.count($toselect).
"\n<br>";
663 $resaction .= $langs->trans(
"NbIgnored").
': '.($nbignored ? $nbignored : 0).
"\n<br>";
664 $resaction .= $langs->trans(
"NbSent").
': '.($nbsent ? $nbsent : 0).
"\n<br>";
669 setEventMessages($langs->trans(
"EMailSentForNElements", $nbsent.
'/'.count($toselect)),
null,
'mesgs');
682 if (!$error && $massaction ==
'cancelorders') {
688 $orders =
GETPOST(
'toselect',
'array');
689 foreach ($orders as $id_order) {
691 if ($cmd->fetch($id_order) <= 0) {
696 $langs->load(
'errors');
697 setEventMessages($langs->trans(
"ErrorObjectMustHaveStatusValidToBeCanceled", $cmd->ref),
null,
'errors');
702 $result = $cmd->cancel();
726 if (!$error && $massaction ==
"builddoc" && $permissiontoread && !
GETPOST(
'button_search')) {
727 if (empty($diroutputmassaction)) {
728 dol_print_error(
null,
'include of actions_massactions.inc.php is done but var $diroutputmassaction was not defined');
732 require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
733 require_once DOL_DOCUMENT_ROOT.
'/core/lib/pdf.lib.php';
734 require_once DOL_DOCUMENT_ROOT.
'/core/lib/date.lib.php';
736 $objecttmp =
new $objectclass($db);
737 $listofobjectid = array();
738 $listofobjectthirdparties = array();
739 $listofobjectref = array();
740 foreach ($toselect as $toselectid) {
741 $objecttmp =
new $objectclass($db);
742 $result = $objecttmp->fetch($toselectid);
744 $listofobjectid[$toselectid] = $toselectid;
745 $thirdpartyid = $objecttmp->fk_soc ? $objecttmp->fk_soc : $objecttmp->socid;
746 $listofobjectthirdparties[$thirdpartyid] = $thirdpartyid;
747 $listofobjectref[$toselectid] = $objecttmp->ref;
751 $arrayofinclusion = array();
752 foreach ($listofobjectref as $tmppdf) {
755 foreach ($listofobjectref as $tmppdf) {
756 $arrayofinclusion[] =
'^'.preg_quote(
dol_sanitizeFileName($tmppdf),
'/').
'_[a-zA-Z0-9-_]+\.pdf$';
758 $listoffiles =
dol_dir_list($uploaddir,
'all', 1, implode(
'|', $arrayofinclusion),
'\.meta$|\.png',
'date', SORT_DESC, 0,
true);
762 foreach ($listofobjectref as $basename) {
764 foreach ($listoffiles as $filefound) {
765 if (strstr($filefound[
"name"], $basename)) {
766 $files[] = $uploaddir.
'/'.$basename.
'/'.$filefound[
"name"];
773 $outputlangs = $langs;
776 $newlang =
GETPOST(
'lang_id',
'aZ09');
781 if (!empty($newlang)) {
783 $outputlangs->setDefaultLang($newlang);
786 if (!empty($conf->global->USE_PDFTK_FOR_PDF_CONCAT)) {
792 $filename = preg_replace(
'/\s/',
'_', $filename);
795 if (in_array($objecttmp->element, array(
'facture',
'facture_fournisseur')) && $search_status ==
Facture::STATUS_VALIDATED) {
796 if ($option ==
'late') {
803 $filename .=
'_'.$year;
806 $filename .=
'_'.$month;
809 if (count($files) > 0) {
811 $file = $diroutputmassaction.
'/'.$filename.
'_'.
dol_print_date($now,
'dayhourlog').
'.pdf';
814 foreach ($files as $f) {
815 $input_files .=
' '.escapeshellarg($f);
818 $cmd =
'pdftk '.$input_files.
' cat output '.escapeshellarg($file);
822 if (file_exists($file)) {
823 if (!empty($conf->global->MAIN_UMASK)) {
824 @chmod($file, octdec($conf->global->MAIN_UMASK));
827 $langs->load(
"exports");
830 setEventMessages($langs->trans(
'ErrorPDFTkOutputFileNotFound'),
null,
'errors');
833 setEventMessages($langs->trans(
'NoPDFAvailableForDocGenAmongChecked'),
null,
'errors');
838 $page_largeur = $formatarray[
'width'];
839 $page_hauteur = $formatarray[
'height'];
840 $format = array($page_largeur, $page_hauteur);
844 if (class_exists(
'TCPDF')) {
845 $pdf->setPrintHeader(
false);
846 $pdf->setPrintFooter(
false);
851 $pdf->SetCompression(
false);
855 foreach ($files as $file) {
857 $pagecount = $pdf->setSourceFile($file);
858 for ($i = 1; $i <= $pagecount; $i++) {
859 $tplidx = $pdf->importPage($i);
860 $s = $pdf->getTemplatesize($tplidx);
861 $pdf->AddPage($s[
'h'] > $s[
'w'] ?
'P' :
'L');
862 $pdf->useTemplate($tplidx);
871 $filename = preg_replace(
'/\s/',
'_', $filename);
874 if (in_array($objecttmp->element, array(
'facture',
'facture_fournisseur')) && $search_status ==
Facture::STATUS_VALIDATED) {
875 if ($option ==
'late') {
882 $filename .=
'_'.$year;
885 $filename .=
'_'.$month;
889 $file = $diroutputmassaction.
'/'.$filename.
'_'.
dol_print_date($now,
'dayhourlog').
'.pdf';
890 $pdf->Output($file,
'F');
891 if (!empty($conf->global->MAIN_UMASK)) {
892 @chmod($file, octdec($conf->global->MAIN_UMASK));
895 $langs->load(
"exports");
898 setEventMessages($langs->trans(
'NoPDFAvailableForDocGenAmongChecked'),
null,
'errors');
904 if ($action ==
'remove_file') {
905 require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
907 $langs->load(
"other");
908 $upload_dir = $diroutputmassaction;
909 $file = $upload_dir.
'/'.
GETPOST(
'file');
921 if (!$error && $massaction ==
'validate' && $permissiontoadd) {
922 $objecttmp =
new $objectclass($db);
924 if (($objecttmp->element ==
'facture' || $objecttmp->element ==
'invoice') &&
isModEnabled(
'stock') && !empty($conf->global->STOCK_CALCULATE_ON_BILL)) {
925 $langs->load(
"errors");
926 setEventMessages($langs->trans(
'ErrorMassValidationNotAllowedWhenStockIncreaseOnAction'),
null,
'errors');
929 if ($objecttmp->element ==
'invoice_supplier' &&
isModEnabled(
'stock') && !empty($conf->global->STOCK_CALCULATE_ON_SUPPLIER_BILL)) {
930 $langs->load(
"errors");
931 setEventMessages($langs->trans(
'ErrorMassValidationNotAllowedWhenStockIncreaseOnAction'),
null,
'errors');
934 if ($objecttmp->element ==
'facture') {
935 if (!empty($toselect) && !empty($conf->global->INVOICE_CHECK_POSTERIOR_DATE)) {
937 $sql =
"SELECT rowid FROM ".MAIN_DB_PREFIX.
"facture";
938 $sql .=
" WHERE rowid IN (".$db->sanitize(implode(
",", $toselect)).
")";
939 $sql .=
" ORDER BY datef";
941 $resql = $db->query($sql);
944 while ( !empty($arr = $db->fetch_row(
$resql))) {
945 $toselectnew[] = $arr[0];
947 $toselect = (empty($toselectnew)) ? $toselect : $toselectnew;
958 foreach ($toselect as $toselectid) {
959 $result = $objecttmp->fetch($toselectid);
961 $result = $objecttmp->validate($user);
963 $langs->load(
"errors");
964 setEventMessages($langs->trans(
"ErrorObjectMustHaveStatusDraftToBeValidated", $objecttmp->ref),
null,
'errors');
967 } elseif ($result < 0) {
974 if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) {
975 $outputlangs = $langs;
978 $newlang =
GETPOST(
'lang_id',
'aZ09');
981 $newlang = $objecttmp->thirdparty->default_lang;
983 if (!empty($newlang)) {
985 $outputlangs->setDefaultLang($newlang);
986 $outputlangs->load(
'products');
988 $model = $objecttmp->model_pdf;
989 $ret = $objecttmp->fetch($objecttmp->id);
991 $hidedetails = !empty($hidedetails) ? $hidedetails : (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DETAILS) ? 1 : 0);
992 $hidedesc = !empty($hidedesc) ? $hidedesc : (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DESC) ? 1 : 0);
993 $hideref = !empty($hideref) ? $hideref : (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_REF) ? 1 : 0);
994 $moreparams = !empty($moreparams) ? $moreparams :
null;
996 $result = $objecttmp->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref);
1014 setEventMessages($langs->trans(
"RecordModifiedSuccessfully"),
null,
'mesgs');
1027 if (!$error && ($massaction ==
'delete' || ($action ==
'delete' && $confirm ==
'yes')) && $permissiontodelete) {
1030 $objecttmp =
new $objectclass($db);
1033 foreach ($toselect as $toselectid) {
1034 $result = $objecttmp->fetch($toselectid);
1037 if ($objectclass ==
'Facture' && empty($conf->global->INVOICE_CAN_ALWAYS_BE_REMOVED) && $objecttmp->status !=
Facture::STATUS_DRAFT) {
1038 $langs->load(
"errors");
1040 $TMsg[] =
'<div class="error">'.$langs->trans(
'ErrorOnlyDraftStatusCanBeDeletedInMassAction', $objecttmp->ref).
'</div><br>';
1044 if (method_exists($objecttmp,
'is_erasable') && $objecttmp->is_erasable() <= 0) {
1045 $langs->load(
"errors");
1047 $TMsg[] =
'<div class="error">'.$langs->trans(
'ErrorRecordHasChildren').
' '.$objecttmp->ref.
'</div><br>';
1052 $langs->load(
"errors");
1054 $TMsg[] =
'<div class="error">'.$langs->trans(
'ErrorLeaveRequestMustBeDraftCanceledOrRefusedToBeDeleted', $objecttmp->ref).
'</div><br>';
1058 if ($objectclass ==
"Task" && $objecttmp->hasChildren() > 0) {
1059 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"projet_task SET fk_task_parent = 0 WHERE fk_task_parent = ".((int) $objecttmp->id);
1060 $res = $db->query($sql);
1068 if (in_array($objecttmp->element, array(
'societe',
'member'))) {
1069 $result = $objecttmp->delete($objecttmp->id, $user, 1);
1070 } elseif (in_array($objecttmp->element, array(
'action'))) {
1071 $result = $objecttmp->delete();
1073 $result = $objecttmp->delete($user);
1076 if (empty($result)) {
1077 $TMsg = array_merge($objecttmp->errors, $TMsg);
1078 } elseif ($result < 0) {
1092 if (empty($error)) {
1096 } elseif ($nbok > 0) {
1103 if (!empty($TMsg)) {
1118 if (!$error && $massaction ==
'generate_doc' && $permissiontoread) {
1120 $objecttmp =
new $objectclass($db);
1122 foreach ($toselect as $toselectid) {
1123 $result = $objecttmp->fetch($toselectid);
1125 $outputlangs = $langs;
1129 $newlang =
GETPOST(
'lang_id',
'aZ09');
1131 if (
getDolGlobalInt(
'MAIN_MULTILANGS') && empty($newlang) && isset($objecttmp->thirdparty->default_lang)) {
1132 $newlang = $objecttmp->thirdparty->default_lang;
1134 if (
getDolGlobalInt(
'MAIN_MULTILANGS') && empty($newlang) && isset($objecttmp->default_lang)) {
1135 $newlang = $objecttmp->default_lang;
1137 if ($conf->global->MAIN_MULTILANGS && empty($newlang) && empty($objecttmp->thirdparty)) {
1138 $objecttmp->fetch_thirdparty();
1139 $newlang = $objecttmp->thirdparty->default_lang;
1141 if (!empty($newlang)) {
1142 $outputlangs =
new Translate(
"", $conf);
1143 $outputlangs->setDefaultLang($newlang);
1147 if (empty($hidedetails)) {
1148 $hidedetails = (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DETAILS) ? 1 : 0);
1150 if (empty($hidedesc)) {
1151 $hidedesc = (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DESC) ? 1 : 0);
1153 if (empty($hideref)) {
1154 $hideref = (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_REF) ? 1 : 0);
1156 if (empty($moreparams)) {
1160 $result = $objecttmp->generateDocument($objecttmp->model_pdf, $outputlangs, $hidedetails, $hidedesc, $hideref, $moreparams);
1188 if (!$error && ($action ==
'affecttag' && $confirm ==
'yes') && $permissiontoadd) {
1191 $affecttag_type=
GETPOST(
'affecttag_type',
'alpha');
1192 if (!empty($affecttag_type)) {
1193 $affecttag_type_array=explode(
',', $affecttag_type);
1197 if (!empty($affecttag_type_array)) {
1199 require_once DOL_DOCUMENT_ROOT.
'/categories/class/categorie.class.php';
1201 $to_affecttag_type_array=array();
1202 $categ_type_array=$categ->getMapList();
1203 foreach ($categ_type_array as $categdef) {
1204 if (in_array($categdef[
'code'], $affecttag_type_array)) {
1205 $to_affecttag_type_array[] = $categdef[
'code'];
1211 if (!empty($to_affecttag_type_array)) {
1212 foreach ($to_affecttag_type_array as $categ_type) {
1213 $contcats =
GETPOST(
'contcats_' . $categ_type,
'array');
1215 foreach ($toselect as $toselectid) {
1216 $result = $object->fetch($toselectid);
1219 $result = $object->setCategoriesCommon($contcats, $categ_type,
false);
1248 if (!$error && ($action ==
'updateprice' && $confirm ==
'yes') && $permissiontoadd) {
1251 $pricepercentage=
GETPOST(
'pricerate',
'int');
1252 if ($pricepercentage == 0) {
1255 foreach ($toselect as $toselectid) {
1256 $result = $object->fetch($toselectid);
1259 if ($obj->price_base_type ==
'TTC') {
1260 $newprice = $object->price_ttc * (100 + $pricepercentage) / 100;
1261 $minprice = $object->price_min_ttc;
1263 $newprice = $object->price * (100 + $pricepercentage) / 100;
1264 $minprice = $object->price_min;
1266 $res = $object->updatePrice($newprice, $obj->price_base_type, $user, $object->tva_tx, $minprice, 0, $object->tva_npr, 0, 0, array(), $object->default_vat_code);
1292 if (!$error && ($action ==
'setsupervisor' && $confirm ==
'yes') && $permissiontoadd) {
1294 $supervisortoset=
GETPOST(
'supervisortoset');
1295 if (!empty($supervisortoset)) {
1296 foreach ($toselect as $toselectid) {
1297 $result = $object->fetch($toselectid);
1300 $object->fk_user = $supervisortoset;
1301 $res = $object->update($user);
1331 if (!$error && ($action ==
'affectuser' && $confirm ==
'yes') && $permissiontoadd) {
1334 $usertoaffect=
GETPOST(
'usertoaffect');
1335 $projectrole=
GETPOST(
'projectrole');
1336 $tasksrole=
GETPOST(
'tasksrole');
1337 if (!empty($usertoaffect)) {
1338 foreach ($toselect as $toselectid) {
1339 $result = $object->fetch($toselectid);
1342 $res = $object->add_contact($usertoaffect, $projectrole,
'internal');
1344 $taskstatic =
new Task($db);
1345 $task_array = $taskstatic->getTasksArray(0, 0, $object->id, 0, 0);
1347 foreach ($task_array as $task) {
1348 $tasksToAffect =
new Task($db);
1349 $result = $tasksToAffect->fetch($task->id);
1351 $res = $tasksToAffect->add_contact($usertoaffect, $tasksrole,
'internal');
1385 if (!$error && ($massaction ==
'enable' || ($action ==
'enable' && $confirm ==
'yes')) && $permissiontoadd) {
1388 $objecttmp =
new $objectclass($db);
1390 foreach ($toselect as $toselectid) {
1391 $result = $objecttmp->fetch($toselectid);
1393 if (in_array($objecttmp->element, array(
'societe'))) {
1394 $result =$objecttmp->setStatut(1);
1422 if (!$error && ($massaction ==
'disable' || ($action ==
'disable' && $confirm ==
'yes')) && $permissiontoadd) {
1425 $objecttmp =
new $objectclass($db);
1427 foreach ($toselect as $toselectid) {
1428 $result = $objecttmp->fetch($toselectid);
1430 if (in_array($objecttmp->element, array(
'societe'))) {
1431 $result =$objecttmp->setStatut(0);
1459 if (!$error && $action ==
'confirm_edit_value_extrafields' && $confirm ==
'yes' && $permissiontoadd) {
1462 $objecttmp =
new $objectclass($db);
1464 $e->fetch_name_optionals_label($objecttmp->table_element);
1467 $extrafieldKeyToUpdate =
GETPOST(
'extrafield-key-to-update');
1470 foreach ($toselect as $toselectid) {
1472 $objecttmp =
new $objectclass($db);
1473 $result = $objecttmp->fetch($toselectid);
1476 $ret = $e->setOptionalsFromPost(
null, $objecttmp, $extrafieldKeyToUpdate);
1478 $objecttmp->insertExtraFields();
1502 if (!$error && ($massaction ==
'affectcommercial' || ($action ==
'affectcommercial' && $confirm ==
'yes')) && $permissiontoadd) {
1505 $objecttmp =
new $objectclass($db);
1508 foreach ($toselect as $toselectid) {
1509 $result = $objecttmp->fetch($toselectid);
1511 if (in_array($objecttmp->element, array(
'societe'))) {
1512 $result = $objecttmp->setSalesRep(
GETPOST(
"commercial",
"alpha"));
1530 setEventMessages($langs->trans(
"CommercialsAffected", $nbok),
null,
'mesgs');
1541 if (!$error && ($massaction ==
'approveleave' || ($action ==
'approveleave' && $confirm ==
'yes')) && $permissiontoapprove) {
1544 $objecttmp =
new $objectclass($db);
1546 foreach ($toselect as $toselectid) {
1547 $result = $objecttmp->fetch($toselectid);
1550 setEventMessages($langs->trans(
'StatusOfRefMustBe', $objecttmp->ref, $langs->transnoentitiesnoconv(
'Validated')),
null,
'warnings');
1553 if ($user->id == $objecttmp->fk_validator) {
1554 $objecttmp->oldcopy =
dol_clone($objecttmp);
1556 $objecttmp->date_valid =
dol_now();
1557 $objecttmp->fk_user_valid = $user->id;
1560 $verif = $objecttmp->approve($user);
1570 $nbopenedday =
num_open_day($objecttmp->date_debut_gmt, $objecttmp->date_fin_gmt, 0, 1, $objecttmp->halfday);
1571 $soldeActuel = $objecttmp->getCpforUser($objecttmp->fk_user, $objecttmp->fk_type);
1572 $newSolde = ($soldeActuel - $nbopenedday);
1575 $result = $objecttmp->addLogCP($user->id, $objecttmp->fk_user, $langs->transnoentitiesnoconv(
"Holidays"), $newSolde, $objecttmp->fk_type);
1582 $result = $objecttmp->updateSoldeCP($objecttmp->fk_user, $newSolde, $objecttmp->fk_type);
1591 $destinataire =
new User($db);
1592 $destinataire->fetch($objecttmp->fk_user);
1593 $emailTo = $destinataire->email;
1596 dol_syslog(
"User that request leave has no email, so we redirect directly to finished page without sending email");
1599 $expediteur =
new User($db);
1600 $expediteur->fetch($objecttmp->fk_validator);
1602 $emailFrom = $conf->global->MAIN_MAIL_EMAIL_FROM;
1605 $societeName = $conf->global->MAIN_INFO_SOCIETE_NOM;
1606 if (!empty($conf->global->MAIN_APPLICATION_TITLE)) {
1607 $societeName = $conf->global->MAIN_APPLICATION_TITLE;
1610 $subject = $societeName.
" - ".$langs->transnoentitiesnoconv(
"HolidaysValidated");
1613 $message = $langs->transnoentitiesnoconv(
"Hello").
" ".$destinataire->firstname.
",\n";
1616 $message .= $langs->transnoentities(
"HolidaysValidatedBody",
dol_print_date($objecttmp->date_debut,
'day'),
dol_print_date($objecttmp->date_fin,
'day')).
"\n";
1618 $message .=
"- ".$langs->transnoentitiesnoconv(
"ValidatedBy").
" : ".
dolGetFirstLastname($expediteur->firstname, $expediteur->lastname).
"\n";
1620 $message .=
"- ".$langs->transnoentitiesnoconv(
"Link").
" : ".$dolibarr_main_url_root.
"/holiday/card.php?id=".$objecttmp->id.
"\n\n";
1623 $trackid =
'leav'.$objecttmp->id;
1625 require_once DOL_DOCUMENT_ROOT.
'/core/class/CMailFile.class.php';
1626 $mail =
new CMailFile($subject, $emailTo, $emailFrom, $message, array(), array(), array(),
'',
'', 0, 0,
'',
'', $trackid);
1629 $result = $mail->sendfile();
1638 $langs->load(
"errors");
1639 setEventMessages($langs->trans(
'ErrorNotApproverForHoliday', $objecttmp->ref),
null,
'errors');
1651 } elseif ($nbok == 1) {
1660 if (!$error && ($massaction ==
'increaseholiday' || ($action ==
'increaseholiday' && $confirm ==
'yes')) && $permissiontoapprove) {
1662 $objecttmp =
new $objectclass($db);
1664 $typeholiday =
GETPOST(
'typeholiday',
'alpha');
1665 $nbdaysholidays =
GETPOST(
'nbdaysholidays',
'double');
1667 if ($nbdaysholidays <= 0) {
1673 foreach ($toselect as $toselectid) {
1674 $balancecpuser = $objecttmp->getCPforUser($toselectid, $typeholiday);
1675 if (!empty($balancecpuser)) {
1676 $newnbdaysholidays = $nbdaysholidays + $balancecpuser;
1678 $newnbdaysholidays = $nbdaysholidays;
1680 $result = $holiday->addLogCP($user->id, $toselectid, $langs->transnoentitiesnoconv(
'ManualUpdate'), $newnbdaysholidays, $typeholiday);
1687 $objecttmp->updateSoldeCP($toselectid, $newnbdaysholidays, $typeholiday);
1700 setEventMessages($langs->trans(
"HolidayRecordsIncreased", $nbok),
null,
'mesgs');
1701 } elseif ($nbok == 1) {
1711 $parameters[
'toselect'] = (empty($toselect) ? array() : $toselect);
1712 $parameters[
'uploaddir'] = $uploaddir;
1713 $parameters[
'massaction'] = $massaction;
1714 $parameters[
'diroutputmassaction'] = isset($diroutputmassaction) ? $diroutputmassaction :
null;
1716 $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.
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.
if(isModEnabled('facture') &&!empty($user->rights->facture->lire)) if((isModEnabled('fournisseur') &&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) && $user->hasRight("fournisseur", "facture", "lire"))||(isModEnabled('supplier_invoice') && $user->hasRight("supplier_invoice", "lire"))) if(isModEnabled('don') &&!empty($user->rights->don->lire)) if(isModEnabled('tax') &&!empty($user->rights->tax->charges->lire)) if(isModEnabled('facture') &&isModEnabled('commande') && $user->hasRight("commande", "lire") &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) $resql
Social contributions to pay.
num_open_day($timestampStart, $timestampEnd, $inhour=0, $lastday=0, $halfday=0, $country_code='')
Function to return number of working days (and text of units) between two dates (working days)
dol_delete_file($file, $disableglob=0, $nophperrors=0, $nohook=0, $object=null, $allowdotdot=false, $indexdatabase=1, $nolog=0)
Remove a file or several files with a mask.
dol_most_recent_file($dir, $regexfilter='', $excludefilter=array('(\.meta|_preview.*\.png)$', '^\.'), $nohook=false, $mode='')
Return file(s) into a directory (by default most recent)
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...
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='')
Set event messages 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).
dol_now($mode='auto')
Return date for now.
getDolGlobalInt($key, $default=0)
Return dolibarr global constant int value.
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...
dol_string_nospecial($str, $newstr='_', $badcharstoreplace='', $badcharstoremove='')
Clean a string from all punctuation characters to use it as a ref or login.
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.
setEventMessage($mesgs, $style='mesgs')
Set event message in dol_events session object.
if(!function_exists('utf8_encode')) if(!function_exists('utf8_decode')) getDolGlobalString($key, $default='')
Return dolibarr global constant string value.
getCommonSubstitutionArray($outputlangs, $onlykey=0, $exclude=null, $object=null)
Return array of possible common substitutions.
dol_sanitizeFileName($str, $newstr='_', $unaccent=1)
Clean a string to use it as a file name.
GETPOSTISSET($paramname)
Return true if we are in a context of submitting the parameter $paramname from a POST of a form.
isModEnabled($module)
Is Dolibarr module enabled.
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.