From: Sven Schöling Date: Fri, 26 Mar 2021 18:26:04 +0000 (+0100) Subject: ImageUpload: erste Version X-Git-Tag: kivitendo-mebil_0.1-0~9^2~87 X-Git-Url: http://wagnertech.de/git?a=commitdiff_plain;h=47577d1daa5da455e3883ed60c70875a6845233a;p=kivitendo-erp.git ImageUpload: erste Version --- diff --git a/SL/Controller/ImageUpload.pm b/SL/Controller/ImageUpload.pm new file mode 100644 index 000000000..173c5daf1 --- /dev/null +++ b/SL/Controller/ImageUpload.pm @@ -0,0 +1,57 @@ +package SL::Controller::ImageUpload; + +use strict; +use parent qw(SL::Controller::Base); + +use SL::DB::Part; +use SL::DB::Order; +use SL::DB::DeliveryOrder; + +use Rose::Object::MakeMethods::Generic +( + scalar => [ qw() ], + 'scalar --get_set_init' => [ qw(object_type object) ], +); + +my %object_loader = ( + part => [ "SL::DB::Part" ], + sales_order => [ "SL::DB::Order", [ sales => 1, quotation => 0 ] ], + sales_quotation => [ "SL::DB::Order", [ sales => 1, quotation => 1 ] ], + purchase_order => [ "SL::DB::Order", [ sales => 0, quotation => 1 ] ], + sales_delivery_order => [ "SL::DB::DeliveryOrder", [ is_sales => 1 ] ], +); + + +################ actions ################# + +sub action_upload_image { + my ($self) = @_; + + $::request->layout->add_javascripts('kivi.File.js'); + + $self->render('image_upload/form'); +} + +################# internal ############### + +sub init_object_type { + $::form->{object_type} or die "need object type" +} + +sub init_object { + my ($self) = @_; + + return unless $self->object_type; + + my $loader = $object_loader{ $self->object_type } or die "unknown object type"; + my $manager = $loader->[0]->_get_manager_class; + + return $manager->find_by(id => $::form->{object_id}*1) if $::form->{object_id}; + + return $manager->find_by(donumber => $::form->{object_number}, @{ $loader->[1] // [] }) if $::form->{object_number}; +} + + +1; + + diff --git a/menus/mobile/00-erp.yaml b/menus/mobile/00-erp.yaml index e510d0869..62231c8ce 100644 --- a/menus/mobile/00-erp.yaml +++ b/menus/mobile/00-erp.yaml @@ -8,8 +8,8 @@ order: 100 access: sales_delivery_order_edit params: - action: ImageUpload/search_delivery_order - sales: 1 + action: ImageUpload/upload_image + object_type: sales_delivery_order - id: component_test name: Component Test order: 200 diff --git a/templates/mobile_webpages/image_upload/form.html b/templates/mobile_webpages/image_upload/form.html new file mode 100644 index 000000000..428f6b905 --- /dev/null +++ b/templates/mobile_webpages/image_upload/form.html @@ -0,0 +1,31 @@ +[% USE HTML %] +[% USE T8 %] +[% USE P %] +[% USE LxERP %] + +

[% title | html %]

+ +
+ +[% IF !SELF.object.id %] + +

[% 'Input delivery order number (picker NYI)' | $T8 %]

+ + [% P.M.input_tag("object_number", "", label=LxERP.t8("Number")) %] + [% P.M.submit_tag("submit", LxERP.t8("Update")) %] +[% ELSE %] +

[% SELF.object.displayable_name | html %]

+ + [% P.hidden_tag("object_id", SELF.object.id) %] +[% END %] + +[% P.hidden_tag("object_type", SELF.object_type) %] +[% P.hidden_tag("action", "ImageUpload/upload_image") %] +
+ +[%# IF SELF.object.id %] +
+ +[%# END %]