public static function absentEveryEmployee() { $employees = Employee::where('status', '=', 'active')->get(); $absentess = []; foreach ($employees as $employee) { //Count the absent except half days foreach (Leavetype::where('leaveType', '<>', 'half day')->get() as $leave) { //$absentess[$employee->employeeID][$leave->leaveType] = 0; // Half Day leaves are added to casual leaves.2 half days are equal to one Casual Leave $absentess[$employee->employeeID][$leave->leaveType] = Attendance::where('status', '=', 'absent')->where('employeeID', '=', $employee->employeeID)->where(function ($query) { $query->where('application_status', '=', 'approved')->orWhere('application_status', '=', null); })->where('leaveType', '=', $leave->leaveType)->count(); } // half days count foreach (Leavetype::where('leaveType', '=', 'half day')->get() as $leave) { $half_day = Attendance::select('halfDayType', DB::raw('count(*) as total'))->where('status', '=', 'absent')->where('employeeID', '=', $employee->employeeID)->where(function ($query) { $query->where('application_status', '=', 'approved')->orWhere('application_status', '=', null); })->where('leaveType', '=', $leave->leaveType)->groupBy('halfDayType')->get(); foreach ($half_day as $half) { $absentess[$employee->employeeID][$half->halfDayType] += $half->total / 2; } } // Total of All leaves $absentess[$employee->employeeID]['total'] = array_sum($absentess[$employee->employeeID]); } return $absentess; }
public function edit($id) { $returnment = Returnment::with('employee')->find($id); $employees = Employee::where('location_id', '=', Auth::user()->location_id)->get(); $menu = 'finance'; return View::make('returnments.edit', compact('returnment', 'employees', 'menu')); }
public function index() { $retrievals = Retrieval::where('project_id', '=', Auth::user()->curr_project_id)->where('location_id', '=', Auth::user()->location_id)->get(); $employees = Employee::where('location_id', '=', Auth::user()->location_id)->get(); $menu = 'student'; return View::make('retrievals.index', compact('retrievals', 'employees', 'menu')); }
public function store() { $validator = Validator::make($data = Input::all(), Employee::$rules); if ($validator->fails()) { return Redirect::back()->withErrors($validator)->withInput(); } /* Employee */ if (Input::has('createEmployee')) { Employee::create($data); } $message = "登録しました。"; if (Input::has('deleteEmployee')) { $e = Employee::where('name', Input::get('name'))->first(); Employee::destroy($e->id); $message = "削除しました。"; if (Input::has('selectedEmployee')) { Input::replace(array('selectedEmployee', '')); } } if (Input::has('updateEmployee')) { $validator_for_update = Validator::make($data = Input::all(), Employee::$update_rules); if ($validator_for_update->fails()) { return Redirect::back()->withErrors($validator_for_update)->withInput(); } $e = Employee::where('name', Input::get('name'))->first(); Employee::destroy($e->id); $data['name'] = $data['new_name']; Employee::create($data); $message = "更新しました。"; } return Redirect::route('employees.index')->with('message', $message); }
public function create($course_id) { $course = Course::with('placements')->find($course_id); $employees = Employee::where('teach_salary', '>', 0.0)->get(); $hours = Hour::all(); $menu = 'academic'; return View::make('presences.create', compact('course', 'subjects', 'employees', 'hours', 'menu')); }
public function employees($members) { $employee = json_decode($members); foreach ($employee as $key) { $employ[] = Employee::where('employee_identity', $key)->first()->name; } return $employ; }
public function edit($id) { $quiz = Quiz::find($id); $subjects = Subject::all(); $employees = Employee::where('teach_salary', '>', 0.0)->get(); $menu = 'academic'; return View::make('quizzes.edit', compact('quiz', 'subjects', 'employees', 'menu')); }
/** * Show the form for editing the specified resource. * * @param int $id * @return Response */ public function edit($id) { $doctors = Employee::where('role', 'Doctor')->where('status', 'active')->get(); $patients = Patient::all(); $opt = Opt::find($id); $timeslot = $opt->timeslot->first()->where('dutyday_id', $opt->timeslot->dutyday_id)->lists('slot', 'id'); return View::make('opt.edit', compact('timeslot', 'opt', 'doctors', 'patients')); }
public function create() { $courses = Course::where('project_id', '=', Auth::user()->curr_project_id)->where('location_id', '=', Auth::user()->location_id)->get(); $employees = Employee::where('location_id', '=', Auth::user()->location_id)->get(); $classifications = Classification::where('category', '=', 'Resign')->get(); $menu = 'student'; return View::make('resigns.create', compact('courses', 'classifications', 'employees', 'menu')); }
/** * Show the form for creating a new prescription * * @return Response */ public function create() { $appointment = Appointment::find(Input::get('id')); $patient_id = $appointment->patient->id; $doctors = Employee::where('role', 'Doctor')->where('status', 'Active')->get(); $medicines = Medicine::all()->lists('name', 'id'); return View::make('prescriptions.create', compact('medicines', 'appointment', 'patient_id', 'doctors')); }
public function update() { $param = Input::all(); $emp_id = Employee::where('ssn', '=', $param['ssn'])->pluck('id'); $user = Account::find($param['id']); $res = $user->edit(array('username' => $param['username'], 'password' => $param['password'], 'emp' => $emp_id, 'role' => $param['role'])); return Response::json(array('valid' => $res)); }
public function filter($month, $year) { $curr_month = $month; $curr_year = $year; $installments = Installment::where('project_id', '=', Auth::user()->curr_project_id)->where('location_id', '=', Auth::user()->location_id)->where(DB::raw('year(schedule)'), '=', $curr_year)->where(DB::raw('month(schedule)'), '=', $curr_month)->get(); $employees = Employee::where('location_id', '=', Auth::user()->location_id)->get(); $menu = 'finance'; return View::make('installments.index', compact('installments', 'employees', 'curr_year', 'curr_month', 'menu')); }
public function edit($id) { $teach = Teach::find($id); $employees = Employee::where('teach_salary', '>', 0.0)->get(); $subjects = Subject::all(); $hours = Hour::all(); $menu = 'employee'; return View::make('teaches.edit', compact('teach', 'employees', 'subjects', 'hours', 'menu')); }
public function create($issue_id) { $issue = Issue::find($issue_id); $receivable = Receivable::with('installments')->where('issue_id', '=', $issue_id)->first(); $registration = Registration::where('student_id', '=', $issue->student_id)->where('cost_is_paid', '=', 0)->first(); $movements = Movement::where('issue_id', '=', $issue_id)->where('paid', '=', 0)->get(); $punishments = Punishment::where('issue_id', '=', $issue_id)->where('paid', '=', 0)->get(); $resigns = Resign::where('issue_id', '=', $issue_id)->where('fines', '>', 0.0)->where('is_earned', '=', 0)->get(); $employees = Employee::where('location_id', '=', Auth::user()->location_id)->get(); $menu = 'finance'; return View::make('earnings.create', compact('issue', 'receivable', 'registration', 'movements', 'punishments', 'resigns', 'employees', 'menu')); }
public function downloadTable($id, $year, $month) { $contents = "DATA ABSENSI BINA BAKTI\n\n"; $department = Department::find($id); $contents .= "Unit: ," . $department->name . "\n"; $months = MyDate::get_month_names(); $contents .= "Bulan: ," . $months[$month - 1] . "\n"; $contents .= "Tahun: ," . $year . "\n\n"; $contents .= "KODE,NAMA,NORMAL,,PULANG AWAL,,,TERLAMBAT,LUPA,TUGAS LUAR,,OTHER,TIDAK MASUK,,,JUMLAH HARI MASUK,,JUMLAH HARI TIDAK MASUK,NOMINAL UANG KONSUMSI\n"; $contents .= ",,WEEKDAY,WEEKEND,WEEKDAY < 12,WEEKDAY >= 12,WEEKEND,,,WEEKDAY,WEEKEND,,SAKIT,IZIN,ALPHA,WEEKDAY,WEEKEND,,WEEKDAY,WEEKEND,PULANG AWAL,TOTAL\n"; $employees = Employee::where('department_id', '=', $id)->orderBy('name')->get(); $total = 0; foreach ($employees as $employee) { $contents .= $employee->ssn . ","; $contents .= $employee->name . ","; $data = Session::pull($employee->id, 'default'); $total += $data['konsumsi_total']; $contents .= $data['normal_weekday'] . ","; $contents .= $data['normal_weekend'] . ","; $contents .= $data['pulang_awal_weekday_before_12'] . ","; $contents .= $data['pulang_awal_weekday'] . ","; $contents .= $data['pulang_awal_weekend'] . ","; $contents .= $data['terlambat'] . ","; $contents .= $data['lupa'] . ","; $contents .= $data['tugas_luar_weekday'] . ","; $contents .= $data['tugas_luar_weekend'] . ","; $contents .= $data['other'] . ","; $contents .= $data['sakit'] . ","; $contents .= $data['izin'] . ","; $contents .= $data['alpha'] . ","; $contents .= $data['masuk_weekday'] . ","; $contents .= $data['masuk_weekend'] . ","; $contents .= $data['tidak_masuk'] . ","; $contents .= $data['konsumsi_weekday'] . ","; $contents .= $data['konsumsi_weekend'] . ","; $contents .= $data['konsumsi_pulang_awal'] . ","; $contents .= $data['konsumsi_total'] . ","; $contents .= "\n"; } $contents .= ",,,,,,,,,,,,,,,,,,,,," . $total; // $file_name = "allowance.csv"; $file = public_path() . "/download/allowance.csv"; File::put($file, $contents); return Response::download($file, "allowance-" . strtolower($department->name) . "-" . $month . "-" . $year . ".csv", array('Content-Type' => 'text/csv', 'Content-Disposition' => 'attachment;')); }
public function assigned($update) { return Employee::where('employee_identity', $update)->first(); }
public function employeesReports() { if (Session::has('username') && (Session::get('user_type') == "Root" || Session::get('user_type') == "Admin" || Session::get("user_type") == "User")) { $view = View::make("Reports.employees_reports"); $view->nav = "system"; $view->tab = "employees"; $view->totalEmployees = Employee::all()->count(); $view->onBoard = Employee::where("status", "=", "On-Board")->count(); $view->ojt = Employee::where("status", "=", "OJT")->count(); $view->ojtGraduate = Employee::where("status", "=", "OJT Graduate")->count(); $view->academy = Employee::where("status", "=", "Academy")->count(); $view->contractual = Employee::where("status", "=", "Contractual")->count(); $view->nsnGuest = Employee::where("status", "=", "NSN Guest")->count(); $view->graduate = Employee::where("status", "=", "Graduate")->count(); $view->resigned = Employee::where("status", "=", "Resigned")->count(); $view->obsolete = Employee::where("status", "=", "Obsolete")->count(); return $view; } else { return Redirect::to("/"); } }
private function processPhoneNumbersUpdate($file) { if (Session::has('username') && (Session::get('user_type') == "Root" || Session::get('user_type') == "Admin")) { if (!in_array($file->getClientOriginalExtension(), array("xls", "xlsx", "csv"))) { Input::flash(); return Redirect::to('settings/employees/updatephonenumbers')->with('message', "Invalid file selected."); } else { $filename = "upload-" . str_random(9) . "." . $file->getClientOriginalExtension(); $file->move("uploads", $filename); $readFile = "uploads/" . $filename; $reader = Excel::selectSheetsByIndex(0)->load($readFile, function ($reader) { })->get(); $excelChecker = Excel::selectSheetsByIndex(0)->load($readFile, function ($reader) { })->get()->toArray(); $excelIsValid = false; foreach ($excelChecker as $ex) { if (isset($ex["employeenumber"])) { $excelIsValid = true; } } if (!$excelIsValid) { Input::flash(); File::delete($readFile); return Redirect::to('settings/employees/updatephonenumbers')->with('message', "Excel file has invalid attributes. Please download the form."); } $hasError = false; //Detects if there are any errors. $hasCorrectRows = false; $rowIndex = 1; //Indexes which row the reader is reading. $rowsWithErrors = array(); //This is used to contain in an array the row numbers of the rows with error. $error = array(); //Error details collector. foreach ($reader as $r) { $rowIndex += 1; $errorCount = 0; //Counts the number of errors for the currect row. $rowHasError = false; //Check if this row has error. I will use this before the reading of the row ends. // If $rowHasError is still false by end of the reading, then I will write it in the database. $validator = Validator::make(array("employee number" => trim($r->employeenumber)), array("employee number" => "required|exists:tbl_employees,employee_number")); if ($validator->fails()) { $hasError = true; $rowHasError = true; $rowsWithErrors[$rowIndex] = $rowIndex; if ($validator->messages()->get("employee number")) { foreach ($validator->messages()->get("employee number") as $e) { $errorCount += 1; $error[$rowIndex][$errorCount] = $errorCount . ". " . $e . "<br/>"; } } } if (!$rowHasError) { $hasCorrectRows = true; //Save Updates //Find the employee by employee number. $employee = Employee::where("employee_number", "=", trim($r->employeenumber))->first(); $employee->cellphone_number = trim($r->phonenumber) != null ? trim($r->phonenumber) : null; $employee->save(); } } File::delete($readFile); if ($hasCorrectRows) { //Log the changes made $desc = "(" . Session::get("user_type") . ") <b>" . Session::get("username") . "</b> has updated employees phone numbers. "; $newLog = new UserLog(); $newLog->description = $desc; $newLog->user_id = Session::get('user_id'); $newLog->save(); } return $this->phoneNumbersUpdateResult($hasError, $hasCorrectRows, $rowsWithErrors, $error); } } else { return Redirect::to("/"); } }
private function processImport($file) { if (Session::has('username') && (Session::get('user_type') == "Root" || Session::get('user_type') == "Admin")) { if (!in_array($file->getClientOriginalExtension(), array("xls", "xlsx", "csv"))) { Input::flash(); return Redirect::to('assets/software/import')->with('message', "Invalid file selected."); } else { $filename = "upload-" . str_random(9) . "." . $file->getClientOriginalExtension(); $file->move("uploads", $filename); $readFile = "uploads/" . $filename; $reader = Excel::selectSheetsByIndex(0)->load($readFile, function ($reader) { })->get(); /* * Before validating each rows of the file uploaded, the file itself is checked if it has the valid attributes (columns) * using the algorithm found below. * * 1. File is read. * 2. Boolean variable $excelIsValid to check if the file is valid. Set to false by default. * */ $excelChecker = Excel::selectSheetsByIndex(0)->load($readFile, function ($reader) { })->get()->toArray(); $excelIsValid = false; /* * 3. Loop through the excel file and check if at least once all the columns have been present. * 4. If it does, $excelIsValid is set to true. * 5. If $excelIsValid is still false by end of the loop, it is automatically assumed that the file is: * A.) Empty * B.) Does not have the right attributes. * C.) Has valid columns, but does not have any valid entry. * */ foreach ($excelChecker as $ex) { if (isset($ex["productkey"]) && isset($ex["softwaretype"]) && isset($ex["status"])) { $excelIsValid = true; } } /* 6. If file is invalid, redirect to import form and return an error. */ if (!$excelIsValid) { Input::flash(); File::delete($readFile); return Redirect::to('assets/software/import')->with('message', "Excel file has invalid attributes. Please download the form."); } /* * CHECKING EXCEL FILE FOR ERRORS WHILE READING THE ROWS * * 1. $hasError is a Boolean variable that is simply used to tell if any error has been found. * This variable is, by default, set to false. If any error has been detected, it is set to true, * regardless of how many errors has been detected. * * 2. $rowIndex indexes which row the reader is currently reading. Default value set to 1 because * the first row of excel files is automatically set as the attribute row. When the reader reads each row, * $rowIndex is incremented. For example, reader is currently reading row 2, $rowIndex will then be incremented, * setting its value to 2, thus the row number. * * 3. $rowsWithErrors is the array of the rows with errors. To explain further, let's say excel file has 10 readable (non-attrib) * rows. No errors were found from rows number 2-8, but errors were found in rows 9, 10, and 11. These 9, 10, and 11 * will then be in the $rowsWithError. * * 4. $error array is the variable that will be used to collect all errors found from the excel file. * This is a two-dimensional array. * * */ $hasError = false; //Detects if there are any errors. $hasCorrectRows = false; $rowIndex = 1; //Indexes which row the reader is reading. $rowsWithErrors = array(); //This is used to contain in an array the row numbers of the rows with error. $error = array(); //Error details collector. foreach ($reader as $r) { /* * 5. Here, we immediately increment the value of $rowIndex, since the variable will be used in the core logic of this method. * * 6. $errorCount variable is a variable used in every loop. Set to 0 when the loop begins, so it always comes back to 0 for every loop. * $errorCount is used to track the number of errors for the current row. This variable goes hand in hand with the * $rowsWithError array when publishing the rows with errors, and the error details for each row with error. * * This is how $rowsWithError and $rowCount will be used: * * for each $rowWithErrors: * Row $rowWithErrors Index: * Errors Found : * $rowCount 1. Foo bar * $rowCount 2. Jane Doe etc.. * * */ $rowIndex += 1; $errorCount = 0; //Counts the number of errors for the currect row. $rowHasError = false; //Check if this row has error. I will use this before the reading of the row ends. // If $rowHasError is still false by end of the reading, then I will write it in the database. $warranty_start = !empty(trim($r->warrantystart)) ? trim($r->warrantystart) : "1994-04-16"; $validator = Validator::make(array("software asset tag" => trim($r->assettag), "product key" => trim($r->productkey), "employee number" => trim($r->employeenumber), "laptop serial number" => trim($r->laptopsn), "software type" => trim($r->softwaretype), "warranty start date" => trim($r->warrantystart), "warranty end date" => trim($r->warrantyend), "status" => trim($r->status)), array("software asset tag" => "required|unique:tbl_software_assets,asset_tag|unique:tbl_assets,asset_tag", "product key" => "required", "employee number" => "exists:tbl_employees,employee_number", "laptop serial number" => "exists:tbl_assets,serial_number", "software type" => "required|exists:tbl_software_types,software_type", "warranty start date" => "required_with:warranty end date|date:Y-m-d", "warranty end date" => "date:Y-m-d|after:" . $warranty_start, "status" => "required|in:Available,PWU,Retired,Test Case,Lost"), array("after" => "The :attribute must be after the warranty start date.")); if ($validator->fails()) { /* 7. When error has been found, $rowsWithError is immediately updated. Also, $hasError and $rowHasError are set to true.*/ $hasError = true; $rowHasError = true; $rowsWithErrors[$rowIndex] = $rowIndex; /* 8. Then I will check which fields have errors. * * 9. If an error has been found in a certain field, * I will loop through the errors found on that field, increment the $errorCount (which, again, tracks * how many errors has been found on a certain row.), update the two-dimensional $error array. * Please note that the first array of $error contains the row number which the errors found belong to. * */ if ($validator->messages()->get("software asset tag")) { foreach ($validator->messages()->get("software asset tag") as $e) { $errorCount += 1; $error[$rowIndex][$errorCount] = $errorCount . ". " . $e . "<br/>"; } } if ($validator->messages()->get("product key")) { foreach ($validator->messages()->get("product key") as $e) { $errorCount += 1; $error[$rowIndex][$errorCount] = $errorCount . ". " . $e . "<br/>"; } } if ($validator->messages()->get("employee number")) { foreach ($validator->messages()->get("employee number") as $e) { $errorCount += 1; $error[$rowIndex][$errorCount] = $errorCount . ". " . $e . "<br/>"; } } if ($validator->messages()->get("laptop serial number")) { foreach ($validator->messages()->get("laptop serial number") as $e) { $errorCount += 1; $error[$rowIndex][$errorCount] = $errorCount . ". " . $e . "<br/>"; } } if ($validator->messages()->get("software type")) { foreach ($validator->messages()->get("software type") as $e) { $errorCount += 1; $error[$rowIndex][$errorCount] = $errorCount . ". " . $e . "<br/>"; } } if ($validator->messages()->get("warranty start date")) { foreach ($validator->messages()->get("warranty start date") as $e) { $errorCount += 1; $error[$rowIndex][$errorCount] = $errorCount . ". " . $e . "<br/>"; } } if ($validator->messages()->get("warranty end date")) { foreach ($validator->messages()->get("warranty end date") as $e) { $errorCount += 1; $error[$rowIndex][$errorCount] = $errorCount . ". " . $e . "<br/>"; } } if ($validator->messages()->get("status")) { foreach ($validator->messages()->get("status") as $e) { $errorCount += 1; $error[$rowIndex][$errorCount] = $errorCount . ". " . $e . "<br/>"; } } } if ($r->status != "Lost" && Employee::where("employee_number", "=", $r->employeenumber)->whereIn("status", array("OJT Graduate", "Graduate", "Resigned", "Obsolete"))->first()) { $hasError = true; //This will only matter if no errors has been found above. $rowHasError = true; //This will only matter if no errors has been found above. $rowsWithErrors[$rowIndex] = $rowIndex; //This will only matter if no errors has been found above. $errorCount += 1; $error[$rowIndex][$errorCount] = $errorCount . ". " . "Cannot assign an asset to employees no longer working in the company." . "<br/>"; } if (trim($r->laptopsn) != null && !Asset::where("serial_number", "=", $r->laptopsn)->whereHas("classification", function ($q) { $q->where("name", "=", "Laptops"); })->first()) { $hasError = true; //This will only matter if no errors has been found above. $rowHasError = true; //This will only matter if no errors has been found above. $rowsWithErrors[$rowIndex] = $rowIndex; //This will only matter if no errors has been found above. $errorCount += 1; $error[$rowIndex][$errorCount] = $errorCount . ". " . "Cannot assign software asset to non-laptop assets. Please check the serial number and try again." . "<br/>"; } if (!$rowHasError) { $hasCorrectRows = true; $software_type_id = SoftwareType::where("software_type", "=", $r->softwaretype)->get(array("id"))->first(); //Create the asset $software = new Software(); $software->asset_tag = trim($r->assettag) != null ? trim($r->assettag) : null; $software->product_key = trim($r->productkey); $software->employee_number = trim($r->employeenumber) != null ? trim($r->employeenumber) : null; $software->assigned_to_serial_number = trim($r->laptopsn) != null ? trim($r->laptopsn) : null; $software->location = trim($r->location) != null ? trim($r->location) : null; $software->software_type_id = $software_type_id->id; $software->warranty_start = trim($r->warrantystart); $software->warranty_end = trim($r->warrantyend); $software->status = trim($r->status); $software->notes = trim($r->notes) != null ? trim($r->notes) : null; $software->date_added = date("Y-m-d H:i:s"); $software->save(); //Log the new asset to asset logs if (!empty(trim($r->employeenumber))) { $employee = Employee::where("employee_number", "=", trim($r->employeenumber))->first(); $desc = "Software Asset <strong>" . $software->asset_tag . "</strong> added to the database and assigned to employee <strong>" . $employee->first_name . " " . $employee->last_name . "</strong> with asset status <strong>" . $software->status . "</strong>."; } else { $desc = "Software Asset <strong>" . $software->asset_tag . "</strong> added to the database with status <strong>" . $software->status . "</strong>."; } $softwareLog = new SoftwareLog(); $softwareLog->user_id = Session::get("user_id"); $softwareLog->software_id = $software->id; $softwareLog->employee_id = !empty($software->employee->id) ? $software->employee->id : null; $softwareLog->description = $desc; $softwareLog->transaction = "History"; $softwareLog->save(); //Parallel logging to system logs $desc = "(" . Session::get('user_type') . ") " . "<strong>" . Session::get('username') . "</strong> added software asset <strong>" . $software->asset_tag . "</strong>."; $newLog = new UserLog(); $newLog->description = $desc; $newLog->user_id = Session::get('user_id'); $newLog->type = "System"; $newLog->save(); } } File::delete($readFile); if ($hasCorrectRows) { //Log the changes made $desc = "(" . Session::get("user_type") . ") <b>" . Session::get("username") . "</b> has imported data to software assets database. "; $newLog = new UserLog(); $newLog->description = $desc; $newLog->user_id = Session::get('user_id'); $newLog->type = "System"; $newLog->save(); } return $this->importResult($hasError, $hasCorrectRows, $rowsWithErrors, $error); } } else { return Redirect::to('/'); } }
/** * Update the specified resource in storage. * * @param int $id * @return Response */ public function update($id) { $input = Input::all(); $rules = array('tool_name' => 'required', 'acc_name' => 'required', 'emp_id' => 'required', 'emp_name' => 'required', 'access' => 'required'); $messages = array('tool_name.required' => 'Tool Name is required !', 'emp_id.required' => 'Employee ID is required !', 'emp_name.required' => 'Employee Name is required !', 'access.required' => 'Please select an accesibility !'); $validation = Validator::make($input, $rules, $messages); if ($validation->passes()) { $toolname = Accounts::select('account_name')->where('id', '=', Input::get('acc_name'))->get(); foreach ($toolname as $key => $tool) { $accName = $tool->account_name; } $employees = Employee::where('emp_id', '=', $id)->select('tools.emp_id as id', 'tools.emp_name as emp_name', 'tools.acc_id as acc_id', 'tools.access as access', 'tools.tool_name as tool_name')->get(); $employees->emp_id = Input::get('emp_id'); $employees->emp_name = Input::get('emp_name'); $employees->acc_id = Input::get('acc_name'); $employees->tool_name = Input::get('tool_name'); $employees->access = Input::get('access'); //$employees->save(); DB::table('tools')->where('emp_id', $id)->update(array('emp_name' => $employees->emp_name, 'acc_id' => $employees->acc_id, 'tool_name' => $employees->tool_name, 'access' => $employees->access)); return Redirect::to('/employees'); } else { return Redirect::to('/employees/' . $id . '/edit')->withErrors($validation); } }
SUM(rest_day_legal_holiday_overtime_night_diff) as rest_day_legal_holiday_overtime_night_diff, SUM(rest_day_legal_holiday_night_diff) as rest_day_legal_holiday_night_diff, SUM(special_holiday) as special_holiday, SUM(special_holiday_overtime) as special_holiday_overtime, SUM(special_holiday_overtime_night_diff) as special_holiday_overtime_night_diff, SUM(special_holiday_night_diff) as special_holiday_night_diff, SUM(legal_holiday) as legal_holiday, SUM(legal_holiday_overtime) as legal_holiday_overtime, SUM(legal_holiday_overtime_night_diff) as legal_holiday_overtime_night_diff, SUM(legal_holiday_night_diff) as legal_holiday_night_diff'))->where('employee_id', $employeeId)->whereBetween('daydate', [$cutOffDateFrom, $cutOffDateTo])->first(); //dd($summary); $userGroups = DB::table('users_groups')->where('user_id', $userId)->first(); //$userGroups = DB::table('users_groups')->where('user_id', Auth::user()->id)->first(); if (!empty($userGroups)) { $groups = DB::table('groups')->where('id', (int) $userGroups->group_id)->first(); } $currentUser = Sentry::getUser(); //$employeeId = Session::get('userEmployeeId'); //$employeeInfo[0]->id $company = Company::find($employeeInfo[0]->company_id); $department = Department::find($employeeInfo[0]->department_id); $jobTitle = JobTitle::find($employeeInfo[0]->position_id); $manager = ''; $manager = Employee::where('id', '=', $employeeInfo[0]->manager_id)->first(); if (!empty($manager)) { $managerFullname = $manager->firstname . ', ' . $manager->lastname; } else { $managerFullname = ''; } $employees = DB::table('employees')->where('manager_id', $employeeInfo[0]->id)->orWhere('supervisor_id', $employeeInfo[0]->id)->get(); $employeeArr[0] = ''; foreach ($employees as $employee) { $employeeArr[$employee->id] = $employee->firstname . ', ' . $employee->lastname; } //$getSchedule = DB::table('employee_schedule')->where('employee_id', $employee->id)->where('schedule_date', trim($currentDate))->get(); //$getWorkShiftByDayOfTheWeek = DB::table('work_shift')->where('employee_id', $employee->id)->where('name_of_day', $dayOfTheWeek)->where('shift', $shift)->get(); ?> <div class="page-container" style="padding-bottom:20px;">
private function processImport($file) { if (Session::has('username') && (Session::get('user_type') == "Root" || Session::get('user_type') == "Admin")) { if (!in_array($file->getClientOriginalExtension(), array("xls", "xlsx", "csv"))) { Input::flash(); return Redirect::to('employees/import')->with('message', "Invalid file selected."); } else { $filename = "upload-" . str_random(9) . "." . $file->getClientOriginalExtension(); $file->move("uploads", $filename); $readFile = "uploads/" . $filename; $reader = Excel::selectSheetsByIndex(0)->load($readFile, function ($reader) { })->get(); /* * Before validating each rows of the file uploaded, the file itself is checked if it has the valid attributes (columns) * using the algorithm found below. * * 1. File is read. * 2. Boolean variable $excelIsValid to check if the file is valid. Set to false by default. * */ $excelChecker = Excel::selectSheetsByIndex(0)->load($readFile, function ($reader) { })->get()->toArray(); $excelIsValid = false; /* * 3. Loop through the excel file and check if at least once all the columns have been present. * 4. If it does, $excelIsValid is set to true. * 5. If $excelIsValid is still false by end of the loop, it is automatically assumed that the file is: * A.) Empty * B.) Does not have the right attributes. * C.) Has valid columns, but does not have any valid entry. * */ foreach ($excelChecker as $ex) { if (isset($ex["employeenumber"]) && isset($ex["lastname"]) && isset($ex["firstname"]) && isset($ex["startdate"]) && isset($ex["status"])) { $excelIsValid = true; } } /* 6. If file is invalid, redirect to import form and return an error. */ if (!$excelIsValid) { Input::flash(); File::delete($readFile); return Redirect::to('employees/import')->with('message', "Excel file has invalid attributes. Please download the form."); } /* * CHECKING EXCEL FILE FOR ERRORS WHILE READING THE ROWS * * 1. $hasError is a Boolean variable that is simply used to tell if any error has been found. * This variable is, by default, set to false. If any error has been detected, it is set to true, * regardless of how many errors has been detected. * * 2. $rowIndex indexes which row the reader is currently reading. Default value set to 1 because * the first row of excel files is automatically set as the attribute row. When the reader reads each row, * $rowIndex is incremented. For example, reader is currently reading row 2, $rowIndex will then be incremented, * setting its value to 2, thus the row number. * * 3. $rowsWithErrors is the array of the rows with errors. To explain further, let's say excel file has 10 readable (non-attrib) * rows. No errors were found from rows number 2-8, but errors were found in rows 9, 10, and 11. These 9, 10, and 11 * will then be in the $rowsWithError. * * 4. $error array is the variable that will be used to collect all errors found from the excel file. * This is a two-dimensional array. * * */ $hasError = false; //Detects if there are any errors. $hasCorrectRows = false; $rowIndex = 1; //Indexes which row the reader is reading. $rowsWithErrors = array(); //This is used to contain in an array the row numbers of the rows with error. $error = array(); //Error details collector. foreach ($reader as $r) { /* * 5. Here, we immediately increment the value of $rowIndex, since the variable will be used in the core logic of this method. * * 6. $errorCount variable is a variable used in every loop. Set to 0 when the loop begins, so it always comes back to 0 for every loop. * $errorCount is used to track the number of errors for the current row. This variable goes hand in hand with the * $rowsWithError array when publishing the rows with errors, and the error details for each row with error. * * This is how $rowsWithError and $rowCount will be used: * * for each $rowWithErrors: * Row $rowWithErrors Index: * Errors Found : * $rowCount 1. Foo bar * $rowCount 2. Jane Doe etc.. * * */ $rowIndex += 1; $errorCount = 0; //Counts the number of errors for the currect row. $rowHasError = false; //Check if this row has error. I will use this before the reading of the row ends. // If $rowHasError is still false by end of the reading, then I will write it in the database. /* * */ $start_date = !empty(trim($r->startdate)) ? trim($r->startdate) : "1994-04-16"; $validator = Validator::make(array("employee number" => trim($r->employeenumber), "last name" => trim($r->lastname), "first name" => trim($r->firstname), "username" => trim($r->username), "start date" => trim($r->startdate), "end date" => trim($r->enddate), "email" => trim($r->email), "status" => trim($r->status)), array("employee number" => "required|numeric|unique:tbl_employees,employee_number", "last name" => "required", "first name" => "required", "username" => "unique:tbl_employees,username", "start date" => "required|date:Y-m-d", "end date" => "date:Y-m-d|after:" . $start_date, "email" => "unique:tbl_employees,email", "status" => "required"), array("after" => "The :attribute must be after the employee start date.")); if ($validator->fails()) { /* 7. When error has been found, $rowsWithError is immediately updated. Also, $hasError and $rowHasError are set to true.*/ $hasError = true; $rowHasError = true; $rowsWithErrors[$rowIndex] = $rowIndex; /* 8. Then I will check which fields has error. * * 9. If an error has been found in a certain field, * I will loop through the errors found on that field, increment the $errorCount (which, again, tracks * how many errors has been found on a certain row.), update the two-dimensional $error array. * Please note that the first array of $error contains the row number which the errors found belong to. * */ if ($validator->messages()->get("employee number")) { foreach ($validator->messages()->get("employee number") as $e) { $errorCount += 1; $error[$rowIndex][$errorCount] = $errorCount . ". " . $e . "<br/>"; } } if ($validator->messages()->get("last name")) { foreach ($validator->messages()->get("last name") as $e) { $errorCount += 1; $error[$rowIndex][$errorCount] = $errorCount . ". " . $e . "<br/>"; } } if ($validator->messages()->get("first name")) { foreach ($validator->messages()->get("first name") as $e) { $errorCount += 1; $error[$rowIndex][$errorCount] = $errorCount . ". " . $e . "<br/>"; } } if ($validator->messages()->get("username")) { foreach ($validator->messages()->get("username") as $e) { $errorCount += 1; $error[$rowIndex][$errorCount] = $errorCount . ". " . $e . "<br/>"; } } if ($validator->messages()->get("start date")) { foreach ($validator->messages()->get("start date") as $e) { $errorCount += 1; $error[$rowIndex][$errorCount] = $errorCount . ". " . $e . "<br/>"; } } if ($validator->messages()->get("end date")) { foreach ($validator->messages()->get("end date") as $e) { $errorCount += 1; $error[$rowIndex][$errorCount] = $errorCount . ". " . $e . "<br/>"; } } if ($validator->messages()->get("email")) { foreach ($validator->messages()->get("email") as $e) { $errorCount += 1; $error[$rowIndex][$errorCount] = $errorCount . ". " . $e . "<br/>"; } } if ($validator->messages()->get("status")) { foreach ($validator->messages()->get("status") as $e) { $errorCount += 1; $error[$rowIndex][$errorCount] = $errorCount . ". " . $e . "<br/>"; } } } if (!preg_match('/^[\\pL.-\\s]+$/u', $r->firstname) || !preg_match('/^[\\pL.-\\s]+$/u', $r->lastname)) { $hasError = true; //This will only matter if no errors has been found above. $rowHasError = true; //This will only matter if no errors has been found above. $rowsWithErrors[$rowIndex] = $rowIndex; //This will only matter if no errors has been found above. $errorCount += 1; $error[$rowIndex][$errorCount] = $errorCount . ". " . "First name/last name fields must only contain alphabetic characters and whitespaces." . "<br/>"; } if (!is_numeric($r->manager)) { $hasError = true; //This will only matter if no errors has been found above. $rowHasError = true; //This will only matter if no errors has been found above. $rowsWithErrors[$rowIndex] = $rowIndex; //This will only matter if no errors has been found above. $errorCount += 1; $error[$rowIndex][$errorCount] = $errorCount . ". " . "Manager ID should be numeric." . "<br/>"; } if (is_numeric($r->manager) && !Manager::find($r->manager)) { $hasError = true; //This will only matter if no errors has been found above. $rowHasError = true; //This will only matter if no errors has been found above. $rowsWithErrors[$rowIndex] = $rowIndex; //This will only matter if no errors has been found above. $errorCount += 1; $error[$rowIndex][$errorCount] = $errorCount . ". " . "Invalid manager ID." . "<br/>"; } if (empty(trim($r->nsnid)) && !in_array(strtolower($r->status), array("academy", "ojt", "contractual", "graduate", "obsolete"))) { $hasError = true; //This will only matter if no errors has been found above. $rowHasError = true; //This will only matter if no errors has been found above. $rowsWithErrors[$rowIndex] = $rowIndex; //This will only matter if no errors has been found above. $errorCount += 1; $error[$rowIndex][$errorCount] = $errorCount . ". " . "The NSN ID is required." . "<br/>"; } if (!empty($r->nsnid) && !is_numeric(trim($r->nsnid)) && !in_array($r->status, array("academy", "ojt", "contractual", "graduate", "obsolete"))) { $hasError = true; //This will only matter if no errors has been found above. $rowHasError = true; //This will only matter if no errors has been found above. $rowsWithErrors[$rowIndex] = $rowIndex; //This will only matter if no errors has been found above. $errorCount += 1; $error[$rowIndex][$errorCount] = $errorCount . ". " . "The NSN ID should be numeric." . "<br/>"; } if (!empty($r->nsnid) && Employee::where("nsn_id", "=", $r->nsnid)->first()) { $hasError = true; //This will only matter if no errors has been found above. $rowHasError = true; //This will only matter if no errors has been found above. $rowsWithErrors[$rowIndex] = $rowIndex; //This will only matter if no errors has been found above. $errorCount += 1; $error[$rowIndex][$errorCount] = $errorCount . ". " . "NSN ID already exists." . "<br/>"; } if (!empty($r->email) && !filter_var(trim($r->email), FILTER_VALIDATE_EMAIL)) { $hasError = true; //This will only matter if no errors has been found above. $rowHasError = true; //This will only matter if no errors has been found above. $rowsWithErrors[$rowIndex] = $rowIndex; //This will only matter if no errors has been found above. $errorCount += 1; $error[$rowIndex][$errorCount] = $errorCount . ". " . "Invalid e-mail address." . "<br/>"; } if (is_numeric($r->businessline) && !BusinessLine::find($r->businessline)) { $hasError = true; //This will only matter if no errors has been found above. $rowHasError = true; //This will only matter if no errors has been found above. $rowsWithErrors[$rowIndex] = $rowIndex; //This will only matter if no errors has been found above. $errorCount += 1; $error[$rowIndex][$errorCount] = $errorCount . ". " . "Invalid Business Line ID." . "<br/>"; } if (is_numeric($r->unit) && !Unit::find($r->unit)) { $hasError = true; //This will only matter if no errors has been found above. $rowHasError = true; //This will only matter if no errors has been found above. $rowsWithErrors[$rowIndex] = $rowIndex; //This will only matter if no errors has been found above. $errorCount += 1; $error[$rowIndex][$errorCount] = $errorCount . ". " . "Invalid Unit ID." . "<br/>"; } if (is_numeric($r->unit) && is_numeric($r->businessline) && (Unit::find($r->unit) && !Unit::where("id", "=", $r->unit)->where("businessline_id", "=", $r->businessline)->first())) { $hasError = true; //This will only matter if no errors has been found above. $rowHasError = true; //This will only matter if no errors has been found above. $rowsWithErrors[$rowIndex] = $rowIndex; //This will only matter if no errors has been found above. $errorCount += 1; $error[$rowIndex][$errorCount] = $errorCount . ". " . "Selected Unit ID does not belong to the selected Business Line ID." . "<br/>"; } if (!in_array(strtolower($r->status), array("ojt", "contractual", "nsn guest", "academy", "graduate", "on-board", "resigned", "obsolete"))) { $hasError = true; //This will only matter if no errors has been found above. $rowHasError = true; //This will only matter if no errors has been found above. $rowsWithErrors[$rowIndex] = $rowIndex; //This will only matter if no errors has been found above. $errorCount += 1; $error[$rowIndex][$errorCount] = $errorCount . ". " . "Invalid employee status." . "<br/>"; } if (!$rowHasError) { $hasCorrectRows = true; $desc = "(" . Session::get('user_type') . ") " . "<strong>" . Session::get('username') . "</strong> has added employee <strong>" . trim($r->firstname) . " " . trim($r->lastname) . "</strong>, employee number <strong>" . trim($r->employeenumber) . "</strong>, with status <strong>" . trim($r->status) . "</strong>."; $employee = new Employee(); $employee->employee_number = $r->employeenumber; $employee->last_name = trim($r->lastname); $employee->first_name = trim($r->firstname); $employee->username = trim($r->username) != null ? trim($r->username) : null; $employee->nickname = trim($r->nickname) != null ? trim($r->nickname) : null; $employee->manager_id = $r->manager != null ? $r->manager : null; $employee->start_date = $r->startdate; $employee->end_date = $r->enddate != null ? $r->enddate : null; $employee->nsn_id = $r->nsnid != null ? $r->nsnid : null; $employee->email = trim($r->email) != null ? trim($r->email) : null; $employee->business_line_id = $r->businessline != null ? $r->businessline : null; $employee->unit_id = $r->unit != null ? $r->unit : null; $employee->subunit = trim($r->subunit) != null ? trim($r->subunit) : null; $employee->cellphone_number = trim($r->cellphonenumber) != null ? trim($r->cellphonenumber) : null; $employee->status = trim($r->status); $employee->save(); //Log the changes made $newLog = new UserLog(); $newLog->description = $desc; $newLog->user_id = Session::get('user_id'); $newLog->type = "Employees"; $newLog->save(); } } File::delete($readFile); if ($hasCorrectRows) { //Log the changes made $desc = "(" . Session::get("user_type") . ") <b>" . Session::get("username") . "</b> has imported data to the employees database. "; $newLog = new UserLog(); $newLog->description = $desc; $newLog->user_id = Session::get('user_id'); $newLog->type = "Employees"; $newLog->save(); } return $this->importResult($hasError, $hasCorrectRows, $rowsWithErrors, $error); } } else { return Redirect::to('/'); } }
public static function getEmployee($key) { $data = Employee::where('eid', '=', $key)->orwhere('ename', 'like', '%' . $key . '%')->orwhere('eemail', 'like', '%' . $key . '%')->get(); return $data; }
public function getPaginateEmployeesAttribute() { return Employee::where('category_id', $this->id)->paginate(); }
public function getCreatedByEmployee() { return Employee::where('employee_identity', '=', $this->created_by_employee_id)->get()->first(); }
public function assgined_to() { $name = Employee::where('employee_identity', $this->updated_by)->first(); return $name; }
//$validator = Validator::make($data, $rules); } /* else { $validator = Validator::make($data, $rules); }*/ //return dd($rules); //die(); $validator = Validator::make($data, $rules); if ($validator->fails()) { $messages = $validator->messages(); return Redirect::to('/admin/user/' . $employeeEditId . '/edit')->withErrors($validator); } else { $employee = new Employee(); $employeeUpdate = Employee::where('id', $employeeEditId)->first(); $employeeUpdate->employee_number = trim(ucwords($data["employee_number"])); $employeeUpdate->firstname = trim(ucwords($data["firstname"])); $employeeUpdate->lastname = trim(ucwords($data["lastname"])); $employeeUpdate->middle_name = trim(ucwords($data["middlename"])); $employeeUpdate->nick_name = trim(ucwords($data["nick_name"])); //$employeeUpdate->employee_type = $employeeType; //$employeeUpdate->manager_id = $managerId; //$employeeUpdate->supervisor_id = $supervisorId; if ($isEmployeeType === 'is_manager') { //Manager:1 $employeeUpdate->employee_type = 1; $employeeUpdate->manager_id = 0; $employeeUpdate->supervisor_id = 0; } elseif ($isEmployeeType === 'is_supervisor') { //Supervisor:2
public function edit($id) { $registration = Registration::find($id); $locations = Location::all(); $employees = Employee::where('location_id', '=', 18)->get(); $classifications = Classification::where('category', '=', 'Registration')->get(); $menu = 'registration'; return View::make('registrations.edit', compact('registration', 'menu', 'locations', 'employees', 'classifications')); }
/** * Show the form for editing the specified workingday. * * @param int $id * @return Response */ public function edit($id) { $workingdays = Workingday::where('employee_id', $id); $doctor = Employee::where('id', $id); return View::make('workingdays.edit', compact('workingdays', 'doctor')); }
//$userId = Session::get('userId'); */ $employee = new Employee(); $employeeInfo = $employee->getEmployeeInfoById($employeeId); $user = DB::table('users')->where('employee_id', $employeeId)->first(); //return dd($user); $userGroup = DB::table('users_groups')->where('user_id', $user->id)->first(); //return dd($userGroup); $group = DB::table('groups')->where('id', (int) $userGroup->group_id)->first(); return View::make('admin.useredit', ['employeeInfo' => $employeeInfo, 'user' => $user, 'group' => $group]); })); Route::post('/admin/user/edit', array('as' => 'adminUserDelete', 'uses' => function () { $data = Input::all(); //return dd($data); $employee = new Employee(); $employeeUpdate = Employee::where('id', (int) $data["employee_id"])->first(); $employeeUpdate->employee_number = $data["employee_number"]; $employeeUpdate->firstname = $data["firstname"]; $employeeUpdate->lastname = $data["lastname"]; $employeeUpdate->middle_name = $data["middlename"]; $employeeUpdate->nick_name = $data["nick_name"]; if ($employeeUpdate->save()) { //$employeeId = Session::get('userEmployeeId'); //$userId = Session::get('userId'); //$userEmail = Session::get('email'); $employeeId = $employeeUpdate->id; /*$userUpdate = User::where('employee_id', $employeeId)->first(); $userUpdate->employee_id = $employeeId; $userUpdate->employee_number = $data["employee_number"]; $userUpdate->first_name = $data["firstname"]; $userUpdate->last_name = $data["lastname"];