30require
'../../main.inc.php';
31require_once DOL_DOCUMENT_ROOT.
'/core/lib/trip.lib.php';
32require_once DOL_DOCUMENT_ROOT.
'/compta/deplacement/class/deplacement.class.php';
33require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formfile.class.php';
34if (isModEnabled(
'project')) {
35 require_once DOL_DOCUMENT_ROOT.
'/projet/class/project.class.php';
45 $socid = $user->socid;
49$hookmanager->initHooks(array(
'tripsandexpensescard',
'globalcard'));
53$action =
GETPOST(
'action',
'aZ09');
54$confirm =
GETPOST(
'confirm',
'alpha');
58$permissionnote = $user->hasRight(
'deplacement',
'creer');
65include DOL_DOCUMENT_ROOT.
'/core/actions_setnotes.inc.php';
67if ($action ==
'validate' && $user->hasRight(
'deplacement',
'creer')) {
70 $result =
$object->setStatut(1);
72 header(
"Location: ".$_SERVER[
"PHP_SELF"].
"?id=".$id);
78} elseif ($action ==
'classifyrefunded' && $user->hasRight(
'deplacement',
'creer')) {
83 header(
"Location: ".$_SERVER[
"PHP_SELF"].
"?id=".$id);
89} elseif ($action ==
'confirm_delete' && $confirm ==
"yes" && $user->hasRight(
'deplacement',
'supprimer')) {
90 $result =
$object->delete($user);
92 header(
"Location: index.php");
97} elseif ($action ==
'add' && $user->hasRight(
'deplacement',
'creer')) {
98 if (!
GETPOST(
'cancel',
'alpha')) {
111 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Date")),
null,
'errors');
115 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Type")),
null,
'errors');
119 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Person")),
null,
'errors');
127 header(
"Location: ".$_SERVER[
"PHP_SELF"].
"?id=".$id);
137 header(
"Location: index.php");
140} elseif ($action ==
'update' && $user->hasRight(
'deplacement',
'creer')) {
142 if (!
GETPOST(
'cancel',
'alpha')) {
153 $result =
$object->update($user);
156 header(
"Location: ".$_SERVER[
"PHP_SELF"].
"?id=".$id);
162 header(
"Location: ".$_SERVER[
"PHP_SELF"].
"?id=".$id);
165} elseif ($action ==
'classin' && $user->hasRight(
'deplacement',
'creer')) {
172} elseif ($action ==
'setdated' && $user->hasRight(
'deplacement',
'creer')) {
176 $result =
$object->setValueFrom(
'dated', $dated,
'',
null,
'date',
'', $user,
'DEPLACEMENT_MODIFY');
180} elseif ($action ==
'setkm' && $user->hasRight(
'deplacement',
'creer')) {
182 $result =
$object->setValueFrom(
'km',
GETPOSTINT(
'km'),
'',
null,
'text',
'', $user,
'DEPLACEMENT_MODIFY');
195$form =
new Form($db);
200if ($action ==
'create') {
202 require_once DOL_DOCUMENT_ROOT.
'/core/class/doleditor.class.php';
208 print
'<form name="add" action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">'.
"\n";
209 print
'<input type="hidden" name="token" value="'.newToken().
'">';
210 print
'<input type="hidden" name="action" value="add">';
212 print
'<table class="border centpercent">';
215 print
'<td class="fieldrequired">'.$langs->trans(
"Type").
'</td><td>';
216 $form->select_type_fees(
GETPOSTINT(
'type'),
'type', 1);
220 print
'<td class="fieldrequired">'.$langs->trans(
"Person").
'</td><td>';
221 print $form->select_dolusers(
GETPOSTINT(
'fk_user'),
'fk_user', 1,
'', 0,
'',
'', 0, 0, 0,
'', 0,
'',
'maxwidth300');
225 print
'<td class="fieldrequired">'.$langs->trans(
"Date").
'</td><td>';
226 print $form->selectDate($datec ? $datec : -1,
'', 0, 0, 0,
'add', 1, 1);
230 print
'<tr><td class="fieldrequired">'.$langs->trans(
"FeesKilometersOrAmout").
'</td><td><input name="km" size="10" value="'.
GETPOST(
"km").
'"></td></tr>';
234 print
'<td>'.$langs->trans(
"CompanyVisited").
'</td><td>';
235 print $form->select_company(
GETPOSTINT(
'socid'),
'socid',
'', 1);
240 print
'<td class="tdtop">'.$langs->trans(
'NotePublic').
'</td>';
243 $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%');
244 print $doleditor->Create(1);
249 if (empty($user->socid)) {
251 print
'<td class="tdtop">'.$langs->trans(
'NotePrivate').
'</td>';
254 $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%');
255 print $doleditor->Create(1);
261 $parameters = array();
262 $reshook = $hookmanager->executeHooks(
'formObjectOptions', $parameters,
$object, $action);
263 print $hookmanager->resPrint;
267 print
'<br><div class="center">';
268 print
'<input class="button button-save" type="submit" value="'.$langs->trans(
"Save").
'">';
269 print
' ';
270 print
'<input class="button button-cancel" type="submit" name="cancel" value="'.$langs->trans(
"Cancel").
'">';
281 if ($action ==
'edit' && $user->hasRight(
'deplacement',
'creer')) {
283 require_once DOL_DOCUMENT_ROOT.
'/core/class/doleditor.class.php';
290 print
'<form name="update" action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">'.
"\n";
291 print
'<input type="hidden" name="token" value="'.newToken().
'">';
292 print
'<input type="hidden" name="action" value="update">';
293 print
'<input type="hidden" name="id" value="'.$id.
'">';
295 print
'<table class="border centpercent">';
299 print
'<td class="titlefield">'.$langs->trans(
"Ref").
'</td><td>';
305 print
'<td class="fieldrequired">'.$langs->trans(
"Type").
'</td><td>';
311 print
'<td class="fieldrequired">'.$langs->trans(
"Person").
'</td><td>';
312 print $form->select_dolusers(
GETPOSTINT(
'fk_user') ?
GETPOSTINT(
'fk_user') :
$object->fk_user,
'fk_user', 0,
'', 0,
'',
'', 0, 0, 0,
'', 0,
'',
'maxwidth300');
316 print
'<tr><td class="fieldrequired">'.$langs->trans(
"Date").
'</td><td>';
317 print $form->selectDate(
$object->date,
'', 0, 0, 0,
'update', 1, 0);
321 print
'<tr><td class="fieldrequired">'.$langs->trans(
"FeesKilometersOrAmout").
'</td><td>';
322 print
'<input name="km" class="flat" size="10" value="'.$object->km.
'">';
327 print
'<td>'.$langs->trans(
"CompanyVisited").
'</td><td>';
328 print $form->select_company($soc->id,
'socid',
'', 1);
332 print
'<tr><td class="tdtop">'.$langs->trans(
"NotePublic").
'</td>';
335 $doleditor =
new DolEditor(
'note_public',
$object->note_public,
'', 200,
'dolibarr_notes',
'In',
false,
true, !
getDolGlobalString(
'FCKEDITOR_ENABLE_NOTE_PUBLIC') ? 0 : 1, ROWS_8,
'90%');
336 print $doleditor->Create(1);
341 if (empty($user->socid)) {
342 print
'<tr><td class="tdtop">'.$langs->trans(
"NotePrivate").
'</td>';
345 $doleditor =
new DolEditor(
'note_private',
$object->note_private,
'', 200,
'dolibarr_notes',
'In',
false,
true, !
getDolGlobalString(
'FCKEDITOR_ENABLE_NOTE_PRIVATE') ? 0 : 1, ROWS_8,
'90%');
346 print $doleditor->Create(1);
352 $parameters = array();
353 $reshook = $hookmanager->executeHooks(
'formObjectOptions', $parameters,
$object, $action);
354 print $hookmanager->resPrint;
358 print
'<br><div class="center">';
359 print
'<input type="submit" class="button button-save" value="'.$langs->trans(
"Save").
'">';
360 print
' ';
361 print
'<input type="submit" name="cancel" class="button button-cancel" value="'.$langs->trans(
"Cancel").
'">';
371 if ($action ==
'delete') {
372 print $form->formconfirm($_SERVER[
"PHP_SELF"].
"?id=".urlencode((
string) ($id)), $langs->trans(
"DeleteTrip"), $langs->trans(
"ConfirmDeleteTrip"),
"confirm_delete");
380 print
'<table class="border centpercent">';
382 $linkback =
'<a href="'.DOL_URL_ROOT.
'/compta/deplacement/list.php'.(!empty($socid) ?
'?socid='.$socid :
'').
'">'.$langs->trans(
"BackToList").
'</a>';
385 print
'<tr><td width="25%">'.$langs->trans(
"Ref").
'</td><td>';
386 print $form->showrefnav(
$object,
'id', $linkback, 1,
'rowid',
'ref',
'');
389 $form->load_cache_types_fees();
393 print $form->editfieldkey(
"Type",
'type', $langs->trans(
$object->type),
$object, $user->hasRight(
'deplacement',
'creer'),
'select:types_fees');
395 print $form->editfieldval(
"Type",
'type', $form->cache_types_fees[
$object->type],
$object, $user->hasRight(
'deplacement',
'creer'),
'select:types_fees');
399 print
'<tr><td>'.$langs->trans(
"Person").
'</td><td>';
400 $userfee =
new User($db);
401 $userfee->fetch(
$object->fk_user);
402 print $userfee->getNomUrl(1);
407 print $form->editfieldkey(
"Date",
'dated',
$object->date,
$object, $user->hasRight(
'deplacement',
'creer'),
'datepicker');
409 print $form->editfieldval(
"Date",
'dated',
$object->date,
$object, $user->hasRight(
'deplacement',
'creer'),
'datepicker');
413 print
'<tr><td class="tdtop">';
414 print $form->editfieldkey(
"FeesKilometersOrAmout",
'km',
$object->km,
$object, $user->hasRight(
'deplacement',
'creer'),
'numeric:6');
416 print $form->editfieldval(
"FeesKilometersOrAmout",
'km',
$object->km,
$object, $user->hasRight(
'deplacement',
'creer'),
'numeric:6');
420 print
'<tr><td>'.$langs->trans(
"CompanyVisited").
'</td>';
423 print $soc->getNomUrl(1);
428 if (isModEnabled(
'project')) {
429 $langs->load(
'projects');
433 print
'<table class="nobordernopadding" width="100%"><tr><td>';
434 print $langs->trans(
'Project');
436 if ($action !=
'classify' && $user->hasRight(
'deplacement',
'creer')) {
437 print
'<td class="right"><a href="'.$_SERVER[
"PHP_SELF"].
'?action=classify&token='.
newToken().
'&id='.
$object->id.
'">';
438 print
img_edit($langs->trans(
'SetProject'), 1);
441 print
'</tr></table>';
442 print
'</td><td colspan="3">';
443 if ($action ==
'classify') {
444 $form->form_project($_SERVER[
'PHP_SELF'].
'?id='.
$object->id,
$object->socid,
$object->fk_project,
'projectid', 0, 0, 1);
446 $form->form_project($_SERVER[
'PHP_SELF'].
'?id='.
$object->id,
$object->socid,
$object->fk_project,
'none', 0, 0);
453 print
'<tr><td>'.$langs->trans(
"Status").
'</td><td>'.
$object->getLibStatut(4).
'</td></tr>';
456 $parameters = array(
'socid' =>
$object->id);
457 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_view.tpl.php';
459 print
"</table><br>";
463 $title = $langs->trans(
'Notes');
464 include DOL_DOCUMENT_ROOT.
'/core/tpl/bloc_showhide.tpl.php';
471 print
'<div class="tabsAction">';
474 if ($user->hasRight(
'deplacement',
'creer')) {
475 print
'<a class="butAction" href="'.$_SERVER[
"PHP_SELF"].
'?action=edit&token='.
newToken().
'&id='.
$id.
'">'.$langs->trans(
'Modify').
'</a>';
477 print
'<a class="butActionRefused classfortooltip" href="#" title="'.dol_escape_htmltag($langs->trans(
"NotAllowed")).
'">'.$langs->trans(
'Modify').
'</a>';
482 if ($user->hasRight(
'deplacement',
'creer')) {
483 print
'<a class="butAction" href="'.$_SERVER[
"PHP_SELF"].
'?action=validate&id='.
$id.
'">'.$langs->trans(
'Validate').
'</a>';
485 print
'<a class="butActionRefused classfortooltip" href="#" title="'.dol_escape_htmltag($langs->trans(
"NotAllowed")).
'">'.$langs->trans(
'Validate').
'</a>';
490 if ($user->hasRight(
'deplacement',
'creer')) {
491 print
'<a class="butAction" href="'.$_SERVER[
"PHP_SELF"].
'?action=classifyrefunded&token='.
newToken().
'&id='.
$id.
'">'.$langs->trans(
'ClassifyRefunded').
'</a>';
493 print
'<a class="butActionRefused classfortooltip" href="#" title="'.dol_escape_htmltag($langs->trans(
"NotAllowed")).
'">'.$langs->trans(
'ClassifyRefunded').
'</a>';
497 $permissiontodelete = $user->hasRight(
'deplacement',
'supprimer');
498 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($head='', $title='', $help_url='', $target='', $disablejs=0, $disablehead=0, $arrayofjs='', $arrayofcss='', $morequerystring='', $morecssonbody='', $replacemainareaby='', $disablenofollow=0, $disablenoindex=0)
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.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0, $attop=0)
Set event messages in dol_events session object.
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.
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 a 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.