29 require
'../main.inc.php';
30 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formexpensereport.class.php';
31 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formfile.class.php';
32 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formmail.class.php';
33 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formprojet.class.php';
34 require_once DOL_DOCUMENT_ROOT.
'/core/class/CMailFile.class.php';
35 require_once DOL_DOCUMENT_ROOT.
'/projet/class/project.class.php';
36 require_once DOL_DOCUMENT_ROOT.
'/ecm/class/ecmfiles.class.php';
37 require_once DOL_DOCUMENT_ROOT.
'/compta/bank/class/account.class.php';
38 require_once DOL_DOCUMENT_ROOT.
'/core/lib/expensereport.lib.php';
39 require_once DOL_DOCUMENT_ROOT.
'/core/lib/price.lib.php';
40 require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
41 require_once DOL_DOCUMENT_ROOT.
'/core/lib/images.lib.php';
42 require_once DOL_DOCUMENT_ROOT.
'/core/modules/expensereport/modules_expensereport.php';
43 require_once DOL_DOCUMENT_ROOT.
'/expensereport/class/expensereport.class.php';
44 require_once DOL_DOCUMENT_ROOT.
'/expensereport/class/paymentexpensereport.class.php';
45 require_once DOL_DOCUMENT_ROOT.
'/core/class/doleditor.class.php';
46 require_once DOL_DOCUMENT_ROOT.
'/core/class/extrafields.class.php';
47 if (!empty($conf->accounting->enabled)) {
48 require_once DOL_DOCUMENT_ROOT.
'/accountancy/class/accountingjournal.class.php';
52 $langs->loadLangs(array(
"trips",
"bills",
"mails"));
54 $action =
GETPOST(
'action',
'aZ09');
55 $cancel =
GETPOST(
'cancel',
'alpha');
56 $confirm =
GETPOST(
'confirm',
'alpha');
62 $fk_project =
GETPOST(
'fk_project',
'int');
63 $vatrate =
GETPOST(
'vatrate',
'alpha');
65 $comments =
GETPOST(
'comments',
'restricthtml');
66 $fk_c_type_fees =
GETPOST(
'fk_c_type_fees',
'int');
69 $childids = $user->getAllChildIds(1);
71 if (! empty($conf->global->EXPENSEREPORT_PREFILL_DATES_WITH_CURRENT_MONTH)) {
72 if (empty($date_start)) {
76 if (empty($date_end)) {
83 $rootfordata = DOL_DATA_ROOT;
84 $rootforuser = DOL_DATA_ROOT;
86 if (!empty($conf->multicompany->enabled) && !empty($conf->entity) && $conf->entity > 1) {
87 $rootfordata .=
'/'.$conf->entity;
89 $conf->expensereport->dir_output = $rootfordata.
'/expensereport';
92 $urlwithouturlroot = preg_replace(
'/'.preg_quote(DOL_URL_ROOT,
'/').
'$/i',
'', trim($dolibarr_main_url_root));
93 $urlwithroot = $urlwithouturlroot.DOL_URL_ROOT;
97 $hidedetails = (
GETPOST(
'hidedetails',
'int') ?
GETPOST(
'hidedetails',
'int') : (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DETAILS) ? 1 : 0));
98 $hidedesc = (
GETPOST(
'hidedesc',
'int') ?
GETPOST(
'hidedesc',
'int') : (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DESC) ? 1 : 0));
99 $hideref = (
GETPOST(
'hideref',
'int') ?
GETPOST(
'hideref',
'int') : (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_REF) ? 1 : 0));
106 $extrafields->fetch_name_optionals_label($object->table_element);
109 include DOL_DOCUMENT_ROOT.
'/core/actions_fetchobject.inc.php';
112 $hookmanager->initHooks(array(
'expensereportcard',
'globalcard'));
114 $permissionnote = $user->rights->expensereport->creer;
115 $permissiondellink = $user->rights->expensereport->creer;
116 $permissiontoadd = $user->rights->expensereport->creer;
120 $projectRequired = $conf->project->enabled && ! empty($conf->global->EXPENSEREPORT_PROJECT_IS_REQUIRED);
121 $fileRequired = !empty($conf->global->EXPENSEREPORT_FILE_IS_REQUIRED);
123 if ($object->id > 0) {
126 if (!empty($user->rights->expensereport->readall)) {
129 if (!empty($user->rights->expensereport->lire) && in_array($object->fk_user_author, $childids)) {
138 if (!empty($user->rights->expensereport->supprimer)) {
141 if ($object->statut ==
ExpenseReport::STATUS_DRAFT && $user->hasRight(
'expensereport',
'write') && in_array($object->fk_user_author, $childids)) {
147 $socid = $user->socid;
149 $result =
restrictedArea($user,
'expensereport', $object->id,
'expensereport');
151 $permissiontoadd = $user->rights->expensereport->creer;
158 $parameters = array(
'socid' => $socid);
159 $reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
164 if (empty($reshook)) {
165 $backurlforlist = DOL_URL_ROOT.
'/expensereport/list.php';
167 if (empty($backtopage) || ($cancel && empty($id))) {
168 if (empty($backtopage) || ($cancel && strpos($backtopage,
'__ID__'))) {
169 if (empty($id) && (($action !=
'add' && $action !=
'create') || $cancel)) {
170 $backtopage = $backurlforlist;
172 $backtopage = DOL_URL_ROOT.
'/expensereport/card.php?id='.((!empty($id) && $id > 0) ? $id :
'__ID__');
178 if (!empty($backtopageforcancel)) {
179 header(
"Location: ".$backtopageforcancel);
181 } elseif (!empty($backtopage)) {
182 header(
"Location: ".$backtopage);
196 $fk_c_type_fees = -1;
199 include DOL_DOCUMENT_ROOT.
'/core/actions_linkedfiles.inc.php';
201 if (!empty(
GETPOST(
'sendit',
'alpha'))) {
202 if ($action ==
'updateline') {
203 $action =
'editline';
209 include DOL_DOCUMENT_ROOT.
'/core/actions_setnotes.inc.php';
211 include DOL_DOCUMENT_ROOT.
'/core/actions_dellink.inc.php';
213 include DOL_DOCUMENT_ROOT.
'/core/actions_lineupdown.inc.php';
216 if ($action ==
'confirm_clone' && $confirm ==
'yes' && $user->rights->expensereport->creer) {
217 if (1 == 0 && !
GETPOST(
'clone_content',
'alpha') && !
GETPOST(
'clone_receivers',
'alpha')) {
220 if ($object->id > 0) {
222 $orig = clone $object;
224 $result = $object->createFromClone($user,
GETPOST(
'fk_user_author',
'int'));
226 header(
"Location: ".$_SERVER[
'PHP_SELF'].
'?id='.$result);
237 if ($action ==
'confirm_delete' &&
GETPOST(
"confirm",
'alpha') ==
"yes" && $id > 0 && $candelete) {
239 $result = $object->fetch($id);
240 $result = $object->delete($user);
242 header(
"Location: index.php");
249 if ($action ==
'add' && $user->rights->expensereport->creer) {
254 $object->date_debut = $date_start;
255 $object->date_fin = $date_end;
257 $object->fk_user_author =
GETPOST(
'fk_user_author',
'int');
258 if (!($object->fk_user_author > 0)) {
259 $object->fk_user_author = $user->id;
263 if ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && empty($user->rights->expensereport->creer))
264 || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && empty($user->rights->expensereport->creer) && empty($user->rights->expensereport->writeall_advance))) {
269 if (empty($conf->global->MAIN_USE_ADVANCED_PERMS) || empty($user->rights->expensereport->writeall_advance)) {
270 if (!in_array($object->fk_user_author, $childids)) {
277 $fuser =
new User($db);
278 $fuser->fetch($object->fk_user_author);
281 $object->fk_c_paiement =
GETPOST(
'fk_c_paiement',
'int');
282 $object->fk_user_validator =
GETPOST(
'fk_user_validator',
'int');
283 $object->note_public =
GETPOST(
'note_public',
'restricthtml');
284 $object->note_private =
GETPOST(
'note_private',
'restricthtml');
287 $ret = $extrafields->setOptionalsFromPost(null, $object);
293 if (!$error && empty($conf->global->EXPENSEREPORT_ALLOW_OVERLAPPING_PERIODS)) {
294 $overlappingExpenseReportID = $object->periode_existe($fuser, $object->date_debut, $object->date_fin,
true);
296 if ($overlappingExpenseReportID > 0) {
298 setEventMessages($langs->trans(
"ErrorDoubleDeclaration").
' <a href="'.$_SERVER[
'PHP_SELF'].
'?id='.$overlappingExpenseReportID.
'">'. $langs->trans(
'ShowTrip').
'</a>', null,
'errors');
306 $id = $object->create($user);
313 Header(
"Location: ".$_SERVER[
"PHP_SELF"].
"?id=".$id);
323 if ($action ==
'update' && $user->rights->expensereport->creer) {
327 $object->date_debut = $date_start;
328 $object->date_fin = $date_end;
330 if ($object->status < 3) {
331 $object->fk_user_validator =
GETPOST(
'fk_user_validator',
'int');
334 $object->fk_c_paiement =
GETPOST(
'fk_c_paiement',
'int');
335 $object->note_public =
GETPOST(
'note_public',
'restricthtml');
336 $object->note_private =
GETPOST(
'note_private',
'restricthtml');
337 $object->fk_user_modif = $user->id;
339 $result = $object->update($user);
341 header(
"Location: ".$_SERVER[
"PHP_SELF"].
"?id=".
GETPOST(
'id',
'int'));
348 if ($action ==
'update_extras') {
352 $ret = $extrafields->setOptionalsFromPost(null, $object,
GETPOST(
'attribute',
'restricthtml'));
359 $result = $object->insertExtraFields(
'EXPENSEREPORT_MODIFY');
367 $action =
'edit_extras';
371 if ($action ==
"confirm_validate" &&
GETPOST(
"confirm",
'alpha') ==
"yes" && $id > 0 && $user->rights->expensereport->creer) {
379 $result = $object->setValidate($user);
383 if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) {
384 $outputlangs = $langs;
386 if ($conf->global->MAIN_MULTILANGS && empty($newlang) &&
GETPOST(
'lang_id',
'aZ09')) {
387 $newlang =
GETPOST(
'lang_id',
'aZ09');
389 if ($conf->global->MAIN_MULTILANGS && empty($newlang)) {
390 $newlang = $object->thirdparty->default_lang;
392 if (!empty($newlang)) {
394 $outputlangs->setDefaultLang($newlang);
396 $model = $object->model_pdf;
397 $ret = $object->fetch($id);
399 $object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref);
406 if (!$error && $result > 0 && $object->fk_user_validator > 0) {
407 $langs->load(
"mails");
410 $destinataire =
new User($db);
411 $destinataire->fetch($object->fk_user_validator);
412 $emailTo = $destinataire->email;
415 $expediteur =
new User($db);
416 $expediteur->fetch($object->fk_user_author);
417 $emailFrom = $expediteur->email;
419 if ($emailTo && $emailFrom) {
420 $filename = array(); $filedir = array(); $mimetype = array();
423 $societeName = $conf->global->MAIN_INFO_SOCIETE_NOM;
424 if (!empty($conf->global->MAIN_APPLICATION_TITLE)) {
425 $societeName = $conf->global->MAIN_APPLICATION_TITLE;
428 $subject = $societeName.
" - ".$langs->transnoentities(
"ExpenseReportWaitingForApproval");
431 $link = $urlwithroot.
'/expensereport/card.php?id='.$object->id;
432 $link =
'<a href="'.$link.
'">'.$link.
'</a>';
433 $message = $langs->transnoentities(
"ExpenseReportWaitingForApprovalMessage", $expediteur->getFullName($langs),
get_date_range($object->date_debut, $object->date_fin,
'', $langs), $link);
448 $mailfile =
new CMailFile($subject, $emailTo, $emailFrom, $message, $filedir, $mimetype, $filename,
'',
'', 0, -1);
452 $result = $mailfile->sendfile();
454 $mesg = $langs->trans(
'MailSuccessfulySent', $mailfile->getValidAddress($emailFrom, 2), $mailfile->getValidAddress($emailTo, 2));
457 $langs->load(
"other");
458 if ($mailfile->error) {
460 $mesg .= $langs->trans(
'ErrorFailedToSendMail', $emailFrom, $emailTo);
461 $mesg .=
'<br>'.$mailfile->error;
464 setEventMessages(
'No mail sent. Feature is disabled by option MAIN_DISABLE_ALL_MAILS', null,
'warnings');
472 setEventMessages($langs->trans(
"NoEmailSentBadSenderOrRecipientEmail"), null,
'warnings');
479 header(
"Location: ".$_SERVER[
"PHP_SELF"].
"?id=".$id);
486 if ($action ==
"confirm_save_from_refuse" &&
GETPOST(
"confirm",
'alpha') ==
"yes" && $id > 0 && $user->rights->expensereport->creer) {
489 $result = $object->set_save_from_refuse($user);
493 if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) {
494 $outputlangs = $langs;
496 if ($conf->global->MAIN_MULTILANGS && empty($newlang) &&
GETPOST(
'lang_id',
'aZ09')) {
497 $newlang =
GETPOST(
'lang_id',
'aZ09');
499 if ($conf->global->MAIN_MULTILANGS && empty($newlang)) {
500 $newlang = $object->thirdparty->default_lang;
502 if (!empty($newlang)) {
504 $outputlangs->setDefaultLang($newlang);
506 $model = $object->model_pdf;
507 $ret = $object->fetch($id);
509 $object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref);
517 $destinataire =
new User($db);
518 $destinataire->fetch($object->fk_user_validator);
519 $emailTo = $destinataire->email;
522 $expediteur =
new User($db);
523 $expediteur->fetch($object->fk_user_author);
524 $emailFrom = $expediteur->email;
526 if ($emailFrom && $emailTo) {
527 $filename = array(); $filedir = array(); $mimetype = array();
530 $societeName = $conf->global->MAIN_INFO_SOCIETE_NOM;
531 if (!empty($conf->global->MAIN_APPLICATION_TITLE)) {
532 $societeName = $conf->global->MAIN_APPLICATION_TITLE;
535 $subject = $societeName.
" - ".$langs->transnoentities(
"ExpenseReportWaitingForReApproval");
538 $link = $urlwithroot.
'/expensereport/card.php?id='.$object->id;
539 $link =
'<a href="'.$link.
'">'.$link.
'</a>';
540 $dateRefusEx = explode(
" ", $object->date_refuse);
541 $message = $langs->transnoentities(
"ExpenseReportWaitingForReApprovalMessage", $dateRefusEx[0], $object->detail_refuse, $expediteur->getFullName($langs), $link);
560 $mailfile =
new CMailFile($subject, $emailTo, $emailFrom, $message, $filedir, $mimetype, $filename,
'',
'', 0, -1);
564 $result = $mailfile->sendfile();
566 $mesg = $langs->trans(
'MailSuccessfulySent', $mailfile->getValidAddress($emailFrom, 2), $mailfile->getValidAddress($emailTo, 2));
568 header(
"Location: ".$_SERVER[
"PHP_SELF"].
"?id=".$id);
571 $langs->load(
"other");
572 if ($mailfile->error) {
574 $mesg .= $langs->trans(
'ErrorFailedToSendMail', $emailFrom, $emailTo);
575 $mesg .=
'<br>'.$mailfile->error;
578 setEventMessages(
'No mail sent. Feature is disabled by option MAIN_DISABLE_ALL_MAILS', null,
'warnings');
586 setEventMessages($langs->trans(
"NoEmailSentBadSenderOrRecipientEmail"), null,
'warnings');
595 if ($action ==
"confirm_approve" &&
GETPOST(
"confirm",
'alpha') ==
"yes" && $id > 0 && $user->rights->expensereport->approve) {
599 $result = $object->setApproved($user);
603 if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) {
604 $outputlangs = $langs;
606 if ($conf->global->MAIN_MULTILANGS && empty($newlang) &&
GETPOST(
'lang_id',
'aZ09')) {
607 $newlang =
GETPOST(
'lang_id',
'aZ09');
609 if ($conf->global->MAIN_MULTILANGS && empty($newlang)) {
610 $newlang = $object->thirdparty->default_lang;
612 if (!empty($newlang)) {
614 $outputlangs->setDefaultLang($newlang);
616 $model = $object->model_pdf;
617 $ret = $object->fetch($id);
619 $object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref);
627 $destinataire =
new User($db);
628 $destinataire->fetch($object->fk_user_author);
629 $emailTo = $destinataire->email;
632 $emailCC = $conf->global->NDF_CC_EMAILS;
633 if (empty($emailTo)) {
638 $expediteur =
new User($db);
639 $expediteur->fetch($object->fk_user_approve > 0 ? $object->fk_user_approve : $object->fk_user_validator);
640 $emailFrom = $expediteur->email;
642 if ($emailFrom && $emailTo) {
643 $filename = array(); $filedir = array(); $mimetype = array();
646 $societeName = $conf->global->MAIN_INFO_SOCIETE_NOM;
647 if (!empty($conf->global->MAIN_APPLICATION_TITLE)) {
648 $societeName = $conf->global->MAIN_APPLICATION_TITLE;
651 $subject = $societeName.
" - ".$langs->transnoentities(
"ExpenseReportApproved");
654 $link = $urlwithroot.
'/expensereport/card.php?id='.$object->id;
655 $link =
'<a href="'.$link.
'">'.$link.
'</a>';
656 $message = $langs->transnoentities(
"ExpenseReportApprovedMessage", $object->ref, $destinataire->getFullName($langs), $expediteur->getFullName($langs), $link);
673 $mailfile =
new CMailFile($subject, $emailTo, $emailFrom, $message, $filedir, $mimetype, $filename,
'',
'', 0, -1);
677 $result = $mailfile->sendfile();
679 $mesg = $langs->trans(
'MailSuccessfulySent', $mailfile->getValidAddress($emailFrom, 2), $mailfile->getValidAddress($emailTo, 2));
681 header(
"Location: ".$_SERVER[
"PHP_SELF"].
"?id=".$id);
684 $langs->load(
"other");
685 if ($mailfile->error) {
687 $mesg .= $langs->trans(
'ErrorFailedToSendMail', $emailFrom, $emailTo);
688 $mesg .=
'<br>'.$mailfile->error;
691 setEventMessages(
'No mail sent. Feature is disabled by option MAIN_DISABLE_ALL_MAILS', null,
'warnings');
699 setEventMessages($langs->trans(
"NoEmailSentBadSenderOrRecipientEmail"), null,
'warnings');
708 if ($action ==
"confirm_refuse" &&
GETPOST(
'confirm',
'alpha') ==
"yes" && $id > 0 && $user->rights->expensereport->approve) {
712 $detailRefuse =
GETPOST(
'detail_refuse',
'alpha');
713 $result = $object->setDeny($user, $detailRefuse);
717 if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) {
718 $outputlangs = $langs;
720 if ($conf->global->MAIN_MULTILANGS && empty($newlang) &&
GETPOST(
'lang_id',
'aZ09')) {
721 $newlang =
GETPOST(
'lang_id',
'aZ09');
723 if ($conf->global->MAIN_MULTILANGS && empty($newlang)) {
724 $newlang = $object->thirdparty->default_lang;
726 if (!empty($newlang)) {
728 $outputlangs->setDefaultLang($newlang);
730 $model = $object->model_pdf;
731 $ret = $object->fetch($id);
733 $object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref);
741 $destinataire =
new User($db);
742 $destinataire->fetch($object->fk_user_author);
743 $emailTo = $destinataire->email;
746 $expediteur =
new User($db);
747 $expediteur->fetch($object->fk_user_refuse);
748 $emailFrom = $expediteur->email;
750 if ($emailFrom && $emailTo) {
751 $filename = array(); $filedir = array(); $mimetype = array();
754 $societeName = $conf->global->MAIN_INFO_SOCIETE_NOM;
755 if (!empty($conf->global->MAIN_APPLICATION_TITLE)) {
756 $societeName = $conf->global->MAIN_APPLICATION_TITLE;
759 $subject = $societeName.
" - ".$langs->transnoentities(
"ExpenseReportRefused");
762 $link = $urlwithroot.
'/expensereport/card.php?id='.$object->id;
763 $link =
'<a href="'.$link.
'">'.$link.
'</a>';
764 $message = $langs->transnoentities(
"ExpenseReportRefusedMessage", $object->ref, $destinataire->getFullName($langs), $expediteur->getFullName($langs), $detailRefuse, $link);
782 $mailfile =
new CMailFile($subject, $emailTo, $emailFrom, $message, $filedir, $mimetype, $filename,
'',
'', 0, -1);
786 $result = $mailfile->sendfile();
788 $mesg = $langs->trans(
'MailSuccessfulySent', $mailfile->getValidAddress($emailFrom, 2), $mailfile->getValidAddress($emailTo, 2));
790 header(
"Location: ".$_SERVER[
"PHP_SELF"].
"?id=".$id);
793 $langs->load(
"other");
794 if ($mailfile->error) {
796 $mesg .= $langs->trans(
'ErrorFailedToSendMail', $emailFrom, $emailTo);
797 $mesg .=
'<br>'.$mailfile->error;
800 setEventMessages(
'No mail sent. Feature is disabled by option MAIN_DISABLE_ALL_MAILS', null,
'warnings');
808 setEventMessages($langs->trans(
"NoEmailSentBadSenderOrRecipientEmail"), null,
'warnings');
818 if ($action ==
"confirm_cancel" &&
GETPOST(
'confirm',
'alpha') ==
"yes" && $id > 0 && $user->rights->expensereport->creer) {
819 if (!
GETPOST(
'detail_cancel',
'alpha')) {
820 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Comment")), null,
'errors');
825 if ($user->id == $object->fk_user_valid || $user->id == $object->fk_user_author) {
826 $detailCancel =
GETPOST(
'detail_cancel',
'alpha');
827 $result = $object->set_cancel($user, $detailCancel);
831 if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) {
832 $outputlangs = $langs;
834 if ($conf->global->MAIN_MULTILANGS && empty($newlang) &&
GETPOST(
'lang_id',
'aZ09')) {
835 $newlang =
GETPOST(
'lang_id',
'aZ09');
837 if ($conf->global->MAIN_MULTILANGS && empty($newlang)) {
838 $newlang = $object->thirdparty->default_lang;
840 if (!empty($newlang)) {
842 $outputlangs->setDefaultLang($newlang);
844 $model = $object->model_pdf;
845 $ret = $object->fetch($id);
847 $object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref);
855 $destinataire =
new User($db);
856 $destinataire->fetch($object->fk_user_author);
857 $emailTo = $destinataire->email;
860 $expediteur =
new User($db);
861 $expediteur->fetch($object->fk_user_cancel);
862 $emailFrom = $expediteur->email;
864 if ($emailFrom && $emailTo) {
865 $filename = array(); $filedir = array(); $mimetype = array();
868 $societeName = $conf->global->MAIN_INFO_SOCIETE_NOM;
869 if (!empty($conf->global->MAIN_APPLICATION_TITLE)) {
870 $societeName = $conf->global->MAIN_APPLICATION_TITLE;
873 $subject = $societeName.
" - ".$langs->transnoentities(
"ExpenseReportCanceled");
876 $link = $urlwithroot.
'/expensereport/card.php?id='.$object->id;
877 $link =
'<a href="'.$link.
'">'.$link.
'</a>';
878 $message = $langs->transnoentities(
"ExpenseReportCanceledMessage", $object->ref, $destinataire->getFullName($langs), $expediteur->getFullName($langs), $detailCancel, $link);
896 $mailfile =
new CMailFile($subject, $emailTo, $emailFrom, $message, $filedir, $mimetype, $filename,
'',
'', 0, -1);
900 $result = $mailfile->sendfile();
902 $mesg = $langs->trans(
'MailSuccessfulySent', $mailfile->getValidAddress($emailFrom, 2), $mailfile->getValidAddress($emailTo, 2));
904 header(
"Location: ".$_SERVER[
"PHP_SELF"].
"?id=".$id);
907 $langs->load(
"other");
908 if ($mailfile->error) {
910 $mesg .= $langs->trans(
'ErrorFailedToSendMail', $emailFrom, $emailTo);
911 $mesg .=
'<br>'.$mailfile->error;
914 setEventMessages(
'No mail sent. Feature is disabled by option MAIN_DISABLE_ALL_MAILS', null,
'warnings');
922 setEventMessages($langs->trans(
"NoEmailSentBadSenderOrRecipientEmail"), null,
'warnings');
935 if ($action ==
"confirm_setdraft" &&
GETPOST(
'confirm',
'alpha') ==
"yes" && $id > 0 && $user->rights->expensereport->creer) {
938 if ($user->id == $object->fk_user_author || $user->id == $object->fk_user_valid) {
939 $result = $object->setStatut(0);
943 if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) {
944 $outputlangs = $langs;
946 if ($conf->global->MAIN_MULTILANGS && empty($newlang) &&
GETPOST(
'lang_id',
'aZ09')) {
947 $newlang =
GETPOST(
'lang_id',
'aZ09');
949 if ($conf->global->MAIN_MULTILANGS && empty($newlang)) {
950 $newlang = $object->thirdparty->default_lang;
952 if (!empty($newlang)) {
954 $outputlangs->setDefaultLang($newlang);
956 $model = $object->model_pdf;
957 $ret = $object->fetch($id);
959 $object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref);
964 header(
"Location: ".$_SERVER[
"PHP_SELF"].
"?id=".$id);
974 if ($action ==
'set_unpaid' && $id > 0 && $user->rights->expensereport->to_paid) {
978 $result = $object->setUnpaid($user);
982 if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) {
983 $outputlangs = $langs;
985 if ($conf->global->MAIN_MULTILANGS && empty($newlang) &&
GETPOST(
'lang_id',
'aZ09')) {
986 $newlang =
GETPOST(
'lang_id',
'aZ09');
988 if ($conf->global->MAIN_MULTILANGS && empty($newlang)) {
989 $newlang = $object->thirdparty->default_lang;
991 if (!empty($newlang)) {
993 $outputlangs->setDefaultLang($newlang);
995 $model = $object->model_pdf;
996 $ret = $object->fetch($id);
998 $object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref);
1003 if ($action ==
'set_paid' && $id > 0 && $user->rights->expensereport->to_paid) {
1005 $object->fetch($id);
1007 $result = $object->setPaid($id, $user);
1011 if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) {
1012 $outputlangs = $langs;
1014 if ($conf->global->MAIN_MULTILANGS && empty($newlang) &&
GETPOST(
'lang_id',
'aZ09')) {
1015 $newlang =
GETPOST(
'lang_id',
'aZ09');
1017 if ($conf->global->MAIN_MULTILANGS && empty($newlang)) {
1018 $newlang = $object->thirdparty->default_lang;
1020 if (!empty($newlang)) {
1021 $outputlangs =
new Translate(
"", $conf);
1022 $outputlangs->setDefaultLang($newlang);
1024 $model = $object->model_pdf;
1025 $ret = $object->fetch($id);
1027 $object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref);
1035 $destinataire =
new User($db);
1036 $destinataire->fetch($object->fk_user_author);
1037 $emailTo = $destinataire->email;
1040 $expediteur =
new User($db);
1041 $expediteur->fetch($user->id);
1042 $emailFrom = $expediteur->email;
1044 if ($emailFrom && $emailTo) {
1045 $filename = array(); $filedir = array(); $mimetype = array();
1048 $societeName = $conf->global->MAIN_INFO_SOCIETE_NOM;
1049 if (!empty($conf->global->MAIN_APPLICATION_TITLE)) {
1050 $societeName = $conf->global->MAIN_APPLICATION_TITLE;
1053 $subject = $societeName.
" - ".$langs->transnoentities(
"ExpenseReportPaid");
1056 $link = $urlwithroot.
'/expensereport/card.php?id='.$object->id;
1057 $link =
'<a href="'.$link.
'">'.$link.
'</a>';
1058 $message = $langs->transnoentities(
"ExpenseReportPaidMessage", $object->ref, $destinataire->getFullName($langs), $expediteur->getFullName($langs), $link);
1061 $object->setDocModel($user,
"");
1062 $resultPDF = expensereport_pdf_create($db, $object,
'',
"", $langs);
1065 $mailfile =
new CMailFile($subject, $emailTo, $emailFrom, $message, $filedir, $mimetype, $filename,
'',
'', 0, -1);
1069 $result = $mailfile->sendfile();
1071 $mesg = $langs->trans(
'MailSuccessfulySent', $mailfile->getValidAddress($emailFrom, 2), $mailfile->getValidAddress($emailTo, 2));
1073 header(
"Location: ".$_SERVER[
"PHP_SELF"].
"?id=".$id);
1076 $langs->load(
"other");
1077 if ($mailfile->error) {
1079 $mesg .= $langs->trans(
'ErrorFailedToSendMail', $emailFrom, $emailTo);
1080 $mesg .=
'<br>'.$mailfile->error;
1083 setEventMessages(
'No mail sent. Feature is disabled by option MAIN_DISABLE_ALL_MAILS', null,
'warnings');
1091 setEventMessages($langs->trans(
"NoEmailSentBadSenderOrRecipientEmail"), null,
'warnings');
1100 if ($action ==
"addline" && $user->rights->expensereport->creer) {
1106 $arrayoffiles =
GETPOST(
'attachfile',
'array');
1107 if (is_array($arrayoffiles) && !empty($arrayoffiles[0])) {
1108 include_once DOL_DOCUMENT_ROOT.
'/ecm/class/ecmfiles.class.php';
1109 $entityprefix = ($conf->entity !=
'1') ? $conf->entity.
'/' :
'';
1110 $relativepath =
'expensereport/'.$object->ref.
'/'.$arrayoffiles[0];
1112 $ecmfiles->
fetch(0,
'', $relativepath);
1113 $fk_ecm_files = $ecmfiles->id;
1118 if (empty($vatrate)) {
1121 $tmpvat =
price2num(preg_replace(
'/\s*\(.*\)/',
'', $vatrate));
1125 if (empty($value_unit)) {
1126 $value_unit =
price2num($value_unit_ht + ($value_unit_ht * $tmpvat / 100),
'MU');
1129 $fk_c_exp_tax_cat =
GETPOST(
'fk_c_exp_tax_cat',
'int');
1136 if (!($fk_c_type_fees > 0)) {
1138 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Type")), null,
'errors');
1142 if ((
float) $tmpvat < 0 || $tmpvat ===
'') {
1144 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"VAT")), null,
'errors');
1149 if (empty($date) || $date ==
"--") {
1151 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Date")), null,
'errors');
1152 } elseif ($date < $object->date_debut || $date > ($object->date_fin + (24 * 3600 - 1))) {
1154 $langs->load(
"errors");
1155 setEventMessages($langs->trans(
"WarningDateOfLineMustBeInExpenseReportRange"), null,
'warnings');
1159 if ($value_unit == 0) {
1161 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"PriceUTTC")), null,
'errors');
1165 if ($projectRequired && $fk_project <= 0) {
1167 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Project")), null,
'errors');
1171 if ($fileRequired && $fk_ecm_files == 0) {
1173 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"File")), null,
'errors');
1180 $result = $object->addline($qty, $value_unit, $fk_c_type_fees, $vatrate, $date, $comments, $fk_project, $fk_c_exp_tax_cat, $type, $fk_ecm_files);
1182 $ret = $object->fetch($object->id);
1184 if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) {
1186 $outputlangs = $langs;
1187 $newlang =
GETPOST(
'lang_id',
'alpha');
1188 if (!empty($conf->global->MAIN_MULTILANGS) && empty($newlang)) {
1189 $newlang = $object->thirdparty->default_lang;
1191 if (!empty($newlang)) {
1192 $outputlangs =
new Translate(
"", $conf);
1193 $outputlangs->setDefaultLang($newlang);
1196 $object->generateDocument($object->model_pdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
1200 unset($value_unit_ht);
1204 unset($fk_c_type_fees);
1216 if ($action ==
'confirm_delete_line' &&
GETPOST(
"confirm",
'alpha') ==
"yes" && $user->rights->expensereport->creer) {
1218 $object->fetch($id);
1221 $object_ligne->fetch(
GETPOST(
"rowid",
'int'));
1222 $total_ht = $object_ligne->total_ht;
1223 $total_tva = $object_ligne->total_tva;
1225 $result = $object->deleteline(
GETPOST(
"rowid",
'int'), $user);
1229 if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) {
1230 $outputlangs = $langs;
1232 if ($conf->global->MAIN_MULTILANGS && empty($newlang) &&
GETPOST(
'lang_id',
'aZ09')) {
1233 $newlang =
GETPOST(
'lang_id',
'aZ09');
1235 if ($conf->global->MAIN_MULTILANGS && empty($newlang)) {
1236 $newlang = $object->thirdparty->default_lang;
1238 if (!empty($newlang)) {
1239 $outputlangs =
new Translate(
"", $conf);
1240 $outputlangs->setDefaultLang($newlang);
1242 $model = $object->model_pdf;
1243 $ret = $object->fetch($id);
1245 $object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref);
1249 header(
"Location: ".$_SERVER[
"PHP_SELF"].
"?id=".
GETPOST(
'id',
'int'));
1256 if ($action ==
"updateline" && $user->rights->expensereport->creer) {
1258 $object->fetch($id);
1263 $arrayoffiles =
GETPOST(
'attachfile',
'array');
1264 if (is_array($arrayoffiles) && !empty($arrayoffiles[0])) {
1265 include_once DOL_DOCUMENT_ROOT.
'/ecm/class/ecmfiles.class.php';
1266 $relativepath =
'expensereport/'.$object->ref.
'/'.$arrayoffiles[0];
1268 $ecmfiles->fetch(0,
'', $relativepath);
1269 $fk_ecm_files = $ecmfiles->id;
1273 $rowid =
GETPOST(
'rowid',
'int');
1274 $type_fees_id =
GETPOST(
'fk_c_type_fees',
'int');
1275 $fk_c_exp_tax_cat =
GETPOST(
'fk_c_exp_tax_cat',
'int');
1276 $projet_id = $fk_project;
1277 $comments =
GETPOST(
'comments',
'restricthtml');
1279 $vatrate =
GETPOST(
'vatrate',
'alpha');
1282 if (empty($vatrate)) {
1285 $tmpvat =
price2num(preg_replace(
'/\s*\(.*\)/',
'', $vatrate));
1289 if (empty($value_unit)) {
1290 $value_unit =
price2num($value_unit_ht + ($value_unit_ht * $tmpvat / 100),
'MU');
1293 if (!
GETPOST(
'fk_c_type_fees',
'int') > 0) {
1295 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Type")), null,
'errors');
1298 if ((
float) $tmpvat < 0 || $tmpvat ==
'') {
1300 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Vat")), null,
'errors');
1304 if ($date < $object->date_debut || $date > ($object->date_fin + (24 * 3600 - 1))) {
1305 $langs->load(
"errors");
1306 setEventMessages($langs->trans(
"WarningDateOfLineMustBeInExpenseReportRange"), null,
'warnings');
1310 if ($projectRequired && $projet_id <= 0) {
1312 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Project")), null,
'errors');
1317 $result = $object->updateline($rowid, $type_fees_id, $projet_id, $vatrate, $comments, $qty, $value_unit, $date, $id, $fk_c_exp_tax_cat, $fk_ecm_files);
1321 if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) {
1322 $outputlangs = $langs;
1324 if ($conf->global->MAIN_MULTILANGS && empty($newlang) &&
GETPOST(
'lang_id',
'aZ09')) {
1325 $newlang =
GETPOST(
'lang_id',
'aZ09');
1327 if ($conf->global->MAIN_MULTILANGS && empty($newlang)) {
1328 $newlang = $object->thirdparty->default_lang;
1330 if (!empty($newlang)) {
1331 $outputlangs =
new Translate(
"", $conf);
1332 $outputlangs->setDefaultLang($newlang);
1334 $model = $object->model_pdf;
1335 $ret = $object->fetch($id);
1337 $object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref);
1341 unset($value_unit_ht);
1345 unset($fk_c_type_fees);
1359 include DOL_DOCUMENT_ROOT.
'/core/actions_printing.inc.php';
1362 $triggersendname =
'EXPENSEREPORT_SENTBYMAIL';
1363 $autocopy =
'MAIN_MAIL_AUTOCOPY_EXPENSEREPORT_TO';
1364 $trackid =
'exp'.$object->id;
1365 include DOL_DOCUMENT_ROOT.
'/core/actions_sendmails.inc.php';
1368 $upload_dir = $conf->expensereport->dir_output;
1369 include DOL_DOCUMENT_ROOT.
'/core/actions_builddoc.inc.php';
1377 $title = $langs->trans(
"ExpenseReport").
" - ".$langs->trans(
"Card");
1378 $help_url =
"EN:Module_Expense_Reports|FR:Module_Notes_de_frais";
1385 $projecttmp =
new Project($db);
1387 $bankaccountstatic =
new Account($db);
1388 $ecmfilesstatic =
new EcmFiles($db);
1392 if ($action ==
'create') {
1395 print
'<form action="'.$_SERVER[
'PHP_SELF'].
'" method="post" name="create">';
1396 print
'<input type="hidden" name="token" value="'.newToken().
'">';
1397 print
'<input type="hidden" name="action" value="add">';
1401 print
'<table class="border centpercent">';
1406 print
'<td class="titlefieldcreate fieldrequired">'.$langs->trans(
"DateStart").
'</td>';
1408 print
$form->selectDate($date_start ? $date_start : -1,
'date_debut', 0, 0, 0,
'', 1, 1);
1414 print
'<td class="fieldrequired">'.$langs->trans(
"DateEnd").
'</td>';
1416 print
$form->selectDate($date_end ? $date_end : -1,
'date_fin', 0, 0, 0,
'', 1, 1);
1422 print
'<td class="fieldrequired">'.$langs->trans(
"User").
'</td>';
1424 $defaultselectuser = $user->id;
1425 if (
GETPOST(
'fk_user_author',
'int') > 0) {
1426 $defaultselectuser =
GETPOST(
'fk_user_author',
'int');
1428 $include_users =
'hierarchyme';
1429 if (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->expensereport->writeall_advance)) {
1430 $include_users = array();
1432 $s =
$form->select_dolusers($defaultselectuser,
"fk_user_author", 0,
"", 0, $include_users,
'',
'0,'.$conf->entity);
1439 print
'<td>'.$langs->trans(
"VALIDATOR").
'</td>';
1442 $include_users = $object->fetch_users_approver_expensereport();
1443 if (empty($include_users)) {
1444 print
img_warning().
' '.$langs->trans(
"NobodyHasPermissionToValidateExpenseReport");
1446 $defaultselectuser = (empty($user->fk_user_expense_validator) ? $user->fk_user : $user->fk_user_expense_validator);
1447 if (!empty($conf->global->EXPENSEREPORT_DEFAULT_VALIDATOR)) {
1448 $defaultselectuser = $conf->global->EXPENSEREPORT_DEFAULT_VALIDATOR;
1450 if (
GETPOST(
'fk_user_validator',
'int') > 0) {
1451 $defaultselectuser =
GETPOST(
'fk_user_validator',
'int');
1453 $s =
$form->select_dolusers($defaultselectuser,
"fk_user_validator", 1,
"", ((empty($defaultselectuser) || empty($conf->global->EXPENSEREPORT_DEFAULT_VALIDATOR_UNCHANGEABLE)) ? 0 : 1), $include_users);
1454 print
$form->textwithpicto($s, $langs->trans(
"AnyOtherInThisListCanValidate"));
1460 if (!empty($conf->global->EXPENSEREPORT_ASK_PAYMENTMODE_ON_CREATION)) {
1462 print
'<td>'.$langs->trans(
"ModePaiement").
'</td>';
1464 $form->select_types_paiements(
'',
'fk_c_paiement');
1473 print
'<td class="tdtop">'.$langs->trans(
'NotePublic').
'</td>';
1476 $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%');
1477 print $doleditor->Create(1);
1481 $note_private =
GETPOSTISSET(
'note_private') ?
GETPOST(
'note_private',
'restricthtml') :
'';
1483 if (empty($user->socid)) {
1485 print
'<td class="tdtop">'.$langs->trans(
'NotePrivate').
'</td>';
1488 $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%');
1489 print $doleditor->Create(1);
1494 $parameters = array(
'colspan' =>
' colspan="3"',
'cols' => 3);
1495 $reshook = $hookmanager->executeHooks(
'formObjectOptions', $parameters, $object, $action);
1496 print $hookmanager->resPrint;
1497 if (empty($reshook)) {
1498 print $object->showOptionals($extrafields,
'create', $parameters);
1506 print
$form->buttonsSaveCancel(
"AddTrip");
1509 } elseif ($id > 0 || $ref) {
1510 $result = $object->fetch($id, $ref);
1513 if (!in_array($object->fk_user_author, $user->getAllChildIds(1))) {
1514 if (empty($user->rights->expensereport->readall) && empty($user->rights->expensereport->lire_tous)
1515 && (empty($conf->global->MAIN_USE_ADVANCED_PERMS) || empty($user->rights->expensereport->writeall_advance))) {
1518 print
'<div class="tabBar">';
1519 print $langs->trans(
'NotUserRightToView');
1532 if ($action ==
'edit' && ($object->status < 3 || $object->status == 99)) {
1533 print
"<form name='update' action=\"".$_SERVER[
'PHP_SELF'].
"\" method=\"post\">\n";
1534 print
'<input type="hidden" name="token" value="'.newToken().
'">';
1535 print
'<input type="hidden" name="id" value="'.$id.
'">';
1539 if ($object->status == 99) {
1540 print
'<input type="hidden" name="action" value="updateFromRefuse">';
1542 print
'<input type="hidden" name="action" value="update">';
1545 $linkback =
'<a href="'.DOL_URL_ROOT.
'/expensereport/list.php?restore_lastsearch_values=1'.(!empty($socid) ?
'&socid='.$socid :
'').
'">'.$langs->trans(
"BackToList").
'</a>';
1547 print
'<table class="border" style="width:100%;">';
1550 print
'<td>'.$langs->trans(
"User").
'</td>';
1552 $userfee =
new User($db);
1553 if ($object->fk_user_author > 0) {
1554 $userfee->fetch($object->fk_user_author);
1555 print $userfee->getNomUrl(-1);
1560 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"Ref").
'</td><td>';
1561 print
$form->showrefnav($object,
'ref', $linkback, 1,
'ref',
'ref',
'');
1565 print
'<td>'.$langs->trans(
"DateStart").
'</td>';
1567 print
$form->selectDate($object->date_debut,
'date_debut');
1571 print
'<td>'.$langs->trans(
"DateEnd").
'</td>';
1573 print
$form->selectDate($object->date_fin,
'date_fin');
1577 if (!empty($conf->global->EXPENSEREPORT_ASK_PAYMENTMODE_ON_CREATION)) {
1579 print
'<td>'.$langs->trans(
"ModePaiement").
'</td>';
1581 $form->select_types_paiements($object->fk_c_paiement,
'fk_c_paiement');
1586 if ($object->status < 3) {
1588 print
'<td>'.$langs->trans(
"VALIDATOR").
'</td>';
1590 $include_users = $object->fetch_users_approver_expensereport();
1591 $s =
$form->select_dolusers($object->fk_user_validator,
"fk_user_validator", 1,
"", 0, $include_users);
1592 print
$form->textwithpicto($s, $langs->trans(
"AnyOtherInThisListCanValidate"));
1597 print
'<td>'.$langs->trans(
"VALIDOR").
'</td>';
1599 $userfee =
new User($db);
1600 $userfee->fetch($object->fk_user_valid);
1601 print $userfee->getNomUrl(-1);
1605 if ($object->status == 6) {
1607 print
'<td>'.$langs->trans(
"AUTHORPAIEMENT").
'</td>';
1609 $userfee =
new User($db);
1610 $userfee->fetch($user->id);
1611 print $userfee->getNomUrl(-1);
1623 print
$form->buttonsSaveCancel(
"Modify");
1627 $taxlessUnitPriceDisabled = ! empty($conf->global->EXPENSEREPORT_FORCE_LINE_AMOUNTS_INCLUDING_TAXES_ONLY) ?
' disabled' :
'';
1634 if ($action ==
'clone') {
1636 $criteriaforfilter =
'hierarchyme';
1637 if (!empty($user->rights->expensereport->readall)) {
1638 $criteriaforfilter =
'';
1640 $formquestion = array(
1642 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'))
1645 $formconfirm =
$form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.$object->id, $langs->trans(
'ToClone'), $langs->trans(
'ConfirmCloneExpenseReport', $object->ref),
'confirm_clone', $formquestion,
'yes', 1);
1648 if ($action ==
'save') {
1649 $formconfirm =
$form->formconfirm($_SERVER[
"PHP_SELF"].
"?id=".$id, $langs->trans(
"SaveTrip"), $langs->trans(
"ConfirmSaveTrip"),
"confirm_validate",
"",
"", 1);
1652 if ($action ==
'save_from_refuse') {
1653 $formconfirm =
$form->formconfirm($_SERVER[
"PHP_SELF"].
"?id=".$id, $langs->trans(
"SaveTrip"), $langs->trans(
"ConfirmSaveTrip"),
"confirm_save_from_refuse",
"",
"", 1);
1656 if ($action ==
'delete') {
1657 $formconfirm =
$form->formconfirm($_SERVER[
"PHP_SELF"].
"?id=".$id, $langs->trans(
"DeleteTrip"), $langs->trans(
"ConfirmDeleteTrip"),
"confirm_delete",
"",
"", 1);
1660 if ($action ==
'validate') {
1661 $formconfirm =
$form->formconfirm($_SERVER[
"PHP_SELF"].
"?id=".$id, $langs->trans(
"ValideTrip"), $langs->trans(
"ConfirmValideTrip"),
"confirm_approve",
"",
"", 1);
1664 if ($action ==
'paid') {
1665 $formconfirm =
$form->formconfirm($_SERVER[
"PHP_SELF"].
"?id=".$id, $langs->trans(
"PaidTrip"), $langs->trans(
"ConfirmPaidTrip"),
"confirm_paid",
"",
"", 1);
1668 if ($action ==
'cancel') {
1669 $array_input = array(
'text'=>$langs->trans(
"ConfirmCancelTrip"), array(
'type'=>
"text",
'label'=>
'<strong>'.$langs->trans(
"Comment").
'</strong>',
'name'=>
"detail_cancel",
'value'=>
""));
1670 $formconfirm =
$form->formconfirm($_SERVER[
"PHP_SELF"].
"?id=".$id, $langs->trans(
"Cancel"),
"",
"confirm_cancel", $array_input,
"", 1);
1673 if ($action ==
'setdraft') {
1674 $formconfirm =
$form->formconfirm($_SERVER[
"PHP_SELF"].
"?id=".$id, $langs->trans(
"BrouillonnerTrip"), $langs->trans(
"ConfirmBrouillonnerTrip"),
"confirm_setdraft",
"",
"", 1);
1677 if ($action ==
'refuse') {
1678 $array_input = array(
'text'=>$langs->trans(
"ConfirmRefuseTrip"), array(
'type'=>
"text",
'label'=>$langs->trans(
"Comment"),
'name'=>
"detail_refuse",
'value'=>
""));
1679 $formconfirm =
$form->formconfirm($_SERVER[
"PHP_SELF"].
"?id=".$id, $langs->trans(
"Deny"),
'',
"confirm_refuse", $array_input,
"yes", 1);
1682 if ($action ==
'delete_line') {
1683 $formconfirm =
$form->formconfirm($_SERVER[
"PHP_SELF"].
"?id=".$id.
"&rowid=".
GETPOST(
'rowid',
'int'), $langs->trans(
"DeleteLine"), $langs->trans(
"ConfirmDeleteLine"),
"confirm_delete_line",
'',
'yes', 1);
1690 $linkback =
'<a href="'.DOL_URL_ROOT.
'/expensereport/list.php?restore_lastsearch_values=1'.(!empty($socid) ?
'&socid='.$socid :
'').
'">'.$langs->trans(
"BackToList").
'</a>';
1692 $morehtmlref =
'<div class="refidno">';
1731 $morehtmlref .=
'</div>';
1733 dol_banner_tab($object,
'ref', $linkback, 1,
'ref',
'ref', $morehtmlref);
1735 print
'<div class="fichecenter">';
1736 print
'<div class="fichehalfleft">';
1737 print
'<div class="underbanner clearboth"></div>';
1739 print
'<table class="border tableforfield centpercent">';
1743 print
'<td class="titlefield">'.$langs->trans(
"User").
'</td>';
1745 if ($object->fk_user_author > 0) {
1746 $userauthor =
new User($db);
1747 $result = $userauthor->fetch($object->fk_user_author);
1750 } elseif ($result > 0) {
1751 print $userauthor->getNomUrl(-1);
1758 print
'<td class="titlefield">'.$langs->trans(
"Period").
'</td>';
1760 print
get_date_range($object->date_debut, $object->date_fin,
'day', $langs, 0);
1763 if (!empty($conf->global->EXPENSEREPORT_ASK_PAYMENTMODE_ON_CREATION)) {
1765 print
'<td>'.$langs->trans(
"ModePaiement").
'</td>';
1766 print
'<td>'.$object->fk_c_paiement.
'</td>';
1772 print
'<td>'.$langs->trans(
"DATE_SAVE").
'</td>';
1773 print
'<td>'.dol_print_date($object->date_valid,
'dayhour',
'tzuser');
1774 if ($object->status == 2 && $object->hasDelay(
'toapprove')) {
1775 print
' '.img_warning($langs->trans(
"Late").
' - '.$langs->trans(
"ToApprove"));
1777 if ($object->status == 5 && $object->hasDelay(
'topay')) {
1778 print
' '.img_warning($langs->trans(
"Late").
' - '.$langs->trans(
"ToPay"));
1786 print
'<td>'.$langs->trans(
"VALIDATOR").
'</td>';
1788 if ($object->fk_user_validator > 0) {
1789 $userfee =
new User($db);
1790 $result = $userfee->fetch($object->fk_user_validator);
1792 print $userfee->getNomUrl(-1);
1794 if (empty($userfee->email) || !
isValidEmail($userfee->email)) {
1795 $langs->load(
"errors");
1796 print
img_warning($langs->trans(
"ErrorBadEMail", $userfee->email));
1802 print
'<td>'.$langs->trans(
"CANCEL_USER").
'</span></td>';
1804 if ($object->fk_user_cancel > 0) {
1805 $userfee =
new User($db);
1806 $result = $userfee->fetch($object->fk_user_cancel);
1808 print $userfee->getNomUrl(-1);
1814 print
'<td>'.$langs->trans(
"MOTIF_CANCEL").
'</td>';
1815 print
'<td>'.$object->detail_cancel.
'</td></tr>';
1818 print
'<td>'.$langs->trans(
"DATE_CANCEL").
'</td>';
1819 print
'<td>'.dol_print_date($object->date_cancel,
'dayhour',
'tzuser').
'</td></tr>';
1823 print
'<td>'.$langs->trans(
"ApprovedBy").
'</td>';
1825 if ($object->fk_user_approve > 0) {
1826 $userapp =
new User($db);
1827 $result = $userapp->fetch($object->fk_user_approve);
1829 print $userapp->getNomUrl(-1);
1835 print
'<td>'.$langs->trans(
"DateApprove").
'</td>';
1836 print
'<td>'.dol_print_date($object->date_approve,
'dayhour',
'tzuser').
'</td></tr>';
1840 if ($object->status == 99 || !empty($object->detail_refuse)) {
1842 print
'<td>'.$langs->trans(
"REFUSEUR").
'</td>';
1844 $userfee =
new User($db);
1845 $result = $userfee->fetch($object->fk_user_refuse);
1847 print $userfee->getNomUrl(-1);
1852 print
'<td>'.$langs->trans(
"DATE_REFUS").
'</td>';
1853 print
'<td>'.dol_print_date($object->date_refuse,
'dayhour',
'tzuser');
1854 if ($object->detail_refuse) {
1855 print
' - '.$object->detail_refuse;
1861 if ($object->status == $object::STATUS_CLOSED) {
1879 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_view.tpl.php';
1884 print
'<div class="fichehalfright">';
1885 print
'<div class="underbanner clearboth"></div>';
1887 print
'<table class="border tableforfield centpercent">';
1891 print
'<td class="titlefieldmiddle">'.$langs->trans(
"AmountHT").
'</td>';
1892 print
'<td class="nowrap amountcard">'.price($object->total_ht, 1,
'', 1, - 1, - 1, $conf->currency).
'</td>';
1911 print
'<td>'.$langs->trans(
"AmountVAT").
'</td>';
1912 print
'<td class="nowrap amountcard">'.price($object->total_tva, 1,
'', 1, -1, -1, $conf->currency).
'</td>';
1916 if ($mysoc->localtax1_assuj ==
"1" || $object->total_localtax1 != 0) {
1917 print
'<tr><td>'.$langs->transcountry(
"AmountLT1", $mysoc->country_code).
'</td>';
1918 print
'<td class="valuefield">'.price($object->total_localtax1, 1,
'', 1, -1, -1, $conf->currency).
'</td></tr>';
1920 if ($mysoc->localtax2_assuj ==
"1" || $object->total_localtax2 != 0) {
1921 print
'<tr><td>'.$langs->transcountry(
"AmountLT2", $mysoc->country_code).
'</td>';
1922 print
'<td class="valuefield">'.price($object->total_localtax2, 1,
'', 1, -1, -1, $conf->currency).
'</td></tr>';
1926 print
'<td>'.$langs->trans(
"AmountTTC").
'</td>';
1927 print
'<td class="nowrap amountcard">'.price($object->total_ttc, 1,
'', 1, -1, -1, $conf->currency).
'</td>';
1933 if (!empty($conf->banque->enabled)) {
1938 print
'<table class="noborder paymenttable centpercent">';
1940 print
'<tr class="liste_titre">';
1941 print
'<td class="liste_titre">'.$langs->trans(
'Payments').
'</td>';
1942 print
'<td class="liste_titre">'.$langs->trans(
'Date').
'</td>';
1943 print
'<td class="liste_titre">'.$langs->trans(
'Type').
'</td>';
1944 if (!empty($conf->banque->enabled)) {
1945 print
'<td class="liste_titre right">'.$langs->trans(
'BankAccount').
'</td>';
1947 print
'<td class="liste_titre right">'.$langs->trans(
'Amount').
'</td>';
1948 print
'<td class="liste_titre" width="18"> </td>';
1952 $sql =
"SELECT p.rowid, p.num_payment, p.datep as dp, p.amount, p.fk_bank,";
1953 $sql .=
"c.code as payment_code, c.libelle as payment_type,";
1954 $sql .=
"ba.rowid as baid, ba.ref as baref, ba.label, ba.number as banumber, ba.account_number, ba.fk_accountancy_journal";
1955 $sql .=
" FROM ".MAIN_DB_PREFIX.
"expensereport as e, ".MAIN_DB_PREFIX.
"payment_expensereport as p";
1956 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"c_paiement as c ON p.fk_typepayment = c.id";
1957 $sql .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'bank as b ON p.fk_bank = b.rowid';
1958 $sql .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'bank_account as ba ON b.fk_account = ba.rowid';
1959 $sql .=
" WHERE e.rowid = ".((int) $id);
1960 $sql .=
" AND p.fk_expensereport = e.rowid";
1961 $sql .=
' AND e.entity IN ('.getEntity(
'expensereport').
')';
1962 $sql .=
" ORDER BY dp";
1964 $resql = $db->query($sql);
1966 $num = $db->num_rows(
$resql);
1967 $i = 0; $totalpaid = 0;
1969 $objp = $db->fetch_object(
$resql);
1971 $paymentexpensereportstatic->id = $objp->rowid;
1972 $paymentexpensereportstatic->datep = $db->jdate($objp->dp);
1973 $paymentexpensereportstatic->ref = $objp->rowid;
1974 $paymentexpensereportstatic->num_payment = $objp->num_payment;
1975 $paymentexpensereportstatic->type_code = $objp->payment_code;
1976 $paymentexpensereportstatic->type_label = $objp->payment_type;
1978 print
'<tr class="oddseven">';
1980 print $paymentexpensereportstatic->getNomUrl(1);
1982 print
'<td>'.dol_print_date($db->jdate($objp->dp),
'day').
"</td>\n";
1983 $labeltype = $langs->trans(
"PaymentType".$objp->payment_code) != (
"PaymentType".$objp->payment_code) ? $langs->trans(
"PaymentType".$objp->payment_code) : $objp->payment_type;
1984 print
"<td>".$labeltype.
' '.$objp->num_payment.
"</td>\n";
1986 if (!empty($conf->banque->enabled)) {
1987 $bankaccountstatic->id = $objp->baid;
1988 $bankaccountstatic->ref = $objp->baref;
1989 $bankaccountstatic->label = $objp->baref;
1990 $bankaccountstatic->number = $objp->banumber;
1992 if (!empty($conf->accounting->enabled)) {
1993 $bankaccountstatic->account_number = $objp->account_number;
1996 $accountingjournal->fetch($objp->fk_accountancy_journal);
1997 $bankaccountstatic->accountancy_journal = $accountingjournal->getNomUrl(0, 1, 1,
'', 1);
2000 print
'<td class="right">';
2001 if ($bankaccountstatic->id) {
2002 print $bankaccountstatic->getNomUrl(1,
'transactions');
2006 print
'<td class="right">'.price($objp->amount).
"</td>";
2009 $totalpaid += $objp->amount;
2012 if (!is_null($totalpaid)) {
2016 $remaintopay =
price2num($object->total_ttc - $totalpaid);
2017 $resteapayeraffiche = $remaintopay;
2019 $cssforamountpaymentcomplete =
'amountpaymentcomplete';
2022 $cssforamountpaymentcomplete =
'amountpaymentneutral';
2023 $resteapayeraffiche = 0;
2024 } elseif ($object->paid == 0) {
2025 $cssforamountpaymentcomplete =
'amountpaymentneutral';
2027 print
'<tr><td colspan="'.$nbcols.
'" class="right">'.$langs->trans(
"AlreadyPaid").
':</td><td class="right">'.
price($totalpaid).
'</td><td></td></tr>';
2028 print
'<tr><td colspan="'.$nbcols.
'" class="right">'.$langs->trans(
"AmountExpected").
':</td><td class="right">'.
price($object->total_ttc).
'</td><td></td></tr>';
2030 print
'<tr><td colspan="'.$nbcols.
'" class="right">'.$langs->trans(
"RemainderToPay").
':</td>';
2031 print
'<td class="right'.($resteapayeraffiche ?
' amountremaintopay' : (
' '.$cssforamountpaymentcomplete)).
'">'.
price($resteapayeraffiche).
'</td><td></td></tr>';
2042 print
'<div class="clearboth"></div><br>';
2044 print
'<div style="clear: both;"></div>';
2046 $actiontouse =
'updateline';
2047 if (($object->status == 0 || $object->status == 99) && $action !=
'editline') {
2048 $actiontouse =
'addline';
2051 print
'<form name="expensereport" action="'.$_SERVER[
"PHP_SELF"].
'" enctype="multipart/form-data" method="post" >';
2052 print
'<input type="hidden" name="token" value="'.newToken().
'">';
2053 print
'<input type="hidden" name="action" value="'.$actiontouse.
'">';
2054 print
'<input type="hidden" name="id" value="'.$object->id.
'">';
2055 print
'<input type="hidden" name="fk_expensereport" value="'.$object->id.
'" />';
2057 print
'<div class="div-table-responsive-no-min">';
2058 print
'<table id="tablelines" class="noborder centpercent">';
2060 if (!empty($object->lines)) {
2063 print
'<tr class="liste_titre headerexpensereportdet">';
2064 print
'<td class="center linecollinenb">'.$langs->trans(
'LineNb').
'</td>';
2066 print
'<td class="center linecoldate">'.$langs->trans(
'Date').
'</td>';
2067 if (!empty($conf->project->enabled)) {
2068 print
'<td class="minwidth100imp linecolproject">'.$langs->trans(
'Project').
'</td>';
2070 print
'<td class="center linecoltype">'.$langs->trans(
'Type').
'</td>';
2071 if (!empty($conf->global->MAIN_USE_EXPENSE_IK)) {
2072 print
'<td class="center linecolcarcategory">'.$langs->trans(
'CarCategory').
'</td>';
2074 print
'<td class="center linecoldescription">'.$langs->trans(
'Description').
'</td>';
2075 print
'<td class="right linecolvat">'.$langs->trans(
'VAT').
'</td>';
2076 print
'<td class="right linecolpriceuht">'.$langs->trans(
'PriceUHT').
'</td>';
2077 print
'<td class="right linecolpriceuttc">'.$langs->trans(
'PriceUTTC').
'</td>';
2078 print
'<td class="right linecolqty">'.$langs->trans(
'Qty').
'</td>';
2079 if ($action !=
'editline') {
2080 print
'<td class="right linecolamountht">'.$langs->trans(
'AmountHT').
'</td>';
2081 print
'<td class="right linecolamountttc">'.$langs->trans(
'AmountTTC').
'</td>';
2092 if (($object->status < 2 || $object->status == 99) && $user->rights->expensereport->creer) {
2093 print
'<td class="right"></td>';
2097 foreach ($object->lines as &$line) {
2100 if ($action !=
'editline' || $line->rowid !=
GETPOST(
'rowid',
'int')) {
2101 print
'<tr class="oddeven linetr" data-id="'.$line->id.
'">';
2104 print
'<td class="center linecollinenb">';
2109 print
'<td class="center linecoldate">'.dol_print_date($db->jdate($line->date),
'day').
'</td>';
2112 if (!empty($conf->project->enabled)) {
2113 print
'<td class="center dateproject">';
2114 if ($line->fk_project > 0) {
2115 $projecttmp->id = $line->fk_project;
2116 $projecttmp->ref = $line->projet_ref;
2117 $projecttmp->title = $line->projet_title;
2118 print $projecttmp->getNomUrl(1);
2124 if (!empty($conf->accounting->enabled)) {
2125 require_once DOL_DOCUMENT_ROOT.
'/accountancy/class/accountingaccount.class.php';
2127 $resaccountingaccount = $accountingaccount->fetch(0, $line->type_fees_accountancy_code, 1);
2129 $titlealt .= $langs->trans(
"AccountancyCode").
': ';
2130 if ($resaccountingaccount > 0) {
2131 $titlealt .= $accountingaccount->account_number;
2133 $titlealt .= $langs->trans(
"NotFound");
2139 print
'<td class="center linecoltype" title="'.dol_escape_htmltag($titlealt).
'">';
2140 $labeltype = ($langs->trans(($line->type_fees_code)) == $line->type_fees_code ? $line->type_fees_libelle : $langs->trans($line->type_fees_code));
2145 if (!empty($conf->global->MAIN_USE_EXPENSE_IK)) {
2146 print
'<td class="fk_c_exp_tax_cat linecoltaxcat">';
2147 $exp_tax_cat_label =
dol_getIdFromCode($db, $line->fk_c_exp_tax_cat,
'c_exp_tax_cat',
'rowid',
'label');
2148 print $langs->trans($exp_tax_cat_label);
2153 print
'<td class="left linecolcomment">'.dol_nl2br($line->comments).
'</td>';
2156 print
'<td class="right linecolvatrate">'.vatrate($line->vatrate.($line->vat_src_code ?
' ('.$line->vat_src_code.
')' :
''),
true).
'</td>';
2159 print
'<td class="right linecolunitht">';
2160 if (!empty($line->value_unit_ht)) {
2161 print
price($line->value_unit_ht);
2163 $tmpvat =
price2num(preg_replace(
'/\s*\(.*\)/',
'', $line->vatrate));
2164 $pricenettoshow =
price2num($line->value_unit / (1 + $tmpvat / 100),
'MU');
2165 print
price($pricenettoshow);
2169 print
'<td class="right linecolunitttc">'.price($line->value_unit).
'</td>';
2171 print
'<td class="right linecolqty">'.dol_escape_htmltag($line->qty).
'</td>';
2173 if ($action !=
'editline') {
2174 print
'<td class="right linecoltotalht">'.price($line->total_ht).
'</td>';
2175 print
'<td class="right linecoltotalttc">'.price($line->total_ttc).
'</td>';
2179 print
'<td class="center linecolpreview">';
2180 if ($line->fk_ecm_files > 0) {
2181 $modulepart =
'expensereport';
2182 $maxheightmini = 32;
2184 $result = $ecmfilesstatic->fetch($line->fk_ecm_files);
2186 $relativepath = preg_replace(
'/expensereport\//',
'', $ecmfilesstatic->filepath);
2187 $fileinfo = pathinfo($ecmfilesstatic->filepath.
'/'.$ecmfilesstatic->filename);
2190 if (!
dol_is_file($conf->expensereport->dir_output.
'/'.$relativepath.
'/'.$minifile)) {
2194 $urlforhref =
getAdvancedPreviewUrl($modulepart, $relativepath.
'/'.$fileinfo[
'filename'].
'.'.strtolower($fileinfo[
'extension']), 1,
'&entity='.(!empty($object->entity) ? $object->entity : $conf->entity));
2195 if (empty($urlforhref)) {
2196 $urlforhref = DOL_URL_ROOT.
'/viewimage.php?modulepart='.$modulepart.
'&entity='.(!empty($object->entity) ? $object->entity : $conf->entity).
'&file='.urlencode($relativepath.$fileinfo[
'filename'].
'.'.strtolower($fileinfo[
'extension']));
2197 print
'<a href="'.$urlforhref.
'" class="aphoto" target="_blank" rel="noopener noreferrer">';
2199 print
'<a href="'.$urlforhref[
'url'].
'" class="'.$urlforhref[
'css'].
'" target="'.$urlforhref[
'target'].
'" mime="'.$urlforhref[
'mime'].
'">';
2201 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="">';
2204 $modulepart =
'expensereport';
2206 if (preg_match(
'/\.pdf$/i', $ecmfilesstatic->filename)) {
2207 $filepdf = $conf->expensereport->dir_output.
'/'.$relativepath.
'/'.$ecmfilesstatic->filename;
2208 $fileimage = $conf->expensereport->dir_output.
'/'.$relativepath.
'/'.$ecmfilesstatic->filename.
'_preview.png';
2209 $relativepathimage = $relativepath.
'/'.$ecmfilesstatic->filename.
'_preview.png';
2211 $pdfexists = file_exists($filepdf);
2214 if (!file_exists($fileimage) || (filemtime($fileimage) < filemtime($filepdf))) {
2215 if (empty($conf->global->MAIN_DISABLE_PDF_THUMBS)) {
2216 include_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
2225 if ($pdfexists && !$error) {
2226 $heightforphotref = 70;
2227 if (!empty($conf->dol_optimize_smallscreen)) {
2228 $heightforphotref = 60;
2231 if (file_exists($fileimage)) {
2233 $urlforhref =
getAdvancedPreviewUrl($modulepart, $relativepath.
'/'.$fileinfo[
'filename'].
'.'.strtolower($fileinfo[
'extension']), 1,
'&entity='.(!empty($object->entity) ? $object->entity : $conf->entity));
2234 print
'<a href="'.$urlforhref[
'url'].
'" class="'.$urlforhref[
'css'].
'" target="'.$urlforhref[
'target'].
'" mime="'.$urlforhref[
'mime'].
'">';
2235 print
'<img height="'.$heightforphotref.
'" class="photo photowithmargin photowithborder" src="'.DOL_URL_ROOT.
'/viewimage.php?modulepart=apercu'.$modulepart.
'&file='.urlencode($relativepathimage).
'">';
2242 print
img_mime($ecmfilesstatic->filename);
2249 print
'<td class="nowrap right linecolwarning">';
2250 print !empty($line->rule_warning_message) ?
img_warning(html_entity_decode($line->rule_warning_message)) :
' ';
2255 print
'<td class="nowrap right linecolaction">';
2257 print
'<a class="editfielda reposition paddingrightonly" href="'.$_SERVER[
"PHP_SELF"].
'?id='.$object->id.
'&action=editline&token='.
newToken().
'&rowid='.$line->rowid.
'">';
2259 print
'</a> ';
2260 print
'<a class="paddingrightonly" href="'.$_SERVER[
"PHP_SELF"].
'?id='.$object->id.
'&action=delete_line&token='.
newToken().
'&rowid='.$line->rowid.
'">';
2270 if ($action ==
'editline' && $line->rowid ==
GETPOST(
'rowid',
'int')) {
2273 if (!empty($conf->project->enabled)) {
2276 if (!empty($conf->global->MAIN_USE_EXPENSE_IK)) {
2280 print
'<!-- line of expense report -->'.
"\n";
2281 print
'<tr class="tredited">';
2283 print
'<td class="center">';
2287 print
'<td colspan="'.($colspan - 1).
'" class="liste_titre"> ';
2288 print
'<a href="" class="commonlink auploadnewfilenow reposition">'.$langs->trans(
"UploadANewFileNow");
2289 print
img_picto($langs->trans(
"UploadANewFileNow"),
'chevron-down',
'',
false, 0, 0,
'',
'marginleftonly');
2291 if (empty($conf->global->EXPENSEREPORT_DISABLE_ATTACHMENT_ON_LINES)) {
2292 print
' - <a href="" class="commonlink aattachtodoc reposition">'.$langs->trans(
"AttachTheNewLineToTheDocument");
2293 print
img_picto($langs->trans(
"AttachTheNewLineToTheDocument"),
'chevron-down',
'',
false, 0, 0,
'',
'marginleftonly');
2297 print
'<!-- Code to open/close section to submit or link files in edit mode -->'.
"\n";
2298 print
'<script type="text/javascript">'.
"\n";
2299 print
'$(document).ready(function() {
2300 $( ".auploadnewfilenow" ).click(function() {
2301 jQuery(".truploadnewfilenow").toggle();
2302 jQuery(".trattachnewfilenow").hide();
2305 $( ".aattachtodoc" ).click(function() {
2306 jQuery(".trattachnewfilenow").toggle();
2307 jQuery(".truploadnewfilenow").hide();
2310 if (is_array(
GETPOST(
'attachfile',
'array')) && count(
GETPOST(
'attachfile',
'array'))) {
2311 print
'jQuery(".trattachnewfilenow").toggle();'.
"\n";
2314 jQuery("form[name=\"expensereport\"]").submit(function() {
2315 if (jQuery(".truploadnewfilenow").is(":hidden")) {
2316 jQuery("input[name=\"sendit\"]").val("");
2323 print
'</script>'.
"\n";
2326 $filenamelinked =
'';
2327 if ($line->fk_ecm_files > 0) {
2328 $result = $ecmfilesstatic->fetch($line->fk_ecm_files);
2330 $filenamelinked = $ecmfilesstatic->filename;
2334 $tredited =
'tredited';
2335 include DOL_DOCUMENT_ROOT.
'/expensereport/tpl/expensereport_addfile.tpl.php';
2336 include DOL_DOCUMENT_ROOT.
'/expensereport/tpl/expensereport_linktofile.tpl.php';
2338 print
'<tr class="oddeven tredited">';
2343 print
'<td class="center">';
2344 print
$form->selectDate($line->date,
'date');
2348 if (!empty($conf->project->enabled)) {
2350 $formproject->select_projects(-1, $line->fk_project,
'fk_project', 0, 0, $projectRequired ? 0 : 1, 1, 0, 0, 0,
'', 0, 0,
'maxwidth300');
2355 print
'<td class="center">';
2356 print $formexpensereport->selectTypeExpenseReport($line->fk_c_type_fees,
'fk_c_type_fees');
2359 if (!empty($conf->global->MAIN_USE_EXPENSE_IK)) {
2360 print
'<td class="fk_c_exp_tax_cat">';
2361 $params = array(
'fk_expense' => $object->id,
'fk_expense_det' => $line->rowid,
'date' => $line->dates);
2362 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);
2368 print
'<textarea name="comments" class="flat_ndf centpercent">'.dol_escape_htmltag($line->comments, 0, 1).
'</textarea>';
2372 $selectedvat =
price2num($line->vatrate).($line->vat_src_code ?
' ('.$line->vat_src_code.
')' :
'');
2373 print
'<td class="right">';
2374 print
$form->load_tva(
'vatrate', (
GETPOSTISSET(
"vatrate") ?
GETPOST(
"vatrate") : $selectedvat), $mysoc,
'', 0, 0,
'',
false, 1);
2378 print
'<td class="right">';
2379 print
'<input type="text" min="0" class="right maxwidth50" id="value_unit_ht" name="value_unit_ht" value="'.dol_escape_htmltag(
price2num($line->value_unit_ht)).
'"'.$taxlessUnitPriceDisabled.
' />';
2383 print
'<td class="right">';
2384 print
'<input type="text" min="0" class="right maxwidth50" id="value_unit" name="value_unit" value="'.dol_escape_htmltag(
price2num($line->value_unit)).
'" />';
2388 print
'<td class="right">';
2389 print
'<input type="text" min="0" class="input_qty right maxwidth50" name="qty" value="'.dol_escape_htmltag($line->qty).
'" />';
2396 print
'<td class="center">';
2400 print
'<td class="center">';
2404 print
'<input type="hidden" name="rowid" value="'.$line->rowid.
'">';
2405 print
$form->buttonsSaveCancel(
'Save',
'Cancel', array(), 0,
'small');
2418 if (!empty($conf->global->MAIN_USE_EXPENSE_IK)) {
2421 if (!empty($conf->project->enabled)) {
2424 if ($action !=
'editline') {
2428 $nbFiles = $nbLinks = 0;
2429 $arrayoffiles = array();
2430 if (empty($conf->global->EXPENSEREPORT_DISABLE_ATTACHMENT_ON_LINES)) {
2431 require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
2432 require_once DOL_DOCUMENT_ROOT.
'/core/lib/images.lib.php';
2433 require_once DOL_DOCUMENT_ROOT.
'/core/class/link.class.php';
2436 $nbFiles = count($arrayoffiles);
2437 $nbLinks =
Link::count($db, $object->element, $object->id);
2441 print
'<tr class="liste_titre">';
2442 print
'<td colspan="'.$colspan.
'" class="liste_titre expensereportautoload">';
2443 print
'<a href="" class="commonlink auploadnewfilenow reposition">'.$langs->trans(
"UploadANewFileNow");
2444 print
img_picto($langs->trans(
"UploadANewFileNow"),
'chevron-down',
'',
false, 0, 0,
'',
'marginleftonly');
2446 if (empty($conf->global->EXPENSEREPORT_DISABLE_ATTACHMENT_ON_LINES)) {
2447 print
' - <a href="" class="commonlink aattachtodoc reposition">'.$langs->trans(
"AttachTheNewLineToTheDocument");
2448 print
img_picto($langs->trans(
"AttachTheNewLineToTheDocument"),
'chevron-down',
'',
false, 0, 0,
'',
'marginleftonly');
2452 print
'<!-- Code to open/close section to submit or link files in the form to add new line -->'.
"\n";
2453 print
'<script type="text/javascript">'.
"\n";
2454 print
'$(document).ready(function() {
2455 $( ".auploadnewfilenow" ).click(function() {
2456 console.log("We click on toggle of auploadnewfilenow");
2457 jQuery(".truploadnewfilenow").toggle();
2458 jQuery(".trattachnewfilenow").hide();
2459 if (jQuery(".truploadnewfilenow").is(":hidden")) {
2460 jQuery("input[name=\"sendit\"]").prop("name", "senditdisabled");
2462 jQuery("input[name=\"senditdisabled\"]").prop("name", "sendit");
2466 $( ".aattachtodoc" ).click(function() {
2467 console.log("We click on toggle of aattachtodoc");
2468 jQuery(".trattachnewfilenow").toggle();
2469 jQuery(".truploadnewfilenow").hide();
2472 if (is_array(
GETPOST(
'attachfile',
'array')) && count(
GETPOST(
'attachfile',
'array')) && $action !=
'updateline') {
2473 print
'jQuery(".trattachnewfilenow").show();'.
"\n";
2476 jQuery("form[name=\"expensereport\"]").submit(function() {
2477 if (jQuery(".truploadnewfilenow").is(":hidden")) {
2478 /* 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. */
2479 jQuery("input[name=\"sendit\"]").val("");
2480 jQuery("input[name=\"sendit\"]").prop("name", "senditdisabled");
2482 jQuery("input[name=\"senditdisabled\"]").prop("name", "sendit");
2489 print
'</script>'.
"\n";
2492 include DOL_DOCUMENT_ROOT.
'/expensereport/tpl/expensereport_linktofile.tpl.php';
2493 include DOL_DOCUMENT_ROOT.
'/expensereport/tpl/expensereport_addfile.tpl.php';
2495 print
'<tr class="liste_titre expensereportcreate">';
2497 print
'<td class="center expensereportcreatedate">'.$langs->trans(
'Date').
'</td>';
2498 if (!empty($conf->project->enabled)) {
2499 print
'<td class="minwidth100imp">'.$form->textwithpicto($langs->trans(
'Project'), $langs->trans(
"ClosedProjectsAreHidden")).
'</td>';
2501 print
'<td class="center expensereportcreatetype">'.$langs->trans(
'Type').
'</td>';
2502 if (!empty($conf->global->MAIN_USE_EXPENSE_IK)) {
2503 print
'<td>'.$langs->trans(
'CarCategory').
'</td>';
2505 print
'<td class="right expensereportcreatedescription">'.$langs->trans(
'Description').
'</td>';
2506 print
'<td class="right expensereportcreatevat">'.$langs->trans(
'VAT').
'</td>';
2507 print
'<td class="right expensereportcreatepriceuth">'.$langs->trans(
'PriceUHT').
'</td>';
2508 print
'<td class="right expensereportcreatepricettc">'.$langs->trans(
'PriceUTTC').
'</td>';
2509 print
'<td class="right expensereportcreateqty">'.$langs->trans(
'Qty').
'</td>';
2516 print
'<tr class="oddeven nohover">';
2522 print
'<td class="center inputdate">';
2523 print
$form->selectDate($date ? $date : -1,
'date', 0, 0, 0,
'', 1, 1);
2527 if (!empty($conf->project->enabled)) {
2528 print
'<td class="inputproject">';
2529 $formproject->select_projects(-1, $fk_project,
'fk_project', 0, 0, $projectRequired ? 0 : 1, -1, 0, 0, 0,
'', 0, 0,
'maxwidth300');
2534 print
'<td class="center inputtype">';
2535 print $formexpensereport->selectTypeExpenseReport($fk_c_type_fees,
'fk_c_type_fees', 1);
2538 if (!empty($conf->global->MAIN_USE_EXPENSE_IK)) {
2539 print
'<td class="fk_c_exp_tax_cat">';
2540 $params = array(
'fk_expense' => $object->id);
2541 print
$form->selectExpenseCategories(
'',
'fk_c_exp_tax_cat', 1, array(),
'fk_c_type_fees', $userauthor->default_c_exp_tax_cat, $params, 0);
2546 print
'<td class="inputcomment">';
2547 print
'<textarea class="flat_ndf centpercent" name="comments" rows="'.ROWS_2.
'">'.
dol_escape_htmltag($comments, 0, 1).
'</textarea>';
2551 print
'<td class="right inputvat">';
2553 if (!empty($conf->global->EXPENSEREPORT_NO_DEFAULT_VAT)) {
2554 $conf->global->MAIN_VAT_DEFAULT_IF_AUTODETECT_FAILS =
'none';
2556 print
$form->load_tva(
'vatrate', ($vatrate !=
'' ? $vatrate : $defaultvat), $mysoc,
'', 0, 0,
'',
false, 1);
2560 print
'<td class="right inputpricenet">';
2561 print
'<input type="text" class="right maxwidth50" id="value_unit_ht" name="value_unit_ht" value="'.dol_escape_htmltag($value_unit_ht).
'"'.$taxlessUnitPriceDisabled.
' />';
2565 print
'<td class="right inputtax">';
2566 print
'<input type="text" class="right maxwidth50" id="value_unit" name="value_unit" value="'.dol_escape_htmltag($value_unit).
'">';
2570 print
'<td class="right inputqty">';
2571 print
'<input type="text" min="0" class=" input_qty right maxwidth50" name="qty" value="'.dol_escape_htmltag($qty ? $qty : 1).
'">';
2577 if ($action !=
'editline') {
2578 print
'<td class="right"></td>';
2579 print
'<td class="right"></td>';
2582 print
'<td class="center inputbuttons">';
2583 print
$form->buttonsSaveCancel(
"Add",
'',
'', 1);
2592 print
'<script javascript>
2594 /* JQuery for product free or predefined select */
2595 jQuery(document).ready(function() {
2596 jQuery("#value_unit_ht").keyup(function(event) {
2597 console.log(event.which); // discard event tag and arrows
2598 if (event.which != 9 && (event.which < 37 ||event.which > 40) && jQuery("#value_unit_ht").val() != "") {
2599 jQuery("#value_unit").val("");
2602 jQuery("#value_unit").keyup(function(event) {
2603 console.log(event.which); // discard event tag and arrows
2604 if (event.which != 9 && (event.which < 37 || event.which > 40) && jQuery("#value_unit").val() != "") {
2605 jQuery("#value_unit_ht").val("");
2609 /* unit price coéf calculation */
2610 jQuery(".input_qty, #fk_c_type_fees, #select_fk_c_exp_tax_cat, #vatrate ").change(function(event) {
2612 let type_fee = jQuery("#fk_c_type_fees").find(":selected").val();
2613 let tax_cat = jQuery("#select_fk_c_exp_tax_cat").find(":selected").val();
2614 let tva = jQuery("#vatrate").find(":selected").val();
2615 let qty = jQuery(".input_qty").val();
2619 let path = "'.dol_buildpath(
"/expensereport/ajax/ajaxik.php", 1) .
'";
2620 path += "?fk_c_exp_tax_cat="+tax_cat;
2621 path +="&fk_expense="+'.$object->id.
';
2622 path += "&vatrate="+tva;
2623 path += "&qty="+qty;
2625 if (type_fee == 4) { // frais_kilométriques
2627 if (tax_cat == "" || parseInt(tax_cat) <= 0){
2635 ,success:function(response) {
2636 if (response.response_status == "success"){
2637 jQuery("#value_unit_ht").val(response.data);
2638 jQuery("#value_unit_ht").trigger("change");
2639 jQuery("#value_unit").val("");
2640 } else if(response.response_status == "error" && response.errorMessage != undefined && response.errorMessage.length > 0 ){
2641 $.jnotify(response.errorMessage, "error", {timeout: 0, type: "error"},{ remove: function (){} } );
2648 /*console.log(event.which); // discard event tag and arrows
2649 if (event.which != 9 && (event.which < 37 || event.which > 40) && jQuery("#value_unit").val() != "") {
2650 jQuery("#value_unit_ht").val("");
2666 print
'Record not found';
2677 print
'<div class="tabsAction">';
2679 if ($action !=
'create' && $action !=
'edit' && $action !=
'editline') {
2681 $object->fetch($id, $ref);
2684 if (empty($user->socid)) {
2687 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>';
2699 if (in_array($object->fk_user_author, $user->getAllChildIds(1)) || !empty($user->rights->expensereport->writeall_advance)) {
2701 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>';
2704 if (count($object->lines) > 0) {
2705 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>';
2716 if ($user->id == $object->fk_user_author || $user->id == $object->fk_user_valid) {
2718 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>';
2723 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>';
2728 if ($user->id == $object->fk_user_author || $user->id == $object->fk_user_valid) {
2730 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>';
2740 if (in_array($object->fk_user_author, $user->getAllChildIds(1))) {
2742 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>';
2750 print
'<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER[
"PHP_SELF"].
'?action=validate&id='.$object->id.
'">'.$langs->trans(
'Approve').
'</a></div>';
2752 print
'<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER[
"PHP_SELF"].
'?action=refuse&id='.$object->id.
'">'.$langs->trans(
'Deny').
'</a></div>';
2755 if ($user->id == $object->fk_user_author || $user->id == $object->fk_user_valid) {
2757 print
'<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER[
"PHP_SELF"].
'?action=cancel&id='.$object->id.
'">'.$langs->trans(
"Cancel").
'</a></div>';
2766 print
'<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER[
"PHP_SELF"].
'?action=refuse&id='.$object->id.
'">'.$langs->trans(
'Deny').
'</a></div>';
2772 if ($remaintopay == 0) {
2773 print
'<div class="inline-block divButAction"><span class="butActionRefused classfortooltip" title="'.$langs->trans(
"DisabledBecauseRemainderToPayIsZero").
'">'.$langs->trans(
'DoPayment').
'</span></div>';
2775 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>';
2782 if ($object->paid == 0) {
2783 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>";
2787 if ($user->rights->expensereport->creer && ($user->id == $object->fk_user_author || $user->id == $object->fk_user_valid) && $object->status ==
ExpenseReport::STATUS_APPROVED) {
2789 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>';
2793 if (($user->rights->expensereport->approve || $user->rights->expensereport->to_paid) && $object->status ==
ExpenseReport::STATUS_CLOSED) {
2795 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>';
2800 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>';
2804 if ($user->rights->expensereport->creer) {
2805 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>';
2811 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>';
2814 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>';
2817 $parameters = array();
2818 $reshook = $hookmanager->executeHooks(
'addMoreActionsButtons', $parameters, $object, $action);
2825 if (
GETPOST(
'modelselected',
'alpha')) {
2826 $action =
'presend';
2829 if ($action !=
'presend') {
2834 print
'<div class="fichecenter"><div class="fichehalfleft">';
2835 print
'<a name="builddoc"></a>';
2837 if ($user->rights->expensereport->creer && $action !=
'create' && $action !=
'edit') {
2840 $urlsource = $_SERVER[
"PHP_SELF"].
"?id=".$object->id;
2841 $genallowed = $user->rights->expensereport->creer;
2842 $delallowed = $user->rights->expensereport->creer;
2844 print $formfile->showdocuments(
'expensereport', $filename, $filedir, $urlsource, $genallowed, $delallowed);
2845 $somethingshown = $formfile->numoffiles;
2857 print
'</div><div class="fichehalfright">';
2859 include_once DOL_DOCUMENT_ROOT.
'/core/class/html.formactions.class.php';
2861 $somethingshown =
$formactions->showactions($object,
'expensereport', null);
2863 print
'</div></div>';
2867 $modelmail =
'expensereport';
2868 $defaulttopic =
'SendExpenseReportRef';
2869 $diroutput = $conf->expensereport->dir_output;
2870 $trackid =
'exp'.$object->id;
2872 include DOL_DOCUMENT_ROOT.
'/core/tpl/card_presend.tpl.php';
dol_convert_file($fileinput, $ext= 'png', $fileoutput= '', $page= '')
Convert an image file or a PDF into another image format.
GETPOST($paramname, $check= 'alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
img_edit($titlealt= 'default', $float=0, $other= '')
Show logo editer/modifier fiche.
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.
const STATUS_APPROVED
Classified approved.
const STATUS_VALIDATED
Validated (need to be paid)
if($cancel &&!$id) if($action== 'add'&&!$cancel) if($action== 'delete') if($id) $form
Actions.
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...
Class of expense report details lines.
dol_now($mode= 'auto')
Return date for now.
get_date_range($date_start, $date_end, $format= '', $outputlangs= '', $withparenthesis=1)
Format output for start and end date.
Class to manage Dolibarr users.
if(!defined('NOREQUIRESOC')) if(!defined('NOREQUIRETRAN')) if(!defined('NOCSRFCHECK')) if(!defined('NOTOKENRENEWAL')) if(!defined('NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined('NOREQUIREAJAX')) llxHeader()
Empty header.
const STATUS_CLOSED
Classified paid.
dol_clone($object, $native=0)
Create a clone of instance of object (new instance with same value for properties) With native = 0: P...
const STATUS_CANCELED
Classified canceled.
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $noescapetags= '', $escapeonlyhtmltags=0)
Returns text escaped for inclusion in HTML alt or title tags, or into values of HTML input fields...
dol_getIdFromCode($db, $key, $tablename, $fieldkey= 'code', $fieldid= 'id', $entityfilter=0, $filters= '')
Return an id or code from a code or id.
if(GETPOST('button_removefilter_x', 'alpha')||GETPOST('button_removefilter.x', 'alpha')||GETPOST('button_removefilter', 'alpha')) if(GETPOST('button_search_x', 'alpha')||GETPOST('button_search.x', 'alpha')||GETPOST('button_search', 'alpha')) if($action=="save"&&empty($cancel)) $help_url
View.
img_mime($file, $titlealt= '', $morecss= '')
Show MIME img of a file.
const STATUS_REFUSED
Classified refused.
Class to manage bank accounts.
image_format_supported($file, $acceptsvg=0)
Return if a filename is file name of a supported image format.
img_warning($titlealt= 'default', $moreatt= '', $morecss= 'pictowarning')
Show warning logo.
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...
isValidEmail($address, $acceptsupervisorkey=0, $acceptuserkey=0)
Return true if email syntax is ok.
getImageFileNameForSize($file, $extName, $extImgTarget= '')
Return the filename of file to get the thumbs.
setEventMessages($mesg, $mesgs, $style= 'mesgs', $messagekey= '')
Set event messages in dol_events session object.
GETPOSTISSET($paramname)
Return true if we are in a context of submitting the parameter $paramname from a POST of a form...
Class to manage projects.
load_fiche_titre($titre, $morehtmlright= '', $picto= 'generic', $pictoisfullpath=0, $id= '', $morecssontable= '', $morehtmlcenter= '')
Load a title with picto.
price2num($amount, $rounding= '', $option=0)
Function that return a number with universal decimal format (decimal separator is '...
Class to send emails (with attachments or not) Usage: $mailfile = new CMailFile($subject,$sendto,$replyto,$message,$filepath,$mimetype,$filename,$cc,$ccc,$deliveryreceipt,$msgishtml,$errors_to,$css,$trackid,$moreinheader,$sendcontext,$replyto); $mailfile->sendfile();.
img_picto($titlealt, $picto, $moreatt= '', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt= '', $morecss= '', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
expensereport_prepare_head($object)
Prepare array with list of tabs.
accessforbidden($message= '', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program Calling this function terminate execution ...
Class to manage translations.
static count($dbs, $objecttype, $objectid)
Return nb of links.
dol_sanitizeFileName($str, $newstr= '_', $unaccent=1)
Clean a string to use it as a file name.
dol_dir_list($path, $types="all", $recursive=0, $filter="", $excludefilter=null, $sortcriteria="name", $sortorder=SORT_ASC, $mode=0, $nohook=0, $relativename="", $donotfollowsymlinks=0)
Scan a directory and return a list of files/directories.
Class to manage Trips and Expenses.
dol_is_file($pathoffile)
Return if path is a file.
restrictedArea($user, $features, $objectid=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.
if(isModEnabled('facture')&&!empty($user->rights->facture->lire)) if((isModEnabled('fournisseur')&&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)&&$user->rights->fournisseur->facture->lire)||(isModEnabled('supplier_invoice')&&$user->rights->supplier_invoice->lire)) if(isModEnabled('don')&&!empty($user->rights->don->lire)) if(isModEnabled('tax')&&!empty($user->rights->tax->charges->lire)) if(isModEnabled('facture')&&isModEnabled('commande')&&$user->rights->commande->lire &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) $resql
Social contributions to pay.
dol_get_fiche_head($links=array(), $active= '', $title= '', $notab=0, $picto= '', $pictoisfullpath=0, $morehtmlright= '', $morecss= '', $limittoshow=0, $moretabssuffix= '')
Show tabs of a record.
dol_print_date($time, $format= '', $tzoutput= 'auto', $outputlangs= '', $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
Class to manage payments of expense report.
dol_print_error($db= '', $error= '', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
newToken()
Return the value of token currently saved into session with name 'newtoken'.
dol_get_fiche_end($notab=0)
Return tab footer of a card.
Class to manage a WYSIWYG editor.
Class to manage accounting accounts.
Class to manage accounting accounts.
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.
img_delete($titlealt= 'default', $other= 'class="pictodelete"', $morecss= '')
Show delete logo.
Class to manage ECM files.
const STATUS_DRAFT
Draft status.
getAdvancedPreviewUrl($modulepart, $relativepath, $alldata=0, $param= '')
Return URL we can use for advanced preview links.
$formconfirm
if ($action == 'delbookkeepingyear') {
fetch($id, $ref= '', $relativepath= '', $hashoffile= '', $hashforshare= '', $src_object_type= '', $src_object_id=0)
Load object in memory from the database.