change viewer calling paths (#1410)
[openemr.git] / interface / usergroup / facilities_add.php
blobf0af56459812181852664c5a6aab0948287b89ea
1 <?php
2 require_once("../globals.php");
3 require_once("../../library/acl.inc");
4 require_once("$srcdir/options.inc.php");
5 require_once("$srcdir/erx_javascript.inc.php");
7 use OpenEMR\Core\Header;
8 use OpenEMR\Services\FacilityService;
10 $facilityService = new FacilityService();
12 $alertmsg = '';
14 <html>
15 <head>
16 <?php Header::setupHeader(['opener', 'jquery-ui']); ?>
17 <script type="text/javascript" src="../main/calendar/modules/PostCalendar/pnincludes/AnchorPosition.js"></script>
18 <script type="text/javascript" src="../main/calendar/modules/PostCalendar/pnincludes/PopupWindow.js"></script>
19 <script type="text/javascript" src="../main/calendar/modules/PostCalendar/pnincludes/ColorPicker2.js"></script>
21 <!-- validation library -->
22 <!--//Not lbf forms use the new validation, please make sure you have the corresponding values in the list Page validation-->
23 <?php $use_validate_js = 1;?>
24 <?php require_once($GLOBALS['srcdir'] . "/validation/validation_script.js.php"); ?>
25 <?php
26 //Gets validation rules from Page Validation list.
27 //Note that for technical reasons, we are bypassing the standard validateUsingPageRules() call.
28 $collectthis = collectValidationPageRules("/interface/usergroup/facilities_add.php");
29 if (empty($collectthis)) {
30 $collectthis = "undefined";
31 } else {
32 $collectthis = $collectthis["facility-add"]["rules"];
35 // Old Browser comp trigger on js
37 if (isset($_POST["mode"]) && $_POST["mode"] == "facility") {
38 echo '
39 <script type="text/javascript">
40 <!--
41 dlgclose();
42 //-->
43 </script>
48 <script type="text/javascript">
49 /// todo, move this to a common library
51 var collectvalidation = <?php echo($collectthis); ?>;
53 function submitform() {
55 var valid = submitme(1, undefined, 'facility-add', collectvalidation);
56 if (!valid) return;
58 <?php if ($GLOBALS['erx_enable']) { ?>
59 alertMsg='';
60 f=document.forms[0];
61 for(i=0;i<f.length;i++){
62 if(f[i].type=='text' && f[i].value)
64 if(f[i].name == 'facility' || f[i].name == 'Washington')
66 alertMsg += checkLength(f[i].name,f[i].value,35);
67 alertMsg += checkFacilityName(f[i].name,f[i].value);
69 else if(f[i].name == 'street')
71 alertMsg += checkLength(f[i].name,f[i].value,35);
72 alertMsg += checkAlphaNumeric(f[i].name,f[i].value);
74 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')
80 alertMsg += checkLength(f[i].name,f[i].value,10);
81 alertMsg += checkFederalEin(f[i].name,f[i].value);
85 if(alertMsg)
87 alert(alertMsg);
88 return false;
90 <?php } ?>
92 top.restoreSession();
94 let post_url = $("#facility-add").attr("action");
95 let request_method = $("#facility-add").attr("method");
96 let form_data = $("#facility-add").serialize();
98 $.ajax({
99 url: post_url,
100 type: request_method,
101 data: form_data
102 }).done(function (r) { //
103 dlgclose('refreshme', false);
105 return false;
108 function toggle( target, div ) {
110 $mode = $(target).find(".indicator").text();
111 if ( $mode == "collapse" ) {
112 $(target).find(".indicator").text( "expand" );
113 $(div).hide();
114 } else {
115 $(target).find(".indicator").text( "collapse" );
116 $(div).show();
121 $(document).ready(function(){
123 $("#dem_view").click( function() {
124 toggle( $(this), "#DEM" );
129 $(document).ready(function(){
130 $("#cancel").click(function() {
131 dlgclose();
135 * add required/star sign to required form fields
137 for (var prop in collectvalidation) {
138 //if (collectvalidation[prop].requiredSign)
139 if (collectvalidation[prop].presence)
140 jQuery("input[name='" + prop + "']").after('*');
143 var cp = new ColorPicker('window');
144 // Runs when a color is clicked
145 function pickColor(color) {
146 document.getElementById('ncolor').value = color;
148 var field;
149 function pick(anchorname,target) {
150 var cp = new ColorPicker('window');
151 field=target;
152 cp.show(anchorname);
154 function displayAlert()
156 if(document.getElementById('primary_business_entity').checked==false)
157 alert("<?php echo addslashes(xl('Primary Business Entity tax id is used as account id for NewCrop ePrescription. Changing the facility will affect the working in NewCrop.'));?>");
158 else if(document.getElementById('primary_business_entity').checked==true)
159 alert("<?php echo addslashes(xl('Once the Primary Business Facility is set, it should not be changed. Changing the facility will affect the working in NewCrop ePrescription.'));?>");
161 </script>
162 <link rel="stylesheet" href="<?php echo $css_header;?>" type="text/css">
164 </head>
165 <body class="body_top">
166 <table>
167 <tr><td>
168 <span class="title"><?php xl('Add Facility', 'e'); ?></span>&nbsp;&nbsp;&nbsp;</td>
169 <td colspan=5 align=center style="padding-left:2px;">
170 <a onclick="submitform();" class="css_button large_button" name='form_save' id='form_save' href='#'>
171 <span class='css_button_span large_button_span'><?php xl('Save', 'e');?></span>
172 </a>
173 <a class="css_button large_button" id='cancel' href='#' >
174 <span class='css_button_span large_button_span'><?php xl('Cancel', 'e');?></span>
175 </a>
176 </td></tr>
177 </table>
179 <br>
181 <form name='facility-add' id='facility-add' method='post' action="facilities.php">
182 <input type=hidden name=mode value="facility">
183 <table border=0 cellpadding=0 cellspacing=0>
184 <tr>
185 <td><span class="text"><?php xl('Name', 'e'); ?>: </span></td><td><input type=entry name=facility size=20 value=""></td>
186 <td width=20>&nbsp;</td>
187 <td><span class="text"><?php xl('Phone', 'e'); ?>: </span></td><td><input type=entry name=phone size=20 value=""></td>
188 </tr>
189 <tr>
190 <td><span class="text"><?php xl('Address', 'e'); ?>: </span></td><td><input type=entry size=20 name=street value=""></td>
191 <td>&nbsp;</td>
192 <td><span class="text"><?php xl('Fax', 'e'); ?>: </span></td><td><input type=entry name=fax size=20 value=""></td>
193 </tr>
194 <tr>
195 <td><span class="text"><?php xl('City', 'e'); ?>: </span></td><td><input type=entry size=20 name=city value=""></td>
196 <td>&nbsp;</td>
197 <td><span class="text"><?php xl('Zip Code', 'e'); ?>: </span></td><td><input type=entry size=20 name=postal_code value=""></td>
198 </tr>
199 <tr>
200 <td><span class="text"><?php xl('State', 'e'); ?>: </span></td><td><input type=entry size=20 name=state value=""></td>
201 <td>&nbsp;</td>
202 <td><span class="text"><?php xl('Tax ID', 'e'); ?>: </span></td><td><select name=tax_id_type><option value="EI"><?php xl('EIN', 'e'); ?></option><option value="SY"><?php xl('SSN', 'e'); ?></option></select><input type=entry size=11 name=federal_ein value=""></td>
203 </tr>
204 <tr>
205 <td height="22"><span class="text"><?php xl('Country', 'e'); ?>: </span></td><td><input type=entry size=20 name=country_code value=""></td>
206 <td>&nbsp;</td>
207 <td><span class="text"><?php ($GLOBALS['simplified_demographics'] ? xl('Facility Code', 'e') : xl('Facility NPI', 'e')); ?>:
208 </span></td><td><input type=entry size=20 name=facility_npi value=""></td>
209 </tr>
210 <tr>
211 <td>&nbsp;</td><td>&nbsp;</td><td width="20"></td><td><span class=text><?php (xl('Facility Taxonomy', 'e')); ?>:</span></td>
212 <td><input type=entry size=20 name=facility_taxonomy value=""></td>
213 </tr>
214 <tr>
215 <td><span class="text"><?php xl('Website', 'e'); ?>: </span></td><td><input type=entry size=20 name=website value=""></td>
216 <td>&nbsp;</td>
217 <td><span class="text"><?php xl('Email', 'e'); ?>: </span></td><td><input type=entry size=20 name=email value=""></td>
218 </tr>
220 <tr>
221 <td><span class='text'><?php xl('Billing Location', 'e'); ?>: </span></td><td><input type='checkbox' name='billing_location' value = '1'></td>
222 <td>&nbsp;</td>
223 <td><span class='text'><?php xl('Accepts Assignment', 'e'); ?><br>(<?php xl('only if billing location', 'e'); ?>): </span></td> <td><input type='checkbox' name='accepts_assignment' value = '1'></td>
224 </tr>
225 <tr>
226 <td><span class='text'><?php xl('Service Location', 'e'); ?>: </span></td> <td><input type='checkbox' name='service_location' value = '1'></td>
227 <td>&nbsp;</td>
228 <td><span class='text'><?php echo htmlspecialchars(xl('Color'), ENT_QUOTES); ?>: </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 htmlspecialchars(xl('Pick'), ENT_QUOTES); ?></a>]</span></td>
229 </tr>
230 <?php
231 $disabled='';
232 $resPBE = $facilityService->getPrimaryBusinessEntity(array("excludedId" => $my_fid));
233 if (sizeof($resPBE)>0) {
234 $disabled='disabled';
237 <tr>
238 <td><span class='text'><?php xl('Primary Business Entity', 'e'); ?>: </span></td>
239 <td><input type='checkbox' name='primary_business_entity' id='primary_business_entity' value='1' <?php if ($facility['primary_business_entity'] == 1) {
240 echo 'checked';
241 } ?> <?php if ($GLOBALS['erx_enable']) {
242 ?> onchange='return displayAlert()' <?php
243 } ?> <?php echo $disabled;?>></td>
244 <td>&nbsp;</td>
245 </tr>
246 <tr>
247 <td><span class=text><?php xl('POS Code', 'e'); ?>: </span></td>
248 <td colspan="6">
249 <select name="pos_code">
250 <?php
251 $pc = new POSRef();
253 foreach ($pc->get_pos_ref() as $pos) {
254 echo "<option value=\"" . $pos["code"] . "\" ";
255 echo ">" . $pos['code'] . ": ". text($pos['title']);
256 echo "</option>\n";
260 </select>
261 </td>
262 </tr>
263 <tr>
264 <td><span class="text"><?php xl('Billing Attn', 'e'); ?>:</span></td>
265 <td colspan="4"><input type="text" name="attn" size="45"></td>
266 </tr>
267 <tr>
268 <td><span class="text"><?php xl('CLIA Number', 'e'); ?>:</span></td>
269 <td colspan="4"><input type="text" name="domain_identifier" size="45"></td>
270 </tr>
271 <tr>
272 <td><span class="text"><?php xl('Facility ID', 'e'); ?>:</span></td>
273 <td colspan="4"><input type="text" name="facility_id" size="20"></td>
274 </tr>
275 <tr height="25" style="valign:bottom;">
276 <td><font class="mandatory">*</font><span class="text"> <?php echo xl('Required', 'e'); ?></span></td><td>&nbsp;</td><td>&nbsp;</td>
277 <td>&nbsp;</td><td>&nbsp;</td>
278 </tr>
279 </table>
280 </form>
282 <script language="JavaScript">
283 <?php
284 if ($alertmsg = trim($alertmsg)) {
285 echo "alert('$alertmsg');\n";
288 </script>
290 </body>
291 </html>