<?php
session_start();
$where 					= " WHERE 1=1 ";
$next_page_condition 	= "";
$paging ="";

if($_REQUEST['start']){
	$paging .="&start=".$_REQUEST['start'];
}
if(isset($_REQUEST["from"]) && $_REQUEST["from"] !=""){
	$_SESSION["from"] = $_REQUEST["from"];
}
if(isset($_REQUEST['id']) && $_REQUEST['id'] !=""){
	$where .= " AND id = ".$_REQUEST['id']." ";
}
###########################################  PAGING WITH PER PAGE  #####################################
$file_name		= "index"; // this is file name which is used during paging  , included at the bottom of the page
$table_name		= "job";
$paging_table_name	= $table_name;
$paging_query		= $where;
$join_query_for_paging = "SELECT * FROM $table_name  $where ";
include("paging/paging_query.inc.php");
############################################ END PAGING WITH PER PAGE  #######################################
$query = "SELECT * FROM $table_name $where ";
$rs = mysqli_query($conn,$query);
?>
<style>
.form-group .control-label{
	padding-top:0px;
}
.content{
	min-height: 0px;
}
.content-header h1{
	float:left;
	padding-bottom: 10px;
}
</style>
<section class="content-header">
  <h1 style="float:left;clear:right;">
	Job Details
  </h1>
  <button type="button" id="back" name="back" value="back"  style="float:right;margin-bottom: 15px;" class="btn btn-primary" onclick="window.location.href = '<?=$config->siteURL;?>/enquiry_management/index?page=view_enquiry_for_user'">Back</button>
</section>
<?
	$enq_row = mysqli_fetch_assoc($rs);
