Skip to content

Commit

Permalink
HP : by default try to use HP Hardware Maintenance Onsite Support
Browse files Browse the repository at this point in the history
  • Loading branch information
tsmr committed Oct 11, 2024
1 parent d4f025a commit 9cadcd2
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 11 deletions.
50 changes: 40 additions & 10 deletions inc/hp.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -109,11 +109,20 @@ public function getBuyDate($contents)
$max_date = false;
if (isset($info[0]['offers'])) {
foreach ($info[0]['offers'] as $d) {
if ($d['serviceObligationLineItemStartDate']) {
$date = new \DateTime($d['serviceObligationLineItemStartDate']);
if ($max_date == false || $date > $max_date) {
//by default try to use HP Hardware Maintenance Onsite Support
if ($d['serviceObligationTypeCode'] && $d['serviceObligationTypeCode'] == "C") {
if ($d['serviceObligationLineItemStartDate']) {
$date = new \DateTime($d['serviceObligationLineItemStartDate']);
$max_date = $date;
}
} else {
// when several dates are available, will take the last one
if ($d['serviceObligationLineItemStartDate']) {
$date = new \DateTime($d['serviceObligationLineItemStartDate']);
if ($max_date == false || $date > $max_date) {
$max_date = $date;
}
}
}
}

Expand All @@ -138,16 +147,26 @@ public function getExpirationDate($contents)
{
$info = json_decode($contents, true);

// when several dates are available, will take the last one
$max_date = false;
if (isset($info[0]['offers'])) {
foreach ($info[0]['offers'] as $k => $d) {
if ($d['serviceObligationLineItemEndDate']) {
$date = new \DateTime($d['serviceObligationLineItemEndDate']);
if ($max_date == false || $date > $max_date) {

//by default try to use HP Hardware Maintenance Onsite Support
if ($d['serviceObligationTypeCode'] && $d['serviceObligationTypeCode'] == "C") {
if ($d['serviceObligationLineItemEndDate']) {
$date = new \DateTime($d['serviceObligationLineItemEndDate']);
$max_date = $date;
}
} else {
// when several dates are available, will take the last one
if ($d['serviceObligationLineItemEndDate']) {
$date = new \DateTime($d['serviceObligationLineItemEndDate']);
if ($max_date == false || $date > $max_date) {
$max_date = $date;
}
}
}

}

if ($max_date) {
Expand All @@ -168,12 +187,23 @@ public function getWarrantyInfo($contents)
$i = false;
if (isset($info[0]['offers'])) {
foreach ($info[0]['offers'] as $k => $d) {
if ($d['serviceObligationLineItemEndDate']) {
$date = new \DateTime($d['serviceObligationLineItemEndDate']);
if ($max_date == false || $date > $max_date) {

//by default try to use HP Hardware Maintenance Onsite Support
if ($d['serviceObligationTypeCode'] && $d['serviceObligationTypeCode'] == "C") {
if ($d['serviceObligationLineItemEndDate']) {
$date = new \DateTime($d['serviceObligationLineItemEndDate']);
$max_date = $date;
$i = $k;
}
} else {
// when several dates are available, will take the last one
if ($d['serviceObligationLineItemEndDate']) {
$date = new \DateTime($d['serviceObligationLineItemEndDate']);
if ($max_date == false || $date > $max_date) {
$max_date = $date;
$i = $k;
}
}
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion setup.php
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ function plugin_version_manufacturersimports()
'oldname' => 'suppliertag',
'version' => PLUGIN_MANUFACTURERSIMPORTS_VERSION,
'license' => 'GPLv2+',
'author' => "<a href='http://infotel.com/services/expertise-technique/glpi/'>Infotel</a>",
'author' => "<a href='https://blogglpi.infotel.com'>Infotel</a>",
'homepage' => 'https://github.com/InfotelGLPI/manufacturersimports/',
'requirements' => [
'glpi' => [
Expand Down

0 comments on commit 9cadcd2

Please sign in to comment.