Revize 553
Přidáno uživatelem Jiří Sviták před téměř 15 roky(ů)
freenetis/trunk/kohana/application/models/member.php | ||
---|---|---|
* @param $account_id
|
||
* @return unknown_type
|
||
*/
|
||
// absolete
|
||
/*
|
||
public function get_fee_information($account_id)
|
||
{
|
||
return self::$db->query('SELECT entrance_date, leaving_date, type
|
||
... | ... | |
WHERE a.id = '.$account_id
|
||
)->current();
|
||
}
|
||
*/
|
||
|
||
/**
|
||
* Function sets redirection to members, who have to pay their member fee soon
|
||
... | ... | |
self::$db->query("
|
||
UPDATE members m,
|
||
(
|
||
SELECT (q3.inbound - q3.outbound) AS balance, q3.mid
|
||
SELECT IFNULL(SUM(t.amount), 0) AS outbound, q2.inbound, q2.mid
|
||
FROM
|
||
(
|
||
SELECT IFNULL(SUM(t.amount), 0) AS outbound, q2.inbound, q2.mid
|
||
SELECT IFNULL(SUM(t.amount), 0) AS inbound, q1.aid, q1.mid
|
||
FROM
|
||
(
|
||
SELECT IFNULL(SUM(t.amount), 0) AS inbound, q1.aid, q1.mid
|
||
FROM
|
||
(
|
||
SELECT id AS aid, member_id AS mid
|
||
FROM accounts
|
||
WHERE member_id <> 1 AND account_attribute_id = ".Account_attribute_Model::$credit."
|
||
) 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
|
||
WHERE $lower_amount < (q3.inbound - q3.outbound) AND (q3.inbound - q3.outbound) < $upper_amount
|
||
) q
|
||
SELECT a.id AS aid, m.id AS mid
|
||
FROM accounts a
|
||
JOIN members m ON m.id = a.member_id
|
||
LEFT JOIN enum_types e ON e.id = m.type
|
||
WHERE member_id <> 1 AND account_attribute_id = ".Account_attribute_Model::$credit."
|
||
AND (e.value = 'Regular member' OR e.value = 'Former member')
|
||
) 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
|
||
SET m.redirect = m.redirect | 4
|
||
WHERE m.id = q.mid
|
||
WHERE m.id = q3.mid AND $lower_amount < (q3.inbound - q3.outbound) AND (q3.inbound - q3.outbound) < $upper_amount
|
||
");
|
||
}
|
||
|
||
... | ... | |
self::$db->query("
|
||
UPDATE members m,
|
||
(
|
||
SELECT (q3.inbound - q3.outbound) AS balance, q3.mid
|
||
SELECT IFNULL(SUM(t.amount), 0) AS outbound, q2.inbound, q2.mid
|
||
FROM
|
||
(
|
||
SELECT IFNULL(SUM(t.amount), 0) AS outbound, q2.inbound, q2.mid
|
||
SELECT IFNULL(SUM(t.amount), 0) AS inbound, q1.aid, q1.mid
|
||
FROM
|
||
(
|
||
SELECT IFNULL(SUM(t.amount), 0) 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 AND a.account_attribute_model = ".Account_attribute_Model::$credit."
|
||
) 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
|
||
SELECT a.id AS aid, m.id AS mid
|
||
FROM accounts a
|
||
JOIN members m ON m.id = a.member_id
|
||
LEFT JOIN enum_types e ON e.id = m.type
|
||
WHERE member_id <> 1 AND account_attribute_id = ".Account_attribute_Model::$credit."
|
||
AND (e.value = 'Regular member' OR e.value = 'Former member')
|
||
) 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
|
||
SET m.redirect = m.redirect | 2
|
||
WHERE q.balance < 0 AND m.id = q.mid
|
||
WHERE m.id = q3.mid AND (q3.inbound - q3.outbound) < 0
|
||
");
|
||
}
|
||
|
freenetis/trunk/kohana/application/controllers/members.php | ||
---|---|---|
$limit_results = (int) $this->input->get('record_per_page');
|
||
|
||
// parameters control
|
||
$allowed_order_type = array('id', 'name', 'street', 'street_number', 'town', 'quarter', 'ZIP_code', 'qos_ceil', 'qos_rate', 'entrance_fee', 'debt_payment_rate', 'current_credit', 'entrance_date', 'comment');
|
||
$allowed_order_type = array('id', 'name', 'street', 'street_number', 'town', 'quarter', 'ZIP_code', 'qos_ceil', 'qos_rate', 'entrance_fee', 'debt_payment_rate', 'current_credit', 'entrance_date', 'comment', 'balance');
|
||
if (!in_array(strtolower($order_by), $allowed_order_type))
|
||
$order_by = 'id';
|
||
if (strtolower($order_by_direction) != 'asc' && strtolower($order_by_direction) != 'desc')
|
freenetis/trunk/kohana/application/controllers/transfers.php | ||
---|---|---|
$leaving_date = '9999-99-99';
|
||
else
|
||
$leaving_date = $account->leaving_date;
|
||
if ($account->entrance_date <= $date && $leaving_date > $date && $account->miid == 0 && $account->type == 1)
|
||
if ($account->entrance_date <= $date && $leaving_date > $date && $account->type == 1 && $account->miid == 0)
|
||
{
|
||
$transfer->amount = $member_fee;
|
||
else
|
||
if (!$transfer->save())
|
||
$save_successful = false;
|
||
}
|
||
elseif ($account->miid > 0)
|
||
{
|
||
$transfer->amount = 0;
|
||
// money transfer is saved and checked
|
||
if (!$transfer->save())
|
||
$save_successful = false;
|
||
if (!$transfer->save())
|
||
$save_successful = false;
|
||
}
|
||
}
|
||
/*
|
||
echo '<table>';
|
Také k dispozici: Unified diff
Po predchozim commitu je nutne smazat rucne vsechny strhavaci prevody v databazi z duvodu prechodu na novy system strhavani prikazem
delete from transfers where type = 1
V tomto commitu upraveny nektere vlastnosti strhavani. V pripade hromadnych presmerovani kvuli neplaceni jsou ignorovany navic neplatici typy clenu.