adminFareMajorStops.phpの例

<?php
//閲覧および各種メニュー
include_once("../../../mainfile.php");
//$xoopsOption['show_rblock'] = 0;
include_once(XOOPS_ROOT_PATH."/header.php");
global $xoopsDB, $xoopsUser;
$myts = & MyTextSanitizer::getInstance();
include_once("../class/class.fare.php"); /* 料金管理クラスの読み込み */

/* display selection menu */
include_once("adminFareCommonHead.php");
/* $fareObj, $selectedRouteID, $selectedGeneralRoute,
   $category are defined in adminFareCommonHead.php */

if(!isset($selectedRouteID) || !$selectedRouteID) {
  include_once(XOOPS_ROOT_PATH."/footer.php");
  return;
}

$joge = $selectedRouteID;

?>

<?php
$ConnTable = $xoopsDB->prefix("BusMap2_BusStopConnections");
$PlatTable = $xoopsDB->prefix("BusMap2_Platform");
$BusStopTable = $xoopsDB->prefix("BusMap2_BusStop");

$stop = array();
$stop[$joge] = array();
$sql = "select c.OrderNum, s.ID, s.Name
         from $ConnTable c, $PlatTable p, $BusStopTable s
         where c.PlatformID = p.ID and p.BusStopID = s.ID and
         c.RouteID = $joge order by c.OrderNum";
$res = $xoopsDB->query($sql) or die($xoopsDB->error());
while($row = $xoopsDB->fetchArray($res)) {
  $stop[$joge][$row['OrderNum']] = array('ID'=>$row['ID'],'Name'=>$row['Name']);
}
?>

<?php
//DevBusMap2_MajorStopsテーブルへ問い合わせ
$MajorStopsTable = $xoopsDB->prefix("DevBusMap2_MajorStops"); //料金テーブルオブジェクト
$sql = "select * from $MajorStopsTable where RouteID = ${joge} order by OrderNum";
$res = $xoopsDB->query($sql);
while($row = $xoopsDB->fetchArray($res)){
  $majorStops[$row['OrderNum']] = $row['StopID'];
}

if(!isset($majorStops)) {
  echo _AD_BM_MAJOR_STOPS_NOT_REGISTERED;
  echo "<form method='POST' action='adminMajorStops.php'>";
  echo "<input type='hidden' name='category' value='${selectedCategoryID}'/>".
    "<input type='hidden' name='general_route_id' value='${selectedGeneralRouteID}'/>".
    "<input type='hidden' name='route_id' value='${selectedRouteID}'/>";
  echo "<input type='submit' value='". _AD_BM_GOTO_ADMIN_MAJOR_STOPS . "'/></form>";

  include_once(XOOPS_ROOT_PATH."/footer.php");
  return;
}
?>

<?php
$j=1;
for($i=1;$i<=count($stop[$joge]);$i++){
  //  print_r($stop[$joge][$i]);
  if(in_array($stop[$joge][$i]["ID"],$majorStops)){
    $aaa[$j]["ID"] = $stop[$joge][$i]["ID"];
    $aaa[$j]["Name"] = $stop[$joge][$i]["Name"];
    $j++;
  }
}

?>
<?php
//BusMap2_Fareテーブルへ問い合わせ
$FareTable = $xoopsDB->prefix("BusMap2_Fare"); //料金テーブルオブジェクト
$sql = "select * from $FareTable";
$res = $xoopsDB->query($sql);
while($row = $xoopsDB->fetchArray($res)){
  $fare[$row['DepartureID']][$row['ArrivalID']] = $row['Fare'];
}
?>

<link href="../js/Super_Tables/superTables_compressed.css" rel="Stylesheet" type="text/css" />
<style type="text/css">
.fakeContainer { /* The parent container */
    margin: 0 0 20px; /* */
    border: none;
    width: 700px; /* Required to set 表の幅を指定*/
    height: 600px; /* Required to set 表の縦を指定*/
    overflow: hidden; /* Required to set 要領を超える場合スクロールをつけない(hidden)ようにしている。*/
}
</style>

<form method="POST" action="adminFare.php">
<input type="hidden" name="route_id" value="<?php echo $selectedRouteID; ?>"/>
<input type="hidden" name="general_route_id" value="<?php echo $selectedGeneralRouteID; ?>"/>
<input type="hidden" name="category" value="<?php echo $selectedCategoryID?>"/>
<div class="fakeContainer">

<?php
//料金表の作成
  echo '<table id="demoTableA">';
//1行目バス停名を上から2番目から表示
echo"<tr><th>". _AD_BM_STOP_NAME . "</th>";
for($i=2;$i<count($aaa)+1;$i++){
  echo"<th>" . $aaa[$i]["Name"] . "</th>";
}
echo"</tr>";
for($i=1;$i<count($aaa);$i++){
  echo'<tr><td size="10">' . $aaa[$i]["Name"] . "</td>";
  for($j=2;$j<count($aaa)+1;$j++){
    if($j <= $i){
      echo'<td></td>';
    }else{
      $tmpfare = isset($fare[$aaa[$i]["ID"]][$aaa[$j]["ID"]])? $fare[$aaa[$i]["ID"]][$aaa[$j]["ID"]] : "";
      if($tmpfare!=""){
        $tmp ='<td class="active"><input type="text" size="5" name="tarea_' . $aaa[$i]["ID"].'_'.$aaa[$j]["ID"] . '" value="'.$tmpfare.'"></td>';
      }else{
        $tmp ='<td class="active"><input type="text" size="5" name="tarea_' . $aaa[$i]["ID"].'_'.$aaa[$j]["ID"] . '" value=""></td>';
      }
      echo $tmp;
    }
  }
  echo "</tr>";
}
echo"</table>";
echo"</div>";


?>
<input type="submit" name="post_major_stops" value="<?php echo _AD_BM_SUBMIT;?>">
</form>


<script type="text/javascript" src="../js/Super_Tables/superTables_compressed.js"></script>
<script type="text/javascript">
//<![CDATA[
(function () {
    new superTable("demoTableA", {
      cssSkin : "sDark",
        fixedCols : 1
    });
})();
//]]>
</script>


<?php
include_once(XOOPS_ROOT_PATH."/footer.php");
?>