Revize 2372
Přidáno uživatelem Michal Kliment před asi 10 roky(ů)
freenetis/branches/1.2/application/controllers/bank_accounts.php | ||
---|---|---|
// form
|
||
if (!isset($member_id) || $member_id != Member_Model::ASSOCIATION)
|
||
{
|
||
// members list
|
||
$arr_members = ORM::factory('member')->select_list();
|
||
$arr_members = arr::merge(
|
||
array(NULL => '----- '.__('Select member').' -----'),
|
||
arr::from_objects(ORM::factory('member')->get_all_members_to_dropdown())
|
||
);
|
||
|
||
if (isset($arr_members[1]))
|
||
{
|
||
unset($arr_members[1]);
|
||
}
|
||
|
||
$form = new Forge('bank_accounts/add/');
|
||
$form = new Forge();
|
||
|
||
$form->dropdown('member_id')
|
||
->label('Member name')
|
||
->options($arr_members)
|
||
->selected($this->session->get('member_id'))
|
||
->rules('required')
|
||
->filter_button('members')
|
||
->style('width:200px');
|
||
}
|
||
else
|
freenetis/branches/1.2/application/controllers/members.php | ||
---|---|---|
throw new Exception(__('Connection to vtiger server has failed'));
|
||
}
|
||
}
|
||
|
||
/**
|
||
* Method used for popup filtering
|
||
*
|
||
* @author Michal Kliment
|
||
*/
|
||
public function filter()
|
||
{
|
||
// access rights
|
||
if (!$this->acl_check_view(get_class($this), 'members'))
|
||
Controller::error(ACCESS);
|
||
|
||
// create filter form
|
||
$filter_form = self::create_filter_form();
|
||
|
||
// filter form is submited => print only result in JSON format
|
||
if (!$filter_form->is_first_load())
|
||
{
|
||
$filter_sql = $filter_form->as_sql();
|
||
|
||
$member_model = new Member_Model();
|
||
|
||
// counts all members
|
||
$total_members = $member_model->count_all_members($filter_sql);
|
||
|
||
// returns all members
|
||
$members = $member_model->get_all_members(
|
||
0, $total_members, 'surname', 'asc',
|
||
$filter_sql
|
||
);
|
||
|
||
$data = array();
|
||
|
||
// transform members from objects to array
|
||
$x = 0;
|
||
foreach ($members as $member)
|
||
{
|
||
$data[$x++] = array
|
||
(
|
||
'id' => $member->id,
|
||
'name' => $member->surname.' '.$member->firstname.' (ID '.$member->id.')'
|
||
);
|
||
}
|
||
|
||
// print array with members in JSON
|
||
die(json_encode($data));
|
||
}
|
||
// filter form is not submited => print only form
|
||
else
|
||
{
|
||
$title = __('Filter members');
|
||
|
||
$view = new View('main');
|
||
$view->title = $title;
|
||
$view->content = new View('form');
|
||
$view->content->headline = $title;
|
||
$view->content->form = $filter_form;
|
||
$view->render(TRUE);
|
||
}
|
||
}
|
||
}
|
freenetis/branches/1.2/application/controllers/subnets.php | ||
---|---|---|
$grid->add_new_button('subnets/add', __('Add new subnet'),
|
||
array
|
||
(
|
||
'title' => __('Add new subnet'),
|
||
'class' => 'popup_link'
|
||
'title' => __('Add new subnet')
|
||
));
|
||
}
|
||
|
||
... | ... | |
|
||
$form->dropdown('owner_id')
|
||
->label(__('Owner').' '.help::hint('subnet_owner'))
|
||
->options($arr_members);
|
||
->options($arr_members)
|
||
->filter_button('members');
|
||
|
||
// add cloud to subnet
|
||
$cloud = new Cloud_Model();
|
||
... | ... | |
$form->dropdown('owner_id')
|
||
->label(__('Owner').' '.help::hint('subnet_owner'))
|
||
->options($arr_members)
|
||
->selected($subnet_model->subnets_owner->member->id);
|
||
->selected($subnet_model->subnets_owner->member->id)
|
||
->filter_button('members');
|
||
|
||
$form->submit('Update');
|
||
|
freenetis/branches/1.2/application/i18n/cs_CZ/texts.php | ||
---|---|---|
'filled' => 'Vyplněno',
|
||
'filter' => 'Filtrovat',
|
||
'filter devices' => 'Filtrovat zařízení',
|
||
'filter members' => 'Filtrovat členy',
|
||
'filter query has been successfully added' => 'Dotaz filtru byl úspěšně přidán.',
|
||
'filter query has been successfully deleted' => 'Dotaz filtru byl úspěšně smazán.',
|
||
'filter query has been successfully set as default' => 'Dotaz filtru byl úspěšně nastaven jako výchozí.',
|
freenetis/branches/1.2/application/libraries/forge/Form_Dropdown.php | ||
---|---|---|
arr::remove('label', $base_data);
|
||
$add_button = arr::remove('add_button', $base_data);
|
||
$add_button_title = arr::remove('add_button_title', $base_data);
|
||
$filter_button = arr::remove('filter_button', $base_data);
|
||
$filter_button_title = arr::remove('filter_button_title', $base_data);
|
||
|
||
$html = form::dropdown($base_data, $options, $selected);
|
||
|
||
... | ... | |
);
|
||
}
|
||
|
||
if ($filter_button)
|
||
{
|
||
$html .= ' ' . html::anchor(
|
||
$this->data['filter_button'], html::image(array
|
||
(
|
||
'src' => 'media/images/icons/filter.png',
|
||
'id' => $this->data['name'] . '_filter_button'
|
||
)), array
|
||
(
|
||
'class' => 'popup-filter popup_link isReloadOff loadOnlyOnFirst',
|
||
'title' => $filter_button_title
|
||
)
|
||
);
|
||
}
|
||
|
||
return $html;
|
||
}
|
||
|
||
/**
|
||
* Add button for adding object to drobbox.
|
||
* Add button for adding object to drobdown.
|
||
* Content of dropdown is automatically update after adding by AJAX.
|
||
*
|
||
* @author Ondřej Fibich, Michal Kliment
|
||
... | ... | |
|
||
return $this;
|
||
}
|
||
|
||
/**
|
||
* Add button for filtering objects to drobdown.
|
||
* Content of dropdown is automatically update after submit by AJAX.
|
||
*
|
||
* @author Michal Kliment
|
||
* @param string $controller
|
||
* @param string $method
|
||
* @param string $args
|
||
* @return \Form_Dropdown
|
||
*/
|
||
public function filter_button($controller = NULL, $method = 'filter', $args = '')
|
||
{
|
||
if (empty($controller))
|
||
{
|
||
return;
|
||
}
|
||
|
||
$url = $controller.'/'.$method;
|
||
|
||
if (!empty($args))
|
||
{
|
||
$url .= '/'.$args;
|
||
}
|
||
|
||
$this->data['filter_button'] = $url;
|
||
$this->data['filter_button_title'] = __('Filter '.$controller);
|
||
|
||
return $this;
|
||
}
|
||
|
||
protected function load_value()
|
||
{
|
freenetis/branches/1.2/application/models/member.php | ||
---|---|---|
// query
|
||
return $this->db->query("
|
||
SELECT id, id AS member_id, name AS member_name, registration, registrations,
|
||
surname, firstname,
|
||
name, street, street_number, town, quarter, variable_symbol, aid, balance,
|
||
a_comment, a_comments_thread_id, type, entrance_date, leaving_date,
|
||
redirect_type_id, GROUP_CONCAT(DISTINCT redirect_type SEPARATOR ', ') AS redirect,
|
||
... | ... | |
(
|
||
SELECT
|
||
m.id, m.registration, m.registrations, m.name,
|
||
u.surname, u.name AS firstname,
|
||
s.street, ap.street_number, t.town, t.quarter,
|
||
vs.variable_symbol, a.id AS aid,
|
||
a.balance, a_comment,
|
freenetis/branches/1.2/application/views/filter_form_template.php | ||
---|---|---|
|
||
if ($val.val() !== '')
|
||
{
|
||
$val.valid();
|
||
$val.valid();
|
||
}
|
||
});
|
||
|
freenetis/branches/1.2/application/views/js/base.php | ||
---|---|---|
if (this._items[id] == undefined)
|
||
this._items[id] = new Dialog(id, parent, isReloadOn);
|
||
|
||
this._items[id]._opened_count++;
|
||
|
||
return this._items[id];
|
||
},
|
||
|
||
... | ... | |
|
||
this._data = '';
|
||
|
||
this._opened_count = 0;
|
||
|
||
// set parent
|
||
this.setParent(parent);
|
||
|
||
... | ... | |
// result is html
|
||
case '<':
|
||
parent._format = 'html';
|
||
|
||
// this is hack because jQuery auto removes scipt tags (credits: http://blog.devlpr.net/2012/04/29/how-to-get-script-tags-with-jquery-find-from-ajax-result/)
|
||
data = data.replace(/script/gi, 'myscript');
|
||
|
||
parent._data = $(data).find('#content-padd');
|
||
break;
|
||
|
||
// result is json
|
||
case '{':
|
||
case '[':
|
||
parent._format = 'json';
|
||
parent._data = jQuery.parseJSON(data);
|
||
break;
|
||
... | ... | |
context = this._element;
|
||
$.getScript('<?php echo url_lang::base() ?>js/'+str_replace('<?php echo url_lang::base() ?>', '', this._url)+glue+'nobase=1');
|
||
|
||
// this is hack because jQuery auto removes scipt tags (credits: http://blog.devlpr.net/2012/04/29/how-to-get-script-tags-with-jquery-find-from-ajax-result/)
|
||
this._element.find("myscript").each (function (){
|
||
eval($(this).html());
|
||
|
||
$(this).remove();
|
||
});
|
||
|
||
this._element.find('#filter_form').addClass('nopopup');
|
||
|
||
this._element.find(".form, #filter_form").each(function()
|
||
{
|
||
$(this).validate();
|
||
... | ... | |
getLink: function ()
|
||
{
|
||
return $('#popup-link-' + this.id);
|
||
},
|
||
|
||
/**
|
||
* Get count of opened dialogs
|
||
*
|
||
* @returns integer
|
||
*/
|
||
getOpenedCount: function ()
|
||
{
|
||
return this._opened_count;
|
||
}
|
||
};
|
||
|
||
... | ... | |
|
||
// create new dialog
|
||
var dialog = dialogs.add($this, parent, !$this.hasClass('isReloadOff'));
|
||
|
||
// load url in it
|
||
dialog.load(url);
|
||
|
||
if (dialog.getOpenedCount() == 1)
|
||
{
|
||
// load url in it
|
||
dialog.load(url);
|
||
}
|
||
|
||
// init TinyMCE Editors in dialog
|
||
if (window['advancedTinyMCE'] !== undefined)
|
||
{
|
||
... | ... | |
if (dialog.isReloadOn())
|
||
{
|
||
reload_element('#'+$(dropdown).attr('id'), url, limit);
|
||
|
||
var text = $('#'+$(dropdown).attr('id')+" option[value="+data.id+"]").text();
|
||
|
||
if (dropdown.attr('multiple') == 'multiple')
|
||
{
|
||
select_multiple[$(dropdown).attr('id')].push({'key': data.id, 'value': text});
|
||
}
|
||
}
|
||
|
||
dropdown.trigger('addOption', data.id);
|
||
... | ... | |
return false;
|
||
});
|
||
|
||
/**
|
||
* Submit of form in filter dialog
|
||
*
|
||
* @author Michal Kliment
|
||
*/
|
||
$(".dialog #filter_form").live('submit', function()
|
||
{
|
||
// get dialog
|
||
var dialog = dialogs.get($(this).parent());
|
||
|
||
var glue = ($(this).attr('action').indexOf('?') == -1) ? '?' : '&';
|
||
|
||
var url = $(this).attr('action')+glue+'noredirect=1';
|
||
|
||
// find link which open this dialog
|
||
var link = dialogs.links.get($(this).parent());
|
||
|
||
// find parent of dialog (another dialog or main page)
|
||
var parent = dialog.getParent();
|
||
|
||
var dropdown = link.prev();
|
||
|
||
$.ajax({
|
||
async: false,
|
||
type: 'GET',
|
||
url: url,
|
||
data: dialog.getFormData(),
|
||
success: function (data)
|
||
{
|
||
var first_option_text = dropdown.children().first().text();
|
||
|
||
dropdown.html('');
|
||
|
||
dropdown.append('<option>'+first_option_text+'</option>');
|
||
|
||
data = jQuery.parseJSON(data);
|
||
|
||
for (key in data)
|
||
{
|
||
dropdown.append('<option value="'+data[key].id+'">'+data[key].name+'</option>');
|
||
}
|
||
}
|
||
});
|
||
|
||
dialog.hide();
|
||
|
||
return false;
|
||
});
|
||
|
||
/* AJAX fulltext search ***************************************************/
|
||
|
||
var r_get = null;
|
Také k dispozici: Unified diff
Upravy:
- refs #839: Univerzalni popup filtr