Revize 2002
Přidáno uživatelem David Raška před více než 11 roky(ů)
freenetis/branches/1.1/application/controllers/members.php | ||
---|---|---|
'order_by' => $order_by,
|
||
'order_by_direction' => $order_by_direction,
|
||
'limit_results' => $limit_results,
|
||
'filter' => $filter_form
|
||
'filter' => $filter_form,
|
||
'method' => 'get'
|
||
));
|
||
|
||
// approve applicant checkbox
|
||
$grid->order_form_field('toapprove')
|
||
->callback('callback::member_approve_avaiable')
|
||
->type('checkbox')
|
||
->class('center')
|
||
->label(' ');
|
||
|
||
$grid->form_submit_value = __('Approve selected applicants');
|
||
|
||
// database columns - some are commented out because of lack of space
|
||
$grid->order_field('id')
|
||
->label('ID');
|
||
... | ... | |
'Registered applicants can be approved using action button (placed in each line)'
|
||
) . '.<br>'. __(
|
||
'Delete applicants for refusing of their request'
|
||
) . '.';
|
||
) . '.';
|
||
|
||
if (isset($_GET) && count(@$_GET) && isset($_GET['toapprove']))
|
||
{
|
||
$this->multiple_applicants_details(@$_GET['toapprove']);
|
||
}
|
||
else
|
||
{
|
||
// view
|
||
$view = new View('main');
|
||
$view->title = $headline;
|
||
$view->breadcrumbs = $breadcrumbs->html();
|
||
$view->content = new View('show_all');
|
||
$view->content->description = $desc;
|
||
$view->content->table = $grid;
|
||
$view->content->headline = $headline;
|
||
$view->render(TRUE);
|
||
}
|
||
} // end of registered function
|
||
|
||
/**
|
||
* Form for approving multiple members
|
||
*
|
||
* @param array $selected
|
||
*/
|
||
private function multiple_applicants_details($selected)
|
||
{
|
||
if (!$this->acl_check_edit('Variable_Symbols_Controller', 'variable_symbols') ||
|
||
!$this->acl_check_edit(get_class($this), 'qos_ceil') ||
|
||
!$this->acl_check_edit(get_class($this), 'qos_rate'))
|
||
{
|
||
Controller::error(ACCESS);
|
||
}
|
||
|
||
if (!Settings::get('finance_enabled'))
|
||
{
|
||
status::warning('Enable financial module before approving applicants.');
|
||
$this->redirect('members/applicants');
|
||
}
|
||
|
||
if (!Variable_Key_Generator::get_active_driver())
|
||
{
|
||
status::warning('Set variable key generator before approving applicants.');
|
||
$this->redirect('members/applicants');
|
||
}
|
||
|
||
//form
|
||
$form = new Forge('members/approve_multiple_applicants');
|
||
|
||
$member = new Member_Model();
|
||
$association = new Member_Model(Member_Model::ASSOCIATION);
|
||
|
||
$items = array();
|
||
|
||
// prepare data
|
||
foreach ($selected AS $id)
|
||
{
|
||
$item = new stdClass();
|
||
$item->id = $id;
|
||
$item->name = $member->find($id)->name;
|
||
$item->registration = $member->find($id)->registration;
|
||
|
||
$items[] = $item;
|
||
|
||
$form->hidden('toapprove['.$item->id.']')
|
||
->value($item->id);
|
||
}
|
||
|
||
// create form items
|
||
$form->group('Basic information');
|
||
|
||
$form->date('entrance_date')
|
||
->label('Entrance date')
|
||
->years(date('Y', strtotime($association->entrance_date)), date('Y'))
|
||
->rules('required')
|
||
->value(time());
|
||
|
||
$speed_class = new Speed_class_Model();
|
||
$speed_classes = array(NULL => '') + $speed_class->select_list();
|
||
$def_speed_class = $speed_class->get_members_default_class();
|
||
|
||
$form->dropdown('speed_class')
|
||
->options($speed_classes)
|
||
->selected($def_speed_class ? $def_speed_class->id : NULL)
|
||
->add_button('speed_classes')
|
||
->style('width:200px');
|
||
|
||
$form->submit('Approve');
|
||
|
||
//description
|
||
$desc = __('Variable symbol will be automaticaly generated for every applicant.');
|
||
|
||
//grid
|
||
$grid = new Grid('members', __('Selected applicants'), array
|
||
(
|
||
'use_paginator' => false,
|
||
'use_selector' => false
|
||
));
|
||
|
||
$grid->order_field('name');
|
||
|
||
$grid->order_callback_field('registration')
|
||
->callback('callback::registration_field');
|
||
|
||
$grid->datasource($items);
|
||
|
||
// headline
|
||
$headline = __('Approve selected applicants');
|
||
|
||
// breadcrumbs navigation
|
||
$breadcrumbs = breadcrumbs::add()
|
||
->link('members/show_all', 'Members',
|
||
$this->acl_check_view(get_class($this),'members'))
|
||
->link('members/applicants', 'Registered applicants',
|
||
$this->acl_check_view(get_class($this),'members'))
|
||
->text($headline);
|
||
|
||
// view
|
||
$view = new View('main');
|
||
$view->title = $headline;
|
||
$view->breadcrumbs = $breadcrumbs->html();
|
||
$view->content = new View('show_all');
|
||
$view->content->table = $grid;
|
||
$view->content->form = $form;
|
||
$view->content->description = $desc;
|
||
$view->content->table = $grid;
|
||
$view->content->headline = $headline;
|
||
$view->render(TRUE);
|
||
} // end of registered function
|
||
}
|
||
|
||
/**
|
||
* Approves multiple applicants
|
||
*
|
||
* @throws Exception
|
||
*/
|
||
public function approve_multiple_applicants()
|
||
{
|
||
if (!$this->acl_check_edit('Variable_Symbols_Controller', 'variable_symbols') ||
|
||
!$this->acl_check_edit(get_class($this), 'qos_ceil') ||
|
||
!$this->acl_check_edit(get_class($this), 'qos_rate'))
|
||
{
|
||
Controller::error(ACCESS);
|
||
}
|
||
|
||
if (!isset($_POST) || !isset($_POST['toapprove']) || !isset($_POST['entrance_date']) ||
|
||
!isset($_POST['speed_class']))
|
||
{
|
||
Controller::error(PARAMETER);
|
||
}
|
||
|
||
$approved_count = 0;
|
||
$selected = @$_POST['toapprove'];
|
||
$date = @$_POST['entrance_date'];
|
||
$speed_class = @$_POST['speed_class'];
|
||
|
||
// approve selected applicants
|
||
foreach ($selected AS $applicant_id)
|
||
{
|
||
$member = new Member_Model($applicant_id);
|
||
|
||
try
|
||
{
|
||
$member->transaction_start();
|
||
|
||
// change member
|
||
$member->entrance_date = date('Y-m-d', mktime(0, 0, 0, $date['month'], $date['day'], $date['year']));
|
||
|
||
// get members account
|
||
$account = ORM::factory('account')->where(array
|
||
(
|
||
'member_id' => $member->id,
|
||
'account_attribute_id' => Account_attribute_Model::CREDIT
|
||
))->find();
|
||
|
||
// generate variable symbol
|
||
$var_sym = Variable_Key_Generator::factory()->generate($member->id);
|
||
|
||
$vs = new Variable_Symbol_Model();
|
||
|
||
$vs_not_unique = $vs->get_variable_symbol_id($var_sym);
|
||
|
||
if ($vs_not_unique && $vs_not_unique->id)
|
||
{
|
||
if ($vs_not_unique->account_id != $account->id)
|
||
{
|
||
throw new Exception(__('Variable symbol already exists in database.'));
|
||
}
|
||
}
|
||
else
|
||
{
|
||
$vs->account_id = $account->id;
|
||
$vs->variable_symbol = $var_sym;
|
||
$vs->save_throwable();
|
||
}
|
||
|
||
// set speed class
|
||
$member->speed_class_id = $speed_class;
|
||
|
||
// unlock and set to Regular member
|
||
$member->type = Member_Model::TYPE_REGULAR;
|
||
$member->locked = 0;
|
||
|
||
$member->save_throwable();
|
||
|
||
// access rights
|
||
$group_aro_map = new Groups_aro_map_Model();
|
||
|
||
// get main user
|
||
$main_user_id = NULL;
|
||
|
||
foreach ($member->users as $user)
|
||
{
|
||
if ($user->type == User_Model::MAIN_USER)
|
||
{
|
||
$main_user_id = $user->id;
|
||
break;
|
||
}
|
||
}
|
||
|
||
if (!$main_user_id)
|
||
throw new Exception('Main user of applicant is missing');
|
||
|
||
// if is not member yet
|
||
if (!$group_aro_map->exist_row(
|
||
Aro_group_Model::REGULAR_MEMBERS, $main_user_id
|
||
))
|
||
{
|
||
// delete rights of applicant
|
||
$group_aro_map->detete_row(
|
||
Aro_group_Model::REGISTERED_APPLICANTS, $main_user_id
|
||
);
|
||
|
||
// insert regular member access rights
|
||
$groups_aro_map = new Groups_aro_map_Model();
|
||
$groups_aro_map->aro_id = $main_user_id;
|
||
$groups_aro_map->group_id = Aro_group_Model::REGULAR_MEMBERS;
|
||
$groups_aro_map->save_throwable();
|
||
|
||
// reload messages
|
||
ORM::factory('member')->reactivate_messages($applicant_id);
|
||
|
||
// inform new member
|
||
Message_Model::activate_special_notice(
|
||
Message_Model::APPLICANT_APPROVE_MEMBERSHIP,
|
||
$member->id, $this->session->get('user_id'),
|
||
Notifications_Controller::ACTIVATE,
|
||
Notifications_Controller::KEEP
|
||
);
|
||
|
||
$member->transaction_commit();
|
||
}
|
||
|
||
$approved_count++;
|
||
}
|
||
catch (Exception $e)
|
||
{
|
||
Log::add_exception($e);
|
||
$member->transaction_rollback();
|
||
// error
|
||
status::error('Applicant for membership cannot be approved', $e);
|
||
}
|
||
}
|
||
|
||
status::info('Applicants for membership accepted (%d / %d)', TRUE, array($approved_count, count($selected)));
|
||
|
||
$this->redirect('members/applicants');
|
||
}
|
||
|
||
/**
|
||
* Form for approving of member
|
||
*
|
||
* @author Ondřej Fibich
|
freenetis/branches/1.1/application/helpers/callback.php | ||
---|---|---|
}
|
||
|
||
/**
|
||
* Callback function to print multiple applicants of membership checkbox
|
||
*
|
||
* @param object $item
|
||
* @param string $name
|
||
*/
|
||
public static function member_approve_avaiable ($item, $name)
|
||
{
|
||
if (condition::is_applicant_registration($item))
|
||
{
|
||
echo form::checkbox('toapprove[]', $item->id);
|
||
}
|
||
}
|
||
|
||
/**
|
||
* Callback function to print state of login log
|
||
*
|
||
* @param object $item
|
freenetis/branches/1.1/application/i18n/cs_CZ/texts.php | ||
---|---|---|
'applicant' => 'Čekatel na členství',
|
||
'applicant for membership' => 'Zájemce o členství',
|
||
'applicant for membership cannot be approved' => 'Zájemce o členství nemůže být povolen',
|
||
'applicants for membership accepted (%d / %d)'=> 'Zájemci o členství přijati (%d / %d)',
|
||
'application password' => 'Aplikační heslo',
|
||
'application for membership approved' => 'Žádost o členství schválena',
|
||
'application for membership rejected' => 'Žádost o členství zamítnuta',
|
||
... | ... | |
'approve' => 'Schválit',
|
||
'approve application for membership' => 'Schválit žádost o členství',
|
||
'approve connection request' => 'Schválit žádost o připojení',
|
||
'approve selected applicants' => 'Schválit vybrané zájemce',
|
||
'approved' => 'Schváleno',
|
||
'approved by' => 'Schválil(a)',
|
||
'approved phone operators and prefixes' => 'Povolení telefonní operátoři a předčíslí',
|
||
... | ... | |
'enable approval of membership without submited registration' => 'Povolit přijetí členství bez odevzdané přihlášky',
|
||
'enable automatic fio import' => 'Povolit automatický import Fio',
|
||
'enable automatic loading of "connected to" field during adding of device' => 'Povolit automatické doplňování pole "připojeno k" během přidávání zařízení',
|
||
'enable financial module before approving applicants' => 'Povolte finanční modul před tím než budete přijímat členy.',
|
||
'enable integrity test (all numbers in invoice has to be in extended statement)' => 'Povolit test na celistvost (každé číslo ve faktuře musí být v podrobném výpisu)',
|
||
'enable mysql event scheduler' => 'Povolit MySQL plánovač akcí',
|
||
'enable monitoring' => 'Povolit monitoring',
|
||
... | ... | |
'select user' => 'Vyber uživatele',
|
||
'select vlan' => 'Vyber VLAN',
|
||
'select vote' => 'Vyber hlas',
|
||
'selected applicants' => 'Vybraní zájemci',
|
||
'selected interface for connecting to is already connected throught different link - <a href="%s/ifaces/remove_from_link/%s" id="remove_from_link">remove from link</a>' => 'Vybrané rozhraní pro připojení k je již připojeno skrze jinou linku - <a href="%s/ifaces/remove_from_link/%s" id="remove_from_link">Odstranit z linky</a>',
|
||
'selected account does not exist'=>'Vybraný účet neexistuje',
|
||
'self-cancelable message' => 'Samozrušitelná zpráva',
|
||
... | ... | |
'sent message' => 'Odeslaná zpráva',
|
||
'september' => 'Září',
|
||
'service' => 'Služba',
|
||
'set variable key generator before approving applicants' => 'Nastavte generátor vyriabilních symbolů před tím než budete přijímat členy.',
|
||
'set as default for this url' => 'Nastavit jako výchozí pro tuto URL',
|
||
'set notification to member' => 'Nastavit notifikace členovi',
|
||
'set votes to' => 'Nastavit hlasy na',
|
||
... | ... | |
'value has not been entered' => 'Hodnota nebyla zadána.',
|
||
'value in range since' => 'hodnota v rozmezí od',
|
||
'variable symbol' => 'Variabilní symbol',
|
||
'variable symbol will be automaticaly generated for every applicant' => 'Variabilní symbol bude vygenerován pro všechny zájemce.',
|
||
'variable symbol settings' => 'Nastavení variabilních symbolů',
|
||
'variable_symbol' => 'Variabilní symbol',
|
||
'variable symbols' => 'Variabilní symboly',
|
freenetis/branches/1.1/application/libraries/Grid.php | ||
---|---|---|
* @method Order_callback_Field order_callback_field(string $column)
|
||
* @method Callback_Field callback_field(string $column)
|
||
* @method Grouped_Action_Field grouped_action_field(string $column)
|
||
* @method Order_Form_Field order_form_field(string $column)
|
||
*/
|
||
class Grid
|
||
{
|
||
... | ... | |
protected $form_extra_buttons = array();
|
||
protected $buttons = array();
|
||
protected $id = NULL;
|
||
protected $method = 'post';
|
||
private $first_add_button;
|
||
|
||
/**
|
||
... | ... | |
$this->template->paginator = ($this->use_paginator) ? $this->pagination->create_links('digg') : '';
|
||
$this->template->selector = ($this->use_selector) ? $this->selector->create() : '';
|
||
$this->template->separator = $this->separator;
|
||
$this->template->method = $this->method;
|
||
$this->template->form = $this->form;
|
||
$this->template->form_extra_buttons = $this->form_extra_buttons;
|
||
$this->template->form_submit_value = ($this->form_submit_value != '') ? $this->form_submit_value : __('Update');
|
freenetis/branches/1.1/application/models/member.php | ||
---|---|---|
SELECT id, id AS member_id, registration, name, street, street_number,
|
||
town, quarter, variable_symbol, aid, balance, applicant_registration_datetime,
|
||
applicant_connected_from, GROUP_CONCAT(a_comment SEPARATOR ', \n\n') AS a_comment,
|
||
comment, a_comments_thread_id, type, entrance_date, leaving_date
|
||
comment, a_comments_thread_id, type, entrance_date, leaving_date, 0 AS toapprove
|
||
FROM
|
||
(
|
||
SELECT * FROM
|
freenetis/branches/1.1/application/models/message.php | ||
---|---|---|
}
|
||
|
||
// send emails
|
||
if ($email == Notifications_Controller::ACTIVATE)
|
||
if (Settings::get('email_enabled') &&
|
||
$email == Notifications_Controller::ACTIVATE)
|
||
{
|
||
// find email addresses of debtors
|
||
$emails = $uc_model->get_contacts_by_member_and_type(
|
freenetis/branches/1.1/application/views/grid_template.php | ||
---|---|---|
|
||
<?php if ($form)
|
||
{
|
||
echo form::open(NULL, array('class' => 'grid_form'));
|
||
echo form::open(NULL, array('class' => 'grid_form', 'method' => $method));
|
||
|
||
if (isset($form_extra_buttons["position"]) && $form_extra_buttons["position"] == 'top')
|
||
{
|
Také k dispozici: Unified diff
closes #604 - Hromadne prijimani novych clenu