<?php include_once(mvc::$cfg['PATH_TPL'].'public/headBase.php');?>

<div class="layui-card">
    <!--  -->
    <div class="right-content" >
        <form class="layui-form" action="" method="get" id="yjtable">
            <table  class="layui-table" style="width: 1480px;">
                <thead>
                    <tr>
                        <th colspan="21" >
                        <?php if($saleArr){?>
                            <div class="layui-inline">
                                <label class="layui-form-label">业务员</label>
                                <div class="layui-input-block">
                                    <select name="yj_au_uid" lay-filter="yj_au_uid">
                                        <option value="">请选择</option>
                                        <?php foreach($saleArr as $skey => $val){?>
                                            <optgroup label="<?=$skey?>">
                                                <?php foreach ($val as $kk => $vv) {?>
                                                    <option value="<?=$kk?>" <?php if($Params['yj_au_uid']==$kk){echo 'selected';}?>><?=$vv?></option>
                                                <?php } ?>
                                            </optgroup>    
                                        <?php }?>
                                    </select>
                                </div>
                            </div>
                            <?php }?>
                            <?=$Params['betime']?>业绩
                            <div class="layui-inline">
                                <label class="layui-form-label">时间区间</label>
                                <div class="layui-input-inline">
                                    <input type="text" name="betime" autocomplete="off" id="betime" class="layui-input" value="<?php echo $Params['betime'];?>" placeholder=" ~ ">
                                </div>
                                <div class="layui-input-inline">
                                    <?php foreach($fastTime as $k=>$v){?>
                                        <a href="javascript:;" data-betime="<?php echo $v;?>" style="margin-left:10px;" class="a_blue"><?php echo $k;?></a>
                                    <?php }?>
                                </div>

                                <div class="layui-input-inline w100">
                                    <select lay-filter="fastYear">
                                        <option value="">按年度</option>
                                        <?php foreach($fastYear as $k=> $v){?>
                                            <option value="<?php echo $v;?>" <?php if($Params['betime'] === $v) echo ' selected'; ?>><?php echo $k;?></option>
                                        <?php }?>
                                    </select>
                                </div>
                            </div>
                            <div class="layui-inline" style="margin-left: 10px;">
                                <button class="layui-btn act-btn" type="submit">
                                    <i class="layui-icon layui-icon-search layuiadmin-button-btn"></i>
                                </button>
                            </div>
                        </th>
                    </tr>
                    <tr>
                        <th rowspan="2">业务员</th>
                        <th colspan="13" style="text-align: center;">宜配</th>
                        <th colspan="10" style="text-align: center;">跑街</th>
                        <!-- <th rowspan="2">续费</th> -->
                        <th rowspan="2" style="color:#FF0000">合计</th>
                        <th rowspan="2">业绩目标</th>
                    </tr>
                    <tr>
                        <th>网站</th>
                        <th>联动服务</th>
                        <th>广告</th>
                        <th width="80px">PDF目录</th>
                        <th>软件</th>
                        <th>软件定制</th>
                        <th style="color:#FF0000">小计(新业绩)</th>
                        <th>网站续费</th>
                        <th>软件年费</th>
                        <th>软件服务费</th>
                        <th>联动服务续费</th>
                        <th>其他</th>
                        <th style="color:#FF0000">宜配总计</th>

                        <th>商家入驻</th>
                        <th>PC会员</th>
                        <th>广告</th>
                        <th>招商加盟</th>
                        <th>机器人</th>
                        <th>资源包</th>
                        <th width="60px">推送服务</th>
                        <th>打电话</th>
                        <th>其它</th>   
                        <th style="color:#FF0000">小计</th>
                    </tr>
                </thead>
                <tbody>
                    <?php foreach ($yjArr as $valArr) {?>
                        <tr>
                            <?php foreach ($showField as $fkey => $fval) {?>
                                <?php if(is_array($valArr[$fkey])){?>
                                    <td style="<?=$valArr[$fkey]['color']?'color:#'.$valArr[$fkey]['color']:''?>;<?=$valArr[$fkey]['font-weight']?'font-weight:'.$valArr[$fkey]['font-weight']:''?>"><?=$valArr[$fkey]['value']?></td>
                                <?php }else{ ?>
                                    <td><?=$valArr[$fkey]?></td>
                                <?php }?>
                            <?php } ?>

                        </tr>
                    <?php } ?>
                </tbody>
            </table>
   
            <!--  -->
            <br />
            <br />
            <br />
            <br />
        
        
            <div style="width: 980px;">
                <table  class="layui-table YpTable">
                    <thead>
                        <tr>
                            <th colspan="6">我该做什么 # <?=$Params['plandate']?date('Ymd',strtotime($Params['plandate'])):date('Ymd')?></th>
                        </tr>
                    </thead>
                    <tbody>
                        <!-- <?php foreach($saleArr as $skey => $val){?>   
                            <tr >
                                <?php if(array_key_first($saleArr)==$skey){?>
                                <th  rowspan="<?=count(array_values($saleArr))?>">业务员</th>
                                <?php }?>
                                <td colspan="5">
                                    <?php foreach ($val as $kk => $vv) {
                                            if(stripos($vv,'所有人')!==false) continue;
                                        ?> 
                                        <a class="a_blue" target="_blank" lay-href="<?=mvc::$cfg['SELF_URI']?>index/dayPlan?au_id=<?=$kk?>&plandate=<?=$Params['plandate']?>"><?=$vv?></a>&nbsp;&nbsp;
                                    <?php }?>
                                </td>
                            </tr>
                        <?php }?> -->
                        <tr>
                            <td colspan="6">
                                
                                <input type="text" name="plandate" class="layui-input w100" id="plandate" autocomplete="false"  value="<?=$Params['plandate']?$Params['plandate']:date('Y-m-d')?>">
                                <a lay-href="<?=mvc::$cfg['SELF_URI']?>customer/search" target="_blank" class="layui-btn">制定客户计划</button>
                                <a lay-href="<?=mvc::$cfg['SELF_URI']?>index/dayPlan" target="_blank" class="layui-btn" >查看日计划</a>
                                <a lay-href="<?=mvc::$cfg['SELF_URI']?>index/daySummary" target="_blank" class="layui-btn">写入日总结</a>
                                &nbsp;
                            </td>
                        </tr>
                    </tbody>
                </table>
            </div>
  
    
            <br />
            <br />
            <br />
            <div style="width: 1280px;">
                <div class="layui-inline">
                    <label class="layui-form-label">意向等级</label>
                    <div class="layui-input-block">
                        <select name="ccr_cla_id" id="">
                            <option value="">请选择</option>
                            <?php foreach ($rankArr as $key => $val) {?>
                                <option value="<?=$key?>" <?=$Params['ccr_cla_id']==$key?'selected':''?>><?=$val?></option>
                            <?php } ?>
                        </select>
                    </div>
                </div>
                <?php if($saleArr){?>
                <div class="layui-inline">
                    <label class="layui-form-label">业务员</label>
                    <div class="layui-input-block">
                        <select name="ccr_au_uid" id="" lay-filter="ccr_au_uid">
                            <option value="">请选择</option>
                            <?php foreach($saleArr as $skey => $val){?>
                                <optgroup label="<?=$skey?>">
                                    <?php foreach ($val as $kk => $vv) {?>
                                        <option value="<?=$kk?>" <?php if($Params['ccr_au_uid']==$kk){echo 'selected';}?>><?=$vv?></option>
                                    <?php } ?>
                                </optgroup>    
                            <?php }?>
                        </select>
                    </div>
                </div>
                <?php }?>
                <div class="layui-inline">
                    <label class="layui-form-label">按月筛选</label>
                    <div class="layui-input-block">
                        <input type="text" name="month" autocomplete="off" id="laydate1" value="<?=$Params['month']?>" class="layui-input w100">
                    </div>
                </div>
                <div class="layui-inline">
                    <label class="layui-form-label">意向项目</label>
                    <div class="layui-input-block" style="width: 100px;">
                        <select class="layui-input" name="sve_id" lay-filter="sve_id">
                            <option value="">--所有--</option>
                            <?php foreach ($sveArr as $sve_key => $sve_val): ?>
                                <option value="<?php echo $sve_key; ?>" <?php if ($Params['sve_id'] == $sve_key) :?>selected<?php endif ;?>><?php echo $sve_val; ?></option>
                            <?php endforeach; ?>
                        </select>
                    </div>
                </div>
                <div class="layui-inline">
                    <button class="layui-btn act-btn" type="submit">
                        <i class="layui-icon layui-icon-search layuiadmin-button-btn"></i>
                    </button>
                </div>
                
                <table class="layui-table">
                    <thead>
                        <tr>
                            <th width="80px">操作</th>
                            <?php if(!$Params['month']){?>
                            <th width="50px">序号</th>
                            <?php }?>
                            <th width="50px">意向等级</th>
                            <th width="50px">意向状态</th>
                            <th width="200px">客户名称</th>
                            <th width="200px">意向项目</th>
                            <th width="80px">添加时间</th>
                            <th width="50px">添加次数</th>
                           
                            <th width="60px">业务员</th>
                            <th>备注</th>
                            <th>是否成交</th>
                            <th>成交转化率</th>
                            <th width="150px">最后跟进</th>
                        </tr>
                    </thead>
                    <tbody>
                        <?php if(empty($listArr)){?>
                            <tr>
                                <td colspan="10" style="text-align: center;">暂无数据</td>
                            </tr>
                        <?php }else{?>
                            <?php foreach ($listArr as $key => $val) {?>
                                <tr>
                                    <td>
                                        <a href="javascript:;" class="a_blue" onclick="yixiang('<?=$val['ctr_id']?>','<?=$val['ccr_id']?>')">意向</a>
                                        &nbsp;&nbsp;<a lay-href="<?= mvc::$cfg['SELF_URI'] ?>customer/custFollow?ctrId=<?=$val['ctr_id']?>" title="<?=$val['ctr_comname']?:$val['ctr_uname']?>跟进记录" class="a_blue" >跟进</a>
                                    </td>
                                    <?php if(!$Params['month']){?>
                                    <td>
                                        <?=$val['sequence_number']?>
                                    </td>
                                    <?php }?>
                                    <td>
                                        <?php if($val['cla_name'] == 'A级'){?>
                                            <span class="layui-badge layui-bg-orange"><?=$val['cla_name']?></span>        
                                        <?php }?>
                                        <?php if($val['cla_name'] == 'B级'){?>
                                            <span class="layui-badge layui-bg-green"><?=$val['cla_name']?></span>        
                                        <?php }?>
                                        <?php if($val['cla_name'] == 'C级'){?>
                                            <span class="layui-badge layui-bg-cyan"><?=$val['cla_name']?></span>        
                                        <?php }?>
                                        <?php if($val['cla_name'] == 'D级'){?>
                                            <span class="layui-badge layui-bg-gray"><?=$val['cla_name']?></span>        
                                        <?php }?>
                                    </td>
                                    <td>
                                        <?php if($val['yxcheck'] == 1){?>
                                            <span class="layui-badge layui-bg-green">有效</span>
                                        <?php }elseif($val['yxcheck'] == -1){?>
                                            <span class="layui-badge layui-bg-red">无效</span>
                                        <?php }?>

                                    </td>
                                    <td> 
                                        <a class="a_blue" lay-href="<?=mvc::$cfg['SELF_URI']?>customer/detail?ctrId=<?=$val['ctr_id']?>"><?=$val['ctr_comname']?:$val['ctr_uname']?></a>  
                                    </td>
                                    <td>
                                        <?=$val['sve_name']?>
                                    </td>
                                    <td>
                                        <?=date('Y-m-d',$val['ccr_etime'])?>
                                    </td>
                                    <td>
                                        <?=$val['ccr_count']?>
                                    </td>
                                    
                                    <td>
                                        <?=$val['au_name']?>
                                    </td>
                                    <td>
                                        <?=$val['ccr_remark']?>
                                    </td>
                                    <td>
                                        <?php if($val['is_deal']==1){?>
                                            <span class="layui-badge layui-bg-green">是</span>
                                        <?php }?>
                                    </td>
                                    <td>
                                        <?=$val['deal_rate']?>
                                    </td>
                                    <td>
                                        <?=$val['lfollow']['cfo_au_name'].' '.($val['lfollow']['cfo_atime']?date('Y-m-d H:i:s',$val['lfollow']['cfo_atime']):'')?>
                                    </td>
                                            
                                </tr>
                            <?php }?>
                        <?php }?>
                    </tbody>
                </table> 
                <?=$pageMsg?>
            </div>
           
        </form>
    </div>
   

</div>
<script type="text/javascript" src="<?php echo mvc::$cfg['SELF_URL'];?>static/js/crm.js?ver=<?php echo mvc::$cfg['VER']['js'];?>"></script>
<?php include_once(mvc::$cfg['PATH_TPL'] . 'public/footBase.php');?>
<script>

layui.use(['form','laydate'],function(){
    var laydate = layui.laydate,
    form = layui.form;

    laydate.render({
        elem: '#plandate',
        type: 'date',
        done: function(value, date, endDate){
            $("#yjtable").submit();
        }
    });

    form.render();
    form.on('select(yj_au_uid)',function(data){
        $("#yjtable").submit();
    })

    laydate.render({
        elem: '#betime',
        type:"month",
        range: '~'
    });
    $('[data-betime]').click(function(){
        $('[name="betime"]').val($(this).data('betime'));
        $("#yjtable").submit();
    });

    form.on('select(fastYear)', function(data){
        $('[name="betime"]').val(data.value);
        $("#yjtable").submit();
    })

    laydate.render({
        elem: '#laydate1',
        type:"month"
    });
})
</script>