<?php 

 
if(isset($_POST['lastrow'])){
    include("includes/dbconfig.php");
    

    $priced = DB::query("SELECT * FROM repair_jobnames");
    $personel = DB::query("SELECT id, first_name , last_name FROM personnel_details where employee_role  ='2'   "); 
    $locations = DB::query("SELECT * FROM repair_location");
    $jobtypes = DB::query("SELECT * FROM repair_jobtypes");

    $start = intval($_POST['lastrow']);
for($i =$start; $i< ($start +1); $i++){
?>
<div class="card card-primary">
<div class="card-header">
    <h6 class="card-title">#<?= $i?></h6>
</div>
<div class="card-body">
<table class='table table-bordered table-hover'>
    <tr> 
        <td> 
        <b>Item details e.g name and serial number color e.t.c</b>  <br /> 

           <input type="text" class="form-control"   id='jobdata<?= $i?>' name='jobdata<?= $i?>'  placeholder="Details about the new job" />
        </td> 
		
		 <td> 
                                                    <b>Job Memo e.g no of pairs</b><br />
										 
										 
										 
										 
										
										
										 <input type="text" class="form-control"   name="jobmemo<?= $i ?>" id="jobmemo<?= $i ?>" required placeholder="Notes about this job" />
                                               

										
                                                    </td>
		
		
		<td>


<b>What type of job</b>  <br /> 
    
    <select  class="form-control"   id="jobtype<?= $i?>" name="jobtype<?= $i?>" data-placeholder="Choose One">
            
            <?php
               
                
                foreach($jobtypes as $useemployee_role)
                {
            ?>
            <option  value="<?php echo $useemployee_role['rptid']; ?>"><?php echo $useemployee_role['rpt_name']; ?></option>
            <?php
                }
            ?>
            </select></td> <td>
        
            
    


    <b>Owner's Category</b>  <br /> 
    
    <select  class="form-control" name="owner<?= $i?>"   id = "ownercat<?= $i?>"  data-placeholder="Choose One">
            <option value="0">Choose One</option>
            <?php
                $owner = DB::query("SELECT * FROM repair_owner_category");
                
                foreach($owner as $ow)
                {
            ?>
            <option  value="<?php echo $ow['owid']; ?>"><?php echo $ow['owner']; ?></option>
            <?php
                }
            ?>
            </select>


        </td>

        
    </tr>

    <tr> 
        <td colspan='4'> 

        <label>Tasks to be performed on this job</label>
        
            <select class="select2bs4 form-control" name='specifics<?= $i?>[]'  multiple="multiple">
            
            <?php
                       
                        foreach($priced as $row)
                        {
                        
                            ?>
                            <option  value="<?php echo $row['job_id']; ?>"><?php echo $row['job_name']; ?> @<?= $row['job_amount'];?></option>
                            <?php
                    
                    }
                    ?>
            
            </select>

            <br /><br />


        </td>
    </tr>
</table>
</div>
</div>

<?php }
}


?>

 

        <script>
  $(function () {
 

    //Initialize Select2 Elements
    $('.select2bs4').select2({
      theme: 'bootstrap4'
    })

   
     
     

     

  
 
 
    $("input[data-bootstrap-switch]").each(function(){
      $(this).bootstrapSwitch('state', $(this).prop('checked'));
    })

  })
   
   
   
  // DropzoneJS Demo Code End
</script>