Projekt

Obecné

Profil

« Předchozí | Další » 

Revize 8d0578dc

Přidáno uživatelem Filip Miškařík před více než 4 roky(ů)

refs #1135: lBilling, voip, voip sip deleted. All relations for this controllers and models deleted.

Zobrazit rozdíly:

application/controllers/transfers.php
);
$account = ORM::factory('account')->where('id', $account_id)->find();
if (Billing::instance()->has_driver() &&
Billing::instance()->get_account($account->member_id))
{
$transfers_grid->add_new_button(
'transfers/add_voip/' . $account_id,
__('Recharge VoIP credit')
);
}
}
if ($account->account_attribute_id == Account_attribute_Model::CREDIT)
{
......
$view->render(TRUE);
}
/**
* Function adds VoIP transfers.
*
* @author Roman Sevcik
* @param integer $origin_account
*/
public function add_voip($origin_account = NULL)
{
if (!isset($origin_account))
{
self::warning(PARAMETER);
}
$origin_acc = new Account_Model($origin_account);
if (!$origin_acc->id)
{
self::error(RECORD);
}
if (!$this->acl_check_new('Accounts_Controller', 'transfers', $origin_acc->member_id))
{ // does the user have rights for this?
self::error(ACCESS);
}
if (!Billing::instance()->has_driver() ||
!Billing::instance()->get_account($origin_acc->member_id))
{
self::error(RECORD);
}
$arr_orig_accounts[$origin_acc->id] =
$origin_acc->name . ' - ' . __('Account ID') . ' ' . $origin_acc->id .
' - ' . __('Member ID') . ' ' . $origin_acc->member_id;
// form
$form = new Forge('transfers/add_voip/' . $origin_account);
$form->group('Transfer');
$form->dropdown('oname')
->label('Origin account')
->options($arr_orig_accounts)
->style('width:450px');
$form->date('datetime')
->label('Date and time')
->years(date('Y') - 20, date('Y'))
->rules('required');
$form->input('amount')
->label('Amount')
->rules('required|valid_numeric')
->callback(array($this, 'valid_amount_to_send'));
$form->submit('Send');
if ($form->validate())
{
// default destination account
$operating = ORM::factory('account')->where(
'account_attribute_id', Account_attribute_Model::OPERATING
)->find();
$text = __('Recharging of VoIP credit');
$form_data = $form->as_array();
try
{
$db = new Transfer_Model();
$db->transaction_start();
Transfer_Model::insert_transfer(
$form_data['oname'], $operating->id, null, null,
$this->session->get('user_id'),
Transfer_Model::DEDUCT_VOIP_UNNACCOUNTED_FEE,
date('Y-m-d', $form_data['datetime']), date('Y-m-d H:i:s'),
$text, $form_data['amount']
);
$db->transaction_commit();
status::success('Transfer has been successfully added.');
}
catch (Exception $e)
{
$db->transaction_rollback();
Log::add_exception($e);
status::success('Transfer has not been successfully added');
}
url::redirect('transfers/show_by_account/' . $origin_account);
}
$headline = __('Add new VoIP transfer');
// breadcrumbs navigation
$breadcrumbs = breadcrumbs::add()
->link('members/show_all', 'Members',
$this->acl_check_view('Members_Controller', 'members')
)->disable_translation()
->link('members/show/' . $origin_acc->member->id,
'ID ' . $origin_acc->member->id . ' - ' . $origin_acc->member->name,
$this->acl_check_view(
'Members_Controller', 'members',
$origin_acc->member->id
)
)->enable_translation()
->link('transfers/show_by_account/' . $origin_account,
'Transfers', $origin_account)
->text($headline);
$info[] = __('Information') . ' : ' . __('Transfer will be effected within 15 minutes.');
$view = new View('main');
$view->title = $headline;
$view->content = new View('form');
$view->breadcrumbs = $breadcrumbs->html();
$view->content->headline = $headline;
$view->content->form = $form->html();
$view->content->aditional_info = $info;
$view->render(TRUE);
}
/**
* Function edits double-entry transfers. They should not be edited.
* Wrong transfer should be solved by new transfer.

Také k dispozici: Unified diff