2 // Copyright (C) 2005 Rod Roark <rod@sunsetsystems.com>
4 // This program is free software; you can redistribute it and/or
5 // modify it under the terms of the GNU General Public License
6 // as published by the Free Software Foundation; either version 2
7 // of the License, or (at your option) any later version.
9 // The purpose of this module is to show a list of insurance
10 // companies that match the passed-in search strings, and to allow
11 // one of them to be selected.
13 include_once("../globals.php");
15 // Putting a message here will cause a popup window to display it.
18 function addwhere($where, $colname, $value) {
21 $where .= "$colname LIKE '%$value%'";
26 // The following code builds the appropriate SQL query from the
27 // search parameters passed by our opener (ins_search.php).
30 $where = addwhere($where, 'i.name' , $_REQUEST['form_name'] );
31 $where = addwhere($where, 'i.attn' , $_REQUEST['form_attn'] );
32 $where = addwhere($where, 'i.cms_id', $_REQUEST['form_cms_id']);
33 $where = addwhere($where, 'a.line1' , $_REQUEST['form_addr1'] );
34 $where = addwhere($where, 'a.line2' , $_REQUEST['form_addr2'] );
35 $where = addwhere($where, 'a.city' , $_REQUEST['form_city'] );
36 $where = addwhere($where, 'a.state' , $_REQUEST['form_state'] );
37 $where = addwhere($where, 'a.zip' , $_REQUEST['form_zip'] );
39 $phone_parts = array();
41 // Search by area code if there is one.
42 if (preg_match("/(\d\d\d)/",
43 $_REQUEST['form_phone'], $phone_parts))
44 $where = addwhere($where, 'p.area_code', $phone_parts[1]);
46 // If there is also an exchange, search for that too.
47 if (preg_match("/\d\d\d\D*(\d\d\d)/",
48 $_REQUEST['form_phone'], $phone_parts))
49 $where = addwhere($where, 'p.prefix', $phone_parts[1]);
51 // If the last 4 phone number digits are given, search for that too.
52 if (preg_match("/\d\d\d\D*\d\d\d\D*(\d\d\d\d)/",
53 $_REQUEST['form_phone'], $phone_parts))
54 $where = addwhere($where, 'p.number', $phone_parts[1]);
57 "i.id, i.name, i.attn, " .
58 "a.line1, a.line2, a.city, a.state, a.zip, " .
59 "p.area_code, p.prefix, p.number " .
60 "FROM insurance_companies AS i, addresses AS a, phone_numbers AS p " .
61 "WHERE a.foreign_id = i.id AND p.foreign_id = i.id$where " .
62 "ORDER BY i.name, a.zip";
63 $res = sqlStatement($query);
67 <title
><?php
xl('List Insurance Companies','e');?
></title
>
68 <link rel
="stylesheet" href
='<?php echo $css_header ?>' type
='text/css'>
71 td
{ font
-size
:10pt
; }
74 <script language
="JavaScript">
76 // This is invoked when an insurance company name is clicked.
77 function setins(ins_id
, ins_name
) {
78 parent
.set_insurance(ins_id
, ins_name
);
79 parent
.$
.fn
.fancybox
.close();
87 <body
class="body_top">
88 <form method
='post' name
='theform'>
91 <table border
='0' width
='100%'>
93 <td
><b
><?php
xl('Name','e');?
></b
> 
;</td
>
94 <td
><b
><?php
xl('Attn','e');?
></b
> 
;</td
>
95 <td
><b
><?php
xl('Address','e');?
></b
> 
;</td
>
96 <td
><b
> 
;</b
> 
;</td
>
97 <td
><b
><?php
xl('City','e');?
></b
> 
;</td
>
98 <td
><b
><?php
xl('State','e');?
></b
> 
;</td
>
99 <td
><b
><?php
xl('Zip','e');?
></b
> 
;</td
>
100 <td
><b
><?php
xl('Phone','e');?
></b
></td
>
104 while ($row = sqlFetchArray($res)) {
105 $anchor = "<a href=\"\" onclick=\"return setins(" .
106 $row['id'] . ",'" . addslashes($row['name']) . "')\">";
108 if ($row['number']) {
109 $phone = $row['area_code'] . '-' . $row['prefix'] . '-' . $row['number'];
112 echo " <td valign='top'>$anchor" . $row['name'] . "</a> </td>\n";
113 echo " <td valign='top'>" . $row['attn'] . " </td>\n";
114 echo " <td valign='top'>" . $row['line1'] . " </td>\n";
115 echo " <td valign='top'>" . $row['line2'] . " </td>\n";
116 echo " <td valign='top'>" . $row['city'] . " </td>\n";
117 echo " <td valign='top'>" . $row['state'] . " </td>\n";
118 echo " <td valign='top'>" . $row['zip'] . " </td>\n";
119 echo " <td valign='top'>$phone</td>\n";