Exemplo n.º 1
0
 /**
  * Display a listing of the resource.
  *
  * @return Response
  */
 public function index()
 {
     $this->data['user'] = User::where('deleted_at', null)->count();
     $this->data['user_disabled'] = User::where('deleted_at', !null)->count();
     $this->data['department'] = Department::where('enabled', 1)->count();
     $this->data['position'] = Position::where('enabled', 1)->count();
     return view('pages.admin.dashboard', $this->data);
 }
 /**
  * Update the specified resource in storage.
  *
  * @param  Request  $request
  * @param  int  $id
  * @return Response
  */
 public function update(PositionsRequest $request)
 {
     $position = Position::where('id', $request['positionID'])->first();
     $position->name = $request['name'];
     $position->save();
     \Session::flash('success', $request['name'] . ' has been successfully updated!');
     return redirect()->back();
 }
Exemplo n.º 3
0
 /**
  * Display a listing of the resource.
  *
  * @return \Illuminate\Http\Response
  */
 public function index()
 {
     $request = request();
     $name = $request->has('name') ? $request->get('name') : '';
     $positions = Position::where(function ($query) use($name) {
         if (!empty($name)) {
             $query->where('name', 'LIKE', "%{$name}%");
         }
     })->paginate(env('LIMIT', 15));
     return view('positions.index', compact('positions', 'name'));
 }
 /**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  *
  * @return \Illuminate\Http\Response
  */
 public function store(Request $request)
 {
     $validator = \Validator::make($request->all(), ['body' => 'required', 'translation_id' => 'sometimes|exists:translations,id', 'via_dictionary' => 'sometimes|boolean']);
     if ($validator->passes()) {
         if ($request->input('via_dictionary')) {
             $definitions = \YaDictionary::lookup($request->input('body'));
             if ($definitions) {
                 foreach ($definitions as $definition) {
                     $partOfSpeech = $definition->getPartOfSpeech();
                     if (!($position = Position::where('body', $partOfSpeech)->first())) {
                         $position = Position::create(['body' => $partOfSpeech]);
                     }
                     if (!Word::where('body', $definition->getText())->where('position_id', $position->id)->first()) {
                         $word = new Word();
                         $word->body = $definition->getText();
                         $word->ts = $definition->getTranscription();
                         $word->position()->associate($position);
                         $word->save();
                         $translationIds = [];
                         foreach ($definition->getTranslations() as $yaTranslation) {
                             if (!($translation = Translation::where('body', $yaTranslation->getText())->first())) {
                                 $translation = Translation::create(['body' => $yaTranslation->getText()]);
                             }
                             $translationIds[] = $translation->id;
                         }
                         $word->translations()->attach($translationIds);
                     }
                 }
                 $response = response('This word has created from the dictionary', 201);
             } else {
                 $response = response()->json(['errors' => ['This word has not found in the dictionary.']], 404);
             }
         } else {
             if ($translationId = $request->input('translation_id')) {
                 $word = Word::create(['body' => $request->input('body')]);
                 $word->translations()->attach($translationId);
                 $response = response()->json(['id' => $word->getId()], 201);
             } else {
                 $response = response()->json(['errors' => ['It needs a translation.']], 400);
             }
         }
     } else {
         $response = response()->json(['errors' => $validator->messages()->all()], 400);
     }
     return $response;
 }
