Projekt

Obecné

Profil

« Předchozí | Další » 

Revize 476

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

Opravy chyb. Pridan filtr pro ucetni denik a segmenty. Rucni pridavani bankovnich plateb rozsireno o identifikaci platby v pripade clenskeho prispevku.

Zobrazit rozdíly:

freenetis/trunk/kohana/application/i18n/cs_CZ/texts.php
'arrival' => 'Příchozí',
'assign' => 'Přiřadit',
'assign transfer' => 'Přiřadit převod',
'assigning of transfer' => 'Přiřazení platby',
'assigning of unidentified payment' => 'Přiřazení neidentifikované platby',
'association has not got credit account' => 'Sdružení nemá kreditní účet.',
'association information' => 'Informace o sdružení',
......
'towns' => 'Města',
'transfer' => 'Převod',
'transfer details' => 'Detaily převodu',
'transfer fee' => 'Poplatek za platbu',
'transfer fee' => 'Transakční poplatek',
'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 id' => 'ID převodu',
freenetis/trunk/kohana/application/models/segment.php
protected $has_many = array('ifaces','ports');
//protected $has_one= array('iface');
public function count_all_segments()
public function count_all_segments($filter_values = array())
{
return self::$db->count_records('segments');
$where = '';
if (!empty($filter_values['name']))
$where = "WHERE name LIKE '%".$filter_values['name']."%' COLLATE utf8_general_ci";
return self::$db->query("SELECT COUNT(*) AS total
FROM segments
$where
")->current()->total;
}
public function get_all_segments($limit_from = 0, $limit_results = 20, $order_by = 'id', $order_by_direction = 'asc', $filter_values = array())
{
$where = '';
if (!empty($filter_values['name']))
$where = "WHERE name LIKE '%".$filter_values['name']."%' COLLATE utf8_general_ci";
return self::$db->query("SELECT *
FROM segments
$where
ORDER BY $order_by $order_by_direction
LIMIT $limit_from, $limit_results
");
}
}
?>
freenetis/trunk/kohana/application/models/transfer.php
* @param $order_by_direction
* @return unknown_type
*/
public function get_all_transfers($limit_from = 0, $limit_results = 20, $order_by = 'id', $order_by_direction = 'desc')
public function get_all_transfers($limit_from = 0, $limit_results = 20, $order_by = 'id', $order_by_direction = 'desc', $filter_values = array())
{
$where = '';
foreach($filter_values as $key => $value)
{
if ($key != 'submit')
{
if ($key == 'oa_name')
$key = 'oa.name';
if ($key == 'da_name')
$key = 'da.name';
if ($where == '')
$where .= 'WHERE '.$key.' LIKE \'%'.$value.'%\' COLLATE utf8_general_ci';
else
$where .= ' AND '.$key.' LIKE \'%'.$value.'%\' COLLATE utf8_general_ci';
}
}
return self::$db->query("SELECT
t.id,
CONCAT('<a href=\"".url_lang::base()."transfers/show_by_account/', oa.id, '\">', oa.name, '</a>') AS origin,
......
FROM transfers t
LEFT JOIN accounts oa ON oa.id = t.origin_id
LEFT JOIN accounts da ON da.id = t.destination_id
$where
ORDER BY $order_by $order_by_direction
LIMIT $limit_from, $limit_results"
);
......
* Function counts all transfers. Used in day book.
* @return unknown_type
*/
public function count_all_transfers()
public function count_all_transfers($filter_values = array())
{
return self::$db->count_records('transfers');
$where = '';
foreach($filter_values as $key => $value)
{
if ($key != 'submit')
{
if ($key == 'oa_name')
$key = 'oa.name';
if ($key == 'da_name')
$key = 'da.name';
if ($where == '')
$where .= 'WHERE '.$key.' LIKE \'%'.$value.'%\' COLLATE utf8_general_ci';
else
$where .= ' AND '.$key.' LIKE \'%'.$value.'%\' COLLATE utf8_general_ci';
}
}
return self::$db->query("SELECT COUNT(*) AS total
FROM transfers t
LEFT JOIN accounts oa ON oa.id = t.origin_id
LEFT JOIN accounts da ON da.id = t.destination_id
$where
")->current()->total;
}
/**
freenetis/trunk/kohana/application/controllers/ifaces.php
$form = new Forge(url_lang::base()."ifaces/edit/".$iface_id, '', 'POST', array('id' => 'article_form'));
$form->set_attr('class', 'form_class')->set_attr('method', 'post');
$form->group('')->label(url_lang::lang('texts.Basic data'));
$form->input('name')->label(url_lang::lang('texts.name').':')->rules('required|length[2,250]')->value($iface->name);
$form->input('name')->label(url_lang::lang('texts.name').':')->rules('length[2,250]')->value($iface->name);
if ($ssDevice_id)
{
$device = new Device_Model($ssDevice_id);
freenetis/trunk/kohana/application/controllers/transfers.php
$order_by = 'id';
if (strtolower($order_by_direction) != 'asc' && strtolower($order_by_direction) != 'desc')
$order_by_direction = 'desc';
// creates fields for filtering
$filter=new Table_Form(url_lang::base()."transfers/show_all", "get", array(
new Table_Form_Item('text', 'oa_name', 'Origin account'),
new Table_Form_Item('text', 'datetime', 'Date and time'),
"tr",
new Table_Form_Item('text', 'da_name', 'Destination account'),
new Table_Form_Item('text', 'amount', 'Amount'),
"tr",
new Table_Form_Item('text', 'text', 'Text'),
"td", new Table_Form_Item('submit', 'submit', 'Filter')
)
);
$arr_gets = array();
foreach ($this->input->get() as $key=>$value)
$arr_gets[] = $key.'='.$value;
$query_string = '?'.implode('&',$arr_gets);
// model
$model_transfer = new Transfer_Model();
$total_transfers = $model_transfer->count_all_transfers();
$total_transfers = $model_transfer->count_all_transfers($filter->values());
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);
$alltransfers = $model_transfer->get_all_transfers($sql_offset, (int)$limit_results, $order_by, $order_by_direction, $filter->values());
$headline = url_lang::lang('texts.Day book');
$grid = new Grid(url_lang::base().'transfers', null, array(
//'separator' => '',
......
'style' => 'classic',
'order_by' => $order_by,
'order_by_direction' => $order_by_direction,
'limit_results' => $limit_results
'limit_results' => $limit_results,
'query_string' => $query_string,
'filter' => $filter->view
));
if ($this->acl_check_edit('Accounts_Controller', 'transfers'))
$grid->add_new_button(url_lang::base().'transfers/deduct_fees', url_lang::lang('texts.Deduction of member fees'));
......
$grid->order_field('amount')->label(url_lang::lang('texts.Amount'));
if ($this->acl_check_view('Accounts_Controller', 'transfers'))
$grid->action_field('id')->label(url_lang::lang('texts.Transfer'))->url(url_lang::base().'transfers/show')->action(url_lang::lang('texts.Show'));
if ($this->acl_check_edit('Accounts_Controller', 'transfers'))
$grid->action_field('id')->label(url_lang::lang('texts.Transfer'))->url(url_lang::base().'transfers/edit')->action(url_lang::lang('texts.Edit'));
// transfers should not be edited
//if ($this->acl_check_edit('Accounts_Controller', 'transfers'))
// $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('main');
$view->title = $headline;
......
$grid->order_field('text')->label(url_lang::lang('texts.Text'));
if ($this->acl_check_view('Accounts_Controller', 'transfers'))
$grid->action_field('id')->label(url_lang::lang('texts.Transfer'))->url(url_lang::base().'transfers/show')->action(url_lang::lang('texts.Show'));
if ($this->acl_check_edit('Accounts_Controller', 'transfers'))
$grid->action_field('id')->label(url_lang::lang('texts.Transfer'))->url(url_lang::base().'transfers/edit')->action(url_lang::lang('texts.Edit'));
// transfers should not be edited
//if ($this->acl_check_edit('Accounts_Controller', 'transfers'))
// $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('main');
$view->title = $headline;
freenetis/trunk/kohana/application/controllers/bank_transfers.php
{
$name = $ba->account_nr.'/'.$ba->bank_nr;
if (trim($ba->name) != '')
$name = $ba->name.' - '.$name;
$name .= ' - '.$ba->name;
$arr_bas[$ba->id] = $name;
}
asort($arr_bas, SORT_LOCALE_STRING);
......
{
$form_data[$key] = htmlspecialchars($value);
}
// preparation
$time_now = date('Y-m-d H:i:s', time());
$operating = ORM::factory('account')->find_by_account_attribute_id(Account_attribute_Model::$operating);
switch ($form_data['type'])
{
case self::$member_fee:
......
$bank_transfer_fee_saved = true;
if ($form_data['bank_transfer_fee'] > 0)
{
// fee transfer
$ft = new Transfer_Model();
$ft->origin_id = $origin_bank_fees->id;
$ft->destination_id = $destination_bank_fees->id;
$ft->user_id = $this->session->get('user_id');
$ft->datetime = date('Y-m-d', $form_data['datetime']);
$ft->creation_datetime = $time_now;
$ft->text = $form_data['fee_text'];
$ft->amount = $form_data['bank_transfer_fee'];
$bank_transfer_fee_saved = $ft->save();
// bank transfer fee
$btf = new Transfer_Model();
$btf->origin_id = $origin_bank_fees->id;
$btf->destination_id = $destination_bank_fees->id;
$btf->user_id = $this->session->get('user_id');
$btf->datetime = date('Y-m-d', $form_data['datetime']);
$btf->creation_datetime = $time_now;
$btf->text = $form_data['fee_text'];
$btf->amount = $form_data['bank_transfer_fee'];
$bank_transfer_fee_saved = $btf->save();
}
// if type of bank transfer is member fee, then it is identified
$identified_transfer_saved = true;
$transfer_fee_saved = true;
if ($form_data['type'] == self::$member_fee)
{
$member_model = new Member_Model();
$member = $member_model->find_member_by_phone($form_data['variable_symbol']);
if ($member->id)
{
// finding credit account
$ca = ORM::factory('account')->find_by_member_id_and_account_attribute_id($member->id,
Account_attribute_Model::$credit);
// identified transfer
$it = new Transfer_Model();
$it->origin_id = $destination_account->id;
$it->destination_id = $ca->id;
$it->user_id = $this->session->get('user_id');
$it->datetime = date('Y-m-d', $form_data['datetime']);
$it->creation_datetime = $time_now;
$it->text = url_lang::lang('texts.Assigning of transfer');
$it->amount = $form_data['amount'];
$identified_transfer_saved = $it->save();
// if there is transfer fee, then it is generated
$fee_model = new Fee_Model();
$fee = $fee_model->get_by_date_type(date('Y-m-d', $form_data['datetime']), 'transfer fee');
if (is_object($fee) && $fee->id)
{
// transfer fee
$tf = new Transfer_Model();
$tf->origin_id = $ca->id;
$tf->destination_id = $operating->id;
$tf->user_id = $this->session->get('user_id');
$tf->datetime = date('Y-m-d', $form_data['datetime']);
$tf->creation_datetime = $time_now;
$tf->text = url_lang::lang('texts.Transfer fee');
$tf->amount = $fee->fee;
$transfer_fee_saved = $tf->save();
}
}
}
// everything successful - setting message and redirection
if ($transfer_saved && $bank_transfer_saved && $bank_transfer_fee_saved)
if ($transfer_saved && $bank_transfer_saved && $bank_transfer_fee_saved && $identified_transfer_saved && $transfer_fee_saved)
{
$this->session->set_flash('message', url_lang::lang('texts.Bank transfer has been successfully added'));
url::redirect(url_lang::base().'bank_transfers/show_by_bank_account/'.$baa_id);
freenetis/trunk/kohana/application/controllers/segments.php
// get new selector
if (is_numeric($this->input->get('record_per_page'))) $limit_results = (int) $this->input->get('record_per_page');
// creates fields for filtering
$filter=new Table_Form(url_lang::base()."segments/show_all", "get", array(
new Table_Form_Item('text', 'name', 'Name'),
"tr", "td", new Table_Form_Item('submit', 'submit', 'Filter')
)
);
$arr_gets = array();
foreach ($this->input->get() as $key=>$value)
$arr_gets[] = $key.'='.$value;
$query_string = '?'.implode('&',$arr_gets);
// model
$segment_model = new Segment_Model();
$total_segments = $segment_model->count_all_segments();
$total_segments = $segment_model->count_all_segments($filter->values());
if (($sql_offset = ($page - 1) * $limit_results) > $total_segments)
$sql_offset = 0;
$query = $segment_model->orderby($order_by, $order_by_direction)->limit($limit_results, $sql_offset)->find_all();
$query = $segment_model->get_all_segments($sql_offset, (int)$limit_results, $order_by, $order_by_direction, $filter->values());
//$query = $segment_model->orderby($order_by, $order_by_direction)->limit($limit_results, $sql_offset)->find_all();
$grid = new Grid(url_lang::base().'segments', null,array(
//'separator' => '<br />-----------',
......
'style' => 'classic',
'order_by' => $order_by,
'order_by_direction' => $order_by_direction,
'limit_results' => $limit_results
'limit_results' => $limit_results,
'query_string' => $query_string,
'filter' => $filter->view
));
if ($this->acl_check_new('Devices_Controller','segment'))
freenetis/trunk/kohana/application/views/grid_template.php
<?php echo ($title) ? '<h2>'.$title.'</h2><br />' : '' ?>
<?php echo ($filter) ? $filter : '' ?>
<?php echo ($filter) ? $filter.'<br />' : '' ?>
<?php echo ($label) ? $label.$separator : '' ?>
<?php echo empty($buttons) ? '' : implode(' | ', $buttons).'<br /><br />' ?>

Také k dispozici: Unified diff