diff --git a/app/Console/Commands/LdapSync.php b/app/Console/Commands/LdapSync.php index e0e001a99..4ec7509d1 100755 --- a/app/Console/Commands/LdapSync.php +++ b/app/Console/Commands/LdapSync.php @@ -190,7 +190,13 @@ class LdapSync extends Command if ($item['ldap_location_override'] == true) { $user->location_id = $item['location_id']; } elseif ((isset($location)) && (!empty($location))) { - $user->location_id = e($location->id); + + if ((is_array($location)) && (array_key_exists('id', $location))) { + $user->location_id = $location['id']; + } elseif (is_object($location)) { + $user->location_id = $location->id; + } + } $user->notes = 'Imported from LDAP'; diff --git a/app/Helpers/Helper.php b/app/Helpers/Helper.php index e92f25a2c..6b0f0f98a 100644 --- a/app/Helpers/Helper.php +++ b/app/Helpers/Helper.php @@ -235,7 +235,7 @@ class Helper */ public static function statusLabelList() { - $statuslabel_list = array('' => trans('general.select_statuslabel')) + Statuslabel::orderBy('deployable', 'desc') + $statuslabel_list = array('' => trans('general.select_statuslabel')) + Statuslabel::orderBy('default_label', 'desc')->orderBy('name','asc')->orderBy('deployable','desc') ->pluck('name', 'id')->toArray(); return $statuslabel_list; } diff --git a/app/Http/Controllers/Api/AssetsController.php b/app/Http/Controllers/Api/AssetsController.php index 85019ad90..8abfab88a 100644 --- a/app/Http/Controllers/Api/AssetsController.php +++ b/app/Http/Controllers/Api/AssetsController.php @@ -420,7 +420,7 @@ class AssetsController extends Controller */ public function update(Request $request, $id) { - $this->authorize('create', Asset::class); + $this->authorize('edit', Asset::class); if ($asset = Asset::find($id)) { ($request->has('model_id')) ? diff --git a/app/Http/Controllers/Api/StatuslabelsController.php b/app/Http/Controllers/Api/StatuslabelsController.php index a3c698fa7..ed6b9e21d 100644 --- a/app/Http/Controllers/Api/StatuslabelsController.php +++ b/app/Http/Controllers/Api/StatuslabelsController.php @@ -22,7 +22,7 @@ class StatuslabelsController extends Controller public function index(Request $request) { $this->authorize('view', Statuslabel::class); - $allowed_columns = ['id','name','created_at', 'assets_count','color']; + $allowed_columns = ['id','name','created_at', 'assets_count','color','default_label']; $statuslabels = Statuslabel::withCount('assets'); diff --git a/app/Http/Controllers/AssetModelsController.php b/app/Http/Controllers/AssetModelsController.php index 8cd9a450d..389f1edd9 100755 --- a/app/Http/Controllers/AssetModelsController.php +++ b/app/Http/Controllers/AssetModelsController.php @@ -166,7 +166,7 @@ class AssetModelsController extends Controller */ public function edit($modelId = null) { - $this->authorize('edit', AssetModel::class); + $this->authorize('update', AssetModel::class); if ($item = AssetModel::find($modelId)) { $category_type = 'asset'; $view = View::make('models/edit', compact('item','category_type')); @@ -190,7 +190,7 @@ class AssetModelsController extends Controller */ public function update(ImageUploadRequest $request, $modelId = null) { - $this->authorize('edit', AssetModel::class); + $this->authorize('update', AssetModel::class); // Check if the model exists if (is_null($model = AssetModel::find($modelId))) { // Redirect to the models management page diff --git a/app/Http/Controllers/StatuslabelsController.php b/app/Http/Controllers/StatuslabelsController.php index 1a9b772dd..a264dd77f 100755 --- a/app/Http/Controllers/StatuslabelsController.php +++ b/app/Http/Controllers/StatuslabelsController.php @@ -93,9 +93,9 @@ class StatuslabelsController extends Controller $statusLabel->archived = $statusType['archived']; $statusLabel->color = Input::get('color'); $statusLabel->show_in_nav = Input::get('show_in_nav', 0); + $statusLabel->default_label = Input::get('default_label', 0); - // Was the asset created? if ($statusLabel->save()) { // Redirect to the new Statuslabel page return redirect()->route('statuslabels.index')->with('success', trans('admin/statuslabels/message.create.success')); @@ -185,6 +185,7 @@ class StatuslabelsController extends Controller $statuslabel->archived = $statustype['archived']; $statuslabel->color = Input::get('color'); $statuslabel->show_in_nav = Input::get('show_in_nav', 0); + $statuslabel->default_label = Input::get('default_label', 0); // Was the asset created? diff --git a/app/Http/Transformers/CustomFieldsTransformer.php b/app/Http/Transformers/CustomFieldsTransformer.php index 6e6a50a7e..5c6e5d4fc 100644 --- a/app/Http/Transformers/CustomFieldsTransformer.php +++ b/app/Http/Transformers/CustomFieldsTransformer.php @@ -26,6 +26,7 @@ class CustomFieldsTransformer 'name' => e($field->name), 'db_column_name' => e($field->db_column_name()), 'format' => e($field->format), + 'field_values' => ($field->field_values) ? e($field->field_values) : null, 'required' => $field->pivot ? $field->pivot->required : false, 'created_at' => Helper::getFormattedDateObject($field->created_at, 'datetime'), 'updated_at' => Helper::getFormattedDateObject($field->updated_at, 'datetime'), diff --git a/app/Http/Transformers/StatuslabelsTransformer.php b/app/Http/Transformers/StatuslabelsTransformer.php index e7b356deb..f1a546053 100644 --- a/app/Http/Transformers/StatuslabelsTransformer.php +++ b/app/Http/Transformers/StatuslabelsTransformer.php @@ -26,6 +26,7 @@ class StatuslabelsTransformer 'type' => $statuslabel->getStatuslabelType(), 'color' => ($statuslabel->color) ? e($statuslabel->color) : null, 'show_in_nav' => ($statuslabel->show_in_nav=='1') ? true : false, + 'default_label' => ($statuslabel->default_label =='1') ? true : false, 'assets_count' => (int) $statuslabel->assets_count, 'notes' => e($statuslabel->notes), 'created_at' => Helper::getFormattedDateObject($statuslabel->created_at, 'datetime'), diff --git a/app/Models/User.php b/app/Models/User.php index 92f3caf9a..d26d5d940 100755 --- a/app/Models/User.php +++ b/app/Models/User.php @@ -346,7 +346,10 @@ class User extends SnipeModel implements AuthenticatableContract, CanResetPasswo $username = str_slug(substr($first_name, 0, 1).$last_name); if ($format=='firstname.lastname') { - $username = str_slug($first_name).'.'.str_slug($last_name); + $username = str_slug($first_name) . '.' . str_slug($last_name); + + } elseif ($format=='lastnamefirstinitial') { + $username = str_slug($last_name.substr($first_name, 0, 1)); } elseif ($format=='firstname_lastname') { $username = str_slug($first_name).'_'.str_slug($last_name); diff --git a/app/Policies/DepreciationPolicy.php b/app/Policies/DepreciationPolicy.php new file mode 100644 index 000000000..cc889b894 --- /dev/null +++ b/app/Policies/DepreciationPolicy.php @@ -0,0 +1,13 @@ + ConsumablePolicy::class, CustomField::class => CustomFieldPolicy::class, Department::class => DepartmentPolicy::class, + Depreciation::class => DepreciationPolicy::class, License::class => LicensePolicy::class, Location::class => LocationPolicy::class, Statuslabel::class => StatuslabelPolicy::class, @@ -130,17 +133,17 @@ class AuthServiceProvider extends ServiceProvider }); Gate::define('backend.interact', function ($user) { - return $user->can('view', \App\Models\Statuslabel::class) - || $user->can('view', \App\Models\AssetModel::class) - || $user->can('view', \App\Models\Category::class) - || $user->can('view', \App\Models\Manufacturer::class) - || $user->can('view', \App\Models\Supplier::class) - || $user->can('view', \App\Models\Department::class) - || $user->can('view', \App\Models\Location::class) - || $user->can('view', \App\Models\Company::class) - || $user->can('view', \App\Models\Manufacturer::class) - || $user->can('view', \App\Models\Company::class) - || $user->can('view', \App\Models\Depreciation::class); + return $user->can('view', Statuslabel::class) + || $user->can('view', AssetModel::class) + || $user->can('view', Category::class) + || $user->can('view', Manufacturer::class) + || $user->can('view', Supplier::class) + || $user->can('view', Department::class) + || $user->can('view', Location::class) + || $user->can('view', Company::class) + || $user->can('view', Manufacturer::class) + || $user->can('view', CustomField::class) + || $user->can('view', Depreciation::class); }); } } diff --git a/config/app.php b/config/app.php index f30388b59..25b7f960b 100755 --- a/config/app.php +++ b/config/app.php @@ -1,5 +1,14 @@ [ diff --git a/config/mail.php b/config/mail.php index eab4ad4d2..9c2aac439 100755 --- a/config/mail.php +++ b/config/mail.php @@ -1,5 +1,14 @@ array( diff --git a/config/services.php b/config/services.php index 83b8cca3e..aaccc92c2 100644 --- a/config/services.php +++ b/config/services.php @@ -1,5 +1,14 @@ 'v4.1.14', - 'full_app_version' => 'v4.1.14 - build 3416-g14af95001', - 'build_version' => '3416', + 'full_app_version' => 'v4.1.14 - build 3446-g90bff709a', + 'build_version' => '3446', 'prerelease_version' => '', - 'hash_version' => 'g14af95001', - 'full_hash' => 'v4.1.14-25-g14af95001', + 'hash_version' => 'g90bff709a', + 'full_hash' => 'v4.1.14-55-g90bff709a', 'branch' => 'master', ); diff --git a/database/factories/StatusLabelFactory.php b/database/factories/StatusLabelFactory.php index 60b0bbc50..bf7ed8bc6 100644 --- a/database/factories/StatusLabelFactory.php +++ b/database/factories/StatusLabelFactory.php @@ -18,13 +18,15 @@ $factory->define(Statuslabel::class, function (Faker\Generator $faker) { $factory->state(Statuslabel::class, 'rtd', function (Faker\Generator $faker) { return [ 'notes' => $faker->sentence, - 'deployable' => 1 + 'deployable' => 1, + 'default_label' => 1, ]; }); $factory->state(Statuslabel::class, 'pending', function (Faker\Generator $faker) { return [ 'notes' => $faker->sentence, 'pending' => 1, + 'default_label' => 0, ]; }); @@ -32,29 +34,34 @@ $factory->state(Statuslabel::class, 'archived', function (Faker\Generator $faker return [ 'notes' => 'These assets are permanently undeployable', 'archived' => 1, + 'default_label' => 0, ]; }); $factory->state(Statuslabel::class, 'out_for_diagnostics', function (Faker\Generator $faker) { return [ 'name' => 'Out for Diagnostics', + 'default_label' => 0, ]; }); $factory->state(Statuslabel::class, 'out_for_repair', function (Faker\Generator $faker) { return [ 'name' => 'Out for Repair', + 'default_label' => 0, ]; }); $factory->state(Statuslabel::class, 'broken', function (Faker\Generator $faker) { return [ 'name' => 'Broken - Not Fixable', + 'default_label' => 0, ]; }); $factory->state(Statuslabel::class, 'lost', function (Faker\Generator $faker) { return [ 'name' => 'Lost/Stolen', + 'default_label' => 0, ]; }); diff --git a/database/migrations/2018_03_06_054937_add_default_flag_on_statuslabels.php b/database/migrations/2018_03_06_054937_add_default_flag_on_statuslabels.php new file mode 100644 index 000000000..54a62bd77 --- /dev/null +++ b/database/migrations/2018_03_06_054937_add_default_flag_on_statuslabels.php @@ -0,0 +1,32 @@ +boolean('default_label')->default(0); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::table('status_labels', function (Blueprint $table) { + $table->dropColumn('default_label'); + }); + } +} diff --git a/resources/lang/en/admin/statuslabels/table.php b/resources/lang/en/admin/statuslabels/table.php index b9b5b7ec4..27befb5ef 100644 --- a/resources/lang/en/admin/statuslabels/table.php +++ b/resources/lang/en/admin/statuslabels/table.php @@ -5,6 +5,8 @@ return array( 'archived' => 'Archived', 'create' => 'Create Status Label', 'color' => 'Chart Color', + 'default_label' => 'Default Label', + 'default_label_help' => 'This is used to ensure your most commonly used status labels appear at the top of the select box when creating/editing assets.', 'deployable' => 'Deployable', 'info' => 'Status labels are used to describe the various states your assets could be in. They may be out for repair, lost/stolen, etc. You can create new status labels for deployable, pending and archived assets.', 'name' => 'Status Name', diff --git a/resources/lang/en/general.php b/resources/lang/en/general.php index c33c33381..abd1fe4e5 100644 --- a/resources/lang/en/general.php +++ b/resources/lang/en/general.php @@ -81,6 +81,7 @@ 'filastname_format' => 'First Initial Last Name (jsmith@example.com)', 'firstname_lastname_format' => 'First Name Last Name (jane.smith@example.com)', 'firstname_lastname_underscore_format' => 'First Name Last Name (jane_smith@example.com)', + 'lastnamefirstinitial_format' => 'Last Name First Initial (smithj@example.com)', 'first' => 'First', 'first_name' => 'First Name', 'first_name_format' => 'First Name (jane@example.com)', diff --git a/resources/macros/macros.php b/resources/macros/macros.php index 6446f5926..9539034f4 100644 --- a/resources/macros/macros.php +++ b/resources/macros/macros.php @@ -456,6 +456,7 @@ Form::macro('username_format', function ($name = "username_format", $selected = 'firstname.lastname' => trans('general.firstname_lastname_format'), 'firstname' => trans('general.first_name_format'), 'filastname' => trans('general.filastname_format'), + 'lastnamefirstinitial' => trans('general.lastnamefirstinitial_format'), 'firstname_lastname' => trans('general.firstname_lastname_underscore_format'), ); diff --git a/resources/views/layouts/default.blade.php b/resources/views/layouts/default.blade.php index 054c3744f..da446d9e2 100644 --- a/resources/views/layouts/default.blade.php +++ b/resources/views/layouts/default.blade.php @@ -524,8 +524,8 @@