<?php

namespace App\Http\Controllers\Admin;

use Illuminate\Http\Request;
use App\Http\Requests;
use App\Http\Controllers\Controller;

use App\User;
use App\Models\Task;

class ReportTaskController extends Controller
{
    public function completed_task_by_user(){

    	$data['title'] = "Report - Completed Tasks";
    	$data['all'] = "";
    	$data['user_name'] = "";
    	$data['tdate'] = "";
    	$data['fdate'] = "";
    	$data['users'] = User::where('utype',2)->where('active',1)->get();

    	return view('admin.report.completed_task_by_user',$data);
    }

    public function search_completed_task_by_user(Request $req){

    	$fromdate = $req->fromdate;
    	$todate = $req->todate;
    	$user_id = $req->user_id;

    	$user_name = User::find($user_id)->name;

    	$data['title'] = "Report - Completed Tasks";
    	$data['user_name'] = $user_name;
    	$data['tdate'] = $todate;
    	$data['fdate'] = $fromdate;
    	$data['all'] =  Task::where('start_time','>=',$fromdate)->with('proj_name')
    					->where('closing_time','<=',$todate)
    					->where('user_id',$user_id)
    					->where('status',6)->orderBy('proj_id')->get();
    	$data['users'] = User::where('utype',2)->where('active',1)->get();

    	return view('admin.report.completed_task_by_user',$data);
    }

    public function work_flow()
    {
        $data['title'] = "Work flow";
        $data['all'] = User::where('utype',2)->get();
    
        return view('admin.report.work_flow',$data);
    }
}
