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

$disp = '';
$pagetitle = 'Edit Project';

if(!isset($_REQUEST['id']))
{
$disp .= 'Please select a project first';
include('../template.php');
exit;
}

$project = $_REQUEST['id'];

$q = "select * from project where id='$project'";
$res = mysqli_query($dbcon,$q) or die(mysqli_error($dbcon));

if(mysqli_num_rows($res)<1)
{
$disp .= 'No project found with this id';
include('../template.php');
exit;
}

$row = mysqli_fetch_array($res);

if(isset($_REQUEST['sm']))
$disp .= '<div class="smdiv">'.$_REQUEST['sm'].'</div>';
else
$disp .= '<div class="smdiv">Edit Project Details</div>';


 
$disp .= '<form method="post" action="editproject2.php" id="editprojectform" enctype="multipart/form-data">
<input type="hidden" name="project" value="'.$project.'">
<div class="row">
                <div class="col-md-12">
                    <!-- Advanced Tables -->
                    <div class="panel panel-default">
                        <div class="panel-heading">
                             Make changes and click submit
                        </div>
                        <div class="panel-body">
                            <div class="table-responsive">
                                <table class="table table-striped table-bordered table-hover" id="dataTables-example">
                                    <tbody>
									 <tr><th><img src="'.$row['photo'].'" style="width:100px;height:100px;"></th><td> Change Picture: <br><input type="file" name="photo"></td></tr>
                                        <tr><th>Project Name *</th><td><input type="text" name="project_name" value="'.$row['project_name'].'" data-validation="required"></td></tr>
										<tr><th>Number of Floors :</th><td><input type="text" name="no_floors" value="'.$row['no_floors'].'" ></td></tr>
										<tr><th>Number of Flats:</th><td><input type="text" name="no_flats" value="'.$row['no_flats'].'"></td></tr>
										<tr><th>Start Date *: </th><td><input type="text" name="start_date" id="datep1" readonly value="'.$row['start_date'].'"  data-validation="required"></td></tr>
										<tr><th>Project Address: </th><td><textarea name="project_address" row="3" >'.$row['project_address'].'</textarea></td></tr>
											<th>Project Details</th><td><input type="text" name="project_details" value="'.$row['project_details'].'"></td></tr>
                                            <th>Flat Numbers (comma separated)</th><td><input type="text" name="flats" value="'.$row['flats'].'"></td></tr>
											<tr><th>Type of Project *</th><td><select name="type" data-validation="required"><option value=""></option>';

											
if($row['type']=='ct')
$disp .= '<option value="ct" selected>Construction</option><option value="mt">Maintenance</option>';
elseif($row['case_type']=='mt')
$disp .= '<option value="mt" selected>Maintenance</option><option value="ct">Construction</option>';

			
$disp .= '</select></td></tr>
<tr><th>Click to Confirm Changes</th><td><button type="submit" name="editprojectsubmit" class="btn-success">Submit Changes</button></td></tr>
																						
                                       
                                    
                                    </tbody>
                                </table>
                            </div>
                            
                        </div>
                    </div>
                    <!--End Advanced Tables -->
                </div>
            </div>
			</form>';
			

		include('../header.php');
		include('../template.php');
			?>
		
    <!-- <script>
            $(document).ready(function () {
                $('#dataTables-example').dataTable();
            });
    </script>  -->
    <script>
                                    $.validate({
  form : '#editprojectform'
});
</script>

			
               