Пример #1
0
 protected function populateForm()
 {
     $task_ndx = 1;
     $task_groups = TaskGroup::orderBy('id')->get();
     foreach ($task_groups as $key => $tg) {
         if ($task_ndx > 4) {
             break;
         }
         Former::populateField('group' . $task_ndx . '_name', $tg->name);
         Former::populateField('group' . $task_ndx . '_order', $tg->order);
         $task_ndx++;
     }
 }
Пример #2
0
 /**
  * Create a new Taskgroup using all the form details of the taskgroup form
  * 
  * @param task_group_type, eg. "TaskGroupType_TaskTodo"
  * @param title, the task group title
  * @param description, a description
  * @param default_assignee_id, a user_id or null
  * @param can_assign, OWNER|MEMBER|GUEST
  * @param can_view, OWNER|MEMBER|GUEST
  * @param can_create, OWNER|MEMBER|GUEST
  * @param is_active, 0|1
  * @param is_deleted, 0|1
  *  
  * @return TaskGroup
  */
 function createTaskGroup($type, $title, $description, $default_assignee_id, $can_assign = "OWNER", $can_view = "OWNER", $can_create = "OWNER", $is_active = 1, $is_deleted = 0)
 {
     // title should be unique!
     $taskgroup = $this->getTaskGroupByUniqueTitle($title);
     if (null != $taskgroup) {
         return $taskgroup;
     }
     // insert newly created task group into the task_group database
     $taskgroup = new TaskGroup($this->w);
     $taskgroup->task_group_type = $type;
     $taskgroup->title = $title;
     $taskgroup->description = $description;
     $taskgroup->can_assign = $can_assign;
     $taskgroup->can_view = $can_view;
     $taskgroup->can_create = $can_create;
     $taskgroup->is_active = $is_active;
     $taskgroup->is_deleted = $is_deleted;
     $taskgroup->default_assignee_id = $default_assignee_id;
     $response = $taskgroup->insert();
     // Check the validation
     if ($response !== true) {
         $this->w->errorMessage($taskgroup, "Taskgroup", $response, false, "/task-group/viewtaskgrouptypes#create");
     }
     // if created succcessfully, create default notify matrix: all on
     if ($taskgroup->id) {
         $arr['guest']['creator'] = 1;
         $arr['member']['creator'] = 1;
         $arr['member']['assignee'] = 1;
         $arr['owner']['creator'] = 1;
         $arr['owner']['assignee'] = 1;
         $arr['owner']['other'] = 1;
         // so foreach role/type lets put the values in the database
         foreach ($arr as $role => $types) {
             foreach ($types as $type => $value) {
                 $notify = new TaskGroupNotify($this->w);
                 $notify->task_group_id = $taskgroup->id;
                 $notify->role = $role;
                 $notify->type = $type;
                 $notify->value = $value;
                 $notify->insert();
             }
         }
     }
     // if task group is successfully created and a default assignee is defined
     // create a task group membership list and set this person as the task group owner
     // if no default assignee, a task group membership list can be created at any time
     if ($taskgroup->id && $default_assignee_id != "") {
         $arrdb = array();
         $arrdb['task_group_id'] = $taskgroup->id;
         $arrdb['user_id'] = $default_assignee_id;
         $arrdb['role'] = "OWNER";
         $arrdb['priority'] = 1;
         $arrdb['is_active'] = 1;
         $mem = new TaskGroupMember($this->w);
         $mem->fill($arrdb);
         $mem->insert();
     }
     return $taskgroup;
 }
Пример #3
0
 public function sendStoreRequest($settings, $key_id, $value, $expire)
 {
     $protocol_groups = $this->groupByProtocols($settings);
     unset($protocol_groups['']);
     $task_group = new TaskGroup($settings);
     foreach ($protocol_groups as $prot_id => $node_list) {
         $protocol =& $settings->instantiateProtocolById($prot_id);
         $task = $protocol->sendStoreRequest($key_id, $value, $expire, $node_list);
         $task_group->add($task);
     }
     return $task_group;
 }
Пример #4
0
     break;
 case 'group.create':
     #debug($req_json);
     $datum = json_decode($req_json);
     #debug_foreach($datum);
     $group = TaskGroup::with_obje($datum);
     if ($group) {
         $result = $group->save();
         $json = json_encode($result);
     }
     break;
 case 'group.update':
     $data = json_decode($req_json);
     $results = array();
     foreach ($data as $datum) {
         $group = TaskGroup::with_obje($datum);
         if ($group) {
             $result = $group->save();
             $results[] = $result;
         } else {
             $results[] = null;
         }
     }
     $json = json_encode($results);
     break;
 case 'task.list':
     $datum = json_decode($req_json);
     #debug_foreach($datum);
     $tasks = Task::all($datum->group_id);
     if (empty($tasks)) {
         $tasks = array();
Пример #5
0
 public function getDetails($model)
 {
     /*
         Get details associated with a given event
     */
     $event_date_col = $model->date()->first();
     $event_date = $event_date_col ? $event_date_col->datetime_start->format('Y-m-d') : null;
     $event_deadline = TaskEvent::select('due_date')->where('events_id', $model->id)->whereNotNull('due_date')->orderBy('due_date', 'ASC')->first();
     $all_event_deadline = TaskEvent::select('due_date')->where('events_id', $model->id)->orderBy('due_date', 'ASC')->get();
     //eerror_log('ED '.json_encode($all_event_deadline));
     $model_venue = $model->venues()->first();
     if (!$model_venue) {
         $event_location = 'unknown';
     } else {
         if (!$model_venue->address) {
             $event_location = 'unknown';
         } else {
             $venue_address = $model_venue->address;
             $event_location = $model_venue->address->city . ' (' . $model_venue->address->country->abbreviation . ')';
         }
     }
     $task_groups = TaskGroup::orderBy('order')->get();
     $event_completion = [];
     $event_completion_data = [];
     $group_ndx = 1;
     foreach ($task_groups as $key => $tg) {
         if ($group_ndx > 4) {
             break;
         }
         $completed = TaskEvent::where('events_id', $model->id)->where('group_id', $tg->id)->where('status', 'complete')->where('active', 1)->count();
         $total = TaskEvent::where('events_id', $model->id)->where('group_id', $tg->id)->where('active', 1)->count();
         $event_completion['group' . $tg->id] = [];
         $event_completion['group' . $tg->id]['completed'] = $completed;
         $event_completion['group' . $tg->id]['total'] = $total;
         $event_completion['group' . $tg->id]['name'] = $tg->name;
         $event_completion['group' . $tg->id]['order'] = $tg->order;
         // same in a more convenient format
         $event_completion_data[] = (object) ['id' => $tg->id, 'name' => $tg->name, 'order' => $tg->order, 'completed' => $completed, 'total' => $total];
         $group_ndx++;
     }
     $resp = ['date' => $event_date, 'location' => $event_location, 'deadline' => $event_deadline ? date("Y-m-d", strtotime($event_deadline->due_date)) : 'UNK', 'completion' => $event_completion, 'data' => $event_completion_data];
     return $resp;
 }