66use App \Models \Asset ;
77use App \Models \AssetMaintenance ;
88use Carbon \Carbon ;
9- use Category ;
109use App \Models \Company ;
1110use Illuminate \Support \Facades \Lang ;
1211use Illuminate \Support \Facades \Log ;
1716use App \Models \License ;
1817use App \Models \Location ;
1918use App \Models \AssetModel ;
19+ use App \Models \CustomField ;
2020use Redirect ;
2121use App \Models \Setting ;
2222use App \Models \User ;
@@ -415,8 +415,8 @@ public function exportLicenseReport()
415415 */
416416 public function getCustomReport ()
417417 {
418-
419- return View::make ('reports/custom ' );
418+ $ customfields = CustomField:: get ();
419+ return View::make ('reports/custom ' )-> with ( ' customfields ' , $ customfields ) ;
420420 }
421421
422422 /**
@@ -430,6 +430,7 @@ public function getCustomReport()
430430 public function postCustom ()
431431 {
432432 $ assets = Asset::orderBy ('created_at ' , 'DESC ' )->get ();
433+ $ customfields = CustomField::get ();
433434
434435 $ rows = [ ];
435436 $ header = [ ];
@@ -484,6 +485,13 @@ public function postCustom()
484485 $ header [] = 'Diff ' ;
485486 }
486487
488+ foreach ($ customfields as $ customfield ) {
489+ if (e (Input::get ($ customfield ->db_column_name ())) == '1 ' ) {
490+ $ header [] = $ customfield ->name ;
491+ }
492+ }
493+
494+
487495 $ header = array_map ('trim ' , $ header );
488496 $ rows [] = implode ($ header , ', ' );
489497
@@ -562,6 +570,16 @@ public function postCustom()
562570 $ row [] = '' ; // Empty string if unassigned
563571 }
564572 }
573+
574+ if (e (Input::get ('username ' )) == '1 ' ) {
575+ if ($ asset ->assigned_to > 0 ) {
576+ $ user = User::find ($ asset ->assigned_to );
577+ $ row [] = '" ' .e ($ user -username). '" ' ;
578+ } else {
579+ $ row [] = '' ; // Empty string if unassigned
580+ }
581+ }
582+
565583 if (e (Input::get ('status ' )) == '1 ' ) {
566584 if (( $ asset ->status_id == '0 ' ) && ( $ asset ->assigned_to == '0 ' )) {
567585 $ row [] = trans ('general.ready_to_deploy ' );
@@ -588,6 +606,15 @@ public function postCustom()
588606 $ row [] = '" ' . number_format ($ depreciation , 2 ) . '" ' ;
589607 $ row [] = '" ' . number_format ($ asset ->purchase_cost - $ depreciation , 2 ) . '" ' ;
590608 }
609+
610+ foreach ($ customfields as $ customfield ) {
611+ $ column_name = $ customfield ->db_column_name ();
612+ if (e (Input::get ($ customfield ->db_column_name ())) == '1 ' ) {
613+ $ row [] = $ asset ->$ column_name ;
614+ }
615+ }
616+
617+
591618 $ rows [] = implode ($ row , ', ' );
592619 }
593620
0 commit comments