Huge Bootstrap 4 Classes Fix (#2807)
[openemr.git] / interface / practice / ins_list.php
blob22f29ed8269ed7d3b5c2ac609c46833c7508dfbf
1 <?php
2 /**
3 * The purpose of this module is to show a list of insurance
4 * companies that match the passed-in search strings, and to allow
5 * one of them to be selected.
7 * @package OpenEMR
8 * @link http://www.open-emr.org
9 * @author Rod Roark <rod@sunsetsystems.com>
10 * @author Brady Miller <brady.g.miller@gmail.com>
11 * @copyright Copyright (c) 2005 Rod Roark <rod@sunsetsystems.com>
12 * @copyright Copyright (c) 2018 Brady Miller <brady.g.miller@gmail.com>
13 * @license https://github.com/openemr/openemr/blob/master/LICENSE GNU General Public License 3
17 require_once("../globals.php");
19 use OpenEMR\Common\Csrf\CsrfUtils;
21 if (!CsrfUtils::verifyCsrfToken($_GET["csrf_token_form"])) {
22 CsrfUtils::csrfNotVerified();
26 // Putting a message here will cause a popup window to display it.
27 $info_msg = "";
29 function addwhere($where, $colname, $value)
31 if ($value) {
32 $where .= " AND ";
33 $where .= "$colname LIKE '%" . add_escape_custom($value) . "%'";
36 return $where;
39 // The following code builds the appropriate SQL query from the
40 // search parameters passed by our opener (ins_search.php).
42 $where = '';
43 $where = addwhere($where, 'i.name', $_GET['form_name']);
44 $where = addwhere($where, 'i.attn', $_GET['form_attn']);
45 $where = addwhere($where, 'i.cms_id', $_GET['form_cms_id']);
46 $where = addwhere($where, 'a.line1', $_GET['form_addr1']);
47 $where = addwhere($where, 'a.line2', $_GET['form_addr2']);
48 $where = addwhere($where, 'a.city', $_GET['form_city']);
49 $where = addwhere($where, 'a.state', $_GET['form_state']);
50 $where = addwhere($where, 'a.zip', $_GET['form_zip']);
52 $phone_parts = array();
54 // Search by area code if there is one.
55 if (preg_match(
56 "/(\d\d\d)/",
57 $_GET['form_phone'],
58 $phone_parts
59 )) {
60 $where = addwhere($where, 'p.area_code', $phone_parts[1]);
63 // If there is also an exchange, search for that too.
64 if (preg_match(
65 "/\d\d\d\D*(\d\d\d)/",
66 $_GET['form_phone'],
67 $phone_parts
68 )) {
69 $where = addwhere($where, 'p.prefix', $phone_parts[1]);
72 // If the last 4 phone number digits are given, search for that too.
73 if (preg_match(
74 "/\d\d\d\D*\d\d\d\D*(\d\d\d\d)/",
75 $_GET['form_phone'],
76 $phone_parts
77 )) {
78 $where = addwhere($where, 'p.number', $phone_parts[1]);
81 $query = "SELECT " .
82 "i.id, i.name, i.attn, " .
83 "a.line1, a.line2, a.city, a.state, a.zip, " .
84 "p.area_code, p.prefix, p.number " .
85 "FROM insurance_companies AS i, addresses AS a, phone_numbers AS p " .
86 "WHERE a.foreign_id = i.id AND p.foreign_id = i.id$where " .
87 "ORDER BY i.name, a.zip";
88 $res = sqlStatement($query);
90 <html>
91 <head>
92 <title><?php echo xlt('List Insurance Companies');?></title>
93 <link rel="stylesheet" href='<?php echo $css_header ?>' type='text/css'>
95 <style>
96 td { font-size:10pt; }
97 </style>
99 <script language="JavaScript">
101 // This is invoked when an insurance company name is clicked.
102 function setins(ins_id, ins_name) {
103 opener.set_insurance(ins_id, ins_name);
104 dlgclose();
105 return false;
108 </script>
110 </head>
112 <body class="body_top">
113 <form method='post' name='theform'>
114 <center>
116 <table class="table table-sm" border='0' width='100%'>
117 <tr>
118 <td><b><?php echo xlt('Name');?></b>&nbsp;</td>
119 <td><b><?php echo xlt('Attn');?></b>&nbsp;</td>
120 <td><b><?php echo xlt('Address');?></b>&nbsp;</td>
121 <td><b>&nbsp;</b>&nbsp;</td>
122 <td><b><?php echo xlt('City');?></b>&nbsp;</td>
123 <td><b><?php echo xlt('State');?></b>&nbsp;</td>
124 <td><b><?php echo xlt('Zip');?></b>&nbsp;</td>
125 <td><b><?php echo xlt('Phone');?></b></td>
126 </tr>
128 <?php
129 while ($row = sqlFetchArray($res)) {
130 $anchor = "<a href=\"\" onclick=\"return setins(" .
131 attr_js($row['id']) . "," . attr_js($row['name']) . ")\">";
132 $phone = '&nbsp';
133 if ($row['number']) {
134 $phone = text($row['area_code']) . '-' . text($row['prefix']) . '-' . text($row['number']);
137 echo " <tr>\n";
138 echo " <td valign='top'>$anchor" . text($row['name']) . "</a>&nbsp;</td>\n";
139 echo " <td valign='top'>" . text($row['attn']) . "&nbsp;</td>\n";
140 echo " <td valign='top'>" . text($row['line1']) . "&nbsp;</td>\n";
141 echo " <td valign='top'>" . text($row['line2']) . "&nbsp;</td>\n";
142 echo " <td valign='top'>" . text($row['city']) . "&nbsp;</td>\n";
143 echo " <td valign='top'>" . text($row['state']) . "&nbsp;</td>\n";
144 echo " <td valign='top'>" . text($row['zip']) . "&nbsp;</td>\n";
145 echo " <td valign='top'>" . $phone . "</td>\n";
146 echo " </tr>\n";
149 </table>
151 </center>
152 </form>
153 </body>
154 </html>