?>
<section class="content">
	<div class="row">
		<div class="col-xs-12">
			<!----------------------- Message ------------------------------->
			<? if(isset($_SESSION['info_message'])){ ?>
			  <div class="alert alert-info alert-dismissable">
				<button type="button" class="close" data-dismiss="alert" aria-hidden="true">&times;</button>
				<? echo $_SESSION['info_message']; unset($_SESSION['info_message']);?>
			  </div>
			  <? } ?>
			<!----------------------- End Message ------------------------------->
			<!-- general form elements -->
			<? 
				$col_width = 12;
			?>
			<div class="col-xs-<?=$col_width;?>">
              <div class="box box-primary">
                <form class="form-horizontal" method="post" name="form1" id="form1" action="index?page=add_placement&action=<? echo $form_action; ?>" onsubmit="return validateForm(this)" enctype="multipart/form-data">
                  <div class="box-body">
					<div class="form-group">
                      <label for="Company Name" class="col-sm-4 control-label">Company Name</label>
                      <div class="col-sm-8">
						<? echo $enq_row["company_name"]; ?>
                      </div>
                    </div>
					<!--<div class="form-group">
                      <label for="Sector" class="col-sm-4 control-label">Sector</label>
                      <div class="col-sm-8">
                        <?php //echo ucfirst(Keycode::getkeycodeById($enq_row["sector"]));?>
                      </div>
                    </div>-->
					<div class="form-group">
                      <label for="Industry" class="col-sm-4 control-label">Industry</label>
                      <div class="col-sm-8">
                        <?php echo ucfirst(Keycode::getkeycodeById($enq_row["client_industry"]));?>
                      </div>
                    </div>
					<div class="form-group">
					  <label for="1st Contact First Name" class="col-sm-4 control-label">1st Contact</label>
					  <div class="col-sm-8">
						<?php echo $enq_row["first_name1"]." ".$enq_row["last_name1"]; ?>
					  </div>
					</div>
					<!--<div class="form-group">
					  <label for="1st Contact Last Name" class="col-sm-4 control-label">1st Contact Last Name</label>
					  <div class="col-sm-8">
						<?php //echo $enq_row["last_name1"]; ?>
					  </div>
					</div>-->
					<div class="form-group">
					  <label for="2nd Contact First Name" class="col-sm-4 control-label">2nd Contact</label>
					  <div class="col-sm-8">
						<?php echo $enq_row["first_name2"]." ".$enq_row["last_name2"]; ?>
					  </div>
					</div>
					<!--<div class="form-group">
					  <label for="2nd Contact Last Name" class="col-sm-4 control-label">2nd Contact Last Name</label>
					  <div class="col-sm-8">
						<?php //echo $enq_row["last_name2"]; ?>
					  </div>
					</div>-->
					<div class="form-group">
					  <label for="3nd Contact First Name" class="col-sm-4 control-label">3nd Contact</label>
					  <div class="col-sm-8">
						<?php echo $enq_row["first_name3"]." ".$enq_row["last_name3"]; ?>
					  </div>
					</div>
					<!--<div class="form-group">
					  <label for="3nd Contact Last Name" class="col-sm-4 control-label">3nd Contact Last Name</label>
					  <div class="col-sm-8">
						<?php //echo $enq_row["last_name3"]; ?>
					  </div>
					</div>-->
					<div class="form-group">
					  <label for="1st Phone No." class="col-sm-4 control-label">Phone No.</label>
					  <div class="col-sm-8">
						<?php 
							if(isset($enq_row["phone_no1"]) && $enq_row["phone_no1"] !=""){
								echo $enq_row["phone_no1"]; 
							}
							if(isset($enq_row["phone_no2"]) && $enq_row["phone_no2"] !=""){
								echo " , ".$enq_row["phone_no2"]; 
							}
							if(isset($enq_row["phone_no3"]) && $enq_row["phone_no3"] !=""){
								echo " , ".$enq_row["phone_no3"]; 
							}
						?>
					  </div>
					</div>
					<!--<div class="form-group">
					  <label for="1st Phone No." class="col-sm-4 control-label">1st Phone No.</label>
					  <div class="col-sm-8">
						<?php //echo $enq_row["phone_no1"]; ?>
					  </div>
					</div>
					<div class="form-group">
					  <label for="2nd Phone No." class="col-sm-4 control-label">2nd Phone No.</label>
					  <div class="col-sm-8">
						<?php //echo $enq_row["phone_no2"]; ?>
					  </div>
					</div>
					<div class="form-group">
					  <label for="3nd Phone No." class="col-sm-4 control-label">3nd Phone No.</label>
					  <div class="col-sm-8">
						<?php //echo $enq_row["phone_no3"]; ?>
					  </div>
					</div>-->
					<div class="form-group">
					  <label for="Email" class="col-sm-4 control-label">Email / Username</label>
					  <div class="col-sm-8">
						<?php echo $enq_row["email"]; ?>
					  </div>
					</div>
					<div class="form-group">
					  <label for="Address" class="col-sm-4 control-label">Address</label>
					  <div class="col-sm-8">
						<?php 
							if(isset($enq_row["address1"]) && $enq_row["address1"] !=""){
								echo $enq_row["address1"]; 
							}
							if(isset($enq_row["address2"]) && $enq_row["address2"] !=""){
								echo " ".$enq_row["address2"]; 
							}
							if(isset($enq_row["address3"]) && $enq_row["address3"] !=""){
								echo " ".$enq_row["address3"]; 
							}
							if(isset($enq_row["city"]) && $enq_row["city"] !=""){
								echo " ".$enq_row["city"]; 
							}
							if(isset($enq_row["county"]) && $enq_row["county"] !=""){
								echo " ".$gsi->getCountyById($enq_row['county']);  
							}
							if(isset($enq_row["postcode"]) && $enq_row["postcode"] !=""){
								echo " ".$enq_row["postcode"]; 
							}
						?>
					  </div>
					</div>
					<!--<div class="form-group">
					  <label for="Address1" class="col-sm-4 control-label">Address1</label>
					  <div class="col-sm-8">
						<?php //echo $enq_row['address1'];  ?>
					  </div>
					</div>
					<div class="form-group">
					  <label for="Address2" class="col-sm-4 control-label">Address2</label>
					  <div class="col-sm-8">
						<?php //echo $enq_row['address2'];  ?>
					  </div>
					</div>
					<div class="form-group">
					  <label for="Address3" class="col-sm-4 control-label">Address3</label>
					  <div class="col-sm-8">
						<?php //echo $enq_row['address3'];  ?>
					  </div>
					</div>
					<div class="form-group">
					  <label for="City" class="col-sm-4 control-label">City</label>
					  <div class="col-sm-8">
						<?php //echo $enq_row['city'];  ?>
					  </div>
					</div>
					<div class="form-group">
					  <label for="County" class="col-sm-4 control-label">County</label>
					  <div class="col-sm-8">
						<?php 
							//if(isset($enq_row['county']) && $enq_row['county'] !=""){
								//echo $gsi->getCountyById($enq_row['county']);  
							//}
						?>
					  </div>
					</div>
                    <div class="form-group">
                      <label for="Postcode" class="col-sm-4 control-label">Postcode</label>
                      <div class="col-sm-8">
						<? //echo $enq_row["postcode"]; ?>
                      </div>
                    </div>-->
					<div class="form-group">
                      <label for="Date" class="col-sm-4 control-label">Date</label>
                      <div class="col-sm-8">
						<? echo utility::getFormatedDateReturn($enq_row["common_date"]); ?>
                      </div>
                    </div>
					<div class="form-group">
                      <label for="Work we've done for them" class="col-sm-4 control-label">Work we've done for them</label>
                      <div class="col-sm-8">
						<? echo stripslashes($enq_row["done_work"]); ?>
                      </div>
                    </div>
					<div class="form-group">
                      <label for="Consultant" class="col-sm-4 control-label">Consultant</label>
                      <div class="col-sm-8" id="introducer_div">
						<? 
							$consultant_string = "";
							$sql_for_enquiry_admin = "SELECT * FROM job_admin_mapping WHERE job_id = ".$_REQUEST['id']." ";
							$result_for_enquiry_admin = mysqli_query($conn,$sql_for_enquiry_admin);
							while($row_for_enquiry_admin = mysqli_fetch_array($result_for_enquiry_admin)){
								$consultant_string .= ucfirst(utility::getTableFieldById("admin","name","id",$row_for_enquiry_admin["admin_id"])).",";
							}
							$consultant_string = substr($consultant_string,0,-1);
							echo $consultant_string;
						?>
                      </div>
                    </div>
					<div class="form-group">
                      <label for="Prospect Source" class="col-sm-4 control-label">Prospect Source</label>
                      <div class="col-sm-8">
                        <?php echo ucfirst(Keycode::getkeycodeById($enq_row["contact_source"]));?>
                      </div>
                    </div>
					<div class="form-group">
                      <label for="Prospect Status" class="col-sm-4 control-label">Prospect Status</label>
                      <div class="col-sm-8">
                        <?php echo ucfirst(Keycode::getkeycodeById($enq_row["prospect_status"]));?>
                      </div>
                    </div>
					<!--<div class="form-group">
                      <label for="Source" class="col-sm-4 control-label">Source & Enquiry Status</label>
                      <div class="col-sm-8">
						<?php //echo ucfirst(Keycode::getkeycodeById($enq_row["source"]));?>
						<?php //echo " , ".ucfirst(Keycode::getkeycodeById($enq_row["enquiry_status"]));?>
                      </div>
                    </div>
					<div class="form-group">
                      <label for="Enquiry Status" class="col-sm-4 control-label">Enquiry Status</label>
                      <div class="col-sm-8">
                        <?php //echo ucfirst(Keycode::getkeycodeById($enq_row["enquiry_status"]));?>
                      </div>
                    </div>
					<div class="form-group">
                      <label for="Enquiry Type" class="col-sm-4 control-label">Enquiry Type</label>
                      <div class="col-sm-8">
                        <?php //echo ucfirst($gsi->getJobTypeById($enq_row["enquiry_type"]));?>
                      </div>
                    </div>-->
					<?
						$display = ($enq_row["enquiry_type"] == 1) ? "display:block" : "display:none";
					?>
					<div id="fixed_packages_div" style="<?=$display;?>" class="common_class">
						<div class="form-group">
						  <label for="Fixed Packages" class="col-sm-4 control-label">Fixed Packages</label>
						  <div class="col-sm-8">
							<?php echo $gsi->getFixedPackagesById($enq_row["fixed_packages"]);?>
						  </div>
						</div>
						<div class="form-group">
						  <label for="Fixed Amount" class="col-sm-4 control-label">Fixed Amount</label>
						  <div class="col-sm-8">
							<? echo "&pound;".number_format($enq_row["fixed_amount"],2); ?>
						  </div>
						</div>
					</div>
					
					<?
						$display = ($enq_row["enquiry_type"] == 2) ? "display:block" : "display:none";
					?>
					<div id="hourly_packages_div" style="<?=$display;?>" class="common_class">
						<div class="form-group">
						  <label for="Consultancy Packages" id="estimated_label" class="col-sm-4 control-label">Consultancy Packages & Amount</label>
						  <div class="col-sm-8">
							<?php echo $gsi->getHourlyPackagesById($enq_row["hourly_packages"])." months";?>
							<? echo " , &pound;".number_format($enq_row["hourly_amount"],2); ?>
						  </div>
						</div>
						<!--<div class="form-group">
						  <label for="Consultancy Amount" class="col-sm-4 control-label">Consultancy Amount</label>
						  <div class="col-sm-8">
							<? //echo "&pound;".number_format($enq_row["hourly_amount"],2); ?>
						  </div>
						</div>-->
						<div class="form-group">
						  <label for="Job Start Date" class="col-sm-4 control-label">Job Start & End Date</label>
						  <div class="col-sm-8">
							<? 
								if($enq_row["job_start_date"] != "0000-00-00 00:00:00"){
									echo utility::getFormatedDateReturn($enq_row["job_start_date"]);
								}
								if($enq_row["job_end_date"] != "0000-00-00 00:00:00"){
									echo utility::getFormatedDateReturn($enq_row["job_end_date"]); 
								}
							?>
						  </div>
						</div>
						<? /*if($enq_row["job_end_date"] != "0000-00-00 00:00:00"){ ?>
						<div class="form-group">
						  <label for="Job End Date" class="col-sm-4 control-label">Job End Date</label>
						  <div class="col-sm-8">
							<? echo utility::getFormatedDateReturn($enq_row["job_end_date"]); ?>
						  </div>
						</div>
						<? }*/ ?>
                    </div>				
                  </div><!-- /.box-body -->
                </form>
              </div><!-- /.box -->
            </div><!-- /.box -->
		</div>
	</div>
</section>

<section class="content-header">
	<h1 style="float:left;">
		Invoices
	</h1>
</section>
<?
$query = "SELECT * FROM invoice WHERE job_id = ".$_REQUEST['id']." ORDER BY invoice_date DESC ";
$sql=mysqli_query($conn,$query);
$result=mysqli_num_rows($sql);
?>
<section class="content">
	<div class="row">
		<div class="col-xs-12">
			<? if($result>0){ ?>
			<div class="box box-primary" id="overflow_div">
			<!-- Start  records header -->
			<table id="example1" class="table table-bordered table-striped">
				<thead>
					<tr>
						<th>Job Id</th>
						<th>Description</th>
						<th>Consultant</th>
						<th>Status</th>
						<th>Amount (&pound;)</th>
						<th>Date</th>
						<th>Due Date</th>
						<th>Inv. Pay. Status</th>
						<th>Paid Amount (&pound;)</th>
						<!--<th>Send Invoice</th>-->
						<th>View Invoice</th>
					</tr>
				</thead>
				<tbody>
				<!-- End records header -->
				<?
				while($row = mysqli_fetch_array($sql)){
				?>
				<!-- Start data -->
				<tr>
					<td><?php echo $row['job_id']; ?></td>
					<td width="20%"><?php echo $row['invoice_text']; ?></td>
					<td><?php echo Admin::getAdminsById($row['admin_id']); ?></td>
					<td><?php echo $gsi->getInvoiceStatusById($row['invoice_status']); ?></td>
					<td><?php echo number_format($row['amount'],2); ?></td>
					<td><?php echo utility::getFormatedDateReturn($row['invoice_date']); ?></td>
					<td><?php echo utility::getFormatedDateReturn($row['due_date']); ?></td>
					<td><?php echo $gsi->getInvoicePaymentStatusById($row['id']); ?></td>
					<td><?php echo $gsi->getInvoicePaymentAmountById($row['id']); ?></td>
					<? $is_send_color = (utility::getTableFieldById("invoice","is_send","id",$row['id']) == 1) ? "red" : "";?>
					<?
						$from = $_REQUEST["from"];
					?>
					<!--<td><a style="color:<?=$is_send_color;?>" href="index?page=view_enquiry_progress&from=<?=$from;?>&action=send_invoice&id=<?=$row['id'];?>&job_id=<?=$row['job_id'];?>">Send Invoice</a></td>-->
					<td><a href="<?=$config->frontEndURL;?>/invoice/invoice.php?id=<?=base64_encode(base64_encode(base64_encode(base64_encode(base64_encode(base64_encode($row['id']))))))?>" target="_blank">View Invoice</a></td>
				</tr>
				<!-- End data -->
				<? 
				}?>
				</tbody>
			</table>
			</div>
			<?}else{?>
				<div class="box box-primary">No invoice found...</div>
			<? } ?>
		</div>
	</div>
