30 require
'../main.inc.php';
31 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formexpensereport.class.php';
32 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formfile.class.php';
33 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formmail.class.php';
34 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formprojet.class.php';
35 require_once DOL_DOCUMENT_ROOT.
'/core/class/CMailFile.class.php';
36 require_once DOL_DOCUMENT_ROOT.
'/projet/class/project.class.php';
37 require_once DOL_DOCUMENT_ROOT.
'/ecm/class/ecmfiles.class.php';
38 require_once DOL_DOCUMENT_ROOT.
'/compta/bank/class/account.class.php';
39 require_once DOL_DOCUMENT_ROOT.
'/core/lib/expensereport.lib.php';
40 require_once DOL_DOCUMENT_ROOT.
'/core/lib/price.lib.php';
41 require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
42 require_once DOL_DOCUMENT_ROOT.
'/core/lib/images.lib.php';
43 require_once DOL_DOCUMENT_ROOT.
'/core/modules/expensereport/modules_expensereport.php';
44 require_once DOL_DOCUMENT_ROOT.
'/expensereport/class/expensereport.class.php';
45 require_once DOL_DOCUMENT_ROOT.
'/expensereport/class/paymentexpensereport.class.php';
46 require_once DOL_DOCUMENT_ROOT.
'/core/class/doleditor.class.php';
47 require_once DOL_DOCUMENT_ROOT.
'/core/class/extrafields.class.php';
49 require_once DOL_DOCUMENT_ROOT.
'/accountancy/class/accountingjournal.class.php';
53 $langs->loadLangs(array(
"trips",
"bills",
"mails"));
55 $action =
GETPOST(
'action',
'aZ09');
56 $cancel =
GETPOST(
'cancel',
'alpha');
57 $confirm =
GETPOST(
'confirm',
'alpha');
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);
73 if (!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;
88 if (
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);
111 include 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);
125 if ($object->id > 0) {
128 if (!empty($user->rights->expensereport->readall)) {
131 if (!empty($user->rights->expensereport->lire) && in_array($object->fk_user_author, $childids)) {
140 if (!empty($user->rights->expensereport->supprimer)) {
143 if ($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;
164 $reshook = $hookmanager->executeHooks(
'doActions',
$parameters, $object, $action);
169 if (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' && $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 ($mailfile->error) {
465 $mesg .= $langs->trans(
'ErrorFailedToSendMail', $emailFrom, $emailTo);
466 $mesg .=
'<br>'.$mailfile->error;
469 setEventMessages(
'No mail sent. Feature is disabled by option MAIN_DISABLE_ALL_MAILS',
null,
'warnings');
477 setEventMessages($langs->trans(
"NoEmailSentBadSenderOrRecipientEmail"),
null,
'warnings');
484 header(
"Location: ".$_SERVER[
"PHP_SELF"].
"?id=".$id);
491 if ($action ==
"confirm_save_from_refuse" &&
GETPOST(
"confirm",
'alpha') ==
"yes" && $id > 0 && $user->rights->expensereport->creer) {
494 $result = $object->set_save_from_refuse($user);
498 if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) {
499 $outputlangs = $langs;
502 $newlang =
GETPOST(
'lang_id',
'aZ09');
505 $newlang = $object->thirdparty->default_lang;
507 if (!empty($newlang)) {
509 $outputlangs->setDefaultLang($newlang);
511 $model = $object->model_pdf;
512 $ret = $object->fetch($id);
514 $object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref);
522 $destinataire =
new User($db);
523 $destinataire->fetch($object->fk_user_validator);
524 $emailTo = $destinataire->email;
527 $expediteur =
new User($db);
528 $expediteur->fetch($object->fk_user_author);
529 $emailFrom = $conf->global->MAIN_MAIL_EMAIL_FROM;
531 if ($emailFrom && $emailTo) {
532 $filename = array(); $filedir = array(); $mimetype = array();
535 $societeName = $conf->global->MAIN_INFO_SOCIETE_NOM;
536 if (!empty($conf->global->MAIN_APPLICATION_TITLE)) {
537 $societeName = $conf->global->MAIN_APPLICATION_TITLE;
540 $subject = $societeName.
" - ".$langs->transnoentities(
"ExpenseReportWaitingForReApproval");
543 $link = $urlwithroot.
'/expensereport/card.php?id='.$object->id;
544 $link =
'<a href="'.$link.
'">'.$link.
'</a>';
545 $dateRefusEx = explode(
" ", $object->date_refuse);
546 $message = $langs->transnoentities(
"ExpenseReportWaitingForReApprovalMessage", $dateRefusEx[0], $object->detail_refuse, $expediteur->getFullName($langs), $link);
565 $mailfile =
new CMailFile($subject, $emailTo, $emailFrom, $message, $filedir, $mimetype, $filename,
'',
'', 0, -1);
569 $result = $mailfile->sendfile();
571 $mesg = $langs->trans(
'MailSuccessfulySent', $mailfile->getValidAddress($emailFrom, 2), $mailfile->getValidAddress($emailTo, 2));
573 header(
"Location: ".$_SERVER[
"PHP_SELF"].
"?id=".$id);
576 $langs->load(
"other");
577 if ($mailfile->error) {
579 $mesg .= $langs->trans(
'ErrorFailedToSendMail', $emailFrom, $emailTo);
580 $mesg .=
'<br>'.$mailfile->error;
583 setEventMessages(
'No mail sent. Feature is disabled by option MAIN_DISABLE_ALL_MAILS',
null,
'warnings');
591 setEventMessages($langs->trans(
"NoEmailSentBadSenderOrRecipientEmail"),
null,
'warnings');
600 if ($action ==
"confirm_approve" &&
GETPOST(
"confirm",
'alpha') ==
"yes" && $id > 0 && $user->rights->expensereport->approve) {
604 $result = $object->setApproved($user);
608 if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) {
609 $outputlangs = $langs;
612 $newlang =
GETPOST(
'lang_id',
'aZ09');
615 $newlang = $object->thirdparty->default_lang;
617 if (!empty($newlang)) {
619 $outputlangs->setDefaultLang($newlang);
621 $model = $object->model_pdf;
622 $ret = $object->fetch($id);
624 $object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref);
632 $destinataire =
new User($db);
633 $destinataire->fetch($object->fk_user_author);
634 $emailTo = $destinataire->email;
637 $emailCC = $conf->global->NDF_CC_EMAILS;
638 if (empty($emailTo)) {
643 $expediteur =
new User($db);
644 $expediteur->fetch($object->fk_user_approve > 0 ? $object->fk_user_approve : $object->fk_user_validator);
645 $emailFrom = $conf->global->MAIN_MAIL_EMAIL_FROM;
647 if ($emailFrom && $emailTo) {
648 $filename = array(); $filedir = array(); $mimetype = array();
651 $societeName = $conf->global->MAIN_INFO_SOCIETE_NOM;
652 if (!empty($conf->global->MAIN_APPLICATION_TITLE)) {
653 $societeName = $conf->global->MAIN_APPLICATION_TITLE;
656 $subject = $societeName.
" - ".$langs->transnoentities(
"ExpenseReportApproved");
659 $link = $urlwithroot.
'/expensereport/card.php?id='.$object->id;
660 $link =
'<a href="'.$link.
'">'.$link.
'</a>';
661 $message = $langs->transnoentities(
"ExpenseReportApprovedMessage", $object->ref, $destinataire->getFullName($langs), $expediteur->getFullName($langs), $link);
678 $mailfile =
new CMailFile($subject, $emailTo, $emailFrom, $message, $filedir, $mimetype, $filename,
'',
'', 0, -1);
682 $result = $mailfile->sendfile();
684 $mesg = $langs->trans(
'MailSuccessfulySent', $mailfile->getValidAddress($emailFrom, 2), $mailfile->getValidAddress($emailTo, 2));
686 header(
"Location: ".$_SERVER[
"PHP_SELF"].
"?id=".$id);
689 $langs->load(
"other");
690 if ($mailfile->error) {
692 $mesg .= $langs->trans(
'ErrorFailedToSendMail', $emailFrom, $emailTo);
693 $mesg .=
'<br>'.$mailfile->error;
696 setEventMessages(
'No mail sent. Feature is disabled by option MAIN_DISABLE_ALL_MAILS',
null,
'warnings');
704 setEventMessages($langs->trans(
"NoEmailSentBadSenderOrRecipientEmail"),
null,
'warnings');
713 if ($action ==
"confirm_refuse" &&
GETPOST(
'confirm',
'alpha') ==
"yes" && $id > 0 && $user->rights->expensereport->approve) {
717 $detailRefuse =
GETPOST(
'detail_refuse',
'alpha');
718 $result = $object->setDeny($user, $detailRefuse);
722 if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) {
723 $outputlangs = $langs;
726 $newlang =
GETPOST(
'lang_id',
'aZ09');
729 $newlang = $object->thirdparty->default_lang;
731 if (!empty($newlang)) {
733 $outputlangs->setDefaultLang($newlang);
735 $model = $object->model_pdf;
736 $ret = $object->fetch($id);
738 $object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref);
746 $destinataire =
new User($db);
747 $destinataire->fetch($object->fk_user_author);
748 $emailTo = $destinataire->email;
751 $expediteur =
new User($db);
752 $expediteur->fetch($object->fk_user_refuse);
753 $emailFrom = $conf->global->MAIN_MAIL_EMAIL_FROM;
755 if ($emailFrom && $emailTo) {
756 $filename = array(); $filedir = array(); $mimetype = array();
759 $societeName = $conf->global->MAIN_INFO_SOCIETE_NOM;
760 if (!empty($conf->global->MAIN_APPLICATION_TITLE)) {
761 $societeName = $conf->global->MAIN_APPLICATION_TITLE;
764 $subject = $societeName.
" - ".$langs->transnoentities(
"ExpenseReportRefused");
767 $link = $urlwithroot.
'/expensereport/card.php?id='.$object->id;
768 $link =
'<a href="'.$link.
'">'.$link.
'</a>';
769 $message = $langs->transnoentities(
"ExpenseReportRefusedMessage", $object->ref, $destinataire->getFullName($langs), $expediteur->getFullName($langs), $detailRefuse, $link);
787 $mailfile =
new CMailFile($subject, $emailTo, $emailFrom, $message, $filedir, $mimetype, $filename,
'',
'', 0, -1);
791 $result = $mailfile->sendfile();
793 $mesg = $langs->trans(
'MailSuccessfulySent', $mailfile->getValidAddress($emailFrom, 2), $mailfile->getValidAddress($emailTo, 2));
795 header(
"Location: ".$_SERVER[
"PHP_SELF"].
"?id=".$id);
798 $langs->load(
"other");
799 if ($mailfile->error) {
801 $mesg .= $langs->trans(
'ErrorFailedToSendMail', $emailFrom, $emailTo);
802 $mesg .=
'<br>'.$mailfile->error;
805 setEventMessages(
'No mail sent. Feature is disabled by option MAIN_DISABLE_ALL_MAILS',
null,
'warnings');
813 setEventMessages($langs->trans(
"NoEmailSentBadSenderOrRecipientEmail"),
null,
'warnings');
823 if ($action ==
"confirm_cancel" &&
GETPOST(
'confirm',
'alpha') ==
"yes" && $id > 0 && $user->rights->expensereport->creer) {
824 if (!
GETPOST(
'detail_cancel',
'alpha')) {
825 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Comment")),
null,
'errors');
830 if ($user->id == $object->fk_user_valid || $user->id == $object->fk_user_author) {
831 $detailCancel =
GETPOST(
'detail_cancel',
'alpha');
832 $result = $object->set_cancel($user, $detailCancel);
836 if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) {
837 $outputlangs = $langs;
840 $newlang =
GETPOST(
'lang_id',
'aZ09');
843 $newlang = $object->thirdparty->default_lang;
845 if (!empty($newlang)) {
847 $outputlangs->setDefaultLang($newlang);
849 $model = $object->model_pdf;
850 $ret = $object->fetch($id);
852 $object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref);
860 $destinataire =
new User($db);
861 $destinataire->fetch($object->fk_user_author);
862 $emailTo = $destinataire->email;
865 $expediteur =
new User($db);
866 $expediteur->fetch($object->fk_user_cancel);
867 $emailFrom = $conf->global->MAIN_MAIL_EMAIL_FROM;
869 if ($emailFrom && $emailTo) {
870 $filename = array(); $filedir = array(); $mimetype = array();
873 $societeName = $conf->global->MAIN_INFO_SOCIETE_NOM;
874 if (!empty($conf->global->MAIN_APPLICATION_TITLE)) {
875 $societeName = $conf->global->MAIN_APPLICATION_TITLE;
878 $subject = $societeName.
" - ".$langs->transnoentities(
"ExpenseReportCanceled");
881 $link = $urlwithroot.
'/expensereport/card.php?id='.$object->id;
882 $link =
'<a href="'.$link.
'">'.$link.
'</a>';
883 $message = $langs->transnoentities(
"ExpenseReportCanceledMessage", $object->ref, $destinataire->getFullName($langs), $expediteur->getFullName($langs), $detailCancel, $link);
901 $mailfile =
new CMailFile($subject, $emailTo, $emailFrom, $message, $filedir, $mimetype, $filename,
'',
'', 0, -1);
905 $result = $mailfile->sendfile();
907 $mesg = $langs->trans(
'MailSuccessfulySent', $mailfile->getValidAddress($emailFrom, 2), $mailfile->getValidAddress($emailTo, 2));
909 header(
"Location: ".$_SERVER[
"PHP_SELF"].
"?id=".$id);
912 $langs->load(
"other");
913 if ($mailfile->error) {
915 $mesg .= $langs->trans(
'ErrorFailedToSendMail', $emailFrom, $emailTo);
916 $mesg .=
'<br>'.$mailfile->error;
919 setEventMessages(
'No mail sent. Feature is disabled by option MAIN_DISABLE_ALL_MAILS',
null,
'warnings');
927 setEventMessages($langs->trans(
"NoEmailSentBadSenderOrRecipientEmail"),
null,
'warnings');
940 if ($action ==
"confirm_setdraft" &&
GETPOST(
'confirm',
'alpha') ==
"yes" && $id > 0 && $user->rights->expensereport->creer) {
943 if ($user->id == $object->fk_user_author || $user->id == $object->fk_user_valid) {
944 $result = $object->setStatut(0);
948 if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) {
949 $outputlangs = $langs;
952 $newlang =
GETPOST(
'lang_id',
'aZ09');
955 $newlang = $object->thirdparty->default_lang;
957 if (!empty($newlang)) {
959 $outputlangs->setDefaultLang($newlang);
961 $model = $object->model_pdf;
962 $ret = $object->fetch($id);
964 $object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref);
969 header(
"Location: ".$_SERVER[
"PHP_SELF"].
"?id=".$id);
979 if ($action ==
'set_unpaid' && $id > 0 && $user->rights->expensereport->to_paid) {
983 $result = $object->setUnpaid($user);
987 if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) {
988 $outputlangs = $langs;
991 $newlang =
GETPOST(
'lang_id',
'aZ09');
994 $newlang = $object->thirdparty->default_lang;
996 if (!empty($newlang)) {
998 $outputlangs->setDefaultLang($newlang);
1000 $model = $object->model_pdf;
1001 $ret = $object->fetch($id);
1003 $object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref);
1008 if ($action ==
'set_paid' && $id > 0 && $user->rights->expensereport->to_paid) {
1010 $object->fetch($id);
1012 $result = $object->setPaid($id, $user);
1016 if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) {
1017 $outputlangs = $langs;
1020 $newlang =
GETPOST(
'lang_id',
'aZ09');
1023 $newlang = $object->thirdparty->default_lang;
1025 if (!empty($newlang)) {
1026 $outputlangs =
new Translate(
"", $conf);
1027 $outputlangs->setDefaultLang($newlang);
1029 $model = $object->model_pdf;
1030 $ret = $object->fetch($id);
1032 $object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref);
1040 $destinataire =
new User($db);
1041 $destinataire->fetch($object->fk_user_author);
1042 $emailTo = $destinataire->email;
1045 $expediteur =
new User($db);
1046 $expediteur->fetch($user->id);
1047 $emailFrom = $conf->global->MAIN_MAIL_EMAIL_FROM;
1049 if ($emailFrom && $emailTo) {
1050 $filename = array(); $filedir = array(); $mimetype = array();
1053 $societeName = $conf->global->MAIN_INFO_SOCIETE_NOM;
1054 if (!empty($conf->global->MAIN_APPLICATION_TITLE)) {
1055 $societeName = $conf->global->MAIN_APPLICATION_TITLE;
1058 $subject = $societeName.
" - ".$langs->transnoentities(
"ExpenseReportPaid");
1061 $link = $urlwithroot.
'/expensereport/card.php?id='.$object->id;
1062 $link =
'<a href="'.$link.
'">'.$link.
'</a>';
1063 $message = $langs->transnoentities(
"ExpenseReportPaidMessage", $object->ref, $destinataire->getFullName($langs), $expediteur->getFullName($langs), $link);
1066 $object->setDocModel($user,
"");
1067 $resultPDF = expensereport_pdf_create($db, $object,
'',
"", $langs);
1070 $mailfile =
new CMailFile($subject, $emailTo, $emailFrom, $message, $filedir, $mimetype, $filename,
'',
'', 0, -1);
1074 $result = $mailfile->sendfile();
1076 $mesg = $langs->trans(
'MailSuccessfulySent', $mailfile->getValidAddress($emailFrom, 2), $mailfile->getValidAddress($emailTo, 2));
1078 header(
"Location: ".$_SERVER[
"PHP_SELF"].
"?id=".$id);
1081 $langs->load(
"other");
1082 if ($mailfile->error) {
1084 $mesg .= $langs->trans(
'ErrorFailedToSendMail', $emailFrom, $emailTo);
1085 $mesg .=
'<br>'.$mailfile->error;
1088 setEventMessages(
'No mail sent. Feature is disabled by option MAIN_DISABLE_ALL_MAILS',
null,
'warnings');
1096 setEventMessages($langs->trans(
"NoEmailSentBadSenderOrRecipientEmail"),
null,
'warnings');
1105 if ($action ==
"addline" && $user->rights->expensereport->creer) {
1111 $arrayoffiles =
GETPOST(
'attachfile',
'array');
1112 if (is_array($arrayoffiles) && !empty($arrayoffiles[0])) {
1113 include_once DOL_DOCUMENT_ROOT.
'/ecm/class/ecmfiles.class.php';
1114 $entityprefix = ($conf->entity !=
'1') ? $conf->entity.
'/' :
'';
1115 $relativepath =
'expensereport/'.$object->ref.
'/'.$arrayoffiles[0];
1117 $ecmfiles->
fetch(0,
'', $relativepath);
1118 $fk_ecm_files = $ecmfiles->id;
1123 if (empty($vatrate)) {
1126 $tmpvat =
price2num(preg_replace(
'/\s*\(.*\)/',
'', $vatrate));
1130 if (empty($value_unit)) {
1131 $value_unit =
price2num($value_unit_ht + ($value_unit_ht * $tmpvat / 100),
'MU');
1134 $fk_c_exp_tax_cat =
GETPOST(
'fk_c_exp_tax_cat',
'int');
1141 if (!($fk_c_type_fees > 0)) {
1143 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Type")),
null,
'errors');
1147 if ((
float) $tmpvat < 0 || $tmpvat ===
'') {
1149 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"VAT")),
null,
'errors');
1154 if (empty($date) || $date ==
"--") {
1156 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Date")),
null,
'errors');
1157 } elseif ($date < $object->date_debut || $date > ($object->date_fin + (24 * 3600 - 1))) {
1159 $langs->load(
"errors");
1160 setEventMessages($langs->trans(
"WarningDateOfLineMustBeInExpenseReportRange"),
null,
'warnings');
1164 if ($value_unit == 0) {
1166 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"PriceUTTC")),
null,
'errors');
1170 if ($projectRequired && $fk_project <= 0) {
1172 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Project")),
null,
'errors');
1176 if ($fileRequired && $fk_ecm_files == 0) {
1178 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"File")),
null,
'errors');
1185 $result = $object->addline($qty, $value_unit, $fk_c_type_fees, $vatrate, $date, $comments, $fk_project, $fk_c_exp_tax_cat, $type, $fk_ecm_files);
1187 $ret = $object->fetch($object->id);
1189 if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) {
1191 $outputlangs = $langs;
1192 $newlang =
GETPOST(
'lang_id',
'alpha');
1194 $user =
new User($db);
1195 $user->fetch($object->fk_user_author);
1196 $newlang = $user->lang;
1198 if (!empty($newlang)) {
1199 $outputlangs =
new Translate(
"", $conf);
1200 $outputlangs->setDefaultLang($newlang);
1203 $object->generateDocument($object->model_pdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
1207 unset($value_unit_ht);
1211 unset($fk_c_type_fees);
1222 header(
"Location: ".$_SERVER[
"PHP_SELF"].
"?id=".
GETPOST(
'id',
'int'));
1229 if ($action ==
'confirm_delete_line' &&
GETPOST(
"confirm",
'alpha') ==
"yes" && $user->rights->expensereport->creer) {
1231 $object->fetch($id);
1234 $object_ligne->fetch(
GETPOST(
"rowid",
'int'));
1235 $total_ht = $object_ligne->total_ht;
1236 $total_tva = $object_ligne->total_tva;
1238 $result = $object->deleteline(
GETPOST(
"rowid",
'int'), $user);
1242 if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) {
1243 $outputlangs = $langs;
1246 $newlang =
GETPOST(
'lang_id',
'aZ09');
1249 $newlang = $object->thirdparty->default_lang;
1251 if (!empty($newlang)) {
1252 $outputlangs =
new Translate(
"", $conf);
1253 $outputlangs->setDefaultLang($newlang);
1255 $model = $object->model_pdf;
1256 $ret = $object->fetch($id);
1258 $object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref);
1262 header(
"Location: ".$_SERVER[
"PHP_SELF"].
"?id=".
GETPOST(
'id',
'int'));
1269 if ($action ==
"updateline" && $user->rights->expensereport->creer) {
1271 $object->fetch($id);
1276 $arrayoffiles =
GETPOST(
'attachfile',
'array');
1277 if (is_array($arrayoffiles) && !empty($arrayoffiles[0])) {
1278 include_once DOL_DOCUMENT_ROOT.
'/ecm/class/ecmfiles.class.php';
1279 $relativepath =
'expensereport/'.$object->ref.
'/'.$arrayoffiles[0];
1281 $ecmfiles->fetch(0,
'', $relativepath);
1282 $fk_ecm_files = $ecmfiles->id;
1286 $rowid =
GETPOST(
'rowid',
'int');
1287 $type_fees_id =
GETPOST(
'fk_c_type_fees',
'int');
1288 $fk_c_exp_tax_cat =
GETPOST(
'fk_c_exp_tax_cat',
'int');
1289 $projet_id = $fk_project;
1290 $comments =
GETPOST(
'comments',
'restricthtml');
1292 $vatrate =
GETPOST(
'vatrate',
'alpha');
1295 if (empty($vatrate)) {
1298 $tmpvat =
price2num(preg_replace(
'/\s*\(.*\)/',
'', $vatrate));
1302 if (empty($value_unit)) {
1303 $value_unit =
price2num($value_unit_ht + ($value_unit_ht * $tmpvat / 100),
'MU');
1306 if (!
GETPOST(
'fk_c_type_fees',
'int') > 0) {
1308 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Type")),
null,
'errors');
1311 if ((
float) $tmpvat < 0 || $tmpvat ==
'') {
1313 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Vat")),
null,
'errors');
1317 if ($date < $object->date_debut || $date > ($object->date_fin + (24 * 3600 - 1))) {
1318 $langs->load(
"errors");
1319 setEventMessages($langs->trans(
"WarningDateOfLineMustBeInExpenseReportRange"),
null,
'warnings');
1323 if ($projectRequired && $projet_id <= 0) {
1325 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Project")),
null,
'errors');
1330 $result = $object->updateline($rowid, $type_fees_id, $projet_id, $vatrate, $comments, $qty, $value_unit, $date, $id, $fk_c_exp_tax_cat, $fk_ecm_files);
1334 if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) {
1335 $outputlangs = $langs;
1338 $newlang =
GETPOST(
'lang_id',
'aZ09');
1341 $newlang = $object->thirdparty->default_lang;
1343 if (!empty($newlang)) {
1344 $outputlangs =
new Translate(
"", $conf);
1345 $outputlangs->setDefaultLang($newlang);
1347 $model = $object->model_pdf;
1348 $ret = $object->fetch($id);
1350 $object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref);
1354 unset($value_unit_ht);
1358 unset($fk_c_type_fees);
1372 include DOL_DOCUMENT_ROOT.
'/core/actions_printing.inc.php';
1375 $triggersendname =
'EXPENSEREPORT_SENTBYMAIL';
1376 $autocopy =
'MAIN_MAIL_AUTOCOPY_EXPENSEREPORT_TO';
1377 $trackid =
'exp'.$object->id;
1378 include DOL_DOCUMENT_ROOT.
'/core/actions_sendmails.inc.php';
1381 $upload_dir = $conf->expensereport->dir_output;
1382 include DOL_DOCUMENT_ROOT.
'/core/actions_builddoc.inc.php';
1390 $title = $langs->trans(
"ExpenseReport").
" - ".$langs->trans(
"Card");
1391 $help_url =
"EN:Module_Expense_Reports|FR:Module_Notes_de_frais";
1398 $projecttmp =
new Project($db);
1400 $bankaccountstatic =
new Account($db);
1401 $ecmfilesstatic =
new EcmFiles($db);
1405 if ($action ==
'create') {
1408 print
'<form action="'.$_SERVER[
'PHP_SELF'].
'" method="post" name="create">';
1409 print
'<input type="hidden" name="token" value="'.newToken().
'">';
1410 print
'<input type="hidden" name="action" value="add">';
1411 print
'<input type="hidden" name="backtopage" value="'.$backtopage.
'">';
1415 print
'<table class="border centpercent">';
1420 print
'<td class="titlefieldcreate fieldrequired">'.$langs->trans(
"DateStart").
'</td>';
1422 print
$form->selectDate($date_start ? $date_start : -1,
'date_debut', 0, 0, 0,
'', 1, 1);
1428 print
'<td class="fieldrequired">'.$langs->trans(
"DateEnd").
'</td>';
1430 print
$form->selectDate($date_end ? $date_end : -1,
'date_fin', 0, 0, 0,
'', 1, 1);
1436 print
'<td class="fieldrequired">'.$langs->trans(
"User").
'</td>';
1438 $defaultselectuser = $user->id;
1439 if (
GETPOST(
'fk_user_author',
'int') > 0) {
1440 $defaultselectuser =
GETPOST(
'fk_user_author',
'int');
1442 $include_users =
'hierarchyme';
1443 if (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->expensereport->writeall_advance)) {
1444 $include_users = array();
1446 $s =
$form->select_dolusers($defaultselectuser,
"fk_user_author", 0,
"", 0, $include_users,
'',
'0,'.$conf->entity);
1453 print
'<td>'.$langs->trans(
"VALIDATOR").
'</td>';
1456 $include_users = $object->fetch_users_approver_expensereport();
1457 if (empty($include_users)) {
1458 print
img_warning().
' '.$langs->trans(
"NobodyHasPermissionToValidateExpenseReport");
1460 $defaultselectuser = (empty($user->fk_user_expense_validator) ? $user->fk_user : $user->fk_user_expense_validator);
1461 if (!empty($conf->global->EXPENSEREPORT_DEFAULT_VALIDATOR)) {
1462 $defaultselectuser = $conf->global->EXPENSEREPORT_DEFAULT_VALIDATOR;
1464 if (
GETPOST(
'fk_user_validator',
'int') > 0) {
1465 $defaultselectuser =
GETPOST(
'fk_user_validator',
'int');
1467 $s =
$form->select_dolusers($defaultselectuser,
"fk_user_validator", 1,
"", ((empty($defaultselectuser) || empty($conf->global->EXPENSEREPORT_DEFAULT_VALIDATOR_UNCHANGEABLE)) ? 0 : 1), $include_users);
1468 print
$form->textwithpicto($s, $langs->trans(
"AnyOtherInThisListCanValidate"));
1474 if (!empty($conf->global->EXPENSEREPORT_ASK_PAYMENTMODE_ON_CREATION)) {
1476 print
'<td>'.$langs->trans(
"ModePaiement").
'</td>';
1478 $form->select_types_paiements(
'',
'fk_c_paiement');
1487 print
'<td class="tdtop">'.$langs->trans(
'NotePublic').
'</td>';
1490 $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%');
1491 print $doleditor->Create(1);
1495 $note_private =
GETPOSTISSET(
'note_private') ?
GETPOST(
'note_private',
'restricthtml') :
'';
1497 if (empty($user->socid)) {
1499 print
'<td class="tdtop">'.$langs->trans(
'NotePrivate').
'</td>';
1502 $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%');
1503 print $doleditor->Create(1);
1508 $parameters = array(
'colspan' =>
' colspan="3"',
'cols' => 3);
1509 $reshook = $hookmanager->executeHooks(
'formObjectOptions',
$parameters, $object, $action);
1510 print $hookmanager->resPrint;
1511 if (empty($reshook)) {
1512 print $object->showOptionals($extrafields,
'create',
$parameters);
1520 print
$form->buttonsSaveCancel(
"AddTrip");
1523 } elseif ($id > 0 || $ref) {
1524 $result = $object->fetch($id, $ref);
1527 if (!in_array($object->fk_user_author, $user->getAllChildIds(1))) {
1528 if (empty($user->rights->expensereport->readall) && empty($user->rights->expensereport->lire_tous)
1529 && (empty($conf->global->MAIN_USE_ADVANCED_PERMS) || empty($user->rights->expensereport->writeall_advance))) {
1532 print
'<div class="tabBar">';
1533 print $langs->trans(
'NotUserRightToView');
1546 if ($action ==
'edit' && ($object->status < 3 || $object->status == 99)) {
1547 print
"<form name='update' action=\"".$_SERVER[
'PHP_SELF'].
"\" method=\"post\">\n";
1548 print
'<input type="hidden" name="token" value="'.newToken().
'">';
1549 print
'<input type="hidden" name="id" value="'.$id.
'">';
1550 print
'<input type="hidden" name="backtopage" value="'.$backtopage.
'">';
1554 if ($object->status == 99) {
1555 print
'<input type="hidden" name="action" value="updateFromRefuse">';
1557 print
'<input type="hidden" name="action" value="update">';
1560 $linkback =
'<a href="'.DOL_URL_ROOT.
'/expensereport/list.php?restore_lastsearch_values=1'.(!empty($socid) ?
'&socid='.$socid :
'').
'">'.$langs->trans(
"BackToList").
'</a>';
1562 print
'<table class="border" style="width:100%;">';
1565 print
'<td>'.$langs->trans(
"User").
'</td>';
1567 $userfee =
new User($db);
1568 if ($object->fk_user_author > 0) {
1569 $userfee->fetch($object->fk_user_author);
1570 print $userfee->getNomUrl(-1);
1575 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"Ref").
'</td><td>';
1576 print
$form->showrefnav($object,
'ref', $linkback, 1,
'ref',
'ref',
'');
1580 print
'<td>'.$langs->trans(
"DateStart").
'</td>';
1582 print
$form->selectDate($object->date_debut,
'date_debut');
1586 print
'<td>'.$langs->trans(
"DateEnd").
'</td>';
1588 print
$form->selectDate($object->date_fin,
'date_fin');
1592 if (!empty($conf->global->EXPENSEREPORT_ASK_PAYMENTMODE_ON_CREATION)) {
1594 print
'<td>'.$langs->trans(
"ModePaiement").
'</td>';
1596 $form->select_types_paiements($object->fk_c_paiement,
'fk_c_paiement');
1601 if ($object->status < 3) {
1603 print
'<td>'.$langs->trans(
"VALIDATOR").
'</td>';
1605 $include_users = $object->fetch_users_approver_expensereport();
1606 $s =
$form->select_dolusers($object->fk_user_validator,
"fk_user_validator", 1,
"", 0, $include_users);
1607 print
$form->textwithpicto($s, $langs->trans(
"AnyOtherInThisListCanValidate"));
1612 print
'<td>'.$langs->trans(
"VALIDOR").
'</td>';
1614 $userfee =
new User($db);
1615 $userfee->fetch($object->fk_user_valid);
1616 print $userfee->getNomUrl(-1);
1620 if ($object->status == 6) {
1622 print
'<td>'.$langs->trans(
"AUTHORPAIEMENT").
'</td>';
1624 $userfee =
new User($db);
1625 $userfee->fetch($user->id);
1626 print $userfee->getNomUrl(-1);
1638 print
$form->buttonsSaveCancel(
"Modify");
1642 $taxlessUnitPriceDisabled = !empty($conf->global->EXPENSEREPORT_FORCE_LINE_AMOUNTS_INCLUDING_TAXES_ONLY) ?
' disabled' :
'';
1649 if ($action ==
'clone') {
1651 $criteriaforfilter =
'hierarchyme';
1652 if (!empty($user->rights->expensereport->readall)) {
1653 $criteriaforfilter =
'';
1655 $formquestion = array(
1657 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'))
1660 $formconfirm =
$form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.$object->id, $langs->trans(
'ToClone'), $langs->trans(
'ConfirmCloneExpenseReport', $object->ref),
'confirm_clone', $formquestion,
'yes', 1);
1663 if ($action ==
'save') {
1664 $formconfirm =
$form->formconfirm($_SERVER[
"PHP_SELF"].
"?id=".$id, $langs->trans(
"SaveTrip"), $langs->trans(
"ConfirmSaveTrip"),
"confirm_validate",
"",
"", 1);
1667 if ($action ==
'save_from_refuse') {
1668 $formconfirm =
$form->formconfirm($_SERVER[
"PHP_SELF"].
"?id=".$id, $langs->trans(
"SaveTrip"), $langs->trans(
"ConfirmSaveTrip"),
"confirm_save_from_refuse",
"",
"", 1);
1671 if ($action ==
'delete') {
1672 $formconfirm =
$form->formconfirm($_SERVER[
"PHP_SELF"].
"?id=".$id, $langs->trans(
"DeleteTrip"), $langs->trans(
"ConfirmDeleteTrip"),
"confirm_delete",
"",
"", 1);
1675 if ($action ==
'validate') {
1676 $formconfirm =
$form->formconfirm($_SERVER[
"PHP_SELF"].
"?id=".$id, $langs->trans(
"ValideTrip"), $langs->trans(
"ConfirmValideTrip"),
"confirm_approve",
"",
"", 1);
1679 if ($action ==
'paid') {
1680 $formconfirm =
$form->formconfirm($_SERVER[
"PHP_SELF"].
"?id=".$id, $langs->trans(
"PaidTrip"), $langs->trans(
"ConfirmPaidTrip"),
"confirm_paid",
"",
"", 1);
1683 if ($action ==
'cancel') {
1684 $array_input = array(
'text'=>$langs->trans(
"ConfirmCancelTrip"), array(
'type'=>
"text",
'label'=>
'<strong>'.$langs->trans(
"Comment").
'</strong>',
'name'=>
"detail_cancel",
'value'=>
""));
1685 $formconfirm =
$form->formconfirm($_SERVER[
"PHP_SELF"].
"?id=".$id, $langs->trans(
"Cancel"),
"",
"confirm_cancel", $array_input,
"", 1);
1688 if ($action ==
'setdraft') {
1689 $formconfirm =
$form->formconfirm($_SERVER[
"PHP_SELF"].
"?id=".$id, $langs->trans(
"BrouillonnerTrip"), $langs->trans(
"ConfirmBrouillonnerTrip"),
"confirm_setdraft",
"",
"", 1);
1692 if ($action ==
'refuse') {
1693 $array_input = array(
'text'=>$langs->trans(
"ConfirmRefuseTrip"), array(
'type'=>
"text",
'label'=>$langs->trans(
"Comment"),
'name'=>
"detail_refuse",
'value'=>
""));
1694 $formconfirm =
$form->formconfirm($_SERVER[
"PHP_SELF"].
"?id=".$id, $langs->trans(
"Deny"),
'',
"confirm_refuse", $array_input,
"yes", 1);
1697 if ($action ==
'delete_line') {
1698 $formconfirm =
$form->formconfirm($_SERVER[
"PHP_SELF"].
"?id=".$id.
"&rowid=".
GETPOST(
'rowid',
'int'), $langs->trans(
"DeleteLine"), $langs->trans(
"ConfirmDeleteLine"),
"confirm_delete_line",
'',
'yes', 1);
1705 $linkback =
'<a href="'.DOL_URL_ROOT.
'/expensereport/list.php?restore_lastsearch_values=1'.(!empty($socid) ?
'&socid='.$socid :
'').
'">'.$langs->trans(
"BackToList").
'</a>';
1707 $morehtmlref =
'<div class="refidno">';
1708 $morehtmlref .=
'</div>';
1710 dol_banner_tab($object,
'ref', $linkback, 1,
'ref',
'ref', $morehtmlref);
1712 print
'<div class="fichecenter">';
1713 print
'<div class="fichehalfleft">';
1714 print
'<div class="underbanner clearboth"></div>';
1716 print
'<table class="border tableforfield centpercent">';
1720 print
'<td class="titlefield">'.$langs->trans(
"User").
'</td>';
1722 if ($object->fk_user_author > 0) {
1723 $userauthor =
new User($db);
1724 $result = $userauthor->fetch($object->fk_user_author);
1727 } elseif ($result > 0) {
1728 print $userauthor->getNomUrl(-1);
1735 print
'<td class="titlefield">'.$langs->trans(
"Period").
'</td>';
1737 print
get_date_range($object->date_debut, $object->date_fin,
'day', $langs, 0);
1740 if (!empty($conf->global->EXPENSEREPORT_ASK_PAYMENTMODE_ON_CREATION)) {
1742 print
'<td>'.$langs->trans(
"ModePaiement").
'</td>';
1743 print
'<td>'.$object->fk_c_paiement.
'</td>';
1749 print
'<td>'.$langs->trans(
"DATE_SAVE").
'</td>';
1750 print
'<td>'.dol_print_date($object->date_valid,
'dayhour',
'tzuser');
1751 if ($object->status == 2 && $object->hasDelay(
'toapprove')) {
1752 print
' '.img_warning($langs->trans(
"Late").
' - '.$langs->trans(
"ToApprove"));
1754 if ($object->status == 5 && $object->hasDelay(
'topay')) {
1755 print
' '.img_warning($langs->trans(
"Late").
' - '.$langs->trans(
"ToPay"));
1763 print
'<td>'.$langs->trans(
"VALIDATOR").
'</td>';
1765 if ($object->fk_user_validator > 0) {
1766 $userfee =
new User($db);
1767 $result = $userfee->fetch($object->fk_user_validator);
1769 print $userfee->getNomUrl(-1);
1771 if (empty($userfee->email) || !
isValidEmail($userfee->email)) {
1772 $langs->load(
"errors");
1773 print
img_warning($langs->trans(
"ErrorBadEMail", $userfee->email));
1779 print
'<td>'.$langs->trans(
"CANCEL_USER").
'</span></td>';
1781 if ($object->fk_user_cancel > 0) {
1782 $userfee =
new User($db);
1783 $result = $userfee->fetch($object->fk_user_cancel);
1785 print $userfee->getNomUrl(-1);
1791 print
'<td>'.$langs->trans(
"MOTIF_CANCEL").
'</td>';
1792 print
'<td>'.$object->detail_cancel.
'</td></tr>';
1795 print
'<td>'.$langs->trans(
"DATE_CANCEL").
'</td>';
1796 print
'<td>'.dol_print_date($object->date_cancel,
'dayhour',
'tzuser').
'</td></tr>';
1800 print
'<td>'.$langs->trans(
"ApprovedBy").
'</td>';
1802 if ($object->fk_user_approve > 0) {
1803 $userapp =
new User($db);
1804 $result = $userapp->fetch($object->fk_user_approve);
1806 print $userapp->getNomUrl(-1);
1812 print
'<td>'.$langs->trans(
"DateApprove").
'</td>';
1813 print
'<td>'.dol_print_date($object->date_approve,
'dayhour',
'tzuser').
'</td></tr>';
1817 if ($object->status == 99 || !empty($object->detail_refuse)) {
1819 print
'<td>'.$langs->trans(
"REFUSEUR").
'</td>';
1821 $userfee =
new User($db);
1822 $result = $userfee->fetch($object->fk_user_refuse);
1824 print $userfee->getNomUrl(-1);
1829 print
'<td>'.$langs->trans(
"DATE_REFUS").
'</td>';
1830 print
'<td>'.dol_print_date($object->date_refuse,
'dayhour',
'tzuser');
1831 if ($object->detail_refuse) {
1832 print
' - '.$object->detail_refuse;
1838 if ($object->status == $object::STATUS_CLOSED) {
1856 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_view.tpl.php';
1861 print
'<div class="fichehalfright">';
1862 print
'<div class="underbanner clearboth"></div>';
1864 print
'<table class="border tableforfield centpercent">';
1868 print
'<td class="titlefieldmiddle">'.$langs->trans(
"AmountHT").
'</td>';
1869 print
'<td class="nowrap amountcard">'.price($object->total_ht, 1,
'', 1, - 1, - 1, $conf->currency).
'</td>';
1888 print
'<td>'.$langs->trans(
"AmountVAT").
'</td>';
1889 print
'<td class="nowrap amountcard">'.price($object->total_tva, 1,
'', 1, -1, -1, $conf->currency).
'</td>';
1893 if ($mysoc->localtax1_assuj ==
"1" || $object->total_localtax1 != 0) {
1894 print
'<tr><td>'.$langs->transcountry(
"AmountLT1", $mysoc->country_code).
'</td>';
1895 print
'<td class="valuefield">'.price($object->total_localtax1, 1,
'', 1, -1, -1, $conf->currency).
'</td></tr>';
1897 if ($mysoc->localtax2_assuj ==
"1" || $object->total_localtax2 != 0) {
1898 print
'<tr><td>'.$langs->transcountry(
"AmountLT2", $mysoc->country_code).
'</td>';
1899 print
'<td class="valuefield">'.price($object->total_localtax2, 1,
'', 1, -1, -1, $conf->currency).
'</td></tr>';
1903 print
'<td>'.$langs->trans(
"AmountTTC").
'</td>';
1904 print
'<td class="nowrap amountcard">'.price($object->total_ttc, 1,
'', 1, -1, -1, $conf->currency).
'</td>';
1915 print
'<table class="noborder paymenttable centpercent">';
1917 print
'<tr class="liste_titre">';
1918 print
'<td class="liste_titre">'.$langs->trans(
'Payments').
'</td>';
1919 print
'<td class="liste_titre">'.$langs->trans(
'Date').
'</td>';
1920 print
'<td class="liste_titre">'.$langs->trans(
'Type').
'</td>';
1922 print
'<td class="liste_titre right">'.$langs->trans(
'BankAccount').
'</td>';
1924 print
'<td class="liste_titre right">'.$langs->trans(
'Amount').
'</td>';
1925 print
'<td class="liste_titre" width="18"> </td>';
1929 $sql =
"SELECT p.rowid, p.num_payment, p.datep as dp, p.amount, p.fk_bank,";
1930 $sql .=
"c.code as payment_code, c.libelle as payment_type,";
1931 $sql .=
"ba.rowid as baid, ba.ref as baref, ba.label, ba.number as banumber, ba.account_number, ba.fk_accountancy_journal";
1932 $sql .=
" FROM ".MAIN_DB_PREFIX.
"expensereport as e, ".MAIN_DB_PREFIX.
"payment_expensereport as p";
1933 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"c_paiement as c ON p.fk_typepayment = c.id";
1934 $sql .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'bank as b ON p.fk_bank = b.rowid';
1935 $sql .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'bank_account as ba ON b.fk_account = ba.rowid';
1936 $sql .=
" WHERE e.rowid = ".((int) $id);
1937 $sql .=
" AND p.fk_expensereport = e.rowid";
1938 $sql .=
' AND e.entity IN ('.getEntity(
'expensereport').
')';
1939 $sql .=
" ORDER BY dp";
1941 $resql = $db->query(
$sql);
1943 $num = $db->num_rows($resql);
1944 $i = 0; $totalpaid = 0;
1946 $objp = $db->fetch_object($resql);
1948 $paymentexpensereportstatic->id = $objp->rowid;
1949 $paymentexpensereportstatic->datep = $db->jdate($objp->dp);
1950 $paymentexpensereportstatic->ref = $objp->rowid;
1951 $paymentexpensereportstatic->num_payment = $objp->num_payment;
1952 $paymentexpensereportstatic->type_code = $objp->payment_code;
1953 $paymentexpensereportstatic->type_label = $objp->payment_type;
1955 print
'<tr class="oddseven">';
1957 print $paymentexpensereportstatic->getNomUrl(1);
1959 print
'<td>'.dol_print_date($db->jdate($objp->dp),
'day').
"</td>\n";
1960 $labeltype = $langs->trans(
"PaymentType".$objp->payment_code) != (
"PaymentType".$objp->payment_code) ? $langs->trans(
"PaymentType".$objp->payment_code) : $objp->payment_type;
1961 print
"<td>".$labeltype.
' '.$objp->num_payment.
"</td>\n";
1964 $bankaccountstatic->id = $objp->baid;
1965 $bankaccountstatic->ref = $objp->baref;
1966 $bankaccountstatic->label = $objp->baref;
1967 $bankaccountstatic->number = $objp->banumber;
1970 $bankaccountstatic->account_number = $objp->account_number;
1973 $accountingjournal->fetch($objp->fk_accountancy_journal);
1974 $bankaccountstatic->accountancy_journal = $accountingjournal->getNomUrl(0, 1, 1,
'', 1);
1977 print
'<td class="right">';
1978 if ($bankaccountstatic->id) {
1979 print $bankaccountstatic->getNomUrl(1,
'transactions');
1983 print
'<td class="right">'.price($objp->amount).
"</td>";
1986 $totalpaid += $objp->amount;
1989 if (!is_null($totalpaid)) {
1993 $remaintopay =
price2num($object->total_ttc - $totalpaid);
1994 $resteapayeraffiche = $remaintopay;
1996 $cssforamountpaymentcomplete =
'amountpaymentcomplete';
1999 $cssforamountpaymentcomplete =
'amountpaymentneutral';
2000 $resteapayeraffiche = 0;
2001 } elseif ($object->paid == 0) {
2002 $cssforamountpaymentcomplete =
'amountpaymentneutral';
2004 print
'<tr><td colspan="'.$nbcols.
'" class="right">'.$langs->trans(
"AlreadyPaid").
':</td><td class="right">'.
price($totalpaid).
'</td><td></td></tr>';
2005 print
'<tr><td colspan="'.$nbcols.
'" class="right">'.$langs->trans(
"AmountExpected").
':</td><td class="right">'.
price($object->total_ttc).
'</td><td></td></tr>';
2007 print
'<tr><td colspan="'.$nbcols.
'" class="right">'.$langs->trans(
"RemainderToPay").
':</td>';
2008 print
'<td class="right'.($resteapayeraffiche ?
' amountremaintopay' : (
' '.$cssforamountpaymentcomplete)).
'">'.
price($resteapayeraffiche).
'</td><td></td></tr>';
2019 print
'<div class="clearboth"></div><br>';
2021 print
'<div style="clear: both;"></div>';
2023 $actiontouse =
'updateline';
2024 if (($object->status == 0 || $object->status == 99) && $action !=
'editline') {
2025 $actiontouse =
'addline';
2028 print
'<form name="expensereport" action="'.$_SERVER[
"PHP_SELF"].
'" enctype="multipart/form-data" method="post" >';
2029 print
'<input type="hidden" name="token" value="'.newToken().
'">';
2030 print
'<input type="hidden" name="action" value="'.$actiontouse.
'">';
2031 print
'<input type="hidden" name="id" value="'.$object->id.
'">';
2032 print
'<input type="hidden" name="fk_expensereport" value="'.$object->id.
'" />';
2033 print
'<input type="hidden" name="backtopage" value="'.$backtopage.
'">';
2034 print
'<input type="hidden" name="page_y" value="">';
2036 print
'<div class="div-table-responsive-no-min">';
2037 print
'<table id="tablelines" class="noborder centpercent">';
2039 if (!empty($object->lines)) {
2042 print
'<tr class="liste_titre headerexpensereportdet">';
2043 print
'<td class="center linecollinenb">'.$langs->trans(
'LineNb').
'</td>';
2045 print
'<td class="center linecoldate">'.$langs->trans(
'Date').
'</td>';
2047 print
'<td class="minwidth100imp linecolproject">'.$langs->trans(
'Project').
'</td>';
2049 print
'<td class="center linecoltype">'.$langs->trans(
'Type').
'</td>';
2050 if (!empty($conf->global->MAIN_USE_EXPENSE_IK)) {
2051 print
'<td class="center linecolcarcategory">'.$langs->trans(
'CarCategory').
'</td>';
2053 print
'<td class="linecoldescription">'.$langs->trans(
'Description').
'</td>';
2054 print
'<td class="right linecolvat">'.$langs->trans(
'VAT').
'</td>';
2055 print
'<td class="right linecolpriceuht">'.$langs->trans(
'PriceUHT').
'</td>';
2056 print
'<td class="right linecolpriceuttc">'.$langs->trans(
'PriceUTTC').
'</td>';
2057 print
'<td class="right linecolqty">'.$langs->trans(
'Qty').
'</td>';
2058 if ($action !=
'editline') {
2059 print
'<td class="right linecolamountht">'.$langs->trans(
'AmountHT').
'</td>';
2060 print
'<td class="right linecolamountttc">'.$langs->trans(
'AmountTTC').
'</td>';
2071 if (($object->status < 2 || $object->status == 99) && $user->rights->expensereport->creer) {
2072 print
'<td class="right"></td>';
2076 foreach ($object->lines as &$line) {
2079 if ($action !=
'editline' || $line->id !=
GETPOST(
'rowid',
'int')) {
2080 print
'<tr class="oddeven linetr" data-id="'.$line->id.
'">';
2083 print
'<td class="center linecollinenb">';
2088 print
'<td class="center linecoldate">'.dol_print_date($db->jdate($line->date),
'day').
'</td>';
2092 print
'<td class="lineproject">';
2093 if ($line->fk_project > 0) {
2094 $projecttmp->id = $line->fk_project;
2095 $projecttmp->ref = $line->projet_ref;
2096 $projecttmp->title = $line->projet_title;
2097 print $projecttmp->getNomUrl(1);
2104 require_once DOL_DOCUMENT_ROOT.
'/accountancy/class/accountingaccount.class.php';
2106 $resaccountingaccount = $accountingaccount->fetch(0, $line->type_fees_accountancy_code, 1);
2108 $titlealt .= $langs->trans(
"AccountancyCode").
': ';
2109 if ($resaccountingaccount > 0) {
2110 $titlealt .= $accountingaccount->account_number;
2112 $titlealt .= $langs->trans(
"NotFound");
2118 print
'<td class="center linecoltype" title="'.dol_escape_htmltag($titlealt).
'">';
2119 $labeltype = ($langs->trans(($line->type_fees_code)) == $line->type_fees_code ? $line->type_fees_libelle : $langs->trans($line->type_fees_code));
2124 if (!empty($conf->global->MAIN_USE_EXPENSE_IK)) {
2125 print
'<td class="fk_c_exp_tax_cat linecoltaxcat">';
2126 $exp_tax_cat_label =
dol_getIdFromCode($db, $line->fk_c_exp_tax_cat,
'c_exp_tax_cat',
'rowid',
'label');
2127 print $langs->trans($exp_tax_cat_label);
2132 print
'<td class="left linecolcomment">'.dol_nl2br($line->comments).
'</td>';
2135 print
'<td class="right linecolvatrate">'.vatrate($line->vatrate.($line->vat_src_code ?
' ('.$line->vat_src_code.
')' :
''),
true).
'</td>';
2138 print
'<td class="right linecolunitht">';
2139 if (!empty($line->value_unit_ht)) {
2140 print
price($line->value_unit_ht);
2142 $tmpvat =
price2num(preg_replace(
'/\s*\(.*\)/',
'', $line->vatrate));
2143 $pricenettoshow =
price2num($line->value_unit / (1 + $tmpvat / 100),
'MU');
2144 print
price($pricenettoshow);
2148 print
'<td class="right linecolunitttc">'.price($line->value_unit).
'</td>';
2150 print
'<td class="right linecolqty">'.dol_escape_htmltag($line->qty).
'</td>';
2152 if ($action !=
'editline') {
2153 print
'<td class="right linecoltotalht">'.price($line->total_ht).
'</td>';
2154 print
'<td class="right linecoltotalttc">'.price($line->total_ttc).
'</td>';
2158 print
'<td class="center linecolpreview">';
2159 if ($line->fk_ecm_files > 0) {
2160 $modulepart =
'expensereport';
2161 $maxheightmini = 32;
2163 $result = $ecmfilesstatic->fetch($line->fk_ecm_files);
2165 $relativepath = preg_replace(
'/expensereport\//',
'', $ecmfilesstatic->filepath);
2166 $fileinfo = pathinfo($ecmfilesstatic->filepath.
'/'.$ecmfilesstatic->filename);
2169 if (!
dol_is_file($conf->expensereport->dir_output.
'/'.$relativepath.
'/'.$minifile)) {
2173 $urlforhref =
getAdvancedPreviewUrl($modulepart, $relativepath.
'/'.$fileinfo[
'filename'].
'.'.strtolower($fileinfo[
'extension']), 1,
'&entity='.(!empty($object->entity) ? $object->entity : $conf->entity));
2174 if (empty($urlforhref)) {
2175 $urlforhref = DOL_URL_ROOT.
'/viewimage.php?modulepart='.$modulepart.
'&entity='.(!empty($object->entity) ? $object->entity : $conf->entity).
'&file='.urlencode($relativepath.$fileinfo[
'filename'].
'.'.strtolower($fileinfo[
'extension']));
2176 print
'<a href="'.$urlforhref.
'" class="aphoto" target="_blank" rel="noopener noreferrer">';
2178 print
'<a href="'.$urlforhref[
'url'].
'" class="'.$urlforhref[
'css'].
'" target="'.$urlforhref[
'target'].
'" mime="'.$urlforhref[
'mime'].
'">';
2180 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="">';
2183 $modulepart =
'expensereport';
2185 if (preg_match(
'/\.pdf$/i', $ecmfilesstatic->filename)) {
2186 $filepdf = $conf->expensereport->dir_output.
'/'.$relativepath.
'/'.$ecmfilesstatic->filename;
2187 $fileimage = $conf->expensereport->dir_output.
'/'.$relativepath.
'/'.$ecmfilesstatic->filename.
'_preview.png';
2188 $relativepathimage = $relativepath.
'/'.$ecmfilesstatic->filename.
'_preview.png';
2190 $pdfexists = file_exists($filepdf);
2193 if (!file_exists($fileimage) || (filemtime($fileimage) < filemtime($filepdf))) {
2194 if (empty($conf->global->MAIN_DISABLE_PDF_THUMBS)) {
2195 include_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
2204 if ($pdfexists && !$error) {
2205 $heightforphotref = 70;
2206 if (!empty($conf->dol_optimize_smallscreen)) {
2207 $heightforphotref = 60;
2210 if (file_exists($fileimage)) {
2212 $urlforhref =
getAdvancedPreviewUrl($modulepart, $relativepath.
'/'.$fileinfo[
'filename'].
'.'.strtolower($fileinfo[
'extension']), 1,
'&entity='.(!empty($object->entity) ? $object->entity : $conf->entity));
2213 print
'<a href="'.$urlforhref[
'url'].
'" class="'.$urlforhref[
'css'].
'" target="'.$urlforhref[
'target'].
'" mime="'.$urlforhref[
'mime'].
'">';
2214 print
'<img height="'.$heightforphotref.
'" class="photo photowithmargin photowithborder" src="'.DOL_URL_ROOT.
'/viewimage.php?modulepart=apercu'.$modulepart.
'&file='.urlencode($relativepathimage).
'">';
2221 print
img_mime($ecmfilesstatic->filename);
2228 print
'<td class="nowrap right linecolwarning">';
2229 print !empty($line->rule_warning_message) ?
img_warning(html_entity_decode($line->rule_warning_message)) :
' ';
2234 print
'<td class="nowrap right linecolaction">';
2236 print
'<a class="editfielda reposition paddingrightonly" href="'.$_SERVER[
"PHP_SELF"].
'?id='.$object->id.
'&action=editline&token='.
newToken().
'&rowid='.$line->rowid.
'">';
2238 print
'</a> ';
2239 print
'<a class="paddingrightonly" href="'.$_SERVER[
"PHP_SELF"].
'?id='.$object->id.
'&action=delete_line&token='.
newToken().
'&rowid='.$line->rowid.
'">';
2249 if ($action ==
'editline' && $line->id ==
GETPOST(
'rowid',
'int')) {
2255 if (!empty($conf->global->MAIN_USE_EXPENSE_IK)) {
2259 print
'<!-- line of expense report -->'.
"\n";
2260 print
'<tr class="tredited">';
2262 print
'<td class="center">';
2266 print
'<td colspan="'.($colspan - 1).
'" class="liste_titre"> ';
2267 print
'<a href="" class="commonlink auploadnewfilenow reposition">'.$langs->trans(
"UploadANewFileNow");
2268 print
img_picto($langs->trans(
"UploadANewFileNow"),
'chevron-down',
'',
false, 0, 0,
'',
'marginleftonly');
2270 if (empty($conf->global->EXPENSEREPORT_DISABLE_ATTACHMENT_ON_LINES)) {
2271 print
' - <a href="" class="commonlink aattachtodoc reposition">'.$langs->trans(
"AttachTheNewLineToTheDocument");
2272 print
img_picto($langs->trans(
"AttachTheNewLineToTheDocument"),
'chevron-down',
'',
false, 0, 0,
'',
'marginleftonly');
2276 print
'<!-- Code to open/close section to submit or link files in edit mode -->'.
"\n";
2277 print
'<script type="text/javascript">'.
"\n";
2278 print
'$(document).ready(function() {
2279 $( ".auploadnewfilenow" ).click(function() {
2280 jQuery(".truploadnewfilenow").toggle();
2281 jQuery(".trattachnewfilenow").hide();
2284 $( ".aattachtodoc" ).click(function() {
2285 jQuery(".trattachnewfilenow").toggle();
2286 jQuery(".truploadnewfilenow").hide();
2289 if (is_array(
GETPOST(
'attachfile',
'array')) && count(
GETPOST(
'attachfile',
'array'))) {
2290 print
'jQuery(".trattachnewfilenow").toggle();'.
"\n";
2293 jQuery("form[name=\"expensereport\"]").submit(function() {
2294 if (jQuery(".truploadnewfilenow").is(":hidden")) {
2295 jQuery("input[name=\"sendit\"]").val("");
2302 print
'</script>'.
"\n";
2305 $filenamelinked =
'';
2306 if ($line->fk_ecm_files > 0) {
2307 $result = $ecmfilesstatic->fetch($line->fk_ecm_files);
2309 $filenamelinked = $ecmfilesstatic->filename;
2313 $tredited =
'tredited';
2314 include DOL_DOCUMENT_ROOT.
'/expensereport/tpl/expensereport_addfile.tpl.php';
2315 include DOL_DOCUMENT_ROOT.
'/expensereport/tpl/expensereport_linktofile.tpl.php';
2317 print
'<tr class="oddeven tredited">';
2322 print
'<td class="center">';
2323 print
$form->selectDate($line->date,
'date');
2329 $formproject->select_projects(-1, $line->fk_project,
'fk_project', 0, 0, $projectRequired ? 0 : 1, 1, 0, 0, 0,
'', 0, 0,
'maxwidth300');
2334 print
'<td class="center">';
2335 print $formexpensereport->selectTypeExpenseReport($line->fk_c_type_fees,
'fk_c_type_fees');
2338 if (!empty($conf->global->MAIN_USE_EXPENSE_IK)) {
2339 print
'<td class="fk_c_exp_tax_cat">';
2340 $params = array(
'fk_expense' => $object->id,
'fk_expense_det' => $line->id,
'date' => $line->date);
2341 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);
2347 print
'<textarea name="comments" class="flat_ndf centpercent">'.dol_escape_htmltag($line->comments, 0, 1).
'</textarea>';
2351 $selectedvat =
price2num($line->vatrate).(!empty($line->vat_src_code) ?
' ('.$line->vat_src_code.
')' :
'');
2352 print
'<td class="right">';
2353 print
$form->load_tva(
'vatrate', (
GETPOSTISSET(
"vatrate") ?
GETPOST(
"vatrate") : $selectedvat), $mysoc,
'', 0, 0,
'',
false, 1);
2357 print
'<td class="right">';
2358 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.
' />';
2362 print
'<td class="right">';
2363 print
'<input type="text" min="0" class="right maxwidth50" id="value_unit" name="value_unit" value="'.dol_escape_htmltag(
price2num($line->value_unit)).
'" />';
2367 print
'<td class="right">';
2368 print
'<input type="text" min="0" class="input_qty right maxwidth50" name="qty" value="'.dol_escape_htmltag($line->qty).
'" />';
2375 print
'<td class="center">';
2379 print
'<td class="center">';
2383 print
'<input type="hidden" name="rowid" value="'.$line->rowid.
'">';
2384 print
$form->buttonsSaveCancel(
'Save',
'Cancel', array(), 0,
'small');
2397 if (!empty($conf->global->MAIN_USE_EXPENSE_IK)) {
2403 if ($action !=
'editline') {
2407 $nbFiles = $nbLinks = 0;
2408 $arrayoffiles = array();
2409 if (empty($conf->global->EXPENSEREPORT_DISABLE_ATTACHMENT_ON_LINES)) {
2410 require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
2411 require_once DOL_DOCUMENT_ROOT.
'/core/lib/images.lib.php';
2412 require_once DOL_DOCUMENT_ROOT.
'/core/class/link.class.php';
2415 $nbFiles = count($arrayoffiles);
2416 $nbLinks =
Link::count($db, $object->element, $object->id);
2420 print
'<tr class="liste_titre">';
2421 print
'<td colspan="'.$colspan.
'" class="liste_titre expensereportautoload">';
2422 print
'<a href="" class="commonlink auploadnewfilenow reposition">'.$langs->trans(
"UploadANewFileNow");
2423 print
img_picto($langs->trans(
"UploadANewFileNow"),
'chevron-down',
'',
false, 0, 0,
'',
'marginleftonly');
2425 if (empty($conf->global->EXPENSEREPORT_DISABLE_ATTACHMENT_ON_LINES)) {
2426 print
' - <a href="" class="commonlink aattachtodoc reposition">'.$langs->trans(
"AttachTheNewLineToTheDocument");
2427 print
img_picto($langs->trans(
"AttachTheNewLineToTheDocument"),
'chevron-down',
'',
false, 0, 0,
'',
'marginleftonly');
2431 print
'<!-- Code to open/close section to submit or link files in the form to add new line -->'.
"\n";
2432 print
'<script type="text/javascript">'.
"\n";
2433 print
'$(document).ready(function() {
2434 $( ".auploadnewfilenow" ).click(function() {
2435 console.log("We click on toggle of auploadnewfilenow");
2436 jQuery(".truploadnewfilenow").toggle();
2437 jQuery(".trattachnewfilenow").hide();
2438 if (jQuery(".truploadnewfilenow").is(":hidden")) {
2439 jQuery("input[name=\"sendit\"]").prop("name", "senditdisabled");
2441 jQuery("input[name=\"senditdisabled\"]").prop("name", "sendit");
2443 // TODO Switch css fa-chevron-dow and add fa-chevron-up
2446 $( ".aattachtodoc" ).click(function() {
2447 console.log("We click on toggle of aattachtodoc");
2448 jQuery(".trattachnewfilenow").toggle();
2449 jQuery(".truploadnewfilenow").hide();
2450 // TODO Switch css fa-chevron-dow and add fa-chevron-up
2453 if (is_array(
GETPOST(
'attachfile',
'array')) && count(
GETPOST(
'attachfile',
'array')) && $action !=
'updateline') {
2454 print
'jQuery(".trattachnewfilenow").show();'.
"\n";
2457 jQuery("form[name=\"expensereport\"]").submit(function() {
2458 if (jQuery(".truploadnewfilenow").is(":hidden")) {
2459 /* 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. */
2460 jQuery("input[name=\"sendit\"]").val("");
2461 jQuery("input[name=\"sendit\"]").prop("name", "senditdisabled");
2463 jQuery("input[name=\"senditdisabled\"]").prop("name", "sendit");
2470 print
'</script>'.
"\n";
2474 include DOL_DOCUMENT_ROOT.
'/expensereport/tpl/expensereport_linktofile.tpl.php';
2475 include DOL_DOCUMENT_ROOT.
'/expensereport/tpl/expensereport_addfile.tpl.php';
2477 print
'<tr class="liste_titre expensereportcreate">';
2479 print
'<td class="center expensereportcreatedate">'.$langs->trans(
'Date').
'</td>';
2481 print
'<td class="minwidth100imp">'.$form->textwithpicto($langs->trans(
'Project'), $langs->trans(
"ClosedProjectsAreHidden")).
'</td>';
2483 print
'<td class="center expensereportcreatetype">'.$langs->trans(
'Type').
'</td>';
2484 if (!empty($conf->global->MAIN_USE_EXPENSE_IK)) {
2485 print
'<td>'.$langs->trans(
'CarCategory').
'</td>';
2487 print
'<td class="expensereportcreatedescription">'.$langs->trans(
'Description').
'</td>';
2488 print
'<td class="right expensereportcreatevat">'.$langs->trans(
'VAT').
'</td>';
2489 print
'<td class="right expensereportcreatepriceuth">'.$langs->trans(
'PriceUHT').
'</td>';
2490 print
'<td class="right expensereportcreatepricettc">'.$langs->trans(
'PriceUTTC').
'</td>';
2491 print
'<td class="right expensereportcreateqty">'.$langs->trans(
'Qty').
'</td>';
2498 print
'<tr class="oddeven nohover">';
2504 print
'<td class="center inputdate">';
2505 print
$form->selectDate(!empty($date) ? $date : -1,
'date', 0, 0, 0,
'', 1, 1);
2510 print
'<td class="inputproject">';
2511 $formproject->select_projects(-1, !empty($fk_project) ? $fk_project : 0,
'fk_project', 0, 0, $projectRequired ? 0 : 1, -1, 0, 0, 0,
'', 0, 0,
'maxwidth300');
2516 print
'<td class="center inputtype">';
2517 print $formexpensereport->selectTypeExpenseReport(!empty($fk_c_type_fees) ? $fk_c_type_fees :
"",
'fk_c_type_fees', 1);
2520 if (!empty($conf->global->MAIN_USE_EXPENSE_IK)) {
2521 print
'<td class="fk_c_exp_tax_cat">';
2522 $params = array(
'fk_expense' => $object->id);
2523 print
$form->selectExpenseCategories(
'',
'fk_c_exp_tax_cat', 1, array(),
'fk_c_type_fees', $userauthor->default_c_exp_tax_cat, $params, 0);
2528 print
'<td class="inputcomment">';
2529 print
'<textarea class="flat_ndf centpercent" name="comments" rows="'.ROWS_2.
'">'.
dol_escape_htmltag(!empty($comments) ? $comments :
"", 0, 1).
'</textarea>';
2533 print
'<td class="right inputvat">';
2535 if (!empty($conf->global->EXPENSEREPORT_NO_DEFAULT_VAT)) {
2537 $conf->global->MAIN_VAT_DEFAULT_IF_AUTODETECT_FAILS =
'none';
2539 print
$form->load_tva(
'vatrate', (!empty($vatrate) ? $vatrate : $defaultvat), $mysoc,
'', 0, 0,
'',
false, 1);
2543 print
'<td class="right inputpricenet">';
2544 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.
' />';
2548 print
'<td class="right inputtax">';
2549 print
'<input type="text" class="right maxwidth50" id="value_unit" name="value_unit" value="'.dol_escape_htmltag((!empty($value_unit) ? $value_unit : 0)).
'">';
2553 print
'<td class="right inputqty">';
2554 print
'<input type="text" min="0" class=" input_qty right maxwidth50" name="qty" value="'.dol_escape_htmltag(!empty($qty) ? $qty : 1).
'">';
2560 if ($action !=
'editline') {
2561 print
'<td class="right"></td>';
2562 print
'<td class="right"></td>';
2565 print
'<td class="center inputbuttons">';
2566 print
$form->buttonsSaveCancel(
"Add",
'',
'', 1,
'reposition');
2577 /* JQuery for product free or predefined select */
2578 jQuery(document).ready(function() {
2579 jQuery("#value_unit_ht").keyup(function(event) {
2580 console.log(event.which); // discard event tag and arrows
2581 if (event.which != 9 && (event.which < 37 ||event.which > 40) && jQuery("#value_unit_ht").val() != "") {
2582 jQuery("#value_unit").val("");
2585 jQuery("#value_unit").keyup(function(event) {
2586 console.log(event.which); // discard event tag and arrows
2587 if (event.which != 9 && (event.which < 37 || event.which > 40) && jQuery("#value_unit").val() != "") {
2588 jQuery("#value_unit_ht").val("");
2593 if (! empty($conf->global->MAIN_USE_EXPENSE_IK)) {
2596 /* unit price coéf calculation */
2597 jQuery(".input_qty, #fk_c_type_fees, #select_fk_c_exp_tax_cat, #vatrate ").change(function(event) {
2599 let type_fee = jQuery("#fk_c_type_fees").find(":selected").val();
2600 let tax_cat = jQuery("#select_fk_c_exp_tax_cat").find(":selected").val();
2601 let tva = jQuery("#vatrate").find(":selected").val();
2602 let qty = jQuery(".input_qty").val();
2606 let path = "'.dol_buildpath(
"/expensereport/ajax/ajaxik.php", 1) .
'";
2607 path += "?fk_c_exp_tax_cat="+tax_cat;
2608 path +="&fk_expense="+'.$object->id.
';
2609 path += "&vatrate="+tva;
2610 path += "&qty="+qty;
2612 if (type_fee == 4) { // frais_kilométriques
2614 if (tax_cat == "" || parseInt(tax_cat) <= 0){
2622 ,success:function(response) {
2623 if (response.response_status == "success"){';
2625 if (!empty($conf->global->EXPENSEREPORT_FORCE_LINE_AMOUNTS_INCLUDING_TAXES_ONLY)) {
2627 jQuery("#value_unit").val(parseFloat(response.data) * (100 + parseFloat(tva)) / 100);
2628 jQuery("#value_unit").trigger("change");
2632 jQuery("#value_unit_ht").val(response.data);
2633 jQuery("#value_unit_ht").trigger("change");
2634 jQuery("#value_unit").val("");
2639 } else if(response.response_status == "error" && response.errorMessage != undefined && response.errorMessage.length > 0 ){
2640 $.jnotify(response.errorMessage, "error", {timeout: 0, type: "error"},{ remove: function (){} } );
2647 /*console.log(event.which); // discard event tag and arrows
2648 if (event.which != 9 && (event.which < 37 || event.which > 40) && jQuery("#value_unit").val() != "") {
2649 jQuery("#value_unit_ht").val("");
2669 print
'Record not found';
2680 print
'<div class="tabsAction">';
2682 if ($action !=
'create' && $action !=
'edit' && $action !=
'editline') {
2684 $object->fetch($id, $ref);
2687 if (empty($user->socid)) {
2690 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>';
2702 if (in_array($object->fk_user_author, $user->getAllChildIds(1)) || !empty($user->rights->expensereport->writeall_advance)) {
2704 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>';
2707 if (count($object->lines) > 0) {
2708 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>';
2719 if ($user->id == $object->fk_user_author || $user->id == $object->fk_user_valid) {
2721 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>';
2726 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>';
2731 if ($user->id == $object->fk_user_author || $user->id == $object->fk_user_valid) {
2733 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>';
2743 if (in_array($object->fk_user_author, $user->getAllChildIds(1))) {
2745 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>';
2753 print
'<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER[
"PHP_SELF"].
'?action=validate&id='.$object->id.
'">'.$langs->trans(
'Approve').
'</a></div>';
2755 print
'<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER[
"PHP_SELF"].
'?action=refuse&id='.$object->id.
'">'.$langs->trans(
'Deny').
'</a></div>';
2758 if ($user->id == $object->fk_user_author || $user->id == $object->fk_user_valid) {
2760 print
'<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER[
"PHP_SELF"].
'?action=cancel&id='.$object->id.
'">'.$langs->trans(
"Cancel").
'</a></div>';
2769 print
'<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER[
"PHP_SELF"].
'?action=refuse&id='.$object->id.
'">'.$langs->trans(
'Deny').
'</a></div>';
2775 if ($remaintopay == 0) {
2776 print
'<div class="inline-block divButAction"><span class="butActionRefused classfortooltip" title="'.$langs->trans(
"DisabledBecauseRemainderToPayIsZero").
'">'.$langs->trans(
'DoPayment').
'</span></div>';
2778 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>';
2785 if ($object->paid == 0) {
2786 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>";
2790 if ($user->rights->expensereport->creer && ($user->id == $object->fk_user_author || $user->id == $object->fk_user_valid) && $object->status ==
ExpenseReport::STATUS_APPROVED) {
2792 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>';
2796 if (($user->rights->expensereport->approve || $user->rights->expensereport->to_paid) && $object->status ==
ExpenseReport::STATUS_CLOSED) {
2798 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>';
2803 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>';
2807 if ($user->rights->expensereport->creer) {
2808 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>';
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 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>';
2821 $reshook = $hookmanager->executeHooks(
'addMoreActionsButtons',
$parameters, $object, $action);
2828 if (
GETPOST(
'modelselected',
'alpha')) {
2829 $action =
'presend';
2832 if ($action !=
'presend') {
2837 print
'<div class="fichecenter"><div class="fichehalfleft">';
2838 print
'<a name="builddoc"></a>';
2840 if ($user->rights->expensereport->creer && $action !=
'create' && $action !=
'edit') {
2843 $urlsource = $_SERVER[
"PHP_SELF"].
"?id=".$object->id;
2844 $genallowed = $user->rights->expensereport->creer;
2845 $delallowed = $user->rights->expensereport->creer;
2847 print $formfile->showdocuments(
'expensereport', $filename, $filedir, $urlsource, $genallowed, $delallowed);
2848 $somethingshown = $formfile->numoffiles;
2860 print
'</div><div class="fichehalfright">';
2862 include_once DOL_DOCUMENT_ROOT.
'/core/class/html.formactions.class.php';
2864 $somethingshown =
$formactions->showactions($object,
'expensereport',
null);
2866 print
'</div></div>';
2870 $modelmail =
'expensereport';
2871 $defaulttopic =
'SendExpenseReportRef';
2872 $diroutput = $conf->expensereport->dir_output;
2873 $trackid =
'exp'.$object->id;
2875 include DOL_DOCUMENT_ROOT.
'/core/tpl/card_presend.tpl.php';
if(GETPOST('button_removefilter_x', 'alpha')||GETPOST('button_removefilter.x', 'alpha')||GETPOST('button_removefilter', 'alpha')) if(GETPOST('button_search_x', 'alpha')||GETPOST('button_search.x', 'alpha')||GETPOST('button_search', 'alpha')) if($action=="save" &&empty($cancel)) $help_url
View.
if(preg_match('/set_([a-z0-9_\-]+)/i', $action, $reg)) if(preg_match('/del_([a-z0-9_\-]+)/i', $action, $reg)) if($action=='set') elseif($action=='specimen') elseif($action=='setmodel') elseif($action=='del') elseif($action=='setdoc') $formactions
View.
if(!defined('NOREQUIRESOC')) if(!defined('NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined('NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined('NOREQUIREAJAX')) llxHeader()
Empty header.
Class to manage bank accounts.
Class to manage accounting accounts.
Class to manage accounting journals.
Class to send emails (with attachments or not) Usage: $mailfile = new CMailFile($subject,...
Class to manage a WYSIWYG editor.
Class to manage ECM files.
fetch($id, $ref='', $relativepath='', $hashoffile='', $hashforshare='', $src_object_type='', $src_object_id=0)
Load object in memory from the database.
Class to manage Trips and Expenses.
const STATUS_DRAFT
Draft status.
const STATUS_APPROVED
Classified approved.
const STATUS_CANCELED
Classified canceled.
const STATUS_CLOSED
Classified paid.
const STATUS_REFUSED
Classified refused.
const STATUS_VALIDATED
Validated (need to be paid)
Class of expense report details lines.
static count($dbs, $objecttype, $objectid)
Return nb of links.
Class to manage payments of expense report.
Class to manage projects.
Class to manage translations.
Class to manage Dolibarr users.
if(isModEnabled('facture') && $user->hasRight('facture', 'lire')) if((isModEnabled('fournisseur') &&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) && $user->hasRight("fournisseur", "facture", "lire"))||(isModEnabled('supplier_invoice') && $user->hasRight("supplier_invoice", "lire"))) if(isModEnabled('don') && $user->hasRight('don', 'lire')) if(isModEnabled('tax') &&!empty($user->rights->tax->charges->lire)) if(isModEnabled('facture') &&isModEnabled('commande') && $user->hasRight("commande", "lire") &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) $sql
Social contributions to pay.
if($cancel &&! $id) if($action=='add' &&! $cancel) if($action=='delete') if($id) $form
Actions.
expensereport_prepare_head($object)
Prepare array with list of tabs.
dol_convert_file($fileinput, $ext='png', $fileoutput='', $page='')
Convert an image file or a PDF into another image format.
dol_is_file($pathoffile)
Return if path is a file.
dol_dir_list($path, $types="all", $recursive=0, $filter="", $excludefilter=null, $sortcriteria="name", $sortorder=SORT_ASC, $mode=0, $nohook=0, $relativename="", $donotfollowsymlinks=0, $nbsecondsold=0)
Scan a directory and return a list of files/directories.
dol_banner_tab($object, $paramid, $morehtml='', $shownav=1, $fieldid='rowid', $fieldref='ref', $morehtmlref='', $moreparam='', $nodbprefix=0, $morehtmlleft='', $morehtmlstatus='', $onlybanner=0, $morehtmlright='')
Show tab footer of a card.
dol_mktime($hour, $minute, $second, $month, $day, $year, $gm='auto', $check=1)
Return a timestamp date built from detailed informations (by default a local PHP server timestamp) Re...
load_fiche_titre($titre, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
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_getIdFromCode($db, $key, $tablename, $fieldkey='code', $fieldid='id', $entityfilter=0, $filters='')
Return an id or code from a code or id.
newToken()
Return the value of token currently saved into session with name 'newtoken'.
dol_clone($object, $native=0)
Create a clone of instance of object (new instance with same value for each properties) With native =...
getImageFileNameForSize($file, $extName, $extImgTarget='')
Return the filename of file to get the thumbs.
getAdvancedPreviewUrl($modulepart, $relativepath, $alldata=0, $param='')
Return URL we can use for advanced preview links.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
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.
GETPOSTISSET($paramname)
Return true if we are in a context of submitting the parameter $paramname from a POST of a form.
isValidEmail($address, $acceptsupervisorkey=0, $acceptuserkey=0)
Return true if email syntax is ok.
isModEnabled($module)
Is Dolibarr module enabled.
img_edit($titlealt='default', $float=0, $other='')
Show logo editer/modifier fiche.
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.
$formconfirm
if ($action == 'delbookkeepingyear') {
restrictedArea(User $user, $features, $object=0, $tableandshare='', $feature2='', $dbt_keyfield='fk_soc', $dbt_select='rowid', $isdraft=0, $mode=0)
Check permissions of a user to show a page and an object.
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.