Merge branch 'develop'
This commit is contained in:
commit
baf51eb430
14 changed files with 159 additions and 50 deletions
|
@ -731,5 +731,62 @@ class Helper
|
|||
}
|
||||
|
||||
|
||||
// Nicked from Drupal :)
|
||||
// Returns a file size limit in bytes based on the PHP upload_max_filesize
|
||||
// and post_max_size
|
||||
public static function file_upload_max_size() {
|
||||
static $max_size = -1;
|
||||
|
||||
if ($max_size < 0) {
|
||||
// Start with post_max_size.
|
||||
$post_max_size = Helper::parse_size(ini_get('post_max_size'));
|
||||
if ($post_max_size > 0) {
|
||||
$max_size = $post_max_size;
|
||||
}
|
||||
|
||||
// If upload_max_size is less, then reduce. Except if upload_max_size is
|
||||
// zero, which indicates no limit.
|
||||
$upload_max = Helper::parse_size(ini_get('upload_max_filesize'));
|
||||
if ($upload_max > 0 && $upload_max < $max_size) {
|
||||
$max_size = $upload_max;
|
||||
}
|
||||
}
|
||||
return $max_size;
|
||||
}
|
||||
|
||||
public static function file_upload_max_size_readable() {
|
||||
static $max_size = -1;
|
||||
|
||||
if ($max_size < 0) {
|
||||
// Start with post_max_size.
|
||||
$post_max_size = Helper::parse_size(ini_get('post_max_size'));
|
||||
if ($post_max_size > 0) {
|
||||
$max_size = ini_get('post_max_size');
|
||||
}
|
||||
|
||||
// If upload_max_size is less, then reduce. Except if upload_max_size is
|
||||
// zero, which indicates no limit.
|
||||
$upload_max = Helper::parse_size(ini_get('upload_max_filesize'));
|
||||
if ($upload_max > 0 && $upload_max < $max_size) {
|
||||
$max_size = ini_get('upload_max_filesize');
|
||||
}
|
||||
}
|
||||
return $max_size;
|
||||
}
|
||||
|
||||
public static function parse_size($size) {
|
||||
$unit = preg_replace('/[^bkmgtpezy]/i', '', $size); // Remove the non-unit characters from the size.
|
||||
$size = preg_replace('/[^0-9\.]/', '', $size); // Remove the non-numeric characters from the size.
|
||||
if ($unit) {
|
||||
// Find the position of the unit in the ordered string which is the power of magnitude to multiply a kilobyte by.
|
||||
return round($size * pow(1024, stripos('bkmgtpezy', $unit[0])));
|
||||
}
|
||||
else {
|
||||
return round($size);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -67,7 +67,7 @@ class ManufacturersController extends Controller
|
|||
public function store(ImageUploadRequest $request)
|
||||
{
|
||||
|
||||
$this->authorize('edit', Manufacturer::class);
|
||||
$this->authorize('create', Manufacturer::class);
|
||||
$manufacturer = new Manufacturer;
|
||||
$manufacturer->name = $request->input('name');
|
||||
$manufacturer->user_id = Auth::user()->id;
|
||||
|
|
|
@ -12,10 +12,12 @@ class AddRememberTokenToUsersTable extends Migration
|
|||
*/
|
||||
public function up()
|
||||
{
|
||||
if (!Schema::hasColumn('users', 'remember_token')) {
|
||||
Schema::table('users', function (Blueprint $table) {
|
||||
$table->text('remember_token')->nullable()->default(NULL);
|
||||
$table->text('remember_token')->nullable()->default(null);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
|
@ -25,7 +27,7 @@ class AddRememberTokenToUsersTable extends Migration
|
|||
public function down()
|
||||
{
|
||||
Schema::table('users', function (Blueprint $table) {
|
||||
//
|
||||
$table->dropColumn('remember_token');
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -32,6 +32,6 @@ class CreatePasswordResetsTable extends Migration
|
|||
*/
|
||||
public function down()
|
||||
{
|
||||
//
|
||||
Schema::dropIfExists('password_resets');
|
||||
}
|
||||
}
|
||||
|
|
File diff suppressed because one or more lines are too long
2
public/js/dist/all.js
vendored
2
public/js/dist/all.js
vendored
File diff suppressed because one or more lines are too long
|
@ -1,8 +1,9 @@
|
|||
/**
|
||||
* @author vincent loh <vincent.ml@gmail.com>
|
||||
* @version: v1.0.0
|
||||
* @version: v1.1.0
|
||||
* https://github.com/vinzloh/bootstrap-table/
|
||||
* Sticky header for bootstrap-table
|
||||
* @update J Manuel Corona <jmcg92@gmail.com>
|
||||
*/
|
||||
|
||||
(function ($) {
|
||||
|
@ -13,6 +14,12 @@
|
|||
stickyHeader: false
|
||||
});
|
||||
|
||||
var bootstrapVersion = 3;
|
||||
try {
|
||||
bootstrapVersion = parseInt($.fn.dropdown.Constructor.VERSION, 10);
|
||||
} catch (e) { }
|
||||
var hidden_class = bootstrapVersion > 3 ? 'd-none' : 'hidden';
|
||||
|
||||
var BootstrapTable = $.fn.bootstrapTable.Constructor,
|
||||
_initHeader = BootstrapTable.prototype.initHeader;
|
||||
|
||||
|
@ -20,17 +27,19 @@
|
|||
var that = this;
|
||||
_initHeader.apply(this, Array.prototype.slice.apply(arguments));
|
||||
|
||||
if (!this.options.stickyHeader) return;
|
||||
if (!this.options.stickyHeader) {
|
||||
return;
|
||||
}
|
||||
|
||||
var table = this.$tableBody.find('table');
|
||||
var table_id = table.attr('id');
|
||||
var header_id = table.attr('id') + '-sticky-header';
|
||||
var sticky_header_container_id = header_id +'-sticky-header-container';
|
||||
var anchor_begin_id = header_id +'_sticky_anchor_begin';
|
||||
var anchor_end_id = header_id +'_sticky_anchor_end';
|
||||
var table = this.$tableBody.find('table'),
|
||||
table_id = table.attr('id'),
|
||||
header_id = table.attr('id') + '-sticky-header',
|
||||
sticky_header_container_id = header_id +'-sticky-header-container',
|
||||
anchor_begin_id = header_id +'_sticky_anchor_begin',
|
||||
anchor_end_id = header_id +'_sticky_anchor_end';
|
||||
// add begin and end anchors to track table position
|
||||
|
||||
table.before(sprintf('<div id="%s" class="hidden"></div>', sticky_header_container_id));
|
||||
table.before(sprintf('<div id="%s" class="%s"></div>', sticky_header_container_id, hidden_class));
|
||||
table.before(sprintf('<div id="%s"></div>', anchor_begin_id));
|
||||
table.after(sprintf('<div id="%s"></div>', anchor_end_id));
|
||||
|
||||
|
@ -38,7 +47,7 @@
|
|||
|
||||
// clone header just once, to be used as sticky header
|
||||
// deep clone header. using source header affects tbody>td width
|
||||
this.$stickyHeader = $($('#'+header_id).clone());
|
||||
this.$stickyHeader = $($('#'+header_id).clone(true, true));
|
||||
// avoid id conflict
|
||||
this.$stickyHeader.removeAttr('id');
|
||||
|
||||
|
@ -48,7 +57,12 @@
|
|||
// render sticky when table scroll left-right
|
||||
table.closest('.fixed-table-container').find('.fixed-table-body').on('scroll.'+table_id, table, match_position_x);
|
||||
|
||||
function render_sticky_header(event){
|
||||
this.$el.on('all.bs.table', function (e) {
|
||||
that.$stickyHeader = $($('#'+header_id).clone(true, true));
|
||||
that.$stickyHeader.removeAttr('id');
|
||||
});
|
||||
|
||||
function render_sticky_header(event) {
|
||||
var table = event.data;
|
||||
var table_header_id = table.find('thead').attr('id');
|
||||
// console.log('render_sticky_header for > '+table_header_id);
|
||||
|
@ -75,7 +89,7 @@
|
|||
$(item).css('min-width', $('#'+table_header_id+' tr').eq(0).find('th').eq(index).css('width'));
|
||||
});
|
||||
// match bootstrap table style
|
||||
$("#"+sticky_header_container_id).removeClass('hidden').addClass("fix-sticky fixed-table-container") ;
|
||||
$("#"+sticky_header_container_id).removeClass(hidden_class).addClass("fix-sticky fixed-table-container") ;
|
||||
// stick it in position
|
||||
$("#"+sticky_header_container_id).css('top', header_height + 'px');
|
||||
// create scrollable container for header
|
||||
|
@ -86,7 +100,7 @@
|
|||
match_position_x(event);
|
||||
} else {
|
||||
// hide sticky
|
||||
$("#"+sticky_header_container_id).removeClass("fix-sticky").addClass('hidden');
|
||||
$("#"+sticky_header_container_id).removeClass("fix-sticky").addClass(hidden_class);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
"/css/app.css.map": "/css/app.css.map?id=bdbe05e6ecd70ccfac72",
|
||||
"/css/overrides.css.map": "/css/overrides.css.map?id=898c91d4a425b01b589b",
|
||||
"/css/dist/all.css": "/css/dist/all.css?id=dc1449877e0f8abedc47",
|
||||
"/js/dist/all.js": "/js/dist/all.js?id=4e5e7295e9a59e718567",
|
||||
"/js/dist/all.js": "/js/dist/all.js?id=d3af8331997bd82e4ec4",
|
||||
"/css/build/all.css": "/css/build/all.css?id=dc1449877e0f8abedc47",
|
||||
"/js/build/all.js": "/js/build/all.js?id=4e5e7295e9a59e718567"
|
||||
"/js/build/all.js": "/js/build/all.js?id=d3af8331997bd82e4ec4"
|
||||
}
|
|
@ -322,6 +322,25 @@ $(document).ready(function () {
|
|||
// ------------------------------------------------
|
||||
|
||||
|
||||
// File size validation
|
||||
$('#uploadFile').bind('change', function() {
|
||||
$('#upload-file-status').removeClass('text-success').removeClass('text-danger');
|
||||
$('.goodfile').remove();
|
||||
$('.badfile').remove();
|
||||
|
||||
var max_size = $('#uploadFile').data('maxsize');
|
||||
var actual_size = this.files[0].size;
|
||||
|
||||
if (actual_size > max_size) {
|
||||
$('#upload-file-status').addClass('text-danger').removeClass('help-block').prepend('<i class="badfile fa fa-times"></i> ');
|
||||
} else {
|
||||
$('#upload-file-status').addClass('text-success').removeClass('help-block').prepend('<i class="goodfile fa fa-check"></i> ');
|
||||
}
|
||||
$('#upload-file-info').html(this.files[0].name);
|
||||
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -97,7 +97,7 @@
|
|||
'image' => 'Image',
|
||||
'image_delete' => 'Delete Image',
|
||||
'image_upload' => 'Upload Image',
|
||||
'image_filetypes_help' => 'Accepted filetypes are jpg, png, gif, and svg.',
|
||||
'image_filetypes_help' => 'Accepted filetypes are jpg, png, gif, and svg. Max upload size allowed is :size.',
|
||||
'import' => 'Import',
|
||||
'import-history' => 'Import History',
|
||||
'asset_maintenance' => 'Asset Maintenance',
|
||||
|
|
|
@ -34,6 +34,15 @@
|
|||
|
||||
<div class="row">
|
||||
|
||||
@if (!$asset->model)
|
||||
<div class="col-md-12">
|
||||
<div class="callout callout-danger">
|
||||
<h4>NO MODEL ASSOCIATED</h4>
|
||||
<p>This will break things in weird and horrible ways. Edit this asset now to assign it a model. </p>
|
||||
</div>
|
||||
</div>
|
||||
@endif
|
||||
|
||||
@if ($asset->deleted_at!='')
|
||||
<div class="col-md-12">
|
||||
<div class="alert alert-danger">
|
||||
|
@ -148,7 +157,7 @@
|
|||
</tr>
|
||||
@endif
|
||||
|
||||
@if ($asset->model->manufacturer)
|
||||
@if (($asset->model) && ($asset->model->manufacturer))
|
||||
<tr>
|
||||
<td>{{ trans('admin/hardware/form.manufacturer') }}</td>
|
||||
<td>
|
||||
|
@ -162,21 +171,21 @@
|
|||
<li> {{ $asset->model->manufacturer->name }}</li>
|
||||
@endcan
|
||||
|
||||
@if ($asset->model->manufacturer->url)
|
||||
@if (($asset->model) && ($asset->model->manufacturer->url))
|
||||
<li><i class="fa fa-globe"></i> <a href="{{ $asset->model->manufacturer->url }}">{{ $asset->model->manufacturer->url }}</a></li>
|
||||
@endif
|
||||
|
||||
@if ($asset->model->manufacturer->support_url)
|
||||
@if (($asset->model) && ($asset->model->manufacturer->support_url))
|
||||
<li><i class="fa fa-life-ring"></i> <a href="{{ $asset->model->manufacturer->support_url }}">{{ $asset->model->manufacturer->support_url }}</a></li>
|
||||
@endif
|
||||
|
||||
@if ($asset->model->manufacturer->support_phone)
|
||||
@if (($asset->model) && ($asset->model->manufacturer->support_phone))
|
||||
<li><i class="fa fa-phone"></i>
|
||||
<a href="tel:{{ $asset->model->manufacturer->support_phone }}">{{ $asset->model->manufacturer->support_phone }}</a>
|
||||
</li>
|
||||
@endif
|
||||
|
||||
@if ($asset->model->manufacturer->support_email)
|
||||
@if (($asset->model) && ($asset->model->manufacturer->support_email))
|
||||
<li><i class="fa fa-envelope"></i> <a href="mailto:{{ $asset->model->manufacturer->support_email }}">{{ $asset->model->manufacturer->support_email }}</a></li>
|
||||
@endif
|
||||
</ul>
|
||||
|
@ -188,7 +197,7 @@
|
|||
<td>
|
||||
{{ trans('general.category') }}</td>
|
||||
<td>
|
||||
@if ($asset->model->category)
|
||||
@if (($asset->model) && ($asset->model->category))
|
||||
|
||||
@can('view', \App\Models\Category::class)
|
||||
|
||||
|
@ -208,8 +217,12 @@
|
|||
|
||||
<tr>
|
||||
<td>
|
||||
{{ trans('admin/hardware/form.model') }}</td>
|
||||
{{ trans('admin/hardware/form.model') }}
|
||||
</td>
|
||||
<td>
|
||||
|
||||
@if ($asset->model)
|
||||
|
||||
@can('view', \App\Models\AssetModel::class)
|
||||
<a href="{{ route('models.show', $asset->model->id) }}">
|
||||
{{ $asset->model->name }}
|
||||
|
@ -217,6 +230,8 @@
|
|||
@else
|
||||
{{ $asset->model->name }}
|
||||
@endcan
|
||||
|
||||
@endif
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
|
@ -224,12 +239,12 @@
|
|||
<tr>
|
||||
<td>{{ trans('admin/models/table.modelnumber') }}</td>
|
||||
<td>
|
||||
{{ $asset->model->model_number }}
|
||||
{{ ($asset->model) ? $asset->model->model_number : ''}}
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
|
||||
@if ($asset->model->fieldset)
|
||||
@if (($asset->model) && ($asset->model->fieldset))
|
||||
@foreach($asset->model->fieldset->fields as $field)
|
||||
<tr>
|
||||
<td>
|
||||
|
@ -326,7 +341,7 @@
|
|||
</tr>
|
||||
@endif
|
||||
|
||||
@if ($asset->depreciation)
|
||||
@if (($asset->model) && ($asset->depreciation))
|
||||
<tr>
|
||||
<td>{{ trans('general.depreciation') }}</td>
|
||||
<td>
|
||||
|
@ -352,7 +367,7 @@
|
|||
</tr>
|
||||
@endif
|
||||
|
||||
@if ($asset->model->eol)
|
||||
@if (($asset->model) && ($asset->model->eol))
|
||||
<tr>
|
||||
<td>{{ trans('admin/hardware/form.eol_rate') }}</td>
|
||||
<td>
|
||||
|
@ -448,7 +463,7 @@
|
|||
<div class="col-md-4">
|
||||
@if ($asset->image)
|
||||
<img src="{{ url('/') }}/uploads/assets/{{{ $asset->image }}}" class="assetimg img-responsive">
|
||||
@elseif ($asset->model->image!='')
|
||||
@elseif (($asset->model) && ($asset->model->image!=''))
|
||||
<img src="{{ url('/') }}/uploads/models/{{{ $asset->model->image }}}" class="assetimg img-responsive">
|
||||
@endif
|
||||
|
||||
|
|
|
@ -823,5 +823,7 @@
|
|||
</script>
|
||||
@endif
|
||||
|
||||
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
|
|
@ -1,13 +1,13 @@
|
|||
<div class="form-group {{ $errors->has('image') ? 'has-error' : '' }}">
|
||||
<label class="col-md-3 control-label" for="image">{{ trans('general.image_upload') }}</label>
|
||||
<div class="col-md-5">
|
||||
<div class="col-md-9">
|
||||
<label class="btn btn-default">
|
||||
{{ trans('button.select_file') }}
|
||||
<input type="file" name="image" accept="image/gif,image/jpeg,image/png,image/svg"
|
||||
onchange="$('#upload-file-info').html(this.files[0].name)" style="display:none">
|
||||
<input type="file" name="image" id="uploadFile" data-maxsize="{{ \App\Helpers\Helper::file_upload_max_size() }}" accept="image/gif,image/jpeg,image/png,image/svg" style="display:none">
|
||||
</label>
|
||||
<span class='label label-default' id="upload-file-info"></span>
|
||||
<p class="help-block">{{ trans('general.image_filetypes_help') }}</p>
|
||||
|
||||
<p class="help-block" id="upload-file-status">{{ trans('general.image_filetypes_help', ['size' => \App\Helpers\Helper::file_upload_max_size_readable()]) }}</p>
|
||||
{!! $errors->first('image', '<span class="alert-msg">:message</span>') !!}
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
<div class="box-footer text-right">
|
||||
<a class="btn btn-link" href="{{ URL::previous() }}">{{ trans('button.cancel') }}</a>
|
||||
<a class="btn btn-link text-left" href="{{ URL::previous() }}">{{ trans('button.cancel') }}</a>
|
||||
<button type="submit" class="btn btn-success"><i class="fa fa-check icon-white"></i> {{ trans('general.save') }}</button>
|
||||
</div>
|
Loading…
Add table
Reference in a new issue