/[debian]/quickappoint/branches/upstream/current/appointment.php
ViewVC logotype

Contents of /quickappoint/branches/upstream/current/appointment.php

Parent Directory Parent Directory | Revision Log Revision Log


Revision 140 - (show annotations)
Sat Feb 25 17:48:32 2006 UTC (15 years, 5 months ago) by gregoa
File size: 8082 byte(s)
[svn-inject] Installing original source of quickappoint
1 <?php
2 /*
3 Description:
4
5 Required variables:
6 id
7 Optional variable:
8 comment
9 values: 0 (or not specified): show no comments
10 1: show short comments
11 2: show all comments
12 */
13
14 require_once(dirname(__FILE__) . '/lib/prepend.php');
15 require_once(dirname(__FILE__) . '/lib/dblogic.php');
16 require_once(dirname(__FILE__) . '/lib/html.php');
17
18 $appointmentid = isset($_GET['id']) ? $_GET['id'] : '';
19 if (empty($appointmentid)) die('No id specified');
20 if (!is_numeric($appointmentid)) die('Invalid id');
21 $appointmentid = (int) $appointmentid;
22 if (isset($_GET['comments'])) {
23 $showcomments = (int) $_GET['comments'];
24 if ($showcomments < 0 || $showcomments > 2) $showcomments = 0;
25 } else $showcomments = 0;
26
27 $appointment = getAppointment($appointmentid);
28 extract(html_escape_array($appointment));
29 $proposals = getProposals($appointmentid);
30 $participants = getParticipants($appointmentid);
31 $appointmentrights = getAppointmentRights($appointmentid, $_SESSION['person']['id']);
32 $expired = strtotime($expire_date)+84600 > time();
33
34 ?>
35 <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
36
37 <html>
38 <head>
39 <title><?php echo htmlspecialchars($title); ?></title>
40 <meta http-equiv="content-type" content="text/html; charset=ISO-8859-1">
41 <meta name="Author" content="Toastfreeware">
42 <link rel="stylesheet" type="text/css" href="<?php echo $cssname; ?>">
43 <!-- <link rel="icon" href="icons/icon.png" type="image/png"> -->
44 </head>
45 <body>
46
47 <?php
48
49 if (isset($_SESSION['editdbmsg'])) echo html_element('p', array('class'=>'hint'), $_SESSION['editdbmsg']);
50 unset($_SESSION['editdbmsg']);
51
52 if ($appointmentrights) {
53
54 echo html_element('h1', $title);
55 if ($description) echo html_element('p', array('class' => 'description'), $description);
56 if ($location) echo html_element('p', array('class' => 'location'), $location);
57 if ($expired) echo html_element('p', array('id' => 'expirewarning'), _('This appointment has expired.'));
58 ?>
59
60
61 <h2><?php echo htmlspecialchars(_("Available proposals")); ?></h2>
62
63 <?php if (count($proposals) == 0)
64 echo html_element('p', array('class' => 'noproposals'), _('There are no proposals.'));
65 else {
66 echo "<table>\n";
67
68 // title
69 echo "\t<tr><th>" . htmlspecialchars(_('proposal')) . '</th>';
70 foreach ($participants as $person) {
71 extract(html_escape_array($person));
72 echo "<th>";
73 if ($email) echo html_element('a', array('href' => "mailto:$email"), $fullname, TRUE);
74 else echo(htmlspecialchars($fullname));
75 echo "</th>";
76 }
77 echo "</tr>\n";
78
79 // responses
80 foreach ($proposals as $proposal) {
81 extract(html_escape_array($proposal));
82 echo "\t<tr";
83 switch ($accepted) {
84 case 't': echo ' class="accepted"'; break;
85 case 'f': echo ' class="declined"'; break;
86 }
87 // new idea:
88 // $timestamp = strtotime("$date $time");
89 // echo "><td>$date $time (" . strftime('%a', $timestamp) . ')</td>';
90 echo "><td>$date $time ($day)</td>";
91 $respones = getResponses($id);
92 foreach ($respones as $response) {
93 extract(html_escape_array($response));
94 if ($showcomments == '1') $comment = htmlspecialchars(text_cut($response['comment'], 15));
95 echo "<td>";
96 if ($value) echo "<strong>$value</strong>";
97 if ($showcomments) echo '&nbsp;', $comment;
98 echo "</td>";
99 }
100 echo "</tr>\n";
101 }
102 echo "</table>\n";
103 echo '<p>';
104 if ($showcomments != 0) echo '<a href="', $_SERVER['PHP_SELF'], "?id=$appointmentid&amp;comments=0\">", htmlspecialchars(_('No comments')), '</a> ';
105 if ($showcomments != 1) echo '<a href="', $_SERVER['PHP_SELF'], "?id=$appointmentid&amp;comments=1\">", htmlspecialchars(_('Short comments')), '</a> ';
106 if ($showcomments != 2) echo '<a href="', $_SERVER['PHP_SELF'], "?id=$appointmentid&amp;comments=2\">", htmlspecialchars(_('Full comments')), '</a>';
107 echo "</p>\n";
108
109
110 // don't show if expired except the user is manager
111 if ($expired || $appointmentrights['manageappointment']) {
112 ?>
113
114 <h2><?php echo htmlspecialchars(_('Own responses')); ?></h2>
115
116 <p><?php echo htmlspecialchars(sprintf(_('A short comment on values: The range for values is %1$d to %2$d.'), $appointment['minvalue'], $appointment['maxvalue']));
117 echo ' ';
118 if ($appointment['approvaldesc']) $text = _('The lower the better.');
119 else $text = _('The higher the better.');
120 echo htmlspecialchars($text); ?></p>
121
122 <?php
123 $sql = 'select proposalid, value, comment, personid from response, proposal where personid=' . $_SESSION['person']['id'] . " and appointmentid=$appointmentid and response.proposalid=proposal.id and date >= date(now()) order by date";
124 $data = pg_u_query_assoc($db_conn, $sql);
125 $sql = "select id, date || ', ' || to_char(time, 'HH24:MI') || to_char(date, ' (Dy)') as datetime from proposal where appointmentid=$appointmentid and date >= date(now()) order by date";
126 $lookup_hash = array_to_hash(pg_u_query_num($db_conn, $sql));
127 $sql = "select id, date || ', ' || to_char(time, 'HH24:MI') || to_char(date, ' (Dy)') as datetime from proposal where appointmentid=$appointmentid and date >= date(now()) and id not in (select proposalid from response where personid=" . $_SESSION['person']['id'] . ") order by date";
128 $insert_hash = array_to_hash(pg_u_query_num($db_conn, $sql));
129
130 $columns = array(
131 new DiOnlyInputSelect('proposalid:', _('proposal'), NULL, $lookup_hash, $insert_hash),
132 new DiTextEdit('value', _('value'), NULL, 3),
133 new DiTextEdit('comment', _('comment'), NULL, 50),
134 new DiHidden('personid:', (string) $_SESSION['person']['id'])
135 );
136
137 echo html_createEditForm(
138 'cgi-bin/editdb.php',
139 basename($_SERVER['REQUEST_URI']),
140 'response',
141 $columns,
142 $data, // Array of rows, that are again arrays of columns
143 count($insert_hash) > 0, TRUE, TRUE);
144 } // if not expired
145 } // if (count($proposals) > 0)
146
147
148 if (($expired || $appointmentrights['manageappointment']) && ($appointmentrights['insertproposal'] || $appointmentrights['updateproposal'] || $appointmentrights['deleteproposal'])) {
149 ?>
150
151 <h2><?php echo htmlspecialchars(_('Manage proposals')); ?></h2>
152
153 <?php
154 $columns = array(
155 new DiHidden('id:'),
156 new DiReadOnly(_('day')),
157 new DiTextEdit('date', _('date'), NULL, 15, 'yyyy-mm-dd'),
158 new DiTextEdit('time', _('time'), NULL, 15, 'hh:mm'),
159 ($appointmentrights['manageappointment'] ? new DiBoolEdit('accepted', _('accepted')) : new DiBoolReadOnly(_('accepted'))),
160 new DiHidden('appointmentid', (string) $appointmentid)
161 );
162
163 echo html_createEditForm(
164 'cgi-bin/editdb.php',
165 basename($_SERVER['REQUEST_URI']),
166 'proposal',
167 $columns,
168 $proposals, // Array of rows, that are again arrays of columns
169 $appointmentrights['insertproposal'], $appointmentrights['updateproposal'], $appointmentrights['deleteproposal']);
170 }
171
172
173 if ($appointmentrights['manageperson']) {
174 ?>
175
176
177 <h2><?php echo htmlspecialchars(_('Invited persons')); ?></h2>
178
179 <?php
180 $sql = "select personid as id, appointmentid, personid, insertproposal, updateproposal, deleteproposal, manageappointment, permission.manageperson from permission, person where appointmentid=$appointmentid and personid=person.id order by fullname";
181 $permission_data = pg_u_query_assoc($db_conn, $sql);
182
183 $sql = "select id, fullname from person order by fullname";
184 $person_data = array_to_hash(pg_u_query_num($db_conn, $sql));
185
186 $columns = array(
187 new DiHidden('personid:'),
188 new DiHidden('appointmentid:', (string) $appointmentid),
189 new DiOnlyInputSelect('personid', _('person'), NULL, $person_data, $person_data),
190 new DiBoolEdit('insertproposal', _('insert proposal'), 'f'),
191 new DiBoolEdit('updateproposal', _('update proposal'), 'f'),
192 new DiBoolEdit('deleteproposal', _('delete proposal'), 'f'),
193 new DiBoolEdit('manageappointment', _('manage appointment'), 'f'),
194 new DiBoolEdit('manageperson', _('manage person'), 'f')
195 );
196
197 echo html_createEditForm(
198 'cgi-bin/editdb.php',
199 basename($_SERVER['REQUEST_URI']),
200 'permission',
201 $columns,
202 $permission_data, // Array of rows, that are again arrays of columns
203 TRUE, TRUE, TRUE);
204 }
205
206 } else { ?>
207
208 <p><em>Person and appointment don't go well together ...</em></p>
209
210 <?php } ?>
211
212 <p><a href="overview.php"><?php echo htmlspecialchars(_('Back')); ?></a></p>
213
214
215 </body>
216 </html>

  ViewVC Help
Powered by ViewVC 1.1.26