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 373 374
| <%@page contentType="text/html"%>
<%@page pageEncoding="UTF-8"%>
<%@page import="java.sql.*" %>
<%@page import="com.airliquide.essbase.report.Menu"%>
<%@page language="java" import="com.airliquide.essbase.custom.*" %>
<%@page import="java.lang.*,java.io.*" %>
<%@page import="java.lang.String"%>
<%@page import="java.util.regex.Matcher"%>
<%@page import="java.util.regex.Pattern"%>
<%@page import="java.util.StringTokenizer"%>
<%@ include file="_HeaderConfig.jsp" %>
<%@ include file="repAccessControl.jsp"%>
<%@ include file="_PageTop.jsp" %>
<%@ include file="repEntete.jsp" %>
<%@ include file="repConnBegin.jsp" %>
<%
out.println("coucou");
%>
<script language="JavaScript">
function itemUp () {
var i = document.form.list.selectedIndex;
var valueTamp = document.form.list.options[i].value;
var textTamp = document.form.list.options[i].text;
document.form.list.options[i].value = document.form.list.options[i-1].value;
document.form.list.options[i].text = document.form.list.options[i-1].text;
document.form.list.options[i-1].value = valueTamp;
document.form.list.options[i-1].text = textTamp;
document.form.list.selectedIndex=i-1;
getList();
}
function itemDown () {
var i = document.form.list.selectedIndex;
var valueTamp = document.form.list.options[i].value;
var textTamp = document.form.list.options[i].text;
document.form.list.options[i].value = document.form.list.options[i+1].value;
document.form.list.options[i].text = document.form.list.options[i+1].text;
document.form.list.options[i+1].value = valueTamp;
document.form.list.options[i+1].text = textTamp;
document.form.list.selectedIndex=i+1;
getList();
}
function getList() {
var list = document.form.list;
var str="";
for(i=0;i<list.length;i++){
str += document.form.list.options[i].value+";";
}
document.form.objectOrder.value=str;
}
</script>
<div class="pagetitle">Administration section - Edit or Modify a report or a category<div align="left" class="prev_back"><a href="javascript:history.back()" class="link"><b><< BACK</b></a></div></div>
<%
String type = session.getAttribute("S_Report").toString();
// in this case we display the tree structure so that the user can choose an object to modify
if (request.getParameter("page1")!=null){
int par = 0;
int lev = 1;
if (request.getParameter("dad")!=null){
String strParent = request.getParameter("dad");
String strLevel = request.getParameter("level");
par = Integer.parseInt(strParent);
lev = Integer.parseInt(strLevel);
}
%>
<div align="center">
<div class="formulaire" align="center">
<br><font color="#666666" size="4"><b>Modify file Form.</b></font><BR>
<a href="repModify.jsp?in=ok" class="link">: : Back to the root : :</a><BR><br>
<%
if (request.getParameter("message")!=null){
out.println("<font color=\"#0000FF\"><b>"+request.getParameter("message")+"</b></font>");
}
%>
<form method="post" name="delete_form" action="repModify.jsp">
<div style="width:310px;color:#333333;width:auto;padding-left:20px">Select a report or a category to modify :<br><br></div>
<table class="delete_tree" cellspacing="0" cellpadding="0">
<%
Menu m = new Menu();
String res = new String(m.modifyTable(connection, statement, type, par, lev));
out.println(res);
%>
</table>
<br>
<table align="center">
<tr>
<td>
<input type=hidden name="page2" value="ok">
<input type="submit" value="Modify" class="button">
</td>
</tr>
</table>
</form>
</div>
</div>
<%
}
else{
if (request.getParameter("page2")!=null){
String errorMessage="";
if (request.getParameter("error")!=null){
errorMessage = request.getParameter("error");
}
String strId = request.getParameter("toModify");
int id = Integer.parseInt(strId);
String sql="SELECT * FROM REPORT WHERE REPORT_ID='"+id+"'";
rs = statement.executeQuery(sql);
rs.next();
int file_idPar = rs.getInt(5);
String file_label = rs.getString(2);
String file_path = rs.getString(3);
String file_name = rs.getString(8);
String file_display = rs.getString(9);
String file_type = rs.getString(7);
int file_level = rs.getInt(6);
String file_parent="";
if (file_level==1){
file_parent = "root";
}else{
sql="SELECT REPORT_NAME FROM REPORT WHERE REPORT_ID='"+file_idPar+"'";
rs=statement.executeQuery(sql);
rs.next();
file_parent = rs.getString(1);
}
%>
<div align="center">
<div class="formulaire">
<form method="POST" action="repModify.jsp" name="form" onsubmit="javascript : getList()">
<input type="hidden" name="page3" value="ok">
<%
out.println("<input type=hidden name=repId value=\""+id+"\">");
out.println("<input type=hidden name=parId value=\""+file_idPar+"\">");
out.println("<input type=hidden name=repTy value=\""+file_type+"\">");
%>
<table class="access_tab" border=0 cellpadding="3">
<tr>
<td colspan=4><font color="#CC0000"><b>
<%
if (errorMessage.compareTo("")!=0){
out.println(errorMessage);
}
%>
</b></font></td>
</tr>
<tr>
<td style="color:#000000;font-weight:bold;font-size:11px">ID :</td>
<%
out.println("<td colspan=3 align=\"left\">"+id+"</td>");
%>
</tr>
<tr>
<td style="color:#000000;font-weight:bold;font-size:11px">Label :</td>
<td colspan=3 align="left">
<%
out.println("<input type=text name=\"label\" value=\""+file_label+"\">");
%>
</td>
</tr>
<%
if (file_type.compareTo("R")==0){
%>
<tr>
<td style="color:#000000;font-weight:bold;font-size:11px;padding-bottom:0px">Path :</td>
<td colspan=3 align="left">
<%
out.println(file_path);
%>
</td>
</tr>
<%
}
if (file_type.compareTo("R")==0){
%>
<tr>
<td style="color:#000000;font-size:10px;padding-top:0px" nowrap><img src="images/fleche.gif">Change it :</td>
<td colspan=3 align="left"><input type=file name="new_fp"></td>
</tr>
<%
}
else{
out.println("<input type=hidden name=\"new_fp\" value=\"\">");
}
%>
<tr>
<td style="color:#000000;font-weight:bold;font-size:11px">Parent :</td>
<td colspan=3>
<%
out.println(file_parent);
%>
</td>
</tr>
<%
if (file_type.compareTo("R")==0){
%>
<tr>
<td style="color:#000000;font-weight:bold;font-size:11px" nowrap>File name :</td>
<td colspan=3>
<%
out.println(file_name);
%>
</td>
</tr>
<%
}
%>
<tr>
<td style="color:#000000;font-weight:bold;font-size:11px">Display :</td>
<td>
<%
out.println(file_display);
%>
</td>
<td style="color:#000000;font-weight:bold;font-size:11px" align=right>Type :</td>
<td align="left">
<%
if (file_type.compareTo("R")==0){
out.println("Report");
}
else{
out.println("Category");
}
%>
</td>
</tr>
<%
if (file_type.compareTo("C")==0){
%>
</table>
<br>
<table>
<tr>
<td>
<select name="list" size=8 style="width:250px">
<script language="javascript">
var list = document.form.list;
<%
rs=statement.executeQuery("SELECT REPORT_ID, REPORT_NAME FROM REPORT WHERE REPORT_PARENT='"+id+"' ORDER BY REPORT_ORDER");
while(rs.next()){
out.println("list.options[list.options.length] = new Option('"+rs.getString(2)+"','"+rs.getInt(1)+"');\n");
}
%>
</script>
</select>
</td>
<td>
<img src="images/up.gif" border=0 onclick="javascript : itemUp()">
<br>
<img src="images/down.gif" border=0 onclick="javascript : itemDown()">
</td>
</tr>
<tr>
<td colspan=2 align=center><br>
<input type=hidden name=objectOrder value="">
<input class="button" type=submit value="Modify" onclick="javascript : void getList()">
</td>
</tr>
</table>
<%
}
else{
%>
<tr>
<td colspan=4 align=center><br>
<input class="button" type=submit value="Modify">
</td>
</tr>
</table>
<%
}
%>
</form>
</div>
</div>
<%
}
else{
// case of controling and operating modifications
if (request.getParameter("page3")!=null){
String label = request.getParameter("label");
String newFP = request.getParameter("new_fp");
String rid = request.getParameter("repId");
String strIdPar = request.getParameter("parId");
String fType = request.getParameter("repTy");
int dadId = Integer.parseInt(strIdPar);
// Is the label field set ?
if (label.compareTo("")==0){
response.sendRedirect("repModify.jsp?page2=ok&toModify="+rid+"&error=You didn't fill the label field.");
}
// is the string correct ?
Pattern pattern = null;
Matcher matcher = null;
/********* TO DO !!!!!!!!!!!!! *************/
/* we need to control the unicity of the name in the category
int intId = Integer.parseInt(rid);
rs = statement.executeQuery("SELECT * FROM REPORT WHERE REPORT_NAME='"+label+"' AND REPORT_PARENT='"+dadId+"'");
if(rs.next()){
int otherId = rs.getInt(1);
if (otherId!=intId){
response.sendRedirect("repModify.jsp?page2=ok&error=The name you choose already exists in this category&toModify="+rid);
}
}*/
pattern = Pattern.compile("^[a-zA-Z0-9_ ]+$");
matcher = pattern.matcher(label);
boolean bool = matcher.matches();
if (!bool){
response.sendRedirect("repModify.jsp?page2=ok&toModify="+rid+"&error=The name of label you entered is not correct.");
}
// case of a category, we have to re order the children
if (fType.compareTo("C")==0){
String order = request.getParameter("objectOrder");
int tk = 1;
out.println("coucou2");
StringTokenizer orderToken = new StringTokenizer(order,";");
while (orderToken.hasMoreElements()){
statement.executeUpdate("UPDATE REPORT SET REPORT_ORDER='"+tk+"' WHERE REPORT_ID='"+orderToken.nextToken()+"'");
tk++;
}
}
// if the path has been modified, we also have to change the file name
if (newFP.compareTo("")!=0){
String newFN="";
StringTokenizer token = new StringTokenizer(newFP,"\\");
while (token.hasMoreElements()){
newFN = token.nextToken();
}
out.println("newFP :"+newFP);
statement.executeUpdate("UPDATE REPORT SET REPORT_NAME='"+label+"', REPORT_PATH='"+newFP+"', REPORT_FILE_NAME='"+newFN+"' WHERE REPORT_ID='"+rid+"'");
}
else{
statement.executeUpdate("UPDATE REPORT SET REPORT_NAME='"+label+"' WHERE REPORT_ID='"+rid+"'");
}
response.sendRedirect("repModify.jsp?page1=ok&message=The object has been successfully modified.");
}
else{
response.sendRedirect("repReporting.jsp?error=Operation not allowed !!");
}
}
}
%>
<%@ include file="repConnEnd.jsp" %>
<%@ include file="repEndAccess.jsp"%> |
Partager