mirror of
https://github.com/snipe/snipe-it.git
synced 2025-03-05 20:52:15 -08:00
Localization digit separator feature. (#8915)
Provides an ability to localize the purchase_cost field in front-end hardware index table. Has two digit separator formats in admin settings with comma and dot.
This commit is contained in:
parent
4a5cb94d94
commit
bbf7fbcff4
|
@ -577,6 +577,7 @@ class SettingsController extends Controller
|
||||||
$setting->default_currency = $request->input('default_currency', '$');
|
$setting->default_currency = $request->input('default_currency', '$');
|
||||||
$setting->date_display_format = $request->input('date_display_format');
|
$setting->date_display_format = $request->input('date_display_format');
|
||||||
$setting->time_display_format = $request->input('time_display_format');
|
$setting->time_display_format = $request->input('time_display_format');
|
||||||
|
$setting->digit_separator = $request->input('digit_separator');
|
||||||
|
|
||||||
if ($setting->save()) {
|
if ($setting->save()) {
|
||||||
return redirect()->route('settings.index')
|
return redirect()->route('settings.index')
|
||||||
|
|
|
@ -146,6 +146,7 @@ class AssetPresenter extends Presenter
|
||||||
"searchable" => true,
|
"searchable" => true,
|
||||||
"sortable" => true,
|
"sortable" => true,
|
||||||
"title" => trans('general.purchase_cost'),
|
"title" => trans('general.purchase_cost'),
|
||||||
|
"formatter" => 'numberWithCommas',
|
||||||
"footerFormatter" => 'sumFormatter',
|
"footerFormatter" => 'sumFormatter',
|
||||||
], [
|
], [
|
||||||
"field" => "order_number",
|
"field" => "order_number",
|
||||||
|
|
|
@ -0,0 +1,32 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
|
||||||
|
class AddDigitSeparatorToSettings extends Migration
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Run the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function up()
|
||||||
|
{
|
||||||
|
Schema::table('settings', function (Blueprint $table) {
|
||||||
|
$table->char('digit_separator')->nullable()->default('1234.56');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function down()
|
||||||
|
{
|
||||||
|
Schema::table('settings', function (Blueprint $table) {
|
||||||
|
$table->dropColumn('digit_separator');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
|
@ -411,6 +411,25 @@ Form::macro('time_display_format', function ($name = "time_display_format", $sel
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Form::macro('digit_separator', function ($name = "digit_separator", $selected = null, $class = null) {
|
||||||
|
|
||||||
|
$formats = [
|
||||||
|
'1234.56',
|
||||||
|
'1.234,56',
|
||||||
|
];
|
||||||
|
|
||||||
|
foreach ($formats as $format) {
|
||||||
|
}
|
||||||
|
$select = '<select name="'.$name.'" class="'.$class.'" style="min-width:120px">';
|
||||||
|
foreach ($formats as $format_inner ) {
|
||||||
|
$select .= '<option value="'.$format_inner.'"'.($selected == $format_inner ? ' selected="selected"' : '').'>'.$format_inner.'</option> ';
|
||||||
|
}
|
||||||
|
|
||||||
|
$select .= '</select>';
|
||||||
|
return $select;
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Barcode macro
|
* Barcode macro
|
||||||
* Generates the dropdown menu of available 1D barcodes
|
* Generates the dropdown menu of available 1D barcodes
|
||||||
|
|
|
@ -592,11 +592,19 @@
|
||||||
var total_sum = data.reduce(function(sum, row) {
|
var total_sum = data.reduce(function(sum, row) {
|
||||||
return (sum) + (parseFloat(row[field]) || 0);
|
return (sum) + (parseFloat(row[field]) || 0);
|
||||||
}, 0);
|
}, 0);
|
||||||
return total_sum.toFixed(2);
|
return numberWithCommas(total_sum.toFixed(2));
|
||||||
}
|
}
|
||||||
return 'not an array';
|
return 'not an array';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function numberWithCommas(value) {
|
||||||
|
if ((value) && ("{{$snipeSettings->digit_separator}}" == "1.234,56")){
|
||||||
|
var parts = value.toString().split(".");
|
||||||
|
parts[0] = parts[0].replace(/\B(?=(\d{3})+(?!\d))/g, ".");
|
||||||
|
return parts.join(",");
|
||||||
|
}
|
||||||
|
return value
|
||||||
|
}
|
||||||
|
|
||||||
$(function () {
|
$(function () {
|
||||||
$('#bulkEdit').click(function () {
|
$('#bulkEdit').click(function () {
|
||||||
|
|
|
@ -72,7 +72,10 @@
|
||||||
{{ Form::label('default_currency', trans('admin/settings/general.default_currency')) }}
|
{{ Form::label('default_currency', trans('admin/settings/general.default_currency')) }}
|
||||||
</div>
|
</div>
|
||||||
<div class="col-md-9">
|
<div class="col-md-9">
|
||||||
{{ Form::text('default_currency', old('default_currency', $setting->default_currency), array('class' => 'form-control','placeholder' => 'USD', 'maxlength'=>'3', 'style'=>'width: 60px;')) }}
|
{{ Form::text('default_currency', old('default_currency', $setting->default_currency), array('class' => 'form-control select2-container','placeholder' => 'USD', 'maxlength'=>'3', 'style'=>'width: 60px; display: inline-block; ')) }}
|
||||||
|
|
||||||
|
{!! Form::digit_separator('digit_separator', old('digit_separator', $setting->digit_separator), 'select2') !!}
|
||||||
|
|
||||||
{!! $errors->first('default_currency', '<span class="alert-msg" aria-hidden="true">:message</span>') !!}
|
{!! $errors->first('default_currency', '<span class="alert-msg" aria-hidden="true">:message</span>') !!}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
Loading…
Reference in a new issue