<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB;

class MasterController extends Controller
{
    public function clearCache()
    {
        \Artisan::call('cache:clear');
        return view('clear-cache');
    }
    
    /////****LFUMIS Master******/////
    public function lfumisinsert(Request $request)
    { 
        $lfumis_name = $request->input('lfumis_name');
        $lfumis_id = $request->input('lfumis_id');
        $data=array("lfumis_name"=>$lfumis_name,"lfumis_id"=>$lfumis_id);
        $insdata = DB::table('lfu_mis_master')->insert($data);
        return redirect('lfumis-master-data');
    }
    
    public function getlfumis(Request $request)
    {
        $getdata = DB::table('lfu_mis_master')->get();
        return view('pages.lfumis-master-data', compact('getdata'));
    }
    
    public function deletelfumis($id)
    { 
        $getdata = DB::table('lfu_mis_master')->delete($id);
        return redirect('lfumis-master-data');
    }
    
    public function showlfumis($id)
    {  
         $showdata = DB::table('lfu_mis_master')->where('id','=',$id)->get();
         return view('pages.lfumis-master', compact('showdata'));
    }

    public function updatelfumis(Request $request)
    { 
        $lfumis_name = $request->input('lfumis_name');
        $lfumis_id = $request->input('lfumis_id');
        $data=array("lfumis_name"=>$lfumis_name,"lfumis_id"=>$lfumis_id);
        $insdata = DB::table('lfu_mis_master')->where('id',$request->id)->update($data);
        return redirect('lfumis-master-data');
    }

    /////****HD Master******/////
    public function hdinsert(Request $request)
    { 
        $hd_outcome = $request->input('hd_outcome');
        $hd_id = $request->input('hd_id');
        $data=array("hd_outcome"=>$hd_outcome,"hd_id"=>$hd_id);
        $insdata = DB::table('hd_master')->insert($data);
        return redirect('hd-master-data');
    }
    
    public function gethdmaster(Request $request)
    {
        $getdata = DB::table('hd_master')->get();
        return view('pages.hd-master-data', compact('getdata'));
    }
    
    public function deletehd($id)
    { 
        $getdata = DB::table('hd_master')->delete($id);
        return redirect('hd-master-data');
    }

    public function showhd($id)
    {  
         $showdata = DB::table('hd_master')->where('id','=',$id)->get();
         return view('pages.hd-master', compact('showdata'));
    }

    public function updatehd(Request $request)
    { 
        $hd_outcome = $request->input('hd_outcome');
        $hd_id = $request->input('hd_id');
        $data=array("hd_outcome"=>$hd_outcome,"hd_id"=>$hd_id);
        $insdata = DB::table('hd_master')->where('id',$request->id)->update($data);
        return redirect('hd-master-data');
    }

    /////****VL Master******/////
    public function vlinsert(Request $request)
    { 
        $vl_outcome = $request->input('vl_outcome');
        $vl_id = $request->input('vl_id');
        $data=array("vl_outcome"=>$vl_outcome,"vl_id"=>$vl_id);
        $insdata = DB::table('vl_master')->insert($data);
        return redirect('vl-master-data');
    }
    
    public function getvlmaster(Request $request)
    {
        $getdata = DB::table('vl_master')->get();
        return view('pages.vl-master-data', compact('getdata'));
    }

    public function deletevl($id)
    { 
        $getdata = DB::table('vl_master')->delete($id);
        return redirect('vl-master-data');
    }
    
    public function showvl($id)
    {  
         $showdata = DB::table('vl_master')->where('id','=',$id)->get();
         return view('pages.vl-master', compact('showdata'));
    }

    public function updatevl(Request $request)
    { 
        $vl_outcome = $request->input('vl_outcome');
        $vl_id = $request->input('vl_id');
        $data=array("vl_outcome"=>$vl_outcome,"vl_id"=>$vl_id);
        $insdata = DB::table('vl_master')->where('id',$request->id)->update($data);
        return redirect('vl-master-data');
    }

    /////****LFU (CI) Master******/////
    public function lfuciinsert(Request $request)
    { 
        $lfu_ci_outcome = $request->input('lfu_ci_outcome');
        $lfu_ci_id = $request->input('lfu_ci_id');
        $data=array("lfu_ci_outcome"=>$lfu_ci_outcome,"lfu_ci_id"=>$lfu_ci_id);
        $insdata = DB::table('lfu_ci_master')->insert($data);
        return redirect('lfuci-master-data');
    }
    
    public function getlfucimaster(Request $request)
    {
        $getdata = DB::table('lfu_ci_master')->get();
        return view('pages.lfuci-master-data', compact('getdata'));
    }

    public function deletelfuci($id)
    { 
        $getdata = DB::table('lfu_ci_master')->delete($id);
        return redirect('lfuci-master-data');
    }
    
