public function testActivityCanBeAddedToAnEvent1()
 {
     $this->logIn();
     $event = new Event();
     $event->name = 'Kokous';
     $event->time = '2016-07-25 16:40:00';
     $event->place = 'Kolo';
     $event->description = 'Iltakokous';
     $event->endDate = '2016-07-25 17:20:20';
     $event->group_id = self::createTestGroup();
     $event->save();
     $activity = new Activity();
     $activity->name = 'Kalastus';
     $activity->guid = 'Guid';
     $activity->age_group = 'sudenpennut';
     $activity->task_group = 'pohjoinen';
     $activity->save();
     $event_id = DB::table('events')->where('name', 'Kokous')->value('id');
     // Pitää muutta occurensejä käyttämään
     /* $this->visit('/events/'. $event_id)
        ->click('Muuta aktiviteetteja')
        ->see('Äänestys')
        ->press('Lisää')
        ->click('Takaisin')
        ->see('Äänestys'); */
 }
 /**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function store(Request $request)
 {
     $notify_report = false;
     for ($i = 0; $i < count($request->all()); $i++) {
         if ($request->input($i . '.include')) {
             $this->validate($request, [$i . '.id' => 'required', $i . '.member.id' => 'required|numeric', $i . '.position_id' => 'required|numeric', $i . '.project_id' => 'required|numeric', $i . '.target_id' => 'required|numeric', $i . '.output' => 'required|numeric', $i . '.date_start' => 'required|date', $i . '.date_end' => 'required|date', $i . '.hours_worked' => 'required|numeric', $i . '.daily_work_hours' => 'required|numeric', $i . '.output_error' => 'required|numeric']);
             // check if a report is already created
             if (!$notify_report) {
                 $admin = User::where('role', 'admin')->first();
                 $report = Report::where('id', $request->input($i . '.report_id'))->first();
                 // create a notification
                 $notification = new Notification();
                 $notification->message = 'updated a ';
                 $notification->sender_user_id = $request->user()->id;
                 $notification->receiver_user_id = $admin->id;
                 $notification->subscriber = 'admin';
                 $notification->state = 'main.weekly-report';
                 $notification->event_id = $report->id;
                 $notification->event_id_type = 'report_id';
                 $notification->seen = false;
                 $notification->save();
                 $notify = DB::table('reports')->join('users', 'users.id', '=', 'reports.user_id')->join('projects', 'projects.id', '=', 'reports.project_id')->join('notifications', 'notifications.event_id', '=', 'reports.id')->select('reports.*', 'users.*', DB::raw('LEFT(users.first_name, 1) as first_letter'), 'projects.*', 'notifications.*')->where('notifications.id', $notification->id)->first();
                 // foreach ($query as $key => $value) {
                 //     $notify = $value;
                 // }
                 event(new ReportSubmittedBroadCast($notify));
                 $activity_type = ActivityType::where('action', 'update')->first();
                 $activity = new Activity();
                 $activity->report_id = $report->id;
                 $activity->user_id = $request->user()->id;
                 $activity->activity_type_id = $activity_type->id;
                 $activity->save();
                 // report
                 $create_report = true;
             }
             $old_performance = Performance::where('id', $request->input($i . '.id'))->first();
             // record history of the performance
             $performance_history = new PerformanceHistory();
             $performance_history->activity_id = $activity->id;
             $performance_history->performance_id = $old_performance->id;
             $performance_history->report_id = $old_performance->report_id;
             $performance_history->member_id = $old_performance->member_id;
             $performance_history->position_id = $old_performance->position_id;
             $performance_history->department_id = $old_performance->department_id;
             $performance_history->project_id = $old_performance->project_id;
             $performance_history->target_id = $old_performance->target_id;
             $performance_history->date_start = $old_performance->date_start;
             $performance_history->date_end = $old_performance->date_end;
             $performance_history->daily_work_hours = $old_performance->daily_work_hours;
             $performance_history->output = $old_performance->output;
             $performance_history->hours_worked = $old_performance->hours_worked;
             $performance_history->output_error = $old_performance->output_error;
             $performance_history->average_output = $old_performance->average_output;
             $performance_history->productivity = $old_performance->productivity;
             $performance_history->quality = $old_performance->quality;
             $performance_history->quadrant = $old_performance->quadrant;
             $performance_history->save();
         }
     }
 }
 /**
  * Bootstrap the application services.
  *
  * @return void
  */
 public function boot()
 {
     Task::created(function ($task) {
         $activity = new Activity();
         $activity->user_id = Auth::user()->id;
         $activity->task_id = $task->id;
         $activity->message = 'task created';
         $activity->save();
     });
 }
