Projekt

Obecné

Profil

« Předchozí | Další » 

Revize 562

Přidáno uživatelem Jiří Sviták před téměř 15 roky(ů)

Dodelan prepocet strzenych clenskych prispevku pro jednoho clena, nutne pouzivat jen v nutnych pripadech, jako potreba prepoctu pri zmene datumu vstupu apod. dale je treba mit uz provedene hromadne strzeni az po aktualni mesic, jinak hromadne strhavani nebude po individualnim prepoctu spravne fungovat (ono si kontroluje prevody pro dany mesic a staci jeden a odmitne se provest). Vylepsen vypocet datumu "zaplaceno do".

Zobrazit rozdíly:

freenetis/trunk/kohana/application/i18n/cs_CZ/texts.php
'applicant' => 'Čekatel na členství',
'application password' => 'Aplikační heslo',
'are you sure you want to deduct all entrance fees' => 'Jste si jistí, že chcete strhnout všechny vstupní příspěvky',
'are you sure you want to recount fees of this member' => 'Jste si jistí, že chcete přepočítat členské příspěvky tohoto člena',
'arrival' => 'Příchozí',
'assign' => 'Přiřadit',
'assign transfer' => 'Přiřadit převod',
freenetis/trunk/kohana/application/models/account.php
* @author Jiri Svitak
* @return unknown_type
*/
/*
public function get_accounts_to_deduct_fees($start_date, $finish_date, $year)
{
return self::$db->query("
......
AND t.datetime LIKE '%".$year."%' COLLATE utf8_general_ci
");
}
*/
/**
* Function gets accounts of all members. Used for member fee deduction (one transfer per month).
......
{
return self::$db->query("
SELECT a.id, m.entrance_date, m.leaving_date,
IF(e.value = 'Regular member' OR e.value = 'Former member', 1, 0) AS correct_type,
IF(e.value = 'Regular member' OR e.value = 'Former member' OR e.value = 'Applicant', 1, 0) AS correct_type,
e.value AS type_name,
IFNULL(miid, 0) AS miid
FROM accounts a
......
WHERE m.id <> 1 AND a.account_attribute_id = ".Account_attribute_Model::$credit."
");
}
/**
* Function deletes deducting transfers of given account.
* @author Jiri Svitak
* @param $account_id
* @return unknown_type
*/
public function delete_deduct_transfers_of_account($account_id)
{
self::$db->query("DELETE FROM transfers WHERE type = ".Transfer_Model::$deduct_member_fee."
AND origin_id = $account_id");
}
public function get_account_to_deduct($account_id, $date)
{
return self::$db->query("
SELECT a.id, m.entrance_date, m.leaving_date,
IF(e.value = 'Regular member' OR e.value = 'Former member' OR e.value = 'Applicant', 1, 0) AS correct_type,
e.value AS type_name,
IFNULL(miid, 0) AS miid
FROM accounts a
JOIN members m ON a.member_id = m.id
LEFT JOIN enum_types e ON e.id = m.type
LEFT JOIN
(
SELECT mi.id as miid, member_id
FROM membership_interrupts mi
WHERE mi.from <= '$date' AND mi.to > '$date'
) mi ON m.id = mi.member_id
WHERE a.id = $account_id AND a.account_attribute_id = ".Account_attribute_Model::$credit."
");
}
/**
* Function gets all members to deduct entrance fees.
* @author Jiri Svitak
......
}
}
?>
freenetis/trunk/kohana/application/controllers/members.php
$balance = $account->get_account_balance($account->id);
$fee_model = new Fee_Model();
$fee = $fee_model->get_by_date_type(date('Y-m-d'), 'regular member fee');
$expiration_date = date('Y-m-d', time() + (($balance / $fee->fee) * 30 * 24 * 60 * 60));
$expiration_date = date('Y-m-d', mktime(0, 0, 0, date('m'), 1, date('Y')) + (($balance / $fee->fee) * 30 * 24 * 60 * 60));
}
// contacts of main user of member
$model_contacts = new Contact_Model();
freenetis/trunk/kohana/application/controllers/transfers.php
if ($this->acl_check_edit('Accounts_Controller', 'transfers'))
$grid->add_new_button(url_lang::base().'transfers/deduct_fees', url_lang::lang('texts.Deduction of member fees'));
if ($this->acl_check_edit('Accounts_Controller', 'transfers'))
$grid->add_new_button(url_lang::base().'transfers/recount_fees', url_lang::lang('texts.Recount of member fees'));
if ($this->acl_check_edit('Accounts_Controller', 'transfers'))
$grid->add_new_button(url_lang::base().'transfers/deduct_entrance_fees', url_lang::lang('texts.Deduction of entrance fees'), array('onclick' => 'return potvrd(\''.url_lang::lang('texts.Are you sure you want to deduct all entrance fees').'\')'));
$grid->order_field('id')->label('ID');
$grid->field('origin')->label(url_lang::lang('texts.Origin account'));
......
$account = new Account_Model($account_id);
if ($account->id == 0)
Controller::error(RECORD);
if (!$this->acl_check_view('Accounts_Controller', 'transfers', $account->member_id))
if (!($this->acl_check_view('Accounts_Controller', 'transfers', $account->member_id)
|| $this->acl_check_view('Members_Controller', 'currentcredit')))
{
Controller::error(ACCESS);
}
$this->session->set('ssAccount_id', $account_id);
// gets grid settings
if (is_numeric($this->input->get('record_per_page')))
......
$balance = $account->get_account_balance($account_id);
$fee_model = new Fee_Model();
$fee = $fee_model->get_by_date_type(date('Y-m-d'), 'regular member fee');
$expiration_date = date('Y-m-d', time() + (($balance / $fee->fee) * 30 * 24 * 60 * 60));
$expiration_date = date('Y-m-d', mktime(0, 0, 0, date('m'), 1, date('Y')) + (($balance / $fee->fee) * 30 * 24 * 60 * 60));
// transfers on account
$transfer_model = new Transfer_Model();
$total_transfers = $transfer_model->count_transfers($account_id, $filter_values);
......
'filter' => $filter->view
));
if ($this->acl_check_view('Accounts_Controller', 'accounts'))
$grid->add_new_button(url_lang::base().'members/show/'.$account->member_id, url_lang::lang('texts.Back to the member'));
$grid->add_new_button(url_lang::base().'members/show/'.$account->member_id, url_lang::lang('texts.Back to the member'));
if ($this->acl_check_new('Accounts_Controller', 'transfers'))
$grid->add_new_button(url_lang::base().'transfers/add/'.$account_id, url_lang::lang('texts.Send money to other account'));
if ($account->account_attribute_id == Account_attribute_Model::$credit)
{
if ($this->acl_check_edit('Accounts_Controller', 'transfers'))
$grid->add_new_button(url_lang::base().'transfers/recount_fees/'.$account->id, url_lang::lang('texts.Recount of member fees'), array('onclick' => 'return potvrd(\''.url_lang::lang('texts.Are you sure you want to recount fees of this member').'\')'));
}
$grid->order_field('id')->label('ID');
//$grid->order_field('trans_type')->label(url_lang::lang('texts.Type'))->bool(array(url_lang::lang('texts.Inbound'),url_lang::lang('texts.Outbound')));
$grid->order_field('name')->label(url_lang::lang('texts.Counteraccount'));
......
}
}
function recount_fees()
/**
* Function recounts wrong deducted fees of given member.
* @author Jiri Svitak
* @return unknown_type
*/
function recount_fees($account_id = 0)
{
// access rights
if (!$this->acl_check_new('Accounts_Controller', 'transfers'))
Controller::error(ACCESS);
$member_model = new Member_Model();
$members = $member_model->find_all();
$arr_members[0] = '----- '.url_lang::lang('texts.Select member').' -----';
foreach($members as $member)
$account_model = new Account_Model($account_id);
if ($account_model->id == 0)
Controller::error(RECORD);
$member = new Member_Model($account_model->member_id);
$entrance = date_parse($member->entrance_date);
$eyear = $entrance['year'];
$emonth = $entrance['month'];
$leaving = date_parse($member->leaving_date);
if ($leaving == '0000-00-00')
$leaving = date('Y-m-d');
$lyear = $leaving['year'];
$lmonth = $leaving['month'];
$operating = ORM::factory('account')->
where('account_attribute_id', Account_attribute_Model::$operating)->find();
$text = url_lang::lang('texts.Deduction of member fee');
$creation_datetime = date('Y-m-d H:i:s');
// deleting of old deduct transfer of member
$account_model->delete_deduct_transfers_of_account($account_id);
$save_successful = true;
while (true)
{
$arr_members[$member->id] = $member->id.' - '.$member->name;
}
// form
$form = new Forge(url_lang::base().'transfers/recount_fees', '', 'POST', array('id' => 'article_form'));
$form->set_attr('class', 'form_class')->set_attr('method', 'post');
$form->dropdown('member')->label(url_lang::lang('texts.Member').':')->options($arr_members)->rules('required')->selected(0);
$form->submit('submit')->value(url_lang::lang('texts.Magic switch :-)'));
special::required_forge_style($form, ' *', 'required');
// form validation
if ($form->validate())
{
// access rights
if (!$this->acl_check_new('Accounts_Controller', 'transfers'))
Controller::error(ACCESS);
$form_data = $form->as_array();
$date = date('Y-m-d', mktime(0, 0, 0, $emonth, 15, $eyear));
if ($date >= date('Y-m-d'))
break;
$fee_model = new Fee_Model();
$fee = $fee_model->get_by_date_type($date, 'regular member fee');
if ($fee->id)
$member_fee = $fee->fee;
else
throw new Kohana_User_Exception(url_lang::lang('texts.Fatal error'), url_lang::lang('texts.Fees have not been set!'));
$member_id = $form_data['member'];
$save_successful = true;
if ($save_successful)
if ($date == '2009-09-15')
{
$this->session->set_flash('message', url_lang::lang('texts.Fees have been successfully recounted.').'<br>'.url_lang::lang('texts.Not yet implemented!!!') );
$ha = 5;
}
$accounts = $account_model->get_account_to_deduct($account_id, $date);
/*
if (count($accounts) == 0)
{
$emonth++;
if ($emonth == 13)
{
$emonth = 1;
$eyear++;
}
if ($eyear == $lyear && $emonth >= $lmonth)
break;
continue;
}
else*/
{
$account = $accounts->current();
}
$transfer = new Transfer_Model();
$transfer->origin_id = $account->id;
$transfer->destination_id = $operating->id;
$transfer->user_id = $this->session->get('user_id');
$transfer->type = Transfer_Model::$deduct_member_fee;
$transfer->datetime = $date;
$transfer->creation_datetime = $creation_datetime;
$transfer->text = $text;
// undefined leaving date has to be set to highest date
if ($account->leaving_date == '0000-00-00')
$leaving_date = '9999-99-99';
else
$leaving_date = $account->leaving_date;
// has active membership? (entrance < membership < leaving)
if ($account->entrance_date <= $date && $leaving_date > $date )
{
$this->session->set_flash('message', url_lang::lang('texts.Error - some fees have not been recounted.'));
// correct member type without membership interrupt?
if ($account->correct_type == 1 && $account->miid == 0)
{
$transfer->amount = $member_fee;
if (!$transfer->save())
$save_successful = false;
}
// else if member has interrupted membership or if he is of non-deduct type
// then zero transfer is generated
else
{
// reason for zero transfer
if ($account->correct_type != 1)
{
$translation = ORM::factory('translation')->
where(array('original_term' => $account->type_name, 'lang' => Config::item('locale.lang')))->find();
$transfer->text .= ' - '.url_lang::lang("texts.".$translation->translated_term);
}
elseif ($account->miid != 0)
{
$transfer->text .= ' - '.url_lang::lang("texts.Membership interrupt");
}
$transfer->amount = 0;
if (!$transfer->save())
$save_successful = false;
}
}
$emonth++;
if ($emonth == 13)
{
$emonth = 1;
$eyear++;
}
url::redirect(url_lang::base().'transfers/show_all');
}
if ($save_successful)
{
$this->session->set_flash('message', url_lang::lang('texts.Fees have been successfully recounted.'));
}
else
{
$headline = url_lang::lang('texts.Recount of member fees');
$view = new View('main');
$view->title = $headline;
$view->content = new View('form');
$view->content->headline = $headline;
$view->content->form = $form->html();
$view->content->link_back = html::anchor(url_lang::base().'transfers/show_all',url_lang::lang('texts.Back to day book'));
$view->render(TRUE);
$this->session->set_flash('message', url_lang::lang('texts.Error - some fees have not been recounted.'));
}
url::redirect(url_lang::base().'transfers/show_by_account/'.$account_id);
}
/**
freenetis/trunk/kohana/application/views/transfers/show_by_account.php
</tr>
<?php if ($account->account_attribute_id == Account_attribute_Model::$credit) { ?>
<tr>
<th><?php echo url_lang::lang('texts.Variable symbol')?></th>
<td><?php echo $account->member->variable_symbol ?></td>
</tr>
<tr>
<th><?php echo url_lang::lang('texts.Entrance date')?></th>
<td><?php echo $account->member->entrance_date ?></td>
</tr>
<?php if ($account->member->leaving_date > '0000-00-00') {?>
<tr>
<th><?php echo url_lang::lang('texts.Leaving date')?></th>
<td><?php echo $account->member->leaving_date ?></td>
</tr>
<?php } ?>
<?php } ?>
</table>
<table class="extended" style="float:left; margin-left:10px">
<tr>
<th><?php echo url_lang::lang('texts.Balance')?></th>
<td><?php echo number_format((float)$balance, 2, ',', ' ').' '.$this->setting->currency ?></td>
......
</tr>
<?php if ($account->account_attribute_id == Account_attribute_Model::$credit) { ?>
<tr>
<th><?php echo url_lang::lang('texts.Variable symbol')?></th>
<td><?php echo $account->member->variable_symbol ?></td>
</tr>
<tr>
<th><?php echo url_lang::lang('texts.Payed to')?></th>
<td><?php echo date('Y-m-d') < $expiration_date ? $expiration_date : '<span style="color:red">'.url_lang::lang('texts.You are in debt').'</span>' ?></td>
</tr>
freenetis/trunk/kohana/application/views/grid_template.php
elseif ($field->name == 'amount' || $field->name == 'balance')
{
if ($item->$field > 0)
echo '<span style="color:green">'.$item->$field.'</span>';
echo '<span style="color:green">'.number_format((float)$item->$field, 2, ',', ' ').'</span>';
elseif ($item->$field < 0)
echo '<span style="color:red">'.$item->$field.'</span>';
echo '<span style="color:red">'.number_format((float)$item->$field, 2, ',', ' ').'</span>';
else
echo $item->$field;
}

Také k dispozici: Unified diff