Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision 7196276b

Von Moritz Bunkus vor fast 9 Jahren hinzugefügt

  • ID 7196276bca4a155d1bcc3947859bc7d4ec1edcd6
  • Vorgänger 17041e6c
  • Nachfolger f2b69169

Brieffunktion: unbenutzte Tabellenspalten entfernt, vc_id → customer_id umbenannt

Unterschiede anzeigen:

SL/Controller/Letter.pm
36 36
  date                  => t8('Date'),
37 37
  subject               => t8('Subject'),
38 38
  letternumber          => t8('Letternumber'),
39
  vc_id                 => t8('Customer'),
39
  customer_id           => t8('Customer'),
40 40
  contact               => t8('Contact'),
41 41
);
42 42

  
......
94 94

  
95 95
  my $letter = $self->letter;
96 96

  
97
  if (!$self->letter->vc_id || !$self->letter->customer) {
97
  if (!$self->letter->customer_id || !$self->letter->customer) {
98 98
    return $self->js
99 99
      ->replaceWith(
100 100
        '#letter_cp_id',
......
108 108
  my $default;
109 109
  if (   $letter->contact
110 110
      && $letter->contact->cp_cv_id
111
      && $letter->contact->cp_cv_id == $letter->vc_id) {
111
      && $letter->contact->cp_cv_id == $letter->customer_id) {
112 112
    $default = $letter->contact->cp_id;
113 113
  } else {
114 114
    $default = '';
......
187 187
  my $greeting_saved      = $::form->{greeting};
188 188
  my $cp_id_saved         = $::form->{cp_id};
189 189

  
190
  $::form->{customer_id} = $self->letter->vc_id;
190
  $::form->{customer_id} = $self->letter->customer_id;
191 191
  IS->customer_details(\%::myconfig, $::form);
192 192

  
193 193
  if (!$cp_id_saved) {
......
405 405
  my $report      = SL::ReportGenerator->new(\%::myconfig, $::form);
406 406
  $self->{report} = $report;
407 407

  
408
  my @columns  = qw(date subject letternumber vc_id contact date);
409
  my @sortable = qw(date subject letternumber vc_id contact date);
408
  my @columns  = qw(date subject letternumber customer_id contact date);
409
  my @sortable = qw(date subject letternumber customer_id contact date);
410 410

  
411 411
  my %column_defs = (
412 412
    date                  => { text => t8('Date'),         sub => sub { $_[0]->date_as_date } },
......
414 414
                               obj_link => sub { $self->url_for(action => 'edit', 'letter.id' => $_[0]->id, callback => $self->models->get_callback) }  },
415 415
    letternumber          => { text => t8('Letternumber'), sub => sub { $_[0]->letternumber },
416 416
                               obj_link => sub { $self->url_for(action => 'edit', 'letter.id' => $_[0]->id, callback => $self->models->get_callback) }  },
417
    vc_id                 => { text => t8('Customer'),      sub => sub { SL::DB::Manager::Customer->find_by_or_create(id => $_[0]->vc_id)->displayable_name } },
417
    customer_id           => { text => t8('Customer'),      sub => sub { SL::DB::Manager::Customer->find_by_or_create(id => $_[0]->customer_id)->displayable_name } },
418 418
    contact               => { text => t8('Contact'),       sub => sub { $_[0]->contact ? $_[0]->contact->full_name : '' } },
419 419
  );
420 420

  
......
571 571
                                           ->assign_attributes(%{ $::form->{letter} });
572 572

  
573 573
  if ($letter->cp_id) {
574
#     $letter->vc_id($letter->contact->cp_cv_id);
574
#     $letter->customer_id($letter->contact->cp_cv_id);
575 575
      # contacts don't have language_id yet
576 576
#     $letter->greeting(GenericTranslations->get(
577 577
#       translation_type => 'greetings::' . ($letter->contact->cp_gender eq 'f' ? 'female' : 'male'),
SL/DB/Letter.pm
7 7
use SL::DB::MetaSetup::Letter;
8 8
use SL::DB::Manager::Letter;
9 9

  
10
__PACKAGE__->meta->add_relationships(
11
  customer  => {
12
    type                   => 'many to one',
13
    class                  => 'SL::DB::Customer',
14
    column_map             => { vc_id => 'id' },
15
  },
16

  
17
);
18

  
19 10
__PACKAGE__->meta->initialize;
20 11

  
21 12
__PACKAGE__->attr_html('body');
SL/DB/MetaSetup/Letter.pm
9 9
__PACKAGE__->meta->table('letter');
10 10

  
11 11
__PACKAGE__->meta->columns(
12
  body              => { type => 'text' },
13
  close             => { type => 'text' },
14
  company_name      => { type => 'text' },
15
  cp_id             => { type => 'integer' },
16
  date              => { type => 'date' },
17
  employee_id       => { type => 'integer' },
18
  employee_position => { type => 'text' },
19
  greeting          => { type => 'text' },
20
  id                => { type => 'integer', not_null => 1, sequence => 'id' },
21
  intnotes          => { type => 'text' },
22
  itime             => { type => 'timestamp', default => 'now()' },
23
  jobnumber         => { type => 'text' },
24
  letternumber      => { type => 'text' },
25
  mtime             => { type => 'timestamp' },
26
  page_created_for  => { type => 'text' },
27
  rcv_address       => { type => 'text' },
28
  rcv_city          => { type => 'text' },
29
  rcv_contact       => { type => 'text' },
30
  rcv_country       => { type => 'text' },
31
  rcv_countrycode   => { type => 'text' },
32
  rcv_name          => { type => 'text' },
33
  rcv_zipcode       => { type => 'text' },
34
  reference         => { type => 'text' },
35
  salesman_id       => { type => 'integer' },
36
  salesman_position => { type => 'text' },
37
  subject           => { type => 'text' },
38
  text_created_for  => { type => 'text' },
39
  vc_id             => { type => 'integer', not_null => 1 },
12
  body         => { type => 'text' },
13
  cp_id        => { type => 'integer' },
14
  customer_id  => { type => 'integer', not_null => 1 },
15
  date         => { type => 'date' },
16
  employee_id  => { type => 'integer' },
17
  greeting     => { type => 'text' },
18
  id           => { type => 'integer', not_null => 1, sequence => 'id' },
19
  intnotes     => { type => 'text' },
20
  itime        => { type => 'timestamp', default => 'now()' },
21
  letternumber => { type => 'text' },
22
  mtime        => { type => 'timestamp' },
23
  reference    => { type => 'text' },
24
  salesman_id  => { type => 'integer' },
25
  subject      => { type => 'text' },
40 26
);
41 27

  
42 28
__PACKAGE__->meta->primary_key_columns([ 'id' ]);
......
49 35
    key_columns => { cp_id => 'cp_id' },
50 36
  },
51 37

  
38
  customer => {
39
    class       => 'SL::DB::Customer',
40
    key_columns => { customer_id => 'id' },
41
  },
42

  
52 43
  employee => {
53 44
    class       => 'SL::DB::Employee',
54 45
    key_columns => { employee_id => 'id' },
SL/DB/MetaSetup/LetterDraft.pm
9 9
__PACKAGE__->meta->table('letter_draft');
10 10

  
11 11
__PACKAGE__->meta->columns(
12
  body              => { type => 'text' },
13
  close             => { type => 'text' },
14
  company_name      => { type => 'text' },
15
  cp_id             => { type => 'integer' },
16
  date              => { type => 'date' },
17
  employee_id       => { type => 'integer' },
18
  employee_position => { type => 'text' },
19
  greeting          => { type => 'text' },
20
  id                => { type => 'integer', not_null => 1, sequence => 'id' },
21
  intnotes          => { type => 'text' },
22
  itime             => { type => 'timestamp', default => 'now()' },
23
  jobnumber         => { type => 'text' },
24
  letternumber      => { type => 'text' },
25
  mtime             => { type => 'timestamp' },
26
  page_created_for  => { type => 'text' },
27
  rcv_address       => { type => 'text' },
28
  rcv_city          => { type => 'text' },
29
  rcv_contact       => { type => 'text' },
30
  rcv_country       => { type => 'text' },
31
  rcv_countrycode   => { type => 'text' },
32
  rcv_name          => { type => 'text' },
33
  rcv_zipcode       => { type => 'text' },
34
  reference         => { type => 'text' },
35
  salesman_id       => { type => 'integer' },
36
  salesman_position => { type => 'text' },
37
  subject           => { type => 'text' },
38
  text_created_for  => { type => 'text' },
39
  vc_id             => { type => 'integer', not_null => 1 },
12
  body         => { type => 'text' },
13
  cp_id        => { type => 'integer' },
14
  customer_id  => { type => 'integer', not_null => 1 },
15
  date         => { type => 'date' },
16
  employee_id  => { type => 'integer' },
17
  greeting     => { type => 'text' },
18
  id           => { type => 'integer', not_null => 1, sequence => 'id' },
19
  intnotes     => { type => 'text' },
20
  itime        => { type => 'timestamp', default => 'now()' },
21
  letternumber => { type => 'text' },
22
  mtime        => { type => 'timestamp' },
23
  reference    => { type => 'text' },
24
  salesman_id  => { type => 'integer' },
25
  subject      => { type => 'text' },
40 26
);
41 27

  
42 28
__PACKAGE__->meta->primary_key_columns([ 'id' ]);
......
49 35
    key_columns => { cp_id => 'cp_id' },
50 36
  },
51 37

  
38
  customer => {
39
    class       => 'SL::DB::Customer',
40
    key_columns => { customer_id => 'id' },
41
  },
42

  
52 43
  employee => {
53 44
    class       => 'SL::DB::Employee',
54 45
    key_columns => { employee_id => 'id' },
sql/Pg-upgrade2/letter_cleanup.sql
1
-- @tag: letter_cleanup
2
-- @description: Tabelle »letter«: Unbenutzte Spalten entfernen und andere Spalten umbenennen
3
-- @depends: release_3_4_0
4

  
5
ALTER TABLE letter       RENAME COLUMN vc_id TO customer_id;
6
ALTER TABLE letter_draft RENAME COLUMN vc_id TO customer_id;
7

  
8
ALTER TABLE letter
9
  DROP COLUMN close,
10
  DROP COLUMN company_name,
11
  DROP COLUMN employee_position,
12
  DROP COLUMN jobnumber,
13
  DROP COLUMN page_created_for,
14
  DROP COLUMN rcv_address,
15
  DROP COLUMN rcv_city,
16
  DROP COLUMN rcv_contact,
17
  DROP COLUMN rcv_country,
18
  DROP COLUMN rcv_countrycode,
19
  DROP COLUMN rcv_name,
20
  DROP COLUMN rcv_zipcode,
21
  DROP COLUMN salesman_position,
22
  DROP COLUMN text_created_for,
23
  ADD FOREIGN KEY (customer_id) REFERENCES customer (id);
24

  
25
ALTER TABLE letter_draft
26
  DROP COLUMN close,
27
  DROP COLUMN company_name,
28
  DROP COLUMN employee_position,
29
  DROP COLUMN jobnumber,
30
  DROP COLUMN page_created_for,
31
  DROP COLUMN rcv_address,
32
  DROP COLUMN rcv_city,
33
  DROP COLUMN rcv_contact,
34
  DROP COLUMN rcv_country,
35
  DROP COLUMN rcv_countrycode,
36
  DROP COLUMN rcv_name,
37
  DROP COLUMN rcv_zipcode,
38
  DROP COLUMN salesman_position,
39
  DROP COLUMN text_created_for,
40
  ADD FOREIGN KEY (customer_id) REFERENCES customer (id);
templates/print/RB/letter.tex
57 57

  
58 58
\vspace{0.5cm}
59 59

  
60
  <%close%>
61

  
62 60
  <%company_name%>
63 61

  
64 62
\vspace*{0.5cm}
......
67 65

  
68 66
\textbf{<%employee_name%>}
69 67

  
70
<%employee_position%>
71

  
72 68
\end{minipage}
73 69
\begin{minipage}{6cm}
74 70

  
75 71
\textbf{<%salesman_name%>}
76 72

  
77
<%salesman_position%>
78

  
79 73
\end{minipage}
80 74

  
81 75
\end{document}
82

  
templates/webpages/letter/edit.html
33 33
   <table width=90%>
34 34
    <tr>
35 35
     <th align='right'>[% 'Customer' | $T8 %]:</th>
36
     <td>[% P.customer_vendor_picker('letter.vc_id', letter.vc_id, type='customer') %]
36
     <td>[% P.customer_vendor_picker('letter.customer_id', letter.customer_id, type='customer') %]
37 37
[%- IF letter.customer_id %]
38 38
      <input type="button" value="[% 'Details (one letter abbreviation)' | $T8 %]" onclick="show_vc_details('customer')">
39 39
[%- END %]
......
41 41
    </tr>
42 42
    <tr>
43 43
     <th align='right'>[% 'Contact Person' | $T8 %]</th>
44
     <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>
44
     <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>
45 45
    </tr>
46 46
    <tr>
47 47
     <th align='right'>[% 'Your Reference' | $T8 %]:</th>
......
163 163

  
164 164
<script type='text/javascript'>
165 165
  $(function(){
166
    $('#letter_vc_id').change(function(){
166
    $('#letter_customer_id').change(function(){
167 167
      var data = $('form').serializeArray();
168 168
      data.push({ name: 'action_update_contacts', value: 1 });
169 169
      $.post('controller.pl', data, kivi.eval_json_result);
templates/webpages/letter/search.html
19 19
  </tr>
20 20
  <tr>
21 21
   <td align="right">[% 'Customer' | $T8 %]</td>
22
   <td>[% L.customer_vendor_picker('filter.vc_id', filter.vc_id, type='customer', style='width:250px') %]</td>
22
   <td>[% L.customer_vendor_picker('filter.customer_id', filter.customer_id, type='customer', style='width:250px') %]</td>
23 23
  </tr>
24 24

  
25 25
  <tr>

Auch abrufbar als: Unified diff