/** * This function submits the changes made in event progress * * @param string POST data (from event progress update) * * @return if successful, 'Events Assigned To Me' page for Team Member */ public function EditProgress() { $input = Request::all(); $iName = $input['EventID']; $user_id = \Auth::user()->id; $iPercentage = array(); $iStatus = array(); $iTaskID = array(); if (isset($_POST['doneprogress'])) { $today = Carbon::today()->toDateString(); $em = Quote_Requests::select('*')->where('id', $iName)->first(); $mailData = ['EventID' => $iName, 'EventType' => $em->EventType, 'DueDate' => $em->DueDate, 'CompletedOn' => $today, 'FirstName' => $em->UserName]; //send email to customer Mail::send('emails.event-complete', $mailData, function ($message) use($em) { $message->to($em->Email, 'Test')->subject('Your Event Is Ready!'); }); //send a notification to customer $newNotification = new Notifications(); $newNotification->title = 'Event Complete'; $newNotification->body = $em->EventType . ' planning is complete'; $newNotification->icon = 'icon'; $newNotification->link = 'dashboard/events/progresscustomer?EventID=' . $iName; $newNotification->readStatus = '0'; $newNotification->save(); $message = $em->EventType . ' planning is complete'; $icon = 'icon'; $link = 'dashboard/events/progresscustomer?EventID=' . $iName; $title = 'Event Complete'; Pusher::trigger('notifications', 'success_notification', ['message' => $message, 'icon' => $icon, 'link' => $icon, 'title' => $title]); return redirect('dashboard/events/myevents')->with('message', 'You Completed The Event'); } else { foreach ($input['percentage'] as $x) { $iPercentage[] = $x; } foreach ($input['status'] as $y) { $iStatus[] = $y; } foreach ($input['taskid'] as $z) { $iTaskID[] = $z; } foreach ($input['taskid'] as $z => $value) { $today = Carbon::today()->toDateString(); Event_Tasks::where('EventID', $iName)->where('id', $iTaskID[$z])->update(['Percentage' => $iPercentage[$z], 'Status' => $iStatus[$z], 'LastUpdated' => $today]); } return redirect('dashboard/events/myevents')->with('message', 'Record Added Successfully'); } }