📄 find_item.php
字号:
<?php
/**************************************************************************************
Simple Library System
Copyright (C) 2002 John Mark Matthews
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
For further information, contact:
John Matthews
jmatthews@exostrategy.com
***************************************************************************************/
include("mainfile.inc");
include("header.inc");
include("footer.inc");
include("auth.inc");
reg('GET','item_type','status','view_login_id');
reg('POST','item_type2','option','fulltext','subject2');
if($item_type || $item_type2) {
if($option=="FULLTEXT") {
$query="&option=FULLTEXT&item_type2=$item_type2&fulltext=$fulltext&subject2=$subject2&status=$status&view_login_id=$view_login_id";
$sql = "select avg_grade,total_review, login, item_type_desc, status_desc, i.* from tbl_review_summary r, tbl_item i left outer join tbl_login x on i.login_id=x.login_id, tbl_item_type t, tbl_status s where ";
$sql.= " r.item_id=i.item_id and i.item_type=t.item_type and i.status=s.status and (i.item_type=$item_type2 or $item_type2=-1)";
if(!$global_is_admin) $sql.= " and i.status<>4 ";
if($fulltext!="") $sql.= " and match(title, author, abstract) against ('$fulltext') ";
if($subject2!="") $sql.=" and lower(subject) like lower('%$subject2%')";
}else{
$query="&item_type=$item_type&title=$title&author=$author&abstrat=$abstract&subject=$subject&status=$status&view_login_id=$view_login_id";
$sql = "select avg_grade,total_review, login, item_type_desc, status_desc, i.* from tbl_review_summary r, tbl_item i left outer join tbl_login x on i.login_id=x.login_id, tbl_item_type t, tbl_status s where ";
$sql.= " r.item_id=i.item_id and i.item_type=t.item_type and i.status=s.status and (i.item_type=$item_type or $item_type=-1)";
if(!$global_is_admin) $sql.= " and i.status<>4 ";
if($title!="") $sql.=" and lower(title) like lower('%$title%')";
if($author!="") $sql.=" and lower(author) like lower('%$author%')";
if($subject!="") $sql.=" and lower(subject) like lower('%$subject%')";
if($abstract!="") $sql.=" and lower(abstract) like lower('%$abstract%')";
}
if($status!="") $sql.=" and i.status=$status";
if($view_login_id!="") $sql.=" and i.login_id=$view_login_id";
if(isset($sort)) {
$sort=$sort.",";
}else{
$sort="";
}
if($status!="") {
$sql.=" order by $sort due_date asc, title";
}else{
$sql.=" order by $sort subject, title, item_type_desc";
}
//echo $sql;
$r=mysql_query($sql);
head();
menu();
OpenTable(0,0,3);
$row_count=1;
OpenRow();
PrintHeader("<a href='./find_item.php?$query&sort=ITEM_TYPE ".(( $sort != "ITEM_TYPE," ) ? "" : "DESC")."'>Type</a>","width=50");
PrintHeader("<a href='./find_item.php?$query&sort=TITLE ".(( $sort != "TITLE," ) ? "" : "DESC")."'>Title</a>","width=150");
PrintHeader("<a href='./find_item.php?$query&sort=AVG_GRADE ".(( $sort != "AVG_GRADE," ) ? "" : "DESC")."'>Rating</a>","width=60");
PrintHeader("<a href='./find_item.php?$query&sort=AUTHOR ".(( $sort != "AUTHOR," ) ? "" : "DESC")."'>Author</a>","width=100");
PrintHeader("<a href='./find_item.php?$query&sort=SUBJECT ".(( $sort != "SUBJECT," ) ? "" : "DESC")."'>Subject</a>","width=200");
PrintHeader("<a href='./find_item.php?$query&sort=STATUS_DESC ".(( $sort != "STATUS_DESC," ) ? "" : "DESC")."'>Status</a>","width=75");
if($global_is_admin) {
PrintHeader("<a href='./find_item.php?$query&sort=LOGIN ".(( $sort != "LOGIN," ) ? "" : "DESC")."'>Checked Out to (due)</a>","width=150");
}else{
PrintHeader("<a href='./find_item.php?$query&sort=DUE_DATE ".(( $sort != "DUE_DATE," ) ? "" : "DESC")."'>Due</a>","width=150");
}
if($global_is_admin) {
PrintHeader(" ","width=75");
PrintHeader(" ","width=75");
PrintHeader(" ","width=75");
PrintHeader(" ","width=75");
}else{
PrintHeader(" ","width=75");
PrintHeader(" ","width=75");
}
CloseRow();
while($line = mysql_fetch_array($r)) {
OpenRow();
PrintCell($line["item_type_desc"],"valign='top'");
echo "<td valign='top' class='data'>";
echo LinkToItem($line["item_id"],$line["title"]);
echo "</td>";
echo "<td valign='top' class='data'>";
$s="";
if($line["total_review"]==0) {
echo "<font class='stars_off'>no reviews</font";
}else{
$s.= " <font class='stars_on'>";
for($i=1;$i<=$line["avg_grade"];$i++){
$s.= "*";
}
$s.= "</font>";
$s.= "<font class='stars_off'>";
for($i=$line["avg_grade"]+1;$i<=5;$i++){
$s.="*";
}
$s.= "</font>";
echo LinkToItem($line["item_id"],$s,1);
}
echo "</td>";
// PrintCell(LinkToItem($line["item_id"],$line["title"]),"valign='top'");
$string = htmlspecialchars($line["author"]);
$string = preg_replace("/(\015\012)|(\015)|(\012)/","<br />",$string);
$string = str_replace("<br /><br><br />","<br />",$string);
PrintCell($string." ","valign='top'");
$string = htmlspecialchars($line["subject"]);
$string = preg_replace("/(\015\012)|(\015)|(\012)/","<br />",$string);
$string = str_replace("<br /><br><br />","<br />",$string);
PrintCell($string." ","valign='top'");
PrintCell($line["status_desc"],"valign='top'");
if($line["login"]!="") {
if($global_is_admin) {
PrintCell(LinkToLogin($line["login_id"],$line["login"])." (".$line["due_date"].") ","valign='top'");
}else{
PrintCell($line["due_date"]." ","valign='top'");
}
}else{
PrintCell($line["login"]." ","valign='top'");
}
if($global_is_admin) {
PrintCell("<a onMouseover=\"showtip(this,event,'Update!')\" onMouseout=\"hidetip()\"href='./update_item.php?&item_id=".$line["item_id"]."'><img src='update.gif' border=0></a>","valign='top'");
PrintCell("<a onMouseover=\"showtip(this,event,'View Requests!')\" onMouseout=\"hidetip()\"href='./view_item_requests.php?&item_id=".$line["item_id"]."'><img src='request.gif' border=0></a>","valign='top'");
if($line["login_id"]>0) {
PrintCell("<a onMouseover=\"showtip(this,event,'Checkin!')\" onMouseout=\"hidetip()\"href='./checkin.php?&item_id=".$line["item_id"]."'><img src='checkin.gif' border=0></a>","valign='top'");
}else{
PrintCell("<a onMouseover=\"showtip(this,event,'Checkout!')\" onMouseout=\"hidetip()\"href='./checkout.php?&item_id=".$line["item_id"]."'><img src='checkout.gif' border=0></a>","valign='top'");
}
PrintCell("<a onMouseover=\"showtip(this,event,'View History!')\" onMouseout=\"hidetip()\"href='./history.php?&item_id=".$line["item_id"]."'><img src='history.gif' border=0></a>","valign='top'");
}else{
if($line["status"]!=0 && $line["login_id"]==$global_login_id) {
PrintCell(" ");
PrintCell("<a onMouseover=\"showtip(this,event,'View Requests!')\" onMouseout=\"hidetip()\"href='./view_item_requests.php?&item_id=".$line["item_id"]."'><img src='request.gif' border=0></a>","valign='top'");
}else{
PrintCell("<a style='cursor:hand' onMouseover=\"showtip(this,event,'Request Checkout!')\" onMouseout=\"hidetip()\" onClick='if (confirm(\"Are you sure you want to request this item for checkout?\")) { window.location.href=\"request_checkout.php?&item_id=".$line["item_id"]."\"; }'><img src='checkout.gif' border=0></a>","valign='top'");
PrintCell("<a onMouseover=\"showtip(this,event,'View Requests!')\" onMouseout=\"hidetip()\"href='./view_item_requests.php?&item_id=".$line["item_id"]."'><img src='request.gif' border=0></a>","valign='top'");
}
}
CloseRow();
}
CloseTable();
foot();
}else{
head();
menu();
$t="";
$t[-1]="All";
$t = MakeSelectArray("select item_type, item_type_desc from tbl_item_type order by item_type_desc",$t);
$subject_list="";
$subject_list[""]="All";
$subject_list = MakeSelectArray("select subject, subject from tbl_subject order by subject",$subject_list);
OpenForm("'$PHP_SELF'");
OpenTable();
echo Row(Cell("Type:").Cell(MakeSelect("item_type2",-1,$t)));
echo Row(Cell("Subject:").Cell(MakeSelect("subject2",-1,$subject_list)));
echo Row(Cell("Search:").Cell("<textarea wrap='virtual' cols='60' rows='3' name='fulltext'></textarea>"));
echo Row(Cell("<input align='center' name='y' type='submit' value = 'Find Item'>","colspan='4' align='center'"));
echo Row(Cell("<input type='hidden' name='option' value='FULLTEXT'>"));
CloseTable();
CloseForm();
foot();
}
?>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -