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);
}
if ((int) $widget_id > 0) {
    if (class_exists('module_group', false)) {
        module_group::display_groups(array('title' => 'Widget' . ' Groups', 'owner_table' => 'widget', 'owner_id' => $widget_id, 'view_link' => module_widget::link_open($widget_id)));
    }
    // and a hook for our new change request plugin
    hook_handle_callback('widget_sidebar', $widget_id);
}
hook_handle_callback('layout_column_half', 2, 65);
if ((int) $widget_id > 0) {
    if (class_exists('module_note', false)) {
        module_note::display_notes(array('title' => 'Widget' . ' Notes', 'owner_table' => 'widget', 'owner_id' => $widget_id, 'view_link' => module_widget::link_open($widget_id)));
    }
    // and a hook for our new change request plugin
    hook_handle_callback('widget_main', $widget_id);
}
hook_handle_callback('layout_column_half', 'end');
$form_actions = array('class' => 'action_bar action_bar_center', 'elements' => array(array('type' => 'save_button', 'name' => 'butt_save', 'value' => _l('Save ' . 'Widget')), array('ignore' => !((int) $widget_id && module_widget::can_i('delete', 'Widgets')), '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_widget::link_open(false) . "';")));
echo module_form::generate_form_actions($form_actions);
?>



</form>
Example #2
0
 public static function get_replace_fields($widget_id, $widget_data = false)
 {
     if (!$widget_data) {
         $widget_data = self::get_widget($widget_id);
     }
     $data = array('widget_name' => $widget_data['name']);
     $data = array_merge($data, $widget_data);
     if (class_exists('module_group', false)) {
         // get the widget groups
         $g = array();
         if ($widget_id > 0) {
             $widget_data = module_widget::get_widget($widget_id);
             foreach (module_group::get_groups_search(array('owner_table' => 'widget', 'owner_id' => $widget_id)) as $group) {
                 $g[$group['group_id']] = $group['name'];
             }
         }
         $data['widget_group'] = implode(', ', $g);
     }
     // addition. find all extra keys for this widget and add them in.
     // we also have to find any EMPTY extra fields, and add those in as well.
     $all_extra_fields = module_extra::get_defaults('widget');
     foreach ($all_extra_fields as $e) {
         $data[$e['key']] = _l('N/A');
     }
     // and find the ones with values:
     $extras = module_extra::get_extras(array('owner_table' => 'widget', 'owner_id' => $widget_id));
     foreach ($extras as $e) {
         $data[$e['extra_key']] = $e['extra'];
     }
     return $data;
 }