📄 holdings.class.php
字号:
<?php
/*apr 2, 2004 [] this should be modified first before fetchdetailed [] pythoning views [] i have a bad practive of putting always return when it is not returning anything [] i have a move towards making this adodb compliant [] then making it smarty compliant [] i'm thinking of converting all the post/get vars into more okey form [] convert the accession number location, so that it will be statically assigned [] Just a note, when encoding the accession number, i think it is good if they will be encoding the format like this, location+accessionnumer, because we are aware that in every accession number it has a varied location. so it is ok now to to encode like this example, 99900$aDMLF$bAccno-12345$cCirculation [] Book/Material type: Reserved/Circulation/Photocopy/RoomUse [] library type is deprecated because the library location should be defined statically, no dependencies*/Class Holdings
{
// a class, nice function Holdings() { // Constructor // Initialize attributes $this->pol = ''; $this->tbl = ''; $this->dbc = ''; $this->pml = ''; $this->tpl = ''; $this->usr = ''; $this->web = ''; $this->cat = ''; $this->trn = ''; $this->hld = ''; $this->fdt = ''; $this->_post = array(); $this->_get = array(); $this->_files = array(); } function SetArgvs($_post=array(), $_get=array(), $_files=array()) { $this->_post = $_post; $this->_get = $_get; $this->_files = $_files; } function SetNeededClasses($pol='', $pml='', $tpl='', $usr='', $web='', $cat='', $trn='', $hld='', $fdt='') { $this->pol = $pol; $this->dbc = $this->pol->DBGetConn(); $this->tbl = $this->pol->DBGetTables(); $this->pml = $pml; $this->tpl = $tpl; $this->usr = $usr; $this->web = $web; $this->cat = $cat; $this->trn = $trn; $this->hld = $hld; $this->fdt = $fdt; } function SelectVarName($id="", $varname="",$strID="")
{ $a = new Polerio;
$table = $a->DBGetTables(); list($dbconn) = $a->DBGetConn(); $holdings = $table['holdings'];
$holdings_col = $table['holdings_column'];
if(!empty($strID)) $strid=$strID; else $strid='id';
$c=0;
if(is_array($varname)) {
while(list($key,$value)=each($varname))
{
$col[$c] = $holdings_col[$value];
$c++;
}
$cols = implode($col,",");
}
else $cols = "$holdings_col[$varname]";
$sql="select $cols from $holdings where $holdings_col[$strid]=$id"; $recordSet = $dbconn->Execute($sql);
return $recordSet->fields;
}
function HoldingsUpdateData($uniqueids="", $vaccessno="", $vlocation="", $vtype="", $vbarcode="")
{
list($dbconn) = $this->dbc;
$table = $this->tbl;
$holdings = $table['holdings'];
$holdings_col = $table['holdings_column'];
$end = count($uniqueids);
$i=0;
while($i <= ($end-1))
{
$sql ="update $holdings set $holdings_col[id]='$uniqueids[$i]',$holdings_col[barcode]='$vbarcode[$i]',";
$sql.="$holdings_col[location]='$vlocation[$i]',$holdings_col[accessno]='$vaccessno[$i]',$holdings_col[type]='$vtype[$i]'";
$sql.=" where $holdings_col[id]=$uniqueids[$i]";
$recordSet = $dbconn->Execute($sql);
$i++;
}
}
function HoldingsAddData($accessid="")
{
$table = $this->tbl;
$holdings = $table['holdings'];
$holdings_col = $table['holdings_column'];
list($dbconn) = $this->dbc;
$holdingsid = $this->pol->TimeAndRandom();
$location = "1";
$key = $this->pol->SessionGetVar('rand');
srand((double)microtime()*1000000);
$accessno = "LC-".rand();
$type = 1;
$sql ="insert into $holdings ($holdings_col[id],$holdings_col[holdingsid],$holdings_col[barcode],";
$sql.="$holdings_col[location],$holdings_col[accessno], $holdings_col[type])";
$sql.="values('$holdingsid','$accessid','$holdingsid','$location','$accessno','$type')";
$recordSet = $dbconn->Execute($sql);
}
function HoldingsDeleteData($delete_hld_id="")
{
$table = $this->tbl;
$holdings = $table['holdings'];
$holdings_col = $table['holdings_column'];
list($dbconn) = $this->dbc;
$sql="delete from $holdings where $holdings_col[id]=$delete_hld_id";
$recordSet = $dbconn->Execute($sql);
}
function ListHoldings($id="", $bakto='')
{ $tbl = $this->tbl; list($dbconn2) = $this->dbc; $tbln = $tbl['holdings']; $tblc = $tbl['holdings_column']; global $book_status,$book_type,$library_type;
$sql="select $tblc[holdingsid], $tblc[id] from $tbln where id=$id"; $color = $this->pol->SelectColor();
$bgcolor1 = $color[1];
$bgcolor2 = $color[2];
$bgcolor3 = $color[3];
$recordSet = $dbconn2->Execute($sql); if (!$recordSet->EOF) {
list($accessid, $EditID) = $recordSet->fields;
}
$recordSet->Close();
$sql ="select $tblc[id], $tblc[accessno], $tblc[location], ";
$sql.="$tblc[type] from $tbln where $tblc[holdingsid]=$accessid";
$recordSet = $dbconn2->Execute($sql); $hi =0;
$i=1;
$j=0;
$id = array(); $accessno = array();
$hld=0;
while(!$recordSet->EOF)
{
list($id[$i],$access[$i],$loc[$i],$typ[$i]) = $recordSet->fields;
$image_url = $this->pol->GetPolerioURL().'phpmylibrary/images';
list($status,$borrowdate,$returndate) = Transaction::SelectVarName($id[$i],array('status','borrowdate','returndate'),'holdingsid');
if(gettype($status)=='NULL') $status=1;
if(($status==1) && ($this->pol->SessionGetVar('uid') >= 2)) {
$sessid = $this->pol->SecGenAuthKey();
$res[$i] = "<a href=\"".$this->pol->GetModuleURL().$this->pol->Med()."div=tra&acc=pub&q=res&id=".$id[$i]."&bakto=".$bakto."&sessid=".$sessid."\" onclick=\"return confirmLink(this, 'With Accession No. ".$access[$i]."','Reserve this material')\">";
$res[$i] .= "<img src=\"$image_url/available.gif\" border=\"0\" width=\"18\" height=\"18\" alt=\"Reserve this Material\"></a>";
} elseif(!($status==1)) {
$res[$i] = "<img src=\"$image_url/available.gif\" border=\"0\" width=\"18\" height=\"18\" alt=\"Not Available\">";
} elseif(!($this->pol->SessionGetVar('uid') >= 2)) {
$res[$i] = "<img src=\"$image_url/available.gif\" border=\"0\" width=\"18\" height=\"18\" alt=\"Available! Login First\">";
}
/* $dSql = "SELECT DATE_FORMAT($borrowdate,'%b %d, %Y %T'), DATE_FORMAT($returndate,'%b %d, %Y %T')";
$drecordSet = $dbconn2->Execute($dSql);
list($borrowdate,$returndate) = $drecordSet->fields; */
if(empty($borrowdate)) $borrowdate='---';
if(empty($returndate)) $returndate='---';
$status = $book_status[$status];
//$typ[$i] = $book_type[$typ[$i]];
$result[$hi] = array($id[$i],$access[$i],$loc[$i],$status,$typ[$i],$borrowdate,$returndate,$res[$i]);
$hi++;
$i++;
$hld++;
$recordSet->MoveNext();
}
$recordSet->Close();
if($id)
{
$ca = $this->pol->GetPolerioURI().'/inc';
$body = "<script src=\"$ca/functions.js\" type=\"text/javascript\" language=\"javascript\"></script>";
$template = "$body".$this->tpl->LoadTemplate($this->pol->GetModuleURI().'templates/listholdings.html');
$vars = array( "pol::holdings","pol::accessno","pol::location","pol::status","pol::type","pol::dateborrowed","pol::datedue","pol::level",
"pol::action","pol::bgcolor2","pol::bgcolor1","pol::borrow"
);
$vals = array( _PMLHOLDINGS,_PMLACCESSNO,_PMLLOCATION,_PMLSTATUS,_PMLTYPE,
_PMLDATEBORROWED,_PMLDATEDUE,_PMLLEVEL,_PMLACTION,
"$bgcolor2","$bgcolor1","Borrow"
);
$varStatic = "table1";
$varDynamic = "loop1";
$template = $this->tpl->ReplaceStatic($template, $vars, $vals);
$vars = array("pol::id","pol::vaccessno","pol::vlocation","pol::vstatus","pol::vtype","pol::vdateborrowed","pol::vdatedue","pol::vborrow");
$template = $this->tpl->DynamicRows($template, $varStatic, $varDynamic, $vars, $result);
$template = "$template";
} else { $template = ""; }
return $template;
}
function HoldingsEditData($disp="", $action="",$tag="",$value="", $approved="", $id="", $catid="", $content="", $level="", $bakto="")
{
global $library_type,$book_type,$HTTP_GET_VARS;
$table = $this->tbl;
$tblbib = $table['tblbib'];
$tblbib_col = $table['tblbib_column'];
$holdings = $table['holdings'];
$holdings_col = $table['holdings_column'];
list($dbconn) = $this->dbc;
$sql="select accessid, id from $tblbib where $tblbib_col[id]=$id";
$recordSet = $dbconn->Execute($sql);
if (!$recordSet->EOF) {
list($accessid, $EditID) = $recordSet->fields;
}
$recordSet->Close();
$sql = "select $holdings_col[id], $holdings_col[accessno], $holdings_col[location], ";
$sql .= " $holdings_col[type], $holdings_col[barcode] from $holdings where $holdings_col[holdingsid]=$accessid";
$recordSet = $dbconn->Execute($sql);
$i=0;
$j=0;
$id = array(); $accessno = array();
$hld=0;
while(!$recordSet->EOF)
{
$id[$i] = $recordSet->fields[0];
$access[$i] = $recordSet->fields[1];
$loc[$i] = $recordSet->fields[2];
$sts[$i] = $recordSet->fields[3];
$bar[$i] = $recordSet->fields[4];
$status = $recordSet->fields[3];
$user_status = $book_type;
$n=$status;
$status = '<select name="vtype[]">';
$status .='';
for($ic=0;$ic<count($user_status);$ic++)
{
if(($ic+1)==$n) $selected="selected"; else $selected="";
$status .= '<option value="'.($ic+1).'" '.$selected.' >'.$user_status[($ic+1)].'</option>'."\n";
}
$status .= '</select> ';
$user_status = $library_type;
$n=$recordSet->fields[2];
$loca = '<select name="vlocation[]">';
$loca .='';
for($ic=0;$ic<count($user_status);$ic++)
{
if(($ic+1)==$n) $selected="selected"; else $selected="";
$loca .= '<option value="'.($ic+1).'" '.$selected.' >'.$library_type[($ic+1)][2].'</option>'."\n";
}
$loca .= '</select> ';
$result[$i] = array($id[$i],$access[$i],$loca,$status,$bar[$i]);
$i++;
$hld++;
$recordSet->MoveNext();
}
$recordSet->Close();
global $bakto;
$ca = $this->pol->GetPolerioURI().'inc';
$body = "<script src=\"$ca/functions.js\" type=\"text/javascript\" language=\"javascript\"></script>";
$template = $this->tpl->LoadTemplate($this->pol->GetModuleURI().'templates/holdingsedit.html');
$vars = array( "pol::bgcolor2","pol::bgcolor1","pol::accessno","pol::location",
"pol::type","pol::barcode","pol::action","pol::vdelete",
"pol::deletethisholdingsno","pol::vbakto","pol::getmoduleurl","pol::getmodulemedurl",
"pol::veditid","pol::vaccessid","pol::holdings","pol::doyoureallywantto","pol::bakto"
);
$bgcolor1 = $this->pml->bgcolor1();
$bgcolor2 = $this->pml->bgcolor2();
$vals = array( "$bgcolor2","$bgcolor1",_PMLACCESSNO,_PMLLOCATION,
_PMLTYPE,"Barcode",_PMLACTION,_PMLDELETE,
_PMLDELETETHISHOLDINGSNO,"$bakto",$this->pol->GetModuleURL(),$this->pol->GetModuleURL().$this->pol->Med(),
"$EditID","$accessid",_PMLHOLDINGS,_PMLDOYOUREALLYWANTTO,"$bakto"
);
$varStatic = "table1";
$varDynamic = "loop1";
$template = $this->tpl->ReplaceStatic($template, $vars, $vals);
$vars = array("pol::vuniqueid","pol::vaccessno","pol::vlocation","pol::vstatus","pol::vlevel");
$template = $this->tpl->DynamicRows($template, $varStatic, $varDynamic, $vars, $result);
$template = "$body"."$template";
return $template;
}
} //end class
?>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -