bug fix march continued (#1921)
[openemr.git] / interface / usergroup / facilities.php
blob416c45800f4678c60dcd23823193bf693991970b
1 <?php
2 /**
3 * Facilities.
5 * @package OpenEMR
6 * @link http://www.open-emr.org
7 * @author Ranganath Pathak <pathak01@hotmail.com>
8 * @author Brady Miller <brady.g.miller@gmail.com>
9 * @copyright Copyright (c) 2017 Ranganath Pathak <pathak01@hotmail.com>
10 * @copyright Copyright (c) 2017 Brady Miller <brady.g.miller@gmail.com>
11 * @license https://github.com/openemr/openemr/blob/master/LICENSE GNU General Public License 3
14 require_once("../globals.php");
15 require_once("../../library/acl.inc");
17 use OpenEMR\Core\Header;
18 use OpenEMR\Services\FacilityService;
20 $facilityService = new FacilityService();
22 $alertmsg = '';
24 /* Inserting New facility */
25 if (isset($_POST["mode"]) && $_POST["mode"] == "facility" && $_POST["newmode"] != "admin_facility") {
26 $newFacility = array(
27 "name" => trim(isset($_POST["facility"]) ? $_POST["facility"] : ''),
28 "phone" => trim(isset($_POST["phone"]) ? $_POST["phone"] : ''),
29 "fax" => trim(isset($_POST["fax"]) ? $_POST["fax"] : ''),
30 "street" => trim(isset($_POST["street"]) ? $_POST["street"] : ''),
31 "city" => trim(isset($_POST["city"]) ? $_POST["city"] : ''),
32 "state" => trim(isset($_POST["state"]) ? $_POST["state"] : ''),
33 "postal_code" => trim(isset($_POST["postal_code"]) ? $_POST["postal_code"] : ''),
34 "country_code" => trim(isset($_POST["country_code"]) ? $_POST["country_code"] : ''),
35 "federal_ein" => trim(isset($_POST["federal_ein"]) ? $_POST["federal_ein"] : ''),
36 "website" => trim(isset($_POST["website"]) ? $_POST["website"] : ''),
37 "email" => trim(isset($_POST["email"]) ? $_POST["email"] : ''),
38 "color" => trim(isset($_POST["ncolor"]) ? $_POST["ncolor"] : ''),
39 "service_location" => trim(isset($_POST["service_location"]) ? $_POST["service_location"] : ''),
40 "billing_location" => trim(isset($_POST["billing_location"]) ? $_POST["billing_location"] : ''),
41 "accepts_assignment" => trim(isset($_POST["accepts_assignment"]) ? $_POST["accepts_assignment"] : ''),
42 "pos_code" => trim(isset($_POST["pos_code"]) ? $_POST["pos_code"] : ''),
43 "domain_identifier" => trim(isset($_POST["domain_identifier"]) ? $_POST["domain_identifier"] : ''),
44 "attn" => trim(isset($_POST["attn"]) ? $_POST["attn"] : ''),
45 "tax_id_type" => trim(isset($_POST["tax_id_type"]) ? $_POST["tax_id_type"] : ''),
46 "primary_business_entity" => trim(isset($_POST["primary_business_entity"]) ? $_POST["primary_business_entity"] : ''),
47 "facility_npi" => trim(isset($_POST["facility_npi"]) ? $_POST["facility_npi"] : ''),
48 "facility_taxonomy" => trim(isset($_POST["facility_taxonomy"]) ? $_POST["facility_taxonomy"] : ''),
49 "facility_code" => trim(isset($_POST["facility_id"]) ? $_POST["facility_id"] : '')
52 $insert_id = $facilityService->insert($newFacility);
53 exit(); // sjp 12/20/17 for ajax save
56 /* Editing existing facility */
57 if (isset($_POST["mode"]) && $_POST["mode"] == "facility" && $_POST["newmode"] == "admin_facility") {
58 $newFacility = array(
59 "fid" => trim(isset($_POST["fid"]) ? $_POST["fid"] : ''),
60 "name" => trim(isset($_POST["facility"]) ? $_POST["facility"] : ''),
61 "phone" => trim(isset($_POST["phone"]) ? $_POST["phone"] : ''),
62 "fax" => trim(isset($_POST["fax"]) ? $_POST["fax"] : ''),
63 "street" => trim(isset($_POST["street"]) ? $_POST["street"] : ''),
64 "city" => trim(isset($_POST["city"]) ? $_POST["city"] : ''),
65 "state" => trim(isset($_POST["state"]) ? $_POST["state"] : ''),
66 "postal_code" => trim(isset($_POST["postal_code"]) ? $_POST["postal_code"] : ''),
67 "country_code" => trim(isset($_POST["country_code"]) ? $_POST["country_code"] : ''),
68 "federal_ein" => trim(isset($_POST["federal_ein"]) ? $_POST["federal_ein"] : ''),
69 "website" => trim(isset($_POST["website"]) ? $_POST["website"] : ''),
70 "email" => trim(isset($_POST["email"]) ? $_POST["email"] : ''),
71 "color" => trim(isset($_POST["ncolor"]) ? $_POST["ncolor"] : ''),
72 "service_location" => trim(isset($_POST["service_location"]) ? $_POST["service_location"] : ''),
73 "billing_location" => trim(isset($_POST["billing_location"]) ? $_POST["billing_location"] : ''),
74 "accepts_assignment" => trim(isset($_POST["accepts_assignment"]) ? $_POST["accepts_assignment"] : ''),
75 "pos_code" => trim(isset($_POST["pos_code"]) ? $_POST["pos_code"] : ''),
76 "domain_identifier" => trim(isset($_POST["domain_identifier"]) ? $_POST["domain_identifier"] : ''),
77 "attn" => trim(isset($_POST["attn"]) ? $_POST["attn"] : ''),
78 "tax_id_type" => trim(isset($_POST["tax_id_type"]) ? $_POST["tax_id_type"] : ''),
79 "primary_business_entity" => trim(isset($_POST["primary_business_entity"]) ? $_POST["primary_business_entity"] : ''),
80 "facility_npi" => trim(isset($_POST["facility_npi"]) ? $_POST["facility_npi"] : ''),
81 "facility_taxonomy" => trim(isset($_POST["facility_taxonomy"]) ? $_POST["facility_taxonomy"] : ''),
82 "facility_code" => trim(isset($_POST["facility_id"]) ? $_POST["facility_id"] : '')
85 $facilityService->update($newFacility);
87 // Update facility name for all users with this facility.
88 // This is necassary because some provider based code uses facility name for lookups instead of facility id.
90 $facilityService->updateUsersFacility($newFacility['name'], $newFacility['fid']);
91 exit(); // sjp 12/20/17 for ajax save
95 <!DOCTYPE html >
96 <html>
97 <head>
99 <title><?php echo xlt("Facilities") ; ?></title>
101 <?php Header::setupHeader(['common', 'jquery-ui']); ?>
103 <script type="text/javascript">
105 function refreshme() {
106 top.restoreSession();
107 document.location.reload();
109 $(document).ready(function(){
111 $(".medium_modal").on('click', function(e) {
112 e.preventDefault();e.stopPropagation();
113 dlgopen('', '', 700, 590, '', '', {
114 allowResize: false,
115 allowDrag: true, // note these default to true if not defined here. left as example.
116 type: 'iframe',
117 url: $(this).attr('href')
121 $(".addfac_modal").on('click', function(e) {
122 e.preventDefault();e.stopPropagation();
123 dlgopen('', '', 700, 620, '', '', {
124 allowResize: false,
125 allowDrag: true,
126 type: 'iframe',
127 url: $(this).attr('href')
133 </script>
134 </head>
136 <body class="body_top">
138 <div class="container-fluid">
139 <div class="row">
140 <div class="col-xs-12">
141 <div class="page-header clearfix">
142 <h2 class="clearfix"><?php echo xlt("Facilities") ; ?></h2>
143 </div>
144 <a href="facilities_add.php" class="addfac_modal btn btn-default btn-add"><span><?php echo xlt('Add Facility');?></span></a>
145 </div>
146 </div>
147 <br>
148 <div class="row">
149 <div class="col-xs-12">
150 <div class="table-responsive">
151 <table class="table table-striped">
152 <thead>
153 <tr>
154 <th><?php echo xlt('Name'); ?></th>
155 <th><?php echo xlt('Address'); ?></th>
156 <th><?php echo xlt('Phone'); ?></th>
157 </tr>
158 </thead>
159 <tbody>
160 <?php
161 $fres = 0;
162 $fres = $facilityService->getAll();
163 if ($fres) {
164 $result2 = array();
165 for ($iter3 = 0; $iter3 < sizeof($fres); $iter3++) {
166 $result2[$iter3] = $fres[$iter3];
169 foreach ($result2 as $iter3) {
170 $varstreet="";//these are assigned conditionally below,blank assignment is done so that old values doesn't get propagated to next level.
171 $varcity="";
172 $varstate="";
173 $varstreet=$iter3["street"];
174 if ($iter3["street"]!="") {
175 $varstreet=$iter3["street"].",";
178 if ($iter3["city"]!="") {
179 $varcity=$iter3["city"].",";
182 if ($iter3["state"]!="") {
183 $varstate=$iter3["state"].",";
186 <tr height="22">
187 <td valign="top" class="text"><b><a href="facility_admin.php?fid=<?php echo attr($iter3["id"]); ?>" class="medium_modal"><span><?php echo text($iter3["name"]);?></span></a></b>&nbsp;</td>
188 <td valign="top" class="text"><?php echo text($varstreet.$varcity.$varstate.$iter3["country_code"]." ".$iter3["postal_code"]); ?>&nbsp;</td>
189 <td><?php echo text($iter3["phone"]);?>&nbsp;</td>
190 </tr>
191 <?php
195 if (count($result2)<=0) {?>
196 <tr height="25">
197 <td colspan="3" style="text-align:center;font-weight:bold;"> <?php echo xlt("Currently there are no facilities."); ?></td>
198 </tr>
199 <?php
200 } ?>
201 </tbody>
202 </table>
203 </div>
204 </div>
205 </div>
206 </div><!-- end of div container -->
207 <script language="JavaScript">
208 <?php
209 if ($alertmsg = trim($alertmsg)) {
210 echo "alert('$alertmsg');\n";
213 </script>
215 </body>
216 </html>