<?php

namespace Option\Lib;

use Dever;

class Member
{
    public function getInfo($id)
    {
        if ($id < 0) {
            return '无';
        }
        $account = Dever::db('option/member')->find($id);
        if ($account) {
            $string = $account['name'] . '<br />' . $account['mobile'] . '<br />' . $account['idcard'] . '<br />' . $account['key'];
            return $string;
            
        } else {
            return '';
        }
    }

    public function search_api()
    {
        $value = Dever::input('value');
        if ($value) {
            $data = Dever::db('option/member')->getList(array('key' => $value));
            $table = array();
            if ($data) {
                $table = array();
                $table['head'] = array('序列号', '姓名', '手机号', '类型');
                $table['body'] = array();
                foreach ($data as $k => $v) {
                    if ($v['main'] == 1) {
                        $main = '主账号';
                    } else {
                        $main = '子账号';
                    }
                    $table['body'][] = array($v['key'], $v['name'], $v['mobile'], $main);
                }

                $result[] = array
                (
                    'type' => 'table',
                    'content' => $table,
                );

                $html = Dever::show('', $result, false, false);
                return $html;
            }

            return '暂无账号';
        } else {
            return '';
        }
    }
}