Skip to content

Commit

Permalink
Fixed all issues that were reported by @leobg
Browse files Browse the repository at this point in the history
Also, renamed and fixed items of concern by @snipe
Renamed Improvements to Asset Maintenances
  • Loading branch information
vsposato committed Jul 6, 2015
1 parent 269f732 commit 1b423f5
Show file tree
Hide file tree
Showing 26 changed files with 1,388 additions and 1,279 deletions.
464 changes: 464 additions & 0 deletions app/controllers/admin/AssetMaintenancesController.php

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions app/controllers/admin/AssetsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
use Lang;
use Asset;
use Supplier;
use AssetMaintenance;
use Statuslabel;
use User;
use Setting;
Expand Down
444 changes: 0 additions & 444 deletions app/controllers/admin/ImprovementsController.php

This file was deleted.

50 changes: 25 additions & 25 deletions app/controllers/admin/ReportsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
use Asset;
use Illuminate\Support\Facades\Lang;
use Illuminate\Support\Facades\Response;
use Improvement;
use AssetMaintenance;
use Input;
use License;
use Location;
Expand Down Expand Up @@ -490,15 +490,15 @@ public function postCustom()
* @author Vincent Sposato <[email protected]>
* @version v1.0
*/
public function getImprovementsReport()
public function getAssetMaintenancesReport()
{

// Grab all the improvements
$improvements = Improvement::with( 'asset', 'supplier' )
$assetMaintenances = \AssetMaintenance::with( 'asset', 'supplier' )
->orderBy( 'created_at', 'DESC' )
->get();

return View::make( 'backend/reports/improvements', compact( 'improvements' ) );
return View::make( 'backend/reports/asset_maintenances', compact( 'assetMaintenances' ) );

}

