<?
/**
*@systemname:       E-Office
*@filename:         general/ipanel/tableleft.php
*@function:         OA��ҳ
*@encoding:         utf8
*@author:           www.weaver.com.cn
*@date:             2008-5-12
*@file Version:     2
*@eoffice Version:  7.8
*/
include_once("inc/auth.php");
include_once("inc/utility_all.php");
include_once("inc/function_usergeneral.php");
includelangpak("index");
$portal_index = $_REQUEST['portal_index'];
$op = $_REQUEST['op'];

if($portal_index!=""){
	$portal_id = $portal_index;
	if($op!='edit'){
		setcookie("USER_PORTAL",$portal_id,time()+60*60*24*1000*7);
	}
}else{
	$query_d = "
		SELECT PORTAL_ID FROM index_portal 
			WHERE PORTAL_DEFAULT = '1'
				AND((
					(VIEW_DEPT_ID='DEPT_ALL')
					or
					(INStr(VIEW_DEPT_ID,',$LOGIN_DEPT_ID,')>0 or INStr(VIEW_DEPT_ID,'$LOGIN_DEPT_ID,')=1)
					or
					(INStr(VIEW_PRIV_ID,',$LOGIN_USER_PRIV,')>0 or INStr(VIEW_PRIV_ID,'$LOGIN_USER_PRIV,')=1)
					or
					(INStr(VIEW_USER_ID,',$LOGIN_USER_ID,')>0 or INStr(VIEW_USER_ID,'$LOGIN_USER_ID,')=1)
				)
				OR(
					(DEPT_ID='DEPT_ALL')
					or
					(INStr(DEPT_ID,',$LOGIN_DEPT_ID,')>0 or INStr(DEPT_ID,'$LOGIN_DEPT_ID,')=1)
					or
					(INStr(PRIV_ID,',$LOGIN_USER_PRIV')>0 or INStr(PRIV_ID,'$LOGIN_USER_PRIV,')=1)
					or
					(INStr(USER_ID,',$LOGIN_USER_ID,')>0 or INStr(USER_ID,'$LOGIN_USER_ID,')=1)
				))
			";
	$res_d  = exequery($connection,$query_d);
	if($ROW_D = mysql_fetch_array($res_d)){
		$portal_id = $ROW_D['PORTAL_ID'];
	}else{
		if($_COOKIE['USER_PORTAL']!=''){
			$portal_id = $_COOKIE['USER_PORTAL'];
		}else{
			$portal_id = 1;//ָ���û��õ��Ż�
			setcookie("USER_PORTAL",1,time()+60*60*24*1000*7);
		}
	}
	$portal_index = $portal_id;
	$_REQUEST['portal_index'] = $portal_id;
}
if($op=='edit'){
	$setIndexAll = true;
}else{
	if($portal_index==1){
		$portal_index = 0;
	}
	$setIndexAll = false; 
}
$priv_str = $_SESSION['LOGIN_FUNC_STR'];
$userid	= $_SESSION['LOGIN_USER_ID'];
if($setIndexAll){
	$index_pur = true;
}else{
	$index_pur = getPurview('PORTAL_ID',$portal_id,'index_portal');//��ȡ�û�Ȩ��
}
//�༭�Ż�ҳ��
if($setIndexAll){
$sql = "SELECT * FROM index_layout WHERE PORTAL_INDEX=$portal_id";
$rs  = exequery($connection,$sql);
$row = mysql_fetch_array($rs);
//��ʼ�����
	if($row=='') {
		$query = "
			      INSERT INTO `index_layout` (`USER_ID`, `LAYOUT_TYPE`, `LAYOUT_1`, `LAYOUT_2`, `LAYOUT_3`, `PORTAL_INDEX`) VALUES 
			('admin', 3, 33, 33, 33, '$portal_id');
			     ";
		$rc=exequery($connection,$query);
		$query1 = "
			INSERT INTO `index_block` ( `USER_ID`, `BLOCK_TYPE`, `BLOCK_TITLE`, `BLOCK_ROW`, `SUBJECT_LENGTH`, `IS_SHOW_DATE`, `BLOCK_TPL`, `IS_SHOW_CREATOR`, `BLOCK_EFFECT`, `COMMON_ID`, `COMMON_STR`, `BLOCK_IMG`, `BLOCK_LAYOUT`, `BLOCK_ORDER`,`PORTAL_INDEX`) VALUES 
			( 'admin', -2, '".$_lang["index_notice_center"]."', 5, 25, 1, 'gray', 1, 1, 0, '', 'box.gif', 1, 3,'$portal_id'),
			( 'admin', 7, '".$_lang["index_person_doc"]."', 5, 25, 1, 'gray', 1, 1, 0, '', 'box.gif', 3, 1,'$portal_id'),
			( 'admin', 16, '".$_lang["index_hr_work"]."', 5, 25, 0, 'gray', 0, 0, 0, '', 'box.gif', 3, 3,'$portal_id'),
			( 'admin', 8, '".$_lang["index_public_doc"]."', 5, 25, 1, 'gray', 1, 1, 0, '', 'box.gif', 2, 1,'$portal_id'),
			( 'admin', -1, '".$_lang["index_new_center"]."', 3, 25, 0, 'gray', 1, 2, 0, '', 'box.gif', 2, 2,'$portal_id'),
			( 'admin', 3, '".$_lang["index_waitfor_flow"]."', 5, 25, 1, 'gray', 1, 1, 0, '', 'box.gif', 1, 2,'$portal_id'),
			( 'admin', 13, '".$_lang["index_current_sms"]."', 5, 25, 0, 'gray', 1, 0, 0, '', 'box.gif', 1, 4,'$portal_id'),
			( 'admin', 12, '".$_lang["index_current_email"]."', 5, 25, 1, 'gray', 1, 1, 0, '', 'box.gif', 2, 3,'$portal_id'),
			( 'admin', -4, '".$_lang["index_weather"]."', 1, 20, 0, 'gray', 0, 0, 0, '�Ϻ�', 'box.gif', 1, 1,'$portal_id');
			";
		$rc1 = exequery($connection,$query1);
		}
}

