Projekt

Obecné

Profil

« Předchozí | Další » 

Revize 755

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

Zobrazovani celkove castky za telefon u uzivatelovych telefonich faktur.
Moznost vypnuti testu integrity dat pri importu telefoni faktury.

Zobrazit rozdíly:

freenetis/trunk/kohana/application/i18n/cs_CZ/texts.php
'e-mail variables' => 'Proměnné e-mailu',
'e-mail variables have been successfully updated' => 'Proměnné e-mailu byly úspěšně aktualizovány.',
'e-mail variables havent been successfully updated' => 'Proměnné e-mailu nebyly úspěšně aktualizovány.',
'enable integrity test (all numbers in invoice has to be in extended statement)' => 'Povolit test na celistvost (každé číslo ve faktuře musí být v podrobném výpisu)',
'enabled' => 'Zapnuto',
'end membership' => 'Ukončit členství',
'end of month' => 'Konec měsíce',
freenetis/trunk/kohana/application/models/phone_invoice_user.php
);
/**
* Get sum of all users phone invoices separated to cells price_company and price_private
* @param integer $user_id
* @return unknown_type
*/
public function get_total_prices($user_id)
{
$result = $this->db->query("
SELECT id FROM phone_invoice_users WHERE user_id = ?
", array($user_id));
$id_array = array();
foreach ($result as $p)
{
$id_array[] = $p->id;
}
$ids = implode(",", $id_array);
if (empty($ids))
{
return $this->db->query("SELECT '0' AS price_company, '0' AS price_private")->current();
}
return $this->db->query("
SELECT ((
SELECT IFNULL(SUM(price), 0)
FROM phone_calls
WHERE phone_invoice_user_id IN (".$ids.") AND private=0
) + (
SELECT IFNULL(SUM(price), 0)
FROM phone_fixed_calls
WHERE phone_invoice_user_id IN (".$ids.") AND private=0
) + (
SELECT IFNULL(SUM(price), 0)
FROM phone_vpn_calls
WHERE phone_invoice_user_id IN (".$ids.") AND private=0
) + (
SELECT IFNULL(SUM(price), 0)
FROM phone_pays
WHERE phone_invoice_user_id IN (".$ids.") AND private=0
) + (
SELECT IFNULL(SUM(price), 0)
FROM phone_connections
WHERE phone_invoice_user_id IN (".$ids.") AND private=0
) + (
SELECT IFNULL(SUM(price), 0)
FROM phone_roaming_sms_messages
WHERE phone_invoice_user_id IN (".$ids.") AND private=0
) + (
SELECT IFNULL(SUM(price), 0)
FROM phone_sms_messages
WHERE phone_invoice_user_id IN (".$ids.") AND private=0
) + (
SELECT IFNULL(SUM(price), 0)
FROM phone_roaming_sms_messages
WHERE phone_invoice_user_id IN (".$ids.") AND private=0
)) AS price_company,
((
SELECT IFNULL(SUM(price), 0)
FROM phone_calls
WHERE phone_invoice_user_id IN (".$ids.") AND private=1
) + (
SELECT IFNULL(SUM(price), 0)
FROM phone_fixed_calls
WHERE phone_invoice_user_id IN (".$ids.") AND private=1
) + (
SELECT IFNULL(SUM(price), 0)
FROM phone_vpn_calls
WHERE phone_invoice_user_id IN (".$ids.") AND private=1
) + (
SELECT IFNULL(SUM(price), 0)
FROM phone_pays
WHERE phone_invoice_user_id IN (".$ids.") AND private=1
) + (
SELECT IFNULL(SUM(price), 0)
FROM phone_connections
WHERE phone_invoice_user_id IN (".$ids.") AND private=1
) + (
SELECT IFNULL(SUM(price), 0)
FROM phone_roaming_sms_messages
WHERE phone_invoice_user_id IN (".$ids.") AND private=1
) + (
SELECT IFNULL(SUM(price), 0)
FROM phone_sms_messages
WHERE phone_invoice_user_id IN (".$ids.") AND private=1
) + (
SELECT IFNULL(SUM(price), 0)
FROM phone_roaming_sms_messages
WHERE phone_invoice_user_id IN (".$ids.") AND private=1
)) AS price_private
")->current();
}
/**
* Gets all users phone invoices
* @param integer $user_id
* @return unknown_type
freenetis/trunk/kohana/application/controllers/phone_invoices.php
$form = new Forge(url::base().url::current(true), '', 'POST', array('id' => 'phone_invoices_form'));
$form->textarea('parse')->label(url_lang::lang('texts.Text to parse') . ':')->rules('required');
$form->checkbox('test_number_count_enabled')->checked(TRUE)->value('1')
->label(url_lang::lang('texts.Enable integrity test (all numbers in invoice has to be in extended statement)'));
$form->submit(url_lang::lang('texts.Parse'))->id('phone_invoices_sumit');
if ($form->validate())
{
try
{
$data = Parser_Vodafone_Invoice::parse($form->parse->value);
$integrity_test = ($form->test_number_count_enabled->value == '1');
$data = Parser_Vodafone_Invoice::parse($form->parse->value, $integrity_test);
$phone_invoice = new Phone_invoice_Model();
$phone_invoice->date_of_issuance = $data->date_of_issuance->format('Y-m-d');
......
$view->title = url_lang::lang('texts.Phone invoices of user');
$view->content = new View('phone_invoices/show_by_user');
$view->content->grid = $grid;
$view->content->total_prices = $phone_inv_user_model->get_total_prices($user_id);
$view->render(TRUE);
}
freenetis/trunk/kohana/application/libraries/Parser_Vodafone_Invoice.php
* - Testuje zda-li odpovídají ceny položek služeb s celkovou cenou za danou službu
* daného čísla.
*
* @param string $text Text k parsování(vstup)
* @param string $text Text k parsování(vstup)
* @param boolean $integrity_test_enabled Povolení testování integrity čísel
* v podrobných výpisech
* @return Bill_Data Data faktury
* @throws Exception Při chybě při parsování
* @throws InvalidArgumentException Při prázdném vstupu
*/
public static function parse($text)
public static function parse($text, $integrity_test_enabled = TRUE)
{
if (empty($text))
{
......
}
// kontrola načtení všech čísel
if ($number_count != count($data->bill_numbers))
if ($integrity_test_enabled === TRUE &&
$number_count != count($data->bill_numbers))
{
$missing = $number_count - count($data->bill_numbers);
throw new Exception(self::em(
freenetis/trunk/kohana/application/views/phone_invoices/show_by_user.php
<h2><?php echo url_lang::lang('texts.Phone invoices of user') ?></h2><br />
<?php echo $grid ?>
<br />
<h3><?php echo url_lang::lang('texts.Total price') ?></h3>
<table class="extended" cellspacing="0">
<tr>
<th><?php echo url_lang::lang('texts.Company') ?>:</th>
<td><?php echo number_format($total_prices->price_company, 2, ',', ' ') ?></td>
</tr>
<tr>
<th><?php echo url_lang::lang('texts.Private') ?>:</th>
<td><b><?php echo number_format($total_prices->price_private, 2, ',', ' ') ?></b></td>
</tr>
</table>

Také k dispozici: Unified diff