diff --git a/app/controllers/admin/AssetsController.php b/app/controllers/admin/AssetsController.php index 3983c7143a..f7fea069c1 100644 --- a/app/controllers/admin/AssetsController.php +++ b/app/controllers/admin/AssetsController.php @@ -413,7 +413,6 @@ class AssetsController extends AdminController { return Redirect::route('assets')->with('error', $error); } - } diff --git a/app/controllers/admin/CategoriesController.php b/app/controllers/admin/CategoriesController.php index 2750eb24f9..245e950c02 100644 --- a/app/controllers/admin/CategoriesController.php +++ b/app/controllers/admin/CategoriesController.php @@ -38,8 +38,7 @@ class CategoriesController extends AdminController { public function getCreate() { // Show the page - $category_options = array('0' => 'Top Level') + Category::lists('name', 'id'); - return View::make('backend/categories/edit')->with('category_options',$category_options)->with('category',new Category); + return View::make('backend/categories/edit')->with('category',new Category); } @@ -63,7 +62,6 @@ class CategoriesController extends AdminController { // Update the category data $category->name = e(Input::get('name')); - $category->parent = e(Input::get('parent')); $category->user_id = Sentry::getId(); // Was the asset created? @@ -134,7 +132,6 @@ class CategoriesController extends AdminController { // Update the category data $category->name = e(Input::get('name')); - $category->parent = e(Input::get('parent')); // Was the asset created? if($category->save()) diff --git a/app/controllers/admin/LicensesController.php b/app/controllers/admin/LicensesController.php index 92d7a3161d..8a91ae534b 100644 --- a/app/controllers/admin/LicensesController.php +++ b/app/controllers/admin/LicensesController.php @@ -10,6 +10,7 @@ use Actionlog; use DB; use Redirect; use LicenseSeat; +use Depreciation; use Setting; use Sentry; use Str; @@ -43,7 +44,9 @@ class LicensesController extends AdminController { { // Show the page $license_options = array('0' => 'Top Level') + License::lists('name', 'id'); - return View::make('backend/licenses/edit')->with('license_options',$license_options)->with('license',new License); + // Show the page + $depreciation_list = array('0' => 'Do Not Depreciate') + Depreciation::lists('name', 'id'); + return View::make('backend/licenses/edit')->with('license_options',$license_options)->with('depreciation_list',$depreciation_list)->with('license',new License); } @@ -128,7 +131,8 @@ class LicensesController extends AdminController { // Show the page $license_options = array('' => 'Top Level') + DB::table('assets')->where('id', '!=', $licenseId)->lists('name', 'id'); - return View::make('backend/licenses/edit', compact('license'))->with('license_options',$license_options); + $depreciation_list = array('0' => 'Do Not Depreciate') + Depreciation::lists('name', 'id'); + return View::make('backend/licenses/edit', compact('license'))->with('license_options',$license_options)->with('depreciation_list',$depreciation_list); } diff --git a/app/controllers/admin/ModelsController.php b/app/controllers/admin/ModelsController.php index cdfc0eb956..a7dac6e3e7 100644 --- a/app/controllers/admin/ModelsController.php +++ b/app/controllers/admin/ModelsController.php @@ -187,4 +187,29 @@ class ModelsController extends AdminController { } + /** + * Get the asset information to present to the model view page + * + * @param int $assetId + * @return View + **/ + public function getView($modelId = null) + { + $model = Model::find($modelId); + + if (isset($model->id)) { + return View::make('backend/models/view', compact('model')); + } else { + // Prepare the error message + $error = Lang::get('admin/models/message.does_not_exist', compact('id')); + + // Redirect to the user management page + return Redirect::route('models')->with('error', $error); + } + + + } + + + } diff --git a/app/database/migrations/2013_11_25_150450_drop_parent_from_categories.php b/app/database/migrations/2013_11_25_150450_drop_parent_from_categories.php new file mode 100644 index 0000000000..be8d754a8d --- /dev/null +++ b/app/database/migrations/2013_11_25_150450_drop_parent_from_categories.php @@ -0,0 +1,30 @@ +dropColumn('parent'); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + // + } + +} \ No newline at end of file diff --git a/app/database/migrations/2013_11_25_151920_add_depreciate_to_assets.php b/app/database/migrations/2013_11_25_151920_add_depreciate_to_assets.php new file mode 100644 index 0000000000..7d6ce6b301 --- /dev/null +++ b/app/database/migrations/2013_11_25_151920_add_depreciate_to_assets.php @@ -0,0 +1,38 @@ +boolean('depreciate'); + + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::table('assets', function($table) + { + $table->dropColumn('depreciate'); + }); + + + + } + +} \ No newline at end of file diff --git a/app/database/migrations/2013_11_25_152903_add_depreciate_to_licenses_table.php b/app/database/migrations/2013_11_25_152903_add_depreciate_to_licenses_table.php new file mode 100644 index 0000000000..078c356767 --- /dev/null +++ b/app/database/migrations/2013_11_25_152903_add_depreciate_to_licenses_table.php @@ -0,0 +1,38 @@ +boolean('depreciate'); + + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::table('licenses', function($table) + { + $table->dropColumn('depreciate'); + }); + + + + } + +} \ No newline at end of file diff --git a/app/models/Asset.php b/app/models/Asset.php index 08ff6fbf40..a249854be6 100644 --- a/app/models/Asset.php +++ b/app/models/Asset.php @@ -16,7 +16,7 @@ class Asset extends Elegant { /** * Handle depreciation */ - public function depreciation() + public function depreciate() { $depreciation_id = Model::find($this->model_id)->depreciation_id; if (isset($depreciation_id)) { @@ -108,12 +108,16 @@ class Asset extends Elegant { public function warrantee_expires() { - $date = date_create($this->purchase_date); date_add($date, date_interval_create_from_date_string($this->warranty_months.' months')); return date_format($date, 'Y-m-d'); } + public function depreciation() + { + return $this->belongsTo('Depreciation','id'); + } + } diff --git a/app/models/Category.php b/app/models/Category.php index fc5e117358..2c6943e444 100644 --- a/app/models/Category.php +++ b/app/models/Category.php @@ -12,20 +12,17 @@ class Category extends Elegant { ); - - /** - * Get the parent category name - */ - public function parentname() - { - return $this->belongsTo('Category','parent'); - } - public function has_models() { return $this->hasMany('Model', 'category_id')->count(); } + public function models() + { + return $this->hasMany('Model', 'category_id'); + + } + } diff --git a/app/models/License.php b/app/models/License.php index c258fe09ab..bd48dd1f6a 100644 --- a/app/models/License.php +++ b/app/models/License.php @@ -104,5 +104,10 @@ class License extends Elegant { return $this->hasMany('LicenseSeat'); } + public function depreciation() + { + return $this->belongsTo('Depreciation','id'); + } + } diff --git a/app/models/Model.php b/app/models/Model.php index 6508caed4a..ea0dbcc6e5 100644 --- a/app/models/Model.php +++ b/app/models/Model.php @@ -10,7 +10,28 @@ class Model extends Elegant { public function assets() { return $this->hasMany('Asset', 'model_id'); - } + public function category() + { + return $this->belongsTo('Category', 'category_id'); + } + + public function depreciation() + { + return $this->belongsTo('Depreciation','id'); + } + + public function adminuser() + { + return $this->belongsTo('User','user_id'); + } + + public function manufacturer() + { + return $this->belongsTo('Manufacturer','manufacturer_id'); + } + + + } diff --git a/app/routes.php b/app/routes.php index 7ac1b6ee6f..a853d63b58 100755 --- a/app/routes.php +++ b/app/routes.php @@ -23,6 +23,7 @@ Route::group(array('prefix' => 'assets'), function() Route::get('{modelId}/edit', array('as' => 'update/model', 'uses' => 'Controllers\Admin\ModelsController@getEdit')); Route::post('{modelId}/edit', 'Controllers\Admin\ModelsController@postEdit'); Route::get('{modelId}/delete', array('as' => 'delete/model', 'uses' => 'Controllers\Admin\ModelsController@getDelete')); + Route::get('{modelId}/view', array('as' => 'view/model', 'uses' => 'Controllers\Admin\ModelsController@getView')); }); Route::get('/', array('as' => 'assets', 'uses' => 'Controllers\Admin\AssetsController@getIndex')); diff --git a/app/views/backend/assets/view.blade.php b/app/views/backend/assets/view.blade.php index 1b7cb6328c..d69dbe1d81 100644 --- a/app/views/backend/assets/view.blade.php +++ b/app/views/backend/assets/view.blade.php @@ -114,6 +114,11 @@ View Asset {{ $asset->asset_tag }} ::
  • Warranty: {{ $asset->warranty_months }} months
  • Expires: {{ $asset->warrantee_expires() }}
  • @endif + + @if ($asset->depreciation) +
  • Depreciation: {{ $asset->depreciation->name }} ({{ $asset->depreciation->months }} months)
  • + @endif + diff --git a/app/views/backend/categories/edit.blade.php b/app/views/backend/categories/edit.blade.php index 33a9fa13d7..6ae26b9680 100755 --- a/app/views/backend/categories/edit.blade.php +++ b/app/views/backend/categories/edit.blade.php @@ -12,46 +12,32 @@ {{-- Page content --}} @section('content') - +
    + +

    Asset Categories +
    + Back +
    +

    -
    +
    + +
    +
    +
    + - -
    - -
    - -
    - -
    - - {{ $errors->first('title', ':message') }} -
    -
    - -
    - -
    - {{ Form::select('parent', $category_options, Input::old('parent', $category->parent), array('class'=>'select2', 'style'=>'width:250px')) }} - {{ $errors->first('parent', ':message') }} -
    -
    + +
    + +
    + + {{ $errors->first('title', ':message') }}
    +
    @@ -63,4 +49,16 @@ +
    +
    + + +
    +

    +
    About Asset Categories
    +

    Asset categories help you organize your assets. Some + example categories might be "Desktops", "Laptops", "Mobile Phones", "Tablets", + and so on, but you can use asset categories any way that makes sense for you.

    + +
    @stop diff --git a/app/views/backend/categories/index.blade.php b/app/views/backend/categories/index.blade.php index 24b62781da..2fdc4345bf 100755 --- a/app/views/backend/categories/index.blade.php +++ b/app/views/backend/categories/index.blade.php @@ -8,50 +8,53 @@ Asset Categories :: {{-- Page content --}} @section('content') - -@if ($categories->getTotal() > Setting::getSettings()->per_page) -{{ $categories->links() }} -@endif -
    - - - - - - - - - - @foreach ($categories as $category) - - - - - - @endforeach - -
    @lang('admin/categories/table.title')@lang('admin/categories/table.parent')@lang('table.actions')
    {{ $category->name }} - @if (is_object($category->parentname)) - {{ $category->parentname->name }} - @else - Top Level - @endif - - @lang('button.edit') - @lang('button.delete') -
    -
    +
    + +
    +
    +
    + -@if ($categories->getTotal() > Setting::getSettings()->per_page) -{{ $categories->links() }} -@endif -@stop + + + + + + + + + @foreach ($categories as $category) + + + + + @endforeach + +
    @lang('admin/categories/table.title')@lang('table.actions')
    {{ $category->name }} + @lang('button.edit') + @lang('button.delete') +
    + + +
    +
    + + +
    +

    +
    About Asset Categories
    +

    Asset categories help you organize your assets. Some + example categories might be "Desktops", "Laptops", "Mobile Phones", "Tablets", + and so on, but you can use asset categories any way that makes sense for you.

    + +
    +@stop \ No newline at end of file diff --git a/app/views/backend/layouts/default.blade.php b/app/views/backend/layouts/default.blade.php index 697fb36005..b9673b183b 100755 --- a/app/views/backend/layouts/default.blade.php +++ b/app/views/backend/layouts/default.blade.php @@ -300,7 +300,9 @@ $(document).ready(function() { $('#example').dataTable({ - "sPaginationType": "full_numbers" + "sPaginationType": "full_numbers", + "iDisplayLength": {{ Setting::getSettings()->per_page }}, + "aLengthMenu": [[{{ Setting::getSettings()->per_page }}, -1], [{{ Setting::getSettings()->per_page }}, "All"]] }); }); @@ -312,7 +314,9 @@ { "bSortable": false }, { "bSortable": false }, { "bSortable": false } - ] + ], + "iDisplayLength": {{ Setting::getSettings()->per_page }}, + "aLengthMenu": [[{{ Setting::getSettings()->per_page }}, -1], [{{ Setting::getSettings()->per_page }}, "All"]] }); diff --git a/app/views/backend/licenses/edit.blade.php b/app/views/backend/licenses/edit.blade.php index c189073bf2..88fcd16bc2 100755 --- a/app/views/backend/licenses/edit.blade.php +++ b/app/views/backend/licenses/edit.blade.php @@ -86,6 +86,17 @@
    + +
    + +
    +
    + {{ Form::select('depreciation_id', $depreciation_list , Input::old('depreciation_id', $license->depreciation_id), array('class'=>'select2', 'style'=>'width:250px')) }} + {{ $errors->first('depreciation_id', ' :message') }} +
    +
    +
    +
    diff --git a/app/views/backend/licenses/index.blade.php b/app/views/backend/licenses/index.blade.php index 1b62426365..665e3e74fc 100755 --- a/app/views/backend/licenses/index.blade.php +++ b/app/views/backend/licenses/index.blade.php @@ -39,7 +39,6 @@ Licenses :: @else ({{ $license->seats }} seats) @endif - {{ $license->serial }} @@ -57,7 +56,8 @@ Licenses :: {{ $license->name }} - (Seat {{ $count }}) + (Seat {{ $count }}) + {{ $license->serial }} @if ($licensedto->assigned_to) diff --git a/app/views/backend/licenses/view.blade.php b/app/views/backend/licenses/view.blade.php index d6a776607a..ee797be2e4 100644 --- a/app/views/backend/licenses/view.blade.php +++ b/app/views/backend/licenses/view.blade.php @@ -163,6 +163,9 @@ View License {{ $license->name }} :: @if ($license->seats)
  • Seats: {{ $license->seats }}
  • @endif + @if ($license->seats) +
  • Depreciation: {{ $license->depreciation->name }} ({{ $license->depreciation->months }} months)
  • + @endif
    diff --git a/app/views/backend/models/index.blade.php b/app/views/backend/models/index.blade.php index 9d28f6203c..151938a0af 100755 --- a/app/views/backend/models/index.blade.php +++ b/app/views/backend/models/index.blade.php @@ -22,19 +22,27 @@ Asset Models :: @lang('admin/models/table.title') - @lang('admin/models/table.modelnumber') - @lang('admin/models/table.numassets') - @lang('admin/models/table.created_at') - @lang('table.actions') + @lang('admin/models/table.modelnumber') + @lang('admin/models/table.numassets') + Depreciation + Category + @lang('table.actions') @foreach ($models as $model) - {{ $model->name }} + {{ $model->name }} {{ $model->modelno }} - {{ ($model->assets->count()) }} - {{ $model->created_at->diffForHumans() }} + {{ ($model->assets->count()) }} + + @if ($model->depreciation) + {{ $model->depreciation->name }} + ({{ $model->depreciation->months }} months) + @endif + + + {{ $model->category->name }} @lang('button.edit') @lang('button.delete') diff --git a/app/views/backend/models/view.blade.php b/app/views/backend/models/view.blade.php new file mode 100644 index 0000000000..dc6c374bfb --- /dev/null +++ b/app/views/backend/models/view.blade.php @@ -0,0 +1,110 @@ +@extends('backend/layouts/default') + +{{-- Page title --}} +@section('title') +View Model {{ $model->model_tag }} :: +@parent +@stop + +{{-- Page content --}} +@section('content') +