<?php

function getPrincipalBranch($conn_rjllearning_specific, $institution_id, $branch_id)
{

    $branch_info = [];
        // Prepare and execute query to get branch details
        $getbranch = $conn_rjllearning_specific->prepare("SELECT id, name, city, pincode, address, contact_number, email FROM branch WHERE institution_id = ? AND id = ?");
        $getbranch->execute(array($institution_id, $branch_id));
        $branchresult = $getbranch->fetchAll();

        // Check and store branch information
        if (count($branchresult) > 0) {
            foreach ($branchresult as $branch) {
                $branch_info = array(
                    "branch_id" => $branch['id'],
                    "branch_name" => $branch['name'],
                    "city" => $branch['city'],
                    "pincode" => $branch['pincode'],
                    "address" => $branch['address'],
                    "contact_number" => $branch['contact_number'],
                    "email" => $branch['email'],
                );
            }
        }

    

    // Return the information
    return  $branch_info;
       
    
}






// function checkFileValidationFlutter($fileSize, $fileType, $file_extension, $allowed_file_size, $allowed_file_types, $allowed_file_extensions, $errormsg_for_type = null)
// {

//     // if (!in_array($fileType, $allowed_file_types) ) {
//     //     if ($errormsg_for_type == null) {
//     //         errorreturn("Only " . implode(", ", $allowed_file_extensions) . " are allowed to be uploaded.");
//     //     } else {
//     //         errorreturn($errormsg_for_type);
//     //     }
//     // }
//     if (!in_array($fileType, $allowed_file_types) && $fileType != 'application/octet-stream') {
//     errorreturn("Only " . implode(", ", $allowed_file_extensions) . " are allowed to be uploaded.");
//     } else {
//     // Handle the case where the MIME type is application/octet-stream
//     if ($fileType == 'application/octet-stream') {
//         if (!in_array($file_extension, $allowed_file_extensions)) {
//             errorreturn("Only " . implode(", ", $allowed_file_extensions) . " are allowed to be uploaded.");
//         }
//     }
//     }

//     if (!in_array($file_extension, $allowed_file_extensions)) {
//         errorreturn("Only " . implode(", ", $allowed_file_extensions) . " are allowed to be uploaded.");
//     }

//     // provide max file size in MB.
//     if ($fileSize > ($allowed_file_size * 1024 * 1024)) {
//         errorreturn("Please upload a valid image  with a size less than $allowed_file_size MB");
// }
// }
