Пример #1
0
function get_op_confirm_form($PHP_SELF, $confirm_message, $HTTP_VARS)
{
    $formContents = "\n<form class=\"confirmForm\" action=\"{$PHP_SELF}\" method=\"POST\">";
    $formContents .= "<p>" . $confirm_message . "</p>" . get_url_fields($HTTP_VARS, NULL, array('confirmed')) . "<fieldset>" . "<label for=\"confirm_yes\">" . get_opendb_lang_var('yes') . "</label>" . "<input type=\"radio\" class=\"radio\" name=\"confirmed\" id=\"confirm_yes\" value=\"true\">" . "<label for=\"confirm_no\">" . get_opendb_lang_var('no') . "</label>" . "<input type=\"radio\" class=\"radio\" name=\"confirmed\" id=\"confirm_no\" value=\"false\" CHECKED>" . "</fieldset>" . "<input type=\"submit\" class=\"submit\" value=\"" . get_opendb_lang_var('submit') . "\">" . "</form>\n";
    return $formContents;
}
Пример #2
0
/**
   @param $edit_op - indicates the operation that spawned this table, will be used
   by the refresh operation.
*/
function display_edit_table($edit_op, $update_op, $headers, $display_functioname, $context_http_vars, $results)
{
    global $PHP_SELF;
    global $ADMIN_TYPE;
    global $HTTP_VARS;
    echo "\n<form name=\"editform\" action=\"{$PHP_SELF}\" method=\"POST\">";
    echo "\n<input type=\"hidden\" name=\"type\" value=\"" . $ADMIN_TYPE . "\">";
    echo "\n<input type=\"hidden\" name=\"op\" value=\"{$edit_op}\">";
    echo get_url_fields($context_http_vars, NULL, array('op', 'type'));
    echo "<table>";
    echo "\n<tr class=\"navbar\">";
    for ($i = 0; $i < count($headers); $i++) {
        echo "\n<th>" . $headers[$i] . "</th>";
    }
    echo "\n</tr>";
    $row = 0;
    if ($results) {
        while ($result_r = db_fetch_assoc($results)) {
            echo "\n<tr>";
            $display_functioname($result_r, $row);
            echo "\n</tr>";
            $row++;
        }
        db_free_result($results);
    }
    if (is_numeric($HTTP_VARS['blank_rows'])) {
        $blank_rows = (int) $HTTP_VARS['blank_rows'];
    } else {
        $blank_rows = 5;
    }
    for ($i = $row; $i < $row + $blank_rows; $i++) {
        echo "\n<tr>";
        $display_functioname(array(), $i);
        echo "\n</tr>";
    }
    echo "</table>";
    echo get_input_field("blank_rows", NULL, NULL, "value_select(\"1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20\",1)", "N", ifempty($HTTP_VARS['blank_rows'], "5"), FALSE, NULL, "this.form.submit();");
    echo "<input type=\"button\" class=\"button\" value=\"Refresh\" onclick=\"this.form['op'].value='{$edit_op}'; this.form.submit();\">";
    echo "<input type=\"button\" class=\"button\" value=\"Update\" onclick=\"this.form['op'].value='{$update_op}'; this.form.submit();\">";
    echo "</form>";
}
Пример #3
0
 //dummy
 if ($HTTP_VARS['op'] == 'checkout') {
     echo "\n<input type=\"hidden\" name=\"borrower_id\" value=\"" . $HTTP_VARS['borrower_id'] . "\">";
 }
 echo "\n<table class=\"borrowerForm\">";
 echo get_item_input_field('alt_item_id', $attribute_type_r, NULL);
 echo "\n</table>";
 echo "<input type=\"submit\" class=\"submit\" value=\"" . get_opendb_lang_var('add_item') . "\">";
 $HTTP_VARS['checkout_item_instance_rs'] = get_encoded_item_instance_rs($altid_item_instance_rs);
 echo get_url_fields(NULL, array('checkout_item_instance_rs' => $HTTP_VARS['checkout_item_instance_rs']));
 if (is_not_empty_array($HTTP_VARS['checkout_item_instance_rs'])) {
     if ($HTTP_VARS['op'] == 'checkout') {
         echo "<input type=\"button\" class=\"button\" onclick=\"doFormSubmit(this.form, 'item_borrow.php', 'quick_check_out')\" value=\"" . get_opendb_lang_var('check_out_item(s)') . "\">";
     } else {
         $HTTP_VARS['sequence_number'] = get_borrowed_item_sequence_number_r($altid_item_instance_rs);
         echo get_url_fields(NULL, array('sequence_number' => $HTTP_VARS['sequence_number']));
         echo "<input type=\"button\" class=\"button\" onclick=\"doFormSubmit(this.form, 'item_borrow.php', 'check_in')\" value=\"" . get_opendb_lang_var('check_in_item(s)') . "\">";
     }
 }
 echo "</form>";
 unset($HTTP_VARS['alt_item_id']);
 $listingObject = new HTML_Listing($PHP_SELF, $HTTP_VARS);
 $listingObject->setNoRowsMessage(get_opendb_lang_var('no_records_found'));
 if (is_numeric($listingObject->getItemsPerPage())) {
     $listingObject->setTotalItems(count($altid_item_instance_rs));
 }
 if (is_array($altid_item_instance_rs)) {
     sort_item_listing($altid_item_instance_rs, $listingObject->getCurrentOrderBy(), $listingObject->getCurrentSortOrder());
     // Now get the bit we actually want for this page.
     if (is_numeric($listingObject->getItemsPerPage())) {
         $altid_item_instance_rs = array_slice($altid_item_instance_rs, $listingObject->getStartIndex(), $listingObject->getItemsPerPage());
Пример #4
0
function getListingFiltersBlock()
{
    global $PHP_SELF;
    global $HTTP_VARS;
    $buffer = '';
    if ($HTTP_VARS['listings.filters'] != 'N' && get_opendb_config_var('listings.filters', 'enable') !== FALSE) {
        $excluded_vars_list = NULL;
        $buffer .= "<div id=\"listing-filters\" class=\"menuContainer toggleContainer\">";
        $buffer .= "<span id=\"listing-filters-toggle\" class=\"menuToggle toggleHidden\" onclick=\"return toggleVisible('listing-filters');\">" . get_opendb_lang_var('listing_filters') . "</span>";
        $buffer .= "<div id=\"listing-filters-content\" class=\"menuContent elementHidden\"\">";
        $buffer .= "<h2 class=\"menu\">" . get_opendb_lang_var('listing_filters') . "</h2>";
        $buffer .= "<form name=\"listing-filters\" action=\"{$PHP_SELF}\" method=\"GET\">";
        $buffer .= "<ul>";
        if (get_opendb_config_var('listings.filters', 'show_owner_lov') !== FALSE) {
            $excluded_vars_list[] = 'owner_id';
            $buffer .= "<li><label for=\"select-owner_id\">" . get_opendb_lang_var('owner_id') . "</label>\n\t\t\t\t<select id=\"select-owner_id\" name=\"owner_id\">\n\t\t\t\t<option value=\"\"></option>" . custom_select('owner_id', fetch_user_rs(PERM_ITEM_OWNER), '%fullname% (%user_id%)', 'NA', $HTTP_VARS['owner_id'], 'user_id') . "\n</select></li>";
        }
        if (get_opendb_config_var('listings.filters', 'show_s_status_type_lov') !== FALSE) {
            if (!is_array($HTTP_VARS['s_status_type']) || $HTTP_VARS['search_list'] != 'y' && $HTTP_VARS['attribute_list'] != 'y') {
                $results = fetch_status_type_rs();
                if ($results && db_num_rows($results) > 1) {
                    $excluded_vars_list[] = 's_status_type';
                    $buffer .= "<li><label for=\"select-s_status_type\">" . get_opendb_lang_var('s_status_type') . "</label>\n\t\t\t\t\t\t<select id=\"select-s_status_type\" name=\"s_status_type\">\n\t\t\t\t\t\t<option value=\"\"></option>" . custom_select('owner_id', $results, '%s_status_type% - %description%', 'NA', $HTTP_VARS['s_status_type'], 's_status_type') . "\n</select></li>";
                }
            }
        }
        if (get_opendb_config_var('listings.filters', 'show_item_type_group_lov') !== FALSE) {
            $v_item_type_groups = get_list_item_type_groups();
            if (is_not_empty_array($v_item_type_groups)) {
                $excluded_vars_list[] = 's_item_type_group';
                $buffer .= "<li><label for=\"select-s_item_type_group\">" . get_opendb_lang_var('s_item_type_group') . "</label>\n\t\t\t\t\t<select id=\"select-s_item_type_group\" name=\"s_item_type_group\">\n\t\t\t\t\t<option value=\"\"></option>" . custom_select('s_item_type_group', $v_item_type_groups, '%value% - %display%', 'NA', $HTTP_VARS['s_item_type_group'], 'value') . "\n</select></li>";
            }
        }
        if (get_opendb_config_var('listings.filters', 'show_item_type_lov') !== FALSE) {
            $v_item_types = get_list_item_types(NULL);
            if (is_not_empty_array($v_item_type_groups)) {
                $excluded_vars_list[] = 's_item_type';
                $buffer .= "<li><label for=\"select-s_item_type\">" . get_opendb_lang_var('s_item_type') . "</label>\n\t\t\t\t\t<select id=\"select-s_item_type\" name=\"s_item_type\">\n\t\t\t\t\t<option value=\"\"></option>" . custom_select('s_item_type', $v_item_types, '%value% - %display%', 'NA', $HTTP_VARS['s_item_type'], 'value') . "\n</select></li>";
            }
        }
        if (get_opendb_config_var('listings.filters', 'show_interest') !== FALSE) {
            $buffer .= "<li><label for=\"select-interest\">" . get_opendb_lang_var('interest_only_marked') . "</label>" . "<input type=\"checkbox\" class=\"checkbox\" id=\"select-interest\" name=\"interest_level\" value=\"1\"" . ($HTTP_VARS['interest_level'] >= 1 ? ' CHECKED' : '') . "></li>";
            $excluded_vars_list[] = 'interest_level';
        }
        if ($HTTP_VARS['owner_id'] != get_opendb_session_var('user_id')) {
            $buffer .= "<li><label for=\"exclude-current-user\">" . get_opendb_lang_var('exclude_current_user') . "</label>" . "<input type=\"checkbox\" class=\"checkbox\" id=\"exclude-current-user\" name=\"not_owner_id\" value=\"" . get_opendb_session_var('user_id') . "\"" . ($HTTP_VARS['not_owner_id'] == get_opendb_session_var('user_id') ? ' CHECKED' : '') . "></li>";
            $excluded_vars_list[] = 'not_owner_id';
        }
        $buffer .= "</ul>";
        $buffer .= get_url_fields($HTTP_VARS, NULL, $excluded_vars_list);
        $buffer .= "<input type=\"submit\" class=\"submit\" value=\"" . get_opendb_lang_var('submit') . "\">";
        $buffer .= "</form>";
        $buffer .= "</div>";
        $buffer .= "</div>";
    }
    return $buffer;
}
Пример #5
0
function show_email_form($to_userid, $to_fullname, $from_userid, $from_fullname, $subject, $message, $HTTP_VARS, $errors)
{
    global $PHP_SELF;
    if (strlen($to_userid) > 0 && strlen($to_fullname) > 0) {
        $to = get_opendb_lang_var('user_name', array('fullname' => $to_fullname, 'user_id' => $to_userid));
    } else {
        if (strlen($to_fullname) > 0) {
            $to = $to_fullname;
        } else {
            if (strlen($to_userid) > 0) {
                $to = $to_userid;
            }
        }
    }
    $isFromReadonly = FALSE;
    if (strlen($from_userid) > 0 && strlen($from_fullname) > 0) {
        $from = get_opendb_lang_var('current_user', array('fullname' => $from_fullname, 'user_id' => $from_userid));
        $isFromReadonly = TRUE;
    } else {
        if (strlen($from_fullname) > 0) {
            $from = $from_fullname;
            // this is an email address
        } else {
            if (strlen($from_userid) > 0) {
                $from = $from_userid;
                // this is an email address
            }
        }
    }
    if (is_array($errors)) {
        echo format_error_block($errors);
    }
    echo "\n<form action=\"{$PHP_SELF}\" method=\"POST\">";
    echo get_url_fields($HTTP_VARS, array('op2' => 'send'), array('subject', 'message'));
    echo "\n<table class=\"emailForm\">";
    echo format_field(get_opendb_lang_var('to'), $to);
    echo get_input_field("from", NULL, get_opendb_lang_var('from'), $isFromReadonly ? "readonly" : "email(50,100)", "Y", $from, TRUE);
    echo get_input_field("subject", NULL, get_opendb_lang_var('subject'), "text(50,100)", "Y", $subject, TRUE);
    echo get_input_field("message", NULL, get_opendb_lang_var('message'), "textarea(50,10)", "N", $message, TRUE);
    echo "</table>";
    $help_block_r[] = array('img' => 'compulsory.gif', 'text' => get_opendb_lang_var('compulsory_field'), id => 'compulsory');
    echo format_help_block($help_block_r);
    echo "<input type=\"submit\" class=\"submit\" value=\"" . get_opendb_lang_var('submit') . "\">";
    echo "\n</form>";
}
Пример #6
0
             if (($resultOfImport = $xmlHandler->handleImport()) !== TRUE) {
                 $importError = $xmlHandler->getError();
             }
         }
     }
     // Close file.
     unset($fileHandler);
     @fclose($inFile);
     $listingObject->endListing();
     if ($resultOfImport !== TRUE) {
         $listingObject->setNoRowsMessage($importError);
         echo format_error_block($importError);
     }
     if ($cfg_is_trial_run) {
         echo "<form action=\"{$PHP_SELF}\" method=\"POST\">";
         echo get_url_fields($HTTP_VARS, array('op'), array('op2'));
         echo "<input type=\"button\" class=\"button\" onclick=\"this.form.op.value='uploaded'; this.form.submit();\" value=\"" . get_opendb_lang_var('back') . "\">";
         echo "<input type=\"button\" class=\"button\" onclick=\"this.form.trial_run.value='N'; this.form.op.value='import'; this.form.submit();\" value=\"" . get_opendb_lang_var('import_items') . "\">";
         echo "</form>";
     } else {
         if (is_not_empty_array($itemImportHandler->getItemIDList())) {
             $footer_links_r[] = array(url => 'listings.php?item_id_range=' . urlencode(get_item_id_range($itemImportHandler->getItemIDList())), text => get_opendb_lang_var('list_imported_items', 'count', count($itemImportHandler->getItemIDList())));
         }
         //Get rid of the file now!
         import_cache_delete($HTTP_VARS['ic_sequence_number']);
         echo format_footer_links($footer_links_r);
     }
     // don't need it anymore.
     unset($listingObject);
     echo _theme_footer();
 } else {
Пример #7
0
             echo "<p>OpenDb configuration was written to <code>./include/local.config.php</code></p>";
             echo "\n<form action=\"{$PHP_SELF}\" method=\"GET\">";
             echo "<input type=\"hidden\" name=\"step\" value=\"pre-install\">\n";
             echo "<input type=\"button\" class=\"button\" value=\"Next\" onclick=\"this.value='Working...'; this.disabled=true; this.form.submit(); return true;\">\n";
             echo "</form>";
         } else {
             echo "<p class=\"error\">OpenDb configuration was not written to <code>./include/local.config.php</code></p>";
             if (is_array($errors)) {
                 echo "<ul class=\"error\">";
                 while (list(, $error) = each($errors)) {
                     echo "<li>{$error}</li>";
                 }
                 echo "</ul>";
             }
             echo "\n<form action=\"{$PHP_SELF}\" method=\"POST\">";
             echo get_url_fields($HTTP_VARS);
             echo "\n<input type=\"button\" class=\"button\" value=\"Retry\" onclick=\"this.value='Working...'; this.disabled=true; this.form.submit(); return true;\">";
             echo "</form>\n";
             echo "<p>If you cannot resolve the issue, you can save the configuration file manually.  The contents of the textarea should be saved to  \n\t\t\t\t<code>./include/local.config.php</code>.  Once this is done click <strong>Retry</strong>.";
             echo "<form>";
             echo "<textarea rows=\"12\" cols=\"100\">" . htmlspecialchars($config_file_contents) . "</textarea>";
             echo "</form>";
         }
     }
     echo _theme_footer();
 } else {
     // if the s_opendb_release table does not exist, we need to install it, and populate with
     // a specific version record.
     echo _theme_header("OpenDb " . get_opendb_version() . " Installation", FALSE);
     echo "<h2>Pre Installation</h2>";
     $preinstall_details = NULL;
Пример #8
0
function handle_site_add_or_refresh($item_r, $status_type_r, &$HTTP_VARS, &$footer_links_r)
{
    global $PHP_SELF;
    global $titleMaskCfg;
    if (!is_array($item_r)) {
        if ($HTTP_VARS['confirmed'] === 'false' || strlen($HTTP_VARS['owner_id']) == 0) {
            $page_title = get_opendb_lang_var('add_new_item');
            echo _theme_header($page_title);
            if (is_exists_item_type($HTTP_VARS['s_item_type'])) {
                echo "<h2>" . $page_title . " " . get_item_image($HTTP_VARS['s_item_type']) . "</h2>";
            } else {
                echo "<h2>" . $page_title . "</h2>";
            }
            echo "<form action=\"{$PHP_SELF}\" method=\"GET\">" . get_url_fields($HTTP_VARS, array('confirmed' => 'true'));
            $HTTP_VARS['owner_id'] = ifempty($HTTP_VARS['owner_id'], get_opendb_session_var('user_id'));
            echo "<h3>" . get_opendb_lang_var('what_owner_add_new_item') . "</h3>";
            echo "\n<select name=\"owner_id\">" . custom_select('owner_id', fetch_user_rs(PERM_ITEM_OWNER), '%fullname% (%user_id%)', 'NA', $HTTP_VARS['owner_id'], 'user_id') . "\n</select>";
            echo "<input type=\"submit\" class=\"submit\" value=\"" . get_opendb_lang_var('add_new_item') . "\">";
            echo "</form>";
        } else {
            //if($show_owner_field || $show_status_type_field)
            if ($HTTP_VARS['owner_id'] != get_opendb_session_var('user_id')) {
                $page_title = get_opendb_lang_var('add_new_item_for_name', array('user_id' => $HTTP_VARS['owner_id'], 'fullname' => fetch_user_name($HTTP_VARS['owner_id'])));
            } else {
                $page_title = get_opendb_lang_var('add_new_item');
            }
            echo _theme_header($page_title);
            if (is_exists_item_type($HTTP_VARS['s_item_type'])) {
                echo "<h2>" . $page_title . " " . get_item_image($HTTP_VARS['s_item_type']) . "</h2>";
            } else {
                echo "<h2>" . $page_title . "</h2>";
            }
            if (!display_site_plugin_blocks($HTTP_VARS, $item_r)) {
                echo "<p class=\"error\">" . get_opendb_lang_var('operation_not_available') . "</p>";
            }
        }
    } else {
        if (is_not_empty_array($item_r)) {
            $HTTP_VARS['s_item_type'] = $item_r['s_item_type'];
            $page_title = get_opendb_lang_var('refresh_title', array('display_title' => $titleMaskCfg->expand_item_title($item_r)));
            echo _theme_header($page_title);
            echo "<h2>" . $page_title . " " . get_item_image($item_r['s_item_type']) . "</h2>\n";
            if (!display_site_plugin_blocks($HTTP_VARS, $item_r)) {
                echo "<p class=\"error\">" . get_opendb_lang_var('operation_not_available') . "</p>";
            }
        }
    }
    if (is_not_empty_array($item_r)) {
        $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'));
    }
}
Пример #9
0
function getToggleControl($PHP_SELF, $HTTP_VARS, $text, $fieldname, $value)
{
    $buffer .= "<form class=\"toggleControl\" id=\"toggle-{$fieldname}\" action=\"" . $PHP_SELF . "\" method=\"GET\">" . get_url_fields($HTTP_VARS, NULL, array($fieldname)) . "<input type=\"hidden\" name=\"{$fieldname}\" value=\"{$value}\">" . "<label for=\"toggle-{$fieldname}-cbox\">" . $text . "</label><input type=\"checkbox\" class=\"checkbox\" id=\"toggle-{$fieldname}-cbox\" name=\"{$fieldname}_cbox\" value=\"Y\" onclick=\"if(this.checked){this.form['{$fieldname}'].value='Y';}else{this.form['{$fieldname}'].value='N';} this.form.submit()\"" . (strcasecmp($value, 'Y') === 0 ? " CHECKED" : "") . ">" . "</form>";
    return $buffer;
}
Пример #10
0
/**
 * @param $borrowed_item_rs Items that this action will be performed against.  It may actually
 * 						be an array of 'sequence_number' values, in which case the borrow
 * 						record for the sequence_number will be fetched.
 * @param $HTTP_VARS
 * */
function more_information_form($op, $borrowed_item_rs, $HTTP_VARS, $email_notification = TRUE)
{
    global $PHP_SELF;
    $duration_attr_type = NULL;
    $default_borrow_duration = NULL;
    echo "\n<form action=\"{$PHP_SELF}\" method=\"POST\">";
    // In case no detail is required.
    echo "\n<input type=\"hidden\" name=\"more_info_requested\" value=\"true\">";
    // Pass all http variables onto next instance...
    // Includes empty fields...
    echo get_url_fields($HTTP_VARS, NULL, NULL);
    // Display the items to be operated on.
    if (is_not_empty_array($borrowed_item_rs)) {
        echo "<div id=\"moreInfoListing\">";
        // no pagination.
        $HTTP_VARS['items_per_page'] = '';
        $listingObject = new HTML_Listing($PHP_SELF, $HTTP_VARS);
        $listingObject->setIncludeHrefLinks(TRUE);
        $listingObject->setIncludeFooter(FALSE);
        $listingObject->startListing();
        $listingObject->addHeaderColumn(get_opendb_lang_var('type'));
        $listingObject->addHeaderColumn(get_opendb_lang_var('title'));
        if ($op == 'reserve' || $op == 'cancel_reserve' || $op == 'quick_check_out') {
            $listingObject->addHeaderColumn(get_opendb_lang_var('owner'));
        } else {
            if ($op == 'check_in') {
                $listingObject->addHeaderColumn(get_opendb_lang_var('borrower'));
            }
        }
        if (get_opendb_config_var('borrow', 'duration_support')) {
            if ($op == 'check_out' || $op == 'quick_check_out') {
                $listingObject->addHeaderColumn(get_opendb_lang_var('borrow_duration'));
            }
        }
        //initialise
        $max_overdue_duration = NULL;
        $default_borrow_duration = NULL;
        reset($borrowed_item_rs);
        while (list(, $borrowed_item_r) = each($borrowed_item_rs)) {
            $listingObject->startRow();
            // If only a sequence_number, we need to fetch the borrow record.
            if (!is_array($borrowed_item_r) && is_numeric($borrowed_item_r)) {
                $borrowed_item_r = fetch_borrowed_item_r($borrowed_item_r);
            }
            // TODO - add borrowed item history this to be displayed as readonly.
            //$results = fetch_borrowed_item_hist_rs($borrowed_item_r['sequence_number']);
            $item_r = fetch_item_instance_r($borrowed_item_r['item_id'], $borrowed_item_r['instance_no']);
            $listingObject->addItemTypeImageColumn($item_r['s_item_type']);
            $listingObject->addTitleColumn($item_r);
            if ($op == 'reserve' || $op == 'cancel_reserve' || $op == 'quick_check_out') {
                $listingObject->addUserNameColumn($item_r['owner_id'], array('bi_sequence_number' => $borrowed_item_r['sequence_number']));
            } else {
                if ($op == 'check_in') {
                    $listingObject->addUserNameColumn($borrowed_item_r['borrower_id'], array('bi_sequence_number' => $borrowed_item_r['sequence_number']));
                }
            }
            if (get_opendb_config_var('borrow', 'duration_support')) {
                if ($op == 'check_out' || $op == 'quick_check_out') {
                    if (is_numeric($item_r['borrow_duration'])) {
                        // todo - change
                        $duration_attr_type_r = fetch_sfieldtype_item_attribute_type_r($item_r['s_item_type'], 'DURATION');
                        $listingObject->addDisplayColumn($duration_attr_type_r['s_attribute_type'], NULL, $duration_attr_type_r['display_type'], $item_r['borrow_duration']);
                    } else {
                        $listingObject->addColumn(get_opendb_lang_var('undefined'));
                    }
                }
            }
            // While we are here, we are going to calculate the default duration value.
            // We want to choose the least duration value.  If any of the items use a
            // different s_attribute_type for duration, then we should not try to get
            // a default value.  This is indicated by the $duration_attr_type===FALSE
            // if we have encountered a difference.
            if (get_opendb_config_var('borrow', 'duration_support') && $duration_attr_type !== FALSE) {
                $new_duration_attr_type = fetch_sfieldtype_item_attribute_type($item_r['s_item_type'], 'DURATION');
                if ($duration_attr_type == NULL) {
                    $duration_attr_type = $new_duration_attr_type;
                } else {
                    if ($duration_attr_type !== $new_duration_attr_type) {
                        // Different s_attribute_type's for DURATION, so cannot display Duration chooser.
                        $duration_attr_type = FALSE;
                    }
                }
                if ($duration_attr_type !== FALSE) {
                    if ($op == 'check_out' || $op == 'quick_check_out') {
                        // The default borrow duration should be the least amount of days or undefined
                        // if no records have a borrow duration.
                        if ($default_borrow_duration === NULL) {
                            $default_borrow_duration = $item_r['borrow_duration'];
                        } else {
                            if ($default_borrow_duration !== '') {
                                // Undefined empty value.
                                if (is_numeric($default_borrow_duration) && is_numeric($item_r['borrow_duration']) && $item_r['borrow_duration'] < $default_borrow_duration) {
                                    $default_borrow_duration = $item_r['borrow_duration'];
                                }
                            }
                        }
                    } else {
                        if ($op == 'extension') {
                            if ($borrowed_item_r['total_duration'] > $borrowed_item_r['borrow_duration']) {
                                $tmp_overdue_duration = $borrowed_item_r['total_duration'] - $borrowed_item_r['borrow_duration'];
                            }
                            // We want to get the max overdue duration, so we can give the User granting the extension a
                            // default, that will bring all selected items back into non-overdue status.
                            if (!is_numeric($max_overdue_duration) || $max_overdue_duration < $tmp_overdue_duration) {
                                $max_overdue_duration = $tmp_overdue_duration;
                            }
                        }
                    }
                }
            }
            //if(get_opendb_config_var('borrow', 'duration_support') && $duration_attr_type!==FALSE)
            $listingObject->endRow();
        }
        //while(list(,$borrowed_item_r) = each($borrowed_item_rs))
        $listingObject->endListing();
        echo "</div>";
    }
    echo "<table class=\"moreInfo\">";
    // Do not display this more information section unless email is enabled.
    if (is_valid_opendb_mailer() && $email_notification !== FALSE) {
        echo get_input_field("more_information", NULL, get_opendb_lang_var('more_information'), "textarea(50,10)", "N", NULL, TRUE);
    }
    // Include a Borrower ID select, minus the current user.
    if ($op == 'quick_check_out') {
        if (strlen($HTTP_VARS['borrower_id']) == 0 || !is_user_granted_permission(PERM_USER_BORROWER, $HTTP_VARS['borrower_id'])) {
            $current_user_mode = EXCLUDE_CURRENT_USER;
            if (get_opendb_config_var('borrow', 'owner_self_checkout') !== FALSE) {
                $current_user_mode = INCLUDE_CURRENT_USER;
            }
            $results = fetch_user_rs(PERM_USER_BORROWER, INCLUDE_ROLE_PERMISSIONS, $current_user_mode, EXCLUDE_DEACTIVATED_USER, 'fullname', 'ASC');
            if ($results) {
                echo format_field(get_opendb_lang_var('borrower'), custom_select('borrower_id', $results, '%fullname% (%user_id%)', 1, NULL, 'user_id'));
            } else {
                echo format_field(get_opendb_lang_var('borrower'), get_opendb_lang_var('no_records_found'));
            }
        }
    }
    //Only for check_out/quick_check_out operations - makes no sense otherwise!
    if (get_opendb_config_var('borrow', 'duration_support') !== FALSE && ($op == 'check_out' || $op == 'quick_check_out' || $op == 'extension')) {
        // Display default borrow duration.
        if (strlen($duration_attr_type) > 0) {
            $duration_attr_type_r = fetch_attribute_type_r($duration_attr_type);
            // We have to find the matching DURATION lookup value, which is at least
            // as many days as the max_overdue value, or the highest possible
            // duration value, if none found as large as the $max_overdue_duration
            if ($op == 'extension') {
                $default_borrow_duration = NULL;
                $result = fetch_attribute_type_lookup_rs($duration_attr_type_r['s_attribute_type'], 'order_no, value ASC');
                if ($result) {
                    while ($lookup_r = db_fetch_assoc($result)) {
                        if (is_numeric($lookup_r['value']) && (!is_numeric($max_overdue_duration) || is_numeric($max_overdue_duration) && $max_overdue_duration <= $lookup_r['value'])) {
                            $default_borrow_duration = $lookup_r['value'];
                            break;
                        }
                        // backup, in case we need to use outside while loop
                        $lookup_r2 = $lookup_r;
                    }
                    db_free_result($result);
                    // If still null, then set to the largest option
                    if ($default_borrow_duration == NULL) {
                        $default_borrow_duration = $lookup_r2['value'];
                    }
                }
            }
            if ($op != 'extension' && strlen(get_opendb_lang_var('default_borrow_duration')) > 0 && is_array($borrowed_item_rs)) {
                $duration_attr_type_r['prompt'] = get_opendb_lang_var('default_borrow_duration');
            }
            $duration_attr_type_r['compulsory_ind'] = 'N';
            echo get_item_input_field("default_borrow_duration", $duration_attr_type_r, NULL, $op != 'quick_check_out' ? $default_borrow_duration : NULL);
            // Not appropriate for extension operation
            if ($op == 'check_out' || $op == 'quick_check_out') {
                echo get_input_field("override_item_duration", NULL, get_opendb_lang_var('override_item_duration'), "simple_checkbox(" . ($default_borrow_duration === NULL ? "CHECKED" : "") . ")", "N", "Y", TRUE);
            }
        } else {
            //otherwise tell checkout to use item_instance borrow duration instead.
            if ($op == 'check_out' || $op == 'quick_check_out') {
                echo "\n<input type=\"hidden\" name=\"override_item_duration\" value=\"N\">";
            }
        }
    }
    echo "</table>";
    echo "<input type=\"submit\" class=\"submit\" value=\"" . get_opendb_lang_var('submit') . "\">";
    echo "</form>";
    echo format_help_block(get_opendb_lang_var('more_information_help'));
}