SIM0211.php
3.78 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
<?PHP
//*****************************************************************************
//* プログラム名:入金画面更新処理
//* プログラムID:SIM0201.php
//* 機能 :入金画面更新処理
//*****************************************************************************
header("Content-type: text/html; charset=EUC-JP");
include("./inc/session_start.inc");
include("./inc/SessionChk.inc");
include("./inc/dbcon.inc");
$yyyy = $_POST["yyyy"];
$bSeq = $_POST["bSeq"];
$dSeq = $_POST["dSeq"];
$dSeqIn = $_POST["kSeqIn"];
$dSeqOut = $_POST["kSeqOut"];
$cSeq = $_POST["cSeq"];
//$sMode = $_POST["sMode"];
//$chgmode = $_GET["chgmode"];
//収入更新処理
if (count($_POST["txtin1"]) > 0) {
$arrCnt = count($_POST["txtin1"]);
$nSeq = $dSeqIn;
//データ更新
for($i=0;$i<$arrCnt;$i++){
//DELETE
$strSQL = "delete from nyukin_tbl where koumoku_seq = ".$nSeq[$i]." and nyukin_year = ".$yyyy." and nyukin_mode = 1" ;
$objRec = pg_exec($strSQL);
if($objRec==false){
echo("SQL実行に失敗しました(DELETE)");
exit;
}
for($j=1;$j<=12;$j++){
//INSERT nyukin_mode 1:収入 2:支出
$strSQL = "insert into nyukin_tbl (koumoku_seq, nyukin_year, nyukin_month, nyukin_mode, nyukin_data, nyukin_ym) ";
$strSQL .= "values(".$nSeq[$i].", ".$yyyy.", ".$j.", 1, ".intval($_POST["txtin".$j][$i]).", ".$yyyy.sprintf('%02d', $j).")";
$objRec = pg_exec($strSQL);
if($objRec==false){
echo("SQL実行に失敗しました(INSERT)");
exit;
}
}
}
//コメント更新
for($i=0;$i<$arrCnt;$i++){
for($j=1;$j<=12;$j++){
if ($_POST["hdnIn".$j][$i] == True) {
//DELETE
$strSQL = "DELETE FROM comment_tbl WHERE ";
$strSQL .= "koumoku_seq = ".$nSeq[$i]." AND nyukin_year = ".$yyyy." ";
$strSQL .= "AND nyukin_month = ".$j." AND nyukin_mode = ".$sMode." ";
$objRec = pg_exec($strSQL);
if($objRec==false){
echo("SQL実行に失敗しました(DELETE)");
exit;
}
//INSERT
$strSQL = "INSERT INTO comment_tbl (koumoku_seq, nyukin_year, nyukin_month, nyukin_mode, comment_text) ";
$strSQL .= "values(".$nSeq[$i].", ".$yyyy.", ".$j.", ".$sMode.", '". strval($_POST["hdnIn".$j][$i])."')";
$objRec = pg_exec($strSQL);
if($objRec==false){
echo("SQL実行に失敗しました(INSERT)");
exit;
}
}
}
}
}
//支出更新処理
if (count($_POST["txtout1"]) > 0) {
$arrCnt = count($_POST["txtout1"]);
$nSeq = $dSeqOut;
for($i=0;$i<$arrCnt;$i++){
//DELETE
$strSQL = "delete from nyukin_tbl where koumoku_seq = ".$nSeq[$i]." and nyukin_year = ".$yyyy." and nyukin_mode = 2" ;
$objRec = pg_exec($strSQL);
if($objRec==false){
echo("SQL実行に失敗しました(DELETE)");
exit;
}
for($j=1;$j<=12;$j++){
//INSERT nyukin_mode 1:収入 2:支出
$strSQL = "insert into nyukin_tbl (koumoku_seq, nyukin_year, nyukin_month, nyukin_mode, nyukin_data, nyukin_ym) ";
$strSQL .= "values(".$nSeq[$i].", ".$yyyy.", ".$j.", 2, ".intval($_POST["txtout".$j][$i]).", ".$yyyy.sprintf('%02d', $j).")";
$objRec = pg_exec($strSQL);
if($objRec==false){
echo("SQL実行に失敗しました(INSERT)");
exit;
}
}
}
}
?>
<html>
<head>
<meta http-equiv="content-type" content="text/html; cahrset=euc-jp">
<meta http-equiv="content-style-type" content="text/css">
<meta name="robots" content="noindex, nofollow">
<title></title>
<script language="javascript">
function trans(){
document.frm.action = "SIM0210.php";
document.frm.method="POST";
document.frm.submit();
}
</script>
</head>
<body onload="trans();">
<form name="frm">
<input type="hidden" name="sMode" value="<?PHP echo $_POST["sMode"] ?>">
<input type="hidden" name="yyyy" value="<?PHP echo $_POST["yyyy"] ?>">
<input type="hidden" name="bSeq" value="<?PHP echo $_POST["bSeq"] ?>">
<input type="hidden" name="dSeq" value="<?PHP echo $_POST["dSeq"] ?>">
<input type="hidden" name="cSeq" value="<?PHP echo $_POST["cSeq"] ?>">
</form>
</body>
</html>