<!--{include file="<!--{$oapath}-->public/ins_page.tpl"}-->

<block name="content">
	<div class="page-header clearfix">
		<div class="dropdown col-sm-8">			
			<b class="dropdown-toggle" data-toggle="dropdown"><span class="title">客户</span></b>
		</div>
		<div class="col-sm-4 pull-right">
			<div class="search_box">
				<div class="input-group ">
					<input type="hidden" value="abc" >
					<input  class="form-control" type="text"  name="keyword" id="keyword" onkeydown="key_local_search();"/>
					<div class="input-group-btn">
						<a class="btn btn-sm btn-info" onclick="btn_local_search();"><i class="fa fa-search" ></i> </a>
					</div>
				</div>
			</div>
		</div>
	</div>

	<form id="form_data" name="form_data" method='post'>
		<div class="operate panel panel-default">
			<div class="panel-body">
				<div class="pull-left">
					
					

				</div>
				<div class="pull-right">
					<a class="btn btn-sm btn-primary" onclick="add();">新建</a>
                                        <a class="btn btn-sm btn-danger" onclick="del();" >删除</a>
				</div>
			</div>
		</div>
		<div class="ul_table border-top border-bottom">
			
                              <!--{if empty($list)}-->
				<ul>
					<li class="no-data">
						没找到数据
					</li>
				</ul>
                              <!--{else}-->
				<ul class="col-xs-12 border">
                                    <!--{foreach $list as  $key=>$vo}-->
					
						<li class="tbody">
                                                    
							<div class="row">
								<div class="data" style="display:none">
									<!--{$vo.letter}-->
								</div>
								<div class="tag" style="display:none">
									<!--{$vo.tag}-->
										
									
								</div>
								<div class="col-sm-6 col-xs-12">
									<label class="inline pull-left col-3">
										<input class="ace" type="checkbox" name="id[]" value="<!--{$vo.id}-->"/>
										<span class="lbl"></span></label>
									<nobr class="col-7 pull-left text-right">
										客户名称：
									</nobr>
									<a href="oa.php?c=Customer&a=add&id=<!--{$vo.id}-->" class="data wrap"> <!--{$vo.name}-->&nbsp;
									
                                                                            <!--{if $vo.dept!=''}-->
                                                                            / <!--{$vo.dept}-->&nbsp;
                                                                            <!--{/if}-->
                                                                             <!--{if $vo.position!=''}-->
                                                                            / <!--{$vo.position}-->&nbsp;
                                                                            <!--{/if}-->
									</a>
								</div>
								<div class="col-sm-6 col-xs-12" >
									<nobr class="col-10 pull-left text-right">
										联系人姓名：
									</nobr>
									<nobr class="data">
										<!--{$vo.contact}-->
									</nobr>
								</div>
							</div>
							<div class="row">
								<div  class="col-sm-6 col-xs-12" >
									<nobr class="col-10 pull-left text-right">
										邮箱：
									</nobr>
									<nobr class="data">
										<!--{$vo.email}-->
									</nobr>
								</div>
								<div  class="col-sm-6 col-xs-12">
									<nobr class="col-10 pull-left text-right">
										电话/手机：
									</nobr>
									<nobr class="data">
										<a href="tel:<!--{$vo.office_tel}-->"><!--{$vo.office_tel}--></a>
                                                                                  <!--{if $vo.mobile_tel!=''}-->
                                                                                 	/ <a href="tel:<!--{$vo.mobile_tel}-->"><!--{$vo.mobile_tel}--></a>
                                                                                    <!--{/if}-->
										
									</nobr>
								</div>
							</div>
						</li>
					 <!--{/foreach}-->
				</ul>
			<!--{/if}-->
		</div>
	</form>
