From 5b5dbec0272c91697acf33c4842ee9d63f041f22 Mon Sep 17 00:00:00 2001 From: Moritz Bunkus Date: Tue, 29 Jan 2013 11:27:43 +0100 Subject: [PATCH] =?utf8?q?Presenter-Module=20f=C3=BCr=20Listen=20von=20Ver?= =?utf8?q?kaufs-/Einkaufsobjekte?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- SL/Presenter/CustomerVendor.pm | 118 +++++ SL/Presenter/DeliveryOrder.pm | 122 +++++ SL/Presenter/Invoice.pm | 188 ++++++++ SL/Presenter/Order.pm | 190 ++++++++ SL/Presenter/Project.pm | 123 +++++ SL/Presenter/Record.pm | 456 ++++++++++++++++++ locale/de/all | 9 +- .../presenter/record/empty_record_list.html | 2 + .../presenter/record/record_list.html | 28 ++ 9 files changed, 1235 insertions(+), 1 deletion(-) create mode 100644 SL/Presenter/CustomerVendor.pm create mode 100644 SL/Presenter/DeliveryOrder.pm create mode 100644 SL/Presenter/Invoice.pm create mode 100644 SL/Presenter/Order.pm create mode 100644 SL/Presenter/Project.pm create mode 100644 SL/Presenter/Record.pm create mode 100644 templates/webpages/presenter/record/empty_record_list.html create mode 100644 templates/webpages/presenter/record/record_list.html diff --git a/SL/Presenter/CustomerVendor.pm b/SL/Presenter/CustomerVendor.pm new file mode 100644 index 000000000..077c376c8 --- /dev/null +++ b/SL/Presenter/CustomerVendor.pm @@ -0,0 +1,118 @@ +package SL::Presenter::CustomerVendor; + +use strict; + +use parent qw(Exporter); + +use Exporter qw(import); +our @EXPORT = qw(customer vendor); + +use Carp; + +sub customer { + my ($self, $customer, $type, %params) = @_; + return _customer_vendor($self, $customer, 'customer', %params); +} + +sub vendor { + my ($self, $vendor, $type, %params) = @_; + return _customer_vendor($self, $vendor, 'vendor', %params); +} + +sub _customer_vendor { + my ($self, $cv, $type, %params) = @_; + + $params{display} ||= 'inline'; + + croak "Unknown display type '$params{display}'" unless $params{display} =~ m/^(?:inline|table-cell)$/; + + my $text = join '', ( + $params{no_link} ? '' : '', + $self->escape($cv->name), + $params{no_link} ? '' : '', + ); + return $self->escaped_text($text); +} + +1; + +__END__ + +=pod + +=encoding utf8 + +=head1 NAME + +SL::Presenter::CustomerVendor - Presenter module for customer and +vendor Rose::DB objects + +=head1 SYNOPSIS + + # Customers: + my $customer = SL::DB::Manager::Customer->get_first; + my $html = SL::Presenter->get->customer($customer, display => 'inline'); + + # Vendors: + my $vendor = SL::DB::Manager::Vendor->get_first; + my $html = SL::Presenter->get->vendor($customer, display => 'inline'); + +=head1 FUNCTIONS + +=over 4 + +=item C + +Returns a rendered version (actually an instance of +L) of the customer object C<$object>. + +C<%params> can include: + +=over 2 + +=item * display + +Either C (the default) or C. At the moment both +representations are identical and produce the customer's name linked +to the corresponding 'edit' action. + +=item * no_link + +If falsish (the default) then the customer's name will be linked to +the "edit customer" dialog from the master data menu. + +=back + +=item C + +Returns a rendered version (actually an instance of +L) of the vendor object C<$object>. + +C<%params> can include: + +=over 2 + +=item * display + +Either C (the default) or C. At the moment both +representations are identical and produce the vendor's name linked +to the corresponding 'edit' action. + +=item * no_link + +If falsish (the default) then the vendor's name will be linked to +the "edit vendor" dialog from the master data menu. + +=back + +=back + +=head1 BUGS + +Nothing here yet. + +=head1 AUTHOR + +Moritz Bunkus Em.bunkus@linet-services.deE + +=cut diff --git a/SL/Presenter/DeliveryOrder.pm b/SL/Presenter/DeliveryOrder.pm new file mode 100644 index 000000000..1abc83546 --- /dev/null +++ b/SL/Presenter/DeliveryOrder.pm @@ -0,0 +1,122 @@ +package SL::Presenter::DeliveryOrder; + +use strict; + +use parent qw(Exporter); + +use Exporter qw(import); +our @EXPORT = qw(sales_delivery_order purchase_delivery_order); + +use Carp; + +sub sales_delivery_order { + my ($self, $delivery_order, %params) = @_; + + return _do_record($self, $delivery_order, 'sales_delivery_order', %params); +} + +sub purchase_delivery_order { + my ($self, $delivery_order, %params) = @_; + + return _do_record($self, $delivery_order, 'purchase_delivery_order', %params); +} + +sub _do_record { + my ($self, $delivery_order, $type, %params) = @_; + + $params{display} ||= 'inline'; + + croak "Unknown display type '$params{display}'" unless $params{display} =~ m/^(?:inline|table-cell)$/; + + my $text = join '', ( + $params{no_link} ? '' : '', + $self->escape($delivery_order->donumber), + $params{no_link} ? '' : '', + ); + return $self->escaped_text($text); +} + +1; + +__END__ + +=pod + +=encoding utf8 + +=head1 NAME + +SL::Presenter::DeliveryOrder - Presenter module for Rose::DB objects +for sales and purchase delivery orders + +=head1 SYNOPSIS + + # Sales delivery orders: + my $object = SL::DB::Manager::DeliveryOrder->get_first(where => [ is_sales => 1 ]); + my $html = SL::Presenter->get->sales_delivery_order($object, display => 'inline'); + + # Purchase delivery orders: + my $object = SL::DB::Manager::DeliveryOrder->get_first(where => [ or => [ is_sales => undef, is_sales => 0 ]]); + my $html = SL::Presenter->get->purchase_delivery_order($object, display => 'inline'); + +=head1 FUNCTIONS + +=over 4 + +=item C + +Returns a rendered version (actually an instance of +L) of the sales delivery order object +C<$object>. + +C<%params> can include: + +=over 2 + +=item * display + +Either C (the default) or C. At the moment both +representations are identical and produce the objects's delivery +order number linked to the corresponding 'edit' action. + +=item * no_link + +If falsish (the default) then the delivery order number will be linked +to the "edit delivery order" dialog from the sales menu. + +=back + +=item C + +Returns a rendered version (actually an instance of +L) of the purchase delivery order object +C<$object>. + +C<%params> can include: + +=over 2 + +=item * display + +Either C (the default) or C. At the moment both +representations are identical and produce the objects's delivery +order number linked to the corresponding 'edit' action. + +=item * no_link + +If falsish (the default) then the delivery order number will be linked +to the "edit delivery order" dialog from the purchase menu. + +=back + +=back + +=head1 BUGS + +Nothing here yet. + +=head1 AUTHOR + +Moritz Bunkus Em.bunkus@linet-services.deE + +=cut diff --git a/SL/Presenter/Invoice.pm b/SL/Presenter/Invoice.pm new file mode 100644 index 000000000..f1aaf7f6f --- /dev/null +++ b/SL/Presenter/Invoice.pm @@ -0,0 +1,188 @@ +package SL::Presenter::Invoice; + +use strict; + +use parent qw(Exporter); + +use Exporter qw(import); +our @EXPORT = qw(sales_invoice ar_transaction purchase_invoice ap_transaction); + +use Carp; + +sub sales_invoice { + my ($self, $invoice, %params) = @_; + + return _is_ir_record($self, $invoice, 'is', %params); +} + +sub ar_transaction { + my ($self, $invoice, %params) = @_; + + return _is_ir_record($self, $invoice, 'ar', %params); +} + +sub purchase_invoice { + my ($self, $invoice, %params) = @_; + + return _is_ir_record($self, $invoice, 'is', %params); +} + +sub ap_transaction { + my ($self, $invoice, %params) = @_; + + return _is_ir_record($self, $invoice, 'ap', %params); +} + +sub _is_ir_record { + my ($self, $invoice, $controller, %params) = @_; + + $params{display} ||= 'inline'; + + croak "Unknown display type '$params{display}'" unless $params{display} =~ m/^(?:inline|table-cell)$/; + + my $text = join '', ( + $params{no_link} ? '' : '', + $self->escape($invoice->invnumber), + $params{no_link} ? '' : '', + ); + return $self->escaped_text($text); +} + +1; + +__END__ + +=pod + +=encoding utf8 + +=head1 NAME + +SL::Presenter::Invoice - Presenter module for sales invoice, AR +transaction, purchase invoice and AP transaction Rose::DB objects + +=head1 SYNOPSIS + + # Sales invoices: + my $object = SL::DB::Manager::Invoice->get_first(where => [ invoice => 1 ]); + my $html = SL::Presenter->get->sales_invoice($object, display => 'inline'); + + # AR transactions: + my $object = SL::DB::Manager::Invoice->get_first(where => [ or => [ invoice => undef, invoice => 0 ]]); + my $html = SL::Presenter->get->ar_transaction($object, display => 'inline'); + + # Purchase invoices: + my $object = SL::DB::Manager::PurchaseInvoice->get_first(where => [ invoice => 1 ]); + my $html = SL::Presenter->get->purchase_invoice($object, display => 'inline'); + + # AP transactions: + my $object = SL::DB::Manager::PurchaseInvoice->get_first(where => [ or => [ invoice => undef, invoice => 0 ]]); + my $html = SL::Presenter->get->ar_transaction($object, display => 'inline'); + +=head1 FUNCTIONS + +=over 4 + +=item C + +Returns a rendered version (actually an instance of +L) of the sales invoice object C<$object> +. + +C<%params> can include: + +=over 2 + +=item * display + +Either C (the default) or C. At the moment both +representations are identical and produce the invoice number linked +to the corresponding 'edit' action. + +=item * no_link + +If falsish (the default) then the invoice number will be linked to the +"edit invoice" dialog from the sales menu. + +=back + +=item C + +Returns a rendered version (actually an instance of +L) of the AR transaction object C<$object> +. + +C<%params> can include: + +=over 2 + +=item * display + +Either C (the default) or C. At the moment both +representations are identical and produce the invoice number linked +to the corresponding 'edit' action. + +=item * no_link + +If falsish (the default) then the invoice number will be linked to the +"edit invoice" dialog from the general ledger menu. + +=back + +=item C + +Returns a rendered version (actually an instance of +L) of the purchase invoice object +C<$object>. + +C<%params> can include: + +=over 2 + +=item * display + +Either C (the default) or C. At the moment both +representations are identical and produce the invoice number name +linked to the corresponding 'edit' action. + +=item * no_link + +If falsish (the default) then the invoice number will be linked to +the "edit invoice" dialog from the purchase menu. + +=back + +=item C + +Returns a rendered version (actually an instance of +L) of the AP transaction object C<$object> +. + +C<%params> can include: + +=over 2 + +=item * display + +Either C (the default) or C. At the moment both +representations are identical and produce the invoice number linked +to the corresponding 'edit' action. + +=item * no_link + +If falsish (the default) then the invoice number will be linked to the +"edit invoice" dialog from the general ledger menu. + +=back + +=back + +=head1 BUGS + +Nothing here yet. + +=head1 AUTHOR + +Moritz Bunkus Em.bunkus@linet-services.deE + +=cut diff --git a/SL/Presenter/Order.pm b/SL/Presenter/Order.pm new file mode 100644 index 000000000..19d8483ec --- /dev/null +++ b/SL/Presenter/Order.pm @@ -0,0 +1,190 @@ +package SL::Presenter::Order; + +use strict; + +use parent qw(Exporter); + +use Exporter qw(import); +our @EXPORT = qw(sales_quotation sales_order request_quotation purchase_order); + +use Carp; + +sub sales_quotation { + my ($self, $order, %params) = @_; + + return _oe_record($self, $order, 'sales_quotation', %params); +} + +sub sales_order { + my ($self, $order, %params) = @_; + + return _oe_record($self, $order, 'sales_order', %params); +} + +sub request_quotation { + my ($self, $order, %params) = @_; + + return _oe_record($self, $order, 'request_quotation', %params); +} + +sub purchase_order { + my ($self, $order, %params) = @_; + + return _oe_record($self, $order, 'purchase_order', %params); +} + +sub _oe_record { + my ($self, $order, $type, %params) = @_; + + $params{display} ||= 'inline'; + + croak "Unknown display type '$params{display}'" unless $params{display} =~ m/^(?:inline|table-cell)$/; + + my $number_method = $order->quotation ? 'quonumber' : 'ordnumber'; + + my $text = join '', ( + $params{no_link} ? '' : '', + $self->escape($order->$number_method), + $params{no_link} ? '' : '', + ); + return $self->escaped_text($text); +} + +1; + + +__END__ + +=pod + +=encoding utf8 + +=head1 NAME + +SL::Presenter::Order - Presenter module for Rose::DB objects for sales +quotations, sales orders, requests for quotations and purchase orders + +=head1 SYNOPSIS + + # Sales quotations: + my $object = SL::DB::Manager::Order->get_first(where => [ SL::DB::Manager::Order->type_filter('sales_quotation') ]); + my $html = SL::Presenter->get->sales_quotation($object, display => 'inline'); + + # Sales orders: + my $object = SL::DB::Manager::Order->get_first(where => [ SL::DB::Manager::Order->type_filter('sales_order') ]); + my $html = SL::Presenter->get->sales_order($object, display => 'inline'); + + # Requests for quotations: + my $object = SL::DB::Manager::Order->get_first(where => [ SL::DB::Manager::Order->type_filter('request_quotation') ]); + my $html = SL::Presenter->get->request_quotation($object, display => 'inline'); + + # Purchase orders: + my $object = SL::DB::Manager::Order->get_first(where => [ SL::DB::Manager::Order->type_filter('purchase_order') ]); + my $html = SL::Presenter->get->purchase_order($object, display => 'inline'); + +=head1 FUNCTIONS + +=over 4 + +=item C + +Returns a rendered version (actually an instance of +L) of the sales quotation object +C<$object>. + +C<%params> can include: + +=over 2 + +=item * display + +Either C (the default) or C. At the moment both +representations are identical and produce the objects's +quotation number linked to the corresponding 'edit' action. + +=item * no_link + +If falsish (the default) then the order number will be linked to the +"edit quotation" dialog from the sales menu. + +=back + +=item C + +Returns a rendered version (actually an instance of +L) of the sales order object C<$object>. + +C<%params> can include: + +=over 2 + +=item * display + +Either C (the default) or C. At the moment both +representations are identical and produce the objects's +order number linked to the corresponding 'edit' action. + +=item * no_link + +If falsish (the default) then the order number will be linked +to the "edit order" dialog from the sales menu. + +=back + +=item C + +Returns a rendered version (actually an instance of +L) of the request for quotation object +C<$object>. + +C<%params> can include: + +=over 2 + +=item * display + +Either C (the default) or C. At the moment both +representations are identical and produce the objects's +quotation number linked to the corresponding 'edit' action. + +=item * no_link + +If falsish (the default) then the order number will be linked to the +"edit request for quotation" dialog from the purchase menu. + +=back + +=item C + +Returns a rendered version (actually an instance of +L) of the purchase order object +C<$object>. + +C<%params> can include: + +=over 2 + +=item * display + +Either C (the default) or C. At the moment both +representations are identical and produce the objects's +order number linked to the corresponding 'edit' action. + +=item * no_link + +If falsish (the default) then the order number will be linked +to the "edit order" dialog from the purchase menu. + +=back + +=back + +=head1 BUGS + +Nothing here yet. + +=head1 AUTHOR + +Moritz Bunkus Em.bunkus@linet-services.deE + +=cut diff --git a/SL/Presenter/Project.pm b/SL/Presenter/Project.pm new file mode 100644 index 000000000..650995c7f --- /dev/null +++ b/SL/Presenter/Project.pm @@ -0,0 +1,123 @@ +package SL::Presenter::Project; + +use strict; + +use parent qw(Exporter); + +use Exporter qw(import); +our @EXPORT = qw(project); + +use Carp; + +sub project { + my ($self, $project, %params) = @_; + + return '' unless $project; + + $params{display} ||= 'inline'; + + croak "Unknown display type '$params{display}'" unless $params{display} =~ m/^(?:inline|table-cell)$/; + + $params{style} ||= 'both'; + my $description; + + if ($params{style} =~ m/number/) { + $description = $project->projectnumber; + + } elsif ($params{style} =~ m/description/) { + $description = $project->description; + + } else { + $description = $project->projectnumber; + if ($project->description && do { my $desc = quotemeta $project->description; $project->projectnumber !~ m/$desc/ }) { + $description .= ' (' . $project->description . ')'; + } + } + + my $text = join '', ( + $params{no_link} ? '' : '', + $self->escape($description), + $params{no_link} ? '' : '', + ); + return $self->escaped_text($text); +} + +1; + +__END__ + +=pod + +=encoding utf8 + +=head1 NAME + +SL::Presenter::Project - Presenter module for project Rose::DB objects + +=head1 SYNOPSIS + + my $project = SL::DB::Manager::Project->get_first; + my $html = SL::Presenter->get->project($project, display => 'inline'); + +=head1 FUNCTIONS + +=over 4 + +=item C + +Returns a rendered version (actually an instance of +L) of the project object C<$customer>. + +C<%params> can include: + +=over 2 + +=item * display + +Either C (the default) or C. At the moment both +representations are identical and produce the project's description +(controlled by the C