3 $monLibrary= dirname(__FILE__) .
"/../library";
4 $monIncludes= dirname(__FILE__) .
"/../includes";
5 require_once(
"$monLibrary/cu_top.i");
6 require_once(
"$monLibrary/ck_hticket.i");
7 require_once(
"$monIncludes/cu_remote_top.prg");
9 if (!CheckPerm($link, $Hu, basename($_SERVER[
'SCRIPT_NAME']), $_SERVER[
'REMOTE_ADDR'])) {
12 header(
"Location: /hcuadm/hcu_noperm.prg");
16 $dms_ok=array(
'act'=>
'digits',
'active_date'=>
'string',
'expires_on'=>
'string',
17 'message'=>
'string',
'msg_id'=>
'string',
'subject'=>
'string',
'livebatch'=>
'string',
'o'=>
'digits',
'd'=>
'digits',
'msg'=>
'string',
'Remote_Update'=>
'array');
21 $self = $_SERVER[
'SCRIPT_NAME'];
23 if (!isset($act)) $act =
"2";
33 if (!($active_date=mdydate($active_date))) {
34 $error_msg .=
"<li>The active date does not appear to be valid.<br></li>";
36 $bdate = strtotime(mdydate($active_date));
38 if (strlen(trim($expires_on)) > 0) {
39 if (!($expires_on=mdydate($expires_on))) {
40 $error_msg .=
"<li>The expires on date does not appear to be valid.<br></li>";
42 $edate = strtotime(mdydate($expires_on));
45 if ($bdate && $edate && $bdate >= $edate) {
46 $error_msg .=
"<li>The expires on date should be after the start date.<br></li>";
48 if (strlen(trim($message)) == 0) {
49 $error_msg .=
"<li>Why are you creating an admin message with no message, please add a message.<br></li>";
50 }
else if (strlen(trim($message)) > 1000) {
51 $error_msg .=
"<li>The message entered is longer than 1000. You entered " . strlen($message) .
" characters.<br></li>";
54 if ($error_msg ==
'') {
57 $save_sql =
"SELECT active_date FROM cuadmin_message WHERE id = '$msg_id'";
59 $db_result = db_query($save_sql, $link);
61 $num_rows = db_num_rows($db_result);
64 if ($expires_on ==
'')
65 $save_expires_on =
"NULL";
67 $save_expires_on =
"'" . prep_save($expires_on, 10) .
"'";
70 $qry_stmt =
"UPDATE cuadmin_message 71 SET active_date = '" . prep_save($active_date, 10) .
"', 72 expires_on = $save_expires_on, 73 message = '" . prep_save($message) .
"', 74 subject = '" . prep_save($subject, 50) .
"', 75 livebatch = '" . prep_save($livebatch, 1) .
"' 76 WHERE id = '" . intval($msg_id) .
"' ";
78 $idsql =
"SELECT nextval('cuadmin_message_id_seq');";
79 $idrs = db_query($idsql, $link);
80 list($save_id) = db_fetch_array($idrs);
81 db_free_result($idrs);
83 $qry_stmt =
"INSERT INTO cuadmin_message 84 (id, active_date, expires_on, message, subject, livebatch) 87 '" . prep_save($active_date, 10) .
"', $save_expires_on, 88 '" . prep_save($message) .
"', 89 '" . prep_save($subject, 50) .
"', 90 '" . prep_save($livebatch, 1) .
"') ";
94 if (!($db_result=db_query($qry_stmt, $link))) {
95 $error_msg =
"A problem occurred while saving your information, you may want to try later .";
100 if (Remote_Update_Selected()) {
101 if ($num_rows == 0) {
102 $remote_msg_id = intval($save_id);
104 $remote_msg_id = intval($msg_id);
109 Remote_Field_Add(
"cuadmmsg",
"msg_id", $remote_msg_id);
110 Remote_Field_Add(
"cuadmmsg",
"active_date", $active_date);
111 Remote_Field_Add(
"cuadmmsg",
"expires_on", $expires_on);
112 Remote_Field_Add(
"cuadmmsg",
"message", $message);
113 Remote_Field_Add(
"cuadmmsg",
"subject", $subject);
114 Remote_Field_Add(
"cuadmmsg",
"livebatch", $livebatch);
117 $Remote_Results = Remote_Update_Send(
"U",
"cuadmmsg");
122 header (
"Location: $self?msg=" . urlencode(
"The information was saved!<br>$Remote_Results"));
127 $error_msg =
"The following problems were found with the information given.<br>Please correct this and try again.<br><br>$error_msg";
131 } elseif ($act ==
"5") {
132 $sql =
"DELETE FROM cuadmin_message 133 WHERE id = '" . intval($msg_id) .
"' ";
135 if (!($db_result=db_query($sql, $link))) {
136 header (
"Location: $self?msg=" . urlencode(
"A problem occurred while deleting the message, you may want to try later."));
140 if (Remote_Update_Selected()) {
143 Remote_Field_Add(
"cuadmmsg",
"msg_id", intval($msg_id));
146 $Remote_Results = Remote_Update_Send(
"D",
"cuadmmsg");
150 header (
"Location: $self?msg=" . urlencode(
"The message was deleted!"));
159 cu_header(
"Credit Union Admin Messages");
161 <form action=
"<?php echo $self; ?>?act=3" method=
"post">
164 $query =
"select id, to_char(active_date, 'MM/DD/YYYY') as a_date, 165 to_char(expires_on, 'MM/DD/YYYY') as e_on, message, 168 where id = '$msg_id'";
170 $result = db_query($query, $link);
172 $msg_row = db_fetch_object($result);
173 $num_rows = db_num_rows($result);
178 if (isset($form_err) && strlen($form_err) > 0)
179 printf(
"\n<font color=\"red\">Errors found before saving the information. Please review errors at bottom of screen.\n<p></font>");
182 <table width=
"80%" cellpadding=
"2" cellspacing=
"0" border=
"0" class=
"dmsbg"><tr><td>
183 <table width=
"100%" cellpadding=
"1" cellspacing=
"0" border=
"0" bgcolor=white>
185 <td colspan=
"2" class=
"bar" align=
"center">
186 <?php
if($num_rows > 0): ?>
188 <input type=
"hidden" name=
"msg_id" value=
"<?php echo $msg_row->id; ?>">
194 <?php
if ($error_msg !=
''): ?>
196 <td colspan=
"2" align=
"center" class=
"err">
197 <?php echo $error_msg; ?>
202 <td nowrap align=
"right" class=
"hdr">
205 <td nowrap
class=
"dtl">
207 if ( isset($active_date))
208 $cu_info = set_string($active_date);
209 elseif ($num_rows > 0)
210 $cu_info = htmlspecialchars(trim($msg_row->a_date));
212 $cu_info = date("m/d/Y");
214 <input type="text" name="active_date" size="10" maxlength="10" value="<?php echo $cu_info ?>">
218 <td nowrap align="right" class="hdr">
221 <td nowrap class="dtl">
224 if ( isset($expires_on))
225 $cu_info = set_string($expires_on);
226 elseif ($num_rows > 0)
227 $cu_info = htmlspecialchars(trim($msg_row->e_on));
229 <input type="text" name="expires_on" size="10" maxlength="10" value="<?php echo $cu_info ?>">
230 <font size=1 color="red">Note: Leave blank for a continuous message</font>
234 <td nowrap align="right" class="hdr" valign="top">
237 <td nowrap class="dtl">
240 if ( isset($message))
241 $cu_info = set_string($message);
242 elseif ($num_rows > 0)
243 $cu_info = htmlspecialchars(trim($msg_row->message));
245 <textarea name="message" rows="10" cols="40"><?php echo $cu_info; ?></textarea>
249 <td nowrap align="right" class="hdr">
252 <td nowrap class="dtl">
255 if ( isset($subject))
256 $cu_info = set_string($subject);
257 elseif ($num_rows > 0)
258 $cu_info = htmlspecialchars(trim($msg_row->subject));
260 <input type="text" name="subject" size="40" maxlength="50" value="<?php echo $cu_info ?>">
264 <td nowrap align="right" class="hdr">
265 Show on which servers?
267 <td nowrap class="dtl">
270 if ( isset($livebatch))
271 $cu_info = set_string($livebatch);
272 elseif ($num_rows > 0)
273 $cu_info = htmlspecialchars(trim($msg_row->livebatch));
275 <select name="livebatch" size=1>
276 <option value="A" <?php echo ($cu_info == "A" ? "SELECTED" : ""); ?>>All Servers</option>
277 <option value="B" <?php echo ($cu_info == "B" ? "SELECTED" : ""); ?>>Batch Only</option>
278 <option value="L" <?php echo ($cu_info == "L" ? "SELECTED" : ""); ?>>Live Only</option>
283 <td class='dtl'> </td>
284 <td nowrap class='dtl'>
285 <?php remote_update_list(); ?>
289 <td class='dtl'> </td>
290 <td nowrap class='dtl' colspan="1">
291 <input type="submit" name="Save" Value="Save">
292 <input type="button" name="Cancel" Value="Cancel" onClick="document.location='<?php echo $self; ?>'">
298 if (isset($form_err)) {
302 echo
"</td></tr></table>";
305 cu_header(
"CU Message List");
314 $order_by =
"expires_on";
319 $order_by =
"substr(message, 1, 50)";
324 $order_by =
"subject";
329 $order_by =
"livebatch";
335 $order_by =
"active_date";
337 $order_by .=
" desc";
340 $order_by =
"active_date";
347 $order_by .=
" desc";
350 $query =
"SELECT id, to_char(active_date, 'MM/DD/YYYY') as a_date, 351 to_char(expires_on, 'MM/DD/YYYY') as e_on, message, 356 $prod_result = db_query($query, $link);
360 <!-- Print out the top of the table -->
362 <table border=
"0" cellpadding=
"2" callspacing=
"0" align=
"center" width=
"80%" class=
"dmsbg"><tr><td>
363 <table border=
"0" cellpadding=2 cellspacing=
"0" align=
"center" width=
"100%">
365 <td colspan=
"6" class=
"bar" align=
"center">
366 CU Admin Messages List
369 <?php
if (isset($msg)): ?>
371 <td colspan=
"6" class=
"err" align=
"center">
372 <font color=
"#FF8080"><?php echo $msg; ?></font>
377 <td
class=
"hdr" align=
"left" valign=
"top" nowrap>
378 <a href=
"<?php echo $self; ?>?o=1<?php echo $o_desc[1]; ?>">Active Date</a>
380 <td
class=
"hdr" align=
"left" valign=
"top" nowrap>
381 <a href=
"<?php echo $self; ?>?o=2<?php echo $o_desc[2]; ?>">Exipires On</a>
383 <td
class=
"hdr" align=
"left" valign=
"top">
384 <a href=
"<?php echo $self; ?>?o=3<?php echo $o_desc[3]; ?>">Message</a>
386 <td
class=
"hdr" align=
"left" valign=
"top">
387 <a href=
"<?php echo $self; ?>?o=4<?php echo $o_desc[4]; ?>">Subject</a>
389 <td
class=
"hdr" align=
"left" valign=
"top">
390 <a href=
"<?php echo $self; ?>?o=5<?php echo $o_desc[5]; ?>">Live/Batch?</a>
392 <td
class=
"hdr" align=
"center" valign=
"top">
399 while ($prod_row = db_fetch_object($prod_result, $row)):
402 <tr
class=
"<?php echo $RGB; ?>_small">
403 <td nowrap valign=
"top">
404 <?php echo trim($prod_row->a_date) ?>
406 <td nowrap valign=
"top">
407 <?php echo trim($prod_row->e_on) ?>
411 echo trim(htmlspecialchars((strlen(trim($prod_row->message)) > 100 ? substr(trim($prod_row->message), 0, 100) .
"..." : trim($prod_row->message))));
415 <?php echo trim($prod_row->subject) ?>
417 <td nowrap valign=
"top">
419 switch ($prod_row->livebatch) {
432 <td nowrap valign=
"top">
433 <a href=
"<?php echo $self; ?>?act=1&msg_id=<?php echo trim($prod_row->id) ?>">Edit</a>
435 <a href=
"<?php echo $self; ?>?act=4&msg_id=<?php echo trim($prod_row->id) ?>">Delete</a>
439 $RGB = ($RGB ==
"odd" ?
"even" :
"odd");
443 <td colspan=
"6" class=
"dtl">
444 <a href=
"<?php echo $self; ?>?act=1" target=
"parent">Add Admin Message</a>
446 <a href=
"<?php echo $infourl ?>/hcuadm/cuilist.prg" target=
"parent">Credit Union List</a>
454 cu_header (
"Delete Admin Message");
460 where id = '$msg_id'";
461 $result = db_query($query, $link);
463 $msg_row = db_fetch_array($result);
464 $num_rows = db_num_rows($result);
466 echo
"<center><table width=\"40%\" cellpadding=\"1\" cellspacing=\"1\" border=\"0\" class=\"dmsbg\"><tr><td>";
467 if ($num_rows > 0): ?>
468 <form action=
"<?php echo $self; ?>?act=5" method=
"post">
469 <input type=
"hidden" name=
"act" value=
"5">
470 <table width=
"100%" cellpadding=
"1" cellspacing=
"1" border=
"0">
472 <td
class=
"bar" align=
"center">
474 <input type=
"hidden" name=
"msg_id" value=
"<?php echo $msg_row['id']; ?>">
478 <td align=
"center" class=
"dtl">
479 Hi, you have selected to
delete an admin message.<br>
480 The message contains the subject <b><?php echo htmlspecialchars(trim($msg_row[
'subject'])); ?></b>.<br><br>
481 Please verify
this before deleting, after deleting said message, <br>you will need to reenter it
if you didn
't 486 <td nowrap class='dtl
'> 487 <table width="250" align='center
'><tr><td> 488 <?php remote_update_list(); ?> 493 <td align="right" class="hdr" nowrap> 494 <input type='submit
' name='btnSubmit
' value="Please delete this message"> 496 <input type="button" name="btnCancel" value="I don't want to
do this" onclick="document.location=
'<?php echo $self; ?>'"> 501 <table width="100%
" cellpadding="1
" cellspacing="1
" border="0
"> 503 <td class="bar
" align="center
"> 504 DELETE ADMIN MESSAGE - Problem Encountered 508 <td class="dtl
" align="center
"> 509 Problem deleting your admin message. <br> 510 It appears the message has already been deleted or never existed.<br> 511 Please return to the <a href="<?php echo $self; ?>
">menu</a> and try again. 517 echo "</td></tr></table>
"; 520 cu_header("Error Displaying Form
"); 522 printError("Requested form not found!<br>Cancelling action.
");