Odyssey
Admin_SurveyView.prg
1 <?php
2  $monLibrary= dirname(__FILE__) . "/../library";
3  require_once("$monLibrary/cu_top.i");
4  require_once("$monLibrary/ck_hticket.i");
5 
6  if (!CheckPerm($link, $Hu, basename($_SERVER['SCRIPT_NAME']), $_SERVER['REMOTE_ADDR'])) {
7  // ** Permissions failed
8  // ** redirect to new page
9  header("Location: /hcuadm/hcu_noperm.prg");
10  exit;
11  }
12 
13 $dms_ok=array('showid'=>'string','viewmsg'=>'digits');
14 dms_import($dms_ok);
15 
16  print <<<EOF
17  <CENTER>
18  <TABLE WIDTH=95% BORDER=0 CELLPADDING=0 CELLSPACING=0>
19  <tr><td CLASS=""><DIV CLASS="barb">Admin Survey</DIV></td></tr>
20  <tr><td>
21  <table border=0 cellspacing=0 cellpadding=2 width=100%>
22  <tr><td class='bar'>HomeCU Survey</td></tr></table>
23  <table border=0 cellspacing=0 cellpadding=2 width=100%>
24 EOF;
25 
26  $showid = trim(strtoupper((empty($showid) ? "PRESENT" : $showid)));
27 
28  switch ($showid) {
29  case "ALL":
30  $sclause = "";
31  break;
32  case "PRESENT":
33  $sclause = " and runstat = 1 and m.startdate < now() and m.stopdate > now() ";
34  break;
35  case "DRAFT":
36  $sclause = " and m.runstat = 0 ";
37  break;
38  case "FUTURE":
39  $sclause = " and m.runstat = 1 and m.startdate > now() ";
40  break;
41  default:
42  $sclause = " and m.surveyid = $showid ";
43  break;
44  }
45  $sql = "select m.surveyid, qstyle, question, answerid, answertext
46  from cuadmin_surveymaster m, cuadmin_surveydetail d
47  where m.surveyid = d.surveyid $sclause
48  order by stopdate, surveyid, answerid";
49 
50  $sth = db_query($sql,$link);
51 
52  print "<form>";
53 
54  for ($row=0; list( $surveyid, $qstyle, $qtext, $answerid, $atext ) =
55  db_fetch_array($sth,$row); $row++) {
56 
57  if ($cur_sid != "$surveyid"){
58 
59  // if not first question
60 
61  if ($cur_sid != "" ) {
62  echo "</table><br>";
63  }
64 
65  if (intval($viewmsg) == 0) {
66  $qtext = htmlspecialchars($qtext);
67  } else {
68  $qtext = trim($qtext);
69  }
70  echo "<table border=0 CELLSPACING=1 CELLPADDING=2 width=100%><tr>\n
71  <td CLASS=hdr1>$qtext</td></tr>";
72  $cur_sid = "$surveyid";
73  $rbg="odd";
74  }
75 
76  if (intval($viewmsg) == 0) {
77  $atext = htmlspecialchars($atext);
78  print <<<EOF
79  <tr CLASS={$rbg}_small>
80  <td><input type="radio" name="response[$surveyid]" value="$answerid">
81  &nbsp;<font size=-1>$atext</font></td></tr>
82 EOF;
83  }
84  $rbg = ($rbg == "odd" ? "even" : "odd");
85  }
86  db_free_result($sth);
87 
88  if ($cur_sid == "" ) {
89  switch ($showid) {
90  case "PRESENT":
91  $notfound = "No PRESENT Surveys Found";
92  break;
93  case "DRAFT":
94  $notfound = "No DRAFT Surveys Found";
95  break;
96  case "FUTURE":
97  $notfound = "No FUTURE Surveys Found";
98  break;
99  default:
100  $notfound = "No Surveys Found";
101  break;
102  }
103  print <<<EOF
104  <table border=0 cellspacing=0 cellpadding=2 width=100%>
105  <tr><td class='hdr1'>$notfound</td></tr>
106 EOF;
107  }
108  print <<<EOF
109  </table></td></tr></TABLE><br>
110  <input type=button value='Close' onClick='self.close();'></form>
111 EOF;
112  echo "</body></html>";
113 ?>