<?php
// Get employee information
$stmt = $conn->prepare("SELECT * FROM employee WHERE id = ?");
$stmt->bind_param("i", $_SESSION['employee_id']);
$stmt->execute();
$result = $stmt->get_result();

if ($row = $result->fetch_assoc()) {
    $em_user = textUncode($row['em_user']);
    $em_role = $row['em_role'];
    $em_code = textUncode($row['em_code']);
    $em_email = textUncode($row['em_email']);
    $em_tel = textUncode($row['em_tel']);
    $em_permission_role_id=$row['em_permission_role_id'];
} else {
    $stmt->close();
    $conn->close();
    header("Location: /");
    exit;
}
$stmt->close();

?>

<div class="panel">
    <section>
        <h3><?= $em_user ?></h3>
        <div class="role_text">
            <?php
            $em_permission_role_array=array(0=>"普通",1=>"管理员",2=>"组长",3=>"组员",4=>"分公司",5=>"经销商",6=>"财务");
            echo $em_permission_role_array[$em_permission_role_id];

            ?>
        </div>
        <ul class="lxfs">
            <li class="tel"><?= $em_tel ?></li>
            <li class="mail"><?= $em_email ?></li>
        </ul>
    </section>
    <div>
        <dl>
            <?php if (checkAdminOrEmployee()): ?>
                <dt><a href="../home.php" target="contentFrame">客户查找</a></dt>
            <?php endif; ?>
            <dt><a href="../customerAdd.php" target="contentFrame">客户录入</a></dt>
            <!-- <dt><a href="relationships.php" target="contentFrame">客户关系</a></dt> -->
            <dt><a href="../rebate_summary.php" target="contentFrame">返点兑换</a></dt>
            <dt><a href="../order.php" target="contentFrame">订单管理</a></dt>
            <dt id="myCustomer" class="subnav">我的客户
                <div class="list-wraper">
                    <a href="../customers.php" target="contentFrame">全部客户  (<?= $_SESSION['t'] ?>)</a>
                    <a href="../customers.php?fliterBusiness=1" target="contentFrame">经销商  (<?= $_SESSION['t1'] ?>)</a>
                    <a href="../customers.php?fliterBusiness=2" target="contentFrame">零售  (<?= $_SESSION['t2'] ?>)</a>
                    <a href="../customers.php?fliterBusiness=3" target="contentFrame">连锁店铺  (<?= $_SESSION['t3'] ?>)</a>
                    <a href="../customers.php?fliterBusiness=4" target="contentFrame">中间商  (<?= $_SESSION['t4'] ?>)</a>
                    <a href="../customers.php?fliterDeal=2" target="contentFrame">明确需求  (<?= $_SESSION['d2'] ?>)</a>
                    <a href="../customers.php?fliterDeal=3" target="contentFrame">已经成交  (<?= $_SESSION['d1'] ?>)</a>
                    <a href="../customersNew.php" target="contentFrame">本月新增</a>
                    <?php if (checkAdminOrEmployee()): ?>
                        <a href="../customersFollow.php" target="contentFrame">即将加入公海 </a>
                        <a href="../highSeas.php" target="contentFrame">公司公海(60天无更新)</a>
                        <a href="../claimRecord.php" target="contentFrame">认领记录</a>
                        <a href="../abnormal.php" target="contentFrame" class="new">异常客户</a>
                    <?php endif; ?>
                </div>
            </dt>
            <?php if (checkAdminOrEmployee()): ?>

            <?php endif; ?>
            <?php
            //权限角色为的时候显示统计分析
            if(checkPermission(1,2,3))
            {

             ?>
            <dt class="subnav">统计分析
                <div class="list-wraper">
                                    <!-- <a href="../team.php" target="contentFrame">本月小组数据</a> -->
<!--                    <a href="statistics.php" target="contentFrame">汇总统计</a>-->
                    <a href="customers_stats.php" target="contentFrame">客户统计分析</a>
                    <a href="products_stats.php" target="contentFrame">产品统计分析</a>
                    <a href="region_stats.php" target="contentFrame">地区统计分析</a>
<!--                    <a href="sales_stats.php" target="contentFrame">销售统计分析</a>-->
                    <a href="statistics_order_warnings.php" target="contentFrame">订单预警系统</a>
                    <a href="monthly_deal_stats.php" target="contentFrame">每月成交客户统计</a>
                    <a href="region_performance_stats.php" target="contentFrame">每月区域新客户业绩</a>
                    <a href="inquiry_conversion_stats.php" target="contentFrame">客户来源转化率</a>
                    <a href="customer_composition_stats.php" target="contentFrame">每月业绩客户构成</a>

                </div>

            </dt>
            <?php }?>
            
            <dt><a href="../tagClound.php" target="contentFrame">标签云</a></dt>
            <?php if (checkAdminOrEmployee()): ?>
                <dt><a href="../silentCustomer.php" target="contentFrame">静默客户</a></dt>
            <?php endif; ?>
            <?php if(($em_role == 0)&&($em_permission_role_id==2)): ?>
                <dt class="subnav">我的团队
                    <div class="list-wraper">
                        <a href="../subCustomers.php" target="contentFrame">组员客户</a>
                        <a href="../subTagClound.php" target="contentFrame">组员客户分析</a>
                    </div>
                </dt>
            <?php endif; ?>
            <dt>
                <?php
                // 获取未读消息数量               
                $unread_count =  getUnreadMessageCount();

                ?>
                <a href="../message_list.php" target="contentFrame">消息列表
                    <?php if($unread_count > 0): ?>
                    <span class="badge badge-danger" style="background-color: #d9534f; color: white; padding: 2px 5px; border-radius: 50%; font-size: 12px; margin-left: 5px;"><?= $unread_count ?></span>
                    <?php endif; ?>
                </a>
            </dt>            
            <dt><a href="../pwdEdit.php" target="contentFrame">修改密码</a></dt>
            <dt><a href="../index.php?act=logout" onclick="return confirm('确认要退出吗?');">退出登录</a></dt>

        </dl>
    </div>
    <div class="copyright">
        <p>Version 1.5</p>
    </div>
    <?php if (strpos($em_code, "BX") === false): ?>
        <div class="statement">***注意事项***<br>所有业务务必全面录入客户资料,如发现有客户重复第一时间与前录入人沟通并妥善将与客户沟通的内容交接到原录入人,如故意隐瞒或者选择无视不交接,自愿接受退还客户及停止一个月官网询盘客户推送的惩罚,情节严重者按照违反公司利益进行辞退!</div>
    <?php endif; ?>
</div>