    public function showlfuci($id)
    {  
         $showdata = DB::table('lfu_ci_master')->where('id','=',$id)->get();
         return view('pages.lfuci-master', compact('showdata'));
    }

    public function updatelfuci(Request $request)
    { 
        $lfu_ci_outcome = $request->input('lfu_ci_outcome');
        $lfu_ci_id = $request->input('lfu_ci_id');
        $data=array("lfu_ci_outcome"=>$lfu_ci_outcome,"lfu_ci_id"=>$lfu_ci_id);
        $insdata = DB::table('lfu_ci_master')->where('id',$request->id)->update($data);
        return redirect('lfuci-master-data');
    }

    /////****CD4 (CI) Master******/////
    public function cd4ciinsert(Request $request)
    { 
        $cd4_ci_outcome = $request->input('cd4_ci_outcome');
        $cd4_ci_id = $request->input('cd4_ci_id');
        $data=array("cd4_ci_outcome"=>$cd4_ci_outcome,"cd4_ci_id"=>$cd4_ci_id);
        $insdata = DB::table('cd4_ci_master')->insert($data);
        return redirect('cd4ci-master-data');
    }
    
    public function getcd4cimaster(Request $request)
    {
        $getdata = DB::table('cd4_ci_master')->get();
        return view('pages.cd4ci-master-data', compact('getdata'));
    }
    
    public function deletecd4ci($id)
    { 
        $getdata = DB::table('cd4_ci_master')->delete($id);
        return redirect('cd4ci-master-data');
    }

    public function showcd4ci($id)
    {  
         $showdata = DB::table('cd4_ci_master')->where('id','=',$id)->get();
         return view('pages.cd4ci-master', compact('showdata'));
    }

    public function updatecd4ci(Request $request)
    { 
        $cd4_ci_outcome = $request->input('cd4_ci_outcome');
        $cd4_ci_id = $request->input('cd4_ci_id');
        $data=array("cd4_ci_outcome"=>$cd4_ci_outcome,"cd4_ci_id"=>$cd4_ci_id);
        $insdata = DB::table('cd4_ci_master')->where('id',$request->id)->update($data);
        return redirect('cd4ci-master-data');
    }

    /////****Due Date Call Master******/////
    public function duedateinsert(Request $request)
    { 
        $due_date_outcome = $request->input('due_date_outcome');
        $due_date_id = $request->input('due_date_id');
        $data=array("due_date_outcome"=>$due_date_outcome,"due_date_id"=>$due_date_id);
        $insdata = DB::table('due_date_master')->insert($data);
        return redirect('duedate-master-data');
    }
    
    public function getduedatemaster(Request $request)
    {
        $getdata = DB::table('due_date_master')->get();
        return view('pages.duedate-master-data', compact('getdata'));
    }

    public function deleteduedate($id)
    { 
        $getdata = DB::table('due_date_master')->delete($id);
        return redirect('duedate-master-data');
    }
    
    public function showduedate($id)
    {  
         $showdata = DB::table('due_date_master')->where('id','=',$id)->get();
         return view('pages.duedate-master', compact('showdata'));
    }

    public function updateduedate(Request $request)
    { 
        $due_date_outcome = $request->input('due_date_outcome');
        $due_date_id = $request->input('due_date_id');
        $data=array("due_date_outcome"=>$due_date_outcome,"due_date_id"=>$due_date_id);
        $insdata = DB::table('due_date_master')->where('id',$request->id)->update($data);
        return redirect('duedate-master-data');
    }

    /////****TB Follow up Master******/////
    public function tbfollowinsert(Request $request)
    { 
        $tb_outcome = $request->input('tb_outcome');
        $tb_id = $request->input('tb_id');
        $data=array("tb_outcome"=>$tb_outcome,"tb_id"=>$tb_id);
        $insdata = DB::table('tb_follow_master')->insert($data);
        return redirect('tbfollow-master-data');
    }
    
    public function gettbfollowmaster(Request $request)
    {
        $getdata = DB::table('tb_follow_master')->get();
        return view('pages.tbfollow-master-data', compact('getdata'));
    }
    
    public function deletetbfolllow($id)
    { 
        $getdata = DB::table('tb_follow_master')->delete($id);
        return redirect('tbfollow-master-data');
    }

    public function showtbfolllow($id)
    {  
         $showdata = DB::table('tb_follow_master')->where('id','=',$id)->get();
         return view('pages.tbfollow-master', compact('showdata'));
    }

    public function updatetbfollow(Request $request)
    { 
        $tb_outcome = $request->input('tb_outcome');
        $tb_id = $request->input('tb_id');
        $data=array("tb_outcome"=>$tb_outcome,"tb_id"=>$tb_id);
        $insdata = DB::table('tb_follow_master')->where('id',$request->id)->update($data);
        return redirect('tbfollow-master-data');
    }

