示例#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
 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;
 }