public function load()
 {
     if (Request::ajax()) {
         $data = Request::all();
         $roomprice = Roommoney::find($data['data'])->toArray();
         if ($roomprice == null) {
             $data_out = 1;
             print_r($data_out);
             die;
         } else {
             $room_237 = Roomtime::mthod('KHUNGGIO7AM_23PM')->roomtype($data['data'])->get()->toArray();
             $room_pt = Roomtime::mthod('PHUTROI')->roomtype($data['data'])->get()->toArray();
             $roomprice['KHUNGGIO7AM_23PM'] = $room_237;
             $roomprice['PHUTROI'] = $room_pt;
             $data_out = json_encode($roomprice);
             print_r($data_out);
             die;
         }
     }
 }
 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store(Request $request)
 {
     $money_sg = 0;
     $money_tw = 0;
     $info_booking = $request->all();
     $arr_datein[] = array();
     $str = $info_booking['date_in'];
     $arr_datein = explode('/', $str);
     $day_in = $arr_datein[0];
     $m_in = $arr_datein[1];
     $y_in = $arr_datein[2];
     $arr_timein = explode(':', $info_booking['time_in']);
     $h_in = $arr_timein[0];
     $m_in = $arr_timein[1];
     $arr_timeout = explode(':', $info_booking['time_out']);
     $h_out = $arr_timeout[0];
     $m_out = $arr_timeout[1];
     $arr_dateout[] = array();
     $str2 = $info_booking['date_out'];
     $arr_dateout = explode('/', $str2);
     $day_out = $arr_dateout[0];
     $m_out = $arr_dateout[1];
     $y_out = $arr_dateout[2];
     $arrival_time = $y_in . '-' . $m_in . '-' . $day_in . ' ' . $info_booking['time_in'];
     $depart_time = $y_out . '-' . $m_out . '-' . $day_out . ' ' . $info_booking['time_out'];
     $in = new DateTime($arrival_time);
     $out = new DateTime($depart_time);
     $diff = $in->diff($out);
     $days = $diff->d;
     $hours = $diff->h;
     $minutes = $diff->i;
     $total_hours = $days * 24 + $hours;
     if ($info_booking['single'] > 0) {
         if ($info_booking['airport'] == 1) {
             $roomprice_sg = Roommoney::find(10)->toArray();
             $room_237_sg = Roomtime::mthod('KHUNGGIO7AM_23PM')->roomtype(10)->get()->toArray();
             $room_pt_sg = Roomtime::mthod('PHUTROI')->roomtype(10)->get()->toArray();
         } else {
             $roomprice_sg = Roommoney::find(12)->toArray();
             $room_237_sg = Roomtime::mthod('KHUNGGIO7AM_23PM')->roomtype(12)->get()->toArray();
             $room_pt_sg = Roomtime::mthod('PHUTROI')->roomtype(12)->get()->toArray();
         }
         if ($roomprice_sg['khunggiobatdau'] <= $h_in && $h_in < $roomprice_sg['khunggioketthuc']) {
             $kt_in = 1;
         } else {
             $kt_in = 2;
         }
         if ($roomprice_sg['khunggiobatdau'] <= $h_out && $h_out < $roomprice_sg['khunggioketthuc']) {
             $kt_out = 1;
         } else {
             $kt_out = 2;
         }
         $test_h = 60 - $m_in;
         if ($minutes < $roomprice_sg['moc1']) {
             $total_hours += $roomprice_sg['lamtron1'] / 60;
         } elseif ($roomprice_sg['moc1'] <= $minutes && $minutes <= $roomprice_sg['moc2']) {
             $total_hours += $roomprice_sg['lamtron2'] / 60;
         } else {
             $total_hours += $roomprice_sg['lamtron3'] / 60;
         }
         if ($roomprice_sg['tinhtheongaydem'] == 0) {
             if ($days < 1) {
                 $money_sg = $this->price_day($total_hours, $roomprice_sg, $room_237_sg);
             } else {
                 $full_price = $days * $roomprice_sg['gianguyenngay'];
                 $last_mn = $this->price_day($hours, $roomprice_sg, $room_237_sg);
                 $money_sg = $full_price + $last_mn;
             }
         } else {
             if ($days < 1) {
                 if ($kt_in == $kt_out) {
                     if ($kt_in == 1) {
                         if ($h_out > $h_in) {
                             $money_sg = $this->price_day($total_hours, $roomprice_sg, $room_237_sg);
                         } elseif ($h_out == $h_in) {
                             if ($m_in < $m_out) {
                                 $money_sg = $this->price_day($total_hours, $roomprice_sg, $room_237_sg);
                             } else {
                                 $money_sg = $roomprice_sg['gianguyenngay'];
                             }
                         } else {
                             if ($test_h > $roomprice_sg['moc2']) {
                                 $hours_day = $roomprice_sg['khunggioketthuc'] - $h_in - 1 + $roomprice_sg['lamtron3'] / 60;
                             }
                             if ($test_h < $roomprice_sg['moc2'] && $test_h >= $roomprice_sg['moc1']) {
                                 $hours_day = $roomprice_sg['khunggioketthuc'] - $h_in - 1 + $roomprice_sg['lamtron2'] / 60;
                             }
                             if ($test_h < $roomprice_sg['moc1']) {
                                 $hours_day = $roomprice_sg['khunggioketthuc'] - $h_in - 1 + $roomprice_sg['lamtron1'] / 60;
                             }
                             $money_sg = $this->price_day($hours_day, $roomprice_sg, $room_237_sg);
                             $money_sg += $roomprice_sg['giaquadem'];
                             if ($m_out < $roomprice_sg['moc1']) {
                                 $hours_day_2 = $h_out - $roomprice_sg['khunggiobatdau'] + $roomprice_sg['lamtron1'] / 60;
                             }
                             if ($m_out <= $roomprice_sg['moc2'] && $m_out >= $roomprice_sg['moc1']) {
                                 $hours_day_2 = $h_out - $roomprice_sg['khunggiobatdau'] + $roomprice_sg['lamtron2'] / 60;
                             }
                             if ($m_out > $roomprice_sg['moc2']) {
                                 $hours_day_2 = $h_out - $roomprice_sg['khunggiobatdau'] + $roomprice_sg['lamtron3'] / 60;
                             }
                             $money_sg += $this->price_day($hours_day_2, $roomprice_sg, $room_237_sg);
                         }
                     } else {
                         $kt_night = $roomprice_sg['khunggiobatdau'] + 24 - $roomprice_sg['khunggioketthuc'];
                         if ($total_hours <= $kt_night) {
                             $money_sg += $total_hours * $roomprice_sg['giatheogio'];
                         } else {
                             if ($h_in < $roomprice_sg['khunggiobatdau']) {
                                 if ($test_h > $roomprice_sg['moc2']) {
                                     $hours_night1 = $roomprice_sg['khunggiobatdau'] - $h_in - 1 + $roomprice_sg['lamtron3'] / 60;
                                 }
                                 if ($test_h < $roomprice_sg['moc2'] && $test_h >= $roomprice_sg['moc1']) {
                                     $hours_night1 = $roomprice_sg['khunggioketthuc'] - $h_in - 1 + $roomprice_sg['lamtron2'] / 60;
                                 }
                                 if ($test_h < $roomprice_sg['moc1']) {
                                     $hours_night1 = $roomprice_sg['khunggioketthuc'] - $h_in - 1 + $roomprice_sg['lamtron1'] / 60;
                                 }
                                 if ($hours_night1 > 3) {
                                     $money_sg += $roomprice_sg['giaquadem'];
                                 } else {
                                     $money_sg += $hours_night1 * $roomprice_sg['giatheogio'];
                                 }
                                 $money_sg += $roomprice_sg['gianguyenngay'];
                                 if ($h_out < $roomprice_sg['khunggiobatdau']) {
                                     if ($m_out > $roomprice_sg['moc2']) {
                                         $hours_night2 = $h_out + 24 - $roomprice_sg['khunggioketthuc'] + $roomprice_sg['lamtron3'] / 60;
                                     }
                                     if ($m_out < $roomprice_sg['moc2'] && $test_h >= $roomprice_sg['moc1']) {
                                         $hours_night2 = $h_out + 24 - $roomprice_sg['khunggioketthuc'] + $roomprice_sg['lamtron2'] / 60;
                                     }
                                     if ($m_out < $roomprice_sg['moc1']) {
                                         $hours_night2 = $h_out + 24 - $roomprice_sg['khunggioketthuc'] + $roomprice_sg['lamtron1'] / 60;
                                     }
                                     if ($hours_night2 > 3) {
                                         $money_sg += $roomprice_sg['giaquadem'];
                                     } else {
                                         $money_sg += $hours_night2 * $roomprice_sg['giatheogio'];
                                     }
                                 } else {
                                     if ($m_out > $roomprice_sg['moc2']) {
                                         $hours_night2 = $h_out - $roomprice_sg['khunggioketthuc'] + $roomprice_sg['lamtron3'] / 60;
                                     }
                                     if ($m_out < $roomprice_sg['moc2'] && $test_h >= $roomprice_sg['moc1']) {
                                         $hours_night2 = $h_out - $roomprice_sg['khunggioketthuc'] + $roomprice_sg['lamtron2'] / 60;
                                     }
                                     if ($m_out < $roomprice_sg['moc1']) {
                                         $hours_night2 = $h_out - $roomprice_sg['khunggioketthuc'] + $roomprice_sg['lamtron1'] / 60;
                                     }
                                     if ($hours_night2 > 3) {
                                         $money_sg += $roomprice_sg['giaquadem'];
                                     } else {
                                         $money_sg += $hours_night2 * $roomprice_sg['giatheogio'];
                                     }
                                 }
                             } else {
                                 if ($test_h > $roomprice_sg['moc2']) {
                                     $hours_night1 = $roomprice_sg['khunggiobatdau'] + 23 - $h_in + $roomprice_sg['lamtron3'] / 60;
                                 }
                                 if ($test_h < $roomprice_sg['moc2'] && $test_h >= $roomprice_sg['moc1']) {
                                     $hours_night1 = $roomprice_sg['khunggioketthuc'] + 23 - $h_in + $roomprice_sg['lamtron2'] / 60;
                                 }
                                 if ($test_h < $roomprice_sg['moc1']) {
                                     $hours_night1 = $roomprice_sg['khunggioketthuc'] + 23 - $h_in + $roomprice_sg['lamtron1'] / 60;
                                 }
                                 if ($hours_night1 > 3) {
                                     $money_sg += $roomprice_sg['giaquadem'];
                                 } else {
                                     $money_sg += $hours_night1 * $roomprice_sg['giatheogio'];
                                 }
                                 $money_sg += $roomprice_sg['gianguyenngay'];
                                 if ($m_out > $roomprice_sg['moc2']) {
                                     $hours_night2 = $h_out - $roomprice_sg['khunggioketthuc'] + $roomprice_sg['lamtron3'] / 60;
                                 }
                                 if ($m_out < $roomprice_sg['moc2'] && $test_h >= $roomprice_sg['moc1']) {
                                     $hours_night2 = $h_out - $roomprice_sg['khunggioketthuc'] + $roomprice_sg['lamtron2'] / 60;
                                 }
                                 if ($m_out < $roomprice_sg['moc1']) {
                                     $hours_night2 = $h_out - $roomprice_sg['khunggioketthuc'] + $roomprice_sg['lamtron1'] / 60;
                                 }
                                 if ($hours_night2 > 3) {
                                     $money_sg += $roomprice_sg['giaquadem'];
                                 } else {
                                     $money_sg += $hours_night2 * $roomprice_sg['giatheogio'];
                                 }
                             }
                         }
                     }
                 } else {
                     if ($kt_in == 1) {
                         if ($test_h > $roomprice_sg['moc2']) {
                             $hours_day = $roomprice_sg['khunggiobatdau'] - $h_in - 1 + $roomprice_sg['lamtron3'] / 60;
                         }
                         if ($test_h < $roomprice_sg['moc2'] && $test_h >= $roomprice_sg['moc1']) {
                             $hours_day = $roomprice_sg['khunggioketthuc'] - $h_in - 1 + $roomprice_sg['lamtron2'] / 60;
                         }
                         if ($test_h < $roomprice_sg['moc1']) {
                             $hours_day = $roomprice_sg['khunggioketthuc'] - $h_in - 1 + $roomprice_sg['lamtron1'] / 60;
                         }
                         $money_sg += $this->price_day($hours_day, $roomprice_sg, $room_237_sg);
                         if ($h_out < $roomprice_sg['khunggiobatdau']) {
                             if ($m_out > $roomprice_sg['moc2']) {
                                 $hours_night2 = $h_out + 24 - $roomprice_sg['khunggioketthuc'] + $roomprice_sg['lamtron3'] / 60;
                             }
                             if ($m_out < $roomprice_sg['moc2'] && $test_h >= $roomprice_sg['moc1']) {
                                 $hours_night2 = $h_out + 24 - $roomprice_sg['khunggioketthuc'] + $roomprice_sg['lamtron2'] / 60;
                             }
                             if ($m_out < $roomprice_sg['moc1']) {
                                 $hours_night2 = $h_out + 24 - $roomprice_sg['khunggioketthuc'] + $roomprice_sg['lamtron1'] / 60;
                             }
                             if ($hours_night2 > 3) {
                                 $money_sg += $roomprice_sg['giaquadem'];
                             } else {
                                 $money_sg += $hours_night2 * $roomprice_sg['giatheogio'];
                             }
                         } else {
                             if ($m_out > $roomprice_sg['moc2']) {
                                 $hours_night2 = $h_out - $roomprice_sg['khunggioketthuc'] + $roomprice_sg['lamtron3'] / 60;
                             }
                             if ($m_out < $roomprice_sg['moc2'] && $test_h >= $roomprice_sg['moc1']) {
                                 $hours_night2 = $h_out - $roomprice_sg['khunggioketthuc'] + $roomprice_sg['lamtron2'] / 60;
                             }
                             if ($m_out < $roomprice_sg['moc1']) {
                                 $hours_night2 = $h_out - $roomprice_sg['khunggioketthuc'] + $roomprice_sg['lamtron1'] / 60;
                             }
                             if ($hours_night2 > 3) {
                                 $money_sg += $roomprice_sg['giaquadem'];
                             } else {
                                 $money_sg += $hours_night2 * $roomprice_sg['giatheogio'];
                             }
                         }
                     } else {
                         if ($h_in < $roomprice_sg['khunggiobatdau']) {
                             if ($test_h > $roomprice_sg['moc2']) {
                                 $hours_night1 = $roomprice_sg['khunggiobatdau'] - $h_in - 1 + $roomprice_sg['lamtron3'] / 60;
                             }
                             if ($test_h < $roomprice_sg['moc2'] && $test_h >= $roomprice_sg['moc1']) {
                                 $hours_night1 = $roomprice_sg['khunggioketthuc'] - $h_in - 1 + $roomprice_sg['lamtron2'] / 60;
                             }
                             if ($test_h < $roomprice_sg['moc1']) {
                                 $hours_night1 = $roomprice_sg['khunggioketthuc'] - $h_in - 1 + $roomprice_sg['lamtron1'] / 60;
                             }
                             if ($hours_night1 > 3) {
                                 $money_sg += $roomprice_sg['giaquadem'];
                             } else {
                                 $money_sg += $hours_night1 * $roomprice_sg['giatheogio'];
                             }
                         } else {
                             if ($test_h > $roomprice_sg['moc2']) {
                                 $hours_night1 = $roomprice_sg['khunggiobatdau'] + 23 - $h_in + $roomprice_sg['lamtron3'] / 60;
                             }
                             if ($test_h < $roomprice_sg['moc2'] && $test_h >= $roomprice_sg['moc1']) {
                                 $hours_night1 = $roomprice_sg['khunggioketthuc'] + 23 - $h_in + $roomprice_sg['lamtron2'] / 60;
                             }
                             if ($test_h < $roomprice_sg['moc1']) {
                                 $hours_night1 = $roomprice_sg['khunggioketthuc'] + 23 - $h_in + $roomprice_sg['lamtron1'] / 60;
                             }
                             if ($hours_night1 > 3) {
                                 $money_sg += $roomprice_sg['giaquadem'];
                             } else {
                                 $money_sg += $hours_night1 * $roomprice_sg['giatheogio'];
                             }
                         }
                         if ($m_out > $roomprice_sg['moc2']) {
                             $hours_night2 = $h_out - $roomprice_sg['khunggiobatdau'] + $roomprice_sg['lamtron3'] / 60;
                         }
                         if ($m_out < $roomprice_sg['moc2'] && $test_h >= $roomprice_sg['moc1']) {
                             $hours_night2 = $h_out - $roomprice_sg['khunggiobatdau'] + $roomprice_sg['lamtron2'] / 60;
                         }
                         if ($m_out < $roomprice_sg['moc1']) {
                             $hours_night2 = $h_out - $roomprice_sg['khunggiobatdau'] + $roomprice_sg['lamtron1'] / 60;
                         }
                         $money_sg += $this->price_day($hours_night2, $roomprice_sg, $room_237_sg);
                     }
                 }
             }
         }
     }
     if ($info_booking['twin'] > 0) {
         if ($info_booking['airport'] == 1) {
             $roomprice_tw = Roommoney::find(11)->toArray();
             $room_237_tw = Roomtime::mthod('KHUNGGIO7AM_23PM')->roomtype(11)->get()->toArray();
             $room_pt_tw = Roomtime::mthod('PHUTROI')->roomtype(11)->get()->toArray();
         } else {
             $roomprice_tw = Roommoney::find(13)->toArray();
             $room_237_tw = Roomtime::mthod('KHUNGGIO7AM_23PM')->roomtype(13)->get()->toArray();
             $room_pt_tw = Roomtime::mthod('PHUTROI')->roomtype(13)->get()->toArray();
         }
         if ($roomprice_tw['khunggiobatdau'] <= $h_in && $h_in < $roomprice_tw['khunggioketthuc']) {
             $kt_in = 1;
         } else {
             $kt_in = 2;
         }
         if ($roomprice_tw['khunggiobatdau'] <= $h_out && $h_out < $roomprice_tw['khunggioketthuc']) {
             $kt_out = 1;
         } else {
             $kt_out = 2;
         }
         $test_h = 60 - $m_in;
         if ($minutes < $roomprice_tw['moc1']) {
             $total_hours += $roomprice_tw['lamtron1'] / 60;
         } elseif ($roomprice_tw['moc1'] <= $minutes && $minutes <= $roomprice_tw['moc2']) {
             $total_hours += $roomprice_tw['lamtron2'] / 60;
         } else {
             $total_hours += $roomprice_tw['lamtron3'] / 60;
         }
         if ($roomprice_tw['tinhtheongaydem'] == 0) {
             if ($days < 1) {
                 $money_tw = $this->price_day($total_hours, $roomprice_tw, $room_237_tw);
             } else {
                 $full_price_tw = $days * $roomprice_tw['gianguyenngay'];
                 $last_tw = $this->price_day($hours, $roomprice_tw, $room_237_tw);
                 $money_tw = $full_price_tw + $last_tw;
             }
         } else {
             if ($days < 1) {
                 if ($kt_in == $kt_out) {
                     if ($kt_in == 1) {
                         if ($h_out > $h_in) {
                             $money_tw = $this->price_day($total_hours, $roomprice_tw, $room_237_tw);
                         } elseif ($h_out == $h_in) {
                             if ($m_in < $m_out) {
                                 $money_tw = $this->price_day($total_hours, $roomprice_tw, $room_237_tw);
                             } else {
                                 $money_tw = $roomprice_tw['gianguyenngay'];
                             }
                         } else {
                             if ($test_h > $roomprice_tw['moc2']) {
                                 $hours_day = $roomprice_tw['khunggioketthuc'] - $h_in - 1 + $roomprice_tw['lamtron3'] / 60;
                             }
                             if ($test_h < $roomprice_tw['moc2'] && $test_h >= $roomprice_tw['moc1']) {
                                 $hours_day = $roomprice_tw['khunggioketthuc'] - $h_in - 1 + $roomprice_tw['lamtron2'] / 60;
                             }
                             if ($test_h < $roomprice_tw['moc1']) {
                                 $hours_day = $roomprice_tw['khunggioketthuc'] - $h_in - 1 + $roomprice_tw['lamtron1'] / 60;
                             }
                             $money_tw = $this->price_day($hours_day, $roomprice_tw, $room_237_tw);
                             $money_tw += $roomprice_tw['giaquadem'];
                             if ($m_out < $roomprice_tw['moc1']) {
                                 $hours_day_2 = $h_out - $roomprice_tw['khunggiobatdau'] + $roomprice_tw['lamtron1'] / 60;
                             }
                             if ($m_out <= $roomprice_tw['moc2'] && $m_out >= $roomprice_tw['moc1']) {
                                 $hours_day_2 = $h_out - $roomprice_tw['khunggiobatdau'] + $roomprice_tw['lamtron2'] / 60;
                             }
                             if ($m_out > $roomprice_tw['moc2']) {
                                 $hours_day_2 = $h_out - $roomprice_tw['khunggiobatdau'] + $roomprice_tw['lamtron3'] / 60;
                             }
                             $money_tw += $this->price_day($hours_day_2, $roomprice_tw, $room_237_tw);
                         }
                     } else {
                         $kt_night = $roomprice_tw['khunggiobatdau'] + 24 - $roomprice_tw['khunggioketthuc'];
                         if ($total_hours <= $kt_night) {
                             $money_tw += $total_hours * $roomprice_tw['giatheogio'];
                         } else {
                             if ($h_in < $roomprice_tw['khunggiobatdau']) {
                                 if ($test_h > $roomprice_tw['moc2']) {
                                     $hours_night1 = $roomprice_tw['khunggiobatdau'] - $h_in - 1 + $roomprice_tw['lamtron3'] / 60;
                                 }
                                 if ($test_h < $roomprice_tw['moc2'] && $test_h >= $roomprice_tw['moc1']) {
                                     $hours_night1 = $roomprice_tw['khunggioketthuc'] - $h_in - 1 + $roomprice_tw['lamtron2'] / 60;
                                 }
                                 if ($test_h < $roomprice_sg['moc1']) {
                                     $hours_night1 = $roomprice_tw['khunggioketthuc'] - $h_in - 1 + $roomprice_tw['lamtron1'] / 60;
                                 }
                                 if ($hours_night1 > 3) {
                                     $money_sg += $roomprice_tw['giaquadem'];
                                 } else {
                                     $money_sg += $hours_night1 * $roomprice_sg['giatheogio'];
                                 }
                                 $money_tw += $roomprice_tw['gianguyenngay'];
                                 if ($h_out < $roomprice_tw['khunggiobatdau']) {
                                     if ($m_out > $roomprice_tw['moc2']) {
                                         $hours_night2 = $h_out + 24 - $roomprice_tw['khunggioketthuc'] + $roomprice_tw['lamtron3'] / 60;
                                     }
                                     if ($m_out < $roomprice_tw['moc2'] && $test_h >= $roomprice_tw['moc1']) {
                                         $hours_night2 = $h_out + 24 - $roomprice_tw['khunggioketthuc'] + $roomprice_tw['lamtron2'] / 60;
                                     }
                                     if ($m_out < $roomprice_tw['moc1']) {
                                         $hours_night2 = $h_out + 24 - $roomprice_tw['khunggioketthuc'] + $roomprice_tw['lamtron1'] / 60;
                                     }
                                     if ($hours_night2 > 3) {
                                         $money_tw += $roomprice_tw['giaquadem'];
                                     } else {
                                         $money_tw += $hours_night2 * $roomprice_tw['giatheogio'];
                                     }
                                 } else {
                                     if ($m_out > $roomprice_tw['moc2']) {
                                         $hours_night2 = $h_out - $roomprice_tw['khunggioketthuc'] + $roomprice_tw['lamtron3'] / 60;
                                     }
                                     if ($m_out < $roomprice_tw['moc2'] && $test_h >= $roomprice_tw['moc1']) {
                                         $hours_night2 = $h_out - $roomprice_tw['khunggioketthuc'] + $roomprice_tw['lamtron2'] / 60;
                                     }
                                     if ($m_out < $roomprice_sg['moc1']) {
                                         $hours_night2 = $h_out - $roomprice_tw['khunggioketthuc'] + $roomprice_tw['lamtron1'] / 60;
                                     }
                                     if ($hours_night2 > 3) {
                                         $money_tw += $roomprice_tw['giaquadem'];
                                     } else {
                                         $money_tw += $hours_night2 * $roomprice_tw['giatheogio'];
                                     }
                                 }
                             } else {
                                 if ($test_h > $roomprice_tw['moc2']) {
                                     $hours_night1 = $roomprice_tw['khunggiobatdau'] + 23 - $h_in + $roomprice_tw['lamtron3'] / 60;
                                 }
                                 if ($test_h < $roomprice_tw['moc2'] && $test_h >= $roomprice_tw['moc1']) {
                                     $hours_night1 = $roomprice_tw['khunggioketthuc'] + 23 - $h_in + $roomprice_tw['lamtron2'] / 60;
                                 }
                                 if ($test_h < $roomprice_tw['moc1']) {
                                     $hours_night1 = $roomprice_tw['khunggioketthuc'] + 23 - $h_in + $roomprice_tw['lamtron1'] / 60;
                                 }
                                 if ($hours_night1 > 3) {
                                     $money_sg += $roomprice_tw['giaquadem'];
                                 } else {
                                     $money_sg += $hours_night1 * $roomprice_tw['giatheogio'];
                                 }
                                 $money_sg += $roomprice_tw['gianguyenngay'];
                                 if ($m_out > $roomprice_tw['moc2']) {
                                     $hours_night2 = $h_out - $roomprice_tw['khunggioketthuc'] + $roomprice_tw['lamtron3'] / 60;
                                 }
                                 if ($m_out < $roomprice_tw['moc2'] && $test_h >= $roomprice_tw['moc1']) {
                                     $hours_night2 = $h_out - $roomprice_tw['khunggioketthuc'] + $roomprice_tw['lamtron2'] / 60;
                                 }
                                 if ($m_out < $roomprice_tw['moc1']) {
                                     $hours_night2 = $h_out - $roomprice_tw['khunggioketthuc'] + $roomprice_tw['lamtron1'] / 60;
                                 }
                                 if ($hours_night2 > 3) {
                                     $money_tw += $roomprice_tw['giaquadem'];
                                 } else {
                                     $money_tw += $hours_night2 * $roomprice_tw['giatheogio'];
                                 }
                             }
                         }
                     }
                 } else {
                     if ($kt_in == 1) {
                         if ($test_h > $roomprice_tw['moc2']) {
                             $hours_day = $roomprice_tw['khunggiobatdau'] - $h_in - 1 + $roomprice_tw['lamtron3'] / 60;
                         }
                         if ($test_h < $roomprice_tw['moc2'] && $test_h >= $roomprice_tw['moc1']) {
                             $hours_day = $roomprice_tw['khunggioketthuc'] - $h_in - 1 + $roomprice_tw['lamtron2'] / 60;
                         }
                         if ($test_h < $roomprice_tw['moc1']) {
                             $hours_day = $roomprice_tw['khunggioketthuc'] - $h_in - 1 + $roomprice_tw['lamtron1'] / 60;
                         }
                         $money_tw += $this->price_day($hours_day, $roomprice_tw, $room_237_tw);
                         if ($h_out < $roomprice_tw['khunggiobatdau']) {
                             if ($m_out > $roomprice_tw['moc2']) {
                                 $hours_night2 = $h_out + 24 - $roomprice_tw['khunggioketthuc'] + $roomprice_tw['lamtron3'] / 60;
                             }
                             if ($m_out < $roomprice_tw['moc2'] && $test_h >= $roomprice_sg['moc1']) {
                                 $hours_night2 = $h_out + 24 - $roomprice_tw['khunggioketthuc'] + $roomprice_tw['lamtron2'] / 60;
                             }
                             if ($m_out < $roomprice_tw['moc1']) {
                                 $hours_night2 = $h_out + 24 - $roomprice_tw['khunggioketthuc'] + $roomprice_tw['lamtron1'] / 60;
                             }
                             if ($hours_night2 > 3) {
                                 $money_tw += $roomprice_tw['giaquadem'];
                             } else {
                                 $money_tw += $hours_night2 * $roomprice_tw['giatheogio'];
                             }
                         } else {
                             if ($m_out > $roomprice_tw['moc2']) {
                                 $hours_night2 = $h_out - $roomprice_tw['khunggioketthuc'] + $roomprice_tw['lamtron3'] / 60;
                             }
                             if ($m_out < $roomprice_tw['moc2'] && $test_h >= $roomprice_tw['moc1']) {
                                 $hours_night2 = $h_out - $roomprice_tw['khunggioketthuc'] + $roomprice_tw['lamtron2'] / 60;
                             }
                             if ($m_out < $roomprice_sg['moc1']) {
                                 $hours_night2 = $h_out - $roomprice_tw['khunggioketthuc'] + $roomprice_tw['lamtron1'] / 60;
                             }
                             if ($hours_night2 > 3) {
                                 $money_tw += $roomprice_tw['giaquadem'];
                             } else {
                                 $money_tw += $hours_night2 * $roomprice_tw['giatheogio'];
                             }
                         }
                     } else {
                         if ($h_in < $roomprice_tw['khunggiobatdau']) {
                             if ($test_h > $roomprice_tw['moc2']) {
                                 $hours_night1 = $roomprice_tw['khunggiobatdau'] - $h_in - 1 + $roomprice_tw['lamtron3'] / 60;
                             }
                             if ($test_h < $roomprice_tw['moc2'] && $test_h >= $roomprice_tw['moc1']) {
                                 $hours_night1 = $roomprice_tw['khunggioketthuc'] - $h_in - 1 + $roomprice_tw['lamtron2'] / 60;
                             }
                             if ($test_h < $roomprice_tw['moc1']) {
                                 $hours_night1 = $roomprice_tw['khunggioketthuc'] - $h_in - 1 + $roomprice_tw['lamtron1'] / 60;
                             }
                             if ($hours_night1 > 3) {
                                 $money_tw += $roomprice_tw['giaquadem'];
                             } else {
                                 $money_tw += $hours_night1 * $roomprice_sg['giatheogio'];
                             }
                         } else {
                             if ($test_h > $roomprice_tw['moc2']) {
                                 $hours_night1 = $roomprice_tw['khunggiobatdau'] + 23 - $h_in + $roomprice_tw['lamtron3'] / 60;
                             }
                             if ($test_h < $roomprice_tw['moc2'] && $test_h >= $roomprice_tw['moc1']) {
                                 $hours_night1 = $roomprice_tw['khunggioketthuc'] + 23 - $h_in + $roomprice_tw['lamtron2'] / 60;
                             }
                             if ($test_h < $roomprice_tw['moc1']) {
                                 $hours_night1 = $roomprice_tw['khunggioketthuc'] + 23 - $h_in + $roomprice_tw['lamtron1'] / 60;
                             }
                             if ($hours_night1 > 3) {
                                 $money_tw += $roomprice_tw['giaquadem'];
                             } else {
                                 $money_tw += $hours_night1 * $roomprice_tw['giatheogio'];
                             }
                         }
                         if ($m_out > $roomprice_tw['moc2']) {
                             $hours_night2 = $h_out - $roomprice_tw['khunggiobatdau'] + $roomprice_tw['lamtron3'] / 60;
                         }
                         if ($m_out < $roomprice_tw['moc2'] && $test_h >= $roomprice_tw['moc1']) {
                             $hours_night2 = $h_out - $roomprice_tw['khunggiobatdau'] + $roomprice_tw['lamtron2'] / 60;
                         }
                         if ($m_out < $roomprice_tw['moc1']) {
                             $hours_night2 = $h_out - $roomprice_tw['khunggiobatdau'] + $roomprice_tw['lamtron1'] / 60;
                         }
                         $money_tw += $this->price_day($hours_night2, $roomprice_tw, $room_237_sg);
                     }
                 }
             }
         }
     }
     if ($info_booking['child'] > 0) {
         $money_pt = $info_booking['child'] * $room_pt_sg[0]['mucdieuchinhgia'] * $total_hours;
     }
     $money_total = $money_sg * $info_booking['single'] + $money_tw * $info_booking['twin'] + $money_pt;
     $data_out[] = array();
     $data_out = ['time_in' => $info_booking['time_in'], 'date_in' => $info_booking['date_in'], 'time_out' => $info_booking['time_out'], 'date_out' => $info_booking['date_out'], 'adult' => $info_booking['adult'], 'child' => $info_booking['child'], 'baby' => $info_booking['baby'], 'airport' => $info_booking['airport'], 'single' => $info_booking['single'], 'twin' => $info_booking['twin'], 'mn_single' => $money_sg * $info_booking['single'], 'mn_twin' => $money_tw * $info_booking['twin'], 'mn_child' => $money_pt, 'total' => $money_total];
     $key_encrypt = $this->mc_encrypt($data_out, $this->vif_key);
     //$key_encrypt=urlencode($key_encrypt);
     return view('booking.info', compact('data_out', 'key_encrypt'));
 }