<?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']." ";
}
$station_id = utility::app_crypt($_REQUEST['station_id'],'d');
if($_REQUEST['id'] != $station_id){
	die("Invaild URL");
}
###########################################  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		= "quotation_machines";
$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);
$station_row = mysqli_fetch_assoc($rs);
$station_row=utility::validate_crypt_data($station_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-10">
					<h4 style="float:left;clear:right;">
						Resource Station Details - <span style='color:#ed5c5c;'><?= $station_row['station'];?></span>
					</h4>
				</div>
				<?
				$query_string 	=  (isset($_POST['query_string'])) ? $_POST['query_string'] : $_SERVER['QUERY_STRING'];
				$query_string = str_ireplace("page=view_station_details", "page=view", $query_string);
			?>
				<button type="button" id="back" name="back" value="back" style="float:right;margin-bottom: 15px;"
				class="btn btn-primary" onclick="window.location.href = 'index?<?=$query_string.$next_page_condition.$paging;?>'">Back</button>

				<? if((isset($_REQUEST["from"]) && $_REQUEST["from"] == "view") || (isset($_REQUEST["from"]) && $_REQUEST['from'] == "view_station_details")){ 
			  ?>
				<a href="index?page=add&from=view_station_details&action=edit&station_id=<?=urlencode(utility::app_crypt($_REQUEST['id'],'e'));?>&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="row">
										<div class="col-lg-12 col-sm-12">
										    <div class="row">
											<div class="form-group col-lg-6">
												<label for="Resource Station" class="col-sm-4 control-label">Resource Station</label>
												<div class="col-sm-8">
													<? echo ucfirst($station_row['station']); ?>
												</div>
											</div>
											<div class="form-group col-lg-6">
												<label for="Facility Rate OEM" class="col-sm-4 control-label">Facility
													Rate OEM</label>
												<div class="col-sm-8">
													<? echo ucfirst($station_row['facility_rate_oem']); ?>
												</div>
											</div>
											</div>
											<div class="row">
											<div class="form-group col-lg-6">
												<label for="Labour Rate OEM" class="col-sm-4 control-label">Labour Rate
													OEM</label>
												<div class="col-sm-8">
													<? echo ucfirst($station_row['labour_rate_oem']); ?>
												</div>
											</div>
											<div class="form-group col-lg-6">
												<label for="Has Set Time" class="col-sm-4 control-label">Has Set Time</label>
												<div class="col-sm-8">
													<? echo  $gsi->getYesNoById($station_row['has_set_time']); ?>
												</div>
											</div>
											</div>
											<div class="row">
											<div class="form-group col-lg-6">
												<label for="Has Operation Time" class="col-sm-4 control-label">Has
													Operation Time</label>
												<div class="col-sm-8">
													<? echo  $gsi->getYesNoById($station_row['has_operation_time']); ?>
												</div>
											</div>
											<div class="form-group col-lg-6 hide">
												<label for="Hrs Week" class="col-sm-4 control-label">Hrs Week</label>
												<div class="col-sm-8">
													<?php echo $station_row["hrs_week"]; ?>
												</div>
											</div>
											</div>
										</div>

									</div>

								</div><!-- /.box-body -->
							</form>
						</div><!-- /.box -->
					</div><!-- /.box -->
				</div>
			</div>
		</div>
	</div>
</section>

