<?php
namespace App\Http\Controllers\v2019;

use Illuminate\Http\Request;
use App\Http\Controllers\Controller;
use Illuminate\Support\Facades\DB;
use Illuminate\Http\JsonResponse;

class HistDataController extends Controller
{ 
    public function __construct(Request $request) {
        if($request->has('debug') && $request->input('debug') == true) {
            $this->debug = true;			
        }
    }
	
	public function getHistoricalDataList(Request $request)
    {      
		$result = array();
		//include_once "/home/steelmin/public_html/api/storage/v2019/reports_pre.php";
		$resourceType = "APP";		
		if ($request->has('resourceType'))
			$resourceType = strtolower($request->input('resourceType'));
			$tabType = strtolower($request->input('tabType'));
		if($resourceType=='web'){
			$code = 1001;
			$message = "Success";
			if ($request->has('memid') && $request->input('memid')!=''){
				include_once "/home/steelmin/public_html/api/storage/v2019/web/web_hist_data_pre.php";
			}else{
				include_once "/home/steelmin/public_html/api/storage/v2019/web/web_hist_data_pre.php";
			}
		} elseif($resourceType=='app') {
			
		}else{
			$code = 2001;
			$message = "invalid input";
		} 	
	   return new JsonResponse(array("status"=>array("code" => $code, "message" => $message), "data"=> $result));
    }  
	
	public function saveHistoricalData(Request $request){
		$result = array();
		$resourceType = "APP";		
		if ($request->has('resourceType'))
			$resourceType = strtolower($request->input('resourceType'));
		$tabType = strtolower($request->input('tabType'));
		if($resourceType=='web'){
			$code = 1001;
			$message = "Success";
			include_once "/home/steelmin/public_html/api/storage/v2019/web/web_hist_save_data_pre.php";
		} elseif($resourceType=='app') {
			
		}else{
			$code = 2001;
			$message = "invalid input";
		}
	   return new JsonResponse(array("status"=>array("code" => $code, "message" => $message), "data"=> $result));
	}

	public function downloadHistoricalData(Request $request){
		$result = array();
		$resourceType = "APP";		
		if ($request->has('resourceType'))
			$resourceType = strtolower($request->input('resourceType'));
		$tabType = strtolower($request->input('tabType'));
		if($resourceType=='web'){
			$code = 1001;
			$message = "Success";
			include_once "/home/steelmin/public_html/api/storage/v2019/web/web_hist_download_data_pre.php";
		} elseif($resourceType=='app') {
			
		}else{
			$code = 2001;
			$message = "invalid input";
		}
	   return new JsonResponse(array("status"=>array("code" => $code, "message" => $message), "data"=> $result));
	}

	public function saveRecentHistoricalData(Request $request){
		$result = array();
		$resourceType = "APP";
		if ($request->has('resourceType'))
			$resourceType = strtolower($request->input('resourceType'));
		$tabType = strtolower($request->input('tabType'));
		if($resourceType=='web'){
			$code = 1001;
			$message = "Success";
			include_once "/home/steelmin/public_html/api/storage/v2019/web/web_hist_recent_save_data.php";
		} elseif($resourceType=='app') {
			
		}else{
			$code = 2001;
			$message = "invalid input";
		}
	   return new JsonResponse(array("status"=>array("code" => $code, "message" => $message), "data"=> $result));
	}


  	
	
}
