Revize 665
Přidáno uživatelem Jiří Sviták před asi 14 roky(ů)
freenetis/trunk/kohana/html/.htaccess.sample | ||
---|---|---|
|
||
Order deny,allow
|
||
# access from internet is denied
|
||
Deny from all
|
||
# allow access from localhost through IPv6 and IPv4, useful for development
|
||
Allow from ::1
|
||
Allow from 127.0.0.1
|
||
# allow access from your local network, for example network 10.0.0.0/8
|
||
Allow from 10.0.0.0/8
|
||
|
||
|
||
RewriteEngine On
|
||
# condition if requested URL contains in the end html or html/
|
||
RewriteCond %{REQUEST_URI} html/$
|
||
# this rule causes opening of html file with name of visitor's IP address
|
||
# visitor is shown his personalised redirection message (static html page)
|
||
RewriteRule .* /freenetis/html/%{REMOTE_ADDR}.html [L]
|
||
|
||
|
||
# if visitor's IP address has not file with its name, then document is not found
|
||
# in this case not found page has the meaning that IP address is unidentified
|
||
ErrorDocument 404 /freenetis/html/response404.html
|
freenetis/trunk/kohana/application/i18n/cs_CZ/texts.php | ||
---|---|---|
'whole d' => 'Celé z.',
|
||
'without change' => 'Beze změny',
|
||
'work' => 'Práce',
|
||
'work approval' => 'Schválení práce',
|
||
'work confirmation' => 'Potvrzení práce',
|
||
'work has been successfully added' => 'Práce byla úspěšně přidána',
|
||
'work has been successfully confirmed' => 'Práce byla úspěšně potvrzena',
|
freenetis/trunk/kohana/application/models/member.php | ||
---|---|---|
else
|
||
$where .= ' AND ';
|
||
if ($key == 'street')
|
||
$where .= "s.street LIKE '%".trim($value)."%' COLLATE utf8_general_ci";
|
||
$where .= "s.street LIKE '%".$value."%' COLLATE utf8_general_ci";
|
||
if ($key == 'town')
|
||
$where .= "t.town LIKE '%".trim($value)."%' COLLATE utf8_general_ci";
|
||
$where .= "t.town LIKE '%".$value."%' COLLATE utf8_general_ci";
|
||
if ($key == 'name')
|
||
$where .= "m.name LIKE '%".$value."%' COLLATE utf8_general_ci";
|
||
if ($key == 'variable_symbol')
|
||
... | ... | |
$where .= "m.type = $value";
|
||
if ($key == 'id')
|
||
$where .= "m.id = ".trim($value);
|
||
if ($key == 'street_number')
|
||
$where .= "ap.street_number = ".trim($value);
|
||
}
|
||
if ($key == 'redirect' && $value != self::$all)
|
||
{
|
||
... | ... | |
else
|
||
$where .= ' AND ';
|
||
if ($key == 'street')
|
||
$where .= "s.street LIKE '%".trim($value)."%' COLLATE utf8_general_ci";
|
||
$where .= "s.street LIKE '%".$value."%' COLLATE utf8_general_ci";
|
||
if ($key == 'town')
|
||
$where .= "t.town LIKE '%".trim($value)."%' COLLATE utf8_general_ci";
|
||
$where .= "t.town LIKE '%".$value."%' COLLATE utf8_general_ci";
|
||
if ($key == 'name')
|
||
$where .= "m.name LIKE '%".$value."%' COLLATE utf8_general_ci";
|
||
if ($key == 'variable_symbol')
|
||
... | ... | |
$where .= "m.type = $value";
|
||
if ($key == 'id')
|
||
$where .= "m.id = ".trim($value);
|
||
if ($key == 'street_number')
|
||
$where .= "ap.street_number = ".trim($value);
|
||
}
|
||
if ($key == 'redirect' && $value != self::$all)
|
||
{
|
freenetis/trunk/kohana/application/models/ip_address.php | ||
---|---|---|
* @param $order_by_direction
|
||
* @return unknown_type
|
||
*/
|
||
public function get_all_ip_addresses($limit_from = 0, $limit_results = 50, $order_by = 'ip_addresses.id', $order_by_direction = 'ASC', $filter_values = array())
|
||
public function get_all_ip_addresses($limit_from = 0, $limit_results = 50, $order_by = 'ip_address', $order_by_direction = 'ASC', $filter_values = array())
|
||
{
|
||
$where = '';
|
||
foreach($filter_values as $key => $value)
|
||
... | ... | |
$where .= ' AND '.$key.' LIKE \'%'.$value.'%\' COLLATE utf8_general_ci';
|
||
}
|
||
}
|
||
if ($order_by == 'ip_address')
|
||
$order_by = 'inet_aton(ip.ip_address)';
|
||
return self::$db->query("
|
||
SELECT ip.*,
|
||
SELECT ip.*, ip.id AS ip_address_id,
|
||
IFNULL(i1.name, i2.name) AS iface_name,
|
||
vi.name AS vlan_iface_name,
|
||
s.name as subnet_name,
|
freenetis/trunk/kohana/application/models/account_attribute.php | ||
---|---|---|
) q1
|
||
")->current()->total;
|
||
}
|
||
|
||
/**
|
||
* Gets account attributes. Returned are only that attributes which have at least one account.
|
||
* @author Jiri Svitak
|
||
*/
|
||
public function get_account_attributes()
|
||
{
|
||
return self::$db->query("
|
||
SELECT aa.id, aa.name
|
||
FROM account_attributes aa
|
||
JOIN accounts a ON a.account_attribute_id = aa.id
|
||
GROUP BY aa.id
|
||
");
|
||
}
|
||
|
||
}
|
||
?>
|
freenetis/trunk/kohana/application/models/transfer.php | ||
---|---|---|
}
|
||
return self::$db->query("SELECT
|
||
t.id,
|
||
CONCAT('<a href=\"".url_lang::base()."transfers/show_by_account/', oa.id, '\">', oa.name, '</a>') AS origin,
|
||
oa.account_attribute_id AS o_attribute,
|
||
CONCAT('<a href=\"".url_lang::base()."transfers/show_by_account/', da.id, '\">', da.name, '</a>') AS destination,
|
||
da.account_attribute_id AS d_attribute,
|
||
oa.id AS oa_id, oa.name AS oa_name,
|
||
oa.account_attribute_id AS oa_attribute,
|
||
da.id AS da_id, da.name AS da_name,
|
||
da.account_attribute_id AS da_attribute,
|
||
t.text, t.amount AS daybook_amount, t.datetime
|
||
FROM transfers t
|
||
LEFT JOIN accounts oa ON oa.id = t.origin_id
|
||
... | ... | |
oa.name AS oa_name,
|
||
da.id AS da_id,
|
||
da.name AS da_name,
|
||
u.name, u.surname
|
||
u.name, u.surname,
|
||
j.id AS job_id, j.description AS job_description
|
||
FROM transfers t
|
||
LEFT JOIN accounts oa ON oa.id = t.origin_id
|
||
LEFT JOIN accounts da ON da.id = t.destination_id
|
||
LEFT JOIN users u ON t.user_id = u.id
|
||
LEFT JOIN jobs j ON j.transfer_id = t.id
|
||
WHERE t.id = $trans_id"
|
||
)->current();
|
||
}
|
freenetis/trunk/kohana/application/controllers/members.php | ||
---|---|---|
"tr",
|
||
new Table_Form_Item('text','comment','Comment'),
|
||
new Table_Form_Item('select','type','Type', $types),
|
||
"tr",
|
||
"tr",
|
||
new Table_Form_Item('text','street_number','Street number'),
|
||
"td",
|
||
new Table_Form_Item('submit','submit','Filter')
|
||
)
|
||
);
|
||
... | ... | |
$grid->order_field('street_number')->label(url_lang::lang('texts.Street number'));
|
||
$grid->order_field('town')->label(url_lang::lang('texts.Town'));
|
||
//$grid->order_field('quarter')->label(url_lang::lang('texts.Quarter'));
|
||
$grid->order_field('balance')->label(url_lang::lang('texts.Balance'));
|
||
$grid->order_field('redirect')->label(url_lang::lang('texts.Redir'));
|
||
$grid->order_callback_field('balance')->label(url_lang::lang('texts.Balance'))->callback('Accounts_Controller::balance_field');
|
||
$grid->order_callback_field('redirect')->label(url_lang::lang('texts.Redir'))->callback('Members_Controller::redirect_field');
|
||
//$grid->order_field('comment')->label(url_lang::lang('texts.Comment'));
|
||
// action fields
|
||
if ($this->acl_check_view(get_class($this), 'members'))
|
||
... | ... | |
} // end of show_all function
|
||
|
||
/**
|
||
* Callback field for redirection.
|
||
* @param unknown_type $item
|
||
* @param unknown_type $name
|
||
*/
|
||
static function redirect_field($item, $name)
|
||
{
|
||
$redirstr = '';
|
||
// membership Interrupt redirection - letter I
|
||
if ($item->redirect & 1)
|
||
$redirstr .= url_lang::lang('texts.I');
|
||
// Debtor redirection - letter D
|
||
elseif ($item->redirect & 2)
|
||
$redirstr .= url_lang::lang('texts.D');
|
||
// payment Notice redirection - letter N
|
||
elseif ($item->redirect & 4)
|
||
$redirstr .= url_lang::lang('texts.N');
|
||
// Optional message redirection - letter O
|
||
elseif ($item->redirect & 8)
|
||
$redirstr .= url_lang::lang('texts.O');
|
||
// no redirection set?
|
||
if ($redirstr == '')
|
||
echo ' ';
|
||
else
|
||
echo $redirstr;
|
||
}
|
||
|
||
|
||
/**
|
||
* Shows details of member.
|
||
* @param $member_id id of member to show
|
||
* @param $order_by sorting column
|
freenetis/trunk/kohana/application/controllers/transfers.php | ||
---|---|---|
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', 'origin', 'destination', 'datetime', 'text', 'amount');
|
||
$allowed_order_type = array('id', 'oa_name', 'da_name', 'oa_attribute', 'da_attribute', 'datetime', 'text', 'amount');
|
||
if (!in_array(strtolower($order_by), $allowed_order_type))
|
||
$order_by = 'id';
|
||
if (strtolower($order_by_direction) != 'asc' && strtolower($order_by_direction) != 'desc')
|
||
... | ... | |
$grid->add_new_button(url_lang::base().'transfers/deduct_entrance_fees', url_lang::lang('texts.Deduction of entrance fees'), array('onclick' => 'return potvrd(\''.url_lang::lang('texts.Are you sure you want to deduct all entrance fees').'\')'));
|
||
}
|
||
$grid->order_field('id')->label('ID');
|
||
$grid->field('origin')->label(url_lang::lang('texts.Origin account'));
|
||
$grid->order_field('o_attribute')->label(url_lang::lang('texts.Type'));
|
||
$grid->field('destination')->label(url_lang::lang('texts.Destination account'));
|
||
$grid->order_field('d_attribute')->label(url_lang::lang('texts.Type'));
|
||
//$grid->field('origin')->label(url_lang::lang('texts.Origin account'));
|
||
$grid->order_callback_field('oa_name')->label(url_lang::lang('texts.Origin account'))->callback('Transfers_Controller::origin_account_field');
|
||
$grid->order_field('oa_attribute')->label(url_lang::lang('texts.Type'));
|
||
//$grid->field('destination')->label(url_lang::lang('texts.Destination account'));
|
||
$grid->order_callback_field('da_name')->label(url_lang::lang('texts.Destination account'))->callback('Transfers_Controller::destination_account_field');
|
||
$grid->order_field('da_attribute')->label(url_lang::lang('texts.Type'));
|
||
$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('daybook_amount')->label(url_lang::lang('texts.Amount'));
|
||
... | ... | |
$view->content->table = $grid;
|
||
$view->render(TRUE);
|
||
}
|
||
|
||
/**
|
||
* Static function for origin account callback field.
|
||
* @param $item
|
||
* @param $name
|
||
*/
|
||
static function origin_account_field($item, $name)
|
||
{
|
||
echo html::anchor(url_lang::base().'transfers/show_by_account/'.$item->oa_id, $item->oa_name);
|
||
}
|
||
|
||
/**
|
||
* Static function for destination account callback field.
|
||
* @param $item
|
||
* @param $name
|
||
*/
|
||
static function destination_account_field($item, $name)
|
||
{
|
||
echo html::anchor(url_lang::base().'transfers/show_by_account/'.$item->da_id, $item->da_name);
|
||
}
|
||
|
||
/**
|
||
* It shows transfers of credit account.
|
||
... | ... | |
//$grid->order_field('trans_type')->label(url_lang::lang('texts.Type'))->bool(array(url_lang::lang('texts.Inbound'),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'));
|
||
$grid->order_field('amount')->label(url_lang::lang('texts.Amount'));
|
||
$grid->order_callback_field('amount')->label(url_lang::lang('texts.Amount'))->callback('Transfers_Controller::amount_field');
|
||
$grid->order_field('text')->label(url_lang::lang('texts.Text'));
|
||
$grid->order_field('variable_symbol')->label(url_lang::lang('texts.VS'));
|
||
if ($this->acl_check_view('Accounts_Controller', 'transfers', $account->member_id))
|
||
... | ... | |
} // end of show_by_account function
|
||
|
||
/**
|
||
* Callback for amount field in transfers of account.
|
||
* @author Jiri Svitak
|
||
* @param unknown_type $item
|
||
* @param unknown_type $name
|
||
*/
|
||
static function amount_field($item, $name)
|
||
{
|
||
if ($item->amount > 0)
|
||
echo '<span style="color:green">'.number_format((float)$item->amount, 2, ',', ' ').'</span>';
|
||
elseif ($item->amount < 0)
|
||
echo '<span style="color:red">'.number_format((float)$item->amount, 2, ',', ' ').'</span>';
|
||
else
|
||
echo $item->amount;
|
||
}
|
||
|
||
/**
|
||
* Function shows information of transfer including previous transfer if exists.
|
||
* @author Jiri Svitak
|
||
* @param $transfer_id
|
||
... | ... | |
* @param $origin_account
|
||
* @return unknown_type
|
||
*/
|
||
function add($origin_account = NULL)
|
||
function add($origin_account_id = NULL)
|
||
{
|
||
if (isset($origin_account)) { // transfer from specific account ?
|
||
$this->origin = $origin_account; // save for callback function valid_amount_to_send
|
||
$origin_acc = new Account_Model($origin_account);
|
||
if ($origin_acc->id == 0)
|
||
echo 'zkus to priste';
|
||
die();
|
||
// transfer from specific account ?
|
||
if (isset($origin_account_id))
|
||
{
|
||
// save for callback function valid_amount_to_send
|
||
$this->origin = $origin_account_id;
|
||
$origin_account = new Account_Model($origin_account_id);
|
||
if ($origin_account->id == 0)
|
||
Controller::error(RECORD);
|
||
if (!$this->acl_check_new('Accounts_Controller', 'transfers', $origin_acc->member_id)) // does the user have rights for this?
|
||
if (!$this->acl_check_new('Accounts_Controller', 'transfers', $origin_account->member_id))
|
||
Controller::error(ACCESS);
|
||
$dst_account_model = new Account_Model(); // yes = create object of all accounts except the origin one
|
||
$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);
|
||
$origin_acc = new Account_Model(); // yes = create object of all accounts
|
||
$dst_accounts = $origin_accounts = $origin_acc->get_some_doubleentry_account_names();
|
||
// 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->addr - ".url_lang::lang('texts.Account ID')." $dst_account->id - "
|
||
.url_lang::lang('texts.Member ID')." $dst_account->member_id - "
|
||
.url_lang::lang('texts.Account type'). " $dst_account->account_attribute_id";
|
||
else
|
||
// transfer from arbitrary account to arbitrary account
|
||
{
|
||
if (!$this->acl_check_new('Accounts_Controller', 'transfers'))
|
||
Controller::error(ACCESS);
|
||
$account_model = new Account_Model();
|
||
$accounts = $account_model->get_some_doubleentry_account_names();
|
||
$origin_accounts = $accounts;
|
||
$dst_accounts = $accounts;
|
||
|
||
}
|
||
asort($arr_dst_accounts);
|
||
if (!isset($origin_account)) // for transfer from any account, use the same array for origin account list
|
||
$arr_orig_accounts=$arr_dst_accounts;
|
||
else
|
||
$arr_orig_accounts[$origin_acc->id] =
|
||
"$origin_acc->name - ".url_lang::lang('texts.Account ID')." $origin_acc->name - "
|
||
.url_lang::lang('texts.Member ID')." $origin_acc->member_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->id.' '.$dst_account->name.', '.$dst_account->addr;
|
||
//"$dst_account->name, $dst_account->addr - ".url_lang::lang('texts.Account ID')." $dst_account->id - "
|
||
//.url_lang::lang('texts.Member ID')." $dst_account->member_id - "
|
||
//.url_lang::lang('texts.Account type'). " $dst_account->account_attribute_id";
|
||
}
|
||
asort($arr_dst_accounts);
|
||
|
||
|
||
if (isset($origin_account_id))
|
||
{
|
||
$arr_orig_accounts[$origin_account->id] = $origin_account->id.' '.$origin_account->name;
|
||
//"$origin_account->name - ".url_lang::lang('texts.Account ID')." $origin_account->name - "
|
||
//.url_lang::lang('texts.Member ID')." $origin_account->member_id";
|
||
}
|
||
else
|
||
{
|
||
// array for dropdown
|
||
$arr_orig_accounts = $arr_dst_accounts;
|
||
}
|
||
|
||
// default destination account
|
||
$operating = ORM::factory('account')->where('account_attribute_id', Account_attribute_Model::$operating)->find();
|
||
|
||
$aa_model = new Account_attribute_Model();
|
||
$account_attributes = $aa_model->get_account_attributes();
|
||
foreach($account_attributes as $account_attribute)
|
||
{
|
||
$arr_attributes[$account_attribute->id] = $account_attribute->id.' '.$account_attribute->name;
|
||
}
|
||
|
||
// form
|
||
$form = new Forge(url_lang::base().'transfers/add/'.$origin_account, '', 'POST', array('id' => 'article_form'));
|
||
$form = new Forge(url_lang::base().'transfers/add/'.$origin_account_id, '', '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('oname')->label(url_lang::lang('texts.Origin account'))->options($arr_orig_accounts);
|
||
$form->dropdown('aname')->label(url_lang::lang('texts.Destination credit account').':')->options($arr_dst_accounts)->rules('required')->selected($operating->id);
|
||
// origin account
|
||
$form->group('')->label(url_lang::lang('texts.Origin account'));
|
||
$form->dropdown('')->label(url_lang::lang('texts.Account type').':')->options($arr_attributes);
|
||
$form->dropdown('oname')->label(url_lang::lang('texts.Origin account').':')->options($arr_orig_accounts);
|
||
// destination account
|
||
$form->group('')->label(url_lang::lang('texts.Destination account'));
|
||
$form->dropdown('')->label(url_lang::lang('texts.Account type').':')->options($arr_attributes);
|
||
$form->dropdown('aname')->label(url_lang::lang('texts.Destination account').':')->options($arr_dst_accounts)->rules('required')->selected($operating->id);
|
||
// other information
|
||
$form->group('')->label(url_lang::lang('texts.Transfer'));
|
||
$form->date('datetime')->label(url_lang::lang('texts.Date and time').':')->years(date('Y')-20, date('Y'))->rules('required');
|
||
$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'))->rules('required');
|
||
$form->input('text')->label(url_lang::lang('texts.Text').':')->rules('required');
|
||
$form->submit('submit')->value(url_lang::lang('texts.Send'));
|
||
special::required_forge_style($form, ' *', 'required');
|
||
if ($form->validate())
|
||
... | ... | |
$transfer->destination_id = $form_data['aname'];
|
||
$transfer->user_id = $this->session->get('user_id');
|
||
$transfer->datetime = date('Y-m-d', $form_data['datetime']);
|
||
$transfer->creation_datetime = date('Y-m-d H:i:s', time());
|
||
$transfer->creation_datetime = date('Y-m-d H:i:s');
|
||
$transfer->text = $form_data['text'];
|
||
$transfer->amount = $form_data['amount'];
|
||
if ($transfer->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);
|
||
//url::redirect(url_lang::base().'transfers/show_by_account/'.$origin_account_id);
|
||
url::redirect(url_lang::base().'transfers/show_all');
|
||
}
|
||
}
|
||
|
||
if ($this->acl_check_view('Members_Controller','members', $origin_acc->member_id))
|
||
$links[] = html::anchor(url_lang::base().'members/show/'.$origin_acc->member_id, url_lang::lang('texts.Back to the member'));
|
||
$links[] = html::anchor(url_lang::base().'transfers/show_by_account/'.$origin_account, url_lang::lang('texts.Back to transfers of account'));
|
||
/*
|
||
if ($this->acl_check_view('Members_Controller','members', $origin_account->member_id))
|
||
$links[] = html::anchor(url_lang::base().'members/show/'.$origin_account->member_id, url_lang::lang('texts.Back to the member'));
|
||
*/
|
||
//$links[] = html::anchor(url_lang::base().'transfers/show_by_account/'.$origin_account_id, url_lang::lang('texts.Back to transfers of account'));
|
||
|
||
$headline = url_lang::lang('texts.Add new transfer');
|
||
$view = new View('main');
|
||
... | ... | |
}
|
||
}
|
||
|
||
/**
|
||
* Function deducts member fees. This version creates one deducting transfer per year and its value
|
||
* can be recalculated (for example every month).
|
||
* Functional and debugged version.
|
||
* @author Jiri Svitak
|
||
* @return unknown_type
|
||
*/
|
||
/*
|
||
function deduct_fees()
|
||
{
|
||
// access rights
|
||
if (!$this->acl_check_new('Accounts_Controller', 'transfers'))
|
||
Controller::error(ACCESS);
|
||
// 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;
|
||
// prefilled member fee
|
||
$fee_model = new Fee_Model();
|
||
$fee = $fee_model->get_by_date_type(date('Y-m-d'), 'regular member fee');
|
||
if ($fee->id)
|
||
$member_fee = $fee->fee;
|
||
else
|
||
$member_fee = 0;
|
||
|
||
$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->dropdown('month')->label(url_lang::lang('texts.Month from').':')->rules('required')->options($arr_months)->selected(1);
|
||
$form->dropdown('months')->label(url_lang::lang('texts.Number of months').':')->rules('required')->options($arr_months)->selected(1)->callback(array($this, 'valid_months'));
|
||
$form->input('fee')->label(url_lang::lang('texts.Monthly member fee').':')->rules('required|valid_numeric')->value($member_fee);
|
||
$form->input('text')->label(url_lang::lang('texts.Text').':')->value(url_lang::lang('texts.Deduction of member fee'));
|
||
$form->submit('submit')->value(url_lang::lang('texts.Deduct'));
|
||
special::required_forge_style($form, ' *', 'required');
|
||
// form validation
|
||
if ($form->validate())
|
||
{
|
||
$form_data = $form->as_array();
|
||
foreach($form_data as $key => $value)
|
||
{
|
||
$form_data[$key] = htmlspecialchars($value);
|
||
}
|
||
$year = $arr_years[$form_data['year']];
|
||
$creation_datetime = date('Y-m-d H:i:s');
|
||
$start_date = date('Y-m-d', mktime(0, 0, 0, $form_data['month'], 1, $year));
|
||
$finish_date = date('Y-m-d', mktime(0, 0, 0, $form_data['month'] + $form_data['months'] -1, 1, $year));
|
||
$account_model = new Account_Model();
|
||
// it gets credit accounts, count of months to deduct and deducting transfer if already exists
|
||
$credit_accounts = $account_model->get_accounts_to_deduct_fees($start_date, $finish_date, $year);
|
||
// it gets id of operating account, the only destination account
|
||
$operating = ORM::factory('account')->
|
||
where('account_attribute_id', Account_attribute_Model::$operating)->find();
|
||
// it supposes that everything will be ok, if a transfer couldn't be created, it sets to false
|
||
$save_successful = true;
|
||
// it is suppossed that thousands of transfers will be generated, transaction processing required
|
||
$db = new Database();
|
||
$db->query("START TRANSACTION;");
|
||
// it goes through all credit accounts and it creates their outbound transfers to operating account
|
||
foreach($credit_accounts as $ca)
|
||
{
|
||
if (empty($ca->transfer_id))
|
||
{
|
||
if ($ca->months == 0)
|
||
continue;
|
||
$transfer = new Transfer_Model();
|
||
}
|
||
else
|
||
{
|
||
if ($ca->amount == $ca->months * $form_data['fee'])
|
||
continue;
|
||
$transfer = new Transfer_Model($ca->transfer_id);
|
||
}
|
||
$transfer->origin_id = $ca->id;
|
||
$transfer->destination_id = $operating->id;
|
||
$transfer->user_id = $this->session->get('user_id');
|
||
$transfer->type = Transfer_Model::$deduct_member_fee;
|
||
$transfer->datetime = $ca->start_date;
|
||
$transfer->creation_datetime = $creation_datetime;
|
||
$transfer->text = $form_data['text'];
|
||
$transfer->amount = $ca->months * $form_data['fee'];
|
||
// money transfer is saved and checked
|
||
if (!$transfer->save())
|
||
$save_successful = false;
|
||
}
|
||
// end of transaction processing
|
||
if ($save_successful)
|
||
{
|
||
$db->query("COMMIT;");
|
||
$this->session->set_flash('message', url_lang::lang('texts.Fees have been successfully deducted.'));
|
||
}
|
||
else
|
||
{
|
||
$db->query("ROLLBACK;");
|
||
$this->session->set_flash('message', url_lang::lang('texts.Error - some fees have not been deducted.'));
|
||
}
|
||
url::redirect(url_lang::base().'transfers/show_all');
|
||
}
|
||
else
|
||
{
|
||
$headline = url_lang::lang('texts.Deduction of member fees');
|
||
$view = new View('main');
|
||
$view->title = $headline;
|
||
$view->content = new View('form');
|
||
$view->content->headline = $headline;
|
||
$view->content->form = $form->html();
|
||
$view->content->link_back = html::anchor(url_lang::base().'transfers/show_all',url_lang::lang('texts.Back to day book'));
|
||
$view->render(TRUE);
|
||
}
|
||
}
|
||
*/
|
||
|
||
|
||
/**
|
||
* Deducts fees of all members in one month. Instead of one transfer per year this function deducts
|
||
* one transfer per month. It is possible to recount member fees by deleting previous
|
freenetis/trunk/kohana/application/controllers/subnets.php | ||
---|---|---|
$view->render(TRUE);
|
||
} // end of show all
|
||
|
||
static function subnet_field($item, $name)
|
||
{
|
||
echo html::anchor(url_lang::base()."subnets/show/$item->subnet_id", $item->subnet_name);
|
||
}
|
||
|
||
/**
|
||
* Function shows subnet.
|
||
* @param $subnet_id
|
freenetis/trunk/kohana/application/controllers/ip_addresses.php | ||
---|---|---|
* @param $order_by_direction sorting direction
|
||
* @return unknown_type
|
||
*/
|
||
function show_all($limit_results = 500, $order_by = 'id', $order_by_direction = 'asc', $page_word = null, $page = 1)
|
||
function show_all($limit_results = 500, $order_by = 'ip_address', $order_by_direction = 'asc', $page_word = null, $page = 1)
|
||
{
|
||
|
||
if (!$this->acl_check_view('Devices_Controller','ip_address'))
|
||
... | ... | |
if ($this->acl_check_new('Devices_Controller','ip_address'))
|
||
$grid->add_new_button(url_lang::base().'ip_addresses/add', url_lang::lang('texts.Add new IP address'));
|
||
//$grid->order_field('id')->label(url_lang::lang('texts.ID'));
|
||
$grid->order_field('ip_address')->label(url_lang::lang('texts.ip addresses'));
|
||
$grid->order_callback_field('ip_address')->label(url_lang::lang('texts.IP address'))->callback('Ip_addresses_Controller::ip_address_field');
|
||
//$grid->order_field('iface_name')->label(url_lang::lang('texts.Interface name'));
|
||
//$grid->order_field('vlan_iface_name')->label(url_lang::lang('texts.VLAN interface name'));
|
||
$grid->order_field('subnet_name')->label(url_lang::lang('texts.Subnet name'));
|
||
$grid->callback_field('device_name')->label(url_lang::lang('texts.Device name'))->callback('Ip_addresses_Controller::device_name');
|
||
if ($this->acl_check_view('Devices_Controller','ip_address'))
|
||
$grid->action_field('id')->label(url_lang::lang('texts.Show'))->url(url_lang::base().'ip_addresses/show')->action(url_lang::lang('texts.Show'))->class('center');
|
||
$grid->order_callback_field('subnet_name')->label(url_lang::lang('texts.Subnet name'))->callback('Subnets_Controller::subnet_field');
|
||
$grid->order_callback_field('device_name')->label(url_lang::lang('texts.Device name'))->callback('Devices_Controller::device_field');
|
||
//if ($this->acl_check_view('Devices_Controller','ip_address'))
|
||
// $grid->action_field('id')->label(url_lang::lang('texts.Show'))->url(url_lang::base().'ip_addresses/show')->action(url_lang::lang('texts.Show'))->class('center');
|
||
//if ($this->acl_check_edit('Devices_Controller','ip_address'))
|
||
// $grid->action_field('id')->label(url_lang::lang('texts.Edit'))->url(url_lang::base().'ip_addresses/edit')->action(url_lang::lang('texts.Edit'))->class('center');
|
||
if ($this->acl_check_edit('Devices_Controller','ip_address'))
|
||
... | ... | |
$view->render(TRUE);
|
||
} // end of show_all function
|
||
|
||
public static function device_name($item, $name)
|
||
static function ip_address_field($item, $name)
|
||
{
|
||
echo html::anchor(url_lang::base()."devices/show/$item->device_id", $item->device_name);
|
||
echo html::anchor(url_lang::base()."ip_addresses/show/$item->ip_address_id", $item->ip_address);
|
||
}
|
||
|
||
/**
|
freenetis/trunk/kohana/application/controllers/works.php | ||
---|---|---|
$transfer->destination_id = $member_account->id;
|
||
$transfer->datetime = date('Y-m-d');
|
||
$transfer->creation_datetime = date('Y-m-d H:i:s');
|
||
$transfer->text = $work->description;
|
||
// work description can contain too large strings
|
||
// $transfer->text = $work->description;
|
||
$transfer->text = url_lang::lang('texts.Work approval');
|
||
$transfer->amount = $form_data["rating"];
|
||
$transfer->user_id = $this->session->get('user_id');
|
||
$transfer_saved = $transfer->save();
|
freenetis/trunk/kohana/application/controllers/accounts.php | ||
---|---|---|
$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'));
|
||
$grid->order_callback_field('balance')->label(url_lang::lang('texts.Balance'))->callback('Accounts_Controller::balance_field');
|
||
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'))
|
||
... | ... | |
}
|
||
|
||
/**
|
||
* Callback for balance field in accounts.
|
||
* @author Jiri Svitak
|
||
* @param unknown_type $item
|
||
* @param unknown_type $name
|
||
*/
|
||
static function balance_field($item, $name)
|
||
{
|
||
if ($item->balance > 0)
|
||
echo '<span style="color:green">'.number_format((float)$item->balance, 2, ',', ' ').'</span>';
|
||
elseif ($item->balance < 0)
|
||
echo '<span style="color:red">'.number_format((float)$item->balance, 2, ',', ' ').'</span>';
|
||
else
|
||
echo $item->balance;
|
||
}
|
||
|
||
/**
|
||
* @author Jiri Svitak
|
||
* Adds new project account.
|
||
* @param $member_id
|
||
* @return unknown_type
|
freenetis/trunk/kohana/application/controllers/devices.php | ||
---|---|---|
$view->render(TRUE);
|
||
} // end of show_all function
|
||
|
||
|
||
/**
|
||
* Callback for device field.
|
||
* @author Jiri Svitak
|
||
* @param $item
|
||
* @param $name
|
||
*/
|
||
static function device_field($item, $name)
|
||
{
|
||
echo html::anchor(url_lang::base()."devices/show/$item->device_id", $item->device_name);
|
||
}
|
||
|
||
/**
|
||
* Function shows all devices of user.
|
||
* @return unknown_type
|
||
*/
|
freenetis/trunk/kohana/application/views/main.php | ||
---|---|---|
<?php echo html::script('media/js/jquery.autocomplete.min', FALSE) ?>
|
||
<?php echo html::script('media/js/jquery.validate.min', FALSE) ?>
|
||
<?php echo html::script('media/js/messages_cs', FALSE) ?>
|
||
<?php echo html::script('media/js/redirection', FALSE) ?>
|
||
<?php // echo html::script('media/js/redirection', FALSE) ?>
|
||
<?php echo html::script('media/js/highslide/highslide-with-html.js', FALSE) ?>
|
||
<?php echo html::script('media/js/php.min', FALSE) ?>
|
||
<?php echo html::script('media/js/tinymce/tiny_mce', FALSE) ?>
|
freenetis/trunk/kohana/application/views/transfers_show.php | ||
---|---|---|
<td><?php echo html::anchor(url_lang::base().'users/show/'.$transfer->user_id, $transfer->name.' '.$transfer->surname) ?></td>
|
||
</tr>
|
||
<?php } ?>
|
||
<?php if (isset($transfer->job_id)) { ?>
|
||
<tr>
|
||
<th><?php echo url_lang::lang('texts.Work') ?></th>
|
||
<td><?php echo html::anchor(url_lang::base().'works/show/'.$transfer->job_id, $transfer->job_description) ?></td>
|
||
</tr>
|
||
<?php } ?>
|
||
<?php if (isset($transfer->previous_transfer_id)) { ?>
|
||
<tr>
|
||
<th><?php echo url_lang::lang('texts.Previous transfer') ?></th>
|
freenetis/trunk/kohana/application/views/works/show.php | ||
---|---|---|
</tr>
|
||
<tr>
|
||
<th><?php echo url_lang::lang('texts.Rating') ?></th>
|
||
<td><?php echo $transfer->amount.' '.$this->settings->get('currency') ?></td>
|
||
<td><?php echo html::anchor(url_lang::base().'transfers/show/'.$transfer->id, $transfer->amount.' '.$this->settings->get('currency')) ?></td>
|
||
</tr>
|
||
<?php endif ?>
|
||
</table>
|
freenetis/trunk/kohana/application/views/grid_template.php | ||
---|---|---|
?>
|
||
<td <?php echo $class_td?>>
|
||
<?php
|
||
|
||
if ($field instanceof Callback_Field)
|
||
{
|
||
if (isset($field->callback))
|
||
if ($field instanceof Callback_Field)
|
||
{
|
||
if (isset($field->callback))
|
||
call_user_func($field->callback, $item, $field->name);
|
||
else
|
||
else
|
||
echo $item->$field;
|
||
}
|
||
elseif ($field instanceof Order_Callback_Field)
|
||
{
|
||
if (isset($field->callback))
|
||
}
|
||
elseif ($field instanceof Order_Callback_Field)
|
||
{
|
||
if (isset($field->callback))
|
||
call_user_func($field->callback, $item, $field->name);
|
||
else
|
||
else
|
||
echo $item->$field;
|
||
}
|
||
// empty field
|
||
elseif (trim($item->$field) == '')
|
||
{
|
||
echo ' ';
|
||
}
|
||
// money format - green for positive amounts, red for negative
|
||
elseif ($field->name == 'amount' || $field->name == 'balance')
|
||
{
|
||
if ($item->$field > 0)
|
||
echo '<span style="color:green">'.number_format((float)$item->$field, 2, ',', ' ').'</span>';
|
||
elseif ($item->$field < 0)
|
||
echo '<span style="color:red">'.number_format((float)$item->$field, 2, ',', ' ').'</span>';
|
||
else
|
||
echo $item->$field;
|
||
}
|
||
// redirect field - displays combination of letters instead of binary mask
|
||
elseif ($field->name == 'redirect')
|
||
{
|
||
$redirstr = '';
|
||
// membership Interrupt redirection - letter I
|
||
if ($item->$field & 1)
|
||
$redirstr .= url_lang::lang('texts.I');
|
||
// Debtor redirection - letter D
|
||
elseif ($item->$field & 2)
|
||
$redirstr .= url_lang::lang('texts.D');
|
||
// payment Notice redirection - letter N
|
||
elseif ($item->$field & 4)
|
||
$redirstr .= url_lang::lang('texts.N');
|
||
// Optional message redirection - letter O
|
||
elseif ($item->$field & 8)
|
||
$redirstr .= url_lang::lang('texts.O');
|
||
// no redirection set?
|
||
if ($redirstr == '')
|
||
echo ' ';
|
||
else
|
||
echo $redirstr;
|
||
}
|
||
// ordinary field without special formating
|
||
else
|
||
{
|
||
echo $item->$field;
|
||
}
|
||
?>
|
||
}
|
||
// empty field
|
||
elseif (trim($item->$field) == '')
|
||
{
|
||
echo ' ';
|
||
}
|
||
// ordinary field without special formating
|
||
else
|
||
{
|
||
echo $item->$field;
|
||
}
|
||
?>
|
||
</td>
|
||
<?php endif;
|
||
endforeach; ?>
|
freenetis/trunk/kohana/static/.htaccess.sample | ||
---|---|---|
# order for solving rules
|
||
Order deny,allow
|
||
|
||
# access from internet is denied
|
||
Deny from all
|
||
|
||
# allow access from localhost through IPv6, check if you have IPv6 enabled
|
||
# in your system, otherwise comment this line
|
||
Allow from ::1
|
||
|
||
# allow access from localhost through IPv4, useful for development
|
||
Allow from 127.0.0.1
|
||
|
||
# allow access from your local network, for example network 10.0.0.0/8
|
||
Allow from 10.0.0.0/8
|
||
|
||
# enable rewriting
|
||
RewriteEngine On
|
||
|
||
# condition if requested URL contains at the end string 'static'
|
||
RewriteCond %{REQUEST_URI} static/$
|
||
|
||
# this rule causes opening of html file with name of visitor's IP address
|
||
# visitor is shown his personalised redirection message (static html page)
|
||
RewriteRule .* /freenetis/static/%{REMOTE_ADDR}.html [L]
|
||
|
||
# if visitor's IP address has not file with its name, then document is not found
|
||
# in this case "not found page" means that IP address is unknown
|
||
ErrorDocument 404 /freenetis/static/response404.html
|
||
|
freenetis/trunk/kohana/.htaccess-sample | ||
---|---|---|
RewriteEngine On
|
||
RewriteBase /
|
||
RewriteBase /
|
||
|
||
# Protect application and system files from being viewed
|
||
#RewriteCond $1 ^(application|system)
|
||
... | ... | |
|
||
|
||
# pravidla pro ktere se to nebude prepisovat...kdyztak doplnit dalsi adresare
|
||
RewriteCond $1 ^(index\.php|robots\.txt|favicon\.ico|media)
|
||
RewriteCond $1 ^(index\.php|robots\.txt|favicon\.ico|media|static)
|
||
|
||
# No rewriting
|
||
RewriteRule ^(.*)$ - [PT,L]
|
||
... | ... | |
|
||
# Silently prepend index.php to EVERY URL.
|
||
RewriteCond $1 !^(index\.php)
|
||
RewriteRule ^(.*)$ index.php/$1 [L]
|
||
RewriteRule ^(.*)$ index.php/$1 [L]
|
Také k dispozici: Unified diff
Pridany callback fieldy. Pridano filtrovani clenu pomoci cisla popisneho. U schvalovani prace se dava text "schvalena prace", puvodni kopirovani textu popisu prace neni vhodne kvuli delce. Provazani praci a prevodu pomoci odkazu. Zahajena prace na novem univerzalnim pridavani prevodu. Upravy .htaccess pro presmerovani.