31require
'../main.inc.php';
32require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formexpensereport.class.php';
33require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formfile.class.php';
34require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formmail.class.php';
35require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formprojet.class.php';
36require_once DOL_DOCUMENT_ROOT.
'/core/class/CMailFile.class.php';
37require_once DOL_DOCUMENT_ROOT.
'/projet/class/project.class.php';
38require_once DOL_DOCUMENT_ROOT.
'/ecm/class/ecmfiles.class.php';
39require_once DOL_DOCUMENT_ROOT.
'/compta/bank/class/account.class.php';
40require_once DOL_DOCUMENT_ROOT.
'/core/lib/expensereport.lib.php';
41require_once DOL_DOCUMENT_ROOT.
'/core/lib/price.lib.php';
42require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
43require_once DOL_DOCUMENT_ROOT.
'/core/lib/images.lib.php';
44require_once DOL_DOCUMENT_ROOT.
'/core/modules/expensereport/modules_expensereport.php';
45require_once DOL_DOCUMENT_ROOT.
'/expensereport/class/expensereport.class.php';
46require_once DOL_DOCUMENT_ROOT.
'/expensereport/class/paymentexpensereport.class.php';
47require_once DOL_DOCUMENT_ROOT.
'/core/class/doleditor.class.php';
48require_once DOL_DOCUMENT_ROOT.
'/core/class/extrafields.class.php';
49if (isModEnabled(
'accounting')) {
50 require_once DOL_DOCUMENT_ROOT.
'/accountancy/class/accountingjournal.class.php';
65$langs->loadLangs(array(
"trips",
"bills",
"mails"));
67$action =
GETPOST(
'action',
'aZ09');
68$cancel =
GETPOST(
'cancel',
'alpha');
69$confirm =
GETPOST(
'confirm',
'alpha');
70$backtopage =
GETPOST(
'backtopage',
'alpha');
77$vatrate =
GETPOST(
'vatrate',
'alpha');
79$comments =
GETPOST(
'comments',
'restricthtml');
84$childids = $user->getAllChildIds(1);
87 if (empty($date_start)) {
91 if (empty($date_end)) {
98$rootfordata = DOL_DATA_ROOT;
99$rootforuser = DOL_DATA_ROOT;
101if (isModEnabled(
'multicompany') && !empty(
$conf->entity) &&
$conf->entity > 1) {
102 $rootfordata .=
'/'.$conf->entity;
104$conf->expensereport->dir_output = $rootfordata.
'/expensereport';
108$urlwithroot = $urlwithouturlroot.DOL_URL_ROOT;
121$extrafields->fetch_name_optionals_label(
$object->table_element);
124include DOL_DOCUMENT_ROOT.
'/core/actions_fetchobject.inc.php';
127$hookmanager->initHooks(array(
'expensereportcard',
'globalcard'));
131$caneditreport = (empty(
$object->id) || in_array(
$object->fk_user_author, $childids) || (
getDolGlobalString(
'MAIN_USE_ADVANCED_PERMS') && $user->hasRight(
'expensereport',
'writeall_advance')));
133$permissionnote = $user->hasRight(
'expensereport',
'creer') && $caneditreport;
134$permissiondellink = $user->hasRight(
'expensereport',
'creer') && $caneditreport;
135$permissiontoadd = $user->hasRight(
'expensereport',
'creer') && $caneditreport;
136$permissiontoeditextra = $permissiontoadd;
137if (
GETPOST(
'attribute',
'aZ09') && isset($extrafields->attributes[
$object->table_element][
'perms'][
GETPOST(
'attribute',
'aZ09')])) {
139 $permissiontoeditextra =
dol_eval((
string) $extrafields->attributes[
$object->table_element][
'perms'][
GETPOST(
'attribute',
'aZ09')]);
144$projectRequired = isModEnabled(
'project') &&
getDolGlobalString(
'EXPENSEREPORT_PROJECT_IS_REQUIRED');
150 if ($user->hasRight(
'expensereport',
'readall')) {
153 if (
getDolGlobalString(
'MAIN_USE_ADVANCED_PERMS') && $user->hasRight(
'expensereport',
'writeall_advance')) {
156 if ($user->hasRight(
'expensereport',
'lire') && in_array(
$object->fk_user_author, $childids)) {
159 if ($user->hasRight(
'expensereport',
'approve') &&
$object->fk_user_validator == $user->id) {
168if ($user->hasRight(
'expensereport',
'supprimer')) {
177 $socid = $user->socid;
181$permissiontoadd = $user->hasRight(
'expensereport',
'creer') && $caneditreport;
194$parameters = array(
'socid' => $socid);
195$reshook = $hookmanager->executeHooks(
'doActions', $parameters,
$object, $action);
200if (empty($reshook)) {
201 $backurlforlist = DOL_URL_ROOT.
'/expensereport/list.php';
203 if (empty($backtopage) || ($cancel && empty($id))) {
204 if (empty($backtopage) || ($cancel && strpos($backtopage,
'__ID__'))) {
205 if (empty($id) && (($action !=
'add' && $action !=
'create') || $cancel)) {
206 $backtopage = $backurlforlist;
208 $backtopage = DOL_URL_ROOT.
'/expensereport/card.php?id='.((!empty($id) &&
$id > 0) ? $id :
'__ID__');
214 if (!empty($backtopageforcancel)) {
215 header(
"Location: ".$backtopageforcancel);
217 } elseif (!empty($backtopage)) {
218 header(
"Location: ".$backtopage);
232 $fk_c_type_fees = -1;
236 $allowedstatusforaction = array(
244 if ($user->hasRight(
'expensereport',
'approve') || $user->hasRight(
'expensereport',
'to_paid')) {
247 if ($user->hasRight(
'expensereport',
'to_paid')) {
250 if (array_key_exists($action, $allowedstatusforaction) &&
$object->id > 0 && !in_array(
$object->status, $allowedstatusforaction[$action])) {
251 $labelsofallowedstatus = array();
252 foreach ($allowedstatusforaction[$action] as $allowedstatus) {
253 $labelsofallowedstatus[] =
$object->LibStatut($allowedstatus, 0);
255 setEventMessages($langs->trans(
"StatusOfRefMustBe",
$object->ref, implode(
' / ', $labelsofallowedstatus)),
null,
'errors');
259 include DOL_DOCUMENT_ROOT.
'/core/actions_linkedfiles.inc.php';
261 if (!empty(
GETPOST(
'sendit',
'alpha'))) {
262 if ($action ==
'updateline') {
263 $action =
'editline';
269 include DOL_DOCUMENT_ROOT.
'/core/actions_setnotes.inc.php';
271 include DOL_DOCUMENT_ROOT.
'/core/actions_dellink.inc.php';
273 include DOL_DOCUMENT_ROOT.
'/core/actions_lineupdown.inc.php';
276 if ($action ==
'confirm_clone' && $confirm ==
'yes' && $permissiontoadd) {
278 if (1 == 0 && !
GETPOST(
'clone_content',
'alpha') && !
GETPOST(
'clone_receivers',
'alpha')) {
282 $fk_user_author_clone = (
GETPOSTINT(
'fk_user_author') > 0 ?
GETPOSTINT(
'fk_user_author') : $user->id);
283 if ((!
getDolGlobalString(
'MAIN_USE_ADVANCED_PERMS') || !$user->hasRight(
'expensereport',
'writeall_advance')) && !in_array($fk_user_author_clone, $childids)) {
292 header(
"Location: ".$_SERVER[
'PHP_SELF'].
'?id='.$result);
303 if ($action ==
'confirm_delete' &&
GETPOST(
"confirm",
'alpha') ==
"yes" && $id > 0 && $candelete) {
306 $result =
$object->delete($user);
308 header(
"Location: index.php");
315 if ($action ==
'add' && $permissiontoadd) {
318 $object->date_debut = $date_start;
322 if (!(
$object->fk_user_author > 0)) {
323 $object->fk_user_author = $user->id;
327 if ((!
getDolGlobalString(
'MAIN_USE_ADVANCED_PERMS') && !$user->hasRight(
'expensereport',
'creer'))
328 || (
getDolGlobalString(
'MAIN_USE_ADVANCED_PERMS') && !$user->hasRight(
'expensereport',
'creer') && !$user->hasRight(
'expensereport',
'writeall_advance'))) {
333 if (!
getDolGlobalString(
'MAIN_USE_ADVANCED_PERMS') || !$user->hasRight(
'expensereport',
'writeall_advance')) {
334 if (!in_array(
$object->fk_user_author, $childids)) {
341 $fuser =
new User($db);
342 $fuser->fetch(
$object->fk_user_author);
351 $ret = $extrafields->setOptionalsFromPost(
null,
$object);
360 if ($overlappingExpenseReportID > 0) {
362 setEventMessages($langs->trans(
"ErrorDoubleDeclaration").
' <a href="'.$_SERVER[
'PHP_SELF'].
'?id='.$overlappingExpenseReportID.
'">'. $langs->trans(
'ShowTrip').
'</a>',
null,
'errors');
377 header(
"Location: ".$_SERVER[
"PHP_SELF"].
"?id=".$id);
387 if (($action ==
'update' || $action ==
'updateFromRefuse') && $permissiontoadd) {
391 $object->date_debut = $date_start;
401 $object->fk_user_modif = $user->id;
403 $result =
$object->update($user);
405 header(
"Location: ".$_SERVER[
"PHP_SELF"].
"?id=".
GETPOSTINT(
'id'));
412 if ($action ==
'update_extras' && $permissiontoeditextra) {
415 $attribute_name =
GETPOST(
'attribute',
'aZ09');
418 $ret = $extrafields->setOptionalsFromPost(
null,
$object, $attribute_name);
424 $result =
$object->updateExtraField($attribute_name,
'EXPENSEREPORT_MODIFY');
432 $action =
'edit_extras';
436 if ($action ==
"confirm_validate" &&
GETPOST(
"confirm",
'alpha') ==
"yes" && $id > 0 && $permissiontoadd) {
442 $result =
$object->setValidate($user);
447 $outputlangs = $langs;
450 $newlang =
GETPOST(
'lang_id',
'aZ09');
453 $tmpuser =
new User($db);
454 $tmpuser->fetch(
$object->fk_user_author);
455 $newlang = $tmpuser->lang;
457 if (!empty($newlang)) {
459 $outputlangs->setDefaultLang($newlang);
464 $object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref);
471 if (!$error && $result > 0 &&
$object->fk_user_validator > 0) {
472 $langs->load(
"mails");
475 $destinataire =
new User($db);
476 $destinataire->fetch(
$object->fk_user_validator);
477 $emailTo = $destinataire->email;
480 $expediteur =
new User($db);
481 $expediteur->fetch(
$object->fk_user_author);
484 if ($emailTo && $emailFrom) {
495 $subject = $societeName.
" - ".$langs->transnoentities(
"ExpenseReportWaitingForApproval");
498 $link = $urlwithroot.
'/expensereport/card.php?id='.
$object->id;
499 $link =
'<a href="'.$link.
'">'.$link.
'</a>';
500 $message = $langs->transnoentities(
"ExpenseReportWaitingForApprovalMessage", $expediteur->getFullName($langs),
get_date_range(
$object->date_debut,
$object->date_fin,
'', $langs), $link);
515 $mailfile =
new CMailFile($subject, $emailTo, $emailFrom, $message, $filedir, $mimetype, $filename,
'',
'', 0, -1);
517 if (empty($mailfile->error)) {
519 $result = $mailfile->sendfile();
521 $mesg = $langs->trans(
'MailSuccessfulySent', $mailfile->getValidAddress($emailFrom, 2), $mailfile->getValidAddress($emailTo, 2));
524 $langs->load(
"other");
525 if (!empty($mailfile->error) || !empty($mailfile->errors)) {
528 if (!empty($mailfile->error)) {
529 $mesg .=
'<br>' . $mailfile->error;
531 if (!empty($mailfile->errors) && is_array($mailfile->errors)) {
532 $mesg .=
'<br>' . implode(
'<br>', $mailfile->errors);
536 setEventMessages(
'No mail sent. Feature is disabled by option MAIN_DISABLE_ALL_MAILS',
null,
'warnings');
544 setEventMessages($langs->trans(
"NoEmailSentBadSenderOrRecipientEmail"),
null,
'warnings');
551 header(
"Location: ".$_SERVER[
"PHP_SELF"].
"?id=".$id);
558 if ($action ==
"confirm_save_from_refuse" &&
GETPOST(
"confirm",
'alpha') ==
"yes" && $id > 0 && $permissiontoadd) {
561 $result =
$object->set_save_from_refuse($user);
566 $outputlangs = $langs;
569 $newlang =
GETPOST(
'lang_id',
'aZ09');
572 $tmpuser =
new User($db);
573 $tmpuser->fetch(
$object->fk_user_author);
574 $newlang = $tmpuser->lang;
576 if (!empty($newlang)) {
578 $outputlangs->setDefaultLang($newlang);
583 $object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref);
591 $destinataire =
new User($db);
592 $destinataire->fetch(
$object->fk_user_validator);
593 $emailTo = $destinataire->email;
596 $expediteur =
new User($db);
597 $expediteur->fetch(
$object->fk_user_author);
600 if ($emailFrom && $emailTo) {
611 $subject = $societeName.
" - ".$langs->transnoentities(
"ExpenseReportWaitingForReApproval");
614 $link = $urlwithroot.
'/expensereport/card.php?id='.
$object->id;
615 $link =
'<a href="'.$link.
'">'.$link.
'</a>';
617 $message .=
'<br>'.$langs->transnoentities(
"ExpenseReportWaitingForReApprovalMessage2", $link);
636 $mailfile =
new CMailFile($subject, $emailTo, $emailFrom, $message, $filedir, $mimetype, $filename,
'',
'', 0, -1);
638 if (empty($mailfile->error)) {
640 $result = $mailfile->sendfile();
642 $mesg = $langs->trans(
'MailSuccessfulySent', $mailfile->getValidAddress($emailFrom, 2), $mailfile->getValidAddress($emailTo, 2));
644 header(
"Location: ".$_SERVER[
"PHP_SELF"].
"?id=".$id);
647 $langs->load(
"other");
648 if ($mailfile->error) {
650 $mesg .= $langs->trans(
'ErrorFailedToSendMail', $emailFrom, $emailTo);
651 $mesg .=
'<br>'.$mailfile->error;
654 setEventMessages(
'No mail sent. Feature is disabled by option MAIN_DISABLE_ALL_MAILS',
null,
'warnings');
662 setEventMessages($langs->trans(
"NoEmailSentBadSenderOrRecipientEmail"),
null,
'warnings');
671 if ($action ==
"confirm_approve" &&
GETPOST(
"confirm",
'alpha') ==
"yes" && $id > 0 && $user->hasRight(
'expensereport',
'approve')) {
675 $result =
$object->setApproved($user);
680 $outputlangs = $langs;
683 $newlang =
GETPOST(
'lang_id',
'aZ09');
686 $tmpuser =
new User($db);
687 $tmpuser->fetch(
$object->fk_user_author);
688 $newlang = $tmpuser->lang;
690 if (!empty($newlang)) {
692 $outputlangs->setDefaultLang($newlang);
697 $object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref);
705 $destinataire =
new User($db);
706 $destinataire->fetch(
$object->fk_user_author);
707 $emailTo = $destinataire->email;
711 if (empty($emailTo)) {
716 $expediteur =
new User($db);
717 $expediteur->fetch(
$object->fk_user_approve > 0 ?
$object->fk_user_approve :
$object->fk_user_validator);
720 if ($emailFrom && $emailTo) {
731 $subject = $societeName.
" - ".$langs->transnoentities(
"ExpenseReportApproved");
734 $link = $urlwithroot.
'/expensereport/card.php?id='.
$object->id;
735 $link =
'<a href="'.$link.
'">'.$link.
'</a>';
736 $message = $langs->transnoentities(
"ExpenseReportApprovedMessage",
$object->ref, $destinataire->getFullName($langs), $expediteur->getFullName($langs), $link);
753 $mailfile =
new CMailFile($subject, $emailTo, $emailFrom, $message, $filedir, $mimetype, $filename, $emailCC,
'', 0, -1);
755 if (empty($mailfile->error)) {
757 $result = $mailfile->sendfile();
759 $mesg = $langs->trans(
'MailSuccessfulySent', $mailfile->getValidAddress($emailFrom, 2), $mailfile->getValidAddress($emailTo, 2));
761 header(
"Location: ".$_SERVER[
"PHP_SELF"].
"?id=".$id);
764 $langs->load(
"other");
765 if ($mailfile->error) {
767 $mesg .= $langs->trans(
'ErrorFailedToSendMail', $emailFrom, $emailTo);
768 $mesg .=
'<br>'.$mailfile->error;
771 setEventMessages(
'No mail sent. Feature is disabled by option MAIN_DISABLE_ALL_MAILS',
null,
'warnings');
779 setEventMessages($langs->trans(
"NoEmailSentBadSenderOrRecipientEmail"),
null,
'warnings');
788 if ($action ==
"confirm_refuse" &&
GETPOST(
'confirm',
'alpha') ==
"yes" && $id > 0 && $user->hasRight(
'expensereport',
'approve')) {
792 $detailRefuse =
GETPOST(
'detail_refuse',
'alpha');
793 $result =
$object->setDeny($user, $detailRefuse);
798 $outputlangs = $langs;
801 $newlang =
GETPOST(
'lang_id',
'aZ09');
804 $tmpuser =
new User($db);
805 $tmpuser->fetch(
$object->fk_user_author);
806 $newlang = $tmpuser->lang;
808 if (!empty($newlang)) {
810 $outputlangs->setDefaultLang($newlang);
815 $object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref);
823 $destinataire =
new User($db);
824 $destinataire->fetch(
$object->fk_user_author);
825 $emailTo = $destinataire->email;
828 $expediteur =
new User($db);
829 $expediteur->fetch(
$object->fk_user_refuse);
832 if ($emailFrom && $emailTo) {
843 $subject = $societeName.
" - ".$langs->transnoentities(
"ExpenseReportRefused");
846 $link = $urlwithroot.
'/expensereport/card.php?id='.
$object->id;
847 $link =
'<a href="'.$link.
'">'.$link.
'</a>';
848 $message = $langs->transnoentities(
"ExpenseReportRefusedMessage",
$object->ref, $destinataire->getFullName($langs), $expediteur->getFullName($langs), $detailRefuse, $link);
866 $mailfile =
new CMailFile($subject, $emailTo, $emailFrom, $message, $filedir, $mimetype, $filename,
'',
'', 0, -1);
868 if (empty($mailfile->error)) {
870 $result = $mailfile->sendfile();
872 $mesg = $langs->trans(
'MailSuccessfulySent', $mailfile->getValidAddress($emailFrom, 2), $mailfile->getValidAddress($emailTo, 2));
874 header(
"Location: ".$_SERVER[
"PHP_SELF"].
"?id=".$id);
877 $langs->load(
"other");
878 if ($mailfile->error) {
880 $mesg .= $langs->trans(
'ErrorFailedToSendMail', $emailFrom, $emailTo);
881 $mesg .=
'<br>'.$mailfile->error;
884 setEventMessages(
'No mail sent. Feature is disabled by option MAIN_DISABLE_ALL_MAILS',
null,
'warnings');
892 setEventMessages($langs->trans(
"NoEmailSentBadSenderOrRecipientEmail"),
null,
'warnings');
902 if ($action ==
"confirm_cancel" &&
GETPOST(
'confirm',
'alpha') ==
"yes" && $id > 0 && $user->hasRight(
'expensereport',
'creer')) {
903 if (!
GETPOST(
'detail_cancel',
'alpha')) {
904 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Comment")),
null,
'errors');
909 if ($user->id ==
$object->fk_user_valid || $user->id ==
$object->fk_user_author) {
910 $detailCancel =
GETPOST(
'detail_cancel',
'alpha');
911 $result =
$object->set_cancel($user, $detailCancel);
916 $outputlangs = $langs;
919 $newlang =
GETPOST(
'lang_id',
'aZ09');
922 $tmpuser =
new User($db);
923 $tmpuser->fetch(
$object->fk_user_author);
924 $newlang = $tmpuser->lang;
926 if (!empty($newlang)) {
928 $outputlangs->setDefaultLang($newlang);
933 $object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref);
941 $destinataire =
new User($db);
942 $destinataire->fetch(
$object->fk_user_author);
943 $emailTo = $destinataire->email;
946 $expediteur =
new User($db);
947 $expediteur->fetch(
$object->fk_user_cancel);
950 if ($emailFrom && $emailTo) {
961 $subject = $societeName.
" - ".$langs->transnoentities(
"ExpenseReportCanceled");
964 $link = $urlwithroot.
'/expensereport/card.php?id='.
$object->id;
965 $link =
'<a href="'.$link.
'">'.$link.
'</a>';
966 $message = $langs->transnoentities(
"ExpenseReportCanceledMessage",
$object->ref, $destinataire->getFullName($langs), $expediteur->getFullName($langs), $detailCancel, $link);
984 $mailfile =
new CMailFile($subject, $emailTo, $emailFrom, $message, $filedir, $mimetype, $filename,
'',
'', 0, -1);
986 if (empty($mailfile->error)) {
988 $result = $mailfile->sendfile();
990 $mesg = $langs->trans(
'MailSuccessfulySent', $mailfile->getValidAddress($emailFrom, 2), $mailfile->getValidAddress($emailTo, 2));
992 header(
"Location: ".$_SERVER[
"PHP_SELF"].
"?id=".$id);
995 $langs->load(
"other");
996 if ($mailfile->error) {
998 $mesg .= $langs->trans(
'ErrorFailedToSendMail', $emailFrom, $emailTo);
999 $mesg .=
'<br>'.$mailfile->error;
1002 setEventMessages(
'No mail sent. Feature is disabled by option MAIN_DISABLE_ALL_MAILS',
null,
'warnings');
1010 setEventMessages($langs->trans(
"NoEmailSentBadSenderOrRecipientEmail"),
null,
'warnings');
1023 if ($action ==
"confirm_setdraft" &&
GETPOST(
'confirm',
'alpha') ==
"yes" && $id > 0 && $user->hasRight(
'expensereport',
'creer')) {
1026 if ($user->id ==
$object->fk_user_author || $user->id ==
$object->fk_user_valid || in_array(
$object->fk_user_author, $childids)) {
1027 $result =
$object->setStatut(0);
1032 $outputlangs = $langs;
1035 $newlang =
GETPOST(
'lang_id',
'aZ09');
1038 $tmpuser =
new User($db);
1039 $tmpuser->fetch(
$object->fk_user_author);
1040 $newlang = $tmpuser->lang;
1042 if (!empty($newlang)) {
1044 $outputlangs->setDefaultLang($newlang);
1049 $object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref);
1054 header(
"Location: ".$_SERVER[
"PHP_SELF"].
"?id=".$id);
1064 if ($action ==
'set_unpaid' && $id > 0 && $user->hasRight(
'expensereport',
'to_paid')) {
1068 $result =
$object->setUnpaid($user);
1073 $outputlangs = $langs;
1076 $newlang =
GETPOST(
'lang_id',
'aZ09');
1079 $tmpuser =
new User($db);
1080 $tmpuser->fetch(
$object->fk_user_author);
1081 $newlang = $tmpuser->lang;
1083 if (!empty($newlang)) {
1085 $outputlangs->setDefaultLang($newlang);
1090 $object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref);
1093 header(
"Location: ".$_SERVER[
"PHP_SELF"].
"?id=".$id);
1099 if ($action ==
'set_paid' && $id > 0 && $user->hasRight(
'expensereport',
'to_paid')) {
1103 $result =
$object->setPaid($id, $user);
1108 $outputlangs = $langs;
1111 $newlang =
GETPOST(
'lang_id',
'aZ09');
1114 $tmpuser =
new User($db);
1115 $tmpuser->fetch(
$object->fk_user_author);
1116 $newlang = $tmpuser->lang;
1118 if (!empty($newlang)) {
1120 $outputlangs->setDefaultLang($newlang);
1125 $object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref);
1136 $destinataire =
new User($db);
1137 $destinataire->fetch(
$object->fk_user_author);
1138 $emailTo = $destinataire->email;
1141 $expediteur =
new User($db);
1142 $expediteur->fetch($user->id);
1145 if ($emailFrom && $emailTo) {
1146 $filename = array();
1148 $mimetype = array();
1156 $subject = $societeName.
" - ".$langs->transnoentities(
"ExpenseReportPaid");
1159 $link = $urlwithroot.
'/expensereport/card.php?id='.
$object->id;
1160 $link =
'<a href="'.$link.
'">'.$link.
'</a>';
1161 $message = $langs->transnoentities(
"ExpenseReportPaidMessage",
$object->ref, $destinataire->getFullName($langs), $expediteur->getFullName($langs), $link);
1164 $object->setDocModel($user,
"");
1165 $resultPDF = expensereport_pdf_create($db,
$object,
'',
"", $langs);
1168 $mailfile =
new CMailFile($subject, $emailTo, $emailFrom, $message, $filedir, $mimetype, $filename,
'',
'', 0, -1);
1170 if (empty($mailfile->error)) {
1172 $result = $mailfile->sendfile();
1174 $mesg = $langs->trans(
'MailSuccessfulySent', $mailfile->getValidAddress($emailFrom, 2), $mailfile->getValidAddress($emailTo, 2));
1177 header(
"Location: ".$_SERVER[
"PHP_SELF"].
"?id=".$id);
1180 $langs->load(
"other");
1181 if ($mailfile->error) {
1183 $mesg .= $langs->trans(
'ErrorFailedToSendMail', $emailFrom, $emailTo);
1184 $mesg .=
'<br>'.$mailfile->error;
1187 setEventMessages(
'No mail sent. Feature is disabled by option MAIN_DISABLE_ALL_MAILS',
null,
'warnings');
1194 setEventMessages($langs->trans(
"NoEmailSentBadSenderOrRecipientEmail"),
null,
'warnings');
1204 if ($action ==
"addline" && $permissiontoadd) {
1207 if (GETPOSTISSET(
'attachfile')) {
1208 $arrayoffiles =
GETPOST(
'attachfile',
'array');
1209 if (is_array($arrayoffiles) && !empty($arrayoffiles[0])) {
1210 include_once DOL_DOCUMENT_ROOT.
'/ecm/class/ecmfiles.class.php';
1211 $entityprefix = (
$conf->entity !=
'1') ?
$conf->entity.
'/' :
'';
1212 $relativepath = $entityprefix.
'expensereport/'.
$object->ref.
'/'.$arrayoffiles[0];
1214 $ecmfiles->fetch(0,
'', $relativepath);
1215 $fk_ecm_files = $ecmfiles->id;
1220 if (empty($vatrate)) {
1223 $tmpvat =
price2num(preg_replace(
'/\s*\(.*\)/',
'', $vatrate));
1227 if (empty($value_unit)) {
1228 $value_unit =
price2num((
float) $value_unit_ht + ((
float) $value_unit_ht * (
float) $tmpvat / 100),
'MU');
1231 $fk_c_exp_tax_cat =
GETPOSTINT(
'fk_c_exp_tax_cat');
1238 if (!($fk_c_type_fees > 0)) {
1240 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Type")),
null,
'errors');
1244 if ((
float) $tmpvat < 0 || $tmpvat ===
'') {
1246 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"VAT")),
null,
'errors');
1251 if (empty($date) || $date ==
"--") {
1253 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Date")),
null,
'errors');
1254 } elseif ($date < $object->date_debut || $date > (
$object->date_fin + (24 * 3600 - 1))) {
1260 $langs->load(
"errors");
1261 $type = $error > 0 ?
'errors' :
'warnings';
1262 setEventMessages($langs->trans(
"WarningDateOfLineMustBeInExpenseReportRange"),
null, $type);
1266 if ($value_unit == 0) {
1268 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"PriceUTTC")),
null,
'errors');
1272 if ($projectRequired && $fk_project <= 0) {
1274 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Project")),
null,
'errors');
1278 if ($fileRequired && $fk_ecm_files == 0) {
1280 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"File")),
null,
'errors');
1287 $result =
$object->addline($qty, $value_unit, $fk_c_type_fees, $vatrate, $date, $comments, $fk_project, $fk_c_exp_tax_cat, $type, $fk_ecm_files);
1293 $outputlangs = $langs;
1294 $newlang =
GETPOST(
'lang_id',
'alpha');
1296 $tmpuser =
new User($db);
1297 $tmpuser->fetch(
$object->fk_user_author);
1298 $newlang = $tmpuser->lang;
1300 if (!empty($newlang)) {
1302 $outputlangs->setDefaultLang($newlang);
1305 $object->generateDocument(
$object->model_pdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
1309 unset($value_unit_ht);
1313 unset($fk_c_type_fees);
1324 header(
"Location: ".$_SERVER[
"PHP_SELF"].
"?id=".
GETPOSTINT(
'id'));
1333 setEventMessages($langs->trans(
"ErrorDeleteLineNotAllowedByObjectStatus"),
null,
'errors');
1337 if ($action ==
'confirm_delete_line' &&
GETPOST(
"confirm",
'alpha') ==
"yes" && $permissiontoadd) {
1343 $total_ht = $object_ligne->total_ht;
1344 $total_tva = $object_ligne->total_tva;
1351 $outputlangs = $langs;
1354 $newlang =
GETPOST(
'lang_id',
'aZ09');
1357 $tmpuser =
new User($db);
1358 $tmpuser->fetch(
$object->fk_user_author);
1359 $newlang = $tmpuser->lang;
1361 if (!empty($newlang)) {
1363 $outputlangs->setDefaultLang($newlang);
1368 $object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref);
1372 header(
"Location: ".$_SERVER[
"PHP_SELF"].
"?id=".
GETPOSTINT(
'id'));
1379 if ($action ==
"updateline" && $permissiontoadd) {
1385 if (GETPOSTISSET(
'attachfile')) {
1386 $arrayoffiles =
GETPOST(
'attachfile',
'array');
1387 if (is_array($arrayoffiles) && !empty($arrayoffiles[0])) {
1388 include_once DOL_DOCUMENT_ROOT.
'/ecm/class/ecmfiles.class.php';
1389 $entityprefix = (
$conf->entity !=
'1') ?
$conf->entity.
'/' :
'';
1390 $relativepath = $entityprefix.
'expensereport/'.
$object->ref.
'/'.$arrayoffiles[0];
1392 $ecmfiles->fetch(0,
'', $relativepath);
1393 $fk_ecm_files = $ecmfiles->id;
1398 $type_fees_id =
GETPOSTINT(
'fk_c_type_fees');
1399 $fk_c_exp_tax_cat =
GETPOSTINT(
'fk_c_exp_tax_cat');
1400 $projet_id = $fk_project;
1401 $comments =
GETPOST(
'comments',
'restricthtml');
1403 $vatrate =
GETPOST(
'vatrate',
'alpha');
1406 if (empty($vatrate)) {
1409 $tmpvat =
price2num(preg_replace(
'/\s*\(.*\)/',
'', $vatrate));
1413 if (empty($value_unit)) {
1414 $value_unit =
price2num((
float) $value_unit_ht + ((
float) $value_unit_ht * (
float) $tmpvat / 100),
'MU');
1419 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Type")),
null,
'errors');
1422 if ((
float) $tmpvat < 0 || $tmpvat ==
'') {
1424 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Vat")),
null,
'errors');
1428 if ($date < $object->date_debut || $date > (
$object->date_fin + (24 * 3600 - 1))) {
1433 $langs->load(
"errors");
1434 $type = $error > 0 ?
'errors' :
'warnings';
1435 setEventMessages($langs->trans(
"WarningDateOfLineMustBeInExpenseReportRange"),
null, $type);
1439 if ($projectRequired && $projet_id <= 0) {
1441 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Project")),
null,
'errors');
1446 $result =
$object->updateline($rowid, $type_fees_id, $projet_id, (
float) $vatrate, $comments, (
float) $qty, (
float) $value_unit, $date, $id, $fk_c_exp_tax_cat, $fk_ecm_files);
1451 $outputlangs = $langs;
1454 $newlang =
GETPOST(
'lang_id',
'aZ09');
1457 $tmpuser =
new User($db);
1458 $tmpuser->fetch(
$object->fk_user_author);
1459 $newlang = $tmpuser->lang;
1461 if (!empty($newlang)) {
1463 $outputlangs->setDefaultLang($newlang);
1468 $object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref);
1472 unset($value_unit_ht);
1476 unset($fk_c_type_fees);
1489 include DOL_DOCUMENT_ROOT.
'/core/actions_printing.inc.php';
1492 $triggersendname =
'EXPENSEREPORT_SENTBYMAIL';
1493 $autocopy =
'MAIN_MAIL_AUTOCOPY_EXPENSEREPORT_TO';
1494 $trackid =
'exp'.$object->id;
1495 include DOL_DOCUMENT_ROOT.
'/core/actions_sendmails.inc.php';
1498 $upload_dir =
$conf->expensereport->dir_output;
1499 include DOL_DOCUMENT_ROOT.
'/core/actions_builddoc.inc.php';
1507$title = $langs->trans(
"ExpenseReport").
" - ".$langs->trans(
"Card");
1508$help_url =
"EN:Module_Expense_Reports|FR:Module_Notes_de_frais";
1512$form =
new Form($db);
1515$projecttmp =
new Project($db);
1517$bankaccountstatic =
new Account($db);
1518$ecmfilesstatic =
new EcmFiles($db);
1523if ($action ==
'create') {
1526 print
'<form action="'.$_SERVER[
'PHP_SELF'].
'" method="post" name="create">';
1527 print
'<input type="hidden" name="token" value="'.newToken().
'">';
1528 print
'<input type="hidden" name="action" value="add">';
1529 print
'<input type="hidden" name="backtopage" value="'.$backtopage.
'">';
1533 print
'<table class="border centpercent">';
1538 print
'<td class="titlefieldcreate fieldrequired">'.$langs->trans(
"DateStart").
'</td>';
1540 print $form->selectDate($date_start ? $date_start : -1,
'date_debut', 0, 0, 0,
'', 1, 1);
1546 print
'<td class="fieldrequired">'.$langs->trans(
"DateEnd").
'</td>';
1548 print $form->selectDate($date_end ? $date_end : -1,
'date_fin', 0, 0, 0,
'', 1, 1);
1554 print
'<td class="fieldrequired">'.$langs->trans(
"User").
'</td>';
1556 $defaultselectuser = $user->id;
1558 $defaultselectuser =
GETPOSTINT(
'fk_user_author');
1560 $include_users =
'hierarchyme';
1561 if (
getDolGlobalString(
'MAIN_USE_ADVANCED_PERMS') && $user->hasRight(
'expensereport',
'writeall_advance')) {
1562 $include_users = array();
1564 $s = $form->select_dolusers($defaultselectuser,
"fk_user_author", 0,
null, 0, $include_users,
'',
'0,'.
$conf->entity);
1571 print
'<td>'.$langs->trans(
"VALIDATOR").
'</td>';
1574 $include_users =
$object->fetch_users_approver_expensereport();
1575 if (empty($include_users)) {
1576 print
img_warning().
' '.$langs->trans(
"NobodyHasPermissionToValidateExpenseReport");
1578 $defaultselectuser = (empty($user->fk_user_expense_validator) ? $user->fk_user : $user->fk_user_expense_validator);
1583 $defaultselectuser =
GETPOSTINT(
'fk_user_validator');
1585 $s = $form->select_dolusers($defaultselectuser,
"fk_user_validator", 1,
null, ((empty($defaultselectuser) || !
getDolGlobalString(
'EXPENSEREPORT_DEFAULT_VALIDATOR_UNCHANGEABLE')) ? 0 : 1), $include_users);
1586 print $form->textwithpicto($s, $langs->trans(
"AnyOtherInThisListCanValidate"));
1594 print
'<td>'.$langs->trans(
"ModePaiement").
'</td>';
1596 $form->select_types_paiements(
'',
'fk_c_paiement');
1602 $note_public = GETPOSTISSET(
'note_public') ?
GETPOST(
'note_public',
'restricthtml') :
'';
1605 print
'<td class="tdtop">'.$langs->trans(
'NotePublic').
'</td>';
1608 $doleditor =
new DolEditor(
'note_public', $note_public,
'', 80,
'dolibarr_notes',
'In',
false,
false, !
getDolGlobalString(
'FCKEDITOR_ENABLE_NOTE_PUBLIC') ? 0 : 1, ROWS_3,
'90%');
1609 print $doleditor->Create(1);
1613 $note_private = GETPOSTISSET(
'note_private') ?
GETPOST(
'note_private',
'restricthtml') :
'';
1615 if (empty($user->socid)) {
1617 print
'<td class="tdtop">'.$langs->trans(
'NotePrivate').
'</td>';
1620 $doleditor =
new DolEditor(
'note_private', $note_private,
'', 80,
'dolibarr_notes',
'In',
false,
false, !
getDolGlobalString(
'FCKEDITOR_ENABLE_NOTE_PRIVATE') ? 0 : 1, ROWS_3,
'90%');
1621 print $doleditor->Create(1);
1626 $parameters = array(
'colspan' =>
' colspan="3"',
'cols' => 3);
1627 $reshook = $hookmanager->executeHooks(
'formObjectOptions', $parameters,
$object, $action);
1628 print $hookmanager->resPrint;
1629 if (empty($reshook)) {
1630 print
$object->showOptionals($extrafields,
'create', $parameters);
1638 print $form->buttonsSaveCancel(
"AddTrip");
1643 $result =
$object->fetch($id, $ref);
1646 if (!in_array(
$object->fk_user_author, $childids)) {
1647 if (!$user->hasRight(
'expensereport',
'readall') && !$user->hasRight(
'expensereport',
'lire_tous')
1648 && (!
getDolGlobalString(
'MAIN_USE_ADVANCED_PERMS') || !$user->hasRight(
'expensereport',
'writeall_advance'))) {
1651 print
'<div class="tabBar">';
1652 print $langs->trans(
'NotUserRightToView');
1667 print
"<form name='update' action=\"".$_SERVER[
'PHP_SELF'].
"\" method=\"post\">\n";
1668 print
'<input type="hidden" name="token" value="'.newToken().
'">';
1669 print
'<input type="hidden" name="id" value="'.$id.
'">';
1670 print
'<input type="hidden" name="backtopage" value="'.$backtopage.
'">';
1672 print
dol_get_fiche_head($head,
'card', $langs->trans(
"ExpenseReport"), 0,
'trip', 0,
'',
'', 0,
'', 1);
1675 print
'<input type="hidden" name="action" value="updateFromRefuse">';
1677 print
'<input type="hidden" name="action" value="update">';
1680 $linkback =
'<a href="'.DOL_URL_ROOT.
'/expensereport/list.php?restore_lastsearch_values=1'.(!empty($socid) ?
'&socid='.$socid :
'').
'">'.$langs->trans(
"BackToList").
'</a>';
1682 print
'<table class="border centpercent">';
1685 print
'<td>'.$langs->trans(
"User").
'</td>';
1687 $userfee =
new User($db);
1688 if (
$object->fk_user_author > 0) {
1689 $userfee->fetch(
$object->fk_user_author);
1690 print $userfee->getNomUrl(-1);
1695 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"Ref").
'</td><td>';
1696 print $form->showrefnav(
$object,
'ref', $linkback, 1,
'ref',
'ref',
'');
1700 print
'<td>'.$langs->trans(
"DateStart").
'</td>';
1702 print $form->selectDate(
$object->date_debut,
'date_debut');
1706 print
'<td>'.$langs->trans(
"DateEnd").
'</td>';
1708 print $form->selectDate(
$object->date_fin,
'date_fin');
1714 print
'<td>'.$langs->trans(
"ModePaiement").
'</td>';
1716 $form->select_types_paiements((
string)
$object->fk_c_paiement,
'fk_c_paiement');
1723 print
'<td>'.$langs->trans(
"VALIDATOR").
'</td>';
1725 $include_users =
$object->fetch_users_approver_expensereport();
1726 $s = $form->select_dolusers(
$object->fk_user_validator,
"fk_user_validator", 1,
null, 0, $include_users);
1727 print $form->textwithpicto($s, $langs->trans(
"AnyOtherInThisListCanValidate"));
1732 print
'<td>'.$langs->trans(
"VALIDOR").
'</td>';
1734 $userfee =
new User($db);
1735 $userfee->fetch(
$object->fk_user_valid);
1736 print $userfee->getNomUrl(-1);
1742 print
'<td>'.$langs->trans(
"AUTHORPAIEMENT").
'</td>';
1744 $userfee =
new User($db);
1745 $userfee->fetch($user->id);
1746 print $userfee->getNomUrl(-1);
1758 print $form->buttonsSaveCancel(
"Modify");
1762 $taxlessUnitPriceDisabled =
getDolGlobalString(
'EXPENSEREPORT_FORCE_LINE_AMOUNTS_INCLUDING_TAXES_ONLY') ?
' disabled' :
'';
1764 print
dol_get_fiche_head($head,
'card', $langs->trans(
"ExpenseReport"), -1,
'trip', 0,
'',
'', 0,
'', 1);
1769 if ($action ==
'clone') {
1771 $criteriaforfilter =
'hierarchyme';
1772 if (
getDolGlobalString(
'MAIN_USE_ADVANCED_PERMS') && $user->hasRight(
'expensereport',
'writeall_advance')) {
1773 $criteriaforfilter =
'';
1775 $formquestion = array(
1777 0 => array(
'type' =>
'other',
'name' =>
'fk_user_author',
'label' => $langs->trans(
"SelectTargetUser"),
'value' => $form->select_dolusers((
GETPOSTINT(
'fk_user_author') > 0 ?
GETPOSTINT(
'fk_user_author') : $user->id),
'fk_user_author', 0, null, 0, $criteriaforfilter,
'',
'0', 0, 0,
'', 0,
'',
'maxwidth150'))
1780 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.
$object->id, $langs->trans(
'ToClone'), $langs->trans(
'ConfirmCloneExpenseReport',
$object->ref),
'confirm_clone', $formquestion,
'yes', 1);
1783 if ($action ==
'save') {
1784 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
"?id=".$id, $langs->trans(
"SaveTrip"), $langs->trans(
"ConfirmSaveTrip"),
"confirm_validate",
"",
"", 1);
1787 if ($action ==
'save_from_refuse') {
1788 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
"?id=".$id, $langs->trans(
"SaveTrip"), $langs->trans(
"ConfirmSaveTrip"),
"confirm_save_from_refuse",
"",
"", 1);
1791 if ($action ==
'delete') {
1792 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
"?id=".$id, $langs->trans(
"DeleteTrip"), $langs->trans(
"ConfirmDeleteTrip"),
"confirm_delete",
"",
"", 1);
1795 if ($action ==
'validate') {
1796 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
"?id=".$id, $langs->trans(
"ValideTrip"), $langs->trans(
"ConfirmValideTrip"),
"confirm_approve",
"",
"", 1);
1799 if ($action ==
'paid') {
1800 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
"?id=".$id, $langs->trans(
"PaidTrip"), $langs->trans(
"ConfirmPaidTrip"),
"confirm_paid",
"",
"", 1);
1803 if ($action ==
'cancel') {
1804 $array_input = array(
'text' => $langs->trans(
"ConfirmCancelTrip"), 0 => array(
'type' =>
"text",
'label' =>
'<strong>'.$langs->trans(
"Comment").
'</strong>',
'name' =>
"detail_cancel",
'value' =>
""));
1805 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
"?id=".$id, $langs->trans(
"Cancel"),
"",
"confirm_cancel", $array_input,
"", 1);
1808 if ($action ==
'setdraft') {
1809 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
"?id=".$id, $langs->trans(
"BrouillonnerTrip"), $langs->trans(
"ConfirmBrouillonnerTrip"),
"confirm_setdraft",
"",
"", 1);
1812 if ($action ==
'refuse') {
1813 $array_input = array(
'text' => $langs->trans(
"ConfirmRefuseTrip"), 0 => array(
'type' =>
"text",
'label' => $langs->trans(
"Comment"),
'name' =>
"detail_refuse",
'value' =>
""));
1814 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
"?id=".$id, $langs->trans(
"Deny"),
'',
"confirm_refuse", $array_input,
"yes", 1);
1817 if ($action ==
'delete_line') {
1818 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
"?id=".
$id.
"&rowid=".
GETPOSTINT(
'rowid'), $langs->trans(
"DeleteLine"), $langs->trans(
"ConfirmDeleteLine"),
"confirm_delete_line",
'',
'yes', 1);
1822 $parameters = array(
'formConfirm' => $formconfirm);
1823 $reshook = $hookmanager->executeHooks(
'formConfirm', $parameters,
$object, $action);
1824 if (empty($reshook)) {
1825 $formconfirm .= $hookmanager->resPrint;
1826 } elseif ($reshook > 0) {
1827 $formconfirm = $hookmanager->resPrint;
1834 $linkback =
'<a href="'.DOL_URL_ROOT.
'/expensereport/list.php?restore_lastsearch_values=1'.(!empty($socid) ?
'&socid='.$socid :
'').
'">'.$langs->trans(
"BackToList").
'</a>';
1836 $morehtmlref =
'<div class="refidno">';
1837 $morehtmlref .=
'</div>';
1839 dol_banner_tab(
$object,
'ref', $linkback, 1,
'ref',
'ref', $morehtmlref);
1841 print
'<div class="fichecenter">';
1842 print
'<div class="fichehalfleft">';
1843 print
'<div class="underbanner clearboth"></div>';
1845 print
'<table class="border tableforfield centpercent">';
1849 print
'<td class="titlefield">'.$langs->trans(
"User").
'</td>';
1851 if (
$object->fk_user_author > 0) {
1852 $userauthor =
new User($db);
1853 $result = $userauthor->fetch(
$object->fk_user_author);
1856 } elseif ($result > 0) {
1857 print $userauthor->getNomUrl(-1);
1864 print
'<td class="titlefield">'.$langs->trans(
"Period").
'</td>';
1871 print
'<td>'.$langs->trans(
"ModePaiement").
'</td>';
1872 print
'<td>'.$object->fk_c_paiement.
'</td>';
1878 print
'<td>'.$langs->trans(
"DATE_SAVE").
'</td>';
1879 print
'<td>'.dol_print_date(
$object->date_valid,
'dayhour',
'tzuser');
1881 print
' '.img_warning($langs->trans(
"Late").
' - '.$langs->trans(
"ToApprove"));
1884 print
' '.img_warning($langs->trans(
"Late").
' - '.$langs->trans(
"ToPay"));
1892 print
'<td>'.$langs->trans(
"VALIDATOR").
'</td>';
1894 if (
$object->fk_user_validator > 0) {
1895 $userfee =
new User($db);
1896 $result = $userfee->fetch(
$object->fk_user_validator);
1898 print $userfee->getNomUrl(-1);
1900 if (empty($userfee->email) || !
isValidEmail($userfee->email)) {
1901 $langs->load(
"errors");
1902 print
img_warning($langs->trans(
"ErrorBadEMail", $userfee->email));
1908 print
'<td>'.$langs->trans(
"CANCEL_USER").
'</span></td>';
1910 if (
$object->fk_user_cancel > 0) {
1911 $userfee =
new User($db);
1912 $result = $userfee->fetch(
$object->fk_user_cancel);
1914 print $userfee->getNomUrl(-1);
1920 print
'<td>'.$langs->trans(
"MOTIF_CANCEL").
'</td>';
1921 print
'<td>'.$object->detail_cancel.
'</td></tr>';
1924 print
'<td>'.$langs->trans(
"DATE_CANCEL").
'</td>';
1925 print
'<td>'.dol_print_date(
$object->date_cancel,
'dayhour',
'tzuser').
'</td></tr>';
1929 print
'<td>'.$langs->trans(
"ApprovedBy").
'</td>';
1931 if (
$object->fk_user_approve > 0) {
1932 $userapp =
new User($db);
1933 $result = $userapp->fetch(
$object->fk_user_approve);
1935 print $userapp->getNomUrl(-1);
1941 print
'<td>'.$langs->trans(
"DateApprove").
'</td>';
1942 print
'<td>'.dol_print_date(
$object->date_approve,
'dayhour',
'tzuser').
'</td></tr>';
1948 print
'<td>'.$langs->trans(
"REFUSEUR").
'</td>';
1950 $userfee =
new User($db);
1951 $result = $userfee->fetch(
$object->fk_user_refuse);
1953 print $userfee->getNomUrl(-1);
1958 print
'<td>'.$langs->trans(
"DATE_REFUS").
'</td>';
1959 print
'<td>'.dol_print_date(
$object->date_refuse,
'dayhour',
'tzuser');
1961 print
' - '.$object->detail_refuse;
1985 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_view.tpl.php';
1990 print
'<div class="fichehalfright">';
1991 print
'<div class="underbanner clearboth"></div>';
1993 print
'<table class="border tableforfield centpercent">';
1997 print
'<td class="titlefieldmiddle">'.$langs->trans(
"AmountHT").
'</td>';
1998 print
'<td class="nowrap amountcard">'.price(
$object->total_ht, 1,
'', 1, - 1, - 1,
$conf->currency).
'</td>';
2015 print
'<td>'.$langs->trans(
"AmountVAT").
'</td>';
2016 print
'<td class="nowrap amountcard">'.price(
$object->total_tva, 1,
'', 1, -1, -1,
$conf->currency).
'</td>';
2020 if ($mysoc->localtax1_assuj ==
"1" ||
$object->total_localtax1 != 0) {
2021 print
'<tr><td>'.$langs->transcountry(
"AmountLT1", $mysoc->country_code).
'</td>';
2022 print
'<td class="valuefield">'.price(
$object->total_localtax1, 1,
'', 1, -1, -1,
$conf->currency).
'</td></tr>';
2024 if ($mysoc->localtax2_assuj ==
"1" ||
$object->total_localtax2 != 0) {
2025 print
'<tr><td>'.$langs->transcountry(
"AmountLT2", $mysoc->country_code).
'</td>';
2026 print
'<td class="valuefield">'.price(
$object->total_localtax2, 1,
'', 1, -1, -1,
$conf->currency).
'</td></tr>';
2030 print
'<td>'.$langs->trans(
"AmountTTC").
'</td>';
2031 print
'<td class="nowrap amountcard">'.price(
$object->total_ttc, 1,
'', 1, -1, -1,
$conf->currency).
'</td>';
2035 $canSeeBankAccount = isModEnabled(
'bank') && $user->hasRight(
'banque',
'lire');
2038 if ($canSeeBankAccount) {
2043 print
'<table class="noborder paymenttable centpercent">';
2045 print
'<tr class="liste_titre">';
2046 print
'<td class="liste_titre">'.$langs->trans(
'Payments').
'</td>';
2047 print
'<td class="liste_titre">'.$langs->trans(
'Date').
'</td>';
2048 print
'<td class="liste_titre">'.$langs->trans(
'Type').
'</td>';
2049 if ($canSeeBankAccount) {
2050 print
'<td class="liste_titre right">'.$langs->trans(
'BankAccount').
'</td>';
2052 print
'<td class="liste_titre right">'.$langs->trans(
'Amount').
'</td>';
2053 print
'<td class="liste_titre" width="18"> </td>';
2057 $sql =
"SELECT p.rowid, p.num_payment, p.datep as dp, p.amount, p.fk_bank,";
2058 $sql .=
"c.code as payment_code, c.libelle as payment_type,";
2059 $sql .=
"ba.rowid as baid, ba.ref as baref, ba.label, ba.number as banumber, ba.account_number, ba.fk_accountancy_journal";
2060 $sql .=
" FROM ".MAIN_DB_PREFIX.
"expensereport as e, ".MAIN_DB_PREFIX.
"payment_expensereport as p";
2061 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"c_paiement as c ON p.fk_typepayment = c.id";
2062 $sql .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'bank as b ON p.fk_bank = b.rowid';
2063 $sql .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'bank_account as ba ON b.fk_account = ba.rowid';
2064 $sql .=
" WHERE e.rowid = ".((int) $id);
2065 $sql .=
" AND p.fk_expensereport = e.rowid";
2066 $sql .=
' AND e.entity IN ('.getEntity(
'expensereport').
')';
2067 $sql .=
" ORDER BY dp";
2069 $resql = $db->query($sql);
2071 $num = $db->num_rows($resql);
2075 $objp = $db->fetch_object($resql);
2077 $paymentexpensereportstatic->id = $objp->rowid;
2078 $paymentexpensereportstatic->datep = $db->jdate($objp->dp);
2079 $paymentexpensereportstatic->ref = $objp->rowid;
2080 $paymentexpensereportstatic->num_payment = $objp->num_payment;
2081 $paymentexpensereportstatic->type_code = $objp->payment_code;
2082 $paymentexpensereportstatic->type_label = $objp->payment_type;
2084 print
'<tr class="oddeven">';
2086 print $paymentexpensereportstatic->getNomUrl(1);
2088 print
'<td>'.dol_print_date($db->jdate($objp->dp),
'day').
"</td>\n";
2089 $labeltype = $langs->trans(
"PaymentType".$objp->payment_code) !=
"PaymentType".$objp->payment_code ? $langs->trans(
"PaymentType".$objp->payment_code) : $objp->payment_type;
2090 print
"<td>".$labeltype.
' '.$objp->num_payment.
"</td>\n";
2092 if ($canSeeBankAccount) {
2093 $bankaccountstatic->id = $objp->baid;
2094 $bankaccountstatic->ref = $objp->baref;
2095 $bankaccountstatic->label = $objp->baref;
2096 $bankaccountstatic->number = $objp->banumber;
2098 if (isModEnabled(
'accounting')) {
2099 $bankaccountstatic->account_number = $objp->account_number;
2102 $accountingjournal->fetch($objp->fk_accountancy_journal);
2103 $bankaccountstatic->accountancy_journal = $accountingjournal->getNomUrl(0, 1, 1,
'', 1);
2106 print
'<td class="right">';
2107 if ($bankaccountstatic->id) {
2108 print $bankaccountstatic->getNomUrl(1,
'transactions');
2112 print
'<td class="right">'.price($objp->amount).
"</td>";
2115 $totalpaid += $objp->amount;
2121 $resteapayeraffiche = $remaintopay;
2123 if ($remaintopay > 0) {
2124 $cssforamountpaymentcomplete =
'amountremaintopay';
2126 $cssforamountpaymentcomplete =
'amountpaymentcomplete';
2130 $cssforamountpaymentcomplete =
'amountpaymentneutral strikefordisabled';
2131 } elseif (
$object->paid == 1 && $remaintopay > 0) {
2132 $cssforamountpaymentcomplete =
'amountpaymentneutral strikefordisabled';
2134 print
'<tr><td colspan="'.$nbcols.
'" class="right">'.$langs->trans(
"AlreadyPaid").
':</td><td class="right">'.
price($totalpaid).
'</td><td></td></tr>';
2135 print
'<tr><td colspan="'.$nbcols.
'" class="right">'.$langs->trans(
"AmountExpected").
':</td><td class="right">'.
price(
$object->total_ttc).
'</td><td></td></tr>';
2137 print
'<tr><td colspan="'.$nbcols.
'" class="right">'.$langs->trans(
"RemainderToPay").
':</td>';
2138 print
'<td class="right'.($resteapayeraffiche ?
' amountremaintopay' : (
' '.$cssforamountpaymentcomplete)).
'">'.
price($resteapayeraffiche).
'</td><td></td></tr>';
2149 print
'<div class="clearboth"></div><br><br>';
2151 print
'<div style="clear: both;"></div>';
2153 $actiontouse =
'updateline';
2155 $actiontouse =
'addline';
2158 print
'<form name="expensereport" action="'.$_SERVER[
"PHP_SELF"].
'" enctype="multipart/form-data" method="post" >';
2159 print
'<input type="hidden" name="token" value="'.newToken().
'">';
2160 print
'<input type="hidden" name="action" value="'.$actiontouse.
'">';
2161 print
'<input type="hidden" name="id" value="'.$object->id.
'">';
2162 print
'<input type="hidden" name="fk_expensereport" value="'.$object->id.
'" />';
2163 print
'<input type="hidden" name="backtopage" value="'.$backtopage.
'">';
2164 print
'<input type="hidden" name="page_y" value="">';
2166 print
'<div class="div-table-responsive-no-min">';
2167 print
'<table id="tablelines" class="noborder centpercent">';
2173 print
'<tr class="liste_titre headerexpensereportdet">';
2174 print
'<td class="center linecollinenb">'.$langs->trans(
'LineNb').
'</td>';
2176 print
'<td class="center linecoldate">'.$langs->trans(
'Date').
'</td>';
2177 if (isModEnabled(
'project')) {
2178 print
'<td class="minwidth100imp linecolproject">'.$langs->trans(
'Project').
'</td>';
2180 print
'<td class="center linecoltype">'.$langs->trans(
'Type').
'</td>';
2182 print
'<td class="center linecolcarcategory">'.$langs->trans(
'CarCategory').
'</td>';
2184 print
'<td class="linecoldescription">'.$langs->trans(
'Description').
'</td>';
2185 print
'<td class="right linecolvat">'.$langs->trans(
'VAT').
'</td>';
2186 print
'<td class="right linecolpriceuht">'.$langs->trans(
'PriceUHT').
'</td>';
2187 print
'<td class="right linecolpriceuttc">'.$langs->trans(
'PriceUTTC').
'</td>';
2188 print
'<td class="right linecolqty">'.$langs->trans(
'Qty').
'</td>';
2189 if ($action !=
'editline') {
2190 print
'<td class="right linecolamountht">'.$langs->trans(
'AmountHT').
'</td>';
2191 print
'<td class="right linecolamountttc">'.$langs->trans(
'AmountTTC').
'</td>';
2203 print
'<td class="right"></td>';
2207 foreach (
$object->lines as &$line) {
2210 if ($action !=
'editline' || $line->id !=
GETPOSTINT(
'rowid')) {
2211 print
'<tr class="oddeven linetr" data-id="'.$line->id.
'">';
2214 print
'<td class="center linecollinenb">';
2219 print
'<td class="center linecoldate">'.dol_print_date($db->jdate($line->date),
'day').
'</td>';
2222 if (isModEnabled(
'project')) {
2223 print
'<td class="lineproject">';
2224 if ($line->fk_project > 0) {
2225 $projecttmp->id = $line->fk_project;
2226 $projecttmp->ref = $line->projet_ref;
2227 $projecttmp->title = $line->projet_title;
2228 print $projecttmp->getNomUrl(1);
2234 if (isModEnabled(
'accounting')) {
2235 require_once DOL_DOCUMENT_ROOT.
'/accountancy/class/accountingaccount.class.php';
2237 $resaccountingaccount = $accountingaccount->fetch(0, $line->type_fees_accountancy_code, 1);
2239 $titlealt .= $langs->trans(
"AccountancyCode").
': ';
2240 if ($resaccountingaccount > 0) {
2241 $titlealt .= $accountingaccount->account_number;
2243 $titlealt .= $langs->trans(
"NotFound");
2249 print
'<td class="center linecoltype" title="'.dol_escape_htmltag($titlealt).
'">';
2250 $labeltype = ($langs->trans(($line->type_fees_code)) == $line->type_fees_code ? $line->type_fees_libelle : $langs->trans($line->type_fees_code));
2256 print
'<td class="fk_c_exp_tax_cat linecoltaxcat">';
2257 $exp_tax_cat_label =
dol_getIdFromCode($db, $line->fk_c_exp_tax_cat,
'c_exp_tax_cat',
'rowid',
'label');
2258 print $langs->trans($exp_tax_cat_label);
2263 print
'<td class="left linecolcomment">'.dol_nl2br($line->comments).
'</td>';
2266 $senderissupplier = 0;
2267 $tooltiponprice =
'';
2268 $tooltiponpriceend =
'';
2270 $tooltiponprice = $langs->transcountry(
"TotalHT", $mysoc->country_code).
'='.
price($line->total_ht);
2271 $tooltiponprice .=
'<br>'.$langs->transcountry(
"TotalVAT", ($senderissupplier ?
$object->thirdparty->country_code : $mysoc->country_code)).
'='.
price($line->total_tva);
2272 if (is_object(
$object->thirdparty)) {
2273 if ($senderissupplier) {
2274 $seller =
$object->thirdparty;
2281 if ($mysoc->useLocalTax(1)) {
2282 if (($seller->country_code == $buyer->country_code) || $line->total_localtax1 || $seller->useLocalTax(1)) {
2283 $tooltiponprice .=
'<br>'.$langs->transcountry(
"TotalLT1", $seller->country_code).
'='.
price($line->total_localtax1);
2285 $tooltiponprice .=
'<br>'.$langs->transcountry(
"TotalLT1", $seller->country_code).
'=<span class="opacitymedium">'.$langs->trans($senderissupplier ?
"NotUsedForThisVendor" :
"NotUsedForThisCustomer").
'</span>';
2288 if ($mysoc->useLocalTax(2)) {
2289 if ((isset($seller->country_code) && isset($buyer->thirdparty->country_code) && $seller->country_code == $buyer->thirdparty->country_code) || $line->total_localtax2 || $seller->useLocalTax(2)) {
2290 $tooltiponprice .=
'<br>'.$langs->transcountry(
"TotalLT2", $seller->country_code).
'='.
price($line->total_localtax2);
2292 $tooltiponprice .=
'<br>'.$langs->transcountry(
"TotalLT2", $seller->country_code).
'=<span class="opacitymedium">'.$langs->trans($senderissupplier ?
"NotUsedForThisVendor" :
"NotUsedForThisCustomer").
'</span>';
2296 $tooltiponprice .=
'<br>'.$langs->transcountry(
"TotalTTC", $mysoc->country_code).
'='.
price($line->total_ttc);
2298 $tooltiponprice =
'<span class="classfortooltip" title="'.dol_escape_htmltag($tooltiponprice).
'">';
2299 $tooltiponpriceend =
'</span>';
2302 print
'<td class="right linecolvatrate">';
2303 print $tooltiponprice;
2304 print
vatrate($line->vatrate.($line->vat_src_code ?
' ('.$line->vat_src_code.
')' :
''), true);
2305 print $tooltiponpriceend;
2309 print
'<td class="right linecolunitht">';
2310 if (!empty($line->value_unit_ht)) {
2311 print
price($line->value_unit_ht);
2313 $tmpvat =
price2num(preg_replace(
'/\s*\(.*\)/',
'', $line->vatrate));
2314 $pricenettoshow =
price2num((
float) $line->value_unit / (1 + (
float) $tmpvat / 100),
'MU');
2315 print
price($pricenettoshow);
2319 print
'<td class="right linecolunitttc">'.price($line->value_unit).
'</td>';
2321 print
'<td class="right linecolqty">'.dol_escape_htmltag((
string) $line->qty).
'</td>';
2323 if ($action !=
'editline') {
2324 print
'<td class="right linecoltotalht">'.price($line->total_ht).
'</td>';
2325 print
'<td class="right linecoltotalttc">'.price($line->total_ttc).
'</td>';
2329 print
'<td class="center linecolpreview">';
2330 if ($line->fk_ecm_files > 0) {
2331 $modulepart =
'expensereport';
2332 $maxheightmini = 32;
2334 $result = $ecmfilesstatic->fetch($line->fk_ecm_files);
2336 $relativepath = preg_replace(
'/^([0-9]+\/)?expensereport\//',
'', $ecmfilesstatic->filepath);
2337 $fileinfo = pathinfo($ecmfilesstatic->filepath.
'/'.$ecmfilesstatic->filename);
2340 if (!
dol_is_file(
$conf->expensereport->dir_output.
'/'.$relativepath.
'/'.$minifile)) {
2344 $urlforhref =
getAdvancedPreviewUrl($modulepart, $relativepath.
'/'.$fileinfo[
'filename'].
'.'.strtolower($fileinfo[
'extension']), 1,
'&entity='.(empty(
$object->entity) ?
$conf->entity :
$object->entity));
2345 if (empty($urlforhref)) {
2346 $urlforhref = DOL_URL_ROOT.
'/viewimage.php?modulepart='.$modulepart.
'&entity='.(empty(
$object->entity) ?
$conf->entity :
$object->entity).
'&file='.urlencode($relativepath.$fileinfo[
'filename'].
'.'.strtolower($fileinfo[
'extension']));
2347 print
'<a href="'.$urlforhref.
'" class="aphoto" target="_blank" rel="noopener noreferrer">';
2349 print
'<a href="'.$urlforhref[
'url'].
'" class="'.$urlforhref[
'css'].
'" target="'.$urlforhref[
'target'].
'" mime="'.$urlforhref[
'mime'].
'">';
2351 print
'<img class="photo" height="'.$maxheightmini.
'" src="'.DOL_URL_ROOT.
'/viewimage.php?modulepart='.$modulepart.
'&entity='.(empty(
$object->entity) ?
$conf->entity :
$object->entity).
'&file='.urlencode($relativepath.
'/'.$minifile).
'" title="">';
2354 if (preg_match(
'/\.pdf$/i', $ecmfilesstatic->filename)) {
2355 $filepdf =
$conf->expensereport->dir_output.
'/'.$relativepath.
'/'.$ecmfilesstatic->filename;
2356 $fileimage =
$conf->expensereport->dir_output.
'/'.$relativepath.
'/'.$ecmfilesstatic->filename.
'_preview.png';
2357 $relativepathimage = $relativepath.
'/'.$ecmfilesstatic->filename.
'_preview.png';
2359 $pdfexists = file_exists($filepdf);
2362 if (!file_exists($fileimage) || (filemtime($fileimage) < filemtime($filepdf))) {
2364 include_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
2373 if ($pdfexists && !$error) {
2374 $heightforphotref = 70;
2375 if (!empty(
$conf->dol_optimize_smallscreen)) {
2376 $heightforphotref = 60;
2378 $urlforhref =
getAdvancedPreviewUrl($modulepart, $relativepath.
'/'.$fileinfo[
'filename'].
'.'.strtolower($fileinfo[
'extension']), 1,
'&entity='.(empty(
$object->entity) ?
$conf->entity :
$object->entity));
2379 print
'<a href="'.$urlforhref[
'url'].
'" class="'.$urlforhref[
'css'].
'" target="'.$urlforhref[
'target'].
'" mime="'.$urlforhref[
'mime'].
'">';
2381 if (file_exists($fileimage)) {
2382 print
'<img height="'.$heightforphotref.
'" class="photo photowithmargin photowithborder" src="'.DOL_URL_ROOT.
'/viewimage.php?modulepart=apercu'.$modulepart.
'&file='.urlencode($relativepathimage).
'">';
2385 print
img_mime($ecmfilesstatic->filename);
2395 print
'<td class="nowrap right linecolwarning">';
2396 print !empty($line->rule_warning_message) ?
img_warning(str_replace(
'\n',
' - ', html_entity_decode($line->rule_warning_message))) :
' ';
2401 print
'<td class="nowrap right linecolaction">';
2403 print
'<a class="editfielda reposition paddingrightonly" href="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&action=editline&token='.
newToken().
'&rowid='.$line->rowid.
'">';
2405 print
'</a> ';
2406 print
'<a class="paddingrightonly" href="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&action=delete_line&token='.
newToken().
'&rowid='.$line->rowid.
'">';
2416 if ($action ==
'editline' && $line->id ==
GETPOSTINT(
'rowid')) {
2419 if (isModEnabled(
'project')) {
2426 print
'<!-- line of expense report -->'.
"\n";
2427 print
'<tr class="tredited">';
2429 print
'<td class="center">';
2433 print
'<td colspan="'.($colspan - 1).
'" class="liste_titre"> ';
2434 print
'<a href="" class="commonlink auploadnewfilenow reposition">'.$langs->trans(
"UploadANewFileNow");
2435 print
img_picto($langs->trans(
"UploadANewFileNow"),
'chevron-down',
'', 0, 0, 0,
'',
'marginleftonly');
2438 print
' - <a href="" class="commonlink aattachtodoc reposition">'.$langs->trans(
"AttachTheNewLineToTheDocument");
2439 print
img_picto($langs->trans(
"AttachTheNewLineToTheDocument"),
'chevron-down',
'', 0, 0, 0,
'',
'marginleftonly');
2443 print
'<!-- Code to open/close section to submit or link files in edit mode -->'.
"\n";
2444 print
'<script type="text/javascript">'.
"\n";
2445 print
'$(document).ready(function() {
2446 $( ".auploadnewfilenow" ).click(function() {
2447 jQuery(".truploadnewfilenow").toggle();
2448 jQuery(".trattachnewfilenow").hide();
2451 $( ".aattachtodoc" ).click(function() {
2452 jQuery(".trattachnewfilenow").toggle();
2453 jQuery(".truploadnewfilenow").hide();
2456 if (is_array(
GETPOST(
'attachfile',
'array')) && count(
GETPOST(
'attachfile',
'array'))) {
2457 print
'jQuery(".trattachnewfilenow").toggle();'.
"\n";
2460 jQuery("form[name=\"expensereport\"]").submit(function() {
2461 if (jQuery(".truploadnewfilenow").is(":hidden")) {
2462 jQuery("input[name=\"sendit\"]").val("");
2469 print
'</script>'.
"\n";
2472 $filenamelinked =
'';
2473 if ($line->fk_ecm_files > 0) {
2474 $result = $ecmfilesstatic->fetch($line->fk_ecm_files);
2476 $filenamelinked = $ecmfilesstatic->filename;
2480 $tredited =
'tredited';
2481 include DOL_DOCUMENT_ROOT.
'/expensereport/tpl/expensereport_addfile.tpl.php';
2482 include DOL_DOCUMENT_ROOT.
'/expensereport/tpl/expensereport_linktofile.tpl.php';
2484 print
'<tr class="oddeven tredited">';
2489 print
'<td class="center">';
2490 print $form->selectDate($line->date,
'date');
2494 if (isModEnabled(
'project')) {
2495 print
'<td class="nowraponall">';
2496 print $formproject->select_projects(-1, (
string) $line->fk_project,
'fk_project', 0, 0, $projectRequired ? 0 : 1, 1, 0, 0, 0,
'', 1, 0,
'maxwidth300');
2501 print
'<td class="center">';
2502 print $formexpensereport->selectTypeExpenseReport($line->fk_c_type_fees,
'fk_c_type_fees');
2506 print
'<td class="fk_c_exp_tax_cat">';
2507 $params = array(
'fk_expense' =>
$object->id,
'fk_expense_det' => $line->id,
'date' => $line->date);
2508 print $form->selectExpenseCategories((
string) $line->fk_c_exp_tax_cat,
'fk_c_exp_tax_cat', 1, array(),
'fk_c_type_fees', (
int) $userauthor->default_c_exp_tax_cat, $params);
2514 print
'<textarea name="comments" class="flat_ndf centpercent">'.dol_escape_htmltag($line->comments, 0, 1).
'</textarea>';
2518 $selectedvat =
price2num($line->vatrate).(!empty($line->vat_src_code) ?
' ('.$line->vat_src_code.
')' :
'');
2519 print
'<td class="right">';
2521 print $form->load_tva(
'vatrate', (GETPOSTISSET(
"vatrate") ?
GETPOST(
"vatrate") : $selectedvat), null, null, 0, 0,
'', false, 1, 2);
2525 print
'<td class="right">';
2526 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.
' />';
2530 print
'<td class="right">';
2531 print
'<input type="text" min="0" class="right maxwidth50" id="value_unit" name="value_unit" value="'.dol_escape_htmltag(
price2num($line->value_unit)).
'" />';
2535 print
'<td class="right">';
2536 print
'<input type="text" min="0" class="input_qty right maxwidth50" name="qty" value="'.dol_escape_htmltag((
string) $line->qty).
'" />';
2543 print
'<td class="center">';
2547 print
'<td class="center">';
2551 print
'<input type="hidden" name="rowid" value="'.$line->rowid.
'">';
2552 print $form->buttonsSaveCancel(
'Save',
'Cancel', array(),
false,
'small');
2568 if (isModEnabled(
'project')) {
2571 if ($action !=
'editline') {
2575 $nbFiles = $nbLinks = 0;
2576 $arrayoffiles = array();
2578 require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
2579 require_once DOL_DOCUMENT_ROOT.
'/core/lib/images.lib.php';
2580 require_once DOL_DOCUMENT_ROOT.
'/core/class/link.class.php';
2583 $nbFiles = count($arrayoffiles);
2588 print
'<tr class="liste_titre">';
2589 print
'<td colspan="'.$colspan.
'" class="liste_titre expensereportautoload">';
2590 print
'<a href="" class="commonlink auploadnewfilenow reposition">'.$langs->trans(
"UploadANewFileNow");
2591 print
img_picto($langs->trans(
"UploadANewFileNow"),
'chevron-down',
'', 0, 0, 0,
'',
'marginleftonly');
2594 print
' - <a href="" class="commonlink aattachtodoc reposition">'.$langs->trans(
"AttachTheNewLineToTheDocument");
2595 print
img_picto($langs->trans(
"AttachTheNewLineToTheDocument"),
'chevron-down',
'', 0, 0, 0,
'',
'marginleftonly');
2599 print
'<!-- Code to open/close section to submit or link files in the form to add new line -->'.
"\n";
2600 print
'<script type="text/javascript">'.
"\n";
2601 print
'$(document).ready(function() {
2602 $( ".auploadnewfilenow" ).click(function() {
2603 console.log("We click on toggle of auploadnewfilenow");
2604 jQuery(".truploadnewfilenow").toggle();
2605 jQuery(".trattachnewfilenow").hide();
2606 if (jQuery(".truploadnewfilenow").is(":hidden")) {
2607 jQuery("input[name=\"sendit\"]").prop("name", "senditdisabled");
2609 jQuery("input[name=\"senditdisabled\"]").prop("name", "sendit");
2611 // TODO Switch css fa-chevron-dow and add fa-chevron-up
2614 $( ".aattachtodoc" ).click(function() {
2615 console.log("We click on toggle of aattachtodoc");
2616 jQuery(".trattachnewfilenow").toggle();
2617 jQuery(".truploadnewfilenow").hide();
2618 // TODO Switch css fa-chevron-dow and add fa-chevron-up
2621 if (is_array(
GETPOST(
'attachfile',
'array')) && count(
GETPOST(
'attachfile',
'array')) && $action !=
'updateline') {
2622 print
'jQuery(".trattachnewfilenow").show();'.
"\n";
2625 jQuery("form[name=\"expensereport\"]").submit(function() {
2626 if (jQuery(".truploadnewfilenow").is(":hidden")) {
2627 /* 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. */
2628 jQuery("input[name=\"sendit\"]").val("");
2629 jQuery("input[name=\"sendit\"]").prop("name", "senditdisabled");
2631 jQuery("input[name=\"senditdisabled\"]").prop("name", "sendit");
2638 print
'</script>'.
"\n";
2642 include DOL_DOCUMENT_ROOT.
'/expensereport/tpl/expensereport_linktofile.tpl.php';
2643 include DOL_DOCUMENT_ROOT.
'/expensereport/tpl/expensereport_addfile.tpl.php';
2645 print
'<tr class="liste_titre expensereportcreate">';
2647 print
'<td class="center expensereportcreatedate">'.$langs->trans(
'Date').
'</td>';
2648 if (isModEnabled(
'project')) {
2649 print
'<td class="minwidth100imp">'.$form->textwithpicto($langs->trans(
'Project'), $langs->trans(
"ClosedProjectsAreHidden")).
'</td>';
2651 print
'<td class="center expensereportcreatetype">'.$langs->trans(
'Type').
'</td>';
2653 print
'<td>'.$langs->trans(
'CarCategory').
'</td>';
2655 print
'<td class="expensereportcreatedescription">'.$langs->trans(
'Description').
'</td>';
2656 print
'<td class="right expensereportcreatevat">'.$langs->trans(
'VAT').
'</td>';
2657 print
'<td class="right expensereportcreatepriceuth">'.$langs->trans(
'PriceUHT').
'</td>';
2658 print
'<td class="right expensereportcreatepricettc">'.$langs->trans(
'PriceUTTC').
'</td>';
2659 print
'<td class="right expensereportcreateqty">'.$langs->trans(
'Qty').
'</td>';
2666 print
'<tr class="oddeven nohover">';
2672 print
'<td class="center inputdate">';
2673 print $form->selectDate(!empty($date) ? $date : -1,
'date', 0, 0, 0,
'', 1, 1);
2677 if (isModEnabled(
'project')) {
2678 print
'<td class="inputproject">';
2679 $formproject->select_projects(-1, !empty($fk_project) ? (
string) $fk_project :
'0',
'fk_project', 0, 0, $projectRequired ? 0 : 1, -1, 0, 0, 0,
'', 0, 0,
'maxwidth300');
2684 print
'<td class="center inputtype">';
2685 print $formexpensereport->selectTypeExpenseReport(!empty($fk_c_type_fees) ? $fk_c_type_fees :
"",
'fk_c_type_fees', 1);
2689 print
'<td class="fk_c_exp_tax_cat">';
2690 $params = array(
'fk_expense' =>
$object->id);
2691 print $form->selectExpenseCategories(
'',
'fk_c_exp_tax_cat', 1, array(),
'fk_c_type_fees', $userauthor->default_c_exp_tax_cat, $params, 0);
2696 print
'<td class="inputcomment">';
2697 print
'<textarea class="flat_ndf centpercent" name="comments" rows="'.ROWS_2.
'">'.
dol_escape_htmltag(!empty($comments) ? $comments :
"", 0, 1).
'</textarea>';
2701 print
'<td class="right inputvat">';
2705 $conf->global->MAIN_VAT_DEFAULT_IF_AUTODETECT_FAILS =
'none';
2708 print $form->load_tva(
'vatrate', (!empty($vatrate) ? $vatrate : $defaultvat), null, null, 0, 0,
'', false, 1);
2712 print
'<td class="right inputpricenet">';
2713 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 :
"")).
'"'.$taxlessUnitPriceDisabled.
' />';
2717 print
'<td class="right inputtax">';
2718 print
'<input type="text" class="right maxwidth50" id="value_unit" name="value_unit" value="'.dol_escape_htmltag((!empty($value_unit) ? $value_unit :
"")).
'">';
2722 print
'<td class="right inputqty">';
2723 print
'<input type="text" min="0" class=" input_qty right maxwidth50" name="qty" value="'.dol_escape_htmltag(!empty($qty) ? $qty : 1).
'">';
2729 if ($action !=
'editline') {
2730 print
'<td class="right"></td>';
2731 print
'<td class="right"></td>';
2735 print
'<td class="center inputbuttons">';
2736 print $form->buttonsSaveCancel(
"Add",
'', array(),
true,
'reposition');
2747 /* JQuery for product free or predefined select */
2748 jQuery(document).ready(function() {
2749 jQuery("#value_unit_ht").keyup(function(event) {
2750 console.log(event.which); // discard event tag and arrows
2751 if (event.which != 9 && (event.which < 37 ||event.which > 40) && jQuery("#value_unit_ht").val() != "") {
2752 jQuery("#value_unit").val("");
2755 jQuery("#value_unit").keyup(function(event) {
2756 console.log(event.which); // discard event tag and arrows
2757 if (event.which != 9 && (event.which < 37 || event.which > 40) && jQuery("#value_unit").val() != "") {
2758 jQuery("#value_unit_ht").val("");
2766 /* unit price coef calculation */
2767 jQuery(".input_qty, #fk_c_type_fees, #select_fk_c_exp_tax_cat, #vatrate ").change(function(event) {
2768 console.log("We change a parameter");
2770 let type_fee = jQuery("#fk_c_type_fees").find(":selected").val();
2771 let tax_cat = jQuery("#select_fk_c_exp_tax_cat").find(":selected").val();
2772 let tva = jQuery("#vatrate").find(":selected").val();
2773 let qty = jQuery(".input_qty").val();
2775 let path = "'.DOL_URL_ROOT.
'/expensereport/ajax/ajaxik.php";
2776 path += "?fk_c_exp_tax_cat="+tax_cat;
2777 path += "&fk_expense="+'.((int)
$object->id).
';
2778 path += "&vatrate="+tva;
2779 path += "&qty="+qty;
2781 if (type_fee == 4) { // frais_kilométriques
2782 if (tax_cat == "" || parseInt(tax_cat) <= 0){
2790 success: function(response) {
2791 if (response.response_status == "success"){';
2795 jQuery("#value_unit").val(parseFloat(response.data) * (100 + parseFloat(tva)) / 100);
2796 jQuery("#value_unit").trigger("change");
2800 jQuery("#value_unit_ht").val(response.data);
2801 jQuery("#value_unit_ht").trigger("change");
2802 jQuery("#value_unit").val("");
2807 } else if(response.response_status == "error" && response.errorMessage != undefined && response.errorMessage.length > 0 ) {
2808 console.log("We get an error result");
2809 $.jnotify(response.errorMessage, "error", {timeout: 0, type: "error"},{ remove: function (){} } );
2815 /*console.log(event.which); // discard event tag and arrows
2816 if (event.which != 9 && (event.which < 37 || event.which > 40) && jQuery("#value_unit").val() != "") {
2817 jQuery("#value_unit_ht").val("");
2837 print
'Record not found';
2848print
'<div class="tabsAction">';
2850if ($action !=
'create' && $action !=
'edit' && $action !=
'editline') {
2855 if (empty($user->socid)) {
2858 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>';
2870 if (in_array(
$object->fk_user_author, $childids) || $user->hasRight(
'expensereport',
'writeall_advance')) {
2872 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>';
2875 if (count(
$object->lines) > 0) {
2876 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>';
2887 if ($user->id ==
$object->fk_user_author || $user->id ==
$object->fk_user_valid) {
2889 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>';
2894 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>';
2899 if ($user->id ==
$object->fk_user_author || $user->id ==
$object->fk_user_valid) {
2901 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>';
2911 if (in_array(
$object->fk_user_author, $childids)) {
2913 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>';
2921 print
'<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER[
"PHP_SELF"].
'?action=validate&token='.
newToken().
'&id='.
$object->id.
'">'.$langs->trans(
'Approve').
'</a></div>';
2923 print
'<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER[
"PHP_SELF"].
'?action=refuse&token='.
newToken().
'&id='.
$object->id.
'">'.$langs->trans(
'Deny').
'</a></div>';
2926 if ($user->id ==
$object->fk_user_author || $user->id ==
$object->fk_user_valid) {
2928 print
'<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER[
"PHP_SELF"].
'?action=cancel&id='.
$object->id.
'">'.$langs->trans(
"Cancel").
'</a></div>';
2937 print
'<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER[
"PHP_SELF"].
'?action=refuse&token='.
newToken().
'&id='.
$object->id.
'">'.$langs->trans(
'Deny').
'</a></div>';
2943 if ($remaintopay == 0) {
2944 print
'<div class="inline-block divButAction"><span class="butActionRefused classfortooltip" title="'.$langs->trans(
"DisabledBecauseRemainderToPayIsZero").
'">'.$langs->trans(
'DoPayment').
'</span></div>';
2946 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>';
2954 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>";
2960 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>';
2969 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>';
2974 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>';
2978 if ($user->hasRight(
'expensereport',
'creer')) {
2979 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>';
2985 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>';
2988 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>';
2991 $parameters = array();
2992 $reshook = $hookmanager->executeHooks(
'addMoreActionsButtons', $parameters,
$object, $action);
2999if (
GETPOST(
'modelselected',
'alpha')) {
3000 $action =
'presend';
3003if ($action !=
'presend') {
3008 print
'<div class="fichecenter"><div class="fichehalfleft">';
3009 print
'<a name="builddoc"></a>';
3011 if ($user->hasRight(
'expensereport',
'creer') && $action !=
'create' && $action !=
'edit') {
3014 $urlsource = $_SERVER[
"PHP_SELF"].
"?id=".
$object->id;
3015 $genallowed = $user->hasRight(
'expensereport',
'creer');
3016 $delallowed = $user->hasRight(
'expensereport',
'creer');
3018 print $formfile->showdocuments(
'expensereport', $filename, $filedir, $urlsource, $genallowed, $delallowed);
3019 $somethingshown = $formfile->numoffiles;
3035 print
'</div><div class="fichehalfright">';
3037 include_once DOL_DOCUMENT_ROOT.
'/core/class/html.formactions.class.php';
3039 $somethingshown = $formactions->showactions(
$object,
'expensereport', 0);
3041 print
'</div></div>';
3045$modelmail =
'expensereport_send';
3046$defaulttopic =
'SendExpenseReportRef';
3047$diroutput =
$conf->expensereport->dir_output;
3048$trackid =
'exp'.$object->id;
3050include DOL_DOCUMENT_ROOT.
'/core/tpl/card_presend.tpl.php';
$id
Support class for third parties, contacts, members, users or resources.
if( $user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $object
global $dolibarr_main_url_root
llxFooter($comment='', $zone='private', $disabledoutputofmessages=0)
Empty footer.
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader($head='', $title='', $help_url='', $target='', $disablejs=0, $disablehead=0, $arrayofjs='', $arrayofcss='', $morequerystring='', $morecssonbody='', $replacemainareaby='', $disablenofollow=0, $disablenoindex=0)
Empty header.
Class to manage bank accounts.
Class to manage accounting accounts.
Class to manage accounting journals.
Class to send emails (with attachments or not) Usage: $mailfile = new CMailFile($subject,...
Class to manage a WYSIWYG editor.
Class to manage ECM files.
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.
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($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_mktime($hour, $minute, $second, $month, $day, $year, $gm='auto', $check=1)
Return a timestamp date built from detailed information (by default a local PHP server timestamp) Rep...
dol_getIdFromCode($db, $key, $tablename, $fieldkey='code', $fieldid='id', $entityfilter=0, $filters='', $useCache=true)
Return an id or code from a code or id.
load_fiche_titre($title, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0, $attop=0)
Set event messages in dol_events session object.
vatrate($rate, $addpercent=false, $info_bits=0, $usestarfornpr=0, $html=0)
Return a string with VAT rate label formatted for view output Used into pdf and HTML pages.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2, $allowothertags=array())
Show picto whatever it's its name (generic function)
img_warning($titlealt='default', $moreatt='', $morecss='pictowarning')
Show warning logo.
img_delete($titlealt='default', $other='class="pictodelete"', $morecss='')
Show delete logo.
GETPOSTINT($paramname, $method=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='', $dragdropfile=0, $morecssdiv='')
Show tabs of a record.
price2num($amount, $rounding='', $option=0)
Function that return a number with universal decimal format (decimal separator is '.
dol_get_fiche_end($notab=0)
Return tab footer of a card.
dol_eval($s, $returnvalue=1, $hideerrors=1, $onlysimplestring='1')
Replace eval function to add more security.
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_now($mode='auto')
Return date for now.
img_mime($file, $titlealt='', $morecss='')
Show MIME img of a file.
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).
newToken()
Return the value of token currently saved into session with name 'newtoken'.
getImageFileNameForSize($file, $extName, $extImgTarget='')
Return the filename of file to get the thumbs.
get_date_range($date_start, $date_end, $format='', $outputlangs=null, $withparenthesis=1)
Format output for start and end date.
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_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...
isValidEmail($address, $acceptsupervisorkey=0, $acceptuserkey=0)
Return true if email syntax is ok.
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.
img_edit($titlealt='default', $float=0, $other='')
Show logo edit/modify fiche.
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $noescapetags='', $escapeonlyhtmltags=0, $cleanalsojavascript=0)
Returns text escaped for inclusion in HTML alt or title or value tags, or into values of HTML input f...
image_format_supported($file, $acceptsvg=0)
Return if a filename is file name of a supported image format.
global $conf
The following vars must be defined: $type2label $form $conf, $lang, The following vars may also be de...
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.