<?php

namespace App\Http\Controllers\Api;

use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
use App\Models\TblUserAuthenticate;
use Auth;
use DB;

class AppController extends Controller
{
    //
    //api-get-view-sub-contractor-agreement-app
    function GetViewSubContractorAgreementApp(Request $request)
    {
        //CALL USP_GET_SUB_CONTRACTOR_AGREEMENT_ACTIVITY_APP('VIEW_SUB_CONTRACTOR_AGREEMENT_FORM','SPECIFIC',1,@ERRNO,@ERRMSG);

        $payload = [
                'P_OPERATION_NAME' => 'VIEW_SUB_CONTRACTOR_AGREEMENT_FORM',
                'P_ITEM' => $request -> ITEM,
                'P_SUB_CONTRACTOR_SYS_ID' => $request -> SUB_CONTRACTOR_SYS_ID,      
        ];
        $response = DB::select("call USP_GET_SUB_CONTRACTOR_AGREEMENT_ACTIVITY_APP(:P_OPERATION_NAME, :P_ITEM, :P_SUB_CONTRACTOR_SYS_ID, @ERRNO,@ERRMSG)", $payload);
        if(!empty($response))
        {
            $response_decoded = json_decode($response[0]->JSON_VALUE, true);
            return $response_decoded;
        }
        else
        {
            $response_data = [ 'status' => 'false', 'response' => 'opps!! something went wrong',];
            return $response_data;
        }
    }
}