</section>

<section class="content-header">
	<h1 style="float:left;">
		Payments
	</h1>
</section>
<?
$query = "SELECT * FROM payment WHERE job_id = ".$_REQUEST['id']." ORDER BY payment_date DESC ";
$sql=mysqli_query($conn,$query);
$result=mysqli_num_rows($sql);
?>
<section class="content">
	<div class="row">
		<div class="col-xs-12">
			<? if($result>0){ ?>
			<div class="box box-primary"  id="overflow_div">
			<!-- Start  records header -->
			<table id="example1" class="table table-bordered table-striped">
				<thead>
					<tr>
						<th>Job Id</th>
						<th>Description</th>
						<th>Consultant</th>
						<th>Status</th>
						<th>Amount (&pound;)</th>
						<th>Date</th>
						<th>For Invoice</th>
					</tr>
				</thead>
				<tbody>
				<!-- End records header -->
				<?
				while($row = mysqli_fetch_array($sql)){
				?>
				<!-- Start data -->
				<tr>
					<td><?php echo $row['job_id']; ?></td>
					<td><?php echo $row['payment_text']; ?></td>
					<td><?php echo Admin::getAdminsById($row['admin_id']); ?></td>
					<td><?php echo $gsi->getPaymentStatusById($row['payment_status']); ?></td>
					<td><?php echo number_format($row['amount'],2); ?></td>
					<td><?php echo utility::getFormatedDateReturn($row['payment_date']); ?></td>
					<td><?php echo $gsi->getInvoiceById($row['invoice_id']); ?></td>
				</tr>
				<!-- End data -->
				<? 
				}?>
				</tbody>
			</table>
			</div>
			<?}else{?>
				<div class="box box-primary">No payment found...</div>
			<? } ?>
		</div>
	</div>
