Skip to content

Commit 92f33c0

Browse files
committed
Merge branch 'develop' into saving_custom_report_template
2 parents 53de97d + 5084843 commit 92f33c0

Some content is hidden

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

44 files changed

+1018
-434
lines changed

.all-contributorsrc

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3217,6 +3217,15 @@
32173217
"contributions": [
32183218
"bug"
32193219
]
3220+
},
3221+
{
3222+
"login": "DarrenRainey",
3223+
"name": "Darren Rainey",
3224+
"avatar_url": "https://avatars.githubusercontent.com/u/6136439?v=4",
3225+
"profile": "https://darrenraineys.co.uk",
3226+
"contributions": [
3227+
"code"
3228+
]
32203229
}
32213230
]
32223231
}

CONTRIBUTORS.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ Thanks goes to all of these wonderful people ([emoji key](https://github.com/ken
5252
| [<img src="https://avatars.githubusercontent.com/u/47315739?v=4" width="110px;"/><br /><sub>bilias</sub>](https://github.com/bilias)<br />[💻](https://github.com/snipe/snipe-it/commits?author=bilias "Code") | [<img src="https://avatars.githubusercontent.com/u/2565989?v=4" width="110px;"/><br /><sub>coach1988</sub>](https://github.com/coach1988)<br />[💻](https://github.com/snipe/snipe-it/commits?author=coach1988 "Code") | [<img src="https://avatars.githubusercontent.com/u/11910225?v=4" width="110px;"/><br /><sub>MrM</sub>](https://github.com/mauro-miatello)<br />[💻](https://github.com/snipe/snipe-it/commits?author=mauro-miatello "Code") | [<img src="https://avatars.githubusercontent.com/u/60405354?v=4" width="110px;"/><br /><sub>koiakoia</sub>](https://github.com/koiakoia)<br />[💻](https://github.com/snipe/snipe-it/commits?author=koiakoia "Code") | [<img src="https://avatars.githubusercontent.com/u/5323832?v=4" width="110px;"/><br /><sub>Mustafa Online</sub>](https://github.com/mustafa-online)<br />[💻](https://github.com/snipe/snipe-it/commits?author=mustafa-online "Code") | [<img src="https://avatars.githubusercontent.com/u/104601439?v=4" width="110px;"/><br /><sub>franceslui</sub>](https://github.com/franceslui)<br />[💻](https://github.com/snipe/snipe-it/commits?author=franceslui "Code") | [<img src="https://avatars.githubusercontent.com/u/125313163?v=4" width="110px;"/><br /><sub>Q4kK</sub>](https://github.com/Q4kK)<br />[💻](https://github.com/snipe/snipe-it/commits?author=Q4kK "Code") |
5353
| [<img src="https://avatars.githubusercontent.com/u/55590532?v=4" width="110px;"/><br /><sub>squintfox</sub>](https://github.com/squintfox)<br />[💻](https://github.com/snipe/snipe-it/commits?author=squintfox "Code") | [<img src="https://avatars.githubusercontent.com/u/1380084?v=4" width="110px;"/><br /><sub>Jeff Clay</sub>](https://github.com/jeffclay)<br />[💻](https://github.com/snipe/snipe-it/commits?author=jeffclay "Code") | [<img src="https://avatars.githubusercontent.com/u/52716446?v=4" width="110px;"/><br /><sub>Phil J R</sub>](https://github.com/PP-JN-RL)<br />[💻](https://github.com/snipe/snipe-it/commits?author=PP-JN-RL "Code") | [<img src="https://avatars.githubusercontent.com/u/1496725?v=4" width="110px;"/><br /><sub>i_virus</sub>](https://www.corelight.com/)<br />[💻](https://github.com/snipe/snipe-it/commits?author=chandanchowdhury "Code") | [<img src="https://avatars.githubusercontent.com/u/1020541?v=4" width="110px;"/><br /><sub>Paul Grime</sub>](https://github.com/gitgrimbo)<br />[💻](https://github.com/snipe/snipe-it/commits?author=gitgrimbo "Code") | [<img src="https://avatars.githubusercontent.com/u/922815?v=4" width="110px;"/><br /><sub>Lee Porte</sub>](https://leeporte.co.uk)<br />[💻](https://github.com/snipe/snipe-it/commits?author=LeePorte "Code") | [<img src="https://avatars.githubusercontent.com/u/23613427?v=4" width="110px;"/><br /><sub>BRYAN </sub>](https://github.com/bryanlopezinc)<br />[💻](https://github.com/snipe/snipe-it/commits?author=bryanlopezinc "Code") [⚠️](https://github.com/snipe/snipe-it/commits?author=bryanlopezinc "Tests") |
5454
| [<img src="https://avatars.githubusercontent.com/u/64061710?v=4" width="110px;"/><br /><sub>U-H-T</sub>](https://github.com/U-H-T)<br />[💻](https://github.com/snipe/snipe-it/commits?author=U-H-T "Code") | [<img src="https://avatars.githubusercontent.com/u/5395363?v=4" width="110px;"/><br /><sub>Matt Tyree</sub>](https://github.com/Tyree)<br />[📖](https://github.com/snipe/snipe-it/commits?author=Tyree "Documentation") | [<img src="https://avatars.githubusercontent.com/u/292081?v=4" width="110px;"/><br /><sub>Florent Bervas</sub>](http://spoontux.net)<br />[💻](https://github.com/snipe/snipe-it/commits?author=FlorentDotMe "Code") | [<img src="https://avatars.githubusercontent.com/u/4498077?v=4" width="110px;"/><br /><sub>Daniel Albertsen</sub>](https://ditscheri.com)<br />[💻](https://github.com/snipe/snipe-it/commits?author=dbakan "Code") | [<img src="https://avatars.githubusercontent.com/u/100710244?v=4" width="110px;"/><br /><sub>r-xyz</sub>](https://github.com/r-xyz)<br />[💻](https://github.com/snipe/snipe-it/commits?author=r-xyz "Code") | [<img src="https://avatars.githubusercontent.com/u/47491036?v=4" width="110px;"/><br /><sub>Steven Mainor</sub>](https://github.com/DrekiDegga)<br />[💻](https://github.com/snipe/snipe-it/commits?author=DrekiDegga "Code") | [<img src="https://avatars.githubusercontent.com/u/65785975?v=4" width="110px;"/><br /><sub>arne-kroeger</sub>](https://github.com/arne-kroeger)<br />[💻](https://github.com/snipe/snipe-it/commits?author=arne-kroeger "Code") |
55-
| [<img src="https://avatars.githubusercontent.com/u/167117705?v=4" width="110px;"/><br /><sub>Glukose1</sub>](https://github.com/Glukose1)<br />[💻](https://github.com/snipe/snipe-it/commits?author=Glukose1 "Code") | [<img src="https://avatars.githubusercontent.com/u/1197791?v=4" width="110px;"/><br /><sub>Scarzy</sub>](https://github.com/Scarzy)<br />[💻](https://github.com/snipe/snipe-it/commits?author=Scarzy "Code") | [<img src="https://avatars.githubusercontent.com/u/37372069?v=4" width="110px;"/><br /><sub>setpill</sub>](https://github.com/setpill)<br />[💻](https://github.com/snipe/snipe-it/commits?author=setpill "Code") | [<img src="https://avatars.githubusercontent.com/u/3755203?v=4" width="110px;"/><br /><sub>swift2512</sub>](https://github.com/swift2512)<br />[🐛](https://github.com/snipe/snipe-it/issues?q=author%3Aswift2512 "Bug reports") |
55+
| [<img src="https://avatars.githubusercontent.com/u/167117705?v=4" width="110px;"/><br /><sub>Glukose1</sub>](https://github.com/Glukose1)<br />[💻](https://github.com/snipe/snipe-it/commits?author=Glukose1 "Code") | [<img src="https://avatars.githubusercontent.com/u/1197791?v=4" width="110px;"/><br /><sub>Scarzy</sub>](https://github.com/Scarzy)<br />[💻](https://github.com/snipe/snipe-it/commits?author=Scarzy "Code") | [<img src="https://avatars.githubusercontent.com/u/37372069?v=4" width="110px;"/><br /><sub>setpill</sub>](https://github.com/setpill)<br />[💻](https://github.com/snipe/snipe-it/commits?author=setpill "Code") | [<img src="https://avatars.githubusercontent.com/u/3755203?v=4" width="110px;"/><br /><sub>swift2512</sub>](https://github.com/swift2512)<br />[🐛](https://github.com/snipe/snipe-it/issues?q=author%3Aswift2512 "Bug reports") | [<img src="https://avatars.githubusercontent.com/u/6136439?v=4" width="110px;"/><br /><sub>Darren Rainey</sub>](https://darrenraineys.co.uk)<br />[💻](https://github.com/snipe/snipe-it/commits?author=DarrenRainey "Code") |
5656
<!-- ALL-CONTRIBUTORS-LIST:END -->
5757

5858
This project follows the [all-contributors](https://github.com/kentcdodds/all-contributors) specification. Contributions of any kind welcome!

app/Console/Commands/LdapSync.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
namespace App\Console\Commands;
44

5+
use App\Models\Asset;
56
use App\Models\Department;
67
use App\Models\Group;
78
use Illuminate\Console\Command;
@@ -418,6 +419,8 @@ public function handle()
418419
if ($item['createorupdate'] === 'created' && $ldap_default_group) {
419420
$user->groups()->attach($ldap_default_group);
420421
}
422+
//updates assets location based on user's location
423+
Asset::where('assigned_to', '=', $user->id)->update(['location_id' => $user->location_id]);
421424

422425
} else {
423426
foreach ($user->getErrors()->getMessages() as $key => $err) {

app/Http/Controllers/Api/AssetModelsController.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ public function index(Request $request) : JsonResponse | array
5959
'model_number',
6060
'min_amt',
6161
'eol',
62+
'created_by',
6263
'requestable',
6364
'models.notes',
6465
'models.created_at',
@@ -69,7 +70,7 @@ public function index(Request $request) : JsonResponse | array
6970
'models.deleted_at',
7071
'models.updated_at',
7172
])
72-
->with('category', 'depreciation', 'manufacturer', 'fieldset.fields.defaultValues','adminuser')
73+
->with('category', 'depreciation', 'manufacturer', 'fieldset.fields.defaultValues', 'adminuser')
7374
->withCount('assets as assets_count');
7475

7576
if ($request->input('status')=='deleted') {
@@ -95,7 +96,7 @@ public function index(Request $request) : JsonResponse | array
9596
$order = $request->input('order') === 'asc' ? 'asc' : 'desc';
9697
$sort = in_array($request->input('sort'), $allowed_columns) ? $request->input('sort') : 'models.created_at';
9798

98-
switch ($sort) {
99+
switch ($request->input('sort')) {
99100
case 'manufacturer':
100101
$assetmodels->OrderManufacturer($order);
101102
break;
@@ -105,6 +106,9 @@ public function index(Request $request) : JsonResponse | array
105106
case 'fieldset':
106107
$assetmodels->OrderFieldset($order);
107108
break;
109+
case 'created_by':
110+
$assetmodels->OrderByCreatedByName($order);
111+
break;
108112
default:
109113
$assetmodels->orderBy($sort, $order);
110114
break;

app/Http/Controllers/Api/ImportController.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,7 @@ class ImportController extends Controller
2828
public function index() : JsonResponse | array
2929
{
3030
$this->authorize('import');
31-
$imports = Import::latest()->get();
32-
31+
$imports = Import::with('adminuser')->latest()->get();
3332
return (new ImportsTransformer)->transformImports($imports);
3433
}
3534

@@ -133,7 +132,7 @@ public function store() : JsonResponse
133132
}
134133

135134
$import->filesize = filesize($path.'/'.$file_name);
136-
135+
$import->created_by = auth()->id();
137136
$import->save();
138137
$results[] = $import;
139138
}
@@ -177,6 +176,9 @@ public function process(ItemImportRequest $request, $import_id) : JsonResponse
177176
case 'asset':
178177
$redirectTo = 'hardware.index';
179178
break;
179+
case 'assetModel':
180+
$redirectTo = 'models.index';
181+
break;
180182
case 'accessory':
181183
$redirectTo = 'accessories.index';
182184
break;

app/Http/Controllers/Users/UsersController.php

Lines changed: 16 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -288,33 +288,31 @@ public function update(SaveUserRequest $request, User $user)
288288
$user->password = bcrypt($request->input('password'));
289289
}
290290

291-
292291
// Update the location of any assets checked out to this user
293292
Asset::where('assigned_type', User::class)
294293
->where('assigned_to', $user->id)
295294
->update(['location_id' => $user->location_id]);
296295

297-
$permissions_array = $request->input('permission');
298-
296+
$permissions_array = $request->input('permission');
299297

300-
// Strip out the superuser permission if the user isn't a superadmin
301-
if (! auth()->user()->isSuperUser()) {
302-
unset($permissions_array['superuser']);
303-
$permissions_array['superuser'] = $orig_superuser;
304-
}
298+
// Strip out the superuser permission if the user isn't a superadmin
299+
if (! auth()->user()->isSuperUser()) {
300+
unset($permissions_array['superuser']);
301+
$permissions_array['superuser'] = $orig_superuser;
302+
}
305303

306-
$user->permissions = json_encode($permissions_array);
304+
$user->permissions = json_encode($permissions_array);
307305

308-
// Handle uploaded avatar
309-
app(ImageUploadRequest::class)->handleImages($user, 600, 'avatar', 'avatars', 'avatar');
310-
session()->put(['redirect_option' => $request->get('redirect_option')]);
306+
// Handle uploaded avatar
307+
app(ImageUploadRequest::class)->handleImages($user, 600, 'avatar', 'avatars', 'avatar');
308+
session()->put(['redirect_option' => $request->get('redirect_option')]);
311309

312-
if ($user->save()) {
313-
// Redirect to the user page
314-
return redirect()->to(Helper::getRedirectOption($request, $user->id, 'Users'))
315-
->with('success', trans('admin/users/message.success.update'));
316-
}
317-
return redirect()->back()->withInput()->withErrors($user->getErrors());
310+
if ($user->save()) {
311+
// Redirect to the user page
312+
return redirect()->to(Helper::getRedirectOption($request, $user->id, 'Users'))
313+
->with('success', trans('admin/users/message.success.update'));
314+
}
315+
return redirect()->back()->withInput()->withErrors($user->getErrors());
318316
}
319317

320318
/**

app/Http/Requests/ItemImportRequest.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,11 @@ public function import(Import $import)
3838

3939
$filename = config('app.private_uploads').'/imports/'.$import->file_path;
4040
$import->import_type = $this->input('import-type');
41-
$class = title_case($import->import_type);
41+
$class = ucfirst($import->import_type);
4242
$classString = "App\\Importer\\{$class}Importer";
4343
$importer = new $classString($filename);
4444
$import->field_map = request('column-mappings');
45+
$import->created_by = auth()->id();
4546
$import->save();
4647
$fieldMappings = [];
4748

@@ -60,7 +61,7 @@ public function import(Import $import)
6061
$fieldMappings = array_change_key_case(array_flip($import->field_map), CASE_LOWER);
6162
}
6263
$importer->setCallbacks([$this, 'log'], [$this, 'progress'], [$this, 'errorCallback'])
63-
->setUserId(auth()->id())
64+
->setCreatedBy(auth()->id())
6465
->setUpdating($this->get('import-update'))
6566
->setShouldNotify($this->get('send-welcome'))
6667
->setUsernameFormat('firstname.lastname')

app/Http/Transformers/AssetModelsTransformer.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,10 @@ public function transformAssetModel(AssetModel $assetmodel)
6565
'eol' => ($assetmodel->eol > 0) ? $assetmodel->eol.' months' : 'None',
6666
'requestable' => ($assetmodel->requestable == '1') ? true : false,
6767
'notes' => Helper::parseEscapedMarkedownInline($assetmodel->notes),
68+
'created_by' => ($assetmodel->adminuser) ? [
69+
'id' => (int) $assetmodel->adminuser->id,
70+
'name'=> e($assetmodel->adminuser->present()->fullName()),
71+
] : null,
6872
'created_at' => Helper::getFormattedDateObject($assetmodel->created_at, 'datetime'),
6973
'updated_at' => Helper::getFormattedDateObject($assetmodel->updated_at, 'datetime'),
7074
'deleted_at' => Helper::getFormattedDateObject($assetmodel->deleted_at, 'datetime'),

app/Importer/AccessoryImporter.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ public function createAccessoryIfNotExists($row)
4242
}
4343
$this->log('No Matching Accessory, Creating a new one');
4444
$accessory = new Accessory();
45+
$accessory->created_by = auth()->id();
4546
$this->item['model_number'] = $this->findCsvMatch($row, "model_number");
4647
$this->item['min_amt'] = $this->findCsvMatch($row, "min_amt");
4748
$accessory->fill($this->sanitizeItemForStoring($accessory));

0 commit comments

Comments
 (0)