41if (empty($objectclass) || empty($uploaddir)) {
42 dol_print_error(
null,
'include of actions_massactions.inc.php is done but var $objectclass or $uploaddir was not defined');
45if (empty($massaction)) {
51if (!empty($permtoread) && empty($permissiontoread)) {
52 $permissiontoread = $permtoread;
54if (!empty($permtocreate) && empty($permissiontoadd)) {
55 $permissiontoadd = $permtocreate;
57if (!empty($permtodelete) && empty($permissiontodelete)) {
58 $permissiontodelete = $permtodelete;
62$maxformassaction = (!
getDolGlobalString(
'MAIN_LIMIT_FOR_MASS_ACTIONS') ? 1000 : $conf->global->MAIN_LIMIT_FOR_MASS_ACTIONS);
63if ($massaction && is_array($toselect) && count($toselect) < 1) {
67if (!$error && isset($toselect) && is_array($toselect) && count($toselect) > $maxformassaction) {
68 setEventMessages($langs->trans(
'TooManyRecordForMassAction', $maxformassaction),
null,
'errors');
72if (!$error && $massaction ==
'confirm_presend' && !
GETPOST(
'sendmail')) {
73 $massaction =
'presend';
75if (!$error && $massaction ==
'confirm_presend') {
79 $langs->load(
"mails");
80 include_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
81 include_once DOL_DOCUMENT_ROOT.
'/core/lib/signature.lib.php';
83 $listofobjectid = array();
84 $listofobjectthirdparties = array();
85 $listofobjectcontacts = array();
86 $listofobjectref = array();
87 $contactidtosend = array();
88 $attachedfilesThirdpartyObj = array();
89 $oneemailperrecipient = (
GETPOSTINT(
'oneemailperrecipient') ? 1 : 0);
92 $objecttmp =
new $objectclass($db);
96 if ($objecttmp->element ==
'expensereport') {
97 $thirdparty =
new User($db);
98 } elseif ($objecttmp->element ==
'contact') {
100 } elseif ($objecttmp->element ==
'partnership' &&
getDolGlobalString(
'PARTNERSHIP_IS_MANAGED_FOR') ==
'member') {
102 } elseif ($objecttmp->element ==
'holiday') {
103 $thirdparty =
new User($db);
104 } elseif ($objecttmp->element ==
'conferenceorboothattendee') {
108 foreach ($toselect as $toselectid) {
109 $objecttmp =
new $objectclass($db);
110 $result = $objecttmp->fetch($toselectid);
112 $listofobjectid[$toselectid] = $toselectid;
113 $tmpobjectid = ($objecttmp->fk_soc ? $objecttmp->fk_soc : $objecttmp->socid);
114 if ($objecttmp->element ==
'societe') {
115 $tmpobjectid = $objecttmp->id;
116 } elseif ($objecttmp->element ==
'contact') {
117 $tmpobjectid = $objecttmp->id;
118 } elseif ($objecttmp->element ==
'expensereport') {
119 $tmpobjectid = $objecttmp->fk_user_author;
120 } elseif ($objecttmp->element ==
'partnership' &&
getDolGlobalString(
'PARTNERSHIP_IS_MANAGED_FOR') ==
'member') {
121 $tmpobjectid = $objecttmp->fk_member;
122 } elseif ($objecttmp->element ==
'holiday') {
123 $tmpobjectid = $objecttmp->fk_user;
124 } elseif ($objecttmp->element ==
'conferenceorboothattendee') {
125 $tmpobjectid = $objecttmp->id;
127 if (empty($tmpobjectid)) {
131 if ($objectclass ==
'Facture') {
132 $tmparraycontact = array();
133 $tmparraycontact = $objecttmp->liste_contact(-1,
'external', 0,
'BILLING');
134 if (is_array($tmparraycontact) && count($tmparraycontact) > 0) {
135 foreach ($tmparraycontact as $data_email) {
136 $listofobjectcontacts[$toselectid][$data_email[
'id']] = $data_email[
'email'];
139 } elseif ($objectclass ==
'CommandeFournisseur') {
140 $tmparraycontact = array();
141 $tmparraycontact = $objecttmp->liste_contact(-1,
'external', 0,
'CUSTOMER');
142 if (is_array($tmparraycontact) && count($tmparraycontact) > 0) {
143 foreach ($tmparraycontact as $data_email) {
144 $listofobjectcontacts[$toselectid][$data_email[
'id']] = $data_email[
'email'];
149 $listofobjectthirdparties[$tmpobjectid] = $tmpobjectid;
150 $listofobjectref[$tmpobjectid][$toselectid] = $objecttmp;
156 if (
GETPOST(
'fromtype',
'alpha') ===
'user' && empty($user->email)) {
159 $massaction =
'presend';
162 $receiver =
GETPOST(
'receiver',
'alphawithlgt');
163 if (!is_array($receiver)) {
164 if (empty($receiver) || $receiver ==
'-1') {
167 $receiver = array($receiver);
170 if (!trim(
GETPOST(
'sendto',
'alphawithlgt')) && count($receiver) == 0 && count($listofobjectthirdparties) == 1) {
172 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Recipient")),
null,
'warnings');
173 $massaction =
'presend';
176 if (!
GETPOST(
'subject',
'restricthtml')) {
178 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"MailTopic")),
null,
'warnings');
179 $massaction =
'presend';
184 foreach ($listofobjectthirdparties as $thirdpartyid) {
185 $result = $thirdparty->fetch($thirdpartyid);
198 if (trim(
GETPOST(
'sendto',
'alphawithlgt'))) {
200 $tmparray[] = trim(
GETPOST(
'sendto',
'alphawithlgt'));
202 if (count($receiver) > 0) {
203 foreach ($receiver as $key => $val) {
205 if ($val ==
'thirdparty') {
206 $tmparray[] = $thirdparty->name.
' <'.$thirdparty->email.
'>';
207 } elseif ($val && method_exists($thirdparty,
'contact_get_property')) {
208 $tmparray[] = $thirdparty->contact_get_property((
int) $val,
'email');
213 $sendto = implode(
',', $tmparray);
216 $receivercc =
GETPOST(
'receivercc',
'alphawithlgt');
217 if (!is_array($receivercc)) {
218 if ($receivercc ==
'-1') {
219 $receivercc = array();
221 $receivercc = array($receivercc);
225 if (trim(
GETPOST(
'sendtocc',
'alphawithlgt'))) {
226 $tmparray[] = trim(
GETPOST(
'sendtocc',
'alphawithlgt'));
228 if (count($receivercc) > 0) {
229 foreach ($receivercc as $key => $val) {
231 if ($val ==
'thirdparty') {
232 $tmparray[] = $thirdparty->name.
' <'.$thirdparty->email.
'>';
234 $tmparray[] = $thirdparty->contact_get_property((
int) $val,
'email');
239 $sendtocc = implode(
',', $tmparray);
242 $listofqualifiedobj = array();
243 $listofqualifiedref = array();
244 $thirdpartywithoutemail = array();
246 foreach ($listofobjectref[$thirdpartyid] as $objectid => $objectobj) {
249 $langs->load(
"errors");
251 $resaction .=
'<div class="error">'.$langs->trans(
'ErrorOnlyProposalNotDraftCanBeSentInMassAction', $objectobj->ref).
'</div><br>';
255 $langs->load(
"errors");
257 $resaction .=
'<div class="error">'.$langs->trans(
'ErrorOnlyOrderNotDraftCanBeSentInMassAction', $objectobj->ref).
'</div><br>';
261 $langs->load(
"errors");
263 $resaction .=
'<div class="error">'.$langs->trans(
'ErrorOnlyInvoiceValidatedCanBeSentInMassAction', $objectobj->ref).
'</div><br>';
268 if (empty($sendto)) {
269 if ($objectobj->element ==
'societe') {
270 $sendto = $objectobj->email;
271 } elseif ($objectobj->element ==
'expensereport') {
272 $fuser =
new User($db);
273 $fuser->fetch($objectobj->fk_user_author);
274 $sendto = $fuser->email;
275 } elseif ($objectobj->element ==
'contact') {
277 $fcontact->fetch($objectobj->id);
278 $sendto = $fcontact->email;
279 } elseif ($objectobj->element ==
'partnership' &&
getDolGlobalString(
'PARTNERSHIP_IS_MANAGED_FOR') ==
'member') {
281 $fadherent->fetch($objectobj->fk_member);
282 $sendto = $fadherent->email;
283 } elseif ($objectobj->element ==
'holiday') {
284 $fuser =
new User($db);
285 $fuser->fetch($objectobj->fk_user);
286 $sendto = $fuser->email;
287 } elseif ($objectobj->element ==
'facture' && !empty($listofobjectcontacts[$objectid])) {
288 $emails_to_sends = array();
289 $objectobj->fetch_thirdparty();
290 $contactidtosend = array();
291 foreach ($listofobjectcontacts[$objectid] as $contactemailid => $contactemailemail) {
292 $emails_to_sends[] = $objectobj->thirdparty->contact_get_property($contactemailid,
'email');
293 if (!in_array($contactemailid, $contactidtosend)) {
294 $contactidtosend[] = $contactemailid;
297 if (count($emails_to_sends) > 0) {
298 $sendto = implode(
',', $emails_to_sends);
300 } elseif ($objectobj->element ==
'order_supplier' && !empty($listofobjectcontacts[$objectid])) {
301 $emails_to_sends = array();
302 $objectobj->fetch_thirdparty();
303 $contactidtosend = array();
304 foreach ($listofobjectcontacts[$objectid] as $contactemailid => $contactemailemail) {
305 $emails_to_sends[] = $objectobj->thirdparty->contact_get_property($contactemailid,
'email');
306 if (!in_array($contactemailid, $contactidtosend)) {
307 $contactidtosend[] = $contactemailid;
310 if (count($emails_to_sends) > 0) {
311 $sendto = implode(
',', $emails_to_sends);
313 } elseif ($objectobj->element ==
'conferenceorboothattendee') {
314 $sendto = $objectobj->email;
316 $objectobj->fetch_thirdparty();
317 $sendto = $objectobj->thirdparty->email;
321 if (empty($sendto)) {
322 if ($objectobj->element ==
'societe') {
323 $objectobj->thirdparty = $objectobj;
328 if (empty($thirdpartywithoutemail[$objectobj->thirdparty->id])) {
329 $resaction .=
'<div class="error">'.$langs->trans(
'NoRecipientEmail', $objectobj->thirdparty->name).
'</div><br>';
331 dol_syslog(
'No recipient for thirdparty: '.$objectobj->thirdparty->name, LOG_WARNING);
332 $thirdpartywithoutemail[$objectobj->thirdparty->id] = 1;
336 if (
GETPOST(
'addmaindocfile')) {
343 $filedir = $uploaddir.
'/'.$subdir.dol_sanitizeFileName($objectobj->ref);
344 $filepath = $filedir.
'/'.$filename;
347 if ($objectobj->element ==
'invoice_supplier') {
348 $fileparams =
dol_most_recent_file($uploaddir.
'/'.
get_exdir($objectobj->id, 2, 0, 0, $objectobj, $objectobj->element).$objectobj->ref, preg_quote($objectobj->ref,
'/').
'([^\-])+');
349 $filepath = $fileparams[
'fullname'];
353 $filename_found =
'';
354 $filepath_found =
'';
355 $file_check_list = array();
356 $file_check_list[] = array(
360 if (
getDolGlobalString(
'MAIL_MASS_ACTION_ADD_LAST_IF_MAIN_DOC_NOT_FOUND') && !empty($objectobj->last_main_doc)) {
361 $file_check_list[] = array(
362 'name' => basename($objectobj->last_main_doc),
363 'path' => DOL_DATA_ROOT .
'/' . $objectobj->last_main_doc,
366 foreach ($file_check_list as $file_check_arr) {
368 $filename_found = $file_check_arr[
'name'];
369 $filepath_found = $file_check_arr[
'path'];
374 if ($filepath_found) {
376 $attachedfilesThirdpartyObj[$thirdpartyid][$objectid] = array(
377 'paths' => array($filepath_found),
378 'names' => array($filename_found),
383 $langs->load(
"errors");
384 foreach ($file_check_list as $file_check_arr) {
385 $resaction .=
'<div class="error">'.$langs->trans(
'ErrorCantReadFile', $file_check_arr[
'path']).
'</div><br>';
386 dol_syslog(
'Failed to read file: '.$file_check_arr[
'path'], LOG_WARNING);
393 $listofqualifiedobj[$objectid] = $objectobj;
394 $listofqualifiedref[$objectid] = $objectobj->ref;
401 if (count($listofqualifiedobj) > 0) {
402 $langs->load(
"commercial");
405 $fromtype =
GETPOST(
'fromtype');
406 if ($fromtype ===
'user') {
407 $from =
dol_string_nospecial($user->getFullName($langs),
' ', array(
",")).
' <'.$user->email.
'>';
408 } elseif ($fromtype ===
'company') {
410 } elseif (preg_match(
'/user_aliases_(\d+)/', $fromtype, $reg)) {
411 $tmp = explode(
',', $user->email_aliases);
412 $from = trim($tmp[($reg[1] - 1)]);
413 } elseif (preg_match(
'/global_aliases_(\d+)/', $fromtype, $reg)) {
415 $from = trim($tmp[($reg[1] - 1)]);
416 } elseif (preg_match(
'/senderprofile_(\d+)_(\d+)/', $fromtype, $reg)) {
417 $sql =
"SELECT rowid, label, email FROM ".MAIN_DB_PREFIX.
"c_email_senderprofile WHERE rowid = ".(int) $reg[1];
418 $resql = $db->query($sql);
419 $obj = $db->fetch_object($resql);
428 $subject =
GETPOST(
'subject',
'restricthtml');
429 $message =
GETPOST(
'message',
'restricthtml');
431 $sendtobcc =
GETPOST(
'sendtoccc');
432 if ($objectclass ==
'Propal') {
435 if ($objectclass ==
'Commande') {
438 if ($objectclass ==
'Facture') {
441 if ($objectclass ==
'SupplierProposal') {
442 $sendtobcc .= (!
getDolGlobalString(
'MAIN_MAIL_AUTOCOPY_SUPPLIER_PROPOSAL_TO') ?
'' : (($sendtobcc ?
", " :
"") .
getDolGlobalString(
'MAIN_MAIL_AUTOCOPY_SUPPLIER_PROPOSAL_TO')));
444 if ($objectclass ==
'CommandeFournisseur') {
447 if ($objectclass ==
'FactureFournisseur') {
450 if ($objectclass ==
'Project') {
456 $looparray = array();
457 if (!$oneemailperrecipient) {
458 $looparray = $listofqualifiedobj;
459 foreach ($looparray as $key => $objecttmp) {
460 $looparray[$key]->thirdparty = $thirdparty;
463 $objectforloop =
new $objectclass($db);
464 $objectforloop->thirdparty = $thirdparty;
465 $looparray[0] = $objectforloop;
468 dol_syslog(
"We have set an array of ".count($looparray).
" emails to send. oneemailperrecipient=".$oneemailperrecipient);
470 foreach ($looparray as $objectid => $objecttmp) {
472 if (isModEnabled(
'project') && method_exists($objecttmp,
'fetch_projet') && is_null($objecttmp->project)) {
473 $objecttmp->fetch_projet();
476 $substitutionarray[
'__ID__'] = ($oneemailperrecipient ? implode(
', ', array_keys($listofqualifiedobj)) : $objecttmp->id);
477 $substitutionarray[
'__REF__'] = ($oneemailperrecipient ? implode(
', ', $listofqualifiedref) : $objecttmp->
ref);
478 $substitutionarray[
'__EMAIL__'] = $thirdparty->email;
479 $substitutionarray[
'__CHECK_READ__'] =
'<img src="'.DOL_MAIN_URL_ROOT.
'/public/emailing/mailing-read.php?tag=undefined&securitykey='.
dol_hash(
getDolGlobalString(
'MAILING_EMAIL_UNSUBSCRIBE_KEY').
"-undefined",
'md5').
'" width="1" height="1" style="width:1px;height:1px" border="0"/>';
481 $parameters = array(
'mode' =>
'formemail');
483 if (!empty($listofobjectthirdparties)) {
484 $parameters[
'listofobjectthirdparties'] = $listofobjectthirdparties;
486 if (!empty($listofobjectref)) {
487 $parameters[
'listofobjectref'] = $listofobjectref;
495 $attachedfiles = array(
'paths' => array(),
'names' => array(),
'mimes' => array());
496 if ($oneemailperrecipient) {
498 if (is_array($attachedfilesThirdpartyObj[$thirdparty->id]) && count($attachedfilesThirdpartyObj[$thirdparty->id])) {
499 foreach ($attachedfilesThirdpartyObj[$thirdparty->id] as $keyObjId => $objAttachedFiles) {
501 $attachedfiles = array(
502 'paths' => array_merge($attachedfiles[
'paths'], $objAttachedFiles[
'paths']),
503 'names' => array_merge($attachedfiles[
'names'], $objAttachedFiles[
'names']),
504 'mimes' => array_merge($attachedfiles[
'mimes'], $objAttachedFiles[
'mimes'])
508 } elseif (!empty($attachedfilesThirdpartyObj[$thirdparty->id][$objectid])) {
511 $attachedfiles = $attachedfilesThirdpartyObj[$thirdparty->id][$objectid];
514 $filepath = $attachedfiles[
'paths'];
515 $filename = $attachedfiles[
'names'];
516 $mimetype = $attachedfiles[
'mimes'];
519 if ($oneemailperrecipient) {
520 $trackid =
'thi'.$thirdparty->id;
521 if ($objecttmp->element ==
'expensereport') {
522 $trackid =
'use'.$thirdparty->id;
523 } elseif ($objecttmp->element ==
'contact') {
524 $trackid =
'ctc'.$thirdparty->id;
525 } elseif ($objecttmp->element ==
'holiday') {
526 $trackid =
'use'.$thirdparty->id;
529 $trackid = strtolower(get_class($objecttmp));
530 if (get_class($objecttmp) ==
'Contact') {
532 } elseif (get_class($objecttmp) ==
'Contrat') {
534 } elseif (get_class($objecttmp) ==
'Propal') {
536 } elseif (get_class($objecttmp) ==
'Commande') {
538 } elseif (get_class($objecttmp) ==
'Facture') {
540 } elseif (get_class($objecttmp) ==
'SupplierProposal') {
542 } elseif (get_class($objecttmp) ==
'CommandeFournisseur') {
544 } elseif (get_class($objecttmp) ==
'FactureFournisseur') {
548 $trackid .= $objecttmp->id;
554 if (empty($sendcontext)) {
555 $sendcontext =
'standard';
559 $vardir = $conf->user->dir_output.
"/".$user->id;
560 $upload_dir_tmp = $vardir.
'/temp';
563 require_once DOL_DOCUMENT_ROOT.
'/core/class/CMailFile.class.php';
564 $mailfile =
new CMailFile($subjectreplaced, $sendto, $from, $messagereplaced, $filepath, $mimetype, $filename, $sendtocc, $sendtobcc, $deliveryreceipt, -1,
'',
'', $trackid,
'', $sendcontext,
'', $upload_dir_tmp);
565 if ($mailfile->error) {
566 $resaction .=
'<div class="error">'.$mailfile->error.
'</div>';
568 $result = $mailfile->sendfile();
570 $resaction .= $langs->trans(
'MailSuccessfulySent', $mailfile->getValidAddress($mailfile->addr_from, 2), $mailfile->getValidAddress($mailfile->addr_to, 2)).
'<br>';
575 foreach ($listofqualifiedobj as $objid2 => $objectobj2) {
576 if ((!$oneemailperrecipient) && $objid2 != $objectid) {
580 dol_syslog(
"Try to insert email event into agenda for objid=".$objid2.
" => objectobj=".get_class($objectobj2));
589 $actionmsg = $langs->transnoentities(
'MailSentByTo', $from, $sendto);
592 $actionmsg =
dol_concatdesc($actionmsg, $langs->transnoentities(
'Bcc').
": ".$sendtocc);
594 $actionmsg =
dol_concatdesc($actionmsg, $langs->transnoentities(
'MailTopic').
": ".$subjectreplaced);
595 $actionmsg =
dol_concatdesc($actionmsg, $langs->transnoentities(
'TextUsedInTheMessageBody').
":");
601 $objectobj2->sendtoid = (empty($contactidtosend) ? 0 : $contactidtosend);
602 $objectobj2->actionmsg = $actionmsg;
603 $objectobj2->actionmsg2 = $actionmsg2;
604 $objectobj2->fk_element = $objid2;
605 $objectobj2->elementtype = $objectobj2->element;
607 $objectobj2->actionmsg2 = $subjectreplaced;
610 $triggername = strtoupper(get_class($objectobj2)).
'_SENTBYMAIL';
611 if ($triggername ==
'SOCIETE_SENTBYMAIL') {
612 $triggername =
'COMPANY_SENTBYMAIL';
614 if ($triggername ==
'CONTRAT_SENTBYMAIL') {
615 $triggername =
'CONTRACT_SENTBYMAIL';
617 if ($triggername ==
'COMMANDE_SENTBYMAIL') {
618 $triggername =
'ORDER_SENTBYMAIL';
620 if ($triggername ==
'FACTURE_SENTBYMAIL') {
621 $triggername =
'BILL_SENTBYMAIL';
623 if ($triggername ==
'EXPEDITION_SENTBYMAIL') {
624 $triggername =
'SHIPPING_SENTBYMAIL';
626 if ($triggername ==
'COMMANDEFOURNISSEUR_SENTBYMAIL') {
627 $triggername =
'ORDER_SUPPLIER_SENTBYMAIL';
629 if ($triggername ==
'FACTUREFOURNISSEUR_SENTBYMAIL') {
630 $triggername =
'BILL_SUPPLIER_SENTBYMAIL';
632 if ($triggername ==
'SUPPLIERPROPOSAL_SENTBYMAIL') {
633 $triggername =
'PROPOSAL_SUPPLIER_SENTBYMAIL';
635 if ($triggername ==
'PROJET_SENTBYMAIL') {
636 $triggername =
'PROJECT_SENTBYMAIL';
639 if (!empty($triggername)) {
641 $result = $objectobj2->call_trigger($triggername, $user);
649 dol_syslog(
"Error in trigger ".$triggername.
' '.$db->lasterror(), LOG_ERR);
656 $langs->load(
"other");
657 if ($mailfile->error) {
658 $resaction .= $langs->trans(
'ErrorFailedToSendMail', $from, $sendto);
659 $resaction .=
'<br><div class="error">'.$mailfile->error.
'</div>';
661 $resaction .=
'<div class="warning">No mail sent. Feature is disabled by option MAIN_DISABLE_ALL_MAILS</div>';
663 $resaction .= $langs->trans(
'ErrorFailedToSendMail', $from, $sendto) .
'<br><div class="error">(unhandled error)</div>';
671 $resaction .= ($resaction ?
'<br>' : $resaction);
672 $resaction .=
'<strong>'.$langs->trans(
"ResultOfMailSending").
':</strong><br>'.
"\n";
673 $resaction .= $langs->trans(
"NbSelected").
': '.count($toselect).
"\n<br>";
674 $resaction .= $langs->trans(
"NbIgnored").
': '.($nbignored ? $nbignored : 0).
"\n<br>";
675 $resaction .= $langs->trans(
"NbSent").
': '.($nbsent ? $nbsent : 0).
"\n<br>";
680 setEventMessages($langs->trans(
"EMailSentForNElements", $nbsent.
'/'.count($toselect)),
null,
'mesgs');
693if (!$error && $massaction ==
'cancelorders') {
698 $orders =
GETPOST(
'toselect',
'array');
699 foreach ($orders as $id_order) {
701 if ($cmd->fetch($id_order) <= 0) {
706 $langs->load(
'errors');
707 setEventMessages($langs->trans(
"ErrorObjectMustHaveStatusValidToBeCanceled", $cmd->ref),
null,
'errors');
712 $result = $cmd->cancel();
732if (!$error && $massaction ==
"builddoc" && $permissiontoread && !
GETPOST(
'button_search')) {
733 if (empty($diroutputmassaction)) {
734 dol_print_error(
null,
'include of actions_massactions.inc.php is done but var $diroutputmassaction was not defined');
738 require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
739 require_once DOL_DOCUMENT_ROOT.
'/core/lib/pdf.lib.php';
740 require_once DOL_DOCUMENT_ROOT.
'/core/lib/date.lib.php';
742 $objecttmp =
new $objectclass($db);
743 $listofobjectid = array();
744 $listofobjectthirdparties = array();
745 $listofobjectref = array();
746 foreach ($toselect as $toselectid) {
747 $objecttmp =
new $objectclass($db);
748 $result = $objecttmp->fetch($toselectid);
750 $listofobjectid[$toselectid] = $toselectid;
751 $thirdpartyid = !empty($objecttmp->fk_soc) ? $objecttmp->fk_soc : $objecttmp->socid;
752 $listofobjectthirdparties[$thirdpartyid] = $thirdpartyid;
753 $listofobjectref[$toselectid] = $objecttmp->ref;
757 $arrayofinclusion = array();
758 foreach ($listofobjectref as $tmppdf) {
761 foreach ($listofobjectref as $tmppdf) {
762 $arrayofinclusion[] =
'^'.preg_quote(
dol_sanitizeFileName($tmppdf),
'/').
'_[a-zA-Z0-9\-\_\'\&\.]+\.pdf$';
764 $listoffiles =
dol_dir_list($uploaddir,
'all', 1, implode(
'|', $arrayofinclusion),
'\.meta$|\.png',
'date', SORT_DESC, 0, 1);
768 foreach ($listofobjectref as $basename) {
770 foreach ($listoffiles as $filefound) {
771 if (strstr($filefound[
"name"], $basename)) {
772 $files[] = $uploaddir.
'/'.$basename.
'/'.$filefound[
"name"];
779 $outputlangs = $langs;
782 $newlang =
GETPOST(
'lang_id',
'aZ09');
787 if (!empty($newlang)) {
789 $outputlangs->setDefaultLang($newlang);
798 $filename = preg_replace(
'/\s/',
'_', $filename);
801 if (in_array($objecttmp->element, array(
'facture',
'facture_fournisseur')) && $search_status ==
Facture::STATUS_VALIDATED) {
802 if ($option ==
'late') {
809 $filename .=
'_'.$year;
812 $filename .=
'_'.$month;
815 if (count($files) > 0) {
817 $file = $diroutputmassaction.
'/'.$filename.
'_'.
dol_print_date($now,
'dayhourlog').
'.pdf';
820 foreach ($files as $f) {
821 $input_files .=
' '.escapeshellarg($f);
824 $cmd =
'pdftk '.$input_files.
' cat output '.escapeshellarg($file);
828 if (file_exists($file)) {
831 $langs->load(
"exports");
834 setEventMessages($langs->trans(
'ErrorPDFTkOutputFileNotFound'),
null,
'errors');
837 setEventMessages($langs->trans(
'NoPDFAvailableForDocGenAmongChecked'),
null,
'errors');
842 $page_largeur = $formatarray[
'width'];
843 $page_hauteur = $formatarray[
'height'];
844 $format = array($page_largeur, $page_hauteur);
848 if (class_exists(
'TCPDF')) {
849 $pdf->setPrintHeader(
false);
850 $pdf->setPrintFooter(
false);
855 $pdf->SetCompression(
false);
859 foreach ($files as $file) {
861 $pagecount = $pdf->setSourceFile($file);
862 for ($i = 1; $i <= $pagecount; $i++) {
863 $tplidx = $pdf->importPage($i);
864 $s = $pdf->getTemplatesize($tplidx);
865 $pdf->AddPage($s[
'h'] > $s[
'w'] ?
'P' :
'L');
866 $pdf->useTemplate($tplidx);
875 $filename = preg_replace(
'/\s/',
'_', $filename);
878 if (in_array($objecttmp->element, array(
'facture',
'facture_fournisseur')) && $search_status ==
Facture::STATUS_VALIDATED) {
879 if ($option ==
'late') {
886 $filename .=
'_'.$year;
889 $filename .=
'_'.$month;
893 $file = $diroutputmassaction.
'/'.$filename.
'_'.
dol_print_date($now,
'dayhourlog').
'.pdf';
894 $pdf->Output($file,
'F');
897 $langs->load(
"exports");
900 setEventMessages($langs->trans(
'NoPDFAvailableForDocGenAmongChecked'),
null,
'errors');
906if ($action ==
'remove_file') {
907 require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
909 $langs->load(
"other");
910 $upload_dir = $diroutputmassaction;
911 $file = $upload_dir.
'/'.
GETPOST(
'file');
923if (!$error && $massaction ==
'validate' && $permissiontoadd) {
924 $objecttmp =
new $objectclass($db);
926 if (($objecttmp->element ==
'facture' || $objecttmp->element ==
'invoice') && isModEnabled(
'stock') &&
getDolGlobalString(
'STOCK_CALCULATE_ON_BILL')) {
927 $langs->load(
"errors");
928 setEventMessages($langs->trans(
'ErrorMassValidationNotAllowedWhenStockIncreaseOnAction'),
null,
'errors');
931 if ($objecttmp->element ==
'invoice_supplier' && isModEnabled(
'stock') &&
getDolGlobalString(
'STOCK_CALCULATE_ON_SUPPLIER_BILL')) {
932 $langs->load(
"errors");
933 setEventMessages($langs->trans(
'ErrorMassValidationNotAllowedWhenStockIncreaseOnAction'),
null,
'errors');
936 if ($objecttmp->element ==
'facture') {
939 $sql =
"SELECT rowid FROM ".MAIN_DB_PREFIX.
"facture";
940 $sql .=
" WHERE rowid IN (".$db->sanitize(implode(
",", $toselect)).
")";
941 $sql .=
" ORDER BY datef";
943 $resql = $db->query($sql);
946 while (!empty($arr = $db->fetch_row($resql))) {
947 $toselectnew[] = $arr[0];
949 $toselect = (empty($toselectnew)) ? $toselect : $toselectnew;
960 foreach ($toselect as $toselectid) {
961 $result = $objecttmp->fetch($toselectid);
963 if (method_exists($objecttmp,
'validate')) {
964 $result = $objecttmp->validate($user);
965 } elseif (method_exists($objecttmp,
'setValid')) {
966 $result = $objecttmp->setValid($user);
968 $objecttmp->error =
'No method validate or setValid on this object';
972 $langs->load(
"errors");
973 setEventMessages($langs->trans(
"ErrorObjectMustHaveStatusDraftToBeValidated", $objecttmp->ref),
null,
'errors');
976 } elseif ($result < 0) {
984 $outputlangs = $langs;
987 $newlang =
GETPOST(
'lang_id',
'aZ09');
989 if (
getDolGlobalInt(
'MAIN_MULTILANGS') && empty($newlang) && property_exists($objecttmp,
'thirdparty')) {
990 if ((property_exists($objecttmp,
'socid') || property_exists($objecttmp,
'fk_soc')) && empty($objecttmp->thirdparty)) {
991 $objecttmp->fetch_thirdparty();
993 if (!empty($objecttmp->thirdparty)) {
994 $newlang = $objecttmp->thirdparty->default_lang;
997 if (!empty($newlang)) {
999 $outputlangs->setDefaultLang($newlang);
1000 $outputlangs->load(
'products');
1002 $model = $objecttmp->model_pdf;
1003 $ret = $objecttmp->fetch($objecttmp->id);
1005 $hidedetails = !empty($hidedetails) ? $hidedetails : (
getDolGlobalString(
'MAIN_GENERATE_DOCUMENTS_HIDE_DETAILS') ? 1 : 0);
1006 $hidedesc = !empty($hidedesc) ? $hidedesc : (
getDolGlobalString(
'MAIN_GENERATE_DOCUMENTS_HIDE_DESC') ? 1 : 0);
1007 $hideref = !empty($hideref) ? $hideref : (
getDolGlobalString(
'MAIN_GENERATE_DOCUMENTS_HIDE_REF') ? 1 : 0);
1008 $moreparams = !empty($moreparams) ? $moreparams :
null;
1010 $result = $objecttmp->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref);
1028 setEventMessages($langs->trans(
"RecordModifiedSuccessfully"),
null,
'mesgs');
1038if (!$error && ($massaction ==
'delete' || ($action ==
'delete' && $confirm ==
'yes')) && $permissiontodelete) {
1041 $objecttmp =
new $objectclass($db);
1047 $unique_arr = array_unique($toselect);
1048 foreach ($unique_arr as $toselectid) {
1049 $result = $objecttmp->fetch($toselectid);
1053 $langs->load(
"errors");
1055 $TMsg[] =
'<div class="error">'.$langs->trans(
'ErrorOnlyDraftStatusCanBeDeletedInMassAction', $objecttmp->ref).
'</div><br>';
1059 if (method_exists($objecttmp,
'is_erasable') && $objecttmp->is_erasable() <= 0) {
1060 $langs->load(
"errors");
1062 $TMsg[] =
'<div class="error">'.$langs->trans(
'ErrorRecordHasChildren').
' '.$objecttmp->ref.
'</div><br>';
1067 $langs->load(
"errors");
1069 $TMsg[] =
'<div class="error">'.$langs->trans(
'ErrorLeaveRequestMustBeDraftCanceledOrRefusedToBeDeleted', $objecttmp->ref).
'</div><br>';
1073 if ($objectclass ==
"Task" && $objecttmp->hasChildren() > 0) {
1074 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"projet_task SET fk_task_parent = 0 WHERE fk_task_parent = ".((int) $objecttmp->id);
1075 $res = $db->query($sql);
1083 if ($objecttmp->element ==
'societe') {
1085 '@phan-var-force Societe $objecttmp';
1087 $result = $objecttmp->delete($objecttmp->id, $user, 1);
1089 $result = $objecttmp->delete($user);
1092 if (empty($result)) {
1093 $TMsg = array_merge($objecttmp->errors, $TMsg);
1094 } elseif ($result < 0) {
1108 if (empty($error)) {
1112 } elseif ($nbok > 0) {
1119 if (!empty($TMsg)) {
1134if (!$error && $massaction ==
'generate_doc' && $permissiontoread) {
1136 $objecttmp =
new $objectclass($db);
1138 foreach ($toselect as $toselectid) {
1139 $result = $objecttmp->fetch($toselectid);
1141 $outputlangs = $langs;
1145 $newlang =
GETPOST(
'lang_id',
'aZ09');
1147 if (
getDolGlobalInt(
'MAIN_MULTILANGS') && empty($newlang) && isset($objecttmp->thirdparty->default_lang)) {
1148 $newlang = $objecttmp->thirdparty->default_lang;
1150 if (
getDolGlobalInt(
'MAIN_MULTILANGS') && empty($newlang) && isset($objecttmp->default_lang)) {
1151 $newlang = $objecttmp->default_lang;
1153 if (
getDolGlobalInt(
'MAIN_MULTILANGS') && empty($newlang) && empty($objecttmp->thirdparty)) {
1154 $objecttmp->fetch_thirdparty();
1155 $newlang = $objecttmp->thirdparty->default_lang;
1157 if (!empty($newlang)) {
1158 $outputlangs =
new Translate(
"", $conf);
1159 $outputlangs->setDefaultLang($newlang);
1163 if (empty($hidedetails)) {
1166 if (empty($hidedesc)) {
1169 if (empty($hideref)) {
1172 if (empty($moreparams)) {
1176 $result = $objecttmp->generateDocument($objecttmp->model_pdf, $outputlangs, $hidedetails, $hidedesc, $hideref, $moreparams);
1204if (!$error && ($action ==
'affecttag' && $confirm ==
'yes') && $permissiontoadd) {
1208 $affecttag_type =
GETPOST(
'affecttag_type',
'alpha');
1209 if (!empty($affecttag_type)) {
1210 $affecttag_type_array = explode(
',', $affecttag_type);
1214 if (!empty($affecttag_type_array)) {
1216 require_once DOL_DOCUMENT_ROOT.
'/categories/class/categorie.class.php';
1218 $to_affecttag_type_array = array();
1219 $categ_type_array = $categ->getMapList();
1220 foreach ($categ_type_array as $categdef) {
1221 if (in_array($categdef[
'code'], $affecttag_type_array)) {
1222 $to_affecttag_type_array[] = $categdef[
'code'];
1227 if (!empty($to_affecttag_type_array)) {
1228 foreach ($to_affecttag_type_array as $categ_type) {
1229 $contcats =
GETPOST(
'contcats_' . $categ_type,
'array');
1231 foreach ($toselect as $toselectid) {
1232 $result =
$object->fetch($toselectid);
1235 $result =
$object->setCategoriesCommon($contcats, $categ_type,
false);
1254 $toselect = array();
1260if (!$error && ($action ==
'updateprice' && $confirm ==
'yes') && $permissiontoadd) {
1263 if (GETPOSTISSET(
'pricerate')) {
1265 if ($pricepercentage == 0) {
1268 foreach ($toselect as $toselectid) {
1269 $result =
$object->fetch($toselectid);
1272 if ($obj->price_base_type ==
'TTC') {
1273 $newprice =
$object->price_ttc * (100 + $pricepercentage) / 100;
1274 $minprice =
$object->price_min_ttc;
1276 $newprice =
$object->price * (100 + $pricepercentage) / 100;
1277 $minprice =
$object->price_min;
1279 $res =
$object->updatePrice($newprice, $obj->price_base_type, $user,
$object->tva_tx, $minprice, 0,
$object->tva_npr, 0, 0, array(),
$object->default_vat_code);
1299 $toselect = array();
1305if (!$error && ($action ==
'setsupervisor' && $confirm ==
'yes') && $permissiontoadd) {
1308 $supervisortoset =
GETPOST(
'supervisortoset');
1309 if (!empty($supervisortoset)) {
1310 foreach ($toselect as $toselectid) {
1311 $result =
$object->fetch($toselectid);
1314 $object->fk_user = $supervisortoset;
1315 $res =
$object->update($user);
1335 $toselect = array();
1341if (!$error && ($action ==
'affectuser' && $confirm ==
'yes') && $permissiontoadd) {
1345 $usertoaffect =
GETPOST(
'usertoaffect');
1346 $projectrole =
GETPOST(
'projectrole');
1347 $tasksrole =
GETPOST(
'tasksrole');
1348 if (!empty($usertoaffect)) {
1349 foreach ($toselect as $toselectid) {
1350 $result =
$object->fetch($toselectid);
1353 $res =
$object->add_contact($usertoaffect, $projectrole,
'internal');
1355 $taskstatic =
new Task($db);
1356 $task_array = $taskstatic->getTasksArray(0, 0,
$object->id, 0, 0);
1358 foreach ($task_array as $task) {
1359 $tasksToAffect =
new Task($db);
1360 $result = $tasksToAffect->fetch($task->id);
1362 $res = $tasksToAffect->add_contact($usertoaffect, $tasksrole,
'internal');
1386 $toselect = array();
1392if (!$error && ($massaction ==
'enable' || ($action ==
'enable' && $confirm ==
'yes')) && $permissiontoadd) {
1395 $objecttmp =
new $objectclass($db);
1397 foreach ($toselect as $toselectid) {
1398 $result = $objecttmp->fetch($toselectid);
1400 if (in_array($objecttmp->element, array(
'societe'))) {
1401 $result = $objecttmp->setStatut(1);
1429if (!$error && ($massaction ==
'disable' || ($action ==
'disable' && $confirm ==
'yes')) && $permissiontoadd) {
1432 $objecttmp =
new $objectclass($db);
1434 foreach ($toselect as $toselectid) {
1435 $result = $objecttmp->fetch($toselectid);
1437 if (in_array($objecttmp->element, array(
'societe'))) {
1438 $result = $objecttmp->setStatut(0);
1466if (!$error && $action ==
'confirm_edit_value_extrafields' && $confirm ==
'yes' && $permissiontoadd) {
1469 $objecttmp =
new $objectclass($db);
1471 $e->fetch_name_optionals_label($objecttmp->table_element);
1474 $extrafieldKeyToUpdate =
GETPOST(
'extrafield-key-to-update');
1477 foreach ($toselect as $toselectid) {
1479 $objecttmp =
new $objectclass($db);
1480 $result = $objecttmp->fetch($toselectid);
1483 $ret = $e->setOptionalsFromPost(
null, $objecttmp, $extrafieldKeyToUpdate);
1485 $objecttmp->insertExtraFields();
1509if (!$error && ($massaction ==
'affectcommercial' || ($action ==
'affectcommercial' && $confirm ==
'yes')) && $permissiontoadd) {
1512 $objecttmp =
new $objectclass($db);
1515 foreach ($toselect as $toselectid) {
1516 $result = $objecttmp->fetch($toselectid);
1518 if (in_array($objecttmp->element, array(
'societe'))) {
1519 $result = $objecttmp->setSalesRep(
GETPOST(
"commercial",
"alpha"));
1537 setEventMessages($langs->trans(
"CommercialsAffected", $nbok),
null,
'mesgs');
1547if (!$error && ($massaction ==
'unassigncommercial' || ($action ==
'unassigncommercial' && $confirm ==
'yes')) && $permissiontoadd) {
1550 $objecttmp =
new $objectclass($db);
1553 foreach ($toselect as $toselectid) {
1554 $result = $objecttmp->fetch($toselectid);
1556 if (in_array($objecttmp->element, array(
'societe'))) {
1557 $TCommercial =
GETPOST(
"commercial",
"alpha");
1558 if (is_array($TCommercial)) {
1559 foreach ($TCommercial as $commercial) {
1560 $result = $objecttmp->del_commercial($user, $commercial);
1580 setEventMessages($langs->trans(
"CommercialsDisaffected", $nbok),
null,
'mesgs');
1590if (!$error && ($massaction ==
'approveleave' || ($action ==
'approveleave' && $confirm ==
'yes')) && $permissiontoapprove) {
1593 $objecttmp =
new $objectclass($db);
1595 foreach ($toselect as $toselectid) {
1596 $result = $objecttmp->fetch($toselectid);
1599 setEventMessages($langs->trans(
'StatusOfRefMustBe', $objecttmp->ref, $langs->transnoentitiesnoconv(
'Validated')),
null,
'warnings');
1602 if ($user->id == $objecttmp->fk_validator) {
1603 $objecttmp->oldcopy =
dol_clone($objecttmp, 2);
1605 $objecttmp->date_valid =
dol_now();
1606 $objecttmp->fk_user_valid = $user->id;
1608 $objecttmp->statut = $objecttmp->status;
1610 $verif = $objecttmp->approve($user);
1620 $nbopenedday =
num_open_day($objecttmp->date_debut_gmt, $objecttmp->date_fin_gmt, 0, 1, $objecttmp->halfday);
1621 $soldeActuel = $objecttmp->getCpforUser($objecttmp->fk_user, $objecttmp->fk_type);
1622 $newSolde = ($soldeActuel - $nbopenedday);
1625 $result = $objecttmp->addLogCP($user->id, $objecttmp->fk_user, $langs->transnoentitiesnoconv(
"Holidays"), $newSolde, $objecttmp->fk_type);
1632 $result = $objecttmp->updateSoldeCP($objecttmp->fk_user, $newSolde, $objecttmp->fk_type);
1641 $destinataire =
new User($db);
1642 $destinataire->fetch($objecttmp->fk_user);
1643 $emailTo = $destinataire->email;
1646 dol_syslog(
"User that request leave has no email, so we redirect directly to finished page without sending email");
1649 $expediteur =
new User($db);
1650 $expediteur->fetch($objecttmp->fk_validator);
1660 $subject = $societeName.
" - ".$langs->transnoentitiesnoconv(
"HolidaysValidated");
1663 $message = $langs->transnoentitiesnoconv(
"Hello").
" ".$destinataire->firstname.
",\n";
1666 $message .= $langs->transnoentities(
"HolidaysValidatedBody",
dol_print_date($objecttmp->date_debut,
'day'),
dol_print_date($objecttmp->date_fin,
'day')).
"\n";
1668 $message .=
"- ".$langs->transnoentitiesnoconv(
"ValidatedBy").
" : ".
dolGetFirstLastname($expediteur->firstname, $expediteur->lastname).
"\n";
1670 $message .=
"- ".$langs->transnoentitiesnoconv(
"Link").
" : ".$dolibarr_main_url_root.
"/holiday/card.php?id=".$objecttmp->id.
"\n\n";
1673 $trackid =
'leav'.$objecttmp->id;
1675 require_once DOL_DOCUMENT_ROOT.
'/core/class/CMailFile.class.php';
1676 $mail =
new CMailFile($subject, $emailTo, $emailFrom, $message, array(), array(), array(),
'',
'', 0, 0,
'',
'', $trackid);
1679 $result = $mail->sendfile();
1688 $langs->load(
"errors");
1689 setEventMessages($langs->trans(
'ErrorNotApproverForHoliday', $objecttmp->ref),
null,
'errors');
1701 } elseif ($nbok == 1) {
1710if (!$error && ($massaction ==
'increaseholiday' || ($action ==
'increaseholiday' && $confirm ==
'yes')) && $permissiontoapprove) {
1712 $objecttmp =
new $objectclass($db);
1714 $typeholiday =
GETPOST(
'typeholiday',
'alpha');
1717 if ($nbdaysholidays <= 0) {
1723 foreach ($toselect as $toselectid) {
1724 $balancecpuser = $objecttmp->getCPforUser($toselectid, $typeholiday);
1725 if (!empty($balancecpuser)) {
1726 $newnbdaysholidays = $nbdaysholidays + $balancecpuser;
1728 $newnbdaysholidays = $nbdaysholidays;
1730 $result = $holiday->addLogCP($user->id, $toselectid, $langs->transnoentitiesnoconv(
'ManualUpdate'), $newnbdaysholidays, $typeholiday);
1737 $objecttmp->updateSoldeCP($toselectid, $newnbdaysholidays, $typeholiday);
1750 setEventMessages($langs->trans(
"HolidayRecordsIncreased", $nbok),
null,
'mesgs');
1751 } elseif ($nbok == 1) {
1755 $toselect = array();
1762if (!$error && ($massaction ==
'clonetasks' || ($action ==
'clonetasks' && $confirm ==
'yes'))) {
1767 $origin_task =
new Task($db);
1768 $clone_task =
new Task($db);
1770 foreach (
GETPOST(
'selected') as $task) {
1771 $origin_task->fetch($task, $ref =
'', $loadparentdata = 0);
1774 $obj = !
getDolGlobalString(
'PROJECT_TASK_ADDON') ?
'mod_task_simple' : $conf->global->PROJECT_TASK_ADDON;
1776 require_once DOL_DOCUMENT_ROOT .
"/core/modules/project/task/" .
getDolGlobalString(
'PROJECT_TASK_ADDON') .
'.php';
1777 $modTask =
new $obj();
1778 $defaultref = $modTask->getNextValue(0, $clone_task);
1782 $clone_task->fk_project =
GETPOSTINT(
'projectid');
1783 $clone_task->ref = $defaultref;
1784 $clone_task->label = $origin_task->label;
1785 $clone_task->description = $origin_task->description;
1786 $clone_task->planned_workload = $origin_task->planned_workload;
1787 $clone_task->fk_task_parent = $origin_task->fk_task_parent;
1788 $clone_task->date_c =
dol_now();
1789 $clone_task->date_start = $origin_task->date_start;
1790 $clone_task->date_end = $origin_task->date_end;
1791 $clone_task->progress = $origin_task->progress;
1794 $ret = $extrafields->setOptionalsFromPost(
null, $clone_task);
1796 $taskid = $clone_task->create($user);
1799 $result = $clone_task->add_contact(
GETPOSTINT(
"userid"),
'TASKEXECUTIVE',
'internal');
1802 if ($db->lasterrno() ==
'DB_ERROR_RECORD_ALREADY_EXISTS') {
1803 $langs->load(
"projects");
1805 $duplicate_code_error =
true;
1817 header(
"Refresh: 1;URL=".DOL_URL_ROOT.
'/projet/tasks.php?id=' .
GETPOSTINT(
'projectid'));
1821$parameters[
'toselect'] = (empty($toselect) ? array() : $toselect);
1822$parameters[
'uploaddir'] = $uploaddir;
1823$parameters[
'massaction'] = $massaction;
1824$parameters[
'diroutputmassaction'] = isset($diroutputmassaction) ? $diroutputmassaction :
null;
1826$reshook = $hookmanager->executeHooks(
'doMassActions', $parameters,
$object, $action);
if( $user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $object
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_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($utf8_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_most_recent_file($dir, $regexfilter='', $excludefilter=array('(\.meta|_preview.*\.png) $', '^\.'), $nohook=0, $mode=0)
Return file(s) into a directory (by default most recent)
dol_mimetype($file, $default='application/octet-stream', $mode=0)
Return MIME type of a file from its name with extension.
GETPOSTINT($paramname, $method=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
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.
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.
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs=null, $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
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.
GETPOSTFLOAT($paramname, $rounding='')
Return the value of a $_GET or $_POST supervariable, converted into float.
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.
dol_print_error($db=null, $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
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.