//��ʼ�����

if($index_pur&&!$setIndexAll&&$portal_id==1){
	$sql = "SELECT COUNT(*) AS CNT  FROM index_layout WHERE USER_ID='".$userid."' AND PORTAL_INDEX=0 ";
	$rs  = exequery($connection,$sql);
	$row = mysql_fetch_array($rs); 
	$CNT = $row['CNT'];
	//��ʼ�����
	//$index_pur
	if($CNT==0){
		$query_all = "
					SELECT * FROM `index_layout` WHERE PORTAL_INDEX=1
					";
		$rcs         = exequery($connection,$query_all);
		$ROW         = mysql_fetch_array($rcs);
		$LAYOUT_TYPE = $ROW['LAYOUT_TYPE'];
		$LAYOUT_1    = $ROW['LAYOUT_1'];
		$LAYOUT_2    = $ROW['LAYOUT_2'];
		$LAYOUT_3    = $ROW['LAYOUT_3'];
		$query       = "
			           INSERT INTO `index_layout` (`USER_ID`, `LAYOUT_TYPE`, `LAYOUT_1`, `LAYOUT_2`, `LAYOUT_3`) VALUES 
			('$userid', '$LAYOUT_TYPE', '$LAYOUT_1', '$LAYOUT_2', '$LAYOUT_3');
			           ";
		$rc=exequery($connection,$query);
		$query_block = "
				   SELECT * FROM index_block WHERE PORTAL_INDEX=1
					";
	    $res = exequery($connection,$query_block);
		while($ROW = mysql_fetch_array($res)){
			$BLOCK_TYPE      = $ROW['BLOCK_TYPE'];
			$BLOCK_TITLE     = $ROW['BLOCK_TITLE'];
			$BLOCK_ROW       = $ROW['BLOCK_ROW'];
			$SUBJECT_LENGTH  = $ROW['SUBJECT_LENGTH'];
			$IS_SHOW_DATE    = $ROW['IS_SHOW_DATE'];
			$BLOCK_TPL       = $ROW['BLOCK_TPL'];
			$IS_SHOW_CREATOR = $ROW['IS_SHOW_CREATOR'];
			$BLOCK_EFFECT    = $ROW['BLOCK_EFFECT'];
			$COMMON_ID       = $ROW['COMMON_ID'];
			$COMMON_STR      = $ROW['COMMON_STR'];
			$BLOCK_IMG       = $ROW['BLOCK_IMG'];
			$BLOCK_LAYOUT    = $ROW['BLOCK_LAYOUT'];
			$BLOCK_ORDER     = $ROW['BLOCK_ORDER'];
			$BLOCK_HEIGHT    = $ROW['BLOCK_HEIGHT']; //ģ��߶�
			$FONT_STYLE      = $ROW['FONT_STYLE'];			
			$query1 = "
			          INSERT INTO `index_block` (`USER_ID`, `BLOCK_TYPE`, `BLOCK_TITLE`, `BLOCK_ROW`, `SUBJECT_LENGTH`, `IS_SHOW_DATE`, `BLOCK_TPL`, `IS_SHOW_CREATOR`, `BLOCK_EFFECT`, `COMMON_ID`, `COMMON_STR`, `BLOCK_IMG`, `BLOCK_LAYOUT`, `BLOCK_ORDER`, `FONT_STYLE`, `BLOCK_HEIGHT`)
				      VALUES 
			          ('$userid', '$BLOCK_TYPE', '$BLOCK_TITLE', '$BLOCK_ROW', '$SUBJECT_LENGTH', '$IS_SHOW_DATE', '$BLOCK_TPL', '$IS_SHOW_CREATOR', '$BLOCK_EFFECT', '$COMMON_ID', '$COMMON_STR', '$BLOCK_IMG', '$BLOCK_LAYOUT', '$BLOCK_ORDER', '$FONT_STYLE', '$BLOCK_HEIGHT');
					  ";
			$rc1 = exequery($connection,$query1);
		}
	}
}

