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

$disp = '';
$pagetitle = 'Construction Expense Entries';
//$disp .=' <div class="col-md-6">';

/*
$q = "select * from project where type='ct'";
$res = mysqli_query($dbcon,$q) or die(mysqli_error($dbcon,$q));
if(mysqli_num_rows($res)<1)
{
$disp .= 'No projects. First create a project';
include('../template.php');
exit;
}
*/

$q2 = "select * from work_type order by work_type";
$res2 = mysqli_query($dbcon,$q2) or die(mysqli_error($dbcon,$q));
if(mysqli_num_rows($res2)<1)
{
$disp .= 'No Work Type Categories Defined. ';
include('../template.php');
exit;
}

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

$disp .='<form role="form" id="addexpense" method="post" action="addexpense2.php" enctype="multipart/form-data" >
                                    <div class="row">
                                <div class="col-md-6">
                                    <h3>Fill all required fields(*) and click Submit</h3>
                                    
                                        
                                       <div class="form-group" >
                                            <label> Date *</label>
                                           <input type="text"  class="form-control" name="date" id="datep1" readonly data-validation="required"  placeholder=""   />
                                        </div>
									   
									   <div class="form-group">
                                            <label>Work Type *</label>
                                            <select class="form-control" name="work_type" data-validation="required "  />
											<option value=""></option>';
				while($row2 = mysqli_fetch_array($res2))
	{
	$disp .= '<option value="'.$row2['id'].'">'.$row2['work_type'].'</option>';
	}	
									
											
		$disp .= '</select> </div>
		
		
		  <div class="form-group">
                                            <label>Amount *</label>
                                            <input type="text" class="form-control" name="amount" data-validation="required number"  />
                                        </div>
										
										 <div class="form-group">
                                            <label>Payment To * </label>
                                            <input type="text" class="form-control" name="name" data-validation="required" placeholder="Name of the person"></textarea>
                                        </div>
										
										 </div>
											  
											  <div class="col-md-6" style="margin-top:55px">
											  
											<div id="photo" style="margin-bottom:15px">
											
											</div>
											
											 
											  
											  <div class="form-group">
                                            <label>Particulars * </label>
                                            <textarea class="form-control" name="particulars" data-validation="required" rows="3"></textarea>
                                        </div>
											  
											 <div class="form-group">
                                            <label>Payment Method *</label>
                                            <select class="form-control" name="payment_method" data-validation="required"  />
                                            <option value=""></option>
                                            <option value="cash">Cash</option>
                                            <option value="cheque">Cheque</option>
                                            <option value="bank transfer">Bank Transfer</option>
                                            </select>
                                        </div>
											  
									<div class="form-group">
                                            <label>Payment Details (Leave blank in case of cash transactions)</label>
                                            <input type="text" class="form-control" name="payment_details" placeholder="Cheque num or bank transfer details" />
                                        </div>
										
										<div class="form-group" >
											  <label>Receipt Photo</label>
											  <input type="file" name="rcptphoto" class="form-control">
											  </div>
                                              
                                         </div>
										
										<div class="col-md-9" style="text-align:center"><button type="submit" class="btn btn-primary" name="addexpensesubmit">Submit Button</button>
                                        <button type="reset" class="btn btn-default">Reset Button</button>
										</form></div>
                                    </div>';
									
									
                                    ?>
                                    <script>
                                    $.validate({
  form : '#addexpense'
});
</script>


<script>
		$(function() {
		
			$("#project").change(function() {
				//$("#text-two").load("textdata/" + $(this).val() + ".txt");
				$("#photo").load("getphoto.php?choice=" + $("#project").val());
			});
			
			

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

<!--  <div class="form-group">
                                            <label>Floor Number </label>
                                            <select class="form-control" name="floor_no"   />
											<option value=""></option>
											<option value="Ground">Ground Floor</option>
											<option value="1">1st Floor</option>
											<option value="2">2nd Floor</option>
											<option value="3">3rd Floor</option>
											<option value="4">4th Floor</option>
											<option value="5">5th Floor</option>
											<option value="Terrace">Terrace</option>
											</select>
                                        </div>
										
										<div class="form-group">
                                            <label>Flat Number </label>
                                            <input type="text" class="form-control" name="flat_no"  />
                                        </div>
                                        
                                        
                                        		  											  
											
										<div class="form-group">
                                            <label>Comments </label>
                                            <textarea class="form-control" name="comments"  rows="3"></textarea>
                                        </div>
											 
--> 