CON123.php
5.93 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
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
<?php
//*****************************************************************************
//*
//* プログラム名:メニュー設定処理(表示順位・表示位置)
//* プログラムID:CON003_2
//* 機能 :サブメニューの表示場所変更
//* 作成者 :
//*
//*****************************************************************************
header("Content-type: text/html; charset=EUC-JP");
include("include/session_start.inc");
include("include/SessionChk.inc");
include("include/dbcon.inc");
// echo $main_no."<hr>";
// echo $sub_no."<hr>";
// $tmp = split("/",$sub_no);
// echo $tmp[1]."<hr>";
//exit;
//echo $main_no."-".$sub_no."<hr>";
//表示順位の最大値、最小値を取得
$strSql = "SELECT MAX(index_no) as maxValue,MIN(index_no) as minValue FROM sub_menu_tbl";
$rsResult = pg_exec($pg_con,$strSql);
$intDispRankMaxValue = pg_result($rsResult,0,"maxValue");
$intDispRankMinValue = pg_result($rsResult,0,"minValue");
switch ($up_down_flg) {
case "up":
$tmp = split("/",$sub_no);
$sub_no = $tmp[1];
//選択されたレコードを抽出
$strSql = "SELECT main_index, index_no, name, org_name, url, img, disp_flg FROM sub_menu_tbl WHERE main_index = ".$main_no." and index_no = ".$sub_no;
$rsResult = pg_exec($pg_con,$strSql);
//最小値の場合処理なし
if (pg_result($rsResult,0,"index_no")==$intDispRankMinValue) {
break;
}
//全レコード抽出
$strSql = "SELECT main_index, index_no, name, org_name, url, img, disp_flg FROM sub_menu_tbl WHERE main_index = ".$main_no." ORDER BY index_no";
$rsResult2 = pg_exec($pg_con,$strSql);
$intRsCnt = pg_numrows($rsResult2);
for ($i = 1 ; $i <= $intRsCnt-1 ; $i++) {
if (pg_result($rsResult,0,"index_no") == pg_result($rsResult2,$i,"index_no")) {
$strSqlTemp = "update sub_menu_tbl SET index_no= 999999999 WHERE main_index =".pg_result($rsResult2,$i,"main_index")." and index_no = ".pg_result($rsResult2,$i,"index_no");
$intDispNow = pg_result($rsResult2,$i,"index_no"); //自分の表示順位
$intDispWork = pg_result($rsResult2,$i-1,"index_no");
$intCategoryWork = pg_result($rsResult2,$i-1,"main_index");
$strSqlDown = "UPDATE sub_menu_tbl SET ";
$strSqlDown .= "index_no = $intDispNow ";
$strSqlDown .= "WHERE main_index = $intCategoryWork and index_no = ".$intDispWork;
$intDispWork = pg_result($rsResult2,$i-1,"index_no"); //1つ前レコードの表示順位
$intCategoryWork = pg_result($rsResult2,$i,"main_index");
$strSqlUp = "UPDATE sub_menu_tbl SET ";
$strSqlUp .= "index_no= $intDispWork ";
$strSqlUp .= "WHERE main_index = $intCategoryWork and index_no = 999999999";
$rsResult = pg_exec($pg_con,$strSqlTemp);
$rsResult = pg_exec($pg_con,$strSqlDown);
$rsResult = pg_exec($pg_con,$strSqlUp);
break;
}
}
break;
case "down":
$tmp = split("/",$sub_no);
$sub_no = $tmp[1];
//選択されたレコードを抽出
$strSql = "SELECT main_index, index_no, name, org_name, url, img, disp_flg FROM sub_menu_tbl WHERE main_index = ".$main_no." and index_no = ".$sub_no;
$rsResult = pg_exec($pg_con,$strSql);
//最大値の場合処理なし
if (pg_result($rsResult,0,"index_no")==$intDispRankMaxValue) {
break;
}
//全レコード抽出
$strSql = "SELECT main_index, index_no, name, org_name, url, img, disp_flg FROM sub_menu_tbl WHERE main_index = ".$main_no." ORDER BY index_no";
$rsResult2 = pg_exec($pg_con,$strSql);
$intRsCnt = pg_numrows($rsResult2);
for ($i = 0 ; $i <= $intRsCnt-2 ; $i++) {
if (pg_result($rsResult,0,"index_no") == pg_result($rsResult2,$i,"index_no")) {
$strSqlTemp = "update sub_menu_tbl SET index_no= 999999999 WHERE main_index =".pg_result($rsResult2,$i,"main_index")." and index_no = ".pg_result($rsResult2,$i,"index_no");
$intDispNow = pg_result($rsResult2,$i,"index_no"); //自分の表示順位
$intDispWork = pg_result($rsResult2,$i+1,"index_no"); //1つ後レコードの表示順位
$intCategoryWork = pg_result($rsResult2,$i,"main_index");
$strSqlUp = "UPDATE sub_menu_tbl SET ";
$strSqlUp .= "index_no= $intDispNow ";
$strSqlUp .= "WHERE main_index = $intCategoryWork and index_no = ".$intDispWork;
$intDispWork = pg_result($rsResult2,$i+1,"index_no");
$intCategoryWork = pg_result($rsResult2,$i+1,"main_index");
$strSqlDown = "UPDATE sub_menu_tbl SET ";
$strSqlDown .= "index_no = $intDispWork ";
$strSqlDown .= "WHERE main_index = $intCategoryWork and index_no = 999999999";
//echo $main_no."-".$sub_no."<hr>";
//echo $strSqlTemp."<hr>";
//echo $strSqlUp."<hr>";
//echo $strSqlDown."<hr>";
//exit;
$rsResult = pg_exec($pg_con,$strSqlTemp);
$rsResult = pg_exec($pg_con,$strSqlUp);
$rsResult = pg_exec($pg_con,$strSqlDown);
break;
}
}
break;
case "move":
// echo $main_no."<hr>";
// echo $sub_no."<hr>";
$tmp = split("/",$sub_no);
if($main_no == 6){
//未使用への移動
//サブメニューUPDATE
$strSql = "update sub_menu_tbl set disp_flg = 0 where main_index = ".$tmp[0]." and index_no = ".$tmp[1];
$rsResult = pg_exec($pg_con,$strSql);
}else{
//移動先インデックス抽出
$strSql = "SELECT main_index, index_no, name, org_name, url, img, disp_flg FROM sub_menu_tbl WHERE main_index = ".$main_no." ORDER BY index_no desc";
$rsResult = pg_exec($pg_con,$strSql);
if(pg_numrows($rsResult) > 0){
$intIDX = pg_result($rsResult,0,"index_no") + 1;
}else{
$intIDX = 1;
}
//サブメニューUPDATE
$strSql = "update sub_menu_tbl set main_index = ".$main_no.", index_no = ".$intIDX.", disp_flg = 1 where main_index = ".$tmp[0]." and index_no = ".$tmp[1];
// echo $strSql."<hr>";
// exit;
$rsResult = pg_exec($pg_con,$strSql);
}
//メインメニュ個数アップデート
for($i=1;$i<=5;$i++){
$strSql = "select index_no from sub_menu_tbl where main_index = ".$i." and disp_flg = 1";
$rsResult = pg_exec($pg_con,$strSql);
if(pg_numrows($rsResult) > 0){
$subCnt = pg_numrows($rsResult);
}else{
$subCnt = 0;
}
$strSql = "update main_menu_tbl set sub_menu_num = ".$subCnt." where index_no = ".$i;
$rsResult = pg_exec($pg_con,$strSql);
}
break;
}
header("Location: CON120.php");
?>