Clean up HTML generated by new_form.php

ytiddo wrote on Tuesday, April 21, 2009:

Someone tap me on the shoulder if this is not the right place to post fixes.

This cleans up the html generated by new_form.php when there are no forms to add, as well as generating the <form> only when needed, and removing a containing <dl>.

{{{
— interface/patient_file/encounter/new_form.php.orig  2009-04-21 16:13:26.000000000 +0100
+++ interface/patient_file/encounter/new_form.php       2009-04-21 17:04:35.000000000 +0100
@@ -7,7 +7,6 @@
<link rel=“stylesheet” href="<?php echo $css_header; ?>" type=“text/css”>
</head>
<body class=“body_top”>
-<dl>
<?php //DYNAMIC FORM RETREIVAL
include_once("$srcdir/registry.inc");
function myGetRegistered ( $state=“1”, $limit=“unlimited”, $offset=“0”)
@@ -27,8 +26,8 @@
}
$reg = myGetRegistered ();
$old_category = ‘’;
+if ($reg != false) {
echo “<FORM METHOD=POST NAME=‘choose’>\n”;
-if ($reg != false)
foreach ($reg as $entry) {
        $new_category = trim($entry[‘category’]);
        $new_nickname = trim($entry[‘nickname’]);
@@ -38,7 +37,6 @@
        if ($old_category != $new_category) {
                $new_category_ = $new_category;
                $new_category_ = str_replace(’ ‘,’_’,$new_category_);
-               if ($old_category != ‘’) {echo “</select>\n”;}
                echo “<select name=” . $new_category_ . " onchange=‘top.restoreSession();";
                echo $GLOBALS[‘concurrent_layout’] ? “parent” : “top.frames[&quot;Main&quot;]”;
                echo “.location.href = document.choose.” . $new_category_ .
@@ -47,6 +45,7 @@
                echo "<option value=’" . $rootdir .
                        ‘/patient_file/encounter/load_form.php?formname=’ .
                        urlencode($entry[‘directory’]) . “’>” . $nickname . “</option>\n”;
+               echo “</select>\n”;
                $old_category = $new_category;
        }
        else {
@@ -55,10 +54,8 @@
                        urlencode($entry[‘directory’]) . “’>” . xl($nickname) . “</option>\n”;
        }
}
-echo “</select>\n”;
echo “</FORM>\n”;
+}
?>
-</dl>
-
</body>
</html>
}}}

bradymiller wrote on Friday, April 24, 2009:

hey,
  Can’t apply the above text as patch because of spacing.  Can you email me your original text file of above patch to brady@sparmy.com .
thanks,
brady

bradymiller wrote on Saturday, April 25, 2009:

hi,
Tried your patch.  It introduces a bug if the forms contains entries.  Pasted the html output of the frame below and note the </select> tag gets outputted early, which makes menu non-functional.
-brady

<html>
<head>
<meta http-equiv=“Content-Type” content=“text/html; charset=UTF-8”/>
<link rel=“stylesheet” href="/openemr/interface/themes/style_sky_blue.css" type=“text/css”>
</head>
<body class=“body_top”>
<FORM METHOD=POST NAME=‘choose’>
<select name=category onchange=‘top.restoreSession();parent.location.href = document.choose.category.options[document.choose.category.selectedIndex].value’>
<option value=category>category</option>
<option value=’/openemr/interface/patient_file/encounter/load_form.php?formname=newpatient’>New Encounter Form</option>
</select>
<option value=’/openemr/interface/patient_file/encounter/load_form.php?formname=reviewofs’>Review of Systems Checks</option>
<option value=’/openemr/interface/patient_file/encounter/load_form.php?formname=dictation’>Speech Dictation</option>
<option value=’/openemr/interface/patient_file/encounter/load_form.php?formname=soap’>SOAP</option>
<option value=’/openemr/interface/patient_file/encounter/load_form.php?formname=vitals’>Vitals</option>
<option value=’/openemr/interface/patient_file/encounter/load_form.php?formname=ros’>Review Of Systems</option>
<option value=’/openemr/interface/patient_file/encounter/load_form.php?formname=fee_sheet’>Fee Sheet</option>
<option value=’/openemr/interface/patient_file/encounter/load_form.php?formname=misc_billing_options’>Misc Billing Options HCFA</option>
</FORM>
</body>
</html>