Disable checkouts if there are none left
This commit is contained in:
@@ -11,6 +11,8 @@ return array(
|
||||
'require_acceptance' => 'Require users to confirm acceptance of assets in this category.',
|
||||
'no_default_eula' => 'No primary default EULA found. Add one in Settings.',
|
||||
'qty' => 'QTY',
|
||||
'total' => 'Total',
|
||||
'remaining' => 'Avail',
|
||||
'update' => 'Update Category',
|
||||
'use_default_eula' => 'Use the <a href="#" data-toggle="modal" data-target="#eulaModal">primary default EULA</a> instead.',
|
||||
'use_default_eula_disabled' => '<del>Use the primary default EULA instead.</del> No primary default EULA is set. Please add one in Settings.',
|
||||
|
||||
@@ -52,6 +52,13 @@ class Accessory extends Elegant
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public function numRemaining() {
|
||||
$checkedout = $this->users->count();
|
||||
$total = $this->qty;
|
||||
$remaining = $total - $checkedout;
|
||||
return $remaining;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -24,8 +24,9 @@
|
||||
<table id="example">
|
||||
<thead>
|
||||
<tr role="row">
|
||||
<th class="col-md-6" bSortable="true">@lang('admin/accessories/table.title')</th>
|
||||
<th class="col-md-2" bSortable="true">@lang('admin/accessories/general.qty')</th>
|
||||
<th class="col-md-5" bSortable="true">@lang('admin/accessories/table.title')</th>
|
||||
<th class="col-md-2" bSortable="true">@lang('admin/accessories/general.total')</th>
|
||||
<th class="col-md-2" bSortable="true">@lang('admin/accessories/general.remaining')</th>
|
||||
<th class="col-md-3 actions" bSortable="true">@lang('table.actions')</th>
|
||||
</tr>
|
||||
</thead>
|
||||
@@ -33,9 +34,10 @@
|
||||
@foreach ($accessories as $accessory)
|
||||
<tr>
|
||||
<td>{{{ $accessory->name }}}</td>
|
||||
<td>{{{ $accessory->qty }}}</td>
|
||||
<td>{{{ $accessory->qty }}} </td>
|
||||
<td>{{{ $accessory->numRemaining() }}} </td>
|
||||
<td>
|
||||
<a href="{{ route('checkout/accessory', $accessory->id) }}" class="btn btn-info btn-sm">@lang('general.checkout')</a>
|
||||
<a href="{{ route('checkout/accessory', $accessory->id) }}" class="btn btn-info btn-sm"{{ (($accessory->numRemaining()== 0) ? ' disabled' : '') }}>@lang('general.checkout')</a>
|
||||
<a href="{{ route('update/accessory', $accessory->id) }}" class="btn btn-warning btn-sm"><i class="fa fa-pencil icon-white"></i></a>
|
||||
<a data-html="false" class="btn delete-asset btn-danger btn-sm" data-toggle="modal" href="{{ route('delete/accessory', $accessory->id) }}" data-content="@lang('admin/accessories/message.delete.confirm')"
|
||||
data-title="@lang('general.delete') {{{ htmlspecialchars($accessory->name) }}}?" onClick="return false;"><i class="fa fa-trash icon-white"></i></a>
|
||||
|
||||
Reference in New Issue
Block a user