<?php

namespace App\Http\Controllers;

use App\HargaEmas;
use App\GlCode;
use App\Cawangan;
use Illuminate\Http\Request;

use Carbon\Carbon;

class GLCodeController extends Controller
{



    public function GetGlcode($kodcaw,Request $request) //create on 2021-02-12
    {


        $current = Carbon::now();
        $current = new Carbon();

        $cawangan = Cawangan::on('mysql7')->where('kodcaw','=',$kodcaw)->first();



        $gc=GlCode::on($cawangan['mysql'])->where('glcode','=',$request->glcode)->get();
        return response()->json($gc);


    }

    public function GetGlcodeByActType($kodcaw,$acttype)
    {
        $current = Carbon::now();
        $current = new Carbon();

        $cawangan = Cawangan::on('mysql7')->where('kodcaw','=',$kodcaw)->first();
        
        $gc=GlCode::on($cawangan['mysql'])->where('acttype','=',$acttype)->get();
        
        return response()->json($gc);
    }








}