A free open source IT asset/license management system
Add settings for alert interval threshold and inventory threshold
snipe15eb6df1dbeb
diff --git a/app/Console/Commands/SendExpirationAlerts.php b/app/Console/Commands/SendExpirationAlerts.phpindex d40470ae59..b5c1170bdb 100644--- a/app/Console/Commands/SendExpirationAlerts.php+++ b/app/Console/Commands/SendExpirationAlerts.php@@ -43,7 +43,7 @@ class SendExpirationAlerts extends Command {{// Expiring Assets- $expiring_assets = Asset::getExpiringWarrantee(60);+ $expiring_assets = Asset::getExpiringWarrantee(Setting::getSettings()->alert_interval);$this->info(count($expiring_assets).' expiring assets');$asset_data['count'] = count($expiring_assets);@@ -71,7 +71,7 @@ class SendExpirationAlerts extends Command {}// Expiring licenses- $expiring_licenses = License::getExpiringLicenses(60);+ $expiring_licenses = License::getExpiringLicenses(Setting::getSettings()->alert_interval);$this->info(count($expiring_licenses).' expiring licenses');diff --git a/app/Helpers/Helper.php b/app/Helpers/Helper.phpindex b5b0d11ea1..ecad35935d 100644--- a/app/Helpers/Helper.php+++ b/app/Helpers/Helper.php@@ -213,7 +213,7 @@ class Helperforeach ($consumables as $consumable) {$avail = $consumable->numRemaining();- if ($avail < ($consumable->min_amt) + 3) {+ if ($avail < ($consumable->min_amt) + \App\Models\Setting::getSettings()->alert_threshold) {$percent = number_format((($consumable->numRemaining() / $consumable->qty) * 100), 0);$items_array[$all_count]['id'] = $consumable->id;$items_array[$all_count]['name'] = $consumable->name;@@ -229,7 +229,7 @@ class Helperforeach ($accessories as $accessory) {$avail = $accessory->numRemaining();- if ($avail < ($accessory->min_amt) + 3) {+ if ($avail < ($accessory->min_amt) + \App\Models\Setting::getSettings()->alert_threshold) {$percent = number_format((($accessory->numRemaining() / $accessory->qty) * 100), 0);$items_array[$all_count]['id'] = $accessory->id;$items_array[$all_count]['name'] = $accessory->name;@@ -244,7 +244,7 @@ class Helperforeach ($components as $component) {$avail = $component->numRemaining();- if ($avail < ($component->min_amt) + 3) {+ if ($avail < ($component->min_amt) + \App\Models\Setting::getSettings()->alert_threshold) {$percent = number_format((($component->numRemaining() / $component->total_qty) * 100), 0);$items_array[$all_count]['id'] = $component->id;$items_array[$all_count]['name'] = $component->name;diff --git a/app/Http/Controllers/SettingsController.php b/app/Http/Controllers/SettingsController.phpindex eae95eb533..29c0d9be46 100755--- a/app/Http/Controllers/SettingsController.php+++ b/app/Http/Controllers/SettingsController.php@@ -338,6 +338,9 @@ class SettingsController extends Controller$setting->qr_text = e(Input::get('qr_text'));$setting->auto_increment_prefix = e(Input::get('auto_increment_prefix'));$setting->auto_increment_assets = e(Input::get('auto_increment_assets', '0'));+ $setting->alert_interval = e(Input::get('alert_interval'));+ $setting->alert_threshold = e(Input::get('alert_threshold'));+$setting->labels_per_page = e(Input::get('labels_per_page'));$setting->labels_width = e(Input::get('labels_width'));diff --git a/database/migrations/2016_05_19_191146_add_alter_interval.php b/database/migrations/2016_05_19_191146_add_alter_interval.phpnew file mode 100644index 0000000000..4f218b1cee--- /dev/null+++ b/database/migrations/2016_05_19_191146_add_alter_interval.php@@ -0,0 +1,33 @@+<?php++use Illuminate\Database\Schema\Blueprint;+use Illuminate\Database\Migrations\Migration;++class AddAlterInterval extends Migration+{+ /**+ * Run the migrations.+ *+ * @return void+ */+ public function up()+ {+ Schema::table('settings', function (Blueprint $table) {+ $table->integer('alert_interval')->nullable()->default('30');+ });+ }++ /**+ * Reverse the migrations.+ *+ * @return void+ */+ public function down()+ {+ Schema::table('settings', function ($table) {+ $table->dropColumn(+ 'alert_interval'+ );+ });+ }+}diff --git a/database/migrations/2016_05_19_192226_add_inventory_threshold.php b/database/migrations/2016_05_19_192226_add_inventory_threshold.phpnew file mode 100644index 0000000000..35f4e9ddfe--- /dev/null+++ b/database/migrations/2016_05_19_192226_add_inventory_threshold.php@@ -0,0 +1,33 @@+<?php++use Illuminate\Database\Schema\Blueprint;+use Illuminate\Database\Migrations\Migration;++class AddInventoryThreshold extends Migration+{+ /**+ * Run the migrations.+ *+ * @return void+ */+ public function up()+ {+ Schema::table('settings', function (Blueprint $table) {+ $table->integer('alert_threshold')->nullable()->default('5');+ });+ }++ /**+ * Reverse the migrations.+ *+ * @return void+ */+ public function down()+ {+ Schema::table('settings', function ($table) {+ $table->dropColumn(+ 'alert_threshold'+ );+ });+ }+}diff --git a/resources/lang/en/admin/settings/general.php b/resources/lang/en/admin/settings/general.phpindex b190db7773..41883acd5f 100644--- a/resources/lang/en/admin/settings/general.php+++ b/resources/lang/en/admin/settings/general.php@@ -2,7 +2,9 @@return array('alert_email' => 'Send alerts to',- 'alerts_enabled' => 'Alerts enabled',+ 'alerts_enabled' => 'Alerts Enabled',+ 'alert_interval' => 'Expiring Alerts Threshold (in days)',+ 'alert_inv_threshold' => 'Inventory Alert Threshold','asset_ids' => 'Asset IDs','auto_increment_assets' => 'Generate auto-incrementing asset IDs','auto_increment_prefix' => 'Prefix (optional)',diff --git a/resources/views/settings/edit.blade.php b/resources/views/settings/edit.blade.phpindex 7b510d7f52..ee481076f5 100755--- a/resources/views/settings/edit.blade.php+++ b/resources/views/settings/edit.blade.php@@ -153,6 +153,31 @@</div></div>+ <!-- Alert interval -->+ <div class="form-group {{ $errors->has('alert_interval') ? 'error' : '' }}">+ <div class="col-md-3">+ {{ Form::label('alert_interval', trans('admin/settings/general.alert_interval')) }}+ </div>+ <div class="col-md-9">+ {{ Form::text('alert_interval', Input::old('alert_interval', $setting->alert_interval), array('class' => 'form-control','placeholder' => '30', 'maxlength'=>'3', 'style'=>'width: 60px;')) }}+ {!! $errors->first('alert_interval', '<span class="alert-msg">:message</span>') !!}+ </div>+ </div>++ <!-- Alert threshold -->+ <div class="form-group {{ $errors->has('alert_threshold') ? 'error' : '' }}">+ <div class="col-md-3">+ {{ Form::label('alert_threshold', trans('admin/settings/general.alert_inv_threshold')) }}+ </div>+ <div class="col-md-9">+ {{ Form::text('alert_threshold', Input::old('alert_threshold', $setting->alert_threshold), array('class' => 'form-control','placeholder' => '5', 'maxlength'=>'3', 'style'=>'width: 60px;')) }}+ {!! $errors->first('alert_threshold', '<span class="alert-msg">:message</span>') !!}+ </div>+ </div>++++<!-- Header color --><div class="form-group {{ $errors->has('header_color') ? 'error' : '' }}"><div class="col-md-3">