예제 #1
0
 public function doAMSearch(AMPlanSearchRequest $request)
 {
     $am = $request->am;
     $planSearchResult = [];
     $leaveRequestSearchResult = [];
     $from = $request->date_from;
     $to = $request->date_to;
     $allSearchedPlan = AMPlan::where('am_id', $am)->where('date', '>=', $from)->where('date', '<=', $to)->approved()->get();
     $allSearchLeaveRequest = AMLeaveRequest::where('am_id', $am)->where('date', '>=', $from)->where('date', '<=', $to)->approved()->get();
     foreach ($allSearchedPlan as $singleReport) {
         $planSearchResult[] = $singleReport;
     }
     foreach ($allSearchLeaveRequest as $singleLeaveRequest) {
         $leaveRequestSearchResult[] = $singleLeaveRequest;
     }
     $dataView = ['planSearchResult' => $planSearchResult, 'leaveRequestSearchResult' => $leaveRequestSearchResult];
     \Session::flash('emp', $am);
     \Session::flash('date_from', $from);
     \Session::flash('date_to', $to);
     \Session::flash('planSearchResult', $planSearchResult);
     \Session::flash('leaveRequestSearchResult', $leaveRequestSearchResult);
     return view('admin.search.plans.result', $dataView);
 }
예제 #2
0
 public function declinePendingLeaveRequest($id)
 {
     $leaveRequest = AMLeaveRequest::findOrFail($id);
     $leaveRequest->approved = 0;
     try {
         $leaveRequest->save();
         return redirect()->back()->with('message', 'Leave Request has been declined successfully !');
     } catch (ParseException $ex) {
         echo 'Failed to decline leave request , with error message: ' . $ex->getMessage();
     }
 }
예제 #3
0
 public function doSearch(PlanSearchRequest $request)
 {
     $mrs[] = $request->mrs;
     $planSearchResult = [];
     $leaveRequestSearchResult = [];
     $from = $request->date_from;
     $to = $request->date_to;
     $allSearchedPlan = Plan::whereIn('mr_id', $mrs)->where('date', '>=', $from)->where('date', '<=', $to)->approved()->get();
     $allSearchLeaveRequest = AMLeaveRequest::whereIn('am_id', $mrs)->where('date', '>=', $from)->where('date', '<=', $to)->approved()->get();
     foreach ($allSearchedPlan as $singleReport) {
         $planSearchResult[] = $singleReport;
     }
     foreach ($allSearchLeaveRequest as $singleLeaveRequest) {
         $leaveRequestSearchResult[] = $singleLeaveRequest;
     }
     $dataView = ['planSearchResult' => $planSearchResult, 'leaveRequestSearchResult' => $leaveRequestSearchResult];
     return view('am.search.plans.result', $dataView);
 }
예제 #4
0
 public function doCreateLeaveRequest(CreateLeaveRequestRequest $request)
 {
     $leaveRequest = new AMLeaveRequest();
     $leaveRequest->am_id = \Auth::user()->id;
     $leaveRequest->month = $request->month . '-' . $request->year;
     $leaveRequest->date = $request->date;
     $leaveRequest->reason = $request->reason;
     $leaveRequest->leave_start = $request->leave_start;
     $leaveRequest->leave_end = $request->leave_end;
     $leaveRequest->count = $request->count;
     try {
         if ($leaveRequest->save()) {
             $extension = $request->file('docs')->getClientOriginalExtension();
             $request->file('docs')->move(public_path('uploads/leave_requests/' . \Auth::user()->id . '/' . $leaveRequest->month . '/'), $leaveRequest->date . '.' . $extension);
         }
         return redirect()->back()->with('message', 'Leave Request has been sent to your managers successfully !');
     } catch (ParseException $ex) {
         echo 'Failed to create new leave request , with error message: ' . $ex->getMessage();
     }
 }
예제 #5
0
 public function getAMPendingLeaveRequests()
 {
     $leaveRequests = AMLeaveRequest::pending()->get();
     return count($leaveRequests);
 }