From: Moritz Bunkus Date: Wed, 20 Apr 2016 11:52:16 +0000 (+0200) Subject: Brieffunktion: unbenutzte Tabellenspalten entfernt, vc_id → customer_id umbenannt X-Git-Tag: release-3.4.1~190 X-Git-Url: http://wagnertech.de/git?a=commitdiff_plain;h=7196276bca4a155d1bcc3947859bc7d4ec1edcd6;p=kivitendo-erp.git Brieffunktion: unbenutzte Tabellenspalten entfernt, vc_id → customer_id umbenannt --- diff --git a/SL/Controller/Letter.pm b/SL/Controller/Letter.pm index 7905cb759..e9fe6cf75 100644 --- a/SL/Controller/Letter.pm +++ b/SL/Controller/Letter.pm @@ -36,7 +36,7 @@ my %sort_columns = ( date => t8('Date'), subject => t8('Subject'), letternumber => t8('Letternumber'), - vc_id => t8('Customer'), + customer_id => t8('Customer'), contact => t8('Contact'), ); @@ -94,7 +94,7 @@ sub action_update_contacts { my $letter = $self->letter; - if (!$self->letter->vc_id || !$self->letter->customer) { + if (!$self->letter->customer_id || !$self->letter->customer) { return $self->js ->replaceWith( '#letter_cp_id', @@ -108,7 +108,7 @@ sub action_update_contacts { my $default; if ( $letter->contact && $letter->contact->cp_cv_id - && $letter->contact->cp_cv_id == $letter->vc_id) { + && $letter->contact->cp_cv_id == $letter->customer_id) { $default = $letter->contact->cp_id; } else { $default = ''; @@ -187,7 +187,7 @@ sub action_print_letter { my $greeting_saved = $::form->{greeting}; my $cp_id_saved = $::form->{cp_id}; - $::form->{customer_id} = $self->letter->vc_id; + $::form->{customer_id} = $self->letter->customer_id; IS->customer_details(\%::myconfig, $::form); if (!$cp_id_saved) { @@ -405,8 +405,8 @@ sub prepare_report { my $report = SL::ReportGenerator->new(\%::myconfig, $::form); $self->{report} = $report; - my @columns = qw(date subject letternumber vc_id contact date); - my @sortable = qw(date subject letternumber vc_id contact date); + my @columns = qw(date subject letternumber customer_id contact date); + my @sortable = qw(date subject letternumber customer_id contact date); my %column_defs = ( date => { text => t8('Date'), sub => sub { $_[0]->date_as_date } }, @@ -414,7 +414,7 @@ sub prepare_report { obj_link => sub { $self->url_for(action => 'edit', 'letter.id' => $_[0]->id, callback => $self->models->get_callback) } }, letternumber => { text => t8('Letternumber'), sub => sub { $_[0]->letternumber }, obj_link => sub { $self->url_for(action => 'edit', 'letter.id' => $_[0]->id, callback => $self->models->get_callback) } }, - vc_id => { text => t8('Customer'), sub => sub { SL::DB::Manager::Customer->find_by_or_create(id => $_[0]->vc_id)->displayable_name } }, + customer_id => { text => t8('Customer'), sub => sub { SL::DB::Manager::Customer->find_by_or_create(id => $_[0]->customer_id)->displayable_name } }, contact => { text => t8('Contact'), sub => sub { $_[0]->contact ? $_[0]->contact->full_name : '' } }, ); @@ -571,7 +571,7 @@ sub init_letter { ->assign_attributes(%{ $::form->{letter} }); if ($letter->cp_id) { -# $letter->vc_id($letter->contact->cp_cv_id); +# $letter->customer_id($letter->contact->cp_cv_id); # contacts don't have language_id yet # $letter->greeting(GenericTranslations->get( # translation_type => 'greetings::' . ($letter->contact->cp_gender eq 'f' ? 'female' : 'male'), diff --git a/SL/DB/Letter.pm b/SL/DB/Letter.pm index 63a00108b..27b0cff47 100644 --- a/SL/DB/Letter.pm +++ b/SL/DB/Letter.pm @@ -7,15 +7,6 @@ use SL::DB::Helper::LinkedRecords; use SL::DB::MetaSetup::Letter; use SL::DB::Manager::Letter; -__PACKAGE__->meta->add_relationships( - customer => { - type => 'many to one', - class => 'SL::DB::Customer', - column_map => { vc_id => 'id' }, - }, - -); - __PACKAGE__->meta->initialize; __PACKAGE__->attr_html('body'); diff --git a/SL/DB/MetaSetup/Letter.pm b/SL/DB/MetaSetup/Letter.pm index 0d29b9fe1..b4dbe1052 100644 --- a/SL/DB/MetaSetup/Letter.pm +++ b/SL/DB/MetaSetup/Letter.pm @@ -9,34 +9,20 @@ use parent qw(SL::DB::Object); __PACKAGE__->meta->table('letter'); __PACKAGE__->meta->columns( - body => { type => 'text' }, - close => { type => 'text' }, - company_name => { type => 'text' }, - cp_id => { type => 'integer' }, - date => { type => 'date' }, - employee_id => { type => 'integer' }, - employee_position => { type => 'text' }, - greeting => { type => 'text' }, - id => { type => 'integer', not_null => 1, sequence => 'id' }, - intnotes => { type => 'text' }, - itime => { type => 'timestamp', default => 'now()' }, - jobnumber => { type => 'text' }, - letternumber => { type => 'text' }, - mtime => { type => 'timestamp' }, - page_created_for => { type => 'text' }, - rcv_address => { type => 'text' }, - rcv_city => { type => 'text' }, - rcv_contact => { type => 'text' }, - rcv_country => { type => 'text' }, - rcv_countrycode => { type => 'text' }, - rcv_name => { type => 'text' }, - rcv_zipcode => { type => 'text' }, - reference => { type => 'text' }, - salesman_id => { type => 'integer' }, - salesman_position => { type => 'text' }, - subject => { type => 'text' }, - text_created_for => { type => 'text' }, - vc_id => { type => 'integer', not_null => 1 }, + body => { type => 'text' }, + cp_id => { type => 'integer' }, + customer_id => { type => 'integer', not_null => 1 }, + date => { type => 'date' }, + employee_id => { type => 'integer' }, + greeting => { type => 'text' }, + id => { type => 'integer', not_null => 1, sequence => 'id' }, + intnotes => { type => 'text' }, + itime => { type => 'timestamp', default => 'now()' }, + letternumber => { type => 'text' }, + mtime => { type => 'timestamp' }, + reference => { type => 'text' }, + salesman_id => { type => 'integer' }, + subject => { type => 'text' }, ); __PACKAGE__->meta->primary_key_columns([ 'id' ]); @@ -49,6 +35,11 @@ __PACKAGE__->meta->foreign_keys( key_columns => { cp_id => 'cp_id' }, }, + customer => { + class => 'SL::DB::Customer', + key_columns => { customer_id => 'id' }, + }, + employee => { class => 'SL::DB::Employee', key_columns => { employee_id => 'id' }, diff --git a/SL/DB/MetaSetup/LetterDraft.pm b/SL/DB/MetaSetup/LetterDraft.pm index 1ef3fb891..8b9782e75 100644 --- a/SL/DB/MetaSetup/LetterDraft.pm +++ b/SL/DB/MetaSetup/LetterDraft.pm @@ -9,34 +9,20 @@ use parent qw(SL::DB::Object); __PACKAGE__->meta->table('letter_draft'); __PACKAGE__->meta->columns( - body => { type => 'text' }, - close => { type => 'text' }, - company_name => { type => 'text' }, - cp_id => { type => 'integer' }, - date => { type => 'date' }, - employee_id => { type => 'integer' }, - employee_position => { type => 'text' }, - greeting => { type => 'text' }, - id => { type => 'integer', not_null => 1, sequence => 'id' }, - intnotes => { type => 'text' }, - itime => { type => 'timestamp', default => 'now()' }, - jobnumber => { type => 'text' }, - letternumber => { type => 'text' }, - mtime => { type => 'timestamp' }, - page_created_for => { type => 'text' }, - rcv_address => { type => 'text' }, - rcv_city => { type => 'text' }, - rcv_contact => { type => 'text' }, - rcv_country => { type => 'text' }, - rcv_countrycode => { type => 'text' }, - rcv_name => { type => 'text' }, - rcv_zipcode => { type => 'text' }, - reference => { type => 'text' }, - salesman_id => { type => 'integer' }, - salesman_position => { type => 'text' }, - subject => { type => 'text' }, - text_created_for => { type => 'text' }, - vc_id => { type => 'integer', not_null => 1 }, + body => { type => 'text' }, + cp_id => { type => 'integer' }, + customer_id => { type => 'integer', not_null => 1 }, + date => { type => 'date' }, + employee_id => { type => 'integer' }, + greeting => { type => 'text' }, + id => { type => 'integer', not_null => 1, sequence => 'id' }, + intnotes => { type => 'text' }, + itime => { type => 'timestamp', default => 'now()' }, + letternumber => { type => 'text' }, + mtime => { type => 'timestamp' }, + reference => { type => 'text' }, + salesman_id => { type => 'integer' }, + subject => { type => 'text' }, ); __PACKAGE__->meta->primary_key_columns([ 'id' ]); @@ -49,6 +35,11 @@ __PACKAGE__->meta->foreign_keys( key_columns => { cp_id => 'cp_id' }, }, + customer => { + class => 'SL::DB::Customer', + key_columns => { customer_id => 'id' }, + }, + employee => { class => 'SL::DB::Employee', key_columns => { employee_id => 'id' }, diff --git a/sql/Pg-upgrade2/letter_cleanup.sql b/sql/Pg-upgrade2/letter_cleanup.sql new file mode 100644 index 000000000..e87f6e028 --- /dev/null +++ b/sql/Pg-upgrade2/letter_cleanup.sql @@ -0,0 +1,40 @@ +-- @tag: letter_cleanup +-- @description: Tabelle »letter«: Unbenutzte Spalten entfernen und andere Spalten umbenennen +-- @depends: release_3_4_0 + +ALTER TABLE letter RENAME COLUMN vc_id TO customer_id; +ALTER TABLE letter_draft RENAME COLUMN vc_id TO customer_id; + +ALTER TABLE letter + DROP COLUMN close, + DROP COLUMN company_name, + DROP COLUMN employee_position, + DROP COLUMN jobnumber, + DROP COLUMN page_created_for, + DROP COLUMN rcv_address, + DROP COLUMN rcv_city, + DROP COLUMN rcv_contact, + DROP COLUMN rcv_country, + DROP COLUMN rcv_countrycode, + DROP COLUMN rcv_name, + DROP COLUMN rcv_zipcode, + DROP COLUMN salesman_position, + DROP COLUMN text_created_for, + ADD FOREIGN KEY (customer_id) REFERENCES customer (id); + +ALTER TABLE letter_draft + DROP COLUMN close, + DROP COLUMN company_name, + DROP COLUMN employee_position, + DROP COLUMN jobnumber, + DROP COLUMN page_created_for, + DROP COLUMN rcv_address, + DROP COLUMN rcv_city, + DROP COLUMN rcv_contact, + DROP COLUMN rcv_country, + DROP COLUMN rcv_countrycode, + DROP COLUMN rcv_name, + DROP COLUMN rcv_zipcode, + DROP COLUMN salesman_position, + DROP COLUMN text_created_for, + ADD FOREIGN KEY (customer_id) REFERENCES customer (id); diff --git a/templates/print/RB/letter.tex b/templates/print/RB/letter.tex index b76b4c130..1092810df 100644 --- a/templates/print/RB/letter.tex +++ b/templates/print/RB/letter.tex @@ -57,8 +57,6 @@ \vspace{0.5cm} - <%close%> - <%company_name%> \vspace*{0.5cm} @@ -67,16 +65,11 @@ \textbf{<%employee_name%>} -<%employee_position%> - \end{minipage} \begin{minipage}{6cm} \textbf{<%salesman_name%>} -<%salesman_position%> - \end{minipage} \end{document} - diff --git a/templates/webpages/letter/edit.html b/templates/webpages/letter/edit.html index 239c84183..390efcc17 100644 --- a/templates/webpages/letter/edit.html +++ b/templates/webpages/letter/edit.html @@ -33,7 +33,7 @@ - - + @@ -163,7 +163,7 @@
[% 'Customer' | $T8 %]:[% P.customer_vendor_picker('letter.vc_id', letter.vc_id, type='customer') %] + [% P.customer_vendor_picker('letter.customer_id', letter.customer_id, type='customer') %] [%- IF letter.customer_id %] [%- END %] @@ -41,7 +41,7 @@
[% 'Contact Person' | $T8 %][% L.select_tag('letter.cp_id', letter.vc_id ? letter.customer.contacts : [], value_key='cp_id', title_key='full_name', default=letter.cp_id) %][% L.select_tag('letter.cp_id', letter.customer_id ? letter.customer.contacts : [], value_key='cp_id', title_key='full_name', default=letter.cp_id) %]
[% 'Your Reference' | $T8 %]: