77@phan-var-force int $error
78@phan-var-force ?string $permissiontoadd
79@phan-var-force ?string $permissiontoread
80@phan-var-force ?string $permissiontodelete
81@phan-var-force ?string $permissiontoclose
82@phan-var-force ?string $permissiontoapprove
83@phan-var-force ?int[] $toselect
84@phan-var-force ?string $diroutputmassaction
85@phan-var-force ?string $objectlabel
86@phan-var-force ?string $option
87@phan-var-force int $deliveryreceipt
88@phan-var-force string $month
89@phan-var-force string $year
90@phan-var-force ?array<string,mixed> $moreparams
91@phan-var-force ?string $search_status
92@phan-var-force ?int $hidedetails
93@phan-var-force ?int $hidedesc
94@phan-var-force ?int $hideref
95@phan-var-force string $confirm
100if (empty($objectclass) || empty($uploaddir)) {
101 dol_print_error(
null,
'include of actions_massactions.inc.php is done but var $objectclass or $uploaddir was not defined');
104if (empty($massaction)) {
110@phan-var-force "CommonObject"|"CommandeFournisseur"|"ConferenceOrBoothAttendee"|"Contrat"|"Contact"|"Expedition"|"ExpenseReport"|"Facture"|"FactureFournisseur"|"Fichinter"|"Holiday"|"Partnership"|"Project"|"Propal"|"Societe"|"SupplierProposal" $objectclass
111@phan-var-force string $massaction
112@phan-var-force string $uploaddir
119if (!empty($permtoread) && empty($permissiontoread)) {
120 $permissiontoread = $permtoread;
122if (!empty($permtocreate) && empty($permissiontoadd)) {
123 $permissiontoadd = $permtocreate;
125if (!empty($permtodelete) && empty($permissiontodelete)) {
126 $permissiontodelete = $permtodelete;
130$maxformassaction =
getDolGlobalInt(
'MAIN_LIMIT_FOR_MASS_ACTIONS', 1000);
131if ($massaction && is_array($toselect) && count($toselect) < 1) {
135if (!$error && isset($toselect) && is_array($toselect) && count($toselect) > $maxformassaction) {
136 setEventMessages($langs->trans(
'TooManyRecordForMassAction', $maxformassaction),
null,
'errors');
140if (!$error && $massaction ==
'confirm_presend' && !
GETPOST(
'sendmail')) {
141 $massaction =
'presend';
144if (!$error && $massaction ==
'confirm_presend') {
148 $langs->load(
"mails");
149 include_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
150 include_once DOL_DOCUMENT_ROOT.
'/core/lib/signature.lib.php';
152 $listofobjectid = array();
153 $listofobjectthirdparties = array();
154 $listofobjectcontacts = array();
155 $listofobjectref = array();
156 $contactidtosend = array();
157 $attachedfilesThirdpartyObj = array();
158 $oneemailperrecipient = (
GETPOSTINT(
'oneemailperrecipient') ? 1 : 0);
162 $objecttmp =
new $objectclass(
$db);
166 if ($objecttmp->element ==
'expensereport') {
168 } elseif ($objecttmp->element ==
'contact') {
170 } elseif ($objecttmp->element ==
'partnership' &&
getDolGlobalString(
'PARTNERSHIP_IS_MANAGED_FOR') ==
'member') {
172 } elseif ($objecttmp->element ==
'holiday') {
174 } elseif ($objecttmp->element ==
'conferenceorboothattendee') {
178 foreach ($toselect as $toselectid) {
179 $objecttmp =
new $objectclass(
$db);
180 '@phan-var-force CommonObject $objecttmp';
182 $result = $objecttmp->fetch($toselectid);
184 $listofobjectid[$toselectid] = $toselectid;
187 $tmpobjectid = ($objecttmp->fk_soc ? $objecttmp->fk_soc : $objecttmp->socid);
188 if ($objecttmp->element ==
'societe') {
189 '@phan-var-force Societe $objecttmp';
191 $tmpobjectid = $objecttmp->id;
192 } elseif ($objecttmp->element ==
'contact') {
193 '@phan-var-force Contact $objecttmp';
195 $tmpobjectid = $objecttmp->id;
196 } elseif ($objecttmp->element ==
'expensereport') {
197 '@phan-var-force ExpenseReport $objecttmp';
199 $tmpobjectid = $objecttmp->fk_user_author;
200 } elseif ($objecttmp->element ==
'partnership' &&
getDolGlobalString(
'PARTNERSHIP_IS_MANAGED_FOR') ==
'member') {
201 '@phan-var-force Partnership $objecttmp';
203 $tmpobjectid = $objecttmp->fk_member;
204 } elseif ($objecttmp->element ==
'holiday') {
205 '@phan-var-force Holiday $objecttmp';
207 $tmpobjectid = $objecttmp->fk_user;
208 } elseif ($objecttmp->element ==
'conferenceorboothattendee') {
209 '@phan-var-force ConferenceOrBoothAttendee $objecttmp';
211 $tmpobjectid = $objecttmp->id;
213 if (empty($tmpobjectid)) {
217 if ($objectclass ==
'Facture') {
218 '@phan-var-force Facture $objecttmp';
220 $tmparraycontact = array();
221 $tmparraycontact = $objecttmp->liste_contact(-1,
'external', 0,
'BILLING');
222 if (is_array($tmparraycontact) && count($tmparraycontact) > 0) {
223 foreach ($tmparraycontact as $data_email) {
224 $listofobjectcontacts[$toselectid][$data_email[
'id']] = $data_email[
'email'];
227 } elseif ($objectclass ==
'CommandeFournisseur') {
228 '@phan-var-force CommandeFournisseur $objecttmp';
230 $tmparraycontact = array();
231 $tmparraycontact = $objecttmp->liste_contact(-1,
'external', 0,
'CUSTOMER');
232 if (is_array($tmparraycontact) && count($tmparraycontact) > 0) {
233 foreach ($tmparraycontact as $data_email) {
234 $listofobjectcontacts[$toselectid][$data_email[
'id']] = $data_email[
'email'];
239 $listofobjectthirdparties[$tmpobjectid] = $tmpobjectid;
240 $listofobjectref[$tmpobjectid][$toselectid] = $objecttmp;
246 if (
GETPOST(
'fromtype',
'alpha') ===
'user' && empty($user->email)) {
249 $massaction =
'presend';
252 $receiver =
GETPOST(
'receiver',
'alphawithlgt');
253 if (!is_array($receiver)) {
254 if (empty($receiver) || $receiver ==
'-1') {
257 $receiver = array($receiver);
260 if (!trim(
GETPOST(
'sendto',
'alphawithlgt')) && count($receiver) == 0 && count($listofobjectthirdparties) == 1) {
262 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"MailRecipient")),
null,
'warnings');
263 $massaction =
'presend';
266 if (!
GETPOST(
'subject',
'restricthtml')) {
268 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"MailTopic")),
null,
'warnings');
269 $massaction =
'presend';
274 foreach ($listofobjectthirdparties as $thirdpartyid) {
275 $result = $thirdparty->fetch($thirdpartyid);
288 if (trim(
GETPOST(
'sendto',
'alphawithlgt'))) {
290 $tmparray[] = trim(
GETPOST(
'sendto',
'alphawithlgt'));
292 if (count($receiver) > 0 && is_object($thirdparty)) {
293 foreach ($receiver as $key => $val) {
295 if ($val ==
'thirdparty') {
296 $tmparray[] = $thirdparty->name.
' <'.$thirdparty->email.
'>';
297 } elseif ($val && method_exists($thirdparty,
'contact_get_property')) {
298 $tmparray[] = $thirdparty->contact_get_property((
int) $val,
'email');
303 $sendto = implode(
',', $tmparray);
306 $receivercc =
GETPOST(
'receivercc',
'alphawithlgt');
307 if (!is_array($receivercc)) {
308 if ($receivercc ==
'-1') {
309 $receivercc = array();
311 $receivercc = array($receivercc);
315 if (trim(
GETPOST(
'sendtocc',
'alphawithlgt'))) {
316 $tmparray[] = trim(
GETPOST(
'sendtocc',
'alphawithlgt'));
318 if (count($receivercc) > 0) {
319 foreach ($receivercc as $key => $val) {
321 if ($val ==
'thirdparty') {
322 $tmparray[] = $thirdparty->name.
' <'.$thirdparty->email.
'>';
324 $tmparray[] = $thirdparty->contact_get_property((
int) $val,
'email');
329 $sendtocc = implode(
',', $tmparray);
332 $listofqualifiedobj = array();
333 $listofqualifiedref = array();
334 $thirdpartywithoutemail = array();
336 foreach ($listofobjectref[$thirdpartyid] as $objectid => $objectobj) {
343 $langs->load(
"errors");
345 $resaction .=
'<div class="error">'.$langs->trans(
'ErrorOnlyProposalNotDraftCanBeSentInMassAction', $objectobj->ref).
'</div><br>';
349 $langs->load(
"errors");
351 $resaction .=
'<div class="error">'.$langs->trans(
'ErrorOnlyOrderNotDraftCanBeSentInMassAction', $objectobj->ref).
'</div><br>';
355 $langs->load(
"errors");
357 $resaction .=
'<div class="error">'.$langs->trans(
'ErrorOnlyInvoiceValidatedCanBeSentInMassAction', $objectobj->ref).
'</div><br>';
362 if (empty($sendto)) {
363 if ($objectobj->element ==
'societe') {
364 $sendto = $objectobj->email;
365 } elseif ($objectobj->element ==
'expensereport') {
367 $fuser->fetch($objectobj->fk_user_author);
368 $sendto = $fuser->email;
369 } elseif ($objectobj->element ==
'contact') {
371 $fcontact->fetch($objectobj->id);
372 $sendto = $fcontact->email;
373 } elseif ($objectobj->element ==
'partnership' &&
getDolGlobalString(
'PARTNERSHIP_IS_MANAGED_FOR') ==
'member') {
375 $fadherent->fetch($objectobj->fk_member);
376 $sendto = $fadherent->email;
377 } elseif ($objectobj->element ==
'holiday') {
379 $fuser->fetch($objectobj->fk_user);
380 $sendto = $fuser->email;
381 } elseif ($objectobj->element ==
'facture' && !empty($listofobjectcontacts[$objectid])) {
382 $emails_to_sends = array();
383 $objectobj->fetch_thirdparty();
384 $contactidtosend = array();
385 foreach ($listofobjectcontacts[$objectid] as $contactemailid => $contactemailemail) {
386 $emails_to_sends[] = $objectobj->thirdparty->contact_get_property($contactemailid,
'email');
387 if (!in_array($contactemailid, $contactidtosend)) {
388 $contactidtosend[] = $contactemailid;
391 if (count($emails_to_sends) > 0) {
392 $sendto = implode(
',', $emails_to_sends);
394 } elseif ($objectobj->element ==
'order_supplier' && !empty($listofobjectcontacts[$objectid])) {
395 $emails_to_sends = array();
396 $objectobj->fetch_thirdparty();
397 $contactidtosend = array();
398 foreach ($listofobjectcontacts[$objectid] as $contactemailid => $contactemailemail) {
399 $emails_to_sends[] = $objectobj->thirdparty->contact_get_property($contactemailid,
'email');
400 if (!in_array($contactemailid, $contactidtosend)) {
401 $contactidtosend[] = $contactemailid;
404 if (count($emails_to_sends) > 0) {
405 $sendto = implode(
',', $emails_to_sends);
407 } elseif ($objectobj->element ==
'conferenceorboothattendee') {
408 $sendto = $objectobj->email;
410 $objectobj->fetch_thirdparty();
411 $sendto = $objectobj->thirdparty->email;
415 if (empty($sendto)) {
416 if ($objectobj->element ==
'societe') {
418 $objectobj->thirdparty = $objectobj;
423 if (empty($thirdpartywithoutemail[$objectobj->thirdparty->id])) {
424 $resaction .=
'<div class="error">'.$langs->trans(
'NoRecipientEmail', $objectobj->thirdparty->name).
'</div><br>';
426 dol_syslog(
'No recipient for thirdparty: '.$objectobj->thirdparty->name, LOG_WARNING);
427 $thirdpartywithoutemail[$objectobj->thirdparty->id] = 1;
431 if (
GETPOST(
'addmaindocfile')) {
438 $filedir = $uploaddir.
'/'.$subdir.dol_sanitizeFileName($objectobj->ref);
439 $filepath = $filedir.
'/'.$filename;
442 if ($objectobj->element ==
'invoice_supplier') {
443 $fileparams =
dol_most_recent_file($uploaddir.
'/'.
get_exdir($objectobj->id, 2, 0, 0, $objectobj, $objectobj->element).$objectobj->ref, preg_quote($objectobj->ref,
'/').
'([^\-])+');
444 $filepath = $fileparams[
'fullname'];
447 if (
getDolGlobalInt(
'MAIL_MASS_ACTION_SEARCH_MOST_RECENT_FILE_IF_NOT_FOUND') && isset($filepath) && !
dol_is_file($filepath)) {
449 if (isset($fileparams)) {
450 $filepath = $fileparams[
'fullname'];
451 $filename = $fileparams[
'name'];
456 $filename_found =
'';
457 $filepath_found =
'';
458 $file_check_list = array();
459 $file_check_list[] = array(
463 if (
getDolGlobalString(
'MAIL_MASS_ACTION_ADD_LAST_IF_MAIN_DOC_NOT_FOUND') && !empty($objectobj->last_main_doc)) {
464 $file_check_list[] = array(
465 'name' => basename($objectobj->last_main_doc),
466 'path' => DOL_DATA_ROOT .
'/' . $objectobj->last_main_doc,
469 foreach ($file_check_list as $file_check_arr) {
471 $filename_found = $file_check_arr[
'name'];
472 $filepath_found = $file_check_arr[
'path'];
477 if ($filepath_found) {
479 $attachedfilesThirdpartyObj[$thirdpartyid][$objectid] = array(
480 'paths' => array($filepath_found),
481 'names' => array($filename_found),
486 $langs->load(
"errors");
487 foreach ($file_check_list as $file_check_arr) {
488 $resaction .=
'<div class="error">'.$langs->trans(
'ErrorCantReadFile', $file_check_arr[
'path']).
'</div><br>';
489 dol_syslog(
'Failed to read file: '.$file_check_arr[
'path'], LOG_WARNING);
496 $listofqualifiedobj[$objectid] = $objectobj;
497 $listofqualifiedref[$objectid] = $objectobj->ref;
504 if (count($listofqualifiedobj) > 0) {
505 $langs->load(
"commercial");
509 $fromtype =
GETPOST(
'fromtype');
510 if ($fromtype ===
'user') {
511 $email_from =
dol_string_nospecial($user->getFullName($langs),
' ', array(
",")).
' <'.$user->email.
'>';
512 } elseif ($fromtype ===
'company') {
514 } elseif (preg_match(
'/global_aliases_(\d+)/', $fromtype, $reg)) {
516 $email_from = trim($tmp[((
int) $reg[1] - 1)]);
517 } elseif (preg_match(
'/senderprofile_(\d+)_(\d+)/', $fromtype, $reg)) {
518 $sql =
"SELECT rowid, label, email FROM ".MAIN_DB_PREFIX.
"c_email_senderprofile WHERE rowid = ".(int) $reg[1];
519 $resql =
$db->query($sql);
520 $obj =
$db->fetch_object($resql);
524 } elseif (preg_match(
'/from_template_(\d+)/', $fromtype, $reg)) {
525 $sql =
"SELECT rowid, email_from FROM ".MAIN_DB_PREFIX.
"c_email_templates WHERE rowid = ".(int) $reg[1];
526 $resql =
$db->query($sql);
527 $obj =
$db->fetch_object($resql);
529 $email_from = $obj->email_from;
535 $replyto = $email_from;
536 $subject =
GETPOST(
'subject',
'restricthtml');
537 $message =
GETPOST(
'message',
'restricthtml');
539 $sendtobcc =
GETPOST(
'sendtoccc');
540 if ($objectclass ==
'Propal') {
543 if ($objectclass ==
'Commande') {
546 if ($objectclass ==
'Facture') {
549 if ($objectclass ==
'SupplierProposal') {
550 $sendtobcc .= (!
getDolGlobalString(
'MAIN_MAIL_AUTOCOPY_SUPPLIER_PROPOSAL_TO') ?
'' : (($sendtobcc ?
", " :
"") .
getDolGlobalString(
'MAIN_MAIL_AUTOCOPY_SUPPLIER_PROPOSAL_TO')));
552 if ($objectclass ==
'CommandeFournisseur') {
555 if ($objectclass ==
'FactureFournisseur') {
558 if ($objectclass ==
'Project') {
564 $looparray = array();
565 if (!$oneemailperrecipient) {
566 $looparray = $listofqualifiedobj;
567 foreach ($looparray as $key => $objecttmp) {
568 $looparray[$key]->thirdparty = $thirdparty;
571 $objectforloop =
new $objectclass(
$db);
572 $objectforloop->thirdparty = $thirdparty;
573 $looparray[0] = $objectforloop;
576 dol_syslog(
"We have set an array of ".count($looparray).
" emails to send. oneemailperrecipient=".$oneemailperrecipient);
578 foreach ($looparray as $objectid => $objecttmp) {
580 if (
isModEnabled(
'project') && method_exists($objecttmp,
'fetchProject') && is_null($objecttmp->project)) {
581 $objecttmp->fetchProject();
583 $substitutionarray = getCommonSubstitutionArray($langs, 0,
null, $objecttmp);
584 $substitutionarray[
'__ID__'] = ($oneemailperrecipient ? implode(
', ', array_keys($listofqualifiedobj)) : $objecttmp->id);
585 $substitutionarray[
'__REF__'] = ($oneemailperrecipient ? implode(
', ', $listofqualifiedref) : $objecttmp->
ref);
586 $substitutionarray[
'__EMAIL__'] = $thirdparty->email;
587 $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"/>';
589 if ($oneemailperrecipient) {
590 $substitutionarray[
'__ONLINE_PAYMENT_URL__'] =
'';
591 $substitutionarray[
'__ONLINE_PAYMENT_TEXT_AND_URL__'] =
'';
594 $parameters = array(
'mode' =>
'formemail');
596 if (!empty($listofobjectthirdparties)) {
597 $parameters[
'listofobjectthirdparties'] = $listofobjectthirdparties;
599 if (!empty($listofobjectref)) {
600 $parameters[
'listofobjectref'] = $listofobjectref;
608 $attachedfiles = array(
'paths' => array(),
'names' => array(),
'mimes' => array());
609 if ($oneemailperrecipient) {
611 if (is_array($attachedfilesThirdpartyObj[$thirdparty->id]) && count($attachedfilesThirdpartyObj[$thirdparty->id])) {
612 foreach ($attachedfilesThirdpartyObj[$thirdparty->id] as $keyObjId => $objAttachedFiles) {
614 $attachedfiles = array(
615 'paths' => array_merge($attachedfiles[
'paths'], $objAttachedFiles[
'paths']),
616 'names' => array_merge($attachedfiles[
'names'], $objAttachedFiles[
'names']),
617 'mimes' => array_merge($attachedfiles[
'mimes'], $objAttachedFiles[
'mimes'])
621 } elseif (!empty($attachedfilesThirdpartyObj[$thirdparty->id][$objectid])) {
624 $attachedfiles = $attachedfilesThirdpartyObj[$thirdparty->id][$objectid];
627 $filepath = $attachedfiles[
'paths'];
628 $filename = $attachedfiles[
'names'];
629 $mimetype = $attachedfiles[
'mimes'];
632 if ($oneemailperrecipient) {
633 $trackid =
'thi'.$thirdparty->id;
634 if ($objecttmp->element ==
'expensereport') {
635 $trackid =
'use'.$thirdparty->id;
636 } elseif ($objecttmp->element ==
'contact') {
637 $trackid =
'ctc'.$thirdparty->id;
638 } elseif ($objecttmp->element ==
'holiday') {
639 $trackid =
'use'.$thirdparty->id;
642 $trackid = strtolower(get_class($objecttmp));
643 if (get_class($objecttmp) ==
'Contact') {
645 } elseif (get_class($objecttmp) ==
'Contrat') {
647 } elseif (get_class($objecttmp) ==
'Propal') {
649 } elseif (get_class($objecttmp) ==
'Commande') {
651 } elseif (get_class($objecttmp) ==
'Facture') {
653 } elseif (get_class($objecttmp) ==
'SupplierProposal') {
655 } elseif (get_class($objecttmp) ==
'CommandeFournisseur') {
657 } elseif (get_class($objecttmp) ==
'FactureFournisseur') {
661 $trackid .= $objecttmp->id;
667 if (empty($sendcontext)) {
668 $sendcontext =
'standard';
672 $vardir =
$conf->user->dir_output.
"/".$user->id;
673 $upload_dir_tmp = $vardir.
'/temp';
676 require_once DOL_DOCUMENT_ROOT.
'/core/class/CMailFile.class.php';
677 $mailfile =
new CMailFile($subjectreplaced, (
string) $sendto, $email_from, $messagereplaced, $filepath, $mimetype, $filename, $sendtocc, $sendtobcc, (
int) $deliveryreceipt, -1,
'',
'', $trackid,
'', $sendcontext,
'', $upload_dir_tmp);
678 if ($mailfile->error) {
679 $resaction .=
'<div class="error">'.$mailfile->error.
'</div>';
681 $result = $mailfile->sendfile();
683 $resaction .= $langs->trans(
'MailSuccessfulySent', $mailfile->getValidAddress($mailfile->addr_from, 2), $mailfile->getValidAddress($mailfile->addr_to, 2)).
'<br>';
688 foreach ($listofqualifiedobj as $objid2 => $objectobj2) {
689 if ((!$oneemailperrecipient) && $objid2 != $objectid) {
693 dol_syslog(
"Try to insert email event into agenda for objid=".$objid2.
" => objectobj=".get_class($objectobj2));
702 $actionmsg = $langs->transnoentities(
'MailSentByTo', $email_from, (
string) $sendto);
705 $actionmsg =
dol_concatdesc($actionmsg, $langs->transnoentities(
'Bcc').
": ".$sendtocc);
707 $actionmsg =
dol_concatdesc($actionmsg, $langs->transnoentities(
'MailTopic').
": ".$subjectreplaced);
708 $actionmsg =
dol_concatdesc($actionmsg, $langs->transnoentities(
'TextUsedInTheMessageBody').
":");
714 $objectobj2->sendtoid = (empty($contactidtosend) ? 0 : $contactidtosend);
715 $objectobj2->actionmsg = $actionmsg;
716 $objectobj2->actionmsg2 = $actionmsg2;
717 $objectobj2->fk_element = $objid2;
718 $objectobj2->elementtype = $objectobj2->element;
720 $objectobj2->actionmsg2 = $subjectreplaced;
723 $triggername = strtoupper(get_class($objectobj2)).
'_SENTBYMAIL';
724 if ($triggername ==
'SOCIETE_SENTBYMAIL') {
725 $triggername =
'COMPANY_SENTBYMAIL';
727 if ($triggername ==
'CONTRAT_SENTBYMAIL') {
728 $triggername =
'CONTRACT_SENTBYMAIL';
730 if ($triggername ==
'COMMANDE_SENTBYMAIL') {
731 $triggername =
'ORDER_SENTBYMAIL';
733 if ($triggername ==
'FACTURE_SENTBYMAIL') {
734 $triggername =
'BILL_SENTBYMAIL';
736 if ($triggername ==
'EXPEDITION_SENTBYMAIL') {
737 $triggername =
'SHIPPING_SENTBYMAIL';
739 if ($triggername ==
'COMMANDEFOURNISSEUR_SENTBYMAIL') {
740 $triggername =
'ORDER_SUPPLIER_SENTBYMAIL';
742 if ($triggername ==
'FACTUREFOURNISSEUR_SENTBYMAIL') {
743 $triggername =
'BILL_SUPPLIER_SENTBYMAIL';
745 if ($triggername ==
'SUPPLIERPROPOSAL_SENTBYMAIL') {
746 $triggername =
'PROPOSAL_SUPPLIER_SENTBYMAIL';
748 if ($triggername ==
'PROJET_SENTBYMAIL') {
749 $triggername =
'PROJECT_SENTBYMAIL';
752 if (!empty($triggername)) {
754 $result = $objectobj2->call_trigger($triggername, $user);
762 dol_syslog(
"Error in trigger ".$triggername.
' '.
$db->lasterror(), LOG_ERR);
769 $langs->load(
"other");
770 if ($mailfile->error) {
771 $resaction .= $langs->trans(
'ErrorFailedToSendMail', $email_from, (
string) $sendto);
772 $resaction .=
'<br><div class="error">'.$mailfile->error.
'</div>';
774 $resaction .=
'<div class="warning">No mail sent. Feature is disabled by option MAIN_DISABLE_ALL_MAILS</div>';
776 $resaction .= $langs->trans(
'ErrorFailedToSendMail', $email_from, (
string) $sendto) .
'<br><div class="error">(unhandled error)</div>';
784 $resaction .= ($resaction ?
'<br>' : $resaction);
785 $resaction .=
'<strong>'.$langs->trans(
"ResultOfMailSending").
':</strong><br>'.
"\n";
786 $resaction .= $langs->trans(
"NbSelected").
': '.count($toselect).
"\n<br>";
787 $resaction .= $langs->trans(
"NbIgnored").
': '.($nbignored ? $nbignored : 0).
"\n<br>";
788 $resaction .= $langs->trans(
"NbSent").
': '.($nbsent ? $nbsent : 0).
"\n<br>";
793 setEventMessages($langs->trans(
"EMailSentForNElements", $nbsent.
'/'.count($toselect)),
null,
'mesgs');
806if (!$error && $massaction ==
'cancelorders') {
811 $orders =
GETPOST(
'toselect',
'array:int');
812 foreach ($orders as $id_order) {
814 if ($cmd->fetch($id_order) <= 0) {
819 $langs->load(
'errors');
820 setEventMessages($langs->trans(
"ErrorObjectMustHaveStatusValidToBeCanceled", $cmd->ref),
null,
'errors');
825 $result = $cmd->cancel($user);
845if (!$error && $massaction ==
"builddoc" && $permissiontoread && !
GETPOST(
'button_search')) {
846 if (empty($diroutputmassaction)) {
847 dol_print_error(
null,
'include of actions_massactions.inc.php is done but var $diroutputmassaction was not defined');
851 require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
852 require_once DOL_DOCUMENT_ROOT.
'/core/lib/pdf.lib.php';
853 require_once DOL_DOCUMENT_ROOT.
'/core/lib/date.lib.php';
855 $objecttmp =
new $objectclass(
$db);
856 $listofobjectid = array();
857 $listofobjectthirdparties = array();
858 $listofobjectref = array();
859 foreach ($toselect as $toselectid) {
860 $objecttmp =
new $objectclass(
$db);
861 $result = $objecttmp->fetch($toselectid);
863 $listofobjectid[$toselectid] = $toselectid;
864 $thirdpartyid = !empty($objecttmp->fk_soc) ? $objecttmp->fk_soc : $objecttmp->socid;
865 $listofobjectthirdparties[$thirdpartyid] = $thirdpartyid;
866 $listofobjectref[$toselectid] = $objecttmp->ref;
870 $arrayofinclusion = array();
872 'listofobjectref' => $listofobjectref,
873 'arrayofinclusion' => &$arrayofinclusion,
875 $reshook = $hookmanager->executeHooks(
'updateSearchRegexToMergeDoc', $parameters,
$object, $action);
877 if (empty($reshook)) {
878 foreach ($listofobjectref as $tmppdf) {
881 foreach ($listofobjectref as $tmppdf) {
882 $arrayofinclusion[] =
'^'.preg_quote(
dol_sanitizeFileName($tmppdf),
'/').
'_[\w\-\'\&\.]+\.pdf$';
886 $listoffiles =
dol_dir_list($uploaddir,
'all', 1, $arrayofinclusion,
'\.meta$|\.png$',
'date', SORT_DESC, 0, 1);
888 dol_syslog(
"Found ".count($listoffiles).
" files");
893 foreach ($listofobjectref as $basename) {
895 foreach ($listoffiles as $filefound) {
896 if (strstr($filefound[
"name"], $basename)) {
897 $files[] = $filefound[
'fullname'];
904 $outputlangs = $langs;
907 $newlang =
GETPOST(
'lang_id',
'aZ09');
912 if (!empty($newlang)) {
914 $outputlangs->setDefaultLang($newlang);
923 $filename = preg_replace(
'/\s/',
'_', $filename);
926 if (in_array($objecttmp->element, array(
'facture',
'invoice_supplier')) && $search_status ==
Facture::STATUS_VALIDATED) {
927 if ($option ==
'late') {
934 $filename .=
'_'.$year;
937 $filename .=
'_'.$month;
940 if (count($files) > 0) {
942 $file = $diroutputmassaction.
'/'.$filename.
'_'.
dol_print_date($now,
'dayhourlog').
'.pdf';
945 foreach ($files as $f) {
946 $input_files .=
' '.escapeshellarg($f);
949 $cmd =
'pdftk '.$input_files.
' cat output '.escapeshellarg($file);
953 if (file_exists($file)) {
956 $langs->load(
"exports");
959 setEventMessages($langs->trans(
'ErrorPDFTkOutputFileNotFound'),
null,
'errors');
962 setEventMessages($langs->trans(
'NoPDFAvailableForDocGenAmongChecked'),
null,
'errors');
967 $page_largeur = $formatarray[
'width'];
968 $page_hauteur = $formatarray[
'height'];
969 $format = array($page_largeur, $page_hauteur);
973 if (class_exists(
'TCPDF')) {
974 $pdf->setPrintHeader(
false);
975 $pdf->setPrintFooter(
false);
980 $pdf->SetCompression(
false);
985 foreach ($files as $file) {
987 $pagecount = $pdf->setSourceFile($file);
988 for ($i = 1; $i <= $pagecount; $i++) {
989 $tplidx = $pdf->importPage($i);
990 $s = $pdf->getTemplatesize($tplidx);
991 $pdf->AddPage($s[
'h'] > $s[
'w'] ?
'P' :
'L');
992 $pdf->useTemplate($tplidx);
1001 $filename = preg_replace(
'/\s/',
'_', $filename);
1005 if (in_array($objecttmp->element, array(
'facture',
'invoice_supplier')) && $search_status ==
Facture::STATUS_VALIDATED) {
1006 if ($option ==
'late') {
1012 if (!empty($year)) {
1013 $filename .=
'_'.$year;
1015 if (!empty($month)) {
1016 $filename .=
'_'.$month;
1020 $file = $diroutputmassaction.
'/'.$filename.
'_'.
dol_print_date($now,
'dayhourlog').
'.pdf';
1021 $pdf->Output($file,
'F');
1024 $langs->load(
"exports");
1027 setEventMessages($langs->trans(
'NoPDFAvailableForDocGenAmongChecked'),
null,
'errors');
1033if ($action ==
'remove_file') {
1034 require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
1036 $langs->load(
"other");
1037 $upload_dir = $diroutputmassaction;
1038 $file = $upload_dir.
'/'.
GETPOST(
'file');
1050if (!$error && $massaction ==
'validate' && $permissiontoadd) {
1051 $objecttmp =
new $objectclass(
$db);
1053 if (($objecttmp->element ==
'facture' || $objecttmp->element ==
'invoice') &&
isModEnabled(
'stock') &&
getDolGlobalString(
'STOCK_CALCULATE_ON_BILL')) {
1054 $langs->load(
"errors");
1055 setEventMessages($langs->trans(
'ErrorMassValidationNotAllowedWhenStockIncreaseOnAction'),
null,
'errors');
1059 $langs->load(
"errors");
1060 setEventMessages($langs->trans(
'ErrorMassValidationNotAllowedWhenStockIncreaseOnAction'),
null,
'errors');
1063 if ($objecttmp->element ==
'facture') {
1066 $sql =
"SELECT rowid FROM ".MAIN_DB_PREFIX.
"facture";
1067 $sql .=
" WHERE rowid IN (".$db->sanitize(implode(
",", $toselect)).
")";
1068 $sql .=
" ORDER BY datef";
1070 $resql =
$db->query($sql);
1073 while (!empty($arr =
$db->fetch_row($resql))) {
1074 $toselectnew[] = $arr[0];
1076 $toselect = (empty($toselectnew)) ? $toselect : $toselectnew;
1090 $perrecordtransaction = (int)
getDolGlobalInt(
'MAIN_MASSVALIDATE_'.strtoupper($objectclass).
'_NO_GLOBAL_TRANSACTION');
1091 if (!$perrecordtransaction) {
1096 foreach ($toselect as $toselectid) {
1097 if ($perrecordtransaction) {
1100 $result = $objecttmp->fetch($toselectid);
1102 if (method_exists($objecttmp,
'validate')) {
1103 $result = $objecttmp->validate($user);
1104 } elseif (method_exists($objecttmp,
'setValid')) {
1105 $result = $objecttmp->setValid($user);
1107 $objecttmp->error =
'No method validate or setValid on this object';
1111 $langs->load(
"errors");
1112 setEventMessages($langs->trans(
"ErrorObjectMustHaveStatusDraftToBeValidated", $objecttmp->ref),
null,
'errors');
1114 if ($perrecordtransaction) {
1118 } elseif ($result < 0) {
1121 if ($perrecordtransaction) {
1129 $outputlangs = $langs;
1132 $newlang =
GETPOST(
'lang_id',
'aZ09');
1134 if (
getDolGlobalInt(
'MAIN_MULTILANGS') && empty($newlang) && property_exists($objecttmp,
'thirdparty')) {
1135 if ((property_exists($objecttmp,
'socid') || property_exists($objecttmp,
'fk_soc')) && empty($objecttmp->thirdparty)) {
1136 $objecttmp->fetch_thirdparty();
1138 if (!empty($objecttmp->thirdparty)) {
1139 $newlang = $objecttmp->thirdparty->default_lang;
1142 if (!empty($newlang)) {
1144 $outputlangs->setDefaultLang($newlang);
1145 $outputlangs->load(
'products');
1147 $model = $objecttmp->model_pdf;
1148 $ret = $objecttmp->fetch($objecttmp->id);
1151 $hidedetails = isset($hidedetails) ? $hidedetails : (
getDolGlobalString(
'MAIN_GENERATE_DOCUMENTS_HIDE_DETAILS') ? 1 : 0);
1152 $hidedesc = isset($hidedesc) ? $hidedesc : (
getDolGlobalString(
'MAIN_GENERATE_DOCUMENTS_HIDE_DESC') ? 1 : 0);
1153 $hideref = isset($hideref) ? $hideref : (
getDolGlobalString(
'MAIN_GENERATE_DOCUMENTS_HIDE_REF') ? 1 : 0);
1154 $moreparams = isset($moreparams) ? $moreparams :
null;
1156 $result = $objecttmp->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref, $moreparams);
1162 if ($perrecordtransaction) {
1169 if ($perrecordtransaction) {
1180 setEventMessages($langs->trans(
"RecordModifiedSuccessfully"),
null,
'mesgs');
1182 if (!$perrecordtransaction) {
1185 } elseif (!$perrecordtransaction) {
1192if (!$error && ($massaction ==
'delete' || ($action ==
'delete' && $confirm ==
'yes')) && $permissiontodelete) {
1195 $objecttmp =
new $objectclass(
$db);
1202 $unique_arr = array_unique($toselect);
1203 foreach ($unique_arr as $toselectid) {
1204 $result = $objecttmp->fetch($toselectid);
1208 $langs->load(
"errors");
1210 $TMsg[] =
'<div class="error">'.$langs->trans(
'ErrorOnlyDraftStatusCanBeDeletedInMassAction', $objecttmp->ref).
'</div><br>';
1214 if (method_exists($objecttmp,
'is_erasable') && $objecttmp->is_erasable() <= 0) {
1215 $langs->load(
"errors");
1217 $TMsg[] =
'<div class="error">'.$langs->trans(
'ErrorRecordHasChildren').
' '.$objecttmp->ref.
'</div><br>';
1222 $langs->load(
"errors");
1224 $TMsg[] =
'<div class="error">'.$langs->trans(
'ErrorLeaveRequestMustBeDraftCanceledOrRefusedToBeDeleted', $objecttmp->ref).
'</div><br>';
1228 if ($objectclass ==
"Task" && $objecttmp->hasChildren() > 0) {
1229 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"projet_task SET fk_task_parent = 0 WHERE fk_task_parent = ".((int) $objecttmp->id);
1230 $res =
$db->query($sql);
1238 if ($objecttmp->element ==
'societe') {
1240 '@phan-var-force Societe $objecttmp';
1242 $result = $objecttmp->delete($objecttmp->id, $user, 1);
1244 $objecttmp->oldcopy =
dol_clone($objecttmp);
1245 $result = $objecttmp->delete($user);
1248 if (empty($result)) {
1249 $TMsg = array_merge($objecttmp->errors, $TMsg);
1250 } elseif ($result < 0) {
1264 if (empty($error)) {
1268 } elseif ($nbok > 0) {
1275 if (!empty($TMsg)) {
1288if (!$error && $massaction ==
'generate_doc' && $permissiontoread) {
1291@phan-var-force
'Commande'|
'CommandeFournisseur'|
'Contrat'|
'Expedition'|
'ExpenseReport'|
'Facture'|
'FactureFournisseur'|
'Fichinter'|
'Project'|
'Propal'|
'SupplierProposal' $objectclass
1297 $objecttmp =
new $objectclass(
$db);
1299 foreach ($toselect as $toselectid) {
1300 $objecttmp->thirdparty =
null;
1301 $result = $objecttmp->fetch($toselectid);
1304 $outputlangs = $langs;
1308 $newlang =
GETPOST(
'lang_id',
'aZ09');
1310 if (
getDolGlobalInt(
'MAIN_MULTILANGS') && empty($newlang) && isset($objecttmp->thirdparty->default_lang)) {
1311 $newlang = $objecttmp->thirdparty->default_lang;
1313 if (
getDolGlobalInt(
'MAIN_MULTILANGS') && empty($newlang) && isset($objecttmp->default_lang)) {
1314 $newlang = $objecttmp->default_lang;
1316 if (
getDolGlobalInt(
'MAIN_MULTILANGS') && empty($newlang) && empty($objecttmp->thirdparty)) {
1317 $objecttmp->fetch_thirdparty();
1318 $newlang = $objecttmp->thirdparty->default_lang;
1320 if (!empty($newlang)) {
1322 $outputlangs->setDefaultLang($newlang);
1326 $hidedetails = isset($hidedetails) ? $hidedetails : (
getDolGlobalString(
'MAIN_GENERATE_DOCUMENTS_HIDE_DETAILS') ? 1 : 0);
1327 $hidedesc = isset($hidedesc) ? $hidedesc : (
getDolGlobalString(
'MAIN_GENERATE_DOCUMENTS_HIDE_DESC') ? 1 : 0);
1328 $hideref = isset($hideref) ? $hideref : (
getDolGlobalString(
'MAIN_GENERATE_DOCUMENTS_HIDE_REF') ? 1 : 0);
1329 $moreparams = isset($moreparams) ? $moreparams :
null;
1331 $result = $objecttmp->generateDocument($objecttmp->model_pdf, $outputlangs, $hidedetails, $hidedesc, $hideref, $moreparams);
1359if (!$error && ($action ==
'affecttag' && $confirm ==
'yes') && $permissiontoadd) {
1363 $affecttag_type =
GETPOST(
'affecttag_type',
'alpha');
1364 if (!empty($affecttag_type)) {
1365 $affecttag_type_array = explode(
',', $affecttag_type);
1369 if (!empty($affecttag_type_array)) {
1371 require_once DOL_DOCUMENT_ROOT.
'/categories/class/categorie.class.php';
1373 $to_affecttag_type_array = array();
1374 $categ_type_array = $categ->getMapList();
1375 foreach ($categ_type_array as $categdef) {
1376 if (in_array($categdef[
'code'], $affecttag_type_array)) {
1377 $to_affecttag_type_array[] = $categdef[
'code'];
1382 if (!empty($to_affecttag_type_array)) {
1383 foreach ($to_affecttag_type_array as $categ_type) {
1384 $contcats =
GETPOST(
'contcats_' . $categ_type,
'array');
1385 foreach ($toselect as $toselectid) {
1386 $result =
$object->fetch($toselectid);
1388 $result =
$object->setCategoriesCommon($contcats, $categ_type,
false);
1407 $toselect = array();
1413if (!$error && ($action ==
'updateprice' && $confirm ==
'yes') && $permissiontoadd) {
1414 '@phan-var-force Product|ProductCustomerPrice $obj';
1415 '@phan-var-force Product|ProductCustomerPrice $object';
1420 if ($pricepercentage == 0) {
1423 foreach ($toselect as $toselectid) {
1424 $result =
$object->fetch($toselectid);
1428 if (
$object->price_base_type ==
'TTC') {
1429 $newprice =
$object->price_ttc * (100 + $pricepercentage) / 100;
1430 $minprice =
$object->price_min_ttc;
1432 $newprice =
$object->price * (100 + $pricepercentage) / 100;
1433 $minprice =
$object->price_min;
1435 $res =
$object->updatePrice($newprice,
$object->price_base_type, $user,
$object->tva_tx, $minprice, 0,
$object->tva_npr, 0, 0, array(),
$object->default_vat_code);
1443 for ($level = 1; $level <= $maxlevel; $level++) {
1444 if (
$object->price_base_type ==
'TTC') {
1445 $newprice =
$object->multiprices_ttc[$level] * (100 + $pricepercentage) / 100;
1446 $minprice =
$object->multiprices_min_ttc[$level];
1448 $newprice =
$object->multiprices[$level] * (100 + $pricepercentage) / 100;
1449 $minprice =
$object->multiprices_min[$level];
1451 $res =
$object->updatePrice($newprice,
$object->price_base_type, $user,
$object->tva_tx, $minprice, $level,
$object->tva_npr, 0, 0, array(),
$object->default_vat_code);
1471 $toselect = array();
1477if (!$error && ($action ==
'setsupervisor' && $confirm ==
'yes') && $permissiontoadd) {
1478 '@phan-var-force User $object';
1481 $supervisortoset =
GETPOSTINT(
'supervisortoset');
1482 if (!empty($supervisortoset)) {
1483 foreach ($toselect as $toselectid) {
1484 $result =
$object->fetch($toselectid);
1486 $object->fk_user = $supervisortoset;
1487 $res =
$object->update($user);
1507 $toselect = array();
1513if (!$error && ($action ==
'affectuser' && $confirm ==
'yes') && $permissiontoadd) {
1518 $projectrole =
GETPOST(
'projectrole');
1519 $tasksrole =
GETPOST(
'tasksrole');
1520 if (!empty($usertoaffect)) {
1521 foreach ($toselect as $toselectid) {
1522 $result =
$object->fetch($toselectid);
1524 $res =
$object->add_contact($usertoaffect, $projectrole,
'internal');
1527 $task_array = $taskstatic->getTasksArray(
null,
null,
$object->id, 0, 0);
1529 foreach ($task_array as $task) {
1530 $tasksToAffect =
new Task(
$db);
1531 $result = $tasksToAffect->fetch($task->id);
1533 $res = $tasksToAffect->add_contact($usertoaffect, $tasksrole,
'internal');
1557 $toselect = array();
1563if (!$error && ($massaction ==
'enable' || ($action ==
'enable' && $confirm ==
'yes')) && $permissiontoadd) {
1566 $objecttmp =
new $objectclass(
$db);
1568 foreach ($toselect as $toselectid) {
1569 $result = $objecttmp->fetch($toselectid);
1571 if (in_array($objecttmp->element, array(
'societe'))) {
1572 $result = $objecttmp->setStatut(1);
1600if (!$error && ($massaction ==
'disable' || ($action ==
'disable' && $confirm ==
'yes')) && $permissiontoadd) {
1603 $objecttmp =
new $objectclass(
$db);
1605 foreach ($toselect as $toselectid) {
1606 $result = $objecttmp->fetch($toselectid);
1608 if (in_array($objecttmp->element, array(
'societe'))) {
1609 $result = $objecttmp->setStatut(0);
1637if (!$error && $action ==
'confirm_edit_value_extrafields' && $confirm ==
'yes' && $permissiontoadd) {
1640 $objecttmp =
new $objectclass(
$db);
1642 $e->fetch_name_optionals_label($objecttmp->table_element);
1645 $extrafieldKeyToUpdate =
GETPOST(
'extrafield-key-to-update');
1648 foreach ($toselect as $toselectid) {
1650 $objecttmp =
new $objectclass(
$db);
1651 $result = $objecttmp->fetch($toselectid);
1654 $ret = $e->setOptionalsFromPost(
null, $objecttmp, $extrafieldKeyToUpdate);
1656 $objecttmp->insertExtraFields();
1672 } elseif ($nbok == 1) {
1673 setEventMessages($langs->trans(
"RecordModifiedSuccessfully"),
null,
'mesgs');
1681if (!$error && ($massaction ==
'assignsalerepresentative' || ($action ==
'assignsalerepresentative' && $confirm ==
'yes')) && $permissiontoadd) {
1684 $objecttmp =
new $objectclass(
$db);
1687 foreach ($toselect as $toselectid) {
1688 $result = $objecttmp->fetch($toselectid);
1690 if (in_array($objecttmp->element, array(
'societe'))) {
1691 $result = $objecttmp->setSalesRep(
GETPOST(
"commercial",
"alpha"));
1709 setEventMessages($langs->trans(
"CommercialsAffected", $nbok),
null,
'mesgs');
1719if (!$error && ($massaction ==
'unassigncommercial' || ($action ==
'unassigncommercial' && $confirm ==
'yes')) && $permissiontoadd) {
1722 $objecttmp =
new $objectclass(
$db);
1725 foreach ($toselect as $toselectid) {
1726 $result = $objecttmp->fetch($toselectid);
1728 if (in_array($objecttmp->element, array(
'societe'))) {
1729 $TCommercial =
GETPOST(
"commercial",
"alpha");
1730 if (is_array($TCommercial)) {
1731 foreach ($TCommercial as $commercial) {
1732 $result = $objecttmp->del_commercial($user, $commercial);
1752 setEventMessages($langs->trans(
"CommercialsDisaffected", $nbok),
null,
'mesgs');
1762if (!$error && ($massaction ==
'approveleave' || ($action ==
'approveleave' && $confirm ==
'yes')) && $permissiontoapprove) {
1765 $objecttmp =
new $objectclass(
$db);
1766 '@phan-var-force Holiday $objecttmp';
1768 foreach ($toselect as $toselectid) {
1769 $result = $objecttmp->fetch($toselectid);
1772 setEventMessages($langs->trans(
'StatusOfRefMustBe', $objecttmp->ref, $langs->transnoentitiesnoconv(
'Validated')),
null,
'warnings');
1775 if ($user->id == $objecttmp->fk_validator) {
1776 $objecttmp->oldcopy =
dol_clone($objecttmp, 2);
1778 $objecttmp->date_valid =
dol_now();
1779 $objecttmp->fk_user_valid = $user->id;
1780 $objecttmp->date_approval =
dol_now();
1781 $objecttmp->fk_user_approve = $user->id;
1783 $objecttmp->statut = $objecttmp->status;
1785 $verif = $objecttmp->approve($user);
1797 $result = $tmpUser->fetch($objecttmp->fk_user);
1800 $nbopenedday =
num_open_day($objecttmp->date_debut_gmt, $objecttmp->date_fin_gmt, 0, 1, $objecttmp->halfday, $tmpUser->country_id);
1801 $soldeActuel = $objecttmp->getCpforUser($objecttmp->fk_user, $objecttmp->fk_type);
1802 $newSolde = ($soldeActuel - $nbopenedday);
1807 $result = $objecttmp->addLogCP($user->id, $objecttmp->fk_user, $langs->transnoentitiesnoconv(
"Holidays"), $newSolde, $objecttmp->fk_type);
1814 $result = $objecttmp->updateSoldeCP($objecttmp->fk_user, $newSolde, $objecttmp->fk_type);
1824 $destinataire =
new User(
$db);
1825 $destinataire->fetch($objecttmp->fk_user);
1826 $emailTo = $destinataire->email;
1829 dol_syslog(
"User that request leave has no email, so we redirect directly to finished page without sending email");
1833 $expediteur->fetch($objecttmp->fk_validator);
1843 $subject = $societeName.
" - ".$langs->transnoentitiesnoconv(
"HolidaysValidated");
1846 $message = $langs->transnoentitiesnoconv(
"Hello").
" ".$destinataire->firstname.
",\n";
1849 $message .= $langs->transnoentities(
"HolidaysValidatedBody",
dol_print_date($objecttmp->date_debut,
'day'),
dol_print_date($objecttmp->date_fin,
'day')).
"\n";
1851 $message .=
"- ".$langs->transnoentitiesnoconv(
"ValidatedBy").
" : ".
dolGetFirstLastname($expediteur->firstname, $expediteur->lastname).
"\n";
1853 $message .=
"- ".$langs->transnoentitiesnoconv(
"Link").
" : ".
$dolibarr_main_url_root.
"/holiday/card.php?id=".$objecttmp->id.
"\n\n";
1856 $trackid =
'leav'.$objecttmp->id;
1858 require_once DOL_DOCUMENT_ROOT.
'/core/class/CMailFile.class.php';
1859 $mail =
new CMailFile($subject, $emailTo, $emailFrom, $message, array(), array(), array(),
'',
'', 0, 0,
'',
'', $trackid);
1862 $result = $mail->sendfile();
1871 $langs->load(
"errors");
1872 setEventMessages($langs->trans(
'ErrorNotApproverForHoliday', $objecttmp->ref),
null,
'errors');
1884 } elseif ($nbok == 1) {
1893if (!$error && ($massaction ==
'increaseholiday' || ($action ==
'increaseholiday' && $confirm ==
'yes')) && $permissiontoapprove && is_array($toselect)) {
1894 '@phan-var-force Holiday $holiday';
1897 $objecttmp =
new $objectclass(
$db);
1902 if ($nbdaysholidays <= 0) {
1908 foreach ($toselect as $toselectid) {
1909 $balancecpuser = $objecttmp->getCPforUser($toselectid, $typeholiday);
1910 if (!empty($balancecpuser)) {
1911 $newnbdaysholidays = $nbdaysholidays + $balancecpuser;
1913 $newnbdaysholidays = $nbdaysholidays;
1915 $result = $holiday->addLogCP($user->id, $toselectid, $langs->transnoentitiesnoconv(
'ManualUpdate'), $newnbdaysholidays, $typeholiday);
1922 $objecttmp->updateSoldeCP($toselectid, $newnbdaysholidays, $typeholiday);
1935 setEventMessages($langs->trans(
"HolidayRecordsIncreased", $nbok),
null,
'mesgs');
1936 } elseif ($nbok == 1) {
1940 $toselect = array();
1947if (!$error && ($massaction ==
'clonetasks' || ($action ==
'clonetasks' && $confirm ==
'yes'))) {
1950 include_once DOL_DOCUMENT_ROOT.
'/projet/class/task.class.php';
1958 $iscontactofnewproject = 0;
1959 if (empty($newproject->public)) {
1960 $tmps = $newproject->getProjectsAuthorizedForUser($user, 0, 1, 0,
'(fk_statut:=:1)');
1961 $tmparray = explode(
',', $tmps);
1962 if (in_array($newproject->id, $tmparray)) {
1963 $iscontactofnewproject = 1;
1968 $permisstiontoadd =
false;
1969 if ($user->hasRight(
'project',
'all',
'creer') || ($user->hasRight(
'project',
'creer') && ($newproject->public || $iscontactofnewproject))) {
1970 $permisstiontoadd =
true;
1973 if ($permisstiontoadd) {
1974 $taskidsmapping = array();
1975 $clonedtaskoldparent = array();
1980 $authorizedsourceprojects =
null;
1981 if (!$user->hasRight(
'projet',
'all',
'lire')) {
1983 $tmps = $sourceprojectstatic->getProjectsAuthorizedForUser($user, 0, 1, 0);
1984 $authorizedsourceprojects = explode(
',', $tmps);
1987 foreach (
GETPOST(
'selected') as $task) {
1988 if ($origin_task->fetch($task,
'', 0) <= 0) {
1993 if (is_array($authorizedsourceprojects) && !in_array($origin_task->fk_project, $authorizedsourceprojects)) {
2002 require_once DOL_DOCUMENT_ROOT .
"/core/modules/project/task/" .
getDolGlobalString(
'PROJECT_TASK_ADDON') .
'.php';
2003 $modTask =
new $classnamemodtask();
2004 '@phan-var-force ModeleNumRefTask $modTask';
2006 $defaultref = $modTask->getNextValue(
null, $clone_task);
2010 $clone_task->fk_project =
GETPOSTINT(
'projectid');
2011 $clone_task->ref = $defaultref;
2012 $clone_task->label = $origin_task->label;
2013 $clone_task->description = $origin_task->description;
2014 $clone_task->planned_workload = $origin_task->planned_workload;
2015 $clone_task->fk_task_parent = $origin_task->fk_task_parent;
2016 $clone_task->date_c =
dol_now();
2017 $clone_task->date_start = $origin_task->date_start;
2018 $clone_task->date_end = $origin_task->date_end;
2019 $clone_task->progress = $origin_task->progress;
2022 $ret = $extrafields->setOptionalsFromPost(
null, $clone_task);
2024 $taskid = $clone_task->create($user);
2027 $result = $clone_task->add_contact(
GETPOSTINT(
"userid"),
'TASKEXECUTIVE',
'internal');
2028 $taskidsmapping[$task] = $taskid;
2029 $clonedtaskoldparent[$taskid] = $origin_task->fk_task_parent;
2032 if (
$db->lasterrno() ==
'DB_ERROR_RECORD_ALREADY_EXISTS') {
2033 $langs->load(
"projects");
2035 $duplicate_code_error =
true;
2049 foreach ($clonedtaskoldparent as $newtaskid => $oldparentid) {
2050 if (empty($oldparentid)) {
2053 $newparentid = isset($taskidsmapping[$oldparentid]) ? $taskidsmapping[$oldparentid] : 0;
2055 if ($remaptask->fetch($newtaskid) > 0 && $remaptask->fk_task_parent != $newparentid) {
2056 $remaptask->fk_task_parent = $newparentid;
2057 if ($remaptask->update($user) < 0) {
2066 setEventMessages($langs->trans(
'NumberOfTasksCloned', $num),
null,
'mesgs');
2067 header(
"Location: ".DOL_URL_ROOT.
'/projet/tasks.php?id='.
GETPOSTINT(
'projectid'));
2075if (!$error && $action ==
'createcreditnote' && $permissiontoadd) {
2078 setEventMessages($langs->trans(
'CreditNoteNotCreatedStockCalculateOnBillEnabled'),
null,
'errors');
2079 header(
"Location: ".DOL_URL_ROOT.
'/compta/facture/list.php?mainmenu=compta&leftmenu=facture');
2083 $objecttmp =
new $objectclass(
$db);
2084 if ($objecttmp->element ==
'facture' || $objecttmp->element ==
'invoice') {
2089 $unique_arr = array_unique($toselect);
2090 foreach ($unique_arr as $toselectid) {
2091 $sourceinvoice = $toselectid;
2092 $result = $objecttmp->fetch($sourceinvoice);
2097 $TMsg[] = $langs->trans(
'CreditNoteNotCreatedSourceInvoiceNotFound', $sourceinvoice);
2102 $isSupportedType =
false;
2104 $isSupportedType =
true;
2107 $isSupportedType =
true;
2110 $isSupportedType =
true;
2113 if (!$isSupportedType) {
2122 $TMsg[] = $langs->trans(
'CreditNoteNotCreatedInvoiceTypeNotSupported', $objecttmp->ref, $listtype[$objecttmp->type]);
2128 $TMsg[] = $langs->trans(
'CreditNoteNotCreatedInvoiceNotValidated', $objecttmp->ref);
2133 $totalpaid = $objecttmp->getSommePaiement();
2134 $totalcreditnotes = $objecttmp->getSumCreditNotesUsed();
2135 $totaldeposits = $objecttmp->getSumDepositsUsed();
2136 if ($totalpaid > 0) {
2137 $TMsg[] = $langs->trans(
'CreditNoteNotCreatedPaymentAlreadyDone', $objecttmp->ref);
2140 if ($totalcreditnotes > 0) {
2141 $TMsg[] = $langs->trans(
'CreditNoteNotCreatedCreditNoteAlreadyUsed', $objecttmp->ref);
2144 if ($totaldeposits > 0) {
2145 $TMsg[] = $langs->trans(
'CreditNoteNotCreatedDepositAlreadyUsed', $objecttmp->ref);
2153 $object->entity = $objecttmp->entity;
2154 $object->socid = $objecttmp->socid;
2155 $object->subtype = $objecttmp->subtype;
2159 $object->ref_client = $objecttmp->ref_client;
2160 $object->ref_customer = $objecttmp->ref_customer;
2161 $object->fk_project = $objecttmp->fk_project;
2162 $object->cond_reglement_id = 0;
2163 $object->fk_account = $objecttmp->fk_account;
2164 $object->fk_incoterms = $objecttmp->fk_incoterms;
2165 $object->location_incoterms = $objecttmp->location_incoterms;
2166 $object->multicurrency_code = $objecttmp->multicurrency_code;
2167 $object->multicurrency_tx = $objecttmp->multicurrency_tx;
2169 $object->fk_facture_source = $sourceinvoice;
2173 if ($objecttmp->isSituationInvoice()) {
2174 $object->situation_counter = $objecttmp->situation_counter;
2175 $object->situation_cycle_ref = $objecttmp->situation_cycle_ref;
2176 $objecttmp->fetchPreviousNextSituationInvoice();
2183 $TMsg[] = $langs->trans(
'CreditNoteNotCreated', $objecttmp->ref);
2187 $facture_source = $objecttmp;
2190 $object->copy_linked_contact($objecttmp,
'internal');
2191 $object->copy_linked_contact($objecttmp,
'external');
2194 if (!empty($facture_source->lines)) {
2195 $fk_parent_line = 0;
2197 foreach ($facture_source->lines as $line) {
2199 if (method_exists($line,
'fetch_optionals')) {
2201 $line->fetch_optionals();
2205 if (($line->product_type != 9 && empty($line->fk_parent_line)) || $line->product_type == 9) {
2206 $fk_parent_line = 0;
2209 if ($facture_source->isSituationInvoice()) {
2210 $source_fk_prev_id = $line->fk_prev_id;
2211 $line->fk_prev_id = $line->id;
2213 if (!empty($facture_source->tab_previous_situation_invoice)) {
2216 $tab_jumped_credit_notes = array();
2217 $lineIndex = count($facture_source->tab_previous_situation_invoice) - 1;
2218 $searchPreviousInvoice =
true;
2219 while ($searchPreviousInvoice) {
2220 if ($facture_source->tab_previous_situation_invoice[$lineIndex]->type ==
Facture::TYPE_SITUATION || $lineIndex < 1) {
2221 $searchPreviousInvoice =
false;
2225 $tab_jumped_credit_notes[$lineIndex] = $facture_source->tab_previous_situation_invoice[$lineIndex]->id;
2231 $maxPrevSituationPercent = 0;
2232 foreach ($facture_source->tab_previous_situation_invoice[$lineIndex]->lines as $prevLine) {
2233 if ($prevLine->id == $source_fk_prev_id) {
2234 $maxPrevSituationPercent = max($maxPrevSituationPercent, $prevLine->situation_percent);
2237 $line->total_ht -= $prevLine->total_ht;
2238 $line->total_tva -= $prevLine->total_tva;
2239 $line->total_ttc -= $prevLine->total_ttc;
2240 $line->total_localtax1 -= $prevLine->total_localtax1;
2241 $line->total_localtax2 -= $prevLine->total_localtax2;
2243 $line->multicurrency_subprice -= $prevLine->multicurrency_subprice;
2244 $line->multicurrency_total_ht -= $prevLine->multicurrency_total_ht;
2245 $line->multicurrency_total_tva -= $prevLine->multicurrency_total_tva;
2246 $line->multicurrency_total_ttc -= $prevLine->multicurrency_total_ttc;
2251 $line->situation_percent = $maxPrevSituationPercent - $line->situation_percent;
2256 $maxPrevSituationPercent = 0;
2257 foreach ($tab_jumped_credit_notes as $index => $creditnoteid) {
2258 foreach ($facture_source->tab_previous_situation_invoice[$index]->lines as $prevLine) {
2259 if ($prevLine->fk_prev_id == $source_fk_prev_id) {
2260 $maxPrevSituationPercent = $prevLine->situation_percent;
2262 $line->total_ht -= $prevLine->total_ht;
2263 $line->total_tva -= $prevLine->total_tva;
2264 $line->total_ttc -= $prevLine->total_ttc;
2265 $line->total_localtax1 -= $prevLine->total_localtax1;
2266 $line->total_localtax2 -= $prevLine->total_localtax2;
2268 $line->multicurrency_subprice -= $prevLine->multicurrency_subprice;
2269 $line->multicurrency_total_ht -= $prevLine->multicurrency_total_ht;
2270 $line->multicurrency_total_tva -= $prevLine->multicurrency_total_tva;
2271 $line->multicurrency_total_ttc -= $prevLine->multicurrency_total_ttc;
2277 $line->situation_percent += $maxPrevSituationPercent;
2283 $line->fk_facture =
$object->id;
2284 $line->fk_parent_line = $fk_parent_line;
2286 $line->subprice = -$line->subprice;
2288 $line->total_ht = -$line->total_ht;
2289 $line->total_tva = -$line->total_tva;
2290 $line->total_ttc = -$line->total_ttc;
2291 $line->total_localtax1 = -$line->total_localtax1;
2292 $line->total_localtax2 = -$line->total_localtax2;
2294 $line->multicurrency_subprice = -$line->multicurrency_subprice;
2295 $line->multicurrency_total_ht = -$line->multicurrency_total_ht;
2296 $line->multicurrency_total_tva = -$line->multicurrency_total_tva;
2297 $line->multicurrency_total_ttc = -$line->multicurrency_total_ttc;
2299 $line->context[
'createcreditnotefrominvoice'] = 1;
2300 $result = $line->insert(0, 1);
2305 if ($result > 0 && $line->product_type == 9) {
2306 $fk_parent_line = $result;
2314 if (!empty(
$object->fk_facture_source) &&
$id > 0) {
2315 $facture_source->fetch(
$object->fk_facture_source);
2316 $facture_source->fetchObjectLinked();
2318 if (!empty($facture_source->linkedObjectsIds)) {
2319 foreach ($facture_source->linkedObjectsIds as $sourcetype => $TIds) {
2320 $object->add_object_linked($sourcetype, current($TIds));
2326 $result =
$object->validate($user);
2329 $TMsg[] = $langs->trans(
'CreditNoteNotCreatedErrorOnValidation', $objecttmp->ref);
2335 $outputlangs = $langs;
2338 $newlang =
GETPOST(
'lang_id',
'aZ09');
2341 $newlang =
$object->thirdparty->default_lang;
2343 if (!empty($newlang)) {
2345 $outputlangs->setDefaultLang($newlang);
2346 $outputlangs->load(
'products');
2352 $result =
$object->generateDocument($model, $outputlangs, (
int) $hidedetails, (
int) $hidedesc, (
int) $hideref);
2364 $result = $discountcheck->fetch(0,
$object->id);
2367 if (empty($discountcheck->id)) {
2372 $amount_ht = $amount_tva = $amount_ttc = array();
2373 $multicurrency_amount_ht = $multicurrency_amount_tva = $multicurrency_amount_ttc = array();
2377 foreach (
$object->lines as $line) {
2378 if ($line->product_type < 9 && $line->total_ht != 0) {
2379 $keyforvatrate = $line->tva_tx.($line->vat_src_code ?
' ('.$line->vat_src_code.
')' :
'');
2381 if (!isset($amount_ht[$keyforvatrate])) {
2382 $amount_ht[$keyforvatrate] = 0;
2384 $amount_ht[$keyforvatrate] += $line->total_ht;
2385 if (!isset($amount_tva[$keyforvatrate])) {
2386 $amount_tva[$keyforvatrate] = 0;
2388 $amount_tva[$keyforvatrate] += $line->total_tva;
2389 if (!isset($amount_ttc[$keyforvatrate])) {
2390 $amount_ttc[$keyforvatrate] = 0;
2392 $amount_ttc[$keyforvatrate] += $line->total_ttc;
2393 if (!isset($multicurrency_amount_ht[$keyforvatrate])) {
2394 $multicurrency_amount_ht[$keyforvatrate] = 0;
2396 $multicurrency_amount_ht[$keyforvatrate] += $line->multicurrency_total_ht;
2397 if (!isset($multicurrency_amount_tva[$keyforvatrate])) {
2398 $multicurrency_amount_tva[$keyforvatrate] = 0;
2400 $multicurrency_amount_tva[$keyforvatrate] += $line->multicurrency_total_tva;
2401 if (!isset($multicurrency_amount_ttc[$keyforvatrate])) {
2402 $multicurrency_amount_ttc[$keyforvatrate] = 0;
2404 $multicurrency_amount_ttc[$keyforvatrate] += $line->multicurrency_total_ttc;
2411 $discount->description =
'(CREDIT_NOTE)';
2412 $discount->fk_soc =
$object->socid;
2413 $discount->socid =
$object->socid;
2414 $discount->socid =
$object->socid;
2415 $discount->fk_facture_source =
$object->id;
2420 foreach ($amount_ht as $tva_tx => $xxx) {
2421 $discount->amount_ht = -((float) $amount_ht[$tva_tx]);
2422 $discount->amount_tva = -((float) $amount_tva[$tva_tx]);
2423 $discount->amount_ttc = -((float) $amount_ttc[$tva_tx]);
2424 $discount->total_ht = -((float) $amount_ht[$tva_tx]);
2425 $discount->total_tva = -((float) $amount_tva[$tva_tx]);
2426 $discount->total_ttc = -((float) $amount_ttc[$tva_tx]);
2427 $discount->multicurrency_amount_ht = -((float) $multicurrency_amount_ht[$tva_tx]);
2428 $discount->multicurrency_amount_tva = -((float) $multicurrency_amount_tva[$tva_tx]);
2429 $discount->multicurrency_amount_ttc = -((float) $multicurrency_amount_ttc[$tva_tx]);
2430 $discount->multicurrency_total_ht = -((float) $multicurrency_amount_ht[$tva_tx]);
2431 $discount->multicurrency_total_tva = -((float) $multicurrency_amount_tva[$tva_tx]);
2432 $discount->multicurrency_total_ttc = -((float) $multicurrency_amount_ttc[$tva_tx]);
2437 if (preg_match(
'/\((.*)\)/', $tva_tx, $reg)) {
2438 $vat_src_code = $reg[1];
2439 $tva_tx = preg_replace(
'/\s*\(.*\)/',
'', $tva_tx);
2442 $discount->tva_tx = abs((
float) $tva_tx);
2443 $discount->vat_src_code = $vat_src_code;
2445 $id_discount = $discount->create($user);
2446 if ($id_discount < 0) {
2452 if (empty($error) && $id_discount > 0) {
2454 $result =
$object->setPaid($user);
2460 $discount->fetch($id_discount);
2461 $result = $discount->link_to_invoice(0,
$object->fk_facture_source);
2464 $TMsg[] = $langs->trans(
'CreditNoteNotCreatedErrorOnDiscountLink', $objecttmp->ref);
2470 $objecttmp->fetch($objecttmp->id);
2471 if ($objecttmp->getRemainToPay(0) == 0) {
2472 $result = $objecttmp->setPaid($user);
2475 $TMsg[] = $langs->trans(
'CreditNoteNotCreatedErrorOnSetPaidSourceInvoice', $objecttmp->ref);
2480 $outputlangs = $langs;
2483 $newlang =
GETPOST(
'lang_id',
'aZ09');
2486 $objecttmp->fetch_thirdparty();
2487 $newlang = $objecttmp->thirdparty->default_lang;
2489 if (!empty($newlang)) {
2491 $outputlangs->setDefaultLang($newlang);
2493 $ret = $objecttmp->fetch($objecttmp->id);
2495 $result = $objecttmp->generateDocument($objecttmp->model_pdf, $outputlangs, (
int) $hidedetails, (
int) $hidedesc, (
int) $hideref);
2503 $TMsg[] = $langs->trans(
'CreditNoteNotCreatedErrorOnSourceInvoiceNotFullyPaidAfterDiscount', $objecttmp->ref);
2509 $TMsg[] = $langs->trans(
'CreditNoteNotCreatedErrorOnSetPaid', $objecttmp->ref);
2515 $TMsg[] = $langs->trans(
'CreditNoteNotCreatedErrorOnDiscount', $objecttmp->ref);
2520 $TMsg[] = $langs->trans(
'CreditNoteNotCreatedAlreadyConverted', $objecttmp->ref);
2528 $TMsg[] = $langs->trans(
'CreditNoteCreated',
$object->ref, $objecttmp->ref);
2533 foreach ($TMsg as $msg) {
2539 setEventMessages($langs->trans(
'CreditNotesCreated', $nbok),
null,
'mesgs');
2542 $toselect = array();
2543 header(
"Location: ".DOL_URL_ROOT.
'/compta/facture/list.php?mainmenu=compta&leftmenu=facture');
2546 setEventMessages($langs->trans(
'ThisMassActionIsOnlyForInvoices'),
null,
'errors');
2547 header(
"Location: ".DOL_URL_ROOT.
'/compta/facture/list.php?mainmenu=compta&leftmenu=facture');
2552if (empty($toselect)) {
2555$parameters[
'toselect'] = &$toselect;
2556$parameters[
'uploaddir'] = $uploaddir;
2557$parameters[
'massaction'] = $massaction;
2558$parameters[
'diroutputmassaction'] = isset($diroutputmassaction) ? $diroutputmassaction :
null;
2561$reshook = $hookmanager->executeHooks(
'doMassActions', $parameters,
$object, $action);
$id
Support class for third parties, contacts, members, users or resources.
if(! $sortfield) if(! $sortorder) $object
global $dolibarr_main_url_root
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.
Class to manage absolute discounts.
Class to manage invoices.
const TYPE_REPLACEMENT
Replacement invoice.
const STATUS_DRAFT
Draft status.
const TYPE_STANDARD
Standard invoice.
const TYPE_SITUATION
Situation invoice.
const TYPE_PROFORMA
Proforma invoice (should not be used.
const STATUS_VALIDATED
Validated (need to be paid)
const TYPE_DEPOSIT
Deposit invoice.
const TYPE_CREDIT_NOTE
Credit note invoice.
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, $countryCodeOrId='', $user_id=0)
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_now($mode='gmt')
Return date for now.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0, $attop=0)
Set event messages in dol_events session object.
dol_mimetype($file, $default='application/octet-stream', $mode=0)
Return MIME type of a file from its name with extension.
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, $attop=0)
Set event message in dol_events session object.
dol_sanitizeFileName($str, $newstr='_', $unaccent=1, $includequotes=0, $allowdash=0)
Clean a string to use it as a file name.
dolChmod($filepath, $newmask='')
Change mod of a file.
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0, $nodefault=0)
Return value of a param into GET or POST supervariable.
GETPOSTFLOAT($paramname, $rounding='', $option=2)
Return the value of a $_GET or $_POST supervariable, converted into float.
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...
GETPOSTINT($paramname, $method=0, $nodefault=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
dol_clone($srcobject, $native=2)
Create a clone of instance of object (new instance with same value for each properties) With native =...
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs=null, $encodetooutput=false, $decorate=0)
Output date in a string format according to outputlangs (or langs if not defined).
dol_print_error($db=null, $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
GETPOSTISSET($paramname)
Return true if we are in a context of submitting the parameter $paramname from a POST of a form.
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
isModEnabled($module)
Is Dolibarr module enabled.
get_exdir($num, $level, $alpha, $withoutslash, $object, $modulepart='')
Return a path to have a the directory according to object where files are stored.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
dol_mkdir($dir, $dataroot='', $newmask='')
Creation of a directory (this can create recursive subdir)
pdf_getFormat($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, $mode=0)
Returns a hash (non reversible encryption) of a string.