asset_admin_transfer.php

来自「这是一个用于资产管理的源码工具包」· PHP 代码 · 共 659 行 · 第 1/3 页

PHP
659
字号
					break;				case "-1":					$new_owner_name = "Surplus";					break;				case "-2":					$new_owner_name = "Retired";					break;				default:					$new_owner_name = $query_data["LastName"] . ", " . $query_data["FirstName"];					break;			}			echo "<tr>";			echo "<td class='approvals'><font class='text12'>";			echo date("l, M d, Y", $query_data["StartDate"]);			echo "</font></td>";			echo "<td class='approvals'>";			echo "<a href='" . $PHP_SELF . "?action=employeeview&key=" . $cur_owner_id . "' class='text12'>" . $cur_owner_name . "</a>";			echo "</td>";			echo "<td class='approvals'>";			echo "<a href='" . $PHP_SELF . "?action=employeeview&key=" . $new_owner_id . "' class='text12'>" . $new_owner_name . "</a>";			echo "</td>";			echo "<td class='approvals'>";			echo "<a href='" . $PHP_SELF . "?action=assetview&key=" . $query_data["Assets_ID"] . "' class='text12'>" . $query_data["AssetTag"] . "</a>";			echo "</td>";			echo "<td class='approvals'><font class='text12'>";			echo $query_data["AssetType"];			echo "</font></td>";			echo "<td class='approvals'><font class='text12'>";			echo $query_data["AssetSupplier"] . " " . $query_data["AssetModel"];			echo "</font></td>";			echo "<td class='approvals'><a href='" . $PHP_SELF . "?action=assetapprovals&approve=" . $query_data["Assignments_ID"] . "' class='text12bold'>Approve</td>";			echo "<td class='approvals'><a href='" . $PHP_SELF . "?action=assetapprovals&deny=" . $query_data["Assignments_ID"] . "' class='text12bold'>Deny</td>";			echo "</tr>";		}		echo "</table>";	} else {		echo "<p><blockquote><font class='text12'>There are no pending transfers to be approved.</blockquote></font>";	}	if (($approve != "") || ($deny != "")) {		if (strlen($err_out) > 10) {			echo "<blockquote><font class='text12'>" . $err_out . "</font></blockquote>\n";		} else {			if (strlen($deny) > 0) echo "<blockquote><font class='text12'>The last request was successfully denied and removed from the database.</font></blockquote>\n";			else echo "<blockquote><font class='text12'>The last request was approved successfully.</font></blockquote>\n";		}	}	echo "<p><center><a href='javascript:history.back()'><img src='images/back.jpg' width=88 height=27 border=0></a></center>\n";}// approves a requested transferfunction asset_admin_transfer_approvals_approve($id, $new) {	$err_out = "";	// get info for transfer id	$sql = "SELECT StartDate, EndDate, AssetId, EmployeeId, Temp FROM Assignments WHERE Id=" . $id;	$result = doSql($sql);	if (($result = doSql($sql)) && (mysql_num_rows($result) && ($query_data = mysql_fetch_array($result)))) {		$startdate = $query_data["StartDate"];		$enddate = $query_data["EndDate"];		$assetid = $query_data["AssetId"];		$employeeid = $query_data["EmployeeId"];		$temp = $query_data["Temp"];	} else {		$err_out = $err_out . "Internal Error: The id supplied within the application was not found.<br>";	}			// for a transfer adjust end dates of others	if ($temp == "0") {		// remove transfers with same start date		$sql = "DELETE FROM Assignments WHERE AssetId=" . $assetid . " AND id <> " . $id . " AND StartDate = " . $startdate . " AND Temp=0 AND Approve=0";		$result = doSql($sql);			// find all startdates greater than my startdate and select the one just after my start date, update my enddate with its startdate		$sql = "SELECT StartDate FROM Assignments WHERE AssetId=" . $assetid . " AND StartDate >= " . $startdate . " AND Temp=0 AND id <> " . $id . " AND Approve=0 ORDER BY StartDate";		if (($result = doSql($sql)) && (mysql_num_rows($result)) && ($query_data = mysql_fetch_array($result))) {			$sql = "UPDATE Assignments SET enddate=" . ($query_data["StartDate"]-1) . " WHERE id=" . $id;			$result = doSql($sql);		}			// find all startdates before my startdate select the last startdate just before my start date, update its enddate with my startdate		$sql = "SELECT id FROM Assignments WHERE AssetId=" . $assetid . " AND StartDate <= " . $startdate . " AND Temp=0 AND id <> " . $id . " AND Approve=0 ORDER BY StartDate DESC";		if (($result = doSql($sql)) && (mysql_num_rows($result)) && ($query_data = mysql_fetch_array($result))) {			$sql = "UPDATE Assignments SET enddate=" . ($startdate-1) . " WHERE id=" . $query_data["id"];			$result = doSql($sql);		}	}	// approve the transfer	$sql = "UPDATE Assignments SET approve=0 WHERE id=" . $id;	$result = doSql($sql);	if (!$result) $err_out = $err_out . "<br>" . mysql_error() . "<br>";	if ($new == true) {		$sql = "INSERT INTO Msgs (employeeid,assetid,date,msgcode,msg) VALUES (" . $employeeid . "," . $assetid . "," . time() . ",1,'transfer request approved')";		$result = doSql($sql);	}	// join adjacent time frames	asset_admin_transfer_squeeze();	return $err_out;}// denies and deletes a requested transferfunction asset_admin_transfer_approvals_deny($id) {	$err_out = "";	$sql = "SELECT AssetId, EmployeeId FROM Assignments WHERE Id=" . $id;	$result = doSql($sql);	if (($result = doSql($sql)) && (mysql_num_rows($result) && ($query_data = mysql_fetch_array($result)))) {		$assetid = $query_data["AssetId"];		$employeeid = $query_data["EmployeeId"];		$sql = "DELETE FROM Assignments WHERE id=" . $id;		$result = doSql($sql);		$sql = "INSERT INTO Msgs (employeeid,assetid,date,msgcode,msg) VALUES (" . $employeeid . "," . $assetid . "," . time() . ",2,'transfer request denied')";		$result = doSql($sql);	} else {		$err_out = $err_out . "<br>" . mysql_error() . "<br>";	}	return $err_out;}// select a new owner for a transfer about to be insertedfunction asset_admin_transfer_choose_owner($key,$curOwnerName,$curOwnerId) {	global $my_emp_id;	global $my_access_level;	global $temp;	global $hrcolor;	global $emp_db;		$PHP_SELF = $_SERVER['PHP_SELF'];	//administrator	if ((strcmp($curOwnerId,$my_emp_id) == 0) || ($my_access_level > 1)) {		echo "<table width=100% bgcolor='#ffeecc'><tr><td><br>";		if ($my_access_level < 2) echo "<center><font class='text12bold'>You are currently the owner of this asset.</font></center>";		echo "<table cellspacing=0 cellpadding=0 border=0><tr><td><form action='" . $PHP_SELF . "' method='get'></td></tr></table>";		// employee drop down		echo "<center>";		echo "<input type='hidden' name='action' value='assettransfer'>";		echo "<input type='hidden' name='key' value='" . $key . "'>";		if ($temp == "1") echo "<font class='text12'>Sign out this asset to </font>";		else echo "<font class='text12'>Transfer this asset from <b>" . $curOwnerName . "</b>  to </font>";		echo "<input type='hidden' name='temp' value='" . $temp . "'>";		echo "<select name='newowner' size='1' class='boxtext13'>";		$sql2 = "SELECT LastName, FirstName, Tel, Organization, Dept, Building, Floor, Workstation, Id AS Employees_ID FROM " . $emp_db . "Employees ORDER BY LastName;";		if (($result2 = doSql($sql2)) && (mysql_num_rows($result2))) {			echo "<option value='0'>General Assets</option>";			echo "<option value='-1'>Surplus</option>";			echo "<option value='-2'>Retired</option>";			echo "<option value=''>----------------------------</option>";			while ($query_data2 = mysql_fetch_array($result2)) {				if (strcmp($curOwnerId,$query_data2["Employees_ID"]) == 0) $selected = " SELECTED";				else $selected = "";				echo "<option value='" . $query_data2["Employees_ID"] . "'" . $selected . ">" . $query_data2["LastName"] . ", " . $query_data2["FirstName"] . "</option>";			}		}		echo "</select>";		echo "</center>";		echo "<p></td></tr></table>";			echo "<hr size=0 color='" . $hrcolor . "'>";		echo "<center>";		echo "<a href='javascript:history.back()'><img src='images/back.jpg' width=88 height=27 border=0></a>";		echo "<input type='image' name='submit' src='images/next.jpg' border=0 width=88 height=27></center></form>";		echo "<br></center>";		echo "<table cellspacing=0 cellpadding=0 border=0><tr><td></form></td></tr></table>";	} else {		// non-administrator users		echo "<table width=100% bgcolor='#ffeecc'><tr><td>";		echo "<br><font class='text12bold'>You are not currently the owner of this asset. Would you like to request a transfer of this item?</font>";		echo "<form action='" . $PHP_SELF . "' method='get'><blockquote>";		echo "<input type='hidden' name='action' value='assettransfer'>";		echo "<input type='hidden' name='key' value='" . $key . "'>";		echo "<input type='radio' name='newowner' value='" . $my_emp_id . "'><font class='text12'>Yes</font><br>";		echo "<input type='radio' name='newowner' value='N'><font class='text12'>No</font><br>";		echo "</blockquote>";		echo "<p></td></tr></table>";			echo "<hr size=0 color='" . $hrcolor . "'>";		echo "<center>";		echo "<a href='javascript:history.back()'><img src='images/back.jpg' width=88 height=27 border=0></a>";		echo "<input type='image' name='submit' src='images/next.jpg' border=0 width=88 height=27></center>";		echo "<table cellspacing=0 cellpadding=0 border=0><tr><td></form></td></tr></table>";		echo "</center>";	}}// select dates for a transfer about to be inserted// sign outs uses startdate and enddate// transfers use startdate but are labelled onscreen as "Transfer Date"function asset_admin_transfer_dates($key) {	global $key, $newowner, $temp;	global $startdate, $enddate;	global $day, $month, $year;	global $hrcolor;		$PHP_SELF = $_SERVER['PHP_SELF'];	echo "<table cellspacing=0 cellpadding=0 border=0><form action='" . $PHP_SELF . "' method=get></td></tr></table>";	echo "<input type='hidden' name='action' value='assettransfer'>";	echo "<input type='hidden' name='key' value='" . $key . "'>";	echo "<input type='hidden' name='newowner' value='" . $newowner . "'>";	echo "<input type='hidden' name='startdate' value='" . $startdate . "'>";	echo "<input type='hidden' name='temp' value='" . $temp . "'>";		echo "<table width=100% bgcolor='#ffeecc' class='assetborder'><tr><td>";	echo "<center>";		if ($temp == "1") {		if (strlen($startdate) < 1) {			$is_enddate = 0;		} else {			$is_enddate = 1;		}	} else {		$is_enddate = 0;			$temp = "0";	}	calendar($day, $month, $year, $is_enddate, $temp, false);

⌨️ 快捷键说明

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