<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>
public function storedetail() { if (Input::has('btnThemDetail')) { //Check Same sách, TG mượn - Trả của từng người dùng(CB - SV). $BarCode = str_replace(" ", "", Input::get('txtMaBarCode')); $CountSACH = DB::table('quyen_sach')->select(DB::raw('count(*) as tong'))->where('quyen_sach.ma_bar_code', $BarCode)->get(); if ($CountSACH[0]->tong == 0) { return Redirect::back()->with('messagecheckdetail1', 'Sách không tồn tại!'); } $IdPhieu = General::getIdPhieu(str_replace(" ", "", Input::get('txtMaPhieuMuon'))); $idSach = General::getIdSach($BarCode); $thoigianmuon = date('Y-m-d', strtotime(Input::get('txtThoiGianMuon'))); //---------------------------------- //---------------------------------- // $thoigianhentra = Date('Y-m-d', strtotime(Input::get('txtThoiGianHenTra'))); $CountSACHDetail = DB::table('chi_tiet_phieu_muon_sach')->select(DB::raw('count(*) as tong'))->where('chi_tiet_phieu_muon_sach.id_quyen_sach', $idSach, 'and')->where('chi_tiet_phieu_muon_sach.id_phieu_muon', $IdPhieu)->get(); if ($CountSACHDetail[0]->tong != 0) { return Redirect::back()->with('messagecheckdetail2', 'Sách đã tồn tại trong phiếu!'); } $IdQuyenHan = General::getIdQuyenHan(General::getIdNguoiMuon($IdPhieu)); $idNguoiMuon = General::getIdNguoiMuon($IdPhieu); $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)->get(); if ($SoSach[0]->tong >= 3 && $IdQuyenHan == 4) { return Redirect::back()->with('messagecheckdetail5', '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 >= 5 && $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!'); } } //------------------------------------------------------------------. $now = time(); $new = 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; $thoigianhentra = date('Y-m-d', $new); $ghichu = str_replace(" ", " ", Input::get('txtGhiChu')); $idnguoixuly = General::getId(str_replace(" ", "", Input::get('txtIdUser'))); $thoigianxuly = Date('Y-m-d H:i:s', strtotime(Input::get('txtThoiGianCapNhatTT'))); $tthoatdong = 1; $result = DB::table('chi_tiet_phieu_muon_sach')->insert(array('id_phieu_muon' => $IdPhieu, 'id_quyen_sach' => $idSach, 'thoi_gian_muon' => $thoigianmuon, 'thoi_gian_hen_tra' => $thoigianhentra, 'ghi_chu_sach_muon' => $ghichu, 'id_nguoi_cap_nhat' => $idnguoixuly, 'tg_cap_nhat_trang_thai' => $thoigianxuly, 'trang_thai_sach_muon' => $tthoatdong)); return Redirect::back()->with('message', 'Thêm sách mượn thành công!'); } }