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"));
39$lineid =
GETPOST(
'lineid',
'int');
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';
78$enablepermissioncheck = 0;
79if ($enablepermissioncheck) {
80 $permissiontoread = $user->hasRight(
'bookcal',
'availabilities',
'read');
81 $permissiontoadd = $user->hasRight(
'bookcal',
'availabilities',
'write');
82 $permissiontodelete = $user->hasRight(
'bookcal',
'availabilities',
'delete') || ($permissiontoadd && isset($object->status) && $object->status == $object::STATUS_DRAFT);
83 $permissionnote = $user->hasRight(
'bookcal',
'availabilities',
'write');
84 $permissiondellink = $user->hasRight(
'bookcal',
'availabilities',
'write');
86 $permissiontoread = 1;
88 $permissiontodelete = 1;
90 $permissiondellink = 1;
93$upload_dir = $conf->bookcal->multidir_output[isset($object->entity) ? $object->entity : 1].
'/availabilities';
100if (!isModEnabled(
'bookcal')) {
103if (!$permissiontoread) {
112$parameters = array();
113$reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
118if (empty($reshook)) {
121 $backurlforlist =
dol_buildpath(
'/bookcal/availabilities_list.php', 1);
123 if (empty($backtopage) || ($cancel && empty($id))) {
124 if (empty($backtopage) || ($cancel && strpos($backtopage,
'__ID__'))) {
125 if (empty($id) && (($action !=
'add' && $action !=
'create') || $cancel)) {
126 $backtopage = $backurlforlist;
128 $backtopage =
dol_buildpath(
'/bookcal/availabilities_card.php', 1).
'?id='.((!empty($id) && $id > 0) ? $id :
'__ID__');
133 $triggermodname =
'BOOKCAL_AVAILABILITIES_MODIFY';
136 include DOL_DOCUMENT_ROOT.
'/core/actions_addupdatedelete.inc.php';
139 include DOL_DOCUMENT_ROOT.
'/core/actions_dellink.inc.php';
142 include DOL_DOCUMENT_ROOT.
'/core/actions_printing.inc.php';
148 include DOL_DOCUMENT_ROOT.
'/core/actions_builddoc.inc.php';
150 if ($action ==
'set_thirdparty' && $permissiontoadd) {
151 $object->setValueFrom(
'fk_soc',
GETPOST(
'fk_soc',
'int'),
'',
'',
'date',
'', $user, $triggermodname);
153 if ($action ==
'classin' && $permissiontoadd) {
154 $object->setProject(
GETPOST(
'projectid',
'int'));
158 $triggersendname =
'BOOKCAL_AVAILABILITIES_SENTBYMAIL';
159 $autocopy =
'MAIN_MAIL_AUTOCOPY_AVAILABILITIES_TO';
160 $trackid =
'availabilities'.$object->id;
161 include DOL_DOCUMENT_ROOT.
'/core/actions_sendmails.inc.php';
173$form =
new Form($db);
177$title = $langs->trans(
"Availabilities");
198if ($action ==
'create') {
199 if (empty($permissiontoadd)) {
204 print
load_fiche_titre($langs->trans(
"NewObject", $langs->transnoentitiesnoconv(
"Availabilities")),
'',
'object_'.$object->picto);
206 print
'<form method="POST" action="'.$_SERVER[
"PHP_SELF"].
'">';
207 print
'<input type="hidden" name="token" value="'.newToken().
'">';
208 print
'<input type="hidden" name="action" value="add">';
210 print
'<input type="hidden" name="backtopage" value="'.$backtopage.
'">';
212 if ($backtopageforcancel) {
213 print
'<input type="hidden" name="backtopageforcancel" value="'.$backtopageforcancel.
'">';
221 print
'<table class="border centpercent tableforfieldcreate">'.
"\n";
224 include DOL_DOCUMENT_ROOT.
'/core/tpl/commonfields_add.tpl.php';
227 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_add.tpl.php';
229 print
'</table>'.
"\n";
233 print $form->buttonsSaveCancel(
"Create");
241if (($id || $ref) && $action ==
'edit') {
242 print
load_fiche_titre($langs->trans(
"Availabilities"),
'',
'object_'.$object->picto);
244 print
'<form method="POST" action="'.$_SERVER[
"PHP_SELF"].
'">';
245 print
'<input type="hidden" name="token" value="'.newToken().
'">';
246 print
'<input type="hidden" name="action" value="update">';
247 print
'<input type="hidden" name="id" value="'.$object->id.
'">';
249 print
'<input type="hidden" name="backtopage" value="'.$backtopage.
'">';
251 if ($backtopageforcancel) {
252 print
'<input type="hidden" name="backtopageforcancel" value="'.$backtopageforcancel.
'">';
257 print
'<table class="border centpercent tableforfieldedit">'.
"\n";
260 include DOL_DOCUMENT_ROOT.
'/core/tpl/commonfields_edit.tpl.php';
263 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_edit.tpl.php';
269 print $form->buttonsSaveCancel();
275if ($object->id > 0 && (empty($action) || ($action !=
'edit' && $action !=
'create'))) {
276 $res = $object->fetch_optionals();
279 print
dol_get_fiche_head($head,
'card', $langs->trans(
"Availabilities"), -1, $object->picto);
284 if ($action ==
'delete') {
285 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.$object->id, $langs->trans(
'DeleteAvailabilities'), $langs->trans(
'ConfirmDeleteObject'),
'confirm_delete',
'', 0, 1);
288 if ($action ==
'deleteline') {
289 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.$object->id.
'&lineid='.$lineid, $langs->trans(
'DeleteLine'), $langs->trans(
'ConfirmDeleteLine'),
'confirm_deleteline',
'', 0, 1);
293 if ($action ==
'clone') {
295 $formquestion = array();
296 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.$object->id, $langs->trans(
'ToClone'), $langs->trans(
'ConfirmCloneAsk', $object->ref),
'confirm_clone', $formquestion,
'yes', 1);
301 if ($action ==
'xxx') {
302 $text = $langs->trans(
'ConfirmActionAvailabilities', $object->ref);
311 $formquestion = array();
322 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.$object->id, $langs->trans(
'XXX'), $text,
'confirm_xxx', $formquestion, 0, 1, 220);
326 $parameters = array(
'formConfirm' => $formconfirm,
'lineid' => $lineid);
327 $reshook = $hookmanager->executeHooks(
'formConfirm', $parameters, $object, $action);
328 if (empty($reshook)) {
329 $formconfirm .= $hookmanager->resPrint;
330 } elseif ($reshook > 0) {
331 $formconfirm = $hookmanager->resPrint;
340 $linkback =
'<a href="'.dol_buildpath(
'/bookcal/availabilities_list.php', 1).
'?restore_lastsearch_values=1'.(!empty($socid) ?
'&socid='.$socid :
'').
'">'.$langs->trans(
"BackToList").
'</a>';
342 $morehtmlref =
'<div class="refidno">';
377 $morehtmlref .=
'</div>';
380 dol_banner_tab($object,
'ref', $linkback, 1,
'ref',
'ref', $morehtmlref);
383 print
'<div class="fichecenter">';
384 print
'<div class="fichehalfleft">';
385 print
'<div class="underbanner clearboth"></div>';
386 print
'<table class="border centpercent tableforfield">'.
"\n";
392 include DOL_DOCUMENT_ROOT.
'/core/tpl/commonfields_view.tpl.php';
395 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_view.tpl.php';
401 print
'<div class="clearboth"></div>';
410 if (!empty($object->table_element_line)) {
412 $result = $object->getLinesArray();
414 print
' <form name="addproduct" id="addproduct" action="'.$_SERVER[
"PHP_SELF"].
'?id='.$object->id.(($action !=
'editline') ?
'' :
'#line_'.
GETPOST(
'lineid',
'int')).
'" method="POST">
415 <input type="hidden" name="token" value="' . newToken().
'">
416 <input type="hidden" name="action" value="' . (($action !=
'editline') ?
'addline' :
'updateline').
'">
417 <input type="hidden" name="mode" value="">
418 <input type="hidden" name="page_y" value="">
419 <input type="hidden" name="id" value="' . $object->id.
'">
422 if (!empty($conf->use_javascript_ajax) && $object->status == 0) {
423 include DOL_DOCUMENT_ROOT.
'/core/tpl/ajaxrow.tpl.php';
426 print
'<div class="div-table-responsive-no-min">';
427 if (!empty($object->lines) || ($object->status == $object::STATUS_DRAFT && $permissiontoadd && $action !=
'selectlines' && $action !=
'editline')) {
428 print
'<table id="tablelines" class="noborder noshadow" width="100%">';
431 if (!empty($object->lines)) {
432 $object->printObjectLines($action, $mysoc,
null,
GETPOST(
'lineid',
'int'), 1);
436 if ($object->status == 0 && $permissiontoadd && $action !=
'selectlines') {
437 if ($action !=
'editline') {
440 $parameters = array();
441 $reshook = $hookmanager->executeHooks(
'formAddObjectLine', $parameters, $object, $action);
445 if (empty($reshook)) {
446 $object->formAddObjectLine(1, $mysoc, $soc);
451 if (!empty($object->lines) || ($object->status == $object::STATUS_DRAFT && $permissiontoadd && $action !=
'selectlines' && $action !=
'editline')) {
462 if ($action !=
'presend' && $action !=
'editline') {
463 print
'<div class="tabsAction">'.
"\n";
464 $parameters = array();
465 $reshook = $hookmanager->executeHooks(
'addMoreActionsButtons', $parameters, $object, $action);
470 if (empty($reshook)) {
472 if (empty($user->socid)) {
473 print
dolGetButtonAction($langs->trans(
'SendMail'),
'',
'default', $_SERVER[
"PHP_SELF"].
'?id='.$object->id.
'&action=presend&mode=init&token='.newToken().
'#formmailbeforetitle');
477 if ($object->status == $object::STATUS_VALIDATED) {
478 print
dolGetButtonAction($langs->trans(
'SetToDraft'),
'',
'default', $_SERVER[
"PHP_SELF"].
'?id='.$object->id.
'&action=confirm_setdraft&confirm=yes&token='.newToken(),
'', $permissiontoadd);
481 print
dolGetButtonAction($langs->trans(
'Modify'),
'',
'default', $_SERVER[
"PHP_SELF"].
'?id='.$object->id.
'&action=edit&token='.newToken(),
'', $permissiontoadd);
484 if ($object->status == $object::STATUS_DRAFT) {
485 if (empty($object->table_element_line) || (is_array($object->lines) && count($object->lines) > 0)) {
486 print
dolGetButtonAction($langs->trans(
'Validate'),
'',
'default', $_SERVER[
'PHP_SELF'].
'?id='.$object->id.
'&action=confirm_validate&confirm=yes&token='.newToken(),
'', $permissiontoadd);
488 $langs->load(
"errors");
489 print
dolGetButtonAction($langs->trans(
"ErrorAddAtLeastOneLineFirst"), $langs->trans(
"Validate"),
'default',
'#',
'', 0);
494 print
dolGetButtonAction($langs->trans(
'ToClone'),
'',
'default', $_SERVER[
'PHP_SELF'].
'?id='.$object->id.(!empty($object->socid) ?
'&socid='.$object->socid :
'').
'&action=clone&token='.newToken(),
'', $permissiontoadd);
514 print
dolGetButtonAction($langs->trans(
'Delete'),
'',
'delete', $_SERVER[
'PHP_SELF'].
'?id='.$object->id.
'&action=delete&token='.newToken(),
'', $permissiontodelete || ($object->status == $object::STATUS_DRAFT && $permissiontoadd));
521 if (
GETPOST(
'modelselected')) {
525 if ($action !=
'presend') {
526 print
'<div class="fichecenter"><div class="fichehalfleft">';
527 print
'<a name="builddoc"></a>';
529 $includedocgeneration = 0;
532 if ($includedocgeneration) {
534 $relativepath = $objref.
'/'.$objref.
'.pdf';
535 $filedir = $conf->bookcal->dir_output.
'/'.$object->element.
'/'.$objref;
536 $urlsource = $_SERVER[
"PHP_SELF"].
"?id=".$object->id;
537 $genallowed = $permissiontoread;
538 $delallowed = $permissiontoadd;
539 print $formfile->showdocuments(
'bookcal:Availabilities', $object->element.
'/'.$objref, $filedir, $urlsource, $genallowed, $delallowed, $object->model_pdf, 1, 0, 0, 28, 0,
'',
'',
'', $langs->defaultlang);
543 $linktoelem = $form->showLinkToObjectBlock($object,
null, array(
'availabilities'));
544 $somethingshown = $form->showLinkedObjectBlock($object, $linktoelem);
547 print
'</div><div class="fichehalfright">';
551 $morehtmlcenter =
dolGetButtonTitle($langs->trans(
'SeeAll'),
'',
'fa fa-bars imgforviewmode',
dol_buildpath(
'/bookcal/availabilities_agenda.php', 1).
'?id='.$object->id);
554 include_once DOL_DOCUMENT_ROOT.
'/core/class/html.formactions.class.php';
556 $somethingshown =
$formactions->showactions($object, $object->element.
'@'.$object->module, (is_object($object->thirdparty) ? $object->thirdparty->id : 0), 1,
'', $MAXEVENT,
'', $morehtmlcenter);
558 print
'</div></div>';
562 if (
GETPOST(
'modelselected')) {
567 $modelmail =
'availabilities';
568 $defaulttopic =
'InformationMessage';
569 $diroutput = $conf->bookcal->dir_output;
570 $trackid =
'availabilities'.$object->id;
572 include DOL_DOCUMENT_ROOT.
'/core/tpl/card_presend.tpl.php';
if(preg_match('/set_([a-z0-9_\-]+)/i', $action, $reg)) if(preg_match('/del_([a-z0-9_\-]+)/i', $action, $reg)) if($action=='set') elseif( $action=='specimen') elseif($action=='setmodel') elseif( $action=='del') elseif($action=='setdoc') $formactions
View.
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_banner_tab($object, $paramid, $morehtml='', $shownav=1, $fieldid='rowid', $fieldref='ref', $morehtmlref='', $moreparam='', $nodbprefix=0, $morehtmlleft='', $morehtmlstatus='', $onlybanner=0, $morehtmlright='')
Show tab footer of a card.
load_fiche_titre($titre, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
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.
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.