Projekt

Obecné

Profil

« Předchozí | Další » 

Revize 304

Přidáno uživatelem Michal Kliment před více než 15 roky(ů)

Pridana tabulka invoice_items. Pridana metoda show pro zobrazeni detailu jednotlive faktury.

Zobrazit rozdíly:

freenetis/trunk/kohana/application/i18n/cs_CZ/texts.php
'show all transfers on the account' => 'Ukaž všechny převody tohoto účtu',
'show his transfers' => 'Zobrazit jeho převody',
'show his devices' => 'Zobrazit jeho zařízení',
'show invoice' => 'Zobrazit fakturu',
'show transfer' => 'ukaž transakci',
'show transfers on this account' => 'Ukaž převody tohoto účtu',
'show user' => 'Ukaž uživatele',
freenetis/trunk/kohana/application/models/member.php
<?php
class Member_Model extends ORM {
protected $has_many = array('users');
protected $has_many = array('invoices',' users');
public function __construct($id = false)
{
freenetis/trunk/kohana/application/models/invoice_item.php
<?php
class Invoice_item_Model extends ORM {
/**
* @author Michal Kliment
* Returns ORM_Iterator of all invoices
* @param $limit_from
* @param $limit_results
* @param $order_by
* @param $order_by_direction
* @return object ORM_Iterator
*/
public function get_all_invoices($limit_from = 0, $limit_results = 50, $order_by = 'id', $order_by_direction = 'ASC')
{
return self::$db->query('SELECT i.id, m.name as supplier, invoice_nr, var_sym, con_sym, date_inv, date_due, date_vat, vat, order_nr, currency FROM invoices i
LEFT JOIN members m ON i.supplier_id = m.id
ORDER BY '.$order_by.' '.$order_by_direction);
}
}
?>
freenetis/trunk/kohana/application/models/invoice.php
<?php
class Invoice_Model extends ORM {
protected $belongs_to = array ('supplier' => 'member');
/**
* @author Michal Kliment
* Returns ORM_Iterator of all invoices
freenetis/trunk/kohana/application/controllers/invoices.php
/**
* @author Michal Kliment
* Shows one invoice
* @param $invoice_id id of inoice to show
*/
function show($invoice_id = NULL)
{
$invoice = new Invoice_Model($invoice_id);
if (!$invoice_id || !$invoice->id) url::redirect(url_lang::base().'invoices');
$supplier = new Member_Model($invoice->supplier_id);
$invoice_item_model = new Invoice_item_Model();
$invoice_items = $invoice_item_model->where('invoice_id',$invoice->id)->find_all();
// create grid
$grid = new Grid(url_lang::base().'devices', NULL, array(
'use_paginator' => false,
'use_selector' => false
));
// access control
if ($this->acl_check_new('Accounts_Controller','invoices'))
$grid->add_new_button(url_lang::base().'invoice_items/add', url_lang::lang('texts.Add new invoice item'));
$grid->order_field('id')->label(url_lang::lang('texts.Id'));
$grid->order_field('name')->label(url_lang::lang('texts.Name'));
$grid->order_field('code')->label(url_lang::lang('texts.Code'));
//$grid->order_field('supplier')->label(url_lang::lang('texts.Supplier'));
//$grid->order_field('invoice_nr')->label(url_lang::lang('texts.Invoice number'));
//$grid->order_field('var_sym')->label(url_lang::lang('texts.Variable symbol'));
//$grid->order_field('con_sym')->label(url_lang::lang('texts.Constant symbol'));
//$grid->order_field('date_inv')->label(url_lang::lang('texts.Date of issue'));
//$grid->order_field('date_due')->label(url_lang::lang('texts.Due date'));
//$grid->order_field('date_vat')->label(url_lang::lang('texts.Date vat'));
//$grid->order_field('vat')->label(url_lang::lang('texts.VAT'));
//$grid->order_field('order_nr')->label(url_lang::lang('texts.Order number'));
//$grid->order_field('currency')->label(url_lang::lang('texts.Currency'));
// access control
if ($this->acl_check_view('Accounts_Controller','invoices'))
$grid->action_field('id') ->label(url_lang::lang('texts.Show'))->url(url_lang::base().'invoices/show')->action(url_lang::lang('texts.Show'));
// access control
if ($this->acl_check_edit('Accounts_Controller','invoices'))
$grid->action_field('id') ->label(url_lang::lang('texts.Edit'))->url(url_lang::base().'invoices/edit')->action(url_lang::lang('texts.Edit'));
// access control
if ($this->acl_check_delete('Accounts_Controller','invoices'))
$grid->action_field('id') ->label(url_lang::lang('texts.Delete'))->url(url_lang::base().'invoices/delete')->action(url_lang::lang('texts.Delete'));
$grid->datasource($invoice_items);
$view = new View('template');
$view->header = new View('base/header');
$view->header->title = url_lang::lang('texts.Show invoice');
$view->header->menu = Controller::render_menu();
$view->content = new View('invoices/show');
$view->content->headline = url_lang::lang('texts.Show invoice');
$view->content->invoice = $invoice;
$view->content->supplier = $supplier;
$view->content->grid = $grid;
$view->footer = new View('base/footer');
$view->render(TRUE);
}
/**
* @author Michal Kliment
* Parses data from invoice in XML, HTML,etc. and stores it in session
*/
function import()
freenetis/trunk/kohana/application/upgrade_sql/upgrade_sql.php
$upgrade_sql[get_SVN_rev()] = array(
"UPDATE `axo` SET `name` = 'Faktury' WHERE `axo`.`id` =55 LIMIT 1;",
"INSERT INTO `axo_map` (`acl_id`, `section_value`, `value`) VALUES (38, 'Accounts_Controller', 'invoices');"
"CREATE TABLE IF NOT EXISTS `invoice_items` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`invoice_id` int(11) NOT NULL,
`name` varchar(255) COLLATE utf8_czech_ci NOT NULL,
`code` varchar(100) COLLATE utf8_czech_ci NOT NULL,
`quantity` double NOT NULL,
`author_fee` double NOT NULL,
`contractual_increase` double NOT NULL,
`service` tinyint(1) NOT NULL,
`price` double NOT NULL,
`price_vat` double NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_czech_ci AUTO_INCREMENT=1;
"
);
?>
freenetis/trunk/kohana/application/upgrade_sql/upgrade_sql_299.php
<?php
$upgrade_sql[299] = array(
"UPDATE `axo` SET `name` = 'Faktury' WHERE `axo`.`id` =55 LIMIT 1;",
"INSERT INTO `axo_map` (`acl_id`, `section_value`, `value`) VALUES (38, 'Accounts_Controller', 'invoices');"
);
?>
freenetis/trunk/kohana/application/views/invoices/show.php
<h2><?php echo $headline ?></h2>
<?php echo html::anchor(url_lang::base().'invoices/show_all', url_lang::lang('texts.Back to list of all invoices')) ?> |
<?php echo html::anchor(url_lang::base().'invoices/edit/'.$invoice->id, url_lang::lang('texts.Edit')) ?>
<br /><br />
<table class="extended" cellspacing="0">
<tr>
<th><?php echo url_lang::lang('texts.ID') ?></th>
<td><?php echo $invoice->id ?></td>
</tr>
<tr>
<th><?php echo url_lang::lang('texts.Supplier') ?></th>
<td><?php echo html::anchor(url_lang::base().'members/show/'.$supplier->id,$supplier->name) ?></td>
</tr>
<tr>
<th><?php echo url_lang::lang('texts.Invoice number') ?></th>
<td><?php echo $invoice->invoice_nr ?></td>
</tr>
<tr>
<th><?php echo url_lang::lang('texts.Variable symbol') ?></th>
<td><?php echo $invoice->var_sym ?></td>
</tr>
<tr>
<th><?php echo url_lang::lang('texts.Constant symbol') ?></th>
<td><?php echo $invoice->con_sym ?></td>
</tr>
<tr>
<th><?php echo url_lang::lang('texts.Date of issue') ?></th>
<td><?php echo $invoice->date_inv ?></td>
</tr>
<tr>
<th><?php echo url_lang::lang('texts.Due date') ?></th>
<td><?php echo $invoice->date_due ?></td>
</tr>
<tr>
<th><?php echo url_lang::lang('texts.Date vat') ?></th>
<td><?php echo $invoice->date_vat ?></td>
</tr>
<tr>
<th><?php echo url_lang::lang('texts.Vat') ?></th>
<td><?php echo ($invoice->vat) ? url_lang::lang('texts.Yes') : url_lang::lang('texts.No') ?></td>
</tr>
<tr>
<th><?php echo url_lang::lang('texts.Order number') ?></th>
<td><?php echo $invoice->order_nr ?></td>
</tr>
<tr>
<th><?php echo url_lang::lang('texts.Currency') ?></th>
<td><?php echo $invoice->currency ?></td>
</tr>
</table><br />
<h3><?php echo url_lang::lang('texts.Invoice items') ?></h3>
<?php echo $grid ?>

Také k dispozici: Unified diff