<!DOCTYPE html>
<html>

<head>

<?php include 'include/common.php';?>


<!-- new datatable js and css -->
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
        <link rel="stylesheet" type="text/css" href="https://cdn.datatables.net/v/dt/dt-1.10.13/datatables.min.css"/>
<!-- <script type="text/javascript" src="https://cdn.datatables.net/v/dt/dt-1.10.13/datatables.min.js"></script> -->
 <link rel="stylesheet" type="text/css" href="https://cdn.datatables.net/responsive/2.2.4/css/responsive.dataTables.min.css"/>
        <link rel="stylesheet" type="text/css" href="https://cdn.datatables.net/buttons/1.6.2/css/buttons.dataTables.min.css"/>

<script type="text/javascript" src="https://cdn.datatables.net/v/dt/dt-1.10.13/datatables.min.js"></script>

<!-- https://code.jquery.com/jquery-3.5.1.js
https://cdn.datatables.net/1.10.21/js/jquery.dataTables.min.js -->
<script type="text/javascript" src="https://cdn.datatables.net/responsive/2.2.4/js/dataTables.responsive.min.js"></script>
<script type="text/javascript" src="https://cdn.datatables.net/buttons/1.6.2/js/dataTables.buttons.min.js"></script>
<script type="text/javascript" src="https://cdn.datatables.net/buttons/1.6.2/js/buttons.colVis.min.js"></script>


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

<!-- end new datatable js and css -->



 <script src="https://unpkg.com/gijgo@1.9.13/js/gijgo.min.js" type="text/javascript"></script>
    <link href="https://unpkg.com/gijgo@1.9.13/css/gijgo.min.css" rel="stylesheet" type="text/css" />





<!-- <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-select/1.13.1/css/bootstrap-select.min.css">
<script src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-select/1.13.1/js/bootstrap-select.min.js"></script> -->

<!-- <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-select@1.13.14/dist/css/bootstrap-select.min.css"> -->

<!-- Latest compiled and minified JavaScript -->
<!-- <script src="https://cdn.jsdelivr.net/npm/bootstrap-select@1.13.14/dist/js/bootstrap-select.min.js"></script> -->

<!-- (Optional) Latest compiled and minified JavaScript translation files -->
<!-- <script src="https://cdn.jsdelivr.net/npm/bootstrap-select@1.13.14/dist/js/i18n/defaults-*.min.js"></script> -->
<!-- <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.1.1/js/bootstrap.bundle.min.js"></script> -->
<script src="https://cdn.jsdelivr.net/npm/@dashboardcode/bsmultiselect@0.5.58/dist/js/BsMultiSelect.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/@dashboardcode/bsmultiselect@0.5.58/dist/js/BsMultiSelect.esm.min.js"></script>
 <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@dashboardcode/bsmultiselect@0.5.58/dist/css/BsMultiSelect.min.css">

<?php
//set default timezone for creater and updater
date_default_timezone_set('Asia/Hong_Kong');

?>
</head>