    /////****BTA Master******/////
    public function btainsert(Request $request)
    { 
        $bta_barriers = $request->input('bta_barriers');
        $bta_id = $request->input('bta_id');
        $data=array("bta_barriers"=>$bta_barriers,"bta_id"=>$bta_id);
        $insdata = DB::table('bta_master')->insert($data);
        return redirect('bta-master-data');
    }
    
    public function getbtamaster(Request $request)
    {
        $getdata = DB::table('bta_master')->get();
        return view('pages.bta-master-data', compact('getdata'));
    }
    
    public function deletebta($id)
    { 
        $getdata = DB::table('bta_master')->delete($id);
        return redirect('bta-master-data');
    }

    public function showbta($id)
    {  
         $showdata = DB::table('bta_master')->where('id','=',$id)->get();
         return view('pages.bta-master', compact('showdata'));
    }

    public function updatebta(Request $request)
    { 
        $bta_barriers = $request->input('bta_barriers');
        $bta_id = $request->input('bta_id');
        $data=array("bta_barriers"=>$bta_barriers,"bta_id"=>$bta_id);
        $insdata = DB::table('bta_master')->where('id',$request->id)->update($data);
        return redirect('bta-master-data');
    }

    /////****INT Master******/////
    public function intinsert(Request $request)
    { 
        $int_support = $request->input('int_support');
        $int_id = $request->input('int_id');
        $data=array("int_support"=>$int_support,"int_id"=>$int_id);
        $insdata = DB::table('int_master')->insert($data);
        return redirect('int-master-data');
    }
    
    public function getintmaster(Request $request)
    {
        $getdata = DB::table('int_master')->get();
        return view('pages.int-master-data', compact('getdata'));
    }
    
    public function deleteint($id)
    { 
        $getdata = DB::table('int_master')->delete($id);
        return redirect('int-master-data');
    }
    
    public function showint($id)
    {  
         $showdata = DB::table('int_master')->where('id','=',$id)->get();
         return view('pages.int-master', compact('showdata'));
    }

    public function updateint(Request $request)
    { 
        $int_support = $request->input('int_support');
        $int_id = $request->input('int_id');
        $data=array("int_support"=>$int_support,"int_id"=>$int_id);
        $insdata = DB::table('int_master')->where('id',$request->id)->update($data);
        return redirect('int-master-data');
    }

    /////****ADH Master******/////
    public function adhinsert(Request $request)
    { 
        $adh_level = $request->input('adh_level');
        $adh_id = $request->input('adh_id');
        $data=array("adh_level"=>$adh_level,"adh_id"=>$adh_id);
        $insdata = DB::table('adh_master')->insert($data);
        return redirect('adh-master-data');
    }
    
    public function getadhmaster(Request $request)
    {
        $getdata = DB::table('adh_master')->get();
        return view('pages.adh-master-data', compact('getdata'));
    }

    public function deleteadh($id)
    { 
        $getdata = DB::table('adh_master')->delete($id);
        return redirect('adh-master-data');
    }

    public function showadh($id)
    {  
         $showdata = DB::table('adh_master')->where('id','=',$id)->get();
         return view('pages.adh-master', compact('showdata'));
    }

    public function updateadh(Request $request)
    { 
        $adh_level = $request->input('adh_level');
        $adh_id = $request->input('adh_id');
        $data=array("adh_level"=>$adh_level,"adh_id"=>$adh_id);
        $insdata = DB::table('adh_master')->where('id',$request->id)->update($data);
        return redirect('adh-master-data');
    }

    /////****SUP Master******/////
    public function supinsert(Request $request)
    { 
        $sup_reason = $request->input('sup_reason');
        $sup_id = $request->input('sup_id');
        $data=array("sup_reason"=>$sup_reason,"sup_id"=>$sup_id);
        $insdata = DB::table('sup_master')->insert($data);
        return redirect('sup-master-data');
    }
    
    public function getsupmaster(Request $request)
    {
        $getdata = DB::table('sup_master')->get();
        return view('pages.sup-master-data', compact('getdata'));
    }

    public function deletesup($id)
    { 
        $getdata = DB::table('sup_master')->delete($id);
        return redirect('sup-master-data');
    }

    public function showsup($id)
    {  
         $showdata = DB::table('sup_master')->where('id','=',$id)->get();
         return view('pages.sup-master', compact('showdata'));
    }

    public function updatesup(Request $request)
    { 
        $sup_reason = $request->input('sup_reason');
        $sup_id = $request->input('sup_id');
        $data=array("sup_reason"=>$sup_reason,"sup_id"=>$sup_id);
        $insdata = DB::table('sup_master')->where('id',$request->id)->update($data);
        return redirect('sup-master-data');
    }
}
