Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision e765448c

Von Moritz Bunkus vor mehr als 17 Jahren hinzugefügt

  • ID e765448cae9f91754d3e93b377705f8533e0b842
  • Vorgänger 30531673
  • Nachfolger f6e5b55a

Diese Datei wird nicht benutzt.

Unterschiede anzeigen:

SL/XIII.pm
1
#=====================================================================
2
# LX-Office ERP
3
# Copyright (C) 2004
4
# Based on SQL-Ledger Version 2.1.9
5
# Web http://www.lx-office.org
6
#
7
#
8
# XIII form retrieval
9
#
10
#======================================================================
11

  
12
package XIII;
13

  
14
sub retrieve_form {
15
  $main::lxdebug->enter_sub();
16

  
17
  my ($self, $myconfig, $form) = @_;
18

  
19
  my $dbh   = $form->dbconnect($myconfig);
20
  my $query = qq|SELECT f.line
21
                 FROM xiii_forms f
22
                 WHERE f.file = '$form->{file}'
23
		 AND f.dbname = '$myconfig->{dbname}'
24
		 ORDER BY f.oid|;
25
  my $sth = $dbh->prepare($query);
26
  $sth->execute || $form->dberror($query);
27

  
28
  my $ref;
29

  
30
  while ($ref = $sth->fetchrow_hashref(NAME_lc)) {
31
    push @{ $form->{body} }, $ref->{line};
32
  }
33

  
34
  $sth->finish;
35

  
36
  $dbh->disconnect;
37

  
38
  $main::lxdebug->leave_sub();
39
}
40

  
41
sub delete_form {
42
  $main::lxdebug->enter_sub();
43

  
44
  my ($self, $myconfig, $form) = @_;
45

  
46
  # connect to database, turn AutoCommit off
47
  my $dbh = $form->dbconnect_noauto($myconfig);
48

  
49
  my $query = qq|DELETE FROM xiii_forms
50
                 WHERE file = '$form->{file}'
51
		 AND dbname = '$myconfig->{dbname}'|;
52
  $dbh->do($query) || $form->dberror($query);
53

  
54
  # commit and redirect
55
  $rc = $dbh->commit;
56
  $dbh->disconnect;
57

  
58
  $main::lxdebug->leave_sub();
59

  
60
  return $rc;
61
}
62

  
63
sub save_form {
64
  $main::lxdebug->enter_sub();
65

  
66
  my ($self, $myconfig, $form) = @_;
67

  
68
  # connect to database, turn AutoCommit off
69
  my $dbh = $form->dbconnect_noauto($myconfig);
70

  
71
  my $query = qq|DELETE FROM xiii_forms
72
                 WHERE file = '$form->{file}'
73
		 AND dbname = '$myconfig->{dbname}'|;
74
  $dbh->do($query) || $form->dberror($query);
75

  
76
  $query = qq|INSERT INTO xiii_forms (line, file, dbname)
77
              VALUES (?, '$form->{file}', '$myconfig->{dbname}')|;
78

  
79
  $sth = $dbh->prepare($query);
80

  
81
  foreach $line (split /\r/, $form->{body}) {
82
    $sth->execute($line) || $form->dberror($query);
83
    $sth->finish;
84
  }
85

  
86
  $rc = $dbh->commit;
87
  $dbh->disconnect;
88

  
89
  $main::lxdebug->leave_sub();
90

  
91
  return $rc;
92
}
93

  
94
1;
95

  

Auch abrufbar als: Unified diff