<body>

    <!-- admin javascript -->
     <script type="text/javascript">
      $( document ).ready(function() {






        //add control
        $("#btnSubmit").click(function(event) {
          var forcusitem="";
          var passCheck=true;


          if($('#mobile').val().length !== 0){
            $("#mobile").addClass(" is-valid ");
            $("#mobile").removeClass(" is-invalid ");
          }
          else{
            if(forcusitem.length===0){
               forcusitem="#mobile";
            }
            passCheck=false;
            $("#mobile").addClass(" is-invalid ");
           $("#mobile").removeClass(" is-valid ");
          }

          if($('#code').val().length <=7 && $('#code').val().length!==0){

            // $("#code").addClass(" is-valid ");
            // $("#code").removeClass(" is-invalid ");
          }
          else{
            if(forcusitem.length===0){
               forcusitem="#code";
            }
            $( '#warningmsg' ).empty().append('<p class="text-danger"  id="feedback">新增失敗。客戶編號的長度應為 7。</p>');
            passCheck=false;
           //  $("#code").addClass(" is-invalid ");
           // $("#code").removeClass(" is-valid ");
          }


        //   if($('#inputadminname').val().length !== 0){
        //     $("#inputadminname").addClass(" is-valid ");
        //     $("#inputadminname").removeClass(" is-invalid ");
        //   }
        //   else{
        //     if(forcusitem.length===0){
        //        forcusitem="#inputadminname";
        //     }
        //     passCheck=false;
        //     $("#inputadminname").addClass(" is-invalid ");
        //    $("#inputadminname").removeClass(" is-valid ");
        //   }

          // if($('#password').val().length !== 0){
          //   $("#password").addClass(" is-valid ");
          //   $("#password").removeClass(" is-invalid ");
          // }
          // else{
          //   if(forcusitem.length===0){
          //      forcusitem="#password";
          //   }
          //   passCheck=false;
          //   $("#password").addClass(" is-invalid ");
          //  $("#password").removeClass(" is-valid ");
          // }

          // if($('#confirm_password').val().length !== 0){
          //   $("#confirm_password").addClass(" is-valid ");
          //   $("#confirm_password").removeClass(" is-invalid ");
          // }
          // else{
          //   if(forcusitem.length===0){
          //      forcusitem="#confirm_password";
          //   }
          //   passCheck=false;
          //   $("#confirm_password").addClass(" is-invalid ");
          //  $("#confirm_password").removeClass(" is-valid ");
          // }

          // if($('#confirm_password').val().length !== 0 || ($('#confirm_password').val()!==$('#password').val())){
          //   $("#confirm_password").addClass(" is-valid ");
          //   $("#confirm_password").removeClass(" is-invalid ");
          // }
          // else{
          //   if(forcusitem.length===0){
          //      forcusitem="#confirm_password";
          //   }
          //   passCheck=false;
          //   $("#confirm_password").addClass(" is-invalid ");
          //  $("#confirm_password").removeClass(" is-valid ");
          // }



          //  if($('#chi_name').val().length !== 0){
          //   $("#chi_name").addClass(" is-valid ");
          //   $("#chi_name").removeClass(" is-invalid ");
          // }
          // else{
          //   if(forcusitem.length===0){
          //      forcusitem="#chi_name";
          //   }
          //   passCheck=false;
          //   $("#chi_name").addClass(" is-invalid ");
          //  $("#chi_name").removeClass(" is-valid ");
          // }

          // if($('#eng_firstname').val().length !== 0){
          //   $("#eng_firstname").addClass(" is-valid ");
          //   $("#eng_firstname").removeClass(" is-invalid ");
          // }
          // else{
          //   if(forcusitem.length===0){
          //      forcusitem="#eng_firstname";
          //   }
          //   passCheck=false;
          //   $("#eng_firstname").addClass(" is-invalid ");
          //  $("#eng_firstname").removeClass(" is-valid ");
          // }

          //  if($('#eng_lastname').val().length !== 0){
          //   $("#eng_lastname").addClass(" is-valid ");
          //   $("#eng_lastname").removeClass(" is-invalid ");
          // }
          // else{
          //   if(forcusitem.length===0){
          //      forcusitem="#eng_lastname";
          //   }
          //   passCheck=false;
          //   $("#eng_lastname").addClass(" is-invalid ");
          //  $("#eng_lastname").removeClass(" is-valid ");
          // }


          //  if($('#role_name').val().length !== 0){
          //   $("#role_name").addClass(" is-valid ");
          //   $("#role_name").removeClass(" is-invalid ");
          // }
          // else{
          //   if(forcusitem.length===0){
          //      forcusitem="#role_name";
          //   }
          //   passCheck=false;
          //   $("#role_name").addClass(" is-invalid ");
          //  $("#role_name").removeClass(" is-valid ");
          // }

          //  if($('#tenant_no').val().length !== 0){
          //   $("#tenant_no").addClass(" is-valid ");
          //   $("#tenant_no").removeClass(" is-invalid ");
          // }
          // else{
          //   if(forcusitem.length===0){
          //      forcusitem="#tenant_no";
          //   }
          //   passCheck=false;
          //   $("#tenant_no").addClass(" is-invalid ");
          //  $("#tenant_no").removeClass(" is-valid ");
          // }

          //  if($('#income_type').val().length !== 0){
          //   $("#income_type").addClass(" is-valid ");
          //   $("#income_type").removeClass(" is-invalid ");
          // }
          // else{
          //   if(forcusitem.length===0){
          //      forcusitem="#income_type";
          //   }
          //   passCheck=false;
          //   $("#income_type").addClass(" is-invalid ");
          //  $("#income_type").removeClass(" is-valid ");
          // }


          //  if($('#commission').val().length !== 0){
          //   $("#commission").addClass(" is-valid ");
          //   $("#commission").removeClass(" is-invalid ");
          // }
          // else{
          //   if(forcusitem.length===0){
          //      forcusitem="#commission";
          //   }
          //   passCheck=false;
          //   $("#commission").addClass(" is-invalid ");
          //  $("#commission").removeClass(" is-valid ");
          // }

          // if($('#gender').val().length !== 0){
          //   $("#gender").addClass(" is-valid ");
          //   $("#gender").removeClass(" is-invalid ");
          // }
          // else{
          //   if(forcusitem.length===0){
          //      forcusitem="#gender";
          //   }
          //   passCheck=false;
          //   $("#gender").addClass(" is-invalid ");
          //  $("#gender").removeClass(" is-valid ");
          // }




        //   alert("1");
          if(passCheck===false){

             $(forcusitem).focus();
          }


          if(passCheck===true){


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

            event.preventDefault();
            var postUrl= '<?php echo base_url(); ?>' +'api/v1/brcustomerend/add';
            // var postData ={
            //       'csrfToken' :'',
            //       'custname' : $('#name').val(),
            //       'tel' : $('#tel').val(),
            //       'email' : $('#email').val(),
            //       'wechat' : $('#wechat').val(),
            //       'birthday' : $('#birthday').val(),
            //       // 'selectedBox' :$('.css-checkbox:checked').val()
            //       'selectedBox' :selectBox1

            // }
            $checkedpurchase=0;
            if($('#need_purchase_service').is(':checked')){
                $checkedpurchase=1;
            }
            else
            {
              $checkedpurchase=0;
            }


            var postData ={
                'code':$('#code').val(),
                'display_name':$('#display_name').val(),
                // 'chi_name':$('#chi_name').val(),
                // 'eng_firstname':$('#eng_firstname').val(),
                // // 'inputadminname':$('#inputadminname').val(),
                // 'eng_lastname':$('#eng_lastname').val(),
                'gender':$('#gender').val(),
                'dob':$('#datepicker').val(),
                'mobile':$('#mobile').val(),
                'district_id':$('#area1').val(),
                'area_id':$('#level2').val(),
                'zone':$('#level3').val(),
                'address':$('#address').val(),
                'join_date':$('#datepicker2').val(),
                'shop_id':$('#first_registered_tenant_no').val(),
                'skin_improve':$('#skin_improve').val(),
                'body_improve':$('#body_improve').val(),
                'face_improve':$('#face_improve').val(),
                'referred_mobile':$('#referred_mobile').val(),
                'remark':$('#remark').val(),
                'need_purchase_service':$checkedpurchase,
                'service_id':$('#service_id').val(),
                'purchased_date':$('#purchased_date').val(),
                'purchased_qty':$('#purchased_qty').val(),
                'available_qty':$('#available_qty').val(),
                'remark2':$('#remark2').val(),
                'promotion_code':$('#promotion_code').val(),
                'first_registered_tenant_no':$('#first_registered_tenant_no').val(),
                'concurrent_registered_tenant_no':$('#concurrent_registered_tenant_no').val(),
                'level':$('#level').val(),
                'isTemp':$('#isTemp').is(':checked') ? 1 : 0,
                'channelSelectID':$('#channelSelectID').val(),
                'prefer_pic':$('#prefer_pic').val(),
                'bodyoptionother_text':$('#bodyoptionother_text').val(),
                'faceoptionother_text':$('#faceoptionother_text').val(),



            }
              postData.need_purchase_service=0;
            if($('#need_purchase_service').is(':checked')===true){
              postData.need_purchase_service=1;
              postData.service_id=$('#service_id').val();
              postData.purchased_date=$('#purchased_date').val();
              postData.purchased_price=$('#purchased_price').val();
              postData.purchased_qty=$('#purchased_qty').val();
              postData.available_qty=$('#available_qty').val();
            }

            // alert($('#level2').val());
            $.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();
                    $( '#newmsg' ).append('<p class="text-primary" id="feedback">'+data['msg']+'</p>');
                    setTimeout(function() {
                        location.reload();
                    }, 3000);
                    // location.reload();

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

            }//if(passCheck==true){
        });//$("#btnSubmit").click(function(event) {

        //end add control


        //edit control
           $("#btnUpdate").click(function(event) {
          var forcusitem="";
          var passCheck=true;


          // if($('#code').val().length !== 0){
          //   $("#code").addClass(" is-valid ");
          //   $("#code").removeClass(" is-invalid ");
          // }
          // else{
          //   if(forcusitem.length===0){
          //      forcusitem="#code";
          //   }
          //   passCheck=false;
          //   $("#code").addClass(" is-invalid ");
          //  $("#code").removeClass(" is-valid ");
          // }

           if($('#mobile').val().length !== 0){
            $("#mobile").addClass(" is-valid ");
            $("#mobile").removeClass(" is-invalid ");
          }
          else{
            if(forcusitem.length===0){
               forcusitem="#mobile";
            }
            passCheck=false;
            $("#mobile").addClass(" is-invalid ");
           $("#mobile").removeClass(" is-valid ");
          }

          if($('#code').val().length <=7 && $('#code').val().length !== 0){

            // $("#code").addClass(" is-valid ");
            // $("#code").removeClass(" is-invalid ");
          }
          else{
            if(forcusitem.length===0){
               forcusitem="#code";
            }
            $( '#warningmsg' ).empty().append('<p class="text-danger"  id="feedback">更改失敗。客戶編號的長度應為 7。</p>');
            passCheck=false;
           //  $("#code").addClass(" is-invalid ");
           // $("#code").removeClass(" is-valid ");
          }



        //   if($('#inputadminname').val().length !== 0){
        //     $("#inputadminname").addClass(" is-valid ");
        //     $("#inputadminname").removeClass(" is-invalid ");
        //   }
        //   else{
        //     if(forcusitem.length===0){
        //        forcusitem="#inputadminname";
        //     }
        //     passCheck=false;
        //     $("#inputadminname").addClass(" is-invalid ");
        //    $("#inputadminname").removeClass(" is-valid ");
        //   }

          // if($('#password').val().length !== 0){
          //   $("#password").addClass(" is-valid ");
          //   $("#password").removeClass(" is-invalid ");
          // }
          // else{
          //   if(forcusitem.length===0){
          //      forcusitem="#password";
          //   }
          //   passCheck=false;
          //   $("#password").addClass(" is-invalid ");
          //  $("#password").removeClass(" is-valid ");
          // }

          // if($('#confirm_password').val().length !== 0){
          //   $("#confirm_password").addClass(" is-valid ");
          //   $("#confirm_password").removeClass(" is-invalid ");
          // }
          // else{
          //   if(forcusitem.length===0){
          //      forcusitem="#confirm_password";
          //   }
          //   passCheck=false;
          //   $("#confirm_password").addClass(" is-invalid ");
          //  $("#confirm_password").removeClass(" is-valid ");
          // }

          // if($('#confirm_password').val().length !== 0 || ($('#confirm_password').val()!==$('#password').val())){
          //   $("#confirm_password").addClass(" is-valid ");
          //   $("#confirm_password").removeClass(" is-invalid ");
          // }
          // else{
          //   if(forcusitem.length===0){
          //      forcusitem="#confirm_password";
          //   }
          //   passCheck=false;
          //   $("#confirm_password").addClass(" is-invalid ");
          //  $("#confirm_password").removeClass(" is-valid ");
          // }



          //  if($('#chi_name').val().length !== 0){
          //   $("#chi_name").addClass(" is-valid ");
          //   $("#chi_name").removeClass(" is-invalid ");
          // }
          // else{
          //   if(forcusitem.length===0){
          //      forcusitem="#chi_name";
          //   }
          //   passCheck=false;
          //   $("#chi_name").addClass(" is-invalid ");
          //  $("#chi_name").removeClass(" is-valid ");
          // }

          // if($('#eng_firstname').val().length !== 0){
          //   $("#eng_firstname").addClass(" is-valid ");
          //   $("#eng_firstname").removeClass(" is-invalid ");
          // }
          // else{
          //   if(forcusitem.length===0){
          //      forcusitem="#eng_firstname";
          //   }
          //   passCheck=false;
          //   $("#eng_firstname").addClass(" is-invalid ");
          //  $("#eng_firstname").removeClass(" is-valid ");
          // }

          //  if($('#eng_lastname').val().length !== 0){
          //   $("#eng_lastname").addClass(" is-valid ");
          //   $("#eng_lastname").removeClass(" is-invalid ");
          // }
          // else{
          //   if(forcusitem.length===0){
          //      forcusitem="#eng_lastname";
          //   }
          //   passCheck=false;
          //   $("#eng_lastname").addClass(" is-invalid ");
          //  $("#eng_lastname").removeClass(" is-valid ");
          // }


          //  if($('#role_name').val().length !== 0){
          //   $("#role_name").addClass(" is-valid ");
          //   $("#role_name").removeClass(" is-invalid ");
          // }
          // else{
          //   if(forcusitem.length===0){
          //      forcusitem="#role_name";
          //   }
          //   passCheck=false;
          //   $("#role_name").addClass(" is-invalid ");
          //  $("#role_name").removeClass(" is-valid ");
          // }

          //  if($('#tenant_no').val().length !== 0){
          //   $("#tenant_no").addClass(" is-valid ");
          //   $("#tenant_no").removeClass(" is-invalid ");
          // }
          // else{
          //   if(forcusitem.length===0){
          //      forcusitem="#tenant_no";
          //   }
          //   passCheck=false;
          //   $("#tenant_no").addClass(" is-invalid ");
          //  $("#tenant_no").removeClass(" is-valid ");
          // }

          //  if($('#income_type').val().length !== 0){
          //   $("#income_type").addClass(" is-valid ");
          //   $("#income_type").removeClass(" is-invalid ");
          // }
          // else{
          //   if(forcusitem.length===0){
          //      forcusitem="#income_type";
          //   }
          //   passCheck=false;
          //   $("#income_type").addClass(" is-invalid ");
          //  $("#income_type").removeClass(" is-valid ");
          // }


          //  if($('#commission').val().length !== 0){
          //   $("#commission").addClass(" is-valid ");
          //   $("#commission").removeClass(" is-invalid ");
          // }
          // else{
          //   if(forcusitem.length===0){
          //      forcusitem="#commission";
          //   }
          //   passCheck=false;
          //   $("#commission").addClass(" is-invalid ");
          //  $("#commission").removeClass(" is-valid ");
          // }

          // if($('#gender').val().length !== 0){
          //   $("#gender").addClass(" is-valid ");
          //   $("#gender").removeClass(" is-invalid ");
          // }
          // else{
          //   if(forcusitem.length===0){
          //      forcusitem="#gender";
          //   }
          //   passCheck=false;
          //   $("#gender").addClass(" is-invalid ");
          //  $("#gender").removeClass(" is-valid ");
          // }


          if(passCheck===false){

             $(forcusitem).focus();
          }

        //   alert("1");
          if(passCheck==true){


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

            event.preventDefault();
            var postUrl= GlobalVariables.baseUrl +'api/v1/brcustomerend/update';
            // var postData ={
            //       'csrfToken' :'',
            //       'custname' : $('#name').val(),
            //       'tel' : $('#tel').val(),
            //       'email' : $('#email').val(),
            //       'wechat' : $('#wechat').val(),
            //       'birthday' : $('#birthday').val(),
            //       // 'selectedBox' :$('.css-checkbox:checked').val()
            //       'selectedBox' :selectBox1

            // }
            $checkedpurchase=0;
            if($('#need_purchase_service').is(':checked')){
                $checkedpurchase=1;
            }
            else
            {
              $checkedpurchase=0;
            }


            var postData ={
                'code':$('#code').val(),
                'display_name':$('#display_name').val(),
                // 'chi_name':$('#chi_name').val(),
                // 'eng_firstname':$('#eng_firstname').val(),
                // 'inputadminname':$('#inputadminname').val(),
                // 'eng_lastname':$('#eng_lastname').val(),
                'gender':$('#gender').val(),
                'dob':$('#datepicker').val(),
                'mobile':$('#mobile').val(),
                'district_id':$('#area1').val(),
                'area_id':$('#level2').val(),
                'zone':$('#level3').val(),
                'address':$('#address').val(),
                'join_date':$('#datepicker2').val(),
                'shop_id':$('#first_registered_tenant_no').val(),
                'skin_improve':$('#skin_improve').val(),
                'referred_mobile':$('#referred_mobile').val(),
                'remark':$('#remark').val(),
                'oridistrict_id':$('#oridistrict_id').val(),
                'oriarea_id':$('#oriarea_id').val(),
                'orizone':$('#orizone').val(),
                'first_registered_tenant_no':$('#first_registered_tenant_no').val(),
                'concurrent_registered_tenant_no':$('#concurrent_registered_tenant_no').val(),
                'level':$('#level').val(),
                'isTemp':$('#isTemp').is(':checked') ? 1 : 0,
                'prefer_pic':$('#prefer_pic').val(),
                'channelSelectID':$('#channelSelectID').val(),
                'body_improve':$('#body_improve').val(),
                'bodyoptionother_text':$('#bodyoptionother_text').val(),
                'face_improve':$('#face_improve').val(),
                'faceoptionother_text':$('#faceoptionother_text').val(),
                // 'need_purchase_service':$checkedpurchase,
                // 'service_id':$('#service_id').val(),
                // 'purchased_date':$('#purchased_date').val(),
                // 'purchased_qty':$('#purchased_qty').val(),
                // 'available_qty':$('#available_qty').val(),
                // 'remark2':$('#remark2').val(),
                'id':$('#id').val()

            }

            // alert($('#level2').val());
            $.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();
                    $( '#newmsg' ).append('<p class="text-primary" id="feedback">'+data['msg']+'</p>');
                    setTimeout(function() {
                        location.reload();
                    }, 3000);
                    // location.reload();

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

            }//if(passCheck==true){
        });//$("#btnUpdate").click(function(event) {


        //end edit control


         $( ".level1select" ).change(function() {
          // alert( "Handler for .change() called." );
          level1boxajax($(this).attr("id"),$(this).val());
        });

          $( ".level2select" ).change(function() {
          // alert( "Handler for .change() called." );
          level2boxajax($(this).attr("id"),$(this).val());
        });

          $( ".level3select" ).change(function() {
          // alert( "Handler for .change() called." );
          $('#address').val($("#area1 option:selected").text()+$(this).val());
        });


        });// $( document ).ready(function() {

         function level1boxajax($id,$value){
              var id = $id;
              // alert(id);
              var res = id.split("-");
              var fileid=res[0];
              var items=res[1];
              // alert("fileid"+fileid);
              // alert("items"+items);
              // var selectedid= $({"#".id}).val();
              var selectedid=$value;
              // alert(selectedid);
              var GlobalVariables ={
                  'csrfToken': '123',
                  'baseUrl':'<?php echo base_url(); ?>',
                  'destUrl':'<?php echo base_url(); ?>/api/v1/livingareaend/getSecondZone',
                  'AJAX_SUCCESS' :'SUCCESS',
                  'AJAX_FAILURE' :'FAILURE'
            };

              //empty lower select box

               var level2box = document.getElementById('level2');
                  // alert(city);
                   $(level2box).empty();


              //end empty lower select box

              var postUrl= GlobalVariables.baseUrl +'/api/v1/livingareaend/getSecondZone';
              //change select box option
                 $.ajax({
                        type:'POST',
                        url:postUrl,
                        data:{'zone_id':selectedid},
                    success:function(data){
                      // alert('empty');
                      var obj = $.parseJSON(data);
                      // alert('empty2');
                    // var v = data.k;

                   // the next thing you want to do
                   // alert(fileid+'-'+items+'Level2');
                   // id='row' + id.toString();
                  // var findname=fileid.toString()+'-'+items.toString()+'-Level2';
                  // var city = document.getElementById(fileid+'-'.items+'Level2');
                  // var city = document.getElementById('5-1-Level2');
                  var level2box = document.getElementById('level2');
                  // alert(city);
                   $(level2box).empty();
                  //  $jsondata=json_decode($data);
                  // alert( obj.length);
                  // alert( obj[0]['name']);

                   //added empty select record
                  $(level2box).append('<option  value=' + '>--- 請選擇居住範圍---'  + '</option>');

                  //end added empty select record


                  for (var i = 0; i < obj.length; i++) {

                  $(level2box).append('<option  value=' + obj[i].id + '>' + obj[i].chi_name + '</option>');
                  }
                  // alert(data);
                  // level3boxajax(fileid+'-'+items+'-Level3', obj[0].id);
                  // alert('level3'+data);
              }
            });

          }
        //end level1boxajax

        //level2ajax
        function level2boxajax($id,$value){
              var id = $id;
              // alert(id);
              var res = id.split("-");
              var fileid=res[0];
              var items=res[1];
              // alert("fileid"+fileid);
              // alert("items"+items);
              // var selectedid= $({"#".id}).val();
              var selectedid=$value;
              // alert(selectedid);
              var GlobalVariables ={
                  'csrfToken': '123',
                  'baseUrl':'<?php echo base_url(); ?>',
                  'destUrl':'<?php echo base_url(); ?>/api/v1/livingareaend/getThirdZone',
                  'AJAX_SUCCESS' :'SUCCESS',
                  'AJAX_FAILURE' :'FAILURE'
            };

              //empty lower select box

               var level3box = document.getElementById('level3');
                  // alert(city);
                   $(level3box).empty();


              //end empty lower select box

              var postUrl= GlobalVariables.baseUrl +'/api/v1/livingareaend/getThirdZone';
              //change select box option
                 $.ajax({
                        type:'POST',
                        url:postUrl,
                        data:{'zone_id':selectedid},
                    success:function(data){
                      // alert('empty');
                      var obj = $.parseJSON(data);
                      // alert('empty2');
                    // var v = data.k;

                   // the next thing you want to do
                   // alert(fileid+'-'+items+'Level2');
                   // id='row' + id.toString();
                  // var findname=fileid.toString()+'-'+items.toString()+'-Level2';
                  // var city = document.getElementById(fileid+'-'.items+'Level2');
                  // var city = document.getElementById('5-1-Level2');
                  var level3box = document.getElementById('level3');
                  // alert(city);
                   $(level3box).empty();
                  //  $jsondata=json_decode($data);
                  // alert( obj.length);
                  // alert( obj[0]['name']);

                   //added empty select record
                  $(level3box).append('<option  value=' + '>--- 請選擇居住範圍---'  + '</option>');

                  //end added empty select record


                  for (var i = 0; i < obj.length; i++) {

                  $(level3box).append('<option  value=' + obj[i] + '>' + obj[i] + '</option>');
                  }
                  // alert(data);
                  // level3boxajax(fileid+'-'+items+'-Level3', obj[0].id);
                  // alert('level3'+data);
              }
            });

          }

        //end level2ajax




      </script>



    <?php include 'include/header.php';?>
    <div class="wrapper" >

        <?php include 'include/sidebar.php';?>
        <!-- Page Content  -->
        <div id="content" style="background-color: #ffffff;">
          <!-- <h5>新增客戶</h5> -->
          <div class="title"><?php if ($pagemethod == "add") {
	echo "新增客戶";
}?>
              <?php if ($pagemethod == "edit") {
	echo "更改客戶";
}?></div>

           <div style="" class="menubar2  p-2">

           <a href="/at-cms/brcustomeradmin"> <i class="fas fa-chevron-left" style=" display: inline-block;
