Esempio n. 1
0
 public function store()
 {
     $movement_costs = Input::get('movement_costs');
     $movement_costs = str_replace(",", ".", $movement_costs);
     $movement_costs = str_replace(".", "", $movement_costs);
     $movement_costs = substr($movement_costs, 0, -2);
     $upgrade_costs = Input::get('upgrade_costs');
     $upgrade_costs = str_replace(",", ".", $upgrade_costs);
     $upgrade_costs = str_replace(".", "", $upgrade_costs);
     $upgrade_costs = substr($upgrade_costs, 0, -2);
     $movement = new Movement();
     $movement->project_id = Auth::user()->curr_project_id;
     $movement->location_id = Auth::user()->location_id;
     $movement->issue_id = Input::get('issue_id');
     $movement->base_id = Input::get('base_id');
     $movement->destination_id = Input::get('destination_id');
     $movement->employee_id = Input::get('employee_id');
     $movement->movement_date = Input::get('date');
     $movement->movement_costs = $movement_costs;
     $movement->upgrade_costs = $upgrade_costs;
     $movement->comments = Input::get('comments');
     $movement->save();
     $placement = Placement::where('issue_id', '=', Input::get('issue_id'))->where('course_id', '=', Input::get('base_id'))->first();
     if ((double) $upgrade_costs > 0) {
         $receivable = Receivable::where('registration_id', '=', $placement->registration_id)->first();
         $receivable->total = $receivable->total + $upgrade_costs;
         $receivable->receivable = $receivable->receivable + $upgrade_costs;
         $receivable->balance = $receivable->balance + $upgrade_costs;
         $receivable->save();
     }
     $placement->course_id = Input::get('destination_id');
     $placement->save();
     // Store to timelines
     return Response::json(array('id' => $movement->id));
 }