Revize 321
Přidáno uživatelem Jiří Sviták před více než 15 roky(ů)
freenetis/trunk/kohana/application/models/device.php | ||
---|---|---|
{
|
||
if($key!='submit')
|
||
{
|
||
if($where!='WHERE ') $where .= ' AND ';
|
||
if($where!='WHERE ')
|
||
$where .= ' AND ';
|
||
$where .= ($key!='device_type' AND $key!='member_id') ? $this->arr_sql[$key].' LIKE \'%'.$value.'%\' COLLATE utf8_general_ci' : $this->arr_sql[$key].' = '.$value;
|
||
}
|
||
}
|
||
|
||
$devices = self::$db->query('SELECT d.id,IFNULL(f.translated_term,e.value) as type,d.name, CONCAT(users.name, \' \', users.surname) AS u_name,
|
||
IFNULL(ifaces.iface_count,0) AS iface_count,
|
||
IFNULL(ports.port_count,0) AS port_count FROM devices d
|
||
JOIN users ON d.user_id = users.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 (SELECT COUNT(*) as iface_count,device_id FROM ifaces GROUP BY ifaces.device_id) ifaces ON d.id=ifaces.device_id
|
||
LEFT JOIN (SELECT COUNT(*) as port_count,device_id FROM ports GROUP BY ports.device_id) ports ON d.id=ports.device_id
|
||
'.$where);
|
||
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
|
||
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 ip_addresses ip ON i.id = ip.iface_id
|
||
'.$where.'
|
||
ORDER BY '.$order_by.' '.$order_by_direction.'
|
||
LIMIT '.$limit_from.','.$limit_results
|
||
);
|
||
return count($devices);
|
||
} // end of count_all_devices
|
||
|
||
|
||
/**
|
||
* Gets all devices from database. Database query returns member's device parameters (id, name, type),
|
||
* owner of device (user name and surname), MAC addresses of interfaces, names of segments and ip addresses.
|
||
* @param $limit_from
|
||
* @param $limit_results
|
||
* @param $order_by
|
||
* @param $order_by_direction
|
||
* @param $member_id
|
||
* @return unknown_type
|
||
*/
|
||
public function get_all_devices($limit_from = 0, $limit_results = 50, $order_by = 'devices.id', $order_by_direction = 'ASC', $user_id = null, $filters = array())
|
||
{
|
||
if (in_array($order_by, $this->arr_sql))
|
freenetis/trunk/kohana/application/models/account.php | ||
---|---|---|
*/
|
||
public function get_accounts($limit_from = 0, $limit_results = 20, $order_by = 'id', $order_by_direction = 'asc', $filter_values = array())
|
||
{
|
||
// default group
|
||
if (count($filter_values) == 0)
|
||
$filter_values['group'] = self::$credit;
|
||
// name filter
|
||
$name = '';
|
||
if (isset($filter_values['name']))
|
||
$name = 'AND a.name LIKE \'%'.$filter_values['name'].'%\' COLLATE utf8_czech_ci';
|
||
// which group will be get
|
||
if ($filter_values['group'] == self::$project)
|
||
{
|
||
$account_attribute = Account_attribute_Model::$project;
|
||
}
|
||
$account_attribute = 'a.account_attribute_id = '.Account_attribute_Model::$project;
|
||
else if ($filter_values['group'] == self::$other)
|
||
{
|
||
$account_attribute = Account_attribute_Model::$cash
|
||
$account_attribute = 'a.account_attribute_id = '.Account_attribute_Model::$cash
|
||
.' OR a.account_attribute_id = '.Account_attribute_Model::$bank
|
||
.' OR a.account_attribute_id = '.Account_attribute_Model::$operating
|
||
.' OR a.account_attribute_id = '.Account_attribute_Model::$infrastructure
|
||
... | ... | |
.' OR a.account_attribute_id = '.Account_attribute_Model::$member_fees;
|
||
}
|
||
else
|
||
{
|
||
$account_attribute = Account_attribute_Model::$credit;
|
||
}
|
||
$account_attribute = 'a.account_attribute_id = '.Account_attribute_Model::$credit;
|
||
// query itself
|
||
return self::$db->query('SELECT a.id, a.name AS aname, a.comment, m.name AS mname, a.member_id,
|
||
q3.credit FROM
|
||
(SELECT id, member_id, (inbound - outbound) AS credit FROM
|
||
q3.balance FROM
|
||
(SELECT id, member_id, (inbound - outbound) AS balance FROM
|
||
(SELECT q1.id, q1.member_id, IFNULL(SUM(amount), 0) AS inbound, outbound FROM
|
||
(SELECT a.id, member_id, IFNULL(SUM(amount), 0) AS outbound
|
||
FROM accounts a
|
||
LEFT JOIN transfers t ON a.id = t.origin_id
|
||
WHERE a.account_attribute_id = '.$account_attribute.'
|
||
WHERE ('.$account_attribute.')
|
||
GROUP BY a.id) AS q1
|
||
LEFT JOIN transfers ON q1.id = transfers.destination_id GROUP BY q1.id) AS q2
|
||
) AS q3
|
||
LEFT JOIN members m ON q3.member_id = m.id
|
||
LEFT JOIN accounts a ON q3.id = a.id
|
||
WHERE a.account_attribute_id = '.$account_attribute.'
|
||
WHERE ('.$account_attribute.')
|
||
'.$name.'
|
||
ORDER BY '.$order_by.' '.$order_by_direction.'
|
||
LIMIT '.$limit_from.','.$limit_results);
|
||
LIMIT '.$limit_from.','.$limit_results
|
||
);
|
||
}
|
||
|
||
/**
|
||
... | ... | |
*/
|
||
public function get_accounts_count($filter_values = array())
|
||
{
|
||
// default group
|
||
if (count($filter_values) == 0)
|
||
$filter_values['group'] = self::$credit;
|
||
// name filter
|
||
$name = '';
|
||
if (isset($filter_values['name']))
|
||
$name = 'AND a.name LIKE \'%'.$filter_values['name'].'%\' COLLATE utf8_czech_ci';
|
||
// which group will be get
|
||
if ($filter_values['group'] == self::$project)
|
||
{
|
||
$account_attribute = Account_attribute_Model::$project;
|
||
}
|
||
$account_attribute = 'a.account_attribute_id = '.Account_attribute_Model::$project;
|
||
else if ($filter_values['group'] == self::$other)
|
||
{
|
||
$account_attribute = Account_attribute_Model::$cash
|
||
$account_attribute = 'a.account_attribute_id = '.Account_attribute_Model::$cash
|
||
.' OR a.account_attribute_id = '.Account_attribute_Model::$bank
|
||
.' OR a.account_attribute_id = '.Account_attribute_Model::$operating
|
||
.' OR a.account_attribute_id = '.Account_attribute_Model::$infrastructure
|
||
... | ... | |
.' OR a.account_attribute_id = '.Account_attribute_Model::$member_fees;
|
||
}
|
||
else
|
||
{
|
||
$account_attribute = Account_attribute_Model::$credit;
|
||
}
|
||
$account_attribute = 'a.account_attribute_id = '.Account_attribute_Model::$credit;
|
||
// query itself
|
||
$count = self::$db->query('SELECT COUNT(*) AS total
|
||
FROM accounts a
|
||
WHERE a.account_attribute_id = '.$account_attribute
|
||
);
|
||
WHERE ('.$account_attribute.')
|
||
'.$name
|
||
);
|
||
return $count->current()->total;
|
||
}
|
||
|
freenetis/trunk/kohana/application/models/bank_transfer.php | ||
---|---|---|
* @param $order_by_direction
|
||
* @return unknown_type
|
||
*/
|
||
public function get_bank_transfers($account_id = null, $limit_from = 0, $limit_results = 20, $order_by = 't.id', $order_by_direction = 'DESC')
|
||
public function get_bank_transfers($ba_id = null, $limit_from = 0, $limit_results = 20, $order_by = 'id', $order_by_direction = 'DESC')
|
||
{
|
||
echo 'kukuc';
|
||
if ($order_by == 'amount')
|
||
$order_by = 'IF( t.destination_id = '.$account_id.', amount, amount*-1 )';
|
||
$order_by = 'IF(bt.destination_id = '.$ba_id.', amount, amount*-1 )';
|
||
return self::$db->query("SELECT
|
||
t.id, t.datetime, t.text, t.amount,
|
||
bt.variable_symbol,
|
||
a.name, CONCAT(ba.account_nr, '/', ba.bank_nr) AS account_number,
|
||
IF (t.destination_id = ".$account_id.", FALSE, TRUE) AS trans_type
|
||
FROM transfers t
|
||
LEFT JOIN accounts a ON a.id = IF (t.origin_id = ".$account_id.", t.destination_id, t.origin_id)
|
||
LEFT JOIN bank_accounts ba ON a.id = ba.account_id
|
||
LEFT JOIN bank_transfers bt ON t.id = bt.transfer_id
|
||
WHERE (t.origin_id = ".$account_id." OR t.destination_id = ".$account_id.")
|
||
AND a.account_attribute_id = ".Account_attribute_Model::$bank."
|
||
bt.id,
|
||
IF (bt.destination_id = ".$ba_id.", FALSE, TRUE) AS trans_type,
|
||
CONCAT(ba.account_nr, '/', ba.bank_nr) AS account_number,
|
||
ba.name,
|
||
t.datetime, t.text, t.amount,
|
||
bt.variable_symbol
|
||
FROM bank_transfers bt
|
||
LEFT JOIN bank_accounts ba ON ba.id = IF (bt.origin_id = ".$ba_id.", bt.destination_id, bt.origin_id)
|
||
LEFT JOIN transfers t ON t.id = bt.transfer_id
|
||
WHERE (bt.origin_id = ".$ba_id." OR bt.destination_id = ".$ba_id.")
|
||
ORDER BY ".$order_by." ".$order_by_direction."
|
||
LIMIT ".$limit_from." , ".$limit_results
|
||
);
|
||
);
|
||
}
|
||
|
||
/**
|
||
* @author Jiri Svitak
|
||
* It counts all bank transfers of given account.
|
||
* It counts all bank transfers of given bank account.
|
||
* @param $account_id
|
||
* @return unknown_type
|
||
*/
|
||
public function count_bank_transfers($account_id)
|
||
public function count_bank_transfers($ba_id)
|
||
{
|
||
return self::$db->query("SELECT COUNT(*) AS total
|
||
FROM transfers t
|
||
JOIN bank_transfers bt ON bt.transfer_id = t.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)
|
||
WHERE bt.origin_id = ".$ba_id." OR bt.destination_id = ".$ba_id
|
||
)->current()->total;
|
||
}
|
||
|
||
... | ... | |
* and no other transfer has set previous_transfer_id to this transfer.
|
||
* @return unknown_type
|
||
*/
|
||
public function get_unidentified_transfers($limit_from = 0, $limit_results = 20, $order_by = 'id', $order_by_direction = 'asc')
|
||
public function get_unidentified_transfers($limit_from = 0, $limit_results = 500, $order_by = 'id', $order_by_direction = 'asc')
|
||
{
|
||
if ($order_by == 'amount')
|
||
$order_by = 'IF( t.destination_id = '.$account_id.', amount, amount*-1 )';
|
||
return self::$db->query("SELECT t.id, t.datetime, t.amount, t.text,
|
||
bt.variable_symbol AS varsym,
|
||
bt.variable_symbol,
|
||
CONCAT(ba.account_nr, '/', ba.bank_nr) AS account_number
|
||
FROM transfers t
|
||
JOIN bank_transfers bt ON bt.transfer_id = t.id
|
freenetis/trunk/kohana/application/models/bank_account.php | ||
---|---|---|
*/
|
||
public function get_assoc_bank_accounts()
|
||
{
|
||
return self::$db->query('SELECT ba.id, ba.name, a.comment,
|
||
return self::$db->query('SELECT
|
||
ba.id, ba.name AS baname,
|
||
CONCAT(ba.account_nr, \'/\', ba.bank_nr) AS account_number,
|
||
q3.credit FROM
|
||
(SELECT id, member_id, (inbound - outbound) AS credit FROM
|
||
(SELECT q1.id, q1.member_id, IFNULL(sum(amount), 0) AS inbound, outbound FROM
|
||
(SELECT a.id, a.member_id, IFNULL(sum(amount), 0) AS outbound
|
||
FROM accounts a
|
||
LEFT JOIN transfers t ON a.id = t.origin_id
|
||
GROUP BY a.id) AS q1
|
||
LEFT JOIN transfers t ON q1.id = t.destination_id
|
||
GROUP BY q1.id) AS q2
|
||
) AS q3
|
||
LEFT JOIN accounts a ON q3.id = a.id
|
||
LEFT JOIN bank_accounts ba ON a.name = ba.account_nr
|
||
WHERE a.member_id = 1 AND a.account_attribute_id = '.Account_attribute_Model::$bank
|
||
m.name AS mname
|
||
FROM bank_accounts ba
|
||
LEFT JOIN members m ON m.id = ba.member_id
|
||
WHERE ba.member_id = 1'
|
||
);
|
||
}
|
||
|
||
... | ... | |
* It gets all bank accounts except bank accounts of association.
|
||
* @return unknown_type
|
||
*/
|
||
public function get_bank_accounts()
|
||
public function get_bank_accounts($limit_from = 0, $limit_results = 20, $order_by = 'id', $order_by_direction = 'asc')
|
||
{
|
||
return self::$db->query('SELECT q3.id, a.name, a.comment,
|
||
return self::$db->query('SELECT
|
||
ba.id, ba.name AS baname,
|
||
CONCAT(ba.account_nr, \'/\', ba.bank_nr) AS account_number,
|
||
q3.credit FROM
|
||
(SELECT id, member_id, (inbound - outbound) AS credit FROM
|
||
(SELECT q1.id, q1.member_id, IFNULL(sum(amount), 0) AS inbound, outbound FROM
|
||
(SELECT a.id, a.member_id, IFNULL(sum(amount), 0) AS outbound
|
||
FROM accounts a
|
||
LEFT JOIN transfers t ON a.id = t.origin_id
|
||
GROUP BY a.id) AS q1
|
||
LEFT JOIN transfers t ON q1.id = t.destination_id
|
||
GROUP BY q1.id) AS q2
|
||
) AS q3
|
||
LEFT JOIN accounts a ON q3.id = a.id
|
||
LEFT JOIN bank_accounts ba ON a.name = ba.account_nr
|
||
WHERE a.member_id <> 1 AND a.account_attribute_id = '.Account_attribute_Model::$bank
|
||
m.name AS mname
|
||
FROM bank_accounts ba
|
||
LEFT JOIN members m ON m.id = ba.member_id
|
||
WHERE ba.member_id <> 1
|
||
ORDER BY '.$order_by.' '.$order_by_direction.'
|
||
LIMIT '.$limit_from.','.$limit_results
|
||
);
|
||
}
|
||
|
||
/**
|
||
* It counts bank accounts except bank accounts of association.
|
||
* @return unknown_type
|
||
*/
|
||
public function count_bank_accounts()
|
||
{
|
||
return self::$db->query('SELECT COUNT(*) AS total
|
||
FROM bank_accounts ba
|
||
WHERE ba.member_id <> 1'
|
||
)->current()->total;
|
||
}
|
||
|
||
/**
|
||
* @author Jiri Svitak
|
||
* It gets bank account number of given account.
|
||
* @param $account_id
|
freenetis/trunk/kohana/application/controllers/transfers.php | ||
---|---|---|
* @param $order_by_direction
|
||
* @return unknown_type
|
||
*/
|
||
function show_all($limit_results = 500, $order_by = 'id', $order_by_direction = 'desc', $page_word = null, $page = 1)
|
||
function show_all($limit_results = 500, $order_by = 'datetime', $order_by_direction = 'desc', $page_word = null, $page = 1)
|
||
{
|
||
// to do - correct access control
|
||
/*
|
||
... | ... | |
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');
|
||
if (!in_array(strtolower($order_by),$allowed_order_type))
|
||
$order_by = 'id';
|
||
$allowed_order_type = array('id', 'origin', 'destination', 'datetime', 'text', 'amount');
|
||
if (!in_array(strtolower($order_by), $allowed_order_type))
|
||
$order_by = 'datetime';
|
||
if (strtolower($order_by_direction) != 'asc' && strtolower($order_by_direction) != 'desc')
|
||
$order_by_direction = 'asc';
|
||
$order_by_direction = 'desc';
|
||
|
||
$model_transfer = new Transfer_Model();
|
||
$total_transfers = $model_transfer->count_all_transfers();
|
||
... | ... | |
* @param $account_id
|
||
* @return unknown_type
|
||
*/
|
||
function show_by_member($member_id = NULL, $limit_results = 50, $order_by = 'id', $order_by_direction = 'asc', $page_word = null, $page = 1)
|
||
function show_by_member($member_id = NULL, $limit_results = 500, $order_by = 'datetime', $order_by_direction = 'desc', $page_word = null, $page = 1)
|
||
{
|
||
if (isset($member_id))
|
||
{
|
||
... | ... | |
if (is_numeric($this->input->get('record_per_page')))
|
||
$limit_results = (int) $this->input->get('record_per_page');
|
||
// to do - correct allowed order type array
|
||
$allowed_order_type = array('id', 'amount', 'name', 'datetime', 'trans_type', 'text');
|
||
$allowed_order_type = array('id', 'trans_type', 'datetime', 'name', 'amount', 'text');
|
||
if (!in_array(strtolower($order_by),$allowed_order_type))
|
||
$order_by = 'id';
|
||
$order_by = 'datetime';
|
||
if (strtolower($order_by_direction) != 'asc' && strtolower($order_by_direction) != 'desc')
|
||
$order_by_direction = 'asc';
|
||
$order_by_direction = 'desc';
|
||
|
||
$member = new Member_Model($member_id);
|
||
$account_model = new Account_Model();
|
||
... | ... | |
$sql_offset = 0;
|
||
$transfers = $transfer_model->get_transfers($account->id, $sql_offset, (int)$limit_results, $order_by, $order_by_direction);
|
||
|
||
$grid = new Grid(url_lang::base().'transfers', url_lang::lang('texts.Transfers of member').' '.$member->name, array(
|
||
$headline = url_lang::lang('texts.Transfers of member').' '.$member->name;
|
||
|
||
$grid = new Grid(url_lang::base().'transfers', $headline, array(
|
||
//'separator' => '<br />-----------',
|
||
//'use_paginator' => false,
|
||
//'use_selector' => false,
|
||
'current' => $limit_results, // current selected 'records_per_page' value
|
||
'selector_increace' => 50, // increace
|
||
'selector_min' => 50, // minimum where selector start
|
||
'selector_increace' => 500, // increace
|
||
'selector_min' => 500, // minimum where selector start
|
||
'selector_max_multiplier' => 10,
|
||
'base_url' => Config::item('locale.lang').'/transfers/show_by_member/'.$member_id.'/'.$limit_results.'/'.$order_by.'/'.$order_by_direction ,
|
||
'uri_segment' => 'page', // pass a string as uri_segment to trigger former 'label' functionality
|
||
... | ... | |
'order_by' => $order_by,
|
||
'order_by_direction' => $order_by_direction,
|
||
'limit_results' => $limit_results,
|
||
'variables' => $member_id.'/',
|
||
'variables' => $member_id.'/',
|
||
'url_array_ofset' => 1
|
||
));//,'acc_grid_template');
|
||
|
||
... | ... | |
$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('amount')->label(url_lang::lang('texts.Amount'));
|
||
$grid->field('text')->label(url_lang::lang('texts.Text'));
|
||
$grid->order_field('text')->label(url_lang::lang('texts.Text'));
|
||
$grid->datasource($transfers);
|
||
|
||
$view = new View('template');
|
||
... | ... | |
$view->content = $grid;
|
||
$view->footer = new View('base/footer');
|
||
$view->header->menu = Controller::render_menu();
|
||
$view->header->title = url_lang::lang('texts.Transfers of member').' '.$member->name;
|
||
$view->header->title = $headline;
|
||
$view->render(TRUE);
|
||
}
|
||
else
|
||
... | ... | |
* @param $account_id
|
||
* @return unknown_type
|
||
*/
|
||
function show_by_account($account_id = NULL, $limit_results = 50, $order_by = 'id', $order_by_direction = 'asc', $page_word = null, $page = 1)
|
||
function show_by_account($account_id = NULL, $limit_results = 500, $order_by = 'id', $order_by_direction = 'asc', $page_word = null, $page = 1)
|
||
{
|
||
if (isset($account_id))
|
||
{
|
||
... | ... | |
if (is_numeric($this->input->get('record_per_page')))
|
||
$limit_results = (int) $this->input->get('record_per_page');
|
||
// to do - correct allowed order type array
|
||
$allowed_order_type = array('id', 'aname', 'amount', 'datetime', 'trans_type');
|
||
$allowed_order_type = array('id', 'trans_type', 'name', 'datetime', 'amount', 'text');
|
||
if (!in_array(strtolower($order_by),$allowed_order_type))
|
||
$order_by = 'id';
|
||
$order_by = 'datetime';
|
||
if (strtolower($order_by_direction) != 'asc' && strtolower($order_by_direction) != 'desc')
|
||
$order_by_direction = 'asc';
|
||
$order_by_direction = 'desc';
|
||
|
||
$transfer_model = new Transfer_Model();
|
||
$total_transfers = $transfer_model->get_transfers_count($account_id);
|
||
... | ... | |
//'use_paginator' => false,
|
||
//'use_selector' => false,
|
||
'current' => $limit_results, // current selected 'records_per_page' value
|
||
'selector_increace' => 50, // increace
|
||
'selector_min' => 50, // minimum where selector start
|
||
'selector_increace' => 500, // increace
|
||
'selector_min' => 500, // minimum where selector start
|
||
'selector_max_multiplier' => 10,
|
||
'base_url' => Config::item('locale.lang').'/transfers/show_by_account/'.$account_id.'/'.$limit_results.'/'.$order_by.'/'.$order_by_direction ,
|
||
'uri_segment' => 'page', // pass a string as uri_segment to trigger former 'label' functionality
|
||
... | ... | |
$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'));
|
||
$grid->field('text')->label(url_lang::lang('texts.Text'));
|
||
$grid->order_field('text')->label(url_lang::lang('texts.Text'));
|
||
$grid->datasource($transfers);
|
||
|
||
$view = new View('template');
|
freenetis/trunk/kohana/application/controllers/bank_transfers.php | ||
---|---|---|
* @param $account_id
|
||
* @return unknown_type
|
||
*/
|
||
function show_by_bank_account($account_id = NULL, $limit_results = 50, $order_by = 'id', $order_by_direction = 'ASC', $page_word = null, $page = 1)
|
||
function show_by_bank_account($bank_account_id = NULL, $limit_results = 500, $order_by = 'datetime', $order_by_direction = 'desc', $page_word = null, $page = 1)
|
||
{
|
||
if (isset($account_id))
|
||
if (isset($bank_account_id))
|
||
{
|
||
// to do - access control
|
||
//if(!$this->acl_check_view('Accounts_Controller', 'bank_transfers', $account_id))
|
||
//if(!$this->acl_check_view('Accounts_Controller', 'bank_transfers', $bank_account_id))
|
||
// Controller::Error(1);
|
||
|
||
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');
|
||
if (!in_array(strtolower($order_by),$allowed_order_type))
|
||
$order_by = 'id';
|
||
if (!in_array(strtolower($order_by), $allowed_order_type))
|
||
$order_by = 'datetime';
|
||
if (strtolower($order_by_direction) != 'asc' && strtolower($order_by_direction) != 'desc')
|
||
$order_by_direction = 'asc';
|
||
$order_by_direction = 'desc';
|
||
|
||
$transfer_model = new Transfer_Model();
|
||
$total_transfers = $transfer_model->count_bank_transfers($account_id);
|
||
$transfer_model = new Bank_transfer_Model();
|
||
$total_transfers = $transfer_model->count_bank_transfers($bank_account_id);
|
||
if (($sql_offset = ($page - 1) * $limit_results) > $total_transfers)
|
||
$sql_offset = 0;
|
||
$transfers = $transfer_model->get_bank_transfers($account_id, $sql_offset, (int)$limit_results, $order_by, $order_by_direction);
|
||
$transfers = $transfer_model->get_bank_transfers($bank_account_id, $sql_offset, (int)$limit_results, $order_by, $order_by_direction);
|
||
|
||
$account_model = new Bank_account_Model();
|
||
$bank_account_number = $account_model->get_bank_account_number($account_id);
|
||
$bank_account_number = $account_model->get_bank_account_number($bank_account_id);
|
||
$headline = url_lang::lang('texts.Transfers of bank account').' '.$bank_account_number;
|
||
|
||
$grid = new Grid(url_lang::base().'transfers', url_lang::lang('texts.Transfers of bank account').' '.$bank_account_number, array(
|
||
$grid = new Grid(url_lang::base().'transfers', $headline, array(
|
||
//'separator' => '<br />-----------',
|
||
//'use_paginator' => false,
|
||
//'use_selector' => false,
|
||
'current' => $limit_results, // current selected 'records_per_page' value
|
||
'selector_increace' => 50, // increace
|
||
'selector_min' => 50, // minimum where selector start
|
||
'selector_increace' => 500, // increace
|
||
'selector_min' => 500, // minimum where selector start
|
||
'selector_max_multiplier' => 10,
|
||
'base_url' => Config::item('locale.lang').'/transfers/show_by_member/'.$account_id.'/'.$limit_results.'/'.$order_by.'/'.$order_by_direction ,
|
||
'base_url' => Config::item('locale.lang').'/transfers/show_by_member/'.$bank_account_id.'/'.$limit_results.'/'.$order_by.'/'.$order_by_direction ,
|
||
'uri_segment' => 'page', // pass a string as uri_segment to trigger former 'label' functionality
|
||
'total_items' => $total_transfers, // 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
|
||
... | ... | |
'order_by' => $order_by,
|
||
'order_by_direction' => $order_by_direction,
|
||
'limit_results' => $limit_results,
|
||
'variables' => $account_id.'/',
|
||
'variables' => $bank_account_id.'/',
|
||
'url_array_ofset' => 1
|
||
));//,'acc_grid_template');
|
||
|
||
//if($this->acl_check_new(get_class($this),'transfers',$account_id))
|
||
//if($this->acl_check_new(get_class($this),'transfers',$bank_account_id))
|
||
// $grid->add_new_button(url_lang::base().'accounts/new_transfer/'.$account->id, url_lang::lang('texts.New transfer'));
|
||
$grid->add_new_button(url_lang::base().'bank_accounts/show_all', url_lang::lang('texts.Back to bank accounts'));
|
||
$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( 'name')->label(url_lang::lang('texts.Counteraccount'));
|
||
$grid->order_field('datetime')->label(url_lang::lang('texts.Date and time'));s
|
||
$grid->order_field('name')->label(url_lang::lang('texts.Counteraccount'));
|
||
$grid->order_field('account_number')->label(url_lang::lang('texts.Account number'));
|
||
$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('variable_symbol')->label(url_lang::lang('texts.VS'));
|
||
$grid->order_field('amount')->label(url_lang::lang('texts.Amount'));
|
||
$grid->order_field('variable_symbol')->label(url_lang::lang('texts.VS'));
|
||
$grid->field('text')->label(url_lang::lang('texts.Text'));
|
||
|
||
$grid->datasource($transfers);
|
||
|
||
$view = new View('template');
|
||
... | ... | |
$view->content = $grid;
|
||
$view->footer = new View('base/footer');
|
||
$view->header->menu = Controller::render_menu();
|
||
$view->header->title = url_lang::lang('texts.Transfers of bank account').' '.$bank_account_number;
|
||
$view->header->title = $headline;
|
||
$view->render(TRUE);
|
||
}
|
||
else
|
||
... | ... | |
* @param $order_by_direction
|
||
* @return unknown_type
|
||
*/
|
||
function unidentified_transfers($limit_results = 50, $order_by = 'id', $order_by_direction = 'asc', $page_word = null, $page = 1)
|
||
function unidentified_transfers($limit_results = 500, $order_by = 'id', $order_by_direction = 'asc', $page_word = null, $page = 1)
|
||
{
|
||
// to do - access rights
|
||
//if (!$this->acl_check_view(get_class($this), 'unidentified_transfers'))
|
||
... | ... | |
$limit_results = (int) $this->input->get('record_per_page');
|
||
|
||
// parameters control
|
||
$allowed_order_type = array('mt.id', 'destination_id', 'timestamp', 'amount', 'variable_symbol', 'constant_symbol', 'specific_symbol', 'name', 'date_time', 'fee_transfer_id');
|
||
$allowed_order_type = array('id', 'datetime', 'amount');
|
||
if (!in_array(strtolower($order_by),$allowed_order_type))
|
||
$order_by = 'id';
|
||
if (strtolower($order_by_direction) != 'asc' && strtolower($order_by_direction) != 'desc')
|
||
... | ... | |
//'use_paginator' => false,
|
||
//'use_selector' => false,
|
||
'current' => $limit_results, // current selected 'records_per_page' value
|
||
'selector_increace' => 50, // increace
|
||
'selector_min' => 50, // minimum where selector start
|
||
'selector_increace' => 500, // increace
|
||
'selector_min' => 500, // minimum where selector start
|
||
'selector_max_multiplier' => 10,
|
||
'base_url' => Config::item('locale.lang').'/transfers/unidentified_transfers/'.$limit_results.'/'.$order_by.'/'.$order_by_direction ,
|
||
'uri_segment' => 'page', // pass a string as uri_segment to trigger former 'label' functionality
|
||
... | ... | |
//$grid->add_new_button(url_lang::base().'accounts/new_transfer/'.$member_id, url_lang::lang('texts.New transfer'));
|
||
$grid->order_field('id')->label('ID');
|
||
$grid->order_field('datetime')->label(url_lang::lang('texts.Date and time'));
|
||
$grid->order_field('account_number')->label(url_lang::lang('texts.Account number'));
|
||
$grid->order_field('text')->label(url_lang::lang('texts.Text'));
|
||
$grid->order_field('variable_symbol')->label(url_lang::lang('texts.Variable symbol'));
|
||
$grid->order_field('amount')->label(url_lang::lang('texts.Amount'));
|
||
$grid->order_field('varsym')->label(url_lang::lang('texts.Variable symbol'));
|
||
$grid->order_field('account_number')->label(url_lang::lang('texts.Account number'));
|
||
$grid->field('text')->label(url_lang::lang('texts.Text'));
|
||
|
||
$grid->action_field('id') ->label(url_lang::lang('texts.Payment'))->url(url_lang::base().'bank_transfers/assign_transfer')->action(url_lang::lang('texts.Assign'));
|
||
$grid->datasource($transfers);
|
||
|
freenetis/trunk/kohana/application/controllers/bank_accounts.php | ||
---|---|---|
* @param $order_by_direction
|
||
* @return unknown_type
|
||
*/
|
||
function show_all($limit_results = 50, $order_by = 'id', $order_by_direction = 'ASC')
|
||
function show_all($limit_results = 500, $order_by = 'id', $order_by_direction = 'ASC', $page_word = null, $page = 1)
|
||
{
|
||
// it gets only bank accounts of association
|
||
$bank_account_model = new Bank_account_Model();
|
||
... | ... | |
//if ($this->acl_check_new(get_class($this), 'accounts', $member_id))
|
||
// $acc_grid->add_new_button(url_lang::base().'accounts/add_bank_account/'.$member_id, url_lang::lang('texts.Add new bank account'));
|
||
$baa_grid->field('id')->label(url_lang::lang('texts.ID'));
|
||
$baa_grid->field('name')->label(url_lang::lang('texts.Name'));
|
||
$baa_grid->field('comment')->label(url_lang::lang('texts.Comment'));
|
||
$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('credit')->label(url_lang::lang('texts.Balance'));
|
||
$baa_grid->field('mname')->label(url_lang::lang('texts.Member name'));
|
||
$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'));
|
||
$baa_grid->action_field('id')->label(url_lang::lang('texts.Import'))->url(url_lang::base().'accounts/upload_bank_file')->action(url_lang::lang('texts.Import'));
|
||
$baa_grid->datasource($baa);
|
||
|
||
// it gets all bank accounts except association's
|
||
$ba = $bank_account_model->get_bank_accounts();
|
||
$total_ba = count($ba);
|
||
// 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';
|
||
|
||
$total_baccounts = $bank_account_model->count_bank_accounts();
|
||
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);
|
||
|
||
$grid = new Grid(url_lang::base().'bank_accounts', null, array(
|
||
'separator' => '<br /><br />',
|
||
'current' => $limit_results, // current selected 'records_per_page' value
|
||
'selector_increace' => 50, // increace
|
||
'selector_min' => 50, // minimum where selector start
|
||
'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_ba, // use db count query here of course
|
||
'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,
|
||
... | ... | |
'limit_results' => $limit_results,
|
||
));
|
||
$grid->order_field('id')->label('ID');
|
||
$grid->order_field('name')->label(url_lang::lang('texts.Account name'));
|
||
$grid->order_field('comment')->label(url_lang::lang('texts.Comment'));
|
||
$grid->order_field('baname')->label(url_lang::lang('texts.Account name'));
|
||
$grid->order_field('account_number')->label(url_lang::lang('texts.Account number'));
|
||
$grid->order_field('credit')->label(url_lang::lang('texts.Balance'));
|
||
$grid->order_field('mname')->label(url_lang::lang('texts.Member name'));
|
||
$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);
|
||
|
freenetis/trunk/kohana/application/controllers/accounts.php | ||
---|---|---|
|
||
/**
|
||
* @author Jiri Svitak
|
||
* It shows credit accounts of members.
|
||
* It shows all double-entry accounts. They are shown by selected group in filter.
|
||
* @param $limit_results
|
||
* @param $order_by
|
||
* @param $order_by_direction
|
||
... | ... | |
if (is_numeric($this->input->get('record_per_page')))
|
||
$limit_results = (int) $this->input->get('record_per_page');
|
||
// to do - correct allowed order type array
|
||
$allowed_order_type = array('id', 'origin_id', 'destination_id', 'timestamp', 'amount', 'constant_symbol', 'specific_symbol', 'name', 'date_time', 'fee_transfer_id', 'trans_type', 'text');
|
||
$allowed_order_type = array('id', 'aname', 'comment', 'mname', 'balance');
|
||
if (!in_array(strtolower($order_by),$allowed_order_type))
|
||
$order_by = 'id';
|
||
if (strtolower($order_by_direction) != 'asc' && strtolower($order_by_direction) != 'desc')
|
||
... | ... | |
$filter_values['group'] = Account_Model::$credit;
|
||
$headline = $arr_groups[$filter_values['group']];
|
||
|
||
$grid = new Grid(url_lang::base().'accounts',
|
||
null, array(
|
||
'separator' => '<br /><br />',
|
||
$grid = new Grid(url_lang::base().'accounts', null, array(
|
||
//'separator' => '<br /><br />',
|
||
'current' => $limit_results, // current selected 'records_per_page' value
|
||
'selector_increace' => 50, // increace
|
||
'selector_min' => 50, // minimum where selector start
|
||
'selector_increace' => 500, // increace
|
||
'selector_min' => 500, // minimum where selector start
|
||
'selector_max_multiplier' => 10,
|
||
'base_url' => Config::item('locale.lang').'/accounts/credit_accounts/'.$limit_results.'/'.$order_by.'/'.$order_by_direction ,
|
||
'uri_segment' => 'page', // pass a string as uri_segment to trigger former 'label' functionality
|
||
... | ... | |
$grid->order_field('aname')->label(url_lang::lang('texts.Account name'));
|
||
$grid->order_field('comment')->label(url_lang::lang('texts.Comment'));
|
||
$grid->order_field('mname')->label(url_lang::lang('texts.Member name'));
|
||
$grid->order_field('credit')->label(url_lang::lang('texts.Credit'));
|
||
$grid->order_field('balance')->label(url_lang::lang('texts.Balance'));
|
||
$grid->action_field('id')->label(url_lang::lang('texts.Transfers'))->url(url_lang::base().'transfers/show_by_account')->action(url_lang::lang('texts.Show'));
|
||
$grid->action_field('member_id')->label(url_lang::lang('texts.Member'))->url(url_lang::base().'members/show')->action(url_lang::lang('texts.Show'));
|
||
$grid->datasource($accounts);
|
||
... | ... | |
{
|
||
Controller::warning(1);;
|
||
}
|
||
|
||
} // end of detail function
|
||
|
||
|
||
... | ... | |
{
|
||
Controller::warning(1);;
|
||
}
|
||
|
||
} // end of delete function
|
||
|
||
function new_transfer($account_id = NULL)
|
||
... | ... | |
foreach ($users as $user) {
|
||
$arr_users[$user->member_id] = $user->surname.' '.$user->name.' - '.$user->login;
|
||
}
|
||
// asort($arr_users);
|
||
// asort($arr_users);
|
||
|
||
$form = new Forge(url_lang::base().'accounts/add/'.$account_id, '', 'POST', array('id' => 'article_form'));
|
||
|
||
... | ... | |
|
||
$view->content = new View('form');
|
||
$view->content->form = $form->html();
|
||
$view->content->link_back = html::anchor(url_lang::base().'/accounts/main_accounts/master',
|
||
url_lang::lang('texts.Back to main bank account'));
|
||
$view->content->link_back = html::anchor(url_lang::base().'accounts/show_all',
|
||
url_lang::lang('texts.Back to bank accounts'));
|
||
$view->content->headline = $title;
|
||
|
||
$view->footer = new View('base/footer');
|
freenetis/trunk/kohana/application/upgrade_sql/upgrade_sql_311.php | ||
---|---|---|
<?php
|
||
|
||
$upgrade_sql[311] = array(
|
||
"DELETE FROM `account_attributes` WHERE `account_attributes`.`id` = 221001 LIMIT 1",
|
||
"ALTER TABLE `users` CHANGE `type` `type` TINYINT NOT NULL"
|
||
);
|
||
|
||
?>
|
freenetis/trunk/kohana/application/upgrade_sql/upgrade_sql.php | ||
---|---|---|
return $svnid;
|
||
}
|
||
|
||
|
||
$upgrade_sql[get_SVN_rev()] = array(
|
||
"DELETE FROM `account_attributes` WHERE `account_attributes`.`id` = 221001 LIMIT 1",
|
||
"ALTER TABLE `users` CHANGE `type` `type` TINYINT NOT NULL"
|
||
$upgrade_sql[get_SVN_rev()] = array("
|
||
CREATE TABLE `freenetis`.`accounts_bank_accounts` (
|
||
`account_id` INT NOT NULL ,
|
||
`bank_account_id` INT NOT NULL ,
|
||
PRIMARY KEY ( `account_id` , `bank_account_id` )
|
||
) ENGINE = InnoDB;
|
||
"
|
||
);
|
||
|
||
?>
|
Také k dispozici: Unified diff
Pridana vazebni tabulka accounts_bank_accounts. Predelany bankovni ucty a prevody.