if($index_pur&&!$setIndexAll&&$portal_id==1){
	$sql = "SELECT * FROM index_layout WHERE USER_ID='".$userid."' AND PORTAL_INDEX=0 ";
} else {
	$sql = "SELECT * FROM index_layout WHERE  PORTAL_INDEX = '$portal_id' ";
}
$rs  = exequery($connection,$sql);
$row = mysql_fetch_array($rs);
$layouttype = $row['LAYOUT_TYPE'];
$layout1    = $row['LAYOUT_1'];
$layout2    = $row['LAYOUT_2'];
$layout3    = $row['LAYOUT_3'];

if ($layouttype == 1){
	$layoutdisplay1 = "";
	$layoutdisplay2 = "none";
	$layoutdisplay3 = "none";
}
if ($layouttype == 2){
	$layoutdisplay1 = "";
	$layoutdisplay2 = "";
	$layoutdisplay3 = "none";
}
if ($layouttype == 3){
	$layoutdisplay1 = "";
	$layoutdisplay2 = "";
	$layoutdisplay3 = "";
}

function getTplBolderColor($tpl){
	$bcol = "#999";
	switch($tpl){
		case "navarat":
			$bcol = "#FFB0B0";
			break;
		case "orange":
			$bcol = "#FFC177";
			break;
		case "yellow":
			$bcol = "#FFED77";
			break;
		case "green":
			$bcol = "#CBE084";
			break;
		case "blue":
			$bcol = "#A1D9ED";
			break;
		case "gray":
			$bcol = "#BBBBBB";
			break;
		case "o_navarat":
			$bcol = "#B78AA9";
			break;
		case "o_orange":
			$bcol = "#D68C6F";
			break;
		case "o_yellow":
			$bcol = "#A9B98C";
			break;
		case "o_green":
			$bcol = "#96C38A";
			break;
		case "o_blue":
			$bcol = "#579AE9";
			break;
		case "o_gray":
			$bcol = "#8AA2B7";
			break;
	}
	return $bcol;

}

$layoutnum1 = $layoutnum2 = $layoutnum3 = "layoutnum";
switch($layouttype){
	case 1:
		$layoutnum1 = "layoutnumselect";
		break;
	case 2:
		$layoutnum2 = "layoutnumselect";
		break;
	case 3:
		$layoutnum3 = "layoutnumselect";
		break;
}
?>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3c.org/TR/1999/REC-html401-19991224/loose.dtd">
 
<HTML>
<HEAD>
<TITLE><?=$_lang["index_page_title"]?></TITLE>
<META http-equiv=Content-Type content="text/html; charset=utf-8">
<META http-equiv=Content-Style-Type content=text/css>
<META http-equiv=Content-Script-Type content=text/javascript>
<STYLE type=text/css media="screen, projection">
#loadbox { width:160px;height:60px; position:absolute;top:50%;left:50%;margin-left:-80px;margin-top:-30px;}
#loadbox span {height:30px;display:block;width:160px;text-align:center; color:#FFF; font-size:12px;}

</STYLE>
 
<LINK media="print, projection, screen" href="css/ui.tabs.css" type=text/css rel=stylesheet>

