diff --git a/app/Http/Controllers/SettingsController.php b/app/Http/Controllers/SettingsController.php index 470e892d0..0ea1ca226 100755 --- a/app/Http/Controllers/SettingsController.php +++ b/app/Http/Controllers/SettingsController.php @@ -348,6 +348,7 @@ class SettingsController extends Controller $setting->qr_text = e(Input::get('qr_text')); $setting->auto_increment_prefix = e(Input::get('auto_increment_prefix')); $setting->auto_increment_assets = e(Input::get('auto_increment_assets', '0')); + $setting->zerofill_count = e(Input::get('zerofill_count')); $setting->alert_interval = e(Input::get('alert_interval')); $setting->alert_threshold = e(Input::get('alert_threshold')); $setting->email_domain = e(Input::get('email_domain')); diff --git a/app/Models/Asset.php b/app/Models/Asset.php index 0fa8e30ff..12f82cfce 100644 --- a/app/Models/Asset.php +++ b/app/Models/Asset.php @@ -466,13 +466,24 @@ class Asset extends Depreciable $asset_tag = \DB::table('assets') ->where('physical', '=', '1') ->max('id'); + + if ($settings->zerofill_count > 0) { + return $settings->auto_increment_prefix.Asset::zerofill(($asset_tag + 1),$settings->zerofill_count); + } return $settings->auto_increment_prefix.($asset_tag + 1); } else { return false; } } - public function checkin_email() + + public static function zerofill ($num, $zerofill = 3) + { + return str_pad($num, $zerofill, '0', STR_PAD_LEFT); + } + + +public function checkin_email() { return $this->model->category->checkin_email; } diff --git a/database/migrations/2016_07_27_211034_add_zerofill_to_settings.php b/database/migrations/2016_07_27_211034_add_zerofill_to_settings.php new file mode 100644 index 000000000..f560c74a4 --- /dev/null +++ b/database/migrations/2016_07_27_211034_add_zerofill_to_settings.php @@ -0,0 +1,31 @@ +integer('zerofill_count')->default(0); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::table('settings', function ($table) { + $table->dropColumn('zerofill_count'); + }); + } +} diff --git a/resources/lang/en/admin/settings/general.php b/resources/lang/en/admin/settings/general.php index d944955e6..623b00060 100644 --- a/resources/lang/en/admin/settings/general.php +++ b/resources/lang/en/admin/settings/general.php @@ -108,4 +108,5 @@ return array( 'bottom' => 'bottom', 'vertical' => 'vertical', 'horizontal' => 'horizontal', + 'zerofill_count' => 'Length of asset tags, including zerofill', ); diff --git a/resources/views/settings/edit.blade.php b/resources/views/settings/edit.blade.php index 39a330312..bf86e3646 100755 --- a/resources/views/settings/edit.blade.php +++ b/resources/views/settings/edit.blade.php @@ -304,6 +304,18 @@ + +
+
+ {{ Form::label('auto_increment_prefix', trans('admin/settings/general.zerofill_count')) }} +
+
+ {{ Form::text('zerofill_count', Input::old('zerofill_count', $setting->zerofill_count), array('class' => 'form-control', 'style'=>'width: 100px;')) }} + {!! $errors->first('zerofill_count', ':message') !!} + +
+
+ @@ -812,9 +824,9 @@
@if (config('app.lock_passwords')===true) - {{ Form::text('ldap_filter', Input::old('ldap_filter', $setting->ldap_filter), array('class' => 'form-control', 'disabled'=>'disabled','placeholder' => 'cn=users/authorized,dc=example,dc=com')) }} + {{ Form::text('ldap_filter', Input::old('ldap_filter', $setting->ldap_filter), array('class' => 'form-control', 'disabled'=>'disabled','placeholder' => '&(cn=*)')) }} @else - {{ Form::text('ldap_filter', Input::old('ldap_filter', $setting->ldap_filter), array('class' => 'form-control','placeholder' => 'cn=users/authorized,dc=example,dc=com')) }} + {{ Form::text('ldap_filter', Input::old('ldap_filter', $setting->ldap_filter), array('class' => 'form-control','placeholder' => '&(cn=*)')) }} @endif {!! $errors->first('ldap_filter', ':message') !!}