/*  border-radius: 10px;
  box-shadow: 0px 0px 2px #888;*/
  color: #957c78;
  padding: 2px 2px;"></i>返回</a>
            </div>
            <!-- add button -->
            <span id="warningmsg" class="text-center"></span>
            <!-- input form -->
            <form>
            <div class="form-group row">
              <label for="username" class="col-sm-2 col-form-label">客戶編號*</label>
              <div class="col-sm-10">
                <input type="text"  class="form-control" id="code" name="code" value="<?php
if ($pagemethod == "add") {
	echo
		$customercode;
}
if ($pagemethod == "edit" || $pagemethod == "details") {
	echo
	$customerdetails->code;
}

?>" placeholder="輸入客戶編號" <?php

if ($pagemethod == "details") {
	echo
		"readonly";
}
?>>
                <div class="valid-feedback">正確</div>
                <div class="invalid-feedback">没有资料</div>
              </div>
            </div>

      <!--       <div class="form-group row">
              <label for="promotion_code" class="col-sm-2 col-form-label">Trial 試用會員</label>
              <div class="col-sm-10"> -->
                <input type="checkbox"  id="isTemp" name="isTemp" value="1" class="form-control" style="width: auto;display: none" <?php
if ($pagemethod == "edit") {
	if ($customerdetails->isTemp == 1) {
		echo "checked";
	}

}
if ($pagemethod == "details") {
	echo 'onclick="return false" ';
}

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

             <div class="form-group row">
              <label for="inputPassword" class="col-sm-2 col-form-label">客戶分級</label>
              <div class="col-sm-10">
                 <select class="select mas-select select2-offscreen form-control" name="level" id="level" tabindex="-1" style="width: auto;">
                 <?php

