1 # @tag: erzeugnisnummern
2 # @description: Erzeugnisnummern und Artikelnummern sollen eindeutig sein.
3 # @depends: release_3_0_0
4 package SL::DBUpgrade2::erzeugnisnummern;
9 use parent qw(SL::DBUpgrade2::Base);
16 if (defined $::form->{upgrade_action} && $::form->{upgrade_action} eq 'filter_parts') {
17 return $self->filter_parts($self);
20 if ( $::form->{'continued'} ) {
22 foreach my $i (1 .. $::form->{rowcount}) {
23 $update_query = qq|UPDATE parts SET partnumber = '| . $::form->{"partnumber_$i"} . qq|' WHERE id = | . $::form->{"partid_$i"};
24 $self->db_query($update_query);
28 my $query = qq|SELECT id, partnumber, description, unit, notes, assembly, ean, inventory_accno_id, obsolete
30 WHERE (SELECT COUNT(*)
32 WHERE p.partnumber=pa.partnumber)
34 ORDER BY partnumber;|;
36 $::form->{PARTS} = [ selectall_hashref_query($::form, $self->dbh, $query) ];
38 if ( scalar @{ $::form->{PARTS} } > 0 ) {
43 $query = qq|ALTER TABLE parts ADD UNIQUE (partnumber)|;
44 $self->db_query($query);
46 $query = qq|ALTER TABLE defaults ADD assemblynumber TEXT|;
47 $self->db_query($query);
51 sub print_error_message {
52 print $::form->parse_html_template("dbupgrade/erzeugnisnummern");
61 if ( $::form->{filter_partnumber} ) {
62 $where .= ' AND partnumber ILIKE ?';
63 push(@values, like( $::form->{filter_partnumber} ));
66 if ($::form->{filter_description}) {
67 $where .= ' AND description ILIKE ?';
68 push(@values, like($::form->{filter_description}));
71 if ($::form->{filter_notes}) {
72 $where .= ' AND notes ILIKE ?';
73 push(@values, like($::form->{filter_notes}));
76 if ($::form->{filter_ean}) {
77 $where .= ' AND ean ILIKE ?';
78 push(@values, like($::form->{filter_ean}));
81 if ($::form->{filter_type} eq 'assembly') {
82 $where .= " AND part_type = 'assembly'";
85 if ($::form->{filter_type} eq 'service') {
86 $where .= " AND part_type = 'service'";
89 if ($::form->{filter_type} eq 'part') {
90 $where .= " AND part_type = 'part'";
93 if ($::form->{filter_obsolete} eq 'obsolete') {
94 $where .= ' AND obsolete';
97 if ($::form->{filter_obsolete} eq 'valid') {
98 $where .= ' AND NOT obsolete';
101 my $query = qq|SELECT id, partnumber, description, unit, notes, assembly, ean, inventory_accno_id, obsolete
104 ORDER BY partnumber|;
106 $::form->{ALL_PARTS} = [ selectall_hashref_query($::form, $self->dbh, $query, @values) ];
108 print $::form->parse_html_template("dbupgrade/show_partlist");