
<!DOCTYPE html>
<html>
<head>
  <!-- <script src="https://code.jquery.com/jquery-3.1.1.min.js"></script> -->
  <script src="<?php echo base_url();?>assets/js/jquery-3.1.1.min.js"></script>
 <?php   include('include/common.php');?>  
  <link rel="stylesheet" type="text/css" href="<?php echo base_url();?>assets/css/jquery.dataTables.min.css">
  <script type="text/javascript" src="<?php echo base_url();?>assets/js/jquery.dataTables.min.js"></script>
  <link rel="stylesheet" type="text/css" href="<?php echo base_url();?>assets/css/bootstrap.css">
  <link rel="stylesheet" type="text/css" href="<?php echo base_url();?>assets/css/dataTables.bootstrap4.min.css">
  <link rel="stylesheet" type="text/css" href="<?php echo base_url();?>assets/css/responsive.dataTables.min.css">
  <script type="text/javascript" src="<?php echo base_url();?>assets/js/responsive.dataTables.min.js"></script>
  <link rel="stylesheet" type="text/css" href="<?php echo base_url();?>assets/css/responsive.bootstrap.css">
<link rel="stylesheet" type="text/css" href="<?php echo base_url();?>assets/css/responsive.bootstrap.min.css">
<!-- <link rel="stylesheet" type="text/css" href="//cdn.datatables.net/responsive/2.2.3/css/responsive.bootstrap4.css">
<link rel="stylesheet" type="text/css" href="//cdn.datatables.net/responsive/2.2.3/css/responsive.bootstrap4.min.css">
<link rel="stylesheet" type="text/css" href="//cdn.datatables.net/responsive/2.2.3/css/responsive.dataTables.css">
<link rel="stylesheet" type="text/css" href="//cdn.datatables.net/responsive/2.2.3/css/responsive.dataTables.min.css">
<link rel="stylesheet" type="text/css" href="//cdn.datatables.net/responsive/2.2.3/css/responsive.foundation.css">
<link rel="stylesheet" type="text/css" href="//cdn.datatables.net/responsive/2.2.3/css/responsive.foundation.min.css">
<link rel="stylesheet" type="text/css" href="//cdn.datatables.net/responsive/2.2.3/css/responsive.jqueryui.css">
<link rel="stylesheet" type="text/css" href="//cdn.datatables.net/responsive/2.2.3/css/responsive.jqueryui.min.css">
<link rel="stylesheet" type="text/css" href="//cdn.datatables.net/responsive/2.2.3/css/responsive.semanticui.css">
<link rel="stylesheet" type="text/css" href="//cdn.datatables.net/responsive/2.2.3/css/responsive.semanticui.min.css">
   -->


  <script type="text/javascript" src="<?php echo base_url();?>assets/js/dataTables.responsive.js"></script>
<!-- <script type="text/javascript" src="//cdn.datatables.net/responsive/2.2.3/js/dataTables.responsive.min.js"></script>
<script type="text/javascript" src="//cdn.datatables.net/responsive/2.2.3/js/responsive.bootstrap.js"></script>
<script type="text/javascript" src="//cdn.datatables.net/responsive/2.2.3/js/responsive.bootstrap.min.js"></script>
<script type="text/javascript" src="//cdn.datatables.net/responsive/2.2.3/js/responsive.bootstrap4.js"></script>
<script type="text/javascript" src="//cdn.datatables.net/responsive/2.2.3/js/responsive.bootstrap4.min.js"></script>
<script type="text/javascript" src="//cdn.datatables.net/responsive/2.2.3/js/responsive.dataTables.js"></script>
<script type="text/javascript" src="//cdn.datatables.net/responsive/2.2.3/js/responsive.dataTables.min.js"></script>
<script type="text/javascript" src="//cdn.datatables.net/responsive/2.2.3/js/responsive.foundation.js"></script>
<script type="text/javascript" src="//cdn.datatables.net/responsive/2.2.3/js/responsive.foundation.min.js"></script>
<script type="text/javascript" src="//cdn.datatables.net/responsive/2.2.3/js/responsive.jqueryui.js"></script>
<script type="text/javascript" src="//cdn.datatables.net/responsive/2.2.3/js/responsive.jqueryui.min.js"></script>
<script type="text/javascript" src="//cdn.datatables.net/responsive/2.2.3/js/responsive.semanticui.js"></script>
<script type="text/javascript" src="//cdn.datatables.net/responsive/2.2.3/js/responsive.semanticui.min.js"></script> -->

