public function officeAssetsReports()
 {
     if (Session::has('username') && (Session::get('user_type') == "Root" || Session::get('user_type') == "Admin" || Session::get("user_type") == "User")) {
         $view = View::make("Reports.office_assets_reports");
         $view->nav = "system";
         $view->tab = "office";
         $totalOfficeAssets = Asset::whereHas("classification", function ($q) {
             $q->where("type", "=", "Office");
         })->get()->count();
         //Summary
         $printers = Asset::whereHas("classification", function ($q) {
             $q->where("name", "=", "Printers");
         })->get()->count();
         $projectors = Asset::whereHas("classification", function ($q) {
             $q->where("name", "=", "Projectors");
         })->get()->count();
         $otherAssets = Asset::whereHas("classification", function ($q) {
             $q->where("name", "=", "Other Assets");
         })->get()->count();
         if ($totalOfficeAssets > 0) {
             $printersPercentage = $printers > 0 ? $printers / $totalOfficeAssets * 100 : "0.00";
             $projectorsPercentage = $projectors > 0 ? $projectors / $totalOfficeAssets * 100 : "0.00";
             $otherAssetsPercentage = $otherAssets > 0 ? $otherAssets / $totalOfficeAssets * 100 : "0.00";
         } else {
             $printersPercentage = "0.00";
             $projectorsPercentage = "0.00";
             $otherAssetsPercentage = "0.00";
         }
         $view->totalOfficeAssets = $totalOfficeAssets;
         $view->printers = $printers;
         $view->projectors = $projectors;
         $view->otherAssets = $otherAssets;
         $view->printersPercentage = $printersPercentage;
         $view->projectorsPercentage = $projectorsPercentage;
         $view->otherAssetsPercentage = $otherAssetsPercentage;
         //Status
         //Printer Status
         $p_available = Asset::where("status", "=", "Available")->whereHas("classification", function ($q) {
             $q->where("name", "=", "Printers");
         })->count();
         $p_for_repair = Asset::where("status", "=", "For Repair")->whereHas("classification", function ($q) {
             $q->where("name", "=", "Printers");
         })->count();
         $p_installed = Asset::where("status", "=", "Installed")->whereHas("classification", function ($q) {
             $q->where("name", "=", "Printers");
         })->count();
         $p_lost = Asset::where("status", "=", "Lost")->whereHas("classification", function ($q) {
             $q->where("name", "=", "Printers");
         })->count();
         $p_retired = Asset::where("status", "=", "Retired")->whereHas("classification", function ($q) {
             $q->where("name", "=", "Printers");
         })->count();
         $view->p_available = $p_available;
         $view->p_for_repair = $p_for_repair;
         $view->p_installed = $p_installed;
         $view->p_lost = $p_lost;
         $view->p_retired = $p_retired;
         //Projector Status
         $pro_available = Asset::where("status", "=", "Available")->whereHas("classification", function ($q) {
             $q->where("name", "=", "Projectors");
         })->count();
         $pro_for_repair = Asset::where("status", "=", "For Repair")->whereHas("classification", function ($q) {
             $q->where("name", "=", "Projectors");
         })->count();
         $pro_installed = Asset::where("status", "=", "Installed")->whereHas("classification", function ($q) {
             $q->where("name", "=", "Projectors");
         })->count();
         $pro_lost = Asset::where("status", "=", "Lost")->whereHas("classification", function ($q) {
             $q->where("name", "=", "Projectors");
         })->count();
         $pro_retired = Asset::where("status", "=", "Retired")->whereHas("classification", function ($q) {
             $q->where("name", "=", "Projectors");
         })->count();
         $view->pro_available = $pro_available;
         $view->pro_for_repair = $pro_for_repair;
         $view->pro_installed = $pro_installed;
         $view->pro_lost = $pro_lost;
         $view->pro_retired = $pro_retired;
         //Other Assets Status
         $o_available = Asset::where("status", "=", "Available")->whereHas("classification", function ($q) {
             $q->where("name", "=", "Other Assets");
         })->count();
         $o_for_repair = Asset::where("status", "=", "For Repair")->whereHas("classification", function ($q) {
             $q->where("name", "=", "Other Assets");
         })->count();
         $o_installed = Asset::where("status", "=", "Installed")->whereHas("classification", function ($q) {
             $q->where("name", "=", "Other Assets");
         })->count();
         $o_lost = Asset::where("status", "=", "Lost")->whereHas("classification", function ($q) {
             $q->where("name", "=", "Other Assets");
         })->count();
         $o_retired = Asset::where("status", "=", "Retired")->whereHas("classification", function ($q) {
             $q->where("name", "=", "Other Assets");
         })->count();
         $view->o_available = $o_available;
         $view->o_for_repair = $o_for_repair;
         $view->o_installed = $o_installed;
         $view->o_lost = $o_lost;
         $view->o_retired = $o_retired;
         return $view;
     } else {
         return Redirect::to("/");
     }
 }
