public function handleEdit() { $book = Borrow::findOrFail(Input::get('borrow')); $book->membership_id = Input::get('membership_id'); $book->book_name = Input::get('book_name'); $book->borrow_date = Input::get('from'); $book->return_date = Input::get('to'); $book->book_copy = Input::get('copy'); $book->updated_by_id = Auth::id(); $book->update(); return Redirect::action('AdminLibraryUserController@index')->with('flash_edit_success', 'Hurray!You have updated a new Book'); }
<?php $base = "../../"; require_once $base . "functions.php"; require_once $base . "loginCheck.php"; header('Content-type: text/html; charset=UTF-8'); $uid = getUid(); $hash = getCookieHash(); checkCookieHash($uid, $hash); //itemId, userId if (!isset($_POST["itemId"]) || !$_POST["itemId"]) { add_return_data(0, 5, "itemId is a must."); } $itemId = $_POST["itemId"]; $lend = new Borrow(); if (!$lend->lendBook($uid = $uid, $hash = $hash, $itemId = $itemId)) { add_return_data(0, 7, "Accept Error."); } add_return_data(1, 1, "Book Lended.");
require_once $base . "functions.php"; require_once $base . "loginCheck.php"; header('Content-type: text/html; charset=UTF-8'); $uid = getUid(); $hash = getCookieHash(); checkCookieHash($uid, $hash); //itemId, (message) if (!isset($_POST["itemId"]) || !$_POST["itemId"]) { add_return_data(0, 5, "itemId is a must."); } $itemId = $_POST["itemId"]; $message = ""; if (isset($_POST["message"])) { $message = $_POST["message"]; } $borrow = new Borrow(); $user = new Items(); $ruid = $user->getUserId($itemId); if ($borrow->isAlreadyBorrowed($itemId)) { add_return_data(0, 6, "Is Already Borrowed"); } if ($ruid == -1 || $ruid == $uid) { add_return_data(0, 8, "Cannot borrow your own book"); } if (!$borrow->borrowBook($uid = $uid, $hash = $hash, $itemId = $itemId, $message = $message)) { add_return_data(0, 7, "Borrow Error."); } $msg = new Message(); $ruid = $user->getUserId($itemId); if ($ruid == -1) { add_return_data(1, 2, "Borrowed but cannot send message.");
<?php $base = "../../"; require_once $base . "functions.php"; require_once $base . "loginCheck.php"; header('Content-type: text/html; charset=UTF-8'); $uid = getUid(); $hash = getCookieHash(); checkCookieHash($uid, $hash); //itemId if (!isset($_POST["itemId"]) || !$_POST["itemId"]) { add_return_data(0, 5, "itemId is a must."); } $itemId = $_POST["itemId"]; $return = new Borrow(); if (!$return->isBorrowedBy($uid = $uid, $itemId = $itemId)) { add_return_data(0, 6, "Uid haven't given this book to anyone"); } if (!$return->returnBook($uid = $uid, $hash = $hash, $itemId = $itemId)) { add_return_data(0, 7, "Return Error."); } add_return_data(1, 1, "Book Returned.");
<?php $base = "../../"; require_once $base . "functions.php"; header('Content-type: text/html; charset=UTF-8'); $uid = getUid(); $hash = getCookieHash(); checkCookieHash($uid, $hash); if (!isset($_POST["itemId"])) { add_return_data(0, 2, "Item Id is required."); } if (!$_POST["itemId"]) { add_return_data(0, 3, "Item Id is required."); } $itemId = $_POST["itemId"]; $items = new Items(); $item = $items->getItemById($itemId); $item["user"] = $items->getUserInformation($itemId); $borrow = new Borrow(); $item["available"] = "no"; if (!$borrow->isNotReturned($itemId)) { $item["available"] = "yes"; } $returndata["data"] = $item; add_return_data(1, 1, "Success");
public function actionReturn($id) { /** * @var $model Borrow */ $model = Borrow::model()->findByPk($id); $model->return_date = date('Y-m-d'); $model->save(); if (strtotime($model->return_date) > strtotime($model->due_date)) { echo 'bad'; } else { echo 'good'; } }