Skip to content

Commit b161a38

Browse files
committed
Add licenses.reassignable migration
Implement licenses.reassignable View edit for licenses.reassignable Add licenses.reassignable to LicensesController Disable Check In when !license->reassignable Validate license check-in post
1 parent aad4734 commit b161a38

File tree

5 files changed

+70
-2
lines changed

5 files changed

+70
-2
lines changed

app/controllers/admin/LicensesController.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
use Datatable;
2323
use Slack;
2424
use Config;
25+
use Session;
2526

2627
class LicensesController extends AdminController
2728
{
@@ -229,6 +230,7 @@ public function postEdit($licenseId = null)
229230
$license->depreciation_id = e(Input::get('depreciation_id'));
230231
$license->purchase_order = e(Input::get('purchase_order'));
231232
$license->maintained = e(Input::get('maintained'));
233+
$license->reassignable = e(Input::get('reassignable'));
232234

233235
if ( e(Input::get('supplier_id')) == '') {
234236
$license->supplier_id = NULL;
@@ -269,6 +271,12 @@ public function postEdit($licenseId = null)
269271
$license->maintained = e(Input::get('maintained'));
270272
}
271273

274+
if ( e(Input::get('reassignable')) == '') {
275+
$license->reassignable = 0;
276+
} else {
277+
$license->reassignable = e(Input::get('reassignable'));
278+
}
279+
272280
if ( e(Input::get('purchase_order')) == '') {
273281
$license->purchase_order = '';
274282
} else {
@@ -607,6 +615,12 @@ public function postCheckin($seatId = null, $backto = null)
607615

608616
$license = License::find($licenseseat->license_id);
609617

618+
if(!$license->reassignable) {
619+
// Not allowed to checkin
620+
Session::flash('error', 'License not reassignable.');
621+
return Redirect::back()->withInput();
622+
}
623+
610624
// Declare the rules for the form validation
611625
$rules = array(
612626
'note' => 'alpha_space',
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
<?php
2+
3+
use Illuminate\Database\Schema\Blueprint;
4+
use Illuminate\Database\Migrations\Migration;
5+
6+
class AddReassignableToLicenses extends Migration {
7+
8+
/**
9+
* Run the migrations.
10+
*
11+
* @return void
12+
*/
13+
public function up()
14+
{
15+
Schema::table('licenses', function(Blueprint $table)
16+
{
17+
$table->boolean('reassignable')->default(true);
18+
});
19+
}
20+
21+
/**
22+
* Reverse the migrations.
23+
*
24+
* @return void
25+
*/
26+
public function down()
27+
{
28+
Schema::table('licenses', function(Blueprint $table)
29+
{
30+
//
31+
$table->dropColumn('reassignable');
32+
});
33+
}
34+
35+
}

app/lang/en/admin/licenses/form.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
'depreciation' => 'Depreciation',
1111
'expiration' => 'Expiration Date',
1212
'maintained' => 'Maintained',
13+
'reassignable' => 'Reassignable',
1314
'name' => 'Software Name',
1415
'no_depreciation' => 'Do Not Depreciate',
1516
'notes' => 'Notes',

app/views/backend/licenses/edit.blade.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,15 @@
8484
</div>
8585
</div>
8686

87+
<!-- Reassignable -->
88+
<div class="form-group {{ $errors->has('reassignable') ? ' has-error' : '' }}">
89+
<label for="reassignable" class="col-md-3 control-label">@lang('admin/licenses/form.reassignable')</label>
90+
<div class="col-md-7 input-group">
91+
{{ Form::Checkbox('reassignable', '1', Input::old('reassignable', $license->reassignable)) }}
92+
@lang('general.yes')
93+
</div>
94+
</div>
95+
8796
<!-- Supplier -->
8897
<div class="form-group {{ $errors->has('supplier_id') ? ' has-error' : '' }}">
8998
<label for="supplier_id" class="col-md-3 control-label">@lang('admin/licenses/form.supplier')</label>

app/views/backend/licenses/view.blade.php

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -134,8 +134,13 @@
134134
</td>
135135
<td>
136136
@if (($licensedto->assigned_to) || ($licensedto->asset_id))
137-
<a href="{{ route('checkin/license', $licensedto->id) }}" class="btn btn-primary btn-sm">
138-
@lang('general.checkin')</a>
137+
@if ($license->reassignable)
138+
<a href="{{ route('checkin/license', $licensedto->id) }}" class="btn btn-primary btn-sm">
139+
@lang('general.checkin')
140+
</a>
141+
@else
142+
<span>Assigned</span>
143+
@endif
139144
@else
140145
<a href="{{ route('checkout/license', $licensedto->id) }}" class="btn btn-info btn-sm">
141146
@lang('general.checkout')</a>
@@ -333,6 +338,10 @@
333338
{{{ $license->seats }}} </li>
334339
@endif
335340

341+
<li><strong>@lang('admin/licenses/form.reassignable'):</strong>
342+
{{ $license->reassignable ? 'Yes' : 'No' }}
343+
</li>
344+
336345
@if ($license->notes)
337346
<li><strong>@lang('admin/licenses/form.notes'):</strong>
338347
<li class="break-word">{{ nl2br(e($license->notes)) }}</li>

0 commit comments

Comments
 (0)