<?php include_once(mvc::$cfg['PATH_TPL'].'public/topSeller.php');?>
<div class="maintb">
    <?php include_once(mvc::$cfg['PATH_TPL'].'seller/leftMenu.php');?>
    <div id="memberList-main-middle" class="main_middle">
        <div class="navrow">

            <ul class="navrow_ul">
                <li>
                    <a href="memberRegister">已注册用户（公众号）</a>
                </li>
                <li class="active">
                    <a href="memberList">店铺会员</a>
                </li>
				<li>
                    <a href="member">会员等级</a>
                </li>
                <li>
                    <a href="memberColl">店铺收藏</a>
                </li>
            </ul>
        </div>
        <div style="margin-top: 18px;" id="searchTable">
          <form class="form-inline" action="/seller/memberList" method="get" id="searchForm">
            <table class="table">
              <tbody>
                <tr>
                  <td class="thr">用户名称：</td>
                  <td><input type="text" class="form-control" name="userName" placeholder="用户名或手机号" value="<?php echo $_GET['userName'];?>"></td>
                  <td class="thr">添加时间：</td>
                  <td>
                    <input type="text" id="start" onchange="reformatend(this)" style="width: 123px;" readonly="" placeholder="点击选择开始时间" class="form-control" name="starttime" value="<?php echo $_GET['starttime'];?>">
                    <strong>到</strong>
                    <input type="text" id="end"  style="width: 123px;"  readonly="" placeholder="点击选择结束时间" class="form-control" name="endtime" value="<?php echo $_GET['endtime'];?>">
                    <span class="add-on"><i class="icon-remove"></i></span>
                </td>
            </tr>
            <tr>
              <td class="thr">会员级别：</td>
              <td>
                <select class="form-control" name="level">
                  <option value="">全部</option>
                  <!-- <option <?php if($_GET['level']==='0'){echo 'selected';}?> value="0">无会员等级</option> -->
                  <?php foreach($level as $v){ ?>
                    <option <?php if($_GET['level'] == $v['mel_id']){echo 'selected';}?> value="<?php echo $v['mel_id'];?>">
                      <?php echo $v['mel_name'];?>
                    </option>
                  <?php } ?>
              </select>
			      </td>
            <td class="thr">
              备注:    
            </td>
            <td>
              <input type="text" class="form-control" name="meml_remark" placeholder="" value="<?php echo $_GET['meml_remark'];?>">
            </td>
			<td colspan="2">
				 <button type="button" class="btn btn-default w100 marr10" onclick="window.location.href='/seller/memberList'">清空</button>
				 <button type="button" class="btn btn-danger w100" onclick="return submit();">搜索</button>
			 </td>
		 </tr>
		 </tbody>
	    </table>
	</form>
</div>
<div style="margin-top:15px;" class="inner_container">
    <table style="border: 1px solid #ccc;" class="table table-striped">
        <thead>
            <tr>
                <th width="50px"><input type="checkbox" onclick="checkallcheckbox(this)" name="checkall"/></th>
                <th width="120px">用户名</th>
				<th width="150px">手机号</th>
                <th width="100px">店铺会员级别</th>
				<th>备注</th>
                <th width="150px">添加时间</th>
                <th width="100px">操作</th>
            </tr>
        </thead>
        <tbody>
            <?php if(!empty($data)){ ?>
            <?php foreach($data as $key=>$value){ ?>
            <tr class="MEMTR_<?php echo $value['meml_uid'];?> member_tr">
                <td><input type="checkbox" name="memluid[]" class="memluids" value="<?php echo $value['meml_uid'];?>" /></td>
                <td><?php echo $value['ub_username'];?></td>
                <td><?php echo $userArr[$value['meml_uid']]['u_mobile'];?></td>
                <td><?php if($value['mel_name']==""){echo "无";}else{echo $value['mel_name'];};?></td>
				<td class="remark"><?php echo $value['meml_remark'];?></td>
                <td><?php echo date('Y-m-d H:i:s',$value['meml_add_time']);?></td>
                <td>
                  <a class="a_blue" onclick="editThisShopMem(this, '<?php echo $value['ub_username'];?>',<?php echo $value['meml_uid'];?>,<?php echo $value['mel_id'];?>)" href="javascript:;">编辑</a>
                  &nbsp;|&nbsp;
                  <a href="javascript:;" class="a_blue" onclick="MESSAGE.confirm('确定删除这个店铺会员吗？','delThisMemUser(<?php echo $value['meml_uid'];?>)')">删除</a>
                </td>		          
            </tr>
            <?php } ?>
            <?php }else{ ?>
            <tr><td colspan="7" class="center orange">非常抱歉，未找到对应条件的店铺会员</td></tr>        
            <?php } ?>
        </tbody>
    </table>
	<div class="padtb5"></div>
	<div style="width: 250px;float: left;">
		<button class="btn btn-default" onclick="$('#myModaladd tbody').html('')" data-toggle="modal" data-target="#myModaladd" >添加店铺会员</button>
		<button class="btn btn-info" onclick="editThisShopMems()">修改级别</button>
		<button class="btn btn-danger" onclick="delThisMemUsers()">批量删除</button>
		<!-- MESSAGE.confirm('确定删除选中的会员吗？','delThisMemUsers()') -->
	</div>
	<?php echo $Page;?>
	</div>
	</div>
