30 require
'../main.inc.php';
31 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formexpensereport.class.php';
32 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formfile.class.php';
33 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formmail.class.php';
34 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formprojet.class.php';
35 require_once DOL_DOCUMENT_ROOT.
'/core/class/CMailFile.class.php';
36 require_once DOL_DOCUMENT_ROOT.
'/projet/class/project.class.php';
37 require_once DOL_DOCUMENT_ROOT.
'/ecm/class/ecmfiles.class.php';
38 require_once DOL_DOCUMENT_ROOT.
'/compta/bank/class/account.class.php';
39 require_once DOL_DOCUMENT_ROOT.
'/core/lib/expensereport.lib.php';
40 require_once DOL_DOCUMENT_ROOT.
'/core/lib/price.lib.php';
41 require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
42 require_once DOL_DOCUMENT_ROOT.
'/core/lib/images.lib.php';
43 require_once DOL_DOCUMENT_ROOT.
'/core/modules/expensereport/modules_expensereport.php';
44 require_once DOL_DOCUMENT_ROOT.
'/expensereport/class/expensereport.class.php';
45 require_once DOL_DOCUMENT_ROOT.
'/expensereport/class/paymentexpensereport.class.php';
46 require_once DOL_DOCUMENT_ROOT.
'/core/class/doleditor.class.php';
47 require_once DOL_DOCUMENT_ROOT.
'/core/class/extrafields.class.php';
49 require_once DOL_DOCUMENT_ROOT.
'/accountancy/class/accountingjournal.class.php';
53 $langs->loadLangs(array(
"trips",
"bills",
"mails"));
55 $action =
GETPOST(
'action',
'aZ09');
56 $cancel =
GETPOST(
'cancel',
'alpha');
57 $confirm =
GETPOST(
'confirm',
'alpha');
63 $fk_project =
GETPOST(
'fk_project',
'int');
64 $vatrate =
GETPOST(
'vatrate',
'alpha');
66 $comments =
GETPOST(
'comments',
'restricthtml');
67 $fk_c_type_fees =
GETPOST(
'fk_c_type_fees',
'int');
70 $childids = $user->getAllChildIds(1);
72 if (!empty($conf->global->EXPENSEREPORT_PREFILL_DATES_WITH_CURRENT_MONTH)) {
73 if (empty($date_start)) {
77 if (empty($date_end)) {
84 $rootfordata = DOL_DATA_ROOT;
85 $rootforuser = DOL_DATA_ROOT;
87 if (
isModEnabled(
'multicompany') && !empty($conf->entity) && $conf->entity > 1) {
88 $rootfordata .=
'/'.$conf->entity;
90 $conf->expensereport->dir_output = $rootfordata.
'/expensereport';
93 $urlwithouturlroot = preg_replace(
'/'.preg_quote(DOL_URL_ROOT,
'/').
'$/i',
'', trim($dolibarr_main_url_root));
94 $urlwithroot = $urlwithouturlroot.DOL_URL_ROOT;
98 $hidedetails = (
GETPOST(
'hidedetails',
'int') ?
GETPOST(
'hidedetails',
'int') : (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DETAILS) ? 1 : 0));
99 $hidedesc = (
GETPOST(
'hidedesc',
'int') ?
GETPOST(
'hidedesc',
'int') : (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DESC) ? 1 : 0));
100 $hideref = (
GETPOST(
'hideref',
'int') ?
GETPOST(
'hideref',
'int') : (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_REF) ? 1 : 0));
107 $extrafields->fetch_name_optionals_label($object->table_element);
110 include DOL_DOCUMENT_ROOT.
'/core/actions_fetchobject.inc.php';
113 $hookmanager->initHooks(array(
'expensereportcard',
'globalcard'));
115 $permissionnote = $user->rights->expensereport->creer;
116 $permissiondellink = $user->rights->expensereport->creer;
117 $permissiontoadd = $user->rights->expensereport->creer;
121 $projectRequired =
isModEnabled(
'project') && !empty($conf->global->EXPENSEREPORT_PROJECT_IS_REQUIRED);
122 $fileRequired = !empty($conf->global->EXPENSEREPORT_FILE_IS_REQUIRED);
124 if ($object->id > 0) {
127 if (!empty($user->rights->expensereport->readall)) {
130 if (!empty($user->rights->expensereport->lire) && in_array($object->fk_user_author, $childids)) {
139 if (!empty($user->rights->expensereport->supprimer)) {
142 if ($object->statut ==
ExpenseReport::STATUS_DRAFT && $user->hasRight(
'expensereport',
'write') && in_array($object->fk_user_author, $childids)) {
148 $socid = $user->socid;
150 $result =
restrictedArea($user,
'expensereport', $object->id,
'expensereport');
152 $permissiontoadd = $user->rights->expensereport->creer;
163 $reshook = $hookmanager->executeHooks(
'doActions',
$parameters, $object, $action);
168 if (empty($reshook)) {
169 $backurlforlist = DOL_URL_ROOT.
'/expensereport/list.php';
171 if (empty($backtopage) || ($cancel && empty($id))) {
172 if (empty($backtopage) || ($cancel && strpos($backtopage,
'__ID__'))) {
173 if (empty($id) && (($action !=
'add' && $action !=
'create') || $cancel)) {
174 $backtopage = $backurlforlist;
176 $backtopage = DOL_URL_ROOT.
'/expensereport/card.php?id='.((!empty($id) && $id > 0) ? $id :
'__ID__');
182 if (!empty($backtopageforcancel)) {
183 header(
"Location: ".$backtopageforcancel);
185 } elseif (!empty($backtopage)) {
186 header(
"Location: ".$backtopage);
200 $fk_c_type_fees = -1;
203 include DOL_DOCUMENT_ROOT.
'/core/actions_linkedfiles.inc.php';
205 if (!empty(
GETPOST(
'sendit',
'alpha'))) {
206 if ($action ==
'updateline') {
207 $action =
'editline';
213 include DOL_DOCUMENT_ROOT.
'/core/actions_setnotes.inc.php';
215 include DOL_DOCUMENT_ROOT.
'/core/actions_dellink.inc.php';
217 include DOL_DOCUMENT_ROOT.
'/core/actions_lineupdown.inc.php';
220 if ($action ==
'confirm_clone' && $confirm ==
'yes' && $user->rights->expensereport->creer) {
221 if (1 == 0 && !
GETPOST(
'clone_content',
'alpha') && !
GETPOST(
'clone_receivers',
'alpha')) {
224 if ($object->id > 0) {
226 $orig = clone $object;
228 $result = $object->createFromClone($user,
GETPOST(
'fk_user_author',
'int'));
230 header(
"Location: ".$_SERVER[
'PHP_SELF'].
'?id='.$result);
241 if ($action ==
'confirm_delete' &&
GETPOST(
"confirm",
'alpha') ==
"yes" && $id > 0 && $candelete) {
243 $result = $object->fetch($id);
244 $result = $object->delete($user);
246 header(
"Location: index.php");
253 if ($action ==
'add' && $user->rights->expensereport->creer) {
258 $object->date_debut = $date_start;
259 $object->date_fin = $date_end;
261 $object->fk_user_author =
GETPOST(
'fk_user_author',
'int');
262 if (!($object->fk_user_author > 0)) {
263 $object->fk_user_author = $user->id;
267 if ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && empty($user->rights->expensereport->creer))
268 || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && empty($user->rights->expensereport->creer) && empty($user->rights->expensereport->writeall_advance))) {
273 if (empty($conf->global->MAIN_USE_ADVANCED_PERMS) || empty($user->rights->expensereport->writeall_advance)) {
274 if (!in_array($object->fk_user_author, $childids)) {
281 $fuser =
new User($db);
282 $fuser->fetch($object->fk_user_author);
285 $object->fk_c_paiement =
GETPOST(
'fk_c_paiement',
'int');
286 $object->fk_user_validator =
GETPOST(
'fk_user_validator',
'int');
287 $object->note_public =
GETPOST(
'note_public',
'restricthtml');
288 $object->note_private =
GETPOST(
'note_private',
'restricthtml');
291 $ret = $extrafields->setOptionalsFromPost(
null, $object);
297 if (!$error && empty($conf->global->EXPENSEREPORT_ALLOW_OVERLAPPING_PERIODS)) {
298 $overlappingExpenseReportID = $object->periode_existe($fuser, $object->date_debut, $object->date_fin);
300 if ($overlappingExpenseReportID > 0) {
302 setEventMessages($langs->trans(
"ErrorDoubleDeclaration").
' <a href="'.$_SERVER[
'PHP_SELF'].
'?id='.$overlappingExpenseReportID.
'">'. $langs->trans(
'ShowTrip').
'</a>',
null,
'errors');
310 $id = $object->create($user);
317 Header(
"Location: ".$_SERVER[
"PHP_SELF"].
"?id=".$id);
327 if ($action ==
'update' && $user->rights->expensereport->creer) {
331 $object->date_debut = $date_start;
332 $object->date_fin = $date_end;
334 if ($object->status < 3) {
335 $object->fk_user_validator =
GETPOST(
'fk_user_validator',
'int');
338 $object->fk_c_paiement =
GETPOST(
'fk_c_paiement',
'int');
339 $object->note_public =
GETPOST(
'note_public',
'restricthtml');
340 $object->note_private =
GETPOST(
'note_private',
'restricthtml');
341 $object->fk_user_modif = $user->id;
343 $result = $object->update($user);
345 header(
"Location: ".$_SERVER[
"PHP_SELF"].
"?id=".
GETPOST(
'id',
'int'));
352 if ($action ==
'update_extras') {
356 $ret = $extrafields->setOptionalsFromPost(
null, $object,
GETPOST(
'attribute',
'restricthtml'));
363 $result = $object->insertExtraFields(
'EXPENSEREPORT_MODIFY');
371 $action =
'edit_extras';
375 if ($action ==
"confirm_validate" &&
GETPOST(
"confirm",
'alpha') ==
"yes" && $id > 0 && $user->rights->expensereport->creer) {
383 $result = $object->setValidate($user);
387 if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) {
388 $outputlangs = $langs;
391 $newlang =
GETPOST(
'lang_id',
'aZ09');
394 $newlang = $object->thirdparty->default_lang;
396 if (!empty($newlang)) {
398 $outputlangs->setDefaultLang($newlang);
400 $model = $object->model_pdf;
401 $ret = $object->fetch($id);
403 $object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref);
410 if (!$error && $result > 0 && $object->fk_user_validator > 0) {
411 $langs->load(
"mails");
414 $destinataire =
new User($db);
415 $destinataire->fetch($object->fk_user_validator);
416 $emailTo = $destinataire->email;
419 $expediteur =
new User($db);
420 $expediteur->fetch($object->fk_user_author);
421 $emailFrom = $conf->global->MAIN_MAIL_EMAIL_FROM;
423 if ($emailTo && $emailFrom) {
424 $filename = array(); $filedir = array(); $mimetype = array();
427 $societeName = $conf->global->MAIN_INFO_SOCIETE_NOM;
428 if (!empty($conf->global->MAIN_APPLICATION_TITLE)) {
429 $societeName = $conf->global->MAIN_APPLICATION_TITLE;
432 $subject = $societeName.
" - ".$langs->transnoentities(
"ExpenseReportWaitingForApproval");
435 $link = $urlwithroot.
'/expensereport/card.php?id='.$object->id;
436 $link =
'<a href="'.$link.
'">'.$link.
'</a>';
437 $message = $langs->transnoentities(
"ExpenseReportWaitingForApprovalMessage", $expediteur->getFullName($langs),
get_date_range($object->date_debut, $object->date_fin,
'', $langs), $link);
452 $mailfile =
new CMailFile($subject, $emailTo, $emailFrom, $message, $filedir, $mimetype, $filename,
'',
'', 0, -1);
456 $result = $mailfile->sendfile();
458 $mesg = $langs->trans(
'MailSuccessfulySent', $mailfile->getValidAddress($emailFrom, 2), $mailfile->getValidAddress($emailTo, 2));
461 $langs->load(
"other");
462 if ($mailfile->error) {
464 $mesg .= $langs->trans(
'ErrorFailedToSendMail', $emailFrom, $emailTo);
465 $mesg .=
'<br>'.$mailfile->error;
468 setEventMessages(
'No mail sent. Feature is disabled by option MAIN_DISABLE_ALL_MAILS',
null,
'warnings');
476 setEventMessages($langs->trans(
"NoEmailSentBadSenderOrRecipientEmail"),
null,
'warnings');
483 header(
"Location: ".$_SERVER[
"PHP_SELF"].
"?id=".$id);
490 if ($action ==
"confirm_save_from_refuse" &&
GETPOST(
"confirm",
'alpha') ==
"yes" && $id > 0 && $user->rights->expensereport->creer) {
493 $result = $object->set_save_from_refuse($user);
497 if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) {
498 $outputlangs = $langs;
501 $newlang =
GETPOST(
'lang_id',
'aZ09');
504 $newlang = $object->thirdparty->default_lang;
506 if (!empty($newlang)) {
508 $outputlangs->setDefaultLang($newlang);
510 $model = $object->model_pdf;
511 $ret = $object->fetch($id);
513 $object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref);
521 $destinataire =
new User($db);
522 $destinataire->fetch($object->fk_user_validator);
523 $emailTo = $destinataire->email;
526 $expediteur =
new User($db);
527 $expediteur->fetch($object->fk_user_author);
528 $emailFrom = $conf->global->MAIN_MAIL_EMAIL_FROM;
530 if ($emailFrom && $emailTo) {
531 $filename = array(); $filedir = array(); $mimetype = array();
534 $societeName = $conf->global->MAIN_INFO_SOCIETE_NOM;
535 if (!empty($conf->global->MAIN_APPLICATION_TITLE)) {
536 $societeName = $conf->global->MAIN_APPLICATION_TITLE;
539 $subject = $societeName.
" - ".$langs->transnoentities(
"ExpenseReportWaitingForReApproval");
542 $link = $urlwithroot.
'/expensereport/card.php?id='.$object->id;
543 $link =
'<a href="'.$link.
'">'.$link.
'</a>';
544 $dateRefusEx = explode(
" ", $object->date_refuse);
545 $message = $langs->transnoentities(
"ExpenseReportWaitingForReApprovalMessage", $dateRefusEx[0], $object->detail_refuse, $expediteur->getFullName($langs), $link);
564 $mailfile =
new CMailFile($subject, $emailTo, $emailFrom, $message, $filedir, $mimetype, $filename,
'',
'', 0, -1);
568 $result = $mailfile->sendfile();
570 $mesg = $langs->trans(
'MailSuccessfulySent', $mailfile->getValidAddress($emailFrom, 2), $mailfile->getValidAddress($emailTo, 2));
572 header(
"Location: ".$_SERVER[
"PHP_SELF"].
"?id=".$id);
575 $langs->load(
"other");
576 if ($mailfile->error) {
578 $mesg .= $langs->trans(
'ErrorFailedToSendMail', $emailFrom, $emailTo);
579 $mesg .=
'<br>'.$mailfile->error;
582 setEventMessages(
'No mail sent. Feature is disabled by option MAIN_DISABLE_ALL_MAILS',
null,
'warnings');
590 setEventMessages($langs->trans(
"NoEmailSentBadSenderOrRecipientEmail"),
null,
'warnings');
599 if ($action ==
"confirm_approve" &&
GETPOST(
"confirm",
'alpha') ==
"yes" && $id > 0 && $user->rights->expensereport->approve) {
603 $result = $object->setApproved($user);
607 if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) {
608 $outputlangs = $langs;
611 $newlang =
GETPOST(
'lang_id',
'aZ09');
614 $newlang = $object->thirdparty->default_lang;
616 if (!empty($newlang)) {
618 $outputlangs->setDefaultLang($newlang);
620 $model = $object->model_pdf;
621 $ret = $object->fetch($id);
623 $object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref);
631 $destinataire =
new User($db);
632 $destinataire->fetch($object->fk_user_author);
633 $emailTo = $destinataire->email;
636 $emailCC = $conf->global->NDF_CC_EMAILS;
637 if (empty($emailTo)) {
642 $expediteur =
new User($db);
643 $expediteur->fetch($object->fk_user_approve > 0 ? $object->fk_user_approve : $object->fk_user_validator);
644 $emailFrom = $conf->global->MAIN_MAIL_EMAIL_FROM;
646 if ($emailFrom && $emailTo) {
647 $filename = array(); $filedir = array(); $mimetype = array();
650 $societeName = $conf->global->MAIN_INFO_SOCIETE_NOM;
651 if (!empty($conf->global->MAIN_APPLICATION_TITLE)) {
652 $societeName = $conf->global->MAIN_APPLICATION_TITLE;
655 $subject = $societeName.
" - ".$langs->transnoentities(
"ExpenseReportApproved");
658 $link = $urlwithroot.
'/expensereport/card.php?id='.$object->id;
659 $link =
'<a href="'.$link.
'">'.$link.
'</a>';
660 $message = $langs->transnoentities(
"ExpenseReportApprovedMessage", $object->ref, $destinataire->getFullName($langs), $expediteur->getFullName($langs), $link);
677 $mailfile =
new CMailFile($subject, $emailTo, $emailFrom, $message, $filedir, $mimetype, $filename,
'',
'', 0, -1);
681 $result = $mailfile->sendfile();
683 $mesg = $langs->trans(
'MailSuccessfulySent', $mailfile->getValidAddress($emailFrom, 2), $mailfile->getValidAddress($emailTo, 2));
685 header(
"Location: ".$_SERVER[
"PHP_SELF"].
"?id=".$id);
688 $langs->load(
"other");
689 if ($mailfile->error) {
691 $mesg .= $langs->trans(
'ErrorFailedToSendMail', $emailFrom, $emailTo);
692 $mesg .=
'<br>'.$mailfile->error;
695 setEventMessages(
'No mail sent. Feature is disabled by option MAIN_DISABLE_ALL_MAILS',
null,
'warnings');
703 setEventMessages($langs->trans(
"NoEmailSentBadSenderOrRecipientEmail"),
null,
'warnings');
712 if ($action ==
"confirm_refuse" &&
GETPOST(
'confirm',
'alpha') ==
"yes" && $id > 0 && $user->rights->expensereport->approve) {
716 $detailRefuse =
GETPOST(
'detail_refuse',
'alpha');
717 $result = $object->setDeny($user, $detailRefuse);
721 if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) {
722 $outputlangs = $langs;
725 $newlang =
GETPOST(
'lang_id',
'aZ09');
728 $newlang = $object->thirdparty->default_lang;
730 if (!empty($newlang)) {
732 $outputlangs->setDefaultLang($newlang);
734 $model = $object->model_pdf;
735 $ret = $object->fetch($id);
737 $object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref);
745 $destinataire =
new User($db);
746 $destinataire->fetch($object->fk_user_author);
747 $emailTo = $destinataire->email;
750 $expediteur =
new User($db);
751 $expediteur->fetch($object->fk_user_refuse);
752 $emailFrom = $conf->global->MAIN_MAIL_EMAIL_FROM;
754 if ($emailFrom && $emailTo) {
755 $filename = array(); $filedir = array(); $mimetype = array();
758 $societeName = $conf->global->MAIN_INFO_SOCIETE_NOM;
759 if (!empty($conf->global->MAIN_APPLICATION_TITLE)) {
760 $societeName = $conf->global->MAIN_APPLICATION_TITLE;
763 $subject = $societeName.
" - ".$langs->transnoentities(
"ExpenseReportRefused");
766 $link = $urlwithroot.
'/expensereport/card.php?id='.$object->id;
767 $link =
'<a href="'.$link.
'">'.$link.
'</a>';
768 $message = $langs->transnoentities(
"ExpenseReportRefusedMessage", $object->ref, $destinataire->getFullName($langs), $expediteur->getFullName($langs), $detailRefuse, $link);
786 $mailfile =
new CMailFile($subject, $emailTo, $emailFrom, $message, $filedir, $mimetype, $filename,
'',
'', 0, -1);
790 $result = $mailfile->sendfile();
792 $mesg = $langs->trans(
'MailSuccessfulySent', $mailfile->getValidAddress($emailFrom, 2), $mailfile->getValidAddress($emailTo, 2));
794 header(
"Location: ".$_SERVER[
"PHP_SELF"].
"?id=".$id);
797 $langs->load(
"other");
798 if ($mailfile->error) {
800 $mesg .= $langs->trans(
'ErrorFailedToSendMail', $emailFrom, $emailTo);
801 $mesg .=
'<br>'.$mailfile->error;
804 setEventMessages(
'No mail sent. Feature is disabled by option MAIN_DISABLE_ALL_MAILS',
null,
'warnings');
812 setEventMessages($langs->trans(
"NoEmailSentBadSenderOrRecipientEmail"),
null,
'warnings');
822 if ($action ==
"confirm_cancel" &&
GETPOST(
'confirm',
'alpha') ==
"yes" && $id > 0 && $user->rights->expensereport->creer) {
823 if (!
GETPOST(
'detail_cancel',
'alpha')) {
824 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Comment")),
null,
'errors');
829 if ($user->id == $object->fk_user_valid || $user->id == $object->fk_user_author) {
830 $detailCancel =
GETPOST(
'detail_cancel',
'alpha');
831 $result = $object->set_cancel($user, $detailCancel);
835 if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) {
836 $outputlangs = $langs;
839 $newlang =
GETPOST(
'lang_id',
'aZ09');
842 $newlang = $object->thirdparty->default_lang;
844 if (!empty($newlang)) {
846 $outputlangs->setDefaultLang($newlang);
848 $model = $object->model_pdf;
849 $ret = $object->fetch($id);
851 $object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref);
859 $destinataire =
new User($db);
860 $destinataire->fetch($object->fk_user_author);
861 $emailTo = $destinataire->email;
864 $expediteur =
new User($db);
865 $expediteur->fetch($object->fk_user_cancel);
866 $emailFrom = $conf->global->MAIN_MAIL_EMAIL_FROM;
868 if ($emailFrom && $emailTo) {
869 $filename = array(); $filedir = array(); $mimetype = array();
872 $societeName = $conf->global->MAIN_INFO_SOCIETE_NOM;
873 if (!empty($conf->global->MAIN_APPLICATION_TITLE)) {
874 $societeName = $conf->global->MAIN_APPLICATION_TITLE;
877 $subject = $societeName.
" - ".$langs->transnoentities(
"ExpenseReportCanceled");
880 $link = $urlwithroot.
'/expensereport/card.php?id='.$object->id;
881 $link =
'<a href="'.$link.
'">'.$link.
'</a>';
882 $message = $langs->transnoentities(
"ExpenseReportCanceledMessage", $object->ref, $destinataire->getFullName($langs), $expediteur->getFullName($langs), $detailCancel, $link);
900 $mailfile =
new CMailFile($subject, $emailTo, $emailFrom, $message, $filedir, $mimetype, $filename,
'',
'', 0, -1);
904 $result = $mailfile->sendfile();
906 $mesg = $langs->trans(
'MailSuccessfulySent', $mailfile->getValidAddress($emailFrom, 2), $mailfile->getValidAddress($emailTo, 2));
908 header(
"Location: ".$_SERVER[
"PHP_SELF"].
"?id=".$id);
911 $langs->load(
"other");
912 if ($mailfile->error) {
914 $mesg .= $langs->trans(
'ErrorFailedToSendMail', $emailFrom, $emailTo);
915 $mesg .=
'<br>'.$mailfile->error;
918 setEventMessages(
'No mail sent. Feature is disabled by option MAIN_DISABLE_ALL_MAILS',
null,
'warnings');
926 setEventMessages($langs->trans(
"NoEmailSentBadSenderOrRecipientEmail"),
null,
'warnings');
939 if ($action ==
"confirm_setdraft" &&
GETPOST(
'confirm',
'alpha') ==
"yes" && $id > 0 && $user->rights->expensereport->creer) {
942 if ($user->id == $object->fk_user_author || $user->id == $object->fk_user_valid) {
943 $result = $object->setStatut(0);
947 if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) {
948 $outputlangs = $langs;
951 $newlang =
GETPOST(
'lang_id',
'aZ09');
954 $newlang = $object->thirdparty->default_lang;
956 if (!empty($newlang)) {
958 $outputlangs->setDefaultLang($newlang);
960 $model = $object->model_pdf;
961 $ret = $object->fetch($id);
963 $object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref);
968 header(
"Location: ".$_SERVER[
"PHP_SELF"].
"?id=".$id);
978 if ($action ==
'set_unpaid' && $id > 0 && $user->rights->expensereport->to_paid) {
982 $result = $object->setUnpaid($user);
986 if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) {
987 $outputlangs = $langs;
990 $newlang =
GETPOST(
'lang_id',
'aZ09');
993 $newlang = $object->thirdparty->default_lang;
995 if (!empty($newlang)) {
997 $outputlangs->setDefaultLang($newlang);
999 $model = $object->model_pdf;
1000 $ret = $object->fetch($id);
1002 $object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref);
1007 if ($action ==
'set_paid' && $id > 0 && $user->rights->expensereport->to_paid) {
1009 $object->fetch($id);
1011 $result = $object->setPaid($id, $user);
1015 if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) {
1016 $outputlangs = $langs;
1019 $newlang =
GETPOST(
'lang_id',
'aZ09');
1022 $newlang = $object->thirdparty->default_lang;
1024 if (!empty($newlang)) {
1025 $outputlangs =
new Translate(
"", $conf);
1026 $outputlangs->setDefaultLang($newlang);
1028 $model = $object->model_pdf;
1029 $ret = $object->fetch($id);
1031 $object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref);
1039 $destinataire =
new User($db);
1040 $destinataire->fetch($object->fk_user_author);
1041 $emailTo = $destinataire->email;
1044 $expediteur =
new User($db);
1045 $expediteur->fetch($user->id);
1046 $emailFrom = $conf->global->MAIN_MAIL_EMAIL_FROM;
1048 if ($emailFrom && $emailTo) {
1049 $filename = array(); $filedir = array(); $mimetype = array();
1052 $societeName = $conf->global->MAIN_INFO_SOCIETE_NOM;
1053 if (!empty($conf->global->MAIN_APPLICATION_TITLE)) {
1054 $societeName = $conf->global->MAIN_APPLICATION_TITLE;
1057 $subject = $societeName.
" - ".$langs->transnoentities(
"ExpenseReportPaid");
1060 $link = $urlwithroot.
'/expensereport/card.php?id='.$object->id;
1061 $link =
'<a href="'.$link.
'">'.$link.
'</a>';
1062 $message = $langs->transnoentities(
"ExpenseReportPaidMessage", $object->ref, $destinataire->getFullName($langs), $expediteur->getFullName($langs), $link);
1065 $object->setDocModel($user,
"");
1066 $resultPDF = expensereport_pdf_create($db, $object,
'',
"", $langs);
1069 $mailfile =
new CMailFile($subject, $emailTo, $emailFrom, $message, $filedir, $mimetype, $filename,
'',
'', 0, -1);
1073 $result = $mailfile->sendfile();
1075 $mesg = $langs->trans(
'MailSuccessfulySent', $mailfile->getValidAddress($emailFrom, 2), $mailfile->getValidAddress($emailTo, 2));
1077 header(
"Location: ".$_SERVER[
"PHP_SELF"].
"?id=".$id);
1080 $langs->load(
"other");
1081 if ($mailfile->error) {
1083 $mesg .= $langs->trans(
'ErrorFailedToSendMail', $emailFrom, $emailTo);
1084 $mesg .=
'<br>'.$mailfile->error;
1087 setEventMessages(
'No mail sent. Feature is disabled by option MAIN_DISABLE_ALL_MAILS',
null,
'warnings');
1095 setEventMessages($langs->trans(
"NoEmailSentBadSenderOrRecipientEmail"),
null,
'warnings');
1104 if ($action ==
"addline" && $user->rights->expensereport->creer) {
1110 $arrayoffiles =
GETPOST(
'attachfile',
'array');
1111 if (is_array($arrayoffiles) && !empty($arrayoffiles[0])) {
1112 include_once DOL_DOCUMENT_ROOT.
'/ecm/class/ecmfiles.class.php';
1113 $entityprefix = ($conf->entity !=
'1') ? $conf->entity.
'/' :
'';
1114 $relativepath =
'expensereport/'.$object->ref.
'/'.$arrayoffiles[0];
1116 $ecmfiles->
fetch(0,
'', $relativepath);
1117 $fk_ecm_files = $ecmfiles->id;
1122 if (empty($vatrate)) {
1125 $tmpvat =
price2num(preg_replace(
'/\s*\(.*\)/',
'', $vatrate));
1129 if (empty($value_unit)) {
1130 $value_unit =
price2num($value_unit_ht + ($value_unit_ht * $tmpvat / 100),
'MU');
1133 $fk_c_exp_tax_cat =
GETPOST(
'fk_c_exp_tax_cat',
'int');
1140 if (!($fk_c_type_fees > 0)) {
1142 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Type")),
null,
'errors');
1146 if ((
float) $tmpvat < 0 || $tmpvat ===
'') {
1148 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"VAT")),
null,
'errors');
1153 if (empty($date) || $date ==
"--") {
1155 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Date")),
null,
'errors');
1156 } elseif ($date < $object->date_debut || $date > ($object->date_fin + (24 * 3600 - 1))) {
1158 $langs->load(
"errors");
1159 setEventMessages($langs->trans(
"WarningDateOfLineMustBeInExpenseReportRange"),
null,
'warnings');
1163 if ($value_unit == 0) {
1165 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"PriceUTTC")),
null,
'errors');
1169 if ($projectRequired && $fk_project <= 0) {
1171 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Project")),
null,
'errors');
1175 if ($fileRequired && $fk_ecm_files == 0) {
1177 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"File")),
null,
'errors');
1184 $result = $object->addline($qty, $value_unit, $fk_c_type_fees, $vatrate, $date, $comments, $fk_project, $fk_c_exp_tax_cat, $type, $fk_ecm_files);
1186 $ret = $object->fetch($object->id);
1188 if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) {
1190 $outputlangs = $langs;
1191 $newlang =
GETPOST(
'lang_id',
'alpha');
1193 $newlang = $object->thirdparty->default_lang;
1195 if (!empty($newlang)) {
1196 $outputlangs =
new Translate(
"", $conf);
1197 $outputlangs->setDefaultLang($newlang);
1200 $object->generateDocument($object->model_pdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
1204 unset($value_unit_ht);
1208 unset($fk_c_type_fees);
1220 if ($action ==
'confirm_delete_line' &&
GETPOST(
"confirm",
'alpha') ==
"yes" && $user->rights->expensereport->creer) {
1222 $object->fetch($id);
1225 $object_ligne->fetch(
GETPOST(
"rowid",
'int'));
1226 $total_ht = $object_ligne->total_ht;
1227 $total_tva = $object_ligne->total_tva;
1229 $result = $object->deleteline(
GETPOST(
"rowid",
'int'), $user);
1233 if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) {
1234 $outputlangs = $langs;
1237 $newlang =
GETPOST(
'lang_id',
'aZ09');
1240 $newlang = $object->thirdparty->default_lang;
1242 if (!empty($newlang)) {
1243 $outputlangs =
new Translate(
"", $conf);
1244 $outputlangs->setDefaultLang($newlang);
1246 $model = $object->model_pdf;
1247 $ret = $object->fetch($id);
1249 $object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref);
1253 header(
"Location: ".$_SERVER[
"PHP_SELF"].
"?id=".
GETPOST(
'id',
'int'));
1260 if ($action ==
"updateline" && $user->rights->expensereport->creer) {
1262 $object->fetch($id);
1267 $arrayoffiles =
GETPOST(
'attachfile',
'array');
1268 if (is_array($arrayoffiles) && !empty($arrayoffiles[0])) {
1269 include_once DOL_DOCUMENT_ROOT.
'/ecm/class/ecmfiles.class.php';
1270 $relativepath =
'expensereport/'.$object->ref.
'/'.$arrayoffiles[0];
1272 $ecmfiles->fetch(0,
'', $relativepath);
1273 $fk_ecm_files = $ecmfiles->id;
1277 $rowid =
GETPOST(
'rowid',
'int');
1278 $type_fees_id =
GETPOST(
'fk_c_type_fees',
'int');
1279 $fk_c_exp_tax_cat =
GETPOST(
'fk_c_exp_tax_cat',
'int');
1280 $projet_id = $fk_project;
1281 $comments =
GETPOST(
'comments',
'restricthtml');
1283 $vatrate =
GETPOST(
'vatrate',
'alpha');
1286 if (empty($vatrate)) {
1289 $tmpvat =
price2num(preg_replace(
'/\s*\(.*\)/',
'', $vatrate));
1293 if (empty($value_unit)) {
1294 $value_unit =
price2num($value_unit_ht + ($value_unit_ht * $tmpvat / 100),
'MU');
1297 if (!
GETPOST(
'fk_c_type_fees',
'int') > 0) {
1299 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Type")),
null,
'errors');
1302 if ((
float) $tmpvat < 0 || $tmpvat ==
'') {
1304 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Vat")),
null,
'errors');
1308 if ($date < $object->date_debut || $date > ($object->date_fin + (24 * 3600 - 1))) {
1309 $langs->load(
"errors");
1310 setEventMessages($langs->trans(
"WarningDateOfLineMustBeInExpenseReportRange"),
null,
'warnings');
1314 if ($projectRequired && $projet_id <= 0) {
1316 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Project")),
null,
'errors');
1321 $result = $object->updateline($rowid, $type_fees_id, $projet_id, $vatrate, $comments, $qty, $value_unit, $date, $id, $fk_c_exp_tax_cat, $fk_ecm_files);
1325 if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) {
1326 $outputlangs = $langs;
1329 $newlang =
GETPOST(
'lang_id',
'aZ09');
1332 $newlang = $object->thirdparty->default_lang;
1334 if (!empty($newlang)) {
1335 $outputlangs =
new Translate(
"", $conf);
1336 $outputlangs->setDefaultLang($newlang);
1338 $model = $object->model_pdf;
1339 $ret = $object->fetch($id);
1341 $object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref);
1345 unset($value_unit_ht);
1349 unset($fk_c_type_fees);
1363 include DOL_DOCUMENT_ROOT.
'/core/actions_printing.inc.php';
1366 $triggersendname =
'EXPENSEREPORT_SENTBYMAIL';
1367 $autocopy =
'MAIN_MAIL_AUTOCOPY_EXPENSEREPORT_TO';
1368 $trackid =
'exp'.$object->id;
1369 include DOL_DOCUMENT_ROOT.
'/core/actions_sendmails.inc.php';
1372 $upload_dir = $conf->expensereport->dir_output;
1373 include DOL_DOCUMENT_ROOT.
'/core/actions_builddoc.inc.php';
1381 $title = $langs->trans(
"ExpenseReport").
" - ".$langs->trans(
"Card");
1382 $help_url =
"EN:Module_Expense_Reports|FR:Module_Notes_de_frais";
1389 $projecttmp =
new Project($db);
1391 $bankaccountstatic =
new Account($db);
1392 $ecmfilesstatic =
new EcmFiles($db);
1396 if ($action ==
'create') {
1399 print
'<form action="'.$_SERVER[
'PHP_SELF'].
'" method="post" name="create">';
1400 print
'<input type="hidden" name="token" value="'.newToken().
'">';
1401 print
'<input type="hidden" name="action" value="add">';
1405 print
'<table class="border centpercent">';
1410 print
'<td class="titlefieldcreate fieldrequired">'.$langs->trans(
"DateStart").
'</td>';
1412 print
$form->selectDate($date_start ? $date_start : -1,
'date_debut', 0, 0, 0,
'', 1, 1);
1418 print
'<td class="fieldrequired">'.$langs->trans(
"DateEnd").
'</td>';
1420 print
$form->selectDate($date_end ? $date_end : -1,
'date_fin', 0, 0, 0,
'', 1, 1);
1426 print
'<td class="fieldrequired">'.$langs->trans(
"User").
'</td>';
1428 $defaultselectuser = $user->id;
1429 if (
GETPOST(
'fk_user_author',
'int') > 0) {
1430 $defaultselectuser =
GETPOST(
'fk_user_author',
'int');
1432 $include_users =
'hierarchyme';
1433 if (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->expensereport->writeall_advance)) {
1434 $include_users = array();
1436 $s =
$form->select_dolusers($defaultselectuser,
"fk_user_author", 0,
"", 0, $include_users,
'',
'0,'.$conf->entity);
1443 print
'<td>'.$langs->trans(
"VALIDATOR").
'</td>';
1446 $include_users = $object->fetch_users_approver_expensereport();
1447 if (empty($include_users)) {
1448 print
img_warning().
' '.$langs->trans(
"NobodyHasPermissionToValidateExpenseReport");
1450 $defaultselectuser = (empty($user->fk_user_expense_validator) ? $user->fk_user : $user->fk_user_expense_validator);
1451 if (!empty($conf->global->EXPENSEREPORT_DEFAULT_VALIDATOR)) {
1452 $defaultselectuser = $conf->global->EXPENSEREPORT_DEFAULT_VALIDATOR;
1454 if (
GETPOST(
'fk_user_validator',
'int') > 0) {
1455 $defaultselectuser =
GETPOST(
'fk_user_validator',
'int');
1457 $s =
$form->select_dolusers($defaultselectuser,
"fk_user_validator", 1,
"", ((empty($defaultselectuser) || empty($conf->global->EXPENSEREPORT_DEFAULT_VALIDATOR_UNCHANGEABLE)) ? 0 : 1), $include_users);
1458 print
$form->textwithpicto($s, $langs->trans(
"AnyOtherInThisListCanValidate"));
1464 if (!empty($conf->global->EXPENSEREPORT_ASK_PAYMENTMODE_ON_CREATION)) {
1466 print
'<td>'.$langs->trans(
"ModePaiement").
'</td>';
1468 $form->select_types_paiements(
'',
'fk_c_paiement');
1477 print
'<td class="tdtop">'.$langs->trans(
'NotePublic').
'</td>';
1480 $doleditor =
new DolEditor(
'note_public', $note_public,
'', 80,
'dolibarr_notes',
'In', 0,
false, empty($conf->global->FCKEDITOR_ENABLE_NOTE_PUBLIC) ? 0 : 1, ROWS_3,
'90%');
1481 print $doleditor->Create(1);
1485 $note_private =
GETPOSTISSET(
'note_private') ?
GETPOST(
'note_private',
'restricthtml') :
'';
1487 if (empty($user->socid)) {
1489 print
'<td class="tdtop">'.$langs->trans(
'NotePrivate').
'</td>';
1492 $doleditor =
new DolEditor(
'note_private', $note_private,
'', 80,
'dolibarr_notes',
'In', 0,
false, empty($conf->global->FCKEDITOR_ENABLE_NOTE_PRIVATE) ? 0 : 1, ROWS_3,
'90%');
1493 print $doleditor->Create(1);
1498 $parameters = array(
'colspan' =>
' colspan="3"',
'cols' => 3);
1499 $reshook = $hookmanager->executeHooks(
'formObjectOptions',
$parameters, $object, $action);
1500 print $hookmanager->resPrint;
1501 if (empty($reshook)) {
1502 print $object->showOptionals($extrafields,
'create',
$parameters);
1510 print
$form->buttonsSaveCancel(
"AddTrip");
1513 } elseif ($id > 0 || $ref) {
1514 $result = $object->fetch($id, $ref);
1517 if (!in_array($object->fk_user_author, $user->getAllChildIds(1))) {
1518 if (empty($user->rights->expensereport->readall) && empty($user->rights->expensereport->lire_tous)
1519 && (empty($conf->global->MAIN_USE_ADVANCED_PERMS) || empty($user->rights->expensereport->writeall_advance))) {
1522 print
'<div class="tabBar">';
1523 print $langs->trans(
'NotUserRightToView');
1536 if ($action ==
'edit' && ($object->status < 3 || $object->status == 99)) {
1537 print
"<form name='update' action=\"".$_SERVER[
'PHP_SELF'].
"\" method=\"post\">\n";
1538 print
'<input type="hidden" name="token" value="'.newToken().
'">';
1539 print
'<input type="hidden" name="id" value="'.$id.
'">';
1543 if ($object->status == 99) {
1544 print
'<input type="hidden" name="action" value="updateFromRefuse">';
1546 print
'<input type="hidden" name="action" value="update">';
1549 $linkback =
'<a href="'.DOL_URL_ROOT.
'/expensereport/list.php?restore_lastsearch_values=1'.(!empty($socid) ?
'&socid='.$socid :
'').
'">'.$langs->trans(
"BackToList").
'</a>';
1551 print
'<table class="border" style="width:100%;">';
1554 print
'<td>'.$langs->trans(
"User").
'</td>';
1556 $userfee =
new User($db);
1557 if ($object->fk_user_author > 0) {
1558 $userfee->fetch($object->fk_user_author);
1559 print $userfee->getNomUrl(-1);
1564 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"Ref").
'</td><td>';
1565 print
$form->showrefnav($object,
'ref', $linkback, 1,
'ref',
'ref',
'');
1569 print
'<td>'.$langs->trans(
"DateStart").
'</td>';
1571 print
$form->selectDate($object->date_debut,
'date_debut');
1575 print
'<td>'.$langs->trans(
"DateEnd").
'</td>';
1577 print
$form->selectDate($object->date_fin,
'date_fin');
1581 if (!empty($conf->global->EXPENSEREPORT_ASK_PAYMENTMODE_ON_CREATION)) {
1583 print
'<td>'.$langs->trans(
"ModePaiement").
'</td>';
1585 $form->select_types_paiements($object->fk_c_paiement,
'fk_c_paiement');
1590 if ($object->status < 3) {
1592 print
'<td>'.$langs->trans(
"VALIDATOR").
'</td>';
1594 $include_users = $object->fetch_users_approver_expensereport();
1595 $s =
$form->select_dolusers($object->fk_user_validator,
"fk_user_validator", 1,
"", 0, $include_users);
1596 print
$form->textwithpicto($s, $langs->trans(
"AnyOtherInThisListCanValidate"));
1601 print
'<td>'.$langs->trans(
"VALIDOR").
'</td>';
1603 $userfee =
new User($db);
1604 $userfee->fetch($object->fk_user_valid);
1605 print $userfee->getNomUrl(-1);
1609 if ($object->status == 6) {
1611 print
'<td>'.$langs->trans(
"AUTHORPAIEMENT").
'</td>';
1613 $userfee =
new User($db);
1614 $userfee->fetch($user->id);
1615 print $userfee->getNomUrl(-1);
1627 print
$form->buttonsSaveCancel(
"Modify");
1631 $taxlessUnitPriceDisabled = !empty($conf->global->EXPENSEREPORT_FORCE_LINE_AMOUNTS_INCLUDING_TAXES_ONLY) ?
' disabled' :
'';
1638 if ($action ==
'clone') {
1640 $criteriaforfilter =
'hierarchyme';
1641 if (!empty($user->rights->expensereport->readall)) {
1642 $criteriaforfilter =
'';
1644 $formquestion = array(
1646 array(
'type' =>
'other',
'name' =>
'fk_user_author',
'label' => $langs->trans(
"SelectTargetUser"),
'value' =>
$form->select_dolusers((
GETPOST(
'fk_user_author',
'int') > 0 ?
GETPOST(
'fk_user_author',
'int') : $user->id),
'fk_user_author', 0,
null, 0, $criteriaforfilter,
'',
'0', 0, 0,
'', 0,
'',
'maxwidth150'))
1649 $formconfirm =
$form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.$object->id, $langs->trans(
'ToClone'), $langs->trans(
'ConfirmCloneExpenseReport', $object->ref),
'confirm_clone', $formquestion,
'yes', 1);
1652 if ($action ==
'save') {
1653 $formconfirm =
$form->formconfirm($_SERVER[
"PHP_SELF"].
"?id=".$id, $langs->trans(
"SaveTrip"), $langs->trans(
"ConfirmSaveTrip"),
"confirm_validate",
"",
"", 1);
1656 if ($action ==
'save_from_refuse') {
1657 $formconfirm =
$form->formconfirm($_SERVER[
"PHP_SELF"].
"?id=".$id, $langs->trans(
"SaveTrip"), $langs->trans(
"ConfirmSaveTrip"),
"confirm_save_from_refuse",
"",
"", 1);
1660 if ($action ==
'delete') {
1661 $formconfirm =
$form->formconfirm($_SERVER[
"PHP_SELF"].
"?id=".$id, $langs->trans(
"DeleteTrip"), $langs->trans(
"ConfirmDeleteTrip"),
"confirm_delete",
"",
"", 1);
1664 if ($action ==
'validate') {
1665 $formconfirm =
$form->formconfirm($_SERVER[
"PHP_SELF"].
"?id=".$id, $langs->trans(
"ValideTrip"), $langs->trans(
"ConfirmValideTrip"),
"confirm_approve",
"",
"", 1);
1668 if ($action ==
'paid') {
1669 $formconfirm =
$form->formconfirm($_SERVER[
"PHP_SELF"].
"?id=".$id, $langs->trans(
"PaidTrip"), $langs->trans(
"ConfirmPaidTrip"),
"confirm_paid",
"",
"", 1);
1672 if ($action ==
'cancel') {
1673 $array_input = array(
'text'=>$langs->trans(
"ConfirmCancelTrip"), array(
'type'=>
"text",
'label'=>
'<strong>'.$langs->trans(
"Comment").
'</strong>',
'name'=>
"detail_cancel",
'value'=>
""));
1674 $formconfirm =
$form->formconfirm($_SERVER[
"PHP_SELF"].
"?id=".$id, $langs->trans(
"Cancel"),
"",
"confirm_cancel", $array_input,
"", 1);
1677 if ($action ==
'setdraft') {
1678 $formconfirm =
$form->formconfirm($_SERVER[
"PHP_SELF"].
"?id=".$id, $langs->trans(
"BrouillonnerTrip"), $langs->trans(
"ConfirmBrouillonnerTrip"),
"confirm_setdraft",
"",
"", 1);
1681 if ($action ==
'refuse') {
1682 $array_input = array(
'text'=>$langs->trans(
"ConfirmRefuseTrip"), array(
'type'=>
"text",
'label'=>$langs->trans(
"Comment"),
'name'=>
"detail_refuse",
'value'=>
""));
1683 $formconfirm =
$form->formconfirm($_SERVER[
"PHP_SELF"].
"?id=".$id, $langs->trans(
"Deny"),
'',
"confirm_refuse", $array_input,
"yes", 1);
1686 if ($action ==
'delete_line') {
1687 $formconfirm =
$form->formconfirm($_SERVER[
"PHP_SELF"].
"?id=".$id.
"&rowid=".
GETPOST(
'rowid',
'int'), $langs->trans(
"DeleteLine"), $langs->trans(
"ConfirmDeleteLine"),
"confirm_delete_line",
'',
'yes', 1);
1694 $linkback =
'<a href="'.DOL_URL_ROOT.
'/expensereport/list.php?restore_lastsearch_values=1'.(!empty($socid) ?
'&socid='.$socid :
'').
'">'.$langs->trans(
"BackToList").
'</a>';
1696 $morehtmlref =
'<div class="refidno">';
1697 $morehtmlref .=
'</div>';
1699 dol_banner_tab($object,
'ref', $linkback, 1,
'ref',
'ref', $morehtmlref);
1701 print
'<div class="fichecenter">';
1702 print
'<div class="fichehalfleft">';
1703 print
'<div class="underbanner clearboth"></div>';
1705 print
'<table class="border tableforfield centpercent">';
1709 print
'<td class="titlefield">'.$langs->trans(
"User").
'</td>';
1711 if ($object->fk_user_author > 0) {
1712 $userauthor =
new User($db);
1713 $result = $userauthor->fetch($object->fk_user_author);
1716 } elseif ($result > 0) {
1717 print $userauthor->getNomUrl(-1);
1724 print
'<td class="titlefield">'.$langs->trans(
"Period").
'</td>';
1726 print
get_date_range($object->date_debut, $object->date_fin,
'day', $langs, 0);
1729 if (!empty($conf->global->EXPENSEREPORT_ASK_PAYMENTMODE_ON_CREATION)) {
1731 print
'<td>'.$langs->trans(
"ModePaiement").
'</td>';
1732 print
'<td>'.$object->fk_c_paiement.
'</td>';
1738 print
'<td>'.$langs->trans(
"DATE_SAVE").
'</td>';
1739 print
'<td>'.dol_print_date($object->date_valid,
'dayhour',
'tzuser');
1740 if ($object->status == 2 && $object->hasDelay(
'toapprove')) {
1741 print
' '.img_warning($langs->trans(
"Late").
' - '.$langs->trans(
"ToApprove"));
1743 if ($object->status == 5 && $object->hasDelay(
'topay')) {
1744 print
' '.img_warning($langs->trans(
"Late").
' - '.$langs->trans(
"ToPay"));
1752 print
'<td>'.$langs->trans(
"VALIDATOR").
'</td>';
1754 if ($object->fk_user_validator > 0) {
1755 $userfee =
new User($db);
1756 $result = $userfee->fetch($object->fk_user_validator);
1758 print $userfee->getNomUrl(-1);
1760 if (empty($userfee->email) || !
isValidEmail($userfee->email)) {
1761 $langs->load(
"errors");
1762 print
img_warning($langs->trans(
"ErrorBadEMail", $userfee->email));
1768 print
'<td>'.$langs->trans(
"CANCEL_USER").
'</span></td>';
1770 if ($object->fk_user_cancel > 0) {
1771 $userfee =
new User($db);
1772 $result = $userfee->fetch($object->fk_user_cancel);
1774 print $userfee->getNomUrl(-1);
1780 print
'<td>'.$langs->trans(
"MOTIF_CANCEL").
'</td>';
1781 print
'<td>'.$object->detail_cancel.
'</td></tr>';
1784 print
'<td>'.$langs->trans(
"DATE_CANCEL").
'</td>';
1785 print
'<td>'.dol_print_date($object->date_cancel,
'dayhour',
'tzuser').
'</td></tr>';
1789 print
'<td>'.$langs->trans(
"ApprovedBy").
'</td>';
1791 if ($object->fk_user_approve > 0) {
1792 $userapp =
new User($db);
1793 $result = $userapp->fetch($object->fk_user_approve);
1795 print $userapp->getNomUrl(-1);
1801 print
'<td>'.$langs->trans(
"DateApprove").
'</td>';
1802 print
'<td>'.dol_print_date($object->date_approve,
'dayhour',
'tzuser').
'</td></tr>';
1806 if ($object->status == 99 || !empty($object->detail_refuse)) {
1808 print
'<td>'.$langs->trans(
"REFUSEUR").
'</td>';
1810 $userfee =
new User($db);
1811 $result = $userfee->fetch($object->fk_user_refuse);
1813 print $userfee->getNomUrl(-1);
1818 print
'<td>'.$langs->trans(
"DATE_REFUS").
'</td>';
1819 print
'<td>'.dol_print_date($object->date_refuse,
'dayhour',
'tzuser');
1820 if ($object->detail_refuse) {
1821 print
' - '.$object->detail_refuse;
1827 if ($object->status == $object::STATUS_CLOSED) {
1845 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_view.tpl.php';
1850 print
'<div class="fichehalfright">';
1851 print
'<div class="underbanner clearboth"></div>';
1853 print
'<table class="border tableforfield centpercent">';
1857 print
'<td class="titlefieldmiddle">'.$langs->trans(
"AmountHT").
'</td>';
1858 print
'<td class="nowrap amountcard">'.price($object->total_ht, 1,
'', 1, - 1, - 1, $conf->currency).
'</td>';
1877 print
'<td>'.$langs->trans(
"AmountVAT").
'</td>';
1878 print
'<td class="nowrap amountcard">'.price($object->total_tva, 1,
'', 1, -1, -1, $conf->currency).
'</td>';
1882 if ($mysoc->localtax1_assuj ==
"1" || $object->total_localtax1 != 0) {
1883 print
'<tr><td>'.$langs->transcountry(
"AmountLT1", $mysoc->country_code).
'</td>';
1884 print
'<td class="valuefield">'.price($object->total_localtax1, 1,
'', 1, -1, -1, $conf->currency).
'</td></tr>';
1886 if ($mysoc->localtax2_assuj ==
"1" || $object->total_localtax2 != 0) {
1887 print
'<tr><td>'.$langs->transcountry(
"AmountLT2", $mysoc->country_code).
'</td>';
1888 print
'<td class="valuefield">'.price($object->total_localtax2, 1,
'', 1, -1, -1, $conf->currency).
'</td></tr>';
1892 print
'<td>'.$langs->trans(
"AmountTTC").
'</td>';
1893 print
'<td class="nowrap amountcard">'.price($object->total_ttc, 1,
'', 1, -1, -1, $conf->currency).
'</td>';
1904 print
'<table class="noborder paymenttable centpercent">';
1906 print
'<tr class="liste_titre">';
1907 print
'<td class="liste_titre">'.$langs->trans(
'Payments').
'</td>';
1908 print
'<td class="liste_titre">'.$langs->trans(
'Date').
'</td>';
1909 print
'<td class="liste_titre">'.$langs->trans(
'Type').
'</td>';
1911 print
'<td class="liste_titre right">'.$langs->trans(
'BankAccount').
'</td>';
1913 print
'<td class="liste_titre right">'.$langs->trans(
'Amount').
'</td>';
1914 print
'<td class="liste_titre" width="18"> </td>';
1918 $sql =
"SELECT p.rowid, p.num_payment, p.datep as dp, p.amount, p.fk_bank,";
1919 $sql .=
"c.code as payment_code, c.libelle as payment_type,";
1920 $sql .=
"ba.rowid as baid, ba.ref as baref, ba.label, ba.number as banumber, ba.account_number, ba.fk_accountancy_journal";
1921 $sql .=
" FROM ".MAIN_DB_PREFIX.
"expensereport as e, ".MAIN_DB_PREFIX.
"payment_expensereport as p";
1922 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"c_paiement as c ON p.fk_typepayment = c.id";
1923 $sql .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'bank as b ON p.fk_bank = b.rowid';
1924 $sql .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'bank_account as ba ON b.fk_account = ba.rowid';
1925 $sql .=
" WHERE e.rowid = ".((int) $id);
1926 $sql .=
" AND p.fk_expensereport = e.rowid";
1927 $sql .=
' AND e.entity IN ('.getEntity(
'expensereport').
')';
1928 $sql .=
" ORDER BY dp";
1930 $resql = $db->query($sql);
1932 $num = $db->num_rows(
$resql);
1933 $i = 0; $totalpaid = 0;
1935 $objp = $db->fetch_object(
$resql);
1937 $paymentexpensereportstatic->id = $objp->rowid;
1938 $paymentexpensereportstatic->datep = $db->jdate($objp->dp);
1939 $paymentexpensereportstatic->ref = $objp->rowid;
1940 $paymentexpensereportstatic->num_payment = $objp->num_payment;
1941 $paymentexpensereportstatic->type_code = $objp->payment_code;
1942 $paymentexpensereportstatic->type_label = $objp->payment_type;
1944 print
'<tr class="oddseven">';
1946 print $paymentexpensereportstatic->getNomUrl(1);
1948 print
'<td>'.dol_print_date($db->jdate($objp->dp),
'day').
"</td>\n";
1949 $labeltype = $langs->trans(
"PaymentType".$objp->payment_code) != (
"PaymentType".$objp->payment_code) ? $langs->trans(
"PaymentType".$objp->payment_code) : $objp->payment_type;
1950 print
"<td>".$labeltype.
' '.$objp->num_payment.
"</td>\n";
1953 $bankaccountstatic->id = $objp->baid;
1954 $bankaccountstatic->ref = $objp->baref;
1955 $bankaccountstatic->label = $objp->baref;
1956 $bankaccountstatic->number = $objp->banumber;
1959 $bankaccountstatic->account_number = $objp->account_number;
1962 $accountingjournal->fetch($objp->fk_accountancy_journal);
1963 $bankaccountstatic->accountancy_journal = $accountingjournal->getNomUrl(0, 1, 1,
'', 1);
1966 print
'<td class="right">';
1967 if ($bankaccountstatic->id) {
1968 print $bankaccountstatic->getNomUrl(1,
'transactions');
1972 print
'<td class="right">'.price($objp->amount).
"</td>";
1975 $totalpaid += $objp->amount;
1978 if (!is_null($totalpaid)) {
1982 $remaintopay =
price2num($object->total_ttc - $totalpaid);
1983 $resteapayeraffiche = $remaintopay;
1985 $cssforamountpaymentcomplete =
'amountpaymentcomplete';
1988 $cssforamountpaymentcomplete =
'amountpaymentneutral';
1989 $resteapayeraffiche = 0;
1990 } elseif ($object->paid == 0) {
1991 $cssforamountpaymentcomplete =
'amountpaymentneutral';
1993 print
'<tr><td colspan="'.$nbcols.
'" class="right">'.$langs->trans(
"AlreadyPaid").
':</td><td class="right">'.
price($totalpaid).
'</td><td></td></tr>';
1994 print
'<tr><td colspan="'.$nbcols.
'" class="right">'.$langs->trans(
"AmountExpected").
':</td><td class="right">'.
price($object->total_ttc).
'</td><td></td></tr>';
1996 print
'<tr><td colspan="'.$nbcols.
'" class="right">'.$langs->trans(
"RemainderToPay").
':</td>';
1997 print
'<td class="right'.($resteapayeraffiche ?
' amountremaintopay' : (
' '.$cssforamountpaymentcomplete)).
'">'.
price($resteapayeraffiche).
'</td><td></td></tr>';
2008 print
'<div class="clearboth"></div><br>';
2010 print
'<div style="clear: both;"></div>';
2012 $actiontouse =
'updateline';
2013 if (($object->status == 0 || $object->status == 99) && $action !=
'editline') {
2014 $actiontouse =
'addline';
2017 print
'<form name="expensereport" action="'.$_SERVER[
"PHP_SELF"].
'" enctype="multipart/form-data" method="post" >';
2018 print
'<input type="hidden" name="token" value="'.newToken().
'">';
2019 print
'<input type="hidden" name="action" value="'.$actiontouse.
'">';
2020 print
'<input type="hidden" name="id" value="'.$object->id.
'">';
2021 print
'<input type="hidden" name="fk_expensereport" value="'.$object->id.
'" />';
2023 print
'<div class="div-table-responsive-no-min">';
2024 print
'<table id="tablelines" class="noborder centpercent">';
2026 if (!empty($object->lines)) {
2029 print
'<tr class="liste_titre headerexpensereportdet">';
2030 print
'<td class="center linecollinenb">'.$langs->trans(
'LineNb').
'</td>';
2032 print
'<td class="center linecoldate">'.$langs->trans(
'Date').
'</td>';
2034 print
'<td class="minwidth100imp linecolproject">'.$langs->trans(
'Project').
'</td>';
2036 print
'<td class="center linecoltype">'.$langs->trans(
'Type').
'</td>';
2037 if (!empty($conf->global->MAIN_USE_EXPENSE_IK)) {
2038 print
'<td class="center linecolcarcategory">'.$langs->trans(
'CarCategory').
'</td>';
2040 print
'<td class="center linecoldescription">'.$langs->trans(
'Description').
'</td>';
2041 print
'<td class="right linecolvat">'.$langs->trans(
'VAT').
'</td>';
2042 print
'<td class="right linecolpriceuht">'.$langs->trans(
'PriceUHT').
'</td>';
2043 print
'<td class="right linecolpriceuttc">'.$langs->trans(
'PriceUTTC').
'</td>';
2044 print
'<td class="right linecolqty">'.$langs->trans(
'Qty').
'</td>';
2045 if ($action !=
'editline') {
2046 print
'<td class="right linecolamountht">'.$langs->trans(
'AmountHT').
'</td>';
2047 print
'<td class="right linecolamountttc">'.$langs->trans(
'AmountTTC').
'</td>';
2058 if (($object->status < 2 || $object->status == 99) && $user->rights->expensereport->creer) {
2059 print
'<td class="right"></td>';
2063 foreach ($object->lines as &$line) {
2066 if ($action !=
'editline' || $line->rowid !=
GETPOST(
'rowid',
'int')) {
2067 print
'<tr class="oddeven linetr" data-id="'.$line->id.
'">';
2070 print
'<td class="center linecollinenb">';
2075 print
'<td class="center linecoldate">'.dol_print_date($db->jdate($line->date),
'day').
'</td>';
2079 print
'<td class="center dateproject">';
2080 if ($line->fk_project > 0) {
2081 $projecttmp->id = $line->fk_project;
2082 $projecttmp->ref = $line->projet_ref;
2083 $projecttmp->title = $line->projet_title;
2084 print $projecttmp->getNomUrl(1);
2091 require_once DOL_DOCUMENT_ROOT.
'/accountancy/class/accountingaccount.class.php';
2093 $resaccountingaccount = $accountingaccount->fetch(0, $line->type_fees_accountancy_code, 1);
2095 $titlealt .= $langs->trans(
"AccountancyCode").
': ';
2096 if ($resaccountingaccount > 0) {
2097 $titlealt .= $accountingaccount->account_number;
2099 $titlealt .= $langs->trans(
"NotFound");
2105 print
'<td class="center linecoltype" title="'.dol_escape_htmltag($titlealt).
'">';
2106 $labeltype = ($langs->trans(($line->type_fees_code)) == $line->type_fees_code ? $line->type_fees_libelle : $langs->trans($line->type_fees_code));
2111 if (!empty($conf->global->MAIN_USE_EXPENSE_IK)) {
2112 print
'<td class="fk_c_exp_tax_cat linecoltaxcat">';
2113 $exp_tax_cat_label =
dol_getIdFromCode($db, $line->fk_c_exp_tax_cat,
'c_exp_tax_cat',
'rowid',
'label');
2114 print $langs->trans($exp_tax_cat_label);
2119 print
'<td class="left linecolcomment">'.dol_nl2br($line->comments).
'</td>';
2122 print
'<td class="right linecolvatrate">'.vatrate($line->vatrate.($line->vat_src_code ?
' ('.$line->vat_src_code.
')' :
''),
true).
'</td>';
2125 print
'<td class="right linecolunitht">';
2126 if (!empty($line->value_unit_ht)) {
2127 print
price($line->value_unit_ht);
2129 $tmpvat =
price2num(preg_replace(
'/\s*\(.*\)/',
'', $line->vatrate));
2130 $pricenettoshow =
price2num($line->value_unit / (1 + $tmpvat / 100),
'MU');
2131 print
price($pricenettoshow);
2135 print
'<td class="right linecolunitttc">'.price($line->value_unit).
'</td>';
2137 print
'<td class="right linecolqty">'.dol_escape_htmltag($line->qty).
'</td>';
2139 if ($action !=
'editline') {
2140 print
'<td class="right linecoltotalht">'.price($line->total_ht).
'</td>';
2141 print
'<td class="right linecoltotalttc">'.price($line->total_ttc).
'</td>';
2145 print
'<td class="center linecolpreview">';
2146 if ($line->fk_ecm_files > 0) {
2147 $modulepart =
'expensereport';
2148 $maxheightmini = 32;
2150 $result = $ecmfilesstatic->fetch($line->fk_ecm_files);
2152 $relativepath = preg_replace(
'/expensereport\//',
'', $ecmfilesstatic->filepath);
2153 $fileinfo = pathinfo($ecmfilesstatic->filepath.
'/'.$ecmfilesstatic->filename);
2156 if (!
dol_is_file($conf->expensereport->dir_output.
'/'.$relativepath.
'/'.$minifile)) {
2160 $urlforhref =
getAdvancedPreviewUrl($modulepart, $relativepath.
'/'.$fileinfo[
'filename'].
'.'.strtolower($fileinfo[
'extension']), 1,
'&entity='.(!empty($object->entity) ? $object->entity : $conf->entity));
2161 if (empty($urlforhref)) {
2162 $urlforhref = DOL_URL_ROOT.
'/viewimage.php?modulepart='.$modulepart.
'&entity='.(!empty($object->entity) ? $object->entity : $conf->entity).
'&file='.urlencode($relativepath.$fileinfo[
'filename'].
'.'.strtolower($fileinfo[
'extension']));
2163 print
'<a href="'.$urlforhref.
'" class="aphoto" target="_blank" rel="noopener noreferrer">';
2165 print
'<a href="'.$urlforhref[
'url'].
'" class="'.$urlforhref[
'css'].
'" target="'.$urlforhref[
'target'].
'" mime="'.$urlforhref[
'mime'].
'">';
2167 print
'<img class="photo" height="'.$maxheightmini.
'" src="'.DOL_URL_ROOT.
'/viewimage.php?modulepart='.$modulepart.
'&entity='.(!empty($object->entity) ? $object->entity : $conf->entity).
'&file='.urlencode($relativepath.
'/'.$minifile).
'" title="">';
2170 $modulepart =
'expensereport';
2172 if (preg_match(
'/\.pdf$/i', $ecmfilesstatic->filename)) {
2173 $filepdf = $conf->expensereport->dir_output.
'/'.$relativepath.
'/'.$ecmfilesstatic->filename;
2174 $fileimage = $conf->expensereport->dir_output.
'/'.$relativepath.
'/'.$ecmfilesstatic->filename.
'_preview.png';
2175 $relativepathimage = $relativepath.
'/'.$ecmfilesstatic->filename.
'_preview.png';
2177 $pdfexists = file_exists($filepdf);
2180 if (!file_exists($fileimage) || (filemtime($fileimage) < filemtime($filepdf))) {
2181 if (empty($conf->global->MAIN_DISABLE_PDF_THUMBS)) {
2182 include_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
2191 if ($pdfexists && !$error) {
2192 $heightforphotref = 70;
2193 if (!empty($conf->dol_optimize_smallscreen)) {
2194 $heightforphotref = 60;
2197 if (file_exists($fileimage)) {
2199 $urlforhref =
getAdvancedPreviewUrl($modulepart, $relativepath.
'/'.$fileinfo[
'filename'].
'.'.strtolower($fileinfo[
'extension']), 1,
'&entity='.(!empty($object->entity) ? $object->entity : $conf->entity));
2200 print
'<a href="'.$urlforhref[
'url'].
'" class="'.$urlforhref[
'css'].
'" target="'.$urlforhref[
'target'].
'" mime="'.$urlforhref[
'mime'].
'">';
2201 print
'<img height="'.$heightforphotref.
'" class="photo photowithmargin photowithborder" src="'.DOL_URL_ROOT.
'/viewimage.php?modulepart=apercu'.$modulepart.
'&file='.urlencode($relativepathimage).
'">';
2208 print
img_mime($ecmfilesstatic->filename);
2215 print
'<td class="nowrap right linecolwarning">';
2216 print !empty($line->rule_warning_message) ?
img_warning(html_entity_decode($line->rule_warning_message)) :
' ';
2221 print
'<td class="nowrap right linecolaction">';
2223 print
'<a class="editfielda reposition paddingrightonly" href="'.$_SERVER[
"PHP_SELF"].
'?id='.$object->id.
'&action=editline&token='.
newToken().
'&rowid='.$line->rowid.
'">';
2225 print
'</a> ';
2226 print
'<a class="paddingrightonly" href="'.$_SERVER[
"PHP_SELF"].
'?id='.$object->id.
'&action=delete_line&token='.
newToken().
'&rowid='.$line->rowid.
'">';
2236 if ($action ==
'editline' && $line->rowid ==
GETPOST(
'rowid',
'int')) {
2242 if (!empty($conf->global->MAIN_USE_EXPENSE_IK)) {
2246 print
'<!-- line of expense report -->'.
"\n";
2247 print
'<tr class="tredited">';
2249 print
'<td class="center">';
2253 print
'<td colspan="'.($colspan - 1).
'" class="liste_titre"> ';
2254 print
'<a href="" class="commonlink auploadnewfilenow reposition">'.$langs->trans(
"UploadANewFileNow");
2255 print
img_picto($langs->trans(
"UploadANewFileNow"),
'chevron-down',
'',
false, 0, 0,
'',
'marginleftonly');
2257 if (empty($conf->global->EXPENSEREPORT_DISABLE_ATTACHMENT_ON_LINES)) {
2258 print
' - <a href="" class="commonlink aattachtodoc reposition">'.$langs->trans(
"AttachTheNewLineToTheDocument");
2259 print
img_picto($langs->trans(
"AttachTheNewLineToTheDocument"),
'chevron-down',
'',
false, 0, 0,
'',
'marginleftonly');
2263 print
'<!-- Code to open/close section to submit or link files in edit mode -->'.
"\n";
2264 print
'<script type="text/javascript">'.
"\n";
2265 print
'$(document).ready(function() {
2266 $( ".auploadnewfilenow" ).click(function() {
2267 jQuery(".truploadnewfilenow").toggle();
2268 jQuery(".trattachnewfilenow").hide();
2271 $( ".aattachtodoc" ).click(function() {
2272 jQuery(".trattachnewfilenow").toggle();
2273 jQuery(".truploadnewfilenow").hide();
2276 if (is_array(
GETPOST(
'attachfile',
'array')) && count(
GETPOST(
'attachfile',
'array'))) {
2277 print
'jQuery(".trattachnewfilenow").toggle();'.
"\n";
2280 jQuery("form[name=\"expensereport\"]").submit(function() {
2281 if (jQuery(".truploadnewfilenow").is(":hidden")) {
2282 jQuery("input[name=\"sendit\"]").val("");
2289 print
'</script>'.
"\n";
2292 $filenamelinked =
'';
2293 if ($line->fk_ecm_files > 0) {
2294 $result = $ecmfilesstatic->fetch($line->fk_ecm_files);
2296 $filenamelinked = $ecmfilesstatic->filename;
2300 $tredited =
'tredited';
2301 include DOL_DOCUMENT_ROOT.
'/expensereport/tpl/expensereport_addfile.tpl.php';
2302 include DOL_DOCUMENT_ROOT.
'/expensereport/tpl/expensereport_linktofile.tpl.php';
2304 print
'<tr class="oddeven tredited">';
2309 print
'<td class="center">';
2310 print
$form->selectDate($line->date,
'date');
2316 $formproject->select_projects(-1, $line->fk_project,
'fk_project', 0, 0, $projectRequired ? 0 : 1, 1, 0, 0, 0,
'', 0, 0,
'maxwidth300');
2321 print
'<td class="center">';
2322 print $formexpensereport->selectTypeExpenseReport($line->fk_c_type_fees,
'fk_c_type_fees');
2325 if (!empty($conf->global->MAIN_USE_EXPENSE_IK)) {
2326 print
'<td class="fk_c_exp_tax_cat">';
2327 $params = array(
'fk_expense' => $object->id,
'fk_expense_det' => $line->rowid,
'date' => $line->dates);
2328 print
$form->selectExpenseCategories($line->fk_c_exp_tax_cat,
'fk_c_exp_tax_cat', 1, array(),
'fk_c_type_fees', $userauthor->default_c_exp_tax_cat, $params);
2334 print
'<textarea name="comments" class="flat_ndf centpercent">'.dol_escape_htmltag($line->comments, 0, 1).
'</textarea>';
2338 $selectedvat =
price2num($line->vatrate).(!empty($line->vat_src_code) ?
' ('.$line->vat_src_code.
')' :
'');
2339 print
'<td class="right">';
2340 print
$form->load_tva(
'vatrate', (
GETPOSTISSET(
"vatrate") ?
GETPOST(
"vatrate") : $selectedvat), $mysoc,
'', 0, 0,
'',
false, 1);
2344 print
'<td class="right">';
2345 print
'<input type="text" min="0" class="right maxwidth50" id="value_unit_ht" name="value_unit_ht" value="'.dol_escape_htmltag(
price2num((!empty($line->value_unit_ht) ? $line->value_unit_ht :
""))).
'"'.$taxlessUnitPriceDisabled.
' />';
2349 print
'<td class="right">';
2350 print
'<input type="text" min="0" class="right maxwidth50" id="value_unit" name="value_unit" value="'.dol_escape_htmltag(
price2num($line->value_unit)).
'" />';
2354 print
'<td class="right">';
2355 print
'<input type="text" min="0" class="input_qty right maxwidth50" name="qty" value="'.dol_escape_htmltag($line->qty).
'" />';
2362 print
'<td class="center">';
2366 print
'<td class="center">';
2370 print
'<input type="hidden" name="rowid" value="'.$line->rowid.
'">';
2371 print
$form->buttonsSaveCancel(
'Save',
'Cancel', array(), 0,
'small');
2384 if (!empty($conf->global->MAIN_USE_EXPENSE_IK)) {
2390 if ($action !=
'editline') {
2394 $nbFiles = $nbLinks = 0;
2395 $arrayoffiles = array();
2396 if (empty($conf->global->EXPENSEREPORT_DISABLE_ATTACHMENT_ON_LINES)) {
2397 require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
2398 require_once DOL_DOCUMENT_ROOT.
'/core/lib/images.lib.php';
2399 require_once DOL_DOCUMENT_ROOT.
'/core/class/link.class.php';
2402 $nbFiles = count($arrayoffiles);
2403 $nbLinks =
Link::count($db, $object->element, $object->id);
2407 print
'<tr class="liste_titre">';
2408 print
'<td colspan="'.$colspan.
'" class="liste_titre expensereportautoload">';
2409 print
'<a href="" class="commonlink auploadnewfilenow reposition">'.$langs->trans(
"UploadANewFileNow");
2410 print
img_picto($langs->trans(
"UploadANewFileNow"),
'chevron-down',
'',
false, 0, 0,
'',
'marginleftonly');
2412 if (empty($conf->global->EXPENSEREPORT_DISABLE_ATTACHMENT_ON_LINES)) {
2413 print
' - <a href="" class="commonlink aattachtodoc reposition">'.$langs->trans(
"AttachTheNewLineToTheDocument");
2414 print
img_picto($langs->trans(
"AttachTheNewLineToTheDocument"),
'chevron-down',
'',
false, 0, 0,
'',
'marginleftonly');
2418 print
'<!-- Code to open/close section to submit or link files in the form to add new line -->'.
"\n";
2419 print
'<script type="text/javascript">'.
"\n";
2420 print
'$(document).ready(function() {
2421 $( ".auploadnewfilenow" ).click(function() {
2422 console.log("We click on toggle of auploadnewfilenow");
2423 jQuery(".truploadnewfilenow").toggle();
2424 jQuery(".trattachnewfilenow").hide();
2425 if (jQuery(".truploadnewfilenow").is(":hidden")) {
2426 jQuery("input[name=\"sendit\"]").prop("name", "senditdisabled");
2428 jQuery("input[name=\"senditdisabled\"]").prop("name", "sendit");
2430 // TODO Switch css fa-chevron-dow and add fa-chevron-up
2433 $( ".aattachtodoc" ).click(function() {
2434 console.log("We click on toggle of aattachtodoc");
2435 jQuery(".trattachnewfilenow").toggle();
2436 jQuery(".truploadnewfilenow").hide();
2437 // TODO Switch css fa-chevron-dow and add fa-chevron-up
2440 if (is_array(
GETPOST(
'attachfile',
'array')) && count(
GETPOST(
'attachfile',
'array')) && $action !=
'updateline') {
2441 print
'jQuery(".trattachnewfilenow").show();'.
"\n";
2444 jQuery("form[name=\"expensereport\"]").submit(function() {
2445 if (jQuery(".truploadnewfilenow").is(":hidden")) {
2446 /* When section to send file is not expanded, we disable the button sendit that submit form to add a new file, so button to submit line will work. */
2447 jQuery("input[name=\"sendit\"]").val("");
2448 jQuery("input[name=\"sendit\"]").prop("name", "senditdisabled");
2450 jQuery("input[name=\"senditdisabled\"]").prop("name", "sendit");
2457 print
'</script>'.
"\n";
2461 include DOL_DOCUMENT_ROOT.
'/expensereport/tpl/expensereport_linktofile.tpl.php';
2462 include DOL_DOCUMENT_ROOT.
'/expensereport/tpl/expensereport_addfile.tpl.php';
2464 print
'<tr class="liste_titre expensereportcreate">';
2466 print
'<td class="center expensereportcreatedate">'.$langs->trans(
'Date').
'</td>';
2468 print
'<td class="minwidth100imp">'.$form->textwithpicto($langs->trans(
'Project'), $langs->trans(
"ClosedProjectsAreHidden")).
'</td>';
2470 print
'<td class="center expensereportcreatetype">'.$langs->trans(
'Type').
'</td>';
2471 if (!empty($conf->global->MAIN_USE_EXPENSE_IK)) {
2472 print
'<td>'.$langs->trans(
'CarCategory').
'</td>';
2474 print
'<td class="right expensereportcreatedescription">'.$langs->trans(
'Description').
'</td>';
2475 print
'<td class="right expensereportcreatevat">'.$langs->trans(
'VAT').
'</td>';
2476 print
'<td class="right expensereportcreatepriceuth">'.$langs->trans(
'PriceUHT').
'</td>';
2477 print
'<td class="right expensereportcreatepricettc">'.$langs->trans(
'PriceUTTC').
'</td>';
2478 print
'<td class="right expensereportcreateqty">'.$langs->trans(
'Qty').
'</td>';
2485 print
'<tr class="oddeven nohover">';
2491 print
'<td class="center inputdate">';
2492 print
$form->selectDate(!empty($date) ? $date : -1,
'date', 0, 0, 0,
'', 1, 1);
2497 print
'<td class="inputproject">';
2498 $formproject->select_projects(-1, !empty($fk_project) ? $fk_project : 0,
'fk_project', 0, 0, $projectRequired ? 0 : 1, -1, 0, 0, 0,
'', 0, 0,
'maxwidth300');
2503 print
'<td class="center inputtype">';
2504 print $formexpensereport->selectTypeExpenseReport(!empty($fk_c_type_fees) ? $fk_c_type_fees :
"",
'fk_c_type_fees', 1);
2507 if (!empty($conf->global->MAIN_USE_EXPENSE_IK)) {
2508 print
'<td class="fk_c_exp_tax_cat">';
2509 $params = array(
'fk_expense' => $object->id);
2510 print
$form->selectExpenseCategories(
'',
'fk_c_exp_tax_cat', 1, array(),
'fk_c_type_fees', $userauthor->default_c_exp_tax_cat, $params, 0);
2515 print
'<td class="inputcomment">';
2516 print
'<textarea class="flat_ndf centpercent" name="comments" rows="'.ROWS_2.
'">'.
dol_escape_htmltag(!empty($comments) ? $comments :
"", 0, 1).
'</textarea>';
2520 print
'<td class="right inputvat">';
2522 if (!empty($conf->global->EXPENSEREPORT_NO_DEFAULT_VAT)) {
2524 $conf->global->MAIN_VAT_DEFAULT_IF_AUTODETECT_FAILS =
'none';
2526 print
$form->load_tva(
'vatrate', (!empty($vatrate) ? $vatrate : $defaultvat), $mysoc,
'', 0, 0,
'',
false, 1);
2530 print
'<td class="right inputpricenet">';
2531 print
'<input type="text" class="right maxwidth50" id="value_unit_ht" name="value_unit_ht" value="'.dol_escape_htmltag((!empty($value_unit_ht) ? $value_unit_ht : 0)).
'"'.$taxlessUnitPriceDisabled.
' />';
2535 print
'<td class="right inputtax">';
2536 print
'<input type="text" class="right maxwidth50" id="value_unit" name="value_unit" value="'.dol_escape_htmltag((!empty($value_unit) ? $value_unit : 0)).
'">';
2540 print
'<td class="right inputqty">';
2541 print
'<input type="text" min="0" class=" input_qty right maxwidth50" name="qty" value="'.dol_escape_htmltag(!empty($qty) ? $qty : 1).
'">';
2547 if ($action !=
'editline') {
2548 print
'<td class="right"></td>';
2549 print
'<td class="right"></td>';
2552 print
'<td class="center inputbuttons">';
2553 print
$form->buttonsSaveCancel(
"Add",
'',
'', 1);
2562 print
'<script javascript>
2564 /* JQuery for product free or predefined select */
2565 jQuery(document).ready(function() {
2566 jQuery("#value_unit_ht").keyup(function(event) {
2567 console.log(event.which); // discard event tag and arrows
2568 if (event.which != 9 && (event.which < 37 ||event.which > 40) && jQuery("#value_unit_ht").val() != "") {
2569 jQuery("#value_unit").val("");
2572 jQuery("#value_unit").keyup(function(event) {
2573 console.log(event.which); // discard event tag and arrows
2574 if (event.which != 9 && (event.which < 37 || event.which > 40) && jQuery("#value_unit").val() != "") {
2575 jQuery("#value_unit_ht").val("");
2579 /* unit price coéf calculation */
2580 jQuery(".input_qty, #fk_c_type_fees, #select_fk_c_exp_tax_cat, #vatrate ").change(function(event) {
2582 let type_fee = jQuery("#fk_c_type_fees").find(":selected").val();
2583 let tax_cat = jQuery("#select_fk_c_exp_tax_cat").find(":selected").val();
2584 let tva = jQuery("#vatrate").find(":selected").val();
2585 let qty = jQuery(".input_qty").val();
2589 let path = "'.dol_buildpath(
"/expensereport/ajax/ajaxik.php", 1) .
'";
2590 path += "?fk_c_exp_tax_cat="+tax_cat;
2591 path +="&fk_expense="+'.$object->id.
';
2592 path += "&vatrate="+tva;
2593 path += "&qty="+qty;
2595 if (type_fee == 4) { // frais_kilométriques
2597 if (tax_cat == "" || parseInt(tax_cat) <= 0){
2605 ,success:function(response) {
2606 if (response.response_status == "success"){
2607 jQuery("#value_unit_ht").val(response.data);
2608 jQuery("#value_unit_ht").trigger("change");
2609 jQuery("#value_unit").val("");
2610 } else if(response.response_status == "error" && response.errorMessage != undefined && response.errorMessage.length > 0 ){
2611 $.jnotify(response.errorMessage, "error", {timeout: 0, type: "error"},{ remove: function (){} } );
2618 /*console.log(event.which); // discard event tag and arrows
2619 if (event.which != 9 && (event.which < 37 || event.which > 40) && jQuery("#value_unit").val() != "") {
2620 jQuery("#value_unit_ht").val("");
2636 print
'Record not found';
2647 print
'<div class="tabsAction">';
2649 if ($action !=
'create' && $action !=
'edit' && $action !=
'editline') {
2651 $object->fetch($id, $ref);
2654 if (empty($user->socid)) {
2657 print
'<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER[
"PHP_SELF"].
'?id='.$object->id.
'&action=presend&mode=init#formmailbeforetitle">'.$langs->trans(
'SendMail').
'</a></div>';
2669 if (in_array($object->fk_user_author, $user->getAllChildIds(1)) || !empty($user->rights->expensereport->writeall_advance)) {
2671 print
'<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER[
"PHP_SELF"].
'?action=edit&token='.
newToken().
'&id='.$object->id.
'">'.$langs->trans(
'Modify').
'</a></div>';
2674 if (count($object->lines) > 0) {
2675 print
'<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER[
"PHP_SELF"].
'?action=save&token='.
newToken().
'&id='.$object->id.
'">'.$langs->trans(
'ValidateAndSubmit').
'</a></div>';
2686 if ($user->id == $object->fk_user_author || $user->id == $object->fk_user_valid) {
2688 print
'<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER[
"PHP_SELF"].
'?action=edit&token='.
newToken().
'&id='.$object->id.
'">'.$langs->trans(
'Modify').
'</a></div>';
2693 print
'<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER[
"PHP_SELF"].
'?action=save_from_refuse&token='.
newToken().
'&id='.$object->id.
'">'.$langs->trans(
'ValidateAndSubmit').
'</a></div>';
2698 if ($user->id == $object->fk_user_author || $user->id == $object->fk_user_valid) {
2700 print
'<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER[
"PHP_SELF"].
'?action=setdraft&token='.
newToken().
'&id='.$object->id.
'">'.$langs->trans(
'SetToDraft').
'</a></div>';
2710 if (in_array($object->fk_user_author, $user->getAllChildIds(1))) {
2712 print
'<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER[
"PHP_SELF"].
'?action=setdraft&token='.
newToken().
'&id='.$object->id.
'">'.$langs->trans(
'SetToDraft').
'</a></div>';
2720 print
'<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER[
"PHP_SELF"].
'?action=validate&id='.$object->id.
'">'.$langs->trans(
'Approve').
'</a></div>';
2722 print
'<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER[
"PHP_SELF"].
'?action=refuse&id='.$object->id.
'">'.$langs->trans(
'Deny').
'</a></div>';
2725 if ($user->id == $object->fk_user_author || $user->id == $object->fk_user_valid) {
2727 print
'<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER[
"PHP_SELF"].
'?action=cancel&id='.$object->id.
'">'.$langs->trans(
"Cancel").
'</a></div>';
2736 print
'<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER[
"PHP_SELF"].
'?action=refuse&id='.$object->id.
'">'.$langs->trans(
'Deny').
'</a></div>';
2742 if ($remaintopay == 0) {
2743 print
'<div class="inline-block divButAction"><span class="butActionRefused classfortooltip" title="'.$langs->trans(
"DisabledBecauseRemainderToPayIsZero").
'">'.$langs->trans(
'DoPayment').
'</span></div>';
2745 print
'<div class="inline-block divButAction"><a class="butAction" href="'.DOL_URL_ROOT.
'/expensereport/payment/payment.php?id='.$object->id.
'&action=create">'.$langs->trans(
'DoPayment').
'</a></div>';
2752 if ($object->paid == 0) {
2753 print
'<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER[
"PHP_SELF"].
'?id='.$object->id.
'&action=set_paid&token='.
newToken().
'">'.$langs->trans(
"ClassifyPaid").
"</a></div>";
2757 if ($user->rights->expensereport->creer && ($user->id == $object->fk_user_author || $user->id == $object->fk_user_valid) && $object->status ==
ExpenseReport::STATUS_APPROVED) {
2759 print
'<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER[
"PHP_SELF"].
'?action=cancel&token='.
newToken().
'&id='.$object->id.
'">'.$langs->trans(
"Cancel").
'</a></div>';
2763 if (($user->rights->expensereport->approve || $user->rights->expensereport->to_paid) && $object->status ==
ExpenseReport::STATUS_CLOSED) {
2765 print
'<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER[
"PHP_SELF"].
'?action=cancel&token='.
newToken().
'&id='.$object->id.
'">'.$langs->trans(
"Cancel").
'</a></div>';
2770 print
'<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER[
"PHP_SELF"].
'?action=set_unpaid&token='.
newToken().
'&id='.$object->id.
'">'.$langs->trans(
'ClassifyUnPaid').
'</a></div>';
2774 if ($user->rights->expensereport->creer) {
2775 print
'<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER[
'PHP_SELF'].
'?id='.$object->id.
'&action=clone&token='.
newToken().
'">'.$langs->trans(
"ToClone").
'</a></div>';
2781 print
'<div class="inline-block divButAction"><a class="butActionDelete" href="'.$_SERVER[
"PHP_SELF"].
'?action=delete&token='.
newToken().
'&id='.$object->id.
'">'.$langs->trans(
'Delete').
'</a></div>';
2784 print
'<div class="inline-block divButAction"><a class="butActionDelete" href="'.$_SERVER[
"PHP_SELF"].
'?action=delete&token='.
newToken().
'&id='.$object->id.
'">'.$langs->trans(
'Delete').
'</a></div>';
2788 $reshook = $hookmanager->executeHooks(
'addMoreActionsButtons',
$parameters, $object, $action);
2795 if (
GETPOST(
'modelselected',
'alpha')) {
2796 $action =
'presend';
2799 if ($action !=
'presend') {
2804 print
'<div class="fichecenter"><div class="fichehalfleft">';
2805 print
'<a name="builddoc"></a>';
2807 if ($user->rights->expensereport->creer && $action !=
'create' && $action !=
'edit') {
2810 $urlsource = $_SERVER[
"PHP_SELF"].
"?id=".$object->id;
2811 $genallowed = $user->rights->expensereport->creer;
2812 $delallowed = $user->rights->expensereport->creer;
2814 print $formfile->showdocuments(
'expensereport', $filename, $filedir, $urlsource, $genallowed, $delallowed);
2815 $somethingshown = $formfile->numoffiles;
2827 print
'</div><div class="fichehalfright">';
2829 include_once DOL_DOCUMENT_ROOT.
'/core/class/html.formactions.class.php';
2831 $somethingshown =
$formactions->showactions($object,
'expensereport',
null);
2833 print
'</div></div>';
2837 $modelmail =
'expensereport';
2838 $defaulttopic =
'SendExpenseReportRef';
2839 $diroutput = $conf->expensereport->dir_output;
2840 $trackid =
'exp'.$object->id;
2842 include DOL_DOCUMENT_ROOT.
'/core/tpl/card_presend.tpl.php';
if(GETPOST('button_removefilter_x', 'alpha')||GETPOST('button_removefilter.x', 'alpha')||GETPOST('button_removefilter', 'alpha')) if(GETPOST('button_search_x', 'alpha')||GETPOST('button_search.x', 'alpha')||GETPOST('button_search', 'alpha')) if($action=="save" &&empty($cancel)) $help_url
View.
if(preg_match('/set_([a-z0-9_\-]+)/i', $action, $reg)) if(preg_match('/del_([a-z0-9_\-]+)/i', $action, $reg)) if($action=='set') elseif($action=='specimen') elseif($action=='setmodel') elseif($action=='del') elseif($action=='setdoc') $formactions
View.
if(!defined('NOREQUIRESOC')) if(!defined('NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined('NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined('NOREQUIREAJAX')) llxHeader()
Empty header.
Class to manage bank accounts.
Class to manage accounting accounts.
Class to manage accounting accounts.
Class to send emails (with attachments or not) Usage: $mailfile = new CMailFile($subject,...
Class to manage a WYSIWYG editor.
Class to manage ECM files.
fetch($id, $ref='', $relativepath='', $hashoffile='', $hashforshare='', $src_object_type='', $src_object_id=0)
Load object in memory from the database.
Class to manage Trips and Expenses.
const STATUS_DRAFT
Draft status.
const STATUS_APPROVED
Classified approved.
const STATUS_CANCELED
Classified canceled.
const STATUS_CLOSED
Classified paid.
const STATUS_REFUSED
Classified refused.
const STATUS_VALIDATED
Validated (need to be paid)
Class of expense report details lines.
static count($dbs, $objecttype, $objectid)
Return nb of links.
Class to manage payments of expense report.
Class to manage projects.
Class to manage translations.
Class to manage Dolibarr users.
if(isModEnabled('facture') &&!empty($user->rights->facture->lire)) if((isModEnabled('fournisseur') &&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) && $user->hasRight("fournisseur", "facture", "lire"))||(isModEnabled('supplier_invoice') && $user->hasRight("supplier_invoice", "lire"))) if(isModEnabled('don') &&!empty($user->rights->don->lire)) if(isModEnabled('tax') &&!empty($user->rights->tax->charges->lire)) if(isModEnabled('facture') &&isModEnabled('commande') && $user->hasRight("commande", "lire") &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) $resql
Social contributions to pay.
if($cancel &&! $id) if($action=='add' &&! $cancel) if($action=='delete') if($id) $form
Actions.
expensereport_prepare_head($object)
Prepare array with list of tabs.
dol_convert_file($fileinput, $ext='png', $fileoutput='', $page='')
Convert an image file or a PDF into another image format.
dol_is_file($pathoffile)
Return if path is a file.
dol_dir_list($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_banner_tab($object, $paramid, $morehtml='', $shownav=1, $fieldid='rowid', $fieldref='ref', $morehtmlref='', $moreparam='', $nodbprefix=0, $morehtmlleft='', $morehtmlstatus='', $onlybanner=0, $morehtmlright='')
Show tab footer of a card.
dol_mktime($hour, $minute, $second, $month, $day, $year, $gm='auto', $check=1)
Return a timestamp date built from detailed informations (by default a local PHP server timestamp) Re...
load_fiche_titre($titre, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='')
Show tabs of a record.
img_warning($titlealt='default', $moreatt='', $morecss='pictowarning')
Show warning logo.
img_delete($titlealt='default', $other='class="pictodelete"', $morecss='')
Show delete logo.
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $noescapetags='', $escapeonlyhtmltags=0)
Returns text escaped for inclusion in HTML alt or title tags, or into values of HTML input fields.
price2num($amount, $rounding='', $option=0)
Function that return a number with universal decimal format (decimal separator is '.
get_date_range($date_start, $date_end, $format='', $outputlangs='', $withparenthesis=1)
Format output for start and end date.
dol_print_error($db='', $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
dol_get_fiche_end($notab=0)
Return tab footer of a card.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='')
Set event messages in dol_events session object.
price($amount, $form=0, $outlangs='', $trunc=1, $rounding=-1, $forcerounding=-1, $currency_code='')
Function to format a value into an amount for visual output Function used into PDF and HTML pages.
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs='', $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
dol_now($mode='auto')
Return date for now.
img_mime($file, $titlealt='', $morecss='')
Show MIME img of a file.
getDolGlobalInt($key, $default=0)
Return dolibarr global constant int value.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
dol_getIdFromCode($db, $key, $tablename, $fieldkey='code', $fieldid='id', $entityfilter=0, $filters='')
Return an id or code from a code or id.
newToken()
Return the value of token currently saved into session with name 'newtoken'.
dol_clone($object, $native=0)
Create a clone of instance of object (new instance with same value for each properties) With native =...
getImageFileNameForSize($file, $extName, $extImgTarget='')
Return the filename of file to get the thumbs.
getAdvancedPreviewUrl($modulepart, $relativepath, $alldata=0, $param='')
Return URL we can use for advanced preview links.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
dol_sanitizeFileName($str, $newstr='_', $unaccent=1)
Clean a string to use it as a file name.
GETPOSTISSET($paramname)
Return true if we are in a context of submitting the parameter $paramname from a POST of a form.
isValidEmail($address, $acceptsupervisorkey=0, $acceptuserkey=0)
Return true if email syntax is ok.
isModEnabled($module)
Is Dolibarr module enabled.
img_edit($titlealt='default', $float=0, $other='')
Show logo editer/modifier fiche.
image_format_supported($file, $acceptsvg=0)
Return if a filename is file name of a supported image format.
$formconfirm
if ($action == 'delbookkeepingyear') {
restrictedArea(User $user, $features, $object=0, $tableandshare='', $feature2='', $dbt_keyfield='fk_soc', $dbt_select='rowid', $isdraft=0, $mode=0)
Check permissions of a user to show a page and an object.
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.