</section>

<section class="content-header">
	<h1 style="float:left;">
		Timesheets
	</h1>
</section>
<?
$query = "SELECT * FROM timesheet WHERE job_id = ".$_REQUEST['id']." ORDER BY timesheet_date DESC ";
$sql=mysqli_query($conn,$query);
$result=mysqli_num_rows($sql);
?>
<section class="content">
	<div class="row">
		<div class="col-xs-12">
			<? if($result>0){ ?>
			<div class="box box-primary" id="overflow_div">
			<!-- Start  records header -->
			<table id="example1" class="table table-bordered table-striped">
				<thead>
					<tr>
						<th>Timesheet Text</th>
						<!--<th>Job</th>-->
						<th>Created By</th>
						<th>Date</th>
						<th>From Time</th>
						<th>To Time</th>
						<th>Time</th>
					</tr>
				</thead>
				<tbody>
				<!-- End records header -->
				<?
				while($row = mysqli_fetch_array($sql)){
				?>
				<!-- Start data -->
				<tr>
					<td><?php echo $row['timesheet_text']; ?></td>
					<!--<td><?php //echo $gsi->getEnqQuoteJobById($row['job_id']); ?></td>-->
					<td><?php echo Admin::getAdminsById($row['admin_id']); ?></td>
					<td><?php echo utility::getFormatedDateReturn($row['timesheet_date']); ?></td>
					<td><?php echo $row['from_time']; ?></td>
					<td><?php echo $row['to_time']; ?></td>
					<td><?php echo $row['timesheet_time']; ?></td>
				</tr>
				<!-- End data -->
				<? 
				}?>
				<tr>
					<td colspan="5" style="text-align:right;"><b>Total Time</b></td>
					<td><b><? echo $gsi->getTotalTimeByJobId($_REQUEST['id'])?></b></td>
				</tr>
				</tbody>
			</table>
			</div>
			<?}else{?>
				<div class="box box-primary">No timesheet found...</div>
			<? } ?>
		</div>
	</div>
