function dbtable_to_html($tablear, $valuesar, $action = "", $formname = "", $actionlabel = "", $hidden = "") { global $CELLBG; $ret = "<table style=\"border-width:0px;\" cellspacing=\"0\" cellpadding=\"0\">" . "<tr><td style=\"background-color:#000000;\">" . "<table style=\"border-width:0px; width:100%;\" cellspacing=\"1\" cellpadding=\"2\">" . "<tr><td style=\"width:100%; background-color:{$CELLBG};\">" . "<table style=\"border-width:0px; width:100%;\">\n"; if (!is_array($tablear)) { return "Error: dbtable_to_html parameter 1 is not an array!\n<br />\n"; } if ($action != "") { $ret .= "<form action=\"{$action}\" method=\"post\""; if ($formname != "") { $ret .= " name=\"{$formname}\""; } $ret .= ">"; if (is_array($hidden)) { for ($i = 0; $i < count($hidden); $i += 2) { $ret .= "<input type=\"hidden\" name=\"" . $hidden[$i] . "\" value=\"" . $hidden[$i + 1] . "\" />"; } } } for ($i = 0; $i < count($tablear); $i++) { if (!empty($tablear[$i]["hide"])) { continue; } if (!empty($action) && !empty($tablear[$i]["calculated"])) { continue; } $ret .= "<tr><td style=\"vertical-align:top;\">"; if (!empty($tablear[$i]["prompt"])) { $ret .= "<b"; if (!empty($tablear[$i]["tooltip"])) { $ret .= " class=\"tooltip\" title=\"" . $tablear[$i]["tooltip"] . "\""; } $ret .= ">" . $tablear[$i]["prompt"] . ":</b></td>\n"; } else { $ret .= " </td>"; } $ret .= "<td style=\"vertical-align:top;\">"; if (empty($tablear[$i]["noneditable"]) && !empty($action)) { if ($tablear[$i]["type"] == "text" || $tablear[$i]["type"] == "int" || $tablear[$i]["type"] == "float") { $ret .= "<input type=\"text\" name=\"" . $tablear[$i]["name"] . "\""; if (!empty($tablear[$i]["maxlength"])) { $ret .= " maxlength=\"" . $tablear[$i]["maxlength"] . "\""; } if (!empty($tablear[$i]["length"])) { $ret .= " size=\"" . $tablear[$i]["length"] . "\""; } if (!empty($valuesar[$i])) { $ret .= " value=\"" . htmlspecialchars($valuesar[$i]) . "\""; } $ret .= " />"; } else { if ($tablear[$i]["type"] == "boolean") { $ret .= "<input type=\"radio\" value=\"Y\" name=\"" . $tablear[$i]["name"] . "\""; if ($valuesar[$i] == "Y") { $ret .= " checked=\"checked\""; } $ret .= ">" . translate("Yes") . " "; $ret .= "<input type=\"radio\" value=\"N\" name=\"" . $tablear[$i]["name"] . "\""; if ($valuesar[$i] != "Y") { $ret .= " checked=\"checked\""; } $ret .= ">" . translate("No"); } else { if ($tablear[$i]["type"] == "date") { $ret .= date_selection_html($tablear[$i]["name"], $valuesar[$i]); } else { if ($tablear[$i]["type"] == "dbdate") { // '2002-12-31' $y = substr($valuesar[$i], 0, 4); $m = substr($valuesar[$i], 5, 2); $d = substr($valuesar[$i], 8, 2); $date = sprintf("%04d%02d%02d", $y, $m, $d); $ret .= date_selection_html($tablear[$i]["name"], $date); } else { $ret .= "(type " . $tablear[$i]["type"] . " not supported)"; } } } } } else { if (!empty($valuesar[$i])) { if ($tablear[$i]["type"] == "text" || $tablear[$i]["type"] == "int" || $tablear[$i]["type"] == "float") { $ret .= htmlentities($valuesar[$i]); } else { if ($tablear[$i]["type"] == "boolean") { if ($valuesar[$i] == "Y" || empty($valuesar[$i])) { $ret .= translate("Yes"); } else { $ret .= translate("No"); } } else { if ($tablear[$i]["type"] == "date") { $ret .= date_to_str($valuesar[$i]); } else { if ($tablear[$i]["type"] == "dbdate") { $y = substr($valuesar[$i], 0, 4); $m = substr($valuesar[$i], 5, 2); $d = substr($valuesar[$i], 8, 2); $date = sprintf("%04d%02d%02d", $y, $m, $d); $ret .= date_to_str($date); } else { $ret .= "(type " . $tablear[$i]["type"] . " not supported)"; } } } } } } $ret .= "</td></tr>\n"; } if (!empty($actionlabel)) { $ret .= "<tr><td colspan=\"2\" style=\"text-align:center;\">\n" . "<input type=\"submit\" value=\"" . htmlspecialchars($actionlabel) . "\" />" . "</td></tr></form>\n"; } $ret .= "</table>\n</td></tr></table>\n</td></tr></table>\n"; return $ret; }
function print_date_selection($prefix, $date) { print date_selection_html($prefix, $date); }
function dbtable_to_html($tablear, $valuesar, $action = "", $formname = "", $actionlabel = "", $hidden = "") { global $CELLBG; $ret = "<TABLE BORDER=\"0\" CELLSPACING=\"0\" CELLPADDING=\"0\">" . "<TR><TD BGCOLOR=\"#000000\">" . "<TABLE BORDER=\"0\" WIDTH=\"100%\" CELLSPACING=\"1\" CELLPADDING=\"2\">" . "<TR><TD WIDTH=\"100%\" BGCOLOR=\"{$CELLBG}\">" . "<TABLE BORDER=\"0\" WIDTH=\"100%\">\n"; if (!is_array($tablear)) { return "Error: dbtable_to_html parameter 1 is not an array!\n<BR>\n"; } if ($action != "") { $ret .= "<FORM ACTION=\"{$action}\" METHOD=\"POST\""; if ($formname != "") { $ret .= " NAME=\"{$formname}\""; } $ret .= ">"; if (is_array($hidden)) { for ($i = 0; $i < count($hidden); $i += 2) { $ret .= "<INPUT TYPE=\"hidden\" NAME=\"" . $hidden[$i] . "\" VALUE=\"" . $hidden[$i + 1] . "\">"; } } } for ($i = 0; $i < count($tablear); $i++) { if (!empty($tablear[$i]["hide"])) { continue; } if (!empty($action) && !empty($tablear[$i]["calculated"])) { continue; } $ret .= "<TR><TD VALIGN=\"top\">"; if (!empty($tablear[$i]["prompt"])) { $ret .= "<B"; if (!empty($tablear[$i]["tooltip"])) { $ret .= " CLASS=\"tooltip\" TITLE=\"" . $tablear[$i]["tooltip"] . "\""; } $ret .= ">" . $tablear[$i]["prompt"] . ":</B></TD>\n"; } else { $ret .= " </TD>"; } $ret .= "<TD VALIGN=\"top\">"; if (empty($tablear[$i]["noneditable"]) && !empty($action)) { if ($tablear[$i]["type"] == "text" || $tablear[$i]["type"] == "int" || $tablear[$i]["type"] == "float") { $ret .= "<INPUT TYPE=\"text\" NAME=\"" . $tablear[$i]["name"] . "\" "; if (!empty($tablear[$i]["maxlength"])) { $ret .= "MAXLENGTH=\"" . $tablear[$i]["maxlength"] . "\" "; } if (!empty($tablear[$i]["length"])) { $ret .= "SIZE=\"" . $tablear[$i]["length"] . "\" "; } if (!empty($valuesar[$i])) { $ret .= "VALUE=\"" . htmlspecialchars($valuesar[$i]) . "\" "; } $ret .= ">"; } else { if ($tablear[$i]["type"] == "boolean") { $ret .= "<INPUT TYPE=\"radio\" VALUE=\"Y\" NAME=\"" . $tablear[$i]["name"] . "\" "; if ($valuesar[$i] == "Y") { $ret .= "CHECKED"; } $ret .= "> " . translate("Yes") . " "; $ret .= "<INPUT TYPE=\"radio\" VALUE=\"N\" NAME=\"" . $tablear[$i]["name"] . "\" "; if ($valuesar[$i] != "Y") { $ret .= "CHECKED"; } $ret .= "> " . translate("No"); } else { if ($tablear[$i]["type"] == "date") { $ret .= date_selection_html($tablear[$i]["name"], $valuesar[$i]); } else { if ($tablear[$i]["type"] == "dbdate") { // '2002-12-31' $y = substr($valuesar[$i], 0, 4); $m = substr($valuesar[$i], 5, 2); $d = substr($valuesar[$i], 8, 2); $date = sprintf("%04d%02d%02d", $y, $m, $d); $ret .= date_selection_html($tablear[$i]["name"], $date); } else { $ret .= "(type " . $tablear[$i]["type"] . " not supported)"; } } } } } else { if (!empty($valuesar[$i])) { if ($tablear[$i]["type"] == "text" || $tablear[$i]["type"] == "int" || $tablear[$i]["type"] == "float") { $ret .= htmlentities($valuesar[$i]); } else { if ($tablear[$i]["type"] == "boolean") { if ($valuesar[$i] == "Y" || empty($valuesar[$i])) { $ret .= translate("Yes"); } else { $ret .= translate("No"); } } else { if ($tablear[$i]["type"] == "date") { $ret .= date_to_str($valuesar[$i]); } else { if ($tablear[$i]["type"] == "dbdate") { $y = substr($valuesar[$i], 0, 4); $m = substr($valuesar[$i], 5, 2); $d = substr($valuesar[$i], 8, 2); $date = sprintf("%04d%02d%02d", $y, $m, $d); $ret .= date_to_str($date); } else { $ret .= "(type " . $tablear[$i]["type"] . " not supported)"; } } } } } } $ret .= "</TD></TR>\n"; } if (!empty($actionlabel)) { $ret .= "<TR><TD COLSPAN=\"2\"><CENTER><INPUT TYPE=\"submit\" " . "VALUE=\"" . htmlspecialchars($actionlabel) . "\">" . "</CENTER></TD></TR></FORM>\n"; } $ret .= "</TABLE>\n</TD></TR></TABLE>\n</TD></TR></TABLE>\n"; return $ret; }