asset_admin_transfer.php

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

PHP
659
字号
	echo "</center>";	echo "</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></form></td></tr></table>";}// decide what to do with transfersfunction asset_admin_transfer_licenses($key,$curOwnerName,$curOwnerId) {	global $key, $newowner, $temp;	global $startdate, $enddate;	global $day, $month, $year;	global $hrcolor;	global $newowner;	global $my_emp_id;	$PHP_SELF = $_SERVER['PHP_SELF'];	$sql = "SELECT LicenseOwners.Id AS LicenseOwners_ID, Licenses.Manufacturer, Licenses.Product FROM LicenseOwners LEFT JOIN Licenses ON LicenseOwners.LicenseId = Licenses.Product WHERE AssetId=" . $key . " GROUP BY LicenseOwners.Id";	if (($result = doSql($sql)) && (mysql_num_rows($result))) {		$transfer_header_text = "Make Licenses Changes";		asset_menu_header(true,$section_text,$transfer_header_text,$key);		asset_tabs($key);		asset_print_info($key);		echo "<table width=100% bgcolor='#ffeecc'><tr><td>";		echo "<blockquote>";		echo "<form action='" . $PHP_SELF . "' method='get'>";		echo "<font class='text12'>";		echo "<p><br>For all checked licenses, I would like to ";		echo "<select name='license_action' class='text12' size='1'>";		echo "<option value='0'>return the licenses to surplus</option>";		if ($my_emp_id == $curOwnerId) $my_the = "my";		else $my_the = "this employee's";				$sql2 = "SELECT Assets.AssetTag, Assets.AssetType, Assets.AssetSupplier, Assets.AssetModel, Assets.AssetSerial, Assets.AssetPrice, Assets.os, Assets.Id AS Assets_ID, Assignments.EmployeeId AS Employees_ID, Assignments.StartDate, Assignments.EndDate, Assignments.Completed, Assignments.Id As Assignments_ID FROM Assignments LEFT JOIN Assets ON Assets.Id = Assignments.AssetId WHERE Assignments.EmployeeId=" . $curOwnerId . " AND Assignments.Temp=0 AND Assignments.Approve=0 AND Assignments.Temp=0 AND (Assignments.EndDate >= " . time() . " OR Assignments.EndDate = 0) AND Assignments.Completed=0 AND Assets.Id <> " . $key . " ORDER BY Assignments.StartDate;";		if (($result2 = doSql($sql2)) && (mysql_num_rows($result2))) {			while ($query_data2 = mysql_fetch_array($result2)) {				echo "<option value='" . $query_data2["Assets_ID"] . "'>Move to " . $my_the . " " . $query_data2["AssetType"] . " (" . $query_data2["AssetSupplier"] . " " . $query_data2["AssetModel"] . ")</option>";			}		}		echo "</select>";				echo "</font>";		echo "<font class='text12'><br><i>All unchecked licenses will remain assigned to this asset after the transfer.</i></font>";		echo "<input type='hidden' name='action' value='assettransfer'>";		echo "<input type='hidden' name='key' value='" . $key . "'>";		echo "<input type='hidden' name='startdate' value='" . $startdate . "'>";		echo "<input type='hidden' name='enddate' value='" . $enddate . "'>";		echo "<input type='hidden' name='temp' value='" . $temp . "'>";		echo "<input type='hidden' name='newowner' value='" . $newowner . "'>";		$license_cnt = 1;		echo "<p><table width=100%>";		while ($query_data = mysql_fetch_array($result)) {			if (($license_cnt % 2) == 1) echo "<tr>";			echo "<td class='text12bold'>";			echo "<input type='checkbox' name='licenses[]' value='" . $query_data["LicenseOwners_ID"] . "'><font class='text12'>" . $query_data["Manufacturer"] . " " . $query_data["Product"] . "</font><br>";			echo "</td>";			if (($license_cnt % 2) == 0) echo "</tr>";			$license_cnt++;		}		echo "</table>";		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>";		return true;	} else {		return false;	}}function asset_admin_transfer_complete($key,$transfer_header_text) {	global $startdate,$enddate, $temp;	global $my_access_level;	global $newowner;	global $license_action;	global $licenses;		$err_out = "";	// set the temp flag	if ($enddate == "0") $temp = 0;					else $temp = 1;		// check in case this page is accidentally reloaded	if ($my_access_level > 1) $approve_val = "0";	else $approve_val = "1";		// update the license information	if ($license_action == "0") {		for ($i=0;$i<count($licenses);$i++) {			doSql("DELETE FROM LicenseOwners WHERE id=" . $licenses[$i]);		}	} else {		for ($i=0;$i<count($licenses);$i++) {			doSql("UPDATE LicenseOwners SET AssetId=" . $license_action ." WHERE id=" . $licenses[$i]);		}	}		$sql = "SELECT * FROM Assignments WHERE employeeid=" . $newowner . " AND assetid=" . $key . " AND startdate=" . $startdate . " AND enddate=" . $enddate . " AND temp=" . $temp . " AND Approve=" . $approve_val;	$result = doSql($sql);	if (($result) && (mysql_num_rows($result))) {		// if the link exists, do nothing	} else {		// if not, create a new link, temporarily unapproved		$sql = "INSERT INTO Assignments (employeeid, assetid, startdate, enddate, approve, temp, completed) VALUES (" . $newowner . "," . $key . "," . $startdate . "," . $enddate . ",1," . $temp . ",0);";		$result = doSql($sql);		if (!($result)) $err_out = $err_out . mysql_error() . "<br>";		// if you are logged in as an Admin OR this is a sign out, automatically approve the sign out.		if ((strlen($err_out) < 1) && (($my_access_level > 1) || (($my_access_level < 2) && ($enddate != 0)))) {			$sql = "SELECT last_insert_id() as last FROM Assignments;";			if (($result = doSql($sql)) && ($query_data = mysql_fetch_array($result))) $err_out = asset_admin_transfer_approvals_approve($query_data[0],false);			else $err_out = "INTERNAL ERROR: No id inserted.";		}	}					// verify if any errors occurred	if (strlen($err_out) > 0) {		// errors occurred		asset_menu_header(true,$transfer_header_text,"<font class=text18bold color='#ff0033'>" . $transfer_header_text . " Failed</font>",$key);		asset_tabs($key);		asset_print_info($key);		echo "<table width=100% bgcolor='#ffeecc' class='assetborder'><tr><td class='text12'>";		echo "<blockquote>";		echo "<font class='text12'><blockquote>The request did not complete successfully.<p>The following errors occurred:<br>" . $err_out . "</blockquote></font>";		echo "</blockquote></td></tr></table>";	} else {		// everything is ok, print a confirmation message		if ($enddate == 0) $enddate_full = "";		else $enddate_full = " to " . date("M-d-Y", $enddate);		asset_menu_header(true,$transfer_header_text,"<font class=text18bold>" . $transfer_header_text . " Completed Successfully</font>",$key);		asset_tabs($key);		asset_print_info($key);		echo "<table width=100% bgcolor='#ffeecc' class='assetborder'><tr><td class='text12'>";		echo "<blockquote>";		echo "<br>The request for this asset has been entered for dates: " . date("M-d-Y", $startdate) . "" . $enddate_full;		if ($temp == "1") echo "<p><font class='text12bold' color='#ff0033'>Please ensure to 'sign in' this asset on the system before or on the due date or it will be marked as overdue.</font>";		if (($my_access_level < 2) && ($temp != "1")) echo "<p><font class='text12bold'>This request must still be approved by an administrator.</font>";		echo "</blockquote></td></tr></table>";	}}// central function that decides what to do when requesting the insertion of a new transferfunction asset_admin_transfer($key) {	global $my_emp_id;	global $my_access_level;	global $startdate;	global $newowner;	global $enddate;	global $temp;	global $licenses;	global $license_action;		global $emp_db;		$PHP_SELF = $_SERVER['PHP_SELF'];	if ($temp == 1) $transfer_header_text = "Sign Out";	else $transfer_header_text = "Transfer";		// N is set when regular users answer to NO to whether to acquire an asset	if ($newowner != "N") {		$sql = "SELECT " . $emp_db . "Employees.LastName, " . $emp_db . "Employees.FirstName, " . $emp_db . "Employees.Tel, " . $emp_db . "Employees.Organization, " . $emp_db . "Employees.Dept, " . $emp_db . "Employees.Building, " . $emp_db . "Employees.Floor, " . $emp_db . "Employees.Workstation, Assignments.StartDate, Assignments.EndDate, Assignments.EmployeeID AS Employees_ID FROM Assignments LEFT JOIN " . $emp_db . "Employees ON Assignments.EmployeeID = " . $emp_db . "Employees.Id WHERE Assignments.AssetId=" . $key . " AND Assignments.Temp=0 AND Assignments.Approve=0 AND (Assignments.EndDate >= " . time() . " OR Assignments.EndDate = 0) ORDER BY Assignments.StartDate;";		if (($result = doSql($sql)) && ($query_data = mysql_fetch_array($result))) {			$curOwnerId = $query_data["Employees_ID"];			if ($curOwnerId == "0") $curOwnerName = "General Assets";			elseif ($curOwnerId == "-1")  $curOwnerName = "Surplus";			elseif ($curOwnerId == "-2")  $curOwnerName = "Retired";			else $curOwnerName = $query_data["LastName"] . ", " . $query_data["FirstName"];		} else {			$curOwnerId = 0;			$curOwnerName = "Unknown";		}			if (strlen($newowner) < 1) {			// if no owner is entered, prompt for an owner			asset_menu_header(true,"",$transfer_header_text,$key);			asset_tabs($key);			asset_print_info($key);			asset_admin_transfer_choose_owner($key,$curOwnerName,$curOwnerId);		} else {			if ((strlen($startdate) < 1) || (strlen($enddate) < 1)) {				// if there is no startdate or enddate, prompt for either				$section_text = $transfer_header_text;				if ($temp == "1") {					if (strlen($startdate) < 1) $transfer_header_text = "Select A Sign Out Date";					else $transfer_header_text = "Select A Return Due Date";				} else {					$transfer_header_text = "Select A Transfer Date";				}				asset_menu_header(true,$section_text,$transfer_header_text,$key);				asset_tabs($key);				asset_print_info($key);				asset_admin_transfer_dates($key);			} else {				if ((strlen($license_action) < 1) && ($temp == 0)) {					$is_licenses = asset_admin_transfer_licenses($key,$curOwnerName,$curOwnerId);				} else {					$is_licenses = false;				}				if ($is_licenses == false) {					asset_admin_transfer_complete($key,$transfer_header_text);				}			}		}	} else {		// User chose not to make changes, print a confirmation message		asset_menu_header(true,"Transfer","No Changes Have Been Made",$key);		echo "<font class='text12'><blockquote>You may continue working.</blockquote></font>";	}	}?>

⌨️ 快捷键说明

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