Revize 676
Přidáno uživatelem Jiří Sviták před asi 14 roky(ů)
freenetis/trunk/kohana/application/i18n/cs_CZ/texts.php | ||
---|---|---|
'day' => 'Den',
|
||
'day book' => 'Účetní deník',
|
||
'debtor' => 'Dlužník',
|
||
'debtor boundary' => 'Hranice pro dlužníka',
|
||
'debtor text' => 'Text pro dlužníka',
|
||
'debtors' => 'Dlužníci',
|
||
'december' => 'Prosinec',
|
||
... | ... | |
'error - cant update transfer' => 'Chyba - nelze upravit převod.',
|
||
'error - cant update user' => 'Chyba - nelze upravit uživatele.',
|
||
'error - cant update work' => 'Chyba - nelze upravit práci.',
|
||
'error - debtor credit boundary has not been set' => 'Chyba - hranice kreditu pro dlužníka nebyla nastavena.',
|
||
'error - it is not possible to remove admin' => 'Chyba - nelze odebrat správce zařízení.',
|
||
'error - it is not possible to remove engineer' => 'Chyba - nelze odebrat technika zařízení.',
|
||
'error - not enough money on origin account' => 'Chyba - nedostatek peněz na zdrojovém účtě.',
|
||
'error - payment notice credit boundary has not been set' => 'Chyba - hranice kreditu pro upozornění na placení nebyla nastavena.',
|
||
'error - some fees have not been recounted' => 'Chyba - některé členské příspěvky nebyly přepočítány.',
|
||
'error - some fees have not been deducted' => 'Chyba - některé členské příspěvky nebyly strženy.',
|
||
'error: parameter ID is required!' => 'Chyba: parametr ID je povinný!',
|
||
... | ... | |
'payment has been successfully assigned' => 'Platba byla úspěšně přiřazena.',
|
||
'payment information' => 'Informace o platbě',
|
||
'payment notice' => 'Upozornění na placení',
|
||
'payment notice boundary' => 'Hranice pro upozornění na placení',
|
||
'payment notice text' => 'Text pro upozornění na placení',
|
||
'penalty' => 'Pokuta',
|
||
'penalty and fee' => 'Poplatky a pokuty',
|
||
... | ... | |
'redirection logs' => 'Logy přesměrování',
|
||
'redirection records' => 'Záznamy přesměrování',
|
||
'redirection settings' => 'Nastavení přesměrování',
|
||
'redirection settings have been successfully updated' => 'Nastavení přesměrování bylo úspěšně upraveno.',
|
||
'redirection settings have not been updated' => 'Nastavení přesměrování nebylo upraveno.',
|
||
'redirection type' => 'Typ přesměrování',
|
||
'reg' => 'Přih.',
|
||
'register' => 'Registrovat',
|
freenetis/trunk/kohana/application/models/account.php | ||
---|---|---|
}
|
||
|
||
/**
|
||
* Function gets total amount of outbound transfers of given account.
|
||
* @param $account_id
|
||
* @return unknown_type
|
||
*/
|
||
public function get_total_outbound_amount($account_id)
|
||
{
|
||
return self::$db->query("SELECT SUM(amount) AS total_outbound
|
||
FROM transfers
|
||
WHERE origin_id = $account_id
|
||
")->current()->total_outbound;
|
||
}
|
||
|
||
/**
|
||
* Function gets total amount of inbound transfers of given account.
|
||
* @param $account_id
|
||
* @return unknown_type
|
||
*/
|
||
public function get_total_inbound_amount($account_id)
|
||
{
|
||
return self::$db->query("SELECT SUM(amount) AS total_inbound
|
||
FROM transfers
|
||
WHERE destination_id = $account_id
|
||
")->current()->total_inbound;
|
||
}
|
||
|
||
/**
|
||
* @author Tomas Dulik
|
||
* This function creates new record in the table "accounts".
|
||
* @param $attribute_id
|
freenetis/trunk/kohana/application/models/transfer.php | ||
---|---|---|
public function get_transfers($account_id = null, $limit_from = 0, $limit_results = 20, $order_by = 't.id', $order_by_direction = 'ASC', $filter_values = array())
|
||
{
|
||
if ($filter_values['type'] == self::$inbound)
|
||
$where = "WHERE t.destination_id = $account_id";
|
||
$where = "WHERE (t.destination_id = $account_id)";
|
||
elseif ($filter_values['type'] == self::$outbound)
|
||
$where = "WHERE t.origin_id = $account_id";
|
||
$where = "WHERE (t.origin_id = $account_id)";
|
||
else
|
||
$where = "WHERE t.origin_id = $account_id OR t.destination_id = $account_id";
|
||
$where = "WHERE (t.origin_id = $account_id OR t.destination_id = $account_id)";
|
||
foreach($filter_values as $key => $value)
|
||
{
|
||
if ($key != 'submit' && $key != 'type')
|
||
... | ... | |
$where .= "t.amount LIKE '%".$value."%' COLLATE utf8_general_ci";
|
||
}
|
||
if ($order_by == 'amount')
|
||
$order_by = 'IF( t.destination_id = '.$account_id.', t.amount, t.amount*-1 )';
|
||
$order_by = 'IF(t.destination_id = '.$account_id.', t.amount, -t.amount)';
|
||
return self::$db->query("SELECT
|
||
t.id,
|
||
t.text,
|
||
IF(t.amount <> 0, IF(t.destination_id = $account_id, t.amount, -t.amount), 0) AS amount,
|
||
t.datetime,
|
||
t.origin_id, t.destination_id,
|
||
a.name,
|
||
IF(t.destination_id = $account_id, bt.variable_symbol, NULL) AS variable_symbol,
|
||
(
|
||
... | ... | |
LEFT JOIN transfers pt ON pt.id = t.previous_transfer_id
|
||
LEFT JOIN bank_transfers bt ON pt.id = bt.transfer_id
|
||
$where
|
||
GROUP BY t.id
|
||
ORDER BY $order_by $order_by_direction
|
||
LIMIT $limit_from, $limit_results"
|
||
);
|
||
... | ... | |
public function count_transfers($account_id = null, $filter_values = array())
|
||
{
|
||
if ($filter_values['type'] == self::$inbound)
|
||
$where = "WHERE t.destination_id = $account_id";
|
||
$where = "WHERE (t.destination_id = $account_id)";
|
||
elseif ($filter_values['type'] == self::$outbound)
|
||
$where = "WHERE t.origin_id = $account_id";
|
||
$where = "WHERE (t.origin_id = $account_id)";
|
||
else
|
||
$where = "WHERE t.origin_id = $account_id OR t.destination_id = $account_id";
|
||
$where = "WHERE (t.origin_id = $account_id OR t.destination_id = $account_id)";
|
||
foreach($filter_values as $key => $value)
|
||
{
|
||
if ($key != 'submit' && $key != 'type')
|
freenetis/trunk/kohana/application/controllers/members.php | ||
---|---|---|
'use_selector' => false
|
||
));
|
||
if ($this->acl_check_new('Messages_Controller', 'member'))
|
||
$redir_grid->add_new_button(url_lang::base().'redirect/add_member/'.$member_id, url_lang::lang('texts.Add redirection to all ip addresses of member'));
|
||
$redir_grid->add_new_button(url_lang::base().'redirect/add_to_member/'.$member_id, url_lang::lang('texts.Add redirection to all ip addresses of member'));
|
||
$redir_grid->field('ip_address')->label(url_lang::lang('texts.IP address'));
|
||
$redir_grid->field('name')->label(url_lang::lang('texts.Message'));
|
||
if ($this->acl_check_delete('Messages_Controller', 'ip_address'))
|
freenetis/trunk/kohana/application/controllers/transfers.php | ||
---|---|---|
$filter_values = $filter->values();
|
||
if (count($filter_values) == 0)
|
||
$filter_values['type'] = Transfer_Model::$inbound_and_outbound;
|
||
// count expiration date of credit
|
||
$balance = $account->get_account_balance($account_id);
|
||
// transfers on account
|
||
$transfer_model = new Transfer_Model();
|
||
$total_transfers = $transfer_model->count_transfers($account_id, $filter_values);
|
||
if (($sql_offset = ($page - 1) * $limit_results) > $total_transfers)
|
||
$sql_offset = 0;
|
||
$transfers = $transfer_model->get_transfers($account_id, $sql_offset, (int)$limit_results, $order_by, $order_by_direction, $filter_values);
|
||
// total amount of inbound and outbound transfers and total balance
|
||
$balance = $inbound = $outbound = 0;
|
||
if (count($transfers) > 0)
|
||
{
|
||
$inbound = $transfers->current()->inbound;
|
||
$outbound = $transfers->current()->outbound;
|
||
$balance = $inbound - $outbound;
|
||
}
|
||
// count expiration date from current balance
|
||
if ($balance == 0)
|
||
{
|
||
$expiration_date = null;
|
||
... | ... | |
$expiration_date = url_lang::lang('texts.No member fee set!');
|
||
}
|
||
}
|
||
// transfers on account
|
||
$transfer_model = new Transfer_Model();
|
||
$total_transfers = $transfer_model->count_transfers($account_id, $filter_values);
|
||
if (($sql_offset = ($page - 1) * $limit_results) > $total_transfers)
|
||
$sql_offset = 0;
|
||
$transfers = $transfer_model->get_transfers($account_id, $sql_offset, (int)$limit_results, $order_by, $order_by_direction, $filter_values);
|
||
// total amount of inbound and outbound transfers
|
||
$inbound = $outbound = 0;
|
||
if (count($transfers) > 0)
|
||
{
|
||
$inbound = $transfers->current()->inbound;
|
||
$outbound = $transfers->current()->outbound;
|
||
}
|
||
// headline
|
||
$headline = url_lang::lang('texts.Transfers of double-entry account');
|
||
// grid of transfers
|
freenetis/trunk/kohana/application/controllers/messages.php | ||
---|---|---|
<?php
|
||
class Messages_Controller extends Controller
|
||
{
|
||
function index()
|
||
{
|
||
url::redirect(url_lang::base().'messages/show_all');
|
||
}
|
||
|
||
/**
|
||
* Shows all redirection messages.
|
||
* @author Jiri Svitak
|
||
... | ... | |
}
|
||
elseif ($message->type == Message_Model::$debtor_message)
|
||
{
|
||
// @todo boundary credit status
|
||
$debtor_boundary = -900;
|
||
// boundary credit status
|
||
$debtor_boundary = $this->settings->get('debtor_boundary');
|
||
if (empty($debtor_boundary))
|
||
{
|
||
$this->session->set_flash('message', url_lang::lang('texts.Error - debtor credit boundary has not been set.'));
|
||
url::redirect(url_lang::base().'messages/show_all');
|
||
}
|
||
// finding IP addresses to redirect to debtor message
|
||
$ips = $db->query("
|
||
SELECT ip.id, ip.ip_address, ip.whitelisted
|
||
... | ... | |
}
|
||
elseif ($message->type == Message_Model::$payment_notice_message)
|
||
{
|
||
// @todo boundary credit status
|
||
$payment_notice_boundary = 0;
|
||
// boundary credit status
|
||
$payment_notice_boundary = $this->settings->get('payment_notice_boundary');
|
||
if (empty($payment_notice_boundary))
|
||
{
|
||
$this->session->set_flash('message', url_lang::lang('texts.Error - payment notice credit boundary has not been set.'));
|
||
url::redirect(url_lang::base().'messages/show_all');
|
||
}
|
||
// finding IP addresses to redirect to debtor message
|
||
$ips = $db->query("
|
||
SELECT ip.id, ip.ip_address, ip.whitelisted
|
||
... | ... | |
{
|
||
Controller::warning(PARAMETER);
|
||
}
|
||
|
||
$this->session->set_flash('message', url_lang::lang('texts.Redirection has been successfully set.'));
|
||
url::redirect(url_lang::base().'messages/show_all');
|
||
}
|
||
|
||
}
|
freenetis/trunk/kohana/application/controllers/redirect.php | ||
---|---|---|
*/
|
||
function settings()
|
||
{
|
||
|
||
// access control
|
||
if (!$this->acl_check_edit('Settings_Controller', 'system'))
|
||
Controller::error(ACCESS);
|
||
// creating links
|
||
$arr_links = array();
|
||
$arr_links[] = html::anchor(url_lang::base().'messages/show_all', url_lang::lang('texts.Messages for redirection'));
|
||
$arr_links[] = html::anchor(url_lang::base().'redirect/show_all', url_lang::lang('texts.Active Redirections'));
|
||
$arr_links[] = html::anchor(url_lang::base().'redirect/settings', url_lang::lang('texts.Settings'));
|
||
$links = implode(' | ', $arr_links);
|
||
// creating of new forge
|
||
$this->form = new Forge(url_lang::base()."redirect/settings", '', 'POST', array('id' => 'article_form'));
|
||
$this->form->set_attr('class', 'form_class')->set_attr('method', 'post');
|
||
$this->form->group('')->label(url_lang::lang('texts.Gateway'));
|
||
$this->form->input('gateway')->label(url_lang::lang('texts.Gateway IP address').":")->value($this->settings->get('gateway'));
|
||
$this->form->input('payment_notice_boundary')->label(url_lang::lang('texts.Payment notice boundary')." (".$this->settings->get('currency')."):")->value($this->settings->get('payment_notice_boundary'));
|
||
$this->form->input('debtor_boundary')->label(url_lang::lang('texts.Debtor boundary')." (".$this->settings->get('currency')."):")->value($this->settings->get('debtor_boundary'));
|
||
$this->form->submit('submit')->value(url_lang::lang('texts.Save'));
|
||
special::required_forge_style($this->form, ' *', 'required');
|
||
// form validate
|
||
if ($this->form->validate())
|
||
{
|
||
$form_data = $this->form->as_array();
|
||
$config_model = new Config_Model();
|
||
$issaved = true;
|
||
foreach ($form_data as $name => $value)
|
||
{
|
||
$value = addslashes($value);
|
||
// check if variable exists
|
||
if ($config_model->check_exist_variable($name))
|
||
// update of variable
|
||
$issaved = $issaved && $config_model->update_variable($name,$value);
|
||
else
|
||
// insert new variable
|
||
$issaved = $issaved && $config_model->insert_variable($name,$value);
|
||
}
|
||
if ($issaved)
|
||
// if all action were succesfull
|
||
$this->session->set_flash('message', url_lang::lang('texts.Redirection settings have been successfully updated.'));
|
||
else
|
||
// if not
|
||
$this->session->set_flash('message', url_lang::lang('texts.Redirection settings have not been updated.'));
|
||
|
||
url::redirect(url_lang::base().'redirect/settings');
|
||
}
|
||
// create view for this template
|
||
$view = new View('main');
|
||
$view->title = url_lang::lang('texts.Settings').' - '.url_lang::lang('texts.Gateway');
|
||
$view->content = new View('form');
|
||
$view->content->form = $this->form->html();
|
||
$view->content->headline = url_lang::lang('texts.Redirection settings');
|
||
$view->content->link_back = $links;
|
||
$message = $this->session->get_once('message');
|
||
if (!empty($message))
|
||
$view->content->message = $message;
|
||
$view->render(TRUE);
|
||
}
|
||
|
||
/**
|
||
... | ... | |
* @author Jiri Svitak
|
||
* @param unknown_type $member_id
|
||
*/
|
||
function add_member($member_id = null)
|
||
function add_to_member($member_id = null)
|
||
{
|
||
// access rights
|
||
if (!$this->acl_check_edit('Messages_Controller', 'member'))
|
||
... | ... | |
url::redirect(url_lang::base().'members/show/'.$member_id);
|
||
}
|
||
// form
|
||
$form = new Forge(url_lang::base().'redirect/add_member/'.$member_id, '', 'POST', array('id' => 'article_form'));
|
||
$form = new Forge(url_lang::base().'redirect/add_to_member/'.$member_id, '', 'POST', array('id' => 'article_form'));
|
||
$form->set_attr('class', 'form_class')->set_attr('method', 'post');
|
||
$form->group('')->label(url_lang::lang('texts.Redirection'));
|
||
$form->dropdown('message_id')->label(url_lang::lang('texts.Redirection').':')->options($message_array);
|
||
... | ... | |
}
|
||
}
|
||
|
||
function delete_from_member($member_id = null)
|
||
{
|
||
// access rights
|
||
if (!$this->acl_check_edit('Messages_Controller', 'member'))
|
||
Controller::error(ACCESS);
|
||
if (!isset($member_id))
|
||
Controller::warning(PARAMETER);
|
||
// member
|
||
$member = new Member_Model($member_id);
|
||
if ($member->id == 0)
|
||
Controller::error(RECORD);
|
||
// load list of IP addresses belonging to member
|
||
$ip_model = new Ip_address_Model();
|
||
$ips = $ip_model->get_ip_addresses_of_member($member_id);
|
||
// array of messages
|
||
$message_array = array();
|
||
foreach($ips as $ip)
|
||
{
|
||
foreach($messages as $message)
|
||
{
|
||
// whitelisted IP addresses can be redirected only by redirections which ignore whitelist
|
||
if ($ip->whitelisted && !$message->ignore_whitelist)
|
||
continue;
|
||
// IP address can be manually redirected only to user message, interrupted membership message, debtor message, payment notice message
|
||
if ($message->type == Message_Model::$user_message ||
|
||
$message->type == Message_Model::$interrupted_membership_message ||
|
||
$message->type == Message_Model::$debtor_message ||
|
||
$message->type == Message_Model::$payment_notice_message)
|
||
{
|
||
$message_array[$message->id] = $message->name;
|
||
}
|
||
}
|
||
}
|
||
// no redirection possible for this member?
|
||
if (empty($message_array))
|
||
{
|
||
$this->session->set_flash('message', url_lang::lang('texts.No redirection is possible to set for this IP address.'));
|
||
url::redirect(url_lang::base().'members/show/'.$member_id);
|
||
}
|
||
// form
|
||
$form = new Forge(url_lang::base().'redirect/add_to_member/'.$member_id, '', 'POST', array('id' => 'article_form'));
|
||
$form->set_attr('class', 'form_class')->set_attr('method', 'post');
|
||
$form->group('')->label(url_lang::lang('texts.Redirection'));
|
||
$form->dropdown('message_id')->label(url_lang::lang('texts.Redirection').':')->options($message_array);
|
||
//$form->textarea('comment')->label(url_lang::lang('texts.Comment of admin shown to user').':');
|
||
$form->submit('submit')->value(url_lang::lang('texts.Redirect'));
|
||
special::required_forge_style($form, ' *', 'required');
|
||
// validation
|
||
if ($form->validate())
|
||
{
|
||
$form_data = $form->as_array();
|
||
$db = new Database();
|
||
foreach($ips as $ip)
|
||
{
|
||
// delete old redirection if present
|
||
$db->delete('messages_ip_addresses', array('message_id' => $form_data['message_id'], 'ip_address_id' => $ip->id));
|
||
if (!$ip->whitelisted || $message->ignore_whitelist)
|
||
{
|
||
// database insert sets redirection for ip address
|
||
$db->insert('messages_ip_addresses', array('message_id' => $form_data['message_id'],
|
||
'ip_address_id' => $ip->id, 'user_id' => $this->session->get('user_id'),
|
||
'comment' => $form_data['comment'], 'datetime' => date('Y-m-d H:i:s')));
|
||
// generate html page
|
||
self::update($ip->ip_address);
|
||
}
|
||
}
|
||
// set flash message
|
||
$this->session->set_flash('message', url_lang::lang('texts.Redirection has been successfully set.'));
|
||
url::redirect(url_lang::base().'members/show/'.$member_id);
|
||
}
|
||
else
|
||
{
|
||
// view
|
||
$headline = url_lang::lang('texts.Redirection');
|
||
$view = new View('main');
|
||
$view->title = $headline;
|
||
$view->content = new View('form');
|
||
$view->content->headline = $headline;
|
||
$view->content->link_back = html::anchor(url_lang::base().'members/show/'.$member_id, url_lang::lang('texts.Back to the member'));
|
||
$view->content->form = $form->html();
|
||
$view->render(TRUE);
|
||
}
|
||
}
|
||
|
||
|
||
/**
|
||
* Updates static html file with redirection message.
|
||
* @param $ip_address
|
||
... | ... | |
// current credit
|
||
$account_balance = ORM::factory('account_balance')->where('member_id', $ip->iface->device->user->member_id)->find();
|
||
$current_credit = $account_balance->balance;
|
||
// count payment amount to end of year
|
||
}
|
||
// subnet name
|
||
$subnet_model = new Subnet_Model();
|
freenetis/trunk/kohana/application/views/form.php | ||
---|---|---|
<h2><?php echo $headline ?></h2>
|
||
<?php echo (isset($message)) ? '<div class="message">'.$message.'</div>' : '' ?>
|
||
<?php
|
||
if (isset($message))
|
||
echo empty($message) ? '' : '<div class="message">'.$message.'</div>';
|
||
?>
|
||
<?php echo (!$this->popup) ? $link_back : '' ?>
|
||
<br /><br />
|
||
<?php echo $form ?>
|
freenetis/trunk/kohana/application/views/show_all.php | ||
---|---|---|
<?php
|
||
echo "<h2>$headline</h2>";
|
||
echo ($message = $this->session->get('message')) ? '<div class="message">'.$message.'</div>' : '';
|
||
if (isset($message))
|
||
{
|
||
echo empty($message) ? '' : '<div class="message">'.$message.'</div>';
|
||
}
|
||
if (isset($link_back)) echo "$link_back<br/>";
|
||
if (isset($create)) echo $create;
|
||
echo "<br/>$table";
|
Také k dispozici: Unified diff
Namisto celkovych sum pohybu na ucte dodelany dynamicke soucty, ktere odpovidaji prave vyfiltrovanym prevodum. Pridana sprava nastaveni presmerovani.