Merge branch 'hotfixes/purchase_cost' into develop

# Conflicts:
#	app/Http/Controllers/ReportsController.php
#	config/version.php
This commit is contained in:
snipe 2016-09-27 19:13:21 -07:00
commit 9091385182
10 changed files with 223 additions and 323 deletions

View file

@ -495,4 +495,16 @@ class Helper
} }
public static function stripTagsFromJSON(Array $array) {
foreach ($array as $key => $value) {
$clean_value = strip_tags($value);
$clean_array[$key] = $clean_value;
}
return $clean_array;
}
} }

View file

@ -92,7 +92,7 @@ class AccessoriesController extends Controller
if (e(Input::get('purchase_cost')) == '0.00') { if (e(Input::get('purchase_cost')) == '0.00') {
$accessory->purchase_cost = null; $accessory->purchase_cost = null;
} else { } else {
$accessory->purchase_cost = e(Input::get('purchase_cost')); $accessory->purchase_cost = Helper::ParseFloat(e(Input::get('purchase_cost')))p;
} }
$accessory->qty = e(Input::get('qty')); $accessory->qty = e(Input::get('qty'));
@ -126,7 +126,7 @@ class AccessoriesController extends Controller
} }
return View::make('accessories/edit', compact('accessory')) return View::make('accessories/edit', compact('accessory'))
->with('category_list', Helper::categoryList('accessory')) ->with('category_list', erper::categoryList('accessory'))
->with('company_list', Helper::companyList()) ->with('company_list', Helper::companyList())
->with('location_list', Helper::locationsList()) ->with('location_list', Helper::locationsList())
->with('manufacturer_list', Helper::manufacturerList()); ->with('manufacturer_list', Helper::manufacturerList());

View file

@ -141,7 +141,7 @@ class AssetMaintenancesController extends Controller
'completion_date' => $maintenance->completion_date, 'completion_date' => $maintenance->completion_date,
'user_id' => ($maintenance->admin) ? (string)link_to('/admin/users/'.$maintenance->admin->id.'/view', $maintenance->admin->fullName()) : '', 'user_id' => ($maintenance->admin) ? (string)link_to('/admin/users/'.$maintenance->admin->id.'/view', $maintenance->admin->fullName()) : '',
'actions' => $actions, 'actions' => $actions,
'companyName' => ($maintenance->asset) ? $maintenance->asset->company->name : '' 'companyName' => ($maintenance->asset->company) ? $maintenance->asset->company->name : ''
); );
} }
@ -215,7 +215,7 @@ class AssetMaintenancesController extends Controller
if (e(Input::get('cost')) == '') { if (e(Input::get('cost')) == '') {
$assetMaintenance->cost = ''; $assetMaintenance->cost = '';
} else { } else {
$assetMaintenance->cost = e(Input::get('cost')); $assetMaintenance->cost = Helper::ParseFloat(e(Input::get('cost')));
} }
if (e(Input::get('notes')) == '') { if (e(Input::get('notes')) == '') {
@ -363,7 +363,7 @@ class AssetMaintenancesController extends Controller
if (e(Input::get('cost')) == '') { if (e(Input::get('cost')) == '') {
$assetMaintenance->cost = ''; $assetMaintenance->cost = '';
} else { } else {
$assetMaintenance->cost = e(Input::get('cost')); $assetMaintenance->cost = Helper::ParseFloat(e(Input::get('cost')));
} }
if (e(Input::get('notes')) == '') { if (e(Input::get('notes')) == '') {

View file

@ -178,7 +178,7 @@ class AssetsController extends Controller
if (e(Input::get('purchase_cost')) == '') { if (e(Input::get('purchase_cost')) == '') {
$asset->purchase_cost = null; $asset->purchase_cost = null;
} else { } else {
$asset->purchase_cost = (e(Input::get('purchase_cost'))); $asset->purchase_cost = Helper::ParseFloat(e(Input::get('purchase_cost')));
} }
if (e(Input::get('purchase_date')) == '') { if (e(Input::get('purchase_date')) == '') {
@ -354,7 +354,7 @@ class AssetsController extends Controller
} }
if ($request->has('purchase_cost')) { if ($request->has('purchase_cost')) {
$asset->purchase_cost = e(Helper::formatCurrencyOutput($request->input('purchase_cost'))); $asset->purchase_cost = Helper::ParseFloat(e($request->input('purchase_cost')));
} else { } else {
$asset->purchase_cost = null; $asset->purchase_cost = null;
} }
@ -1492,7 +1492,7 @@ class AssetsController extends Controller
} }
if (Input::has('purchase_cost')) { if (Input::has('purchase_cost')) {
$update_array['purchase_cost'] = e(Input::get('purchase_cost')); $update_array['purchase_cost'] = Helper::ParseFloat(e(Input::get('purchase_cost')));
} }
if (Input::has('supplier_id')) { if (Input::has('supplier_id')) {
@ -1840,7 +1840,13 @@ class AssetsController extends Controller
} }
} }
$rows[]=$row;
if (($request->has('report')) && ($request->get('report')=='true')) {
$rows[]= Helper::stripTagsFromJSON($row);
} else {
$rows[]= $row;
}
} }
$data = array('total'=>$assetCount, 'rows'=>$rows); $data = array('total'=>$assetCount, 'rows'=>$rows);

