0){ while($row = mssql_fetch_assoc($result)){ $arrayOfCustomerInformation[] = $row; } return $arrayOfCustomerInformation; } else { return 0; } } ?> Assets per Customer List of Assets per customer"; //Part 1: Obtain list of Active Customers. $query = "select top(100)* from wh_account where account_type_id = '1' AND is_active = '1' "; $myCustomerArray = queryToArray($query); //Part 2: Per Customer, enumerate All assets //generic query to pull top 100 values from the Installed Product table // where is_active = 1 (Currently Active) // in this query, we are JOINING with the account table to provide a // meaningful link between assets and accounts. We are using a LEFT // Join to show any assets without a 'Vendor Name' // (to show only assets with vendor names, change LEFT to INNER for($i = 0; $i"; echo "P:".$myCustomerArray[$i]["phone_number"] ."\n
"; echo "W:".$myCustomerArray[$i]["web_url"] . "\n
"; //This query shows all assets assigned to the '0' account. // (your internal Autotask account) $query = "select top(100) wh_installed_product.reference_title, wh_installed_product.serial_number, wh_installed_product.installed_product_id, wh_installed_product.warranty_expiration_date, wh_installed_product.notes, wh_installed_product.vendor_name, wh_installed_product.account_id, wh_account.account_name, wh_account.phone_number, wh_account.web_url from wh_installed_product LEFT JOIN wh_account ON wh_installed_product.vendor_name = wh_account.account_name where wh_installed_product.is_active = '1' AND wh_installed_product.account_id = '". $myCustomerArray[$i]["account_id"]."' order by wh_installed_product.warranty_expiration_date "; //create an array of values that are returned by the query $myAssetArray = queryToArray($query); //If there are results from the query, print them out to the //screen. echo "
"; if($myAssetArray != 0){ echo "".count($myAssetArray)." Active Asset(s)\n
"; echo "\n"; echo "". "". "". "". "". "". "". "". ""; for($k=0;$k ". "". "". "". "". "". "". ""; //NOTE: the values listed in the 'CAST' parends below must match the names //you used for the UDF in Autotask. Replace spaces with '_' //Also- list types must append '_visible_value' to the end of the variable. $query = "select CAST(circuit_id as TEXT) as circuit_id, CAST(circuit_type_visible_value as TEXT) as circuit_type, CAST(download_speed as TEXT) as download_speed, CAST(upload_speed as TEXT) as upload_speed, CAST(public_ip_address as TEXT) as public_ip_address, CAST(public_subnet_mask as TEXT) as public_subnet_mask, CAST(public_default_gateway as TEXT) as public_default_gateway, CAST(useable_public_range as TEXT) as useable_public_range from wh_installed_product_udf where installed_product_id = '". $myAssetArray[$k]["installed_product_id"]."' "; $myUDFArray = queryToArray($query); echo ""; echo ""; } echo "
VendorVendor PhoneReference TitleSerial NumberWarranty Exp DateNotesProduct IDProduct UDF
". $myAssetArray[$k]["account_name"]."". $myAssetArray[$k]["phone_number"] ."". $myAssetArray[$k]["reference_title"]."". $myAssetArray[$k]["serial_number"] ."". $myAssetArray[$k]["warranty_expiration_date"]. "". $myAssetArray[$k]["notes"] ."". $myAssetArray[$k]["installed_product_id"] ."
\n";
				print_r($myUDFArray);
			echo "
\n
\n"; } else{ echo "There were 0 results returned. There are no assets associated with this account.\n
"; } echo "
"; //to quickly see all values returned, use the print_r function. //(commented out.) // echo "
\n";
	//		print_r($myAssetArray);
	//	echo "
\n"; } ?>