Exemplo n.º 5
0
 /**
  * Update the specified resource in storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function update($id)
 {
     if (Request::isMethod('get')) {
         $this->data['positions'] = Position::where('enabled', 1)->get();
         $this->data['departments'] = Department::where('enabled', 1)->get();
         $this->data['item'] = User::find($id);
         if ($this->data['item']) {
             return view('pages.user.update', $this->data);
         } else {
             return redirect('user');
         }
     } elseif (Request::isMethod('post')) {
         $user = User::find($id);
         $user->update(Input::all());
         return redirect('user');
     }
 }
 /**
  * Store a newly created resource in storage.
  *
  * @param  Request  $request
  * @return Response
  */
 public function store(UserRequest $request, User $user)
 {
     /*  New User Table */
     $user->name = $request['Fname'];
     $user->surname = $request['Sname'];
     $user->cellphone = $request['Cell1'];
     $user->username = $request['Email'];
     $user->email = $request['Cell1'];
     $position = Position::where('slug', '=', $request['Position'])->first();
     $user->position = $position->id;
     $province = Province::where('slug', '=', $request['Province'])->first();
     $user->province = $province->id;
     $district = District::where('slug', '=', $request['District'])->first();
     $user->district = $district->id;
     $municipalityIds = array();
     foreach ($request['Municipality'] as $municipalityName) {
         $municipality = Municipality::where('slug', '=', $municipalityName)->first();
         $municipalityIds[] = $municipality->id;
     }
     $user->municipality = implode(",", $municipalityIds);
     $department = Department::where('slug', '=', $request['Department'])->first();
     $user->department = $department->id;
     $password = rand(1000, 99999);
     $user->password = \Hash::make($password);
     $user->api_key = uniqid();
     $user->status = 1;
     $user->role = 2;
     $user->save();
     \Session::flash('success', $request['Fname'] . ' ' . $request['Sname'] . ' has been added successfully!');
     $data = array('name' => $user->name, 'username' => $user->email, 'password' => $password);
     \Mail::send('emails.registrationConfirmation', $data, function ($message) use($user) {
         $message->from('*****@*****.**', 'Siyaleader');
         $message->to($user->username)->subject("Siyaleader User Registration Confirmation: " . $user->name);
     });
     return redirect('list-users');
 }
Exemplo n.º 7
0
 public function getAvailableUnits($id)
 {
     $file = file_get_contents("units.txt");
     $units = json_decode($file, true);
     $position = Position::find($id);
     $x = $position->x;
     $y = $position->y;
     $position = Position::where('y', $y)->where('x', $x)->get()->lists('id');
     $city = City::whereIn('position_id', $position)->get();
     if (count($city) == 0) {
         return $city;
     } else {
         switch ($city[0]->tier) {
             case 1:
                 $txt = 'tier1';
                 break;
             case 2:
                 $txt = 'tier2';
                 break;
         }
         $units = Unit::whereIn('Id', $units[$txt])->with('resource')->get();
         return \App\CityEffectApplier::modifyUnitPricesByCity($units, $city[0]);
     }
 }
