Projekt

Obecné

Profil

« Předchozí | Další » 

Revize 1734

Přidáno uživatelem Ondřej Fibich před téměř 12 roky(ů)

Vydani:

- freenetis 1.1.0~aplha3 - novinky v cekatelech na clenstvi

Novinky:

- fixes #303: Zpravy pro samo-registraci
- fixes #369: Formular pro prijeti cekatele na clenstvi
- fixes #340: Zaznamenani pripojeni cekatele
- fixes #326: Pridat strankovani k zobrazeni cekatelu na cl.
- fixes #322: Moznost pridat komentar k prirazeni clena k tarifu

Opravy:

- pri pridavani/editaci clena je u datumu vstupu je moznost nastavit rok v rozsaju <rok zalozeni sdruzeni, aktualni rok>

Zobrazit rozdíly:

freenetis/branches/1.1/db_upgrades/upgrade_1.1.0~alpha1.php
// insert new message type
"INSERT INTO `messages` (`id`, `name`, `text`, `email_text`, `sms_text`, `type`, `self_cancel`, `ignore_whitelist`) VALUES
(NULL, 'Received payment notice', NULL,
'Hello {name},<br /><br />Your payment has been accepted into FreenetIS.<br/>Your current balance is: {balance},-',
'Hello {member_name},<br /><br />Your payment has been accepted into FreenetIS.<br/>Your current balance is: {balance},-',
'Your payment has been accepted into FreenetIS. Your current balance is: {balance},-',
8, NULL, 1);"
);
freenetis/branches/1.1/db_upgrades/upgrade_1.1.0~alpha3.php
<?php defined('SYSPATH') or die('No direct script access.');
/*
* This file is part of open source system FreenetIS
* and it is released under GPLv3 licence.
*
* More info about licence can be found:
* http://www.gnu.org/licenses/gpl-3.0.html
*
* More info about project can be found:
* http://www.freenetis.org/
*
*/
/**
* Adds field for recognization of date from which applicant is connected.
* Adds comment to member fee.
*
* @author Ondřej Fibich
* @see #340
* @see #322
* @see #303
*/
$upgrade_sql['1.1.0~alpha3'] = array
(
// Adds field for recognization of date from which applicant is connected. (#340)
"ALTER TABLE `members` ADD `applicant_connected_from` DATE NULL DEFAULT NULL AFTER `applicant_registration_datetime`",
// Adds comment to member fee. (#322)
"ALTER TABLE `members_fees` ADD `comment` TEXT NOT NULL",
// insert new message for approving of applicant (#303)
"INSERT INTO `messages` (`id`, `name`, `text`, `email_text`, `sms_text`, `type`, `self_cancel`, `ignore_whitelist`) VALUES
(NULL, 'Application for membership approved', NULL,
'Hello {member_name},<br/><br/>your membership application has been approved. You are one of us from now :-)<br/><br/>Your association!',
NULL, 9, NULL, 1);",
// insert new message for approving of applicant (#303)
"INSERT INTO `messages` (`id`, `name`, `text`, `email_text`, `sms_text`, `type`, `self_cancel`, `ignore_whitelist`) VALUES
(NULL, 'Application for membership rejected', NULL,
'Hello {member_name},<br/><br/>your membership application has been refused. Sorry :-(',
NULL, 10, NULL, 1);"
);
freenetis/branches/1.1/application/i18n/cs_CZ/texts.php
'add work' => 'Přidat práci',
'added' => 'Přidáno',
'added by' => 'Přidal',
'additional payment for services' => 'Dodatečná platba za služky',
'additional payment form services provided before membership' => 'Doplatek za využívání služeb v době kdy nebyl uživatel členem',
'another contact information' => 'Další kontaktní informace',
'additional information' => 'Doplňkové informace',
'address' => 'Adresa',
......
'all without former' => 'Všichni bez bývalých',
'all users' => 'Všichni uživatelé',
'allow' => 'Povolit',
'allow additional payment' => 'Povolit doplatek',
'allowed subnet' => 'Povolená podsíť',
'allowed subnets' => 'Povolené podsítě',
'allowed subnets of member' => 'Povolené podsítě člena',
......
'append interface to link' => 'Přidat k linkce rozhraní',
'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',
'application password' => 'Aplikační heslo',
'application for membership approved' => 'Žádost o členství schválena',
'application for membership rejected' => 'Žádost o členství zamítnuta',
'apply' => 'Použít',
'approval' => 'Hlasování',
'approval state' => 'Stav hlasování',
......
'approval type has been successfully deleted' => 'Hlasovací typ byl úspěšně smazán.',
'approval type has been successfully updated' => 'Hlasovací typ byl úspěšně aktualizován.',
'approval types' => 'Hlasovací typy',
'approve' => 'Schválit',
'approve application for membership' => 'Schválit žádost o členství',
'approved' => 'Schváleno',
'approved phone operators and prefixes' => 'Povolení telefonní operátoři a předčíslí',
'approved work reports' => 'Schválené prácovní výkazy',
......
'confirmed by' => 'Potvrzeno od',
'confirmed time' => 'Čas potvrzení',
'confirmed works' => 'Potvrzené práce',
'connected from' => 'Připojen od',
'connected to' => 'Připojeno k',
'connected to device' => 'Připojeno k zařízení',
'connected to interface' => 'Připojeno k rozhraní',
......
'read-only tariff cannot be edited' => 'Tarif pouze pro čtení nelze editovat.',
'really delete this account' => 'Opravdu smazat tento účet',
'recalculate account balances' => 'Přepočítat zůstatky na účtech',
'recalculating' => 'Přepočítávám',
'recipient information' => 'Informace o příjemci',
'received member fees' => 'Přijaté členské příspěvky',
'received' => 'Přijatá',
......
'register to %s' => 'Registrovat na %s',
'registered' => 'Registrovaný',
'registered applicants' => 'Registrovaní zájemci',
'registered applicants can be approved in edit form by changing their type' => 'Registrovaní zájemci mohou být přijmuti v editačním formuláři změnou jejich typu',
'registered applicants can be approved using action button (placed in each line)' => 'Registrovaní zájemci mohou být přijmuti pomocí tlačítka umístěného u každého z nich',
'registration' => 'Přihláška',
'registration form' => 'Registrační formulář',
'registration has been sended' => 'Registrace byla odeslána',
freenetis/branches/1.1/application/i18n/cs_CZ/help.php
'allowed_subnets_enabled' => 'Zelené tlačítko nalevo znamená to, že podsíť, ze které se přihlašujete, patří mezi vaše povolené podsítě. POZOR! Kliknutím na tlačítko ji zakážete. Tímto úkonem povolíte některou z aktuálně zakázaných podsítí.',
'allowed_subnets_update_interval' => 'Interval aktualizace povolených podsítí v sekundách. Po uplynutí této doby se IP adresám z nepovolených podsítí nastaví přesměrování typu Přerušené členství. Výchozí hodnota je 60 sekund (1 minuta).',
'amount_including_transfer_fee' => 'Částka včetně transakčního poplatku',
'applicant_additional_payment' => 'Platba za služby, které byli poskytnuty čekateli před vstupem do sdružení.',
'application_password' => 'Aplikační heslo slouží uživateli pro přihlášení ke službám, které jsou závislé na Radius serveru, jako například VPN, aktivní prvky sítě atd. Toto heslo je v databázi uloženo v otevřené podobě.',
'approval_priority' => 'Priorita umožňuje vícekolové hlasování o práci/pracovním výkazu. Pokud nechcete šablonu s vícekolovým hlasováním, nastavte u všech položek šablony prioritu na hodnotu \'0\'. Vícekolové hlasování začíná u prvku s nejvyšší prioritou a sestupuje k dalším kolům hlasováním, dokud není buďto schváleno ve všech kolech, nebo v jednom z kol zamítnuto. Pokud v některém z kol hlasování chcete schvalovat více prvků zadejte jim stejnou prioritu.',
'approval_state' => 'Stav je ve formátu Pro / Proti / Zdrželi se.',
freenetis/branches/1.1/application/i18n/en_US/help.php
'allowed_subnets_enabled' => 'Green button on the left means that the subnet from which you access the board, is allowed between your subnet. ATTENTION! Click the button to disable it. This act enabled some of the currently banned subnets.',
'allowed_subnets_update_interval' => 'Update interval of allowed subnets in seconds. After this time, the IP addresses from unauthorized subnets set up redirects Broken type of membership. The default is 60 seconds (1 minute).',
'amount_including_transfer_fee' => 'Amount including transfer fee',
'applicant_additional_payment' => 'Payment for services that were provided to the applicant before joining of the association.',
'application_password' => 'Application user password used to login to services that are dependent on the Radius server, such as VPN, active network elements, etc. This password is stored in the database in an open form.',
'approval_priority' => 'Priority allows multi-round voting for works / work reports. If you do not vote multi-round template, set the template for all items priority to \'0 \'. Multi-round voting begins at the element with the highest priority and descends to the next rounds of voting until it is either approved in all rounds, or in one of the rounds rejected. If any of the rounds of votes to approve more elements enter them the same priority.',
'approval_state' => 'State with the format in Agree / Disagree / Abstain.',
freenetis/branches/1.1/application/helpers/callback.php
if ($message->type == Message_Model::CONTACT_INFORMATION ||
$message->type == Message_Model::CANCEL_MESSAGE ||
$message->type == Message_Model::UNKNOWN_DEVICE_MESSAGE ||
$message->type == Message_Model::RECEIVED_PAYMENT_NOTICE_MESSAGE)
$message->type == Message_Model::RECEIVED_PAYMENT_NOTICE_MESSAGE ||
$message->type == Message_Model::APPLICANT_APPROVE_MEMBERSHIP ||
$message->type == Message_Model::APPLICANT_REFUSE_MEMBERSHIP)
{
echo '&nbsp;';
}
......
if ($message->type == Message_Model::CONTACT_INFORMATION ||
$message->type == Message_Model::CANCEL_MESSAGE ||
$message->type == Message_Model::UNKNOWN_DEVICE_MESSAGE ||
$message->type == Message_Model::RECEIVED_PAYMENT_NOTICE_MESSAGE)
$message->type == Message_Model::RECEIVED_PAYMENT_NOTICE_MESSAGE ||
$message->type == Message_Model::APPLICANT_APPROVE_MEMBERSHIP ||
$message->type == Message_Model::APPLICANT_REFUSE_MEMBERSHIP)
{
echo '&nbsp;';
}
freenetis/branches/1.1/application/models/members_fee.php
* @property date $activation_date
* @property date $deactivation_date
* @property integer $priority
* @property string $comment
* @property ORM_Iterator $membership_interrupts
*/
class Members_fee_Model extends ORM
......
SELECT mf.*, f.readonly, f.type_id AS fee_type_id,
IFNULL(t.translated_term,et.value) AS fee_type_name,
f.name AS fee_name, f.fee AS fee_fee, 1 AS status,
f.special_type_id
f.special_type_id, mf.comment
FROM members_fees mf
LEFT JOIN fees f ON mf.fee_id = f.id
LEFT JOIN enum_types et ON f.type_id = et.id
......
return ($result && $result->count()) ? $result->current() : null;
}
/**
* Caclulate additional payment for services before membership
*
* @author Ondřej Fibich
* @see Members_Controller#approve_applicant
* @param integer $applicant_id Member ID
* @param string $connected_from Y-m-d format
* @param string $entrance_date Y-m-d format
* @return double
*/
public function calculate_additional_payment_of_applicant($connected_from, $entrance_date)
{
if (empty($connected_from) || ($connected_from == '0000-00-00'))
{
return 0;
}
$fee_model = new Fee_Model();
$amount = 0;
$current_year = date('Y', strtotime($entrance_date));
$current_month = date('m', strtotime($entrance_date));
$year = date('Y', strtotime($connected_from));
$month = date('m', strtotime($connected_from));
// will be payed later in ordinary member fees
if (date('d', strtotime($entrance_date)) <= 15) // fix after #332 implemented
{
if (--$current_month <= 0)
{
$current_month = 12;
$year--;
}
}
// get payment (loop gets default regular member fees)
while ($year <= $current_year)
{
$to_month = ($year == $current_year) ? $current_month : 12;
while ($month <= $to_month)
{
$date = date('Y-m-d', mktime(0, 0, 0, $month, 15, $year)); // fix after #332 implemented
$fee = $fee_model->get_default_fee_by_date_type($date, 'regular member fee');
if ($fee && $fee->id)
{
$amount += $fee->fee;
}
$month++;
}
$month = 1;
$year++;
}
return $amount;
}
}
freenetis/branches/1.1/application/models/message.php
const UNALLOWED_CONNECTING_PLACE_MESSAGE = 7;
/**
* content of page for unallowed connecting place, depends on allowed subnets
* content of page for received payment notice
*/
const RECEIVED_PAYMENT_NOTICE_MESSAGE = 8;
/**
* content of page for approved application for membership
*/
const APPLICANT_APPROVE_MEMBERSHIP = 9;
/**
* content of page for refused application for membership
*/
const APPLICANT_REFUSE_MEMBERSHIP = 10;
// self-cancel constants
/**
......
}
/**
* Activates accept payment notice to given member
* Activates notice messages (only e-mail and sometimes also SMS) for accept
* payment notice, approoving/refusing of application for membership
* to a single member.
*
* @author Ondřej Fibich
* @param integer $member_id who payed
* @param integer $type 8 => payment, 9 => application approve, 10 => application refuse
* @param integer $member_id Member ID
* @param integer $user_id Who redirects
* @param integer $email E-mail state
* @param integer $sms SMS state
* @return boolean Notiication made?
* @return boolean Notification made?
*/
public static function activate_received_payment_message($member_id, $user_id, $email, $sms)
public static function activate_special_notice(
$type, $member_id, $user_id, $email, $sms)
{
if ($type != self::RECEIVED_PAYMENT_NOTICE_MESSAGE &&
$type != self::APPLICANT_APPROVE_MEMBERSHIP &&
$type != self::APPLICANT_REFUSE_MEMBERSHIP)
{
throw new Exception('Wrong type');
}
// preparation
$message = ORM::factory('message')->where(array
(
'type' => self::RECEIVED_PAYMENT_NOTICE_MESSAGE
))->find();
$message = ORM::factory('message')->where(array('type' => $type))->find();
$uc_model = new Users_contacts_Model();
// message do not exists
if (!$message || !$message->id)
{
Log::add('error', 'Payment accepted notice message not exists in messages table');
Log::add('error', 'Notice message (' . $type . ') not exists in messages table');
return false;
}
freenetis/branches/1.1/application/models/member.php
* @property string $qos_rate
* @property double $entrance_fee
* @property double $debt_payment_rate
* @property date $entrance_date
* @property double $entrance_fee_left
* @property date $entrance_fee_date
* @property date $date
......
* @property date $entrance_form_accepted
* @property date $leaving_date
* @property datetime $applicant_registration_datetime
* @property datetime $applicant_connected_from
* @property integer $locked
* @property integer $voip_billing_limit
* @property integer $voip_billing_type
......
/**
* Function gets list of registered applicans.
*
* @param $limit_from starting row
* @param $limit_results number of rows
* @param $order_by sorting column
* @param $order_by_direction sorting direction
* @param string $filter_sql used for filtering
* @return Mysql_Result
*/
public function get_registered_members()
public function get_registered_applicants($limit_from = 0, $limit_results = 50,
$order_by = 'id', $order_by_direction = 'asc', $filter_sql = '')
{
$where = '';
if ($filter_sql != '')
$where = "WHERE $filter_sql";
// order by direction check
if (strtolower($order_by_direction) != 'desc')
{
$order_by_direction = 'asc';
}
// query
return $this->db->query("
SELECT id, id AS member_id, registration, name, street, street_number,
town, quarter, variable_symbol, aid, balance, applicant_registration_datetime,
GROUP_CONCAT(a_comment SEPARATOR ', \n\n') AS a_comment, comment,
a_comments_thread_id, type, entrance_date, leaving_date
applicant_connected_from, GROUP_CONCAT(a_comment SEPARATOR ', \n\n') AS a_comment,
comment, a_comments_thread_id, type, entrance_date, leaving_date
FROM
(
SELECT
m.id, m.registration, m.name,
s.street, ap.street_number, t.town, t.quarter,
vs.variable_symbol, a.id AS aid,
a.balance, m.applicant_registration_datetime,
CONCAT(u.surname,' ',u.name,' (',SUBSTRING(c.datetime,1,10),'):\n',c.text) AS a_comment,
a.comments_thread_id AS a_comments_thread_id,
m.type, m.entrance_date, m.leaving_date, m.comment
FROM members m
LEFT JOIN address_points ap ON m.address_point_id = ap.id
LEFT JOIN streets s ON ap.street_id = s.id
LEFT JOIN towns t ON ap.town_id = t.id
LEFT JOIN accounts a ON a.member_id = m.id AND m.id <> 1
LEFT JOIN variable_symbols vs ON vs.account_id = a.id
LEFT JOIN comments_threads ct ON a.comments_thread_id = ct.id
LEFT JOIN comments c ON ct.id = c.comments_thread_id
LEFT JOIN users u ON c.user_id = u.id
WHERE m.type = ?
ORDER BY c.datetime DESC
SELECT * FROM
(
SELECT
m.id, m.registration, m.name, m.applicant_connected_from,
s.street, ap.street_number, t.town, t.quarter,
vs.variable_symbol, a.id AS aid,
a.balance, m.applicant_registration_datetime,
CONCAT(u.surname,' ',u.name,' (',SUBSTRING(c.datetime,1,10),'):\n',c.text) AS a_comment,
a.comments_thread_id AS a_comments_thread_id,
m.type, m.entrance_date, m.leaving_date, m.comment
FROM members m
LEFT JOIN address_points ap ON m.address_point_id = ap.id
LEFT JOIN streets s ON ap.street_id = s.id
LEFT JOIN towns t ON ap.town_id = t.id
LEFT JOIN accounts a ON a.member_id = m.id AND m.id <> 1
LEFT JOIN variable_symbols vs ON vs.account_id = a.id
LEFT JOIN comments_threads ct ON a.comments_thread_id = ct.id
LEFT JOIN comments c ON ct.id = c.comments_thread_id
LEFT JOIN users u ON c.user_id = u.id
WHERE m.type = ?
ORDER BY c.datetime DESC
) m
$where
) AS q
GROUP BY id
ORDER BY id DESC
", self::TYPE_APPLICANT );
ORDER BY " . $this->db->escape_column($order_by) . " $order_by_direction
LIMIT " . intval($limit_from) . ", " . intval($limit_results) . "
", self::TYPE_APPLICANT);
}
/**
......
__('User message')
))->current()->total;
}
/**
* Function gets member for registration table.
* Function gets count of registered applicans.
*
* @param integer $limit
* @param integer $limit_results
* @return Mysql_Result
* @param string $filter_sql used for filtering
* @return integer
*/
public function get_all_members_to_registration($limit = 0, $limit_results = 50)
public function count_all_registered_applicants($filter_sql = '')
{
$where = '';
if ($filter_sql != '')
$where = "WHERE $filter_sql";
// query
return $this->db->query("
SELECT m.id, m.registration, CONCAT(u.surname,' ',u.name) as name,
s.street, ap.street_number, t.town
FROM members m
LEFT JOIN users u ON m.id = u.member_id and u.type = 1
LEFT JOIN address_points ap ON m.address_point_id = ap.id
LEFT JOIN streets s ON ap.street_id = s.id
LEFT JOIN towns t ON ap.town_id = t.id
ORDER BY name ASC
LIMIT " . intval($limit) . ", " . intval($limit_results) ."
");
SELECT COUNT(id) AS total
FROM
(
SELECT id
FROM
(
SELECT
m.id, m.registration, m.name, m.applicant_connected_from,
s.street, ap.street_number, t.town, t.quarter,
vs.variable_symbol, a.id AS aid,
a.balance, m.applicant_registration_datetime,
CONCAT(u.surname,' ',u.name,' (',SUBSTRING(c.datetime,1,10),'):\n',c.text) AS a_comment,
a.comments_thread_id AS a_comments_thread_id,
m.type, m.entrance_date, m.leaving_date, m.comment
FROM members m
LEFT JOIN address_points ap ON m.address_point_id = ap.id
LEFT JOIN streets s ON ap.street_id = s.id
LEFT JOIN towns t ON ap.town_id = t.id
LEFT JOIN accounts a ON a.member_id = m.id AND m.id <> 1
LEFT JOIN variable_symbols vs ON vs.account_id = a.id
LEFT JOIN comments_threads ct ON a.comments_thread_id = ct.id
LEFT JOIN comments c ON ct.id = c.comments_thread_id
LEFT JOIN users u ON c.user_id = u.id
WHERE m.type = ?
ORDER BY c.datetime DESC
) AS m
$where
) q2
", self::TYPE_APPLICANT)->current()->total;
}
/**
freenetis/branches/1.1/application/controllers/members.php
* Function shows list of all registered applicants.
*
* @author Ondřej Fibich
* @param integer $limit_results
* @param string $order_by
* @param string $order_by_direction
* @param integer $page_word
* @param integer $page
*/
public function applicants()
public function applicants(
$limit_results = 40, $order_by = 'id',
$order_by_direction = 'ASC', $page_word = 'page', $page = 1,
$regs = 0)
{
// access rights
if (!$this->acl_check_view(get_class($this),'members'))
Controller::error(ACCESS);
// query
$town_model = new Town_Model();
$street_model = new Street_Model();
// filter form
$filter_form = new Filter_form('m');
$filter_form->add('name')
->callback('json/member_name');
$filter_form->add('id')
->type('number');
$filter_form->add('applicant_connected_from')
->type('date')
->label('Connected from');
$filter_form->add('applicant_registration_datetime')
->type('date')
->label('Registration time');
$filter_form->add('comment');
$filter_form->add('registration')
->type('select')
->values(arr::bool());
$filter_form->add('town')
->type('select')
->values(array_unique($town_model->select_list('town', 'town')));
$filter_form->add('street')
->type('select')
->values(array_unique($street_model->select_list('street', 'street')));
$filter_form->add('street_number')
->type('number');
// gets new selector
if (is_numeric($this->input->get('record_per_page')))
$limit_results = (int) $this->input->get('record_per_page');
// parameters control
$allowed_order_type = array
(
'id', 'registration', 'name', 'street', 'street_number', 'town',
'applicant_connected_from', 'applicant_registration_datetime',
'comment'
);
// order by check
if (!in_array(strtolower($order_by), $allowed_order_type))
$order_by = 'id';
// order by direction check
if (strtolower($order_by_direction) != 'desc')
$order_by_direction = 'asc';
// load members
$model_members = new Member_Model();
$query = $model_members->get_registered_members();
$total_members = $model_members->count_all_registered_applicants($filter_form->as_sql());
// limit check
if (($sql_offset = ($page - 1) * $limit_results) > $total_members)
$sql_offset = 0;
// query data
$query = $model_members->get_registered_applicants(
$sql_offset, $limit_results, $order_by, $order_by_direction,
$filter_form->as_sql()
);
// path to form
$path = Config::get('lang') . '/members/applicants/' . $limit_results . '/'
. $order_by . '/' . $order_by_direction.'/'.$page_word.'/'
. $page.'/'.$regs;
// grid
$grid = new Grid(url::base(TRUE) . url::current(true), null, array
$grid = new Grid(null, null, array
(
'use_paginator' => false,
'use_selector' => false
'current' => $limit_results,
'selector_increace' => 40,
'selector_min' => 40,
'selector_max_multiplier' => 25,
'base_url' => $path,
'uri_segment' => 'page',
'total_items' => $total_members,
'items_per_page' => $limit_results,
'style' => 'classic',
'order_by' => $order_by,
'order_by_direction' => $order_by_direction,
'limit_results' => $limit_results,
'filter' => $filter_form
));
// database columns - some are commented out because of lack of space
$grid->field('id')
$grid->order_field('id')
->label('ID');
$grid->field('name');
$grid->order_field('name');
$grid->field('street');
$grid->order_field('street');
$grid->field('street_number');
$grid->order_field('street_number');
$grid->field('town');
$grid->order_field('town');
$grid->field('applicant_registration_datetime')
$grid->order_field('applicant_registration_datetime')
->label('Registration time');
$grid->field('comment');
$grid->order_field('applicant_connected_from')
->label('Connected from');
$grid->order_callback_field('registration')
->callback('callback::registration_field');
$grid->order_field('comment');
$actions = $grid->grouped_action_field();
// action fields
......
if ($this->acl_check_edit(get_class($this), 'members'))
{
$actions->add_action('id')
->icon_action('edit')
->url('members/edit');
->icon_action('member')
->url('members/approve_applicant')
->label('Approve application for membership')
->class('popup_link');
}
if ($this->acl_check_delete(get_class($this), 'members'))
......
// description
$desc = '<br>' . __(
'Registered applicants can be approved in edit form by changing their type'
'Registered applicants can be approved using action button (placed in each line)'
) . '.<br>'. __(
'Delete applicants for refusing of their request'
) . '.';
......
} // end of registered function
/**
* Deletes registered applicants
*
* Form for approving of member
*
* @author Ondřej Fibich
* @param integer $member_id
* @see #369
* @param integer $member_id
*/
public function delete_applicant($member_id = NULL)
public function approve_applicant($member_id = NULL)
{
// parameter is wrong
if (!$member_id || !is_numeric($member_id))
Controller::warning(PARAMETER);
$association = new Member_Model(Member_Model::ASSOCIATION);
$member = new Member_Model($member_id);
$member_fee = new Members_fee_Model();
$additional_payment_amount = $member_fee->calculate_additional_payment_of_applicant(
$member->applicant_connected_from, date('Y-m-d')
);
// member doesn't exist
if (!$member->id)
Controller::error(RECORD);
// access control
if (!$this->acl_check_delete(get_class($this), 'members'))
if (!$this->acl_check_delete(get_class($this), 'members') ||
!$this->acl_check_edit(get_class($this), 'entrance_date') ||
!$this->acl_check_new('Accounts_Controller', 'transfers'))
Controller::error(ACCESS);
// delete is enabled only on applicants
if ($member->type != Member_Model::TYPE_APPLICANT)
Controller::warning(PARAMETER);
// send email with details
$contact = new Contact_Model();
$emails = $contact->find_all_users_contacts($member->user->id, Contact_Model::TYPE_EMAIL);
if ($emails && $emails->count())
// form
$form = new Forge();
$form->group('Basic information');
$form->date('entrance_date')
->label('Entrance date')
->years(date('Y', strtotime($association->entrance_date)), date('Y'))
->rules('required')
->value(time());
if ($this->acl_check_edit(get_class($this), 'registration'))
{
$to = $emails->current()->value;
$from = Settings::get('email_default_email');
$subject = 'Registration deny';
$message = 'Your registration to FreenetIS has been denied';
$form->dropdown('registration')
->options(arr::rbool())
->selected($member->registration);
}
if ($this->acl_check_edit(get_class($this), 'comment'))
{
$form->textarea('comment')
->rules('length[0,250]')
->value($member->comment);
}
$form->group(__('Additional payment for services') . ' ' . help::hint('applicant_additional_payment'));
$form->checkbox('allow_additional_payment')
->label('Allow additional payment')
->value(1);
$form->input('connection_payment_amount')
->label('Amount')
->value($additional_payment_amount)
->style('width: 70px');
$form->submit('Approve');
// sended
if ($form->validate())
{
try
{
email::send($to, $from, $subject, $message);
$member->transaction_start();
$form_data = $form->as_array();
// change member
$member->entrance_date = date('Y-m-d', $form_data['entrance_date']);
if ($this->acl_check_edit('Members_Controller', 'registration'))
{
$member->registration = $form_data['registration'];
}
if ($this->acl_check_edit(get_class($this), 'comment'))
{
$member->comment = $form_data['comment'];
}
$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();
}
// make transfer for connection
if (isset($form_data['allow_additional_payment']) &&
$form_data['allow_additional_payment'] &&
($form_data['connection_payment_amount'] > 0))
{
$operating_account = ORM::factory('account')
->where('account_attribute_id', Account_attribute_Model::OPERATING)
->find();
$credit_account = ORM::factory('account')->where(array
(
'member_id' => $member->id,
'account_attribute_id' => Account_attribute_Model::CREDIT
))->find();
Transfer_Model::insert_transfer(
$credit_account->id, $operating_account->id, null,
null, $this->session->get('user_id'),
null, $member->entrance_date,
date('Y-m-d H:i:s'),
__('Additional payment form services provided before membership'),
$form_data['connection_payment_amount']
);
}
// 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
);
unset($form_data);
$member->transaction_commit();
$this->redirect('members/show', $member_id);
}
catch (Exception $e)
{
status::error(
__('Error - cannot send email to applicant about deny of membership')
. '<br>' . __('Error') . ': ' . $e->getMessage(),
FALSE
);
Log::add_exception($e);
$member->transaction_rollback();
// error
status::error('Applicant for membership cannot be approved');
}
}
$headline = __('Approve application for membership');
// breadcrumbs navigation
$breadcrumbs = breadcrumbs::add()
->link('members/show_all', 'Members',
$this->acl_check_view(get_class($this), 'members'))
->disable_translation()
->link('members/show/'.$member->id,
"ID $member->id - $member->name",
$this->acl_check_view(get_class($this), 'members', $member->id)
)->text($headline);
// view
$view = new View('main');
$view->breadcrumbs = $breadcrumbs->html();
$view->title = $headline;
$view->content = new View('form');
$view->content->headline = $headline;
$view->content->form = $form->html();
$view->content->link_back = '';
$view->render(TRUE);
}
/**
* Deletes registered applicants
*
* @author Ondřej Fibich
* @param integer $member_id
*/
public function delete_applicant($member_id = NULL)
{
// parameter is wrong
if (!$member_id || !is_numeric($member_id))
Controller::warning(PARAMETER);
$member = new Member_Model($member_id);
// member doesn't exist
if (!$member->id)
Controller::error(RECORD);
// access control
if (!$this->acl_check_delete(get_class($this), 'members'))
Controller::error(ACCESS);
// delete is enabled only on applicants
if ($member->type != Member_Model::TYPE_APPLICANT)
Controller::warning(PARAMETER);
// send notice with details
Message_Model::activate_special_notice(
Message_Model::APPLICANT_REFUSE_MEMBERSHIP,
$member->id, $this->session->get('user_id'),
Notifications_Controller::ACTIVATE,
Notifications_Controller::KEEP
);
// delete user
$member->user->delete_depends_items($member->user->id);
$member->user->delete();
......
$title = ($active_interrupt) ? $type . ' '.$member->name
. ' ('. __('I') .')' : $type . ' '.$member->name;
if (($member->type == Member_Model::TYPE_APPLICANT) &&
$this->acl_check_edit(get_class($this), 'members', $member->id))
{
$title .= ' <small style="font-size: 60%; font-weight: normal">(' . html::anchor(
'members/approve_applicant/' . $member_id,
__('Approve application for membership'),
array('class' => 'popup_link')
) . ')</small>';
}
// finds credit account of member
if ($member->id != 1)
......
)
);
if ($member->id != 1)
if ($member->id != 1 && ($member->type != Member_Model::TYPE_APPLICANT))
{
if ($member->type != $former_type_id)
{
......
$types = $enum_types->get_values(Enum_type_Model::MEMBER_TYPE_ID);
asort($types);
// start entrance date
$association = new Member_Model(Member_Model::ASSOCIATION);
$entrace_start_year = date('Y', strtotime($association->entrance_date));
// cannot add former member
unset($types[$enum_types->get_type_id('Former member')]);
......
$form->date('entrance_date')
->label('Entrance date')
->years(date('Y')-100, date('Y'))
->years($entrace_start_year, date('Y'))
->rules('required')
->callback(array($this, 'valid_entrance_date'));
......
}
else
{
$member->entrance_date = date("Y-m-d",$form_data['entrance_date']);
$member->entrance_date = date('Y-m-d', $form_data['entrance_date']);
}
// saving member
......
Controller::error(ACCESS);
$this->_member_id = $member->id;
// start entrance date
$entrace_start_year = date('Y') - 100;
if ($member->id != Member_Model::ASSOCIATION)
{
$association = new Member_Model(Member_Model::ASSOCIATION);
$entrace_start_year = date('Y', strtotime($association->entrance_date));
}
// countries
$arr_countries = ORM::factory('country')->select_list('id', 'country_name');
......
{
$form->date('entrance_date')
->label('Entrance date')
->years(date('Y')-100, date('Y'))
->years($entrace_start_year, date('Y'))
->rules('required')
->value(strtotime($member->entrance_date));
}
......
if ($member->type == Member_Model::TYPE_APPLICANT)
{
$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, $member->user_id
Aro_group_Model::REGULAR_MEMBERS, $main_user_id
))
{
// delete rights of applicant
$group_aro_map->detete_row(
Aro_group_Model::REGISTERED_APPLICANTS,
$member->user_id
$main_user_id
);
// insert regular member access rights
$groups_aro_map = new Groups_aro_map_Model();
$groups_aro_map->aro_id = $member->user_id;
$groups_aro_map->aro_id = $main_user_id;
$groups_aro_map->group_id = Aro_group_Model::REGULAR_MEMBERS;
$groups_aro_map->save();
}
// send email message about approval
$contact = new Contact_Model();
$emails = $contact->find_all_users_contacts(
$member->user->id, Contact_Model::TYPE_EMAIL
);
if ($emails && $emails->count())
{
$to = $emails->current()->value;
$from = Settings::get('email_default_email');
$subject = 'Registration confirm';
$message = 'Your registration to FreenetIS has been confirmed';
try
{
email::send($to, $from, $subject, $message);
}
catch (Exception $e)
{
$m = __('Error - cannot send ' .
'email to applicant about approval of membership'
) . '<br>' . __('Error') .
': ' . $e->getMessage();
status::error($m, FALSE);
}
}
}
}
$member->type = $form_data['type'];
}
freenetis/branches/1.1/application/controllers/members_fees.php
$members_fees_grids[$fee_type_id]->callback_field('status')
->class('center')
->callback('Members_fees_Controller::status_field');
$members_fees_grids[$fee_type_id]->callback_field('comment');
$actions = $members_fees_grids[$fee_type_id]->grouped_action_field();
......
->label('Date to')
->rules('valid_date_string')
->callback(array($this, 'valid_to'));
$form->textarea('comment');
$form->submit('Save');
......
$members_fee->fee_id = $form_data['fee_id'];
$members_fee->activation_date = $from;
$members_fee->deactivation_date = $to;
$members_fee->comment = $form_data['comment'];
$members_fee->save();
status::success('Tariff has been successfully added.');
......
->rules('required|valid_date_string')
->callback(array($this, 'valid_to'))
->value($members_fee->deactivation_date);
$form->textarea('comment')
->value($members_fee->comment);
$form->submit('Save');
......
$members_fee = new Members_fee_Model($members_fee_id);
$members_fee->activation_date = $form_data['from'];
$members_fee->deactivation_date = $form_data['to'];
$members_fee->comment = $form_data['comment'];
$members_fee->save();
status::success('Tariff has been successfully updated.');
freenetis/branches/1.1/application/controllers/messages.php
->selected($message->ignore_whitelist);
}
if ($message->type != Message_Model::RECEIVED_PAYMENT_NOTICE_MESSAGE)
if ($message->type != Message_Model::RECEIVED_PAYMENT_NOTICE_MESSAGE &&
$message->type != Message_Model::APPLICANT_APPROVE_MEMBERSHIP &&
$message->type != Message_Model::APPLICANT_REFUSE_MEMBERSHIP)
{
$form->html_textarea('text')
->label(__('Content of the message for redirection').':&nbsp;'.
......
if ($message->type == Message_Model::USER_MESSAGE ||
$message->type == Message_Model::DEBTOR_MESSAGE ||
$message->type == Message_Model::PAYMENT_NOTICE_MESSAGE ||
$message->type == Message_Model::RECEIVED_PAYMENT_NOTICE_MESSAGE)
$message->type == Message_Model::RECEIVED_PAYMENT_NOTICE_MESSAGE ||
$message->type == Message_Model::APPLICANT_APPROVE_MEMBERSHIP ||
$message->type == Message_Model::APPLICANT_REFUSE_MEMBERSHIP)
{
$form->html_textarea('email_text')
->label(__('Content of the message for E-mail').':&nbsp;'.
......
->cols(100)
->value($message->email_text);
$form->textarea('sms_text')
->label(__('Content of the message for SMS').':&nbsp;'.
help::hint('content_of_message'))
->rules('length[1,760]')
->style('width: 100%; max-width: 633px; height: 150px')
->value($message->sms_text);
if ($message->type != Message_Model::APPLICANT_APPROVE_MEMBERSHIP &&
$message->type != Message_Model::APPLICANT_REFUSE_MEMBERSHIP)
{
$form->textarea('sms_text')
->label(__('Content of the message for SMS').':&nbsp;'.
help::hint('content_of_message'))
->rules('length[1,760]')
->style('width: 100%; max-width: 633px; height: 150px')
->value($message->sms_text);
}
}
$form->submit('Edit');
......
$message->ignore_whitelist = htmlspecialchars($form_data['ignore_whitelist']);
}
if ($message->type != Message_Model::RECEIVED_PAYMENT_NOTICE_MESSAGE)
if ($message->type != Message_Model::RECEIVED_PAYMENT_NOTICE_MESSAGE &&
$message->type != Message_Model::APPLICANT_APPROVE_MEMBERSHIP &&
$message->type != Message_Model::APPLICANT_REFUSE_MEMBERSHIP)
{
$message->text = $form_data['text'];
}
......
if ($message->type == Message_Model::USER_MESSAGE ||
$message->type == Message_Model::DEBTOR_MESSAGE ||
$message->type == Message_Model::PAYMENT_NOTICE_MESSAGE ||
$message->type == Message_Model::RECEIVED_PAYMENT_NOTICE_MESSAGE)
$message->type == Message_Model::RECEIVED_PAYMENT_NOTICE_MESSAGE ||
$message->type == Message_Model::APPLICANT_APPROVE_MEMBERSHIP ||
$message->type == Message_Model::APPLICANT_REFUSE_MEMBERSHIP)
{
// email text
$email_text = trim($form_data['email_text']);
$email_text = empty($email_text) ? NULL : $email_text;
// sms text
$sms_text = trim(text::cs_utf2ascii(strip_tags($form_data['sms_text'])));
$sms_text = empty($sms_text) ? NULL : $sms_text;
// set vars
// set var
$message->email_text = $email_text;
$message->sms_text = $sms_text;
if ($message->type != Message_Model::APPLICANT_APPROVE_MEMBERSHIP &&
$message->type != Message_Model::APPLICANT_REFUSE_MEMBERSHIP)
{
// sms text
$sms_text = trim(text::cs_utf2ascii(strip_tags($form_data['sms_text'])));
$sms_text = empty($sms_text) ? NULL : $sms_text;
// set var
$message->sms_text = $sms_text;
}
}
unset($form_data);
freenetis/branches/1.1/application/controllers/json.php
echo json_encode($result);
}
}
/**
* Calculated additional of applicant
*
* @author Ondřej Fibich
* @see Members_Controller#approve_applicant
*/
public function calculate_additional_payment_of_applicant()
{
$entrance_date = $this->input->get('entrance_date');
$connected_from = $this->input->get('connected_from');
$data = array('amount' => 0);
if (preg_match('/^\d{4}\-\d{1,2}\-\d{1,2}$/', $entrance_date) !== FALSE &&
preg_match('/^\d{4}\-\d{1,2}\-\d{1,2}$/', $connected_from) !== FALSE &&
$entrance_date != '0000-00-00' &&
$connected_from != '0000-00-00')
{
$mf = new Members_fee_Model();
$data['amount'] = $mf->calculate_additional_payment_of_applicant($connected_from, $entrance_date);
}
echo json_encode($data);
}
}
freenetis/branches/1.1/application/controllers/js.php
$this->member_type();
}
private function _js_members_approve_applicant($applicant_id)
{
$applicant = new Member_Model($applicant_id);
if ($applicant && $applicant->id)
{
$this->views['members_approve_applicant'] = View::factory('js/members_approve_applicant');
$this->views['members_approve_applicant']->applicant_connected_from = $applicant->applicant_connected_from;
}
}
private function _js_members_edit()
{
$this->address_point_streets();
freenetis/branches/1.1/application/libraries/importers/Raiffeisenbank/RB_Importer.php
*/
try
{
Message_Model::activate_received_payment_message(
Message_Model::activate_special_notice(
Message_Model::RECEIVED_PAYMENT_NOTICE_MESSAGE,
$member->id, self::$user_id,
$notification_email, $notification_sms
);
freenetis/branches/1.1/application/libraries/importers/Fio/FioSaver.php
*/
try
{
Message_Model::activate_received_payment_message(
Message_Model::activate_special_notice(
Message_Model::RECEIVED_PAYMENT_NOTICE_MESSAGE,
$member->id, $user_id,
$send_emails, $send_sms
);
freenetis/branches/1.1/application/views/members/registration.php
<h2><?php echo __('Administration of members registrations') ?></h2><br />
<?php echo form::open(url_lang::base() . 'members/registration') ?>
<input type="hidden" name="limit_results" value="<?php echo $limit_results ?>">
<input type="hidden" name="page" value="<?php echo $page ?>">
<table class="extended" cellspacing="0">
<tr>
<th>
<?php echo 'ID' ?>
</th>
<th>
<?php echo __('Registration') . '?' ?>
</th>
<th>
<?php echo __('Members name') ?>
</th>
<th>
<?php echo __('Street') ?>
</th>
<th>
<?php echo __('Street number') ?>
</th>
<th>
<?php echo __('Town') ?>
</th>
</tr>
<?php foreach ($members as $member): ?>
<tr>
<?php echo "<input type=\"hidden\" name=\"ids[]\" value=\"" . $member->id . "\">" ?>
<td><?php echo $member->id; ?></td>
<td><input type="checkbox" name="registrations[<?php echo $member->id ?>]" value="yes" <?php if ($member->registration == 1)
echo 'checked' ?>></td>
<td><?php echo $member->name; ?></td>
<td><?php echo $member->street; ?></td>
<td><?php echo $member->street_number; ?></td>
<td><?php echo $member->town; ?></td>
</tr>
<?php endforeach; ?>
<tr>
<td>
</td>
<td colspan="6">
<input id="contactsubmit" type="submit" value="<?php echo __('Save changes') ?>" name="registrationsubmit" />
</td>
</tr>
</table>
<?php echo form::close() ?>
<?php
for ($i = 1; $i <= $max_page; $i++)
{
echo '<a href="' . url_lang::base() . 'members/registration/' . $limit_results . '/' . $i . '">' . $i . '</a> ';
}
?>
freenetis/branches/1.1/application/views/members/show.php
<tr>
<td colspan="2"><?php echo html::anchor(url_lang::base().'variable_symbols/show_by_account/'.$account->id,__('Administrate variable symbols')) ?></td>
</tr>
<?php if (Settings::get('self_registration') && $member->applicant_connected_from) { ?>
<tr>
<th><?php echo __('Connected from') ?></th>
<td><?php echo $member->applicant_connected_from ?></td>
</tr>
<?php } ?>
<?php }} ?>
<?php if ($this->acl_check_view('Members_Controller', 'entrance_date', $member->id)) { ?>
<tr>
freenetis/branches/1.1/application/views/js/members_approve_applicant.php
<?php
/**
* Applicant approval - autoload of calculated additional payment,
* after changing of entrance day.
*
* @author Ondřej Fibich
*/
// IDE complementation
if (FALSE): ?><script type="text/javascript"><?php endif
?>
$('#connection_payment_amount', context).after('<span class="recalculating" style="margin: 5px; display: none"><?php echo html::image('/media/images/icons/animations/ajax-loader.gif') . ' ' . __('Recalculating') ?>...</span>');
$('#connection_payment_amount', context).parent().find('.loading');
// recalculate additional payment on change of entrance date
$('select[name^="entrance_date["]', context).change(function ()
{
var day = $('select[name="entrance_date[day]"]', context).val();
var month = $('select[name="entrance_date[month]"]', context).val();
var year = $('select[name="entrance_date[year]"]', context).val();
var entrance_date = year + '-' + month + '-' + day;
$('#connection_payment_amount', context).parent().find('span.recalculating').show();
$.getJSON('<?php echo url_lang::base() ?>json/calculate_additional_payment_of_applicant?entrance_date=' + entrance_date + '&connected_from=<?php echo $applicant_connected_from ?>', function (data)
{
if (data.amount != undefined)
{
$('#connection_payment_amount', context).val(data.amount);
$('#connection_payment_amount', context).parent().find('span.recalculating').hide();
}
});
});
// on disable of payment hide disable amount field
$('#allow_additional_payment', context).change(function ()
{
if ($(this).is(':checked'))
$('#connection_payment_amount', context).removeAttr('disabled');
else
$('#connection_payment_amount', context).attr('disabled', true);
}).trigger('change');
freenetis/branches/1.1/version.php
* The current version of FreenetIS.
* This value must be changed by developers in a new release of FreenetIS.
*/
define('FREENETIS_VERSION', '1.1.0~alpha2');
define('FREENETIS_VERSION', '1.1.0~alpha3');

Také k dispozici: Unified diff