-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathedit_case.php
409 lines (381 loc) · 14.2 KB
/
edit_case.php
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
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
<?php
// ReqHeap - a simple requirement management program.
//
// Copyright (C) 2007 Slav Peev , Matthias Gunter
// Programmed by i-nature.com
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as
// published by the Free Software Foundation, either version 3 of the
// License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
//
// -----------------------------------------------------------------
//
// Page: "edit case" - editing/adding/deleting case
//check if logged
if (!($_SESSION['rights']=="2" || $_SESSION['rights']=="3" || $_SESSION['rights']=="4" || $_SESSION['rights']=="5")) header("Location:index.php");
if ($action=="delete" && $c_id!="")
{
$query="delete from project_cases where pc_c_id=".$c_id;
mysql_query($query) or die(mysql_error());
$query="delete from release_cases where rc_c_id=".$c_id;
mysql_query($query) or die(mysql_error());
$query="delete from cases where c_id=".$c_id;
mysql_query($query) or die(mysql_error());
header("Location:index.php?inc=manage_cases");
}
if ($action=="add")
{
//work up the text
$ta=str_replace('<link href="styles.css" rel="stylesheet" />','',stripslashes($ta));
$ta2=str_replace('<link href="styles.css" rel="stylesheet" />','',stripslashes($ta2));
$query="insert into cases (c_name, c_desc, c_result, c_status, c_global) values ('".escapeChars($c_name)."','".stripbr(escapeChars($ta))."','".stripbr(escapeChars($ta2))."','".escapeChars($c_status)."','".escapeChars($c_global)."')";
mysql_query($query) or die(mysql_error());
$c_id=mysql_insert_id();
//header("Location:index.php?inc=manage_cases");
}
if ($action=="update" && $c_id!="")
{
//work up the text
$ta=str_replace('<link href="styles.css" rel="stylesheet" />','',stripslashes($ta));
$ta2=str_replace('<link href="styles.css" rel="stylesheet" />','',stripslashes($ta2));
$query="update cases set c_name='".escapeChars($c_name)."', c_desc='".stripbr(escapeChars($ta))."', c_result='".stripbr(escapeChars($ta2))."', c_status='".escapeChars($c_status)."', c_global='".escapeChars($c_global)."' where c_id=".$c_id;
mysql_query($query) or die(mysql_error());
//header("Location:index.php?inc=manage_cases");
}
// if ($what=="projects_list" && $c_id!="")
if ($action!="")
{
$query="delete from project_cases where pc_c_id=".$c_id;
mysql_query($query) or die(mysql_error());
$list = explode(",", substr($projects_list,1));
if ($projects_list!="")
{
while (list ($key, $val) = each ($list))
{
$query="insert into project_cases (pc_c_id, pc_p_id) values ('".$c_id."','".$val."')";
mysql_query($query) or die(mysql_error());
}
}
//header("Location:index.php?inc=manage_cases");
}
// if ($what=="releases_list" && $c_id!="")
if ($action!="")
{
$query="delete from release_cases where rc_c_id=".$c_id;
mysql_query($query) or die(mysql_error());
$list = explode(",", substr($releases_list,1));
if ($releases_list!="")
{
while (list ($key, $val) = each ($list))
{
$query="insert into release_cases (rc_c_id, rc_r_id) values ('".$c_id."','".$val."')";
mysql_query($query) or die(mysql_error());
}
}
header("Location:index.php?inc=manage_cases");
}
if ($c_id!="")
{
$query="select * from cases where c_id=".$c_id;
$rs = mysql_query($query) or die(mysql_error());
if($row=mysql_fetch_array($rs))
{
$c_name=htmlspecialchars($row['c_name']);
$c_desc=$row['c_desc'];
$c_result=$row['c_result'];
$c_status=$row['c_status'];
$c_global=$row['c_global'];
}
}
?>
<?if ($tmp!="") echo $tmp;?>
<form method="post" name="f" action="">
<table border="0" width="70%">
<tr valign="top">
<td>
<input type="hidden" name="c_id" value="<?=$c_id?>">
<table border="0" cellpadding="2" cellspacing="2" class="content" width="100%">
<tr class="gray">
<td colspan="2" align="center"><b><?=($c_id=="")?$lng[30][2]:$lng[30][1]?></b></td>
</tr>
<tr class="blue" title="<?=$lng[30][12]?>">
<td align="right"> <?=$lng[30][3]?> : </td>
<td> <input type="text" name="c_name" value="<?=$c_name?>" maxlength="90" size=60></td>
</tr>
<tr class="blue" valign=top title="<?=$lng[30][13]?>">
<td align="right"> <?=$lng[30][4]?> : </td>
<td><?
include("FCKeditor/fckeditor.php");
$oFCKeditor = new FCKeditor('ta') ;
$oFCKeditor->BasePath = 'FCKeditor/' ;
$oFCKeditor->Value = $c_desc;
$oFCKeditor->Width = '560';
$oFCKeditor->Height = '300';
$oFCKeditor->Create() ;
?>
</td>
</tr>
<tr class="blue" title="<?=$lng[30][14]?>">
<td align="right"> <?=$lng[30][5]?> : </td>
<td>
<?
$oFCKeditor = new FCKeditor('ta2') ;
$oFCKeditor->BasePath = 'FCKeditor/' ;
$oFCKeditor->Value = $c_result;
$oFCKeditor->Width = '560';
$oFCKeditor->Height = '300';
$oFCKeditor->Create() ;
?>
</td>
</tr>
<tr class="light_blue" title="<?=$lng[30][15]?>">
<td align="right"> <?=$lng[30][6]?> : </td>
<td>
<select name="c_status">
<option value="1" <?if ($c_status==1) echo "selected";?>><?=$lng[30][16];?>
<option value="0" <?if ($c_status==0) echo "selected";?>><?=$lng[30][17];?>
</select>
</td>
</tr>
<tr class="blue" title="<?=$lng[13][13]?>">
<td align="right"> <?=$lng[13][12]?> : </td>
<td>
<select name="c_global">
<option value="0"><?=$lng[13][14]?>
<option value="1" <?if ($c_global==1) echo "selected";?>><?=$lng[13][15]?>
</select>
</td>
</tr>
</table>
<input type="hidden" name="inc" value="edit_case">
<input type="hidden" name="action" value="">
<!--/form-->
</td>
</tr>
<!--/table-->
<?
if ($c_id!="")
{
$tmp_list="0";
$query="select p.* from projects p, project_cases pc where p.p_id=pc.pc_p_id and pc.pc_c_id=".$c_id." and p.p_status<>2 order by p_name asc";
$rs = mysql_query($query) or die(mysql_error());
while($row=mysql_fetch_array($rs))
{
$p_projects_list2.="<option value='".$row['p_id']."'>".htmlspecialchars($row['p_name']);
$tmp_list.=",".$row['p_id'];
}
$query="select * from projects where p_status<>2 and p_id not in (".$tmp_list.")";
$rs = mysql_query($query) or die(mysql_error());
while($row=mysql_fetch_array($rs))
{
$p_projects_list.="<option value='".$row['p_id']."'>".htmlspecialchars($row['p_name']);
}
}
else
{
$tmp_list="0";
$query="select p.* from projects p, project_cases pc where p.p_id=pc.pc_p_id and pc.pc_c_id=0 and p.p_status<>2 order by p_name asc";
$rs = mysql_query($query) or die(mysql_error());
while($row=mysql_fetch_array($rs))
{
$p_projects_list2.="<option value='".$row['p_id']."'>".htmlspecialchars($row['p_name']);
$tmp_list.=",".$row['p_id'];
}
$query="select * from projects where p_status<>2 and p_id not in (".$tmp_list.")";
$rs = mysql_query($query) or die(mysql_error());
while($row=mysql_fetch_array($rs))
{
$p_projects_list.="<option value='".$row['p_id']."'>".htmlspecialchars($row['p_name']);
}
}
?>
<!--br/>
<table border="0" width="60%"-->
<tr valign="top">
<td>
<!--form method="post" name="f2" action="">
<input type="hidden" name="c_id" value="<?=$c_id?>"-->
<table border="0" cellpadding="2" cellspacing="2" class="content" width="100%">
<tr class="gray" title="<?=$lng[30][20]?>">
<td colspan="3" align="center"><b><?=$lng[30][19]?></b></td>
</tr>
<tr class="blue">
<td align="center">
<br/><?=$lng[30][21]?><br/>
<select name="projects_tmp" multiple size=10 style="width:190px;background:#F3F3F3;">
<?=$p_projects_list?>
</select><br/><br/>
</td>
<td align="center"><a href="#" onclick="copyToList('projects_tmp','projects_tmp2','f');return false;"><b>==></b></a><br><br><a href="#" onclick="copyToList('projects_tmp2','projects_tmp','f');return false;"><b><==</b></a></td>
<td align="center">
<br/><?=$lng[30][22]?><br/>
<select name="projects_tmp2" multiple size=10 style="width:190px;background:#F3F3F3;">
<?=$p_projects_list2?>
</select><br/><br/>
</td>
</tr>
<!--tr class="gray">
<td colspan="3" align="center">
<input type="button" onclick="selectProjects();" value="<?=$lng[10][27]?>">
</td>
</tr-->
</table>
<!--input type="hidden" name="inc" value="edit_case"-->
<input type="hidden" name="projects_list" value="">
<!--input type="hidden" name="what" value="">
</form-->
</td>
</tr>
<!--/table-->
<?
if ($c_id!="")
{
$tmp_list="0";
$query="select r.* from releases r, release_cases rc where r.r_id=rc.rc_r_id and rc.rc_c_id=".$c_id." order by r_name asc";
$rs = mysql_query($query) or die(mysql_error());
while($row=mysql_fetch_array($rs))
{
$p_releases_list2.="<option value='".$row['r_id']."'>".htmlspecialchars($row['r_name']);
$tmp_list.=",".$row['r_id'];
}
$query="select * from releases where r_id not in (".$tmp_list.")";
$rs = mysql_query($query) or die(mysql_error());
while($row=mysql_fetch_array($rs))
{
$p_releases_list.="<option value='".$row['r_id']."'>".htmlspecialchars($row['r_name']);
}
}
else
{
$tmp_list="0";
$query="select r.* from releases r, release_cases rc where r.r_id=rc.rc_r_id and rc.rc_c_id=0 order by r_name asc";
$rs = mysql_query($query) or die(mysql_error());
while($row=mysql_fetch_array($rs))
{
$p_releases_list2.="<option value='".$row['r_id']."'>".htmlspecialchars($row['r_name']);
$tmp_list.=",".$row['r_id'];
}
$query="select * from releases where r_id not in (".$tmp_list.")";
$rs = mysql_query($query) or die(mysql_error());
while($row=mysql_fetch_array($rs))
{
$p_releases_list.="<option value='".$row['r_id']."'>".htmlspecialchars($row['r_name']);
}
}
?>
<!--br/>
<table border="0" width="60%"-->
<tr valign="top">
<td>
<!--form method="post" name="f3" action="">
<input type="hidden" name="c_id" value="<?=$c_id?>"-->
<table border="0" cellpadding="2" cellspacing="2" class="content" width="100%">
<tr class="gray" title="<?=$lng[30][24]?>">
<td colspan="3" align="center"><b><?=$lng[30][23]?></b></td>
</tr>
<tr class="blue">
<td align="center">
<br/><?=$lng[30][25]?><br/>
<select name="releases_tmp" multiple size=10 style="width:190px;background:#F3F3F3;">
<?=$p_releases_list?>
</select><br/><br/>
</td>
<td align="center"><a href="#" onclick="copyToList('releases_tmp','releases_tmp2','f');return false;"><b>==></b></a><br><br><a href="#" onclick="copyToList('releases_tmp2','releases_tmp','f');return false;"><b><==</b></a></td>
<td align="center">
<br/><?=$lng[30][26]?><br/>
<select name="releases_tmp2" multiple size=10 style="width:190px;background:#F3F3F3;">
<?=$p_releases_list2?>
</select><br/><br/>
</td>
</tr>
<!--tr class="gray">
<td colspan="3" align="center">
<input type="button" onclick="selectReleases();" value="<?=$lng[10][27]?>">
</td>
</tr-->
</table>
<!--input type="hidden" name="inc" value="edit_case"-->
<input type="hidden" name="releases_list" value="">
<!--input type="hidden" name="what" value="">
</form-->
</td>
</tr>
<tr class="gray">
<td colspan="2" align="center">
<?if ($c_id=="") {?><input type="button" onclick="sub('add');" value="<?=$lng[30][11]?>"><?}?>
<?if ($c_id!="") {?><input type="button" onclick="sub('update');" value="<?=$lng[30][11]?>"> <input type="button" onclick="if (confirm('<?=$lng[30][10]?>')) sub('delete');" value="<?=$lng[30][18]?>"><?}?>
</td>
</tr>
</table>
</form>
<script>
function sub(what)
{
df=document.forms['f'];
if (what!="delete")
{
if (df.c_name.value=="")
{
alert("<?=$lng[30][9]?>");
df.c_name.focus();
return false;
}
}
df.action.value=what;
selectProjects();
selectReleases();
df.submit();
}
function copyToList(from,to,form_name)
{
fromList = eval('document.forms["'+form_name+'"].' + from);
toList = eval('document.forms["'+form_name+'"].' + to);
if (toList.options.length > 0 && toList.options[0].value == 'temp')
{
toList.options.length = 0;
}
var sel = false;
for (i=0;i<fromList.options.length;i++)
{
var current = fromList.options[i];
if (current.selected)
{
sel = true;
txt = current.text;
val = current.value;
toList.options[toList.length] = new Option(txt,val);
fromList.options[i] = null;
i--;
}
}
}
function selectProjects()
{
document.forms['f'].projects_list.value="";
for (i=0;i<document.forms['f'].projects_tmp2.options.length;i++)
{
document.forms['f'].projects_list.value+=","+document.forms['f'].projects_tmp2.options[i].value;
}
//document.forms['f'].what.value="projects_list";
//document.forms['f'].submit();
}
function selectReleases()
{
document.forms['f'].releases_list.value="";
for (i=0;i<document.forms['f'].releases_tmp2.options.length;i++)
{
document.forms['f'].releases_list.value+=","+document.forms['f'].releases_tmp2.options[i].value;
}
//document.forms['f'].what.value="releases_list";
//document.forms['f'].submit();
}
</script>