<!DOCTYPE html>
<html>

<head>

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


 <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" />
<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($('#username').val().length !== 0){
          //   $("#username").addClass(" is-valid ");
          //   $("#username").removeClass(" is-invalid ");
          // }
          // else{
          //   if(forcusitem.length===0){
          //      forcusitem="#username";
          //   }
          //   passCheck=false;
          //   $("#username").addClass(" is-invalid ");
          //  $("#username").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($('#confirmpassword').val().length !== 0 || ($('#confirmpassword').val()!==$('#password').val())){
          //   $("#confirmpassword").addClass(" is-valid ");
          //   $("#confirmpassword").removeClass(" is-invalid ");
          // }
          // else{
          //   if(forcusitem.length===0){
          //      forcusitem="#confirmpassword";
          //   }
          //   passCheck=false;
          //   $("#confirmpassword").addClass(" is-invalid ");
          //  $("#confirmpassword").removeClass(" is-valid ");
          // }

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


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


          //  if($('#incomeId').find(":selected").val().length !== 0){
          //   $("#incomeId").addClass(" is-valid ");
          //   $("#incomeId").removeClass(" is-invalid ");
          // }
          // else{
          //   if(forcusitem.length===0){
          //      forcusitem="#incomeId";
          //   }
          //   passCheck=false;
          //   $("#incomeId").addClass(" is-invalid ");
          //  $("#incomeId").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($('#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==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/brshopend/add';
            var postUrl= '<?php echo base_url(); ?>' +'/api/v1/bremployeewageend/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

            // }


            // var postData ={
            //     'username':$('#username').val(),
            //     'password':$('#password').val(),
            //     'chi_name':$('#chi_name').val(),
            //     'eng_firstname':$('#eng_firstname').val(),
            //     'eng_lastname':$('#eng_lastname').val(),
            //     'roleId':$('#roleId').val(),
            //     'shopid':$('#formshopid').val(),
            //     'incomeId':$('#incomeId').val(),
            //     'salary':$('#salary').val(),
            //     'gender':$('#gender').val(),
            //     'remark':$('#remark').val()
            //     // 'inputadminname':$('#inputadminname').val(),

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

            $checkedaverage_shop_bonus=0;
            if($('#average_shop_bonus').is(':checked')){
                $checkedaverage_shop_bonus=1;
            }
            else
            {
              $checkedaverage_shop_bonus=0;
            }


            var formData = new FormData();

        // formData.append('file_url', jQuery('form#upload-file').find('input#file-url')[0].files[0]);

        formData.append('username', jQuery('form#upload-file').find('#username').val());
        formData.append('password', jQuery('form#upload-file').find('#password').val());
        formData.append('chi_name', jQuery('form#upload-file').find('#chi_name').val());
        formData.append('eng_firstname', jQuery('form#upload-file').find('#eng_firstname').val());
        formData.append('eng_lastname', jQuery('form#upload-file').find('#eng_lastname').val());
        formData.append('roleId', jQuery('form#upload-file').find('#roleId').val());
        formData.append('shopid', jQuery('form#upload-file').find('#formshopid').val());
        formData.append('incomeId', jQuery('form#upload-file').find('#incomeId').val());
        formData.append('salary', jQuery('form#upload-file').find('#salary').val());
        formData.append('gender', jQuery('form#upload-file').find('#gender').val());
        formData.append('remark', jQuery('form#upload-file').find('#remark').val());

        formData.append('dateofentry', jQuery('form#upload-file').find('#dateofentry').val());

        formData.append('second_shopid', jQuery('form#upload-file').find('#second_shopid').val());

        formData.append('sole_shop_bonus', $checkedsole_shop_bonus);
        formData.append('average_shop_bonus', $checkedaverage_shop_bonus);
        formData.append('employeegroup',jQuery('form#upload-file').find('#employeegroup').val());
             // var file = document.getElementById("input_photo").files[0];
             //  postData.append('file', file);

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

                //   processData: false, //prevent jQuery from converting your FormData into a string
                // contentType: false, //jQuery does not add a Content-Type header for you
                url: postUrl,
                 type: 'post',
            data: formData,
            cache: false,
            processData: false,
            contentType: false,
            dataType:'json',
                 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) {


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


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


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

         //    //end check two password match or not
         //  }//if($('#password').val().length !== 0){

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

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


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

           //   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= '<?php echo base_url(); ?>' +'api/v1/bremployeewageend/update';


            $checkedsole_shop_bonus=0;
            if($('#sole_shop_bonus').is(':checked')){
                $checkedsole_shop_bonus=1;
            }
            else
            {
              $checkedsole_shop_bonus=0;
            }
            // alert("sole_shop_bonus"+$checkedsole_shop_bonus);
            $checkedaverage_shop_bonus=0;
            if($('#average_shop_bonus').is(':checked')){
                $checkedaverage_shop_bonus=1;
            }
            else
            {
              $checkedaverage_shop_bonus=0;
            }


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



            //not use
            // var postData ={
            //     'username':$('#username').val(),
            //     'password':$('#password').val(),
            //     'chi_name':$('#chi_name').val(),
            //     'eng_firstname':$('#eng_firstname').val(),
            //     'eng_lastname':$('#eng_lastname').val(),
            //     'roleId':$('#roleId').val(),
            //     'shopid':$('#formshopid').val(),
            //     'incomeId':$('#incomeId').val(),
            //     'salary':$('#salary').val(),
            //     'gender':$('#gender').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(),
            //     'id':$('#id').val()

            // }

            //end not use

            var formData = new FormData();

        // formData.append('file_url', jQuery('form#upload-file').find('input#file-url')[0].files[0]);

        // formData.append('username', jQuery('form#upload-file').find('#username').val());

        // formData.append('password', jQuery('form#upload-file').find('#password').val());

        formData.append('chi_name', jQuery('form#upload-file').find('#chi_name').val());

        // formData.append('eng_firstname', jQuery('form#upload-file').find('#eng_firstname').val());

        // formData.append('eng_lastname', jQuery('form#upload-file').find('#eng_lastname').val());
        // formData.append('roleId', jQuery('form#upload-file').find('#roleId').val());
        // formData.append('shopid', jQuery('form#upload-file').find('#formshopid').val());
        // formData.append('incomeId', jQuery('form#upload-file').find('#incomeId').val());
        // formData.append('salary', jQuery('form#upload-file').find('#salary').val());
        // formData.append('gender', jQuery('form#upload-file').find('#gender').val());
        formData.append('remark', jQuery('form#upload-file').find('#remark').val());
        formData.append('id', jQuery('form#upload-file').find('#id').val());
        // formData.append('avatar', jQuery('form#upload-file').find('#avatar').val());
        // formData.append('dateofquit', jQuery('form#upload-file').find('#dateofquit').val());
        // formData.append('changepic', jQuery('form#upload-file').find('#changepic').val());

        // formData.append('dateofentry', jQuery('form#upload-file').find('#dateofentry').val());

        // formData.append('second_shopid', jQuery('form#upload-file').find('#second_shopid').val());
        formData.append('shopid', jQuery('form#upload-file').find('#formshopid').val());
        formData.append('sole_shop_bonus', $checkedsole_shop_bonus);
        formData.append('average_shop_bonus', $checkedaverage_shop_bonus);
        formData.append('employeegroup',jQuery('form#upload-file').find('#employeegroup').val());
            // alert($('#level2').val());
            $.ajax({
                 //  method: "POST",
                 //  url: postUrl,
                 //  dataType: "json",
                 // data: postData,
                 url: postUrl,
                 type: 'post',
            data: formData,
            cache: false,
            processData: false,
            contentType: false,
            dataType:'json',
                 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

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

      </script>



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

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

            <!-- add button -->
            <div class="title">
            <?php
if ($pagemethod == "add") {
	?>
            <h5>新增職員薪金級別</h5>
            <?php
}
?>
             <?php
if ($pagemethod == "edit") {
	?>
             <h5>更改職員薪金級別</h5>
            <?php
}
?>

             <?php
if ($pagemethod == "detail") {
	?>
             <h5>職員薪金級別資料</h5>
            <?php
}
?>
            </div>

          <div style="" class="menubar2  p-2">
            <a href="/at-cms/bremployeewageadmin">
                        <i class="fas fa-plus" style=" display: inline-block;
/*  border-radius: 10px;
  box-shadow: 0px 0px 2px #888;*/
  color: <?php echo MAIN_TEXT_COLOR; ?>;
  padding: 2px 2px;"></i>返回</a></div>


            <?php //echo ROUNDDIGITS;?>
            <!-- input form -->
            <form method="post" name="upload_file" id="upload-file" enctype="multipart/form-data">


<!--             <div class="form-group row">
              <label for="password" class="col-sm-2 col-form-label">登入密碼</label>
              <div class="col-sm-10">
                <input type="password" class="form-control" id="password" name="password" -->

                <?php
//if ($pagemethod == "detail") {
//echo "readonly";
//}
?>
<!--  >
                <div class="valid-feedback">正確</div>
                <div class="invalid-feedback">没有资料</div>
              </div>
            </div> -->
<!--             <div class="form-group row">
              <label for="confirmpassword" class="col-sm-2 col-form-label">確認登入密碼</label>
              <div class="col-sm-10">
                <input type="password" class="form-control" id="confirmpassword" name="confirmpassword"  -->
                <?php
//                 if ($pagemethod == "detail") {
// 	echo "readonly";
// }
?>
<!-- >
                <div class="valid-feedback">正確</div>
                <div class="invalid-feedback">没有资料</div>
              </div>
            </div> -->
<!--             <div class="form-group row">
              <label for="shopid" class="col-sm-2 col-form-label">店鋪</label>
              <div class="col-sm-10"> -->
                 <select class="select mas-select select2-offscreen form-control" name="formshopid" id="formshopid" tabindex="-1" style="width: auto;display: none;"
                 <?php if ($pagemethod == "detail" || $pagemethod == "edit") {
	echo 'disabled="disabled"';
}
?>
                 >
                  <?php
foreach ($shoplist as $shoprow) {
	?>
                <option value="<?php echo $shoprow->id; ?>"
                <?php
if ($pagemethod == "add") {
		if ($this->session->userdata('currentshop') == $shoprow->id) {
			echo "selected";
		}
	}

	if ($pagemethod == "edit" || $pagemethod == "detail") {
		if ($wagedetails->shopid == $shoprow->id) {
			echo "selected";
		}
	}

	?>
                 ><?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="chi_name" class="col-sm-2 col-form-label">中文名稱</label>
              <div class="col-sm-10">
                <input type="text" class="form-control" id="chi_name" name="chi_name"  placeholder="輸入中文名稱" value="<?php
if ($pagemethod == "edit" || $pagemethod == "detail") {
	echo $wagedetails->chi_name;
}
?>" <?php if ($pagemethod == "detail") {
	echo "readonly";
}
?>>
                <div class="valid-feedback">正確</div>
                <div class="invalid-feedback">没有资料或密碼和登入密碼不同</div>
              </div>
            </div>
             <div class="form-group row">
              <label for="shop_bonus" class="col-sm-2 col-form-label">獨佔獎金</label>
              <div class="col-sm-10">
                 <input type="checkbox" id="sole_shop_bonus" name="sole_shop_bonus" value="1"  <?php if ($pagemethod == "add") {
	echo "";
}?><?php if ($pagemethod == "edit") {
	if ($wagedetails->sole_shop_bonus == 1) {
		echo "checked";
	}
}?>>
                <div class="valid-feedback">正確</div>
                <div class="invalid-feedback">没有资料或密碼和登入密碼不同</div>
              </div>
            </div>

            <div class="form-group row">
              <label for="average_shop_bonus" class="col-sm-2 col-form-label">全店平均獎金</label>
              <div class="col-sm-10">
                 <input type="checkbox" id="average_shop_bonus" name="average_shop_bonus" value="1"  <?php if ($pagemethod == "add") {
	echo "";
}?><?php if ($pagemethod == "edit") {
	if ($wagedetails->average_shop_bonus == 1) {
		echo "checked";
	}
}?>>
                <div class="valid-feedback">正確</div>
                <div class="invalid-feedback">没有资料或密碼和登入密碼不同</div>
              </div>
            </div>

             <!-- added select emplopyeegroup -->
            <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="selectemployeegroup w-100" id="employeegroup" name="employeegroup" <?php

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

            </select>
            <script type="text/javascript">
                   $(function () {
                    // $('.selectpicker').selectpicker();
                     $('.selectemployeegroup').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 select employeegroup -->






            <!-- add wage level -->
            <?php
if ($pagemethod == "edit" || $pagemethod == "detail") {
	?>
            <div style="" class="menubar2">
              <a href="/at-cms/bremployeewageleveladmin/add/<?php echo $wagedetails->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"){
?>
<?php if ($pagemethod == "edit" || $pagemethod == "detail") {
	?>
            <br>
            <br>
             <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 style="width:10%;">備註</td><td>編輯</td></tr>

            </thead>
            <tbody>
            <?php

	foreach ($wagelevel as $wagelevelrow) {
		?>
            <tr>
              <td>
                <?php

		echo '$ ' . number_format(round($wagelevelrow->sales_amount, 0)); ?>
              </td>
              <td>
                <?php echo round($wagelevelrow->precentage, 1); ?>
              </td>
              <td>
                <?php echo round($wagelevelrow->job_pay, 0); ?>
              </td>
              <td>
              </td>
              <td>
                  <?php if ($pagemethod == "edit") {
			?>

                  <a href="/at-cms/bremployeewageleveladmin/edit/<?php echo $wagelevelrow->id; ?>">編輯</a>
                  <?php
} //if($pagemethod=="edit"){
		?>
                </td>
              </tr>
               <?php

	} //foreach ($wagelevel as $wagelevelrow) {
	?>
            </tbody>
            </table>


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

            <!-- end add wage level -->


            <div class="form-group row">
              <label for="name" 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 == "detail") {
	echo 'readonly';
}
?>
                 ><?php
if ($pagemethod == "edit" || $pagemethod == "detail") {
	echo $wagedetails->remark;
}

?></textarea>

              </div>
            </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="newmsg" class="text-center"></span>
                         </div>
            </div>

            <div class="form-group row">
                        <div class="col-sm-12 text-center">
                        <?php
if ($pagemethod == "add") {?>
                        <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
	$wagedetails->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") {
	?>

                           <input type="hidden" class="form-control" id="id" name="id" placeholder="" value="<?php echo
	$wagedetails->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" onclick="location.href='<?php
$link = "at-cms/bremployeeadmin/edit/" . $wagedetails->id;
	echo site_url($link);?>';">更改</button>
                        <?php
} //if($pagemethod=="edit"){?>

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

            <!-- end add button -->


        </div>
    </div>


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

            // password click
            bootstrapRevealPassword();

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

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

            // end password click

        });
    </script>
</body>

</html>