</block>

					
				</div>
			</div>
		</div>
		<!--<iframe src="{:U('push/client')}" class="push" id="push"></iframe>-->
		<!-- Mainly scripts -->
		<script src="<!--{$oapath}-->Ins/js/jquery-2.1.1.js"></script>
		<script src="<!--{$oapath}-->Ins/js/bootstrap.min.js"></script>
		<script src="<!--{$oapath}-->Ins/js/plugins/metisMenu/jquery.metisMenu.js"></script>
		<script src="<!--{$oapath}-->Ins/js/plugins/slimscroll/jquery.slimscroll.min.js"></script>
		<!-- Custom and plugin javascript -->
		<script src="<!--{$oapath}-->Ins/js/inspinia.js"></script>
		<script src="<!--{$oapath}-->Ins/js/common.js"></script>
		<script src="<!--{$oapath}-->Ins/js/plugins/pace/pace.min.js"></script>
                
		<script src="<!--{$oapath}-->Ins/js/plugins/toastr/toastr.min.js"></script>
                <script src="<!--{$oapath}-->Ins/js/plugins/gritter/jquery.gritter.min.js"></script>
                <script src="<!--{$oapath}-->Ins/js/plugins/bootbox/bootbox.min.js"></script>
		<include file="Layout:ins_plugin_js"/>
<block name="js">
	<script type="text/javascript">
		function add() {
			window.open("oa.php?c=Customer&a=add", "_self");
			return false;
		}

		function del() {
			count = $("li.tbody :checked").length;
			if (count == 0) {
				ui_error("请选择要删除的数据");
				return false;
			}
			ui_confirm('确定要删除吗?', function() {
				var vars = $("#form_data").serialize();
				sendAjax("oa.php?c=Customer&a=del", vars, function(data) {
					if ($("#form_data .ul_table input:checked").length == 0) {
						$("li.tbody.active :checkbox").attr("checked", true);
					}

					$("#form_data input:checked").each(function() {
						$(this).parents("li").remove();
					});
				});
                                ui_alert("删除成功");
			});
		}

		function apply() {
			if ($("#form_data .ul_table input:checked").length == 0) {
				ui_error("请选择数据");
				return false;
			}			
			sendForm("form_data", "oa.php?c=Contact&a=set_tag", "oa.php?c=Contact");
		}

		function create_new_tag() {
			$(".cmd").hide();
			$(".new_tag").css("display", "block");
			$(".apply").show();
		}

		function key_local_search() {
			if (event.keyCode == 13) {
				$(".ul_table li").hide();
				val = $("#keyword").val().toUpperCase();
				if (val.length == 0) {
					$(".page-header .title").html("全部");
				} else {
					$(".page-header .title").html("搜索结果");
				}
				$(".ul_table li .data").each(function() {
					if ($(this).text().indexOf(val) >= 0) {
						$(this).parents("li").show();
					};
				});
			}
		}

		function btn_local_search() {
			$(".ul_table li").hide();
			val = $("#keyword").val().toUpperCase();
			if (val.length == 0) {
				$(".title nobr").html("全部");
			} else {
				$(".title nobr").html("搜索结果");
			}
			$(".ul_table li .data").each(function() {
				if ($(this).text().indexOf(val) >= 0) {
					$(this).parents("li").show();
				};
			});
			return false;
		}

		function export_contact() {
			window.open("{:U('export')}", "_blank");
			return false;
		}

		function import_contact() {
			window.open("{:U('import')}", "_self");
			return false;
		}

		function manage_tag() {
			window.open("oa.php?c=Contact&a=tag_manage", "_self");
			return false;
		}


		$(document).ready(function() {
			set_return_url();

			$(".page-header .dropdown-menu li").click(function() {
				$("#keyword").val("");
				$(".ul_table li").hide();
				gid = $(this).attr("gid");
                          
				$(".page-header .title").html($(this).text());
				$(".ul_table li div.tag").each(function() {
					if ($(this).text().indexOf(gid) >= 0) {
						$(this).parents("li").show();
					};
				});
			});

			$('.tag_list li').click(function(event) {
                           
				event.stopPropagation();
			});

			$("li.tbody").click(function() {
				$(".table input:checkbox").attr("checked", false);
				$(".tag_list input[name='tag[]']").attr("checked", false);
				str = trim($(this).find(".tag").text());

				strs = str.split(",");
				for ( i = 0; i < strs.length; i++) {
					$(".tag_list input[name='tag[]'][value='" + strs[i] + "']").prop("checked", true);
				}
			});

			$('.tag_list input').on('change', function(event) {
				if (($('.tag_list input:checked').length == 0) && ($(".tag_list input[name='new_tag']").val() == "")) {
					$(".cmd").show();
					$(".apply").hide();
				} else {
					$(".cmd").hide();
					$(".apply").show();
				}
			});
		});
	</script>
</block>
	</body>
</html>
