/**
  * print 表格在螢幕上
  * 參數說明:
  * c : china or taiwan
  * pageID : 頁面分類
  * ValueatRiskData : 風險值資料
  * fixedCols : 固定的title數
  */
 function printValueatRisktable($c, $pageID)
 {
     // new a db_controller_unit object
     $obj1 = new db_controller_unit();
     // justify china or taiwan company
     if ($c == "china") {
         $ValueatRiskData = $obj1->getChinaCompanyValueatRiskData();
     } else {
         $ValueatRiskData = $obj1->getCompanyValueatRiskData($pageID);
     }
     // justify how fixed col(title, not change, and always in left)
     if ($pageID === '上市' or $pageID === '上櫃' or $pageID === '下市櫃') {
         $fixedCols = 3;
     } else {
         $fixedCols = 2;
     }
     // if has data then
     if (!empty($ValueatRiskData)) {
         $ValueatRiskData = $this->sortData($ValueatRiskData, $pageID);
         echo "<div id='demoDiv'><div id='demoGrid'><table id='demoTable'><colgroup><col id='demoTableCol1'></colgroup><thead><tr>";
         // 印title
         for ($j = 0; $j < count($ValueatRiskData[0]); $j++) {
             echo '<th><span id="demoHdr' . $j . '">' . $ValueatRiskData[0][$j] . '</span></th>';
         }
         echo "</tr></thead><tbody>";
         // 印資料
         for ($i = 1; $i < count($ValueatRiskData); $i++) {
             echo "<tr>";
             for ($j = 0; $j < count($ValueatRiskData[0]); $j++) {
                 if ($j === 0) {
                     echo '<td class="g_title">' . $ValueatRiskData[$i][$j] . '</td>';
                 } else {
                     if ($j === 1) {
                         if ($c === "china") {
                             echo '<td class="g_title"><a href="#" onclick="window.open(' . "'drawcn.php?id=" . $ValueatRiskData[$i][$j - 1] . "'" . ');">' . $ValueatRiskData[$i][$j] . '</a></td>';
                         } else {
                             if ($pageID == '下市櫃') {
                                 echo '<td class="g_title">' . $ValueatRiskData[$i][$j] . '</td>';
                             } else {
                                 echo '<td class="g_title"><a href="#" onclick="window.open(' . "'draw.php?class=" . $this->id . "&id=" . $ValueatRiskData[$i][$j - 1] . "'" . ');">' . $ValueatRiskData[$i][$j] . '</a></td>';
                             }
                         }
                     } else {
                         if ($j === 2 and $fixedCols === 3) {
                             echo '<td class="g_title">' . $ValueatRiskData[$i][$j] . '</td>';
                         } else {
                             if ($this->checkValueatRisk($ValueatRiskData[$i][$j]) > 0 and $j >= $fixedCols) {
                                 if ($this->checkValueatRisk($ValueatRiskData[$i][$j]) > 1) {
                                     echo '<td class="g_hRisk">' . $ValueatRiskData[$i][$j] . '</td>';
                                 } else {
                                     echo '<td class="g_lRisk">' . $ValueatRiskData[$i][$j] . '</td>';
                                 }
                                 // 中風險值背景class
                             } else {
                                 echo '<td>' . $ValueatRiskData[$i][$j] . '</td>';
                             }
                         }
                     }
                 }
             }
             echo "</tr></tbody>";
         }
         echo "</table></div></div>";
     } else {
         echo "<br>no data";
     }
 }