<?php

function getSpecificGlobalSettings($conn_rjllearning_specific,$institution_id,$branch_id) {
    
    $sql = $conn_rjllearning_specific->prepare("SELECT * FROM  institution_global_settings where institution_id =? AND branch_id  = ? ");
    $sql->execute(array($institution_id,$branch_id));
    $rows = $sql->fetchAll();
    $array_return = [];
    // print_r($rows);die();
    if (count($rows) >= 1) {
            
        $branch_info = getBranchInfo($conn_rjllearning_specific, $institution_id, $rows[0]['branch_id']);
        $faculty_attendance_setting = $rows[0]['faculty_attendance_setting'] !== null ? json_decode($rows[0]['faculty_attendance_setting'], true) : [];
        $accounting_setting = $rows[0]['accounting_setting'] !== null ? json_decode($rows[0]['accounting_setting'], true) : [];
        $birthday_setting = $rows[0]['other'] !== null ? json_decode($rows[0]['other'], true) : [];
        $fee_concession_application = $rows[0]['fee_concession_application'];
        
        $send_sms_on_fee_receipt = $rows[0]['send_sms_on_fee_receipt'];

         $array_return[]  = array('setting_id'=> $rows[0]['id'],'institution_id'=> $rows[0]['institution_id'],'branch_id'=> $branch_info,'attendance_system'=> $rows[0]['attendance_system'],
         'faculty_attendance_setting' => $faculty_attendance_setting,'birthday_setting'=>$birthday_setting,'accounting_setting' => $accounting_setting,'fee_concession_application'=>$fee_concession_application,
         'send_sms_on_fee_receipt'=>$send_sms_on_fee_receipt);
      
    }
    // else{
    //       errorreturn("Invalid global settings.");
    // }
    return  $array_return;

}