Correcting time entry slowness
[wrms.git] / html / qams-request-approval.php
blobad23b77a44629d088387c8c8adb487dbad93c48c
1 <?php
2 /* ******************************************************************** */
3 /* CATALYST PHP Source Code */
4 /* -------------------------------------------------------------------- */
5 /* This program is free software; you can redistribute it and/or modify */
6 /* it under the terms of the GNU General Public License as published by */
7 /* the Free Software Foundation; either version 2 of the License, or */
8 /* (at your option) any later version. */
9 /* */
10 /* This program is distributed in the hope that it will be useful, */
11 /* but WITHOUT ANY WARRANTY; without even the implied warranty of */
12 /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
13 /* GNU General Public License for more details. */
14 /* */
15 /* You should have received a copy of the GNU General Public License */
16 /* along with this program; if not, write to: */
17 /* The Free Software Foundation, Inc., 59 Temple Place, Suite 330, */
18 /* Boston, MA 02111-1307 USA */
19 /* -------------------------------------------------------------------- */
20 /* */
21 /* Filename: qams-request-approval.php */
22 /* Author: Paul Waite */
23 /* Description: QAMS step approval request page */
24 /* */
25 /* ******************************************************************** */
26 require_once("always.php");
27 require_once("authorisation-page.php");
29 $session->LoginRequired();
31 require_once("maintenance-page.php");
33 $title = "QAMS Request Approval";
35 // -----------------------------------------------------------------------------------------------
36 include_once("qams-project-defs.php");
38 // -----------------------------------------------------------------------
39 // FUNCTIONS
40 function ContentForm(&$project, &$qastep) {
41 global $have_admin;
43 $s = "";
44 $s .= "<table cellspacing=\"2\" cellpadding=\"2\" width=\"100%\">\n";
46 $s .= "<tr class=\"row0\">";
47 $s .= "<td colspan=\"2\" style=\"padding-left:20px;padding-right:50px\">"
48 . "<p>The information and fields below are to help you obtain a Quality Assurance Approval "
49 . "from a nominated reviewer. The reviewer has to be someone 'allocated' to the project, "
50 . "so if you don't find them on the list, you will need to add them to the project (use "
51 . "the Edit Project link) and then return to this screen once that is done.</p>"
52 . "<p>When you click on the 'Request Approval' button QAMS will e-mail the selected reviewer "
53 . "with a request for approval. The e-mail will contain links to the details screen for this "
54 . "QA Step, <b><u>to which you should have attached any relevant document(s)</b></u> for "
55 . "the review.</p>"
56 . "</td>";
57 $s .= "</tr>\n";
59 // Vertical spacer
60 $s .= "<tr class=\"row0\">";
61 $s .= "<td colspan=\"2\" height=\"15\">&nbsp;</td>";
62 $s .= "</tr>\n";
64 // Project brief..
65 $s .= "<tr class=\"row1\">";
66 $s .= "<th width=\"30%\" class=\"prompt\"><b>Project:</b> </th>";
67 $s .= "<td width=\"70%\">$project->brief</td>";
68 $s .= "</tr>\n";
70 // Step description..
71 $s .= "<tr class=\"row1\">";
72 $s .= "<th class=\"prompt\"><b>Step to approve:</b> </th>";
73 $s .= "<td>" . $qastep->qa_step_desc . "</td>";
74 $s .= "</tr>\n";
76 // Step notes..
77 $s .= "<tr class=\"row1\">";
78 $s .= "<th class=\"prompt\"><b>Notes:</b> </th>";
79 $s .= "<td><p>" . $qastep->qa_step_notes . "</p></td>";
80 $s .= "</tr>\n";
82 // Special notes..
83 if ( isset($qastep->special_notes) ) {
84 $s .= "<tr class=\"row1\">";
85 $s .= "<th class=\"prompt\"><b>Special notes:</b> </th>";
86 $s .= "<td>" . $qastep->special_notes . "</td>";
87 $s .= "</tr>\n";
90 // Overall status..
91 $status = qa_status_coloured($qastep->overall_approval_status());
92 $s .= "<tr class=\"row1\">";
93 $s .= "<th class=\"prompt\"><b>Current overall status:</b> </th>";
94 $s .= "<td>$status</td>";
95 $s .= "</tr>\n";
97 // Required approvals list..
98 $s .= "<tr class=\"row1\">";
99 $s .= "<th class=\"prompt\"><b>Current approval statuses:</b> </th>";
100 $s .= "<td>" . $qastep->render_approval_types(false, true) . "</td>";
101 $s .= "</tr>\n";
103 // Request from person..
104 $F = "<select size=\"1\" name=\"approval_from_person\">";
105 $F .= "<option value=\"\">-- select a person --</option>\n";
106 $extras = array();
107 if (isset($project->user_no) && isset($project->fullname)) {
108 $extras[$project->user_no] = $project->fullname;
110 $extras[$project->project_manager] = $project->project_manager_fullname;
111 $extras[$project->qa_mentor] = $project->qa_mentor_fullname;
112 $requestors = $extras + $project->allocated;
113 foreach ($requestors as $user_no => $fullname) {
114 $F .= "<option value=\"$user_no\">$fullname</option>\n";
116 $F .= "</select>\n";
118 $s .= "<tr class=\"row1\">";
119 $s .= "<th class=\"prompt\"><b>Send to this reviewer:</b> </th>";
120 $s .= "<td>" . $F . "</td>";
121 $s .= "</tr>\n";
123 // Approval type to request..
124 $F = "<select size=\"1\" name=\"approval_type\">";
125 $F .= "<option value=\"\">-- select an approval type --</option>\n";
126 foreach ($qastep->approvals_required() as $ap_type_id => $ap_type_desc) {
127 $F .= "<option value=\"$ap_type_id\"";
128 $F .= ">$ap_type_desc</option>\n";
130 $s .= "<tr class=\"row1\">";
131 $s .= "<th class=\"prompt\"><b>Requesting this approval:</b> </th>";
132 $s .= "<td>" . $F . "</td>";
133 $s .= "</tr>\n";
135 $F = "<textarea name=\"approval_covernotes\" style=\"width:400px;height:150px\">";
136 $F .= "</textarea>";
137 $s .= "<tr class=\"row1\">";
138 $s .= "<th class=\"prompt\"><b>Covering notes:</b> </th>";
139 $s .= "<td>" . $F . "</td>";
140 $s .= "</tr>\n";
142 // Vertical spacer
143 $s .= "<tr class=\"row0\">";
144 $s .= "<td colspan=\"2\" height=\"15\">&nbsp;</td>";
145 $s .= "</tr>\n";
147 $s .= "<tr class=\"row0\">";
148 $s .= "<td colspan=\"2\" style=\"padding-left:20px;padding-right:50px\">"
149 . "<p>The e-mail will also contain clickable links for the recipient to either "
150 . "Approve or Refuse the request. If the above all looks ok, then click the "
151 . "button below to send the e-mail off.</p>"
152 . "</td>";
153 $s .= "</tr>\n";
155 // Vertical spacer
156 $s .= "<tr class=\"row0\">";
157 $s .= "<td colspan=\"2\" height=\"25\">&nbsp;</td>";
158 $s .= "</tr>\n";
160 $s .= "</table>\n";
161 return $s;
163 } // ContentForm
166 // -----------------------------------------------------------------------------------------------
167 // MAIN CONTENT
169 // Must haves..
170 if (!isset($step_id)) {
171 exit;
174 // Get the step
175 $qastep = new qa_project_step();
176 $qastep->get($step_id);
178 if ($qastep->valid) {
179 // Project object to work with..
180 $project = new qa_project($qastep->project_id);
181 $have_admin = $project->qa_process->have_admin;
183 else {
184 unset($qastep);
187 $s = "";
188 if (isset($qastep)) {
190 // PROCESS POSTED UPDATES..
191 if (isset($submit) && $submit == "Request Approval") {
192 if ($project->request_id > 0 && $approval_from_person != "" && $approval_type != "") {
193 // Now create and deliver some e-mail..
194 $qry = new PgQuery("SELECT email, fullname FROM usr WHERE user_no=$approval_from_person");
195 if ($qry->Exec("qams-request-approval.php::get approver") && $qry->rows > 0) {
196 $row = $qry->Fetch();
198 // Approver email..
199 $approver_email = $row->email;
200 $approver_fullname = $row->fullname;
201 $subject = "QAMS Approval Request: $qastep->qa_step_desc [$project->system_id/$project->username]";
202 $recipients = array($approver_email => $approver_fullname);
204 // First of all, let's sort out the database..
205 $qastep->request_approval($approval_type, $approval_from_person);
207 // Assemble body for approver..
208 $s = "";
209 $s .= "<p>This is a request for you to <b>review and approve</b> a Quality Assurance Step ";
210 $s .= "for the project. Please do so as soon as you can manage it, otherwise it ";
211 $s .= "is possible the project may be held up.</p>";
212 $s .= "<p>The step for review is: <b>" . $qastep->qa_step_desc . "</b></p>";
213 if ($qastep->qa_document_title != "") {
214 $s .= "<p>The focus of this review is documentation, the '" . $qastep->qa_document_title . "'. ";
215 if ($qastep->qa_document_desc != "") {
216 $s .= $qastep->qa_document_desc;
218 $s .= "This document, and any other files, are now available to you for ";
219 $s .= "review at the link provided below.</p>";
222 // Review/Approve link..
223 $href = $URL_PREFIX . "/qams-step-approve.php";
224 $href .= "?step_id=$qastep->qa_project_step_id";
225 $href .= "&ap_type_id=$approval_type";
226 $desc = "Click to Review and Approve: $qastep->qa_step_desc";
227 $applink = "<a href=\"$href\">$desc</a>";
229 $s .= "<p>&nbsp; &nbsp;</p>";
230 $s .= "<p>This link will take you to the Review/Approval screen for this QA Step.<br>";
231 $s .= "&nbsp;&nbsp;" . $applink . "</p>";
232 $s .= "<p>&nbsp; &nbsp;</p>";
234 // General notes
235 if ($qastep->qa_step_notes != "") {
236 $s .= "<p>Points to consider: " . $qastep->qa_step_notes . "</p>";
238 // Covering notes..
239 if ($approval_covernotes != "") {
240 $s .= "<p><b>Specific Notes:</b><br>";
241 $s .= $approval_covernotes . "</p>";
244 $s .= "<p>Thank you for participating in Catalyst Quality Assurance.</p>";
245 $project->QAMSNotifyEmail("Request for QA approval", $s, $subject, $recipients);
247 // Other emails to let everyone know what's going on..
248 $recipients = $project->GetRecipients();
249 if (isset($recipients[$approver_email])) {
250 unset($recipients[$approver_email]);
252 $s = "<p>A request has been sent to $approver_fullname to review and ";
253 $s .= "approve the Quality Assurance Step '$qastep->qa_step_desc' on this project. ";
254 $s .= "The details for this QA step are available here:<br>";
255 $href = $URL_PREFIX . "/qams-step-detail.php?step_id=$qastep->qa_project_step_id";
256 $desc = "Quality Assurance Step Details for: $qastep->qa_step_desc";
257 $stlink = "<a href=\"$href\">$desc</a>";
258 $s .= "&nbsp;&nbsp;" . $stlink . "</p>";
259 $project->QAMSNotifyEmail("QAMS Activity Notice", $s, $subject, $recipients);
260 } // got approver email
264 // Main content..
265 require_once("top-menu-bar.php");
266 require_once("page-header.php");
268 $s = "";
269 $ef = new EntryForm($_SERVER['REQUEST_URI'], $project, ($have_admin ? 1 : 0));
270 $ef->NoHelp();
272 if ($have_admin) {
273 $s .= $ef->StartForm();
274 $s .= $ef->HiddenField( "qa_action", "$qa_action" );
276 if ( $project->request_id > 0 ) {
277 $s .= $ef->HiddenField( "project_id", $project->request_id );
278 $s .= $ef->HiddenField( "step_id", "$qastep->qa_project_step_id" );
280 // Start main table..
281 $s .= "<table width=\"100%\" class=\"data\" cellspacing=\"0\" cellpadding=\"0\">\n";
283 $s .= $ef->BreakLine("Quality Assurance Approval Request");
284 $s .= "<tr><td height=\"15\" colspan=\"2\">&nbsp;</td></tr>";
285 $s .= "<tr><td colspan=\"2\">" . ContentForm($project, $qastep) . "</td></tr>";
286 $s .= "<tr><td height=\"15\" colspan=\"2\">&nbsp;</td></tr>";
287 $s .= "</table>\n";
289 if ($have_admin) {
290 $s .= $ef->SubmitButton( "submit", "Request Approval" );
291 $s .= $ef->EndForm();
294 } // isset qastep
296 // -----------------------------------------------------------------------------
297 // ASSEMBLE CONTENT
298 if ($s == "") {
299 $content = "<p>Nothing known about that QA step.</p>";
301 else {
302 $content = $s;
305 // -----------------------------------------------------------------------------
306 // DELIVER..
308 echo $content;
310 include("page-footer.php");