Fully responsive globals.php with vertical menu (#2460)
[openemr.git] / interface / usergroup / facilities_add.php
blobee0c4fff5951d8bbfc3fda6b11364eff68abcb85
1 <?php
2 /**
3 * facilities_add.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("../../library/acl.inc");
15 require_once("$srcdir/options.inc.php");
16 require_once("$srcdir/erx_javascript.inc.php");
18 use OpenEMR\Core\Header;
19 use OpenEMR\Services\FacilityService;
21 $facilityService = new FacilityService();
23 $alertmsg = '';
25 <html>
26 <head>
27 <?php Header::setupHeader(['opener', 'jquery-ui']); ?>
28 <script type="text/javascript" src="../main/calendar/modules/PostCalendar/pnincludes/AnchorPosition.js"></script>
29 <script type="text/javascript" src="../main/calendar/modules/PostCalendar/pnincludes/PopupWindow.js"></script>
30 <script type="text/javascript" src="../main/calendar/modules/PostCalendar/pnincludes/ColorPicker2.js"></script>
32 <!-- validation library -->
33 <!--//Not lbf forms use the new validation, please make sure you have the corresponding values in the list Page validation-->
34 <?php $use_validate_js = 1;?>
35 <?php require_once($GLOBALS['srcdir'] . "/validation/validation_script.js.php"); ?>
36 <?php
37 //Gets validation rules from Page Validation list.
38 //Note that for technical reasons, we are bypassing the standard validateUsingPageRules() call.
39 $collectthis = collectValidationPageRules("/interface/usergroup/facilities_add.php");
40 if (empty($collectthis)) {
41 $collectthis = "undefined";
42 } else {
43 $collectthis = json_sanitize($collectthis["facility-add"]["rules"]);
46 // Old Browser comp trigger on js
48 if (isset($_POST["mode"]) && $_POST["mode"] == "facility") {
49 echo '
50 <script type="text/javascript">
51 <!--
52 dlgclose();
53 //-->
54 </script>
59 <script type="text/javascript">
60 /// todo, move this to a common library
62 var collectvalidation = <?php echo $collectthis; ?>;
64 function submitform() {
66 var valid = submitme(1, undefined, 'facility-add', collectvalidation);
67 if (!valid) return;
69 <?php if ($GLOBALS['erx_enable']) { ?>
70 alertMsg='';
71 f=document.forms[0];
72 for(i=0;i<f.length;i++){
73 if(f[i].type=='text' && f[i].value)
75 if(f[i].name == 'facility' || f[i].name == 'Washington')
77 alertMsg += checkLength(f[i].name,f[i].value,35);
78 alertMsg += checkFacilityName(f[i].name,f[i].value);
80 else if(f[i].name == 'street')
82 alertMsg += checkLength(f[i].name,f[i].value,35);
83 alertMsg += checkAlphaNumeric(f[i].name,f[i].value);
85 else if(f[i].name == 'phone' || f[i].name == 'fax')
87 alertMsg += checkPhone(f[i].name,f[i].value);
89 else if(f[i].name == 'federal_ein')
91 alertMsg += checkLength(f[i].name,f[i].value,10);
92 alertMsg += checkFederalEin(f[i].name,f[i].value);
96 if(alertMsg)
98 alert(alertMsg);
99 return false;
101 <?php } ?>
103 top.restoreSession();
105 let post_url = $("#facility-add").attr("action");
106 let request_method = $("#facility-add").attr("method");
107 let form_data = $("#facility-add").serialize();
109 $.ajax({
110 url: post_url,
111 type: request_method,
112 data: form_data
113 }).done(function (r) { //
114 dlgclose('refreshme', false);
116 return false;
119 function toggle( target, div ) {
121 $mode = $(target).find(".indicator").text();
122 if ( $mode == "collapse" ) {
123 $(target).find(".indicator").text( "expand" );
124 $(div).hide();
125 } else {
126 $(target).find(".indicator").text( "collapse" );
127 $(div).show();
132 $(function(){
134 $("#dem_view").click( function() {
135 toggle( $(this), "#DEM" );
140 $(function(){
141 $("#cancel").click(function() {
142 dlgclose();
146 * add required/star sign to required form fields
148 for (var prop in collectvalidation) {
149 //if (collectvalidation[prop].requiredSign)
150 if (collectvalidation[prop].presence)
151 jQuery("input[name='" + prop + "']").after('*');
154 var cp = new ColorPicker('window');
155 // Runs when a color is clicked
156 function pickColor(color) {
157 document.getElementById('ncolor').value = color;
159 var field;
160 function pick(anchorname,target) {
161 var cp = new ColorPicker('window');
162 field=target;
163 cp.show(anchorname);
165 function displayAlert()
167 if(document.getElementById('primary_business_entity').checked==false)
168 alert(<?php echo xlj('Primary Business Entity tax id is used as account id for NewCrop ePrescription. Changing the facility will affect the working in NewCrop.'); ?>);
169 else if(document.getElementById('primary_business_entity').checked==true)
170 alert(<?php echo xlj('Once the Primary Business Facility is set, it should not be changed. Changing the facility will affect the working in NewCrop ePrescription.'); ?>);
172 </script>
173 <link rel="stylesheet" href="<?php echo $css_header;?>" type="text/css">
175 </head>
176 <body class="body_top">
177 <table>
178 <tr><td>
179 <span class="title"><?php echo xlt('Add Facility'); ?></span>&nbsp;&nbsp;&nbsp;</td>
180 <td colspan=5 align=center style="padding-left:2px;">
181 <a onclick="submitform();" class="css_button large_button" name='form_save' id='form_save' href='#'>
182 <span class='css_button_span large_button_span'><?php echo xlt('Save'); ?></span>
183 </a>
184 <a class="css_button large_button" id='cancel' href='#' >
185 <span class='css_button_span large_button_span'><?php echo xlt('Cancel'); ?></span>
186 </a>
187 </td></tr>
188 </table>
190 <br>
192 <form name='facility-add' id='facility-add' method='post' action="facilities.php">
193 <input type="hidden" name="csrf_token_form" value="<?php echo attr(collectCsrfToken()); ?>" />
194 <input type=hidden name=mode value="facility">
195 <table border=0 cellpadding=0 cellspacing=0>
196 <tr>
197 <td><span class="text"><?php echo xlt('Name'); ?>: </span></td><td><input type=entry name=facility size=20 value=""></td>
198 <td width=20>&nbsp;</td>
199 <td><span class="text"><?php echo xlt('Phone'); ?>: </span></td><td><input type=entry name=phone size=20 value=""></td>
200 </tr>
201 <tr>
202 <td><span class="text"><?php echo xlt('Address'); ?>: </span></td><td><input type=entry size=20 name=street value=""></td>
203 <td>&nbsp;</td>
204 <td><span class="text"><?php echo xlt('Fax'); ?>: </span></td><td><input type=entry name=fax size=20 value=""></td>
205 </tr>
206 <tr>
207 <td><span class="text"><?php echo xlt('City'); ?>: </span></td><td><input type=entry size=20 name=city value=""></td>
208 <td>&nbsp;</td>
209 <td><span class="text"><?php echo xlt('Zip Code'); ?>: </span></td><td><input type=entry size=20 name=postal_code value=""></td>
210 </tr>
211 <tr>
212 <td><span class="text"><?php echo xlt('State'); ?>: </span></td><td><input type=entry size=20 name=state value=""></td>
213 <td>&nbsp;</td>
214 <td><span class="text"><?php echo xlt('Tax ID'); ?>: </span></td><td><select name=tax_id_type><option value="EI"><?php echo xlt('EIN'); ?></option><option value="SY"><?php echo xlt('SSN'); ?></option></select><input type=entry size=11 name=federal_ein value=""></td>
215 </tr>
216 <tr>
217 <td height="22"><span class="text"><?php echo xlt('Country'); ?>: </span></td><td><input type=entry size=20 name=country_code value=""></td>
218 <td>&nbsp;</td>
219 <td><span class="text"><?php echo ($GLOBALS['simplified_demographics'] ? xlt('Facility Code') : xlt('Facility NPI')); ?>:
220 </span></td><td><input type=entry size=20 name=facility_npi value=""></td>
221 </tr>
222 <tr>
223 <td>&nbsp;</td><td>&nbsp;</td><td width="20"></td><td><span class=text><?php echo xlt('Facility Taxonomy'); ?>:</span></td>
224 <td><input type=entry size=20 name=facility_taxonomy value=""></td>
225 </tr>
226 <tr>
227 <td><span class="text"><?php echo xlt('Website'); ?>: </span></td><td><input type=entry size=20 name=website value=""></td>
228 <td>&nbsp;</td>
229 <td><span class="text"><?php echo xlt('Email'); ?>: </span></td><td><input type=entry size=20 name=email value=""></td>
230 </tr>
232 <tr>
233 <td><span class='text'><?php echo xlt('Billing Location'); ?>: </span></td><td><input type='checkbox' name='billing_location' value = '1'></td>
234 <td>&nbsp;</td>
235 <td><span class='text'><?php echo xlt('Accepts Assignment'); ?><br>(<?php echo xlt('only if billing location'); ?>): </span></td> <td><input type='checkbox' name='accepts_assignment' value = '1'></td>
236 </tr>
237 <tr>
238 <td><span class='text'><?php echo xlt('Service Location'); ?>: </span></td> <td><input type='checkbox' name='service_location' value = '1'></td>
239 <td>&nbsp;</td>
240 <td><span class='text'><?php echo xlt('Color'); ?>: </span></td> <td><input type=entry name=ncolor id=ncolor size=20 value=""><span>[<a href="javascript:void(0);" onClick="pick('pick','newcolor');return false;" NAME="pick" ID="pick"><?php echo xlt('Pick'); ?></a>]</span></td>
241 </tr>
242 <?php
243 $disabled='';
244 $resPBE = $facilityService->getPrimaryBusinessEntity(array("excludedId" => $my_fid));
245 if (!empty($resPBE) && sizeof($resPBE)>0) {
246 $disabled='disabled';
249 <tr>
250 <td><span class='text'><?php echo xlt('Primary Business Entity'); ?>: </span></td>
251 <td><input type='checkbox' name='primary_business_entity' id='primary_business_entity' value='1' <?php echo ($facility['primary_business_entity'] == 1) ? 'checked' : ''; ?>
252 <?php if ($GLOBALS['erx_enable']) { ?>
253 onchange='return displayAlert()'
254 <?php } ?> <?php echo $disabled;?>></td>
255 <td>&nbsp;</td>
256 </tr>
257 <tr>
258 <td><span class=text><?php echo xlt('POS Code'); ?>: </span></td>
259 <td colspan="6">
260 <select name="pos_code">
261 <?php
262 $pc = new POSRef();
264 foreach ($pc->get_pos_ref() as $pos) {
265 echo "<option value=\"" . attr($pos["code"]) . "\" ";
266 echo ">" . text($pos['code']) . ": ". text($pos['title']);
267 echo "</option>\n";
271 </select>
272 </td>
273 </tr>
274 <tr>
275 <td><span class="text"><?php echo xlt('Billing Attn'); ?>:</span></td>
276 <td colspan="4"><input type="entry" name="attn" size="45"></td>
277 </tr>
278 <tr>
279 <td><span class="text"><?php echo xlt('CLIA Number'); ?>:</span></td>
280 <td colspan="4"><input type="entry" name="domain_identifier" size="45"></td>
281 </tr>
282 <tr>
283 <td><span class="text"><?php echo xlt('Facility ID'); ?>:</span></td>
284 <td colspan="4"><input type="entry" name="facility_id" size="20"></td>
285 </tr>
286 <tr>
287 <td>
288 <span class="text"><?php echo xlt('OID'); ?>: </span>
289 </td>
290 <td>
291 <input type="entry" size="20" name="oid" value="<?php echo attr($facility["oid"]) ?>">
292 </td>
293 </tr>
294 <tr>
295 <td>
296 <hr>
297 </td>
298 </tr>
299 <tr>
300 <td>
301 <label><?php echo xlt('Mailing Address'); ?>: </label>
302 </td>
303 <td>
304 <input type="entry" size="20" name="mail_street" value="<?php echo attr($facility["mail_street"]) ?>">
305 </td>
306 </tr>
308 <tr>
309 <td>
310 <label><?php echo xlt('Dept'); ?>: </label>
311 </td>
312 <td>
313 <input type="entry" size="20" name="mail_street2" value="<?php echo attr($facility["mail_street2"]) ?>">
314 </td>
315 </tr>
317 <tr>
318 <td>
319 <label><?php echo xlt('City'); ?>: </label>
320 </td>
321 <td>
322 <input type="entry" size="20" name="mail_city" value="<?php echo attr($facility["mail_city"]) ?>">
323 </td>
324 </tr>
325 <tr>
326 <td>
327 <label><?php echo xlt('State'); ?>: </label>
328 </td>
329 <td>
330 <input type="entry" size="20" name="mail_state" value="<?php echo attr($facility["mail_state"]) ?>">
331 </td>
332 </tr>
333 <tr>
334 <td>
335 <label><?php echo xlt('Zip'); ?>: </label>
336 </td>
337 <td>
338 <input type="entry" size="20" name="mail_zip" value="<?php echo attr($facility["mail_zip"]) ?>">
339 </td>
340 </tr>
341 <tr height="25" style="valign:bottom;">
342 <td><font class="mandatory">*</font><span class="text"> <?php echo xlt('Required'); ?></span></td><td>&nbsp;</td><td>&nbsp;</td>
343 <td>&nbsp;</td><td>&nbsp;</td>
344 </tr>
345 </table>
346 </form>
348 <script language="JavaScript">
349 <?php
350 if ($alertmsg = trim($alertmsg)) {
351 echo "alert(" . js_escape($alertmsg) . ");\n";
354 </script>
356 </body>
357 </html>