Revize 2458
Přidáno uživatelem Ondřej Fibich před více než 9 roky(ů)
freenetis/trunk/application/controllers/json.php | ||
---|---|---|
|
||
$id = $this->input->get('id');
|
||
|
||
$accounts = ORM::factory('account')->get_some_doubleentry_account_names(
|
||
$origin_account_id, $id
|
||
);
|
||
$account_model = new Account_Model;
|
||
$accounts = $account_model->select_some_list($origin_account_id, $id);
|
||
|
||
$arr_accounts = array();
|
||
foreach ($accounts as $account)
|
||
{ // convert the object into array (used for HTML select list)
|
||
$name = $account->name . ' ' . $account->id . ' (' . $account->addr . ')';
|
||
$arr_accounts[$name] = $account->id;
|
||
}
|
||
|
||
echo json_encode($arr_accounts);
|
||
echo json_encode(array_flip($accounts));
|
||
}
|
||
|
||
/**
|
freenetis/trunk/application/controllers/transfers.php | ||
---|---|---|
|
||
// destination account, instead of origin one
|
||
$dst_account_model = new Account_Model();
|
||
$dst_accounts = $dst_account_model->get_some_doubleentry_account_names($origin_account_id);
|
||
|
||
foreach ($dst_accounts as $dst_account)
|
||
{ // convert the object into array (used for HTML select list)
|
||
$arr_dst_accounts[$dst_account->id] = $dst_account->name . ' '
|
||
. $dst_account->id . ' (' . $dst_account->addr . ')';
|
||
}
|
||
$arr_dst_accounts = $dst_account_model->select_some_list($origin_account_id);
|
||
asort($arr_dst_accounts, SORT_LOCALE_STRING);
|
||
// default destination account
|
||
$operating = ORM::factory('account')->where(
|
||
'account_attribute_id', Account_attribute_Model::OPERATING
|
||
)->find();
|
||
// array with only one origin account
|
||
$arr_orig_accounts[$origin_account->id] = $origin_account->name . ' ' . $origin_account->id;
|
||
$arr_orig_accounts[$origin_account->id] = $origin_account->name . ' ('
|
||
. $origin_account->id . ', '
|
||
. $origin_account->account_attribute_id . ', '
|
||
. $origin_account->member_id . ')';
|
||
// account attributes for types of accounts
|
||
$aa_model = new Account_attribute_Model();
|
||
$account_attributes = $aa_model->get_account_attributes();
|
||
... | ... | |
$form->group('Origin account');
|
||
|
||
$form->dropdown('oname')
|
||
->label('Origin account (account name, account ID)')
|
||
->label('Origin account (name, ID, type, member ID)')
|
||
->options($arr_orig_accounts)
|
||
->rules('required')
|
||
->style('width:600px');
|
||
... | ... | |
->style('width:600px');
|
||
|
||
$form->dropdown('aname')
|
||
->label('Destination account (account name, account ID)')
|
||
->label('Destination account (name, ID, type, member ID)')
|
||
->options($arr_dst_accounts)
|
||
->rules('required')
|
||
->selected($operating->id)
|
||
... | ... | |
|
||
$account_model = new Account_Model();
|
||
|
||
$accounts = $account_model->get_some_doubleentry_account_names();
|
||
$origin_accounts = $accounts;
|
||
$dst_accounts = $accounts;
|
||
|
||
foreach ($dst_accounts as $dst_account)
|
||
{
|
||
$arr_dst_accounts[$dst_account->id] = $dst_account->name . ' '
|
||
. $dst_account->id . ' (' . $dst_account->addr . ')';
|
||
}
|
||
$arr_dst_accounts = $account_model->select_some_list();
|
||
asort($arr_dst_accounts);
|
||
|
||
// array origin accounts for dropdown
|
||
$arr_orig_accounts = $arr_dst_accounts;
|
||
|
||
// default destination account
|
||
$operating = ORM::factory('account')->where(
|
||
'account_attribute_id', Account_attribute_Model::OPERATING
|
||
)->find();
|
||
// account attributes for types of accounts
|
||
$aa_model = new Account_attribute_Model();
|
||
$account_attributes = $aa_model->get_account_attributes();
|
||
foreach ($account_attributes as $account_attribute)
|
||
{
|
||
$arr_attributes[$account_attribute->id] = $dst_account->name . ' ' . $dst_account->id;
|
||
}
|
||
|
||
// form
|
||
$form = new Forge('transfers/add');
|
||
... | ... | |
$form->group('Origin account');
|
||
|
||
$form->dropdown('oname')
|
||
->label(__('Origin account (account name, account ID)') . ':')
|
||
->label('Origin account (name, ID, type, member ID)')
|
||
->options($arr_orig_accounts)
|
||
->rules('required');
|
||
->rules('required')
|
||
->style('width:600px');
|
||
// destination account
|
||
$form->group('Destination account');
|
||
|
||
$form->dropdown('aname')
|
||
->label(__('Destination account (account name, account ID)') . ':')
|
||
->label('Destination account (name, ID, type, member ID)')
|
||
->options($arr_dst_accounts)
|
||
->rules('required')
|
||
->selected($operating->id);
|
||
->selected($operating->id)
|
||
->style('width:600px');
|
||
|
||
// other information
|
||
$form->group('Transfer');
|
||
... | ... | |
Controller::error(RECORD);
|
||
}
|
||
|
||
if (isset($origin_account))
|
||
{ // transfer from specific account?
|
||
// save for callback function valid_amount_to_send
|
||
$this->origin = $origin_account;
|
||
$origin_acc = new Account_Model($origin_account);
|
||
|
||
if ($origin_acc->id == 0)
|
||
{
|
||
Controller::error(RECORD);
|
||
}
|
||
|
||
if (!$this->acl_check_new('Accounts_Controller', 'transfers', $origin_acc->member_id))
|
||
{ // does the user have rights for this?
|
||
Controller::error(ACCESS);
|
||
}
|
||
|
||
// yes = create object of all accounts except the origin one
|
||
$dst_account_model = new Account_Model();
|
||
$dst_accounts = $dst_account_model->get_some_doubleentry_account_names($origin_account);
|
||
}
|
||
else
|
||
{ // transfer from any (arbitrary) account
|
||
if (!$this->acl_check_new('Accounts_Controller', 'transfers'))
|
||
{ // Does the user have the rights for this?
|
||
Controller::error(ACCESS);
|
||
}
|
||
|
||
// yes = create object of all accounts
|
||
$origin_acc = new Account_Model();
|
||
$dst_accounts = $origin_accounts = $origin_acc->get_some_doubleentry_account_names();
|
||
}
|
||
$arr_orig_accounts[$origin_acc->id] =
|
||
"$origin_acc->name - " . __('Account ID') . " $origin_acc->name - "
|
||
. __('Member ID') . " $origin_acc->member_id";
|
||
// transfer from specific account?
|
||
// save for callback function valid_amount_to_send
|
||
$this->origin = $origin_account;
|
||
$origin_acc = new Account_Model($origin_account);
|
||
|
||
if (!$origin_acc->id)
|
||
{
|
||
Controller::error(RECORD);
|
||
}
|
||
|
||
if (!$this->acl_check_new('Accounts_Controller', 'transfers', $origin_acc->member_id))
|
||
{ // does the user have rights for this?
|
||
Controller::error(ACCESS);
|
||
}
|
||
|
||
$arr_orig_accounts[$origin_acc->id] = $origin_acc->name . ' - '
|
||
. __('Account ID') . ' ' . $origin_acc->id . ' - '
|
||
. __('Member ID') . ' ' . $origin_acc->member_id;
|
||
|
||
// form
|
||
$form = new Forge('transfers/add_voip/' . $origin_account);
|
freenetis/trunk/application/i18n/cs_CZ/texts.php | ||
---|---|---|
'deselect all' => 'Zrušit výběr',
|
||
'destination' => 'Destinace',
|
||
'destination account' => 'Cílový účet',
|
||
'destination account (account name, account id)' => 'Cílový účet (název účtu, ID účtu)',
|
||
'destination account (name, id, type, member id)' => 'Cílový účet (název, ID, typ, ID člena)',
|
||
'destination bank account' => 'Cílový bankovní účet',
|
||
'destination credit account' => 'Cílový kreditní účet',
|
||
'destination language' => 'Cílový jazyk',
|
||
... | ... | |
'organization identifier' => 'IČ',
|
||
'organization_identifier' => 'IČ',
|
||
'origin account' => 'Zdrojový účet',
|
||
'origin account (account name, account id)' => 'Zdrojový účet (název účtu, ID účtu)',
|
||
'origin account (name, id, type, member id)' => 'Zdrojový účet (název, ID, typ, ID člena)',
|
||
'origin bank account' => 'Zdrojový bankovní účet',
|
||
'original term' => 'Původní výraz',
|
||
'originating call' => 'Odchozí volání',
|
freenetis/trunk/application/models/account.php | ||
---|---|---|
public function get_some_doubleentry_account_names($origin = null, $account_attribute_id = null)
|
||
{
|
||
// conditions
|
||
$cond_origin = "";
|
||
$where = "";
|
||
$where = $cond_origin = '';
|
||
// make origin condition
|
||
if ($origin !== null)
|
||
{
|
||
... | ... | |
. " AND a.account_attribute_id IN ("
|
||
. implode(', ', array_map('intval', $allowed_types)) . ")";
|
||
}
|
||
// make account confition
|
||
// make account attribute condition
|
||
if ($account_attribute_id)
|
||
{
|
||
$where = 'WHERE a.account_attribute_id=' . intval($account_attribute_id);
|
||
... | ... | |
// query
|
||
return $this->db->query("
|
||
SELECT a.id, a.name, a.member_id, a.account_attribute_id,
|
||
IF(t.quarter IS NULL, concat(t.town, ' ', p.street_number),
|
||
concat(t.town, '-', t.quarter, ' ', p.street_number)) AS addr
|
||
m.name as member_name
|
||
FROM accounts a
|
||
JOIN members m ON
|
||
a.member_id=m.id
|
||
$cond_origin
|
||
JOIN address_points p ON m.address_point_id=p.id
|
||
JOIN towns t ON t.id=p.town_id $where
|
||
JOIN members m ON a.member_id=m.id $cond_origin
|
||
$where
|
||
ORDER BY a.name
|
||
");
|
||
}
|
||
|
||
/**
|
||
* Select some double entry accounts for select. If origin is supplied than
|
||
* account with origin ID is not in list. If account attribute ID is
|
||
* supplied than only account with given attribute ID are listed.
|
||
*
|
||
* @author Ondřej Fibich <fibich@freenetis.org>
|
||
* @param integer $origin optional origin account ID to be ignored
|
||
* @param type $account_attribute_id optional account attribute ID for filter
|
||
* @return array associative array with account ID as key and text
|
||
* reprezentation of account as value (name, ID, attribute ID, owner
|
||
* member ID)
|
||
*/
|
||
public function select_some_list($origin = NULL, $account_attribute_id = NULL)
|
||
{
|
||
$accounts = $this->get_some_doubleentry_account_names($origin,
|
||
$account_attribute_id);
|
||
$arr_accounts = array();
|
||
foreach ($accounts as $a)
|
||
{
|
||
$name = $a->name . ' (' . $a->id . ', ' . $a->account_attribute_id . ')';
|
||
if ($a->account_attribute_id == Account_attribute_Model::CREDIT)
|
||
{
|
||
$name .= ' - ' . $a->member_name . ' (' . $a->member_id . ')';
|
||
}
|
||
$arr_accounts[$a->id] = $a->name . ' (' . $a->id . ', '
|
||
. $a->account_attribute_id . ', ' . $a->member_id . ')';
|
||
}
|
||
return $arr_accounts;
|
||
}
|
||
|
||
/**
|
||
* It gets balance of account.
|
||
* It subtracts all outbound transfers from all incoming transfers.
|
Také k dispozici: Unified diff
Upravy: closes #977: Seznamy uctu - odstranit adresu, pridat ID vlastnika