Odyssey
tr_hist.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('w'=>'digits','user_name'=>'string','wc'=>'string','set_trunc'=>'string','unset_trunc'=>'string');
14 
15 dms_import($dms_ok);
16 
17  if (isset($w) == false || $w > 2) $w = "1";
18 
19  $dbh = $link;
20 
21  switch ($w):
22 
23  case "1":
24  cu_header("Truncate History");
25  $sql = "SELECT histtrunc FROM cuadmin WHERE user_name = '$user_name'";
26  $sql_rs = db_query($sql, $dbh);
27  $sql_row = db_fetch_array($sql_rs, 0);
28  $tr_hist = $sql_row['histtrunc'];
29 
30 ?>
31  <form action="tr_hist.prg" method="post">
32  <input type="hidden" value="<?php echo $user_name; ?>" name="user_name">
33  <input type="hidden" value="<?php echo $wc; ?>" name="wc">
34  <input type="hidden" value="2" name="w">
35  <table border=0 align=center cellpadding=3 cellspacing=0 width=500 class="dmsbg"><tr><td>
36  <table border=0 cellpadding=1 cellspacing=0 width="100%" bgcolor=white>
37  <tr>
38  <td class='bar' align=center>
39  Truncate History
40  </td>
41  </tr>
42  <tr>
43  <td align=center class='dtl'>
44  <font size="4" color="red">
45  WARNING!<br>
46  This will delete the history records of this Credit Union. <br>Be sure this is what you want to do
47  </font>
48  </td>
49  </tr>
50  <tr>
51  <td class='dtl'>
52  Currently truncate history is set to <span style="font-weight: bold; color: red;" class="err2"><?php echo ($tr_hist == 1 ? "YES" : "NO"); ?></span>
53  </td>
54  </tr>
55  <tr>
56  <td class='dtl'>
57  Truncate history the next time this credit union is uploaded?
58  </td>
59  </tr>
60  <tr>
61  <td class='dtl'>
62  <input type="submit" value="Yes" name="set_trunc">
63  <input type="submit" value="No" name="unset_trunc">
64  </td>
65  </tr>
66  </table>
67  </td></tr></table>
68 <?php
69  break;
70  case "2":
71  // This part of the form will be used for saving the flag
72  if ((isset($set_trunc) || isset($unset_trunc)) && isset($user_name)) {
73  if (isset($set_trunc))
74  $val= "1";
75  else
76  $val = "0";
77  $sql = "UPDATE cuadmin SET histtrunc = '$val' WHERE user_name = '$user_name'";
78  if (!$sql_rs = db_query($sql, $dbh))
79  $err = true;
80  else
81  $err = false;
82  }
83  else
84  $err = true;
85 
86  if ($err == true) {
87  cu_header("Truncate History");
88  print ("<form>");
89  cu_message("Unexpected errors!<br>Try again.");
90  }
91  else {
92  // Redirect to the main page
93  header("Location: $infourl/hcuadm/cuview.prg?user_name=$user_name&wc=$wc");
94  exit;
95  }
96 ?>
97 
98 <?php
99  break;
100  endswitch;
101 ?>
102 
103  </form>
104  </body>
105  </html>