Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision c6fcdedb

Von Sven Schöling vor etwa 3 Jahren hinzugefügt

  • ID c6fcdedba1b71725e5d09c50af5513df5099421b
  • Vorgänger bdad8942
  • Nachfolger a7b4d288

Inventory: before hooks für trans_id, shippingdate und employee

Unterschiede anzeigen:

SL/DB/Inventory.pm
10 10

  
11 11
__PACKAGE__->meta->initialize;
12 12

  
13
__PACKAGE__->before_save(\&_before_save_create_trans_id);
14
__PACKAGE__->before_save(\&_before_save_set_shippingdate);
15
__PACKAGE__->before_save(\&_before_save_set_employee);
16

  
13 17
# part accessor is badly named
14 18
sub part {
15 19
  goto &parts;
16 20
}
17 21

  
22
sub _before_save_create_trans_id {
23
  my ($self, %params) = @_;
24

  
25
  return 1 if $self->trans_id;
26

  
27
  my ($trans_id) = selectrow_query($::form, SL::DB->client->dbh, qq|SELECT nextval('id')|);
28

  
29
  $self->trans_id($trans_id);
30

  
31
  return 1;
32
}
33

  
34
sub _before_save_set_shippingdate {
35
  my ($self, %params) = @_;
36

  
37
  return 1 if $self->shippingdate;
38

  
39
  $self->shippingdate(DateTime->now);
40

  
41
  return 1;
42
}
43

  
44
sub _before_save_set_employee {
45
  my ($self, %params) = @_;
46

  
47
  return 1 if $self->emplyee_id;
48

  
49
  $self->employee(SL::DB::Manager::Employee->current);
50

  
51
  return 1;
52
}
18 53
1;

Auch abrufbar als: Unified diff