Example #4
0
 private static function pullDataForProvider($provider)
 {
     foreach ($provider->providesSensors() as $name => $type) {
         $functionName = self::getFunctionName($name, $type);
         $val = $provider->{$functionName}();
         $activity = new Activity();
         $activity->provider = get_class($provider);
         $activity->name = $name;
         $activity->value = $val;
         $activity->save();
     }
 }
Example #5
0
 public function authenticate()
 {
     $username = Input::get('username');
     $password = Input::get('password');
     $remember = Input::get('remember');
     if (Auth::viaRemember() || Auth::attempt(['email' => $username, 'password' => $password], $remember) || Auth::attempt(['username' => $username, 'password' => $password], $remember)) {
         // Authentication passed...
         $thisactivity = new Activity();
         $thisactivity->createActivity(Auth::user(), 'login', 'have logged in', 0);
         return redirect()->intended('/home');
     } else {
         return redirect()->intended('/login')->withErrors(['Username and/or Password you entered does not belong to any user']);
     }
 }
 public function testActivityIsAddedToUserCorrectly()
 {
     $this->logIn();
     $user = new User();
     $user->membernumber = '100000';
     $user->firstname = 'First_name';
     $user->lastname = 'Last_name';
     $user->save();
     $activity = new Activity();
     $activity->guid = 1;
     $activity->name = 'Activity 1';
     $activity->age_group = 'sudenpennut';
     $activity->task_group = 'pohjoinen';
     $activity->save();
     $this->visit('/users/1/activities')->select('1', 'activityId')->press('Lisää')->seeInDatabase('activity_user', ['activity_id' => 1, 'user_id' => 1]);
 }
 public function performIntuitiveAssignment()
 {
     //Grab all the activities
     $activities = Activity::all();
     //pr0duce a tally 0f h0w many succesful applicati0ns each activity has received,
     //in the f0rm 0f an ass0ciative array f0r th0se activities which have received
     //m0re than 0 applicati0ns
     $activityApplicationTally = array();
     foreach ($activities as $activity) {
         //get a c0unt 0f the number 0f succesful applicants f0r this activity
         $numSuccesfulApplicants = $activity->getSuccessfulApplications->count();
         if ($numSuccesfulApplicants > 0) {
             $activityApplicationTally[$activity->id] = $numSuccesfulApplicants;
         }
     }
     //fr0m http://www.w3schools.com/php/func_array_asort.asp
     asort($activityApplicationTally, SORT_NUMERIC);
     foreach ($activityApplicationTally as $activityID => $numSuccesfulApplicants) {
         $numTutorsRequired = Activity::find($activityID)->quant_ppl_needed;
         echo $numTutorsRequired;
         //var_dump($activity);
     }
     //return $activityApplicationTally;
     //return Activity::with('activityRequests');
 }
 private function initData()
 {
     $this->login();
     factory(App\Activity::class, 50)->create();
     factory(App\User::class, 10)->create();
     factory(App\User::class, 'admin', 1)->create();
     factory(App\Group::class, 25)->create()->each(function ($g) {
         for ($i = 0; $i < 5; $i++) {
             $g->users()->save(factory(App\User::class)->make(), ['role' => 'member']);
         }
         $g->users()->save(factory(App\User::class)->make(), ['role' => 'leader']);
     });
     factory(App\Event::class, 5)->create()->each(function ($event) {
         $date = $event->time->startOfDay();
         $endDate = $event->endDate;
         do {
             $occurrence = new EventOccurrence();
             $occurrence->event_id = $event->id;
             $occurrence->date = $date;
             $occurrence->save();
             $date->addWeek();
         } while ($date < $endDate);
     });
     $faker = Faker\Factory::create();
     $occurrences = EventOccurrence::all();
     $activities = Activity::all()->toArray();
     foreach ($occurrences as $occurrence) {
         foreach ($faker->randomElements($activities, $faker->randomDigit) as $activity) {
             $occurrence->activities()->attach($activity['id']);
         }
     }
 }
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     $faker = Faker\Factory::create();
     // Create a faker, add en_SG providers
     $faker->addProvider(new Faker\Provider\en_SG\Address($faker));
     $faker->addProvider(new Faker\Provider\en_SG\Enhanced($faker));
     $faker->addProvider(new Faker\Provider\en_SG\Person($faker));
     $faker->addProvider(new Faker\Provider\en_SG\PhoneNumber($faker));
     $faker->seed(9876);
     // Calling the same script twice with the same seed produces the same results
     $durations = [30, 45, 60, 75, 90, 105, 120, 135, 150, 165, 180];
     // Insert 30 dummy records
     foreach (range(1, 30) as $index) {
         $startDate = $faker->dateTimeBetween('-3 months', '3 months');
         $startHour = ['08', '09', '10', '11', '13', '14', '15', '16'];
         $startMin = ['00', '15', '30', '45'];
         while (Carbon::instance($startDate)->dayOfWeek === Carbon::SUNDAY) {
             $startDate = $faker->dateTimeBetween('-3 months', '3 months');
         }
         if ($startDate === Carbon::SATURDAY) {
             $startHour = ['08', '09', '10', '11'];
         }
         $startTime = $faker->randomElement($startHour) . ":" . $faker->randomElement($startMin) . ":00";
         $elderly = Elderly::with('centre')->find($faker->numberBetween(1, 15));
         $staffList = $elderly->centre->staff->lists('staff_id')->toArray();
         Activity::create(['datetime_start' => $startDate->format('Y-m-d') . " " . $startTime, 'expected_duration_minutes' => $faker->randomElement($durations), 'category' => 'transport', 'more_information' => $faker->optional(0.4, '')->sentence(10, true), 'location_from_id' => $elderly->centre_id, 'location_to_id' => $faker->numberBetween(4, 6), 'elderly_id' => $elderly->elderly_id, 'centre_id' => $elderly->centre_id, 'staff_id' => $faker->randomElement($staffList)]);
     }
 }
