Пример #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);
}
Пример #2
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);
}
Пример #3
0
/**
 * 删除收支类别
 */
function delete_bill_type()
{
    $billTypeId = $_REQUEST['billTypeId'];
    $code = '0';
    $billService = new BillService();
    // 校验类别下是否有记账
    if ($billService->countBill(null, null, $billTypeId) > 0) {
        $code = 'existBillInBillType';
    } else {
        $billTypeService = new BillTypeService();
        $billTypeService->deleteBillType($billTypeId);
    }
    $output = array('retCode' => $code);
    echo get_json($output);
}