1 |
dpavlin |
1.1 |
# Project: Clipping |
2 |
|
|
# Author: Nelson Ferraz <nferraz@phperl.com> |
3 |
|
|
# Date: 2003-08-14 |
4 |
|
|
|
5 |
|
|
# Configuration |
6 |
|
|
|
7 |
|
|
# Modules |
8 |
|
|
use lib "./lib"; |
9 |
|
|
|
10 |
|
|
use c_customer; |
11 |
|
|
use c_source; |
12 |
|
|
use c_type; |
13 |
|
|
use c_news; |
14 |
|
|
|
15 |
|
|
# Database configuration -- MODIFY THIS LINE!!! |
16 |
|
|
%conf = ( |
17 |
|
|
db => "dbname=nferraz user=nferraz" |
18 |
|
|
); |
19 |
|
|
|
20 |
|
|
# Valid actions |
21 |
|
|
|
22 |
|
|
%action = ( |
23 |
|
|
'print_source' => '&print_source', |
24 |
|
|
'select_c_customer' => '&select_c_customer', |
25 |
|
|
'view_c_customer' => '&view_c_customer', |
26 |
|
|
'insert_c_customer' => '&insert_c_customer', |
27 |
|
|
'update_c_customer' => '&update_c_customer', |
28 |
|
|
'delete_c_customer' => '&delete_c_customer', |
29 |
|
|
'download_c_customer' => '&download_c_customer', |
30 |
|
|
'select_c_source' => '&select_c_source', |
31 |
|
|
'view_c_source' => '&view_c_source', |
32 |
|
|
'insert_c_source' => '&insert_c_source', |
33 |
|
|
'update_c_source' => '&update_c_source', |
34 |
|
|
'delete_c_source' => '&delete_c_source', |
35 |
|
|
'download_c_source' => '&download_c_source', |
36 |
|
|
'select_c_type' => '&select_c_type', |
37 |
|
|
'view_c_type' => '&view_c_type', |
38 |
|
|
'insert_c_type' => '&insert_c_type', |
39 |
|
|
'update_c_type' => '&update_c_type', |
40 |
|
|
'delete_c_type' => '&delete_c_type', |
41 |
|
|
'download_c_type' => '&download_c_type', |
42 |
|
|
'select_c_news' => '&select_c_news', |
43 |
|
|
'view_c_news' => '&view_c_news', |
44 |
|
|
'insert_c_news' => '&insert_c_news', |
45 |
|
|
'update_c_news' => '&update_c_news', |
46 |
|
|
'delete_c_news' => '&delete_c_news', |
47 |
|
|
'download_c_news' => '&download_c_news' |
48 |
|
|
); |
49 |
|
|
|
50 |
|
|
# Events (actions raised automatically by templates) |
51 |
|
|
%event = ( |
52 |
|
|
|
53 |
|
|
'before_pg_sel_c_customer' => '&before_pg_sel_c_customer', |
54 |
|
|
'before_pg_ins_c_customer' => '&before_pg_ins_c_customer', |
55 |
|
|
'before_pg_upd_c_customer' => '&before_pg_upd_c_customer', |
56 |
|
|
'before_pg_detail_c_customer' => '&before_pg_detail_c_customer', |
57 |
|
|
|
58 |
|
|
'before_pg_sel_c_source' => '&before_pg_sel_c_source', |
59 |
|
|
'before_pg_ins_c_source' => '&before_pg_ins_c_source', |
60 |
|
|
'before_pg_upd_c_source' => '&before_pg_upd_c_source', |
61 |
|
|
'before_pg_detail_c_source' => '&before_pg_detail_c_source', |
62 |
|
|
|
63 |
|
|
'before_pg_sel_c_type' => '&before_pg_sel_c_type', |
64 |
|
|
'before_pg_ins_c_type' => '&before_pg_ins_c_type', |
65 |
|
|
'before_pg_upd_c_type' => '&before_pg_upd_c_type', |
66 |
|
|
'before_pg_detail_c_type' => '&before_pg_detail_c_type', |
67 |
|
|
|
68 |
|
|
'before_pg_sel_c_news' => '&before_pg_sel_c_news', |
69 |
|
|
'before_pg_ins_c_news' => '&before_pg_ins_c_news', |
70 |
|
|
'before_pg_upd_c_news' => '&before_pg_upd_c_news', |
71 |
|
|
'before_pg_detail_c_news' => '&before_pg_detail_c_news', |
72 |
|
|
|
73 |
|
|
'before_count_c_news_by_c_source' => '&count_c_news_by_c_source', |
74 |
|
|
|
75 |
|
|
'before_count_c_news_by_c_customer' => '&count_c_news_by_c_customer', |
76 |
|
|
|
77 |
|
|
'before_count_c_news_by_c_type' => '&count_c_news_by_c_type', |
78 |
|
|
|
79 |
|
|
'beforePrint' => '&beforePrint' |
80 |
|
|
); |
81 |
|
|
|
82 |
|
|
####### ACTIONS ####### |
83 |
|
|
|
84 |
|
|
sub print_source { |
85 |
|
|
# Print template source code |
86 |
|
|
|
87 |
|
|
my $template = $in->{'template'}; |
88 |
|
|
if ($template =~ /(\w+)\.tt2/) { |
89 |
|
|
$template = "../templates/$1.tt2"; |
90 |
|
|
} else { |
91 |
|
|
die "Invalid template name '$template'\n"; |
92 |
|
|
} |
93 |
|
|
|
94 |
|
|
open (FILE,$template) or die "Can't read '$template': $!\n"; |
95 |
|
|
my @source = <FILE>; |
96 |
|
|
close FILE; |
97 |
|
|
|
98 |
|
|
print "Content-type: text/html\n\n"; |
99 |
|
|
print "<PRE>"; |
100 |
|
|
foreach my $r (@source) { |
101 |
|
|
$r =~ s/\</\</g; |
102 |
|
|
$r =~ s/\>/\>/g; |
103 |
|
|
$r =~ s/\[\%(.+?)\%\]/\<span style\=\"background-color\:\#ffffcc\"\>\[\%$1\%\]\<\/span\>/g; |
104 |
|
|
|
105 |
|
|
if ($r =~ /(\w+\.tt2)/) { |
106 |
|
|
my $tmpl = $1; |
107 |
|
|
my $link = "<a href=\"$out->{'script_name'}?action=print_source&template=$tmpl\">$tmpl</a>"; |
108 |
|
|
$r =~ s/$tmpl/$link/g; |
109 |
|
|
} |
110 |
|
|
print $r; |
111 |
|
|
} |
112 |
|
|
print "</PRE>"; |
113 |
|
|
exit; |
114 |
|
|
} |
115 |
|
|
|
116 |
|
|
### |
117 |
|
|
|
118 |
|
|
sub select_c_customer { |
119 |
|
|
my $c_customer = new c_customer(\$conn); |
120 |
|
|
my @c_customer = $c_customer->select($in); |
121 |
|
|
|
122 |
|
|
$out->{'select_c_customer'} = \@c_customer; |
123 |
|
|
} |
124 |
|
|
|
125 |
|
|
### |
126 |
|
|
|
127 |
|
|
sub view_c_customer { |
128 |
|
|
my $c_customer = new c_customer(\$conn); |
129 |
|
|
my @view_c_customer = $c_customer->view($in); |
130 |
|
|
|
131 |
|
|
$out->{'view_c_customer'} = \@view_c_customer; |
132 |
|
|
} |
133 |
|
|
|
134 |
|
|
### |
135 |
|
|
|
136 |
|
|
|
137 |
|
|
sub insert_c_customer { |
138 |
|
|
my $c_customer = new c_customer(\$conn); |
139 |
|
|
$c_customer->insert($in); |
140 |
|
|
&_clean_c_customer_params; |
141 |
|
|
} |
142 |
|
|
|
143 |
|
|
### |
144 |
|
|
|
145 |
|
|
sub update_c_customer { |
146 |
|
|
my $c_customer = new c_customer(\$conn); |
147 |
|
|
$c_customer->update($in); |
148 |
|
|
&_clean_c_customer_params; |
149 |
|
|
} |
150 |
|
|
|
151 |
|
|
### |
152 |
|
|
|
153 |
|
|
sub delete_c_customer { |
154 |
|
|
my $c_customer = new c_customer(\$conn); |
155 |
|
|
$c_customer->delete($in); |
156 |
|
|
&_clean_c_customer_params; |
157 |
|
|
} |
158 |
|
|
|
159 |
|
|
### |
160 |
|
|
|
161 |
|
|
sub download_c_customer { |
162 |
|
|
# Print CSV file and exit |
163 |
|
|
my $c_customer = new c_customer(\$conn); |
164 |
|
|
my @view_c_customer = $c_customer->view($in); |
165 |
|
|
|
166 |
|
|
my @keys = sort keys %{$view_c_customer[0]}; |
167 |
|
|
|
168 |
|
|
print "Content-type: text/plain\n\n"; |
169 |
|
|
|
170 |
|
|
print "# ", join (";", @keys), "\n"; # "key1","key2", ... "keyn" |
171 |
|
|
|
172 |
|
|
foreach my $c_customer (@view_c_customer) { |
173 |
|
|
my @values = (); |
174 |
|
|
foreach my $key (@keys) { |
175 |
|
|
my $value = $c_customer->{$key}; |
176 |
|
|
$value =~ s/\t/\\t/gs; |
177 |
|
|
$value =~ s/\r/\\r/gs; |
178 |
|
|
$value =~ s/\n/\\n/gs; |
179 |
|
|
$value =~ s/\;/\%3B/gs; |
180 |
|
|
push @values, $value; |
181 |
|
|
} |
182 |
|
|
print join (";", @values), "\n"; |
183 |
|
|
} |
184 |
|
|
|
185 |
|
|
exit; |
186 |
|
|
|
187 |
|
|
} |
188 |
|
|
|
189 |
|
|
### |
190 |
|
|
|
191 |
|
|
sub _clean_c_customer_params { |
192 |
|
|
# clean input params |
193 |
|
|
delete $in->{'c_customer_id'}; |
194 |
|
|
delete $in->{'c_customer_name'}; |
195 |
|
|
delete $in->{'c_customer_phone'}; |
196 |
|
|
delete $in->{'c_customer_email'}; |
197 |
|
|
delete $in->{'c_customer_notes'}; |
198 |
|
|
} |
199 |
|
|
|
200 |
|
|
### |
201 |
|
|
|
202 |
|
|
|
203 |
|
|
|
204 |
|
|
|
205 |
|
|
sub select_c_source { |
206 |
|
|
my $c_source = new c_source(\$conn); |
207 |
|
|
my @c_source = $c_source->select($in); |
208 |
|
|
|
209 |
|
|
$out->{'select_c_source'} = \@c_source; |
210 |
|
|
} |
211 |
|
|
|
212 |
|
|
### |
213 |
|
|
|
214 |
|
|
sub view_c_source { |
215 |
|
|
my $c_source = new c_source(\$conn); |
216 |
|
|
my @view_c_source = $c_source->view($in); |
217 |
|
|
|
218 |
|
|
$out->{'view_c_source'} = \@view_c_source; |
219 |
|
|
} |
220 |
|
|
|
221 |
|
|
### |
222 |
|
|
|
223 |
|
|
|
224 |
|
|
sub insert_c_source { |
225 |
|
|
my $c_source = new c_source(\$conn); |
226 |
|
|
$c_source->insert($in); |
227 |
|
|
&_clean_c_source_params; |
228 |
|
|
} |
229 |
|
|
|
230 |
|
|
### |
231 |
|
|
|
232 |
|
|
sub update_c_source { |
233 |
|
|
my $c_source = new c_source(\$conn); |
234 |
|
|
$c_source->update($in); |
235 |
|
|
&_clean_c_source_params; |
236 |
|
|
} |
237 |
|
|
|
238 |
|
|
### |
239 |
|
|
|
240 |
|
|
sub delete_c_source { |
241 |
|
|
my $c_source = new c_source(\$conn); |
242 |
|
|
$c_source->delete($in); |
243 |
|
|
&_clean_c_source_params; |
244 |
|
|
} |
245 |
|
|
|
246 |
|
|
### |
247 |
|
|
|
248 |
|
|
sub download_c_source { |
249 |
|
|
# Print CSV file and exit |
250 |
|
|
my $c_source = new c_source(\$conn); |
251 |
|
|
my @view_c_source = $c_source->view($in); |
252 |
|
|
|
253 |
|
|
my @keys = sort keys %{$view_c_source[0]}; |
254 |
|
|
|
255 |
|
|
print "Content-type: text/plain\n\n"; |
256 |
|
|
|
257 |
|
|
print "# ", join (";", @keys), "\n"; # "key1","key2", ... "keyn" |
258 |
|
|
|
259 |
|
|
foreach my $c_source (@view_c_source) { |
260 |
|
|
my @values = (); |
261 |
|
|
foreach my $key (@keys) { |
262 |
|
|
my $value = $c_source->{$key}; |
263 |
|
|
$value =~ s/\t/\\t/gs; |
264 |
|
|
$value =~ s/\r/\\r/gs; |
265 |
|
|
$value =~ s/\n/\\n/gs; |
266 |
|
|
$value =~ s/\;/\%3B/gs; |
267 |
|
|
push @values, $value; |
268 |
|
|
} |
269 |
|
|
print join (";", @values), "\n"; |
270 |
|
|
} |
271 |
|
|
|
272 |
|
|
exit; |
273 |
|
|
|
274 |
|
|
} |
275 |
|
|
|
276 |
|
|
### |
277 |
|
|
|
278 |
|
|
sub _clean_c_source_params { |
279 |
|
|
# clean input params |
280 |
|
|
delete $in->{'c_source_id'}; |
281 |
|
|
delete $in->{'c_source_description'}; |
282 |
|
|
delete $in->{'c_source_notes'}; |
283 |
|
|
} |
284 |
|
|
|
285 |
|
|
### |
286 |
|
|
|
287 |
|
|
|
288 |
|
|
|
289 |
|
|
|
290 |
|
|
sub select_c_type { |
291 |
|
|
my $c_type = new c_type(\$conn); |
292 |
|
|
my @c_type = $c_type->select($in); |
293 |
|
|
|
294 |
|
|
$out->{'select_c_type'} = \@c_type; |
295 |
|
|
} |
296 |
|
|
|
297 |
|
|
### |
298 |
|
|
|
299 |
|
|
sub view_c_type { |
300 |
|
|
my $c_type = new c_type(\$conn); |
301 |
|
|
my @view_c_type = $c_type->view($in); |
302 |
|
|
|
303 |
|
|
$out->{'view_c_type'} = \@view_c_type; |
304 |
|
|
} |
305 |
|
|
|
306 |
|
|
### |
307 |
|
|
|
308 |
|
|
|
309 |
|
|
sub insert_c_type { |
310 |
|
|
my $c_type = new c_type(\$conn); |
311 |
|
|
$c_type->insert($in); |
312 |
|
|
&_clean_c_type_params; |
313 |
|
|
} |
314 |
|
|
|
315 |
|
|
### |
316 |
|
|
|
317 |
|
|
sub update_c_type { |
318 |
|
|
my $c_type = new c_type(\$conn); |
319 |
|
|
$c_type->update($in); |
320 |
|
|
&_clean_c_type_params; |
321 |
|
|
} |
322 |
|
|
|
323 |
|
|
### |
324 |
|
|
|
325 |
|
|
sub delete_c_type { |
326 |
|
|
my $c_type = new c_type(\$conn); |
327 |
|
|
$c_type->delete($in); |
328 |
|
|
&_clean_c_type_params; |
329 |
|
|
} |
330 |
|
|
|
331 |
|
|
### |
332 |
|
|
|
333 |
|
|
sub download_c_type { |
334 |
|
|
# Print CSV file and exit |
335 |
|
|
my $c_type = new c_type(\$conn); |
336 |
|
|
my @view_c_type = $c_type->view($in); |
337 |
|
|
|
338 |
|
|
my @keys = sort keys %{$view_c_type[0]}; |
339 |
|
|
|
340 |
|
|
print "Content-type: text/plain\n\n"; |
341 |
|
|
|
342 |
|
|
print "# ", join (";", @keys), "\n"; # "key1","key2", ... "keyn" |
343 |
|
|
|
344 |
|
|
foreach my $c_type (@view_c_type) { |
345 |
|
|
my @values = (); |
346 |
|
|
foreach my $key (@keys) { |
347 |
|
|
my $value = $c_type->{$key}; |
348 |
|
|
$value =~ s/\t/\\t/gs; |
349 |
|
|
$value =~ s/\r/\\r/gs; |
350 |
|
|
$value =~ s/\n/\\n/gs; |
351 |
|
|
$value =~ s/\;/\%3B/gs; |
352 |
|
|
push @values, $value; |
353 |
|
|
} |
354 |
|
|
print join (";", @values), "\n"; |
355 |
|
|
} |
356 |
|
|
|
357 |
|
|
exit; |
358 |
|
|
|
359 |
|
|
} |
360 |
|
|
|
361 |
|
|
### |
362 |
|
|
|
363 |
|
|
sub _clean_c_type_params { |
364 |
|
|
# clean input params |
365 |
|
|
delete $in->{'c_type_id'}; |
366 |
|
|
delete $in->{'c_type_description'}; |
367 |
|
|
delete $in->{'c_type_notes'}; |
368 |
|
|
} |
369 |
|
|
|
370 |
|
|
### |
371 |
|
|
|
372 |
|
|
|
373 |
|
|
|
374 |
|
|
|
375 |
|
|
sub select_c_news { |
376 |
|
|
my $c_news = new c_news(\$conn); |
377 |
|
|
my @c_news = $c_news->select($in); |
378 |
|
|
|
379 |
|
|
$out->{'select_c_news'} = \@c_news; |
380 |
|
|
} |
381 |
|
|
|
382 |
|
|
### |
383 |
|
|
|
384 |
|
|
sub view_c_news { |
385 |
|
|
my $c_news = new c_news(\$conn); |
386 |
|
|
my @view_c_news = $c_news->view($in); |
387 |
|
|
|
388 |
|
|
$out->{'view_c_news'} = \@view_c_news; |
389 |
|
|
} |
390 |
|
|
|
391 |
|
|
### |
392 |
|
|
|
393 |
|
|
|
394 |
|
|
sub insert_c_news { |
395 |
|
|
my $c_news = new c_news(\$conn); |
396 |
|
|
$c_news->insert($in); |
397 |
|
|
&_clean_c_news_params; |
398 |
|
|
} |
399 |
|
|
|
400 |
|
|
### |
401 |
|
|
|
402 |
|
|
sub update_c_news { |
403 |
|
|
my $c_news = new c_news(\$conn); |
404 |
|
|
$c_news->update($in); |
405 |
|
|
&_clean_c_news_params; |
406 |
|
|
} |
407 |
|
|
|
408 |
|
|
### |
409 |
|
|
|
410 |
|
|
sub delete_c_news { |
411 |
|
|
my $c_news = new c_news(\$conn); |
412 |
|
|
$c_news->delete($in); |
413 |
|
|
&_clean_c_news_params; |
414 |
|
|
} |
415 |
|
|
|
416 |
|
|
### |
417 |
|
|
|
418 |
|
|
sub download_c_news { |
419 |
|
|
# Print CSV file and exit |
420 |
|
|
my $c_news = new c_news(\$conn); |
421 |
|
|
my @view_c_news = $c_news->view($in); |
422 |
|
|
|
423 |
|
|
my @keys = sort keys %{$view_c_news[0]}; |
424 |
|
|
|
425 |
|
|
print "Content-type: text/plain\n\n"; |
426 |
|
|
|
427 |
|
|
print "# ", join (";", @keys), "\n"; # "key1","key2", ... "keyn" |
428 |
|
|
|
429 |
|
|
foreach my $c_news (@view_c_news) { |
430 |
|
|
my @values = (); |
431 |
|
|
foreach my $key (@keys) { |
432 |
|
|
my $value = $c_news->{$key}; |
433 |
|
|
$value =~ s/\t/\\t/gs; |
434 |
|
|
$value =~ s/\r/\\r/gs; |
435 |
|
|
$value =~ s/\n/\\n/gs; |
436 |
|
|
$value =~ s/\;/\%3B/gs; |
437 |
|
|
push @values, $value; |
438 |
|
|
} |
439 |
|
|
print join (";", @values), "\n"; |
440 |
|
|
} |
441 |
|
|
|
442 |
|
|
exit; |
443 |
|
|
|
444 |
|
|
} |
445 |
|
|
|
446 |
|
|
### |
447 |
|
|
|
448 |
|
|
sub _clean_c_news_params { |
449 |
|
|
# clean input params |
450 |
|
|
delete $in->{'c_news_id'}; |
451 |
|
|
delete $in->{'c_source_fk'}; |
452 |
|
|
delete $in->{'c_customer_fk'}; |
453 |
|
|
delete $in->{'c_type_fk'}; |
454 |
|
|
delete $in->{'c_news_section'}; |
455 |
|
|
delete $in->{'c_news_page'}; |
456 |
|
|
delete $in->{'c_news_title'}; |
457 |
|
|
delete $in->{'c_news_abstract'}; |
458 |
|
|
delete $in->{'c_news_full_text'}; |
459 |
|
|
} |
460 |
|
|
|
461 |
|
|
### |
462 |
|
|
|
463 |
|
|
|
464 |
|
|
sub count_c_news_by_c_source { |
465 |
|
|
my $c_news = new c_news(\$conn); |
466 |
|
|
my @count_c_news_by_c_source = $c_news->count_by_c_source($in); |
467 |
|
|
$out->{'count_c_news_by_c_source'} = \@count_c_news_by_c_source; |
468 |
|
|
&_clean_c_news_params; |
469 |
|
|
} |
470 |
|
|
|
471 |
|
|
### |
472 |
|
|
|
473 |
|
|
sub count_c_news_by_c_customer { |
474 |
|
|
my $c_news = new c_news(\$conn); |
475 |
|
|
my @count_c_news_by_c_customer = $c_news->count_by_c_customer($in); |
476 |
|
|
$out->{'count_c_news_by_c_customer'} = \@count_c_news_by_c_customer; |
477 |
|
|
&_clean_c_news_params; |
478 |
|
|
} |
479 |
|
|
|
480 |
|
|
### |
481 |
|
|
|
482 |
|
|
sub count_c_news_by_c_type { |
483 |
|
|
my $c_news = new c_news(\$conn); |
484 |
|
|
my @count_c_news_by_c_type = $c_news->count_by_c_type($in); |
485 |
|
|
$out->{'count_c_news_by_c_type'} = \@count_c_news_by_c_type; |
486 |
|
|
&_clean_c_news_params; |
487 |
|
|
} |
488 |
|
|
|
489 |
|
|
### |
490 |
|
|
|
491 |
|
|
|
492 |
|
|
|
493 |
|
|
####### EVENTS ####### |
494 |
|
|
|
495 |
|
|
sub before_pg_sel_c_customer { |
496 |
|
|
# view_c_customer |
497 |
|
|
|
498 |
|
|
my $c_customer = new c_customer(\$conn); |
499 |
|
|
my @view_c_customer = $c_customer->view($in); |
500 |
|
|
|
501 |
|
|
|
502 |
|
|
|
503 |
|
|
if ($#view_c_customer == -1) { |
504 |
|
|
&Print_template ('pg_ins_c_customer'); |
505 |
|
|
exit; |
506 |
|
|
} elsif ($#view_c_customer == 0) { |
507 |
|
|
$in->{"c_customer_id"} = $view_c_customer[0]->{"c_customer_id"}; |
508 |
|
|
&Print_template ('pg_detail_c_customer'); |
509 |
|
|
exit; |
510 |
|
|
} |
511 |
|
|
|
512 |
|
|
$out->{'view_c_customer'} = \@view_c_customer; |
513 |
|
|
} |
514 |
|
|
|
515 |
|
|
### |
516 |
|
|
|
517 |
|
|
sub before_pg_ins_c_customer { |
518 |
|
|
# select |
519 |
|
|
|
520 |
|
|
|
521 |
|
|
} |
522 |
|
|
|
523 |
|
|
### |
524 |
|
|
|
525 |
|
|
sub before_pg_upd_c_customer { |
526 |
|
|
# select c_customer |
527 |
|
|
|
528 |
|
|
&select_c_customer; |
529 |
|
|
} |
530 |
|
|
|
531 |
|
|
### |
532 |
|
|
|
533 |
|
|
sub before_pg_detail_c_customer { |
534 |
|
|
# select c_customer |
535 |
|
|
|
536 |
|
|
&view_c_customer; |
537 |
|
|
&view_c_news; |
538 |
|
|
} |
539 |
|
|
|
540 |
|
|
### |
541 |
|
|
|
542 |
|
|
|
543 |
|
|
sub before_pg_sel_c_source { |
544 |
|
|
# view_c_source |
545 |
|
|
|
546 |
|
|
my $c_source = new c_source(\$conn); |
547 |
|
|
my @view_c_source = $c_source->view($in); |
548 |
|
|
|
549 |
|
|
|
550 |
|
|
|
551 |
|
|
if ($#view_c_source == -1) { |
552 |
|
|
&Print_template ('pg_ins_c_source'); |
553 |
|
|
exit; |
554 |
|
|
} elsif ($#view_c_source == 0) { |
555 |
|
|
$in->{"c_source_id"} = $view_c_source[0]->{"c_source_id"}; |
556 |
|
|
&Print_template ('pg_detail_c_source'); |
557 |
|
|
exit; |
558 |
|
|
} |
559 |
|
|
|
560 |
|
|
$out->{'view_c_source'} = \@view_c_source; |
561 |
|
|
} |
562 |
|
|
|
563 |
|
|
### |
564 |
|
|
|
565 |
|
|
sub before_pg_ins_c_source { |
566 |
|
|
# select |
567 |
|
|
|
568 |
|
|
|
569 |
|
|
} |
570 |
|
|
|
571 |
|
|
### |
572 |
|
|
|
573 |
|
|
sub before_pg_upd_c_source { |
574 |
|
|
# select c_source |
575 |
|
|
|
576 |
|
|
&select_c_source; |
577 |
|
|
} |
578 |
|
|
|
579 |
|
|
### |
580 |
|
|
|
581 |
|
|
sub before_pg_detail_c_source { |
582 |
|
|
# select c_source |
583 |
|
|
|
584 |
|
|
&view_c_source; |
585 |
|
|
&view_c_news; |
586 |
|
|
} |
587 |
|
|
|
588 |
|
|
### |
589 |
|
|
|
590 |
|
|
|
591 |
|
|
sub before_pg_sel_c_type { |
592 |
|
|
# view_c_type |
593 |
|
|
|
594 |
|
|
my $c_type = new c_type(\$conn); |
595 |
|
|
my @view_c_type = $c_type->view($in); |
596 |
|
|
|
597 |
|
|
|
598 |
|
|
|
599 |
|
|
if ($#view_c_type == -1) { |
600 |
|
|
&Print_template ('pg_ins_c_type'); |
601 |
|
|
exit; |
602 |
|
|
} elsif ($#view_c_type == 0) { |
603 |
|
|
$in->{"c_type_id"} = $view_c_type[0]->{"c_type_id"}; |
604 |
|
|
&Print_template ('pg_detail_c_type'); |
605 |
|
|
exit; |
606 |
|
|
} |
607 |
|
|
|
608 |
|
|
$out->{'view_c_type'} = \@view_c_type; |
609 |
|
|
} |
610 |
|
|
|
611 |
|
|
### |
612 |
|
|
|
613 |
|
|
sub before_pg_ins_c_type { |
614 |
|
|
# select |
615 |
|
|
|
616 |
|
|
|
617 |
|
|
} |
618 |
|
|
|
619 |
|
|
### |
620 |
|
|
|
621 |
|
|
sub before_pg_upd_c_type { |
622 |
|
|
# select c_type |
623 |
|
|
|
624 |
|
|
&select_c_type; |
625 |
|
|
} |
626 |
|
|
|
627 |
|
|
### |
628 |
|
|
|
629 |
|
|
sub before_pg_detail_c_type { |
630 |
|
|
# select c_type |
631 |
|
|
|
632 |
|
|
&view_c_type; |
633 |
|
|
&view_c_news; |
634 |
|
|
} |
635 |
|
|
|
636 |
|
|
### |
637 |
|
|
|
638 |
|
|
|
639 |
|
|
sub before_pg_sel_c_news { |
640 |
|
|
# view_c_news |
641 |
|
|
|
642 |
|
|
my $c_news = new c_news(\$conn); |
643 |
|
|
my @view_c_news = $c_news->view($in); |
644 |
|
|
|
645 |
|
|
&select_c_source; |
646 |
|
|
&select_c_customer; |
647 |
|
|
&select_c_type; |
648 |
|
|
|
649 |
|
|
if ($#view_c_news == -1) { |
650 |
|
|
&Print_template ('pg_ins_c_news'); |
651 |
|
|
exit; |
652 |
|
|
} elsif ($#view_c_news == 0) { |
653 |
|
|
$in->{"c_news_id"} = $view_c_news[0]->{"c_news_id"}; |
654 |
|
|
&Print_template ('pg_detail_c_news'); |
655 |
|
|
exit; |
656 |
|
|
} |
657 |
|
|
|
658 |
|
|
$out->{'view_c_news'} = \@view_c_news; |
659 |
|
|
} |
660 |
|
|
|
661 |
|
|
### |
662 |
|
|
|
663 |
|
|
sub before_pg_ins_c_news { |
664 |
|
|
# select c_source, c_customer, c_type |
665 |
|
|
|
666 |
|
|
&select_c_source; |
667 |
|
|
&select_c_customer; |
668 |
|
|
&select_c_type; |
669 |
|
|
} |
670 |
|
|
|
671 |
|
|
### |
672 |
|
|
|
673 |
|
|
sub before_pg_upd_c_news { |
674 |
|
|
# select c_news, c_source, c_customer, c_type |
675 |
|
|
|
676 |
|
|
&select_c_news; |
677 |
|
|
&select_c_source; |
678 |
|
|
&select_c_customer; |
679 |
|
|
&select_c_type; |
680 |
|
|
} |
681 |
|
|
|
682 |
|
|
### |
683 |
|
|
|
684 |
|
|
sub before_pg_detail_c_news { |
685 |
|
|
# select c_news, c_source, c_customer, c_type |
686 |
|
|
|
687 |
|
|
&view_c_news; |
688 |
|
|
|
689 |
|
|
} |
690 |
|
|
|
691 |
|
|
### |
692 |
|
|
|
693 |
|
|
|
694 |
|
|
|
695 |
|
|
__END__ |
696 |
|
|
|
697 |
|
|
Clipping - Copyright 2003 PhPerl.com |
698 |
|
|
|
699 |
|
|
This program is free software; you can redistribute it and/or |
700 |
|
|
modify it under the terms of the GNU General Public License |
701 |
|
|
as published by the Free Software Foundation; either version 2 |
702 |
|
|
of the License, or (at your option) any later version. |
703 |
|
|
|
704 |
|
|
This program is distributed in the hope that it will be useful, |
705 |
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of |
706 |
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
707 |
|
|
|
708 |
|
|
See the GNU General Public License for more details: |
709 |
|
|
|
710 |
|
|
http://www.gnu.org/copyleft/gpl.html |