public function show($id)
 {
     $employee = Employee::findOrFail($id);
     $registrations = Registration::where('project_id', '=', Auth::user()->curr_project_id)->where('location_id', '=', Auth::user()->location_id)->where('employee_id', '=', $id)->orderBy('registration_date', 'desc')->get();
     $earnings = Earning::where('project_id', '=', Auth::user()->curr_project_id)->where('location_id', '=', Auth::user()->location_id)->where('employee_id', '=', $id)->get();
     $retrievals = Retrieval::where('project_id', '=', Auth::user()->curr_project_id)->where('location_id', '=', Auth::user()->location_id)->where('employee_id', '=', $id)->get();
     $timelines = Timeline::where('project_id', '=', Auth::user()->curr_project_id)->where('location_id', '=', Auth::user()->location_id)->where('informable_type', '=', 'Employee')->where('informable_id', '=', $id)->get();
     $menu = 'employee';
     return View::make('employees.show', compact('employee', 'registrations', 'earnings', 'retrievals', 'timelines', 'menu'));
 }
 private function generateEarningCode()
 {
     $earning = Earning::where('project_id', '=', Auth::user()->curr_project_id)->where('location_id', '=', Auth::user()->location_id)->orderBy('id', 'desc')->first();
     if ($earning) {
         $last_code = (int) substr($earning->code, 4);
         $earning_counter = $last_code + 1;
     } else {
         $earning_counter = 1;
     }
     $code = Auth::user()->curr_project->code . Auth::user()->location->code . $earning_counter;
     return $code;
 }
Example #3
0
 public static function RedeemLeaveDays($employee, $leavetype)
 {
     $payrate = $employee->basic_pay / 30;
     $balancedays = Leaveapplication::getBalanceDays($employee, $leavetype);
     $amount = $balancedays * $payrate;
     Earning::insert($employee->id, 'Leave earning', 'redeemed leave days', $amount);
 }
Example #4
0
 public function destroy($code)
 {
     $earnings = Earning::where('code', '=', $code)->get();
     foreach ($earnings as $earning) {
         switch ($earning->earnable_type) {
             case 'Receivable':
                 $receivable = Receivable::find($earning->earnable_id);
                 $receivable->balance += $receivable->balance + $earning->payment;
                 $receivable->save();
                 $earning->delete();
                 break;
             case 'Installment':
                 $installment = Installment::find($earning->earnable_id);
                 $installment->balance += $installment->balance + $earning->payment;
                 $installment->paid = 0;
                 $installment->save();
                 $earning->delete();
                 break;
             case 'Registration':
                 $registration = Registration::find($earning->earnable_id);
                 $registration->cost_is_paid = 0;
                 $registration->save();
                 $earning->delete();
                 break;
             case 'Movement':
                 $movement = Movement::find($earning->earnable_id);
                 $movement->paid = 0;
                 $movement->save();
                 $earning->delete();
                 break;
             case 'Punishment':
                 $punishment = Punishment::find($earning->earnable_id);
                 $punishment->paid = 0;
                 $punishment->save();
                 $earning->delete();
                 break;
             case 'Resign':
                 $resign = Resign::find($earning->earnable_id);
                 $resign->is_earned = 0;
                 $resign->save();
                 $earning->delete();
                 break;
             default:
                 $earning->delete();
                 break;
         }
     }
 }
Example #5
0
 public function destroy($id)
 {
     $resign = Resign::find($id);
     $placements = Placement::where('resign_id', '=', $id)->get();
     foreach ($placements as $placement) {
         $placement->resign_id = 0;
         $placement->active = 1;
         $placement->save();
     }
     Returnment::where('resign_id', '=', $id)->delete();
     Earning::where('earnable_type', '=', 'Resign')->where('earnable_id', '=', $id)->delete();
     Resign::destroy($id);
     Session::flash('message', 'Sukses membatalkan penon-aktifan siswa');
 }
Example #6
0
 public function earningsFilter($month, $year)
 {
     $curr_month = $month;
     $curr_year = $year;
     $earnings = Earning::where('project_id', '=', Auth::user()->curr_project_id)->where('location_id', '=', Auth::user()->location_id)->where(DB::raw('year(earning_date)'), '=', $curr_year)->where(DB::raw('month(earning_date)'), '=', $curr_month)->get();
     $menu = 'report';
     return View::make('reports.earnings', compact('earnings', 'curr_year', 'curr_month', 'menu'));
 }