</section>

<section class="content-header">
	<h1 style="float:left;">
		Mileage
	</h1>
</section>
<?
$query = "SELECT * FROM mileage WHERE job_id = ".$_REQUEST['id']." ORDER BY mileage_date DESC ";
$sql=mysqli_query($conn,$query);
$result=mysqli_num_rows($sql);
?>
<section class="content">
	<div class="row">
		<div class="col-xs-12">
			<? if($result>0){ ?>
			<div class="box box-primary" id="overflow_div">
			<!-- Start  records header -->
			<table id="example1" class="table table-bordered table-striped">
				<thead>
					<tr>
						<th>Description</th>
						<th>Mileage (In miles)</th>
						<th>Date</th>
						<th>Rate</th>
						<th>Cost (&pound;)</th>
					</tr>
				</thead>
				<tbody>
				<!-- End records header -->
				<?
				$total_mileage = 0;
				$mileage = 0;
				while($row = mysqli_fetch_array($sql)){
					$vat = utility::getTableFieldById('keycode','code','name','vat');
					$mileage_cost = $row['mileage']*$vat*$row['mileage_rate'];
					$total_mileage = $total_mileage + $mileage_cost;
					$mileage = $mileage + $row['mileage'];
				?>
				<!-- Start data -->
				<tr>
					<td><?php echo $row['mileage_text']; ?></td>
					<td><?php echo utility::getFormatedDateReturn($row['mileage_date']); ?></td>
					<td><?php echo number_format($row['mileage_rate'],2); ?></td>
					<td><?php echo $row['mileage']; ?></td>
					<td>
						<?php 
							echo number_format($mileage_cost,2);
						?>
					</td>
				</tr>
				<!-- End data -->
				<? } ?>
				<tr>
					<td>&nbsp;</td>
					<td colspan="2" style="text-align:right;"><b>Total</b></td>
					<td><b><?=$mileage;?></b></td>
					<td><b><?=number_format($total_mileage,2);?></b></td>
				</tr>
				</tbody>
			</table>
			</div>
			<?}else{?>
				<div class="box box-primary">No mileage found...</div>
			<? } ?>
		</div>
	</div>
</section>

<section class="content-header">
	<h1 style="float:left;">
		Appointments
	</h1>
</section>
<?
$query = "SELECT * FROM appointment WHERE job_id = ".$_REQUEST['id']." ORDER BY appointment_date DESC ";
$sql=mysqli_query($conn,$query);
$result=mysqli_num_rows($sql);
?>
<section class="content">
	<div class="row">
		<div class="col-xs-12">
			<? if($result>0){ ?>
			<div class="box box-primary" id="overflow_div">
			<!-- Start  records header -->
			<table id="example1" class="table table-bordered table-striped">
				<thead>
					<tr>
						<th>Description</th>
						<!--<th>Job</th>-->
						<th>Consultant</th>
						<th>Date</th>
						<th>Time</th>
					</tr>
				</thead>
				<tbody>
				<!-- End records header -->
				<?
				while($row = mysqli_fetch_array($sql)){
				?>
				<!-- Start data -->
				<tr>
					<td><?php echo $row['appointment_text']; ?></td>
					<!--<td><?php //echo $gsi->getEnqQuoteJobById($row['job_id']); ?></td>-->
					<td><?php echo Admin::getAdminsById($row['admin_id']); ?></td>
					<td><?php echo utility::getFormatedDateReturn($row['appointment_date']); ?></td>
					<td><?php echo $row['appointment_time']; ?></td>
				</tr>
				<!-- End data -->
				<? 
				}?>
				</tbody>
			</table>
			</div>
			<?}else{?>
				<div class="box box-primary">No appointment found...</div>
			<? } ?>
		</div>
	</div>
