Pflichtenhefte: Unterstützung für an Textblöcke angehängte Bilder
[kivitendo-erp.git] / SL / Controller / CsvImport / Shipto.pm
1 package SL::Controller::CsvImport::Shipto;
2
3 use strict;
4
5 use SL::Helper::Csv;
6
7 use parent qw(SL::Controller::CsvImport::Base);
8
9 use Rose::Object::MakeMethods::Generic
10 (
11  scalar => [ qw(table) ],
12 );
13
14 sub init_class {
15   my ($self) = @_;
16   $self->class('SL::DB::Shipto');
17 }
18
19 sub check_objects {
20   my ($self) = @_;
21
22   $self->controller->track_progress(phase => 'building data', progress => 0);
23
24   my $i;
25   my $num_data = scalar @{ $self->controller->data };
26   foreach my $entry (@{ $self->controller->data }) {
27     $self->controller->track_progress(progress => $i/$num_data * 100) if $i % 100 == 0;
28
29     $self->check_vc($entry, 'trans_id');
30     $entry->{object}->module('CT');
31   } continue {
32     $i++;
33   }
34
35   $self->add_info_columns({ header => $::locale->text('Customer/Vendor'), method => 'vc_name' });
36 }
37
38 sub get_duplicate_check_fields {
39   return {
40     shiptoname_and_shiptostreet => {
41       label     => $::locale->text('Name and Street'),
42       default   => 1,
43       maker     => sub {
44         my $o = shift;
45         return join(
46                  '--',
47                  $o->trans_id,
48                  map(
49                    { s/[\s,\.\-]//g; $_ }
50                    $o->shiptoname,
51                    $o->shiptostreet
52                  )
53         );
54       }
55     },
56
57     shiptoname => {
58       label     => $::locale->text('Name'),
59       default   => 1,
60       maker     => sub {
61         my $o = shift;
62         return join(
63                  '--',
64                  $o->trans_id,
65                  map(
66                    { s/[\s,\.\-]//g; $_ }
67                    $o->shiptoname
68                  )
69         );
70       }
71     },
72
73     shiptostreet => {
74       label     => $::locale->text('Street'),
75       default   => 1,
76       maker     => sub {
77         my $o = shift;
78         return join(
79                  '--',
80                  $o->trans_id,
81                  map(
82                    { s/[\s,\.\-]//g; $_ }
83                    $o->shiptostreet
84                  )
85         );
86       }
87     },
88   };
89 }
90
91 sub field_lengths {
92   return ( shiptoname         => 75,
93            shiptodepartment_1 => 75,
94            shiptodepartment_2 => 75,
95            shiptostreet       => 75,
96            shiptozipcode      => 75,
97            shiptocity         => 75,
98            shiptocountry      => 75,
99            shiptocontact      => 75,
100            shiptophone        => 30,
101            shiptofax          => 30,
102          );
103 }
104
105 sub init_profile {
106   my ($self) = @_;
107
108   my $profile = $self->SUPER::init_profile;
109   delete @{$profile}{qw(module)};
110
111   return $profile;
112 }
113
114 sub setup_displayable_columns {
115   my ($self) = @_;
116
117   $self->SUPER::setup_displayable_columns;
118
119   $self->add_displayable_columns({ name => 'shiptocity',         description => $::locale->text('City')                          },
120                                  { name => 'shiptocontact',      description => $::locale->text('Contact')                       },
121                                  { name => 'shiptocountry',      description => $::locale->text('Country')                       },
122                                  { name => 'shiptodepartment_1', description => $::locale->text('Department 1')                  },
123                                  { name => 'shiptodepartment_2', description => $::locale->text('Department 2')                  },
124                                  { name => 'shiptoemail',        description => $::locale->text('E-mail')                        },
125                                  { name => 'shiptofax',          description => $::locale->text('Fax')                           },
126                                  { name => 'shiptoname',         description => $::locale->text('Name')                          },
127                                  { name => 'shiptophone',        description => $::locale->text('Phone')                         },
128                                  { name => 'shiptostreet',       description => $::locale->text('Street')                        },
129                                  { name => 'shiptozipcode',      description => $::locale->text('Zipcode')                       },
130                                  { name => 'trans_id',           description => $::locale->text('Customer/Vendor (database ID)') },
131                                  { name => 'customer',           description => $::locale->text('Customer (name)')               },
132                                  { name => 'customernumber',     description => $::locale->text('Customer Number')               },
133                                  { name => 'vendor',             description => $::locale->text('Vendor (name)')                 },
134                                  { name => 'vendornumber',       description => $::locale->text('Vendor Number')                 },
135                                 );
136 }
137
138 1;