3 $monLibrary = dirname(__FILE__) .
"/../library";
4 $sharedLibrary = dirname(__FILE__) .
"/../../shared/library";
5 require_once(
"$monLibrary/cu_top.i");
6 require_once(
"$monLibrary/ck_hticket.i");
7 require_once(
"$sharedLibrary/cu_flagconst.i");
9 $dms_ok=array(
'report'=>
'digits',
'ob'=>
'digits',
'csv'=>
'string',
10 'pos'=>
'digits',
'd'=>
'digits',
'jval'=>
'string',
'pm'=>
'digits');
13 $report = (isset($report) ? $report : 2);
18 $sql_query =
"select trim(upper(user_name)) as cu, 19 trim(www_server) as www_server, system_options 21 where system_options & 3::bigint > 0 22 and system_options & 64::bigint = 0 23 and date_live is not null 24 and user_name not in ('miki', 'demo', 'dmstest') ";
25 if (!isset($ob) || (intval($ob) < 1 || intval($ob) > 3)) {
26 $sql_order =
" ORDER BY 1";
29 $sql_order =
" ORDER BY " . intval($ob);
32 $title =
"HCU Contacts Cuinfo List";
36 $sql_query =
"select trim(m.cu) as cu, 37 case when n.notify is null then trim(m.master) 38 else trim(n.notify) end as email 39 from (select a.cu, u.email as master from cuadmin a 40 join cuadminusers u on a.cu = u.cu where u.realname = 'CU Master') as m 41 left join (select cu, email as notify from cuadmnotify 42 where role = 'hcunotice') as n on m.cu = n.cu ";
43 if (!isset($ob) || (intval($ob) < 1 || intval($ob) > 2)) {
44 $sql_order =
" ORDER BY 1";
47 $sql_order =
" ORDER BY " . intval($ob);
49 $title =
"HCU Contact Email List";
53 $sql_query =
"select m.cu as \"CU\", n.notify as \"HCU Notice\", 54 m.master as \"CU Master\" 55 from (select a.cu, u.email as master from cuadmin a 56 join cuadminusers u on a.cu=u.cu where u.realname = 'CU Master') 57 as m left join (select cu, email as notify from cuadmnotify 58 where role = 'hcunotice') as n on m.cu = n.cu ";
59 if (!isset($ob) || (intval($ob) < 1 || intval($ob) > 3)) {
60 $sql_order =
" ORDER BY 1";
63 $sql_order =
" ORDER BY " . intval($ob);
65 $title =
"HCU Notice and Master Email List";
69 $sql_query =
"select trim(cu) as cu, 71 from cuadmnotify where role = 'hcunotice' ";
72 if (!isset($ob) || (intval($ob) < 1 || intval($ob) > 2)) {
73 $sql_order =
" ORDER BY 1";
76 $sql_order =
" ORDER BY " . intval($ob);
78 $title =
"HCU Notice Email List";
82 $sql_query =
"select trim(cu) as cu, 84 from cuadmnotify where role = 'esload' ";
85 if (!isset($ob) || (intval($ob) < 1 || intval($ob) > 2)) {
86 $sql_order =
" ORDER BY 1";
89 $sql_order =
" ORDER BY " . intval($ob);
91 $title =
"HCU ESLoad Email List";
95 $sql_query = stripslashes($sql_query);
96 $sql_order = stripslashes($sql_order);
97 $title = stripslashes($title);
99 $d = isset($d) ? $d :
null;
101 $sql_order .=
" desc";
104 $sql_order = isset($sql_order) ? trim($sql_order) :
"";
105 if (!$result = db_query($sql_query . $sql_order, $dbh)) {
106 pg_die(pg_errormessage($dbh), $sql_query . $sqlorder, __FILE__, __LINE__);
108 $num_rows = db_num_rows($result);
109 $num_fields = @pg_numfields($result);
111 if (isset($csv) && $csv ==
'raw') {
119 # First record has the field names 122 for ($i_field = 0; $i_field < $num_fields; $i_field++) {
123 $field_name = pg_fieldname($result, $i_field);
124 $ostring .=
"${osep}${field_name}";
129 # Second record has the field types 132 for ($i_field = 0; $i_field < $num_fields; $i_field++) {
133 $field_type = pg_fieldtype($result, $i_field);
134 $ostring .=
"${osep}${field_type}";
142 for ($i_row = 0; $i_row < $num_rows; $i_row++) {
144 $row = pg_fetch_row($result, $i_row);
145 for ($i_field = 0; $i_field < $num_fields; $i_field++) {
146 $ostring .=
"${osep}${row[$i_field]}";
155 header(
"Content-length: " . strlen( $ostring ) );
156 header(
"Content-type: application/octetstream");
157 header(
"Content-disposition: inline; filename=\"${Cu}report${report}.csv\"");
163 $query = display_table($result);
165 function display_table ($dt_result) {
166 global $pos, $dbh, $sql_query, $sql_order, $report, $self, $title, $ob, $d, $jval, $pm;
174 $strShowingRecords =
"Showing records ";
176 $strPrevious =
"Previous";
181 $strEmptySet =
"No records found";
184 # if jval is set, search through the ob field until we find a match 185 # set $pos so record is on the page 195 $num_rows = @pg_numrows($dt_result);
197 $num_fields = @pg_numfields($dt_result);
199 if (isset($jval) && trim($jval) >
'') {
201 $jval = trim(stripslashes(preg_replace(
"/[\"\`;\\\]/",
"",$jval)));
202 if ($pm) $clen = strlen($jval);
203 for ( $rowptr = 0; $rowptr < $num_rows; $rowptr++ ) {
204 $colval = pg_fetch_result($dt_result, $rowptr, $ob - 1);
205 $coloff = (strpos(strtolower($colval), strtolower($jval)) ===
false ? 0 : strpos(strtolower($colval), strtolower($jval)));
207 $colval = substr($colval, $coloff, $clen);
210 $colval = substr($colval, 0, $clen);
212 if (strtolower(trim($colval)) == strtolower($jval)) {
213 $pos = $cfgMaxRows * floor($rowptr / $cfgMaxRows);
221 $pos_next = $pos + $cfgMaxRows;
222 $pos_prev = $pos - $cfgMaxRows;
225 $iNumRows = $num_rows;
226 if ($num_rows < $pos_next) {
227 $pos_next = $num_rows;
230 if (!isset($strNavigation)) {
233 $strNavigation .=
"<table border=0 cellpadding=2 cellspacing=0><tr>\n";
234 $strNavigation .=
"<td align=left>";
235 if ($pos >= $cfgMaxRows) {
237 $strNavigation .=
"<a href=\"$self?report=$report&ob=$ob&d=$d&pos=0\"><< $strPos1 </a> | ";
239 $strNavigation .=
" <a href=\"$self?report=$report&ob=$ob&d=$d&pos=$pos_prev\">< $strPrevious </a> | ";
241 $strNavigation .=
" ";
243 $strNavigation .=
"</td>\n";
245 $strNavigation .=
"<td align=center>\n";
248 if (empty($cfgMaxPages)) {
252 $iCount = $pos - ($cfgMaxRows * $cfgMaxPages);
256 $iPageCnt = (int)($iCount / $cfgMaxRows);
257 $iPageStop = $pos + ($cfgMaxRows * ($cfgMaxPages + 1));
259 if (!isset($strPages)) {
262 for (; $iCount < $iNumRows && $iCount < $iPageStop; $iCount += $cfgMaxRows) {
265 if ($iCount != $pos) {
266 $strPages .=
"<a href=\"$self?report=$report&ob=$ob&d=$d&pos=$iCount\">$iPageCnt</a> | ";
268 if ($iNumRows > $cfgMaxRows) {
269 $strPages .=
"$iPageCnt | ";
273 $strNavigation .= preg_replace(
'/ \| $/i',
"", $strPages);
275 $strNavigation .=
"</td>\n";
277 $strNavigation .=
"<td align=right>";
278 if ($pos_next < $num_rows) {
279 $strNavigation .=
" | <a href=\"$self?report=$report&ob=$ob&d=$d&pos=$pos_next\"> $strNext ></a>";
282 $pos_end = $num_rows - $cfgMaxRows;
283 $strNavigation .=
" | <a href=\"$self?report=$report&ob=$ob&d=$d&pos=$pos_end\"> $strEnd >></a>";
285 $strNavigation .=
" ";
287 $strNavigation .=
"</td>\n";
288 $strNavigation .=
"</tr></table>\n";
290 header(
"Expires: Sat 20 May 1995 03:32:38 GMT");
291 header(
"Pragma: no-cache");
292 header(
"Cache-Control: no-cache, must-revalidate");
298 <script language=
'javascript'>
301 var strJval=document.jumpform.jval.value;
303 for (i=document.jumpform.pm.length-1; i > -1; i--) {
304 if (document.jumpform.pm[i].checked) {
305 strPm = document.jumpform.pm[i].value; i = -1;
308 document.location=
'$self?report=$report&ob=$ob&d=$d&pos=0&jval=' + strJval +
'&pm=' + strPm +
'$q';
314 echo
"<table border=$cfgBorder align=center width='100%' bgcolor=white cellpadding=2 cellspacing=0>";
315 echo
"<tr><td class='dtl' align='left'>";
316 echo
"<a href='cuilist.prg'>Credit Union List</a> 317 <A HREF='$self?csv=csv&report=$report&ob=$ob&d=$d'>Download CSV</a></td><td class='dtl' align='right'> ";
319 echo
"$strShowingRecords $pos - $pos_next ($num_rows $strTotal)";
321 echo
"</td></tr></table>";
324 if ($iNumRows > $cfgMaxRows) {
325 # show a 'Jump to this value' link for the sorted field only 326 print
"<form name='jumpform' onSubmit='jumpto();return false;'> 327 <table border=$cfgBorder align=center width='90%'> 328 <tr><td class='msg'><hr> 329 Click column heading to change sort order and jump value<br> </td></tr> 331 pg_fieldname($dt_result, $ob-1) .
": 332 <input type='text' name='jval' value='$jval' size='10'> 334 <input type='radio' name='pm' value='1'> Partial Match 336 <input type='radio' name='pm' value='2'> Wildcard 337 <input type='button' value='Go' onClick='jumpto();return false;'>";
338 if ($nomatch == 1 ) print
"<br><font color='red' align='center'>No Match Found</font>";
339 print
"</td></tr></table></form>";
341 echo
"<table border=$cfgBorder align=center width='100%' bgcolor=white cellpadding=2 cellspacing=0>";
342 echo
"<tr><td class='hdr' colspan='$num_fields' align='center'>$title</td></tr><tr>";
345 for ($i_field = 0; $i_field < $num_fields; $i_field++) {
346 $field_name = pg_fieldname($dt_result, $i_field);
347 if (@pg_numrows($dt_result) > 1) {
349 if (($i_field + 1) == intval($ob) && $d != 1) {
355 $sort_order = ($i_field + 1);
356 echo
"<th class='small' align='left'><A HREF=\"$self?report=$report&pos=$pos&ob={$sort_order}{$desc_ord}\">$field_name</a></th>\n";
358 echo
"<th class='small' align='left'>$field_name</th>";
362 if ((@pg_numrows($dt_result)) < 1) {
363 echo
"<tr class='odd'><td colspan='$num_fields'>$strEmptySet</td>";
366 if (!isset($cfgShowBlob)) {
370 for ($i_row = $pos; $i_row < $pos_next; $i_row++) {
371 $row = pg_fetch_row($dt_result, $i_row);
372 $i_row % 2 ? $rbg =
"odd_small" : $rbg =
"even_small";
373 echo
"<tr class=$rbg>";
374 for ($i_field = 0; $i_field < pg_numfields($dt_result); $i_field++) {
375 if (!isset($row[$i_field])) {
376 unset($row[$i_field]);
378 $field_type = pg_fieldtype($dt_result, $i_field);
379 $field_name = pg_fieldname($dt_result, $i_field);
380 if (preg_match(
'/int|numeric/i', $field_type)) {
382 echo
"<td align=right valign=top> $row[$i_field] </td>\n";
383 } elseif ($cfgShowBlob ==
false && preg_match(
'/blob/i', $field_type)) {
384 echo
"<td align=right valign=top> [BLOB] </td>\n";
385 } elseif (preg_match(
'/text|char/i', $field_type)) {
387 if (strlen($row[$i_field]) > $cfgMaxText && !empty($cfgMaxText)) {
388 $strLgText = nl2br(htmlspecialchars(substr($row[$i_field], 0, $cfgMaxText))) .
" <br><b>... $strMore ...</b>";
390 $strLgText = nl2br(htmlspecialchars($row[$i_field]));
392 echo
"<td valign=top> $strLgText</td>\n";
393 } elseif ($field_type ==
"bool") {
394 echo
"<td valign=top> ", bool_YesNo($row[$i_field]),
" </td>\n";
396 echo
"<td valign=top> ", nl2br(htmlspecialchars($row[$i_field])),
" </td>\n";
403 if (!isset($query)) {
407 echo
"</tr></table>\n";
415 function pg_die($error =
"", $query =
"", $err_file = __FILE__, $err_line = __LINE__) {
416 global $strError,$strMySQLSaid, $strBack, $sql_query, $link, $db, $table, $cfgDebug, $server;
418 echo
"<b><font face=\"arial,helvetican,sans-serif\" color=\"red\">$strError - $err_file -- Line: $err_line</font></b><p>";
420 $error = @pg_errormessage();
422 echo
"<font face=\"arial,helvetican,sans-serif\" color=\"red\">", $strMySQLSaid . $error;
426 if (!empty($query)) {
427 echo
"<br>Your query: <br><b>", nl2br(htmlentities($query)),
"</b>";
429 echo
"<br><a href=\"javascript:history.back()\">$strBack</a></font>";
432 echo
"<br>Link: $link<br>DB: $db<br>Table: $table<br>Server: $server";