Revision b3673e83
Von Moritz Bunkus vor mehr als 17 Jahren hinzugefügt
bin/mozilla/ct.pl | ||
---|---|---|
37 | 37 |
# $locale->text('Add Customer') |
38 | 38 |
# $locale->text('Add Vendor') |
39 | 39 |
|
40 |
use SL::CT; |
|
41 |
use CGI::Ajax; |
|
42 | 40 |
use CGI; |
43 |
use Data::Dumper; |
|
41 |
use CGI::Ajax; |
|
42 |
use POSIX qw(strftime); |
|
43 |
|
|
44 |
use SL::CT; |
|
45 |
use SL::ReportGenerator; |
|
44 | 46 |
|
45 | 47 |
require "bin/mozilla/common.pl"; |
48 |
require "bin/mozilla/reportgenerator.pl"; |
|
46 | 49 |
|
47 | 50 |
1; |
48 | 51 |
|
... | ... | |
217 | 220 |
sub list_names { |
218 | 221 |
$lxdebug->enter_sub(); |
219 | 222 |
|
220 |
CT->search(\%myconfig, \%$form);
|
|
223 |
$form->{IS_CUSTOMER} = $form->{db} eq 'customer';
|
|
221 | 224 |
|
222 |
$callback = |
|
223 |
"$form->{script}?action=list_names&db=$form->{db}&login=$form->{login}&password=$form->{password}&status=$form->{status}&obsolete=$form->{obsolete}"; |
|
224 |
$href = $callback; |
|
225 |
|
|
226 |
@columns = |
|
227 |
$form->sort_columns(id, name, |
|
228 |
"$form->{db}number", address, |
|
229 |
contact, phone, |
|
230 |
fax, email, |
|
231 |
taxnumber, |
|
232 |
sic_code, business, |
|
233 |
invnumber, ordnumber, |
|
234 |
quonumber); |
|
235 |
|
|
236 |
foreach $item (@columns) { |
|
237 |
if ($form->{"l_$item"} eq "Y") { |
|
238 |
push @column_index, $item; |
|
239 |
|
|
240 |
# add column to href and callback |
|
241 |
$callback .= "&l_$item=Y"; |
|
242 |
$href .= "&l_$item=Y"; |
|
243 |
} |
|
244 |
} |
|
245 |
$number = |
|
246 |
($form->{db} eq "customer") |
|
247 |
? $locale->text('Customer Number') |
|
248 |
: $locale->text('Vendor Number'); |
|
225 |
CT->search(\%myconfig, \%$form); |
|
249 | 226 |
|
227 |
my @options; |
|
250 | 228 |
if ($form->{status} eq 'all') { |
251 |
$option = $locale->text('All');
|
|
252 |
} |
|
253 |
if ($form->{status} eq 'orphaned') { |
|
254 |
$option .= $locale->text('Orphaned');
|
|
229 |
push @options, $locale->text('All');
|
|
230 |
|
|
231 |
} elsif ($form->{status} eq 'orphaned') {
|
|
232 |
push @options, $locale->text('Orphaned');
|
|
255 | 233 |
} |
234 |
|
|
256 | 235 |
if ($form->{name}) { |
257 |
$callback .= "&name=" . $form->escape($form->{name}, 1); |
|
258 |
$href .= "&name=" . $form->escape($form->{name}); |
|
259 |
$option .= "\n<br>" . $locale->text('Name') . " : $form->{name}"; |
|
236 |
push @options, $locale->text('Name') . " : $form->{name}"; |
|
260 | 237 |
} |
261 | 238 |
if ($form->{contact}) { |
262 |
$callback .= "&contact=" . $form->escape($form->{contact}, 1); |
|
263 |
$href .= "&contact=" . $form->escape($form->{contact}); |
|
264 |
$option .= "\n<br>" . $locale->text('Contact') . " : $form->{contact}"; |
|
239 |
push @options, $locale->text('Contact') . " : $form->{contact}"; |
|
265 | 240 |
} |
266 | 241 |
if ($form->{"$form->{db}number"}) { |
267 |
$callback .= |
|
268 |
qq|&$form->{db}number=| . $form->escape($form->{"$form->{db}number"}, 1); |
|
269 |
$href .= |
|
270 |
"&$form->{db}number=" . $form->escape($form->{"$form->{db}number"}); |
|
271 |
$option .= |
|
272 |
"\n<br>" . $locale->text('Number') . qq| : $form->{"$form->{db}number"}|; |
|
242 |
push @options, $locale->text('Number') . qq| : $form->{"$form->{db}number"}|; |
|
273 | 243 |
} |
274 | 244 |
if ($form->{email}) { |
275 |
$callback .= "&email=" . $form->escape($form->{email}, 1); |
|
276 |
$href .= "&email=" . $form->escape($form->{email}); |
|
277 |
$option .= "\n<br>" . $locale->text('E-mail') . " : $form->{email}"; |
|
245 |
push @options, $locale->text('E-mail') . " : $form->{email}"; |
|
278 | 246 |
} |
279 | 247 |
|
280 |
$form->{callback} = "$callback&sort=$form->{sort}"; |
|
281 |
$callback = $form->escape($form->{callback}); |
|
282 |
|
|
283 |
$column_header{id} = |
|
284 |
qq|<th class=listheading>| . $locale->text('ID') . qq|</th>|; |
|
285 |
$column_header{"$form->{db}number"} = |
|
286 |
qq|<th><a class=listheading href=$href&sort=$form->{db}number>$number</a></th>|; |
|
287 |
$column_header{name} = |
|
288 |
qq|<th><a class=listheading href=$href&sort=name>| |
|
289 |
. $locale->text('Name') |
|
290 |
. qq|</a></th>|; |
|
291 |
$column_header{address} = |
|
292 |
qq|<th><a class=listheading href=$href&sort=address>| |
|
293 |
. $locale->text('Address') |
|
294 |
. qq|</a></th>|; |
|
295 |
$column_header{contact} = |
|
296 |
qq|<th><a class=listheading href=$href&sort=contact>| |
|
297 |
. $locale->text('Contact') |
|
298 |
. qq|</a></th>|; |
|
299 |
$column_header{phone} = |
|
300 |
qq|<th><a class=listheading href=$href&sort=phone>| |
|
301 |
. $locale->text('Phone') |
|
302 |
. qq|</a></th>|; |
|
303 |
$column_header{fax} = |
|
304 |
qq|<th><a class=listheading href=$href&sort=fax>| |
|
305 |
. $locale->text('Fax') |
|
306 |
. qq|</a></th>|; |
|
307 |
$column_header{email} = |
|
308 |
qq|<th><a class=listheading href=$href&sort=email>| |
|
309 |
. $locale->text('E-mail') |
|
310 |
. qq|</a></th>|; |
|
311 |
$column_header{cc} = |
|
312 |
qq|<th><a class=listheading href=$href&sort=cc>| |
|
313 |
. $locale->text('Cc') |
|
314 |
. qq|</a></th>|; |
|
315 |
|
|
316 |
$column_header{taxnumber} = |
|
317 |
qq|<th><a class=listheading href=$href&sort=taxnumber>| |
|
318 |
. $locale->text('Tax Number') |
|
319 |
. qq|</a></th>|; |
|
320 |
$column_header{sic_code} = |
|
321 |
qq|<th><a class=listheading href=$href&sort=sic_code>| |
|
322 |
. $locale->text('SIC') |
|
323 |
. qq|</a></th>|; |
|
324 |
$column_header{business} = |
|
325 |
qq|<th><a class=listheading href=$href&sort=business>| |
|
326 |
. $locale->text('Type of Business') |
|
327 |
. qq|</a></th>|; |
|
328 |
|
|
329 |
$column_header{invnumber} = |
|
330 |
qq|<th><a class=listheading href=$href&sort=invnumber>| |
|
331 |
. $locale->text('Invoice') |
|
332 |
. qq|</a></th>|; |
|
333 |
$column_header{ordnumber} = |
|
334 |
qq|<th><a class=listheading href=$href&sort=ordnumber>| |
|
335 |
. $locale->text('Order') |
|
336 |
. qq|</a></th>|; |
|
337 |
$column_header{quonumber} = |
|
338 |
qq|<th><a class=listheading href=$href&sort=quonumber>| |
|
339 |
. $locale->text('Quotation') |
|
340 |
. qq|</a></th>|; |
|
341 |
|
|
342 |
$label = ucfirst $form->{db} . "s"; |
|
343 |
$form->{title} = $locale->text($label); |
|
344 |
|
|
345 |
$form->header; |
|
346 |
|
|
347 |
print qq| |
|
348 |
<body> |
|
349 |
|
|
350 |
<table width=100%> |
|
351 |
<tr> |
|
352 |
<th class=listtop>$form->{title}</th> |
|
353 |
</tr> |
|
354 |
<tr height="5"></tr> |
|
355 |
<tr> |
|
356 |
<td>$option</td> |
|
357 |
</tr> |
|
358 |
<tr> |
|
359 |
<td> |
|
360 |
<table width=100%> |
|
361 |
<tr class=listheading> |
|
362 |
|; |
|
363 |
|
|
364 |
map { print "$column_header{$_}\n" } @column_index; |
|
365 |
|
|
366 |
print qq| |
|
367 |
</tr> |
|
368 |
|; |
|
248 |
my @columns = ( |
|
249 |
'id', 'name', "$form->{db}number", 'address', 'contact', 'phone', |
|
250 |
'fax', 'email', 'taxnumber', 'sic_code', 'business', 'invnumber', |
|
251 |
'ordnumber', 'quonumber' |
|
252 |
); |
|
253 |
|
|
254 |
my %column_defs = ( |
|
255 |
'id' => { 'text' => $locale->text('ID'), }, |
|
256 |
"$form->{db}number" => { 'text' => $form->{IS_CUSTOMER} ? $locale->text('Customer Number') : $locale->text('Vendor Number'), }, |
|
257 |
'name' => { 'text' => $locale->text('Name'), }, |
|
258 |
'address' => { 'text' => $locale->text('Address'), }, |
|
259 |
'contact' => { 'text' => $locale->text('Contact'), }, |
|
260 |
'phone' => { 'text' => $locale->text('Phone'), }, |
|
261 |
'fax' => { 'text' => $locale->text('Fax'), }, |
|
262 |
'email' => { 'text' => $locale->text('E-mail'), }, |
|
263 |
'cc' => { 'text' => $locale->text('Cc'), }, |
|
264 |
'taxnumber' => { 'text' => $locale->text('Tax Number'), }, |
|
265 |
'sic_code' => { 'text' => $locale->text('SIC'), }, |
|
266 |
'business' => { 'text' => $locale->text('Type of Business'), }, |
|
267 |
'invnumber' => { 'text' => $locale->text('Invoice'), }, |
|
268 |
'ordnumber' => { 'text' => $form->{IS_CUSTOMER} ? $locale->text('Sales Order') : $locale->text('Purchase Order'), }, |
|
269 |
'quonumber' => { 'text' => $form->{IS_CUSTOMER} ? $locale->text('Quotation') : $locale->text('Request for Quotation'), }, |
|
270 |
); |
|
271 |
|
|
272 |
map { $column_defs{$_}->{visible} = $form->{"l_$_"} eq 'Y' } @columns; |
|
273 |
|
|
274 |
my @hidden_variables = (qw(db status obsolete), map { "l_$_" } @columns); |
|
275 |
my @hidden_nondefault = grep({ $form->{$_} } @hidden_variables); |
|
276 |
my $callback = build_std_url('action=list_names', grep { $form->{$_} } @hidden_variables); |
|
277 |
$form->{callback} = "$callback&sort=" . E($form->{sort}); |
|
278 |
|
|
279 |
map { $column_defs{$_}->{link} = "${callback}&sort=${_}" } @columns; |
|
280 |
|
|
281 |
my ($ordertype, $quotationtype, $attachment_basename); |
|
282 |
if ($form->{IS_CUSTOMER}) { |
|
283 |
$form->{title} = $locale->text('Customers'); |
|
284 |
$ordertype = 'sales_order'; |
|
285 |
$quotationtype = 'sales_quotation'; |
|
286 |
$attachment_basename = $locale->text('customer_list'); |
|
369 | 287 |
|
370 |
$ordertype = ($form->{db} eq 'customer') ? 'sales_order' : 'purchase_order'; |
|
371 |
$quotationtype = |
|
372 |
($form->{db} eq 'customer') ? 'sales_quotation' : 'request_quotation'; |
|
373 |
|
|
374 |
foreach $ref (@{ $form->{CT} }) { |
|
288 |
} else { |
|
289 |
$form->{title} = $locale->text('Vendors'); |
|
290 |
$ordertype = 'purchase_order'; |
|
291 |
$quotationtype = 'request_quotation'; |
|
292 |
$attachment_basename = $locale->text('vendor_list'); |
|
293 |
} |
|
375 | 294 |
|
376 |
if ($ref->{id} eq $sameid) { |
|
377 |
map { $column_data{$_} = "<td> </td>" } @column_index; |
|
378 |
} else { |
|
379 |
map { $column_data{$_} = "<td>$ref->{$_} </td>" } @column_index; |
|
295 |
my $report = SL::ReportGenerator->new(\%myconfig, $form); |
|
380 | 296 |
|
381 |
map { $column_data{$_} = "<td>$ref->{$_} </td>" } |
|
382 |
(invnumber, ordnumber, quonumber); |
|
297 |
$report->set_options('top_info_text' => join("\n", @options), |
|
298 |
'raw_bottom_info_text' => $form->parse_html_template2('ct/list_names_bottom'), |
|
299 |
'output_format' => 'HTML', |
|
300 |
'title' => $form->{title}, |
|
301 |
'attachment_basename' => $attachment_basename . strftime('_%Y%m%d', localtime time), |
|
302 |
); |
|
303 |
$report->set_options_from_form(); |
|
383 | 304 |
|
384 |
$column_data{name} =
|
|
385 |
"<td align=left><a href=$form->{script}?action=edit&id=$ref->{id}&db=$form->{db}&login=$form->{login}&password=$form->{password}&status=$form->{status}&callback=$callback>$ref->{name} </td>";
|
|
305 |
$report->set_columns(%column_defs);
|
|
306 |
$report->set_column_order(@columns);
|
|
386 | 307 |
|
387 |
if ($ref->{email}) { |
|
388 |
$email = $ref->{email}; |
|
389 |
$email =~ s/</\</; |
|
390 |
$email =~ s/>/\>/; |
|
308 |
$report->set_export_options('list_names', @hidden_variables); |
|
391 | 309 |
|
392 |
$column_data{email} = |
|
393 |
qq|<td><a href="mailto:$ref->{email}">$email</a></td>|; |
|
394 |
} |
|
310 |
$report->set_sort_indicator($form->{sort}, 1); |
|
395 | 311 |
|
396 |
}
|
|
312 |
my $previous_id;
|
|
397 | 313 |
|
398 |
if ($ref->{formtype} eq 'invoice') { |
|
399 |
$column_data{invnumber} = |
|
400 |
"<td><a href=$ref->{module}.pl?action=edit&id=$ref->{invid}&login=$form->{login}&password=$form->{password}&callback=$callback>$ref->{invnumber} </td>"; |
|
401 |
} |
|
314 |
foreach my $ref (@{ $form->{CT} }) { |
|
315 |
my $row = { map { $_ => { 'data' => '' } } @columns }; |
|
402 | 316 |
|
403 |
if ($ref->{formtype} eq 'order') { |
|
404 |
$column_data{ordnumber} = |
|
405 |
"<td><a href=$ref->{module}.pl?action=edit&id=$ref->{invid}&type=$ordertype&login=$form->{login}&password=$form->{password}&callback=$callback>$ref->{ordnumber} </td>"; |
|
406 |
} |
|
317 |
if ($ref->{id} ne $previous_id) { |
|
318 |
$previous_id = $ref->{id}; |
|
319 |
map { $row->{$_}->{data} = $ref->{$_} } @columns; |
|
407 | 320 |
|
408 |
if ($ref->{formtype} eq 'quotation') { |
|
409 |
$column_data{quonumber} = |
|
410 |
"<td><a href=$ref->{module}.pl?action=edit&id=$ref->{invid}&type=$quotationtype&login=$form->{login}&password=$form->{password}&callback=$callback>$ref->{quonumber} </td>"; |
|
321 |
$row->{name}->{link} = build_std_url('action=edit', 'id=' . E($ref->{id}), 'callback', @hidden_nondefault); |
|
322 |
$row->{email}->{link} = 'mailto:' . E($ref->{email}); |
|
411 | 323 |
} |
412 | 324 |
|
413 |
$i++; |
|
414 |
$i %= 2; |
|
415 |
print " |
|
416 |
<tr class=listrow$i> |
|
417 |
"; |
|
418 |
|
|
419 |
map { print "$column_data{$_}\n" } @column_index; |
|
420 |
|
|
421 |
print qq| |
|
422 |
</tr> |
|
423 |
|; |
|
424 |
|
|
425 |
$sameid = $ref->{id}; |
|
325 |
my $base_url = build_std_url("script=$ref->{module}.pl", 'action=edit', 'id=' . E($ref->{invid}), 'callback', @hidden_nondefault); |
|
326 |
$row->{invnumber}->{link} = $base_url; |
|
327 |
$row->{ordnumber}->{link} = $base_url . "&type=${ordertype}"; |
|
328 |
$row->{quonumber}->{link} = $base_url . "&type=${quotationtype}"; |
|
329 |
my $column = $ref->{formtype} eq 'invoice' ? 'invnumber' : $ref->{formtype} eq 'order' ? 'ordnumber' : 'quonumber'; |
|
330 |
$row->{$column}->{data} = $ref->{$column}; |
|
426 | 331 |
|
332 |
$report->add_data($row); |
|
427 | 333 |
} |
428 | 334 |
|
429 |
print qq| |
|
430 |
</table> |
|
431 |
</td> |
|
432 |
</tr> |
|
433 |
<tr> |
|
434 |
<td><hr size=3 noshade></td> |
|
435 |
</tr> |
|
436 |
</table> |
|
437 |
|
|
438 |
<br> |
|
439 |
<form method=post action=$form->{script}> |
|
440 |
|
|
441 |
<input name=callback type=hidden value="$form->{callback}"> |
|
442 |
<input name=db type=hidden value=$form->{db}> |
|
443 |
|
|
444 |
<input type=hidden name=login value=$form->{login}> |
|
445 |
<input type=hidden name=password value=$form->{password}> |
|
446 |
|
|
447 |
<input class=submit type=submit name=action value="| |
|
448 |
. $locale->text('Add') . qq|"> |
|
449 |
|
|
450 |
</form> |
|
451 |
|
|
452 |
</body> |
|
453 |
</html> |
|
454 |
|; |
|
335 |
$report->generate_with_headers(); |
|
455 | 336 |
|
456 | 337 |
$lxdebug->leave_sub(); |
457 | 338 |
} |
Auch abrufbar als: Unified diff
Kunden- und Liferantenstammdatenliste auf die Verwendung von ReportGenerator umgestellt.