Odyssey
cuhavetrans.prg
1 <?php
2 $monLibrary= dirname(__FILE__) . "/../library";
3 require_once("$monLibrary/cu_top.i");
4 require_once("$monLibrary/ck_hticket.i");
5 
6 
7  if (!CheckPerm($link, $Hu, basename($_SERVER['SCRIPT_NAME']), $_SERVER['REMOTE_ADDR'])) {
8  // ** Permissions failed
9  // ** redirect to new page
10  header("Location: /hcuadm/hcu_noperm.prg");
11  exit;
12  }
13 
14 $dms_ok=array('act'=>'digits','rowid'=>'string','cu_types'=>'array');
15 
16 dms_import($dms_ok);
17 
18  if (!isset($act)) $act = 1;
19 
20  switch ($act):
21  case 1: // Edit Cu Transactions
22  cu_header("Edit CU Transactions");
23 ?>
24  <form action="cuhavetrans.prg?act=2" method="post">
25  <input type="hidden" name="rowid" value="<?php echo $rowid; ?>">
26  <table border=0 cellpadding=1 cellspacing=1>
27  <tr><td colspan="2" align="center" class="bar">
28  Maintain Transaction Types
29  </td></tr>
30  <tr><td align=right class="hdr" valign="top">
31  Transcation Types Allowed:
32  </td>
33 
34  <td valign="top" nowrap >
35  <select name="cu_types[]" multiple size="6">
36  <?php // Create a query here to query the available
37  // products from the cuprodlist table
38 
39  $sql = "SELECT * FROM cutrans ORDER BY trandesc";
40  if ($sql_rs = db_query($sql, $link))
41  {
42  //Items were found in the table so print them, otherwise leave options empty
43  while($sql_row = db_fetch_object( $sql_rs, $row++)) {
44  // For each row we'll need to add it to the list, and look it up in the cuproducts table to see if the user has it selected
45  $trancode = htmlspecialchars(trim($sql_row->trancode));
46  $trandesc = htmlspecialchars(trim($sql_row->trandesc));
47 
48  $item_select = "";
49  $have_sql = "SELECT * FROM cuhavetrans WHERE cu = '$rowid' AND trancode = '$trancode'";
50 
51  if ($have_rs = db_query($have_sql, $link))
52  if (db_num_rows( $have_rs) > 0)
53  $item_select = "SELECTED";
54  printf("<option value=\"%s\" %s>%s\n",$trancode, $item_select, $trandesc);
55  }
56  }
57 
58  ?>
59  </select>
60  </td></tr>
61  <tr><td class='hdr'>&nbsp;</td>
62  <td class='hdr'>
63  <input type="submit" value="Save" name="save">
64  <!-- <input type="button" value="Cancel" name="cancel" onclick="document.location='cumntc?action=fetch&rowid=<?php echo $rowid; ?>'"> -->
65  <input type="button" value="Cancel" name="cancel" onclick="document.location='$infourl/hcuadm/cuilist.prg'">
66  </td></tr>
67  </table>
68 <?php
69  break;
70  case 2:
71  // The purpose of this section is to save the items the user selected
72 
73 
74 
75  // Always delete any possible items from the cuproducts table for the specified user_name
76  $save_sql = "DELETE FROM cuhavetrans WHERE cu = '$rowid'; ";
77 
78  // Now add back any selected items to the table
79  if (isset($cu_types)) {
80  foreach ($cu_types as $value) {
81  $save_sql .= " INSERT INTO cuhavetrans VALUES ('$rowid', '$value'); ";
82  }
83  }
84 
85  if (! db_query($save_sql, $link)) {
86  // Query Failed
87  printError(sprintf("<br>"));
88  printError(sprintf("Error in executing query<br>"));
89  printError(sprintf("<font face=\"Arial\" size=\"2\">Unable to Save Transcation Types!</font><br>"));
90  }
91  else {
92  // Query was successful
93  // Go back to the Update Credit union screen
94  print <<< js_code
95  <script language="javascript">
96  //document.location = "cumntc?action=fetch&rowid=$rowid";
97  document.location = "$infourl/hcuadm/cuilist.prg";
98  </script>
99 js_code;
100  }
101 
102  break;
103  default:
104  endswitch; ?>
105 
106  </form>
107 </body>
108 </html>
109