Exemplo n.º 1
0
 public function checkEarnings($id)
 {
     $startDate = $start = Input::get('startDate');
     $endDate = $end = Input::get('endDate');
     $start = date('Y-m-d', strtotime($start));
     $end = date('Y-m-d', strtotime($end));
     // Get the owed sum for the given range.
     $salaryForRange = Employee::getSalaryRange($id, $start, $end);
     $rangeSum = 0;
     $rangeValetedVehicles = 0;
     foreach ($salaryForRange as $item) {
         $employeesCut = Vehicle::getEmployeesCut($item->vehicle_fk);
         $rangeSum = $rangeSum + $employeesCut * $item->quantity;
         // Calculate the number of processed vehicles.
         $rangeValetedVehicles += $item->quantity;
     }
     $employeeData = Employee::find($id);
     $processedVehicles = InvoiceElement::where('employee_fk', '=', $employeeData->id)->count();
     $totalSalary = Employee::getSalary($id);
     // Get the rest of the information.
     $totalSum = 0;
     foreach ($totalSalary as $item) {
         $employeesCut = Vehicle::getEmployeesCut($item->vehicle_fk);
         $totalSum = $totalSum + $employeesCut * $item->quantity;
     }
     return View::make('employee.profile')->with(['employeeData' => $employeeData, 'processedVehicles' => $processedVehicles, 'totalSum' => $totalSum, 'rangeSum' => $rangeSum, 'startDate' => $startDate, 'endDate' => $endDate, 'rangeValetedVehicles' => $rangeValetedVehicles]);
 }
Exemplo n.º 2
0
 public function destroy($id)
 {
     $targetInvoice = Invoice::find($id);
     if ($targetInvoice) {
         $targetInvoice->delete();
         InvoiceElement::where('invoice_fk', '=', $id)->delete();
         return $this->index();
     } else {
         return $this->index();
     }
 }