28 require
'../../main.inc.php';
29 require_once DOL_DOCUMENT_ROOT.
'/core/lib/trip.lib.php';
30 require_once DOL_DOCUMENT_ROOT.
'/compta/deplacement/class/deplacement.class.php';
31 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formfile.class.php';
32 if (!empty($conf->projet->enabled))
34 require_once DOL_DOCUMENT_ROOT.
'/projet/class/project.class.php';
38 $langs->load(
"trips");
43 if ($user->socid) $socid = $user->socid;
46 $action =
GETPOST(
'action',
'aZ09');
47 $confirm =
GETPOST(
'confirm',
'alpha');
52 $hookmanager->initHooks(array(
'tripsandexpensescard',
'globalcard'));
54 $permissionnote = $user->rights->deplacement->creer;
61 include DOL_DOCUMENT_ROOT.
'/core/actions_setnotes.inc.php';
63 if ($action ==
'validate' && $user->rights->deplacement->creer)
68 $result = $object->setStatut(1);
71 header(
"Location: ".
$_SERVER[
"PHP_SELF"].
"?id=".$id);
77 } elseif ($action ==
'classifyrefunded' && $user->rights->deplacement->creer)
85 header(
"Location: ".
$_SERVER[
"PHP_SELF"].
"?id=".$id);
91 } elseif ($action ==
'confirm_delete' && $confirm ==
"yes" && $user->rights->deplacement->supprimer)
93 $result = $object->delete($id);
96 header(
"Location: index.php");
101 } elseif ($action ==
'add' && $user->rights->deplacement->creer)
103 if (!
GETPOST(
'cancel',
'alpha'))
109 $object->type =
GETPOST(
'type',
'alpha');
110 $object->socid = (int)
GETPOST(
'socid',
'int');
111 $object->fk_user = (int)
GETPOST(
'fk_user',
'int');
112 $object->note_private =
GETPOST(
'note_private',
'alpha');
113 $object->note_public =
GETPOST(
'note_public',
'alpha');
118 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Date")), null,
'errors');
121 if ($object->type ==
'-1')
123 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Type")), null,
'errors');
126 if (!($object->fk_user > 0))
128 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Person")), null,
'errors');
134 $id = $object->create($user);
138 header(
"Location: ".
$_SERVER[
"PHP_SELF"].
"?id=".$id);
148 header(
"Location: index.php");
152 elseif ($action ==
'update' && $user->rights->deplacement->creer)
154 if (!
GETPOST(
'cancel',
'alpha'))
156 $result = $object->fetch($id);
160 $object->type =
GETPOST(
'type',
'alpha');
161 $object->socid = (int)
GETPOST(
'socid',
'int');
162 $object->fk_user = (int)
GETPOST(
'fk_user',
'int');
163 $object->note_private =
GETPOST(
'note_private',
'alpha');
164 $object->note_public =
GETPOST(
'note_public',
'alpha');
166 $result = $object->update($user);
170 header(
"Location: ".
$_SERVER[
"PHP_SELF"].
"?id=".$id);
176 header(
"Location: ".
$_SERVER[
"PHP_SELF"].
"?id=".$id);
180 elseif ($action ==
'classin' && $user->rights->deplacement->creer)
183 $result = $object->setProject(
GETPOST(
'projectid',
'int'));
186 elseif ($action ==
'setdated' && $user->rights->deplacement->creer)
188 $dated =
dol_mktime(
GETPOST(
'datedhour',
'int'),
GETPOST(
'datedmin',
'int'),
GETPOST(
'datedsec',
'int'),
GETPOST(
'datedmonth',
'int'),
GETPOST(
'datedday',
'int'),
GETPOST(
'datedyear',
'int'));
190 $result = $object->setValueFrom(
'dated', $dated,
'',
'',
'date',
'', $user,
'DEPLACEMENT_MODIFY');
192 } elseif ($action ==
'setkm' && $user->rights->deplacement->creer)
195 $result = $object->setValueFrom(
'km',
GETPOST(
'km',
'int'),
'', null,
'text',
'', $user,
'DEPLACEMENT_MODIFY');
206 $form =
new Form($db);
211 if ($action ==
'create')
214 require_once DOL_DOCUMENT_ROOT.
'/core/class/doleditor.class.php';
220 print '<form name="add" action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">'.
"\n";
221 print '<input type="hidden" name="token" value="'.newToken().
'">';
222 print '<input type="hidden" name="action" value="add">';
224 print '<table class="border centpercent">';
227 print '<td class="fieldrequired">'.$langs->trans(
"Type").
'</td><td>';
228 $form->select_type_fees(
GETPOST(
'type',
'int'),
'type', 1);
232 print '<td class="fieldrequired">'.$langs->trans(
"Person").
'</td><td>';
233 print $form->select_dolusers(
GETPOST(
'fk_user',
'int'),
'fk_user', 1,
'', 0,
'',
'', 0, 0, 0,
'', 0,
'',
'maxwidth300');
237 print '<td class="fieldrequired">'.$langs->trans(
"Date").
'</td><td>';
238 print $form->selectDate($datec ? $datec : -1,
'',
'',
'',
'',
'add', 1, 1);
242 print '<tr><td class="fieldrequired">'.$langs->trans(
"FeesKilometersOrAmout").
'</td><td><input name="km" size="10" value="'.
GETPOST(
"km").
'"></td></tr>';
246 print '<td>'.$langs->trans(
"CompanyVisited").
'</td><td>';
247 print $form->select_company(
GETPOST(
'socid',
'int'),
'socid',
'', 1);
252 print '<td class="tdtop">'.$langs->trans(
'NotePublic').
'</td>';
255 $doleditor =
new DolEditor(
'note_public',
GETPOST(
'note_public',
'restricthtml'),
'', 200,
'dolibarr_notes',
'In',
false,
true,
true, ROWS_8,
'90%');
256 print $doleditor->Create(1);
261 if (empty($user->socid))
264 print '<td class="tdtop">'.$langs->trans(
'NotePrivate').
'</td>';
267 $doleditor =
new DolEditor(
'note_private',
GETPOST(
'note_private',
'restricthtml'),
'', 200,
'dolibarr_notes',
'In',
false,
true,
true, ROWS_8,
'90%');
268 print $doleditor->Create(1);
274 $parameters = array();
275 $reshook = $hookmanager->executeHooks(
'formObjectOptions', $parameters, $object, $action);
276 print $hookmanager->resPrint;
280 print '<br><div class="center">';
281 print '<input class="button button-save" type="submit" value="'.$langs->trans(
"Save").
'">';
282 print ' ';
283 print '<input class="button button-cancel" type="submit" name="cancel" value="'.$langs->trans(
"Cancel").
'">';
289 $result = $object->fetch($id);
296 if ($action ==
'edit' && $user->rights->deplacement->creer)
299 require_once DOL_DOCUMENT_ROOT.
'/core/class/doleditor.class.php';
304 $soc->fetch($object->socid);
307 print '<form name="update" action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">'.
"\n";
308 print '<input type="hidden" name="token" value="'.newToken().
'">';
309 print '<input type="hidden" name="action" value="update">';
310 print '<input type="hidden" name="id" value="'.$id.
'">';
312 print '<table class="border centpercent">';
316 print '<td class="titlefield">'.$langs->trans(
"Ref").
'</td><td>';
322 print '<td class="fieldrequired">'.$langs->trans(
"Type").
'</td><td>';
323 $form->select_type_fees(
GETPOST(
'type',
'int') ?
GETPOST(
'type',
'int') : $object->type,
'type', 0);
328 print '<td class="fieldrequired">'.$langs->trans(
"Person").
'</td><td>';
329 print $form->select_dolusers(
GETPOST(
'fk_user',
'int') ?
GETPOST(
'fk_user',
'int') : $object->fk_user,
'fk_user', 0,
'', 0,
'',
'', 0, 0, 0,
'', 0,
'',
'maxwidth300');
333 print '<tr><td class="fieldrequired">'.$langs->trans(
"Date").
'</td><td>';
334 print $form->selectDate($object->date,
'', 0, 0, 0,
'update', 1, 0);
338 print '<tr><td class="fieldrequired">'.$langs->trans(
"FeesKilometersOrAmout").
'</td><td>';
339 print '<input name="km" class="flat" size="10" value="'.$object->km.
'">';
344 print '<td>'.$langs->trans(
"CompanyVisited").
'</td><td>';
345 print $form->select_company($soc->id,
'socid',
'', 1);
349 print '<tr><td class="tdtop">'.$langs->trans(
"NotePublic").
'</td>';
352 $doleditor =
new DolEditor(
'note_public', $object->note_public,
'', 200,
'dolibarr_notes',
'In',
false,
true,
true, ROWS_8,
'90%');
353 print $doleditor->Create(1);
358 if (empty($user->socid))
360 print '<tr><td class="tdtop">'.$langs->trans(
"NotePrivate").
'</td>';
363 $doleditor =
new DolEditor(
'note_private', $object->note_private,
'', 200,
'dolibarr_notes',
'In',
false,
true,
true, ROWS_8,
'90%');
364 print $doleditor->Create(1);
370 $parameters = array();
371 $reshook = $hookmanager->executeHooks(
'formObjectOptions', $parameters, $object, $action);
372 print $hookmanager->resPrint;
376 print '<br><div class="center">';
377 print '<input type="submit" class="button button-save" value="'.$langs->trans(
"Save").
'">';
378 print ' ';
379 print '<input type="submit" name="cancel" class="button button-cancel" value="'.$langs->trans(
"Cancel").
'">';
389 if ($action ==
'delete')
391 print $form->formconfirm(
$_SERVER[
"PHP_SELF"].
"?id=".$id, $langs->trans(
"DeleteTrip"), $langs->trans(
"ConfirmDeleteTrip"),
"confirm_delete");
395 if ($object->socid) $soc->fetch($object->socid);
397 print '<table class="border centpercent">';
399 $linkback =
'<a href="'.DOL_URL_ROOT.
'/compta/deplacement/list.php'.(!empty($socid) ?
'?socid='.$socid :
'').
'">'.$langs->trans(
"BackToList").
'</a>';
402 print '<tr><td width="25%">'.$langs->trans(
"Ref").
'</td><td>';
403 print $form->showrefnav($object,
'id', $linkback, 1,
'rowid',
'ref',
'');
406 $form->load_cache_types_fees();
410 print $form->editfieldkey(
"Type",
'type', $langs->trans($object->type), $object, $user->rights->deplacement->creer,
'select:types_fees');
412 print $form->editfieldval(
"Type",
'type', $form->cache_types_fees[$object->type], $object, $user->rights->deplacement->creer,
'select:types_fees');
416 print '<tr><td>'.$langs->trans(
"Person").
'</td><td>';
417 $userfee =
new User($db);
418 $userfee->fetch($object->fk_user);
419 print $userfee->getNomUrl(1);
424 print $form->editfieldkey(
"Date",
'dated', $object->date, $object, $user->rights->deplacement->creer,
'datepicker');
426 print $form->editfieldval(
"Date",
'dated', $object->date, $object, $user->rights->deplacement->creer,
'datepicker');
430 print '<tr><td class="tdtop">';
431 print $form->editfieldkey(
"FeesKilometersOrAmout",
'km', $object->km, $object, $user->rights->deplacement->creer,
'numeric:6');
433 print $form->editfieldval(
"FeesKilometersOrAmout",
'km', $object->km, $object, $user->rights->deplacement->creer,
'numeric:6');
437 print '<tr><td>'.$langs->trans(
"CompanyVisited").
'</td>';
439 if ($soc->id)
print $soc->getNomUrl(1);
443 if (!empty($conf->projet->enabled))
445 $langs->load(
'projects');
449 print '<table class="nobordernopadding" width="100%"><tr><td>';
450 print $langs->trans(
'Project');
452 if ($action !=
'classify' && $user->rights->deplacement->creer)
454 print '<td class="right"><a href="'.$_SERVER[
"PHP_SELF"].
'?action=classify&id='.$object->id.
'">';
458 print '</tr></table>';
459 print '</td><td colspan="3">';
460 if ($action ==
'classify')
462 $form->form_project(
$_SERVER[
'PHP_SELF'].
'?id='.$object->id, $object->socid, $object->fk_project,
'projectid', 0, 0, 1);
464 $form->form_project(
$_SERVER[
'PHP_SELF'].
'?id='.$object->id, $object->socid, $object->fk_project,
'none', 0, 0);
471 print '<tr><td>'.$langs->trans(
"Status").
'</td><td>'.$object->getLibStatut(4).
'</td></tr>';
474 $parameters = array(
'socid'=>$object->id);
475 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_view.tpl.php';
477 print "</table><br>";
481 $title = $langs->trans(
'Notes');
482 include DOL_DOCUMENT_ROOT.
'/core/tpl/bloc_showhide.tpl.php';
490 print '<div class="tabsAction">';
494 if ($user->rights->deplacement->creer)
496 print '<a class="butAction" href="'.$_SERVER[
"PHP_SELF"].
'?action=edit&id='.$id.
'">'.$langs->trans(
'Modify').
'</a>';
498 print '<a class="butActionRefused classfortooltip" href="#" title="'.dol_escape_htmltag($langs->trans(
"NotAllowed")).
'">'.$langs->trans(
'Modify').
'</a>';
504 if ($user->rights->deplacement->creer)
506 print '<a class="butAction" href="'.$_SERVER[
"PHP_SELF"].
'?action=validate&id='.$id.
'">'.$langs->trans(
'Validate').
'</a>';
508 print '<a class="butActionRefused classfortooltip" href="#" title="'.dol_escape_htmltag($langs->trans(
"NotAllowed")).
'">'.$langs->trans(
'Validate').
'</a>';
514 if ($user->rights->deplacement->creer)
516 print '<a class="butAction" href="'.$_SERVER[
"PHP_SELF"].
'?action=classifyrefunded&id='.$id.
'">'.$langs->trans(
'ClassifyRefunded').
'</a>';
518 print '<a class="butActionRefused classfortooltip" href="#" title="'.dol_escape_htmltag($langs->trans(
"NotAllowed")).
'">'.$langs->trans(
'ClassifyRefunded').
'</a>';
522 if ($user->rights->deplacement->supprimer)
524 print '<a class="butActionDelete" href="'.$_SERVER[
"PHP_SELF"].
'?action=delete&token='.
newToken().
'&id='.$id.
'">'.$langs->trans(
'Delete').
'</a>';
526 print '<a class="butActionRefused classfortooltip" href="#" title="'.dol_escape_htmltag($langs->trans(
"NotAllowed")).
'">'.$langs->trans(
'Delete').
'</a>';
GETPOST($paramname, $check= 'alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
img_edit($titlealt= 'default', $float=0, $other= '')
Show logo editer/modifier fiche.
const STATUS_DRAFT
Draft status.
Class to manage trips and working credit notes.
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...
const STATUS_REFUNDED
Refunded status.
const STATUS_VALIDATED
Validated status.
Class to manage Dolibarr users.
setEventMessages($mesg, $mesgs, $style= 'mesgs', $messagekey= '')
Set event messages in dol_events session object.
Class to manage third parties objects (customers, suppliers, prospects...)
load_fiche_titre($titre, $morehtmlright= '', $picto= 'generic', $pictoisfullpath=0, $id= '', $morecssontable= '', $morehtmlcenter= '')
Load a title with picto.
price2num($amount, $rounding= '', $option=0)
Function that return a number with universal decimal format (decimal separator is '...
restrictedArea($user, $features, $objectid=0, $tableandshare= '', $feature2= '', $dbt_keyfield= 'fk_soc', $dbt_select= 'rowid', $isdraft=0)
Check permissions of a user to show a page and an object.
print $_SERVER["PHP_SELF"]
Edit parameters.
dol_get_fiche_head($links=array(), $active= '', $title= '', $notab=0, $picto= '', $pictoisfullpath=0, $morehtmlright= '', $morecss= '', $limittoshow=0, $moretabssuffix= '')
Show tabs of a record.
print
Draft customers invoices.
trip_prepare_head(Deplacement $object)
Prepare array with list of tabs.
dol_print_error($db= '', $error= '', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
newToken()
Return the value of token currently saved into session with name 'newtoken'.
Class to manage a WYSIWYG editor.