30require
'../main.inc.php';
31require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formexpensereport.class.php';
32require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formfile.class.php';
33require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formmail.class.php';
34require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formprojet.class.php';
35require_once DOL_DOCUMENT_ROOT.
'/core/class/CMailFile.class.php';
36require_once DOL_DOCUMENT_ROOT.
'/projet/class/project.class.php';
37require_once DOL_DOCUMENT_ROOT.
'/ecm/class/ecmfiles.class.php';
38require_once DOL_DOCUMENT_ROOT.
'/compta/bank/class/account.class.php';
39require_once DOL_DOCUMENT_ROOT.
'/core/lib/expensereport.lib.php';
40require_once DOL_DOCUMENT_ROOT.
'/core/lib/price.lib.php';
41require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
42require_once DOL_DOCUMENT_ROOT.
'/core/lib/images.lib.php';
43require_once DOL_DOCUMENT_ROOT.
'/core/modules/expensereport/modules_expensereport.php';
44require_once DOL_DOCUMENT_ROOT.
'/expensereport/class/expensereport.class.php';
45require_once DOL_DOCUMENT_ROOT.
'/expensereport/class/paymentexpensereport.class.php';
46require_once DOL_DOCUMENT_ROOT.
'/core/class/doleditor.class.php';
47require_once DOL_DOCUMENT_ROOT.
'/core/class/extrafields.class.php';
48if (isModEnabled(
'accounting')) {
49 require_once DOL_DOCUMENT_ROOT.
'/accountancy/class/accountingjournal.class.php';
53$langs->loadLangs(array(
"trips",
"bills",
"mails"));
55$action =
GETPOST(
'action',
'aZ09');
56$cancel =
GETPOST(
'cancel',
'alpha');
57$confirm =
GETPOST(
'confirm',
'alpha');
58$backtopage =
GETPOST(
'backtopage',
'alpha');
64$fk_project =
GETPOST(
'fk_project',
'int');
65$vatrate =
GETPOST(
'vatrate',
'alpha');
67$comments =
GETPOST(
'comments',
'restricthtml');
68$fk_c_type_fees =
GETPOST(
'fk_c_type_fees',
'int');
71$childids = $user->getAllChildIds(1);
73if (!empty($conf->global->EXPENSEREPORT_PREFILL_DATES_WITH_CURRENT_MONTH)) {
74 if (empty($date_start)) {
78 if (empty($date_end)) {
85$rootfordata = DOL_DATA_ROOT;
86$rootforuser = DOL_DATA_ROOT;
88if (isModEnabled(
'multicompany') && !empty($conf->entity) && $conf->entity > 1) {
89 $rootfordata .=
'/'.$conf->entity;
91$conf->expensereport->dir_output = $rootfordata.
'/expensereport';
94$urlwithouturlroot = preg_replace(
'/'.preg_quote(DOL_URL_ROOT,
'/').
'$/i',
'', trim($dolibarr_main_url_root));
95$urlwithroot = $urlwithouturlroot.DOL_URL_ROOT;
99$hidedetails = (
GETPOST(
'hidedetails',
'int') ?
GETPOST(
'hidedetails',
'int') : (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DETAILS) ? 1 : 0));
100$hidedesc = (
GETPOST(
'hidedesc',
'int') ?
GETPOST(
'hidedesc',
'int') : (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DESC) ? 1 : 0));
101$hideref = (
GETPOST(
'hideref',
'int') ?
GETPOST(
'hideref',
'int') : (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_REF) ? 1 : 0));
108$extrafields->fetch_name_optionals_label($object->table_element);
111include DOL_DOCUMENT_ROOT.
'/core/actions_fetchobject.inc.php';
114$hookmanager->initHooks(array(
'expensereportcard',
'globalcard'));
116$permissionnote = $user->rights->expensereport->creer;
117$permissiondellink = $user->rights->expensereport->creer;
118$permissiontoadd = $user->rights->expensereport->creer;
122$projectRequired = isModEnabled(
'project') && !empty($conf->global->EXPENSEREPORT_PROJECT_IS_REQUIRED);
123$fileRequired = !empty($conf->global->EXPENSEREPORT_FILE_IS_REQUIRED);
125if ($object->id > 0) {
128 if (!empty($user->rights->expensereport->readall)) {
131 if (!empty($user->rights->expensereport->lire) && in_array($object->fk_user_author, $childids)) {
140if (!empty($user->rights->expensereport->supprimer)) {
143if ($object->statut ==
ExpenseReport::STATUS_DRAFT && $user->hasRight(
'expensereport',
'write') && in_array($object->fk_user_author, $childids)) {
149 $socid = $user->socid;
151$result =
restrictedArea($user,
'expensereport', $object->id,
'expensereport');
153$permissiontoadd = $user->rights->expensereport->creer;
163$parameters = array(
'socid' => $socid);
164$reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
169if (empty($reshook)) {
170 $backurlforlist = DOL_URL_ROOT.
'/expensereport/list.php';
172 if (empty($backtopage) || ($cancel && empty($id))) {
173 if (empty($backtopage) || ($cancel && strpos($backtopage,
'__ID__'))) {
174 if (empty($id) && (($action !=
'add' && $action !=
'create') || $cancel)) {
175 $backtopage = $backurlforlist;
177 $backtopage = DOL_URL_ROOT.
'/expensereport/card.php?id='.((!empty($id) && $id > 0) ? $id :
'__ID__');
183 if (!empty($backtopageforcancel)) {
184 header(
"Location: ".$backtopageforcancel);
186 } elseif (!empty($backtopage)) {
187 header(
"Location: ".$backtopage);
201 $fk_c_type_fees = -1;
204 include DOL_DOCUMENT_ROOT.
'/core/actions_linkedfiles.inc.php';
206 if (!empty(
GETPOST(
'sendit',
'alpha'))) {
207 if ($action ==
'updateline') {
208 $action =
'editline';
214 include DOL_DOCUMENT_ROOT.
'/core/actions_setnotes.inc.php';
216 include DOL_DOCUMENT_ROOT.
'/core/actions_dellink.inc.php';
218 include DOL_DOCUMENT_ROOT.
'/core/actions_lineupdown.inc.php';
221 if ($action ==
'confirm_clone' && $confirm ==
'yes' && $user->rights->expensereport->creer) {
222 if (1 == 0 && !
GETPOST(
'clone_content',
'alpha') && !
GETPOST(
'clone_receivers',
'alpha')) {
225 if ($object->id > 0) {
227 $orig = clone $object;
229 $result = $object->createFromClone($user,
GETPOST(
'fk_user_author',
'int'));
231 header(
"Location: ".$_SERVER[
'PHP_SELF'].
'?id='.$result);
242 if ($action ==
'confirm_delete' &&
GETPOST(
"confirm",
'alpha') ==
"yes" && $id > 0 && $candelete) {
244 $result = $object->fetch($id);
245 $result = $object->delete($user);
247 header(
"Location: index.php");
254 if ($action ==
'add' && $user->rights->expensereport->creer) {
259 $object->date_debut = $date_start;
260 $object->date_fin = $date_end;
262 $object->fk_user_author =
GETPOST(
'fk_user_author',
'int');
263 if (!($object->fk_user_author > 0)) {
264 $object->fk_user_author = $user->id;
268 if ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && empty($user->rights->expensereport->creer))
269 || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && empty($user->rights->expensereport->creer) && empty($user->rights->expensereport->writeall_advance))) {
274 if (empty($conf->global->MAIN_USE_ADVANCED_PERMS) || empty($user->rights->expensereport->writeall_advance)) {
275 if (!in_array($object->fk_user_author, $childids)) {
282 $fuser =
new User($db);
283 $fuser->fetch($object->fk_user_author);
286 $object->fk_c_paiement =
GETPOST(
'fk_c_paiement',
'int');
287 $object->fk_user_validator =
GETPOST(
'fk_user_validator',
'int');
288 $object->note_public =
GETPOST(
'note_public',
'restricthtml');
289 $object->note_private =
GETPOST(
'note_private',
'restricthtml');
292 $ret = $extrafields->setOptionalsFromPost(
null, $object);
298 if (!$error && empty($conf->global->EXPENSEREPORT_ALLOW_OVERLAPPING_PERIODS)) {
299 $overlappingExpenseReportID = $object->periode_existe($fuser, $object->date_debut, $object->date_fin);
301 if ($overlappingExpenseReportID > 0) {
303 setEventMessages($langs->trans(
"ErrorDoubleDeclaration").
' <a href="'.$_SERVER[
'PHP_SELF'].
'?id='.$overlappingExpenseReportID.
'">'. $langs->trans(
'ShowTrip').
'</a>',
null,
'errors');
311 $id = $object->create($user);
318 Header(
"Location: ".$_SERVER[
"PHP_SELF"].
"?id=".$id);
328 if (($action ==
'update' || $action ==
'updateFromRefuse') && $user->rights->expensereport->creer) {
332 $object->date_debut = $date_start;
333 $object->date_fin = $date_end;
335 if ($object->status < 3) {
336 $object->fk_user_validator =
GETPOST(
'fk_user_validator',
'int');
339 $object->fk_c_paiement =
GETPOST(
'fk_c_paiement',
'int');
340 $object->note_public =
GETPOST(
'note_public',
'restricthtml');
341 $object->note_private =
GETPOST(
'note_private',
'restricthtml');
342 $object->fk_user_modif = $user->id;
344 $result = $object->update($user);
346 header(
"Location: ".$_SERVER[
"PHP_SELF"].
"?id=".
GETPOST(
'id',
'int'));
353 if ($action ==
'update_extras') {
357 $ret = $extrafields->setOptionalsFromPost(
null, $object,
GETPOST(
'attribute',
'restricthtml'));
364 $result = $object->insertExtraFields(
'EXPENSEREPORT_MODIFY');
372 $action =
'edit_extras';
376 if ($action ==
"confirm_validate" &&
GETPOST(
"confirm",
'alpha') ==
"yes" && $id > 0 && $user->rights->expensereport->creer) {
384 $result = $object->setValidate($user);
388 if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) {
389 $outputlangs = $langs;
392 $newlang =
GETPOST(
'lang_id',
'aZ09');
395 $newlang = $object->thirdparty->default_lang;
397 if (!empty($newlang)) {
399 $outputlangs->setDefaultLang($newlang);
401 $model = $object->model_pdf;
402 $ret = $object->fetch($id);
404 $object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref);
411 if (!$error && $result > 0 && $object->fk_user_validator > 0) {
412 $langs->load(
"mails");
415 $destinataire =
new User($db);
416 $destinataire->fetch($object->fk_user_validator);
417 $emailTo = $destinataire->email;
420 $expediteur =
new User($db);
421 $expediteur->fetch($object->fk_user_author);
422 $emailFrom = $conf->global->MAIN_MAIL_EMAIL_FROM;
424 if ($emailTo && $emailFrom) {
425 $filename = array(); $filedir = array(); $mimetype = array();
428 $societeName = $conf->global->MAIN_INFO_SOCIETE_NOM;
429 if (!empty($conf->global->MAIN_APPLICATION_TITLE)) {
430 $societeName = $conf->global->MAIN_APPLICATION_TITLE;
433 $subject = $societeName.
" - ".$langs->transnoentities(
"ExpenseReportWaitingForApproval");
436 $link = $urlwithroot.
'/expensereport/card.php?id='.$object->id;
437 $link =
'<a href="'.$link.
'">'.$link.
'</a>';
438 $message = $langs->transnoentities(
"ExpenseReportWaitingForApprovalMessage", $expediteur->getFullName($langs),
get_date_range($object->date_debut, $object->date_fin,
'', $langs), $link);
453 $mailfile =
new CMailFile($subject, $emailTo, $emailFrom, $message, $filedir, $mimetype, $filename,
'',
'', 0, -1);
457 $result = $mailfile->sendfile();
459 $mesg = $langs->trans(
'MailSuccessfulySent', $mailfile->getValidAddress($emailFrom, 2), $mailfile->getValidAddress($emailTo, 2));
462 $langs->load(
"other");
463 if (!empty($mailfile->error) || !empty($mailfile->errors)) {
466 if (!empty($mailfile->error)) {
467 $mesg .=
'<br>' . $mailfile->error;
469 if (!empty($mailfile->errors) && is_array($mailfile->errors)) {
470 $mesg .=
'<br>' . implode(
'<br>', $mailfile->errors);
474 setEventMessages(
'No mail sent. Feature is disabled by option MAIN_DISABLE_ALL_MAILS',
null,
'warnings');
482 setEventMessages($langs->trans(
"NoEmailSentBadSenderOrRecipientEmail"),
null,
'warnings');
489 header(
"Location: ".$_SERVER[
"PHP_SELF"].
"?id=".$id);
496 if ($action ==
"confirm_save_from_refuse" &&
GETPOST(
"confirm",
'alpha') ==
"yes" && $id > 0 && $user->rights->expensereport->creer) {
499 $result = $object->set_save_from_refuse($user);
503 if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) {
504 $outputlangs = $langs;
507 $newlang =
GETPOST(
'lang_id',
'aZ09');
510 $newlang = $object->thirdparty->default_lang;
512 if (!empty($newlang)) {
514 $outputlangs->setDefaultLang($newlang);
516 $model = $object->model_pdf;
517 $ret = $object->fetch($id);
519 $object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref);
527 $destinataire =
new User($db);
528 $destinataire->fetch($object->fk_user_validator);
529 $emailTo = $destinataire->email;
532 $expediteur =
new User($db);
533 $expediteur->fetch($object->fk_user_author);
534 $emailFrom = $conf->global->MAIN_MAIL_EMAIL_FROM;
536 if ($emailFrom && $emailTo) {
537 $filename = array(); $filedir = array(); $mimetype = array();
540 $societeName = $conf->global->MAIN_INFO_SOCIETE_NOM;
541 if (!empty($conf->global->MAIN_APPLICATION_TITLE)) {
542 $societeName = $conf->global->MAIN_APPLICATION_TITLE;
545 $subject = $societeName.
" - ".$langs->transnoentities(
"ExpenseReportWaitingForReApproval");
548 $link = $urlwithroot.
'/expensereport/card.php?id='.$object->id;
549 $link =
'<a href="'.$link.
'">'.$link.
'</a>';
550 $message = $langs->transnoentities(
"ExpenseReportWaitingForReApprovalMessage",
dol_print_date($object->date_refuse,
'day'), $object->detail_refuse, $expediteur->getFullName($langs),
get_date_range($object->date_debut, $object->date_fin,
'', $langs), $link);
569 $mailfile =
new CMailFile($subject, $emailTo, $emailFrom, $message, $filedir, $mimetype, $filename,
'',
'', 0, -1);
573 $result = $mailfile->sendfile();
575 $mesg = $langs->trans(
'MailSuccessfulySent', $mailfile->getValidAddress($emailFrom, 2), $mailfile->getValidAddress($emailTo, 2));
577 header(
"Location: ".$_SERVER[
"PHP_SELF"].
"?id=".$id);
580 $langs->load(
"other");
581 if ($mailfile->error) {
583 $mesg .= $langs->trans(
'ErrorFailedToSendMail', $emailFrom, $emailTo);
584 $mesg .=
'<br>'.$mailfile->error;
587 setEventMessages(
'No mail sent. Feature is disabled by option MAIN_DISABLE_ALL_MAILS',
null,
'warnings');
595 setEventMessages($langs->trans(
"NoEmailSentBadSenderOrRecipientEmail"),
null,
'warnings');
604 if ($action ==
"confirm_approve" &&
GETPOST(
"confirm",
'alpha') ==
"yes" && $id > 0 && $user->rights->expensereport->approve) {
608 $result = $object->setApproved($user);
612 if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) {
613 $outputlangs = $langs;
616 $newlang =
GETPOST(
'lang_id',
'aZ09');
619 $newlang = $object->thirdparty->default_lang;
621 if (!empty($newlang)) {
623 $outputlangs->setDefaultLang($newlang);
625 $model = $object->model_pdf;
626 $ret = $object->fetch($id);
628 $object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref);
636 $destinataire =
new User($db);
637 $destinataire->fetch($object->fk_user_author);
638 $emailTo = $destinataire->email;
641 $emailCC = $conf->global->NDF_CC_EMAILS;
642 if (empty($emailTo)) {
647 $expediteur =
new User($db);
648 $expediteur->fetch($object->fk_user_approve > 0 ? $object->fk_user_approve : $object->fk_user_validator);
649 $emailFrom = $conf->global->MAIN_MAIL_EMAIL_FROM;
651 if ($emailFrom && $emailTo) {
652 $filename = array(); $filedir = array(); $mimetype = array();
655 $societeName = $conf->global->MAIN_INFO_SOCIETE_NOM;
656 if (!empty($conf->global->MAIN_APPLICATION_TITLE)) {
657 $societeName = $conf->global->MAIN_APPLICATION_TITLE;
660 $subject = $societeName.
" - ".$langs->transnoentities(
"ExpenseReportApproved");
663 $link = $urlwithroot.
'/expensereport/card.php?id='.$object->id;
664 $link =
'<a href="'.$link.
'">'.$link.
'</a>';
665 $message = $langs->transnoentities(
"ExpenseReportApprovedMessage", $object->ref, $destinataire->getFullName($langs), $expediteur->getFullName($langs), $link);
682 $mailfile =
new CMailFile($subject, $emailTo, $emailFrom, $message, $filedir, $mimetype, $filename,
'',
'', 0, -1);
686 $result = $mailfile->sendfile();
688 $mesg = $langs->trans(
'MailSuccessfulySent', $mailfile->getValidAddress($emailFrom, 2), $mailfile->getValidAddress($emailTo, 2));
690 header(
"Location: ".$_SERVER[
"PHP_SELF"].
"?id=".$id);
693 $langs->load(
"other");
694 if ($mailfile->error) {
696 $mesg .= $langs->trans(
'ErrorFailedToSendMail', $emailFrom, $emailTo);
697 $mesg .=
'<br>'.$mailfile->error;
700 setEventMessages(
'No mail sent. Feature is disabled by option MAIN_DISABLE_ALL_MAILS',
null,
'warnings');
708 setEventMessages($langs->trans(
"NoEmailSentBadSenderOrRecipientEmail"),
null,
'warnings');
717 if ($action ==
"confirm_refuse" &&
GETPOST(
'confirm',
'alpha') ==
"yes" && $id > 0 && $user->rights->expensereport->approve) {
721 $detailRefuse =
GETPOST(
'detail_refuse',
'alpha');
722 $result = $object->setDeny($user, $detailRefuse);
726 if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) {
727 $outputlangs = $langs;
730 $newlang =
GETPOST(
'lang_id',
'aZ09');
733 $newlang = $object->thirdparty->default_lang;
735 if (!empty($newlang)) {
737 $outputlangs->setDefaultLang($newlang);
739 $model = $object->model_pdf;
740 $ret = $object->fetch($id);
742 $object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref);
750 $destinataire =
new User($db);
751 $destinataire->fetch($object->fk_user_author);
752 $emailTo = $destinataire->email;
755 $expediteur =
new User($db);
756 $expediteur->fetch($object->fk_user_refuse);
757 $emailFrom = $conf->global->MAIN_MAIL_EMAIL_FROM;
759 if ($emailFrom && $emailTo) {
760 $filename = array(); $filedir = array(); $mimetype = array();
763 $societeName = $conf->global->MAIN_INFO_SOCIETE_NOM;
764 if (!empty($conf->global->MAIN_APPLICATION_TITLE)) {
765 $societeName = $conf->global->MAIN_APPLICATION_TITLE;
768 $subject = $societeName.
" - ".$langs->transnoentities(
"ExpenseReportRefused");
771 $link = $urlwithroot.
'/expensereport/card.php?id='.$object->id;
772 $link =
'<a href="'.$link.
'">'.$link.
'</a>';
773 $message = $langs->transnoentities(
"ExpenseReportRefusedMessage", $object->ref, $destinataire->getFullName($langs), $expediteur->getFullName($langs), $detailRefuse, $link);
791 $mailfile =
new CMailFile($subject, $emailTo, $emailFrom, $message, $filedir, $mimetype, $filename,
'',
'', 0, -1);
795 $result = $mailfile->sendfile();
797 $mesg = $langs->trans(
'MailSuccessfulySent', $mailfile->getValidAddress($emailFrom, 2), $mailfile->getValidAddress($emailTo, 2));
799 header(
"Location: ".$_SERVER[
"PHP_SELF"].
"?id=".$id);
802 $langs->load(
"other");
803 if ($mailfile->error) {
805 $mesg .= $langs->trans(
'ErrorFailedToSendMail', $emailFrom, $emailTo);
806 $mesg .=
'<br>'.$mailfile->error;
809 setEventMessages(
'No mail sent. Feature is disabled by option MAIN_DISABLE_ALL_MAILS',
null,
'warnings');
817 setEventMessages($langs->trans(
"NoEmailSentBadSenderOrRecipientEmail"),
null,
'warnings');
827 if ($action ==
"confirm_cancel" &&
GETPOST(
'confirm',
'alpha') ==
"yes" && $id > 0 && $user->rights->expensereport->creer) {
828 if (!
GETPOST(
'detail_cancel',
'alpha')) {
829 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Comment")),
null,
'errors');
834 if ($user->id == $object->fk_user_valid || $user->id == $object->fk_user_author) {
835 $detailCancel =
GETPOST(
'detail_cancel',
'alpha');
836 $result = $object->set_cancel($user, $detailCancel);
840 if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) {
841 $outputlangs = $langs;
844 $newlang =
GETPOST(
'lang_id',
'aZ09');
847 $newlang = $object->thirdparty->default_lang;
849 if (!empty($newlang)) {
851 $outputlangs->setDefaultLang($newlang);
853 $model = $object->model_pdf;
854 $ret = $object->fetch($id);
856 $object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref);
864 $destinataire =
new User($db);
865 $destinataire->fetch($object->fk_user_author);
866 $emailTo = $destinataire->email;
869 $expediteur =
new User($db);
870 $expediteur->fetch($object->fk_user_cancel);
871 $emailFrom = $conf->global->MAIN_MAIL_EMAIL_FROM;
873 if ($emailFrom && $emailTo) {
874 $filename = array(); $filedir = array(); $mimetype = array();
877 $societeName = $conf->global->MAIN_INFO_SOCIETE_NOM;
878 if (!empty($conf->global->MAIN_APPLICATION_TITLE)) {
879 $societeName = $conf->global->MAIN_APPLICATION_TITLE;
882 $subject = $societeName.
" - ".$langs->transnoentities(
"ExpenseReportCanceled");
885 $link = $urlwithroot.
'/expensereport/card.php?id='.$object->id;
886 $link =
'<a href="'.$link.
'">'.$link.
'</a>';
887 $message = $langs->transnoentities(
"ExpenseReportCanceledMessage", $object->ref, $destinataire->getFullName($langs), $expediteur->getFullName($langs), $detailCancel, $link);
905 $mailfile =
new CMailFile($subject, $emailTo, $emailFrom, $message, $filedir, $mimetype, $filename,
'',
'', 0, -1);
909 $result = $mailfile->sendfile();
911 $mesg = $langs->trans(
'MailSuccessfulySent', $mailfile->getValidAddress($emailFrom, 2), $mailfile->getValidAddress($emailTo, 2));
913 header(
"Location: ".$_SERVER[
"PHP_SELF"].
"?id=".$id);
916 $langs->load(
"other");
917 if ($mailfile->error) {
919 $mesg .= $langs->trans(
'ErrorFailedToSendMail', $emailFrom, $emailTo);
920 $mesg .=
'<br>'.$mailfile->error;
923 setEventMessages(
'No mail sent. Feature is disabled by option MAIN_DISABLE_ALL_MAILS',
null,
'warnings');
931 setEventMessages($langs->trans(
"NoEmailSentBadSenderOrRecipientEmail"),
null,
'warnings');
944 if ($action ==
"confirm_setdraft" &&
GETPOST(
'confirm',
'alpha') ==
"yes" && $id > 0 && $user->rights->expensereport->creer) {
947 if ($user->id == $object->fk_user_author || $user->id == $object->fk_user_valid) {
948 $result = $object->setStatut(0);
952 if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) {
953 $outputlangs = $langs;
956 $newlang =
GETPOST(
'lang_id',
'aZ09');
959 $newlang = $object->thirdparty->default_lang;
961 if (!empty($newlang)) {
963 $outputlangs->setDefaultLang($newlang);
965 $model = $object->model_pdf;
966 $ret = $object->fetch($id);
968 $object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref);
973 header(
"Location: ".$_SERVER[
"PHP_SELF"].
"?id=".$id);
983 if ($action ==
'set_unpaid' && $id > 0 && $user->rights->expensereport->to_paid) {
987 $result = $object->setUnpaid($user);
991 if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) {
992 $outputlangs = $langs;
995 $newlang =
GETPOST(
'lang_id',
'aZ09');
998 $newlang = $object->thirdparty->default_lang;
1000 if (!empty($newlang)) {
1001 $outputlangs =
new Translate(
"", $conf);
1002 $outputlangs->setDefaultLang($newlang);
1004 $model = $object->model_pdf;
1005 $ret = $object->fetch($id);
1007 $object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref);
1012 if ($action ==
'set_paid' && $id > 0 && $user->rights->expensereport->to_paid) {
1014 $object->fetch($id);
1016 $result = $object->setPaid($id, $user);
1020 if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) {
1021 $outputlangs = $langs;
1024 $newlang =
GETPOST(
'lang_id',
'aZ09');
1027 $newlang = $object->thirdparty->default_lang;
1029 if (!empty($newlang)) {
1030 $outputlangs =
new Translate(
"", $conf);
1031 $outputlangs->setDefaultLang($newlang);
1033 $model = $object->model_pdf;
1034 $ret = $object->fetch($id);
1036 $object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref);
1044 $destinataire =
new User($db);
1045 $destinataire->fetch($object->fk_user_author);
1046 $emailTo = $destinataire->email;
1049 $expediteur =
new User($db);
1050 $expediteur->fetch($user->id);
1051 $emailFrom = $conf->global->MAIN_MAIL_EMAIL_FROM;
1053 if ($emailFrom && $emailTo) {
1054 $filename = array(); $filedir = array(); $mimetype = array();
1057 $societeName = $conf->global->MAIN_INFO_SOCIETE_NOM;
1058 if (!empty($conf->global->MAIN_APPLICATION_TITLE)) {
1059 $societeName = $conf->global->MAIN_APPLICATION_TITLE;
1062 $subject = $societeName.
" - ".$langs->transnoentities(
"ExpenseReportPaid");
1065 $link = $urlwithroot.
'/expensereport/card.php?id='.$object->id;
1066 $link =
'<a href="'.$link.
'">'.$link.
'</a>';
1067 $message = $langs->transnoentities(
"ExpenseReportPaidMessage", $object->ref, $destinataire->getFullName($langs), $expediteur->getFullName($langs), $link);
1070 $object->setDocModel($user,
"");
1071 $resultPDF = expensereport_pdf_create($db, $object,
'',
"", $langs);
1074 $mailfile =
new CMailFile($subject, $emailTo, $emailFrom, $message, $filedir, $mimetype, $filename,
'',
'', 0, -1);
1078 $result = $mailfile->sendfile();
1080 $mesg = $langs->trans(
'MailSuccessfulySent', $mailfile->getValidAddress($emailFrom, 2), $mailfile->getValidAddress($emailTo, 2));
1082 header(
"Location: ".$_SERVER[
"PHP_SELF"].
"?id=".$id);
1085 $langs->load(
"other");
1086 if ($mailfile->error) {
1088 $mesg .= $langs->trans(
'ErrorFailedToSendMail', $emailFrom, $emailTo);
1089 $mesg .=
'<br>'.$mailfile->error;
1092 setEventMessages(
'No mail sent. Feature is disabled by option MAIN_DISABLE_ALL_MAILS',
null,
'warnings');
1100 setEventMessages($langs->trans(
"NoEmailSentBadSenderOrRecipientEmail"),
null,
'warnings');
1109 if ($action ==
"addline" && $user->rights->expensereport->creer) {
1114 if (GETPOSTISSET(
'attachfile')) {
1115 $arrayoffiles =
GETPOST(
'attachfile',
'array');
1116 if (is_array($arrayoffiles) && !empty($arrayoffiles[0])) {
1117 include_once DOL_DOCUMENT_ROOT.
'/ecm/class/ecmfiles.class.php';
1118 $entityprefix = ($conf->entity !=
'1') ? $conf->entity.
'/' :
'';
1119 $relativepath =
'expensereport/'.$object->ref.
'/'.$arrayoffiles[0];
1121 $ecmfiles->fetch(0,
'', $relativepath);
1122 $fk_ecm_files = $ecmfiles->id;
1127 if (empty($vatrate)) {
1130 $tmpvat =
price2num(preg_replace(
'/\s*\(.*\)/',
'', $vatrate));
1134 if (empty($value_unit)) {
1135 $value_unit =
price2num($value_unit_ht + ($value_unit_ht * $tmpvat / 100),
'MU');
1138 $fk_c_exp_tax_cat =
GETPOST(
'fk_c_exp_tax_cat',
'int');
1145 if (!($fk_c_type_fees > 0)) {
1147 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Type")),
null,
'errors');
1151 if ((
float) $tmpvat < 0 || $tmpvat ===
'') {
1153 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"VAT")),
null,
'errors');
1158 if (empty($date) || $date ==
"--") {
1160 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Date")),
null,
'errors');
1161 } elseif ($date < $object->date_debut || $date > ($object->date_fin + (24 * 3600 - 1))) {
1163 $langs->load(
"errors");
1164 setEventMessages($langs->trans(
"WarningDateOfLineMustBeInExpenseReportRange"),
null,
'warnings');
1168 if ($value_unit == 0) {
1170 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"PriceUTTC")),
null,
'errors');
1174 if ($projectRequired && $fk_project <= 0) {
1176 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Project")),
null,
'errors');
1180 if ($fileRequired && $fk_ecm_files == 0) {
1182 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"File")),
null,
'errors');
1189 $result = $object->addline($qty, $value_unit, $fk_c_type_fees, $vatrate, $date, $comments, $fk_project, $fk_c_exp_tax_cat, $type, $fk_ecm_files);
1191 $ret = $object->fetch($object->id);
1193 if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) {
1195 $outputlangs = $langs;
1196 $newlang =
GETPOST(
'lang_id',
'alpha');
1198 $user =
new User($db);
1199 $user->fetch($object->fk_user_author);
1200 $newlang = $user->lang;
1202 if (!empty($newlang)) {
1203 $outputlangs =
new Translate(
"", $conf);
1204 $outputlangs->setDefaultLang($newlang);
1207 $object->generateDocument($object->model_pdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
1211 unset($value_unit_ht);
1215 unset($fk_c_type_fees);
1226 header(
"Location: ".$_SERVER[
"PHP_SELF"].
"?id=".
GETPOST(
'id',
'int'));
1233 if ($action ==
'confirm_delete_line' &&
GETPOST(
"confirm",
'alpha') ==
"yes" && $user->rights->expensereport->creer) {
1235 $object->fetch($id);
1238 $object_ligne->fetch(
GETPOST(
"rowid",
'int'));
1239 $total_ht = $object_ligne->total_ht;
1240 $total_tva = $object_ligne->total_tva;
1242 $result = $object->deleteline(
GETPOST(
"rowid",
'int'), $user);
1246 if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) {
1247 $outputlangs = $langs;
1250 $newlang =
GETPOST(
'lang_id',
'aZ09');
1253 $newlang = $object->thirdparty->default_lang;
1255 if (!empty($newlang)) {
1256 $outputlangs =
new Translate(
"", $conf);
1257 $outputlangs->setDefaultLang($newlang);
1259 $model = $object->model_pdf;
1260 $ret = $object->fetch($id);
1262 $object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref);
1266 header(
"Location: ".$_SERVER[
"PHP_SELF"].
"?id=".
GETPOST(
'id',
'int'));
1273 if ($action ==
"updateline" && $user->rights->expensereport->creer) {
1275 $object->fetch($id);
1279 if (GETPOSTISSET(
'attachfile')) {
1280 $arrayoffiles =
GETPOST(
'attachfile',
'array');
1281 if (is_array($arrayoffiles) && !empty($arrayoffiles[0])) {
1282 include_once DOL_DOCUMENT_ROOT.
'/ecm/class/ecmfiles.class.php';
1283 $relativepath =
'expensereport/'.$object->ref.
'/'.$arrayoffiles[0];
1285 $ecmfiles->fetch(0,
'', $relativepath);
1286 $fk_ecm_files = $ecmfiles->id;
1290 $rowid =
GETPOST(
'rowid',
'int');
1291 $type_fees_id =
GETPOST(
'fk_c_type_fees',
'int');
1292 $fk_c_exp_tax_cat =
GETPOST(
'fk_c_exp_tax_cat',
'int');
1293 $projet_id = $fk_project;
1294 $comments =
GETPOST(
'comments',
'restricthtml');
1296 $vatrate =
GETPOST(
'vatrate',
'alpha');
1299 if (empty($vatrate)) {
1302 $tmpvat =
price2num(preg_replace(
'/\s*\(.*\)/',
'', $vatrate));
1306 if (empty($value_unit)) {
1307 $value_unit =
price2num($value_unit_ht + ($value_unit_ht * $tmpvat / 100),
'MU');
1310 if (!
GETPOST(
'fk_c_type_fees',
'int') > 0) {
1312 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Type")),
null,
'errors');
1315 if ((
float) $tmpvat < 0 || $tmpvat ==
'') {
1317 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Vat")),
null,
'errors');
1321 if ($date < $object->date_debut || $date > ($object->date_fin + (24 * 3600 - 1))) {
1322 $langs->load(
"errors");
1323 setEventMessages($langs->trans(
"WarningDateOfLineMustBeInExpenseReportRange"),
null,
'warnings');
1327 if ($projectRequired && $projet_id <= 0) {
1329 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Project")),
null,
'errors');
1334 $result = $object->updateline($rowid, $type_fees_id, $projet_id, $vatrate, $comments, $qty, $value_unit, $date, $id, $fk_c_exp_tax_cat, $fk_ecm_files);
1338 if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) {
1339 $outputlangs = $langs;
1342 $newlang =
GETPOST(
'lang_id',
'aZ09');
1345 $newlang = $object->thirdparty->default_lang;
1347 if (!empty($newlang)) {
1348 $outputlangs =
new Translate(
"", $conf);
1349 $outputlangs->setDefaultLang($newlang);
1351 $model = $object->model_pdf;
1352 $ret = $object->fetch($id);
1354 $object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref);
1358 unset($value_unit_ht);
1362 unset($fk_c_type_fees);
1376 include DOL_DOCUMENT_ROOT.
'/core/actions_printing.inc.php';
1379 $triggersendname =
'EXPENSEREPORT_SENTBYMAIL';
1380 $autocopy =
'MAIN_MAIL_AUTOCOPY_EXPENSEREPORT_TO';
1381 $trackid =
'exp'.$object->id;
1382 include DOL_DOCUMENT_ROOT.
'/core/actions_sendmails.inc.php';
1385 $upload_dir = $conf->expensereport->dir_output;
1386 include DOL_DOCUMENT_ROOT.
'/core/actions_builddoc.inc.php';
1394$title = $langs->trans(
"ExpenseReport").
" - ".$langs->trans(
"Card");
1395$help_url =
"EN:Module_Expense_Reports|FR:Module_Notes_de_frais";
1399$form =
new Form($db);
1402$projecttmp =
new Project($db);
1404$bankaccountstatic =
new Account($db);
1405$ecmfilesstatic =
new EcmFiles($db);
1409if ($action ==
'create') {
1412 print
'<form action="'.$_SERVER[
'PHP_SELF'].
'" method="post" name="create">';
1413 print
'<input type="hidden" name="token" value="'.newToken().
'">';
1414 print
'<input type="hidden" name="action" value="add">';
1415 print
'<input type="hidden" name="backtopage" value="'.$backtopage.
'">';
1419 print
'<table class="border centpercent">';
1424 print
'<td class="titlefieldcreate fieldrequired">'.$langs->trans(
"DateStart").
'</td>';
1426 print $form->selectDate($date_start ? $date_start : -1,
'date_debut', 0, 0, 0,
'', 1, 1);
1432 print
'<td class="fieldrequired">'.$langs->trans(
"DateEnd").
'</td>';
1434 print $form->selectDate($date_end ? $date_end : -1,
'date_fin', 0, 0, 0,
'', 1, 1);
1440 print
'<td class="fieldrequired">'.$langs->trans(
"User").
'</td>';
1442 $defaultselectuser = $user->id;
1443 if (
GETPOST(
'fk_user_author',
'int') > 0) {
1444 $defaultselectuser =
GETPOST(
'fk_user_author',
'int');
1446 $include_users =
'hierarchyme';
1447 if (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->expensereport->writeall_advance)) {
1448 $include_users = array();
1450 $s = $form->select_dolusers($defaultselectuser,
"fk_user_author", 0,
"", 0, $include_users,
'',
'0,'.$conf->entity);
1457 print
'<td>'.$langs->trans(
"VALIDATOR").
'</td>';
1460 $include_users = $object->fetch_users_approver_expensereport();
1461 if (empty($include_users)) {
1462 print
img_warning().
' '.$langs->trans(
"NobodyHasPermissionToValidateExpenseReport");
1464 $defaultselectuser = (empty($user->fk_user_expense_validator) ? $user->fk_user : $user->fk_user_expense_validator);
1465 if (!empty($conf->global->EXPENSEREPORT_DEFAULT_VALIDATOR)) {
1466 $defaultselectuser = $conf->global->EXPENSEREPORT_DEFAULT_VALIDATOR;
1468 if (
GETPOST(
'fk_user_validator',
'int') > 0) {
1469 $defaultselectuser =
GETPOST(
'fk_user_validator',
'int');
1471 $s = $form->select_dolusers($defaultselectuser,
"fk_user_validator", 1,
"", ((empty($defaultselectuser) || empty($conf->global->EXPENSEREPORT_DEFAULT_VALIDATOR_UNCHANGEABLE)) ? 0 : 1), $include_users);
1472 print $form->textwithpicto($s, $langs->trans(
"AnyOtherInThisListCanValidate"));
1478 if (!empty($conf->global->EXPENSEREPORT_ASK_PAYMENTMODE_ON_CREATION)) {
1480 print
'<td>'.$langs->trans(
"ModePaiement").
'</td>';
1482 $form->select_types_paiements(
'',
'fk_c_paiement');
1488 $note_public = GETPOSTISSET(
'note_public') ?
GETPOST(
'note_public',
'restricthtml') :
'';
1491 print
'<td class="tdtop">'.$langs->trans(
'NotePublic').
'</td>';
1494 $doleditor =
new DolEditor(
'note_public', $note_public,
'', 80,
'dolibarr_notes',
'In', 0,
false, empty($conf->global->FCKEDITOR_ENABLE_NOTE_PUBLIC) ? 0 : 1, ROWS_3,
'90%');
1495 print $doleditor->Create(1);
1499 $note_private = GETPOSTISSET(
'note_private') ?
GETPOST(
'note_private',
'restricthtml') :
'';
1501 if (empty($user->socid)) {
1503 print
'<td class="tdtop">'.$langs->trans(
'NotePrivate').
'</td>';
1506 $doleditor =
new DolEditor(
'note_private', $note_private,
'', 80,
'dolibarr_notes',
'In', 0,
false, empty($conf->global->FCKEDITOR_ENABLE_NOTE_PRIVATE) ? 0 : 1, ROWS_3,
'90%');
1507 print $doleditor->Create(1);
1512 $parameters = array(
'colspan' =>
' colspan="3"',
'cols' => 3);
1513 $reshook = $hookmanager->executeHooks(
'formObjectOptions', $parameters, $object, $action);
1514 print $hookmanager->resPrint;
1515 if (empty($reshook)) {
1516 print $object->showOptionals($extrafields,
'create', $parameters);
1524 print $form->buttonsSaveCancel(
"AddTrip");
1527} elseif ($id > 0 || $ref) {
1528 $result = $object->fetch($id, $ref);
1531 if (!in_array($object->fk_user_author, $user->getAllChildIds(1))) {
1532 if (empty($user->rights->expensereport->readall) && empty($user->rights->expensereport->lire_tous)
1533 && (empty($conf->global->MAIN_USE_ADVANCED_PERMS) || empty($user->rights->expensereport->writeall_advance))) {
1536 print
'<div class="tabBar">';
1537 print $langs->trans(
'NotUserRightToView');
1550 if ($action ==
'edit' && ($object->status < 3 || $object->status == 99)) {
1551 print
"<form name='update' action=\"".$_SERVER[
'PHP_SELF'].
"\" method=\"post\">\n";
1552 print
'<input type="hidden" name="token" value="'.newToken().
'">';
1553 print
'<input type="hidden" name="id" value="'.$id.
'">';
1554 print
'<input type="hidden" name="backtopage" value="'.$backtopage.
'">';
1558 if ($object->status == 99) {
1559 print
'<input type="hidden" name="action" value="updateFromRefuse">';
1561 print
'<input type="hidden" name="action" value="update">';
1564 $linkback =
'<a href="'.DOL_URL_ROOT.
'/expensereport/list.php?restore_lastsearch_values=1'.(!empty($socid) ?
'&socid='.$socid :
'').
'">'.$langs->trans(
"BackToList").
'</a>';
1566 print
'<table class="border" style="width:100%;">';
1569 print
'<td>'.$langs->trans(
"User").
'</td>';
1571 $userfee =
new User($db);
1572 if ($object->fk_user_author > 0) {
1573 $userfee->fetch($object->fk_user_author);
1574 print $userfee->getNomUrl(-1);
1579 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"Ref").
'</td><td>';
1580 print $form->showrefnav($object,
'ref', $linkback, 1,
'ref',
'ref',
'');
1584 print
'<td>'.$langs->trans(
"DateStart").
'</td>';
1586 print $form->selectDate($object->date_debut,
'date_debut');
1590 print
'<td>'.$langs->trans(
"DateEnd").
'</td>';
1592 print $form->selectDate($object->date_fin,
'date_fin');
1596 if (!empty($conf->global->EXPENSEREPORT_ASK_PAYMENTMODE_ON_CREATION)) {
1598 print
'<td>'.$langs->trans(
"ModePaiement").
'</td>';
1600 $form->select_types_paiements($object->fk_c_paiement,
'fk_c_paiement');
1605 if ($object->status < 3) {
1607 print
'<td>'.$langs->trans(
"VALIDATOR").
'</td>';
1609 $include_users = $object->fetch_users_approver_expensereport();
1610 $s = $form->select_dolusers($object->fk_user_validator,
"fk_user_validator", 1,
"", 0, $include_users);
1611 print $form->textwithpicto($s, $langs->trans(
"AnyOtherInThisListCanValidate"));
1616 print
'<td>'.$langs->trans(
"VALIDOR").
'</td>';
1618 $userfee =
new User($db);
1619 $userfee->fetch($object->fk_user_valid);
1620 print $userfee->getNomUrl(-1);
1624 if ($object->status == 6) {
1626 print
'<td>'.$langs->trans(
"AUTHORPAIEMENT").
'</td>';
1628 $userfee =
new User($db);
1629 $userfee->fetch($user->id);
1630 print $userfee->getNomUrl(-1);
1642 print $form->buttonsSaveCancel(
"Modify");
1646 $taxlessUnitPriceDisabled = !empty($conf->global->EXPENSEREPORT_FORCE_LINE_AMOUNTS_INCLUDING_TAXES_ONLY) ?
' disabled' :
'';
1653 if ($action ==
'clone') {
1655 $criteriaforfilter =
'hierarchyme';
1656 if (!empty($user->rights->expensereport->readall)) {
1657 $criteriaforfilter =
'';
1659 $formquestion = array(
1661 array(
'type' =>
'other',
'name' =>
'fk_user_author',
'label' => $langs->trans(
"SelectTargetUser"),
'value' => $form->select_dolusers((
GETPOST(
'fk_user_author',
'int') > 0 ?
GETPOST(
'fk_user_author',
'int') : $user->id),
'fk_user_author', 0, null, 0, $criteriaforfilter,
'',
'0', 0, 0,
'', 0,
'',
'maxwidth150'))
1664 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.$object->id, $langs->trans(
'ToClone'), $langs->trans(
'ConfirmCloneExpenseReport', $object->ref),
'confirm_clone', $formquestion,
'yes', 1);
1667 if ($action ==
'save') {
1668 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
"?id=".$id, $langs->trans(
"SaveTrip"), $langs->trans(
"ConfirmSaveTrip"),
"confirm_validate",
"",
"", 1);
1671 if ($action ==
'save_from_refuse') {
1672 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
"?id=".$id, $langs->trans(
"SaveTrip"), $langs->trans(
"ConfirmSaveTrip"),
"confirm_save_from_refuse",
"",
"", 1);
1675 if ($action ==
'delete') {
1676 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
"?id=".$id, $langs->trans(
"DeleteTrip"), $langs->trans(
"ConfirmDeleteTrip"),
"confirm_delete",
"",
"", 1);
1679 if ($action ==
'validate') {
1680 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
"?id=".$id, $langs->trans(
"ValideTrip"), $langs->trans(
"ConfirmValideTrip"),
"confirm_approve",
"",
"", 1);
1683 if ($action ==
'paid') {
1684 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
"?id=".$id, $langs->trans(
"PaidTrip"), $langs->trans(
"ConfirmPaidTrip"),
"confirm_paid",
"",
"", 1);
1687 if ($action ==
'cancel') {
1688 $array_input = array(
'text'=>$langs->trans(
"ConfirmCancelTrip"), array(
'type'=>
"text",
'label'=>
'<strong>'.$langs->trans(
"Comment").
'</strong>',
'name'=>
"detail_cancel",
'value'=>
""));
1689 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
"?id=".$id, $langs->trans(
"Cancel"),
"",
"confirm_cancel", $array_input,
"", 1);
1692 if ($action ==
'setdraft') {
1693 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
"?id=".$id, $langs->trans(
"BrouillonnerTrip"), $langs->trans(
"ConfirmBrouillonnerTrip"),
"confirm_setdraft",
"",
"", 1);
1696 if ($action ==
'refuse') {
1697 $array_input = array(
'text'=>$langs->trans(
"ConfirmRefuseTrip"), array(
'type'=>
"text",
'label'=>$langs->trans(
"Comment"),
'name'=>
"detail_refuse",
'value'=>
""));
1698 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
"?id=".$id, $langs->trans(
"Deny"),
'',
"confirm_refuse", $array_input,
"yes", 1);
1701 if ($action ==
'delete_line') {
1702 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
"?id=".$id.
"&rowid=".
GETPOST(
'rowid',
'int'), $langs->trans(
"DeleteLine"), $langs->trans(
"ConfirmDeleteLine"),
"confirm_delete_line",
'',
'yes', 1);
1709 $linkback =
'<a href="'.DOL_URL_ROOT.
'/expensereport/list.php?restore_lastsearch_values=1'.(!empty($socid) ?
'&socid='.$socid :
'').
'">'.$langs->trans(
"BackToList").
'</a>';
1711 $morehtmlref =
'<div class="refidno">';
1712 $morehtmlref .=
'</div>';
1714 dol_banner_tab($object,
'ref', $linkback, 1,
'ref',
'ref', $morehtmlref);
1716 print
'<div class="fichecenter">';
1717 print
'<div class="fichehalfleft">';
1718 print
'<div class="underbanner clearboth"></div>';
1720 print
'<table class="border tableforfield centpercent">';
1724 print
'<td class="titlefield">'.$langs->trans(
"User").
'</td>';
1726 if ($object->fk_user_author > 0) {
1727 $userauthor =
new User($db);
1728 $result = $userauthor->fetch($object->fk_user_author);
1731 } elseif ($result > 0) {
1732 print $userauthor->getNomUrl(-1);
1739 print
'<td class="titlefield">'.$langs->trans(
"Period").
'</td>';
1741 print
get_date_range($object->date_debut, $object->date_fin,
'day', $langs, 0);
1744 if (!empty($conf->global->EXPENSEREPORT_ASK_PAYMENTMODE_ON_CREATION)) {
1746 print
'<td>'.$langs->trans(
"ModePaiement").
'</td>';
1747 print
'<td>'.$object->fk_c_paiement.
'</td>';
1753 print
'<td>'.$langs->trans(
"DATE_SAVE").
'</td>';
1754 print
'<td>'.dol_print_date($object->date_valid,
'dayhour',
'tzuser');
1755 if ($object->status == 2 && $object->hasDelay(
'toapprove')) {
1756 print
' '.img_warning($langs->trans(
"Late").
' - '.$langs->trans(
"ToApprove"));
1758 if ($object->status == 5 && $object->hasDelay(
'topay')) {
1759 print
' '.img_warning($langs->trans(
"Late").
' - '.$langs->trans(
"ToPay"));
1767 print
'<td>'.$langs->trans(
"VALIDATOR").
'</td>';
1769 if ($object->fk_user_validator > 0) {
1770 $userfee =
new User($db);
1771 $result = $userfee->fetch($object->fk_user_validator);
1773 print $userfee->getNomUrl(-1);
1775 if (empty($userfee->email) || !
isValidEmail($userfee->email)) {
1776 $langs->load(
"errors");
1777 print
img_warning($langs->trans(
"ErrorBadEMail", $userfee->email));
1783 print
'<td>'.$langs->trans(
"CANCEL_USER").
'</span></td>';
1785 if ($object->fk_user_cancel > 0) {
1786 $userfee =
new User($db);
1787 $result = $userfee->fetch($object->fk_user_cancel);
1789 print $userfee->getNomUrl(-1);
1795 print
'<td>'.$langs->trans(
"MOTIF_CANCEL").
'</td>';
1796 print
'<td>'.$object->detail_cancel.
'</td></tr>';
1799 print
'<td>'.$langs->trans(
"DATE_CANCEL").
'</td>';
1800 print
'<td>'.dol_print_date($object->date_cancel,
'dayhour',
'tzuser').
'</td></tr>';
1804 print
'<td>'.$langs->trans(
"ApprovedBy").
'</td>';
1806 if ($object->fk_user_approve > 0) {
1807 $userapp =
new User($db);
1808 $result = $userapp->fetch($object->fk_user_approve);
1810 print $userapp->getNomUrl(-1);
1816 print
'<td>'.$langs->trans(
"DateApprove").
'</td>';
1817 print
'<td>'.dol_print_date($object->date_approve,
'dayhour',
'tzuser').
'</td></tr>';
1821 if ($object->status == 99 || !empty($object->detail_refuse)) {
1823 print
'<td>'.$langs->trans(
"REFUSEUR").
'</td>';
1825 $userfee =
new User($db);
1826 $result = $userfee->fetch($object->fk_user_refuse);
1828 print $userfee->getNomUrl(-1);
1833 print
'<td>'.$langs->trans(
"DATE_REFUS").
'</td>';
1834 print
'<td>'.dol_print_date($object->date_refuse,
'dayhour',
'tzuser');
1835 if ($object->detail_refuse) {
1836 print
' - '.$object->detail_refuse;
1842 if ($object->status == $object::STATUS_CLOSED) {
1860 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_view.tpl.php';
1865 print
'<div class="fichehalfright">';
1866 print
'<div class="underbanner clearboth"></div>';
1868 print
'<table class="border tableforfield centpercent">';
1872 print
'<td class="titlefieldmiddle">'.$langs->trans(
"AmountHT").
'</td>';
1873 print
'<td class="nowrap amountcard">'.price($object->total_ht, 1,
'', 1, - 1, - 1, $conf->currency).
'</td>';
1892 print
'<td>'.$langs->trans(
"AmountVAT").
'</td>';
1893 print
'<td class="nowrap amountcard">'.price($object->total_tva, 1,
'', 1, -1, -1, $conf->currency).
'</td>';
1897 if ($mysoc->localtax1_assuj ==
"1" || $object->total_localtax1 != 0) {
1898 print
'<tr><td>'.$langs->transcountry(
"AmountLT1", $mysoc->country_code).
'</td>';
1899 print
'<td class="valuefield">'.price($object->total_localtax1, 1,
'', 1, -1, -1, $conf->currency).
'</td></tr>';
1901 if ($mysoc->localtax2_assuj ==
"1" || $object->total_localtax2 != 0) {
1902 print
'<tr><td>'.$langs->transcountry(
"AmountLT2", $mysoc->country_code).
'</td>';
1903 print
'<td class="valuefield">'.price($object->total_localtax2, 1,
'', 1, -1, -1, $conf->currency).
'</td></tr>';
1907 print
'<td>'.$langs->trans(
"AmountTTC").
'</td>';
1908 print
'<td class="nowrap amountcard">'.price($object->total_ttc, 1,
'', 1, -1, -1, $conf->currency).
'</td>';
1914 if (isModEnabled(
"banque")) {
1919 print
'<table class="noborder paymenttable centpercent">';
1921 print
'<tr class="liste_titre">';
1922 print
'<td class="liste_titre">'.$langs->trans(
'Payments').
'</td>';
1923 print
'<td class="liste_titre">'.$langs->trans(
'Date').
'</td>';
1924 print
'<td class="liste_titre">'.$langs->trans(
'Type').
'</td>';
1925 if (isModEnabled(
"banque")) {
1926 print
'<td class="liste_titre right">'.$langs->trans(
'BankAccount').
'</td>';
1928 print
'<td class="liste_titre right">'.$langs->trans(
'Amount').
'</td>';
1929 print
'<td class="liste_titre" width="18"> </td>';
1933 $sql =
"SELECT p.rowid, p.num_payment, p.datep as dp, p.amount, p.fk_bank,";
1934 $sql .=
"c.code as payment_code, c.libelle as payment_type,";
1935 $sql .=
"ba.rowid as baid, ba.ref as baref, ba.label, ba.number as banumber, ba.account_number, ba.fk_accountancy_journal";
1936 $sql .=
" FROM ".MAIN_DB_PREFIX.
"expensereport as e, ".MAIN_DB_PREFIX.
"payment_expensereport as p";
1937 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"c_paiement as c ON p.fk_typepayment = c.id";
1938 $sql .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'bank as b ON p.fk_bank = b.rowid';
1939 $sql .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'bank_account as ba ON b.fk_account = ba.rowid';
1940 $sql .=
" WHERE e.rowid = ".((int) $id);
1941 $sql .=
" AND p.fk_expensereport = e.rowid";
1942 $sql .=
' AND e.entity IN ('.getEntity(
'expensereport').
')';
1943 $sql .=
" ORDER BY dp";
1945 $resql = $db->query($sql);
1947 $num = $db->num_rows($resql);
1948 $i = 0; $totalpaid = 0;
1950 $objp = $db->fetch_object($resql);
1952 $paymentexpensereportstatic->id = $objp->rowid;
1953 $paymentexpensereportstatic->datep = $db->jdate($objp->dp);
1954 $paymentexpensereportstatic->ref = $objp->rowid;
1955 $paymentexpensereportstatic->num_payment = $objp->num_payment;
1956 $paymentexpensereportstatic->type_code = $objp->payment_code;
1957 $paymentexpensereportstatic->type_label = $objp->payment_type;
1959 print
'<tr class="oddseven">';
1961 print $paymentexpensereportstatic->getNomUrl(1);
1963 print
'<td>'.dol_print_date($db->jdate($objp->dp),
'day').
"</td>\n";
1964 $labeltype = $langs->trans(
"PaymentType".$objp->payment_code) != (
"PaymentType".$objp->payment_code) ? $langs->trans(
"PaymentType".$objp->payment_code) : $objp->payment_type;
1965 print
"<td>".$labeltype.
' '.$objp->num_payment.
"</td>\n";
1967 if (isModEnabled(
"banque")) {
1968 $bankaccountstatic->id = $objp->baid;
1969 $bankaccountstatic->ref = $objp->baref;
1970 $bankaccountstatic->label = $objp->baref;
1971 $bankaccountstatic->number = $objp->banumber;
1973 if (isModEnabled(
'accounting')) {
1974 $bankaccountstatic->account_number = $objp->account_number;
1977 $accountingjournal->fetch($objp->fk_accountancy_journal);
1978 $bankaccountstatic->accountancy_journal = $accountingjournal->getNomUrl(0, 1, 1,
'', 1);
1981 print
'<td class="right">';
1982 if ($bankaccountstatic->id) {
1983 print $bankaccountstatic->getNomUrl(1,
'transactions');
1987 print
'<td class="right">'.price($objp->amount).
"</td>";
1990 $totalpaid += $objp->amount;
1993 if (!is_null($totalpaid)) {
1997 $remaintopay =
price2num($object->total_ttc - $totalpaid);
1998 $resteapayeraffiche = $remaintopay;
2000 $cssforamountpaymentcomplete =
'amountpaymentcomplete';
2003 $cssforamountpaymentcomplete =
'amountpaymentneutral';
2004 $resteapayeraffiche = 0;
2005 } elseif ($object->paid == 0) {
2006 $cssforamountpaymentcomplete =
'amountpaymentneutral';
2008 print
'<tr><td colspan="'.$nbcols.
'" class="right">'.$langs->trans(
"AlreadyPaid").
':</td><td class="right">'.
price($totalpaid).
'</td><td></td></tr>';
2009 print
'<tr><td colspan="'.$nbcols.
'" class="right">'.$langs->trans(
"AmountExpected").
':</td><td class="right">'.
price($object->total_ttc).
'</td><td></td></tr>';
2011 print
'<tr><td colspan="'.$nbcols.
'" class="right">'.$langs->trans(
"RemainderToPay").
':</td>';
2012 print
'<td class="right'.($resteapayeraffiche ?
' amountremaintopay' : (
' '.$cssforamountpaymentcomplete)).
'">'.
price($resteapayeraffiche).
'</td><td></td></tr>';
2023 print
'<div class="clearboth"></div><br>';
2025 print
'<div style="clear: both;"></div>';
2027 $actiontouse =
'updateline';
2028 if (($object->status == 0 || $object->status == 99) && $action !=
'editline') {
2029 $actiontouse =
'addline';
2032 print
'<form name="expensereport" action="'.$_SERVER[
"PHP_SELF"].
'" enctype="multipart/form-data" method="post" >';
2033 print
'<input type="hidden" name="token" value="'.newToken().
'">';
2034 print
'<input type="hidden" name="action" value="'.$actiontouse.
'">';
2035 print
'<input type="hidden" name="id" value="'.$object->id.
'">';
2036 print
'<input type="hidden" name="fk_expensereport" value="'.$object->id.
'" />';
2037 print
'<input type="hidden" name="backtopage" value="'.$backtopage.
'">';
2038 print
'<input type="hidden" name="page_y" value="">';
2040 print
'<div class="div-table-responsive-no-min">';
2041 print
'<table id="tablelines" class="noborder centpercent">';
2043 if (!empty($object->lines)) {
2046 print
'<tr class="liste_titre headerexpensereportdet">';
2047 print
'<td class="center linecollinenb">'.$langs->trans(
'LineNb').
'</td>';
2049 print
'<td class="center linecoldate">'.$langs->trans(
'Date').
'</td>';
2050 if (isModEnabled(
'project')) {
2051 print
'<td class="minwidth100imp linecolproject">'.$langs->trans(
'Project').
'</td>';
2053 print
'<td class="center linecoltype">'.$langs->trans(
'Type').
'</td>';
2054 if (!empty($conf->global->MAIN_USE_EXPENSE_IK)) {
2055 print
'<td class="center linecolcarcategory">'.$langs->trans(
'CarCategory').
'</td>';
2057 print
'<td class="linecoldescription">'.$langs->trans(
'Description').
'</td>';
2058 print
'<td class="right linecolvat">'.$langs->trans(
'VAT').
'</td>';
2059 print
'<td class="right linecolpriceuht">'.$langs->trans(
'PriceUHT').
'</td>';
2060 print
'<td class="right linecolpriceuttc">'.$langs->trans(
'PriceUTTC').
'</td>';
2061 print
'<td class="right linecolqty">'.$langs->trans(
'Qty').
'</td>';
2062 if ($action !=
'editline') {
2063 print
'<td class="right linecolamountht">'.$langs->trans(
'AmountHT').
'</td>';
2064 print
'<td class="right linecolamountttc">'.$langs->trans(
'AmountTTC').
'</td>';
2075 if (($object->status < 2 || $object->status == 99) && $user->rights->expensereport->creer) {
2076 print
'<td class="right"></td>';
2080 foreach ($object->lines as &$line) {
2083 if ($action !=
'editline' || $line->id !=
GETPOST(
'rowid',
'int')) {
2084 print
'<tr class="oddeven linetr" data-id="'.$line->id.
'">';
2087 print
'<td class="center linecollinenb">';
2092 print
'<td class="center linecoldate">'.dol_print_date($db->jdate($line->date),
'day').
'</td>';
2095 if (isModEnabled(
'project')) {
2096 print
'<td class="lineproject">';
2097 if ($line->fk_project > 0) {
2098 $projecttmp->id = $line->fk_project;
2099 $projecttmp->ref = $line->projet_ref;
2100 $projecttmp->title = $line->projet_title;
2101 print $projecttmp->getNomUrl(1);
2107 if (isModEnabled(
'accounting')) {
2108 require_once DOL_DOCUMENT_ROOT.
'/accountancy/class/accountingaccount.class.php';
2110 $resaccountingaccount = $accountingaccount->fetch(0, $line->type_fees_accountancy_code, 1);
2112 $titlealt .= $langs->trans(
"AccountancyCode").
': ';
2113 if ($resaccountingaccount > 0) {
2114 $titlealt .= $accountingaccount->account_number;
2116 $titlealt .= $langs->trans(
"NotFound");
2122 print
'<td class="center linecoltype" title="'.dol_escape_htmltag($titlealt).
'">';
2123 $labeltype = ($langs->trans(($line->type_fees_code)) == $line->type_fees_code ? $line->type_fees_libelle : $langs->trans($line->type_fees_code));
2128 if (!empty($conf->global->MAIN_USE_EXPENSE_IK)) {
2129 print
'<td class="fk_c_exp_tax_cat linecoltaxcat">';
2130 $exp_tax_cat_label =
dol_getIdFromCode($db, $line->fk_c_exp_tax_cat,
'c_exp_tax_cat',
'rowid',
'label');
2131 print $langs->trans($exp_tax_cat_label);
2136 print
'<td class="left linecolcomment">'.dol_nl2br($line->comments).
'</td>';
2139 print
'<td class="right linecolvatrate">'.vatrate($line->vatrate.($line->vat_src_code ?
' ('.$line->vat_src_code.
')' :
''), true).
'</td>';
2142 print
'<td class="right linecolunitht">';
2143 if (!empty($line->value_unit_ht)) {
2144 print
price($line->value_unit_ht);
2146 $tmpvat =
price2num(preg_replace(
'/\s*\(.*\)/',
'', $line->vatrate));
2147 $pricenettoshow =
price2num($line->value_unit / (1 + $tmpvat / 100),
'MU');
2148 print
price($pricenettoshow);
2152 print
'<td class="right linecolunitttc">'.price($line->value_unit).
'</td>';
2154 print
'<td class="right linecolqty">'.dol_escape_htmltag($line->qty).
'</td>';
2156 if ($action !=
'editline') {
2157 print
'<td class="right linecoltotalht">'.price($line->total_ht).
'</td>';
2158 print
'<td class="right linecoltotalttc">'.price($line->total_ttc).
'</td>';
2162 print
'<td class="center linecolpreview">';
2163 if ($line->fk_ecm_files > 0) {
2164 $modulepart =
'expensereport';
2165 $maxheightmini = 32;
2167 $result = $ecmfilesstatic->fetch($line->fk_ecm_files);
2169 $relativepath = preg_replace(
'/expensereport\//',
'', $ecmfilesstatic->filepath);
2170 $fileinfo = pathinfo($ecmfilesstatic->filepath.
'/'.$ecmfilesstatic->filename);
2173 if (!
dol_is_file($conf->expensereport->dir_output.
'/'.$relativepath.
'/'.$minifile)) {
2177 $urlforhref =
getAdvancedPreviewUrl($modulepart, $relativepath.
'/'.$fileinfo[
'filename'].
'.'.strtolower($fileinfo[
'extension']), 1,
'&entity='.(!empty($object->entity) ? $object->entity : $conf->entity));
2178 if (empty($urlforhref)) {
2179 $urlforhref = DOL_URL_ROOT.
'/viewimage.php?modulepart='.$modulepart.
'&entity='.(!empty($object->entity) ? $object->entity : $conf->entity).
'&file='.urlencode($relativepath.$fileinfo[
'filename'].
'.'.strtolower($fileinfo[
'extension']));
2180 print
'<a href="'.$urlforhref.
'" class="aphoto" target="_blank" rel="noopener noreferrer">';
2182 print
'<a href="'.$urlforhref[
'url'].
'" class="'.$urlforhref[
'css'].
'" target="'.$urlforhref[
'target'].
'" mime="'.$urlforhref[
'mime'].
'">';
2184 print
'<img class="photo" height="'.$maxheightmini.
'" src="'.DOL_URL_ROOT.
'/viewimage.php?modulepart='.$modulepart.
'&entity='.(!empty($object->entity) ? $object->entity : $conf->entity).
'&file='.urlencode($relativepath.
'/'.$minifile).
'" title="">';
2187 $modulepart =
'expensereport';
2189 if (preg_match(
'/\.pdf$/i', $ecmfilesstatic->filename)) {
2190 $filepdf = $conf->expensereport->dir_output.
'/'.$relativepath.
'/'.$ecmfilesstatic->filename;
2191 $fileimage = $conf->expensereport->dir_output.
'/'.$relativepath.
'/'.$ecmfilesstatic->filename.
'_preview.png';
2192 $relativepathimage = $relativepath.
'/'.$ecmfilesstatic->filename.
'_preview.png';
2194 $pdfexists = file_exists($filepdf);
2197 if (!file_exists($fileimage) || (filemtime($fileimage) < filemtime($filepdf))) {
2198 if (empty($conf->global->MAIN_DISABLE_PDF_THUMBS)) {
2199 include_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
2208 if ($pdfexists && !$error) {
2209 $heightforphotref = 70;
2210 if (!empty($conf->dol_optimize_smallscreen)) {
2211 $heightforphotref = 60;
2214 if (file_exists($fileimage)) {
2216 $urlforhref =
getAdvancedPreviewUrl($modulepart, $relativepath.
'/'.$fileinfo[
'filename'].
'.'.strtolower($fileinfo[
'extension']), 1,
'&entity='.(!empty($object->entity) ? $object->entity : $conf->entity));
2217 print
'<a href="'.$urlforhref[
'url'].
'" class="'.$urlforhref[
'css'].
'" target="'.$urlforhref[
'target'].
'" mime="'.$urlforhref[
'mime'].
'">';
2218 print
'<img height="'.$heightforphotref.
'" class="photo photowithmargin photowithborder" src="'.DOL_URL_ROOT.
'/viewimage.php?modulepart=apercu'.$modulepart.
'&file='.urlencode($relativepathimage).
'">';
2224 if (!$thumbshown && $fileinfo[
'extension'] ==
'pdf' && !empty($filepdf) && !empty($relativepath) && !empty($fileinfo[
'filename'])) {
2226 $imgpreview = $formFile->showPreview([], $modulepart, $relativepath.
'/'.$fileinfo[
'filename'].
'.'.strtolower($fileinfo[
'extension']), 0);
2228 } elseif (!$thumbshown) {
2229 print
img_mime($ecmfilesstatic->filename);
2236 print
'<td class="nowrap right linecolwarning">';
2237 print !empty($line->rule_warning_message) ?
img_warning(html_entity_decode($line->rule_warning_message)) :
' ';
2242 print
'<td class="nowrap right linecolaction">';
2244 print
'<a class="editfielda reposition paddingrightonly" href="'.$_SERVER[
"PHP_SELF"].
'?id='.$object->id.
'&action=editline&token='.newToken().
'&rowid='.$line->rowid.
'">';
2246 print
'</a> ';
2247 print
'<a class="paddingrightonly" href="'.$_SERVER[
"PHP_SELF"].
'?id='.$object->id.
'&action=delete_line&token='.newToken().
'&rowid='.$line->rowid.
'">';
2257 if ($action ==
'editline' && $line->id ==
GETPOST(
'rowid',
'int')) {
2260 if (isModEnabled(
'project')) {
2263 if (!empty($conf->global->MAIN_USE_EXPENSE_IK)) {
2267 print
'<!-- line of expense report -->'.
"\n";
2268 print
'<tr class="tredited">';
2270 print
'<td class="center">';
2274 print
'<td colspan="'.($colspan - 1).
'" class="liste_titre"> ';
2275 print
'<a href="" class="commonlink auploadnewfilenow reposition">'.$langs->trans(
"UploadANewFileNow");
2276 print
img_picto($langs->trans(
"UploadANewFileNow"),
'chevron-down',
'',
false, 0, 0,
'',
'marginleftonly');
2278 if (empty($conf->global->EXPENSEREPORT_DISABLE_ATTACHMENT_ON_LINES)) {
2279 print
' - <a href="" class="commonlink aattachtodoc reposition">'.$langs->trans(
"AttachTheNewLineToTheDocument");
2280 print
img_picto($langs->trans(
"AttachTheNewLineToTheDocument"),
'chevron-down',
'',
false, 0, 0,
'',
'marginleftonly');
2284 print
'<!-- Code to open/close section to submit or link files in edit mode -->'.
"\n";
2285 print
'<script type="text/javascript">'.
"\n";
2286 print
'$(document).ready(function() {
2287 $( ".auploadnewfilenow" ).click(function() {
2288 jQuery(".truploadnewfilenow").toggle();
2289 jQuery(".trattachnewfilenow").hide();
2292 $( ".aattachtodoc" ).click(function() {
2293 jQuery(".trattachnewfilenow").toggle();
2294 jQuery(".truploadnewfilenow").hide();
2297 if (is_array(
GETPOST(
'attachfile',
'array')) && count(
GETPOST(
'attachfile',
'array'))) {
2298 print
'jQuery(".trattachnewfilenow").toggle();'.
"\n";
2301 jQuery("form[name=\"expensereport\"]").submit(function() {
2302 if (jQuery(".truploadnewfilenow").is(":hidden")) {
2303 jQuery("input[name=\"sendit\"]").val("");
2310 print
'</script>'.
"\n";
2313 $filenamelinked =
'';
2314 if ($line->fk_ecm_files > 0) {
2315 $result = $ecmfilesstatic->fetch($line->fk_ecm_files);
2317 $filenamelinked = $ecmfilesstatic->filename;
2321 $tredited =
'tredited';
2322 include DOL_DOCUMENT_ROOT.
'/expensereport/tpl/expensereport_addfile.tpl.php';
2323 include DOL_DOCUMENT_ROOT.
'/expensereport/tpl/expensereport_linktofile.tpl.php';
2325 print
'<tr class="oddeven tredited">';
2330 print
'<td class="center">';
2331 print $form->selectDate($line->date,
'date');
2335 if (isModEnabled(
'project')) {
2337 $formproject->select_projects(-1, $line->fk_project,
'fk_project', 0, 0, $projectRequired ? 0 : 1, 1, 0, 0, 0,
'', 0, 0,
'maxwidth300');
2342 print
'<td class="center">';
2343 print $formexpensereport->selectTypeExpenseReport($line->fk_c_type_fees,
'fk_c_type_fees');
2346 if (!empty($conf->global->MAIN_USE_EXPENSE_IK)) {
2347 print
'<td class="fk_c_exp_tax_cat">';
2348 $params = array(
'fk_expense' => $object->id,
'fk_expense_det' => $line->id,
'date' => $line->date);
2349 print $form->selectExpenseCategories($line->fk_c_exp_tax_cat,
'fk_c_exp_tax_cat', 1, array(),
'fk_c_type_fees', $userauthor->default_c_exp_tax_cat, $params);
2355 print
'<textarea name="comments" class="flat_ndf centpercent">'.dol_escape_htmltag($line->comments, 0, 1).
'</textarea>';
2359 $selectedvat =
price2num($line->vatrate).(!empty($line->vat_src_code) ?
' ('.$line->vat_src_code.
')' :
'');
2360 print
'<td class="right">';
2361 print $form->load_tva(
'vatrate', (GETPOSTISSET(
"vatrate") ?
GETPOST(
"vatrate") : $selectedvat), $mysoc,
'', 0, 0,
'', false, 1);
2365 print
'<td class="right">';
2366 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.
' />';
2370 print
'<td class="right">';
2371 print
'<input type="text" min="0" class="right maxwidth50" id="value_unit" name="value_unit" value="'.dol_escape_htmltag(
price2num($line->value_unit)).
'" />';
2375 print
'<td class="right">';
2376 print
'<input type="text" min="0" class="input_qty right maxwidth50" name="qty" value="'.dol_escape_htmltag($line->qty).
'" />';
2383 print
'<td class="center">';
2387 print
'<td class="center">';
2391 print
'<input type="hidden" name="rowid" value="'.$line->rowid.
'">';
2392 print $form->buttonsSaveCancel(
'Save',
'Cancel', array(), 0,
'small');
2405 if (!empty($conf->global->MAIN_USE_EXPENSE_IK)) {
2408 if (isModEnabled(
'project')) {
2411 if ($action !=
'editline') {
2415 $nbFiles = $nbLinks = 0;
2416 $arrayoffiles = array();
2417 if (empty($conf->global->EXPENSEREPORT_DISABLE_ATTACHMENT_ON_LINES)) {
2418 require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
2419 require_once DOL_DOCUMENT_ROOT.
'/core/lib/images.lib.php';
2420 require_once DOL_DOCUMENT_ROOT.
'/core/class/link.class.php';
2423 $nbFiles = count($arrayoffiles);
2424 $nbLinks =
Link::count($db, $object->element, $object->id);
2428 print
'<tr class="liste_titre">';
2429 print
'<td colspan="'.$colspan.
'" class="liste_titre expensereportautoload">';
2430 print
'<a href="" class="commonlink auploadnewfilenow reposition">'.$langs->trans(
"UploadANewFileNow");
2431 print
img_picto($langs->trans(
"UploadANewFileNow"),
'chevron-down',
'',
false, 0, 0,
'',
'marginleftonly');
2433 if (empty($conf->global->EXPENSEREPORT_DISABLE_ATTACHMENT_ON_LINES)) {
2434 print
' - <a href="" class="commonlink aattachtodoc reposition">'.$langs->trans(
"AttachTheNewLineToTheDocument");
2435 print
img_picto($langs->trans(
"AttachTheNewLineToTheDocument"),
'chevron-down',
'',
false, 0, 0,
'',
'marginleftonly');
2439 print
'<!-- Code to open/close section to submit or link files in the form to add new line -->'.
"\n";
2440 print
'<script type="text/javascript">'.
"\n";
2441 print
'$(document).ready(function() {
2442 $( ".auploadnewfilenow" ).click(function() {
2443 console.log("We click on toggle of auploadnewfilenow");
2444 jQuery(".truploadnewfilenow").toggle();
2445 jQuery(".trattachnewfilenow").hide();
2446 if (jQuery(".truploadnewfilenow").is(":hidden")) {
2447 jQuery("input[name=\"sendit\"]").prop("name", "senditdisabled");
2449 jQuery("input[name=\"senditdisabled\"]").prop("name", "sendit");
2451 // TODO Switch css fa-chevron-dow and add fa-chevron-up
2454 $( ".aattachtodoc" ).click(function() {
2455 console.log("We click on toggle of aattachtodoc");
2456 jQuery(".trattachnewfilenow").toggle();
2457 jQuery(".truploadnewfilenow").hide();
2458 // TODO Switch css fa-chevron-dow and add fa-chevron-up
2461 if (is_array(
GETPOST(
'attachfile',
'array')) && count(
GETPOST(
'attachfile',
'array')) && $action !=
'updateline') {
2462 print
'jQuery(".trattachnewfilenow").show();'.
"\n";
2465 jQuery("form[name=\"expensereport\"]").submit(function() {
2466 if (jQuery(".truploadnewfilenow").is(":hidden")) {
2467 /* 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. */
2468 jQuery("input[name=\"sendit\"]").val("");
2469 jQuery("input[name=\"sendit\"]").prop("name", "senditdisabled");
2471 jQuery("input[name=\"senditdisabled\"]").prop("name", "sendit");
2478 print
'</script>'.
"\n";
2482 include DOL_DOCUMENT_ROOT.
'/expensereport/tpl/expensereport_linktofile.tpl.php';
2483 include DOL_DOCUMENT_ROOT.
'/expensereport/tpl/expensereport_addfile.tpl.php';
2485 print
'<tr class="liste_titre expensereportcreate">';
2487 print
'<td class="center expensereportcreatedate">'.$langs->trans(
'Date').
'</td>';
2488 if (isModEnabled(
'project')) {
2489 print
'<td class="minwidth100imp">'.$form->textwithpicto($langs->trans(
'Project'), $langs->trans(
"ClosedProjectsAreHidden")).
'</td>';
2491 print
'<td class="center expensereportcreatetype">'.$langs->trans(
'Type').
'</td>';
2492 if (!empty($conf->global->MAIN_USE_EXPENSE_IK)) {
2493 print
'<td>'.$langs->trans(
'CarCategory').
'</td>';
2495 print
'<td class="expensereportcreatedescription">'.$langs->trans(
'Description').
'</td>';
2496 print
'<td class="right expensereportcreatevat">'.$langs->trans(
'VAT').
'</td>';
2497 print
'<td class="right expensereportcreatepriceuth">'.$langs->trans(
'PriceUHT').
'</td>';
2498 print
'<td class="right expensereportcreatepricettc">'.$langs->trans(
'PriceUTTC').
'</td>';
2499 print
'<td class="right expensereportcreateqty">'.$langs->trans(
'Qty').
'</td>';
2506 print
'<tr class="oddeven nohover">';
2512 print
'<td class="center inputdate">';
2513 print $form->selectDate(!empty($date) ? $date : -1,
'date', 0, 0, 0,
'', 1, 1);
2517 if (isModEnabled(
'project')) {
2518 print
'<td class="inputproject">';
2519 $formproject->select_projects(-1, !empty($fk_project) ? $fk_project : 0,
'fk_project', 0, 0, $projectRequired ? 0 : 1, -1, 0, 0, 0,
'', 0, 0,
'maxwidth300');
2524 print
'<td class="center inputtype">';
2525 print $formexpensereport->selectTypeExpenseReport(!empty($fk_c_type_fees) ? $fk_c_type_fees :
"",
'fk_c_type_fees', 1);
2528 if (!empty($conf->global->MAIN_USE_EXPENSE_IK)) {
2529 print
'<td class="fk_c_exp_tax_cat">';
2530 $params = array(
'fk_expense' => $object->id);
2531 print $form->selectExpenseCategories(
'',
'fk_c_exp_tax_cat', 1, array(),
'fk_c_type_fees', $userauthor->default_c_exp_tax_cat, $params, 0);
2536 print
'<td class="inputcomment">';
2537 print
'<textarea class="flat_ndf centpercent" name="comments" rows="'.ROWS_2.
'">'.
dol_escape_htmltag(!empty($comments) ? $comments :
"", 0, 1).
'</textarea>';
2541 print
'<td class="right inputvat">';
2543 if (!empty($conf->global->EXPENSEREPORT_NO_DEFAULT_VAT)) {
2545 $conf->global->MAIN_VAT_DEFAULT_IF_AUTODETECT_FAILS =
'none';
2547 print $form->load_tva(
'vatrate', (!empty($vatrate) ? $vatrate : $defaultvat), $mysoc,
'', 0, 0,
'', false, 1);
2551 print
'<td class="right inputpricenet">';
2552 print
'<input type="text" class="right maxwidth50" id="value_unit_ht" name="value_unit_ht" value="'.dol_escape_htmltag((!empty($value_unit_ht) ? $value_unit_ht : 0)).
'"'.$taxlessUnitPriceDisabled.
' />';
2556 print
'<td class="right inputtax">';
2557 print
'<input type="text" class="right maxwidth50" id="value_unit" name="value_unit" value="'.dol_escape_htmltag((!empty($value_unit) ? $value_unit : 0)).
'">';
2561 print
'<td class="right inputqty">';
2562 print
'<input type="text" min="0" class=" input_qty right maxwidth50" name="qty" value="'.dol_escape_htmltag(!empty($qty) ? $qty : 1).
'">';
2568 if ($action !=
'editline') {
2569 print
'<td class="right"></td>';
2570 print
'<td class="right"></td>';
2573 print
'<td class="center inputbuttons">';
2574 print $form->buttonsSaveCancel(
"Add",
'',
'', 1,
'reposition');
2585 /* JQuery for product free or predefined select */
2586 jQuery(document).ready(function() {
2587 jQuery("#value_unit_ht").keyup(function(event) {
2588 console.log(event.which); // discard event tag and arrows
2589 if (event.which != 9 && (event.which < 37 ||event.which > 40) && jQuery("#value_unit_ht").val() != "") {
2590 jQuery("#value_unit").val("");
2593 jQuery("#value_unit").keyup(function(event) {
2594 console.log(event.which); // discard event tag and arrows
2595 if (event.which != 9 && (event.which < 37 || event.which > 40) && jQuery("#value_unit").val() != "") {
2596 jQuery("#value_unit_ht").val("");
2601 if (! empty($conf->global->MAIN_USE_EXPENSE_IK)) {
2604 /* unit price coéf calculation */
2605 jQuery(".input_qty, #fk_c_type_fees, #select_fk_c_exp_tax_cat, #vatrate ").change(function(event) {
2607 let type_fee = jQuery("#fk_c_type_fees").find(":selected").val();
2608 let tax_cat = jQuery("#select_fk_c_exp_tax_cat").find(":selected").val();
2609 let tva = jQuery("#vatrate").find(":selected").val();
2610 let qty = jQuery(".input_qty").val();
2614 let path = "'.dol_buildpath(
"/expensereport/ajax/ajaxik.php", 1) .
'";
2615 path += "?fk_c_exp_tax_cat="+tax_cat;
2616 path +="&fk_expense="+'.$object->id.
';
2617 path += "&vatrate="+tva;
2618 path += "&qty="+qty;
2620 if (type_fee == 4) { // frais_kilométriques
2622 if (tax_cat == "" || parseInt(tax_cat) <= 0){
2630 ,success:function(response) {
2631 if (response.response_status == "success"){';
2633 if (!empty($conf->global->EXPENSEREPORT_FORCE_LINE_AMOUNTS_INCLUDING_TAXES_ONLY)) {
2635 jQuery("#value_unit").val(parseFloat(response.data) * (100 + parseFloat(tva)) / 100);
2636 jQuery("#value_unit").trigger("change");
2640 jQuery("#value_unit_ht").val(response.data);
2641 jQuery("#value_unit_ht").trigger("change");
2642 jQuery("#value_unit").val("");
2647 } else if(response.response_status == "error" && response.errorMessage != undefined && response.errorMessage.length > 0 ){
2648 $.jnotify(response.errorMessage, "error", {timeout: 0, type: "error"},{ remove: function (){} } );
2655 /*console.log(event.which); // discard event tag and arrows
2656 if (event.which != 9 && (event.which < 37 || event.which > 40) && jQuery("#value_unit").val() != "") {
2657 jQuery("#value_unit_ht").val("");
2677 print
'Record not found';
2688print
'<div class="tabsAction">';
2690if ($action !=
'create' && $action !=
'edit' && $action !=
'editline') {
2692 $object->fetch($id, $ref);
2695 if (empty($user->socid)) {
2698 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>';
2710 if (in_array($object->fk_user_author, $user->getAllChildIds(1)) || !empty($user->rights->expensereport->writeall_advance)) {
2712 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>';
2715 if (count($object->lines) > 0) {
2716 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>';
2727 if ($user->id == $object->fk_user_author || $user->id == $object->fk_user_valid) {
2729 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>';
2734 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>';
2739 if ($user->id == $object->fk_user_author || $user->id == $object->fk_user_valid) {
2741 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>';
2751 if (in_array($object->fk_user_author, $user->getAllChildIds(1))) {
2753 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>';
2761 print
'<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER[
"PHP_SELF"].
'?action=validate&id='.$object->id.
'">'.$langs->trans(
'Approve').
'</a></div>';
2763 print
'<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER[
"PHP_SELF"].
'?action=refuse&id='.$object->id.
'">'.$langs->trans(
'Deny').
'</a></div>';
2766 if ($user->id == $object->fk_user_author || $user->id == $object->fk_user_valid) {
2768 print
'<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER[
"PHP_SELF"].
'?action=cancel&id='.$object->id.
'">'.$langs->trans(
"Cancel").
'</a></div>';
2777 print
'<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER[
"PHP_SELF"].
'?action=refuse&id='.$object->id.
'">'.$langs->trans(
'Deny').
'</a></div>';
2783 if ($remaintopay == 0) {
2784 print
'<div class="inline-block divButAction"><span class="butActionRefused classfortooltip" title="'.$langs->trans(
"DisabledBecauseRemainderToPayIsZero").
'">'.$langs->trans(
'DoPayment').
'</span></div>';
2786 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>';
2793 if ($object->paid == 0) {
2794 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>";
2798 if ($user->rights->expensereport->creer && ($user->id == $object->fk_user_author || $user->id == $object->fk_user_valid) && $object->status ==
ExpenseReport::STATUS_APPROVED) {
2800 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>';
2804 if (($user->rights->expensereport->approve || $user->rights->expensereport->to_paid) && $object->status ==
ExpenseReport::STATUS_CLOSED) {
2806 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>';
2811 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>';
2815 if ($user->rights->expensereport->creer) {
2816 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>';
2822 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>';
2825 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>';
2828 $parameters = array();
2829 $reshook = $hookmanager->executeHooks(
'addMoreActionsButtons', $parameters, $object, $action);
2836if (
GETPOST(
'modelselected',
'alpha')) {
2837 $action =
'presend';
2840if ($action !=
'presend') {
2845 print
'<div class="fichecenter"><div class="fichehalfleft">';
2846 print
'<a name="builddoc"></a>';
2848 if ($user->rights->expensereport->creer && $action !=
'create' && $action !=
'edit') {
2851 $urlsource = $_SERVER[
"PHP_SELF"].
"?id=".$object->id;
2852 $genallowed = $user->rights->expensereport->creer;
2853 $delallowed = $user->rights->expensereport->creer;
2855 print $formfile->showdocuments(
'expensereport', $filename, $filedir, $urlsource, $genallowed, $delallowed);
2856 $somethingshown = $formfile->numoffiles;
2868 print
'</div><div class="fichehalfright">';
2870 include_once DOL_DOCUMENT_ROOT.
'/core/class/html.formactions.class.php';
2872 $somethingshown =
$formactions->showactions($object,
'expensereport',
null);
2874 print
'</div></div>';
2878$modelmail =
'expensereport_send';
2879$defaulttopic =
'SendExpenseReportRef';
2880$diroutput = $conf->expensereport->dir_output;
2881$trackid =
'exp'.$object->id;
2883include DOL_DOCUMENT_ROOT.
'/core/tpl/card_presend.tpl.php';
if(preg_match('/set_([a-z0-9_\-]+)/i', $action, $reg)) if(preg_match('/del_([a-z0-9_\-]+)/i', $action, $reg)) if($action=='set') elseif( $action=='specimen') elseif($action=='setmodel') elseif( $action=='del') elseif($action=='setdoc') $formactions
View.
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader()
Empty header.
Class to manage bank accounts.
Class to manage accounting accounts.
Class to manage accounting accounts.
Class to send emails (with attachments or not) Usage: $mailfile = new CMailFile($subject,...
Class to manage a WYSIWYG editor.
Class to manage ECM files.
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($path, $types="all", $recursive=0, $filter="", $excludefilter=null, $sortcriteria="name", $sortorder=SORT_ASC, $mode=0, $nohook=0, $relativename="", $donotfollowsymlinks=0, $nbsecondsold=0)
Scan a directory and return a list of files/directories.
dol_banner_tab($object, $paramid, $morehtml='', $shownav=1, $fieldid='rowid', $fieldref='ref', $morehtmlref='', $moreparam='', $nodbprefix=0, $morehtmlleft='', $morehtmlstatus='', $onlybanner=0, $morehtmlright='')
Show tab footer of a card.
dol_mktime($hour, $minute, $second, $month, $day, $year, $gm='auto', $check=1)
Return a timestamp date built from detailed informations (by default a local PHP server timestamp) Re...
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($titre, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
img_warning($titlealt='default', $moreatt='', $morecss='pictowarning')
Show warning logo.
img_delete($titlealt='default', $other='class="pictodelete"', $morecss='')
Show delete logo.
dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='', $dragdropfile=0)
Show tabs of a record.
price2num($amount, $rounding='', $option=0)
Function that return a number with universal decimal format (decimal separator is '.
get_date_range($date_start, $date_end, $format='', $outputlangs='', $withparenthesis=1)
Format output for start and end date.
dol_print_error($db='', $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
dol_get_fiche_end($notab=0)
Return tab footer of a card.
price($amount, $form=0, $outlangs='', $trunc=1, $rounding=-1, $forcerounding=-1, $currency_code='')
Function to format a value into an amount for visual output Function used into PDF and HTML pages.
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs='', $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
dol_now($mode='auto')
Return date for now.
img_mime($file, $titlealt='', $morecss='')
Show MIME img of a file.
getDolGlobalInt($key, $default=0)
Return dolibarr global constant int value.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
dol_clone($object, $native=0)
Create a clone of instance of object (new instance with same value for each properties) With native =...
getImageFileNameForSize($file, $extName, $extImgTarget='')
Return the filename of file to get the thumbs.
getAdvancedPreviewUrl($modulepart, $relativepath, $alldata=0, $param='')
Return URL we can use for advanced preview links.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0)
Set event messages in dol_events session object.
dol_sanitizeFileName($str, $newstr='_', $unaccent=1)
Clean a string to use it as a file name.
isValidEmail($address, $acceptsupervisorkey=0, $acceptuserkey=0)
Return true if email syntax is ok.
img_edit($titlealt='default', $float=0, $other='')
Show logo editer/modifier 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.
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.