Exemplo n.º 8
0
 /**
  * Show the form for editing the specified resource.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function edit($id)
 {
     $position = Position::where('active', 1)->get();
     // if is Leader
     // if staff edit != dev or yourself => denied
     if (Gate::allows('check-leader')) {
         $staff = Staff::find($id)->level->role;
         if ($staff->name != "Developer" && $id != Auth::user()->id) {
             return redirect()->route('admin.staff.index')->with('message', 'Access is denied');
         } else {
             $level = Level::where('role_id', 4)->get();
             $department = Department::where('id', Auth::user()->department_id)->where('active', 1)->get()->first();
         }
     } else {
         if (Gate::allows('check-admin')) {
             $staff = Staff::find($id)->level->role;
             if ($staff->name == "Developer" && $id != Auth::user()->id) {
                 return redirect()->route('admin.staff.index')->with('message', 'Access is denied');
             } else {
                 $department = Department::where('active', 1)->get();
                 $level = Level::where(['role_id' => 2, 'active' => 1])->orWhere(['role_id' => 3, 'active' => 1])->get();
             }
         } else {
             if (Gate::allows('check-manager')) {
                 $staff = Staff::find($id)->level->role;
                 if ($staff->name == "Manager" && $id != Auth::user()->id) {
                     return redirect()->route('admin.staff.index')->with('message', 'Access is denied');
                 } else {
                     $level = Level::where('role_id', 3)->orWhere('role_id', 4)->get();
                     if ($id == Auth::user()->id) {
                         $department = '';
                     }
                     $department = Department::where('active', 1)->get();
                 }
             } else {
                 $staff_id = Auth::user()->id;
                 if ($staff_id != $id) {
                     return redirect()->route('admin.staff.index')->with('message', 'Access is denied');
                 } else {
                     $position = Position::where('id', Auth::user()->position_id)->where('active', 1)->get();
                     $level = Level::where('id', Auth::user()->level_id)->where('active', 1)->get();
                     $department = Department::where('id', Auth::user()->department_id)->where('active', 1)->get()->first();
                 }
             }
         }
     }
     if ($id == Auth::user()->id) {
         $check_account = 1;
     } else {
         $check_account = 0;
     }
     $staff = Staff::find($id);
     return view('admin.staff.update', compact('id', 'staff', 'position', 'level', 'department', 'check_account'));
 }
Exemplo n.º 9
0
 public function getCityArmyIsIn($army)
 {
     $position = Position::where('y', $army->position->y)->where('x', $army->position->x)->get()->lists('id');
     $city = City::whereIn('position_id', $position)->get();
     return $city[0];
 }
 public function departmentMonthlyPosition(Request $request)
 {
     $this->date_start = $request->month && $request->year ? new Carbon('first Monday of ' . $request->month . ' ' . $request->year) : new Carbon('first Monday of this month');
     // first Monday of the month
     $this->date_end = $request->month && $request->year ? new Carbon('last Monday of ' . $request->month . ' ' . $request->year) : new Carbon('last Monday of this month');
     // last Monday of the month
     $project = Project::with('positions')->where('department_id', $request->id)->first();
     $first_report = Report::where('project_id', $project->id)->whereBetween('date_start', [$this->date_start, $this->date_end])->orderBy('date_start')->first();
     $project->reports = Report::with('project')->where('project_id', $project->id)->whereBetween('date_start', [$this->date_start, $this->date_end])->where('daily_work_hours', 'like', $first_report->daily_work_hours . '%')->get();
     $project->members = Experience::with(['member' => function ($query) {
         $query->withTrashed();
     }])->where('project_id', $project->id)->get();
     foreach ($project->members as $member_key => $member) {
         $member->total_output = 0;
         $member->total_output_error = 0;
         $member->total_hours_worked = 0;
         $member->average_output = 0;
         $member->monthly_productivity = 0;
         $member->monthly_quality = 0;
     }
     foreach ($project->reports as $report_key => $report) {
         $project->position = Position::where('id', $request->input('position.id'))->first();
         $report->members = Experience::with('member')->where('project_id', $report->project_id)->get();
         foreach ($report->members as $member_key => $member) {
             $member->performance = Performance::with('position')->with(['target' => function ($query) {
                 $query->withTrashed();
             }])->where('member_id', $member->member_id)->where('report_id', $report->id)->where('position_id', $request->input('position.id'))->first();
             if ($member->performance) {
                 $project->members[$member_key]->total_output += $member->performance->output;
                 $project->members[$member_key]->total_output_error += $member->performance->output_error;
                 $project->members[$member_key]->total_hours_worked += $member->performance->hours_worked;
             }
         }
         $report->date_start = Carbon::parse($report->date_start)->toFormattedDateString();
         $report->date_end = Carbon::parse($report->date_end)->toFormattedDateString();
     }
     if (count($project->reports)) {
         foreach ($project->members as $member_key => $member) {
             for ($i = 0; $i < count($project->reports); $i++) {
                 if ($project->reports[$i]->members[$member_key]->performance) {
                     $target = $project->reports[$i]->members[$member_key]->performance->target;
                     $member->average_output = round($member->total_output / $member->total_hours_worked * $first_report->daily_work_hours, 2);
                     $member->monthly_productivity = round($member->average_output / $target->productivity * 100, 2);
                     $member->monthly_quality = round((1 - $member->total_output_error / $member->total_output) * 100, 2);
                     if ($member->monthly_productivity < 100 && $member->monthly_quality >= $target->quality) {
                         $member->quadrant = 'Quadrant 1';
                     } else {
                         if ($member->monthly_productivity >= 100 && $member->monthly_quality >= $target->quality) {
                             $member->quadrant = 'Quadrant 2';
                         } else {
                             if ($member->monthly_productivity >= 100 && $member->monthly_quality < $target->quality) {
                                 $member->quadrant = 'Quadrant 3';
                             } else {
                                 if ($member->monthly_productivity < 100 && $member->monthly_quality < $target->quality) {
                                     $member->quadrant = 'Quadrant 4';
                                 }
                             }
                         }
                     }
                 }
             }
         }
     }
     $project->date_cover_start = $this->date_start->toFormattedDateString();
     $project->date_cover_end = $this->date_end->toFormattedDateString();
     return $project;
 }
Exemplo n.º 11
0
 public function getPositionToMoveTo()
 {
     $x = $this->army->move_to_x;
     $y = $this->army->move_to_y;
     $position = Position::where('x', $x)->where('y', $y)->first();
     if ($position == null) {
         $position = new Position();
         $position->x = $x;
         $position->y = $y;
     }
     return $position;
 }
 /**
  * Update the specified resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function update(Request $request, $id)
 {
     $this->validate($request, ['name' => 'required|string']);
     $duplicate = Position::whereNotIn('id', [$request->id])->where('name', $request->name)->where('department_id', $request->department_id)->where('project_id', $request->project_id)->first();
     if ($duplicate) {
         return response()->json(true);
     }
     $position = Position::where('id', $id)->first();
     $position->name = $request->name;
     // $position->department_id = $request->department_id;
     // $position->project_id = $request->project_id;
     $position->save();
     return $position;
 }
Exemplo n.º 13
0
 /**
  * Store a newly created resource in storage.
  *
  * @param  Request  $request
  * @return Response
  */
 public function store(UserRequest $request, User $user)
 {
     $role = UserRole::where('slug', '=', $request['role'])->first();
     $user->role = $role->id;
     $title = Title::where('slug', '=', $request['title'])->first();
     $user->title = $title->id;
     $language = Language::where('slug', '=', $request['language'])->first();
     $user->language = $language->id;
     $user->name = $request['name'];
     $user->surname = $request['surname'];
     $user->cellphone = $request['cellphone'];
     $user->alt_cellphone = $request['alt_cellphone'];
     $user->email = $request['email'];
     $user->alt_email = $request['alt_email'];
     $province = Province::where('slug', '=', $request['province'])->first();
     $user->province = $province->id;
     $district = District::where('slug', '=', $request['district'])->first();
     $user->district = $district->id;
     $municipality = Municipality::where('slug', '=', $request['municipality'])->first();
     $user->municipality = $municipality->id;
     $ward = Ward::where('slug', '=', $request['ward'])->first();
     $user->ward = $ward->id;
     $department = Department::where('slug', '=', $request['department'])->first();
     $user->department = $department->id;
     $position = Position::where('slug', '=', $request['position'])->first();
     $user->position = $position->id;
     $password = rand(1000, 99999);
     $user->password = \Hash::make($password);
     $user->api_key = uniqid();
     $user->created_by = \Auth::user()->id;
     $user->save();
     \Session::flash('success', $request['name'] . ' ' . $request['surname'] . ' user has been added successfully!');
     $data = array('name' => $user->name, 'username' => $user->email, 'password' => $password);
     \Mail::send('emails.registrationConfirmation', $data, function ($message) use($user) {
         $message->from('*****@*****.**', 'Siyaleader');
         $message->to($user->email)->subject("Siyaleader Notification - User Registration Confirmation: " . $user->name);
     });
     return redirect('list-users');
 }
Exemplo n.º 14
0
 public function apply($position)
 {
     $countries = $this->getCountries();
     $position = str_replace('-', ' ', $position);
     $position = Position::where('position', 'LIKE', '%' . $position . '%')->first();
     return view('pages.apply', compact('position', 'countries'));
 }