Пример #1
0
function get_upload_form($HTTP_VARS)
{
    global $PHP_SELF;
    $buffer .= "\n<form name=\"main\" action=\"{$PHP_SELF}\" method=\"POST\" enctype=\"multipart/form-data\">";
    $buffer .= "\n<input type=\"hidden\" name=\"op\" value=\"upload\">";
    $buffer .= "\n<table>";
    if (is_user_granted_permission(PERM_ADMIN_IMPORT)) {
        $buffer .= format_field(get_opendb_lang_var('owner'), custom_select('owner_id', fetch_user_rs(PERM_USER_IMPORT), '%fullname% (%user_id%)', 1, ifempty($HTTP_VARS['owner_id'], get_opendb_session_var('user_id')), 'user_id'));
    } else {
        $buffer .= "\n<input type=\"hidden\" name=\"owner_id\" value=\"" . $HTTP_VARS['owner_id'] . "\">";
    }
    $buffer .= format_field(get_opendb_lang_var('item_type'), single_select('s_item_type', fetch_item_type_rs(TRUE), "%value% - %display%", NULL, $HTTP_VARS['s_item_type']));
    $buffer .= format_field(get_opendb_lang_var('file'), "<input type=\"file\" class=\"file\" size=\"25\" name=\"uploadfile\">");
    $buffer .= "\n</table>";
    $buffer .= "\n<input type=\"submit\" class=\"submit\" value=\"" . get_opendb_lang_var('submit') . "\">";
    $buffer .= "\n</form>";
    return $buffer;
}
Пример #2
0
function get_item_input_field($fieldname, $item_attribute_type_r, $item_r, $value = NULL, $dowrap = TRUE, $prompt_mask = NULL, $onchange_event = NULL, $disabled = FALSE)
{
    if (is_array($item_attribute_type_r)) {
        $s_attribute_type = $item_attribute_type_r['s_attribute_type'];
        $order_no = $item_attribute_type_r['order_no'];
        $prompt = $item_attribute_type_r['prompt'];
        $input_type = $item_attribute_type_r['input_type'];
        $compulsory_ind = $item_attribute_type_r['compulsory_ind'];
        $widget['type'] = $item_attribute_type_r['input_type'];
        $widget['args'][0] = $item_attribute_type_r['input_type_arg1'];
        $widget['args'][1] = $item_attribute_type_r['input_type_arg2'];
        $widget['args'][2] = $item_attribute_type_r['input_type_arg3'];
        $widget['args'][3] = $item_attribute_type_r['input_type_arg4'];
        $widget['args'][4] = $item_attribute_type_r['input_type_arg5'];
    }
    if ($item_attribute_type_r['multi_attribute_ind'] == 'Y') {
        $multi_value = TRUE;
        if (!is_array($value)) {
            $old_value = ifempty($value, "");
            unset($value);
            $value[] = $old_value;
        }
    } else {
        $multi_value = FALSE;
        // an array will be a lookup value
        if (!is_array($value)) {
            // Escape all html entities so they are displayed correctly!
            if (strlen($value) > 0) {
                $value = htmlspecialchars($value);
            }
        }
    }
    $field = NULL;
    $field_mask = NULL;
    // Now we have to work out how to parse the input_type
    if ($item_attribute_type_r['input_type'] == 'hidden') {
        return hidden_field($fieldname, $value);
    } else {
        if ($item_attribute_type_r['input_type'] == 'readonly') {
            $field = readonly_field($fieldname, $value);
        } else {
            if ($item_attribute_type_r['input_type'] == 'textarea' || $item_attribute_type_r['input_type'] == 'htmlarea') {
                // arg[0] = rows, arg[1] = cols, arg[2] = length
                $field = textarea_field($fieldname, $prompt, $widget['args']['0'], $widget['args']['1'], $widget['widget']['2'], $compulsory_ind, $value, $onchange_event, $disabled);
            } else {
                if ($item_attribute_type_r['input_type'] == 'text') {
                    // arg[0] = length of field, arg[1] = maxlength of field
                    $field = text_field($fieldname, $prompt, $widget['args']['0'], $widget['args']['1'], $compulsory_ind, $value, $onchange_event, $disabled, $multi_value);
                } else {
                    if ($item_attribute_type_r['input_type'] == 'password') {
                        // arg[0] = length of field, arg[1] = maxlength of field
                        $field = password_field($fieldname, $prompt, $widget['args']['0'], $widget['args']['1'], $compulsory_ind, $value, $onchange_event, $disabled, $multi_value);
                    } else {
                        if ($item_attribute_type_r['input_type'] == 'email') {
                            // arg[0] = length of field, arg[1] = maxlength of field
                            $field = email_field($fieldname, $prompt, $widget['args']['0'], $widget['args']['1'], $compulsory_ind, $value, $onchange_event, $disabled, $multi_value);
                        } else {
                            if ($item_attribute_type_r['input_type'] == 'filtered') {
                                // arg[0] = length of field, arg[1] = maxlength of field, arg[2] = legalChars
                                $field = filtered_field($fieldname, $prompt, $widget['args']['0'], $widget['args']['1'], $widget['args']['2'], $compulsory_ind, $value, $onchange_event, $disabled, $multi_value);
                            } else {
                                if ($item_attribute_type_r['input_type'] == 'datetime') {
                                    // arg[0] = datetime mask, arg[1] = auto_datetime
                                    $field = datetime_field($fieldname, $prompt, ifempty($widget['args']['0'], 'DD/MM/YYYY'), $widget['args']['1'], $compulsory_ind, $value, $onchange_event, $disabled, $multi_value);
                                } else {
                                    if ($item_attribute_type_r['input_type'] == 'number') {
                                        // arg[0] = length of field, arg[0] = maxlength of field
                                        $field = number_field($fieldname, $prompt, $widget['args']['0'], $widget['args']['0'], $compulsory_ind, $value, $onchange_event, $disabled, $multi_value);
                                    } else {
                                        if ($item_attribute_type_r['input_type'] == 'simple_checkbox') {
                                            // arg[0] = checked
                                            $field = checkbox_field($fieldname, $prompt, strcasecmp(trim($widget['args']['0']), 'CHECKED') === 0, $value, $onchange_event, $disabled);
                                        } else {
                                            if ($item_attribute_type_r['input_type'] == 'checkbox') {
                                                // arg[0] = checked, arg[1] = unchecked
                                                $field = enhanced_checkbox_field($fieldname, $prompt, $widget['args']['0'], $widget['args']['1'], $value, $onchange_event, $disabled);
                                            } else {
                                                if ($item_attribute_type_r['input_type'] == 'checkbox_grid') {
                                                    $lookup_results = fetch_attribute_type_lookup_rs($s_attribute_type, 'order_no, ' . get_lookup_order_by($widget['args']['0']) . ' ASC');
                                                    if ($lookup_results) {
                                                        //arg[0] = display_mask, arg[1] = orientation
                                                        $field = checkbox_grid($fieldname, $lookup_results, $widget['args']['0'], $widget['args']['1'], $value, $disabled);
                                                    }
                                                } else {
                                                    if ($item_attribute_type_r['input_type'] == 'radio_grid') {
                                                        $lookup_results = fetch_attribute_type_lookup_rs($s_attribute_type, 'order_no, ' . get_lookup_order_by($widget['args']['0']) . ' ASC');
                                                        if ($lookup_results) {
                                                            //arg[0] = display_mask, arg[1] = orientation
                                                            $field = radio_grid($fieldname, $lookup_results, $widget['args']['0'], $widget['args']['1'], $value, $disabled);
                                                        }
                                                    } else {
                                                        if ($item_attribute_type_r['input_type'] == 'value_radio_grid') {
                                                            //arg[0] = "comma delimited list of values"
                                                            $field = value_radio_grid($fieldname, explode(',', $widget['args']['0']), $value, $disabled);
                                                        } else {
                                                            if ($item_attribute_type_r['input_type'] == 'single_select') {
                                                                $lookup_results = fetch_attribute_type_lookup_rs($s_attribute_type, 'order_no, ' . get_lookup_order_by($widget['args']['0']) . ' ASC');
                                                                if ($lookup_results) {
                                                                    //arg[0] = display mask, arg[1] = max value length
                                                                    $field = single_select($fieldname, $lookup_results, $widget['args']['0'], $widget['args']['1'], $value, $onchange_event, $disabled);
                                                                }
                                                            } else {
                                                                if ($item_attribute_type_r['input_type'] == 'multi_select') {
                                                                    $lookup_results = fetch_attribute_type_lookup_rs($s_attribute_type, 'order_no, ' . get_lookup_order_by($widget['args']['0']) . ' ASC');
                                                                    if ($lookup_results) {
                                                                        //arg[0] = display mask, arg[1] = max value length, arg[2] = select box number of visible rows
                                                                        $field = multi_select($fieldname, $lookup_results, $widget['args']['0'], $widget['args']['1'], $widget['args']['2'], $value, $onchange_event, $disabled);
                                                                    }
                                                                } else {
                                                                    if ($item_attribute_type_r['input_type'] == 'value_select') {
                                                                        //arg[0] = "comma delimited list of values"; arg[1] = number of visible rows (Defaults to single select
                                                                        $field = value_select($fieldname, explode(',', $widget['args']['0']), $widget['args']['1'], $value, $onchange_event, $disabled);
                                                                    } else {
                                                                        if ($item_attribute_type_r['input_type'] == 'review_options') {
                                                                            //arg[1] = display_mask, arg[1] = orientation
                                                                            $lookup_results = fetch_attribute_type_lookup_rs($s_attribute_type, 'value DESC');
                                                                            //We want the rows highest value first.
                                                                            if ($lookup_results) {
                                                                                $field = review_options($fieldname, $lookup_results, $widget['args']['0'], $widget['args']['1'], $value, $disabled);
                                                                            }
                                                                        } else {
                                                                            if ($item_attribute_type_r['input_type'] == 'url') {
                                                                                //arg[0] = length of field, arg[1] = maxlength of field, arg[2] = extensions
                                                                                $field = url($fieldname, $item_r, $item_attribute_type_r, $prompt, $widget['args']['0'], $widget['args']['1'], $widget['args']['2'], $value, $onchange_event, $disabled, $multi_value);
                                                                            } else {
                                                                                $field = ">>> ERROR (input_type = {$input_type}) <<<";
                                                                            }
                                                                        }
                                                                    }
                                                                }
                                                            }
                                                        }
                                                    }
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }
    if ($dowrap) {
        return format_item_data_field($item_attribute_type_r, $field, $prompt_mask);
    } else {
        return $field;
    }
}
Пример #3
0
function display_site_plugin_blocks($HTTP_VARS, $item_r = NULL)
{
    global $titleMaskCfg;
    $site_plugin_rs = get_site_plugin_rs($HTTP_VARS, $item_r);
    if (is_array($site_plugin_rs)) {
        echo "<div id=\"site-add-container\">";
        echo "<ul id=\"site-add-menu\">";
        reset($site_plugin_rs);
        $first = TRUE;
        while (list(, $site_plugin_r) = each($site_plugin_rs)) {
            echo "<li" . ($first ? ' class="first activeTab"' : ' class=""') . " id=\"menu-" . $site_plugin_r['site_type'] . "\" onClick=\"return activateTab('" . $site_plugin_r['site_type'] . "', 'site-add-menu', 'site-add-content', 'activeTab', 'sitePlugin'); return false;\">" . $site_plugin_r['title'] . "</li>";
            if ($first) {
                $first = FALSE;
            }
        }
        echo "</ul>";
        echo "\n<div id=\"site-add-content\">";
        reset($site_plugin_rs);
        while (list(, $site_plugin_r) = each($site_plugin_rs)) {
            echo "\n<div class=\"sitePlugin" . ($site_plugin_r['checked_ind'] != 'Y' ? "Hidden" : "") . "\" id=\"" . $site_plugin_r['site_type'] . "\">";
            $title = "<img src=\"./images/site/" . $site_plugin_r['image'] . "\" title=\"" . strip_tags($site_plugin_r['description']) . "\" alt=\"" . strip_tags($site_plugin_r['description']) . "\">";
            echo "<h3>" . $site_plugin_r['title'] . "</h3>";
            echo theme_image("images/site/" . $site_plugin_r['image'], strip_tags($site_plugin_r['description']), "siteLogo");
            echo "<h4>" . $site_plugin_r['description'] . "</h4>";
            echo "\n<form action=\"item_input.php\" method=\"GET\">";
            if (is_exists_item_type($HTTP_VARS['s_item_type'])) {
                echo "\n<input type=\"hidden\" name=\"s_item_type\" value=\"" . $HTTP_VARS['s_item_type'] . "\">";
            } else {
                echo "\n<label for=\"" . $site_plugin_r['site_type'] . "-s_item_type\">" . get_opendb_lang_var('item_type') . "</label>";
                echo single_select("s_item_type", fetch_item_type_for_item_types_rs($site_plugin_r['s_item_type'], TRUE), "%value% - %display%", NULL, NULL, NULL, FALSE, $site_plugin_r['site_type'] . "-s_item_type");
            }
            echo "<input type=hidden name=\"site_type\" value=\"" . $site_plugin_r['site_type'] . "\">";
            echo "<input type=hidden name=\"owner_id\" value=\"" . $HTTP_VARS['owner_id'] . "\">";
            echo "<input type=hidden name=\"s_status_type\" value=\"" . $HTTP_VARS['s_status_type'] . "\">";
            echo "<input type=hidden name=\"item_id\" value=\"" . $HTTP_VARS['item_id'] . "\">";
            echo "<input type=hidden name=\"instance_no\" value=\"" . $HTTP_VARS['instance_no'] . "\">";
            echo "<input type=hidden name=\"parent_item_id\" value=\"" . $HTTP_VARS['parent_item_id'] . "\">";
            echo "<input type=hidden name=\"parent_instance_no\" value=\"" . $HTTP_VARS['parent_instance_no'] . "\">";
            if (is_array($site_plugin_r['input_fields'])) {
                while (list(, $input_field_r) = each($site_plugin_r['input_fields'])) {
                    if ($input_field_r['type'] == 'hidden') {
                        echo "<input type=hidden name=\"" . $input_field_r['name'] . "\" value=\"" . htmlspecialchars($input_field_r['value']) . "\">";
                    } else {
                        echo "\n<label for=\"" . $site_plugin_r['site_type'] . "-" . $field_r['name'] . "\">" . $input_field_r['prompt'] . "</label>";
                        while (list(, $field_r) = each($input_field_r['fieldset'])) {
                            echo "<input id=\"" . $site_plugin_r['site_type'] . "-" . $field_r['name'] . "\" class=\"text\" type=\"text\" name=\"" . $field_r['name'] . "\" value=\"" . htmlspecialchars($field_r['value']) . "\">";
                        }
                    }
                }
            }
            echo "<input type=hidden name=\"op\" value=\"site-search\">";
            echo "<input class=\"submit\" type=submit value=\"" . get_opendb_lang_var('site_search', 'site', $site_plugin_r['title']) . "\">";
            echo "</form>";
            echo "\n</div>\n";
        }
        echo "</div>";
    }
    //if($results)
    // add manual entry record
    if (!is_array($item_r)) {
        echo "<div id=\"site-add-manual\">";
        echo "<h3>" . get_opendb_lang_var('manual_entry') . "</h3>";
        echo "\n<form action=\"item_input.php\" method=\"GET\">";
        echo "<input type=\"hidden\" name=\"owner_id\" value=\"" . $HTTP_VARS['owner_id'] . "\">";
        echo "<input type=\"hidden\" name=\"s_status_type\" value=\"" . $HTTP_VARS['s_status_type'] . "\">";
        echo "<input type=\"hidden\" name=\"item_id\" value=\"" . $HTTP_VARS['item_id'] . "\">";
        echo "<input type=\"hidden\" name=\"instance_no\" value=\"" . $HTTP_VARS['instance_no'] . "\">";
        echo "<input type=\"hidden\" name=\"parent_item_id\" value=\"" . $HTTP_VARS['parent_item_id'] . "\">";
        echo "<input type=\"hidden\" name=\"parent_instance_no\" value=\"" . $HTTP_VARS['parent_instance_no'] . "\">";
        if (is_exists_item_type($HTTP_VARS['s_item_type'])) {
            echo "\n<input type=\"hidden\" name=\"s_item_type\" value=\"" . $HTTP_VARS['s_item_type'] . "\">";
        } else {
            echo "\n<label for=\"manual-s_item_type\">" . get_opendb_lang_var('item_type') . "</label>";
            echo single_select("s_item_type", fetch_item_type_rs(TRUE), "%value% - %display%", NULL, NULL, NULL, FALSE, 'manual-s_item_type');
        }
        echo "\n<input type=\"hidden\" name=\"op\" value=\"new\">";
        echo "<input type=\"submit\" class=\"submit\" value=\"" . get_opendb_lang_var('submit') . "\">";
        echo "</form>";
        echo "</div>";
    }
    return is_array($site_plugin_rs) || !is_array($item_r);
}