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';
53 $socid = $user->socid;
57$hookmanager->initHooks(array(
'tripsandexpensescard',
'globalcard'));
61$action =
GETPOST(
'action',
'aZ09');
62$confirm =
GETPOST(
'confirm',
'alpha');
66$permissionnote = $user->hasRight(
'deplacement',
'creer');
73include DOL_DOCUMENT_ROOT.
'/core/actions_setnotes.inc.php';
75if ($action ==
'validate' && $user->hasRight(
'deplacement',
'creer')) {
78 $result =
$object->setStatut(1);
80 header(
"Location: ".$_SERVER[
"PHP_SELF"].
"?id=".$id);
86} elseif ($action ==
'classifyrefunded' && $user->hasRight(
'deplacement',
'creer')) {
91 header(
"Location: ".$_SERVER[
"PHP_SELF"].
"?id=".$id);
97} elseif ($action ==
'confirm_delete' && $confirm ==
"yes" && $user->hasRight(
'deplacement',
'supprimer')) {
98 $result =
$object->delete($user);
100 header(
"Location: index.php");
105} elseif ($action ==
'add' && $user->hasRight(
'deplacement',
'creer')) {
106 if (!
GETPOST(
'cancel',
'alpha')) {
119 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Date")),
null,
'errors');
123 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Type")),
null,
'errors');
127 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Person")),
null,
'errors');
135 header(
"Location: ".$_SERVER[
"PHP_SELF"].
"?id=".$id);
145 header(
"Location: index.php");
148} elseif ($action ==
'update' && $user->hasRight(
'deplacement',
'creer')) {
150 if (!
GETPOST(
'cancel',
'alpha')) {
161 $result =
$object->update($user);
164 header(
"Location: ".$_SERVER[
"PHP_SELF"].
"?id=".$id);
170 header(
"Location: ".$_SERVER[
"PHP_SELF"].
"?id=".$id);
173} elseif ($action ==
'classin' && $user->hasRight(
'deplacement',
'creer')) {
180} elseif ($action ==
'setdated' && $user->hasRight(
'deplacement',
'creer')) {
184 $result =
$object->setValueFrom(
'dated', $dated,
'',
null,
'date',
'', $user,
'DEPLACEMENT_MODIFY');
188} elseif ($action ==
'setkm' && $user->hasRight(
'deplacement',
'creer')) {
190 $result =
$object->setValueFrom(
'km',
GETPOSTINT(
'km'),
'',
null,
'text',
'', $user,
'DEPLACEMENT_MODIFY');
203$form =
new Form($db);
208if ($action ==
'create') {
210 require_once DOL_DOCUMENT_ROOT.
'/core/class/doleditor.class.php';
216 print
'<form name="add" action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">'.
"\n";
217 print
'<input type="hidden" name="token" value="'.newToken().
'">';
218 print
'<input type="hidden" name="action" value="add">';
220 print
'<table class="border centpercent">';
223 print
'<td class="fieldrequired">'.$langs->trans(
"Type").
'</td><td>';
224 $form->select_type_fees(
GETPOSTINT(
'type'),
'type', 1);
228 print
'<td class="fieldrequired">'.$langs->trans(
"Person").
'</td><td>';
229 print $form->select_dolusers(
GETPOSTINT(
'fk_user'),
'fk_user', 1,
'', 0,
'',
'', 0, 0, 0,
'', 0,
'',
'maxwidth300');
233 print
'<td class="fieldrequired">'.$langs->trans(
"Date").
'</td><td>';
234 print $form->selectDate($datec ? $datec : -1,
'', 0, 0, 0,
'add', 1, 1);
238 print
'<tr><td class="fieldrequired">'.$langs->trans(
"FeesKilometersOrAmout").
'</td><td><input name="km" size="10" value="'.
GETPOST(
"km").
'"></td></tr>';
242 print
'<td>'.$langs->trans(
"CompanyVisited").
'</td><td>';
243 print $form->select_company(
GETPOSTINT(
'socid'),
'socid',
'', 1);
248 print
'<td class="tdtop">'.$langs->trans(
'NotePublic').
'</td>';
251 $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%');
252 print $doleditor->Create(1);
257 if (empty($user->socid)) {
259 print
'<td class="tdtop">'.$langs->trans(
'NotePrivate').
'</td>';
262 $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%');
263 print $doleditor->Create(1);
269 $parameters = array();
270 $reshook = $hookmanager->executeHooks(
'formObjectOptions', $parameters,
$object, $action);
271 print $hookmanager->resPrint;
275 print
'<br><div class="center">';
276 print
'<input class="button button-save" type="submit" value="'.$langs->trans(
"Save").
'">';
277 print
' ';
278 print
'<input class="button button-cancel" type="submit" name="cancel" value="'.$langs->trans(
"Cancel").
'">';
289 if ($action ==
'edit' && $user->hasRight(
'deplacement',
'creer')) {
291 require_once DOL_DOCUMENT_ROOT.
'/core/class/doleditor.class.php';
298 print
'<form name="update" action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">'.
"\n";
299 print
'<input type="hidden" name="token" value="'.newToken().
'">';
300 print
'<input type="hidden" name="action" value="update">';
301 print
'<input type="hidden" name="id" value="'.$id.
'">';
303 print
'<table class="border centpercent">';
307 print
'<td class="titlefield">'.$langs->trans(
"Ref").
'</td><td>';
313 print
'<td class="fieldrequired">'.$langs->trans(
"Type").
'</td><td>';
319 print
'<td class="fieldrequired">'.$langs->trans(
"Person").
'</td><td>';
320 print $form->select_dolusers(
GETPOSTINT(
'fk_user') ?
GETPOSTINT(
'fk_user') :
$object->fk_user,
'fk_user', 0,
'', 0,
'',
'', 0, 0, 0,
'', 0,
'',
'maxwidth300');
324 print
'<tr><td class="fieldrequired">'.$langs->trans(
"Date").
'</td><td>';
325 print $form->selectDate(
$object->date,
'', 0, 0, 0,
'update', 1, 0);
329 print
'<tr><td class="fieldrequired">'.$langs->trans(
"FeesKilometersOrAmout").
'</td><td>';
330 print
'<input name="km" class="flat" size="10" value="'.$object->km.
'">';
335 print
'<td>'.$langs->trans(
"CompanyVisited").
'</td><td>';
336 print $form->select_company($soc->id,
'socid',
'', 1);
340 print
'<tr><td class="tdtop">'.$langs->trans(
"NotePublic").
'</td>';
343 $doleditor =
new DolEditor(
'note_public',
$object->note_public,
'', 200,
'dolibarr_notes',
'In',
false,
true, !
getDolGlobalString(
'FCKEDITOR_ENABLE_NOTE_PUBLIC') ? 0 : 1, ROWS_8,
'90%');
344 print $doleditor->Create(1);
349 if (empty($user->socid)) {
350 print
'<tr><td class="tdtop">'.$langs->trans(
"NotePrivate").
'</td>';
353 $doleditor =
new DolEditor(
'note_private',
$object->note_private,
'', 200,
'dolibarr_notes',
'In',
false,
true, !
getDolGlobalString(
'FCKEDITOR_ENABLE_NOTE_PRIVATE') ? 0 : 1, ROWS_8,
'90%');
354 print $doleditor->Create(1);
360 $parameters = array();
361 $reshook = $hookmanager->executeHooks(
'formObjectOptions', $parameters,
$object, $action);
362 print $hookmanager->resPrint;
366 print
'<br><div class="center">';
367 print
'<input type="submit" class="button button-save" value="'.$langs->trans(
"Save").
'">';
368 print
' ';
369 print
'<input type="submit" name="cancel" class="button button-cancel" value="'.$langs->trans(
"Cancel").
'">';
379 if ($action ==
'delete') {
380 print $form->formconfirm($_SERVER[
"PHP_SELF"].
"?id=".urlencode((
string) ($id)), $langs->trans(
"DeleteTrip"), $langs->trans(
"ConfirmDeleteTrip"),
"confirm_delete");
388 print
'<table class="border centpercent">';
390 $linkback =
'<a href="'.DOL_URL_ROOT.
'/compta/deplacement/list.php'.(!empty($socid) ?
'?socid='.$socid :
'').
'">'.$langs->trans(
"BackToList").
'</a>';
393 print
'<tr><td width="25%">'.$langs->trans(
"Ref").
'</td><td>';
394 print $form->showrefnav(
$object,
'id', $linkback, 1,
'rowid',
'ref',
'');
397 $form->load_cache_types_fees();
401 print $form->editfieldkey(
"Type",
'type', $langs->trans(
$object->type),
$object, $user->hasRight(
'deplacement',
'creer'),
'select:types_fees');
403 print $form->editfieldval(
"Type",
'type', $form->cache_types_fees[
$object->type],
$object, $user->hasRight(
'deplacement',
'creer'),
'select:types_fees');
407 print
'<tr><td>'.$langs->trans(
"Person").
'</td><td>';
408 $userfee =
new User($db);
409 $userfee->fetch(
$object->fk_user);
410 print $userfee->getNomUrl(1);
415 print $form->editfieldkey(
"Date",
'dated',
$object->date,
$object, $user->hasRight(
'deplacement',
'creer'),
'datepicker');
417 print $form->editfieldval(
"Date",
'dated',
$object->date,
$object, $user->hasRight(
'deplacement',
'creer'),
'datepicker');
421 print
'<tr><td class="tdtop">';
422 print $form->editfieldkey(
"FeesKilometersOrAmout",
'km',
$object->km,
$object, $user->hasRight(
'deplacement',
'creer'),
'numeric:6');
424 print $form->editfieldval(
"FeesKilometersOrAmout",
'km',
$object->km,
$object, $user->hasRight(
'deplacement',
'creer'),
'numeric:6');
428 print
'<tr><td>'.$langs->trans(
"CompanyVisited").
'</td>';
431 print $soc->getNomUrl(1);
436 if (isModEnabled(
'project')) {
437 $langs->load(
'projects');
441 print
'<table class="nobordernopadding" width="100%"><tr><td>';
442 print $langs->trans(
'Project');
444 if ($action !=
'classify' && $user->hasRight(
'deplacement',
'creer')) {
445 print
'<td class="right"><a href="'.$_SERVER[
"PHP_SELF"].
'?action=classify&token='.
newToken().
'&id='.
$object->id.
'">';
446 print
img_edit($langs->trans(
'SetProject'), 1);
449 print
'</tr></table>';
450 print
'</td><td colspan="3">';
451 if ($action ==
'classify') {
452 $form->form_project($_SERVER[
'PHP_SELF'].
'?id='.
$object->id,
$object->socid,
$object->fk_project,
'projectid', 0, 0, 1);
454 $form->form_project($_SERVER[
'PHP_SELF'].
'?id='.
$object->id,
$object->socid,
$object->fk_project,
'none', 0, 0);
461 print
'<tr><td>'.$langs->trans(
"Status").
'</td><td>'.
$object->getLibStatut(4).
'</td></tr>';
464 $parameters = array(
'socid' =>
$object->id);
465 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_view.tpl.php';
467 print
"</table><br>";
471 $title = $langs->trans(
'Notes');
472 include DOL_DOCUMENT_ROOT.
'/core/tpl/bloc_showhide.tpl.php';
479 print
'<div class="tabsAction">';
482 if ($user->hasRight(
'deplacement',
'creer')) {
483 print
'<a class="butAction" href="'.$_SERVER[
"PHP_SELF"].
'?action=edit&token='.
newToken().
'&id='.
$id.
'">'.$langs->trans(
'Modify').
'</a>';
485 print
'<a class="butActionRefused classfortooltip" href="#" title="'.dol_escape_htmltag($langs->trans(
"NotAllowed")).
'">'.$langs->trans(
'Modify').
'</a>';
490 if ($user->hasRight(
'deplacement',
'creer')) {
491 print
'<a class="butAction" href="'.$_SERVER[
"PHP_SELF"].
'?action=validate&id='.
$id.
'">'.$langs->trans(
'Validate').
'</a>';
493 print
'<a class="butActionRefused classfortooltip" href="#" title="'.dol_escape_htmltag($langs->trans(
"NotAllowed")).
'">'.$langs->trans(
'Validate').
'</a>';
498 if ($user->hasRight(
'deplacement',
'creer')) {
499 print
'<a class="butAction" href="'.$_SERVER[
"PHP_SELF"].
'?action=classifyrefunded&token='.
newToken().
'&id='.
$id.
'">'.$langs->trans(
'ClassifyRefunded').
'</a>';
501 print
'<a class="butActionRefused classfortooltip" href="#" title="'.dol_escape_htmltag($langs->trans(
"NotAllowed")).
'">'.$langs->trans(
'ClassifyRefunded').
'</a>';
505 $permissiontodelete = $user->hasRight(
'deplacement',
'supprimer');
506 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.