2017年10月10日 星期二

X學務系統自訂輸出(使用tinyD或區塊)

tinyD去建立有學校的轉入轉出,底下是轉出的範例


//取得目前的學年學期
$d = explode('-',date('Y-m-d'));
if ($d[1]>=8) {
  $curr_year=$d[0]-1911;
  $curr_seme=1;
} elseif ($d[1]==1) {
  $curr_year=$d[0]-1912; 
  $curr_seme=1;
}else{ 
  $curr_year=$d[0]-1912;
  $curr_seme=2;
}


$curr_link=$_SERVER['PHP_SELF']. '?id='.$_GET['id'].'&gc_year='. $curr_year.'&gc_seme='.$curr_seme;

//取得參數的學年學期
if ($_GET['gc_year'] && $_GET['gc_seme']) {
  $gc_year = $_GET['gc_year'];
  $gc_seme=$_GET['gc_seme'];
} else {
  $gc_year = $curr_year;
  $gc_seme=$curr_seme;
}

if ($gc_seme==2) {
  $last_year = $gc_year;
  $last_seme=1;
} else {
  $last_year=$gc_year-1;
  $last_seme=2;
}

$last_link= $_SERVER['PHP_SELF']. '?id='.$_GET['id'].'&gc_year='. $last_year.'&gc_seme='.$last_seme;


echo '<p align=center>';
if ($gc_year==$curr_year && $gc_seme==$curr_seme) {
// skip
} else {
  echo '<a href='.$curr_link.'>本學期</a> ';
}
echo $gc_year.'學年第'.$gc_seme.'學期轉出一覽表 <a href='.$last_link.'>前一學期</a> </p>';

/**** 建立XOOPS資料庫物件 ****/

$xoopsDB =& Database::getInstance();

/**** 輸出表格開頭 ****/
echo "<table cellSpacing=1 cellPadding=1 align=center bgColor=#ccccff border=1>
<TR>
<TD><Font Color=white>序號</Font></TD>
<TD><Font Color=white>現在年級</Font></TD>
<TD><Font Color=white>現在班級</Font></TD>
<TD><Font Color=white>現在座號</Font></TD>
<TD><Font Color=white>學號</Font></TD>
<TD><Font Color=white>學生姓名</Font></TD>
<TD><Font Color=white>學生生日</Font></TD>
<TD><Font Color=white>證照號碼</Font></TD>
<TD><Font Color=white>異動日期</Font></TD>
<TD><Font Color=white>學校</Font></TD>

</TR>";
$order="order by smb_grad,ABS(smb_class),smb_seat";
$cond="and (stud_study_cond='轉出' or stud_study_cond='出國') ";
$ta = $xoopsDB->prefix("sxs_stud_base");
$tb = $xoopsDB->prefix("sxs_stud_seme_base");
$sql="SELECT smb_sn,smb_grad,smb_class,smb_seat,stud_id,stud_name,stud_birth,stud_person_id from $ta a,$tb b where a.stud_sn=b.stud_sn and smb_year='$gc_year' and smb_seme='$gc_seme' $cond $order";
/**** 執行 SQL語法 ****/
$result = $xoopsDB->query($sql) ;
$sn=0;
while(list($smb_sn,$smb_grad,$smb_class,$smb_seat,$stud_id,$stud_name,$stud_birth,$stud_person_id)=$xoopsDB->fetchRow($result)){

$sql2="select move_y,move_m,move_d,move_school_name from ". $xoopsDB->prefix("sxs_stud_move")." where smb_sn='$smb_sn' order by move_sn desc";

$rs2=$xoopsDB->query($sql2) ;

list($y,$m,$d,$move_school_name)=$xoopsDB->fetchRow($rs2);

$sn++;
echo "<tr bgcolor=white>
<td>{$sn}</td>
<td>{$smb_grad}</td>
<td>{$smb_class}</td>
<td>{$smb_seat}</td>
<td>{$stud_id}</td>
<td>{$stud_name}</td>
<td>{$stud_birth}</td>
<td>{$stud_person_id}</td>
<td>{$y}-{$m}-{$d}</td>
<td>{$move_school_name}</td>

</tr>";
}
echo "</table>";


沒有留言:

張貼留言