Пример #1
0
function build_item_types_chart_data()
{
    $results = fetch_item_type_rs();
    while ($item_type_r = db_fetch_assoc($results)) {
        $num_total = fetch_item_instance_cnt($item_type_r['s_item_type']);
        if ($num_total > 0) {
            $data[] = array('display' => $item_type_r['s_item_type'], 'value' => $num_total);
        }
    }
    db_free_result($results);
    return $data;
}
Пример #2
0
function get_item_type_totals_rs()
{
    $item_type_rs = array();
    $itemresults = fetch_item_type_rs();
    if ($itemresults) {
        while ($item_type_r = db_fetch_assoc($itemresults)) {
            $type_total_items = fetch_item_instance_cnt($item_type_r['s_item_type']);
            if ($type_total_items > 0) {
                $item_type_r['count'] = $type_total_items;
                $item_type_rs[] = $item_type_r;
            }
        }
        db_free_result($itemresults);
    }
    return $item_type_rs;
}
Пример #3
0
function display_site_plugin_s_attribute_type_map_row($record_r, $row)
{
    global $PHP_SELF;
    global $ADMIN_TYPE;
    if (is_not_empty_array($record_r)) {
        echo "<input type=\"hidden\" name=\"exists_ind[{$row}]\" value=\"Y\">";
        echo "<input type=\"hidden\" name=\"sequence_number[{$row}]\" value=\"" . $record_r['sequence_number'] . "\">";
        echo "<td class=\"data\">" . get_input_field("variable[{$row}]", NULL, "Variable", "readonly", "Y", $record_r['variable'], FALSE) . "</td>";
    } else {
        echo "<input type=\"hidden\" name=\"exists_ind[{$row}]\" value=\"N\">";
        echo "<td class=\"data\">" . get_input_field("variable[{$row}]", NULL, "Variable", "text(10,20)", "Y", NULL, FALSE) . "</td>";
    }
    $item_type_groups[] = '*';
    $results = fetch_item_type_group_rs();
    if ($results) {
        while ($item_type_group_r = db_fetch_assoc($results)) {
            $item_type_groups[] = $item_type_group_r['s_item_type_group'];
        }
        db_free_result($results);
    }
    // this is to avoid confusion if system data is defined for non-existent s_item_type_groups
    if (!in_array($record_r['s_item_type_group'], $item_type_groups)) {
        $item_type_groups[] = $record_r['s_item_type_group'];
    }
    echo "\n<td class=\"data\">" . custom_select("s_item_type_group[{$row}]", $item_type_groups, "%value%", 1, $record_r['s_item_type_group'], 'value', NULL, NULL, "if(this.options[this.options.selectedIndex].value != '*'){this.form['s_item_type[{$row}]'].options[0].selected=true;}") . "</td>";
    $item_types[] = '*';
    $results = fetch_item_type_rs();
    if ($results) {
        while ($item_type_r = db_fetch_assoc($results)) {
            $item_types[] = $item_type_r['s_item_type'];
        }
        db_free_result($results);
    }
    // this is to avoid confusion if system data is defined for non-existent s_item_types
    if (!in_array($record_r['s_item_type'], $item_types)) {
        $item_types[] = $record_r['s_item_type'];
    }
    echo "\n<td class=\"data\">" . custom_select("s_item_type[{$row}]", $item_types, "%value%", 1, $record_r['s_item_type'], 'value', NULL, NULL, "if(this.options[this.options.selectedIndex].value != '*'){this.form['s_item_type_group[{$row}]'].options[0].selected=true;}") . "</td>";
    $attribute_types[] = '';
    $results = fetch_item_type_s_attribute_type_rs();
    if ($results) {
        while ($attribute_type_r = db_fetch_assoc($results)) {
            $attribute_types[] = $attribute_type_r['s_attribute_type'];
        }
        db_free_result($results);
    }
    // this is to avoid confusion if system data is defined for non-existent s_attribute_types
    if (!in_array($record_r['s_attribute_type'], $attribute_types)) {
        $attribute_types[] = $record_r['s_attribute_type'];
    }
    echo "\n<td class=\"data\">" . custom_select("s_attribute_type[{$row}]", $attribute_types, "%value%", 1, $record_r['s_attribute_type']) . "</td>";
    if (is_array($record_r) && is_lookup_attribute_type($record_r['s_attribute_type'])) {
        echo "<td class=\"data\"><input type=\"checkbox\" class=\"checkbox\" name=\"lookup_attribute_val_restrict_ind[{$row}]\" value=\"Y\"" . (strtoupper($record_r['lookup_attribute_val_restrict_ind']) == 'Y' ? 'CHECKED' : '') . ">";
    } else {
        echo "\n<td class=\"data\">&nbsp;</td>";
    }
    echo "\n<td class=\"data\">";
    if (is_not_empty_array($record_r)) {
        echo "<a href=\"{$PHP_SELF}?type={$ADMIN_TYPE}&op=delete_site_plugin_s_attribute_type_map&site_type=" . $record_r['site_type'] . "&sequence_number=" . $record_r['sequence_number'] . "\">Delete</a>";
    } else {
        echo "&nbsp;";
    }
    echo "\n</td>";
}
Пример #4
0
function get_list_item_types($s_item_type_group, $s_item_type = NULL)
{
    if (strlen($s_item_type_group) > 0) {
        $results = fetch_item_types_for_group_rs($s_item_type_group);
    } else {
        if (is_not_empty_array($s_item_type)) {
            //set of s_item_types.
            $results = fetch_item_type_for_item_types_rs($s_item_type);
        } else {
            $results = fetch_item_type_rs();
        }
    }
    if ($results) {
        while ($itemtype_r = db_fetch_assoc($results)) {
            $types[] = array('value' => $itemtype_r['s_item_type'], 'display' => $itemtype_r['description']);
        }
        db_free_result($results);
    }
    return $types;
}
Пример #5
0
                 while (list(, $plugin_r) = @each($plugin_list_r)) {
                     $field .= '<option value="' . $plugin_r['name'] . '"';
                     if ($plugin_r['name'] == 'OpenDbExportPlugin') {
                         $field .= ' SELECTED';
                     }
                     $field .= '>' . $plugin_r['description'] . "\n";
                 }
             }
             $field .= "</select>";
             echo format_field(get_opendb_lang_var('type'), $field);
             if (is_user_granted_permission(PERM_ADMIN_EXPORT)) {
                 echo format_field(get_opendb_lang_var('owner'), "\n<select name=\"owner_id\">" . "\n<option value=\"\">-------------- " . get_opendb_lang_var('all') . " --------------" . custom_select('owner_id', fetch_user_rs(PERM_USER_EXPORT), '%fullname% (%user_id%)', 'NA', ifempty($HTTP_VARS['owner_id'], get_opendb_session_var('user_id')), 'user_id') . "\n</select>");
             } else {
                 echo "<input type=\"hidden\" name=\"owner_id\" value=\"" . $HTTP_VARS['owner_id'] . "\">";
             }
             echo format_field(get_opendb_lang_var('item_type'), "<select name=\"s_item_type\">" . "\n<option value=\"\">-------------- " . get_opendb_lang_var('all') . " --------------" . custom_select('s_item_type', fetch_item_type_rs(), '%s_item_type% - %description%', 'NA', $HTTP_VARS['s_item_type'], 's_item_type') . "\n</select>");
             $lookup_results = fetch_status_type_rs(TRUE);
             if ($lookup_results && db_num_rows($lookup_results) > 1) {
                 echo format_field(get_opendb_lang_var('s_status_type'), checkbox_grid('s_status_type', $lookup_results, '%img%', 'VERTICAL', NULL));
                 // value
             }
             echo "</table>";
             echo "<input type=\"submit\" class=\"submit\" value=\"" . get_opendb_lang_var('submit') . "\">";
             echo "</form>";
             echo _theme_footer();
         }
     } else {
         //no guests or borrowers allowed!
         opendb_not_authorised_page(array(PERM_USER_EXPORT, PERM_ADMIN_EXPORT));
     }
 } else {
Пример #6
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;
}
Пример #7
0
function encode_search_javascript_arrays(&$item_type_rs, &$arrayOfUniqueCategories, &$item_attribute_type_rs)
{
    $buffer = "";
    $arrayOfCategoryTypes = array();
    $arrayOfUniqueAttributes = array();
    $itemTypeBlock = "";
    $attrTypeSelect = "";
    $jsArrayOfAttributes = "";
    $jsArrayOfAttributesCount = 0;
    $itemresults = fetch_item_type_rs();
    while ($item_type_r = db_fetch_assoc($itemresults)) {
        $results = fetch_item_attribute_type_rs($item_type_r['s_item_type'], NULL, 'prompt');
        // For the case where we have a s_item_type with no attributes associated with it!
        if ($results) {
            while ($item_attribute_type_r = db_fetch_assoc($results)) {
                // Do not include any attributes which do not exist as item attributes
                if ($item_attribute_type_r['s_field_type'] != 'TITLE' && $item_attribute_type_r['s_field_type'] != 'DURATION' && $item_attribute_type_r['s_field_type'] != 'STATUSTYPE' && $item_attribute_type_r['s_field_type'] != 'STATUSCMNT' && $item_attribute_type_r['s_field_type'] != 'ITEM_ID') {
                    // Only unique attributes should be added to attribute options object.
                    if (!is_array($arrayOfUniqueAttributes) || !in_array($item_attribute_type_r['s_attribute_type'], $arrayOfUniqueAttributes)) {
                        // This array, is only so we can make sure that we have unique attributes only!
                        $arrayOfUniqueAttributes[] = $item_attribute_type_r['s_attribute_type'];
                        $jsArrayOfUniqueAttributes .= "\narrayOfAttributes[{$jsArrayOfAttributesCount}] = new LookupAttribute(\"\",\"" . $item_attribute_type_r['s_attribute_type'] . "\",\"" . $item_attribute_type_r['s_attribute_type'] . " - " . $item_attribute_type_r['description'] . "\");";
                        $item_attribute_type_rs[] = $item_attribute_type_r;
                    }
                    $jsArrayOfAttributes .= "\narrayOfAttributes[{$jsArrayOfAttributesCount}] = new LookupAttribute(\"" . $item_type_r['s_item_type'] . "\",\"" . $item_attribute_type_r['s_attribute_type'] . "\",\"" . $item_attribute_type_r['s_attribute_type'] . " - " . $item_attribute_type_r['description'] . "\");";
                    $jsArrayOfAttributesCount++;
                }
            }
        }
        // Get the category_attribute_type for this item_type
        $category_attribute_type = fetch_sfieldtype_item_attribute_type($item_type_r['s_item_type'], 'CATEGORY');
        // We need this list further down, to work out which of the lookup items are actually categories.
        $arrayOfCategoryTypes[] = $category_attribute_type;
        $item_type_rs[] = $item_type_r;
    }
    // Give us the whole s_attribute_type_lookup table, whoo baby...
    $jsArrayOfLookupValues = "";
    $jsArrayOfLookupValuesCount = 0;
    $attresults = fetch_attribute_type_lookup_rs(NULL, 's_attribute_type ASC');
    while ($attribute_type_r = db_fetch_assoc($attresults)) {
        if ($attribute_type_r['s_field_type'] != 'ADDRESS' && $attribute_type_r['s_field_type'] != 'S_RATING') {
            if (in_array($attribute_type_r['s_attribute_type'], $arrayOfCategoryTypes) && (!is_array($arrayOfUniqueCategories) || !in_array($attribute_type_r['value'], $arrayOfUniqueCategories))) {
                $arrayOfUniqueCategories[$attribute_type_r['value']] = $attribute_type_r['display'];
            }
            $jsArrayOfLookupValues .= "\narrayOfLookupValues[{$jsArrayOfLookupValuesCount}] = new LookupAttribute(\"" . $attribute_type_r['s_attribute_type'] . "\",\"" . $attribute_type_r['value'] . "\",\"" . $attribute_type_r['display'] . "\");";
            $jsArrayOfLookupValuesCount++;
        }
    }
    $buffer .= "\n\narrayOfLookupValues = new Array({$jsArrayOfLookupValuesCount});";
    $buffer .= $jsArrayOfLookupValues;
    $buffer .= "\n\narrayOfAttributes = new Array({$jsArrayOfAttributesCount});";
    $buffer .= $jsArrayOfAttributes;
    $arrayOfUniqueCategoryValues = "";
    $arrayOfUniqueCatValuesCount = 0;
    // Now sort all values into alphabetical order!
    if (is_array($arrayOfUniqueCategories)) {
        asort($arrayOfUniqueCategories);
        reset($arrayOfUniqueCategories);
        while (list($value, $display) = each($arrayOfUniqueCategories)) {
            $arrayOfUniqueCatValues .= "\narrayOfUniqueCatValues[{$arrayOfUniqueCatValuesCount}] = new LookupAttribute('',\"{$value}\",\"{$display}\");";
            $arrayOfUniqueCatValuesCount++;
        }
    }
    // Now wrap and return
    return "\n<script language=\"JavaScript\">\n<!-- // hide from stupid browsers\n" . $buffer . "\n// -->\n</script>\n";
}
Пример #8
0
function perform_cloneitem_process(&$item_r, &$status_type_r, &$HTTP_VARS, &$footer_links_r)
{
    global $PHP_SELF;
    if (!is_exists_item_type($HTTP_VARS['s_item_type'])) {
        do_op_title($item_r, $status_type_r, 'clone_item');
        echo '<form action="' . $PHP_SELF . '">';
        echo '<input type="hidden" name="op" value="clone_item">';
        echo '<input type="hidden" name="item_id" value="' . $item_r['item_id'] . '">';
        echo '<input type="hidden" name="instance_no" value="' . $item_r['instance_no'] . '">';
        echo '<table class="cloneItemForm">';
        echo '<tr><th class="prompt">' . get_opendb_lang_var('item_type') . '</th>' . '<td class="data">' . custom_select('s_item_type', fetch_item_type_rs(), '%s_item_type% - %description%', '1', $item_r['s_item_type'], 's_item_type', NULL, NULL, NULL, FALSE, 'clone-s_item_type') . '</td></tr>';
        echo '</table>';
        echo '<input type="submit" class="submit" value="' . get_opendb_lang_var('submit') . '">';
        echo '</form>';
        echo format_help_block(get_opendb_lang_var('clone_item_help'));
        $footer_links_r[] = array(url => "item_display.php?item_id=" . $item_r['item_id'] . "&instance_no=" . $item_r['instance_no'], text => get_opendb_lang_var('back_to_item'));
    } else {
        // at this point we need to populate $HTTP_VARS with all data corresponding to a mapping between the old and possible new item type
        $HTTP_VARS = array_merge($HTTP_VARS, copy_item_to_http_vars($item_r, $HTTP_VARS['s_item_type']));
        // insert item for item type as specified in previous dialog
        $item_r['s_item_type'] = $HTTP_VARS['s_item_type'];
        do_op_title($item_r, $status_type_r, 'clone_item');
        $item_r['title'] = NULL;
        // fix for clone reverting to source item on insert.
        $item_r['item_id'] = NULL;
        $item_r['instance_no'] = NULL;
        $errors = NULL;
        $formContents = handle_new_or_site($HTTP_VARS['op'], $item_r, $status_type_r, $HTTP_VARS, $errors);
        if ($formContents !== FALSE) {
            echo $formContents;
        } else {
            echo format_error_block($errors);
        }
    }
}