function printFinancialIndexTable($cid)
 {
     $obj1 = new db_controller_unit();
     if (!empty($obj1->isExistedFinancialIndexData($cid))) {
         $financial_index_data = $obj1->getComapnyFinancialIndex($cid);
         echo '<div id="demoDiv"><div id="demoGrid"><table id="demoTable"><colgroup><col id="demoTableCol1"></colgroup><thead><tr>';
         for ($i = 0; $i < count($financial_index_data[0]); $i++) {
             echo '<th><span id="demoHdr' . ($i + 1) . '">' . $financial_index_data[0][$i] . '</span></th>';
         }
         echo '</tr></thead><tbody>';
         for ($i = 1; $i < count($financial_index_data); $i++) {
             echo '<tr>';
             for ($j = 0; $j < count($financial_index_data[0]); $j++) {
                 // title class
                 if ($i === 1 or $i === 11 or $i === 16 or $i === 21 or $i === 24) {
                     echo '<td class="finacial_title">' . $financial_index_data[$i][$j] . '</td>';
                 } else {
                     if ($j === 0) {
                         echo '<td class="g_title">' . $financial_index_data[$i][$j] . '</td>';
                     } else {
                         if ((double) $financial_index_data[$i][$j] < 0 and $financial_index_data[$i][$j] != '-') {
                             echo '<td><font color="red">' . $this->thousandsplit($financial_index_data[$i][$j]) . '</font></td>';
                         } else {
                             echo '<td>' . $this->thousandsplit($financial_index_data[$i][$j]) . '</td>';
                         }
                     }
                 }
             }
             echo '</tr>';
         }
         echo '</tbody></table></div></div>';
     } else {
         echo '<br>no data';
     }
 }
 function printValueatRisktable($year)
 {
     $obj1 = new db_controller_unit();
     $top100_financial_info = $obj1->getTop100FinancialInfo($year);
     if (!empty($top100_financial_info)) {
         echo '<div id="demoDiv"><div id="demoGrid"><table id="demoTable"><colgroup><col id="demoTableCol1"></colgroup><thead><tr>';
         $title_name = $this->getTop100TitleName();
         for ($i = 0; $i < count($title_name); $i++) {
             echo "<th><span id=demoHdr" . $i . ">" . $title_name[$i] . "</span></th>";
         }
         echo '</tr></thead><tbody>';
         for ($i = 0; $i < count($top100_financial_info); $i++) {
             echo '<tr>';
             for ($j = 0; $j < count($top100_financial_info[0]); $j++) {
                 if ($j < 2) {
                     echo '<td class="g_title">' . $top100_financial_info[$i][$j] . '</td>';
                 } else {
                     if (preg_match('/%/', $top100_financial_info[$i][$j])) {
                         echo '<td>' . $top100_financial_info[$i][$j] . '</td>';
                     } else {
                         echo '<td>' . $this->thousandsplit($top100_financial_info[$i][$j]) . '</td>';
                     }
                 }
             }
             echo '</tr>';
         }
         echo '</tbody></table></div></div>';
     } else {
         echo '<br>no data.';
     }
 }
