<?php
/**
 * Created by PhpStorm.
 * User: Ludah
 * Date: 9/12/2017
 * Time: 5:24 AM
 */

function get_currency_mgt($dbc){
    $q = mysqli_query($dbc,"SELECT * FROM currencyexchange_tbl");
    $data = array();
    while ($row = mysqli_fetch_assoc($q)){
        $data[] = $row;
    }
    return $data;
}

function get_currency_mgt_by_id($dbc,$id){
    $q = mysqli_query($dbc,"SELECT * FROM currencyexchange_tbl WHERE id = '$id' ");
    $data = mysqli_fetch_assoc($q);
    return $data;
}

function get_currency_by_countryCode($dbc,$countryCode){
    $q = mysqli_query($dbc,"SELECT * FROM country_tbl WHERE countryCode = '$countryCode' ");
    $data = mysqli_fetch_assoc($q);
    return $data;
}

function update_exchangeRate($dbc,$id,$rate){
    $q = mysqli_query($dbc,"UPDATE currencyexchange_tbl SET conversionRate = '$rate', updated_by = '$_SESSION[uid]', updated_date = NOW() WHERE id = '$id'");
    if($q){
        return true;
    }
}

function get_forex_account($dbc){
    $q = mysqli_query($dbc,"SELECT * FROM payglobal_forex_account_tbl");
    $data = array();
    while ($row = mysqli_fetch_assoc($q)){
        $data[] = $row;
    }
    return $data;
}

function update_system_status($dbc,$service_type,$status){
    $q = mysqli_query($dbc,"UPDATE system_tbl SET status = '$status',updated_date = NOW(),updated_by = '$_SESSION[uid]' WHERE name = '$service_type'");
    if($q){
        return true;
    }
}

function get_system_status_by_serviceType($dbc,$serviceType){
    $q = mysqli_query($dbc,"SELECT * FROM system_tbl WHERE name = '$serviceType'");
    $data = mysqli_fetch_assoc($q);
    return $data;
}