<?php include 'header.php';




$link="http://chart2.chartnexus.com/stockdata/get_historical_quote.jsp?market_id=$marketID&stockcode=$companyImage";
// 			       		echo $link;
$json = file_get_contents("$link");

$arr = json_decode($json, true);
$EODdate= $arr["date"];
$LastPrice= $arr["c"];
$Change= $arr["chg"];
$PChange= $arr["chgp"];
$Open= $arr["o"];
$IntradayHigh= $arr["h"];
$IntradayLow= $arr["l"];
$Volume= $arr["v"];

if($Change<0){
	$color="rgb(255,0,0)";
	$arrow_image="img/icon/arrow_down.png";
	$symbol="";
}
if($Change>0){
	$color="#74c258";
	$arrow_image="img/icon/arrow_up.png";
	$symbol="+";
}
if($Change==0){
	$color="rgb(61,148,0)";
	$arrow_image="img/icon/remain.png";
	$symbol="+";
}

$timestamp = strtotime($EODdate);
$new_date_format = (date('d F Y', $timestamp));
$new_time_format = strtoupper(date("H:i "));


$new_time_mobile_format = strtoupper(date("H:i "));

$issuedShares = 6800839377;//Kian Ann : Please find the value from AR
$trueasuryShares = 0;//Kian Ann : Please check with Vincent on this
$num = ($LastPrice*($issuedShares-$trueasuryShares)/1000000000);
$marketCap = number_format($num, 2);
$LastPrice = number_format($LastPrice, 3);
$Open = number_format($Open, 3);
$IntradayLow = number_format($IntradayLow, 3);
$IntradayHigh = number_format($IntradayHigh, 3);


function dot_num($n) {
	// first strip any formatting;
	$n = (0+str_replace(",", "", $n));

	// is this a number?
	if (!is_numeric($n)) return false;

	// now filter it;
	if ($n > 1000000000000) return round(($n/1000000000000), 2).' tri';
	elseif ($n > 1000000000) return round(($n/1000000000), 2).' bil';
	elseif ($n > 1000000) return round(($n/1000000), 2).' mil';
	elseif ($n > 1000) return round(($n/1000), 2).' k';

	return number_format($n);
}
$Volume2 = dot_num($Volume);


?>

<style>
 .iframechart{
    box-shadow: 0px 2px 12px rgba(0, 0, 0, 0.4);
}
</style>
<section class="hero small with-bg" style="background-image: url(img/banner/Banner.png)">
	<div class="hero-overlay">
		<div class="container">
			<div class="row">
				<div class="column col-10 pull-center">
					Stock Information
				</div>
			</div>
		</div>
	</div>
</section>

<section class="commonSection">
	<div class="container">
		<div class="row align-items-center sfarea">
			<div class="col-md-3">
				<div class="boxdf">
					<div class="hero-column-heading">
						Last Price                          
					</div>
					<h2>MYR <?=$LastPrice?></h2>
					<p><small>Updated on <?=$new_date_format?></small></p>
				</div>
			</div>
			<div class="col-md-9">
				<div class="row align-items-center">
					<div class="col-md-2 col-sm-6">
						<div class="box-1">
							<div class="hero-column-heading-2">
								<small>Open </small>                         
							</div>
							<h5><?=$Open?></h5>
						</div>
					</div>
					<div class="col-md-2 col-sm-6">
						<div class="box-1">
							<div class="hero-column-heading-2">
								<small>Intraday High </small>                         
							</div>
							<h5><?=$IntradayHigh?></h5>
						</div>
					</div>
					<div class="col-md-2 col-sm-6">
						<div class="box-1">
							<div class="hero-column-heading-2">
								<small>Intraday Low </small>                         
							</div>
							<h5><?=$IntradayLow?></h5>
						</div>
					</div>
					<div class="col-md-2 col-sm-6">
						<div class="box-1">
							<div class="hero-column-heading-2">
								<small>Change </small>                         
							</div>
							<h5><?=$Change?></h5>
						</div>
					</div>
					<div class="col-md-2 col-sm-6">
						<div class="box-1">
							<div class="hero-column-heading-2">
								<small>Change % </small>                         
							</div>
							<h5><?=$PChange?></h5>
						</div>
					</div>
					<div class="col-md-2 col-sm-6">
						<div class="box-1">
							<div class="hero-column-heading-2">
								<small>Volume </small>                         
							</div>
							<h5><?=$Volume2?></h5>
						</div>
					</div>
				
				</div>
			</div>
		</div>
		<div class="col-md-12 mt-4 mb-4">
			<iframe src="https://ir.chartnexus.com/HTML5/IRChart.jsp?load_counter0=2,5218&ir_watermark=https://cdn.chartnexus.com/IR/irchart_sources/v1/vantnrg/watermark/watermark.png&WTRMK_WIDTH=239&WTRMK_HEIGHT=100" scrolling="no" frameborder="0" width="100%" height="700" class="iframechart"></iframe>
		</div>
	</div>
</section>

<?php include 'footer.php';?>
