diff --git a/app/controllers/admin/LicensesController.php b/app/controllers/admin/LicensesController.php index 6a0fbc6163..30046537d6 100644 --- a/app/controllers/admin/LicensesController.php +++ b/app/controllers/admin/LicensesController.php @@ -1,5 +1,6 @@ 'Top Level') + License::lists('name', 'id'); + // Show the page $depreciation_list = array('0' => Lang::get('admin/licenses/form.no_depreciation')) + Depreciation::lists('name', 'id'); return View::make('backend/licenses/edit')->with('license_options',$license_options)->with('depreciation_list',$depreciation_list)->with('license',new License); @@ -79,6 +82,7 @@ class LicensesController extends AdminController $license->purchase_date = e(Input::get('purchase_date')); $license->purchase_cost = e(Input::get('purchase_cost')); $license->depreciation_id = e(Input::get('depreciation_id')); + $license->asset_id = e(Input::get('asset_id')); $license->user_id = Sentry::getId(); if (($license->purchase_date == "") || ($license->purchase_date == "0000-00-00")) { @@ -182,6 +186,7 @@ class LicensesController extends AdminController $license->notes = e(Input::get('notes')); $license->order_number = e(Input::get('order_number')); $license->depreciation_id = e(Input::get('depreciation_id')); + $license->asset_id = e(Input::get('asset_id')); // Update the asset data if ( e(Input::get('purchase_date')) == '') { @@ -317,8 +322,10 @@ class LicensesController extends AdminController // Get the dropdown of users and then pass it to the checkout view $users_list = array('' => 'Select a User') + DB::table('users')->select(DB::raw('concat (first_name," ",last_name) as full_name, id'))->whereNull('deleted_at')->lists('full_name', 'id'); + $asset_list = array('' => '') + Asset::orderBy('name', 'asc')->lists('name', 'id'); + //print_r($users); - return View::make('backend/licenses/checkout', compact('licenseseat'))->with('users_list',$users_list); + return View::make('backend/licenses/checkout', compact('licenseseat'))->with('users_list',$users_list)->with('asset_list',$asset_list); } diff --git a/app/database/seeds/LicenseSeatsSeeder.php b/app/database/seeds/LicenseSeatsSeeder.php index 239937445a..e7eb95215e 100644 --- a/app/database/seeds/LicenseSeatsSeeder.php +++ b/app/database/seeds/LicenseSeatsSeeder.php @@ -14,72 +14,79 @@ class LicenseSeatsSeeder extends Seeder $license_seats[] = array( 'license_id' => '1', 'assigned_to' => '1', - 'created_at' => $date->modify('-10 day'), - 'updated_at' => $date->modify('-3 day'), + 'created_at' => $date->modify('-10 day')->format('Y-m-d H:i:s'), + 'updated_at' => $date->modify('-3 day')->format('Y-m-d H:i:s'), 'deleted_at' => NULL, 'notes' => '', 'user_id' => '1', - ); - - $license_seats[] = array( - 'license_id' => '1', - 'assigned_to' => '0', - 'created_at' => $date->modify('-10 day'), - 'updated_at' => $date->modify('-3 day'), - 'deleted_at' => NULL, - 'notes' => '', - 'user_id' => '1', - ); - - $license_seats[] = array( - 'license_id' => '1', - 'assigned_to' => '0', - 'created_at' => $date->modify('-10 day'), - 'updated_at' => $date->modify('-3 day'), - 'deleted_at' => NULL, - 'notes' => '', - 'user_id' => '1', - ); - - $license_seats[] = array( - 'license_id' => '1', - 'assigned_to' => '0', - 'created_at' => $date->modify('-10 day'), - 'updated_at' => $date->modify('-3 day'), - 'deleted_at' => NULL, - 'notes' => '', - 'user_id' => '1', + 'asset_id' => '1', ); $license_seats[] = array( 'license_id' => '1', 'assigned_to' => '2', - 'created_at' => $date->modify('-10 day'), - 'updated_at' => $date->modify('-3 day'), + 'created_at' => $date->modify('-10 day')->format('Y-m-d H:i:s'), + 'updated_at' => $date->modify('-3 day')->format('Y-m-d H:i:s'), 'deleted_at' => NULL, 'notes' => '', 'user_id' => '1', + 'asset_id' => '2', + ); + + $license_seats[] = array( + 'license_id' => '1', + 'assigned_to' => '3', + 'created_at' => $date->modify('-10 day')->format('Y-m-d H:i:s'), + 'updated_at' => $date->modify('-3 day')->format('Y-m-d H:i:s'), + 'deleted_at' => NULL, + 'notes' => '', + 'user_id' => '1', + 'asset_id' => '3', + ); + + $license_seats[] = array( + 'license_id' => '1', + 'assigned_to' => '0', + 'created_at' => $date->modify('-10 day')->format('Y-m-d H:i:s'), + 'updated_at' => $date->modify('-3 day')->format('Y-m-d H:i:s'), + 'deleted_at' => NULL, + 'notes' => '', + 'user_id' => '1', + 'asset_id' => NULL, + ); + + $license_seats[] = array( + 'license_id' => '1', + 'assigned_to' => '2', + 'created_at' => $date->modify('-10 day')->format('Y-m-d H:i:s'), + 'updated_at' => $date->modify('-3 day')->format('Y-m-d H:i:s'), + 'deleted_at' => NULL, + 'notes' => '', + 'user_id' => '1', + 'asset_id' => NULL, ); $license_seats[] = array( 'license_id' => '2', 'assigned_to' => '1', - 'created_at' => $date->modify('-10 day'), - 'updated_at' => $date->modify('-3 day'), + 'created_at' => $date->modify('-10 day')->format('Y-m-d H:i:s'), + 'updated_at' => $date->modify('-3 day')->format('Y-m-d H:i:s'), 'deleted_at' => NULL, 'notes' => '', 'user_id' => '1', + 'asset_id' => NULL, ); // Pending (status_id is null, assigned_to = 0) $license_seats[] = array( 'license_id' => '2', 'assigned_to' => '0', - 'created_at' => $date->modify('-10 day'), - 'updated_at' => $date->modify('-3 day'), + 'created_at' => $date->modify('-10 day')->format('Y-m-d H:i:s'), + 'updated_at' => $date->modify('-3 day')->format('Y-m-d H:i:s'), 'deleted_at' => NULL, 'notes' => '', 'user_id' => '1', + 'asset_id' => NULL, ); diff --git a/app/lang/en/admin/licenses/form.php b/app/lang/en/admin/licenses/form.php index 77ecae052f..5d9ee6c5aa 100644 --- a/app/lang/en/admin/licenses/form.php +++ b/app/lang/en/admin/licenses/form.php @@ -2,6 +2,7 @@ return array( + 'asset' => 'Asset', 'checkin' => 'Checkin', 'checkin' => 'Checkin', 'cost' => 'Purchase Cost', diff --git a/app/models/Asset.php b/app/models/Asset.php index 8d2a67cb92..8d6bced3ef 100644 --- a/app/models/Asset.php +++ b/app/models/Asset.php @@ -149,6 +149,25 @@ class Asset extends Elegant return $this->belongsTo('Model','model_id'); } + /** + * Get the license seat information + **/ + public function licenseseats() + { + return $this->hasMany('LicenseSeat','id')->withTrashed(); + } + + /** + * Info on the license seat's parent licenses + * ????????? + **/ + public function licenses() + { + return LicenseSeat::license(); + // return $this->belongsTo('LicenseSeat','id')->withTrashed(); + } + + public function supplier() { return $this->belongsTo('Supplier','supplier_id'); diff --git a/app/models/License.php b/app/models/License.php index b457ad6e86..b6e5e10a47 100644 --- a/app/models/License.php +++ b/app/models/License.php @@ -24,7 +24,6 @@ class License extends Elegant } - /** * Get asset logs for this asset */ diff --git a/app/models/LicenseSeat.php b/app/models/LicenseSeat.php index f4d3b44e4a..5c5bd29b8c 100644 --- a/app/models/LicenseSeat.php +++ b/app/models/LicenseSeat.php @@ -15,4 +15,9 @@ class LicenseSeat extends Elegant return $this->belongsTo('User','assigned_to')->withTrashed(); } + public function asset() + { + return $this->belongsTo('Asset','asset_id')->withTrashed(); + } + } diff --git a/app/views/backend/hardware/view.blade.php b/app/views/backend/hardware/view.blade.php index 2b1f311567..9703764ca5 100644 --- a/app/views/backend/hardware/view.blade.php +++ b/app/views/backend/hardware/view.blade.php @@ -128,8 +128,50 @@ @endif + @if ($asset->licenses) +
| @lang('general.name') | +@lang('table.actions') | +
|---|---|
| {{{ $license->license_id->license()->name }}} | +@lang('general.checkin') + | +