Odyssey
resetPktstamp.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 (isset($w) == false || $w > 2)
7  $w = "1";
8 
9 $dbh = $link;
10 
11 if (!CheckPerm($link, $Hu, basename($_SERVER['SCRIPT_NAME']), $_SERVER['REMOTE_ADDR'])) {
12  // ** Permissions failed
13  // ** redirect to new page
14  header("Location: /hcuadm/hcu_noperm.prg");
15  exit;
16 }
17 
18 $dms_ok = array('cu' => 'string', 'w' => 'string', 'msg' => 'string');
19 
20 dms_import($dms_ok);
21 
22 switch ($w):
23 
24  case "1":
25  cu_header("Set Packet Stamps for Full-packet Refresh");
26 
27  $sql = "SELECT COUNT(user_name) FROM {$cu}user";
28  $cnt_rs = db_query($sql, $dbh);
29  list($usercount) = db_fetch_array($cnt_rs);
30  db_free_result($cnt_rs);
31 
32  $sql = "SELECT COUNT(accountnumber) FROM {$cu}memberacct";
33  $cnt_rs = db_query($sql, $dbh);
34  list($memcount) = db_fetch_array($cnt_rs);
35  db_free_result($cnt_rs);
36  ?>
37  <form action="<?php echo $_SERVER['PHP_SELF']; ?>?cu=<?php echo $cu; ?>" method="post">
38  <input type="hidden" value="2" name="w">
39  <table border=0 align=center cellpadding=3 cellspacing=0 width=500 class="dmsbg"><tr><td>
40  <table border=0 cellpadding=1 cellspacing=0 width="100%" bgcolor=white>
41  <tr>
42  <td class='bar' align=center>
43  Set Packet Stamps for Full-packet Refresh
44  </td>
45  </tr>
46  <?php if ($memcount == 0): ?>
47  <tr>
48  <td class='dtl' align=center>
49  <br>No member accounts found!<br>Please check CU code and try again
50  </td>
51  </tr>
52  <?php else: ?>
53  <?php if (isset($msg)): ?>
54  <tr>
55  <td class='dtl' align=center>
56  <br><?php echo $msg; ?>
57  </td>
58  </tr>
59  <?php else: ?>
60  <tr>
61  <td align=center class='dtl'>
62  <font size="3" color="red">
63  WARNING!<br>
64  This will set all member accounts at <?php echo $cu; ?> to request a full-refresh packet.<br>Be sure this is what you want to do.
65  </font>
66  </td>
67  </tr>
68  <tr>
69  <td class='dtl' align=center>
70  <table border=0 cellpadding=0 cellspacing=0>
71  <tr>
72  <td class="dtl" align="left">
73  &nbsp;Current Users:&nbsp;
74  </td>
75  <td class="dtl" align="right">
76  &nbsp;<?php echo $usercount; ?>&nbsp;
77  </td>
78  </tr>
79  <tr>
80  <td class="dtl" align="left">
81  &nbsp;Current Member Accounts:&nbsp;
82  </td>
83  <td class="dtl" align="right">
84  &nbsp;<?php echo $memcount; ?>&nbsp;
85  </td>
86  </tr>
87  </table>
88  </td>
89  </tr>
90  <tr>
91  <td class='dtl' align=center>
92  <hr>
93  </td>
94  </tr>
95  <tr>
96  <td class='dtl'>
97  Are you sure you want to reset packet stamps for member accounts at <?php echo strtoupper($cu); ?>?
98  </td>
99  </tr>
100  <tr>
101  <td class='dtl'>
102  <input type="submit" value="Yes, please do it NOW!!" name="btnVerify">
103  </td>
104  </tr>
105  <?php endif; ?>
106  <?php endif; ?>
107  </table>
108  </td></tr></table>
109  </form>
110  </body>
111  </html>
112 
113  <?php
114  break;
115  case "2":
116 
117  // *** SANITY CHECK THE CREDIT UNION ID
118  $sql = "SELECT trim(cu) FROM cuadmin WHERE user_name = '" . prep_save($cu) . "'";
119  $cu_rs = db_query($sql, $dbh);
120  list($cu_code) = db_fetch_array($cu_rs);
121  db_free_result($cu_rs);
122 
123  if ($cu_code != "") {
124  // ** I HAVE THE CODE -- UPDATE THE memberacct, accountbalance and loanbalance tables
125  $upd_sql = "";
126  $upd_sql .= "UPDATE {$cu_code}accountbalance SET balance_stamp = 1, history_stamp = 1;";
127  $upd_sql .= "UPDATE {$cu_code}loanbalance SET balance_stamp = 1, history_stamp = 1;";
128  $upd_sql .= "UPDATE {$cu_code}memberacct SET balance_stamp = 1;";
129 
130  if ($upd_rs = db_query($upd_sql, $dbh)) {
131  $upd_msg = "I have reset packet stamps for " . db_affected_rows($upd_rs) . " member accounts. I hope this helped.";
132  } else {
133  $upd_msg = "The member accounts were NOT updated. Please contact a system administrator to update the member accounts.";
134  }
135  } else {
136  // *** CU CODE NOT VALID
137  $upd_msg = "The credit union code is NOT valid. Please contact a system administrator to update the member accounts.";
138  }
139 
140  header("Location: {$_SERVER['PHP_SELF']}?cu={$cu}&msg=" . urlencode($upd_msg));
141  exit;
142  break;
143 endswitch;
144 ?>