<!-- if (<?php echo implode(" && ", $checkboxes); ?> ) errors[errors.length] = "Contact Department must be checked"; --> </script> <table class="left" cellspacing="1"> <?php echo drawHeaderRow("View Contact", 2); ?> <form method="post" action="<?php echo $request["path_query"]; ?> " onsubmit="javascript:return validate(this);"> <?php echo draw_form_hidden("objectID", @$_GET["id"]); ?> <tr> <td class="left">Courtesy Title</td> <td> <?php echo draw_form_select("tag_single_10", "SELECT id, tag FROM contacts_tags WHERE type_id = 10 AND is_active = 1 ORDER BY tag", @$i["salutation"]); ?> </td> </tr> <tr> <td class="left">Name</td> <td width="82%"> <?php echo draw_form_text("varchar_01", @$i["first"], "", 255, "width:150px;"); ?>
function addRow($type, $title, $name = "", $value = "", $default = "", $required = false, $maxlength = 50, $onchange = false) { global $rows, $js, $months, $month, $today, $year, $_josh; $textlength = $maxlength > 50 ? 50 : $maxlength; $value = trim($value); if ($type == "raw") { $rows .= $title; } else { $rows .= '<tr>'; if ($type != "button" && $type != "submit" && $type != "hidden" && $type != "raw") { $rows .= '<td class="left">' . $title . '</td>'; } if ($type == "text") { //output text, no form element $rows .= '<td>' . $value . '</td>'; } elseif ($type == "date") { $rows .= '<td>' . draw_form_date($name, $value, false, false, $required) . '</td>'; } elseif ($type == "datetime") { $rows .= '<td>' . draw_form_date($name, $value, true) . '</td>'; } elseif ($type == "checkbox") { $rows .= '<td>' . draw_form_checkbox($name, $value) . '</td>'; } elseif ($type == "itext") { $rows .= '<td>' . draw_form_text($name, $value, false, $maxlength) . '</td>'; if ($required) { $js .= "if (!form." . $name . ".value.length) errors[errors.length] = 'the \\'" . $title . "\\' field is empty';" . $_josh["newline"]; } } elseif ($type == "phone") { $rows .= '<td>' . draw_form_text($name, $value, 14, $maxlength) . '</td>'; if ($required) { $js .= "if (!form." . $name . ".value.length) errors[errors.length] = 'the \\'" . $title . "\\' field is empty';" . $_josh["newline"]; } } elseif ($type == "extension") { $rows .= '<td>' . draw_form_text($name, $value, 4, $maxlength) . '</td>'; if ($required) { $js .= "if (!form." . $name . ".value.length) errors[errors.length] = 'the \\'" . $title . "\\' field is empty';" . $_josh["newline"]; } } elseif ($type == "password") { $rows .= '<td>' . draw_form_password($name, $value, $textlength, $maxlength) . '</td>'; if ($required) { $js .= "if (!form." . $name . ".value.length) errors[errors.length] = 'the \\'" . $title . "\\' field is empty';" . $_josh["newline"]; } } elseif ($type == "select") { $rows .= '<td>'; $rows .= draw_form_select($name, $value, $default, $required, false, $onchange); $rows .= '</td>'; } elseif ($type == "user") { $result = db_query("SELECT \n\t\t\t\t\t\t\t\t\t\t\tuserID, \n\t\t\t\t\t\t\t\t\t\t\tISNULL(nickname, firstname) first,\n\t\t\t\t\t\t\t\t\t\t\tlastname last \n\t\t\t\t\t\t\t\t\t\tFROM intranet_users\n\t\t\t\t\t\t\t\t\t\tWHERE isActive = 1\n\t\t\t\t\t\t\t\t\t\tORDER by lastname"); while ($r = db_fetch($result)) { $options[$r["userID"]] = $r["first"] . ", " . $r["last"]; } $rows .= '<td>'; $rows .= draw_form_select($name, $options, $default, $required, false, $onchange); $rows .= '</td>'; } elseif ($type == "department") { $rows .= '<td><select name="' . $name . '">'; $result = db_query("SELECT \n\t\t\t\t\t\t\t\t\t\t\tdepartmentID,\n\t\t\t\t\t\t\t\t\t\t\tdepartmentName,\n\t\t\t\t\t\t\t\t\t\t\tquoteLevel\n\t\t\t\t\t\t\t\t\t\tFROM intranet_departments\n\t\t\t\t\t\t\t\t\t\tWHERE isActive = 1\n\t\t\t\t\t\t\t\t\t\tORDER by precedence"); while ($r = db_fetch($result)) { $rows .= '<option value="' . $r["departmentID"] . '"'; if ($r["departmentID"] == $default) { $rows .= ' selected'; } $rows .= '>'; if ($r["quoteLevel"] == 2) { $rows .= " · "; } elseif ($r["quoteLevel"] == 3) { $rows .= " - "; } $rows .= $r["departmentName"] . '</option>'; } $rows .= '</select></td>'; } elseif ($type == "userpic") { $rows .= '<td>' . drawName($name, $value, $default, true, " ") . '</td>'; } elseif ($type == "textarea") { $rows .= '<td>' . draw_form_textarea($name, $value) . '</td>'; $js .= " tinyMCE.triggerSave();" . $_josh["newline"]; if ($required) { $js .= "if (!form." . $name . ".value.length || (form." . $name . ".value == '<p> </p>')) errors[errors.length] = 'the \\'" . $title . "\\' field is empty';" . $_josh["newline"]; } } elseif ($type == "textarea-plain") { $rows .= '<td>' . draw_form_textarea($name, $value, "noMceEditor") . '</td>'; if ($required) { $js .= "if (!form." . $name . ".value.length) errors[errors.length] = 'the \\'" . $title . "\\' field is empty';" . $_josh["newline"]; } } elseif ($type == "hidden") { $rows .= draw_form_hidden($name, $value); } elseif ($type == "submit") { $rows .= '<td colspan="2" align="center" class="bottom">' . draw_form_submit($title, "button") . '</td>'; } elseif ($type == "button") { $rows .= '<td colspan="2" align="center" class="bottom">' . draw_form_button($title, $value, "button") . '</td>'; } elseif ($type == "file") { $rows .= '<td>' . draw_form_file($name) . '</td>'; } $rows .= '</tr>' . $_josh["newline"]; } }
function addRow($field) { global $_josh; extract($field); $return = ""; if ($type == "hidden") { $return .= draw_form_hidden($name, $value); } else { if ($label) { $return .= '<dt class="' . $type . '">' . $label; if ($additional && $type == "checkboxes") { $return .= $additional; } $return .= '</dt>' . $_josh["newline"]; } $return .= '<dd class="' . $type . '">'; if ($type == "checkbox") { $return .= '<div class="checkbox_option">' . draw_form_checkbox($name, $value) . '<span class="option_name" onclick="javascript:form_checkbox_toggle(\'' . $name . '\');">' . $additional . '</span></div>'; } elseif ($type == "checkboxes") { if ($value) { $options = db_query("SELECT o.id, o.name, (SELECT COUNT(*) FROM {$linking_table} l WHERE l.option_id = o.id AND l.object_id = {$value}) checked FROM {$options_table} o ORDER BY o.name"); } else { $options = db_query("SELECT id, name, 0 checked FROM {$options_table} ORDER BY name"); } while ($o = db_fetch($options)) { $name = "chk_" . str_replace("_", "-", $options_table) . "_" . $o["id"]; $return .= '<div class="checkbox_option">' . draw_form_checkbox($name, $o["checked"]) . '<span class="option_name" onclick="javascript:form_checkbox_toggle(\'' . $name . '\');">' . $o["name"] . '</span></div>'; } } elseif ($type == "date") { $return .= draw_form_date($name, $value, false) . $additional; } elseif ($type == "datetime") { $return .= draw_form_date($name, $value, true) . $additional; } elseif ($type == "note") { $return .= "<div class='note'>" . $additional . "</div>"; } elseif ($type == "password") { $return .= draw_form_password($name, $value, $class, 255, false) . $additional; } elseif ($type == "radio") { if (!$options) { if (!$sql) { $sql = "SELECT id, name FROM options_" . str_replace("_id", "", $name); } $options = db_array($sql); } if ($append) { while (list($addkey, $addval) = each($append)) { $options[$addkey] = $addval; } } foreach ($options as $id => $description) { $return .= '<div class="radio_option">' . draw_form_radio($name, $id, $value == $id, $class) . $description . '</div>'; } } elseif ($type == "select") { if (!$options) { if (!$sql) { $sql = "SELECT id, name FROM options_" . str_replace("_id", "", $name); } $options = db_array($sql); } if ($append) { while (list($addkey, $addval) = each($append)) { $options[$addkey] = $addval; } } $return .= draw_form_select($name, $options, $value, $required, $class, $action); } elseif ($type == "submit") { $return .= draw_form_submit($value, $class) . $additional; } elseif ($type == "text") { $return .= draw_form_text($name, $value, $class, $maxlength, false, false) . $additional; } elseif ($type == "textarea") { $return .= draw_form_textarea($name, $value, $class) . $additional; } $return .= '</dd>' . $_josh["newline"]; } return $return; }
function draw($pageTitle) { global $rows, $_josh, $js; if ($js) { echo draw_javascript("function validate(form) {\n\t\t\t\tvar errors = new Array();\n\t\t\t\t" . $js . "\n\t\t\t\treturn form_errors(errors);\n\t\t\t}"); } ?> <a name="bottom"></a> <table class="left" cellspacing="1"> <tr> <td class="head" colspan="2"><?php echo $pageTitle; ?> </td> </tr> <form method="post" action="<?php echo $_josh["request"]["path_query"]; ?> " enctype="multipart/form-data" accept-charset="utf-8" onsubmit="javascript:return validate(this);"> <?php if (isset($_josh["referrer"])) { echo draw_form_hidden("return_to", $_josh["referrer"]["url"]); } echo $rows; ?> </form> </table> <?php }