MT#5879 Commit relative to db-cshema commit hash 7246a8d414246d5b07f5957a195dc3c9ffd90272 "Add name column for template. Preparing for "fixed" template, where only position of rows and their amount can be modified. And resources, which may connect one template with some different css."

agranig/subprof
Irina Peshinskaya 11 years ago
parent 8ac4c7b131
commit 1421bf7680

@ -38,15 +38,37 @@ __PACKAGE__->add_columns(
{ data_type => "mediumblob", is_nullable => 1 },
"base64_previewed",
{ data_type => "mediumblob", is_nullable => 1 },
"name",
{ data_type => "varchar", is_nullable => 0, size => 255 },
"x_title",
{ data_type => "mediumint", default_value => 0, is_nullable => 0 },
"y_title",
{ data_type => "mediumint", default_value => 0, is_nullable => 0 },
"rows_title",
{ data_type => "mediumint", default_value => 0, is_nullable => 0 },
"x_mid",
{ data_type => "mediumint", default_value => 0, is_nullable => 0 },
"y_mid",
{ data_type => "mediumint", default_value => 0, is_nullable => 0 },
"rows_mid",
{ data_type => "mediumint", default_value => 0, is_nullable => 0 },
"x_last",
{ data_type => "mediumint", default_value => 0, is_nullable => 0 },
"y_last",
{ data_type => "mediumint", default_value => 0, is_nullable => 0 },
"rows_last",
{ data_type => "mediumint", default_value => 0, is_nullable => 0 },
);
__PACKAGE__->set_primary_key("id");
__PACKAGE__->add_unique_constraint(
"invoice_template_reseller_active_UNIQUE",
["reseller_id", "is_active"],
__PACKAGE__->has_many(
"invoice_template_resources",
"NGCP::Schema::billing::Result::invoice_template_resource",
{ "foreign.invoice_template_id" => "self.id" },
{ cascade_copy => 0, cascade_delete => 0 },
);

@ -0,0 +1,97 @@
package NGCP::Schema::Result::invoice_template_resource;
use Scalar::Util qw(blessed);
use parent 'DBIx::Class::Core';
our $VERSION = '2.010';
__PACKAGE__->load_components("InflateColumn::DateTime", "Helper::Row::ToJSON");
__PACKAGE__->table("invoice_template_resource");
__PACKAGE__->add_columns(
"invoice_template_id",
{
data_type => "integer",
extra => { unsigned => 1 },
is_foreign_key => 1,
is_nullable => 0,
},
"is_active",
{ data_type => "tinyint", default_value => 0, is_nullable => 0 },
"type",
{ data_type => "enum", extra => { list => ["css"] }, is_nullable => 1 },
"base64",
{ data_type => "mediumblob", is_nullable => 1 },
);
__PACKAGE__->belongs_to(
"invoice_template",
"NGCP::Schema::Result::invoice_template",
{ id => "invoice_template_id" },
{ is_deferrable => 1, on_delete => "CASCADE", on_update => "CASCADE" },
);
sub TO_JSON {
my ($self) = @_;
return {
map { blessed($_) && $_->isa('DateTime') ? $_->datetime : $_ } %{ $self->next::method }
};
}
1;
__END__
=encoding UTF-8
=head1 NAME
NGCP::Schema::Result::invoice_template_resource
=head1 COMPONENTS LOADED
=over 4
=item * L<DBIx::Class::InflateColumn::DateTime>
=item * L<DBIx::Class::Helper::Row::ToJSON>
=back
=head1 TABLE: C<invoice_template_resource>
=head1 ACCESSORS
=head2 invoice_template_id
data_type: 'integer'
extra: {unsigned => 1}
is_foreign_key: 1
is_nullable: 0
=head2 is_active
data_type: 'tinyint'
default_value: 0
is_nullable: 0
=head2 type
data_type: 'enum'
extra: {list => ["css"]}
is_nullable: 1
=head2 base64
data_type: 'mediumblob'
is_nullable: 1
=head1 RELATIONS
=head2 invoice_template
Type: belongs_to
Related object: L<NGCP::Schema::Result::invoice_template>
=cut
Loading…
Cancel
Save