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>";


2017年10月8日 星期日

ITYCX 定位

本來已經不想處理學務系統了

但是有鑑於私立學校還有部分學校要使用,決定再出新版X學務系統的計畫

1. 相容於原來的資料庫,唯一要處理的是Xoop本身

系統需求
Xoops 2.5.8
Mysql 5.0 以上 使用 Mysqli
使用 bootstrap相容樣板
PHP 5.5以上 建議PHP5.6
centOS安裝參考 
  https://webtatic.com/packages/php56/
  https://www.cadch.com/modules/news/article.php?storyid=227

2. 建立一個專用樣板

3. 改善學生資料結構

4. 改用Mysqli

5. 盡量用ajax取代全螢幕的變化

2017年10月7日 星期六

字串轉數值、數值轉字串


字串轉數值

方法一: Number constructor function
var e = '123';
e = Number(e);   // 123

方法二: parseInt() 或 parseFloat()
var e = '123.45abc';
var e1 = parseInt(e, 10);  // 123
var e2 = parseFloat(e);    // 123.45

若無法轉換成數值時,會回傳 NaN (Not A Number)。
var f = 'abc123';
var f1 = Number(f);         // NaN
var f2 = parseInt(f, 10);  // NaN
var f3 = parseFloat(f);    // NaN

數值轉字串

var a=10; a = String(a); alert(typeof a);
var a=10; a = a.toString(); alert (typeof a);

Javascript 參考文

先連結別人的網誌、以後再做自己的

1. 初體驗
2. 變數與常數
3. 基礎資料型態
4. Null undefined
5. parseInt()、parseFloat() 與 Number()
6. 基礎型態轉換
7. 簡單敘述與運算子 、 運算子 (Operator)
8. 邏輯運算子2 、 邏輯運算子1
9. 關係運算子
10. 位元運算子
11. 字串與數字的相乘與相加
12. 字串轉數值、數值轉字串
13. Math ,數學物件 ,數學 (Math)
14. Random
15. 函數 (Function)
16. 事件 (Event)
17. 流程控制 (Flow Control)
18. DOM BOM
19. 視窗 (Window)
20.
21.
22.




範例
1. 利用setTimeout(setInterval)做簡易倒數計時器
2. 手工萬年曆
3. 倒字 flip text
4.
5.
6.
7.
8.
9.
10.





jQuery的載入事件先後


在jQuery中,要做到"等網頁載入後再執行",我們有兩種選擇:
$(document).ready(fn)與$(window).load(fn)
二者的差別在於$(document).ready(fn)發生在"網頁本身的HTML"載入後就觸發,而$(window).load(fn)則會等到"網頁HTML標籤中引用的圖檔、內嵌物件(如Flash)、IFrame"等拉哩拉雜的東西都載入後才會觸發。

來源: http://blog.darkthread.net/post-2009-06-05-jquery-ready-vs-load.aspx

瀏覽器物件(5)Location

Location Object Properties