Beispiel #2
0
        echo $a->employee->last_name . "<br/>";
    }
});
Route::get("dummy4", function () {
    // 	$logs = UserLog::whereBetween("datetime",array("2014-12-01","2014-12-02"." 23:59:59.000000"))->get();
    // 	foreach($logs as $l){
    // 		echo $l->datetime."<br/>";
    // 	}
    // 	$g1 = Asset::whereHas("classification",function($query){
    // 			$query->where("name","=","Laptops");
    // 		  })
    // 		  ->whereHas("model",function($query){
    // 			$query->where("id","=",1);
    // 		  })
    // 		  ->where("status","=","Available")
    // 		  ->get();
    // 	echo count($g1);
    $models = Model::whereHas("classification", function ($query) {
        $query->where("name", "=", "Laptops");
    })->get();
    foreach ($models as $m) {
        $assets[$m->id] = Asset::whereHas("model", function ($query) use($m) {
            $query->where("id", "=", $m->id);
        })->where("status", "=", "Available")->count();
        // 		echo $m->name.": ".count($assets)."<br/>";
    }
    //loop models again
    foreach ($models as $m) {
        echo $m->name . ": " . $assets[$m->id] . "<br/>";
    }
});
 public function exportOffice()
 {
     if (Session::has('username') && (Session::get('user_type') == "Root" || Session::get('user_type') == "Admin")) {
         $view = View::make("Export.export_office");
         $view->nav = "system";
         $view->tab = "office";
         $view->assets = Asset::whereHas("classification", function ($query) {
             $query->where("type", "=", "Office");
         })->paginate(25);
         $view->results = Asset::whereHas("classification", function ($query) {
             $query->where("type", "=", "Office");
         })->count();
         $getAssetClassifications = AssetClassification::where("type", "=", "Office")->get();
         $assetClassifications = array("" => "All");
         foreach ($getAssetClassifications as $gac) {
             $assetClassifications[$gac->id] = $gac->name;
         }
         $view->assetClassifications = $assetClassifications;
         $getAssetModels = Model::whereHas('classification', function ($query) {
             $query->where("type", "=", "Office");
         })->orderBy("name", "asc")->get();
         $assetModels = array("" => "--Select One--");
         foreach ($getAssetModels as $gam) {
             $assetModels[$gam->id] = $gam->name;
         }
         $view->assetModels = $assetModels;
         return $view;
     } else {
         return Redirect::to("/");
     }
 }
 public function advancedSearch()
 {
     if (Session::has('username') && (Session::get('user_type') == "Root" || Session::get('user_type') == "Admin" || Session::get("user_type") == "User")) {
         $view = View::make("Assets.Network.network_advanced_search");
         $view->nav = "assets";
         $view->tab = "search";
         $view->assets = Asset::whereHas("classification", function ($query) {
             $query->where("type", "=", "Network");
         })->paginate(25);
         $view->results = Asset::whereHas("classification", function ($query) {
             $query->where("type", "=", "Network");
         })->count();
         $getAssetClassifications = AssetClassification::where("type", "=", "Network")->get();
         $assetClassifications = array("" => "All");
         foreach ($getAssetClassifications as $gac) {
             $assetClassifications[$gac->id] = $gac->name;
         }
         $view->assetClassifications = $assetClassifications;
         $getAssetModels = Model::whereHas('classification', function ($query) {
             $query->where("type", "=", "Network");
         })->orderBy("name", "asc")->get();
         $assetModels = array("" => "--Select One--");
         foreach ($getAssetModels as $gam) {
             $assetModels[$gam->id] = $gam->name;
         }
         $view->assetModels = $assetModels;
         return $view;
     } else {
         return Redirect::to("/");
     }
 }
 public function generateWaiver($assetClass, $id)
 {
     if (Session::has('username') && (Session::get('user_type') == "Root" || Session::get('user_type') == "Admin")) {
         $asset = Asset::whereHas("classification", function ($q) use($assetClass) {
             $q->where("url_key", "=", $assetClass)->where("type", "=", "Client");
         })->where("id", "=", $id)->first();
         if (!$asset) {
             return Redirect::to("assets");
         } else {
             if (empty($asset->employee->last_name)) {
                 return Redirect::to("assets/client/update/" . $assetClass . "/" . $asset->id)->with("message", "Cannot generate waiver to unassigned assets.");
             }
         }
         return $this->generatePdf($asset);
     } else {
         return Redirect::to("/");
     }
 }