Exemplo n.º 1
0
 public function create()
 {
     $user = Auth::user();
     $userGroups = UserGroup::where('level', '>', $user->user_group_id)->lists('name_en', 'id');
     $designations = Designation::lists('name', 'id');
     $workspaces = Workspace::lists('name', 'id');
     return view('employees.create', compact('designations', 'workspaces', 'userGroups'));
 }
 public function sumUserGroup($date)
 {
     $userGroup = UserGroup::where('item_id', $this->item->id)->where('user_grouping_date', $date)->first();
     if ($userGroup && $this->getNextUserGroupDate($date) < date("Y-m-d")) {
         return $userGroup;
     }
     $userDefinition = $this->item->project->userDefinition;
     $value = DB::connection($this->item->project->db)->table($userDefinition->table_name)->whereRaw($this->item->other_criteria ? $this->item->other_criteria : 'TRUE')->where($userDefinition->date_column, '>=', $date)->where($userDefinition->date_column, '<', $this->getNextUserGroupDate($date))->count();
     if (!$userGroup) {
         $userGroup = new UserGroup();
         $userGroup->user_grouping_date = $date;
     }
     $userGroup->value = $value;
     return $this->item->userGroups()->save($userGroup);
 }
Exemplo n.º 3
0
 public function getForEdit($id)
 {
     $data = [];
     $e = $this->empDto->findById($id);
     if ($e) {
         $ug = UserGroup::where('user_id', $e->user->id)->first();
         $data['empId'] = $e->id;
         $data['id_number'] = substr($e->id_number, 4);
         $data['first_name'] = $e->first_name;
         $data['middle_name'] = $e->middle_name;
         $data['last_name'] = $e->last_name;
         $data['sex'] = $e->sex;
         $data['birthday'] = $e->birthday;
         $data['email'] = $e->user->email;
         $data['shift'] = ['id' => $e->shift->id];
         $data['group'] = ['id' => $ug->group->id];
     }
     return $data;
 }
Exemplo n.º 4
0
 public function create()
 {
     $groups = UserGroup::where('id', '!=', 1)->lists('name_en', 'id');
     $workspaces = Workspace::lists('name', 'id');
     return view('users.create', compact('groups', 'workspaces'));
 }
Exemplo n.º 5
0
 /**
  * @param $userId
  * @return 1 if User is Administrator
  * @return 2 if User is Student
  * @return 3 if User is Teacher
  */
 public static function checkUserTypeByUserId($userId)
 {
     $userGroup = UserGroup::where('user_id', $userId)->get()->first();
     return $userGroup->group_id;
 }
Exemplo n.º 6
0
<?php

use App\Models\UserGroup;
use App\Models\UserDetails;
use App\Models\Groups;
$user_id = Auth::user()->id;
$user_group = UserGroup::where('user_id', '=', $user_id)->get()->first();
$userDetails = UserDetails::where('user_id', '=', $user_id)->get()->first();
$admin_group_id = Groups::Administrator_Group_ID;
$teacher_group_id = Groups::Teacher_Group_Id;
$student_group_id = Groups::Student_Group_Id;
?>
@section('upper-dropdown')
    <a data-toggle="dropdown" data-hover="dropdown" class="dropdown-toggle" data-close-others="true" href="#">
        @if($userDetails->pic == null)
            <img src="{{ URL::asset('assets/images/anonymous.jpg') }}" class="img-circle" alt="" width="30px"
                 height="30px" id="upper_dropdown_menu_profile_image">
        @else
            <img src="{{ URL::asset('school/images/user/profile_images/'.$userDetails->pic) }}" class="img-circle"
                 alt="" width="30px" height="30px" id="upper_dropdown_menu_profile_image">
        @endif
        <span class="username hidden-xs">{{ $userDetails->first_name }} {{ $userDetails->last_name }}</span> <i
                class="fa fa-caret-down "></i>
    </a>
@stop
@section('left-user-profile')
    <div class="inline-block">
        @if($userDetails->pic == null)
            <img src="{{ URL::asset('assets/images/anonymous.jpg') }}" class="img-circle" alt="" width="50px"
                 height="50px" id="left_menu_profile_image">
        @else
Exemplo n.º 7
0
 function save(array $params)
 {
     $response = new ResponseEntity();
     DB::transaction(function () use(&$response, $params) {
         $empId = isset($params['empId']) ? intval($params['empId']) : 0;
         $idNumber = Config::get('hris_system.employee_id_prefix') . $params['id_number'];
         $existingEmp = Employee::with('user')->find($empId);
         // check for duplicate id_number
         $tempEmp = Employee::where('id_number', '=', $idNumber)->first();
         if ($tempEmp) {
             if (!$existingEmp) {
                 // new
                 $response->setMessages(['id_number' => ['Id number is already taken']]);
                 return $response;
             } else {
                 if ($existingEmp && $existingEmp->id != $tempEmp->id) {
                     // update
                     $response->setMessages(['id_number' => ['Id number is already taken']]);
                     return $response;
                 }
             }
         }
         if ($empId > 0 && !$existingEmp) {
             // check when updating
             $response->setMessages(['Employee is not available!']);
             return $response;
         } else {
             // employee user account
             $user = $existingEmp ? $existingEmp->user : new User();
             $user->email = $params['email'];
             if (!$existingEmp) {
                 // for new employee user account
                 $user->password = Hash::make($idNumber);
                 //default password is the ID Number of the employee
                 $user->active = '1';
             }
             $user->save();
             // clear user group
             UserGroup::where('user_id', $user->id)->delete();
             // assign group
             $ug = new UserGroup();
             $ug->user_id = $user->id;
             $ug->group_id = $params['group_id'];
             $ug->save();
             // employee records
             $employee = $existingEmp ? $existingEmp : new Employee();
             $employee->user_id = $user->id;
             $employee->id_number = $idNumber;
             $employee->first_name = $params['first_name'];
             $employee->last_name = $params['last_name'];
             if (isset($params['middle_name'])) {
                 $employee->middle_name = $params['middle_name'];
             }
             if (isset($params['supervisor_id'])) {
                 $employee->supervisor_id = $params['supervisor_id'];
             }
             $employee->sex = $params['sex'];
             $employee->birthday = Carbon::createFromFormat('m/d/Y', $params['birthday']);
             $employee->shift_id = $params['shift_id'];
             $employee->active = $existingEmp ? $existingEmp->active : '1';
             $ok = $employee->save();
             if ($ok) {
                 $response->setSuccess(true);
                 $response->setData(['empId' => $employee->id]);
                 $response->setMessages(['Employee successfully ' . ($existingEmp ? 'saved' : 'created')]);
             } else {
                 $response->setMessages(['Failed to ' . ($existingEmp ? 'save' : 'create') . ' employee!']);
             }
         }
     });
     return $response;
 }
Exemplo n.º 8
0
 public function getUserGroup()
 {
     return UserGroup::where('UserID', $this->UserID)->where('Default', 'Y');
 }