Ejemplo n.º 3
0
<style type="text/css">
BODY {
	background: linear-gradient(top, #888, #eee);
	background: -moz-linear-gradient(top, #888, #eee);
	background: -webkit-linear-gradient(top, #888, #eee);
}
</style>
</head>
	
	<?php 
if (isset($_SESSION['username'])) {
    $company_id = $_GET['id'];
    $classification = $_GET['class'];
    // 取所有資料
    include 'db_controller_unit.php';
    $obj1 = new db_controller_unit();
    $dbn = $obj1->connect_DB();
    if (isset($company_id)) {
        $datatem = $dbn->query('SELECT * FROM `company_basic_information` WHERE `company_id` = "' . $company_id . '" ');
        $data_row = mysqli_fetch_row($datatem);
    }
    ?>
		<script type="text/javascript">	
			// 讀取Google API結束後執行loadVisual()
			loadAPI('http://www.google.com/jsapi?callback=loadVisual');

			// Google API讀取繪圖所需Packages,並執行loadPage()
			function loadVisual() {
				google.load('visualization', '1', {'packages':['corechart'], "callback" : loadPage});
			}
			
<?php

/*
  檢查 input string 是否為財務指標頁面有資料的公司
*/
$str = $_GET['input'];
include './db_controller_unit.php';
$obj1 = new db_controller_unit();
$cid = $obj1->isExistedFinancialIndexData($str);
echo $cid;
<?php

// 連結資料庫
include "./db_controller_unit.php";
$company_id = $_GET['id'];
$obj1 = new db_controller_unit();
// --取得指定公司的資料
$stock_chart_xy_axis = $obj1->getStockforTrendChart($company_id);
$obj1 = null;
// return data
echo json_encode($stock_chart_xy_axis);
<?php

// 連結資料庫
include "./db_controller_unit.php";
//台灣還中國公司分類 中國=china
$c = $_GET['class'];
// --取得公司資料
$company_id = $_GET['id'];
$obj1 = new db_controller_unit();
$value_at_risk_chart_xy_axis = $obj1->getValueatRiskforTrendChart($c, $company_id);
$obj1 = null;
// return data
echo json_encode($value_at_risk_chart_xy_axis);
<?php

// 連結資料庫
include "./db_controller_unit.php";
$sectorgroup_name = $_GET['name'];
$obj1 = new db_controller_unit();
// --取得指定公司的資料
$cashflow_chart_xy_axis = $obj1->getSectorGroupCashflowforTrendChart($sectorgroup_name);
$obj1 = null;
// return data
echo json_encode($cashflow_chart_xy_axis);
<?php

$name = $_GET['name'];
// 取所有資料
include "./db_controller_unit.php";
$obj1 = new db_controller_unit();
$total_value_at_risk_data = $obj1->getTotalValueatRiskforTrendChart($name);
$obj1 = null;
// return data
echo json_encode($total_value_at_risk_data);
 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>';
                                 } 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 ((double) $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 sortData($datalist, $pageID)
 {
     // 不須整理直接回傳
     if ($pageID === '興櫃' or $pageID === '公開發行' or $pageID === '中國') {
         return $datalist;
     } else {
         if ($pageID === '下市櫃') {
             // 下市櫃頁面加上危機發生年月
             $obj1 = new db_controller_unit();
             $dbn = $obj1->connect_DB();
             for ($i = 0; $i < count($datalist); $i++) {
                 $new_index = 0;
                 for ($j = 0; $j < count($datalist[0]); $j++) {
                     if ($i === 0) {
                         if ($j === 1) {
                             $new_datalist[$i][$new_index] = $datalist[$i][$j];
                             $new_datalist[$i][$new_index + 1] = "危機發生年/月";
                             $new_index = $new_index + 2;
                         } else {
                             $new_datalist[$i][$new_index] = $datalist[$i][$j];
                             $new_index = $new_index + 1;
                         }
                     } else {
                         if ($j === 1) {
                             $new_datalist[$i][$new_index] = $datalist[$i][$j];
                             $crisis_date = $dbn->query('SELECT * FROM `company_financial_crisis` WHERE `company_id` = "' . $datalist[$i][0] . '"');
                             if (!empty($crisis_date)) {
                                 $crisis_date_row = mysqli_fetch_row($crisis_date);
                                 if (!empty($crisis_date_row)) {
                                     $new_datalist[$i][$new_index + 1] = $crisis_date_row[1];
                                 } else {
                                     $new_datalist[$i][$new_index + 1] = "NULL";
                                 }
                             } else {
                                 $new_datalist[$i][$new_index + 1] = "NULL";
                             }
                             $new_index = $new_index + 2;
                         } else {
                             $new_datalist[$i][$new_index] = $datalist[$i][$j];
                             $new_index = $new_index + 1;
                         }
                     }
                 }
             }
             return $new_datalist;
         } else {
             // 上市上櫃頁面加上三年預警率
             for ($i = 0; $i < count($datalist); $i++) {
                 $new_index = 0;
                 for ($j = 0; $j < count($datalist[0]); $j++) {
                     if ($i === 0) {
                         if ($j === 1) {
                             $new_datalist[$i][$new_index] = $datalist[$i][$j];
                             $new_datalist[$i][$new_index + 1] = "三年預警率";
                             $new_index = $new_index + 2;
                         } else {
                             $new_datalist[$i][$new_index] = $datalist[$i][$j];
                             $new_index = $new_index + 1;
                         }
                     } else {
                         if ($j === 1) {
                             $new_datalist[$i][$new_index] = $datalist[$i][$j];
                             $highrisk = 0;
                             $value_at_risk_num = 0;
                             for ($k = 1; $k < 13; $k++) {
                                 // $tem = explode( "%", $datalist[$i][$j+$k] );
                                 /*
                                  * if ( $datalist[$i][$j+$k] != "-" )
                                  * $value_at_risk_num++;
                                  */
                                 if (strcasecmp($datalist[$i][$j + $k], "-")) {
                                     $value_at_risk_num++;
                                 }
                                 // if ( $tem[0] > 50.00 )
                                 // $highrisk++;
                                 if ($this->checkValueatRisk($datalist[$i][$j + $k]) === 2) {
                                     $highrisk++;
                                 }
                             }
                             if ($value_at_risk_num) {
                                 $warining_rate = $highrisk / $value_at_risk_num * 100;
                             } else {
                                 $warining_rate = 0;
                             }
                             $new_datalist[$i][$new_index + 1] = sprintf("%.0f", $warining_rate) . "% (" . $highrisk . '/' . $value_at_risk_num . ')';
                             $new_index = $new_index + 2;
                         } else {
                             $new_datalist[$i][$new_index] = $datalist[$i][$j];
                             $new_index = $new_index + 1;
                         }
                     }
                 }
             }
             return $new_datalist;
         }
     }
 }