48if (!$res && !empty($_SERVER[
"CONTEXT_DOCUMENT_ROOT"])) {
49 $res = @include $_SERVER[
"CONTEXT_DOCUMENT_ROOT"].
"/main.inc.php";
52$tmp = empty($_SERVER[
'SCRIPT_FILENAME']) ?
'' : $_SERVER[
'SCRIPT_FILENAME']; $tmp2 = realpath(__FILE__); $i = strlen($tmp) - 1; $j = strlen($tmp2) - 1;
53while ($i > 0 && $j > 0 && isset($tmp[$i]) && isset($tmp2[$j]) && $tmp[$i] == $tmp2[$j]) {
57if (!$res && $i > 0 && file_exists(substr($tmp, 0, ($i + 1)).
"/main.inc.php")) {
58 $res = @include substr($tmp, 0, ($i + 1)).
"/main.inc.php";
60if (!$res && $i > 0 && file_exists(dirname(substr($tmp, 0, ($i + 1))).
"/main.inc.php")) {
61 $res = @include dirname(substr($tmp, 0, ($i + 1))).
"/main.inc.php";
64if (!$res && file_exists(
"../main.inc.php")) {
65 $res = @include
"../main.inc.php";
67if (!$res && file_exists(
"../../main.inc.php")) {
68 $res = @include
"../../main.inc.php";
70if (!$res && file_exists(
"../../../main.inc.php")) {
71 $res = @include
"../../../main.inc.php";
74 die(
"Include of main fails");
77require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formcompany.class.php';
78require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formfile.class.php';
79require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formprojet.class.php';
84$langs->loadLangs(array(
"bookcal@bookcal",
"other"));
89$lineid =
GETPOST(
'lineid',
'int');
91$action =
GETPOST(
'action',
'aZ09');
92$confirm =
GETPOST(
'confirm',
'alpha');
93$cancel =
GETPOST(
'cancel',
'aZ09');
94$contextpage =
GETPOST(
'contextpage',
'aZ') ?
GETPOST(
'contextpage',
'aZ') : str_replace(
'_',
'', basename(dirname(__FILE__)).basename(__FILE__,
'.php'));
95$backtopage =
GETPOST(
'backtopage',
'alpha');
96$backtopageforcancel =
GETPOST(
'backtopageforcancel',
'alpha');
97$backtopagejsfields =
GETPOST(
'backtopagejsfields',
'alpha');
98$dol_openinpopup =
GETPOST(
'dol_openinpopup',
'aZ09');
100if (!empty($backtopagejsfields)) {
101 $tmpbacktopagejsfields = explode(
':', $backtopagejsfields);
102 $dol_openinpopup = $tmpbacktopagejsfields[0];
108$diroutputmassaction = $conf->bookcal->dir_output.
'/temp/massgeneration/'.$user->id;
109$hookmanager->initHooks(array(
'calendarcard',
'globalcard'));
112$extrafields->fetch_name_optionals_label($object->table_element);
114$search_array_options = $extrafields->getOptionalsFromPost($object->table_element,
'',
'search_');
117$search_all =
GETPOST(
"search_all",
'alpha');
119foreach ($object->fields as $key => $val) {
120 if (
GETPOST(
'search_'.$key,
'alpha')) {
121 $search[$key] =
GETPOST(
'search_'.$key,
'alpha');
125if (empty($action) && empty($id) && empty($ref)) {
130include DOL_DOCUMENT_ROOT.
'/core/actions_fetchobject.inc.php';
134$enablepermissioncheck = 0;
135if ($enablepermissioncheck) {
136 $permissiontoread = $user->hasRight(
'bookcal',
'calendar',
'read');
137 $permissiontoadd = $user->hasRight(
'bookcal',
'calendar',
'write');
138 $permissiontodelete = $user->hasRight(
'bookcal',
'calendar',
'delete') || ($permissiontoadd && isset($object->status) && $object->status == $object::STATUS_DRAFT);
139 $permissionnote = $user->hasRight(
'bookcal',
'calendar',
'write');
140 $permissiondellink = $user->hasRight(
'bookcal',
'calendar',
'write');
142 $permissiontoread = 1;
143 $permissiontoadd = 1;
144 $permissiontodelete = 1;
146 $permissiondellink = 1;
149$upload_dir = $conf->bookcal->multidir_output[isset($object->entity) ? $object->entity : 1].
'/calendar';
156if (!isModEnabled(
"bookcal")) {
159if (!$permissiontoread) {
168$parameters = array();
169$reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
174if (empty($reshook)) {
177 $backurlforlist =
dol_buildpath(
'/bookcal/calendar_list.php', 1);
179 if (empty($backtopage) || ($cancel && empty($id))) {
180 if (empty($backtopage) || ($cancel && strpos($backtopage,
'__ID__'))) {
181 if (empty($id) && (($action !=
'add' && $action !=
'create') || $cancel)) {
182 $backtopage = $backurlforlist;
184 $backtopage =
dol_buildpath(
'/bookcal/calendar_card.php', 1).
'?id='.((!empty($id) && $id > 0) ? $id :
'__ID__');
189 $triggermodname =
'BOOKCAL_MYOBJECT_MODIFY';
192 include DOL_DOCUMENT_ROOT.
'/core/actions_addupdatedelete.inc.php';
195 include DOL_DOCUMENT_ROOT.
'/core/actions_dellink.inc.php';
198 include DOL_DOCUMENT_ROOT.
'/core/actions_printing.inc.php';
204 include DOL_DOCUMENT_ROOT.
'/core/actions_builddoc.inc.php';
206 if ($action ==
'set_thirdparty' && $permissiontoadd) {
207 $object->setValueFrom(
'fk_soc',
GETPOST(
'fk_soc',
'int'),
'',
'',
'date',
'', $user, $triggermodname);
209 if ($action ==
'classin' && $permissiontoadd) {
210 $object->setProject(
GETPOST(
'projectid',
'int'));
214 $triggersendname =
'BOOKCAL_MYOBJECT_SENTBYMAIL';
215 $autocopy =
'MAIN_MAIL_AUTOCOPY_MYOBJECT_TO';
216 $trackid =
'calendar'.$object->id;
217 include DOL_DOCUMENT_ROOT.
'/core/actions_sendmails.inc.php';
227$form =
new Form($db);
231$title = $langs->trans(
"Calendar");
252if ($action ==
'create') {
253 if (empty($permissiontoadd)) {
257 print
load_fiche_titre($langs->trans(
"NewObject", $langs->transnoentitiesnoconv(
"Calendar")),
'',
'object_'.$object->picto);
259 print
'<form method="POST" action="'.$_SERVER[
"PHP_SELF"].
'">';
260 print
'<input type="hidden" name="token" value="'.newToken().
'">';
261 print
'<input type="hidden" name="action" value="add">';
263 print
'<input type="hidden" name="backtopage" value="'.$backtopage.
'">';
265 if ($backtopageforcancel) {
266 print
'<input type="hidden" name="backtopageforcancel" value="'.$backtopageforcancel.
'">';
268 if ($backtopagejsfields) {
269 print
'<input type="hidden" name="backtopagejsfields" value="'.$backtopagejsfields.
'">';
271 if ($dol_openinpopup) {
272 print
'<input type="hidden" name="dol_openinpopup" value="'.$dol_openinpopup.
'">';
280 print
'<table class="border centpercent tableforfieldcreate">'.
"\n";
283 include DOL_DOCUMENT_ROOT.
'/core/tpl/commonfields_add.tpl.php';
286 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_add.tpl.php';
288 print
'</table>'.
"\n";
292 print $form->buttonsSaveCancel(
"Create");
300if (($id || $ref) && $action ==
'edit') {
301 print
load_fiche_titre($langs->trans(
"Calendar"),
'',
'object_'.$object->picto);
303 print
'<form method="POST" action="'.$_SERVER[
"PHP_SELF"].
'">';
304 print
'<input type="hidden" name="token" value="'.newToken().
'">';
305 print
'<input type="hidden" name="action" value="update">';
306 print
'<input type="hidden" name="id" value="'.$object->id.
'">';
308 print
'<input type="hidden" name="backtopage" value="'.$backtopage.
'">';
310 if ($backtopageforcancel) {
311 print
'<input type="hidden" name="backtopageforcancel" value="'.$backtopageforcancel.
'">';
316 print
'<table class="border centpercent tableforfieldedit">'.
"\n";
319 include DOL_DOCUMENT_ROOT.
'/core/tpl/commonfields_edit.tpl.php';
322 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_edit.tpl.php';
328 print $form->buttonsSaveCancel();
334if ($object->id > 0 && (empty($action) || ($action !=
'edit' && $action !=
'create'))) {
337 print
dol_get_fiche_head($head,
'card', $langs->trans(
"Calendar"), -1, $object->picto, 0,
'',
'', 0,
'', 1);
342 if ($action ==
'delete') {
343 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.$object->id, $langs->trans(
'DeleteCalendar'), $langs->trans(
'ConfirmDeleteObject'),
'confirm_delete',
'', 0, 1);
346 if ($action ==
'deleteline') {
347 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.$object->id.
'&lineid='.$lineid, $langs->trans(
'DeleteLine'), $langs->trans(
'ConfirmDeleteLine'),
'confirm_deleteline',
'', 0, 1);
351 if ($action ==
'clone') {
353 $formquestion = array();
354 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.$object->id, $langs->trans(
'ToClone'), $langs->trans(
'ConfirmCloneAsk', $object->ref),
'confirm_clone', $formquestion,
'yes', 1);
358 $parameters = array(
'formConfirm' => $formconfirm,
'lineid' => $lineid);
359 $reshook = $hookmanager->executeHooks(
'formConfirm', $parameters, $object, $action);
360 if (empty($reshook)) {
361 $formconfirm .= $hookmanager->resPrint;
362 } elseif ($reshook > 0) {
363 $formconfirm = $hookmanager->resPrint;
372 $linkback =
'<a href="'.dol_buildpath(
'/bookcal/calendar_list.php', 1).
'?restore_lastsearch_values=1'.(!empty($socid) ?
'&socid='.$socid :
'').
'">'.$langs->trans(
"BackToList").
'</a>';
374 $morehtmlref =
'<div class="refidno">';
406 $morehtmlref .=
'</div>';
409 dol_banner_tab($object,
'ref', $linkback, 1,
'ref',
'ref', $morehtmlref);
412 print
'<div class="fichecenter">';
413 print
'<div class="fichehalfleft">';
414 print
'<div class="underbanner clearboth"></div>';
415 print
'<table class="border centpercent tableforfield">'.
"\n";
421 include DOL_DOCUMENT_ROOT.
'/core/tpl/commonfields_view.tpl.php';
424 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_view.tpl.php';
427 print
'<tr><td>Link</td>';
428 print
'<td><a href="'. DOL_URL_ROOT.
'/public/bookcal/index.php?id='.$object->id.
'" target="_blank">Public page</a>';
435 print
'<div class="clearboth"></div>';
444 if (!empty($object->table_element_line)) {
446 $result = $object->getLinesArray();
448 print
' <form name="addproduct" id="addproduct" action="'.$_SERVER[
"PHP_SELF"].
'?id='.$object->id.(($action !=
'editline') ?
'' :
'#line_'.
GETPOST(
'lineid',
'int')).
'" method="POST">
449 <input type="hidden" name="token" value="' . newToken().
'">
450 <input type="hidden" name="action" value="' . (($action !=
'editline') ?
'addline' :
'updateline').
'">
451 <input type="hidden" name="mode" value="">
452 <input type="hidden" name="page_y" value="">
453 <input type="hidden" name="id" value="' . $object->id.
'">
456 if (!empty($conf->use_javascript_ajax) && $object->status == 0) {
457 include DOL_DOCUMENT_ROOT.
'/core/tpl/ajaxrow.tpl.php';
460 print
'<div class="div-table-responsive-no-min">';
461 if (!empty($object->lines) || ($object->status == $object::STATUS_DRAFT && $permissiontoadd && $action !=
'selectlines' && $action !=
'editline')) {
462 print
'<table id="tablelines" class="noborder noshadow" width="100%">';
465 if (!empty($object->lines)) {
466 $object->printObjectLines($action, $mysoc,
null,
GETPOST(
'lineid',
'int'), 1);
470 if ($object->status == 0 && $permissiontoadd && $action !=
'selectlines') {
471 if ($action !=
'editline') {
474 $parameters = array();
475 $reshook = $hookmanager->executeHooks(
'formAddObjectLine', $parameters, $object, $action);
479 if (empty($reshook)) {
480 $object->formAddObjectLine(1, $mysoc, $soc);
485 if (!empty($object->lines) || ($object->status == $object::STATUS_DRAFT && $permissiontoadd && $action !=
'selectlines' && $action !=
'editline')) {
496 if ($action !=
'presend' && $action !=
'editline') {
497 print
'<div class="tabsAction">'.
"\n";
498 $parameters = array();
499 $reshook = $hookmanager->executeHooks(
'addMoreActionsButtons', $parameters, $object, $action);
504 if (empty($reshook)) {
511 if ($object->status == $object::STATUS_VALIDATED) {
512 print
dolGetButtonAction(
'', $langs->trans(
'SetToDraft'),
'default', $_SERVER[
"PHP_SELF"].
'?id='.$object->id.
'&action=confirm_setdraft&confirm=yes&token='.newToken(),
'', $permissiontoadd);
515 print
dolGetButtonAction(
'', $langs->trans(
'Modify'),
'default', $_SERVER[
"PHP_SELF"].
'?id='.$object->id.
'&action=edit&token='.newToken(),
'', $permissiontoadd);
518 if ($object->status == $object::STATUS_DRAFT) {
519 if (empty($object->table_element_line) || (is_array($object->lines) && count($object->lines) > 0)) {
520 print
dolGetButtonAction(
'', $langs->trans(
'Validate'),
'default', $_SERVER[
'PHP_SELF'].
'?id='.$object->id.
'&action=confirm_validate&confirm=yes&token='.newToken(),
'', $permissiontoadd);
522 $langs->load(
"errors");
523 print
dolGetButtonAction($langs->trans(
"ErrorAddAtLeastOneLineFirst"), $langs->trans(
"Validate"),
'default',
'#',
'', 0);
528 if ($permissiontoadd) {
529 print
dolGetButtonAction(
'', $langs->trans(
'ToClone'),
'default', $_SERVER[
'PHP_SELF'].
'?id='.$object->id.(!empty($object->socid) ?
'&socid='.$object->socid :
'').
'&action=clone&token='.newToken(),
'', $permissiontoadd);
551 print
dolGetButtonAction(
'', $langs->trans(
"Delete"),
'delete', $_SERVER[
"PHP_SELF"].
'?id='.$object->id.
'&action=delete&token='.newToken(),
'delete', $permissiontodelete, $params);
558 if (
GETPOST(
'modelselected')) {
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader()
Empty header.
calendarPrepareHead($object)
Prepare array of tabs for Calendar.
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='', $dragdropfile=0)
Show tabs of a record.
dol_get_fiche_end($notab=0)
Return tab footer of a card.
if(!function_exists( 'dol_getprefix')) dol_include_once($relpath, $classname='')
Make an include_once using default root and alternate root if it fails.
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_buildpath($path, $type=0, $returnemptyifnotfound=0)
Return path of url or filesystem.
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.