27require 
'../main.inc.php';
 
   29require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formcompany.class.php';
 
   30require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formfile.class.php';
 
   31require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formprojet.class.php';
 
   32require_once DOL_DOCUMENT_ROOT.
'/bookcal/class/calendar.class.php';
 
   33require_once DOL_DOCUMENT_ROOT.
'/bookcal/lib/bookcal_calendar.lib.php';
 
   36$langs->loadLangs(array(
"agenda", 
"other"));
 
   43$action = 
GETPOST(
'action', 
'aZ09');
 
   44$confirm = 
GETPOST(
'confirm', 
'alpha');
 
   45$cancel = 
GETPOST(
'cancel', 
'aZ09');
 
   46$contextpage = 
GETPOST(
'contextpage', 
'aZ') ? 
GETPOST(
'contextpage', 
'aZ') : str_replace(
'_', 
'', basename(dirname(__FILE__)).basename(__FILE__, 
'.php')); 
 
   47$backtopage = 
GETPOST(
'backtopage', 
'alpha');         
 
   48$backtopageforcancel = 
GETPOST(
'backtopageforcancel', 
'alpha'); 
 
   49$backtopagejsfields = 
GETPOST(
'backtopagejsfields', 
'alpha');
 
   50$dol_openinpopup = 
GETPOST(
'dol_openinpopup', 
'aZ09');
 
   52if (!empty($backtopagejsfields)) {
 
   53  $tmpbacktopagejsfields = explode(
':', $backtopagejsfields);
 
   54  $dol_openinpopup = preg_replace(
'/[^a-z0-9_]/i', 
'', $tmpbacktopagejsfields[0]);
 
   60$diroutputmassaction = $conf->bookcal->dir_output.
'/temp/massgeneration/'.$user->id;
 
   61$hookmanager->initHooks(array(
'calendarcard', 
'globalcard')); 
 
   64$extrafields->fetch_name_optionals_label(
$object->table_element);
 
   66$search_array_options = $extrafields->getOptionalsFromPost(
$object->table_element, 
'', 
'search_');
 
   69$search_all = 
GETPOST(
"search_all", 
'alpha');
 
   71foreach (
$object->fields as $key => $val) {
 
   72  if (
GETPOST(
'search_'.$key, 
'alpha')) {
 
   73    $search[$key] = 
GETPOST(
'search_'.$key, 
'alpha');
 
   77if (empty($action) && empty($id) && empty($ref)) {
 
   82include DOL_DOCUMENT_ROOT.
'/core/actions_fetchobject.inc.php'; 
 
   88$enablepermissioncheck = 0;
 
   89if ($enablepermissioncheck) {
 
   90  $permissiontoread = $user->hasRight(
'bookcal', 
'calendar', 
'read');
 
   91  $permissiontoadd = $user->hasRight(
'bookcal', 
'calendar', 
'write'); 
 
   92  $permissiontodelete = $user->hasRight(
'bookcal', 
'calendar', 
'delete') || ($permissiontoadd && isset(
$object->status) && 
$object->status == $object::STATUS_DRAFT);
 
   93  $permissionnote = $user->hasRight(
'bookcal', 
'calendar', 
'write'); 
 
   94  $permissiondellink = $user->hasRight(
'bookcal', 
'calendar', 
'write'); 
 
   96  $permissiontoread = 1;
 
   98  $permissiontodelete = 1;
 
  100  $permissiondellink = 1;
 
  103$upload_dir = $conf->bookcal->multidir_output[isset(
$object->entity) ? 
$object->entity : 1].
'/calendar';
 
  110if (!isModEnabled(
"bookcal")) {
 
  113if (!$permissiontoread) {
 
  122$parameters = array();
 
  123$reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action); 
 
  128if (empty($reshook)) {
 
  131  $backurlforlist = 
dol_buildpath(
'/bookcal/calendar_list.php', 1);
 
  133  if (empty($backtopage) || ($cancel && empty($id))) {
 
  134    if (empty($backtopage) || ($cancel && strpos($backtopage, 
'__ID__'))) {
 
  135      if (empty($id) && (($action != 
'add' && $action != 
'create') || $cancel)) {
 
  136        $backtopage = $backurlforlist;
 
  138        $backtopage = 
dol_buildpath(
'/bookcal/calendar_card.php', 1).
'?id='.((!empty($id) && $id > 0) ? $id : 
'__ID__');
 
  143  $triggermodname = 
'BOOKCAL_MYOBJECT_MODIFY'; 
 
  146  include DOL_DOCUMENT_ROOT.
'/core/actions_addupdatedelete.inc.php';
 
  149  include DOL_DOCUMENT_ROOT.
'/core/actions_dellink.inc.php';
 
  152  include DOL_DOCUMENT_ROOT.
'/core/actions_printing.inc.php';
 
  158  include DOL_DOCUMENT_ROOT.
'/core/actions_builddoc.inc.php';
 
  160  if ($action == 
'set_thirdparty' && $permissiontoadd) {
 
  161    $object->setValueFrom(
'fk_soc', 
GETPOSTINT(
'fk_soc'), 
'', 
'', 
'date', 
'', $user, $triggermodname);
 
  163  if ($action == 
'classin' && $permissiontoadd) {
 
  168  $triggersendname = 
'BOOKCAL_MYOBJECT_SENTBYMAIL';
 
  169  $autocopy = 
'MAIN_MAIL_AUTOCOPY_MYOBJECT_TO';
 
  170  $trackid = 
'calendar'.$object->id;
 
  171  include DOL_DOCUMENT_ROOT.
'/core/actions_sendmails.inc.php';
 
  181$form = 
new Form($db);
 
  185$title = $langs->trans(
"Calendar");
 
  206if ($action == 
'create') {
 
  207  if (empty($permissiontoadd)) {
 
  211  print 
load_fiche_titre($langs->trans(
"NewObject", $langs->transnoentitiesnoconv(
"Calendar")), 
'', 
'object_'.$object->picto);
 
  213  print 
'<form method="POST" action="'.$_SERVER[
"PHP_SELF"].
'">';
 
  214  print 
'<input type="hidden" name="token" value="'.newToken().
'">';
 
  215  print 
'<input type="hidden" name="action" value="add">';
 
  217    print 
'<input type="hidden" name="backtopage" value="'.$backtopage.
'">';
 
  219  if ($backtopageforcancel) {
 
  220    print 
'<input type="hidden" name="backtopageforcancel" value="'.$backtopageforcancel.
'">';
 
  222  if ($backtopagejsfields) {
 
  223    print 
'<input type="hidden" name="backtopagejsfields" value="'.$backtopagejsfields.
'">';
 
  225  if ($dol_openinpopup) {
 
  226    print 
'<input type="hidden" name="dol_openinpopup" value="'.$dol_openinpopup.
'">';
 
  232  print 
'<table class="border centpercent tableforfieldcreate">'.
"\n";
 
  235  include DOL_DOCUMENT_ROOT.
'/core/tpl/commonfields_add.tpl.php';
 
  238  include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_add.tpl.php';
 
  240  print 
'</table>'.
"\n";
 
  244  print $form->buttonsSaveCancel(
"Create");
 
  252if (($id || $ref) && $action == 
'edit') {
 
  253  print 
load_fiche_titre($langs->trans(
"Calendar"), 
'', 
'object_'.$object->picto);
 
  255  print 
'<form method="POST" action="'.$_SERVER[
"PHP_SELF"].
'">';
 
  256  print 
'<input type="hidden" name="token" value="'.newToken().
'">';
 
  257  print 
'<input type="hidden" name="action" value="update">';
 
  258  print 
'<input type="hidden" name="id" value="'.$object->id.
'">';
 
  260    print 
'<input type="hidden" name="backtopage" value="'.$backtopage.
'">';
 
  262  if ($backtopageforcancel) {
 
  263    print 
'<input type="hidden" name="backtopageforcancel" value="'.$backtopageforcancel.
'">';
 
  268  print 
'<table class="border centpercent tableforfieldedit">'.
"\n";
 
  271  include DOL_DOCUMENT_ROOT.
'/core/tpl/commonfields_edit.tpl.php';
 
  274  include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_edit.tpl.php';
 
  280  print $form->buttonsSaveCancel();
 
  286if (
$object->id > 0 && (empty($action) || ($action != 
'edit' && $action != 
'create'))) {
 
  289  print 
dol_get_fiche_head($head, 
'card', $langs->trans(
"Calendar"), -1, 
$object->picto, 0, 
'', 
'', 0, 
'', 1);
 
  294  if ($action == 
'delete') {
 
  295    $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.
$object->id, $langs->trans(
'DeleteCalendar'), $langs->trans(
'ConfirmDeleteObject'), 
'confirm_delete', 
'', 0, 1);
 
  298  if ($action == 
'deleteline') {
 
  299    $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&lineid='.$lineid, $langs->trans(
'DeleteLine'), $langs->trans(
'ConfirmDeleteLine'), 
'confirm_deleteline', 
'', 0, 1);
 
  303  if ($action == 
'clone') {
 
  305    $formquestion = array();
 
  306    $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.
$object->id, $langs->trans(
'ToClone'), $langs->trans(
'ConfirmCloneAsk', 
$object->ref), 
'confirm_clone', $formquestion, 
'yes', 1);
 
  310  $parameters = array(
'formConfirm' => $formconfirm, 
'lineid' => $lineid);
 
  311  $reshook = $hookmanager->executeHooks(
'formConfirm', $parameters, $object, $action); 
 
  312  if (empty($reshook)) {
 
  313    $formconfirm .= $hookmanager->resPrint;
 
  314  } elseif ($reshook > 0) {
 
  315    $formconfirm = $hookmanager->resPrint;
 
  324  $linkback = 
'<a href="'.dol_buildpath(
'/bookcal/calendar_list.php', 1).
'?restore_lastsearch_values=1'.(!empty($socid) ? 
'&socid='.$socid : 
'').
'">'.$langs->trans(
"BackToList").
'</a>';
 
  326  $morehtmlref = 
'<div class="refidno">';
 
  358  $morehtmlref .= 
'</div>';
 
  361  dol_banner_tab($object, 
'ref', $linkback, 1, 
'ref', 
'ref', $morehtmlref);
 
  364  print 
'<div class="fichecenter">';
 
  365  print 
'<div class="fichehalfleft">';
 
  366  print 
'<div class="underbanner clearboth"></div>';
 
  367  print 
'<table class="border centpercent tableforfield">'.
"\n";
 
  373  include DOL_DOCUMENT_ROOT.
'/core/tpl/commonfields_view.tpl.php';
 
  376  include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_view.tpl.php';
 
  379  print 
'<tr><td>Link</td>';
 
  380  print 
'<td><a href="'. DOL_URL_ROOT.
'/public/bookcal/index.php?id='.
$object->id.
'" target="_blank">Public page</a>';
 
  387  print 
'<div class="clearboth"></div>';
 
  396  if (!empty(
$object->table_element_line)) {
 
  398    $result = 
$object->getLinesArray();
 
  400    print 
' <form name="addproduct" id="addproduct" action="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.(($action != 
'editline') ? 
'' : 
'#line_'.
GETPOSTINT(
'lineid')).
'" method="POST"> 
  401    <input type="hidden" name="token" value="' . 
newToken().
'"> 
  402    <input type="hidden" name="action" value="' . (($action != 
'editline') ? 
'addline' : 
'updateline').
'"> 
  403    <input type="hidden" name="mode" value=""> 
  404    <input type="hidden" name="page_y" value=""> 
  405    <input type="hidden" name="id" value="' . 
$object->id.
'"> 
  408    if (!empty($conf->use_javascript_ajax) && 
$object->status == 0) {
 
  409      include DOL_DOCUMENT_ROOT.
'/core/tpl/ajaxrow.tpl.php';
 
  412    print 
'<div class="div-table-responsive-no-min">';
 
  413    if (!empty(
$object->lines) || (
$object->status == $object::STATUS_DRAFT && $permissiontoadd && $action != 
'selectlines' && $action != 
'editline')) {
 
  414      print 
'<table id="tablelines" class="noborder noshadow" width="100%">';
 
  422    if (
$object->status == 0 && $permissiontoadd && $action != 
'selectlines') {
 
  423      if ($action != 
'editline') {
 
  426        $parameters = array();
 
  427        $reshook = $hookmanager->executeHooks(
'formAddObjectLine', $parameters, $object, $action); 
 
  431        if (empty($reshook)) {
 
  432          $object->formAddObjectLine(1, $mysoc, $soc);
 
  437    if (!empty(
$object->lines) || (
$object->status == $object::STATUS_DRAFT && $permissiontoadd && $action != 
'selectlines' && $action != 
'editline')) {
 
  448  if ($action != 
'presend' && $action != 
'editline') {
 
  449    print 
'<div class="tabsAction">'.
"\n";
 
  450    $parameters = array();
 
  451    $reshook = $hookmanager->executeHooks(
'addMoreActionsButtons', $parameters, $object, $action); 
 
  456    if (empty($reshook)) {
 
  463      if (
$object->status == $object::STATUS_VALIDATED) {
 
  464        print 
dolGetButtonAction(
'', $langs->trans(
'SetToDraft'), 
'default', $_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&action=confirm_setdraft&confirm=yes&token='.
newToken(), 
'', $permissiontoadd);
 
  467      print 
dolGetButtonAction(
'', $langs->trans(
'Modify'), 
'default', $_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&action=edit&token='.
newToken(), 
'', $permissiontoadd);
 
  470      if (
$object->status == $object::STATUS_DRAFT) {
 
  472          print 
dolGetButtonAction(
'', $langs->trans(
'Validate'), 
'default', $_SERVER[
'PHP_SELF'].
'?id='.
$object->id.
'&action=confirm_validate&confirm=yes&token='.
newToken(), 
'', $permissiontoadd);
 
  474          $langs->load(
"errors");
 
  475          print 
dolGetButtonAction($langs->trans(
"ErrorAddAtLeastOneLineFirst"), $langs->trans(
"Validate"), 
'default', 
'#', 
'', 0);
 
  480      if ($permissiontoadd) {
 
  481        print 
dolGetButtonAction(
'', $langs->trans(
'ToClone'), 
'default', $_SERVER[
'PHP_SELF'].
'?id='.
$object->id.(!empty(
$object->socid) ? 
'&socid='.$object->socid : 
'').
'&action=clone&token='.
newToken(), 
'', $permissiontoadd);
 
  503      print 
dolGetButtonAction(
'', $langs->trans(
"Delete"), 
'delete', $_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&action=delete&token='.
newToken(), 
'delete', $permissiontodelete, $params);
 
  510  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()
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.
 
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.
 
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.