Fully responsive globals.php with vertical menu (#2460)
[openemr.git] / interface / usergroup / facility_admin.php
blob4b1d9ca2a3f675fca748e0ec8e6f702c546f3422
1 <?php
2 /**
3 * facility_admin.php
5 * @package OpenEMR
6 * @link http://www.open-emr.org
7 * @author Brady Miller <brady.g.miller@gmail.com>
8 * @copyright Copyright (c) 2018 Brady Miller <brady.g.miller@gmail.com>
9 * @license https://github.com/openemr/openemr/blob/master/LICENSE GNU General Public License 3
13 require_once("../globals.php");
14 require_once("$srcdir/options.inc.php");
15 require_once("$srcdir/erx_javascript.inc.php");
17 use OpenEMR\Core\Header;
18 use OpenEMR\Services\FacilityService;
20 $facilityService = new FacilityService();
22 if (isset($_GET["fid"])) {
23 $my_fid = $_GET["fid"];
26 <html>
27 <head>
28 <?php Header::setupHeader(['opener', 'jquery-ui']); ?>
30 <script type="text/javascript" src="../main/calendar/modules/PostCalendar/pnincludes/AnchorPosition.js"></script>
31 <script type="text/javascript" src="../main/calendar/modules/PostCalendar/pnincludes/PopupWindow.js"></script>
32 <script type="text/javascript" src="../main/calendar/modules/PostCalendar/pnincludes/ColorPicker2.js"></script>
34 <!-- validation library -->
35 <!--//Not lbf forms use the new validation, please make sure you have the corresponding values in the list Page validation-->
36 <?php $use_validate_js = 1;?>
37 <?php require_once($GLOBALS['srcdir'] . "/validation/validation_script.js.php"); ?>
38 <?php
39 //Gets validation rules from Page Validation list.
40 //Note that for technical reasons, we are bypassing the standard validateUsingPageRules() call.
41 $collectthis = collectValidationPageRules("/interface/usergroup/facility_admin.php");
42 if (empty($collectthis)) {
43 $collectthis = "undefined";
44 } else {
45 $collectthis = json_sanitize($collectthis["facility-form"]["rules"]);
49 <script type="text/javascript">
52 * validation on the form with new client side validation (using validate.js).
53 * this enable to add new rules for this form in the pageValidation list.
54 * */
55 var collectvalidation = <?php echo $collectthis; ?>;
57 function submitform() {
59 var valid = submitme(1, undefined, 'facility-form', collectvalidation);
60 if (!valid) return;
62 <?php if ($GLOBALS['erx_enable']) { ?>
63 alertMsg = '';
64 f = document.forms[0];
65 for (i = 0; i < f.length; i++) {
66 if (f[i].type == 'text' && f[i].value) {
67 if (f[i].name == 'facility' || f[i].name == 'Washington') {
68 alertMsg += checkLength(f[i].name, f[i].value, 35);
69 alertMsg += checkFacilityName(f[i].name, f[i].value);
71 else if (f[i].name == 'street') {
72 alertMsg += checkLength(f[i].name, f[i].value, 35);
73 alertMsg += checkAlphaNumeric(f[i].name, f[i].value);
75 else if (f[i].name == 'phone' || f[i].name == 'fax') {
76 alertMsg += checkPhone(f[i].name, f[i].value);
78 else if (f[i].name == 'federal_ein') {
79 alertMsg += checkLength(f[i].name, f[i].value, 10);
80 alertMsg += checkFederalEin(f[i].name, f[i].value);
84 if (alertMsg) {
85 alert(alertMsg);
86 return false;
88 <?php } ?>
90 top.restoreSession();
92 let post_url = $("#facility-form").attr("action");
93 let request_method = $("#facility-form").attr("method");
94 let form_data = $("#facility-form").serialize();
96 $.ajax({
97 url: post_url,
98 type: request_method,
99 data: form_data
100 }).done(function (r) { //
101 dlgclose('refreshme', false);
103 return false;
106 $(function(){
107 $("#cancel").click(function() {
108 dlgclose();
112 * add required/star sign to required form fields
114 for (var prop in collectvalidation) {
115 //if (collectvalidation[prop].requiredSign)
116 if (collectvalidation[prop].presence)
117 jQuery("input[name='" + prop + "']").after('*');
120 var cp = new ColorPicker('window');
121 // Runs when a color is clicked
122 function pickColor(color) {
123 document.getElementById('ncolor').value = color;
125 var field;
126 function pick(anchorname,target) {
127 var cp = new ColorPicker('window');
128 field=target;
129 cp.show(anchorname);
131 function displayAlert()
133 if(document.getElementById('primary_business_entity').checked==false)
134 alert(<?php echo xlj('Primary Business Entity tax id is used as the account id for NewCrop ePrescription.'); ?>);
135 else if(document.getElementById('primary_business_entity').checked==true)
136 alert(<?php echo xlj('Once the Primary Business Facility is set, changing the facility id will affect NewCrop ePrescription.'); ?>);
138 </script>
140 </head>
141 <body class="body_top" style="width:600px;height:330px !important;">
143 <table>
144 <tr>
145 <td>
146 <span class="title"><?php echo xlt('Edit Facility'); ?></span>&nbsp;&nbsp;&nbsp;</td><td>
147 <a class="css_button large_button" name='form_save' id='form_save' onclick='submitform()' href='#' >
148 <span class='css_button_span large_button_span'><?php echo xlt('Save');?></span>
149 </a>
150 <a class="css_button large_button" id='cancel' href='#'>
151 <span class='css_button_span large_button_span'><?php echo xlt('Cancel');?></span>
152 </a>
153 </td>
154 </tr>
155 </table>
157 <form name='facility-form' id="facility-form" method='post' action="facilities.php">
158 <input type="hidden" name="csrf_token_form" value="<?php echo attr(collectCsrfToken()); ?>" />
159 <input type=hidden name=mode value="facility">
160 <input type=hidden name=newmode value="admin_facility"> <!-- Diffrentiate Admin and add post backs -->
161 <input type=hidden name=fid value="<?php echo attr($my_fid); ?>">
162 <?php $facility = $facilityService->getById($my_fid); ?>
164 <table border=0 cellpadding=0 cellspacing=1 style="width:630px;">
165 <tr>
166 <td width='150px'><span class='text'><?php echo xlt('Name'); ?>: </span></td>
167 <td width='220px'><input type='entry' name='facility' size='20' value='<?php echo attr($facility['name']); ?>'></td>
168 <td width='200px'><span class='text'><?php echo xlt('Phone'); ?> <?php echo xlt('as'); ?> (000) 000-0000:</span></td>
169 <td width='220px'><input type='entry' name='phone' size='20' value='<?php echo attr($facility['phone']); ?>'></td>
170 </tr>
171 <tr>
172 <td><span class=text><?php echo xlt('Address'); ?>: </span></td><td><input type=entry size=20 name="street" value="<?php echo attr($facility["street"]); ?>"></td>
173 <td><span class='text'><?php echo xlt('Fax'); ?> <?php echo xlt('as'); ?> (000) 000-0000:</span></td>
174 <td><input type='entry' name="fax" size='20' value='<?php echo attr($facility['fax']); ?>'></td>
175 </tr>
176 <tr>
178 <td><span class=text><?php echo xlt('City'); ?>: </span></td>
179 <td><input type=entry size=20 name=city value="<?php echo attr($facility["city"]); ?>"></td>
180 <td><span class=text><?php echo xlt('Zip Code'); ?>: </span></td><td><input type=entry size=20 name=postal_code value="<?php echo attr($facility["postal_code"]); ?>"></td>
181 </tr>
182 <?php
183 $ssn='';
184 $ein='';
185 if ($facility['tax_id_type']=='SY') {
186 $ssn='selected';
187 } else {
188 $ein='selected';
191 <tr>
192 <td><span class=text><?php echo xlt('State'); ?>: </span></td><td><input type=entry size=20 name=state value="<?php echo attr($facility["state"]); ?>"></td>
193 <td><span class=text><?php echo xlt('Tax ID'); ?>: </span></td><td><select name=tax_id_type><option value="EI" <?php echo $ein;?>><?php echo xlt('EIN'); ?></option><option value="SY" <?php echo $ssn;?>><?php echo xlt('SSN'); ?></option></select><input type=entry size=11 name=federal_ein value="<?php echo attr($facility["federal_ein"]); ?>"></td>
194 </tr>
195 <tr>
196 <td><span class=text><?php echo xlt('Country'); ?>: </span></td><td><input type=entry size=20 name=country_code value="<?php echo attr($facility["country_code"]); ?>"></td>
197 <td width="21"><span class=text><?php echo ($GLOBALS['simplified_demographics'] ? xlt('Facility Code') : xlt('Facility NPI')); ?>:
198 </span></td><td><input type=entry size=20 name=facility_npi value="<?php echo attr($facility["facility_npi"]); ?>"></td>
199 </tr>
200 <tr>
201 <td>&nbsp;</td><td>&nbsp;</td><td><span class=text><?php echo xlt('Facility Taxonomy'); ?>:</span></td>
202 <td><input type=entry size=20 name=facility_taxonomy value="<?php echo attr($facility["facility_taxonomy"]); ?>"></td>
203 </tr>
206 <tr>
207 <td><span class=text><?php echo xlt('Website'); ?>: </span></td><td><input type=entry size=20 name=website value="<?php echo attr($facility["website"]); ?>"></td>
208 <td><span class=text><?php echo xlt('Email'); ?>: </span></td><td><input type=entry size=20 name=email value="<?php echo attr($facility["email"]); ?>"></td>
209 </tr>
211 <tr>
212 <td><span class='text'><?php echo xlt('Billing Location'); ?>: </span></td>
213 <td><input type='checkbox' name='billing_location' value='1' <?php echo ($facility['billing_location'] != 0) ? 'checked' : ''; ?>></td>
214 <td rowspan='2'><span class='text'><?php echo xlt('Accepts Assignment'); ?><br>(<?php echo xlt('only if billing location'); ?>): </span></td>
215 <td><input type='checkbox' name='accepts_assignment' value='1' <?php echo ($facility['accepts_assignment'] == 1) ? 'checked' : ''; ?>></td>
216 </tr>
217 <tr>
218 <td><span class='text'><?php echo xlt('Service Location'); ?>: </span></td>
219 <td><input type='checkbox' name='service_location' value='1' <?php echo ($facility['service_location'] == 1) ? 'checked' : ''; ?>></td>
220 <td>&nbsp;</td>
221 </tr>
222 <?php
223 $disabled='';
224 $resPBE = $facilityService->getPrimaryBusinessEntity(array("excludedId" => $my_fid));
225 if ($resPBE) {
226 $disabled='disabled';
229 <tr>
230 <td><span class='text'><?php echo xlt('Primary Business Entity'); ?>: </span></td>
231 <td><input type='checkbox' name='primary_business_entity' id='primary_business_entity' value='1' <?php echo ($facility['primary_business_entity'] == 1) ? 'checked' : ''; ?>
232 <?php if ($GLOBALS['erx_enable']) { ?>
233 onchange='return displayAlert()'
234 <?php } ?> <?php echo $disabled;?>></td>
235 <td>&nbsp;</td>
236 </tr>
237 <tr>
238 <td><span class='text'><?php echo xlt('Color'); ?>: </span></td> <td><input type=entry name=ncolor id=ncolor size=20 value="<?php echo attr($facility["color"]); ?>"></td>
239 <td>[<a href="javascript:void(0);" onClick="pick('pick','newcolor');return false;" NAME="pick" ID="pick"><?php echo xlt('Pick'); ?></a>]</td><td>&nbsp;</td>
241 <tr>
242 <td><span class=text><?php echo xlt('POS Code'); ?>: </span></td>
243 <td colspan="6">
244 <select name="pos_code">
245 <?php
246 $pc = new POSRef();
248 foreach ($pc->get_pos_ref() as $pos) {
249 echo "<option value=\"" . attr($pos["code"]) . "\" ";
250 if ($facility['pos_code'] == $pos['code']) {
251 echo "selected";
254 echo ">" . text($pos['code']) . ": ". text($pos['title']);
255 echo "</option>\n";
259 </select>
260 </td>
261 </tr>
262 <tr>
263 <td><span class="text"><?php echo xlt('Billing Attn'); ?>:</span></td>
264 <td colspan="4"><input type="entry" name="attn" size="45" value="<?php echo attr($facility['attn']); ?>"></td>
265 </tr>
266 <tr>
267 <td><span class="text"><?php echo xlt('CLIA Number'); ?>:</span></td>
268 <td colspan="4"><input type="entry" name="domain_identifier" size="45" value="<?php echo attr($facility['domain_identifier']); ?>"></td>
269 </tr>
270 <tr>
271 <td><span class="text"><?php echo xlt('Facility ID'); ?>:</span></td>
272 <td colspan="4"><input type="entry" name="facility_id" size="45" value="<?php echo attr($facility['facility_code']); ?>"></td>
273 </tr>
274 <tr>
275 <td>
276 <span class="text"><?php echo xlt('OID'); ?>: </span>
277 </td>
278 <td>
279 <input type="entry" size="20" name="oid" value="<?php echo attr($facility["oid"]) ?>">
280 </td>
281 </tr>
282 <tr>
283 <td>
284 <hr>
285 </td>
286 </tr>
287 <tr>
288 <td>
289 <label><?php echo xlt('Mailing Address'); ?>: </label>
290 </td>
291 <td>
292 <input type="entry" size="20" name="mail_street" value="<?php echo attr($facility["mail_street"]) ?>">
293 </td>
294 </tr>
296 <tr>
297 <td>
298 <label><?php echo xlt('Suite'); ?>: </label>
299 </td>
300 <td>
301 <input type="entry" size="20" name="mail_street2" value="<?php echo attr($facility["mail_street2"]) ?>">
302 </td>
303 </tr>
305 <tr>
306 <td>
307 <label><?php echo xlt('City'); ?>: </label>
308 </td>
309 <td>
310 <input type="entry" size="20" name="mail_city" value="<?php echo attr($facility["mail_city"]) ?>">
311 </td>
312 </tr>
313 <tr>
314 <td>
315 <label><?php echo xlt('State'); ?>: </label>
316 </td>
317 <td>
318 <input type="entry" size="20" name="mail_state" value="<?php echo attr($facility["mail_state"]) ?>">
319 </td>
320 </tr>
321 <tr>
322 <td>
323 <label><?php echo xlt('Zip'); ?>: </label>
324 </td>
325 <td>
326 <input type="entry" size="20" name="mail_zip" value="<?php echo attr($facility["mail_zip"]) ?>">
327 </td>
328 </tr>
329 <tr height="20" valign="bottom">
330 <td colspan=2><span class="text"><font class="mandatory">*</font> <?php echo xlt('Required'); ?></span></td>
331 </tr>
332 </table>
333 </form>
335 </body>
336 </html>