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);
91 $objecttmp =
new $objectclass($db);
95 if ($objecttmp->element ==
'expensereport') {
96 $thirdparty =
new User($db);
98 if ($objecttmp->element ==
'partnership' &&
getDolGlobalString(
'PARTNERSHIP_IS_MANAGED_FOR') ==
'member') {
101 if ($objecttmp->element ==
'holiday') {
102 $thirdparty =
new User($db);
104 if ($objecttmp->element ==
'conferenceorboothattendee') {
108 foreach ($toselect as $toselectid) {
109 $objecttmp =
new $objectclass($db);
110 $result = $objecttmp->fetch($toselectid);
112 $listofobjectid[$toselectid] = $toselectid;
113 $tmpobjectid = ($objecttmp->fk_soc ? $objecttmp->fk_soc : $objecttmp->socid);
114 if ($objecttmp->element ==
'societe') {
115 $tmpobjectid = $objecttmp->id;
117 if ($objecttmp->element ==
'expensereport') {
118 $tmpobjectid = $objecttmp->fk_user_author;
120 if ($objecttmp->element ==
'partnership' &&
getDolGlobalString(
'PARTNERSHIP_IS_MANAGED_FOR') ==
'member') {
121 $tmpobjectid = $objecttmp->fk_member;
123 if ($objecttmp->element ==
'holiday') {
124 $tmpobjectid = $objecttmp->fk_user;
126 if ($objecttmp->element ==
'conferenceorboothattendee') {
127 $tmpobjectid = $objecttmp->id;
129 if (empty($tmpobjectid)) {
133 if ($objectclass ==
'Facture') {
134 $tmparraycontact = array();
135 $tmparraycontact = $objecttmp->liste_contact(-1,
'external', 0,
'BILLING');
136 if (is_array($tmparraycontact) && count($tmparraycontact) > 0) {
137 foreach ($tmparraycontact as $data_email) {
138 $listofobjectcontacts[$toselectid][$data_email[
'id']] = $data_email[
'email'];
141 } elseif ($objectclass ==
'CommandeFournisseur') {
142 $tmparraycontact = array();
143 $tmparraycontact = $objecttmp->liste_contact(-1,
'external', 0,
'CUSTOMER');
144 if (is_array($tmparraycontact) && count($tmparraycontact) > 0) {
145 foreach ($tmparraycontact as $data_email) {
146 $listofobjectcontacts[$toselectid][$data_email[
'id']] = $data_email[
'email'];
151 $listofobjectthirdparties[$tmpobjectid] = $tmpobjectid;
152 $listofobjectref[$tmpobjectid][$toselectid] = $objecttmp;
158 if (
GETPOST(
'fromtype',
'alpha') ===
'user' && empty($user->email)) {
161 $massaction =
'presend';
164 $receiver =
GETPOST(
'receiver',
'alphawithlgt');
165 if (!is_array($receiver)) {
166 if (empty($receiver) || $receiver ==
'-1') {
169 $receiver = array($receiver);
172 if (!trim($_POST[
'sendto']) && count($receiver) == 0 && count($listofobjectthirdparties) == 1) {
174 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Recipient")),
null,
'warnings');
175 $massaction =
'presend';
178 if (!
GETPOST(
'subject',
'restricthtml')) {
180 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"MailTopic")),
null,
'warnings');
181 $massaction =
'presend';
186 foreach ($listofobjectthirdparties as $thirdpartyid) {
187 $result = $thirdparty->fetch($thirdpartyid);
200 if (trim($_POST[
'sendto'])) {
202 $tmparray[] = trim(
GETPOST(
'sendto',
'alphawithlgt'));
204 if (count($receiver) > 0) {
205 foreach ($receiver as $key => $val) {
207 if ($val ==
'thirdparty') {
208 $tmparray[] = $thirdparty->name.
' <'.$thirdparty->email.
'>';
209 } elseif ($val && method_exists($thirdparty,
'contact_get_property')) {
210 $tmparray[] = $thirdparty->contact_get_property((
int) $val,
'email');
215 $sendto = implode(
',', $tmparray);
218 $receivercc =
GETPOST(
'receivercc',
'alphawithlgt');
219 if (!is_array($receivercc)) {
220 if ($receivercc ==
'-1') {
221 $receivercc = array();
223 $receivercc = array($receivercc);
227 if (trim($_POST[
'sendtocc'])) {
228 $tmparray[] = trim(
GETPOST(
'sendtocc',
'alphawithlgt'));
230 if (count($receivercc) > 0) {
231 foreach ($receivercc as $key => $val) {
233 if ($val ==
'thirdparty') {
234 $tmparray[] = $thirdparty->name.
' <'.$thirdparty->email.
'>';
236 $tmparray[] = $thirdparty->contact_get_property((
int) $val,
'email');
241 $sendtocc = implode(
',', $tmparray);
244 $listofqualifiedobj = array();
245 $listofqualifiedref = array();
246 $thirdpartywithoutemail = array();
248 foreach ($listofobjectref[$thirdpartyid] as $objectid => $objectobj) {
251 $langs->load(
"errors");
253 $resaction .=
'<div class="error">'.$langs->trans(
'ErrorOnlyProposalNotDraftCanBeSentInMassAction', $objectobj->ref).
'</div><br>';
257 $langs->load(
"errors");
259 $resaction .=
'<div class="error">'.$langs->trans(
'ErrorOnlyOrderNotDraftCanBeSentInMassAction', $objectobj->ref).
'</div><br>';
263 $langs->load(
"errors");
265 $resaction .=
'<div class="error">'.$langs->trans(
'ErrorOnlyInvoiceValidatedCanBeSentInMassAction', $objectobj->ref).
'</div><br>';
270 if (empty($sendto)) {
271 if ($objectobj->element ==
'societe') {
272 $sendto = $objectobj->email;
273 } elseif ($objectobj->element ==
'expensereport') {
274 $fuser =
new User($db);
275 $fuser->fetch($objectobj->fk_user_author);
276 $sendto = $fuser->email;
277 } elseif ($objectobj->element ==
'partnership' &&
getDolGlobalString(
'PARTNERSHIP_IS_MANAGED_FOR') ==
'member') {
279 $fadherent->fetch($objectobj->fk_member);
280 $sendto = $fadherent->email;
281 } elseif ($objectobj->element ==
'holiday') {
282 $fuser =
new User($db);
283 $fuser->fetch($objectobj->fk_user);
284 $sendto = $fuser->email;
285 } elseif ($objectobj->element ==
'facture' && !empty($listofobjectcontacts[$objectid])) {
286 $emails_to_sends = array();
287 $objectobj->fetch_thirdparty();
288 $contactidtosend = array();
289 foreach ($listofobjectcontacts[$objectid] as $contactemailid => $contactemailemail) {
290 $emails_to_sends[] = $objectobj->thirdparty->contact_get_property($contactemailid,
'email');
291 if (!in_array($contactemailid, $contactidtosend)) {
292 $contactidtosend[] = $contactemailid;
295 if (count($emails_to_sends) > 0) {
296 $sendto = implode(
',', $emails_to_sends);
298 } elseif ($objectobj->element ==
'order_supplier' && !empty($listofobjectcontacts[$objectid])) {
299 $emails_to_sends = array();
300 $objectobj->fetch_thirdparty();
301 $contactidtosend = array();
302 foreach ($listofobjectcontacts[$objectid] as $contactemailid => $contactemailemail) {
303 $emails_to_sends[] = $objectobj->thirdparty->contact_get_property($contactemailid,
'email');
304 if (!in_array($contactemailid, $contactidtosend)) {
305 $contactidtosend[] = $contactemailid;
308 if (count($emails_to_sends) > 0) {
309 $sendto = implode(
',', $emails_to_sends);
311 } elseif ($objectobj->element ==
'conferenceorboothattendee') {
312 $sendto = $objectobj->email;
314 $objectobj->fetch_thirdparty();
315 $sendto = $objectobj->thirdparty->email;
319 if (empty($sendto)) {
320 if ($objectobj->element ==
'societe') {
321 $objectobj->thirdparty = $objectobj;
326 if (empty($thirdpartywithoutemail[$objectobj->thirdparty->id])) {
327 $resaction .=
'<div class="error">'.$langs->trans(
'NoRecipientEmail', $objectobj->thirdparty->name).
'</div><br>';
329 dol_syslog(
'No recipient for thirdparty: '.$objectobj->thirdparty->name, LOG_WARNING);
330 $thirdpartywithoutemail[$objectobj->thirdparty->id] = 1;
334 if (
GETPOST(
'addmaindocfile')) {
341 $filedir = $uploaddir.
'/'.$subdir.dol_sanitizeFileName($objectobj->ref);
342 $filepath = $filedir.
'/'.$filename;
345 if ($objectobj->element ==
'invoice_supplier') {
346 $fileparams =
dol_most_recent_file($uploaddir.
'/'.
get_exdir($objectobj->id, 2, 0, 0, $objectobj, $objectobj->element).$objectobj->ref, preg_quote($objectobj->ref,
'/').
'([^\-])+');
347 $filepath = $fileparams[
'fullname'];
351 $filename_found =
'';
352 $filepath_found =
'';
353 $file_check_list = array();
354 $file_check_list[] = array(
358 if (!empty($conf->global->MAIL_MASS_ACTION_ADD_LAST_IF_MAIN_DOC_NOT_FOUND) && !empty($objectobj->last_main_doc)) {
359 $file_check_list[] = array(
360 'name' => basename($objectobj->last_main_doc),
361 'path' => DOL_DATA_ROOT .
'/' . $objectobj->last_main_doc,
364 foreach ($file_check_list as $file_check_arr) {
366 $filename_found = $file_check_arr[
'name'];
367 $filepath_found = $file_check_arr[
'path'];
372 if ($filepath_found) {
374 $attachedfilesThirdpartyObj[$thirdpartyid][$objectid] = array(
375 'paths'=>array($filepath_found),
376 'names'=>array($filename_found),
381 $langs->load(
"errors");
382 foreach ($file_check_list as $file_check_arr) {
383 $resaction .=
'<div class="error">'.$langs->trans(
'ErrorCantReadFile', $file_check_arr[
'path']).
'</div><br>';
384 dol_syslog(
'Failed to read file: '.$file_check_arr[
'path'], LOG_WARNING);
391 $listofqualifiedobj[$objectid] = $objectobj;
392 $listofqualifiedref[$objectid] = $objectobj->ref;
399 if (count($listofqualifiedobj) > 0) {
400 $langs->load(
"commercial");
403 $fromtype =
GETPOST(
'fromtype');
404 if ($fromtype ===
'user') {
405 $from =
dol_string_nospecial($user->getFullName($langs),
' ', array(
",")).
' <'.$user->email.
'>';
406 } elseif ($fromtype ===
'company') {
407 $from = $conf->global->MAIN_INFO_SOCIETE_NOM.
' <'.$conf->global->MAIN_INFO_SOCIETE_MAIL.
'>';
408 } elseif (preg_match(
'/user_aliases_(\d+)/', $fromtype, $reg)) {
409 $tmp = explode(
',', $user->email_aliases);
410 $from = trim($tmp[($reg[1] - 1)]);
411 } elseif (preg_match(
'/global_aliases_(\d+)/', $fromtype, $reg)) {
412 $tmp = explode(
',', $conf->global->MAIN_INFO_SOCIETE_MAIL_ALIASES);
413 $from = trim($tmp[($reg[1] - 1)]);
414 } elseif (preg_match(
'/senderprofile_(\d+)_(\d+)/', $fromtype, $reg)) {
415 $sql =
"SELECT rowid, label, email FROM ".MAIN_DB_PREFIX.
"c_email_senderprofile WHERE rowid = ".(int) $reg[1];
416 $resql = $db->query($sql);
417 $obj = $db->fetch_object(
$resql);
426 $subject =
GETPOST(
'subject',
'restricthtml');
427 $message =
GETPOST(
'message',
'restricthtml');
429 $sendtobcc =
GETPOST(
'sendtoccc');
430 if ($objectclass ==
'Propal') {
431 $sendtobcc .= (empty($conf->global->MAIN_MAIL_AUTOCOPY_PROPOSAL_TO) ?
'' : (($sendtobcc ?
", " :
"").$conf->global->MAIN_MAIL_AUTOCOPY_PROPOSAL_TO));
433 if ($objectclass ==
'Commande') {
434 $sendtobcc .= (empty($conf->global->MAIN_MAIL_AUTOCOPY_ORDER_TO) ?
'' : (($sendtobcc ?
", " :
"").$conf->global->MAIN_MAIL_AUTOCOPY_ORDER_TO));
436 if ($objectclass ==
'Facture') {
437 $sendtobcc .= (empty($conf->global->MAIN_MAIL_AUTOCOPY_INVOICE_TO) ?
'' : (($sendtobcc ?
", " :
"").$conf->global->MAIN_MAIL_AUTOCOPY_INVOICE_TO));
439 if ($objectclass ==
'Supplier_Proposal') {
440 $sendtobcc .= (empty($conf->global->MAIN_MAIL_AUTOCOPY_SUPPLIER_PROPOSAL_TO) ?
'' : (($sendtobcc ?
", " :
"").$conf->global->MAIN_MAIL_AUTOCOPY_SUPPLIER_PROPOSAL_TO));
442 if ($objectclass ==
'CommandeFournisseur') {
443 $sendtobcc .= (empty($conf->global->MAIN_MAIL_AUTOCOPY_SUPPLIER_ORDER_TO) ?
'' : (($sendtobcc ?
", " :
"").$conf->global->MAIN_MAIL_AUTOCOPY_SUPPLIER_ORDER_TO));
445 if ($objectclass ==
'FactureFournisseur') {
446 $sendtobcc .= (empty($conf->global->MAIN_MAIL_AUTOCOPY_SUPPLIER_INVOICE_TO) ?
'' : (($sendtobcc ?
", " :
"").$conf->global->MAIN_MAIL_AUTOCOPY_SUPPLIER_INVOICE_TO));
448 if ($objectclass ==
'Project') {
449 $sendtobcc .= (empty($conf->global->MAIN_MAIL_AUTOCOPY_PROJECT_TO) ?
'' : (($sendtobcc ?
", " :
"").$conf->global->MAIN_MAIL_AUTOCOPY_PROJECT_TO));
454 $looparray = array();
455 if (!$oneemailperrecipient) {
456 $looparray = $listofqualifiedobj;
457 foreach ($looparray as $key => $objecttmp) {
458 $looparray[$key]->thirdparty = $thirdparty;
461 $objectforloop =
new $objectclass($db);
462 $objectforloop->thirdparty = $thirdparty;
463 $looparray[0] = $objectforloop;
466 dol_syslog(
"We have set an array of ".count($looparray).
" emails to send. oneemailperrecipient=".$oneemailperrecipient);
468 foreach ($looparray as $objectid => $objecttmp) {
470 if (
isModEnabled(
'project') && method_exists($objecttmp,
'fetch_projet') && is_null($objecttmp->project)) {
471 $objecttmp->fetch_projet();
474 $substitutionarray[
'__ID__'] = ($oneemailperrecipient ? join(
', ', array_keys($listofqualifiedobj)) : $objecttmp->id);
475 $substitutionarray[
'__REF__'] = ($oneemailperrecipient ? join(
', ', $listofqualifiedref) : $objecttmp->
ref);
476 $substitutionarray[
'__EMAIL__'] = $thirdparty->email;
477 $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"/>';
479 $parameters = array(
'mode'=>
'formemail');
481 if (!empty($listofobjectthirdparties)) {
482 $parameters[
'listofobjectthirdparties'] = $listofobjectthirdparties;
484 if (!empty($listofobjectref)) {
485 $parameters[
'listofobjectref'] = $listofobjectref;
493 $attachedfiles = array(
'paths'=>array(),
'names'=>array(),
'mimes'=>array());
494 if ($oneemailperrecipient) {
496 if (is_array($attachedfilesThirdpartyObj[$thirdparty->id]) && count($attachedfilesThirdpartyObj[$thirdparty->id])) {
497 foreach ($attachedfilesThirdpartyObj[$thirdparty->id] as $keyObjId => $objAttachedFiles) {
499 $attachedfiles = array(
500 'paths'=>array_merge($attachedfiles[
'paths'], $objAttachedFiles[
'paths']),
501 'names'=>array_merge($attachedfiles[
'names'], $objAttachedFiles[
'names']),
502 'mimes'=>array_merge($attachedfiles[
'mimes'], $objAttachedFiles[
'mimes'])
506 } elseif (!empty($attachedfilesThirdpartyObj[$thirdparty->id][$objectid])) {
509 $attachedfiles = $attachedfilesThirdpartyObj[$thirdparty->id][$objectid];
512 $filepath = $attachedfiles[
'paths'];
513 $filename = $attachedfiles[
'names'];
514 $mimetype = $attachedfiles[
'mimes'];
517 if ($oneemailperrecipient) {
518 $trackid =
'thi'.$thirdparty->id;
519 if ($objecttmp->element ==
'expensereport') {
520 $trackid =
'use'.$thirdparty->id;
522 if ($objecttmp->element ==
'holiday') {
523 $trackid =
'use'.$thirdparty->id;
526 $trackid = strtolower(get_class($objecttmp));
527 if (get_class($objecttmp) ==
'Contrat') {
530 if (get_class($objecttmp) ==
'Propal') {
533 if (get_class($objecttmp) ==
'Commande') {
536 if (get_class($objecttmp) ==
'Facture') {
539 if (get_class($objecttmp) ==
'Supplier_Proposal') {
542 if (get_class($objecttmp) ==
'CommandeFournisseur') {
545 if (get_class($objecttmp) ==
'FactureFournisseur') {
549 $trackid .= $objecttmp->id;
555 if (empty($sendcontext)) {
556 $sendcontext =
'standard';
560 $vardir = $conf->user->dir_output.
"/".$user->id;
561 $upload_dir_tmp = $vardir.
'/temp';
564 require_once DOL_DOCUMENT_ROOT.
'/core/class/CMailFile.class.php';
565 $mailfile =
new CMailFile($subjectreplaced, $sendto, $from, $messagereplaced, $filepath, $mimetype, $filename, $sendtocc, $sendtobcc, $deliveryreceipt, -1,
'',
'', $trackid,
'', $sendcontext,
'', $upload_dir_tmp);
566 if ($mailfile->error) {
567 $resaction .=
'<div class="error">'.$mailfile->error.
'</div>';
569 $result = $mailfile->sendfile();
571 $resaction .= $langs->trans(
'MailSuccessfulySent', $mailfile->getValidAddress($mailfile->addr_from, 2), $mailfile->getValidAddress($mailfile->addr_to, 2)).
'<br>';
576 foreach ($listofqualifiedobj as $objid2 => $objectobj2) {
577 if ((!$oneemailperrecipient) && $objid2 != $objectid) {
581 dol_syslog(
"Try to insert email event into agenda for objid=".$objid2.
" => objectobj=".get_class($objectobj2));
590 $actionmsg = $langs->transnoentities(
'MailSentBy').
' '.$from.
' '.$langs->transnoentities(
'To').
' '.$sendto;
593 $actionmsg =
dol_concatdesc($actionmsg, $langs->transnoentities(
'Bcc').
": ".$sendtocc);
595 $actionmsg =
dol_concatdesc($actionmsg, $langs->transnoentities(
'MailTopic').
": ".$subjectreplaced);
596 $actionmsg =
dol_concatdesc($actionmsg, $langs->transnoentities(
'TextUsedInTheMessageBody').
":");
602 $objectobj2->sendtoid = (empty($contactidtosend) ? 0 : $contactidtosend);
603 $objectobj2->actionmsg = $actionmsg;
604 $objectobj2->actionmsg2 = $actionmsg2;
605 $objectobj2->fk_element = $objid2;
606 $objectobj2->elementtype = $objectobj2->element;
607 if (!empty($conf->global->MAIN_MAIL_REPLACE_EVENT_TITLE_BY_EMAIL_SUBJECT)) {
608 $objectobj2->actionmsg2 = $subjectreplaced;
611 $triggername = strtoupper(get_class($objectobj2)).
'_SENTBYMAIL';
612 if ($triggername ==
'SOCIETE_SENTBYMAIL') {
613 $triggername =
'COMPANY_SENTBYMAIL';
615 if ($triggername ==
'CONTRAT_SENTBYMAIL') {
616 $triggername =
'CONTRACT_SENTBYMAIL';
618 if ($triggername ==
'COMMANDE_SENTBYMAIL') {
619 $triggername =
'ORDER_SENTBYMAIL';
621 if ($triggername ==
'FACTURE_SENTBYMAIL') {
622 $triggername =
'BILL_SENTBYMAIL';
624 if ($triggername ==
'EXPEDITION_SENTBYMAIL') {
625 $triggername =
'SHIPPING_SENTBYMAIL';
627 if ($triggername ==
'COMMANDEFOURNISSEUR_SENTBYMAIL') {
628 $triggername =
'ORDER_SUPPLIER_SENTBYMAIL';
630 if ($triggername ==
'FACTUREFOURNISSEUR_SENTBYMAIL') {
631 $triggername =
'BILL_SUPPLIER_SENTBYMAIL';
633 if ($triggername ==
'SUPPLIERPROPOSAL_SENTBYMAIL') {
634 $triggername =
'PROPOSAL_SUPPLIER_SENTBYMAIL';
636 if ($triggername ==
'PROJET_SENTBYMAIL') {
637 $triggername =
'PROJECT_SENTBYMAIL';
640 if (!empty($triggername)) {
642 $result = $objectobj2->call_trigger($triggername, $user);
650 dol_syslog(
"Error in trigger ".$triggername.
' '.$db->lasterror(), LOG_ERR);
657 $langs->load(
"other");
658 if ($mailfile->error) {
659 $resaction .= $langs->trans(
'ErrorFailedToSendMail', $from, $sendto);
660 $resaction .=
'<br><div class="error">'.$mailfile->error.
'</div>';
661 } elseif (!empty($conf->global->MAIN_DISABLE_ALL_MAILS)) {
662 $resaction .=
'<div class="warning">No mail sent. Feature is disabled by option MAIN_DISABLE_ALL_MAILS</div>';
664 $resaction .= $langs->trans(
'ErrorFailedToSendMail', $from, $sendto) .
'<br><div class="error">(unhandled error)</div>';
672 $resaction .= ($resaction ?
'<br>' : $resaction);
673 $resaction .=
'<strong>'.$langs->trans(
"ResultOfMailSending").
':</strong><br>'.
"\n";
674 $resaction .= $langs->trans(
"NbSelected").
': '.count($toselect).
"\n<br>";
675 $resaction .= $langs->trans(
"NbIgnored").
': '.($nbignored ? $nbignored : 0).
"\n<br>";
676 $resaction .= $langs->trans(
"NbSent").
': '.($nbsent ? $nbsent : 0).
"\n<br>";
681 setEventMessages($langs->trans(
"EMailSentForNElements", $nbsent.
'/'.count($toselect)),
null,
'mesgs');
694 if (!$error && $massaction ==
'cancelorders') {
699 $orders =
GETPOST(
'toselect',
'array');
700 foreach ($orders as $id_order) {
702 if ($cmd->fetch($id_order) <= 0) {
707 $langs->load(
'errors');
708 setEventMessages($langs->trans(
"ErrorObjectMustHaveStatusValidToBeCanceled", $cmd->ref),
null,
'errors');
713 $result = $cmd->cancel();
737 if (!$error && $massaction ==
"builddoc" && $permissiontoread && !
GETPOST(
'button_search')) {
738 if (empty($diroutputmassaction)) {
739 dol_print_error(
null,
'include of actions_massactions.inc.php is done but var $diroutputmassaction was not defined');
743 require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
744 require_once DOL_DOCUMENT_ROOT.
'/core/lib/pdf.lib.php';
745 require_once DOL_DOCUMENT_ROOT.
'/core/lib/date.lib.php';
747 $objecttmp =
new $objectclass($db);
748 $listofobjectid = array();
749 $listofobjectthirdparties = array();
750 $listofobjectref = array();
751 foreach ($toselect as $toselectid) {
752 $objecttmp =
new $objectclass($db);
753 $result = $objecttmp->fetch($toselectid);
755 $listofobjectid[$toselectid] = $toselectid;
756 $thirdpartyid = $objecttmp->fk_soc ? $objecttmp->fk_soc : $objecttmp->socid;
757 $listofobjectthirdparties[$thirdpartyid] = $thirdpartyid;
758 $listofobjectref[$toselectid] = $objecttmp->ref;
762 $arrayofinclusion = array();
763 foreach ($listofobjectref as $tmppdf) {
766 foreach ($listofobjectref as $tmppdf) {
767 $arrayofinclusion[] =
'^'.preg_quote(
dol_sanitizeFileName($tmppdf),
'/').
'_[a-zA-Z0-9\-\_\'\&\.]+\.pdf$';
769 $listoffiles =
dol_dir_list($uploaddir,
'all', 1, implode(
'|', $arrayofinclusion),
'\.meta$|\.png',
'date', SORT_DESC, 0,
true);
773 foreach ($listofobjectref as $basename) {
775 foreach ($listoffiles as $filefound) {
776 if (strstr($filefound[
"name"], $basename)) {
777 $files[] = $uploaddir.
'/'.$basename.
'/'.$filefound[
"name"];
784 $outputlangs = $langs;
787 $newlang =
GETPOST(
'lang_id',
'aZ09');
792 if (!empty($newlang)) {
794 $outputlangs->setDefaultLang($newlang);
797 if (!empty($conf->global->USE_PDFTK_FOR_PDF_CONCAT)) {
803 $filename = preg_replace(
'/\s/',
'_', $filename);
806 if (in_array($objecttmp->element, array(
'facture',
'facture_fournisseur')) && $search_status ==
Facture::STATUS_VALIDATED) {
807 if ($option ==
'late') {
814 $filename .=
'_'.$year;
817 $filename .=
'_'.$month;
820 if (count($files) > 0) {
822 $file = $diroutputmassaction.
'/'.$filename.
'_'.
dol_print_date($now,
'dayhourlog').
'.pdf';
825 foreach ($files as $f) {
826 $input_files .=
' '.escapeshellarg($f);
829 $cmd =
'pdftk '.$input_files.
' cat output '.escapeshellarg($file);
833 if (file_exists($file)) {
834 if (!empty($conf->global->MAIN_UMASK)) {
835 @chmod($file, octdec($conf->global->MAIN_UMASK));
838 $langs->load(
"exports");
841 setEventMessages($langs->trans(
'ErrorPDFTkOutputFileNotFound'),
null,
'errors');
844 setEventMessages($langs->trans(
'NoPDFAvailableForDocGenAmongChecked'),
null,
'errors');
849 $page_largeur = $formatarray[
'width'];
850 $page_hauteur = $formatarray[
'height'];
851 $format = array($page_largeur, $page_hauteur);
855 if (class_exists(
'TCPDF')) {
856 $pdf->setPrintHeader(
false);
857 $pdf->setPrintFooter(
false);
862 $pdf->SetCompression(
false);
866 foreach ($files as $file) {
868 $pagecount = $pdf->setSourceFile($file);
869 for ($i = 1; $i <= $pagecount; $i++) {
870 $tplidx = $pdf->importPage($i);
871 $s = $pdf->getTemplatesize($tplidx);
872 $pdf->AddPage($s[
'h'] > $s[
'w'] ?
'P' :
'L');
873 $pdf->useTemplate($tplidx);
882 $filename = preg_replace(
'/\s/',
'_', $filename);
885 if (in_array($objecttmp->element, array(
'facture',
'facture_fournisseur')) && $search_status ==
Facture::STATUS_VALIDATED) {
886 if ($option ==
'late') {
893 $filename .=
'_'.$year;
896 $filename .=
'_'.$month;
900 $file = $diroutputmassaction.
'/'.$filename.
'_'.
dol_print_date($now,
'dayhourlog').
'.pdf';
901 $pdf->Output($file,
'F');
902 if (!empty($conf->global->MAIN_UMASK)) {
903 @chmod($file, octdec($conf->global->MAIN_UMASK));
906 $langs->load(
"exports");
909 setEventMessages($langs->trans(
'NoPDFAvailableForDocGenAmongChecked'),
null,
'errors');
915 if ($action ==
'remove_file') {
916 require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
918 $langs->load(
"other");
919 $upload_dir = $diroutputmassaction;
920 $file = $upload_dir.
'/'.
GETPOST(
'file');
932 if (!$error && $massaction ==
'validate' && $permissiontoadd) {
933 $objecttmp =
new $objectclass($db);
935 if (($objecttmp->element ==
'facture' || $objecttmp->element ==
'invoice') &&
isModEnabled(
'stock') && !empty($conf->global->STOCK_CALCULATE_ON_BILL)) {
936 $langs->load(
"errors");
937 setEventMessages($langs->trans(
'ErrorMassValidationNotAllowedWhenStockIncreaseOnAction'),
null,
'errors');
940 if ($objecttmp->element ==
'invoice_supplier' &&
isModEnabled(
'stock') && !empty($conf->global->STOCK_CALCULATE_ON_SUPPLIER_BILL)) {
941 $langs->load(
"errors");
942 setEventMessages($langs->trans(
'ErrorMassValidationNotAllowedWhenStockIncreaseOnAction'),
null,
'errors');
945 if ($objecttmp->element ==
'facture') {
946 if (!empty($toselect) && !empty($conf->global->INVOICE_CHECK_POSTERIOR_DATE)) {
948 $sql =
"SELECT rowid FROM ".MAIN_DB_PREFIX.
"facture";
949 $sql .=
" WHERE rowid IN (".$db->sanitize(implode(
",", $toselect)).
")";
950 $sql .=
" ORDER BY datef";
952 $resql = $db->query($sql);
955 while ( !empty($arr = $db->fetch_row(
$resql))) {
956 $toselectnew[] = $arr[0];
958 $toselect = (empty($toselectnew)) ? $toselect : $toselectnew;
969 foreach ($toselect as $toselectid) {
970 $result = $objecttmp->fetch($toselectid);
972 if (method_exists($objecttmp,
'validate')) {
973 $result = $objecttmp->validate($user);
974 } elseif (method_exists($objecttmp,
'setValid')) {
975 $result = $objecttmp->setValid($user);
977 $objecttmp->error =
'No method validate or setValid on this object';
981 $langs->load(
"errors");
982 setEventMessages($langs->trans(
"ErrorObjectMustHaveStatusDraftToBeValidated", $objecttmp->ref),
null,
'errors');
985 } elseif ($result < 0) {
992 if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) {
993 $outputlangs = $langs;
996 $newlang =
GETPOST(
'lang_id',
'aZ09');
998 if (
getDolGlobalInt(
'MAIN_MULTILANGS') && empty($newlang) && property_exists($objecttmp,
'thirdparty')) {
999 if ((property_exists($objecttmp,
'socid') || property_exists($objecttmp,
'fk_soc')) && empty($objecttmp->thirdparty)) {
1000 $objecttmp->fetch_thirdparty();
1002 if (!empty($objecttmp->thirdparty)) {
1003 $newlang = $objecttmp->thirdparty->default_lang;
1006 if (!empty($newlang)) {
1007 $outputlangs =
new Translate(
"", $conf);
1008 $outputlangs->setDefaultLang($newlang);
1009 $outputlangs->load(
'products');
1011 $model = $objecttmp->model_pdf;
1012 $ret = $objecttmp->fetch($objecttmp->id);
1014 $hidedetails = !empty($hidedetails) ? $hidedetails : (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DETAILS) ? 1 : 0);
1015 $hidedesc = !empty($hidedesc) ? $hidedesc : (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DESC) ? 1 : 0);
1016 $hideref = !empty($hideref) ? $hideref : (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_REF) ? 1 : 0);
1017 $moreparams = !empty($moreparams) ? $moreparams :
null;
1019 $result = $objecttmp->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref);
1037 setEventMessages($langs->trans(
"RecordModifiedSuccessfully"),
null,
'mesgs');
1050 if (!$error && ($massaction ==
'delete' || ($action ==
'delete' && $confirm ==
'yes')) && $permissiontodelete) {
1053 $objecttmp =
new $objectclass($db);
1058 $unique_arr = array_unique($toselect);
1059 foreach ($unique_arr as $toselectid) {
1060 $result = $objecttmp->fetch($toselectid);
1063 if ($objectclass ==
'Facture' && empty($conf->global->INVOICE_CAN_ALWAYS_BE_REMOVED) && $objecttmp->status !=
Facture::STATUS_DRAFT) {
1064 $langs->load(
"errors");
1066 $TMsg[] =
'<div class="error">'.$langs->trans(
'ErrorOnlyDraftStatusCanBeDeletedInMassAction', $objecttmp->ref).
'</div><br>';
1070 if (method_exists($objecttmp,
'is_erasable') && $objecttmp->is_erasable() <= 0) {
1071 $langs->load(
"errors");
1073 $TMsg[] =
'<div class="error">'.$langs->trans(
'ErrorRecordHasChildren').
' '.$objecttmp->ref.
'</div><br>';
1078 $langs->load(
"errors");
1080 $TMsg[] =
'<div class="error">'.$langs->trans(
'ErrorLeaveRequestMustBeDraftCanceledOrRefusedToBeDeleted', $objecttmp->ref).
'</div><br>';
1084 if ($objectclass ==
"Task" && $objecttmp->hasChildren() > 0) {
1085 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"projet_task SET fk_task_parent = 0 WHERE fk_task_parent = ".((int) $objecttmp->id);
1086 $res = $db->query($sql);
1094 if (in_array($objecttmp->element, array(
'societe',
'member'))) {
1095 $result = $objecttmp->delete($objecttmp->id, $user, 1);
1096 } elseif (in_array($objecttmp->element, array(
'action'))) {
1097 $result = $objecttmp->delete();
1099 $result = $objecttmp->delete($user);
1102 if (empty($result)) {
1103 $TMsg = array_merge($objecttmp->errors, $TMsg);
1104 } elseif ($result < 0) {
1118 if (empty($error)) {
1122 } elseif ($nbok > 0) {
1129 if (!empty($TMsg)) {
1144 if (!$error && $massaction ==
'generate_doc' && $permissiontoread) {
1146 $objecttmp =
new $objectclass($db);
1148 foreach ($toselect as $toselectid) {
1149 $result = $objecttmp->fetch($toselectid);
1151 $outputlangs = $langs;
1155 $newlang =
GETPOST(
'lang_id',
'aZ09');
1157 if (
getDolGlobalInt(
'MAIN_MULTILANGS') && empty($newlang) && isset($objecttmp->thirdparty->default_lang)) {
1158 $newlang = $objecttmp->thirdparty->default_lang;
1160 if (
getDolGlobalInt(
'MAIN_MULTILANGS') && empty($newlang) && isset($objecttmp->default_lang)) {
1161 $newlang = $objecttmp->default_lang;
1163 if ($conf->global->MAIN_MULTILANGS && empty($newlang) && empty($objecttmp->thirdparty)) {
1164 $objecttmp->fetch_thirdparty();
1165 $newlang = $objecttmp->thirdparty->default_lang;
1167 if (!empty($newlang)) {
1168 $outputlangs =
new Translate(
"", $conf);
1169 $outputlangs->setDefaultLang($newlang);
1173 if (empty($hidedetails)) {
1174 $hidedetails = (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DETAILS) ? 1 : 0);
1176 if (empty($hidedesc)) {
1177 $hidedesc = (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DESC) ? 1 : 0);
1179 if (empty($hideref)) {
1180 $hideref = (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_REF) ? 1 : 0);
1182 if (empty($moreparams)) {
1186 $result = $objecttmp->generateDocument($objecttmp->model_pdf, $outputlangs, $hidedetails, $hidedesc, $hideref, $moreparams);
1214 if (!$error && ($action ==
'affecttag' && $confirm ==
'yes') && $permissiontoadd) {
1217 $affecttag_type=
GETPOST(
'affecttag_type',
'alpha');
1218 if (!empty($affecttag_type)) {
1219 $affecttag_type_array=explode(
',', $affecttag_type);
1223 if (!empty($affecttag_type_array)) {
1225 require_once DOL_DOCUMENT_ROOT.
'/categories/class/categorie.class.php';
1227 $to_affecttag_type_array=array();
1228 $categ_type_array=$categ->getMapList();
1229 foreach ($categ_type_array as $categdef) {
1230 if (in_array($categdef[
'code'], $affecttag_type_array)) {
1231 $to_affecttag_type_array[] = $categdef[
'code'];
1237 if (!empty($to_affecttag_type_array)) {
1238 foreach ($to_affecttag_type_array as $categ_type) {
1239 $contcats =
GETPOST(
'contcats_' . $categ_type,
'array');
1241 foreach ($toselect as $toselectid) {
1242 $result = $object->fetch($toselectid);
1245 $result = $object->setCategoriesCommon($contcats, $categ_type,
false);
1274 if (!$error && ($action ==
'updateprice' && $confirm ==
'yes') && $permissiontoadd) {
1277 $pricepercentage=
GETPOST(
'pricerate',
'int');
1278 if ($pricepercentage == 0) {
1281 foreach ($toselect as $toselectid) {
1282 $result = $object->fetch($toselectid);
1285 if ($obj->price_base_type ==
'TTC') {
1286 $newprice = $object->price_ttc * (100 + $pricepercentage) / 100;
1287 $minprice = $object->price_min_ttc;
1289 $newprice = $object->price * (100 + $pricepercentage) / 100;
1290 $minprice = $object->price_min;
1292 $res = $object->updatePrice($newprice, $obj->price_base_type, $user, $object->tva_tx, $minprice, 0, $object->tva_npr, 0, 0, array(), $object->default_vat_code);
1318 if (!$error && ($action ==
'setsupervisor' && $confirm ==
'yes') && $permissiontoadd) {
1320 $supervisortoset=
GETPOST(
'supervisortoset');
1321 if (!empty($supervisortoset)) {
1322 foreach ($toselect as $toselectid) {
1323 $result = $object->fetch($toselectid);
1326 $object->fk_user = $supervisortoset;
1327 $res = $object->update($user);
1357 if (!$error && ($action ==
'affectuser' && $confirm ==
'yes') && $permissiontoadd) {
1360 $usertoaffect=
GETPOST(
'usertoaffect');
1361 $projectrole=
GETPOST(
'projectrole');
1362 $tasksrole=
GETPOST(
'tasksrole');
1363 if (!empty($usertoaffect)) {
1364 foreach ($toselect as $toselectid) {
1365 $result = $object->fetch($toselectid);
1368 $res = $object->add_contact($usertoaffect, $projectrole,
'internal');
1370 $taskstatic =
new Task($db);
1371 $task_array = $taskstatic->getTasksArray(0, 0, $object->id, 0, 0);
1373 foreach ($task_array as $task) {
1374 $tasksToAffect =
new Task($db);
1375 $result = $tasksToAffect->fetch($task->id);
1377 $res = $tasksToAffect->add_contact($usertoaffect, $tasksrole,
'internal');
1411 if (!$error && ($massaction ==
'enable' || ($action ==
'enable' && $confirm ==
'yes')) && $permissiontoadd) {
1414 $objecttmp =
new $objectclass($db);
1416 foreach ($toselect as $toselectid) {
1417 $result = $objecttmp->fetch($toselectid);
1419 if (in_array($objecttmp->element, array(
'societe'))) {
1420 $result =$objecttmp->setStatut(1);
1448 if (!$error && ($massaction ==
'disable' || ($action ==
'disable' && $confirm ==
'yes')) && $permissiontoadd) {
1451 $objecttmp =
new $objectclass($db);
1453 foreach ($toselect as $toselectid) {
1454 $result = $objecttmp->fetch($toselectid);
1456 if (in_array($objecttmp->element, array(
'societe'))) {
1457 $result =$objecttmp->setStatut(0);
1485 if (!$error && $action ==
'confirm_edit_value_extrafields' && $confirm ==
'yes' && $permissiontoadd) {
1488 $objecttmp =
new $objectclass($db);
1490 $e->fetch_name_optionals_label($objecttmp->table_element);
1493 $extrafieldKeyToUpdate =
GETPOST(
'extrafield-key-to-update');
1496 foreach ($toselect as $toselectid) {
1498 $objecttmp =
new $objectclass($db);
1499 $result = $objecttmp->fetch($toselectid);
1502 $ret = $e->setOptionalsFromPost(
null, $objecttmp, $extrafieldKeyToUpdate);
1504 $objecttmp->insertExtraFields();
1528 if (!$error && ($massaction ==
'affectcommercial' || ($action ==
'affectcommercial' && $confirm ==
'yes')) && $permissiontoadd) {
1531 $objecttmp =
new $objectclass($db);
1534 foreach ($toselect as $toselectid) {
1535 $result = $objecttmp->fetch($toselectid);
1537 if (in_array($objecttmp->element, array(
'societe'))) {
1538 $result = $objecttmp->setSalesRep(
GETPOST(
"commercial",
"alpha"));
1556 setEventMessages($langs->trans(
"CommercialsAffected", $nbok),
null,
'mesgs');
1567 if (!$error && ($massaction ==
'approveleave' || ($action ==
'approveleave' && $confirm ==
'yes')) && $permissiontoapprove) {
1570 $objecttmp =
new $objectclass($db);
1572 foreach ($toselect as $toselectid) {
1573 $result = $objecttmp->fetch($toselectid);
1576 setEventMessages($langs->trans(
'StatusOfRefMustBe', $objecttmp->ref, $langs->transnoentitiesnoconv(
'Validated')),
null,
'warnings');
1579 if ($user->id == $objecttmp->fk_validator) {
1580 $objecttmp->oldcopy =
dol_clone($objecttmp);
1582 $objecttmp->date_valid =
dol_now();
1583 $objecttmp->fk_user_valid = $user->id;
1586 $verif = $objecttmp->approve($user);
1596 $nbopenedday =
num_open_day($objecttmp->date_debut_gmt, $objecttmp->date_fin_gmt, 0, 1, $objecttmp->halfday);
1597 $soldeActuel = $objecttmp->getCpforUser($objecttmp->fk_user, $objecttmp->fk_type);
1598 $newSolde = ($soldeActuel - $nbopenedday);
1601 $result = $objecttmp->addLogCP($user->id, $objecttmp->fk_user, $langs->transnoentitiesnoconv(
"Holidays"), $newSolde, $objecttmp->fk_type);
1608 $result = $objecttmp->updateSoldeCP($objecttmp->fk_user, $newSolde, $objecttmp->fk_type);
1617 $destinataire =
new User($db);
1618 $destinataire->fetch($objecttmp->fk_user);
1619 $emailTo = $destinataire->email;
1622 dol_syslog(
"User that request leave has no email, so we redirect directly to finished page without sending email");
1625 $expediteur =
new User($db);
1626 $expediteur->fetch($objecttmp->fk_validator);
1628 $emailFrom = $conf->global->MAIN_MAIL_EMAIL_FROM;
1631 $societeName = $conf->global->MAIN_INFO_SOCIETE_NOM;
1632 if (!empty($conf->global->MAIN_APPLICATION_TITLE)) {
1633 $societeName = $conf->global->MAIN_APPLICATION_TITLE;
1636 $subject = $societeName.
" - ".$langs->transnoentitiesnoconv(
"HolidaysValidated");
1639 $message = $langs->transnoentitiesnoconv(
"Hello").
" ".$destinataire->firstname.
",\n";
1642 $message .= $langs->transnoentities(
"HolidaysValidatedBody",
dol_print_date($objecttmp->date_debut,
'day'),
dol_print_date($objecttmp->date_fin,
'day')).
"\n";
1644 $message .=
"- ".$langs->transnoentitiesnoconv(
"ValidatedBy").
" : ".
dolGetFirstLastname($expediteur->firstname, $expediteur->lastname).
"\n";
1646 $message .=
"- ".$langs->transnoentitiesnoconv(
"Link").
" : ".$dolibarr_main_url_root.
"/holiday/card.php?id=".$objecttmp->id.
"\n\n";
1649 $trackid =
'leav'.$objecttmp->id;
1651 require_once DOL_DOCUMENT_ROOT.
'/core/class/CMailFile.class.php';
1652 $mail =
new CMailFile($subject, $emailTo, $emailFrom, $message, array(), array(), array(),
'',
'', 0, 0,
'',
'', $trackid);
1655 $result = $mail->sendfile();
1664 $langs->load(
"errors");
1665 setEventMessages($langs->trans(
'ErrorNotApproverForHoliday', $objecttmp->ref),
null,
'errors');
1677 } elseif ($nbok == 1) {
1686 if (!$error && ($massaction ==
'increaseholiday' || ($action ==
'increaseholiday' && $confirm ==
'yes')) && $permissiontoapprove) {
1688 $objecttmp =
new $objectclass($db);
1690 $typeholiday =
GETPOST(
'typeholiday',
'alpha');
1691 $nbdaysholidays =
GETPOST(
'nbdaysholidays',
'double');
1693 if ($nbdaysholidays <= 0) {
1699 foreach ($toselect as $toselectid) {
1700 $balancecpuser = $objecttmp->getCPforUser($toselectid, $typeholiday);
1701 if (!empty($balancecpuser)) {
1702 $newnbdaysholidays = $nbdaysholidays + $balancecpuser;
1704 $newnbdaysholidays = $nbdaysholidays;
1706 $result = $holiday->addLogCP($user->id, $toselectid, $langs->transnoentitiesnoconv(
'ManualUpdate'), $newnbdaysholidays, $typeholiday);
1713 $objecttmp->updateSoldeCP($toselectid, $newnbdaysholidays, $typeholiday);
1726 setEventMessages($langs->trans(
"HolidayRecordsIncreased", $nbok),
null,
'mesgs');
1727 } elseif ($nbok == 1) {
1737 $parameters[
'toselect'] = (empty($toselect) ? array() : $toselect);
1738 $parameters[
'uploaddir'] = $uploaddir;
1739 $parameters[
'massaction'] = $massaction;
1740 $parameters[
'diroutputmassaction'] = isset($diroutputmassaction) ? $diroutputmassaction :
null;
1742 $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.
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.