26 require
'../main.inc.php';
28 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formcompany.class.php';
29 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formfile.class.php';
30 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formprojet.class.php';
31 require_once DOL_DOCUMENT_ROOT.
'/bookcal/class/booking.class.php';
32 require_once DOL_DOCUMENT_ROOT.
'/bookcal/lib/bookcal_booking.lib.php';
35 $langs->loadLangs(array(
"bookcal@bookcal",
"other"));
40 $lineid =
GETPOST(
'lineid',
'int');
42 $action =
GETPOST(
'action',
'aZ09');
43 $confirm =
GETPOST(
'confirm',
'alpha');
44 $cancel =
GETPOST(
'cancel',
'aZ09');
45 $contextpage =
GETPOST(
'contextpage',
'aZ') ?
GETPOST(
'contextpage',
'aZ') : str_replace(
'_',
'', basename(dirname(__FILE__)).basename(__FILE__,
'.php'));
46 $backtopage =
GETPOST(
'backtopage',
'alpha');
47 $backtopageforcancel =
GETPOST(
'backtopageforcancel',
'alpha');
48 $dol_openinpopup =
GETPOST(
'dol_openinpopup',
'aZ09');
53 $diroutputmassaction = $conf->bookcal->dir_output.
'/temp/massgeneration/'.$user->id;
54 $hookmanager->initHooks(array(
'bookingcard',
'globalcard'));
57 $extrafields->fetch_name_optionals_label($object->table_element);
59 $search_array_options = $extrafields->getOptionalsFromPost($object->table_element,
'',
'search_');
62 $search_all =
GETPOST(
"search_all",
'alpha');
64 foreach ($object->fields as $key => $val) {
65 if (
GETPOST(
'search_'.$key,
'alpha')) {
66 $search[$key] =
GETPOST(
'search_'.$key,
'alpha');
70 if (empty($action) && empty($id) && empty($ref)) {
75 include DOL_DOCUMENT_ROOT.
'/core/actions_fetchobject.inc.php';
79 $enablepermissioncheck = 0;
80 if ($enablepermissioncheck) {
81 $permissiontoread = $user->rights->bookcal->booking->read;
82 $permissiontoadd = $user->rights->bookcal->booking->write;
83 $permissiontodelete = $user->rights->bookcal->booking->delete || ($permissiontoadd && isset($object->status) && $object->status == $object::STATUS_DRAFT);
84 $permissionnote = $user->rights->bookcal->booking->write;
85 $permissiondellink = $user->rights->bookcal->booking->write;
87 $permissiontoread = 1;
89 $permissiontodelete = 1;
91 $permissiondellink = 1;
94 $upload_dir = $conf->bookcal->multidir_output[isset($object->entity) ? $object->entity : 1].
'/booking';
109 $parameters = array();
110 $reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
115 if (empty($reshook)) {
118 $backurlforlist =
dol_buildpath(
'/bookcal/booking_list.php', 1);
120 if (empty($backtopage) || ($cancel && empty($id))) {
121 if (empty($backtopage) || ($cancel && strpos($backtopage,
'__ID__'))) {
122 if (empty($id) && (($action !=
'add' && $action !=
'create') || $cancel)) {
123 $backtopage = $backurlforlist;
125 $backtopage =
dol_buildpath(
'/bookcal/booking_card.php', 1).
'?id='.((!empty($id) && $id > 0) ? $id :
'__ID__');
130 $triggermodname =
'BOOKCAL_BOOKING_MODIFY';
133 include DOL_DOCUMENT_ROOT.
'/core/actions_addupdatedelete.inc.php';
136 include DOL_DOCUMENT_ROOT.
'/core/actions_dellink.inc.php';
139 include DOL_DOCUMENT_ROOT.
'/core/actions_printing.inc.php';
145 include DOL_DOCUMENT_ROOT.
'/core/actions_builddoc.inc.php';
147 if ($action ==
'set_thirdparty' && $permissiontoadd) {
148 $object->setValueFrom(
'fk_soc',
GETPOST(
'fk_soc',
'int'),
'',
'',
'date',
'', $user, $triggermodname);
150 if ($action ==
'classin' && $permissiontoadd) {
151 $object->setProject(
GETPOST(
'projectid',
'int'));
155 $triggersendname =
'BOOKCAL_BOOKING_SENTBYMAIL';
156 $autocopy =
'MAIN_MAIL_AUTOCOPY_BOOKING_TO';
157 $trackid =
'booking'.$object->id;
158 include DOL_DOCUMENT_ROOT.
'/core/actions_sendmails.inc.php';
174 $title = $langs->trans(
"Booking");
195 if ($action ==
'create') {
196 if (empty($permissiontoadd)) {
201 print
load_fiche_titre($langs->trans(
"NewObject", $langs->transnoentitiesnoconv(
"Booking")),
'',
'object_'.$object->picto);
203 print
'<form method="POST" action="'.$_SERVER[
"PHP_SELF"].
'">';
204 print
'<input type="hidden" name="token" value="'.newToken().
'">';
205 print
'<input type="hidden" name="action" value="add">';
207 print
'<input type="hidden" name="backtopage" value="'.$backtopage.
'">';
209 if ($backtopageforcancel) {
210 print
'<input type="hidden" name="backtopageforcancel" value="'.$backtopageforcancel.
'">';
218 print
'<table class="border centpercent tableforfieldcreate">'.
"\n";
221 include DOL_DOCUMENT_ROOT.
'/core/tpl/commonfields_add.tpl.php';
224 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_add.tpl.php';
226 print
'</table>'.
"\n";
230 print
$form->buttonsSaveCancel(
"Create");
238 if (($id || $ref) && $action ==
'edit') {
239 print
load_fiche_titre($langs->trans(
"Booking"),
'',
'object_'.$object->picto);
241 print
'<form method="POST" action="'.$_SERVER[
"PHP_SELF"].
'">';
242 print
'<input type="hidden" name="token" value="'.newToken().
'">';
243 print
'<input type="hidden" name="action" value="update">';
244 print
'<input type="hidden" name="id" value="'.$object->id.
'">';
246 print
'<input type="hidden" name="backtopage" value="'.$backtopage.
'">';
248 if ($backtopageforcancel) {
249 print
'<input type="hidden" name="backtopageforcancel" value="'.$backtopageforcancel.
'">';
254 print
'<table class="border centpercent tableforfieldedit">'.
"\n";
257 include DOL_DOCUMENT_ROOT.
'/core/tpl/commonfields_edit.tpl.php';
260 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_edit.tpl.php';
266 print
$form->buttonsSaveCancel();
272 if ($object->id > 0 && (empty($action) || ($action !=
'edit' && $action !=
'create'))) {
273 $res = $object->fetch_optionals();
276 print
dol_get_fiche_head($head,
'card', $langs->trans(
"Booking"), -1, $object->picto);
281 if ($action ==
'delete') {
282 $formconfirm =
$form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.$object->id, $langs->trans(
'DeleteBooking'), $langs->trans(
'ConfirmDeleteObject'),
'confirm_delete',
'', 0, 1);
285 if ($action ==
'deleteline') {
286 $formconfirm =
$form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.$object->id.
'&lineid='.$lineid, $langs->trans(
'DeleteLine'), $langs->trans(
'ConfirmDeleteLine'),
'confirm_deleteline',
'', 0, 1);
290 if ($action ==
'clone') {
292 $formquestion = array();
293 $formconfirm =
$form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.$object->id, $langs->trans(
'ToClone'), $langs->trans(
'ConfirmCloneAsk', $object->ref),
'confirm_clone', $formquestion,
'yes', 1);
297 if ($action ==
'xxx') {
298 $text = $langs->trans(
'ConfirmActionBooking', $object->ref);
307 $formquestion = array();
318 $formconfirm =
$form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.$object->id, $langs->trans(
'XXX'), $text,
'confirm_xxx', $formquestion, 0, 1, 220);
322 $parameters = array(
'formConfirm' =>
$formconfirm,
'lineid' => $lineid);
323 $reshook = $hookmanager->executeHooks(
'formConfirm', $parameters, $object, $action);
324 if (empty($reshook)) {
326 } elseif ($reshook > 0) {
336 $linkback =
'<a href="'.dol_buildpath(
'/bookcal/booking_list.php', 1).
'?restore_lastsearch_values=1'.(!empty($socid) ?
'&socid='.$socid :
'').
'">'.$langs->trans(
"BackToList").
'</a>';
338 $morehtmlref =
'<div class="refidno">';
373 $morehtmlref .=
'</div>';
376 dol_banner_tab($object,
'ref', $linkback, 1,
'ref',
'ref', $morehtmlref);
379 print
'<div class="fichecenter">';
380 print
'<div class="fichehalfleft">';
381 print
'<div class="underbanner clearboth"></div>';
382 print
'<table class="border centpercent tableforfield">'.
"\n";
388 include DOL_DOCUMENT_ROOT.
'/core/tpl/commonfields_view.tpl.php';
391 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_view.tpl.php';
397 print
'<div class="clearboth"></div>';
406 if (!empty($object->table_element_line)) {
408 $result = $object->getLinesArray();
410 print
' <form name="addproduct" id="addproduct" action="'.$_SERVER[
"PHP_SELF"].
'?id='.$object->id.(($action !=
'editline') ?
'' :
'#line_'.
GETPOST(
'lineid',
'int')).
'" method="POST">
411 <input type="hidden" name="token" value="' .
newToken().
'">
412 <input type="hidden" name="action" value="' . (($action !=
'editline') ?
'addline' :
'updateline').
'">
413 <input type="hidden" name="mode" value="">
414 <input type="hidden" name="page_y" value="">
415 <input type="hidden" name="id" value="' . $object->id.
'">
418 if (!empty($conf->use_javascript_ajax) && $object->status == 0) {
419 include DOL_DOCUMENT_ROOT.
'/core/tpl/ajaxrow.tpl.php';
422 print
'<div class="div-table-responsive-no-min">';
423 if (!empty($object->lines) || ($object->status == $object::STATUS_DRAFT && $permissiontoadd && $action !=
'selectlines' && $action !=
'editline')) {
424 print
'<table id="tablelines" class="noborder noshadow" width="100%">';
427 if (!empty($object->lines)) {
428 $object->printObjectLines($action, $mysoc,
null,
GETPOST(
'lineid',
'int'), 1);
432 if ($object->status == 0 && $permissiontoadd && $action !=
'selectlines') {
433 if ($action !=
'editline') {
436 $parameters = array();
437 $reshook = $hookmanager->executeHooks(
'formAddObjectLine', $parameters, $object, $action);
438 if ($reshook < 0)
setEventMessages($hookmanager->error, $hookmanager->errors,
'errors');
440 $object->formAddObjectLine(1, $mysoc, $soc);
444 if (!empty($object->lines) || ($object->status == $object::STATUS_DRAFT && $permissiontoadd && $action !=
'selectlines' && $action !=
'editline')) {
455 if ($action !=
'presend' && $action !=
'editline') {
456 print
'<div class="tabsAction">'.
"\n";
457 $parameters = array();
458 $reshook = $hookmanager->executeHooks(
'addMoreActionsButtons', $parameters, $object, $action);
463 if (empty($reshook)) {
465 if (empty($user->socid)) {
466 print
dolGetButtonAction($langs->trans(
'SendMail'),
'',
'default', $_SERVER[
"PHP_SELF"].
'?id='.$object->id.
'&action=presend&mode=init&token='.
newToken().
'#formmailbeforetitle');
470 if ($object->status == $object::STATUS_VALIDATED) {
471 print
dolGetButtonAction($langs->trans(
'SetToDraft'),
'',
'default', $_SERVER[
"PHP_SELF"].
'?id='.$object->id.
'&action=confirm_setdraft&confirm=yes&token='.
newToken(),
'', $permissiontoadd);
474 print
dolGetButtonAction($langs->trans(
'Modify'),
'',
'default', $_SERVER[
"PHP_SELF"].
'?id='.$object->id.
'&action=edit&token='.
newToken(),
'', $permissiontoadd);
477 if ($object->status == $object::STATUS_DRAFT) {
478 if (empty($object->table_element_line) || (is_array($object->lines) && count($object->lines) > 0)) {
479 print
dolGetButtonAction($langs->trans(
'Validate'),
'',
'default', $_SERVER[
'PHP_SELF'].
'?id='.$object->id.
'&action=confirm_validate&confirm=yes&token='.
newToken(),
'', $permissiontoadd);
481 $langs->load(
"errors");
482 print
dolGetButtonAction($langs->trans(
"ErrorAddAtLeastOneLineFirst"), $langs->trans(
"Validate"),
'default',
'#',
'', 0);
487 print
dolGetButtonAction($langs->trans(
'ToClone'),
'',
'default', $_SERVER[
'PHP_SELF'].
'?id='.$object->id.(!empty($object->socid)?
'&socid='.$object->socid:
'').
'&action=clone&token='.
newToken(),
'', $permissiontoadd);
507 print
dolGetButtonAction($langs->trans(
'Delete'),
'',
'delete', $_SERVER[
'PHP_SELF'].
'?id='.$object->id.
'&action=delete&token='.
newToken(),
'', $permissiontodelete || ($object->status == $object::STATUS_DRAFT && $permissiontoadd));
514 if (
GETPOST(
'modelselected')) {
518 if ($action !=
'presend') {
519 print
'<div class="fichecenter"><div class="fichehalfleft">';
520 print
'<a name="builddoc"></a>';
522 $includedocgeneration = 0;
525 if ($includedocgeneration) {
527 $relativepath = $objref.
'/'.$objref.
'.pdf';
528 $filedir = $conf->bookcal->dir_output.
'/'.$object->element.
'/'.$objref;
529 $urlsource = $_SERVER[
"PHP_SELF"].
"?id=".$object->id;
530 $genallowed = $permissiontoread;
531 $delallowed = $permissiontoadd;
532 print $formfile->showdocuments(
'bookcal:Booking', $object->element.
'/'.$objref, $filedir, $urlsource, $genallowed, $delallowed, $object->model_pdf, 1, 0, 0, 28, 0,
'',
'',
'', $langs->defaultlang);
536 $linktoelem =
$form->showLinkToObjectBlock($object,
null, array(
'booking'));
537 $somethingshown =
$form->showLinkedObjectBlock($object, $linktoelem);
540 print
'</div><div class="fichehalfright">';
544 $morehtmlcenter =
dolGetButtonTitle($langs->trans(
'SeeAll'),
'',
'fa fa-bars imgforviewmode',
dol_buildpath(
'/bookcal/booking_agenda.php', 1).
'?id='.$object->id);
547 include_once DOL_DOCUMENT_ROOT.
'/core/class/html.formactions.class.php';
549 $somethingshown =
$formactions->showactions($object, $object->element.
'@'.$object->module, (is_object($object->thirdparty) ? $object->thirdparty->id : 0), 1,
'', $MAXEVENT,
'', $morehtmlcenter);
551 print
'</div></div>';
555 if (
GETPOST(
'modelselected')) {
560 $modelmail =
'booking';
561 $defaulttopic =
'InformationMessage';
562 $diroutput = $conf->bookcal->dir_output;
563 $trackid =
'booking'.$object->id;
565 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.
bookingPrepareHead($object)
Prepare array of tabs for Booking.
if($cancel &&! $id) if($action=='add' &&! $cancel) if($action=='delete') if($id) $form
Actions.
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.
load_fiche_titre($titre, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='')
Show tabs of a record.
dolGetButtonTitle($label, $helpText='', $iconClass='fa fa-file', $url='', $id='', $status=1, $params=array())
Function dolGetButtonTitle : this kind of buttons are used in title in list.
dol_get_fiche_end($notab=0)
Return tab footer of a card.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='')
Set event messages in dol_events session object.
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_buildpath($path, $type=0, $returnemptyifnotfound=0)
Return path of url or filesystem.
dol_sanitizeFileName($str, $newstr='_', $unaccent=1)
Clean a string to use it as a file name.
$formconfirm
if ($action == 'delbookkeepingyear') {
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.