<!DOCTYPE html>
<html>

<head>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<?php   include('include/common.php');?>  

        <link rel="stylesheet" type="text/css" href="https://cdn.datatables.net/v/dt/dt-1.10.13/datatables.min.css"/>

       
<!--         <link rel="stylesheet" type="text/css" href=" https://cdn.datatables.net/1.10.21/css/jquery.dataTables.min.css"/>   -->  
        <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>





                <script language="JavaScript">
                function checkall(source) {
                   
                checkboxes = document.getElementsByName('admincheck');
                    for(var i=0, n=checkboxes.length;i<n;i++) {
                        checkboxes[i].checked = source.checked;
                    }
                }
                function checkalllevel(source){
  
                    alert("clicked");
                    alert(source.className);
                    alert(source.data('clickid'));
                }
                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/servicesend/status',
                      'AJAX_SUCCESS' :'SUCCESS',
                      'AJAX_FAILURE' :'FAILURE'
                     };
                     var postUrl= GlobalVariables.baseUrl +'/api/v1/servicesend/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
                }
    //             $('.togglenewclass').change(function() {
    //                  alert("clicked");
    //                         // $('#console-event').html('Toggle: ' + $(this).prop('checked'))
    //             });


    //             function notify(){
    //                 alert("1");
    //                  var $this = $(this);
    //                 $.post('YOUR/API/URL', function(response){
    //         //...
    //                 }).fail(function(response){
    //                 $this.off('change'); //先關閉Change事件。
    //                 $this.bootstrapToggle('off');
    //                 $this.on('change', notify);  //執行完後打開Change 事件，並執行handler
    //                     });
    //             }
    // ​
    // $('.togglenewclass').bootstrapToggle({
    //     on:'開啟', 
    //     off:'關閉',
    //     size:'small', 
    //     onstyle:'success'
    // }).change(notify);

                  //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/fileend/delete',
                  'AJAX_SUCCESS' :'SUCCESS',
                  'AJAX_FAILURE' :'FAILURE'
            };

            event.preventDefault();
            var postUrl= GlobalVariables.baseUrl +'/api/v1/servicesend/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  

            

            //end GlobelSearch


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

            


              //GlobelSearch
            function GlobelSearch(_invalue) {
                 var list, i, switching, b, shouldSwitch;
                list = document.getElementById("dtirectory_list");
                switching = true;
                /*Make a loop that will continue until
                no switching has been done:*/
                // while (switching) {
                  // alert('insideswitch');
                  //start by saying: no switching is done:
                  switching = false;
                  b = list.getElementsByClassName("highlight_full");

                  //Loop through all list-items:

                  for (i = 0; i < b.length ; i++) {
                    // alert('highlight_full');
                    //start by saying there should be no switching:
                    shouldSwitch = false;
                    /*check if the next item should
                    switch place with the current item:*/
                    // alert(b[i]);

                    var displaymethod='none';

                    if(_invalue!=""){
                      if (b[i].getAttribute("file-code").toLowerCase().indexOf(_invalue.toLowerCase()) >= 0){
                      // if(b[i].getAttribute("file-name")==_invalue){
                        // b[i].style.display='block';
                        displaymethod='block';
                      }
                      if (b[i].getAttribute("file-name").toLowerCase().indexOf(_invalue.toLowerCase()) >= 0){
                      // if(b[i].getAttribute("file-name")==_invalue){
                        // b[i].style.display='block';
                        displaymethod='block';
                      }
                      // else{
                         
                      //    b[i].style.display='none';
                      // }
                    }//if(_invalue!=""){
                    else{
                      displaymethod='block';
                    }
                    b[i].style.display=displaymethod;
                  }//for (i = 0; i < b.length - 1; i++) {
                  
                // }
            }//function GlobelSearch(_invalue) {

            //end GlobelSearch

                </script>
</head>