</section>

<section class="content-header">
	<h1 style="float:left;">
		Notes
	</h1>
	<a href="" data-toggle="modal" data-target="#myModal" alt="<?=$_REQUEST['id'];?>" class="btn btn-primary notes" style="float:right;margin-right:5px;margin-bottom:5px;">
	Add Note</a>
</section>
<?
$query = "SELECT * FROM notes WHERE job_id = ".$_REQUEST['id']." AND note_type = 0 AND updated_by = ".$_SESSION['job_user_id']." ORDER BY note_date DESC ";
$sql=mysqli_query($conn,$query);
$result=mysqli_num_rows($sql);
?>
<section class="content">
	<div class="row">
		<div class="col-xs-12">
			<? if($result>0){ ?>
			<div class="box box-primary" id="overflow_div">
			<!-- Start  records header -->
			<table id="example1" class="table table-bordered table-striped">
				<thead>
					<tr>
						<th>Description</th>
						<th>Created By</th>
						<th>Date</th>
					</tr>
				</thead>
				<tbody>
				<!-- End records header -->
				<?
				while($row = mysqli_fetch_array($sql)){
				?>
				<!-- Start data -->
				<tr>
					<td><?php echo $row['note_text']; ?></td>
					<td>
						<?php 
							if(isset($_SESSION['job_user_id']) && $_SESSION['job_user_id'] !=""){
								echo $gsi->getJobUserById($row['admin_id']); 
							}else{
								echo Admin::getAdminsById($row['admin_id']); 
							}
						?>
					</td>
					<td><?php echo utility::getFormatedDateReturn($row['note_date']); ?></td>
				</tr>
				<!-- End data -->
				<? 
				}?>
				</tbody>
			</table>
			</div>
			<?}else{?>
				<div class="box box-primary">No notes found...</div>
			<? } ?>
		</div>
	</div>
</section>

<? if(!(isset($_SESSION['job_user_id']) && $_SESSION['job_user_id'] !="")){ ?>
<section class="content-header">
	<h1 style="float:left;">
		Reminders
	</h1>
</section>
<?
$query = "SELECT * FROM notes WHERE job_id = ".$_REQUEST['id']." AND note_type = 1 ORDER BY note_date DESC ";
$sql=mysqli_query($conn,$query);
$result=mysqli_num_rows($sql);
?>
<section class="content">
	<div class="row">
		<div class="col-xs-12">
			<? if($result>0){ ?>
			<div class="box box-primary" id="overflow_div">
			<!-- Start  records header -->
			<table id="example1" class="table table-bordered table-striped">
				<thead>
					<tr>
						<th>Description</th>
						<th>Consultant</th>
						<th>Date</th>
						<th>Time</th>
					</tr>
				</thead>
				<tbody>
				<!-- End records header -->
				<?
				while($row = mysqli_fetch_array($sql)){
				?>
				<!-- Start data -->
				<tr>
					<td><?php echo $row['note_text']; ?></td>
					<td><?php echo Admin::getAdminsById($row['admin_id']); ?></td>
					<td><?php echo utility::getFormatedDateReturn($row['note_date']); ?></td>
					<td><?php echo $row['reminder_time']; ?></td>
				</tr>
				<!-- End data -->
				<? 
				}?>
				</tbody>
			</table>
			</div>
			<?}else{?>
				<div class="box box-primary">No reminders found...</div>
			<? } ?>
		</div>
	</div>
</section>
<? } ?>

<section class="content-header">
	<h1 style="float:left;">
		Documents
	</h1>
