Example #1
0
 public function postUpdateOtherCost($id)
 {
     $ruless = array('tt_charge' => 'required', 'dollar_rate_per_tt' => 'required', 'dollar_to_bd_rate' => 'required');
     $validate = Validator::make(Input::all(), $ruless);
     if ($validate->fails()) {
         return Redirect::to('imports/editCost', $id)->withErrors($validate);
     } else {
         $counter = 0;
         $tt_charges = TTCharge::where('import_id', '=', $id)->get();
         foreach ($tt_charges as $row) {
             $row->delete();
         }
         $total = 0;
         foreach (Input::get("tt_charge") as $tt) {
             $tt_charge = new TTCharge();
             $tt_charge->tt_amount = $tt;
             $tt_charge->dollar_rate = Input::get("dollar_rate_per_tt")[$counter++];
             echo $total_tt = $tt_charge->tt_amount * $tt_charge->dollar_rate . '_';
             echo $total_tt2 = $tt_charge->tt_amount * Input::get("dollar_to_bd_rate") . '_';
             echo $subTotal = $total_tt - $total_tt2;
             $total += $subTotal;
             $tt_charge->import_id = $id;
             $tt_charge->save();
         }
         $otherCost = OtherCost::find($id);
         $otherCost->dollar_to_bd_rate = Input::get('dollar_to_bd_rate');
         $otherCost->tt_charge = $total;
         $otherCost->import_id = $id;
         $otherCost->save();
         Session::flash('message', 'Others Cost has been Successfully Updated.');
         return Redirect::to('imports/index');
     }
 }
 public function postUpdateOtherCost($id)
 {
     $ruless = array('tt_charge' => 'required', 'dollar_to_bd_rate' => 'required');
     $validate = Validator::make(Input::all(), $ruless);
     if ($validate->fails()) {
         return Redirect::to('imports/editCost', $id)->withErrors($validate);
     } else {
         $otherCost = OtherCost::find($id);
         $this->setOtherCostData($otherCost);
         $otherCost->save();
         Session::flash('message', 'Others Cost has been Successfully Updated.');
         return Redirect::to('imports/index');
     }
 }