<?php include_once(mvc::$cfg['PATH_TPL'].'public/headBase.php');?>
<script type="text/javascript" src="<?php echo mvc::$cfg['SELF_URL'];?>static/js/crm.js?ver=<?php echo mvc::$cfg['VER']['js'];?>"></script>
<style>
    .customer-tel-row {
        display: flex;
        align-items: center;
        gap: 12px;
    }
    .customer-tel-row .customer-tel-input {
        flex: 0 0 140px;
        width: 120px;
        min-width: 120px;
        padding-left: 0;
        padding-right: 0;
        background: transparent;
    }
    .customer-tel-row .customer-weixin-workers {
        flex: 1;
        min-width: 0;
        line-height: 38px;
        white-space: normal;
        word-break: break-all;
    }
</style>

<div class="layui-form" style="padding: 10px;width:800px;">
    <?php include_once(mvc::$cfg['PATH_TPL'].'customer/detailHead.php');?>
    <table class="layui-table">
        <tr>
            <th class="textRight">活跃度:</th>
            <td>
                <span id="werwerwerwerwer-13214234"></span>
            </td>
            <th class="textRight">用户名:</th>
            <td>
                <input type="text" style="border:none;" autocomplete="off" class="layui-input" readonly="readonly" value="<?=$ctrArr['ctr_uname']?>">
            </td>
        </tr>
        <tr>
            <th class="textRight">状态:</th>
            <td>
                <?php if($ctrArr['ctr_level_id']==0){?>
                    <span style="line-height: 300%;" class="green">公海</span>
                <?php }elseif ($ctrArr['ctr_level_id']==5) {?>
                    <span style="line-height: 300%;" class="red">成交客户</span><?=$ctrArr['au_name']?'-'.$ctrArr['au_name']:''?>
                <?php }elseif ($ctrArr['ctr_level_id']==6){?>
                    <span style="line-height: 300%;" class="gray">过期客户</span>
                <?php }elseif ($ctrArr['ctr_level_id']==-1) {?>
                    <span class="red">已忽略</span>
                <?php }elseif ($ctrArr['ctr_level_id']==1) {?>
                    <span class="red">保护中</span>
                <?php }elseif ($ctrArr['ctr_level_id']==2) {?>
                    <span class="red">已分配</span>
                <?php } ?>
            </td>
            <th class="textRight">跑街令:</th>
            <td>
                <?php if($ctrArr['ctr_pjl_shop_id'] > 0 && $ctrArr['shop_vip_etime'] > time()){?>
                    <span style='margin-top:8px;' class='layui-btn layui-btn-xs'><?=date('Y-m-d H:i:s',$ctrArr['shop_enter_time'])?>入驻-使用中<?=date('Y-m-d H:i:s',$ctrArr['shop_vip_etime'])?>到期<span>
                <?php }elseif($ctrArr['ctr_pjl_shop_id'] > 0 && $ctrArr['shop_vip_etime'] <= time() && $ctrArr['shop_vip_etime'] > 0){?>
                
                    <span style='margin-top:8px;' class='layui-btn layui-btn-xs layui-btn-danger'><?=date('Y-m-d H:i:s',$ctrArr['shop_enter_time'])?>入驻-已过期-<?=date('Y-m-d H:i:s',$ctrArr['shop_vip_etime'])?>到期<span>
                <?php }elseif($ctrArr['ctr_pjl_shop_id'] > 0 && $ctrArr['shop_vip_etime'] == 0){?>
                    <span style='margin-top:8px;' class='layui-btn layui-btn-xs layui-btn-normal'><?=date('Y-m-d H:i:s',$ctrArr['shop_apply_etime'])?>申请-未缴费<span>
                <?php }else if($ctrArr['ctr_pjl_shop_id'] == 0 && $ctrArr['shop_vip_etime'] == 0){ ?>
                    <span style='margin-top:8px;' class='layui-btn layui-btn-disabled layui-btn-xs'>未申请<span>
                <?php }?>
            </td>
        </tr>
        <tr>
            <th class="textRight">公司:</th>
            <td>
                <input type="text" style="border:none;" autocomplete="off" class="layui-input" readonly="readonly" value="<?=$ctrArr['ctr_comname']?>">
            </td>
            <th class="textRight">联系人:</th>
            <td>
                <input type="text" style="border:none;" autocomplete="off" class="layui-input w100" readonly="readonly" value="<?=$ctrArr['ctr_contact']?>">
                <?php if($ctrArr['contactChange']){?>
                    <span><b>最后修改：<?=$ctrArr['contactChange']['name'].date('Y-m-d H:i:s',$ctrArr['contactChange']['ccl_etime'])?></b> &nbsp;&nbsp;<a lay-href="<?=mvc::$cfg['SELF_URI']?>customer/contactChangeLog?ctrId=<?=$ctrArr['ctr_id']?>" title="<?=$ctrArr['ctr_uname']?>联系人修改历史" class="a_blue">修改历史</a></span>
                <?php }?>
            </td>
        </tr>
        <tr>
            <th class="textRight">手机号:</th>
            <td>
                <div class="customer-tel-row">
                    <input type="text" style="border:none;" autocomplete="off" class="layui-input customer-tel-input" readonly="readonly" value="<?=$ctrArr['ctr_tel']?>">
                    <?php if($ctrArr['weixin_workers']){?>
                        <span class="customer-weixin-workers">已加微信:<span style="color: orange;"><?=implode(' ',$ctrArr['weixin_workers'])?></span></span>
                    <?php }?>
                </div>
            </td>
            <th class="textRight">类型:</th>
            <td>
                <?=$comStyleArr[$ctrArr['ctr_com_style']]?> 
            </td>
        </tr>
        <tr>
            <th class="textRight">合同服务:</th>
            <td colspan="3">
                <?php if(!empty($sveList)){?>
                <table class="layui-table">
                    <!-- 合同名称  服务项目  服务期  业务员 -->
                    <thead>
                        <th>合同名称</th>
                        <th>服务项目</th>
                        <th>服务期</th>
                        <th>金额</th>
                        <th>业务员</th>
                    </thead>
                    <tbody>
                        <?php foreach ($sveList as $key => $val) {?>
                            <?php foreach ($val['sveArr'] as $kk => $vval) {?>
                                <tr>
                                    <?php if($kk == 0){?>
                                        <td rowspan="<?=count($val['sveArr'])?>">
                                            <a class="a_blue" lay-href="<?=mvc::$cfg['SELF_URI']?>customer/applyPayAdd?conId=<?=$val['fct_id']?>"><?=$val['fct_title'];?></a>   
                                        </td>
                                    <?php }?>
                                    <td>
                                       <?=$vval['sve_text']?>
                                    </td>
                                    <td>
                                        <?=date('Y-m-d',$vval['fsl_btime']).'-'.date('Y-m-d',$vval['fsl_etime'])?>
                                        <?php if($vval['shoufei']==0){?>
                                            <?='（赠送）'?>
                                        <?php }elseif($vval['zs']==1){?>
                                            <?='（已续费）'?>
                                        <?php }else{?>
                                            <?=$vval['fsl_etime']<time()?'（已过期）':''?>
                                        <?php }?>
                                    </td>
                                    <td><?=$vval['fsl_money']?></td>
                                    <?php if($kk == 0){?>
                                        <td rowspan="<?=count($val['sveArr'])?>"><?=$salesArr[$val['duc_usr_id']]?></td>
                                    <?php }?>
                                </tr>
                            <?php }?>
                            
                        <?php }?>
                    </tbody>
                </table>
                <?php }?>
            </td>
        </tr>
        <tr>
            <th class="textRight">服务时间:</th>
            <td colspan="3">
                <?php if($ctrArr['min_btime'] && $ctrArr['max_etime']){?>
                    <?=$ctrArr['min_btime']?>至<?=$ctrArr['max_etime']?>
                <?php }?>
            </td>
        </tr>
        <tr>
            <th class="textRight">主营类别:</th>
            <td colspan="3">
                <input type="text" value="<?=$ctrArr['part']?implode(',',array_column($ctrArr['part'],'cla_name')):'' ?>" style="border:none;" autocomplete="off" class="layui-input" readonly="readonly">
            </td>
        </tr>
        <tr>
            <th class="textRight">关注零件:</th>
            <td colspan="3">
                <input type="text"  value="<?=implode(',',$ctrArr['act_part'])?>" style="border:none;" autocomplete="off" class="layui-input" readonly="readonly">
            </td>
        </tr>
        <tr>
            <th class="textRight">主营车型:</th>
            <td colspan="3">
                <input type="text"  value="<?=$ctrArr['make']?implode(',',array_column($ctrArr['make'],'cla_name')):''?>" style="border:none;" autocomplete="off" class="layui-input" readonly="readonly">
            </td>
        </tr>
        <tr>
            <th class="textRight">关注品牌:</th>
            <td colspan="3">
                <input type="text"  value="<?=implode(',',$ctrArr['act_make'])?>" style="border:none;" autocomplete="off" class="layui-input" readonly="readonly">
            </td>
        </tr>
        <tr>
            <th class="textRight">标签:</th>
            <td colspan="3">
                <input type="text"  value="<?=$ctrArr['self']?implode(',',array_column($ctrArr['self'],'cla_name')):''?>" style="border:none;" autocomplete="off" class="layui-input" readonly="readonly">
            </td>
        </tr>
        <tr>
            <th class="textRight">意向等级:</th>
            <td colspan="3">
                <input type="text"  value="<?=$ctrArr['rank_name']?>" style="border:none;" autocomplete="off" class="layui-input" readonly="readonly">
            </td>
        </tr>
        <tr>
            <th class="textRight">地区:</th>
            <td colspan="3">
                <input type="text"  value="<?=implode(' ',$ctrArr['pcts'])?>" style="border:none;" autocomplete="off" class="layui-input" readonly="readonly">
            </td>
        </tr>
        <tr>
            <th class="textRight">地址:</th>
            <td colspan="3">
                <input type="text"  value="<?=$ctrArr['ctr_addr']?>" style="border:none;" autocomplete="off" class="layui-input" readonly="readonly">
            </td>
        </tr>
        <tr>
            <th class="textRight">备注:</th>
            <td colspan="3">
                <input type="text"  value="<?=$ctrArr['ctr_remark']?>" style="border:none;" autocomplete="off" class="layui-input" readonly="readonly">
            </td>
        </tr>
    </table>
    <div style="text-align:center;padding:10px 0">
        <a href="javascript:void(0)" onclick="yixiang(<?=$ctrArr['ctr_id']?>)" title="标识" class="a_blue">标识意向客户</a>&nbsp;|&nbsp;
        <a href="javascript:void(0)" onclick="crmEditPage(<?=$ctrArr['ctr_id']?>)" title="编辑" class="a_blue">编辑客户信息</a>&nbsp;|&nbsp;
        <a lay-href="<?=mvc::$cfg['SELF_URI']?>customer/addContract?ctrId=<?=$ctrArr['ctr_id']?>" class="a_blue" title="我的客户, 马上去创建合同~">创建合同</a>&nbsp;|&nbsp;
        <a lay-href="<?=mvc::$cfg['SELF_URI']?>customer/contract?ctrId=<?=$ctrArr['ctr_id']?>" class="a_blue">合同列表</a>&nbsp;|&nbsp;
    </div>
</div>
<?php include_once(mvc::$cfg['PATH_TPL'].'public/footBase.php');?>
<script>
    layui.use(['rate','form'],function(){
        var rate = layui.rate;
        var form = layui.form;
        rate.render({
            elem: '#werwerwerwerwer-13214234'
            , length: 5
            , value: <?=$ctrArr['ctr_score']?>
            , theme: '#f30808'
            , half: true
            , text: false
            , readonly: true
        });
        form.render();
    });
    function refreshParentPage() {
        location.reload();
    }
</script>
