Skip to content

Commit 2229dd8

Browse files
committed
Build JS
2 parents c796cd4 + b6778bb commit 2229dd8

File tree

154 files changed

+3654
-2670
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

154 files changed

+3654
-2670
lines changed

.env.example

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ REPORT_TIME_LIMIT=12000
197197
API_THROTTLE_PER_MINUTE=120
198198
CSV_ESCAPE_FORMULAS=true
199199
LIVEWIRE_URL_PREFIX=null
200-
200+
MAX_UNPAGINATED=5000
201201

202202
# --------------------------------------------
203203
# OPTIONAL: SAML SETTINGS

app/Console/Commands/SendExpectedCheckinAlerts.php

Lines changed: 39 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
use App\Notifications\ExpectedCheckinNotification;
1010
use Carbon\Carbon;
1111
use Illuminate\Console\Command;
12+
use Illuminate\Support\Facades\Notification;
13+
use App\Helpers\Helper;
1214

1315
class SendExpectedCheckinAlerts extends Command
1416
{
@@ -17,7 +19,7 @@ class SendExpectedCheckinAlerts extends Command
1719
*
1820
* @var string
1921
*/
20-
protected $name = 'snipeit:expected-checkin';
22+
protected $signature = 'snipeit:expected-checkin {--with-output : Display the results in a table in your console in addition to sending the email}';
2123

2224
/**
2325
* The console command description.
@@ -42,19 +44,47 @@ public function __construct()
4244
public function handle()
4345
{
4446
$settings = Setting::getSettings();
45-
$interval = $settings->audit_warning_days ?? 0;
47+
$interval = $settings->due_checkin_days ?? 0;
4648
$today = Carbon::now();
4749
$interval_date = $today->copy()->addDays($interval);
48-
50+
$count = 0;
51+
52+
if (!$this->option('with-output')) {
53+
$this->info('Run this command with the --with-output option to see the full list in the console.');
54+
}
55+
4956
$assets = Asset::whereNull('deleted_at')->DueOrOverdueForCheckin($settings)->orderBy('assets.expected_checkin', 'desc')->get();
5057

51-
$this->info($assets->count().' assets must be checked in on or before '.$interval_date.' is deadline');
58+
$this->info($assets->count().' assets must be checked on or before '.Helper::getFormattedDateObject($interval_date, 'date', false));
5259

5360

5461
foreach ($assets as $asset) {
5562
if ($asset->assignedTo && (isset($asset->assignedTo->email)) && ($asset->assignedTo->email!='') && $asset->checkedOutToUser()) {
56-
$this->info('Sending User ExpectedCheckinNotification to: '.$asset->assignedTo->email);
5763
$asset->assignedTo->notify((new ExpectedCheckinNotification($asset)));
64+
$count++;
65+
}
66+
}
67+
68+
if ($this->option('with-output')) {
69+
if (($assets) && ($assets->count() > 0) && ($settings->alert_email != '')) {
70+
$this->table(
71+
[
72+
trans('general.id'),
73+
trans('admin/hardware/form.tag'),
74+
trans('admin/hardware/form.model'),
75+
trans('general.model_no'),
76+
trans('general.purchase_date'),
77+
trans('admin/hardware/form.expected_checkin'),
78+
],
79+
$assets->map(fn($assets) => [
80+
trans('general.id') => $assets->id,
81+
trans('admin/hardware/form.tag') => $assets->asset_tag,
82+
trans('admin/hardware/form.model') => $assets->model->name,
83+
trans('general.model_no') => $assets->model->model_number,
84+
trans('general.purchase_date') => $assets->purchase_date_formatted,
85+
trans('admin/hardware/form.eol_date') => $assets->expected_checkin_formattedDate ? $assets->expected_checkin_formattedDate . ' (' . $assets->expected_checkin_diff_for_humans . ')' : '',
86+
])
87+
);
5888
}
5989
}
6090

@@ -63,10 +93,11 @@ public function handle()
6393
$recipients = collect(explode(',', $settings->alert_email))->map(function ($item) {
6494
return new AlertRecipient($item);
6595
});
66-
67-
$this->info('Sending Admin ExpectedCheckinNotification to: '.$settings->alert_email);
68-
\Notification::send($recipients, new ExpectedCheckinAdminNotification($assets));
96+
Notification::send($recipients, new ExpectedCheckinAdminNotification($assets));
6997

7098
}
99+
100+
$this->info('Sent checkin reminders to to '.$count.' users.');
101+
71102
}
72103
}

app/Http/Controllers/Api/CategoriesController.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ public function index(Request $request) : array
4343
'created_at',
4444
'updated_at',
4545
'image',
46+
'tag_color',
4647
'notes',
4748
];
4849

@@ -57,6 +58,7 @@ public function index(Request $request) : array
5758
'require_acceptance',
5859
'checkin_email',
5960
'image',
61+
'tag_color',
6062
'notes',
6163
])
6264
->with('adminuser')

app/Http/Controllers/Api/CompaniesController.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ public function index(Request $request) : JsonResponse | array
3838
'accessories_count',
3939
'consumables_count',
4040
'components_count',
41+
'tag_color',
4142
'notes',
4243
];
4344

@@ -64,6 +65,11 @@ public function index(Request $request) : JsonResponse | array
6465
$companies->where('created_by', '=', $request->input('created_by'));
6566
}
6667

68+
if ($request->filled('tag_color')) {
69+
$companies->where('tag_color', '=', $request->input('tag_color'));
70+
}
71+
72+
6773

6874
// Make sure the offset and limit are actually integers and do not exceed system limits
6975
$offset = ($request->input('offset') > $companies->count()) ? $companies->count() : app('api_offset_value');
@@ -191,6 +197,7 @@ public function selectlist(Request $request) : array
191197
'companies.name',
192198
'companies.email',
193199
'companies.image',
200+
'companies.tag_color',
194201
]);
195202

196203

app/Http/Controllers/Api/DepartmentsController.php

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ class DepartmentsController extends Controller
2424
public function index(Request $request) : JsonResponse | array
2525
{
2626
$this->authorize('view', Department::class);
27-
$allowed_columns = ['id', 'name', 'image', 'users_count', 'notes'];
27+
$allowed_columns = ['id', 'name', 'image', 'users_count', 'notes', 'tag_color'];
2828

2929
$departments = Department::select(
3030
[
@@ -38,8 +38,9 @@ public function index(Request $request) : JsonResponse | array
3838
'departments.created_at',
3939
'departments.updated_at',
4040
'departments.image',
41+
'departments.tag_color',
4142
'departments.notes'
42-
])->with('users')->with('location')->with('manager')->with('company')->withCount('users as users_count');
43+
])->with('location')->with('manager')->with('company')->withCount('users as users_count');
4344

4445
if ($request->filled('search')) {
4546
$departments = $departments->TextSearch($request->input('search'));
@@ -61,6 +62,10 @@ public function index(Request $request) : JsonResponse | array
6162
$departments->where('location_id', '=', $request->input('location_id'));
6263
}
6364

65+
if ($request->filled('tag_color')) {
66+
$departments->where('tag_color', '=', $request->input('departments.tag_color'));
67+
}
68+
6469
// Make sure the offset and limit are actually integers and do not exceed system limits
6570
$offset = ($request->input('offset') > $departments->count()) ? $departments->count() : app('api_offset_value');
6671
$limit = app('api_limit_value');
@@ -186,6 +191,7 @@ public function selectlist(Request $request) : array
186191
'id',
187192
'name',
188193
'image',
194+
'tag_color',
189195
]);
190196

191197
if ($request->filled('search')) {

app/Http/Controllers/Api/LocationsController.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ public function index(Request $request) : JsonResponse | array
5959
'state',
6060
'updated_at',
6161
'zip',
62+
'tag_color',
6263
'notes',
6364
];
6465

@@ -81,6 +82,8 @@ public function index(Request $request) : JsonResponse | array
8182
'locations.ldap_ou',
8283
'locations.currency',
8384
'locations.company_id',
85+
'locations.tag_color',
86+
'locations.tag_color',
8487
'locations.notes',
8588
'locations.created_by',
8689
'locations.deleted_at',
@@ -145,6 +148,10 @@ public function index(Request $request) : JsonResponse | array
145148
$locations->onlyTrashed();
146149
}
147150

151+
if ($request->filled('tag_color')) {
152+
$locations->where('tag_color', '=', $request->input('locations.tag_color'));
153+
}
154+
148155
// Make sure the offset and limit are actually integers and do not exceed system limits
149156
$offset = ($request->input('offset') > $locations->count()) ? $locations->count() : app('api_offset_value');
150157
$limit = app('api_limit_value');
@@ -402,6 +409,7 @@ public function selectlist(Request $request) : array
402409
'locations.name',
403410
'locations.parent_id',
404411
'locations.image',
412+
'locations.tag_color',
405413
]);
406414

407415
// Only scope locations if the setting is enabled

app/Http/Controllers/Api/ManufacturersController.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ public function index(Request $request) : JsonResponse | array
4747
'consumables_count',
4848
'components_count',
4949
'licenses_count',
50+
'tag_color',
5051
'notes',
5152
];
5253

@@ -63,6 +64,7 @@ public function index(Request $request) : JsonResponse | array
6364
'updated_at',
6465
'image',
6566
'deleted_at',
67+
'tag_color',
6668
'notes',
6769
])
6870
->with('adminuser')
@@ -104,6 +106,10 @@ public function index(Request $request) : JsonResponse | array
104106
$manufacturers->where('support_email', '=', $request->input('support_email'));
105107
}
106108

109+
if ($request->filled('tag_color')) {
110+
$manufacturers->where('tag_color', '=', $request->input('manufacturers.tag_color'));
111+
}
112+
107113
// Make sure the offset and limit are actually integers and do not exceed system limits
108114
$offset = ($request->input('offset') > $manufacturers->count()) ? $manufacturers->count() : app('api_offset_value');
109115
$limit = app('api_limit_value');
@@ -258,6 +264,7 @@ public function selectlist(Request $request) : array
258264
'id',
259265
'name',
260266
'image',
267+
'tag_color',
261268
]);
262269

263270
if ($request->filled('search')) {

app/Http/Controllers/Api/SuppliersController.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,12 +50,13 @@ public function index(Request $request): array
5050
'accessories_count',
5151
'components_count',
5252
'consumables_count',
53+
'tag_color',
5354
'url',
5455
'notes',
5556
];
5657

5758
$suppliers = Supplier::select(
58-
['id', 'name', 'address', 'address2', 'city', 'state', 'country', 'fax', 'phone', 'email', 'contact', 'created_at', 'created_by', 'updated_at', 'deleted_at', 'image', 'notes', 'url', 'zip'])
59+
['id', 'name', 'address', 'address2', 'city', 'state', 'country', 'fax', 'phone', 'email', 'contact', 'created_at', 'created_by', 'updated_at', 'deleted_at', 'image', 'notes', 'url', 'zip', 'tag_color'])
5960
->withCount('assets as assets_count')
6061
->withCount('licenses as licenses_count')
6162
->withCount('accessories as accessories_count')
@@ -251,6 +252,7 @@ public function selectlist(Request $request) : array
251252
'id',
252253
'name',
253254
'image',
255+
'tag_color',
254256
]);
255257

256258
if ($request->filled('search')) {

app/Http/Controllers/Api/UsersController.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,11 @@ public function index(Request $request) : array
162162

163163
if ($request->filled('filter')) {
164164
$filter = json_decode($request->input('filter'), true);
165+
166+
if (is_null($filter)) {
167+
$filter = [];
168+
}
169+
165170
$filter = array_filter($filter, function ($key) use ($allowed_columns) {
166171
return in_array($key, $allowed_columns);
167172
}, ARRAY_FILTER_USE_KEY);

app/Http/Controllers/CategoriesController.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ public function store(ImageUploadRequest $request) : RedirectResponse
7878
$category->require_acceptance = $request->input('require_acceptance', '0');
7979
$category->alert_on_response = $request->input('alert_on_response', '0');
8080
$category->checkin_email = $request->input('checkin_email', '0');
81+
$category->tag_color = $request->input('tag_color');
8182
$category->notes = $request->input('notes');
8283
$category->created_by = auth()->id();
8384

@@ -132,6 +133,7 @@ public function update(ImageUploadRequest $request, Category $category) : Redire
132133
$category->require_acceptance = $request->input('require_acceptance', '0');
133134
$category->alert_on_response = $request->input('alert_on_response', '0');
134135
$category->checkin_email = $request->input('checkin_email', '0');
136+
$category->tag_color = $request->input('tag_color');
135137
$category->notes = $request->input('notes');
136138

137139
$category = $request->handleImages($category);

0 commit comments

Comments
 (0)