|
Server : Apache/2.2.2 (Fedora) System : Linux App1.pathumtani.go.th 2.6.20-1.2320.fc5smp #1 SMP Tue Jun 12 19:40:16 EDT 2007 i686 User : apache ( 48) PHP Version : 5.2.9 Disable Function : NONE Directory : /var/www/html/pathumthani_eoffice/application/bin/gov_news2/ |
Upload File : |
<?
session_start();
ob_start();
if ($_SESSION['display']==0) { $appsession = $_SESSION[session_apppermit][6]; } else { $appsession=""; }
//echo "<pre>";
//print_r($_POST);
//exit;
$staffid=$_SESSION['session_staffid'];
include("var.inc.php");
include("../../config/config.inc.php");
include("../../common/function.php");
$save_dir = "../../upload/govnews/";
function randigit($numchar){
$frchar = array("a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z") ;
$ran_digit ="";
for ($ii = 0 ; $ii < $numchar ; $ii++ ){
$ran_digit .= $frchar[rand(1,26)] ;
}
return $ran_digit ;
} ## END function
// query for intializing...
if ($sub_id) {
$sql1 = "SELECT * FROM kpi_detail WHERE id='$sub_id' ";
$query1 = mysql_query($sql1) or die(mysql_error());
$nrows = mysql_num_rows($query1);
$rs = mysql_fetch_assoc($query1);
$temp1 = explode(" ",$rs[date_end]);
$temp2 = explode(":",$temp1[1]);
$hh = $temp2[0];
$mm = $temp2[1];
}
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>พรบ. ข้อมูลข่าวสาร</title>
<meta http-equiv="Content-Type" content="text/html; charset=windows-874">
<link href="../../common/style.css" type="text/css" rel="stylesheet">
<style type="text/css">
<!--
body {
margin-left: 4px;
margin-top: 0px;
margin-right: 0px;
margin-bottom: 0px;
}
a:link {
text-decoration: none;
}
a:visited {
text-decoration: none;
}
a:hover {
text-decoration: underline;
}
a:active {
text-decoration: none;
}
-->
</style>
<script type="text/javascript" src="../../common/popcalendar.js"></script>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="../../common/fckeditor/fckeditor.js"></script>
<script type="text/javascript">
$(document).ready(function(){
$("#type2").hide();
$("input[name='type']").click(function(){
var value = $("input[name='type']:checked").val();
if (value==1) { $("#type2").hide(); $("#type1").slideDown(); $("#Submit23").show(); }
else if (value==2) { $("#type1").hide(); $("#type2").slideDown(); $("#Submit23").hide(); }
});
$("input[name='expire']").click(function(){
var value = $("input[name='expire']:checked").val();
if (value==0) { $("#expirex").slideUp(); }
else if (value==1) { $("#expirex").slideDown(); }
});
});
</script>
<body bgcolor="#A3B2CC">
<?
if ($act=="unhide") {
$sqlx = "UPDATE kpi_detail SET hide='0' WHERE id='$cat_id' AND sub_id='$sub_id'";
$queryx = mysql_query($sqlx) or die(mysql_error());
addlog("ยกเลิกระงับการแสดงผล #$sub_id",$varappid,$sub_id,7);
echo "<center><h2>ยกเลิกระงับการแสดงผลแล้ว</h2></center>";
echo "<meta http-equiv='Refresh' content='1;URL=$PHP_SELF?cat_id=$cat_id&sub_id=$sub_id'>";
exit();
}
if ($_POST) {
if ($act=="hide") {
$sqlx = "UPDATE kpi_detail SET hide='1', hide_reason='$hide_reason' WHERE id='$sub_id'";
$queryx = mysql_query($sqlx) or die(mysql_error());
addlog("ระงับการแสดงผล #$sub_id",$varappid,$sub_id,7);
echo "<center><h2>ระงับการแสดงผลแล้ว</h2></center>";
echo "<meta http-equiv='Refresh' content='1;URL=$PHP_SELF?cat_id=$cat_id&sub_id=$sub_id'>";
exit();
}
if($type==2 ) { $title=$title2;$detail=$detail2; }
$date_end = convert_2mysql($date_end);
$hour = $h_end.":".$m_end.":00";
$date_end = $date_end." ".$hour;
$q = mysql_query("show table status from $dbname like 'kpi_detail'") or die(mysql_error());
$no = mysql_result($q, 0, 'Auto_increment');
$no=$no;
if($act=="add") {
$sql = "INSERT INTO kpi_detail(title,detail,staffid,type,date_start,date_end,expire) VALUES ('$title','$detail','$staffid','$type',NOW(),'$date_end','$expire')";
addlog("เพิ่มหัวข้อใหม่ #$no",$varappid,$no,3);
}
else {
$sql = "UPDATE kpi_detail SET title='$title',detail='$detail',type='$type',date_end='$date_end',expire='$expire' WHERE id='$sub_id'";
addlog("แก้ไขหัวข้อ #$sub_id",$varappid,$sub_id,4);
}
$query = mysql_query($sql) or die(mysql_error());
$query = mysql_query("INSERT INTO kpi_detail_member(id,sub_id) VALUES('$cat_id','$no')");
if($actx=="step2") {
header("Location: showcat_attach.php?actx=$actx&cat_id=$cat_id&sub_id=$no");
}
else {
echo "<center><h2>บันทึกข้อมูลแล้ว</h2></center>";
echo "<meta http-equiv='Refresh' content='1;URL=$PHP_SELF?cat_id=$cat_id&sub_id=$sub_id'>";
exit();
}
}
if ($act=="del") {
$sqlx = "DELETE FROM kpi_detail WHERE id='$cat_id' AND id='$sub_id'";
$queryx = mysql_query($sqlx) or die(mysql_error());
addlog("ลบหัวข้อ #$sub_id",$varappid,$sub_id,5);
echo "<center><h2>ลบข้อมูลแล้ว</h2></center>";
echo "<META HTTP-EQUIV='Refresh' CONTENT='1;URL=$PHP_SELF?cat_id=$cat_id&sub_id=$sub_id'>";
exit();
}
?>
<br>
<? if (($act=="add")||($act=="edit")) { ?>
<form action="<?=$PHP_SELF;?>?cat_id=<?=$cat_id;?>&sub_id=<?=$sub_id;?>" id="form1" method="post" enctype="multipart/form-data" name="form<?=$cat_id;?><?=$sub_id;?>">
<table width="95%" border="0" align="center" cellpadding="0" cellspacing="0" bgcolor="#000000">
<tr>
<td align="left" valign="top" bgcolor="#000000"><table width="100%" border="0" align="center" cellpadding="5" cellspacing="1">
<tr>
<th align="center" valign="top" bgcolor="#CCCCCC">ขั้นตอนที่ 1 จากทั้งหมด 2 ขั้นตอน </th>
</tr>
</table></td>
</tr>
</table>
<br>
<table width="95%" border="0" align="center" cellpadding="0" cellspacing="0" bgcolor="#000000">
<tr>
<td><table width="100%" border="0" align="center" cellpadding="2" cellspacing="1">
<tr>
<th width="100%" align="left" bgcolor="#7E96B8">รายละเอียด</th>
</tr>
<tr>
<td align="right" valign="top" bgcolor="#F3F5F8"><table width="100%%" border="0" align="center" cellpadding="2" cellspacing="0">
<tr>
<td width="20%" align="right" valign="top" bgcolor="#F3F5F8">ประเภทข่าว : </td>
<td width="80%" align="left" valign="top" bgcolor="#F3F5F8"><input name="type" type="radio" value="1" checked>
ข้อความ
<input name="type" type="radio" value="2">
URL </td>
</tr>
</table></td>
</tr>
<tr>
<td align="left" valign="top" bgcolor="#F3F5F8">
<div id="type1">
<table width="100%%" border="0" align="center" cellpadding="2" cellspacing="0">
<tr>
<td width="20%" align="right" valign="top" bgcolor="#F3F5F8">หัวข้อ : </td>
<td width="80%" align="center" valign="top" bgcolor="#F3F5F8">
<input name="title" type="text" id="title" style="width:98%;" value="<?=$rs[title];?>"> </td>
</tr>
<tr>
<td align="right" valign="top" bgcolor="#F3F5F8">รายละเอียด : </td>
<td align="center" valign="top" bgcolor="#F3F5F8">
<textarea name="detail" id="detail" style="width:98%; height:100px;"><?=$rs[detail];?></textarea></td>
</tr>
</table>
</div>
<div id="type2">
<table width="100%%" border="0" align="center" cellpadding="2" cellspacing="0">
<tr>
<td width="20%" align="right" valign="top" bgcolor="#F3F5F8">หัวข้อ : </td>
<td width="80%" align="center" valign="top" bgcolor="#F3F5F8"><input name="title2" type="text" id="title2" style="width:98%;" value="<?=$rs[title];?>"></td>
</tr>
<tr>
<td align="right" valign="top" bgcolor="#F3F5F8">URL : </td>
<td align="center" valign="top" bgcolor="#F3F5F8">
<input name="detail2" type="text" id="detail2" style="width:98%;"></td>
</tr>
</table>
<br/>
</div> </td>
</tr>
<tr>
<td align="right" valign="top" bgcolor="#F3F5F8"><table width="100%%" border="0" align="center" cellpadding="2" cellspacing="0">
<tr>
<td width="20%" align="right" valign="middle" bgcolor="#F3F5F8"> </td>
<td width="80%" align="left" valign="middle" bgcolor="#F3F5F8">
<input name="expire" type="radio" value="0" <? if((!$rs[expire])||($rs[expire]==0)) {?>checked<? } ?>>
ไม่กำหนดวันหมดอายุ
<input name="expire" type="radio" value="1" <? if($rs[expire]==1) {?>checked<? } ?>> กำหนดวันหมดอายุ </td>
</tr>
</table>
<div id="expirex" <? if($rs[expire]!=1) {?>style="display:none;"<? } ?>>
<table width="100%%" border="0" align="center" cellpadding="2" cellspacing="0">
<tr>
<td width="20%" align="right" valign="middle" bgcolor="#F3F5F8">วันหมดอายุ :</td>
<td width="80%" align="left" valign="middle" bgcolor="#F3F5F8">
<? if($rs[date_end]!="") {
if($rs[date_end]!="0000-00-00 00:00:00") {
$datex=$rs[date_end];
} else { $datex=date("Y-m-d h:m:s"); }
} else { $datex=date("Y-m-d h:m:s"); }
?>
<input name="date_end" type="text" value="<?=convert2th(convert_mysql2carendar(substr($datex,0,10)));?>" size="15" readonly>
<input name="button" type="button" class="index2" style='font-size:11px; width:80px;' onClick="popUpCalendar(this, form.date_end, 'd/m/yyyy')" value='ปีเดือนวัน'>
<input type="button" name="btnC1" value="ล้างค่าปฏิทิน" onClick="document.form1.date_end.value='';"></td>
</tr>
<tr>
<td align="right" valign="middle" bgcolor="#F3F5F8">เวลาหมดอายุ : </td>
<td align="left" valign="middle" bgcolor="#F3F5F8">ชั่วโมง
<select name="h_end" >
<?
for ($i=0;$i<=23;$i++){
//if ((intval($h_et)== $i) or (intval($h_end) == $i)){
if ($hh==$i) {
echo "<option value='".sprintf("%02d",$i)."' SELECTED>" . sprintf("%02d",$i) . "</option>\n";
}elseif ($i==18) {
echo "<option value='".sprintf("%02d",$i)."' SELECTED>" . sprintf("%02d",$i) . "</option>\n";
}else{
echo "<option value='".sprintf("%02d",$i)."'>" . sprintf("%02d",$i) . "</option>\n";
}
}
?>
</select>
นาที
<select name="m_end" >
<?
for ($i=0;$i<=59;$i++){
if ($mm==$i) {
echo "<option value='".sprintf("%02d",$i)."' SELECTED>" . sprintf("%02d",$i) . "</option>\n";
}else{
echo "<option value='".sprintf("%02d",$i)."'>" . sprintf("%02d",$i) . "</option>\n";
}
}
?>
</select></td>
</tr>
</table>
</div>
</td>
</tr>
<tr>
<td align="center" valign="top" bgcolor="#F3F5F8"><input name="act" type="hidden" id="act" value="<?=$act;?>">
<input name="Submit23" id="Submit23" type="submit" class="epm_button" value="ขั้นตอนที่ 2 แนบไฟล์" onClick="document.form1.action='<?=$PHP_SELF;?>?actx=step2&cat_id=<?=$cat_id;?>&sub_id=<?=$rs[sub_id];?>';">
<input name="Submit2" type="submit" class="epm_button" value="บันทึกโดยไม่แนบไฟล์">
<input name="Submit22" type="button" class="epm_button" value=" กลับ " onClick="window.location='<?=$PHP_SELF;?>?cat_id=<?=$cat_id?>';"></td>
</tr>
</table>
</td>
</tr>
</table>
</form>
<br/>
<? } else if ($act=="hide") { ?>
<form action="<?=$PHP_SELF;?>?cat_id=<?=$cat_id;?>&sub_id=<?=$rs[id];?>" method="post" enctype="multipart/form-data" name="form<?=$cat_id;?><?=$rs[id];?>">
<table width="95%" border="0" align="center" cellpadding="0" cellspacing="0" bgcolor="#000000">
<tr>
<td><table width="100%" border="0" align="center" cellpadding="2" cellspacing="1">
<tr>
<th colspan="2" align="left" bgcolor="#7E96B8">ระงับการแสดงผล</th>
</tr>
<tr>
<td width="20%" align="right" valign="top" bgcolor="#F3F5F8">เหตุผล : </td>
<td width="80%" align="left" valign="top" bgcolor="#F3F5F8"><textarea name="hide_reason" cols="50" rows="5" id="hide_reason"></textarea></td>
</tr>
<tr>
<td colspan="2" align="center" valign="top" bgcolor="#F3F5F8">
<input name="act" type="hidden" id="act" value="<?=$act;?>">
<input name="Submit2" type="submit" class="epm_button" value="จัดเก็บข้อมูล">
<input name="Submit22" type="button" class="epm_button" value=" ยกเลิก " onClick="window.location='<?=$PHP_SELF;?>?cat_id=<?=$cat_id?>';"></td>
</tr>
</table>
</td>
</tr>
</table>
</form>
<br/>
<? } else if ($act=="view") {
addlog("รายการหัวข้อ #$sub_id $rs[title]",$varappid,$rs[id],1);
?>
<table width="95%" border="0" align="center" cellpadding="0" cellspacing="0" bgcolor="#000000">
<tr>
<td>
<table width="100%" border="0" align="center" cellpadding="2" cellspacing="1">
<? if($rs[type]==1) { ?>
<tr>
<th colspan="2" align="left" bgcolor="#7E96B8">รายละเอียด</th>
</tr>
<tr>
<td width="20%" align="right" valign="top" bgcolor="#F3F5F8">หัวข้อ : </td>
<td width="80%" align="left" valign="top" bgcolor="#F3F5F8"><?=$rs[title];?></td>
</tr>
<? } ?>
<tr>
<td width="20%" align="right" valign="top" bgcolor="#F3F5F8"><? if($rs[type]==1) { ?>รายละเอียด : <? } else { ?>URL : <? } ?></td>
<td width="80%" valign="top" bgcolor="#F3F5F8">
<? if($rs[type]==1) { ?>
<?=eregi_replace("\n","",eregi_replace(chr(13),"",$rs[detail]));?>
<? } else { ?><a href="<?=$rs[detail];?>"><?=$rs[title];?></a><? } ?> </td>
</tr>
<? if($rs[type]==1) { ?>
<tr>
<td width="20%" align="right" valign="top" bgcolor="#F3F5F8">ไฟล์แนบ : </td>
<td width="80%" align="left" valign="top" bgcolor="#F3F5F8">
<?
$i=1;
$sql = "SELECT * FROM kpi_detail_file WHERE id='$sub_id' ORDER BY no ASC";
$result = mysql_query($sql)or die("Query line " . __LINE__ . " Error<hr>".mysql_error());
while ($rs = mysql_fetch_assoc($result)) {
?><a href="download.php?file=<?=$rs[filename]?>" target="_blank"><?=$i;?>. <? if($rs[detail]){echo "$rs[detail]";}else{ echo "ไฟล์แนบ";}?></a><br/>
<?
$i++; } ?> </td>
</tr>
<? } ?>
</table>
</td>
</tr>
</table>
<br/>
<? } else { ?>
<table width="95%" border="0" align="center" cellpadding="0" cellspacing="0" bgcolor="#000000" >
<tr>
<td align="left" valign="middle"><table width="100%" border="0" align="center" cellpadding="2" cellspacing="1">
<tr>
<td <? if (($appsession[10] == "on" )||($appsession[100] == "on")||($appsession[300] == "on")){ ?>colspan="3"<? } else { ?>colspan="2"<? } ?> align="left" bgcolor="#7E96B8">
<table width="100%" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<th width="80%" align="left">รายการหัวข้อทั้งหมด</th>
<th width="20%" align="center">
<? if ($appsession[300] == "on" ){ ?><a href="<?=$PHP_SELF;?>?act=add&cat_id=<?=$cat_id;?>"><img src="../../images_sys/nolines_plus.gif" alt="plus" width="18" height="18" border="0" align="middle">เพิ่มหัวข้อใหม่</a>
<? } ?>
</th>
</tr>
</table>
</td>
</tr>
<?
if (($appsession[300] == "on" )||($appsession[100] == "on" )||($appsession[10] == "on" )){ $jsql =""; } else { $jsql = " AND hide<>'1'"; }
if (($appsession[300] == "on" )||($appsession[100] == "on" )){ $asql =" AND staffid='$staffid'"; }
addlog("รายการหัวข้อทั้งหมด (cat_id = $cat_id)",$varappid,$cat_id,6);
$sql1x = "SELECT * FROM kpi_detail_member WHERE id='$cat_id'";
$query1x = mysql_query($sql1x) or die(mysql_error());
$counter=1;
while($rsx = mysql_fetch_assoc($query1x)) {
$sql1 = "SELECT * FROM kpi_detail WHERE id='$rsx[sub_id]'".$jsql.$asql;
$query1 = mysql_query($sql1) or die(mysql_error());
while($rs = mysql_fetch_assoc($query1)) {
if (($appsession[100] == "on" )||($appsession[300] == "on" )){ ?>
<tr>
<td width="5%" height="8" align="center" valign="middle" bgcolor="#F3F5F8"><?=$counter;?></td>
<td width="83%" align="left" valign="middle" bgcolor="#F3F5F8">
<? if ($rs[type]==1) {
if($rs[hide]==1){ ?><img src="../../images/icon_exit.gif" width="13" height="13" border="0" /> <? } ?>
<a href="showcat.php?act=view&cat_id=<?=$cat_id;?>&sub_id=<?=$rs[id];?>"><?=$rs[title];?></a>
<? }
elseif($rs[type]==2){
if($rs[hide]==1){ ?><img src="../../images/icon_exit.gif" width="13" height="13" border="0" /> <? } ?>
<a href="<?=$rs[detail];?>"><?=$rs[title];?></a>
<? } ?>
</td>
<td width="12%" height="8" align="center" valign="middle" bgcolor="#F3F5F8">
<? if (($appsession[100] == "on" )){
if($rs[hide]!=1){ ?>
<a href="<?=$PHP_SELF;?>?act=hide&cat_id=<?=$cat_id;?>&sub_id=<?=$rs[id];?>" onclick="if(!confirm('ต้องการระงับการแสดงผลหัวข้อนี้?')) return false;"><img src="../../images/icon_exit.gif" width="13" height="13" border="0" /></a>
<? } else { ?>
<a href="<?=$PHP_SELF;?>?act=unhide&cat_id=<?=$cat_id;?>&sub_id=<?=$rs[id];?>" onclick="if(!confirm('ต้องการยกเลิกระงับการแสดงผลหัวข้อนี้?')) return false;"><img src="../../images/approve20.png" width="13" height="13" border="0" /></a>
<? } } if (($appsession[300] == "on" )){ ?>
<a href="showcat_attach.php?cat_id=<?=$cat_id;?>&sub_id=<?=$rs[id];?>"><img src="../../images/attach.gif" alt="attach file" width="13" height="12" border="0"></a>
<a href="<?=$PHP_SELF;?>?act=edit&cat_id=<?=$cat_id;?>&sub_id=<?=$rs[id];?>"><img src="../../images/edit.png" width="12" height="13" border="0" /></a>
<a href="<?=$PHP_SELF;?>?act=del&cat_id=<?=$cat_id;?>&sub_id=<?=$rs[id];?>" onclick="if(!confirm('ต้องการลบหัวข้อนี้?')) return false;"><img src="../../images/del.png" width="11" height="13" border="0" /></a>
<? } ?>
</td>
</tr>
<? } else {?>
<tr>
<td width="5%" height="8" align="center" valign="middle" bgcolor="#F3F5F8"><?=$counter;?></td>
<td width="95%" align="left" valign="middle" bgcolor="#F3F5F8"><a href="showcat.php?act=view&cat_id=<?=$cat_id;?>&sub_id=<?=$rs[id];?>"><?=$rs[title];?></a></td>
</tr>
<? } $counter++; } }?>
</table></td>
</tr>
</table>
<? } ?>
</body>
</html>