<?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		= "organisation_management";
$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);
$enq_row = mysqli_fetch_assoc($rs);
$enq_row=utility::validate_crypt_data($enq_row);
?>
<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">
	<div class="container-fluid">
		<div class="row">
		<div class="col-lg-12 col-md-6 col-sm-6">
		  <div class="col-sm-4">
			  <h1 style="float:left;clear:right;">
				Organisation Details - <span style='color:#ed5c5c;'><?= $enq_row['organisation_name'];?></span>
			  </h1>
		  </div>
			<?
				$query_string 	=  (isset($_POST['query_string'])) ? $_POST['query_string'] : $_SERVER['QUERY_STRING'];
				$query_string = str_ireplace("page=view_organisation_details", "page=view", $query_string);
			?>
			  <button type="button" id="back" name="back" value="back"  style="float:right;margin-bottom: 15px;" class="btn btn-success" onclick="window.location.href = 'index?<?=$query_string.$next_page_condition.$paging;?>'">Back</button>
			  
			  <? if((isset($_REQUEST["from"]) && $_REQUEST["from"] == "view_organisation") || (isset($_REQUEST["from"]) && $_REQUEST['from'] == "view_organisation_details")){ 
			  ?>
				<a href="index?page=add&from=view_organisation_details&action=edit&id=<?=$_REQUEST['id'].$next_page_condition;?>" style="float:right;margin-right:5px;" class="btn btn-primary">Edit</a>
			  <? } ?>
		</div>
		</div>
	</div>
</section>

<section class="content">
	<div class="container-fluid">
		<div class="row">
			<div class="col-lg-12 no-padding">
				<div class="row">
					<!----------------------- Message ------------------------------->
					<? if(isset($_SESSION['info_message'])){ ?>
					  <div class="col-sm-12 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-lg-12 col-md-12 col-sm-12 col-xs-<?=$col_width;?>">
					  <div class="box box-primary card">
						<form class="form-horizontal" method="post" name="form1" id="form1" action="index?page=add&action=<? echo $form_action; ?>" onsubmit="return validateForm(this)" enctype="multipart/form-data">
						  <div class="box-body">
							<div class="form-group">
							  <label for="organisation_name" class="col-sm-4 control-label">Organisation Name</label>
							  <div class="col-sm-8">
								<? echo ucfirst($enq_row['organisation_name']); ?>
							  </div>
							</div>
							<div class="form-group">
							  <label for="title" class="col-sm-4 control-label">Title</label>
							  <div class="col-sm-8">
								<?php echo Keycode::getkeycodeById($enq_row['title']); ?>
							  </div>
							</div>
							<div class="form-group">
							  <label for="contact_name" class="col-sm-4 control-label">Contact Name</label>
							  <div class="col-sm-8">
								<? if(isset($enq_row['first_name']) && $enq_row['first_name'] !=""){
									echo ucfirst($enq_row['first_name'])." ".ucfirst($enq_row['last_name']); 
								}?>
							  </div>
							</div>
							<div class="form-group">
							  <label for="Phone No" class="col-sm-4 control-label">Phone No.1</label>
							  <div class="col-sm-8">
								<?php echo $enq_row["phone_no"]; ?>
							  </div>
							</div>
							<div class="form-group">
							  <label for="Phone No" class="col-sm-4 control-label">Phone No.2</label>
							  <div class="col-sm-8">
								<?php echo $enq_row["landline_phone_no"]; ?>
							  </div>
							</div>
							<div class="form-group">
							  <label for="email" class="col-sm-4 control-label">Email</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["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="prospect Date" class="col-sm-4 control-label">Enquiry Date</label>
							  <div class="col-sm-8">
								<? echo utility::getFormatedDateReturn($enq_row["common_date"]); ?>
							  </div>
							</div>
							<div class="form-group">
							  <label for="current_supplier" class="col-sm-4 control-label">Notes</label>
							  <div class="col-sm-8">
								<?php echo $enq_row["notes"]; ?>
							  </div>
							</div>
						  </div><!-- /.box-body -->
						</form>
					  </div><!-- /.box -->
					</div><!-- /.box -->
				</div>
			</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:200px;
		overflow-y: auto;
	}
	@media print{
		body{
			visibility: hidden;
		  }
		  #overflow_div{
			height:auto;
		  }
		  .printable{
			visibility: visible;
		  }
		  .printable{
			position: absolute;
			left: 0;
			top: 0;
		  }
	}
</style>
<script type="text/javascript">
function divPrint(section){
	// Some logic determines which div should be printed...
	// This example uses div3.
	$("#"+section).addClass("printable");
	window.print();
}	  
	$(".close_button").click(function(){
		$(".modal_iframe").attr("src","");
		location.reload();
	});
});
</script>