69@phan-var-force ?string $permissiontoread
70@phan-var-force ?string $permissiontodelete
71@phan-var-force ?string $permissiontoclose
72@phan-var-force ?string $permissiontoapprove
73@phan-var-force ?int[] $toselect
74@phan-var-force ?string $diroutputmassaction
75@phan-var-force ?string $objectlabel
76@phan-var-force ?string $option
77@phan-var-force ?string $deliveryreceipt
82if (empty($objectclass) || empty($uploaddir)) {
83 dol_print_error(
null,
'include of actions_massactions.inc.php is done but var $objectclass or $uploaddir was not defined');
86if (empty($massaction)) {
93@phan-var-force "CommonObject"|"CommandeFournisseur"|"ConferenceOrBoothAttendee"|"Contrat"|"Contact"|"Expedition"|"ExpenseReport"|"Facture"|"FactureFournisseur"|"Fichinter"|"Holiday"|"Partnership"|"Project"|"Propal"|"Societe"|"SupplierProposal" $objectclass
94@phan-var-force string $massaction
95@phan-var-force string $uploaddir
100if (!empty($permtoread) && empty($permissiontoread)) {
101 $permissiontoread = $permtoread;
103if (!empty($permtocreate) && empty($permissiontoadd)) {
104 $permissiontoadd = $permtocreate;
106if (!empty($permtodelete) && empty($permissiontodelete)) {
107 $permissiontodelete = $permtodelete;
111$maxformassaction =
getDolGlobalInt(
'MAIN_LIMIT_FOR_MASS_ACTIONS', 1000);
112if ($massaction && is_array($toselect) && count($toselect) < 1) {
116if (!$error && isset($toselect) && is_array($toselect) && count($toselect) > $maxformassaction) {
117 setEventMessages($langs->trans(
'TooManyRecordForMassAction', $maxformassaction),
null,
'errors');
121if (!$error && $massaction ==
'confirm_presend' && !
GETPOST(
'sendmail')) {
122 $massaction =
'presend';
125if (!$error && $massaction ==
'confirm_presend') {
129 $langs->load(
"mails");
130 include_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
131 include_once DOL_DOCUMENT_ROOT.
'/core/lib/signature.lib.php';
133 $listofobjectid = array();
134 $listofobjectthirdparties = array();
135 $listofobjectcontacts = array();
136 $listofobjectref = array();
137 $contactidtosend = array();
138 $attachedfilesThirdpartyObj = array();
139 $oneemailperrecipient = (
GETPOSTINT(
'oneemailperrecipient') ? 1 : 0);
143 $objecttmp =
new $objectclass($db);
146 $thirdparty =
new Societe($db);
147 if ($objecttmp->element ==
'expensereport') {
148 $thirdparty =
new User($db);
149 } elseif ($objecttmp->element ==
'contact') {
150 $thirdparty =
new Contact($db);
151 } elseif ($objecttmp->element ==
'partnership' &&
getDolGlobalString(
'PARTNERSHIP_IS_MANAGED_FOR') ==
'member') {
153 } elseif ($objecttmp->element ==
'holiday') {
154 $thirdparty =
new User($db);
155 } elseif ($objecttmp->element ==
'conferenceorboothattendee') {
159 foreach ($toselect as $toselectid) {
160 $objecttmp =
new $objectclass($db);
161 '@phan-var-force CommonObject $objecttmp';
163 $result = $objecttmp->fetch($toselectid);
165 $listofobjectid[$toselectid] = $toselectid;
168 $tmpobjectid = ($objecttmp->fk_soc ? $objecttmp->fk_soc : $objecttmp->socid);
169 if ($objecttmp->element ==
'societe') {
170 '@phan-var-force Societe $objecttmp';
172 $tmpobjectid = $objecttmp->id;
173 } elseif ($objecttmp->element ==
'contact') {
174 '@phan-var-force Contact $objecttmp';
176 $tmpobjectid = $objecttmp->id;
177 } elseif ($objecttmp->element ==
'expensereport') {
178 '@phan-var-force ExpenseReport $objecttmp';
180 $tmpobjectid = $objecttmp->fk_user_author;
181 } elseif ($objecttmp->element ==
'partnership' &&
getDolGlobalString(
'PARTNERSHIP_IS_MANAGED_FOR') ==
'member') {
182 '@phan-var-force Partnership $objecttmp';
184 $tmpobjectid = $objecttmp->fk_member;
185 } elseif ($objecttmp->element ==
'holiday') {
186 '@phan-var-force Holiday $objecttmp';
188 $tmpobjectid = $objecttmp->fk_user;
189 } elseif ($objecttmp->element ==
'conferenceorboothattendee') {
190 '@phan-var-force ConferenceOrBoothAttendee $objecttmp';
192 $tmpobjectid = $objecttmp->id;
194 if (empty($tmpobjectid)) {
198 if ($objectclass ==
'Facture') {
199 '@phan-var-force Facture $objecttmp';
201 $tmparraycontact = array();
202 $tmparraycontact = $objecttmp->liste_contact(-1,
'external', 0,
'BILLING');
203 if (is_array($tmparraycontact) && count($tmparraycontact) > 0) {
204 foreach ($tmparraycontact as $data_email) {
205 $listofobjectcontacts[$toselectid][$data_email[
'id']] = $data_email[
'email'];
208 } elseif ($objectclass ==
'CommandeFournisseur') {
209 '@phan-var-force CommandeFournisseur $objecttmp';
211 $tmparraycontact = array();
212 $tmparraycontact = $objecttmp->liste_contact(-1,
'external', 0,
'CUSTOMER');
213 if (is_array($tmparraycontact) && count($tmparraycontact) > 0) {
214 foreach ($tmparraycontact as $data_email) {
215 $listofobjectcontacts[$toselectid][$data_email[
'id']] = $data_email[
'email'];
220 $listofobjectthirdparties[$tmpobjectid] = $tmpobjectid;
221 $listofobjectref[$tmpobjectid][$toselectid] = $objecttmp;
227 if (
GETPOST(
'fromtype',
'alpha') ===
'user' && empty($user->email)) {
230 $massaction =
'presend';
233 $receiver =
GETPOST(
'receiver',
'alphawithlgt');
234 if (!is_array($receiver)) {
235 if (empty($receiver) || $receiver ==
'-1') {
238 $receiver = array($receiver);
241 if (!trim(
GETPOST(
'sendto',
'alphawithlgt')) && count($receiver) == 0 && count($listofobjectthirdparties) == 1) {
243 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Recipient")),
null,
'warnings');
244 $massaction =
'presend';
247 if (!
GETPOST(
'subject',
'restricthtml')) {
249 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"MailTopic")),
null,
'warnings');
250 $massaction =
'presend';
255 foreach ($listofobjectthirdparties as $thirdpartyid) {
256 $result = $thirdparty->fetch($thirdpartyid);
269 if (trim(
GETPOST(
'sendto',
'alphawithlgt'))) {
271 $tmparray[] = trim(
GETPOST(
'sendto',
'alphawithlgt'));
273 if (count($receiver) > 0 && is_object($thirdparty)) {
274 foreach ($receiver as $key => $val) {
276 if ($val ==
'thirdparty') {
277 $tmparray[] = $thirdparty->name.
' <'.$thirdparty->email.
'>';
278 } elseif ($val && method_exists($thirdparty,
'contact_get_property')) {
279 $tmparray[] = $thirdparty->contact_get_property((
int) $val,
'email');
284 $sendto = implode(
',', $tmparray);
287 $receivercc =
GETPOST(
'receivercc',
'alphawithlgt');
288 if (!is_array($receivercc)) {
289 if ($receivercc ==
'-1') {
290 $receivercc = array();
292 $receivercc = array($receivercc);
296 if (trim(
GETPOST(
'sendtocc',
'alphawithlgt'))) {
297 $tmparray[] = trim(
GETPOST(
'sendtocc',
'alphawithlgt'));
299 if (count($receivercc) > 0) {
300 foreach ($receivercc as $key => $val) {
302 if ($val ==
'thirdparty') {
303 $tmparray[] = $thirdparty->name.
' <'.$thirdparty->email.
'>';
305 $tmparray[] = $thirdparty->contact_get_property((
int) $val,
'email');
310 $sendtocc = implode(
',', $tmparray);
313 $listofqualifiedobj = array();
314 $listofqualifiedref = array();
315 $thirdpartywithoutemail = array();
317 foreach ($listofobjectref[$thirdpartyid] as $objectid => $objectobj) {
324 $langs->load(
"errors");
326 $resaction .=
'<div class="error">'.$langs->trans(
'ErrorOnlyProposalNotDraftCanBeSentInMassAction', $objectobj->ref).
'</div><br>';
330 $langs->load(
"errors");
332 $resaction .=
'<div class="error">'.$langs->trans(
'ErrorOnlyOrderNotDraftCanBeSentInMassAction', $objectobj->ref).
'</div><br>';
336 $langs->load(
"errors");
338 $resaction .=
'<div class="error">'.$langs->trans(
'ErrorOnlyInvoiceValidatedCanBeSentInMassAction', $objectobj->ref).
'</div><br>';
343 if (empty($sendto)) {
344 if ($objectobj->element ==
'societe') {
345 $sendto = $objectobj->email;
346 } elseif ($objectobj->element ==
'expensereport') {
347 $fuser =
new User($db);
348 $fuser->fetch($objectobj->fk_user_author);
349 $sendto = $fuser->email;
350 } elseif ($objectobj->element ==
'contact') {
352 $fcontact->fetch($objectobj->id);
353 $sendto = $fcontact->email;
354 } elseif ($objectobj->element ==
'partnership' &&
getDolGlobalString(
'PARTNERSHIP_IS_MANAGED_FOR') ==
'member') {
356 $fadherent->fetch($objectobj->fk_member);
357 $sendto = $fadherent->email;
358 } elseif ($objectobj->element ==
'holiday') {
359 $fuser =
new User($db);
360 $fuser->fetch($objectobj->fk_user);
361 $sendto = $fuser->email;
362 } elseif ($objectobj->element ==
'facture' && !empty($listofobjectcontacts[$objectid])) {
363 $emails_to_sends = array();
364 $objectobj->fetch_thirdparty();
365 $contactidtosend = array();
366 foreach ($listofobjectcontacts[$objectid] as $contactemailid => $contactemailemail) {
367 $emails_to_sends[] = $objectobj->thirdparty->contact_get_property($contactemailid,
'email');
368 if (!in_array($contactemailid, $contactidtosend)) {
369 $contactidtosend[] = $contactemailid;
372 if (count($emails_to_sends) > 0) {
373 $sendto = implode(
',', $emails_to_sends);
375 } elseif ($objectobj->element ==
'order_supplier' && !empty($listofobjectcontacts[$objectid])) {
376 $emails_to_sends = array();
377 $objectobj->fetch_thirdparty();
378 $contactidtosend = array();
379 foreach ($listofobjectcontacts[$objectid] as $contactemailid => $contactemailemail) {
380 $emails_to_sends[] = $objectobj->thirdparty->contact_get_property($contactemailid,
'email');
381 if (!in_array($contactemailid, $contactidtosend)) {
382 $contactidtosend[] = $contactemailid;
385 if (count($emails_to_sends) > 0) {
386 $sendto = implode(
',', $emails_to_sends);
388 } elseif ($objectobj->element ==
'conferenceorboothattendee') {
389 $sendto = $objectobj->email;
391 $objectobj->fetch_thirdparty();
392 $sendto = $objectobj->thirdparty->email;
396 if (empty($sendto)) {
397 if ($objectobj->element ==
'societe') {
399 $objectobj->thirdparty = $objectobj;
404 if (empty($thirdpartywithoutemail[$objectobj->thirdparty->id])) {
405 $resaction .=
'<div class="error">'.$langs->trans(
'NoRecipientEmail', $objectobj->thirdparty->name).
'</div><br>';
407 dol_syslog(
'No recipient for thirdparty: '.$objectobj->thirdparty->name, LOG_WARNING);
408 $thirdpartywithoutemail[$objectobj->thirdparty->id] = 1;
412 if (
GETPOST(
'addmaindocfile')) {
419 $filedir = $uploaddir.
'/'.$subdir.dol_sanitizeFileName($objectobj->ref);
420 $filepath = $filedir.
'/'.$filename;
423 if ($objectobj->element ==
'invoice_supplier') {
424 $fileparams =
dol_most_recent_file($uploaddir.
'/'.
get_exdir($objectobj->id, 2, 0, 0, $objectobj, $objectobj->element).$objectobj->ref, preg_quote($objectobj->ref,
'/').
'([^\-])+');
425 $filepath = $fileparams[
'fullname'];
429 $filename_found =
'';
430 $filepath_found =
'';
431 $file_check_list = array();
432 $file_check_list[] = array(
436 if (
getDolGlobalString(
'MAIL_MASS_ACTION_ADD_LAST_IF_MAIN_DOC_NOT_FOUND') && !empty($objectobj->last_main_doc)) {
437 $file_check_list[] = array(
438 'name' => basename($objectobj->last_main_doc),
439 'path' => DOL_DATA_ROOT .
'/' . $objectobj->last_main_doc,
442 foreach ($file_check_list as $file_check_arr) {
444 $filename_found = $file_check_arr[
'name'];
445 $filepath_found = $file_check_arr[
'path'];
450 if ($filepath_found) {
452 $attachedfilesThirdpartyObj[$thirdpartyid][$objectid] = array(
453 'paths' => array($filepath_found),
454 'names' => array($filename_found),
459 $langs->load(
"errors");
460 foreach ($file_check_list as $file_check_arr) {
461 $resaction .=
'<div class="error">'.$langs->trans(
'ErrorCantReadFile', $file_check_arr[
'path']).
'</div><br>';
462 dol_syslog(
'Failed to read file: '.$file_check_arr[
'path'], LOG_WARNING);
469 $listofqualifiedobj[$objectid] = $objectobj;
470 $listofqualifiedref[$objectid] = $objectobj->ref;
477 if (count($listofqualifiedobj) > 0) {
478 $langs->load(
"commercial");
481 $fromtype =
GETPOST(
'fromtype');
482 if ($fromtype ===
'user') {
483 $from =
dol_string_nospecial($user->getFullName($langs),
' ', array(
",")).
' <'.$user->email.
'>';
484 } elseif ($fromtype ===
'company') {
486 } elseif (preg_match(
'/user_aliases_(\d+)/', $fromtype, $reg)) {
487 $tmp = explode(
',', $user->email_aliases);
488 $from = trim($tmp[((
int) $reg[1] - 1)]);
489 } elseif (preg_match(
'/global_aliases_(\d+)/', $fromtype, $reg)) {
491 $from = trim($tmp[((
int) $reg[1] - 1)]);
492 } elseif (preg_match(
'/senderprofile_(\d+)_(\d+)/', $fromtype, $reg)) {
493 $sql =
"SELECT rowid, label, email FROM ".MAIN_DB_PREFIX.
"c_email_senderprofile WHERE rowid = ".(int) $reg[1];
494 $resql = $db->query($sql);
495 $obj = $db->fetch_object($resql);
504 $subject =
GETPOST(
'subject',
'restricthtml');
505 $message =
GETPOST(
'message',
'restricthtml');
507 $sendtobcc =
GETPOST(
'sendtoccc');
508 if ($objectclass ==
'Propal') {
511 if ($objectclass ==
'Commande') {
514 if ($objectclass ==
'Facture') {
517 if ($objectclass ==
'SupplierProposal') {
518 $sendtobcc .= (!
getDolGlobalString(
'MAIN_MAIL_AUTOCOPY_SUPPLIER_PROPOSAL_TO') ?
'' : (($sendtobcc ?
", " :
"") .
getDolGlobalString(
'MAIN_MAIL_AUTOCOPY_SUPPLIER_PROPOSAL_TO')));
520 if ($objectclass ==
'CommandeFournisseur') {
523 if ($objectclass ==
'FactureFournisseur') {
526 if ($objectclass ==
'Project') {
532 $looparray = array();
533 if (!$oneemailperrecipient) {
534 $looparray = $listofqualifiedobj;
535 foreach ($looparray as $key => $objecttmp) {
536 $looparray[$key]->thirdparty = $thirdparty;
539 $objectforloop =
new $objectclass($db);
540 $objectforloop->thirdparty = $thirdparty;
541 $looparray[0] = $objectforloop;
544 dol_syslog(
"We have set an array of ".count($looparray).
" emails to send. oneemailperrecipient=".$oneemailperrecipient);
546 foreach ($looparray as $objectid => $objecttmp) {
548 if (isModEnabled(
'project') && method_exists($objecttmp,
'fetchProject') && is_null($objecttmp->project)) {
549 $objecttmp->fetchProject();
552 $substitutionarray[
'__ID__'] = ($oneemailperrecipient ? implode(
', ', array_keys($listofqualifiedobj)) : $objecttmp->id);
553 $substitutionarray[
'__REF__'] = ($oneemailperrecipient ? implode(
', ', $listofqualifiedref) : $objecttmp->
ref);
554 $substitutionarray[
'__EMAIL__'] = $thirdparty->email;
555 $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"/>';
557 if ($oneemailperrecipient) {
558 $substitutionarray[
'__ONLINE_PAYMENT_URL__'] =
'';
559 $substitutionarray[
'__ONLINE_PAYMENT_TEXT_AND_URL__'] =
'';
562 $parameters = array(
'mode' =>
'formemail');
564 if (!empty($listofobjectthirdparties)) {
565 $parameters[
'listofobjectthirdparties'] = $listofobjectthirdparties;
567 if (!empty($listofobjectref)) {
568 $parameters[
'listofobjectref'] = $listofobjectref;
576 $attachedfiles = array(
'paths' => array(),
'names' => array(),
'mimes' => array());
577 if ($oneemailperrecipient) {
579 if (is_array($attachedfilesThirdpartyObj[$thirdparty->id]) && count($attachedfilesThirdpartyObj[$thirdparty->id])) {
580 foreach ($attachedfilesThirdpartyObj[$thirdparty->id] as $keyObjId => $objAttachedFiles) {
582 $attachedfiles = array(
583 'paths' => array_merge($attachedfiles[
'paths'], $objAttachedFiles[
'paths']),
584 'names' => array_merge($attachedfiles[
'names'], $objAttachedFiles[
'names']),
585 'mimes' => array_merge($attachedfiles[
'mimes'], $objAttachedFiles[
'mimes'])
589 } elseif (!empty($attachedfilesThirdpartyObj[$thirdparty->id][$objectid])) {
592 $attachedfiles = $attachedfilesThirdpartyObj[$thirdparty->id][$objectid];
595 $filepath = $attachedfiles[
'paths'];
596 $filename = $attachedfiles[
'names'];
597 $mimetype = $attachedfiles[
'mimes'];
600 if ($oneemailperrecipient) {
601 $trackid =
'thi'.$thirdparty->id;
602 if ($objecttmp->element ==
'expensereport') {
603 $trackid =
'use'.$thirdparty->id;
604 } elseif ($objecttmp->element ==
'contact') {
605 $trackid =
'ctc'.$thirdparty->id;
606 } elseif ($objecttmp->element ==
'holiday') {
607 $trackid =
'use'.$thirdparty->id;
610 $trackid = strtolower(get_class($objecttmp));
611 if (get_class($objecttmp) ==
'Contact') {
613 } elseif (get_class($objecttmp) ==
'Contrat') {
615 } elseif (get_class($objecttmp) ==
'Propal') {
617 } elseif (get_class($objecttmp) ==
'Commande') {
619 } elseif (get_class($objecttmp) ==
'Facture') {
621 } elseif (get_class($objecttmp) ==
'SupplierProposal') {
623 } elseif (get_class($objecttmp) ==
'CommandeFournisseur') {
625 } elseif (get_class($objecttmp) ==
'FactureFournisseur') {
629 $trackid .= $objecttmp->id;
635 if (empty($sendcontext)) {
636 $sendcontext =
'standard';
640 $vardir =
$conf->user->dir_output.
"/".$user->id;
641 $upload_dir_tmp = $vardir.
'/temp';
644 require_once DOL_DOCUMENT_ROOT.
'/core/class/CMailFile.class.php';
645 $mailfile =
new CMailFile($subjectreplaced, $sendto, $from, $messagereplaced, $filepath, $mimetype, $filename, $sendtocc, $sendtobcc, $deliveryreceipt, -1,
'',
'', $trackid,
'', $sendcontext,
'', $upload_dir_tmp);
646 if ($mailfile->error) {
647 $resaction .=
'<div class="error">'.$mailfile->error.
'</div>';
649 $result = $mailfile->sendfile();
651 $resaction .= $langs->trans(
'MailSuccessfulySent', $mailfile->getValidAddress($mailfile->addr_from, 2), $mailfile->getValidAddress($mailfile->addr_to, 2)).
'<br>';
656 foreach ($listofqualifiedobj as $objid2 => $objectobj2) {
657 if ((!$oneemailperrecipient) && $objid2 != $objectid) {
661 dol_syslog(
"Try to insert email event into agenda for objid=".$objid2.
" => objectobj=".get_class($objectobj2));
670 $actionmsg = $langs->transnoentities(
'MailSentByTo', $from, $sendto);
673 $actionmsg =
dol_concatdesc($actionmsg, $langs->transnoentities(
'Bcc').
": ".$sendtocc);
675 $actionmsg =
dol_concatdesc($actionmsg, $langs->transnoentities(
'MailTopic').
": ".$subjectreplaced);
676 $actionmsg =
dol_concatdesc($actionmsg, $langs->transnoentities(
'TextUsedInTheMessageBody').
":");
682 $objectobj2->sendtoid = (empty($contactidtosend) ? 0 : $contactidtosend);
683 $objectobj2->actionmsg = $actionmsg;
684 $objectobj2->actionmsg2 = $actionmsg2;
685 $objectobj2->fk_element = $objid2;
686 $objectobj2->elementtype = $objectobj2->element;
688 $objectobj2->actionmsg2 = $subjectreplaced;
691 $triggername = strtoupper(get_class($objectobj2)).
'_SENTBYMAIL';
692 if ($triggername ==
'SOCIETE_SENTBYMAIL') {
693 $triggername =
'COMPANY_SENTBYMAIL';
695 if ($triggername ==
'CONTRAT_SENTBYMAIL') {
696 $triggername =
'CONTRACT_SENTBYMAIL';
698 if ($triggername ==
'COMMANDE_SENTBYMAIL') {
699 $triggername =
'ORDER_SENTBYMAIL';
701 if ($triggername ==
'FACTURE_SENTBYMAIL') {
702 $triggername =
'BILL_SENTBYMAIL';
704 if ($triggername ==
'EXPEDITION_SENTBYMAIL') {
705 $triggername =
'SHIPPING_SENTBYMAIL';
707 if ($triggername ==
'COMMANDEFOURNISSEUR_SENTBYMAIL') {
708 $triggername =
'ORDER_SUPPLIER_SENTBYMAIL';
710 if ($triggername ==
'FACTUREFOURNISSEUR_SENTBYMAIL') {
711 $triggername =
'BILL_SUPPLIER_SENTBYMAIL';
713 if ($triggername ==
'SUPPLIERPROPOSAL_SENTBYMAIL') {
714 $triggername =
'PROPOSAL_SUPPLIER_SENTBYMAIL';
716 if ($triggername ==
'PROJET_SENTBYMAIL') {
717 $triggername =
'PROJECT_SENTBYMAIL';
720 if (!empty($triggername)) {
722 $result = $objectobj2->call_trigger($triggername, $user);
730 dol_syslog(
"Error in trigger ".$triggername.
' '.$db->lasterror(), LOG_ERR);
737 $langs->load(
"other");
738 if ($mailfile->error) {
739 $resaction .= $langs->trans(
'ErrorFailedToSendMail', $from, $sendto);
740 $resaction .=
'<br><div class="error">'.$mailfile->error.
'</div>';
742 $resaction .=
'<div class="warning">No mail sent. Feature is disabled by option MAIN_DISABLE_ALL_MAILS</div>';
744 $resaction .= $langs->trans(
'ErrorFailedToSendMail', $from, $sendto) .
'<br><div class="error">(unhandled error)</div>';
752 $resaction .= ($resaction ?
'<br>' : $resaction);
753 $resaction .=
'<strong>'.$langs->trans(
"ResultOfMailSending").
':</strong><br>'.
"\n";
754 $resaction .= $langs->trans(
"NbSelected").
': '.count($toselect).
"\n<br>";
755 $resaction .= $langs->trans(
"NbIgnored").
': '.($nbignored ? $nbignored : 0).
"\n<br>";
756 $resaction .= $langs->trans(
"NbSent").
': '.($nbsent ? $nbsent : 0).
"\n<br>";
761 setEventMessages($langs->trans(
"EMailSentForNElements", $nbsent.
'/'.count($toselect)),
null,
'mesgs');
774if (!$error && $massaction ==
'cancelorders') {
779 $orders =
GETPOST(
'toselect',
'array');
780 foreach ($orders as $id_order) {
782 if ($cmd->fetch($id_order) <= 0) {
787 $langs->load(
'errors');
788 setEventMessages($langs->trans(
"ErrorObjectMustHaveStatusValidToBeCanceled", $cmd->ref),
null,
'errors');
793 $result = $cmd->cancel();
813if (!$error && $massaction ==
"builddoc" && $permissiontoread && !
GETPOST(
'button_search')) {
814 if (empty($diroutputmassaction)) {
815 dol_print_error(
null,
'include of actions_massactions.inc.php is done but var $diroutputmassaction was not defined');
819 require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
820 require_once DOL_DOCUMENT_ROOT.
'/core/lib/pdf.lib.php';
821 require_once DOL_DOCUMENT_ROOT.
'/core/lib/date.lib.php';
823 $objecttmp =
new $objectclass($db);
824 $listofobjectid = array();
825 $listofobjectthirdparties = array();
826 $listofobjectref = array();
827 foreach ($toselect as $toselectid) {
828 $objecttmp =
new $objectclass($db);
829 $result = $objecttmp->fetch($toselectid);
831 $listofobjectid[$toselectid] = $toselectid;
832 $thirdpartyid = !empty($objecttmp->fk_soc) ? $objecttmp->fk_soc : $objecttmp->socid;
833 $listofobjectthirdparties[$thirdpartyid] = $thirdpartyid;
834 $listofobjectref[$toselectid] = $objecttmp->ref;
838 $arrayofinclusion = array();
839 foreach ($listofobjectref as $tmppdf) {
842 foreach ($listofobjectref as $tmppdf) {
843 $arrayofinclusion[] =
'^'.preg_quote(
dol_sanitizeFileName($tmppdf),
'/').
'_[a-zA-Z0-9\-\_\'\&\.]+\.pdf$';
845 $listoffiles =
dol_dir_list($uploaddir,
'all', 1, implode(
'|', $arrayofinclusion),
'\.meta$|\.png',
'date', SORT_DESC, 0, 1);
850 foreach ($listofobjectref as $basename) {
852 foreach ($listoffiles as $filefound) {
853 if (strstr($filefound[
"name"], $basename)) {
854 $files[] = $filefound[
'fullname'];
861 $outputlangs = $langs;
864 $newlang =
GETPOST(
'lang_id',
'aZ09');
869 if (!empty($newlang)) {
871 $outputlangs->setDefaultLang($newlang);
880 $filename = preg_replace(
'/\s/',
'_', $filename);
883 if (in_array($objecttmp->element, array(
'facture',
'invoice_supplier')) && $search_status ==
Facture::STATUS_VALIDATED) {
884 if ($option ==
'late') {
891 $filename .=
'_'.$year;
894 $filename .=
'_'.$month;
897 if (count($files) > 0) {
899 $file = $diroutputmassaction.
'/'.$filename.
'_'.
dol_print_date($now,
'dayhourlog').
'.pdf';
902 foreach ($files as $f) {
903 $input_files .=
' '.escapeshellarg($f);
906 $cmd =
'pdftk '.$input_files.
' cat output '.escapeshellarg($file);
910 if (file_exists($file)) {
913 $langs->load(
"exports");
916 setEventMessages($langs->trans(
'ErrorPDFTkOutputFileNotFound'),
null,
'errors');
919 setEventMessages($langs->trans(
'NoPDFAvailableForDocGenAmongChecked'),
null,
'errors');
924 $page_largeur = $formatarray[
'width'];
925 $page_hauteur = $formatarray[
'height'];
926 $format = array($page_largeur, $page_hauteur);
930 if (class_exists(
'TCPDF')) {
931 $pdf->setPrintHeader(
false);
932 $pdf->setPrintFooter(
false);
937 $pdf->SetCompression(
false);
942 foreach ($files as $file) {
944 $pagecount = $pdf->setSourceFile($file);
945 for ($i = 1; $i <= $pagecount; $i++) {
946 $tplidx = $pdf->importPage($i);
947 $s = $pdf->getTemplatesize($tplidx);
948 $pdf->AddPage($s[
'h'] > $s[
'w'] ?
'P' :
'L');
949 $pdf->useTemplate($tplidx);
958 $filename = preg_replace(
'/\s/',
'_', $filename);
962 if (in_array($objecttmp->element, array(
'facture',
'invoice_supplier')) && $search_status ==
Facture::STATUS_VALIDATED) {
963 if ($option ==
'late') {
970 $filename .=
'_'.$year;
972 if (!empty($month)) {
973 $filename .=
'_'.$month;
977 $file = $diroutputmassaction.
'/'.$filename.
'_'.
dol_print_date($now,
'dayhourlog').
'.pdf';
978 $pdf->Output($file,
'F');
981 $langs->load(
"exports");
984 setEventMessages($langs->trans(
'NoPDFAvailableForDocGenAmongChecked'),
null,
'errors');
990if ($action ==
'remove_file') {
991 require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
993 $langs->load(
"other");
994 $upload_dir = $diroutputmassaction;
995 $file = $upload_dir.
'/'.
GETPOST(
'file');
1007if (!$error && $massaction ==
'validate' && $permissiontoadd) {
1008 $objecttmp =
new $objectclass($db);
1010 if (($objecttmp->element ==
'facture' || $objecttmp->element ==
'invoice') && isModEnabled(
'stock') &&
getDolGlobalString(
'STOCK_CALCULATE_ON_BILL')) {
1011 $langs->load(
"errors");
1012 setEventMessages($langs->trans(
'ErrorMassValidationNotAllowedWhenStockIncreaseOnAction'),
null,
'errors');
1015 if ($objecttmp->element ==
'invoice_supplier' && isModEnabled(
'stock') &&
getDolGlobalString(
'STOCK_CALCULATE_ON_SUPPLIER_BILL')) {
1016 $langs->load(
"errors");
1017 setEventMessages($langs->trans(
'ErrorMassValidationNotAllowedWhenStockIncreaseOnAction'),
null,
'errors');
1020 if ($objecttmp->element ==
'facture') {
1023 $sql =
"SELECT rowid FROM ".MAIN_DB_PREFIX.
"facture";
1024 $sql .=
" WHERE rowid IN (".$db->sanitize(implode(
",", $toselect)).
")";
1025 $sql .=
" ORDER BY datef";
1027 $resql = $db->query($sql);
1030 while (!empty($arr = $db->fetch_row($resql))) {
1031 $toselectnew[] = $arr[0];
1033 $toselect = (empty($toselectnew)) ? $toselect : $toselectnew;
1044 foreach ($toselect as $toselectid) {
1045 $result = $objecttmp->fetch($toselectid);
1047 if (method_exists($objecttmp,
'validate')) {
1048 $result = $objecttmp->validate($user);
1049 } elseif (method_exists($objecttmp,
'setValid')) {
1050 $result = $objecttmp->setValid($user);
1052 $objecttmp->error =
'No method validate or setValid on this object';
1056 $langs->load(
"errors");
1057 setEventMessages($langs->trans(
"ErrorObjectMustHaveStatusDraftToBeValidated", $objecttmp->ref),
null,
'errors');
1060 } elseif ($result < 0) {
1068 $outputlangs = $langs;
1071 $newlang =
GETPOST(
'lang_id',
'aZ09');
1073 if (
getDolGlobalInt(
'MAIN_MULTILANGS') && empty($newlang) && property_exists($objecttmp,
'thirdparty')) {
1074 if ((property_exists($objecttmp,
'socid') || property_exists($objecttmp,
'fk_soc')) && empty($objecttmp->thirdparty)) {
1075 $objecttmp->fetch_thirdparty();
1077 if (!empty($objecttmp->thirdparty)) {
1078 $newlang = $objecttmp->thirdparty->default_lang;
1081 if (!empty($newlang)) {
1083 $outputlangs->setDefaultLang($newlang);
1084 $outputlangs->load(
'products');
1086 $model = $objecttmp->model_pdf;
1087 $ret = $objecttmp->fetch($objecttmp->id);
1090 $hidedetails = isset($hidedetails) ? $hidedetails : (
getDolGlobalString(
'MAIN_GENERATE_DOCUMENTS_HIDE_DETAILS') ? 1 : 0);
1091 $hidedesc = isset($hidedesc) ? $hidedesc : (
getDolGlobalString(
'MAIN_GENERATE_DOCUMENTS_HIDE_DESC') ? 1 : 0);
1092 $hideref = isset($hideref) ? $hideref : (
getDolGlobalString(
'MAIN_GENERATE_DOCUMENTS_HIDE_REF') ? 1 : 0);
1093 $moreparams = isset($moreparams) ? $moreparams :
null;
1095 $result = $objecttmp->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref);
1113 setEventMessages($langs->trans(
"RecordModifiedSuccessfully"),
null,
'mesgs');
1123if (!$error && ($massaction ==
'delete' || ($action ==
'delete' && $confirm ==
'yes')) && $permissiontodelete) {
1126 $objecttmp =
new $objectclass($db);
1132 $unique_arr = array_unique($toselect);
1133 foreach ($unique_arr as $toselectid) {
1134 $result = $objecttmp->fetch($toselectid);
1138 $langs->load(
"errors");
1140 $TMsg[] =
'<div class="error">'.$langs->trans(
'ErrorOnlyDraftStatusCanBeDeletedInMassAction', $objecttmp->ref).
'</div><br>';
1144 if (method_exists($objecttmp,
'is_erasable') && $objecttmp->is_erasable() <= 0) {
1145 $langs->load(
"errors");
1147 $TMsg[] =
'<div class="error">'.$langs->trans(
'ErrorRecordHasChildren').
' '.$objecttmp->ref.
'</div><br>';
1152 $langs->load(
"errors");
1154 $TMsg[] =
'<div class="error">'.$langs->trans(
'ErrorLeaveRequestMustBeDraftCanceledOrRefusedToBeDeleted', $objecttmp->ref).
'</div><br>';
1158 if ($objectclass ==
"Task" && $objecttmp->hasChildren() > 0) {
1159 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"projet_task SET fk_task_parent = 0 WHERE fk_task_parent = ".((int) $objecttmp->id);
1160 $res = $db->query($sql);
1168 if ($objecttmp->element ==
'societe') {
1170 '@phan-var-force Societe $objecttmp';
1172 $result = $objecttmp->delete($objecttmp->id, $user, 1);
1174 $result = $objecttmp->delete($user);
1177 if (empty($result)) {
1178 $TMsg = array_merge($objecttmp->errors, $TMsg);
1179 } elseif ($result < 0) {
1193 if (empty($error)) {
1197 } elseif ($nbok > 0) {
1204 if (!empty($TMsg)) {
1219if (!$error && $massaction ==
'generate_doc' && $permissiontoread) {
1222@phan-var-force
'Commande'|
'CommandeFournisseur'|
'Contrat'|
'Expedition'|
'ExpenseReport'|
'Facture'|
'FactureFournisseur'|
'Fichinter'|
'Project'|
'Propal'|
'SupplierProposal' $objectclass
1228 $objecttmp =
new $objectclass($db);
1230 foreach ($toselect as $toselectid) {
1231 $objecttmp->thirdparty =
null;
1232 $result = $objecttmp->fetch($toselectid);
1235 $outputlangs = $langs;
1239 $newlang =
GETPOST(
'lang_id',
'aZ09');
1241 if (
getDolGlobalInt(
'MAIN_MULTILANGS') && empty($newlang) && isset($objecttmp->thirdparty->default_lang)) {
1242 $newlang = $objecttmp->thirdparty->default_lang;
1244 if (
getDolGlobalInt(
'MAIN_MULTILANGS') && empty($newlang) && isset($objecttmp->default_lang)) {
1245 $newlang = $objecttmp->default_lang;
1247 if (
getDolGlobalInt(
'MAIN_MULTILANGS') && empty($newlang) && empty($objecttmp->thirdparty)) {
1248 $objecttmp->fetch_thirdparty();
1249 $newlang = $objecttmp->thirdparty->default_lang;
1251 if (!empty($newlang)) {
1253 $outputlangs->setDefaultLang($newlang);
1257 $hidedetails = isset($hidedetails) ? $hidedetails : (
getDolGlobalString(
'MAIN_GENERATE_DOCUMENTS_HIDE_DETAILS') ? 1 : 0);
1258 $hidedesc = isset($hidedesc) ? $hidedesc : (
getDolGlobalString(
'MAIN_GENERATE_DOCUMENTS_HIDE_DESC') ? 1 : 0);
1259 $hideref = isset($hideref) ? $hideref : (
getDolGlobalString(
'MAIN_GENERATE_DOCUMENTS_HIDE_REF') ? 1 : 0);
1260 $moreparams = isset($moreparams) ? $moreparams :
null;
1262 $result = $objecttmp->generateDocument($objecttmp->model_pdf, $outputlangs, $hidedetails, $hidedesc, $hideref, $moreparams);
1290if (!$error && ($action ==
'affecttag' && $confirm ==
'yes') && $permissiontoadd) {
1294 $affecttag_type =
GETPOST(
'affecttag_type',
'alpha');
1295 if (!empty($affecttag_type)) {
1296 $affecttag_type_array = explode(
',', $affecttag_type);
1300 if (!empty($affecttag_type_array)) {
1302 require_once DOL_DOCUMENT_ROOT.
'/categories/class/categorie.class.php';
1304 $to_affecttag_type_array = array();
1305 $categ_type_array = $categ->getMapList();
1306 foreach ($categ_type_array as $categdef) {
1307 if (in_array($categdef[
'code'], $affecttag_type_array)) {
1308 $to_affecttag_type_array[] = $categdef[
'code'];
1313 if (!empty($to_affecttag_type_array)) {
1314 foreach ($to_affecttag_type_array as $categ_type) {
1315 $contcats =
GETPOST(
'contcats_' . $categ_type,
'array');
1317 foreach ($toselect as $toselectid) {
1318 $result =
$object->fetch($toselectid);
1321 $result =
$object->setCategoriesCommon($contcats, $categ_type,
false);
1340 $toselect = array();
1346if (!$error && ($action ==
'updateprice' && $confirm ==
'yes') && $permissiontoadd) {
1347 '@phan-var-force Product|ProductCustomerPrice $obj';
1348 '@phan-var-force Product|ProductCustomerPrice $object';
1351 if (GETPOSTISSET(
'pricerate')) {
1353 if ($pricepercentage == 0) {
1356 foreach ($toselect as $toselectid) {
1357 $result =
$object->fetch($toselectid);
1362 if (
$object->price_base_type ==
'TTC') {
1363 $newprice =
$object->price_ttc * (100 + $pricepercentage) / 100;
1364 $minprice =
$object->price_min_ttc;
1366 $newprice =
$object->price * (100 + $pricepercentage) / 100;
1367 $minprice =
$object->price_min;
1369 $res =
$object->updatePrice($newprice,
$object->price_base_type, $user,
$object->tva_tx, $minprice, 0,
$object->tva_npr, 0, 0, array(),
$object->default_vat_code);
1377 for ($level = 1; $level <= $maxlevel; $level++) {
1378 if (
$object->price_base_type ==
'TTC') {
1379 $newprice =
$object->multiprices_ttc[$level] * (100 + $pricepercentage) / 100;
1380 $minprice =
$object->multiprices_min_ttc[$level];
1382 $newprice =
$object->multiprices[$level] * (100 + $pricepercentage) / 100;
1383 $minprice =
$object->multiprices_min[$level];
1385 $res =
$object->updatePrice($newprice,
$object->price_base_type, $user,
$object->tva_tx, $minprice, $level,
$object->tva_npr, 0, 0, array(),
$object->default_vat_code);
1405 $toselect = array();
1411if (!$error && ($action ==
'setsupervisor' && $confirm ==
'yes') && $permissiontoadd) {
1412 '@phan-var-force User $object';
1415 $supervisortoset =
GETPOSTINT(
'supervisortoset');
1416 if (!empty($supervisortoset)) {
1417 foreach ($toselect as $toselectid) {
1418 $result =
$object->fetch($toselectid);
1421 $object->fk_user = $supervisortoset;
1422 $res =
$object->update($user);
1442 $toselect = array();
1448if (!$error && ($action ==
'affectuser' && $confirm ==
'yes') && $permissiontoadd) {
1452 $usertoaffect =
GETPOST(
'usertoaffect');
1453 $projectrole =
GETPOST(
'projectrole');
1454 $tasksrole =
GETPOST(
'tasksrole');
1455 if (!empty($usertoaffect)) {
1456 foreach ($toselect as $toselectid) {
1457 $result =
$object->fetch($toselectid);
1460 $res =
$object->add_contact($usertoaffect, $projectrole,
'internal');
1462 $taskstatic =
new Task($db);
1463 $task_array = $taskstatic->getTasksArray(
null,
null,
$object->id, 0, 0);
1465 foreach ($task_array as $task) {
1466 $tasksToAffect =
new Task($db);
1467 $result = $tasksToAffect->fetch($task->id);
1469 $res = $tasksToAffect->add_contact($usertoaffect, $tasksrole,
'internal');
1493 $toselect = array();
1499if (!$error && ($massaction ==
'enable' || ($action ==
'enable' && $confirm ==
'yes')) && $permissiontoadd) {
1502 $objecttmp =
new $objectclass($db);
1504 foreach ($toselect as $toselectid) {
1505 $result = $objecttmp->fetch($toselectid);
1507 if (in_array($objecttmp->element, array(
'societe'))) {
1508 $result = $objecttmp->setStatut(1);
1536if (!$error && ($massaction ==
'disable' || ($action ==
'disable' && $confirm ==
'yes')) && $permissiontoadd) {
1539 $objecttmp =
new $objectclass($db);
1541 foreach ($toselect as $toselectid) {
1542 $result = $objecttmp->fetch($toselectid);
1544 if (in_array($objecttmp->element, array(
'societe'))) {
1545 $result = $objecttmp->setStatut(0);
1573if (!$error && $action ==
'confirm_edit_value_extrafields' && $confirm ==
'yes' && $permissiontoadd) {
1576 $objecttmp =
new $objectclass($db);
1578 $e->fetch_name_optionals_label($objecttmp->table_element);
1581 $extrafieldKeyToUpdate =
GETPOST(
'extrafield-key-to-update');
1584 foreach ($toselect as $toselectid) {
1586 $objecttmp =
new $objectclass($db);
1587 $result = $objecttmp->fetch($toselectid);
1590 $ret = $e->setOptionalsFromPost(
null, $objecttmp, $extrafieldKeyToUpdate);
1592 $objecttmp->insertExtraFields();
1616if (!$error && ($massaction ==
'assignsalerepresentative' || ($action ==
'assignsalerepresentative' && $confirm ==
'yes')) && $permissiontoadd) {
1619 $objecttmp =
new $objectclass($db);
1622 foreach ($toselect as $toselectid) {
1623 $result = $objecttmp->fetch($toselectid);
1625 if (in_array($objecttmp->element, array(
'societe'))) {
1626 $result = $objecttmp->setSalesRep(
GETPOST(
"commercial",
"alpha"));
1644 setEventMessages($langs->trans(
"CommercialsAffected", $nbok),
null,
'mesgs');
1654if (!$error && ($massaction ==
'unassigncommercial' || ($action ==
'unassigncommercial' && $confirm ==
'yes')) && $permissiontoadd) {
1657 $objecttmp =
new $objectclass($db);
1660 foreach ($toselect as $toselectid) {
1661 $result = $objecttmp->fetch($toselectid);
1663 if (in_array($objecttmp->element, array(
'societe'))) {
1664 $TCommercial =
GETPOST(
"commercial",
"alpha");
1665 if (is_array($TCommercial)) {
1666 foreach ($TCommercial as $commercial) {
1667 $result = $objecttmp->del_commercial($user, $commercial);
1687 setEventMessages($langs->trans(
"CommercialsDisaffected", $nbok),
null,
'mesgs');
1697if (!$error && ($massaction ==
'approveleave' || ($action ==
'approveleave' && $confirm ==
'yes')) && $permissiontoapprove) {
1700 $objecttmp =
new $objectclass($db);
1701 '@phan-var-force Holiday $objecttmp';
1703 foreach ($toselect as $toselectid) {
1704 $result = $objecttmp->fetch($toselectid);
1707 setEventMessages($langs->trans(
'StatusOfRefMustBe', $objecttmp->ref, $langs->transnoentitiesnoconv(
'Validated')),
null,
'warnings');
1710 if ($user->id == $objecttmp->fk_validator) {
1711 $objecttmp->oldcopy =
dol_clone($objecttmp, 2);
1713 $objecttmp->date_valid =
dol_now();
1714 $objecttmp->fk_user_valid = $user->id;
1715 $objecttmp->date_approval =
dol_now();
1716 $objecttmp->fk_user_approve = $user->id;
1718 $objecttmp->statut = $objecttmp->status;
1720 $verif = $objecttmp->approve($user);
1730 $nbopenedday =
num_open_day($objecttmp->date_debut_gmt, $objecttmp->date_fin_gmt, 0, 1, $objecttmp->halfday);
1731 $soldeActuel = $objecttmp->getCpforUser($objecttmp->fk_user, $objecttmp->fk_type);
1732 $newSolde = ($soldeActuel - $nbopenedday);
1735 $result = $objecttmp->addLogCP($user->id, $objecttmp->fk_user, $langs->transnoentitiesnoconv(
"Holidays"), $newSolde, $objecttmp->fk_type);
1742 $result = $objecttmp->updateSoldeCP($objecttmp->fk_user, $newSolde, $objecttmp->fk_type);
1751 $destinataire =
new User($db);
1752 $destinataire->fetch($objecttmp->fk_user);
1753 $emailTo = $destinataire->email;
1756 dol_syslog(
"User that request leave has no email, so we redirect directly to finished page without sending email");
1759 $expediteur =
new User($db);
1760 $expediteur->fetch($objecttmp->fk_validator);
1770 $subject = $societeName.
" - ".$langs->transnoentitiesnoconv(
"HolidaysValidated");
1773 $message = $langs->transnoentitiesnoconv(
"Hello").
" ".$destinataire->firstname.
",\n";
1776 $message .= $langs->transnoentities(
"HolidaysValidatedBody",
dol_print_date($objecttmp->date_debut,
'day'),
dol_print_date($objecttmp->date_fin,
'day')).
"\n";
1778 $message .=
"- ".$langs->transnoentitiesnoconv(
"ValidatedBy").
" : ".
dolGetFirstLastname($expediteur->firstname, $expediteur->lastname).
"\n";
1780 $message .=
"- ".$langs->transnoentitiesnoconv(
"Link").
" : ".$dolibarr_main_url_root.
"/holiday/card.php?id=".$objecttmp->id.
"\n\n";
1783 $trackid =
'leav'.$objecttmp->id;
1785 require_once DOL_DOCUMENT_ROOT.
'/core/class/CMailFile.class.php';
1786 $mail =
new CMailFile($subject, $emailTo, $emailFrom, $message, array(), array(), array(),
'',
'', 0, 0,
'',
'', $trackid);
1789 $result = $mail->sendfile();
1798 $langs->load(
"errors");
1799 setEventMessages($langs->trans(
'ErrorNotApproverForHoliday', $objecttmp->ref),
null,
'errors');
1811 } elseif ($nbok == 1) {
1820if (!$error && ($massaction ==
'increaseholiday' || ($action ==
'increaseholiday' && $confirm ==
'yes')) && $permissiontoapprove && is_array($toselect)) {
1821 '@phan-var-force Holiday $holiday';
1823 $objecttmp =
new $objectclass($db);
1825 $typeholiday =
GETPOST(
'typeholiday',
'alpha');
1828 if ($nbdaysholidays <= 0) {
1834 foreach ($toselect as $toselectid) {
1835 $balancecpuser = $objecttmp->getCPforUser($toselectid, $typeholiday);
1836 if (!empty($balancecpuser)) {
1837 $newnbdaysholidays = $nbdaysholidays + $balancecpuser;
1839 $newnbdaysholidays = $nbdaysholidays;
1841 $result = $holiday->addLogCP($user->id, $toselectid, $langs->transnoentitiesnoconv(
'ManualUpdate'), $newnbdaysholidays, $typeholiday);
1848 $objecttmp->updateSoldeCP($toselectid, $newnbdaysholidays, $typeholiday);
1861 setEventMessages($langs->trans(
"HolidayRecordsIncreased", $nbok),
null,
'mesgs');
1862 } elseif ($nbok == 1) {
1866 $toselect = array();
1873if (!$error && ($massaction ==
'clonetasks' || ($action ==
'clonetasks' && $confirm ==
'yes'))) {
1876 include_once DOL_DOCUMENT_ROOT.
'/projet/class/task.class.php';
1878 $origin_task =
new Task($db);
1879 $clone_task =
new Task($db);
1880 $newproject =
new Project($db);
1884 $iscontactofnewproject = 0;
1885 if (empty($newproject->public)) {
1886 $tmps = $newproject->getProjectsAuthorizedForUser($user, 0, 1, 0,
'(fk_statut:=:1)');
1887 $tmparray = explode(
',', $tmps);
1888 if (!in_array($newproject->id, $tmparray)) {
1889 $iscontactofnewproject = 1;
1894 $permisstiontoadd =
false;
1895 if ($user->hasRight(
'project',
'all',
'creer') || ($user->hasRight(
'project',
'creer') && ($newproject->public || $iscontactofnewproject))) {
1896 $permisstiontoadd =
true;
1899 if ($permisstiontoadd) {
1900 foreach (
GETPOST(
'selected') as $task) {
1901 $origin_task->fetch($task,
'', 0);
1906 require_once DOL_DOCUMENT_ROOT .
"/core/modules/project/task/" .
getDolGlobalString(
'PROJECT_TASK_ADDON') .
'.php';
1907 $modTask =
new $classnamemodtask();
1908 '@phan-var-force ModeleNumRefTask $modTask';
1909 $defaultref = $modTask->getNextValue(
null, $clone_task);
1913 $clone_task->fk_project =
GETPOSTINT(
'projectid');
1914 $clone_task->ref = $defaultref;
1915 $clone_task->label = $origin_task->label;
1916 $clone_task->description = $origin_task->description;
1917 $clone_task->planned_workload = $origin_task->planned_workload;
1918 $clone_task->fk_task_parent = $origin_task->fk_task_parent;
1919 $clone_task->date_c =
dol_now();
1920 $clone_task->date_start = $origin_task->date_start;
1921 $clone_task->date_end = $origin_task->date_end;
1922 $clone_task->progress = $origin_task->progress;
1925 $ret = $extrafields->setOptionalsFromPost(
null, $clone_task);
1927 $taskid = $clone_task->create($user);
1930 $result = $clone_task->add_contact(
GETPOSTINT(
"userid"),
'TASKEXECUTIVE',
'internal');
1933 if ($db->lasterrno() ==
'DB_ERROR_RECORD_ALREADY_EXISTS') {
1934 $langs->load(
"projects");
1936 $duplicate_code_error =
true;
1947 setEventMessages($langs->trans(
'NumberOfTasksCloned', $num),
null,
'mesgs');
1948 header(
"Location: ".DOL_URL_ROOT.
'/projet/tasks.php?id='.
GETPOSTINT(
'projectid'));
1956if (empty($toselect)) {
1959$parameters[
'toselect'] = &$toselect;
1960$parameters[
'uploaddir'] = $uploaddir;
1961$parameters[
'massaction'] = $massaction;
1962$parameters[
'diroutputmassaction'] = isset($diroutputmassaction) ? $diroutputmassaction :
null;
1964$reshook = $hookmanager->executeHooks(
'doMassActions', $parameters,
$object, $action);
if( $user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $object
Class to manage members of a foundation.
Class to send emails (with attachments or not) Usage: $mailfile = new CMailFile($subject,...
Class to manage categories.
Class to manage customers orders.
const STATUS_DRAFT
Draft status.
const STATUS_VALIDATED
Validated status.
Class for ConferenceOrBoothAttendee.
const STATUS_DRAFT
Draft status.
const STATUS_VALIDATED
Validated (need to be paid)
const STATUS_VALIDATED
Validated status.
const STATUS_DRAFT
Draft status.
const STATUS_REFUSED
Refused.
const STATUS_CANCELED
Canceled.
const STATUS_APPROVED
Approved.
Class to manage projects.
const STATUS_DRAFT
Draft status.
Class to manage third parties objects (customers, suppliers, prospects...)
Class to manage translations.
Class to manage Dolibarr users.
num_open_day($timestampStart, $timestampEnd, $inhour=0, $lastday=0, $halfday=0, $country_code='')
Function to return number of working days (and text of units) between two dates (working days)
dol_delete_file($file, $disableglob=0, $nophperrors=0, $nohook=0, $object=null, $allowdotdot=false, $indexdatabase=1, $nolog=0)
Remove a file or several files with a mask.
dol_is_file($pathoffile)
Return if path is a file.
dol_dir_list($utf8_path, $types="all", $recursive=0, $filter="", $excludefilter=null, $sortcriteria="name", $sortorder=SORT_ASC, $mode=0, $nohook=0, $relativename="", $donotfollowsymlinks=0, $nbsecondsold=0)
Scan a directory and return a list of files/directories.
dol_most_recent_file($dir, $regexfilter='', $excludefilter=array('(\.meta|_preview.*\.png) $', '^\.'), $nohook=0, $mode=0)
Return file(s) into a directory (by default most recent)
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.
GETPOSTINT($paramname, $method=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
dol_string_nospecial($str, $newstr='_', $badcharstoreplace='', $badcharstoremove='', $keepspaces=0)
Clean a string from all punctuation characters to use it as a ref or login.
setEventMessage($mesgs, $style='mesgs', $noduplicate=0, $attop=0)
Set event message in dol_events session object.
dolChmod($filepath, $newmask='')
Change mod of a file.
dol_now($mode='auto')
Return date for now.
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs=null, $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
dolGetFirstLastname($firstname, $lastname, $nameorder=-1)
Return firstname and lastname in correct order.
dol_concatdesc($text1, $text2, $forxml=false, $invert=false)
Concat 2 descriptions with a new line between them (second operand after first one with appropriate n...
complete_substitutions_array(&$substitutionarray, $outputlangs, $object=null, $parameters=null, $callfunc="completesubstitutionarray")
Complete the $substitutionarray with more entries coming from external module that had set the "subst...
make_substitutions($text, $substitutionarray, $outputlangs=null, $converttextinhtmlifnecessary=0)
Make substitution into a text string, replacing keys with vals from $substitutionarray (oldval=>newva...
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
GETPOSTFLOAT($paramname, $rounding='')
Return the value of a $_GET or $_POST supervariable, converted into float.
dol_clone($object, $native=2)
Create a clone of instance of object (new instance with same value for each properties) With native =...
dol_print_error($db=null, $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
getCommonSubstitutionArray($outputlangs, $onlykey=0, $exclude=null, $object=null, $include=null)
Return array of possible common substitutions.
dol_sanitizeFileName($str, $newstr='_', $unaccent=1, $includequotes=0)
Clean a string to use it as a file name.
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
get_exdir($num, $level, $alpha, $withoutslash, $object, $modulepart='')
Return a path to have a the directory according to object where files are stored.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
dol_mkdir($dir, $dataroot='', $newmask='')
Creation of a directory (this can create recursive subdir)
global $conf
The following vars must be defined: $type2label $form $conf, $lang, The following vars may also be de...
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.