<link rel="stylesheet" type="text/css" href="<?php echo base_url();?>assets/css/buttons.dataTables.min.css">
<script type="text/javascript" src="<?php echo base_url();?>assets/js/buttons.dataTables.min.js"></script>
<script type="text/javascript" src="<?php echo base_url();?>assets/js/buttons.colVis.min.js"></script>
<link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.13.0/css/all.min.css" rel="stylesheet">

<script src="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.13.0/js/all.min.js"></script>

<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" integrity="sha384-wvfXpqpZZVQGK6TAh5PVlGOfQNHSoD2xbE+QkPxCAFlNEevoEH3Sl0sibVcOQVnN" crossorigin="anonymous">

  <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" crossorigin="anonymous">

  <link rel="stylesheet" href="https://pro.fontawesome.com/releases/v5.10.0/css/all.css" integrity="sha384-AYmEC3Yw5cVb3ZcuHtOA93w35dYTsvhLPVnYs9eStHfGJvOvKxVfELGroGkvsg+p" crossorigin="anonymous"/>
<link href="https://gitcdn.github.io/bootstrap-toggle/2.2.2/css/bootstrap-toggle.min.css" rel="stylesheet">
<script src="https://gitcdn.github.io/bootstrap-toggle/2.2.2/js/bootstrap-toggle.min.js"></script>

   <script language="JavaScript">
                function checkall(source) {
                   
                checkboxes = document.getElementsByName('admincheck');
                    for(var i=0, n=checkboxes.length;i<n;i++) {
                        checkboxes[i].checked = source.checked;
                    }
                }

                function checkToggle(source){
                    if(source.checked==true){
                    // alert("clicked123");
                    // alert("add");
                        action="add";
                        // check status to 1
                    }
                    else{
                      // alert("remove");  
                    // alert(source.data('clickid'));
                      action="remove";
                      // check status to 0
                    }
                    // alert( $(source).attr('data-clickid'));
                    // alert( $(source).val());
                    var personid=$(source).attr('data-clickid');
                    var postData ={
                    'action':action,
                    'personid':personid
                    // 'currentlevel':currentlevel,
                    // 'level1id':split1[1],
                    // 'level2id':split1[2],
                    // 'level3id':split1[3],
                    // 'level4id':split1[4]
                    }
                     var GlobalVariables ={
                      'csrfToken': '123',
                      'baseUrl':'<?php echo base_url();?>',
                      'destUrl':'<?php echo base_url();?>/api/v1/brcustomerend/status',
                      'AJAX_SUCCESS' :'SUCCESS',
                      'AJAX_FAILURE' :'FAILURE'
                     };
                     var postUrl= GlobalVariables.baseUrl +'/api/v1/brcustomerend/status';

                     $.ajax({
                      method: "POST",
                      url: postUrl,
                      dataType: "json",
                     data: postData,
                     success : function(data){

                    // alert("posted");
                    // alert('formsubmit');
                    // alert(data);
                    
                    // alert(data['recordstatus']);
                    // alert(data['msg']);
                    if(data['recordstatus']=="SUCCESS"){
                        $('#feedback').remove();
                        $( '#editmsg' ).append('<p class="text-primary" id="feedback">'+data['msg']+'</p>');
                        // setTimeout(function() {
                        //     location.reload();
                        // }, 3000);
                        // location.reload();

                    }
                      if(data['recordstatus']=="FAILURE"){
                        $('#feedback').remove();
                        $( '#editmsg' ).append('<p class="text-danger"  id="feedback">'+data['msg']+'</p>');
                    //   $( '#modal-bodymsg' ).empty();
                    //   $( '#modal-bodymsg' ).append( '<h5 class="text-center" style="color: #a03d49;">客戶不能增加。</h5> <h5 class="text-center" style="color: #a03d49;">請稍後再嘗試。</h5>' );
                    //   $('#finishModal').modal('show');
                    // }
                      // if (data.AJAX_SUCCESS==GlobalVariables.AJAX_SUCCESS){
                      //     window.location.href=GlobalVariables.destUrl;
                      // } else {
                      //     $('.alert').text("登入錯誤");
                      //    $('.alert').removeClass('hidden');
                      }
                  }
                }); 
                   //end ajax module
                }
                </script>
