Revision 9ebaa094
Von Moritz Bunkus vor mehr als 8 Jahren hinzugefügt
SL/Common.pm | ||
---|---|---|
100 | 100 |
return $parts; |
101 | 101 |
} |
102 | 102 |
|
103 |
sub retrieve_projects { |
|
104 |
$main::lxdebug->enter_sub(); |
|
105 |
|
|
106 |
my ($self, $myconfig, $form, $order_by, $order_dir) = @_; |
|
107 |
|
|
108 |
my $dbh = $form->dbconnect($myconfig); |
|
109 |
|
|
110 |
my (@filter_values, $filter); |
|
111 |
if ($form->{"projectnumber"}) { |
|
112 |
$filter .= qq| AND (projectnumber ILIKE ?)|; |
|
113 |
push(@filter_values, '%' . $form->{"projectnumber"} . '%'); |
|
114 |
} |
|
115 |
if ($form->{"description"}) { |
|
116 |
$filter .= qq| AND (description ILIKE ?)|; |
|
117 |
push(@filter_values, '%' . $form->{"description"} . '%'); |
|
118 |
} |
|
119 |
substr($filter, 1, 3) = "WHERE" if ($filter); |
|
120 |
|
|
121 |
$order_by =~ s/[^a-zA-Z_]//g; |
|
122 |
$order_dir = $order_dir ? "ASC" : "DESC"; |
|
123 |
|
|
124 |
my $query = |
|
125 |
qq|SELECT id, projectnumber, description | . |
|
126 |
qq|FROM project $filter | . |
|
127 |
qq|ORDER BY $order_by $order_dir|; |
|
128 |
my $sth = $dbh->prepare($query); |
|
129 |
$sth->execute(@filter_values) || $form->dberror($query . " (" . join(", ", @filter_values) . ")"); |
|
130 |
my $projects = []; |
|
131 |
while (my $ref = $sth->fetchrow_hashref()) { |
|
132 |
push(@{$projects}, $ref); |
|
133 |
} |
|
134 |
$sth->finish(); |
|
135 |
$dbh->disconnect(); |
|
136 |
|
|
137 |
$main::lxdebug->leave_sub(); |
|
138 |
|
|
139 |
return $projects; |
|
140 |
} |
|
141 |
|
|
142 |
sub retrieve_employees { |
|
143 |
$main::lxdebug->enter_sub(); |
|
144 |
|
|
145 |
my ($self, $myconfig, $form, $order_by, $order_dir) = @_; |
|
146 |
|
|
147 |
my $dbh = $form->dbconnect($myconfig); |
|
148 |
|
|
149 |
my (@filter_values, $filter); |
|
150 |
if ($form->{"name"}) { |
|
151 |
$filter .= qq| AND (name ILIKE ?)|; |
|
152 |
push(@filter_values, '%' . $form->{"name"} . '%'); |
|
153 |
} |
|
154 |
substr($filter, 1, 3) = "WHERE" if ($filter); |
|
155 |
|
|
156 |
$order_by =~ s/[^a-zA-Z_]//g; |
|
157 |
$order_dir = $order_dir ? "ASC" : "DESC"; |
|
158 |
|
|
159 |
my $query = |
|
160 |
qq|SELECT id, name | . |
|
161 |
qq|FROM employee $filter | . |
|
162 |
qq|ORDER BY $order_by $order_dir|; |
|
163 |
my $sth = $dbh->prepare($query); |
|
164 |
$sth->execute(@filter_values) || $form->dberror($query . " (" . join(", ", @filter_values) . ")"); |
|
165 |
my $employees = []; |
|
166 |
while (my $ref = $sth->fetchrow_hashref()) { |
|
167 |
push(@{$employees}, $ref); |
|
168 |
} |
|
169 |
$sth->finish(); |
|
170 |
$dbh->disconnect(); |
|
171 |
|
|
172 |
$main::lxdebug->leave_sub(); |
|
173 |
|
|
174 |
return $employees; |
|
175 |
} |
|
176 |
|
|
177 | 103 |
sub retrieve_customers_or_vendors { |
178 | 104 |
$main::lxdebug->enter_sub(); |
179 | 105 |
|
Auch abrufbar als: Unified diff
SL::Common: unbenutzte Funktionen retrieve_{projects,employees} entfernt