public function oldFolio_detailed($id) { try { $folio_num = folio_services::where('folio_num', $id)->orderBy('date')->get(); //obtain all services purchased by the current folio with purchased dates. $balance = folio::where('folio_num', $id)->first(); //to obtain the progressive balance of the current folio. $res_details = reservation::where('res_id', $balance->res_id)->first(); //to obtain reservation details of current folio. $services = DB::table('services')->select('service_id')->get(); $reason_code = DB::table('reason_codes')->select('reason_code')->get(); $updates = folio_update::where('folio_num', $id)->get(); } catch (ModelNotFoundException $e) { dd('no data'); } return view('Cashiering/oldFolio_detailed', compact('folio_num', 'balance', 'res_details', 'services', 'id', 'reason_code', 'updates')); }
function checkin() { try { $input = Request::all(); $res_id = $input['res_id']; DB::table('reservation')->where('res_id', '=', $res_id)->update(['status' => 'Checked_In']); //changing guest status in the folio DB::table('folio')->where('res_id', '=', $res_id)->update(['guest_status' => 'Checked_In']); //adding Room Charges $no_of_nights = DB::table('reservation')->where('res_id', '=', $res_id)->value('nights'); $variable = DB::table('room_reservation_rate')->where('res_id', '=', $res_id)->select('room_id')->get(); foreach ($variable as $var) { $type = DB::table('room')->where('room_id', '=', $var->room_id)->value('type_id'); $rate = DB::table('reservation_room_type_count')->where('type_id', '=', $type)->where('res_id', '=', $res_id)->value('rate_code'); $rate_value = DB::table('rate')->where('rate_code', '=', $rate)->value('rate'); $total = $rate_value * $no_of_nights; $folio_num = DB::table('folio')->where('res_id', '=', $res_id)->where('room_id', '=', $var->room_id)->value('folio_num'); //start try { folio_services::create(['service_id' => "RMCHRG", 'folio_num' => $folio_num, 'date' => Carbon::now(), 'price' => $total, 'service_count' => "1"]); //updating the folio table $credit_balance = DB::table('folio')->select('credit_total')->where('folio_num', '=', $folio_num)->first(); $total_balance = DB::table('folio')->select('prog_balance')->where('folio_num', '=', $folio_num)->first(); $credit_balance->credit_total = $credit_balance->credit_total + $total; $total_balance->prog_balance = $total_balance->prog_balance + $total; DB::table('folio')->where('folio_num', $folio_num)->update(['credit_total' => $credit_balance->credit_total, 'prog_balance' => $total_balance->prog_balance, 'Rate_code' => $rate]); } catch (QueryException $e) { /*$folios = folio::all(); $services = DB::table('services')->select('service_id')->get(); $exception_msg = 1; return view("Cashiering/FolioManagement", compact('folios', 'services', 'exception_msg'));*/ return redirect('/FO_mainpage')->with(['exception' => 'You have errors in your last request.Try again!']); //redirect the user to the corresponding folio to view the new record. /*return redirect('/payments/view/'.$input['folio_num']);*/ //end } } return redirect('/checkin')->with(['succ_status' => 'Successfully Checked-In']); } catch (Exception $e) { return redirect('/FO_mainpage')->with(['exception' => 'You have errors in your last request.Try again!']); } }