</head>

<body>

    <!-- admin javascript -->
    
    


    <?php   include('include/header.php');?>
    <div class="wrapper" >
        
        <?php   include('include/sidebar.php');?>
        <!-- Page Content  -->
        <div id="content" style="background-color: #ffffff;">
            <?php 

               //for manager can see other shop but cannot edit
                        $extraPasscheck=false;
                        if($this->session->userdata('shopid')==$currentshop){
                          $extraPasscheck=true;
                        }
                        if($this->session->userdata('shopid')!=$currentshop && ($this->session->userdata('roleId')==6 || $this->session->userdata('roleId')==7 )){
                          $extraPasscheck=true;
                        }
                //end for manager can see other shop but cannot edit


            ?>

            <div class="title">客戶管理</div>
            <!-- add button -->
            <?php
              if($this->session->userdata('brcustomer_add')==true && $extraPasscheck==true){
            ?>
            <div style="" class="menubar2 p-2">
              <a href="/at-cms/brcustomeradmin/add"><i class="fas fa-plus" style=" display: inline-block;
              /*border-radius: 10px;*/
              /*box-shadow: 0px 0px 2px #888;*/
              color: #957c78;
              padding: 2px 2px;"></i>
            新增</a>
            </div>
            <?php
              }//if($this->session->userdata('brcustomer_add')==true){

            ?>
            <!-- end add button -->
             <form action="/at-cms/brcustomeradmin/level" method="post" >
            <div class="form-group row">
                <div class="col-sm-10">
              <label for="inputPassword" class=" col-form-label d-inline">客戶分級</label>
            
                 <select class="select mas-select select2-offscreen d-inline form-control ml-2" name="level" id="level" tabindex="-1" style="width: auto;" 
                 
                 onchange="this.form.submit()" 
                 >
                  <!-- <option value="">--- 請選擇薪酬種類 ---</option> -->
                  <option value=""></option>
                <?php
                  foreach ($memberlevel_list as $memberlevelrow) {
                ?>
                
                <option value="<?php echo $memberlevelrow->id;?>" <?php 

                  if($this->session->userdata('searchlevel')== $memberlevelrow->id){
                    echo "selected";
                  }
                  // if(!empty($customerdetails->first_registered_tenant_no)){
                  //   if($customerdetails->first_registered_tenant_no==$shoprow->id){
                  //     echo "selected";
                  //   }
                  // }
                  
                ?><?php
                // if($pagemethod=="edit"){ 

                //   if($customerdetails->level==$memberlevelrow->id)
                //   echo "selected";
                // } 

              ?>

               ><?php echo $memberlevelrow->name;?></option>
                 <?php
                    }
                  ?>

                </select>
                  <div class="valid-feedback">正確</div>
                  <div class="invalid-feedback">没有资料</div>
              </div>
            </div>
            
             </form>

             <form action="/at-cms/brcustomeradmin/channel" method="post" >
            <div class="form-group row">
              <div class="col-sm-12">
              <label for="inputPassword" class="col-form-label d-inline">會員來源</label>
              
                 <select class="select mas-select select2-offscreen d-inline ml-2 form-control" name="channelSelectID" id="channelSelectID" tabindex="-1"
                 style="width: auto;" 
                 onchange="this.form.submit()" 
                 >
                  <!-- <option value="">--- 請選擇薪酬種類 ---</option> -->
                  <option value=""></option>
                <?php
                  foreach ($channel_list as $channel_listrow) {
                ?>
                
                <option value="<?php echo $channel_listrow->id;?>" <?php 

                  if($this->session->userdata('channelSelectID')== $channel_listrow->id){
                    echo "selected";
                  }
                  // if(!empty($customerdetails->first_registered_tenant_no)){
                  //   if($customerdetails->first_registered_tenant_no==$shoprow->id){
                  //     echo "selected";
                  //   }
                  // }
                  
                ?><?php
                // if($pagemethod=="edit"){ 

                //   if($customerdetails->level==$memberlevelrow->id)
                //   echo "selected";
                // } 

              ?>

               ><?php echo $channel_listrow->name;?></option>
                 <?php
                    }
                  ?>

                </select>
                  <div class="valid-feedback">正確</div>
                  <div class="invalid-feedback">没有资料</div>
              </div>
            </div>
            
             </form>
             
             <form action="/at-cms/brcustomeradmin/tempmem" method="post" >
            <div class="form-group row">
              <div  class="col-sm-12">
              <label for="inputPassword" class=" col-form-label d-inline">會員類別</label>
              
                 <select class="select mas-select select2-offscreen  d-inline ml-2 form-control" name="isTemp" id="isTemp" tabindex="-1"
                 style="width: auto;" 
                 onchange="this.form.submit()" 
                 >
                  <!-- <option value="">--- 請選擇薪酬種類 ---</option> -->
                  <option value="" ></option>
                  <option value="3" <?php if($this->session->userdata('searchmem')=="3"){echo "selected";}?>>所有會員</option>
                  <option value="1" <?php if($this->session->userdata('searchmem')=="1"){echo "selected";}?>>臨時會員</option>
                  <option value="2" <?php if($this->session->userdata('searchmem')=="2"){echo "selected";}?>>非臨時會員</option>

                </select>
                  <div class="valid-feedback">正確</div>
                  <div class="invalid-feedback">没有资料</div>
              </div>
            </div>
            
             </form>

            <style type="text/css">
              /*
                table#book-table.dataTable tbody tr:hover {
                    background-color: #fbeae6;
                  }
                table#book-table.dataTable tbody tr {
                    background-color: #fbeae6;
                  }
    957c78  
    b6a5a2          */
                  table#book-table.dataTable tbody tr:hover{
                    background-color: <?php echo DATATABLE_HOVER;?>;
                  }
                  table#book-table.dataTable tbody tr.odd {
                    background-color: <?php echo DATATABLE_ODD;?>;
                  }
                  table#book-table.dataTable tbody tr.odd:hover {
                    background-color: <?php echo DATATABLE_HOVER;?>;
                  }
   
