1#===================================================================== 2# SQL-Ledger 3# Copyright (c) DWS Systems Inc. 4# 5# Author: DWS Systems Inc. 6# Web: http://www.sql-ledger.com 7# 8#====================================================================== 9# 10# Reference Documents 11# 12#====================================================================== 13 14 15use SL::RD; 16 17require "$form->{path}/js.pl"; 18 191; 20 21 22sub formnames { 23 24 my %module = ( ar_transaction => { script => ar, db => ar, var => "type=transaction", label => $locale->text('AR Transaction') }, 25 credit_note => { script => ar, db => ar, var => "type=credit_note", label => $locale->text('Credit Note') }, 26 ap_transaction => { script => ap, db => ap, var => "type=transaction", label => $locale->text('AP Transaction') }, 27 debit_note => { script => ap, db => ap, var => "type=debit_note", label => $locale->text('Debit Note') }, 28 ar_invoice => { script => is, db => ar, var => "type=invoice", label => $locale->text('Sales Invoice') }, 29 credit_invoice => { script => is, db => ar, var => "type=credit_invoice", label => $locale->text('Credit Invoice') }, 30 ap_invoice => { script => ir, db => ap, var => "type=invoice", label => $locale->text('Vendor Invoice') }, 31 debit_invoice => { script => ir, db => ap, var => "type=debit_invoice", label => $locale->text('Debit Invoice') }, 32 sales_order => { script => oe, db => oe, var => "type=sales_order", label => $locale->text('Sales Order') }, 33 sales_quotation => { script => oe, db => oe, var => "type=sales_quotation", label => $locale->text('Quotation') }, 34 purchase_order => { script => oe, db => oe, var => "type=purchase_order", label => $locale->text('Purchase Order') }, 35 request_quotation => { script => oe, db => oe, var => "type=request_quotation", label => $locale->text('RFQ') }, 36 gl => { script => gl, db => gl, label => $locale->text('GL Transaction') }, 37 project => { script => pe, db => oe, var => "type=project", label => $locale->text('Project') }, 38 job => { script => pe, db => project, var => "type=job", label => $locale->text('Job') }, 39 customer => { script => ct, db => customer, var => "db=customer", label => $locale->text('Customer') }, 40 vendor => { script => ct, db => vendor, var => "db=vendor", label => $locale->text('Vendor') }, 41 part => { script => ic, db => parts, var => "item=part", label => $locale->text('Part') }, 42 service => { script => ic, db => parts, var => "item=service", label => $locale->text('Service') }, 43 assembly => { script => ic, db => parts, var => "item=assembly", label => $locale->text('Assembly') }, 44 labor => { script => ic, db => parts, var => "item=labor", label => $locale->text('Labor') }, 45 employee => { script => hr, db => employee, var => "db=employee", label => $locale->text('Employee') }, 46 timecard => { script => jc, db => jcitems, var => "type=timecard", label => $locale->text('Timecard') }, 47 storescard => { script => jc, db => jcitems, var => "type=storescard", label => $locale->text('Stores Card') } 48 ); 49 50 %module; 51 52} 53 54 55sub upload { 56 57 if ($form->{id}) { 58 &display_documents; 59 exit; 60 } 61 62 $form->{title} = $locale->text('Upload Document'); 63 64 $form->helpref("cms", $myconfig{countrycode}); 65 66 $form->header; 67 68 $form->{nextsub} = "upload_file"; 69 70 &resize; 71 72 $focus = "description"; 73 74 print qq| 75<body onLoad="main.${focus}.focus()" /> 76 77<form enctype="multipart/form-data" name=main method=post action=$form->{script}> 78 79<table width=100%> 80 <tr> 81 <th class=listtop>$form->{helpref}$form->{title}</a></th> 82 </tr> 83 <tr height="5"></tr> 84 <tr> 85 <td> 86 <table> 87 <tr> 88 <th align="right">|.$locale->text('Description').qq|</th> 89 <td> 90 <input name=description size=40 value="$form->{description}"> 91 </td> 92 </tr> 93 <tr> 94 <th align="right">|.$locale->text('Folder').qq|</th> 95 <td> 96 <input name=folder size=40 value="$form->{folder}"> 97 </td> 98 </tr> 99 <tr> 100 <th align="right">|.$locale->text('Filename').qq|</th> 101 <td> 102 <input name=file size=40 value="$form->{file}"> 103 </td> 104 </tr> 105 106 <tr> 107 <th align="right">|.$locale->text('File').qq|</th> 108 <td> 109 <input name=data size=60 type=file> 110 </td> 111 </tr> 112 </table> 113 </td> 114 </tr> 115 <tr> 116 <td><hr size=3 noshade></td> 117 </tr> 118 119</table> 120|; 121 122 $form->hide_form(qw(callback row title nextsub login path)); 123 124 print qq| 125<input name=action class=submit type=submit value="|.$locale->text('Continue').qq|"> 126</form> 127 128</body> 129</html> 130|; 131 132} 133 134 135sub upload_file { 136 137 if ($form->{row}) { 138 139 $form->header; 140 141 $form->{filename} = ($form->{file}) ? $form->{file} : $form->{filename}; 142 143 &pickvalue; 144 145for (qw(description filename folder)) { $form->{$_} =~ s/'/\\'/g } 146 147 print qq| 148<body onLoad="pickvalue('referencedescription_$form->{row}', '$form->{description}'); pickvalue('referencefilename_$form->{row}', '$form->{filename}'); pickvalue('referencetmpfile_$form->{row}', '$form->{tmpfile}'); pickvalue('referencearchive_id_$form->{row}', '-'); pickvalue('referencefolder_$form->{row}', '$form->{folder}'); window.close()"> 149 150</body> 151</html> 152|; 153 } else { 154 155 $form->{userspath} = $userspath; 156 157 $form->error($locale->text('No file selected!')) unless $form->{filename}; 158 159 if (RD->save_document(\%myconfig, \%$form)) { 160 ($script, $argv) = split /\?/, $form->{callback}; 161 %argv = split /[&=]/, $argv; 162 for (qw(action description folder filename)) { delete $form->{$_} } 163 for (keys %argv) { $form->{$_} = $argv{$_} } 164 &list_documents; 165 } else { 166 $form->error($locale->text('Add document failed!')); 167 } 168 169 } 170 171} 172 173 174sub display_documents { 175 176 $form->{action} = "display_documents"; 177 178 $form->{title} = $locale->text('Reference Documents'); 179 180 $form->helpref("cms", $myconfig{countrycode}); 181 182 if ($form->{id} eq '-') { 183 $form->header; 184 185 print qq| 186<script language="javascript" type="text/javascript"> 187<!-- 188self.resizeTo(600,600); 189//--> 190</script> 191 192<body> 193|; 194 195 $form->error($locale->text('Document not archived!')); 196 197 } 198 199 if ($form->{id}) { 200 if ($data = $form->get_reference(\%myconfig)) { 201 202 $form->{contenttype} ||= 'text/plain'; 203 204 print qq|Content-Type: $form->{contenttype} 205Content-Disposition: inline; filename=$form->{filename};\n\n|; 206 207 open(OUT, ">-") or $form->error("STDOUT : $!"); 208 209 binmode(OUT); 210 211 print OUT $data; 212 close(OUT); 213 214 } else { 215 $form->error($locale->text('No data!')); 216 } 217 } 218 219} 220 221 222sub search_documents { 223 224 $form->{title} = $locale->text('Reference Documents'); 225 226 $form->{nextsub} = "list_documents"; 227 228 $form->helpref("cms", $myconfig{countrycode}); 229 230 %m = &formnames; 231 $selectformname = "\n"; 232 for (sort { $m{$a}->{label} cmp $m{$b}->{label} } keys %m) { 233 $selectformname .= qq|$m{$_}{label}--$_\n|; 234 } 235 236 $form->header; 237 238 $focus = "description"; 239 240 print qq| 241<body onLoad="main.${focus}.focus()" /> 242 243<form method="post" name="main" action="$form->{script}"> 244 245 246<table width=100%> 247 <tr><th class=listtop>$form->{helpref}$form->{title}</a></th></tr> 248 <tr height="5"></tr> 249 <tr> 250 <td> 251 <table> 252 <tr> 253 <th align=right nowrap>|.$locale->text('Description').qq|</th> 254 <td><input name=description size=40></td> 255 </tr> 256 <tr> 257 <th align=right nowrap>|.$locale->text('Folder').qq|</th> 258 <td><input name=folder size=40></td> 259 </tr> 260 <tr> 261 <th align=right nowrap>|.$locale->text('Form').qq|</th> 262 <td><select name=formname>| 263 .$form->select_option($selectformname, undef, 1).qq| 264 </td> 265 </tr> 266 <tr> 267 <th align=right nowrap>|.$locale->text('Filename').qq|</th> 268 <td><input name=filename size=40></td> 269 </tr> 270 </table> 271 </td> 272 <tr> 273 <td><hr size=3 noshade></td> 274 </tr> 275</table> 276 277<br> 278<input class=submit type=submit name=action value="|.$locale->text('Continue').qq|">|; 279 280 $form->{action} = $form->{nextsub}; 281 $form->hide_form(qw(action nextsub login path)); 282 283 if ($form->{menubar}) { 284 require "$form->{path}/menu.pl"; 285 &menubar; 286 } 287 288 print qq| 289</form> 290 291</body> 292</html> 293|; 294 295} 296 297 298sub list_documents { 299 300 RD->all_documents(\%myconfig, \%$form); 301 302 $href = "$form->{script}?action=list_documents"; 303 for (qw(direction oldsort path login)) { $href .= qq|&$_=$form->{$_}| } 304 305 $form->sort_order(); 306 307 $callback = "$form->{script}?action=list_documents"; 308 for (qw(direction oldsort path login)) { $callback .= qq|&$_=$form->{$_}| } 309 310 @columns = qw(description folder filename confidential formname); 311 312 if ($form->{description}) { 313 $option .= "\n<br>" if ($option); 314 $option .= $locale->text('Description')." : $form->{description}"; 315 $href .= "&description=".$form->escape($form->{description}); 316 $callback .= "&description=$form->{description}"; 317 } 318 if ($form->{filename}) { 319 $option .= "\n<br>" if ($option); 320 $option .= $locale->text('Filename')." : $form->{filename}"; 321 $href .= "&filename=".$form->escape($form->{filename}); 322 $callback .= "&filename=$form->{filename}"; 323 } 324 if ($form->{folder}) { 325 $option .= "\n<br>" if ($option); 326 $option .= $locale->text('Folder')." : $form->{folder}"; 327 $href .= "&folder=".$form->escape($form->{folder}); 328 $callback .= "&folder=$form->{folder}"; 329 } 330 if ($form->{formname}) { 331 ($formname) = split /--/, $form->{formname}; 332 $option .= "\n<br>" if ($option); 333 $option .= $locale->text('Form')." : $formname"; 334 $href .= "&formname=".$form->escape($form->{formname}); 335 $callback .= "&formname=$form->{formname}"; 336 } 337 338 %module = &formnames; 339 340 $column_data{delete} = qq|<th class=listheading width=1%><input name="allbox_delete" type=checkbox class=checkbox value="1" onChange="CheckAll();"></th>|; 341 $column_data{confidential} = qq|<th class=listheading>|.$locale->text('C').qq|</th>|; 342 $column_data{description} = qq|<th><a class=listheading href=$href&sort=description>|.$locale->text('Description').qq|</a></th>|; 343 $column_data{folder} = qq|<th><a class=listheading href=$href&sort=folder>|.$locale->text('Folder').qq|</a></th>|; 344 $column_data{formname} = qq|<th><a class=listheading href=$href&sort=formname>|.$locale->text('Attached to').qq|</a></th>|; 345 $column_data{filename} = qq|<th><a class=listheading href=$href&sort=filename>|.$locale->text('Filename').qq|</a></th>|; 346 347 $form->{title} = $locale->text('Reference Documents'); 348 349 $form->{callback} = $callback; 350 $callback = $form->escape($callback,1); 351 352 @column_index = $form->sort_columns(@columns); 353 354 unshift @column_index, "delete"; 355 356 $form->helpref("cms", $myconfig{countrycode}); 357 358 $form->header; 359 360 &check_all(qw(allbox_delete id_)); 361 362 print qq| 363<body> 364 365<form method="post" name="main" action="$form->{script}"> 366 367<table width=100%> 368 <tr> 369 <th class=listtop>$form->{helpref}$form->{title}</a></th> 370 </tr> 371 <tr height="5"></tr> 372 <tr> 373 <td>$option</td> 374 </tr> 375 <tr> 376 <td> 377 <table width=100%> 378 <tr class=listheading> 379|; 380 381 for (@column_index) { print "\n$column_data{$_}" } 382 383 print qq| 384 </tr> 385|; 386 387 $idlabel = $locale->text('ID'); 388 389 $i = 0; 390 foreach $ref (@{ $form->{all_documents} }) { 391 392 $i++; 393 394 for (@column_index) { $column_data{$_} = "<td>$ref->{$_} </td>" } 395 396 if ($ref->{formname}) { 397 $column_data{formname} = qq|<td>$module{$ref->{formname}}{label}</td>|; 398 if ($module{$ref->{formname}}{script}) { 399 $href="$module{$ref->{formname}}{script}.pl?action=edit&id=$ref->{trans_id}&login=$form->{login}&path=$form->{path}"; 400 $href .= "&$module{$ref->{formname}}{var}" if $module{$ref->{formname}}{var}; 401 $column_data{formname} = qq|<td><a href="$href" target=_new>$module{$ref->{formname}}{label}</a> - $idlabel $ref->{trans_id}</td>|; 402 } 403 } 404 if ($ref->{filename}) { 405 $column_data{filename} = qq|<td><a href=$form->{script}?action=display_documents&login=$form->{login}&path=$form->{path}&id=$ref->{archive_id} target=popup>$ref->{filename}</a></td>|; 406 } 407 $column_data{description} = qq|<td><a href=$form->{script}?action=edit&login=$form->{login}&path=$form->{path}&id=$ref->{id}&callback=$callback>$ref->{description}</a></td>|; 408 409 $column_data{delete} = qq|<td><input name="id_$i" class=checkbox type=checkbox value=$ref->{id}></td>|; 410 411 if ($ref->{login}) { 412 $column_data{confidential} = qq|<td>x</td>|; 413 } 414 415 $j++; $j %= 2; 416 417 print " 418 <tr class=listrow$j> 419"; 420 421 for (@column_index) { print "\n$column_data{$_}" } 422 423 print qq| 424 </tr> 425|; 426 } 427 428 print qq| 429 </table> 430 </td> 431 </tr> 432 <tr> 433 <td><hr size=3 noshade></td> 434 </tr> 435</table> 436|; 437 438 $form->{rowcount} = $i; 439 440 %button = ( 'Add Document' => { ndx => 2, key => 'A', value => $locale->text('Add Document') }, 441 'Delete Documents' => { ndx => 3, key => 'D', value => $locale->text('Delete Documents') }, 442 ); 443 444 $form->print_button(\%button); 445 446 $form->hide_form(qw(rowcount folder formname callback login path)); 447 448 449 if ($form->{menubar}) { 450 require "$form->{path}/menu.pl"; 451 &menubar; 452 } 453 454 print qq| 455</form> 456 457</body> 458</html> 459|; 460 461} 462 463 464sub add_document { &upload } 465 466 467sub edit { 468 469 RD->get_document(\%myconfig, \%$form); 470 471 $form->{title} = $locale->text('Edit Reference Document'); 472 $form->helpref("cms", $myconfig{countrycode}); 473 $form->{confidential} = ($form->{confidential}) ? "checked" : ""; 474 475 $form->error($locale->text('Reference Document does not exist!')) unless $form->{id}; 476 477 %module = &formnames; 478 479 if ($form->{formname}) { 480 $attached = qq| 481 <tr> 482 <th align=right nowrap>|.$locale->text('Attached to').qq|</th>|; 483 484 if ($module{$form->{formname}}{script}) { 485 $href="$module{$form->{formname}}{script}.pl?action=edit&id=$form->{trans_id}&login=$form->{login}&path=$form->{path}"; 486 $href .= "&$module{$form->{formname}}{var}" if $module{$form->{formname}}{var}; 487 } 488 489 $attached .= qq|<td><a href="$href" target=_new>$module{$form->{formname}}{label}</a></td>|; 490 } 491 492 $form->header; 493 494 print qq| 495<body> 496 497<form method=post action=$form->{script}> 498 499<table width=100%> 500 <tr> 501 <th class=listtop>$form->{helpref}$form->{title}</a></th> 502 </tr> 503 <tr height="5"></tr> 504 <tr> 505 <td> 506 <table> 507 <tr> 508 <th align="right">|.$locale->text('Description').qq|</th> 509 <td> 510 <input name=description size=40 value="$form->{description}"> 511 </td> 512 </tr> 513 <tr> 514 <th align="right">|.$locale->text('Folder').qq|</th> 515 <td> 516 <input name=folder size=40 value="$form->{folder}"> 517 </td> 518 </tr> 519 <tr> 520 <th align="right">|.$locale->text('Filename').qq|</th> 521 <td> 522 <input name=file size=40 value="$form->{filename}"> 523 </td> 524 </tr> 525 <tr> 526 <th align=right nowrap>|.$locale->text('Confidential').qq|</th> 527 <td><input name="confidential" class="checkbox" type="checkbox" $form->{confidential}></td> 528 </tr> 529 $attached 530 </table> 531 </td> 532 </tr> 533 <tr> 534 <td><hr size=3 noshade></td> 535 </tr> 536 537</table> 538|; 539 540 $form->hide_form(qw(callback trans_id formname id archive_id login path)); 541 542 %button = ('Save' => { ndx => 1, key => 'S', value => $locale->text('Save') }, 543 'Attach' => { ndx => 2, key => 'A', value => $locale->text('Attach') }, 544 'Detach' => { ndx => 3, key => 'E', value => $locale->text('Detach') }, 545 'Delete' => { ndx => 11, key => 'D', value => $locale->text('Delete') } 546 ); 547 548 delete $button{'Delete'} unless $form->{id}; 549 550 $form->print_button(\%button); 551 552 if ($form->{menubar}) { 553 require "$form->{path}/menu.pl"; 554 &menubar; 555 } 556 557 print qq| 558</form> 559 560</body> 561</html> 562|; 563 564} 565 566 567sub detach { 568 569 $form->redirect($locale->text('Document detached!')) if RD->detach_document(\%myconfig, \%$form); 570 $form->error($locale->text('Could not detach document!')); 571 572} 573 574 575sub attach { 576 577 (undef, $form->{formname}) = split /--/, $form->{formname} if $form->{formname} =~ /--/; 578 579 %m = &formnames; 580 $selectformname = ""; 581 for (sort { $m{$a}->{label} cmp $m{$b}->{label} } keys %m) { 582 $selectformname .= qq|$m{$_}{label}--$_\n|; 583 $formselected = qq|$m{$_}{label}--$_| if $form->{formname} eq $_; 584 } 585 586 $form->{title} = $locale->text('Attach Document'); 587 $form->helpref("cms", $myconfig{countrycode}); 588 589 $form->header; 590 591 print qq| 592<body> 593 594<form method="post" name="main" action="$form->{script}"> 595 596 597<table width=100%> 598 <tr><th class=listtop>$form->{helpref}$form->{title}</a></th></tr> 599 <tr height="5"></tr> 600 <tr> 601 <td> 602 <table> 603 <tr> 604 <th align="right">|.$locale->text('Description').qq|</th> 605 <td>$form->{description} 606 </td> 607 </tr> 608 <tr> 609 <th align="right">|.$locale->text('Folder').qq|</th> 610 <td>$form->{folder} 611 </td> 612 </tr> 613 <tr> 614 <th align="right">|.$locale->text('Filename').qq|</th> 615 <td>$form->{file} 616 </td> 617 </tr> 618 <tr> 619 <th align=right nowrap>|.$locale->text('Attach to').qq|</th> 620 <td><select name=formname>| 621 .$form->select_option($selectformname, $formselected, 1).qq| 622 </td> 623 </tr> 624 <tr> 625 <th align="right">|.$locale->text('ID').qq|</th> 626 <td><input name=trans_id> 627 </td> 628 </tr> 629 </table> 630 </td> 631 <tr> 632 <td><hr size=3 noshade></td> 633 </tr> 634</table> 635 636<br> 637<input class=submit type=submit name=action value="|.$locale->text('Continue').qq|">|; 638 639 $form->{nextsub} = "do_attach"; 640 $form->{action} = $form->{nextsub}; 641 $form->hide_form(qw(id action description folder file callback nextsub login path)); 642 643 if ($form->{menubar}) { 644 require "$form->{path}/menu.pl"; 645 &menubar; 646 } 647 648 print qq| 649</form> 650 651</body> 652</html> 653|; 654 655} 656 657 658sub do_attach { 659 660 %m = &formnames; 661 ($formname, $form->{formname}) = split /--/, $form->{formname}; 662 $form->{db} = $m{$form->{formname}}{db}; 663 664 $form->redirect($locale->text('Document attached!')) if RD->attach_document(\%myconfig, \%$form); 665 666 $form->error($locale->text($formname).qq| |.$locale->text('ID').qq| $form->{trans_id} |.$locale->text('does not exist!')); 667 668} 669 670 671sub delete { 672 673 $form->redirect($locale->text('Document deleted!')) if RD->delete_document(\%myconfig, \%$form); 674 675 $form->error($locale->text('Could not delete document!')); 676 677} 678 679 680sub delete_documents { 681 682 $form->redirect($locale->text('Documents deleted!')) if RD->delete_documents(\%myconfig, \%$form); 683 684} 685 686 687sub save { 688 689 $form->{userspath} = $userspath; 690 $form->redirect($locale->text('Document saved!')) if RD->save_document(\%myconfig, \%$form); 691 $form->error($locale->text('Could not save document!')); 692 693} 694 695 696sub upload_image { 697 698 $form->{title} = $locale->text('Upload Image'); 699 700 $form->helpref("upload_image", $myconfig{countrycode}); 701 702 $form->header; 703 704 $form->{nextsub} = "upload_imagefile"; 705 706 &resize; 707 708 print qq| 709<body> 710 711<form enctype="multipart/form-data" method=post action=$form->{script}> 712 713<table width=100%> 714 <tr> 715 <th class=listtop>$form->{helpref}$form->{title}</a></th> 716 </tr> 717 <tr height="5"></tr> 718 <tr> 719 <td> 720 <table> 721 <tr> 722 <th align="right">|.$locale->text('File').qq|</th> 723 <td> 724 <input name=data size=60 type=file> 725 </td> 726 </tr> 727 </table> 728 </td> 729 </tr> 730 <tr> 731 <td><hr size=3 noshade></td> 732 </tr> 733 734</table> 735|; 736 737 $form->hide_form(qw(nextsub login path)); 738 739 print qq| 740<input name=action class=submit type=submit value="|.$locale->text('Continue').qq|"> 741</form> 742 743</body> 744</html> 745|; 746 747} 748 749 750sub upload_imagefile { 751 752 if (-s "$userspath/$form->{tmpfile}") { 753 unless ($^O =~ /mswin/i) { 754 $image = `file $userspath/$form->{tmpfile}`; 755 unless ($image =~ /image/) { 756 unlink "$userspath/$form->{tmpfile}"; 757 $form->error($locale->text('Not an Image file!')); 758 } 759 } 760 761 open(IN, "$userspath/$form->{tmpfile}") or $form->error("$userspath/$form->{tmpfile} : $!\n"); 762 open(OUT, "> $images/$myconfig{dbname}/$form->{filename}") or $form->error("$images/$myconfig{dbname}/$form->{filename} : $!\n"); 763 764 binmode(IN); 765 binmode(OUT); 766 767 while (<IN>) { 768 print OUT $_; 769 } 770 771 close(IN); 772 close(OUT); 773 774 } 775 776 unlink "$userspath/$form->{tmpfile}"; 777 778 &list_images; 779 780} 781 782 783sub list_images { 784 785 opendir DIR, "$images/$myconfig{dbname}" or $form->error("$images/$myconfig{dbname} : $!"); 786 787 @files = grep !/^\.\.?$/, readdir DIR; 788 closedir DIR; 789 790 @column_index = qw(ndx filename image); 791 792 $form->{allbox} = ($form->{allbox}) ? "checked" : ""; 793 $action = ($form->{deselect}) ? "deselect_all" : "select_all"; 794 $column_data{ndx} = qq|<th class=listheading width=1%><input name="allbox" type=checkbox class=checkbox value="1" $form->{allbox} onChange="CheckAll(); javascript:document.main.submit()"><input type=hidden name=action value="$action"></th>|; 795 $column_data{filename} = "<th class=listheading>".$locale->text('Filename')."</th>"; 796 $column_data{image} = "<th class=listheading>".$locale->text('Image')."</th>"; 797 798 $form->{callback} = "$form->{script}?action=list_images&path=$form->{path}&login=$form->{login}"; 799 800 $form->header; 801 802 &check_all(qw(allbox ndx_)); 803 804 print qq| 805<body> 806 807<form method="post" name="main" action="$form->{script}"> 808 809<table width=100%> 810 <tr> 811 <th class=listtop>$form->{helpref}$form->{title}</a></th> 812 </tr> 813 <tr height="5"></tr> 814 <tr> 815 <td> 816 <table width=100%> 817 <tr class=listheading> 818|; 819 820 for (@column_index) { print "\n$column_data{$_}" } 821 822 print qq| 823 </tr> 824|; 825 826 $checked = ($form->{deselect}) ? "checked" : ""; 827 $i = 0; 828 for (@files) { 829 $i++; 830 $column_data{ndx} = qq|<td><input name="ndx_$i" class=checkbox type=checkbox value=$_ $checked></td>|; 831 $column_data{filename} = qq|<td>$_</td>|; 832 $column_data{image} = "<td><a href=$images/$myconfig{dbname}/$_><img src=$images/$myconfig{dbname}/$_ height=32 border=0></a></td>"; 833 834 $j++; $j %= 2; 835 print "<tr class=listrow$j>"; 836 837 for (@column_index) { print "\n$column_data{$_}" } 838 839 print qq| 840 </tr> 841|; 842 } 843 844 print qq| 845 </table> 846 </td> 847 </tr> 848 <tr><td><hr size=3 noshade></td></tr> 849</table> 850|; 851 852 $form->{rowcount} = $i; 853 854 $form->hide_form(qw(rowcount callback path login)); 855 856 %button = ('Select all' => { ndx => 2, key => 'A', value => $locale->text('Select all') }, 857 'Deselect all' => { ndx => 3, key => 'A', value => $locale->text('Deselect all') }, 858 'Add File' => { ndx => 4, key => 'I', value => $locale->text('Add File') }, 859 'Delete Files' => { ndx => 5, key => 'D', value => $locale->text('Delete Files') } 860 ); 861 862 if ($form->{deselect}) { 863 delete $button{'Select all'}; 864 } else { 865 delete $button{'Deselect all'}; 866 } 867 868 $form->print_button(\%button); 869 870 if ($form->{menubar}) { 871 require "$form->{path}/menu.pl"; 872 &menubar; 873 } 874 875 print qq| 876</form> 877 878</body> 879</html> 880|; 881 882} 883 884 885sub select_all { 886 887 $form->{allbox} = 1; 888 $form->{deselect} = 1; 889 for (qw(allbox deselect)) { $form->{callback} .= "&$_=$form->{$_}" } 890 891 $form->redirect; 892} 893 894 895sub deselect_all { 896 897 $form->redirect; 898 899} 900 901 902sub add_file { &upload_image } 903 904 905sub delete_files { 906 907 for $i (1 .. $form->{rowcount}) { 908 if ($form->{"ndx_$i"}) { 909 unlink qq|$images/$myconfig{dbname}/$form->{"ndx_$i"}|; 910 } 911 } 912 913 $form->redirect; 914 915} 916 917 918sub continue { &{ $form->{nextsub} } }; 919 920