<body>

    <!-- admin javascript -->
    
    


    <?php   include('include/header.php');?>
    <div class="wrapper" >
        
        <?php   include('include/sidebar.php');?>
        <!-- Page Content  -->

            <!-- 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:#7d4495" class="text-center py-2"><i class="fas fa-plus mr-2" style="color:#7d4495"></i>删除服務</h5>
                     <form>

                   
                    <div class="form-group row">
                        <label for="inputRePassword" class="col-sm-12 "><span style="color:#7d4495;" >確定删除</span><span id="deletenum" style="color:#7d4495;"></span><span style="color:#7d4495;" >個服務?</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 -->   



        <div id="content" style="background-color: #ffffff;">


            <!-- title     -->

            <div class="title">價錢列表</div>    
            <!-- end title -->

            <!-- add button -->

            
            
            <div class="row">
              
            <!-- left column -->
            <div class="col-12 col-lg-6">
            <div class="row">
              <div class="col-12">
                <div class="title">
                  試做療程服務
                </div>
               <form> 
                <span class="">
                <div class="input-group   mt-1 mr-3 ml-auto  " style="float: right;">
                <input type="search" placeholder="  輸入關鍵字搜尋" aria-describedby="button-addon5" class="form-control " style="max-width:80vw;" onkeyup="GlobelSearch(this.value)">
                <div class="input-group-append">
                  <button id="button-addon5" type="submit" class="btn btn-outline-secondary "><svg class="svg-inline--fa fa-search fa-w-16" style="color: #7d4495;" aria-hidden="true" data-prefix="fa" data-icon="search" role="img" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512" data-fa-i2svg=""><path fill="currentColor" d="M505 442.7L405.3 343c-4.5-4.5-10.6-7-17-7H372c27.6-35.3 44-79.7 44-128C416 93.1 322.9 0 208 0S0 93.1 0 208s93.1 208 208 208c48.3 0 92.7-16.4 128-44v16.3c0 6.4 2.5 12.5 7 17l99.7 99.7c9.4 9.4 24.6 9.4 33.9 0l28.3-28.3c9.4-9.4 9.4-24.6.1-34zM208 336c-70.7 0-128-57.2-128-128 0-70.7 57.2-128 128-128 70.7 0 128 57.2 128 128 0 70.7-57.2 128-128 128z"></path></svg><!-- <i class="fa fa-search" style="color:#7d4495"></i> --></button>
                </div>
                </div>
            </span>
                </form>
              </div>
              <div class="col-12">
                <div class="row">
                  <div class="col-2">
                    服務編號
                  </div>
                  <div class="col-6">
                    服務項目
                  </div>
                  <div class="col-2">
                    試做價
                  </div>
                  <div class="col-2">
                    時間
                  </div>
                </div>
                <div class="row" id="dtirectory_list">
                <?php  foreach ($ftservices as $ftservicesrow) {

            ?>  


                  <div class="col-12 highlight_full"   file-code="<?php echo $ftservicesrow->code;?>" file-name="<?php echo $ftservicesrow->name;?>" style="padding-right: 0px;padding-left: 0px;" >
                    <div class="row">
                      <div class="col-2">
                        <?php echo $ftservicesrow->code;?>
                      </div>
                      <div class="col-6">
                        <?php echo $ftservicesrow->name;?>
                      </div>
                      <div class="col-2">
                        <?php echo (int)round($ftservicesrow->price);?>
                      </div>
                      <div class="col-2">
                        <?php echo (int)round($ftservicesrow->time);?>
                      
                      </div>

                    </div>
                 
              


                    </div>
             <?php  
                  }//foreach ($ftservices as $ftservicesrow) {
              
            ?>  
                </div>
              </div>

            


            </div>


             </div>
            <!-- end left column -->

            <!-- right column -->
            <div class="col-12 col-lg-6">
            <div class="row">
              <div class="col-12">
                <div class="title">
                  療程服務
                </div>
               <form> 
                <span class="d-none d-md-block">
                <div class="input-group   mt-1 mr-3 ml-auto  " style="float: right;">
                <input type="search" placeholder="  輸入關鍵字搜尋" aria-describedby="button-addon5" class="form-control " style="max-width:80vw;" onkeyup="GlobelSearch2(this.value)">
                <div class="input-group-append">
                  <button id="button-addon5" type="submit" class="btn btn-outline-secondary customsearch"><svg class="svg-inline--fa fa-search fa-w-16" style="color: #7d4495;" aria-hidden="true" data-prefix="fa" data-icon="search" role="img" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512" data-fa-i2svg=""><path fill="currentColor" d="M505 442.7L405.3 343c-4.5-4.5-10.6-7-17-7H372c27.6-35.3 44-79.7 44-128C416 93.1 322.9 0 208 0S0 93.1 0 208s93.1 208 208 208c48.3 0 92.7-16.4 128-44v16.3c0 6.4 2.5 12.5 7 17l99.7 99.7c9.4 9.4 24.6 9.4 33.9 0l28.3-28.3c9.4-9.4 9.4-24.6.1-34zM208 336c-70.7 0-128-57.2-128-128 0-70.7 57.2-128 128-128 70.7 0 128 57.2 128 128 0 70.7-57.2 128-128 128z"></path></svg><!-- <i class="fa fa-search" style="color:#7d4495"></i> --></button>
                </div>
                </div>
            </span>
                </form>
              </div>
              <div class="col-12">
                <div class="row">
                  <div class="col-2">
                    服務編號
                  </div>
                  <div class="col-6">
                    服務項目
                  </div>
                  <div class="col-2">
                    試做價
                  </div>
                  <div class="col-2">
                    時間
                  </div>
                </div>
                <div class="row" id="dtirectory_list">
                <?php  foreach ($tservices as $tservicesrow) {

            ?>  


                  <div class="col-12 highlight_full"   file-code="<?php echo $tservicesrow->code;?>" file-name="<?php echo $tservicesrow->name;?>" style="padding-right: 0px;padding-left: 0px;" >
                    <div class="row">
                      <div class="col-2">
                        <?php echo $tservicesrow->code;?>
                      </div>
                      <div class="col-6">
                        <?php echo $tservicesrow->name;?>
                      </div>
                      <div class="col-2">
                        <?php echo $tservicesrow->price;?>
                      </div>
                      <div class="col-2">
                        <?php echo $tservicesrow->time;?>
                      </div>

                    </div>
                 
              


                    </div>
             <?php  
                  }//foreach ($ftservices as $ftservicesrow) {
              
            ?>  
                </div>
              </div>

            


            </div>


             </div>
            <!-- end right column -->

           
          </div>


            
            <!-- end add button -->

            <!-- sample table -->
              
            <!-- end sample table -->

            <!-- test datatable -->
            <!-- <table id="book-table" class="table table-bordered table-striped table-hover "> -->
            
            

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