Skip to content

Commit

Permalink
Merge pull request #1033 from vsposato/feature/865_fixIssuesFromSnipe
Browse files Browse the repository at this point in the history
Feature/865 fix issues from snipe
  • Loading branch information
snipe committed Aug 11, 2015
2 parents 9540db4 + d363a0d commit 38d774e
Show file tree
Hide file tree
Showing 10 changed files with 702 additions and 669 deletions.
214 changes: 0 additions & 214 deletions app/commands/ThreadAssetLogsCommand.php

This file was deleted.

5 changes: 5 additions & 0 deletions app/controllers/account/ViewAssetsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -132,9 +132,11 @@ public function postAcceptAsset($logID = null) {

if (Input::get('asset_acceptance')=='accepted') {
$logaction_msg = 'accepted';
$accepted="accepted";
$return_msg = Lang::get('admin/users/message.accepted');
} else {
$logaction_msg = 'declined';
$accepted="rejected";
$return_msg = Lang::get('admin/users/message.declined');
}

Expand Down Expand Up @@ -174,6 +176,9 @@ public function postAcceptAsset($logID = null) {
$update_checkout = DB::table('asset_logs')
->where('id',$findlog->id)
->update(array('accepted_id' => $logaction->id));
$affected_asset=$logaction->assetlog;
$affected_asset->accepted=$accepted;
$affected_asset->save();

if ($update_checkout ) {
return Redirect::to('account/view-assets')->with('success', $return_msg);
Expand Down
4 changes: 4 additions & 0 deletions app/controllers/admin/AssetsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -442,6 +442,9 @@ public function postCheckout($assetId)

// Update the asset data
$asset->assigned_to = e(Input::get('assigned_to'));
if($asset->requireAcceptance()) {
$asset->accepted="pending";
}

// Was the asset updated?
if($asset->save()) {
Expand Down Expand Up @@ -574,6 +577,7 @@ public function postCheckin($assetId = null, $backto = null)

// Update the asset data to null, since it's being checked in
$asset->assigned_to = NULL;
$asset->accepted = NULL;


// Was the asset updated?
Expand Down
35 changes: 17 additions & 18 deletions app/controllers/admin/ReportsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -576,20 +576,30 @@ public function exportAssetMaintenancesReport()
return $response;
}

/**
* getAssetAcceptanceReport
*
* @return mixed
* @author Vincent Sposato <[email protected]>
* @version v1.0
*/
public function getAssetAcceptanceReport()
{

if (count($this->getAssetsNotAcceptedYet()) > 0) {
$assetsForReport = Actionlog::whereIn( 'id', $this->getAssetsNotAcceptedYet())->get();
} else {
$assetsForReport = null;
}

$assetsForReport = Asset::notYetAccepted()
->get();

return View::make( 'backend/reports/unaccepted_assets', compact( 'assetsForReport' ) );

}

/**
* exportAssetAcceptanceReport
*
* @return \Illuminate\Http\Response
* @author Vincent Sposato <[email protected]>
* @version v1.0
*/
public function exportAssetAcceptanceReport()
{

Expand All @@ -604,9 +614,7 @@ public function exportAssetAcceptanceReport()
Lang::get( 'admin/hardware/form.model' ),
Lang::get( 'admin/hardware/form.name' ),
Lang::get( 'admin/hardware/table.asset_tag' ),
Lang::get( 'admin/hardware/table.checkout_date' ),
Lang::get( 'admin/hardware/table.checkoutto' ),
Lang::get( 'admin/hardware/table.days_without_acceptance' ),
];

$header = array_map( 'trim', $header );
Expand All @@ -618,9 +626,7 @@ public function exportAssetAcceptanceReport()
$row[] = str_replace( ',', '', $assetItem->assetlog->model->name );
$row[] = str_replace( ',', '', $assetItem->assetlog->showAssetName() );
$row[] = str_replace( ',', '', $assetItem->assetlog->asset_tag );
$row[] = $assetItem->created_at->format( 'Y-m-d' );
$row[] = str_replace( ',', '', $assetItem->assetlog->assigneduser->fullName() );
$row[] = $assetItem->created_at->diffInDays( Carbon::now() );
$rows[] = implode( $row, ',' );
}

Expand Down Expand Up @@ -712,13 +718,6 @@ protected function getAssetsCheckedOutRequiringAcceptance()
protected function getAssetsNotAcceptedYet()
{

if (count($this->getAssetsCheckedOutRequiringAcceptance()) > 0) {
return array_pluck(
Actionlog::getUnacceptedAssets( $this->getAssetsCheckedOutRequiringAcceptance() ),
'id' );
} else {
return null;
}

return Asset::unaccepted();
}
}
Loading

0 comments on commit 38d774e

Please sign in to comment.