Example #1
0
function RenderParamSpec($param_spec, $divname = "")
{
    $current_val = null;
    if (array_key_exists("Value", $param_spec)) {
        $current_val = $param_spec["Value"];
    }
    if (!array_key_exists("FieldName", $param_spec) || !array_key_exists("FieldType", $param_spec)) {
        log_error("renderlib.php->RenderParamInput", 'Bad param_spec: no FieldName or FieldType.');
        return;
    }
    $fn = $param_spec["FieldName"];
    $ft = $param_spec["FieldType"];
    if ($ft == "Selection") {
        if (!isset($param_spec["Selection"])) {
            log_error("renderlib.php->RenderParamInput", 'Bad param_spec for ' . $fn . ": No selection element.");
            return;
        }
        $sel = $param_spec["Selection"];
        if (!is_array($sel)) {
            log_error("renderlib.php->RenderParamInput", 'Bad param_spec for ' . $fn . ": Selection element is not an array.");
            return;
        }
    }
    if (!in_array($ft, array("Text", "Password", "Boolean", "Selection", "TextArea", "Date", "File", "Hidden"))) {
        log_error("renderlib.php->RenderParamInput", 'Bad param_spec for ' . $fn . '": FieldType "' . $ft . '" not valid."');
        return;
    }
    if (isset($param_spec["Caption"])) {
        $cap = $param_spec["Caption"];
    } else {
        $cap = $fn;
    }
    if (isset($param_spec["Instructions"])) {
        $ins = $param_spec["Instructions"];
    } else {
        $ins = "";
    }
    if (isset($param_spec["Style"])) {
        $style = $param_spec["Style"];
    } else {
        $style = "";
    }
    if (isset($param_spec["Rows"])) {
        $rows = intval($param_spec["Rows"]);
    } else {
        $rows = 3;
    }
    if (isset($param_spec["Columns"])) {
        $columns = intval($param_spec["Columns"]);
    } else {
        $columns = "";
    }
    if ($ft == "Text") {
        render_text_field($cap, $fn, $style, $divname, $current_val);
        return;
    }
    if ($ft == "Password") {
        render_password_field($cap, $fn, $style, $divname, $current_val);
        return;
    }
    if ($ft == "Boolean") {
        render_boolean_field($cap, $fn, $divname, $current_val);
        return;
    }
    if ($ft == "Selection") {
        render_selection_field($cap, $fn, $sel, $style, $divname, $current_val);
        return;
    }
    if ($ft == "TextArea") {
        render_textarea_field($cap, $fn, $rows, $columns, $style, $divname, $current_val);
        return;
    }
    if ($ft == "Date") {
        render_date_field($cap, $fn, $style, $divname, $current_val);
        return;
    }
    if ($ft == "Hidden") {
        render_hidden_field($fn, $divname, $current_val);
        return;
    }
    if ($ft == "File") {
        render_file_field($cap, $fn, $style, $divname, $current_val);
        return;
    }
    log_error("renderlib.php->RenderParamInput", "Should be unreachable code. {$ft}=" . $ft);
}
     echo '<div style="clear: both;"></div>' . "\n";
     echo '<div class="btn_form_submit_div">';
     echo '<input class="btn_form_submit" type="submit" value="Submit" name="Add">' . "\n";
     echo '</div></form>';
 } else {
     echo '<div class="wo_not_avaliable">No Workers Avaliable for Assignments.</div>' . "\n";
 }
 echo '</div>' . "\n";
 //}
 //if(!empty($currentworkers))
 //{
 echo '<div id="wo_aw_bot" class="inputform_area">' . "\n";
 if (!empty($currentworkers)) {
     echo '<form action="wo_assign_workers.php" method="post">' . "\n";
     echo '<input type="hidden" name="wid" value="' . $wid . '" />' . "\n";
     render_selection_field("Worker to Unassign", "Workers", $currentworkers, "wo_aw_");
     echo '<div style="clear: both;"></div>' . "\n";
     echo '<div class="btn_form_submit_div">';
     echo '<input class="btn_form_submit" type="submit" value="Submit" name="Remove">' . "\n";
     echo '</div></form>';
 } else {
     echo '<div class="wo_not_avaliable">No Workers to Unassign</div>' . "\n";
 }
 echo '</div>' . "\n";
 //}
 echo '</div>' . "\n";
 echo '<div id="worker_info_block">' . "\n";
 if (!empty($currentworkers)) {
     echo '<div class="wo_aw_info">' . "\n";
     echo '<div id="wo_aw_title">Currently Assigned Workers</div>' . "\n";
     foreach ($currentworkers as $c) {