minor fix to prior commit
[openemr.git] / interface / usergroup / facilities_add.php
blob17f3ef529dc234fd438723eade0e220a6839d88f
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 $facilityService = new \services\FacilityService();
9 $alertmsg = '';
11 <html>
12 <head>
13 <link rel="stylesheet" href="<?php echo $css_header;?>" type="text/css">
14 <link rel="stylesheet" type="text/css" href="<?php echo $GLOBALS['webroot'] ?>/library/js/fancybox/jquery.fancybox-1.2.6.css" media="screen" />
15 <script type="text/javascript" src="<?php echo $GLOBALS['webroot'] ?>/library/dialog.js?v=<?php echo $v_js_includes; ?>"></script>
16 <script type="text/javascript" src="<?php echo $GLOBALS['assets_static_relative'] ?>/jquery-min-1-9-1/index.js"></script>
17 <script type="text/javascript" src="<?php echo $GLOBALS['webroot'] ?>/library/js/common.js"></script>
18 <script type="text/javascript" src="<?php echo $GLOBALS['webroot'] ?>/library/js/fancybox/jquery.fancybox-1.2.6.js"></script>
19 <script type="text/javascript" src="<?php echo $GLOBALS['webroot'] ?>/library/js/jquery-ui.js"></script>
20 <script type="text/javascript" src="../main/calendar/modules/PostCalendar/pnincludes/AnchorPosition.js"></script>
21 <script type="text/javascript" src="../main/calendar/modules/PostCalendar/pnincludes/PopupWindow.js"></script>
22 <script type="text/javascript" src="../main/calendar/modules/PostCalendar/pnincludes/ColorPicker2.js"></script>
24 <!-- validation library -->
25 <!--//Not lbf forms use the new validation, please make sure you have the corresponding values in the list Page validation-->
26 <?php $use_validate_js = 1;?>
27 <?php require_once($GLOBALS['srcdir'] . "/validation/validation_script.js.php"); ?>
28 <?php
29 //Gets validation rules from Page Validation list.
30 //Note that for technical reasons, we are bypassing the standard validateUsingPageRules() call.
31 $collectthis = collectValidationPageRules("/interface/usergroup/facilities_add.php");
32 if (empty($collectthis)) {
33 $collectthis = "undefined";
35 else {
36 $collectthis = $collectthis["facility-add"]["rules"];
39 // Old Browser comp trigger on js
41 if (isset($_POST["mode"]) && $_POST["mode"] == "facility") {
42 echo '
43 <script type="text/javascript">
44 <!--
45 parent.$.fn.fancybox.close();
46 //-->
47 </script>
52 <script type="text/javascript">
53 /// todo, move this to a common library
55 var collectvalidation = <?php echo($collectthis); ?>;
57 function submitform() {
59 var valid = submitme(1, undefined, 'facility-add', 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)
68 if(f[i].name == 'facility' || f[i].name == 'Washington')
70 alertMsg += checkLength(f[i].name,f[i].value,35);
71 alertMsg += checkFacilityName(f[i].name,f[i].value);
73 else if(f[i].name == 'street')
75 alertMsg += checkLength(f[i].name,f[i].value,35);
76 alertMsg += checkAlphaNumeric(f[i].name,f[i].value);
78 else if(f[i].name == 'phone' || f[i].name == 'fax')
80 alertMsg += checkPhone(f[i].name,f[i].value);
82 else if(f[i].name == 'federal_ein')
84 alertMsg += checkLength(f[i].name,f[i].value,10);
85 alertMsg += checkFederalEin(f[i].name,f[i].value);
89 if(alertMsg)
91 alert(alertMsg);
92 return false;
94 <?php } ?>
96 top.restoreSession();
97 document.forms[0].submit();
100 function toggle( target, div ) {
102 $mode = $(target).find(".indicator").text();
103 if ( $mode == "collapse" ) {
104 $(target).find(".indicator").text( "expand" );
105 $(div).hide();
106 } else {
107 $(target).find(".indicator").text( "collapse" );
108 $(div).show();
113 $(document).ready(function(){
115 $("#dem_view").click( function() {
116 toggle( $(this), "#DEM" );
119 // fancy box
120 enable_modals();
122 tabbify();
124 // special size for
125 $(".large_modal").fancybox( {
126 'overlayOpacity' : 0.0,
127 'showCloseButton' : true,
128 'frameHeight' : 600,
129 'frameWidth' : 1000
132 // special size for
133 $(".medium_modal").fancybox( {
134 'overlayOpacity' : 0.0,
135 'showCloseButton' : true,
136 'frameHeight' : 260,
137 'frameWidth' : 510
142 $(document).ready(function(){
143 $("#cancel").click(function() {
144 parent.$.fn.fancybox.close();
148 * add required/star sign to required form fields
150 for (var prop in collectvalidation) {
151 //if (collectvalidation[prop].requiredSign)
152 if (collectvalidation[prop].presence)
153 jQuery("input[name='" + prop + "']").after('*');
156 var cp = new ColorPicker('window');
157 // Runs when a color is clicked
158 function pickColor(color) {
159 document.getElementById('ncolor').value = color;
161 var field;
162 function pick(anchorname,target) {
163 var cp = new ColorPicker('window');
164 field=target;
165 cp.show(anchorname);
167 function displayAlert()
169 if(document.getElementById('primary_business_entity').checked==false)
170 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.'));?>");
171 else if(document.getElementById('primary_business_entity').checked==true)
172 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.'));?>");
174 </script>
175 <link rel="stylesheet" href="<?php echo $css_header;?>" type="text/css">
177 </head>
178 <body class="body_top">
179 <table>
180 <tr><td>
181 <span class="title"><?php xl('Add Facility','e'); ?></span>&nbsp;&nbsp;&nbsp;</td>
182 <td colspan=5 align=center style="padding-left:2px;">
183 <a onclick="submitform();" class="css_button large_button" name='form_save' id='form_save' href='#'>
184 <span class='css_button_span large_button_span'><?php xl('Save','e');?></span>
185 </a>
186 <a class="css_button large_button" id='cancel' href='#' >
187 <span class='css_button_span large_button_span'><?php xl('Cancel','e');?></span>
188 </a>
189 </td></tr>
190 </table>
192 <br>
194 <form name='facility-add' id='facility-add' method='post' action="facilities.php" target='_parent'>
195 <input type=hidden name=mode value="facility">
196 <table border=0 cellpadding=0 cellspacing=0>
197 <tr>
198 <td><span class="text"><?php xl('Name','e'); ?>: </span></td><td><input type=entry name=facility size=20 value=""></td>
199 <td width=20>&nbsp;</td>
200 <td><span class="text"><?php xl('Phone','e'); ?>: </span></td><td><input type=entry name=phone size=20 value=""></td>
201 </tr>
202 <tr>
203 <td><span class="text"><?php xl('Address','e'); ?>: </span></td><td><input type=entry size=20 name=street value=""></td>
204 <td>&nbsp;</td>
205 <td><span class="text"><?php xl('Fax','e'); ?>: </span></td><td><input type=entry name=fax size=20 value=""></td>
206 </tr>
207 <tr>
208 <td><span class="text"><?php xl('City','e'); ?>: </span></td><td><input type=entry size=20 name=city value=""></td>
209 <td>&nbsp;</td>
210 <td><span class="text"><?php xl('Zip Code','e'); ?>: </span></td><td><input type=entry size=20 name=postal_code value=""></td>
211 </tr>
212 <tr>
213 <td><span class="text"><?php xl('State','e'); ?>: </span></td><td><input type=entry size=20 name=state value=""></td>
214 <td>&nbsp;</td>
215 <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>
216 </tr>
217 <tr>
218 <td height="22"><span class="text"><?php xl('Country','e'); ?>: </span></td><td><input type=entry size=20 name=country_code value=""></td>
219 <td>&nbsp;</td>
220 <td><span class="text"><?php ($GLOBALS['simplified_demographics'] ? xl('Facility Code','e') : xl('Facility NPI','e')); ?>:
221 </span></td><td><input type=entry size=20 name=facility_npi value=""></td>
222 </tr>
223 <tr>
224 <td><span class="text"><?php xl('Website','e'); ?>: </span></td><td><input type=entry size=20 name=website value=""></td>
225 <td>&nbsp;</td>
226 <td><span class="text"><?php xl('Email','e'); ?>: </span></td><td><input type=entry size=20 name=email value=""></td>
227 </tr>
229 <tr>
230 <td><span class='text'><?php xl('Billing Location','e'); ?>: </span></td><td><input type='checkbox' name='billing_location' value = '1'></td>
231 <td>&nbsp;</td>
232 <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>
233 </tr>
234 <tr>
235 <td><span class='text'><?php xl('Service Location','e'); ?>: </span></td> <td><input type='checkbox' name='service_location' value = '1'></td>
236 <td>&nbsp;</td>
237 <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>
238 </tr>
239 <?php
240 $disabled='';
241 $resPBE = $facilityService->getPrimaryBusinessEntity(array("excludedId" => $my_fid));
242 if(sizeof($resPBE)>0)
243 $disabled='disabled';
245 <tr>
246 <td><span class='text'><?php xl('Primary Business Entity','e'); ?>: </span></td>
247 <td><input type='checkbox' name='primary_business_entity' id='primary_business_entity' value='1' <?php if ($facility['primary_business_entity'] == 1) echo 'checked'; ?> <?php if($GLOBALS['erx_enable']){ ?> onchange='return displayAlert()' <?php } ?> <?php echo $disabled;?>></td>
248 <td>&nbsp;</td>
249 </tr>
250 <tr>
251 <td><span class=text><?php xl('POS Code','e'); ?>: </span></td>
252 <td colspan="6">
253 <select name="pos_code">
254 <?php
255 $pc = new POSRef();
257 foreach ($pc->get_pos_ref() as $pos) {
258 echo "<option value=\"" . $pos["code"] . "\" ";
259 echo ">" . $pos['code'] . ": ". text($pos['title']);
260 echo "</option>\n";
264 </select>
265 </td>
266 </tr>
267 <tr>
268 <td><span class="text"><?php xl('Billing Attn','e'); ?>:</span></td>
269 <td colspan="4"><input type="text" name="attn" size="45"></td>
270 </tr>
271 <tr>
272 <td><span class="text"><?php xl('CLIA Number','e'); ?>:</span></td>
273 <td colspan="4"><input type="text" name="domain_identifier" size="45"></td>
274 </tr>
275 <tr>
276 <td><span class="text"><?php xl('Facility ID','e'); ?>:</span></td>
277 <td colspan="4"><input type="text" name="facility_id" size="20"></td>
278 </tr>
279 <tr height="25" style="valign:bottom;">
280 <td><font class="mandatory">*</font><span class="text"> <?php echo xl('Required','e'); ?></span></td><td>&nbsp;</td><td>&nbsp;</td>
281 <td>&nbsp;</td><td>&nbsp;</td>
282 </tr>
283 </table>
284 </form>
286 <script language="JavaScript">
287 <?php
288 if ($alertmsg = trim($alertmsg)) {
289 echo "alert('$alertmsg');\n";
292 </script>
294 </body>
295 </html>