if ($pagemethod == "details") {
	echo
		"disabled";
}
?>
                 >
                  <!-- <option value="">--- 請選擇薪酬種類 ---</option> -->
                  <option value=""></option>
                <?php
foreach ($memberlevel_list as $memberlevelrow) {
	?>

                <option value="<?php echo $memberlevelrow->id; ?>" <?php
// 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>


            <div class="form-group row">
              <label for="display_name" class="col-sm-2 col-form-label">名稱</label>
              <div class="col-sm-10">
                <input type="text" class="form-control" id="display_name" name="display_name" placeholder="輸入中文名稱" value="<?php
if ($pagemethod == "add") {
	echo
		"";
}
if ($pagemethod == "edit" || $pagemethod == "details") {
	echo
	$customerdetails->display_name;
}

?>" <?php

if ($pagemethod == "details") {
	echo
		"readonly";
}
?>>
                <div class="valid-feedback">正確</div>
                <div class="invalid-feedback">没有资料</div>
              </div>
            </div>



             <div class="form-group row">
              <label for="eng_firstname" class="col-sm-2 col-form-label">性別</label>
              <div class="col-sm-10">
                <?php
// $st[""] = "";
// $st["0"] = "女";
// $st["1"] = "男";

// echo form_dropdown('gender', $st, 0, 'id="gender" name="gender" data-placeholder="' . ' '  . '" class="form-control input-tip select2" style=""');
?>
                <select  id="gender" name="gender" data-placeholder="" class="form-control input-tip select2" style="" <?php

if ($pagemethod == "details") {
	echo
		"disabled";
}
?>>
                  <option value="" <?php if ($pagemethod == "edit" || $pagemethod == "details") {
	if ($customerdetails->gender == "") {echo "selected";}
}?>></option>
              <option value="0" <?php if ($pagemethod == "edit" || $pagemethod == "details") {
	if ($customerdetails->gender == "0") {echo "selected";}
}?>
              <?php if ($pagemethod == "add") {echo "selected";}?>
              >女</option>
              <option value="1" <?php if ($pagemethod == "edit" || $pagemethod == "details") {
	if ($customerdetails->gender == "1") {echo "selected";}
}?>>男</option>
                </select>
                <div class="valid-feedback">正確</div>
                <div class="invalid-feedback">没有资料</div>
              </div>
            </div>

            <div class="form-group row">
              <label for="inputPassword" class="col-sm-2 col-form-label" >出生日期</label>
              <div class="col-sm-10">
                  <!-- date picker -->
                  <!-- dob readonly="true" -->
                  <input id="datepicker" width="276" autocomplete="off" value="<?php
if ($pagemethod == "add") {
	echo
		"";
}
if ($pagemethod == "edit" || $pagemethod == "details") {
	echo
	$customerdetails->dob;
}?>" <?php

if ($pagemethod == "details") {
	echo
		"readonly";
}
?>/>
                  <script>
                      $('#datepicker').datepicker({
                          uiLibrary: 'bootstrap4',
                          format: 'yyyy-mm-dd'
                      });
                  </script>
                  <!-- end date picker -->

                  <div class="valid-feedback">正確</div>
                  <div class="invalid-feedback">没有资料</div>
              </div>
            </div>
            <div class="form-group row">
              <label for="mobile" class="col-sm-2 col-form-label">手機號碼*</label>
              <div class="col-sm-10">
                <input type="text" class="form-control" id="mobile" name="mobile" placeholder="" value="<?php
if ($pagemethod == "add") {
	echo
		"";
}
if ($pagemethod == "edit" || $pagemethod == "details") {
	echo
	$customerdetails->mobile;
}?>" <?php

if ($pagemethod == "details") {
	echo
		"readonly";
}
?>>
                <div class="valid-feedback">正確</div>
                <div class="invalid-feedback">没有资料</div>
              </div>
            </div>
             <div class="form-group row">
              <label for="inputPassword" class="col-sm-2 col-form-label">居住地區</label>
              <div class="col-sm-10">
                <!-- first column area 1 -->
                              <select class="form-control level1select" id="area1"
                              <?php
if ($pagemethod == "details") {
	echo 'disabled="disabled"';
}
?>
                               >
                                <option value="">--- 請選擇居住區域 ---</option>
                             <?php foreach ($firstzone as $firstzonedata): ?>
                               <option value="<?php echo $firstzonedata->id; ?>"  ><?php echo $firstzonedata->chi_name; ?></option>
                             <?php endforeach?>
                          <!-- <option value="">1</option> -->
                            </select>


                <!-- end first column area 1 -->
                <!-- second column area 2 -->
                <select class="form-control level2select" id="level2" <?php
if ($pagemethod == "details") {
	echo 'disabled="disabled"';
}
?>>
                    <option value=""></option>
                </select>
                <!-- end second column area 2 -->

                <!-- second column area 3 -->
                <select class="form-control level3select" id="level3" <?php
if ($pagemethod == "details") {
	echo 'disabled="disabled"';
}
?>>
                    <option value=""></option>
                </select>
                <!-- end second column area 3 -->

                <!-- <select class="select mas-select select2-offscreen" name="income_type" id="income_type" tabindex="-1">
                  <option value="">--- 請選擇薪酬種類 ---</option> -->
                <?php
//foreach ($employeeincometype as $row) {
?>
                <!-- <option value="<?php echo $row->id; ?>" ><?php echo $row->name; ?></option> -->
                 <?php
// }
?>
                <?php

if ($pagemethod == "edit") {

	?>
                    <input type="hidden" class="form-control" id="oridistrict_id" name="oridistrict_id" placeholder="" value="<?php echo
	$customerdetailslivingarea->district_id; ?>">

                    <input type="hidden" class="form-control" id="oriarea_id" name="oriarea_id" placeholder="" value="<?php echo
	$customerdetailslivingarea->area_id; ?>">

                    <input type="hidden" class="form-control" id="orizone" name="orizone" placeholder="" value="<?php echo
	$customerdetailslivingarea->zone; ?>">
                <?php
}

?>
                <!-- </select> -->
                <div class="valid-feedback">正確</div>
                <div class="invalid-feedback">没有资料</div>
              </div>
            </div>
              <div class="form-group row">
              <label for="inputPassword" class="col-sm-2 col-form-label">地址</label>
              <div class="col-sm-10">
                <input type="text" class="form-control" id="address" name="address" placeholder="" value="<?php
if ($pagemethod == "add") {
	echo
		"";
}
if ($pagemethod == "edit" || $pagemethod == "details") {
	echo
	$customerdetailslivingarea->address;
}?>"  <?php if ($pagemethod == "details") {
	echo
		"readonly";
}?>>
                <div class="valid-feedback">正確</div>
                <div class="invalid-feedback">没有资料</div>
              </div>
            </div>
            <div class="form-group row">
              <label for="inputPassword" class="col-sm-2 col-form-label">加入日期</label>
              <div class="col-sm-10">
                <!-- date picker -->
                <!-- dob readonly="true" -->
                  <input id="datepicker2" width="276" autocomplete="off" value="<?php
