Projekt

Obecné

Profil

« Předchozí | Další » 

Revize 504

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

Dodelano hromadne nastaveni presmerovani u clenu, je to bomba! Umi to ted presmerovat dle vyberu vsechny dluzniky, prerusene clenstvi, pripadne upozornit vsechny, kterym vyprsi brzy kredit. Totez dodelano i v scheduleru, to znamena staci, si spravne nastavit na server cron a tyto kroky delat automaticky. V zarizenich pridana dalsi vychytavka - pri pridavani to predvyplni technika uz existujiciho zarizeni.

Zobrazit rozdíly:

freenetis/trunk/kohana/application/i18n/cs_CZ/texts.php
'channel' => 'Kanál',
'i accept this message and i want to cancel this redirection' => 'Beru na vědomí tuto zprávu a chci zrušit toto přesměrování',
'id' => 'ID',
'if you were redirected, wait and redirection will stop in one minute' => 'Pokud jste byli přesměrováni, počkejte a přesměrování do jedné minuty skončí.',
'ignore' => 'Ignorovat',
'import dhcp export from mikrotik' => 'Import exportu DHCP z Mikrotiku',
'import has been successfully finished' => 'Import byl úspěšně dokončen.',
......
'surname' => 'Příjmení',
'system' => 'Systém',
'system administrators' => 'Systémoví administrátoři',
'system has not found reason to this redirection, this should not happen in ordinary running' => 'Systém nenašel důvod pro toto přesměrování, toto by se nemělo stát při běžném provozu.',
'system users' => 'Systémoví uživatelé',
'system variables' => 'Systémové proměnné',
'system variables have been successfully updated' => 'Systémové proměnné byly úspěšně aktualizovány',
......
'voip number must be a number' => 'VoIP číslo musí být číslo',
'warning' => 'Varování',
'website after redirection' => 'Webová stránka po přesměrování',
'without change' => 'Beze změny',
'work' => 'Práce',
'work confirmation' => 'Potvrzení práce',
'work has been successfully added' => 'Práce byla úspěšně přidána',
freenetis/trunk/kohana/application/models/member.php
)->current();
}
/**
* Function sets redirection to members, who have to pay their member fee soon
* or their's credit account will be negative. Used in scheduler/run/payment_notice.
* @author Jiri Svitak
* @return unknown_type
*/
public function update_payment_notice($amount)
{
// preparation
self::$db->query("UPDATE members SET redirect = redirect & ~4;");
// setting redirection
self::$db->query("
UPDATE members m,
(
SELECT (q3.inbound - q3.outbound) AS balance, q3.mid
FROM
(
SELECT SUM(t.amount) AS outbound, q2.inbound, q2.mid
FROM
(
SELECT SUM(t.amount) AS inbound, q1.aid, q1.mid
FROM
(
SELECT a.id AS aid, m.id AS mid
FROM accounts a
JOIN members m ON m.id = a.member_id
WHERE m.id <> 1
) q1
LEFT JOIN transfers t ON t.destination_id = q1.aid
GROUP BY q1.aid
) q2
LEFT JOIN transfers t ON t.origin_id = q2.aid
GROUP BY q2.aid
) q3
) q
SET m.redirect = m.redirect | 4
WHERE $amount >= q.balance AND m.id = q.mid
");
}
/**
* Function sets debtor redirection to members who have their current credit is negative.
* @author Jiri Svitak
* @return unknown_type
*/
public function update_debtors()
{
// preparation
self::$db->query("UPDATE members SET redirect = redirect & ~2;");
// setting redirection
self::$db->query("
UPDATE members m,
(
SELECT (q3.inbound - q3.outbound) AS balance, q3.mid
FROM
(
SELECT SUM(t.amount) AS outbound, q2.inbound, q2.mid
FROM
(
SELECT SUM(t.amount) AS inbound, q1.aid, q1.mid
FROM
(
SELECT a.id AS aid, m.id AS mid
FROM accounts a
JOIN members m ON m.id = a.member_id
WHERE m.id <> 1
) q1
LEFT JOIN transfers t ON t.destination_id = q1.aid
GROUP BY q1.aid
) q2
LEFT JOIN transfers t ON t.origin_id = q2.aid
GROUP BY q2.aid
) q3
) q
SET m.redirect = m.redirect | 2
WHERE q.balance < 0 AND m.id = q.mid
");
}
/**
* Function sets membership interrupt redirection to all members who interrupted their membership.
* @author Jiri Svitak
* @return unknown_type
*/
public function update_membership_interrupts()
{
// preparation
self::$db->query("UPDATE members SET redirect = redirect & ~1;");
// setting redirection
self::$db->query("
UPDATE members m,
(
SELECT m.id as mid
FROM members m
JOIN membership_interrupts mi ON mi.member_id = m.id
WHERE mi.from <= CURDATE() AND CURDATE() <= mi.to
) mi
SET m.redirect = m.redirect | 1
WHERE m.id = mi.mid
");
}
/**
* Function sets optional message to all members.
* @author Jiri Svitak
* @return unknown_type
*/
public function update_optional_message()
{
// setting redirection
self::$db->query("UPDATE members SET redirect = redirect | 8;");
}
/**
* Function cancels redirection of given number.
* @author Jiri Svitak
* @param $number
* @return unknown_type
*/
public function cancel_redirection($number)
{
self::$db->query("UPDATE members SET redirect = redirect & ~$number");
}
}
?>
freenetis/trunk/kohana/application/models/device_engineer.php
ORDER BY id asc
");
}
/**
* Function gets engineer of user. Used in devices/add and devices/add_whole to prefill engineer field.
* @param $user_id
* @return unknown_type
*/
public function get_engineer_of_user($user_id)
{
return self::$db->query("SELECT de.user_id AS id
FROM device_engineers de
JOIN devices d ON d.id = de.device_id
WHERE d.user_id = $user_id
ORDER BY de.id asc
")->current();
}
}
?>
freenetis/trunk/kohana/application/controllers/redirect.php
// no reason to redirect, this shouldn't happen
else
{
$content = url_lang::lang('texts.System has not found reason to this redirection, this should not happen in ordinary running.').' '.
url_lang::lang('texts.If you were redirected, wait and redirection will stop in one minute.');
// so if there is no reason, then member is from these pages redirected to defined website
url::redirect($this->setting->website_after_redirection);
}
// engineer of user's device, owner of ip address - if available
if ($ip_address->id != 0)
......
// access rights
if (!$this->acl_check_edit('Members_Controller', 'redirect'))
Controller::error(ACCESS);
$array[0] = url_lang::lang('texts.No');
$array[0] = url_lang::lang('texts.Without change');
$array[1] = url_lang::lang('texts.Yes');
$array[2] = url_lang::lang('texts.No');
// form
$form = new Forge(url_lang::base().'redirect/members', '', 'POST', array('id' => 'article_form'));
$form->set_attr('class', 'form_class')->set_attr('method', 'post');
$form->group('')->label(url_lang::lang('texts.Redirection'));
//$form->dropdown('payment_notice')->label(url_lang::lang('texts.Payment notice').':')->options($array)->selected(0);
$form->dropdown('interrupt')->label(url_lang::lang('texts.Membership interrupt').':')->options($array)->selected(0);
$form->dropdown('debtor')->label(url_lang::lang('texts.Debtor').':')->options($array)->selected(0);
$form->dropdown('payment_notice')->label(url_lang::lang('texts.Payment notice').':')->options($array)->selected(0);
$form->dropdown('optional_message')->label(url_lang::lang('texts.Optional message').':')->options($array)->selected(0);
$form->submit('submit')->value(url_lang::lang('texts.Redirect'));
special::required_forge_style($form, ' *', 'required');
......
if ($form->validate())
{
$form_data = $form->as_array();
// direct database queries are much more faster
$db = new Database();
// canceling payment notice and optional message redirection
//$db->query("UPDATE members SET redirect = redirect & ~12;");
//if ($form_data['payment_notice'] == 1)
// $db->query("UPDATE members SET redirect = redirect | 4;");
// canceling optional message redirection
$db->query("UPDATE members SET redirect = redirect & ~8");
$member_model = new Member_Model();
// membership interrupt
if ($form_data['interrupt'] == 1)
$member_model->update_membership_interrupts();
elseif ($form_data['interrupt'] == 2)
$member_model->cancel_redirection(1);
// debtor
if ($form_data['debtor'] == 1)
$member_model->update_debtors();
elseif ($form_data['debtor'] == 2)
$member_model->cancel_redirection(2);
// payment notice
if ($form_data['payment_notice'] == 1)
{
$fee_model = new Fee_Model();
$fee = $fee_model->get_by_date_type(date('Y-m-d'), 'regular member fee');
if ($fee->id)
$current_fee = $fee->fee;
$member_model->update_payment_notice(2 * $current_fee);
}
elseif ($form_data['payment_notice'] == 2)
$member_model->cancel_redirection(4);
// optional message
if ($form_data['optional_message'] == 1)
$db->query("UPDATE members SET redirect = redirect | 8;");
$member_model->update_optional_message();
elseif ($form_data['optional_message'] == 2)
$member_model->cancel_redirection(8);
$this->session->set_flash('message', url_lang::lang('texts.Redirection has been successfully set.'));
url::redirect(url_lang::base().'members/show_all');
}
freenetis/trunk/kohana/application/controllers/bank_transfers.php
$tf->amount = $fee->fee;
$transfer_fee_saved = $tf->save();
}
// identification of transfer and bank fee
// identification of transfer
$transfer->member_id = $member->id;
$transfer_saved = $transfer->save();
// identification of bank fee
if ($form_data['bank_transfer_fee'] > 0)
{
$btf->member_id = $member->id;
$btf_saved = $btf->save();
}
// identification of origin bank account
if (!isset($counter_ba->member_id))
{
$counter_ba->member_id = $member->id;
$counter_ba->save();
}
}
}
// everything successful - setting message and redirection
// everything successful
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'));
freenetis/trunk/kohana/application/controllers/scheduler.php
{
if (!isset($type))
Controller::warning(PARAMETER);
if (server::remote_addr() != '127.0.0.1')
$ip = server::remote_addr();
if ($ip != '127.0.0.1')
if (!$this->acl_check_edit('Devices_Controller', 'redirect'))
die();
$member_model = new Member_Model();
switch($type)
{
case 'payment_notice':
case 'update_payment_notice':
$fee_model = new Fee_Model();
$fee = $fee_model->get_by_date_type(date('Y-m-d'), 'regular member fee');
if ($fee->id)
$current_fee = $fee->fee;
$member_model->update_payment_notice($current_fee * 2);
break;
case 'update_debtors':
$member_model->update_debtors();
break;
case 'update_membership_interrupts':
$member_model->update_membership_interrupts();
break;
}
}
}
freenetis/trunk/kohana/application/controllers/devices.php
*/
function add($user_id = null)
{
$user_model = new User_Model();
// if the device is added to given user, then only one user will be to select
$selected_engineer = $this->session->get('user_id');
if(isset($user_id))
{
$user = new User_Model($user_id);
if ($user->id == 0)
Controller::error(RECORD);
Controller::error(RECORD);
if (!$this->acl_check_new('Devices_Controller', 'devices', $user->member_id))
Controller::error(ACCESS);
$selected = $user->id;
$selected_GPS = $user->member->address_point->GPS;
$selected_street_id = $user->member->address_point->street_id;
$selected_street_number = $user->member->address_point->street_number;
$selected_town_id = $user->member->address_point->town_id;
$device_engineer_model = new Device_engineer_Model();
$found_engineer = $device_engineer_model->get_engineer_of_user($user->id);
if ($found_engineer)
$selected_engineer = $found_engineer->id;
$arr_users[$user->id] = $user->surname.' '.$user->name.' - '.$user->login;
}
else
{
if (!$this->acl_check_new('Devices_Controller', 'devices'))
Controller::error(ACCESS);
$users = $user_model->select('id','name','surname','login')->orderby('id')->find_all();
$arr_users[0] = '----- '.url_lang::lang('texts.select user').' -----';
$selected = 0;
......
$form->input('street_number')->label(url_lang::lang('texts.street number').':')->rules('length[1,50]|valid_numeric')->value($selected_street_number);
$form->dropdown('town_id')->label(url_lang::lang('texts.town').':')->rules('required')->options($arr_towns)->selected($selected_town_id);
$form->textarea('comment')->label(url_lang::lang('texts.comment').':')->rules('length[0,254]');
$form->dropdown('first_engineer_id')->label(url_lang::lang('texts.engineer').':')->options($arr_engineers)->rules('required')->selected($this->session->get('user_id'));
$form->dropdown('first_engineer_id')->label(url_lang::lang('texts.engineer').':')->options($arr_engineers)->rules('required')->selected($selected_engineer);
$form->submit('submit')->value(url_lang::lang('texts.Save'));
special::required_forge_style($form, ' *', 'required');
......
// if the device is added to given user, then only one user will be to select
$selected_segment = 0;
$selected_subnet = 0;
$selected_engineer = $this->session->get('user_id');
if(isset($user_id))
{
$user = new User_Model($user_id);
if ($user->id == 0)
Controller::error(RECORD);
Controller::error(RECORD);
if (!$this->acl_check_new('Devices_Controller', 'devices', $user->member_id))
Controller::error(ACCESS);
$selected = $user->id;
$selected_GPS = $user->member->address_point->GPS;
$selected_street_id = $user->member->address_point->street_id;
$selected_street_number = $user->member->address_point->street_number;
$selected_town_id = $user->member->address_point->town_id;
$segment = new Segment_Model();
$found_segment = $segment->get_segment_of_user($user->id);
$segment_model = new Segment_Model();
$found_segment = $segment_model->get_segment_of_user($user->id);
if ($found_segment)
$selected_segment = $found_segment->id;
$subnet = new Subnet_Model();
$found_subnet = $subnet->get_subnet_of_user($user->id);
$subnet_model = new Subnet_Model();
$found_subnet = $subnet_model->get_subnet_of_user($user->id);
if ($found_subnet)
$selected_subnet = $found_subnet->id;
$device_engineer_model = new Device_engineer_Model();
$found_engineer = $device_engineer_model->get_engineer_of_user($user->id);
if ($found_engineer)
$selected_engineer = $found_engineer->id;
$arr_users[$user->id] = $user->surname.' '.$user->name.' - '.$user->login;
}
else
{
if (!$this->acl_check_new('Devices_Controller', 'devices'))
Controller::error(ACCESS);
$users = $user_model->select('id','name','surname','login')->orderby('id')->find_all();
$arr_users[0] = '----- '.url_lang::lang('texts.select user').' -----';
$selected = 0;
......
$arr_engineers[$engineer->id] = $engineer->surname.' '.$engineer->name.' - '.$engineer->login;
}
$form->dropdown('first_engineer_id')->label(url_lang::lang('texts.engineer').':')->options($arr_engineers)->rules('required')->selected($this->session->get('user_id'));
$form->dropdown('first_engineer_id')->label(url_lang::lang('texts.engineer').':')->options($arr_engineers)->rules('required')->selected($selected_engineer);
// adding interface
$form->group('')->label(url_lang::lang('texts.Interface'));

Také k dispozici: Unified diff