Revize 544
Přidáno uživatelem Jiří Sviták před téměř 15 roky(ů)
freenetis/trunk/kohana/application/models/device.php | ||
---|---|---|
* @param $user_id
|
||
* @return unknown_type
|
||
*/
|
||
public function get_devices_of_user($limit_from = 0, $limit_results = 50, $order_by = 'id', $order_by_direction = 'ASC', $user_id = null)
|
||
public function get_devices_of_user($limit_from = 0, $limit_results = 50, $order_by = 'inet_aton(ip.ip_address)', $order_by_direction = 'ASC', $user_id = null)
|
||
{
|
||
return self::$db->query("SELECT
|
||
d.id, IFNULL(f.translated_term,e.value) as type, d.name,
|
||
CONCAT(u.name, ' ', u.surname) AS u_name,
|
||
i.mac, s.name AS segment_name, ip.ip_address
|
||
i.mac, se.name AS segment_name, ip.ip_address, su.name AS subnet_name
|
||
FROM devices d
|
||
JOIN users u ON d.user_id = u.id
|
||
LEFT JOIN enum_types e ON d.type = e.id
|
||
LEFT JOIN (SELECT * FROM translations WHERE lang = '".Config::item('locale.lang')."') f ON e.value = f.original_term
|
||
LEFT JOIN ifaces i ON d.id = i.device_id
|
||
LEFT JOIN segments s ON s.id = i.segment_id
|
||
LEFT JOIN segments se ON se.id = i.segment_id
|
||
LEFT JOIN ip_addresses ip ON i.id = ip.iface_id
|
||
LEFT JOIN subnets su ON su.id = ip.subnet_id
|
||
WHERE u.id = $user_id
|
||
ORDER BY $order_by $order_by_direction
|
||
LIMIT $limit_from, $limit_results
|
freenetis/trunk/kohana/application/models/member.php | ||
---|---|---|
* @author Jiri Svitak
|
||
* @return unknown_type
|
||
*/
|
||
public function update_payment_notice($amount)
|
||
public function update_payment_notice($lower_amount, $upper_amount)
|
||
{
|
||
// preparation
|
||
self::$db->query("UPDATE members SET redirect = redirect & ~4;");
|
||
... | ... | |
SELECT (q3.inbound - q3.outbound) AS balance, q3.mid
|
||
FROM
|
||
(
|
||
SELECT SUM(t.amount) AS outbound, q2.inbound, q2.mid
|
||
SELECT IFNULL(SUM(t.amount), 0) AS outbound, q2.inbound, q2.mid
|
||
FROM
|
||
(
|
||
SELECT SUM(t.amount) AS inbound, q1.aid, q1.mid
|
||
SELECT IFNULL(SUM(t.amount), 0) AS inbound, q1.aid, q1.mid
|
||
FROM
|
||
(
|
||
SELECT a.id AS aid, m.id AS mid
|
||
FROM accounts a
|
||
JOIN members m ON m.id = a.member_id
|
||
WHERE m.id <> 1 AND a.account_attribute_model = ".Account_attribute_Model::$credit."
|
||
SELECT id AS aid, member_id AS mid
|
||
FROM accounts
|
||
WHERE member_id <> 1 AND account_attribute_id = ".Account_attribute_Model::$credit."
|
||
) q1
|
||
LEFT JOIN transfers t ON t.destination_id = q1.aid
|
||
GROUP BY q1.aid
|
||
... | ... | |
LEFT JOIN transfers t ON t.origin_id = q2.aid
|
||
GROUP BY q2.aid
|
||
) q3
|
||
WHERE $lower_amount < (q3.inbound - q3.outbound) AND (q3.inbound - q3.outbound) < $upper_amount
|
||
) q
|
||
SET m.redirect = m.redirect | 4
|
||
WHERE $amount >= q.balance AND q.balance >= 0 AND m.id = q.mid
|
||
WHERE m.id = q.mid
|
||
");
|
||
}
|
||
|
||
... | ... | |
SELECT (q3.inbound - q3.outbound) AS balance, q3.mid
|
||
FROM
|
||
(
|
||
SELECT SUM(t.amount) AS outbound, q2.inbound, q2.mid
|
||
SELECT IFNULL(SUM(t.amount), 0) AS outbound, q2.inbound, q2.mid
|
||
FROM
|
||
(
|
||
SELECT SUM(t.amount) AS inbound, q1.aid, q1.mid
|
||
SELECT IFNULL(SUM(t.amount), 0) AS inbound, q1.aid, q1.mid
|
||
FROM
|
||
(
|
||
SELECT a.id AS aid, m.id AS mid
|
freenetis/trunk/kohana/application/models/bank_transfer.php | ||
---|---|---|
$order_by = 'IF(bt.destination_id = '.$ba_id.', amount, amount*-1 )';
|
||
return self::$db->query("SELECT
|
||
bt.id,
|
||
IF (bt.destination_id = $ba_id, FALSE, TRUE) AS trans_type,
|
||
ba.account_nr, ba.bank_nr,
|
||
ba.name,
|
||
t.datetime, t.text, t.amount,
|
||
t.datetime, t.text,
|
||
IF(bt.destination_id = $ba_id, t.amount, -t.amount) AS amount,
|
||
bt.variable_symbol, bt.transfer_id
|
||
FROM bank_transfers bt
|
||
LEFT JOIN bank_accounts ba ON ba.id = IF (bt.origin_id = $ba_id, bt.destination_id, bt.origin_id)
|
freenetis/trunk/kohana/application/models/transfer.php | ||
---|---|---|
oa.account_attribute_id AS o_attribute,
|
||
CONCAT('<a href=\"".url_lang::base()."transfers/show_by_account/', da.id, '\">', da.name, '</a>') AS destination,
|
||
da.account_attribute_id AS d_attribute,
|
||
t.text, t.amount, t.datetime
|
||
t.text, t.amount AS daybook_amount, t.datetime
|
||
FROM transfers t
|
||
LEFT JOIN accounts oa ON oa.id = t.origin_id
|
||
LEFT JOIN accounts da ON da.id = t.destination_id
|
||
... | ... | |
if ($order_by == 'amount')
|
||
$order_by = 'IF( t.destination_id = '.$account_id.', amount, amount*-1 )';
|
||
return self::$db->query("SELECT
|
||
t.id, IF(t.destination_id = $account_id, FALSE, TRUE) AS trans_type,
|
||
t.text, t.amount, t.datetime,
|
||
t.id,
|
||
t.text,
|
||
IF(t.amount <> 0, IF(t.destination_id = $account_id, t.amount, -t.amount), 0) AS amount,
|
||
t.datetime,
|
||
a.name,
|
||
IF(t.destination_id = $account_id, bt.variable_symbol, NULL) AS variable_symbol
|
||
FROM transfers t
|
freenetis/trunk/kohana/application/controllers/ifaces.php | ||
---|---|---|
*/
|
||
function edit($iface_id = null)
|
||
{
|
||
$ssDevice_id = $this->session->get('ssDevice_id');
|
||
$ssIface_id = $this->session->get('ssIface_id');
|
||
$iface = new Iface_Model($iface_id);
|
||
if (!isset($iface_id) || $iface->id == 0)
|
||
{
|
||
... | ... | |
$form->set_attr('class', 'form_class')->set_attr('method', 'post');
|
||
$form->group('')->label(url_lang::lang('texts.Basic data'));
|
||
$form->input('name')->label(url_lang::lang('texts.name').':')->rules('length[2,250]')->value($iface->name);
|
||
if ($ssDevice_id)
|
||
{
|
||
$device = new Device_Model($ssDevice_id);
|
||
$form->dropdown('device_id')->label(url_lang::lang('texts.Device name'))->options(array($ssDevice_id => $device->name))->rules('required');
|
||
}
|
||
else
|
||
{
|
||
$device_model = new Device_Model();
|
||
$devices = $device_model->select(array('id','name'))->orderby('name')->find_all();
|
||
$arr_devices[0] = '----- '.url_lang::lang('texts.select device').' -----';
|
||
foreach ($devices as $device)
|
||
{
|
||
$arr_devices[$device->id] = $device->name;
|
||
}
|
||
$form->dropdown('device_id')->label(url_lang::lang('texts.Device name'))->options($arr_devices)->rules('required')->selected($iface->device_id);
|
||
}
|
||
|
||
$device = new Device_Model($iface->device_id);
|
||
$form->dropdown('device_id')->label(url_lang::lang('texts.Device name'))->options(array($device->id => $device->name))->rules('required');
|
||
|
||
$segment_model = new Segment_Model();
|
||
$segments = $segment_model->select(array('id','name'))->orderby('name')->find_all();
|
||
$arr_segments[0] = '----- '.url_lang::lang('texts.select segment').' -----';
|
||
... | ... | |
url::redirect(url_lang::base().'ifaces/show/'.$iface->id);
|
||
}
|
||
}
|
||
if ($ssIface_id)
|
||
$link_back = html::anchor(url_lang::base().'ifaces/show/'.$iface->id, url_lang::lang('texts.Back to interface parameters'));
|
||
else
|
||
$link_back = html::anchor(url_lang::base().'ifaces/show_all/', url_lang::lang('texts.Back to interfaces list'));
|
||
$headline = url_lang::lang('texts.Edit interface').' - '.$iface->name;
|
||
$link_back = html::anchor(url_lang::base().'ifaces/show/'.$iface->id, url_lang::lang('texts.Back to interface parameters'));
|
||
$headline = url_lang::lang('texts.Edit interface');
|
||
$view = new View('main');
|
||
$view->title = $headline;
|
||
$view->content = new View('form');
|
||
... | ... | |
{
|
||
if (isset($iface_id))
|
||
{
|
||
// gets information from session to know where to return
|
||
$ssDevice_id = $this->session->get('ssDevice_id');
|
||
$iface = new Iface_Model($iface_id);
|
||
if (!$iface->id)
|
||
url::redirect(url_lang::base().'ifaces/show_all');
|
||
if ($ssDevice_id)
|
||
$link_back = url_lang::base().'devices/show/'.$iface->device_id;
|
||
else
|
||
$link_back = url_lang::base().'ifaces/show_all';
|
||
$link_back = url_lang::base().'devices/show/'.$iface->device_id;
|
||
// access rights
|
||
if (!$this->acl_check_delete('Devices_Controller', 'iface', $iface->device->user->member_id))
|
||
Controller::error(ACCESS);
|
||
// find ip addresses of interface, in this relation 1:n ORM works
|
freenetis/trunk/kohana/application/controllers/transfers.php | ||
---|---|---|
$grid->order_field('d_attribute')->label(url_lang::lang('texts.Type'));
|
||
$grid->order_field('datetime')->label(url_lang::lang('texts.Date and time'));
|
||
$grid->order_field('text')->label(url_lang::lang('texts.Text'));
|
||
$grid->order_field('amount')->label(url_lang::lang('texts.Amount'));
|
||
$grid->order_field('daybook_amount')->label(url_lang::lang('texts.Amount'));
|
||
if ($this->acl_check_view('Accounts_Controller', 'transfers'))
|
||
$grid->action_field('id')->label(url_lang::lang('texts.Transfer'))->url(url_lang::base().'transfers/show')->action(url_lang::lang('texts.Show'));
|
||
// transfers should not be edited
|
||
... | ... | |
if ($this->acl_check_new('Accounts_Controller', 'transfers'))
|
||
$grid->add_new_button(url_lang::base().'transfers/add/'.$account_id, url_lang::lang('texts.Send money to other account'));
|
||
$grid->order_field('id')->label('ID');
|
||
$grid->order_field('trans_type')->label(url_lang::lang('texts.Type'))->bool(array(url_lang::lang('texts.Inbound'),url_lang::lang('texts.Outbound')));
|
||
//$grid->order_field('trans_type')->label(url_lang::lang('texts.Type'))->bool(array(url_lang::lang('texts.Inbound'),url_lang::lang('texts.Outbound')));
|
||
$grid->order_field('name')->label(url_lang::lang('texts.Counteraccount'));
|
||
$grid->order_field('datetime')->label(url_lang::lang('texts.Date and time'));
|
||
$grid->order_field('amount')->label(url_lang::lang('texts.Amount'));
|
||
... | ... | |
{
|
||
if (!isset($transfer_id))
|
||
Controller::warning(PARAMETER);
|
||
$account_model = new Account_Model();
|
||
//$account_model = new Account_Model();
|
||
$transfer_model = new Transfer_Model();
|
||
$transfer = $transfer_model->get_transfer($transfer_id);
|
||
if (!is_object($transfer))
|
||
Controller::error(RECORD);
|
||
if (!$this->acl_check_view('Accounts_Controller', 'transfers', $transfer->member_id))
|
||
$oa = new Account_Model($transfer->oa_id);
|
||
if ($oa->member_id != 1)
|
||
$member_id = $oa->member_id;
|
||
$da = new Account_Model($transfer->da_id);
|
||
if ($da->member_id != 1)
|
||
$member_id = $da->member_id;
|
||
if (!$this->acl_check_view('Accounts_Controller', 'transfers', $member_id))
|
||
Controller::error(ACCESS);
|
||
// transfers dependent on this transfer, if this transfer is member fee payment
|
||
$dependent_transfers = $transfer_model->get_dependent_transfers($transfer->id);
|
freenetis/trunk/kohana/application/controllers/redirect.php | ||
---|---|---|
}
|
||
break;
|
||
// special list of ip addresses - some ip addresses are never redirected
|
||
// now it is useless - whitelisted ip addresses can be added to allowed ip addresses
|
||
case 'partners':
|
||
|
||
break;
|
||
... | ... | |
$fee = $fee_model->get_by_date_type(date('Y-m-d'), 'regular member fee');
|
||
if ($fee->id)
|
||
$current_fee = $fee->fee;
|
||
$member_model->update_payment_notice(2 * $current_fee);
|
||
$member_model->update_payment_notice(-100000, 0);
|
||
}
|
||
elseif ($form_data['payment_notice'] == 2)
|
||
$member_model->cancel_redirection(4);
|
freenetis/trunk/kohana/application/controllers/bank_transfers.php | ||
---|---|---|
{
|
||
if (!isset($bank_account_id))
|
||
Controller::warning(PARAMETER);
|
||
// access rights
|
||
if(!$this->acl_check_view('Accounts_Controller', 'bank_transfers'))
|
||
Controller::error(ACCESS);
|
||
// bank account
|
||
$ba = new Bank_account_Model($bank_account_id);
|
||
if ($ba->id == 0)
|
||
Controller::error(RECORD);
|
||
|
||
// access rights
|
||
if (!($this->acl_check_view('Accounts_Controller', 'bank_transfers') || ($this->acl_check_2D('menu', 'bank_accounts') && ($ba->member_id == 1))))
|
||
Controller::error(ACCESS);
|
||
|
||
if (is_numeric($this->input->get('record_per_page')))
|
||
$limit_results = (int) $this->input->get('record_per_page');
|
||
$allowed_order_type = array('id', 'name', 'amount', 'datetime', 'trans_type', 'account_number', 'variable_symbol');
|
||
... | ... | |
$grid->add_new_button(url_lang::base().'bank_transfers/add/'.$bank_account_id, url_lang::lang('texts.Add new bank transfer'));
|
||
$grid->add_new_button(url_lang::base().'bank_transfers/add_fee/'.$bank_account_id, url_lang::lang('texts.Add new bank transfer without counteraccount'));
|
||
}
|
||
$grid->order_field('id')->label('ID');
|
||
$grid->order_field('trans_type')->label(url_lang::lang('texts.Type'))->bool(array(url_lang::lang('texts.Arrival'),url_lang::lang('texts.Outbound')));
|
||
//$grid->order_field('id')->label('ID');
|
||
$grid->order_field('datetime')->label(url_lang::lang('texts.Date and time'));
|
||
$grid->order_field('name')->label(url_lang::lang('texts.Counteraccount'));
|
||
$grid->order_field('account_nr')->label(url_lang::lang('texts.Account number'));
|
||
$grid->order_field('bank_nr')->label(url_lang::lang('texts.Bank code'));
|
||
//$grid->order_field('text')->label(url_lang::lang('texts.Text'));
|
||
if ($this->acl_check_view('Accounts_Controller', 'bank_transfers'))
|
||
{
|
||
$grid->order_field('account_nr')->label(url_lang::lang('texts.Account number'));
|
||
$grid->order_field('bank_nr')->label(url_lang::lang('texts.Bank code'));
|
||
}
|
||
$grid->order_field('text')->label(url_lang::lang('texts.Text'));
|
||
$grid->order_field('variable_symbol')->label(url_lang::lang('texts.VS'));
|
||
$grid->order_field('amount')->label(url_lang::lang('texts.Amount'));
|
||
if ($this->acl_check_view('Accounts_Controller', 'transfers'))
|
freenetis/trunk/kohana/application/controllers/bank_accounts.php | ||
---|---|---|
*/
|
||
function show_all($limit_results = 500, $order_by = 'id', $order_by_direction = 'ASC', $page_word = null, $page = 1)
|
||
{
|
||
if (!$this->acl_check_view('Accounts_Controller', 'bank_accounts'))
|
||
if (!$this->acl_check_2D('menu', 'bank_accounts'))
|
||
Controller::error(ACCESS);
|
||
// it gets only bank accounts of association
|
||
$bank_account_model = new Bank_account_Model();
|
||
... | ... | |
$baa_grid->add_new_button(url_lang::base().'bank_accounts/add/1', url_lang::lang('texts.Add new bank account of association'));
|
||
// csv file templates for bank listings
|
||
if ($this->acl_check_view('Accounts_Controller', 'bank_transfers'))
|
||
$baa_grid->add_new_button(url_lang::base().'bank_templates/show_all', url_lang::lang('texts.CSV file templates'));
|
||
$baa_grid->add_new_button(url_lang::base().'bank_templates/show_all', url_lang::lang('texts.CSV file templates'));
|
||
$baa_grid->field('id')->label(url_lang::lang('texts.ID'));
|
||
$baa_grid->field('baname')->label(url_lang::lang('texts.Account name'));
|
||
$baa_grid->field('account_number')->label(url_lang::lang('texts.Account number'));
|
||
$baa_grid->field('mname')->label(url_lang::lang('texts.Member name'));
|
||
if ($this->acl_check_view('Accounts_Controller', 'bank_transfers'))
|
||
if ($this->acl_check_view('Accounts_Controller', 'bank_transfers') || $this->acl_check_2D('menu', 'bank_accounts'))
|
||
$baa_grid->action_field('id')->label(url_lang::lang('texts.Transfers'))->url(url_lang::base().'bank_transfers/show_by_bank_account')->action(url_lang::lang('texts.Show'));
|
||
if ($this->acl_check_new('Accounts_Controller', 'bank_transfers'))
|
||
$baa_grid->action_field('id')->label(url_lang::lang('texts.Import'))->url(url_lang::base().'import/upload_bank_file')->action(url_lang::lang('texts.Import'));
|
||
... | ... | |
|
||
// bank accounts except association's
|
||
|
||
// get 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', 'baname', 'account_number', 'mname');
|
||
if (!in_array(strtolower($order_by),$allowed_order_type))
|
||
$order_by = 'id';
|
||
if (strtolower($order_by_direction) != 'asc' && strtolower($order_by_direction) != 'desc')
|
||
$order_by_direction = 'asc';
|
||
// creates fields for filtering unidentified transfers
|
||
$filter=new Table_Form(url_lang::base()."bank_accounts/show_all", "get", array(
|
||
new Table_Form_Item('text', 'name', 'Account name'),
|
||
new Table_Form_Item('text', 'account_nr', 'Account number'),
|
||
"tr",
|
||
new Table_Form_Item('text', 'bank_nr', 'Bank code'),
|
||
"td", new Table_Form_Item('submit', 'submit', 'Filter')
|
||
)
|
||
);
|
||
$arr_gets = array();
|
||
foreach ($this->input->get() as $key=>$value)
|
||
$arr_gets[] = $key.'='.$value;
|
||
$query_string = '?'.implode('&',$arr_gets);
|
||
// bank accounts
|
||
$total_baccounts = $bank_account_model->count_bank_accounts($filter->values());
|
||
if (($sql_offset = ($page - 1) * $limit_results) > $total_baccounts)
|
||
$sql_offset = 0;
|
||
$ba = $bank_account_model->get_bank_accounts($sql_offset, (int)$limit_results, $order_by, $order_by_direction, $filter->values());
|
||
if ($this->acl_check_view('Accounts_Controller', 'bank_accounts'))
|
||
{
|
||
|
||
$grid = new Grid(url_lang::base().'bank_accounts', null, array(
|
||
'separator' => '<br /><br />',
|
||
'current' => $limit_results, // current selected 'records_per_page' value
|
||
'selector_increace' => 500, // increace
|
||
'selector_min' => 500, // minimum where selector start
|
||
'selector_max_multiplier' => 10,
|
||
'base_url' => Config::item('locale.lang').'/bank_accounts/show_all/'.$limit_results.'/'.$order_by.'/'.$order_by_direction,
|
||
'uri_segment' => 'page', // pass a string as uri_segment to trigger former 'label' functionality
|
||
'total_items' => $total_baccounts, // use db count query here of course
|
||
'items_per_page' => $limit_results, // it may be handy to set defaults for stuff like this in config/pagination.php
|
||
'style' => 'classic',
|
||
'order_by' => $order_by,
|
||
'order_by_direction' => $order_by_direction,
|
||
'limit_results' => $limit_results,
|
||
'filter' => $filter->view,
|
||
'query_string' => $query_string
|
||
));
|
||
// adding bank account
|
||
if ($this->acl_check_new('Accounts_Controller', 'bank_accounts'))
|
||
$grid->add_new_button(url_lang::base().'bank_accounts/add', url_lang::lang('texts.Add new bank account'));
|
||
$grid->order_field('id')->label('ID');
|
||
$grid->order_field('baname')->label(url_lang::lang('texts.Account name'));
|
||
$grid->order_field('account_nr')->label(url_lang::lang('texts.Account number'));
|
||
$grid->order_field('bank_nr')->label(url_lang::lang('texts.Bank code'));
|
||
$grid->field('mname')->label(url_lang::lang('texts.Member name'));
|
||
if ($this->acl_check_view('Accounts_Controller', 'bank_transfers'))
|
||
$grid->action_field('id')->label(url_lang::lang('texts.Transfers'))->url(url_lang::base().'bank_transfers/show_by_bank_account')->action(url_lang::lang('texts.Show'));
|
||
$grid->datasource($ba);
|
||
// get 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', 'baname', 'account_number', 'mname');
|
||
if (!in_array(strtolower($order_by),$allowed_order_type))
|
||
$order_by = 'id';
|
||
if (strtolower($order_by_direction) != 'asc' && strtolower($order_by_direction) != 'desc')
|
||
$order_by_direction = 'asc';
|
||
// creates fields for filtering unidentified transfers
|
||
$filter=new Table_Form(url_lang::base()."bank_accounts/show_all", "get", array(
|
||
new Table_Form_Item('text', 'name', 'Account name'),
|
||
new Table_Form_Item('text', 'account_nr', 'Account number'),
|
||
"tr",
|
||
new Table_Form_Item('text', 'bank_nr', 'Bank code'),
|
||
"td", new Table_Form_Item('submit', 'submit', 'Filter')
|
||
)
|
||
);
|
||
$arr_gets = array();
|
||
foreach ($this->input->get() as $key=>$value)
|
||
$arr_gets[] = $key.'='.$value;
|
||
$query_string = '?'.implode('&',$arr_gets);
|
||
// bank accounts
|
||
$total_baccounts = $bank_account_model->count_bank_accounts($filter->values());
|
||
if (($sql_offset = ($page - 1) * $limit_results) > $total_baccounts)
|
||
$sql_offset = 0;
|
||
$ba = $bank_account_model->get_bank_accounts($sql_offset, (int)$limit_results, $order_by, $order_by_direction, $filter->values());
|
||
|
||
$grid = new Grid(url_lang::base().'bank_accounts', url_lang::lang('texts.Bank accounts'), array(
|
||
'separator' => '<br /><br />',
|
||
'current' => $limit_results, // current selected 'records_per_page' value
|
||
'selector_increace' => 500, // increace
|
||
'selector_min' => 500, // minimum where selector start
|
||
'selector_max_multiplier' => 10,
|
||
'base_url' => Config::item('locale.lang').'/bank_accounts/show_all/'.$limit_results.'/'.$order_by.'/'.$order_by_direction,
|
||
'uri_segment' => 'page', // pass a string as uri_segment to trigger former 'label' functionality
|
||
'total_items' => $total_baccounts, // use db count query here of course
|
||
'items_per_page' => $limit_results, // it may be handy to set defaults for stuff like this in config/pagination.php
|
||
'style' => 'classic',
|
||
'order_by' => $order_by,
|
||
'order_by_direction' => $order_by_direction,
|
||
'limit_results' => $limit_results,
|
||
'filter' => $filter->view,
|
||
'query_string' => $query_string
|
||
));
|
||
// adding bank account
|
||
if ($this->acl_check_new('Accounts_Controller', 'bank_accounts'))
|
||
$grid->add_new_button(url_lang::base().'bank_accounts/add', url_lang::lang('texts.Add new bank account'));
|
||
$grid->order_field('id')->label('ID');
|
||
$grid->order_field('baname')->label(url_lang::lang('texts.Account name'));
|
||
$grid->order_field('account_nr')->label(url_lang::lang('texts.Account number'));
|
||
$grid->order_field('bank_nr')->label(url_lang::lang('texts.Bank code'));
|
||
$grid->field('mname')->label(url_lang::lang('texts.Member name'));
|
||
if ($this->acl_check_view('Accounts_Controller', 'bank_transfers'))
|
||
$grid->action_field('id')->label(url_lang::lang('texts.Transfers'))->url(url_lang::base().'bank_transfers/show_by_bank_account')->action(url_lang::lang('texts.Show'));
|
||
$grid->datasource($ba);
|
||
}
|
||
else
|
||
{
|
||
$grid = '';
|
||
}
|
||
|
||
$view = new View('main');
|
||
$view->title = url_lang::lang('texts.Bank accounts');
|
freenetis/trunk/kohana/application/controllers/scheduler.php | ||
---|---|---|
* @param $type
|
||
* @return unknown_type
|
||
*/
|
||
public function run($type = null)
|
||
public function run()
|
||
{
|
||
if (!isset($type))
|
||
Controller::warning(PARAMETER);
|
||
$ip = server::remote_addr();
|
||
echo $ip;
|
||
if ($ip != '127.0.0.1')
|
||
if (!$this->acl_check_edit('Devices_Controller', 'redirect'))
|
||
die();
|
||
die();
|
||
$member_model = new Member_Model();
|
||
switch($type)
|
||
|
||
// for debugging
|
||
/*
|
||
if (date('w') == '2' && date('H:i') == '13:16')
|
||
{
|
||
case 'update_payment_notice':
|
||
$fee_model = new Fee_Model();
|
||
$fee = $fee_model->get_by_date_type(date('Y-m-d'), 'regular member fee');
|
||
if ($fee->id)
|
||
$current_fee = $fee->fee;
|
||
$member_model->update_payment_notice($current_fee * 2);
|
||
break;
|
||
case 'update_debtors':
|
||
$member_model->update_debtors();
|
||
break;
|
||
case 'update_membership_interrupts':
|
||
$member_model->update_membership_interrupts();
|
||
break;
|
||
echo date('l H:i');
|
||
$member_model->update_payment_notice(-10000000, 0);
|
||
}
|
||
$this->profiler = new Profiler();
|
||
echo $this->profiler->render(true);
|
||
*/
|
||
|
||
// redirection of 'should-pay' members
|
||
// monday nine o'clock and wednesday nine o'clock
|
||
if ((date('w') == '1' && date('H:i') == '09:00') ||
|
||
(date('w') == '3' && date('H:i') == '09:00'))
|
||
{
|
||
/*
|
||
$fee_model = new Fee_Model();
|
||
$fee = $fee_model->get_by_date_type(date('Y-m-d'), 'regular member fee');
|
||
if ($fee->id)
|
||
$current_fee = $fee->fee;
|
||
*/
|
||
$member_model->update_payment_notice(-10000000, 0);
|
||
}
|
||
|
||
// redirection of members with interrupted membership
|
||
if ((date('H:i') == '00:00'))
|
||
{
|
||
$member_model->update_membership_interrupts();
|
||
}
|
||
|
||
}
|
||
}
|
freenetis/trunk/kohana/application/controllers/devices.php | ||
---|---|---|
* Function shows all devices of user.
|
||
* @return unknown_type
|
||
*/
|
||
function show_by_user($user_id = null, $limit_results = 500, $order_by = 'id', $order_by_direction = 'asc', $page_word = null, $page = 1)
|
||
function show_by_user($user_id = null, $limit_results = 500, $order_by = 'inet_aton(ip.ip_address)', $order_by_direction = 'asc', $page_word = null, $page = 1)
|
||
{
|
||
if (!isset($user_id))
|
||
Controller::warning(PARAMETER);
|
||
... | ... | |
$grid->add_new_button(url_lang::base().'devices/add_whole/'.$user->id, url_lang::lang('texts.Add new whole device'));
|
||
if ($this->acl_check_new(get_class($this),'devices',$user->member_id))
|
||
$grid->add_new_button(url_lang::base().'devices/add/'.$user->id, url_lang::lang('texts.Add new device'));
|
||
$grid->order_field('id')->label('ID')->class('center');
|
||
//$grid->order_field('id')->label('ID')->class('center');
|
||
//$grid->order_field('name')->label(url_lang::lang('texts.Name'));
|
||
$grid->order_field('type')->label(url_lang::lang('texts.Type'));
|
||
$grid->order_field('u_name')->label(url_lang::lang('texts.User'));
|
||
$grid->order_field('mac')->label(url_lang::lang('texts.MAC address'));
|
||
$grid->order_field('segment_name')->label(url_lang::lang('texts.Segment'));
|
||
$grid->order_field('ip_address')->label(url_lang::lang('texts.IP address'));
|
||
$grid->order_field('subnet_name')->label(url_lang::lang('texts.Subnet'));
|
||
if ($this->acl_check_view(get_class($this),'devices',$user->member_id))
|
||
$grid->action_field('id')->label(url_lang::lang('texts.Device'))->url(url_lang::base().'devices/show')->action(url_lang::lang('texts.Show'))->class('center');
|
||
if ($this->acl_check_edit(get_class($this),'devices',$user->member_id))
|
||
... | ... | |
asort($arr_towns);
|
||
|
||
$form->dropdown('user_id')->label(url_lang::lang('texts.user'))->options($arr_users)->rules('required')->selected($device->user_id);
|
||
$form->input('name')->label(url_lang::lang('texts.Device name').':')->rules('required|length[1,50]')->value($device->name);
|
||
$form->input('name')->label(url_lang::lang('texts.Device name').':')->rules('length[1,50]')->value($device->name);
|
||
$form->input('trade_name')->label(url_lang::lang('texts.Trade name').':')->rules('length[1,50]')->value($device->trade_name);
|
||
$form->dropdown('type')->label(url_lang::lang('texts.Type'))->options($types)->rules('required')->selected($device->type);
|
||
$form->checkbox('PPPoE_logging_in')->label(url_lang::lang('texts.PPPoE'))->value('1')->checked($device->PPPoE_logging_in);
|
freenetis/trunk/kohana/application/upgrade_sql/upgrade_sql.php | ||
---|---|---|
|
||
// array of sql queries that upgrade database
|
||
$upgrade_sql[get_SVN_rev()] = array(
|
||
"INSERT INTO enum_types (type_id , value , read_only)
|
||
VALUES ('11', 'Horizontal and vertical', '0')",
|
||
"INSERT INTO `aco` (
|
||
`id` ,
|
||
`section_value` ,
|
||
`value` ,
|
||
`order_value` ,
|
||
`name` ,
|
||
`hidden`
|
||
)
|
||
VALUES (
|
||
'38', 'menu', 'bank_accounts', '0', 'Bank accounts', '0'
|
||
);",
|
||
|
||
"INSERT INTO translations (original_term, translated_term, lang)
|
||
VALUES ('Horizontal and vertical', 'Horizontální i vertikální', 'cs')"
|
||
"INSERT INTO `aco_map` (
|
||
`acl_id` ,
|
||
`section_value` ,
|
||
`value`
|
||
)
|
||
VALUES (
|
||
'34', 'menu', 'bank_accounts'
|
||
), (
|
||
'37', 'menu', 'bank_accounts'
|
||
);
|
||
"
|
||
|
||
);
|
||
|
||
?>
|
freenetis/trunk/kohana/application/upgrade_sql/upgrade_sql_542.php | ||
---|---|---|
<?php
|
||
$upgrade_sql[542] = array(
|
||
"INSERT INTO enum_types (type_id , value , read_only)
|
||
VALUES ('11', 'Horizontal and vertical', '0')",
|
||
|
||
"INSERT INTO translations (original_term, translated_term, lang)
|
||
VALUES ('Horizontal and vertical', 'Horizontální i vertikální', 'cs')"
|
||
);
|
||
?>
|
freenetis/trunk/kohana/application/views/menu.php | ||
---|---|---|
<?php if ($this->acl_check_2D('menu', 'unidentified_transfers')) { ?>
|
||
<li><?php echo html::anchor(url_lang::base().'bank_transfers/unidentified_transfers/', url_lang::lang('texts.Unidentified transfers')) ?></li>
|
||
<?php } ?>
|
||
<?php if ($this->acl_check_2D('menu', 'bank_accounts')) { ?>
|
||
<li><?php echo html::anchor(url_lang::base().'bank_accounts/show_all', url_lang::lang('texts.Bank accounts')) ?></li>
|
||
<?php } ?>
|
||
<?php if ($this->acl_check_2D('menu', 'accounts')) { ?>
|
||
<li><?php echo html::anchor(url_lang::base().'bank_accounts/show_all', url_lang::lang('texts.Bank accounts')) ?></li>
|
||
<li><?php echo html::anchor(url_lang::base().'accounts/show_all', url_lang::lang('texts.Double-entry accounts')) ?></li>
|
||
<li><?php echo html::anchor(url_lang::base().'transfers/show_all', url_lang::lang('texts.Day book')) ?></li>
|
||
<li><?php echo html::anchor(url_lang::base().'invoices', url_lang::lang('texts.Invoices')) ?></li>
|
freenetis/trunk/kohana/application/views/grid_template.php | ||
---|---|---|
if ($field->class != '') $class_td = ' class="'.$field->class.'"';
|
||
else $class_td = '';
|
||
|
||
// color difference of inbound and outbound transfer amounts
|
||
if ($field->name == 'trans_type')
|
||
if (trim($item->trans_type) == 0)
|
||
$inbound = true;
|
||
else
|
||
$outbound = true;
|
||
|
||
// action field
|
||
if ($field instanceof Action_Field) :
|
||
$property = $field->name; ?>
|
||
... | ... | |
echo number_format((float)$item->$field, 2, ',', ' ');
|
||
elseif ($field->name == 'amount')
|
||
{
|
||
if ($inbound)
|
||
if ($item->$field > 0)
|
||
echo '<span style="color:green">'.$item->$field.'</span>';
|
||
elseif ($outbound)
|
||
elseif ($item->$field < 0)
|
||
echo '<span style="color:red">'.$item->$field.'</span>';
|
||
else
|
||
echo $item->$field;
|
freenetis/trunk/kohana/application/views/bank_accounts/show_all.php | ||
---|---|---|
<?php echo $baa_grid; ?>
|
||
<br />
|
||
<br />
|
||
<h2><?php echo url_lang::lang('texts.Bank accounts') ?></h2>
|
||
<br />
|
||
<?php echo $grid; ?>
|
Také k dispozici: Unified diff
Opravy mnoha chyb a vychytavek. Obycejny clen muze videt vypis vsech bankovnich prevodu - stejne jako na transparentnim uctu, transparentni ucet na strankach banky je tedy mozne zrusit. Vylepseni vypisu bankovnich i nebankovnich prevodu. Predelan scheduler - pokud bude scheduler aktivovan cronem kazdou minutu, pak automaticky presmeruje vsechny cleny se zapornym kreditem na stranku upozorneni na placeni kazde pondeli a stredu v 9h (Jovakuv priblizny prichod do prace). Jednou denne bude meneno presmerovani prerusenym clenum. Neni mozne podminky a casy v scheduleru resit univerzalne, ceka se na Lubomira Bubna, ktery ma presmerovani rozdelane a dosud nic neposlal.