</div>
<?php include_once(mvc::$cfg['PATH_TPL'].'public/footAll.php');?>
<!-- 批量编辑店铺会员模态框 -->
<div class="modal fade" id="myModals" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
    <div  class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                <h4 class="modal-title" id="myModalLabel">批量编辑会员</h4>
            </div>
            <div class="modal-body">
              <table id="addnewUserName" class="table table-striped">
                      <thead>
                        <tr class="success">
                          <th>会员等级</th>
                      </tr>
                  </thead>
                  <tbody>
                    <tr>
                        <td>
                          <select id="editlevels" name="level" class="form-control">
                              <?php foreach($level as $v){ ?>
                                <option value="<?php echo $v['mel_id'];?>">
                                  <?php echo $v['mel_name'];?>
                                </option>
                              <?php } ?>
                            </select>
                          </td>
                      </tr>
                  </tbody>
              </table>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
                <button type="button" id="submitedits" class="btn btn-primary">提交</button>
            </div>
        </div>
    </div>
</div>
<!-- 编辑店铺会员模态框 -->
<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
    <div  class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                <h4 class="modal-title" id="myModalLabel">编辑会员</h4>
            </div>
            <div class="modal-body">
              <table id="addnewUserName" class="table table-striped">
                  <tbody>
                    <tr>
						<th width="100px">用户名</th>
                        <td id="updateMemUserName"></td>
                     </tr> 
					 <tr>
					 	 <th>会员等级</th>
						<td>
                          <select id="editlevel" name="level" class="form-control">
                              <?php foreach($level as $v){ ?>
                                <option value="<?php echo $v['mel_id'];?>">
                                  <?php echo $v['mel_name'];?>
                                </option>
                              <?php } ?>
                            </select>
                          </td>
                      </tr>
					  <tr>
						<th width="100px">备注</th>
                        <td>
							<input type="text" class="form-control" id="updateMemRemark" size="50">
                        </td>
                     </tr
                  </tbody>
              </table>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
                <button type="button" id="submitedit" class="btn btn-primary">提交</button>
            </div>
        </div>
    </div>
</div>


<!-- 新增会员的模态框 -->
<div class="modal fade" id="myModaladd" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
    <div  class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                <h4 class="modal-title" id="myModalLabel">添加店铺会员</h4>
            </div>
            <div class="modal-body">
              <input type="text" id="newUserName" class="form-control" name="" placeholder="输入用户名或手机号">
              <button class="btn btn-info" onclick="searchUser()">查询注册用户</button>
              <button style="display: none;" id="newUserName-notice" class='btn btn-danger'>用户不存在！</button>
              <table id="addnewUserName" class="table table-striped">
                <thead>
                  <tr class="success">
                    <th>用户名</th>
                    <th>会员等级</th>
                    <th>备注</th>
                    <th>操作</th>
                </tr>
            </thead>
            <tbody>
            </tbody>
        </table>
		<br>
    </div>
    <div class="modal-footer">
        <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
        <button type="button" onclick="submitnewUid()" class="btn btn-primary">提交</button>
    </div>
</div>
</div>
</div>
<script type="text/javascript">
  var level = <?php echo json_encode($level);?>;
  laydate.render({
    elem: '#start' //指定元素
     ,type: 'datetime'
  });
  laydate.render({
    elem: '#end' //指定元素
     ,type: 'datetime'
  }); 
</script>