Revize 920
Přidáno uživatelem Michal Kliment před více než 13 roky(ů)
freenetis/trunk/kohana/application/models/fee.php | ||
---|---|---|
return $this->db->query("SELECT f.* FROM fees f WHERE special_type_id = ".$special_type)->current();
|
||
}
|
||
|
||
/**
|
||
* Helper method for finding min/max from/to date of fees
|
||
*
|
||
* @author Michal Kliment
|
||
* @param <type> $type
|
||
* @param <type> $col
|
||
* @param <type> $order_direction
|
||
* @return <type>
|
||
*/
|
||
private function _get_date_fee ($type, $col, $order_direction)
|
||
{
|
||
return $this->db->query ("
|
||
SELECT f.$col FROM fees f
|
||
LEFT JOIN enum_types et ON f.type_id = et.id
|
||
WHERE et.value = ?
|
||
ORDER BY f.$col $order_direction LIMIT 0,1
|
||
", array($type))->current()->$col;
|
||
}
|
||
|
||
/**
|
||
* Returns max to date of fees
|
||
*
|
||
* @author Michal Kliment
|
||
* @param <type> $type
|
||
* @return <type>
|
||
*/
|
||
public function get_max_todate_fee_by_type ($type)
|
||
{
|
||
return $this->_get_date_fee ($type, 'to', 'DESC');
|
||
}
|
||
|
||
/**
|
||
* Returns min from date of fees
|
||
*
|
||
* @author Michal Kliment
|
||
* @param <type> $type
|
||
* @return <type>
|
||
*/
|
||
public function get_min_fromdate_fee_by_type ($type)
|
||
{
|
||
return $this->_get_date_fee ($type, 'from', 'ASC');
|
||
}
|
||
|
||
}
|
||
?>
|
freenetis/trunk/kohana/application/controllers/members.php | ||
---|---|---|
}
|
||
|
||
$fee_model = new Fee_Model();
|
||
|
||
|
||
// finds min and max date = due to prevent before unending loop
|
||
$min_fee_date = $fee_model->get_min_fromdate_fee_by_type ('regular member fee');
|
||
$max_fee_date = $fee_model->get_max_todate_fee_by_type ('regular member fee');
|
||
|
||
while (true)
|
||
{
|
||
$date = date::create(15, $month, $year);
|
||
|
||
// date is bigger/smaller than max/min fee date, ends it (prevent before unending loop)
|
||
if (($sign == 1 && $date > $max_fee_date) || ($sign == -1 && $date < $min_fee_date))
|
||
break;
|
||
|
||
// finds regular member fee for this month
|
||
$fee = $fee_model->get_regular_member_fee_by_member_date ($account->member_id, date::create(15, $month, $year));
|
||
$fee = $fee_model->get_regular_member_fee_by_member_date ($account->member_id, $date);
|
||
|
||
// if exist payment for this month, adds it to the fee
|
||
if (isset($payments[$year][$month]))
|
Také k dispozici: Unified diff
Merge z testingu do trunku: Snad posledni oprava na vypoctu platnosti kreditu - dodelana ochrana pred zacyklenim u nulovych tarifu clenu majici kredit vetsi nez 0 (od teto castky se do nekonecna odecitala nula).