<?php
session_start();
include '../assets/constant/config.php';

try {
  $conn = new PDO("mysql:host=$servername;dbname=$dbname", $username, $password);
  $conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
} catch (PDOException $e) {
  echo "Connection failed: " . $e->getMessage();
}
?>
<?php include('include/sidebar.php'); ?>

<?php include('include/header.php'); ?>

<!--  connect author at mdkhairnar92@gmail.com  -->

<div class="page-content-wrapper ">

  <div class="container-fluid">

    <div class="row">
      <div class="col-sm-12">
        <div class="page-title-box">
          <div class="btn-group float-right">


          </div>
          <h4 class="page-title">Add Payroll</h4>
        </div>
      </div>
      <div class="clearfix"></div>
    </div>
    <!-- end page title end breadcrumb -->
    <div class="row">
      <div class="col-lg-12">
        <div class="card">
          <div class="card-body">

            <div class="tab-content">

              <div class="tab-pane active p-3" id="home" role="tabpanel">
                <form name="myform" action="app/branch_crud.php" class="row" method="POST" enctype="multipart/form-data" onsubmit="return validation()" id="add_service">

                  <div class="form-group col-md-6">
                              <label for="id_label_multiple">Branch<span class="text-danger">*</span> </label>
                              <select class="form-control postName" id="role" aria-label="Default select example" type="text" name="branch" >
                              <option value="">Select branch</option>
                               <?php    
                                $sql1=$conn->prepare("select * from `branch` where delete_status='0' ");
                                $sql1->execute();
                                $row1=$sql1->fetchAll();
                                //print_r($row);
                                //exit;
                                foreach ($row1 as $key1) {?>
                                <option value="<?php echo $key1['branch_name'];?> ">
                                       <?php echo $key1['branch_name'];?>
                                        </option>
                                    <?php } ?>
                              </select>
                           </div>
                           <div class="form-group col-md-6">
                              <label for="id_label_multiple">Member Staff<span class="text-danger">*</span> </label>
                              <select class="form-control postName" id="role" aria-label="Default select example" type="text" name="user" >
                              <option value="">Select </option>
                               <?php    
                                $sql1=$conn->prepare("select * from `user` where delete_status='0' ");
                                $sql1->execute();
                                $row1=$sql1->fetchAll();
                                //print_r($row);
                                //exit;
                                foreach ($row1 as $key1) {?>
                                <option value="<?php echo $key1['username'];?> ">
                                       <?php echo $key1['username'];?>
                                        </option>
                                    <?php } ?>
                              </select>
                           </div>
    
    <!-- <div class="container">
    <table id="dataTable" class="table table-bordered">
        <thead>
            <tr>
               
                <th>Employee Name<input type="text" name="name" class="form-control"></th>
                <th>payroll date<input type="date" name="date" class="form-control"></th>
                
            </tr>
        </thead>
        <tbody>
            <tr>
              
                <td>admin<input type="text" name="admin[]" class="form-control"></td>
                <td> business name<input type="text" name="bname" class="form-control"></td>
                <td><button class="btn btn-success addRow" type="button">Add Row</button></td>
               
            </tr>
        </tbody>
    </table>
</div> -->
<div class="container">
    <table id="dataTable" class="table table-bordered">
        <thead>
            <tr>
                <th>Employee Name<input type="text" name="name" class="form-control"></th>
                <th>Payroll Date<input type="date" name="date" class="form-control"></th>
            </tr>
        </thead>
        <tbody>
            <tr>
                <td><input type="text" name="admin[]" class="form-control"></td>
                <td><input type="text" name="bname" class="form-control"></td>
                <td><button class="btn btn-success addRow" type="button">Add Row</button></td>
            </tr>
        </tbody>
    </table>
</div>






<div class="container">
    <table id="dataTable" class="table table-bordered">
        <thead>
            <tr>
               
                <th>description</th>
                <th> Amount</th>
                <!-- <th>Action</th> -->
            </tr>
        </thead>
        <tbody>
            <tr>

                <td>extra time<input type="text" name="extra_time[]" class="form-control"></td>
                <td>total pay<input type="text" name="total_pay" class="form-control"></td>
              <td>time in late<input type="text" name="timein_late[]" class="form-control"></td>
               <td>total deduction<input type="text" name="total_deduction" class="form-control"></td>
                <td>net pay<input type="text" name="net_pay" class="form-control"></td>
                <td><button class="btn btn-success addRow" type="button">Add Row</button></td>
               
            </tr>
        </tbody>
    </table>
</div>

<div class="col-md-12">
                    <h6 class="p-2 seo-info" style="background-color: lightgrey;">Net Pay Distribution</h6>
                  </div>

<div class="box-body">
    <div class="row">
        <div class="col-lg-12">
            <div class="card">
                <div class="card-body">
                    <div class="form-group col-md-6">
                        <label class="control-label">Payment Method</label>
                        <input type="text" name="paymentmethod">
                    </div>
                    <div class="form-group col-md-6">
                        <label class="control-label">Bank Name</label>
                        <input type="text" name="bank_name">
                    </div>
                    <div class="form-group col-md-6">
                        <label class="control-label">Account Number</label>
                        <input  type="text" name="acc_no">
                    </div>
                    <div class="form-group col-md-6">
                        <label class="control-label">Description</label>
                        <input  type="text" name="description" placeholder="Enter location">
                    </div>
                    <div class="form-group col-md-6">
                        <label class="control-label">Paid Amount</label>
                        <input type="text" name="paid_amount" placeholder="Enter amount">
                    </div>
                </div>
            </div>
        </div>

       </div>
       
                    
                    <div class="form-group col-md-6">
                                     <label class="control-label">comment</label>
                                    <textarea name="comment" class="form-control" ></textarea>
                                   </div>

              
   
    </div>
</div>

                           
         <div class="form-group col-sm-6">
                         <label class="control-label">Recurring<span class="text-danger">*</span></label>
                          <select class="form-control" name="recurring">
                        <option value="">Select </option>
                        <option value="1">Yes</option>
                        <option value="2">No</option>
                       
                        </select>
                        </div>
                
                  


                  <div class="form-group col-md-12">

                    <button class="btn btn-primary" type="submit" name="submit" onclick="addService()">Save</button>

                  </div>
                </form>
              </div>


            </div>

          </div>
        </div><!--end card-->
      </div><!--end col-->
    </div><!--end row-->
  </div> <!-- Page content Wrapper -->
</div> <!-- content -->

<?php include('include/footer.php'); ?>
<!--  Author Name: Mayuri K. 
 for any PHP, Codeignitor or Laravel website or software development contact me at mayuri.infospace@gmail.com  -->



<script type="text/javascript">
  function addService() {
    jQuery.validator.addMethod("alphanumeric", function(value, element) {
      return this.optional(element) || /^(?=.*[a-zA-Z])[a-zA-Z0-9\s!@#$%^&*()_-]+$/.test(value);
    }, "Please enter alphabet characters only");

    jQuery.validator.addMethod("lettersonly", function(value, element) {
      // Check if the value is empty
      if (value.trim() === "") {
        return false;
      }
      return /^[a-zA-Z\s]*$/.test(value);
    }, "Please enter alphabet characters only");
    $('#add_service').validate({
      rules: {
        name: {
          required: true
           
        },

        notes: {
          required: true
        },
       
       
      },
      messages: {
        name: {
          required: "Please enter a name",
          pattern: "Only alphanumeric characters and spaces are allowed"
        },

        note: {
          required: "Please enter a note ",
          pattern: "Only alphanumeric characters and spaces are allowed"
        },
        
      
      }
    });
  };
</script>