View file

@ -99,7 +99,7 @@ class ComponentsController extends Controller
if (e(Input::get('purchase_cost')) == '0.00') { if (e(Input::get('purchase_cost')) == '0.00') {
$component->purchase_cost = null; $component->purchase_cost = null;
} else { } else {
$component->purchase_cost = e(Input::get('purchase_cost')); $component->purchase_cost = Helper::ParseFloat(e(Input::get('purchase_cost')));
} }
$component->total_qty = e(Input::get('total_qty')); $component->total_qty = e(Input::get('total_qty'));
@ -183,7 +183,7 @@ class ComponentsController extends Controller
if (e(Input::get('purchase_cost')) == '0.00') { if (e(Input::get('purchase_cost')) == '0.00') {
$component->purchase_cost = null; $component->purchase_cost = null;
} else { } else {
$component->purchase_cost = e(Input::get('purchase_cost')); $component->purchase_cost = Helper::ParseFloat(e(Input::get('purchase_cost')));
} }
$component->total_qty = e(Input::get('total_qty')); $component->total_qty = e(Input::get('total_qty'));

View file

@ -97,7 +97,7 @@ class ConsumablesController extends Controller
if (e(Input::get('purchase_cost')) == '0.00') { if (e(Input::get('purchase_cost')) == '0.00') {
$consumable->purchase_cost = null; $consumable->purchase_cost = null;
} else { } else {
$consumable->purchase_cost = e(Input::get('purchase_cost')); $consumable->purchase_cost = Helper::ParseFloat(e(Input::get('purchase_cost')));
} }
$consumable->qty = e(Input::get('qty')); $consumable->qty = e(Input::get('qty'));
@ -182,10 +182,10 @@ class ConsumablesController extends Controller
if (e(Input::get('purchase_cost')) == '0.00') { if (e(Input::get('purchase_cost')) == '0.00') {
$consumable->purchase_cost = null; $consumable->purchase_cost = null;
} else { } else {
$consumable->purchase_cost = e(Input::get('purchase_cost')); $consumable->purchase_cost = Helper::ParseFloat(e(Input::get('purchase_cost')));
} }
$consumable->qty = e(Input::get('qty')); $consumable->qty = Helper::ParseFloat(e(Input::get('qty')));
if ($consumable->save()) { if ($consumable->save()) {
return redirect()->to("admin/consumables")->with('success', trans('admin/consumables/message.update.success')); return redirect()->to("admin/consumables")->with('success', trans('admin/consumables/message.update.success'));

View file

@ -87,17 +87,13 @@ class LicensesController extends Controller
public function postCreate() public function postCreate()
{ {
// get the POST data
$new = Input::all();
// create a new model instance // create a new model instance
$license = new License(); $license = new License();
if (e(Input::get('purchase_cost')) == '') { if (e(Input::get('purchase_cost')) == '') {
$license->purchase_cost = null; $license->purchase_cost = null;
} else { } else {
$license->purchase_cost = e(Input::get('purchase_cost')); $license->purchase_cost = Helper::ParseFloat(e(Input::get('purchase_cost')));
} }
if (e(Input::get('supplier_id')) == '') { if (e(Input::get('supplier_id')) == '') {
@ -289,10 +285,9 @@ class LicensesController extends Controller
} }
if (e(Input::get('purchase_cost')) == '') { if (e(Input::get('purchase_cost')) == '') {
$license->purchase_cost = null; $license->purchase_cost = null;
} else { } else {
$license->purchase_cost = e(Input::get('purchase_cost')); $license->purchase_cost = Helper::ParseFloat(e(Input::get('purchase_cost')));
//$license->purchase_cost = e(Input::get('purchase_cost'));
} }
if (e(Input::get('maintained')) == '') { if (e(Input::get('maintained')) == '') {

View file

@ -33,12 +33,12 @@ class ReportsController extends Controller
{ {
/** /**
* Returns a view that displays the accessories report. * Returns a view that displaysthe accessories report.
* *
* @author [A. Gianotto] [<snipe@snipe.net>] * @author [A. Gianotto] [<snipe@snipe.net>]
* @since [v1.0] * @since [v1.0]
* @return View * @return View
*/ */
public function getAccessoryReport() public function getAccessoryReport()
{ {
$accessories = Accessory::orderBy('created_at', 'DESC')->with('company')->get(); $accessories = Accessory::orderBy('created_at', 'DESC')->with('company')->get();
@ -47,14 +47,14 @@ class ReportsController extends Controller
} }
/** /**
* Exports the accessories to CSV * Exports the accessories to CSV
* *
* @deprecated Server-side exports have been replaced by datatables export since v2. * @deprecated Server-side exports have been replaced by datatables export since v2.
* @author [A. Gianotto] [<snipe@snipe.net>] * @author [A. Gianotto] [<snipe@snipe.net>]
* @see ManufacturersController::getDatatable() method that generates the JSON response * @see ManufacturersController::getDatatable() method that generates the JSON response
* @since [v1.0] * @since [v1.0]
* @return \Illuminate\Http\Response * @return \Illuminate\Http\Response
*/ */
public function exportAccessoryReport() public function exportAccessoryReport()
{ {
$accessories = Accessory::orderBy('created_at', 'DESC')->get(); $accessories = Accessory::orderBy('created_at', 'DESC')->get();
@ -89,53 +89,41 @@ class ReportsController extends Controller
} }
/** /**
* Display asset report. * Display asset report view.
* *
* @author [A. Gianotto] [<snipe@snipe.net>] * @author [A. Gianotto] [<snipe@snipe.net>]
* @since [v1.0] * @since [v1.0]
* @return View * @return View
*/ */
public function getAssetsReport() public function getAssetsReport()
{ {
$settings = \App\Models\Setting::first(); $settings = \App\Models\Setting::first();
// Grab all the assets
$assets = Asset::with(
'model',
'assigneduser.userLoc',
'assetstatus',
'defaultLoc',
'assetlog',
'supplier',
'model.manufacturer',
'company'
)
->orderBy('created_at', 'DESC')
->get();
return View::make('reports/asset', compact('assets'))->with('settings', $settings); return View::make('reports/asset', compact('assets'))->with('settings', $settings);
} }
/** /**
* Exports the assets to CSV * Exports the assets to CSV
* *
* @author [A. Gianotto] [<snipe@snipe.net>] * @author [A. Gianotto] [<snipe@snipe.net>]
* @since [v1.0] * @since [v1.0]
* @return \Illuminate\Http\Response * @return \Illuminate\Http\Response
*/ */
public function exportAssetReport() public function exportAssetReport()
{ {
\Debugbar::disable(); \Debugbar::disable();
$customfields = CustomField::get();
$response = new StreamedResponse(function(){ $response = new StreamedResponse(function(){
// Open output stream // Open output stream
$handle = fopen('php://output', 'w'); $handle = fopen('php://output', 'w');
Asset::with('assigneduser', 'assetloc','defaultLoc','assigneduser.userloc','model','supplier','assetstatus','model.manufacturer')->orderBy('created_at', 'DESC')->chunk(500, function($assets) use($handle) { Asset::with('assigneduser', 'assetloc','defaultLoc','assigneduser.userloc','model','supplier','assetstatus','model.manufacturer')->orderBy('created_at', 'DESC')->chunk(500, function($assets) use($handle) {
$headers=[
//BOM trans('general.company'),
fputs($handle, chr(0xEF) . chr(0xBB) . chr(0xBF));
fputcsv($handle, [
trans('admin/hardware/table.asset_tag'), trans('admin/hardware/table.asset_tag'),
trans('admin/hardware/form.manufacturer'), trans('admin/hardware/form.manufacturer'),
trans('admin/hardware/form.model'), trans('admin/hardware/form.model'),
@ -148,13 +136,19 @@ class ReportsController extends Controller
trans('admin/hardware/form.order'), trans('admin/hardware/form.order'),
trans('admin/hardware/form.supplier'), trans('admin/hardware/form.supplier'),
trans('admin/hardware/table.checkoutto'), trans('admin/hardware/table.checkoutto'),
trans('admin/hardware/table.checkout_date'),
trans('admin/hardware/table.location'), trans('admin/hardware/table.location'),
trans('general.notes'), trans('general.notes'),
]); ];
foreach($customfields as $field) {
$headers[]=$field->name;
}
fputcsv($handle, $headers);
foreach ($assets as $asset) { foreach ($assets as $asset) {
// Add a new row with data // Add a new row with data
fputcsv($handle, [ $values=[
($asset->company) ? $asset->company->name : '',
$asset->asset_tag, $asset->asset_tag,
($asset->model->manufacturer) ? $asset->model->manufacturer->name : '', ($asset->model->manufacturer) ? $asset->model->manufacturer->name : '',
($asset->model) ? $asset->model->name : '', ($asset->model) ? $asset->model->name : '',
@ -167,10 +161,15 @@ class ReportsController extends Controller
($asset->order_number) ? e($asset->order_number) : '', ($asset->order_number) ? e($asset->order_number) : '',
($asset->supplier) ? e($asset->supplier->name) : '', ($asset->supplier) ? e($asset->supplier->name) : '',
($asset->assigneduser) ? e($asset->assigneduser->fullName()) : '', ($asset->assigneduser) ? e($asset->assigneduser->fullName()) : '',
($asset->last_checkout!='') ? e($asset->last_checkout) : '',
($asset->assigneduser && $asset->assigneduser->userloc!='') ? ($asset->assigneduser && $asset->assigneduser->userloc!='') ?
e($asset->assigneduser->userloc->name) : ( ($asset->defaultLoc!='') ? e($asset->defaultLoc->name) : ''), e($asset->assigneduser->userloc->name) : ( ($asset->defaultLoc!='') ? e($asset->defaultLoc->name) : ''),
($asset->notes) ? e($asset->notes) : '', ($asset->notes) ? e($asset->notes) : '',
]); ];
foreach($customfields as $field) {
$values[]=$asset->{$field->db_column_name()};
}
fputcsv($handle, $values);
} }
}); });
@ -186,36 +185,36 @@ class ReportsController extends Controller
} }
/** /**
* Show depreciation report for assets. * Show depreciation report for assets.
* *
* @author [A. Gianotto] [<snipe@snipe.net>] * @author [A. Gianotto] [<snipe@snipe.net>]
* @since [v1.0] * @since [v1.0]
* @return View * @return View
*/ */
public function getDeprecationReport() public function getDeprecationReport()
{ {
// Grab all the assets // Grab all the assets
$assets = Asset::with('model', 'assigneduser', 'assetstatus', 'defaultLoc', 'assetlog', 'company') $assets = Asset::with('model', 'assigneduser', 'assetstatus', 'defaultLoc', 'assetlog', 'company')
->orderBy('created_at', 'DESC')->get(); ->orderBy('created_at', 'DESC')->get();
return View::make('reports/depreciation', compact('assets')); return View::make('reports/depreciation', compact('assets'));
} }
/** /**
* Exports the depreciations to CSV * Exports the depreciations to CSV
* *
* @deprecated Server-side exports have been replaced by datatables export since v2. * @deprecated Server-side exports have been replaced by datatables export since v2.
* @author [A. Gianotto] [<snipe@snipe.net>] * @author [A. Gianotto] [<snipe@snipe.net>]
* @since [v1.0] * @since [v1.0]
* @return \Illuminate\Http\Response * @return \Illuminate\Http\Response
*/ */
public function exportDeprecationReport() public function exportDeprecationReport()
{ {
// Grab all the assets // Grab all the assets
$assets = Asset::with('model', 'assigneduser', 'assetstatus', 'defaultLoc', 'assetlog') $assets = Asset::with('model', 'assigneduser', 'assetstatus', 'defaultLoc', 'assetlog')
->orderBy('created_at', 'DESC')->get(); ->orderBy('created_at', 'DESC')->get();
$csv = \League\Csv\Writer::createFromFileObject(new \SplTempFileObject()); $csv = \League\Csv\Writer::createFromFileObject(new \SplTempFileObject());
$csv->setOutputBOM(Reader::BOM_UTF16_BE); $csv->setOutputBOM(Reader::BOM_UTF16_BE);
@ -284,143 +283,51 @@ class ReportsController extends Controller
} }
/** /**
* Displays activity report. * Displays activity report.
* *
* @author [A. Gianotto] [<snipe@snipe.net>] * @author [A. Gianotto] [<snipe@snipe.net>]
* @since [v1.0] * @since [v1.0]
* @return View * @return View
*/ */
public function getActivityReport() public function getActivityReport()
{ {
$log_actions = Actionlog::orderBy('created_at', 'DESC') $log_actions = Actionlog::orderBy('created_at', 'DESC')
->with('item') ->with('adminlog')
->orderBy('created_at', 'DESC') ->with('accessorylog')
->get(); ->with('assetlog')
->with('licenselog')
->with('userlog')
->orderBy('created_at', 'DESC')
->get();
return View::make('reports/activity', compact('log_actions')); return View::make('reports/activity', compact('log_actions'));
} }
/** /**
* Returns Activity Report JSON. * Displays license report
* *
* @author [A. Gianotto] [<snipe@snipe.net>] * @author [A. Gianotto] [<snipe@snipe.net>]
* @since [v1.0] * @since [v1.0]
* @return View * @return View
*/ */
public function getActivityReportDataTable()
{
$activitylogs = Actionlog::orderBy('created_at', 'DESC');
if (Input::has('search')) {
$activity = $activity->TextSearch(e(Input::get('search')));
}
if (Input::has('offset')) {
$offset = e(Input::get('offset'));
} else {
$offset = 0;
}
if (Input::has('limit')) {
$limit = e(Input::get('limit'));
} else {
$limit = 50;
}
$allowed_columns = ['created_at'];
$order = Input::get('order') === 'asc' ? 'asc' : 'desc';
$sort = in_array(Input::get('sort'), $allowed_columns) ? e(Input::get('sort')) : 'created_at';
$activityCount = $activitylogs->count();
$activitylogs = $activitylogs->skip($offset)->take($limit)->get();
$rows = array();
foreach ($activitylogs as $activity) {
if ($activity->itemType() == "asset") {
$activity_icons = '<i class="fa fa-barcode"></i>';
} elseif ($activity->itemType() == "accessory") {
$activity_icons = '<i class="fa fa-keyboard-o"></i>';
} elseif ($activity->itemType()=="consumable") {
$activity_icons = '<i class="fa fa-tint"></i>';
} elseif ($activity->itemType()=="license"){
$activity_icons = '<i class="fa fa-floppy-o"></i>';
} elseif ($activity->itemType()=="component") {
$activity_icons = '<i class="fa fa-hdd-o"></i>';
} else {
$activity_icons = '<i class="fa fa-paperclip"></i>';
}
if (($activity->item) && ($activity->itemType()=="asset")) {
$actvity_item = '<a href="'.route('view/hardware', $activity->item_id).'">'.e($activity->item->asset_tag).' - '. e($activity->item->showAssetName()).'</a>';
$item_type = 'asset';
} elseif ($activity->item) {
$actvity_item = '<a href="'.route('view/'. $activity->itemType(), $activity->item_id).'">'.e($activity->item->name).'</a>';
$item_type = $activity->itemType();
}
if (($activity->userasassetlog) && ($activity->action_type=="uploaded") && ($activity->itemType()=="user")) {
$activity_target = '<a href="'.route('view/user', $activity->target_id).'">'.$activity->userasassetlog->fullName().'</a>';
} elseif (($activity->item) && ($activity->target instanceof \App\Models\Asset)) {
$activity_target = '<a href="'.route('view/hardware', $activity->target_id).'">'.$activity->target->showAssetName().'</a>';
} elseif (($activity->item) && ($activity->target instanceof \App\Models\User)) {
$activity_target = '<a href="'.route('view/user', $activity->target_id).'">'.$activity->target->fullName().'</a>';
} elseif ($activity->action_type=='requested') {
$activity_target = '<a href="'.route('view/user', $activity->user_id).'">'.$activity->user->fullName().'</a>';
} else {
$activity_target = $activity->target;
}
$rows[] = array(
'icon' => $activity_icons,
'created_at' => date("M d, Y g:iA", strtotime($activity->created_at)),
'action_type' => strtolower(trans('general.'.str_replace(' ','_',$activity->action_type))),
'admin' => $activity->user ? (string) link_to('/admin/users/'.$activity->user_id.'/view', $activity->user->fullName()) : 'Deleted Admin',
'target' => $activity_target,
'item' => $actvity_item,
'item_type' => $item_type,
'note' => e($activity->note),
);
}
$data = array('total'=>$activityCount, 'rows'=>$rows);
return $data;
}
/**
* Displays license report
*
* @author [A. Gianotto] [<snipe@snipe.net>]
* @since [v1.0]
* @return View
*/
public function getLicenseReport() public function getLicenseReport()
{ {
$licenses = License::with('depreciation')->orderBy('created_at', 'DESC') $licenses = License::orderBy('created_at', 'DESC')
->with('company') ->with('company')
->get(); ->get();
return View::make('reports/licenses', compact('licenses')); return View::make('reports/licenses', compact('licenses'));
} }
/** /**
* Exports the licenses to CSV * Exports the licenses to CSV
* *
* @deprecated Server-side exports have been replaced by datatables export since v2. * @deprecated Server-side exports have been replaced by datatables export since v2.
* @author [A. Gianotto] [<snipe@snipe.net>] * @author [A. Gianotto] [<snipe@snipe.net>]
* @since [v1.0] * @since [v1.0]
* @return \Illuminate\Http\Response * @return \Illuminate\Http\Response
*/ */
public function exportLicenseReport() public function exportLicenseReport()
{ {
$licenses = License::orderBy('created_at', 'DESC')->get(); $licenses = License::orderBy('created_at', 'DESC')->get();
@ -433,7 +340,6 @@ class ReportsController extends Controller
trans('admin/licenses/form.remaining_seats'), trans('admin/licenses/form.remaining_seats'),
trans('admin/licenses/form.expiration'), trans('admin/licenses/form.expiration'),
trans('admin/licenses/form.date'), trans('admin/licenses/form.date'),
trans('admin/licenses/form.depreciation'),
trans('admin/licenses/form.cost') trans('admin/licenses/form.cost')
]; ];
@ -449,7 +355,6 @@ class ReportsController extends Controller
$row[] = $license->remaincount(); $row[] = $license->remaincount();
$row[] = $license->expiration_date; $row[] = $license->expiration_date;
$row[] = $license->purchase_date; $row[] = $license->purchase_date;
$row[] = ($license->depreciation!='') ? '' : e($license->depreciation->name);
$row[] = '"' . Helper::formatCurrencyOutput($license->purchase_cost) . '"'; $row[] = '"' . Helper::formatCurrencyOutput($license->purchase_cost) . '"';
$rows[] = implode($row, ','); $rows[] = implode($row, ',');
@ -464,13 +369,13 @@ class ReportsController extends Controller
} }
/** /**
* Returns a form that allows the user to generate a custom CSV report. * Returns a form that allows the user to generate a custom CSV report.
* *
* @author [A. Gianotto] [<snipe@snipe.net>] * @author [A. Gianotto] [<snipe@snipe.net>]
* @see ReportsController::postCustomReport() method that generates the CSV * @see ReportsController::postCustomReport() method that generates the CSV
* @since [v1.0] * @since [v1.0]
* @return \Illuminate\Http\Response * @return \Illuminate\Http\Response
*/ */
public function getCustomReport() public function getCustomReport()
{ {
$customfields = CustomField::get(); $customfields = CustomField::get();
@ -493,10 +398,10 @@ class ReportsController extends Controller
$rows = [ ]; $rows = [ ];
$header = [ ]; $header = [ ];
if (e(Input::get('company_name')) == '1') { if (e(Input::get('company')) == '1') {
$header[] = 'Company Name'; $header[] = 'Company Name';
} }
if (e(Input::get('asset_name')) == '1') { if (e(Input::get('asset_name')) == '1') {
$header[] = 'Asset Name'; $header[] = 'Asset Name';
} }
@ -562,9 +467,9 @@ class ReportsController extends Controller
foreach ($assets as $asset) { foreach ($assets as $asset) {
$row = [ ]; $row = [ ];
if (e(Input::get('company_name')) == '1') { if (e(Input::get('company')) == '1') {
$row[] = is_null($asset->company) ? '' : e($asset->company->name); $row[] = is_null($asset->company) ? '' : '"'.$asset->company->name.'"';
} }
if (e(Input::get('asset_name')) == '1') { if (e(Input::get('asset_name')) == '1') {
@ -693,7 +598,7 @@ class ReportsController extends Controller
$csv = implode($rows, "\n"); $csv = implode($rows, "\n");
$response = Response::make($csv, 200); $response = Response::make($csv, 200);
$response->header('Content-Type', 'text/csv'); $response->header('Content-Type', 'text/csv');
$response->header('Content-disposition', 'attachment;filename=report.csv'); $response->header('Content-disposition', 'attachment;filename='.date('Y-m-d-His').'-custom-asset-report.csv');
return $response; return $response;
} else { } else {
@ -701,6 +606,7 @@ class ReportsController extends Controller
->with('error', trans('admin/reports/message.error')); ->with('error', trans('admin/reports/message.error'));
} }
} }
/** /**
* getImprovementsReport * getImprovementsReport
@ -713,8 +619,8 @@ class ReportsController extends Controller
{ {
// Grab all the improvements // Grab all the improvements
$assetMaintenances = AssetMaintenance::with('asset', 'supplier', 'asset.company') $assetMaintenances = AssetMaintenance::with('asset', 'supplier', 'asset.company')
->orderBy('created_at', 'DESC') ->orderBy('created_at', 'DESC')
->get(); ->get();
return View::make('reports/asset_maintenances', compact('assetMaintenances')); return View::make('reports/asset_maintenances', compact('assetMaintenances'));
@ -731,8 +637,8 @@ class ReportsController extends Controller
{ {
// Grab all the improvements // Grab all the improvements
$assetMaintenances = AssetMaintenance::with('asset', 'supplier') $assetMaintenances = AssetMaintenance::with('asset', 'supplier')
->orderBy('created_at', 'DESC') ->orderBy('created_at', 'DESC')
->get(); ->get();
$rows = [ ]; $rows = [ ];
@ -760,7 +666,7 @@ class ReportsController extends Controller
$row[] = e($assetMaintenance->completion_date); $row[] = e($assetMaintenance->completion_date);
if (is_null($assetMaintenance->asset_maintenance_time)) { if (is_null($assetMaintenance->asset_maintenance_time)) {
$improvementTime = intval(Carbon::now() $improvementTime = intval(Carbon::now()
->diffInDays(Carbon::parse($assetMaintenance->start_date))); ->diffInDays(Carbon::parse($assetMaintenance->start_date)));
} else { } else {
$improvementTime = intval($assetMaintenance->asset_maintenance_time); $improvementTime = intval($assetMaintenance->asset_maintenance_time);
} }
@ -804,7 +710,7 @@ class ReportsController extends Controller
// Grab all the improvements // Grab all the improvements
$assetsForReport = Actionlog::whereIn('id', $this->getAssetsNotAcceptedYet()) $assetsForReport = Actionlog::whereIn('id', $this->getAssetsNotAcceptedYet())
->get(); ->get();
$rows = [ ]; $rows = [ ];
@ -851,10 +757,10 @@ class ReportsController extends Controller
protected function getCheckedOutAssetsRequiringAcceptance($modelsInCategoriesThatRequireAcceptance) protected function getCheckedOutAssetsRequiringAcceptance($modelsInCategoriesThatRequireAcceptance)
{ {
$assets = Asset::deployed() $assets = Asset::deployed()
->inModelList($modelsInCategoriesThatRequireAcceptance) ->inModelList($modelsInCategoriesThatRequireAcceptance)
->select('id') ->select('id')
->get() ->get()
->toArray(); ->toArray();
return array_pluck($assets, 'id'); return array_pluck($assets, 'id');
} }
@ -871,9 +777,9 @@ class ReportsController extends Controller
{ {
return array_pluck(Model::inCategory($assetCategoriesRequiringAcceptance) return array_pluck(Model::inCategory($assetCategoriesRequiringAcceptance)
->select('id') ->select('id')
->get() ->get()
->toArray(), 'id'); ->toArray(), 'id');
} }
/** /**
@ -887,9 +793,9 @@ class ReportsController extends Controller
{ {
return array_pluck(Category::requiresAcceptance() return array_pluck(Category::requiresAcceptance()
->select('id') ->select('id')
->get() ->get()
->toArray(), 'id'); ->toArray(), 'id');
} }
/** /**

View file

@ -23,91 +23,55 @@
<div class="table-responsive"> <div class="table-responsive">
<table <table
name="assetReport" name="assetsReport"
id="table" {{-- data-row-style="rowStyle" --}}
class="table table-striped" data-toolbar="#toolbar"
data-cookie="true" class="table table-striped"
data-click-to-select="true" id="table"
data-cookie-id-table="assetReportTable"> data-url="{{route('api.hardware.list', array(''=>e(Input::get('status')),'order_number'=>e(Input::get('order_number')), 'status_id'=>e(Input::get('status_id')), 'report'=>'true'))}}"
data-cookie="true"
data-click-to-select="true"
data-cookie-id-table="{{ e(Input::get('status')) }}assetTable-{{ config('version.hash_version') }}">
<thead>
<tr>
@if (Input::get('status')!='Deleted')
<th data-class="hidden-xs" data-switchable="false" data-searchable="false" data-sortable="false" data-field="checkbox"><div class="text-center"><input type="checkbox" id="checkAll" style="padding-left: 0px;"></div></th>
@endif
<th data-sortable="true" data-field="id" data-visible="false">{{ trans('general.id') }}</th>
<th data-field="companyName" data-searchable="true" data-sortable="true" data-switchable="true" data-visible="false">{{ trans('general.company') }}</th>
<th data-sortable="true" data-field="name" data-visible="false">{{ trans('admin/hardware/form.name') }}</th>
<th data-sortable="true" data-field="asset_tag">{{ trans('admin/hardware/table.asset_tag') }}</th>
<th data-sortable="true" data-field="serial">{{ trans('admin/hardware/table.serial') }}</th>
<th data-sortable="true" data-field="model">{{ trans('admin/hardware/form.model') }}</th>
<th data-sortable="true" data-field="model_number" data-visible="false">{{ trans('admin/models/table.modelnumber') }}</th>
<th data-sortable="true" data-field="status_label">{{ trans('admin/hardware/table.status') }}</th>
<th data-sortable="true" data-field="assigned_to">{{ trans('admin/hardware/form.checkedout_to') }}</th>
<th data-sortable="true" data-field="location" data-searchable="true">{{ trans('admin/hardware/table.location') }}</th>
<th data-sortable="true" data-field="category" data-searchable="true">{{ trans('general.category') }}</th>
<th data-sortable="true" data-field="manufacturer" data-searchable="true" data-visible="false">{{ trans('general.manufacturer') }}</th>
<th data-sortable="true" data-field="purchase_cost" data-searchable="true" data-visible="false">{{ trans('admin/hardware/form.cost') }}</th>
<th data-sortable="true" data-field="purchase_date" data-searchable="true" data-visible="false">{{ trans('admin/hardware/form.date') }}</th>
<th data-sortable="false" data-field="eol" data-searchable="true">{{ trans('general.eol') }}</th>
<th data-sortable="true" data-searchable="true" data-field="notes">{{ trans('general.notes') }}</th>
<th data-sortable="true" data-searchable="true" data-field="order_number">{{ trans('admin/hardware/form.order') }}</th>
<th data-sortable="true" data-searchable="true" data-field="last_checkout">{{ trans('admin/hardware/table.checkout_date') }}</th>
<th data-sortable="true" data-field="expected_checkin" data-searchable="true">{{ trans('admin/hardware/form.expected_checkin') }}</th>
@foreach(\App\Models\CustomField::all() AS $field)
<thead>
<tr role="row">
<th class="col-sm-1">{{ trans('admin/companies/table.title') }}</th>
<th class="col-sm-1">{{ trans('admin/hardware/table.asset_tag') }}</th>
<th class="col-sm-1">{{ trans('admin/hardware/form.manufacturer') }}</th>
<th class="col-sm-1">{{ trans('admin/hardware/form.model') }}</th>
<th class="col-sm-1">{{ trans('general.model_no') }}</th>
@if ($settings->display_asset_name)
<th class="col-sm-1">{{ trans('general.name') }}</th>
@endif
<th class="col-sm-1">{{ trans('admin/hardware/table.serial') }}</th>
<th class="col-sm-1">{{ trans('admin/hardware/table.status') }}</th>
<th class="col-sm-1">{{ trans('admin/hardware/table.purchase_date') }}</th>
<th class="col-sm-1">{{ trans('admin/hardware/table.purchase_cost') }}</th>
<th class="col-sm-1">{{ trans('admin/hardware/form.order') }}</th>
<th class="col-sm-1">{{ trans('admin/hardware/form.supplier') }}</th>
<th class="col-sm-1">{{ trans('admin/hardware/table.checkoutto') }}</th>
<th class="col-sm-1">{{ trans('admin/hardware/table.location') }}</th>
</tr>
</thead>
<tbody>
@foreach ($assets as $asset) <th data-sortable="{{ ($field->field_encrypted=='1' ? 'false' : 'true') }}" data-visible="false" data-field="{{$field->db_column_name()}}">
<tr> @if ($field->field_encrypted=='1')
<td>{{ is_null($asset->company) ? '' : $asset->company->name }}</td> <i class="fa fa-lock"></i>
<td>{{ $asset->asset_tag }}</td> @endif
<td>
@if ($asset->model->manufacturer)
{{ $asset->model->manufacturer->name }}
@endif
</td>
<td>{{ $asset->model->name }}</td>
<td>{{ $asset->model->modelno }}</td>
@if ($settings->display_asset_name)
<td>{{ $asset->name }}</td>
@endif
<td>{{ $asset->serial }}</td>
<td>
{{ ($asset->assigneduser) ? 'Deployed' : ((e($asset->assetstatus)) ? e($asset->assetstatus->name) : '') }}
</td>
<td>{{ $asset->purchase_date }}</td>
<td class="align-right">{{ $settings->default_currency }}
{{ \App\Helpers\Helper::formatCurrencyOutput($asset->purchase_cost) }}
</td>
<td>
@if ($asset->order_number)
{{ $asset->order_number }}
@endif
</td>
<td>
@if ($asset->supplier_id)
<a href="{{ route('view/supplier', $asset->supplier_id) }}">
{{ $asset->supplier->name }}
</a>
@endif
</td>
<td>
@if ($asset->assigneduser)
@if ($asset->assigneduser->deleted_at!='')
<del>{{ $asset->assigneduser->fullName() }}</del>
@else
<a href="{{ route('view/user', $asset->assigned_to) }}">
{{ $asset->assigneduser->fullName() }}
</a>
@endif
@endif {{$field->name}}
</td> </th>
<td>
@if (($asset->assigneduser) && ($asset->assigneduser->userLoc)) @endforeach
{{ $asset->assigneduser->userLoc->name }} <th data-sortable="true" data-field="created_at" data-searchable="true" data-visible="false">{{ trans('general.created_at') }}</th>
@elseif ($asset->defaultLoc)
{{ $asset->defaultLoc->name }} </tr>
@endif </thead>
</td>
</tr>
@endforeach
</tbody>
</table> </table>
</div> </div>
</div> </div>
@ -122,6 +86,7 @@
<script src="{{ asset('assets/js/extensions/export/bootstrap-table-export.js') }}"></script> <script src="{{ asset('assets/js/extensions/export/bootstrap-table-export.js') }}"></script>
<script src="{{ asset('assets/js/extensions/export/tableExport.js') }}"></script> <script src="{{ asset('assets/js/extensions/export/tableExport.js') }}"></script>
<script src="{{ asset('assets/js/extensions/export/jquery.base64.js') }}"></script> <script src="{{ asset('assets/js/extensions/export/jquery.base64.js') }}"></script>
<script type="text/javascript"> <script type="text/javascript">
$('#table').bootstrapTable({ $('#table').bootstrapTable({
classes: 'table table-responsive table-no-bordered', classes: 'table table-responsive table-no-bordered',
@ -129,30 +94,39 @@
iconsPrefix: 'fa', iconsPrefix: 'fa',
showRefresh: true, showRefresh: true,
search: true, search: true,
pageSize: {{ $settings->per_page }}, pageSize: 100,
pagination: true, pagination: true,
sidePagination: 'client', sidePagination: 'server',
sortable: true, sortable: true,
showMultiSort: true,
cookie: true, cookie: true,
cookieExpire: '2y',
mobileResponsive: true, mobileResponsive: true,
showExport: true, showExport: true,
showColumns: true, showColumns: true,
exportDataType: 'all', exportDataType: 'all',
exportTypes: ['csv', 'txt','json', 'xml'], exportTypes: ['csv', 'excel', 'txt','json', 'xml'],
maintainSelected: true, maintainSelected: true,
paginationFirstText: "{{ trans('general.first') }}", paginationFirstText: "{{ trans('general.first') }}",
paginationLastText: "{{ trans('general.last') }}", paginationLastText: "{{ trans('general.last') }}",
paginationPreText: "{{ trans('general.previous') }}", paginationPreText: "{{ trans('general.previous') }}",
paginationNextText: "{{ trans('general.next') }}", paginationNextText: "{{ trans('general.next') }}",
pageList: ['10','25','50','100','150','200'], pageList: ['10','25','50','100','150','200','500','1000'],
exportOptions: {
fileName: 'assets-export-' + (new Date()).toISOString().slice(0,10),
},
icons: { icons: {
paginationSwitchDown: 'fa-caret-square-o-down', paginationSwitchDown: 'fa-caret-square-o-down',
paginationSwitchUp: 'fa-caret-square-o-up', paginationSwitchUp: 'fa-caret-square-o-up',
sort: 'fa fa-sort-amount-desc',
plus: 'fa fa-plus',
minus: 'fa fa-minus',
columns: 'fa-columns', columns: 'fa-columns',
refresh: 'fa-refresh' refresh: 'fa-refresh'
}, },
}); });
</script> </script>
@stop @stop

View file

@ -34,6 +34,13 @@
<div class="box-body"> <div class="box-body">
<div class="col-md-3"> <div class="col-md-3">
<div class="checkbox col-md-12">
<label>
{{ Form::checkbox('company', '1') }}
{{ trans('general.company') }}
</label>
</div>
<div class="checkbox col-md-12"> <div class="checkbox col-md-12">
<label> <label>
{{ Form::checkbox('company_name', '1') }} {{ Form::checkbox('company_name', '1') }}