</section>
<?
$query = "SELECT * FROM documents WHERE job_id = ".$_REQUEST['id']." ORDER BY document_date DESC ";
$sql=mysqli_query($conn,$query);
$result=mysqli_num_rows($sql);
?>
<section class="content">
	<div class="row">
		<div class="col-xs-12">
			<? if($result>0){ ?>
			<div class="box box-primary" id="overflow_div">
			<!-- Start  records header -->
			<table id="example1" class="table table-bordered table-striped">
				<thead>
					<tr>
						<th>Description</th>
						<th>Document Name</th>
						<th>Type</th>
						<th>Date</th>
					</tr>
				</thead>
				<tbody>
				<!-- End records header -->
				<?
				while($row = mysqli_fetch_array($sql)){
				?>
				<!-- Start data -->
				<tr>
					<td><?php echo $row['document_text']; ?></td>
					<td>
						<!--<a href="../../document/<?php //echo $row['document_name']; ?>" target="_blank"><?php //echo $row['document_name']; ?></a>-->
						<?php echo $row['document_name']; ?>
						<a href="<?=$config->siteURL;?>/document_management/index?page=file_download&document_id=<?php echo $row['id']; ?>" target="_blank">
							<span style="cursor:pointer;" class="download_span">
								<i class="fa fa-fw fa-download"></i>
							</span>
						</a>
					</td>
					<td><?php echo Keycode::getkeycodeById($row['document_type']); ?></td>
					<td><?php echo utility::getFormatedDateReturn($row['document_date']); ?></td>
				</tr>
				<!-- End data -->
				<?}?>
				</tbody>
			</table>
			</div>
			<? }else{ ?>
				<div class="box box-primary">No documents found...</div>
			<? } ?>
		</div>
	</div>
</section>

<section class="content-header">
	<h1 style="float:left;">
		Mails
	</h1>
</section>
<?
$query = "SELECT * FROM email_track WHERE job_id = ".$_REQUEST['id']." ORDER BY email_date DESC ";
$sql=mysqli_query($conn,$query);
$result=mysqli_num_rows($sql);
?>
<section class="content">
	<div class="row">
		<div class="col-xs-12">
			<? if($result>0){ ?>
			<div class="box box-primary" id="overflow_div">
			<!-- Start  records header -->
			<table id="example1" class="table table-bordered table-striped">
				<thead>
					<tr>
						<th>Mail Subject</th>
						<th>Mail Body</th>
						<th>Date</th>
						<th>Attach</th>
					</tr>
				</thead>
				<tbody>
				<!-- End records header -->
				<?
				while($row = mysqli_fetch_array($sql)){
				?>
				<!-- Start data -->
				<tr>
					<td><?php echo $row['email_subject']; ?></td>
					<td><?php echo $row['email_body']; ?></td>
					<td><?php echo utility::getFormatedDateReturn($row['email_date']); ?></td>
					<td>
						<?php
						$sql_for_attch = "SELECT * FROM mail_document_upload WHERE email_track_id = ".$row['id'];
							$rs_for_attch = mysqli_query($conn,$sql_for_attch);
							if(mysqli_num_rows($rs_for_attch) > 0){
								while($data_for_attch = mysqli_fetch_assoc($rs_for_attch)){
									echo "<a href='".$config->siteURL."/document_upload/".$data_for_attch["document_name"]."' target='_blank'>".$data_for_attch["document_name"]."</a> ,  ";
								}
							}
						?>
					</td>
				</tr>
				<!-- End data -->
				<? 
				}?>
				</tbody>
			</table>
			</div>
			<? }else{ ?>
				<div class="box box-primary">No email found...</div>
			<? } ?>
		</div>
	</div>
</section>
<style>
	#overflow_div::-webkit-scrollbar
    {
      width: 5px;  /* for vertical scrollbars */
      height: 5px; /* for horizontal scrollbars */
    }
 
    #overflow_div::-webkit-scrollbar-track
    {
      background:#E7E8E9;
    }
 
    #overflow_div::-webkit-scrollbar-thumb
    {
      background: #3c8dbc;
    }
	#overflow_div{
		height:150px;
		overflow-y: auto;
	}
</style>
<div class="modal fade" id="myModalForSendMail" tabindex="-1" role="dialog" aria-labelledby="myModalLabel"></div>
<script type="text/javascript">
$(function(){
	$(".notes").click(function(){	
		$("#myModalLabel").text("Notes");
		var hide_top_left = "&hide_top=1&hide_left=1";
		var job_id = $(this).attr("alt");		
		$(".modal_iframe").attr("src","<?=$config->frontEndURL?>/admin/notes/index?page=view&source=j&job_id="+job_id+hide_top_left);
	});
	$(".close_button").click(function(){
		$(".modal_iframe").attr("src","");
		location.reload();
	});
});
</script>