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';
45$langs->loadLangs(array(
"agenda",
"other"));
52$action =
GETPOST(
'action',
'aZ09');
53$confirm =
GETPOST(
'confirm',
'alpha');
54$cancel =
GETPOST(
'cancel',
'aZ09');
55$contextpage =
GETPOST(
'contextpage',
'aZ') ?
GETPOST(
'contextpage',
'aZ') : str_replace(
'_',
'', basename(dirname(__FILE__)).basename(__FILE__,
'.php'));
56$backtopage =
GETPOST(
'backtopage',
'alpha');
57$backtopageforcancel =
GETPOST(
'backtopageforcancel',
'alpha');
58$dol_openinpopup =
GETPOST(
'dol_openinpopup',
'aZ09');
63$diroutputmassaction =
$conf->bookcal->dir_output.
'/temp/massgeneration/'.$user->id;
64$hookmanager->initHooks(array(
'availabilitiescard',
'globalcard'));
67$extrafields->fetch_name_optionals_label(
$object->table_element);
69$search_array_options = $extrafields->getOptionalsFromPost(
$object->table_element,
'',
'search_');
72$search_all =
GETPOST(
"search_all",
'alpha');
74foreach (
$object->fields as $key => $val) {
75 if (
GETPOST(
'search_'.$key,
'alpha')) {
76 $search[$key] =
GETPOST(
'search_'.$key,
'alpha');
80if (empty($action) && empty($id) && empty($ref)) {
85include DOL_DOCUMENT_ROOT.
'/core/actions_fetchobject.inc.php';
92$enablepermissioncheck = 0;
93if ($enablepermissioncheck) {
94 $permissiontoread = $user->hasRight(
'bookcal',
'availabilities',
'read');
95 $permissiontoadd = $user->hasRight(
'bookcal',
'availabilities',
'write');
96 $permissiontodelete = $user->hasRight(
'bookcal',
'availabilities',
'delete') || ($permissiontoadd && isset(
$object->status) &&
$object->status == $object::STATUS_DRAFT);
97 $permissionnote = $user->hasRight(
'bookcal',
'availabilities',
'write');
98 $permissiondellink = $user->hasRight(
'bookcal',
'availabilities',
'write');
100 $permissiontoread = 1;
101 $permissiontoadd = 1;
102 $permissiontodelete = 1;
104 $permissiondellink = 1;
107$upload_dir =
$conf->bookcal->multidir_output[isset(
$object->entity) ?
$object->entity : 1].
'/availabilities';
114if (!isModEnabled(
'bookcal')) {
117if (!$permissiontoread) {
127$parameters = array();
128$reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
133if (empty($reshook)) {
134 $backurlforlist =
dol_buildpath(
'/bookcal/availabilities_list.php', 1);
136 if (empty($backtopage) || ($cancel && empty($id))) {
137 if (empty($backtopage) || ($cancel && strpos($backtopage,
'__ID__'))) {
138 if (empty($id) && (($action !=
'add' && $action !=
'create') || $cancel)) {
139 $backtopage = $backurlforlist;
141 $backtopage =
dol_buildpath(
'/bookcal/availabilities_card.php', 1).
'?id='.((!empty($id) &&
$id > 0) ? $id :
'__ID__');
146 $triggermodname =
'BOOKCAL_AVAILABILITIES_MODIFY';
153 if (
GETPOST(
'startHour') ==
"") {
155 setEventMessages($langs->trans(
"ErrorStartHourIsNull"), $hookmanager->errors,
'errors');
158 $dateStartTimestamp =
dol_mktime($starthour, 0, 0, $startmonth, $startday, $startyear);
165 if (
GETPOST(
'endHour') ==
"") {
167 setEventMessages($langs->trans(
"ErrorEndHourIsNull"), $hookmanager->errors,
'errors');
170 $dateEndTimestamp =
dol_mktime($endhour, 0, 0, $endmonth, $endday, $endyear);
173 if ($starthour > $endhour) {
174 if ($dateStartTimestamp === $dateEndTimestamp) {
176 setEventMessages($langs->trans(
"ErrorEndTimeMustBeGreaterThanStartTime"), $hookmanager->errors,
'errors');
181 if (($dateStartTimestamp !=
"") && ($dateStartTimestamp >= $dateEndTimestamp)) {
183 setEventMessages($langs->trans(
"ErrorIncoherentDates"), $hookmanager->errors,
'errors');
188 include DOL_DOCUMENT_ROOT.
'/core/actions_addupdatedelete.inc.php';
191 include DOL_DOCUMENT_ROOT.
'/core/actions_dellink.inc.php';
194 include DOL_DOCUMENT_ROOT.
'/core/actions_printing.inc.php';
200 include DOL_DOCUMENT_ROOT.
'/core/actions_builddoc.inc.php';
202 if ($action ==
'set_thirdparty' && $permissiontoadd) {
203 $object->setValueFrom(
'fk_soc',
GETPOSTINT(
'fk_soc'),
'',
null,
'date',
'', $user, $triggermodname);
205 if ($action ==
'classin' && $permissiontoadd) {
210 $triggersendname =
'BOOKCAL_AVAILABILITIES_SENTBYMAIL';
211 $autocopy =
'MAIN_MAIL_AUTOCOPY_AVAILABILITIES_TO';
212 $trackid =
'availabilities'.$object->id;
213 include DOL_DOCUMENT_ROOT.
'/core/actions_sendmails.inc.php';
225$form =
new Form($db);
229$title = $langs->trans(
"Availabilities");
231llxHeader(
'', $title, $help_url,
'', 0, 0,
'',
'',
'',
'mod-bookcal page-card_availabilities');
234if ($action ==
'create') {
235 if (empty($permissiontoadd)) {
239 print
load_fiche_titre($langs->trans(
"NewAvailabilities"),
'',
'object_'.$object->picto);
240 print
'<form method="POST" action="'.$_SERVER[
"PHP_SELF"].
'">';
241 print
'<input type="hidden" name="token" value="'.newToken().
'">';
243 print
'<input type="hidden" name="action" value="create">';
245 print
'<input type="hidden" name="action" value="add">';
248 print
'<input type="hidden" name="backtopage" value="'.$backtopage.
'">';
250 if ($backtopageforcancel) {
251 print
'<input type="hidden" name="backtopageforcancel" value="'.$backtopageforcancel.
'">';
256 print
'<table class="border centpercent tableforfieldcreate">'.
"\n";
259 include DOL_DOCUMENT_ROOT.
'/core/tpl/commonfields_add.tpl.php';
262 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_add.tpl.php';
264 print
'</table>'.
"\n";
268 print $form->buttonsSaveCancel(
"Create");
276if (($id || $ref) && $action ==
'edit') {
277 print
load_fiche_titre($langs->trans(
"Availabilities"),
'',
'object_'.$object->picto);
279 print
'<form method="POST" action="'.$_SERVER[
"PHP_SELF"].
'">';
280 print
'<input type="hidden" name="token" value="'.newToken().
'">';
281 print
'<input type="hidden" name="action" value="update">';
282 print
'<input type="hidden" name="id" value="'.$object->id.
'">';
284 print
'<input type="hidden" name="backtopage" value="'.$backtopage.
'">';
286 if ($backtopageforcancel) {
287 print
'<input type="hidden" name="backtopageforcancel" value="'.$backtopageforcancel.
'">';
292 print
'<table class="border centpercent tableforfieldedit">'.
"\n";
295 include DOL_DOCUMENT_ROOT.
'/core/tpl/commonfields_edit.tpl.php';
298 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_edit.tpl.php';
304 print $form->buttonsSaveCancel();
310if (
$object->id > 0 && (empty($action) || ($action !=
'edit' && $action !=
'create'))) {
311 $res =
$object->fetch_optionals();
319 if ($action ==
'delete') {
320 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.
$object->id, $langs->trans(
'DeleteAvailabilities'), $langs->trans(
'ConfirmDeleteObject'),
'confirm_delete',
'', 0, 1);
323 if ($action ==
'deleteline') {
324 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&lineid='.$lineid, $langs->trans(
'DeleteLine'), $langs->trans(
'ConfirmDeleteLine'),
'confirm_deleteline',
'', 0, 1);
328 if ($action ==
'clone') {
330 $formquestion = array();
331 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.
$object->id, $langs->trans(
'ToClone'), $langs->trans(
'ConfirmCloneAsk',
$object->ref),
'confirm_clone', $formquestion,
'yes', 1);
336 if ($action ==
'xxx') {
337 $text = $langs->trans(
'ConfirmActionAvailabilities',
$object->ref);
346 $formquestion = array();
357 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.
$object->id, $langs->trans(
'XXX'), $text,
'confirm_xxx', $formquestion, 0, 1, 220);
361 $parameters = array(
'formConfirm' => $formconfirm,
'lineid' => $lineid);
362 $reshook = $hookmanager->executeHooks(
'formConfirm', $parameters, $object, $action);
363 if (empty($reshook)) {
364 $formconfirm .= $hookmanager->resPrint;
365 } elseif ($reshook > 0) {
366 $formconfirm = $hookmanager->resPrint;
375 $linkback =
'<a href="'.dol_buildpath(
'/bookcal/availabilities_list.php', 1).
'?restore_lastsearch_values=1'.(!empty($socid) ?
'&socid='.$socid :
'').
'">'.$langs->trans(
"BackToList").
'</a>';
377 $morehtmlref =
'<div class="refidno">';
412 $morehtmlref .=
'</div>';
415 dol_banner_tab($object,
'ref', $linkback, 1,
'ref',
'ref', $morehtmlref);
418 print
'<div class="fichecenter">';
419 print
'<div class="fichehalfleft">';
420 print
'<div class="underbanner clearboth"></div>';
421 print
'<table class="border centpercent tableforfield">'.
"\n";
427 include DOL_DOCUMENT_ROOT.
'/core/tpl/commonfields_view.tpl.php';
430 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_view.tpl.php';
436 print
'<div class="clearboth"></div>';
445 if (!empty(
$object->table_element_line)) {
447 $result =
$object->getLinesArray();
449 print
' <form name="addproduct" id="addproduct" action="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.(($action !=
'editline') ?
'' :
'#line_'.
GETPOSTINT(
'lineid')).
'" method="POST">
450 <input type="hidden" name="token" value="' .
newToken().
'">
451 <input type="hidden" name="action" value="' . (($action !=
'editline') ?
'addline' :
'updateline').
'">
452 <input type="hidden" name="mode" value="">
453 <input type="hidden" name="page_y" value="">
454 <input type="hidden" name="id" value="' .
$object->id.
'">
457 if (!empty(
$conf->use_javascript_ajax) &&
$object->status == 0) {
458 include DOL_DOCUMENT_ROOT.
'/core/tpl/ajaxrow.tpl.php';
461 print
'<div class="div-table-responsive-no-min">';
462 if (!empty(
$object->lines) || (
$object->status == $object::STATUS_DRAFT && $permissiontoadd && $action !=
'selectlines' && $action !=
'editline')) {
463 print
'<table id="tablelines" class="noborder noshadow" width="100%">';
471 if (
$object->status == 0 && $permissiontoadd && $action !=
'selectlines') {
472 if ($action !=
'editline') {
475 $parameters = array();
476 $reshook = $hookmanager->executeHooks(
'formAddObjectLine', $parameters, $object, $action);
480 if (empty($reshook)) {
481 $object->formAddObjectLine(1, $mysoc, $soc);
486 if (!empty(
$object->lines) || (
$object->status == $object::STATUS_DRAFT && $permissiontoadd && $action !=
'selectlines' && $action !=
'editline')) {
497 if ($action !=
'presend' && $action !=
'editline') {
498 print
'<div class="tabsAction">'.
"\n";
499 $parameters = array();
500 $reshook = $hookmanager->executeHooks(
'addMoreActionsButtons', $parameters, $object, $action);
505 if (empty($reshook)) {
507 if (empty($user->socid)) {
508 print
dolGetButtonAction($langs->trans(
'SendMail'),
'',
'default', $_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&action=presend&mode=init&token='.
newToken().
'#formmailbeforetitle');
512 if (
$object->status == $object::STATUS_VALIDATED) {
513 print
dolGetButtonAction($langs->trans(
'SetToDraft'),
'',
'default', $_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&action=confirm_setdraft&confirm=yes&token='.
newToken(),
'', $permissiontoadd);
516 print
dolGetButtonAction($langs->trans(
'Modify'),
'',
'default', $_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&action=edit&token='.
newToken(),
'', $permissiontoadd);
519 if (
$object->status == $object::STATUS_DRAFT) {
521 print
dolGetButtonAction($langs->trans(
'Validate'),
'',
'default', $_SERVER[
'PHP_SELF'].
'?id='.
$object->id.
'&action=confirm_validate&confirm=yes&token='.
newToken(),
'', $permissiontoadd);
523 $langs->load(
"errors");
524 print
dolGetButtonAction($langs->trans(
"ErrorAddAtLeastOneLineFirst"), $langs->trans(
"Validate"),
'default',
'#',
'', 0);
529 print
dolGetButtonAction($langs->trans(
'ToClone'),
'',
'default', $_SERVER[
'PHP_SELF'].
'?id='.
$object->id.(!empty(
$object->socid) ?
'&socid='.$object->socid :
'').
'&action=clone&token='.
newToken(),
'', $permissiontoadd);
549 print
dolGetButtonAction($langs->trans(
'Delete'),
'',
'delete', $_SERVER[
'PHP_SELF'].
'?id='.
$object->id.
'&action=delete&token='.
newToken(),
'', $permissiontodelete || (
$object->status == $object::STATUS_DRAFT && $permissiontoadd));
556 if (
GETPOST(
'modelselected')) {
560 if ($action !=
'presend') {
561 print
'<div class="fichecenter"><div class="fichehalfleft">';
562 print
'<a name="builddoc"></a>';
564 $includedocgeneration = 0;
567 if ($includedocgeneration) {
569 $relativepath = $objref.
'/'.$objref.
'.pdf';
570 $filedir =
$conf->bookcal->dir_output.
'/'.
$object->element.
'/'.$objref;
571 $urlsource = $_SERVER[
"PHP_SELF"].
"?id=".
$object->id;
572 $genallowed = $permissiontoread;
573 $delallowed = $permissiontoadd;
574 print $formfile->showdocuments(
'bookcal:Availabilities',
$object->element.
'/'.$objref, $filedir, $urlsource, $genallowed, $delallowed,
$object->model_pdf, 1, 0, 0, 28, 0,
'',
'',
'', $langs->defaultlang);
578 $tmparray = $form->showLinkToObjectBlock($object, array(), array(
'availabilities'), 1);
579 $linktoelem = $tmparray[
'linktoelem'];
580 $htmltoenteralink = $tmparray[
'htmltoenteralink'];
581 print $htmltoenteralink;
583 $somethingshown = $form->showLinkedObjectBlock($object, $linktoelem);
586 print
'</div><div class="fichehalfright">';
593 include_once DOL_DOCUMENT_ROOT.
'/core/class/html.formactions.class.php';
595 $somethingshown = $formactions->showactions($object,
$object->element.
'@'.
$object->module, (is_object(
$object->thirdparty) ?
$object->thirdparty->id : 0), 1,
'', $MAXEVENT,
'', $morehtmlcenter);
597 print
'</div></div>';
601 if (
GETPOST(
'modelselected')) {
606 $modelmail =
'availabilities';
607 $defaulttopic =
'InformationMessage';
608 $diroutput =
$conf->bookcal->dir_output;
609 $trackid =
'availabilities'.$object->id;
611 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.
global $conf
The following vars must be defined: $type2label $form $conf, $lang, The following vars may also be de...
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.