<form action="" method="post">
	<input type="hidden" name="_process" value="save_widget" />
    <input type="hidden" name="widget_id" value="<?php 
echo $widget_id;
?>
" />


    <?php 
$fields = array('fields' => array('name' => 'Name'));
module_form::set_required($fields);
module_form::prevent_exit(array('valid_exits' => array('.submit_button', '.form_save')));
hook_handle_callback('layout_column_half', 1, '35');
$fieldset_data = array('heading' => array('type' => 'h3', 'title' => _l('Widget' . ' Details')), 'class' => 'tableclass tableclass_form tableclass_full', 'elements' => array('name' => array('title' => _l('Name'), 'field' => array('type' => 'text', 'name' => 'name', 'value' => $widget['name']))), 'extra_settings' => array('owner_table' => 'widget', 'owner_key' => 'widget_id', 'owner_id' => $widget['widget_id'], 'layout' => 'table_row', 'allow_new' => module_widget::can_i('create', 'Widgets'), 'allow_edit' => module_widget::can_i('create', 'Widgets')));
$fieldset_data['elements']['Status'] = array('title' => _l('Status'), 'fields' => array(array('type' => 'select', 'name' => 'status', 'value' => $widget['status'], 'options' => module_widget::get_statuses(), 'allow_new' => true)));
echo module_form::generate_fieldset($fieldset_data);
/*** ADVANCED ****/
if (module_widget::can_i('edit', 'Widgets')) {
    $c = array();
    $res = module_customer::get_customers();
    foreach ($res as $row) {
        $c[$row['customer_id']] = $row['customer_name'];
    }
    $fieldset_data = array('heading' => array('type' => 'h3', 'title' => _l('Advanced')), 'class' => 'tableclass tableclass_form tableclass_full', 'elements' => array());
    if (count($res) <= 1 && $widget['customer_id'] && isset($c[$widget['customer_id']])) {
        $fieldset_data['elements']['change'] = array('title' => _l('Change Customer'), 'fields' => array(htmlspecialchars($c[$widget['customer_id']]), array('type' => 'hidden', 'name' => 'customer_id', 'value' => $widget['customer_id'])));
    } else {
        $fieldset_data['elements']['change'] = array('title' => _l('Change Customer'), 'fields' => array(array('type' => 'select', 'name' => 'customer_id', 'options' => $c, 'value' => $widget['customer_id'], 'help' => 'Changing a customer will also change all the current linked jobs and invoices across to this new customer.')));
    }
    echo module_form::generate_fieldset($fieldset_data);