diff --git a/app/controllers/admin/ImprovementsController.php b/app/controllers/admin/ImprovementsController.php index e03e039851a4..938a63b474e5 100644 --- a/app/controllers/admin/ImprovementsController.php +++ b/app/controllers/admin/ImprovementsController.php @@ -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', @@ -234,6 +237,7 @@ public function postCreate() /** * getDelete + * * @param $improvementId * * @return mixed @@ -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); + } + } \ No newline at end of file diff --git a/app/database/migrations/2015_06_26_213716_create_improvements_table.php b/app/database/migrations/2015_06_26_213716_create_improvements_table.php index e210f408a3f9..58f5c18da503 100644 --- a/app/database/migrations/2015_06_26_213716_create_improvements_table.php +++ b/app/database/migrations/2015_06_26_213716_create_improvements_table.php @@ -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(); diff --git a/app/lang/en/admin/improvements/form.php b/app/lang/en/admin/improvements/form.php index a5e42532cb5f..25b8814ceb79 100755 --- a/app/lang/en/admin/improvements/form.php +++ b/app/lang/en/admin/improvements/form.php @@ -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' diff --git a/app/lang/en/admin/improvements/general.php b/app/lang/en/admin/improvements/general.php index bc70f76a3c21..46defda5e4c8 100755 --- a/app/lang/en/admin/improvements/general.php +++ b/app/lang/en/admin/improvements/general.php @@ -3,4 +3,6 @@ return [ 'improvements' => 'Improvements', 'edit' => 'Edit Improvement', + 'delete' => 'Delete Improvement', + 'view' => 'View Improvement Details' ]; diff --git a/app/lang/en/admin/improvements/message.php b/app/lang/en/admin/improvements/message.php index a644c29fe813..85d457d0232b 100644 --- a/app/lang/en/admin/improvements/message.php +++ b/app/lang/en/admin/improvements/message.php @@ -1,15 +1,17 @@ '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', ]; \ No newline at end of file diff --git a/app/views/backend/hardware/view.blade.php b/app/views/backend/hardware/view.blade.php index c7022549f1e6..f3ce89db9423 100755 --- a/app/views/backend/hardware/view.blade.php +++ b/app/views/backend/hardware/view.blade.php @@ -229,7 +229,7 @@ {{{ $improvement->improvement_type }}} {{{ Carbon::parse($improvement->start_date)->toDateString() }}} {{{ Carbon::parse($improvement->completion_date)->toDateString() }}} - {{{ $improvement->is_warranty ? "Warranty" : "Not Warranty" }}} + {{{ $improvement->is_warranty ? Lang::get('admin/improvements/message.warranty') : Lang::get('admin/improvements/message.not_warranty') }}} {{{ sprintf( Lang::get( 'general.currency' ) . '%01.2f', $improvement->cost) }}} cost; ?> diff --git a/app/views/backend/improvements/view.blade.php b/app/views/backend/improvements/view.blade.php new file mode 100644 index 000000000000..b69796d29aaf --- /dev/null +++ b/app/views/backend/improvements/view.blade.php @@ -0,0 +1,110 @@ + +@extends('backend/layouts/default') + +{{-- Page title --}} +@section('title') + @lang('admin/improvements/general.view') {{ $improvement->title }} :: + @parent +@stop + +{{-- Page content --}} +@section('content') +
+
+

+ @lang('admin/improvements/general.view') + {{{ " - " . $improvement->title }}} +

+ +
+ + +
+
+
+ +
+
+
+ +
+
+ @lang('admin/improvements/form.improvement_type'): + {{{ $improvement->improvement_type }}} +
+
+ + +
+
+ @lang('admin/improvements/table.asset_name'): + + {{{ $improvement->asset->name }}} + +
+
+ @lang('admin/improvements/table.supplier_name'): + + {{{ $improvement->supplier->name }}} + +
+
+ + +
+
+ @lang('admin/improvements/form.start_date'): + start_date); ?> + {{{ $startDate->toDateString() }}} +
+
+ @lang('admin/improvements/form.completion_date'): + 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') }}} +
+
+ @lang('admin/improvements/form.improvement_time'): + {{ $calculationEndDate->diffInDays($startDate) }} +
+
+ + +
+
+ @lang('admin/improvements/form.cost'): + {{{ sprintf( Lang::get( 'general.currency' ) . '%01.2f', $improvement->cost) }}} +
+
+ @lang('admin/improvements/form.is_warranty'): + {{{ $improvement->is_warranty ? Lang::get('admin/improvements/message.warranty') : Lang::get('admin/improvements/message.not_warranty') }}} +
+
+ + +
+
+ @lang('admin/improvements/form.notes'): + {{{ $improvement->notes }}} +
+
+ +
+
+
+@stop \ No newline at end of file diff --git a/app/views/backend/suppliers/view.blade.php b/app/views/backend/suppliers/view.blade.php index 3f54ef2a73be..00f8ee6cf03c 100755 --- a/app/views/backend/suppliers/view.blade.php +++ b/app/views/backend/suppliers/view.blade.php @@ -137,7 +137,7 @@ {{{ $improvement->improvement_type }}} {{{ Carbon::parse($improvement->start_date)->toDateString() }}} {{{ Carbon::parse($improvement->completion_date)->toDateString() }}} - {{{ $improvement->is_warranty ? "Warranty" : "Not Warranty" }}} + {{{ $improvement->is_warranty ? Lang::get('admin/improvements/message.warranty') : Lang::get('admin/improvements/message.not_warranty') }}} {{{ sprintf( Lang::get( 'general.currency' ) . '%01.2f', $improvement->cost) }}} cost; ?>