Projekt

Obecné

Profil

« Předchozí | Další » 

Revize 1945

Přidáno uživatelem Michal Kliment před více než 11 roky(ů)

Opravy:
- fixes #590: Automaticke prepocitani kreditu clena
- fixes #591: Splatky vstupniho prispevku na profilu clena
- fixes #592: Aktualni vyse mesicniho clenskeho prispevku na profilu clena

Zobrazit rozdíly:

freenetis/branches/1.1/application/i18n/cs_CZ/texts.php
'error - cannot export invoice with no items' => 'Chyba - nelze exportovat fakturu bez položek',
'error - cannot load intelligent selection' => 'Chyba - nelze načíst inteligentní výběr',
'error - cannot update message' => 'Chyba - nelze upravit zprávu.',
'error - cannot recalculate fees' => 'Chyba - nelze přepočítat příspěvky.',
'error - cannot remove admin of cloud' => 'Chyba - nelze odebrat admina oblasti',
'error - cannot remove device from monitoring' => 'Chyba - nelze odstranit zařízení z monitoringu.',
'error - cannot save data' => 'Chyba - nelze uložit data.',
......
'membership interrupt' => 'Přerušení členství',
'membership interrupt text' => 'Text pro přerušení členství',
'membership interrupts' => 'Přerušená členství',
'membership interruption has been succesfully added' => 'Přerušení členství bylo úspěšně přidáno',
'membership interruption has been succesfully deleted' => 'Přerušení členství bylo úspěšně smazáno',
'membership interruption has been succesfully updated' => 'Přerušení členství bylo úspěšně aktualizováno',
'membership interrupt has been succesfully added' => 'Přerušení členství bylo úspěšně přidáno',
'membership interrupt has been succesfully deleted' => 'Přerušení členství bylo úspěšně smazáno',
'membership interrupt has been succesfully updated' => 'Přerušení členství bylo úspěšně aktualizováno',
'membership of the member has been ended' => 'Členství člena bylo ukončeno.',
'membership of the member has been successfully restored' => 'Členství člena bylo úspěšně obnoveno.',
'membership transfer can be only from former member without debt' => 'Převod členství může být pouze od bývalého člena bez dluhu.',
......
'password for voip account' => 'Heslo pro VoIP účet',
'password has been successfully changed' => 'Heslo bylo úspěšně změněno.',
'path' => 'Cesta',
'paid amount from entrance' => 'Zaplacená částka z vstupního',
'pay from account' => 'Platit z účtu',
'payed to' => 'Zaplaceno do',
'payed to %s' => 'Zaplaceno do %s',
......
'receiver' => 'Příjemce',
'receiver type' => 'Typ příjemce',
'recorded' => 'Zaznamenáno',
'recount of device repayments' => 'Přepočítání splátek zařízení',
'recount of member fees' => 'Přepočítání členských příspěvků',
'recount of entrance fees' => 'Přepočítání vstupních příspěvků',
'recount of fees' => 'Přepočítání příspěvků',
'redir' => 'Přesm',
'redirect' => 'Přesměrovat',
'redirect ip address' => 'Přesměrovat IP adresu',
......
'rejected works' => 'Zamítnuté práce',
'rejected work reports' => 'Zamítnuté prácovní výkazy',
'rejected by' => 'Zamítnul(a)',
'remaining amount from entrance' => 'Zbývající částka z vstupního',
'remove' => 'Odebrat',
'remove broadcast ip address' => 'Odebrat IP adresu broadcastu',
'remove device from monitoring' => 'Odebrat zařízení z monitoringu',
freenetis/branches/1.1/application/i18n/cs_CZ/help.php
'entrance_date' => 'Datum vstupu do sdružení. Se vstupem do sdružení je člen povinen platit členské příspěvky. V případě, že člen vstoupil do %d. dne v měsíci včetně, tak již tento měsíc se započítává k placení.',
'entrance_fee' => 'Vstupní poplatek je jednorázový členský příspěvek, který je člen povinen zaplatit při vstupu do sdružení kromě případů, kdy je mu odpuštěn.',
'entrance_fee_instalment' => 'Splátka vstupního příspěvku je pro případ, kdy člen chce splácet vstupní příspěvek postupně. Zde nastavená částka mu bude každý měsíc stržena z jeho kreditního účtu. Pokud nechcete splátky využít, nechte výši splátky rovnu výši vstupního příspěvku.',
'entrance_fee_left' => 'Zobrazuje zbývající částku k zaplacení ze vstupního příspěvku.',
'entrance_fee_paid' => 'Zobrazuje součet již stržených splátek vstupního příspěvku.',
'fio_account_number' => 'Číslo Fio účtu, vyplňujte bez kódu banky.',
'fio_import_daily' => 'Umožňuje zapnout automatický import Fio výpisů ve formátu CSV přímo z internetového bankovnictví. Je potřeba vyplnit uživatelské jméno a heslo, číslo účtu (bez kódu banky) a jméno pohledu. Import se provádí vždy v 1:00 a importuje všechny položky od doby importu posledního výpisu po právě skončený včerejšek. Oproti manuálnímu importu CSV souboru, kde je vidět okamžitý výsledek importu, je zde potřeba občas kontrolovat občas výsledek, zda vše probíhá správně.',
'fio_password' => 'Heslo pro daného uživatele do internetového bankovnictví. Zvažte bezpečnostní riziko spojené s ukládáním hesla od internetového bankovnictví na server s Freenetisem.',
......
'monitoring_notification_up_host_interval' => 'Určuje do kolika minut od znovu funkčnosti zařízení se bude zasílat upozornění. Výchozí hodnota je 5, pro zakázání zasílání nastavte 0.',
'monitoring_notification_interval' => 'Jedná se o interval opakování upozornění v minutách. Výchozí hodnota je 1 (upozorňovat se bude každou minutu).',
'monitoring_server_ip_address' => 'Jedná se o IP adresu počítače, na kterém běží skript freenetis-monitor. IP adresa se používá pro omezení přístupu na vstupní/výstupní data.',
'monthly_member_fee' => 'Zobrazuje výši aktuálního měsíčního členského příspěvku člena. Tato částka je každý měsíc členovi stržena z kreditu.',
'multiple_dropdown' => 'Více hodnot lze vybrat označení myší se stiknutou klávesou CTRL.',
'never_redirect' => 'Zapnete-li tuto volbu, pak nebude možné tuto IP adresu nikdy přesměrovat běžným přesměrováním. Toto je vhodné zejména pro významné partnery jako jsou úřady, školy atd.',
'notification_settings' => 'Na této stránce můžete nastavit přesměrování a posílání zpráv členům.<br>Aktivovat - povolit přesměrování nebo odeslání zprávy členovi.<br>Beze změny - neměnit nastavení přesměrování nebo zakázání posílání zpráv.<br>Deaktivovat - zakázat přesměrování člena.<br>Text v políčku komentář nahradí tag {comment} v SMS a E-mailové zprávě.',
......
'redirection_port_self_cancel' => 'Port brány pro zrušení samozrušitelného přesměrování IP adresy.',
'recalculate_account_balances' => 'Primárním zdrojem o stavu financí v systému jsou převody. Zůstatky na účtech byly dříve pokaždé počítány na požádání z převodů. Nyní si každý účet ukládá svůj zůstatek kvůli vyšší rychlosti. Tuto funkci použijete v případě přechodu na verzi systému, která tuto optimalizaci obsahuje.',
'recalculate_device_fees' => 'Pro primární strhávání splátek zařízení používejte funkci pro globální strhávání v účetním deníku. Tuto funkci používejte jen v případě, že došlo k nějakému omylu.',
'recalculate_fees' => 'Pro primární strhávání členských příspěvků používejte funkci pro globální strhávání členských příspěvků v Účetním deníku. Tuto funkci používejte opatrně a to jen v případě, že máte správně strženy všechny členské příspěvky pro všechny členy od založení sdružení až po současné datum. Pak můžete tomuto členovi přepočítat stržení členských příspěvků v případě, že u něj došlo k nutnosti je přepočítat, např. chybné datum vstupu, vznikla nutnost přidat přerušení členství apod.',
'recalculate_fees' => 'Pro primární strhávání příspěvků používejte funkci pro globální strhávání příspěvků v Účetním deníku. Tuto funkci používejte pouze ve výjimečných případech.',
'recalculate_entrance_fees' => 'Pro primární strhávání vstupních příspěvků používejte funkci pro globální strhávání v účetním deníku. Tuto funkci používejte jen v případě, že došlo k nějakému omylu, například, že měl zaplatit vstupní a pak se ukázalo, že nemusel.',
'redirection_logo' => 'Jedná se o logo, které se zobrazí na stránce s přesměrováním. Rozměr by měl být 212x49px',
'redirection_preview' => 'Náhled zobrazí stránku přesně tak, jak se zobrazí dané IP adrese. V případě více aktivovaných přesměrování najednou pro jednu IP adresu se zobrazí jen to, které se členovi zobrazí jako první.',
freenetis/branches/1.1/application/i18n/en_US/help.php
'entrance_date' => 'Date of entry into the association. With the entry into the association is a member must pay membership dues. In the event that the member joined by %d including the day of the month, and already this month is counted for payment.',
'entrance_fee' => 'Entrance fee is a one-time membership fee, which member is obligated to pay at the entrance to the association unless it is forgiven.',
'entrance_fee_instalment' => 'Instalment initial contribution is for the case when a member wants to repay the initial contribution gradually. Here he set amount each month will be deducted from his credit account. If you do not use the installment, let the installment amount equal to the amount of initial contribution.',
'entrance_fee_left' => 'Shows remaining amount to pay from entrance fee.',
'entrance_fee_paid' => 'Shows sum of already deducted amounts of instalments of entrance fee.',
'gateway' => 'Determines whether an IP address in your subnet gateway. Typically this is set each IP address ending in the number one network prefix 24th',
'gps_coordinates' => 'GPS can be in shape of real number, or: hours°minutes\'seconds&quot.',
'grid_hide_on_first_load' => 'It determines whether hide grid and its items on its first load. It is used as optimalization of memory usage.',
......
'monitoring_notification_down_host_interval' => 'It determines for how many minutes from host failure will be send notification. Default valueis 10, to disable of sending notifications set 0.',
'monitoring_notification_up_host_interval' => 'It determines for how many minutes from host funcionality again will be send notification. Default valueis 5, to disable of sending notifications set 0.',
'monitoring_notification_interval' => 'It is interval of loop of notification in minutes. Default value is (notification will be every minute).',
'monthly_member_fee' => 'Shows value current monthly member fee of member. This amount is every month deducted from member\'s credit.',
'multiple_dropdown' => 'More values can be selected by mouse with triggered CTRL key.',
'never_redirect' => 'When you turn on this option, it is not possible to redirect an IP address never ordinary redirection. This is particularly suitable for major partners such as offices, schools, etc.',
'notification_settings' => 'On this page you can set redirection and sending messages to members.<br>Activate - enable redirection or sending messages to member.<br>Without change - don\'t change redirection setting or disable sending messages.<br>Deactivate - disable redirection for member.<br>Text in comment field will replace {comment} tag in SMS and E-mail message.',
......
'qos_rate' => 'It is a minimal (guarenteed) speed. The value may be written in shape XXXJ (XXX is a shared value for download and upload and J is a unit, e.g. 300M, 1G) or in shape XXXJ/YYYJ (where XXX is a value for download, YYY for upload and J is a unit, e.g. 100M/300M, 400M/1G).',
'qos_total_speed' => 'Is is the total speed (connectivity) of association. The value may be written in shape XXXJ (XXX is a shared value for download and upload and J is a unit, e.g. 300M, 1G) or in shape XXXJ/YYYJ (where XXX is a value for download, YYY for upload and J is a unit, e.g. 100M/300M, 400M/1G).',
'recalculate_account_balances' => 'The primary source of state finance in the system are transfers. Balances were previously calculated on every request from the transfers. Now each account stores your balance due to higher speeds. This function is use when upgrading to a system that includes this optimization.',
'recalculate_fees' => 'For primary entrainment function, use the membership fees for the global entrainment of membership fees in the Court diary. Use this function with caution and only in the event that you have correctly taken down all the membership dues for all members from the association to the current date. You can then convert this member stripped of membership fees in the event that for him there is the need to recalculate such as incorrect date of entry, it became necessary to add the suspension of its membership, etc.',
'recalculate_fees' => 'For primary entrainment function, use the fees for the global entrainment of fees in the Court diary. Use this function with caution and only in exceptional cases.',
'recalculate_entrance_fees' => 'For primary use posts input entrainment function for global entrainment in an accounting journal. Use this function only if there was any mistake, for example, that he had to pay the entrance and then it turned out that did not.',
'redirection_logo' => 'Is a logo that appears on redirection page. Image size should be 212x49px',
'redirection_preview' => 'Preview shows the page exactly as it appears that IP address. In the case of multiple simultaneously activated to redirect one IP address is displayed only thing that appears as a member first.',
freenetis/branches/1.1/application/vendors/redirection/freenetis-redirection.sh
#!/bin/bash
################################################################################
# #
# This script serves for redirection IP policy of IS FreenetIS #
# #
# author Sevcik Roman 2011 #
# email sevcik.roman@slfree.net #
# #
# name freenetis-redirection.sh #
# version 1.9.4 #
# #
################################################################################
# Load variables from config file
CONFIG=/etc/freenetis/freenetis-redirection.conf
# Local variable contains path to iptables - mandatory
IPTABLES=/sbin/iptables
# Local variable contains path to ipset - mandatory
IPSET=/usr/sbin/ipset
# Local variable contains path to wget - mandatory
WGET=/usr/bin/wget
# Path to HTTP 302 redirector
REDIRECTION_HTTP_REDIRECTOR=/usr/sbin/freenetis-http-302-redirection.py
# Path to HTTP 302 redirector
REDIRECTION_HTTP_REDIRECTOR_PIDFILE=/var/run/freenetis-http-302-redirection.pid
#Paths where temporary data will be saved.
PATH_ERRORS=`mktemp`
#Load variables
if [ -f ${CONFIG} ]; then
. $CONFIG;
else
echo "Config file is missing at path $CONFIG."
echo "Terminating..."
exit 0
fi
# Runs command and print result (OK = success, FAILED = error)
run_and_print_result ()
{
$@ 2> "$PATH_ERRORS"
if [ $? -eq 0 ];
then
echo "OK"
else
echo "FAILED! Error: $? "`cat "$PATH_ERRORS" | awk '{$1 = ""; print}'`
fi
}
# Tests whether iptables rule already exists
rule_exists ()
{
iptables-save | grep -q "$@"
if [ $? -eq 0 ];
then
echo 1
else
echo 0
fi
}
# Tests whether program is running
is_running ()
{
ps aux | grep -v grep | grep "$@" | wc -l
}
# Adds iptables rules
add_rules()
{
echo -n "Adding iptables rule for self canceling..."
#Rule for allowing access. If come packet to $IP_TARGET then we add source address do set allowed and to set seen
#Set seen is used for ip synchronization with FreenetIS.
if [ `rule_exists "PREROUTING -d $IP_TARGET/32 -i $INPUT_INTERFACE -p tcp -m set --match-set self_cancel src -m tcp --dport $PORT_SELF_CANCEL -j SET --add-set allowed src"` -eq 0 ];
then
run_and_print_result "$IPTABLES -i $INPUT_INTERFACE -t nat -A PREROUTING -m set --match-set self_cancel src -d $IP_TARGET -p tcp --dport $PORT_SELF_CANCEL -j SET --add-set allowed src"
else
echo "already added"
fi
echo -n "Adding iptables rule for allowed..."
#If IP is allowed then it is not redirected
if [ `rule_exists "PREROUTING -i $INPUT_INTERFACE -m set --match-set allowed src -j ACCEPT"` -eq 0 ];
then
run_and_print_result "$IPTABLES -i $INPUT_INTERFACE -t nat -A PREROUTING -m set --match-set allowed src -j ACCEPT"
else
echo "already added"
fi
echo -n "Adding iptables rule for redirection..."
#Redirect everything trafic what has destination port $PORT_WEB to $PORT_REDIRECT
if [ `rule_exists "PREROUTING -i $INPUT_INTERFACE -p tcp -m set --match-set ranges src -m tcp --dport $PORT_WEB -j REDIRECT --to-ports $PORT_REDIRECT"` -eq 0 ];
then
run_and_print_result "$IPTABLES -i $INPUT_INTERFACE -t nat -A PREROUTING -m set --match-set ranges src -p tcp --dport $PORT_WEB -j REDIRECT --to-port $PORT_REDIRECT"
else
echo "already added"
fi
echo -n "Adding iptables rule for allowed..."
#If IP is allowed then it is not redirected
if [ `rule_exists "FORWARD -i $INPUT_INTERFACE -m set --match-set allowed src -j ACCEPT"` -eq 0 ];
then
run_and_print_result "$IPTABLES -i $INPUT_INTERFACE -I FORWARD 1 -m set --match-set allowed src -j ACCEPT"
else
echo "already added"
fi
echo -n "Adding iptables rule for block others..."
#Else everything drop
if [ `rule_exists "FORWARD -i $INPUT_INTERFACE -m set --match-set ranges src -j DROP"` -eq 0 ];
then
run_and_print_result "$IPTABLES -i $INPUT_INTERFACE -I FORWARD 2 -m set --match-set ranges src -j DROP"
else
echo "already added"
fi
}
# Deletes iptables rules
delete_rules()
{
echo -n "Deleting iptables rule for self canceling..."
#Rule for allowing access. If come packet to $IP_TARGET then we add source address do set allowed and to set seen
#Set seen is used for ip synchronization with FreenetIS.
if [ `rule_exists "PREROUTING -d $IP_TARGET/32 -i $INPUT_INTERFACE -p tcp -m set --match-set self_cancel src -m tcp --dport $PORT_SELF_CANCEL -j SET --add-set allowed src"` -eq 1 ];
then
run_and_print_result "$IPTABLES -i $INPUT_INTERFACE -t nat -D PREROUTING -m set --match-set self_cancel src -d $IP_TARGET -p tcp --dport $PORT_SELF_CANCEL -j SET --add-set allowed src"
else
echo "already deleted"
fi
echo -n "Deleting iptables rule for allowed..."
#If IP is allowed then it is not redirected
if [ `rule_exists "PREROUTING -i $INPUT_INTERFACE -m set --match-set allowed src -j ACCEPT"` -eq 1 ];
then
run_and_print_result "$IPTABLES -i $INPUT_INTERFACE -t nat -D PREROUTING -m set --match-set allowed src -j ACCEPT"
else
echo "already deleted"
fi
echo -n "Deleting iptables rule for redirection..."
#Redirect everything trafic what has destination port $PORT_WEB to $PORT_REDIRECT
if [ `rule_exists "PREROUTING -i $INPUT_INTERFACE -p tcp -m set --match-set ranges src -m tcp --dport $PORT_WEB -j REDIRECT --to-ports $PORT_REDIRECT"` -eq 1 ];
then
run_and_print_result "$IPTABLES -i $INPUT_INTERFACE -t nat -D PREROUTING -m set --match-set ranges src -p tcp --dport $PORT_WEB -j REDIRECT --to-port $PORT_REDIRECT"
else
echo "already deleted"
fi
echo -n "Deleting iptables rule for allowed..."
#If IP is allowed then it is not redirected
if [ `rule_exists "FORWARD -i $INPUT_INTERFACE -m set --match-set allowed src -j ACCEPT"` -eq 1 ];
then
run_and_print_result "$IPTABLES -i $INPUT_INTERFACE -D FORWARD -m set --match-set allowed src -j ACCEPT"
else
echo "already deleted"
fi
echo -n "Deleting iptables rule for block others..."
#Else everything drop
if [ `rule_exists "FORWARD -i $INPUT_INTERFACE -m set --match-set ranges src -j DROP"` -eq 1 ];
then
run_and_print_result "$IPTABLES -i $INPUT_INTERFACE -D FORWARD -m set --match-set ranges src -j DROP"
else
echo "already deleted"
fi
}
# Adds ipsets
add_ipsets()
{
echo -n "Adding ipset allowed... "
if [ -n "`$IPSET -L allowed 2>&1>/dev/null`" ];
then
run_and_print_result "$IPSET -N allowed iphash --hashsize 10000 --probes 8 --resize 50"
else
echo "already added"
fi
echo -n "Adding ipset self_cancel..."
if [ -n "`$IPSET -L self_cancel 2>&1>/dev/null`" ];
then
run_and_print_result "$IPSET -N self_cancel iphash --hashsize 10000 --probes 8 --resize 50"
else
echo "already added"
fi
echo -n "Adding ipset ranges..."
if [ -n "`$IPSET -L ranges 2>&1>/dev/null`" ];
then
run_and_print_result "$IPSET -N ranges nethash --hashsize 1024 --probes 4 --resize 50"
else
echo "already added"
fi
echo -n "Adding temporary ipset for ipset allowed..."
if [ -n "`$IPSET -L allowed_tmp 2>&1>/dev/null`" ];
then
run_and_print_result "$IPSET -N allowed_tmp iphash --hashsize 10000 --probes 8 --resize 50"
else
echo "already added"
fi
echo -n "Adding temporary ipset for ipset self_cancel..."
if [ -n "`$IPSET -L self_cancel_tmp 2>&1>/dev/null`" ];
then
run_and_print_result "$IPSET -N self_cancel_tmp iphash --hashsize 10000 --probes 8 --resize 50"
else
echo "already added"
fi
echo -n "Adding temporary ipset for ipset ranges..."
if [ -n "`$IPSET -L ranges_tmp 2>&1>/dev/null`" ];
then
run_and_print_result "$IPSET -N ranges_tmp nethash --hashsize 1024 --probes 4 --resize 50"
else
echo "already added"
fi
}
# Deletes ipsets
delete_ipsets()
{
echo -n "Deleting ipset allowed... "
if [ -z "`$IPSET -L allowed 2>&1>/dev/null`" ];
then
run_and_print_result "$IPSET -X allowed"
else
echo "already deleted"
fi
echo -n "Deleting ipset self_cancel..."
if [ -z "`$IPSET -L self_cancel 2>&1>/dev/null`" ];
then
run_and_print_result "$IPSET -X self_cancel"
else
echo "already deleted"
fi
echo -n "Deleting ipset ranges..."
if [ -z "`$IPSET -L ranges 2>&1>/dev/null`" ];
then
run_and_print_result "$IPSET -X ranges"
else
echo "already deleted"
fi
echo -n "Deleting temporary ipset for ipset allowed..."
if [ -z "`$IPSET -L allowed_tmp 2>&1>/dev/null`" ];
then
run_and_print_result "$IPSET -X allowed_tmp"
else
echo "already deleted"
fi
echo -n "Deleting temporary ipset for ipset self_cancel..."
if [ -z "`$IPSET -L self_cancel_tmp 2>&1>/dev/null`" ];
then
run_and_print_result "$IPSET -X self_cancel_tmp"
else
echo "already deleted"
fi
echo -n "Deleting temporary ipset for ipset ranges..."
if [ -z "`$IPSET -L ranges_tmp 2>&1>/dev/null`" ];
then
run_and_print_result "$IPSET -X ranges_tmp"
else
echo "already deleted"
fi
}
# Starts HTTP 302 redirector
start_http_redirector ()
{
echo -n "Starting FreenetIS redirection HTTP deamon: "
if [ `is_running "$REDIRECTION_HTTP_REDIRECTOR"` -eq 0 ];
then
run_and_print_result "start-stop-daemon --start --quiet --make-pidfile --pidfile=$REDIRECTION_HTTP_REDIRECTOR_PIDFILE --background --exec $REDIRECTION_HTTP_REDIRECTOR -- $PORT_REDIRECT $PATH_FN $LOG_FILE_REDIRECTOR"
else
echo "already started"
fi
}
# Stops HTTP 302 redirector
stop_http_redirector ()
{
echo -n "Stopping FreenetIS redirection HTTP deamon: "
if [ `is_running "$REDIRECTION_HTTP_REDIRECTOR"` -eq 1 ];
then
run_and_print_result "start-stop-daemon --stop --quiet --pidfile=$REDIRECTION_HTTP_REDIRECTOR_PIDFILE"
else
echo "already stopped"
fi
rm -f "$REDIRECTION_HTTP_REDIRECTOR_PIDFILE"
}
# Starts redirection - only adds ipsets, rules and starts HTTP redirector
start_redirection ()
{
echo "[STARTING]"
add_ipsets
add_rules
start_http_redirector
}
# Stops redirection - only deletes ipset, rules and stops HTTP redirector
stop_redirection ()
{
echo "[STOPPING]"
delete_rules
delete_ipsets
stop_http_redirector
}
# Syncs ipsets with FreenetIS - only one time
sync_ipsets ()
{
echo "[SYNCING]"
PATH_ALLOWED=`mktemp`
PATH_SELF_CANCEL=`mktemp`
PATH_RANGES=`mktemp`
for URL in "$SET_URL_ALLOWED";
do
echo -n "Downloading list of allowed IP addresses from $URL: ";
$WGET -qO- $URL --no-check-certificate >> $PATH_ALLOWED 2>/dev/null
if [ $? -eq 0 ];
then
echo "OK"
else
echo "FAILED!"
fi
done
for URL in "$SET_URL_SELF_CANCEL";
do
echo -n "Downloading list of self-cancel IP addresses from $URL: ";
$WGET -qO- $URL --no-check-certificate >> $PATH_SELF_CANCEL 2>/dev/null
if [ $? -eq 0 ];
then
echo "OK"
else
echo "FAILED!"
fi
done
for URL in "$SET_URL_RANGES";
do
echo -n "Downloading list of ranges from $URL: ";
$WGET -qO- $URL --no-check-certificate >> $PATH_RANGES 2>/dev/null
if [ $? -eq 0 ];
then
echo "OK"
else
echo "FAILED!"
fi
done
$IPSET -F ranges_tmp 2>/dev/null
$IPSET -F allowed_tmp 2>/dev/null
$IPSET -F self_cancel_tmp 2>/dev/null
echo -n "Adding IP addresses to temporary ipset for ipset allowed..."
for i in $(cat $PATH_ALLOWED);
do
$IPSET -A allowed_tmp $i 2>/dev/null
done
echo `cat $PATH_ALLOWED | wc -l`" addresses added "
echo -n "Adding IP addresses to temporary ipset for ipset self_cancel..."
for i in $(cat $PATH_SELF_CANCEL);
do
$IPSET -A self_cancel_tmp $i 2>/dev/null
done
echo `cat $PATH_SELF_CANCEL | wc -l`" addresses added "
echo -n "Adding IP addresses to temporary ipset for ipset ranges..."
for i in $(cat $PATH_RANGES);
do
$IPSET -A ranges_tmp $i 2>/dev/null
done
echo `cat $PATH_RANGES | wc -l`" addresses added "
echo -n "Replacing content of ipset ranges with content of temporary ipset..."
run_and_print_result "$IPSET -W ranges_tmp ranges"
echo -n "Replacing content of ipset allowed with content of temporary ipset..."
run_and_print_result "$IPSET -W allowed_tmp allowed"
echo -n "Replacing content of ipset self_cancel with content of temporary ipset..."
run_and_print_result "$IPSET -W self_cancel_tmp self_cancel"
#Cleaning up...
rm -f $PATH_RANGES
rm -f $PATH_ALLOWED
rm -f $PATH_SELF_CANCEL
}
# Runs whole redirections (start, sync, stop) in endless loop
run ()
{
echo "[STARTING]"
trap 'stop_redirection' EXIT
while (true);
do
# makes sure ipsets exist
add_ipsets
# makes sure iptables rules exist
add_rules
# makes sure HTTP 302 redirector is running
start_http_redirector
# syncs ipsets with FreenetIS
sync_ipsets
echo "Sleeping now for $DELAY seconds..."
sleep $DELAY;
done
}
# Prints usage
usage ()
{
echo "Usage : `echo $0` ACTION [ LOG FILE ]"
echo "where ACTION := { start | stop | restart | sync | run | help }"
}
# Prints help
help ()
{
echo " start - creates firewall rules and ipsets for redirection"
echo " stop - deletes firewall rules and ipsets for redirection"
echo " restart - deletes and recreates firewall rules and ipsets for redirection"
echo " sync - sync content of ipsets with FreenetIS"
echo " run - run complete redirection in endless loop"
echo " help - prints help for redirection"
}
# Second parameter is set => will used as log file
if [ -n "$2" ]; then
exec > "$2"
fi;
# Is parameter #1 zero length?
if [ -z "$1" ]; then
usage
exit 0
fi;
case "$1" in
start)
start_redirection
exit 0
;;
stop)
stop_redirection
exit 0
;;
restart)
stop_redirection
start_redirection
exit 0
;;
sync)
sync_ipsets
exit 0
;;
run)
run
exit 0
;;
help)
usage
help
exit 0
;;
*)
usage
exit 0
;;
esac
exit 0
freenetis/branches/1.1/application/models/ip_address.php
LEFT JOIN ifaces i ON ip.iface_id = i.id
LEFT JOIN devices d ON i.device_id = d.id
LEFT JOIN users u ON d.user_id = u.id
LEFT JOIN members_whitelists mw ON mw.member_id = u.member_id
LEFT JOIN members_whitelists mw ON mw.member_id = u.member_id OR mw.member_id = ip.member_id
LEFT JOIN messages_ip_addresses mip ON mip.ip_address_id = ip.id
LEFT JOIN messages m ON m.id = mip.message_id
WHERE u.member_id = ? OR ip.member_id = ?
freenetis/branches/1.1/application/models/member.php
WHERE m.type = ? AND a.balance >= 0
", self::TYPE_FORMER);
}
/**
* Return credit account of member
*
* @author Michal Kliment
* @param type $member_id
* @return type
*/
public function get_credit_account($member_id = NULL)
{
if (!$member_id && $this)
$member_id = $this->id;
$account_model = new Account_Model();
return $account_model->get_account_by_account_attribute_and_member(
Account_attribute_Model::CREDIT, $member_id
);
}
}
freenetis/branches/1.1/application/models/account.php
* @author Jiri Svitak
* @return Mysql_Result
*/
public function get_accounts_to_deduct_entrance_fees()
public function get_accounts_to_deduct_entrance_fees($deduct_date)
{
return $this->db->query("
SELECT a.id, m.entrance_fee, m.debt_payment_rate, m.entrance_date, t.id AS transfer_id, t.amount
FROM accounts a
JOIN members m ON a.member_id = m.id AND m.id <> 1
LEFT JOIN transfers t ON t.origin_id = a.id AND t.type = ?
WHERE a.account_attribute_id = ?
", array(Transfer_Model::DEDUCT_ENTRANCE_FEE, Account_attribute_Model::CREDIT));
SELECT a.id AS id,
IF (debt > debt_payment_rate, debt_payment_rate, debt) AS amount
FROM
(
SELECT a.id,
IFNULL(m.entrance_fee, 0) - IFNULL(SUM(t.amount),0) AS debt,
debt_payment_rate
FROM accounts a
JOIN members m ON a.member_id = m.id
LEFT JOIN transfers t ON t.origin_id = a.id AND t.type = ?
WHERE a.account_attribute_id = ?
AND m.entrance_fee > 0 AND m.type <> ?
AND m.entrance_date < ? AND
(
m.type <> ? OR m.leaving_date > ?
) AND a.id NOT IN
(
SELECT t.origin_id
FROM transfers t
WHERE type = ? AND datetime = ?
)
GROUP BY a.id
) a
WHERE a.debt > 0
", array
(
Transfer_Model::DEDUCT_ENTRANCE_FEE,
Account_attribute_Model::CREDIT,
Member_Model::TYPE_APPLICANT,
$deduct_date,
Member_Model::TYPE_FORMER,
$deduct_date,
Transfer_Model::DEDUCT_ENTRANCE_FEE,
$deduct_date
));
}
......
* @author Jiri Svitak
* @return Mysql_Result
*/
public function get_accounts_to_deduct_device_fees()
public function get_accounts_to_deduct_device_fees($deduct_date)
{
return $this->db->query("
SELECT a.id, SUM(d.price) AS total_price
FROM accounts a
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
WHERE a.account_attribute_id = ?
GROUP BY a.id
HAVING total_price > 0
", array(Account_attribute_Model::CREDIT));
SELECT a.id, IF (debt > payment_rate, payment_rate, debt) AS amount
FROM
(
SELECT a.id, IFNULL(d.price, 0) - IFNULL(SUM(t.amount),0) AS debt,
payment_rate
FROM accounts a
JOIN members m ON a.member_id = m.id
JOIN users u ON u.member_id = m.id
JOIN devices d ON d.user_id = u.id AND d.price IS NOT NULL AND d.price > 0
LEFT JOIN transfers t ON t.origin_id = a.id AND t.type = ?
WHERE a.id NOT IN
(
SELECT t.origin_id
FROM transfers t
WHERE type = ? AND datetime = ?
)
GROUP BY a.id
) a
WHERE a.debt > 0
", array
(
Transfer_Model::DEDUCT_DEVICE_FEE,
Transfer_Model::DEDUCT_DEVICE_FEE,
$deduct_date
));
}
/**
......
return ($result) ? $result->comment: '';
}
/**
* Returns account by given attribute and member
*
* @author Michal Kliment
* @param type $account_attribute_id
* @param type $member_id
* @return type
*/
public function get_account_by_account_attribute_and_member ($account_attribute_id, $member_id)
{
return $this
->where('account_attribute_id', $account_attribute_id)
->where('member_id', $member_id)
->find();
}
}
freenetis/branches/1.1/application/controllers/transfers.php
);
$grid->add_new_button(
'transfers/deduct_fees', __('Deduction of member fees'),
$link_opt, help::hint('deduct_member_fees', $deduct_day)
'transfers/deduct_member_fees', __('Deduction of member fees'),
$link_opt + array('class' => 'popup_link'),
help::hint('deduct_member_fees', $deduct_day)
);
$m = __('Are you sure you want to deduct all entrance fees');
$grid->add_new_button(
'transfers/deduct_entrance_fees',
__('Deduction of entrance fees'),
$link_opt + array('onclick' => 'return window.confirm(\'' . $m . '?\')'),
$link_opt + array('class' => 'popup_link'),
help::hint('deduct_entrance_fees', $deduct_day)
);
$m = __('Are you sure you want to deduct all device repayments');
$grid->add_new_button(
'transfers/deduct_device_fees',
__('Deduction of device repayments'),
$link_opt + array('onclick' => 'return window.confirm(\'' . $m . '?\')'),
$link_opt + array('class' => 'popup_link'),
help::hint('deduct_device_repayments')
);
}
......
if ($account->account_attribute_id == Account_attribute_Model::CREDIT)
{
if ($this->acl_check_edit('Accounts_Controller', 'transfers'))
{
$m = __('Are you sure you want to recount fees of this member');
{
$transfers_grid->add_new_button(
'transfers/recalculate_fees/' . $account->id,
__('Recount of member fees'),
array('onclick' => 'return window.confirm(\'' . $m . '?\')'),
'accounts/recalculate_fees/' . $account->id,
__('Recount of fees'),
array(),
help::hint('recalculate_fees')
);
}
if ($this->acl_check_edit('Accounts_Controller', 'transfers'))
{
$m = __('Are you sure you want to recount entrance fees of this member');
$transfers_grid->add_new_button(
'transfers/recalculate_entrance_fees/' .
$account->id, __('Recount of entrance fees'),
array('onclick' => 'return window.confirm(\'' . $m . '?\')'),
help::hint('recalculate_entrance_fees')
);
}
if ($this->acl_check_edit('Accounts_Controller', 'transfers'))
{
$m = __('Are you sure you want to recount device repayments of this member');
$transfers_grid->add_new_button(
'transfers/recalculate_device_fees/' .
$account->id, __('Recount of device repayments'),
array('onclick' => 'return window.confirm(\'' . $m . '?\')'),
help::hint('recalculate_device_fees')
);
}
}
$transfers_grid->order_field('id')
->label('ID');
......
* @author Jiri Svitak
* @return unknown_type
*/
public function deduct_fees()
public function deduct_member_fees()
{
// access rights
if (!$this->acl_check_new('Accounts_Controller', 'transfers'))
......
$arr_years[$i] = $i;
}
$form = new Forge('transfers/deduct_fees');
$form = new Forge();
$form->dropdown('year')
->rules('required')
......
}
// end
url::redirect('transfers/show_all');
$this->redirect('transfers/show_all');
}
if (Settings::get('deduct_fees_automatically_enabled'))
{
$m = 'Automatically deduction is enabled, this operation should be ' .
'use only if automatical deduction has failed';
status::mwarning($m);
}
$breadcrumbs = breadcrumbs::add()
->link('transfers/show_all', 'Day book')
->text('Deduction of member fees');
$view = new View('main');
$view->title = __('Deduction of member fees');
$view->breadcrumbs = $breadcrumbs->html();
$view->content = new View('form');
$view->content->headline = __('Deduction of member fees');
$view->content->form = $form->html();
$view->render(TRUE);
}
/**
* Function recalculates wrong deducted fees of given account of member.
*
* @author Jiri Svitak
*/
public function recalculate_fees($account_id = 0)
{
// access control
if (!$this->acl_check_new('Accounts_Controller', 'transfers'))
Controller::error(ACCESS);
$account = new Account_Model($account_id);
// account doesn't exist
if (!$account->id)
Controller::error(RECORD);
// finds default fee
$fee_model = new Fee_Model();
// finds member's entrance date
$entrance_date = date_parse($account->member->entrance_date);
$year = $entrance_date['year'];
$month = $entrance_date['month'];
$day = $entrance_date['day'];
$deduct_day = date::get_deduct_day_to($month, $year);
// round entrance date
if ($day > $deduct_day)
{
$month++;
if ($month > 12)
{
$year++;
$month = 1;
}
}
// finds member's leaving date
if ($account->member->leaving_date != '0000-00-00')
{
$max_date = date_parse($account->member->leaving_date);
}
else
{
// find datetime of last deduct fee
$transfer_model = new Transfer_Model();
$last_datetime = $transfer_model->find_last_transfer_datetime_by_type(
Transfer_Model::DEDUCT_MEMBER_FEE
);
if ($last_datetime)
$max_date = date_parse($last_datetime);
else
$max_date = date_parse(date('Y-m-d'));
}
$max_day = $max_date['day'];
$max_month = $max_date['month'];
$max_year = $max_date['year'];
$max_deduct_day = date::get_deduct_day_to($max_month, $max_year);
// round max date
if ($max_day < $max_deduct_day)
{
$max_month--;
if ($max_month == 0)
if (Settings::get('deduct_fees_automatically_enabled'))
{
$max_year--;
$max_month = 12;
$m = 'Automatically deduction is enabled, this operation should be ' .
'use only if automatical deduction has failed';
status::mwarning($m);
}
$breadcrumbs = breadcrumbs::add()
->link('transfers/show_all', 'Day book')
->text('Deduction of member fees');
$view = new View('main');
$view->title = __('Deduction of member fees');
$view->breadcrumbs = $breadcrumbs->html();
$view->content = new View('form');
$view->content->headline = __('Deduction of member fees');
$view->content->form = $form->html();
$view->render(TRUE);
}
// finds operating account
$operating = ORM::factory('account')->where(
'account_attribute_id', Account_attribute_Model::OPERATING
)->find();
// creation datetime of transfers
$creation_datetime = date('Y-m-d H:i:s');
// status message
$message = '';
try
{
$db = new Transfer_Model();
$db->transaction_start();
// deleting old deduct transfer of member
$deleted_transfers_count = $account->delete_deduct_transfers_of_account($account_id);
$created_transfers_count = 0;
$max_deduct_day2 = date::get_deduct_day_to($max_month, $max_year);
$max_date = date('Y-m-d', mktime(0, 0, 0, $max_month, $max_deduct_day2, $max_year));
while (($date = date('Y-m-d', mktime(0, 0, 0, $month, date::get_deduct_day_to($month, $year), $year))) <= $max_date)
{
$text = __('Deduction of member fee');
// finds default regular member fee for this month
$fee = $fee_model->get_default_fee_by_date_type($date, 'regular member fee');
if ($fee && $fee->id)
$default_fee = $fee->fee;
else
{
$message = __('Error').': '.url_lang::lang('texts.Default fee for date %s have not been set!', $date);
throw new Exception($message);
}
// finds regular member fee for this member and this month
$fee = $fee_model->get_fee_by_member_date_type(
$account->member_id, $date, 'regular member fee'
);
// it exists
if ($fee && $fee->id)
{
$amount = $fee->fee;
// translate only read-only fee names
$text = ($fee->readonly) ? $text . ' - ' . __(''
. $fee->name) : $text . ' - ' . $fee->name;
}
// it doesn't exist - uses default fee
else
{
$amount = $default_fee;
}
if ($amount > 0)
{
$created_transfers_count++;
Transfer_Model::insert_transfer(
$account->id, $operating->id, null, null,
$this->session->get('user_id'),
Transfer_Model::DEDUCT_MEMBER_FEE, $date,
$creation_datetime, $text, $amount
);
}
// iterate to next month
$month++;
if ($month == 13)
{
$month = 1;
$year++;
}
}
$db->transaction_commit();
status::success(
'Fees have been successfully recalculated, %d deleted '.
'transfers, %d created new transfers.',
TRUE, array
(
0 => $deleted_transfers_count,
1 => $created_transfers_count
)
);
}
catch (Exception $e)
{
$db->transaction_rollback();
Log::add_exception($e);
status::error($message);
}
url::redirect('transfers/show_by_account/' . $account_id);
}
/**
......
* It checks each member if his fee was deducted, and if it is not, then
* the fee is deducted.
*
* @author Jiri Svitak
* @author Michal Kliment
*/
public function deduct_entrance_fees()
{
......
if (!$this->acl_check_new('Accounts_Controller', 'transfers'))
Controller::error(ACCESS);
// perform
try
{
$c = self::worker_deduct_entrance_fees($this->session->get('user_id'));
status::success(
'Entrance fees have been successfully deducted, '.
'%d new transfers created.', TRUE, $c
);
}
catch (Exception $e)
{
Log::add_exception($e);
status::error('Error - cant deduct entrance fee.');
}
// content of dropdown for months
for ($i = 1; $i <= 12; $i++)
$arr_months[$i] = $i;
// end
url::redirect('transfers/show_all');
}
/**
* Recounts transfer of one member credit account.
* Used only in special cases, like changing entrance date.
*
* @author Jiri Svitak
* @param integer $account_id
*/
public function recalculate_entrance_fees($account_id = NULL)
{
if (!$account_id || !is_numeric($account_id))
Controller::warning(PARAMETER);
$current_month = (int) date('n');
// access rights
if (!$this->acl_check_new('Accounts_Controller', 'transfers'))
Controller::error(ACCESS);
// association
$association = new Member_Model(Member_Model::ASSOCIATION);
$account_model = new Account_Model($account_id);
// content of dropdown for years
$year_from = date('Y', strtotime($association->entrance_date));
if ($account_model->id == 0)
Controller::error(RECORD);
// first of all is necessary to delete previous entrance fee transfers
// user can change debt payment rate, this means that existing transfers are useless
$deleted_transfers_count = $account_model->delete_entrance_deduct_transfers_of_account($account_id);
// preparation
$created_transfers_count = 0;
$creation_datetime = date('Y-m-d H:i:s');
$infrastructure = ORM::factory('account')->where(
'account_attribute_id', Account_attribute_Model::INFRASTRUCTURE
)->find();
$account_model = new Account_Model();
// gets credit account including its transfers, tries to find also existing transfer
$credit_account = $account_model->get_account_to_recalculate_entrance_fees($account_id);
$ca = $credit_account->current();
// if member's entrance fee is 0, then no transfer is generated
if ($ca->entrance_fee == 0)
for ($i = $year_from; $i <= date('Y'); $i++)
{
status::success(
'Entrance fees have been successfully recalculated, ' .
'%d transfers deleted, %d new transfers created.',
TRUE, array
(
1 => $deleted_transfers_count,
2 => $created_transfers_count
)
);
url::redirect('transfers/show_by_account/' . $account_id);
$arr_years[$i] = $i;
}
// entrance fee is not wholy paid, calculate debt
$debt = $ca->entrance_fee;
// entrance date of current member
$entrance = date_parse($ca->entrance_date);
$eyear = $entrance['year'];
$emonth = $entrance['month'];
$eday = $entrance['day'];
$deduct_eday = date::get_deduct_day_to($emonth, $eyear);
$form = new Forge();
if ($eday > $deduct_eday)
$emonth++;
$form->dropdown('year')
->rules('required')
->options($arr_years)
->style('width:200px')
->selected(date('Y'));
if ($emonth == 13)
{
$emonth = 1;
$eyear++;
}
$form->dropdown('month')
->rules('required')
->options($arr_months)
->selected($current_month)
->style('width:200px')
->callback(array($this, 'valid_default_fee'));
$deduct_eday2 = date::get_deduct_day_to($emonth, $eyear);
$form->submit('Deduct');
// getting boundary date - 15th day in the month
$date = date('Y-m-d', mktime(0, 0, 0, $emonth, $deduct_eday2, $eyear));
try
// form validation
if ($form->validate())
{
$db = new Transfer_Model();
$db->transaction_start();
// while debt is greater than zero and date of instalment is lower than current date
while ($debt > 0 && $date < date('Y-m-d'))
$form_data = $form->as_array();
// preparation
$month = $form_data['month'];
$year = $arr_years[$form_data['year']];
$user_id = $this->session->get('user_id');
// perform deduction
try
{
// is debt still greater than one monthly instalment?
if ($debt > $ca->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;
}
else
{
$amount = $debt;
}
// decrease amount of debt due to size of one instalment
$debt -= $amount;
// create new transfer
if ($amount > 0)
{
$created_transfers_count++;
Transfer_Model::insert_transfer(
$ca->id, $infrastructure->id, null, null,
$this->session->get('user_id'),
Transfer_Model::DEDUCT_ENTRANCE_FEE,
$date, $creation_datetime, __('Entrance fee'),
$amount
);
}
// iterate to next month
$emonth++;
if ($emonth == 13)
{
$emonth = 1;
$eyear++;
}
$count = self::worker_deduct_entrance_fees($month, $year, $user_id);
$deduct_eday3 = date::get_deduct_day_to($emonth, $eyear);
// getting boundary date - 15th day in the month
$date = date('Y-m-d', mktime(0, 0, 0, $emonth, $deduct_eday3, $eyear));
status::success(
'Entrance fees have been successfully deducted, %d new transfers created.',
TRUE, array($count)
);
}
$db->transaction_commit();
catch (Exception $e)
{
Log::add_exception($e);
status::error('Error - some fees have not been deducted.');
}
status::success(
'Entrance fees have been successfully recalculated, ' .
'%d transfers deleted, %d new transfers created.',
TRUE, array
(
1 => $deleted_transfers_count,
2 => $created_transfers_count
)
);
// end
$this->redirect('transfers/show_all');
}
catch (Exception $e)
else
{
$db->transaction_rollback();
Log::add_exception($e);
status::error('Error - cant deduct entrance fee.');
if (Settings::get('deduct_fees_automatically_enabled'))
{
$m = 'Automatically deduction is enabled, this operation should be ' .
'use only if automatical deduction has failed';
status::mwarning($m);
}
$title = __('Deduction of entrance fees');
$breadcrumbs = breadcrumbs::add()
->link('transfers/show_all', 'Day book')
->text($title);
$view = new View('main');
$view->title = $title;
$view->breadcrumbs = $breadcrumbs->html();
$view->content = new View('form');
$view->content->headline = $title;
$view->content->form = $form->html();
$view->render(TRUE);
}
url::redirect('transfers/show_by_account/' . $account_id);
}
/**
......
* @author Jiri Svitak
*/
public function deduct_device_fees()
{
{
// access rights
if (!$this->acl_check_new('Accounts_Controller', 'transfers'))
Controller::error(ACCESS);
// perform
try
{
$c = self::worker_deduct_devices_fees($this->session->get('user_id'));
status::success(
'Device fees have been successfully deducted, %d '.
'new transfers created.', TRUE, $c
);
}
catch (Exception $e)
{
Log::add_exception($e);
status::error('Error - cant deduct device fee.');
}
// content of dropdown for months
for ($i = 1; $i <= 12; $i++)
$arr_months[$i] = $i;
// end
url::redirect('transfers/show_all');
}
/**
* Recalculates device repayments of member by given account
*
* @author Michal Kliment
* @param integer $account_id
*/
public function recalculate_device_fees($account_id = NULL)
{
// bad parameter
if (!$account_id || !is_numeric($account_id))
Controller::warning (PARAMETER);
$current_month = (int) date('n');
// access rights
if (!$this->acl_check_new('Accounts_Controller', 'transfers'))
Controller::error(ACCESS);
// association
$association = new Member_Model(Member_Model::ASSOCIATION);
$account = new Account_Model($account_id);
// content of dropdown for years
$year_from = date('Y', strtotime($association->entrance_date));
// record doesn't exist
if (!$account->id)
Controller::error (RECORD);
$operating = ORM::factory('account')->where(
'account_attribute_id', Account_attribute_Model::OPERATING
)->find();
$created_transfers_count = 0;
$current_date = date('Y-m-d');
$creation_datetime = date('Y-m-d H:i:s');
$payments = array();
$deleted_transfers_count = $account->delete_device_deduct_transfers_of_account($account->id);
// finds all member's devices with debt payments
$devices = ORM::factory('device')->get_member_devices_with_debt_payments($account->member_id);
$debt = 0;
// no device with debt payments
if (!count($devices))
for ($i = $year_from; $i <= date('Y'); $i++)
{
status::success(
'Device repayments have been successfully recalculated, ' .
'%d transfers deleted, %d new transfers created.',
TRUE, array
(
1 => $deleted_transfers_count,
2 => $created_transfers_count
)
);
url::redirect('transfers/show_by_account/' . $account_id);
$arr_years[$i] = $i;
}
foreach ($devices as $device)
{
// finds buy date of this device
$buy_date = date_parse(date::get_closses_deduct_date_to($device->buy_date));
$debt += $device->price;
// finds all debt payments of this device
money::find_debt_payments(
$payments, $buy_date['month'], $buy_date['year'],
$device->price, $device->payment_rate
);
}
$form = new Forge();
$year = min(array_keys($payments));
$month = min(array_keys($payments[$year]));
$day = date::get_deduct_day_to($month, $year);
$form->dropdown('year')
->rules('required')
->options($arr_years)
->style('width:200px')
->selected(date('Y'));
$date = date::create($day, $month, $year);
$form->dropdown('month')
->rules('required')
->options($arr_months)
->selected($current_month)
->style('width:200px')
->callback(array($this, 'valid_default_fee'));
try
$form->submit('Deduct');
// form validation
if ($form->validate())
{
$account->transaction_start();
... Rozdílový soubor je zkrácen, protože jeho délka přesahuje max. limit.

Také k dispozici: Unified diff