Skip to content

A free open source IT asset/license management system

Adds default values if the expiring alerts threshold is null

Ivan Nieto Vivanco42d86bf57bff
diff --git a/app/Models/Asset.php b/app/Models/Asset.php
index bff0134a05..a1e94b4510 100644
--- a/app/Models/Asset.php
+++ b/app/Models/Asset.php
@@ -665,13 +665,15 @@ class Asset extends Depreciable
*/
public static function getExpiringWarrantee($days = 30)
{
+ $days = (is_null($days)) ? 30 : $days;
+
return Asset::where('archived', '=', '0')
->whereNotNull('warranty_months')
->whereNotNull('purchase_date')
->whereNull('deleted_at')
->whereRaw(\DB::raw('DATE_ADD(`purchase_date`,INTERVAL `warranty_months` MONTH) <= DATE(NOW() + INTERVAL '
. $days
- . ' DAY) AND DATE_ADD(`purchase_date`,INTERVAL `warranty_months` MONTH) > NOW()'))
+ . ' DAY) AND DATE_ADD(`purchase_date`, INTERVAL `warranty_months` MONTH) > NOW()'))
->orderBy('purchase_date', 'ASC')
->get();
}
diff --git a/app/Models/License.php b/app/Models/License.php
index 8f0fbdfaab..9bd7627f94 100755
--- a/app/Models/License.php
+++ b/app/Models/License.php
@@ -627,7 +627,8 @@ class License extends Depreciable
*/
public static function getExpiringLicenses($days = 60)
{
-
+ $days = (is_null($days)) ? 30 : $days;
+
return License::whereNotNull('expiration_date')
->whereNull('deleted_at')
->whereRaw(DB::raw('DATE_SUB(`expiration_date`,INTERVAL '.$days.' DAY) <= DATE(NOW()) '))