78@phan-var-force int $error
79@phan-var-force ?string $permissiontoadd
80@phan-var-force ?string $permissiontoread
81@phan-var-force ?string $permissiontodelete
82@phan-var-force ?string $permissiontoclose
83@phan-var-force ?string $permissiontocancel
84@phan-var-force ?string $permissiontoapprove
85@phan-var-force ?int[] $toselect
86@phan-var-force ?string $diroutputmassaction
87@phan-var-force ?string $objectlabel
88@phan-var-force ?string $option
89@phan-var-force int $deliveryreceipt
90@phan-var-force string $month
91@phan-var-force string $year
92@phan-var-force ?array<string,mixed> $moreparams
93@phan-var-force ?string $search_status
94@phan-var-force ?int $hidedetails
95@phan-var-force ?int $hidedesc
96@phan-var-force ?int $hideref
97@phan-var-force string $confirm
102if (empty($objectclass) || empty($uploaddir)) {
103 dol_print_error(
null,
'include of actions_massactions.inc.php is done but var $objectclass or $uploaddir was not defined');
106if (empty($massaction)) {
112@phan-var-force "CommonObject"|"CommandeFournisseur"|"ConferenceOrBoothAttendee"|"Contrat"|"Contact"|"Expedition"|"ExpenseReport"|"Facture"|"FactureFournisseur"|"Fichinter"|"Holiday"|"Partnership"|"Project"|"Propal"|"Societe"|"SupplierProposal" $objectclass
113@phan-var-force string $massaction
114@phan-var-force string $uploaddir
121if (!empty($permtoread) && empty($permissiontoread)) {
122 $permissiontoread = $permtoread;
124if (!empty($permtocreate) && empty($permissiontoadd)) {
125 $permissiontoadd = $permtocreate;
127if (!empty($permtodelete) && empty($permissiontodelete)) {
128 $permissiontodelete = $permtodelete;
132$maxformassaction =
getDolGlobalInt(
'MAIN_LIMIT_FOR_MASS_ACTIONS', 1000);
133if ($massaction && is_array($toselect) && count($toselect) < 1) {
137if (!$error && isset($toselect) && is_array($toselect) && count($toselect) > $maxformassaction) {
138 setEventMessages($langs->trans(
'TooManyRecordForMassAction', $maxformassaction),
null,
'errors');
145if (!$error && $massaction && !empty($toselect) && is_array($toselect)) {
146 $objecttmpforaccesscheck =
new $objectclass(
$db);
148 if (!empty($refusedids)) {
149 $langs->load(
"errors");
155if (!$error && $massaction ==
'confirm_presend' && !
GETPOST(
'sendmail')) {
156 $massaction =
'presend';
159if (!$error && $massaction ==
'confirm_presend') {
163 $langs->load(
"mails");
164 include_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
165 include_once DOL_DOCUMENT_ROOT.
'/core/lib/signature.lib.php';
167 $listofobjectid = array();
168 $listofobjectthirdparties = array();
169 $listofobjectcontacts = array();
170 $listofobjectref = array();
171 $contactidtosend = array();
172 $attachedfilesThirdpartyObj = array();
173 $oneemailperrecipient = (
GETPOSTINT(
'oneemailperrecipient') ? 1 : 0);
177 $objecttmp =
new $objectclass(
$db);
181 if ($objecttmp->element ==
'expensereport') {
183 } elseif ($objecttmp->element ==
'contact') {
185 } elseif ($objecttmp->element ==
'partnership' &&
getDolGlobalString(
'PARTNERSHIP_IS_MANAGED_FOR') ==
'member') {
187 } elseif ($objecttmp->element ==
'holiday') {
189 } elseif ($objecttmp->element ==
'conferenceorboothattendee') {
193 foreach ($toselect as $toselectid) {
194 $objecttmp =
new $objectclass(
$db);
195 '@phan-var-force CommonObject $objecttmp';
197 $result = $objecttmp->fetch($toselectid);
199 $listofobjectid[$toselectid] = $toselectid;
202 $tmpobjectid = ($objecttmp->fk_soc ? $objecttmp->fk_soc : $objecttmp->socid);
203 if ($objecttmp->element ==
'societe') {
204 '@phan-var-force Societe $objecttmp';
206 $tmpobjectid = $objecttmp->id;
207 } elseif ($objecttmp->element ==
'contact') {
208 '@phan-var-force Contact $objecttmp';
210 $tmpobjectid = $objecttmp->id;
211 } elseif ($objecttmp->element ==
'expensereport') {
212 '@phan-var-force ExpenseReport $objecttmp';
214 $tmpobjectid = $objecttmp->fk_user_author;
215 } elseif ($objecttmp->element ==
'partnership' &&
getDolGlobalString(
'PARTNERSHIP_IS_MANAGED_FOR') ==
'member') {
216 '@phan-var-force Partnership $objecttmp';
218 $tmpobjectid = $objecttmp->fk_member;
219 } elseif ($objecttmp->element ==
'holiday') {
220 '@phan-var-force Holiday $objecttmp';
222 $tmpobjectid = $objecttmp->fk_user;
223 } elseif ($objecttmp->element ==
'conferenceorboothattendee') {
224 '@phan-var-force ConferenceOrBoothAttendee $objecttmp';
226 $tmpobjectid = $objecttmp->id;
228 if (empty($tmpobjectid)) {
232 if ($objectclass ==
'Facture') {
233 '@phan-var-force Facture $objecttmp';
235 $tmparraycontact = array();
236 $tmparraycontact = $objecttmp->liste_contact(-1,
'external', 0,
'BILLING');
237 if (is_array($tmparraycontact) && count($tmparraycontact) > 0) {
238 foreach ($tmparraycontact as $data_email) {
239 $listofobjectcontacts[$toselectid][$data_email[
'id']] = $data_email[
'email'];
242 } elseif ($objectclass ==
'CommandeFournisseur') {
243 '@phan-var-force CommandeFournisseur $objecttmp';
245 $tmparraycontact = array();
246 $tmparraycontact = $objecttmp->liste_contact(-1,
'external', 0,
'CUSTOMER');
247 if (is_array($tmparraycontact) && count($tmparraycontact) > 0) {
248 foreach ($tmparraycontact as $data_email) {
249 $listofobjectcontacts[$toselectid][$data_email[
'id']] = $data_email[
'email'];
254 $listofobjectthirdparties[$tmpobjectid] = $tmpobjectid;
255 $listofobjectref[$tmpobjectid][$toselectid] = $objecttmp;
261 if (
GETPOST(
'fromtype',
'alpha') ===
'user' && empty($user->email)) {
264 $massaction =
'presend';
267 $receiver =
GETPOST(
'receiver',
'alphawithlgt');
268 if (!is_array($receiver)) {
269 if (empty($receiver) || $receiver ==
'-1') {
272 $receiver = array($receiver);
275 if (!trim(
GETPOST(
'sendto',
'alphawithlgt')) && count($receiver) == 0 && count($listofobjectthirdparties) == 1) {
277 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"MailRecipient")),
null,
'warnings');
278 $massaction =
'presend';
281 if (!
GETPOST(
'subject',
'restricthtml')) {
283 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"MailTopic")),
null,
'warnings');
284 $massaction =
'presend';
289 foreach ($listofobjectthirdparties as $thirdpartyid) {
290 $result = $thirdparty->fetch($thirdpartyid);
303 if (trim(
GETPOST(
'sendto',
'alphawithlgt'))) {
305 $tmparray[] = trim(
GETPOST(
'sendto',
'alphawithlgt'));
307 if (count($receiver) > 0 && is_object($thirdparty)) {
308 foreach ($receiver as $key => $val) {
310 if ($val ==
'thirdparty') {
311 $tmparray[] =
dol_string_nospecial((
string) $thirdparty->name,
' ', array(
",")).
' <'.$thirdparty->email.
'>';
312 } elseif ($val && method_exists($thirdparty,
'contact_get_property')) {
313 $tmparray[] = $thirdparty->contact_get_property((
int) $val,
'email');
318 $sendto = implode(
',', $tmparray);
321 $receivercc =
GETPOST(
'receivercc',
'alphawithlgt');
322 if (!is_array($receivercc)) {
323 if ($receivercc ==
'-1') {
324 $receivercc = array();
326 $receivercc = array($receivercc);
330 if (trim(
GETPOST(
'sendtocc',
'alphawithlgt'))) {
331 $tmparray[] = trim(
GETPOST(
'sendtocc',
'alphawithlgt'));
333 if (count($receivercc) > 0) {
334 foreach ($receivercc as $key => $val) {
336 if ($val ==
'thirdparty') {
337 $tmparray[] =
dol_string_nospecial((
string) $thirdparty->name,
' ', array(
",")).
' <'.$thirdparty->email.
'>';
339 $tmparray[] = $thirdparty->contact_get_property((
int) $val,
'email');
344 $sendtocc = implode(
',', $tmparray);
347 $listofqualifiedobj = array();
348 $listofqualifiedref = array();
349 $thirdpartywithoutemail = array();
351 foreach ($listofobjectref[$thirdpartyid] as $objectid => $objectobj) {
358 $langs->load(
"errors");
360 $resaction .=
'<div class="error">'.$langs->trans(
'ErrorOnlyProposalNotDraftCanBeSentInMassAction', $objectobj->ref).
'</div><br>';
364 $langs->load(
"errors");
366 $resaction .=
'<div class="error">'.$langs->trans(
'ErrorOnlyOrderNotDraftCanBeSentInMassAction', $objectobj->ref).
'</div><br>';
370 $langs->load(
"errors");
372 $resaction .=
'<div class="error">'.$langs->trans(
'ErrorOnlyInvoiceValidatedCanBeSentInMassAction', $objectobj->ref).
'</div><br>';
377 if (empty($sendto)) {
378 if ($objectobj->element ==
'societe') {
379 $sendto = $objectobj->email;
380 } elseif ($objectobj->element ==
'expensereport') {
382 $fuser->fetch($objectobj->fk_user_author);
383 $sendto = $fuser->email;
384 } elseif ($objectobj->element ==
'contact') {
386 $fcontact->fetch($objectobj->id);
387 $sendto = $fcontact->email;
388 } elseif ($objectobj->element ==
'partnership' &&
getDolGlobalString(
'PARTNERSHIP_IS_MANAGED_FOR') ==
'member') {
390 $fadherent->fetch($objectobj->fk_member);
391 $sendto = $fadherent->email;
392 } elseif ($objectobj->element ==
'holiday') {
394 $fuser->fetch($objectobj->fk_user);
395 $sendto = $fuser->email;
396 } elseif ($objectobj->element ==
'facture' && !empty($listofobjectcontacts[$objectid])) {
397 $emails_to_sends = array();
398 $objectobj->fetch_thirdparty();
399 $contactidtosend = array();
400 foreach ($listofobjectcontacts[$objectid] as $contactemailid => $contactemailemail) {
401 $emails_to_sends[] = $objectobj->thirdparty->contact_get_property($contactemailid,
'email');
402 if (!in_array($contactemailid, $contactidtosend)) {
403 $contactidtosend[] = $contactemailid;
406 if (count($emails_to_sends) > 0) {
407 $sendto = implode(
',', $emails_to_sends);
409 } elseif ($objectobj->element ==
'order_supplier' && !empty($listofobjectcontacts[$objectid])) {
410 $emails_to_sends = array();
411 $objectobj->fetch_thirdparty();
412 $contactidtosend = array();
413 foreach ($listofobjectcontacts[$objectid] as $contactemailid => $contactemailemail) {
414 $emails_to_sends[] = $objectobj->thirdparty->contact_get_property($contactemailid,
'email');
415 if (!in_array($contactemailid, $contactidtosend)) {
416 $contactidtosend[] = $contactemailid;
419 if (count($emails_to_sends) > 0) {
420 $sendto = implode(
',', $emails_to_sends);
422 } elseif ($objectobj->element ==
'conferenceorboothattendee') {
423 $sendto = $objectobj->email;
425 $objectobj->fetch_thirdparty();
426 $sendto = $objectobj->thirdparty->email;
430 if (empty($sendto)) {
431 if ($objectobj->element ==
'societe') {
433 $objectobj->thirdparty = $objectobj;
438 if (empty($thirdpartywithoutemail[$objectobj->thirdparty->id])) {
439 $resaction .=
'<div class="error">'.$langs->trans(
'NoRecipientEmail', $objectobj->thirdparty->name).
'</div><br>';
441 dol_syslog(
'No recipient for thirdparty: '.$objectobj->thirdparty->name, LOG_WARNING);
442 $thirdpartywithoutemail[$objectobj->thirdparty->id] = 1;
446 if (
GETPOST(
'addmaindocfile')) {
453 $filedir = $uploaddir.
'/'.$subdir.dol_sanitizeFileName($objectobj->ref);
454 $filepath = $filedir.
'/'.$filename;
457 if ($objectobj->element ==
'invoice_supplier') {
458 $fileparams =
dol_most_recent_file($uploaddir.
'/'.
get_exdir($objectobj->id, 2, 0, 0, $objectobj, $objectobj->element).$objectobj->ref, preg_quote($objectobj->ref,
'/').
'([^\-])+');
459 $filepath = $fileparams[
'fullname'];
462 if (
getDolGlobalInt(
'MAIL_MASS_ACTION_SEARCH_MOST_RECENT_FILE_IF_NOT_FOUND') && isset($filepath) && !
dol_is_file($filepath)) {
464 if (isset($fileparams)) {
465 $filepath = $fileparams[
'fullname'];
466 $filename = $fileparams[
'name'];
471 $filename_found =
'';
472 $filepath_found =
'';
473 $file_check_list = array();
474 $file_check_list[] = array(
478 if (
getDolGlobalString(
'MAIL_MASS_ACTION_ADD_LAST_IF_MAIN_DOC_NOT_FOUND') && !empty($objectobj->last_main_doc)) {
479 $file_check_list[] = array(
480 'name' => basename($objectobj->last_main_doc),
481 'path' => DOL_DATA_ROOT .
'/' . $objectobj->last_main_doc,
484 foreach ($file_check_list as $file_check_arr) {
486 $filename_found = $file_check_arr[
'name'];
487 $filepath_found = $file_check_arr[
'path'];
492 if ($filepath_found) {
494 $attachedfilesThirdpartyObj[$thirdpartyid][$objectid] = array(
495 'paths' => array($filepath_found),
496 'names' => array($filename_found),
501 $langs->load(
"errors");
502 foreach ($file_check_list as $file_check_arr) {
503 $resaction .=
'<div class="error">'.$langs->trans(
'ErrorCantReadFile', $file_check_arr[
'path']).
'</div><br>';
504 dol_syslog(
'Failed to read file: '.$file_check_arr[
'path'], LOG_WARNING);
511 $listofqualifiedobj[$objectid] = $objectobj;
512 $listofqualifiedref[$objectid] = $objectobj->ref;
519 if (count($listofqualifiedobj) > 0) {
520 $langs->load(
"commercial");
524 $fromtype =
GETPOST(
'fromtype');
525 if ($fromtype ===
'user') {
526 $email_from =
dol_string_nospecial($user->getFullName($langs),
' ', array(
",")).
' <'.$user->email.
'>';
527 } elseif ($fromtype ===
'company') {
529 } elseif (preg_match(
'/global_aliases_(\d+)/', $fromtype, $reg)) {
531 $email_from = trim($tmp[((
int) $reg[1] - 1)]);
532 } elseif (preg_match(
'/senderprofile_(\d+)_(\d+)/', $fromtype, $reg)) {
533 $sql =
"SELECT rowid, label, email FROM ".MAIN_DB_PREFIX.
"c_email_senderprofile WHERE rowid = ".(int) $reg[1];
534 $resql =
$db->query($sql);
535 $obj =
$db->fetch_object($resql);
539 } elseif (preg_match(
'/from_template_(\d+)/', $fromtype, $reg)) {
540 $sql =
"SELECT rowid, email_from FROM ".MAIN_DB_PREFIX.
"c_email_templates WHERE rowid = ".(int) $reg[1];
541 $resql =
$db->query($sql);
542 $obj =
$db->fetch_object($resql);
544 $email_from = $obj->email_from;
550 $replyto = $email_from;
551 $subject =
GETPOST(
'subject',
'restricthtml');
552 $message =
GETPOST(
'message',
'restricthtml');
554 $sendtobcc =
GETPOST(
'sendtoccc');
555 if ($objectclass ==
'Propal') {
558 if ($objectclass ==
'Commande') {
561 if ($objectclass ==
'Facture') {
564 if ($objectclass ==
'SupplierProposal') {
565 $sendtobcc .= (!
getDolGlobalString(
'MAIN_MAIL_AUTOCOPY_SUPPLIER_PROPOSAL_TO') ?
'' : (($sendtobcc ?
", " :
"") .
getDolGlobalString(
'MAIN_MAIL_AUTOCOPY_SUPPLIER_PROPOSAL_TO')));
567 if ($objectclass ==
'CommandeFournisseur') {
570 if ($objectclass ==
'FactureFournisseur') {
573 if ($objectclass ==
'Project') {
579 $looparray = array();
580 if (!$oneemailperrecipient) {
581 $looparray = $listofqualifiedobj;
582 foreach ($looparray as $key => $objecttmp) {
583 $looparray[$key]->thirdparty = $thirdparty;
586 $objectforloop =
new $objectclass(
$db);
587 $objectforloop->thirdparty = $thirdparty;
588 $looparray[0] = $objectforloop;
591 dol_syslog(
"We have set an array of ".count($looparray).
" emails to send. oneemailperrecipient=".$oneemailperrecipient);
593 foreach ($looparray as $objectid => $objecttmp) {
595 if (
isModEnabled(
'project') && method_exists($objecttmp,
'fetchProject') && is_null($objecttmp->project)) {
596 $objecttmp->fetchProject();
598 $substitutionarray = getCommonSubstitutionArray($langs, 0,
null, $objecttmp);
599 $substitutionarray[
'__ID__'] = ($oneemailperrecipient ? implode(
', ', array_keys($listofqualifiedobj)) : $objecttmp->id);
600 $substitutionarray[
'__REF__'] = ($oneemailperrecipient ? implode(
', ', $listofqualifiedref) : $objecttmp->
ref);
601 $substitutionarray[
'__EMAIL__'] = $thirdparty->email;
602 $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"/>';
604 if ($oneemailperrecipient) {
605 $substitutionarray[
'__ONLINE_PAYMENT_URL__'] =
'';
606 $substitutionarray[
'__ONLINE_PAYMENT_TEXT_AND_URL__'] =
'';
609 $parameters = array(
'mode' =>
'formemail');
611 if (!empty($listofobjectthirdparties)) {
612 $parameters[
'listofobjectthirdparties'] = $listofobjectthirdparties;
614 if (!empty($listofobjectref)) {
615 $parameters[
'listofobjectref'] = $listofobjectref;
623 $attachedfiles = array(
'paths' => array(),
'names' => array(),
'mimes' => array());
624 if ($oneemailperrecipient) {
626 if (is_array($attachedfilesThirdpartyObj[$thirdparty->id]) && count($attachedfilesThirdpartyObj[$thirdparty->id])) {
627 foreach ($attachedfilesThirdpartyObj[$thirdparty->id] as $keyObjId => $objAttachedFiles) {
629 $attachedfiles = array(
630 'paths' => array_merge($attachedfiles[
'paths'], $objAttachedFiles[
'paths']),
631 'names' => array_merge($attachedfiles[
'names'], $objAttachedFiles[
'names']),
632 'mimes' => array_merge($attachedfiles[
'mimes'], $objAttachedFiles[
'mimes'])
636 } elseif (!empty($attachedfilesThirdpartyObj[$thirdparty->id][$objectid])) {
639 $attachedfiles = $attachedfilesThirdpartyObj[$thirdparty->id][$objectid];
642 $filepath = $attachedfiles[
'paths'];
643 $filename = $attachedfiles[
'names'];
644 $mimetype = $attachedfiles[
'mimes'];
647 if ($oneemailperrecipient) {
648 $trackid =
'thi'.$thirdparty->id;
649 if ($objecttmp->element ==
'expensereport') {
650 $trackid =
'use'.$thirdparty->id;
651 } elseif ($objecttmp->element ==
'contact') {
652 $trackid =
'ctc'.$thirdparty->id;
653 } elseif ($objecttmp->element ==
'holiday') {
654 $trackid =
'use'.$thirdparty->id;
657 $trackid = strtolower(get_class($objecttmp));
658 if (get_class($objecttmp) ==
'Contact') {
660 } elseif (get_class($objecttmp) ==
'Contrat') {
662 } elseif (get_class($objecttmp) ==
'Propal') {
664 } elseif (get_class($objecttmp) ==
'Commande') {
666 } elseif (get_class($objecttmp) ==
'Facture') {
668 } elseif (get_class($objecttmp) ==
'SupplierProposal') {
670 } elseif (get_class($objecttmp) ==
'CommandeFournisseur') {
672 } elseif (get_class($objecttmp) ==
'FactureFournisseur') {
676 $trackid .= $objecttmp->id;
682 if (empty($sendcontext)) {
683 $sendcontext =
'standard';
687 $vardir =
$conf->user->dir_output.
"/".$user->id;
688 $upload_dir_tmp = $vardir.
'/temp';
691 require_once DOL_DOCUMENT_ROOT.
'/core/class/CMailFile.class.php';
692 $mailfile =
new CMailFile($subjectreplaced, (
string) $sendto, $email_from, $messagereplaced, $filepath, $mimetype, $filename, $sendtocc, $sendtobcc, (
int) $deliveryreceipt, -1,
'',
'', $trackid,
'', $sendcontext,
'', $upload_dir_tmp);
693 if ($mailfile->error) {
694 $resaction .=
'<div class="error">'.$mailfile->error.
'</div>';
696 $result = $mailfile->sendfile();
698 $resaction .= $langs->trans(
'MailSuccessfulySent', $mailfile->getValidAddress($mailfile->addr_from, 2), $mailfile->getValidAddress($mailfile->addr_to, 2)).
'<br>';
703 foreach ($listofqualifiedobj as $objid2 => $objectobj2) {
704 if ((!$oneemailperrecipient) && $objid2 != $objectid) {
708 dol_syslog(
"Try to insert email event into agenda for objid=".$objid2.
" => objectobj=".get_class($objectobj2));
717 $actionmsg = $langs->transnoentities(
'MailSentByTo', $email_from, (
string) $sendto);
720 $actionmsg =
dol_concatdesc($actionmsg, $langs->transnoentities(
'Bcc').
": ".$sendtocc);
722 $actionmsg =
dol_concatdesc($actionmsg, $langs->transnoentities(
'MailTopic').
": ".$subjectreplaced);
723 $actionmsg =
dol_concatdesc($actionmsg, $langs->transnoentities(
'TextUsedInTheMessageBody').
":");
729 $objectobj2->sendtoid = (empty($contactidtosend) ? 0 : $contactidtosend);
730 $objectobj2->actionmsg = $actionmsg;
731 $objectobj2->actionmsg2 = $actionmsg2;
732 $objectobj2->fk_element = $objid2;
733 $objectobj2->elementtype = $objectobj2->element;
735 $objectobj2->actionmsg2 = $subjectreplaced;
738 $triggername = strtoupper(get_class($objectobj2)).
'_SENTBYMAIL';
739 if ($triggername ==
'SOCIETE_SENTBYMAIL') {
740 $triggername =
'COMPANY_SENTBYMAIL';
742 if ($triggername ==
'CONTRAT_SENTBYMAIL') {
743 $triggername =
'CONTRACT_SENTBYMAIL';
745 if ($triggername ==
'COMMANDE_SENTBYMAIL') {
746 $triggername =
'ORDER_SENTBYMAIL';
748 if ($triggername ==
'FACTURE_SENTBYMAIL') {
749 $triggername =
'BILL_SENTBYMAIL';
751 if ($triggername ==
'EXPEDITION_SENTBYMAIL') {
752 $triggername =
'SHIPPING_SENTBYMAIL';
754 if ($triggername ==
'COMMANDEFOURNISSEUR_SENTBYMAIL') {
755 $triggername =
'ORDER_SUPPLIER_SENTBYMAIL';
757 if ($triggername ==
'FACTUREFOURNISSEUR_SENTBYMAIL') {
758 $triggername =
'BILL_SUPPLIER_SENTBYMAIL';
760 if ($triggername ==
'SUPPLIERPROPOSAL_SENTBYMAIL') {
761 $triggername =
'PROPOSAL_SUPPLIER_SENTBYMAIL';
763 if ($triggername ==
'PROJET_SENTBYMAIL') {
764 $triggername =
'PROJECT_SENTBYMAIL';
767 if (!empty($triggername)) {
769 $result = $objectobj2->call_trigger($triggername, $user);
777 dol_syslog(
"Error in trigger ".$triggername.
' '.
$db->lasterror(), LOG_ERR);
784 $langs->load(
"other");
785 if ($mailfile->error) {
786 $resaction .= $langs->trans(
'ErrorFailedToSendMail', $email_from, (
string) $sendto);
787 $resaction .=
'<br><div class="error">'.$mailfile->error.
'</div>';
789 $resaction .=
'<div class="warning">No mail sent. Feature is disabled by option MAIN_DISABLE_ALL_MAILS</div>';
791 $resaction .= $langs->trans(
'ErrorFailedToSendMail', $email_from, (
string) $sendto) .
'<br><div class="error">(unhandled error)</div>';
799 $resaction .= ($resaction ?
'<br>' : $resaction);
800 $resaction .=
'<strong>'.$langs->trans(
"ResultOfMailSending").
':</strong><br>'.
"\n";
801 $resaction .= $langs->trans(
"NbSelected").
': '.count($toselect).
"\n<br>";
802 $resaction .= $langs->trans(
"NbIgnored").
': '.($nbignored ? $nbignored : 0).
"\n<br>";
803 $resaction .= $langs->trans(
"NbSent").
': '.($nbsent ? $nbsent : 0).
"\n<br>";
808 setEventMessages($langs->trans(
"EMailSentForNElements", $nbsent.
'/'.count($toselect)),
null,
'mesgs');
821if (!$error && $massaction ==
'cancelorders' && !empty($permissiontocancel)) {
826 $orders =
GETPOST(
'toselect',
'array:int');
827 foreach ($orders as $id_order) {
829 if ($cmd->fetch($id_order) <= 0) {
840 $langs->load(
'errors');
841 setEventMessages($langs->trans(
"ErrorObjectMustHaveStatusValidToBeCanceled", $cmd->ref),
null,
'errors');
846 $result = $cmd->cancel($user);
866if (!$error && $massaction ==
"builddoc" && $permissiontoread && !
GETPOST(
'button_search')) {
867 if (empty($diroutputmassaction)) {
868 dol_print_error(
null,
'include of actions_massactions.inc.php is done but var $diroutputmassaction was not defined');
872 require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
873 require_once DOL_DOCUMENT_ROOT.
'/core/lib/pdf.lib.php';
874 require_once DOL_DOCUMENT_ROOT.
'/core/lib/date.lib.php';
876 $objecttmp =
new $objectclass(
$db);
877 $listofobjectid = array();
878 $listofobjectthirdparties = array();
879 $listofobjectref = array();
880 foreach ($toselect as $toselectid) {
881 $objecttmp =
new $objectclass(
$db);
882 $result = $objecttmp->fetch($toselectid);
884 $listofobjectid[$toselectid] = $toselectid;
885 $thirdpartyid = !empty($objecttmp->fk_soc) ? $objecttmp->fk_soc : $objecttmp->socid;
886 $listofobjectthirdparties[$thirdpartyid] = $thirdpartyid;
887 $listofobjectref[$toselectid] = $objecttmp->ref;
891 $arrayofinclusion = array();
893 'listofobjectref' => $listofobjectref,
894 'arrayofinclusion' => &$arrayofinclusion,
896 $reshook = $hookmanager->executeHooks(
'updateSearchRegexToMergeDoc', $parameters,
$object, $action);
898 if (empty($reshook)) {
899 foreach ($listofobjectref as $tmppdf) {
902 foreach ($listofobjectref as $tmppdf) {
903 $arrayofinclusion[] =
'^'.preg_quote(
dol_sanitizeFileName($tmppdf),
'/').
'_[\w\-\'\&\.]+\.pdf$';
907 $listoffiles =
dol_dir_list($uploaddir,
'all', 1, $arrayofinclusion,
'\.meta$|\.png$',
'date', SORT_DESC, 0, 1);
909 dol_syslog(
"Found ".count($listoffiles).
" files");
914 foreach ($listofobjectref as $basename) {
916 foreach ($listoffiles as $filefound) {
917 if (strstr($filefound[
"name"], $basename)) {
918 $files[] = $filefound[
'fullname'];
925 $outputlangs = $langs;
928 $newlang =
GETPOST(
'lang_id',
'aZ09');
933 if (!empty($newlang)) {
935 $outputlangs->setDefaultLang($newlang);
944 $filename = preg_replace(
'/\s/',
'_', $filename);
947 if (in_array($objecttmp->element, array(
'facture',
'invoice_supplier')) && $search_status == $objecttmp::STATUS_VALIDATED) {
948 if ($option ==
'late') {
955 $filename .=
'_'.$year;
958 $filename .=
'_'.$month;
961 if (count($files) > 0) {
963 $file = $diroutputmassaction.
'/'.$filename.
'_'.
dol_print_date($now,
'dayhourlog').
'.pdf';
966 foreach ($files as $f) {
967 $input_files .=
' '.escapeshellarg($f);
970 $cmd =
'pdftk '.$input_files.
' cat output '.escapeshellarg($file);
974 if (file_exists($file)) {
977 $langs->load(
"exports");
980 setEventMessages($langs->trans(
'ErrorPDFTkOutputFileNotFound'),
null,
'errors');
983 setEventMessages($langs->trans(
'NoPDFAvailableForDocGenAmongChecked'),
null,
'errors');
988 $page_largeur = $formatarray[
'width'];
989 $page_hauteur = $formatarray[
'height'];
990 $format = array($page_largeur, $page_hauteur);
994 if (class_exists(
'TCPDF')) {
995 $pdf->setPrintHeader(
false);
996 $pdf->setPrintFooter(
false);
1001 $pdf->SetCompression(
false);
1006 foreach ($files as $file) {
1008 $pagecount = $pdf->setSourceFile($file);
1009 for ($i = 1; $i <= $pagecount; $i++) {
1010 $tplidx = $pdf->importPage($i);
1011 $s = $pdf->getTemplatesize($tplidx);
1012 $pdf->AddPage($s[
'h'] > $s[
'w'] ?
'P' :
'L');
1013 $pdf->useTemplate($tplidx);
1022 $filename = preg_replace(
'/\s/',
'_', $filename);
1026 if (in_array($objecttmp->element, array(
'facture',
'invoice_supplier')) && $search_status == $objecttmp::STATUS_VALIDATED) {
1027 if ($option ==
'late') {
1033 if (!empty($year)) {
1034 $filename .=
'_'.$year;
1036 if (!empty($month)) {
1037 $filename .=
'_'.$month;
1041 $file = $diroutputmassaction.
'/'.$filename.
'_'.
dol_print_date($now,
'dayhourlog').
'.pdf';
1042 $pdf->Output($file,
'F');
1045 $langs->load(
"exports");
1048 setEventMessages($langs->trans(
'NoPDFAvailableForDocGenAmongChecked'),
null,
'errors');
1054if ($action ==
'remove_file') {
1055 require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
1057 $langs->load(
"other");
1058 $upload_dir = $diroutputmassaction;
1059 $file = $upload_dir.
'/'.
GETPOST(
'file');
1071if (!$error && $massaction ==
'validate' && $permissiontoadd) {
1072 $objecttmp =
new $objectclass(
$db);
1074 if (($objecttmp->element ==
'facture' || $objecttmp->element ==
'invoice') &&
isModEnabled(
'stock') &&
getDolGlobalString(
'STOCK_CALCULATE_ON_BILL')) {
1075 $langs->load(
"errors");
1076 setEventMessages($langs->trans(
'ErrorMassValidationNotAllowedWhenStockIncreaseOnAction'),
null,
'errors');
1080 $langs->load(
"errors");
1081 setEventMessages($langs->trans(
'ErrorMassValidationNotAllowedWhenStockIncreaseOnAction'),
null,
'errors');
1084 if ($objecttmp->element ==
'facture') {
1087 $sql =
"SELECT rowid FROM ".MAIN_DB_PREFIX.
"facture";
1088 $sql .=
" WHERE rowid IN (".$db->sanitize(implode(
",", $toselect)).
")";
1089 $sql .=
" ORDER BY datef";
1091 $resql =
$db->query($sql);
1094 while (!empty($arr =
$db->fetch_row($resql))) {
1095 $toselectnew[] = $arr[0];
1097 $toselect = (empty($toselectnew)) ? $toselect : $toselectnew;
1111 $perrecordtransaction = (int)
getDolGlobalInt(
'MAIN_MASSVALIDATE_'.strtoupper($objectclass).
'_NO_GLOBAL_TRANSACTION');
1112 if (!$perrecordtransaction) {
1117 foreach ($toselect as $toselectid) {
1118 if ($perrecordtransaction) {
1121 $result = $objecttmp->fetch($toselectid);
1123 if (method_exists($objecttmp,
'validate')) {
1124 $result = $objecttmp->validate($user);
1125 } elseif (method_exists($objecttmp,
'setValid')) {
1126 $result = $objecttmp->setValid($user);
1128 $objecttmp->error =
'No method validate or setValid on this object';
1132 $langs->load(
"errors");
1133 setEventMessages($langs->trans(
"ErrorObjectMustHaveStatusDraftToBeValidated", $objecttmp->ref),
null,
'errors');
1135 if ($perrecordtransaction) {
1139 } elseif ($result < 0) {
1142 if ($perrecordtransaction) {
1150 $outputlangs = $langs;
1153 $newlang =
GETPOST(
'lang_id',
'aZ09');
1155 if (
getDolGlobalInt(
'MAIN_MULTILANGS') && empty($newlang) && property_exists($objecttmp,
'thirdparty')) {
1156 if ((property_exists($objecttmp,
'socid') || property_exists($objecttmp,
'fk_soc')) && empty($objecttmp->thirdparty)) {
1157 $objecttmp->fetch_thirdparty();
1159 if (!empty($objecttmp->thirdparty)) {
1160 $newlang = $objecttmp->thirdparty->default_lang;
1163 if (!empty($newlang)) {
1165 $outputlangs->setDefaultLang($newlang);
1166 $outputlangs->load(
'products');
1168 $model = $objecttmp->model_pdf;
1169 $ret = $objecttmp->fetch($objecttmp->id);
1172 $hidedetails = isset($hidedetails) ? $hidedetails : (
getDolGlobalString(
'MAIN_GENERATE_DOCUMENTS_HIDE_DETAILS') ? 1 : 0);
1173 $hidedesc = isset($hidedesc) ? $hidedesc : (
getDolGlobalString(
'MAIN_GENERATE_DOCUMENTS_HIDE_DESC') ? 1 : 0);
1174 $hideref = isset($hideref) ? $hideref : (
getDolGlobalString(
'MAIN_GENERATE_DOCUMENTS_HIDE_REF') ? 1 : 0);
1175 $moreparams = isset($moreparams) ? $moreparams :
null;
1177 $result = $objecttmp->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref, $moreparams);
1183 if ($perrecordtransaction) {
1190 if ($perrecordtransaction) {
1201 setEventMessages($langs->trans(
"RecordModifiedSuccessfully"),
null,
'mesgs');
1203 if (!$perrecordtransaction) {
1206 } elseif (!$perrecordtransaction) {
1213if (!$error && ($massaction ==
'delete' || ($action ==
'delete' && $confirm ==
'yes')) && $permissiontodelete) {
1216 $objecttmp =
new $objectclass(
$db);
1223 $unique_arr = array_unique($toselect);
1224 foreach ($unique_arr as $toselectid) {
1225 $result = $objecttmp->fetch($toselectid);
1229 $langs->load(
"errors");
1231 $TMsg[] =
'<div class="error">'.$langs->trans(
'ErrorOnlyDraftStatusCanBeDeletedInMassAction', $objecttmp->ref).
'</div><br>';
1235 if (method_exists($objecttmp,
'is_erasable') && $objecttmp->is_erasable() <= 0) {
1236 $langs->load(
"errors");
1238 $TMsg[] =
'<div class="error">'.$langs->trans(
'ErrorRecordHasChildren').
' '.$objecttmp->ref.
'</div><br>';
1243 $langs->load(
"errors");
1245 $TMsg[] =
'<div class="error">'.$langs->trans(
'ErrorLeaveRequestMustBeDraftCanceledOrRefusedToBeDeleted', $objecttmp->ref).
'</div><br>';
1249 if ($objectclass ==
"Task" && $objecttmp->hasChildren() > 0) {
1250 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"projet_task SET fk_task_parent = 0 WHERE fk_task_parent = ".((int) $objecttmp->id);
1251 $res =
$db->query($sql);
1259 if ($objecttmp->element ==
'societe') {
1261 '@phan-var-force Societe $objecttmp';
1263 $result = $objecttmp->delete($objecttmp->id, $user, 1);
1265 $objecttmp->oldcopy =
dol_clone($objecttmp);
1266 $result = $objecttmp->delete($user);
1269 if (empty($result)) {
1270 $TMsg = array_merge($objecttmp->errors, $TMsg);
1271 } elseif ($result < 0) {
1285 if (empty($error)) {
1289 } elseif ($nbok > 0) {
1296 if (!empty($TMsg)) {
1309if (!$error && $massaction ==
'generate_doc' && $permissiontoread) {
1312@phan-var-force
'Commande'|
'CommandeFournisseur'|
'Contrat'|
'Expedition'|
'ExpenseReport'|
'Facture'|
'FactureFournisseur'|
'Fichinter'|
'Project'|
'Propal'|
'SupplierProposal' $objectclass
1318 $objecttmp =
new $objectclass(
$db);
1320 foreach ($toselect as $toselectid) {
1321 $objecttmp->thirdparty =
null;
1322 $result = $objecttmp->fetch($toselectid);
1325 $outputlangs = $langs;
1329 $newlang =
GETPOST(
'lang_id',
'aZ09');
1331 if (
getDolGlobalInt(
'MAIN_MULTILANGS') && empty($newlang) && isset($objecttmp->thirdparty->default_lang)) {
1332 $newlang = $objecttmp->thirdparty->default_lang;
1334 if (
getDolGlobalInt(
'MAIN_MULTILANGS') && empty($newlang) && isset($objecttmp->default_lang)) {
1335 $newlang = $objecttmp->default_lang;
1337 if (
getDolGlobalInt(
'MAIN_MULTILANGS') && empty($newlang) && empty($objecttmp->thirdparty)) {
1338 $objecttmp->fetch_thirdparty();
1339 $newlang = $objecttmp->thirdparty->default_lang;
1341 if (!empty($newlang)) {
1343 $outputlangs->setDefaultLang($newlang);
1347 $hidedetails = isset($hidedetails) ? $hidedetails : (
getDolGlobalString(
'MAIN_GENERATE_DOCUMENTS_HIDE_DETAILS') ? 1 : 0);
1348 $hidedesc = isset($hidedesc) ? $hidedesc : (
getDolGlobalString(
'MAIN_GENERATE_DOCUMENTS_HIDE_DESC') ? 1 : 0);
1349 $hideref = isset($hideref) ? $hideref : (
getDolGlobalString(
'MAIN_GENERATE_DOCUMENTS_HIDE_REF') ? 1 : 0);
1350 $moreparams = isset($moreparams) ? $moreparams :
null;
1352 $result = $objecttmp->generateDocument($objecttmp->model_pdf, $outputlangs, $hidedetails, $hidedesc, $hideref, $moreparams);
1380if (!$error && ($action ==
'affecttag' && $confirm ==
'yes') && $permissiontoadd) {
1384 $affecttag_type =
GETPOST(
'affecttag_type',
'alpha');
1385 if (!empty($affecttag_type)) {
1386 $affecttag_type_array = explode(
',', $affecttag_type);
1390 if (!empty($affecttag_type_array)) {
1392 require_once DOL_DOCUMENT_ROOT.
'/categories/class/categorie.class.php';
1394 $to_affecttag_type_array = array();
1395 $categ_type_array = $categ->getMapList();
1396 foreach ($categ_type_array as $categdef) {
1397 if (in_array($categdef[
'code'], $affecttag_type_array)) {
1398 $to_affecttag_type_array[] = $categdef[
'code'];
1403 if (!empty($to_affecttag_type_array)) {
1404 foreach ($to_affecttag_type_array as $categ_type) {
1405 $contcats =
GETPOST(
'contcats_' . $categ_type,
'array');
1406 foreach ($toselect as $toselectid) {
1407 $result =
$object->fetch($toselectid);
1409 $result =
$object->setCategoriesCommon($contcats, $categ_type,
false);
1428 $toselect = array();
1434if (!$error && ($action ==
'updateprice' && $confirm ==
'yes') && $permissiontoadd) {
1435 '@phan-var-force Product|ProductCustomerPrice $obj';
1436 '@phan-var-force Product|ProductCustomerPrice $object';
1441 if ($pricepercentage == 0) {
1444 foreach ($toselect as $toselectid) {
1445 $result =
$object->fetch($toselectid);
1449 if (
$object->price_base_type ==
'TTC') {
1450 $newprice =
$object->price_ttc * (100 + $pricepercentage) / 100;
1451 $minprice =
$object->price_min_ttc;
1453 $newprice =
$object->price * (100 + $pricepercentage) / 100;
1454 $minprice =
$object->price_min;
1456 $res =
$object->updatePrice($newprice,
$object->price_base_type, $user,
$object->tva_tx, $minprice, 0,
$object->tva_npr, 0, 0, array(),
$object->default_vat_code);
1464 for ($level = 1; $level <= $maxlevel; $level++) {
1465 if (
$object->price_base_type ==
'TTC') {
1466 $newprice =
$object->multiprices_ttc[$level] * (100 + $pricepercentage) / 100;
1467 $minprice =
$object->multiprices_min_ttc[$level];
1469 $newprice =
$object->multiprices[$level] * (100 + $pricepercentage) / 100;
1470 $minprice =
$object->multiprices_min[$level];
1472 $res =
$object->updatePrice($newprice,
$object->price_base_type, $user,
$object->tva_tx, $minprice, $level,
$object->tva_npr, 0, 0, array(),
$object->default_vat_code);
1492 $toselect = array();
1498if (!$error && ($action ==
'setsupervisor' && $confirm ==
'yes') && $permissiontoadd) {
1499 '@phan-var-force User $object';
1502 $supervisortoset =
GETPOSTINT(
'supervisortoset');
1503 if (!empty($supervisortoset)) {
1504 foreach ($toselect as $toselectid) {
1505 $result =
$object->fetch($toselectid);
1507 $object->fk_user = $supervisortoset;
1508 $res =
$object->update($user);
1528 $toselect = array();
1534if (!$error && ($action ==
'affectuser' && $confirm ==
'yes') && $permissiontoadd) {
1539 $projectrole =
GETPOST(
'projectrole');
1540 $tasksrole =
GETPOST(
'tasksrole');
1541 if (!empty($usertoaffect)) {
1542 foreach ($toselect as $toselectid) {
1543 $result =
$object->fetch($toselectid);
1545 $res =
$object->add_contact($usertoaffect, $projectrole,
'internal');
1548 $task_array = $taskstatic->getTasksArray(
null,
null,
$object->id, 0, 0);
1550 foreach ($task_array as $task) {
1551 $tasksToAffect =
new Task(
$db);
1552 $result = $tasksToAffect->fetch($task->id);
1554 $res = $tasksToAffect->add_contact($usertoaffect, $tasksrole,
'internal');
1578 $toselect = array();
1584if (!$error && ($massaction ==
'enable' || ($action ==
'enable' && $confirm ==
'yes')) && $permissiontoadd) {
1587 $objecttmp =
new $objectclass(
$db);
1589 foreach ($toselect as $toselectid) {
1590 $result = $objecttmp->fetch($toselectid);
1592 if (in_array($objecttmp->element, array(
'societe'))) {
1593 $result = $objecttmp->setStatut(1);
1621if (!$error && ($massaction ==
'disable' || ($action ==
'disable' && $confirm ==
'yes')) && $permissiontoadd) {
1624 $objecttmp =
new $objectclass(
$db);
1626 foreach ($toselect as $toselectid) {
1627 $result = $objecttmp->fetch($toselectid);
1629 if (in_array($objecttmp->element, array(
'societe'))) {
1630 $result = $objecttmp->setStatut(0);
1658if (!$error && $action ==
'confirm_edit_value_extrafields' && $confirm ==
'yes' && $permissiontoadd) {
1661 $objecttmp =
new $objectclass(
$db);
1663 $e->fetch_name_optionals_label($objecttmp->table_element);
1666 $extrafieldKeyToUpdate =
GETPOST(
'extrafield-key-to-update');
1669 foreach ($toselect as $toselectid) {
1671 $objecttmp =
new $objectclass(
$db);
1672 $result = $objecttmp->fetch($toselectid);
1675 $ret = $e->setOptionalsFromPost(
null, $objecttmp, $extrafieldKeyToUpdate);
1677 $objecttmp->insertExtraFields();
1693 } elseif ($nbok == 1) {
1694 setEventMessages($langs->trans(
"RecordModifiedSuccessfully"),
null,
'mesgs');
1702if (!$error && ($massaction ==
'assignsalerepresentative' || ($action ==
'assignsalerepresentative' && $confirm ==
'yes')) && $permissiontoadd) {
1705 $objecttmp =
new $objectclass(
$db);
1708 foreach ($toselect as $toselectid) {
1709 $result = $objecttmp->fetch($toselectid);
1711 if (in_array($objecttmp->element, array(
'societe'))) {
1712 $result = $objecttmp->setSalesRep(
GETPOST(
"commercial",
"alpha"));
1730 setEventMessages($langs->trans(
"CommercialsAffected", $nbok),
null,
'mesgs');
1740if (!$error && ($massaction ==
'unassigncommercial' || ($action ==
'unassigncommercial' && $confirm ==
'yes')) && $permissiontoadd) {
1743 $objecttmp =
new $objectclass(
$db);
1746 foreach ($toselect as $toselectid) {
1747 $result = $objecttmp->fetch($toselectid);
1749 if (in_array($objecttmp->element, array(
'societe'))) {
1750 $TCommercial =
GETPOST(
"commercial",
"alpha");
1751 if (is_array($TCommercial)) {
1752 foreach ($TCommercial as $commercial) {
1753 $result = $objecttmp->del_commercial($user, $commercial);
1773 setEventMessages($langs->trans(
"CommercialsDisaffected", $nbok),
null,
'mesgs');
1783if (!$error && ($massaction ==
'approveleave' || ($action ==
'approveleave' && $confirm ==
'yes')) && $permissiontoapprove) {
1786 $objecttmp =
new $objectclass(
$db);
1787 '@phan-var-force Holiday $objecttmp';
1789 foreach ($toselect as $toselectid) {
1790 $result = $objecttmp->fetch($toselectid);
1793 setEventMessages($langs->trans(
'StatusOfRefMustBe', $objecttmp->ref, $langs->transnoentitiesnoconv(
'Validated')),
null,
'warnings');
1796 if ($user->id == $objecttmp->fk_validator) {
1797 $objecttmp->oldcopy =
dol_clone($objecttmp, 2);
1799 $objecttmp->date_valid =
dol_now();
1800 $objecttmp->fk_user_valid = $user->id;
1801 $objecttmp->date_approval =
dol_now();
1802 $objecttmp->fk_user_approve = $user->id;
1804 $objecttmp->statut = $objecttmp->status;
1806 $verif = $objecttmp->approve($user);
1818 $result = $tmpUser->fetch($objecttmp->fk_user);
1821 $nbopenedday =
num_open_day($objecttmp->date_debut_gmt, $objecttmp->date_fin_gmt, 0, 1, $objecttmp->halfday, $tmpUser->country_id);
1822 $soldeActuel = $objecttmp->getCpforUser($objecttmp->fk_user, $objecttmp->fk_type);
1823 $newSolde = ($soldeActuel - $nbopenedday);
1828 $result = $objecttmp->addLogCP($user->id, $objecttmp->fk_user, $langs->transnoentitiesnoconv(
"Holidays"), $newSolde, $objecttmp->fk_type);
1835 $result = $objecttmp->updateSoldeCP($objecttmp->fk_user, $newSolde, $objecttmp->fk_type);
1845 $destinataire =
new User(
$db);
1846 $destinataire->fetch($objecttmp->fk_user);
1847 $emailTo = $destinataire->email;
1850 dol_syslog(
"User that request leave has no email, so we redirect directly to finished page without sending email");
1854 $expediteur->fetch($objecttmp->fk_validator);
1864 $subject = $societeName.
" - ".$langs->transnoentitiesnoconv(
"HolidaysValidated");
1867 $message = $langs->transnoentitiesnoconv(
"Hello").
" ".$destinataire->firstname.
",\n";
1870 $message .= $langs->transnoentities(
"HolidaysValidatedBody",
dol_print_date($objecttmp->date_debut,
'day'),
dol_print_date($objecttmp->date_fin,
'day')).
"\n";
1872 $message .=
"- ".$langs->transnoentitiesnoconv(
"ValidatedBy").
" : ".
dolGetFirstLastname($expediteur->firstname, $expediteur->lastname).
"\n";
1874 $message .=
"- ".$langs->transnoentitiesnoconv(
"Link").
" : ".
$dolibarr_main_url_root.
"/holiday/card.php?id=".$objecttmp->id.
"\n\n";
1877 $trackid =
'leav'.$objecttmp->id;
1879 require_once DOL_DOCUMENT_ROOT.
'/core/class/CMailFile.class.php';
1880 $mail =
new CMailFile($subject, $emailTo, $emailFrom, $message, array(), array(), array(),
'',
'', 0, 0,
'',
'', $trackid);
1883 $result = $mail->sendfile();
1892 $langs->load(
"errors");
1893 setEventMessages($langs->trans(
'ErrorNotApproverForHoliday', $objecttmp->ref),
null,
'errors');
1905 } elseif ($nbok == 1) {
1915if (!$error && ($massaction ==
'increaseholiday' || ($action ==
'increaseholiday' && $confirm ==
'yes')) && $user->hasRight(
'holiday',
'define_holiday') && is_array($toselect)) {
1916 '@phan-var-force Holiday $holiday';
1919 $objecttmp =
new $objectclass(
$db);
1924 if ($nbdaysholidays <= 0) {
1930 foreach ($toselect as $toselectid) {
1931 $balancecpuser = $objecttmp->getCPforUser($toselectid, $typeholiday);
1932 if (!empty($balancecpuser)) {
1933 $newnbdaysholidays = $nbdaysholidays + $balancecpuser;
1935 $newnbdaysholidays = $nbdaysholidays;
1937 $result = $holiday->addLogCP($user->id, $toselectid, $langs->transnoentitiesnoconv(
'ManualUpdate'), $newnbdaysholidays, $typeholiday);
1944 $objecttmp->updateSoldeCP($toselectid, $newnbdaysholidays, $typeholiday);
1957 setEventMessages($langs->trans(
"HolidayRecordsIncreased", $nbok),
null,
'mesgs');
1958 } elseif ($nbok == 1) {
1962 $toselect = array();
1969if (!$error && ($massaction ==
'clonetasks' || ($action ==
'clonetasks' && $confirm ==
'yes'))) {
1972 include_once DOL_DOCUMENT_ROOT.
'/projet/class/task.class.php';
1980 $iscontactofnewproject = 0;
1981 if (empty($newproject->public)) {
1982 $tmps = $newproject->getProjectsAuthorizedForUser($user, 0, 1, 0,
'(fk_statut:=:1)');
1983 $tmparray = explode(
',', $tmps);
1984 if (in_array($newproject->id, $tmparray)) {
1985 $iscontactofnewproject = 1;
1990 $permisstiontoadd =
false;
1991 if ($user->hasRight(
'project',
'all',
'creer') || ($user->hasRight(
'project',
'creer') && ($newproject->public || $iscontactofnewproject))) {
1992 $permisstiontoadd =
true;
1995 if ($permisstiontoadd) {
1996 $taskidsmapping = array();
1997 $clonedtaskoldparent = array();
2002 $authorizedsourceprojects =
null;
2003 if (!$user->hasRight(
'projet',
'all',
'lire')) {
2005 $tmps = $sourceprojectstatic->getProjectsAuthorizedForUser($user, 0, 1, 0);
2006 $authorizedsourceprojects = explode(
',', $tmps);
2009 foreach (
GETPOST(
'selected') as $task) {
2010 if ($origin_task->fetch($task,
'', 0) <= 0) {
2015 if (is_array($authorizedsourceprojects) && !in_array($origin_task->fk_project, $authorizedsourceprojects)) {
2024 require_once DOL_DOCUMENT_ROOT .
"/core/modules/project/task/" .
getDolGlobalString(
'PROJECT_TASK_ADDON') .
'.php';
2025 $modTask =
new $classnamemodtask();
2026 '@phan-var-force ModeleNumRefTask $modTask';
2028 $defaultref = $modTask->getNextValue(
null, $clone_task);
2032 $clone_task->fk_project =
GETPOSTINT(
'projectid');
2033 $clone_task->ref = $defaultref;
2034 $clone_task->label = $origin_task->label;
2035 $clone_task->description = $origin_task->description;
2036 $clone_task->planned_workload = $origin_task->planned_workload;
2037 $clone_task->fk_task_parent = $origin_task->fk_task_parent;
2038 $clone_task->date_c =
dol_now();
2039 $clone_task->date_start = $origin_task->date_start;
2040 $clone_task->date_end = $origin_task->date_end;
2041 $clone_task->progress = $origin_task->progress;
2044 $ret = $extrafields->setOptionalsFromPost(
null, $clone_task);
2046 $taskid = $clone_task->create($user);
2049 $result = $clone_task->add_contact(
GETPOSTINT(
"userid"),
'TASKEXECUTIVE',
'internal');
2050 $taskidsmapping[$task] = $taskid;
2051 $clonedtaskoldparent[$taskid] = $origin_task->fk_task_parent;
2054 if (
$db->lasterrno() ==
'DB_ERROR_RECORD_ALREADY_EXISTS') {
2055 $langs->load(
"projects");
2057 $duplicate_code_error =
true;
2071 foreach ($clonedtaskoldparent as $newtaskid => $oldparentid) {
2072 if (empty($oldparentid)) {
2075 $newparentid = isset($taskidsmapping[$oldparentid]) ? $taskidsmapping[$oldparentid] : 0;
2077 if ($remaptask->fetch($newtaskid) > 0 && $remaptask->fk_task_parent != $newparentid) {
2078 $remaptask->fk_task_parent = $newparentid;
2079 if ($remaptask->update($user) < 0) {
2088 setEventMessages($langs->trans(
'NumberOfTasksCloned', $num),
null,
'mesgs');
2089 header(
"Location: ".DOL_URL_ROOT.
'/projet/tasks.php?id='.
GETPOSTINT(
'projectid'));
2097if (!$error && $action ==
'createcreditnote' && $permissiontoadd) {
2100 setEventMessages($langs->trans(
'CreditNoteNotCreatedStockCalculateOnBillEnabled'),
null,
'errors');
2101 header(
"Location: ".DOL_URL_ROOT.
'/compta/facture/list.php?mainmenu=compta&leftmenu=facture');
2105 $objecttmp =
new $objectclass(
$db);
2106 if ($objecttmp->element ==
'facture' || $objecttmp->element ==
'invoice') {
2111 $unique_arr = array_unique($toselect);
2112 foreach ($unique_arr as $toselectid) {
2113 $sourceinvoice = $toselectid;
2114 $result = $objecttmp->fetch($sourceinvoice);
2119 $TMsg[] = $langs->trans(
'CreditNoteNotCreatedSourceInvoiceNotFound', $sourceinvoice);
2124 $isSupportedType =
false;
2126 $isSupportedType =
true;
2129 $isSupportedType =
true;
2132 $isSupportedType =
true;
2135 if (!$isSupportedType) {
2144 $TMsg[] = $langs->trans(
'CreditNoteNotCreatedInvoiceTypeNotSupported', $objecttmp->ref, $listtype[$objecttmp->type]);
2150 $TMsg[] = $langs->trans(
'CreditNoteNotCreatedInvoiceNotValidated', $objecttmp->ref);
2155 $totalpaid = $objecttmp->getSommePaiement();
2156 $totalcreditnotes = $objecttmp->getSumCreditNotesUsed();
2157 $totaldeposits = $objecttmp->getSumDepositsUsed();
2158 if ($totalpaid > 0) {
2159 $TMsg[] = $langs->trans(
'CreditNoteNotCreatedPaymentAlreadyDone', $objecttmp->ref);
2162 if ($totalcreditnotes > 0) {
2163 $TMsg[] = $langs->trans(
'CreditNoteNotCreatedCreditNoteAlreadyUsed', $objecttmp->ref);
2166 if ($totaldeposits > 0) {
2167 $TMsg[] = $langs->trans(
'CreditNoteNotCreatedDepositAlreadyUsed', $objecttmp->ref);
2175 $object->entity = $objecttmp->entity;
2176 $object->socid = $objecttmp->socid;
2177 $object->subtype = $objecttmp->subtype;
2181 $object->ref_client = $objecttmp->ref_client;
2182 $object->ref_customer = $objecttmp->ref_customer;
2183 $object->fk_project = $objecttmp->fk_project;
2184 $object->cond_reglement_id = 0;
2185 $object->fk_account = $objecttmp->fk_account;
2186 $object->fk_incoterms = $objecttmp->fk_incoterms;
2187 $object->location_incoterms = $objecttmp->location_incoterms;
2188 $object->multicurrency_code = $objecttmp->multicurrency_code;
2189 $object->multicurrency_tx = $objecttmp->multicurrency_tx;
2191 $object->fk_facture_source = $sourceinvoice;
2195 if ($objecttmp->isSituationInvoice()) {
2196 $object->situation_counter = $objecttmp->situation_counter;
2197 $object->situation_cycle_ref = $objecttmp->situation_cycle_ref;
2198 $objecttmp->fetchPreviousNextSituationInvoice();
2205 $TMsg[] = $langs->trans(
'CreditNoteNotCreated', $objecttmp->ref);
2209 $facture_source = $objecttmp;
2212 $object->copy_linked_contact($objecttmp,
'internal');
2213 $object->copy_linked_contact($objecttmp,
'external');
2216 if (!empty($facture_source->lines)) {
2217 $fk_parent_line = 0;
2219 foreach ($facture_source->lines as $line) {
2221 if (method_exists($line,
'fetch_optionals')) {
2223 $line->fetch_optionals();
2227 if (($line->product_type != 9 && empty($line->fk_parent_line)) || $line->product_type == 9) {
2228 $fk_parent_line = 0;
2231 if ($facture_source->isSituationInvoice()) {
2232 $source_fk_prev_id = $line->fk_prev_id;
2233 $line->fk_prev_id = $line->id;
2235 if (!empty($facture_source->tab_previous_situation_invoice)) {
2238 $tab_jumped_credit_notes = array();
2239 $lineIndex = count($facture_source->tab_previous_situation_invoice) - 1;
2240 $searchPreviousInvoice =
true;
2241 while ($searchPreviousInvoice) {
2242 if ($facture_source->tab_previous_situation_invoice[$lineIndex]->type ==
Facture::TYPE_SITUATION || $lineIndex < 1) {
2243 $searchPreviousInvoice =
false;
2247 $tab_jumped_credit_notes[$lineIndex] = $facture_source->tab_previous_situation_invoice[$lineIndex]->id;
2253 $maxPrevSituationPercent = 0;
2254 foreach ($facture_source->tab_previous_situation_invoice[$lineIndex]->lines as $prevLine) {
2255 if ($prevLine->id == $source_fk_prev_id) {
2256 $maxPrevSituationPercent = max($maxPrevSituationPercent, $prevLine->situation_percent);
2259 $line->total_ht -= $prevLine->total_ht;
2260 $line->total_tva -= $prevLine->total_tva;
2261 $line->total_ttc -= $prevLine->total_ttc;
2262 $line->total_localtax1 -= $prevLine->total_localtax1;
2263 $line->total_localtax2 -= $prevLine->total_localtax2;
2265 $line->multicurrency_subprice -= $prevLine->multicurrency_subprice;
2266 $line->multicurrency_total_ht -= $prevLine->multicurrency_total_ht;
2267 $line->multicurrency_total_tva -= $prevLine->multicurrency_total_tva;
2268 $line->multicurrency_total_ttc -= $prevLine->multicurrency_total_ttc;
2273 $line->situation_percent = $maxPrevSituationPercent - $line->situation_percent;
2278 $maxPrevSituationPercent = 0;
2279 foreach ($tab_jumped_credit_notes as $index => $creditnoteid) {
2280 foreach ($facture_source->tab_previous_situation_invoice[$index]->lines as $prevLine) {
2281 if ($prevLine->fk_prev_id == $source_fk_prev_id) {
2282 $maxPrevSituationPercent = $prevLine->situation_percent;
2284 $line->total_ht -= $prevLine->total_ht;
2285 $line->total_tva -= $prevLine->total_tva;
2286 $line->total_ttc -= $prevLine->total_ttc;
2287 $line->total_localtax1 -= $prevLine->total_localtax1;
2288 $line->total_localtax2 -= $prevLine->total_localtax2;
2290 $line->multicurrency_subprice -= $prevLine->multicurrency_subprice;
2291 $line->multicurrency_total_ht -= $prevLine->multicurrency_total_ht;
2292 $line->multicurrency_total_tva -= $prevLine->multicurrency_total_tva;
2293 $line->multicurrency_total_ttc -= $prevLine->multicurrency_total_ttc;
2299 $line->situation_percent += $maxPrevSituationPercent;
2305 $line->fk_facture =
$object->id;
2306 $line->fk_parent_line = $fk_parent_line;
2308 $line->subprice = -$line->subprice;
2310 $line->total_ht = -$line->total_ht;
2311 $line->total_tva = -$line->total_tva;
2312 $line->total_ttc = -$line->total_ttc;
2313 $line->total_localtax1 = -$line->total_localtax1;
2314 $line->total_localtax2 = -$line->total_localtax2;
2316 $line->multicurrency_subprice = -$line->multicurrency_subprice;
2317 $line->multicurrency_total_ht = -$line->multicurrency_total_ht;
2318 $line->multicurrency_total_tva = -$line->multicurrency_total_tva;
2319 $line->multicurrency_total_ttc = -$line->multicurrency_total_ttc;
2321 $line->context[
'createcreditnotefrominvoice'] = 1;
2322 $result = $line->insert(0, 1);
2327 if ($result > 0 && $line->product_type == 9) {
2328 $fk_parent_line = $result;
2336 if (!empty(
$object->fk_facture_source) &&
$id > 0) {
2337 $facture_source->fetch(
$object->fk_facture_source);
2338 $facture_source->fetchObjectLinked();
2340 if (!empty($facture_source->linkedObjectsIds)) {
2341 foreach ($facture_source->linkedObjectsIds as $sourcetype => $TIds) {
2342 $object->add_object_linked($sourcetype, current($TIds));
2348 $result =
$object->validate($user);
2351 $TMsg[] = $langs->trans(
'CreditNoteNotCreatedErrorOnValidation', $objecttmp->ref);
2357 $outputlangs = $langs;
2360 $newlang =
GETPOST(
'lang_id',
'aZ09');
2363 $newlang =
$object->thirdparty->default_lang;
2365 if (!empty($newlang)) {
2367 $outputlangs->setDefaultLang($newlang);
2368 $outputlangs->load(
'products');
2374 $result =
$object->generateDocument($model, $outputlangs, (
int) $hidedetails, (
int) $hidedesc, (
int) $hideref);
2386 $result = $discountcheck->fetch(0,
$object->id);
2389 if (empty($discountcheck->id)) {
2394 $amount_ht = $amount_tva = $amount_ttc = array();
2395 $multicurrency_amount_ht = $multicurrency_amount_tva = $multicurrency_amount_ttc = array();
2399 foreach (
$object->lines as $line) {
2400 if ($line->product_type < 9 && $line->total_ht != 0) {
2401 $keyforvatrate = $line->tva_tx.($line->vat_src_code ?
' ('.$line->vat_src_code.
')' :
'');
2403 if (!isset($amount_ht[$keyforvatrate])) {
2404 $amount_ht[$keyforvatrate] = 0;
2406 $amount_ht[$keyforvatrate] += $line->total_ht;
2407 if (!isset($amount_tva[$keyforvatrate])) {
2408 $amount_tva[$keyforvatrate] = 0;
2410 $amount_tva[$keyforvatrate] += $line->total_tva;
2411 if (!isset($amount_ttc[$keyforvatrate])) {
2412 $amount_ttc[$keyforvatrate] = 0;
2414 $amount_ttc[$keyforvatrate] += $line->total_ttc;
2415 if (!isset($multicurrency_amount_ht[$keyforvatrate])) {
2416 $multicurrency_amount_ht[$keyforvatrate] = 0;
2418 $multicurrency_amount_ht[$keyforvatrate] += $line->multicurrency_total_ht;
2419 if (!isset($multicurrency_amount_tva[$keyforvatrate])) {
2420 $multicurrency_amount_tva[$keyforvatrate] = 0;
2422 $multicurrency_amount_tva[$keyforvatrate] += $line->multicurrency_total_tva;
2423 if (!isset($multicurrency_amount_ttc[$keyforvatrate])) {
2424 $multicurrency_amount_ttc[$keyforvatrate] = 0;
2426 $multicurrency_amount_ttc[$keyforvatrate] += $line->multicurrency_total_ttc;
2433 $discount->description =
'(CREDIT_NOTE)';
2434 $discount->fk_soc =
$object->socid;
2435 $discount->socid =
$object->socid;
2436 $discount->socid =
$object->socid;
2437 $discount->fk_facture_source =
$object->id;
2442 foreach ($amount_ht as $tva_tx => $xxx) {
2443 $discount->amount_ht = -((float) $amount_ht[$tva_tx]);
2444 $discount->amount_tva = -((float) $amount_tva[$tva_tx]);
2445 $discount->amount_ttc = -((float) $amount_ttc[$tva_tx]);
2446 $discount->total_ht = -((float) $amount_ht[$tva_tx]);
2447 $discount->total_tva = -((float) $amount_tva[$tva_tx]);
2448 $discount->total_ttc = -((float) $amount_ttc[$tva_tx]);
2449 $discount->multicurrency_amount_ht = -((float) $multicurrency_amount_ht[$tva_tx]);
2450 $discount->multicurrency_amount_tva = -((float) $multicurrency_amount_tva[$tva_tx]);
2451 $discount->multicurrency_amount_ttc = -((float) $multicurrency_amount_ttc[$tva_tx]);
2452 $discount->multicurrency_total_ht = -((float) $multicurrency_amount_ht[$tva_tx]);
2453 $discount->multicurrency_total_tva = -((float) $multicurrency_amount_tva[$tva_tx]);
2454 $discount->multicurrency_total_ttc = -((float) $multicurrency_amount_ttc[$tva_tx]);
2459 if (preg_match(
'/\((.*)\)/', $tva_tx, $reg)) {
2460 $vat_src_code = $reg[1];
2461 $tva_tx = preg_replace(
'/\s*\(.*\)/',
'', $tva_tx);
2464 $discount->tva_tx = abs((
float) $tva_tx);
2465 $discount->vat_src_code = $vat_src_code;
2467 $id_discount = $discount->create($user);
2468 if ($id_discount < 0) {
2474 if (empty($error) && $id_discount > 0) {
2476 $result =
$object->setPaid($user);
2482 $discount->fetch($id_discount);
2483 $result = $discount->link_to_invoice(0,
$object->fk_facture_source);
2486 $TMsg[] = $langs->trans(
'CreditNoteNotCreatedErrorOnDiscountLink', $objecttmp->ref);
2492 $objecttmp->fetch($objecttmp->id);
2493 if ($objecttmp->getRemainToPay(0) == 0) {
2494 $result = $objecttmp->setPaid($user);
2497 $TMsg[] = $langs->trans(
'CreditNoteNotCreatedErrorOnSetPaidSourceInvoice', $objecttmp->ref);
2502 $outputlangs = $langs;
2505 $newlang =
GETPOST(
'lang_id',
'aZ09');
2508 $objecttmp->fetch_thirdparty();
2509 $newlang = $objecttmp->thirdparty->default_lang;
2511 if (!empty($newlang)) {
2513 $outputlangs->setDefaultLang($newlang);
2515 $ret = $objecttmp->fetch($objecttmp->id);
2517 $result = $objecttmp->generateDocument($objecttmp->model_pdf, $outputlangs, (
int) $hidedetails, (
int) $hidedesc, (
int) $hideref);
2525 $TMsg[] = $langs->trans(
'CreditNoteNotCreatedErrorOnSourceInvoiceNotFullyPaidAfterDiscount', $objecttmp->ref);
2531 $TMsg[] = $langs->trans(
'CreditNoteNotCreatedErrorOnSetPaid', $objecttmp->ref);
2537 $TMsg[] = $langs->trans(
'CreditNoteNotCreatedErrorOnDiscount', $objecttmp->ref);
2542 $TMsg[] = $langs->trans(
'CreditNoteNotCreatedAlreadyConverted', $objecttmp->ref);
2550 $TMsg[] = $langs->trans(
'CreditNoteCreated',
$object->ref, $objecttmp->ref);
2555 foreach ($TMsg as $msg) {
2561 setEventMessages($langs->trans(
'CreditNotesCreated', $nbok),
null,
'mesgs');
2564 $toselect = array();
2565 header(
"Location: ".DOL_URL_ROOT.
'/compta/facture/list.php?mainmenu=compta&leftmenu=facture');
2568 setEventMessages($langs->trans(
'ThisMassActionIsOnlyForInvoices'),
null,
'errors');
2569 header(
"Location: ".DOL_URL_ROOT.
'/compta/facture/list.php?mainmenu=compta&leftmenu=facture');
2574if (empty($toselect)) {
2577$parameters[
'toselect'] = &$toselect;
2578$parameters[
'uploaddir'] = $uploaddir;
2579$parameters[
'massaction'] = $massaction;
2580$parameters[
'diroutputmassaction'] = isset($diroutputmassaction) ? $diroutputmassaction :
null;
2583$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 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.
checkUserAccessToObject($user, array $featuresarray, $object=0, $tableandshare='', $feature2='', $dbt_keyfield='', $dbt_select='rowid', $parenttableforentity='')
Check that access by a given user to an object is ok.
getObjectIdsRefusedToUser(User $user, $object, array $ids)
Return, among a list of ids of objects of the same type, the ids of the objects the user is not allow...
dol_hash($chain, $type='0', $nosalt=0, $mode=0)
Returns a hash (non reversible encryption) of a string.