-
Notifications
You must be signed in to change notification settings - Fork 0
/
sector_group_financial_info_page.php
109 lines (90 loc) · 3.13 KB
/
sector_group_financial_info_page.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
<?php
include 'value_at_risk_page.php';
class sector_group_financial_info_page extends value_at_risk_page {
// 超過1000以上的數會加千位逗號
function thousandsplit($f)
{
if( $f >= 1000 OR $f <= -1000 ) {
return number_format($f);
}
return $f;
}
// 印出table在螢幕上
function printValueatRisktable($class, $pageID) {
$obj1 = new db_controller_unit;
$pageID = $this->toSectorGroupName($class, $pageID);
// 取得資料
if($pageID)
$financialInfo = $obj1->getSectorGroupFinancialInfo($class, $pageID);
if (!empty($financialInfo)) {
echo "<div id='demoDiv'><div id='demoGrid'><table id='demoTable'><colgroup><col id='demoTableCol1'></colgroup><thead><tr>";
for( $j=0; $j<count($financialInfo[0]); $j++ ) {
echo '<th><span id="demoHdr'.$j.'">'.$financialInfo[0][$j].'</span></th>';
}
echo "</tr></thead><tbody>";
$isVaR = 1;
for($a=1; $a<count($financialInfo); $a++) {
echo "<tr>";
if($financialInfo[$a][0] === '產業總風險值' OR $financialInfo[$a][0] === '集團總風險值') $isVaR = 2;
if($financialInfo[$a][0] === '總資產') $isVaR = 0;
for($b=0; $b<count($financialInfo[0]); $b++) {
//$tem = explode( "%", $financialInfo[$a][$b] );
if($isVaR!=0) {
if ( $b === 0 AND $isVaR === 2 ) {
echo '<td class="g_title"><a href="#" onclick="window.open('."'drawsectorgroup.php?id=".$pageID."'".');">'.$financialInfo[$a][$b].'</a></td>';
}
else if ( $b === 0 ) {
echo '<td class="g_title">'.$financialInfo[$a][$b].'</td>';
}
else if( $this->checkValueatRisk($financialInfo[$a][$b]) > 0 AND $b >= 1 ) {
if($this->checkValueatRisk($financialInfo[$a][$b])>1)
echo '<td class="g_hRisk">'.$financialInfo[$a][$b].'</td>'; // 高風險值背景class
else
echo '<td class="g_lRisk">'.$financialInfo[$a][$b].'</td>'; // 中風險值背景class
}
else {
echo '<td>'.$financialInfo[$a][$b].'</td>';
}
}
else {
if ( $b === 0 ) {
echo '<td class="g_title2">'.$financialInfo[$a][$b].'</td>';
}
else {
if ( (float)$financialInfo[$a][$b] < 0 ) {
echo '<td class="g_body2"><font color="red">'. $this->thousandsplit($financialInfo[$a][$b]) .'</font></td>';
}
else {
echo '<td class="g_body2">'. $this->thousandsplit($financialInfo[$a][$b]) .'</td>';
}
}
}
}
echo "</tr>";
}
echo '</tbody></table></div></div>';
} else {
echo "<br>no data.";
}
}
// 將產業 企業集團代號轉換成實際的名稱
function toSectorGroupName($class, $str)
{
$dname ="sectorgroupname.xml"; // xml檔名
//建立XML操作物件
$doc = new DOMDocument();
$doc->load($dname);
$nodes = $doc->getElementsByTagName($class);
$k=0;
foreach ($nodes as $node) {
$eng_abbreviation = $nodes->item($k)->getAttribute('eng_abbreviation');
if($str==$eng_abbreviation) {
$name = $node->nodeValue;
return $name;
}
$k++;
}
return null;
}
}
?>