28require
'../main.inc.php';
30require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formcompany.class.php';
31require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formfile.class.php';
32require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formprojet.class.php';
33require_once DOL_DOCUMENT_ROOT.
'/bookcal/class/calendar.class.php';
34require_once DOL_DOCUMENT_ROOT.
'/bookcal/lib/bookcal_calendar.lib.php';
37$langs->loadLangs(array(
"agenda",
"other"));
44$action =
GETPOST(
'action',
'aZ09');
45$confirm =
GETPOST(
'confirm',
'alpha');
46$cancel =
GETPOST(
'cancel',
'aZ09');
47$contextpage =
GETPOST(
'contextpage',
'aZ') ?
GETPOST(
'contextpage',
'aZ') : str_replace(
'_',
'', basename(dirname(__FILE__)).basename(__FILE__,
'.php'));
48$backtopage =
GETPOST(
'backtopage',
'alpha');
49$backtopageforcancel =
GETPOST(
'backtopageforcancel',
'alpha');
50$backtopagejsfields =
GETPOST(
'backtopagejsfields',
'alpha');
51$dol_openinpopup =
GETPOST(
'dol_openinpopup',
'aZ09');
53if (!empty($backtopagejsfields)) {
54 $tmpbacktopagejsfields = explode(
':', $backtopagejsfields);
55 $dol_openinpopup = preg_replace(
'/[^a-z0-9_]/i',
'', $tmpbacktopagejsfields[0]);
61$diroutputmassaction = $conf->bookcal->dir_output.
'/temp/massgeneration/'.$user->id;
62$hookmanager->initHooks(array(
'calendarcard',
'globalcard'));
65$extrafields->fetch_name_optionals_label(
$object->table_element);
67$search_array_options = $extrafields->getOptionalsFromPost(
$object->table_element,
'',
'search_');
70$search_all =
GETPOST(
"search_all",
'alpha');
72foreach (
$object->fields as $key => $val) {
73 if (
GETPOST(
'search_'.$key,
'alpha')) {
74 $search[$key] =
GETPOST(
'search_'.$key,
'alpha');
78if (empty($action) && empty($id) && empty($ref)) {
83include DOL_DOCUMENT_ROOT.
'/core/actions_fetchobject.inc.php';
89$enablepermissioncheck = 0;
90if ($enablepermissioncheck) {
91 $permissiontoread = $user->hasRight(
'bookcal',
'calendar',
'read');
92 $permissiontoadd = $user->hasRight(
'bookcal',
'calendar',
'write');
93 $permissiontodelete = $user->hasRight(
'bookcal',
'calendar',
'delete') || ($permissiontoadd && isset(
$object->status) &&
$object->status == $object::STATUS_DRAFT);
94 $permissionnote = $user->hasRight(
'bookcal',
'calendar',
'write');
95 $permissiondellink = $user->hasRight(
'bookcal',
'calendar',
'write');
97 $permissiontoread = 1;
99 $permissiontodelete = 1;
101 $permissiondellink = 1;
104$upload_dir = $conf->bookcal->multidir_output[isset(
$object->entity) ?
$object->entity : 1].
'/calendar';
111if (!isModEnabled(
"bookcal")) {
114if (!$permissiontoread) {
123$parameters = array();
124$reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
129if (empty($reshook)) {
132 $backurlforlist =
dol_buildpath(
'/bookcal/calendar_list.php', 1);
134 if (empty($backtopage) || ($cancel && empty($id))) {
135 if (empty($backtopage) || ($cancel && strpos($backtopage,
'__ID__'))) {
136 if (empty($id) && (($action !=
'add' && $action !=
'create') || $cancel)) {
137 $backtopage = $backurlforlist;
139 $backtopage =
dol_buildpath(
'/bookcal/calendar_card.php', 1).
'?id='.((!empty($id) &&
$id > 0) ? $id :
'__ID__');
144 $triggermodname =
'BOOKCAL_MYOBJECT_MODIFY';
147 include DOL_DOCUMENT_ROOT.
'/core/actions_addupdatedelete.inc.php';
150 include DOL_DOCUMENT_ROOT.
'/core/actions_dellink.inc.php';
153 include DOL_DOCUMENT_ROOT.
'/core/actions_printing.inc.php';
159 include DOL_DOCUMENT_ROOT.
'/core/actions_builddoc.inc.php';
161 if ($action ==
'set_thirdparty' && $permissiontoadd) {
162 $object->setValueFrom(
'fk_soc',
GETPOSTINT(
'fk_soc'),
'',
null,
'date',
'', $user, $triggermodname);
164 if ($action ==
'classin' && $permissiontoadd) {
169 $triggersendname =
'BOOKCAL_MYOBJECT_SENTBYMAIL';
170 $autocopy =
'MAIN_MAIL_AUTOCOPY_MYOBJECT_TO';
171 $trackid =
'calendar'.$object->id;
172 include DOL_DOCUMENT_ROOT.
'/core/actions_sendmails.inc.php';
182$form =
new Form($db);
186$title = $langs->trans(
"Calendar");
188llxHeader(
'', $title, $help_url,
'', 0, 0,
'',
'',
'',
'mod-bookcal page-card_calendar');
207if ($action ==
'create') {
208 if (empty($permissiontoadd)) {
212 print
load_fiche_titre($langs->trans(
"NewObject", $langs->transnoentitiesnoconv(
"Calendar")),
'',
'object_'.$object->picto);
214 print
'<form method="POST" action="'.$_SERVER[
"PHP_SELF"].
'">';
215 print
'<input type="hidden" name="token" value="'.newToken().
'">';
216 print
'<input type="hidden" name="action" value="add">';
218 print
'<input type="hidden" name="backtopage" value="'.$backtopage.
'">';
220 if ($backtopageforcancel) {
221 print
'<input type="hidden" name="backtopageforcancel" value="'.$backtopageforcancel.
'">';
223 if ($backtopagejsfields) {
224 print
'<input type="hidden" name="backtopagejsfields" value="'.$backtopagejsfields.
'">';
226 if ($dol_openinpopup) {
227 print
'<input type="hidden" name="dol_openinpopup" value="'.$dol_openinpopup.
'">';
233 print
'<table class="border centpercent tableforfieldcreate">'.
"\n";
236 include DOL_DOCUMENT_ROOT.
'/core/tpl/commonfields_add.tpl.php';
239 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_add.tpl.php';
241 print
'</table>'.
"\n";
245 print $form->buttonsSaveCancel(
"Create");
253if (($id || $ref) && $action ==
'edit') {
254 print
load_fiche_titre($langs->trans(
"Calendar"),
'',
'object_'.$object->picto);
256 print
'<form method="POST" action="'.$_SERVER[
"PHP_SELF"].
'">';
257 print
'<input type="hidden" name="token" value="'.newToken().
'">';
258 print
'<input type="hidden" name="action" value="update">';
259 print
'<input type="hidden" name="id" value="'.$object->id.
'">';
261 print
'<input type="hidden" name="backtopage" value="'.$backtopage.
'">';
263 if ($backtopageforcancel) {
264 print
'<input type="hidden" name="backtopageforcancel" value="'.$backtopageforcancel.
'">';
269 print
'<table class="border centpercent tableforfieldedit">'.
"\n";
272 include DOL_DOCUMENT_ROOT.
'/core/tpl/commonfields_edit.tpl.php';
275 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_edit.tpl.php';
281 print $form->buttonsSaveCancel();
287if (
$object->id > 0 && (empty($action) || ($action !=
'edit' && $action !=
'create'))) {
290 print
dol_get_fiche_head($head,
'card', $langs->trans(
"Calendar"), -1,
$object->picto, 0,
'',
'', 0,
'', 1);
295 if ($action ==
'delete') {
296 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.
$object->id, $langs->trans(
'DeleteCalendar'), $langs->trans(
'ConfirmDeleteObject'),
'confirm_delete',
'', 0, 1);
299 if ($action ==
'deleteline') {
300 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&lineid='.$lineid, $langs->trans(
'DeleteLine'), $langs->trans(
'ConfirmDeleteLine'),
'confirm_deleteline',
'', 0, 1);
304 if ($action ==
'clone') {
306 $formquestion = array();
307 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.
$object->id, $langs->trans(
'ToClone'), $langs->trans(
'ConfirmCloneAsk',
$object->ref),
'confirm_clone', $formquestion,
'yes', 1);
311 $parameters = array(
'formConfirm' => $formconfirm,
'lineid' => $lineid);
312 $reshook = $hookmanager->executeHooks(
'formConfirm', $parameters, $object, $action);
313 if (empty($reshook)) {
314 $formconfirm .= $hookmanager->resPrint;
315 } elseif ($reshook > 0) {
316 $formconfirm = $hookmanager->resPrint;
325 $linkback =
'<a href="'.dol_buildpath(
'/bookcal/calendar_list.php', 1).
'?restore_lastsearch_values=1'.(!empty($socid) ?
'&socid='.$socid :
'').
'">'.$langs->trans(
"BackToList").
'</a>';
327 $morehtmlref =
'<div class="refidno">';
359 $morehtmlref .=
'</div>';
362 dol_banner_tab($object,
'ref', $linkback, 1,
'ref',
'ref', $morehtmlref);
365 print
'<div class="fichecenter">';
366 print
'<div class="fichehalfleft">';
367 print
'<div class="underbanner clearboth"></div>';
368 print
'<table class="border centpercent tableforfield">'.
"\n";
374 include DOL_DOCUMENT_ROOT.
'/core/tpl/commonfields_view.tpl.php';
377 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_view.tpl.php';
380 print
'<tr><td>Link</td>';
381 print
'<td><a href="'. DOL_URL_ROOT.
'/public/bookcal/index.php?id='.
$object->id.
'" target="_blank">Public page</a>';
388 print
'<div class="clearboth"></div>';
397 if (!empty(
$object->table_element_line)) {
399 $result =
$object->getLinesArray();
401 print
' <form name="addproduct" id="addproduct" action="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.(($action !=
'editline') ?
'' :
'#line_'.
GETPOSTINT(
'lineid')).
'" method="POST">
402 <input type="hidden" name="token" value="' .
newToken().
'">
403 <input type="hidden" name="action" value="' . (($action !=
'editline') ?
'addline' :
'updateline').
'">
404 <input type="hidden" name="mode" value="">
405 <input type="hidden" name="page_y" value="">
406 <input type="hidden" name="id" value="' .
$object->id.
'">
409 if (!empty($conf->use_javascript_ajax) &&
$object->status == 0) {
410 include DOL_DOCUMENT_ROOT.
'/core/tpl/ajaxrow.tpl.php';
413 print
'<div class="div-table-responsive-no-min">';
414 if (!empty(
$object->lines) || (
$object->status == $object::STATUS_DRAFT && $permissiontoadd && $action !=
'selectlines' && $action !=
'editline')) {
415 print
'<table id="tablelines" class="noborder noshadow" width="100%">';
423 if (
$object->status == 0 && $permissiontoadd && $action !=
'selectlines') {
424 if ($action !=
'editline') {
427 $parameters = array();
428 $reshook = $hookmanager->executeHooks(
'formAddObjectLine', $parameters, $object, $action);
432 if (empty($reshook)) {
433 $object->formAddObjectLine(1, $mysoc, $soc);
438 if (!empty(
$object->lines) || (
$object->status == $object::STATUS_DRAFT && $permissiontoadd && $action !=
'selectlines' && $action !=
'editline')) {
449 if ($action !=
'presend' && $action !=
'editline') {
450 print
'<div class="tabsAction">'.
"\n";
451 $parameters = array();
452 $reshook = $hookmanager->executeHooks(
'addMoreActionsButtons', $parameters, $object, $action);
457 if (empty($reshook)) {
464 if (
$object->status == $object::STATUS_VALIDATED) {
465 print
dolGetButtonAction(
'', $langs->trans(
'SetToDraft'),
'default', $_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&action=confirm_setdraft&confirm=yes&token='.
newToken(),
'', $permissiontoadd);
468 print
dolGetButtonAction(
'', $langs->trans(
'Modify'),
'default', $_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&action=edit&token='.
newToken(),
'', $permissiontoadd);
471 if (
$object->status == $object::STATUS_DRAFT) {
473 print
dolGetButtonAction(
'', $langs->trans(
'Validate'),
'default', $_SERVER[
'PHP_SELF'].
'?id='.
$object->id.
'&action=confirm_validate&confirm=yes&token='.
newToken(),
'', $permissiontoadd);
475 $langs->load(
"errors");
476 print
dolGetButtonAction($langs->trans(
"ErrorAddAtLeastOneLineFirst"), $langs->trans(
"Validate"),
'default',
'#',
'', 0);
481 if ($permissiontoadd) {
482 print
dolGetButtonAction(
'', $langs->trans(
'ToClone'),
'default', $_SERVER[
'PHP_SELF'].
'?id='.
$object->id.(!empty(
$object->socid) ?
'&socid='.$object->socid :
'').
'&action=clone&token='.
newToken(),
'', $permissiontoadd);
504 print
dolGetButtonAction(
'', $langs->trans(
"Delete"),
'delete', $_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&action=delete&token='.
newToken(),
'delete', $permissiontodelete, $params);
511 if (
GETPOST(
'modelselected')) {
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.
calendarPrepareHead($object)
Prepare array of tabs for Calendar.
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.
dol_get_fiche_end($notab=0)
Return tab footer of a card.
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.
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.