
<!DOCTYPE html>
<html>
  <?php 
    
    date_default_timezone_set('Asia/Hong_Kong');

   ?>
<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;
                    }
                }

                     //show delete modal
                    function showdeletemodal() {
                        checkboxes = document.getElementsByName('admincheck');
                        var favorite = [];
                        $count=0;
                        $.each($("input[name='admincheck']:checked"), function(){
                            favorite.push($(this).val());
                            $count=$count+1;
                        });
                        // alert(1);
                        // alert("My favourite sports are: " + favorite.join(", "));
                        document.getElementById("deletenum").innerHTML = $count;
                        $('#deleteModalCenter').modal({
                                            show: true,
                                        }); 
                    }//function showdeletemodal() {
                    //end show delete modal  

                     $( document ).ready(function() {
    
            //delete submit button
        $("#btndeleteSubmit").click(function(event) {
            // alert("1");
          var forcusitem="";
          var passCheck=true;
            //check delete have value
            // var checkboxvalue = $('.checkbox').val();   

            var checkboxvalue =  [];    
            // $("input.checkbox[type=checkbox]:checked").each(function(i){
            //     alert(i.value );
            // checkboxvalue.push( i.value );
            // }); 

            $('input.checkbox:checkbox:checked').each(function () {

                // alert($(this).val());
                checkboxvalue.push( $(this).val() );

            });
            var postData ={
                'inputdeletecheckboxvalue':checkboxvalue
            }
            var GlobalVariables ={
                  'csrfToken': '123',
                  'baseUrl':'<?php echo base_url();?>',
                  'destUrl':'<?php echo base_url();?>/api/v1/brshopend/delete',
                  'AJAX_SUCCESS' :'SUCCESS',
                  'AJAX_FAILURE' :'FAILURE'
            };

            event.preventDefault();
            var postUrl= GlobalVariables.baseUrl +'/api/v1/brshopend/delete';
            //end　check delete have value
            // $('#loading').show();
            $.ajax({
                  method: "POST",
                  url: postUrl,
                  dataType: "json",
                 data: postData,
                 success : function(data){
                  // $('#loading').hide();
                // alert("posted");
                // alert('formsubmit');
                // alert(data);
                
                // alert(data['recordstatus']);
                // alert(data['msg']);
                if(data['recordstatus']=="SUCCESS"){

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

                }
                  if(data['recordstatus']=="FAILURE"){
                    $('#feedback').remove();
                    $( '#deletemsg' ).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');
                  }
              }
            });  

        });  //$("#btndeleteSubmit").click(function(event) {      
        //end delete submit button  
        });//$( document ).ready(function() {


                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/customerend/status',
                      'AJAX_SUCCESS' :'SUCCESS',
                      'AJAX_FAILURE' :'FAILURE'
                     };
                     var postUrl= GlobalVariables.baseUrl +'/api/v1/customerend/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');?>

        <!-- delete modal -->
            <script>
                
            </script>

            <div class="modal fade" id="deleteModalCenter" tabindex="-1" role="dialog" aria-labelledby="deleteModalCenterTitle" aria-hidden="true">
            <div class="modal-dialog modal-dialog-centered  " role="document" style="max-width: 600px;">
                <div class="modal-content px-3">
                <!-- <div class="modal-header">
                    <h5 class="modal-title" id="exampleModalLongTitle">Modal title</h5>
                    <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                    <span aria-hidden="true">&times;</span>
                    </button>
                </div> -->
                <div class="modal-body ">
                     <h5 style="color:<?php echo MAIN_TEXT_COLOR;?>" class="text-center py-2"><i class="fas fa-plus mr-2" style="color:<?php echo MAIN_TEXT_COLOR;?>"></i>删除門店</h5>
                     <form>

                   
                    <div class="form-group row">
                        <label for="inputRePassword" class="col-sm-12 "><span style="color:<?php echo MAIN_TEXT_COLOR;?>;" >確定删除</span><span id="deletenum" style="color:<?php echo MAIN_TEXT_COLOR;?>;"></span><span style="color:<?php echo MAIN_TEXT_COLOR;?>;" >個門店?</span></label>
                        
                        <span id="deletemsg" class="text-center"></span>
                    </div>
                    <!-- <div class="form-group row">
                        <div class="col-sm-12">
                        <p style="font-size: 12px;"><span style="color:#616161">*為必填項目<br>登入名稱為英文字或數字組成(不分大小寫)</span></p>
                        <span id="editmsg" class="text-center"></span>
                         </div>
                    </div> -->
                    <div class="form-group row">
                        <div class="col-sm-12 text-center">
                        <button type="button" class="btn  px-5  custombutton" id="btndeleteSubmit">確定</button>
                        </div>
                    </div>
                    <input type="hidden" class="form-control" id="inputadminid" placeholder="">
                    </form>
                </div>
                <!-- <div class="modal-footer">
                    <button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
                    <button type="button" class="btn btn-primary">Save changes</button>
                </div> -->
                </div>
            </div>
            </div>
            <script type="text/javascript">
             


            </script>
            <!-- end delete modal --> 

        <!-- Page Content  -->
        <div id="content" style="background-color: #ffffff;">
            <div class="title">門店管理</div>
            <!-- add button -->

            <div style="" class="menubar2 p-2">
            <a href="/at-cms/brshopadmin/add"><i class="fas fa-plus" style=" display: inline-block;
              /*border-radius: 10px;*/
              /*box-shadow: 0px 0px 2px #888;*/
              color: <?php echo MAIN_TEXT_COLOR;?>;
              padding: 2px 2px;"></i>新增</a>
            </div>
            <!-- end add button -->
             <style type="text/css">
              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 {
    position: relative;
    background-image: none !important;
}
  
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>      
            <!-- test datatable -->
            <table id="book-table" class="display responsive wrap table table-bordered table-striped table-hover  " style="width:100%">
         
            <!-- <table id="book-table" class="display responsive nowrap"  width="100%"> -->
            <thead>
            <tr><td style="border-bottom: 1px solid <?php echo MAIN_TEXT_COLOR;?>;" ></td><td style="border-bottom: 1px solid <?php echo MAIN_TEXT_COLOR;?>;" ><span class="tabletextcolor">門店簡稱</span></td><td style="border-bottom: 1px solid <?php echo MAIN_TEXT_COLOR;?>;" ><span class="tabletextcolor">門店長寫</span></td><td style="border-bottom: 1px solid <?php echo MAIN_TEXT_COLOR;?>;" ><span class="tabletextcolor">門店中文名</span></td><td style="border-bottom: 1px solid <?php echo MAIN_TEXT_COLOR;?>;" ><span class="tabletextcolor">詳情</span></td><td style="border-bottom: 1px solid <?php echo MAIN_TEXT_COLOR;?>;" ><span class="tabletextcolor">編輯</span></td><td style="border-bottom: 1px solid <?php echo MAIN_TEXT_COLOR;?>;" ><span class="tabletextcolor">删除</span> <input type="checkbox" class="" id="admincheck" name="admincheck" value="" onclick="checkall(this)"></td></tr>

            </thead>
            <tbody>
            <?php  foreach ($shop_list as $shop_row) {
            ?>
                    <tr><td><?php echo $shop_row->id;?></td><td><?php echo $shop_row->shortcode;?></td><td><?php echo $shop_row->code;?></td><td><?php echo $shop_row->name;?></td><td><a href="/at-cms/brshopadmin/detail/<?php echo $shop_row->id;?>">詳情</a></td><td><a href="/at-cms/brshopadmin/edit/<?php echo $shop_row->id;?>">編輯</a></td>
                      <!--   <td>
                    <input type="checkbox" <?php
                        if($shop_row->status=="1"){
                            echo "checked";
                        }
                      ?> data-toggle="toggle" id="checkstatus<?php echo $shop_row->id;?>"  name="checkstatus<?php echo $shop_row->id;?>" class="togglenewclass" data-clickid="<?php echo $shop_row->id;?>"  onchange="checkToggle(this)">    
                    </td> -->
                <td>
                         <input type="checkbox" class="checkbox" id="admincheck" name="admincheck" value="<?php echo   $shop_row->id; ?>">  
                    </td>    
                </tr>



            <?php 
                   }//foreach ($employee as $row) {
            ?>


                        
            </tbody>
            </table>

            <script type="text/javascript">
$(document).ready(function() {
    $('#book-table').DataTable( {
        "order": [[ 0, "desc" ]],
         dom: 'Bfrtip',
        buttons: [
            // 'colvis'
        ]
    }

        );
});
</script>
            <!-- end test datatable -->

              <!-- delete button -->
             <button type="button" class="btn  custombutton" id="deletebutton" onclick="showdeletemodal()" data-toggle="" data-target="">
            <!-- <i class="fas fa-trash-alt mr-2" style="color:#7d4495"></i>  -->  
            <span style="color:#ffffff">遞交</span></button>   

            <!-- end delete button -->     

        </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>