OutReportItemOperation.jsp
15.6 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
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
<%@ page import="weaver.general.Util" %>
<%@ page import="java.util.*" %>
<%@ page language="java" contentType="text/html; charset=GBK" %> <%@ include file="/systeminfo/init.jsp" %>
<jsp:useBean id="RecordSet" class="weaver.conn.RecordSet" scope="page" />
<jsp:useBean id="ConditionComInfo" class="weaver.datacenter.ConditionComInfo" scope="page" />
<%
String operation = Util.null2String(request.getParameter("operation"));
String itemid = Util.null2String(request.getParameter("itemid"));
String outrepid = Util.null2String(request.getParameter("outrepid"));
String itemrow = Util.null2String(request.getParameter("itemrow"));
String itemcolumn = Util.null2String(request.getParameter("itemcolumn"));
String itemtype = Util.null2String(request.getParameter("itemtype"));
String itemexpress = Util.fromScreen(request.getParameter("itemexpress"),user.getLanguage());
String itemdesc = Util.fromScreen(request.getParameter("itemdesc"),user.getLanguage());
String itemendesc = Util.fromScreen(request.getParameter("itemendesc"),user.getLanguage());
String itemexpresstype = Util.null2String(request.getParameter("itemexpresstype"));
String itemmodtype = Util.null2String(request.getParameter("itemmodtype"));
String picstatbudget = ""+ Util.getIntValue(request.getParameter("picstatbudget"),0);
String picstatlast = ""+ Util.getIntValue(request.getParameter("picstatlast"),0);
String picstat = ""+ Util.getIntValue(request.getParameter("picstat"),0);
int totaldetail1 = Util.getIntValue(request.getParameter("totaldetail1"),0);
int totaldetail2 = Util.getIntValue(request.getParameter("totaldetail2"),0);
int totaldetail3 = Util.getIntValue(request.getParameter("totaldetail3"),0);
String fromitem = Util.null2String(request.getParameter("fromitem"));
String toitems[] = request.getParameterValues("toitem");
int outrepcolumn = Util.getIntValue(request.getParameter("outrepcolumn"),0);
int outreprow = Util.getIntValue(request.getParameter("outreprow"),0);
String deletetype = Util.null2String(request.getParameter("deletetype"));
String sqlfrom = "" ;
String sqlcondition = "" ;
if(operation.equals("edit")){
char separator = Util.getSeparator() ;
String para = itemid + separator + outrepid
+ separator + itemrow + separator + itemcolumn + separator + itemtype + separator + itemexpress + separator + itemdesc + separator + itemexpresstype + separator + picstatbudget + separator + picstatlast + separator + picstat + separator + itemmodtype + separator + itemendesc ;
RecordSet.executeProc("T_OutReportItem_Insert",para);
RecordSet.next() ;
itemid = RecordSet.getString(1) ;
if(itemtype.equals("2")) {
ArrayList tables = new ArrayList() ;
ArrayList tablenames = new ArrayList() ;
ArrayList conditionids = new ArrayList() ;
ArrayList conditionvalues = new ArrayList() ;
String thetemptable = "" ;
for(int i=0 ; i< totaldetail1 ; i++) {
String itemtable = Util.null2String(request.getParameter("itemtable"+i));
String itemtablealter = Util.null2String(request.getParameter("itemtablealter"+i));
if(!itemtable.equals("")) {
para = itemid + separator + itemtable + separator + itemtablealter ;
RecordSet.executeProc("T_OutReportItemTable_Insert",para);
tables.add(itemtablealter) ;
tablenames.add(itemtable) ;
if(thetemptable.equals("")) thetemptable = itemtablealter ;
}
}
for(int i=0 ; i< totaldetail2 ; i++) {
String conditionid = Util.null2String(request.getParameter("conditionid"+i));
String conditionvalue = Util.fromScreen(request.getParameter("conditionvalue"+i),user.getLanguage());
if(!conditionid.equals("") && !conditionvalue.equals("")) {
para = itemid + separator + conditionid + separator + conditionvalue ;
RecordSet.executeProc("T_OutRItemCondition_Insert",para);
conditionids.add(conditionid) ;
conditionvalues.add(conditionvalue) ;
}
}
String fromyear = "" ;
String frommonth = "$monthf" ;
String fromday = "$dayf" ;
String toyear = "" ;
String tomonth = "$montht" ;
String today = "$dayt" ;
if(tables.size() != 0) {
String conditionkey = " where " ;
for(int j=0 ; j<conditionids.size() ; j++) {
int tempconditionid = Util.getIntValue((String)conditionids.get(j),0) ;
String tempconditionvalue = (String)conditionvalues.get(j) ;
if(tempconditionid == 1 || tempconditionvalue.equalsIgnoreCase("$crm_code") ) {
if(tempconditionvalue.equalsIgnoreCase("$crm")) {
sqlcondition += conditionkey + " CRM_CustomerInfo.id=" + thetemptable + ".crmid " +
" and CRM_CustomerInfo.id in("+tempconditionvalue+") " ;
}
else {
if(tempconditionvalue.equalsIgnoreCase("$crm_code")) tempconditionvalue = "$crm" ;
sqlcondition += conditionkey + " CRM_CustomerInfo.id=" + thetemptable+".crmid " +
" and CRM_CustomerInfo.crmcode like ''"+tempconditionvalue+"'' " ;
}
conditionkey = " and " ;
}
else if(tempconditionid == 2 ) fromyear = "$yearf" ;
else if(tempconditionid == 5 ) toyear = "$yeart" ;
else if(tempconditionid > 7 ) {
String tempfieldname = ConditionComInfo.getConditionitemfieldnames(""+tempconditionid) ;
if(tempconditionvalue.indexOf("%") == -1 ) sqlcondition += conditionkey + thetemptable+"."+tempfieldname+" = ''"+tempconditionvalue+"'' " ;
else sqlcondition += conditionkey + thetemptable+"."+tempfieldname+" like ''"+tempconditionvalue+"'' " ;
conditionkey = " and " ;
}
}
String fromdate = "" ;
String todate = "" ;
if(!fromyear.equals("") && !frommonth.equals("") && !fromday.equals("")) {
fromdate = fromyear+"-" + frommonth + "-" + fromday ;
sqlcondition += conditionkey + thetemptable+".reportdate >= ''"+fromdate+"'' ";
conditionkey = " and " ;
}
if(!toyear.equals("") && !tomonth.equals("") && !today.equals("")) {
todate = toyear+"-" + tomonth + "-" + today ;
sqlcondition += conditionkey + thetemptable+".reportdate <= ''"+todate+"'' ";
conditionkey = " and " ;
}
String inputstatus = "$inputstatus" ;
sqlcondition += conditionkey + thetemptable+".inputstatus >= ''"+inputstatus +"'' " ;
for(int i=0 ; i< tables.size() ; i++ ) {
if(sqlfrom.equals(""))
sqlfrom = "from " + (String)tablenames.get(i) +" "+ (String)tables.get(i) ;
else {
String temptable = (String)tables.get(i) ;
sqlfrom += " left join " + (String)tablenames.get(i) +" "+ temptable ;
conditionkey = " on " ;
for(int j=0 ; j<conditionids.size() ; j++) {
int tempconditionid = Util.getIntValue((String)conditionids.get(j),0) ;
String tempconditionvalue = (String)conditionvalues.get(j) ;
if(tempconditionid == 1 || tempconditionvalue.equalsIgnoreCase("$crm_code") ) {
sqlfrom += conditionkey + thetemptable + ".crmid = " + temptable + ".crmid " ;
conditionkey = " and " ;
}
else if(tempconditionid > 7 ) {
String tempfieldname = ConditionComInfo.getConditionitemfieldnames(""+tempconditionid) ;
sqlfrom += conditionkey + thetemptable + "." + tempfieldname + " = " + temptable + "." + tempfieldname ;
conditionkey = " and " ;
}
}
if(!fromdate.equals("") || !todate.equals("") ) {
sqlfrom += conditionkey + thetemptable + ".reportdate = " + temptable + ".reportdate " ;
conditionkey = " and " ;
}
sqlfrom += conditionkey + thetemptable + ".modtype = " + temptable + ".modtype " ;
}
}
for(int j=0 ; j<conditionids.size() ; j++) {
int tempconditionid = Util.getIntValue((String)conditionids.get(j),0) ;
String tempconditionvalue = (String)conditionvalues.get(j) ;
if(tempconditionid == 1 || tempconditionvalue.equalsIgnoreCase("$crm_code") ) {
sqlfrom += " , CRM_CustomerInfo " ;
break ;
}
}
RecordSet.executeSql("update T_OutReportItem set itemtable ='"+sqlfrom+"' , itemcondition = '" +
sqlcondition + "' , firstaltertablename = '" + thetemptable + "' " +
" where itemid="+itemid) ;
}
}
// ¸ÄΪÓÐpost ·½·¨Ìá½»
%>
<HTML>
<BODY onload='frOutReportItemOperation.submit ()'>
<FORM name=frOutReportItemOperation method=post action='OutReportItemDetail.jsp'>
<input type=hidden name=haspost value="1">
<input type=hidden name=desc value="<%=itemdesc%>">
</FORM>
</BODY>
</HTML>
<%
}
if(operation.equals("delete")){
char separator = Util.getSeparator() ;
String para = itemid ;
RecordSet.executeProc("T_OutReportItem_Delete",para);
response.sendRedirect("OutReportItemDetail.jsp?haspost=2");
}
if(operation.equals("copy")){
if(!fromitem.equals("")) {
if(toitems != null) {
char separator = Util.getSeparator() ;
int toitemcount = toitems.length ;
if(fromitem.indexOf("row_") == 0 ) {
String fromrow = fromitem.substring(4) ;
for(int countindex =0 ; countindex < toitemcount ; countindex++) {
String toitemvalue = toitems[countindex] ;
if(toitemvalue.indexOf("row_") != 0 ) continue ;
String torow = toitemvalue.substring(4) ;
if(fromrow.equals(torow)) continue ;
for(int i= 1 ; i <= outrepcolumn ; i++) {
String para = outrepid + separator + torow
+ separator + ""+i + separator + fromrow + separator + ""+i ;
RecordSet.executeProc("T_OutReportItem_Copy",para);
}
}
}
if(fromitem.indexOf("col_") == 0 ) {
String fromcol = fromitem.substring(4) ;
for(int countindex =0 ; countindex < toitemcount ; countindex++) {
String toitemvalue = toitems[countindex] ;
if(toitemvalue.indexOf("col_") != 0 ) continue ;
String tocol = toitemvalue.substring(4) ;
if(fromcol.equals(tocol)) continue ;
for(int i= 1 ; i <= outreprow ; i++) {
String para = outrepid + separator + ""+i
+ separator + tocol + separator + ""+i + separator + fromcol ;
RecordSet.executeProc("T_OutReportItem_Copy",para);
}
}
}
if(fromitem.indexOf("rowcol_") == 0 ) {
String fromrowcol[] = Util.TokenizerString2(fromitem,"_") ;
String fromrow = fromrowcol[1] ;
String fromcol = fromrowcol[2] ;
for(int countindex =0 ; countindex < toitemcount ; countindex++) {
String toitemvalue = toitems[countindex] ;
if(toitemvalue.indexOf("col_") == 0 ) {
String tocol = toitemvalue.substring(4) ;
for(int i= 1 ; i <= outreprow ; i++) {
String torow = "" +i ;
if(fromrow.equals(torow) && fromcol.equals(tocol)) continue ;
String para = outrepid + separator + torow
+ separator + tocol + separator + fromrow + separator + fromcol ;
RecordSet.executeProc("T_OutReportItem_Copy",para);
}
}
if(toitemvalue.indexOf("row_") == 0 ) {
String torow = toitemvalue.substring(4) ;
for(int i= 1 ; i <= outrepcolumn ; i++) {
String tocol = "" +i ;
if(fromrow.equals(torow) && fromcol.equals(tocol)) continue ;
String para = outrepid + separator + torow
+ separator + tocol + separator + fromrow + separator + fromcol ;
RecordSet.executeProc("T_OutReportItem_Copy",para);
}
}
if(toitemvalue.indexOf("rowcol_") == 0 ) {
String torowcol[] = Util.TokenizerString2(toitemvalue,"_") ;
String torow = torowcol[1] ;
String tocol = torowcol[2] ;
if(fromrow.equals(torow) && fromcol.equals(tocol)) continue ;
String para = outrepid + separator + torow
+ separator + tocol + separator + fromrow + separator + fromcol ;
RecordSet.executeProc("T_OutReportItem_Copy",para);
}
}
}
}
}
response.sendRedirect("OutReportItem.jsp?outrepid="+outrepid);
}
if(operation.equals("deletebatch")){
char separator = Util.getSeparator() ;
if(deletetype.equals("1")) {
for(int j= 1 ; j<= outrepcolumn ; j++ ) {
String para = outrepid + separator + itemrow + separator + ""+j ;
RecordSet.executeProc("T_OutReportItem_DeleteByRowCol",para);
}
}
else if(deletetype.equals("2")) {
for(int j= 1 ; j<= outreprow ; j++ ) {
String para = outrepid + separator + ""+j + separator + itemcolumn ;
RecordSet.executeProc("T_OutReportItem_DeleteByRowCol",para);
}
}
response.sendRedirect("OutReportItem.jsp?outrepid="+outrepid);
}
if(operation.equals("editrow")){
RecordSet.executeSql(" select row_id from T_OutReportItemRow where outrepid="+outrepid+" and itemrow="+itemrow );
if(RecordSet.next()) {
RecordSet.executeSql(" delete from T_OutReportItemRow where outrepid="+outrepid+" and itemrow="+itemrow );
}
else {
RecordSet.executeSql(" insert into T_OutReportItemRow(outrepid,itemrow) values("+outrepid+","+itemrow +")");
}
response.sendRedirect("OutReportItem.jsp?outrepid="+outrepid);
}
if(operation.equals("editcrmgroup")){
RecordSet.executeSql(" delete T_OutReportItemRowGroup where outrepid="+outrepid+" and itemrow="+itemrow );
String crmgroup = Util.null2String(request.getParameter("crmgroup"));
if (!crmgroup.equals("")) RecordSet.executeSql(" insert into T_OutReportItemRowGroup(outrepid,itemrow,rowgroup) values("+outrepid+","+itemrow +",'"+crmgroup+"')");
response.sendRedirect("OutReportItem.jsp?outrepid="+outrepid);
}
%>