<STYLE type=text/css media="screen, projection">
BODY {
	font-size:12px;line-height:22px;font-family:"宋体"
}
H1 {
	FONT-FAMILY: "宋体", Trebuchet, Verdana, Helvetica, Arial, sans-serif
}
H2 {
	FONT-FAMILY: "宋体", Trebuchet, Verdana, Helvetica, Arial, sans-serif
}
H1 {
	FONT-SIZE: 18px; MARGIN: 1em 0px 1.5em
}
H2 {
	FONT-SIZE: 16px; MARGIN: 2em 0px 1.5em
}
P {
	MARGIN: 0px
	
}
UNKNOWN {
	MARGIN: 0px 0px
}
CODE {
	FONT-FAMILY: "Courier New", Courier, monospace
}
.info{padding:6px 8px 0 6px;color:#BAB9B9;font-size:12px;line-height:23px;}
.info a{ font-size:14px;}

.info a.black:hover{color:#000;}
.fnb{font-weight:200;margin-left:-1px;}


a.button {
    color: #444;
    display: block;
    float: left;
    font: normal 12px arial, sans-serif;
    height: 24px;
    margin-right: 0px;
    padding-right: 9px; 
    text-decoration: none;
}

a.button span {
	display: block;
	line-height: 14px;
	padding-top: 5px;
	padding-right: 0;
	padding-bottom: 5px;
	padding-left: 9px;
} 

/*----------------------------------------------*/

a.button:hover {
	background-position: bottom right;
	background: transparent url('images/bg_button_a.gif') no-repeat scroll top right;
	color: #000;
	outline: none;
}
a.button:hover span {
    background-position: bottom left;
    background: transparent url('images/bg_button_span.gif') no-repeat;
    padding: 4px 0 4px 9px; 
}

/*----------------------------------------------*/

a.button:active {
	background-position: right -25px;
	color: #000;
	outline: none;
	background-attachment: scroll;
	background-color: transparent;
	background-image: url(images/bg_button_a.gif);
	background-repeat: no-repeat;
}

a.button:active span {
	background-position: left -25px;
	padding: 4px 0 4px 9px;
	background-color: transparent;
	background-image: url(images/bg_button_span.gif);
	background-repeat: no-repeat;
} 


</STYLE>

<SCRIPT src="js/jquery-1.2.6.js" 
type=text/javascript></SCRIPT>

 
<SCRIPT src="js/ui.core.js" 
type=text/javascript></SCRIPT>

<SCRIPT src="js/ui.tabs.js" 
type=text/javascript></SCRIPT>
 

<SCRIPT type=text/javascript>
	$(function() {
		$('#rotate > ul').tabs({ fx: { opacity: 'toggle' } }).tabs('rotate',5000);
	});
	function winReLoad()
	{
		window.location.reload();
	}

</SCRIPT>
<META content="MSHTML 6.00.2900.5726" name=GENERATOR></HEAD>
<BODY   >
 <span>
	 
	
	<a class="button" href="javascript:winReLoad()"  onClick="this.blur();" title="刷新">
		<span>
			<img src="images/refresh.gif" border="0" align="absmiddle"/>&nbsp;刷新		
			</span>	
	</a>
	
	<div class="top_line"></div>
	</span>

<DIV id=rotate>
<UL>
  <LI><A 
  href="portal_index=6&f=readblock&blockid="   ><SPAN>新闻</SPAN></A> 
  <LI><A 
  href="#fragment-2" ><SPAN>财经</SPAN></A> 
  <LI><A 
  href="#fragment-3"><SPAN>娱乐</SPAN></A> 
  <LI><A 
  href="#fragment-4"><SPAN>体育</SPAN></A> 
  <LI><A 
  href="#fragment-5"><SPAN>汽车</SPAN></A> </LI></UL>
	<DIV id=fragment-1 class="info">
	 <?php echo $rss_str[0];?>
	 </DIV>
	<DIV id=fragment-2 class="info"> 
	<?php echo $rss_str[1];?>

	</DIV>
	<DIV id=fragment-3 class="info">
	<?php echo $rss_str[2];?>

	</DIV>
	<DIV id=fragment-4 class="info">
	<?php echo $rss_str[3];?>
	</DIV>
	<DIV id=fragment-5 class="info">
	<?php echo $rss_str[4];?>
	</DIV>
</DIV>
 <script>
  	 
document.documentElement?document.documentElement.style.overflow="hidden":document.body.style.overflow="hidden" 
 
 </script>
</BODY>
</HTML>
