Revize a29b0d63
Přidáno uživatelem Michal Kliment před více než 9 roky(ů)
application/controllers/export.php | ||
---|---|---|
// character encoding
|
||
if (!$is_utf)
|
||
{
|
||
$field = iconv('utf-8', $encoding, $value);
|
||
$value = iconv('utf-8', $encoding, $value);
|
||
}
|
||
// emails body
|
||
if ($content == 'email_queue_sent' && $key == 'message')
|
application/controllers/json.php | ||
---|---|---|
|
||
$id = $this->input->get('id');
|
||
|
||
$accounts = ORM::factory('account')->get_some_doubleentry_account_names(
|
||
$origin_account_id, $id
|
||
);
|
||
|
||
$arr_accounts = array();
|
||
foreach ($accounts as $account)
|
||
{ // convert the object into array (used for HTML select list)
|
||
$name = $account->name . ' ' . $account->id . ' (' . $account->addr . ')';
|
||
$arr_accounts[$name] = $account->id;
|
||
}
|
||
$account_model = new Account_Model;
|
||
$accounts = $account_model->select_some_list($origin_account_id, $id);
|
||
|
||
echo json_encode($arr_accounts);
|
||
echo json_encode(array_flip($accounts));
|
||
}
|
||
|
||
/**
|
application/controllers/membership_interrupts.php | ||
---|---|---|
|
||
$filter_form->add('id')
|
||
->type('number');
|
||
|
||
$filter_form->add('member_id')
|
||
->type('number');
|
||
|
||
$filter_form->add('name')
|
||
->label(__('Member name'))
|
application/controllers/transfers.php | ||
---|---|---|
|
||
// destination account, instead of origin one
|
||
$dst_account_model = new Account_Model();
|
||
$dst_accounts = $dst_account_model->get_some_doubleentry_account_names($origin_account_id);
|
||
|
||
foreach ($dst_accounts as $dst_account)
|
||
{ // convert the object into array (used for HTML select list)
|
||
$arr_dst_accounts[$dst_account->id] = $dst_account->name . ' '
|
||
. $dst_account->id . ' (' . $dst_account->addr . ')';
|
||
}
|
||
$arr_dst_accounts = $dst_account_model->select_some_list($origin_account_id);
|
||
asort($arr_dst_accounts, SORT_LOCALE_STRING);
|
||
// default destination account
|
||
$operating = ORM::factory('account')->where(
|
||
'account_attribute_id', Account_attribute_Model::OPERATING
|
||
)->find();
|
||
// array with only one origin account
|
||
$arr_orig_accounts[$origin_account->id] = $origin_account->name . ' ' . $origin_account->id;
|
||
$arr_orig_accounts[$origin_account->id] = $origin_account->name . ' ('
|
||
. $origin_account->id . ', '
|
||
. $origin_account->account_attribute_id . ', '
|
||
. $origin_account->member_id . ')';
|
||
// account attributes for types of accounts
|
||
$aa_model = new Account_attribute_Model();
|
||
$account_attributes = $aa_model->get_account_attributes();
|
||
... | ... | |
$form->group('Origin account');
|
||
|
||
$form->dropdown('oname')
|
||
->label('Origin account (account name, account ID)')
|
||
->label('Origin account (name, ID, type, member ID)')
|
||
->options($arr_orig_accounts)
|
||
->rules('required')
|
||
->style('width:600px');
|
||
... | ... | |
->style('width:600px');
|
||
|
||
$form->dropdown('aname')
|
||
->label('Destination account (account name, account ID)')
|
||
->label('Destination account (name, ID, type, member ID)')
|
||
->options($arr_dst_accounts)
|
||
->rules('required')
|
||
->selected($operating->id)
|
||
... | ... | |
|
||
$account_model = new Account_Model();
|
||
|
||
$accounts = $account_model->get_some_doubleentry_account_names();
|
||
$origin_accounts = $accounts;
|
||
$dst_accounts = $accounts;
|
||
|
||
foreach ($dst_accounts as $dst_account)
|
||
{
|
||
$arr_dst_accounts[$dst_account->id] = $dst_account->name . ' '
|
||
. $dst_account->id . ' (' . $dst_account->addr . ')';
|
||
}
|
||
$arr_dst_accounts = $account_model->select_some_list();
|
||
asort($arr_dst_accounts);
|
||
|
||
// array origin accounts for dropdown
|
||
$arr_orig_accounts = $arr_dst_accounts;
|
||
|
||
// default destination account
|
||
$operating = ORM::factory('account')->where(
|
||
'account_attribute_id', Account_attribute_Model::OPERATING
|
||
)->find();
|
||
// account attributes for types of accounts
|
||
$aa_model = new Account_attribute_Model();
|
||
$account_attributes = $aa_model->get_account_attributes();
|
||
foreach ($account_attributes as $account_attribute)
|
||
{
|
||
$arr_attributes[$account_attribute->id] = $dst_account->name . ' ' . $dst_account->id;
|
||
}
|
||
|
||
// form
|
||
$form = new Forge('transfers/add');
|
||
... | ... | |
$form->group('Origin account');
|
||
|
||
$form->dropdown('oname')
|
||
->label(__('Origin account (account name, account ID)') . ':')
|
||
->label('Origin account (name, ID, type, member ID)')
|
||
->options($arr_orig_accounts)
|
||
->rules('required');
|
||
->rules('required')
|
||
->style('width:600px');
|
||
// destination account
|
||
$form->group('Destination account');
|
||
|
||
$form->dropdown('aname')
|
||
->label(__('Destination account (account name, account ID)') . ':')
|
||
->label('Destination account (name, ID, type, member ID)')
|
||
->options($arr_dst_accounts)
|
||
->rules('required')
|
||
->selected($operating->id);
|
||
->selected($operating->id)
|
||
->style('width:600px');
|
||
|
||
// other information
|
||
$form->group('Transfer');
|
||
... | ... | |
Controller::error(RECORD);
|
||
}
|
||
|
||
if (isset($origin_account))
|
||
{ // transfer from specific account?
|
||
// save for callback function valid_amount_to_send
|
||
$this->origin = $origin_account;
|
||
$origin_acc = new Account_Model($origin_account);
|
||
|
||
if ($origin_acc->id == 0)
|
||
{
|
||
Controller::error(RECORD);
|
||
}
|
||
|
||
if (!$this->acl_check_new('Accounts_Controller', 'transfers', $origin_acc->member_id))
|
||
{ // does the user have rights for this?
|
||
Controller::error(ACCESS);
|
||
}
|
||
|
||
// yes = create object of all accounts except the origin one
|
||
$dst_account_model = new Account_Model();
|
||
$dst_accounts = $dst_account_model->get_some_doubleentry_account_names($origin_account);
|
||
}
|
||
else
|
||
{ // transfer from any (arbitrary) account
|
||
if (!$this->acl_check_new('Accounts_Controller', 'transfers'))
|
||
{ // Does the user have the rights for this?
|
||
Controller::error(ACCESS);
|
||
}
|
||
|
||
// yes = create object of all accounts
|
||
$origin_acc = new Account_Model();
|
||
$dst_accounts = $origin_accounts = $origin_acc->get_some_doubleentry_account_names();
|
||
}
|
||
$arr_orig_accounts[$origin_acc->id] =
|
||
"$origin_acc->name - " . __('Account ID') . " $origin_acc->name - "
|
||
. __('Member ID') . " $origin_acc->member_id";
|
||
// transfer from specific account?
|
||
// save for callback function valid_amount_to_send
|
||
$this->origin = $origin_account;
|
||
$origin_acc = new Account_Model($origin_account);
|
||
|
||
if (!$origin_acc->id)
|
||
{
|
||
Controller::error(RECORD);
|
||
}
|
||
|
||
if (!$this->acl_check_new('Accounts_Controller', 'transfers', $origin_acc->member_id))
|
||
{ // does the user have rights for this?
|
||
Controller::error(ACCESS);
|
||
}
|
||
|
||
$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);
|
application/controllers/users.php | ||
---|---|---|
$filter_form->add('login')
|
||
->label(__('Login name'))
|
||
->callback('json/user_login');
|
||
|
||
$filter_form->add('member_id')
|
||
->type('number');
|
||
|
||
$filter_form->add('member_name')
|
||
->type('combo')
|
application/i18n/cs_CZ/texts.php | ||
---|---|---|
'deselect all' => 'Zrušit výběr',
|
||
'destination' => 'Destinace',
|
||
'destination account' => 'Cílový účet',
|
||
'destination account (account name, account id)' => 'Cílový účet (název účtu, ID účtu)',
|
||
'destination account (name, id, type, member id)' => 'Cílový účet (název, ID, typ, ID člena)',
|
||
'destination bank account' => 'Cílový bankovní účet',
|
||
'destination credit account' => 'Cílový kreditní účet',
|
||
'destination language' => 'Cílový jazyk',
|
||
... | ... | |
'interval of update' => 'Interval aktualizace',
|
||
'interval of update in seconds' => 'Interval aktualizace v sekundách',
|
||
'invalid address point' => 'Neplatná adresa',
|
||
'invalid amount format' => 'Chybný formát částka',
|
||
'invalid connect to interface - already has different link' => 'Nelze se připojit k rozhraní - již má jinou linku',
|
||
'invalid date' => 'Neplatné datum!',
|
||
'invalid date format' => 'Chybný formát datumu',
|
||
'invalid data - no data available' => 'Neplatná data - žádné data k dispozici',
|
||
'invalid file format (json_decode failed): %s' => 'chybný formát souboru (json_decode selhal): %s',
|
||
'invalid input data' => 'Neplatná vstupní data',
|
||
... | ... | |
'organization identifier' => 'IČ',
|
||
'organization_identifier' => 'IČ',
|
||
'origin account' => 'Zdrojový účet',
|
||
'origin account (account name, account id)' => 'Zdrojový účet (název účtu, ID účtu)',
|
||
'origin account (name, id, type, member id)' => 'Zdrojový účet (název, ID, typ, ID člena)',
|
||
'origin bank account' => 'Zdrojový bankovní účet',
|
||
'original term' => 'Původní výraz',
|
||
'originating call' => 'Odchozí volání',
|
application/libraries/Bank_Statement_File_Importer.php | ||
---|---|---|
/* check header of statement */
|
||
$header_data = $driver->get_header_data();
|
||
|
||
if (!$header_data ||
|
||
$header_data->get_bank_id() != $bank_account->bank_nr ||
|
||
$header_data->get_account_id() != $bank_account->account_nr)
|
||
{
|
||
$an = $header_data->get_account_id() . '/' . $header_data->get_bank_id();
|
||
$m = __('Bank account number in listing (%s) header does not match ' .
|
||
'bank account %s in database!', array($an, $acc));
|
||
throw new Exception($m);
|
||
}
|
||
if ($header_data !== NULL)
|
||
{
|
||
if (!$header_data ||
|
||
$header_data->get_bank_id() != $bank_account->bank_nr ||
|
||
$header_data->get_account_id() != $bank_account->account_nr)
|
||
{
|
||
$an = $header_data->get_account_id() . '/'
|
||
. $header_data->get_bank_id();
|
||
$m = __('Bank account number in listing (%s) header does not ' .
|
||
'match bank account %s in database!', array($an, $acc));
|
||
throw new Exception($m);
|
||
}
|
||
}
|
||
|
||
/* parse file */
|
||
if (!$driver->parse_file_data())
|
||
... | ... | |
*
|
||
* An error in the format may be add into error stack (addError) that is later
|
||
* displayed to user if this function returns FALSE.
|
||
*
|
||
* If bank statement file not providing any header information NULL can
|
||
* be returned to skip assert for bank account match.
|
||
*
|
||
* @return Header_Data
|
||
* @return Header_Data|boolean|null
|
||
*/
|
||
protected abstract function get_header_data();
|
||
|
application/libraries/Billing.php | ||
---|---|---|
|
||
if ($call && isset($call->descr) && $call->descr == 'OK')
|
||
{
|
||
$number = explode('@', $call->calls[0]->callee);
|
||
$number = explode('@', $call->callee);
|
||
$number = explode(':', $number[0]);
|
||
$number = $number[1];
|
||
|
application/libraries/importers/Csv_Fio_Bank_Statement_File_Importer.php | ||
---|---|---|
/*
|
||
* 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/
|
||
*
|
||
*
|
||
*/
|
||
|
||
require dirname(__FILE__) . '/Fio_Bank_Statement_File_Importer.php';
|
||
require dirname(__FILE__) . '/Fio/FioParser.php';
|
||
require dirname(__FILE__) . '/Fio/NewFioCsvParser.php';
|
||
|
||
/**
|
||
* FIO importer for statements in CSV format that are obtained from the FIO
|
||
* e-banking portal.
|
||
*
|
||
*
|
||
* It uses old version of driver for parsing.
|
||
*
|
||
*
|
||
* @author Ondrej Fibich
|
||
* @since 1.1
|
||
*/
|
||
class Csv_Fio_Bank_Statement_File_Importer extends Fio_Bank_Statement_File_Importer
|
||
{
|
||
|
||
|
||
/**
|
||
* Data reprezentation of import.
|
||
*
|
||
* @var array
|
||
*/
|
||
private $data = NULL;
|
||
|
||
|
||
/**
|
||
* Indicates whether header is available or not.
|
||
*
|
||
* @var boolean
|
||
*/
|
||
private $header_available = TRUE;
|
||
|
||
/*
|
||
* @Override
|
||
*/
|
||
... | ... | |
{
|
||
// reset
|
||
$this->data = NULL;
|
||
// convert encoding
|
||
$this->set_file_data(iconv('cp1250', 'UTF-8', $this->get_file_data()));
|
||
$this->header_available = TRUE;
|
||
// parse (we have no function for checking)
|
||
try
|
||
{
|
||
// parse
|
||
$this->data = FioParser::parseCSV($this->get_file_data());
|
||
|
||
// correct data
|
||
foreach ($this->data as &$row)
|
||
{
|
||
if ($row['mena'] != 'CZK')
|
||
{
|
||
throw new Exception(__('Unknown currency %s!', $row['mena']));
|
||
}
|
||
|
||
// convert date
|
||
if (preg_match('/^[0-9]{1,2}\.[0-9]{1,2}\.[0-9]{4}\.$/', $row['datum']) !== FALSE)
|
||
{
|
||
$date_arr = explode('.', $row['datum']);
|
||
$timestamp = mktime(0, 0, 0, $date_arr[1], $date_arr[0], $date_arr[2]);
|
||
$row['datum'] = date('Y-m-d', $timestamp);
|
||
}
|
||
|
||
// only transfer from Fio to Fio have 'nazev_protiuctu'
|
||
// for accounts in other banks we have to derive account name
|
||
if (!$row['nazev_protiuctu'] && $row['identifikace'])
|
||
{
|
||
$row['nazev_protiuctu'] = $row['identifikace'];
|
||
}
|
||
|
||
// convert from cents
|
||
$row['castka'] /= 100;
|
||
|
||
}
|
||
|
||
$parser_new = new NewFioCsvParser;
|
||
if ($parser_new->accept_file($this->get_file_data()))
|
||
{
|
||
$this->header_available = FALSE;
|
||
$this->data = $parser_new->parse($this->get_file_data());
|
||
// correct data
|
||
foreach ($this->data as &$row)
|
||
{
|
||
$this->correct_new_listing_row($row);
|
||
}
|
||
}
|
||
// old parser
|
||
else
|
||
{
|
||
$this->set_file_data(iconv('cp1250', 'UTF-8', $this->get_file_data()));
|
||
$this->data = FioParser::parseCSV($this->get_file_data());
|
||
// correct data
|
||
foreach ($this->data as &$row)
|
||
{
|
||
$this->correct_old_listing_row($row);
|
||
}
|
||
}
|
||
|
||
// ok
|
||
return TRUE;
|
||
}
|
||
... | ... | |
}
|
||
}
|
||
|
||
/**
|
||
* Correct passed listing row from old parser for application needs.
|
||
*
|
||
* @param array $row listing row passed by reference
|
||
* @throws Exception on error in data
|
||
*/
|
||
private function correct_new_listing_row(&$row)
|
||
{
|
||
if ($row['mena'] != 'CZK')
|
||
{
|
||
throw new Exception(__('Unknown currency %s!', $row['mena']));
|
||
}
|
||
// only transfer from Fio to Fio have 'nazev_protiuctu'
|
||
// for accounts in other banks we have to derive account name
|
||
if (!$row['nazev_protiuctu'] && $row['identifikace'])
|
||
{
|
||
$row['nazev_protiuctu'] = $row['identifikace'];
|
||
}
|
||
}
|
||
|
||
/**
|
||
* Correct passed listing row from old parser for application needs.
|
||
*
|
||
* @param array $row listing row passed by reference
|
||
* @throws Exception on error in data
|
||
*/
|
||
private function correct_old_listing_row(&$row)
|
||
{
|
||
if ($row['mena'] != 'CZK')
|
||
{
|
||
throw new Exception(__('Unknown currency %s!', $row['mena']));
|
||
}
|
||
|
||
// convert date
|
||
if (preg_match('/^[0-9]{1,2}\.[0-9]{1,2}\.[0-9]{4}\.$/', $row['datum']) !== FALSE)
|
||
{
|
||
$date_arr = explode('.', $row['datum']);
|
||
$timestamp = mktime(0, 0, 0, $date_arr[1], $date_arr[0], $date_arr[2]);
|
||
$row['datum'] = date('Y-m-d', $timestamp);
|
||
}
|
||
|
||
// only transfer from Fio to Fio have 'nazev_protiuctu'
|
||
// for accounts in other banks we have to derive account name
|
||
if (!$row['nazev_protiuctu'] && $row['identifikace'])
|
||
{
|
||
$row['nazev_protiuctu'] = $row['identifikace'];
|
||
}
|
||
|
||
// convert from cents
|
||
$row['castka'] /= 100;
|
||
}
|
||
|
||
/*
|
||
* @Override
|
||
*/
|
||
... | ... | |
{
|
||
if (empty($this->data))
|
||
throw new InvalidArgumentException('Check CSV first');
|
||
|
||
|
||
if (!$this->header_available)
|
||
{
|
||
return NULL;
|
||
}
|
||
|
||
$fio_ph = FioParser::getListingHeader();
|
||
|
||
|
||
$hd = new Header_Data($fio_ph['account_nr'], $fio_ph['bank_nr']);
|
||
|
||
|
||
$hd->currency = 'CZK';
|
||
$hd->openingBalance = $fio_ph['opening_balance'];
|
||
$hd->closingBalance = $fio_ph['closing_balance'];
|
||
$hd->dateStart = $fio_ph['from'];
|
||
$hd->dateEnd = $fio_ph['to'];
|
||
|
||
|
||
return $hd;
|
||
}
|
||
|
||
... | ... | |
{
|
||
return $this->data;
|
||
}
|
||
|
||
|
||
}
|
application/libraries/importers/Fio/NewFioCsvParser.php | ||
---|---|---|
<?php
|
||
|
||
/*
|
||
* 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/
|
||
*
|
||
*/
|
||
|
||
/**
|
||
* Auxiliary class for parsing CSV bank account listings from czech bank
|
||
* "FIO banka". Listing may be obtain from from the ebanking web application
|
||
* of FIO bank.
|
||
*
|
||
* The CSV format looks like this:
|
||
* "Datum";"ID operace";"ID pokynu";"KS";"Název banky";"Název protiúčtu";
|
||
* "Objem";"Měna";"Protiúčet";"Kód banky";"Zadal";"SS";"Typ";"Poznámka";
|
||
* "VS";"Upřesnění - objem";"Upřesnění - měna";"Zpráva pro příjemce"
|
||
* "Suma";"";"";"";"";"";"-188170,4";"CZK";"";"";"";"";"";"";"";"";"";""
|
||
*
|
||
* @author Ondřej Fibich <fibich@freenetis.org>
|
||
* @since 1.1.11
|
||
* @todo i18n of error messages
|
||
*/
|
||
class NewFioCsvParser
|
||
{
|
||
/**
|
||
* CSV column separator.
|
||
*/
|
||
const CSV_COL_DELIM = ';';
|
||
|
||
/**
|
||
* CSV column value wrapper.
|
||
*/
|
||
const CSV_COL_WRAPPER = '"';
|
||
|
||
/**
|
||
* Last line date string that is used for end of statement detection.
|
||
*/
|
||
const HEADER_LINE_DATE_VALUE = 'Suma';
|
||
|
||
/**
|
||
* Default CSV file encoding.
|
||
*/
|
||
const DEFAULT_CHARSET = 'UTF-8';
|
||
|
||
/**
|
||
* All fields available must be used and sorted alphabetically
|
||
*
|
||
* @var array[string]
|
||
*/
|
||
private static $fields = array
|
||
(
|
||
'datum' => 'Datum',
|
||
'id_pohybu' => 'ID operace',
|
||
'id_pokynu' => 'ID pokynu',
|
||
'ks' => 'KS',
|
||
'nazev_banky' => 'Název banky',
|
||
'nazev_protiuctu' => 'Název protiúčtu',
|
||
'castka' => 'Objem',
|
||
'mena' => 'Měna',
|
||
'protiucet' => 'Protiúčet',
|
||
'kod_banky' => 'Kód banky',
|
||
'provedl' => 'Zadal',
|
||
'ss' => 'SS',
|
||
'typ' => 'Typ',
|
||
'identifikace' => 'Poznámka',
|
||
'vs' => 'VS',
|
||
'upresneni_objem' => 'Upřesnění - objem',
|
||
'upresneni_mena' => 'Upřesnění - měna',
|
||
'zprava' => 'Zpráva pro příjemce'
|
||
);
|
||
|
||
/**
|
||
* FIO statement columns fields names.
|
||
*
|
||
* @return array
|
||
*/
|
||
public static function get_fields()
|
||
{
|
||
return self::$fields;
|
||
}
|
||
|
||
/**
|
||
* Parse bank statement in CSV format that is passed as string.
|
||
*
|
||
* @param string $csv string containing the original csv file.
|
||
* @param string $charset optional charset name of file, default is UTF-8
|
||
* @return array[array] Integer-indexed array of associative arrays.
|
||
* Each associative array represents one line of the CSV
|
||
* @throws Exception on parse error
|
||
*/
|
||
public function parse($csv, $charset = self::DEFAULT_CHARSET)
|
||
{
|
||
$total_sum = -1;
|
||
$sum = 0;
|
||
$keys = array_keys(self::$fields);
|
||
$lines = self::transformFileToLineArray($csv, $charset);
|
||
$result = array();
|
||
// check each line of CSV
|
||
for ($i = 0; $i < count($lines); $i++)
|
||
{
|
||
$line = trim($lines[$i]);
|
||
// header
|
||
if ($i == 0)
|
||
{
|
||
$this->checkHeaders($line);
|
||
}
|
||
else if ($i == 1)
|
||
{
|
||
$total_sum = $this->parseHeaderLine($line);
|
||
}
|
||
else if (empty($line)) // empty last line?
|
||
{
|
||
break;
|
||
}
|
||
else
|
||
{
|
||
// data lines
|
||
$cols = $this->parseLine($line, $keys);
|
||
// add data row
|
||
$sum += $cols['castka'];
|
||
$result[] = $cols;
|
||
}
|
||
}
|
||
$this->checkIntegrity($total_sum, $sum);
|
||
return $result;
|
||
}
|
||
|
||
/**
|
||
* Check whether parser accept given CSV file.
|
||
*
|
||
* @param string $csv string containing the original csv file.
|
||
* @param string $charset optional charset name of file, default is UTF-8
|
||
* @return boolean
|
||
*/
|
||
public function accept_file($csv, $charset = self::DEFAULT_CHARSET)
|
||
{
|
||
$lines = self::transformFileToLineArray($csv, $charset);
|
||
if (count($lines) < 3)
|
||
{
|
||
return FALSE;
|
||
}
|
||
try
|
||
{
|
||
$this->checkHeaders(trim($lines[0]));
|
||
$this->parseHeaderLine(trim($lines[1]));
|
||
return TRUE;
|
||
}
|
||
catch (Exception $ex)
|
||
{
|
||
return FALSE;
|
||
}
|
||
}
|
||
|
||
/**
|
||
* Parse statement header line with total sum.
|
||
*
|
||
* @param string $line_str raw CSV line
|
||
*/
|
||
private function parseHeaderLine($line_str)
|
||
{
|
||
$fields_keys = array_keys(self::$fields);
|
||
$columns = $this->parseLine($line_str, $fields_keys, FALSE);
|
||
if ($columns['datum'] != self::HEADER_LINE_DATE_VALUE)
|
||
{
|
||
throw new Exception('Chybná hlavička výpisu.');
|
||
}
|
||
if (empty($columns['castka']))
|
||
{
|
||
throw new Exception('Chybná hlavička výpisu (suma).');
|
||
}
|
||
return $columns['castka'];
|
||
}
|
||
|
||
/**
|
||
* Checks headers that start data part of statement.
|
||
*
|
||
* @param integer $header_line header line
|
||
* @throws Exception
|
||
*/
|
||
private function checkHeaders($header_line)
|
||
{
|
||
$em = __("Nelze parsovat hlavičku Fio výpisu. Ujistěte se, že jste "
|
||
. "zvolili všech " . count(self::$fields) . " sloupců k importu "
|
||
. "v internetovém bankovnictví.");
|
||
$expected_header_cols = array_values(self::$fields);
|
||
// first column has issue with some UTF-8 characters
|
||
$fix_hl = preg_replace('/^[\x00-\x1F\x80-\xFF]+/', '', $header_line);
|
||
// extract header
|
||
$header_cols = str_getcsv($fix_hl, self::CSV_COL_DELIM,
|
||
self::CSV_COL_WRAPPER);
|
||
// check if extracted
|
||
if (empty($header_cols))
|
||
{
|
||
throw new Exception($em);
|
||
}
|
||
// check if count match
|
||
if (count($header_cols) != count($expected_header_cols))
|
||
{
|
||
throw new Exception($em);
|
||
}
|
||
// check each column
|
||
for ($i = count($header_cols) - 1; $i >= 0; $i--)
|
||
{
|
||
if ($header_cols[$i] != $expected_header_cols[$i])
|
||
{
|
||
throw new Exception($em);
|
||
}
|
||
}
|
||
}
|
||
|
||
/**
|
||
* Parse line of dump
|
||
*
|
||
* @param string $line
|
||
* @param array $keys
|
||
* @param boolean $parse_date
|
||
* @return array
|
||
* @throws Exception
|
||
*/
|
||
private function parseLine($line, $keys, $parse_date = TRUE)
|
||
{
|
||
$cols = str_getcsv($line, self::CSV_COL_DELIM, self::CSV_COL_WRAPPER);
|
||
|
||
if (count($cols) != count($keys))
|
||
{
|
||
throw new Exception('Chybný počet políček v položce výpisu.');
|
||
}
|
||
|
||
// Convert to associative array
|
||
$assoc_cols = array_combine($keys, $cols);
|
||
|
||
// Convert date
|
||
if ($parse_date)
|
||
{
|
||
$assoc_cols['datum'] = self::parseDate($assoc_cols['datum']);
|
||
}
|
||
|
||
// Amount has to be converted
|
||
$assoc_cols['castka'] = self::parseAmount($assoc_cols['castka']);
|
||
|
||
// Trim leading zeros from VS
|
||
$assoc_cols['vs'] = ltrim($assoc_cols['vs'], '0');
|
||
|
||
// join both "upresneni"
|
||
$assoc_cols['upresneni'] = trim($assoc_cols['upresneni_objem'] . ' ' .
|
||
$assoc_cols['upresneni_mena']);
|
||
|
||
// column prevod N/A
|
||
$assoc_cols['prevod'] = NULL;
|
||
|
||
return $assoc_cols;
|
||
}
|
||
|
||
/**
|
||
* Checks parsed money amount agains data from integrity line.
|
||
*
|
||
* @param array $sum
|
||
* @param integer $calculated_sum total counted sum
|
||
* @throws Exception on integrity error
|
||
*/
|
||
private function checkIntegrity($sum, $calculated_sum)
|
||
{
|
||
if (abs($sum - $calculated_sum) > 0.0001)
|
||
{
|
||
throw new Exception("Chybný kontrolní součet částky "
|
||
. "('$calculated_sum' != '$sum').");
|
||
}
|
||
}
|
||
|
||
/**
|
||
* Normalize string amount to double value.
|
||
*
|
||
* @example " 1000 278,40 " -> "1000278.40"
|
||
* @param string $amount
|
||
* @return double
|
||
* @throws InvalidArgumentException on invalid passed amount
|
||
*/
|
||
public static function parseAmount($amount)
|
||
{
|
||
$norm_amount = str_replace(array(' ', ','), array('', '.'), $amount);
|
||
if (!is_numeric($norm_amount))
|
||
{
|
||
$m = __('Invalid amount format') . ': ' . $amount;
|
||
throw new InvalidArgumentException($m);
|
||
}
|
||
return doubleval($norm_amount);
|
||
}
|
||
|
||
/**
|
||
* Parse date from format DD.MM.YYYY into YYYY-MM-DD.
|
||
*
|
||
* @param string $date in format DD.MM.YYYY
|
||
* @return string date in format YYYY-MM-DD
|
||
* @throws InvalidArgumentException on invalid date format
|
||
*/
|
||
public static function parseDate($date)
|
||
{
|
||
$matches = NULL;
|
||
if (!preg_match("/^(\d{1,2})\.(\d{1,2})\.(\d{4})$/", $date, $matches))
|
||
{
|
||
$m = __('Invalid date format') . ': ' . $date;
|
||
throw new InvalidArgumentException($m);
|
||
}
|
||
$timestamp = mktime(0, 0, 0, $matches[2], $matches[1], $matches[3]);
|
||
return date('Y-m-d', $timestamp);
|
||
}
|
||
|
||
/**
|
||
* Transforms file content in passed charset into array of its lines encoded
|
||
* in UTF-8 encoding. This function must handle differences of end of line
|
||
* separators on all platforms.
|
||
*
|
||
* @param string $file_content file countent to be transformed
|
||
* @param string $charset charset of file content
|
||
* @return array array of lines in UTF-8 charset
|
||
*/
|
||
public static function transformFileToLineArray($file_content, $charset)
|
||
{
|
||
$internal_charset = 'UTF-8';
|
||
$fc_utf8 = NULL;
|
||
// transform to uTF-8
|
||
if (strtolower($charset) != strtolower($internal_charset))
|
||
{
|
||
$fc_utf8 = iconv($charset, $internal_charset, $file_content);
|
||
}
|
||
else
|
||
{
|
||
$fc_utf8 = $file_content;
|
||
}
|
||
// eplode lines
|
||
return preg_split("/\r\n|\n|\r/", $fc_utf8);
|
||
}
|
||
|
||
}
|
application/libraries/importers/Fio_Bank_Statement_File_Importer.php | ||
---|---|---|
$statement->bank_account_id = $ba->id;
|
||
$statement->user_id = $this->get_user_id();
|
||
$statement->type = $this->get_importer_name();
|
||
$statement->from = $header->dateStart;
|
||
$statement->to = $header->dateEnd;
|
||
$statement->opening_balance = $header->openingBalance;
|
||
$statement->closing_balance = $header->closingBalance;
|
||
if ($header != NULL)
|
||
{
|
||
$statement->from = $header->dateStart;
|
||
$statement->to = $header->dateEnd;
|
||
$statement->opening_balance = $header->openingBalance;
|
||
$statement->closing_balance = $header->closingBalance;
|
||
}
|
||
$statement->save_throwable();
|
||
|
||
/* transactions */
|
application/models/account.php | ||
---|---|---|
public function get_some_doubleentry_account_names($origin = null, $account_attribute_id = null)
|
||
{
|
||
// conditions
|
||
$cond_origin = "";
|
||
$where = "";
|
||
$where = $cond_origin = '';
|
||
// make origin condition
|
||
if ($origin !== null)
|
||
{
|
||
$cond_origin = "AND a.id <> " . intval($origin) . "
|
||
AND (a.account_attribute_id = ".Account_attribute_Model::CREDIT."
|
||
OR a.account_attribute_id = ".Account_attribute_Model::OPERATING."
|
||
OR a.account_attribute_id = ".Account_attribute_Model::PROJECT.")";
|
||
$allowed_types = array(Account_attribute_Model::CREDIT,
|
||
Account_attribute_Model::OPERATING,
|
||
Account_attribute_Model::PROJECT,
|
||
Account_attribute_Model::MEMBER_FEES);
|
||
$cond_origin = "AND a.id <> " . intval($origin)
|
||
. " AND a.account_attribute_id IN ("
|
||
. implode(', ', array_map('intval', $allowed_types)) . ")";
|
||
}
|
||
// make account confition
|
||
// make account attribute condition
|
||
if ($account_attribute_id)
|
||
{
|
||
$where = 'WHERE a.account_attribute_id=' . intval($account_attribute_id);
|
||
... | ... | |
// query
|
||
return $this->db->query("
|
||
SELECT a.id, a.name, a.member_id, a.account_attribute_id,
|
||
IF(t.quarter IS NULL, concat(t.town, ' ', p.street_number),
|
||
concat(t.town, '-', t.quarter, ' ', p.street_number)) AS addr
|
||
m.name as member_name
|
||
FROM accounts a
|
||
JOIN members m ON
|
||
a.member_id=m.id
|
||
$cond_origin
|
||
JOIN address_points p ON m.address_point_id=p.id
|
||
JOIN towns t ON t.id=p.town_id $where
|
||
JOIN members m ON a.member_id=m.id $cond_origin
|
||
$where
|
||
ORDER BY a.name
|
||
");
|
||
}
|
||
|
||
/**
|
||
* Select some double entry accounts for select. If origin is supplied than
|
||
* account with origin ID is not in list. If account attribute ID is
|
||
* supplied than only account with given attribute ID are listed.
|
||
*
|
||
* @author Ondřej Fibich <fibich@freenetis.org>
|
||
* @param integer $origin optional origin account ID to be ignored
|
||
* @param type $account_attribute_id optional account attribute ID for filter
|
||
* @return array associative array with account ID as key and text
|
||
* reprezentation of account as value (name, ID, attribute ID, owner
|
||
* member ID)
|
||
*/
|
||
public function select_some_list($origin = NULL, $account_attribute_id = NULL)
|
||
{
|
||
$accounts = $this->get_some_doubleentry_account_names($origin,
|
||
$account_attribute_id);
|
||
$arr_accounts = array();
|
||
foreach ($accounts as $a)
|
||
{
|
||
$name = $a->name . ' (' . $a->id . ', ' . $a->account_attribute_id . ')';
|
||
if ($a->account_attribute_id == Account_attribute_Model::CREDIT)
|
||
{
|
||
$name .= ' - ' . $a->member_name . ' (' . $a->member_id . ')';
|
||
}
|
||
$arr_accounts[$a->id] = $a->name . ' (' . $a->id . ', '
|
||
. $a->account_attribute_id . ', ' . $a->member_id . ')';
|
||
}
|
||
return $arr_accounts;
|
||
}
|
||
|
||
/**
|
||
* It gets balance of account.
|
||
* It subtracts all outbound transfers from all incoming transfers.
|
application/vendors/billing/lbilling/lbilling.php | ||
---|---|---|
$line = 0;
|
||
|
||
$acc = explode(";", $output[$line]);
|
||
|
||
|
||
$account = new stdClass();
|
||
$account->valid_to = $acc[0];
|
||
$account->valid_from = $acc[1];
|
||
$account->desc = $acc[2];
|
||
... | ... | |
for ($line; $line < $count; $line++)
|
||
{
|
||
$acc = explode(";", $output[$line]);
|
||
|
||
$account->subscribers[$i] = new stdClass();
|
||
$account->subscribers[$i]->valid_to = $acc[0];
|
||
$account->subscribers[$i]->valid_from = $acc[1];
|
||
$account->subscribers[$i]->descr = $acc[2];
|
||
... | ... | |
|
||
$acc = explode(";", $output[$line]);
|
||
|
||
$account = new stdClass();
|
||
$account->billingid = $acc[0];
|
||
$account->from = $acc[1];
|
||
$account->to = $acc[2];
|
||
... | ... | |
for ($line; $line < $count; $line++)
|
||
{
|
||
$acc = explode(";", $output[$line]);
|
||
$account->calls[$i] = new stdClass();
|
||
$account->calls[$i]->provider = $acc[0];
|
||
$account->calls[$i]->rate_vat = $acc[1];
|
||
$account->calls[$i]->subscriber = $acc[2];
|
||
... | ... | |
|
||
$acc = explode(";", $output[$line]);
|
||
|
||
$subscriber = new stdClass();
|
||
$subscriber->billingid = $acc[0];
|
||
$subscriber->from = $acc[1];
|
||
$subscriber->to = $acc[2];
|
||
... | ... | |
for ($line; $line < $count; $line++)
|
||
{
|
||
$acc = explode(";", $output[$line]);
|
||
|
||
$subscriber->calls[$i] = new stdClass();
|
||
$subscriber->calls[$i]->provider = $acc[0];
|
||
$subscriber->calls[$i]->rate_vat = $acc[1];
|
||
$subscriber->calls[$i]->subscriber = $acc[2];
|
||
... | ... | |
|
||
$acc = explode(";", $output[$line]);
|
||
|
||
$partner = new stdClass();
|
||
$partner->from = $acc[0];
|
||
$partner->to = $acc[1];
|
||
|
||
... | ... | |
{
|
||
$acc = explode(";", $output[$line]);
|
||
|
||
$partner->calls[$i] = new stdClass();
|
||
$partner->calls[$i]->provider = $acc[0];
|
||
$partner->calls[$i]->cost_sum = $acc[1];
|
||
$partner->calls[$i]->subscriber = $acc[2];
|
||
... | ... | |
|
||
$acc = explode(";", $output[$line]);
|
||
|
||
$call = new stdClass();
|
||
$call->length = $acc[0];
|
||
$call->callee = $acc[1];
|
||
$call->caller = $acc[2];
|
||
... | ... | |
for ($line; $line < $count; $line++)
|
||
{
|
||
$acc = explode(";", $output[$line]);
|
||
$call->calls[$i] = new stdClass();
|
||
$call->calls[$i]->provider = $acc[0];
|
||
$call->calls[$i]->rate_vat = $acc[1];
|
||
$call->calls[$i]->subscriber = $acc[2];
|
application/vendors/billing/lbilling/perl/lbilling-get_account.pl | ||
---|---|---|
#!/usr/bin/perl
|
||
|
||
use strict;
|
||
use DBI;
|
||
use Getopt::Std;
|
||
use Data::Dumper;
|
||
use warnings;
|
||
|
||
if ($#ARGV != 2) {
|
||
print "Wrong number of parameters", "\n";
|
||
exit 0;
|
||
}
|
||
|
||
my $account = {"billingid" => $ARGV[2]};
|
||
|
||
use SOAP::Lite +autodispatch =>
|
||
uri => "http://sip.nfx.czf/lBilling",
|
||
proxy => 'https://'.$ARGV[0].':'.$ARGV[1].'@sip.nfx.czf/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->get_account($account) ) {
|
||
print $result->{"valid_to"}, ";";
|
||
print $result->{"valid_from"}, ";";
|
||
print $result->{"descr"}, ";";
|
||
print $result->{"state"}, ";";
|
||
print $result->{"billingid"}, ";";
|
||
print $result->{"currency"}, ";";
|
||
print $result->{"ballance"}, ";";
|
||
print $result->{"limit"}, ";";
|
||
print $result->{"type"}, ";";
|
||
print $result->{"partner"}, "\n";
|
||
|
||
unless ( $result->{"subscribers"} ) {
|
||
print "0", "\n";
|
||
exit 1;
|
||
}
|
||
|
||
my $count = @{$result->{"subscribers"}};
|
||
|
||
print $count, "\n";
|
||
|
||
for ($i=0; $i<$count; $i++)
|
||
{
|
||
print $result->{"subscribers"}[$i]->{"valid_to"}, ";";
|
||
print $result->{"subscribers"}[$i]->{"valid_from"}, ";";
|
||
print $result->{"subscribers"}[$i]->{"descr"}, ";";
|
||
print $result->{"subscribers"}[$i]->{"state"}, ";";
|
||
print $result->{"subscribers"}[$i]->{"billingid"}, ";";
|
||
print $result->{"subscribers"}[$i]->{"tarif"}, ";";
|
||
print $result->{"subscribers"}[$i]->{"cid"}, ";";
|
||
print $result->{"subscribers"}[$i]->{"limit"}, "\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;
|
||
}
|
||
#!/usr/bin/perl
|
||
|
||
use strict;
|
||
use DBI;
|
||
use Getopt::Std;
|
||
use Data::Dumper;
|
||
use warnings;
|
||
|
||
if ($#ARGV != 2) {
|
||
print "Wrong number of parameters", "\n";
|
||
exit 0;
|
||
}
|
||
|
||
$ENV{PERL_LWP_SSL_VERIFY_HOSTNAME}=0;
|
||
|
||
use SOAP::Lite;
|
||
my $lbilling = SOAP::Lite
|
||
-> uri("http://sip.nfx.czf/lBilling")
|
||
-> proxy('https://'.$ARGV[0].':'.$ARGV[1].'@sip.nfx.czf/cgi-bin/admin/lbilling/soap.pl');
|
||
|
||
unless ( $lbilling ) {
|
||
print "Could not create SOAP instance", "\n";
|
||
exit 0;
|
||
}
|
||
|
||
my $account = {"billingid" => $ARGV[2]};
|
||
|
||
my $result;
|
||
my $i;
|
||
|
||
$result = $lbilling->get_account($account)->result;
|
||
|
||
if ( exists($result->{"status"}) and $result->{"status"} ) {
|
||
$result = $result->{"data"};
|
||
|
||
print $result->{"valid_to"}, ";";
|
||
print $result->{"valid_from"}, ";";
|
||
print $result->{"descr"}, ";";
|
||
print $result->{"state"}, ";";
|
||
print $result->{"billingid"}, ";";
|
||
print $result->{"currency"}, ";";
|
||
print $result->{"ballance"}, ";";
|
||
print $result->{"limit"}, ";";
|
||
print $result->{"type"}, ";";
|
||
print $result->{"partner"}, "\n";
|
||
|
||
unless ( $result->{"subscribers"} ) {
|
||
print "0", "\n";
|
||
exit 1;
|
||
}
|
||
|
||
my $count = @{$result->{"subscribers"}};
|
||
|
||
print $count, "\n";
|
||
|
||
for ($i=0; $i<$count; $i++)
|
||
{
|
||
print $result->{"subscribers"}[$i]->{"valid_to"}, ";";
|
||
print $result->{"subscribers"}[$i]->{"valid_from"}, ";";
|
||
print $result->{"subscribers"}[$i]->{"descr"}, ";";
|
||
print $result->{"subscribers"}[$i]->{"state"}, ";";
|
||
print $result->{"subscribers"}[$i]->{"billingid"}, ";";
|
||
print $result->{"subscribers"}[$i]->{"tarif"}, ";";
|
||
print $result->{"subscribers"}[$i]->{"cid"}, ";";
|
||
print $result->{"subscribers"}[$i]->{"limit"}, "\n";
|
||
}
|
||
exit 1;
|
||
} else {
|
||
if ( exists($result->{"error"}) ) {
|
||
my $error = $result->{"error"};
|
||
my $errcount = @{$result->{"error"}};
|
||
for ($i=0; $i<$errcount; $i++)
|
||
{
|
||
print $result->{"error"}->[$i], "\n";
|
||
}
|
||
}
|
||
exit 0;
|
||
}
|
application/vendors/billing/lbilling/perl/lbilling-get_account_calls.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;
|
||
}
|
||
|
||
use SOAP::Lite +autodispatch =>
|
||
uri => "http://sip.nfx.czf/lBilling",
|
||
proxy => 'https://'.$ARGV[0].':'.$ARGV[1].'@sip.nfx.czf/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;
|
||
|
||
my $account = {"billingid" => $ARGV[2], "from" => $ARGV[3], "to" => $ARGV[4]};
|
||
|
||
if ( $result = $lbilling->get_account_calls($account) ) {
|
||
|
||
print $result->{"billingid"}, ";";
|
||
print $result->{"from"}, ";";
|
||
print $result->{"to"}, "\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;
|
||
}
|
||
#!/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;
|
||
}
|
||
|
||
$ENV{PERL_LWP_SSL_VERIFY_HOSTNAME}=0;
|
||
|
||
use SOAP::Lite;
|
||
my $lbilling = SOAP::Lite
|
||
-> uri("http://sip.nfx.czf/lBilling")
|
||
-> proxy('https://'.$ARGV[0].':'.$ARGV[1].'@sip.nfx.czf/cgi-bin/admin/lbilling/soap.pl');
|
||
|
||
unless ( $lbilling ) {
|
||
print "Could not create SOAP instance", "\n";
|
||
exit 0;
|
||
}
|
||
|
||
my $result;
|
||
my $i;
|
||
|
||
my $account = {"billingid" => $ARGV[2], "from" => $ARGV[3], "to" => $ARGV[4]};
|
||
|
||
$result = $lbilling->get_account_calls($account)->result;
|
||
|
||
if ( exists($result->{"status"}) and $result->{"status"} ) {
|
||
$result = $result->{"data"};
|
||
|
||
print $result->{"billingid"}, ";";
|
||
print $result->{"from"}, ";";
|
||
print $result->{"to"}, "\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 {
|
||
if ( exists($result->{"error"}) ) {
|
||
my $error = $result->{"error"};
|
||
my $errcount = @{$result->{"error"}};
|
||
for ($i=0; $i<$errcount; $i++)
|
||
{
|
||
print $result->{"error"}->[$i], "\n";
|
||
}
|
||
}
|
||
exit 0;
|
||
}
|
application/vendors/billing/lbilling/perl/lbilling-get_account_cost.pl | ||
---|---|---|
#!/usr/bin/perl
|
||
|
||
use strict;
|
||
use DBI;
|
||
use Getopt::Std;
|
||
use Data::Dumper;
|
||
use warnings;
|
||
|
||
if ($#ARGV != 1) {
|
||
print "Wrong number of parameters", "\n";
|
||
exit 0;
|
||
}
|
||
|
||
use SOAP::Lite +autodispatch =>
|
||
uri => "http://sip.nfx.czf/lBilling",
|
||
proxy => 'https://'.$ARGV[0].':'.$ARGV[1].'@sip.nfx.czf/cgi-bin/admin/lbilling/soap.pl';
|
||
|
||
my $lbilling = lBilling->new();
|
||
|
||
unless ( $lbilling ) {
|
||
print "Could not create SOAP instance", "\n";
|
||
exit 0;
|
||
}
|
||
|
||
my $result;
|
||
my $line;
|
||
my @error;
|
||
|
||
my $account = {"billingid" => 1949, "from" => 0, "to" => time()};
|
||
|
||
if ( $result = $lbilling->get_account_cost($account) ) {
|
||
#print $result->{"valid_to"}, "\n";
|
||
#print $result->{"valid_from"}, "\n";
|
||
#print $result->{"descr"}, "\n";
|
||
#print $result->{"state"}, "\n";
|
||
#print $result->{"billingid"}, "\n";
|
||
#print $result->{"currency"}, "\n";
|
||
#print $result->{"ballance"}, "\n";
|
||
#print $result->{"limit"}, "\n";
|
||
#print $result->{"type"}, "\n";
|
||
#print $result->{"partner"}, "\n";
|
||
print Dumper($result);
|
||
exit 1;
|
||
} else {
|
||
@error = $lbilling->get_error();
|
||
print Dumper($lbilling->get_error());
|
||
#print $error[0][0], "\n";
|
||
#print $error[0][1], "\n";
|
||
exit 0;
|
||
}
|
||
#!/usr/bin/perl
|
||
|
||
use strict;
|
||
use DBI;
|
||
use Getopt::Std;
|
||
use Data::Dumper;
|
||
use warnings;
|
||
|
||
if ($#ARGV != 1) {
|
||
print "Wrong number of parameters", "\n";
|
||
exit 0;
|
||
}
|
||
|
||
$ENV{PERL_LWP_SSL_VERIFY_HOSTNAME}=0;
|
||
|
||
use SOAP::Lite;
|
||
my $lbilling = SOAP::Lite
|
||
-> uri("http://sip.nfx.czf/lBilling")
|
||
-> proxy('https://'.$ARGV[0].':'.$ARGV[1].'@sip.nfx.czf/cgi-bin/admin/lbilling/soap.pl');
|
||
|
||
unless ( $lbilling ) {
|
||
print "Could not create SOAP instance", "\n";
|
||
exit 0;
|
||
}
|
||
|
||
my $result;
|
||
my $line;
|
||
my @error;
|
||
|
||
my $account = {"billingid" => 1949, "from" => 0, "to" => time()};
|
||
|
||
$result = $lbilling->get_account_calls($account)->result;
|
||
|
||
if ( exists($result->{"status"}) and $result->{"status"} ) {
|
||
$result = $result->{"data"};
|
||
#print $result->{"valid_to"}, "\n";
|
||
#print $result->{"valid_from"}, "\n";
|
||
#print $result->{"descr"}, "\n";
|
||
#print $result->{"state"}, "\n";
|
||
#print $result->{"billingid"}, "\n";
|
||
#print $result->{"currency"}, "\n";
|
||
#print $result->{"ballance"}, "\n";
|
||
#print $result->{"limit"}, "\n";
|
||
#print $result->{"type"}, "\n";
|
||
#print $result->{"partner"}, "\n";
|
||
print Dumper($result);
|
||
exit 1;
|
||
} else {
|
||
@error = $lbilling->get_error();
|
Také k dispozici: Unified diff
Release 1.1.11