Example #10
0
 public static function transformOutMany($activities)
 {
     foreach ($activities as $k => $v) {
         $activities[$k] = Activity::transformOut($v);
     }
     return $activities;
 }
 /**
  * Define your route model bindings, pattern filters, etc.
  *
  * @param  \Illuminate\Routing\Router  $router
  * @return void
  */
 public function boot(Router $router)
 {
     //
     parent::boot($router);
     $router->bind('devices', function ($slug) {
         return \App\Device::findBySlugOrFail($slug);
     });
     $router->bind('types', function ($slug) {
         return \App\DeviceType::findBySlugOrFail($slug);
     });
     $router->bind('locations', function ($slug) {
         return \App\DeviceLocation::findBySlugOrFail($slug);
     });
     $router->bind('admins', function ($slug) {
         return \App\User::findBySlugOrFail($slug);
     });
     $router->bind('systemusers', function ($slug) {
         return \App\User::findBySlugOrFail($slug);
     });
     $router->bind('activitylogs', function ($id) {
         return \App\Activity::findOrFail($id);
     });
     $router->bind('userlogs', function ($id) {
         return \App\UserLog::findOrFail($id);
     });
     $router->bind('authuser', function ($slug) {
         return \App\User::findBySlugOrFail($slug);
     });
 }
 public function update($id, Request $request)
 {
     if ($this->inputIsValid($request)) {
         $agenda = Agenda::findOrFail($id);
         $agenda->update($request->except('attendees', 'activities'));
         // Remove all old attendees.
         $agenda->users()->detach();
         // Add attendees to agenda_user table as many-to-many relationship.
         foreach ($request->input('attendees') as $attendeeId) {
             $agenda->users()->attach(1, ['agenda_id' => $agenda->id, 'user_id' => $attendeeId]);
         }
         // Remove this agenda_id from all its activities.
         foreach ($agenda->activities() as $activity) {
             $activity = Activity::find($activityId);
             $activity->agenda_id = 0;
             $activity->save();
         }
         // Add agenda_id to a_activities table.
         foreach ($request->input('activities') as $activityId) {
             $activity = Activity::find($activityId);
             $activity->agenda_id = $agenda->id;
             $activity->save();
         }
         return response()->json(['header' => 'Your agenda was successfully updated!', 'info' => 'Both your agenda here on Meeter and you Google
               Calendar event were updated with your changes.'], 200);
     } else {
         return response()->json('', 400);
     }
 }
 /**
  * Display the specified resource.
  *
  * @param  int  $id
  * @return Response
  */
 public function show($id)
 {
     $actArray = POF::getItem(Activity::findOrFail($id)->guid);
     $activity = Activity::findOrFail($id);
     $singleActArray = ['title' => array_get($actArray, 'title', 'ei määritetty'), 'guid' => array_get($actArray, 'guid', 'ei määritetty'), 'content' => array_get($actArray, 'content', 'ei määritetty'), 'pakollisuus' => array_get($actArray, 'tags.pakollisuus.name', 'ei määritetty'), 'pakollisuusikoni' => array_get($actArray, 'tags.pakollisuus.0.icon', 'ei määritetty'), 'ryhmakoko' => array_get($actArray, 'tags.ryhmakoko.0.name', 'ei määritetty'), 'agegroup' => array_get($actArray, 'parents.1.title'), 'paikka' => array_get($actArray, 'tags.paikka.0.name', 'ei määritetty'), 'suoritus_kesto' => array_get($actArray, 'tags.suoritus_kesto.name', 'ei määritetty')];
     return view('activity', compact('singleActArray', 'activity'));
 }
 /**
  * Execute the command.
  *
  * @return void
  */
 public function handle()
 {
     $this->menu->updated_at = Carbon::now();
     $this->menu->update($this->request->all());
     Activity::create(['text' => $this->auth->linkedName() . ' updated menu named ' . $this->menu->linkedName(), 'user_id' => $this->auth->id]);
     Session::flash('flash_message', 'You have updated menu!');
 }
Example #15
0
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function destroy($id)
 {
     $item = Activity::find($id);
     $item->status = 'deleted';
     $item->save();
     Log::create(array("user_id" => Auth::user()->id, "action" => "Delete Activities named " . $item->name));
 }
Example #16
0
 /**
  * Show the form for editing the specified resource.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function edit($id)
 {
     $warehouse = Warehouse::findOrFail($id);
     $activities = Activity::lists('name', 'id');
     $types = Type::lists('name', 'id');
     return view('warehouses.edit', compact('warehouse', 'activities', 'types'));
 }
 /**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function store($id, Request $request)
 {
     $this->validate($request, ['file' => 'required|mimes:jpg,jpeg,png']);
     $activity = Activity::findOrFail($id);
     $photo = $request->file('file');
     ActivityPhoto::createPhoto($activity, $photo);
     return 'Done';
 }
 /**
  * Run the migrations.
  *
  * @return void
  */
 public function up()
 {
     $activities = Activity::where('type', 'Run')->orderBy('start_date_local', 'desc')->get();
     foreach ($activities as $activity) {
         $activity->details = 0;
         $activity->save();
     }
 }
 /**
  * Update the specified resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function update(Requests\SpacificationEditRequesyt $request, $id)
 {
     $especificacion = Spacification::find($id);
     $especificacion->fill($request->all());
     $especificacion->save();
     $actividad = Activity::find($especificacion->activity_id);
     return response()->json(['valid', $especificacion, $actividad]);
 }
 /**
  * Register any other events for your application.
  *
  * @param  \Illuminate\Contracts\Events\Dispatcher $events
  * @return void
  */
 public function boot(DispatcherContract $events)
 {
     parent::boot($events);
     $events->listen('auth.login', function ($user, $remember) {
         // Record user login
         Activity::create(['subject_type' => 'User', 'subject_id' => '', 'event' => 'Logged In', 'user_id' => $user->id, 'ip' => Request::server('REMOTE_ADDR')]);
     });
 }
 public function byLoan($id, Manager $fractal, ActivityTransformer $activityTransformer)
 {
     // show all
     $records = Activity::where('loan_id', $id)->get();
     $collection = new Collection($records, $activityTransformer);
     $data = $fractal->createData($collection)->toArray();
     return $this->respond($data);
 }
 /**
  * Bootstrap any application services.
  *
  * @return void
  */
 public function boot()
 {
     \App\Project::observe(new \App\Observers\ActivityObserver());
     \App\Task::observe(new \App\Observers\ActivityObserver());
     \App\Activity::creating(function ($activity) {
         $activity->user()->associate(auth()->user());
     });
 }
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function destroy($id)
 {
     if (Activity::destroy($id)) {
         return "Activity deleted successfully.";
     } else {
         return $this->response->error('Activity does not exist.', 404);
     }
 }
 /**
  * Removes activity from given event
  *
  * @param type $id
  * @param type $activityId
  */
 public function remove($id, $occId, Request $request)
 {
     $eventOccurrence = EventOccurrence::where('event_id', $id)->findOrFail($occId);
     $activity = Activity::findOrFail($request->input('activityId'));
     $eventOccurrence->activities()->detach($activity);
     $eventOccurrence->save();
     return redirect()->back();
 }
Example #25
0
 /**
  * Execute the console command.
  *
  * @return mixed
  */
 public function fire()
 {
     //register log in DB
     $dateBegin = new \DateTime();
     $activity = Activity::concept(ConstDb::LOAD_CRL)->first();
     if ($activity) {
         $activity->date_begin = $dateBegin->format('Y-m-d H:i:s');
         $activity->save();
     } else {
         Activity::create(['concept' => ConstDb::LOAD_CRL, 'date_begin' => $dateBegin->format('Y-m-d H:i:s')]);
     }
     //end log
     $this->info('Begin: ' . date('H:i:s'));
     $result = DB::connection('mysql_crl')->select($this->getQuery(true));
     $rows = $result[0]->total;
     $this->info("Total de filas: {$rows}");
     $begin = 0;
     $block = 10000;
     $countBlock = 1;
     $fCsv = storage_path('app/crl.csv');
     if (file_exists($fCsv)) {
         unlink($fCsv);
     }
     $fp = fopen($fCsv, 'w');
     fputs($fp, "organization, from, year, quarter, month, total \n");
     while ($rows > $begin) {
         $result = DB::connection('mysql_crl')->select($this->getQuery(false, $begin, $block));
         foreach ($result as $key => $value) {
             $array = json_decode(json_encode($value), true);
             $replace = ["\n", ',', '  '];
             $replaceTo = ["", ';', ' '];
             foreach ($array as $key => $value) {
                 $array[$key] = str_replace($replace, $replaceTo, $value);
             }
             fputs($fp, implode($array, ',') . "\n");
         }
         $this->info("End block {$countBlock}: " . date('H:i:s'));
         $begin += $block;
         $countBlock++;
     }
     fclose($fp);
     $this->info('End export CSV: ' . date('H:i:s'));
     Schema::drop('crl');
     $db = env('MONGO_DATABASE');
     $command = "mongoimport -d {$db} -c crl --type csv --file {$fCsv} --headerline";
     shell_exec($command);
     //register log in DB
     $dateEnd = new \DateTime();
     $activity = Activity::concept(ConstDb::LOAD_CRL)->first();
     if ($activity) {
         $activity->date_end = $dateEnd->format('Y-m-d H:i:s');
         $activity->save();
     } else {
         Activity::create(['concept' => ConstDb::LOAD_CRL, 'date_end' => $dateEnd->format('Y-m-d H:i:s')]);
     }
     //end log
     $this->info('End: ' . $dateEnd->format('H:i:s'));
 }
 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Closure  $next
  * @return mixed
  */
 public function handle($request, Closure $next)
 {
     $activity = Activity::findOrFail($request->route()->parameter('activities'));
     // Allows only activity that has no applicant and starts in the future
     if (str_contains($activity->getApplicationStatus(), 'No application') && !$activity->datetime_start->isToday()) {
         return $next($request);
     }
     return redirect('/activities');
 }
Example #27
0
 public function index(Request $request)
 {
     $activities = Activity::with(['user', 'subject'])->latest();
     $activities = $activities->where('old_value', 'LIKE', '%' . $request->get('filter') . '%');
     $activities = $activities->orwhere('new_value', 'LIKE', '%' . $request->get('filter') . '%');
     $activities = $activities->orWhere('name', 'LIKE', '%' . $request->get('filter') . '%')->paginate(25);
     $activities->setPath('activity');
     return view('activity.index', compact('activities'));
 }
Example #28
0
 public function getActivityOfOneMonth($month, $year)
 {
     $date = Carbon::create($year, $month, 1, 0);
     $initial_date = $date->toDateString();
     $last_date = $date->addMonth()->subDay()->toDateString();
     $trucks = Car::lists('name');
     $activities = Activity::where('date', '>=', $initial_date)->where('date', '<=', $last_date)->get();
     return $activities;
 }
Example #29
0
 /**
  * Define the application's command schedule.
  *
  * @param  \Illuminate\Console\Scheduling\Schedule  $schedule
  * @return void
  */
 protected function schedule(Schedule $schedule)
 {
     $schedule->command('inspire')->hourly();
     // Delete user activity older than 30 days
     $schedule->call(function () {
         Activity::where('created_at', '<', date('Y-m-d H:i:s', strtotime("-1 month")))->delete();
     })->daily();
     $schedule->command('bill:run')->daily();
 }
 public function index()
 {
     $activities = Activity::all()->take(2);
     $title = trans('default.home');
     $locale = App::getLocale();
     $homeText = HomeText::first();
     $sliders = Slider::all();
     return view('pages.index', compact('title', 'activities', 'locale', 'homeText', 'sliders'));
 }