示例#1
0
function handle_reserve($item_id, $instance_no, $borrower_id, $more_information, &$errors)
{
    $status_type_r = fetch_status_type_r(fetch_item_s_status_type($item_id, $instance_no));
    if ($status_type_r['borrow_ind'] != 'Y') {
        $errors = get_opendb_lang_var('s_status_type_items_cannot_be_borrowed', 's_status_type_desc', $status_type_r['description']);
        return FALSE;
    } else {
        if (is_user_owner_of_item($item_id, $instance_no, $borrower_id) && get_opendb_config_var('borrow', 'owner_self_checkout') !== TRUE) {
            $errors = get_opendb_lang_var('cannot_reserve_items_you_own');
            return FALSE;
        } else {
            if (is_item_borrowed_by_user($item_id, $instance_no, $borrower_id)) {
                $errors = get_opendb_lang_var('you_have_it_borrowed');
                return FALSE;
            } else {
                if (is_item_reserved_by_user($item_id, $instance_no, $borrower_id)) {
                    $errors = get_opendb_lang_var('you_have_reservation');
                    return FALSE;
                } else {
                    if (get_opendb_config_var('borrow', 'allow_reserve_if_borrowed') === FALSE && is_item_borrowed($item_id, $instance_no)) {
                        $errors = get_opendb_lang_var('item_is_already_checked_out');
                        return FALSE;
                    } else {
                        if (get_opendb_config_var('borrow', 'allow_multi_reserve') === FALSE && is_item_reserved($item_id, $instance_no)) {
                            $errors = get_opendb_lang_var('item_is_already_reserved');
                            return FALSE;
                        } else {
                            // All but the actual reservation of item should occur, when this variable is set to TRUE.
                            if (get_opendb_config_var('borrow', 'reserve_email_only') !== TRUE) {
                                $new_borrowed_item_id = reserve_item($item_id, $instance_no, $borrower_id, $more_information);
                                if ($new_borrowed_item_id !== FALSE) {
                                    return new_borrowed_item_id;
                                } else {
                                    return FALSE;
                                }
                            } else {
                                opendb_logger(OPENDB_LOG_INFO, __FILE__, __FUNCTION__, 'No Reservation was made because reserve email only is enabled.', array($item_id, $instance_no, $borrower_id));
                                return TRUE;
                            }
                        }
                    }
                }
            }
        }
    }
}
示例#2
0
     if (is_item_borrowed($item_r['item_id'], $item_r['instance_no'])) {
         if (is_user_allowed_to_checkin_item($item_r['item_id'], $item_r['instance_no'])) {
             $action_links_rs[] = array(url => 'item_borrow.php?op=check_in&item_id=' . $item_r['item_id'] . '&instance_no=' . $item_r['instance_no'], img => 'check_in_item.gif', text => get_opendb_lang_var('check_in_item'));
         }
     } else {
         if (get_opendb_config_var('borrow', 'quick_checkout') !== FALSE && get_opendb_config_var('listings.borrow', 'quick_checkout_action') !== FALSE && $status_type_rs[$item_r['s_status_type']]['borrow_ind'] == 'Y' && is_user_allowed_to_checkout_item($item_r['item_id'], $item_r['instance_no'])) {
             $action_links_rs[] = array(url => 'item_borrow.php?op=quick_check_out&item_id=' . $item_r['item_id'] . '&instance_no=' . $item_r['instance_no'], img => 'quick_check_out.gif', text => get_opendb_lang_var('quick_check_out'));
         }
     }
 }
 if ($item_r['owner_id'] != get_opendb_session_var('user_id')) {
     // Reservation/Cancel Information.
     if (get_opendb_config_var('borrow', 'enable') !== FALSE && get_opendb_config_var('listings.borrow', 'enable') !== FALSE) {
         if (is_user_granted_permission(PERM_USER_BORROWER) && $status_type_rs[$item_r['s_status_type']]['borrow_ind'] == 'Y') {
             if (is_item_reserved_or_borrowed($item_r['item_id'], $item_r['instance_no'])) {
                 if (is_item_reserved_by_user($item_r['item_id'], $item_r['instance_no'])) {
                     $action_links_rs[] = array(url => 'item_borrow.php?op=cancel_reserve&item_id=' . $item_r['item_id'] . '&instance_no=' . $item_r['instance_no'], img => 'cancel_reserve.gif', text => get_opendb_lang_var('cancel'));
                 } else {
                     if (!is_item_borrowed_by_user($item_r['item_id'], $item_r['instance_no'])) {
                         if ((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']))) {
                             if (get_opendb_config_var('borrow', 'reserve_basket') !== FALSE && get_opendb_config_var('listings.borrow', 'basket_action') !== FALSE) {
                                 $action_links_rs[] = array(url => 'borrow.php?op=update_my_reserve_basket&item_id=' . $item_r['item_id'] . '&instance_no=' . $item_r['instance_no'], img => 'add_reserve_basket.gif', text => get_opendb_lang_var('add_to_reserve_list'));
                             }
                             if (get_opendb_config_var('listings.borrow', 'reserve_action') !== FALSE) {
                                 $action_links_rs[] = array(url => 'item_borrow.php?op=reserve&item_id=' . $item_r['item_id'] . '&instance_no=' . $item_r['instance_no'], img => 'reserve_item.gif', text => get_opendb_lang_var('reserve'));
                             }
                         }
                     }
                 }
             } else {
                 if (get_opendb_config_var('borrow', 'reserve_basket') !== FALSE && get_opendb_config_var('listings.borrow', 'basket_action') !== FALSE) {
示例#3
0
/**
	@selected will be currently selected record.

	$borrow_duration is the item_instance.borrow_duration value in all cases, the rest of the values to do
	with borrow duration will be calculated.
*/
function get_item_status_row($class, $item_r, $selected)
{
    global $HTTP_VARS;
    global $PHP_SELF;
    global $titleMaskCfg;
    $rowcontents = "\n<tr class=\"{$class}\"><td";
    if ($selected) {
        $rowcontents .= " class=\"currentItemInstance\">" . $item_r['instance_no'] . "</span>";
    } else {
        $rowcontents .= "><a href=\"{$PHP_SELF}?item_id={$item_r['item_id']}&instance_no={$item_r['instance_no']}\">" . $item_r['instance_no'] . "</a>";
    }
    $rowcontents .= "\n</td>";
    $page_title = $titleMaskCfg->expand_item_title($item_r);
    $page_title = remove_enclosing_quotes($page_title);
    $rowcontents .= "<td>" . get_list_username($item_r['owner_id'], $HTTP_VARS['mode'], $page_title, get_opendb_lang_var('back_to_item'), 'item_display.php?item_id=' . $item_r['item_id'] . '&instance_no=' . $item_r['instance_no']) . "</td>";
    $status_type_r = fetch_status_type_r($item_r['s_status_type']);
    // ---------------------- Borrow,Reserve,Cancel,Edit,Delete,etc operations here.
    $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=' . $item_r['item_id'] . '&instance_no=' . $item_r['instance_no'], img => 'edit.gif', text => get_opendb_lang_var('edit'));
        // Checks if any legal site plugins defined for $item_r['s_item_type']
        if (is_item_legal_site_type($item_r['s_item_type'])) {
            $action_links_rs[] = array(url => 'item_input.php?op=site-refresh&item_id=' . $item_r['item_id'] . '&instance_no=' . $item_r['instance_no'], img => 'refresh.gif', text => get_opendb_lang_var('refresh'));
        }
        if ($status_type_r['delete_ind'] == 'Y' && !is_item_reserved_or_borrowed($item_r['item_id'], $item_r['instance_no'])) {
            $action_links_rs[] = array(url => 'item_input.php?op=delete&item_id=' . $item_r['item_id'] . '&instance_no=' . $item_r['instance_no'], img => 'delete.gif', text => get_opendb_lang_var('delete'));
        }
    }
    if (is_user_granted_permission(array(PERM_USER_BORROWER, PERM_ADMIN_BORROWER))) {
        if (get_opendb_config_var('borrow', 'enable') !== FALSE) {
            if (get_opendb_config_var('borrow', 'quick_checkout') !== FALSE && $status_type_r['borrow_ind'] == 'Y' && is_user_allowed_to_checkout_item($item_r['item_id'], $item_r['instance_no'])) {
                if (!is_item_borrowed($item_r['item_id'], $item_r['instance_no'])) {
                    $action_links_rs[] = array(url => 'item_borrow.php?op=quick_check_out&item_id=' . $item_r['item_id'] . '&instance_no=' . $item_r['instance_no'], img => 'quick_check_out.gif', text => get_opendb_lang_var('quick_check_out'));
                }
            }
            // Check if already in reservation session variable.
            if (get_opendb_config_var('borrow', 'reserve_basket') !== FALSE && is_item_in_reserve_basket($item_r['item_id'], $item_r['instance_no'])) {
                $action_links_rs[] = array(url => 'borrow.php?op=delete_from_my_reserve_basket&item_id=' . $item_r['item_id'] . '&instance_no=' . $item_r['instance_no'], img => 'delete_reserve_basket.gif', text => get_opendb_lang_var('delete_from_reserve_list'));
            } else {
                if (is_item_reserved_or_borrowed($item_r['item_id'], $item_r['instance_no'])) {
                    if (is_item_reserved_by_user($item_r['item_id'], $item_r['instance_no'])) {
                        $action_links_rs[] = array(url => 'item_borrow.php?op=cancel_reserve&item_id=' . $item_r['item_id'] . '&instance_no=' . $item_r['instance_no'], img => 'cancel_reserve.gif', text => get_opendb_lang_var('cancel_reservation'));
                    } else {
                        if (!is_item_borrowed_by_user($item_r['item_id'], $item_r['instance_no'])) {
                            if ($status_type_r['borrow_ind'] == 'Y' && (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']))) {
                                if (get_opendb_config_var('borrow', 'reserve_basket') !== FALSE) {
                                    $action_links_rs[] = array(url => 'borrow.php?op=update_my_reserve_basket&item_id=' . $item_r['item_id'] . '&instance_no=' . $item_r['instance_no'], img => 'add_reserve_basket.gif', text => get_opendb_lang_var('add_to_reserve_list'));
                                } else {
                                    $action_links_rs[] = array(url => 'item_borrow.php?op=reserve&item_id=' . $item_r['item_id'] . '&instance_no=' . $item_r['instance_no'], img => 'reserve_item.gif', text => get_opendb_lang_var('reserve_item'));
                                }
                            }
                        }
                    }
                } else {
                    if ($status_type_r['borrow_ind'] == 'Y') {
                        if (get_opendb_config_var('borrow', 'reserve_basket') !== FALSE) {
                            $action_links_rs[] = array(url => 'borrow.php?op=update_my_reserve_basket&item_id=' . $item_r['item_id'] . '&instance_no=' . $item_r['instance_no'], img => 'add_reserve_basket.gif', text => get_opendb_lang_var('add_to_reserve_list'));
                        } else {
                            $action_links_rs[] = array(url => 'item_borrow.php?op=reserve&item_id=' . $item_r['item_id'] . '&instance_no=' . $item_r['instance_no'], img => 'reserve_item.gif', text => get_opendb_lang_var('reserve_item'));
                        }
                    }
                }
            }
        }
    }
    if (is_item_borrowed($item_r['item_id'], $item_r['instance_no']) && is_user_allowed_to_checkin_item($item_r['item_id'], $item_r['instance_no'])) {
        $action_links_rs[] = array(url => 'item_borrow.php?op=check_in&item_id=' . $item_r['item_id'] . '&instance_no=' . $item_r['instance_no'], img => 'check_in_item.gif', text => get_opendb_lang_var('check_in_item'));
    }
    if ($item_r['owner_id'] == get_opendb_session_var('user_id') || is_user_granted_permission(PERM_ADMIN_BORROWER)) {
        if (is_exists_item_instance_history_borrowed_item($item_r['item_id'], $item_r['instance_no'])) {
            $action_links_rs[] = array(url => 'borrow.php?op=my_item_history&item_id=' . $item_r['item_id'] . '&instance_no=' . $item_r['instance_no'], img => 'item_history.gif', text => get_opendb_lang_var('item_history'));
        }
    }
    $rowcontents .= "\n<td>";
    $rowcontents .= ifempty(format_action_links($action_links_rs), get_opendb_lang_var('not_applicable'));
    $rowcontents .= "</td>";
    // Item Status Image.
    $rowcontents .= "\n<td>";
    $rowcontents .= theme_image($status_type_r['img'], $status_type_r['description'], "s_status_type");
    $rowcontents .= "</td>";
    // If a comment is allowed and defined, add it in.
    $rowcontents .= "\n<td>";
    if ($status_type_r['status_comment_ind'] == 'Y' || get_opendb_session_var('user_id') === $item_r['owner_id'] || is_user_granted_permission(PERM_ITEM_ADMIN)) {
        $rowcontents .= ifempty(nl2br($item_r['status_comment']), "&nbsp;");
        // support newlines in this field
    } else {
        $rowcontents .= get_opendb_lang_var('not_applicable');
    }
    $rowcontents .= "</td>";
    if (get_opendb_config_var('borrow', 'enable') !== FALSE) {
        if (get_opendb_config_var('borrow', 'include_borrower_column') !== FALSE) {
            $rowcontents .= "\n<td>";
            if (is_item_borrowed($item_r['item_id'], $item_r['instance_no'])) {
                $rowcontents .= get_list_username(fetch_item_borrower($item_r['item_id'], $item_r['instance_no']), NULL, $page_title, get_opendb_lang_var('back_to_item'), 'item_display.php?item_id=' . $item_r['item_id'] . '&instance_no=' . $item_r['instance_no']);
            } else {
                $rowcontents .= get_opendb_lang_var('not_applicable');
            }
            $rowcontents .= "</td>";
        }
        // Borrow Status Image.
        $rowcontents .= "\n<td>";
        if (is_item_borrowed($item_r['item_id'], $item_r['instance_no'])) {
            $rowcontents .= theme_image("borrowed.gif", get_opendb_lang_var('borrowed'), "borrowed_item");
        } else {
            if (is_item_reserved($item_r['item_id'], $item_r['instance_no'])) {
                $rowcontents .= theme_image("reserved.gif", get_opendb_lang_var('reserved'), "borrowed_item");
            } else {
                $rowcontents .= get_opendb_lang_var('not_applicable');
            }
        }
        $rowcontents .= "</td>";
        if (get_opendb_config_var('borrow', 'duration_support') !== FALSE) {
            // 'Due Back' functionality.
            $rowcontents .= "\n<td>";
            if (is_item_borrowed($item_r['item_id'], $item_r['instance_no'])) {
                $due_date = fetch_item_duedate_timestamp($item_r['item_id'], $item_r['instance_no']);
                if (strlen($due_date) > 0) {
                    $rowcontents .= get_localised_timestamp(get_opendb_config_var('borrow', 'date_mask'), $due_date);
                } else {
                    $rowcontents .= get_opendb_lang_var('undefined');
                }
            } else {
                if (is_numeric($item_r['borrow_duration'])) {
                    $duration_attr_type_r = fetch_sfieldtype_item_attribute_type_r($item_r['s_item_type'], 'DURATION');
                    $rowcontents .= get_item_display_field($item_r, $duration_attr_type_r, $item_r['borrow_duration'], FALSE);
                } else {
                    $rowcontents .= get_opendb_lang_var('undefined');
                }
            }
            $rowcontents .= "</td>";
        }
    }
    $rowcontents .= "\n</tr>";
    return $rowcontents;
}