public function updatedetail() { $id = Input::get('txtidChitietPhieu'); $BarCode = str_replace(" ", "", Input::get('txtMaBarCode')); $idSach = General::getIdSach($BarCode); // $thoigianmuon = Input::get('txtThoiGianMuon'); $thoigianhentra = Input::get('txtThoiGianHenTra'); $ghichu = str_replace(" ", " ", Input::get('txtGhiChu')); $tthoatdong = Input::get('trangthai'); $idNguoiCapNhat = General::getId(Auth::user()->ma_so_the); //Kiểm tra trạng thái chi tiết phiếu mượn -> quyển sách -> đầu sách ->banner. $tthoatdongold = General::getTrangThaiSachMuon($id); if ($tthoatdong != $tthoatdongold) { //Trạng thái sách trả if ($tthoatdong == 0) { $now = date('Y-m-d', time()); if ($thoigianhentra < $now) { $idNguoiMuon = General::getIdNguoiMuon(General::getIdPhieuMuon($id)); $CountBanner = DB::table('banned_tk')->select(DB::raw('count(*) as tong'))->where('banned_tk.id_nguoi_bi_banned', $idNguoiMuon)->get(); if ($CountBanner[0]->tong == 0) { $idNguoiBiBan = $idNguoiMuon; $SoNgayBan = SO_NGAY_BANNED_LAN_NHAT; $NgayBatDau = $now; $LyDo = "Trả sách trể hẹn"; $IdNguoiBan = General::getId(Auth::user()->ma_so_the); $ThoiGianTacVu = date('Y-m-d H:i:s', time()); $TrangThaiBan = 0; $result = DB::table('banned_tk')->insert(array('id_nguoi_bi_banned' => $idNguoiBiBan, 'so_ngay_banned' => $SoNgayBan, 'ngay_bat_dau' => $NgayBatDau, 'ly_do_banned' => $LyDo, 'id_nguoi_banned' => $IdNguoiBan, 'thoi_gian_tac_vu' => $ThoiGianTacVu, 'trang_thai_ban' => $TrangThaiBan)); } else { if ($CountBanner[0]->tong == 1) { $idNguoiBiBan = $idNguoiMuon; $SoNgayBan = SO_NGAY_BANNED_LAN_HAI; $NgayBatDau = $now; $LyDo = "Trả sách trể hẹn"; $IdNguoiBan = General::getId(Auth::user()->ma_so_the); $ThoiGianTacVu = date('Y-m-d H:i:s', time()); $TrangThaiBan = 0; $result = DB::table('banned_tk')->insert(array('id_nguoi_bi_banned' => $idNguoiBiBan, 'so_ngay_banned' => $SoNgayBan, 'ngay_bat_dau' => $NgayBatDau, 'ly_do_banned' => $LyDo, 'id_nguoi_banned' => $IdNguoiBan, 'thoi_gian_tac_vu' => $ThoiGianTacVu, 'trang_thai_ban' => $TrangThaiBan)); } else { $idNguoiBiBan = $idNguoiMuon; $NgayBatDau = $now; $LyDo = "Trả sách trể hẹn"; $IdNguoiBan = General::getId(Auth::user()->ma_so_the); $ThoiGianTacVu = date('Y-m-d H:i:s', time()); $TrangThaiBan = 1; $result = DB::table('banned_tk')->insert(array('id_nguoi_bi_banned' => $idNguoiBiBan, 'ngay_bat_dau' => $NgayBatDau, 'ly_do_banned' => $LyDo, 'id_nguoi_banned' => $IdNguoiBan, 'thoi_gian_tac_vu' => $ThoiGianTacVu, 'trang_thai_ban' => $TrangThaiBan)); } } } } else { if ($tthoatdong == 2) { $now = date('Y-m-d', time()); if ($thoigianhentra < $now) { $idNguoiMuon = General::getIdNguoiMuon(General::getIdPhieuMuon($id)); $CountBanner = DB::table('banned_tk')->select(DB::raw('count(*) as tong'))->where('banned_tk.id_nguoi_bi_banned', $idNguoiMuon)->get(); if ($CountBanner[0]->tong == 0) { $idNguoiBiBan = $idNguoiMuon; $SoNgayBan = SO_NGAY_BANNED_LAN_NHAT; $NgayBatDau = $now; $LyDo = "Trả sách trể hẹn"; $IdNguoiBan = General::getId(Auth::user()->ma_so_the); $ThoiGianTacVu = date('Y-m-d H:i:s', time()); $TrangThaiBan = 0; $result = DB::table('banned_tk')->insert(array('id_nguoi_bi_banned' => $idNguoiBiBan, 'so_ngay_banned' => $SoNgayBan, 'ngay_bat_dau' => $NgayBatDau, 'ly_do_banned' => $LyDo, 'id_nguoi_banned' => $IdNguoiBan, 'thoi_gian_tac_vu' => $ThoiGianTacVu, 'trang_thai_ban' => $TrangThaiBan)); } else { if ($CountBanner[0]->tong == 1) { $idNguoiBiBan = $idNguoiMuon; $SoNgayBan = SO_NGAY_BANNED_LAN_HAI; $NgayBatDau = $now; $LyDo = "Trả sách trể hẹn"; $IdNguoiBan = General::getId(Auth::user()->ma_so_the); $ThoiGianTacVu = date('Y-m-d H:i:s', time()); $TrangThaiBan = 0; $result = DB::table('banned_tk')->insert(array('id_nguoi_bi_banned' => $idNguoiBiBan, 'so_ngay_banned' => $SoNgayBan, 'ngay_bat_dau' => $NgayBatDau, 'ly_do_banned' => $LyDo, 'id_nguoi_banned' => $IdNguoiBan, 'thoi_gian_tac_vu' => $ThoiGianTacVu, 'trang_thai_ban' => $TrangThaiBan)); } else { $idNguoiBiBan = $idNguoiMuon; $NgayBatDau = $now; $LyDo = "Trả sách trể hẹn"; $IdNguoiBan = General::getId(Auth::user()->ma_so_the); $ThoiGianTacVu = date('Y-m-d H:i:s', time()); $TrangThaiBan = 1; $result = DB::table('banned_tk')->insert(array('id_nguoi_bi_banned' => $idNguoiBiBan, 'ngay_bat_dau' => $NgayBatDau, 'ly_do_banned' => $LyDo, 'id_nguoi_banned' => $IdNguoiBan, 'thoi_gian_tac_vu' => $ThoiGianTacVu, 'trang_thai_ban' => $TrangThaiBan)); } } } //-------------------. } else { if ($tthoatdong == 3) { $idQuyenSach = $idSach; //Cập nhật sách mượn (quyển sach). $RowAction = DB::update('update quyen_sach set trang_thai_sach=0 where id=?', array($idQuyenSach)); //-------------------------------. $idDauSach = General::getIdDauSach($idQuyenSach); $CountDauSach = DB::table('quyen_sach')->select(DB::raw('count(*) as tong'))->where('quyen_sach.id_dau_sach', $idDauSach, 'and')->where('quyen_sach.trang_thai_sach', 1)->get(); if ($CountDauSach[0]->tong == 0) { //Cập nhật đầu sách (đầu sách). $RowAction = DB::update('update dau_sach set trang_thai_dau_sach=0 where id=?', array($idDauSach)); //-------------------------------. } } } } } $ThoiGianTraOld = General::getThoiGianHenTra($id); if ($ThoiGianTraOld != $thoigianhentra) { $IdGiaHan = $id; $SoNgayGiaHan = date('d', strtotime($thoigianhentra)) - date('d', strtotime($ThoiGianTraOld)); $ThoiGianDKGH = date('Y-m-d H:i:s', time()); $GhiChu = "Gia hạn trược tiếp với thủ thư"; $result = DB::table('dang_ki_gia_han_sach')->insert(array('id_sach_muon' => $IdGiaHan, 'so_ngay_gia_han' => $SoNgayGiaHan, 'thoi_gian_dk_gia_han' => $ThoiGianDKGH, 'ghi_chu_gia_han' => $GhiChu)); } //--------------------------------------------------------------------------. $RowAction = DB::update('update chi_tiet_phieu_muon_sach set id_quyen_sach ="' . $idSach . '",thoi_gian_hen_tra="' . $thoigianhentra . '",id_nguoi_cap_nhat=' . $idNguoiCapNhat . ', ghi_chu_sach_muon="' . $ghichu . '",trang_thai_sach_muon=' . $tthoatdong . ' where id=?', array($id)); return Redirect::back()->with('message', 'Sửa thông tin phiếu mượn thành công!'); }
<span class="input-group-addon">Mã BarCode:</span> <input type="text" name="txtMaBarCode" id="iduserid" class="form-control" maxlength="11" placehoder="Thời gian hẹn trả"/> </div> <div class="input-group"> <span class="input-group-addon">Thời Gian Mượn:</span> <input type="text" name="txtThoiGianMuon" id="ThoiGianMuonId" class="form-control" placehoder="Thời gian mượn" value="<?php echo date('d/m/Y', time()); ?> " readonly/> </div> <div class="input-group"> <span class="input-group-addon">Thời Gian Hẹn Trả:</span> <input type="text" name="txtThoiGianHenTra" id="ThoiGianHenTraId" class="form-control" placehoder="Thời gian hẹn trả" value="<?php $now = time(); $add = 86400; if (General::getIdQuyenHan(General::getIdNguoiMuon(General::getIdPhieu(ThuThuQuanLyMuonTra::getMaSoVuaNhap()))) == 4) { $add = $add * SO_NGAY_MUON_SV; } else { $add = $add * SO_NGAY_MUON_CB; } $new = $add + $now; echo date('d/m/Y', $new); ?> " readonly/> </div> <div class="input-group"> <span class="input-group-addon">Ghi Chú:</span> <input type="text" name="txtGhiChu" id="GhiChulId" class="form-control" placehoder="Ghi Chú"/> </div> <div class="input-group"> <span class="input-group-addon">Mã Số Người Nhập:</span>
<input type="text" class="form-control" placeholder="Thời gian mượn" name="txtThoiGianMuon" id="txtThoiGianMuonId" value="<?php echo date('d/m/Y', strtotime($Phieu->thoi_gian_muon)); ?> " readonly/> </div> <div class="input-group"> <span class="input-group-addon">Thời Gian Hẹn Trả:</span> <input type="date" class="form-control" placeholder="Thời gian hẹn trả" name="txtThoiGianHenTra" id="txtThoiGianHenTraId" value="<?php echo $Phieu->thoi_gian_hen_tra; ?> " min="<?php echo date("Y-m-d", strtotime($Phieu->thoi_gian_hen_tra)); ?> " <?php if (General::getIdQuyenHan(General::getIdNguoiMuon(General::getIdPhieuMuon($Phieu->id))) == 4) { ?> max="<?php echo date("Y-m-d", strtotime($Phieu->thoi_gian_hen_tra) + 86400 * SO_NGAY_MUON_SV); ?> " <?php } else { ?> max="<?php echo date("Y-m-d", strtotime($Phieu->thoi_gian_hen_tra) + 86400 * SO_NGAY_MUON_CB); ?> " <?php } ?> /> </div>