if ($pagemethod == "add") {
	echo date("Y-m-d");
}if ($pagemethod == "edit" || $pagemethod == "details") {
	echo
	$customerdetails->join_date;
}?>" <?php if ($pagemethod == "details") {
	echo
		"readonly";
}?>/>
                  <script>
                      $('#datepicker2').datepicker({
                          uiLibrary: 'bootstrap4',
                          format: 'yyyy-mm-dd'
                      });
                  </script>
                  <!-- end date picker -->
                <div class="valid-feedback">正確</div>
                <div class="invalid-feedback">没有资料</div>
              </div>
            </div>
            <div class="form-group row">
              <label for="inputPassword" class="col-sm-2 col-form-label">首次登記分店</label>
              <div class="col-sm-10">
                 <select class="select mas-select select2-offscreen form-control" style="width:auto "  name="first_registered_tenant_no" id="first_registered_tenant_no" tabindex="-1"
                 <?php

if ($pagemethod == "details") {
	echo
		"disabled";
}
?>
                 >
                  <!-- <option value="">--- 請選擇薪酬種類 ---</option> -->
                <?php
foreach ($shop_list as $shoprow) {
	?>
                <option value="<?php echo $shoprow->id; ?>" <?php

	if ($pagemethod == 'add') {
		if ($this->session->userdata('currentshop') == $shoprow->id) {
			echo "selected";
		}
	} //if($pagemethod=='add'){
	if ($pagemethod == 'edit' || $pagemethod == 'details') {

		if (!empty($customerdetails->first_registered_tenant_no)) {
			if ($customerdetails->first_registered_tenant_no == $shoprow->id) {
				echo "selected";
			}
		}

	} //if($pagemethod=='edit' || $pagemethod=='detail'){

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

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

            <div class="form-group row">
              <label for="inputPassword" class="col-sm-2 col-form-label">常駐登記分店</label>
              <div class="col-sm-10">
                 <select class="select mas-select select2-offscreen form-control" style="width:auto " name="concurrent_registered_tenant_no" id="concurrent_registered_tenant_no" tabindex="-1"
                 <?php

if ($pagemethod == "details") {
	echo
		"disabled";
}
?>
                 >
                  <!-- <option value="">--- 請選擇薪酬種類 ---</option> -->
                <?php
foreach ($shop_list as $shoprow) {
	?>
                <option value="<?php echo $shoprow->id; ?>"  <?php
if ($pagemethod == 'add') {
		if ($this->session->userdata('currentshop') == $shoprow->id) {
			echo "selected";
		}
	} //if($pagemethod=='add'){
	if ($pagemethod == 'edit' || $pagemethod == 'details') {

		if (!empty($customerdetails->concurrent_registered_tenant_no)) {
			if ($customerdetails->concurrent_registered_tenant_no == $shoprow->id) {
				echo "selected";
			}
		}

	} //if($pagemethod=='edit' || $pagemethod=='detail'){

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

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


            <div class="form-group row">
              <label for="inputPassword" class="col-sm-2 col-form-label">預設美容師</label>
              <div class="col-sm-10">
                 <select class="select mas-select select2-offscreen form-control" style="width:auto " name="prefer_pic" id="prefer_pic" tabindex="-1"
                 <?php

if ($pagemethod == "details") {
	echo
		"disabled";
}
?>
                 >
                  <!-- <option value="">--- 請選擇薪酬種類 ---</option> -->
                 <option value>--</option>
                <?php foreach ($therapistlist as $therapistrow) {
	?>
                  <option value="<?php echo $therapistrow->id; ?>"
                     <?php
if (!empty($customerdetails->prefer_pic)) {
		if ($customerdetails->prefer_pic == $therapistrow->id) {
			echo "selected";
		}
	}

	?>
                    ><?php

	echo $therapistrow->username;

	?></option>
                <?php
} //php foreach ($customers as $customerrow){ ?>


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


             <div class="form-group row">
              <label for="channelSelectID" class="col-sm-2 col-form-label">會員來源</label>
              <div class="col-sm-10">
                 <select class="select mas-select select2-offscreen form-control" style="width:auto " name="channelSelectID" id="channelSelectID" tabindex="-1"
                 <?php

if ($pagemethod == "details") {
	echo
		"disabled";
}
?>
                 >
                  <option value="">--- 請選擇會員來源 ---</option>
                <?php
foreach ($channel_list as $channelrow) {
	?>
                <option value="<?php echo $channelrow->id; ?>"  <?php
if (!empty($customerdetails->channelSelectID)) {
		if ($customerdetails->channelSelectID == $channelrow->id) {
			echo "selected";
		}
	}

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

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

            <div class="form-group row">
              <label for="inputPassword" class="col-sm-2 col-form-label">想改善既皮膚問題</label>
              <div class="col-sm-10">
                <?php

if ($pagemethod == "add") {

}
if ($pagemethod == "edit" || $pagemethod == "details") {
	// echo $customerdetailsSkinImprove->skin_improve_ids;
	// echo "<br>";
	$str1 = substr($customerdetailsSkinImprove->skin_improve_ids, 1);
	$str2 = substr($str1, 0, -1);
	$pieces = explode(",", $str2);
}
?>
     <!--            <input type="text" class="form-control" id="commission" name="commission" placeholder=""> -->
              <select multiple data-style="bg-white rounded-pill px-4 py-3 shadow-sm " style="display: none;">  class="selectpicker w-100" id="skin_improve" name="skin_improve" <?php

if ($pagemethod == "details") {
	echo
		"disabled";
}
?>>
                <?php foreach ($shopimprove as $shopimproverow) {
	?>
                    <option value="<?php echo $shopimproverow->id; ?>"  <?php
if ($pagemethod == "edit" || $pagemethod == "details") {
		if (in_array($shopimproverow->id, $pieces)) {
			echo "selected";
		}
	}
	?>><?php echo $shopimproverow->name; ?></option>
                <?php
} //foreach ($shopimprove as $shopimproverow) {
?>

            </select><!-- End -->

           <!--  <select class="selectpicker1" multiple data-live-search="true">
  <option>Mustard</option>
  <option>Ketchup</option>
  <option>Relish</option>
</select> -->

                <script type="text/javascript">
                   $(function () {
                    // $('.selectpicker').selectpicker();
                     // $('.selectpicker').bsMultiSelect();

                    // $('select').selectpicker();
                });


                </script>
                <style type="text/css">
                    .bootstrap-select .bs-ok-default::after {
                        width: 0.3em;
                        height: 0.6em;
                        border-width: 0 0.1em 0.1em 0;
                        transform: rotate(45deg) translateY(0.5rem);
                    }

                    .btn.dropdown-toggle:focus {
                        outline: none !important;
                    }

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

            <!-- added body option -->
             <div class="form-group row">
              <label for="inputPassword" class="col-sm-2 col-form-label">身體:</label>

              <div class="col-sm-10">
                <?php

if ($pagemethod == "add") {

}
if ($pagemethod == "edit" || $pagemethod == "details") {
	// echo $customerdetailsSkinImprove->skin_improve_ids;
	// echo "<br>";
	$str1 = substr($customerdetailsBodyImprove->body_improve_ids, 1);
	$str2 = substr($str1, 0, -1);
	$pieces = explode(",", $str2);
}
?>
     <!--            <input type="text" class="form-control" id="commission" name="commission" placeholder=""> -->
              <select multiple data-style="bg-white rounded-pill px-4 py-3 shadow-sm " class="selectbodypicker w-100" id="body_improve" name="body_improve" <?php

if ($pagemethod == "details") {
	echo
		"disabled";
}
?>>
                <?php foreach ($bodyimprovelist as $bodyimproverow) {
	?>
                    <option value="<?php echo $bodyimproverow->id; ?>"  <?php
if ($pagemethod == "edit" || $pagemethod == "details") {
		if (in_array($bodyimproverow->id, $pieces)) {
			echo "selected";
		}
	}
	?>><?php echo $bodyimproverow->name; ?></option>
                <?php
} //foreach ($shopimprove as $shopimproverow) {
?>

            </select><!-- End -->

           <!--  <select class="selectpicker1" multiple data-live-search="true">
  <option>Mustard</option>
  <option>Ketchup</option>
  <option>Relish</option>
</select> -->

                <script type="text/javascript">
                   $(function () {
                    // $('.selectpicker').selectpicker();
                     $('.selectbodypicker').bsMultiSelect();

                    // $('select').selectpicker();
                });


                </script>
                <style type="text/css">
                    .bootstrap-select .bs-ok-default::after {
                        width: 0.3em;
                        height: 0.6em;
                        border-width: 0 0.1em 0.1em 0;
                        transform: rotate(45deg) translateY(0.5rem);
                    }

                    .btn.dropdown-toggle:focus {
                        outline: none !important;
                    }

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

            <!-- body option other -->
            <div class="form-group row">
              <label for="inputPassword" class="col-sm-2 col-form-label"></label>

              <div class="col-sm-10">
                <p style="display: inline-block;">其他</p>
                <!-- 123 -->
                <input type="text" class="form-control" id="bodyoptionother_text" name="bodyoptionother_text" placeholder="" value="<?php
if ($pagemethod == "add") {
	echo
		"";
}
if ($pagemethod == "edit" || $pagemethod == "details") {

	if (!empty($customerdetails->bodyoptionother_text)) {
		echo $customerdetails->bodyoptionother_text;
	}

}?>"  <?php

if ($pagemethod == "details") {
	echo
		"readonly";
}
?>  style="display: inline-block;width:auto;">
                <div class="valid-feedback">正確</div>
                <div class="invalid-feedback">没有资料</div>

                <!-- end 123 -->


              </div>
            </div>


            <!-- end body option other -->


            <!-- end added body option -->

            <!-- added face option -->
            <div class="form-group row">
              <label for="inputPassword" class="col-sm-2 col-form-label">面部:</label>

              <div class="col-sm-10">
                <?php

if ($pagemethod == "add") {

}
if ($pagemethod == "edit" || $pagemethod == "details") {
	// echo $customerdetailsSkinImprove->skin_improve_ids;
	// echo "<br>";
	$str1 = substr($customerdetailsFaceImprove->face_improve_ids, 1);
	$str2 = substr($str1, 0, -1);
	$pieces = explode(",", $str2);
}
?>
     <!--            <input type="text" class="form-control" id="commission" name="commission" placeholder=""> -->
              <select multiple data-style="bg-white rounded-pill px-4 py-3 shadow-sm " class="selectfacepicker w-100" id="face_improve" name="face_improve" <?php

if ($pagemethod == "details") {
	echo
		"disabled";
}
?>>
                <?php foreach ($faceimprovelist as $faceimproverow) {
	?>
                    <option value="<?php echo $faceimproverow->id; ?>"  <?php
if ($pagemethod == "edit" || $pagemethod == "details") {
		if (in_array($faceimproverow->id, $pieces)) {
			echo "selected";
		}
	}
	?>><?php echo $faceimproverow->name; ?></option>
                <?php
} //foreach ($shopimprove as $shopimproverow) {
?>

            </select><!-- End -->

           <!--  <select class="selectpicker1" multiple data-live-search="true">
  <option>Mustard</option>
  <option>Ketchup</option>
  <option>Relish</option>
</select> -->

                <script type="text/javascript">
                   $(function () {
                    // $('.selectpicker').selectpicker();
                     $('.selectfacepicker').bsMultiSelect();

                    // $('select').selectpicker();
                });


                </script>
                <style type="text/css">
                    .bootstrap-select .bs-ok-default::after {
                        width: 0.3em;
                        height: 0.6em;
                        border-width: 0 0.1em 0.1em 0;
                        transform: rotate(45deg) translateY(0.5rem);
                    }

                    .btn.dropdown-toggle:focus {
                        outline: none !important;
                    }

                </style>
                <div class="valid-feedback">正確</div>
                <div class="invalid-feedback">没有资料</div>
              </div>
            </div>
            <!-- end added face option -->


            <!-- added face other input box -->
            <div class="form-group row">
              <label for="inputPassword" class="col-sm-2 col-form-label"></label>

              <div class="col-sm-10">
                <p style="display: inline-block;">其他</p>
                <!-- 123 -->
                <input type="text" class="form-control" id="faceoptionother_text" name="faceoptionother_text" placeholder="" value="<?php
if ($pagemethod == "add") {
	echo
		"";
}
if ($pagemethod == "edit" || $pagemethod == "details") {

	if (!empty($customerdetails->faceoptionother_text)) {
		echo $customerdetails->faceoptionother_text;
	}

}?>"  <?php

if ($pagemethod == "details") {
	echo
		"readonly";
}
?>  style="display: inline-block;width:auto;">
                <div class="valid-feedback">正確</div>
                <div class="invalid-feedback">没有资料</div>

                <!-- end 123 -->


              </div>
            </div>
            <!-- end added face other input box -->

            <div class="form-group row">
              <label for="referred_mobile" class="col-sm-2 col-form-label">介紹人手機號碼</label>
              <div class="col-sm-10">
                <input type="text" class="form-control" id="referred_mobile" name="referred_mobile" placeholder="" value="<?php
if ($pagemethod == "add") {
	echo
		"";
}
if ($pagemethod == "edit" || $pagemethod == "details") {
	echo
	$customerdetails->referred_mobile;
}?>"  <?php

if ($pagemethod == "details") {
	echo
		"readonly";
}
?>>
                <div class="valid-feedback">正確</div>
                <div class="invalid-feedback">没有资料</div>
              </div>
            </div>

            <div class="form-group row">
              <label for="promotion_code" class="col-sm-2 col-form-label">促銷代碼</label>
              <div class="col-sm-10">
                <input type="text" class="form-control" id="promotion_code" name="promotion_code" placeholder="" value="<?php
if ($pagemethod == "add") {
	echo
		"";
}
if ($pagemethod == "edit" || $pagemethod == "details") {

	if (!empty($customerdetailsPromotionCode->promotion_code)) {
		echo $customerdetailsPromotionCode->promotion_code;
	}

}?>"  <?php

if ($pagemethod == "details") {
	echo
		"readonly";
}
?> >
                <div class="valid-feedback">正確</div>
                <div class="invalid-feedback">没有资料</div>
              </div>
            </div>

            <div class="form-group row">
              <label for="inputPassword" class="col-sm-2 col-form-label">備註</label>
              <div class="col-sm-10">
                <textarea  type="text" class="form-control" id="remark" name="remark" rows="4" cols="50" placeholder="輸入備註" <?php

if ($pagemethod == "details") {
	echo
		"readonly";
}
?>><?php
if ($pagemethod == "add") {
	echo
		"";
}
if ($pagemethod == "edit" || $pagemethod == "details") {
	echo
	$customerdetails->remark;
}?></textarea>
              </div>
            </div>

            <?php

if ($pagemethod == "edit" || $pagemethod == "details") {
	?>
            <div class="form-group row">
              <label for="update_time" class="col-sm-2 col-form-label">更改時間</label>
              <div class="col-sm-10">
                <input type="text" class="form-control" id="update_time" name="update_time" placeholder="" value="<?php

	if ($pagemethod == "edit" || $pagemethod == "details") {
		if (!empty($customerdetails->update_time)) {
			// $date = new DateTime($customerdetails->update_time, new DateTimeZone('Asia/Hong') );
			//  echo $date->format('Y-m-d H:i:s');

			echo date("Y-m-d H:i:s", $customerdetails->update_time);
		}

	}?>"  <?php

	if ($pagemethod == "details") {
		echo
			"readonly";
	}
	?> >
                <div class="valid-feedback">正確</div>
                <div class="invalid-feedback">没有资料</div>
              </div>
            </div>

          <?php
}
?>

             <?php

if ($pagemethod == "edit" || $pagemethod == "details") {
	?>
            <div class="form-group row">
              <label for="updated_by" class="col-sm-2 col-form-label">更改者</label>
              <div class="col-sm-10">
                <input type="text" class="form-control" id="updated_by" name="updated_by" placeholder="" value="<?php

	if ($pagemethod == "edit" || $pagemethod == "details") {

		if (!empty($updater->eng_firstname)) {
			echo $updater->eng_firstname;
			echo " ";
		}
		if (!empty($updater->eng_lastname)) {
			echo $updater->eng_lastname;
		}

	}?>"  <?php

	if ($pagemethod == "details") {
		echo
			"readonly";
	}
	?> >
                <div class="valid-feedback">正確</div>
                <div class="invalid-feedback">没有资料</div>
              </div>
            </div>

          <?php
}
?>

           <?php

if ($pagemethod == "edit" || $pagemethod == "details") {
	?>
            <div class="form-group row">
              <label for="create_time" class="col-sm-2 col-form-label">創建時間</label>
              <div class="col-sm-10">
                <input type="text" class="form-control" id="create_time" name="create_time" placeholder="" value="<?php

	if ($pagemethod == "edit" || $pagemethod == "details") {

		if (!empty($customerdetails->create_time)) {
			echo date("Y-m-d H:i:s", $customerdetails->create_time);
		}

	}?>"  <?php

	if ($pagemethod == "details") {
		echo
			"readonly";
	}
	?> >
                <div class="valid-feedback">正確</div>
                <div class="invalid-feedback">没有资料</div>
              </div>
            </div>

          <?php
}
?>

            <?php

if ($pagemethod == "edit" || $pagemethod == "details") {
	?>
            <div class="form-group row">
              <label for="created_by" class="col-sm-2 col-form-label">創建者</label>
              <div class="col-sm-10">
                <input type="text" class="form-control" id="created_by" name="created_by" placeholder="" value="<?php

	if ($pagemethod == "edit" || $pagemethod == "details") {

		if (!empty($creator->eng_firstname)) {
			echo $creator->eng_firstname;
			echo " ";
		}
		if (!empty($creator->eng_lastname)) {
			echo $creator->eng_lastname;
		}

	}?>"  <?php

	if ($pagemethod == "details") {
		echo
			"readonly";
	}
	?> >
                <div class="valid-feedback">正確</div>
                <div class="invalid-feedback">没有资料</div>
              </div>
            </div>

          <?php
}
?>

            <div class="form-group row">
                        <div class="col-sm-12">
                        <p style="font-size: 12px;"><span style="color:#616161">*為必填項目</span></p>

                         </div>
            </div>
            <?php
if ($pagemethod == "add") {
	?>


            <h5>購買療程服務</h5>

            <div class="form-group row">
              <label for="promotion_code" class="col-sm-2 col-form-label">新增購買療程服務</label>
              <div class="col-sm-10">
                <input type="checkbox" id="need_purchase_service" name="need_purchase_service" value="true">
                <div class="valid-feedback">正確</div>
                <div class="invalid-feedback">没有资料</div>
              </div>
            </div>


            <div class="form-group row">
              <label for="inputPassword" class="col-sm-2 col-form-label">服務項目*</label>
              <div class="col-sm-10">
                <!-- first column area 1 -->
                              <select class="form-control " id="service_id" name="service_id">
                                <option value="">--</option>
                             <?php foreach ($services as $servicesrow): ?>
                               <option value="<?php echo $servicesrow->id; ?>"  ><?php echo $servicesrow->name; ?></option>
                             <?php endforeach?>
                          <!-- <option value="">1</option> -->
                            </select>




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

             <div class="form-group row">
              <label for="purchased_date" class="col-sm-2 col-form-label">購買日期</label>
              <div class="col-sm-10">
                  <!-- date picker -->
                  <!-- dob readonly="true" -->
                  <input id="purchased_date" width="276" name="purchased_date" autocomplete="off"/>
                  <script>
                      $('#purchased_date').datepicker({
                          uiLibrary: 'bootstrap4',
                          format: 'yyyy-mm-dd'
                      });
                  </script>
                  <!-- end date picker -->

                  <div class="valid-feedback">正確</div>
                  <div class="invalid-feedback">没有资料</div>
              </div>
            </div>
             <div class="form-group row">
              <label for="purchased_price" class="col-sm-2 col-form-label">購買價錢</label>
              <div class="col-sm-10">
                <input type="text" class="form-control" id="purchased_price" name="purchased_price" placeholder="" value="1">
                <div class="valid-feedback">正確</div>
                <div class="invalid-feedback">没有资料</div>
              </div>
            </div>

            <div class="form-group row">
              <label for="purchased_qty" class="col-sm-2 col-form-label">購買次數*</label>
              <div class="col-sm-10">
                <input type="text" class="form-control" id="purchased_qty" name="purchased_qty" placeholder="" value="1">
                <div class="valid-feedback">正確</div>
                <div class="invalid-feedback">没有资料</div>
              </div>
            </div>

             <div class="form-group row">
              <label for="available_qty" class="col-sm-2 col-form-label">可用次數*</label>
              <div class="col-sm-10">
                <input type="text" class="form-control" id="available_qty" name="available_qty" placeholder="" value="1">
                <div class="valid-feedback">正確</div>
                <div class="invalid-feedback">没有资料</div>
              </div>
            </div>



            <div class="form-group row">
              <label for="inputPassword" class="col-sm-2 col-form-label">備註</label>
              <div class="col-sm-10">
                <textarea  type="text" class="form-control" id="remark2" name="remark2" rows="4" cols="50" placeholder="輸入備註"></textarea>
              </div>
            </div>

            <?php

} //if($pagemethod=="add"){?>



            <!-- load old services record -->
             <?php
if ($pagemethod == "edit") {
	?>
            <div style="" class="menubar2">
              <a href="/at-cms/brserviceuseradmin/add/<?php echo $customerdetails->id; ?>"><i class="fas fa-plus" style=" display: inline-block;
    border-radius: 10px;
    box-shadow: 0px 0px 2px #888;
    color: #33aaae;
    padding: 2px 2px;"></i>新增購買記錄</a>
            </div>
            <?php
} //if($pagemethod=="edit"){
?>
            <br>
            <br>
            <?php
//var_dump($customerService);
?>
            <?php
if ($pagemethod == "edit" || $pagemethod == "details") {
	?>
            <h5>購買記錄</h5>
            <!-- service table -->
              <table id="book-table" class="display responsive wrap table table-bordered table-striped table-hover  " width="100%">

            <!-- <table id="book-table" class="display responsive nowrap"  width="100%"> -->
            <thead>
            <tr><td>購買日期</td><td>服務種類</td><td>服務項目</td><td>已購買次數</td><td>剩餘次數</td><td style="width:10%;">備註</td><td>編輯</td></tr>

            </thead>
            <tbody>
            <?php
function isTimestamp($string) {
		return (1 === preg_match('~^[1-9][0-9]*$~', $string));
	}
	date_default_timezone_set('Asia/Hong_Kong');

	foreach ($customerService as $servicerow) {

		$purchaseTimeStamp = $servicerow['purchased_date'];
		// $timestamp = 1465298940;
		$datetimeFormat = 'Y-m-d';
		$outPutDate = "";
		// $date = new \DateTime();
		// If you must have use time zones
		// $date = new \DateTime('now', new \DateTimeZone('Europe/Helsinki'));
		if (isTimestamp($purchaseTimeStamp) == false) {
			$outPutDate = $purchaseTimeStamp;
		} else {
			$outPutDate = date('Y-m-d', $purchaseTimeStamp);
		}
		// $date->setTimestamp($timestamp);
		// echo $date->format($datetimeFormat);
		?>
               <!-- <tr><td><?php echo $servicerow->purchased_date; ?></td> -->
               <tr><td><?php echo $outPutDate; ?></td>
                <td><?php
if ($servicerow['category_id'] == 1) {
			echo "FT - 試做療程";
		}
		if ($servicerow['category_id'] == 2) {
			echo "T - 療程";
		}

		?></td>
                <td><?php echo $servicerow['serviceName']; ?></td>
                <td><?php echo $servicerow['purchased_qty']; ?></td>
                <td><?php echo $servicerow['leaving_qty']; ?></td>
                <!-- <td><?php echo $servicerow->id ?></td> -->
                <td><?php echo $servicerow['remark']; ?></td>
                <td>
                  <?php if ($pagemethod == "edit") {
			?>

                  <a href="/at-cms/brserviceuseradmin/edit/<?php echo $servicerow['id']; ?>">編輯</a>
                  <?php
} //if($pagemethod=="edit"){
		?>
                </td>
               </tr>
            <?php
} //foreach ($customerService as $servicerow) {

	?>
            </tbody>
            </table>
            <!-- end service table -->
            <?php
} //if($pagemethod=="edit" || $pagemethod=="detail"){
?>
            <!-- end load old services record -->

            <!-- customer point -->
             <?php
if ($pagemethod == "edit" || $pagemethod == "details") {
	?>

            <br>

            <h5>客戶積分: <?php if (empty($customerpoint)) {
		echo "沒有積分";
	} else {
		echo $customerpoint;
	}
	?></h5>


            <div style="" class="menubar2">
               <?php
if ($pagemethod == "edit") {
		?>
              <a href="/at-cms/brcustomerpointadmin/add/<?php echo $customerdetails->id; ?>"><i class="fas fa-plus" style=" display: inline-block;
    border-radius: 10px;
    box-shadow: 0px 0px 2px #888;
    color: #33aaae;
    padding: 2px 2px;"></i>新增積分記錄</a>
                <?php

	} //if($pagemethod=="edit"){
	?>
            </div>

            <h5>積分記錄</h5>

            <table id="custpoint-table" class="display responsive wrap table table-bordered table-striped table-hover  " width="100%">

            <!-- <table id="book-table" class="display responsive nowrap"  width="100%"> -->
            <thead>
            <tr><td>購買日期</td><td>積分</td><td>購買價錢</td><td>備註</td><td>編輯</td></tr>

            </thead>
            <?php
foreach ($customerpoint_history as $customerpoint_row) {
		?>
                <tr>
                <td><?php echo $customerpoint_row->purchased_date; ?></td>
                <td><?php echo $customerpoint_row->point; ?></td>
                <td><?php echo $customerpoint_row->purchased_price; ?></td>
                <!-- <td><?php echo $customerpoint_row->id ?></td> -->
                <td><?php echo $customerpoint_row->remark; ?></td>
                <td>
                  <?php if ($pagemethod == "edit") {
			?>

                  <a href="/at-cms/brcustomerpointadmin/edit/<?php echo $customerpoint_row->id; ?>">編輯</a>
                  <?php
} //if($pagemethod=="edit"){
		?>
                </td>
                </tr>
             <?php
} //foreach ($customerService as $servicerow) {

	?>
             </tbody>
            </table>

            <?php
} // if($pagemethod=="edit" || $pagemethod=="details"){
?>
            <!-- end customer point -->

            <!-- customer used point -->

            <?php
if ($pagemethod == "edit" || $pagemethod == "details") {
	?>
            <br>
            <h5>使用積分記錄</h5>
              <table id="custusedpoint-table" class="display responsive wrap table table-bordered table-striped table-hover  " width="100%">

            <!-- <table id="book-table" class="display responsive nowrap"  width="100%"> -->
            <thead>
            <tr><td rowspan="2"></td><td rowspan="2">使用日期</td><td rowspan="2">預約日期</td><td rowspan="2">服務編號</td><td rowspan="2">服務名稱</td><td rowspan="2">發票號碼</td><td rowspan="2">使用積分</td><td>餘數</td><td rowspan="2">備註</td><td rowspan="2">編輯</td></tr>
              <tr><td><?php echo round($customertotalpoint); ?></td></tr>
            </thead>

            <?php
$count = 1;
	$leaving_point = $customertotalpoint;
	foreach ($customerusedpoint_history as $customerusedpoint_row) {
		?>
              <tr>
                <td><?php echo $count; ?></td>
                <td><?php echo $customerusedpoint_row['used_date']; ?></td>
                <td><?php echo $customerusedpoint_row['booking_date']; ?></td>

                <!-- <td><?php echo $customerusedpoint_row->id ?></td> -->
                <td><?php echo $customerusedpoint_row['item_code']; ?></td>
                <td><?php echo $customerusedpoint_row['item_name']; ?></td>
                <td><?php echo $customerusedpoint_row['issued_name']; ?></td>
                <td>-<?php echo round($customerusedpoint_row['point']); ?></td>
                <td>&nbsp;&nbsp;<?php
$leaving_point = $leaving_point - $customerusedpoint_row['point'];
		echo $leaving_point;
		?></td>
                <td><?php echo $customerusedpoint_row['remark']; ?></td>
                <td>
                   <?php
// if($this->session->userdata('brcustomerpoint_edit')==true && $extraPasscheck==true){
		//if($this->session->userdata('brcustomerpoint_edit')==true ){
		?>
             <?php if ($pagemethod == "edit") {
			?>
                          <a href="/at-cms/brcustomerusedpointadmin/edit/<?php echo $customerusedpoint_row['id']; ?>/<?php echo $customerusedpoint_row['user_id']; ?>">編輯</a>
                        <?php
} //if($pagemethod=="edit"){
		?>
                         <?php
//}//if($this->session->userdata('brinvoice_edit')==true && $extraPasscheck==true){
		?>
                </td>
                </tr>
             <?php
$count = $count + 1;
	} //foreach ($customerService as $servicerow) {

	?>
             </tbody>
            </table>



              <?php
} //if($pagemethod=="edit" || $pagemethod=="details"){

?>
            <!-- end customer used point -->


            <!-- booking data -->

            <?php

//var_dump($customer_booking);

?>
             <?php
if ($pagemethod == "edit" || $pagemethod == "details") {
	?>
            <br>
            <h5>預約記錄</h5>
            <table id="bookinglist-table" class="display responsive wrap table table-bordered table-striped table-hover  " width="100%">
            <thead>
            <tr><td>ID</td><td>預約日期</td><td>美容師1</td><td>美容師2</td><td>服務內容</td><td>店鋪</td><td>房間</td><td>失<br>約</td><td>客<br>人<br>取<br>消</td><td>確<br>定</td><td>報<br>到</td><td>報<br>走</td><td>備註</td><!-- <td>詳情</td> --></tr>

            </thead>
            <tbody>
             <?php

	foreach ($customer_booking as $bookingrow) {

		?>
             <tr>
                <td>
                    <?php
// var_dump($bookingrow);
		echo $bookingrow['id']; ?>
                </td>
                <td>
                    <?php

		// echo $bookingrow['starttime']->format('Y-m-d H:i:s');

		$bookingdatetime = $bookingrow['starttime']->format('Y-m-d H:i:s');
		$new_date = date("Y-m-d", strtotime($bookingdatetime));
		echo $new_date;
		$start_time = date("H:i", strtotime($bookingdatetime));
		echo "<br>";
		echo $start_time;
		?>
                    <?php echo ' - '; ?>
                    <?php
// echo $bookingrow['endtime']->format('Y-m-d H:i:s');
		$bookingendtime = $bookingrow['endtime']->format('Y-m-d H:i:s');
		$end_time = date("H:i", strtotime($bookingendtime));
		echo $end_time;
		?>


                </td>
                <td>
                    <?php if (!empty($bookingrow['pic_1name'])) {echo $bookingrow['pic_1name'];}?>
                </td>
                <td>
                    <?php if (!empty($bookingrow['pic_2name'])) {echo $bookingrow['pic_2name'];}?>
                </td>
                <!-- <td>
                    <?php echo $bookingrow['roomname']; ?>
                </td> -->
                <td>
                    <?php echo $bookingrow['bookingitemsname']; ?>
                </td>

                <td>
                    <?php echo $bookingrow['shopname']; ?>
                </td>
                <td>
                    <?php echo $bookingrow['roomname']; ?>
                </td>
<!--                 <td>
                    <?php echo date('Y-m-d', $bookingrow['create_time']); ?>

                </td> -->
                <td>
                     <?php
if ($bookingrow['missedReservation'] == 0) {
			echo '<i class="fas fa-times"></i>';
		}
		?>

                     <?php
if ($bookingrow['missedReservation'] == 1) {
			echo '<i class="fas fa-check"></i>';
		}
		?>

                </td>
                <td>
                     <?php
if ($bookingrow['isCancel'] == 0) {
			echo '<i class="fas fa-times"></i>';
		}
		?>

                     <?php
if ($bookingrow['isCancel'] == 1) {
			echo '<i class="fas fa-check"></i>';
		}
		?>

                </td>
                <td>
                     <?php
if ($bookingrow['isConfirm'] == 0) {
			echo '<i class="fas fa-times"></i>';
		}
		?>

                     <?php
if ($bookingrow['isConfirm'] == 1) {
			echo '<i class="fas fa-check"></i>';
		}
		?>

                </td>
                <td>
                     <?php
if ($bookingrow['isArrive'] == 0) {
			echo '<i class="fas fa-times"></i>';
		}
		?>

                     <?php
if ($bookingrow['isArrive'] == 1) {
			echo '<i class="fas fa-check"></i>';
		}
		?>

                </td>
                <td>
                     <?php
// if(empty($bookingrow['out_time'])){

		if ($bookingrow['isReturn'] == 0) {
			echo '<i class="fas fa-times"></i>';
		}
		// }
		?>

                     <?php
// if(!empty($bookingrow['out_time'])){
		if ($bookingrow['isReturn'] == 1) {
			echo '<i class="fas fa-check"></i>';
		}
		?>

                </td>
                <td>
                    <?php echo $bookingrow['remark']; ?>
                </td>
                <!-- <td>
                <?php
if ($this->session->userdata('brbooking_access') == true || $this->session->userdata('brbooking_edit') == true || $this->session->userdata('brbooking_delete') == true) {
			?>
                    <a
                      href="#" onclick="showbrbookingdetail(<?php echo $bookingrow['id']; ?>);"
                      >詳情</a>
                 <?php
} //if($this->session->userdata('brbooking_access')==true){
		?>
                 </td> -->
                </tr>
          <?php

	} //foreach ($customer_booking as $bookingrow) {

	?>

            </tbody>
            </table>
            <?php
} //if($pagemethod=="edit" || $pagemethod=="details"){
?>
            <!-- end booking data -->

             <div class="form-group row">
                      <div class="col-sm-12 text-center">
                      <span id="newmsg" class="text-center"></span>
                      </div>
            </div>

            <div class="form-group row mt-4">
                        <div class="col-sm-12 text-center">
                        <?php
if ($pagemethod == "add") {?>
                          <button type="button" class="btn  px-5  custombutton mr-5" id="btnReset">重設</button>
                        <button type="button" class="btn  px-5  custombutton" id="btnSubmit">確定</button>
                        <?php
} //if($pagemethod=="add"){?>
                        <?php
if ($pagemethod == "edit") {
	?>

                           <input type="hidden" class="form-control" id="id" name="id" placeholder="" value="<?php echo
	$customerdetails->id;
	?>">
                          <button type="button" class="btn  px-5  custombutton mr-5" id="btnResetUpdate" onClick="window.location.reload();">重設</button>
                          <button type="button" class="btn  px-5  custombutton" id="btnUpdate">更改</button>
                        <?php
} //if($pagemethod=="edit"){?>

                        <?php
if ($pagemethod == "details") {?>


                        <?php
} //if($pagemethod=="edit"){?>
                        </div>
            </div>

          </form>
          <!-- end input form -->

            <!-- end add button -->


        </div>
    </div>

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

                    );

                $('#bookinglist-table').DataTable( {
                    "order": [[ 1, "desc" ]],
                     dom: 'Bfrtip',
                    buttons: [
                        // 'colvis'
                    ]
                }

                    );

                $('#custpoint-table').DataTable( {
                    "order": [[ 1, "desc" ]],
                     dom: 'Bfrtip',
                    buttons: [
                        // 'colvis'
                    ]
                }

                    );

                $('#custusedpoint-table').DataTable( {
                    "order": [[ 0, "desc" ]],
                     dom: 'Bfrtip',
                    buttons: [
                        // 'colvis'
                    ]
                }

                    );
            });
      </script>

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