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 $parameters = array(
'mode' =>
'formemail');
485 if (!empty($listofobjectthirdparties)) {
486 $parameters[
'listofobjectthirdparties'] = $listofobjectthirdparties;
488 if (!empty($listofobjectref)) {
489 $parameters[
'listofobjectref'] = $listofobjectref;
497 $attachedfiles = array(
'paths' => array(),
'names' => array(),
'mimes' => array());
498 if ($oneemailperrecipient) {
500 if (is_array($attachedfilesThirdpartyObj[$thirdparty->id]) && count($attachedfilesThirdpartyObj[$thirdparty->id])) {
501 foreach ($attachedfilesThirdpartyObj[$thirdparty->id] as $keyObjId => $objAttachedFiles) {
503 $attachedfiles = array(
504 'paths' => array_merge($attachedfiles[
'paths'], $objAttachedFiles[
'paths']),
505 'names' => array_merge($attachedfiles[
'names'], $objAttachedFiles[
'names']),
506 'mimes' => array_merge($attachedfiles[
'mimes'], $objAttachedFiles[
'mimes'])
510 } elseif (!empty($attachedfilesThirdpartyObj[$thirdparty->id][$objectid])) {
513 $attachedfiles = $attachedfilesThirdpartyObj[$thirdparty->id][$objectid];
516 $filepath = $attachedfiles[
'paths'];
517 $filename = $attachedfiles[
'names'];
518 $mimetype = $attachedfiles[
'mimes'];
521 if ($oneemailperrecipient) {
522 $trackid =
'thi'.$thirdparty->id;
523 if ($objecttmp->element ==
'expensereport') {
524 $trackid =
'use'.$thirdparty->id;
525 } elseif ($objecttmp->element ==
'contact') {
526 $trackid =
'ctc'.$thirdparty->id;
527 } elseif ($objecttmp->element ==
'holiday') {
528 $trackid =
'use'.$thirdparty->id;
531 $trackid = strtolower(get_class($objecttmp));
532 if (get_class($objecttmp) ==
'Contact') {
534 } elseif (get_class($objecttmp) ==
'Contrat') {
536 } elseif (get_class($objecttmp) ==
'Propal') {
538 } elseif (get_class($objecttmp) ==
'Commande') {
540 } elseif (get_class($objecttmp) ==
'Facture') {
542 } elseif (get_class($objecttmp) ==
'SupplierProposal') {
544 } elseif (get_class($objecttmp) ==
'CommandeFournisseur') {
546 } elseif (get_class($objecttmp) ==
'FactureFournisseur') {
550 $trackid .= $objecttmp->id;
556 if (empty($sendcontext)) {
557 $sendcontext =
'standard';
561 $vardir = $conf->user->dir_output.
"/".$user->id;
562 $upload_dir_tmp = $vardir.
'/temp';
565 require_once DOL_DOCUMENT_ROOT.
'/core/class/CMailFile.class.php';
566 $mailfile =
new CMailFile($subjectreplaced, $sendto, $from, $messagereplaced, $filepath, $mimetype, $filename, $sendtocc, $sendtobcc, $deliveryreceipt, -1,
'',
'', $trackid,
'', $sendcontext,
'', $upload_dir_tmp);
567 if ($mailfile->error) {
568 $resaction .=
'<div class="error">'.$mailfile->error.
'</div>';
570 $result = $mailfile->sendfile();
572 $resaction .= $langs->trans(
'MailSuccessfulySent', $mailfile->getValidAddress($mailfile->addr_from, 2), $mailfile->getValidAddress($mailfile->addr_to, 2)).
'<br>';
577 foreach ($listofqualifiedobj as $objid2 => $objectobj2) {
578 if ((!$oneemailperrecipient) && $objid2 != $objectid) {
582 dol_syslog(
"Try to insert email event into agenda for objid=".$objid2.
" => objectobj=".get_class($objectobj2));
591 $actionmsg = $langs->transnoentities(
'MailSentByTo', $from, $sendto);
594 $actionmsg =
dol_concatdesc($actionmsg, $langs->transnoentities(
'Bcc').
": ".$sendtocc);
596 $actionmsg =
dol_concatdesc($actionmsg, $langs->transnoentities(
'MailTopic').
": ".$subjectreplaced);
597 $actionmsg =
dol_concatdesc($actionmsg, $langs->transnoentities(
'TextUsedInTheMessageBody').
":");
603 $objectobj2->sendtoid = (empty($contactidtosend) ? 0 : $contactidtosend);
604 $objectobj2->actionmsg = $actionmsg;
605 $objectobj2->actionmsg2 = $actionmsg2;
606 $objectobj2->fk_element = $objid2;
607 $objectobj2->elementtype = $objectobj2->element;
609 $objectobj2->actionmsg2 = $subjectreplaced;
612 $triggername = strtoupper(get_class($objectobj2)).
'_SENTBYMAIL';
613 if ($triggername ==
'SOCIETE_SENTBYMAIL') {
614 $triggername =
'COMPANY_SENTBYMAIL';
616 if ($triggername ==
'CONTRAT_SENTBYMAIL') {
617 $triggername =
'CONTRACT_SENTBYMAIL';
619 if ($triggername ==
'COMMANDE_SENTBYMAIL') {
620 $triggername =
'ORDER_SENTBYMAIL';
622 if ($triggername ==
'FACTURE_SENTBYMAIL') {
623 $triggername =
'BILL_SENTBYMAIL';
625 if ($triggername ==
'EXPEDITION_SENTBYMAIL') {
626 $triggername =
'SHIPPING_SENTBYMAIL';
628 if ($triggername ==
'COMMANDEFOURNISSEUR_SENTBYMAIL') {
629 $triggername =
'ORDER_SUPPLIER_SENTBYMAIL';
631 if ($triggername ==
'FACTUREFOURNISSEUR_SENTBYMAIL') {
632 $triggername =
'BILL_SUPPLIER_SENTBYMAIL';
634 if ($triggername ==
'SUPPLIERPROPOSAL_SENTBYMAIL') {
635 $triggername =
'PROPOSAL_SUPPLIER_SENTBYMAIL';
637 if ($triggername ==
'PROJET_SENTBYMAIL') {
638 $triggername =
'PROJECT_SENTBYMAIL';
641 if (!empty($triggername)) {
643 $result = $objectobj2->call_trigger($triggername, $user);
651 dol_syslog(
"Error in trigger ".$triggername.
' '.$db->lasterror(), LOG_ERR);
658 $langs->load(
"other");
659 if ($mailfile->error) {
660 $resaction .= $langs->trans(
'ErrorFailedToSendMail', $from, $sendto);
661 $resaction .=
'<br><div class="error">'.$mailfile->error.
'</div>';
663 $resaction .=
'<div class="warning">No mail sent. Feature is disabled by option MAIN_DISABLE_ALL_MAILS</div>';
665 $resaction .= $langs->trans(
'ErrorFailedToSendMail', $from, $sendto) .
'<br><div class="error">(unhandled error)</div>';
673 $resaction .= ($resaction ?
'<br>' : $resaction);
674 $resaction .=
'<strong>'.$langs->trans(
"ResultOfMailSending").
':</strong><br>'.
"\n";
675 $resaction .= $langs->trans(
"NbSelected").
': '.count($toselect).
"\n<br>";
676 $resaction .= $langs->trans(
"NbIgnored").
': '.($nbignored ? $nbignored : 0).
"\n<br>";
677 $resaction .= $langs->trans(
"NbSent").
': '.($nbsent ? $nbsent : 0).
"\n<br>";
682 setEventMessages($langs->trans(
"EMailSentForNElements", $nbsent.
'/'.count($toselect)),
null,
'mesgs');
695if (!$error && $massaction ==
'cancelorders') {
700 $orders =
GETPOST(
'toselect',
'array');
701 foreach ($orders as $id_order) {
703 if ($cmd->fetch($id_order) <= 0) {
708 $langs->load(
'errors');
709 setEventMessages($langs->trans(
"ErrorObjectMustHaveStatusValidToBeCanceled", $cmd->ref),
null,
'errors');
714 $result = $cmd->cancel();
734if (!$error && $massaction ==
"builddoc" && $permissiontoread && !
GETPOST(
'button_search')) {
735 if (empty($diroutputmassaction)) {
736 dol_print_error(
null,
'include of actions_massactions.inc.php is done but var $diroutputmassaction was not defined');
740 require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
741 require_once DOL_DOCUMENT_ROOT.
'/core/lib/pdf.lib.php';
742 require_once DOL_DOCUMENT_ROOT.
'/core/lib/date.lib.php';
744 $objecttmp =
new $objectclass($db);
745 $listofobjectid = array();
746 $listofobjectthirdparties = array();
747 $listofobjectref = array();
748 foreach ($toselect as $toselectid) {
749 $objecttmp =
new $objectclass($db);
750 $result = $objecttmp->fetch($toselectid);
752 $listofobjectid[$toselectid] = $toselectid;
753 $thirdpartyid = !empty($objecttmp->fk_soc) ? $objecttmp->fk_soc : $objecttmp->socid;
754 $listofobjectthirdparties[$thirdpartyid] = $thirdpartyid;
755 $listofobjectref[$toselectid] = $objecttmp->ref;
759 $arrayofinclusion = array();
760 foreach ($listofobjectref as $tmppdf) {
763 foreach ($listofobjectref as $tmppdf) {
764 $arrayofinclusion[] =
'^'.preg_quote(
dol_sanitizeFileName($tmppdf),
'/').
'_[a-zA-Z0-9\-\_\'\&\.]+\.pdf$';
766 $listoffiles =
dol_dir_list($uploaddir,
'all', 1, implode(
'|', $arrayofinclusion),
'\.meta$|\.png',
'date', SORT_DESC, 0,
true);
771 foreach ($listofobjectref as $basename) {
773 foreach ($listoffiles as $filefound) {
774 if (strstr($filefound[
"name"], $basename)) {
775 $files[] = $filefound[
'fullname'];
782 $outputlangs = $langs;
785 $newlang =
GETPOST(
'lang_id',
'aZ09');
790 if (!empty($newlang)) {
792 $outputlangs->setDefaultLang($newlang);
801 $filename = preg_replace(
'/\s/',
'_', $filename);
804 if (in_array($objecttmp->element, array(
'facture',
'invoice_supplier')) && $search_status ==
Facture::STATUS_VALIDATED) {
805 if ($option ==
'late') {
812 $filename .=
'_'.$year;
815 $filename .=
'_'.$month;
818 if (count($files) > 0) {
820 $file = $diroutputmassaction.
'/'.$filename.
'_'.
dol_print_date($now,
'dayhourlog').
'.pdf';
823 foreach ($files as $f) {
824 $input_files .=
' '.escapeshellarg($f);
827 $cmd =
'pdftk '.$input_files.
' cat output '.escapeshellarg($file);
831 if (file_exists($file)) {
834 $langs->load(
"exports");
837 setEventMessages($langs->trans(
'ErrorPDFTkOutputFileNotFound'),
null,
'errors');
840 setEventMessages($langs->trans(
'NoPDFAvailableForDocGenAmongChecked'),
null,
'errors');
845 $page_largeur = $formatarray[
'width'];
846 $page_hauteur = $formatarray[
'height'];
847 $format = array($page_largeur, $page_hauteur);
851 if (class_exists(
'TCPDF')) {
852 $pdf->setPrintHeader(
false);
853 $pdf->setPrintFooter(
false);
858 $pdf->SetCompression(
false);
862 foreach ($files as $file) {
864 $pagecount = $pdf->setSourceFile($file);
865 for ($i = 1; $i <= $pagecount; $i++) {
866 $tplidx = $pdf->importPage($i);
867 $s = $pdf->getTemplatesize($tplidx);
868 $pdf->AddPage($s[
'h'] > $s[
'w'] ?
'P' :
'L');
869 $pdf->useTemplate($tplidx);
878 $filename = preg_replace(
'/\s/',
'_', $filename);
882 if (in_array($objecttmp->element, array(
'facture',
'invoice_supplier')) && $search_status ==
Facture::STATUS_VALIDATED) {
883 if ($option ==
'late') {
890 $filename .=
'_'.$year;
893 $filename .=
'_'.$month;
897 $file = $diroutputmassaction.
'/'.$filename.
'_'.
dol_print_date($now,
'dayhourlog').
'.pdf';
898 $pdf->Output($file,
'F');
901 $langs->load(
"exports");
904 setEventMessages($langs->trans(
'NoPDFAvailableForDocGenAmongChecked'),
null,
'errors');
910if ($action ==
'remove_file') {
911 require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
913 $langs->load(
"other");
914 $upload_dir = $diroutputmassaction;
915 $file = $upload_dir.
'/'.
GETPOST(
'file');
927if (!$error && $massaction ==
'validate' && $permissiontoadd) {
928 $objecttmp =
new $objectclass($db);
930 if (($objecttmp->element ==
'facture' || $objecttmp->element ==
'invoice') && isModEnabled(
'stock') &&
getDolGlobalString(
'STOCK_CALCULATE_ON_BILL')) {
931 $langs->load(
"errors");
932 setEventMessages($langs->trans(
'ErrorMassValidationNotAllowedWhenStockIncreaseOnAction'),
null,
'errors');
935 if ($objecttmp->element ==
'invoice_supplier' && isModEnabled(
'stock') &&
getDolGlobalString(
'STOCK_CALCULATE_ON_SUPPLIER_BILL')) {
936 $langs->load(
"errors");
937 setEventMessages($langs->trans(
'ErrorMassValidationNotAllowedWhenStockIncreaseOnAction'),
null,
'errors');
940 if ($objecttmp->element ==
'facture') {
943 $sql =
"SELECT rowid FROM ".MAIN_DB_PREFIX.
"facture";
944 $sql .=
" WHERE rowid IN (".$db->sanitize(implode(
",", $toselect)).
")";
945 $sql .=
" ORDER BY datef";
947 $resql = $db->query($sql);
950 while (!empty($arr = $db->fetch_row($resql))) {
951 $toselectnew[] = $arr[0];
953 $toselect = (empty($toselectnew)) ? $toselect : $toselectnew;
964 foreach ($toselect as $toselectid) {
965 $result = $objecttmp->fetch($toselectid);
967 if (method_exists($objecttmp,
'validate')) {
968 $result = $objecttmp->validate($user);
969 } elseif (method_exists($objecttmp,
'setValid')) {
970 $result = $objecttmp->setValid($user);
972 $objecttmp->error =
'No method validate or setValid on this object';
976 $langs->load(
"errors");
977 setEventMessages($langs->trans(
"ErrorObjectMustHaveStatusDraftToBeValidated", $objecttmp->ref),
null,
'errors');
980 } elseif ($result < 0) {
988 $outputlangs = $langs;
991 $newlang =
GETPOST(
'lang_id',
'aZ09');
993 if (
getDolGlobalInt(
'MAIN_MULTILANGS') && empty($newlang) && property_exists($objecttmp,
'thirdparty')) {
994 if ((property_exists($objecttmp,
'socid') || property_exists($objecttmp,
'fk_soc')) && empty($objecttmp->thirdparty)) {
995 $objecttmp->fetch_thirdparty();
997 if (!empty($objecttmp->thirdparty)) {
998 $newlang = $objecttmp->thirdparty->default_lang;
1001 if (!empty($newlang)) {
1002 $outputlangs =
new Translate(
"", $conf);
1003 $outputlangs->setDefaultLang($newlang);
1004 $outputlangs->load(
'products');
1006 $model = $objecttmp->model_pdf;
1007 $ret = $objecttmp->fetch($objecttmp->id);
1009 $hidedetails = !empty($hidedetails) ? $hidedetails : (
getDolGlobalString(
'MAIN_GENERATE_DOCUMENTS_HIDE_DETAILS') ? 1 : 0);
1010 $hidedesc = !empty($hidedesc) ? $hidedesc : (
getDolGlobalString(
'MAIN_GENERATE_DOCUMENTS_HIDE_DESC') ? 1 : 0);
1011 $hideref = !empty($hideref) ? $hideref : (
getDolGlobalString(
'MAIN_GENERATE_DOCUMENTS_HIDE_REF') ? 1 : 0);
1012 $moreparams = !empty($moreparams) ? $moreparams :
null;
1014 $result = $objecttmp->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref);
1032 setEventMessages($langs->trans(
"RecordModifiedSuccessfully"),
null,
'mesgs');
1042if (!$error && ($massaction ==
'delete' || ($action ==
'delete' && $confirm ==
'yes')) && $permissiontodelete) {
1045 $objecttmp =
new $objectclass($db);
1051 $unique_arr = array_unique($toselect);
1052 foreach ($unique_arr as $toselectid) {
1053 $result = $objecttmp->fetch($toselectid);
1057 $langs->load(
"errors");
1059 $TMsg[] =
'<div class="error">'.$langs->trans(
'ErrorOnlyDraftStatusCanBeDeletedInMassAction', $objecttmp->ref).
'</div><br>';
1063 if (method_exists($objecttmp,
'is_erasable') && $objecttmp->is_erasable() <= 0) {
1064 $langs->load(
"errors");
1066 $TMsg[] =
'<div class="error">'.$langs->trans(
'ErrorRecordHasChildren').
' '.$objecttmp->ref.
'</div><br>';
1071 $langs->load(
"errors");
1073 $TMsg[] =
'<div class="error">'.$langs->trans(
'ErrorLeaveRequestMustBeDraftCanceledOrRefusedToBeDeleted', $objecttmp->ref).
'</div><br>';
1077 if ($objectclass ==
"Task" && $objecttmp->hasChildren() > 0) {
1078 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"projet_task SET fk_task_parent = 0 WHERE fk_task_parent = ".((int) $objecttmp->id);
1079 $res = $db->query($sql);
1087 if ($objecttmp->element ==
'societe') {
1089 '@phan-var-force Societe $objecttmp';
1091 $result = $objecttmp->delete($objecttmp->id, $user, 1);
1093 $result = $objecttmp->delete($user);
1096 if (empty($result)) {
1097 $TMsg = array_merge($objecttmp->errors, $TMsg);
1098 } elseif ($result < 0) {
1112 if (empty($error)) {
1116 } elseif ($nbok > 0) {
1123 if (!empty($TMsg)) {
1138if (!$error && $massaction ==
'generate_doc' && $permissiontoread) {
1140 $objecttmp =
new $objectclass($db);
1142 foreach ($toselect as $toselectid) {
1143 $result = $objecttmp->fetch($toselectid);
1145 $outputlangs = $langs;
1149 $newlang =
GETPOST(
'lang_id',
'aZ09');
1151 if (
getDolGlobalInt(
'MAIN_MULTILANGS') && empty($newlang) && isset($objecttmp->thirdparty->default_lang)) {
1152 $newlang = $objecttmp->thirdparty->default_lang;
1154 if (
getDolGlobalInt(
'MAIN_MULTILANGS') && empty($newlang) && isset($objecttmp->default_lang)) {
1155 $newlang = $objecttmp->default_lang;
1157 if ($conf->global->MAIN_MULTILANGS && empty($newlang) && empty($objecttmp->thirdparty)) {
1158 $objecttmp->fetch_thirdparty();
1159 $newlang = $objecttmp->thirdparty->default_lang;
1161 if (!empty($newlang)) {
1162 $outputlangs =
new Translate(
"", $conf);
1163 $outputlangs->setDefaultLang($newlang);
1167 if (empty($hidedetails)) {
1170 if (empty($hidedesc)) {
1173 if (empty($hideref)) {
1176 if (empty($moreparams)) {
1180 $result = $objecttmp->generateDocument($objecttmp->model_pdf, $outputlangs, $hidedetails, $hidedesc, $hideref, $moreparams);
1208if (!$error && ($action ==
'affecttag' && $confirm ==
'yes') && $permissiontoadd) {
1212 $affecttag_type =
GETPOST(
'affecttag_type',
'alpha');
1213 if (!empty($affecttag_type)) {
1214 $affecttag_type_array = explode(
',', $affecttag_type);
1218 if (!empty($affecttag_type_array)) {
1220 require_once DOL_DOCUMENT_ROOT.
'/categories/class/categorie.class.php';
1222 $to_affecttag_type_array = array();
1223 $categ_type_array = $categ->getMapList();
1224 foreach ($categ_type_array as $categdef) {
1225 if (in_array($categdef[
'code'], $affecttag_type_array)) {
1226 $to_affecttag_type_array[] = $categdef[
'code'];
1231 if (!empty($to_affecttag_type_array)) {
1232 foreach ($to_affecttag_type_array as $categ_type) {
1233 $contcats =
GETPOST(
'contcats_' . $categ_type,
'array');
1235 foreach ($toselect as $toselectid) {
1236 $result =
$object->fetch($toselectid);
1239 $result =
$object->setCategoriesCommon($contcats, $categ_type,
false);
1258 $toselect = array();
1264if (!$error && ($action ==
'updateprice' && $confirm ==
'yes') && $permissiontoadd) {
1267 if (GETPOSTISSET(
'pricerate')) {
1269 if ($pricepercentage == 0) {
1272 foreach ($toselect as $toselectid) {
1273 $result =
$object->fetch($toselectid);
1276 if ($obj->price_base_type ==
'TTC') {
1277 $newprice =
$object->price_ttc * (100 + $pricepercentage) / 100;
1278 $minprice =
$object->price_min_ttc;
1280 $newprice =
$object->price * (100 + $pricepercentage) / 100;
1281 $minprice =
$object->price_min;
1283 $res =
$object->updatePrice($newprice, $obj->price_base_type, $user,
$object->tva_tx, $minprice, 0,
$object->tva_npr, 0, 0, array(),
$object->default_vat_code);
1303 $toselect = array();
1309if (!$error && ($action ==
'setsupervisor' && $confirm ==
'yes') && $permissiontoadd) {
1312 $supervisortoset =
GETPOST(
'supervisortoset');
1313 if (!empty($supervisortoset)) {
1314 foreach ($toselect as $toselectid) {
1315 $result =
$object->fetch($toselectid);
1318 $object->fk_user = $supervisortoset;
1319 $res =
$object->update($user);
1339 $toselect = array();
1345if (!$error && ($action ==
'affectuser' && $confirm ==
'yes') && $permissiontoadd) {
1349 $usertoaffect =
GETPOST(
'usertoaffect');
1350 $projectrole =
GETPOST(
'projectrole');
1351 $tasksrole =
GETPOST(
'tasksrole');
1352 if (!empty($usertoaffect)) {
1353 foreach ($toselect as $toselectid) {
1354 $result =
$object->fetch($toselectid);
1357 $res =
$object->add_contact($usertoaffect, $projectrole,
'internal');
1359 $taskstatic =
new Task($db);
1360 $task_array = $taskstatic->getTasksArray(0, 0,
$object->id, 0, 0);
1362 foreach ($task_array as $task) {
1363 $tasksToAffect =
new Task($db);
1364 $result = $tasksToAffect->fetch($task->id);
1366 $res = $tasksToAffect->add_contact($usertoaffect, $tasksrole,
'internal');
1390 $toselect = array();
1396if (!$error && ($massaction ==
'enable' || ($action ==
'enable' && $confirm ==
'yes')) && $permissiontoadd) {
1399 $objecttmp =
new $objectclass($db);
1401 foreach ($toselect as $toselectid) {
1402 $result = $objecttmp->fetch($toselectid);
1404 if (in_array($objecttmp->element, array(
'societe'))) {
1405 $result = $objecttmp->setStatut(1);
1433if (!$error && ($massaction ==
'disable' || ($action ==
'disable' && $confirm ==
'yes')) && $permissiontoadd) {
1436 $objecttmp =
new $objectclass($db);
1438 foreach ($toselect as $toselectid) {
1439 $result = $objecttmp->fetch($toselectid);
1441 if (in_array($objecttmp->element, array(
'societe'))) {
1442 $result = $objecttmp->setStatut(0);
1470if (!$error && $action ==
'confirm_edit_value_extrafields' && $confirm ==
'yes' && $permissiontoadd) {
1473 $objecttmp =
new $objectclass($db);
1475 $e->fetch_name_optionals_label($objecttmp->table_element);
1478 $extrafieldKeyToUpdate =
GETPOST(
'extrafield-key-to-update');
1481 foreach ($toselect as $toselectid) {
1483 $objecttmp =
new $objectclass($db);
1484 $result = $objecttmp->fetch($toselectid);
1487 $ret = $e->setOptionalsFromPost(
null, $objecttmp, $extrafieldKeyToUpdate);
1489 $objecttmp->insertExtraFields();
1513if (!$error && ($massaction ==
'affectcommercial' || ($action ==
'affectcommercial' && $confirm ==
'yes')) && $permissiontoadd) {
1516 $objecttmp =
new $objectclass($db);
1519 foreach ($toselect as $toselectid) {
1520 $result = $objecttmp->fetch($toselectid);
1522 if (in_array($objecttmp->element, array(
'societe'))) {
1523 $result = $objecttmp->setSalesRep(
GETPOST(
"commercial",
"alpha"));
1541 setEventMessages($langs->trans(
"CommercialsAffected", $nbok),
null,
'mesgs');
1551if (!$error && ($massaction ==
'unassigncommercial' || ($action ==
'unassigncommercial' && $confirm ==
'yes')) && $permissiontoadd) {
1554 $objecttmp =
new $objectclass($db);
1557 foreach ($toselect as $toselectid) {
1558 $result = $objecttmp->fetch($toselectid);
1560 if (in_array($objecttmp->element, array(
'societe'))) {
1561 $TCommercial =
GETPOST(
"commercial",
"alpha");
1562 if (is_array($TCommercial)) {
1563 foreach ($TCommercial as $commercial) {
1564 $result = $objecttmp->del_commercial($user, $commercial);
1584 setEventMessages($langs->trans(
"CommercialsDisaffected", $nbok),
null,
'mesgs');
1594if (!$error && ($massaction ==
'approveleave' || ($action ==
'approveleave' && $confirm ==
'yes')) && $permissiontoapprove) {
1597 $objecttmp =
new $objectclass($db);
1599 foreach ($toselect as $toselectid) {
1600 $result = $objecttmp->fetch($toselectid);
1603 setEventMessages($langs->trans(
'StatusOfRefMustBe', $objecttmp->ref, $langs->transnoentitiesnoconv(
'Validated')),
null,
'warnings');
1606 if ($user->id == $objecttmp->fk_validator) {
1607 $objecttmp->oldcopy =
dol_clone($objecttmp, 2);
1609 $objecttmp->date_valid =
dol_now();
1610 $objecttmp->fk_user_valid = $user->id;
1612 $objecttmp->statut = $objecttmp->status;
1614 $verif = $objecttmp->approve($user);
1624 $nbopenedday =
num_open_day($objecttmp->date_debut_gmt, $objecttmp->date_fin_gmt, 0, 1, $objecttmp->halfday);
1625 $soldeActuel = $objecttmp->getCpforUser($objecttmp->fk_user, $objecttmp->fk_type);
1626 $newSolde = ($soldeActuel - $nbopenedday);
1629 $result = $objecttmp->addLogCP($user->id, $objecttmp->fk_user, $langs->transnoentitiesnoconv(
"Holidays"), $newSolde, $objecttmp->fk_type);
1636 $result = $objecttmp->updateSoldeCP($objecttmp->fk_user, $newSolde, $objecttmp->fk_type);
1645 $destinataire =
new User($db);
1646 $destinataire->fetch($objecttmp->fk_user);
1647 $emailTo = $destinataire->email;
1650 dol_syslog(
"User that request leave has no email, so we redirect directly to finished page without sending email");
1653 $expediteur =
new User($db);
1654 $expediteur->fetch($objecttmp->fk_validator);
1664 $subject = $societeName.
" - ".$langs->transnoentitiesnoconv(
"HolidaysValidated");
1667 $message = $langs->transnoentitiesnoconv(
"Hello").
" ".$destinataire->firstname.
",\n";
1670 $message .= $langs->transnoentities(
"HolidaysValidatedBody",
dol_print_date($objecttmp->date_debut,
'day'),
dol_print_date($objecttmp->date_fin,
'day')).
"\n";
1672 $message .=
"- ".$langs->transnoentitiesnoconv(
"ValidatedBy").
" : ".
dolGetFirstLastname($expediteur->firstname, $expediteur->lastname).
"\n";
1674 $message .=
"- ".$langs->transnoentitiesnoconv(
"Link").
" : ".$dolibarr_main_url_root.
"/holiday/card.php?id=".$objecttmp->id.
"\n\n";
1677 $trackid =
'leav'.$objecttmp->id;
1679 require_once DOL_DOCUMENT_ROOT.
'/core/class/CMailFile.class.php';
1680 $mail =
new CMailFile($subject, $emailTo, $emailFrom, $message, array(), array(), array(),
'',
'', 0, 0,
'',
'', $trackid);
1683 $result = $mail->sendfile();
1692 $langs->load(
"errors");
1693 setEventMessages($langs->trans(
'ErrorNotApproverForHoliday', $objecttmp->ref),
null,
'errors');
1705 } elseif ($nbok == 1) {
1714if (!$error && ($massaction ==
'increaseholiday' || ($action ==
'increaseholiday' && $confirm ==
'yes')) && $permissiontoapprove) {
1716 $objecttmp =
new $objectclass($db);
1718 $typeholiday =
GETPOST(
'typeholiday',
'alpha');
1721 if ($nbdaysholidays <= 0) {
1727 foreach ($toselect as $toselectid) {
1728 $balancecpuser = $objecttmp->getCPforUser($toselectid, $typeholiday);
1729 if (!empty($balancecpuser)) {
1730 $newnbdaysholidays = $nbdaysholidays + $balancecpuser;
1732 $newnbdaysholidays = $nbdaysholidays;
1734 $result = $holiday->addLogCP($user->id, $toselectid, $langs->transnoentitiesnoconv(
'ManualUpdate'), $newnbdaysholidays, $typeholiday);
1741 $objecttmp->updateSoldeCP($toselectid, $newnbdaysholidays, $typeholiday);
1754 setEventMessages($langs->trans(
"HolidayRecordsIncreased", $nbok),
null,
'mesgs');
1755 } elseif ($nbok == 1) {
1759 $toselect = array();
1766if (!$error && ($massaction ==
'clonetasks' || ($action ==
'clonetasks' && $confirm ==
'yes'))) {
1769 include_once DOL_DOCUMENT_ROOT.
'/projet/class/task.class.php';
1771 $origin_task =
new Task($db);
1772 $clone_task =
new Task($db);
1773 $newproject =
new Project($db);
1777 $iscontactofnewproject = 0;
1778 if (empty($newproject->public)) {
1779 $tmps = $newproject->getProjectsAuthorizedForUser($user, 0, 1, 0,
'(fk_statut:=:1)');
1780 $tmparray = explode(
',', $tmps);
1781 if (!in_array($newproject->id, $tmparray)) {
1782 $iscontactofnewproject = 1;
1787 $permisstiontoadd =
false;
1788 if ($user->hasRight(
'project',
'all',
'creer') || ($user->hasRight(
'project',
'creer') && ($newproject->public || $iscontactofnewproject))) {
1789 $permisstiontoadd =
true;
1792 if ($permisstiontoadd) {
1793 foreach (
GETPOST(
'selected') as $task) {
1794 $origin_task->fetch($task,
'', 0);
1799 require_once DOL_DOCUMENT_ROOT .
"/core/modules/project/task/" .
getDolGlobalString(
'PROJECT_TASK_ADDON') .
'.php';
1800 $modTask =
new $classnamemodtask();
1801 '@phan-var-force ModeleNumRefTask $modTask';
1802 $defaultref = $modTask->getNextValue(
null, $clone_task);
1806 $clone_task->fk_project =
GETPOSTINT(
'projectid');
1807 $clone_task->ref = $defaultref;
1808 $clone_task->label = $origin_task->label;
1809 $clone_task->description = $origin_task->description;
1810 $clone_task->planned_workload = $origin_task->planned_workload;
1811 $clone_task->fk_task_parent = $origin_task->fk_task_parent;
1812 $clone_task->date_c =
dol_now();
1813 $clone_task->date_start = $origin_task->date_start;
1814 $clone_task->date_end = $origin_task->date_end;
1815 $clone_task->progress = $origin_task->progress;
1818 $ret = $extrafields->setOptionalsFromPost(
null, $clone_task);
1820 $taskid = $clone_task->create($user);
1823 $result = $clone_task->add_contact(
GETPOSTINT(
"userid"),
'TASKEXECUTIVE',
'internal');
1826 if ($db->lasterrno() ==
'DB_ERROR_RECORD_ALREADY_EXISTS') {
1827 $langs->load(
"projects");
1829 $duplicate_code_error =
true;
1840 setEventMessages($langs->trans(
'NumberOfTasksCloned', $num),
null,
'mesgs');
1841 header(
"Location: ".DOL_URL_ROOT.
'/projet/tasks.php?id='.
GETPOSTINT(
'projectid'));
1849$parameters[
'toselect'] = (empty($toselect) ? array() : $toselect);
1850$parameters[
'uploaddir'] = $uploaddir;
1851$parameters[
'massaction'] = $massaction;
1852$parameters[
'diroutputmassaction'] = isset($diroutputmassaction) ? $diroutputmassaction :
null;
1854$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.