33 include_once(
'./Services/Calendar/classes/class.ilTimeZone.php');
34 include_once(
'./Services/Calendar/classes/class.ilDateTime.php');
61 $lng->loadLanguageModule(
'dateplaner');
80 $next_class = $this->ctrl->getNextClass($this);
85 $cmd = $this->ctrl->getCmd(
"add");
101 $this->ctrl->returnToParent($this);
111 protected function initForm($a_mode, $a_as_milestone =
false)
115 include_once(
'./Services/Form/classes/class.ilPropertyFormGUI.php');
116 include_once(
'./Services/Calendar/classes/class.ilCalendarRecurrenceGUI.php');
117 include_once(
'./Services/Calendar/classes/class.ilCalendarCategories.php');
118 include_once(
'./Services/Calendar/classes/class.ilCalendarCategoryAssignments.php');
119 include_once(
'./Services/Calendar/classes/class.ilCalendarCategory.php');
123 include_once(
'./Services/YUI/classes/class.ilYuiUtil.php');
129 $this->ctrl->saveParameter($this,array(
'seed'));
130 $this->form->setFormAction($this->ctrl->getFormAction($this));
133 $this->form->setTitle($this->lng->txt(
'cal_new_ms'));
134 $this->form->addCommandButton(
'saveMilestone',$this->lng->txt(
'cal_add_milestone'));
135 $this->form->addCommandButton(
'cancel',$this->lng->txt(
'cancel'));
139 $this->form->setTitle($this->lng->txt(
'cal_new_app'));
140 $this->form->addCommandButton(
'save',$this->lng->txt(
'cal_add_appointment'));
141 $this->form->addCommandButton(
'cancel',$this->lng->txt(
'cancel'));
148 $this->form->setTitle($this->lng->txt(
'cal_edit_milestone'));
152 $this->form->setTitle($this->lng->txt(
'cal_edit_appointment'));
154 $this->ctrl->saveParameter($this,array(
'seed',
'app_id'));
155 $this->form->setFormAction($this->ctrl->getFormAction($this));
159 include_once(
'./Services/Calendar/classes/class.ilCalendarCategory.php');
166 $this->form->addCommandButton(
'editResponsibleUsers',$this->lng->txt(
'cal_change_responsible_users'));
168 $this->form->addCommandButton(
'update',$this->lng->txt(
'save'));
169 $this->form->addCommandButton(
'askDelete',$this->lng->txt(
'delete'));
170 $this->form->addCommandButton(
'cancel',$this->lng->txt(
'cancel'));
175 $title->setValue($this->app->getTitle());
176 $title->setRequired(
true);
177 $title->setMaxLength(128);
179 $this->form->addItem(
$title);
182 $calendar =
new ilSelectInputGUI($this->lng->txt(
'cal_category_selection'),
'calendar');
191 $calendar->setValue($cat);
195 include_once(
'./Services/Calendar/classes/class.ilCalendarCategories.php');
199 $calendar->setRequired(
true);
201 $calendar->setOptions($cats->prepareCategoriesOfUserForSelection());
202 $this->form->addItem($calendar);
204 if (!$a_as_milestone)
206 include_once
'./Services/Form/classes/class.ilDateDurationInputGUI.php';
207 #$tpl->addJavaScript('./Modules/Session/js/toggle_session_time.js');
208 $tpl->addJavaScript(
'./Services/Form/js/date_duration.js');
211 $dur->setEndText($this->lng->txt(
'cal_end'));
212 $dur->enableToggleFullTime(
213 $this->lng->txt(
'cal_fullday_title'),
214 $this->app->isFullday() ?
true : false
216 $dur->setMinuteStepSize(5);
217 $dur->setShowDate(
true);
218 $dur->setShowTime(
true);
219 $dur->setStart($this->app->getStart());
220 $dur->setEnd($this->app->getEnd());
221 $this->form->addItem($dur);
247 include_once(
'./Services/Calendar/classes/Form/class.ilRecurrenceInputGUI.php');
249 $rec->setRecurrence($this->rec);
250 $this->form->addItem(
$rec);
253 $where =
new ilTextInputGUI($this->lng->txt(
'cal_where'),
'location');
254 $where->
setValue($this->app->getLocation());
255 $where->setMaxLength(128);
257 $this->form->addItem($where);
262 $deadline->
setDate($this->app->getStart());
263 $deadline->setShowTime(
false);
264 $deadline->setMinuteStepSize(5);
265 $this->form->addItem($deadline);
268 $completion_vals = array();
269 for($i = 0; $i <= 100; $i+=5)
271 $completion_vals[$i] = $i.
" %";
276 $compl->setValue($this->app->getCompletion());
277 $this->form->addItem($compl);
281 $desc->setValue($this->app->getDescription());
283 $this->form->addItem(
$desc);
285 if ($a_as_milestone && $a_mode ==
"edit" && $resp_info)
288 $users = $this->app->readResponsibleUsers();
292 foreach($users as $r)
294 $value.= $delim.$r[
"lastname"].
", ".$r[
"firstname"].
" [".$r[
"login"].
"]";
297 if (count($users) > 0)
303 $resp->setValue(
"-");
306 $this->form->addItem($resp);
322 $tpl->setContent($this->form->getHTML());
336 $tpl->setContent($this->form->getHTML());
354 protected function save($a_as_milestone =
false)
358 $this->
load($a_as_milestone);
360 if($this->app->validate())
362 if(!(
int)
$_POST[
'calendar'])
368 $cat_id = (int)
$_POST[
'calendar'];
372 $this->rec->setEntryId($this->app->getEntryId());
375 include_once(
'./Services/Calendar/classes/class.ilCalendarCategoryAssignments.php');
379 include_once(
'./Services/Calendar/classes/class.ilCalendarCategory.php');
392 $this->ctrl->returnToParent($this);
397 $this->ctrl->returnToParent($this);
420 include_once(
'./Services/Calendar/classes/class.ilCalendarCategoryAssignments.php');
422 include_once(
'./Services/Calendar/classes/class.ilCalendarCategory.php');
436 include_once(
"./Services/Calendar/classes/class.ilMilestoneResponsiblesTableGUI.php");
438 $this->app->getEntryId());
439 $tpl->setContent($table_gui->getHTML());
449 $this->app->writeResponsibleUsers(
$_POST[
"user_id"]);
450 $ilCtrl->returnToParent($this);
464 include_once(
'./Services/Calendar/classes/class.ilCalendarCategory.php');
465 include_once(
'./Services/Calendar/classes/class.ilCalendarCategories.php');
466 include_once(
'./Services/Calendar/classes/class.ilCalendarCategoryAssignments.php');
471 if(!$cats->isVisible($cat_id))
473 $ilErr->raiseError($this->lng->txt(
'permission_denied'),$ilErr->WARNING);
476 if(!$cats->isEditable($cat_id) or $this->app->isAutoGenerated())
482 $this->
initForm(
'edit', $this->app->isMilestone());
483 $tpl->setContent($this->form->getHTML());
496 include_once(
"./Services/InfoScreen/classes/class.ilInfoScreenGUI.php");
498 $info->setFormAction($this->ctrl->getFormAction($this));
500 if ($this->app->isMilestone())
502 $info->addSection($this->lng->txt(
'cal_ms_details'));
506 $info->addSection($this->lng->txt(
'cal_details'));
510 $info->addProperty($this->lng->txt(
'appointment'),
512 $this->app->getStart(),
513 $this->app->getEnd()));
514 $info->addProperty($this->lng->txt(
'title'),$this->app->getPresentationTitle());
517 if(strlen(
$desc = $this->app->getDescription()))
519 $info->addProperty($this->lng->txt(
'description'),
$desc);
523 if(strlen($loc = $this->app->getLocation()))
525 $info->addProperty($this->lng->txt(
'cal_where'),$loc);
529 if ($this->app->isMilestone() && $this->app->getCompletion() > 0)
531 $info->addProperty($this->lng->txt(
'cal_task_completion'),
532 $this->app->getCompletion().
" %");
535 include_once(
'./Services/Calendar/classes/class.ilCalendarCategoryAssignments.php');
540 && (
$type ==
"grp" || $type ==
"crs"))
543 $users = $this->app->readResponsibleUsers();
545 foreach($users as $r)
547 $value.= $delim.$r[
"lastname"].
", ".$r[
"firstname"].
" [".$r[
"login"].
"]";
550 if (count($users) > 0)
552 $info->addProperty($this->lng->txt(
'cal_responsible'),
561 $info->addSection($this->lng->txt(
'additional_info'));
566 include_once(
'classes/class.ilLink.php');
568 $info->addProperty($this->lng->txt(
'perma_link'),
'<a class="small" href="'.$href.
'" target="_top">'.$href.
'</a>');
571 $tpl->setContent($info->getHTML());
584 $this->
load($this->app->isMilestone());
586 if($this->app->validate())
588 if(!(
int)
$_POST[
'calendar'])
594 $cat_id = (int)
$_POST[
'calendar'];
597 $this->app->update();
600 include_once(
'./Services/Calendar/classes/class.ilCalendarCategoryAssignments.php');
603 $ass->addAssignment($cat_id);
606 $this->ctrl->returnToParent($this);
627 include_once(
'./Services/Utilities/classes/class.ilConfirmationGUI.php');
629 $this->ctrl->saveParameter($this,array(
'seed',
'app_id'));
632 $confirm->setFormAction($this->ctrl->getFormAction($this));
633 $confirm->setHeaderText($this->lng->txt(
'cal_delete_app_sure'));
634 $confirm->setCancel($this->lng->txt(
'cancel'),
'edit');
635 $confirm->setConfirm($this->lng->txt(
'delete'),
'delete');
636 $confirm->addItem(
'appointments[]',$this->app->getEntryId(),$this->app->getTitle());
637 $tpl->setContent($confirm->getHTML());
648 protected function delete()
650 foreach(
$_POST[
'appointments'] as $app_id)
655 include_once(
'./Services/Calendar/classes/class.ilCalendarCategoryAssignments.php');
659 $this->ctrl->returnToParent($this);
673 $this->timezone = $ilUser->getTimeZone();
685 if(!isset(
$_GET[
'hour']))
687 $this->seed = clone
$seed;
688 $this->default_fulltime =
true;
692 if((
int)
$_GET[
'hour'] < 10)
694 $time =
'0'.(int)
$_GET[
'hour'].
':00:00';
698 $time = (int)
$_GET[
'hour'].
':00:00';
701 $this->default_fulltime =
false;
715 include_once(
'./Services/Calendar/classes/class.ilCalendarEntry.php');
716 include_once(
'./Services/Calendar/classes/class.ilCalendarRecurrences.php');
722 $this->app->setStart(
$start);
725 if($this->default_fulltime)
727 #$seed_end->increment(IL_CAL_DAY,1);
733 $this->app->setEnd($seed_end);
734 $this->app->setFullday($this->default_fulltime);
752 protected function load($a_as_milestone =
false)
756 $this->app->setMilestone(
true);
766 $this->app->setFullday(
true);
770 $this->app->setFullday(isset(
$_POST[
'event'][
'fulltime']) ?
true :
false);
773 if($this->app->isFullday())
777 $this->app->setStart(
$start);
779 $end =
new ilDate($_POST[
'event'][
'end'][
'date'][
'y'].
'-'.$_POST[
'event'][
'end'][
'date'][
'm'].
'-'.$_POST[
'event'][
'end'][
'date'][
'd'],
785 $this->app->setEnd(
$start);
789 $this->app->setEnd($end);
794 $start_dt[
'year'] = (int)
$_POST[
'event'][
'start'][
'date'][
'y'];
795 $start_dt[
'mon'] = (int)
$_POST[
'event'][
'start'][
'date'][
'm'];
796 $start_dt[
'mday'] = (int)
$_POST[
'event'][
'start'][
'date'][
'd'];
797 $start_dt[
'hours'] = (int)
$_POST[
'event'][
'start'][
'time'][
'h'];
798 $start_dt[
'minutes'] = (int)
$_POST[
'event'][
'start'][
'time'][
'm'];
800 $this->app->setStart(
$start);
802 $end_dt[
'year'] = (int)
$_POST[
'event'][
'end'][
'date'][
'y'];
803 $end_dt[
'mon'] = (int)
$_POST[
'event'][
'end'][
'date'][
'm'];
804 $end_dt[
'mday'] = (int)
$_POST[
'event'][
'end'][
'date'][
'd'];
805 $end_dt[
'hours'] = (int)
$_POST[
'event'][
'end'][
'time'][
'h'];
806 $end_dt[
'minutes'] = (int)
$_POST[
'event'][
'end'][
'time'][
'm'];
808 $this->app->setEnd($end);
823 switch(
$_POST[
'frequence'])
826 $this->rec->setFrequenceType(
$_POST[
'frequence']);
827 $this->rec->setInterval((
int)
$_POST[
'count_DAILY']);
831 $this->rec->setFrequenceType($_POST[
'frequence']);
832 $this->rec->setInterval((
int) $_POST[
'count_WEEKLY']);
833 if(is_array($_POST[
'byday_WEEKLY']))
840 $this->rec->setFrequenceType($_POST[
'frequence']);
841 $this->rec->setInterval((
int) $_POST[
'count_MONTHLY']);
842 switch((
int) $_POST[
'subtype_MONTHLY'])
849 switch((
int) $_POST[
'monthly_byday_day'])
853 $this->rec->setBYSETPOS((
int) $_POST[
'monthly_byday_num']);
854 $this->rec->setBYDAY(
'MO,TU,WE,TH,FR');
859 $this->rec->setBYMONTHDAY((
int) $_POST[
'monthly_byday_num']);
863 $this->rec->setBYDAY((
int) $_POST[
'monthly_byday_num'].$_POST[
'monthly_byday_day']);
869 $this->rec->setBYMONTHDAY((
int) $_POST[
'monthly_bymonthday']);
875 $this->rec->setFrequenceType($_POST[
'frequence']);
876 $this->rec->setInterval((
int) $_POST[
'count_YEARLY']);
877 switch((
int) $_POST[
'subtype_YEARLY'])
884 $this->rec->setBYMONTH((
int) $_POST[
'yearly_bymonth_byday']);
885 $this->rec->setBYDAY((
int) $_POST[
'yearly_byday_num'].$_POST[
'yearly_byday']);
889 $this->rec->setBYMONTH((
int) $_POST[
'yearly_bymonth_by_monthday']);
890 $this->rec->setBYMONTHDAY((
int) $_POST[
'yearly_bymonthday']);
897 switch((
int)
$_POST[
'until_type'])
904 $this->rec->setFrequenceUntilCount((
int) $_POST[
'count']);
919 switch(
$_POST[
'frequence'])
923 if($this->rec->getRecurrenceId())
925 $this->rec->delete();
930 if($this->rec->getRecurrenceId())
932 $this->rec->update();
955 $cat->setTitle($this->lng->txt(
'cal_default_calendar'));
956 $cat->setObjId($ilUser->getId());