/**
  * Display a listing of the resource.
  *
  * @return Response
  */
 public function index()
 {
     $user = Auth::user();
     $recruiting = parent::getRecruiting($user->id, 0);
     $clientDev = parent::getClientDev($user->id, 0);
     $clientDevOut = parent::getClientDevOut($user->id, 0);
     return view('myRatio.report', compact('recruiting', 'clientDev', 'clientDevOut'));
 }
 /**
  * Display a listing of the resource.
  *
  * @return Response
  */
 public function index()
 {
     $directHire = parent::getDirectHire(null, 0);
     $directHireAnnual = parent::getDirectHireAnnual(null, 0);
     $directHireTarget = parent::getDirectHireTarget(null, 0);
     $gmp = parent::getGMP(null, 0);
     $gmpAnnual = parent::getGMPAnnual(null, 0);
     $pointMonthly = parent::getPointMonthly(null, 0);
     $pointDaily = parent::getPointDaily(null, 0);
     //        $gmpTarget = parent::getGMPTarget( null );
     //        $recruitingData = parent::getRecruitingPoints( null );
     //        $recruitingGoal = parent::getRecruitingGoal( null );
     //        return view('prodSales.report', compact('recruitingData', 'recruitingGoal', 'directHire', 'directHireAnnual', 'directHireTarget', 'gmp', 'gmpAnnual', 'gmpTarget'));
     return view('prodSales.report', compact('directHireTarget', 'directHireAnnual', 'directHire', 'gmp', 'gmpAnnual', 'pointMonthly', 'pointDaily'));
 }
 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store(Requests\UpdateAndSaveCompany $request, Company $company)
 {
     $request->offsetSet('created_by', Auth::user()->id);
     $request->offsetSet('updated_by', Auth::user()->id);
     $request->offsetSet('status', 'ACTIVE');
     $company->create($request->all());
     $company = DB::table('companies')->where('name', $request->name)->first();
     $password = $request->password;
     $user = new User();
     $request->offsetSet('password', bcrypt($request->password));
     $request->offsetSet('created_by', Auth::user()->id);
     $request->offsetSet('updated_by', Auth::user()->id);
     $request->offsetSet('status', "NEW");
     $request->offsetSet('role_id', "4");
     $request->offsetSet('manager_id', 0);
     $request->offsetSet('company_id', $company->id);
     $user->create($request->all());
     $user = DB::table('users')->where('email', $request->email)->first();
     $goal = parent::assembleGoalSetting();
     $goal->user_id = $user->id;
     $goal->created_by = Auth::user()->id;
     $goal->updated_by = Auth::user()->id;
     $goal->save();
     $userPassword = new UserPassword();
     $userPassword->user_id = $user->id;
     $userPassword->crypt_password = \Crypt::encrypt($password);
     $userPassword->updated_at = new \DateTime();
     $userPassword->created_at = new \DateTime();
     $userPassword->save();
     $contactEmail = $user->email;
     $contactName = $user->first_name . ' ' . $user->last_name;
     Mail::send('emails.hello', array('first_name' => $user->first_name, 'user_name' => $user->email, 'password' => $password), function ($message) use($contactEmail, $contactName) {
         $message->from('*****@*****.**', 'Sales Performance Indicator');
         $message->to($contactEmail, $contactName)->subject('Welcome to Sales Performance Indicator!');
     });
     \Session::flash('message', 'You have successfully Created ' . $company->name);
     $companies = Company::orderBy('name')->paginate(15);
     $keyword = '';
     return view('company.list', compact('companies', 'keyword'));
 }
 private function getTarget()
 {
     $user_id = Auth::user()->id;
     return $users = DB::table('goal_managements')->select(DB::raw(parent::getMonthQuery() . ' as target'))->where('user_id', '=', $user_id)->first();
 }
 public function reset($id)
 {
     $user = User::findOrFail($id);
     $userPassword = UserPassword::whereRaw('user_id = ?', array($id))->first();
     $date = new \DateTime();
     //this returns the current date time
     $password = parent::randStrGen(8);
     $user->password = bcrypt($password);
     $userPassword->crypt_password = \Crypt::encrypt($password);
     $user->updated_by = Auth::user()->id;
     $user->status = 'RESET';
     $user->save();
     $userPassword->update();
     \Session::flash('message', 'You have successfully Reset ' . $user->last_name . ', ' . $user->first_name . '\'s password. ');
     $message = 'You have successfully Reset ' . $user->last_name . ', ' . $user->first_name . '\'s password. ';
     $keyword = '';
     $users = $this->getActiveUsers();
     $contactEmail = $user->email;
     $contactName = $user->first_name . ' ' . $user->last_name;
     Mail::send('emails.reset', array('first_name' => $user->first_name, 'last_name' => $user->last_name, 'user_name' => $contactEmail, 'password' => $password), function ($message) use($contactEmail, $contactName) {
         $message->from('*****@*****.**', 'Sales Performance Indicator');
         $message->to($contactEmail, $contactName)->subject('Password Reset');
     });
     return view('user.list', compact('users', 'keyword'));
 }
 public function statistics($id)
 {
     $user = User::findOrFail($id);
     $directHire = parent::getDirectHire($user->id);
     $directHireAnnual = parent::getDirectHireAnnual($user->id, 0);
     $directHireTarget = parent::getDirectHireTarget($user->id);
     $gmp = parent::getGMP($user->id);
     $gmpAnnual = parent::getGMPAnnual($user->id);
     return view('prodSales.report', compact('directHireTarget', 'directHireAnnual', 'directHire', 'gmp', 'gmpAnnual', 'user'));
 }