function logEvent($event, $mid_user=0, $mid_patron=0, $description=''){ $dt = date("Y-m-d G:i:s"); $sql = sprintf("INSERT INTO eventlog (mid_user, mid_patron, dt, event, description) VALUES (%d, %d, '%s', '%s', '%s')", $mid_user, $mid_patron, $dt, $event, $description); $a = executeSqlNonQuery($sql); $rows = $a['rows']; if($rows != 1){ // Not logged // } }
if($rowsUpdated == 1){ header("Location: feedback.php?msg=Entry updated."); exit(); } else { header("Location: feedback.php?msg=Failed to update entry."); exit(); } } /**** END: Update record */ /**** Delete record */ if(isset($_REQUEST['BtnDelete'])){ $id = $_REQUEST['id']; $sql = sprintf("DELETE FROM feedback WHERE id=%d",$id); $a = executeSqlNonQuery($sql); $rowsUpdated = $a['rows']; if($rowsUpdated == 1){ header("Location: feedback.php?msg=Entry deleted."); exit(); } else { header("Location: feedback.php?msg=Failed to delete entry."); exit(); } } /**** END: Delete record */ /**** Display record */ if(isset($_REQUEST['ID'])){
function changeBarcode($member, $barcode){ $sql = sprintf("SELECT * FROM member WHERE barcode='%s'", $barcode); $rs = executeSqlQuery($sql); $cnt = mysql_num_rows($rs); if($cnt>0){ //Specified barcode already exist $midT = $member['mid']; $msg = "The barcode <strong>$barcode</strong> already exists!<br>Barcode was not changed<hr>" . $this->toString($member) . '<hr>' . "<a href='member_edit.php?ID=$midT'>Edit Again</a> | <a href='member_view.php?ID=$midT'>View Full Details</a> | <a href='member_browse.php'>Browse Members</a>"; $title = 'No Changes Made'; displayMsg($msg,$title); } $sql = sprintf("update member set barcode='%s' WHERE mid=%d", $barcode, $member['mid']); $a = executeSqlNonQuery($sql); $rows_affected = $a['rows']; $midT = $member['mid']; if ($rows_affected == 1) { //[Log Event]--------------------------- $des = '[' . $member['barcode'] . "] ==> [$barcode]"; logEvent('MEMBER_BARCODE', $_SESSION['CurrentUser']['mid'], $member['mid'], addslashes($des)); //[Display message] ------------------------------ $msg = "Barcode Changed to: <strong>$barcode</strong><br>Member Details before the change are:<hr>" . $this->toString($member) . '<hr>' . "<a href='member_edit.php?ID=$midT'>Edit Again</a> | <a href='member_view.php?ID=$midT'>View Full Details</a> | <a href='member_browse.php'>Browse Members</a>"; $title = 'Member Barcode Changed'; displayMsg($msg,$title); } elseif ($rows_affected == 0) { $msg = 'Barcode was not changed, because you had specified the old barcode as the new one.<hr>' . $this->toString($member) . '<hr>' . "<a href='member_edit.php?ID=$midT'>Edit Again</a> | <a href='member_view.php?ID=$midT'>View Full Details</a> | <a href='member_browse.php'>Browse Members</a>"; $title = 'No Changes Made'; displayMsg($msg, $title); } }
function changeBarcode($copy, $barcode) { $sql = sprintf("SELECT * FROM copy WHERE barcode='%s'", $barcode); $rs = executeSqlQuery($sql); $cnt = mysql_num_rows($rs); if ($cnt > 0) { //Specified barcode already exist $msg = "The barcode <strong>$barcode</strong> already exists!<br>Barcode was not changed<hr>" . $this->toStringCopy($copy) . '<hr>' . "<a href='book_copy_edit.php?ID=$cid'>Edit This Copy Again</a> | <a href='book_edit.php?ID=$bid'>Edit the Associated Book</a> | <a href='book_search.php'>Browse Books</a>"; $title = 'No Changes Made'; displayMsg($msg, $title); } $sql = sprintf("update copy set barcode='%s' WHERE cid=%d", $barcode, $copy['cid']); $a = executeSqlNonQuery($sql); $rows_affected = $a['rows']; $bid = $copy['bid']; $cid = $copy['cid']; if ($rows_affected == 1) { //[Log Event]--------------------------- $des = '[' . $copy['barcode'] . "] ==> [$barcode]"; logEvent('BOOK_BARCODE', $_SESSION['CurrentUser']['mid'], 0, addslashes($des)); //[Display message] ------------------------------ $msg = "Barcode Changed to: $barcode<br>Copy Details before the change are:<hr>" . $this->toStringCopy($copy) . '<hr>' . "<a href='book_copy_edit.php?ID=$cid'>Edit This Copy Again</a> | <a href='book_edit.php?ID=$bid'>Edit the Associated Book</a> | <a href='book_search.php'>Browse Books</a>"; $title = 'Copy Updated'; displayMsg($msg, $title); } elseif ($rows_affected == 0) { $msg = 'Barcode was not changed, because you had specified the old barcode as the new one.<hr>' . $this->toStringCopy($copy) . '<hr>' . "<a href='book_copy_edit.php?ID=$cid'>Edit This Copy Again</a> | <a href='book_edit.php?ID=$bid'>Edit the Associated Book</a> | <a href='book_search.php'>Browse Books</a>"; $title = 'No Changes Made'; displayMsg($msg, $title); } }
function ReturnBook($rowCopy, $rowLoan, $rowMember){ // Set date_returned $irDate = $_SESSION['irDate']; unset($_SESSION['irDate']); if(isset($irDate) && $irDate != ""){ $t = @strtotime($irDate); if($t!=-1){ $date_returned = date("Y-m-d G:i:s",$t); } else { $_SESSION['msg'] = 'ERROR issuing book.<br>' . $rowCopy['title'] . " by " . $rowCopy['authors'] . '<br>' . "Please enter a valid date time in the format 'YYYY-MM-DD hh:mm'.<br>". "Or you may leave the Date/Time box blank to use the current time.<br>"; header("Location: ir2.php?mid=" . $rowMember['mid']); exit(); } } else { $date_returned = date("Y-m-d G:i:s"); } $rowLoan['date_returned'] = $date_returned; // Update loan table $fineDetails = CalcFine($rowCopy, $rowLoan, $rowMember); $rowLoan['fine'] = $fineDetails[0]; $rowLoan['date_returned'] = $date_returned; $sql = sprintf("UPDATE loan SET returned=1, date_returned = '%s', fine=%d WHERE lid=%d", $date_returned, $fine,$rowLoan['lid']); $a = executeSqlNonQuery($sql); $rowsUpdated = $a['rows']; if($rowsUpdated != 1){ $_SESSION['msg'] = "An error occured while returning book."; $_SESSION['msgIcon'] = 'ERROR'; header("Location: ir2.php?mid=" . $rowMember['mid']); exit(); } $des = '[' . $rowCopy['access_no'] . ']' . $rowCopy['title'] . ' <== ' . '[' . $rowMember['title'] . ' ' . $rowMember['firstnames'] . ' ' . $rowMember['surname'] . ']'; logEvent('RETURN', $_SESSION['CurrentUser']['mid'], $rowMember['mid'], addslashes($des)); include('../classes/Reservations.php'); $re = new Reservations; if ($re->IsReserved($rowCopy['bid'])){ $reservationsMsg = $re->updateReservations($rowCopy); } // Display Returned Books info if(!isset($_SESSION['Returned'])){ $_SESSION['Returned'][0] = 0; $_SESSION['TotalFine'] = 0; } $_SESSION['Returned'][0] += 1; $n = $_SESSION['Returned'][0]; $_SESSION['Returned'][$n]['copy'] = $rowCopy; $_SESSION['Returned'][$n]['member'] = $rowMember; $_SESSION['Returned'][$n]['loan'] = $rowLoan; $_SESSION['Returned'][$n]['msg'] = $fineDetails[1]; if(!isset($_SESSION['TotalFine'])) $_SESSION['TotalFine']=0; $_SESSION['TotalFine'] = (int)$_SESSION['TotalFine'] + $fineDetails[0]; $_SESSION['msg'] = $_SESSION['msg'] . "Book Returned<br>". $rowCopy['title'] . " by " . $rowCopy['authors'] . '<br>'; $_SESSION['msgIcon'] = 'INFO'; if(isset($reservationsMsg)) $_SESSION['msg'] = $_SESSION['msg'] . "<div class='reservationsMsg'>" . $reservationsMsg . '</div>'; header("Location: ir2.php?mid=" . $rowMember['mid']); exit(); }
function MarkReservationAsFullfilled($rid){ // returns a status message $sql = sprintf("UPDATE reservation SET status='Fullfilled' WHERE rid=%d",$rid); $a = executeSqlNonQuery($sql); $rows_updated = $a['rows']; if($rows_updated != 1){ return "ERROR: couldn't update reservation status"; } else { return "Reservation marked as fullfilled"; } }