mirror of
https://github.com/snipe/snipe-it.git
synced 2024-12-25 05:34:06 -08:00
working on getting notifications
This commit is contained in:
parent
38d5691b88
commit
011c09a3dd
|
@ -2,6 +2,8 @@
|
|||
|
||||
namespace App\Helpers;
|
||||
use App\Models\Accessory;
|
||||
use App\Models\Asset;
|
||||
use App\Models\AssetModel;
|
||||
use App\Models\Component;
|
||||
use App\Models\Consumable;
|
||||
use App\Models\CustomField;
|
||||
|
@ -643,6 +645,7 @@ class Helper
|
|||
$consumables = Consumable::withCount('consumableAssignments as consumable_assignments_count')->whereNotNull('min_amt')->get();
|
||||
$accessories = Accessory::withCount('users as users_count')->whereNotNull('min_amt')->get();
|
||||
$components = Component::whereNotNull('min_amt')->get();
|
||||
$asset_models = AssetModel::where('min_amt', '>', 0)->get();
|
||||
|
||||
$avail_consumables = 0;
|
||||
$items_array = [];
|
||||
|
@ -704,6 +707,29 @@ class Helper
|
|||
$all_count++;
|
||||
}
|
||||
}
|
||||
// dd($asset_models);
|
||||
foreach ($asset_models as $asset_model){
|
||||
|
||||
$used= new Asset();
|
||||
dd($asset_model->id);
|
||||
$count =$used->where('model_id', '==', $asset_model->id)->count();
|
||||
$avail = Asset::withCount('model as model_count');
|
||||
if ($avail < ($asset_model->min_amt) + \App\Models\Setting::getSettings()->alert_threshold) {
|
||||
if ($asset_model->qty > 0) {
|
||||
$percent = number_format((($avail / $asset_model->qty) * 100), 0);
|
||||
} else {
|
||||
$percent = 100;
|
||||
}
|
||||
|
||||
$items_array[$all_count]['id'] = $accessory->id;
|
||||
$items_array[$all_count]['name'] = $accessory->name;
|
||||
$items_array[$all_count]['type'] = 'accessories';
|
||||
$items_array[$all_count]['percent'] = $percent;
|
||||
$items_array[$all_count]['remaining'] = $avail;
|
||||
$items_array[$all_count]['min_amt'] = $accessory->min_amt;
|
||||
$all_count++;
|
||||
}
|
||||
}
|
||||
|
||||
return $items_array;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue