Exemplo n.º 1
0
             // reserved!
             $listingObject->addHeaderColumn(get_opendb_lang_var('borrow_duration'));
         }
     }
 }
 $listingObject->addHeaderColumn(get_opendb_lang_var('more_information'));
 // If mysql resultset or static $item_reservation_rs array defined, we can continue.
 if ($result) {
     while ($borrowed_item_r = db_fetch_assoc($result)) {
         $listingObject->startRow();
         $status_type_r = fetch_status_type_r($borrowed_item_r['s_status_type']);
         if ($checkbox_column !== FALSE) {
             if ($HTTP_VARS['op'] == 'my_reserve_basket' || $HTTP_VARS['op'] == 'my_reserved' || $HTTP_VARS['op'] == 'owner_borrowed' || $HTTP_VARS['op'] == 'owner_reserved' && !is_item_borrowed($borrowed_item_r['item_id'], $borrowed_item_r['instance_no'])) {
                 $listingObject->addCheckboxColumn($borrowed_item_r['sequence_number'], FALSE);
             } else {
                 $listingObject->addColumn();
             }
         }
         if ($HTTP_VARS['op'] != 'my_item_history') {
             // Type
             $listingObject->addItemTypeImageColumn($borrowed_item_r['s_item_type']);
             if ($HTTP_VARS['op'] == 'my_borrowed' || $HTTP_VARS['op'] == 'my_history') {
                 $listingObject->addTitleColumn($borrowed_item_r);
             } else {
                 $listingObject->addTitleColumn($borrowed_item_r);
             }
         }
         // Owner/Borrower
         if ($HTTP_VARS['op'] == 'my_reserve_basket' || $HTTP_VARS['op'] == 'my_borrowed' || $HTTP_VARS['op'] == 'my_reserved' || $HTTP_VARS['op'] == 'my_history' || $HTTP_VARS['op'] == 'all_borrowed' || $HTTP_VARS['op'] == 'all_reserved') {
             $listingObject->addUserNameColumn($borrowed_item_r['owner_id'], array('bi_sequence_number' => $borrowed_item_r['sequence_number']));
         }
Exemplo n.º 2
0
 $listingObject = new HTML_Listing($PHP_SELF, $HTTP_VARS);
 $listingObject->setNoRowsMessage(get_opendb_lang_var('no_items_found'));
 $listingObject->startListing();
 $listingObject->addHeaderColumn('URL', 'url');
 $listingObject->addHeaderColumn('Cached', 'cache_date');
 $listingObject->addHeaderColumn('Expires', 'expire_date');
 if (is_numeric($listingObject->getItemsPerPage())) {
     $listingObject->setTotalItems(fetch_file_cache_cnt($HTTP_VARS['cache_type']));
 }
 $results = fetch_file_cache_rs($HTTP_VARS['cache_type'], $listingObject->getCurrentOrderBy(), $listingObject->getCurrentSortOrder(), $listingObject->getStartIndex(), $listingObject->getItemsPerPage());
 if ($results) {
     while ($file_cache_r = db_fetch_assoc($results)) {
         $listingObject->startRow();
         if (file_cache_get_cache_file($file_cache_r)) {
             $popupUrl = "url.php?id=" . $file_cache_r['sequence_number'];
             $listingObject->addColumn("<a href=\"" . $file_cache_r['url'] . "\" onclick=\"popup('{$popupUrl}'); return false;\" target=\"_new\">" . get_overflow_tooltip_column($file_cache_r['url'], 100) . "</a>");
         } else {
             $listingObject->addColumn(get_overflow_tooltip_column($file_cache_r['url'], 100));
         }
         $listingObject->addColumn(get_localised_timestamp(get_opendb_config_var('http', 'datetime_mask'), $file_cache_r['cache_date']));
         $column = '';
         if ($file_cache_r['expired_ind'] == 'Y') {
             $column .= "<span class=\"error\">";
         }
         if ($file_cache_r['expire_date'] != NULL) {
             $column .= get_localised_timestamp(get_opendb_config_var('http', 'datetime_mask'), $file_cache_r['expire_date']);
         } else {
             $column .= "NA";
         }
         if ($file_cache_r['expired_ind'] == 'Y') {
             $column .= "</span>";
Exemplo n.º 3
0
         $listingObject->addHeaderColumn(get_opendb_lang_var('title'), 'title');
         $listingObject->addHeaderColumn(get_opendb_lang_var('owner'), 'owner');
         if (get_opendb_config_var('borrow', 'duration_support')) {
             $listingObject->addHeaderColumn(get_opendb_lang_var('borrow_duration'), 'borrow_duration', FALSE);
         }
         if (is_not_empty_array($altid_item_instance_rs)) {
             while (list(, $item_instance_r) = each($altid_item_instance_rs)) {
                 $listingObject->startRow();
                 $listingObject->addItemTypeImageColumn($item_instance_r['s_item_type']);
                 $listingObject->addTitleColumn($item_instance_r);
                 $listingObject->addUserNameColumn($item_instance_r['owner_id']);
                 if (is_numeric($item_instance_r['borrow_duration']) && $item_instance_r['borrow_duration'] > 0) {
                     $duration_attr_type_r = fetch_sfieldtype_item_attribute_type_r($item_instance_r['s_item_type'], 'DURATION');
                     $listingObject->addDisplayColumn($duration_attr_type_r['s_attribute_type'], NULL, $duration_attr_type_r['display_type'], $item_instance_r['borrow_duration']);
                 } else {
                     $listingObject->addColumn(get_opendb_lang_var('undefined'));
                 }
                 $listingObject->endRow();
             }
         }
         $listingObject->endListing();
         echo "</div>";
         echo "<ul class=\"listingControls\">";
         if (get_opendb_config_var('listings', 'allow_override_show_item_image') !== FALSE) {
             echo "<li>" . getToggleControl($PHP_SELF, $HTTP_VARS, get_opendb_lang_var('show_item_image'), 'show_item_image', ifempty($HTTP_VARS['show_item_image'], get_opendb_config_var('listings', 'show_item_image') == TRUE ? 'Y' : 'N')) . "</li>";
         }
         echo "</ul>";
     }
     echo _theme_footer();
 } else {
     opendb_operation_not_available();
Exemplo n.º 4
0
 $v_listing_url_vars['item_id_instance_no'] = NULL;
 $v_listing_url_vars['checked_item_id_instance_no'] = NULL;
 $v_listing_url_vars['checked_item_id_instance_no_list'] = NULL;
 register_opendb_session_var('listing_url_vars', $v_listing_url_vars);
 while ($item_r = db_fetch_assoc($result)) {
     $listingObject->startRow();
     // Get the Status Type config for the current item_instance.s_status_type, but grab it once.
     if (!is_array($status_type_rs[$item_r['s_status_type']])) {
         $status_type_rs[$item_r['s_status_type']] = fetch_status_type_r($item_r['s_status_type']);
     }
     if ($show_checkbox_column) {
         if (!is_item_in_reserve_basket($item_r['item_id'], $item_r['instance_no'], get_opendb_session_var('user_id'))) {
             if ($status_type_rs[$item_r['s_status_type']]['borrow_ind'] == 'Y' && ($item_r['owner_id'] !== get_opendb_session_var('user_id') || get_opendb_config_var('borrow', 'owner_self_checkout') !== FALSE) && is_user_granted_permission(PERM_USER_BORROWER) && !is_item_reserved_or_borrowed_by_user($item_r['item_id'], $item_r['instance_no']) && (get_opendb_config_var('borrow', 'allow_reserve_if_borrowed') !== FALSE || !is_item_borrowed($item_r['item_id'], $item_r['instance_no'])) && (get_opendb_config_var('borrow', 'allow_multi_reserve') !== FALSE || !is_item_reserved($item_r['item_id'], $item_r['instance_no']))) {
                 $listingObject->addCheckboxColumn($item_r['item_id'] . "_" . $item_r['instance_no'], FALSE);
             } else {
                 $listingObject->addColumn();
             }
         } else {
             $listingObject->addColumn();
         }
     }
     for ($i = 0; $i < count($v_column_display_config_rs); $i++) {
         if ($v_column_display_config_rs[$i]['include_in_listing'] !== FALSE) {
             if ($v_column_display_config_rs[$i]['column_type'] == 's_attribute_type') {
                 if ($v_column_display_config_rs[$i]['search_attribute_ind'] == 'y') {
                     $attribute_val = $item_r[$v_column_display_config_rs[$i]['fieldname']];
                 } else {
                     if ($v_column_display_config_rs[$i]['multi_attribute_ind'] == 'Y' || $v_column_display_config_rs[$i]['lookup_attribute_ind'] == 'Y') {
                         $attribute_val = fetch_attribute_val_r($item_r['item_id'], $item_r['instance_no'], $v_column_display_config_rs[$i]['s_attribute_type']);
                     } else {
                         $attribute_val = fetch_attribute_val($item_r['item_id'], $item_r['instance_no'], $v_column_display_config_rs[$i]['s_attribute_type']);
Exemplo n.º 5
0
function get_related_items_listing($item_r, $HTTP_VARS, $related_mode)
{
    global $PHP_SELF;
    $buffer = '';
    $results = fetch_item_instance_relationship_rs($item_r['item_id'], $item_r['instance_no'], $related_mode);
    if ($results) {
        $listingObject = new HTML_Listing($PHP_SELF, $HTTP_VARS);
        $listingObject->setBufferOutput(TRUE);
        $listingObject->setNoRowsMessage(get_opendb_lang_var('no_items_found'));
        $listingObject->setShowItemImages(TRUE);
        $listingObject->setIncludeFooter(FALSE);
        $listingObject->addHeaderColumn(get_opendb_lang_var('type'), 'type', FALSE);
        $listingObject->addHeaderColumn(get_opendb_lang_var('title'), 'title', FALSE);
        $listingObject->addHeaderColumn(get_opendb_lang_var('action'), 'action', FALSE);
        $listingObject->addHeaderColumn(get_opendb_lang_var('status'), 'status', FALSE);
        $listingObject->addHeaderColumn(get_opendb_lang_var('status_comment'), 'status_comment', FALSE);
        $listingObject->addHeaderColumn(get_opendb_lang_var('category'), 'category', FALSE);
        $listingObject->startListing(NULL);
        while ($related_item_r = db_fetch_assoc($results)) {
            $listingObject->startRow();
            $listingObject->addItemTypeImageColumn($related_item_r['s_item_type']);
            $listingObject->addTitleColumn($related_item_r);
            $action_links_rs = NULL;
            if (is_user_granted_permission(PERM_ITEM_OWNER) && get_opendb_session_var('user_id') === $item_r['owner_id'] || is_user_granted_permission(PERM_ITEM_ADMIN)) {
                $action_links_rs[] = array(url => 'item_input.php?op=edit&item_id=' . $related_item_r['item_id'] . '&instance_no=' . $related_item_r['instance_no'], img => 'edit.gif', text => get_opendb_lang_var('edit'));
                if (get_opendb_config_var('listings', 'show_refresh_actions') && is_item_legal_site_type($related_item_r['s_item_type'])) {
                    $action_links_rs[] = array(url => 'item_input.php?op=site-refresh&item_id=' . $related_item_r['item_id'] . '&instance_no=' . $related_item_r['instance_no'], img => 'refresh.gif', text => get_opendb_lang_var('refresh'));
                }
                $action_links_rs[] = array(url => 'item_input.php?op=delete&item_id=' . $related_item_r['item_id'] . '&instance_no=' . $related_item_r['instance_no'] . '&parent_item_id=' . $item_r['item_id'] . '&parent_instance_no=' . $item_r['instance_no'], img => 'delete.gif', text => get_opendb_lang_var('delete'));
                $action_links_rs[] = array(url => 'item_input.php?op=delete-relation&item_id=' . $item_r['item_id'] . '&instance_no=' . $item_r['instance_no'] . '&parent_item_id=' . $related_item_r['item_id'] . '&parent_instance_no=' . $related_item_r['instance_no'], img => 'delete.gif', text => get_opendb_lang_var('delete_relationship'));
            }
            $listingObject->addActionColumn($action_links_rs);
            $status_type_r = fetch_status_type_r($related_item_r['s_status_type']);
            $listingObject->addThemeImageColumn($status_type_r['img'], $status_type_r['description'], $status_type_r['description'], 's_status_type');
            //type
            // If a comment is allowed and defined, add it in.
            if ($status_type_r['status_comment_ind'] == 'Y' || get_opendb_session_var('user_id') === $related_item_r['owner_id'] || is_user_granted_permission(PERM_ITEM_ADMIN)) {
                // support newlines in this field
                $listingObject->addColumn(nl2br($related_item_r['status_comment']));
            } else {
                $listingObject->addColumn(get_opendb_lang_var('not_applicable'));
            }
            $attribute_type_r = fetch_sfieldtype_item_attribute_type_r($related_item_r['s_item_type'], 'CATEGORY');
            if (is_array($attribute_type_r)) {
                if ($attribute_type_r['lookup_attribute_ind'] === 'Y') {
                    $attribute_val = fetch_attribute_val_r($related_item_r['item_id'], $related_item_r['instance_no'], $attribute_type_r['s_attribute_type'], $attribute_type_r['order_no']);
                } else {
                    $attribute_val = fetch_attribute_val($related_item_r['item_id'], $related_item_r['instance_no'], $attribute_type_r['s_attribute_type'], $attribute_type_r['order_no']);
                }
                $listingObject->addAttrDisplayColumn($related_item_r, $attribute_type_r, $attribute_val);
            }
            $listingObject->endRow();
        }
        $listingObject->endListing();
        $buffer =& $listingObject->getContents();
        unset($listingObject);
        return $buffer;
    } else {
        return NULL;
    }
}
Exemplo n.º 6
0
 if (is_numeric($listingObject->getItemsPerPage())) {
     $listingObject->setTotalItems(fetch_file_cache_cnt($HTTP_VARS['cache_type']));
 }
 $results = fetch_file_cache_rs($HTTP_VARS['cache_type'], $listingObject->getCurrentOrderBy(), $listingObject->getCurrentSortOrder(), $listingObject->getStartIndex(), $listingObject->getItemsPerPage());
 if ($results) {
     while ($file_cache_r = db_fetch_assoc($results)) {
         $listingObject->startRow();
         if (file_cache_get_cache_file($file_cache_r)) {
             $hrefUrl = "url.php?id=" . $file_cache_r['sequence_number'];
             if (!is_url_absolute($file_cache_r['url'])) {
                 $url = get_item_input_file_upload_url($file_cache_r['url']);
                 if ($url !== FALSE) {
                     $hrefUrl = $url;
                 }
             }
             $listingObject->addColumn("<a href=\"" . $hrefUrl . "\" target=\"_new\">" . get_overflow_tooltip_column($file_cache_r['url'], 100) . "</a>");
         } else {
             $listingObject->addColumn(get_overflow_tooltip_column($file_cache_r['url'], 100));
         }
         if (file_cache_get_cache_file_thumbnail($file_cache_r)) {
             $listingObject->addThemeImageColumn('tick.gif');
         } else {
             $listingObject->addThemeImageColumn('cross.gif');
         }
         $listingObject->addColumn(get_localised_timestamp(get_opendb_config_var('http', 'datetime_mask'), $file_cache_r['cache_date']));
         $column = '';
         if ($file_cache_r['expired_ind'] == 'Y') {
             $column .= "<span class=\"error\">";
         }
         if ($file_cache_r['expire_date'] != NULL) {
             $column .= get_localised_timestamp(get_opendb_config_var('http', 'datetime_mask'), $file_cache_r['expire_date']);
Exemplo n.º 7
0
 if ($HTTP_VARS['restrict_active_ind'] != 'X') {
     $listingObject->addHeaderColumn(get_opendb_lang_var('last_visit'), 'lastvisit');
 }
 if ($result) {
     $v_listing_url_vars = $HTTP_VARS;
     $v_listing_url_vars['mode'] = NULL;
     unset($v_listing_url_vars['show_deactivated_users_cbox']);
     register_opendb_session_var('user_listing_url_vars', $v_listing_url_vars);
     while ($user_r = db_fetch_assoc($result)) {
         $user_is_active = is_user_active($user_r['user_id']);
         $listingObject->startRow();
         // todo - consider disabling for guest users!
         if ($HTTP_VARS['restrict_active_ind'] != 'X' ? $user_is_active : TRUE) {
             $listingObject->addCheckboxColumn($user_r['user_id'], FALSE);
         } else {
             $listingObject->addColumn();
         }
         $user_name = get_opendb_lang_var('user_name', array('fullname' => $user_r['fullname'], 'user_id' => $user_r['user_id']));
         $listingObject->addColumn('<a href="user_profile.php?uid=' . $user_r['user_id'] . '" title="' . get_opendb_lang_var('user_profile') . '">' . $user_name . '</a>');
         $action_links_rs = NULL;
         $action_links_rs[] = array(url => 'user_admin.php?op=edit&user_id=' . $user_r['user_id'], img => 'edit_user.gif', text => get_opendb_lang_var('edit'));
         if ($user_r['user_id'] != get_opendb_session_var('user_id')) {
             if ($user_r['active_ind'] == 'X') {
                 $action_links_rs[] = array(url => 'user_admin.php?op=delete&user_id=' . $user_r['user_id'], img => 'delete_user.gif', text => get_opendb_lang_var('delete_user'));
             } else {
                 if ($user_is_active) {
                     $action_links_rs[] = array(url => 'user_admin.php?op=deactivate&user_id=' . $user_r['user_id'], img => 'deactivate_user.gif', text => get_opendb_lang_var('deactivate_user'));
                 }
             }
             if (!$user_is_active) {
                 $action_links_rs[] = array(url => 'user_admin.php?op=activate&user_id=' . $user_r['user_id'], img => 'activate_user.gif', text => get_opendb_lang_var('activate_user'));
Exemplo n.º 8
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'));
}