<?php
include('../headertop.php');
include('../datepicker.php');
include('../db.php');

$disp = '';
$pagetitle = 'Add Work Type Category';
//$disp .=' <div class="col-md-6">';

$q = "select * from work_type order by work_type";
$res = mysqli_query($dbcon,$q) or die(mysqli_error($dbcon));

if(isset($_REQUEST['sm']))
$disp .= '<div class="smdiv">'.$_REQUEST['sm'].'</div>';
else
$disp .= '<div class="smdiv">Add Work Category</div>';

$disp .='
<div class="row"><div class="col-md-12">
<h3>Enter in Text box or Upload a text file</h3></div></div>

                                    <div class="row">
                                <div class="col-md-6">
								<form role="form" id="addworktype" method="post" action="addworktype3.php" >
                                    
                                    
                                        <div class="form-group">
                                            <label>Work Type *</label>
                                            <input type="text" name="work_type" data-validation="required" class="form-control" />
                                                                                  </div>
                                      				
										<button type="submit" class="btn btn-primary" name="addworktypesubmit">Submit Button</button></form>					  
											  </div>
										
										<div class="col-md-6">
										<form role="form" id="addworktype2" method="post" action="addworktype2.php" enctype="multipart/form-data">
										 <div class="form-group">
                                            <label>Work Type Text File (One Category per line in text file) *</label>
                                            <input type="file" name="uploadedfile" data-validation="required" class="form-control" />
                                                                                  </div>
										
										<button type="submit" class="btn btn-primary" name="addworktype2submit">Submit Button</button>
										</form>
										</div>
										
                                        </div>
										
							<div class="row">
							<div class="col-md-3"></div> <div class="col-md-9"><h3>Edit/Delete Work Type Entries</h3><form method="post" action="editworktype2.php">';
while($row = mysqli_fetch_array($res))
{					
$wname = "work_type[".$row['id']."]";
$disp .= '<input type="text" name="'.$wname.'" value="'.$row['work_type'].'" style="width:60%;padding:4px;">&nbsp;&nbsp;<a onclick="return confirm(\'Are you sure you want to delete this entry?\')" class="btn btn-warning" href="deleteworktype.php?id='.$row['id'].'" style="margin-bottom:3px">Delete</a><br>';
}

$disp .= '<button class="btn-primary" type="submit">Save All Work Category Changes</button></form></div>			
                                    </div></div>';
									
									include('../template.php');
									include('../header.php');
                                    ?>
                                    <script>
                                    $.validate({
  form : '#addworktype,#addworktype2'
});
</script>
                                      