From 11d2ae5772060a0426dc8722dfe69bf2c6aeceea Mon Sep 17 00:00:00 2001 From: Werner Hahn Date: Fri, 22 Sep 2017 02:32:53 +0200 Subject: [PATCH] WebshopApi: ShopOrder Controller --- SL/Controller/ShopOrder.pm | 407 ++++++++++++++++++ SL/DB/Helper/LinkedRecords.pm | 2 + js/kivi.ShopOrder.js | 35 ++ templates/webpages/shop_order/_filter.html | 38 ++ .../webpages/shop_order/_transfer_status.html | 61 +++ templates/webpages/shop_order/list.html | 204 +++++++++ templates/webpages/shop_order/show.html | 208 +++++++++ 7 files changed, 955 insertions(+) create mode 100644 SL/Controller/ShopOrder.pm create mode 100644 js/kivi.ShopOrder.js create mode 100644 templates/webpages/shop_order/_filter.html create mode 100644 templates/webpages/shop_order/_transfer_status.html create mode 100644 templates/webpages/shop_order/list.html create mode 100644 templates/webpages/shop_order/show.html diff --git a/SL/Controller/ShopOrder.pm b/SL/Controller/ShopOrder.pm new file mode 100644 index 000000000..e8d804f27 --- /dev/null +++ b/SL/Controller/ShopOrder.pm @@ -0,0 +1,407 @@ +package SL::Controller::ShopOrder; + +use strict; + +use parent qw(SL::Controller::Base); + +use SL::BackgroundJob::ShopOrderMassTransfer; +use SL::System::TaskServer; +use SL::DB::ShopOrder; +use SL::DB::ShopOrderItem; +use SL::DB::Shop; +use SL::DB::History; +use SL::DBUtils; +use SL::Shop; +use SL::Presenter; +use SL::Helper::Flash; +use SL::Locale::String; +use SL::Controller::Helper::ParseFilter; +use Rose::Object::MakeMethods::Generic +( + 'scalar --get_set_init' => [ qw(shop_order shops transferred js) ], +); + +__PACKAGE__->run_before('check_auth'); +__PACKAGE__->run_before('setup'); + +use Data::Dumper; + +sub action_get_orders { + my ( $self ) = @_; + my $orders_fetched; + my $new_orders; + my %new_order; + my $active_shops = SL::DB::Manager::Shop->get_all(query => [ obsolete => 0 ]); + foreach my $shop_config ( @{ $active_shops } ) { + my $shop = SL::Shop->new( config => $shop_config ); + my $connect = $shop->check_connectivity; + + if( !$connect->{success} ){ + %new_order = ( + number_of_orders => $connect->{data}->{version}, + shop_id => $shop->config->description, + error => 1, + ); + $new_orders = \%new_order; + }else{ + $new_orders = $shop->connector->get_new_orders; + } + push @{ $orders_fetched }, $new_orders ; + } + + foreach my $shop_fetched(@{ $orders_fetched }) { + if($shop_fetched->{error}){ + flash_later('error', t8('From shop "#1" : #2 ', $shop_fetched->{shop_id}, $shop_fetched->{number_of_orders},)); + }else{ + flash_later('info', t8('From shop #1 : #2 shoporders have been fetched.', $shop_fetched->{shop_id}, $shop_fetched->{number_of_orders},)); + } + } + $self->redirect_to(controller => "ShopOrder", action => 'list'); +} + +sub action_list { + my ( $self ) = @_; + + my %filter = ($::form->{filter} ? parse_filter($::form->{filter}) : query => [ transferred => 0, obsolete => 0 ]); + my $transferred = $::form->{filter}->{transferred_eq_ignore_empty} ne '' ? $::form->{filter}->{transferred_eq_ignore_empty} : ''; + my $sort_by = $::form->{sort_by} ? $::form->{sort_by} : 'order_date'; + $sort_by .=$::form->{sort_dir} ? ' DESC' : ' ASC'; + my $shop_orders = SL::DB::Manager::ShopOrder->get_all( %filter, sort_by => $sort_by, + with_objects => ['shop_order_items', 'kivi_customer', 'shop'], + ); + + foreach my $shop_order(@{ $shop_orders }){ + + my $open_invoices = SL::DB::Manager::Invoice->get_all_count( + query => [customer_id => $shop_order->{kivi_customer_id}, + paid => {lt_sql => 'amount'}, + ], + ); + $shop_order->{open_invoices} = $open_invoices; + } + $self->_setup_list_action_bar; + $self->render('shop_order/list', + title => t8('ShopOrders'), + SHOPORDERS => $shop_orders, + TOOK => $transferred, + ); +} + +sub action_show { + my ( $self ) = @_; + my $id = $::form->{id} || {}; + my $shop_order = SL::DB::ShopOrder->new( id => $id )->load( with => ['kivi_customer'] ); + die "can't find shoporder with id $id" unless $shop_order; + + my $proposals = $shop_order->check_for_existing_customers; + + $self->render('shop_order/show', + title => t8('Shoporder'), + IMPORT => $shop_order, + PROPOSALS => $proposals, + ); + +} + +sub action_delete_order { + my ( $self ) = @_; + + $self->shop_order->obsolete(1); + $self->shop_order->save; + $self->redirect_to(controller => "ShopOrder", action => 'list', filter => { 'transferred:eq_ignore_empty' => 0 }); +} + +sub action_undelete_order { + my ( $self ) = @_; + + $self->shop_order->obsolete(0); + $self->shop_order->save; + $self->redirect_to(controller => "ShopOrder", action => 'show', id => $self->shop_order->id); +} + +sub action_transfer { + my ( $self ) = @_; + + my $customer = SL::DB::Manager::Customer->find_by(id => $::form->{customer}); + die "Can't find customer" unless $customer; + my $employee = SL::DB::Manager::Employee->current; + die "Can't find employee" unless $employee; + + die "Can't load shop_order form form->import_id" unless $self->shop_order; + my $order = $self->shop_order->convert_to_sales_order(customer => $customer, employee => $employee); + + if ($order->{error}){ + flash_later('error',@{$order->{errors}}); + $self->redirect_to(controller => "ShopOrder", action => 'show', id => $self->shop_order->id); + }else{ + $order->db->with_transaction( sub { + $order->calculate_prices_and_taxes; + $order->save; + + my $snumbers = "ordernumber_" . $order->ordnumber; + SL::DB::History->new( + trans_id => $order->id, + snumbers => $snumbers, + employee_id => SL::DB::Manager::Employee->current->id, + addition => 'SAVED', + what_done => 'Shopimport -> Order', + )->save(); + foreach my $item(@{ $order->orderitems }){ + $item->parse_custom_variable_values->save; + $item->{custom_variables} = \@{ $item->cvars_by_config }; + $item->save; + } + + $self->shop_order->transferred(1); + $self->shop_order->transfer_date(DateTime->now_local); + $self->shop_order->save; + $self->shop_order->link_to_record($order); + }) || die $order->db->error; + $self->redirect_to(controller => "oe.pl", action => 'edit', type => 'sales_order', vc => 'customer', id => $order->id); + } +} + +sub action_mass_transfer { + my ($self) = @_; + my @shop_orders = @{ $::form->{id} || [] }; + + my $job = SL::DB::BackgroundJob->new( + type => 'once', + active => 1, + package_name => 'ShopOrderMassTransfer', + )->set_data( + shop_order_record_ids => [ @shop_orders ], + num_order_created => 0, + num_delivery_order_created => 0, + status => SL::BackgroundJob::ShopOrderMassTransfer->WAITING_FOR_EXECUTION(), + conversion_errors => [ ], + )->update_next_run_at; + + SL::System::TaskServer->new->wake_up; + + my $html = $self->render('shop_order/_transfer_status', { output => 0 }, job => $job); + + $self->js + ->html('#status_mass_transfer', $html) + ->run('kivi.ShopOrder.massTransferStarted') + ->render; +} + +sub action_transfer_status { + my ($self) = @_; + my $job = SL::DB::BackgroundJob->new(id => $::form->{job_id})->load; + my $html = $self->render('shop_order/_transfer_status', { output => 0 }, job => $job); + + $self->js->html('#status_mass_transfer', $html); + $self->js->run('kivi.ShopOrder.massTransferFinished') if $job->data_as_hash->{status} == SL::BackgroundJob::ShopOrderMassTransfer->DONE(); + $self->js->render; + +} + +sub action_apply_customer { + my ( $self, %params ) = @_; + my $shop = SL::DB::Manager::Shop->find_by( id => $self->shop_order->shop_id ); + my $what = $::form->{create_customer}; # new from billing, customer or delivery address + my %address = ( 'name' => $::form->{$what.'_name'}, + 'department_1' => $::form->{$what.'_company'}, + 'department_2' => $::form->{$what.'_department'}, + 'street' => $::form->{$what.'_street'}, + 'zipcode' => $::form->{$what.'_zipcode'}, + 'city' => $::form->{$what.'_city'}, + 'email' => $::form->{$what.'_email'}, + 'country' => $::form->{$what.'_country'}, + 'phone' => $::form->{$what.'_phone'}, + 'email' => $::form->{$what.'_email'}, + 'greeting' => $::form->{$what.'_greeting'}, + 'taxincluded_checked' => $shop->pricetype eq "brutto" ? 1 : 0, + 'taxincluded' => $shop->pricetype eq "brutto" ? 1 : 0, + 'pricegroup_id' => (split '\/',$shop->price_source)[0] eq "pricegroup" ? (split '\/',$shop->price_source)[1] : undef, + 'taxzone_id' => $shop->taxzone_id, + 'currency' => $::instance_conf->get_currency_id, + #'payment_id' => 7345,# TODO hardcoded + ); + my $customer; + if($::form->{cv_id}){ + $customer = SL::DB::Customer->new(id => $::form->{cv_id})->load; + $customer->assign_attributes(%address); + $customer->save; + }else{ + $customer = SL::DB::Customer->new(%address); + $customer->save; + } + my $snumbers = "customernumber_" . $customer->customernumber; + SL::DB::History->new( + trans_id => $customer->id, + snumbers => $snumbers, + employee_id => SL::DB::Manager::Employee->current->id, + addition => 'SAVED', + what_done => 'Shopimport', + )->save(); + + $self->redirect_to(action => 'show', id => $::form->{import_id}); +} + +sub setup { + my ($self) = @_; + $::auth->assert('shop_part_edit'); + $::request->layout->use_javascript("${_}.js") for qw(kivi.ShopOrder); +} + +sub check_auth { + $::auth->assert('shop_part_edit'); +} +# +# Helper +# + +sub init_shop_order { + my ( $self ) = @_; + return SL::DB::ShopOrder->new(id => $::form->{import_id})->load if $::form->{import_id}; +} + +sub init_transferred { + [ { title => t8("all"), value => '' }, + { title => t8("transferred"), value => 1 }, + { title => t8("not transferred"), value => 0 }, ] +} + +sub init_shops { + SL::DB::Shop->shops_dd; +} + +sub _setup_list_action_bar { + my ($self) = @_; + + for my $bar ($::request->layout->get('actionbar')) { + $bar->add( + action => [ + t8('Search'), + submit => [ '#shoporders', { action => "ShopOrder/list" } ], + ], + link => [ + t8('Shoporders'), + link => [ $self->url_for(action => 'get_orders') ], + tooltip => t8('New shop orders'), + ], + 'separator', + action => [ + t8('Execute'), + call => [ 'kivi.ShopOrder.setup', id => "mass_transfer" ], + tooltip => t8('Transfer all marked'), + ], + ); + } +} + +1; + +__END__ + +=encoding utf-8 + +=head1 NAME + +SL::Controller::ShopOrder - Shoporder CRUD Controller + +=head1 DESCRIPTION + +Fetches the shoporders and transfers them to orders. + +Relations for shoporders + +=over 2 + +=item shop_order_items + +=item shops + +=item shop_parts + +=back + +=head1 URL ACTIONS + +=over 4 + +=item C + +Fetches the shoporders with the shopconnector class + +=item C + +List the shoporders by different filters. +From the List you can transfer shoporders into orders in batch where it is possible or one by one. + +=item C + +Shows one order. From here you can apply/change/select customer data and transfer the shoporder to an order. + +=item C + +Marks the shoporder as obsolete. It's for shoporders you don't want to transfer. + +=item C + +Marks the shoporder obsolete = false + +=item C + +Transfers one shoporder to an order. + +=item C + +Applys a new customer from the shoporder. + +=back + +=head1 TASKSERVER ACTIONS + +=over 4 + +=item C + +Transfers more shoporders by backgroundjob called from the taskserver to orders. + +=item C + +Shows the backgroundjobdata for the popup status window + +=back + +=head1 SETUP + +=over 4 + +=item C + +=back + +=head1 INITS + +=over 4 + +=item C + +=item C + +Transferstatuses for the filter dropdown + +=item C + +Filter dropdown Shops + +=back + +=head1 TODO + +Implements different payments, pricesources and pricegroups. Till now not needed. + +=head1 BUGS + +None yet. :) + +=head1 AUTHOR + +W. Hahn Ewh@futureworldsearch.netE + +=cut diff --git a/SL/DB/Helper/LinkedRecords.pm b/SL/DB/Helper/LinkedRecords.pm index 5ad49257c..bf91e6a7b 100644 --- a/SL/DB/Helper/LinkedRecords.pm +++ b/SL/DB/Helper/LinkedRecords.pm @@ -312,6 +312,7 @@ sub sort_linked_records { 'SL::DB::PurchaseInvoice' => sub { $_[0]->invnumber }, 'SL::DB::RequirementSpec' => sub { $_[0]->id }, 'SL::DB::Letter' => sub { $_[0]->letternumber }, + 'SL::DB::ShopOrder' => sub { $_[0]->shop_ordernumber }, UNKNOWN => '9999999999999999', ); my $number_xtor = sub { @@ -341,6 +342,7 @@ sub sort_linked_records { 'SL::DB::PurchaseInvoice' => 150, 'SL::DB::PurchaseInvoice' => 150, 'SL::DB::Letter' => 200, + 'SL::DB::ShopOrder' => 250, UNKNOWN => 999, ); my $score_xtor = sub { diff --git a/js/kivi.ShopOrder.js b/js/kivi.ShopOrder.js new file mode 100644 index 000000000..21ac4873c --- /dev/null +++ b/js/kivi.ShopOrder.js @@ -0,0 +1,35 @@ +namespace('kivi.ShopOrder', function(ns) { + ns.massTransferInitialize = function() { + kivi.popup_dialog({ + id: 'status_mass_transfer', + dialog: { + title: kivi.t8('Status Shoptransfer'), + } + }); + }; + + ns.massTransferStarted = function() { + $('#status_mass_transfer').data('timerId', setInterval(function() { + $.get("controller.pl", { + action: 'ShopOrder/transfer_status', + job_id: $('#smt_job_id').val() + }, kivi.eval_json_result); + }, 5000)); + }; + + ns.massTransferFinished = function() { + clearInterval($('#status_mass_transfer').data('timerId')); + $('.ui-dialog-titlebar button.ui-dialog-titlebar-close').prop('disabled', '') + }; + + ns.processClose = function() { + $('#status_mass_transfer').dialog('close'); + window.location.href = 'controller.pl?filter.obsolete=0&filter.transferred=0&action=ShopOrder%2flist&db=shop_orders&sort_by=shop_ordernumber'; + }; + + ns.setup = function() { + kivi.ShopOrder.massTransferInitialize(); + kivi.submit_ajax_form('controller.pl?action=ShopOrder/mass_transfer','[name=shop_orders_list]'); + }; + +}); diff --git a/templates/webpages/shop_order/_filter.html b/templates/webpages/shop_order/_filter.html new file mode 100644 index 000000000..b07d7f787 --- /dev/null +++ b/templates/webpages/shop_order/_filter.html @@ -0,0 +1,38 @@ +[%- USE T8 %] +[%- USE L %] +[%- USE LxERP %] +[%- USE HTML %] +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + +
[% 'Shop' | $T8 %][% L.select_tag('filter.shop_id:eq_ignore_empty', SELF.shops, value_key = 'value', title_key = 'title', default=0) %]
[% 'Status' | $T8 %][% L.select_tag('filter.transferred:eq_ignore_empty', SELF.transferred, value_key = 'value', title_key = 'title', default=0) %]
[% 'from' | $T8 %][% L.date_tag('filter.order_date:date::ge', FORM.filter.order_date_date__ge) %]
[% 'to' | $T8 %][% L.date_tag('filter.order_date:date::le', FORM.filter.order_date_date__le) %]
[% 'Obsolete' | $T8 %][% L.yes_no_tag('filter.obsolete', FORM.filter.obsolete, default='0', with_empty=1, empty_title='---') %]
+ + +[% 'Reset' | $T8 %] +
diff --git a/templates/webpages/shop_order/_transfer_status.html b/templates/webpages/shop_order/_transfer_status.html new file mode 100644 index 000000000..26b8c822b --- /dev/null +++ b/templates/webpages/shop_order/_transfer_status.html @@ -0,0 +1,61 @@ +[%- USE LxERP -%][%- USE L -%][%- USE HTML -%] +[%- USE Dumper -%] +[% SET data = job.data_as_hash %] + + +

[% LxERP.t8("Watch status") %]

+ +[% L.hidden_tag('', job.id, id="smt_job_id") %] + +JOBID: [% job.id %]

+ [% LxERP.t8("This status output will be refreshed every five seconds.") %] +

+

+

+

+ [% L.link("#", LxERP.t8("Close window"), onclick="kivi.ShopOrder.processClose();") %] + + + + + + + + + + + + + + + +
[% LxERP.t8("Current status:") %] + [% IF !data.status %] + [% LxERP.t8("waiting for job to be started") %] + [% ELSIF data.status == 1 %] + [% LxERP.t8("Converting to deliveryorder") %] + [% ELSE %] + [% LxERP.t8("Done.") %] + [% END %] +
[% LxERP.t8("Number of orders created:") %][% IF data.status > 0 %][% HTML.escape(data.num_order_created) %] / [% HTML.escape(data.shop_order_record_ids.size) %][% ELSE %]–[% END %]
[% LxERP.t8("Errors during conversion:") %] +[% IF !data.status %] + – +[% ELSIF !data.conversion_errors.size %] + [% LxERP.t8("No errors have occurred.") %] +[% ELSE %] + + + + + + + [% FOREACH error = data.conversion_errors %] + + + + + [% END %] +
[% LxERP.t8("Shoporder") %][% LxERP.t8("Error") %]
[% HTML.escape(error.number) %][% FOREACH message = error.message %][% HTML.escape(message) %]
[% END %]
+[% END %] +
+

diff --git a/templates/webpages/shop_order/list.html b/templates/webpages/shop_order/list.html new file mode 100644 index 000000000..1da0b17fa --- /dev/null +++ b/templates/webpages/shop_order/list.html @@ -0,0 +1,204 @@ +[%- USE HTML -%][%- USE LxERP -%][%- USE L -%][%- USE T8 -%] +[% USE Dumper %] + +[% L.stylesheet_tag('webshop') %] +[%- INCLUDE 'common/flash.html' %] +

[% title %][% 'Number data sets' | $T8 %]: [% SHOPORDERS.size %]

+[%- PROCESS 'shop_order/_filter.html' filter=SELF.models.filtered.laundered %] + +
+ + + + + + + + + + + + + + + + + + + [% FOREACH shop_order = SHOPORDERS %] + [% # Dumper.dump_html(shop_order) %] + [% IF shop_order.kivi_customer.id && shop_order.kivi_customer.order_lock == 0 && shop_order.open_invoices == 0 %] [% SET transferable = 1 %] [% SET transferable_class = 'class="shop_transferable"' %] [% ELSE %] [% SET transferable = 0 %] [% SET transferable_class = '' %][% END %] + + + + + + + + [% IF (shop_order.delivery_lastname != shop_order.billing_lastname || shop_order.delivery_firstname != shop_order.billing_firstname || shop_order.delivery_street != shop_order.billing_street || shop_order.delivery_city != shop_order.billing_city) %] [% SET deliveryclass = 'class="shop_delivery"' %] [% ELSE %] [% SET deliveryclass = '' %] [% END %] + + + + + [% END %] + + [% END %] +
[% 'Shop' | $T8 %][% IF FORM.sort_by == 'order_date' %] + + [% 'Shop orderdate' | $T8 %][% IF FORM.sort_dir == 0 %][% ELSE %][% END %] + [% ELSE %] + + [% 'Shop orderdate' | $T8 %] + [% END %] +
+ [% IF FORM.sort_by == 'itime' %] + + [% 'Importdate' | $T8 %][% IF FORM.sort_dir == 0 %][% ELSE %][% END %] + [% ELSE %] + + [% 'Importdate' | $T8 %] + [% END %] +
[% IF FORM.sort_by == 'shop_ordernumber' %] + + [% 'Shop ordernumber' | $T8 %][% IF FORM.sort_dir == 0 %][% ELSE %][% END %] + [% ELSE %] + + [% 'Shop ordernumber' | $T8 %] + [% END %] + [% IF FORM.sort_by == 'shop_customer_number' %] + + [% 'Shop customernumber' | $T8 %][% IF FORM.sort_dir == 0 %][% ELSE %][% END %] + [% ELSE %] + + [% 'Shop customernumber' | $T8 %] + [% END %] + [% 'Shop Customer Address' | $T8 %]
+ [% IF FORM.sort_by == 'customer_lastname' %] + + [% 'Name' | $T8 %][% IF FORM.sort_dir == 0 %][% ELSE %][% END %]| + [% ELSE %] + + [% 'Name' | $T8 %]| + [% END %] + [% IF FORM.sort_by == 'customer_zipcode' %] + + [% 'Zip' | $T8 %][% IF FORM.sort_dir == 0 %][% ELSE %][% END %]| + [% ELSE %] + + [% 'Zip' | $T8 %]| + [% END %] + [% IF FORM.sort_by == 'customer_country' %] + + [% 'Country' | $T8 %][% IF FORM.sort_dir == 0 %][% ELSE %][% END %] + [% ELSE %] + + [% 'Country' | $T8 %] + [% END %] +
[% 'Shop Billing Address' | $T8 %]
+ [% IF FORM.sort_by == 'billing_lastname' %] + + [% 'Name' | $T8 %][% IF FORM.sort_dir == 0 %][% ELSE %][% END %]| + [% ELSE %] + + [% 'Name' | $T8 %]| + [% END %] + [% IF FORM.sort_by == 'billing_zipcode' %] + + [% 'Zip' | $T8 %][% IF FORM.sort_dir == 0 %][% ELSE %][% END %]| + [% ELSE %] + + [% 'Zip' | $T8 %]| + [% END %] + [% IF FORM.sort_by == 'billing_country' %] + + [% 'Country' | $T8 %][% IF FORM.sort_dir == 0 %][% ELSE %][% END %] + [% ELSE %] + + [% 'Country' | $T8 %] + [% END %] +
[% 'Shop Delivery Address' | $T8 %]
+ [% IF FORM.sort_by == 'delivery_lastname' %] + + [% 'Name' | $T8 %][% IF FORM.sort_dir == 0 %][% ELSE %][% END %]| + [% ELSE %] + + [% 'Name' | $T8 %]| + [% END %] + [% IF FORM.sort_by == 'delivery_zipcode' %] + + [% 'Zip' | $T8 %][% IF FORM.sort_dir == 0 %][% ELSE %][% END %]| + [% ELSE %] + + [% 'Zip' | $T8 %]| + [% END %] + [% IF FORM.sort_by == 'delivery_country' %] + + [% 'Country' | $T8 %][% IF FORM.sort_dir == 0 %][% ELSE %][% END %] + [% ELSE %] + + [% 'Country' | $T8 %] + [% END %] +
[% IF FORM.sort_by == 'shop_customer_comment' %] + + [% 'Notes' | $T8 %][% IF FORM.sort_dir == 0 %][% ELSE %][% END %] + [% ELSE %] + + [% 'Notes' | $T8 %] + [% END %] + + [% IF FORM.sort_by == 'positions' %] + + [% 'Positions' | $T8 %][% IF FORM.sort_dir == 0 %][% ELSE %][% END %]
+ [% ELSE %] + [% 'Positions' | $T8 %]
+ [% END %] + [% IF FORM.sort_by == 'amount' %] + + [% 'Amount' | $T8 %][% IF FORM.sort_dir == 0 %][% ELSE %][% END %]
+ [% ELSE %] + [% 'Amount' | $T8 %]
+ [% END %] + [% IF FORM.sort_by == 'shipping_costs' %] + + [% 'Shippingcosts' | $T8 %][% IF FORM.sort_dir == 0 %][% ELSE %][% END %] + [% ELSE %] + [% 'Shippingcosts' | $T8 %] + [% END %] +
[% 'Action' | $T8 %]
[% L.checkbox_tag('check_all') %]
[% HTML.escape(shop_order.shop.description) %][% shop_order.order_date.to_kivitendo('precision' => 'minute') %]
[% shop_order.itime.to_kivitendo('precision' => 'minute') %]
[% HTML.escape(shop_order.shop_ordernumber) %][% HTML.escape(shop_order.shop_customer_number) %][% IF shop_order.customer_company %][% HTML.escape(shop_order.customer_company) %]
[% END %] + [% HTML.escape(shop_order.customer_lastname) %], [% HTML.escape(shop_order.customer_firstname) %] +
[% HTML.escape(shop_order.customer_street) %] +
[% HTML.escape(shop_order.customer_zipcode) %] [% HTML.escape(shop_order.customer_city) %] +
[% HTML.escape(shop_order.customer_country) %]
[% IF shop_order.customer_company %][% HTML.escape(shop_order.customer_company) %]
[% END %] + [% HTML.escape(shop_order.billing_lastname) %], [% HTML.escape(shop_order.billing_firstname) %] +
[% HTML.escape(shop_order.billing_street) %] +
[% HTML.escape(shop_order.billing_zipcode) %] [% HTML.escape(shop_order.billing_city) %] +
[% HTML.escape(shop_order.billing_country) %] +
[% IF shop_order.open_invoices > 0 || shop_order.customer.order_lock == 1 %][% SET alertclass = 'class="shop_alert"' %][% ELSE %][% SET alertclass = '' %][% END %]  [% 'Customernumber' | $T8 %] [% HTML.escape(shop_order.kivi_customer.customernumber) %] -- [% 'Invoices' | $T8 %] [% shop_order.open_invoices %]  
[% IF shop_order.customer_company %][% HTML.escape(shop_order.customer_company) %]
[% END %] + [% HTML.escape(shop_order.delivery_lastname) %], [% HTML.escape(shop_order.delivery_firstname) %] +
[% HTML.escape(shop_order.delivery_street) %] +
[% HTML.escape(shop_order.delivery_zipcode) %] [% HTML.escape(shop_order.delivery_city) %] +
[% HTML.escape(shop_order.delivery_country) %]
[% HTML.escape(shop_order.shop_customer_comment) %][% shop_order.positions %]
[% shop_order.amount_as_number %]
[% shop_order.shipping_costs_as_number %]
[% IF shop_order.transferred == 1 %][% 'Show order' | $T8 %]
[% shop_order.transferred_date_as_date %]
+ [% ELSE %] + [% IF transferable == 1 && shop_order.obsolete == 0 %] + [% L.checkbox_tag('id[]', checked = '1', value=shop_order.id) %]
+ [% END %] + [% IF shop_order.obsolete == 0 %][% 'Create order' | $T8 %]

+ [% 'Delete shoporder' | $T8 %] + [% ELSE %] + [% 'Obsolete' | $T8 %]

+ [% 'Show order' | $T8 %] + [% END %] +
+
+ + + diff --git a/templates/webpages/shop_order/show.html b/templates/webpages/shop_order/show.html new file mode 100644 index 000000000..e9c22e5ee --- /dev/null +++ b/templates/webpages/shop_order/show.html @@ -0,0 +1,208 @@ +[%- USE HTML -%][%- USE LxERP -%][%- USE L -%][%- USE T8 -%] +[% L.stylesheet_tag('webshop') %] +[%- INCLUDE 'common/flash.html' %] +

[% title %]

+ +
+
+
+
[% L.hidden_tag('create_customer','customer') %][% L.hidden_tag('import_id', IMPORT.id) %] +
+
+
[% 'Shop Customer Address' | $T8 %]
+
+
+
[% 'Greeting' | $T8 %]
[% HTML.escape(IMPORT.customer_greeting) %]
+
[% 'Firstname' | $T8 %]
[% HTML.escape(IMPORT.customer_firstname) %]
+
[% 'Lastname' | $T8 %]
[% HTML.escape(IMPORT.customer_lastname) %]
+
[% 'Company' | $T8 %]
[% HTML.escape(IMPORT.customer_company) %]
+
[% 'Department' | $T8 %]
[% HTML.escape(IMPORT.customer_department) %]
+ [% SET customer = IMPORT.customer_firstname _ ' ' _ IMPORT.customer_lastname %] +
+
[% 'Greeting' | $T8 %]
[% L.input_tag('customer_greeting', IMPORT.customer_greeting) %]
+
[% 'Customer' | $T8 %]
[% L.input_tag('customer_name', customer) %]
+
[% 'Name 2' | $T8 %]
[% L.input_tag('customer_company', IMPORT.customer_company) %]
+
[% 'Name 3' | $T8 %]
[% L.input_tag('customer_department', IMPORT.customer_department) %]
+
[% 'Street' | $T8 %]
[% L.input_tag('customer_street', IMPORT.customer_street) %]
+
[% 'Zipcode' | $T8 %]
[% L.input_tag('customer_zipcode', IMPORT.customer_zipcode) %]
+
[% 'City' | $T8 %]
[% L.input_tag('customer_city', IMPORT.customer_city) %]
+
[% 'Country' | $T8 %]
[% L.input_tag('customer_country', IMPORT.customer_country) %]
+
[% 'Phone' | $T8 %]
[% L.input_tag('customer_phone', IMPORT.customer_phone) %]
+
[% 'Email' | $T8 %]
[% L.input_tag('customer_email', IMPORT.customer_email) %]
+ [% IF C_ADDRESS %] +
[% 'Customernumber' | $T8 %]
[% C_ADDRESS.customernumber %]
+ [% ELSE %] +
[% L.ajax_submit_tag("controller.pl?action=ShopOrder/apply_customer", "#customer", LxERP.t8("Apply customer")) %]
+ [% END %] +
+
+
+
+
[% L.hidden_tag('create_customer','billing') %][% L.hidden_tag('import_id', IMPORT.id) %] +
+
+
[% 'Shop Billing Address' | $T8 %]
+
+
+
[% 'Greeting' | $T8 %]
[% HTML.escape(IMPORT.billing_greeting) %]
+
[% 'Firstname' | $T8 %]
[% HTML.escape(IMPORT.billing_firstname) %]
+
[% 'Lastname' | $T8 %]
[% HTML.escape(IMPORT.billing_lastname) %]
+
[% 'Company' | $T8 %]
[% HTML.escape(IMPORT.billing_company) %]
+
[% 'Department' | $T8 %]
[% HTML.escape(IMPORT.billing_department) %]
+ [% SET billing = IMPORT.billing_firstname _ ' ' _ IMPORT.billing_lastname %] +
+
[% 'Greeting' | $T8 %]
[% L.input_tag('billing_greeting', IMPORT.billing_greeting) %]
+
[% 'Customer' | $T8 %]
[% L.input_tag('billing_name', billing) %]
+
[% 'Name 2' | $T8 %]
[% L.input_tag('billing_company', IMPORT.billing_company) %]
+
[% 'Name 3' | $T8 %]
[% L.input_tag('billing_department', IMPORT.billing_department) %]
+
[% 'Street' | $T8 %]
[% L.input_tag('billing_street', IMPORT.billing_street) %]
+
[% 'Zipcode' | $T8 %]
[% L.input_tag('billing_zipcode', IMPORT.billing_zipcode) %]
+
[% 'City' | $T8 %]
[% L.input_tag('billing_city', IMPORT.billing_city) %]
+
[% 'Country' | $T8 %]
[% L.input_tag('billing_country', IMPORT.billing_country) %]
+
[% 'Phone' | $T8 %]
[% L.input_tag('billing_phone', IMPORT.billing_phone) %]
+
[% 'Email' | $T8 %]
[% L.input_tag('billing_email', IMPORT.billing_email) %]
+ [% IF B_ADDRESS %] +
[% 'Customernumber' | $T8 %]
[% B_ADDRESS.customernumber %]
+ [% ELSE %] +
[% L.ajax_submit_tag("controller.pl?action=ShopOrder/apply_customer", "#billing", LxERP.t8("Apply customer")) %]
+ [% END %] +
+
+
+
+
[% L.hidden_tag('create_customer','delivery') %][% L.hidden_tag('import_id', IMPORT.id) %] +
+
+
[% 'Shop Delivery Address' | $T8 %]
+
+
+
[% 'Greeting' | $T8 %]
[% HTML.escape(IMPORT.delivery_greeting) %]
+
[% 'Firstname' | $T8 %]
[% HTML.escape(IMPORT.delivery_firstname) %]
+
[% 'Lastname' | $T8 %]
[% HTML.escape(IMPORT.delivery_lastname) %]
+
[% 'Company' | $T8 %]
[% HTML.escape(IMPORT.delivery_company) %]
+
[% 'Department' | $T8 %]
[% HTML.escape(IMPORT.delivery_department) %]
+ [% SET delivery = IMPORT.delivery_firstname _ ' ' _ IMPORT.delivery_lastname %] +
+
[% 'Greeting' | $T8 %]
[% L.input_tag('delivery_greeting', IMPORT.delivery_greeting) %]
+
[% 'Customer' | $T8 %]
[% L.input_tag('delivery_name', delivery) %]
+
[% 'Name 2' | $T8 %]
[% L.input_tag('delivery_company', IMPORT.delivery_company) %]
+
[% 'Name 3' | $T8 %]
[% L.input_tag('delivery_department', IMPORT.delivery_department) %]
+
[% 'Street' | $T8 %]
[% L.input_tag('delivery_street', IMPORT.delivery_street) %]
+
[% 'Zipcode' | $T8 %]
[% L.input_tag('delivery_zipcode', IMPORT.delivery_zipcode) %]
+
[% 'City' | $T8 %]
[% L.input_tag('delivery_city', IMPORT.delivery_city) %]
+
[% 'Country' | $T8 %]
[% L.input_tag('delivery_country', IMPORT.delivery_country) %]
+
[% 'Phone' | $T8 %]
[% L.input_tag('delivery_phone', IMPORT.delivery_phone) %]
+
[% 'Email' | $T8 %]
[% L.input_tag('delivery_email', IMPORT.delivery_email) %]
+ [% IF D_ADDRESS %] +
[% 'Customernumber' | $T8 %]
[% D_ADDRESS.customernumber %]
+ [% ELSE %] +
[% L.ajax_submit_tag("controller.pl?action=ShopOrder/apply_customer", "#delivery", LxERP.t8("Apply customer")) %]
+ [% END %] +
+
+
+
+
+
+ + + + + +
+ + + + + + + + + + + +
[% 'Shop Headdata' | $T8 %]
[% 'Shop Ordernumber' | $T8 %][% HTML.escape(IMPORT.shop_ordernumber) %]
[% 'Shop Orderdate' | $T8 %][% HTML.escape(IMPORT.order_date.dmy('.')) _ ' ' _ HTML.escape(IMPORT.order_date.hms(':')) %]
[% 'Shop Host' | $T8 %][% HTML.escape(IMPORT.host) %]
[% 'Shop OrderIP' | $T8 %][% HTML.escape(IMPORT.remote_ip) %]
[% 'Shop Ordernotes' | $T8 %][% HTML.escape(IMPORT.shop_customer_comment) %]
[% 'Shop Orderamount' | $T8 %][% HTML.escape(IMPORT.amount_as_number) %]
[% 'Shipping costs' | $T8 %][% HTML.escape(IMPORT.shipping_costs_as_number) %]
+
+ [% IF IMPORT.obsolete %] + [% 'Shoporder deleted -- ' | $T8 %][% 'revert deleted' | $T8 %] + [% ELSE %] + [% UNLESS IMPORT.transferred %] + [% IF PROPOSALS %] +
+ [% L.hidden_tag('import_id', IMPORT.id) %] +
+ + + + [% FOREACH prop = PROPOSALS %][% IF prop.order_lock %][% SET orderlock_class = 'style="background:rgba(232, 32, 23, 0.2);"' %][% ELSE %][% SET orderlock_class = '' %][% END %] + + + + + + + + + + [% END %] +
Customer Proposals +
[% IF !prop.order_lock %][% L.radio_button_tag('customer', value=prop.id) %][% END %][% HTML.escape(prop.customernumber) %][% IF !prop.notes == '' %][% HTML.escape(prop.name) %][% ELSE %][% HTML.escape(prop.name) %][% END %][% HTML.escape(prop.street) %][% HTML.escape(prop.zipcode) %][% HTML.escape(prop.city) %][% HTML.escape(prop.email) %]
+
+ + [% FOREACH prop = PROPOSALS %] + + [% END %] +
+ [% 'delete order' | $T8 %] + [% END # PROPOSALS %] + [% ELSE %] +
+ [% 'Transferred' | $T8 %] + + +
+ [% END %] + [% END %] +
+
+
+ + + + + + + + + + [% FOREACH pos = IMPORT.shop_order_items %] + + + + + + + [% SET extended = pos.price * pos.quantity %] + + + [% END %] +
[% 'Position' | $T8 %][% 'Partnumber' | $T8 %][% 'Part Description' | $T8 %][% 'Qty' | $T8 %][% 'Price' | $T8 %][% 'Extended' | $T8 %]
[% count() %][% HTML.escape(pos.partnumber) %][% HTML.escape(pos.description) %][% pos.quantity_as_number%][% pos.price_as_number%][% LxERP.format_amount(extended,2) %]
+
+
+ +[% # L.dump(IMPORT) %] -- 2.20.1