Projekt

Obecné

Profil

« Předchozí | Další » 

Revize 337

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

Pridany editace podvojnych uctu a prevodu. Upravena moznost posilani penez. Opravy chyb.

Zobrazit rozdíly:

freenetis/trunk/kohana/application/i18n/cs_CZ/texts.php
'add new project account' => 'Přidat nový projektový účet',
'add new segment' => 'Přidat nový segment',
'add new subnet' => 'Přidat novu podsíť',
'add new transfer' => 'Přidat nový převod',
'add new translation' => 'Přidat nový překlad',
'add new user' => 'Přidat nového uživatele',
'add new vlan interface' => 'Přidat nové VLAN rozhraní',
......
'back to the user' => 'Zpět na uživatele',
'back to this account' => 'Zpět na tento účet',
'back to this user' => 'Zpět na tohoto uživatele',
'back to transfers of member' => 'Zpět na převody člena',
'back to transfers of account' => 'Zpět na převody na účtu',
'back to unidentified transfers' => 'Zpět na neidentifikované platby',
'back to vlan interface parameters' => 'Zpět na parametry VLAN rozhraní',
'back to vlan interfaces list' => 'Zpět na seznam VLAN rozhraní',
......
'edit vlan interface' => 'Úprava VLAN rozhraní',
'edit vlan' => 'Úprava VLANu',
'edit' => 'Upravit',
'editing of member' => 'Úprava člena',
'editing of account' => 'Úprava účtu',
'editing of member' => 'Úprava člena',
'editing of transfer' => 'Úprava převodu',
'editing of user' => 'Úprava uživatele',
'email' => 'E-mail',
'end membership' => 'Ukončit členství',
......
'error - cant update account' => 'Chyba - nelze upravit účet.',
'error - cant update aditional contacts' => 'Chyba - nelze upravit další kontakty.',
'error - cant update member' => 'Chyba - nelze upravit člena.',
'error - cant update transfer' => 'Chyba - nelze upravit převod.',
'error - cant update user' => 'Chyba - nelze upravit uživatele.',
'error - cant update work' => 'Chyba - nelze upravit práci.',
'error - it is not possible to remove admin' => 'Chyba - nelze odebrat správce zařízení.',
......
'transfer fee' => 'Poplatek za převod',
'transfer fee have to be a number' => 'Poplatek za převod musí být číslo',
'transfer has been successfully added' => 'Převod byl úspěšně přidán.',
'transfer has been successfully updated' => 'Převod byl úspěšně upraven.',
'transfer information' => 'Informace o převodu',
'transfers' => 'Převody',
'transfers of bank account' => 'Převody na bankovním účtu',
freenetis/trunk/kohana/application/models/member.php
return self::$db->query('
SELECT m.id, m.registration, m.name, m.street, m.street_number, m.town, u.phone
FROM members m
LEFT JOIN users u ON m.id = u.member_id
JOIN users u ON m.id = u.member_id AND u.type = '.User_Model::$member.'
'.$where.'
ORDER BY '.$order_by.' '.$order_by_direction.'
LIMIT '.$limit_from.','.$limit_results
......
}
if ($key == 'phone')
{
// joins table users to get phone number from user assigned to this member
$phone = ' JOIN users u ON m.id = u.member_id';
$where .= 'u.phone = \''.trim($value).'\'';
}
else
......
}
return self::$db->query('SELECT COUNT(*) AS total
FROM members m
LEFT JOIN users u ON m.id = u.member_id
JOIN users u ON m.id = u.member_id AND u.type = '.User_Model::$member.'
'.$where)->current()->total;
}
freenetis/trunk/kohana/application/controllers/transfers.php
$order_by = 'datetime';
if (strtolower($order_by_direction) != 'asc' && strtolower($order_by_direction) != 'desc')
$order_by_direction = 'desc';
$model_transfer = new Transfer_Model();
$total_transfers = $model_transfer->count_all_transfers();
if (($sql_offset = ($page - 1) * $limit_results) > $total_transfers)
$sql_offset = 0;
$alltransfers = $model_transfer->get_all_transfers($sql_offset, (int)$limit_results, $order_by, $order_by_direction);
$headline = url_lang::lang('texts.Day book');
$grid = new Grid(url_lang::base().'transfers', null, array(
//'separator' => '',
'use_paginator' => true,
......
$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->action_field('id')->label(url_lang::lang('texts.Transfer'))->url(url_lang::base().'transfers/edit')->action(url_lang::lang('texts.Edit'));
$grid->datasource($alltransfers);
$view = new View('template');
$view->header = new View('base/header');
$view->content = new View('transfers/show_all');
......
// to do - access control
if(!$this->acl_check_view('Accounts_Controller','transfers',$member_id))
Controller::Error(1);
$this->session->set('ssMember_id',$member_id);
$this->session->del('ssAccount_id');
// gets grid settings
if (is_numeric($this->input->get('record_per_page')))
$limit_results = (int) $this->input->get('record_per_page');
......
$order_by = 'datetime';
if (strtolower($order_by_direction) != 'asc' && strtolower($order_by_direction) != 'desc')
$order_by_direction = 'desc';
$member = new Member_Model($member_id);
$account_model = new Account_Model();
$account = $account_model->find_by_member_id($member_id);
......
if (($sql_offset = ($page - 1) * $limit_results) > $total_transfers)
$sql_offset = 0;
$transfers = $transfer_model->get_transfers($account->id, $sql_offset, (int)$limit_results, $order_by, $order_by_direction);
$headline = url_lang::lang('texts.Transfers of member').' '.$member->name;
$grid = new Grid(url_lang::base().'transfers', $headline, array(
//'separator' => '<br />-----------',
//'use_paginator' => false,
......
// $grid->add_new_button(url_lang::base().'accounts/new_transfer/'.$account->id, url_lang::lang('texts.New transfer'));
// to do - access rights
$grid->add_new_button(url_lang::base().'members/show/'.$member_id, url_lang::lang('texts.Back to the member'));
// to do - has to be solved by session, add function has to know where to return
//$grid->add_new_button(url_lang::base().'transfers/add/'.$account->id, url_lang::lang('texts.Send money to other account'));
$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.Arrival'),url_lang::lang('texts.Outbound')));
$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->order_field('text')->label(url_lang::lang('texts.Text'));
$grid->action_field('id')->label(url_lang::lang('texts.Transfer'))->url(url_lang::base().'transfers/edit')->action(url_lang::lang('texts.Edit'));
$grid->datasource($transfers);
$view = new View('template');
$view->header = new View('base/header');
$view->content = $grid;
......
*/
function show_by_account($account_id = NULL, $limit_results = 500, $order_by = 'id', $order_by_direction = 'asc', $page_word = null, $page = 1)
{
$this->session->del('ssMember_id');
$this->session->set('ssAccount_id', $account_id);
if (isset($account_id))
{
// to do - access control
if(!$this->acl_check_view('Accounts_Controller', 'transfers', $account_id))
Controller::Error(1);
// gets grid settings
if (is_numeric($this->input->get('record_per_page')))
$limit_results = (int) $this->input->get('record_per_page');
......
$order_by = 'datetime';
if (strtolower($order_by_direction) != 'asc' && strtolower($order_by_direction) != 'desc')
$order_by_direction = 'desc';
$transfer_model = new Transfer_Model();
$total_transfers = $transfer_model->get_transfers_count($account_id);
if (($sql_offset = ($page - 1) * $limit_results) > $total_transfers)
$sql_offset = 0;
$transfers = $transfer_model->get_transfers($account_id, $sql_offset, (int)$limit_results, $order_by, $order_by_direction);
$account_model = new Account_Model();
$account = $account_model->get_account($account_id);
$headline = url_lang::lang('texts.Transfers of double-entry account');
$grid = new Grid(url_lang::base().'transfers', null, array(
//'separator' => '<br />-----------',
......
$grid->order_field('datetime')->label(url_lang::lang('texts.Date and time'));
$grid->order_field('amount')->label(url_lang::lang('texts.Amount'));
$grid->order_field('text')->label(url_lang::lang('texts.Text'));
$grid->action_field('id')->label(url_lang::lang('texts.Transfer'))->url(url_lang::base().'transfers/edit')->action(url_lang::lang('texts.Edit'));
$grid->datasource($transfers);
$view = new View('template');
$view->header = new View('base/header');
$view->content = new View('transfers/show_by_account');
......
}
else
{
Controller::warning(1);;
Controller::warning(1);
}
} // end of show_by_bank_account function
/**
* @author Jiri Svitak
* Function adds transfers. Transfer can be send only.
* @param $origin_account
* @return unknown_type
*/
function add($origin_account = NULL)
{
if (isset($origin_account))
{
$ssMember_id = $this->session->get('ssMember_id');
// to do - access rights
//if (!$this->gacl_class->acl_check('freenetis', 'new_own', 'all', $_SESSION['username'],get_class($this),'assign_transfers')) Controller::error(1);
$account_model = new Account_Model();
$accounts = $account_model->get_some_doubleentry_account_names($origin_account);
foreach ($accounts as $account)
......
}
asort($arr_accounts);
$this->origin = $origin_account;
$form = new Forge(url_lang::base().'transfers/add/'.$origin_account, '', 'POST', array('id' => 'article_form'));
$form->set_attr('class', 'form_class')->set_attr('method', 'post');
$form->group('')->label(url_lang::lang('texts.Transfer'));
$form->dropdown('aname')->label(url_lang::lang('texts.Destination credit account').':')->options($arr_accounts)->rules('required');
$form->input('amount')->label(url_lang::lang('texts.Amount').':')->rules('required|valid_numeric')->callback(array($this, 'valid_amount'));
$form->input('amount')->label(url_lang::lang('texts.Amount').':')->rules('required|valid_numeric')->callback(array($this, 'valid_amount_to_send'));
$form->input('text')->label(url_lang::lang('texts.Text'));
$form->submit('submit')->value(url_lang::lang('texts.Send'));
special::required_forge_style($form, ' *', 'required');
if ($form->validate())
{
$form_data = $form->as_array();
......
if ($mt->save())
{
$this->session->set_flash('message', url_lang::lang('texts.Transfer has been successfully added.'));
url::redirect(url_lang::base().'transfers/show_by_account/'.$origin_account);
if ($ssMember_id)
url::redirect(url_lang::base.'transfers/show_by_member/'.$ssMember_id);
else
url::redirect(url_lang::base().'transfers/show_by_account/'.$origin_account);
}
}
$headline = url_lang::lang('texts.Add new transfer');
$view = new View('template');
$view->header = new View('base/header');
$view->header->menu = Controller::render_menu();
$view->header->title = url_lang::lang('texts.Transfer');
$view->content = $form->html();
$view->header->title = $headline;
$view->content = new View('form');
$view->content->headline = $headline;
$view->content->form = $form->html();
if($ssMember_id)
$view->content->link_back = html::anchor(url_lang::base().'transfers/show_by_member/'.$ssMember_id, url_lang::lang('texts.Back to transfers of member'));
else
$view->content->link_back = html::anchor(url_lang::base().'transfers/show_by_account/'.$origin_account, url_lang::lang('texts.Back to transfers of account'));
$view->footer = new View('base/footer');
$view->render(TRUE);
}
else
{
Controller::warning(1);
}
}
/**
* Form for deducting membership fees.
* @author Jiri Svitak
* Function edits double-entry transfers.
* @param $transfer_id
* @return unknown_type
*/
public function edit($transfer_id = NULL)
{
if (isset($transfer_id))
{
$ssMember_id = $this->session->get('ssMember_id');
$ssAccount_id = $this->session->get('ssAccount_id');
// to do - access rights
//if (!$this->gacl_class->acl_check('freenetis', 'new_own', 'all', $_SESSION['username'],get_class($this),'assign_transfers')) Controller::error(1);
$transfer = new Transfer_Model($transfer_id);
$form = new Forge(url_lang::base().'transfers/edit/'.$transfer_id, '', 'POST', array('id' => 'article_form'));
$form->set_attr('class', 'form_class')->set_attr('method', 'post');
$form->group('')->label(url_lang::lang('texts.Basic information'));
$form->input('text')->label(url_lang::lang('texts.Text').':')->rules('required|length[3,50]')->value($transfer->text);
$form->input('amount')->label(url_lang::lang('texts.Amount').':')->rules('required')->value($transfer->amount)->callback(array($this, 'valid_amount'));
$form->submit('submit')->value(url_lang::lang('texts.Edit'));
special::required_forge_style($form, ' *', 'required');
if($form->validate())
{
$form_data = $form->as_array();
foreach($form_data as $key => $value)
$transfer->$key = htmlspecialchars($value);
unset($form_data);
if ($transfer->save())
$this->session->set_flash('message', url_lang::lang('texts.Transfer has been successfully updated.'));
else
$this->session->set_flash('message', url_lang::lang('texts.Error - cant update transfer.'));
if ($ssMember_id)
url::redirect(url_lang::base().'transfers/show_by_member/'.$ssMember_id);
else if ($ssAccount_id)
url::redirect(url_lang::base().'transfers/show_by_account/'.$ssAccount_id);
else
url::redirect(url_lang::base().'transfers/show_all');
}
else
{
$headline = url_lang::lang('texts.Editing of transfer');
$view->form = new View('registration');
$view = new View('template');
$view->header = new View('base/header');
$view->content = new View('transfers/edit');
$view->footer = new View('base/footer');
$view->header->menu = Controller::render_menu();
$view->header->title = $headline;
$view->content->headline = $headline;
$view->content->form = $form->html();
if ($ssMember_id)
$view->content->link_back = html::anchor(url_lang::base().'transfers/show_by_member/'.$ssMember_id, url_lang::lang('texts.Back to transfers of member'));
else if ($ssAccount_id)
$view->content->link_back = html::anchor(url_lang::base().'transfers/show_by_account/'.$ssAccount_id, url_lang::lang('texts.Back to transfers of account'));
else
$view->content->link_back = html::anchor(url_lang::base().'transfers/show_all', url_lang::lang('texts.Back to day book'));
$view->render(TRUE);
}
}
else
{
Controller::warning(1);
}
}
/**
* Function deducts member fees.
* @return unknown_type
*/
function deduct_fees()
{
// to do - access rights
//if (!$this->acl_check_new(get_class($this),'members')) Controller::error(1);
// content of dropdowns
// content of dropdown for months
for ($i = 1; $i <= 12; $i++)
$arr_months[$i] = $i;
// content of dropdown for years
$year_from = date('Y') - 20;
for ($i = 1; $i <= 20; $i++)
$arr_years[$i] = $year_from + $i;
$form = new Forge(url_lang::base().'transfers/deduct_fees', '', 'POST', array('id' => 'article_form'));
$form->set_attr('class', 'form_class')->set_attr('method', 'post');
$form->dropdown('year')->label(url_lang::lang('texts.Year').':')->rules('required')->options($arr_years)->selected(20);
......
$form->input('text')->label(url_lang::lang('texts.Text').':');
$form->submit('submit')->value(url_lang::lang('texts.Deduct'));
special::required_forge_style($form, ' *', 'required');
if ($form->validate())
{
$form_data = $form->as_array();
......
* @param $input
* @return unknown_type
*/
function valid_amount($input)
function valid_amount_to_send($input)
{
$account_model = new Account_Model();
if ($account_model->get_account_balance($this->origin) < $input->value)
if ($input->value <= 0)
{
$input->add_error('required', url_lang::lang('texts.Error - amount has to be positive.'));
}
else if ($account_model->get_account_balance($this->origin) < $input->value)
{
$input->add_error('required', url_lang::lang('texts.Error - not enough money on origin account.'));
}
}
/**
* Function validates amount of money in editing.
* @param $input
* @return unknown_type
*/
function valid_amount($input)
{
if ($input->value <= 0)
{
$input->add_error('required', url_lang::lang('texts.Error - amount has to be positive.'));
$input->add_error('required', url_lang::lang('texts.Error - amount has to be positive.'));
}
}
freenetis/trunk/kohana/application/controllers/accounts.php
<?php
class Accounts_Controller extends Controller {
protected $owner_id = NULL;
protected $member_id = NULL;
protected $editation = FALSE;
protected $acc_id = NULL;
protected $sel_member;
......
'limit_results' => $limit_results,
'query_string' => $query_string
));
// adding account, to do - access rights
//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'));
$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('mname')->label(url_lang::lang('texts.Member name'));
$grid->order_field('balance')->label(url_lang::lang('texts.Balance'));
// to do - access rights
$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->action_field('id')->label(url_lang::lang('texts.Account'))->url(url_lang::base().'accounts/edit')->action(url_lang::lang('texts.Edit'));
$grid->datasource($accounts);
$view = new View('template');
......
if (!$this->gacl_class->acl_check('freenetis', 'new_own', 'all', $_SESSION['username'],get_class($this),'add_accounts')) Controller::error(1);
if (isset($member_id))
{
$this->owner_id = $member_id;
$this->member_id = $member_id;
$form = new Forge(url_lang::base().'accounts/add/'.$member_id, '', 'POST', array('id' => 'article_form'));
$form->set_attr('class', 'form_class')->set_attr('method', 'post');
......
// Controller::error(1);
if (isset($member_id))
{
$this->owner_id = $member_id;
$this->member_id = $member_id;
$form = new Forge(url_lang::base().'accounts/add_credit_account/'.$member_id, '', 'POST', array('id' => 'article_form'));
$form->set_attr('class', 'form_class')->set_attr('method', 'post');
$form->group('')->label(url_lang::lang('texts.Basic information'));
......
// Controller::error(1);
if (isset($member_id))
{
$this->owner_id = $member_id;
$this->member_id = $member_id;
$form = new Forge(url_lang::base().'accounts/add_project/'.$member_id, '', 'POST', array('id' => 'article_form'));
$form->set_attr('class', 'form_class')->set_attr('method', 'post');
$form->group('')->label(url_lang::lang('texts.Basic information'));
......
}
} // end of add_credit_account function
/**
* @author Jiri Svitak
* Function edits double-entry account, only name and comment can be edited.
* @param $acc_id
* @return unknown_type
*/
function edit($acc_id = NULL)
{
if (!$this->gacl_class->acl_check('freenetis', 'edit_own', 'all', $_SESSION['username'],get_class($this),'edit_accounts')) Controller::error(1);
// to do - correct access rights
//if (!$this->gacl_class->acl_check('freenetis', 'edit_own', 'all', $_SESSION['username'], get_class($this),'edit_accounts'))
// Controller::error(1);
if (isset($acc_id))
{
$model_account = new Account_Model($acc_id);
$this->owner_id = $model_account->owner_id;
$this->member_id = $model_account->member_id;
$this->editation = TRUE;
$this->acc_id = $acc_id;
$form = new Forge(url_lang::base().'accounts/edit/'.$acc_id, '', 'POST', array('id' => 'article_form'));
$form->set_attr('class', 'form_class')->set_attr('method', 'post');
$form->group('')->label(url_lang::lang('texts.Basic informations'));
$form->group('')->label(url_lang::lang('texts.Basic information'));
$form->input('name')->label(url_lang::lang('texts.Name').':')->rules('required|length[3,50]')->value($model_account->name);
$form->input('start_amount')->label(url_lang::lang('texts.Start amount').':')->value((float)$model_account->start_amount);
$form->dropdown('type')->label(url_lang::lang('texts.Account type').':')->options(array('bank'=>url_lang::lang('texts.Bank account'),'analytic'=>url_lang::lang('texts.Double entry account'),'project'=>url_lang::lang('texts.Project account'),'master'=>url_lang::lang('texts.Master bank account'),'operating'=>url_lang::lang('texts.Operating account'),'infrastructure'=>url_lang::lang('texts.Infrastructure account'),'suppliers'=>url_lang::lang('texts.Suppliers account'),'unidentified'=>url_lang::lang('texts.Unidentified acccount')))->callback(array($this, 'callback_acc_type'))->selected($model_account->type);
$form->textarea('comment')->label(url_lang::lang('texts.Comment').':')->rules('length[0,250]')->value($model_account->comment);
$form->submit('submit')->value(url_lang::lang('texts.Edit'));
special::required_forge_style($form, ' *', 'required');
if($form->validate())
{
$form_data = $form->as_array();
......
{
$model_account->$key = htmlspecialchars($value);
}
if (trim($form_data['start_amount'])=='') $model_account->start_amount = '0';
unset($form_data);
if ($model_account->save())
{
$this->session->set_flash('message', url_lang::lang('texts.Account successfully updated.'));
$this->session->set_flash('message', url_lang::lang('texts.Account has been successfully updated.'));
}
else
{
$this->session->set_flash('message', url_lang::lang('texts.Error - cant update account.'));
}
url::redirect(url_lang::base().'accounts/detail/'.(int)$model_account->id);
url::redirect(url_lang::base().'accounts/show_all');
}
else
{
$headline = url_lang::lang('texts.Editing of account').' '.$model_account->name;
$view->form = new View('registration');
$view = new View('template');
$view->header = new View('base/header');
$view->content = new View('account_edit');
$view->content = new View('accounts/edit');
$view->footer = new View('base/footer');
$view->header->menu = Controller::render_menu();
$view->header->title = url_lang::lang('texts.Account editation');
$view->header->title = $headline;
$view->content->headline = $headline;
$view->content->form = $form->html();
$view->content->acc_data = $model_account;
$view->render(TRUE);
}
}
......
/**
* @author Jiri Svitak
* Deletes account. It shouldn't be used. Accounts cannot be deleted.
* Deletes account. It should not be used. Accounts should not be deleted.
* @param $acc_id
* @return unknown_type
*/
......
}
} // end of delete function
function new_transfer($account_id = NULL)
{
if (isset($account_id))
{
$this->account_id = $account_id;
$account = new Account_Model($account_id);
// access control
if (!$this->acl_check_new(get_class($this),'transfers',$account->member_id)) Controller::error(1);
$arr_users = array();
$user_model = new User_Model;
$users = $user_model->select('member_id','name','surname','login')->orderby('surname, name')->where('type!=','user')->find_all();
$arr_users[0] = '----- '.url_lang::lang('texts.Select the member').' -----';
foreach ($users as $user) {
$arr_users[$user->member_id] = $user->surname.' '.$user->name.' - '.$user->login;
}
// asort($arr_users);
$form = new Forge(url_lang::base().'accounts/add/'.$account_id, '', 'POST', array('id' => 'article_form'));
$form->set_attr('class', 'form_class')->set_attr('method', 'post');
$form->input('amount')->label(url_lang::lang('texts.Amount').':')->rules('required|length[0,50]|valid_numeric')->value('0')->callback(array($this, 'callback_amount'));
$form->dropdown('username')->label(url_lang::lang('texts.Send to member').':')->options($arr_users)->onchange('ajax_get_accounts(this.value,'.$account_id.')')->callback(array($this, 'callback_username'));
$form->dropdown('account')->label(url_lang::lang('texts.Members account').':')->options(array('0'=>'----- '.url_lang::lang('texts.Select the account').' -----'))->callback(array($this, 'callback_account'));
$form->textarea('comment')->label(url_lang::lang('texts.Comment').':')->rules('length[0,250]');
special::required_forge_style($form, ' *', 'required');
if($form->validate())
{
$form_data = $form->as_array();
$transfer = new Transfer_Model();
foreach($form_data as $key => $value)
{
$form_data->$key = htmlspecialchars($value);
}
$transfer->origin_id = $account->id;
$transfer->destination_id = $form_data['account'];
$transfer->text = $form_data['comment'];
$transfer->amount = (float)$form_data['amount'];
if ($transfer->save())
{
if ($account->type=='analytic')
{
$member = new Member_Model($account->member_id);
$member->current_credit = (float)$member->current_credit - (float)$form_data['amount'];
$member->save();
unset($model_members);
}
$account2 = new Account_Model($form_data['account']);
if ($account2->type=='analytic')
{
$member = new Member_Model($account2->owner_id);
$member->current_credit = (float)$member->current_credit + (float)$form_data['amount'];
$member->save();
}
$this->session->set_flash('message', url_lang::lang('texts.The transfer successfully done.'));
}
else
{
$this->session->set_flash('message', url_lang::lang('texts.Error - cant do the transfer.'));
}
url::redirect(url_lang::base().'accounts/transfers/'.(int)$account->member_id);
}
else
{
$view->form = new View('registration');
$view = new View('template');
$view->header = new View('base/header');
$view->content = new View('transfers_new');
$view->footer = new View('base/footer');
$view->header->menu = Controller::render_menu();
$view->header->title = url_lang::lang('texts.New transfer');
$view->content->form = $form->html('forge/new_transfer',TRUE);
$view->content->acc_data = $account;
//$view->content->acc_id = $acc_id;
$view->render(TRUE);
}
}
else
{
Controller::warning(1);;
}
} // end of new_transfer function
/***************************** SPECIAL AND AJAX FUNCTIONS ************************
**********************************************************************************
*********************HERE ARE FUNCTIONS FOR DIRECT GET ACCESS *******************/
......
{
$acc_id = $this->input->get('acc_id');
$model_account = new Account_Model();
$owner_id = ($this->input->get('account')!=0) ? 'id!='.$this->input->get('account').' AND ' : '';
$accounts = $model_account->where($owner_id.'type!=\'master\' AND type!=\'bank\' AND owner_id='.$acc_id)->find_all();
$member_id = ($this->input->get('account')!=0) ? 'id!='.$this->input->get('account').' AND ' : '';
$accounts = $model_account->where($member_id.'type!=\'master\' AND type!=\'bank\' AND member_id='.$acc_id)->find_all();
if (count($accounts)>0)
{
$return = '<accounts>';
......
$model_account= new Account_Model();
if ($input->value == 'analytic' || trim($input->value)=='')
{
if ($model_account->acc_type_exist($input->value, $this->owner_id, $this->acc_id) || trim($input->value)=='')
if ($model_account->acc_type_exist($input->value, $this->member_id, $this->acc_id) || trim($input->value)=='')
{
$input->add_error('required', url_lang::lang('texts.Member already have the double entry account.'));
}
......
if ($this->editation)
{
// member must have ONE double entry account
if (!$model_account->acc_type_exist('analytic', $this->owner_id, $this->acc_id) && $input->value != 'analytic')
if (!$model_account->acc_type_exist('analytic', $this->member_id, $this->acc_id) && $input->value != 'analytic')
{
$input->add_error('required', url_lang::lang('texts.Member have to own ONE double entry account.'));
}
......
if ($this->sel_member>0)
{
$model_account = new Account_Model();
$owner_id = ($this->acc_id) ? 'id!='.$this->acc_id.' AND ' : '';
$accounts = $model_account->where($owner_id.'type!=\'master\' AND type!=\'bank\' AND owner_id='.$this->sel_member)->find_all();
$member_id = ($this->acc_id) ? 'id!='.$this->acc_id.' AND ' : '';
$accounts = $model_account->where($member_id.'type!=\'master\' AND type!=\'bank\' AND member_id='.$this->sel_member)->find_all();
$arr_users = array();
$arr_users[0] = '----- '.url_lang::lang('texts.Select the account').' -----';
foreach ($accounts as $account) {
freenetis/trunk/kohana/application/controllers/devices.php
function show_all($limit_results = 500, $order_by = 'id', $order_by_direction = 'ASC', $page_word = null, $page = 1)
{
$this->session->del('ssMember_id');
if (!$this->acl_check_view(get_class($this),'devices'))
Controller::error(1);
$member_id = NULL;
if (is_numeric($this->input->get('member_id')))
$member_id = $this->input->get('member_id');
$member = new Member_Model($member_id);
if ($member->id)
$this->session->set('ssMember_id',$member_id);
$enum_type_model = new Enum_type_Model();
$arr_types = $enum_type_model->get_values(Enum_type_model::id_type_of_device);
$arr_types[0] = '----- '.url_lang::lang('texts.select type').' -----';
......
new Table_Form_Item('text','user','User'),
"tr",
new Table_Form_Item('select','device_type','Type',$arr_types),
new Table_Form_Item('hidden','member_id','',array($member_id)),
"td",
new Table_Form_Item('submit','submit','Filter')
)
);
$filter_values = $filter->values();
if ($member->id)
$filter_values["member_id"] = (int) $this->input->get('member_id');
// get new selector
if (is_numeric($this->input->get('record_per_page')))
$limit_results = (int) $this->input->get('record_per_page');
$device_model = new Device_Model;
$total_devices = $device_model->count_all_devices($filter_values);
if (($sql_offset = ($page - 1) * $limit_results) > $total_devices)
$sql_offset = 0;
$query = $device_model->get_all_devices($sql_offset, (int)$limit_results, $order_by, $order_by_direction, NULL, $filter_values);
$arr_gets = array();
foreach ($this->input->get() as $key=>$value)
$arr_gets[] = $key.'='.$value;
$query_string = '?'.implode('&',$arr_gets);
$headline = ($member->id) ? url_lang::lang('texts.Devices list of member').' '.$member->name : url_lang::lang('texts.Devices list');
$headline = url_lang::lang('texts.Devices list');
$grid = new Grid(url_lang::base().'devices', $headline, array(
//'separator' => '<br />-----------',
//'use_paginator' => false,
......
'limit_results' => $limit_results,
'query_string' => $query_string
));
if ($member->id)
$grid->add_new_button(url_lang::base().'devices/show_all', url_lang::lang('texts.Back to list of all devices'));
if ($this->acl_check_new(get_class($this),'devices'))
$grid->add_new_button(url_lang::base().'devices/add_whole', url_lang::lang('texts.Add new device'));
$grid->order_field('id')->label('ID')->class('center');
......
$grid->action_field('id')->label(url_lang::lang('texts.Device')) ->url(url_lang::base().'devices/edit') ->action(url_lang::lang('texts.Edit'))->class('center');
//$grid->action_field('id')->label(url_lang::lang('texts.Delete')) ->url('delete') ->action(url_lang::lang('texts.Delete'))->class('center');
$grid->datasource( $query );
$view = new View('template');
$view->header = new View('base/header');
$view->header->title = url_lang::lang('texts.Devices list');
freenetis/trunk/kohana/application/views/account_edit.php
<h2><?php echo url_lang::lang('texts.Editation of account').' '.$acc_data->name ?></h2><br />
<?php echo html::anchor(url_lang::base().'accounts/detail/'.$acc_data->id,url_lang::lang('texts.Back to this account.')) ?>
<br /><br />
<?php echo $form?>
freenetis/trunk/kohana/application/views/account_show.php
<h2><?php echo url_lang::lang('texts.Account').' '.$acc_data->name ?></h2><br />
<?php echo $message ? '<div class="message">'.$message.'</div>' : '' ?>
<?php echo html::anchor(url_lang::base().'accounts/edit/'.$acc_data->id,url_lang::lang('texts.Edit account')).' | '.html::anchor(url_lang::base().'accounts/account_transfers/'.$acc_data->id,url_lang::lang('texts.Show transfers on this account.')).' | '.html::anchor(url_lang::base().'accounts/transfers/'.$acc_data->owner_id,url_lang::lang('texts.Back to the members transfers.')) ?><br />
<br />
<table class="extended" cellspacing="0" style="float:left">
<tr>
<th colspan="2"><?php echo url_lang::lang('texts.Basic information') ?></th>
</tr>
<tr>
<th>ID</th>
<td><?php echo $acc_data->id ?></td>
</tr>
<tr>
<th><?php echo url_lang::lang('texts.Name') ?></th>
<td><?php echo $acc_data->name ?></td>
</tr>
<tr>
<th><?php echo url_lang::lang('texts.Type') ?></th>
<td><?php echo $acc_data->type ?></td>
</tr>
<tr>
<th><?php echo url_lang::lang('texts.Start amount') ?></th>
<td><?php echo number_format($acc_data->start_amount, 2, ',', ' ').' '.url_lang::lang('texts.CZK') ?></td>
</tr>
<tr>
<th><?php echo url_lang::lang('texts.Current credit') ?></th>
<td><?php echo number_format($credit, 2, ',', ' ').' '.url_lang::lang('texts.CZK') ?></td>
</tr>
<tr>
<th><?php echo url_lang::lang('texts.Comment') ?></th>
<td><?php echo trim($acc_data->comment) ? $acc_data->comment : '&nbsp;'; ?></td>
</tr>
</table>
freenetis/trunk/kohana/application/views/accounts/edit.php
<h2><?php echo $headline ?></h2><br />
<?php echo html::anchor(url_lang::base().'accounts/show_all', url_lang::lang('texts.Back to this account.')) ?>
<br /><br />
<?php echo $form?>
freenetis/trunk/kohana/application/views/transfers/edit.php
<h2><?php echo $headline ?></h2><br />
<?php echo $link_back ?>
<br /><br />
<?php echo $form?>

Také k dispozici: Unified diff