/*  table#book-table.dataTable tbody tr:hover > .sorting_1 {
    background-color: <?php echo DATATABLE_ODD;?>;
  }*/
             table#book-table.dataTable tbody tr:hover > .sorting_1 {
    background-color: <?php echo DATATABLE_HOVER;?>;
  }      


  table#book-table.dataTable tbody tr.odd > .sorting_1 {
    background-color: <?php echo DATATABLE_ODD;?>;
  }      
   table#book-table.dataTable tbody tr.even > .sorting_1 {
    background-color: <?php echo DATATABLE_EVEN;?>;
  }   

  table#book-table.dataTable tbody tr.even:hover > .sorting_1 {
    background-color: <?php echo DATATABLE_HOVER;?>;
  }    

  table#book-table.dataTable tbody tr.odd:hover > .sorting_1 {
    background-color: <?php echo DATATABLE_HOVER;?>;
  }       

table.dataTable thead th {
    position: relative;
    background-image: none !important;
}

  a, a:hover, a:focus{
    text-decoration: none!important;
    color: #000000;
  }

  
table.dataTable thead th.sorting:after,
table.dataTable thead th.sorting_asc:after,
table.dataTable thead th.sorting_desc:after {
    position: absolute !important;
    top: 12px !important;
    right: 8px !important;
    display: block !important;
    font-family: FontAwesome !important;
}
table.dataTable thead th.sorting:after {
    content: "\f0dc" !important;
    color: #ddd !important;
    font-size: 0.8em !important;
    padding-top: 0.12em !important;
}
table.dataTable thead th.sorting_asc:after {
    content: "\f0de" !important;
    color: #e97358 !important;
}
table.dataTable thead th.sorting_desc:after {
    content: "\f0dd" !important;
    color: #e97358 !important;
}    
table.dataTable.dtr-inline.collapsed>tbody>tr[role="row"]>td:first-child:before, table.dataTable.dtr-inline.collapsed>tbody>tr[role="row"]>th:first-child:before {
  background-color: #4dac47;

}
/*  table#book-table.dataTable.order-column.stripe tbody tr.odd>.sorting_1{
    background-color: #fbeae6;
  }      


table.dataTable td.sorting_1{ background-color: white; border:1px lightgrey; }
    table.dataTable td{ background-color: white;  border:1px lightgrey;}
    table.dataTable tr.odd { background-color: white;  border:1px lightgrey;}
    table.dataTable tr.even{ background-color: white; border:1px lightgrey; }*/
            </style>
            
            <!-- end test datatable -->

            <!-- new table -->
          <table id='book-table' class="display responsive wrap table table-bordered table-striped table-hover  " style="width:100%">

        <thead>
            <tr><td style="border-bottom: 1px solid #dbd0ce;" ><span class="tabletextcolor">客戶編號</span></td><!-- <td>中文姓名</td><td>英文名</td><td>英文姓</td> -->
              <td style="border-bottom: 1px solid #dbd0ce;"><span class="tabletextcolor">名稱</span></td>
              <td style="border-bottom: 1px solid #dbd0ce;"><span class="tabletextcolor">性別</span></td><td style="border-bottom: 1px solid #dbd0ce;"><span class="tabletextcolor">出生日期</span></td><td style="border-bottom: 1px solid #dbd0ce;"><span class="tabletextcolor">手機號碼</span></td><td style="border-bottom: 1px solid #dbd0ce;"><span class="tabletextcolor">詳情</span></td><td style="border-bottom: 1px solid #dbd0ce;"><span class="tabletextcolor">編輯</span></td><td style="border-bottom: 1px solid #dbd0ce;"><span class="tabletextcolor">啟用</span></td></tr>

            </thead>

     </table>

     <!-- Script -->
     <script type="text/javascript">
     $(document).ready(function(){
        $('#book-table').DataTable({
          "order": [[ 0, "desc" ]],
         dom: 'Bfrtip',
        buttons: [
            // 'colvis'
        ],
          'processing': true,
          'serverSide': true,
          'serverMethod': 'post',
          'ajax': {
            <?php if($this->session->userdata('userid')== '22' && $this->session->userdata('username')=='sarah'){
            ?>
             'url':'<?=base_url()?>at-cms/brcustomeradmin/custdatalistwithSecondShop'
             <?php
              }
              
             ?>
            <?php if($this->session->userdata('userid')!= '22' && $this->session->userdata('username')!='sarah'){
            ?>
             'url':'<?=base_url()?>at-cms/brcustomeradmin/custdatalist'
             <?php
              }
              
             ?>
          },
          'columns': [
             { data: 'code' },
             { data: 'display_name' },
             { data: 'gender' },
             { data: 'dob' },
             { data: 'mobile' },
             { data: 'details' },
             { data: 'edit' },
             { data: 'open' },
          ],
          "columnDefs": [ {
          "targets": [5,6,7],
          "orderable": false
          } ]
        });
     });
     </script>

          <!-- end new table -->

        </div>
    </div>


    <script type="text/javascript">
        $(document).ready(function () {
            $('#sidebarCollapse').on('click', function () {
                $('#sidebar').toggleClass('active');
            });

            // password click
            bootstrapRevealPassword();

// Plugin to integrate in your javascript file
            function bootstrapRevealPassword() {
            $('[data-password]').closest('.form-group').addClass('position-relative').append('<span class="form-password-icon"><i class="material-icons">visibility_off</i></span>');

            $('.form-password-icon').on('click', function() {
                var clicks = $(this).data('clicks');
                if (clicks) {
                // odd clicks
                $(this).html('<span class="input-group-text "><i class="fas fa-eye-slash"></i></span>').prevAll(':input').attr('type', 'password');
                } else {
                // even clicks
                $(this).html('<span class="input-group-text "><i class="fas fa-eye"></i></span>').prevAll(':input').attr('type', 'text');
                }
                $(this).data("clicks", !clicks);
            });
            }

            // end password click

        });
    </script>
</body>

</html>