Viewing file: InsertState.php (5.79 KB) -rw-r--r-- Select action/file-type: (+) | (+) | (+) | Code (+) | Session (+) | (+) | SDB (+) | (+) | (+) | (+) | (+) | (+) |
<?php
include("../include/FunctionDB.php");
include("../source/myFunc.php");
ConnectDB();
$Flag = true;
$State = htmlspecialchars(trim($State));
$Year_State = htmlspecialchars(trim($Year_State));
$Date_note = $_POST['mYear']."-".$_POST['mMonth']."-".$_POST['mDate'];
$No = htmlspecialchars(trim($No));
$Disciption = htmlspecialchars(trim($Disciption));
$Cost1 = htmlspecialchars(trim($Cost1));
$Cost2 = htmlspecialchars(trim($Cost2));
$Cost3 = htmlspecialchars(trim($Cost3));
$Cost4 = htmlspecialchars(trim($Cost4));
$Cost5 = htmlspecialchars(trim($Cost5));
$CostSum = htmlspecialchars(trim($CostSum));
//$sql = "select * from state_tb where State = '$State' AND stateId = (select MAX(stateId) from state_tb)";
//$result = mysql_query($sql) or die("Error".mysql_error());
//$rsState = mysql_fetch_array($result);
/*=========================Cost Sum===========================*/
$sql = "select * from state_tb where State = '$State' ";
$result = mysql_query($sql) or die("Select State Error".mysql_error());
$row = mysql_num_rows($result);
if($row) $CostSum2 = ($Cost1+$Cost5+$CostSum)-($Cost2+$Cost3+$Cost4);
else $CostSum2 = $CostSum;
/*===========================================================*/
///////////////////// check Code
if ($Year_State =="")
{
$msg .="<li>กรุณาระบุ ปีงบประมาณ";
$button ="<input type=\"button\" value=\"Back to Edit\" onclick=\"history.back();\" style=\"font-weight:bold;color:#FFF;background-color:#036;border-style:outset;border-color:#69F;font-family:Tohoma;\">";
$Flag = false;
}
///////////////////// check name
if ($Date_note =="")
{
$msg .="<li>กรุณาระบุ วัน/เดือน/ปี";
$button ="<input type=\"button\" value=\"Back to Edit\" onclick=\"history.back();\" style=\"font-weight:bold;color:#FFF;background-color:#036;border-style:outset;border-color:#69F;font-family:Tohoma;\">";
$Flag = false;
}
//////////////////////
if ($State =="")
{
$msg .="<li>กรุณาระบ งบดำเนินการ";
$button ="<input type=\"button\" value=\"Back to Edit\" onclick=\"history.back();\" style=\"font-weight:bold;color:#FFF;background-color:#036;border-style:outset;border-color:#69F;font-family:Tohoma;\">";
$Flag = false;
}
//////////////////////
/*if ($Cost2 =="")
{
$msg .="<li>กรุณาระบ ค่าไฟฟ้า";
$button ="<input type=\"button\" value=\"Back to Edit\" onclick=\"history.back();\" style=\"font-weight:bold;color:#FFF;background-color:#036;border-style:outset;border-color:#69F;font-family:Tohoma;\">";
$Flag = false;
}
//////////////////////
if ($Cost3 =="")
{
$msg .="<li>กรุณาระบ ค่าไปรษณีย์/โทรเลข";
$button ="<input type=\"button\" value=\"Back to Edit\" onclick=\"history.back();\" style=\"font-weight:bold;color:#FFF;background-color:#036;border-style:outset;border-color:#69F;font-family:Tohoma;\">";
$Flag = false;
}
//////////////////////
if ($Cost4 =="")
{
$msg .="<li>กรุณาระบุ ค่าโทรศัพท์";
$button ="<input type=\"button\" value=\"Back to Edit\" onclick=\"history.back();\" style=\"font-weight:bold;color:#FFF;background-color:#036;border-style:outset;border-color:#69F;font-family:Tohoma;\">";
$Flag = false;
}
//////////////////////
if ($Cost4 =="")
{
$msg .="<li>กรุณาระบุ ค่าโทรศัพท์";
$button ="<input type=\"button\" value=\"Back to Edit\" onclick=\"history.back();\" style=\"font-weight:bold;color:#FFF;background-color:#036;border-style:outset;border-color:#69F;font-family:Tohoma;\">";
$Flag = false;
}
//////////////////////
if ($Cost5 =="")
{
$msg .="<li>กรุณาระบุ บริการอินเตอร์เน็ต";
$button ="<input type=\"button\" value=\"Back to Edit\" onclick=\"history.back();\" style=\"font-weight:bold;color:#FFF;background-color:#036;border-style:outset;border-color:#69F;font-family:Tohoma;\">";
$Flag = false;
}
//////////////////////
if ($Cost6 =="")
{
$msg .="<li>กรุณาระบุ";
$button ="<input type=\"button\" value=\"Back to Edit\" onclick=\"history.back();\" style=\"font-weight:bold;color:#FFF;background-color:#036;border-style:outset;border-color:#69F;font-family:Tohoma;\">";
$Flag = false;
}*/
///////////////////////// Check Status to Insert Data /////////////////////////////
if( $Flag)
{
InsertState($State,$Year_State,dmyE2ymdT($date),$No,$Disciption,$Cost1,$Cost2,$Cost3,$Cost4,$Cost5,$CostSum2);
//echo dmyE2ymdO($date);
$msg.="<li>ระบบจัดเก็บข้อมูลของท่านเรียบร้อยแล้ว";
echo"<meta http-equiv=\"refresh\" content=\"1;URL=StateList.php?State=$State\">";
}
CloseDB();
?>
<html>
<head>
<title>....Insert State...</title>
<meta http-equiv="Content-Type" content="text/html; charset=windows-874">
<link rel="stylesheet" href="../css/style1.css" type="text/css">
</head>
<body bgcolor="#FFFFFF" leftmargin="0" topmargin="0"marginwidth="0"marginheight="0">
<form>
<br>
<table width="70%" border="0" cellspacing="0"cellpadding="2"align="center">
<tr>
<td><div align="center"><span><b><font color="#003399" size="4" face="Tahoma">::<font color="#000000">แบบฟอร์มการลงข้อมูลการเงิน</font>
</font><font color="#003399" size="4" face="Tahoma">::</font></b></span></div></td>
</tr>
<tr>
<td>
<table width="100%" border="0" cellspacing="1"cellpadding="0"align="center" class="table">
<tr>
<td bgcolor="#D6ECF3"><div align="center"><b><font color="#000000" size="3" face="Tahoma">ระบบแจ้งการทำงาน</font></b></div></td>
</tr>
<tr>
<td bgcolor="#000000">
<table width="90%" border="0" cellspacing="0"cellpadding="2"align="center">
<tr>
<td><span><b><font color="#FFFFFF"><?php echo $msg;?></font></b></span></td>
</tr>
</table>
</td>
</tr>
<tr>
<td bgcolor="#D6ECF3">
<div align="center"><b><font color="#CCFF00"><?php echo $button;?> <font size="2" face="Tahoma"></font></font></b></div></td>
</tr>
</table>
</td>
</tr>
</table>
<br>
</form>
</body>
</html>
|