<?php
if (!defined('GV32_COM')) exit('GV32.COM No direct script access allowed');
class Reply
{
	function Reply()
	{
	
	}
	
	function infolist()
	{
		$pageSize = 2 ;		
		$pageNum 	= $GLOBALS['Reque'] -> reqval["pageNum"];
		
		if( $pageNum > 1 )
		{
			$pageNum  = $pageNum;
			$LIMITnum = ceil( ( $pageNum -1 ) * $pageSize );
		}else{
			$pageNum  = 1;
			$LIMITnum = 0 ;
		}
		
		if($GLOBALS['Reque'] -> reqval["keyword"] !='')
		{   
			$keywordval 	= $GLOBALS['Reque'] -> reqval["keyword"];
			$keywordval  	= urldecode($keywordval); 
		}
		if($keywordval!='')
		{ 	
			$endArray["keyword"] =$keywordval;
			
			$endurl 	   .= '&keyword='.urlencode($keywordval);
			$whereadd .= " AND ( r.rep_desc LIKE  '%".$keywordval."%' )";  
		}
		
			
		$sqlQuery = " SELECT r.rep_id,  r.rep_desc, r.rep_enabled, r.rep_list ,t.thr_id ,t.thr_title FROM  ".SQL_PREFIX."reply as r left join ".SQL_PREFIX."thread as t on r.thr_id = t.thr_id  WHERE 1   $whereadd  GROUP BY r.rep_id ORDER BY r.`rep_id` LIMIT  $LIMITnum , $pageSize ";
		
		$info = $GLOBALS['MySql'] -> selectInfo($sqlQuery);
		
		$sqlQuery = " SELECT count(1) as LNUM  FROM  ".SQL_PREFIX."reply as r   WHERE 1 $whereadd   ORDER BY `rep_id`  ";
		
		$infocount = $GLOBALS['MySql'] -> selectOne($sqlQuery);
		//var_dump();
		$PageStr = $GLOBALS['Page']->buildPageStr( $url = '?load=reply&act=infolist', $pageNum  , $pageSize  , $resultCount = $infocount["LNUM"], $endArray);
		
		$GLOBALS['Templ']->assign('PageStr',$PageStr);
		$GLOBALS['Templ']->assign('info',$info);
		$GLOBALS['Templ']->display('reply_tpl.html');
		
		
	}

	
	function del( )
	{
		$infoid = $GLOBALS['Reque'] -> getval["id"];

		$insertip = " DELETE FROM `".SQL_PREFIX."reply` WHERE `rep_id` in ( $infoid ) ";
		$GLOBALS['MySql'] -> querySql($insertip);
		
		$GLOBALS['Templ'] -> assign('infomessage',$GLOBALS['_LANG']['bd_delsusse']);
		$GLOBALS['Templ'] -> assign('URL_TIME',URL_TIME);
		$GLOBALS['Templ'] -> assign('geturl',EMPLOYEE_WEBURL."/index.php?load=reply&act=infolist");
		$GLOBALS['Templ'] -> display('suggestion_tpl.html');
	}
	


		
}

//nmon_x86_rhel4


$Reply = new Reply();

?>