Highway to PSR2
[openemr.git] / interface / usergroup / facilities_add.php
blobe621c52e976dd606754b557fbb78f07975b45561
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";
34 } else {
35 $collectthis = $collectthis["facility-add"]["rules"];
38 // Old Browser comp trigger on js
40 if (isset($_POST["mode"]) && $_POST["mode"] == "facility") {
41 echo '
42 <script type="text/javascript">
43 <!--
44 parent.$.fn.fancybox.close();
45 //-->
46 </script>
51 <script type="text/javascript">
52 /// todo, move this to a common library
54 var collectvalidation = <?php echo($collectthis); ?>;
56 function submitform() {
58 var valid = submitme(1, undefined, 'facility-add', collectvalidation);
59 if (!valid) return;
61 <?php if ($GLOBALS['erx_enable']) { ?>
62 alertMsg='';
63 f=document.forms[0];
64 for(i=0;i<f.length;i++){
65 if(f[i].type=='text' && f[i].value)
67 if(f[i].name == 'facility' || f[i].name == 'Washington')
69 alertMsg += checkLength(f[i].name,f[i].value,35);
70 alertMsg += checkFacilityName(f[i].name,f[i].value);
72 else if(f[i].name == 'street')
74 alertMsg += checkLength(f[i].name,f[i].value,35);
75 alertMsg += checkAlphaNumeric(f[i].name,f[i].value);
77 else if(f[i].name == 'phone' || f[i].name == 'fax')
79 alertMsg += checkPhone(f[i].name,f[i].value);
81 else if(f[i].name == 'federal_ein')
83 alertMsg += checkLength(f[i].name,f[i].value,10);
84 alertMsg += checkFederalEin(f[i].name,f[i].value);
88 if(alertMsg)
90 alert(alertMsg);
91 return false;
93 <?php } ?>
95 top.restoreSession();
96 document.forms[0].submit();
99 function toggle( target, div ) {
101 $mode = $(target).find(".indicator").text();
102 if ( $mode == "collapse" ) {
103 $(target).find(".indicator").text( "expand" );
104 $(div).hide();
105 } else {
106 $(target).find(".indicator").text( "collapse" );
107 $(div).show();
112 $(document).ready(function(){
114 $("#dem_view").click( function() {
115 toggle( $(this), "#DEM" );
118 // fancy box
119 enable_modals();
121 tabbify();
123 // special size for
124 $(".large_modal").fancybox( {
125 'overlayOpacity' : 0.0,
126 'showCloseButton' : true,
127 'frameHeight' : 600,
128 'frameWidth' : 1000
131 // special size for
132 $(".medium_modal").fancybox( {
133 'overlayOpacity' : 0.0,
134 'showCloseButton' : true,
135 'frameHeight' : 260,
136 'frameWidth' : 510
141 $(document).ready(function(){
142 $("#cancel").click(function() {
143 parent.$.fn.fancybox.close();
147 * add required/star sign to required form fields
149 for (var prop in collectvalidation) {
150 //if (collectvalidation[prop].requiredSign)
151 if (collectvalidation[prop].presence)
152 jQuery("input[name='" + prop + "']").after('*');
155 var cp = new ColorPicker('window');
156 // Runs when a color is clicked
157 function pickColor(color) {
158 document.getElementById('ncolor').value = color;
160 var field;
161 function pick(anchorname,target) {
162 var cp = new ColorPicker('window');
163 field=target;
164 cp.show(anchorname);
166 function displayAlert()
168 if(document.getElementById('primary_business_entity').checked==false)
169 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.'));?>");
170 else if(document.getElementById('primary_business_entity').checked==true)
171 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.'));?>");
173 </script>
174 <link rel="stylesheet" href="<?php echo $css_header;?>" type="text/css">
176 </head>
177 <body class="body_top">
178 <table>
179 <tr><td>
180 <span class="title"><?php xl('Add Facility', 'e'); ?></span>&nbsp;&nbsp;&nbsp;</td>
181 <td colspan=5 align=center style="padding-left:2px;">
182 <a onclick="submitform();" class="css_button large_button" name='form_save' id='form_save' href='#'>
183 <span class='css_button_span large_button_span'><?php xl('Save', 'e');?></span>
184 </a>
185 <a class="css_button large_button" id='cancel' href='#' >
186 <span class='css_button_span large_button_span'><?php xl('Cancel', 'e');?></span>
187 </a>
188 </td></tr>
189 </table>
191 <br>
193 <form name='facility-add' id='facility-add' method='post' action="facilities.php" target='_parent'>
194 <input type=hidden name=mode value="facility">
195 <table border=0 cellpadding=0 cellspacing=0>
196 <tr>
197 <td><span class="text"><?php xl('Name', 'e'); ?>: </span></td><td><input type=entry name=facility size=20 value=""></td>
198 <td width=20>&nbsp;</td>
199 <td><span class="text"><?php xl('Phone', 'e'); ?>: </span></td><td><input type=entry name=phone size=20 value=""></td>
200 </tr>
201 <tr>
202 <td><span class="text"><?php xl('Address', 'e'); ?>: </span></td><td><input type=entry size=20 name=street value=""></td>
203 <td>&nbsp;</td>
204 <td><span class="text"><?php xl('Fax', 'e'); ?>: </span></td><td><input type=entry name=fax size=20 value=""></td>
205 </tr>
206 <tr>
207 <td><span class="text"><?php xl('City', 'e'); ?>: </span></td><td><input type=entry size=20 name=city value=""></td>
208 <td>&nbsp;</td>
209 <td><span class="text"><?php xl('Zip Code', 'e'); ?>: </span></td><td><input type=entry size=20 name=postal_code value=""></td>
210 </tr>
211 <tr>
212 <td><span class="text"><?php xl('State', 'e'); ?>: </span></td><td><input type=entry size=20 name=state value=""></td>
213 <td>&nbsp;</td>
214 <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>
215 </tr>
216 <tr>
217 <td height="22"><span class="text"><?php xl('Country', 'e'); ?>: </span></td><td><input type=entry size=20 name=country_code value=""></td>
218 <td>&nbsp;</td>
219 <td><span class="text"><?php ($GLOBALS['simplified_demographics'] ? xl('Facility Code', 'e') : xl('Facility NPI', 'e')); ?>:
220 </span></td><td><input type=entry size=20 name=facility_npi value=""></td>
221 </tr>
222 <tr>
223 <td><span class="text"><?php xl('Website', 'e'); ?>: </span></td><td><input type=entry size=20 name=website value=""></td>
224 <td>&nbsp;</td>
225 <td><span class="text"><?php xl('Email', 'e'); ?>: </span></td><td><input type=entry size=20 name=email value=""></td>
226 </tr>
228 <tr>
229 <td><span class='text'><?php xl('Billing Location', 'e'); ?>: </span></td><td><input type='checkbox' name='billing_location' value = '1'></td>
230 <td>&nbsp;</td>
231 <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>
232 </tr>
233 <tr>
234 <td><span class='text'><?php xl('Service Location', 'e'); ?>: </span></td> <td><input type='checkbox' name='service_location' value = '1'></td>
235 <td>&nbsp;</td>
236 <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>
237 </tr>
238 <?php
239 $disabled='';
240 $resPBE = $facilityService->getPrimaryBusinessEntity(array("excludedId" => $my_fid));
241 if (sizeof($resPBE)>0) {
242 $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) {
248 echo 'checked';
249 } ?> <?php if ($GLOBALS['erx_enable']) {
250 ?> onchange='return displayAlert()' <?php
251 } ?> <?php echo $disabled;?>></td>
252 <td>&nbsp;</td>
253 </tr>
254 <tr>
255 <td><span class=text><?php xl('POS Code', 'e'); ?>: </span></td>
256 <td colspan="6">
257 <select name="pos_code">
258 <?php
259 $pc = new POSRef();
261 foreach ($pc->get_pos_ref() as $pos) {
262 echo "<option value=\"" . $pos["code"] . "\" ";
263 echo ">" . $pos['code'] . ": ". text($pos['title']);
264 echo "</option>\n";
268 </select>
269 </td>
270 </tr>
271 <tr>
272 <td><span class="text"><?php xl('Billing Attn', 'e'); ?>:</span></td>
273 <td colspan="4"><input type="text" name="attn" size="45"></td>
274 </tr>
275 <tr>
276 <td><span class="text"><?php xl('CLIA Number', 'e'); ?>:</span></td>
277 <td colspan="4"><input type="text" name="domain_identifier" size="45"></td>
278 </tr>
279 <tr>
280 <td><span class="text"><?php xl('Facility ID', 'e'); ?>:</span></td>
281 <td colspan="4"><input type="text" name="facility_id" size="20"></td>
282 </tr>
283 <tr height="25" style="valign:bottom;">
284 <td><font class="mandatory">*</font><span class="text"> <?php echo xl('Required', 'e'); ?></span></td><td>&nbsp;</td><td>&nbsp;</td>
285 <td>&nbsp;</td><td>&nbsp;</td>
286 </tr>
287 </table>
288 </form>
290 <script language="JavaScript">
291 <?php
292 if ($alertmsg = trim($alertmsg)) {
293 echo "alert('$alertmsg');\n";
296 </script>
298 </body>
299 </html>