Odyssey
cusso.prg
1 <?php
2  $monLibrary= dirname(__FILE__) . "/../library";
3  $monIncludes= dirname(__FILE__) . "/../includes";
4  require_once("$monLibrary/cu_top.i");
5  require_once("$monLibrary/ck_hticket.i");
6  require_once("$monIncludes/cu_remote_top.prg");
7 
8  if (!CheckPerm($link, $Hu, basename($_SERVER['SCRIPT_NAME']), $_SERVER['REMOTE_ADDR'])) {
9  // ** Permissions failed
10  // ** redirect to new page
11  header("Location: /hcuadm/hcu_noperm.prg");
12  exit;
13  }
14 
15 $dms_ok=array('act'=>'string','vc'=>'string','ssovendor'=>'string','ssotype'=>'string','ssodesc'=>'string','contact'=>'string','email'=>'string','form_err'=>'string','msg'=>'string','phone'=>'string','setup'=>'string','comments'=>'string','Remote_Update'=>'array');
16 
17 dms_import($dms_ok);
18 
19 #case "1": // Edit Cu Image Vendors (vc=code sets edit mode, otherwise add)
20 #case "2": // Contacts list
21 #case "3": // Save add/change edits
22 #case "4": // Pop-up requirements list - bill pay vendors
23 #case "5": // Pop-up requirements list - trusted access vendor
24 #case "6": // Pop-up requirements card - selected vendor
25 
26 
27  if (!isset($act)) $act = "2";
28 
29  switch ($act):
30  case "1": // Edit CU SSO Vendors
31  cu_header("Edit CU SSO Vendors");
32 ?>
33  <form action="cusso.prg?act=3" method="post">
34  <?php
35  // Connect to the database - get the information
36  $num_rows = 0;
37  if (isset($vc)) {
38  $query = "select *
39  from cussovendors
40  where ssovendor = '$vc'";
41  $result = db_query($query, $link);
42  // Now fetch the row
43  $cusso_row = db_fetch_object($result);
44  $num_rows = db_num_rows($result);
45  }
46  if (isset($form_err) && strlen($form_err) > 0)
47  printf("\n<font color=\"red\">Errors found before saving the information. Please review errors at bottom of screen.\n<p></font>");
48  ?>
49  <center>
50  <table cellpadding="3" cellspacing="0" border="0" width="50%" class="dmsbg"><tr><td>
51  <table cellpadding="1" cellspacing="0" border="0" bgcolor=white>
52  <tr>
53  <td colspan="4" class="bar" align="center">
54  <?php if($num_rows > 0): ?>
55  EDIT CU SSO VENDOR
56  <?php else: ?>
57  ADD CU SSO VENDOR
58  <?php endif; ?>
59  </td>
60  </tr>
61  <?php if (isset($msg)): ?>
62  <tr>
63  <td colspan="4" class="msg" align="center">
64  <?php echo $msg; ?>
65  </td>
66  </tr>
67  <?php endif; ?>
68  <tr>
69  <td nowrap align="right" class="hdr">
70  SSO Vendor Code:
71  </td>
72  <td nowrap class='dtl'>
73  <?php
74  if ($num_rows > 0) {
75  $cu_info = htmlspecialchars(trim($cusso_row->ssovendor));
76  } else {
77  $cu_info = isset($ssovendor) ? set_string($ssovendor) : "";
78  }
79  ?>
80  <input type="text" name="ssovendor" size="10" maxlength="10" value="<?php echo $cu_info ?>">
81  </td>
82  </tr>
83  <tr>
84  <td nowrap valign="top" align="right" class="hdr">
85  Type:
86  </td>
87  <td nowrap class='dtl'>
88  <?php
89  if ($num_rows > 0) {
90  $cu_info = htmlspecialchars(trim($cusso_row->ssotype));
91  } else {
92  $cu_info = isset($ssotype) ? set_string($ssotype) : "";
93  }
94  ?>
95  <input type="text" name="ssotype" size="8" maxlength="1" value="<?php echo $cu_info ?>"> &nbsp; <font color='green'>B=Billpay, C=Credit Card Info, E=E-Statement, O=Other</font>
96  </td>
97  </tr>
98  <tr>
99  <td nowrap valign="top" align="right" class="hdr">
100  Name:
101  </td>
102  <td nowrap class='dtl'>
103  <?php
104  if ($num_rows > 0) {
105  $cu_info = htmlspecialchars(trim($cusso_row->ssodesc));
106  } else {
107  $cu_info = isset($ssodesc) ? set_string($ssodesc) : "";
108  }
109  ?>
110  <input type="text" name="ssodesc" size="20" maxlength="30" value="<?php echo $cu_info ?>">
111  </td>
112  </tr>
113  <tr>
114  <td nowrap align="right" class="hdr">
115  Contact:
116  </td>
117  <td nowrap class='dtl'>
118  <?php
119  if ($num_rows > 0) {
120  $cu_info = htmlspecialchars(trim($cusso_row->contact));
121  } else {
122  $cu_info = isset($contact) ? set_string($contact) : "";
123  }
124  ?>
125  <input type="text" name="contact" size="24" maxlength="40" value="<?php echo $cu_info ?>">
126  </td>
127  </tr>
128  <tr>
129  <td nowrap align="right" class="hdr">
130  Email:
131  </td>
132  <td nowrap class='dtl' >
133  <?php
134  if ($num_rows > 0) {
135  $cu_info = htmlspecialchars(trim($cusso_row->email));
136  } else {
137  $cu_info = isset($email) ? set_string($email) : "";
138  }
139  ?>
140  <input type="text" name="email" size="24" maxlength="50" value="<?php echo $cu_info ?>">
141  </td>
142  <tr>
143  <td nowrap align="right" class="hdr">
144  Phone:
145  </td>
146  <td nowrap class='dtl'>
147  <?php
148  if ($num_rows > 0) {
149  $cu_info = htmlspecialchars(trim($cusso_row->phone));
150  } else {
151  $cu_info = isset($phone) ? set_string($phone) : "";
152  }
153  ?>
154  <input type="text" name="phone" size="15" maxlength="20" value="<?php echo $cu_info ?>">
155  </td>
156  </tr>
157  <tr>
158  <td nowrap align="right" class="hdr" valign="top">
159  Comments:
160  </td>
161  <td nowrap class='dtl'>
162  <?php
163  if ($num_rows > 0) {
164  $cu_info = htmlspecialchars(trim($cusso_row->setup));
165  } else {
166  $cu_info = isset($setup) ? set_string($setup) : "";
167  }
168  ?>
169  <textarea name="setup" rows=3 cols=65 wrap="physical"><?php echo $cu_info; ?></textarea>
170  </td>
171  </tr>
172  <tr>
173  <td class='dtl'>&nbsp;</td>
174  <td nowrap class='dtl' colspan='3'>
175  <?php remote_update_list(); ?>
176  </td>
177  </tr>
178  <tr>
179  <td nowrap colspan="4" align="center" class='dtl'>
180  <input type="submit" name="Save" Value="Save">&nbsp;&nbsp;
181  <input type="button" name="Cancel" Value="Cancel" onClick="document.location='cusso.prg'">
182  </td>
183  </table>
184 
185  <?php // If the error value is here then print it at the end
186  if (isset($form_err))
187  {
188  echo $form_err;
189  echo "<hr>";
190  }
191  echo "</td></tr></table>";
192  break;
193  case "2":
194  cu_header(" CU SSO Vendors");
195  ?>
196  <form>
197 
198  <?php
199  // Connect to the data and retrieve the current list of SSO vendors
200  $query = "SELECT * FROM cussovendors ORDER BY ssovendor";
201  $prod_result = db_query($query, $link);
202 
203  ?>
204 
205  <!-- Print out the top of the table -->
206 
207  <table border="0" cellpadding="3" cellspacing="0" align="center" width="60%" class="dmsbg"><tr><td>
208  <table border="0" cellpadding="1" cellspacing="0" align="center" bgcolor=white>
209  <tr>
210  <td colspan="6" class="bar" align="center">
211  CU SSO VENDORS LIST
212  </td>
213  </tr>
214  <?php if (isset($msg)): ?>
215  <tr>
216  <td colspan="6" class="msg" align="center">
217  <?php echo $msg; ?>
218  </td>
219  </tr>
220  <?php endif; ?>
221  <tr>
222  <td class="hdr" align="left">
223  CU SSO Vendor
224  </td>
225  <td class="hdr" align="left">
226  Type
227  </td>
228  <td class="hdr" align="left">
229  Name
230  </td>
231  <td class="hdr" align="left">
232  Contact
233  </td>
234  <td class="hdr" align="left">
235  Phone
236  </td>
237  <td class="hdr" align="left">
238  Email
239  </td>
240  </tr>
241  <?php
242  $RGB = "odd";
243  $row = 0;
244  while ($prod_row = db_fetch_object($prod_result, $row)):
245  $row++;
246  ?>
247  <tr class="<?php echo $RGB; ?>">
248  <td class='usul' nowrap >
249  <a href="cusso.prg?act=1&vc=<?php echo trim($prod_row->ssovendor) ?>"><?php echo trim($prod_row->ssovendor) ?></a>
250  </td>
251  <td class='usul' nowrap >
252  <?php echo trim($prod_row->ssotype) ?>
253  </td>
254  <td class='usul' nowrap >
255  <?php echo trim($prod_row->ssodesc) ?>
256  </td>
257  <td class='usul' nowrap>
258  <?php echo trim($prod_row->contact) ?>
259  </td>
260  <td class='usul' nowrap>
261  <?php echo trim($prod_row->phone) ?>
262  </td>
263  <td class='usul' nowrap>
264  <?php echo trim($prod_row->email) ?>
265  </td>
266  </tr>
267  <?php
268  $RGB = ($RGB == "odd" ? "even" : "odd");
269  endwhile; ?>
270 
271  <tr>
272  <td>&nbsp;</td>
273  <td colspan="4">
274  <a href="cusso.prg?act=1" >Add CU SSO Vendor</a>
275  &nbsp;|&nbsp;
276  <a href="cusso.prg?act=4">Bill Pay Requirements List</a>
277  &nbsp;|&nbsp;
278  <a href="cusso.prg?act=5">Trusted Access Requirements List</a>
279  <!--&nbsp;|&nbsp;
280  <a href="<?php echo $infourl ?>/hcuadm/cuilist.prg" target="parent">Credit Union List</a>-->
281  </td>
282  </tr>
283  </table>
284  </td></tr></table>
285 <?php
286  break;
287  case "3":
288  cu_header("Save SSO Vendor");
289  // Setup a function to go back to the CU Edit form, if anything went wrong
290  function save_fail($msg){
291  global $ssovendor;
292  printf("<script language=\"javascript\">\n");
293  printf("document.forms[0].elements[\"form_err\"].value = '%s';\n", $msg);
294  printf("document.forms[0].action=\"cusso.prg?act=1&vc=%s\";\n", $ssovendor);
295  printf("document.forms[0].method=\"post\";\n");
296  printf("document.forms[0].submit();\n");
297  printf("</script>");
298  printf("\n</form>\n </body>\n </html>\n");
299  exit();
300  }
301 
302  ?>
303 
304  <form action="cusso.prg?act=1" method="post">
305  <?php
306  $errors_found = "No";
307  $err_msg = "";
308 
309 
310  /* VALIDATE THE INFORMATION - whether it's been saved before or NOT
311  After validation fails it will send the information back to the edit form
312  So it looks like it did before, the fail information will be at the bottom of the
313  screen.
314 
315  */
316  $err_msg="";
317 
318  // Now we need to load all the fields from the CU form, and post them back
319  // So the user does not have to press the back button.
320  // Load all the Fields from the previous form into hidden fields on this form
321  ?>
322  <!-- LOAD ALL HIDDEN FIELDS -->
323 
324  <!-- Description -->
325  <input type="hidden" name="ssovendor" value="<?php echo set_string($ssovendor) ?>">
326  <input type="hidden" name="ssodesc" value="<?php echo set_string($ssodesc) ?>">
327  <input type="hidden" name="ssotype" value="<?php echo set_string($ssotype) ?>">
328  <input type="hidden" name="contact" value="<?php echo set_string($contact) ?>">
329  <input type="hidden" name="email" value="<?php echo set_string($email) ?>">
330  <input type="hidden" name="phone" value="<?php echo set_string($phone) ?>">
331  <input type="hidden" name="comments" value="<?php echo set_string($setup) ?>">
332 
333  <!-- Create a hidden field for the form error -->
334  <input type="hidden" name="form_err" value="">
335 
336  <?php if (strlen($err_msg) > 0): ?>
337  <?php
338  //If an error was found post the information back to the CU edit form here
339  $form_err = sprintf("<font size=\"+1\">ERROR! Problems with the SSO Vendor information found: <BR></font>");
340  $form_err .= sprintf("The following errors will need to be corrected before you will be allowed to save the form.");
341  $form_err .= sprintf("<P> <font color=red>%s</font>", $err_msg);
342  save_fail($form_err);
343  ?>
344  <?php else: ?>
345 
346  <?php
347  // Everything was validated, we now need to save the information, either insert for new or update for edited.
348 
349  $save_sql = "SELECT ssovendor FROM cussovendors WHERE ssovendor = '$ssovendor'";
350  // Execute the query and find out how many rows are in the query
351  $db_result = db_query($save_sql, $link);
352 
353  $num_rows = db_num_rows($db_result);
354  if ($num_rows > 0 ) {
355  // UPDATE the information into the table
356  $qry_stmt = sprintf("UPDATE cussovendors ");
357  $qry_stmt .= sprintf("SET ssodesc ='%s', ",prep_save($ssodesc));
358  $qry_stmt .= sprintf("ssotype ='%s', ",prep_save($ssotype));
359  $qry_stmt .= sprintf("contact ='%s', ",prep_save($contact));
360  $qry_stmt .= sprintf("email ='%s', ",prep_save($email));
361  $qry_stmt .= sprintf("phone ='%s', ",prep_save($phone));
362  $qry_stmt .= sprintf("setup = '%s' ", prep_save($setup));
363  $qry_stmt .= sprintf("WHERE ssovendor = '%s'; ",$ssovendor);
364  } else {
365  $qry_stmt = sprintf("INSERT INTO cussovendors ");
366  $qry_stmt .= sprintf("(ssovendor, ssodesc, ssotype,");
367  $qry_stmt .= sprintf(" contact, email, phone,");
368  $qry_stmt .= sprintf(" setup) ");
369  $qry_stmt .= sprintf(" VALUES (");
370  $qry_stmt .= sprintf("'%s', '%s', '%s', '%s', '%s', '%s', '%s'); ",
371  strtoupper(prep_save($ssovendor)),
372  prep_save($ssodesc),
373  prep_save($ssotype),
374  prep_save($contact),
375  prep_save($email),
376  prep_save($phone),
377  prep_save($setup));
378  }
379  // Now pass the query to the Database
380 
381  if (!($db_result=db_query($qry_stmt, $link))) {
382  // A problem was encoutered with saving the data - report the message
383  $form_err = "<br>";
384  $form_err .= "<font face=\"Arial\" size=\"2\">Unable to Save Home CU SSO Vendor!<br></font><br>";
385  save_fail($form_err);
386  } else {
387  printError(sprintf("SSO Vendor Saved Successfully.<br>
388  <a href=\"cusso.prg?act=2\" target=\"CONTENT\">CU SSO Vendor List</a>"));
389 
390  // Only need to do this if at least one remote server was selected
391  if (Remote_Update_Selected()) {
392  // ** NOW CHECK FOR SAVING TO A REMOTE SERVER
393  // ** Add Each field that will be updated
394  Remote_Field_Add("cussovnd", "ssocode", $ssovendor);
395  Remote_Field_Add("cussovnd", "ssodesc", $ssodesc);
396  Remote_Field_Add("cussovnd", "ssotype", $ssotype);
397  Remote_Field_Add("cussovnd", "ssocnt", $contact);
398  Remote_Field_Add("cussovnd", "ssophn", $phone);
399  Remote_Field_Add("cussovnd", "ssoem", $email);
400  Remote_Field_Add("cussovnd", "ssosetup", $setup);
401 
402 
403  // ** Need to create the url I am going to send to the remote server
404  $Remote_Results = Remote_Update_Send("U", "cussovnd");
405  }
406  }
407  header ("Location: " . $_SERVER['PHP_SELF'] . "?msg=" . urlencode($Remote_Results));
408 
409 
410  /*
411  print <<< js
412  <script language="javascript">
413  document.location = "cusso.prg";
414  </script>
415 js;
416 */
417  ?>
418  <?php endif; ?>
419 
420  <?php
421  break;
422  case "4":
423 # display corporate requirements list for monitor pop-up help
424  cu_header(" CU Bill Pay Vendors");
425  ?>
426  <form>
427 
428  <?php
429  // Connect to the data and retrieve the current list of Image vendors
430  $query = "SELECT ssovendor, ssodesc, setup
431  FROM cussovendors where ssotype = 'B'
432  ORDER BY ssovendor";
433  $prod_result = db_query($query, $link);
434 
435  ?>
436 
437  <!-- Print out the top of the table -->
438 
439  <table border="0" cellpadding="3" cellspacing="0" align="center" width="80%" class="dmsbg"><tr><td>
440  <table border="0" cellpadding="1" cellspacing="0" align="center" bgcolor=white width="98%">
441  <tr>
442  <td colspan="3" class="bar" align="center">
443  CU BILL PAY VENDORS REQUIREMENTS
444  </td>
445  </tr>
446  <tr>
447  <td class="hdr" align="left" width="17%">
448  CU Bill Pay Vendor
449  </td>
450  <td class="hdr" align="left" width="35%">
451  Name
452  </td>
453  <td class="hdr" align="left" width="*">
454  Requirements
455  </td>
456  </tr>
457  <?php
458  $RGB = "odd";
459  $row = 0;
460  while ($prod_row = db_fetch_object($prod_result, $row)):
461  $row++;
462  ?>
463  <tr class="<?php echo $RGB; ?>">
464  <td class='usul' nowrap>
465  <a href="cusso.prg?act=1&vc=<?php echo trim($prod_row->ssovendor) ?>"><?php echo trim($prod_row->ssovendor) ?></a>
466  </td>
467  <td class='usul'>
468  <?php echo trim($prod_row->ssodesc) ?>
469  </td>
470  <td class='usul' nowrap>
471  <?php echo trim($prod_row->setup) ?>
472  </td>
473  </tr>
474  <?php
475  $RGB = ($RGB == "odd" ? "even" : "odd");
476  endwhile; ?>
477  <tr>
478  <td>&nbsp;</td>
479  <td colspan="2">
480  <a href="cusso.prg?act=2"> CU SSO Vendors List</a>
481  </td>
482  </tr>
483 
484  </table>
485  </td></tr></table>
486  <?php
487 
488  break;
489  case "5":
490 # display corporate requirements list for monitor pop-up help
491  cu_header(" CU Trusted Access Vendors");
492  ?>
493  <form>
494 
495  <?php
496  // Connect to the data and retrieve the current list of Image vendors
497  $query = "SELECT ssovendor, ssodesc, ssotype, setup FROM cussovendors where ssotype <> 'B'
498  ORDER BY ssovendor";
499  $prod_result = db_query($query, $link);
500 
501  ?>
502 
503  <!-- Print out the top of the table -->
504 
505  <table border="0" cellpadding="3" cellspacing="0" align="center" width="80%" class="dmsbg"><tr><td>
506  <table border="0" cellpadding="1" cellspacing="0" align="center" bgcolor=white width="98%">
507  <tr>
508  <td colspan="4" class="bar" align="center">
509  CU TRUSTED ACCESS VENDORS REQUIREMENTS
510  </td>
511  </tr>
512  <tr>
513  <td class="hdr" align="left" width="17%">
514  CU Trusted Access Vendor
515  </td>
516  <td class="hdr" align="left" width="5%">
517  Type
518  </td>
519  <td class="hdr" align="left" width="35%">
520  Name
521  </td>
522  <td class="hdr" align="left" width="*">
523  Requirements
524  </td>
525  </tr>
526  <?php
527  $RGB = "odd";
528  $row = 0;
529  while ($prod_row = db_fetch_object($prod_result, $row)):
530  $row++;
531  ?>
532  <tr class="<?php echo $RGB; ?>">
533  <td class='usul' nowrap>
534  <a href="cusso.prg?act=1&vc=<?php echo trim($prod_row->ssovendor) ?>"><?php echo trim($prod_row->ssovendor) ?></a>
535  </td>
536  <td class='usul'>
537  <?php echo trim($prod_row->ssotype) ?>
538  </td>
539  <td class='usul'>
540  <?php echo trim($prod_row->ssodesc) ?>
541  </td>
542  <td class='usul' nowrap>
543  <?php echo trim($prod_row->setup) ?>
544  </td>
545  </tr>
546  <?php
547  $RGB = ($RGB == "odd" ? "even" : "odd");
548  endwhile; ?>
549  <tr>
550  <td>&nbsp;</td>
551  <td colspan="2">
552  <a href="cusso.prg?act=2"> CU SSO Vendors List</a>
553  </td>
554  </tr>
555 
556  </table>
557  </td></tr></table>
558  <?php
559 
560  break;
561  case "6":
562 # display corporate requirements card for monitor pop-up help
563  cu_header(" CU Trusted Access Vendors");
564  ?>
565  <form>
566 
567  <?php
568  // Connect to the data and retrieve the requested vendor
569  $query = "SELECT ssovendor, ssodesc, contact, phone, setup,comments,
570  ssotype FROM cussovendors where ssovendor = '$vc'";
571  $prod_result = db_query($query, $link);
572  $prod_row = db_fetch_object($prod_result, 0);
573 
574 if ($prod_row->ssotype == 'B' ){ $stype='4';}
575  else { $stype='5';}
576 
577  ?>
578 
579  <!-- Print out the top of the table -->
580 
581  <table border="0" cellpadding="3" cellspacing="0" align="center" width="80%" class="dmsbg"><tr><td>
582  <table border="0" cellpadding="1" cellspacing="0" align="center" bgcolor='white' width='100%'>
583  <tr>
584  <td colspan="4" class="bar" align="center">
585  CU TRUSTED ACCESS VENDOR <?php echo $vc; ?>
586  </td>
587  </tr>
588  <tr class="dtll">
589  <td class='usul' nowrap>
590  <a href="cusso.prg?act=1&vc=<?php echo trim($prod_row->ssovendor) ?>"><?php echo trim($prod_row->ssovendor) ?></a>
591  </td>
592  <td class='usul'>
593  <?php echo trim($prod_row->ssodesc) ?>
594  </td>
595  <td class='usul'>
596  <?php echo trim($prod_row->contact) ?>
597  </td>
598  <td class='usul'>
599  <?php echo trim($prod_row->phone) ?>
600  </td>
601  </tr>
602  <tr>
603  <td colspan='4' class='usul'>
604  <?php echo trim($prod_row->comments) ?>
605  </td>
606  </tr>
607  <tr>
608  <td colspan='4' class='usul' align='center'>
609  <hr width='80%'>
610  </td>
611  </tr>
612  <tr>
613  <td colspan='4' class='usul'>
614  <?php echo trim($prod_row->setup) ?>
615  </td>
616  </tr>
617  <tr>
618  <td colspan="4" class='dtlr'>
619  <a href="cusso.prg?act=<?php echo $stype; ?>">Show All Vendors</a>
620  </td>
621  </tr>
622  </table>
623  </td></tr></table>
624  <?php
625 
626  break;
627  default:
628  cu_header("Error Displaying Form");
629  print ("<form>");
630  printError("Requested form not found!<br>Cancelling action.");
631  endswitch;
632  ?>
633  </form>
634  </body>
635 </html>
636