<?php
require_once 'conn.php';
checkLogin();
?>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>管理区域</title>
    <link rel="stylesheet" href="css/common.css" type="text/css" />
    <script src="js/jquery-1.7.2.min.js"></script>
    <script src="js/js.js"></script>
    <script src="js/xheditor-1.1.9/xheditor-1.1.9-zh-cn.min.js"></script>
    <script src="js/Hz2Py-szm-min.js"></script>
    <script src="js/ySearchSelect.js"></script>
    <script>
    $(document).ready(function(){
        $('.txt2').xheditor({
            tools:'full',
            hoverExecDelay:-1,
            urlBase:'system',
            upLinkUrl:"upload.php",
            upLinkExt:"zip,rar,txt,pdf",
            upImgUrl:"upload.php",
            upImgExt:"jpg,jpeg,gif,png",
            upFlashUrl:"upload.php",
            upFlashExt:"swf",
            upMediaUrl:"upload.php",
            upMediaExt:"wmv,avi,wma,mp3,mid"
        });
    });
    </script>
    <style>
        body {
            margin: 0;
            padding: 20px;
            background: #fff;
        }
        #man_zone {
            margin-left: 0;
        }
    </style>
</head>
<body class="clear">
<?php // require_once 'panel.php'; ?>
<div id="man_zone">
    <form name="form1" id="form1" method="post" action="customerSave.php<?= $hrefstr ?? '' ?>" onSubmit="return checkInput();">
        <table width="100%" border="0" cellpadding="3" cellspacing="1" class="table1">
            <tbody>
                <tr>
                    <th width="8%">客户编号</th>
                    <td>
                        <input type="text" id="cs_code" name="cs_code" value="" class="txt1" />
                        <input type="hidden" name="cs_addtime" value="<?= date('Y-m-d H:i:s') ?>" />
                    </td>
                </tr>
                <tr>
                    <th width="8%">公司名称</th>
                    <td><input type="text" id="cs_company" name="cs_company" value="" class="txt1" /></td>
                </tr>
                <tr>
                    <th width="8%">联系人</th>
                    <td><input type="text" id="cs_name" name="cs_name" value="" class="txt1" /></td>
                </tr>
                <tr>
                    <th width="8%">地区</th>
                    <td>
                        <div class="layui-input-inline">
                            <div class="layui-form-select ySearchSelect y1">
                                <div class="layui-input">请选择客户区域</div>
                                <input name="cs_country" id="cs_country" type="hidden">
                                <i class="layui-edge"></i>
                                <ul>
                                    <?php
                                    $result = $conn->query("SELECT id, countryCode, countryName FROM country");
                                    while ($row = $result->fetch_assoc()) {
                                        echo "<li class=\"on\" data-c=\"{$row['id']}\">(+{$row['countryCode']}){$row['countryName']}</li>";
                                    }
                                    ?>
                                    <p>无匹配项</p>
                                </ul>
                            </div>
                        </div>
                        <script>
                            $(function () {
                                $(".y1").ySearchSelect();  
                            })
                        </script>
                    </td>
                </tr>
                <tr>
                    <th width="8%">来源</th>
                    <td>
                        <select id="cs_from" name="cs_from">
                            <option value="0">请选择来源</option>
                            <?php
                            $result = $conn->query("SELECT id, ch_name FROM qudao");
                            while ($row = $result->fetch_assoc()) {
                                echo "<option value=\"{$row['id']}\">{$row['ch_name']}</option>";
                            }
                            ?>
                        </select>
                    </td>
                </tr>
                <tr>
                    <th rowspan="7">联系方式</th>
                    <td><input type="text" id="cs_tel" name="cs_tel" value="" class="txt1 tel" placeholder="电话格式:区号+号码 如:+86 15012345678" /></td>
                </tr>
                <tr>
                    <td><input type="text" id="cs_wechat" name="cs_wechat" value="" class="txt1 wechat" placeholder="微信"/></td>
                </tr>
                <tr>
                    <td>
                        <input type="text" id="cs_whatsapp" name="cs_whatsapp" value="" class="txt-short2 whatsapp" placeholder="Whatsapp 格式:区号+号码 如:+86 15012345678"/>
                        <span class="syncphone">同步到电话联方式</span>
                    </td>
                </tr>
                <tr>
                    <td><input type="text" id="cs_email" name="cs_email" value="" class="txt1 mail" placeholder="邮件" /></td>
                </tr>
                <tr>
                    <td><input type="text" id="cs_linkedin" name="cs_linkedin" value="" class="txt1 linkedin" placeholder="领英链接"/></td>
                </tr>
                <tr>
                    <td><input type="text" id="cs_facebook" name="cs_facebook" value="" class="txt1 facebook" placeholder="Facebook" /></td>
                </tr>
                <tr>
                    <td><input type="text" id="cs_alibaba" name="cs_alibaba" value="" class="txt1 alibaba" placeholder="阿里巴巴会员名" /></td>
                </tr>
                <tr>
                    <th>地址</th>
                    <td><input type="text" id="cs_address" name="cs_address" value="" class="txt1" /></td>
                </tr>
                <tr>
                    <th>业务类型</th>
                    <td>
                        <?php
                        $result = $conn->query("SELECT id, businessType FROM clienttype");
                        while ($row = $result->fetch_assoc()) {
                            echo "<input type=\"radio\" name=\"cs_type\" value=\"{$row['id']}\" id=\"fortype{$row['id']}\">
                                  <label for=\"fortype{$row['id']}\">{$row['businessType']}</label>";
                        }
                        ?>
                    </td>
                </tr>
                <tr>
                    <th>跟进阶段</th>
                    <td>
                        <input type="radio" id="fordeal1" class="cs_deal" name="cs_deal" value="0"><label for="fordeal1">无响应</label>
                        <input type="radio" id="fordeal2" class="cs_deal" name="cs_deal" value="1" checked="checked"><label for="fordeal2">背景调查</label>
                        <input type="radio" id="fordeal3" class="cs_deal" name="cs_deal" value="2"><label for="fordeal3">明确需求</label>
                        <input type="radio" id="fordeal4" class="cs_deal" name="cs_deal" value="3"><label for="fordeal4">已成交</label>
                    </td>
                </tr>
                <tr>
                    <th>其他</th>
                    <td>
                        <input type="checkbox" id="belongClient" class="cs_belongClient" name="cs_belongClient" value="1">
                        <label for="belongClient">客户的客户</label>
                    </td>
                </tr>
                <tr>
                    <th>自定义标签</th>
                    <td>
                        <div class="taglist"></div>
                        <input type="hidden" id="mytag" name="mytag" value="">
                        <div class="commontag clear">
                            <i class="tag">美特柏品牌客户</i>,
                            <i class="tag">OEM定制客户</i>,
                            <i class="tag">小型B端客户</i>,
                            <i class="tag">C端客户</i>,
                            <i class="tag">贸易公司</i>,
                            <i class="tag">档口客户</i>
                            <?php
                            $stmt = $conn->prepare("SELECT DISTINCT tagName FROM tagtable WHERE employeeId = ?");
                            $stmt->bind_param("i", $_SESSION['employee_id']);
                            $stmt->execute();
                            $result = $stmt->get_result();
                            
                            while ($row = $result->fetch_assoc()) {
                                echo "<i class=\"tag\">" . htmlspecialcharsFix(textUncode($row['tagName'])) . "</i>,";
                            }
                            ?>
                        </div>
                        <input type="text" id="tapinput" class="txt-short" placeholder="添加新标签,按Enter添加">
                    </td>
                </tr>
                <tr>
                    <th width="8%">备注</th>
                    <td><textarea name="cs_note" class="txt2" placeholder=""></textarea></td>
                </tr>
                <tr>
                    <th></th>
                    <td>
                        <input type="button" name="save" id="save" value="确定" class="btn1" onclick="subform();" />
                        <input type="button" value="返回" class="btn1" onClick="location.href='customers.php'" />
                    </td>
                </tr>
            </tbody>
        </table>
    </form>
</div>
</body>
</html>