Revize 1175
Přidáno uživatelem Ondřej Fibich před asi 13 roky(ů)
freenetis/branches/testing/application/i18n/cs_CZ/texts.php | ||
---|---|---|
'active message' => 'Aktivní zpráva',
|
||
'actual' => 'Aktuální',
|
||
'actual download' => 'Aktuální download',
|
||
'actual price of calls' => 'Aktuální cena hovorů',
|
||
'actual traffic' => 'Aktuální provoz',
|
||
'actual traffic of ip addresses' => 'Aktuální provoz IP adres',
|
||
'actual traffic of members' => 'Aktuální provoz členů',
|
||
... | ... | |
'buy date' => 'Datum koupě',
|
||
'cable' => 'kabel',
|
||
'cancel' => 'Zrušit',
|
||
'calculate' => 'Spočítat',
|
||
'calulate price for call to any number' => 'Spočítat cenu hovoru na jakékoliv číslo',
|
||
'called number' => 'Volané číslo',
|
||
'caller' => 'Volající',
|
||
'callcon' => 'Volaný',
|
||
... | ... | |
'cash' => 'Pokladna',
|
||
'cash flow' => 'Peněžní tok',
|
||
'cash drawn' => 'Výběry hotovosti',
|
||
'cellphone number' => 'Mobilní číslo',
|
||
'cellphone operator' => 'Mobilní operátor',
|
||
'centralized logging' => 'Centralizované logování',
|
||
'chairman and agent' => 'Předseda a jednatel',
|
||
'change' => 'Změnit',
|
||
... | ... | |
'currency' => 'Měna',
|
||
'current application password is' => 'Současné aplikační heslo je',
|
||
'current credit' => 'Současný kredit',
|
||
'current prices for voip calls' => 'Aktuální cena VoIP hovorů',
|
||
'currently clean urls are turn off' => 'V současné době jsou čistá URL vypnuta.',
|
||
'czk' => 'Kč',
|
||
'daily' => 'denně',
|
||
... | ... | |
'first number can\'t be larger then second number' => 'První číslo nesmí být větší než druhé číslo',
|
||
'first or last day of month is not valid' => 'První nebo poslední den v měsíci není správně.',
|
||
'firstname of user' => 'Křestní jméno uživatele',
|
||
'fixed line' => 'Pevná linka',
|
||
'fixed line number' => 'Číslo v pevné lince',
|
||
'for smtp settings only' => 'Pouze pro nastavení SMTP.',
|
||
'for this month and year is not set default fee' => 'Pro tento měsíc a rok není nastaven výchozí poplatek.',
|
||
'forgotten password' => 'Zapomenuté heslo',
|
||
... | ... | |
'voip account' => 'VoIP účet',
|
||
'voip admins' => 'VoIP správci',
|
||
'voip information' => 'VoIP informace',
|
||
'voip number' => 'VoIP číslo',
|
||
'voip number interval must be in format xxxxxxxxx-xxxxxxxxx' => 'Rozsah VoIP čísel musí být ve formátu xxxxxxxxx-xxxxxxxxx',
|
||
'voip number must be 9 characters long' => 'VoIP číslo musí obsahovat 9 znaků',
|
||
'voip number must be a number' => 'VoIP číslo musí být číslo',
|
||
'voip settings' => 'Nastavení VoIP',
|
||
'vpn calls' => 'VPN volání',
|
||
'wait please' => 'Počkejte prosím',
|
||
'waiting for registration' => 'Čekám na registraci',
|
||
'warning' => 'Varování',
|
||
'weak' => 'Slabé',
|
||
... | ... | |
'write new message' => 'Napsat novou zprávu',
|
||
'wrong call length' => 'Chybné trvání hovoru',
|
||
'wrong email' => 'Chybný e-mail',
|
||
'wrong input' => 'Chybný vstup',
|
||
'wrong password' => 'Špatné heslo',
|
||
'wrong period' => 'Špatné období',
|
||
'wrong phone number' => 'Špatné telefonní číslo',
|
freenetis/branches/testing/application/vendors/billing/lbilling/lbilling.php | ||
---|---|---|
<?php
|
||
<?php defined('SYSPATH') or die('No direct script access.');
|
||
/*
|
||
* This file is part of open source system FreeNetIS
|
||
* and it is released under GPLv3 licence.
|
||
*
|
||
* More info about licence can be found:
|
||
* http://www.gnu.org/licenses/gpl-3.0.html
|
||
*
|
||
* More info about project can be found:
|
||
* http://www.freenetis.org/
|
||
*
|
||
*/
|
||
|
||
/**
|
||
* LBilling for VoIP.
|
||
* Gets data from remote server.
|
||
*
|
||
* @author Roman Sevcik, Ondrej Fibich
|
||
*/
|
||
class lbilling
|
||
{
|
||
/**
|
||
* Path to lbilling scripts
|
||
*
|
||
* @var string
|
||
*/
|
||
private $path;
|
||
|
||
/**
|
||
* Username for connection
|
||
*
|
||
* @var string
|
||
*/
|
||
private $partner;
|
||
|
||
/**
|
||
* Password for connection
|
||
*
|
||
* @var string
|
||
*/
|
||
private $pass;
|
||
private $init;
|
||
|
||
/**
|
||
* Error storage
|
||
*
|
||
* @var array
|
||
*/
|
||
private $error;
|
||
|
||
public function lbilling()
|
||
/**
|
||
* Contruct of lbilling
|
||
*
|
||
* @param string $partner Login
|
||
* @param string $pass Password
|
||
*/
|
||
public function __construct($partner, $pass)
|
||
{
|
||
$this->path = 'perl '.APPPATH.'vendors/billing/lbilling/';
|
||
|
||
$this->partner = null;
|
||
$this->pass = null;
|
||
$this->init = false;
|
||
$this->error = array();
|
||
}
|
||
|
||
public function set_auth_data($partner, $pass)
|
||
{
|
||
$this->path = 'perl ' . APPPATH . 'vendors/billing/lbilling/';
|
||
$this->partner = $partner;
|
||
$this->pass = $pass;
|
||
$this->init = true;
|
||
$this->error = array();
|
||
}
|
||
|
||
/**
|
||
* Tests connection
|
||
*
|
||
* @return bool
|
||
*/
|
||
public function test_conn()
|
||
{
|
||
if (!$this->init)
|
||
{
|
||
$e[0] = 'No auth data.';
|
||
$this->set_error($e);
|
||
return false;
|
||
}
|
||
exec(
|
||
$this->path . "perl/lbilling-test_conn.pl $this->partner $this->pass",
|
||
$output, $err
|
||
);
|
||
|
||
exec($this->path.'perl/lbilling-test_conn.pl '.$this->partner.' '.$this->pass, $output, $err);
|
||
|
||
if ( $err == 1)
|
||
if ($err == 1)
|
||
{
|
||
return true;
|
||
}
|
||
... | ... | |
}
|
||
}
|
||
|
||
/**
|
||
* Gets account
|
||
*
|
||
* @param type $accountid Account ID
|
||
* @return mixed Data on success NULL on error
|
||
*/
|
||
public function get_account($accountid)
|
||
{
|
||
if (!$this->init)
|
||
{
|
||
$e[0] = 'No auth data.';
|
||
$this->set_error($e);
|
||
return null;
|
||
}
|
||
exec(
|
||
$this->path . "perl/lbilling-get_account.pl " .
|
||
"$this->partner $this->pass $accountid",
|
||
$output, $err
|
||
);
|
||
|
||
exec($this->path.'perl/lbilling-get_account.pl '.$this->partner.' '.$this->pass.' '.$accountid, $output, $err);
|
||
|
||
if ( $err == 0)
|
||
if ($err == 0)
|
||
{
|
||
$this->set_error($output);
|
||
return null;
|
||
}
|
||
else if ( $err == 1)
|
||
else if ($err == 1)
|
||
{
|
||
$line = 0;
|
||
|
||
... | ... | |
}
|
||
return $account;
|
||
}
|
||
|
||
|
||
$e[0] = 'Unknow error. ';
|
||
$this->set_error($e);
|
||
return null;
|
||
}
|
||
|
||
/**
|
||
* Gets account calls
|
||
*
|
||
* @param type $accountid Account ID
|
||
* @param string $from From date
|
||
* @param string $to To date
|
||
* @return mixed Data on success NULL on error
|
||
*/
|
||
public function get_account_calls($accountid, $from, $to)
|
||
{
|
||
if (!$this->init)
|
||
{
|
||
$e[0] = 'No auth data.';
|
||
$this->set_error($e);
|
||
return null;
|
||
}
|
||
exec(
|
||
$this->path . "perl/lbilling-get_account_calls.pl " .
|
||
"$this->partner $this->pass $accountid $from $to",
|
||
$output, $err
|
||
);
|
||
|
||
exec($this->path.'perl/lbilling-get_account_calls.pl '.$this->partner.' '.$this->pass.' '.$accountid.' '.$from.' '.$to , $output, $err);
|
||
|
||
if ( $err == 0)
|
||
if ($err == 0)
|
||
{
|
||
$this->set_error($output);
|
||
return null;
|
||
}
|
||
else if ( $err == 1)
|
||
else if ($err == 1)
|
||
{
|
||
$line = 0;
|
||
|
||
... | ... | |
return null;
|
||
}
|
||
|
||
/**
|
||
* Gets subscriber calls
|
||
*
|
||
* @param type $accountid Account ID
|
||
* @param string $from From date
|
||
* @param string $to To date
|
||
* @return mixed Data on success NULL on error
|
||
*/
|
||
public function get_subscriber_calls($accountid, $from, $to)
|
||
{
|
||
if (!$this->init)
|
||
{
|
||
$e[0] = 'No auth data.';
|
||
$this->set_error($e);
|
||
return null;
|
||
}
|
||
exec(
|
||
$this->path . 'perl/lbilling-get_subscriber_calls.pl ' .
|
||
$this->partner . ' ' . $this->pass . ' ' . $accountid . ' ' .
|
||
$from . ' ' . $to, $output, $err
|
||
);
|
||
|
||
exec($this->path.'perl/lbilling-get_subscriber_calls.pl '.$this->partner.' '.$this->pass.' '.$accountid.' '.$from.' '.$to , $output, $err);
|
||
|
||
if ( $err == 0)
|
||
if ($err == 0)
|
||
{
|
||
$this->set_error($output);
|
||
return null;
|
||
}
|
||
else if ( $err == 1)
|
||
else if ($err == 1)
|
||
{
|
||
$line = 0;
|
||
|
||
... | ... | |
return null;
|
||
}
|
||
|
||
/**
|
||
* Gets partner calls
|
||
*
|
||
* @param type $accountid Account ID
|
||
* @param string $from From date
|
||
* @param string $to To date
|
||
* @return mixed Data on success NULL on error
|
||
*/
|
||
public function get_partner_calls($from, $to)
|
||
{
|
||
if (!$this->init)
|
||
{
|
||
$e[0] = 'No auth data.';
|
||
$this->set_error($e);
|
||
return null;
|
||
}
|
||
exec(
|
||
$this->path . 'perl/lbilling-get_partner_calls.pl ' .
|
||
$this->partner . ' ' . $this->pass . ' ' . $from . ' ' . $to,
|
||
$output, $err
|
||
);
|
||
|
||
exec($this->path.'perl/lbilling-get_partner_calls.pl '.$this->partner.' '.$this->pass.' '.$from.' '.$to , $output, $err);
|
||
|
||
if ( $err == 0)
|
||
if ($err == 0)
|
||
{
|
||
$this->set_error($output);
|
||
return null;
|
||
}
|
||
else if ( $err == 1)
|
||
else if ($err == 1)
|
||
{
|
||
$line = 0;
|
||
|
||
... | ... | |
$this->set_error($e);
|
||
return null;
|
||
}
|
||
|
||
/**
|
||
* Simulate call for getting info about call price
|
||
*
|
||
* @param string $callee Call number
|
||
* @param type $caller Call from number
|
||
* @param type $length Length of call in seconds
|
||
* @return mixed Data on success NULL on error
|
||
*/
|
||
public function simulate_call($callee, $caller, $length)
|
||
{
|
||
exec(
|
||
$this->path . 'perl/lbilling-simulate_call.pl ' . $this->partner .
|
||
' ' . $this->pass . ' ' . $callee . ' ' . $caller . ' ' . $length,
|
||
$output, $err
|
||
);
|
||
|
||
if ($err == 0)
|
||
{
|
||
$this->set_error($output);
|
||
return null;
|
||
}
|
||
else if ($err == 1)
|
||
{
|
||
$line = 0;
|
||
|
||
$acc = explode(";", $output[$line]);
|
||
|
||
$call->length = $acc[0];
|
||
$call->callee = $acc[1];
|
||
$call->caller = $acc[2];
|
||
$call->callid = $acc[3];
|
||
|
||
if ($acc[4] != "")
|
||
$call->descr = $acc[4];
|
||
|
||
$line++;
|
||
$count = $output[$line] + $line + 1;
|
||
$line++;
|
||
|
||
$i = 0;
|
||
for ($line; $line < $count; $line++)
|
||
{
|
||
$acc = explode(";", $output[$line]);
|
||
$call->calls[$i]->provider = $acc[0];
|
||
$call->calls[$i]->rate_vat = $acc[1];
|
||
$call->calls[$i]->subscriber = $acc[2];
|
||
$call->calls[$i]->account = $acc[3];
|
||
$call->calls[$i]->area = $acc[4];
|
||
$call->calls[$i]->callee = $acc[5];
|
||
$call->calls[$i]->status = $acc[6];
|
||
$call->calls[$i]->emergency = $acc[7];
|
||
$call->calls[$i]->rate_sum = $acc[8];
|
||
$call->calls[$i]->currency = $acc[9];
|
||
$call->calls[$i]->end_date = $acc[10];
|
||
$call->calls[$i]->callcon = $acc[11];
|
||
$call->calls[$i]->caller = $acc[12];
|
||
$call->calls[$i]->type = $acc[13];
|
||
$call->calls[$i]->start_date = $acc[14];
|
||
$call->calls[$i]->result = $acc[15];
|
||
|
||
$i++;
|
||
}
|
||
return $call;
|
||
}
|
||
|
||
$e[0] = 'Unknow error. ';
|
||
$this->set_error($e);
|
||
return null;
|
||
}
|
||
|
||
/**
|
||
* Sets error message
|
||
*
|
||
* @param array $error
|
||
*/
|
||
protected function set_error($error)
|
||
{
|
||
$this->error = $error;
|
||
}
|
||
|
||
/**
|
||
* Gets errors
|
||
*
|
||
* @return array
|
||
*/
|
||
public function get_error()
|
||
{
|
||
return $this->error;
|
||
}
|
||
|
||
}
|
||
|
||
|
||
?>
|
freenetis/branches/testing/application/vendors/billing/lbilling/perl/lbilling-simulate_call.pl | ||
---|---|---|
#!/usr/bin/perl
|
||
|
||
#use strict;
|
||
use DBI;
|
||
use Getopt::Std;
|
||
use Data::Dumper;
|
||
use warnings;
|
||
|
||
if ($#ARGV != 4) {
|
||
print "Wrong number of parameters", "\n";
|
||
exit 0;
|
||
}
|
||
|
||
my $call = {"callee" => $ARGV[2], "caller" => $ARGV[3], "length" => $ARGV[4]};
|
||
|
||
|
||
use SOAP::Lite +autodispatch =>
|
||
uri => "http://sip.nfx.cz/lBilling",
|
||
proxy => 'https://'.$ARGV[0].':'.$ARGV[1].'@sip.nfx.cz/cgi-bin/admin/lbilling/soap.pl';
|
||
|
||
my $lbilling = lBilling->new();
|
||
|
||
unless ( $lbilling ) {
|
||
print "Could not create SOAP instance", "\n";
|
||
exit 0;
|
||
}
|
||
|
||
my $result;
|
||
my $i;
|
||
|
||
if ( $result = $lbilling->simulate_call($call) ) {
|
||
|
||
print $result->{"length"}, ";";
|
||
print $result->{"callee"}, ";";
|
||
print $result->{"caller"}, ";";
|
||
print $result->{"callid"}, ";";
|
||
print $result->{"descr"}, ";","\n";
|
||
|
||
unless ( $result->{"calls"} ) {
|
||
print "0", "\n";
|
||
exit 1;
|
||
}
|
||
|
||
my $count = @{$result->{"calls"}};
|
||
|
||
print $count, "\n";
|
||
|
||
for ($i=0; $i<$count; $i++)
|
||
{
|
||
print $result->{"calls"}[$i]->{"provider"}, ";";
|
||
print $result->{"calls"}[$i]->{"rate_vat"}, ";";
|
||
print $result->{"calls"}[$i]->{"subscriber"}, ";";
|
||
print $result->{"calls"}[$i]->{"account"}, ";";
|
||
print $result->{"calls"}[$i]->{"area"}, ";";
|
||
print $result->{"calls"}[$i]->{"callee"}, ";";
|
||
print $result->{"calls"}[$i]->{"status"}, ";";
|
||
print $result->{"calls"}[$i]->{"emergency"}, ";";
|
||
print $result->{"calls"}[$i]->{"rate_sum"}, ";";
|
||
print $result->{"calls"}[$i]->{"currency"}, ";";
|
||
print $result->{"calls"}[$i]->{"end_date"}, ";";
|
||
print $result->{"calls"}[$i]->{"callcon"}, ";";
|
||
print $result->{"calls"}[$i]->{"caller"}, ";";
|
||
print $result->{"calls"}[$i]->{"type"}, ";";
|
||
print $result->{"calls"}[$i]->{"start_date"}, ";";
|
||
print $result->{"calls"}[$i]->{"result"}, "\n";
|
||
}
|
||
|
||
exit 1;
|
||
} else {
|
||
my $error = $lbilling->get_error();
|
||
my $errcount = @{$lbilling->get_error()};
|
||
for ($i=0; $i<$errcount; $i++)
|
||
{
|
||
print $lbilling->get_error()->[$i], "\n";
|
||
}
|
||
exit 0;
|
||
}
|
freenetis/branches/testing/application/vendors/unit_tester/unit_testing_config.xml | ||
---|---|---|
<input></input>
|
||
</values>
|
||
</method>
|
||
<method name="voip_call_price" autogenerate="on">
|
||
<attributes></attributes>
|
||
<values>
|
||
<input></input>
|
||
</values>
|
||
</method>
|
||
</controller>
|
||
<controller name="votes">
|
||
<method name="add_to_work" autogenerate="off">
|
freenetis/branches/testing/application/controllers/transfers.php | ||
---|---|---|
array(), help::hint('add_from_account')
|
||
);
|
||
|
||
$billing = new Billing();
|
||
|
||
$account = ORM::factory('account')->where('id', $account_id)->find();
|
||
|
||
if ($billing->has_driver() && ($billing->get_account($account->member_id) != null))
|
||
if (Billing::instance()->has_driver() &&
|
||
Billing::instance()->get_account($account->member_id))
|
||
{
|
||
$transfers_grid->add_new_button(
|
||
url_lang::base() . 'transfers/add_voip/' . $account_id,
|
||
... | ... | |
if (!isset($origin_account))
|
||
Controller::warning(PARAMETER);
|
||
|
||
$billing = new Billing();
|
||
$account = ORM::factory('account')->where('id', $origin_account)->find();
|
||
|
||
if (!$billing->has_driver() || ($billing->get_account($account->member_id) == null))
|
||
if (!Billing::instance()->has_driver() ||
|
||
!Billing::instance()->get_account($account->member_id))
|
||
{
|
||
Controller::error(RECORD);
|
||
}
|
||
|
||
if (isset($origin_account))
|
||
{ // transfer from specific account?
|
freenetis/branches/testing/application/controllers/voip.php | ||
---|---|---|
|
||
$link_status = (($voip->regseconds - time()) > 1);
|
||
|
||
$billing = new Billing();
|
||
|
||
$billing = Billing::instance();
|
||
|
||
$has_driver = $billing->has_driver();
|
||
$b_account = $billing->get_account($user->member_id);
|
||
|
||
... | ... | |
->link('voip/show_all', 'VoIP')
|
||
->disable_translation()
|
||
->text($voip->name);
|
||
|
||
// prices of calls
|
||
$fixed_price = null;
|
||
$cellphone_price = null;
|
||
$voip_price = null;
|
||
|
||
if (Settings::get('voip_tariff_fixed'))
|
||
{
|
||
$fixed_price = $billing->get_price_of_minute_call(
|
||
$voip->name, Settings::get('voip_tariff_fixed')
|
||
);
|
||
}
|
||
|
||
if (Settings::get('voip_tariff_cellphone'))
|
||
{
|
||
$cellphone_price = $billing->get_price_of_minute_call(
|
||
$voip->name, Settings::get('voip_tariff_cellphone')
|
||
);
|
||
}
|
||
|
||
if (Settings::get('voip_tariff_voip'))
|
||
{
|
||
$voip_price = $billing->get_price_of_minute_call(
|
||
$voip->name, Settings::get('voip_tariff_voip')
|
||
);
|
||
}
|
||
|
||
$view = new View('main');
|
||
$view->title = __('Show VoIP account');
|
||
$view->breadcrumbs = $breadcrumbs->html();
|
||
... | ... | |
$view->content->regseconds = $regseconds;
|
||
$view->content->voice_email = $voicemail->email;
|
||
$view->content->voice_status = $voicemail->active;
|
||
$view->content->fixed_price = $fixed_price;
|
||
$view->content->cellphone_price = $cellphone_price;
|
||
$view->content->voip_price = $voip_price;
|
||
$view->render(true);
|
||
}
|
||
|
||
... | ... | |
if (!$member->id)
|
||
Controller::error(RECORD);
|
||
|
||
$billing = new Billing();
|
||
|
||
$billing = Billing::instance();
|
||
|
||
$has_driver = $billing->has_driver();
|
||
$b_account = $billing->get_account($member_id);
|
||
|
freenetis/branches/testing/application/controllers/members.php | ||
---|---|---|
|
||
/******** VoIP ***********/
|
||
|
||
$billing = new Billing();
|
||
$has_driver = $billing->has_driver();
|
||
$b_account = $billing->get_account($member->id);
|
||
$has_driver = Billing::instance()->has_driver();
|
||
$b_account = Billing::instance()->get_account($member->id);
|
||
$voip_sip = new Voip_sip_Model();
|
||
$voip = $voip_sip->get_all_record_by_member_limited($member->id);
|
||
|
freenetis/branches/testing/application/controllers/voip_calls.php | ||
---|---|---|
{
|
||
if (!$this->acl_check_view('VoIP_Controller', 'voip'))
|
||
Controller::error(ACCESS);
|
||
|
||
$billing = Billing::instance();
|
||
|
||
$billing = new Billing();
|
||
|
||
if (!$billing->has_driver() || ($billing->test_conn() == false))
|
||
if (!$billing->has_driver() ||
|
||
!$billing->test_conn())
|
||
{
|
||
Controller::error(RECORD);
|
||
}
|
||
|
||
if (is_numeric($from))
|
||
$from = (int) $from;
|
||
... | ... | |
// main user of member also see private contacts of other users of member
|
||
if ($this->session->get('user_type') == User_Model::$member)
|
||
{
|
||
$users = ORM::factory('user')->where(array
|
||
$users = ORM::factory('user')->select('id')->where(array
|
||
(
|
||
'id !=' => $this->session->get('user_id'),
|
||
'member_id' => $this->session->get('member_id')
|
||
... | ... | |
$arr_users[] = $user->id;
|
||
}
|
||
}
|
||
|
||
$billing = Billing::instance();
|
||
|
||
$billing = new Billing();
|
||
|
||
if (!$billing->has_driver() ||
|
||
($billing->get_account($member->id) == null))
|
||
!$billing->get_account($member->id))
|
||
{
|
||
Controller::error(RECORD);
|
||
}
|
||
... | ... | |
$order_by_direction = 'asc';
|
||
|
||
$account_calls = $billing->get_account_calls($member->id, $from, $to);
|
||
|
||
|
||
$calls = NULL;
|
||
$count = 0;
|
||
|
||
... | ... | |
if ($this->session->get('user_id') == $user->id)
|
||
$arr_users = array($user->id);
|
||
|
||
$billing = new Billing();
|
||
|
||
$billing = Billing::instance();
|
||
|
||
if (!$billing->has_driver() ||
|
||
($billing->get_account($user->member_id) == null))
|
||
!$billing->get_account($user->member_id))
|
||
{
|
||
Controller::error(RECORD);
|
||
}
|
||
}
|
||
|
||
if (is_numeric($from))
|
||
$from = (int) $from;
|
||
... | ... | |
->enable_translation()
|
||
->text(__('List of calls'));
|
||
|
||
// prices of calls
|
||
$fixed_price = null;
|
||
$cellphone_price = null;
|
||
$voip_price = null;
|
||
|
||
if (Settings::get('voip_tariff_fixed'))
|
||
{
|
||
$fixed_price = $billing->get_price_of_minute_call(
|
||
$sip->name, Settings::get('voip_tariff_fixed')
|
||
);
|
||
}
|
||
|
||
if (Settings::get('voip_tariff_cellphone'))
|
||
{
|
||
$cellphone_price = $billing->get_price_of_minute_call(
|
||
$sip->name, Settings::get('voip_tariff_cellphone')
|
||
);
|
||
}
|
||
|
||
if (Settings::get('voip_tariff_voip'))
|
||
{
|
||
$voip_price = $billing->get_price_of_minute_call(
|
||
$sip->name, Settings::get('voip_tariff_voip')
|
||
);
|
||
}
|
||
|
||
// view
|
||
$view = new View('main');
|
||
$view->breadcrumbs = $breadcrumbs->html();
|
||
$view->title = __('List of calls');
|
||
$view->content = $grid;
|
||
$view->content = new View('voip/calls');
|
||
$view->content->sip = $sip;
|
||
$view->content->fixed_price = $fixed_price;
|
||
$view->content->cellphone_price = $cellphone_price;
|
||
$view->content->voip_price = $voip_price;
|
||
$view->content->grid = $grid;
|
||
$view->render(TRUE);
|
||
}
|
||
|
||
... | ... | |
'title' => $title
|
||
)).'</div>';
|
||
}
|
||
|
||
|
||
/**
|
||
* Callback AJAX function for getting price of call
|
||
*
|
||
* @author Ondrej Fibich
|
||
*/
|
||
public function voip_call_price()
|
||
{
|
||
$from = $this->input->get('from');
|
||
$to = $this->input->get('to');
|
||
|
||
$result = array();
|
||
|
||
if (is_numeric($from) && is_numeric($to))
|
||
{
|
||
$billing = Billing::instance();
|
||
|
||
$result = $billing->get_price_of_minute_call($from, $to);
|
||
|
||
echo number_format($result['price'], 2, ',', ' ');
|
||
echo ' ' . $this->settings->get('currency') . ', ';
|
||
echo $result['number'] . ', ' . $result['area'];
|
||
}
|
||
else
|
||
{
|
||
echo __('Wrong input');
|
||
}
|
||
}
|
||
|
||
}
|
freenetis/branches/testing/application/controllers/settings.php | ||
---|---|---|
->rules('required')
|
||
->options(array
|
||
(
|
||
Billing::$INACTIVE => __('Inactive'),
|
||
Billing::$NFX_LBILLING => "lBilling - NFX"
|
||
Billing::INACTIVE => __('Inactive'),
|
||
Billing::NFX_LBILLING => "lBilling - NFX"
|
||
))->selected($this->settings->get('voip_billing_driver'));
|
||
|
||
$this->form->input('voip_billing_partner')
|
||
... | ... | |
->label(__('Password') . ':')
|
||
->rules('length[1,50]')
|
||
->value($this->settings->get('voip_billing_password'));
|
||
|
||
|
||
$this->form->group('')
|
||
->label(__('Actual price of calls'));
|
||
|
||
$this->form->input('voip_tariff_fixed')
|
||
->label(__('Fixed line number') . ':')
|
||
->rules('valid_numeric')
|
||
->value($this->settings->get('voip_tariff_fixed'));
|
||
|
||
$this->form->input('voip_tariff_cellphone')
|
||
->label(__('Cellphone number') . ':')
|
||
->rules('valid_numeric')
|
||
->value($this->settings->get('voip_tariff_cellphone'));
|
||
|
||
$this->form->input('voip_tariff_voip')
|
||
->label(__('VoIP number') . ':')
|
||
->rules('valid_numeric')
|
||
->value($this->settings->get('voip_tariff_voip'));
|
||
|
||
$this->form->submit('submit')
|
||
->value(__('Save'));
|
||
|
||
... | ... | |
$user = $this->settings->get('voip_asterisk_user');
|
||
$pass = $this->settings->get('voip_asterisk_pass');
|
||
|
||
$aditional_info = null;
|
||
$additional_info = null;
|
||
|
||
$billing = new Billing();
|
||
|
||
if ($billing->has_driver())
|
||
if (Billing::instance()->has_driver())
|
||
{
|
||
if ($billing->test_conn())
|
||
if (Billing::instance()->test_conn())
|
||
{
|
||
$aditional_info[] = __('Testing driver')
|
||
. ' : lBilling - NFX......<span style="color:green">OK</span>';
|
||
$additional_info = __('Testing driver')
|
||
. ': lBilling - NFX......<span style="color:green">OK</span>';
|
||
}
|
||
else
|
||
{
|
||
$aditional_info[] = __('Testing driver')
|
||
. ' : lBilling - NFX......<span style="color:red">'
|
||
$additional_info = __('Testing driver')
|
||
. ': lBilling - NFX......<span style="color:red">'
|
||
. __('Failed') . '</span>';
|
||
}
|
||
}
|
||
|
||
$view->content->aditional_info = $aditional_info;
|
||
$view->content->additional_info = $additional_info;
|
||
$view->render(TRUE);
|
||
}
|
||
|
freenetis/branches/testing/application/libraries/Billing.php | ||
---|---|---|
<?php
|
||
<?php defined('SYSPATH') or die('No direct script access.');
|
||
/*
|
||
* This file is part of open source system FreeNetIS
|
||
* and it is released under GPLv3 licence.
|
||
*
|
||
* More info about licence can be found:
|
||
* http://www.gnu.org/licenses/gpl-3.0.html
|
||
*
|
||
* More info about project can be found:
|
||
* http://www.freenetis.org/
|
||
*
|
||
*/
|
||
|
||
|
||
|
||
/**
|
||
* Billing for VoIP
|
||
*
|
||
* @author Roman Sevcik, Ondrej Fibich
|
||
*/
|
||
class Billing
|
||
{
|
||
/**
|
||
* Singleton instance
|
||
*
|
||
* @var Billing
|
||
*/
|
||
private static $instance = null;
|
||
|
||
/**
|
||
* Returns instance of billing
|
||
*
|
||
* @return Billing
|
||
*/
|
||
public static function & instance()
|
||
{
|
||
if (empty(self::$instance))
|
||
{
|
||
self::$instance = new Billing();
|
||
}
|
||
|
||
return self::$instance;
|
||
}
|
||
|
||
// states of VoIP
|
||
const INACTIVE = 1;
|
||
const NFX_LBILLING = 2;
|
||
|
||
/**
|
||
* Indicator of driver
|
||
*
|
||
* @var bool
|
||
*/
|
||
private $driver;
|
||
private $c;
|
||
|
||
/**
|
||
* LBilling class
|
||
*
|
||
* @var lbilling
|
||
*/
|
||
private $billing;
|
||
|
||
public static $INACTIVE = 1;
|
||
public static $NFX_LBILLING = 2;
|
||
|
||
public function Billing()
|
||
/**
|
||
* Construct of cilling
|
||
*/
|
||
private function __construct()
|
||
{
|
||
$this->c = new Settings();
|
||
|
||
if ($this->c->get('voip_billing_driver') == Billing::$NFX_LBILLING)
|
||
if (Settings::get('voip_billing_driver') == Billing::NFX_LBILLING)
|
||
{
|
||
require_once(APPPATH.'vendors/billing/lbilling/lbilling.php');
|
||
$this->billing = new lbilling();
|
||
$this->billing->set_auth_data($this->c->get('voip_billing_partner'),$this->c->get('voip_billing_password'));
|
||
|
||
$this->billing = new lbilling(
|
||
Settings::get('voip_billing_partner'),
|
||
Settings::get('voip_billing_password')
|
||
);
|
||
|
||
$this->driver = true;
|
||
}
|
||
... | ... | |
}
|
||
}
|
||
|
||
/**
|
||
* Check if driver is on
|
||
*
|
||
* @return bool
|
||
*/
|
||
public function has_driver()
|
||
{
|
||
return $this->driver;
|
||
}
|
||
|
||
/**
|
||
* Tests connection to billing
|
||
*
|
||
* @return bool
|
||
*/
|
||
public function test_conn()
|
||
{
|
||
if (!$this->driver)
|
||
... | ... | |
return $this->billing->test_conn();
|
||
}
|
||
|
||
/**
|
||
* Gets account
|
||
*
|
||
* @param integer $accountid
|
||
* @return mixed false on error, data otherwise
|
||
*/
|
||
public function get_account($accountid)
|
||
{
|
||
if (!$this->driver)
|
||
... | ... | |
return $this->billing->get_account($accountid);
|
||
}
|
||
|
||
/**
|
||
* Gets calls from acount in given date interval
|
||
*
|
||
* @param integer $accountid
|
||
* @param string $from
|
||
* @param string $to
|
||
* @return mixed
|
||
*/
|
||
public function get_account_calls($accountid, $from, $to)
|
||
{
|
||
return $this->billing->get_account_calls($accountid, $from, $to);
|
||
}
|
||
|
||
/**
|
||
* Gets subscribers calls in given date interval
|
||
*
|
||
* @param integer $accountid
|
||
* @param string $from
|
||
* @param string $to
|
||
* @return mixed
|
||
*/
|
||
public function get_subscriber_calls($accountid, $from, $to)
|
||
{
|
||
return $this->billing->get_subscriber_calls($accountid, $from, $to);
|
||
}
|
||
|
||
/**
|
||
* Gets partner calls in given date interval
|
||
*
|
||
* @param integer $accountid
|
||
* @param string $from
|
||
* @param string $to
|
||
* @return mixed
|
||
*/
|
||
public function get_partner_calls($from, $to)
|
||
{
|
||
return $this->billing->get_partner_calls($from, $to);
|
||
}
|
||
|
||
/**
|
||
* Gets price of simulated one minute long call
|
||
*
|
||
* @param type $caller_number Number to call from
|
||
* @param type $number Number to call to
|
||
* @return mixed Array with price and details on success
|
||
* FALSE otherwise
|
||
*/
|
||
public function get_price_of_minute_call($caller_number, $number)
|
||
{
|
||
$call = $this->billing->simulate_call($number, $caller_number, 60);
|
||
|
||
if ($call && $call->descr == 'OK')
|
||
{
|
||
$number = explode('@', $call->calls[0]->callee);
|
||
$number = explode(':', $number[0]);
|
||
$number = $number[1];
|
||
|
||
return array
|
||
(
|
||
'number' => $number,
|
||
'price' => doubleval($call->calls[0]->rate_sum),
|
||
'area' => $call->calls[0]->area
|
||
);
|
||
}
|
||
|
||
return FALSE;
|
||
}
|
||
|
||
/**
|
||
* Gets error from billing
|
||
*
|
||
* @return array
|
||
*/
|
||
public function get_error()
|
||
{
|
||
return $this->billing->get_error();
|
||
}
|
||
}
|
||
?>
|
freenetis/branches/testing/application/views/voip/calls.php | ||
---|---|---|
<script type="text/javascript"><!--
|
||
|
||
function get_price()
|
||
{
|
||
var $input = $('#number');
|
||
var $output = $('#number_price');
|
||
|
||
$input.attr('disable', 'disable');
|
||
$('#a_calculate img').unbind('click');
|
||
|
||
$output.css('color', '#ccc');
|
||
$output.html('<?php echo __('Wait please') ?>...');
|
||
|
||
$.get('<?php echo url_lang::base() ?>voip_calls/voip_call_price?from=<?php echo $sip->name ?>&to=' + $input.val(), function(data)
|
||
{
|
||
$output.css('color', 'black');
|
||
$output.html(data);
|
||
|
||
$input.removeAttr('disable');
|
||
$('#a_calculate img').click(get_price);
|
||
$input.focus();
|
||
});
|
||
|
||
return false;
|
||
}
|
||
|
||
$(document).ready(function ()
|
||
{
|
||
var $input = $('#number');
|
||
var $calculate = $('#a_calculate');
|
||
|
||
$calculate.css('opacity', 0.5);
|
||
$calculate.css('cursor', 'default');
|
||
|
||
$input.click(function ()
|
||
{
|
||
$input.val('');
|
||
$input.css('color', 'black');
|
||
$input.unbind('click');
|
||
return false;
|
||
});
|
||
|
||
$input.keyup(function (event)
|
||
{
|
||
$('#a_calculate img').unbind('click');
|
||
|
||
if (($input.val().length < 3) || !$input.val().match(/^\d+$/))
|
||
{
|
||
$input.css('border', '1px solid red');
|
||
$calculate.css('opacity', 0.5);
|
||
$calculate.css('cursor', 'default');
|
||
}
|
||
else
|
||
{
|
||
if (event.which == 13)
|
||
{
|
||
get_price();
|
||
}
|
||
else
|
||
{
|
||
$input.css('border', '1px solid #ccc');
|
||
$calculate.css('opacity', 1);
|
||
$calculate.css('cursor', 'pointer');
|
||
$('#a_calculate img').click(get_price);
|
||
}
|
||
}
|
||
});
|
||
});
|
||
|
||
|
||
--></script>
|
||
|
||
<h2><?php echo __('Current prices for VoIP calls') ?></h2><br />
|
||
|
||
<table class="extended" cellspacing="0">
|
||
<tr>
|
||
<th><?php echo __('Destination') ?></th>
|
||
<th><?php echo __('Price') ?></th>
|
||
</tr>
|
||
<?php if (isset($fixed_price) && is_array($fixed_price)): ?>
|
||
<tr>
|
||
<td><?php echo __('Fixed line') ?></td>
|
||
<td><?php echo number_format($fixed_price['price'], 2, ',', ' ').' '.$this->settings->get('currency') ?></td>
|
||
</tr>
|
||
<?php endif; ?>
|
||
<?php if (isset($cellphone_price) && is_array($cellphone_price)): ?>
|
||
<tr>
|
||
<td><?php echo __('Cellphone operator') ?></td>
|
||
<td><?php echo number_format($cellphone_price['price'], 2, ',', ' ').' '.$this->settings->get('currency') ?></td>
|
||
</tr>
|
||
<?php endif; ?>
|
||
<?php if (isset($voip_price) && is_array($voip_price)): ?>
|
||
<tr>
|
||
<td><?php echo __('VoIP') ?></td>
|
||
<td><?php echo number_format($voip_price['price'], 2, ',', ' ').' '.$this->settings->get('currency') ?></td>
|
||
</tr>
|
||
<?php endif; ?>
|
||
<tr>
|
||
<td>
|
||
<table>
|
||
<tr>
|
||
<td style="border: none; padding: 0;">
|
||
<input type="text" name="number" id="number" value="<?php echo __('Phone number') ?>" style="width: 110px; color: #ccc" />
|
||
</td>
|
||
<td style="border: none; padding: 0 0 0 2px;">
|
||
<a id="a_calculate" style="text-decoration: none;" title="<?php echo __('Calculate') ?>">
|
||
<img src="<?php echo url::base() ?>media/images/icons/calculate.png" width="16" height="16" alt="<?php echo __('Calculate') ?>" />
|
||
</a>
|
||
</td>
|
||
</tr>
|
||
</table>
|
||
</td>
|
||
<td id="number_price"><?php echo __('Calulate price for call to any number') ?></td>
|
||
</tr>
|
||
</table>
|
||
|
||
<br /><br />
|
||
|
||
<?php echo $grid; ?>
|
freenetis/branches/testing/application/views/voip/show.php | ||
---|---|---|
<script type="text/javascript"><!--
|
||
|
||
function get_price()
|
||
{
|
||
var $input = $('#number');
|
||
var $output = $('#number_price');
|
||
|
||
$input.attr('disable', 'disable');
|
||
$('#a_calculate img').unbind('click');
|
||
|
||
$output.css('color', '#ccc');
|
||
$output.html('<?php echo __('Wait please') ?>...');
|
||
|
||
$.get('<?php echo url_lang::base() ?>voip_calls/voip_call_price?from=<?php echo $voip->name ?>&to=' + $input.val(), function(data)
|
||
{
|
||
$output.css('color', 'black');
|
||
$output.html(data);
|
||
|
||
$input.removeAttr('disable');
|
||
$('#a_calculate img').click(get_price);
|
||
$input.focus();
|
||
});
|
||
|
||
return false;
|
||
}
|
||
|
||
$(document).ready(function ()
|
||
{
|
||
var $input = $('#number');
|
||
var $calculate = $('#a_calculate');
|
||
|
||
$calculate.css('opacity', 0.5);
|
||
$calculate.css('cursor', 'default');
|
||
|
||
$input.click(function ()
|
||
{
|
||
$input.val('');
|
||
$input.css('color', 'black');
|
||
$input.unbind('click');
|
||
return false;
|
||
});
|
||
|
||
$input.keyup(function (event)
|
||
{
|
||
$('#a_calculate img').unbind('click');
|
||
|
||
if (($input.val().length < 3) || !$input.val().match(/^\d+$/))
|
||
{
|
||
$input.css('border', '1px solid red');
|
||
$calculate.css('opacity', 0.5);
|
||
$calculate.css('cursor', 'default');
|
||
}
|
||
else
|
||
{
|
||
if (event.which == 13)
|
||
{
|
||
get_price();
|
||
}
|
||
else
|
||
{
|
||
$input.css('border', '1px solid #ccc');
|
||
$calculate.css('opacity', 1);
|
||
$calculate.css('cursor', 'pointer');
|
||
$('#a_calculate img').click(get_price);
|
||
}
|
||
}
|
||
});
|
||
});
|
||
|
||
|
||
--></script>
|
||
|
||
<h2>
|
||
<?php echo __('VoIP account') . ' ' . $voip->name ?>
|
||
</h2>
|
||
... | ... | |
</tr>
|
||
</table>
|
||
<br />
|
||
<table class="extended" style="width:360px;">
|
||
<table class="extended" style="margin-right:10px; float:left; width:360px;">
|
||
<tr>
|
||
<th colspan="2"><?php echo __('Voicemail data') ?></th>
|
||
</tr>
|
||
... | ... | |
<th><?php echo __('email') ?></th>
|
||
<td><?php echo $voice_email ?></td>
|
||
</tr>
|
||
</table>
|
||
|
||
<table class="extended" cellspacing="0" style="width:360px;">
|
||
<tr>
|
||
<th><?php echo __('Destination') ?></th>
|
||
<th><?php echo __('Price') ?></th>
|
||
</tr>
|
||
<?php if (isset($fixed_price) && is_array($fixed_price)): ?>
|
||
<tr>
|
||
<td><?php echo __('Fixed line') ?></td>
|
||
<td><?php echo number_format($fixed_price['price'], 2, ',', ' ').' '.$this->settings->get('currency') ?></td>
|
||
</tr>
|
||
<?php endif; ?>
|
||
<?php if (isset($cellphone_price) && is_array($cellphone_price)): ?>
|
||
<tr>
|
||
<td><?php echo __('Cellphone operator') ?></td>
|
||
<td><?php echo number_format($cellphone_price['price'], 2, ',', ' ').' '.$this->settings->get('currency') ?></td>
|
||
</tr>
|
||
<?php endif; ?>
|
||
<?php if (isset($voip_price) && is_array($voip_price)): ?>
|
||
<tr>
|
||
<td><?php echo __('VoIP') ?></td>
|
||
<td><?php echo number_format($voip_price['price'], 2, ',', ' ').' '.$this->settings->get('currency') ?></td>
|
||
</tr>
|
||
<?php endif; ?>
|
||
<tr>
|
||
<td>
|
||
<table>
|
||
<tr>
|
||
<td style="border: none; padding: 0;">
|
||
<input type="text" name="number" id="number" value="<?php echo __('Phone number') ?>" style="width: 110px; color: #ccc" />
|
||
</td>
|
||
<td style="border: none; padding: 0 0 0 2px;">
|
||
<a id="a_calculate" style="text-decoration: none;" title="<?php echo __('Calculate') ?>">
|
||
<img src="<?php echo url::base() ?>media/images/icons/calculate.png" width="16" height="16" alt="<?php echo __('Calculate') ?>" />
|
||
</a>
|
||
</td>
|
||
</tr>
|
||
</table>
|
||
</td>
|
||
<td id="number_price"><?php echo __('Calulate price for call to any number') ?></td>
|
||
</tr>
|
||
</table>
|
Také k dispozici: Unified diff
Novinky:
- pridani kalkulacky ceny VoIP hovoru do zobrazeni VoIP uctu a vypisu hovoru uzivatele
Upravy:
- prepsani a okomentovani trid Billing a LBilling pro VoIP