Fully responsive globals.php with vertical menu (#2460)
[openemr.git] / interface / usergroup / facilities.php
blob8b9bf2f643e6995541fc2ad9b5a3848f3dca9f96
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-2018 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 if (!empty($_POST)) {
21 if (!verifyCsrfToken($_POST["csrf_token_form"])) {
22 csrfNotVerified();
26 $facilityService = new FacilityService();
28 $alertmsg = '';
30 /* Inserting New facility */
31 if (isset($_POST["mode"]) && $_POST["mode"] == "facility" && $_POST["newmode"] != "admin_facility") {
32 $newFacility = array(
33 "name" => trim(isset($_POST["facility"]) ? $_POST["facility"] : ''),
34 "phone" => trim(isset($_POST["phone"]) ? $_POST["phone"] : ''),
35 "fax" => trim(isset($_POST["fax"]) ? $_POST["fax"] : ''),
36 "street" => trim(isset($_POST["street"]) ? $_POST["street"] : ''),
37 "city" => trim(isset($_POST["city"]) ? $_POST["city"] : ''),
38 "state" => trim(isset($_POST["state"]) ? $_POST["state"] : ''),
39 "postal_code" => trim(isset($_POST["postal_code"]) ? $_POST["postal_code"] : ''),
40 "country_code" => trim(isset($_POST["country_code"]) ? $_POST["country_code"] : ''),
41 "federal_ein" => trim(isset($_POST["federal_ein"]) ? $_POST["federal_ein"] : ''),
42 "website" => trim(isset($_POST["website"]) ? $_POST["website"] : ''),
43 "email" => trim(isset($_POST["email"]) ? $_POST["email"] : ''),
44 "color" => trim(isset($_POST["ncolor"]) ? $_POST["ncolor"] : ''),
45 "service_location" => trim(isset($_POST["service_location"]) ? $_POST["service_location"] : ''),
46 "billing_location" => trim(isset($_POST["billing_location"]) ? $_POST["billing_location"] : ''),
47 "accepts_assignment" => trim(isset($_POST["accepts_assignment"]) ? $_POST["accepts_assignment"] : ''),
48 "pos_code" => trim(isset($_POST["pos_code"]) ? $_POST["pos_code"] : ''),
49 "domain_identifier" => trim(isset($_POST["domain_identifier"]) ? $_POST["domain_identifier"] : ''),
50 "attn" => trim(isset($_POST["attn"]) ? $_POST["attn"] : ''),
51 "tax_id_type" => trim(isset($_POST["tax_id_type"]) ? $_POST["tax_id_type"] : ''),
52 "primary_business_entity" => trim(isset($_POST["primary_business_entity"]) ? $_POST["primary_business_entity"] : ''),
53 "facility_npi" => trim(isset($_POST["facility_npi"]) ? $_POST["facility_npi"] : ''),
54 "facility_taxonomy" => trim(isset($_POST["facility_taxonomy"]) ? $_POST["facility_taxonomy"] : ''),
55 "facility_code" => trim(isset($_POST["facility_id"]) ? $_POST["facility_id"] : ''),
56 "mail_street" => trim(isset($_POST["mail_street"]) ? $_POST["mail_street"] : ''),
57 "mail_street2" => trim(isset($_POST["mail_street2"]) ? $_POST["mail_street2"] : ''),
58 "mail_city" => trim(isset($_POST["mail_city"]) ? $_POST["mail_city"] : ''),
59 "mail_state" => trim(isset($_POST["mail_state"]) ? $_POST["mail_state"] : ''),
60 "mail_zip" => trim(isset($_POST["mail_zip"]) ? $_POST["mail_zip"] : ''),
61 "oid" => trim(isset($_POST["oid"]) ? $_POST["oid"] : '')
64 $insert_id = $facilityService->insert($newFacility);
65 exit(); // sjp 12/20/17 for ajax save
68 /* Editing existing facility */
69 if (isset($_POST["mode"]) && $_POST["mode"] == "facility" && $_POST["newmode"] == "admin_facility") {
70 $newFacility = array(
71 "fid" => trim(isset($_POST["fid"]) ? $_POST["fid"] : ''),
72 "name" => trim(isset($_POST["facility"]) ? $_POST["facility"] : ''),
73 "phone" => trim(isset($_POST["phone"]) ? $_POST["phone"] : ''),
74 "fax" => trim(isset($_POST["fax"]) ? $_POST["fax"] : ''),
75 "street" => trim(isset($_POST["street"]) ? $_POST["street"] : ''),
76 "city" => trim(isset($_POST["city"]) ? $_POST["city"] : ''),
77 "state" => trim(isset($_POST["state"]) ? $_POST["state"] : ''),
78 "postal_code" => trim(isset($_POST["postal_code"]) ? $_POST["postal_code"] : ''),
79 "country_code" => trim(isset($_POST["country_code"]) ? $_POST["country_code"] : ''),
80 "federal_ein" => trim(isset($_POST["federal_ein"]) ? $_POST["federal_ein"] : ''),
81 "website" => trim(isset($_POST["website"]) ? $_POST["website"] : ''),
82 "email" => trim(isset($_POST["email"]) ? $_POST["email"] : ''),
83 "color" => trim(isset($_POST["ncolor"]) ? $_POST["ncolor"] : ''),
84 "service_location" => trim(isset($_POST["service_location"]) ? $_POST["service_location"] : ''),
85 "billing_location" => trim(isset($_POST["billing_location"]) ? $_POST["billing_location"] : ''),
86 "accepts_assignment" => trim(isset($_POST["accepts_assignment"]) ? $_POST["accepts_assignment"] : ''),
87 "pos_code" => trim(isset($_POST["pos_code"]) ? $_POST["pos_code"] : ''),
88 "domain_identifier" => trim(isset($_POST["domain_identifier"]) ? $_POST["domain_identifier"] : ''),
89 "attn" => trim(isset($_POST["attn"]) ? $_POST["attn"] : ''),
90 "tax_id_type" => trim(isset($_POST["tax_id_type"]) ? $_POST["tax_id_type"] : ''),
91 "primary_business_entity" => trim(isset($_POST["primary_business_entity"]) ? $_POST["primary_business_entity"] : ''),
92 "facility_npi" => trim(isset($_POST["facility_npi"]) ? $_POST["facility_npi"] : ''),
93 "facility_taxonomy" => trim(isset($_POST["facility_taxonomy"]) ? $_POST["facility_taxonomy"] : ''),
94 "facility_code" => trim(isset($_POST["facility_id"]) ? $_POST["facility_id"] : ''),
95 "mail_street" => trim(isset($_POST["mail_street"]) ? $_POST["mail_street"] : ''),
96 "mail_street2" => trim(isset($_POST["mail_street2"]) ? $_POST["mail_street2"] : ''),
97 "mail_city" => trim(isset($_POST["mail_city"]) ? $_POST["mail_city"] : ''),
98 "mail_state" => trim(isset($_POST["mail_state"]) ? $_POST["mail_state"] : ''),
99 "mail_zip" => trim(isset($_POST["mail_zip"]) ? $_POST["mail_zip"] : ''),
100 "oid" => trim(isset($_POST["oid"]) ? $_POST["oid"] : '')
103 $facilityService->update($newFacility);
105 // Update facility name for all users with this facility.
106 // This is necassary because some provider based code uses facility name for lookups instead of facility id.
108 $facilityService->updateUsersFacility($newFacility['name'], $newFacility['fid']);
109 exit(); // sjp 12/20/17 for ajax save
113 <!DOCTYPE html >
114 <html>
115 <head>
117 <title><?php echo xlt("Facilities") ; ?></title>
119 <?php Header::setupHeader(['common', 'jquery-ui']); ?>
121 <script type="text/javascript">
123 function refreshme() {
124 top.restoreSession();
125 document.location.reload();
127 $(function(){
129 $(".medium_modal").on('click', function(e) {
130 e.preventDefault();e.stopPropagation();
131 dlgopen('', '', 700, 590, '', '', {
132 allowResize: false,
133 allowDrag: true, // note these default to true if not defined here. left as example.
134 type: 'iframe',
135 url: $(this).attr('href')
139 $(".addfac_modal").on('click', function(e) {
140 e.preventDefault();e.stopPropagation();
141 dlgopen('', '', 700, 620, '', '', {
142 allowResize: false,
143 allowDrag: true,
144 type: 'iframe',
145 url: $(this).attr('href')
151 </script>
152 </head>
154 <body class="body_top">
156 <div class="container-fluid">
157 <div class="row">
158 <div class="col-xs-12">
159 <div class="page-header clearfix">
160 <h2 class="clearfix"><?php echo xlt("Facilities") ; ?></h2>
161 </div>
162 <a href="facilities_add.php" class="addfac_modal btn btn-default btn-add"><span><?php echo xlt('Add Facility');?></span></a>
163 </div>
164 </div>
165 <br>
166 <div class="row">
167 <div class="col-xs-12">
168 <div class="table-responsive">
169 <table class="table table-striped">
170 <thead>
171 <tr>
172 <th><?php echo xlt('Name'); ?></th>
173 <th><?php echo xlt('Billing Address'); ?></th>
174 <th><?php echo xlt('Mailing Address'); ?></th>
175 <th><?php echo xlt('Phone'); ?></th>
176 </tr>
177 </thead>
178 <tbody>
179 <?php
180 $fres = 0;
181 $fres = $facilityService->getAll();
182 if ($fres) {
183 $result2 = array();
184 for ($iter3 = 0; $iter3 < sizeof($fres); $iter3++) {
185 $result2[$iter3] = $fres[$iter3];
188 foreach ($result2 as $iter3) {
189 $varstreet="";//these are assigned conditionally below,blank assignment is done so that old values doesn't get propagated to next level.
190 $varcity="";
191 $varstate="";
192 $varmstreet="";
193 $varmcity="";
194 $varmstate="";
195 $varstreet=$iter3["street"];
196 if ($iter3["street"]!="") {
197 $varstreet=$iter3["street"].",";
200 if ($iter3["city"]!="") {
201 $varcity=$iter3["city"].",";
204 if ($iter3["state"]!="") {
205 $varstate=$iter3["state"].",";
208 $varmstreet=$iter3["mail_street"];
209 if ($iter3["mail_street"] !="") {
210 $varmstreet=$iter3["mail_street"].",";
213 if ($iter3["mail_city"]!="") {
214 $varmcity=$iter3["mail_city"].",";
217 if ($iter3["mail_state"]!="") {
218 $varmstate=$iter3["mail_state"].",";
221 <tr height="22">
222 <td valign="top" class="text"><b><a href="facility_admin.php?fid=<?php echo attr_url($iter3["id"]); ?>" class="medium_modal"><span><?php echo xlt($iter3["name"]);?></span></a></b>&nbsp;</td>
223 <td valign="top" class="text"><?php echo text($varstreet.$varcity.$varstate.$iter3["country_code"]." ".$iter3["postal_code"]); ?>&nbsp;</td>
224 <td valign="top" class="text"><?php echo text($varmstreet.$varmcity.$varmstate.$iter3['mail_zip']); ?></td>
225 <td><?php echo text($iter3["phone"]);?>&nbsp;</td>
226 </tr>
227 <?php
231 if (count($result2)<=0) {?>
232 <tr height="25">
233 <td colspan="3" style="text-align:center;font-weight:bold;"> <?php echo xlt("Currently there are no facilities."); ?></td>
234 </tr>
235 <?php
236 } ?>
237 </tbody>
238 </table>
239 </div>
240 </div>
241 </div>
242 </div><!-- end of div container -->
243 <script language="JavaScript">
244 <?php
245 if ($alertmsg = trim($alertmsg)) {
246 echo "alert(" . js_escape($alertmsg) . ");\n";
249 </script>
251 </body>
252 </html>