date => t8('Date'),
subject => t8('Subject'),
letternumber => t8('Letternumber'),
- vc_id => t8('Customer'),
+ customer_id => t8('Customer'),
contact => t8('Contact'),
);
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',
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 = '';
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) {
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 } },
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 : '' } },
);
->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'),
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');
__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' ]);
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' },
__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' ]);
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' },
--- /dev/null
+-- @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);
\vspace{0.5cm}
- <%close%>
-
<%company_name%>
\vspace*{0.5cm}
\textbf{<%employee_name%>}
-<%employee_position%>
-
\end{minipage}
\begin{minipage}{6cm}
\textbf{<%salesman_name%>}
-<%salesman_position%>
-
\end{minipage}
\end{document}
-
<table width=90%>
<tr>
<th align='right'>[% 'Customer' | $T8 %]:</th>
- <td>[% P.customer_vendor_picker('letter.vc_id', letter.vc_id, type='customer') %]
+ <td>[% P.customer_vendor_picker('letter.customer_id', letter.customer_id, type='customer') %]
[%- IF letter.customer_id %]
<input type="button" value="[% 'Details (one letter abbreviation)' | $T8 %]" onclick="show_vc_details('customer')">
[%- END %]
</tr>
<tr>
<th align='right'>[% 'Contact Person' | $T8 %]</th>
- <td>[% L.select_tag('letter.cp_id', letter.vc_id ? letter.customer.contacts : [], value_key='cp_id', title_key='full_name', default=letter.cp_id) %]</td>
+ <td>[% L.select_tag('letter.cp_id', letter.customer_id ? letter.customer.contacts : [], value_key='cp_id', title_key='full_name', default=letter.cp_id) %]</td>
</tr>
<tr>
<th align='right'>[% 'Your Reference' | $T8 %]:</th>
<script type='text/javascript'>
$(function(){
- $('#letter_vc_id').change(function(){
+ $('#letter_customer_id').change(function(){
var data = $('form').serializeArray();
data.push({ name: 'action_update_contacts', value: 1 });
$.post('controller.pl', data, kivi.eval_json_result);
</tr>
<tr>
<td align="right">[% 'Customer' | $T8 %]</td>
- <td>[% L.customer_vendor_picker('filter.vc_id', filter.vc_id, type='customer', style='width:250px') %]</td>
+ <td>[% L.customer_vendor_picker('filter.customer_id', filter.customer_id, type='customer', style='width:250px') %]</td>
</tr>
<tr>