Example #1
0
function display_borrower_form($HTTP_VARS)
{
    echo "\n<form action=\"{$PHP_SELF}\" method=\"GET\">";
    echo "\n<input type=\"hidden\" name=\"op\" value=\"checkout\">";
    echo "\n<table class=\"borrowerForm\">";
    if (get_opendb_config_var('borrow', 'admin_quick_checkout_borrower_lov') !== TRUE) {
        echo get_input_field('borrower_id', NULL, get_opendb_lang_var('borrower'), "filtered(20,20,a-zA-Z0-9_.)", "Y", NULL, TRUE);
    } else {
        $results = fetch_user_rs(PERM_USER_BORROWER, INCLUDE_ROLE_PERMISSIONS, EXCLUDE_CURRENT_USER, 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'));
        }
    }
    echo "</table>";
    echo "<input type=\"submit\" class=\"submit\" value=\"" . get_opendb_lang_var('submit') . "\">";
    echo "</form>";
}
Example #2
0
function display_edit_site_plugin($record_r, $HTTP_VARS = NULL)
{
    if (is_array($record_r)) {
        echo get_input_field('site_type', NULL, 'Site Type', 'readonly', 'Y', $record_r['site_type']);
    } else {
        echo get_input_field('site_type', NULL, 'Site Type', 'text(10,10)', 'Y', $record_r['site_type']);
    }
    echo get_input_field('classname', NULL, 'Class Name', 'text(50,50)', 'Y', $record_r['classname']);
    echo get_input_field('title', NULL, 'Title', 'text(25,50)', 'Y', $record_r['title']);
    $field = get_input_field('image', NULL, 'Image', 'url(25,*,"gif,jpg,png",N)', 'N', $record_r['image'], FALSE);
    if (strlen($record_r['image']) > 0) {
        $image_src = "images/site/" . $record_r['image'];
    }
    if ($image_src !== FALSE && strlen($image_src) > 0 && file_exists($image_src)) {
        $field .= theme_image("images/site/" . $image_src, NULL, NULL);
    }
    echo format_field('Image', $field);
    echo get_input_field('description', NULL, 'Description', 'text(50,255)', 'Y', $record_r['description']);
    echo get_input_field('external_url', NULL, 'External URL', 'text(50,255)', 'Y', $record_r['external_url']);
    echo get_input_field('more_info_url', NULL, 'More Info URL', 'text(50,255)', 'N', $record_r['more_info_url']);
    echo get_input_field('items_per_page', NULL, 'Items Per Page', 'number(3)', 'N', $record_r['items_per_page']);
}
Example #3
0
function build_roles_select($attribute_type_r)
{
    $user_roles = array();
    $result = fetch_user_role_rs();
    $public = fetch_role_r(get_public_access_rolename());
    $user_roles[] = array('role_name' => $public['role_name'], 'description' => $public['description']);
    while ($role = db_fetch_assoc($result)) {
        $user_roles[] = $role;
    }
    $select = format_field("View Permission", custom_select('view_perm', $user_roles, '%description%', 1, $attribute_type_r['view_perm'], 'role_name'));
    db_free_result($result);
    return $select;
}
Example #4
0
function draw_list_file($list, $module)
{
    global $DB, $LIST_TEMPLATE, $CONF, $curstn, $done_id, $search_fields;
    $done_id = array();
    $start = 0;
    $subrow = 0;
    // MAKE OPTION ARRAY AND SQL STATEMENT
    foreach (explode("||", $list["options"]) as $opt) {
        list($k, $v) = explode("::", $opt);
        switch ($k) {
            case "perpage":
                $start = isset($_GET[$module . "_st"]) ? intval($_GET[$module . "_st"] * $v) : "0";
                $sql_append2 = " LIMIT " . $_GET[$module . "_st"] * $v . "," . $v;
                $perpage = $v;
                break;
            case "defordfield":
                if (isset($_GET[$module . "_ordfield"])) {
                    $v = $_GET[$module . "_ordfield"];
                }
                $defield = $v;
                $sql_append1 = " ORDER BY " . $v;
                break;
            case "defordtype":
                if (isset($_GET[$module . "_ordtype"]) && ($_GET[$module . "_ordtype"] == "asc" || $_GET[$module . "_ordtype"] == "desc")) {
                    $v = $_GET[$module . "_ordtype"];
                }
                $deftype = $v;
                $sql_append1 .= " " . $v;
                break;
            case "defordfield2":
                if (isset($_GET[$module . "_ordfield"])) {
                    $v = $_GET[$module . "_ordfield"];
                }
                $defield = $v;
                $sql_append1 .= " , " . $v;
                break;
            case "defordtype2":
                if (isset($_GET[$module . "_ordtype"]) && ($_GET[$module . "_ordtype"] == "asc" || $_GET[$module . "_ordtype"] == "desc")) {
                    $v = $_GET[$module . "_ordtype"];
                }
                $deftype = $v;
                $sql_append1 .= " " . $v;
                break;
            case "defordfield3":
                if (isset($_GET[$module . "_ordfield"])) {
                    $v = $_GET[$module . "_ordfield"];
                }
                $defield = $v;
                $sql_append1 .= " , " . $v;
                break;
            case "defordtype3":
                if (isset($_GET[$module . "_ordtype"]) && ($_GET[$module . "_ordtype"] == "asc" || $_GET[$module . "_ordtype"] == "desc")) {
                    $v = $_GET[$module . "_ordtype"];
                }
                $deftype = $v;
                $sql_append1 .= " " . $v;
                break;
            case "exp_sub":
                $defexp_sub = $v == 1 ? 1 : 0;
                break;
            case "exp_child":
                $defexp_child = $v == 1 ? 1 : 0;
                break;
            case "action_style":
                $defact_style = $v;
                break;
            case "row_col":
                $row_col = explode(",,", $v);
                break;
            case "search":
                if ($v == 1) {
                    $is_search = 1;
                }
                break;
        }
    }
    if (isset($list[search_options])) {
        foreach (explode("||", $list["search_options"]) as $sopt) {
            list($k, $v) = explode("::", $sopt);
            $search_fields[$k] = explode(";;", $v);
        }
    }
    // CHECK IF THERE ARE SUB-ROW
    if (isset($list["multilevel"])) {
        $subrow = 1;
        list($main, $ref, $def) = explode("||", $list["multilevel"]);
        if ($is_search != 1) {
            if (eregi("where", $list["sql_select"])) {
                $sql_where = " AND {$ref} = '{$def}' ";
                $sql_where2 = " AND {$ref} = '%ID%' ";
            } else {
                $sql_where = " WHERE {$ref} = '{$def}' ";
                $sql_where2 = " WHERE {$ref} = '%ID%' ";
            }
            $sql_ref = $list["sql_select"] . $sql_where2 . $sql_append1 . $sql_append2;
        } else {
            if (eregi("where", $list["sql_select"])) {
                $sql_where2 = " AND {$ref} = '%ID%' ";
            } else {
                $sql_where2 = " WHERE {$ref} = '%ID%' ";
            }
            $sql_ref = "SELECT * FROM {$module} WHERE %[PERM]% AND {$ref}='%ID%'" . $sql_append1;
        }
    }
    if (strlen($list[box_title]) > 0) {
        $output .= str_replace("%[TITLE]%", $list[box_title], $LIST_TEMPLATE[list_title]);
    }
    $titles = explode("||", $list["titles"]);
    $fields = explode("||", $list["fields"]);
    //REMEMBER aggiungere trigger error.
    if (count($titles) != count($fields)) {
        return "Error, field number";
    }
    $rs = @$DB->Execute(perm_sql_read($list[sql_select] . $sql_where . $sql_append1 . $sql_append2, $module));
    $rstot = @$DB->Execute(perm_sql_read($list[sql_select] . $sql_where . $sql_append1, $module));
    //List head
    $cnt = 0;
    if ($subrow == 1) {
        $titar[] = '  ';
    }
    foreach ($titles as $value) {
        $cur = "";
        list($val, $type) = explode("::", $value);
        list($vf, $tf) = explode("::", $fields[$cnt]);
        $titar[] = $value;
        $cnt++;
    }
    $odd = 0;
    $arcnt = 0;
    while (!$rs->EOF) {
        $row = $rs->FetchRow();
        $cnt = 0;
        $output2 = "";
        //Fix for search lists (check if a object is a subitem
        if ($subrow == 1 && $is_search == 1 && $row[$ref] != $def && !in_array($row[$ref], $done_id)) {
            $rstmp = @$DB->Execute(perm_sql_read("SELECT * FROM {$module} WHERE %[PERM]% AND id=" . $row[$ref], $module));
            $row = $rstmp->FetchRow();
            //Explode this row if search result is in a subrow
            if (!isset($_GET[$module . "_exp"])) {
                $_GET[$module . "_exp"] = $row[id];
            } else {
                $_GET[$module . "_exp"] .= "," . $row[id];
            }
        }
        if ($subrow == 1) {
            $output2 = draw_subrow($row["id"], $sql_ref, 1, $fields, $list["action"], $defexp, $module);
            if ($output2 == '') {
                $output2 = "";
                $resar[$arcnt][] = '  ';
            } else {
                $cnt = 1;
            }
        }
        if (is_array($done_id)) {
            if (in_array($row[id], $done_id)) {
                continue;
            } else {
                $done_id[] = $row[id];
            }
        } else {
            $done_id[] = $row[id];
        }
        foreach ($fields as $value) {
            $cur = format_field($value, $row, $list["action"]);
            if (isset($search_fields[$value])) {
                foreach ($search_fields[$value] as $searcht) {
                    $cur = $cur;
                }
            }
            $resar[$arcnt][] = quote_xml($cur);
        }
        $arcnt++;
    }
    $res[tit] = $titar;
    $res[res] = $resar;
    return $res;
}
Example #5
0
    print "</tr>\n";
    /* output To: line */
    print "<tr>\n";
    print "<td align=left><strong>" . $AppUI->_('To') . "</strong></td>";
    $recipient = query2result("SELECT author FROM tickets WHERE ticket = '{$ticket_parent}'");
    print "<td align=left>" . format_field($recipient, "recipient") . "</td>\n";
    print "</tr>\n";
    /* output ticket */
    for ($loop = 0; $loop < count($fields["headings"]); $loop++) {
        print "<tr>\n";
        // do not translate if heading is "<br />"
        if ($fields["headings"][$loop] == "<br />") {
        } else {
            $fields["headings"][$loop] = $AppUI->_($fields["headings"][$loop]);
        }
        print "<td align=left><strong>" . $fields["headings"][$loop] . "</strong></td>";
        print "<td align=left>" . format_field($ticket_info[$fields["columns"][$loop]], $fields["types"][$loop]) . "</td>\n";
        print "</tr>\n";
    }
    /* output submit button */
    print '<tr><td><br /></td><td><font size=-1><input class=button type=submit value="' . $AppUI->_('Post Followup') . '"></font></td></tr>';
    /* output actions */
    print "<tr>\n";
    print "<td align=left valign=top><br /></td>";
    print "<td align=left valign=top>&nbsp;</td>\n";
    print "</tr>\n";
    /* end table */
    print "</table>\n";
    /* end form */
    print "</form>\n";
}
Example #6
0
File: view.php Project: n2i/xvnkb
<?php 
/* start form */
/* get ticket */
$ticket_info = query2hash("SELECT * FROM tickets WHERE ticket = {$ticket}");
echo '<input type="hidden" name="orig_assignment" value="' . $ticket_info['assignment'] . '"/>';
echo '<input type="hidden" name="author" value="' . $ticket_info['author'] . '"/>';
echo '<input type="hidden" name="priority" value="' . $ticket_info['priority'] . '"/>';
echo '<input type="hidden" name="subject" value="' . $ticket_info['subject'] . '"/>';
/* output ticket */
for ($n = 0; $n < count($fields['headings']); $n++) {
    echo '<tr>';
    if ($fields['headings'][$n] !== '<br />') {
        $fields['headings'][$n] = $AppUI->_($fields['headings'][$n]) . ':';
    }
    echo '<td align="right" width="100"><b>' . $fields['headings'][$n] . '</b></td>';
    echo '<td align="left">' . format_field($ticket_info[$fields['columns'][$n]], $fields['types'][$n]) . '</td>';
    echo '</tr>';
}
$ticket_info["assignment"];
/* output attachment indicator */
$attach_count = query2result("SELECT attachment FROM tickets WHERE ticket = '{$ticket}'");
if ($attach_count == 1) {
    echo '<tr>';
    echo '<td align="left"><b>Attachments</b></td>';
    echo '<td align="left">This email had attachments which were removed.</td>';
    echo '</tr>';
} else {
    if ($attach_count == 2) {
        $result = do_query("SELECT file_id, file_name from files, tickets where ticket = '{$ticket}'\n\t\t\t\t\t\tand file_task = ticket and file_project = 0");
        if (number_rows($result)) {
            echo '<tr>';
Example #7
0
<?php 
/* start form */
/* get ticket */
$ticket_info = query2hash("SELECT * FROM tickets WHERE ticket = {$ticket}");
print "<input type=\"hidden\" name=\"orig_assignment\" value='" . $ticket_info["assignment"] . "' />\n";
print "<input type=\"hidden\" name=\"author\" value='" . $ticket_info["author"] . "' />\n";
print "<input type=\"hidden\" name=\"priority\" value='" . $ticket_info["priority"] . "' />\n";
print "<input type=\"hidden\" name=\"subject\" value='" . $ticket_info["subject"] . "' />\n";
/* output ticket */
for ($loop = 0; $loop < count($fields["headings"]); $loop++) {
    print "<tr>\n";
    if ($fields["headings"][$loop] !== "<br />") {
        $fields["headings"][$loop] = $AppUI->_($fields["headings"][$loop]);
    }
    print "<td align=\"right\">" . $fields["headings"][$loop] . "</td>";
    print "<td align=\"left\" class=\"hilite\">" . format_field($ticket_info[$fields["columns"][$loop]], $fields["types"][$loop]) . "</td>\n";
    print "</tr>\n";
}
$ticket_info["assignment"];
/* output attachment indicator */
$attach_count = query2result("SELECT attachment FROM tickets WHERE ticket = '{$ticket}'");
if ($attach_count == 1) {
    print "<tr>\n";
    print "<td align=\"left\"><strong>Attachments</strong></td>";
    print "<td align=\"left\">This email had attachments which were removed.</td>\n";
    print "</tr>\n";
} else {
    if ($attach_count == 2) {
        $result = do_query("SELECT file_id, file_name from files, tickets where ticket = '{$ticket}'\n  and file_task = ticket and file_project = 0");
        if (number_rows($result)) {
            print "<tr>\n";
Example #8
0
 if (is_opendb_valid_session()) {
     if (is_user_granted_permission(PERM_VIEW_USER_PROFILE)) {
         $user_r = fetch_user_r($HTTP_VARS['uid']);
         if (is_array($user_r)) {
             $page_title = get_opendb_lang_var('user_profile_for_user_name', array('user_id' => $user_r['user_id'], 'fullname' => $user_r['fullname']));
             echo _theme_header($page_title);
             echo '<h2>' . $page_title . '</h2>';
             if ($user_r['active_ind'] != 'Y') {
                 echo "<p class=\"userDeactivatedNotice\">" . get_opendb_lang_var('user_deactivated') . "</p>";
             }
             echo "<table>";
             echo format_field(get_opendb_lang_var('userid'), $user_r['user_id']);
             echo format_field(get_opendb_lang_var('user_role'), $user_r['role_description']);
             echo format_field(get_opendb_lang_var('fullname'), $user_r['fullname']);
             if ($user_r['user_id'] === get_opendb_session_var('user_id') || is_user_granted_permission(PERM_ADMIN_USER_PROFILE)) {
                 echo format_field(get_opendb_lang_var('email'), $user_r['email_addr']);
             }
             echo "\n</table>";
             $address_header_displayed = FALSE;
             $addr_results = fetch_user_address_type_rs($user_r['user_id'], TRUE);
             if ($addr_results) {
                 while ($address_type_r = db_fetch_assoc($addr_results)) {
                     if (is_user_address_visible($HTTP_VARS, $address_type_r)) {
                         $attr_results = fetch_address_type_attribute_type_rs($address_type_r['s_address_type'], 'query', TRUE);
                         if ($attr_results) {
                             echo '<h3>' . $address_type_r['description'] . '</h3>';
                             echo "<table>";
                             while ($addr_attribute_type_r = db_fetch_assoc($attr_results)) {
                                 $value = NULL;
                                 if (is_lookup_attribute_type($addr_attribute_type_r['s_attribute_type'])) {
                                     $value = fetch_user_address_lookup_attribute_val($address_type_r['sequence_number'], $addr_attribute_type_r['s_attribute_type'], $addr_attribute_type_r['order_no']);
Example #9
0
                         $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 {
     // invalid login, so login instead.
     redirect_login($PHP_SELF, $HTTP_VARS);
 }
Example #10
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;
}
Example #11
0
File: index.php Project: n2i/xvnkb
        if ($CONFIG['index_link'] == 'latest') {
            $latest_value = query2result("SELECT ticket FROM tickets WHERE parent = '{$value}' ORDER BY ticket DESC LIMIT 1");
            if ($latest_value) {
                $value = $latest_value;
            }
        }
        $action = "location.href = 'index.php?m=ticketsmith&a=view&ticket={$value}'";
        echo '<tr class="' . ($nticks % 2 == 1 ? 'first' : 'second') . '" onclick="' . $action . '" style="cursor:pointer">';
        echo '<td align="center"><img src="images/view.gif"></td>';
        for ($n = 1; $n < count($fields['headings']); $n++) {
            echo '<td align=' . $fields['aligns'][$n] . '>';
            //translate some information, some not
            if ($fields['headings'][$n] == 'Status') {
                echo $AppUI->_(format_field($row[$fields['columns'][$n]], $fields['types'][$n], $row[$fields['columns'][0]]));
            } else {
                echo format_field($row[$fields['columns'][$n]], $fields['types'][$n], $row[$fields['columns'][0]]);
            }
            echo '</td>';
        }
        echo '</tr>';
        $nticks++;
    }
    echo '<script>Table("idTicketList").setNormalHover(2)</script>';
} else {
    echo '<tr class="second">';
    echo '<td align="center" colspan="100%">';
    echo $AppUI->_('There are no') . ' ';
    echo $type == 'All' ? '' : strtolower($AppUI->_($type)) . ' ';
    echo $AppUI->_('tickets');
    echo '</td>';
    echo '</tr>';
Example #12
0
function get_item_display_field($item_r, $item_attribute_type_r, $value = NULL, $dowrap = TRUE, $prompt_mask = NULL)
{
    if ($item_attribute_type_r['display_type'] == 'hidden') {
        return '';
    } else {
        if ($item_attribute_type_r['display_type'] == 'fileviewer') {
            $format_mask = ifempty($item_attribute_type_r['display_type_arg1'], '%value%');
            $width = ifempty($item_attribute_type_r['display_type_arg2'], '400');
            $height = ifempty($item_attribute_type_r['display_type_arg3'], '300');
            $target = ifempty($item_attribute_type_r['display_type_arg4'], '_blank');
            if (is_array($value)) {
                $values = $value;
            } else {
                $values[] = $value;
            }
            if (count($values) > 0) {
                $display_value_r = array();
                while (list(, $value) = each($values)) {
                    $value = trim($value);
                    $value_format_mask = $format_mask;
                    if (strpos($value_format_mask, '%img%') !== FALSE) {
                        $file_type_r = fetch_file_type_r(fetch_file_type_for_extension(get_file_ext($value)));
                        if (strlen($file_type_r['image']) > 0 && ($image_src = theme_image_src($file_type_r['image'])) !== FALSE) {
                            $img = '<img src="' . $image_src . '" title="' . $value . '">';
                        } else {
                            $img = '';
                        }
                        $value_format_mask = str_replace('%img%', $img, $value_format_mask);
                    }
                    if (strpos($value_format_mask, '%value%') !== FALSE) {
                        $value_format_mask = str_replace('%value%', $value, $value_format_mask);
                    }
                    $file_r = file_cache_get_image_r($value, 'display');
                    $url = $file_r['fullsize']['url'];
                    $display_value_r[] = "<a href=\"" . $value . "\" onclick=\"fileviewer('{$url}' ,'" . ($width + 20) . "', '" . ($height + 25) . "', '" . $target . "'); return false;\" title=\"" . $item_attribute_type_r['prompt'] . "\" class=\"popuplink\">{$value_format_mask}</a>";
                }
                $field = format_multivalue_block($display_value_r, 'fileviewer');
                if ($dowrap) {
                    return format_field($item_attribute_type_r['prompt'], $field, $prompt_mask);
                } else {
                    return $field;
                }
            } else {
                return '';
            }
        } else {
            if ($item_attribute_type_r['display_type'] == 'datetime') {
                if (is_array($value)) {
                    $values = $value;
                } else {
                    $values[] = $value;
                }
                if (count($values) > 0) {
                    $display_value_r = array();
                    while (list(, $value) = each($values)) {
                        $value = trim($value);
                        $timestamp = get_timestamp_for_datetime($value, 'YYYYMMDDHH24MISS');
                        if ($timestamp !== FALSE) {
                            if (strlen($item_attribute_type_r['display_type_arg1']) == 0) {
                                $item_attribute_type_r['display_type_arg1'] = 'DD/MM/YYYY';
                            }
                            $datetime = get_localised_timestamp($item_attribute_type_r['display_type_arg1'], $timestamp);
                            if ($datetime !== FALSE) {
                                $display_value_r[] = $datetime;
                            } else {
                                $display_value_r[] = $value;
                            }
                        } else {
                            $display_value_r[] = $value;
                        }
                    }
                    $field = format_multivalue_block($display_value_r, 'datetime');
                    if ($dowrap) {
                        return format_field($item_attribute_type_r['prompt'], $field, $prompt_mask);
                    } else {
                        return $field;
                    }
                } else {
                    return '';
                }
            } else {
                if ($item_attribute_type_r['display_type'] == 'format_mins') {
                    if (is_array($value)) {
                        $values = $value;
                    } else {
                        $values[] = $value;
                    }
                    if (count($values) > 0) {
                        $display_value_r = array();
                        while (list(, $value) = each($values)) {
                            $value = trim($value);
                            if (is_numeric($value)) {
                                // Ensure we have a mask to work with.
                                $display_mask = $item_attribute_type_r['display_type_arg1'];
                                if (strlen($display_mask) == 0) {
                                    $display_mask = '%h %H %m %M';
                                }
                                $hrs = floor($value / 60);
                                // hours
                                $mins = $value % 60;
                                // minutes
                                // Process display_mask and remove any bits that are not needed because the hour/minute is zero.
                                if ($mins == 0 && $hrs > 0) {
                                    // only get rid of minutes if $hrs is a value.
                                    $index = strpos($display_mask, '%H');
                                    if ($index !== FALSE) {
                                        $display_mask = substr($display_mask, 0, $index + 2);
                                    } else {
                                        $index = strpos($display_mask, '%m');
                                        if ($index != FALSE) {
                                            $display_mask = substr($display_mask, 0, $index);
                                        }
                                        //include the %H
                                    }
                                } else {
                                    if ($hrs == 0) {
                                        $index = strpos($display_mask, '%m');
                                        if ($index != FALSE) {
                                            $display_mask = substr($display_mask, $index);
                                        }
                                        //include the %H
                                    }
                                }
                                // Unfortunately we need to do $mins>0 and $hrs>0 if's twice, because otherwise once we
                                // replace the %h and %H the test for $mins>0 would not be able to cut the display_mask,
                                // based on the %h/%H...
                                if ($hrs > 0) {
                                    // Now do all replacements.
                                    $display_mask = str_replace('%h', $hrs, $display_mask);
                                    if ($hrs != 1) {
                                        $display_mask = str_replace('%H', get_opendb_lang_var('hours'), $display_mask);
                                    } else {
                                        $display_mask = str_replace('%H', get_opendb_lang_var('hour'), $display_mask);
                                    }
                                }
                                if ($mins >= 0 || $hrs === 0 && $mins === 0) {
                                    // Now do minute replacements only.
                                    $display_mask = str_replace('%m', $mins, $display_mask);
                                    if ($mins != 1) {
                                        $display_mask = str_replace('%M', get_opendb_lang_var('minutes'), $display_mask);
                                    } else {
                                        $display_mask = str_replace('%M', get_opendb_lang_var('minute'), $display_mask);
                                    }
                                }
                                $display_value_r[] = $display_mask;
                            } else {
                                // what else can we do here?!
                                $display_value_r[] = $value;
                            }
                        }
                        $field = format_multivalue_block($display_value_r, 'format_mins');
                        if ($dowrap) {
                            return format_field($item_attribute_type_r['prompt'], $field, $prompt_mask);
                        } else {
                            return $field;
                        }
                    } else {
                        return '';
                    }
                } else {
                    if ($item_attribute_type_r['display_type'] == 'star_rating') {
                        // arg[0] = rating range
                        if (is_array($value)) {
                            $values = $value;
                        } else {
                            $values[] = $value;
                        }
                        if (count($values) > 0) {
                            $display_value_r = array();
                            while (list(, $value) = each($values)) {
                                $value = trim($value);
                                // no point unless numeric
                                if (is_numeric($value)) {
                                    $total_count = $item_attribute_type_r['display_type_arg1'];
                                    if (is_numeric($total_count)) {
                                        $display_value = '';
                                        $j = $value;
                                        for ($i = 0; $i < $total_count; ++$i) {
                                            if ($j >= 0.75) {
                                                $display_value .= theme_image('rs.gif');
                                            } else {
                                                if ($j >= 0.25) {
                                                    $display_value .= theme_image('rgs.gif');
                                                } else {
                                                    $display_value .= theme_image('gs.gif');
                                                }
                                            }
                                            $j = $j - 1;
                                        }
                                        $ratingmask = $item_attribute_type_r['display_type_arg2'];
                                        if (strlen($ratingmask) > 0) {
                                            $ratingmask = str_replace('%value%', $value, $ratingmask);
                                            $ratingmask = str_replace('%maxrange%', $total_count, $ratingmask);
                                            $display_value = str_replace('%starrating%', $display_value, $ratingmask);
                                        }
                                        if ($item_attribute_type_r['listing_link_ind'] == 'Y') {
                                            $display_value = format_listing_link($value, $display_value, $item_attribute_type_r, NULL);
                                        }
                                    }
                                    $display_value_r[] = $display_value;
                                }
                            }
                            $field = format_multivalue_block($display_value_r, 'starrating');
                            if ($dowrap) {
                                return format_field($item_attribute_type_r['prompt'], $field, $prompt_mask);
                            } else {
                                return $field;
                            }
                        } else {
                            return '';
                            // nothing to do!
                        }
                    } else {
                        if (!is_array($value) && $item_attribute_type_r['display_type'] == 'display' && ifempty($item_attribute_type_r['display_type_arg1'], '%value%') == '%value%') {
                            // Support newline formatting by default.
                            $value = nl2br(trim($value));
                            if ($item_attribute_type_r['listing_link_ind'] == 'Y') {
                                $field = format_listing_links($value, $item_attribute_type_r, 'exact');
                            } else {
                                $field = $value;
                            }
                            if ($dowrap) {
                                return format_field($item_attribute_type_r['prompt'], $field, $prompt_mask);
                            } else {
                                return $field;
                            }
                        } else {
                            if ($item_attribute_type_r['display_type'] == 'list') {
                                //list(list_type [,delimiter])
                                if (is_array($value)) {
                                    $values = $value;
                                    $attr_match = 'exact';
                                } else {
                                    $value = trim($value);
                                    if (strlen($item_attribute_type_r['display_type_arg2']) == 0) {
                                        // Use newline!
                                        $values = explode_lines($value);
                                        $attr_match = 'partial';
                                    } else {
                                        $values = explode($item_attribute_type_r['display_type_arg2'], $value);
                                        if (strlen(trim($item_attribute_type_r['display_type_arg2'])) === 0) {
                                            $attr_match = 'word';
                                        } else {
                                            $attr_match = 'partial';
                                        }
                                    }
                                }
                                $field = format_list_from_array($values, $item_attribute_type_r, $item_attribute_type_r['listing_link_ind'] == 'Y' ? $attr_match : FALSE);
                                if ($dowrap) {
                                    return format_field($item_attribute_type_r['prompt'], $field, $prompt_mask);
                                } else {
                                    return $field;
                                }
                            } else {
                                if ($item_attribute_type_r['display_type'] == 'category' || $item_attribute_type_r['display_type'] == 'display') {
                                    $field = '';
                                    if (is_array($value)) {
                                        $value_array = $value;
                                    } else {
                                        $value_array[] = $value;
                                    }
                                    $attribute_value_rs = array();
                                    if ($item_attribute_type_r['lookup_attribute_ind'] == 'Y') {
                                        $results = fetch_value_match_attribute_type_lookup_rs($item_attribute_type_r['s_attribute_type'], $value_array, get_lookup_order_by($item_attribute_type_r['display_type_arg1']), 'asc');
                                        if ($results) {
                                            while ($lookup_r = db_fetch_assoc($results)) {
                                                $lookup_key = array_search2($lookup_r['value'], $value_array, TRUE);
                                                if ($lookup_key !== FALSE) {
                                                    // Remove the matched element
                                                    array_splice($value_array, $lookup_key, 1);
                                                    $attribute_value_rs[] = array(value => $lookup_r['value'], display => $lookup_r['display'], img => $lookup_r['img']);
                                                }
                                            }
                                            db_free_result($results);
                                        }
                                    }
                                    // where extra items that do not have a matching lookup value.
                                    if (is_not_empty_array($value_array)) {
                                        reset($value_array);
                                        while (list(, $value) = each($value_array)) {
                                            if (strlen(trim($value)) > 0) {
                                                // In case there are extra spaces
                                                $attribute_value_rs[] = array(value => $value, display => $value);
                                            }
                                        }
                                    }
                                    if (is_not_empty_array($attribute_value_rs)) {
                                        $field = format_lookup_display_block($item_attribute_type_r, $attribute_value_rs);
                                        if (strlen($field) > 0) {
                                            if ($dowrap) {
                                                return format_field($item_attribute_type_r['prompt'], $field, $prompt_mask);
                                            } else {
                                                return $field;
                                            }
                                        } else {
                                            return NULL;
                                        }
                                    }
                                } else {
                                    if ($item_attribute_type_r['display_type'] == 'review') {
                                        $total_count = fetch_attribute_type_cnt('S_RATING');
                                        if (is_numeric($total_count)) {
                                            $value = trim($value);
                                            if (!is_numeric($value)) {
                                                $value = 0;
                                            }
                                            $field = '';
                                            $j = $value;
                                            for ($i = 0; $i < $total_count; ++$i) {
                                                if ($j >= 0.75) {
                                                    $field .= theme_image('rs.gif');
                                                } else {
                                                    if ($j >= 0.25) {
                                                        $field .= theme_image('rgs.gif');
                                                    } else {
                                                        $field .= theme_image('gs.gif');
                                                    }
                                                }
                                                $j = $j - 1;
                                            }
                                            // If a mask is defined, format the display value.
                                            if (strlen($item_attribute_type_r['display_type_arg1']) > 0) {
                                                $lookup_r = fetch_attribute_type_lookup_r('S_RATING', $value);
                                                if (is_not_empty_array($lookup_r)) {
                                                    $field .= format_display_value($item_attribute_type_r['display_type_arg1'], $lookup_r['img'], $lookup_r['value'], $lookup_r['display']);
                                                }
                                            }
                                            return $field;
                                            // this is only used in a few places.
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }
    //else -- no display type match.
    if ($dowrap) {
        return format_field($item_attribute_type_r['prompt'], nl2br($value), $prompt_mask);
    } else {
        return nl2br($value);
    }
}
Example #13
0
function install_check_php_settings()
{
    $buffer = "<h3>PHP Settings</h3>\n";
    $buffer .= "<table>";
    if (opendb_version_compare(phpversion(), "5.0.0", ">=")) {
        $buffer .= format_field("PHP Version", phpversion());
    } else {
        $buffer .= format_field("PHP Version", "<span class='error'>" . phpversion() . " (must be >= 5.0.0)</span>");
    }
    if (preg_match("/([0-9]+)M/", ini_get('memory_limit'), $matches)) {
        if (is_numeric($matches[1]) && $matches[1] >= 8) {
            $buffer .= format_field("Memory Limit", $matches[0]);
        } else {
            $buffer .= format_field("Memory Limit", "<span class='error'>" . $matches[0] . " (should be >= 8M)</span>");
        }
    }
    if (ini_get('safe_mode') == 0 || strtolower(ini_get('safe_mode')) == 'off') {
        $buffer .= format_field("Safe Mode", "off");
    } else {
        $buffer .= format_field("Safe Mode", "<span class='error'>on (item / http cache, file uploads, and potentially other parts of the system do not function well with safe mode enabled.)</span>");
    }
    $max_execution_time = ini_get('max_execution_time');
    if (is_numeric(ini_get('max_execution_time')) && (ini_get('max_execution_time') >= 600 || @set_time_limit('600') && ini_get('max_execution_time') >= 600)) {
        if ($max_execution_time < 600) {
            $max_execution_time = 600;
            // set_time_limit can be activated, so for display purposes, up it to the 600, which is what we use
        }
        $buffer .= format_field("Max Execution Time", $max_execution_time);
    } else {
        $buffer .= format_field("Max Execution Time", "<span class='error'>" . $max_execution_time . " (set_time_limit disabled - set_time_limit should be enabled or max_execution_time >= 600)</span>");
    }
    if (ini_get('register_globals') == 0 || strtolower(ini_get('register_globals')) == 'off') {
        $buffer .= format_field("Register Globals", "off");
    } else {
        $buffer .= format_field("Register Globals", "<span class='warn'>on (register globals is not required)</span>");
    }
    if (ini_get('file_uploads') == 1 || strtolower(ini_get('file_uploads')) == 'on') {
        $buffer .= format_field("File Uploads", "on");
    } else {
        $buffer .= format_field("File Uploads", "<span class='error'>off (import functionality will be disabled)</span>");
    }
    $buffer .= "</table>";
    return $buffer;
}
Example #14
0
            $itemTypeBlock .= "</select>";
            echo format_field(get_opendb_lang_var('s_attribute_type'), $attrTypeSelect);
            echo format_field(get_opendb_lang_var('s_attribute_type_lookup'), "\n<select name=\"lookup_attribute_val\" id=\"search-lookupattributeval\" onChange=\"if(this.options[this.options.selectedIndex].value.length>0){this.form['attribute_val'].disabled=true;}else{this.form['attribute_val'].disabled=false;}\">" . "\n<option value=\"\">" . get_opendb_lang_var('use_the_value_field') . " ---->" . "\n</select>");
            echo format_field(get_opendb_lang_var('attribute_val'), "<input type=\"text\" class=\"text\" name=\"attribute_val\" id=\"search-attributeval\" size=\"50\" value=\"\">" . "\n<ul class=\"searchInputOptions\">" . "\n<li><input type=\"radio\" class=\"radio\" name=\"attr_match\" value=\"word\">" . get_opendb_lang_var('word_match') . "</li>" . "\n<li><input type=\"radio\" class=\"radio\" name=\"attr_match\" value=\"partial\" CHECKED>" . get_opendb_lang_var('partial_match') . "</li>" . "\n<li><input type=\"radio\" class=\"radio\" name=\"attr_match\" value=\"exact\">" . get_opendb_lang_var('exact_match') . "</li>" . "\n<li><input type=\"checkbox\" class=\"checkbox\" name=\"attr_case\" value=\"case_sensitive\">" . get_opendb_lang_var('case_sensitive') . "</li>" . "\n</ul>");
            if (strlen($HTTP_VARS['not_owner_id']) > 0) {
                echo "\n<input type=\"hidden\" name=\"not_owner_id\" value=\"" . $HTTP_VARS['not_owner_id'] . "\">";
            }
            echo format_field(get_opendb_lang_var('owner'), "\n<select name=\"owner_id\" id=\"search-owner\">" . "\n<option value=\"\">-------------- " . get_opendb_lang_var('all') . " --------------" . custom_select('owner_id', fetch_user_rs(PERM_ITEM_OWNER), '%fullname% (%user_id%)', 'NA', NULL, 'user_id') . "\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', array()));
                // value
            }
            echo format_field(get_opendb_lang_var('status_comment'), "\n<input type=\"text\" class=\"text\" name=\"status_comment\" id=\"search-statuscomment\" size=\"50\">" . "\n<ul class=\"searchInputOptions\">" . "\n<li><input type=\"radio\" class=\"radio\" name=\"status_comment_match\" value=\"word\">" . get_opendb_lang_var('word_match') . "</li>" . "\n<li><input type=\"radio\" class=\"radio\" name=\"status_comment_match\" value=\"partial\" CHECKED>" . get_opendb_lang_var('partial_match') . "</li>" . "\n<li><input type=\"radio\" class=\"radio\" name=\"status_comment_match\" value=\"exact\">" . get_opendb_lang_var('exact_match') . "</li>" . "\n<li><input type=\"checkbox\" class=\"checkbox\" name=\"status_comment_case\" value=\"case_sensitive\">" . get_opendb_lang_var('case_sensitive') . "</li>" . "\n</ul>");
            echo format_field(get_opendb_lang_var('updated'), "\n<select name=\"update_on_days\" id=\"search-updateondays\" onChange=\"if(this.options[this.options.selectedIndex].value.length>0){this.form['update_on'].disabled=true;}else{this.form['update_on'].disabled=false;}\">" . "\n<option value=\"\">" . get_opendb_lang_var('specify_datetime') . " ---->" . "\n<option value=\"1\">" . get_opendb_lang_var('one_day_ago') . "\n<option value=\"7\">" . get_opendb_lang_var('one_week_ago') . "\n<option value=\"28\">" . get_opendb_lang_var('one_month_ago') . "\n<option value=\"365\">" . get_opendb_lang_var('one_year_ago') . "\n</select>" . get_input_field("update_on", NULL, NULL, "datetime(" . get_opendb_config_var('search', 'datetime_mask') . ")", "N", NULL, FALSE));
            echo format_field(get_opendb_lang_var('order_by'), "\n<select name=\"order_by\"  id=\"search-orderby\">" . "\n<option value=\"title\" SELECTED>" . get_opendb_lang_var('title') . "\n<option value=\"owner_id\">" . get_opendb_lang_var('owner') . "\n<option value=\"category\">" . get_opendb_lang_var('category') . "\n<option value=\"s_item_type\">" . get_opendb_lang_var('item_type') . "\n<option value=\"s_status_type\">" . get_opendb_lang_var('s_status_type') . "\n<option value=\"update_on\">" . get_opendb_lang_var('update_date') . "\n</select>" . "\n<input type=\"radio\" class=\"radio\" name=\"sortorder\" value=\"ASC\" CHECKED>" . get_opendb_lang_var('asc') . "\n<input type=\"radio\" class=\"radio\" name=\"sortorder\" value=\"DESC\">" . get_opendb_lang_var('desc'));
            echo "</table>";
            echo "\n<input type=\"submit\" class=\"submit\" value=\"" . get_opendb_lang_var('search') . "\">";
            echo "</form>";
            echo _theme_footer();
        } else {
            opendb_not_authorised_page(PERM_VIEW_ADVANCED_SEARCH, $HTTP_VARS);
        }
    } else {
        // invalid login, so login instead.
        redirect_login($PHP_SELF, $HTTP_VARS);
    }
} else {
    //if(is_site_enabled())
    opendb_site_disabled();
}
Example #15
0
function get_edit_item_instance_form($op, $item_r, $status_type_r, $HTTP_VARS)
{
    $formContents = "<div class=\"tabContentHidden\" id=\"instance_info\">";
    $formContents .= get_related_item_search_script();
    $results = fetch_item_attribute_type_rs($item_r['s_item_type'], 'instance_field_types');
    if ($results) {
        $formContents .= "<h3>" . get_opendb_lang_var('instance_info') . "</h3>";
        $formContents .= "\n<table>";
        if (($op == 'edit' || $op == 'refresh') && $status_type_r['change_owner_ind'] == 'Y') {
            $formContents .= format_field(get_opendb_lang_var('owner'), "\n<select name=\"owner_id\">" . custom_select('owner_id', fetch_user_rs(PERM_ITEM_OWNER, INCLUDE_ROLE_PERMISSIONS, INCLUDE_CURRENT_USER, EXCLUDE_DEACTIVATED_USER, 'user_id', 'ASC'), '%fullname% (%user_id%)', 'NA', ifempty($HTTP_VARS['owner_id'], $item_r['owner_id']), 'user_id') . "\n</select>");
        }
        if ($op == 'newinstance' || $op == 'clone_item') {
            $item_r['s_status_type'] = NULL;
            $item_r['status_comment'] = NULL;
            $item_r['borrow_duration'] = NULL;
        }
        while ($item_attribute_type_r = db_fetch_assoc($results)) {
            if ($item_attribute_type_r['s_field_type'] == 'STATUSTYPE') {
                $status_type = ifempty(filter_item_input_field($item_attribute_type_r, $HTTP_VARS['s_status_type']), $item_r['s_status_type']);
                if ($op == 'new' || $op == 'site' || $op == 'newinstance' || $op == 'clone_item') {
                    $lookup_results = fetch_newitem_status_type_rs();
                } else {
                    // If item has borrowed records, then no s_status_type with borrow_ind == 'X' should be included.
                    $lookup_results = fetch_update_status_type_rs($status_type);
                }
                if ($lookup_results && db_num_rows($lookup_results) > 0) {
                    $formContents .= format_field($item_attribute_type_r['prompt'], radio_grid('s_status_type', $lookup_results, '%img%', 'VERTICAL', $status_type));
                    // value
                }
            } else {
                if ($item_attribute_type_r['s_field_type'] == 'STATUSCMNT') {
                    $status_comment = ifempty(filter_item_input_field($item_attribute_type_r, $HTTP_VARS['status_comment']), $item_r['status_comment']);
                    $formContents .= get_item_input_field('status_comment', $item_attribute_type_r, NULL, $status_comment);
                } else {
                    if ($item_attribute_type_r['s_field_type'] == 'DURATION') {
                        $borrow_duration = ifempty(filter_item_input_field($item_attribute_type_r, $HTTP_VARS['borrow_duration']), $item_r['borrow_duration']);
                        // The S_DURATION lookup list will most likely include an 'Undefined' option, that equates
                        // to an empty string.  So for Updates, we want to allow for a match, by forcing any NULL
                        // value to a empty string.  The reason why we do this, is because the Borrow Duration was
                        // probably set to 'Undefined', but because this equated to an empty string, the field was
                        // never updated.
                        if ($op != 'new' && $op != 'site') {
                            if ($borrow_duration === NULL) {
                                $borrow_duration = '';
                            }
                        }
                        $formContents .= get_item_input_field('borrow_duration', $item_attribute_type_r, NULL, $borrow_duration);
                    }
                }
            }
        }
        //while
        db_free_result($results);
        $formContents .= "\n</table>";
    }
    if (get_opendb_config_var('item_input', 'related_item_support') !== FALSE) {
        $formContents .= "<h3>" . get_opendb_lang_var('add_related_parent') . "</h3>";
        $formContents .= "\n<table>";
        $formContents .= format_field(get_opendb_lang_var('parent_item_filter'), '<input type="text" name="parent_item_filter" id="parent_item_filter">');
        $formContents .= format_field(get_opendb_lang_var('parent_item'), format_item_parents_select($HTTP_VARS, $item_r, '%parent_only%'));
        $formContents .= "\n</table>";
        $relatedItems = get_related_items_listing($item_r, $HTTP_VARS, RELATED_PARENTS_MODE);
        if ($relatedItems != NULL) {
            $formContents .= "<h3>" . get_opendb_lang_var('related_parent_item(s)') . "</h3>";
            $formContents .= $relatedItems;
        }
    }
    $formContents .= "</div>";
    return $formContents;
}
Example #16
0
    } elseif ($search_depth != "All") {
        $query .= " AND type = '{$search_depth}'";
    }
    $query .= " ORDER BY {$sort_column} {$sort_direction}";
    /* perform search */
    $result = do_query($query);
    /* display results */
    $result_count = number_rows($result);
    if ($result_count) {
        print "<tr><td colspan=\"5\">" . $AppUI->_('There were') . " " . $result_count . " " . $AppUI->_('results') . " " . $AppUI->_('in the given search') . ".</td></tr>\n";
        while ($row = result2hash($result)) {
            print "<tr>";
            for ($loop = 0; $loop < count($fields["columns"]); $loop++) {
                print "<td align=\"" . $fields["aligns"][$loop] . "\">";
                if ($loop == 4) {
                    print format_field($AppUI->_($row[$fields["columns"][$loop]]), $fields["types"][$loop]);
                } else {
                    print format_field($row[$fields["columns"][$loop]], $fields["types"][$loop]);
                }
                print "</td>";
            }
            print "</tr>\n";
        }
    } else {
        print "<tr><td>" . $AppUI->_('There were') . " " . $AppUI->_('no results') . " " . $AppUI->_('in the given search') . ".</td></tr>\n";
    }
    /* end results table */
    print "</table>\n";
}
/* end form */
print "</form>\n";
Example #17
0
                         $HTTP_VARS['op'] = 'my_reserve_basket';
                         if (is_exists_item_instance($HTTP_VARS['item_id'], $HTTP_VARS['instance_no'])) {
                             $footer_links_r[] = array(url => "item_display.php?item_id=" . $HTTP_VARS['item_id'] . "&instance_no=" . $HTTP_VARS['instance_no'], text => get_opendb_lang_var('back_to_item'));
                         }
                         if (is_opendb_session_var('listing_url_vars')) {
                             $footer_links_r[] = array(url => "listings.php?" . get_url_string(get_opendb_session_var('listing_url_vars')), text => get_opendb_lang_var('back_to_listing'));
                         }
                     } else {
                         if ($HTTP_VARS['op'] == 'admin_history') {
                             echo _theme_header(get_opendb_lang_var('borrower_history'));
                             echo "<h2>" . get_opendb_lang_var('borrower_history') . "</h2>";
                             echo "\n<form action=\"{$PHP_SELF}\" method=\"GET\">";
                             echo "\n<input type=\"hidden\" name=\"op\" value=\"my_history\">";
                             echo "\n<table>";
                             $results = fetch_user_rs(PERM_USER_BORROWER, ROLE_PERMISSIONS_INCLUDE, INCLUDE_CURRENT_USER, EXCLUDE_DEACTIVATED_USER, "fullname", "ASC");
                             echo format_field(get_opendb_lang_var('borrower'), custom_select('uid', $results, '%fullname% (%user_id%)', 1, get_opendb_session_var('user_id'), 'user_id'));
                             echo "</table>";
                             echo "<input type=\"submit\" class=\"submit\" value=\"" . get_opendb_lang_var('submit') . "\">";
                             echo "</form>";
                             echo _theme_footer();
                             $show_listings = FALSE;
                         } else {
                             opendb_operation_not_available();
                             $show_listings = FALSE;
                         }
                     }
                 }
             }
         }
     }
 }
Example #18
0
function display_edit_form($status_type_r, $HTTP_VARS = NULL)
{
    global $_COLUMN_DESC;
    if (is_array($status_type_r)) {
        echo get_input_field("s_status_type", NULL, $_COLUMN_DESC['s_status_type'], "readonly", "Y", $status_type_r['s_status_type'], TRUE, "%prompt% <a class=\"smlink\" href=\"#\" onmouseover=\"" . get_edit_form_tooltip('s_status_type') . "\" onmouseout=\"return hide_tooltip();\">(?)</a>");
    } else {
        echo get_input_field("s_status_type", NULL, $_COLUMN_DESC['s_status_type'], "text(1,1)", "Y", $HTTP_VARS['s_status_type'], TRUE, "%prompt% <a class=\"smlink\" href=\"#\" onmouseover=\"" . get_edit_form_tooltip('s_status_type') . "\" onmouseout=\"return hide_tooltip();\">(?)</a>");
    }
    echo get_input_field("description", NULL, $_COLUMN_DESC['description'], "text(30,60)", "Y", ifempty($status_type_r['description'], $HTTP_VARS['description']), TRUE, "%prompt% <a class=\"smlink\" href=\"#\" onmouseover=\"" . get_edit_form_tooltip('description') . "\" onmouseout=\"return hide_tooltip();\">(?)</a>");
    $field = get_input_field("img", NULL, $_COLUMN_DESC['img'], "url(15,*,\"gif,jpg,png\",N)", "N", ifempty($status_type_r['img'], $HTTP_VARS['img']), FALSE);
    $image_src = theme_image_src(ifempty($status_type_r['img'], $HTTP_VARS['img']));
    if ($image_src !== FALSE && strlen($image_src) > 0) {
        $field .= " <img src=\"{$image_src}\">";
    }
    echo format_field($_COLUMN_DESC['img'], $field, "%prompt% <a class=\"smlink\" href=\"#\" onmouseover=\"" . get_edit_form_tooltip('img') . "\" onmouseout=\"return hide_tooltip();\">(?)</a>");
    echo get_input_field("delete_ind", NULL, $_COLUMN_DESC['delete_ind'], "value_radio_grid('Y,N')", "N", ifempty($status_type_r['delete_ind'], $HTTP_VARS['delete_ind']), TRUE, "%prompt% <a class=\"smlink\" href=\"#\" onmouseover=\"" . get_edit_form_tooltip('delete_ind') . "\" onmouseout=\"return hide_tooltip();\">(?)</a>");
    echo get_input_field("change_owner_ind", NULL, $_COLUMN_DESC['change_owner_ind'], "value_radio_grid('Y,N')", "N", ifempty($status_type_r['change_owner_ind'], ifempty($HTTP_VARS['change_owner_ind'], "N")), TRUE, "%prompt% <a class=\"smlink\" href=\"#\" onmouseover=\"" . get_edit_form_tooltip('change_owner_ind') . "\" onmouseout=\"return hide_tooltip();\">(?)</a>");
    echo get_input_field("borrow_ind", NULL, $_COLUMN_DESC['borrow_ind'], "value_radio_grid('Y,N')", "N", ifempty($status_type_r['borrow_ind'], $HTTP_VARS['borrow_ind']), TRUE, "%prompt% <a class=\"smlink\" href=\"#\" onmouseover=\"" . get_edit_form_tooltip('borrow_ind') . "\" onmouseout=\"return hide_tooltip();\">(?)</a>");
    echo get_input_field("status_comment_ind", NULL, $_COLUMN_DESC['status_comment_ind'], "value_radio_grid('Y,N')", "N", ifempty($status_type_r['status_comment_ind'], $HTTP_VARS['status_comment_ind']), TRUE, "%prompt% <a class=\"smlink\" href=\"#\" onmouseover=\"" . get_edit_form_tooltip('status_comment_ind') . "\" onmouseout=\"return hide_tooltip();\">(?)</a>");
    echo get_input_field("hidden_ind", NULL, $_COLUMN_DESC['hidden_ind'], "value_radio_grid('Y,N')", "N", ifempty($status_type_r['hidden_ind'], $HTTP_VARS['hidden_ind']), TRUE, "%prompt% <a class=\"smlink\" href=\"#\" onmouseover=\"" . get_edit_form_tooltip('hidden_ind') . "\" onmouseout=\"return hide_tooltip();\">(?)</a>");
    echo get_input_field("default_ind", NULL, $_COLUMN_DESC['default_ind'], "checkbox(Y,N)", "N", ifempty($status_type_r['default_ind'], $HTTP_VARS['default_ind']), TRUE, "%prompt% <a class=\"smlink\" href=\"#\" onmouseover=\"" . get_edit_form_tooltip('default_ind') . "\" onmouseout=\"return hide_tooltip();\">(?)</a>");
    if (is_array($status_type_r)) {
        echo get_input_field("closed_ind", NULL, $_COLUMN_DESC['closed_ind'], "checkbox(Y,N)", "N", ifempty($status_type_r['closed_ind'], $HTTP_VARS['closed_ind']), TRUE, "%prompt% <a class=\"smlink\" href=\"#\" onmouseover=\"" . get_edit_form_tooltip('closed_ind') . "\" onmouseout=\"return hide_tooltip();\">(?)</a>");
    }
}
Example #19
0
/**
 * @param $op is 'edit' or 'new'
 */
function get_user_input_form($user_r, $HTTP_VARS)
{
    global $PHP_SELF;
    $buffer .= "<form action=\"{$PHP_SELF}\" method=\"POST\">";
    $buffer .= "<table class=\"userInputForm\">";
    if (is_not_empty_array($user_r)) {
        $buffer .= get_input_field("user_id", NULL, get_opendb_lang_var('userid'), "readonly", "", $user_r['user_id'], TRUE);
    } else {
        $buffer .= get_input_field("user_id", NULL, get_opendb_lang_var('userid'), "filtered(20,20,a-zA-Z0-9_.)", "Y", $HTTP_VARS['user_id'], TRUE);
    }
    if (is_not_empty_array($user_r) && !is_user_granted_permission(PERM_ADMIN_USER_PROFILE)) {
        $role_r = fetch_role_r($user_r['user_role']);
        $buffer .= get_input_field("user_role", NULL, get_opendb_lang_var('user_role'), "readonly", "", $role_r['description'], TRUE);
    } else {
        $buffer .= format_field(get_opendb_lang_var('user_role'), custom_select('user_role', fetch_user_role_rs($HTTP_VARS['op'] == 'signup' ? EXCLUDE_SIGNUP_UNAVAILABLE_USER : INCLUDE_SIGNUP_UNAVAILABLE_USER), "%description%", '1', ifempty($user_r['user_role'], $HTTP_VARS['user_role']), 'role_name'));
    }
    $buffer .= get_input_field("fullname", NULL, get_opendb_lang_var('fullname'), "text(30,100)", "Y", ifempty($HTTP_VARS['fullname'], $user_r['fullname']), TRUE);
    $buffer .= get_input_field("email_addr", NULL, get_opendb_lang_var('email'), "email(30,100)", "Y", ifempty($HTTP_VARS['email_addr'], $user_r['email_addr']), TRUE);
    if (get_opendb_config_var('user_admin', 'user_themes_support') !== FALSE) {
        $uid_theme = ifempty($HTTP_VARS['uid_theme'], $user_r['theme']);
        $buffer .= format_field(get_opendb_lang_var('user_theme'), custom_select("uid_theme", get_user_theme_r(), "%value%", 1, is_exists_theme($uid_theme) ? $uid_theme : get_opendb_config_var('site', 'theme')));
        // If theme no longer exists, then set to default!
    }
    if (get_opendb_config_var('user_admin', 'user_language_support') !== FALSE) {
        // Do not bother with language input field if only one language pack available.
        if (fetch_language_cnt() > 1) {
            $uid_language = ifempty($HTTP_VARS['uid_language'], $user_r['language']);
            $buffer .= format_field(get_opendb_lang_var('user_language'), custom_select('uid_language', fetch_language_rs(), "%language%", 1, is_exists_language($uid_language) ? $uid_language : get_opendb_config_var('site', 'language'), 'language', NULL, 'default_ind'));
            // If language no longer exists, then set to default!
        }
    }
    $buffer .= "</table>";
    // Now do the addresses
    if (is_not_empty_array($user_r)) {
        $addr_results = fetch_user_address_type_rs($user_r['user_id'], TRUE);
    } else {
        $addr_results = fetch_address_type_rs(TRUE);
    }
    if ($addr_results) {
        while ($address_type_r = db_fetch_assoc($addr_results)) {
            $v_address_type = strtolower($address_type_r['s_address_type']);
            if (is_not_empty_array($user_r)) {
                $attr_results = fetch_address_type_attribute_type_rs($address_type_r['s_address_type'], 'update', TRUE);
            } else {
                $attr_results = fetch_address_type_attribute_type_rs($address_type_r['s_address_type'], 'update', TRUE);
            }
            if ($attr_results) {
                $buffer .= '<h3>' . $address_type_r['description'] . '</h3>';
                $buffer .= "<ul class=\"addressIndicators\">";
                $buffer .= '<li><input type="checkbox" class="checkbox" name="' . $v_address_type . '[public_address_ind]" value="Y"' . (ifempty($address_type_r['public_address_ind'], $HTTP_VARS[$v_address_type]['public_address_ind']) == 'Y' ? ' CHECKED' : '') . '">' . get_opendb_lang_var('public_address_indicator') . '</li>';
                $buffer .= '<li><input type="checkbox" class="checkbox" name="' . $v_address_type . '[borrow_address_ind]" value="Y"' . (ifempty($address_type_r['borrow_address_ind'], $HTTP_VARS[$v_address_type]['borrow_address_ind']) == 'Y' ? ' CHECKED' : '') . '">' . get_opendb_lang_var('borrow_address_indicator') . '</li>';
                $buffer .= "</ul>";
                $buffer .= "<table class=\"addressInputForm\">";
                while ($addr_attribute_type_r = db_fetch_assoc($attr_results)) {
                    $fieldname = get_field_name($addr_attribute_type_r['s_attribute_type'], $addr_attribute_type_r['order_no']);
                    $value = NULL;
                    if ($address_type_r['sequence_number'] !== NULL) {
                        if (is_lookup_attribute_type($addr_attribute_type_r['s_attribute_type'])) {
                            $value = fetch_user_address_lookup_attribute_val($address_type_r['sequence_number'], $addr_attribute_type_r['s_attribute_type'], $addr_attribute_type_r['order_no']);
                        } else {
                            $value = fetch_user_address_attribute_val($address_type_r['sequence_number'], $addr_attribute_type_r['s_attribute_type'], $addr_attribute_type_r['order_no']);
                        }
                        $value = ifempty(filter_item_input_field($addr_attribute_type_r, $HTTP_VARS[$v_address_type][$fieldname]), $value);
                    } else {
                        $value = filter_item_input_field($addr_attribute_type_r, $HTTP_VARS[$v_address_type][$fieldname]);
                    }
                    // If this is an edit operation - the value must be NOT NULL
                    // for some widgets to work properly.
                    if ($address_type_r['sequence_number'] !== NULL && $value === NULL) {
                        $value = '';
                    }
                    $buffer .= get_item_input_field($v_address_type . '[' . $fieldname . ']', $addr_attribute_type_r, NULL, $value);
                }
                //while
                db_free_result($attr_results);
                $buffer .= "</table>";
            }
            //if($attr_results)
        }
        //while
        db_free_result($addr_results);
    }
    //if($addr_results)
    $buffer .= format_help_block(array('img' => 'compulsory.gif', 'text' => get_opendb_lang_var('compulsory_field'), id => 'compulsory'));
    if ($HTTP_VARS['op'] == 'new_user') {
        $buffer .= "<h3>" . get_opendb_lang_var('password') . "</h3>";
        if (get_opendb_config_var('user_admin', 'user_passwd_change_allowed') !== FALSE || is_user_granted_permission(PERM_ADMIN_CHANGE_PASSWORD)) {
            $buffer .= "<table class=\"changePasswordForm\">";
            if (is_valid_opendb_mailer()) {
                $compulsory_ind = 'N';
            } else {
                $compulsory_ind = 'Y';
            }
            $buffer .= get_input_field("pwd", NULL, get_opendb_lang_var('new_passwd'), "password(30,40)", $compulsory_ind, "", TRUE);
            $buffer .= get_input_field("confirmpwd", NULL, get_opendb_lang_var('confirm_passwd'), "password(30,40)", $compulsory_ind, "", TRUE, NULL, get_opendb_config_var('widgets', 'enable_javascript_validation') !== FALSE ? "if( (this.form.pwd.value.length!=0 || this.form.confirmpwd.value.length!=0) && this.form.pwd.value!=this.form.confirmpwd.value){alert('" . get_opendb_lang_var('passwds_do_not_match') . "'); this.focus(); return false;}" : "");
            $buffer .= "\n</table>";
            if ($compulsory_ind == 'N') {
                $buffer .= format_help_block(get_opendb_lang_var('new_passwd_will_be_autogenerated_if_not_specified'));
            }
        }
    }
    if ($HTTP_VARS['op'] == 'signup' && get_opendb_config_var('login.signup', 'disable_captcha') !== TRUE) {
        $buffer .= render_secret_image_form_field();
    }
    if (get_opendb_config_var('widgets', 'enable_javascript_validation') !== FALSE) {
        $onclick_event = "if(!checkForm(this.form)){return false;}else{this.form.submit();}";
    } else {
        $onclick_event = "this.form.submit();";
    }
    if (is_not_empty_array($user_r)) {
        $buffer .= "\n<input type=\"hidden\" name=\"op\" value=\"update\">";
        if ($HTTP_VARS['user_id'] != get_opendb_session_var('user_id')) {
            $buffer .= "\n<input type=\"button\" class=\"button\" onclick=\"this.form.op.value='update'; {$onclick_event}\" value=\"" . get_opendb_lang_var('update_user') . "\">";
            if (is_user_not_activated($HTTP_VARS['user_id'])) {
                $buffer .= "\n<input type=\"button\" class=\"button\" onclick=\"this.form.op.value='delete'; this.form.submit();\" value=\"" . get_opendb_lang_var('delete_user') . "\">";
            } else {
                if (is_user_active($HTTP_VARS['user_id'])) {
                    $buffer .= "\n<input type=\"button\" class=\"button\" onclick=\"this.form.op.value='deactivate'; this.form.submit();\" value=\"" . get_opendb_lang_var('deactivate_user') . "\">";
                }
            }
            if (!is_user_active($HTTP_VARS['user_id'])) {
                $buffer .= "\n<input type=\"button\" class=\"button\" onclick=\"this.form.op.value='activate'; this.form.submit();\" value=\"" . get_opendb_lang_var('activate_user') . "\">";
            }
        } else {
            $buffer .= "\n<input type=\"button\" class=\"button\" onclick=\"{$onclick_event}\" value=\"" . get_opendb_lang_var('update_details') . "\">";
        }
    } else {
        if ($HTTP_VARS['op'] != 'signup') {
            if (is_valid_opendb_mailer()) {
                if ($HTTP_VARS['op'] == 'new_user') {
                    if ($HTTP_VARS['email_user'] == 'Y') {
                        $checked = "CHECKED";
                    } else {
                        $checked = "";
                    }
                } else {
                    $checked = "CHECKED";
                }
                $buffer .= "<p><input type=\"checkbox\" class=\"checkbox\" id=\"email_user\" name=\"email_user\" value=\"Y\" {$checked}>" . get_opendb_lang_var('send_welcome_email') . "</p>";
            }
            $buffer .= "\n<input type=\"hidden\" name=\"op\" value=\"insert\">" . "\n<input type=\"button\" class=\"button\" onclick=\"{$onclick_event}\" value=\"" . get_opendb_lang_var('add_user') . "\">";
        } else {
            $buffer .= "\n<input type=\"hidden\" name=\"op\" value=\"signup\">" . "<input type=\"hidden\" name=\"op2\" value=\"send_info\">" . "<input type=\"button\" class=\"button\" onclick=\"{$onclick_event}\" value=\"" . get_opendb_lang_var('submit') . "\">";
        }
    }
    $buffer .= "\n</form>";
    return $buffer;
}
Example #20
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>";
}
Example #21
0
                $new_direction == "ASC";
            }
        }
        print "&amp;direction={$new_direction}";
        print '" class="hdr">' . $AppUI->_($fields["headings"][$loop]) . "</a></th>\n";
    }
    print "</tr>\n";
    while ($row = result2hash($result)) {
        print "<tr style='height:25px;'>\n";
        for ($loop = 0; $loop < count($fields["headings"]); $loop++) {
            print "<td  bgcolor='white' align=" . $fields["aligns"][$loop] . ">\n";
            //translate some information, some not
            if ($fields["headings"][$loop] == "Status") {
                print $AppUI->_(format_field($row[$fields["columns"][$loop]], $fields["types"][$loop], $row[$fields["columns"][0]])) . "\n";
            } else {
                print format_field($row[$fields["columns"][$loop]], $fields["types"][$loop], $row[$fields["columns"][0]]) . "\n";
            }
            print "</td>\n";
        }
        print "</tr>\n";
    }
} else {
    print "<tr style='height:25px;'>\n";
    print "<td align='center' colspan='" . count($fields["headings"]) . "'>\n";
    print $AppUI->_('There are no') . " ";
    print $type == "All" ? "" : mb_strtolower($AppUI->_($type)) . " ";
    print $AppUI->_('tickets') . ".\n";
    print "</td>\n";
    print "</tr>\n";
}
/* output action links */
Example #22
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'));
}