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