mirror of
https://github.com/snipe/snipe-it.git
synced 2024-11-09 23:24:06 -08:00
Add settings for alert interval threshold and inventory threshold
This commit is contained in:
parent
29e54830e1
commit
15eb6df1db
|
@ -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');
|
||||
|
||||
|
||||
|
|
|
@ -213,7 +213,7 @@ class Helper
|
|||
|
||||
foreach ($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 Helper
|
|||
|
||||
foreach ($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 Helper
|
|||
|
||||
foreach ($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;
|
||||
|
|
|
@ -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'));
|
||||
|
|
33
database/migrations/2016_05_19_191146_add_alter_interval.php
Normal file
33
database/migrations/2016_05_19_191146_add_alter_interval.php
Normal file
|
@ -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'
|
||||
);
|
||||
});
|
||||
}
|
||||
}
|
|
@ -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'
|
||||
);
|
||||
});
|
||||
}
|
||||
}
|
|
@ -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)',
|
||||
|
|
|
@ -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">
|
||||
|
|
Loading…
Reference in a new issue