28require
'../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/availabilities.class.php';
33require_once DOL_DOCUMENT_ROOT.
'/bookcal/lib/bookcal_availabilities.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$dol_openinpopup =
GETPOST(
'dol_openinpopup',
'aZ09');
54$diroutputmassaction = $conf->bookcal->dir_output.
'/temp/massgeneration/'.$user->id;
55$hookmanager->initHooks(array(
'availabilitiescard',
'globalcard'));
58$extrafields->fetch_name_optionals_label(
$object->table_element);
60$search_array_options = $extrafields->getOptionalsFromPost(
$object->table_element,
'',
'search_');
63$search_all =
GETPOST(
"search_all",
'alpha');
65foreach (
$object->fields as $key => $val) {
66 if (
GETPOST(
'search_'.$key,
'alpha')) {
67 $search[$key] =
GETPOST(
'search_'.$key,
'alpha');
71if (empty($action) && empty($id) && empty($ref)) {
76include DOL_DOCUMENT_ROOT.
'/core/actions_fetchobject.inc.php';
83$enablepermissioncheck = 0;
84if ($enablepermissioncheck) {
85 $permissiontoread = $user->hasRight(
'bookcal',
'availabilities',
'read');
86 $permissiontoadd = $user->hasRight(
'bookcal',
'availabilities',
'write');
87 $permissiontodelete = $user->hasRight(
'bookcal',
'availabilities',
'delete') || ($permissiontoadd && isset(
$object->status) &&
$object->status == $object::STATUS_DRAFT);
88 $permissionnote = $user->hasRight(
'bookcal',
'availabilities',
'write');
89 $permissiondellink = $user->hasRight(
'bookcal',
'availabilities',
'write');
91 $permissiontoread = 1;
93 $permissiontodelete = 1;
95 $permissiondellink = 1;
98$upload_dir = $conf->bookcal->multidir_output[isset(
$object->entity) ?
$object->entity : 1].
'/availabilities';
105if (!isModEnabled(
'bookcal')) {
108if (!$permissiontoread) {
121$parameters = array();
122$reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
127if (empty($reshook)) {
130 $backurlforlist =
dol_buildpath(
'/bookcal/availabilities_list.php', 1);
132 if (empty($backtopage) || ($cancel && empty($id))) {
133 if (empty($backtopage) || ($cancel && strpos($backtopage,
'__ID__'))) {
134 if (empty($id) && (($action !=
'add' && $action !=
'create') || $cancel)) {
135 $backtopage = $backurlforlist;
137 $backtopage =
dol_buildpath(
'/bookcal/availabilities_card.php', 1).
'?id='.((!empty($id) &&
$id > 0) ? $id :
'__ID__');
142 $triggermodname =
'BOOKCAL_AVAILABILITIES_MODIFY';
145 $startday =
GETPOST(
'startday',
'int');
146 $startmonth =
GETPOST(
'startmonth',
'int');
147 $startyear =
GETPOST(
'startyear',
'int');
148 $starthour =
GETPOST(
'startHour',
'int');
150 if ($starthour ==
"0") {
152 setEventMessages($langs->trans(
"ErrorStartHourIsNull"), $hookmanager->errors,
'errors');
155 $dateStartTimestamp =
dol_mktime($starthour, 0, 0, $startmonth, $startday, $startyear);
157 $endday =
GETPOST(
'endday',
'int');
158 $endmonth =
GETPOST(
'endmonth',
'int');
159 $endyear =
GETPOST(
'endyear',
'int');
160 $endhour =
GETPOST(
'endHour',
'int');
162 if ($endhour ==
"0") {
164 setEventMessages($langs->trans(
"ErrorEndHourIsNull"), $hookmanager->errors,
'errors');
167 $dateEndTimestamp =
dol_mktime($endhour, 0, 0, $endmonth, $endday, $endyear);
170 if ($starthour > $endhour) {
171 if ($dateStartTimestamp === $dateEndTimestamp) {
173 setEventMessages($langs->trans(
"ErrorEndTimeMustBeGreaterThanStartTime"), $hookmanager->errors,
'errors');
178 if (($dateStartTimestamp !=
"") && ($dateStartTimestamp >= $dateEndTimestamp)) {
180 setEventMessages($langs->trans(
"ErrorIncoherentDates"), $hookmanager->errors,
'errors');
185 include DOL_DOCUMENT_ROOT.
'/core/actions_addupdatedelete.inc.php';
188 include DOL_DOCUMENT_ROOT.
'/core/actions_dellink.inc.php';
191 include DOL_DOCUMENT_ROOT.
'/core/actions_printing.inc.php';
197 include DOL_DOCUMENT_ROOT.
'/core/actions_builddoc.inc.php';
199 if ($action ==
'set_thirdparty' && $permissiontoadd) {
200 $object->setValueFrom(
'fk_soc',
GETPOSTINT(
'fk_soc'),
'',
null,
'date',
'', $user, $triggermodname);
202 if ($action ==
'classin' && $permissiontoadd) {
207 $triggersendname =
'BOOKCAL_AVAILABILITIES_SENTBYMAIL';
208 $autocopy =
'MAIN_MAIL_AUTOCOPY_AVAILABILITIES_TO';
209 $trackid =
'availabilities'.$object->id;
210 include DOL_DOCUMENT_ROOT.
'/core/actions_sendmails.inc.php';
222$form =
new Form($db);
226$title = $langs->trans(
"Availabilities");
228llxHeader(
'', $title, $help_url,
'', 0, 0,
'',
'',
'',
'mod-bookcal page-card_availabilities');
247if ($action ==
'create') {
248 if (empty($permissiontoadd)) {
253 print
load_fiche_titre($langs->trans(
"NewAvailabilities"),
'',
'object_'.$object->picto);
254 print
'<form method="POST" action="'.$_SERVER[
"PHP_SELF"].
'">';
255 print
'<input type="hidden" name="token" value="'.newToken().
'">';
257 print
'<input type="hidden" name="action" value="create">';
259 print
'<input type="hidden" name="action" value="add">';
262 print
'<input type="hidden" name="backtopage" value="'.$backtopage.
'">';
264 if ($backtopageforcancel) {
265 print
'<input type="hidden" name="backtopageforcancel" value="'.$backtopageforcancel.
'">';
270 print
'<table class="border centpercent tableforfieldcreate">'.
"\n";
273 include DOL_DOCUMENT_ROOT.
'/core/tpl/commonfields_add.tpl.php';
276 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_add.tpl.php';
278 print
'</table>'.
"\n";
282 print $form->buttonsSaveCancel(
"Create");
290if (($id || $ref) && $action ==
'edit') {
291 print
load_fiche_titre($langs->trans(
"Availabilities"),
'',
'object_'.$object->picto);
293 print
'<form method="POST" action="'.$_SERVER[
"PHP_SELF"].
'">';
294 print
'<input type="hidden" name="token" value="'.newToken().
'">';
295 print
'<input type="hidden" name="action" value="update">';
296 print
'<input type="hidden" name="id" value="'.$object->id.
'">';
298 print
'<input type="hidden" name="backtopage" value="'.$backtopage.
'">';
300 if ($backtopageforcancel) {
301 print
'<input type="hidden" name="backtopageforcancel" value="'.$backtopageforcancel.
'">';
306 print
'<table class="border centpercent tableforfieldedit">'.
"\n";
309 include DOL_DOCUMENT_ROOT.
'/core/tpl/commonfields_edit.tpl.php';
312 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_edit.tpl.php';
318 print $form->buttonsSaveCancel();
324if (
$object->id > 0 && (empty($action) || ($action !=
'edit' && $action !=
'create'))) {
325 $res =
$object->fetch_optionals();
333 if ($action ==
'delete') {
334 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.
$object->id, $langs->trans(
'DeleteAvailabilities'), $langs->trans(
'ConfirmDeleteObject'),
'confirm_delete',
'', 0, 1);
337 if ($action ==
'deleteline') {
338 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&lineid='.$lineid, $langs->trans(
'DeleteLine'), $langs->trans(
'ConfirmDeleteLine'),
'confirm_deleteline',
'', 0, 1);
342 if ($action ==
'clone') {
344 $formquestion = array();
345 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.
$object->id, $langs->trans(
'ToClone'), $langs->trans(
'ConfirmCloneAsk',
$object->ref),
'confirm_clone', $formquestion,
'yes', 1);
350 if ($action ==
'xxx') {
351 $text = $langs->trans(
'ConfirmActionAvailabilities',
$object->ref);
360 $formquestion = array();
371 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.
$object->id, $langs->trans(
'XXX'), $text,
'confirm_xxx', $formquestion, 0, 1, 220);
375 $parameters = array(
'formConfirm' => $formconfirm,
'lineid' => $lineid);
376 $reshook = $hookmanager->executeHooks(
'formConfirm', $parameters, $object, $action);
377 if (empty($reshook)) {
378 $formconfirm .= $hookmanager->resPrint;
379 } elseif ($reshook > 0) {
380 $formconfirm = $hookmanager->resPrint;
389 $linkback =
'<a href="'.dol_buildpath(
'/bookcal/availabilities_list.php', 1).
'?restore_lastsearch_values=1'.(!empty($socid) ?
'&socid='.$socid :
'').
'">'.$langs->trans(
"BackToList").
'</a>';
391 $morehtmlref =
'<div class="refidno">';
426 $morehtmlref .=
'</div>';
429 dol_banner_tab($object,
'ref', $linkback, 1,
'ref',
'ref', $morehtmlref);
432 print
'<div class="fichecenter">';
433 print
'<div class="fichehalfleft">';
434 print
'<div class="underbanner clearboth"></div>';
435 print
'<table class="border centpercent tableforfield">'.
"\n";
441 include DOL_DOCUMENT_ROOT.
'/core/tpl/commonfields_view.tpl.php';
444 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_view.tpl.php';
450 print
'<div class="clearboth"></div>';
459 if (!empty(
$object->table_element_line)) {
461 $result =
$object->getLinesArray();
463 print
' <form name="addproduct" id="addproduct" action="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.(($action !=
'editline') ?
'' :
'#line_'.
GETPOSTINT(
'lineid')).
'" method="POST">
464 <input type="hidden" name="token" value="' .
newToken().
'">
465 <input type="hidden" name="action" value="' . (($action !=
'editline') ?
'addline' :
'updateline').
'">
466 <input type="hidden" name="mode" value="">
467 <input type="hidden" name="page_y" value="">
468 <input type="hidden" name="id" value="' .
$object->id.
'">
471 if (!empty($conf->use_javascript_ajax) &&
$object->status == 0) {
472 include DOL_DOCUMENT_ROOT.
'/core/tpl/ajaxrow.tpl.php';
475 print
'<div class="div-table-responsive-no-min">';
476 if (!empty(
$object->lines) || (
$object->status == $object::STATUS_DRAFT && $permissiontoadd && $action !=
'selectlines' && $action !=
'editline')) {
477 print
'<table id="tablelines" class="noborder noshadow" width="100%">';
485 if (
$object->status == 0 && $permissiontoadd && $action !=
'selectlines') {
486 if ($action !=
'editline') {
489 $parameters = array();
490 $reshook = $hookmanager->executeHooks(
'formAddObjectLine', $parameters, $object, $action);
494 if (empty($reshook)) {
495 $object->formAddObjectLine(1, $mysoc, $soc);
500 if (!empty(
$object->lines) || (
$object->status == $object::STATUS_DRAFT && $permissiontoadd && $action !=
'selectlines' && $action !=
'editline')) {
511 if ($action !=
'presend' && $action !=
'editline') {
512 print
'<div class="tabsAction">'.
"\n";
513 $parameters = array();
514 $reshook = $hookmanager->executeHooks(
'addMoreActionsButtons', $parameters, $object, $action);
519 if (empty($reshook)) {
521 if (empty($user->socid)) {
522 print
dolGetButtonAction($langs->trans(
'SendMail'),
'',
'default', $_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&action=presend&mode=init&token='.
newToken().
'#formmailbeforetitle');
526 if (
$object->status == $object::STATUS_VALIDATED) {
527 print
dolGetButtonAction($langs->trans(
'SetToDraft'),
'',
'default', $_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&action=confirm_setdraft&confirm=yes&token='.
newToken(),
'', $permissiontoadd);
530 print
dolGetButtonAction($langs->trans(
'Modify'),
'',
'default', $_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&action=edit&token='.
newToken(),
'', $permissiontoadd);
533 if (
$object->status == $object::STATUS_DRAFT) {
535 print
dolGetButtonAction($langs->trans(
'Validate'),
'',
'default', $_SERVER[
'PHP_SELF'].
'?id='.
$object->id.
'&action=confirm_validate&confirm=yes&token='.
newToken(),
'', $permissiontoadd);
537 $langs->load(
"errors");
538 print
dolGetButtonAction($langs->trans(
"ErrorAddAtLeastOneLineFirst"), $langs->trans(
"Validate"),
'default',
'#',
'', 0);
543 print
dolGetButtonAction($langs->trans(
'ToClone'),
'',
'default', $_SERVER[
'PHP_SELF'].
'?id='.
$object->id.(!empty(
$object->socid) ?
'&socid='.$object->socid :
'').
'&action=clone&token='.
newToken(),
'', $permissiontoadd);
563 print
dolGetButtonAction($langs->trans(
'Delete'),
'',
'delete', $_SERVER[
'PHP_SELF'].
'?id='.
$object->id.
'&action=delete&token='.
newToken(),
'', $permissiontodelete || (
$object->status == $object::STATUS_DRAFT && $permissiontoadd));
570 if (
GETPOST(
'modelselected')) {
574 if ($action !=
'presend') {
575 print
'<div class="fichecenter"><div class="fichehalfleft">';
576 print
'<a name="builddoc"></a>';
578 $includedocgeneration = 0;
581 if ($includedocgeneration) {
583 $relativepath = $objref.
'/'.$objref.
'.pdf';
584 $filedir = $conf->bookcal->dir_output.
'/'.
$object->element.
'/'.$objref;
585 $urlsource = $_SERVER[
"PHP_SELF"].
"?id=".
$object->id;
586 $genallowed = $permissiontoread;
587 $delallowed = $permissiontoadd;
588 print $formfile->showdocuments(
'bookcal:Availabilities',
$object->element.
'/'.$objref, $filedir, $urlsource, $genallowed, $delallowed,
$object->model_pdf, 1, 0, 0, 28, 0,
'',
'',
'', $langs->defaultlang);
592 $tmparray = $form->showLinkToObjectBlock($object, array(), array(
'availabilities'), 1);
593 $linktoelem = $tmparray[
'linktoelem'];
594 $htmltoenteralink = $tmparray[
'htmltoenteralink'];
595 print $htmltoenteralink;
597 $somethingshown = $form->showLinkedObjectBlock($object, $linktoelem);
600 print
'</div><div class="fichehalfright">';
607 include_once DOL_DOCUMENT_ROOT.
'/core/class/html.formactions.class.php';
609 $somethingshown = $formactions->showactions($object,
$object->element.
'@'.
$object->module, (is_object(
$object->thirdparty) ?
$object->thirdparty->id : 0), 1,
'', $MAXEVENT,
'', $morehtmlcenter);
611 print
'</div></div>';
615 if (
GETPOST(
'modelselected')) {
620 $modelmail =
'availabilities';
621 $defaulttopic =
'InformationMessage';
622 $diroutput = $conf->bookcal->dir_output;
623 $trackid =
'availabilities'.$object->id;
625 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($head='', $title='', $help_url='', $target='', $disablejs=0, $disablehead=0, $arrayofjs='', $arrayofcss='', $morequerystring='', $morecssonbody='', $replacemainareaby='', $disablenofollow=0, $disablenoindex=0)
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.
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.
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.
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.