42if (empty($objectclass) || empty($uploaddir)) {
43 dol_print_error(
null,
'include of actions_massactions.inc.php is done but var $objectclass or $uploaddir was not defined');
46if (empty($massaction)) {
52if (!empty($permtoread) && empty($permissiontoread)) {
53 $permissiontoread = $permtoread;
55if (!empty($permtocreate) && empty($permissiontoadd)) {
56 $permissiontoadd = $permtocreate;
58if (!empty($permtodelete) && empty($permissiontodelete)) {
59 $permissiontodelete = $permtodelete;
63$maxformassaction = (!
getDolGlobalString(
'MAIN_LIMIT_FOR_MASS_ACTIONS') ? 1000 : $conf->global->MAIN_LIMIT_FOR_MASS_ACTIONS);
64if ($massaction && is_array($toselect) && count($toselect) < 1) {
68if (!$error && isset($toselect) && is_array($toselect) && count($toselect) > $maxformassaction) {
69 setEventMessages($langs->trans(
'TooManyRecordForMassAction', $maxformassaction),
null,
'errors');
73if (!$error && $massaction ==
'confirm_presend' && !
GETPOST(
'sendmail')) {
74 $massaction =
'presend';
77if (!$error && $massaction ==
'confirm_presend') {
81 $langs->load(
"mails");
82 include_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
83 include_once DOL_DOCUMENT_ROOT.
'/core/lib/signature.lib.php';
85 $listofobjectid = array();
86 $listofobjectthirdparties = array();
87 $listofobjectcontacts = array();
88 $listofobjectref = array();
89 $contactidtosend = array();
90 $attachedfilesThirdpartyObj = array();
91 $oneemailperrecipient = (
GETPOSTINT(
'oneemailperrecipient') ? 1 : 0);
94 $objecttmp =
new $objectclass($db);
98 if ($objecttmp->element ==
'expensereport') {
99 $thirdparty =
new User($db);
100 } elseif ($objecttmp->element ==
'contact') {
101 $thirdparty =
new Contact($db);
102 } elseif ($objecttmp->element ==
'partnership' &&
getDolGlobalString(
'PARTNERSHIP_IS_MANAGED_FOR') ==
'member') {
104 } elseif ($objecttmp->element ==
'holiday') {
105 $thirdparty =
new User($db);
106 } elseif ($objecttmp->element ==
'conferenceorboothattendee') {
110 foreach ($toselect as $toselectid) {
111 $objecttmp =
new $objectclass($db);
112 $result = $objecttmp->fetch($toselectid);
114 $listofobjectid[$toselectid] = $toselectid;
115 $tmpobjectid = ($objecttmp->fk_soc ? $objecttmp->fk_soc : $objecttmp->socid);
116 if ($objecttmp->element ==
'societe') {
117 $tmpobjectid = $objecttmp->id;
118 } elseif ($objecttmp->element ==
'contact') {
119 $tmpobjectid = $objecttmp->id;
120 } elseif ($objecttmp->element ==
'expensereport') {
121 $tmpobjectid = $objecttmp->fk_user_author;
122 } elseif ($objecttmp->element ==
'partnership' &&
getDolGlobalString(
'PARTNERSHIP_IS_MANAGED_FOR') ==
'member') {
123 $tmpobjectid = $objecttmp->fk_member;
124 } elseif ($objecttmp->element ==
'holiday') {
125 $tmpobjectid = $objecttmp->fk_user;
126 } elseif ($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(
GETPOST(
'sendto',
'alphawithlgt')) && 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(
GETPOST(
'sendto',
'alphawithlgt'))) {
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(
GETPOST(
'sendtocc',
'alphawithlgt'))) {
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 ==
'contact') {
279 $fcontact->fetch($objectobj->id);
280 $sendto = $fcontact->email;
281 } elseif ($objectobj->element ==
'partnership' &&
getDolGlobalString(
'PARTNERSHIP_IS_MANAGED_FOR') ==
'member') {
283 $fadherent->fetch($objectobj->fk_member);
284 $sendto = $fadherent->email;
285 } elseif ($objectobj->element ==
'holiday') {
286 $fuser =
new User($db);
287 $fuser->fetch($objectobj->fk_user);
288 $sendto = $fuser->email;
289 } elseif ($objectobj->element ==
'facture' && !empty($listofobjectcontacts[$objectid])) {
290 $emails_to_sends = array();
291 $objectobj->fetch_thirdparty();
292 $contactidtosend = array();
293 foreach ($listofobjectcontacts[$objectid] as $contactemailid => $contactemailemail) {
294 $emails_to_sends[] = $objectobj->thirdparty->contact_get_property($contactemailid,
'email');
295 if (!in_array($contactemailid, $contactidtosend)) {
296 $contactidtosend[] = $contactemailid;
299 if (count($emails_to_sends) > 0) {
300 $sendto = implode(
',', $emails_to_sends);
302 } elseif ($objectobj->element ==
'order_supplier' && !empty($listofobjectcontacts[$objectid])) {
303 $emails_to_sends = array();
304 $objectobj->fetch_thirdparty();
305 $contactidtosend = array();
306 foreach ($listofobjectcontacts[$objectid] as $contactemailid => $contactemailemail) {
307 $emails_to_sends[] = $objectobj->thirdparty->contact_get_property($contactemailid,
'email');
308 if (!in_array($contactemailid, $contactidtosend)) {
309 $contactidtosend[] = $contactemailid;
312 if (count($emails_to_sends) > 0) {
313 $sendto = implode(
',', $emails_to_sends);
315 } elseif ($objectobj->element ==
'conferenceorboothattendee') {
316 $sendto = $objectobj->email;
318 $objectobj->fetch_thirdparty();
319 $sendto = $objectobj->thirdparty->email;
323 if (empty($sendto)) {
324 if ($objectobj->element ==
'societe') {
325 $objectobj->thirdparty = $objectobj;
330 if (empty($thirdpartywithoutemail[$objectobj->thirdparty->id])) {
331 $resaction .=
'<div class="error">'.$langs->trans(
'NoRecipientEmail', $objectobj->thirdparty->name).
'</div><br>';
333 dol_syslog(
'No recipient for thirdparty: '.$objectobj->thirdparty->name, LOG_WARNING);
334 $thirdpartywithoutemail[$objectobj->thirdparty->id] = 1;
338 if (
GETPOST(
'addmaindocfile')) {
345 $filedir = $uploaddir.
'/'.$subdir.dol_sanitizeFileName($objectobj->ref);
346 $filepath = $filedir.
'/'.$filename;
349 if ($objectobj->element ==
'invoice_supplier') {
350 $fileparams =
dol_most_recent_file($uploaddir.
'/'.
get_exdir($objectobj->id, 2, 0, 0, $objectobj, $objectobj->element).$objectobj->ref, preg_quote($objectobj->ref,
'/').
'([^\-])+');
351 $filepath = $fileparams[
'fullname'];
355 $filename_found =
'';
356 $filepath_found =
'';
357 $file_check_list = array();
358 $file_check_list[] = array(
362 if (
getDolGlobalString(
'MAIL_MASS_ACTION_ADD_LAST_IF_MAIN_DOC_NOT_FOUND') && !empty($objectobj->last_main_doc)) {
363 $file_check_list[] = array(
364 'name' => basename($objectobj->last_main_doc),
365 'path' => DOL_DATA_ROOT .
'/' . $objectobj->last_main_doc,
368 foreach ($file_check_list as $file_check_arr) {
370 $filename_found = $file_check_arr[
'name'];
371 $filepath_found = $file_check_arr[
'path'];
376 if ($filepath_found) {
378 $attachedfilesThirdpartyObj[$thirdpartyid][$objectid] = array(
379 'paths' => array($filepath_found),
380 'names' => array($filename_found),
385 $langs->load(
"errors");
386 foreach ($file_check_list as $file_check_arr) {
387 $resaction .=
'<div class="error">'.$langs->trans(
'ErrorCantReadFile', $file_check_arr[
'path']).
'</div><br>';
388 dol_syslog(
'Failed to read file: '.$file_check_arr[
'path'], LOG_WARNING);
395 $listofqualifiedobj[$objectid] = $objectobj;
396 $listofqualifiedref[$objectid] = $objectobj->ref;
403 if (count($listofqualifiedobj) > 0) {
404 $langs->load(
"commercial");
407 $fromtype =
GETPOST(
'fromtype');
408 if ($fromtype ===
'user') {
409 $from =
dol_string_nospecial($user->getFullName($langs),
' ', array(
",")).
' <'.$user->email.
'>';
410 } elseif ($fromtype ===
'company') {
412 } elseif (preg_match(
'/user_aliases_(\d+)/', $fromtype, $reg)) {
413 $tmp = explode(
',', $user->email_aliases);
414 $from = trim($tmp[($reg[1] - 1)]);
415 } elseif (preg_match(
'/global_aliases_(\d+)/', $fromtype, $reg)) {
417 $from = trim($tmp[($reg[1] - 1)]);
418 } elseif (preg_match(
'/senderprofile_(\d+)_(\d+)/', $fromtype, $reg)) {
419 $sql =
"SELECT rowid, label, email FROM ".MAIN_DB_PREFIX.
"c_email_senderprofile WHERE rowid = ".(int) $reg[1];
420 $resql = $db->query($sql);
421 $obj = $db->fetch_object($resql);
430 $subject =
GETPOST(
'subject',
'restricthtml');
431 $message =
GETPOST(
'message',
'restricthtml');
433 $sendtobcc =
GETPOST(
'sendtoccc');
434 if ($objectclass ==
'Propal') {
437 if ($objectclass ==
'Commande') {
440 if ($objectclass ==
'Facture') {
443 if ($objectclass ==
'SupplierProposal') {
444 $sendtobcc .= (!
getDolGlobalString(
'MAIN_MAIL_AUTOCOPY_SUPPLIER_PROPOSAL_TO') ?
'' : (($sendtobcc ?
", " :
"") .
getDolGlobalString(
'MAIN_MAIL_AUTOCOPY_SUPPLIER_PROPOSAL_TO')));
446 if ($objectclass ==
'CommandeFournisseur') {
449 if ($objectclass ==
'FactureFournisseur') {
452 if ($objectclass ==
'Project') {
458 $looparray = array();
459 if (!$oneemailperrecipient) {
460 $looparray = $listofqualifiedobj;
461 foreach ($looparray as $key => $objecttmp) {
462 $looparray[$key]->thirdparty = $thirdparty;
465 $objectforloop =
new $objectclass($db);
466 $objectforloop->thirdparty = $thirdparty;
467 $looparray[0] = $objectforloop;
470 dol_syslog(
"We have set an array of ".count($looparray).
" emails to send. oneemailperrecipient=".$oneemailperrecipient);
472 foreach ($looparray as $objectid => $objecttmp) {
474 if (isModEnabled(
'project') && method_exists($objecttmp,
'fetch_projet') && is_null($objecttmp->project)) {
475 $objecttmp->fetch_projet();
478 $substitutionarray[
'__ID__'] = ($oneemailperrecipient ? implode(
', ', array_keys($listofqualifiedobj)) : $objecttmp->id);
479 $substitutionarray[
'__REF__'] = ($oneemailperrecipient ? implode(
', ', $listofqualifiedref) : $objecttmp->
ref);
480 $substitutionarray[
'__EMAIL__'] = $thirdparty->email;
481 $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"/>';
483 if ($oneemailperrecipient) {
484 $substitutionarray[
'__ONLINE_PAYMENT_URL__'] =
'';
485 $substitutionarray[
'__ONLINE_PAYMENT_TEXT_AND_URL__'] =
'';
488 $parameters = array(
'mode' =>
'formemail');
490 if (!empty($listofobjectthirdparties)) {
491 $parameters[
'listofobjectthirdparties'] = $listofobjectthirdparties;
493 if (!empty($listofobjectref)) {
494 $parameters[
'listofobjectref'] = $listofobjectref;
502 $attachedfiles = array(
'paths' => array(),
'names' => array(),
'mimes' => array());
503 if ($oneemailperrecipient) {
505 if (is_array($attachedfilesThirdpartyObj[$thirdparty->id]) && count($attachedfilesThirdpartyObj[$thirdparty->id])) {
506 foreach ($attachedfilesThirdpartyObj[$thirdparty->id] as $keyObjId => $objAttachedFiles) {
508 $attachedfiles = array(
509 'paths' => array_merge($attachedfiles[
'paths'], $objAttachedFiles[
'paths']),
510 'names' => array_merge($attachedfiles[
'names'], $objAttachedFiles[
'names']),
511 'mimes' => array_merge($attachedfiles[
'mimes'], $objAttachedFiles[
'mimes'])
515 } elseif (!empty($attachedfilesThirdpartyObj[$thirdparty->id][$objectid])) {
518 $attachedfiles = $attachedfilesThirdpartyObj[$thirdparty->id][$objectid];
521 $filepath = $attachedfiles[
'paths'];
522 $filename = $attachedfiles[
'names'];
523 $mimetype = $attachedfiles[
'mimes'];
526 if ($oneemailperrecipient) {
527 $trackid =
'thi'.$thirdparty->id;
528 if ($objecttmp->element ==
'expensereport') {
529 $trackid =
'use'.$thirdparty->id;
530 } elseif ($objecttmp->element ==
'contact') {
531 $trackid =
'ctc'.$thirdparty->id;
532 } elseif ($objecttmp->element ==
'holiday') {
533 $trackid =
'use'.$thirdparty->id;
536 $trackid = strtolower(get_class($objecttmp));
537 if (get_class($objecttmp) ==
'Contact') {
539 } elseif (get_class($objecttmp) ==
'Contrat') {
541 } elseif (get_class($objecttmp) ==
'Propal') {
543 } elseif (get_class($objecttmp) ==
'Commande') {
545 } elseif (get_class($objecttmp) ==
'Facture') {
547 } elseif (get_class($objecttmp) ==
'SupplierProposal') {
549 } elseif (get_class($objecttmp) ==
'CommandeFournisseur') {
551 } elseif (get_class($objecttmp) ==
'FactureFournisseur') {
555 $trackid .= $objecttmp->id;
561 if (empty($sendcontext)) {
562 $sendcontext =
'standard';
566 $vardir = $conf->user->dir_output.
"/".$user->id;
567 $upload_dir_tmp = $vardir.
'/temp';
570 require_once DOL_DOCUMENT_ROOT.
'/core/class/CMailFile.class.php';
571 $mailfile =
new CMailFile($subjectreplaced, $sendto, $from, $messagereplaced, $filepath, $mimetype, $filename, $sendtocc, $sendtobcc, $deliveryreceipt, -1,
'',
'', $trackid,
'', $sendcontext,
'', $upload_dir_tmp);
572 if ($mailfile->error) {
573 $resaction .=
'<div class="error">'.$mailfile->error.
'</div>';
575 $result = $mailfile->sendfile();
577 $resaction .= $langs->trans(
'MailSuccessfulySent', $mailfile->getValidAddress($mailfile->addr_from, 2), $mailfile->getValidAddress($mailfile->addr_to, 2)).
'<br>';
582 foreach ($listofqualifiedobj as $objid2 => $objectobj2) {
583 if ((!$oneemailperrecipient) && $objid2 != $objectid) {
587 dol_syslog(
"Try to insert email event into agenda for objid=".$objid2.
" => objectobj=".get_class($objectobj2));
596 $actionmsg = $langs->transnoentities(
'MailSentByTo', $from, $sendto);
599 $actionmsg =
dol_concatdesc($actionmsg, $langs->transnoentities(
'Bcc').
": ".$sendtocc);
601 $actionmsg =
dol_concatdesc($actionmsg, $langs->transnoentities(
'MailTopic').
": ".$subjectreplaced);
602 $actionmsg =
dol_concatdesc($actionmsg, $langs->transnoentities(
'TextUsedInTheMessageBody').
":");
608 $objectobj2->sendtoid = (empty($contactidtosend) ? 0 : $contactidtosend);
609 $objectobj2->actionmsg = $actionmsg;
610 $objectobj2->actionmsg2 = $actionmsg2;
611 $objectobj2->fk_element = $objid2;
612 $objectobj2->elementtype = $objectobj2->element;
614 $objectobj2->actionmsg2 = $subjectreplaced;
617 $triggername = strtoupper(get_class($objectobj2)).
'_SENTBYMAIL';
618 if ($triggername ==
'SOCIETE_SENTBYMAIL') {
619 $triggername =
'COMPANY_SENTBYMAIL';
621 if ($triggername ==
'CONTRAT_SENTBYMAIL') {
622 $triggername =
'CONTRACT_SENTBYMAIL';
624 if ($triggername ==
'COMMANDE_SENTBYMAIL') {
625 $triggername =
'ORDER_SENTBYMAIL';
627 if ($triggername ==
'FACTURE_SENTBYMAIL') {
628 $triggername =
'BILL_SENTBYMAIL';
630 if ($triggername ==
'EXPEDITION_SENTBYMAIL') {
631 $triggername =
'SHIPPING_SENTBYMAIL';
633 if ($triggername ==
'COMMANDEFOURNISSEUR_SENTBYMAIL') {
634 $triggername =
'ORDER_SUPPLIER_SENTBYMAIL';
636 if ($triggername ==
'FACTUREFOURNISSEUR_SENTBYMAIL') {
637 $triggername =
'BILL_SUPPLIER_SENTBYMAIL';
639 if ($triggername ==
'SUPPLIERPROPOSAL_SENTBYMAIL') {
640 $triggername =
'PROPOSAL_SUPPLIER_SENTBYMAIL';
642 if ($triggername ==
'PROJET_SENTBYMAIL') {
643 $triggername =
'PROJECT_SENTBYMAIL';
646 if (!empty($triggername)) {
648 $result = $objectobj2->call_trigger($triggername, $user);
656 dol_syslog(
"Error in trigger ".$triggername.
' '.$db->lasterror(), LOG_ERR);
663 $langs->load(
"other");
664 if ($mailfile->error) {
665 $resaction .= $langs->trans(
'ErrorFailedToSendMail', $from, $sendto);
666 $resaction .=
'<br><div class="error">'.$mailfile->error.
'</div>';
668 $resaction .=
'<div class="warning">No mail sent. Feature is disabled by option MAIN_DISABLE_ALL_MAILS</div>';
670 $resaction .= $langs->trans(
'ErrorFailedToSendMail', $from, $sendto) .
'<br><div class="error">(unhandled error)</div>';
678 $resaction .= ($resaction ?
'<br>' : $resaction);
679 $resaction .=
'<strong>'.$langs->trans(
"ResultOfMailSending").
':</strong><br>'.
"\n";
680 $resaction .= $langs->trans(
"NbSelected").
': '.count($toselect).
"\n<br>";
681 $resaction .= $langs->trans(
"NbIgnored").
': '.($nbignored ? $nbignored : 0).
"\n<br>";
682 $resaction .= $langs->trans(
"NbSent").
': '.($nbsent ? $nbsent : 0).
"\n<br>";
687 setEventMessages($langs->trans(
"EMailSentForNElements", $nbsent.
'/'.count($toselect)),
null,
'mesgs');
700if (!$error && $massaction ==
'cancelorders') {
705 $orders =
GETPOST(
'toselect',
'array');
706 foreach ($orders as $id_order) {
708 if ($cmd->fetch($id_order) <= 0) {
713 $langs->load(
'errors');
714 setEventMessages($langs->trans(
"ErrorObjectMustHaveStatusValidToBeCanceled", $cmd->ref),
null,
'errors');
719 $result = $cmd->cancel();
739if (!$error && $massaction ==
"builddoc" && $permissiontoread && !
GETPOST(
'button_search')) {
740 if (empty($diroutputmassaction)) {
741 dol_print_error(
null,
'include of actions_massactions.inc.php is done but var $diroutputmassaction was not defined');
745 require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
746 require_once DOL_DOCUMENT_ROOT.
'/core/lib/pdf.lib.php';
747 require_once DOL_DOCUMENT_ROOT.
'/core/lib/date.lib.php';
749 $objecttmp =
new $objectclass($db);
750 $listofobjectid = array();
751 $listofobjectthirdparties = array();
752 $listofobjectref = array();
753 foreach ($toselect as $toselectid) {
754 $objecttmp =
new $objectclass($db);
755 $result = $objecttmp->fetch($toselectid);
757 $listofobjectid[$toselectid] = $toselectid;
758 $thirdpartyid = !empty($objecttmp->fk_soc) ? $objecttmp->fk_soc : $objecttmp->socid;
759 $listofobjectthirdparties[$thirdpartyid] = $thirdpartyid;
760 $listofobjectref[$toselectid] = $objecttmp->ref;
764 $arrayofinclusion = array();
765 foreach ($listofobjectref as $tmppdf) {
768 foreach ($listofobjectref as $tmppdf) {
769 $arrayofinclusion[] =
'^'.preg_quote(
dol_sanitizeFileName($tmppdf),
'/').
'_[a-zA-Z0-9\-\_\'\&\.]+\.pdf$';
771 $listoffiles =
dol_dir_list($uploaddir,
'all', 1, implode(
'|', $arrayofinclusion),
'\.meta$|\.png',
'date', SORT_DESC, 0,
true);
776 foreach ($listofobjectref as $basename) {
778 foreach ($listoffiles as $filefound) {
779 if (strstr($filefound[
"name"], $basename)) {
780 $files[] = $filefound[
'fullname'];
787 $outputlangs = $langs;
790 $newlang =
GETPOST(
'lang_id',
'aZ09');
795 if (!empty($newlang)) {
797 $outputlangs->setDefaultLang($newlang);
806 $filename = preg_replace(
'/\s/',
'_', $filename);
809 if (in_array($objecttmp->element, array(
'facture',
'invoice_supplier')) && $search_status ==
Facture::STATUS_VALIDATED) {
810 if ($option ==
'late') {
817 $filename .=
'_'.$year;
820 $filename .=
'_'.$month;
823 if (count($files) > 0) {
825 $file = $diroutputmassaction.
'/'.$filename.
'_'.
dol_print_date($now,
'dayhourlog').
'.pdf';
828 foreach ($files as $f) {
829 $input_files .=
' '.escapeshellarg($f);
832 $cmd =
'pdftk '.$input_files.
' cat output '.escapeshellarg($file);
836 if (file_exists($file)) {
839 $langs->load(
"exports");
842 setEventMessages($langs->trans(
'ErrorPDFTkOutputFileNotFound'),
null,
'errors');
845 setEventMessages($langs->trans(
'NoPDFAvailableForDocGenAmongChecked'),
null,
'errors');
850 $page_largeur = $formatarray[
'width'];
851 $page_hauteur = $formatarray[
'height'];
852 $format = array($page_largeur, $page_hauteur);
856 if (class_exists(
'TCPDF')) {
857 $pdf->setPrintHeader(
false);
858 $pdf->setPrintFooter(
false);
863 $pdf->SetCompression(
false);
867 foreach ($files as $file) {
869 $pagecount = $pdf->setSourceFile($file);
870 for ($i = 1; $i <= $pagecount; $i++) {
871 $tplidx = $pdf->importPage($i);
872 $s = $pdf->getTemplatesize($tplidx);
873 $pdf->AddPage($s[
'h'] > $s[
'w'] ?
'P' :
'L');
874 $pdf->useTemplate($tplidx);
883 $filename = preg_replace(
'/\s/',
'_', $filename);
887 if (in_array($objecttmp->element, array(
'facture',
'invoice_supplier')) && $search_status ==
Facture::STATUS_VALIDATED) {
888 if ($option ==
'late') {
895 $filename .=
'_'.$year;
898 $filename .=
'_'.$month;
902 $file = $diroutputmassaction.
'/'.$filename.
'_'.
dol_print_date($now,
'dayhourlog').
'.pdf';
903 $pdf->Output($file,
'F');
906 $langs->load(
"exports");
909 setEventMessages($langs->trans(
'NoPDFAvailableForDocGenAmongChecked'),
null,
'errors');
915if ($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');
932if (!$error && $massaction ==
'validate' && $permissiontoadd) {
933 $objecttmp =
new $objectclass($db);
935 if (($objecttmp->element ==
'facture' || $objecttmp->element ==
'invoice') && isModEnabled(
'stock') &&
getDolGlobalString(
'STOCK_CALCULATE_ON_BILL')) {
936 $langs->load(
"errors");
937 setEventMessages($langs->trans(
'ErrorMassValidationNotAllowedWhenStockIncreaseOnAction'),
null,
'errors');
940 if ($objecttmp->element ==
'invoice_supplier' && isModEnabled(
'stock') &&
getDolGlobalString(
'STOCK_CALCULATE_ON_SUPPLIER_BILL')) {
941 $langs->load(
"errors");
942 setEventMessages($langs->trans(
'ErrorMassValidationNotAllowedWhenStockIncreaseOnAction'),
null,
'errors');
945 if ($objecttmp->element ==
'facture') {
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) {
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 : (
getDolGlobalString(
'MAIN_GENERATE_DOCUMENTS_HIDE_DETAILS') ? 1 : 0);
1015 $hidedesc = !empty($hidedesc) ? $hidedesc : (
getDolGlobalString(
'MAIN_GENERATE_DOCUMENTS_HIDE_DESC') ? 1 : 0);
1016 $hideref = !empty($hideref) ? $hideref : (
getDolGlobalString(
'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');
1047if (!$error && ($massaction ==
'delete' || ($action ==
'delete' && $confirm ==
'yes')) && $permissiontodelete) {
1050 $objecttmp =
new $objectclass($db);
1056 $unique_arr = array_unique($toselect);
1057 foreach ($unique_arr as $toselectid) {
1058 $result = $objecttmp->fetch($toselectid);
1062 $langs->load(
"errors");
1064 $TMsg[] =
'<div class="error">'.$langs->trans(
'ErrorOnlyDraftStatusCanBeDeletedInMassAction', $objecttmp->ref).
'</div><br>';
1068 if (method_exists($objecttmp,
'is_erasable') && $objecttmp->is_erasable() <= 0) {
1069 $langs->load(
"errors");
1071 $TMsg[] =
'<div class="error">'.$langs->trans(
'ErrorRecordHasChildren').
' '.$objecttmp->ref.
'</div><br>';
1076 $langs->load(
"errors");
1078 $TMsg[] =
'<div class="error">'.$langs->trans(
'ErrorLeaveRequestMustBeDraftCanceledOrRefusedToBeDeleted', $objecttmp->ref).
'</div><br>';
1082 if ($objectclass ==
"Task" && $objecttmp->hasChildren() > 0) {
1083 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"projet_task SET fk_task_parent = 0 WHERE fk_task_parent = ".((int) $objecttmp->id);
1084 $res = $db->query($sql);
1092 if ($objecttmp->element ==
'societe') {
1094 '@phan-var-force Societe $objecttmp';
1096 $result = $objecttmp->delete($objecttmp->id, $user, 1);
1098 $result = $objecttmp->delete($user);
1101 if (empty($result)) {
1102 $TMsg = array_merge($objecttmp->errors, $TMsg);
1103 } elseif ($result < 0) {
1117 if (empty($error)) {
1121 } elseif ($nbok > 0) {
1128 if (!empty($TMsg)) {
1143if (!$error && $massaction ==
'generate_doc' && $permissiontoread) {
1145 $objecttmp =
new $objectclass($db);
1147 foreach ($toselect as $toselectid) {
1148 $result = $objecttmp->fetch($toselectid);
1150 $outputlangs = $langs;
1154 $newlang =
GETPOST(
'lang_id',
'aZ09');
1156 if (
getDolGlobalInt(
'MAIN_MULTILANGS') && empty($newlang) && isset($objecttmp->thirdparty->default_lang)) {
1157 $newlang = $objecttmp->thirdparty->default_lang;
1159 if (
getDolGlobalInt(
'MAIN_MULTILANGS') && empty($newlang) && isset($objecttmp->default_lang)) {
1160 $newlang = $objecttmp->default_lang;
1162 if ($conf->global->MAIN_MULTILANGS && empty($newlang) && empty($objecttmp->thirdparty)) {
1163 $objecttmp->fetch_thirdparty();
1164 $newlang = $objecttmp->thirdparty->default_lang;
1166 if (!empty($newlang)) {
1167 $outputlangs =
new Translate(
"", $conf);
1168 $outputlangs->setDefaultLang($newlang);
1172 if (empty($hidedetails)) {
1175 if (empty($hidedesc)) {
1178 if (empty($hideref)) {
1181 if (empty($moreparams)) {
1185 $result = $objecttmp->generateDocument($objecttmp->model_pdf, $outputlangs, $hidedetails, $hidedesc, $hideref, $moreparams);
1213if (!$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'];
1236 if (!empty($to_affecttag_type_array)) {
1237 foreach ($to_affecttag_type_array as $categ_type) {
1238 $contcats =
GETPOST(
'contcats_' . $categ_type,
'array');
1240 foreach ($toselect as $toselectid) {
1241 $result =
$object->fetch($toselectid);
1244 $result =
$object->setCategoriesCommon($contcats, $categ_type,
false);
1263 $toselect = array();
1269if (!$error && ($action ==
'updateprice' && $confirm ==
'yes') && $permissiontoadd) {
1272 if (GETPOSTISSET(
'pricerate')) {
1274 if ($pricepercentage == 0) {
1277 foreach ($toselect as $toselectid) {
1278 $result =
$object->fetch($toselectid);
1281 if ($obj->price_base_type ==
'TTC') {
1282 $newprice =
$object->price_ttc * (100 + $pricepercentage) / 100;
1283 $minprice =
$object->price_min_ttc;
1285 $newprice =
$object->price * (100 + $pricepercentage) / 100;
1286 $minprice =
$object->price_min;
1288 $res =
$object->updatePrice($newprice, $obj->price_base_type, $user,
$object->tva_tx, $minprice, 0,
$object->tva_npr, 0, 0, array(),
$object->default_vat_code);
1308 $toselect = array();
1314if (!$error && ($action ==
'setsupervisor' && $confirm ==
'yes') && $permissiontoadd) {
1317 $supervisortoset =
GETPOST(
'supervisortoset');
1318 if (!empty($supervisortoset)) {
1319 foreach ($toselect as $toselectid) {
1320 $result =
$object->fetch($toselectid);
1323 $object->fk_user = $supervisortoset;
1324 $res =
$object->update($user);
1344 $toselect = array();
1350if (!$error && ($action ==
'affectuser' && $confirm ==
'yes') && $permissiontoadd) {
1354 $usertoaffect =
GETPOST(
'usertoaffect');
1355 $projectrole =
GETPOST(
'projectrole');
1356 $tasksrole =
GETPOST(
'tasksrole');
1357 if (!empty($usertoaffect)) {
1358 foreach ($toselect as $toselectid) {
1359 $result =
$object->fetch($toselectid);
1362 $res =
$object->add_contact($usertoaffect, $projectrole,
'internal');
1364 $taskstatic =
new Task($db);
1365 $task_array = $taskstatic->getTasksArray(0, 0,
$object->id, 0, 0);
1367 foreach ($task_array as $task) {
1368 $tasksToAffect =
new Task($db);
1369 $result = $tasksToAffect->fetch($task->id);
1371 $res = $tasksToAffect->add_contact($usertoaffect, $tasksrole,
'internal');
1395 $toselect = array();
1401if (!$error && ($massaction ==
'enable' || ($action ==
'enable' && $confirm ==
'yes')) && $permissiontoadd) {
1404 $objecttmp =
new $objectclass($db);
1406 foreach ($toselect as $toselectid) {
1407 $result = $objecttmp->fetch($toselectid);
1409 if (in_array($objecttmp->element, array(
'societe'))) {
1410 $result = $objecttmp->setStatut(1);
1438if (!$error && ($massaction ==
'disable' || ($action ==
'disable' && $confirm ==
'yes')) && $permissiontoadd) {
1441 $objecttmp =
new $objectclass($db);
1443 foreach ($toselect as $toselectid) {
1444 $result = $objecttmp->fetch($toselectid);
1446 if (in_array($objecttmp->element, array(
'societe'))) {
1447 $result = $objecttmp->setStatut(0);
1475if (!$error && $action ==
'confirm_edit_value_extrafields' && $confirm ==
'yes' && $permissiontoadd) {
1478 $objecttmp =
new $objectclass($db);
1480 $e->fetch_name_optionals_label($objecttmp->table_element);
1483 $extrafieldKeyToUpdate =
GETPOST(
'extrafield-key-to-update');
1486 foreach ($toselect as $toselectid) {
1488 $objecttmp =
new $objectclass($db);
1489 $result = $objecttmp->fetch($toselectid);
1492 $ret = $e->setOptionalsFromPost(
null, $objecttmp, $extrafieldKeyToUpdate);
1494 $objecttmp->insertExtraFields();
1518if (!$error && ($massaction ==
'affectcommercial' || ($action ==
'affectcommercial' && $confirm ==
'yes')) && $permissiontoadd) {
1521 $objecttmp =
new $objectclass($db);
1524 foreach ($toselect as $toselectid) {
1525 $result = $objecttmp->fetch($toselectid);
1527 if (in_array($objecttmp->element, array(
'societe'))) {
1528 $result = $objecttmp->setSalesRep(
GETPOST(
"commercial",
"alpha"));
1546 setEventMessages($langs->trans(
"CommercialsAffected", $nbok),
null,
'mesgs');
1556if (!$error && ($massaction ==
'unassigncommercial' || ($action ==
'unassigncommercial' && $confirm ==
'yes')) && $permissiontoadd) {
1559 $objecttmp =
new $objectclass($db);
1562 foreach ($toselect as $toselectid) {
1563 $result = $objecttmp->fetch($toselectid);
1565 if (in_array($objecttmp->element, array(
'societe'))) {
1566 $TCommercial =
GETPOST(
"commercial",
"alpha");
1567 if (is_array($TCommercial)) {
1568 foreach ($TCommercial as $commercial) {
1569 $result = $objecttmp->del_commercial($user, $commercial);
1589 setEventMessages($langs->trans(
"CommercialsDisaffected", $nbok),
null,
'mesgs');
1599if (!$error && ($massaction ==
'approveleave' || ($action ==
'approveleave' && $confirm ==
'yes')) && $permissiontoapprove) {
1602 $objecttmp =
new $objectclass($db);
1604 foreach ($toselect as $toselectid) {
1605 $result = $objecttmp->fetch($toselectid);
1608 setEventMessages($langs->trans(
'StatusOfRefMustBe', $objecttmp->ref, $langs->transnoentitiesnoconv(
'Validated')),
null,
'warnings');
1611 if ($user->id == $objecttmp->fk_validator) {
1612 $objecttmp->oldcopy =
dol_clone($objecttmp, 2);
1614 $objecttmp->date_valid =
dol_now();
1615 $objecttmp->fk_user_valid = $user->id;
1617 $objecttmp->statut = $objecttmp->status;
1619 $verif = $objecttmp->approve($user);
1629 $nbopenedday =
num_open_day($objecttmp->date_debut_gmt, $objecttmp->date_fin_gmt, 0, 1, $objecttmp->halfday);
1630 $soldeActuel = $objecttmp->getCpforUser($objecttmp->fk_user, $objecttmp->fk_type);
1631 $newSolde = ($soldeActuel - $nbopenedday);
1634 $result = $objecttmp->addLogCP($user->id, $objecttmp->fk_user, $langs->transnoentitiesnoconv(
"Holidays"), $newSolde, $objecttmp->fk_type);
1641 $result = $objecttmp->updateSoldeCP($objecttmp->fk_user, $newSolde, $objecttmp->fk_type);
1650 $destinataire =
new User($db);
1651 $destinataire->fetch($objecttmp->fk_user);
1652 $emailTo = $destinataire->email;
1655 dol_syslog(
"User that request leave has no email, so we redirect directly to finished page without sending email");
1658 $expediteur =
new User($db);
1659 $expediteur->fetch($objecttmp->fk_validator);
1669 $subject = $societeName.
" - ".$langs->transnoentitiesnoconv(
"HolidaysValidated");
1672 $message = $langs->transnoentitiesnoconv(
"Hello").
" ".$destinataire->firstname.
",\n";
1675 $message .= $langs->transnoentities(
"HolidaysValidatedBody",
dol_print_date($objecttmp->date_debut,
'day'),
dol_print_date($objecttmp->date_fin,
'day')).
"\n";
1677 $message .=
"- ".$langs->transnoentitiesnoconv(
"ValidatedBy").
" : ".
dolGetFirstLastname($expediteur->firstname, $expediteur->lastname).
"\n";
1679 $message .=
"- ".$langs->transnoentitiesnoconv(
"Link").
" : ".$dolibarr_main_url_root.
"/holiday/card.php?id=".$objecttmp->id.
"\n\n";
1682 $trackid =
'leav'.$objecttmp->id;
1684 require_once DOL_DOCUMENT_ROOT.
'/core/class/CMailFile.class.php';
1685 $mail =
new CMailFile($subject, $emailTo, $emailFrom, $message, array(), array(), array(),
'',
'', 0, 0,
'',
'', $trackid);
1688 $result = $mail->sendfile();
1697 $langs->load(
"errors");
1698 setEventMessages($langs->trans(
'ErrorNotApproverForHoliday', $objecttmp->ref),
null,
'errors');
1710 } elseif ($nbok == 1) {
1719if (!$error && ($massaction ==
'increaseholiday' || ($action ==
'increaseholiday' && $confirm ==
'yes')) && $permissiontoapprove) {
1721 $objecttmp =
new $objectclass($db);
1723 $typeholiday =
GETPOST(
'typeholiday',
'alpha');
1726 if ($nbdaysholidays <= 0) {
1732 foreach ($toselect as $toselectid) {
1733 $balancecpuser = $objecttmp->getCPforUser($toselectid, $typeholiday);
1734 if (!empty($balancecpuser)) {
1735 $newnbdaysholidays = $nbdaysholidays + $balancecpuser;
1737 $newnbdaysholidays = $nbdaysholidays;
1739 $result = $holiday->addLogCP($user->id, $toselectid, $langs->transnoentitiesnoconv(
'ManualUpdate'), $newnbdaysholidays, $typeholiday);
1746 $objecttmp->updateSoldeCP($toselectid, $newnbdaysholidays, $typeholiday);
1759 setEventMessages($langs->trans(
"HolidayRecordsIncreased", $nbok),
null,
'mesgs');
1760 } elseif ($nbok == 1) {
1764 $toselect = array();
1771if (!$error && ($massaction ==
'clonetasks' || ($action ==
'clonetasks' && $confirm ==
'yes'))) {
1774 include_once DOL_DOCUMENT_ROOT.
'/projet/class/task.class.php';
1776 $origin_task =
new Task($db);
1777 $clone_task =
new Task($db);
1778 $newproject =
new Project($db);
1782 $iscontactofnewproject = 0;
1783 if (empty($newproject->public)) {
1784 $tmps = $newproject->getProjectsAuthorizedForUser($user, 0, 1, 0,
'(fk_statut:=:1)');
1785 $tmparray = explode(
',', $tmps);
1786 if (!in_array($newproject->id, $tmparray)) {
1787 $iscontactofnewproject = 1;
1792 $permisstiontoadd =
false;
1793 if ($user->hasRight(
'project',
'all',
'creer') || ($user->hasRight(
'project',
'creer') && ($newproject->public || $iscontactofnewproject))) {
1794 $permisstiontoadd =
true;
1797 if ($permisstiontoadd) {
1798 foreach (
GETPOST(
'selected') as $task) {
1799 $origin_task->fetch($task,
'', 0);
1804 require_once DOL_DOCUMENT_ROOT .
"/core/modules/project/task/" .
getDolGlobalString(
'PROJECT_TASK_ADDON') .
'.php';
1805 $modTask =
new $classnamemodtask();
1806 '@phan-var-force ModeleNumRefTask $modTask';
1807 $defaultref = $modTask->getNextValue(
null, $clone_task);
1811 $clone_task->fk_project =
GETPOSTINT(
'projectid');
1812 $clone_task->ref = $defaultref;
1813 $clone_task->label = $origin_task->label;
1814 $clone_task->description = $origin_task->description;
1815 $clone_task->planned_workload = $origin_task->planned_workload;
1816 $clone_task->fk_task_parent = $origin_task->fk_task_parent;
1817 $clone_task->date_c =
dol_now();
1818 $clone_task->date_start = $origin_task->date_start;
1819 $clone_task->date_end = $origin_task->date_end;
1820 $clone_task->progress = $origin_task->progress;
1823 $ret = $extrafields->setOptionalsFromPost(
null, $clone_task);
1825 $taskid = $clone_task->create($user);
1828 $result = $clone_task->add_contact(
GETPOSTINT(
"userid"),
'TASKEXECUTIVE',
'internal');
1831 if ($db->lasterrno() ==
'DB_ERROR_RECORD_ALREADY_EXISTS') {
1832 $langs->load(
"projects");
1834 $duplicate_code_error =
true;
1845 setEventMessages($langs->trans(
'NumberOfTasksCloned', $num),
null,
'mesgs');
1846 header(
"Location: ".DOL_URL_ROOT.
'/projet/tasks.php?id='.
GETPOSTINT(
'projectid'));
1854$parameters[
'toselect'] = (empty($toselect) ? array() : $toselect);
1855$parameters[
'uploaddir'] = $uploaddir;
1856$parameters[
'massaction'] = $massaction;
1857$parameters[
'diroutputmassaction'] = isset($diroutputmassaction) ? $diroutputmassaction :
null;
1859$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.
Class to manage projects.
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).
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.