<?php
if (!defined('GV32_COM')) exit('GV32.COM No direct script access allowed');
class Leaveword
{
	function Leaveword()
	{
		//$GLOBALS['WebSe'] -> isOnLine();

		//$GLOBALS['Templ']->assign('actUrl',EMPLOYEE_WEBURL."/index.php/login/actlogin");
	}
	
	function infolist(  )
	{
		$pageSize = 20 ;		$pageNumval 	= $GLOBALS['Reque'] -> reqval["pageNum"];
		
		if( $pageNumval > 1 )
		{
			$pageNum  = $pageNumval;
			$LIMITnum = ceil( ( $pageNumval -1 ) * $pageSize );
		}else{
			$pageNum  = 1;
			$LIMITnum = 0 ;
		}

		$sqlQuery = " SELECT fm.lwd_id,fm.user_id,fm.user_name,fm.lwd_title,fm.lwd_type,fm.lwd_status,fm.lwd_content,fm.lwd_time,rm.lwd_id as rmlwd_id,rm.lwd_content as rmlwd_content,rm.admin_name as rmuser_name FROM leaveword as fm left join leaveword as rm on rm.lwd_parentid = fm.lwd_id  WHERE fm.lwd_parentid = 0  LIMIT  $LIMITnum , $pageSize ";
		
		$info = $GLOBALS['MySql'] -> selectInfo($sqlQuery);
		
		$sqlQuery = " SELECT count(1) as CNUM  FROM  leaveword  WHERE lwd_parentid = 0  ORDER BY `lwd_id`  ";
		
		$infocount = $GLOBALS['MySql'] -> selectOne($sqlQuery);
		
		//var_dump($info);
		
		$PageStr = $GLOBALS['Page']->buildPageStr( $url = '?load=leaveword&act=infolist', $pageNum  , $pageSize  , $resultCount = $infocount["CNUM"] );
		
		$GLOBALS['Templ']->assign('PageStr',$PageStr);
		$GLOBALS['Templ']->assign('info',$info);
		$GLOBALS['Templ']->display('leaveword_tpl.html');
		
	}
	
 
	

	function del( )
	{
		$indel 		= implode(',', $delArray);
		$insertip 	= "  DELETE FROM `msg` WHERE `msg`.`lwd_id` in ( $indel ) or `msg`.`lwd_parentid`  in ( $indel ) ";
		$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/msg/infolist/");
		$GLOBALS['Templ'] -> display('suggestion_tpl.html');
	}
	
	function info(  )
	{
		$infoid   = $infoArray[0];
		//SELECT  fm.*,rm.lwd_content as relwd_content  FROM msg as fm left join msg as rm on rm.lwd_parentid = fm.lwd_id  WHERE fm.parent_id = 0  and  fm.lwd_id =
		$sqlQuery = " SELECT  fm.*, rm.lwd_content as relwd_content,rm.lwd_id as rmlwd_id  FROM msg as fm left join msg as rm on rm.lwd_parentid = fm.lwd_id  WHERE fm.lwd_parentid = 0  and  fm.lwd_id ='".$infoid."' ORDER BY fm.`lwd_id` ";
		$info = $GLOBALS['MySql'] -> selectOne($sqlQuery);
		$GLOBALS['Templ']->assign('actUrl',EMPLOYEE_WEBURL."/index.php/msg/editinfo");
		$GLOBALS['Templ'] -> assign('info',$info);
		$GLOBALS['Templ'] -> display('leavewordedit_tpl.html');
	
	}
	
	
	function editinfo( )
	{	
	
		$lwd_parentidval 	= $GLOBALS['Reque'] -> funpost("lwd_parentid");
		$relwd_contentval 	= $GLOBALS['Reque'] -> funpost("relwd_content");
		
		$rmlwd_idval 	= $GLOBALS['Reque'] -> funpost("rmlwd_id");
		
		$replylwd_titleval 	= "reply:".$GLOBALS['Reque'] -> funpost("lwd_title");
		
		$lwd_timeval = time();
		
		//$_SESSION["emplyeeUser"]["use_id"] =='' or  $_SESSION["webAdmin"]["admin_name"]
		
		$addsetUp = '';
		
		if($lwd_parentidval !='' and $relwd_contentval !='' )
		{
			///"UPDATE `links` SET  link_name = '".$link_nameval."' , link_url = '".$link_urlval."' , link_logo = '".$link_logoval."', link_list = '".$link_listval."',link_istrue = '".$link_istrueval."'  WHERE  link_id = '".$link_idval."' ";
			
			if($rmlwd_idval!='')
			{
				$updatedata = "UPDATE `msg` SET  lwd_content = '".$relwd_contentval."' , admin_id = '".$_SESSION["emplyeeUser"]["use_id"]."' , admin_name = '".$_SESSION["webAdmin"]["admin_name"]."' ,`lwd_time`= '$lwd_timeval' WHERE   lwd_id = ".$rmlwd_idval;
			}else{
				$updatedata = "INSERT INTO `msg` (`lwd_parentid` , `admin_id` , `admin_name` , `lwd_title` , `lwd_type`,`lwd_status`,`lwd_content`,`lwd_time`)
							VALUES ( '$lwd_parentidval', '".$_SESSION["emplyeeUser"]["use_id"]."', '".$_SESSION["webAdmin"]["admin_name"]."', '$replylwd_titleval', '$lwd_typeval','$lwd_statusval','$relwd_contentval','$lwd_timeval') ";
			}
			
			
			$GLOBALS['MySql'] -> querySql( $updatedata );
			
			$GLOBALS['Templ'] -> assign('infomessage',$GLOBALS['_LANG']['bd_editsusse']);
			$GLOBALS['Templ'] -> assign('URL_TIME',URL_TIME);
			$GLOBALS['Templ'] -> assign('geturl',EMPLOYEE_WEBURL."/index.php/msg/infolist/");
			$GLOBALS['Templ'] -> display('suggestion_tpl.html');
				
		}else{
		
			$GLOBALS['Templ'] -> assign('infomessage',$GLOBALS['_LANG']['bd_losssusse']);
			$GLOBALS['Templ'] -> assign('URL_TIME',URL_TIME);
			$GLOBALS['Templ'] -> assign('geturl',EMPLOYEE_WEBURL."/index.php/msg/info/".$admin_idval);
			$GLOBALS['Templ'] -> display('suggestion_tpl.html');	
		}
		
	}
		
}

//nmon_x86_rhel4


$Leaveword = new Leaveword();

?>