PropertyDescription
hashSets or returns the anchor part (#) of a URL
hostSets or returns the hostname and port number of a URL
hostnameSets or returns the hostname of a URL
hrefSets or returns the entire URL
originReturns the protocol, hostname and port number of a URL
pathnameSets or returns the path name of a URL
portSets or returns the port number of a URL
protocolSets or returns the protocol of a URL
searchSets or returns the querystring part of a URL

Location Object Methods

MethodDescription
assign()Loads a new document
reload()Reloads the current document
replace()Replaces the current document with a new one

瀏覽器物件(4)History

History Object Properties

PropertyDescription
lengthReturns the number of URLs in the history list

History Object Methods

MethodDescription
back()Loads the previous URL in the history list
forward()Loads the next URL in the history list
go()Loads a specific URL from the history list

瀏覽器物件(3)Screen

Screen Object Properties

PropertyDescription
availHeightReturns the height of the screen (excluding the Windows Taskbar)
availWidthReturns the width of the screen (excluding the Windows Taskbar)
colorDepthReturns the bit depth of the color palette for displaying images
heightReturns the total height of the screen
pixelDepthReturns the color resolution (in bits per pixel) of the screen
widthReturns the total width of the screen

2017年10月6日 星期五

瀏覽器物件(2)Navigator

Navigator Object Properties

PropertyDescription
appCodeNameReturns the code name of the browser
appNameReturns the name of the browser
appVersionReturns the version information of the browser
cookieEnabledDetermines whether cookies are enabled in the browser
geolocationReturns a Geolocation object that can be used to locate the user's position
languageReturns the language of the browser
onLineDetermines whether the browser is online
platformReturns for which platform the browser is compiled
productReturns the engine name of the browser
userAgentReturns the user-agent header sent by the browser to the server





瀏覽器物件(1) Window

Window Object Properties

PropertyDescription
closedReturns a Boolean value indicating whether a window has been closed or not
defaultStatusSets or returns the default text in the statusbar of a window
documentReturns the Document object for the window (See Document object)
frameElementReturns the <iframe> element in which the current window is inserted
framesReturns all <iframe> elements in the current window
historyReturns the History object for the window (See History object)
innerHeightReturns the inner height of a window's content area
innerWidthReturns the inner width of a window's content area
lengthReturns the number of <iframe> elements in the current window
localStorageAllows to save key/value pairs in a web browser. Stores the data with no expiration date
locationReturns the Location object for the window (See Location object)
nameSets or returns the name of a window
navigatorReturns the Navigator object for the window (See Navigator object)
openerReturns a reference to the window that created the window
outerHeightReturns the outer height of a window, including toolbars/scrollbars
outerWidthReturns the outer width of a window, including toolbars/scrollbars
pageXOffsetReturns the pixels the current document has been scrolled (horizontally) from the upper left corner of the window
pageYOffsetReturns the pixels the current document has been scrolled (vertically) from the upper left corner of the window
parentReturns the parent window of the current window
screenReturns the Screen object for the window (See Screen object)
screenLeftReturns the horizontal coordinate of the window relative to the screen
screenTopReturns the vertical coordinate of the window relative to the screen
screenXReturns the horizontal coordinate of the window relative to the screen
screenYReturns the vertical coordinate of the window relative to the screen
sessionStorageAllows to save key/value pairs in a web browser. Stores the data for one session
scrollXAn alias of pageXOffset
scrollYAn alias of pageYOffset
selfReturns the current window
statusSets or returns the text in the statusbar of a window
topReturns the topmost browser window


Window Method
MethodDescription
alert()Displays an alert box with a message and an OK button
atob()Decodes a base-64 encoded string
blur()Removes focus from the current window
btoa()Encodes a string in base-64
clearInterval()Clears a timer set with setInterval()
clearTimeout()Clears a timer set with setTimeout()
close()Closes the current window
confirm()Displays a dialog box with a message and an OK and a Cancel button
focus()Sets focus to the current window
getComputedStyle()Gets the current computed CSS styles applied to an element
getSelection()Returns a Selection object representing the range of text selected by the user
matchMedia()Returns a MediaQueryList object representing the specified CSS media query string
moveBy()Moves a window relative to its current position
moveTo()Moves a window to the specified position
open()Opens a new browser window
print()Prints the content of the current window
prompt()Displays a dialog box that prompts the visitor for input
resizeBy()Resizes the window by the specified pixels
resizeTo()Resizes the window to the specified width and height
scroll()Deprecated. This method has been replaced by the scrollTo() method.
scrollBy()Scrolls the document by the specified number of pixels
scrollTo()Scrolls the document to the specified coordinates
setInterval()Calls a function or evaluates an expression at specified intervals (in milliseconds)
setTimeout()Calls a function or evaluates an expression after a specified number of milliseconds
stop()Stops the window from loading