mirror of
https://github.com/snipe/snipe-it.git
synced 2024-11-09 23:24:06 -08:00
Zerofilling for auto-increment
This commit is contained in:
parent
e9eb5ad372
commit
eb508901c5
|
@ -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'));
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -0,0 +1,31 @@
|
|||
<?php
|
||||
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
|
||||
class AddZerofillToSettings extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::table('settings', function (Blueprint $table) {
|
||||
$table->integer('zerofill_count')->default(0);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::table('settings', function ($table) {
|
||||
$table->dropColumn('zerofill_count');
|
||||
});
|
||||
}
|
||||
}
|
|
@ -108,4 +108,5 @@ return array(
|
|||
'bottom' => 'bottom',
|
||||
'vertical' => 'vertical',
|
||||
'horizontal' => 'horizontal',
|
||||
'zerofill_count' => 'Length of asset tags, including zerofill',
|
||||
);
|
||||
|
|
|
@ -304,6 +304,18 @@
|
|||
</div>
|
||||
</div>
|
||||
|
||||
<!-- auto zerofill -->
|
||||
<div class="form-group {{ $errors->has('zerofill_count') ? 'error' : '' }}">
|
||||
<div class="col-md-3">
|
||||
{{ Form::label('auto_increment_prefix', trans('admin/settings/general.zerofill_count')) }}
|
||||
</div>
|
||||
<div class="col-md-9">
|
||||
{{ Form::text('zerofill_count', Input::old('zerofill_count', $setting->zerofill_count), array('class' => 'form-control', 'style'=>'width: 100px;')) }}
|
||||
{!! $errors->first('zerofill_count', '<span class="alert-msg">:message</span>') !!}
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
Loading…
Reference in a new issue