echo popup_link('<a href="' . module_faq::link_open_list($ticket['faq_product_id']) . '">' . _l('FAQ') . '</a>', array('force' => true, 'width' => 1100, 'height' => 600));
        //}
    }));
}
if (module_config::c('ticket_support_accounts', 1) && module_ticket::get_accounts_rel()) {
    $fieldset_data['elements'][] = array('title' => _l('Account'), 'fields' => array(array('type' => module_ticket::can_edit_tickets() ? 'select' : 'html', 'name' => 'ticket_account_id', 'value' => module_ticket::can_edit_tickets() ? $ticket['ticket_account_id'] : friendly_key(module_ticket::get_accounts_rel(), $ticket['ticket_account_id']), 'options' => module_ticket::get_accounts_rel())));
}
$fieldset_data['elements'][] = array('title' => _l('Status'), 'fields' => array(array('type' => module_ticket::can_edit_tickets() ? 'select' : 'html', 'name' => 'status_id', 'value' => module_ticket::can_edit_tickets() ? $ticket['status_id'] : friendly_key(module_ticket::get_statuses(), $ticket['status_id']), 'options' => module_ticket::get_statuses())));
if (module_ticket::can_edit_tickets() || module_config::c('ticket_allow_priority_selection', 0)) {
    $priorities = module_ticket::get_ticket_priorities();
    if (!module_ticket::can_edit_tickets() && isset($priorities[_TICKET_PRIORITY_STATUS_ID]) && $ticket['priority'] != _TICKET_PRIORITY_STATUS_ID) {
        unset($priorities[_TICKET_PRIORITY_STATUS_ID]);
    }
    $fieldset_data['elements'][] = array('title' => _l('Priority'), 'fields' => array(array('type' => 'select', 'name' => 'priority', 'value' => $ticket['priority'], 'blank' => false, 'options' => $priorities)));
}
$fieldset_data['extra_settings'] = array('owner_table' => 'ticket', 'owner_key' => 'ticket_id', 'owner_id' => $ticket['ticket_id'], 'layout' => 'table_row', 'allow_new' => module_extra::can_i('create', 'Tickets'), 'allow_edit' => module_extra::can_i('edit', 'Tickets'));
echo module_form::generate_fieldset($fieldset_data);
unset($fieldset_data);
$done_messages = false;
if (class_exists('module_mobile', false)) {
    if (module_mobile::is_mobile_browser()) {
        // we're on mobile, display the ticket messages here:
        $tickets_in_reverse = false;
        include module_theme::include_ucm('includes/plugin_ticket/pages/ticket_admin_edit_messages.php');
        $done_messages = true;
    }
}
if ($ticket['user_id']) {
    if (module_config::c('ticket_other_list_by', 'user') == 'user') {
        $other_tickets = module_ticket::get_tickets(array('user_id' => $ticket['user_id']));
    } else {
function metis_print_extra_search_bar($callback, $owner_table, $options = array())
{
    ob_start();
    // let the themes override this search bar function.
    if (module_extra::can_i('view', 'Extra Fields')) {
        $defaults = module_extra::get_defaults($owner_table);
        $searchable_fields = array();
        foreach ($defaults as $default) {
            if (isset($default['searchable']) && $default['searchable']) {
                $searchable_fields[$default['key']] = $default;
            }
        }
        foreach ($searchable_fields as $searchable_field) {
            ?>
                <div class="form-group search_title">
                    <?php 
            echo htmlspecialchars($searchable_field['key']);
            ?>
:
                </div>
                <div class="form-group search_input">
                    <?php 
            module_form::generate_form_element(array('type' => 'text', 'name' => 'search[extra_fields][' . htmlspecialchars($searchable_field['key']) . ']'));
            ?>
                </div>
                <?php 
        }
    }
    return ob_get_clean();
}
    $fieldset_data['elements']['primary'] = array('title' => 'Primary', 'fields' => array(array('type' => 'check', 'name' => 'customer_primary', 'value' => '1', 'checked' => $primary), _hr('This users details will be used as a primary point of contact for this customer. These details will display in the main customer listing for this customer. Also if you send an invoice or a newsletter to this "customer" then this email address will be used.')));
} else {
    if (isset($show_more_button) && $show_more_button) {
        $fieldset_data['heading']['button'] = array('title' => 'More', 'url' => module_user::link_open_contact($user_id, false));
    }
}
$fieldset_data['elements']['fname'] = array('title' => 'First Name', 'fields' => array(array('type' => 'text', 'name' => 'name', 'value' => $user['name'])));
$fieldset_data['elements']['last_name'] = array('title' => 'Last Name', 'fields' => array(array('type' => 'text', 'name' => 'last_name', 'value' => $user['last_name'])));
$fieldset_data['elements']['email'] = array('title' => 'Email Address', 'fields' => array(array('type' => 'text', 'name' => 'email', 'value' => $user['email'])));
$fieldset_data['elements']['phone'] = array('title' => 'Phone', 'fields' => array(array('type' => 'text', 'name' => 'phone', 'value' => $user['phone'])));
$fieldset_data['elements']['mobile'] = array('title' => 'Mobile', 'fields' => array(array('type' => 'text', 'name' => 'mobile', 'value' => $user['mobile'])));
$fieldset_data['elements']['fax'] = array('title' => 'Fax', 'fields' => array(array('type' => 'text', 'name' => 'fax', 'value' => $user['fax'])));
if (class_exists('module_language', false) && isset($user['language'])) {
    $attr = array();
    foreach (module_language::get_languages_attributes() as $langauge) {
        $attr[$langauge['language_code']] = $langauge['language_name'];
    }
    $fieldset_data['elements']['language'] = array('title' => 'Language', 'fields' => array(array('type' => 'select', 'name' => 'language', 'options' => $attr, 'value' => $user['language'])));
}
if (class_exists('module_extra') && module_extra::is_plugin_enabled() && module_extra::can_i('view', 'Contacts')) {
    $fieldset_data['extra_settings'] = array('owner_table' => 'user', 'owner_key' => 'user_id', 'owner_id' => $user['user_id'], 'layout' => 'table_row', 'allow_new' => module_extra::can_i('create', 'Contacts'), 'allow_edit' => module_extra::can_i('edit', 'Contacts'));
}
echo module_form::generate_fieldset($fieldset_data);
unset($fieldset_data);
?>


	<input type="hidden" name="user_id" value="<?php 
echo $user_id;
?>
" />
    }
    //print_heading($heading);
    $company_fields = array();
    foreach ($companys as $company) {
        $company_fields[] = array('type' => 'hidden', 'name' => "available_customer_company[" . $company['company_id'] . "]", 'value' => 1);
        $company_fields[] = array('type' => 'check', 'name' => "customer_company[" . $company['company_id'] . "]", 'value' => $company['company_id'], 'checked' => isset($customer['company_ids'][$company['company_id']]) || !$customer_id && !module_company::can_i('edit', 'Company'), 'label' => htmlspecialchars($company['name']));
    }
    $fieldset_data = array('heading' => $heading, 'class' => 'tableclass tableclass_form tableclass_full', 'elements' => array('company' => array('title' => _l('Company'), 'fields' => $company_fields)));
    echo module_form::generate_fieldset($fieldset_data);
}
/** CUSTOMER INFORMATION **/
$responsive_summary = array();
$responsive_summary[] = htmlspecialchars($customer['customer_name']);
$fieldset_data = array('heading' => array('type' => 'h3', 'title' => $page_type_single . ' Information', 'responsive' => array('title' => $page_type_single, 'summary' => implode(', ', $responsive_summary))), 'class' => 'tableclass tableclass_form tableclass_full', 'elements' => array('name' => array('title' => _l('Name'), 'field' => array('type' => 'text', 'name' => 'customer_name', 'value' => $customer['customer_name'])), 'type' => array('title' => _l('Type'), 'ignore' => !module_customer::get_customer_types(), 'field' => array('type' => 'select', 'name' => 'customer_type_id', 'value' => $customer['customer_type_id'], 'blank' => false, 'options' => module_customer::get_customer_types(), 'options_array_id' => 'type_name'))));
if (class_exists('module_extra', false) && module_extra::is_plugin_enabled() && module_extra::can_i('view', $page_type)) {
    $fieldset_data['extra_settings'] = array('owner_table' => 'customer', 'owner_key' => 'customer_id', 'owner_id' => $customer_id, 'layout' => 'table_row', 'allow_new' => module_extra::can_i('create', $page_type), 'allow_edit' => module_extra::can_i('edit', $page_type));
}
echo module_form::generate_fieldset($fieldset_data);
unset($fieldset_data);
/** PRIMARY CONTACT DETAILS **/
// we use the "user" module to find the user details
// for the currently selected primary contact id
if ($customer['primary_user_id']) {
    if (!module_user::can_i('view', 'All ' . $page_type_single . ' Contacts', 'Customer', 'customer') && $customer['primary_user_id'] != module_security::get_loggedin_id()) {
        ob_start();
        echo '<div class="content_box_wheader"><table width="100%" border="0" cellspacing="0" cellpadding="2" class="tableclass tableclass_form"><tbody><tr><td>';
        _e('Details hidden');
        echo '</td></tr></tbody></table></div>';
        $responsive_summary = array();
        $responsive_summary[] = htmlspecialchars($customer['customer_name']);
        $fieldset_data = array('heading' => array('type' => 'h3', 'title' => 'Primary Contact Details', 'responsive' => array('title' => 'Primary Contact', 'summary' => implode(', ', $responsive_summary))), 'class' => 'tableclass tableclass_form tableclass_full', 'elements_before' => ob_get_clean());