Projekt

Obecné

Profil

« Předchozí | Další » 

Revize 1299

Přidáno uživatelem pajinek před téměř 13 roky(ů)

basic changes; i try to create some new controller and model

Zobrazit rozdíly:

freenetis/branches/ticket_system/application/i18n/cs_CZ/texts.php
'this month has been already deducted!' => 'Tento měsíc už byl stržen!',
'this subnet is disabled' => 'Tato podsíť je zakázána.',
'this subnet is enabled' => 'Tato podsíť je povolena.',
'ticket reports' => 'Tikety',
'time' => 'Čas',
'time constraints' => 'Časová omezení',
'time deposits' => 'Termínované vklady',
......
'your work has been rejected' => 'Vaše práce byla zamítnuta',
'your work has been updated' => 'Vaše práce byla aktualizována',
'zip code' => 'PSČ'
);
);
freenetis/branches/ticket_system/application/models/ticket.php
<?php
class Ticket_Model extends ORM
{
// user message, can be added and deleted by user
public static $user_message = 0;
// not exactly message, it is content of side panel, should be used for information for all redirections
public static $contact_information = 1;
// content of page shown after canceling redirection
public static $cancel_message = 2;
// content of page with text for unknown device
public static $unknown_device_message = 3;
// content of page for interrupted member, this redirection can be set in system
public static $interrupted_membership_message = 4;
// content of page for debtor, this redirection can be set in system
public static $debtor_message = 5;
// content of page for payment notice, this redirection can be set in system and can be canceled by user
public static $payment_notice_message = 6;
// self cancel disabled, remote computer cannot cancel this message
public static $self_cancel_disabled = 0;
// self cancel enabled, every member's IP address will have cancelled given redirection
public static $self_cancel_member = 1;
// self cancel enabled, redirection is canceled only for current remote computer
public static $self_cancel_ip = 2;
/**
* Counts all active redirections from junction table messages_ip_addresses.
* @author Jiri Svitak
* @return unknown_type
*/
public function count_all_redirections()
{
return $this->db->count_records('tickets');
}
/**
* Gets all active redirections from junction table messages_ip_addresses.
* @return unknown_type
*/
public function get_all_redirections($limit_from = 0, $limit_results = 20, $order_by = 'ip_address', $order_by_direction = 'ASC', $filter_values = array())
{
if ($order_by == 'ip_address')
$order_by = 'inet_aton(ip_address)';
return $this->db->query("
SELECT mip.ip_address_id, ip.ip_address, m.name, mip.datetime
FROM messages_ip_addresses mip
LEFT JOIN ip_addresses ip ON ip.id = mip.ip_address_id
LEFT JOIN messages m ON m.id = mip.message_id
ORDER BY $order_by $order_by_direction
LIMIT $limit_from, $limit_results
");
}
/**
* Counts all messages.
* @return unknown_type
*/
public function count_all_messages()
{
return $this->db->count_records('messages');
}
/**
* Gets all redirection messages.
* @author Jiri Svitak
* @param $limit_from
* @param $limit_results
* @param $order_by
* @param $order_by_direction
* @param $filter_values
* @return unknown_type
*/
public function get_all_tickets($limit_from = 0, $limit_results = 20, $order_by = 'ip_address_id', $order_by_direction = 'DESC', $filter_values = array())
{
return $this->db->query("
SELECT t.*
FROM tickets t join users u on t.owner_id=u.id "); /*
ORDER BY $order_by $order_by_direction
LIMIT $limit_from, $limit_results
"); */
}
public function get_ticket_by_id($id = 0)
{
return $this->db->query("
SELECT t.*
FROM tickets t join users u on t.owner_id=u.id
WHERE t.id='{$id}' LIMIT 1
"); /*
ORDER BY $order_by $order_by_direction
LIMIT $limit_from, $limit_results
"); */
}
}
?>
freenetis/branches/ticket_system/application/controllers/tickets.php
<?php
/**
*
* Manages all double-entry accounts in the system including accounting system.
* @author Pavel Studeník
* @license <http://www.gnu.org/licenses/> GNU/GPLv3
*
*/
class Tickets_Controller extends Controller
{
function index()
{
url::redirect(url_lang::base().'tickets/show_all/');
}
/**
* @author Pavel Studeník
* It shows all tikets for account.
* @param $order_by
* @return unknown_type
*/
function show_all($group = 1, $limit_results = 500, $order_by = 'id', $order_by_direction = 'asc', $page_word = null, $page = 1)
{
if(!$this->acl_check_view('Accounts_Controller','accounts'))
Controller::error(ACCESS);
if (is_numeric($this->input->get('record_per_page')))
$limit_results = (int) $this->input->get('record_per_page');
$allowed_order_type = array('id', 'from', 'to', 'extension', 'opening_balance', 'closing_balance');
if (!in_array(strtolower($order_by), $allowed_order_type))
$order_by = 'id';
if (strtolower($order_by_direction) != 'asc' && strtolower($order_by_direction) != 'desc')
$order_by_direction = 'desc';
// model
$message_model = new Ticket_Model();
$total_messages = $message_model->count_all_messages();
if (($sql_offset = ($page - 1) * $limit_results) > $total_messages)
$sql_offset = 0;
$tickets = $message_model->get_all_tickets($sql_offset, (int)$limit_results, $order_by, $order_by_direction);
$headline = url_lang::lang('texts.Messages for redirection');
$grid = new Grid(url_lang::base().'messages', null, array(
//'separator' => '<br />-----------',
//'use_paginator' => false,
//'use_selector' => false,
'current' => $limit_results, // current selected 'records_per_page' value
'selector_increace' => 500, // increace
'selector_min' => 500, // minimum where selector start
'selector_max_multiplier' => 10,
'base_url' => Config::get('lang').'/messages/show_all/'.$limit_results.'/'.$order_by.'/'.$order_by_direction ,
'uri_segment' => 'page', // pass a string as uri_segment to trigger former 'label' functionality
'total_items' => $total_messages, // use db count query here of course
'items_per_page' => $limit_results, // it may be handy to set defaults for stuff like this in config/pagination.php
'style' => 'classic',
'order_by' => $order_by,
'order_by_direction' => $order_by_direction,
'limit_results' => $limit_results,
'url_array_ofset' => 1,
));
$grid->add_new_button(url_lang::base().'tickets/settings', url_lang::lang('texts.Settings'));
$grid->add_new_button(url_lang::base().'tickets/add', url_lang::lang('texts.Add new message'));
$grid->order_field('id')->label('ID');
$grid->order_field('title')->label("název"); //url_lang::lang('texts.Name'));
$grid->order_field('pub_date')->label("datum"); //url_lang::lang('texts.Name'));
$grid->order_field('status')->label("stav"); //url_lang::lang('texts.Name'));
$grid->order_field('priority')->label("priorita"); //url_lang::lang('texts.Name'));
$grid->order_field('group_id')->label("skupina"); //url_lang::lang('texts.Name'));
//if ($this->acl_check_view('Messages_Controller', 'message'))
// $grid->action_field('id') ->label(url_lang::lang('texts.Message'))->url(url_lang::base().'messages/show')->action(url_lang::lang('texts.Show'));
if ($this->acl_check_edit('Messages_Controller', 'message'))
$grid->action_field('id') ->label(url_lang::lang('texts.Message'))->url(url_lang::base().'tickets/show')->action(url_lang::lang('texts.Show'));
$grid->datasource($tickets);
$view = new View('main');
$view->title = $headline;
$view->content = new View('show_all');
$view->content->headline = "Tikety"; //$headline;
$view->content->message = $this->session->get_once('ticket');
$view->content->table = $grid;
$view->render(TRUE);
}
/**
* @author Pavel Studeník
* Show detail ticket
* @return unknown_type
*/
function show($ticket_id)
{
if(!$this->acl_check_view('Accounts_Controller','accounts'))
Controller::error(ACCESS);
// model
$ticket_model = new Ticket_Model($ticket_id);
$ticket = $ticket_model->get_ticket_by_id($ticket_id);
$headline = url_lang::lang('texts.Messages for redirection');
$grid = new Grid(url_lang::base().'messages', null, array(
//'separator' => '<br />-----------',
//'use_paginator' => false,
//'use_selector' => false,
// 'current' => $limit_results, // current selected 'records_per_page' value
'selector_increace' => 500, // increace
'selector_min' => 500, // minimum where selector start
'selector_max_multiplier' => 10,
// 'base_url' => Config::get('lang').'/messages/show_all/'.$limit_results.'/'.$order_by.'/'.$order_by_direction ,
'uri_segment' => 'page', // pass a string as uri_segment to trigger former 'label' functionality
// 'total_items' => $total_messages, // use db count query here of course
// 'items_per_page' => $limit_results, // it may be handy to set defaults for stuff like this in config/pagination.php
'style' => 'classic',
// 'order_by_direction' => $order_by_direction,
// 'limit_results' => $limit_results,
'url_array_ofset' => 1,
));
$grid->add_new_button(url_lang::base().'tickets/settings', url_lang::lang('texts.Settings'));
$grid->add_new_button(url_lang::base().'tickets/add', url_lang::lang('texts.Add new message'));
$grid->order_field('id')->label('ID');
$grid->order_field('title')->label("název"); //url_lang::lang('texts.Name'));
$grid->order_field('pub_date')->label("datum"); //url_lang::lang('texts.Name'));
$grid->order_field('status')->label("stav"); //url_lang::lang('texts.Name'));
$grid->order_field('priority')->label("priorita"); //url_lang::lang('texts.Name'));
$grid->order_field('group_id')->label("skupina"); //url_lang::lang('texts.Name'));
//if ($this->acl_check_view('Messages_Controller', 'message'))
// $grid->action_field('id') ->label(url_lang::lang('texts.Message'))->url(url_lang::base().'messages/show')->action(url_lang::lang('texts.Show'));
$grid->datasource($ticket);
$view = new View('main');
$view->title = $headline;
$view->content = new View('show_all');
$view->content->headline = "Tikety"; //$headline;
$view->content->message = $this->session->get_once('ticket');
$view->content->table = $grid;
$view->render(TRUE);
}
/**
* @author Pavel Studeník
* Add new ticket ticket
* @return unknown_type
*/
function add($group = 1, $limit_results = 500, $order_by = 'id', $order_by_direction = 'asc', $page_word = null, $page = 1)
{
if(!$this->acl_check_view('Accounts_Controller','accounts'))
Controller::error(ACCESS);
// account groups
}
function settings($group = 1, $limit_results = 500, $order_by = 'id', $order_by_direction = 'asc', $page_word = null, $page = 1)
{
if(!$this->acl_check_view('Accounts_Controller','accounts'))
Controller::error(ACCESS);
// account groups
}
}
freenetis/branches/ticket_system/application/views/menu.php
<?php if ($this->acl_check_view('Users_Controller', 'work')) { ?>
<li><?php echo html::anchor(url_lang::base().'work_reports/pending', url_lang::lang('texts.Work reports')) ?></li>
<?php } ?>
<?php if ($this->acl_check_view('Users_Controller', 'work')) { ?>
<li><?php echo html::anchor(url_lang::base().'tickets/show_all', url_lang::lang('texts.Ticket reports')) ?></li>
<?php } ?>
<?php /*<li><?php echo html::anchor(url_lang::base().'requests', url_lang::lang('texts.Requests')) ?></li>*/ ?>
</ul>
</li>
......
</li><?php } ?>
</ul>
</ul>

Také k dispozici: Unified diff