예제 #1
0
 /**
  * @NoAdminRequired
  */
 public function setCompletedPercentMainTask()
 {
     $id = $this->params('id');
     $aTask = TasksApp::getEventObject($id, true, true);
     if ($aTask['relatedto'] === '') {
         $subTaskIds = TasksApp::getSubTasks($aTask['eventuid']);
         if ($subTaskIds !== '') {
             $tempIds = explode(',', $subTaskIds);
             $iSubTasksComplete = 0;
             foreach ($tempIds as $subIds) {
                 $vcalendar = TasksApp::getVCalendar($subIds, true, true);
                 $vtodo = $vcalendar->VTODO;
                 if ($vtodo->{'PERCENT-COMPLETE'}) {
                     $iSubTasksComplete += (int) $vtodo->getAsString('PERCENT-COMPLETE');
                 }
             }
             if ($iSubTasksComplete > 0) {
                 $gesamtCptl = $iSubTasksComplete * 100 / (100 * count($tempIds));
                 $gesamtCptl = round($gesamtCptl);
                 $vcalendar1 = TasksApp::getVCalendar($id, true, true);
                 $vtodoMain = $vcalendar1->VTODO;
                 TasksApp::setComplete($vtodoMain, $gesamtCptl, null);
                 TasksApp::edit($id, $vcalendar1->serialize());
                 $params = ['id' => $id, 'percentCptl' => $gesamtCptl];
                 $response = new JSONResponse();
                 $response->setData($params);
                 return $response;
             }
         }
     }
 }
예제 #2
0
 /**
  * @NoAdminRequired
  */
 public function setCompletedTask()
 {
     $id = $this->params('id');
     $checked = $this->params('checked');
     $vcalendar = CalendarApp::getVCalendar($id);
     $vtodo = $vcalendar->VTODO;
     TasksApp::setComplete($vtodo, $checked ? 100 : 0, null);
     Object::edit($id, $vcalendar->serialize());
     $user_timezone = CalendarApp::getTimezone();
     $aTask = TasksApp::getEventObject($id, true, true);
     $aCalendar = CalendarCalendar::find($aTask['calendarid']);
     $task_info[] = TasksApp::arrayForJSON($id, $vtodo, $user_timezone, $aCalendar, $aTask);
     $subTaskIds = '';
     if ($aTask['relatedto'] === '') {
         $subTaskIds = TasksApp::getSubTasks($aTask['eventuid']);
         if ($subTaskIds !== '') {
             $tempIds = explode(',', $subTaskIds);
             foreach ($tempIds as $subIds) {
                 $vcalendar = TasksApp::getVCalendar($subIds, true, true);
                 $vtodo = $vcalendar->VTODO;
                 TasksApp::setComplete($vtodo, $checked ? 100 : 0, null);
                 TasksApp::edit($subIds, $vcalendar->serialize());
                 $task_info[] = TasksApp::arrayForJSON($subIds, $vtodo, $user_timezone, $aCalendar, $aTask);
             }
         }
     }
     $params = ['status' => 'success', 'data' => $task_info];
     $response = new JSONResponse($params);
     return $response;
 }