0f4bb43d13723e0b6f4a721faea637d14ca9c95e
[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.1 $
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.1  2007-02-01 12:31:23  arjen
33    Added web interface for editing issues
34
35
36 ******************************/
37
38 // RCSID = "$Id: issues.php,v 1.1 2007-02-01 12:31:23 arjen Exp $";
39
40 ini_set('include_path', '.:./classes:../phpclasses');
41
42 require_once('page.class.php');
43
44 function clientscripts()
45 {
46
47 ?>
48
49 <script language='JavaScript'>
50
51 function CheckCreate(f)
52 {
53    if (f.issuename.value == "")
54    {
55       alert("You must supply an issue name");
56       return false;
57    }
58
59    if (f.issuedescr.value == "")
60    {
61       alert("You must supply a description");
62       return false;
63    }
64    return true;
65 }
66
67 function CheckRemove(f)
68 {
69    var message = "Are you sure you want to remove issue type '";
70    message += f.issuename.value;
71    message += "' ?";
72
73    return confirm(message);
74 }
75
76 </script>
77
78 <?php
79 }
80
81 class issue_page extends page
82 {
83
84    function Body()
85    {
86
87    clientscripts();
88
89    if (isset($_POST['action']) && $_POST['action'] == 'Create'
90        && !empty($_POST['issuename']) && !empty($_POST['issuedescr']))
91    {
92       pg_exec($this->database, "INSERT INTO type_of_issue
93                        (name, suggested_priority, description) VALUES ('"
94                      . $_POST['issuename'] . "','" . $_POST['prior'] . "','" . $_POST['issuedescr'] . "')");
95    }
96
97    if (isset($_POST['action']) && $_POST['action'] == 'Remove'
98        && !empty($_POST['issueid']) )
99    {
100       pg_exec($this->database, "DELETE FROM type_of_issue WHERE type_of_issueid='"
101                                 . $_POST['issueid'] . "'");
102    }
103
104    echo "<h1>Issue Types Administration</h1><hr>";
105
106    $res = pg_exec($this->database, "SELECT type_of_issueid, name, suggested_priority, description
107                                     FROM type_of_issue ORDER BY name");
108
109    echo "<table>";
110    echo "<tr><th>Issue</th><th>Priority</th><th>Description</th><tr>";
111    $cls = 0;
112    while ($cls < pg_numrows($res))
113    {
114       $u = pg_fetch_object($res, $cls);
115       ?>
116       <tr><td align='center'><img src='bell.png'><br>
117              <b><?php echo $u->name ?></b>
118       </td><td>
119          <?php echo $u->suggested_priority ?>
120       </td><td>
121          <?php echo $u->description ?>
122       </td><td>
123           <form action='issues.php' method='post' onSubmit='return CheckRemove(this)'>
124               <input type='hidden' name='issueid' value='<?php echo $u->type_of_issueid ?>'>
125               <input type='hidden' name='issuename' value='<?php echo $u->name ?>'>
126               <input type='submit' name='action' value='Remove'>
127           </form>
128       </td></tr>
129       <?php
130       $cls++;
131    }
132    echo "</table>";
133
134 ?>
135
136 <h2>Create new issue type:</h2>
137 <p>
138
139 <form action='issues.php' method='post' onSubmit='return CheckCreate(this)'>
140 Issue name: <input name='issuename' type='text'>
141 Priority: <select name='prior'>
142 <option value='1'>1</option>
143 <option value='2'>2</option>
144 <option value='3'>3</option>
145 <option value='4'>4</option>
146 <option value='5'>5</option>
147 </select>
148 Description: <input name='issuedescr' type='text'>
149 <br>
150 <input type='submit' name='action' value='Create'>
151 </form>
152 </p>
153
154 <?php
155    }
156 }
157
158 $page = new issue_page("Gnucomo Parameter Classes Administration");
159
160 $page->Showpage();
161
162 ?>