Skip to content

Commit

Permalink
Update the migration to fix an issue with the improvement_time so it …
Browse files Browse the repository at this point in the history
…would be an integer

Created the view for improvements
Updated messages in language pack for additional items needed
Updated the asset view and supplier view to fix an issue
  • Loading branch information
vsposato committed Jun 27, 2015
1 parent cc67569 commit b7f050a
Show file tree
Hide file tree
Showing 8 changed files with 142 additions and 10 deletions.
23 changes: 20 additions & 3 deletions app/controllers/admin/ImprovementsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -85,12 +85,15 @@ public function getDatatable()
return $improvements->start_date->toDateString();
} )
->addColumn( 'completion_date', function ( $improvements ) {

return $improvements->completion_date->toDateString();
if (is_null($improvements->completion_date)) {
return null;
} else {
return $improvements->completion_date->toDateString();
}
} )
->addColumn( 'cost', function ( $improvements ) {

return sprintf( Lang::get( 'general.currency' ) . '%01.2f', $improvements->cost);
return sprintf( Lang::get( 'general.currency' ) . '%01.2f', $improvements->cost );
} )
->addColumn( $actions )
->searchColumns( 'asset', 'supplier', 'improvement_type', 'title', 'start_date',
Expand Down Expand Up @@ -234,6 +237,7 @@ public function postCreate()

/**
* getDelete
*
* @param $improvementId
*
* @return mixed
Expand All @@ -257,4 +261,17 @@ public function getDelete( $improvementId )
->with( 'success', Lang::get( 'admin/improvements/message.delete.success' ) );
}

public function getView( $improvementId )
{

// Check if the improvement exists
if (is_null( $improvement = Improvement::find( $improvementId ) )) {
// Redirect to the improvement management page
return Redirect::to( 'admin/improvements' )
->with( 'error', Lang::get( 'admin/improvements/message.not_found' ) );
}

return View::make('backend/improvements/view')->with('improvement', $improvement);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public function up()
$table->date( 'start_date' );
$table->date( 'completion_date' )
->nullable();
$table->decimal( 'improvement_time', 8, 2 )
$table->integer( 'improvement_time')
->nullable();
$table->longText( 'notes' )
->nullable();
Expand Down
1 change: 1 addition & 0 deletions app/lang/en/admin/improvements/form.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
'completion_date' => 'Completion Date',
'cost' => 'Cost',
'is_warranty' => 'Warranty Improvement',
'improvement_time' => 'Improvement Time (in days)',
'notes' => 'Notes',
'update' => 'Update Improvement',
'create' => 'Create Improvement'
Expand Down
2 changes: 2 additions & 0 deletions app/lang/en/admin/improvements/general.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,6 @@
return [
'improvements' => 'Improvements',
'edit' => 'Edit Improvement',
'delete' => 'Delete Improvement',
'view' => 'View Improvement Details'
];
10 changes: 6 additions & 4 deletions app/lang/en/admin/improvements/message.php
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
<?php

return [
'not_found' => 'Improvement you were looking for was not found!',
'delete' => [
'not_found' => 'Improvement you were looking for was not found!',
'delete' => [
'confirm' => 'Are you sure you wish to delete this improvement?',
'error' => 'There was an issue deleting the improvement. Please try again.',
'success' => 'The improvement was deleted successfully.'
],
'create' => [
'create' => [
'error' => 'Improvement was not created, please try again.',
'success' => 'Improvement created successfully.'
],

'improvement_incomplete' => 'Not Completed Yet',
'warranty' => 'Warranty',
'not_warranty' => 'Not Warranty',
];
2 changes: 1 addition & 1 deletion app/views/backend/hardware/view.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@
<td>{{{ $improvement->improvement_type }}}</td>
<td>{{{ Carbon::parse($improvement->start_date)->toDateString() }}}</td>
<td>{{{ Carbon::parse($improvement->completion_date)->toDateString() }}}</td>
<td>{{{ $improvement->is_warranty ? "Warranty" : "Not Warranty" }}}</td>
<td>{{{ $improvement->is_warranty ? Lang::get('admin/improvements/message.warranty') : Lang::get('admin/improvements/message.not_warranty') }}}</td>
<td>{{{ sprintf( Lang::get( 'general.currency' ) . '%01.2f', $improvement->cost) }}}</td>
<?php $totalCost += $improvement->cost; ?>
<td><a href="{{ route('update/improvement', $improvement->id) }}" class="btn btn-warning"><i class="fa fa-pencil icon-white"></i></a>
Expand Down
110 changes: 110 additions & 0 deletions app/views/backend/improvements/view.blade.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
<?php
use Carbon\Carbon;
?>
@extends('backend/layouts/default')

{{-- Page title --}}
@section('title')
@lang('admin/improvements/general.view') {{ $improvement->title }} ::
@parent
@stop

{{-- Page content --}}
@section('content')
<div class="row header">
<div class="col-md-12">
<h3 class="title">
@lang('admin/improvements/general.view')
{{{ " - " . $improvement->title }}}
</h3>

<div class="btn-group pull-right">

<div class="dropdown">
<button class="btn btn-default dropdown-toggle" data-toggle="dropdown">@lang('button.actions')
<span class="caret"></span>
</button>
<ul class="dropdown-menu pull-right" role="menu" aria-labelledby="dropdownMenu1">
<li role="presentation"><a href="{{ route('update/improvement', $improvement->id) }}">@lang('admin/improvements/general.edit')</a></li>
</ul>
</div>
</div>
</div>
</div>

<div class="user-profile ">
<div class="row profile">
<div class="col-md-9 bio">
<!-- 1st Row Begin -->
<div class="row">
<div class="col-md-12 col-sm-12" style="padding-bottom: 10px; margin-left: 15px; word-wrap: break-word;">
<strong>@lang('admin/improvements/form.improvement_type'): </strong>
{{{ $improvement->improvement_type }}}
</div>
</div>
<!-- 1st Row End -->
<!-- 2nd Row Begin -->
<div class="row">
<div class="col-md-3 col-sm-3" style="padding-bottom: 10px; margin-left: 15px; word-wrap: break-word;">
<strong>@lang('admin/improvements/table.asset_name'): </strong>
<a href="{{ route('view/hardware', $improvement->asset_id) }}">
{{{ $improvement->asset->name }}}
</a>
</div>
<div class="col-md-3 col-sm-3" style="padding-bottom: 10px; margin-left: 15px; word-wrap: break-word;">
<strong>@lang('admin/improvements/table.supplier_name'): </strong>
<a href="{{ route('view/supplier', $improvement->supplier_id) }}">
{{{ $improvement->supplier->name }}}
</a>
</div>
</div>
<!-- 2nd Row End -->
<!-- 3rd Row Begin -->
<div class="row">
<div class="col-md-3 col-sm-3" style="padding-bottom: 10px; margin-left: 15px; word-wrap: break-word;">
<strong>@lang('admin/improvements/form.start_date'): </strong>
<?php $startDate = Carbon::parse($improvement->start_date); ?>
{{{ $startDate->toDateString() }}}
</div>
<div class="col-md-3 col-sm-3" style="padding-bottom: 10px; margin-left: 15px; word-wrap: break-word;">
<strong>@lang('admin/improvements/form.completion_date'): </strong>
<?php if (is_null($improvement->completion_date)) {
$calculationEndDate = Carbon::now();
$completionDate = NULL;
} else {
$completionDate = Carbon::parse($improvement->start_date);
$calculationEndDate = $completionDate;
}
?>
{{{ $completionDate ? $completionDate->toDateString() : Lang::get('admin/improvements/message.improvement_incomplete') }}}
</div>
<div class="col-md-3 col-sm-3" style="padding-bottom: 10px; margin-left: 15px; word-wrap: break-word;">
<strong>@lang('admin/improvements/form.improvement_time'): </strong>
{{ $calculationEndDate->diffInDays($startDate) }}
</div>
</div>
<!-- 3rd Row End -->
<!-- 4th Row Begin -->
<div class="row">
<div class="col-md-3 col-sm-3" style="padding-bottom: 10px; margin-left: 15px; word-wrap: break-word;">
<strong>@lang('admin/improvements/form.cost'): </strong>
{{{ sprintf( Lang::get( 'general.currency' ) . '%01.2f', $improvement->cost) }}}
</div>
<div class="col-md-3 col-sm-3" style="padding-bottom: 10px; margin-left: 15px; word-wrap: break-word;">
<strong>@lang('admin/improvements/form.is_warranty'): </strong>
{{{ $improvement->is_warranty ? Lang::get('admin/improvements/message.warranty') : Lang::get('admin/improvements/message.not_warranty') }}}
</div>
</div>
<!-- 4th Row End -->
<!-- 5th Row Begin -->
<div class="row">
<div class="col-md-12 col-sm-12" style="padding-bottom: 10px; margin-left: 15px; word-wrap: break-word;">
<strong>@lang('admin/improvements/form.notes'): </strong>
{{{ $improvement->notes }}}
</div>
</div>
<!-- 5th Row End -->
</div> <!-- col-md-9 bio end -->
</div> <!-- row profile end -->
</div> <!-- user-profile end -->
@stop
2 changes: 1 addition & 1 deletion app/views/backend/suppliers/view.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@
<td>{{{ $improvement->improvement_type }}}</td>
<td>{{{ Carbon::parse($improvement->start_date)->toDateString() }}}</td>
<td>{{{ Carbon::parse($improvement->completion_date)->toDateString() }}}</td>
<td>{{{ $improvement->is_warranty ? "Warranty" : "Not Warranty" }}}</td>
<td>{{{ $improvement->is_warranty ? Lang::get('admin/improvements/message.warranty') : Lang::get('admin/improvements/message.not_warranty') }}}</td>
<td>{{{ sprintf( Lang::get( 'general.currency' ) . '%01.2f', $improvement->cost) }}}</td>
<?php $totalCost += $improvement->cost; ?>
<td><a href="{{ route('update/improvement', $improvement->id) }}" class="btn btn-warning"><i class="fa fa-pencil icon-white"></i></a>
Expand Down

0 comments on commit b7f050a

Please sign in to comment.