<?php
if (!defined('HUCART_COM')) exit('HuCart.COM No direct script access allowed');
class Reply
{
	function Reply()
	{
	
	}
	
	function info_list()
	{
		$page_size = 2 ;		
		$page_num 	= $this -> input ->  req["page_num"];
		
		if( $page_num > 1 )
		{
			$page_num  = $page_num;
			$limit_num = ceil( ( $page_num -1 ) * $page_size );
		}else{
			$page_num  = 1;
			$limit_num = 0 ;
		}
		
		if($this -> input ->  req["keyword"] !='')
		{   
			$keywordval 	= $this -> input ->  req["keyword"];
			$keywordval  	= urldecode($keywordval); 
		}
		if($keywordval!='')
		{ 	
			//$endArray["keyword"] =$keywordval;
			
			$endurl 	   .= '&keyword='.urlencode($keywordval);
			$whereadd .= " AND ( r.rep_desc LIKE  '%".$keywordval."%' )";  
		}
		
			
		$sql_query = " SELECT r.rep_id,  r.rep_desc, r.rep_enabled, r.rep_list ,t.thr_id ,t.thr_title FROM  ".$this -> db -> prefix."reply as r left join ".$this -> db -> 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  $limit_num , $page_size ";
		
		$info = $this -> db -> select_info($sql_query);
		
		$sql_query = " SELECT count(1) as LNUM  FROM  ".$this -> db -> prefix."reply as r   WHERE 1 $whereadd   ORDER BY `rep_id`  ";
		
		$infocount = $this -> db -> select_one($sql_query);
		//var_dump();
		$page_str = $this -> page ->get_admin_page( $url = '?load=reply&act=info_list', $page_num  , $page_size  , $result_count = $infocount["LNUM"], $endArray);
		
		$this -> view -> assign('page_str',$page_str);
		$this -> view -> assign('info',$info);
		$this -> view -> display('reply.tpl');
		
		
	}

	
	function del( )
	{
		$infoid = $this -> input ->  get["id"];

		$insertip = " DELETE FROM `".$this -> db -> prefix."reply` WHERE `rep_id` in ( $infoid ) ";
		$this -> db -> query_sql($insertip);
		
		$this -> view ->  assign('info_title',$this->lang['del_success']);
		$this -> view ->  assign('URL_TIME',URL_TIME);
		$this -> view ->  assign('get_url',ADMIN_WEBURL."/index.php?load=reply&act=info_list");
		$this -> view ->  display('suggestion.tpl');
	}
	


		
}

//


$Reply = new Reply();

?>