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

$disp = '';
$pagetitle = 'Construction Estimates';
//$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";
$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></div>';

$disp .= '<div class="container-fluid"><div class="row">

<div class="col-md-6">
<p style="margin-top:23px"><button id="showest" class="btn btn-primary">Add Cost Estimates for a Project</button></p>
<div id="addest" style="display:none;max-height:350px;overflow:scroll;"><form role="form" id="addestimate" method="post" action="estimates2.php" >
    
<table>';
while($row2 = mysqli_fetch_array($res2))
{
//$qestnow = "select * from estimates where project_id='$project' and work_type_id='".$row2['id']."'";

$disp .= '<tr><td><input type="hidden" name="work_type" value="'.$row2['id'].'">'.$row2['work_type'].'</td><td><input type="text" name="estimate['.$row2['id'].']"></td></tr>';
}
$disp .= '</table>
<p><button type="submit" name="estimatesubmit" class="btn btn-primary">Submit Estimates</button> &nbsp; <button type="reset" class="btn btn-primary">Reset</button>
</form></div>
</div>


<div class="col-md-5"><form method="post" action="viewestimates.php">
<b>Click Here to View Cost Estimates Already Entered</b><br>
<br><button type="submit" class="btn btn-warning">View Estimates</button>
</form>
</div>


</div></div>';

//$disp .='<button id="showest" class="btn btn-primary">Add Cost Estimates for a Project</button>';
   
   

?>
<script>
                                    $.validate({
  form : '#addestimate'
});
</script>

<script>
$(document).ready(function(){
$("#showest").click(function(){
$("#addest").show();
$("#showest").hide();
});
});	 
</script>                               
<?php
include('../header.php');   
include('../template.php');
	