The buttonbar at the top of each page is now a fixed 'div' element
[gnucomo.git] / src / web / issues.php
1 <?php 
2
3 /**************************************************************************
4 **  (c) Copyright 2003, Andromeda Technology & Automation
5 ** This is free software; you can redistribute it and/or modify it under the
6 ** terms of the GNU General Public License, see the file COPYING.
7 ***************************************************************************
8 ** MODULE INFORMATION *
9 ***********************
10 **      FILE NAME      : issues.php
11 **      SYSTEM NAME    : Gnucomo - Gnu Computer Monitoring
12 **      VERSION NUMBER : $Revision: 1.2 $
13 **
14 **  DESCRIPTION      :  Issue types Administration page.
15 **                      Input parameters: action (POST) : empty, 'Create'
16 **                            issuename (POST) : short name of the issue
17 **
18 **  EXPORTED OBJECTS : 
19 **  LOCAL    OBJECTS : 
20 **  MODULES  USED    :
21 ***************************************************************************
22 **  ADMINISTRATIVE INFORMATION *
23 ********************************
24 **      ORIGINAL AUTHOR : Arjen Baart - arjen@andromeda.nl
25 **      CREATION DATE   : Aug 04, 2003
26 **      LAST UPDATE     : Aug 28, 2003
27 **      MODIFICATIONS   : 
28 **************************************************************************/
29
30 /*****************************
31    $Log: issues.php,v $
32    Revision 1.2  2007-11-21 14:38:06  arjen
33    The buttonbar at the top of each page is now a fixed 'div' element
34    instead of a framed page.
35    Contributed by Edwin Nadorp.
36
37    Revision 1.1  2007/02/01 12:31:23  arjen
38    Added web interface for editing issues
39
40
41 ******************************/
42
43 // RCSID = "$Id: issues.php,v 1.2 2007-11-21 14:38:06 arjen Exp $";
44
45 ini_set('include_path', '.:./classes:../phpclasses');
46
47 require_once('page.class.php');
48
49 function clientscripts()
50 {
51
52 ?>
53
54 <script type='text/ecmascript'>
55
56 function CheckCreate(f)
57 {
58    if (f.issuename.value == "")
59    {
60       alert("You must supply an issue name");
61       return false;
62    }
63
64    if (f.issuedescr.value == "")
65    {
66       alert("You must supply a description");
67       return false;
68    }
69    return true;
70 }
71
72 function CheckRemove(f)
73 {
74    var message = "Are you sure you want to remove issue type '";
75    message += f.issuename.value;
76    message += "' ?";
77
78    return confirm(message);
79 }
80
81 </script>
82
83 <?php
84 }
85
86 class issue_page extends page
87 {
88
89    function Body()
90    {
91
92    clientscripts();
93
94    if (isset($_POST['action']) && $_POST['action'] == 'Create'
95        && !empty($_POST['issuename']) && !empty($_POST['issuedescr']))
96    {
97       pg_exec($this->database, "INSERT INTO type_of_issue
98                        (name, suggested_priority, description) VALUES ('"
99                      . $_POST['issuename'] . "','" . $_POST['prior'] . "','" . $_POST['issuedescr'] . "')");
100    }
101
102    if (isset($_POST['action']) && $_POST['action'] == 'Remove'
103        && !empty($_POST['issueid']) )
104    {
105       pg_exec($this->database, "DELETE FROM type_of_issue WHERE type_of_issueid='"
106                                 . $_POST['issueid'] . "'");
107    }
108
109    echo "<script type='text/ecmascript'>document.getElementById('menu_title').innerHTML = '<h1>Issue Types Administration<\/h1>'</script><br>";
110
111    $res = pg_exec($this->database, "SELECT type_of_issueid, name, suggested_priority, description
112                                     FROM type_of_issue ORDER BY name");
113
114    echo "<table>";
115    echo "<tr><th>Issue</th><th>Priority</th><th>Description</th></tr>";
116    $cls = 0;
117    while ($cls < pg_numrows($res))
118    {
119       $u = pg_fetch_object($res, $cls);
120       ?>
121       <tr><td align='center'><img src='bell.png' alt='bell'><br>
122              <b><?php echo $u->name ?></b>
123       </td><td>
124          <?php echo $u->suggested_priority ?>
125       </td><td>
126          <?php echo $u->description ?>
127       </td><td>
128           <form action='issues.php' method='post' onSubmit='return CheckRemove(this)'>
129               <input type='hidden' name='issueid' value='<?php echo $u->type_of_issueid ?>'>
130               <input type='hidden' name='issuename' value='<?php echo $u->name ?>'>
131               <input type='submit' name='action' value='Remove'>
132           </form>
133       </td></tr>
134       <?php
135       $cls++;
136    }
137    echo "</table>";
138
139 ?>
140
141 <h2>Create new issue type:</h2>
142
143 <form action='issues.php' method='post' onSubmit='return CheckCreate(this)'>
144 Issue name: <input name='issuename' type='text'>
145 Priority: <select name='prior'>
146 <option value='1'>1</option>
147 <option value='2'>2</option>
148 <option value='3'>3</option>
149 <option value='4'>4</option>
150 <option value='5'>5</option>
151 </select>
152 Description: <input name='issuedescr' type='text'>
153 <br>
154 <input type='submit' name='action' value='Create'>
155 </form>
156
157 <?php
158    }
159 }
160
161 $page = new issue_page("Gnucomo Parameter Classes Administration");
162
163 $page->Showpage();
164
165 ?>