Bigtop
view release on metacpan or search on metacpan
examples/Billing-Finished/lib/Bigtop/Example/Billing/LineItem.pm view on Meta::CPAN
package Bigtop::Example::Billing::LineItem;
use strict;
use base 'Bigtop::Example::Billing::GEN::LineItem';
use Gantry::Plugins::AutoCRUD qw(
do_add
do_edit
do_delete
form_name
);
use Bigtop::Example::Billing::Model;
use Bigtop::Example::Billing::Model::line_item qw( $LINE_ITEM );
use Bigtop::Example::Billing::Model::invoice qw( $INVOICE );
sub schema_base_class { return 'Bigtop::Example::Billing::Model'; }
use Gantry::Plugins::DBIxClassConn qw( get_schema );
use Gantry::Plugins::Calendar qw(
do_calendar_month
calendar_month_js
);
#-----------------------------------------------------------------
# $self->do_main( [ $invoice_id ] )
#-----------------------------------------------------------------
sub do_main {
my ( $self, $invoice_id ) = @_;
my $title = 'Line Items';
my $only_one_invoice = 0;
if ( defined $invoice_id ) {
$only_one_invoice = 1;
my $invoice = $INVOICE->gfind( $self, $invoice_id );
$title .= ' for Invoice ' . $invoice->foreign_display();
}
$self->stash->view->template( 'results.tt' );
$self->stash->view->title( $title );
my $retval = {
headings => [
'Name',
'Due Date',
'Invoice',
],
header_options => [
{
text => 'Add',
link => $self->location() . "/add",
},
],
};
my $schema = $self->get_schema();
my @rows = $LINE_ITEM->get_listing( { schema => $schema } );
ROW:
foreach my $row ( @rows ) {
my $id = $row->id;
next ROW if ( $only_one_invoice and $id != $invoice_id );
push(
@{ $retval->{rows} }, {
data => [
$row->name,
$row->due_date,
$row->invoice->foreign_display(),
],
options => [
{
text => 'Edit',
link => $self->location() . "/edit/$id",
},
{
text => 'Delete',
link => $self->location() . "/delete/$id",
( run in 0.790 second using v1.01-cache-2.11-cpan-e1769b4cff6 )