Revize 711
Přidáno uživatelem Jiří Sviták před asi 14 roky(ů)
freenetis/trunk/kohana/application/i18n/cs_CZ/texts.php | ||
---|---|---|
'device admins' => 'Správci zařízení',
|
||
'device engineers' => 'Technici zařízení',
|
||
'device detail' => 'Detail zařízení',
|
||
'device fees have been successfully deducted' => 'Splátky zařízení byly úspěšně strženy.',
|
||
'device has been successfully deleted' => 'Zařízení bylo úspěšně smazáno.',
|
||
'device has been successfully saved' => 'Zařízení bylo úspěšně uloženo.',
|
||
'device has been successfully updated' => 'Zařízení bylo úspěšně upraveno.',
|
freenetis/trunk/kohana/application/models/message.php | ||
---|---|---|
if ($order_by == 'ip_address')
|
||
$order_by = 'inet_aton(ip_address)';
|
||
return self::$db->query("
|
||
SELECT ip.ip_address, m.name, mip.datetime
|
||
SELECT mip.ip_address_id, ip.ip_address, m.name, mip.datetime
|
||
FROM messages_ip_addresses mip
|
||
LEFT JOIN ip_addresses ip ON ip.id = mip.ip_address_id
|
||
LEFT JOIN messages m ON m.id = mip.message_id
|
freenetis/trunk/kohana/application/models/account.php | ||
---|---|---|
JOIN members m ON a.member_id = m.id AND m.id <> 1
|
||
JOIN users u ON u.member_id = m.id
|
||
JOIN devices d ON d.user_id = u.id
|
||
LEFT JOIN transfers t ON t.origin_id = a.id AND t.type = ".Transfer_Model::$deduct_device_fee."
|
||
WHERE a.account_attribute_id = ".Account_attribute_Model::$credit."
|
||
GROUP BY a.id
|
||
HAVING total_price > 0
|
||
... | ... | |
|
||
/**
|
||
* Gets actually repaied amount of prices of all member's devices.
|
||
* @todo dodelat
|
||
* @author Jiri Svitak
|
||
* @param $account_id
|
||
*/
|
||
... | ... | |
return self::$db->query("
|
||
SELECT IFNULL(SUM(t.amount), 0) AS amount
|
||
FROM transfers t
|
||
WHERE t.origin_id = $account_id AND t.type = ".Transfer_Model::$deduct_entrance_fee
|
||
WHERE t.origin_id = $account_id AND t.type = ".Transfer_Model::$deduct_device_fee
|
||
)->current()->amount;
|
||
}
|
||
|
||
/**
|
||
* Gets list of devices with repayments. Devices are ordered ascending by their buy date.
|
||
* @author Jiri Svitak
|
||
* @param unknown_type $account_id
|
||
*/
|
||
function get_devices_of_account($account_id)
|
||
{
|
||
return self::$db->query("
|
||
SELECT d.id, d.payment_rate, d.buy_date, d.price
|
||
FROM devices d
|
||
JOIN users u ON d.user_id = u.id
|
||
JOIN accounts a ON a.member_id = u.member_id AND u.member_id <> 1
|
||
WHERE a.id = $account_id AND d.price IS NOT NULL AND d.price > 0
|
||
ORDER BY d.buy_date ASC
|
||
");
|
||
}
|
||
|
||
}
|
||
|
||
?>
|
freenetis/trunk/kohana/application/controllers/web_interface.php | ||
---|---|---|
* @param $synchronized
|
||
* @return unknown_type
|
||
*/
|
||
/*
|
||
function synchronized($synchronized = null)
|
||
{
|
||
|
||
// test if central router has send information about its synchronization status
|
||
// if necessary update synchronization status in Freenetis
|
||
if (isset($synchronized))
|
||
... | ... | |
|
||
}
|
||
}
|
||
*/
|
||
|
||
// asi neni nutne resit posilani zpravy z centralniho routeru, proste kdyz jsem prijde, tak je synchornizovany
|
||
function synchronized()
|
||
{
|
||
// get actual synchronization status
|
||
$synchronized = $this->settings->get('synchronized');
|
||
// set status to synchronized
|
||
$this->settings->set('synchronized', 1);
|
||
// return synchronization status to central router
|
||
return $synchronized;
|
||
}
|
||
|
||
/**
|
||
* Receives with POST method list of IP addresses which have active self-cancelable redirection and
|
||
* they have already visited canceling page. So this method cancels redirection in Freenetis database.
|
||
... | ... | |
{
|
||
print_r($_POST);
|
||
die();
|
||
// IP address to cancel redirection
|
||
$ip_string = $_POST['self_cancelable'];
|
||
$ip_array = explode(";", $ip_string);
|
||
$db = new Database();
|
||
foreach ($ip_array as $ip_address)
|
||
{
|
||
$ip_address;
|
||
$db->query("DELETE messages_ip_addresses FROM messages_ip_addresses mip, ip_addresses ip WHERE mip.ip_address_id = ip.id AND ip.ip_address = $ip_address");
|
||
}
|
||
}
|
||
|
||
/**
|
freenetis/trunk/kohana/application/controllers/transfers.php | ||
---|---|---|
{
|
||
url::redirect(url_lang::base().'transfers/show_all');
|
||
}
|
||
|
||
|
||
/**
|
||
* It shows all double-entry transfers. They are shown in day book.
|
||
* @author Jiri Svitak
|
||
... | ... | |
$account_model = new Account_Model();
|
||
// gets all credit accounts
|
||
$credit_accounts = $account_model->get_accounts_to_deduct_device_fees();
|
||
die();
|
||
// large amount of database inserts, transaction processing is necessary
|
||
$db = new Database();
|
||
$db->query("START TRANSACTION;");
|
||
$save_successful = true;
|
||
foreach($credit_accounts as $ca)
|
||
{
|
||
// are there some deduct transfers?
|
||
if (empty($ca->transfer_id))
|
||
{
|
||
// no deduct entrance fee transfer means that nothing is already paid
|
||
$already_paid = 0;
|
||
}
|
||
else
|
||
{
|
||
// some transfers already exist, then their total amount is calculated
|
||
$already_paid = $account_model->get_amount_of_device_fees($ca->id);
|
||
}
|
||
// is already whole entrance fee paid?
|
||
if ($already_paid >= $ca->entrance_fee)
|
||
// total amount of already repaied transfers
|
||
$already_paid = $account_model->get_amount_of_device_fees($ca->id);
|
||
// is all device repayments already paid?
|
||
if ($already_paid >= $ca->total_price)
|
||
continue;
|
||
// entrance fee is not wholy paid, calculate debt
|
||
$debt = $ca->entrance_fee - $already_paid;
|
||
// entrance date of current member
|
||
$entrance = date_parse($ca->entrance_date);
|
||
$eyear = $entrance['year'];
|
||
$emonth = $entrance['month'];
|
||
// device repayment is not wholy paid, calculate debt
|
||
$debt = $ca->total_price - $already_paid;
|
||
// gets all devices including their buy dates and payment rates
|
||
$devices = $account_model->get_devices_of_account($ca->id);
|
||
// gets buy date of the first device
|
||
$buy_date = date_parse($devices->current()->buy_date);
|
||
$year = $buy_date['year'];
|
||
$month = $buy_date['month'];
|
||
// getting boundary date - 15th day in the month
|
||
$date = date('Y-m-d', mktime(0, 0, 0, $emonth, 15, $eyear));
|
||
$date = date('Y-m-d', mktime(0, 0, 0, $month, 15, $year));
|
||
// while debt is greater than zero and date of instalment is lower than current date
|
||
while ($debt > 0 && $date < date('Y-m-d'))
|
||
{
|
||
//echo "date $date<br>";
|
||
// calculate total payment rate for current month
|
||
$payment_rate = 0;
|
||
foreach ($devices as $device)
|
||
{
|
||
// find finishing date of repayments for given device
|
||
$bd = date_parse($device->buy_date);
|
||
$y = $bd['year'];
|
||
$m = $bd['month'];
|
||
$d = date('Y-m-d', mktime(0, 0, 0, $m, 15, $y));
|
||
// payments
|
||
$payments = 0;
|
||
while ($device->price > $payments)
|
||
{
|
||
$payments += $device->payment_rate;
|
||
// iterate to next month
|
||
$m++;
|
||
if ($m == 13)
|
||
{
|
||
$m = 1;
|
||
$y++;
|
||
}
|
||
// getting boundary date - 15th day in the month
|
||
$d = date('Y-m-d', mktime(0, 0, 0, $m, 15, $y));
|
||
echo "payments $payments<br>";
|
||
}
|
||
echo "buy date $device->buy_date, current date $date, end date $d<br>";
|
||
// is current date between buying of device and date of its full repayment?
|
||
if ($device->buy_date <= $date && $date <= $d)
|
||
$payment_rate += $device->payment_rate;
|
||
echo "payment rate $payment_rate<br>";
|
||
}
|
||
|
||
|
||
// is debt still greater than one monthly instalment?
|
||
if ($debt > $ca->debt_payment_rate)
|
||
if ($debt > $payment_rate)
|
||
{
|
||
// one monthly instalment is deducted
|
||
$amount = $ca->debt_payment_rate;
|
||
// if debt pay rate is zero, then whole amount of debt is deducted
|
||
if ($amount <= 0)
|
||
$amount = $debt;
|
||
$amount = $payment_rate;
|
||
}
|
||
else
|
||
{
|
||
$amount = $debt;
|
||
}
|
||
|
||
echo "<strong>date $date, amount $amount</strong><br>";
|
||
|
||
// decrease amount of debt due to size of one instalment
|
||
$debt -= $amount;
|
||
// create new transfer
|
||
$transfer = new Transfer_Model();
|
||
$transfer->origin_id = $ca->id;
|
||
$transfer->destination_id = $infrastructure->id;
|
||
$transfer->user_id = $this->session->get('user_id');
|
||
$transfer->type = Transfer_Model::$deduct_entrance_fee;
|
||
$transfer->datetime = $date;
|
||
$transfer->creation_datetime = $creation_datetime;
|
||
$transfer->text = url_lang::lang('texts.Entrance fee');
|
||
$transfer->amount = $amount;
|
||
if (!$transfer->save())
|
||
$save_successful = false;
|
||
|
||
//$transfer = ORM::factory('transfer')->where(array('type' => Transfer_Model::$deduct_device_fee, 'amount' => $amount,
|
||
// 'origin_id' => $ca->id, 'datetime' => $date))->find();
|
||
$db = new Database();
|
||
$transfers = $db->query("SELECT id FROM transfers WHERE type = ".Transfer_Model::$deduct_device_fee." AND amount = $amount AND origin_id = $ca->id AND datetime LIKE '%$date%'");
|
||
|
||
if ($amount > 0 && count($transfers) == 0)
|
||
{
|
||
// create new transfer
|
||
$transfer = new Transfer_Model();
|
||
$transfer->origin_id = $ca->id;
|
||
$transfer->destination_id = $operating->id;
|
||
$transfer->user_id = $this->session->get('user_id');
|
||
$transfer->type = Transfer_Model::$deduct_device_fee;
|
||
$transfer->datetime = $date;
|
||
$transfer->creation_datetime = $creation_datetime;
|
||
$transfer->text = url_lang::lang('texts.Device repayments');
|
||
$transfer->amount = $amount;
|
||
if (!$transfer->save())
|
||
$save_successful = false;
|
||
}
|
||
// iterate to next month
|
||
$emonth++;
|
||
if ($emonth == 13)
|
||
$month++;
|
||
if ($month == 13)
|
||
{
|
||
$emonth = 1;
|
||
$eyear++;
|
||
$month = 1;
|
||
$year++;
|
||
}
|
||
// getting boundary date - 15th day in the month
|
||
$date = date('Y-m-d', mktime(0, 0, 0, $emonth, 15, $eyear));
|
||
$date = date('Y-m-d', mktime(0, 0, 0, $month, 15, $year));
|
||
}
|
||
}
|
||
//die();
|
||
if ($save_successful)
|
||
{
|
||
$db->query("COMMIT;");
|
freenetis/trunk/kohana/application/controllers/redirect.php | ||
---|---|---|
$grid->add_new_button(url_lang::base().'messages/show_all', url_lang::lang('texts.Messages for redirection'));
|
||
$grid->add_new_button(url_lang::base().'redirect/show_all', url_lang::lang('texts.Active Redirections'));
|
||
$grid->add_new_button(url_lang::base().'redirect/settings', url_lang::lang('texts.Settings'));
|
||
$grid->order_field('ip_address')->label(url_lang::lang('texts.IP address'));
|
||
$grid->order_callback_field('ip_address')->label(url_lang::lang('texts.IP address'))->callback('Ip_addresses_Controller::ip_address_field');
|
||
$grid->order_field('name')->label(url_lang::lang('texts.Redirection'));
|
||
$grid->order_field('datetime')->label(url_lang::lang('texts.Date and time'));
|
||
/*
|
freenetis/trunk/kohana/application/views/form.php | ||
---|---|---|
<h2><?php echo $headline ?></h2>
|
||
<?php
|
||
if (isset($message) || ($message = $this->session->get('message')))
|
||
echo empty($message) ? '' : '<div class="message">'.$message.'</div>';
|
||
$message = $this->session->get('message');
|
||
echo empty($message) ? '' : '<div class="message">'.$message.'</div>';
|
||
?>
|
||
<?php echo (!$this->popup) ? $link_back : '' ?>
|
||
<br /><br />
|
freenetis/trunk/kohana/application/views/menu.php | ||
---|---|---|
echo html::anchor(url_lang::base().'members/show/'.$this->session->get('member_id'), url_lang::lang('texts.My profile'));
|
||
else
|
||
echo html::anchor(url_lang::base().'users/show/'.$this->session->get('user_id'), url_lang::lang('texts.My profile')); ?></li>
|
||
<?php if ($this->acl_check_view('Users_Controller', 'users',$this->session->get('member_id'))) { ?>
|
||
<?php /* if ($this->acl_check_view('Users_Controller', 'users',$this->session->get('member_id'))) { ?>
|
||
<li><?php echo html::anchor(url_lang::base().'users/show_by_member/'.$this->session->get('member_id'), url_lang::lang('texts.My users')) ?></li>
|
||
<?php } ?>
|
||
<?php } */ ?>
|
||
<?php if ($this->acl_check_view('Accounts_Controller', 'transfers',$this->session->get('member_id')) && $this->session->get('member_id') != 1) {
|
||
$account = ORM::factory('account')->find_by_member_id($this->session->get('member_id')); ?>
|
||
<li><?php echo html::anchor(url_lang::base().'transfers/show_by_account/'.$account->id, url_lang::lang('texts.My transfers')) ?></li>
|
||
... | ... | |
</ul>
|
||
</li>
|
||
|
||
<?php if ($this->acl_check_view('Members_Controller', 'members')) { ?>
|
||
<li class="users"><h2><?php echo url_lang::lang('texts.Users') ?></h2>
|
||
<ul>
|
||
<li><?php echo html::anchor(url_lang::base().'members', url_lang::lang('texts.Members')) ?></li>
|
||
<li><?php echo html::anchor(url_lang::base().'users', url_lang::lang('texts.Users')) ?></li>
|
||
</ul>
|
||
</li>
|
||
<?php } ?>
|
||
|
||
<?php
|
||
/*
|
||
... | ... | |
</li>
|
||
<?php } ?>
|
||
|
||
<?php if ($this->acl_check_view('Members_Controller', 'members')) { ?>
|
||
<li class="users"><h2><?php echo url_lang::lang('texts.Users') ?></h2>
|
||
<ul>
|
||
<li><?php echo html::anchor(url_lang::base().'members', url_lang::lang('texts.Members')) ?></li>
|
||
<li><?php echo html::anchor(url_lang::base().'users', url_lang::lang('texts.Users')) ?></li>
|
||
</ul>
|
||
</li>
|
||
<?php } ?>
|
||
|
||
<?php if ($this->acl_check_view('Devices_Controller', 'devices')) { ?>
|
||
<li class="networks"><h2><?php echo url_lang::lang('texts.Networks') ?></h2>
|
||
<ul>
|
||
<li><?php echo html::anchor(url_lang::base().'ip_addresses', url_lang::lang('texts.IP addresses')) ?></li>
|
||
<li><?php echo html::anchor(url_lang::base().'subnets', url_lang::lang('texts.Subnets')) ?></li>
|
||
<li><?php echo html::anchor(url_lang::base().'devices', url_lang::lang('texts.Devices')) ?></li>
|
||
<li><?php echo html::anchor(url_lang::base().'ifaces', url_lang::lang('texts.Interfaces')) ?></li>
|
||
<li><?php echo html::anchor(url_lang::base().'segments', url_lang::lang('texts.Segments')) ?></li>
|
||
<li><?php echo html::anchor(url_lang::base().'ifaces', url_lang::lang('texts.Interfaces')) ?></li>
|
||
<li><?php echo html::anchor(url_lang::base().'ports', url_lang::lang('texts.Ports')) ?></li>
|
||
<li><?php echo html::anchor(url_lang::base().'vlan_ifaces', url_lang::lang('texts.Vlan interfaces')) ?></li>
|
||
<li><?php echo html::anchor(url_lang::base().'vlans', url_lang::lang('texts.Vlans')) ?></li>
|
||
<li><?php echo html::anchor(url_lang::base().'ip_addresses', url_lang::lang('texts.IP addresses')) ?></li>
|
||
<li><?php echo html::anchor(url_lang::base().'subnets', url_lang::lang('texts.Subnets')) ?></li>
|
||
<?php if ($this->acl_check_view('VoIP_Controller', 'voip')) { ?>
|
||
<li><?php echo html::anchor(url_lang::base().'voip', url_lang::lang('texts.VoIP')) ?></li>
|
||
<?php } ?>
|
||
... | ... | |
<?php if ($this->acl_check_view('Settings_Controller', 'system') || $this->acl_check_view('Address_points_Controller', 'address_point')) { ?>
|
||
<li class="administration"><h2><?php echo url_lang::lang('texts.Administration') ?></h2>
|
||
<ul>
|
||
<?php if ($this->acl_check_view('Address_points_Controller', 'address_point')) {?>
|
||
<li><?php echo html::anchor(url_lang::base().'address_points', url_lang::lang('texts.Address points')) ?></li>
|
||
<?php if ($this->acl_check_view('Settings_Controller', 'system')) { ?>
|
||
<li><?php echo html::anchor(url_lang::base().'settings', url_lang::lang('texts.Settings')) ?></li>
|
||
<?php } ?>
|
||
<?php if ($this->acl_check_view('Messages_Controller', 'message')) {?>
|
||
<li><?php echo html::anchor(url_lang::base().'messages', url_lang::lang('texts.Redirection')) ?></li>
|
||
<?php } ?>
|
||
<?php if ($this->acl_check_view('Address_points_Controller', 'address_point')) {?>
|
||
<li><?php echo html::anchor(url_lang::base().'address_points', url_lang::lang('texts.Address points')) ?></li>
|
||
<?php } ?>
|
||
<?php if ($this->acl_check_2D('freenetis', 'write_email')) {?>
|
||
<li><?php echo html::anchor(url_lang::base().'sms', url_lang::lang('texts.SMS messages')) ?></li>
|
||
<?php } ?>
|
||
<?php if ($this->acl_check_view('Settings_Controller', 'system')) { ?>
|
||
<li><?php echo html::anchor(url_lang::base().'settings', url_lang::lang('texts.Settings')) ?></li>
|
||
<li><?php echo html::anchor(url_lang::base().'approval_templates', url_lang::lang('texts.Approval')) ?></li>
|
||
<li><?php echo html::anchor(url_lang::base().'access_rights', url_lang::lang('texts.Access rights')) ?></li>
|
||
<li><?php echo html::anchor(url_lang::base().'fees', url_lang::lang('texts.Fees')) ?></li>
|
freenetis/trunk/kohana/application/views/show_all.php | ||
---|---|---|
<?php
|
||
echo "<h2>$headline</h2>";
|
||
if (isset($message))
|
||
{
|
||
echo empty($message) ? '' : '<div class="message">'.$message.'</div>';
|
||
}
|
||
$message = $this->session->get('message');
|
||
echo empty($message) ? '' : '<div class="message">'.$message.'</div>';
|
||
if (isset($link_back)) echo "$link_back<br/>";
|
||
if (isset($create)) echo $create;
|
||
echo "<br/>$table";
|
Také k dispozici: Unified diff
Dodelano strhavani splatek zarizeni. Zmena organizace menu. Uprava obecnych view form a show_all pro automaticke zobrazovani flash_message. Synchronizace presmerovani.