Exemplo n.º 1
0
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});
			}
			
			// 依公司代號及名稱取得資料並開始繪圖
 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;
         }
     }
 }