public function update() { $id = Input::get('txtIdPhieu'); $nm = str_replace(" ", "", Input::get('txtMaSoNguoiMuon')); $ghichu = str_replace(" ", " ", Input::get('txtGhiChu')); $tthoatdong = Input::get('trangthai'); $idNguoixuly = General::getId(Auth::user()->ma_so_the); //Cập nhật trạng thái chi tiết phiếu mượn khi trạng thái phiếu mượn là 1(Được mượn). if ($tthoatdong == 1) { $RowAction = DB::update('update chi_tiet_phieu_muon_sach set trang_thai_sach_muon=' . $tthoatdong . ' where id_phieu_muon=?', array($id)); } else { if ($tthoatdong == 2) { $RowAction = DB::update('update chi_tiet_phieu_muon_sach set trang_thai_sach_muon=5 where id_phieu_muon=?', array($id)); } else { if ($tthoatdong == 0) { } } } //null. //-------------------------------------------------------- //Kiểm tra mã số thẻ trước khi cập nhật. $CountND = DB::table('nguoi_dung')->select(DB::raw('count(*) as tong'))->where('nguoi_dung.ma_so_the', $nm)->get(); if ($CountND[0]->tong == 0) { return Redirect::back()->with('messagecheck1', 'Mã số thẻ không tồn tại!'); } else { $TT = General::getTrangThai($nm); if ($TT == 0) { return Redirect::back()->with('messagecheck2', 'Tài khoản này đang bị khóa!'); } } $idnguoimuon = General::getId($nm); $idOld = General::getIdNguoiMuon($id); if ($idnguoimuon != $idOld) { $IdQuyenHan = General::getIdQuyenHan($idnguoimuon); $SoSach = DB::table('phieu_muon_sach')->join('chi_tiet_phieu_muon_sach', function ($join) { $join->on('phieu_muon_sach.id', '=', 'chi_tiet_phieu_muon_sach.id_phieu_muon'); })->select(DB::raw('count(*) as tong'))->where('phieu_muon_sach.id_nguoi_muon', $idnguoimuon, 'OR')->where('phieu_muon_sach.id_nguoi_muon', $idOld)->get(); if ($SoSach[0]->tong >= SO_SACH_MUON_SV && $IdQuyenHan == 4) { return Redirect::back()->with('messagecheckdetail6', 'Theo quy định của thư viện sinh viên chỉ được mượn tối đa 3 quyển!'); } else { if ($SoSach[0]->tong >= SO_SACH_MUON_CB && $IdQuyenHan != 4) { return Redirect::back()->with('messagecheckdetail6', 'Theo quy định của thư viện cán bộ chỉ được mượn tối đa 5 quyển!'); } } } //---------------------------------- $RowAction = DB::update('update phieu_muon_sach set id_nguoi_muon =' . $idnguoimuon . ',ghi_chu_phieu="' . $ghichu . '",id_nguoi_xu_ly=' . $idNguoixuly . ', trang_thai_phieu=' . $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>