Projekt

Obecné

Profil

« Předchozí | Další » 

Revize 754

Přidáno uživatelem Ondřej Fibich před téměř 14 roky(ů)

Parser Vodafone faktur:
-prizpusobeni pro novejsi faktury - pridana podpora pro pripojeni k internetu na 1 den, upraveno parsovani mezinarodnich hovoru na pevnou linku
-upraveno testovani integrity dat pro vetsi efektivnost
-upraveno parsovani telefoniho cisla

Rozhrani telefonich faktur:
-uzivateli se ve vypisu zobrazuje cena firemnich a soukromych hovoru

Zobrazit rozdíly:

freenetis/trunk/kohana/application/i18n/cs_CZ/texts.php
'item separator' => 'Oddělovač položek',
'item(s) have been successfully added' => 'položka(ek) bylo úspěšně přidáno',
'is not telephonists' => 'Není telefonista',
'is missing from' => 'chybí z',
'january' => 'Leden',
'june' => 'Červen',
'july' => 'Červenec',
freenetis/trunk/kohana/application/models/phone_invoice_user.php
public function get_phone_invoices_of_user($user_id)
{
return $this->db->query(
"SELECT phone_invoice_users.id, phone_invoices.locked,
"SELECT p.id, phone_invoices.locked,
phone_invoices.billing_period_from,
phone_invoices.billing_period_to, phone_invoice_users.user_id,
phone_invoice_users.phone_number AS number
FROM phone_invoice_users
LEFT JOIN phone_invoices ON phone_invoice_users.phone_invoice_id = phone_invoices.id
WHERE phone_invoice_users.user_id =" . intval($user_id)
phone_invoices.billing_period_to, p.user_id,
p.phone_number AS number,
((
SELECT IFNULL(SUM(price), 0)
FROM phone_calls
WHERE phone_invoice_user_id=p.id AND private=0
) + (
SELECT IFNULL(SUM(price), 0)
FROM phone_fixed_calls
WHERE phone_invoice_user_id=p.id AND private=0
) + (
SELECT IFNULL(SUM(price), 0)
FROM phone_vpn_calls
WHERE phone_invoice_user_id=p.id AND private=0
) + (
SELECT IFNULL(SUM(price), 0)
FROM phone_pays
WHERE phone_invoice_user_id=p.id AND private=0
) + (
SELECT IFNULL(SUM(price), 0)
FROM phone_connections
WHERE phone_invoice_user_id=p.id AND private=0
) + (
SELECT IFNULL(SUM(price), 0)
FROM phone_roaming_sms_messages
WHERE phone_invoice_user_id=p.id AND private=0
) + (
SELECT IFNULL(SUM(price), 0)
FROM phone_sms_messages
WHERE phone_invoice_user_id=p.id AND private=0
) + (
SELECT IFNULL(SUM(price), 0)
FROM phone_roaming_sms_messages
WHERE phone_invoice_user_id=p.id AND private=0
)) AS price_company,
((
SELECT IFNULL(SUM(price), 0)
FROM phone_calls
WHERE phone_invoice_user_id=p.id AND private=1
) + (
SELECT IFNULL(SUM(price), 0)
FROM phone_fixed_calls
WHERE phone_invoice_user_id=p.id AND private=1
) + (
SELECT IFNULL(SUM(price), 0)
FROM phone_vpn_calls
WHERE phone_invoice_user_id=p.id AND private=1
) + (
SELECT IFNULL(SUM(price), 0)
FROM phone_pays
WHERE phone_invoice_user_id=p.id AND private=1
) + (
SELECT IFNULL(SUM(price), 0)
FROM phone_connections
WHERE phone_invoice_user_id=p.id AND private=1
) + (
SELECT IFNULL(SUM(price), 0)
FROM phone_roaming_sms_messages
WHERE phone_invoice_user_id=p.id AND private=1
) + (
SELECT IFNULL(SUM(price), 0)
FROM phone_sms_messages
WHERE phone_invoice_user_id=p.id AND private=1
) + (
SELECT IFNULL(SUM(price), 0)
FROM phone_roaming_sms_messages
WHERE phone_invoice_user_id=p.id AND private=1
)) AS price_private
FROM phone_invoice_users p
LEFT JOIN phone_invoices ON p.phone_invoice_id = phone_invoices.id
WHERE p.user_id =" . intval($user_id)
);
}
freenetis/trunk/kohana/application/controllers/phone_invoices.php
* Fuction checks access rights
* Return true if user with $login may view own $axo_section
* in this controller else return false
* @see Phone_invoices_Controller::user_field
*
* @param $axo_value object to view
* @param string $login
* @staticvar gacl $gacl_class
* @return boolean returns true if member has enough access rights
*/
private function _acl_check_view($axo_value, $login)
private static function _acl_check_view($axo_value, $login)
{
if (!isset($this->gacl_class))
static $gacl_class = NULL;
if ($gacl_class == NULL)
{
$this->phpgacl_init();
require_once(APPPATH.'vendors/phpgacl/gacl.class.php');
$gacl_class = new gacl();
}
return !empty($login) && $this->gacl_class->acl_check(
return !empty($login) && $gacl_class->acl_check(
'freenetis', 'view_own', 'all',
$login, 'Phone_invoices_Controller', $axo_value
);
......
}
$phone_inv_user_model = new Phone_invoice_user_Model();
$users_inv = $phone_inv_user_model->get_phone_invoices_of_user($user_id);;
$users_inv = $phone_inv_user_model->get_phone_invoices_of_user($user_id);
$grid = new Grid(url::base().url::current(true), null, array(
'use_paginator' => false,
......
$grid->field('number')->label(url_lang::lang('texts.Number'));
$grid->field('billing_period_from')->label(url_lang::lang('texts.Billing period from'));
$grid->field('billing_period_to')->label(url_lang::lang('texts.Billing period to'));
$grid->callback_field('price_company')->label(url_lang::lang('texts.Company'))
->callback('Phone_invoices_Controller::price_field');
$grid->callback_field('price_private')->label(url_lang::lang('texts.Private'))
->callback('Phone_invoices_Controller::price_field');
if ($this->acl_check_view('Phone_invoices_Controller', 'dumps', $user->member_id))
{
$grid->action_field('id')->label(url_lang::lang('texts.Show'))
......
* @param unknown_type $item
* @param unknown_type $name
*/
protected function user_field($item, $name)
protected static function user_field($item, $name)
{
if (!empty($item->name))
{
......
);
// is user in telephonists group
$user_model = new User_Model($item->user_id);
if (!$this->_acl_check_view('user_invoices', $user_model->login))
if (!self::_acl_check_view('user_invoices', $user_model->login))
{
echo ' <b style="color: red;">(' . url_lang::lang('texts.Is not telephonists') . '!)</b>';
}
......
*/
public static function price_field($item, $name)
{
echo ($item->price == .0) ? '<span style="color:red">' : '';
echo str_replace(' ', '&nbsp;', number_format($item->price, 2, ',', ' '));
echo ($item->price == .0) ? '</span' : '';
echo ($item->$name == .0) ? '<span style="color:red">' : '';
echo str_replace(' ', '&nbsp;', number_format($item->$name, 2, ',', ' '));
echo ($item->$name == .0) ? '</span>' : '';
}
/**
freenetis/trunk/kohana/application/libraries/Parser_Vodafone_Invoice.php
// <-- Konstanty prohlavičku faktury
const BILL_EXTRACT_DATA_LONG_CONNECTIONS = "^(Pøipojení na dlouho[^\(]*)\(([0-9]{2}).([0-9]{2}).([0-9]{4}) ([0-9]{2}):([0-9]{2})\) [0-9]+ ([0-9\, ]+) ([0-9]+) %";
const BILL_EXTRACT_DATA_DAY_CONNECTIONS = "^(Internet v mobilu na den) ([0-9]+) ([0-9\, ]+) ([0-9]+) % ([0-9\, ]+)$";
// Konstanty pro podrobný výpis -->
const BILL_EXTRACT_PHONE_REGEX = "^Telefonní èíslo ([0-9]{3} [0-9]{3} [0-9]{3}) Tarif";
......
// den, měsíc, hodina, minuta, sekunda, období, číslo, trvání, cíl, sleva, ?cena?
"^([0-9]{1,2}).([0-9]{1,2}). ([0-9]{2}):([0-9]{2}):([0-9]{2}) ([^0-9]+) (\+?[0-9]+) ([0-9]{2}:[0-9]{2}:[0-9]{2}) ([^0-9]+) ([0-9 ]+,[0-9]{2})([0-9 ]+,[0-9]{2})?$",
11,
"Celkem za Volání do zahr. - veø. tel. sí [0-9]{2}:[0-9]{2}:[0-9]{2} ([0-9 ]+,[0-9]{2}) ([0-9 ]+,[0-9]{2})"
"Celkem za Volání do zahr. - veø. tel. sí [0-9]{2}:[0-9]{2}:[0-9]{2} ([0-9 ]+,[0-9]{2})"
),
"sms" => array(
"smss", "SMS služby",
......
* Předčíslí je ve tvaru: xxx
*
* @param string $number Číslo ve tvaru [(+|00)xxx ]xxx xxx xxx
* @staticvar string $default_prefix
* @return string Telefoní číslo
* @throws InvalidArgumentException Při chybném čísle
*/
protected static function parse_phone_number($number)
{
$prefix = Settings::get("default_phone_prefix");
static $default_prefix = NULL;
if ($default_prefix == NULL)
{
$default_country = new Country_Model(Settings::get("default_country"));
if (!$default_country->id)
{
throw new ErrorException("Invalid default country, check table config and countries!!");
}
$default_prefix = $default_country->country_code;
}
// osekání mezer
$number = str_replace(" ", "", $number);
// kontrola formátu
......
// pokud je číslo nemá předčíslí a je devítimístné vložím předčíslí z configu
else if (mb_strlen($number) == 9)
{
$number = $prefix . $number;
$number = $default_prefix . $number;
}
}
else
......
$pre_number = self::parse_phone_number($r[1]);
continue;
}
// vyhledání řádku s připojením
// vyhledání řádku s dlouhodobým připojením
else if (mb_eregi(self::BILL_EXTRACT_DATA_LONG_CONNECTIONS, $line, $r) &&
$pre_number != null)
{
......
$data->get_bill_number($pre_number)->add_internet($internet);
}
// vyhledání řádku s krátkodobým připojením
else if (mb_eregi(self::BILL_EXTRACT_DATA_DAY_CONNECTIONS, $line, $r) &&
$pre_number != null)
{
$internet = new Internet_Service();
// neznám datum služby, použiju začátek intervalu
$internet->date_time = $data->billing_period_from;
$internet->date_time->setTime("00", "00", "00");
$internet->apn = rtrim($r[1]);
$internet->period = period::NO_PERIOD;
$internet->transfered = 0;
$internet->price = self::parse_price($r[3]);
try
{
$data->add_bill_number($pre_number, new Services($pre_number));
}
catch (InvalidArgumentException $ignore)
{ // číslo již existuje
}
$data->get_bill_number($pre_number)->add_internet($internet);
}
//
// 2. NALEZENÍ podrobných výpisů
//
......
}
$line = rtrim($tl[$tli++]);
// if (array_search($line, self::$BILL_EXTRACT_START_SL))
//// if (strcmp(strtolower(self::BILL_EXTRACT_START_SL),
//// strtolower($line)) == 0)
// {
// // nalezeny podrobné výpisy
// break;
// }
foreach (self::$BILL_EXTRACT_START_SL as $line_search)
{
if (mb_strtolower($line) == mb_strtolower($line_search))
......
if (strcmp(mb_strtolower($value[self::SLINE]),
mb_strtolower(rtrim($tl[$tli]))) != 0)
{
$test[$index] = -1; // aktivace testování
continue; // 2. řádek nenalezen, pokračuji dál v hledání
}
// posun o řádek
......
// kontrola datového řádku
if (mb_eregi($value[self::REGEX], $line, $r))
{
// aktivace testování
$test[$index] = -1;
// extrakce dat
try
{
......
$services->add_call($call);
break;
case "fixed":
case "fixed_international":
$call = new Fixed_Call_Service();
$call->date_time->setDate(
$data->billing_period_to->format("Y"),
......
$services->add_internet($net);
break;
default:
// warning
// tohle by se nemělo nikdy stát :-)
throw new Exception("Error statement " . $number . " " . $index);
}
}
catch (InvalidArgumentException $e)
......
{
$missing = $number_count - count($data->bill_numbers);
throw new Exception(self::em(
url_lang::lang("texts.Some phones wasn't founded") . ".\n" . $missing . " chybí."
url_lang::lang("texts.Some phones wasn't founded") . ".\n" .
$missing . " " .
url_lang::lang("texts.is missing from") ." " . $number_count . "."
));
}

Také k dispozici: Unified diff