Commit eae940d7 authored by Arnaud ABELARD's avatar Arnaud ABELARD
Browse files

commit initial

parents
<?
class dellAsset {
private $_url = "http://xserv.dell.com/services/assetservice.asmx?WSDL";
private $_app = "AssetInformationClass";
private $_guid = "11111111-1111-1111-1111-111111111111";
private $_tag = "";
private $_soapClient;
private $_assetInformation;
public $ServiceTag;
public $Build;
public $SystemID;
public $Region;
public $SystemType;
public $SystemModel;
public $SystemShipDate;
public $warranties;
public $errormsg;
function __construct($options=array()) {
if (count($options)>0) {
if (array_key_exists("tag",$options)) $this->_tag=$options["tag"];
else {
$this->errormsg = "You must at least provide a service tag";
return null;
}
if (array_key_exists("url",$options)){ $this->_url=$options["url"]; }
if (array_key_exists("app",$options)){ $this->_app=$options["app"]; }
if (array_key_exists("guid",$options)){ $this->_app=$options["guid"]; } //todo tester la valider du guid: XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX
} else {
$this->errormsg = "You must at least provide a service tag";
return null;
}
$AssetInformation["guid"]=$this->_guid;
$AssetInformation["applicationName"]=$this->_app;
$AssetInformation["serviceTags"]= $this->_tag;
$this->_soapClient = new SoapClient("http://xserv.dell.com/services/assetservice.asmx?WSDL",array('proxy_host' => "proxy-serveur.univ-nantes.prive",'proxy_port' => 3128));
$this->_assetInformation = $this->_soapClient->GetAssetInformation($AssetInformation);
$arr=(array)$this->_assetInformation->GetAssetInformationResult;
if(empty($arr)) {
$this->errormsg = "No assetInformation for this tag";
return null;
}
$this->ServiceTag = $this->_getServiceTag();
$this->Build=$this->_getBuild();
$this->SystemID=$this->_getSystemID();
$this->Region=$this->_getRegion();
$this->SystemType=$this->_getSystemType();
$this->SystemModel=$this->_getSystemModel();
$this->SystemShipDate=$this->_getSystemShipDate();
$this->Warranties=$this->getAssetEntitlementsObject();
}
#---------------------------------------------------
# recuperation des objets
#---------------------------------------------------
# retourne l'objet complet
public function getAssetInformationObject() {
return (array)$this->_assetInformation;
}
# retourne juste l'objet AssetHeaderData (infos sur le systeme)
public function getAssetHeaderDataObject() {
return $this->_assetInformation->GetAssetInformationResult->Asset->AssetHeaderData;
}
# retourne juste l'objet Entitlements (infos sur les diff. garanties)
public function getAssetEntitlementsObject() {
return $this->_assetInformation->GetAssetInformationResult->Asset->Entitlements->EntitlementData;
}
#---------------------------------------------------
# recuperation des objets sous forme d'array
#---------------------------------------------------
# retourne un array des infos du systeme
public function getSystemInfoArray() {
return (array)$this->_assetInformation->GetAssetInformationResult->Asset->AssetHeaderData;
}
# retourne un array des differentes garanties
public function getAssetEntitlementsArray() {
$entitlements = array();
foreach($this->_assetInformation->GetAssetInformationResult->Asset->Entitlements->EntitlementData as $ent) {
$entitlements[]=(array) $ent;
}
return $entitlements;
}
# fonctions privees
private function _getWarranties() {
$this->getAssEntitlementsArray();
}
private function _getServiceTag() {
return $this->_assetInformation->GetAssetInformationResult->Asset->AssetHeaderData->ServiceTag;
}
private function _getBuild() {
return $this->_assetInformation->GetAssetInformationResult->Asset->AssetHeaderData->Build;
}
private function _getSystemID() {
return $this->_assetInformation->GetAssetInformationResult->Asset->AssetHeaderData->SystemID;
}
private function _getRegion() {
return $this->_assetInformation->GetAssetInformationResult->Asset->AssetHeaderData->Region;
}
private function _getSystemType() {
return $this->_assetInformation->GetAssetInformationResult->Asset->AssetHeaderData->SystemType;
}
private function _getSystemModel() {
return $this->_assetInformation->GetAssetInformationResult->Asset->AssetHeaderData->SystemModel;
}
private function _getSystemShipDate() {
return $this->_assetInformation->GetAssetInformationResult->Asset->AssetHeaderData->SystemShipDate;
}
}
<?
require("dellAsset.class.php");
$tag = $_GET['tag'];
if(!$tag) $tag="B41284J";
$matos = new dellAsset(array("tag" => $tag));
if(!$matos->ServiceTag) die($matos->errormsg);
print "Service tag: ".$matos->ServiceTag."<br>";
print "Modele: ".$matos->SystemModel."<Br>";
print "Type: ".$matos->SystemType."<br>";
print "Date de livraison: ".$matos->SystemShipDate."<br><br>";
print "Garanties:<br>";
foreach($matos->Warranties as $warranty) {
print "Nom: ".$warranty->ServiceLevelDescription."<br>";
#print "<pre>".print_r($warranty,1)."</pre>";
print "Date de debut: ".$warranty->StartDate."<br>";
print "Date de fin: ".$warranty->EndDate."<br>";
print "Status: ".$warranty->EntitlementType."<br>";
print "<br>";
}
?>
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment