29require
'../../main.inc.php';
30require_once DOL_DOCUMENT_ROOT.
'/core/lib/trip.lib.php';
31require_once DOL_DOCUMENT_ROOT.
'/compta/deplacement/class/deplacement.class.php';
32require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formfile.class.php';
33if (isModEnabled(
'project')) {
34 require_once DOL_DOCUMENT_ROOT.
'/projet/class/project.class.php';
44 $socid = $user->socid;
48$action =
GETPOST(
'action',
'aZ09');
49$confirm =
GETPOST(
'confirm',
'alpha');
54$hookmanager->initHooks(array(
'tripsandexpensescard',
'globalcard'));
56$permissionnote = $user->hasRight(
'deplacement',
'creer');
63include DOL_DOCUMENT_ROOT.
'/core/actions_setnotes.inc.php';
65if ($action ==
'validate' && $user->hasRight(
'deplacement',
'creer')) {
68 $result =
$object->setStatut(1);
70 header(
"Location: ".$_SERVER[
"PHP_SELF"].
"?id=".$id);
76} elseif ($action ==
'classifyrefunded' && $user->hasRight(
'deplacement',
'creer')) {
81 header(
"Location: ".$_SERVER[
"PHP_SELF"].
"?id=".$id);
87} elseif ($action ==
'confirm_delete' && $confirm ==
"yes" && $user->hasRight(
'deplacement',
'supprimer')) {
88 $result =
$object->delete($user);
90 header(
"Location: index.php");
95} elseif ($action ==
'add' && $user->hasRight(
'deplacement',
'creer')) {
96 if (!
GETPOST(
'cancel',
'alpha')) {
109 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Date")),
null,
'errors');
113 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Type")),
null,
'errors');
117 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Person")),
null,
'errors');
125 header(
"Location: ".$_SERVER[
"PHP_SELF"].
"?id=".$id);
135 header(
"Location: index.php");
138} elseif ($action ==
'update' && $user->hasRight(
'deplacement',
'creer')) {
140 if (!
GETPOST(
'cancel',
'alpha')) {
151 $result =
$object->update($user);
154 header(
"Location: ".$_SERVER[
"PHP_SELF"].
"?id=".$id);
160 header(
"Location: ".$_SERVER[
"PHP_SELF"].
"?id=".$id);
163} elseif ($action ==
'classin' && $user->hasRight(
'deplacement',
'creer')) {
170} elseif ($action ==
'setdated' && $user->hasRight(
'deplacement',
'creer')) {
174 $result =
$object->setValueFrom(
'dated', $dated,
'',
'',
'date',
'', $user,
'DEPLACEMENT_MODIFY');
178} elseif ($action ==
'setkm' && $user->hasRight(
'deplacement',
'creer')) {
180 $result =
$object->setValueFrom(
'km',
GETPOSTINT(
'km'),
'',
null,
'text',
'', $user,
'DEPLACEMENT_MODIFY');
193$form =
new Form($db);
198if ($action ==
'create') {
200 require_once DOL_DOCUMENT_ROOT.
'/core/class/doleditor.class.php';
206 print
'<form name="add" action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">'.
"\n";
207 print
'<input type="hidden" name="token" value="'.newToken().
'">';
208 print
'<input type="hidden" name="action" value="add">';
210 print
'<table class="border centpercent">';
213 print
'<td class="fieldrequired">'.$langs->trans(
"Type").
'</td><td>';
214 $form->select_type_fees(
GETPOSTINT(
'type'),
'type', 1);
218 print
'<td class="fieldrequired">'.$langs->trans(
"Person").
'</td><td>';
219 print $form->select_dolusers(
GETPOSTINT(
'fk_user'),
'fk_user', 1,
'', 0,
'',
'', 0, 0, 0,
'', 0,
'',
'maxwidth300');
223 print
'<td class="fieldrequired">'.$langs->trans(
"Date").
'</td><td>';
224 print $form->selectDate($datec ? $datec : -1,
'', 0, 0, 0,
'add', 1, 1);
228 print
'<tr><td class="fieldrequired">'.$langs->trans(
"FeesKilometersOrAmout").
'</td><td><input name="km" size="10" value="'.
GETPOST(
"km").
'"></td></tr>';
232 print
'<td>'.$langs->trans(
"CompanyVisited").
'</td><td>';
233 print $form->select_company(
GETPOSTINT(
'socid'),
'socid',
'', 1);
238 print
'<td class="tdtop">'.$langs->trans(
'NotePublic').
'</td>';
241 $doleditor =
new DolEditor(
'note_public',
GETPOST(
'note_public',
'restricthtml'),
'', 200,
'dolibarr_notes',
'In',
false,
true, !
getDolGlobalString(
'FCKEDITOR_ENABLE_NOTE_PUBLIC') ? 0 : 1, ROWS_8,
'90%');
242 print $doleditor->Create(1);
247 if (empty($user->socid)) {
249 print
'<td class="tdtop">'.$langs->trans(
'NotePrivate').
'</td>';
252 $doleditor =
new DolEditor(
'note_private',
GETPOST(
'note_private',
'restricthtml'),
'', 200,
'dolibarr_notes',
'In',
false,
true, !
getDolGlobalString(
'FCKEDITOR_ENABLE_NOTE_PRIVATE') ? 0 : 1, ROWS_8,
'90%');
253 print $doleditor->Create(1);
259 $parameters = array();
260 $reshook = $hookmanager->executeHooks(
'formObjectOptions', $parameters,
$object, $action);
261 print $hookmanager->resPrint;
265 print
'<br><div class="center">';
266 print
'<input class="button button-save" type="submit" value="'.$langs->trans(
"Save").
'">';
267 print
' ';
268 print
'<input class="button button-cancel" type="submit" name="cancel" value="'.$langs->trans(
"Cancel").
'">';
279 if ($action ==
'edit' && $user->hasRight(
'deplacement',
'creer')) {
281 require_once DOL_DOCUMENT_ROOT.
'/core/class/doleditor.class.php';
288 print
'<form name="update" action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">'.
"\n";
289 print
'<input type="hidden" name="token" value="'.newToken().
'">';
290 print
'<input type="hidden" name="action" value="update">';
291 print
'<input type="hidden" name="id" value="'.$id.
'">';
293 print
'<table class="border centpercent">';
297 print
'<td class="titlefield">'.$langs->trans(
"Ref").
'</td><td>';
303 print
'<td class="fieldrequired">'.$langs->trans(
"Type").
'</td><td>';
309 print
'<td class="fieldrequired">'.$langs->trans(
"Person").
'</td><td>';
310 print $form->select_dolusers(
GETPOSTINT(
'fk_user') ?
GETPOSTINT(
'fk_user') :
$object->fk_user,
'fk_user', 0,
'', 0,
'',
'', 0, 0, 0,
'', 0,
'',
'maxwidth300');
314 print
'<tr><td class="fieldrequired">'.$langs->trans(
"Date").
'</td><td>';
315 print $form->selectDate(
$object->date,
'', 0, 0, 0,
'update', 1, 0);
319 print
'<tr><td class="fieldrequired">'.$langs->trans(
"FeesKilometersOrAmout").
'</td><td>';
320 print
'<input name="km" class="flat" size="10" value="'.$object->km.
'">';
325 print
'<td>'.$langs->trans(
"CompanyVisited").
'</td><td>';
326 print $form->select_company($soc->id,
'socid',
'', 1);
330 print
'<tr><td class="tdtop">'.$langs->trans(
"NotePublic").
'</td>';
333 $doleditor =
new DolEditor(
'note_public',
$object->note_public,
'', 200,
'dolibarr_notes',
'In',
false,
true, !
getDolGlobalString(
'FCKEDITOR_ENABLE_NOTE_PUBLIC') ? 0 : 1, ROWS_8,
'90%');
334 print $doleditor->Create(1);
339 if (empty($user->socid)) {
340 print
'<tr><td class="tdtop">'.$langs->trans(
"NotePrivate").
'</td>';
343 $doleditor =
new DolEditor(
'note_private',
$object->note_private,
'', 200,
'dolibarr_notes',
'In',
false,
true, !
getDolGlobalString(
'FCKEDITOR_ENABLE_NOTE_PRIVATE') ? 0 : 1, ROWS_8,
'90%');
344 print $doleditor->Create(1);
350 $parameters = array();
351 $reshook = $hookmanager->executeHooks(
'formObjectOptions', $parameters,
$object, $action);
352 print $hookmanager->resPrint;
356 print
'<br><div class="center">';
357 print
'<input type="submit" class="button button-save" value="'.$langs->trans(
"Save").
'">';
358 print
' ';
359 print
'<input type="submit" name="cancel" class="button button-cancel" value="'.$langs->trans(
"Cancel").
'">';
369 if ($action ==
'delete') {
370 print $form->formconfirm($_SERVER[
"PHP_SELF"].
"?id=".urlencode((
string) ($id)), $langs->trans(
"DeleteTrip"), $langs->trans(
"ConfirmDeleteTrip"),
"confirm_delete");
378 print
'<table class="border centpercent">';
380 $linkback =
'<a href="'.DOL_URL_ROOT.
'/compta/deplacement/list.php'.(!empty($socid) ?
'?socid='.$socid :
'').
'">'.$langs->trans(
"BackToList").
'</a>';
383 print
'<tr><td width="25%">'.$langs->trans(
"Ref").
'</td><td>';
384 print $form->showrefnav(
$object,
'id', $linkback, 1,
'rowid',
'ref',
'');
387 $form->load_cache_types_fees();
391 print $form->editfieldkey(
"Type",
'type', $langs->trans(
$object->type),
$object, $user->hasRight(
'deplacement',
'creer'),
'select:types_fees');
393 print $form->editfieldval(
"Type",
'type', $form->cache_types_fees[
$object->type],
$object, $user->hasRight(
'deplacement',
'creer'),
'select:types_fees');
397 print
'<tr><td>'.$langs->trans(
"Person").
'</td><td>';
398 $userfee =
new User($db);
399 $userfee->fetch(
$object->fk_user);
400 print $userfee->getNomUrl(1);
405 print $form->editfieldkey(
"Date",
'dated',
$object->date,
$object, $user->hasRight(
'deplacement',
'creer'),
'datepicker');
407 print $form->editfieldval(
"Date",
'dated',
$object->date,
$object, $user->hasRight(
'deplacement',
'creer'),
'datepicker');
411 print
'<tr><td class="tdtop">';
412 print $form->editfieldkey(
"FeesKilometersOrAmout",
'km',
$object->km,
$object, $user->hasRight(
'deplacement',
'creer'),
'numeric:6');
414 print $form->editfieldval(
"FeesKilometersOrAmout",
'km',
$object->km,
$object, $user->hasRight(
'deplacement',
'creer'),
'numeric:6');
418 print
'<tr><td>'.$langs->trans(
"CompanyVisited").
'</td>';
421 print $soc->getNomUrl(1);
426 if (isModEnabled(
'project')) {
427 $langs->load(
'projects');
431 print
'<table class="nobordernopadding" width="100%"><tr><td>';
432 print $langs->trans(
'Project');
434 if ($action !=
'classify' && $user->hasRight(
'deplacement',
'creer')) {
435 print
'<td class="right"><a href="'.$_SERVER[
"PHP_SELF"].
'?action=classify&token='.
newToken().
'&id='.
$object->id.
'">';
436 print
img_edit($langs->trans(
'SetProject'), 1);
439 print
'</tr></table>';
440 print
'</td><td colspan="3">';
441 if ($action ==
'classify') {
442 $form->form_project($_SERVER[
'PHP_SELF'].
'?id='.
$object->id,
$object->socid,
$object->fk_project,
'projectid', 0, 0, 1);
444 $form->form_project($_SERVER[
'PHP_SELF'].
'?id='.
$object->id,
$object->socid,
$object->fk_project,
'none', 0, 0);
451 print
'<tr><td>'.$langs->trans(
"Status").
'</td><td>'.
$object->getLibStatut(4).
'</td></tr>';
454 $parameters = array(
'socid' =>
$object->id);
455 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_view.tpl.php';
457 print
"</table><br>";
461 $title = $langs->trans(
'Notes');
462 include DOL_DOCUMENT_ROOT.
'/core/tpl/bloc_showhide.tpl.php';
469 print
'<div class="tabsAction">';
472 if ($user->hasRight(
'deplacement',
'creer')) {
473 print
'<a class="butAction" href="'.$_SERVER[
"PHP_SELF"].
'?action=edit&token='.
newToken().
'&id='.$id.
'">'.$langs->trans(
'Modify').
'</a>';
475 print
'<a class="butActionRefused classfortooltip" href="#" title="'.dol_escape_htmltag($langs->trans(
"NotAllowed")).
'">'.$langs->trans(
'Modify').
'</a>';
480 if ($user->hasRight(
'deplacement',
'creer')) {
481 print
'<a class="butAction" href="'.$_SERVER[
"PHP_SELF"].
'?action=validate&id='.$id.
'">'.$langs->trans(
'Validate').
'</a>';
483 print
'<a class="butActionRefused classfortooltip" href="#" title="'.dol_escape_htmltag($langs->trans(
"NotAllowed")).
'">'.$langs->trans(
'Validate').
'</a>';
488 if ($user->hasRight(
'deplacement',
'creer')) {
489 print
'<a class="butAction" href="'.$_SERVER[
"PHP_SELF"].
'?action=classifyrefunded&token='.
newToken().
'&id='.$id.
'">'.$langs->trans(
'ClassifyRefunded').
'</a>';
491 print
'<a class="butActionRefused classfortooltip" href="#" title="'.dol_escape_htmltag($langs->trans(
"NotAllowed")).
'">'.$langs->trans(
'ClassifyRefunded').
'</a>';
495 $permissiontodelete = $user->hasRight(
'deplacement',
'supprimer');
496 print
dolGetButtonAction($langs->trans(
"Delete"),
'',
'delete', $_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&action=delete&token='.
newToken(),
'delete', $permissiontodelete);
if( $user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $object
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader()
Empty header.
Class to manage trips and working credit notes.
const STATUS_DRAFT
Draft status.
const STATUS_REFUNDED
Refunded status.
const STATUS_VALIDATED
Validated status.
Class to manage a WYSIWYG editor.
Class to manage third parties objects (customers, suppliers, prospects...)
Class to manage Dolibarr users.
dol_mktime($hour, $minute, $second, $month, $day, $year, $gm='auto', $check=1)
Return a timestamp date built from detailed information (by default a local PHP server timestamp) Rep...
load_fiche_titre($title, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
GETPOSTINT($paramname, $method=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='', $dragdropfile=0)
Show tabs of a record.
price2num($amount, $rounding='', $option=0)
Function that return a number with universal decimal format (decimal separator is '.
newToken()
Return the value of token currently saved into session with name 'newtoken'.
dolGetButtonAction($label, $text='', $actionType='default', $url='', $id='', $userRight=1, $params=array())
Function dolGetButtonAction.
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_print_error($db=null, $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
getDolGlobalString($key, $default='')
Return dolibarr global constant string value.
img_edit($titlealt='default', $float=0, $other='')
Show logo edit/modify fiche.
if(preg_match('/crypted:/i', $dolibarr_main_db_pass)||!empty($dolibarr_main_db_encrypted_pass)) $conf db type
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.
trip_prepare_head(Deplacement $object)
Prepare array with list of tabs.