Skip to content

Commit 06067fc

Browse files
committed
Fixed CSV rexport
1 parent 67aba76 commit 06067fc

File tree

1 file changed

+19
-11
lines changed

1 file changed

+19
-11
lines changed

app/controllers/admin/AssetsController.php

Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
use View;
1919
use Response;
2020
use Config;
21+
use Location;
2122
use Log;
2223

2324
use BaconQrCode\Renderer\Image as QrImage;
@@ -96,7 +97,8 @@ public function exportReports()
9697
Lang::get('admin/hardware/table.location'),
9798
Lang::get('admin/hardware/table.purchase_date'),
9899
Lang::get('admin/hardware/table.purchase_cost'),
99-
Lang::get('admin/hardware/table.book_value')
100+
Lang::get('admin/hardware/table.book_value'),
101+
Lang::get('admin/hardware/table.diff')
100102
);
101103
$header = array_map('trim', $header);
102104
$rows[] = implode($header, ',');
@@ -107,19 +109,25 @@ public function exportReports()
107109
$row[] = $asset->asset_tag;
108110
$row[] = $asset->name;
109111
$row[] = $asset->serial;
110-
$row[] = $asset->assigned_to;
112+
111113

112114
if ($asset->assigned_to > 0) {
113115
$user = User::find($asset->assigned_to);
114116
$row[] = $user->fullName();
115-
}
116-
else {
117-
$row[] = ''; // Empty string if unassigned
118-
}
117+
}
118+
else {
119+
$row[] = ''; // Empty string if unassigned
120+
}
119121

120122
if (($asset->assigned_to > 0) && ($asset->assigneduser->location_id > 0)) {
121123
$location = Location::find($asset->assigneduser->location_id);
122-
$row[] = $location->city . ', ' . $location->state;
124+
if ($location->city) {
125+
$row[] = '"'.$location->city . ', ' . $location->state.'"';
126+
} elseif ($location->name) {
127+
$row[] = $location->name;
128+
} else {
129+
$row[] = '';
130+
}
123131
}
124132
else {
125133
$row[] = ''; // Empty string if location is not set
@@ -128,9 +136,9 @@ public function exportReports()
128136
$depreciation = $asset->depreciate();
129137

130138
$row[] = $asset->purchase_date;
131-
$row[] = number_format($asset->purchase_cost);
132-
$row[] = number_format($depreciation);
133-
$row[] = number_format(($asset->purchase_cost - $depreciation));
139+
$row[] = '$'.$asset->purchase_cost;
140+
$row[] = '$'.$depreciation;
141+
$row[] = '$'.($asset->purchase_cost - $depreciation);
134142
$rows[] = implode($row, ',');
135143
}
136144

@@ -581,7 +589,7 @@ public function getQrCode($assetId = null)
581589
->setHeight($this->qrCodeDimensions['height'])
582590
->setMargin(0)
583591
->addDecorator($text);
584-
592+
585593
$writer = new \BaconQrCode\Writer($renderer);
586594
$content = $writer->writeString(route('view/hardware', $asset->id));
587595

0 commit comments

Comments
 (0)