Example #1
0
function get_export_type_item(&$exportPlugin, $item_id, $instance_no, $s_item_type, $title, $owner_id)
{
    $buffer = '';
    $buffer .= $exportPlugin->start_item($item_id, $s_item_type, $title);
    // export item (non instance level) attributes.
    $buffer .= export_type_item_attributes($exportPlugin, $item_id, NULL, $s_item_type);
    // $instance_no will have been provided if a single item.instance is being exported, otherwise
    // we are exporting all instances for this particular item.
    if (is_numeric($instance_no)) {
        $item_instance_r = fetch_item_instance_r($item_id, $instance_no);
        if (is_not_empty_array($item_instance_r)) {
            $buffer .= $exportPlugin->start_item_instance($item_instance_r['item_id'], $item_instance_r['instance_no'], $item_instance_r['owner_id'], $item_instance_r['borrow_duration'], $item_instance_r['s_status_type'], $item_instance_r['status_comment'], $item_instance_r['update_on']);
            $buffer .= export_type_item_attributes($exportPlugin, $item_id, $item_instance_r['instance_no'], $s_item_type);
            $buffer .= $exportPlugin->end_item_instance();
        }
    } else {
        $iiresults = fetch_item_instance_rs($item_id, $owner_id);
        if ($iiresults) {
            while ($item_instance_r = db_fetch_assoc($iiresults)) {
                $buffer .= $exportPlugin->start_item_instance($item_instance_r['item_id'], $item_instance_r['instance_no'], $item_instance_r['owner_id'], $item_instance_r['borrow_duration'], $item_instance_r['s_status_type'], $item_instance_r['status_comment'], $item_instance_r['update_on']);
                $buffer .= export_type_item_attributes($exportPlugin, $item_id, $item_instance_r['instance_no'], $s_item_type);
                $buffer .= $exportPlugin->end_item_instance();
            }
            db_free_result($iiresults);
        }
    }
    $buffer .= $exportPlugin->end_item();
    return $buffer;
}
Example #2
0
function insert_item_instance_relationships($item_id, $related_item_id, $related_instance_no)
{
    $instance_no_r = NULL;
    $results = fetch_item_instance_rs($item_id);
    if ($results) {
        while ($item_instance_r = db_fetch_assoc($results)) {
            $instance_no_r[] = $item_instance_r['instance_no'];
        }
        db_free_result($results);
    }
    // todo - should this be locked?!
    if (is_array($instance_no_r)) {
        while (list(, $instance_no) = each($instance_no_r)) {
            insert_item_instance_relationship($item_id, $instance_no, $related_item_id, $related_instance_no);
        }
    }
}
Example #3
0
function get_instance_info_block($item_r, $HTTP_VARS, &$instance_info_links_r)
{
    $buffer = '<div id="instanceInfo">';
    $buffer .= "<h3>" . get_opendb_lang_var('instance_info') . "</h3>";
    $results = fetch_item_instance_rs($item_r['item_id'], NULL);
    if ($results) {
        $buffer .= "<table>" . "\n<tr class=\"navbar\">" . "\n<th>" . get_opendb_lang_var('instance') . "</th>" . "\n<th>" . get_opendb_lang_var('owner') . "</th>" . "\n<th>" . get_opendb_lang_var('action') . "</th>" . "\n<th>" . get_opendb_lang_var('status') . "</th>" . "\n<th>" . get_opendb_lang_var('status_comment') . "</th>";
        if (get_opendb_config_var('borrow', 'enable') !== FALSE) {
            if (get_opendb_config_var('borrow', 'include_borrower_column') !== FALSE) {
                $buffer .= "\n<th>" . get_opendb_lang_var('borrower') . "</th>";
            }
            $buffer .= "\n<th>" . get_opendb_lang_var('borrow_status') . "</th>";
            if (get_opendb_config_var('borrow', 'duration_support') !== FALSE) {
                if (is_item_borrowed($item_r['item_id'], $item_r['instance_no'])) {
                    $buffer .= "\n<th>" . get_opendb_lang_var('due_date') . "</th>";
                } else {
                    $buffer .= "\n<th>" . get_opendb_lang_var('borrow_duration') . "</th>";
                }
            }
        }
        $buffer .= "\n</tr>";
        $toggle = TRUE;
        $numrows = db_num_rows($results);
        while ($item_instance_r = db_fetch_assoc($results)) {
            if ($toggle) {
                $color = "oddRow";
            } else {
                $color = "evenRow";
            }
            $toggle = !$toggle;
            $buffer .= get_item_status_row($color, array_merge($item_r, $item_instance_r), $numrows > 1 && $item_r['instance_no'] === $item_instance_r['instance_no']);
        }
        $buffer .= "\n</table>";
    } else {
        // No instances found, because user has been deactivated and/or items are hidden.
        $buffer .= get_opendb_lang_var('no_records_found');
    }
    if (is_user_granted_permission(PERM_ITEM_OWNER)) {
        if (get_opendb_config_var('item_input', 'item_instance_support') !== FALSE) {
            array_push($instance_info_links_r, array(url => "item_input.php?op=newinstance&item_id=" . $item_r['item_id'] . "&instance_no=" . $item_r['instance_no'], text => get_opendb_lang_var('new_item_instance')));
        }
        if (get_opendb_config_var('item_input', 'clone_item_support') !== FALSE) {
            array_push($instance_info_links_r, array(url => "item_input.php?op=clone_item&item_id=" . $item_r['item_id'] . "&instance_no=" . $item_r['instance_no'], text => get_opendb_lang_var('clone_item')));
        }
    }
    $buffer .= "</div>";
    return $buffer;
}