Example #1
0
/**
 * 初始化记账管理基本数据
 */
function init_bill_manage_data()
{
    $userId = (int) $_SESSION['userId'];
    $code = '0';
    // 加载账户列表
    $accountDefault = get_user_config('accountDefault');
    $accountService = new AccountService();
    $accountList = $accountService->getAccountSimpleList($userId, null);
    $accountDebtList = $accountService->getAccountSimpleList($userId, 2);
    $accountCreditList = $accountService->getAccountSimpleList($userId, 3);
    // 加载收支类别列表
    $billTypeService = new BillTypeService();
    $billTypeList = $billTypeService->getBillTypeSimpleList($userId, null);
    $billTypeInList = array();
    $billTypeOutList = array();
    foreach ($billTypeList as $row) {
        // print_r($row);
        $flag = (int) $row['bill_type_flag'];
        if ($flag == 1) {
            $billTypeInList[] = $row;
        } else {
            if ($flag == 0) {
                $billTypeOutList[] = $row;
            }
        }
    }
    $output = array('retCode' => $code, 'accountDefault' => $accountDefault, 'accountList' => $accountList, 'accountDebtList' => $accountDebtList, 'accountCreditList' => $accountCreditList, 'billTypeList' => $billTypeList, 'billTypeInList' => $billTypeInList, 'billTypeOutList' => $billTypeOutList);
    echo get_json($output);
}
Example #2
0
/**
 * 获取账户简单列表
 */
function get_account_simple_list()
{
    $userId = $_SESSION['userId'];
    $accountTypeFlag = isset($_REQUEST['accountTypeFlag']) ? (int) $_REQUEST['accountTypeFlag'] : null;
    $accountService = new AccountService();
    $result = $accountService->getAccountSimpleList($userId, $accountTypeFlag);
    $code = '0';
    if ($result == null) {
        $code = '-1';
    }
    $output = array('retCode' => $code, 'accountList' => $result);
    echo get_json($output);
}
Example #3
0
/**
 * 收支趋势基础数据初始化
 */
function init_trend_statistic_data()
{
    $userId = (int) $_SESSION['userId'];
    $code = '0';
    // 获取首次记账年份,生成年份列表
    $billService = new BillService();
    $firstBillTime = $billService->getFirstBillTime($userId);
    $yearList = array();
    if ($firstBillTime != null) {
        $firstYear = (int) date('Y', $firstBillTime);
        $nowYear = (int) date('Y');
        if ($firstYear > $nowYear) {
            for ($i = $firstYear; $i <= $nowYear; $i++) {
                $yearList[] = array('yearVal' => (string) $i, 'yearStr' => (string) $i);
            }
        }
    } else {
        $yearList[] = array('yearVal' => date('Y'), 'yearStr' => date('Y'));
    }
    // 加载账户列表
    $accountService = new AccountService();
    $accountList = $accountService->getAccountSimpleList($userId, null);
    // 加载收支类别列表
    $billTypeService = new BillTypeService();
    $billTypeList = $billTypeService->getBillTypeSimpleList($userId, null);
    $output = array('retCode' => $code, 'yearList' => $yearList, 'accountList' => $accountList, 'billTypeList' => $billTypeList);
    echo get_json($output);
}