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';
76if (!$error && $massaction ==
'confirm_presend') {
80 $langs->load(
"mails");
81 include_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
82 include_once DOL_DOCUMENT_ROOT.
'/core/lib/signature.lib.php';
84 $listofobjectid = array();
85 $listofobjectthirdparties = array();
86 $listofobjectcontacts = array();
87 $listofobjectref = array();
88 $contactidtosend = array();
89 $attachedfilesThirdpartyObj = array();
90 $oneemailperrecipient = (
GETPOSTINT(
'oneemailperrecipient') ? 1 : 0);
93 $objecttmp =
new $objectclass($db);
97 if ($objecttmp->element ==
'expensereport') {
98 $thirdparty =
new User($db);
99 } elseif ($objecttmp->element ==
'contact') {
100 $thirdparty =
new Contact($db);
101 } elseif ($objecttmp->element ==
'partnership' &&
getDolGlobalString(
'PARTNERSHIP_IS_MANAGED_FOR') ==
'member') {
103 } elseif ($objecttmp->element ==
'holiday') {
104 $thirdparty =
new User($db);
105 } elseif ($objecttmp->element ==
'conferenceorboothattendee') {
109 foreach ($toselect as $toselectid) {
110 $objecttmp =
new $objectclass($db);
111 $result = $objecttmp->fetch($toselectid);
113 $listofobjectid[$toselectid] = $toselectid;
114 $tmpobjectid = ($objecttmp->fk_soc ? $objecttmp->fk_soc : $objecttmp->socid);
115 if ($objecttmp->element ==
'societe') {
116 $tmpobjectid = $objecttmp->id;
117 } elseif ($objecttmp->element ==
'contact') {
118 $tmpobjectid = $objecttmp->id;
119 } elseif ($objecttmp->element ==
'expensereport') {
120 $tmpobjectid = $objecttmp->fk_user_author;
121 } elseif ($objecttmp->element ==
'partnership' &&
getDolGlobalString(
'PARTNERSHIP_IS_MANAGED_FOR') ==
'member') {
122 $tmpobjectid = $objecttmp->fk_member;
123 } elseif ($objecttmp->element ==
'holiday') {
124 $tmpobjectid = $objecttmp->fk_user;
125 } elseif ($objecttmp->element ==
'conferenceorboothattendee') {
126 $tmpobjectid = $objecttmp->id;
128 if (empty($tmpobjectid)) {
132 if ($objectclass ==
'Facture') {
133 $tmparraycontact = array();
134 $tmparraycontact = $objecttmp->liste_contact(-1,
'external', 0,
'BILLING');
135 if (is_array($tmparraycontact) && count($tmparraycontact) > 0) {
136 foreach ($tmparraycontact as $data_email) {
137 $listofobjectcontacts[$toselectid][$data_email[
'id']] = $data_email[
'email'];
140 } elseif ($objectclass ==
'CommandeFournisseur') {
141 $tmparraycontact = array();
142 $tmparraycontact = $objecttmp->liste_contact(-1,
'external', 0,
'CUSTOMER');
143 if (is_array($tmparraycontact) && count($tmparraycontact) > 0) {
144 foreach ($tmparraycontact as $data_email) {
145 $listofobjectcontacts[$toselectid][$data_email[
'id']] = $data_email[
'email'];
150 $listofobjectthirdparties[$tmpobjectid] = $tmpobjectid;
151 $listofobjectref[$tmpobjectid][$toselectid] = $objecttmp;
157 if (
GETPOST(
'fromtype',
'alpha') ===
'user' && empty($user->email)) {
160 $massaction =
'presend';
163 $receiver =
GETPOST(
'receiver',
'alphawithlgt');
164 if (!is_array($receiver)) {
165 if (empty($receiver) || $receiver ==
'-1') {
168 $receiver = array($receiver);
171 if (!trim(
GETPOST(
'sendto',
'alphawithlgt')) && count($receiver) == 0 && count($listofobjectthirdparties) == 1) {
173 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Recipient")),
null,
'warnings');
174 $massaction =
'presend';
177 if (!
GETPOST(
'subject',
'restricthtml')) {
179 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"MailTopic")),
null,
'warnings');
180 $massaction =
'presend';
185 foreach ($listofobjectthirdparties as $thirdpartyid) {
186 $result = $thirdparty->fetch($thirdpartyid);
199 if (trim(
GETPOST(
'sendto',
'alphawithlgt'))) {
201 $tmparray[] = trim(
GETPOST(
'sendto',
'alphawithlgt'));
203 if (count($receiver) > 0) {
204 foreach ($receiver as $key => $val) {
206 if ($val ==
'thirdparty') {
207 $tmparray[] = $thirdparty->name.
' <'.$thirdparty->email.
'>';
208 } elseif ($val && method_exists($thirdparty,
'contact_get_property')) {
209 $tmparray[] = $thirdparty->contact_get_property((
int) $val,
'email');
214 $sendto = implode(
',', $tmparray);
217 $receivercc =
GETPOST(
'receivercc',
'alphawithlgt');
218 if (!is_array($receivercc)) {
219 if ($receivercc ==
'-1') {
220 $receivercc = array();
222 $receivercc = array($receivercc);
226 if (trim(
GETPOST(
'sendtocc',
'alphawithlgt'))) {
227 $tmparray[] = trim(
GETPOST(
'sendtocc',
'alphawithlgt'));
229 if (count($receivercc) > 0) {
230 foreach ($receivercc as $key => $val) {
232 if ($val ==
'thirdparty') {
233 $tmparray[] = $thirdparty->name.
' <'.$thirdparty->email.
'>';
235 $tmparray[] = $thirdparty->contact_get_property((
int) $val,
'email');
240 $sendtocc = implode(
',', $tmparray);
243 $listofqualifiedobj = array();
244 $listofqualifiedref = array();
245 $thirdpartywithoutemail = array();
247 foreach ($listofobjectref[$thirdpartyid] as $objectid => $objectobj) {
250 $langs->load(
"errors");
252 $resaction .=
'<div class="error">'.$langs->trans(
'ErrorOnlyProposalNotDraftCanBeSentInMassAction', $objectobj->ref).
'</div><br>';
256 $langs->load(
"errors");
258 $resaction .=
'<div class="error">'.$langs->trans(
'ErrorOnlyOrderNotDraftCanBeSentInMassAction', $objectobj->ref).
'</div><br>';
262 $langs->load(
"errors");
264 $resaction .=
'<div class="error">'.$langs->trans(
'ErrorOnlyInvoiceValidatedCanBeSentInMassAction', $objectobj->ref).
'</div><br>';
269 if (empty($sendto)) {
270 if ($objectobj->element ==
'societe') {
271 $sendto = $objectobj->email;
272 } elseif ($objectobj->element ==
'expensereport') {
273 $fuser =
new User($db);
274 $fuser->fetch($objectobj->fk_user_author);
275 $sendto = $fuser->email;
276 } elseif ($objectobj->element ==
'contact') {
278 $fcontact->fetch($objectobj->id);
279 $sendto = $fcontact->email;
280 } elseif ($objectobj->element ==
'partnership' &&
getDolGlobalString(
'PARTNERSHIP_IS_MANAGED_FOR') ==
'member') {
282 $fadherent->fetch($objectobj->fk_member);
283 $sendto = $fadherent->email;
284 } elseif ($objectobj->element ==
'holiday') {
285 $fuser =
new User($db);
286 $fuser->fetch($objectobj->fk_user);
287 $sendto = $fuser->email;
288 } elseif ($objectobj->element ==
'facture' && !empty($listofobjectcontacts[$objectid])) {
289 $emails_to_sends = array();
290 $objectobj->fetch_thirdparty();
291 $contactidtosend = array();
292 foreach ($listofobjectcontacts[$objectid] as $contactemailid => $contactemailemail) {
293 $emails_to_sends[] = $objectobj->thirdparty->contact_get_property($contactemailid,
'email');
294 if (!in_array($contactemailid, $contactidtosend)) {
295 $contactidtosend[] = $contactemailid;
298 if (count($emails_to_sends) > 0) {
299 $sendto = implode(
',', $emails_to_sends);
301 } elseif ($objectobj->element ==
'order_supplier' && !empty($listofobjectcontacts[$objectid])) {
302 $emails_to_sends = array();
303 $objectobj->fetch_thirdparty();
304 $contactidtosend = array();
305 foreach ($listofobjectcontacts[$objectid] as $contactemailid => $contactemailemail) {
306 $emails_to_sends[] = $objectobj->thirdparty->contact_get_property($contactemailid,
'email');
307 if (!in_array($contactemailid, $contactidtosend)) {
308 $contactidtosend[] = $contactemailid;
311 if (count($emails_to_sends) > 0) {
312 $sendto = implode(
',', $emails_to_sends);
314 } elseif ($objectobj->element ==
'conferenceorboothattendee') {
315 $sendto = $objectobj->email;
317 $objectobj->fetch_thirdparty();
318 $sendto = $objectobj->thirdparty->email;
322 if (empty($sendto)) {
323 if ($objectobj->element ==
'societe') {
324 $objectobj->thirdparty = $objectobj;
329 if (empty($thirdpartywithoutemail[$objectobj->thirdparty->id])) {
330 $resaction .=
'<div class="error">'.$langs->trans(
'NoRecipientEmail', $objectobj->thirdparty->name).
'</div><br>';
332 dol_syslog(
'No recipient for thirdparty: '.$objectobj->thirdparty->name, LOG_WARNING);
333 $thirdpartywithoutemail[$objectobj->thirdparty->id] = 1;
337 if (
GETPOST(
'addmaindocfile')) {
344 $filedir = $uploaddir.
'/'.$subdir.dol_sanitizeFileName($objectobj->ref);
345 $filepath = $filedir.
'/'.$filename;
348 if ($objectobj->element ==
'invoice_supplier') {
349 $fileparams =
dol_most_recent_file($uploaddir.
'/'.
get_exdir($objectobj->id, 2, 0, 0, $objectobj, $objectobj->element).$objectobj->ref, preg_quote($objectobj->ref,
'/').
'([^\-])+');
350 $filepath = $fileparams[
'fullname'];
354 $filename_found =
'';
355 $filepath_found =
'';
356 $file_check_list = array();
357 $file_check_list[] = array(
361 if (
getDolGlobalString(
'MAIL_MASS_ACTION_ADD_LAST_IF_MAIN_DOC_NOT_FOUND') && !empty($objectobj->last_main_doc)) {
362 $file_check_list[] = array(
363 'name' => basename($objectobj->last_main_doc),
364 'path' => DOL_DATA_ROOT .
'/' . $objectobj->last_main_doc,
367 foreach ($file_check_list as $file_check_arr) {
369 $filename_found = $file_check_arr[
'name'];
370 $filepath_found = $file_check_arr[
'path'];
375 if ($filepath_found) {
377 $attachedfilesThirdpartyObj[$thirdpartyid][$objectid] = array(
378 'paths' => array($filepath_found),
379 'names' => array($filename_found),
384 $langs->load(
"errors");
385 foreach ($file_check_list as $file_check_arr) {
386 $resaction .=
'<div class="error">'.$langs->trans(
'ErrorCantReadFile', $file_check_arr[
'path']).
'</div><br>';
387 dol_syslog(
'Failed to read file: '.$file_check_arr[
'path'], LOG_WARNING);
394 $listofqualifiedobj[$objectid] = $objectobj;
395 $listofqualifiedref[$objectid] = $objectobj->ref;
402 if (count($listofqualifiedobj) > 0) {
403 $langs->load(
"commercial");
406 $fromtype =
GETPOST(
'fromtype');
407 if ($fromtype ===
'user') {
408 $from =
dol_string_nospecial($user->getFullName($langs),
' ', array(
",")).
' <'.$user->email.
'>';
409 } elseif ($fromtype ===
'company') {
411 } elseif (preg_match(
'/user_aliases_(\d+)/', $fromtype, $reg)) {
412 $tmp = explode(
',', $user->email_aliases);
413 $from = trim($tmp[((
int) $reg[1] - 1)]);
414 } elseif (preg_match(
'/global_aliases_(\d+)/', $fromtype, $reg)) {
416 $from = trim($tmp[((
int) $reg[1] - 1)]);
417 } elseif (preg_match(
'/senderprofile_(\d+)_(\d+)/', $fromtype, $reg)) {
418 $sql =
"SELECT rowid, label, email FROM ".MAIN_DB_PREFIX.
"c_email_senderprofile WHERE rowid = ".(int) $reg[1];
419 $resql = $db->query($sql);
420 $obj = $db->fetch_object($resql);
429 $subject =
GETPOST(
'subject',
'restricthtml');
430 $message =
GETPOST(
'message',
'restricthtml');
432 $sendtobcc =
GETPOST(
'sendtoccc');
433 if ($objectclass ==
'Propal') {
436 if ($objectclass ==
'Commande') {
439 if ($objectclass ==
'Facture') {
442 if ($objectclass ==
'SupplierProposal') {
443 $sendtobcc .= (!
getDolGlobalString(
'MAIN_MAIL_AUTOCOPY_SUPPLIER_PROPOSAL_TO') ?
'' : (($sendtobcc ?
", " :
"") .
getDolGlobalString(
'MAIN_MAIL_AUTOCOPY_SUPPLIER_PROPOSAL_TO')));
445 if ($objectclass ==
'CommandeFournisseur') {
448 if ($objectclass ==
'FactureFournisseur') {
451 if ($objectclass ==
'Project') {
457 $looparray = array();
458 if (!$oneemailperrecipient) {
459 $looparray = $listofqualifiedobj;
460 foreach ($looparray as $key => $objecttmp) {
461 $looparray[$key]->thirdparty = $thirdparty;
464 $objectforloop =
new $objectclass($db);
465 $objectforloop->thirdparty = $thirdparty;
466 $looparray[0] = $objectforloop;
469 dol_syslog(
"We have set an array of ".count($looparray).
" emails to send. oneemailperrecipient=".$oneemailperrecipient);
471 foreach ($looparray as $objectid => $objecttmp) {
473 if (isModEnabled(
'project') && method_exists($objecttmp,
'fetch_projet') && is_null($objecttmp->project)) {
474 $objecttmp->fetch_projet();
477 $substitutionarray[
'__ID__'] = ($oneemailperrecipient ? implode(
', ', array_keys($listofqualifiedobj)) : $objecttmp->id);
478 $substitutionarray[
'__REF__'] = ($oneemailperrecipient ? implode(
', ', $listofqualifiedref) : $objecttmp->
ref);
479 $substitutionarray[
'__EMAIL__'] = $thirdparty->email;
480 $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"/>';
482 $parameters = array(
'mode' =>
'formemail');
484 if (!empty($listofobjectthirdparties)) {
485 $parameters[
'listofobjectthirdparties'] = $listofobjectthirdparties;
487 if (!empty($listofobjectref)) {
488 $parameters[
'listofobjectref'] = $listofobjectref;
496 $attachedfiles = array(
'paths' => array(),
'names' => array(),
'mimes' => array());
497 if ($oneemailperrecipient) {
499 if (is_array($attachedfilesThirdpartyObj[$thirdparty->id]) && count($attachedfilesThirdpartyObj[$thirdparty->id])) {
500 foreach ($attachedfilesThirdpartyObj[$thirdparty->id] as $keyObjId => $objAttachedFiles) {
502 $attachedfiles = array(
503 'paths' => array_merge($attachedfiles[
'paths'], $objAttachedFiles[
'paths']),
504 'names' => array_merge($attachedfiles[
'names'], $objAttachedFiles[
'names']),
505 'mimes' => array_merge($attachedfiles[
'mimes'], $objAttachedFiles[
'mimes'])
509 } elseif (!empty($attachedfilesThirdpartyObj[$thirdparty->id][$objectid])) {
512 $attachedfiles = $attachedfilesThirdpartyObj[$thirdparty->id][$objectid];
515 $filepath = $attachedfiles[
'paths'];
516 $filename = $attachedfiles[
'names'];
517 $mimetype = $attachedfiles[
'mimes'];
520 if ($oneemailperrecipient) {
521 $trackid =
'thi'.$thirdparty->id;
522 if ($objecttmp->element ==
'expensereport') {
523 $trackid =
'use'.$thirdparty->id;
524 } elseif ($objecttmp->element ==
'contact') {
525 $trackid =
'ctc'.$thirdparty->id;
526 } elseif ($objecttmp->element ==
'holiday') {
527 $trackid =
'use'.$thirdparty->id;
530 $trackid = strtolower(get_class($objecttmp));
531 if (get_class($objecttmp) ==
'Contact') {
533 } elseif (get_class($objecttmp) ==
'Contrat') {
535 } elseif (get_class($objecttmp) ==
'Propal') {
537 } elseif (get_class($objecttmp) ==
'Commande') {
539 } elseif (get_class($objecttmp) ==
'Facture') {
541 } elseif (get_class($objecttmp) ==
'SupplierProposal') {
543 } elseif (get_class($objecttmp) ==
'CommandeFournisseur') {
545 } elseif (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(
'MailSentByTo', $from, $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;
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>';
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');
694if (!$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();
733if (!$error && $massaction ==
"builddoc" && $permissiontoread && !
GETPOST(
'button_search')) {
734 if (empty($diroutputmassaction)) {
735 dol_print_error(
null,
'include of actions_massactions.inc.php is done but var $diroutputmassaction was not defined');
739 require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
740 require_once DOL_DOCUMENT_ROOT.
'/core/lib/pdf.lib.php';
741 require_once DOL_DOCUMENT_ROOT.
'/core/lib/date.lib.php';
743 $objecttmp =
new $objectclass($db);
744 $listofobjectid = array();
745 $listofobjectthirdparties = array();
746 $listofobjectref = array();
747 foreach ($toselect as $toselectid) {
748 $objecttmp =
new $objectclass($db);
749 $result = $objecttmp->fetch($toselectid);
751 $listofobjectid[$toselectid] = $toselectid;
752 $thirdpartyid = !empty($objecttmp->fk_soc) ? $objecttmp->fk_soc : $objecttmp->socid;
753 $listofobjectthirdparties[$thirdpartyid] = $thirdpartyid;
754 $listofobjectref[$toselectid] = $objecttmp->ref;
758 $arrayofinclusion = array();
759 foreach ($listofobjectref as $tmppdf) {
762 foreach ($listofobjectref as $tmppdf) {
763 $arrayofinclusion[] =
'^'.preg_quote(
dol_sanitizeFileName($tmppdf),
'/').
'_[a-zA-Z0-9\-\_\'\&\.]+\.pdf$';
765 $listoffiles =
dol_dir_list($uploaddir,
'all', 1, implode(
'|', $arrayofinclusion),
'\.meta$|\.png',
'date', SORT_DESC, 0, 1);
770 foreach ($listofobjectref as $basename) {
772 foreach ($listoffiles as $filefound) {
773 if (strstr($filefound[
"name"], $basename)) {
774 $files[] = $filefound[
'fullname'];
781 $outputlangs = $langs;
784 $newlang =
GETPOST(
'lang_id',
'aZ09');
789 if (!empty($newlang)) {
791 $outputlangs->setDefaultLang($newlang);
800 $filename = preg_replace(
'/\s/',
'_', $filename);
803 if (in_array($objecttmp->element, array(
'facture',
'invoice_supplier')) && $search_status ==
Facture::STATUS_VALIDATED) {
804 if ($option ==
'late') {
811 $filename .=
'_'.$year;
814 $filename .=
'_'.$month;
817 if (count($files) > 0) {
819 $file = $diroutputmassaction.
'/'.$filename.
'_'.
dol_print_date($now,
'dayhourlog').
'.pdf';
822 foreach ($files as $f) {
823 $input_files .=
' '.escapeshellarg($f);
826 $cmd =
'pdftk '.$input_files.
' cat output '.escapeshellarg($file);
830 if (file_exists($file)) {
833 $langs->load(
"exports");
836 setEventMessages($langs->trans(
'ErrorPDFTkOutputFileNotFound'),
null,
'errors');
839 setEventMessages($langs->trans(
'NoPDFAvailableForDocGenAmongChecked'),
null,
'errors');
844 $page_largeur = $formatarray[
'width'];
845 $page_hauteur = $formatarray[
'height'];
846 $format = array($page_largeur, $page_hauteur);
850 if (class_exists(
'TCPDF')) {
851 $pdf->setPrintHeader(
false);
852 $pdf->setPrintFooter(
false);
857 $pdf->SetCompression(
false);
861 foreach ($files as $file) {
863 $pagecount = $pdf->setSourceFile($file);
864 for ($i = 1; $i <= $pagecount; $i++) {
865 $tplidx = $pdf->importPage($i);
866 $s = $pdf->getTemplatesize($tplidx);
867 $pdf->AddPage($s[
'h'] > $s[
'w'] ?
'P' :
'L');
868 $pdf->useTemplate($tplidx);
877 $filename = preg_replace(
'/\s/',
'_', $filename);
881 if (in_array($objecttmp->element, array(
'facture',
'invoice_supplier')) && $search_status ==
Facture::STATUS_VALIDATED) {
882 if ($option ==
'late') {
889 $filename .=
'_'.$year;
892 $filename .=
'_'.$month;
896 $file = $diroutputmassaction.
'/'.$filename.
'_'.
dol_print_date($now,
'dayhourlog').
'.pdf';
897 $pdf->Output($file,
'F');
900 $langs->load(
"exports");
903 setEventMessages($langs->trans(
'NoPDFAvailableForDocGenAmongChecked'),
null,
'errors');
909if ($action ==
'remove_file') {
910 require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
912 $langs->load(
"other");
913 $upload_dir = $diroutputmassaction;
914 $file = $upload_dir.
'/'.
GETPOST(
'file');
926if (!$error && $massaction ==
'validate' && $permissiontoadd) {
927 $objecttmp =
new $objectclass($db);
929 if (($objecttmp->element ==
'facture' || $objecttmp->element ==
'invoice') && isModEnabled(
'stock') &&
getDolGlobalString(
'STOCK_CALCULATE_ON_BILL')) {
930 $langs->load(
"errors");
931 setEventMessages($langs->trans(
'ErrorMassValidationNotAllowedWhenStockIncreaseOnAction'),
null,
'errors');
934 if ($objecttmp->element ==
'invoice_supplier' && isModEnabled(
'stock') &&
getDolGlobalString(
'STOCK_CALCULATE_ON_SUPPLIER_BILL')) {
935 $langs->load(
"errors");
936 setEventMessages($langs->trans(
'ErrorMassValidationNotAllowedWhenStockIncreaseOnAction'),
null,
'errors');
939 if ($objecttmp->element ==
'facture') {
942 $sql =
"SELECT rowid FROM ".MAIN_DB_PREFIX.
"facture";
943 $sql .=
" WHERE rowid IN (".$db->sanitize(implode(
",", $toselect)).
")";
944 $sql .=
" ORDER BY datef";
946 $resql = $db->query($sql);
949 while (!empty($arr = $db->fetch_row($resql))) {
950 $toselectnew[] = $arr[0];
952 $toselect = (empty($toselectnew)) ? $toselect : $toselectnew;
963 foreach ($toselect as $toselectid) {
964 $result = $objecttmp->fetch($toselectid);
966 if (method_exists($objecttmp,
'validate')) {
967 $result = $objecttmp->validate($user);
968 } elseif (method_exists($objecttmp,
'setValid')) {
969 $result = $objecttmp->setValid($user);
971 $objecttmp->error =
'No method validate or setValid on this object';
975 $langs->load(
"errors");
976 setEventMessages($langs->trans(
"ErrorObjectMustHaveStatusDraftToBeValidated", $objecttmp->ref),
null,
'errors');
979 } elseif ($result < 0) {
987 $outputlangs = $langs;
990 $newlang =
GETPOST(
'lang_id',
'aZ09');
992 if (
getDolGlobalInt(
'MAIN_MULTILANGS') && empty($newlang) && property_exists($objecttmp,
'thirdparty')) {
993 if ((property_exists($objecttmp,
'socid') || property_exists($objecttmp,
'fk_soc')) && empty($objecttmp->thirdparty)) {
994 $objecttmp->fetch_thirdparty();
996 if (!empty($objecttmp->thirdparty)) {
997 $newlang = $objecttmp->thirdparty->default_lang;
1000 if (!empty($newlang)) {
1001 $outputlangs =
new Translate(
"", $conf);
1002 $outputlangs->setDefaultLang($newlang);
1003 $outputlangs->load(
'products');
1005 $model = $objecttmp->model_pdf;
1006 $ret = $objecttmp->fetch($objecttmp->id);
1008 $hidedetails = !empty($hidedetails) ? $hidedetails : (
getDolGlobalString(
'MAIN_GENERATE_DOCUMENTS_HIDE_DETAILS') ? 1 : 0);
1009 $hidedesc = !empty($hidedesc) ? $hidedesc : (
getDolGlobalString(
'MAIN_GENERATE_DOCUMENTS_HIDE_DESC') ? 1 : 0);
1010 $hideref = !empty($hideref) ? $hideref : (
getDolGlobalString(
'MAIN_GENERATE_DOCUMENTS_HIDE_REF') ? 1 : 0);
1011 $moreparams = !empty($moreparams) ? $moreparams :
null;
1013 $result = $objecttmp->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref);
1031 setEventMessages($langs->trans(
"RecordModifiedSuccessfully"),
null,
'mesgs');
1041if (!$error && ($massaction ==
'delete' || ($action ==
'delete' && $confirm ==
'yes')) && $permissiontodelete) {
1044 $objecttmp =
new $objectclass($db);
1050 $unique_arr = array_unique($toselect);
1051 foreach ($unique_arr as $toselectid) {
1052 $result = $objecttmp->fetch($toselectid);
1056 $langs->load(
"errors");
1058 $TMsg[] =
'<div class="error">'.$langs->trans(
'ErrorOnlyDraftStatusCanBeDeletedInMassAction', $objecttmp->ref).
'</div><br>';
1062 if (method_exists($objecttmp,
'is_erasable') && $objecttmp->is_erasable() <= 0) {
1063 $langs->load(
"errors");
1065 $TMsg[] =
'<div class="error">'.$langs->trans(
'ErrorRecordHasChildren').
' '.$objecttmp->ref.
'</div><br>';
1070 $langs->load(
"errors");
1072 $TMsg[] =
'<div class="error">'.$langs->trans(
'ErrorLeaveRequestMustBeDraftCanceledOrRefusedToBeDeleted', $objecttmp->ref).
'</div><br>';
1076 if ($objectclass ==
"Task" && $objecttmp->hasChildren() > 0) {
1077 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"projet_task SET fk_task_parent = 0 WHERE fk_task_parent = ".((int) $objecttmp->id);
1078 $res = $db->query($sql);
1086 if ($objecttmp->element ==
'societe') {
1088 '@phan-var-force Societe $objecttmp';
1090 $result = $objecttmp->delete($objecttmp->id, $user, 1);
1092 $result = $objecttmp->delete($user);
1095 if (empty($result)) {
1096 $TMsg = array_merge($objecttmp->errors, $TMsg);
1097 } elseif ($result < 0) {
1111 if (empty($error)) {
1115 } elseif ($nbok > 0) {
1122 if (!empty($TMsg)) {
1137if (!$error && $massaction ==
'generate_doc' && $permissiontoread) {
1140 foreach ($toselect as $toselectid) {
1141 $objecttmp =
new $objectclass($db);
1142 $result = $objecttmp->fetch($toselectid);
1144 $outputlangs = $langs;
1148 $newlang =
GETPOST(
'lang_id',
'aZ09');
1150 if (
getDolGlobalInt(
'MAIN_MULTILANGS') && empty($newlang) && isset($objecttmp->thirdparty->default_lang)) {
1151 $newlang = $objecttmp->thirdparty->default_lang;
1153 if (
getDolGlobalInt(
'MAIN_MULTILANGS') && empty($newlang) && isset($objecttmp->default_lang)) {
1154 $newlang = $objecttmp->default_lang;
1156 if (
getDolGlobalInt(
'MAIN_MULTILANGS') && empty($newlang) && empty($objecttmp->thirdparty)) {
1157 $objecttmp->fetch_thirdparty();
1158 $newlang = $objecttmp->thirdparty->default_lang;
1160 if (!empty($newlang)) {
1161 $outputlangs =
new Translate(
"", $conf);
1162 $outputlangs->setDefaultLang($newlang);
1166 if (empty($hidedetails)) {
1169 if (empty($hidedesc)) {
1172 if (empty($hideref)) {
1175 if (empty($moreparams)) {
1179 $result = $objecttmp->generateDocument($objecttmp->model_pdf, $outputlangs, $hidedetails, $hidedesc, $hideref, $moreparams);
1209if (!$error && ($action ==
'affecttag' && $confirm ==
'yes') && $permissiontoadd) {
1213 $affecttag_type =
GETPOST(
'affecttag_type',
'alpha');
1214 if (!empty($affecttag_type)) {
1215 $affecttag_type_array = explode(
',', $affecttag_type);
1219 if (!empty($affecttag_type_array)) {
1221 require_once DOL_DOCUMENT_ROOT.
'/categories/class/categorie.class.php';
1223 $to_affecttag_type_array = array();
1224 $categ_type_array = $categ->getMapList();
1225 foreach ($categ_type_array as $categdef) {
1226 if (in_array($categdef[
'code'], $affecttag_type_array)) {
1227 $to_affecttag_type_array[] = $categdef[
'code'];
1232 if (!empty($to_affecttag_type_array)) {
1233 foreach ($to_affecttag_type_array as $categ_type) {
1234 $contcats =
GETPOST(
'contcats_' . $categ_type,
'array');
1236 foreach ($toselect as $toselectid) {
1237 $result =
$object->fetch($toselectid);
1240 $result =
$object->setCategoriesCommon($contcats, $categ_type,
false);
1259 $toselect = array();
1265if (!$error && ($action ==
'updateprice' && $confirm ==
'yes') && $permissiontoadd) {
1268 if (GETPOSTISSET(
'pricerate')) {
1270 if ($pricepercentage == 0) {
1273 foreach ($toselect as $toselectid) {
1274 $result =
$object->fetch($toselectid);
1277 if ($obj->price_base_type ==
'TTC') {
1278 $newprice =
$object->price_ttc * (100 + $pricepercentage) / 100;
1279 $minprice =
$object->price_min_ttc;
1281 $newprice =
$object->price * (100 + $pricepercentage) / 100;
1282 $minprice =
$object->price_min;
1284 $res =
$object->updatePrice($newprice, $obj->price_base_type, $user,
$object->tva_tx, $minprice, 0,
$object->tva_npr, 0, 0, array(),
$object->default_vat_code);
1304 $toselect = array();
1310if (!$error && ($action ==
'setsupervisor' && $confirm ==
'yes') && $permissiontoadd) {
1313 $supervisortoset =
GETPOST(
'supervisortoset');
1314 if (!empty($supervisortoset)) {
1315 foreach ($toselect as $toselectid) {
1316 $result =
$object->fetch($toselectid);
1319 $object->fk_user = $supervisortoset;
1320 $res =
$object->update($user);
1340 $toselect = array();
1346if (!$error && ($action ==
'affectuser' && $confirm ==
'yes') && $permissiontoadd) {
1350 $usertoaffect =
GETPOST(
'usertoaffect');
1351 $projectrole =
GETPOST(
'projectrole');
1352 $tasksrole =
GETPOST(
'tasksrole');
1353 if (!empty($usertoaffect)) {
1354 foreach ($toselect as $toselectid) {
1355 $result =
$object->fetch($toselectid);
1358 $res =
$object->add_contact($usertoaffect, $projectrole,
'internal');
1360 $taskstatic =
new Task($db);
1361 $task_array = $taskstatic->getTasksArray(0, 0,
$object->id, 0, 0);
1363 foreach ($task_array as $task) {
1364 $tasksToAffect =
new Task($db);
1365 $result = $tasksToAffect->fetch($task->id);
1367 $res = $tasksToAffect->add_contact($usertoaffect, $tasksrole,
'internal');
1391 $toselect = array();
1397if (!$error && ($massaction ==
'enable' || ($action ==
'enable' && $confirm ==
'yes')) && $permissiontoadd) {
1400 $objecttmp =
new $objectclass($db);
1402 foreach ($toselect as $toselectid) {
1403 $result = $objecttmp->fetch($toselectid);
1405 if (in_array($objecttmp->element, array(
'societe'))) {
1406 $result = $objecttmp->setStatut(1);
1434if (!$error && ($massaction ==
'disable' || ($action ==
'disable' && $confirm ==
'yes')) && $permissiontoadd) {
1437 $objecttmp =
new $objectclass($db);
1439 foreach ($toselect as $toselectid) {
1440 $result = $objecttmp->fetch($toselectid);
1442 if (in_array($objecttmp->element, array(
'societe'))) {
1443 $result = $objecttmp->setStatut(0);
1471if (!$error && $action ==
'confirm_edit_value_extrafields' && $confirm ==
'yes' && $permissiontoadd) {
1474 $objecttmp =
new $objectclass($db);
1476 $e->fetch_name_optionals_label($objecttmp->table_element);
1479 $extrafieldKeyToUpdate =
GETPOST(
'extrafield-key-to-update');
1482 foreach ($toselect as $toselectid) {
1484 $objecttmp =
new $objectclass($db);
1485 $result = $objecttmp->fetch($toselectid);
1488 $ret = $e->setOptionalsFromPost(
null, $objecttmp, $extrafieldKeyToUpdate);
1490 $objecttmp->insertExtraFields();
1514if (!$error && ($massaction ==
'affectcommercial' || ($action ==
'affectcommercial' && $confirm ==
'yes')) && $permissiontoadd) {
1517 $objecttmp =
new $objectclass($db);
1520 foreach ($toselect as $toselectid) {
1521 $result = $objecttmp->fetch($toselectid);
1523 if (in_array($objecttmp->element, array(
'societe'))) {
1524 $result = $objecttmp->setSalesRep(
GETPOST(
"commercial",
"alpha"));
1542 setEventMessages($langs->trans(
"CommercialsAffected", $nbok),
null,
'mesgs');
1552if (!$error && ($massaction ==
'unassigncommercial' || ($action ==
'unassigncommercial' && $confirm ==
'yes')) && $permissiontoadd) {
1555 $objecttmp =
new $objectclass($db);
1558 foreach ($toselect as $toselectid) {
1559 $result = $objecttmp->fetch($toselectid);
1561 if (in_array($objecttmp->element, array(
'societe'))) {
1562 $TCommercial =
GETPOST(
"commercial",
"alpha");
1563 if (is_array($TCommercial)) {
1564 foreach ($TCommercial as $commercial) {
1565 $result = $objecttmp->del_commercial($user, $commercial);
1585 setEventMessages($langs->trans(
"CommercialsDisaffected", $nbok),
null,
'mesgs');
1595if (!$error && ($massaction ==
'approveleave' || ($action ==
'approveleave' && $confirm ==
'yes')) && $permissiontoapprove) {
1598 $objecttmp =
new $objectclass($db);
1600 foreach ($toselect as $toselectid) {
1601 $result = $objecttmp->fetch($toselectid);
1604 setEventMessages($langs->trans(
'StatusOfRefMustBe', $objecttmp->ref, $langs->transnoentitiesnoconv(
'Validated')),
null,
'warnings');
1607 if ($user->id == $objecttmp->fk_validator) {
1608 $objecttmp->oldcopy =
dol_clone($objecttmp, 2);
1610 $objecttmp->date_valid =
dol_now();
1611 $objecttmp->fk_user_valid = $user->id;
1613 $objecttmp->statut = $objecttmp->status;
1615 $verif = $objecttmp->approve($user);
1625 $nbopenedday =
num_open_day($objecttmp->date_debut_gmt, $objecttmp->date_fin_gmt, 0, 1, $objecttmp->halfday);
1626 $soldeActuel = $objecttmp->getCpforUser($objecttmp->fk_user, $objecttmp->fk_type);
1627 $newSolde = ($soldeActuel - $nbopenedday);
1630 $result = $objecttmp->addLogCP($user->id, $objecttmp->fk_user, $langs->transnoentitiesnoconv(
"Holidays"), $newSolde, $objecttmp->fk_type);
1637 $result = $objecttmp->updateSoldeCP($objecttmp->fk_user, $newSolde, $objecttmp->fk_type);
1646 $destinataire =
new User($db);
1647 $destinataire->fetch($objecttmp->fk_user);
1648 $emailTo = $destinataire->email;
1651 dol_syslog(
"User that request leave has no email, so we redirect directly to finished page without sending email");
1654 $expediteur =
new User($db);
1655 $expediteur->fetch($objecttmp->fk_validator);
1665 $subject = $societeName.
" - ".$langs->transnoentitiesnoconv(
"HolidaysValidated");
1668 $message = $langs->transnoentitiesnoconv(
"Hello").
" ".$destinataire->firstname.
",\n";
1671 $message .= $langs->transnoentities(
"HolidaysValidatedBody",
dol_print_date($objecttmp->date_debut,
'day'),
dol_print_date($objecttmp->date_fin,
'day')).
"\n";
1673 $message .=
"- ".$langs->transnoentitiesnoconv(
"ValidatedBy").
" : ".
dolGetFirstLastname($expediteur->firstname, $expediteur->lastname).
"\n";
1675 $message .=
"- ".$langs->transnoentitiesnoconv(
"Link").
" : ".$dolibarr_main_url_root.
"/holiday/card.php?id=".$objecttmp->id.
"\n\n";
1678 $trackid =
'leav'.$objecttmp->id;
1680 require_once DOL_DOCUMENT_ROOT.
'/core/class/CMailFile.class.php';
1681 $mail =
new CMailFile($subject, $emailTo, $emailFrom, $message, array(), array(), array(),
'',
'', 0, 0,
'',
'', $trackid);
1684 $result = $mail->sendfile();
1693 $langs->load(
"errors");
1694 setEventMessages($langs->trans(
'ErrorNotApproverForHoliday', $objecttmp->ref),
null,
'errors');
1706 } elseif ($nbok == 1) {
1715if (!$error && ($massaction ==
'increaseholiday' || ($action ==
'increaseholiday' && $confirm ==
'yes')) && $permissiontoapprove) {
1717 $objecttmp =
new $objectclass($db);
1719 $typeholiday =
GETPOST(
'typeholiday',
'alpha');
1722 if ($nbdaysholidays <= 0) {
1728 foreach ($toselect as $toselectid) {
1729 $balancecpuser = $objecttmp->getCPforUser($toselectid, $typeholiday);
1730 if (!empty($balancecpuser)) {
1731 $newnbdaysholidays = $nbdaysholidays + $balancecpuser;
1733 $newnbdaysholidays = $nbdaysholidays;
1735 $result = $holiday->addLogCP($user->id, $toselectid, $langs->transnoentitiesnoconv(
'ManualUpdate'), $newnbdaysholidays, $typeholiday);
1742 $objecttmp->updateSoldeCP($toselectid, $newnbdaysholidays, $typeholiday);
1755 setEventMessages($langs->trans(
"HolidayRecordsIncreased", $nbok),
null,
'mesgs');
1756 } elseif ($nbok == 1) {
1760 $toselect = array();
1767if (!$error && ($massaction ==
'clonetasks' || ($action ==
'clonetasks' && $confirm ==
'yes'))) {
1772 $origin_task =
new Task($db);
1773 $clone_task =
new Task($db);
1775 foreach (
GETPOST(
'selected') as $task) {
1776 $origin_task->fetch($task, $ref =
'', $loadparentdata = 0);
1779 $obj = !
getDolGlobalString(
'PROJECT_TASK_ADDON') ?
'mod_task_simple' : $conf->global->PROJECT_TASK_ADDON;
1781 require_once DOL_DOCUMENT_ROOT .
"/core/modules/project/task/" .
getDolGlobalString(
'PROJECT_TASK_ADDON') .
'.php';
1782 $modTask =
new $obj();
1783 '@phan-var-force ModeleNumRefTask $modTask';
1784 $defaultref = $modTask->getNextValue(
null, $clone_task);
1788 $clone_task->fk_project =
GETPOSTINT(
'projectid');
1789 $clone_task->ref = $defaultref;
1790 $clone_task->label = $origin_task->label;
1791 $clone_task->description = $origin_task->description;
1792 $clone_task->planned_workload = $origin_task->planned_workload;
1793 $clone_task->fk_task_parent = $origin_task->fk_task_parent;
1794 $clone_task->date_c =
dol_now();
1795 $clone_task->date_start = $origin_task->date_start;
1796 $clone_task->date_end = $origin_task->date_end;
1797 $clone_task->progress = $origin_task->progress;
1800 $ret = $extrafields->setOptionalsFromPost(
null, $clone_task);
1802 $taskid = $clone_task->create($user);
1805 $result = $clone_task->add_contact(
GETPOSTINT(
"userid"),
'TASKEXECUTIVE',
'internal');
1808 if ($db->lasterrno() ==
'DB_ERROR_RECORD_ALREADY_EXISTS') {
1809 $langs->load(
"projects");
1811 $duplicate_code_error =
true;
1823 header(
"Refresh: 1;URL=".DOL_URL_ROOT.
'/projet/tasks.php?id=' .
GETPOSTINT(
'projectid'));
1827$parameters[
'toselect'] = (empty($toselect) ? array() : $toselect);
1828$parameters[
'uploaddir'] = $uploaddir;
1829$parameters[
'massaction'] = $massaction;
1830$parameters[
'diroutputmassaction'] = isset($diroutputmassaction) ? $diroutputmassaction :
null;
1832$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 a 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.