Expand All @@ -509,46 +509,46 @@ public function getImprovementsReport()
* @author Vincent Sposato <[email protected]>
* @version v1.0
*/
public function exportImprovementsReport()
public function exportAssetMaintenancesReport()
{

// Grab all the improvements
$improvements = Improvement::with( 'asset', 'supplier' )
$assetMaintenances = AssetMaintenance::with( 'asset', 'supplier' )
->orderBy( 'created_at', 'DESC' )
->get();

$rows = [ ];

$header = [
Lang::get( 'admin/improvements/table.asset_name' ),
Lang::get( 'admin/improvements/table.supplier_name' ),
Lang::get( 'admin/improvements/form.improvement_type' ),
Lang::get( 'admin/improvements/form.title' ),
Lang::get( 'admin/improvements/form.start_date' ),
Lang::get( 'admin/improvements/form.completion_date' ),
Lang::get( 'admin/improvements/form.improvement_time' ),
Lang::get( 'admin/improvements/form.cost' )
Lang::get( 'admin/asset_maintenances/table.asset_name' ),
Lang::get( 'admin/asset_maintenances/table.supplier_name' ),
Lang::get( 'admin/asset_maintenances/form.asset_maintenance_type' ),
Lang::get( 'admin/asset_maintenances/form.title' ),
Lang::get( 'admin/asset_maintenances/form.start_date' ),
Lang::get( 'admin/asset_maintenances/form.completion_date' ),
Lang::get( 'admin/asset_maintenances/form.asset_maintenance_time' ),
Lang::get( 'admin/asset_maintenances/form.cost' )
];

$header = array_map( 'trim', $header );
$rows[ ] = implode( $header, ',' );

foreach ($improvements as $improvement) {
foreach ($assetMaintenances as $assetMaintenance) {
$row = [ ];
$row[ ] = str_replace( ',', '', $improvement->asset->name );
$row[ ] = str_replace( ',', '', $improvement->supplier->name );
$row[ ] = $improvement->improvement_type;
$row[ ] = $improvement->title;
$row[ ] = $improvement->start_date;
$row[ ] = $improvement->completion_date;
if (is_null( $improvement->improvement_time )) {
$row[ ] = str_replace( ',', '', $assetMaintenance->asset->name );
$row[ ] = str_replace( ',', '', $assetMaintenance->supplier->name );
$row[ ] = $assetMaintenance->improvement_type;
$row[ ] = $assetMaintenance->title;
$row[ ] = $assetMaintenance->start_date;
$row[ ] = $assetMaintenance->completion_date;
if (is_null( $assetMaintenance->asset_maintenance_time )) {
$improvementTime = intval( Carbon::now()
->diffInDays( Carbon::parse( $improvement->start_date ) ) );
->diffInDays( Carbon::parse( $assetMaintenance->start_date ) ) );
} else {
$improvementTime = intval( $improvement->improvement_time );
$improvementTime = intval( $assetMaintenance->asset_maintenance_time );
}
$row[ ] = $improvementTime;
$row[ ] = Lang::get( 'general.currency' ) . number_format( $improvement->cost, 2 );
$row[ ] = Lang::get( 'general.currency' ) . number_format( $assetMaintenance->cost, 2 );
$rows[ ] = implode( $row, ',' );
}

Expand Down
1 change: 1 addition & 0 deletions app/controllers/admin/SuppliersController.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

use AdminController;
use Image;
use AssetMaintenance;
use Input;
use Lang;
use Supplier;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Lang;

class CreateImprovementsTable extends Migration
class CreateAssetMaintenancesTable extends Migration
{

/**
Expand All @@ -14,20 +15,20 @@ class CreateImprovementsTable extends Migration
public function up()
{

Schema::create( 'improvements', function ( Blueprint $table ) {
Schema::create( 'asset_maintenances', function ( Blueprint $table ) {

$table->increments( 'id' );
$table->integer( 'asset_id' )
->unsigned();
$table->integer( 'supplier_id' )
->unsigned();
$table->enum( 'improvement_type', [ 'Maintenance', 'Repair', 'Upgrade' ] );
$table->enum( 'asset_maintenance_type', $this->getEnumFields() );
$table->string( 'title', 100 );
$table->boolean( 'is_warranty' );
$table->date( 'start_date' );
$table->date( 'completion_date' )
->nullable();
$table->integer( 'improvement_time')
$table->integer( 'asset_maintenance_time' )
->nullable();
$table->longText( 'notes' )
->nullable();
Expand All @@ -39,6 +40,16 @@ public function up()
} );
}

protected function getEnumFields()
{

return [
Lang::get( 'admin/asset_maintenances/general.maintenance' ),
Lang::get( 'admin/asset_maintenances/general.repair' ),
Lang::get( 'admin/asset_maintenances/general.upgrade' )
];
}

/**
* Reverse the migrations.
*
Expand All @@ -47,7 +58,7 @@ public function up()
public function down()
{

Schema::dropIfExists( 'improvements' );
Schema::dropIfExists( 'asset_maintenances' );

}

Expand Down
14 changes: 14 additions & 0 deletions app/lang/en/admin/asset_maintenances/form.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?php

return [
'asset_maintenance_type' => 'Asset Maintenance Type',
'title' => 'Title',
'start_date' => 'Start Date',
'completion_date' => 'Completion Date',
'cost' => 'Cost',
'is_warranty' => 'Warranty Improvement',
'asset_maintenance_time' => 'Asset Maintenance Time (in days)',
'notes' => 'Notes',
'update' => 'Update Asset Maintenance',
'create' => 'Create Asset Maintenance'
];
11 changes: 11 additions & 0 deletions app/lang/en/admin/asset_maintenances/general.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?php

return [
'asset_maintenances' => 'Asset Maintenances',
'edit' => 'Edit Asset Maintenance',
'delete' => 'Delete Asset Maintenance',
'view' => 'View Asset Maintenance Details',
'repair' => 'Repair',
'maintenance' => 'Maintenance',
'upgrade' => 'Upgrade'
];
17 changes: 17 additions & 0 deletions app/lang/en/admin/asset_maintenances/message.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?php

return [
'not_found' => 'Asset Maintenance you were looking for was not found!',
'delete' => [
'confirm' => 'Are you sure you wish to delete this asset maintenance?',
'error' => 'There was an issue deleting the asset maintenance. Please try again.',
'success' => 'The asset maintenance was deleted successfully.'
],
'create' => [
'error' => 'Asset Maintenance was not created, please try again.',
'success' => 'Asset Maintenance created successfully.'
],
'asset_maintenance_incomplete' => 'Not Completed Yet',
'warranty' => 'Warranty',
'not_warranty' => 'Not Warranty',
];
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php

return [
'title' => 'Improvement',
'title' => 'Asset Maintenance',
'asset_name' => 'Asset Name',
'supplier_name' => 'Supplier Name',
'is_warranty' => 'Warranty',
Expand Down
14 changes: 0 additions & 14 deletions app/lang/en/admin/improvements/form.php

This file was deleted.

8 changes: 0 additions & 8 deletions app/lang/en/admin/improvements/general.php

This file was deleted.

17 changes: 0 additions & 17 deletions app/lang/en/admin/improvements/message.php

This file was deleted.

Loading

0 comments on commit 1b423f5

Please sign in to comment.