public static function getThoiGianHenTra($id)
 {
     $idThoiGianHenTra = ChiTietPhieuMuonSach::select('thoi_gian_hen_tra')->where('id', $id)->get();
     return $idThoiGianHenTra[0]->thoi_gian_hen_tra;
 }
 public function store()
 {
     $ngaylap = date("Y-m-d", strtotime(Input::get('txtthoigian')));
     $msphieu = PhieuMuonSach::max('ma_so_phieu');
     $msphieu = ++$msphieu;
     $id_qs = Session::get('phieumuon.id_qs');
     $nhom_nguoi_dung = Auth::user()->id_nhom_quyen_han;
     if ($nhom_nguoi_dung == 3) {
         $so_ngay = SO_NGAY_MUON_SV;
     } else {
         $so_ngay = SO_NGAY_MUON_SV;
     }
     $ngaytra = date("Y-m-d", strtotime(Input::get('txtthoigian')) + 86400 * $so_ngay);
     $id_nm = Auth::user()->id;
     $count = count($id_qs);
     $maxid = PhieuMuonSach::max('id');
     DB::statement(DB::raw("CALL insert_phieu_muon(" . ++$maxid . ",'" . $msphieu . "'," . $id_nm . ");"));
     for ($i = 0; $i < $count; $i++) {
         $id = ChiTietPhieuMuonSach::max('id');
         DB::statement(DB::raw("CALL insert_chi_tiet_phieu_muon(" . ++$id . "," . $maxid . "," . $id_qs[$i] . ",'" . $ngaylap . "','" . $ngaytra . "');"));
     }
     Session::forget('phieumuon.id_ds');
     Session::forget('phieumuon.id_qs');
     Session::forget('phieumuon.bar_code');
     Session::forget('phieumuon.ten_sach');
     Session::forget('phieumuon.gioi_thieu');
     Session::forget('phieumuon.link_ha');
     Session::forget('phieumuon.ngon_ngu');
     return Redirect::back()->with('success_message', 'Cảm ơn bạn đã đặt sách trực tuyến, xin hãy liên hệ xác nhận với thủ thư trong thời gian 2 NGÀY kể từ lúc đặt!');
 }
 public function destroydetailtemp()
 {
     $id = Input::get('txtIdPhieuMuon');
     $idPhieuMuon = General::getIdPhieuMuon($id);
     $result = false;
     try {
         $result = ChiTietPhieuMuonSach::find($id)->delete();
     } catch (Exception $ex) {
         $result = false;
     }
     return Redirect::back()->with('result', $result);
 }
        echo date("d/m/Y", strtotime($quyensach->thoi_gian_muon));
        ?>
</td>
                                <td class="center"><?php 
        echo date("d/m/Y", strtotime($quyensach->thoi_gian_hen_tra));
        ?>
</td>
                                <td class="center" >
                                    <?php 
        $checksn = true;
        switch ($quyensach->trang_thai_sach_muon) {
            case 0:
                echo "<input style='color:white !important;'class='btn btn-large btn-primary' type='text' value='Đã Trả' readonly>";
                break;
            case 1:
                if (ChiTietPhieuMuonSach::kiemTraTrangThai($quyensach->id)) {
                    echo "<input style='color:white !important;'class='btn btn-large btn-success' type='text' value='Mượn Đúng Hẹn' readonly>";
                } else {
                    echo "<input style='color:white !important;'class='btn btn-large btn-warning' type='text' value='Đang Trễ Hẹn' readonly>";
                    $checksn = FALSE;
                }
                break;
            case 2:
                echo "<input style='color:white !important;'class='btn btn-large btn-warning' type='text' value='Đang Trễ Hẹn' readonly>";
                break;
            case 3:
                echo "<input style='color:white !important;'class='btn btn-large btn-inverse' type='text' value='Đã Làm Mất' readonly>";
                break;
            case 4:
                echo "<input style='color:white !important;'class='btn btn-large btn-info' type='text' value='Đang Giữ Chỗ' readonly>";
                break;