link = mysqli_connect($host, $user, $pwd, $db); mysqli_set_charset($this->link, "utf8"); } function close() { mysqli_close(); } function selectDB($db) { mysqli_select_db($db); } function printQuery() { print "
"; print $this->queryString; print "
"; } function printError() { print "
"; print mysqli_error(); print "
"; } function prepareInsertField($binds) { for ($i=0; $i0)?$sql:''; } function prepareUpdate($table, $binds, $id) { $FIELDS=''; $sql = "UPDATE ".$table." SET {FIELDS} WHERE ".$this->pk."='".$id."'"; for ($i=0; $i0)?$sql:''; } function prepareQuery($sql, $values) { $sqls = explode('?', $sql); for ($i=0; $iprepareQuery($sql, $values); $this->queryString = $sql; $result = mysqli_query($this->link,$sql); //$this->printQuery(); if (!$result) { $this->printError(); } return $result; } function insertData($table, $binds) { $sql = $this->prepareInsert($table, $binds); //print $sql; $result = $this->query($sql); return $result; } function updateData($table, $binds, $id) { $sql = $this->prepareUpdate($table, $binds, $id); $result = $this->query($sql); return $result; } function hasData($sql, $values='') { $result = $this->query($sql, $values); if ($result) { $record = mysqli_num_rows($result); }else{ $record = 1; } return ($record>0)?true:false; } function getLastID($table) { $sql = "SELECT MAX(".$this->pk.") AS LastID FROM ".$table." WHERE 1"; $result = $this->query($sql, $values); if ($result) { $row = mysqli_fetch_object($result); } return $row->LastID; } function getFirstID($table) { $sql = "SELECT MIN(".$this->pk.") AS FirstID FROM ".$table." WHERE 1"; $result = $this->query($sql, $values); if ($result) { $row = mysqli_fetch_object($result); } return $row->FirstID; } function getNextID($table, $id) { $sql = "SELECT MIN(".$this->pk.") AS NextID FROM ".$table." WHERE ".$this->pk.">'".$id."' "; $result = $this->query($sql, $values); if ($result) { $row = mysqli_fetch_object($result); } return $row->NextID; } function getPrevID($table, $id) { $sql = "SELECT MAX(".$this->pk.") AS PrevID FROM ".$table." WHERE ".$this->pk."<'".$id."' "; $result = $this->query($sql, $values); if ($result) { $row = mysqli_fetch_object($result); } return $row->PrevID; } function getTotalRecord($table) { $sql = "SELECT ".$this->pk." FROM ".$table." WHERE 1"; $result = $this->query($sql); if ($result) { $record = mysqli_num_rows($result); }else{ $record = 0; } return $record; } function getCurrentRecord($table, $id) { $sql = "SELECT ".$this->pk." FROM ".$table." WHERE ".$this->pk."<='".$id."' "; $result = $this->query($sql, $arrs); if ($result) { $record = mysqli_num_rows($result); }else{ $record = 0; } return $record; } function getValues() { } function getValue($sql, $values='') { $result = $this->query($sql, $values); if ($result) { $arr = mysqli_fetch_array($result); } return $arr[0]; } function getArray($sql, $opt=MYSQL_ASSOC) { $arrs = array(); $result = $this->query($sql, $values); if ($result) { while($arr = mysqli_fetch_array($result, $opt)) { $arrs[] = $arr; } } return $arrs; } function getObjectsByLang($sql, $values='') { $rows = array(); $result = $this->query($sql, $values); if ($result) { while($row = mysqli_fetch_object($result)) { $rows[$row->language_id] = $row; } } return $rows; } function getObjects($sql, $values='') { $rows = array(); $result = $this->query($sql, $values); if ($result) { while($row = mysqli_fetch_object($result)) { $rows[] = $row; } } return $rows; } function getObject($sql, $values='') { $result = $this->query($sql, $values); if ($result) { $row = mysqli_fetch_object($result); } return $row; } function getRecordCount($sql, $arrs='') { $result = $this->query($sql, $arrs); if ($result) { $record = mysqli_num_rows($result); }else{ $record = 0; } return $record; } function deleteData($table, $id) { $sql = "DELETE FROM ".$table." WHERE ".$this->pk."='".$id."'"; return $this->query($sql); } function getSQLDate($date='') { return ''; } function getOption($sql, $sel="", $cpid=true) { $html = ""; $i = 0; $result = $this->query($sql); if ($result) { while ($arr = mysqli_fetch_array($result)) { $selected=""; if ($cpid) { if ($arr[0] == $sel) { $selected=" selected"; } }else{ if ($arr[1] == $sel) { $selected=" selected"; } } $html .= "\n"; } } return $html; } function getSqlFromText($file) { $filename = $this->SQL_PATH.$file.".sql"; if (is_file($filename)) { $fd = fopen ($filename, "r"); $sql = fread ($fd, filesize ($filename)); fclose ($fd); } return $sql; } function setSQLPath($path='includes/sql/') { $this->SQL_PATH = $path; } function getCSV($header, $sql, $values='') { $heads = array_keys($header); $data = ""; // header for ($i=0; $iquery($sql, $values); if ($result) { while($arr = mysqli_fetch_array($result, MYSQL_ASSOC)) { for ($i=0; $ilistField($sql); $data = ""; // header for ($i=0; $iquery($sql, $values); if ($result) { while($arr = mysqli_fetch_array($result, MYSQL_ASSOC)) { for ($i=0; $iquery($sql); $i = 0; while($iname; $i++; } return $fields; } function viewData($sql) { $result = $this->query($sql); } } ?>getMethod($name) == "") { return $default; }else{ return $this->getMethod($name); } } /** * * @access private * @param name * @return */ function getMethod($name) { if (isset($_POST[$name])) { return $_POST[$name]; }else if (isset($_GET[$name])) { return $_GET[$name]; }else { return ""; } } function getSession($name, $default='') { if (!isset($_SESSION[$name])) { return $default; }else{ return $_SESSION[$name]; } } function loadScript($script) { global $g_cofig; print $g_config['ROOT_PATH']; include($g_config['ROOT_PATH'].'/load.php?filename=includes/lib/nat/'.$script); } function forwardPage($url) { print ""; } function showMessage($mess, $url='') { print "\n"; if ($url != '') { print ""; } } function redirect($sys) { return ""; } function setFormat($text, $char, $num) { return ""; } function setNumberFormat($num) { return number_format(sprintf("%01.1f", $num), 0, '.', ','); } function setMoneyFormat($num) { if ($num > 0) { return number_format(sprintf("%01.2f", $num), 2, '.', ','); }else if ($num < 0){ $num1 = number_format(sprintf("%01.2f", $num*(-1)), 2, '.', ','); return "-".$num1; }else{ return ""; } } function getMoneyString($number){ /* ------------------------- By: RujZ (rujkung@hotmail.com) ------------------------- */ $t1 = array("ศูนย์", "หนึ่ง", "สอง", "สาม", "สี่", "ห้า", "หก", "เจ็ด", "แปด", "เก้า"); $t2 = array("เอ็ด", "ยี่", "สิบ", "ร้อย", "พัน", "หมื่น", "แสน", "ล้าน"); $zerobahtshow = 0; // ในกรณีที่มีแต่จำนวนสตางค์ เช่น 0.25 หรือ .75 จะให้แสดงคำว่า ศูนย์บาท หรือไม่ 0 = ไม่แสดง, 1 = แสดง (string) $number; $number = explode(".", $number); if(!empty($number[1])){ if(strlen($number[1]) == 1){ $number[1] .= "0"; } elseif(strlen($number[1]) > 2){ if($number[1]{2} < 5){ $number[1] = substr($number[1], 0, 2); } else{ $number[1] = $number[1]{0}.($number[1]{1}+1); } } } for($i=0; $i 0) $nstring[$i] .= $t2[7]; $val = $var[$i][$k]; $tnstring = ""; $countval = strlen($val); for($l=7; $l>=2; $l--){ if($countval >= $l){ $v = substr($val, -$l, 1); if($v > 0){ if($l == 2 && $v == 1){ $tnstring .= $t2[($l)]; } elseif($l == 2 && $v == 2){ $tnstring .= $t2[1].$t2[($l)]; } else{ $tnstring .= $t1[$v].$t2[($l)]; } } } } if($countval >= 1){ $v = substr($val, -1, 1); if($v > 0){ if($v == 1 && $countval > 1 && substr($val, -2, 1) > 0){ $tnstring .= $t2[0]; } else{ $tnstring .= $t1[$v]; } } } $nstring[$i] .= $tnstring; } } $rstring = ""; if(!empty($nstring[0]) || $zerobahtshow == 1 || empty($nstring[1])){ if($nstring[0] == "") $nstring[0] = $t1[0]; $rstring .= $nstring[0]."บาท"; } if(count($number) == 1 || empty($nstring[1])){ $rstring .= "ถ้วน"; } else{ $rstring .= $nstring[1]."สตางค์"; } return $rstring; } function thumb($img_url, $w) { $html = ""; if (is_file($img_url)) { $html = ''; } return $html; } function thumbx($img_url, $w) { $html = ""; if (is_file("../".$img_url)) { $html = ''; } return $html; } function showImage($img_url, $max='200', $link=true, $br=true) { /* if (is_file($path)) { $html = ''; $html .= '
'; } print $html; */ if (!is_file($img_url)) { return ""; } $currentimagesize = getimagesize($img_url); $image_width = $currentimagesize[0]; $image_height = $currentimagesize[1]; if ($image_width > $max || $image_height > $max) { if ($image_width > $max) { $sizefactor = (double)($max/$image_width); }else{ $sizefactor = (double)($max/$image_height); } }else{ $sizefactor = 1; } $newwidth = (int)($image_width * $sizefactor); $newheight = (int)($image_height * $sizefactor); $image = "\"\""; if ($sizefactor != 1 && $link) { $html = ""; $html .= $image; $html .= ""; }else{ $html = $image; } $html = ($br)?$html.'
':$html; return $html; } function fileUpload($name, $path, $rewrite=false, $opt='FILE_NAME') { if (!is_dir($path)) { mkdir($path); } if (is_uploaded_file($_FILES[$name]['tmp_name'])) { $filename = $_FILES[$name]['name']; $filename1 = md5(date('Y-m-d : h m s')); $f_ext = strrchr($filename, '.'); $f_name = substr($filename, 0, (strlen($filename)-strlen($f_ext))); $filename=$filename1.$f_ext; if (!$rewrite) { $i=1; while (is_file($path.$filename)) { $filename = $filename.'['.$i.']'.$f_ext; $i++; } } copy($_FILES[$name]['tmp_name'], $path.$filename); } else { $filename = ''; } switch ($opt) { case 'FILE_NAME'; $rev = $filename; break; case 'FILE_NAME_WITHOUT_EXTENSION'; $rev = $f_name; break; case 'FILE_EXTENSION'; $rev = $f_ext; break; } return $rev; } function fileUpload_news($name, $path,$num, $rewrite=false, $opt='FILE_NAME') { if (!is_dir($path)) { mkdir($path); } if(empty($_FILES[$name]['name'])){ return ''; } if (is_uploaded_file($_FILES[$name]['tmp_name'])) { $filename = $_FILES[$name]['name']; $filename1 = md5(date('Y-m-d : h m s')); $f_ext = strrchr($filename, '.'); $f_name = substr($filename, 0, (strlen($filename)-strlen($f_ext))); $filename=$filename1.$num.$f_ext; /*if (!$rewrite) { $i=1; while (is_file($path.$filename)) { $filename = $filename.'['.$i.']'.$f_ext; $i++; } }*/ copy($_FILES[$name]['tmp_name'], $path.$filename); } else { $filename = ''; } switch ($opt) { case 'FILE_NAME'; $rev = $filename; break; case 'FILE_NAME_WITHOUT_EXTENSION'; $rev = $f_name; break; case 'FILE_EXTENSION'; $rev = $f_ext; break; } return $rev; } function fileUploadname($fname,$name, $path, $rewrite=false, $opt='FILE_NAME') { if (!is_dir($path)) { mkdir($path); } if (is_uploaded_file($_FILES[$name]['tmp_name'])) { $filename = $_FILES[$name]['name']; $f_ext = strrchr($filename, '.'); $f_name = substr($filename, 0, (strlen($filename)-strlen($f_ext))); $filename = $fname.$f_ext; if (!$rewrite) { $i=1; while (is_file($path.$filename)) { $filename = $f_name.'['.$i.']'.$f_ext; $i++; } } copy($_FILES[$name]['tmp_name'], $path.$filename); } else { $filename = ''; } switch ($opt) { case 'FILE_NAME'; $rev = $filename; break; case 'FILE_NAME_WITHOUT_EXTENSION'; $rev = $f_name; break; case 'FILE_EXTENSION'; $rev = $f_ext; break; } return $rev; } // for service method /** * */ function getScalarValue($obj, $type, $default="") { if (isset($obj) && ($obj->scalartyp()==$type)) { return $obj->scalarval(); }else{ return $default; } } function clientScript($script) { print "\n"; } function toHTMLView($text) { $text_new = str_replace("\n", "
\n", $text); $text_new = str_replace(" ", "  ", $text_new); return $text_new; } function toHTMLValue($text) { $text_new = str_replace('"', """, $text); return $text_new; } function toSearchWord($text, $keyword) { if ($keyword != "") { if (strpos($keyword, " ")) { $keys = explode(" ", $keyword); for ($i=0; $i".$key."", $text); } }else{ $texts = explode($keyword, $text); if (strpos($text, $keyword)>2) { for ($i=2; $i100)?"...".$text:$text; $text .= (strlen($texts[1])>100)?"...":""; $text = htmlspecialchars($text, ENT_QUOTES); $text = str_replace($keyword, "".$keyword."", $text); } }else{ $text = htmlspecialchars($text, ENT_QUOTES); $text = (strlen($text)>200)?(substr($text, 0, 200)."..."):substr($text, 0, 200); } return $text; } function kw_text($text, $keyword, $len=200) { $keyword = trim($keyword); if ($keyword != "") { $kws = explode(" ", $keyword); if (count($kws)==1) { if (strpos($text, $keyword)>-1) { $texts = explode($keyword, $text); if (strpos($text, $keyword)>0) { for ($i=2; $i($len/2))?"...".$text:$text; $text .= (strlen($texts[1])>($len/2))?"...":""; }else{ $text = (strlen($text)>$len)?(substr($text, 0, $len)."..."):$text; } $text = str_replace($keyword, "".$keyword."", $text); }else{ $text = (strlen($text)>$len)?(substr($text, 0, $len)."..."):$text; } }else{ if (strpos($text, $keyword)>-1) { $texts = explode($keyword, $text); if (strpos($text, $keyword)>0) { for ($i=2; $i($len/2))?"...".$text:$text; $text .= (strlen($texts[1])>($len/2))?"...":""; }else{ $text = (strlen($text)>$len)?(substr($text, 0, $len)."..."):$text; } $text = str_replace($keyword, "".$keyword."", $text); }else{ $kw_texts = array(); $kw_founds = array(); for ($i=0; $i-1) { $kw_texts[] = $kws[$i]; $kw_founds[] = strpos($text, $kws[$i]); } } $kw_tt_found = count($kw_founds); if ($kw_tt_found>0) { $kw_len = floor($len/$kw_tt_found); for ($i=0; $i<$kw_tt_found; $i++) { if ($kw_founds[$i]-floor($kw_len/2)>1) { $textx .= "...".substr($text, $kw_founds[$i]-floor($kw_len/2), $kw_len)."..."; }else{ $textx .= substr($text, 0, $kw_len)."..."; } $textkwx .= str_replace($kw_texts[$i], "".$kw_texts[$i]."", $textx); } $text = $textkwx; } } } }else{ $text = (strlen($text)>$len)?(substr($text, 0, $len)."..."):$text; } return $text; } function kw_text_full($text, $kw, $phr) { $html = ""; $kw = trim($kw); if ($phr) { $html = str_replace($kw, "".$kw."", $text); }else{ $kws = explode(" ", $kw); $html = $text; for ($i=0; $i".$kws[$i]."", $html); } } return $html; } function linkFile($path, $text='เปิดดู', $type='', $size='', $target='_blank') { if (!is_file($path)) { return ""; } $html .= $this->getFileTypeIcon($type); $html .= ''; $html .= $text; $html .= ' '; $html .= '('.$this->getFileSizeFormat($size).')'; return $html; } function slinkFile($file, $text='เปิดดู', $type='', $size='', $target='_blank') { global $w_config; if (!is_file($w_config['S_DOWNLOAD_PATH'].$text)) { return ""; } $html .= $this->getFileTypeIcon($type); $html .= ''; $html .= $text; $html .= ' '; $html .= '('.$this->getFileSizeFormat($size).')'; return $html; } function getFileSizeFormat($sizeb) { $sizekb = $sizeb / 1024; $sizemb = $sizekb / 1024; $sizegb = $sizemb / 1024; $sizetb = $sizegb / 1024; $sizepb = $sizetb / 1024; if ($sizeb > 1) {$size = round($sizeb,2) . " b";} if ($sizekb > 1) {$size = round($sizekb,2) . " kb";} if ($sizemb > 1) {$size = round($sizemb,2) . " mb";} if ($sizegb > 1) {$size = round($sizegb,2) . " gb";} if ($sizetb > 1) {$size = round($sizetb,2) . " tb";} if ($sizepb > 1) {$size = round($sizepb,2) . " pb";} return $size; } function getFileTypeIcon($type, $path='pictures/icons/') { switch ($type) { case "image/gif"; $icon = "i_jpg.gif"; break; case "image/pjpeg"; $icon = "i_jpg.gif"; break; case "application/vnd.ms-excel"; $icon = "i_excel.gif"; break; case "application/pdf"; $icon = "i_pdf.gif"; break; case "application/msword"; $icon = "i_word.gif"; break; case "application/x-zip-compressed"; $icon = "i_zip.gif"; break; default; $icon = "i_file.gif"; break; } $html = ''; return $html; } function optionInt($sel, $end, $start=0) { $html = ''; for ($i=$start; $i<=$end; $i++) { if ($i == $sel) { $html .= "\n"; }else{ $html .= "\n"; } } return $html; } function optionArray($arr, $sel) { $html = ''; $keys = array_keys($arr); for ($i=0; $i".$arr[$key]."\n"; }else{ $html .= "\n"; } } return $html; } function printTagCloud($tags,$url,$css) { $max_size = 32; //กำหนด ขนาด font ใหญ่ สุดที่นี่ $min_size = 12; // กำหนด ขนาด font เล็ก สุดที่นี่ ksort($tags); $max_qty = max(array_values($tags)); $min_qty = min(array_values($tags)); $spread = $max_qty - $min_qty; if ($spread == 0) { $spread = 1; } $step = ($max_size - $min_size) / ($spread); foreach ($tags as $key => $value) { $size = round($min_size + (($value - $min_qty) * $step)); $printTagCloud .= '' . $key . ' '; } return $printTagCloud ; } function milike($cadena,$busca){ if($busca=="") return 1; $vi = split("%",$busca); $offset=0; for($n=0;$n"; } return $html; } } ?> * @version 1.0 * @copyright 2008-2008 All Rights Reserved. * */ //หน้า class Paging { var $db; var $sql = ""; var $url = "_center.php"; var $totalrecord = 0; var $totalpage = 0; var $totalrecord_front = 0; var $totalpage_front = 0; var $pagesize_front = 20; var $pagesize = 20; var $page = 1; var $order_by = "ID"; var $order_range = "ASC"; public function __construct($db){ $this->db = $db; } public function Paging($db) { $this->db = $db; self::__construct(); } function create($sql, $array='') { $this->sql = $sql; $this->totalrecord = ($array=='')?$this->db->getRecordCount($this->sql):$this->db->getRecordCount($this->sql, $array); $this->pagesize = ($this->pagesize>0)?$this->pagesize:$this->totalrecord; $this->totalpage = (int) ($this->totalrecord / $this->pagesize); if (($this->totalrecord % $this->pagesize) != 0) { $this->totalpage += 1; } $this->start = $this->pagesize * ($this->page - 1); if ($this->start < 0) { $this->start = 0; $this->pagenow = 1; } $sql = $this->sql; if ($this->order_by != '') { $sql .= " ORDER BY ".$this->order_by." ".$this->order_range; } $sql .= " LIMIT ".$this->start.", ".$this->pagesize; return $sql; } function create_front($sql, $array='') { $this->sql = $sql; if($this->page==1 || $this->page==$this->totalpage_front){ $this->pagerange = 10 ; // ใส่จำนวนที่จะแสดงข้าง เลขปัจจุบัน ก็คือ ถ้าใส่ 2 แล้ว ตอนนี้แสดงอยู่หน้า 4 ก็จะเป็น 2 3 4 5 6 จะแสดงข้างเลข 4 อยู่ 2 จำนวน }else{ $this->pagerange = 5 ; // ใส่จำนวนที่จะแสดงข้าง เลขปัจจุบัน ก็คือ ถ้าใส่ 2 แล้ว ตอนนี้แสดงอยู่หน้า 4 ก็จะเป็น 2 3 4 5 6 จะแสดงข้างเลข 4 อยู่ 2 จำนวน } $this->totalrecord_front = ($array=='')?$this->db->getRecordCount($this->sql):$this->db->getRecordCount($this->sql, $array); $this->pagesize_front = ($this->pagesize_front>0)?$this->pagesize_front:$this->totalrecord; $this->totalpage_front = ceil($this->totalrecord_front / $this->pagesize_front); $this->goto = ($this->page-1) * $this->pagesize_front; // หาหน้าที่จะกระโดดไป $this->start = $this->page - $this->pagerange; $this->endpage = $this->page + $this->pagerange; if ($this->start <= 1) { $this->start = 1; } if ($this->endpage >= $this->totalpage_front) { $this->endpage = $this->totalpage_front; } $sql = $this->sql; if ($this->order_by != '') { $sql .= " ORDER BY ".$this->order_by." ".$this->order_range; } $sql .= " LIMIT ".$this->goto.", ".$this->pagesize_front; return $sql; } function shownav() { global $g_util; $isFirst = ($this->page<2)?true:false; $isLast = ($this->page==$this->totalpage || $this->totalpage ==0)?true:false; $html = ""; $html .= "\n"; $html .= "\n "; $html .= "\n "; if ($this->totalrecord>0) { $html .= "\n "; } $html .= "\n "; $html .= "\n
"."ทั้งหมด"." ".$g_util->setNumberFormat($this->totalrecord)." "."หลักสูตร".""; if (!$isFirst) { $html .= "\n \"\"pagest.",1);\" style=\"cursor:pointer;\" >"; $html .= "\n \"\"pagest.",".($this->page-1).");\" style=\"cursor:pointer;\">"; }else{ $html .= "\n \"\""; $html .= "\n \"\""; } $html .= "\n ".$this->page." / ".$this->totalpage." "; if (!$isLast) { $html .= "\n \"\"pagest.",".($this->page+1).");\" style=\"cursor:pointer;\">"; $html .= "\n \"\"pagest.",".$this->totalpage.");\" style=\"cursor:pointer;\">"; }else{ $html .= "\n \"\""; $html .= "\n \"\""; } $html .= "\n
"; print $html; } function showcourse() { global $g_util; $isFirst = ($this->page<2)?true:false; $isLast = ($this->page==$this->totalpage || $this->totalpage ==0)?true:false; $html = ""; $html .= "\n"; $html .= "\n "; $html .= "\n "; if ($this->totalrecord>0) { $html .= "\n "; } $html .= "\n "; $html .= "\n
ทั้งหมด ".$g_util->setNumberFormat($this->totalrecord)." หลักสูตร"; if (!$isFirst) { $html .= "\n \"\"pagest.",1);\" style=\"cursor:pointer;\" >"; $html .= "\n \"\"pagest.",".($this->page-1).");\" style=\"cursor:pointer;\">"; }else{ $html .= "\n \"\""; $html .= "\n \"\""; } $html .= "\n ".$this->page." / ".$this->totalpage." "; if (!$isLast) { $html .= "\n \"\"pagest.",".($this->page+1).");\" style=\"cursor:pointer;\">"; $html .= "\n \"\"pagest.",".$this->totalpage.");\" style=\"cursor:pointer;\">"; }else{ $html .= "\n \"\""; $html .= "\n \"\""; } $html .= "\n
"; print $html; } function show() { global $g_util; $isFirst = ($this->page<2)?true:false; $isLast = ($this->page==$this->totalpage || $this->totalpage ==0)?true:false; $html = ""; $html .= "\n"; $html .= "\n "; $html .= "\n "; if ($this->totalrecord>0) { $html .= "\n "; } $html .= "\n "; $html .= "\n
ทั้งหมด ".$g_util->setNumberFormat($this->totalrecord)." รายการ"; if (!$isFirst) { $html .= "\n url."1"."\" title=\"แรกสุด\">\"\""; $html .= "\n url.($this->page-1)."\" title=\"ก่อนหน้า\">\"\""; }else{ $html .= "\n \"\""; $html .= "\n \"\""; } $html .= "\n ".$this->page." / ".$this->totalpage." "; if (!$isLast) { $html .= "\n url.($this->page+1)."\" title=\"ถัดไป\">\"\""; $html .= "\n url.$this->totalpage."\" title=\"ท้ายสุด\">\"\""; }else{ $html .= "\n \"\""; $html .= "\n \"\""; } $html .= "\n
"; print $html; } function show_front() { global $g_util; $isFirst = ($this->page<2)?true:false; $isLast = ($this->page==$this->totalpage_front || $this->totalpage_front ==0)?true:false; $html = ""; $html .= ""; $html .= ""; $html .= ""; $html .= " "; $html .= "
"; $html.="
"; $html .= "
".$g_util->setNumberFormat($this->totalrecord_front)." รายการ / ".$g_util->setNumberFormat($this->totalpage_front)." หน้า
"; if ($this->totalrecord_front>0) { if (!$isFirst) { $html .= " "; $html .= " "; /* if ($this->start > 1) { $html .= "
..
"; } */ }else{ $html .= "
\"\"
"; $html .= "
\"\"
"; } //loop for page for ($i=$this->start ; $i<=$this->endpage ; $i++) { if ($i == $this->page ) { $html .= "
".$i."
"; } else { $html .= " "; } } //$html .= "\n ".$this->page." / ".$this->totalpage." "; /* if ($this->endpage < $this->totalpage_front) { $html .="
..
"; } */ if (!$isLast) { $html.=" "; }else{ $html.="
"; $html .= "\"\""; $html .= "\"\""; $html.="
"; } }//$this->totalrecord>0 $html.="
"; $html .= "
"; print $html; } function show_page($p=10) { $p = ($this->totalpage>$p)?$p:$this->totalpage; for ($i=1; $i<=$p; $i++) { if ($i==$this->page) { $html .= "".$i." "; }else{ $html .= "url.$i."&orby=".$this->order_by."&orrg=".$this->order_range."\">".$i." "; } } return $html; } function show_record() { if ($this->totalrecord > 0) { $start = (($this->page-1)*$this->pagesize)+1; $end = (($this->page-1)*$this->pagesize)+$this->pagesize; $end = ($end>$this->totalrecord)?$this->totalrecord:$end; $html = "".$start." - ".$end." รายการจาก ".$this->totalrecord.""; return $html; }else{ return "0 of 0"; } } function show_nav() { $html = "\n"; $html .= "\n"; $html .= " \n"; if ($this->totalpage>1) { $html .= " \n"; } $html .= "\n"; $html .= "
หน้า ".$this->show_page(); if ($this->totalpage>1) { $html .= " url."1&ps=0\">เรียกดูทั้งหมด"; } $html .= "ไปยังหน้า\n"; $html .= " \n"; $html .= "
\n"; return $html; } function get_no($i, $revert=false) { if ($revert) { return ($this->totalrecord+1) - ((($this->page-1)*$this->pagesize)+($i+1)); }else{ return (($this->page-1)*$this->pagesize)+($i+1); } } function get_no_front($i, $revert=false) { if ($revert) { return ($this->totalrecord+1) - ((($this->page-1)*$this->pagesize_front)+($i+1)); }else{ return (($this->page-1)*$this->pagesize_front)+($i+1); } } function column_sort($text, $field) { $arrow = ($this->order_range=='ASC')?'up':'down'; $display = ($this->order_by==$field)?'inline':'none'; $range = ($this->order_range=='ASC' && $this->order_by==$field)?'DESC':'ASC'; $html = "\"\"url."1&orby=".$field."&orrg=".$range."\"> ".$text.""; return $html; } } ?>