diff --git a/app/Http/Controllers/SettingsController.php b/app/Http/Controllers/SettingsController.php index 1557991c0..931addf24 100755 --- a/app/Http/Controllers/SettingsController.php +++ b/app/Http/Controllers/SettingsController.php @@ -334,6 +334,7 @@ class SettingsController extends Controller $setting->full_multiple_companies_support = $request->input('full_multiple_companies_support', '0'); $setting->load_remote = $request->input('load_remote', '0'); + $setting->unique_serial = $request->input('unique_serial', '0'); $setting->show_images_in_email = $request->input('show_images_in_email', '0'); $setting->show_archived_in_list = $request->input('show_archived_in_list', '0'); $setting->dashboard_message = $request->input('dashboard_message'); diff --git a/app/Http/Traits/UniqueSerialTrait.php b/app/Http/Traits/UniqueSerialTrait.php new file mode 100644 index 000000000..fc2291c7a --- /dev/null +++ b/app/Http/Traits/UniqueSerialTrait.php @@ -0,0 +1,23 @@ +unique_serial=='1') { + return 'unique_undeleted:'.$this->table.','. $this->getKey(); + } + + } +} diff --git a/app/Http/Transformers/CategoriesTransformer.php b/app/Http/Transformers/CategoriesTransformer.php index 8fc3cb900..710bf84bc 100644 --- a/app/Http/Transformers/CategoriesTransformer.php +++ b/app/Http/Transformers/CategoriesTransformer.php @@ -41,7 +41,7 @@ class CategoriesTransformer $permissions_array['available_actions'] = [ 'update' => Gate::allows('update', Category::class) ? true : false, - 'delete' => (Gate::allows('delete', Category::class) && ($category->assets_count == 0) && ($category->accessories_count == 0) && ($category->consumables_count == 0) && ($category->components_count == 0)) ? true : false, + 'delete' => (Gate::allows('delete', Category::class) && ($category->assets_count == 0) && ($category->accessories_count == 0) && ($category->consumables_count == 0) && ($category->components_count == 0) && ($category->licenses_count == 0)) ? true : false, ]; $array += $permissions_array; diff --git a/app/Models/Asset.php b/app/Models/Asset.php index 5595b2d2b..92085b582 100644 --- a/app/Models/Asset.php +++ b/app/Models/Asset.php @@ -2,6 +2,7 @@ namespace App\Models; use App\Exceptions\CheckoutNotAllowed; +use App\Http\Traits\UniqueSerialTrait; use App\Http\Traits\UniqueUndeletedTrait; use App\Presenters\Presentable; use AssetPresenter; @@ -23,7 +24,7 @@ use App\Notifications\CheckoutAssetNotification; class Asset extends Depreciable { protected $presenter = 'App\Presenters\AssetPresenter'; - use Loggable, Requestable, Presentable, SoftDeletes, ValidatingTrait, UniqueUndeletedTrait; + use Loggable, Requestable, Presentable, SoftDeletes, ValidatingTrait, UniqueUndeletedTrait, UniqueSerialTrait; const LOCATION = 'location'; const ASSET = 'asset'; @@ -72,12 +73,13 @@ class Asset extends Depreciable 'status_id' => 'required|integer|exists:status_labels,id', 'company_id' => 'integer|nullable', 'warranty_months' => 'numeric|nullable', - 'physical' => 'numeric|max:1|nullable', + 'physical' => 'numeric|max:1|nullable', 'checkout_date' => 'date|max:10|min:10|nullable', 'checkin_date' => 'date|max:10|min:10|nullable', 'supplier_id' => 'numeric|nullable', 'asset_tag' => 'required|min:1|max:255|unique_undeleted', 'status' => 'integer', + 'serial' => 'unique_serial|nullable', 'purchase_cost' => 'numeric|nullable', 'next_audit_date' => 'date|nullable', 'last_audit_date' => 'date|nullable', diff --git a/database/migrations/2018_07_05_215440_add_unique_serial_option_to_settings.php b/database/migrations/2018_07_05_215440_add_unique_serial_option_to_settings.php new file mode 100644 index 000000000..eeaeb7927 --- /dev/null +++ b/database/migrations/2018_07_05_215440_add_unique_serial_option_to_settings.php @@ -0,0 +1,32 @@ +boolean('unique_serial')->default('0'); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::table('settings', function (Blueprint $table) { + $table->dropColumn('unique_serial'); + }); + } +} diff --git a/resources/lang/en/admin/settings/general.php b/resources/lang/en/admin/settings/general.php index fb68f1220..177041b18 100644 --- a/resources/lang/en/admin/settings/general.php +++ b/resources/lang/en/admin/settings/general.php @@ -179,5 +179,7 @@ return array( 'bottom' => 'bottom', 'vertical' => 'vertical', 'horizontal' => 'horizontal', + 'unique_serial' => 'Unique serial numbers', + 'unique_serial_help_text' => 'Checking this box will enforce a uniqeness constraint on asset serials', 'zerofill_count' => 'Length of asset tags, including zerofill', ); diff --git a/resources/views/custom_fields/fields/edit.blade.php b/resources/views/custom_fields/fields/edit.blade.php index 1973a6991..fb109c7cc 100644 --- a/resources/views/custom_fields/fields/edit.blade.php +++ b/resources/views/custom_fields/fields/edit.blade.php @@ -105,7 +105,7 @@
{{ trans('general.image_filetypes_help') }}
+ +{{ trans('general.image_filetypes_help', ['size' => \App\Helpers\Helper::file_upload_max_size_readable()]) }}
{!! $errors->first('image', ':message') !!} {{ Form::checkbox('clear_logo', '1', Input::old('clear_logo'),array('class' => 'minimal')) }} Remove diff --git a/resources/views/settings/general.blade.php b/resources/views/settings/general.blade.php index 0f5012e5e..174d173af 100644 --- a/resources/views/settings/general.blade.php +++ b/resources/views/settings/general.blade.php @@ -137,8 +137,23 @@+ {{ trans('admin/settings/general.unique_serial_help_text') }} +
+