Merge branch 'refs/heads/develop'

This commit is contained in:
snipe
2013-11-25 13:18:49 -05:00
22 changed files with 411 additions and 110 deletions
@@ -413,7 +413,6 @@ class AssetsController extends AdminController {
return Redirect::route('assets')->with('error', $error);
}
}
@@ -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())
+6 -2
View File
@@ -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);
}
@@ -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);
}
}
}
@@ -0,0 +1,30 @@
<?php
use Illuminate\Database\Migrations\Migration;
class DropParentFromCategories extends Migration {
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('categories', function($table)
{
$table->dropColumn('parent');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
//
}
}
@@ -0,0 +1,38 @@
<?php
use Illuminate\Database\Migrations\Migration;
class AddDepreciateToAssets extends Migration {
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
//
Schema::table('assets', function($table)
{
$table->boolean('depreciate');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('assets', function($table)
{
$table->dropColumn('depreciate');
});
}
}
@@ -0,0 +1,38 @@
<?php
use Illuminate\Database\Migrations\Migration;
class AddDepreciateToLicensesTable extends Migration {
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
//
Schema::table('licenses', function($table)
{
$table->boolean('depreciate');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('licenses', function($table)
{
$table->dropColumn('depreciate');
});
}
}
+6 -2
View File
@@ -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');
}
}
+6 -9
View File
@@ -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');
}
}
+5
View File
@@ -104,5 +104,10 @@ class License extends Elegant {
return $this->hasMany('LicenseSeat');
}
public function depreciation()
{
return $this->belongsTo('Depreciation','id');
}
}
+22 -1
View File
@@ -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');
}
}
+1
View File
@@ -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'));
+5
View File
@@ -114,6 +114,11 @@ View Asset {{ $asset->asset_tag }} ::
<li>Warranty: {{ $asset->warranty_months }} months</li>
<li>Expires: {{ $asset->warrantee_expires() }}</li>
@endif
@if ($asset->depreciation)
<li>Depreciation: {{ $asset->depreciation->name }} ({{ $asset->depreciation->months }} months)</li>
@endif
</ul>
+32 -34
View File
@@ -12,46 +12,32 @@
{{-- Page content --}}
@section('content')
<div class="page-header">
<h3>
@if ($category->id)
Category Update
@else
Create Category
@endif
<div class="pull-right">
<a href="{{ route('categories') }}" class="btn-flat gray"><i class="icon-circle-arrow-left icon-white"></i> Back</a>
</div>
</h3>
</div>
<div id="pad-wrapper" class="user-profile">
<!-- header -->
<h3 class="name">Asset Categories
<div class="pull-right">
<a href="{{ route('categories') }}" class="btn-flat gray"><i class="icon-circle-arrow-left icon-white"></i> Back</a>
</div>
</h3>
<form class="form-horizontal" method="post" action="" autocomplete="off">
<div class="row-fluid profile">
<!-- bio, new note & orders column -->
<div class="span9 bio">
<div class="profile-box">
<br>
<form class="form-horizontal" method="post" action="" autocomplete="off">
<!-- CSRF Token -->
<input type="hidden" name="_token" value="{{ csrf_token() }}" />
<!-- Tabs Content -->
<div class="tab-content">
<div class="tab-pane active" id="tab-general">
<!-- Category Title -->
<div class="control-group {{ $errors->has('name') ? 'error' : '' }}">
<label class="control-label" for="name">Category Name</label>
<div class="controls">
<input type="text" name="name" id="name" value="{{ Input::old('name', $category->name) }}" />
{{ $errors->first('title', '<span class="help-inline">:message</span>') }}
</div>
</div>
<!-- Category Parent Title -->
<div class="control-group {{ $errors->has('parent') ? 'error' : '' }}">
<label class="control-label" for="parent">Category Parent</label>
<div class="controls">
{{ Form::select('parent', $category_options, Input::old('parent', $category->parent), array('class'=>'select2', 'style'=>'width:250px')) }}
{{ $errors->first('parent', '<span class="help-inline">:message</span>') }}
</div>
</div>
<!-- Category Title -->
<div class="control-group {{ $errors->has('name') ? 'error' : '' }}">
<label class="control-label" for="name">Category Name</label>
<div class="controls">
<input type="text" name="name" id="name" value="{{ Input::old('name', $category->name) }}" />
{{ $errors->first('title', '<span class="help-inline">:message</span>') }}
</div>
</div>
<!-- Form actions -->
<div class="control-group">
@@ -63,4 +49,16 @@
</form>
</div>
</div>
<!-- side address column -->
<div class="span3 address pull-right">
<br /><br />
<h6>About Asset Categories</h6>
<p>Asset categories help you organize your assets. Some
example categories might be &quot;Desktops&quot;, &quot;Laptops&quot;, &quot;Mobile Phones&quot;, &quot;Tablets&quot;,
and so on, but you can use asset categories any way that makes sense for you. </p>
</div>
@stop
+47 -44
View File
@@ -8,50 +8,53 @@ Asset Categories ::
{{-- Page content --}}
@section('content')
<div class="page-header">
<h3>
Asset Categories
<div id="pad-wrapper" class="user-profile">
<!-- header -->
<h3 class="name">Asset Categories
<div class="pull-right">
<a href="{{ route('create/category') }}" class="btn-flat success"><i class="icon-plus-sign icon-white"></i> Create New</a>
</div>
</h3>
<div class="pull-right">
<a href="{{ route('create/category') }}" class="btn-flat success"><i class="icon-plus-sign icon-white"></i> Create New</a>
</div>
</h3>
</div>
@if ($categories->getTotal() > Setting::getSettings()->per_page)
{{ $categories->links() }}
@endif
<div class="row-fluid table">
<table class="table table-hover">
<thead>
<tr>
<th class="span6">@lang('admin/categories/table.title')</th>
<th class="span2"><span class="line"></span>@lang('admin/categories/table.parent')</th>
<th class="span2"><span class="line"></span>@lang('table.actions')</th>
</tr>
</thead>
<tbody>
@foreach ($categories as $category)
<tr>
<td>{{ $category->name }}</td>
<td>
@if (is_object($category->parentname))
{{ $category->parentname->name }}
@else
Top Level
@endif
</td>
<td>
<a href="{{ route('update/category', $category->id) }}" class="btn-flat white"> @lang('button.edit')</a>
<a class="btn-flat danger delete-asset" data-toggle="modal" href="{{ route('delete/category', $category->id) }}" data-content="Are you sure you wish to delete the {{ $category->name }} category?" data-title="Delete this category?" onClick="return false;">@lang('button.delete')</a>
</td>
</tr>
@endforeach
</tbody>
</table>
</div>
<div class="row-fluid profile">
<!-- bio, new note & orders column -->
<div class="span9 bio">
<div class="profile-box">
<br>
<!-- checked out assets table -->
@if ($categories->getTotal() > Setting::getSettings()->per_page)
{{ $categories->links() }}
@endif
@stop
<table id="example">
<thead>
<tr role="row">
<th class="span6">@lang('admin/categories/table.title')</th>
<th class="span3">@lang('table.actions')</th>
</tr>
</thead>
<tbody>
@foreach ($categories as $category)
<tr>
<td>{{ $category->name }}</td>
<td>
<a href="{{ route('update/category', $category->id) }}" class="btn-flat white"> @lang('button.edit')</a>
<a class="btn-flat danger delete-asset" data-toggle="modal" href="{{ route('delete/category', $category->id) }}" data-content="Are you sure you wish to delete the {{ $category->name }} category?" data-title="Delete this category?" onClick="return false;">@lang('button.delete')</a>
</td>
</tr>
@endforeach
</tbody>
</table>
</div>
</div>
<!-- side address column -->
<div class="span3 address pull-right">
<br /><br />
<h6>About Asset Categories</h6>
<p>Asset categories help you organize your assets. Some
example categories might be &quot;Desktops&quot;, &quot;Laptops&quot;, &quot;Mobile Phones&quot;, &quot;Tablets&quot;,
and so on, but you can use asset categories any way that makes sense for you. </p>
</div>
@stop
+6 -2
View File
@@ -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"]]
});
+11
View File
@@ -86,6 +86,17 @@
</div>
</div>
<!-- Depreciation -->
<div class="control-group {{ $errors->has('depreciation_id') ? 'error' : '' }}">
<label class="control-label" for="parent">Depreciation</label>
<div class="controls">
<div class="field-box">
{{ Form::select('depreciation_id', $depreciation_list , Input::old('depreciation_id', $license->depreciation_id), array('class'=>'select2', 'style'=>'width:250px')) }}
{{ $errors->first('depreciation_id', '<span class="help-inline"><i class="icon-remove-sign"></i> :message</span>') }}
</div>
</div>
</div>
<div class="control-group {{ $errors->has('purchase_date') ? 'error' : '' }}">
<label class="control-label" for="purchase_date">Purchase Date</label>
<div class="controls">
+2 -2
View File
@@ -39,7 +39,6 @@ Licenses ::
@else
({{ $license->seats }} seats)
@endif
</td>
<td><a href="{{ route('view/license', $license->id) }}">{{ $license->serial }}</a></td>
<td></td>
@@ -57,7 +56,8 @@ Licenses ::
<tr>
<td><a href="{{ route('view/license', $license->id) }}">{{ $license->name }}</a>
(Seat {{ $count }})</td>
(Seat {{ $count }})
</td>
<td><a href="{{ route('view/license', $license->id) }}">{{ $license->serial }}</a></td>
<td>
@if ($licensedto->assigned_to)
@@ -163,6 +163,9 @@ View License {{ $license->name }} ::
@if ($license->seats)
<li>Seats: {{ $license->seats }} </li>
@endif
@if ($license->seats)
<li>Depreciation: {{ $license->depreciation->name }} ({{ $license->depreciation->months }} months)</li>
@endif
</ul>
</div>
+15 -7
View File
@@ -22,19 +22,27 @@ Asset Models ::
<thead>
<tr role="row">
<th class="span3">@lang('admin/models/table.title')</th>
<th class="span3"><span class="line"></span>@lang('admin/models/table.modelnumber')</th>
<th class="span1"><span class="line"></span>@lang('admin/models/table.numassets')</th>
<th class="span2"><span class="line"></span>@lang('admin/models/table.created_at')</th>
<th class="span3"><span class="line"></span>@lang('table.actions')</th>
<th class="span2">@lang('admin/models/table.modelnumber')</th>
<th class="span1">@lang('admin/models/table.numassets')</th>
<th class="span2">Depreciation</th>
<th class="span1">Category</th>
<th class="span2">@lang('table.actions')</th>
</tr>
</thead>
<tbody>
@foreach ($models as $model)
<tr>
<td>{{ $model->name }}</td>
<td><a href="{{ route('update/model', $model->id) }}">{{ $model->name }}</a></td>
<td>{{ $model->modelno }}</td>
<td>{{ ($model->assets->count()) }}</td>
<td>{{ $model->created_at->diffForHumans() }}</td>
<td><a href="{{ route('view/model', $model->id) }}">{{ ($model->assets->count()) }}</a></td>
<td>
@if ($model->depreciation)
{{ $model->depreciation->name }}
({{ $model->depreciation->months }} months)
@endif
</td>
<td>{{ $model->category->name }}</td>
<td>
<a href="{{ route('update/model', $model->id) }}" class="btn-flat white">@lang('button.edit')</a>
<a class="btn-flat danger delete-asset" data-toggle="modal" href="{{ route('delete/model', $model->id) }}" data-content="Are you sure you wish to delete the {{ $model->name }} model?" data-title="Delete {{ $model->name }}?" onClick="return false;">@lang('button.delete')</a>
+110
View File
@@ -0,0 +1,110 @@
@extends('backend/layouts/default')
{{-- Page title --}}
@section('title')
View Model {{ $model->model_tag }} ::
@parent
@stop
{{-- Page content --}}
@section('content')
<div id="pad-wrapper" class="user-profile">
<!-- header -->
<h3 class="name">History for {{ $model->name }}
<div class="btn-group pull-right">
<button class="btn glow">Actions</button>
<button class="btn glow dropdown-toggle" data-toggle="dropdown">
<span class="caret"></span>
</button>
<ul class="dropdown-menu">
<li><a href="{{ route('update/model', $model->id) }}">Edit Asset</a></li>
</ul>
</div>
</h3>
<div class="row-fluid profile">
<!-- bio, new note & orders column -->
<div class="span9 bio">
<div class="profile-box">
<br>
<!-- checked out models table -->
@if (count($model->assets) > 0)
<table id="example">
<thead>
<tr role="row">
<th class="span3">Name</th>
<th class="span3">Asset Tag</th>
<th class="span3">User</th>
<th class="span2">Actions</th>
</tr>
</thead>
<tbody>
@foreach ($model->assets as $modelassets)
<tr>
<td><a href="{{ route('view/asset', $modelassets->id) }}">{{ $modelassets->name }}</a></td>
<td><a href="{{ route('view/asset', $modelassets->id) }}">{{ $modelassets->asset_tag }}</a></td>
<td>
@if ($modelassets->assigneduser)
<a href="{{ route('view/user', $modelassets->assigned_to) }}">
{{ $modelassets->assigneduser->fullName() }}
</a>
@endif
</td>
<td>
@if ($modelassets->assigned_to != 0)
<a href="{{ route('checkin/asset', $modelassets->id) }}" class="btn-flat info">Checkin</a>
@else
<a href="{{ route('checkout/asset', $modelassets->id) }}" class="btn-flat success">Checkout</a>
@endif
</td>
</tr>
@endforeach
</tbody>
</table>
@else
<div class="col-md-6">
<div class="alert alert-info alert-block">
<i class="icon-info-sign"></i>
There are no results for your query.
</div>
</div>
@endif
</div>
</div>
<!-- side address column -->
<div class="span3 address pull-right">
<h6><br>More Info:</h6>
<ul>
@if ($model->manufacturer)
<li>Manufacturer: {{ $model->manufacturer->name }}</li>
@endif
@if ($model->modelno)
<li>Model No.: {{ $model->modelno }}</li>
@endif
@if ($model->depreciation)
<li>Depreciation: {{ $model->depreciation->name }} ({{ $model->depreciation->months }} months)</li>
@endif
</ul>
<ul>
<li><br><br />Blah blah blah.</li>
</ul>
</div>
@stop
+2 -2
View File
@@ -69,8 +69,8 @@ Depreciation Report
</td>
<td>{{ $asset->purchase_date }}</td>
<td class="align-right">${{ number_format($asset->purchase_cost) }}</td>
<td class="align-right">${{ number_format($asset->depreciation()) }}</td>
<td class="align-right">-${{ number_format(($asset->purchase_cost - $asset->depreciation())) }}</td>
<td class="align-right">${{ number_format($asset->depreciate()) }}</td>
<td class="align-right">-${{ number_format(($asset->purchase_cost - $asset->depreciate())) }}</td>
</tr>
@endforeach