コード例 #1
0
ファイル: EventsController.php プロジェクト: strikles/php
 public function addDefaultTasks($model)
 {
     // add to taskevents all the tasktemplates
     $default_tasks = TaskTemplate::all();
     $event_date_col = $model->date()->first();
     if (!$event_date_col) {
         return;
     }
     $event_date = $event_date_col->datetime_start->format('Y-m-d');
     eerror_log("Le event date : " . $event_date);
     foreach ($default_tasks as $task_ndx => $task) {
         if ($task->deadline_days_gap > 0) {
             $task_deadline = date('Y-m-d', strtotime(-$task->deadline_days_gap . ' days', strtotime($event_date)));
         } else {
             $task_deadline = date('Y-m-d', strtotime($event_date));
         }
         $new_task = new TaskEvent();
         $new_task->title = $task->title;
         $new_task->description = $task->description;
         $new_task->due_date = $task_deadline;
         $new_task->status = 'incomplete';
         $new_task->group_id = $task->group_id;
         $new_task->events_id = $model->id;
         $new_task->deadline_days_gap = $task->deadline_days_gap;
         $new_task->updated_by = Auth::user()->id;
         $new_task->owner_changed_at = date("Y-m-d H:i:s");
         eerror_log('task due date ' . json_encode($new_task->due_date) . '\\n');
         $new_task->save();
     }
 }
コード例 #2
0
ファイル: TaskFileController.php プロジェクト: strikles/php
 public function getFileURL($file)
 {
     $url = "";
     // find the file
     $afile = TaskFile::find($file->id);
     if (!$afile) {
         return "";
     }
     // get corresponding taskevent so that we can get at the event_id
     // used to segment files per event
     $taskevent = TaskEvent::find($afile->taskevents_id);
     if (!$taskevent) {
         return "";
     }
     $url = $this->aws_client->getObjectUrl($this->aws_config['bucket'], "files/events/{$taskevent->events_id}/" . $afile->path, '+60 minutes', array('ResponseContentDisposition' => 'attachment; filename=' . $afile->original_filename, 'ResponseContentType' => 'application/octet-stream'));
     return $url;
 }
コード例 #3
0
ファイル: events.php プロジェクト: strikles/php
<?php

Event::listen('event.datechanged', function ($event) {
    $event_date = $event->date()->first();
    $tasks = TaskEvent::where('events_id', $event->id)->get();
    if ($event_date) {
        $event_date_str = $event_date->datetime_start->format('d-m-Y');
        foreach ($tasks as $task_ndx => $task) {
            $task_deadline = new DateTime($event_date_str);
            //error_log(__DIR__.' >> Le event '.$task_deadline->format('d-m-Y'));
            if ($task->deadline_days_gap > 0) {
                $disc = 'P' . $task->deadline_days_gap . 'D';
                $task_deadline->sub(new DateInterval($disc));
                $task->due_date = $task_deadline->format('Y-m-d');
                $task->save();
                //error_log('Updating task due_date'.json_encode($task->due_date));
            }
        }
    }
    return false;
});
Event::listen('event.created', function ($event) {
    // associate user who created the event with the event
    return false;
});
コード例 #4
0
ファイル: PromoterController.php プロジェクト: strikles/php
 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;
 }