Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision 4d32ba10

Von Tamino Steinert vor etwa 1 Jahr hinzugefügt

  • ID 4d32ba1005f8c76249130347f2039eb9759682f7
  • Vorgänger 9c42cae9
  • Nachfolger 45073f4d

EmailJournal: Belegvorlage zum Workflow hinzugefügt

Unterschiede anzeigen:

SL/Controller/EmailJournal.pm
'purchase_credit_note',
],
},
RecordTemplate => {
controller => '',
class => 'RecordTemplate',
types => [
'gl_transaction_template',
'ar_transaction_template',
'ap_transaction_template',
],
}
);
my %RECORD_TYPE_TO_CONTROLLER =
map {
......
my $model = $RECORD_TYPE_TO_MODEL{$_};
if (any {$model eq $_} qw(SL::DB::Invoice SL::DB::PurchaseInvoice)) {
$_ => 'invnumber';
} elsif (any {$model eq $_} qw(SL::DB::RecordTemplate)) {
$_ => 'template_name';
} else {
my $type_data = SL::DB::Helper::TypeDataProxy->new($model, $_);
$_ => $type_data->properties('nr_key');
......
# TODO: what record types can be created, which are only available in workflows?
my @record_types_with_info = ();
for my $record_class ('SL::DB::Order', 'SL::DB::DeliveryOrder', 'SL::DB::Reclamation') {
my $valid_types = "${record_class}::TypeData"->valid_types();
my $type_data = "${record_class}::TypeData";
my $valid_types = $type_data->valid_types();
for my $type (@$valid_types) {
my $type_data = SL::DB::Helper::TypeDataProxy->new($record_class, $type);
push @record_types_with_info, {
record_type => $type,
customervendor => $type_data->properties('customervendor'),
text => $type_data->text('type'),
record_type => $type,
text => $type_data->can('get3')->($type, 'text', 'type'),
customervendor => $type_data->can('get3')->($type, 'properties', 'customervendor'),
workflow_needed => $type_data->can('get3')->($type, 'properties', 'worflow_needed'),
can_workflow => (
any {
$_ ne 'delete' && $type_data->can('get3')->($type, 'show_menu', $_)
} keys %{$type_data->can('get')->($type, 'show_menu')}
),
};
}
}
push @record_types_with_info, (
# invoice
{ record_type => 'invoice', customervendor => 'customer', text => t8('Invoice') },
{ record_type => 'invoice_for_advance_payment', customervendor => 'customer', text => t8('Invoice for Advance Payment')},
{ record_type => 'invoice_for_advance_payment_storno', customervendor => 'customer', text => t8('Storno Invoice for Advance Payment')},
{ record_type => 'final_invoice', customervendor => 'customer', text => t8('Final Invoice')},
{ record_type => 'invoice_storno', customervendor => 'customer', text => t8('Storno Invoice')},
{ record_type => 'credit_note', customervendor => 'customer', text => t8('Credit Note')},
{ record_type => 'credit_note_storno', customervendor => 'customer', text => t8('Storno Credit Note')},
{ record_type => 'ar_transaction', customervendor => 'customer', text => t8('AR Transaction')},
{ record_type => 'invoice', customervendor => 'customer', workflow_needed => 0, can_workflow => 1, text => t8('Invoice') },
{ record_type => 'invoice_for_advance_payment', customervendor => 'customer', workflow_needed => 0, can_workflow => 1, text => t8('Invoice for Advance Payment')},
{ record_type => 'invoice_for_advance_payment_storno', customervendor => 'customer', workflow_needed => 1, can_workflow => 1, text => t8('Storno Invoice for Advance Payment')},
{ record_type => 'final_invoice', customervendor => 'customer', workflow_needed => 1, can_workflow => 1, text => t8('Final Invoice')},
{ record_type => 'invoice_storno', customervendor => 'customer', workflow_needed => 1, can_workflow => 1, text => t8('Storno Invoice')},
{ record_type => 'credit_note', customervendor => 'customer', workflow_needed => 0, can_workflow => 1, text => t8('Credit Note')},
{ record_type => 'credit_note_storno', customervendor => 'customer', workflow_needed => 1, can_workflow => 1, text => t8('Storno Credit Note')},
# purchase invoice
{ record_type => 'purchase_invoice', customervendor => 'vendor', text => t8('Purchase Invoice')},
{ record_type => 'purchase_credit_note', customervendor => 'vendor', text => t8('Purchase Credit Note')},
{ record_type => 'ap_transaction', customervendor => 'vendor', text => t8('AP Transaction')},
{ record_type => 'purchase_invoice', customervendor => 'vendor', workflow_needed => 0, can_workflow => 1, text => t8('Purchase Invoice')},
{ record_type => 'purchase_credit_note', customervendor => 'vendor', workflow_needed => 0, can_workflow => 1, text => t8('Purchase Credit Note')},
# transactions
# TODO: create gl_transaction with email
# { record_type => 'gl_transaction', customervendor => 'customer', workflow_needed => 0, can_workflow => 0, text => t8('GL Transaction')},
# { record_type => 'gl_transaction', customervendor => 'vendor', workflow_needed => 0, can_workflow => 0, text => t8('GL Transaction')},
{ record_type => 'ar_transaction', customervendor => 'customer', workflow_needed => 0, can_workflow => 1, text => t8('AR Transaction')},
{ record_type => 'ap_transaction', customervendor => 'vendor', workflow_needed => 0, can_workflow => 1, text => t8('AP Transaction')},
# templates
{ record_type => 'gl_transaction_template', is_template => 1, customervendor => 'customer', workflow_needed => 0, can_workflow => 0, text => t8('GL Transaction')},
{ record_type => 'gl_transaction_template', is_template => 1, customervendor => 'vendor', workflow_needed => 0, can_workflow => 0, text => t8('GL Transaction')},
{ record_type => 'ar_transaction_template', is_template => 1, customervendor => 'customer', workflow_needed => 0, can_workflow => 0, text => t8('AR Transaction')},
{ record_type => 'ap_transaction_template', is_template => 1, customervendor => 'vendor', workflow_needed => 0, can_workflow => 0, text => t8('AP Transaction')},
);
return @record_types_with_info;
}
sub record_types_for_customer_vendor_type {
my ($self, $customer_vendor_type) = @_;
return [ map { $_->{record_type} } grep { $_->{customervendor} eq $customer_vendor_type } $self->get_record_types_with_info ];
sub record_types_for_customer_vendor_type_and_action {
my ($self, $customer_vendor_type, $action) = @_;
return [
map { $_->{record_type} }
grep {
($_->{customervendor} eq $customer_vendor_type)
&& ($action eq 'workflow_record' ? $_->{can_workflow} : 1)
&& ($action eq 'create_new' ? $_->{workflow_needed} : 1)
&& ($action eq 'linking_record' ? $_->{record_type} !~ /_template$/ : 1)
&& ($action eq 'template_record' ? $_->{record_type} =~ /_template$/ : 1)
}
$self->get_record_types_with_info()
];
}
#
......
my $customer_vendor = $self->find_customer_vendor_from_email($self->entry);
my $cv_type = $customer_vendor && $customer_vendor->is_vendor ? 'vendor' : 'customer';
my $record_types = $self->record_types_for_customer_vendor_type($cv_type);
my $record_types = $self->record_types_for_customer_vendor_type_and_action($cv_type, 'workflow_record');
my @records = $self->get_records_for_types(
$record_types,
customer_vendor_type => $cv_type,
......
my $manager = $RECORD_TYPE_TO_MANAGER{$record_type};
my $model = $RECORD_TYPE_TO_MODEL{$record_type};
my %additional_where = ();
if ($cv_type && $cv_id) {
if ($cv_type && $cv_id && $record_type !~ /^gl_transaction/) {
$additional_where{"${cv_type}_id"} = $cv_id;
}
if ($record_number) {
......
$::auth->assert('email_journal');
my $customer_vendor_type = $::form->{customer_vendor_selection};
my $customer_vendor_id = $::form->{"${customer_vendor_type}_id"};
my $record_type = $::form->{"${customer_vendor_type}_record_type_selection"};
my $action = $::form->{action_selection};
my $record_type = $::form->{"${customer_vendor_type}_${action}_type_selection"};
my $record_number = $::form->{record_number};
my $with_closed = $::form->{with_closed};
$record_type ||= $self->record_types_for_customer_vendor_type($customer_vendor_type);
$record_type ||= $self->record_types_for_customer_vendor_type_and_action($customer_vendor_type, $action);
my @records = $self->get_records_for_types(
$record_type,
......
id => 'record_list',
);
$self->js->replaceWith('#record_list', $new_div);
$self->js->hide('#record_toggle_closed') if scalar @records < 20;
$self->js->show('#record_toggle_open') if scalar @records < 20;
js/kivi.EmailJournal.js
$.post("controller.pl", data, kivi.eval_json_result);
}
ns.update_customer_vendor_selection = function() {
ns.update_email_workflow_options = function() {
let customer_vendor = $('#customer_vendor_selection').val();
$('#customer_div').hide();
$('#customer_record_types_div').hide();
$('#vendor_div').hide();
$('#vendor_record_types_div').hide();
if (customer_vendor == 'customer') {
$('#customer_div').show();
$('#customer_record_types_div').show();
} else { // if (customer_vendor == 'vendor')
$('#vendor_div').show();
$('#vendor_record_types_div').show();
}
kivi.EmailJournal.update_record_list();
}
ns.update_action_selection = function() {
let record_action = $('#action_selection').val();
// Hide all div
['customer', 'vendor'].forEach(function(cv) {
$(`#${cv}_div`).hide();
['workflow_record', 'template_record', 'linking_record', 'new_record'].forEach(function(action) {
$(`#${cv}_${action}_types_div`).hide();
});
});
$('#new_record_div').hide();
$('#template_record_div').hide();
$('#record_selection_div').hide();
$('#create_new_div').hide();
if (record_action == 'create_new') {
$('#create_new_div').show();
$('#create_new_div').css('display','inline-block')
// Enable needed div
$(`#${customer_vendor}_div`).show();
$(`#${customer_vendor}_${record_action}_types_div`).show();
if (record_action == 'new_record') {
$('#new_record_div').show();
$('#new_record_div').css('display','inline-block')
} else {
$('#record_selection_div').show();
kivi.EmailJournal.update_record_list();
}
}
locale/de/all
'Create customers and vendors. Edit all vendors. Edit only customers where salesman equals employee (login)' => 'Kunden und Lieferanten erfassen. Alle Lieferanten bearbeiten. Nur Kunden bearbeiten bei denen der Verkäufer gleich Bearbeiter (login) ist',
'Create delivery order' => 'Lieferschein erstellen',
'Create first invoice on' => 'Erste Rechnung erzeugen am',
'Create from Record Template' => 'Mit Belegvorlage erstellen',
'Create from Workflow' => 'Workflow weiterführen von',
'Create invoice' => 'Buchung erstellen',
'Create invoice?' => 'Rechnung erstellen?',
locale/en/all
'Create customers and vendors. Edit all vendors. Edit only customers where salesman equals employee (login)' => '',
'Create delivery order' => '',
'Create first invoice on' => '',
'Create from Record Template' => '',
'Create from Workflow' => '',
'Create invoice' => '',
'Create invoice?' => '',
templates/design40_webpages/email_journal/show.html
<div id="action_div" class="col">
[% L.select_tag('action_selection',
[
{value => "workflow", name => LxERP.t8("Create from Workflow")},
{value => "linking", name => LxERP.t8("Linking to Record")},
{value => "create_new", name => LxERP.t8("Create new")},
{value => "workflow_record", name => LxERP.t8("Create from Workflow")},
{value => "linking_record", name => LxERP.t8("Linking to Record")},
{value => "new_record", name => LxERP.t8("Create new")},
{value => "template_record", name => LxERP.t8("Create from Record Template")},
],
value_key='value', title_key='name',
class="wi-normal",
onchange='kivi.EmailJournal.update_action_selection();'
onchange='kivi.EmailJournal.update_email_workflow_options();'
) %]
</div>
......
default = CV_TYPE_FOUND,
value_key='value', title_key='name',
class="wi-verysmall",
onchange='kivi.EmailJournal.update_customer_vendor_selection();'
onchange='kivi.EmailJournal.update_email_workflow_options();'
) %]
</div>
[% FOREACH customer_vendor = ['customer', 'vendor'] %]
<div id="[% customer_vendor _ "_record_types_div" %]" class="col"
<div id="[% customer_vendor _ "_workflow_record_types_div" %]" class="col"
style=[% IF customer_vendor == CV_TYPE_FOUND %] "display:block" [% ELSE %] "display:none" [% END %]
>
[%
SET options = [];
FOREACH record_info = RECORD_TYPES_WITH_INFO;
IF (record_info.customervendor == customer_vendor);
IF (record_info.customervendor == customer_vendor && record_info.can_workflow && !record_info.is_template);
options.push({value => record_info.record_type, name => record_info.text});
END;
END;
%]
[% L.select_tag(customer_vendor _ '_record_type_selection',
[% L.select_tag(customer_vendor _ '_workflow_record_type_selection',
options,
value_key='value', title_key='name',
with_empty=1, empty_value='', empty_title=LxERP.t8("Select record type"),
onchange='kivi.EmailJournal.update_record_list();'
) %]
</div>
<div id="[% customer_vendor _ "_new_record_types_div" %]" class="col"
style="display:none"
>
[%
SET options = [];
FOREACH record_info = RECORD_TYPES_WITH_INFO;
IF (record_info.customervendor == customer_vendor && !record_info.workflow_needed && !record_info.is_template);
options.push({value => record_info.record_type, name => record_info.text});
END;
END;
%]
[% L.select_tag(customer_vendor _ '_new_record_type_selection',
options,
value_key='value', title_key='name',
with_empty=1, empty_value='', empty_title=LxERP.t8("Select record type"),
onchange='kivi.EmailJournal.update_record_list();'
) %]
</div>
<div id="[% customer_vendor _ "_linking_record_types_div" %]" class="col"
style="display:none"
>
[%
SET options = [];
FOREACH record_info = RECORD_TYPES_WITH_INFO;
IF (record_info.customervendor == customer_vendor && !record_info.is_template);
options.push({value => record_info.record_type, name => record_info.text});
END;
END;
%]
[% L.select_tag(customer_vendor _ '_linking_record_type_selection',
options,
value_key='value', title_key='name',
with_empty=1, empty_value='', empty_title=LxERP.t8("Select record type"),
onchange='kivi.EmailJournal.update_record_list();'
) %]
</div>
<div id="[% customer_vendor _ "_template_record_types_div" %]" class="col"
style="display:none"
>
[%
SET options = [];
FOREACH record_info = RECORD_TYPES_WITH_INFO;
IF (record_info.customervendor == customer_vendor && record_info.is_template);
options.push({value => record_info.record_type, name => record_info.text});
END;
END;
%]
[% L.select_tag(customer_vendor _ '_template_record_type_selection',
options,
value_key='value', title_key='name',
with_empty=1, empty_value='', empty_title=LxERP.t8("Select record type"),
......
<script type="text/javascript">
$(document).ready(function() {
kivi.EmailJournal.update_action_selection();
kivi.EmailJournal.update_customer_vendor_selection();
kivi.EmailJournal.update_email_workflow_options();
kivi.EmailJournal.update_record_list();
kivi.EmailJournal.update_attachment_preview();
});

Auch abrufbar als: Unified diff