Odyssey
cuproduct_report.prg
1 <?php
2 /* This report will allow the user to determine sales information such as which
3  * products a CU has, decider contact, and contract expiration.
4  *
5  * NOTES: If Single Line, then don't show decider (since could be multiple lines). If not
6  * showing decider, don't worry about blank emails.
7  *
8  * History:
9  * 05/02/13 mbl - created.
10  * 06/03/13 mbl - Added Option Filter to filter on cuinfo.system_options.
11  * 06/12/13 mbl - Added Vendor and Renewal columns.
12  * 06/17/14 mbl - Added SingleLine concept.
13  */
14 $monLibrary= dirname(__FILE__) . "/../library";
15 require_once("$monLibrary/cu_top.i");
16 require_once("$monLibrary/ck_hticket.i");
17 require_once("$monLibrary/cu_pass.i");
18 
19  if (!CheckPerm($link, $Hu, basename($_SERVER['SCRIPT_NAME']), $_SERVER['REMOTE_ADDR'])) {
20  // ** Permissions failed
21  // ** redirect to new page
22  header("Location: /hcuadm/hcu_noperm.prg");
23  exit;
24  }
25 
26  $dms_ok=array('act'=>'string', 'csv'=>'string');
27 
28  dms_import($dms_ok);
29 
30 
31  $self = $_SERVER['PHP_SELF'];
32 
33  /* ***** GLOBALS ****** */
34 
35  // don't show header if outputing csv
36  if ( $csv == "" )
37  cu_header("CU Products Report");
38 
39  $act = intval($_REQUEST['act']);
40  $showProduct = isset( $_REQUEST["show_product"] ) && intval($_REQUEST['show_product']) == 1 ? 1 : 0;
41  $singleLine = isset( $_REQUEST["single_line"] ) && intval($_REQUEST['single_line']) == 1 ? 1 : 0;
42  $showDecider = isset( $_REQUEST["show_decider"] ) && intval($_REQUEST['show_decider']) == 1 ? 1 : 0;
43  $skipBlankEmails = isset( $_REQUEST["skip_blank_emails"] ) && intval($_REQUEST['skip_blank_emails']) == 1 ? 1 : 0;
44  $showExpDate = isset( $_REQUEST["show_exp_date"] ) && intval($_REQUEST['show_exp_date']) == 1 ? 1 : 0;
45  $pDescending = isset( $_REQUEST["d"] ) && intval($_REQUEST['d']) == 1 ? 1 : 0;
46 
47  // if Single Line, then ignore Decider
48  if ( $singleLine ) $showDecider = 0;
49 
50  // if no decider, don't care about blank emails
51  if ( !$showDecider ) $skipBlankEmails = 0;
52 
53  // get a list of products for the product filter
54  $sql = "SELECT * FROM cuprodlist ORDER BY home_cu_desc";
55 
56  $product_rs = db_query($sql, $link);
57  $productList = array();
58  $row_cnt = 0;
59  while ($product_row = db_fetch_array($product_rs, $row_cnt++)) {
60  $code = trim( $product_row["home_cu_code"] );
61  $descr = trim( $product_row["home_cu_desc"] );
62  $include = isset( $_REQUEST["value$code"] ) ? intval( $_REQUEST["value$code"] ) : 0;
63  $productList[] = array( "code" => $code, "desc" => $descr, "include" => $include );
64  }
65 
66  usort($productList, "productSort");
67 
68  // set up a list of options for the option filter (only the ones we care about)
69  $systemOptions = array();
70  $systemOptions[] = array( "code" => "WEBONLY", "desc" => "Web Only", "mask" => $SYS_TYPE_WEBONLY );
71  $systemOptions[] = array( "code" => "BATCH", "desc" => "Batch", "mask" => $SYS_TYPE_BATCH );
72  $systemOptions[] = array( "code" => "LIVE", "desc" => "Live", "mask" => $SYS_TYPE_LIVE );
73  $systemOptions[] = array( "code" => "IVR", "desc" => "IVR", "mask" => $SYS_TYPE_IVR );
74  $systemOptions[] = array( "code" => "VOIP", "desc" => "VOIP", "mask" => $SYS_TYPE_VOIP );
75  $systemOptions[] = array( "code" => "ASP", "desc" => "ASP", "mask" => $SYS_TYPE_ASP );
76  $systemOptions[] = array( "code" => "UPGRADE", "desc" => "Upgrade/Conversion", "mask" => $SYS_TYPE_UPGRADE );
77  $optionList = array();
78  for ( $o = 0; $o < count( $systemOptions ); $o++ ) {
79  $code = $systemOptions[$o]["code"];
80  $desc = $systemOptions[$o]["desc"];
81  $mask = $systemOptions[$o]["mask"];
82  $includeOption = isset( $_REQUEST["option$code"] ) ? intval( $_REQUEST["option$code"] ) : 0;
83  $optionList[] = array( "code" => $code, "desc" => $desc, "include" => $includeOption, "mask" => $mask );
84  }
85 
86  // figure out the product selection logic setting
87  $prodLogic = isset( $_REQUEST["prod_logic"] ) ? intval( $_REQUEST["prod_logic"] ) : 0;
88 
89  $sql = "";
90  $act="1";
91  switch ($act) {
92  case "1": // This is ONLY a listing of NON-COMPLETED items
93  // have five sortable fields but start with offest = 1
94  $ob_desc = array(0, 0, 0, 0, 0, 0, 0, 0);
95 
96  // This is where the report is actually Running from -- RUN IT HERE
97 
98  // build a required option mask and a required not-option mask
99  $requiredOptions = 0;
100  $requiredNotOptions = 0;
101  for ( $i = 0; $i < count( $optionList ); $i++ ) {
102  if ( $optionList[$i]["include"] == 1 ) // Has
103  $requiredOptions |= $optionList[$i]["mask"];
104  else if ( $optionList[$i]["include"] == 2 ) // Does NOT Have
105  $requiredNotOptions |= $optionList[$i]["mask"];
106  }
107 
108  // Just get the CU info first
109 
110  // always get the cu name and exp date since getting that info anyway
111  $sql = "SELECT cuinfo.user_name, cuinfo.name, cuinfo.vendor, cuinfo.contract_expires, cuinfo.renewal_term, cuinfo.system_options, home_page_url, www_server, dec_31_assets, dec_31_mem";
112 
113  // note: row count will just be based on the number of credit unions and products
114  $rows_sql = "SELECT count(cuinfo.user_name) as row_count
115  FROM cuinfo ";
116 
117  // always show cu code, cu name, vendor, asset size, # member
118  $vis_col = 5;
119 
120  if ( $showProduct && !$singleLine ) {
121  $sql .= ", cuprodlist.home_cu_desc";
122  $vis_col += 1;
123  } else if ( $showProduct && $singleLine ) {
124  // we are not getting data with this query but we know how many columns will be added
125  $vis_col += count($productList);
126  }
127 
128  if ( $showDecider ) {
129  $vis_col += 4;
130  }
131 
132  if ( $showExpDate ) {
133  $vis_col += 2; // exp date and renewal term
134  }
135 
136  $sql .= " FROM cuinfo ";
137 
138  if ( $showProduct && !$singleLine ) {
139  $tempSql = "JOIN cuproducts on cuproducts.user_name = cuinfo.user_name
140  JOIN cuprodlist on cuprodlist.home_cu_code = cuproducts.home_cu_code ";
141  $sql .= $tempSql;
142  $rows_sql .= $tempSql;
143  }
144 
145  $tempSql = " WHERE (cuinfo.system_options & $SYS_TYPE_CLOSED) = 0 ";
146  $sql .= $tempSql;
147  $rows_sql .= $tempSql;
148 
149  // only get the CUs with required options
150  if ( $requiredOptions > 0 ) {
151  $tempSql = " AND (cuinfo.system_options & $requiredOptions) = $requiredOptions ";
152  $sql .= $tempSql;
153  $rows_sql .= $tempSql;
154  }
155 
156  // DON'T get the CUs with required not-options
157  if ( $requiredNotOptions > 0 ) {
158  $tempSql = " AND (cuinfo.system_options & $requiredNotOptions) = 0 ";
159  $sql .= $tempSql;
160  $rows_sql .= $tempSql;
161  }
162 
163  // Determine the Ordering of the records
164  $ob_fldid = (intval($_GET['ob']) < 1) ? 1 : intval($_GET['ob']);
165  $order_sql = " ORDER BY " . get_field(intval($ob_fldid));
166 
167  if ($pDescending == 1)
168  $order_sql .= " desc ";
169  else
170  $ob_desc[$_GET["ob"]] = 1;
171 
172  $sql .= $order_sql;
173 
174  $cu_rs = db_query($sql, $link);
175 
176  $rows_rs = db_query($rows_sql, $link);
177  list($num_rows) = db_fetch_array($rows_rs, 0);
178  db_free_result($rows_rs);
179 
180  #
181  if (($csv) && ($num_rows > 1)) {
182  unset($csv);
183 
184  #
185  # First record has the field names
186  #
187  $fieldNames = "\"CU Code\",\"CU Name\",\"Asset\",\"Mem\",\"Vendor\"";
188  if ( $showProduct && !$singleLine )
189  $fieldNames .= ",\"Product\"";
190  if ( $showDecider )
191  $fieldNames .= ",\"First\",\"Last\",\"E-mail\",\"Phone\"";
192  if ( $showExpDate )
193  $fieldNames .= ",\"Exp Date\",\"Renewal\"";
194  if ( $showProduct && $singleLine ) {
195  // if showing products on a single line, show them last because there are so many
196  // list all the possible products as fields
197  for ( $p = 0; $p < count( $productList ); $p++ ) {
198  $fieldNames .= ",\"{$productList[$p]["code"]}\"";
199  }
200  }
201 
202  $outputString = "$fieldNames\r\n";
203  #
204  # Now the data
205  #
206  if ( $singleLine ) {
207  // NOTE: if $singleLine is true then ignore the $showDecider flag
208  $row_cnt = 0;
209  $row_class = "odd";
210  while ($cu_row = db_fetch_array($cu_rs, $row_cnt++)) {
211  $userName = trim($cu_row["user_name"]);
212 
213  // get the products for the credit union
214  $cuProducts = GetCUProductList( $userName );
215 
216  $passedFilter = TestProductFilter2($cuProducts, $productList, $prodLogic);
217 
218  if ( !$passedFilter ) {
219  continue;
220  }
221 
222  $row_class = ($row_class == "odd" ? "even" : "odd");
223 
224  // these only print for the first occurance
225  $cuCode = $userName;
226  $cuName = $cu_row['name'];
227  $cuAssets = $cu_row['dec_31_assets'];
228  $cuMembers = $cu_row['dec_31_mem'];
229  $cuVendor = $cu_row['vendor'];
230  $cuExpires = $cu_row['contract_expires'];
231  $cuRenewal = $cu_row['renewal_term'];
232  $cuHomepage = trim($cu_row["home_page_url"]);
233 
234  $vend_show = (trim($cu_row["vendor"]) == '' ? "" : "&vc=". trim($cu_row["vendor"]));
235  $www_show = (trim($cu_row["www_server"]) == '' ? "" : "&wc=". trim($cu_row["www_server"]));
236 
237  $outputFields = "\"$cuCode\",\"$cuName\",\"$cuAssets\",\"$cuMembers\",\"$cuVendor\"";
238 
239  if ( $showExpDate )
240  $outputFields .= ",\"$cuExpires\",\"$cuRenewal\"";
241 
242  if ( $showProduct ) {
243  // give each product an "X" or "" based on the setting; do in order of $productList
244  for( $p = 0; $p < count( $productList ); $p++ ) {
245  $cuHasProduct = false;
246  for ( $c = 0; $c < count( $cuProducts ); $c++ ) {
247  if ( $cuProducts[$c] == $productList[$p]["code"] ) {
248  $cuHasProduct = true;
249  break;
250  }
251  }
252 
253  $outputFields .= sprintf( ",\"%s\"", ($cuHasProduct ? "X" : "") );
254  }
255  }
256 
257  $outputString .= "$outputFields\r\n";
258  }
259  } else {
260  $skippingCU = "";
261  $currCU = "";
262  $row_cnt = 0;
263  $deciderList = array();
264  $deciderOffset = 0;
265  while ($cu_row = db_fetch_array($cu_rs, $row_cnt++)) {
266  $userName = trim($cu_row["user_name"]);
267  if ( $userName == $skippingCU ) continue;
268 
269  if ( $userName != $currCU ) {
270  // first, see if need to finish with any deciders from the previous CU
271  if ( $showDecider ) {
272  while ( $deciderOffset < count( $deciderList ) ) {
273  // only print the decider columns since we ran out of the products or we wouldn't be here
274  $cuDecideFirst = trim($deciderList[$deciderOffset]['fname']);
275  $cuDecideLast = trim($deciderList[$deciderOffset]['lname']);
276  $cuDecideEmail = $deciderList[$deciderOffset]['email'];
277  $cuDecidePhone = $deciderList[$deciderOffset]['phone'];
278 
279  $outputFields = "\"\",\"\"";
280 
281  if ( $showProduct )
282  $outputFields .= ",\"\"";
283 
284  $outputFields .= ",\"$cuDecideFirst\",\"$cuDecideLast\",\"$cuDecideEmail\",\"$cuDecidePhone\"";
285 
286  if ( $showExpDate )
287  $outputFields .= ",\"\"";
288 
289  $outputString .= "$outputFields\r\n";
290 
291  $deciderOffset++;
292  }
293  }
294 
295  $passedFilter = TestProductFilter($userName, $productList, $prodLogic);
296 
297  if ( !$passedFilter ) {
298  $skippingCU = $userName;
299  continue;
300  }
301 
302  // get the list of deciders for this CU
303  if ( $showDecider ) {
304  $deciderSQL = "SELECT monitor_contact.fname, monitor_contact.lname, monitor_contact.email, monitor_contact.phone
305  FROM monitor_contact
306  WHERE user_name = '$userName'
307  AND monitor_contact.decider = 'Y' ";
308 
309  if ( $skipBlankEmails )
310  $deciderSQL .= " AND length( monitor_contact.email ) > 0 ";
311 
312  $deciderRS = db_query($deciderSQL, $link);
313 
314  // get the list of deciders all right now
315  $deciderList = array();
316  $deciderRowCnt = 0;
317  while ($deciderRow = db_fetch_array($deciderRS, $deciderRowCnt++)) {
318  $deciderList[] = $deciderRow;
319  }
320 
321  // reset offset so we know where we are
322  $deciderOffset = 0;
323  }
324  }
325 
326  if ( $showDecider &&
327  $deciderOffset < count( $deciderList ) ) {
328  $cuDecideFirst = trim($deciderList[$deciderOffset]['fname']);
329  $cuDecideLast = trim($deciderList[$deciderOffset]['lname']);
330  $cuDecideEmail = $deciderList[$deciderOffset]['email'];
331  $cuDecidePhone = $deciderList[$deciderOffset]['phone'];
332  } else {
333  $cuDecideFirst = "";
334  $cuDecideLast = "";
335  $cuDecideEmail = "";
336  $cuDecidePhone = "";
337  }
338 
339  if ( !($showDecider && $skipBlankEmails && !count( $deciderList )) ) {
340  // these only print for the first occurance
341  $cuCode = ($userName != $currCU ? $userName : "");
342  $cuName = ($userName != $currCU ? $cu_row['name'] : "");
343  $cuAssets = ($userName != $currCU ? $cu_row['dec_31_assets'] : "");
344  $cuMembers = ($userName != $currCU ? $cu_row['dec_31_mem'] : "");
345  $cuVendor = ($userName != $currCU ? $cu_row['vendor'] : "");
346  $cuExpires = ($userName != $currCU ? $cu_row['contract_expires'] : "");
347  $cuRenewal = ($userName != $currCU ? $cu_row['renewal_term'] : "");
348 
349  $outputFields = "\"$cuCode\",\"$cuName\",\"$cuAssets\",\"$cuMembers\",\"$cuVendor\"";
350 
351  if ( $showProduct )
352  $outputFields .= sprintf( ",\"%s\"", $cu_row['home_cu_desc'] );
353 
354  if ( $showDecider ) {
355  $outputFields .= ",\"$cuDecideFirst\",\"$cuDecideLast\",\"$cuDecideEmail\",\"$cuDecidePhone\"";
356  $deciderOffset++;
357  }
358 
359  if ( $showExpDate )
360  $outputFields .= ",\"$cuExpires\",\"$cuRenewal\"";
361 
362  $outputString .= "$outputFields\r\n";
363  }
364 
365  $currCU = $userName;
366  }
367 
368  // finally, see if need to finish with any deciders from the final CU
369  if ( $showDecider ) {
370  while ( $deciderOffset < count( $deciderList ) ) {
371  // only print the decider columns since we ran out of the products or we wouldn't be here
372  $cuDecideFirst = trim($deciderList[$deciderOffset]['fname']);
373  $cuDecideLast = trim($deciderList[$deciderOffset]['lname']);
374  $cuDecideEmail = $deciderList[$deciderOffset]['email'];
375  $cuDecidePhone = $deciderList[$deciderOffset]['phone'];
376 
377  $outputFields = "\"\",\"\"";
378 
379  if ( $showProduct )
380  $outputFields .= ",\"\"";
381 
382  $outputFields .= ",\"$cuDecideFirst\",\"$cuDecideLast\",\"$cuDecideEmail\",\"$cuDecidePhone\"";
383 
384  if ( $showExpDate )
385  $outputFields .= ",\"\"";
386 
387  $outputString .= "$outputFields\r\n";
388 
389  $deciderOffset++;
390  }
391  }
392  }
393 
394  header("Content-length: " . strlen( $outputString ) );
395  header("Content-type: application/octetstream");
396  header("Content-disposition: inline; filename=\"ProductReport.csv\"");
397  print ( $outputString );
398  exit;
399  }
400 
401  // ** VIEW RECORDS
402 ?>
403  <center>
404  <table cellpadding="3" cellspacing="0" border="0" width="99%" class="dmsbg">
405  <tr>
406  <td>
407  <table cellpadding="0" cellspacing="0" border="0" width="100%" bgcolor=white>
408  <tr>
409  <td class="ahd" align="center" colspan="<?php echo $vis_col; ?>">
410  CU Products Report
411  </td>
412  </tr>
413  <?php
414  // let the user select what they want to see and set up similar filter for CSV output
415  $csvFilter = "";
416  if ( $showProduct ) {
417  if ( strlen( $csvFilter ) ) $csvFilter .= "&";
418  $csvFilter .= "show_product=1";
419  }
420  if ( $singleLine ) {
421  if ( strlen( $csvFilter ) ) $csvFilter .= "&";
422  $csvFilter .= "single_line=1";
423  }
424  if ( $showDecider ) {
425  if ( strlen( $csvFilter ) ) $csvFilter .= "&";
426  $csvFilter .= "show_decider=1";
427  }
428  if ( $skipBlankEmails ) {
429  if ( strlen( $csvFilter ) ) $csvFilter .= "&";
430  $csvFilter .= "skip_blank_emails=1";
431  }
432  if ( $showExpDate ) {
433  if ( strlen( $csvFilter ) ) $csvFilter .= "&";
434  $csvFilter .= "show_exp_date=1";
435  }
436  ?>
437  <tr>
438  <td colspan='8'>
439  <form action="<?php echo $self; ?>" method="get">
440  <input type="hidden" name="act" value="<?php echo $act; ?>">
441  <table cellpadding="0" cellspacing="0" style='border-width: 1px;' width="100%" bgcolor=white>
442  <tr>
443  <td style='font-weight:bold;'>Select what to view: </td>
444  <td><input type="checkbox" name="show_product" value="1" <?php echo ($showProduct == 1 ? "checked='CHECKED'" : "") ?>>
445  Show Products
446  </td>
447  <td><input type="checkbox" name="single_line" value="1" <?php echo ($singleLine == 1 ? "checked='CHECKED'" : "") ?>>
448  Single Line
449  </td>
450  <td><input type="checkbox" name="show_decider" value="1" <?php echo ($showDecider == 1 ? "checked='CHECKED'" : "") ?>>
451  Show Decision Maker
452  </td>
453  <td><input type="checkbox" name="skip_blank_emails" value="1" <?php echo ($skipBlankEmails == 1 ? "checked='CHECKED'" : "") ?>>
454  Skip Blank E-mails
455  </td>
456  <td><input type="checkbox" name="show_exp_date" value="1" <?php echo ($showExpDate == 1 ? "checked='CHECKED'" : "") ?>>
457  Show Expiration Date
458  </td>
459  <td><button type="submit">Refresh</button>
460  </td>
461  </tr>
462  <tr>
463  <td style='font-weight:bold;'>Product Filter: <span id='productExpand' style='cursor:pointer;' onClick="javascript:toggleFilter();">[&nbsp;+&nbsp;]</span></td>
464  </tr>
465  <tr id='productFilter' style='display:none;'>
466  <td colspan='8'><table>
467  <tr>
468  <td colspan='8'><table>
469  <?php
470  // products
471  for ( $i = 0; $i < count( $productList ); $i++ ) {
472  print "<tr>";
473  printf( "<td>%s</td>", $productList[$i]["desc"] );
474  printf( "<td><input type='radio' name='value%s' value='1' %s> Has</td>", $productList[$i]["code"], $productList[$i]["include"] == 1 ? "checked='CHECKED'" : "" );
475  printf( "<td><input type='radio' name='value%s' value='2' %s> Doesn't Have</td>", $productList[$i]["code"], $productList[$i]["include"] == 2 ? "checked='CHECKED'" : "" );
476  printf( "<td><input type='radio' name='value%s' value='0' %s> Don't Care</td>", $productList[$i]["code"], $productList[$i]["include"] == 0 ? "checked='CHECKED'" : "" );
477  print "</tr>\n";
478 
479  // add to the filter
480  if ( strlen( $csvFilter ) ) $csvFilter .= "&";
481  $csvFilter .= sprintf( "value%s=%s", $productList[$i]["code"], $productList[$i]["include"] );
482  }
483  ?>
484  </table></td>
485  </tr>
486  <tr>
487  <td colspan='8'><table>
488  <?php
489  // logic
490  print "<tr>";
491  printf( "<td style='font-weight:bold;'>Filter Logic:</td>" );
492  print "</tr>";
493  print "<tr>";
494  printf( "<td>&nbsp;</td>" );
495  printf( "<td><input type='radio' name='prod_logic' value='0' %s> Show Credit Unions respecting the \"Has\" and \"Doesn't Have\"</td>", $prodLogic == 0 ? "checked='CHECKED'" : "" );
496  print "</tr>";
497  print "<tr>";
498  printf( "<td>&nbsp;</td>" );
499  printf( "<td><input type='radio' name='prod_logic' value='1' %s> Show Credit Unions with any \"Has\"</td>", $prodLogic == 1 ? "checked='CHECKED'" : "" );
500  print "</tr>";
501  print "<tr>";
502  printf( "<td>&nbsp;</td>" );
503  printf( "<td><input type='radio' name='prod_logic' value='2' %s> Show Credit Unions with all \"Has\"</td>", $prodLogic == 2 ? "checked='CHECKED'" : "" );
504  print "</tr>";
505 
506  // add to the filter
507  if ( strlen( $csvFilter ) ) $csvFilter .= "&";
508  $csvFilter .= sprintf( "prod_logic=%s", $prodLogic );
509  ?>
510  </table></td>
511  </tr>
512  </table></td>
513  </tr>
514  <tr>
515  <td style='font-weight:bold;'>Option Filter: <span id='optionExpand' style='cursor:pointer;' onClick="javascript:toggleOptionFilter();">[&nbsp;+&nbsp;]</span></td>
516  </tr>
517  <tr id='optionFilter' style='display:none;'>
518  <td colspan='8'><table style="border-width: 1;">
519  <?php
520  // options
521  for ( $i = 0; $i < count( $optionList ); $i++ ) {
522  print "<tr>";
523  printf( "<td>%s</td>", $optionList[$i]["desc"] );
524  printf( "<td><input type='radio' name='option%s' value='1' %s> Has</td>", $optionList[$i]["code"], $optionList[$i]["include"] == 1 ? "checked='CHECKED'" : "" );
525  printf( "<td><input type='radio' name='option%s' value='2' %s> Does NOT Have</td>", $optionList[$i]["code"], $optionList[$i]["include"] == 2 ? "checked='CHECKED'" : "" );
526  printf( "<td><input type='radio' name='option%s' value='0' %s> Don't Care</td>", $optionList[$i]["code"], $optionList[$i]["include"] == 0 ? "checked='CHECKED'" : "" );
527  print "</tr>\n";
528 
529  // add to the filter
530  if ( strlen( $csvFilter ) ) $csvFilter .= "&";
531  $csvFilter .= sprintf( "option%s=%s", $optionList[$i]["code"], $optionList[$i]["include"] );
532  }
533  ?>
534  </table></td>
535  </tr>
536  </table>
537  </form>
538  <?php
539 print <<< js_code
540  <script language="javascript">
541  <!--
542  function toggleFilter() {
543  var elemExpand = document.getElementById('productExpand');
544  var elemFilter = document.getElementById('productFilter');
545 
546  if ( elemFilter.style.display == "none" ) {
547  elemFilter.style.display = "block";
548  elemExpand.innerHTML = "[&nbsp;-&nbsp;]";
549  } else {
550  elemFilter.style.display = "none";
551  elemExpand.innerHTML = "[&nbsp;+&nbsp;]";
552  }
553  }
554  function toggleOptionFilter() {
555  var elemExpand = document.getElementById('optionExpand');
556  var elemFilter = document.getElementById('optionFilter');
557 
558  if ( elemFilter.style.display == "none" ) {
559  elemFilter.style.display = "block";
560  elemExpand.innerHTML = "[&nbsp;-&nbsp;]";
561  } else {
562  elemFilter.style.display = "none";
563  elemExpand.innerHTML = "[&nbsp;+&nbsp;]";
564  }
565  }
566  // -->
567  </script>
568 js_code;
569  ?>
570  </td>
571  </tr>
572  <tr><td>&nbsp;</td></tr>
573  <tr>
574  <td colspan="<?php echo $vis_col; ?>" >
575  <a href="/monitor/mindex.html" target="_top">Return to Monitor</a>
576  &nbsp;&nbsp;
577  <a href="cuproduct_report.prg?csv=csv&<?php echo $csvFilter; ?>&ob=<?php echo $ob_fldid ?>&d=<?php echo $pDescending?>">Download CSV</a>
578  </td>
579  </tr>
580  <tr>
581  <td class="hdr"><a href="<?php echo $self; ?>?act=<?php echo $act; ?>&ob=1&d=<?php echo $ob_desc[1]; ?>&<?php echo $csvFilter; ?>">CU Code</a></td>
582  <td class="hdr"><a href="<?php echo $self; ?>?act=<?php echo $act; ?>&ob=2&d=<?php echo $ob_desc[2]; ?>&<?php echo $csvFilter; ?>">CU Name</a></td>
583  <td class="hdr"><a href="<?php echo $self; ?>?act=<?php echo $act; ?>&ob=3&d=<?php echo $ob_desc[3]; ?>&<?php echo $csvFilter; ?>">Asset</a></td>
584  <td class="hdr"><a href="<?php echo $self; ?>?act=<?php echo $act; ?>&ob=4&d=<?php echo $ob_desc[4]; ?>&<?php echo $csvFilter; ?>">Mem</a></td>
585  <td class="hdr"><a href="<?php echo $self; ?>?act=<?php echo $act; ?>&ob=5&d=<?php echo $ob_desc[5]; ?>&<?php echo $csvFilter; ?>">Vendor</a></td>
586  <?php
587  if ( $showProduct && !$singleLine ) {
588  printf( "<td class=\"hdr\"><a href=\"$self?act=$act&ob=6&d=%s&$csvFilter\">Product</a></td>\n", $ob_desc[6] );
589  }
590  if ( $showDecider ) {
591  // doesn't make sense to sort on these
592  printf( "<td class=\"hdr\"><a href=\"javascript:void();\">First</a></td>\n" );
593  printf( "<td class=\"hdr\"><a href=\"javascript:void();\">Last</a></td>\n" );
594  printf( "<td class=\"hdr\"><a href=\"javascript:void();\">E-mail</a></td>\n" );
595  printf( "<td class=\"hdr\"><a href=\"javascript:void();\">Phone</a></td>\n" );
596  }
597  if ( $showExpDate ) {
598  printf( "<td class=\"hdr\"><a href=\"$self?act=$act&ob=7&d=%s&$csvFilter\">Exp Date</a></td>\n", $ob_desc[7] );
599  printf( "<td class=\"hdr\"><a href=\"javascript:void();\">Renewal</a></td>\n" );
600  }
601  // if showing products on a single line, show them last because there are so many
602  if ( $showProduct && $singleLine ) {
603  // list all the possible products
604  for ( $p = 0; $p < count( $productList ); $p++ ) {
605  printf( "<td class=\"hdr\">%s</td>\n", $productList[$p]["code"] );
606  }
607  }
608  ?>
609  </tr>
610 
611 
612  <?php if ($num_rows == 0): ?>
613  <tr>
614  <td class="ahd" align="center" colspan="<?php echo $vis_col; ?>">
615  No Records Found
616  </td>
617  </tr>
618  <?php else: ?>
619  <?php
620  if ( $singleLine ) {
621  // NOTE: if $singleLine is true then ignore the $showDecider flag
622  $row_cnt = 0;
623  $row_class = "odd";
624  while ($cu_row = db_fetch_array($cu_rs, $row_cnt++)) {
625  $userName = trim($cu_row["user_name"]);
626 
627  // get the products for the credit union
628  $cuProducts = GetCUProductList( $userName );
629 
630  $passedFilter = TestProductFilter2($cuProducts, $productList, $prodLogic);
631 
632  if ( !$passedFilter ) {
633  continue;
634  }
635 
636  $row_class = ($row_class == "odd" ? "even" : "odd");
637 
638  print "<tr class=\"$row_class\">";
639 
640  // these only print for the first occurance
641  $cuCode = $userName;
642  $cuName = $cu_row['name'];
643  $cuAssets = $cu_row['dec_31_assets'];
644  $cuMembers = $cu_row['dec_31_mem'];
645  $cuVendor = $cu_row['vendor'];
646  $cuExpires = $cu_row['contract_expires'];
647  $cuRenewal = $cu_row['renewal_term'];
648  $cuHomepage = trim($cu_row["home_page_url"]);
649 
650  $vend_show = (trim($cu_row["vendor"]) == '' ? "" : "&vc=". trim($cu_row["vendor"]));
651  $www_show = (trim($cu_row["www_server"]) == '' ? "" : "&wc=". trim($cu_row["www_server"]));
652 
653  printf("<td class=\"usul\"><a href=\"%s/hcuadm/cuindex.prg?action=fetch&rowid=%s%s%s\">$cuCode</a></td>",
654  $info_url, $cuCode, $vend_show, $www_show );
655 
656  if ( strlen( $cuName ) > 0 && strlen( $cuHomepage ) > 0 )
657  print "<td class=\"usul\"><a href='http://$cuHomepage' target='_blank'>$cuName</a></td>";
658  else if ( strlen( $cuName ) > 0 )
659  print "<td class=\"usul\">$cuName</td>";
660  else
661  print "<td class=\"usul\">&nbsp;</td>";
662 
663  if ( $cuAssets > 0 )
664  print "<td class=\"usul\">$cuAssets</td>";
665  else
666  print "<td class=\"usul\">&nbsp;</td>";
667 
668  if ( $cuMembers > 0 )
669  print "<td class=\"usul\">$cuMembers</td>";
670  else
671  print "<td class=\"usul\">&nbsp;</td>";
672 
673  if ( strlen( $cuVendor ) > 0 )
674  print "<td class=\"usul\">$cuVendor</td>";
675  else
676  print "<td class=\"usul\">&nbsp;</td>";
677 
678  if ( $showExpDate ) {
679  if ( strlen( $cuExpires ) )
680  print "<td class=\"usul\">$cuExpires</a></td>\n";
681  else
682  print "<td class=\"usul\">&nbsp;</a></td>\n";
683  if ( strlen( $cuRenewal ) )
684  print "<td class=\"usul\">$cuRenewal</a></td>\n";
685  else
686  print "<td class=\"usul\">&nbsp;</a></td>\n";
687  }
688 
689  if ( $showProduct ) {
690  // give each product an "X" or "" based on the setting; do in order of $productList
691  for( $p = 0; $p < count( $productList ); $p++ ) {
692  $cuHasProduct = false;
693  for ( $c = 0; $c < count( $cuProducts ); $c++ ) {
694  if ( $cuProducts[$c] == $productList[$p]["code"] ) {
695  $cuHasProduct = true;
696  break;
697  }
698  }
699 
700  printf( "<td class=\"usul\" style='border-left:1px dotted grey;'>%s</td>\n", ($cuHasProduct ? "X" : "&nbsp;") );
701  }
702  }
703 
704  print "</tr>";
705  }
706  } else {
707  $row_cnt = 0;
708  $currCU = "";
709  $skippingCU = "";
710  $deciderList = array();
711  $deciderOffset = 0;
712  while ($cu_row = db_fetch_array($cu_rs, $row_cnt++)) {
713  $userName = trim($cu_row["user_name"]);
714 
715  if ( $userName == $skippingCU ) continue;
716 
717  if ( $userName != $currCU ) {
718  // first, see if need to finish with any deciders from the previous CU
719  if ( $showDecider ) {
720  while ( $deciderOffset < count( $deciderList ) ) {
721  $row_class = ($row_class == "odd" ? "even" : "odd");
722 
723  // only print the decider columns since we ran out of the products or we wouldn't be here
724  print "<tr class=\"$row_class\">";
725  print "<td class=\"usul\">&nbsp;</td>"; // cu code
726  print "<td class=\"usul\">&nbsp;</td>"; // cu name
727  print "<td class=\"usul\">&nbsp;</td>"; // assets
728  print "<td class=\"usul\">&nbsp;</td>"; // members
729  print "<td class=\"usul\">&nbsp;</td>"; // vendor
730  if ( $showProduct && !$singleLine )
731  print "<td class=\"usul\">&nbsp;</td>"; // product
732 
733  $cuDecideFirst = dms_disphtml($deciderList[$deciderOffset]['fname']);
734  $cuDecideLast = dms_disphtml($deciderList[$deciderOffset]['lname']);
735  $cuDecideEmail = $deciderList[$deciderOffset]['email'];
736  $cuDecidePhone = $deciderList[$deciderOffset]['phone'];
737 
738  print "<td class=\"usul\">$cuDecideFirst</a></td>\n";
739  print "<td class=\"usul\">$cuDecideLast</a></td>\n";
740  print "<td class=\"usul\">$cuDecideEmail</a></td>\n";
741  print "<td class=\"usul\">$cuDecidePhone</a></td>\n";
742 
743  if ( $showExpDate ) {
744  print "<td class=\"usul\">&nbsp;</td>"; // exp date
745  print "<td class=\"usul\">&nbsp;</td>"; // renewal
746  }
747 
748  if ( $showProduct && $singleLine )
749  print "<td class=\"usul\">&nbsp;</td>"; // product
750 
751  print "</tr>";
752 
753  $deciderOffset++;
754  }
755  }
756 
757  $passedFilter = TestProductFilter($userName, $productList, $prodLogic);
758 
759  if ( !$passedFilter ) {
760  $skippingCU = $userName;
761  continue;
762  }
763 
764  // get the list of deciders for this CU
765  if ( $showDecider ) {
766  $deciderSQL = "SELECT monitor_contact.fname, monitor_contact.lname, monitor_contact.email, monitor_contact.phone
767  FROM monitor_contact
768  WHERE user_name = '$userName'
769  AND monitor_contact.decider = 'Y' ";
770 
771  if ( $skipBlankEmails )
772  $deciderSQL .= " AND length( monitor_contact.email ) > 0 ";
773 
774  $deciderRS = db_query($deciderSQL, $link);
775 
776  // get the list of deciders all right now
777  $deciderList = array();
778  $deciderRowCnt = 0;
779  while ($deciderRow = db_fetch_array($deciderRS, $deciderRowCnt++)) {
780  $deciderList[] = $deciderRow;
781  }
782 
783  // reset offset so we know where we are
784  $deciderOffset = 0;
785  }
786  }
787 
788  if ( $showDecider &&
789  $deciderOffset < count( $deciderList ) ) {
790  $cuDecideFirst = dms_disphtml($deciderList[$deciderOffset]['fname']);
791  $cuDecideLast = dms_disphtml($deciderList[$deciderOffset]['lname']);
792  $cuDecideEmail = $deciderList[$deciderOffset]['email'];
793  $cuDecidePhone = $deciderList[$deciderOffset]['phone'];
794  } else {
795  $cuDecideFirst = "";
796  $cuDecideLast = "";
797  $cuDecideEmail = "";
798  $cuDecidePhone = "";
799  }
800 
801  if ( !($showDecider && $skipBlankEmails && !count( $deciderList )) ) {
802  $row_class = ($row_class == "odd" ? "even" : "odd");
803 
804  print "<tr class=\"$row_class\">";
805 
806  // these only print for the first occurance
807  $cuCode = ($userName != $currCU ? $userName : "");
808  $cuName = ($userName != $currCU ? $cu_row['name'] : "");
809  $cuAssets = ($userName != $currCU ? $cu_row['dec_31_assets'] : "");
810  $cuMembers = ($userName != $currCU ? $cu_row['dec_31_mem'] : "");
811  $cuVendor = ($userName != $currCU ? $cu_row['vendor'] : "");
812  $cuExpires = ($userName != $currCU ? $cu_row['contract_expires'] : "");
813  $cuRenewal = ($userName != $currCU ? $cu_row['renewal_term'] : "");
814  $cuHomepage = trim($cu_row["home_page_url"]);
815 
816  $vend_show = (trim($cu_row["vendor"]) == '' ? "" : "&vc=". trim($cu_row["vendor"]));
817  $www_show = (trim($cu_row["www_server"]) == '' ? "" : "&wc=". trim($cu_row["www_server"]));
818 
819  if ( $userName != $currCU )
820  printf("<td class=\"usul\"><a href=\"%s/hcuadm/cuindex.prg?action=fetch&rowid=%s%s%s\">$cuCode</a></td>",
821  $info_url, $cuCode, $vend_show, $www_show );
822  else
823  print "<td class=\"usul\">&nbsp;</td>";
824 
825  if ( strlen( $cuName ) > 0 && strlen( $cuHomepage ) > 0 )
826  print "<td class=\"usul\"><a href='http://$cuHomepage' target='_blank'>$cuName</a></td>";
827  else if ( strlen( $cuName ) > 0 )
828  print "<td class=\"usul\">$cuName</td>";
829  else
830  print "<td class=\"usul\">&nbsp;</td>";
831 
832  if ( $cuAssets > 0 )
833  print "<td class=\"usul\">$cuAssets</td>";
834  else
835  print "<td class=\"usul\">&nbsp;</td>";
836 
837  if ( $cuMembers > 0 )
838  print "<td class=\"usul\">$cuMembers</td>";
839  else
840  print "<td class=\"usul\">&nbsp;</td>";
841 
842  if ( strlen( $cuVendor ) > 0 )
843  print "<td class=\"usul\">$cuVendor</td>";
844  else
845  print "<td class=\"usul\">&nbsp;</td>";
846 
847  if ( $showProduct && !$singleLine )
848  printf( "<td class=\"usul\">%s</td>\n", dms_disphtml($cu_row['home_cu_desc']) );
849 
850  if ( $showDecider ) {
851  print "<td class=\"usul\">$cuDecideFirst</a></td>\n";
852  print "<td class=\"usul\">$cuDecideLast</a></td>\n";
853  print "<td class=\"usul\">$cuDecideEmail</a></td>\n";
854  print "<td class=\"usul\">$cuDecidePhone</a></td>\n";
855  $deciderOffset++;
856  }
857 
858  if ( $showExpDate ) {
859  if ( strlen( $cuExpires ) )
860  print "<td class=\"usul\">$cuExpires</a></td>\n";
861  else
862  print "<td class=\"usul\">&nbsp;</a></td>\n";
863  if ( strlen( $cuRenewal ) )
864  print "<td class=\"usul\">$cuRenewal</a></td>\n";
865  else
866  print "<td class=\"usul\">&nbsp;</a></td>\n";
867  }
868 
869  if ( $showProduct && $singleLine )
870  printf( "<td class=\"usul\">%s</td>\n", dms_disphtml($cu_row['home_cu_desc']) );
871 
872  print "</tr>";
873  }
874 
875  $currCU = $userName;
876  }
877 
878  // finally, see if need to finish with any deciders from the last CU
879  if ( $showDecider ) {
880  while ( $deciderOffset < count( $deciderList ) ) {
881  $row_class = ($row_class == "odd" ? "even" : "odd");
882 
883  // only print the decider columns since we ran out of the products or we wouldn't be here
884  print "<tr class=\"$row_class\">";
885  print "<td class=\"usul\">&nbsp;</td>"; // cu code
886  print "<td class=\"usul\">&nbsp;</td>"; // cu name
887  print "<td class=\"usul\">&nbsp;</td>"; // assets
888  print "<td class=\"usul\">&nbsp;</td>"; // members
889  print "<td class=\"usul\">&nbsp;</td>"; // vendor
890  if ( $showProduct && !$singleLine )
891  print "<td class=\"usul\">&nbsp;</td>"; // product
892 
893  $cuDecideFirst = dms_disphtml($deciderList[$deciderOffset]['fname']);
894  $cuDecideLast = dms_disphtml($deciderList[$deciderOffset]['lname']);
895  $cuDecideEmail = $deciderList[$deciderOffset]['email'];
896  $cuDecidePhone = $deciderList[$deciderOffset]['phone'];
897 
898  print "<td class=\"usul\">$cuDecideFirst</a></td>\n";
899  print "<td class=\"usul\">$cuDecideLast</a></td>\n";
900  print "<td class=\"usul\">$cuDecideEmail</a></td>\n";
901  print "<td class=\"usul\">$cuDecidePhone</a></td>\n";
902 
903  if ( $showExpDate ) {
904  print "<td class=\"usul\">&nbsp;</td>"; // exp date
905  print "<td class=\"usul\">&nbsp;</td>"; // renewal
906  }
907 
908  if ( $showProduct && $singleLine )
909  print "<td class=\"usul\">&nbsp;</td>"; // product
910 
911  print "</tr>";
912 
913  $deciderOffset++;
914  }
915  }
916  }
917  endif;
918  ?>
919  </table>
920  </td>
921  </tr>
922  </table>
923  </body>
924  </html>
925 <?php
926  break;
927  }
928 
929 
930 
931  // Included Functions for this script
932 
933  // NOTE: The below function can be replaced by the next two since there is no gain in querying the products with
934  // the CUs at the beginning. In that case the logic of the calling routine will need to changed.
935  // Query the database to get the products for the credit union and then check if the product filter logic is met.
936  function TestProductFilter( $cuName, $productList, $prodLogic ) {
937  global $link;
938 
939  // see if the product filter matches this credit union
940  $productSql = "SELECT cuproducts.home_cu_code FROM cuproducts
941  JOIN cuprodlist on cuprodlist.home_cu_code = cuproducts.home_cu_code
942  WHERE cuproducts.user_name = '$cuName' order by cuproducts.home_cu_code";
943  $product_rs = db_query($productSql, $link);
944 
945  $cuProductList = array();
946  $prodRowCnt = 0;
947  while ( $product_row = db_fetch_array($product_rs, $prodRowCnt++) ) {
948  $cuProductList[] = trim($product_row["home_cu_code"]);
949  }
950 
951  // free it just in case we need the memory
952  db_free_result($product_rs);
953 
954  // compare what we are looking for to what we got
955  $passedFilter = false;
956  $matchCount = 0;
957  for ( $i = 0; $i < count( $productList ); $i++ ) {
958 //print "<br>Product " . $productList[$i]["code"];
959  if ( $productList[$i]["include"] == 1 ) {
960 //print " Include = 1 ";
961  // Need to have this be present
962  $found = false;
963  for ( $p = 0; $p < count( $cuProductList ); $p++ ) {
964 //print " test: " . $cuProductList[$p] . " = " . $productList[$i]["code"];
965  if ( $cuProductList[$p] == $productList[$i]["code"] ) {
966  $found = true;
967  break;
968  }
969  }
970 //print "Found: $found ";
971  if ( $prodLogic == 1 && $found ) {
972  // this is good enough
973  $passedFilter = true;
974  break;
975  } else if ( $prodLogic == 2 && !$found ) {
976  // fail - need all haves
977  $passedFilter = false;
978  break;
979  } else if ( $prodLogic == 0 && !$found ) {
980  // fail - needed to be found
981  $passedFilter = false;
982  break;
983  } else {
984  // need to count the matches
985  $matchCount++;
986  }
987  } else if ( ($productList[$i]["include"] == 2) && ($prodLogic == 0) ) {
988 //print " Include = 2 ";
989  // Need this one to be not present, but only if checking the exact option
990  $found = false;
991  for ( $p = 0; $p < count( $cuProductList ); $p++ ) {
992 //print " test: " . $cuProductList[$p] . " = " . $productList[$i]["code"];
993  if ( $cuProductList[$p] == $productList[$i]["code"] ) {
994  $found = true;
995  break;
996  }
997  }
998 //print "Found: $found ";
999 
1000  if ( $found ) {
1001  // fail - it shouldn't have been found
1002  $passedFilter = false;
1003  break;
1004  } else {
1005  // need to count these matches
1006  $matchCount++;
1007  }
1008  }
1009  }
1010 //print "<br>Passed: $passedFilter";
1011 
1012  // if comparing exact then all "has" and "don't haves" need to have been found
1013  if ( !$passedFilter && $prodLogic == 0 ) {
1014  $expectedCount = 0;
1015  for ( $i = 0; $i < count( $productList ); $i++ ) {
1016  if ( $productList[$i]["include"] == 1 || $productList[$i]["include"] == 2 ) {
1017  $expectedCount++;
1018  }
1019  }
1020  if ( $expectedCount == $matchCount ) $passedFilter = true;
1021  }
1022 //print "<br>Passed: $passedFilter";
1023 
1024  // if need ALL haves then need to match that
1025  if ( !$passedFilter && $prodLogic == 2 ) {
1026  $expectedCount = 0;
1027  for ( $i = 0; $i < count( $productList ); $i++ ) {
1028  if ( $productList[$i]["include"] == 1 ) {
1029  $expectedCount++;
1030  }
1031  }
1032  if ( $expectedCount == $matchCount ) $passedFilter = true;
1033  }
1034 //print "<br>Passed: $passedFilter";
1035  return $passedFilter;
1036  }
1037 
1038  function productSort($a, $b)
1039  {
1040  $indexArray= array_flip(array("", "Silver", "Gold", "Platinum"));
1041  $aIndex= intval($indexArray[$a["code"]]);
1042  $bIndex= intval($indexArray[$b["code"]]);
1043 
1044  $indexChange= $aIndex - $bIndex;
1045  if ($indexChange != 0)
1046  return $indexChange;
1047  return strcmp($a["desc"], $b["desc"]);
1048  }
1049 
1050  // Query the database for the list of products for the given credit union.
1051  function GetCUProductList( $cuName ) {
1052  global $link;
1053 
1054  // see if the product filter matches this credit union
1055  $productSql = "SELECT cuproducts.home_cu_code FROM cuproducts
1056  WHERE cuproducts.user_name = '$cuName' order by cuproducts.home_cu_code";
1057  $product_rs = db_query($productSql, $link);
1058 
1059  $cuProductList = array();
1060  $prodRowCnt = 0;
1061  while ( $product_row = db_fetch_array($product_rs, $prodRowCnt++) ) {
1062  $cuProductList[] = trim($product_row["home_cu_code"]);
1063  }
1064 
1065  // free it just in case we need the memory
1066  db_free_result($product_rs);
1067 
1068  return $cuProductList;
1069  } // end GetCUProductList
1070 
1071  // Use the products passed in for the credit union and then check if the product filter logic is met.
1072  function TestProductFilter2( $cuProductList, $productList, $prodLogic ) {
1073 
1074  // compare what we are looking for to what we got
1075  $passedFilter = false;
1076  $matchCount = 0;
1077  for ( $i = 0; $i < count( $productList ); $i++ ) {
1078 //print "<br>Product " . $productList[$i]["code"];
1079  if ( $productList[$i]["include"] == 1 ) {
1080 //print " Include = 1 ";
1081  // Need to have this be present
1082  $found = false;
1083  for ( $p = 0; $p < count( $cuProductList ); $p++ ) {
1084 //print " test: " . $cuProductList[$p] . " = " . $productList[$i]["code"];
1085  if ( $cuProductList[$p] == $productList[$i]["code"] ) {
1086  $found = true;
1087  break;
1088  }
1089  }
1090 //print "Found: $found ";
1091  if ( $prodLogic == 1 && $found ) {
1092  // this is good enough
1093  $passedFilter = true;
1094  break;
1095  } else if ( $prodLogic == 2 && !$found ) {
1096  // fail - need all haves
1097  $passedFilter = false;
1098  break;
1099  } else if ( $prodLogic == 0 && !$found ) {
1100  // fail - needed to be found
1101  $passedFilter = false;
1102  break;
1103  } else {
1104  // need to count the matches
1105  $matchCount++;
1106  }
1107  } else if ( ($productList[$i]["include"] == 2) && ($prodLogic == 0) ) {
1108 //print " Include = 2 ";
1109  // Need this one to be not present, but only if checking the exact option
1110  $found = false;
1111  for ( $p = 0; $p < count( $cuProductList ); $p++ ) {
1112 //print " test: " . $cuProductList[$p] . " = " . $productList[$i]["code"];
1113  if ( $cuProductList[$p] == $productList[$i]["code"] ) {
1114  $found = true;
1115  break;
1116  }
1117  }
1118 //print "Found: $found ";
1119 
1120  if ( $found ) {
1121  // fail - it shouldn't have been found
1122  $passedFilter = false;
1123  break;
1124  } else {
1125  // need to count these matches
1126  $matchCount++;
1127  }
1128  }
1129  }
1130 //print "<br>Passed: $passedFilter";
1131 
1132  // if comparing exact then all "has" and "don't haves" need to have been found
1133  if ( !$passedFilter && $prodLogic == 0 ) {
1134  $expectedCount = 0;
1135  for ( $i = 0; $i < count( $productList ); $i++ ) {
1136  if ( $productList[$i]["include"] == 1 || $productList[$i]["include"] == 2 ) {
1137  $expectedCount++;
1138  }
1139  }
1140  if ( $expectedCount == $matchCount ) $passedFilter = true;
1141  }
1142 //print "<br>Passed: $passedFilter";
1143 
1144  // if need ALL haves then need to match that
1145  if ( !$passedFilter && $prodLogic == 2 ) {
1146  $expectedCount = 0;
1147  for ( $i = 0; $i < count( $productList ); $i++ ) {
1148  if ( $productList[$i]["include"] == 1 ) {
1149  $expectedCount++;
1150  }
1151  }
1152  if ( $expectedCount == $matchCount ) $passedFilter = true;
1153  }
1154 //print "<br>Passed: $passedFilter";
1155  return $passedFilter;
1156  }
1157 
1158  function get_field($value) {
1159  switch (intval($value)) {
1160  case 2:
1161  $ret_field = " cuinfo.name ";
1162  break;
1163  case 3:
1164  $ret_field = " cuinfo.dec_31_assets ";
1165  break;
1166  case 4:
1167  $ret_field = " cuinfo.dec_31_mem ";
1168  break;
1169  case 5:
1170  $ret_field = " cuinfo.vendor ";
1171  break;
1172  case 6:
1173  $ret_field = " cuprodlist.home_cu_desc ";
1174  break;
1175  case 7:
1176  $ret_field = " cuinfo.contract_expires ";
1177  break;
1178  case 1:
1179  default:
1180  $ret_field = " cuinfo.user_name ";
1181  break;
1182  }
1183 
1184  return $ret_field;
1185  }
1186 
1187 
1188  function get_desc($value) {
1189  if ($value == "Y")
1190  return " DESC ";
1191  else
1192  return "";
1193  }
1194 
1195 ?>