diff --git a/lib/NGCP/Panel/Controller/Reseller.pm b/lib/NGCP/Panel/Controller/Reseller.pm new file mode 100644 index 0000000000..1ea17651ba --- /dev/null +++ b/lib/NGCP/Panel/Controller/Reseller.pm @@ -0,0 +1,83 @@ +package NGCP::Panel::Controller::Reseller; +use Moose; +use namespace::autoclean; + +BEGIN { extends 'Catalyst::Controller'; } + +use NGCP::Panel::Form::Reseller; + +=head1 NAME + +NGCP::Panel::Controller::Reseller - Catalyst Controller + +=head1 DESCRIPTION + +Catalyst Controller. + +=head1 METHODS + +=cut + + +=head2 index + +=cut + +sub reseller : Path Chained('/') CaptureArgs(0) { + my ( $self, $c ) = @_; + + my $resellers = [ + {id => 1, contract_id => 1, name => 'reseller 1', status => 'active'}, + {id => 2, contract_id => 2, name => 'reseller 2', status => 'active'}, + {id => 3, contract_id => 3, name => 'reseller 3', status => 'active'}, + {id => 4, contract_id => 4, name => 'reseller 4', status => 'locked'}, + {id => 5, contract_id => 5, name => 'reseller 5', status => 'terminated'}, + {id => 6, contract_id => 6, name => 'reseller 6', status => 'active'}, + ]; + $c->stash(resellers => $resellers); + + + $c->stash(template => 'reseller.tt'); +} + + +sub edit : Chained('reseller') PathPart('edit') :Args(1) { + my ( $self, $c, $reseller_id ) = @_; + + my @reseller = grep { $_->{id} == $reseller_id } @{ $c->stash->{resellers} }; + use Data::Printer; + p @reseller; + my $form = NGCP::Panel::Form::Reseller->new; + $form->process( + posted => ($c->req->method eq 'POST'), + params => $reseller[0], + action => $c->uri_for('/reseller/save'), + ); + $c->stash(form => $form); + $c->stash(edit => $reseller[0]); +} + +sub save : Path('/reseller/save') :Args(0) { + my ( $self, $c) = @_; +} + +sub delete : Path('/reseller/delete') :Args(1) { + my ( $self, $c, $reseller_id) = @_; +} + +=head1 AUTHOR + +Andreas Granig,,, + +=head1 LICENSE + +This library is free software. You can redistribute it and/or modify +it under the same terms as Perl itself. + +=cut + +__PACKAGE__->meta->make_immutable; + +1; + +# vim: set tabstop=4 expandtab: diff --git a/lib/NGCP/Panel/Form/Reseller.pm b/lib/NGCP/Panel/Form/Reseller.pm new file mode 100644 index 0000000000..c807700682 --- /dev/null +++ b/lib/NGCP/Panel/Form/Reseller.pm @@ -0,0 +1,30 @@ +package NGCP::Panel::Form::Reseller; + +use HTML::FormHandler::Moose; +extends 'HTML::FormHandler'; +use Moose::Util::TypeConstraints; + +with 'HTML::FormHandler::Render::Table'; + +has '+widget_form' => (default => 'Table'); + +#sub build_form_tags {{ error_class => 'label label-secondary'}} + +has_field 'id' => ( + type 'NonEditable', +); + +has_field 'name' => ( + type 'Text', +); + +has_field 'contract_id' => ( + type 'Integer', +); + +has_field 'status' => ( + type 'Text', +); + +1; +# vim: set tabstop=4 expandtab: diff --git a/share/templates/reseller.tt b/share/templates/reseller.tt new file mode 100644 index 0000000000..8dfe823261 --- /dev/null +++ b/share/templates/reseller.tt @@ -0,0 +1,44 @@ +[% META title = 'Resellers' -%] +
| # | +Name | +Contract # | +Status | +
|---|---|---|---|
| [% r.id %] | +[% r.name %] | +[% r.contract_id %] | ++ [% r.status %] + [% UNLESS edit.defined -%] + + [% END -%] + | + [% END -%] +