Projekt

Obecné

Profil

« Předchozí | Další » 

Revize 1251

Přidáno uživatelem Ondřej Fibich před asi 13 roky(ů)

Novinky:

- strhavani kreditu za soukrome sluzby v telefonnich fakturach

Upravy:

- optimalizace a zabezpeceni importu telefonnich faktur transakcemi
- uprava rozhrani tel. faktur
- v MY_Controlleru zmeneny nektere metody na staticke

Zobrazit rozdíly:

freenetis/branches/testing/application/i18n/cs_CZ/texts.php
'disable this subnet' => 'Zakázat tuto podsíť',
'disabled' => 'Vypnuto',
'disagree' => 'Nesouhlas',
'discount private services from phone keepers credit account' => 'Strhnout soukromé služby z kreditního účtu držitelů telefonů',
'discounted from credit accounts' => 'Strženo z kreditních účtů',
'display member' => 'Zobraz člena',
'display user' => 'Zobraz uživatele',
'dns configuration' => 'Konfigurace DNS',
......
'error - cannot assign transfer' => 'Chyba - nelze přiřadit převod.',
'error - cannot complete registration' => 'Chyba - Nelze dokončit registraci',
'error - cannot delete bank statement' => 'Chyba - nelze smazat bankovní výpis.',
'error - cannot discount private services' => 'Chyba - nemohu strhnout soukromé služby.',
'error - cannot load intelligent selection' => 'Chyba - nelze načíst inteligentní výběr',
'error - cannot update message' => 'Chyba - nelze upravit zprávu.',
'error - cannot remove admin of cloud' => 'Chyba - nelze odebrat admina oblasti',
......
'invoice has been successfully added' => 'Faktura byla úspěšně přidána.',
'invoice has been successfully deleted' => 'Faktura byla úspěšně smazána.',
'invoice has been successfully updated' => 'Faktura byla úspěšně aktualizována.',
'invoice has to be locked for this operation' => 'Faktura musí být pro tuto operaci uzamčena.',
'invoice item has been successfully added' => 'Položka faktury byla úspěšně přidána.',
'invoice item has been successfully deleted' => 'Položka faktury byla úspěšně smazána.',
'invoice item has been successfully updated' => 'Položka faktury byla úspěšně aktualizována.',
......
'number of the recipient' => 'Číslo příjemce',
'phone number of the sim card' => 'Telefonní číslo SIM karty',
'phone invoice has been' => 'Faktura byla',
'phone invoice' => 'Telefonní faktura',
'number of the sender' => 'Číslo odesilatele',
'numbers' => 'Čísla',
'number interval' => 'Rozsah čísel',
......
'price per kilometre' => 'Cena za kilometr',
'price per one hour, kilometre' => 'Cena za jednu hodinu, kilometr',
'price vat' => 'Cena s DPH',
'prices of private services has been discounted from phone keepers credit accounts' => 'Ceny soukromých služeb byly strhnuty z creditních účtů držitelů telefonů.',
'primary dns' => 'Primární DNS.',
'primary user of member cannot be deleted' => 'Primárního uživatele člena nelze smazat.',
'priority' => 'Priorita',
......
'private phone contact has been deleted' => 'Soukromí telefonní kontakt byl smazán.',
'contacts can be added in telephone invoices' => 'Kontakty mohou být přidány v telefonních fakturách',
'private phone contacts of user, which are used in telephone invoices' => 'Soukromé uživatelské telefonní kontakty, které jsou užívány v telefonních fakturách',
'private services already discounted' => 'Soukromé služby již byli strhnuty.',
'private user contacts' => 'Soukromé uživatelské kontakty',
'profile of association' => 'Profil organizace',
'project account' => 'Účet projektu',
freenetis/branches/testing/application/vendors/unit_tester/unit_testing_config.xml
</input>
</values>
</method>
<method name="pay" autogenerate="on">
<attributes>
<attribute name="phone_invoice_id" default_value="0" />
</attributes>
<values>
<input></input>
<input>
<param value="0" />
</input>
</values>
</method>
<method name="show_by_user" autogenerate="off">
<attributes>
<attribute name="user_id" default_value="0"/>
......
</input>
</values>
</method>
<method name="valid_price_per_km" autogenerate="off">
<attributes>
<attribute name="input" default_value=""/>
</attributes>
<values>
</values>
</method>
</controller>
<model name="account">
<method name="get_accounts_count" autogenerate="off">
......
</input>
</values>
</method>
<method name="get_ip_addresses_of_members_in_protective_period" autogenerate="on">
<attributes></attributes>
<values>
<input></input>
</values>
</method>
<method name="set_whitelist" autogenerate="on">
<attributes>
<attribute name="whitelist" default_value="" />
<attribute name="ip_address_id" default_value="" />
</attributes>
<values>
<input>
<param value="" />
</input>
<input>
<param value="" />
<param value="" />
</input>
</values>
</method>
</model>
<model name="ip_addresses_traffic">
<method name="count_all_ip_addresses_traffics" autogenerate="on">
......
<input></input>
</values>
</method>
<method name="get_rating" autogenerate="on">
<attributes></attributes>
<values>
<input></input>
</values>
</method>
<method name="get_count_of_unvoted_work_reports_of_voter" autogenerate="on">
<attributes>
<attribute name="user_id" default_value="" />
......
</method>
</model>
<model name="phone_invoice">
<method name="is_payed" autogenerate="on">
<attributes></attributes>
<values>
<input></input>
</values>
</method>
<method name="is_unique" autogenerate="on">
<attributes></attributes>
<values>
......
<values>
</values>
</method>
<method name="transfer_link" autogenerate="off">
<attributes>
<attribute name="item" default_value=""/>
<attribute name="name" default_value=""/>
</attributes>
<values>
</values>
</method>
<method name="work_approved" autogenerate="off">
<attributes>
<attribute name="item" default_value=""/>
......
<values>
</values>
</method>
<method name="work_report_payment_type" autogenerate="on">
<method name="work_report_rating" autogenerate="off">
<attributes>
<attribute name="item" default_value="" />
<attribute name="name" default_value="" />
<attribute name="item" default_value=""/>
<attribute name="name" default_value=""/>
</attributes>
<values>
<input>
<param value="" />
<param value="" />
</input>
</values>
</method>
<method name="limited_text" autogenerate="off">
......
</attributes>
<values>
</values>
</method>
</helper>
</method></helper>
<helper name="condition">
<method name="is_own" autogenerate="off">
<attributes>
freenetis/branches/testing/application/helpers/callback.php
}
/**
* Callback for transfer
*
* @author Ondrej Fibich
* @param object $item
* @param string $name
*/
public static function transfer_link($item, $name)
{
if (isset($item->transfer_id, $item->amount) && $item->transfer_id)
{
echo html::anchor(
'transfers/show/' . $item->transfer_id,
number_format($item->amount, 2, ',', ' ') .
' ' . __(Settings::get('currency'))
);
}
}
/**
* Callback for true false values.
*
* @author Ondrej Fibich
......
{
echo ($item->$name <= .0) ? '<span style="color:red">' : '';
echo str_replace(' ', '&nbsp;', number_format($item->$name, 2, ',', ' '));
echo ' ' . __(Settings::get('currency'));
echo ($item->$name <= .0) ? '</span>' : '';
}
freenetis/branches/testing/application/models/phone_invoice_user.php
* @property User_Model $user
* @property integer $phone_invoice_id
* @property Phone_invoice_Model $phone_invoice
* @property integer $transfer_id
* @property Transfer_Model
* @property string $phone_number
* @property boolean $locked
* @property ORM $phone_connections
......
*/
class Phone_invoice_user_Model extends ORM
{
protected $belongs_to = array('user', 'phone_invoice');
protected $belongs_to = array('user', 'phone_invoice', 'transfer');
protected $has_many = array
(
......
return $this->db->query("
SELECT p.id, pi.locked, p.locked AS filled,
pi.billing_period_from,
pi.billing_period_to, p.user_id,
pi.billing_period_to, p.user_id, p.transfer_id, t.amount,
p.phone_number AS number,
((
SELECT IFNULL(SUM(price), 0)
......
)) AS price_private
FROM phone_invoice_users p
LEFT JOIN transfers t ON p.transfer_id = t.id
LEFT JOIN phone_invoices pi ON p.phone_invoice_id = pi.id
WHERE p.user_id = ?
", $user_id);
......
{
// madness query to calculate price for each user invoicee
return $this->db->query("
SELECT p.tax_rate, `phone_invoice_users`.`id`, `phone_invoice_users`.`locked` AS filled,
`phone_invoice_users`.`user_id`,
`phone_invoice_users`.`phone_number` ,
CONCAT( `users`.`surname`, ' ', `users`.`name` ) AS `name`,
SELECT p.tax_rate, piu.id, piu.locked AS filled,
piu.user_id, piu.phone_number , piu.transfer_id, t.amount,
CONCAT( users.surname, ' ', users.name ) AS name,
(
(SELECT IFNULL(SUM( price ), 0)
FROM phone_calls
WHERE phone_invoice_user_id =phone_invoice_users.id AND private = 0)
+
(SELECT IFNULL(SUM( price ), 0)
FROM phone_fixed_calls
WHERE phone_invoice_user_id =phone_invoice_users.id AND private = 0)
+
(SELECT IFNULL(SUM( price ), 0)
FROM phone_vpn_calls
WHERE phone_invoice_user_id =phone_invoice_users.id AND private = 0)
+
(SELECT IFNULL(SUM( price ), 0)
FROM phone_sms_messages
WHERE phone_invoice_user_id =phone_invoice_users.id AND private = 0)
+
(SELECT IFNULL(SUM( price ), 0)
FROM phone_pays
WHERE phone_invoice_user_id =phone_invoice_users.id AND private = 0)
+
(SELECT IFNULL(SUM( price ), 0)
FROM phone_roaming_sms_messages
WHERE phone_invoice_user_id =phone_invoice_users.id AND private = 0)
+
(SELECT IFNULL(SUM( price ), 0)
FROM phone_connections
WHERE phone_invoice_user_id =phone_invoice_users.id AND private = 0)
) * (1 + p.tax_rate / 100) AS price_company,
(
(SELECT IFNULL(SUM( price ), 0)
FROM phone_calls
WHERE phone_invoice_user_id =phone_invoice_users.id AND private = 1)
+
(SELECT IFNULL(SUM( price ), 0)
FROM phone_fixed_calls
WHERE phone_invoice_user_id =phone_invoice_users.id AND private = 1)
+
(SELECT IFNULL(SUM( price ), 0)
FROM phone_vpn_calls
WHERE phone_invoice_user_id =phone_invoice_users.id AND private = 1)
+
(SELECT IFNULL(SUM( price ), 0)
FROM phone_sms_messages
WHERE phone_invoice_user_id =phone_invoice_users.id AND private = 1)
+
(SELECT IFNULL(SUM( price ), 0)
FROM phone_pays
WHERE phone_invoice_user_id =phone_invoice_users.id AND private = 1)
+
(SELECT IFNULL(SUM( price ), 0)
FROM phone_roaming_sms_messages
WHERE phone_invoice_user_id =phone_invoice_users.id AND private = 1)
+
(SELECT IFNULL(SUM( price ), 0)
FROM phone_connections
WHERE phone_invoice_user_id =phone_invoice_users.id AND private = 1)
(SELECT IFNULL(SUM( price ), 0)
FROM phone_calls
WHERE phone_invoice_user_id =piu.id AND private = 0)
+
(SELECT IFNULL(SUM( price ), 0)
FROM phone_fixed_calls
WHERE phone_invoice_user_id =piu.id AND private = 0)
+
(SELECT IFNULL(SUM( price ), 0)
FROM phone_vpn_calls
WHERE phone_invoice_user_id =piu.id AND private = 0)
+
(SELECT IFNULL(SUM( price ), 0)
FROM phone_sms_messages
WHERE phone_invoice_user_id =piu.id AND private = 0)
+
(SELECT IFNULL(SUM( price ), 0)
FROM phone_pays
WHERE phone_invoice_user_id =piu.id AND private = 0)
+
(SELECT IFNULL(SUM( price ), 0)
FROM phone_roaming_sms_messages
WHERE phone_invoice_user_id =piu.id AND private = 0)
+
(SELECT IFNULL(SUM( price ), 0)
FROM phone_connections
WHERE phone_invoice_user_id =piu.id AND private = 0)
) * (1 + p.tax_rate / 100) AS price_company,
(
(SELECT IFNULL(SUM( price ), 0)
FROM phone_calls
WHERE phone_invoice_user_id =piu.id AND private = 1)
+
(SELECT IFNULL(SUM( price ), 0)
FROM phone_fixed_calls
WHERE phone_invoice_user_id =piu.id AND private = 1)
+
(SELECT IFNULL(SUM( price ), 0)
FROM phone_vpn_calls
WHERE phone_invoice_user_id =piu.id AND private = 1)
+
(SELECT IFNULL(SUM( price ), 0)
FROM phone_sms_messages
WHERE phone_invoice_user_id =piu.id AND private = 1)
+
(SELECT IFNULL(SUM( price ), 0)
FROM phone_pays
WHERE phone_invoice_user_id =piu.id AND private = 1)
+
(SELECT IFNULL(SUM( price ), 0)
FROM phone_roaming_sms_messages
WHERE phone_invoice_user_id =piu.id AND private = 1)
+
(SELECT IFNULL(SUM( price ), 0)
FROM phone_connections
WHERE phone_invoice_user_id =piu.id AND private = 1)
) * (1 + p.tax_rate / 100) AS price_private
FROM `phone_invoice_users`
LEFT JOIN `phone_invoices` p ON `p`.`id` = `phone_invoice_users`.`phone_invoice_id`
LEFT JOIN `users` ON `phone_invoice_users`.`user_id` = `users`.`id`
WHERE `phone_invoice_users`.`phone_invoice_id` = ?;
FROM phone_invoice_users piu
LEFT JOIN phone_invoices p ON p.id = piu.phone_invoice_id
LEFT JOIN users ON piu.user_id = users.id
LEFT JOIN transfers t ON piu.transfer_id = t.id
WHERE piu.phone_invoice_id = ?;
", array($invoice_id));
}
freenetis/branches/testing/application/models/user.php
*
* @return array[string]
*/
public function select_list_grouped()
public static function select_list_grouped()
{
$list = array();
$assoc_user = $this->where('id', self::ASSOCIATION)->find();
$assoc_user = ORM::factory('user', self::ASSOCIATION);
$list[__('Association')][$assoc_user->id] = $assoc_user->member->name;
$users = $this->where('id !=', self::ASSOCIATION)
->orderby('surname')
->find_all();
$concat = "CONCAT(
COALESCE(surname, ''), ' ',
COALESCE(name, ''), ' - ',
COALESCE(login, '')
)";
foreach ($users as $user)
$list[__('users')][$user->id] = $user->surname.' '.$user->name;
$list[__('Users')] = $assoc_user->where('id !=', self::ASSOCIATION)
->select_list('id', $concat);
return $list;
}
freenetis/branches/testing/application/models/bank_transfer.php
*/
public function get_transaction_code_duplicities($transaction_codes)
{
if (!count($transaction_codes))
if (!is_array($transaction_codes) || !count($transaction_codes))
{
return array();
}
freenetis/branches/testing/application/models/phone_invoice.php
* @property double $total_price
* @property double $tax
* @property double $tax_rate
* @property boolean $locked
* @property ORM $phone_invoice_users
*/
class Phone_invoice_Model extends ORM
{
protected $has_many = array('phone_invoice_users');
/**
* Test if users has payd for invoice
*
* @return bool
*/
public function is_payed()
{
static $cache = array();
if (!$this->id)
{
return FALSE;
}
if (!isset($cache[$this->id]))
{
$cache[$this->id] = $this->db->query("
SELECT COUNT(*) AS count
FROM phone_invoice_users
WHERE phone_invoice_id = ? AND transfer_id IS NOT NULL
", $this->id)->current()->count > 0;
}
return $cache[$this->id];
}
/**
* Test if invoice is not in database already
*
freenetis/branches/testing/application/controllers/phone_invoices.php
{
try
{
$phone_invoice = new Phone_invoice_Model();
$phone_invoice->transaction_start();
$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->set_logger(FALSE);
$phone_invoice->date_of_issuance = $data->date_of_issuance->format('Y-m-d');
$phone_invoice->billing_period_from = $data->billing_period_from->format('Y-m-d');
......
self::_set_invoice_data($data, $phone_invoice);
// redirect to edit
$phone_invoice->transaction_commit();
url::redirect(url_lang::base() . '/phone_invoices/show/' . $phone_invoice->id . '/');
}
catch (Exception $e)
{
$phone_invoice->transaction_rollback();
$form->parse->add_error('requied', nl2br($e->getMessage()));
}
}
......
* @param integer $phone_invoice_id
* @param integer $phone_invoice_user_id
*/
public function show($phone_invoice_id = -1, $phone_invoice_user_id = -1)
public function show($phone_invoice_id = NULL, $phone_invoice_user_id = NULL)
{
if (!$this->acl_check_view('Phone_invoices_Controller', 'details'))
{
......
}
$form = NULL;
if ($this->acl_check_edit('Phone_invoices_Controller', 'details'))
$phone_inv_user_model = new Phone_invoice_user_Model();
if ($this->acl_check_edit('Phone_invoices_Controller', 'details') &&
intval($phone_invoice_user_id))
{
if (intval($phone_invoice_user_id) >= 0)
$phone_inv_user_model->find($phone_invoice_user_id);
if (!$phone_inv_user_model->id)
{
$phone_inv_user_model = new Phone_invoice_user_Model($phone_invoice_user_id);
$user = new User_Model();
$users = $user->get_all_user_names();
$users_data = array();
Controller::error(RECORD);
}
if (!$phone_inv_user_model->id)
{
Controller::error(RECORD);
}
if ($phone_inv_user_model->phone_invoice->locked)
{
Controller::error(ACCESS);
}
foreach ($users as $u)
{
$users_data[$u->id] = $u->username;
}
$form = new Forge(
url::base(TRUE) . url::current(true), '',
'POST', array('id' => 'phone_invoices_form')
);
$form = new Forge(
url::base(TRUE) . url::current(true), '',
'POST', array('id' => 'phone_invoices_form')
);
$form->dropdown('user_id')
->label(__('Phone') . ' ' . $phone_inv_user_model->phone_number)
->options($users_data)
->selected($phone_inv_user_model->user_id)
->rules('required');
$form->dropdown('user_id')
->label(__('Phone') . ' ' . $phone_inv_user_model->phone_number)
->options(ORM::factory('user')->select_list_grouped())
->selected($phone_inv_user_model->user_id)
->rules('required');
if ($form->validate())
{
$phone_inv_user_model->user_id = $form->user_id->value;
$phone_inv_user_model->save();
if ($form->validate())
{
$phone_inv_user_model->user_id = $form->user_id->value;
$phone_inv_user_model->save();
status::success('User has been assigned');
url::redirect(url_lang::base() . 'phone_invoices/show/' . $phone_invoice_id);
}
status::success('User has been assigned');
url::redirect(url_lang::base() . 'phone_invoices/show/' . $phone_invoice_id);
}
$form->submit(__('Save'));
}
$form->submit(__('Save'));
}
$grid = new Grid(url_lang::base() . 'phone_invoices/show', NULL, array
......
'use_selector' => false
));
$phone_inv_user_model = new Phone_invoice_user_Model();
$is_payed = $phone_invoice->is_payed();
$query = $phone_inv_user_model->get_all_invoice_users($phone_invoice->id);
$grid->callback_field('state')
......
->label(__('Company') . '&nbsp;' . help::hint('price_tax'))
->callback('callback::phone_price_field');
if ($is_payed)
{
$grid->callback_field('transfer_id')
->label('Transfer')
->callback('callback::transfer_link');
}
$actions = $grid->grouped_action_field();
$actions->add_action()
......
$view->title = __('Detail of invoice');
$view->breadcrumbs = $breadcrumbs->html();
$view->content = new View('phone_invoices/show');
$view->content->is_payed = $is_payed;
$view->content->phone_invoice = $phone_invoice;
$view->content->total_price = $phone_invoice->total_price + $phone_invoice->tax;
$view->content->grid = $grid;
......
{
Controller::error(RECORD);
}
if ($phone_invoice->is_payed())
{
Controller::error(ACCESS);
}
$phone_invoice->locked = !$phone_invoice->locked;
$phone_invoice->save();
......
}
/**
* Disccount private services price from users credit
*
* @param integer $phone_invoice_id
*/
public function pay($phone_invoice_id = 0)
{
if (!$this->acl_check_new('Phone_invoices_Controller', 'pay'))
{
Controller::error(ACCESS);
}
if (intval($phone_invoice_id) <= 0)
{
Controller::warning(PARAMETER);
}
$phone_invoice = new Phone_invoice_Model($phone_invoice_id);
$phone_invoice_user = new Phone_invoice_user_Model();
if (!$phone_invoice->id)
{
Controller::error(RECORD);
}
// is not locked?
if (!$phone_invoice->locked)
{
status::warning('Invoice has to be locked for this operation.');
url::redirect(url_lang::base() . 'phone_invoices/show/' . $phone_invoice_id);
}
// already payed?
if ($phone_invoice->is_payed())
{
status::warning('Private services already discounted.');
url::redirect(url_lang::base() . 'phone_invoices/show/' . $phone_invoice_id);
}
// users of invoice
$users = $phone_invoice_user->get_all_invoice_users($phone_invoice->id);
// accounts
$account_model = new Account_Model();
$operating_id = $account_model->where(array(
'account_attribute_id' => Account_attribute_Model::$operating
))->find()->id;
try
{
$phone_invoice->transaction_start();
// for each number in invoice
foreach ($users as $user)
{
// load
$phone_invoice_user->find($user->id);
// unassigned or empty or asociation?
if (!$user->user_id ||
!$phone_invoice_user->id ||
$user->price_private == 0 ||
$phone_invoice_user->user->member_id == Member_Model::ASSOCIATION)
{
continue;
}
// account
$credit_id = $account_model->where(array
(
'member_id' => $phone_invoice_user->user->member_id,
'account_attribute_id' => Account_attribute_Model::$credit
))->find()->id;
echo $phone_invoice_user->user->get_full_name() . ' ' . $credit_id . "<br><br>";
// add transfer
$transfer_id = Transfer_Model::insert_transfer(
$credit_id, $operating_id, null, null,
$this->session->get('user_id'),
null, date('Y-m-d'), date('Y-m-d H:i:s'),
__('Phone invoice') . ' ' . $phone_invoice->id,
$user->price_private
);
// add to user
$phone_invoice_user->transfer_id = $transfer_id;
$phone_invoice_user->save_throwable();
}
// commit
$phone_invoice->transaction_commit();
status::success(
'Prices of private services has been discounted ' .
'from phone keepers credit accounts.'
);
}
catch (Kohana_Database_Exception $e)
{
$phone_invoice->transaction_rollback();
status::error('Error - cannot discount private services');
die($e->__toString());
}
url::redirect(url_lang::base() . 'phone_invoices/show/' . $phone_invoice_id);
}
/**
* Displays users phone invoices
* @param integer $user_id
*/
......
$grid->field('billing_period_to')
->label(__('Billing period to'));
$grid->callback_field('price_private')
->label(__('Private'))
->callback('callback::phone_price_field');
$grid->callback_field('price_company')
->label(__('Company'))
->callback('callback::phone_price_field');
$grid->callback_field('price_private')
->label(__('Private'))
->callback('callback::phone_price_field');
$grid->callback_field('transfer_id')
->label('Transfer')
->callback('callback::transfer_link');
$action = $grid->grouped_action_field();
......
->label(__('Date'));
$heading = null;
$edit_enabled = ((
$this->acl_check_edit('Phone_invoices_Controller', 'dumps') &&
!$phone_inv_model->is_payed()
) || (
$phone_inv_model->locked == 0 &&
$phone_inv_user_model->locked == 0 &&
$this->acl_check_edit(
'Phone_invoices_Controller', 'dumps', $user->member_id
)
));
switch ($detail_of)
{
......
$grid->callback_field('number')->label(__('Called number'))
->callback('callback::phone_number_field');
if ($this->acl_check_edit('Phone_invoices_Controller', 'dumps') ||
($phone_inv_model->locked == 0 &&
$phone_inv_user_model->locked == 0 &&
$this->acl_check_edit('Phone_invoices_Controller', 'dumps', $user->member_id)))
if ($edit_enabled)
{
if ($_POST && count($_POST))
{
......
->label(__('Called number'))
->callback('callback::phone_number_field');
if ($this->acl_check_edit('Phone_invoices_Controller', 'dumps') ||
($phone_inv_model->locked == 0 &&
$phone_inv_user_model->locked == 0 &&
$this->acl_check_edit('Phone_invoices_Controller', 'dumps', $user->member_id)))
if ($edit_enabled)
{
if ($_POST && count($_POST))
{
......
->label(__('Called number'))
->callback('callback::phone_number_field');
if ($this->acl_check_edit('Phone_invoices_Controller', 'dumps') ||
($phone_inv_model->locked == 0 &&
$phone_inv_user_model->locked == 0 &&
$this->acl_check_edit('Phone_invoices_Controller', 'dumps', $user->member_id)))
if ($edit_enabled)
{
if ($_POST && count($_POST))
{
......
->label(__('Number'))
->callback('callback::phone_number_field');
if ($this->acl_check_edit('Phone_invoices_Controller', 'dumps') ||
($phone_inv_model->locked == 0 &&
$phone_inv_user_model->locked == 0 &&
$this->acl_check_edit('Phone_invoices_Controller', 'dumps', $user->member_id)))
if ($edit_enabled)
{
if ($_POST && count($_POST))
{
......
$grid->field('roaming_zone')
->label(__('Roaming zone'));
if ($this->acl_check_edit('Phone_invoices_Controller', 'dumps') ||
($phone_inv_model->locked == 0 &&
$phone_inv_user_model->locked == 0 &&
$this->acl_check_edit('Phone_invoices_Controller', 'dumps', $user->member_id)))
if ($edit_enabled)
{
if ($_POST && count($_POST))
{
......
$grid->field('description')
->label(__('Description'));
if ($this->acl_check_edit('Phone_invoices_Controller', 'dumps') ||
($phone_inv_model->locked == 0 &&
$phone_inv_user_model->locked == 0 &&
$this->acl_check_edit('Phone_invoices_Controller', 'dumps', $user->member_id)))
if ($edit_enabled)
{
if ($_POST && count($_POST))
{
......
->label(__('Price'))
->callback('callback::phone_price_field');
if ($this->acl_check_edit('Phone_invoices_Controller', 'dumps') ||
($phone_inv_model->locked == 0 &&
$this->acl_check_edit('Phone_invoices_Controller', 'dumps', $user->member_id)))
if ($edit_enabled)
{
if ($_POST && count($_POST))
{
......
$prices->phone_roaming_sms_messages_company +
$prices->phone_pays_company;
$phone_invoice = new Phone_invoice_Model($phone_inv_user_model->phone_invoice_id);
$user = new User_Model($phone_inv_user_model->user_id);
$phone_invoice = $phone_inv_user_model->phone_invoice;
$user = $phone_inv_user_model->user;
$price = round($price_private + ($price_private * $phone_invoice->tax_rate / 100), 2);
// breadcrumbs navigation
......
$view->title = __('Detail of invoice');
$view->breadcrumbs = $breadcrumbs->html();
$view->content = new View('phone_invoices/show_details');
$view->content->edit_enabled = $edit_enabled;
$view->content->phone_invoice = $phone_inv_model;
$view->content->phone_invoice_user = $phone_inv_user_model;
$view->content->phone_invoice_user_lock_enabled =
......
*/
private function _set_invoice_data(Bill_Data &$data, Phone_invoice_Model &$phone_invoice)
{
$phone_invoice->save();
$phone_invoice->save_throwable();
/* @var $services Services */
foreach ($data->bill_numbers as $services)
{
$user_id = self::user_number_cache($services->number);
if (!intval($user_id))
{
$user_id = NULL;
}
$phone_inv_user = new Phone_invoice_user_Model();
$phone_inv_user->set_logger(FALSE);
$phone_inv_user->user_id = strval(self::user_number_cache($services->number));
$phone_inv_user->user_id = $user_id;
$phone_inv_user->phone_invoice_id = $phone_invoice->id;
$phone_inv_user->phone_number = $services->number;
$phone_inv_user->save();
$phone_inv_user->save_throwable();
/* @var $item Call_Service */
foreach ($services->calls as $item)
......
$model->private = ($ppcontact_id <= 0) ? '0' : '1';
$model->save();
$model->save_throwable();
}
/* @var $item Fixed_Call_Service */
......
$model->private = (($ppcontact_id <= 0) &&
(self::user_number_cache($model->number) != 0)) ? '0' : '1';
$model->save();
$model->save_throwable();
}
/* @var $item Vpn_Call_Service */
......
$model->private = ($ppcontact_id <= 0) ? '0' : '1';
$model->save();
$model->save_throwable();
}
/* @var $item Sms_Service */
......
$model->private = ($ppcontact_id <= 0) ? '0' : '1';
$model->save();
$model->save_throwable();
}
/* @var $item RoamingSms_Service */
......
$model->price = $item->price;
$model->roaming_zone = $item->roaming_zone;
$model->private = '1';
$model->save();
$model->save_throwable();
}
/* @var $item Internet_Service */
......
$model->apn = $item->apn;
$model->transfered = $item->transfered;
$model->private = '1';
$model->save();
$model->save_throwable();
}
/* @var $item Pay_Service */
......
$model->description = $item->description;
$model->private = '1';
$model->save();
$model->save_throwable();
}
}
}
freenetis/branches/testing/application/upgrade_sql/upgrade_sql.php
/**
* Column for payment type of work report
* Column for transfer key in phone invoice users
*
* @author Ondřej Fibich
*/
$upgrade_sql[get_SVN_rev()] = array
(
"ALTER TABLE `job_reports` ADD `payment_type` TINYINT NOT NULL DEFAULT '0'
COMMENT 'Specified payment, 0 is credit payment, 1 is cash payment, see model for more details'"
"ALTER TABLE `phone_invoice_users` ADD `transfer_id` INT( 11 ) NULL AFTER `phone_invoice_id`;",
"ALTER TABLE `phone_invoice_users` ADD INDEX ( `transfer_id` );",
"ALTER TABLE `phone_invoice_users` ADD FOREIGN KEY ( `transfer_id` ) REFERENCES `transfers` ( `id` ) ON SET NULL;",
);
freenetis/branches/testing/application/upgrade_sql/upgrade_sql_1247.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/
*
*/
/**
* Column for payment type of work report
*
* @author Ondřej Fibich
*/
$upgrade_sql[1247] = array
(
"ALTER TABLE `job_reports` ADD `payment_type` TINYINT NOT NULL DEFAULT '0'
COMMENT 'Specified payment, 0 is credit payment, 1 is cash payment, see model for more details'"
);
freenetis/branches/testing/application/libraries/MY_Controller.php
/**
* Function shows error of given message number.
*
* @param $message
* @param $content
* @param integer $message_type
* @param string $content
*/
public function error($message_type, $content = NULL)
public static function error($message_type, $content = NULL)
{
switch ($message_type)
{
case ACCESS:
$message = url_lang::lang('states.Access denied');
$this->showbox($message, self::ICON_ERROR, $content);
break;
case EMAIL:
$message = url_lang::lang('states.Failed to send e-mail') . '<br />' .
url_lang::lang('states.Please check settings.');
$this->showbox($message, self::ICON_ERROR, $content);
$message = url_lang::lang('states.Failed to send e-mail') .
'<br />' . url_lang::lang('states.Please check settings.');
break;
case DATABASE:
$message = url_lang::lang('states.Failed to connect to database') .
'<br />' . url_lang::lang('states.Please check settings.');
$this->showbox($message, self::ICON_ERROR, $content);
break;
case RECORD:
$message = url_lang::lang('states.This record does not exist');
$this->showbox($message, self::ICON_ERROR, $content);
break;
case PAGE:
$message = url_lang::lang('states.Page not found');
$this->showbox($message, self::ICON_ERROR, $content);
break;
case UPGRADE:
$message = url_lang::lang('states.Database upgrade failed');
$this->showbox($message, self::ICON_ERROR, $content);
break;
case WRITABLE:
$message = url_lang::lang('states.Directory or file is not writable.');
$this->showbox($message, self::ICON_ERROR, $content);
break;
case READONLY:
$message = url_lang::lang('states.Item is read only.');
$this->showbox($message, self::ICON_ERROR, $content);
break;
default:
$message = url_lang::lang('states.Unknown error message');
$this->showbox($message, self::ICON_WARNING, $content);
break;
}
self::showbox($message, self::ICON_ERROR, $content);
}
/**
* Function shows warning of given message number.
*
* @param integer $message
* @param integer $message_type
* @param string $content
*/
public function warning($message, $content = NULL)
public static function warning($message_type, $content = NULL)
{
switch ($message)
switch ($message_type)
{
case PARAMETER:
$message = url_lang::lang('states.Parameter required');
$this->showbox($message, self::ICON_WARNING, $content);
break;
default:
$message = url_lang::lang('states.Unknown warning message');
$this->showbox($message, self::ICON_WARNING, $content);
break;
}
self::showbox($message, self::ICON_WARNING, $content);
}
/**
......
* @param integer $type
* @param string $content
*/
private function showbox($message, $type, $content = NULL)
private static function showbox($message, $type, $content = NULL)
{
$view = new View('main');
$view->content = new View('statesbox');
freenetis/branches/testing/application/views/phone_invoices/show.php
</tr>
<tr>
<th><?php echo __('Price out of tax') ?></th>
<td><?php echo number_format($phone_invoice->total_price, 2, ',', ' ') ?></td>
<td><?php echo number_format($phone_invoice->total_price, 2, ',', ' ') ?> <?php __(Settings::get('currency')) ?></td>
</tr>
<tr>
<th><?php echo __('Tax') ?></th>
<td><?php echo number_format($phone_invoice->tax, 2, ',', ' ') ?> / <?php echo $phone_invoice->tax_rate ?>%</td>
<td><?php echo number_format($phone_invoice->tax, 2, ',', ' ') ?> <?php __(Settings::get('currency')) ?> / <?php echo $phone_invoice->tax_rate ?>%</td>
</tr>
<tr>
<th><?php echo __('Total price') ?></th>
<td><b><?php echo number_format($total_price, 2, ',', ' ') ?></b></td>
<td><b><?php echo number_format($total_price, 2, ',', ' ') ?> <?php __(Settings::get('currency')) ?></b></td>
</tr>
<?php if (!$is_payed): ?>
<?php if (!$phone_invoice->locked && $this->acl_check_new('Phone_invoices_Controller', 'mail_warning')): ?>
<tr>
<th><?php echo html::image(array('src' => 'media/images/inbox.png')); ?></th>
<th><?php echo html::anchor(url_lang::base() . 'phone_invoices/post_mail_warning/' . $phone_invoice->id, __('Send mail warning to users related with invoice')) ?></th>
<th><?php echo html::anchor('phone_invoices/post_mail_warning/' . $phone_invoice->id, __('Send mail warning to users related with invoice')) ?></th>
</tr>
<?php endif; ?>
<tr>
<th><?php echo html::image(array('src' => 'media/images/locked.png')); ?></th>
<th><?php echo html::anchor(url_lang::base() . 'phone_invoices/lock_set/' . $phone_invoice->id, $phone_invoice->locked ? __('Unlock invoice') : __('Lock invoice')) ?></th>
<th><?php echo html::anchor('phone_invoices/lock_set/' . $phone_invoice->id, $phone_invoice->locked ? __('Unlock invoice') : __('Lock invoice')) ?></th>
</tr>
<?php if ($phone_invoice->locked): ?>
<tr>
<th><?php echo html::image(array('src' => 'media/images/icons/grid_action/money.png')); ?></th>
<th><?php echo html::anchor('phone_invoices/pay/' . $phone_invoice->id, __('Discount private services from phone keepers credit account')) ?></th>
</tr>
<?php endif ?>
<?php else: ?>
<th><?php echo html::image(array('src' => 'media/images/icons/grid_action/money.png')); ?></th>
<th style="color: green; font-weight: bold"><?php echo __('Discounted from credit accounts') ?></th>
</tr>
<?php endif ?>
</table><br />
<h2><?php echo __('Phones in invoice') ?></h2><br />
freenetis/branches/testing/application/views/phone_invoices/show_details.php
<table class="extended" cellspacing="0">
<tr>
<th><?php echo url_lang::lang('texts.Price out of tax') ?></th>
<td><?php echo number_format($price_private, 2, ',', ' ') ?></td>
<td><?php echo number_format($price_private, 2, ',', ' ') ?> <?php echo __(Settings::get('currency')) ?></td>
</tr>
<tr>
<th><?php echo url_lang::lang('texts.Tax rate') ?></th>
<td><?php echo $tax_rate ?>%</td>
</tr>
<?php if ($phone_invoice_user->transfer_id): ?>
<tr>
<th><?php echo url_lang::lang('texts.Price vat') ?></th>
<td><b><?php echo number_format($price, 2, ',', ' ') ?></b></td>
<td><b><?php echo html::anchor('transfers/show/' . $phone_invoice_user->transfer_id, number_format($phone_invoice_user->transfer->amount, 2, ',', ' ')) ?></b> <?php echo __(Settings::get('currency')) ?></td>
</tr>
<?php else: ?>
<tr>
<th><?php echo url_lang::lang('texts.Price vat') ?></th>
<td><b><?php echo number_format($price, 2, ',', ' ') ?></b> <?php echo __(Settings::get('currency')) ?></td>
</tr>
<?php endif ?>
</table>
<br />
......
<br /><br />
<h2><?php echo $heading; ?></h2><br />
<?php if (($phone_invoice->locked == 0 && $phone_invoice_user->locked == 0) || $this->acl_check_view('Phone_invoices_Controller', 'dumps')): ?>
<?php if ($edit_enabled): ?>
<script type="text/javascript"><!--
......
<br />
<input type="checkbox" name="smart_checking" id="smart_checking" class="checkbox" />
<label for="smart_checking"><?php echo url_lang::lang('texts.Group selection by same phone number') ?></label>
<br />
<br /><br />
<?php endif; ?>
<br />
<?php echo $grid ?>
freenetis/branches/testing/application/views/phone_invoices/show_by_user.php
<table class="extended" cellspacing="0">
<tr>
<th><?php echo __('Company') ?>:</th>
<td><?php echo number_format($total_prices->price_company, 2, ',', ' ') ?></td>
<td>
<?php echo number_format($total_prices->price_company, 2, ',', ' ') ?>
<?php echo __(Settings::get('currency')) ?>
</td>
</tr>
<tr>
<th><?php echo __('Private') ?>:</th>
<td><b><?php echo number_format($total_prices->price_private, 2, ',', ' ') ?></b></td>
<td>
<b><?php echo number_format($total_prices->price_private, 2, ',', ' ') ?></b>
<?php echo __(Settings::get('currency')) ?>
</td>
</tr>
</table>

Také k dispozici: Unified diff