Projekt

Obecné

Profil

« Předchozí | Další » 

Revize 494

Přidáno uživatelem Jiří Sviták před asi 15 roky(ů)

Narocne predelavky podvojnych uctu po konzultaci s ucetni, hlavni je nyni ucetni osnova, ktera skutecne odpovida uctum v ucetni osnove. Jsou v ni obsazeny i ucty nase vlastni, kreditni ucty z pohledu ucetniho nejsou ucty, ale spise "poducty". Ucet 221100 z pohledu ucetniho je jen jeden a reprezentuje soucet vsech stavu kreditnich poductu. To same plati pro bankovni ucty, poplatky a uroky. Ucetni vidi jeden ucet "Bankovni ucty 221000", ktery opet reprezentuje sumu stavu vsech kreditnich poductu clenu. Dale pridany funkce pro zjisteni podsite ip adresy a pro zjisteni brany na podsiti.

Zobrazit rozdíly:

freenetis/trunk/kohana/application/i18n/cs_CZ/texts.php
'account number' => 'Číslo účtu',
'account transfers' => 'Převody účtu',
'account type' => 'Typ účtu',
'account overview' => 'Přehled účtů',
'accounting system' => 'Účetní osnova',
'activate' => 'Aktivovat',
'add' => 'Přidat',
'add member fee payment by cash' => 'Přidat platbu členského příspěvku hotově',
......
'bad variable symbol format' => 'Špatný formát variabilního symbolu.',
'bad voip number interval format' => 'Špatný formát VoIP čísel',
'balance' => 'Stav',
'balance to year' => 'Zůstatek k roku',
'bank account' => 'Bankovní účet',
'bank account id' => 'ID bankovního účtu',
'bank account name' => 'Název bankovního účtu',
......
'counteraccount name' => 'Název protiúčtu',
'counteraccount number' => 'Číslo protiúčtu',
'credit' => 'Kredit',
'credit accounts' => 'Kreditní účty',
'credit subaccounts' => 'Kreditní podúčty',
'csv file template' => 'Šablona CSV souboru',
'csv file templates' => 'Šablony CSV souborů',
'current application password is' => 'Současné aplikační heslo je',
......
'price vat' => 'Cena s DPH',
'primary user of member cannot be deleted' => 'Primárního uživatele člena nelze smazat.',
'project account' => 'Účet projektu',
'project accounts' => 'Projektové účty',
'project subaccounts' => 'Projektové podúčty',
'project site' => 'Stránky projektu',
'purchasers account' => 'Účet odběratelů',
'qos ceil' => 'Ceil (max-limit) pro QoS',
......
'show all confirmed works' => 'Zobraz všechnny potvrzené práce',
'show all transfers on the account' => 'Ukaž všechny převody tohoto účtu',
'show all unconfirmed works' => 'Zobraz všechnny nepotvrzené práce',
'show his devices' => 'Zobrazit jeho zařízení',
'show his transfers' => 'Zobrazit jeho převody',
'show his works' => 'Zobrazit jeho práce',
'show devices' => 'Zobrazit zařízení',
'show transfers' => 'Zobrazit převody',
'show works' => 'Zobrazit práce',
'show invoice' => 'Zobrazit fakturu',
'show invoice item' => 'Zobrazit položku faktury',
'show transfer' => 'ukaž transakci',
freenetis/trunk/kohana/application/models/subnet.php
}
/**
* Function finds subnet to which given ip address belongs to.
* @param $ip_address
* @return unknown_type
*/
public function get_subnet_of_ip_address($ip_address)
{
return self::$db->query("SELECT *
FROM subnets
WHERE inet_aton(netmask) & inet_aton('$ip_address') = inet_aton(network_address)
")->current();
}
/**
* Function gets items of subnet to export.
* @param $subnet_id
* @return unknown_type
freenetis/trunk/kohana/application/models/account.php
class Account_Model extends ORM
{
// groups of double-entry accounts
public static $credit = 1;
public static $project = 2;
public static $other = 3;
public static $accounting_system = 1;
public static $credit = 2;
public static $project = 3;
//protected $has_one = array();
// protected $has_many = array('transfers');
......
*/
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_general_ci';
// which group will be get
if ($filter_values['group'] == self::$project)
$account_attribute = 'a.account_attribute_id = '.Account_attribute_Model::$project;
else if ($filter_values['group'] == self::$other)
$where = '';
$datetime1 = '';
$datetime2 = '';
foreach ($filter_values as $key => $value)
{
$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::$purchasers
.' OR a.account_attribute_id = '.Account_attribute_Model::$suppliers
.' OR a.account_attribute_id = '.Account_attribute_Model::$bank_fees
.' OR a.account_attribute_id = '.Account_attribute_Model::$bank_interests
.' OR a.account_attribute_id = '.Account_attribute_Model::$member_fees;
if ($key != 'submit' && $key != 'datetime')
{
if ($where == '')
$where = 'WHERE ';
else
$where .= ' AND ';
if ($key == 'name')
$where .= "a.name LIKE '%".$value."%' COLLATE utf8_general_ci";
if ($key == 'group')
{
if ($value == self::$project)
$where .= 'account_attribute_id = '.Account_attribute_Model::$project;
else if ($value == self::$credit)
$where .= 'account_attribute_id = '.Account_attribute_Model::$credit;
else
$where .= 'account_attribute_id <> '.Account_attribute_Model::$project.
' AND account_attribute_id <> '.Account_attribute_Model::$credit;
}
}
if ($key == 'datetime')
{
$datetime1 = " AND t1.datetime LIKE '%".$value."%' COLLATE utf8_general_ci";
$datetime2 = " AND t2.datetime LIKE '%".$value."%' COLLATE utf8_general_ci";
}
}
else
$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,
CONCAT('<a href=\"".url_lang::base()."members/show/', a.member_id, '\">', m.name, '</a>') AS mname,
q3.balance
FROM (SELECT q2.id, q2.member_id, (inbound - outbound) AS balance 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
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 ($account_attribute)
$name
// query
return self::$db->query("
SELECT q2.*, (inbound - outbound) AS balance FROM
(SELECT q1.*, IFNULL(SUM(amount), 0) AS inbound FROM
(SELECT a.id, a.name, a.account_attribute_id,
CONCAT('<a href=\"".url_lang::base()."members/show/', a.member_id, '\">', m.name, '</a>') AS mname,
IFNULL(SUM(amount), 0) AS outbound
FROM accounts a
LEFT JOIN members m ON m.id = a.member_id
LEFT JOIN transfers t1 ON a.id = t1.origin_id $datetime1
$where
GROUP BY a.id
) q1
LEFT JOIN transfers t2 ON q1.id = t2.destination_id $datetime2
GROUP BY q1.id
) q2
ORDER BY $order_by $order_by_direction
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 = 'a.account_attribute_id = '.Account_attribute_Model::$project;
else if ($filter_values['group'] == self::$other)
$where = '';
foreach ($filter_values as $key => $value)
{
$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::$purchasers
.' OR a.account_attribute_id = '.Account_attribute_Model::$suppliers
.' OR a.account_attribute_id = '.Account_attribute_Model::$bank_fees
.' OR a.account_attribute_id = '.Account_attribute_Model::$bank_interests
.' OR a.account_attribute_id = '.Account_attribute_Model::$member_fees;
if ($key != 'submit' && $key != 'datetime')
{
if ($where == '')
$where = 'WHERE ';
else
$where .= ' AND ';
if ($key == 'name')
$where .= "a.name LIKE '%".$value."%' COLLATE utf8_general_ci";
if ($key == 'group')
{
if ($value == self::$project)
$where .= 'a.account_attribute_id = '.Account_attribute_Model::$project;
else if ($value == self::$credit)
$where .= 'a.account_attribute_id = '.Account_attribute_Model::$credit;
else
$where .= 'a.account_attribute_id <> '.Account_attribute_Model::$project.
' AND a.account_attribute_id <> '.Account_attribute_Model::$credit;
}
}
}
return self::$db->query("SELECT COUNT(*) AS total
FROM accounts a
$where"
)->current()->total;
}
/**
* Accounting system requires special query.
* @return unknown_type
*/
public function get_accounting_system($limit_from = 0, $limit_results = 20, $order_by = 'id', $order_by_direction = 'asc', $filter_values = array())
{
$where = '';
$datetime1 = '';
$datetime2 = '';
foreach ($filter_values as $key => $value)
{
if ($key == 'name')
{
$where = " WHERE aa.name LIKE '%".$value."%' COLLATE utf8_general_ci";
}
if ($key == 'datetime')
{
$datetime1 = " AND t1.datetime LIKE '%".$value."%' COLLATE utf8_general_ci";
$datetime2 = " AND t2.datetime LIKE '%".$value."%' COLLATE utf8_general_ci";
}
}
else
$account_attribute = 'a.account_attribute_id = '.Account_attribute_Model::$credit;
// query itself
$count = self::$db->query('SELECT COUNT(*) AS total
FROM accounts a
WHERE ('.$account_attribute.')
'.$name
);
return $count->current()->total;
}
// query
return self::$db->query("
SELECT aa.id, aa.name, SUM(partial_balance) AS balance
FROM account_attributes aa
JOIN
(SELECT q2.account_attribute_id, (inbound - outbound) AS partial_balance FROM
(SELECT q1.*, IFNULL(SUM(amount), 0) AS inbound FROM
(SELECT q0.*, IFNULL(SUM(amount), 0) AS outbound FROM
(SELECT a.id, a.account_attribute_id
FROM accounts a
WHERE a.member_id = 1
) q0
LEFT JOIN transfers t1 ON q0.id = t1.origin_id $datetime1
GROUP BY q0.id
) q1
LEFT JOIN transfers t2 ON q1.id = t2.destination_id $datetime2
GROUP BY q1.id
) q2
) q3 ON aa.id = q3.account_attribute_id
$where
GROUP BY q3.account_attribute_id
ORDER BY $order_by $order_by_direction
LIMIT $limit_from, $limit_results"
);
}
public function get_accounting_system_count($filter_values = array())
{
$where = '';
foreach ($filter_values as $key => $value)
{
if ($key == 'name')
$where = "AND aa.name LIKE '%".$value."%' COLLATE utf8_general_ci";
}
return self::$db->query("SELECT COUNT(*) AS total
FROM
(SELECT a.account_attribute_id
FROM account_attributes aa
JOIN accounts a ON aa.id = a.account_attribute_id
WHERE a.member_id = 1 $where
GROUP BY a.account_attribute_id
) q1
")->current()->total;
}
/**
* Function gets some double-entry accounts. Used in dropdown to select destination account.
* @return unknown_type
freenetis/trunk/kohana/application/models/ip_address.php
}
/**
* Function gets ip address ORM object of gateway which belongs to given network address.
* @param $network_address
* @return unknown_type
*/
public function get_gateway_of_subnet($network_address)
{
$arr_ip = explode('.', $network_address);
$arr_ip[3]++;
$gateway_ip = implode('.',$arr_ip);
return $this->where('ip_address', $gateway_ip)->find();
}
/**
* Function gets all ip address of interfaces of devices of users of given member.
* @param $member_id
* @return unknown_type
freenetis/trunk/kohana/application/controllers/redirect.php
$device_engineers = $device_engineer_model->get_device_engineers($ip_address->iface->device_id);
}
// trying to find subnet of visitor's ip address
$ip = ip2long(server::remote_addr());
$subnet_model = new Subnet_Model();
$subnets = $subnet_model
->select("id","name","network_address as net_str",
"inet_aton(network_address) as net",
"32-log2((~inet_aton(netmask) & 0xffffffff) + 1) as mask")
->find_all();
$arr_subnets = array();
foreach($subnets as $subnet)
{
$mask = 0xffffffff << (32-$subnet->mask) & 0xffffffff;
if (($ip & $mask) == $subnet->net)
$arr_subnets[] = $subnet;
}
$subnet = $subnet_model->get_subnet_of_ip_address(server::remote_addr());
// remote ip address belongs to some subnet
if (count($arr_subnets) > 0)
if (count($subnet) > 0)
{
$subnet = $arr_subnets[0];
//$subnet = $arr_subnets[0];
$subnet_name = $subnet->name;
// finding subnet's gateway
$arr_ip = explode('.', $subnet->net_str);
$arr_ip[3]++;
$gateway_ip = implode('.',$arr_ip);
$ip_address_model = new Ip_address_Model();
$ap = $ip_address_model->where('ip_address',$gateway_ip)->find();
$ap = $ip_address_model->get_gateway_of_subnet($subnet->network_address);
// admin of access point - only if ap exists
if ($ap->id != 0)
{
......
$device_engineers = $device_engineer_model->get_device_engineers($ip_address->iface->device_id);
}
// trying to find subnet of visitor's ip address
$ip = ip2long(server::remote_addr());
$subnet_model = new Subnet_Model();
$subnets = $subnet_model
->select("id","name","network_address as net_str",
"inet_aton(network_address) as net",
"32-log2((~inet_aton(netmask) & 0xffffffff) + 1) as mask")
->find_all();
$arr_subnets = array();
foreach($subnets as $subnet)
{
$mask = 0xffffffff << (32-$subnet->mask) & 0xffffffff;
if (($ip & $mask) == $subnet->net)
$arr_subnets[] = $subnet;
}
$subnet = $subnet_model->get_subnet_of_ip_address(server::remote_addr());
// remote ip address belongs to some subnet
if (count($arr_subnets) > 0)
if (count($subnet) > 0)
{
$subnet = $arr_subnets[0];
//$subnet = $arr_subnets[0];
$subnet_name = $subnet->name;
// finding subnet's gateway
$arr_ip = explode('.', $subnet->net_str);
$arr_ip[3]++;
$gateway_ip = implode('.',$arr_ip);
$ip_address_model = new Ip_address_Model();
$ap = $ip_address_model->where('ip_address',$gateway_ip)->find();
$ap = $ip_address_model->get_gateway_of_subnet($subnet->network_address);
// admin of access point - only if ap exists
if ($ap->id != 0)
{
freenetis/trunk/kohana/application/controllers/accounts.php
Controller::error(ACCESS);
$this->session->del('ssMember_id');
$this->session->del('ssAccount_id');
$arr_groups[Account_Model::$credit] = url_lang::lang('texts.Credit accounts');
$arr_groups[Account_Model::$project] = url_lang::lang('texts.Project accounts');
$arr_groups[Account_Model::$other] = url_lang::lang('texts.Other accounts');
$arr_groups[Account_Model::$accounting_system] = url_lang::lang('texts.Accounting system');
$arr_groups[Account_Model::$credit] = url_lang::lang('texts.Credit subaccounts');
$arr_groups[Account_Model::$project] = url_lang::lang('texts.Project subaccounts');
$filter=new Table_Form(url_lang::base()."accounts/show_all", "get", array(
new Table_Form_Item('text', 'name', 'Account name'),
new Table_Form_Item('select', 'group', 'Group', $arr_groups),
"tr",
new Table_Form_Item('select', 'group', 'Group', $arr_groups),
"tr",
new Table_Form_Item('submit', 'submit', 'Filter')
new Table_Form_Item('text', 'datetime', 'Balance to year'),
"td", new Table_Form_Item('submit', 'submit', 'Filter'),
)
);
$filter_values = $filter->values();
......
$order_by = 'id';
if (strtolower($order_by_direction) != 'asc' && strtolower($order_by_direction) != 'desc')
$order_by_direction = 'asc';
$account_model = new Account_Model();
$total_accounts = $account_model->get_accounts_count($filter_values);
if (($sql_offset = ($page - 1) * $limit_results) > $total_accounts)
$sql_offset = 0;
$accounts = $account_model->get_accounts($sql_offset, (int)$limit_results, $order_by, $order_by_direction, $filter_values);
if (isset($filter_values['group']))
$load_account_system = $filter_values['group'] == Account_Model::$accounting_system;
else
$load_account_system = true;
if ($load_account_system)
{
$total_accounts = $account_model->get_accounting_system_count($filter_values);
if (($sql_offset = ($page - 1) * $limit_results) > $total_accounts)
$sql_offset = 0;
$accounts = $account_model->get_accounting_system($sql_offset, (int)$limit_results, $order_by, $order_by_direction, $filter_values);
}
else
{
$total_accounts = $account_model->get_accounts_count($filter_values);
if (($sql_offset = ($page - 1) * $limit_results) > $total_accounts)
$sql_offset = 0;
$accounts = $account_model->get_accounts($sql_offset, (int)$limit_results, $order_by, $order_by_direction, $filter_values);
}
// creates parameters of filter in url
$arr_gets = array();
foreach ($this->input->get() as $key=>$value)
......
'query_string' => $query_string,
'filter' => $filter->view
));
// adding project account
if ($filter_values['group'] == Account_Model::$project && $this->acl_check_new('Accounts_Controller', 'accounts'))
$grid->add_new_button(url_lang::base().'accounts/add_project', url_lang::lang('texts.Add new project account'));
$grid->order_field('id')->label('ID');
$grid->order_field('aname')->label(url_lang::lang('texts.Account name'));
$grid->order_field('comment')->label(url_lang::lang('texts.Comment'));
$grid->order_field('balance')->label(url_lang::lang('texts.Balance'));
if ($this->acl_check_view('Accounts_Controller', 'transfers'))
$grid->action_field('id')->label(url_lang::lang('texts.Transfers'))->url(url_lang::base().'transfers/show_by_account')->action(url_lang::lang('texts.Show'));
if ($this->acl_check_edit('Accounts_Controller', 'accounts'))
$grid->action_field('id')->label(url_lang::lang('texts.Account'))->url(url_lang::base().'accounts/edit')->action(url_lang::lang('texts.Edit'));
$grid->field('mname')->label(url_lang::lang('texts.Member name'));
if ($load_account_system)
{
$grid->order_field('id')->label(url_lang::lang('texts.Account'));
$grid->order_field('name')->label(url_lang::lang('texts.Account name'));
$grid->order_field('balance')->label(url_lang::lang('texts.Balance'));
}
else
{
$grid->order_field('id')->label('ID');
$grid->order_field('name')->label(url_lang::lang('texts.Account name'));
$grid->order_field('account_attribute_id')->label(url_lang::lang('texts.Type'));
$grid->order_field('balance')->label(url_lang::lang('texts.Balance'));
if ($this->acl_check_view('Accounts_Controller', 'transfers'))
$grid->action_field('id')->label(url_lang::lang('texts.Transfers'))->url(url_lang::base().'transfers/show_by_account')->action(url_lang::lang('texts.Show'));
if ($this->acl_check_edit('Accounts_Controller', 'accounts'))
$grid->action_field('id')->label(url_lang::lang('texts.Account'))->url(url_lang::base().'accounts/edit')->action(url_lang::lang('texts.Edit'));
$grid->field('mname')->label(url_lang::lang('texts.Member name'));
}
$grid->datasource($accounts);
$view = new View('main');
freenetis/trunk/kohana/application/libraries/MY_Controller.php
$this->db->query('ROLLBACK;');
$this->profiler = new Profiler();
echo $this->profiler->render(true);
$this->error(UPGRADE, $query);
$message = "upgrade_sql_$i.php: <br />$query";
$this->error(UPGRADE, $message);
}
$config->set_db_schema_version($i);
$this->db->query('COMMIT;');
......
$this->db->query('ROLLBACK;');
$this->profiler = new Profiler();
echo $this->profiler->render(true);
$this->error(UPGRADE, $query);
$message = "upgrade_sql_$i.php: <br />$query";
$this->error(UPGRADE, $message);
}
$config->set_db_schema_version($this->current_svn_db_schema_version);
$this->db->query('COMMIT;');
freenetis/trunk/kohana/application/views/members_show.php
if ($member_data->member_id != 1)
{
if ($this->acl_check_view('Accounts_Controller', 'transfers', $member_data->member_id))
$links[] = html::anchor(url_lang::base().'transfers/show_by_account/'.$account->id, url_lang::lang('texts.Show his transfers'));
$links[] = html::anchor(url_lang::base().'transfers/show_by_account/'.$account->id, url_lang::lang('texts.Show transfers'));
if (!$former)
{
if ($this->acl_check_edit('Accounts_Controller', 'transfers', $member_data->member_id))
......
if(!$former && $this->acl_check_edit('Users_Controller','users',$member_data->member_id))
$links[] = html::anchor(url_lang::base().'users/edit/'.$member_data->id, url_lang::lang('texts.Edit'));
if ($this->acl_check_view('Devices_Controller', 'devices', $member_data->member_id))
$links[] = html::anchor(url_lang::base().'devices/show_by_user/'.$member_data->id,url_lang::lang('texts.Show his devices'));
$links[] = html::anchor(url_lang::base().'devices/show_by_user/'.$member_data->id,url_lang::lang('texts.Show devices'));
if ($member_data->id != 1 && $this->acl_check_view('Users_Controller', 'work', $member_data->member_id))
$links[] = html::anchor(url_lang::base().'works/show_by_user/'.$member_data->id,url_lang::lang('texts.Show his works'));
$links[] = html::anchor(url_lang::base().'works/show_by_user/'.$member_data->id,url_lang::lang('texts.Show works'));
if (!$former)
{
if ($this->acl_check_edit('Users_Controller', 'password', $member_data->id))

Také k dispozici: Unified diff