diff --git a/app/controllers/admin/LicensesController.php b/app/controllers/admin/LicensesController.php index b1a64d214882..c9b983ca8c58 100644 --- a/app/controllers/admin/LicensesController.php +++ b/app/controllers/admin/LicensesController.php @@ -287,6 +287,7 @@ public function postCheckout($assetId) $logaction->asset_id = $license->id; $logaction->checkedout_to = $license->assigned_to; $logaction->location_id = $assigned_to->location_id; + $logaction->asset_type = 'software'; $logaction->user_id = Sentry::getUser()->id; $log = $logaction->logaction('checkout'); @@ -320,8 +321,8 @@ public function postCheckin($assetId) if($license->save()) { $logaction->asset_id = $license->id; - $logaction->location_id = NULL; + $logaction->asset_type = 'software'; $logaction->user_id = Sentry::getUser()->id; $log = $logaction->logaction('checkin from'); @@ -341,13 +342,13 @@ public function postCheckin($assetId) **/ public function getView($licenseId = null) { - $license = Asset::find($licenseId); + $license = License::find($licenseId); if (isset($license->id)) { return View::make('backend/licenses/view', compact('license')); } else { // Prepare the error message - $error = Lang::get('admin/licenses/message.does_not_exist', compact('id' )); + $error = Lang::get('admin/licenses/message.does_not_exist', compact('id')); // Redirect to the user management page return Redirect::route('licenses')->with('error', $error); diff --git a/app/models/License.php b/app/models/License.php index 0a57414a8b49..05e046a6e901 100644 --- a/app/models/License.php +++ b/app/models/License.php @@ -29,7 +29,7 @@ public function assignedusers() **/ public function assetloc() { - return $this->assigneduser->hasOne('Location'); + return $this->assignedusers->hasOne('Location'); } /** @@ -38,7 +38,7 @@ public function assetloc() public function assetlog() { return $this->hasMany('Actionlog','asset_id') - ->where('assigned_to', '=', '0') + ->where('checkedout_to', '=', '0') ->orderBy('added_on', 'desc'); } @@ -72,6 +72,37 @@ public static function availassetcount() } + public function availcount() + { + return DB::table('license_seats') + ->where('assigned_to', '=', '0') + ->where('license_id', '=', $this->id) + ->whereNull('deleted_at','and') + ->count(); + } + + + public function assignedcount() + { + return DB::table('license_seats') + ->where('assigned_to', '>', '0') + ->where('license_id', '=', $this->id) + ->whereNull('deleted_at','and') + ->count(); + } + + public function totalcount() + { + $avail = $this->availcount(); + $taken = $this->assignedcount(); + $diff = ($avail + $taken); + return $diff; + } + + public function licenseseats() + { + return $this->hasMany('LicenseSeat'); + } } diff --git a/app/models/LicenseSeat.php b/app/models/LicenseSeat.php index 9d2321ad2777..ae0ce4441304 100644 --- a/app/models/LicenseSeat.php +++ b/app/models/LicenseSeat.php @@ -3,10 +3,14 @@ class LicenseSeat extends Elegant { protected $table = 'license_seats'; - public function assignedusers() - { - return $this->belongsToMany('LicenseSeat', 'assigned_to'); - } + public function license() + { + return $this->belongsTo('License'); + } + public function user() + { + return $this->belongsTo('User','assigned_to'); + } } \ No newline at end of file diff --git a/app/views/backend/licenses/edit.blade.php b/app/views/backend/licenses/edit.blade.php index 4c2a7c539683..c189073bf2d9 100755 --- a/app/views/backend/licenses/edit.blade.php +++ b/app/views/backend/licenses/edit.blade.php @@ -50,23 +50,27 @@ {{ $errors->first('serial', ':message') }} - +
+ +
+ + {{ $errors->first('license_name', ':message') }} +
+
- +
{{ $errors->first('license_email', ':message') }}
- -
- +
+
- - {{ $errors->first('license_name', ':message') }} + + {{ $errors->first('seats', ':message') }}
-
@@ -74,8 +78,6 @@ {{ $errors->first('order_number', ':message') }}
- -
diff --git a/app/views/backend/licenses/index.blade.php b/app/views/backend/licenses/index.blade.php index 003c60ac78a7..751a22ef33ce 100755 --- a/app/views/backend/licenses/index.blade.php +++ b/app/views/backend/licenses/index.blade.php @@ -23,7 +23,8 @@ - + + @@ -33,35 +34,68 @@ + + @foreach ($licenses as $license) - - - - - - - - - - - + + + + + + + + + + + + @if ($license->licenseseats) + + @foreach ($license->licenseseats as $licensedto) + + + + + + + + + + + + + + + @endforeach + @endif + + @endforeach + + + + + + +
@lang('admin/licenses/table.title')@lang('admin/licenses/table.seats')@lang('admin/licenses/table.title') @lang('admin/licenses/table.serial') @lang('admin/licenses/table.license_name') @lang('admin/licenses/table.license_email')
{{ $license->name }}{{ $license->serial }}{{ $license->license_name }}{{ $license->license_email }} - @if ($license->assigned_to != 0) - - {{ $license->assigneduser->fullName() }} - - @endif - - @if ($license->assigned_to != 0) - Checkin - @else - Checkout - @endif - - @lang('button.edit') - @lang('button.delete') - -
{{ $license->seats }}{{ $license->name }}{{ $license->serial }}{{ $license->license_name }}{{ $license->license_email }} + + @lang('button.edit') + @lang('button.delete') + + +
{{ $license->serial }}{{ $license->license_name }}{{ $license->license_email }} + @if ($licensedto->assigned_to) + + {{ $licensedto->user->fullName() }} + + @endif + + @if ($licensedto->assigned_to) + Checkin + @else + Checkout + @endif + +
diff --git a/app/views/backend/licenses/view.blade.php b/app/views/backend/licenses/view.blade.php index 6af5bddd5bb7..57f6093c62ba 100644 --- a/app/views/backend/licenses/view.blade.php +++ b/app/views/backend/licenses/view.blade.php @@ -28,11 +28,28 @@
  • Edit License
  • - - +
    +
    +
    + @if ($license->serial) +

    Serial: {{ $license->serial }}
    + @endif + @if ($license->license_name) + License Name: {{ $license->license_name }}
    + @endif + @if ($license->license_email) + License Email: {{ $license->license_email }}
    + @endif + @if ($license->purchase_date) + Purchase Date: {{ $license->purchase_date }}
    + @endif +

    +
    +
    + @@ -106,6 +123,8 @@
    + + @if ((isset($license->assigned_to ) && ($license->assigned_to > 0)))

    Checked Out To: