Revize 1350
Přidáno uživatelem Michal Kliment před více než 12 roky(ů)
freenetis/branches/tariffs/dotaz | ||
---|---|---|
INSERT INTO transfers
|
||
SELECT NULL, 3, a.id, NULL, NULL, 634, 1, '2012-06-15', NOW(), 'Member fee', IFNULL( mf.fee, (
|
||
SELECT fee
|
||
FROM members_fees mf
|
||
JOIN fees f ON mf.fee_id = f.id
|
||
AND f.type_id =35
|
||
AND member_id =1
|
||
AND activation_date <= CURDATE( )
|
||
AND deactivation_date >= CURDATE( ) )
|
||
) AS fee
|
||
FROM accounts a
|
||
JOIN members m ON a.member_id = m.id
|
||
LEFT JOIN (
|
||
|
||
SELECT *
|
||
FROM (
|
||
|
||
SELECT member_id, fee
|
||
FROM members_fees mf
|
||
JOIN fees f ON mf.fee_id = f.id
|
||
AND f.type_id =35
|
||
WHERE activation_date <= CURDATE( )
|
||
AND deactivation_date >= CURDATE( )
|
||
ORDER BY priority
|
||
)mf
|
||
GROUP BY member_id
|
||
)mf ON mf.member_id = m.id
|
||
WHERE account_attribute_id =221100
|
||
AND (
|
||
mf.fee IS NULL
|
||
OR mf.fee <>0
|
||
)
|
freenetis/branches/tariffs/application/helpers/callback.php | ||
---|---|---|
}
|
||
}
|
||
|
||
public static function fee_deduct_type_field($item, $name)
|
||
{
|
||
$type = Fee_deduct_Model::get_type($item->type);
|
||
|
||
echo ($type !== FALSE) ? $type : '';
|
||
}
|
||
|
||
/**
|
||
* Callback function to print type of interface
|
||
*
|
freenetis/branches/tariffs/application/helpers/arr.php | ||
---|---|---|
|
||
return $array;
|
||
}
|
||
|
||
/**
|
||
* Create new array with odd values as keys and even values as values
|
||
* @param type $array
|
||
* @return type
|
||
*/
|
||
public static function odd2key($array)
|
||
{
|
||
$arr = array();
|
||
|
||
for ($i=0; $i<count($array); $i+=2)
|
||
{
|
||
$arr[$array[$i]] = isset($array[$i+1]) ? $array[$i+1] : '';
|
||
}
|
||
|
||
return $arr;
|
||
}
|
||
|
||
} // End arr
|
freenetis/branches/tariffs/application/helpers/condition.php | ||
---|---|---|
|
||
/**
|
||
* Check if special type id of item is not membership interrupt.
|
||
* Data row has to have special_type_id column.
|
||
* Data row has to have system column.
|
||
*
|
||
* @author Ondřej Fibich
|
||
* @param object $item Data row
|
||
* @return boolean
|
||
*/
|
||
public static function special_type_id_is_not_membership_interrupt($item)
|
||
public static function is_not_system($item)
|
||
{
|
||
return ($item->special_type_id != Fee_Model::MEMBERSHIP_INTERRUPT);
|
||
return (!$item->system);
|
||
}
|
||
}
|
freenetis/branches/tariffs/application/models/fee.php | ||
---|---|---|
{
|
||
/** special type constants */
|
||
const MEMBERSHIP_INTERRUPT = 1;
|
||
const FORMER_MEMBER = 5;
|
||
|
||
const TYPE_REGULAR_MEMBER_FEE = 35;
|
||
const TYPE_ENTRANCE_FEE = 36;
|
||
const TYPE_TRANSFER_FEE = 37;
|
||
const TYPE_BANK_TRANSFER_FEE = 38;
|
||
const TYPE_PENALTY = 39;
|
||
|
||
protected $belongs_to = array('type' => 'enum_type');
|
||
protected $has_many = array('members_fees');
|
||
... | ... | |
public function get_all_fees($order_by = 'from', $order_by_direction = 'asc')
|
||
{
|
||
return $this->db->query("
|
||
SELECT fees.id, fees.readonly, fees.special_type_id, fees.type_id,
|
||
fees.fee, fees.from, fees.to, fees.name,
|
||
SELECT fees.id, fees.readonly, fees.special_type_id, fees.system,
|
||
fees.type_id, fees.fee, fees.from, fees.to, fees.name,
|
||
IFNULL(translations.translated_term, enum_types.value) as type
|
||
FROM fees
|
||
LEFT JOIN enum_types on enum_types.id = fees.type_id
|
||
... | ... | |
public function get_all_fees_by_fee_type_id($fee_type_id)
|
||
{
|
||
return $this->db->query("
|
||
SELECT f.id, f.readonly, f.special_type_id, f.fee, f.from, f.to,
|
||
SELECT f.id, f.readonly, f.special_type_id, f.system, f.fee, f.from, f.to,
|
||
IFNULL(translations.translated_term, enum_types.value) as type, f.name
|
||
FROM fees f
|
||
LEFT JOIN enum_types on enum_types.id = f.type_id
|
freenetis/branches/tariffs/application/models/subnet.php | ||
---|---|---|
* @param array $filter_values
|
||
* @return Mysql_Result
|
||
*/
|
||
public function get_all_subnets($limit_from = 0, $limit_results = NULL,
|
||
$order_by = 'id', $order_by_direction = 'ASC', $filter_sql = '')
|
||
public function get_all_subnets($sql_data = array())
|
||
{
|
||
$where = '';
|
||
$limit = '';
|
||
|
||
$order_by = $this->db->escape_column($order_by);
|
||
$limit = isset($sql_data['limit']) ? $sql_data['limit'] : '';
|
||
$order_by = isset($sql_data['order_by']) ? $sql_data['order_by'] : '';
|
||
|
||
// order by direction check
|
||
if (strtolower($order_by_direction) != 'desc')
|
||
{
|
||
$order_by_direction = 'asc';
|
||
}
|
||
|
||
// filter
|
||
if ($filter_sql != '')
|
||
$where = "WHERE $filter_sql";
|
||
//if ($filter_sql != '')
|
||
// $where = "WHERE $filter_sql";
|
||
|
||
// limit is set
|
||
if ($limit_results)
|
||
$limit = "LIMIT ".intval($limit_from) . "," . intval($limit_results);
|
||
|
||
// query
|
||
return $this->db->query("
|
||
SELECT * FROM
|
||
... | ... | |
LEFT JOIN members m ON so.member_id = m.id
|
||
) s
|
||
$where
|
||
ORDER BY $order_by $order_by_direction
|
||
$order_by
|
||
$limit
|
||
");
|
||
}
|
freenetis/branches/tariffs/application/models/members_fee.php | ||
---|---|---|
SELECT mf.*, f.readonly, f.type_id AS fee_type_id,
|
||
IFNULL(t.translated_term,et.value) AS fee_type_name,
|
||
f.name AS fee_name, f.fee AS fee_fee, 1 AS status,
|
||
f.special_type_id
|
||
f.special_type_id, f.system
|
||
FROM members_fees mf
|
||
LEFT JOIN fees f ON mf.fee_id = f.id
|
||
LEFT JOIN enum_types et ON f.type_id = et.id
|
freenetis/branches/tariffs/application/models/fee_deduct.php | ||
---|---|---|
<?php defined('SYSPATH') or die('No direct script access.');
|
||
/*
|
||
* This file is part of open source system FreeNetIS
|
||
* and it is release 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/
|
||
*
|
||
*/
|
||
|
||
/**
|
||
* Deduct of fees.
|
||
*
|
||
* @package Model
|
||
*
|
||
* @property integer $id
|
||
* @property integer $type
|
||
* @property string $date
|
||
* @property string $creation_datetime
|
||
* @property integer $user_id
|
||
*/
|
||
class Fee_deduct_Model extends ORM
|
||
{
|
||
const TYPE_MEMBER_FEE = 1;
|
||
const TYPE_ENTRANCE_FEE = 2;
|
||
const TYPE_DEVICE_FEE = 5;
|
||
|
||
private static $types = array
|
||
(
|
||
self::TYPE_MEMBER_FEE => 'member fee',
|
||
self::TYPE_ENTRANCE_FEE => 'entrance fee',
|
||
self::TYPE_DEVICE_FEE => 'device fee'
|
||
);
|
||
|
||
public static function get_type ($type_id)
|
||
{
|
||
if (isset(self::$types[$type_id]))
|
||
return __(self::$types[$type_id]);
|
||
else
|
||
return false;
|
||
}
|
||
|
||
public function get_all_fee_deducts($sql_data = array())
|
||
{
|
||
$limit = isset($sql_data['limit']) ? $sql_data['limit'] : '';
|
||
$order_by = isset($sql_data['order_by']) ? $sql_data['order_by'] : '';
|
||
|
||
return $this->db->query("
|
||
SELECT
|
||
fd.*, transfers_count, total_amount
|
||
FROM fee_deducts fd
|
||
LEFT JOIN
|
||
(
|
||
SELECT
|
||
fee_deduct_id,
|
||
COUNT(*) AS transfers_count,
|
||
SUM(amount) AS total_amount
|
||
FROM transfers t
|
||
WHERE fee_deduct_id IS NOT NULL
|
||
GROUP BY fee_deduct_id
|
||
) t ON t.fee_deduct_id = fd.id
|
||
$order_by
|
||
$limit
|
||
");
|
||
}
|
||
|
||
public function count_all_fee_deducts()
|
||
{
|
||
return count($this->get_all_fee_deducts());
|
||
}
|
||
}
|
freenetis/branches/tariffs/application/models/member.php | ||
---|---|---|
* @property double $entrance_fee
|
||
* @property double $debt_payment_rate
|
||
* @property double $entrance_fee_left
|
||
* @property date $entrance_fee_date
|
||
* @property date $entrance_date
|
||
* @property date $date
|
||
* @property date $entrance_form_received
|
||
* @property date $entrance_form_accepted
|
||
... | ... | |
* @param $filter_values used for filtering
|
||
* @return Mysql_Result
|
||
*/
|
||
public function get_all_members($limit_from = 0, $limit_results = 50, $order_by = 'id',
|
||
$order_by_direction = 'asc', $filter_sql = "")
|
||
public function get_all_members($sql_data = array())
|
||
{
|
||
$where = '';
|
||
if ($filter_sql != '')
|
||
$where = "WHERE $filter_sql";
|
||
/*if ($filter_sql != '')
|
||
$where = "WHERE $filter_sql";*/
|
||
|
||
// order by direction check
|
||
if (strtolower($order_by_direction) != 'desc')
|
||
{
|
||
$order_by_direction = 'asc';
|
||
}
|
||
$limit = isset($sql_data['limit']) ? $sql_data['limit'] : '';
|
||
$order_by = isset($sql_data['order_by']) ? $sql_data['order_by'] : '';
|
||
|
||
// query
|
||
return $this->db->query("
|
||
SELECT id, id AS member_id, name AS member_name, registration, registrations,
|
||
... | ... | |
$where
|
||
) AS q
|
||
GROUP BY q.id
|
||
ORDER BY " . $this->db->escape_column($order_by) . " $order_by_direction
|
||
LIMIT " . intval($limit_from) . ", " . intval($limit_results) . "
|
||
$order_by
|
||
$limit
|
||
", array
|
||
(
|
||
__('Yes'),
|
freenetis/branches/tariffs/application/models/account.php | ||
---|---|---|
* @param string $date
|
||
* @return Mysql_Result object
|
||
*/
|
||
public function get_accounts_to_deduct($date)
|
||
public function get_accounts_to_deduct($type, $date)
|
||
{
|
||
// check
|
||
if (!preg_match("/^\d{4}\-\d{2}\-\d{2}$/", $date))
|
||
{
|
||
return FALSE;
|
||
}
|
||
|
||
return $this->db->query("
|
||
SELECT m.id, m.name, IFNULL(mf.fee,
|
||
(
|
||
SELECT fee
|
||
FROM members_fees mf
|
||
JOIN fees f ON mf.fee_id = f.id
|
||
AND f.type_id = ?
|
||
AND member_id = ?
|
||
AND activation_date <= ?
|
||
AND deactivation_date >= ?
|
||
)) AS fee
|
||
FROM accounts a
|
||
JOIN members m ON a.member_id = m.id
|
||
LEFT JOIN
|
||
(
|
||
SELECT *
|
||
FROM
|
||
(
|
||
SELECT member_id, fee
|
||
FROM members_fees mf
|
||
JOIN fees f ON mf.fee_id = f.id
|
||
AND f.type_id = ?
|
||
WHERE activation_date <= ?
|
||
AND deactivation_date >= ?
|
||
ORDER BY priority
|
||
)mf
|
||
GROUP BY member_id
|
||
)mf ON mf.member_id = m.id
|
||
WHERE account_attribute_id = ?
|
||
AND (mf.fee IS NULL OR mf.fee <> 0)
|
||
AND m.entrance_date <= ?
|
||
", array
|
||
(
|
||
$type, Member_Model::ASSOCIATION, $date, $date, $type,
|
||
$date, $date, Account_attribute_Model::CREDIT, $date
|
||
));
|
||
|
||
//die($this->db->last_query());
|
||
|
||
// query
|
||
return $this->db->query("
|
||
/*return $this->db->query("
|
||
SELECT a.id, a.balance, m.entrance_date, m.leaving_date,
|
||
IF(mf.fee IS NOT NULL, 1, 0) fee_is_set,
|
||
mf.fee,
|
||
... | ... | |
AND (m.leaving_date = '0000-00-00'
|
||
OR (m.leaving_date <> '0000-00-00' AND m.leaving_date > '$date'))
|
||
AND a.account_attribute_id = ?
|
||
", array(Transfer_Model::DEDUCT_MEMBER_FEE, Account_attribute_Model::CREDIT));
|
||
", array(Transfer_Model::DEDUCT_MEMBER_FEE, Account_attribute_Model::CREDIT));*/
|
||
}
|
||
|
||
/**
|
freenetis/branches/tariffs/application/models/transfer.php | ||
---|---|---|
// delete transfer
|
||
$transfer->delete_throwable();
|
||
}
|
||
|
||
public function deduct_fees($type, $date)
|
||
{
|
||
return $this->db->query("
|
||
INSERT INTO transfers
|
||
SELECT
|
||
NULL,
|
||
(
|
||
SELECT a.id
|
||
FROM accounts a
|
||
WHERE account_attribute_id = ?
|
||
),
|
||
a.id,
|
||
NULL,
|
||
NULL,
|
||
?,
|
||
?,
|
||
?,
|
||
NOW(),
|
||
'Member fee',
|
||
IFNULL(mf.fee,
|
||
(
|
||
SELECT fee
|
||
FROM members_fees mf
|
||
JOIN fees f ON mf.fee_id = f.id
|
||
AND f.type_id = ?
|
||
AND member_id = ?
|
||
AND activation_date <= ?
|
||
AND deactivation_date >= ?
|
||
)) AS fee
|
||
FROM accounts a
|
||
JOIN members m ON a.member_id = m.id
|
||
LEFT JOIN
|
||
(
|
||
SELECT *
|
||
FROM
|
||
(
|
||
SELECT member_id, fee
|
||
FROM members_fees mf
|
||
JOIN fees f ON mf.fee_id = f.id
|
||
AND f.type_id = ?
|
||
WHERE activation_date <= ?
|
||
AND deactivation_date >= ?
|
||
ORDER BY priority
|
||
)mf
|
||
GROUP BY member_id
|
||
)mf ON mf.member_id = m.id
|
||
WHERE account_attribute_id = ?
|
||
AND (mf.fee IS NULL OR mf.fee <> 0)
|
||
AND m.entrance_date <= ?
|
||
", array
|
||
(
|
||
Account_attribute_Model::OPERATING, $this->session->get('user_id'),
|
||
$type, $date, $type, Member_Model::ASSOCIATION, $date, $date, $type,
|
||
$date, $date, Account_attribute_Model::CREDIT, $date
|
||
));
|
||
}
|
||
|
||
}
|
freenetis/branches/tariffs/application/controllers/subnets.php | ||
---|---|---|
$filter_form->add('used')
|
||
->type('number');
|
||
|
||
// get new selector
|
||
if (is_numeric($this->input->get('record_per_page')))
|
||
{
|
||
$limit_results = (int) $this->input->get('record_per_page');
|
||
}
|
||
|
||
// get count of records
|
||
$subnet_model = new Subnet_Model();
|
||
$total_subnets = $subnet_model->count_all_subnets($filter_form->as_sql());
|
||
|
||
// offset check
|
||
if (($sql_offset = ($page - 1) * $limit_results) > $total_subnets)
|
||
$sql_offset = 0;
|
||
|
||
// get records
|
||
$query = $subnet_model->get_all_subnets(
|
||
$sql_offset, (int) $limit_results, $order_by,
|
||
$order_by_direction, $filter_form->as_sql()
|
||
);
|
||
$total_subnets = $subnet_model->count_all_subnets($filter_form->as_sql());
|
||
|
||
// grid
|
||
$grid = new Grid(url_lang::base().'devices', null, array(
|
||
'current' => $limit_results,
|
||
'selector_increace' => 500,
|
||
'selector_min' => 500,
|
||
'selector_max_multiplier' => 20,
|
||
'base_url' => Config::get('lang').'/subnets/show_all/'
|
||
. $limit_results.'/'.$order_by.'/'.$order_by_direction ,
|
||
'uri_segment' => 'page',
|
||
'total_items' => $total_subnets,
|
||
'items_per_page' => $limit_results,
|
||
'style' => 'classic',
|
||
'order_by' => $order_by,
|
||
'order_by_direction' => $order_by_direction,
|
||
'limit_results' => $limit_results,
|
||
'filter' => $filter_form
|
||
));
|
||
$grid = new Grid($this->url(), array(
|
||
'total_items' => $total_subnets
|
||
), arr::odd2key($this->extra_arguments));
|
||
|
||
if ($this->acl_check_new('Devices_Controller', 'subnet'))
|
||
{
|
||
... | ... | |
}
|
||
|
||
// load data
|
||
$grid->datasource( $query );
|
||
$grid->datasource($subnet_model->get_all_subnets($grid->sql_data()));
|
||
|
||
// view
|
||
$view = new View('main');
|
freenetis/branches/tariffs/application/controllers/fee_deducts.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/
|
||
*
|
||
*/
|
||
|
||
/**
|
||
* Controller performs actions with deducts of fees.
|
||
*
|
||
* @package Controller
|
||
*/
|
||
class Fee_deducts_Controller extends Controller
|
||
{
|
||
/**
|
||
* Index redirects to show all
|
||
*/
|
||
public function index()
|
||
{
|
||
$this->redirect('show_all');
|
||
}
|
||
|
||
public function show_all()
|
||
{
|
||
$fee_deduct_model = new Fee_deduct_Model();
|
||
|
||
$grid = new Grid($this->url(), array
|
||
(
|
||
'total_items' => $fee_deduct_model->count_all_fee_deducts()
|
||
), arr::odd2key($this->extra_arguments));
|
||
|
||
$grid->order_field('id')
|
||
->label('ID');
|
||
|
||
$grid->order_callback_field('type')
|
||
->callback('callback::fee_deduct_type_field');
|
||
|
||
$grid->order_field('date');
|
||
|
||
$grid->order_field('transfers_count')
|
||
->class('center');
|
||
|
||
$grid->order_callback_field('total_amount')
|
||
->callback('callback::money')
|
||
->class('center');
|
||
|
||
$actions = $grid->grouped_action_field();
|
||
|
||
$actions->add_action('id')
|
||
->icon_action('transfer')
|
||
->url('transfers/show_by_fee_deduct')
|
||
->label('Show transfers');
|
||
|
||
$actions->add_action('id')
|
||
->icon_action('delete')
|
||
->url('fee_deduct/delete')
|
||
->class('delete_link');
|
||
|
||
$grid->datasource($fee_deduct_model->get_all_fee_deducts($grid->sql_data()));
|
||
|
||
$title = __('List of all deducts of fees');
|
||
|
||
$view = new View('main');
|
||
$view->title = $title;
|
||
$view->content = new View('show_all');
|
||
$view->content->headline = $title;
|
||
$view->content->table = $grid->render();
|
||
$view->render(TRUE);
|
||
}
|
||
|
||
public function add()
|
||
{
|
||
$form = new Forge();
|
||
|
||
$types = array(
|
||
Fee_deduct_Model::TYPE_MEMBER_FEE => __('Member fee'),
|
||
Fee_deduct_Model::TYPE_ENTRANCE_FEE => __('Entrance fee'),
|
||
Fee_deduct_Model::TYPE_DEVICE_FEE => __('Device fee')
|
||
);
|
||
|
||
$form->dropdown('type')
|
||
->options($types);
|
||
|
||
$form->dropdown('month')
|
||
->options(date::months());
|
||
|
||
$form->dropdown('year')
|
||
->options(date::years(
|
||
substr($this->association->entrance_date, 0, 4),
|
||
date('Y')
|
||
));
|
||
|
||
$form->submit('Deduct');
|
||
|
||
if ($form->validate())
|
||
{
|
||
$form_data = $form->as_array();
|
||
|
||
switch ($form_data['type'])
|
||
{
|
||
case Fee_deduct_Model::TYPE_MEMBER_FEE:
|
||
|
||
$date = date('Y-m-d', mktime(
|
||
0, 0, 0, $form_data['month'], 15, $form_data['year']
|
||
));
|
||
|
||
$account_model = new Account_Model();
|
||
$accounts = $account_model->get_accounts_to_deduct(Fee_Model::TYPE_REGULAR_MEMBER_FEE, $date);
|
||
|
||
echo count($accounts);
|
||
|
||
break;
|
||
}
|
||
}
|
||
|
||
$title = __('Deduct fees');
|
||
|
||
$view = new View('main');
|
||
$view->title = $title;
|
||
$view->content = new View('form');
|
||
$view->content->headline = $title;
|
||
$view->content->form = $form;
|
||
$view->render(TRUE);
|
||
}
|
||
}
|
||
|
||
?>
|
freenetis/branches/tariffs/application/controllers/members.php | ||
---|---|---|
* @param integer $page_word
|
||
* @param integer $page
|
||
*/
|
||
public function show_all(
|
||
$limit_results = 100, $order_by = 'id',
|
||
$order_by_direction = 'ASC', $page_word = 'page', $page = 1,
|
||
$registrations = 0)
|
||
public function show_all()
|
||
{
|
||
$profiler = new Profiler();
|
||
|
||
// access rights
|
||
if (!$this->acl_check_view(get_class($this),'members'))
|
||
... | ... | |
Ip_address_Model::PERNAMENT_WHITELIST => __('Permanent whitelist'),
|
||
Ip_address_Model::TEMPORARY_WHITELIST => __('Temporary whitelist')
|
||
));
|
||
|
||
// gets new selector
|
||
if (is_numeric($this->input->get('record_per_page')))
|
||
$limit_results = (int) $this->input->get('record_per_page');
|
||
|
||
// parameters control
|
||
$allowed_order_type = array
|
||
... | ... | |
'balance', 'type_name', 'redirect', 'whitelisted'
|
||
);
|
||
|
||
// order by check
|
||
if (!in_array(strtolower($order_by), $allowed_order_type))
|
||
$order_by = 'id';
|
||
|
||
// order by direction check
|
||
if (strtolower($order_by_direction) != 'desc')
|
||
$order_by_direction = 'asc';
|
||
|
||
// load members
|
||
$model_members = new Member_Model();
|
||
$total_members = $model_members->count_all_members($filter_form->as_sql());
|
||
|
||
// limit check
|
||
if (($sql_offset = ($page - 1) * $limit_results) > $total_members)
|
||
$sql_offset = 0;
|
||
|
||
// query data
|
||
$query = $model_members->get_all_members(
|
||
$sql_offset, (int)$limit_results, $order_by, $order_by_direction,
|
||
$filter_form->as_sql()
|
||
);
|
||
|
||
// headline
|
||
$headline = __('List of all members');
|
||
// path to form
|
||
$path = Config::get('lang') . '/members/show_all/' . $limit_results . '/'
|
||
. $order_by . '/' . $order_by_direction.'/'.$page_word.'/'
|
||
. $page.'/'.$registrations;
|
||
|
||
// it creates grid to view all members
|
||
$grid = new Grid('members', null, array
|
||
$grid = new Grid($this->url(), array
|
||
(
|
||
'current' => $limit_results,
|
||
'selector_increace' => 200,
|
||
'selector_min' => 200,
|
||
'selector_max_multiplier' => 25,
|
||
'base_url' => $path,
|
||
'uri_segment' => 'page',
|
||
'total_items' => $total_members,
|
||
'items_per_page' => $limit_results,
|
||
'style' => 'classic',
|
||
'order_by' => $order_by,
|
||
'order_by_direction' => $order_by_direction,
|
||
'limit_results' => $limit_results,
|
||
'filter' => $filter_form
|
||
));
|
||
'total_items' => $model_members->count_all_members($filter_form->as_sql())
|
||
), arr::odd2key($this->extra_arguments));
|
||
|
||
// grid buttons
|
||
if ($this->acl_check_new(get_class($this), 'members'))
|
||
... | ... | |
|
||
if ($this->acl_check_edit('Members_Controller', 'registration'))
|
||
{
|
||
if (!$registrations)
|
||
/*if (!$registrations)
|
||
{
|
||
$grid->add_new_button(
|
||
'members/show_all/'.$limit_results .
|
||
... | ... | |
'/'.$page_word.'/'.$page.'/0'.server::query_string(),
|
||
__('End editing of registrations')
|
||
);
|
||
}
|
||
}*/
|
||
}
|
||
|
||
if ($this->acl_check_view(get_class($this), 'members'))
|
||
... | ... | |
$grid->order_field('id')
|
||
->label('ID');
|
||
|
||
if ($registrations)
|
||
/*if ($registrations)
|
||
{
|
||
$grid->order_form_field('registrations')
|
||
->type('checkbox')
|
||
... | ... | |
->label(__('Reg'))
|
||
->class('center')
|
||
->callback('callback::registration_field');
|
||
}
|
||
}*/
|
||
|
||
$grid->order_field('type');
|
||
|
||
... | ... | |
}
|
||
|
||
// load data
|
||
$grid->datasource($query);
|
||
$grid->datasource($model_members->get_all_members($grid->sql_data()));
|
||
|
||
if (isset($_POST) && count ($_POST))
|
||
{
|
||
... | ... | |
url::redirect($_POST["url"]);
|
||
}
|
||
|
||
// headline
|
||
$headline = __('List of all members');
|
||
|
||
// view
|
||
$view = new View('main');
|
||
$view->title = $headline;
|
||
... | ... | |
$view->content->table = $grid;
|
||
$view->content->headline = $headline;
|
||
$view->render(TRUE);
|
||
|
||
echo $profiler->render(TRUE);
|
||
} // end of show_all function
|
||
|
||
/**
|
||
... | ... | |
* @param string $order_by_direction sorting direction
|
||
*/
|
||
public function show(
|
||
$member_id = NULL, $order_by = 'member_id',
|
||
Member_Model $member, $order_by = 'member_id',
|
||
$order_by_direction = 'ASC')
|
||
{
|
||
// parameter is wrong
|
||
if (!$member_id || !is_numeric($member_id))
|
||
Controller::warning(PARAMETER);
|
||
|
||
$this->member = $member = new Member_Model($member_id);
|
||
|
||
// member doesn't exist
|
||
if (!$member->id)
|
||
Controller::error(RECORD);
|
||
... | ... | |
{
|
||
$account = ORM::factory('account')->where(array
|
||
(
|
||
'member_id' => $member_id,
|
||
'member_id' => $member->id,
|
||
'account_attribute_id' => Account_attribute_Model::CREDIT
|
||
))->find();
|
||
}
|
||
... | ... | |
'use_selector' => false,
|
||
'order_by' => $order_by,
|
||
'order_by_direction' => $order_by_direction,
|
||
'variables' => $member_id.'/'
|
||
'variables' => $member->id.'/'
|
||
));
|
||
|
||
$voip_grid->field('id')
|
||
... | ... | |
}
|
||
|
||
// finds date of expiration of member fee
|
||
$expiration_date = (isset($account)) ? self::get_expiration_date($account) : '';
|
||
$expiration_date = '';
|
||
|
||
// finds total traffic of member
|
||
$members_traffic_model = new Members_traffic_Model();
|
||
... | ... | |
if ($form->validate())
|
||
{
|
||
$form_data = $form->as_array();
|
||
$member->leaving_date = date('Y-m-d', $form_data['leaving_date']);
|
||
$enum_type_model = new Enum_type_Model();
|
||
$member->type = $enum_type_model->get_type_id('Former member');
|
||
|
||
if ($member->save())
|
||
try
|
||
{
|
||
$member->transaction_start();
|
||
|
||
$member->leaving_date = date('Y-m-d', $form_data['leaving_date']);
|
||
$enum_type_model = new Enum_type_Model();
|
||
$member->type = $enum_type_model->get_type_id('Former member');
|
||
|
||
$member->save_throwable();
|
||
|
||
$fee_model = new Fee_Model();
|
||
|
||
$former_member_fee = $fee_model
|
||
->get_by_special_type(Fee_Model::FORMER_MEMBER);
|
||
|
||
$members_fee = new Members_fee_Model();
|
||
$members_fee->fee_id = $former_member_fee->id;
|
||
$members_fee->member_id = $member->id;
|
||
$members_fee->activation_date = date('Y-m-d', $form_data['leaving_date']);
|
||
$members_fee->deactivation_date = $former_member_fee->to;
|
||
$members_fee->priority = 0;
|
||
|
||
$members_fee->save_throwable();
|
||
|
||
$member->transaction_commit();
|
||
status::success('Membership of the member has been ended.');
|
||
}
|
||
else
|
||
catch(Exception $e)
|
||
{
|
||
$member->transaction_rollback();
|
||
status::error('Error - cant end membership.');
|
||
}
|
||
|
||
url::redirect('members/show/' . $member_id);
|
||
$this->redirect('members/show/' . $member_id);
|
||
}
|
||
else
|
||
{
|
||
$headline = __('End membership');
|
||
|
||
$headline = __('End membership');
|
||
// breadcrumbs navigation
|
||
$breadcrumbs = breadcrumbs::add()
|
||
->link('members/show_all', 'Members',
|
||
$this->acl_check_view(get_class($this),'members'))
|
||
->disable_translation()
|
||
->link('members/show/'.$member->id,
|
||
"ID $member->id - $member->name",
|
||
$this->acl_check_view(
|
||
get_class($this),'members', $member->id
|
||
)
|
||
)
|
||
->text($headline);
|
||
|
||
// breadcrumbs navigation
|
||
$breadcrumbs = breadcrumbs::add()
|
||
->link('members/show_all', 'Members',
|
||
$this->acl_check_view(get_class($this),'members'))
|
||
->disable_translation()
|
||
->link('members/show/'.$member->id,
|
||
"ID $member->id - $member->name",
|
||
$this->acl_check_view(
|
||
get_class($this),'members', $member->id
|
||
)
|
||
)
|
||
->text($headline);
|
||
|
||
// view
|
||
$view = new View('main');
|
||
$view->breadcrumbs = $breadcrumbs->html();
|
||
$view->title = $headline;
|
||
$view->content = new View('form');
|
||
$view->content->headline = $headline;
|
||
$view->content->form = $form->html();
|
||
$view->content->link_back = '';
|
||
$view->render(TRUE);
|
||
// view
|
||
$view = new View('main');
|
||
$view->breadcrumbs = $breadcrumbs->html();
|
||
$view->title = $headline;
|
||
$view->content = new View('form');
|
||
$view->content->headline = $headline;
|
||
$view->content->form = $form->html();
|
||
$view->content->link_back = '';
|
||
$view->render(TRUE);
|
||
}
|
||
}
|
||
|
||
/**
|
||
... | ... | |
if (!$this->acl_check_edit(get_class($this), 'members', $member_id))
|
||
Controller::error(ACCESS);
|
||
|
||
// this sets member to regular member
|
||
$member->leaving_date = '0000-00-00';
|
||
$enum_type_model = new Enum_type_Model();
|
||
$member->type = $enum_type_model->get_type_id('Regular member');
|
||
|
||
if ($member->save())
|
||
try
|
||
{
|
||
$member->transaction_start();
|
||
|
||
$enum_type_model = new Enum_type_Model();
|
||
$members_fee_model = new Members_fee_Model();
|
||
$fee_model = new Fee_Model();
|
||
|
||
// find type of regular member
|
||
$regular_member_type = $enum_type_model
|
||
->get_type_id('Regular member');
|
||
|
||
// find fee for former member
|
||
$former_member_fee = $fee_model
|
||
->get_by_special_type(Fee_Model::FORMER_MEMBER);
|
||
|
||
// this sets member to regular member
|
||
$member->leaving_date = NULL;
|
||
$member->type = $regular_member_type;
|
||
|
||
$member->save_throwable();
|
||
|
||
$members_fee = $members_fee_model->where(array
|
||
(
|
||
'member_id' => $member->id,
|
||
'fee_id' => $former_member_fee->id
|
||
))->find();
|
||
|
||
$members_fee->delete_throwable();
|
||
|
||
$member->transaction_commit();
|
||
status::success('Membership of the member has been successfully restored.');
|
||
}
|
||
else
|
||
catch (Exception $e)
|
||
{
|
||
$member->transaction_rollback();
|
||
status::error('Error - cant restore membership.');
|
||
}
|
||
|
freenetis/branches/tariffs/application/controllers/members_fees.php | ||
---|---|---|
{
|
||
$actions->add_conditional_action()
|
||
->icon_action('edit')
|
||
->condition('special_type_id_is_not_membership_interrupt')
|
||
->condition('is_not_system')
|
||
->url('members_fees/edit');
|
||
}
|
||
|
||
... | ... | |
{
|
||
$actions->add_conditional_action()
|
||
->icon_action('delete')
|
||
->condition('special_type_id_is_not_membership_interrupt')
|
||
->condition('is_not_system')
|
||
->url('members_fees/delete')
|
||
->class('delete_link');
|
||
}
|
||
... | ... | |
// converts to array
|
||
foreach ($fees as $fee)
|
||
{
|
||
// tariff of membership interrupt can be add only by adding of new membership interrupt
|
||
if ($fee->special_type_id == Fee_Model::MEMBERSHIP_INTERRUPT)
|
||
// tariff of membership interrupt or former member can be add by system
|
||
if ($fee->system)
|
||
continue;
|
||
|
||
// name is optional, uses it only if it is not empty
|
||
... | ... | |
Controller::error(ACCESS);
|
||
|
||
// read-only tariff cannot be edited
|
||
if ($members_fee->fee->special_type_id == Fee_Model::MEMBERSHIP_INTERRUPT)
|
||
if ($members_fee->fee->system)
|
||
{
|
||
status::success('Read-only tariff cannot be edited.');
|
||
url::redirect(
|
||
... | ... | |
Controller::error(ACCESS);
|
||
|
||
// read-only tariff cannot be edited
|
||
if ($members_fee->fee->special_type_id == Fee_Model::MEMBERSHIP_INTERRUPT)
|
||
if ($members_fee->fee->system)
|
||
{
|
||
status::warning('Read-only tariff cannot be deleted.');
|
||
url::redirect('members_fees/show_by_member/'.$members_fee->member_id);
|
||
... | ... | |
$input->add_error('required', __('Date must be in interval of membership.'));
|
||
}
|
||
|
||
// member is former member
|
||
if ($member->leaving_date != '0000-00-00')
|
||
{
|
||
// member ended his membership before tariff activation date
|
||
if ($member->leaving_date < $from || $member->leaving_date < $to)
|
||
{
|
||
$input->add_error('required', __('Date must be in interval of membership.'));
|
||
}
|
||
}
|
||
|
||
$members_fees = ORM::factory('members_fee')->exists(
|
||
$member->id, $fee->type_id, $from, $to, $members_fee_id
|
||
);
|
freenetis/branches/tariffs/application/upgrade_sql/upgrade_sql.php | ||
---|---|---|
}
|
||
|
||
/**
|
||
* Re-create function to ulogd
|
||
* @return boolean
|
||
*/
|
||
function upgrade_sql_after()
|
||
{
|
||
$user_model = new User_Model();
|
||
|
||
// check if user have permissions to create function
|
||
if (Settings::get('ulogd_enabled')
|
||
&& $user_model->check_permission("CREATE ROUTINE"))
|
||
{
|
||
// creates function for ulogd
|
||
Ulog2_ct_Model::create_functions();
|
||
}
|
||
else
|
||
Settings::set('ulogd_enabled', 0);
|
||
|
||
return true;
|
||
}
|
||
|
||
/**
|
||
* Add column to member table for registration time and column to phone call
|
||
* table for descripton of call.
|
||
*
|
||
... | ... | |
*/
|
||
$upgrade_sql[get_SVN_rev()] = array
|
||
(
|
||
"CREATE TABLE IF NOT EXISTS `filter_queries` (
|
||
`id` int(11) NOT NULL AUTO_INCREMENT,
|
||
`name` varchar(255) COLLATE utf8_czech_ci NOT NULL,
|
||
`url` varchar(255) COLLATE utf8_czech_ci NOT NULL,
|
||
`values` text COLLATE utf8_czech_ci NOT NULL,
|
||
`default` tinyint(1) NOT NULL DEFAULT '0',
|
||
PRIMARY KEY (`id`)
|
||
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_czech_ci AUTO_INCREMENT=1 ;",
|
||
"ALTER TABLE fees ADD system BOOLEAN NOT NULL DEFAULT '0'",
|
||
|
||
"DROP TABLE members_traffics",
|
||
"UPDATE fees SET system = 1 WHERE special_type_id = 1",
|
||
|
||
"RENAME TABLE `members_traffics_daily` TO `members_traffics`;",
|
||
"INSERT INTO fees
|
||
VALUES(
|
||
NULL, 1, 0,
|
||
(SELECT entrance_date FROM members WHERE id = 1),
|
||
'9999-12-31', 35, 'Former member', 5, 1
|
||
);",
|
||
|
||
"ALTER TABLE `members_traffics`
|
||
ADD `local_upload` INT( 11 ) NOT NULL AFTER `download`,
|
||
ADD `local_download` INT( 11 ) NOT NULL AFTER `local_upload`,
|
||
ADD `active` BOOLEAN NOT NULL DEFAULT FALSE AFTER `local_download`",
|
||
"INSERT INTO members_fees
|
||
SELECT NULL, (
|
||
SELECT id FROM fees WHERE special_type_id = 5
|
||
), m.id, leaving_date, '9999-12-31', 0
|
||
FROM members m
|
||
WHERE type = 15",
|
||
|
||
"ALTER TABLE `ip_addresses_traffics`
|
||
ADD `local_upload` INT( 11 ) NOT NULL AFTER `download`,
|
||
ADD `local_download` INT( 11 ) NOT NULL AFTER `local_upload`",
|
||
"ALTER TABLE transfers ADD fee_deduct_id INT( 11 ) NULL DEFAULT NULL AFTER id ,
|
||
ADD INDEX ( fee_deduct_id )",
|
||
|
||
"CREATE TABLE IF NOT EXISTS `local_subnets` (
|
||
"CREATE TABLE IF NOT EXISTS `fee_deducts` (
|
||
`id` int(11) NOT NULL AUTO_INCREMENT,
|
||
`network_address` varchar(15) COLLATE utf8_czech_ci DEFAULT NULL,
|
||
`netmask` varchar(15) COLLATE utf8_czech_ci DEFAULT NULL,
|
||
`type` int(11) NOT NULL,
|
||
`date` date NOT NULL,
|
||
`creation_datetime` datetime NOT NULL,
|
||
`user_id` int(11) NOT NULL,
|
||
PRIMARY KEY (`id`),
|
||
UNIQUE KEY `network_address_2` (`network_address`),
|
||
KEY `network_address` (`network_address`),
|
||
KEY `netmask` (`netmask`)
|
||
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_czech_ci AUTO_INCREMENT=1 ;",
|
||
UNIQUE KEY `type` (`type`,`date`),
|
||
KEY `type_2` (`type`),
|
||
KEY `date` (`date`),
|
||
KEY `user_id` (`user_id`)
|
||
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_czech_ci AUTO_INCREMENT=1;",
|
||
|
||
"TRUNCATE TABLE ulog2_ct"
|
||
"INSERT INTO fee_deducts
|
||
SELECT NULL, type, datetime, creation_datetime, user_id
|
||
FROM transfers t
|
||
WHERE t.type = 1 OR t.type = 2 OR t.type = 5
|
||
GROUP BY type, datetime",
|
||
|
||
"UPDATE transfers t, fee_deducts fd
|
||
SET t.fee_deduct_id = fd.id
|
||
WHERE t.type = fd.type AND t.datetime = fd.date",
|
||
|
||
"ALTER TABLE `transfers` ADD FOREIGN KEY ( `fee_deduct_id` )
|
||
REFERENCES `fee_deducts` (`id`) ON DELETE CASCADE ;",
|
||
);
|
freenetis/branches/tariffs/application/upgrade_sql/upgrade_sql_1342.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/
|
||
*
|
||
*/
|
||
|
||
/**
|
||
* Re-create function to ulogd
|
||
* @return boolean
|
||
*/
|
||
function upgrade_sql_1342_after()
|
||
{
|
||
$user_model = new User_Model();
|
||
|
||
// check if user have permissions to create function
|
||
if (Settings::get('ulogd_enabled')
|
||
&& $user_model->check_permission("CREATE ROUTINE"))
|
||
{
|
||
// creates function for ulogd
|
||
Ulog2_ct_Model::create_functions();
|
||
}
|
||
else
|
||
Settings::set('ulogd_enabled', 0);
|
||
|
||
return true;
|
||
}
|
||
|
||
/**
|
||
* Add column to member table for registration time and column to phone call
|
||
* table for descripton of call.
|
||
*
|
||
* @author Ondřej Fibich
|
||
*/
|
||
$upgrade_sql[1342] = array
|
||
(
|
||
"CREATE TABLE IF NOT EXISTS `filter_queries` (
|
||
`id` int(11) NOT NULL AUTO_INCREMENT,
|
||
`name` varchar(255) COLLATE utf8_czech_ci NOT NULL,
|
||
`url` varchar(255) COLLATE utf8_czech_ci NOT NULL,
|
||
`values` text COLLATE utf8_czech_ci NOT NULL,
|
||
`default` tinyint(1) NOT NULL DEFAULT '0',
|
||
PRIMARY KEY (`id`)
|
||
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_czech_ci AUTO_INCREMENT=1 ;",
|
||
|
||
"DROP TABLE members_traffics",
|
||
|
||
"RENAME TABLE `members_traffics_daily` TO `members_traffics`;",
|
||
|
||
"ALTER TABLE `members_traffics`
|
||
ADD `local_upload` INT( 11 ) NOT NULL AFTER `download`,
|
||
ADD `local_download` INT( 11 ) NOT NULL AFTER `local_upload`,
|
||
ADD `active` BOOLEAN NOT NULL DEFAULT FALSE AFTER `local_download`",
|
||
|
||
"ALTER TABLE `ip_addresses_traffics`
|
||
ADD `local_upload` INT( 11 ) NOT NULL AFTER `download`,
|
||
ADD `local_download` INT( 11 ) NOT NULL AFTER `local_upload`",
|
||
|
||
"CREATE TABLE IF NOT EXISTS `local_subnets` (
|
||
`id` int(11) NOT NULL AUTO_INCREMENT,
|
||
`network_address` varchar(15) COLLATE utf8_czech_ci DEFAULT NULL,
|
||
`netmask` varchar(15) COLLATE utf8_czech_ci DEFAULT NULL,
|
||
PRIMARY KEY (`id`),
|
||
UNIQUE KEY `network_address_2` (`network_address`),
|
||
KEY `network_address` (`network_address`),
|
||
KEY `netmask` (`netmask`)
|
||
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_czech_ci AUTO_INCREMENT=1 ;",
|
||
|
||
"TRUNCATE TABLE ulog2_ct"
|
||
);
|
||
freenetis/branches/tariffs/application/libraries/grid/Order_field.php | ||
---|---|---|
* @param string $new_order
|
||
* @param array $arguments
|
||
*/
|
||
public function __construct($name, $new_order, $arguments)
|
||
public function __construct($name, $base_url, $data)
|
||
{
|
||
parent::__construct($name);
|
||
|
||
if (!isset($new_order))
|
||
$new_order = $name;
|
||
|
||
$this->use_selector = $arguments['use_selector'];
|
||
$this->use_paginator = $arguments['use_paginator'];
|
||
|
||
$this->create_order_by_link(
|
||
$new_order, $arguments['order_by'],
|
||
$arguments['order_by_direction'],
|
||
$arguments['limit_results'],
|
||
$arguments['url_array_ofset'],
|
||
$arguments['variables'],
|
||
$arguments['query_string']
|
||
);
|
||
|
||
$this->create_order_by_link($name, $base_url, $data);
|
||
}
|
||
|
||
/**
|
||
... | ... | |
* @param string $variables
|
||
* @param string $query_string
|
||
*/
|
||
private function create_order_by_link(
|
||
$new_order_by = 'users.id', $order_by = 'users.id',
|
||
$order_by_direction = 'ASC', $record_per_page = NULL,
|
||
$url_array_ofset = 0, $variables = '', $query_string = '')
|
||
private function create_order_by_link($name, $base_url, $data)
|
||
{
|
||
$url_array = explode('/', trim(url::current(), '/'));
|
||
|
||
if (count($url_array) < 7)
|
||
if (isset($data['order_by']) && $data['order_by'] == $name)
|
||
$data['order_by_direction'] = ($data['order_by_direction'] == 'asc') ? 'desc' : 'asc';
|
||
else
|
||
{
|
||
$url_array[3] = 50;
|
||
$url_array[6] = 'page';
|
||
$url_array[7] = 1;
|
||
$url_array_ofset = 0;
|
||
$data['order_by'] = $name;
|
||
$data['order_by_direction'] = 'asc';
|
||
}
|
||
|
||
if (isset($record_per_page))
|
||
{
|
||
$url_array[3] = (int) $record_per_page;
|
||
}
|
||
|
||
$pre_url = $url_array[1] . '/' . $url_array[2] . '/' . $variables;
|
||
$pre_url .= ( $this->use_selector) ? $url_array[3 + $url_array_ofset] . '/' : '';
|
||
$this->return_link = $base_url;
|
||
|
||
if ($new_order_by == $order_by)
|
||
foreach ($data as $key => $val)
|
||
{
|
||
$order_by_direction = strtoupper($order_by_direction) == 'ASC' ? 'DESC' : 'ASC';
|
||
$this->return_link .= '/'.$key.'/'.$val;
|
||
}
|
||
else
|
||
{
|
||
$order_by_direction = strtoupper($order_by_direction);
|
||
}
|
||
|
||
$this->return_link = url_lang::base() . $pre_url . $new_order_by . '/' . $order_by_direction . '/';
|
||
$this->return_link .= ($this->use_paginator) ? $url_array[6 + $url_array_ofset] . '/' . $url_array[7 + $url_array_ofset] : '';
|
||
|
||
if (server::query_string() != '')
|
||
{
|
||
$this->return_link .= server::query_string();
|
||
}
|
||
$this->return_link .= server::query_string();
|
||
}
|
||
|
||
}
|
freenetis/branches/tariffs/application/libraries/Selector.php | ||
---|---|---|
*/
|
||
class Selector
|
||
{
|
||
|
||
// Config values
|
||
protected $selector_increace = 30;
|
||
protected $selector_min = 10;
|
||
protected $selector_max_multiplier = 5;
|
||
protected $current = 10;
|
||
protected $selector_increace = 100;
|
||
protected $selector_min = 100;
|
||
protected $selector_max_multiplier = 50;
|
||
protected $base_url = NULL;
|
||
|
||
protected $limit = 500;
|
||
|
||
/**
|
||
* Constructs the Selector object.
|
||
... | ... | |
* @param array configuration
|
||
* @return void
|
||
*/
|
||
public function __construct($config = array())
|
||
public function __construct($base_url = '', $config = array(), $args = array())
|
||
{
|
||
$this->base_url = $base_url;
|
||
|
||
$config = array_merge($args, $config);
|
||
|
||
// Load configuration
|
||
$this->initialize($config);
|
||
|
||
Log::add('debug', 'Selector Library initialized');
|
||
}
|
||
|
||
/**
|
||
... | ... | |
}
|
||
|
||
$view->sel_values_array = $sel_values_array;
|
||
$view->current = $this->current;
|
||
$view->limit = $this->limit;
|
||
return $view->render();
|
||
}
|
||
|
freenetis/branches/tariffs/application/libraries/Grid.php | ||
---|---|---|
class Grid
|
||
{
|
||
|
||
protected $fields;
|
||
/*protected $fields;
|
||
protected $action_fields;
|
||
protected $add_button = FALSE;
|
||
protected $back_button = FALSE;
|
||
protected $base_uri;
|
||
protected $template = 'grid_template';
|
||
protected $title;
|
||
protected $label = NULL;
|
||
protected $use_paginator = true;
|
||
protected $use_selector = true;
|
||
protected $separator = '<br /><br />';
|
||
protected $show_labels = true;
|
||
protected $selector_increace = 30;
|
||
... | ... | |
protected $style = 'classic';
|
||
protected $uri_segment = 3;
|
||
protected $items_per_page = 10;
|
||
protected $total_items = 0;
|
||
protected $base_url = '';
|
||
protected $order_by;
|
||
protected $a_rec_per_page;
|
||
... | ... | |
protected $form_extra_buttons = array();
|
||
protected $buttons = array();
|
||
protected $id = NULL;
|
||
private $first_add_button;
|
||
private $first_add_button;*/
|
||
|
||
protected $args = array();
|
||
|
||
protected $template = 'grid_template';
|
||
|
||
protected $limit = 500;
|
||
protected $order_by = 'id';
|
||
protected $order_by_direction = 'asc';
|
||
|
||
protected $allowed_options = array
|
||
(
|
||
'order_by_direction' => array('asc', 'desc')
|
||
);
|
||
|
||
protected $total_items = 0;
|
||
protected $total_pages = 1;
|
||
protected $offset = 0;
|
||
|
||
protected $format = '{}';
|
||
|
||
protected $use_paginator = true;
|
||
protected $use_selector = true;
|
||
|
||
/**
|
||
* Grid construct
|
||
... | ... | |
* @param type $config
|
||
* @param type $template
|
||
*/
|
||
public function __construct($base_uri, $title, $config = NULL, $template = FALSE)
|
||
public function __construct($base_url = '', $config = array(), $args = array())
|
||
{
|
||
if ($template)
|
||
$this->base_url = $base_url;
|
||
|
||
$this->args = $args;
|
||
|
||
$config = array_merge($args, $config);
|
||
|
||
if (is_array($config) && count($config))
|
||
{
|
||
$this->template = $template;
|
||
$this->initialize($config);
|
||
}
|
||
|
||
if (!text::starts_with($base_uri, url::base()))
|
||
if ($this->use_paginator)
|
||
{
|
||
$base_uri = url_lang::base() . $base_uri;
|
||
$this->pagination = new Pagination($this->base_url, array
|
||
(
|
Také k dispozici: Unified diff
Prvni sada zmen ve vetvi s tarify - pridana entita fee_deducts, zjednodusen grid, atd.