$fieldset_data['elements'][] = array('title' => 'Menu Icon', 'fields' => array(array('type' => 'text', 'name' => 'menu_icon', 'value' => $customer_type['menu_icon'], 'help' => 'Type the icon name from http://fontawesome.io/icons/ (eg: bell). Compatible with the Metis theme.')));
    if (class_exists('module_extra', false) && module_extra::is_plugin_enabled()) {
        $fieldset_data['extra_settings'] = array('owner_table' => 'customer_type', 'owner_key' => 'customer_type_id', 'owner_id' => $customer_type_id, 'layout' => 'table_row');
    }
    echo module_form::generate_fieldset($fieldset_data);
    unset($fieldset_data);
    $form_actions = array('class' => 'action_bar action_bar_center', 'elements' => array(array('type' => 'save_button', 'name' => 'butt_save', 'value' => _l('Save')), array('ignore' => !(int) $customer_type_id, 'type' => 'delete_button', 'name' => 'butt_del', 'value' => _l('Delete')), array('type' => 'button', 'name' => 'cancel', 'value' => _l('Cancel'), 'class' => 'submit_button', 'onclick' => "window.location.href='" . $module->link_open_customer_type(false) . "';")));
    echo module_form::generate_form_actions($form_actions);
    ?>


	</form>

	<?php 
} else {
    $customer_types = module_customer::get_customer_types();
    $header = array('title' => _l('Customer Types'), 'type' => 'h2', 'main' => true, 'button' => array());
    $header['button'] = array('url' => module_customer::link_open_customer_type('new'), 'title' => _l('Add New Type'), 'type' => 'add');
    print_heading($header);
    /** START TABLE LAYOUT **/
    $table_manager = module_theme::new_table_manager();
    $columns = array();
    $columns['customer_type'] = array('title' => _l('Customer Type'), 'callback' => function ($data) {
        echo module_customer::link_open_customer_type($data['customer_type_id'], true, $data);
    }, 'cell_class' => 'row_action');
    $columns['menu_position'] = array('title' => _l('Menu Position'));
    $table_manager->set_id('customer_type_list');
    $table_manager->set_columns($columns);
    $table_manager->set_rows($customer_types);
    $table_manager->pagination = true;
    $table_manager->print_table();
        $help_text = addcslashes(_l("Here you can select which Company this Customer belongs to. This is handy if you are running multiple companies through this system and you would like to separate customers between different companies."), "'");
        $heading['button'] = array('url' => '#', 'onclick' => "alert('{$help_text}'); return false;", 'title' => 'help');
    }
    //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();