⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 transaction.class.php

📁 开源MARC数据处理
💻 PHP
📖 第 1 页 / 共 2 页
字号:
<?php/*apr-03-2004	[] modifying the transaction files	[] pythoning the file*/
Class Transaction
	{	function Transaction() 		{		// 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="")
		{
		$table = $this->tbl;
		$trans = $table['transaction'];
		$trans_col = $table['transaction_column'];
		list($dbconn) = $this->dbc;
		if(!empty($strID)) $strid=$strID; else $strid='id';
		$c=0;
		if(is_array($varname)) 			{
			while(list($key,$value)=each($varname))
				{
				$col[$c] = $trans_col[$value];
				$c++;
				}
			$cols = implode($col,",");
			}
		else 			{			$cols = "$trans_col[$varname]";			}
		$sql="select $cols from $trans where $trans_col[$strid]=$id";
		$recordSet = $dbconn->Execute($sql);
		return $recordSet->fields;
		}
	function GetStatus($hid="")
		{
		$table = $this->tbl;
		list($dbconn) = $this->dbc;
		$trans = $table['transaction'];
		$trans_col = $table['transaction_column'];
		$sql = "select $trans_col[status] from $trans where $trans_col[holdingsid]='$hid'";
		$recordSet = $dbconn->Execute($sql);
		return $recordSet->fields[0];
		}
	function Reserve($hid="",$q="")
		{
		global $cut_off;
		$uid = $this->pol->SessionGetVar('uid');
		$table = $this->tbl;
		list($dbconn) = $this->dbc;
		$trans = $table['transaction'];
		$trans_col = $table['transaction_column'];
		$dSql = "SELECT NOW()";
		$drecordSet = $dbconn->Execute($dSql);
		$Fborrow = $drecordSet->fields[0];
		$rSql = "SELECT NOW() + INTERVAL '".$cut_off[1]." HOUR'";		$rrecordSet = $dbconn->Execute($rSql);		$Freturn = $rrecordSet->fields[0];
		$transid = $hid;
		$sql = "INSERT INTO  $trans ";
		$sql .= "($trans_col[id], $trans_col[holdingsid], $trans_col[userid], ";
		$sql .= "$trans_col[status], $trans_col[borrowdate], $trans_col[returndate]) ";
		$sql .= " VALUES ('$transid', $hid, $uid,0,'$Fborrow','$Freturn')";
		$recordSet = $dbconn->Execute($sql);		$id = $dbconn->Insert_ID();
		return $id;
		}
	function Update($tid="")
		{
		global $user_type;
		$uid = $this->pol->SessionGetVar('uid');
		$table = $this->tbl;
		list($dbconn) = $this->dbc;
		$trans = $table['transaction'];
		$trans_col = $table['transaction_column'];
		list($holdingsid,$userid,$borrowdate) = $this->SelectVarName($tid,array('holdingsid','userid','borrowdate'));
		list($holdingstype) = $this->hld->SelectVarName($holdingsid, 'type');
		list($usertype) = $this->usr->SelectVarName($userid, 'type');
		$nodayscanborrow = $this->pml->NoOfDaysCanBorrow();
		$dateadd = "SELECT  timestamp '$borrowdate' + INTERVAL '".$nodayscanborrow." DAY'";		$dateSet = $dbconn->Execute($dateadd);
		$sql = "UPDATE $trans ";
		$sql .= "set $trans_col[status]='2',$trans_col[returndate]='".$dateSet->fields[0]."' WHERE $trans_col[id]=$tid";		$recordSet = $dbconn->Execute($sql);
		return;
		}
	function Delete($tid="")
		{
		global $user_type;
		$uid = $this->pol->SessionGetVar('uid');
		$table = $this->tbl;
		list($dbconn) = $this->dbc;
		$trans = $table['transaction'];
		$trans_col = $table['transaction_column'];
		$sql = "DELETE FROM $trans ";
		$sql .= "WHERE $trans_col[id]=$tid";
		$recordSet = $dbconn->Execute($sql);
		return;
		}
	function DeleteUserTransactions($userid="")
		{
		global $user_type;
		$table = $this->tbl;
		list($dbconn) = $this->dbc;
		$trans = $table['transaction'];
		$trans_col = $table['transaction_column'];
		$sql = "DELETE FROM $trans ";
		$sql .= "WHERE $trans_col[userid]=$userid";
		$recordSet = $dbconn->Execute($sql);
		return;
		}
	function DeleteBorrowed($userid="")
		{
		$table = $this->tbl;
		list($dbconn) = $this->dbc;
		$trans = $table['transaction'];
		$trans_col = $table['transaction_column'];
		$sql = "DELETE FROM $trans ";
		$sql .= "WHERE $trans_col[userid]=$userid";
		$recordSet = $dbconn->Execute($sql);
		return;
		}
	function UserTransaction()
		{
		global $ac,$tid;
		global $user_type;
		$uid = $this->pol->SessionGetVar('uid');
		$table = $this->tbl;
		list($dbconn) = $this->dbc;
		$trans = $table['transaction'];
		$trans_col = $table['transaction_column'];
		if($ac=="canapp") 			{
			$sql = "DELETE FROM $trans ";
			$sql .= " WHERE $trans_col[id]=$tid AND $trans_col[userid]=$uid";
			$recordSet = $dbconn->Execute($sql);
			return '<b>For Approval Cancelled!</b>';
			} 		elseif($ac=="ret") 			{
			$sql = "UPDATE $trans ";
			$sql .= " set $trans_col[status]=5";
			$sql .= " WHERE $trans_col[id]=$tid AND $trans_col[userid]=$uid";
			$recordSet = $dbconn->Execute($sql);
			return '<b>Material lined up For Return!</b>';
			}		elseif($ac=="ren") 			{
			$sql = "UPDATE $trans ";
			$sql .= " set $trans_col[status]=6";
			$sql .= " WHERE $trans_col[id]=$tid AND $trans_col[userid]=$uid";
			$recordSet = $dbconn->Execute($sql);
			return '<b>Material lined up For Renewal!</b>';
			}		elseif($ac=="canre")			{
			$sql = "UPDATE $trans ";
			$sql .= " set $trans_col[status]=2";
			$sql .= " WHERE $trans_col[id]=$tid AND $trans_col[userid]=$uid";
			$recordSet = $dbconn->Execute($sql);
			return '<b>Cancelled!</b>';
			}
		return '';
		}
	function AdminAction()
		{		global $cut_off;
		global $q, $tid,$uid;
		$table = $this->tbl;
		list($dbconn) = $this->dbc;
		$trans = $table['transaction'];
		$trans_col = $table['transaction_column'];
		global $sessid;
		if(!$this->pol->SecConfirmAuthKey($sessid)) return '<b>Session Expired!</b>';
		if($q=="ret")			{
			$sql = "UPDATE $trans ";
			$sql .= " set $trans_col[status]=5";
			$sql .= " WHERE $trans_col[id]=$tid";
			$recordSet = $dbconn->Execute($sql);
			return '<b>Material lined up For Return!</b>';
			}		elseif($q=="ren")			{
			$sql = "UPDATE $trans ";
			$sql .= " set $trans_col[status]=6";
			$sql .= " WHERE $trans_col[id]=$tid";

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -