26require
'../main.inc.php';
27require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formcompany.class.php';
28require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formfile.class.php';
29require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formprojet.class.php';
30require_once DOL_DOCUMENT_ROOT.
'/bookcal/class/availabilities.class.php';
31require_once DOL_DOCUMENT_ROOT.
'/bookcal/lib/bookcal_availabilities.lib.php';
34$langs->loadLangs(array(
"agenda",
"other"));
41$action =
GETPOST(
'action',
'aZ09');
42$confirm =
GETPOST(
'confirm',
'alpha');
43$cancel =
GETPOST(
'cancel',
'aZ09');
44$contextpage =
GETPOST(
'contextpage',
'aZ') ?
GETPOST(
'contextpage',
'aZ') : str_replace(
'_',
'', basename(dirname(__FILE__)).basename(__FILE__,
'.php'));
45$backtopage =
GETPOST(
'backtopage',
'alpha');
46$backtopageforcancel =
GETPOST(
'backtopageforcancel',
'alpha');
47$dol_openinpopup =
GETPOST(
'dol_openinpopup',
'aZ09');
52$diroutputmassaction = $conf->bookcal->dir_output.
'/temp/massgeneration/'.$user->id;
53$hookmanager->initHooks(array(
'availabilitiescard',
'globalcard'));
56$extrafields->fetch_name_optionals_label(
$object->table_element);
58$search_array_options = $extrafields->getOptionalsFromPost(
$object->table_element,
'',
'search_');
61$search_all =
GETPOST(
"search_all",
'alpha');
63foreach (
$object->fields as $key => $val) {
64 if (
GETPOST(
'search_'.$key,
'alpha')) {
65 $search[$key] =
GETPOST(
'search_'.$key,
'alpha');
69if (empty($action) && empty($id) && empty($ref)) {
74include DOL_DOCUMENT_ROOT.
'/core/actions_fetchobject.inc.php';
81$enablepermissioncheck = 0;
82if ($enablepermissioncheck) {
83 $permissiontoread = $user->hasRight(
'bookcal',
'availabilities',
'read');
84 $permissiontoadd = $user->hasRight(
'bookcal',
'availabilities',
'write');
85 $permissiontodelete = $user->hasRight(
'bookcal',
'availabilities',
'delete') || ($permissiontoadd && isset(
$object->status) &&
$object->status == $object::STATUS_DRAFT);
86 $permissionnote = $user->hasRight(
'bookcal',
'availabilities',
'write');
87 $permissiondellink = $user->hasRight(
'bookcal',
'availabilities',
'write');
89 $permissiontoread = 1;
91 $permissiontodelete = 1;
93 $permissiondellink = 1;
96$upload_dir = $conf->bookcal->multidir_output[isset(
$object->entity) ?
$object->entity : 1].
'/availabilities';
103if (!isModEnabled(
'bookcal')) {
106if (!$permissiontoread) {
119$parameters = array();
120$reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
125if (empty($reshook)) {
128 $backurlforlist =
dol_buildpath(
'/bookcal/availabilities_list.php', 1);
130 if (empty($backtopage) || ($cancel && empty($id))) {
131 if (empty($backtopage) || ($cancel && strpos($backtopage,
'__ID__'))) {
132 if (empty($id) && (($action !=
'add' && $action !=
'create') || $cancel)) {
133 $backtopage = $backurlforlist;
135 $backtopage =
dol_buildpath(
'/bookcal/availabilities_card.php', 1).
'?id='.((!empty($id) && $id > 0) ? $id :
'__ID__');
140 $triggermodname =
'BOOKCAL_AVAILABILITIES_MODIFY';
143 $startday =
GETPOST(
'startday',
'int');
144 $startmonth =
GETPOST(
'startmonth',
'int');
145 $startyear =
GETPOST(
'startyear',
'int');
146 $starthour =
GETPOST(
'startHour',
'int');
148 if ($starthour ==
"0") {
150 setEventMessages($langs->trans(
"ErrorStartHourIsNull"), $hookmanager->errors,
'errors');
153 $dateStartTimestamp =
dol_mktime($starthour, 0, 0, $startmonth, $startday, $startyear);
155 $endday =
GETPOST(
'endday',
'int');
156 $endmonth =
GETPOST(
'endmonth',
'int');
157 $endyear =
GETPOST(
'endyear',
'int');
158 $endhour =
GETPOST(
'endHour',
'int');
160 if ($endhour ==
"0") {
162 setEventMessages($langs->trans(
"ErrorEndHourIsNull"), $hookmanager->errors,
'errors');
165 $dateEndTimestamp =
dol_mktime($endhour, 0, 0, $endmonth, $endday, $endyear);
168 if ($starthour > $endhour) {
169 if ($dateStartTimestamp === $dateEndTimestamp) {
171 setEventMessages($langs->trans(
"ErrorEndTimeMustBeGreaterThanStartTime"), $hookmanager->errors,
'errors');
176 if (($dateStartTimestamp !=
"") && ($dateStartTimestamp >= $dateEndTimestamp)) {
178 setEventMessages($langs->trans(
"ErrorIncoherentDates"), $hookmanager->errors,
'errors');
183 include DOL_DOCUMENT_ROOT.
'/core/actions_addupdatedelete.inc.php';
186 include DOL_DOCUMENT_ROOT.
'/core/actions_dellink.inc.php';
189 include DOL_DOCUMENT_ROOT.
'/core/actions_printing.inc.php';
195 include DOL_DOCUMENT_ROOT.
'/core/actions_builddoc.inc.php';
197 if ($action ==
'set_thirdparty' && $permissiontoadd) {
198 $object->setValueFrom(
'fk_soc',
GETPOSTINT(
'fk_soc'),
'',
'',
'date',
'', $user, $triggermodname);
200 if ($action ==
'classin' && $permissiontoadd) {
205 $triggersendname =
'BOOKCAL_AVAILABILITIES_SENTBYMAIL';
206 $autocopy =
'MAIN_MAIL_AUTOCOPY_AVAILABILITIES_TO';
207 $trackid =
'availabilities'.$object->id;
208 include DOL_DOCUMENT_ROOT.
'/core/actions_sendmails.inc.php';
220$form =
new Form($db);
224$title = $langs->trans(
"Availabilities");
245if ($action ==
'create') {
246 if (empty($permissiontoadd)) {
251 print
load_fiche_titre($langs->trans(
"NewAvailabilities"),
'',
'',
'object_'.$object->picto);
252 print
'<form method="POST" action="'.$_SERVER[
"PHP_SELF"].
'">';
253 print
'<input type="hidden" name="token" value="'.newToken().
'">';
255 print
'<input type="hidden" name="action" value="create">';
257 print
'<input type="hidden" name="action" value="add">';
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 tableforfieldcreate">'.
"\n";
271 include DOL_DOCUMENT_ROOT.
'/core/tpl/commonfields_add.tpl.php';
274 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_add.tpl.php';
276 print
'</table>'.
"\n";
280 print $form->buttonsSaveCancel(
"Create");
288if (($id || $ref) && $action ==
'edit') {
289 print
load_fiche_titre($langs->trans(
"Availabilities"),
'',
'object_'.$object->picto);
291 print
'<form method="POST" action="'.$_SERVER[
"PHP_SELF"].
'">';
292 print
'<input type="hidden" name="token" value="'.newToken().
'">';
293 print
'<input type="hidden" name="action" value="update">';
294 print
'<input type="hidden" name="id" value="'.$object->id.
'">';
296 print
'<input type="hidden" name="backtopage" value="'.$backtopage.
'">';
298 if ($backtopageforcancel) {
299 print
'<input type="hidden" name="backtopageforcancel" value="'.$backtopageforcancel.
'">';
304 print
'<table class="border centpercent tableforfieldedit">'.
"\n";
307 include DOL_DOCUMENT_ROOT.
'/core/tpl/commonfields_edit.tpl.php';
310 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_edit.tpl.php';
316 print $form->buttonsSaveCancel();
322if (
$object->id > 0 && (empty($action) || ($action !=
'edit' && $action !=
'create'))) {
323 $res =
$object->fetch_optionals();
331 if ($action ==
'delete') {
332 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.
$object->id, $langs->trans(
'DeleteAvailabilities'), $langs->trans(
'ConfirmDeleteObject'),
'confirm_delete',
'', 0, 1);
335 if ($action ==
'deleteline') {
336 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&lineid='.$lineid, $langs->trans(
'DeleteLine'), $langs->trans(
'ConfirmDeleteLine'),
'confirm_deleteline',
'', 0, 1);
340 if ($action ==
'clone') {
342 $formquestion = array();
343 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.
$object->id, $langs->trans(
'ToClone'), $langs->trans(
'ConfirmCloneAsk',
$object->ref),
'confirm_clone', $formquestion,
'yes', 1);
348 if ($action ==
'xxx') {
349 $text = $langs->trans(
'ConfirmActionAvailabilities',
$object->ref);
358 $formquestion = array();
369 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.
$object->id, $langs->trans(
'XXX'), $text,
'confirm_xxx', $formquestion, 0, 1, 220);
373 $parameters = array(
'formConfirm' => $formconfirm,
'lineid' => $lineid);
374 $reshook = $hookmanager->executeHooks(
'formConfirm', $parameters, $object, $action);
375 if (empty($reshook)) {
376 $formconfirm .= $hookmanager->resPrint;
377 } elseif ($reshook > 0) {
378 $formconfirm = $hookmanager->resPrint;
387 $linkback =
'<a href="'.dol_buildpath(
'/bookcal/availabilities_list.php', 1).
'?restore_lastsearch_values=1'.(!empty($socid) ?
'&socid='.$socid :
'').
'">'.$langs->trans(
"BackToList").
'</a>';
389 $morehtmlref =
'<div class="refidno">';
424 $morehtmlref .=
'</div>';
427 dol_banner_tab($object,
'ref', $linkback, 1,
'ref',
'ref', $morehtmlref);
430 print
'<div class="fichecenter">';
431 print
'<div class="fichehalfleft">';
432 print
'<div class="underbanner clearboth"></div>';
433 print
'<table class="border centpercent tableforfield">'.
"\n";
439 include DOL_DOCUMENT_ROOT.
'/core/tpl/commonfields_view.tpl.php';
442 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_view.tpl.php';
448 print
'<div class="clearboth"></div>';
457 if (!empty(
$object->table_element_line)) {
459 $result =
$object->getLinesArray();
461 print
' <form name="addproduct" id="addproduct" action="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.(($action !=
'editline') ?
'' :
'#line_'.
GETPOSTINT(
'lineid')).
'" method="POST">
462 <input type="hidden" name="token" value="' .
newToken().
'">
463 <input type="hidden" name="action" value="' . (($action !=
'editline') ?
'addline' :
'updateline').
'">
464 <input type="hidden" name="mode" value="">
465 <input type="hidden" name="page_y" value="">
466 <input type="hidden" name="id" value="' .
$object->id.
'">
469 if (!empty($conf->use_javascript_ajax) &&
$object->status == 0) {
470 include DOL_DOCUMENT_ROOT.
'/core/tpl/ajaxrow.tpl.php';
473 print
'<div class="div-table-responsive-no-min">';
474 if (!empty(
$object->lines) || (
$object->status == $object::STATUS_DRAFT && $permissiontoadd && $action !=
'selectlines' && $action !=
'editline')) {
475 print
'<table id="tablelines" class="noborder noshadow" width="100%">';
483 if (
$object->status == 0 && $permissiontoadd && $action !=
'selectlines') {
484 if ($action !=
'editline') {
487 $parameters = array();
488 $reshook = $hookmanager->executeHooks(
'formAddObjectLine', $parameters, $object, $action);
492 if (empty($reshook)) {
493 $object->formAddObjectLine(1, $mysoc, $soc);
498 if (!empty(
$object->lines) || (
$object->status == $object::STATUS_DRAFT && $permissiontoadd && $action !=
'selectlines' && $action !=
'editline')) {
509 if ($action !=
'presend' && $action !=
'editline') {
510 print
'<div class="tabsAction">'.
"\n";
511 $parameters = array();
512 $reshook = $hookmanager->executeHooks(
'addMoreActionsButtons', $parameters, $object, $action);
517 if (empty($reshook)) {
519 if (empty($user->socid)) {
520 print
dolGetButtonAction($langs->trans(
'SendMail'),
'',
'default', $_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&action=presend&mode=init&token='.
newToken().
'#formmailbeforetitle');
524 if (
$object->status == $object::STATUS_VALIDATED) {
525 print
dolGetButtonAction($langs->trans(
'SetToDraft'),
'',
'default', $_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&action=confirm_setdraft&confirm=yes&token='.
newToken(),
'', $permissiontoadd);
528 print
dolGetButtonAction($langs->trans(
'Modify'),
'',
'default', $_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&action=edit&token='.
newToken(),
'', $permissiontoadd);
531 if (
$object->status == $object::STATUS_DRAFT) {
533 print
dolGetButtonAction($langs->trans(
'Validate'),
'',
'default', $_SERVER[
'PHP_SELF'].
'?id='.
$object->id.
'&action=confirm_validate&confirm=yes&token='.
newToken(),
'', $permissiontoadd);
535 $langs->load(
"errors");
536 print
dolGetButtonAction($langs->trans(
"ErrorAddAtLeastOneLineFirst"), $langs->trans(
"Validate"),
'default',
'#',
'', 0);
541 print
dolGetButtonAction($langs->trans(
'ToClone'),
'',
'default', $_SERVER[
'PHP_SELF'].
'?id='.
$object->id.(!empty(
$object->socid) ?
'&socid='.$object->socid :
'').
'&action=clone&token='.
newToken(),
'', $permissiontoadd);
561 print
dolGetButtonAction($langs->trans(
'Delete'),
'',
'delete', $_SERVER[
'PHP_SELF'].
'?id='.
$object->id.
'&action=delete&token='.
newToken(),
'', $permissiontodelete || (
$object->status == $object::STATUS_DRAFT && $permissiontoadd));
568 if (
GETPOST(
'modelselected')) {
572 if ($action !=
'presend') {
573 print
'<div class="fichecenter"><div class="fichehalfleft">';
574 print
'<a name="builddoc"></a>';
576 $includedocgeneration = 0;
579 if ($includedocgeneration) {
581 $relativepath = $objref.
'/'.$objref.
'.pdf';
582 $filedir = $conf->bookcal->dir_output.
'/'.
$object->element.
'/'.$objref;
583 $urlsource = $_SERVER[
"PHP_SELF"].
"?id=".
$object->id;
584 $genallowed = $permissiontoread;
585 $delallowed = $permissiontoadd;
586 print $formfile->showdocuments(
'bookcal:Availabilities',
$object->element.
'/'.$objref, $filedir, $urlsource, $genallowed, $delallowed,
$object->model_pdf, 1, 0, 0, 28, 0,
'',
'',
'', $langs->defaultlang);
590 $linktoelem = $form->showLinkToObjectBlock($object,
null, array(
'availabilities'));
591 $somethingshown = $form->showLinkedObjectBlock($object, $linktoelem);
594 print
'</div><div class="fichehalfright">';
601 include_once DOL_DOCUMENT_ROOT.
'/core/class/html.formactions.class.php';
603 $somethingshown = $formactions->showactions($object,
$object->element.
'@'.
$object->module, (is_object(
$object->thirdparty) ?
$object->thirdparty->id : 0), 1,
'', $MAXEVENT,
'', $morehtmlcenter);
605 print
'</div></div>';
609 if (
GETPOST(
'modelselected')) {
614 $modelmail =
'availabilities';
615 $defaulttopic =
'InformationMessage';
616 $diroutput = $conf->bookcal->dir_output;
617 $trackid =
'availabilities'.$object->id;
619 include DOL_DOCUMENT_ROOT.
'/core/tpl/card_presend.tpl.php';
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.
availabilitiesPrepareHead($object)
Prepare array of tabs for Availabilities.
Class for Availabilities.
dol_mktime($hour, $minute, $second, $month, $day, $year, $gm='auto', $check=1)
Return a timestamp date built from detailed information (by default a local PHP server timestamp) Rep...
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.
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.
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.
dol_sanitizeFileName($str, $newstr='_', $unaccent=1)
Clean a string to use it as a file name.
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.