alert_interval); $this->info(count($expiring_assets).' expiring assets'); $asset_data['count'] = count($expiring_assets); $asset_data['email_content'] =''; $now = date("Y-m-d"); foreach ($expiring_assets as $asset) { $expires = $asset->warrantee_expires(); $difference = round(abs(strtotime($expires) - strtotime($now))/86400); if ($difference > 30) { $asset_data['email_content'] .= ''; } else { $asset_data['email_content'] .= ''; } $asset_data['email_content'] .= ''; $asset_data['email_content'] .= $asset->showAssetName().''.e($asset->asset_tag).''; $asset_data['email_content'] .= ''.e($asset->warrantee_expires()).''; $asset_data['email_content'] .= ''.$difference.' days'; $asset_data['email_content'] .= ''.($asset->supplier ? e($asset->supplier->name) : '').''; $asset_data['email_content'] .= ''.($asset->assigneduser ? e($asset->assigneduser->fullName()) : '').''; $asset_data['email_content'] .= ''; } // Expiring licenses $expiring_licenses = License::getExpiringLicenses(Setting::getSettings()->alert_interval); $this->info(count($expiring_licenses).' expiring licenses'); $license_data['count'] = count($expiring_licenses); $license_data['email_content'] = ''; foreach ($expiring_licenses as $license) { $expires = $license->expiration_date; $difference = round(abs(strtotime($expires) - strtotime($now))/86400); if ($difference > 30) { $license_data['email_content'] .= ''; } else { $license_data['email_content'] .= ''; } $license_data['email_content'] .= ''; $license_data['email_content'] .= $license->name.''; $license_data['email_content'] .= ''.$license->expiration_date.''; $license_data['email_content'] .= ''.$difference.' days'; $license_data['email_content'] .= ''; } if ((Setting::getSettings()->alert_email!='') && (Setting::getSettings()->alerts_enabled==1)) { if (count($expiring_assets) > 0) { $this->info('Report sent to '.Setting::getSettings()->alert_email); \Mail::send('emails.expiring-assets-report', $asset_data, function ($m) { $m->to(explode(',', Setting::getSettings()->alert_email), Setting::getSettings()->site_name); $m->replyTo(config('mail.reply_to.address'), config('mail.reply_to.name')); $m->subject('Expiring Assets Report'); }); } if (count($expiring_licenses) > 0) { $this->info('Report sent to '.Setting::getSettings()->alert_email); \Mail::send('emails.expiring-licenses-report', $license_data, function ($m) { $m->to(explode(',', Setting::getSettings()->alert_email), Setting::getSettings()->site_name); $m->replyTo(config('mail.reply_to.address'), config('mail.reply_to.name')); $m->subject('Expiring Licenses Report'); }); } } else { if (Setting::getSettings()->alert_email=='') { echo "Could not send email. No alert email configured in settings. \n"; } elseif (Setting::getSettings()->alerts_enabled!=1) { echo "Alerts are disabled in the settings. No mail will be sent. \n"; } } } }