32require
'../main.inc.php';
33require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formexpensereport.class.php';
34require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formfile.class.php';
35require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formmail.class.php';
36require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formprojet.class.php';
37require_once DOL_DOCUMENT_ROOT.
'/core/class/CMailFile.class.php';
38require_once DOL_DOCUMENT_ROOT.
'/projet/class/project.class.php';
39require_once DOL_DOCUMENT_ROOT.
'/ecm/class/ecmfiles.class.php';
40require_once DOL_DOCUMENT_ROOT.
'/compta/bank/class/account.class.php';
41require_once DOL_DOCUMENT_ROOT.
'/core/lib/expensereport.lib.php';
42require_once DOL_DOCUMENT_ROOT.
'/core/lib/price.lib.php';
43require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
44require_once DOL_DOCUMENT_ROOT.
'/core/lib/images.lib.php';
45require_once DOL_DOCUMENT_ROOT.
'/core/modules/expensereport/modules_expensereport.php';
46require_once DOL_DOCUMENT_ROOT.
'/expensereport/class/expensereport.class.php';
47require_once DOL_DOCUMENT_ROOT.
'/expensereport/class/paymentexpensereport.class.php';
48require_once DOL_DOCUMENT_ROOT.
'/core/class/doleditor.class.php';
49require_once DOL_DOCUMENT_ROOT.
'/core/class/extrafields.class.php';
51 require_once DOL_DOCUMENT_ROOT.
'/accountancy/class/accountingjournal.class.php';
66$langs->loadLangs(array(
"trips",
"bills",
"mails"));
68$action =
GETPOST(
'action',
'aZ09');
69$cancel =
GETPOST(
'cancel',
'alpha');
70$confirm =
GETPOST(
'confirm',
'alpha');
71$backtopage =
GETPOST(
'backtopage',
'alpha');
78$vatrate =
GETPOST(
'vatrate',
'alpha');
80$comments =
GETPOST(
'comments',
'restricthtml');
85$childids = $user->getAllChildIds(1);
88 if (empty($date_start)) {
92 if (empty($date_end)) {
99$rootfordata = DOL_DATA_ROOT;
100$rootforuser = DOL_DATA_ROOT;
102if (
isModEnabled(
'multicompany') && !empty($conf->entity) && $conf->entity > 1) {
103 $rootfordata .=
'/'.$conf->entity;
105$conf->expensereport->dir_output = $rootfordata.
'/expensereport';
109$urlwithroot = $urlwithouturlroot.DOL_URL_ROOT;
122$extrafields->fetch_name_optionals_label(
$object->table_element);
125include DOL_DOCUMENT_ROOT.
'/core/actions_fetchobject.inc.php';
128$hookmanager->initHooks(array(
'expensereportcard',
'globalcard'));
130$permissionnote = $user->hasRight(
'expensereport',
'creer');
131$permissiondellink = $user->hasRight(
'expensereport',
'creer');
132$permissiontoadd = $user->hasRight(
'expensereport',
'creer');
133$permissiontoeditextra = $permissiontoadd;
134if (
GETPOST(
'attribute',
'aZ09') && isset($extrafields->attributes[
$object->table_element][
'perms'][
GETPOST(
'attribute',
'aZ09')])) {
136 $permissiontoeditextra =
dol_eval((
string) $extrafields->attributes[
$object->table_element][
'perms'][
GETPOST(
'attribute',
'aZ09')]);
147 if ($user->hasRight(
'expensereport',
'readall')) {
150 if ($user->hasRight(
'expensereport',
'lire') && in_array(
$object->fk_user_author, $childids)) {
159if ($user->hasRight(
'expensereport',
'supprimer')) {
168 $socid = $user->socid;
172$permissiontoadd = $user->hasRight(
'expensereport',
'creer');
185$parameters = array(
'socid' => $socid);
186$reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
191if (empty($reshook)) {
192 $backurlforlist = DOL_URL_ROOT.
'/expensereport/list.php';
194 if (empty($backtopage) || ($cancel && empty($id))) {
195 if (empty($backtopage) || ($cancel && strpos($backtopage,
'__ID__'))) {
196 if (empty($id) && (($action !=
'add' && $action !=
'create') || $cancel)) {
197 $backtopage = $backurlforlist;
199 $backtopage = DOL_URL_ROOT.
'/expensereport/card.php?id='.((!empty($id) &&
$id > 0) ? $id :
'__ID__');
205 if (!empty($backtopageforcancel)) {
206 header(
"Location: ".$backtopageforcancel);
208 } elseif (!empty($backtopage)) {
209 header(
"Location: ".$backtopage);
223 $fk_c_type_fees = -1;
226 include DOL_DOCUMENT_ROOT.
'/core/actions_linkedfiles.inc.php';
228 if (!empty(
GETPOST(
'sendit',
'alpha'))) {
229 if ($action ==
'updateline') {
230 $action =
'editline';
236 include DOL_DOCUMENT_ROOT.
'/core/actions_setnotes.inc.php';
238 include DOL_DOCUMENT_ROOT.
'/core/actions_dellink.inc.php';
240 include DOL_DOCUMENT_ROOT.
'/core/actions_lineupdown.inc.php';
243 if ($action ==
'confirm_clone' && $confirm ==
'yes' && $permissiontoadd) {
253 header(
"Location: ".$_SERVER[
'PHP_SELF'].
'?id='.$result);
264 if ($action ==
'confirm_delete' &&
GETPOST(
"confirm",
'alpha') ==
"yes" && $id > 0 && $candelete) {
267 $result =
$object->delete($user);
269 header(
"Location: index.php");
276 if ($action ==
'add' && $permissiontoadd) {
279 $object->date_debut = $date_start;
283 if (!(
$object->fk_user_author > 0)) {
284 $object->fk_user_author = $user->id;
288 if ((!
getDolGlobalString(
'MAIN_USE_ADVANCED_PERMS') && !$user->hasRight(
'expensereport',
'creer'))
289 || (
getDolGlobalString(
'MAIN_USE_ADVANCED_PERMS') && !$user->hasRight(
'expensereport',
'creer') && !$user->hasRight(
'expensereport',
'writeall_advance'))) {
294 if (!
getDolGlobalString(
'MAIN_USE_ADVANCED_PERMS') || !$user->hasRight(
'expensereport',
'writeall_advance')) {
295 if (!in_array(
$object->fk_user_author, $childids)) {
302 $fuser =
new User($db);
303 $fuser->fetch(
$object->fk_user_author);
312 $ret = $extrafields->setOptionalsFromPost(
null, $object);
321 if ($overlappingExpenseReportID > 0) {
323 setEventMessages($langs->trans(
"ErrorDoubleDeclaration").
' <a href="'.$_SERVER[
'PHP_SELF'].
'?id='.$overlappingExpenseReportID.
'">'. $langs->trans(
'ShowTrip').
'</a>',
null,
'errors');
338 header(
"Location: ".$_SERVER[
"PHP_SELF"].
"?id=".$id);
348 if (($action ==
'update' || $action ==
'updateFromRefuse') && $permissiontoadd) {
352 $object->date_debut = $date_start;
362 $object->fk_user_modif = $user->id;
364 $result =
$object->update($user);
366 header(
"Location: ".$_SERVER[
"PHP_SELF"].
"?id=".
GETPOSTINT(
'id'));
373 if ($action ==
'update_extras' && $permissiontoeditextra) {
376 $attribute_name =
GETPOST(
'attribute',
'aZ09');
379 $ret = $extrafields->setOptionalsFromPost(
null, $object, $attribute_name);
385 $result =
$object->updateExtraField($attribute_name,
'EXPENSEREPORT_MODIFY');
393 $action =
'edit_extras';
397 if ($action ==
"confirm_validate" &&
GETPOST(
"confirm",
'alpha') ==
"yes" && $id > 0 && $permissiontoadd) {
403 $result =
$object->setValidate($user);
408 $outputlangs = $langs;
411 $newlang =
GETPOST(
'lang_id',
'aZ09');
414 $tmpuser =
new User($db);
415 $tmpuser->fetch(
$object->fk_user_author);
416 $newlang = $tmpuser->lang;
418 if (!empty($newlang)) {
420 $outputlangs->setDefaultLang($newlang);
425 $object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref);
432 if (!$error && $result > 0 &&
$object->fk_user_validator > 0) {
433 $langs->load(
"mails");
436 $destinataire =
new User($db);
437 $destinataire->fetch(
$object->fk_user_validator);
438 $emailTo = $destinataire->email;
441 $expediteur =
new User($db);
442 $expediteur->fetch(
$object->fk_user_author);
445 if ($emailTo && $emailFrom) {
456 $subject = $societeName.
" - ".$langs->transnoentities(
"ExpenseReportWaitingForApproval");
459 $link = $urlwithroot.
'/expensereport/card.php?id='.
$object->id;
460 $link =
'<a href="'.$link.
'">'.$link.
'</a>';
461 $message = $langs->transnoentities(
"ExpenseReportWaitingForApprovalMessage", $expediteur->getFullName($langs),
get_date_range(
$object->date_debut,
$object->date_fin,
'', $langs), $link);
476 $mailfile =
new CMailFile($subject, $emailTo, $emailFrom, $message, $filedir, $mimetype, $filename,
'',
'', 0, -1);
478 if (empty($mailfile->error)) {
480 $result = $mailfile->sendfile();
482 $mesg = $langs->trans(
'MailSuccessfulySent', $mailfile->getValidAddress($emailFrom, 2), $mailfile->getValidAddress($emailTo, 2));
485 $langs->load(
"other");
486 if (!empty($mailfile->error) || !empty($mailfile->errors)) {
489 if (!empty($mailfile->error)) {
490 $mesg .=
'<br>' . $mailfile->error;
492 if (!empty($mailfile->errors) && is_array($mailfile->errors)) {
493 $mesg .=
'<br>' . implode(
'<br>', $mailfile->errors);
497 setEventMessages(
'No mail sent. Feature is disabled by option MAIN_DISABLE_ALL_MAILS',
null,
'warnings');
505 setEventMessages($langs->trans(
"NoEmailSentBadSenderOrRecipientEmail"),
null,
'warnings');
512 header(
"Location: ".$_SERVER[
"PHP_SELF"].
"?id=".$id);
519 if ($action ==
"confirm_save_from_refuse" &&
GETPOST(
"confirm",
'alpha') ==
"yes" && $id > 0 && $permissiontoadd) {
522 $result =
$object->set_save_from_refuse($user);
527 $outputlangs = $langs;
530 $newlang =
GETPOST(
'lang_id',
'aZ09');
533 $tmpuser =
new User($db);
534 $tmpuser->fetch(
$object->fk_user_author);
535 $newlang = $tmpuser->lang;
537 if (!empty($newlang)) {
539 $outputlangs->setDefaultLang($newlang);
544 $object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref);
552 $destinataire =
new User($db);
553 $destinataire->fetch(
$object->fk_user_validator);
554 $emailTo = $destinataire->email;
557 $expediteur =
new User($db);
558 $expediteur->fetch(
$object->fk_user_author);
561 if ($emailFrom && $emailTo) {
572 $subject = $societeName.
" - ".$langs->transnoentities(
"ExpenseReportWaitingForReApproval");
575 $link = $urlwithroot.
'/expensereport/card.php?id='.
$object->id;
576 $link =
'<a href="'.$link.
'">'.$link.
'</a>';
578 $message .=
'<br>'.$langs->transnoentities(
"ExpenseReportWaitingForReApprovalMessage2", $link);
597 $mailfile =
new CMailFile($subject, $emailTo, $emailFrom, $message, $filedir, $mimetype, $filename,
'',
'', 0, -1);
599 if (empty($mailfile->error)) {
601 $result = $mailfile->sendfile();
603 $mesg = $langs->trans(
'MailSuccessfulySent', $mailfile->getValidAddress($emailFrom, 2), $mailfile->getValidAddress($emailTo, 2));
605 header(
"Location: ".$_SERVER[
"PHP_SELF"].
"?id=".$id);
608 $langs->load(
"other");
609 if ($mailfile->error) {
611 $mesg .= $langs->trans(
'ErrorFailedToSendMail', $emailFrom, $emailTo);
612 $mesg .=
'<br>'.$mailfile->error;
615 setEventMessages(
'No mail sent. Feature is disabled by option MAIN_DISABLE_ALL_MAILS',
null,
'warnings');
623 setEventMessages($langs->trans(
"NoEmailSentBadSenderOrRecipientEmail"),
null,
'warnings');
632 if ($action ==
"confirm_approve" &&
GETPOST(
"confirm",
'alpha') ==
"yes" && $id > 0 && $user->hasRight(
'expensereport',
'approve')) {
636 $result =
$object->setApproved($user);
641 $outputlangs = $langs;
644 $newlang =
GETPOST(
'lang_id',
'aZ09');
647 $tmpuser =
new User($db);
648 $tmpuser->fetch(
$object->fk_user_author);
649 $newlang = $tmpuser->lang;
651 if (!empty($newlang)) {
653 $outputlangs->setDefaultLang($newlang);
658 $object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref);
666 $destinataire =
new User($db);
667 $destinataire->fetch(
$object->fk_user_author);
668 $emailTo = $destinataire->email;
672 if (empty($emailTo)) {
677 $expediteur =
new User($db);
678 $expediteur->fetch(
$object->fk_user_approve > 0 ?
$object->fk_user_approve :
$object->fk_user_validator);
681 if ($emailFrom && $emailTo) {
692 $subject = $societeName.
" - ".$langs->transnoentities(
"ExpenseReportApproved");
695 $link = $urlwithroot.
'/expensereport/card.php?id='.
$object->id;
696 $link =
'<a href="'.$link.
'">'.$link.
'</a>';
697 $message = $langs->transnoentities(
"ExpenseReportApprovedMessage",
$object->ref, $destinataire->getFullName($langs), $expediteur->getFullName($langs), $link);
714 $mailfile =
new CMailFile($subject, $emailTo, $emailFrom, $message, $filedir, $mimetype, $filename, $emailCC,
'', 0, -1);
716 if (empty($mailfile->error)) {
718 $result = $mailfile->sendfile();
720 $mesg = $langs->trans(
'MailSuccessfulySent', $mailfile->getValidAddress($emailFrom, 2), $mailfile->getValidAddress($emailTo, 2));
722 header(
"Location: ".$_SERVER[
"PHP_SELF"].
"?id=".$id);
725 $langs->load(
"other");
726 if ($mailfile->error) {
728 $mesg .= $langs->trans(
'ErrorFailedToSendMail', $emailFrom, $emailTo);
729 $mesg .=
'<br>'.$mailfile->error;
732 setEventMessages(
'No mail sent. Feature is disabled by option MAIN_DISABLE_ALL_MAILS',
null,
'warnings');
740 setEventMessages($langs->trans(
"NoEmailSentBadSenderOrRecipientEmail"),
null,
'warnings');
749 if ($action ==
"confirm_refuse" &&
GETPOST(
'confirm',
'alpha') ==
"yes" && $id > 0 && $user->hasRight(
'expensereport',
'approve')) {
753 $detailRefuse =
GETPOST(
'detail_refuse',
'alpha');
754 $result =
$object->setDeny($user, $detailRefuse);
759 $outputlangs = $langs;
762 $newlang =
GETPOST(
'lang_id',
'aZ09');
765 $tmpuser =
new User($db);
766 $tmpuser->fetch(
$object->fk_user_author);
767 $newlang = $tmpuser->lang;
769 if (!empty($newlang)) {
771 $outputlangs->setDefaultLang($newlang);
776 $object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref);
784 $destinataire =
new User($db);
785 $destinataire->fetch(
$object->fk_user_author);
786 $emailTo = $destinataire->email;
789 $expediteur =
new User($db);
790 $expediteur->fetch(
$object->fk_user_refuse);
793 if ($emailFrom && $emailTo) {
804 $subject = $societeName.
" - ".$langs->transnoentities(
"ExpenseReportRefused");
807 $link = $urlwithroot.
'/expensereport/card.php?id='.
$object->id;
808 $link =
'<a href="'.$link.
'">'.$link.
'</a>';
809 $message = $langs->transnoentities(
"ExpenseReportRefusedMessage",
$object->ref, $destinataire->getFullName($langs), $expediteur->getFullName($langs), $detailRefuse, $link);
827 $mailfile =
new CMailFile($subject, $emailTo, $emailFrom, $message, $filedir, $mimetype, $filename,
'',
'', 0, -1);
829 if (empty($mailfile->error)) {
831 $result = $mailfile->sendfile();
833 $mesg = $langs->trans(
'MailSuccessfulySent', $mailfile->getValidAddress($emailFrom, 2), $mailfile->getValidAddress($emailTo, 2));
835 header(
"Location: ".$_SERVER[
"PHP_SELF"].
"?id=".$id);
838 $langs->load(
"other");
839 if ($mailfile->error) {
841 $mesg .= $langs->trans(
'ErrorFailedToSendMail', $emailFrom, $emailTo);
842 $mesg .=
'<br>'.$mailfile->error;
845 setEventMessages(
'No mail sent. Feature is disabled by option MAIN_DISABLE_ALL_MAILS',
null,
'warnings');
853 setEventMessages($langs->trans(
"NoEmailSentBadSenderOrRecipientEmail"),
null,
'warnings');
863 if ($action ==
"confirm_cancel" &&
GETPOST(
'confirm',
'alpha') ==
"yes" && $id > 0 && $user->hasRight(
'expensereport',
'creer')) {
864 if (!
GETPOST(
'detail_cancel',
'alpha')) {
865 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Comment")),
null,
'errors');
870 if ($user->id ==
$object->fk_user_valid || $user->id ==
$object->fk_user_author) {
871 $detailCancel =
GETPOST(
'detail_cancel',
'alpha');
872 $result =
$object->set_cancel($user, $detailCancel);
877 $outputlangs = $langs;
880 $newlang =
GETPOST(
'lang_id',
'aZ09');
883 $tmpuser =
new User($db);
884 $tmpuser->fetch(
$object->fk_user_author);
885 $newlang = $tmpuser->lang;
887 if (!empty($newlang)) {
889 $outputlangs->setDefaultLang($newlang);
894 $object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref);
902 $destinataire =
new User($db);
903 $destinataire->fetch(
$object->fk_user_author);
904 $emailTo = $destinataire->email;
907 $expediteur =
new User($db);
908 $expediteur->fetch(
$object->fk_user_cancel);
911 if ($emailFrom && $emailTo) {
922 $subject = $societeName.
" - ".$langs->transnoentities(
"ExpenseReportCanceled");
925 $link = $urlwithroot.
'/expensereport/card.php?id='.
$object->id;
926 $link =
'<a href="'.$link.
'">'.$link.
'</a>';
927 $message = $langs->transnoentities(
"ExpenseReportCanceledMessage",
$object->ref, $destinataire->getFullName($langs), $expediteur->getFullName($langs), $detailCancel, $link);
945 $mailfile =
new CMailFile($subject, $emailTo, $emailFrom, $message, $filedir, $mimetype, $filename,
'',
'', 0, -1);
947 if (empty($mailfile->error)) {
949 $result = $mailfile->sendfile();
951 $mesg = $langs->trans(
'MailSuccessfulySent', $mailfile->getValidAddress($emailFrom, 2), $mailfile->getValidAddress($emailTo, 2));
953 header(
"Location: ".$_SERVER[
"PHP_SELF"].
"?id=".$id);
956 $langs->load(
"other");
957 if ($mailfile->error) {
959 $mesg .= $langs->trans(
'ErrorFailedToSendMail', $emailFrom, $emailTo);
960 $mesg .=
'<br>'.$mailfile->error;
963 setEventMessages(
'No mail sent. Feature is disabled by option MAIN_DISABLE_ALL_MAILS',
null,
'warnings');
971 setEventMessages($langs->trans(
"NoEmailSentBadSenderOrRecipientEmail"),
null,
'warnings');
984 if ($action ==
"confirm_setdraft" &&
GETPOST(
'confirm',
'alpha') ==
"yes" && $id > 0 && $user->hasRight(
'expensereport',
'creer')) {
987 if ($user->id ==
$object->fk_user_author || $user->id ==
$object->fk_user_valid || in_array(
$object->fk_user_author, $childids)) {
988 $result =
$object->setStatut(0);
993 $outputlangs = $langs;
996 $newlang =
GETPOST(
'lang_id',
'aZ09');
999 $tmpuser =
new User($db);
1000 $tmpuser->fetch(
$object->fk_user_author);
1001 $newlang = $tmpuser->lang;
1003 if (!empty($newlang)) {
1004 $outputlangs =
new Translate(
"", $conf);
1005 $outputlangs->setDefaultLang($newlang);
1010 $object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref);
1015 header(
"Location: ".$_SERVER[
"PHP_SELF"].
"?id=".$id);
1025 if ($action ==
'set_unpaid' && $id > 0 && $user->hasRight(
'expensereport',
'to_paid')) {
1029 $result =
$object->setUnpaid($user);
1034 $outputlangs = $langs;
1037 $newlang =
GETPOST(
'lang_id',
'aZ09');
1040 $tmpuser =
new User($db);
1041 $tmpuser->fetch(
$object->fk_user_author);
1042 $newlang = $tmpuser->lang;
1044 if (!empty($newlang)) {
1045 $outputlangs =
new Translate(
"", $conf);
1046 $outputlangs->setDefaultLang($newlang);
1051 $object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref);
1054 header(
"Location: ".$_SERVER[
"PHP_SELF"].
"?id=".$id);
1060 if ($action ==
'set_paid' && $id > 0 && $user->hasRight(
'expensereport',
'to_paid')) {
1064 $result =
$object->setPaid($id, $user);
1069 $outputlangs = $langs;
1072 $newlang =
GETPOST(
'lang_id',
'aZ09');
1075 $tmpuser =
new User($db);
1076 $tmpuser->fetch(
$object->fk_user_author);
1077 $newlang = $tmpuser->lang;
1079 if (!empty($newlang)) {
1080 $outputlangs =
new Translate(
"", $conf);
1081 $outputlangs->setDefaultLang($newlang);
1086 $object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref);
1097 $destinataire =
new User($db);
1098 $destinataire->fetch(
$object->fk_user_author);
1099 $emailTo = $destinataire->email;
1102 $expediteur =
new User($db);
1103 $expediteur->fetch($user->id);
1106 if ($emailFrom && $emailTo) {
1107 $filename = array();
1109 $mimetype = array();
1117 $subject = $societeName.
" - ".$langs->transnoentities(
"ExpenseReportPaid");
1120 $link = $urlwithroot.
'/expensereport/card.php?id='.
$object->id;
1121 $link =
'<a href="'.$link.
'">'.$link.
'</a>';
1122 $message = $langs->transnoentities(
"ExpenseReportPaidMessage",
$object->ref, $destinataire->getFullName($langs), $expediteur->getFullName($langs), $link);
1125 $object->setDocModel($user,
"");
1126 $resultPDF = expensereport_pdf_create($db, $object,
'',
"", $langs);
1129 $mailfile =
new CMailFile($subject, $emailTo, $emailFrom, $message, $filedir, $mimetype, $filename,
'',
'', 0, -1);
1131 if (empty($mailfile->error)) {
1133 $result = $mailfile->sendfile();
1135 $mesg = $langs->trans(
'MailSuccessfulySent', $mailfile->getValidAddress($emailFrom, 2), $mailfile->getValidAddress($emailTo, 2));
1138 header(
"Location: ".$_SERVER[
"PHP_SELF"].
"?id=".$id);
1141 $langs->load(
"other");
1142 if ($mailfile->error) {
1144 $mesg .= $langs->trans(
'ErrorFailedToSendMail', $emailFrom, $emailTo);
1145 $mesg .=
'<br>'.$mailfile->error;
1148 setEventMessages(
'No mail sent. Feature is disabled by option MAIN_DISABLE_ALL_MAILS',
null,
'warnings');
1155 setEventMessages($langs->trans(
"NoEmailSentBadSenderOrRecipientEmail"),
null,
'warnings');
1165 if ($action ==
"addline" && $user->hasRight(
'expensereport',
'creer')) {
1168 if (GETPOSTISSET(
'attachfile')) {
1169 $arrayoffiles =
GETPOST(
'attachfile',
'array');
1170 if (is_array($arrayoffiles) && !empty($arrayoffiles[0])) {
1171 include_once DOL_DOCUMENT_ROOT.
'/ecm/class/ecmfiles.class.php';
1172 $entityprefix = ($conf->entity !=
'1') ? $conf->entity.
'/' :
'';
1173 $relativepath =
'expensereport/'.$object->ref.
'/'.$arrayoffiles[0];
1175 $ecmfiles->fetch(0,
'', $relativepath);
1176 $fk_ecm_files = $ecmfiles->id;
1181 if (empty($vatrate)) {
1184 $tmpvat =
price2num(preg_replace(
'/\s*\(.*\)/',
'', $vatrate));
1188 if (empty($value_unit)) {
1189 $value_unit =
price2num((
float) $value_unit_ht + ((
float) $value_unit_ht * (
float) $tmpvat / 100),
'MU');
1192 $fk_c_exp_tax_cat =
GETPOSTINT(
'fk_c_exp_tax_cat');
1199 if (!($fk_c_type_fees > 0)) {
1201 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Type")),
null,
'errors');
1205 if ((
float) $tmpvat < 0 || $tmpvat ===
'') {
1207 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"VAT")),
null,
'errors');
1212 if (empty($date) || $date ==
"--") {
1214 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Date")),
null,
'errors');
1215 } elseif ($date < $object->date_debut || $date > (
$object->date_fin + (24 * 3600 - 1))) {
1221 $langs->load(
"errors");
1222 $type = $error > 0 ?
'errors' :
'warnings';
1223 setEventMessages($langs->trans(
"WarningDateOfLineMustBeInExpenseReportRange"),
null, $type);
1227 if ($value_unit == 0) {
1229 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"PriceUTTC")),
null,
'errors');
1233 if ($projectRequired && $fk_project <= 0) {
1235 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Project")),
null,
'errors');
1239 if ($fileRequired && $fk_ecm_files == 0) {
1241 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"File")),
null,
'errors');
1248 $result =
$object->addline($qty, $value_unit, $fk_c_type_fees, $vatrate, $date, $comments, $fk_project, $fk_c_exp_tax_cat, $type, $fk_ecm_files);
1254 $outputlangs = $langs;
1255 $newlang =
GETPOST(
'lang_id',
'alpha');
1257 $tmpuser =
new User($db);
1258 $tmpuser->fetch(
$object->fk_user_author);
1259 $newlang = $tmpuser->lang;
1261 if (!empty($newlang)) {
1262 $outputlangs =
new Translate(
"", $conf);
1263 $outputlangs->setDefaultLang($newlang);
1266 $object->generateDocument(
$object->model_pdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
1270 unset($value_unit_ht);
1274 unset($fk_c_type_fees);
1285 header(
"Location: ".$_SERVER[
"PHP_SELF"].
"?id=".
GETPOSTINT(
'id'));
1292 if ($action ==
'confirm_delete_line' &&
GETPOST(
"confirm",
'alpha') ==
"yes" && $user->hasRight(
'expensereport',
'creer')) {
1298 $total_ht = $object_ligne->total_ht;
1299 $total_tva = $object_ligne->total_tva;
1306 $outputlangs = $langs;
1309 $newlang =
GETPOST(
'lang_id',
'aZ09');
1312 $tmpuser =
new User($db);
1313 $tmpuser->fetch(
$object->fk_user_author);
1314 $newlang = $tmpuser->lang;
1316 if (!empty($newlang)) {
1317 $outputlangs =
new Translate(
"", $conf);
1318 $outputlangs->setDefaultLang($newlang);
1323 $object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref);
1327 header(
"Location: ".$_SERVER[
"PHP_SELF"].
"?id=".
GETPOSTINT(
'id'));
1334 if ($action ==
"updateline" && $permissiontoadd) {
1340 if (GETPOSTISSET(
'attachfile')) {
1341 $arrayoffiles =
GETPOST(
'attachfile',
'array');
1342 if (is_array($arrayoffiles) && !empty($arrayoffiles[0])) {
1343 include_once DOL_DOCUMENT_ROOT.
'/ecm/class/ecmfiles.class.php';
1344 $relativepath =
'expensereport/'.$object->ref.
'/'.$arrayoffiles[0];
1346 $ecmfiles->fetch(0,
'', $relativepath);
1347 $fk_ecm_files = $ecmfiles->id;
1352 $type_fees_id =
GETPOSTINT(
'fk_c_type_fees');
1353 $fk_c_exp_tax_cat =
GETPOSTINT(
'fk_c_exp_tax_cat');
1354 $projet_id = $fk_project;
1355 $comments =
GETPOST(
'comments',
'restricthtml');
1357 $vatrate =
GETPOST(
'vatrate',
'alpha');
1360 if (empty($vatrate)) {
1363 $tmpvat =
price2num(preg_replace(
'/\s*\(.*\)/',
'', $vatrate));
1367 if (empty($value_unit)) {
1368 $value_unit =
price2num((
float) $value_unit_ht + ((
float) $value_unit_ht * (
float) $tmpvat / 100),
'MU');
1373 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Type")),
null,
'errors');
1376 if ((
float) $tmpvat < 0 || $tmpvat ==
'') {
1378 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Vat")),
null,
'errors');
1382 if ($date < $object->date_debut || $date > (
$object->date_fin + (24 * 3600 - 1))) {
1387 $langs->load(
"errors");
1388 $type = $error > 0 ?
'errors' :
'warnings';
1389 setEventMessages($langs->trans(
"WarningDateOfLineMustBeInExpenseReportRange"),
null, $type);
1393 if ($projectRequired && $projet_id <= 0) {
1395 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Project")),
null,
'errors');
1400 $result =
$object->updateline($rowid, $type_fees_id, $projet_id, $vatrate, $comments, (
float) $qty, (
float) $value_unit, $date, $id, $fk_c_exp_tax_cat, $fk_ecm_files);
1405 $outputlangs = $langs;
1408 $newlang =
GETPOST(
'lang_id',
'aZ09');
1411 $tmpuser =
new User($db);
1412 $tmpuser->fetch(
$object->fk_user_author);
1413 $newlang = $tmpuser->lang;
1415 if (!empty($newlang)) {
1416 $outputlangs =
new Translate(
"", $conf);
1417 $outputlangs->setDefaultLang($newlang);
1422 $object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref);
1426 unset($value_unit_ht);
1430 unset($fk_c_type_fees);
1443 include DOL_DOCUMENT_ROOT.
'/core/actions_printing.inc.php';
1446 $triggersendname =
'EXPENSEREPORT_SENTBYMAIL';
1447 $autocopy =
'MAIN_MAIL_AUTOCOPY_EXPENSEREPORT_TO';
1448 $trackid =
'exp'.$object->id;
1449 include DOL_DOCUMENT_ROOT.
'/core/actions_sendmails.inc.php';
1452 $upload_dir = $conf->expensereport->dir_output;
1453 include DOL_DOCUMENT_ROOT.
'/core/actions_builddoc.inc.php';
1461$title = $langs->trans(
"ExpenseReport").
" - ".$langs->trans(
"Card");
1462$help_url =
"EN:Module_Expense_Reports|FR:Module_Notes_de_frais";
1466$form =
new Form($db);
1469$projecttmp =
new Project($db);
1471$bankaccountstatic =
new Account($db);
1472$ecmfilesstatic =
new EcmFiles($db);
1477if ($action ==
'create') {
1480 print
'<form action="'.$_SERVER[
'PHP_SELF'].
'" method="post" name="create">';
1481 print
'<input type="hidden" name="token" value="'.newToken().
'">';
1482 print
'<input type="hidden" name="action" value="add">';
1483 print
'<input type="hidden" name="backtopage" value="'.$backtopage.
'">';
1487 print
'<table class="border centpercent">';
1492 print
'<td class="fieldrequired">'.$langs->trans(
"User").
'</td>';
1494 $defaultselectuser = $user->id;
1496 $defaultselectuser =
GETPOSTINT(
'fk_user_author');
1498 $include_users =
'hierarchyme';
1499 if (
getDolGlobalString(
'MAIN_USE_ADVANCED_PERMS') && $user->hasRight(
'expensereport',
'writeall_advance')) {
1500 $include_users = array();
1502 print
img_picto(
'',
'user',
'class="pictofixedwidth"').$form->select_dolusers($defaultselectuser,
'fk_user_author', 0,
null, 0, $include_users,
'',
'0,'.$conf->entity, 0, 0,
'', 0,
'',
'minwidth200 maxwidth500 inline-block');
1508 print
'<td class="titlefieldcreate fieldrequired">'.$langs->trans(
"DateStart").
'</td>';
1509 print
'<td>'.img_picto(
'',
'action',
'class="pictofixedwidth"');
1510 print $form->selectDate($date_start ? $date_start : -1,
'date_debut', 0, 0, 0,
'', 1, 1);
1516 print
'<td class="fieldrequired">'.$langs->trans(
"DateEnd").
'</td>';
1517 print
'<td>'.img_picto(
'',
'action',
'class="pictofixedwidth"');
1518 print $form->selectDate($date_end ? $date_end : -1,
'date_fin', 0, 0, 0,
'', 1, 1);
1525 print
'<td>'.$langs->trans(
"ReviewedByCP").
'</td>';
1528 $include_users =
$object->fetch_users_approver_expensereport();
1529 if (empty($include_users)) {
1530 print
img_warning().
' '.$langs->trans(
"NobodyHasPermissionToValidateExpenseReport");
1532 $defaultselectuser = (empty($user->fk_user_expense_validator) ? $user->fk_user : $user->fk_user_expense_validator);
1537 $defaultselectuser =
GETPOSTINT(
'fk_user_validator');
1539 $s = $form->select_dolusers($defaultselectuser,
"fk_user_validator", 1,
null, ((empty($defaultselectuser) || !
getDolGlobalString(
'EXPENSEREPORT_DEFAULT_VALIDATOR_UNCHANGEABLE')) ? 0 : 1), $include_users);
1540 print
img_picto(
'',
'user',
'class="pictofixedwidth"').$form->textwithpicto($s, $langs->trans(
"AnyOtherInThisListCanValidate"));
1548 print
'<td>'.$langs->trans(
"ModePaiement").
'</td>';
1550 $form->select_types_paiements(
'',
'fk_c_paiement');
1556 $note_public = GETPOSTISSET(
'note_public') ?
GETPOST(
'note_public',
'restricthtml') :
'';
1559 print
'<td class="tdtop">'.$langs->trans(
'NotePublic').
'</td>';
1562 $doleditor =
new DolEditor(
'note_public', $note_public,
'', 80,
'dolibarr_notes',
'In',
false,
false, !
getDolGlobalString(
'FCKEDITOR_ENABLE_NOTE_PUBLIC') ? 0 : 1, ROWS_3,
'90%');
1563 print $doleditor->Create(1);
1567 $note_private = GETPOSTISSET(
'note_private') ?
GETPOST(
'note_private',
'restricthtml') :
'';
1569 if (empty($user->socid)) {
1571 print
'<td class="tdtop">'.$langs->trans(
'NotePrivate').
'</td>';
1574 $doleditor =
new DolEditor(
'note_private', $note_private,
'', 80,
'dolibarr_notes',
'In',
false,
false, !
getDolGlobalString(
'FCKEDITOR_ENABLE_NOTE_PRIVATE') ? 0 : 1, ROWS_3,
'90%');
1575 print $doleditor->Create(1);
1580 $parameters = array(
'colspan' =>
' colspan="3"',
'cols' => 3);
1581 $reshook = $hookmanager->executeHooks(
'formObjectOptions', $parameters, $object, $action);
1582 print $hookmanager->resPrint;
1583 if (empty($reshook)) {
1584 print
$object->showOptionals($extrafields,
'create', $parameters);
1592 print $form->buttonsSaveCancel(
"AddTrip");
1597 $result =
$object->fetch($id, $ref);
1600 if (!in_array(
$object->fk_user_author, $childids)) {
1601 if (!$user->hasRight(
'expensereport',
'readall') && !$user->hasRight(
'expensereport',
'lire_tous')
1602 && (!
getDolGlobalString(
'MAIN_USE_ADVANCED_PERMS') || !$user->hasRight(
'expensereport',
'writeall_advance'))) {
1605 print
'<div class="tabBar">';
1606 print $langs->trans(
'NotUserRightToView');
1621 print
"<form name='update' action=\"".$_SERVER[
'PHP_SELF'].
"\" method=\"post\">\n";
1622 print
'<input type="hidden" name="token" value="'.newToken().
'">';
1623 print
'<input type="hidden" name="id" value="'.$id.
'">';
1624 print
'<input type="hidden" name="backtopage" value="'.$backtopage.
'">';
1629 print
'<input type="hidden" name="action" value="updateFromRefuse">';
1631 print
'<input type="hidden" name="action" value="update">';
1634 $linkback =
'<a href="'.DOL_URL_ROOT.
'/expensereport/list.php?restore_lastsearch_values=1'.(!empty($socid) ?
'&socid='.$socid :
'').
'">'.$langs->trans(
"BackToList").
'</a>';
1636 print
'<table class="border centpercent">';
1639 print
'<td>'.$langs->trans(
"User").
'</td>';
1641 $userfee =
new User($db);
1642 if (
$object->fk_user_author > 0) {
1643 $userfee->fetch(
$object->fk_user_author);
1644 print $userfee->getNomUrl(-1);
1649 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"Ref").
'</td><td>';
1650 print $form->showrefnav($object,
'ref', $linkback, 1,
'ref',
'ref',
'');
1654 print
'<td>'.$langs->trans(
"DateStart").
'</td>';
1656 print $form->selectDate(
$object->date_debut,
'date_debut');
1660 print
'<td>'.$langs->trans(
"DateEnd").
'</td>';
1662 print $form->selectDate(
$object->date_fin,
'date_fin');
1668 print
'<td>'.$langs->trans(
"ModePaiement").
'</td>';
1670 $form->select_types_paiements((
string)
$object->fk_c_paiement,
'fk_c_paiement');
1677 print
'<td>'.$langs->trans(
"VALIDATOR").
'</td>';
1679 $include_users =
$object->fetch_users_approver_expensereport();
1680 $s = $form->select_dolusers(
$object->fk_user_validator,
"fk_user_validator", 1,
null, 0, $include_users);
1681 print $form->textwithpicto($s, $langs->trans(
"AnyOtherInThisListCanValidate"));
1686 print
'<td>'.$langs->trans(
"VALIDOR").
'</td>';
1688 $userfee =
new User($db);
1689 $userfee->fetch(
$object->fk_user_valid);
1690 print $userfee->getNomUrl(-1);
1696 print
'<td>'.$langs->trans(
"AUTHORPAIEMENT").
'</td>';
1698 $userfee =
new User($db);
1699 $userfee->fetch($user->id);
1700 print $userfee->getNomUrl(-1);
1712 print $form->buttonsSaveCancel(
"Modify");
1716 $taxlessUnitPriceDisabled =
getDolGlobalString(
'EXPENSEREPORT_FORCE_LINE_AMOUNTS_INCLUDING_TAXES_ONLY') ?
' disabled' :
'';
1723 if ($action ==
'clone') {
1725 $criteriaforfilter =
'hierarchyme';
1726 if ($user->hasRight(
'expensereport',
'readall')) {
1727 $criteriaforfilter =
'';
1729 $formquestion = array(
1731 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'))
1734 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.
$object->id, $langs->trans(
'ToClone'), $langs->trans(
'ConfirmCloneExpenseReport',
$object->ref),
'confirm_clone', $formquestion,
'yes', 1);
1737 if ($action ==
'save') {
1738 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
"?id=".$id, $langs->trans(
"SaveTrip"), $langs->trans(
"ConfirmSaveTrip"),
"confirm_validate",
"",
"", 1);
1741 if ($action ==
'save_from_refuse') {
1742 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
"?id=".$id, $langs->trans(
"SaveTrip"), $langs->trans(
"ConfirmSaveTrip"),
"confirm_save_from_refuse",
"",
"", 1);
1745 if ($action ==
'delete') {
1746 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
"?id=".$id, $langs->trans(
"DeleteTrip"), $langs->trans(
"ConfirmDeleteTrip"),
"confirm_delete",
"",
"", 1);
1749 if ($action ==
'validate') {
1750 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
"?id=".$id, $langs->trans(
"ValideTrip"), $langs->trans(
"ConfirmValideTrip"),
"confirm_approve",
"",
"", 1);
1753 if ($action ==
'paid') {
1754 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
"?id=".$id, $langs->trans(
"PaidTrip"), $langs->trans(
"ConfirmPaidTrip"),
"confirm_paid",
"",
"", 1);
1757 if ($action ==
'cancel') {
1758 $array_input = array(
'text' => $langs->trans(
"ConfirmCancelTrip"), 0 => array(
'type' =>
"text",
'label' =>
'<strong>'.$langs->trans(
"Comment").
'</strong>',
'name' =>
"detail_cancel",
'value' =>
""));
1759 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
"?id=".$id, $langs->trans(
"Cancel"),
"",
"confirm_cancel", $array_input,
"", 1);
1762 if ($action ==
'setdraft') {
1763 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
"?id=".$id, $langs->trans(
"BrouillonnerTrip"), $langs->trans(
"ConfirmBrouillonnerTrip"),
"confirm_setdraft",
"",
"", 1);
1766 if ($action ==
'refuse') {
1767 $array_input = array(
'text' => $langs->trans(
"ConfirmRefuseTrip"), 0 => array(
'type' =>
"text",
'label' => $langs->trans(
"Comment"),
'name' =>
"detail_refuse",
'value' =>
""));
1768 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
"?id=".$id, $langs->trans(
"Deny"),
'',
"confirm_refuse", $array_input,
"yes", 1);
1771 if ($action ==
'delete_line') {
1772 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
"?id=".
$id.
"&rowid=".
GETPOSTINT(
'rowid'), $langs->trans(
"DeleteLine"), $langs->trans(
"ConfirmDeleteLine"),
"confirm_delete_line",
'',
'yes', 1);
1776 $parameters = array(
'formConfirm' => $formconfirm);
1777 $reshook = $hookmanager->executeHooks(
'formConfirm', $parameters, $object, $action);
1778 if (empty($reshook)) {
1779 $formconfirm .= $hookmanager->resPrint;
1780 } elseif ($reshook > 0) {
1781 $formconfirm = $hookmanager->resPrint;
1788 $linkback =
'<a href="'.DOL_URL_ROOT.
'/expensereport/list.php?restore_lastsearch_values=1'.(!empty($socid) ?
'&socid='.$socid :
'').
'">'.$langs->trans(
"BackToList").
'</a>';
1790 $morehtmlref =
'<div class="refidno">';
1791 $morehtmlref .=
'</div>';
1793 dol_banner_tab($object,
'ref', $linkback, 1,
'ref',
'ref', $morehtmlref);
1795 print
'<div class="fichecenter">';
1796 print
'<div class="fichehalfleft">';
1797 print
'<div class="underbanner clearboth"></div>';
1799 print
'<table class="border tableforfield centpercent">';
1803 print
'<td class="titlefield">'.$langs->trans(
"User").
'</td>';
1805 if (
$object->fk_user_author > 0) {
1806 $userauthor =
new User($db);
1807 $result = $userauthor->fetch(
$object->fk_user_author);
1810 } elseif ($result > 0) {
1811 print $userauthor->getNomUrl(-1);
1818 print
'<td class="titlefield">'.$langs->trans(
"Period").
'</td>';
1825 print
'<td>'.$langs->trans(
"ModePaiement").
'</td>';
1826 print
'<td>'.$object->fk_c_paiement.
'</td>';
1832 print
'<td>'.$langs->trans(
"DATE_SAVE").
'</td>';
1833 print
'<td>'.dol_print_date(
$object->date_valid,
'dayhour',
'tzuser');
1835 print
' '.img_warning($langs->trans(
"Late").
' - '.$langs->trans(
"ToApprove"));
1838 print
' '.img_warning($langs->trans(
"Late").
' - '.$langs->trans(
"ToPay"));
1846 print
'<td>'.$langs->trans(
"VALIDATOR").
'</td>';
1848 if (
$object->fk_user_validator > 0) {
1849 $userfee =
new User($db);
1850 $result = $userfee->fetch(
$object->fk_user_validator);
1852 print $userfee->getNomUrl(-1);
1854 if (empty($userfee->email) || !
isValidEmail($userfee->email)) {
1855 $langs->load(
"errors");
1856 print
img_warning($langs->trans(
"ErrorBadEMail", $userfee->email));
1862 print
'<td>'.$langs->trans(
"CANCEL_USER").
'</span></td>';
1864 if (
$object->fk_user_cancel > 0) {
1865 $userfee =
new User($db);
1866 $result = $userfee->fetch(
$object->fk_user_cancel);
1868 print $userfee->getNomUrl(-1);
1874 print
'<td>'.$langs->trans(
"MOTIF_CANCEL").
'</td>';
1875 print
'<td>'.$object->detail_cancel.
'</td></tr>';
1878 print
'<td>'.$langs->trans(
"DATE_CANCEL").
'</td>';
1879 print
'<td>'.dol_print_date(
$object->date_cancel,
'dayhour',
'tzuser').
'</td></tr>';
1883 print
'<td>'.$langs->trans(
"ApprovedBy").
'</td>';
1885 if (
$object->fk_user_approve > 0) {
1886 $userapp =
new User($db);
1887 $result = $userapp->fetch(
$object->fk_user_approve);
1889 print $userapp->getNomUrl(-1);
1895 print
'<td>'.$langs->trans(
"DateApprove").
'</td>';
1896 print
'<td>'.dol_print_date(
$object->date_approve,
'dayhour',
'tzuser').
'</td></tr>';
1902 print
'<td>'.$langs->trans(
"REFUSEUR").
'</td>';
1904 $userfee =
new User($db);
1905 $result = $userfee->fetch(
$object->fk_user_refuse);
1907 print $userfee->getNomUrl(-1);
1912 print
'<td>'.$langs->trans(
"DATE_REFUS").
'</td>';
1913 print
'<td>'.dol_print_date(
$object->date_refuse,
'dayhour',
'tzuser');
1915 print
' - '.$object->detail_refuse;
1939 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_view.tpl.php';
1944 print
'<div class="fichehalfright">';
1945 print
'<div class="underbanner clearboth"></div>';
1947 print
'<table class="border tableforfield centpercent">';
1951 print
'<td class="titlefieldmiddle">'.$langs->trans(
"AmountHT").
'</td>';
1952 print
'<td class="nowrap amountcard">'.price(
$object->total_ht, 1,
'', 1, - 1, - 1, $conf->currency).
'</td>';
1969 print
'<td>'.$langs->trans(
"AmountVAT").
'</td>';
1970 print
'<td class="nowrap amountcard">'.price(
$object->total_tva, 1,
'', 1, -1, -1, $conf->currency).
'</td>';
1974 if (
$mysoc->localtax1_assuj ==
"1" ||
$object->total_localtax1 != 0) {
1975 print
'<tr><td>'.$langs->transcountry(
"AmountLT1",
$mysoc->country_code).
'</td>';
1976 print
'<td class="valuefield">'.price(
$object->total_localtax1, 1,
'', 1, -1, -1, $conf->currency).
'</td></tr>';
1978 if (
$mysoc->localtax2_assuj ==
"1" ||
$object->total_localtax2 != 0) {
1979 print
'<tr><td>'.$langs->transcountry(
"AmountLT2",
$mysoc->country_code).
'</td>';
1980 print
'<td class="valuefield">'.price(
$object->total_localtax2, 1,
'', 1, -1, -1, $conf->currency).
'</td></tr>';
1984 print
'<td>'.$langs->trans(
"AmountTTC").
'</td>';
1985 print
'<td class="nowrap amountcard">'.price(
$object->total_ttc, 1,
'', 1, -1, -1, $conf->currency).
'</td>';
1989 $canSeeBankAccount =
isModEnabled(
'bank') && $user->hasRight(
'banque',
'lire');
1992 if ($canSeeBankAccount) {
1997 print
'<div class="div-table-responsive-no-min">';
1998 print
'<table class="noborder paymenttable centpercent">';
2000 print
'<tr class="liste_titre">';
2001 print
'<td class="liste_titre">'.$langs->trans(
'Payments').
'</td>';
2002 print
'<td class="liste_titre">'.$langs->trans(
'Date').
'</td>';
2003 print
'<td class="liste_titre">'.$langs->trans(
'Type').
'</td>';
2004 if ($canSeeBankAccount) {
2005 print
'<td class="liste_titre right">'.$langs->trans(
'BankAccount').
'</td>';
2007 print
'<td class="liste_titre" width="18"> </td>';
2008 print
'<td class="liste_titre right">'.$langs->trans(
'Amount').
'</td>';
2012 $sql =
"SELECT p.rowid, p.num_payment, p.datep as dp, p.amount, p.fk_bank,";
2013 $sql .=
"c.code as payment_code, c.libelle as payment_type,";
2014 $sql .=
"ba.rowid as baid, ba.ref as baref, ba.label, ba.number as banumber, ba.account_number, ba.fk_accountancy_journal";
2015 $sql .=
" FROM ".MAIN_DB_PREFIX.
"expensereport as e, ".MAIN_DB_PREFIX.
"payment_expensereport as p";
2016 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"c_paiement as c ON p.fk_typepayment = c.id";
2017 $sql .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'bank as b ON p.fk_bank = b.rowid';
2018 $sql .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'bank_account as ba ON b.fk_account = ba.rowid';
2019 $sql .=
" WHERE e.rowid = ".((int) $id);
2020 $sql .=
" AND p.fk_expensereport = e.rowid";
2021 $sql .=
' AND e.entity IN ('.getEntity(
'expensereport').
')';
2022 $sql .=
" ORDER BY dp";
2024 $resql = $db->query($sql);
2026 $num = $db->num_rows($resql);
2030 $objp = $db->fetch_object($resql);
2032 $paymentexpensereportstatic->id = $objp->rowid;
2033 $paymentexpensereportstatic->datep = $db->jdate($objp->dp);
2034 $paymentexpensereportstatic->ref = $objp->rowid;
2035 $paymentexpensereportstatic->num_payment = $objp->num_payment;
2036 $paymentexpensereportstatic->type_code = $objp->payment_code;
2037 $paymentexpensereportstatic->type_label = $objp->payment_type;
2039 print
'<tr class="oddeven">';
2041 print $paymentexpensereportstatic->getNomUrl(1);
2043 print
'<td>'.dol_print_date($db->jdate($objp->dp),
'day').
"</td>\n";
2044 $labeltype = $langs->trans(
"PaymentType".$objp->payment_code) !=
"PaymentType".$objp->payment_code ? $langs->trans(
"PaymentType".$objp->payment_code) : $objp->payment_type;
2045 print
"<td>".$labeltype.
' '.$objp->num_payment.
"</td>\n";
2047 if ($canSeeBankAccount) {
2048 $bankaccountstatic->id = $objp->baid;
2049 $bankaccountstatic->ref = $objp->baref;
2050 $bankaccountstatic->label = $objp->baref;
2051 $bankaccountstatic->number = $objp->banumber;
2054 $bankaccountstatic->account_number = $objp->account_number;
2057 $accountingjournal->fetch($objp->fk_accountancy_journal);
2058 $bankaccountstatic->accountancy_journal = $accountingjournal->getNomUrl(0, 1, 1,
'', 1);
2061 print
'<td class="right">';
2062 if ($bankaccountstatic->id) {
2063 print $bankaccountstatic->getNomUrl(1,
'transactions');
2068 print
'<td class="right">'.price($objp->amount).
"</td>";
2070 $totalpaid += $objp->amount;
2076 $resteapayeraffiche = $remaintopay;
2078 if ($remaintopay > 0) {
2079 $cssforamountpaymentcomplete =
'amountremaintopay';
2081 $cssforamountpaymentcomplete =
'amountpaymentcomplete';
2085 $cssforamountpaymentcomplete =
'amountpaymentneutral strikefordisabled';
2086 } elseif (
$object->paid == 1 && $remaintopay > 0) {
2087 $cssforamountpaymentcomplete =
'amountpaymentneutral strikefordisabled';
2089 print
'<tr><td colspan="'.$nbcols.
'" class="right">'.$langs->trans(
"AlreadyPaid").
':</td>';
2091 print
'<td class="right">'.price($totalpaid).
'</td></tr>';
2093 print
'<tr><td colspan="'.$nbcols.
'" class="right">'.$langs->trans(
"AmountExpected").
':</td>';
2095 print
'<td class="right">'.price(
$object->total_ttc).
'</td></tr>';
2097 print
'<tr><td colspan="'.$nbcols.
'" class="right">'.$langs->trans(
"RemainderToPay").
':</td>';
2099 print
'<td class="right'.($resteapayeraffiche ?
' amountremaintopay' : (
' '.$cssforamountpaymentcomplete)).
'">'.
price($resteapayeraffiche).
'</td></tr>';
2111 print
'<div class="clearboth"></div><br><br>';
2113 print
'<div style="clear: both;"></div>';
2115 $actiontouse =
'updateline';
2117 $actiontouse =
'addline';
2120 print
'<form name="expensereport" action="'.$_SERVER[
"PHP_SELF"].
'" enctype="multipart/form-data" method="post" >';
2121 print
'<input type="hidden" name="token" value="'.newToken().
'">';
2122 print
'<input type="hidden" name="action" value="'.$actiontouse.
'">';
2123 print
'<input type="hidden" name="id" value="'.$object->id.
'">';
2124 print
'<input type="hidden" name="fk_expensereport" value="'.$object->id.
'" />';
2125 print
'<input type="hidden" name="backtopage" value="'.$backtopage.
'">';
2126 print
'<input type="hidden" name="page_y" value="">';
2128 print
'<div class="div-table-responsive-no-min">';
2129 print
'<table id="tablelines" class="noborder centpercent">';
2135 print
'<tr class="liste_titre headerexpensereportdet">';
2136 print
'<td class="center linecollinenb">'.$langs->trans(
'LineNb').
'</td>';
2138 print
'<td class="center linecoldate">'.$langs->trans(
'Date').
'</td>';
2140 print
'<td class="minwidth100imp linecolproject">'.$langs->trans(
'Project').
'</td>';
2142 print
'<td class="center linecoltype">'.$langs->trans(
'Type').
'</td>';
2144 print
'<td class="center linecolcarcategory">'.$langs->trans(
'CarCategory').
'</td>';
2146 print
'<td class="linecoldescription">'.$langs->trans(
'Description').
'</td>';
2147 print
'<td class="right linecolvat">'.$langs->trans(
'VAT').
'</td>';
2148 print
'<td class="right linecolpriceuht">'.$langs->trans(
'PriceUHT').
'</td>';
2149 print
'<td class="right linecolpriceuttc">'.$langs->trans(
'PriceUTTC').
'</td>';
2150 print
'<td class="right linecolqty">'.$langs->trans(
'Qty').
'</td>';
2151 if ($action !=
'editline') {
2152 print
'<td class="right linecolamountht">'.$langs->trans(
'AmountHT').
'</td>';
2153 print
'<td class="right linecolamountttc">'.$langs->trans(
'AmountTTC').
'</td>';
2165 print
'<td class="right"></td>';
2169 foreach (
$object->lines as &$line) {
2172 if ($action !=
'editline' || $line->id !=
GETPOSTINT(
'rowid')) {
2173 print
'<tr class="oddeven linetr" data-id="'.$line->id.
'">';
2176 print
'<td class="center linecollinenb">';
2181 print
'<td class="center linecoldate">'.dol_print_date($db->jdate($line->date),
'day').
'</td>';
2185 print
'<td class="lineproject">';
2186 if ($line->fk_project > 0) {
2187 $projecttmp->id = $line->fk_project;
2188 $projecttmp->ref = $line->projet_ref;
2189 $projecttmp->title = $line->projet_title;
2190 print $projecttmp->getNomUrl(1);
2197 require_once DOL_DOCUMENT_ROOT.
'/accountancy/class/accountingaccount.class.php';
2199 $resaccountingaccount = $accountingaccount->fetch(0, $line->type_fees_accountancy_code, 1);
2201 $titlealt .= $langs->trans(
"AccountancyCode").
': ';
2202 if ($resaccountingaccount > 0) {
2203 $titlealt .= $accountingaccount->account_number;
2205 $titlealt .= $langs->trans(
"NotFound");
2211 print
'<td class="center linecoltype" title="'.dol_escape_htmltag($titlealt).
'">';
2212 $labeltype = ($langs->trans(($line->type_fees_code)) == $line->type_fees_code ? $line->type_fees_libelle : $langs->trans($line->type_fees_code));
2218 print
'<td class="fk_c_exp_tax_cat linecoltaxcat">';
2219 $exp_tax_cat_label =
dol_getIdFromCode($db, $line->fk_c_exp_tax_cat,
'c_exp_tax_cat',
'rowid',
'label');
2220 print $langs->trans($exp_tax_cat_label);
2225 print
'<td class="left linecolcomment minwidth100">'.dol_nl2br($line->comments).
'</td>';
2228 $senderissupplier = 0;
2229 $tooltiponprice =
'';
2230 $tooltiponpriceend =
'';
2232 $tooltiponprice = $langs->transcountry(
"TotalHT",
$mysoc->country_code).
'='.
price($line->total_ht);
2233 $tooltiponprice .=
'<br>'.$langs->transcountry(
"TotalVAT", ($senderissupplier ?
$object->thirdparty->country_code :
$mysoc->country_code)).
'='.
price($line->total_tva);
2234 if (is_object(
$object->thirdparty)) {
2235 if ($senderissupplier) {
2236 $seller =
$object->thirdparty;
2243 if (
$mysoc->useLocalTax(1)) {
2244 if (($seller->country_code == $buyer->country_code) || $line->total_localtax1 || $seller->useLocalTax(1)) {
2245 $tooltiponprice .=
'<br>'.$langs->transcountry(
"TotalLT1", $seller->country_code).
'='.
price($line->total_localtax1);
2247 $tooltiponprice .=
'<br>'.$langs->transcountry(
"TotalLT1", $seller->country_code).
'=<span class="opacitymedium">'.$langs->trans($senderissupplier ?
"NotUsedForThisVendor" :
"NotUsedForThisCustomer").
'</span>';
2250 if (
$mysoc->useLocalTax(2)) {
2251 if ((isset($seller->country_code) && isset($buyer->thirdparty->country_code) && $seller->country_code == $buyer->thirdparty->country_code) || $line->total_localtax2 || $seller->useLocalTax(2)) {
2252 $tooltiponprice .=
'<br>'.$langs->transcountry(
"TotalLT2", $seller->country_code).
'='.
price($line->total_localtax2);
2254 $tooltiponprice .=
'<br>'.$langs->transcountry(
"TotalLT2", $seller->country_code).
'=<span class="opacitymedium">'.$langs->trans($senderissupplier ?
"NotUsedForThisVendor" :
"NotUsedForThisCustomer").
'</span>';
2258 $tooltiponprice .=
'<br>'.$langs->transcountry(
"TotalTTC",
$mysoc->country_code).
'='.
price($line->total_ttc);
2260 $tooltiponprice =
'<span class="classfortooltip" title="'.dol_escape_htmltag($tooltiponprice).
'">';
2261 $tooltiponpriceend =
'</span>';
2264 print
'<td class="right linecolvatrate">';
2265 print $tooltiponprice;
2266 print
vatrate($line->vatrate.($line->vat_src_code ?
' ('.$line->vat_src_code.
')' :
''), true);
2267 print $tooltiponpriceend;
2271 print
'<td class="right linecolunitht">';
2272 if (!empty($line->value_unit_ht)) {
2273 print
price($line->value_unit_ht);
2275 $tmpvat =
price2num(preg_replace(
'/\s*\(.*\)/',
'', $line->vatrate));
2276 $pricenettoshow =
price2num((
float) $line->value_unit / (1 + (
float) $tmpvat / 100),
'MU');
2277 print
price($pricenettoshow);
2281 print
'<td class="right linecolunitttc">'.price($line->value_unit).
'</td>';
2283 print
'<td class="right linecolqty">'.dol_escape_htmltag((
string) $line->qty).
'</td>';
2285 if ($action !=
'editline') {
2286 print
'<td class="right linecoltotalht">'.price($line->total_ht).
'</td>';
2287 print
'<td class="right linecoltotalttc">'.price($line->total_ttc).
'</td>';
2291 print
'<td class="center linecolpreview">';
2292 if ($line->fk_ecm_files > 0) {
2293 $modulepart =
'expensereport';
2294 $maxheightmini = 32;
2296 $result = $ecmfilesstatic->fetch($line->fk_ecm_files);
2298 $relativepath = preg_replace(
'/expensereport\//',
'', $ecmfilesstatic->filepath);
2299 $fileinfo = pathinfo($ecmfilesstatic->filepath.
'/'.$ecmfilesstatic->filename);
2302 if (!
dol_is_file($conf->expensereport->dir_output.
'/'.$relativepath.
'/'.$minifile)) {
2306 $urlforhref =
getAdvancedPreviewUrl($modulepart, $relativepath.
'/'.$fileinfo[
'filename'].
'.'.strtolower($fileinfo[
'extension']), 1,
'&entity='.(empty(
$object->entity) ? $conf->entity :
$object->entity));
2307 if (empty($urlforhref)) {
2308 $urlforhref = DOL_URL_ROOT.
'/viewimage.php?modulepart='.$modulepart.
'&entity='.(empty(
$object->entity) ? $conf->entity :
$object->entity).
'&file='.urlencode($relativepath.$fileinfo[
'filename'].
'.'.strtolower($fileinfo[
'extension']));
2309 print
'<a href="'.$urlforhref.
'" class="aphoto" target="_blank" rel="noopener noreferrer">';
2311 print
'<a href="'.$urlforhref[
'url'].
'" class="'.$urlforhref[
'css'].
'" target="'.$urlforhref[
'target'].
'" mime="'.$urlforhref[
'mime'].
'">';
2313 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="">';
2316 if (preg_match(
'/\.pdf$/i', $ecmfilesstatic->filename)) {
2317 $filepdf = $conf->expensereport->dir_output.
'/'.$relativepath.
'/'.$ecmfilesstatic->filename;
2318 $fileimage = $conf->expensereport->dir_output.
'/'.$relativepath.
'/'.$ecmfilesstatic->filename.
'_preview.png';
2319 $relativepathimage = $relativepath.
'/'.$ecmfilesstatic->filename.
'_preview.png';
2321 $pdfexists = file_exists($filepdf);
2324 if (!file_exists($fileimage) || (filemtime($fileimage) < filemtime($filepdf))) {
2326 include_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
2335 if ($pdfexists && !$error) {
2336 $heightforphotref = 70;
2337 if (!empty($conf->dol_optimize_smallscreen)) {
2338 $heightforphotref = 60;
2340 $urlforhref =
getAdvancedPreviewUrl($modulepart, $relativepath.
'/'.$fileinfo[
'filename'].
'.'.strtolower($fileinfo[
'extension']), 1,
'&entity='.(empty(
$object->entity) ? $conf->entity :
$object->entity));
2341 print
'<a href="'.$urlforhref[
'url'].
'" class="'.$urlforhref[
'css'].
'" target="'.$urlforhref[
'target'].
'" mime="'.$urlforhref[
'mime'].
'">';
2343 if (file_exists($fileimage)) {
2344 print
'<img height="'.$heightforphotref.
'" class="photo photowithmargin photowithborder" src="'.DOL_URL_ROOT.
'/viewimage.php?modulepart=apercu'.$modulepart.
'&file='.urlencode($relativepathimage).
'">';
2347 print
img_mime($ecmfilesstatic->filename);
2357 print
'<td class="nowrap right linecolwarning">';
2358 print !empty($line->rule_warning_message) ?
img_warning(html_entity_decode($line->rule_warning_message)) :
'';
2363 print
'<td class="nowrap right linecolaction">';
2365 print
'<a class="editfielda reposition paddingrightonly" href="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&action=editline&token='.
newToken().
'&rowid='.$line->rowid.
'">';
2367 print
'</a> ';
2368 print
'<a class="paddingrightonly" href="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&action=delete_line&token='.
newToken().
'&rowid='.$line->rowid.
'">';
2378 if ($action ==
'editline' && $line->id ==
GETPOSTINT(
'rowid')) {
2388 print
'<!-- line of expense report -->'.
"\n";
2389 print
'<tr class="tredited">';
2391 print
'<td class="center">';
2395 print
'<td colspan="'.($colspan - 1).
'" class="liste_titre"> ';
2396 print
'<a href="" class="commonlink auploadnewfilenow reposition">'.$langs->trans(
"UploadANewFileNow");
2397 print
img_picto($langs->trans(
"UploadANewFileNow"),
'chevron-down',
'', 0, 0, 0,
'',
'marginleftonly');
2400 print
' - <a href="" class="commonlink aattachtodoc reposition">'.$langs->trans(
"AttachTheNewLineToTheDocument");
2401 print
img_picto($langs->trans(
"AttachTheNewLineToTheDocument"),
'chevron-down',
'', 0, 0, 0,
'',
'marginleftonly');
2405 print
'<!-- Code to open/close section to submit or link files in edit mode -->'.
"\n";
2406 print
'<script type="text/javascript">'.
"\n";
2407 print
'$(document).ready(function() {
2408 $( ".auploadnewfilenow" ).click(function() {
2409 jQuery(".truploadnewfilenow").toggle();
2410 jQuery(".trattachnewfilenow").hide();
2413 $( ".aattachtodoc" ).click(function() {
2414 jQuery(".trattachnewfilenow").toggle();
2415 jQuery(".truploadnewfilenow").hide();
2418 if (is_array(
GETPOST(
'attachfile',
'array')) && count(
GETPOST(
'attachfile',
'array'))) {
2419 print
'jQuery(".trattachnewfilenow").toggle();'.
"\n";
2422 jQuery("form[name=\"expensereport\"]").submit(function() {
2423 if (jQuery(".truploadnewfilenow").is(":hidden")) {
2424 jQuery("input[name=\"sendit\"]").val("");
2431 print
'</script>'.
"\n";
2434 $filenamelinked =
'';
2435 if ($line->fk_ecm_files > 0) {
2436 $result = $ecmfilesstatic->fetch($line->fk_ecm_files);
2438 $filenamelinked = $ecmfilesstatic->filename;
2442 $tredited =
'tredited';
2443 include DOL_DOCUMENT_ROOT.
'/expensereport/tpl/expensereport_addfile.tpl.php';
2444 include DOL_DOCUMENT_ROOT.
'/expensereport/tpl/expensereport_linktofile.tpl.php';
2446 print
'<tr class="oddeven tredited">';
2451 print
'<td class="center">';
2452 print $form->selectDate($line->date,
'date');
2457 print
'<td class="nowraponall">';
2458 print $formproject->select_projects(-1, (
string) $line->fk_project,
'fk_project', 0, 0, $projectRequired ? 0 : 1, 1, 0, 0, 0,
'', 1, 0,
'maxwidth300');
2463 print
'<td class="center">';
2464 print $formexpensereport->selectTypeExpenseReport($line->fk_c_type_fees,
'fk_c_type_fees');
2468 print
'<td class="fk_c_exp_tax_cat">';
2469 $params = array(
'fk_expense' =>
$object->id,
'fk_expense_det' => $line->id,
'date' => $line->date);
2470 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);
2476 print
'<textarea name="comments" class="flat_ndf centpercent">'.dol_escape_htmltag($line->comments, 0, 1).
'</textarea>';
2480 $selectedvat =
price2num($line->vatrate).(!empty($line->vat_src_code) ?
' ('.$line->vat_src_code.
')' :
'');
2481 print
'<td class="right">';
2483 print $form->load_tva(
'vatrate', (GETPOSTISSET(
"vatrate") ?
GETPOST(
"vatrate") : $selectedvat), null, null, 0, 0,
'', false, 1, 2);
2487 print
'<td class="right">';
2488 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.
' />';
2492 print
'<td class="right">';
2493 print
'<input type="text" min="0" class="right maxwidth50" id="value_unit" name="value_unit" value="'.dol_escape_htmltag(
price2num($line->value_unit)).
'" />';
2497 print
'<td class="right">';
2498 print
'<input type="text" min="0" class="input_qty right maxwidth50" name="qty" value="'.dol_escape_htmltag((
string) $line->qty).
'" />';
2505 print
'<td class="center">';
2509 print
'<td class="center">';
2513 print
'<input type="hidden" name="rowid" value="'.$line->rowid.
'">';
2514 print $form->buttonsSaveCancel(
'Save',
'Cancel', array(),
false,
'small');
2533 if ($action !=
'editline') {
2537 $nbFiles = $nbLinks = 0;
2538 $arrayoffiles = array();
2540 require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
2541 require_once DOL_DOCUMENT_ROOT.
'/core/lib/images.lib.php';
2542 require_once DOL_DOCUMENT_ROOT.
'/core/class/link.class.php';
2545 $nbFiles = count($arrayoffiles);
2550 print
'<tr class="liste_titre">';
2551 print
'<td colspan="'.$colspan.
'" class="liste_titre expensereportautoload">';
2552 print
'<a href="" class="commonlink auploadnewfilenow reposition">'.$langs->trans(
"UploadANewFileNow");
2553 print
img_picto($langs->trans(
"UploadANewFileNow"),
'chevron-down',
'', 0, 0, 0,
'',
'marginleftonly');
2556 print
' - <a href="" class="commonlink aattachtodoc reposition">'.$langs->trans(
"AttachTheNewLineToTheDocument");
2557 print
img_picto($langs->trans(
"AttachTheNewLineToTheDocument"),
'chevron-down',
'', 0, 0, 0,
'',
'marginleftonly');
2561 print
'<!-- Code to open/close section to submit or link files in the form to add new line -->'.
"\n";
2562 print
'<script type="text/javascript">'.
"\n";
2563 print
'$(document).ready(function() {
2564 $( ".auploadnewfilenow" ).click(function() {
2565 console.log("We click on toggle of auploadnewfilenow");
2566 jQuery(".truploadnewfilenow").toggle();
2567 jQuery(".trattachnewfilenow").hide();
2568 if (jQuery(".truploadnewfilenow").is(":hidden")) {
2569 jQuery("input[name=\"sendit\"]").prop("name", "senditdisabled");
2571 jQuery("input[name=\"senditdisabled\"]").prop("name", "sendit");
2573 // TODO Switch css fa-chevron-dow and add fa-chevron-up
2576 $( ".aattachtodoc" ).click(function() {
2577 console.log("We click on toggle of aattachtodoc");
2578 jQuery(".trattachnewfilenow").toggle();
2579 jQuery(".truploadnewfilenow").hide();
2580 // TODO Switch css fa-chevron-dow and add fa-chevron-up
2583 if (is_array(
GETPOST(
'attachfile',
'array')) && count(
GETPOST(
'attachfile',
'array')) && $action !=
'updateline') {
2584 print
'jQuery(".trattachnewfilenow").show();'.
"\n";
2587 jQuery("form[name=\"expensereport\"]").submit(function() {
2588 if (jQuery(".truploadnewfilenow").is(":hidden")) {
2589 /* 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. */
2590 jQuery("input[name=\"sendit\"]").val("");
2591 jQuery("input[name=\"sendit\"]").prop("name", "senditdisabled");
2593 jQuery("input[name=\"senditdisabled\"]").prop("name", "sendit");
2600 print
'</script>'.
"\n";
2604 include DOL_DOCUMENT_ROOT.
'/expensereport/tpl/expensereport_linktofile.tpl.php';
2605 include DOL_DOCUMENT_ROOT.
'/expensereport/tpl/expensereport_addfile.tpl.php';
2607 print
'<tr class="liste_titre expensereportcreate">';
2609 print
'<td class="center expensereportcreatedate">'.$langs->trans(
'Date').
'</td>';
2611 print
'<td class="minwidth100imp">'.$form->textwithpicto($langs->trans(
'Project'), $langs->trans(
"ClosedProjectsAreHidden")).
'</td>';
2613 print
'<td class="center expensereportcreatetype">'.$langs->trans(
'Type').
'</td>';
2615 print
'<td>'.$langs->trans(
'CarCategory').
'</td>';
2617 print
'<td class="expensereportcreatedescription">'.$langs->trans(
'Description').
'</td>';
2618 print
'<td class="right expensereportcreatevat">'.$langs->trans(
'VAT').
'</td>';
2619 print
'<td class="right expensereportcreatepriceuth">'.$langs->trans(
'PriceUHT').
'</td>';
2620 print
'<td class="right expensereportcreatepricettc">'.$langs->trans(
'PriceUTTC').
'</td>';
2621 print
'<td class="right expensereportcreateqty">'.$langs->trans(
'Qty').
'</td>';
2628 print
'<tr class="oddeven nohover">';
2634 print
'<td class="center inputdate">';
2635 print $form->selectDate(!empty($date) ? $date : -1,
'date', 0, 0, 0,
'', 1, 1);
2640 print
'<td class="inputproject">';
2641 $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');
2646 print
'<td class="center inputtype">';
2647 print $formexpensereport->selectTypeExpenseReport(!empty($fk_c_type_fees) ? $fk_c_type_fees :
"",
'fk_c_type_fees', 1);
2651 print
'<td class="fk_c_exp_tax_cat">';
2652 $params = array(
'fk_expense' =>
$object->id);
2653 print $form->selectExpenseCategories(
'',
'fk_c_exp_tax_cat', 1, array(),
'fk_c_type_fees', $userauthor->default_c_exp_tax_cat, $params, 0);
2658 print
'<td class="inputcomment">';
2659 print
'<textarea class="flat_ndf centpercent" name="comments" rows="'.ROWS_2.
'">'.
dol_escape_htmltag(!empty($comments) ? $comments :
"", 0, 1).
'</textarea>';
2663 print
'<td class="right inputvat">';
2667 $conf->global->MAIN_VAT_DEFAULT_IF_AUTODETECT_FAILS =
'none';
2670 print $form->load_tva(
'vatrate', (!empty($vatrate) ? $vatrate : $defaultvat), null, null, 0, 0,
'', false, 1);
2674 print
'<td class="right inputpricenet">';
2675 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.
' />';
2679 print
'<td class="right inputtax">';
2680 print
'<input type="text" class="right maxwidth50" id="value_unit" name="value_unit" value="'.dol_escape_htmltag((!empty($value_unit) ? $value_unit :
"")).
'">';
2684 print
'<td class="right inputqty">';
2685 print
'<input type="text" min="0" class=" input_qty right maxwidth50" name="qty" value="'.dol_escape_htmltag(!empty($qty) ? $qty : 1).
'">';
2691 if ($action !=
'editline') {
2692 print
'<td class="right"></td>';
2693 print
'<td class="right"></td>';
2697 print
'<td class="center inputbuttons">';
2698 print $form->buttonsSaveCancel(
"Add",
'', array(),
true,
'reposition');
2709 /* JQuery for product free or predefined select */
2710 jQuery(document).ready(function() {
2711 jQuery("#value_unit_ht").keyup(function(event) {
2712 console.log(event.which); // discard event tag and arrows
2713 if (event.which != 9 && (event.which < 37 ||event.which > 40) && jQuery("#value_unit_ht").val() != "") {
2714 jQuery("#value_unit").val("");
2717 jQuery("#value_unit").keyup(function(event) {
2718 console.log(event.which); // discard event tag and arrows
2719 if (event.which != 9 && (event.which < 37 || event.which > 40) && jQuery("#value_unit").val() != "") {
2720 jQuery("#value_unit_ht").val("");
2728 /* unit price coef calculation */
2729 jQuery(".input_qty, #fk_c_type_fees, #select_fk_c_exp_tax_cat, #vatrate ").change(function(event) {
2730 console.log("We change a parameter");
2732 let type_fee = jQuery("#fk_c_type_fees").find(":selected").val();
2733 let tax_cat = jQuery("#select_fk_c_exp_tax_cat").find(":selected").val();
2734 let tva = jQuery("#vatrate").find(":selected").val();
2735 let qty = jQuery(".input_qty").val();
2737 let path = "'.DOL_URL_ROOT.
'/expensereport/ajax/ajaxik.php";
2738 path += "?fk_c_exp_tax_cat="+tax_cat;
2739 path += "&fk_expense="+'.((int)
$object->id).
';
2740 path += "&vatrate="+tva;
2741 path += "&qty="+qty;
2743 if (type_fee == 4) { // frais_kilométriques
2744 if (tax_cat == "" || parseInt(tax_cat) <= 0){
2752 success: function(response) {
2753 if (response.response_status == "success"){';
2757 jQuery("#value_unit").val(parseFloat(response.data) * (100 + parseFloat(tva)) / 100);
2758 jQuery("#value_unit").trigger("change");
2762 jQuery("#value_unit_ht").val(response.data);
2763 jQuery("#value_unit_ht").trigger("change");
2764 jQuery("#value_unit").val("");
2769 } else if(response.response_status == "error" && response.errorMessage != undefined && response.errorMessage.length > 0 ) {
2770 console.log("We get an error result");
2771 $.jnotify(response.errorMessage, "error", {timeout: 0, type: "error"},{ remove: function (){} } );
2777 /*console.log(event.which); // discard event tag and arrows
2778 if (event.which != 9 && (event.which < 37 || event.which > 40) && jQuery("#value_unit").val() != "") {
2779 jQuery("#value_unit_ht").val("");
2799 print
'Record not found';
2810print
'<div class="tabsAction">';
2812if ($action !=
'create' && $action !=
'edit' && $action !=
'editline') {
2817 if (empty($user->socid)) {
2819 print
dolGetButtonAction(
'', $langs->trans(
'SendMail'),
'email',
dolBuildUrl($_SERVER[
"PHP_SELF"], [
'id' =>
$object->id,
'action' =>
'presend',
'mode' =>
'init'],
true).
'#formmailbeforetitle',
'');
2829 if (in_array(
$object->fk_user_author, $childids) || $user->hasRight(
'expensereport',
'writeall_advance')) {
2831 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>';
2834 if (count(
$object->lines) > 0) {
2835 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>';
2846 if ($user->id ==
$object->fk_user_author || $user->id ==
$object->fk_user_valid) {
2848 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>';
2853 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>';
2858 if ($user->id ==
$object->fk_user_author || $user->id ==
$object->fk_user_valid) {
2860 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>';
2870 if (in_array(
$object->fk_user_author, $childids)) {
2872 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>';
2880 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>';
2882 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>';
2885 if ($user->id ==
$object->fk_user_author || $user->id ==
$object->fk_user_valid) {
2887 print
'<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER[
"PHP_SELF"].
'?action=cancel&id='.
$object->id.
'">'.$langs->trans(
"Cancel").
'</a></div>';
2896 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>';
2902 if ($remaintopay == 0) {
2903 print
'<div class="inline-block divButAction"><span class="butActionRefused classfortooltip" title="'.$langs->trans(
"DisabledBecauseRemainderToPayIsZero").
'">'.$langs->trans(
'DoPayment').
'</span></div>';
2905 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>';
2913 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>";
2919 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>';
2928 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>';
2933 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>';
2937 if ($user->hasRight(
'expensereport',
'creer')) {
2938 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>';
2944 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>';
2947 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>';
2950 $parameters = array();
2951 $reshook = $hookmanager->executeHooks(
'addMoreActionsButtons', $parameters, $object, $action);
2958if (
GETPOST(
'modelselected',
'alpha')) {
2959 $action =
'presend';
2962if ($action !=
'presend') {
2967 print
'<div class="fichecenter"><div class="fichehalfleft">';
2968 print
'<a name="builddoc"></a>';
2970 if ($user->hasRight(
'expensereport',
'creer') && $action !=
'create' && $action !=
'edit') {
2973 $urlsource = $_SERVER[
"PHP_SELF"].
"?id=".
$object->id;
2974 $genallowed = $user->hasRight(
'expensereport',
'creer');
2975 $delallowed = $user->hasRight(
'expensereport',
'creer');
2977 print $formfile->showdocuments(
'expensereport', $filename, $filedir, $urlsource, $genallowed, $delallowed);
2978 $somethingshown = $formfile->numoffiles;
2994 print
'</div><div class="fichehalfright">';
2996 include_once DOL_DOCUMENT_ROOT.
'/core/class/html.formactions.class.php';
2998 $somethingshown = $formactions->showactions($object,
'expensereport', 0);
3000 print
'</div></div>';
3004$modelmail =
'expensereport_send';
3005$defaulttopic =
'SendExpenseReportRef';
3006$diroutput = $conf->expensereport->dir_output;
3007$trackid =
'exp'.$object->id;
3009include DOL_DOCUMENT_ROOT.
'/core/tpl/card_presend.tpl.php';
$id
Support class for third parties, contacts, members, users or resources.
if(! $sortfield) if(! $sortorder) $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_now($mode='gmt')
Return date for now.
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.
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.
dolBuildUrl($url, $params=[], $addtoken=false)
Return path of url.
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.
dol_sanitizeFileName($str, $newstr='_', $unaccent=1, $includequotes=0, $allowdash=0)
Clean a string to use it as a file name.
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.
img_mime($file, $titlealt='', $morecss='')
Show MIME img of a file.
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
newToken()
Return the value of token currently saved into session with name 'newtoken'.
dolGetButtonAction($label, $text='', $actionType='default', $url='', $id='', $userRight=1, $params=array())
Function dolGetButtonAction.
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($srcobject, $native=2)
Create a clone of instance of object (new instance with same value for each properties) With native =...
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs=null, $encodetooutput=false, $decorate=0)
Output date in a string format according to outputlangs (or langs if not defined).
dol_print_error($db=null, $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
load_fiche_titre($title, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='', $morecssonpicto='widthpictotitle')
Load a title with picto.
isValidEmail($address, $acceptsupervisorkey=0, $acceptuserkey=0)
Return true if email syntax is ok.
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
isModEnabled($module)
Is Dolibarr module enabled.
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.
if(getDolGlobalString( 'TAKEPOS_SHOW_CUSTOMER')) print $langs trans('Date')." left Label right Qty right Price right TotalHT right TotalTTC right right right right right right right right right centpercent right TotalHT right n right VAT right n right TotalVAT right n No sujeto a RE IRPF right TotalLT1 right n right TotalLT2 right n right TotalTTC right n takeposcustomercurrency takeposcustomercurrency takeposcustomercurrency takeposcustomercurrency right TotalTTC takeposcustomercurrency right takeposcustomercurrency n right PaymentTypeShortLIQ right SELECT p pos_change as p datep as date
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.