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# administration 11# 12#====================================================================== 13 14 15use SL::AM; 16use SL::CA; 17use SL::Form; 18use SL::User; 19use SL::RP; 20use SL::GL; 21 22require "$form->{path}/js.pl"; 23 24 251; 26# end of main 27 28# this is for our long dates 29# $locale->text('January') 30# $locale->text('February') 31# $locale->text('March') 32# $locale->text('April') 33# $locale->text('May ') 34# $locale->text('June') 35# $locale->text('July') 36# $locale->text('August') 37# $locale->text('September') 38# $locale->text('October') 39# $locale->text('November') 40# $locale->text('December') 41 42# this is for our short month 43# $locale->text('Jan') 44# $locale->text('Feb') 45# $locale->text('Mar') 46# $locale->text('Apr') 47# $locale->text('May') 48# $locale->text('Jun') 49# $locale->text('Jul') 50# $locale->text('Aug') 51# $locale->text('Sep') 52# $locale->text('Oct') 53# $locale->text('Nov') 54# $locale->text('Dec') 55 56 57sub add { &{ "add_$form->{type}" } }; 58sub edit { &{ "edit_$form->{type}" } }; 59sub save { &{ "save_$form->{type}" } }; 60sub delete { &{ "delete_$form->{type}" } }; 61 62 63sub save_as_new { 64 65 $form->{copydir} = $form->{id}; 66 67 for (qw(id oldIC_taxpart oldIC_taxservice)) { delete $form->{$_} } 68 69 &save; 70 71} 72 73 74sub add_account { 75 76 $form->{title} = $locale->text('Add Account'); 77 $form->{charttype} = "A"; 78 79 $form->{callback} = "$form->{script}?action=list_account&path=$form->{path}&login=$form->{login}" unless $form->{callback}; 80 81 &account_header; 82 &form_footer; 83 84} 85 86 87sub edit_account { 88 89 $form->{title} = $locale->text('Edit Account'); 90 91 $form->{accno} =~ s/\\'/'/g; 92 $form->{accno} =~ s/\\\\/\\/g; 93 94 AM->get_account(\%myconfig, \%$form); 95 96 for (split(/:/, $form->{link})) { $form->{$_} = "checked" } 97 98 &account_header; 99 &form_footer; 100 101} 102 103 104sub account_header { 105 106 my %checked; 107 $checked{$form->{charttype}} = "checked"; 108 $checked{contra} = "checked" if $form->{contra}; 109 $checked{"$form->{category}_"} = "checked"; 110 $checked{closed} = "checked" if $form->{closed}; 111 112 $form->{oldIC_taxpart} = $form->{IC_taxpart}; 113 $form->{oldIC_taxservice} = $form->{IC_taxservice}; 114 115 for (qw(accno description)) { $form->{$_} = $form->quote($form->{$_}) } 116 117 $form->{type} = "account"; 118 119 $form->helpref("account", $myconfig{countrycode}); 120 121 $form->header; 122 123 print qq| 124<body> 125 126<form method=post action=$form->{script}> 127 128<input type=hidden name=type value=account> 129|; 130 131 $form->hide_form(qw(id type oldIC_taxpart oldIC_taxservice)); 132 $form->hide_form(map { "${_}_accno_id" } qw(inventory income expense fxgainloss)); 133 134 print qq| 135<table border=0 width=100%> 136 <tr> 137 <th class=listtop>$form->{helpref}$form->{title}</a></th> 138 </tr> 139 <tr height="5"></tr> 140 <tr valign=top> 141 <td> 142 <table> 143 <tr> 144 <th align=right>|.$locale->text('Account Number').qq| <font color=red>*</font></th> 145 <td><input name=accno size=20 value="|.$form->quote($form->{accno}).qq|"></td> 146 <td><input name=closed class=checkbox type=checkbox value=1 $checked{closed}> |.$locale->text('Closed').qq|</td> 147 </tr> 148 <tr> 149 <th align=right>|.$locale->text('Description').qq|</th> 150 <td><input name=description size=40 value="|.$form->quote($form->{description}).qq|"></td> 151 </tr> 152 <tr> 153 <th align=right>|.$locale->text('Account Type').qq| <font color=red>*</font></th> 154 <td> 155 <table> 156 <tr valign=top> 157 <td><input name=category type=radio class=radio value=A $checked{A_}> |.$locale->text('Asset').qq|<br> 158 <input name=category type=radio class=radio value=L $checked{L_}> |.$locale->text('Liability').qq|<br> 159 <input name=category type=radio class=radio value=Q $checked{Q_}> |.$locale->text('Equity').qq|<br> 160 <input name=category type=radio class=radio value=I $checked{I_}> |.$locale->text('Income').qq|<br> 161 <input name=category type=radio class=radio value=E $checked{E_}> |.$locale->text('Expense') 162 .qq|</td> 163 <td> 164 <input name=contra class=checkbox type=checkbox value=1 $checked{contra}> |.$locale->text('Contra').qq| 165 </td> 166 <td> 167 <input name=charttype type=radio class=radio value="H" $checked{H}> |.$locale->text('Heading').qq|<br> 168 <input name=charttype type=radio class=radio value="A" $checked{A}> |.$locale->text('Account') 169 .qq|</td> 170 </tr> 171 </table> 172 </td> 173 </tr> 174|; 175 176 177if ($form->{charttype} eq "A") { 178 print qq| 179 <tr> 180 <td colspan=2> 181 <table> 182 <tr> 183 <th align=left>|.$locale->text('Is this a summary account to record').qq|</th> 184 <td> 185 <input name=AR class=checkbox type=checkbox value=AR $form->{AR}> |.$locale->text('AR') 186 .qq| <input name=AP class=checkbox type=checkbox value=AP $form->{AP}> |.$locale->text('AP') 187 .qq| <input name=IC class=checkbox type=checkbox value=IC $form->{IC}> |.$locale->text('Inventory') 188 .qq|</td> 189 </tr> 190 </table> 191 </td> 192 </tr> 193 <tr> 194 <th colspan=2>|.$locale->text('Include in drop-down menus').qq|</th> 195 </tr> 196 <tr valign=top> 197 <td colspan=2> 198 <table width=100%> 199 <tr> 200 <th align=left>|.$locale->text('AR').qq|</th> 201 <th align=left>|.$locale->text('AP').qq|</th> 202 <th align=left>|.$locale->text('Tracking Items').qq|</th> 203 <th align=left>|.$locale->text('Non-tracking Items').qq|</th> 204 </tr> 205 <tr valign=top> 206 <td> 207 <input name=AR_amount class=checkbox type=checkbox value=AR_amount $form->{AR_amount}> |.$locale->text('Lineitem').qq|<br> 208 <input name=AR_paid class=checkbox type=checkbox value=AR_paid $form->{AR_paid}> |.$locale->text('Payment').qq|<br> 209 <input name=AR_discount class=checkbox type=checkbox value=AR_discount $form->{AR_discount}> |.$locale->text('Discount').qq|<br> 210 <input name=AR_tax class=checkbox type=checkbox value=AR_tax $form->{AR_tax}> |.$locale->text('Tax') .qq| 211 </td> 212 <td> 213 <input name=AP_amount class=checkbox type=checkbox value=AP_amount $form->{AP_amount}> |.$locale->text('Lineitem').qq|<br> 214 <input name=AP_paid class=checkbox type=checkbox value=AP_paid $form->{AP_paid}> |.$locale->text('Payment').qq|<br> 215 <input name=AP_discount class=checkbox type=checkbox value=AP_discount $form->{AP_discount}> |.$locale->text('Discount').qq|<br> 216 <input name=AP_tax class=checkbox type=checkbox value=AP_tax $form->{AP_tax}> |.$locale->text('Tax') .qq| 217 </td> 218 <td> 219 <input name=IC_sale class=checkbox type=checkbox value=IC_sale $form->{IC_sale}> |.$locale->text('Income').qq|<br> 220 <input name=IC_cogs class=checkbox type=checkbox value=IC_cogs $form->{IC_cogs}> |.$locale->text('COGS').qq|<br> 221 <input name=IC_taxpart class=checkbox type=checkbox value=IC_taxpart $form->{IC_taxpart}> |.$locale->text('Tax') .qq| 222 </td> 223 <td> 224 <input name=IC_income class=checkbox type=checkbox value=IC_income $form->{IC_income}> |.$locale->text('Income').qq|<br> 225 <input name=IC_expense class=checkbox type=checkbox value=IC_expense $form->{IC_expense}> |.$locale->text('Expense').qq|<br> 226 <input name=IC_taxservice class=checkbox type=checkbox value=IC_taxservice $form->{IC_taxservice}> |.$locale->text('Tax') .qq| 227 </td> 228 </tr> 229 </table> 230 </td> 231 </tr> 232|; 233} 234 235print qq| 236 <tr> 237 <th align=right>|.$locale->text('GIFI').qq|</th> 238 <td><input name=gifi_accno size=9 value="|.$form->quote($form->{gifi_accno}).qq|"></td> 239 </tr> 240 </table> 241 </td> 242 </tr> 243 <tr> 244 <td><hr size=3 noshade></td> 245 </tr> 246</table> 247|; 248 249} 250 251 252sub form_footer { 253 254 $form->hide_form(qw(callback path login)); 255 256 my %button; 257 258 if ($form->{id}) { 259 $button{'Save'} = { ndx => 3, key => 'S', value => $locale->text('Save') }; 260 $button{'Save as new'} = { ndx => 7, key => 'N', value => $locale->text('Save as new') } if $form->{type} ne 'currency'; 261 262 if ($form->{orphaned}) { 263 $button{'Delete'} = { ndx => 16, key => 'D', value => $locale->text('Delete') }; 264 } 265 } else { 266 $button{'Save'} = { ndx => 3, key => 'S', value => $locale->text('Save') }; 267 } 268 269 $form->print_button(\%button); 270 271 if ($form->{menubar}) { 272 require "$form->{path}/menu.pl"; 273 &menubar; 274 } 275 276 print qq| 277</form> 278 279</body> 280</html> 281|; 282 283} 284 285 286sub save_account { 287 288 $form->isblank("accno", $locale->text('Account Number missing!')); 289 $form->isblank("category", $locale->text('Account Type missing!')); 290 291 # check for conflicting accounts 292 if ($form->{AR} || $form->{AP} || $form->{IC}) { 293 my $a = ""; 294 for (qw(AR AP IC)) { $a .= $form->{$_} } 295 $form->error($locale->text('Cannot set account for more than one of AR, AP or IC')) if length $a > 2; 296 297 for (qw(AR_amount AR_tax AR_paid AP_amount AP_tax AP_paid IC_taxpart IC_taxservice IC_sale IC_cogs IC_income IC_expense)) { $form->error("$form->{AR}$form->{AP}$form->{IC} ". $locale->text('account cannot be set to any other type of account')) if $form->{$_} } 298 } 299 300 foreach my $item (qw(AR AP)) { 301 my $i = 0; 302 for ("${item}_amount", "${item}_paid", "${item}_discount", "${item}_tax") { $i++ if $form->{$_} } 303 $form->error($locale->text('Cannot set multiple options for')." $item") if $i > 1; 304 } 305 306 if (AM->save_account(\%myconfig, \%$form)) { 307 $form->redirect($locale->text('Account saved!')); 308 } else { 309 $form->error($locale->text('Cannot save account!')); 310 } 311 312} 313 314 315sub list_account { 316 317 CA->all_accounts(\%myconfig, \%$form); 318 319 $form->{title} = $locale->text('Chart of Accounts') . " / $form->{company}"; 320 321 # construct callback 322 my $callback = "$form->{script}?action=list_account&path=$form->{path}&login=$form->{login}"; 323 324 my %dropdown = ( AR => $locale->text('AR'), 325 AP => $locale->text('AP'), 326 AR_paid => $locale->text('AR Payment'), 327 AR_amount => $locale->text('AR Amount'), 328 AR_tax => $locale->text('Tax collected'), 329 AR_discount => $locale->text('Early Payment Discount given'), 330 AP_paid => $locale->text('AP Payment'), 331 AP_amount => $locale->text('AP Amount'), 332 AP_tax => $locale->text('Tax paid'), 333 AP_discount => $locale->text('Early Payment Discount received'), 334 IC => $locale->text('Inventory'), 335 IC_sale => $locale->text('Tracking Item Income'), 336 IC_income => $locale->text('Non-tracking Item Income'), 337 IC_cogs => $locale->text('COGS'), 338 IC_expense => $locale->text('Non-tracking Item Expense'), 339 IC_taxpart => $locale->text('Tracking Item Tax'), 340 IC_taxservice => $locale->text('Non-tracking Item Tax') 341 ); 342 343 my %category = ( A => $locale->text('Asset'), 344 L => $locale->text('Liability'), 345 Q => $locale->text('Equity'), 346 I => $locale->text('Income'), 347 E => $locale->text('Expense') 348 ); 349 my @column_index = qw(accno gifi_accno description category contra dropdown closed); 350 351 my %column_data; 352 353 $column_data{accno} = qq|<th class=listtop>|.$locale->text('Account').qq|</a></th>|; 354 $column_data{gifi_accno} = qq|<th class=listtop>|.$locale->text('GIFI').qq|</a></th>|; 355 $column_data{description} = qq|<th class=listtop>|.$locale->text('Description').qq|</a></th>|; 356 $column_data{dropdown} = qq|<th class=listtop>|.$locale->text('Drop-down').qq|</a></th>|; 357 $column_data{category} = qq|<th class=listtop>|.$locale->text('Type').qq|</a></th>|; 358 $column_data{contra} = qq|<th width=1% class=listtop>|.$locale->text('Contra').qq|</a></th>|; 359 $column_data{closed} = qq|<th width=1% class=listtop>|.$locale->text('Closed').qq|</a></th>|; 360 361 $form->helpref("list_account", $myconfig{countrycode}); 362 363 $form->header; 364 365 my $colspan = $#column_index + 1; 366 367 print qq| 368<body> 369 370<table width=100%> 371 <tr> 372 <th class=listtop colspan=$colspan>$form->{helpref}$form->{title}</a></th> 373 </tr> 374 <tr height=5></tr> 375 <tr class=listheading> 376|; 377 378 for (@column_index) { print "$column_data{$_}\n" } 379 380 print qq| 381</tr> 382|; 383 384 # escape callback 385 $callback = $form->escape($callback); 386 387 foreach my $ref (@{ $form->{CA} }) { 388 389 $ref->{dropdown} = join '<br>', map { $dropdown{$_} } split /:/, $ref->{link}; 390 391 my $gifi_accno = $form->escape($ref->{gifi_accno}); 392 393 if ($ref->{charttype} eq "H") { 394 print qq|<tr class=listheading>|; 395 396 $column_data{accno} = qq|<th><a class=listheading href=$form->{script}?action=edit_account&id=$ref->{id}&path=$form->{path}&login=$form->{login}&callback=$callback>$ref->{accno}</a></th>|; 397 $column_data{gifi_accno} = qq|<th><a class=listheading href=$form->{script}?action=edit_gifi&accno=$gifi_accno&path=$form->{path}&login=$form->{login}&callback=$callback>$ref->{gifi_accno}</a> </th>|; 398 $column_data{description} = qq|<th class=listheading>$ref->{description} </th>|; 399 $column_data{dropdown} = qq|<th> </th>|; 400 $column_data{category} = qq|<th class=listheading>$category{$ref->{category}} </th>|; 401 $column_data{contra} = qq|<td> </td>|; 402 $column_data{closed} = qq|<td> </td>|; 403 404 } else { 405 $i++; $i %= 2; 406 print qq| 407<tr valign=top class=listrow$i>|; 408 $column_data{accno} = qq|<td><a href=$form->{script}?action=edit_account&id=$ref->{id}&path=$form->{path}&login=$form->{login}&callback=$callback>$ref->{accno}</a></td>|; 409 $column_data{gifi_accno} = qq|<td><a href=$form->{script}?action=edit_gifi&accno=$ref->{gifi_accno}&path=$form->{path}&login=$form->{login}&callback=$callback>$ref->{gifi_accno}</a> </td>|; 410 $column_data{description} = qq|<td>$ref->{description} </td>|; 411 $column_data{dropdown} = qq|<td>$ref->{dropdown} </td>|; 412 $column_data{category} = qq|<td>$category{$ref->{category}} </td>|; 413 414 $ref->{contra} = ($ref->{contra}) ? '*' : ' '; 415 $column_data{contra} = qq|<td align=center>$ref->{contra}</td>|; 416 $ref->{closed} = ($ref->{closed}) ? '*' : ' '; 417 $column_data{closed} = qq|<td align=center>$ref->{closed}</td>|; 418 } 419 420 for (@column_index) { print "$column_data{$_}\n" } 421 422 print "</tr>\n"; 423 } 424 425 print qq| 426 <tr><td colspan=$colspan><hr size=3 noshade></td></tr> 427</table> 428 429</body> 430</html> 431|; 432 433} 434 435 436sub delete_account { 437 438 $form->{title} = $locale->text('Delete Account'); 439 440 for (qw(inventory_accno_id income_accno_id expense_accno_id fxgainloss_accno_id)) { 441 if ($form->{id} == $form->{$_}) { 442 $form->error($locale->text('Cannot delete default account!')); 443 } 444 } 445 446 if (AM->delete_account(\%myconfig, \%$form)) { 447 $form->redirect($locale->text('Account deleted!')); 448 } else { 449 $form->error($locale->text('Cannot delete account!')); 450 } 451 452} 453 454 455sub list_gifi { 456 457 @{ $form->{fields} } = qw(accno description); 458 $form->{table} = "gifi"; 459 460 AM->gifi_accounts(\%myconfig, \%$form); 461 462 $form->{title} = $locale->text('GIFI') . " / $form->{company}"; 463 464 # construct callback 465 my $callback = "$form->{script}?action=list_gifi&path=$form->{path}&login=$form->{login}"; 466 467 my @column_index = qw(accno description); 468 469 my %column_data; 470 471 $column_data{accno} = qq|<th class=listheading>|.$locale->text('GIFI').qq|</a></th>|; 472 $column_data{description} = qq|<th class=listheading>|.$locale->text('Description').qq|</a></th>|; 473 474 $form->helpref("list_gifi", $myconfig{countrycode}); 475 476 $form->header; 477 478 my $colspan = $#column_index + 1; 479 480 print qq| 481<body> 482 483<table width=100%> 484 <tr> 485 <th class=listtop colspan=$colspan>$form->{helpref}$form->{title}</a></th> 486 </tr> 487 <tr height="5"></tr> 488 <tr class=listheading> 489|; 490 491 for (@column_index) { print "$column_data{$_}\n" } 492 493 print qq| 494</tr> 495|; 496 497 # escape callback 498 $callback = $form->escape($callback); 499 500 my $i; 501 502 foreach my $ref (@{ $form->{ALL} }) { 503 504 $i++; $i %= 2; 505 506 print qq| 507<tr valign=top class=listrow$i>|; 508 509 my $accno = $form->escape($ref->{accno}); 510 $column_data{accno} = qq|<td><a href=$form->{script}?action=edit_gifi&coa=1&accno=$accno&path=$form->{path}&login=$form->{login}&callback=$callback>$ref->{accno}</td>|; 511 $column_data{description} = qq|<td>$ref->{description} </td>|; 512 513 for (@column_index) { print "$column_data{$_}\n" } 514 515 print "</tr>\n"; 516 } 517 518 print qq| 519 <tr> 520 <td colspan=$colspan><hr size=3 noshade></td> 521 </tr> 522</table> 523 524</body> 525</html> 526|; 527 528} 529 530 531sub add_gifi { 532 533 $form->{title} = $locale->text('Add GIFI'); 534 535 # construct callback 536 $form->{callback} = "$form->{script}?action=list_gifi&path=$form->{path}&login=$form->{login}" unless $form->{callback}; 537 538 $form->{coa} = 1; 539 540 &gifi_header; 541 &gifi_footer; 542 543} 544 545 546sub edit_gifi { 547 548 $form->{title} = $locale->text('Edit GIFI'); 549 550 $accno = $form->{accno}; 551 552 AM->get_gifi(\%myconfig, \%$form); 553 554 if ($form->{accno}) { 555 &gifi_header; 556 &gifi_footer; 557 } else { 558 $form->{accno} = $accno; 559 add_gifi; 560 } 561 562} 563 564 565sub gifi_header { 566 567 for (qw(accno description)) { $form->{$_} = $form->quote($form->{$_}) } 568 569 $form->helpref("gifi", $myconfig{countrycode}); 570 571 $form->header; 572 573 print qq| 574<body> 575 576<form method=post action=$form->{script}> 577 578<input type=hidden name=id value="$form->{accno}"> 579<input type=hidden name=type value=gifi> 580 581<table width=100%> 582 <tr> 583 <th class=listtop>$form->{helpref}$form->{title}</a></th> 584 </tr> 585 <tr height="5"></tr> 586 <tr> 587 <td> 588 <table> 589 <tr> 590 <th align=right>|.$locale->text('GIFI').qq|</th> 591 <td><input name=accno size=20 value="|.$form->quote($form->{accno}).qq|"></td> 592 </tr> 593 <tr> 594 <th align=right>|.$locale->text('Description').qq|</th> 595 <td><input name=description size=60 value="|.$form->quote($form->{description}).qq|"></td> 596 </tr> 597 </table> 598 </td> 599 </tr> 600 <tr> 601 <td colspan=2><hr size=3 noshade></td> 602 </tr> 603</table> 604|; 605 606} 607 608 609sub gifi_footer { 610 611 $form->hide_form(qw(callback path login)); 612 613 my %button; 614 615 $button{'Save'} = { ndx => 3, key => 'S', value => $locale->text('Save') }; 616 617 if ($form->{accno}) { 618 if ($form->{orphaned}) { 619 $button{'Delete'} = { ndx => 16, key => 'D', value => $locale->text('Delete') }; 620 } 621 } 622 623 if ($form->{coa}) { 624 $button{'Copy to COA'} = { ndx => 7, key => 'C', value => $locale->text('Copy to COA') }; 625 } 626 627 $form->print_button(\%button); 628 629 if ($form->{menubar}) { 630 require "$form->{path}/menu.pl"; 631 &menubar; 632 } 633 634 print qq| 635 </form> 636 637</body> 638</html> 639|; 640 641} 642 643 644sub save_gifi { 645 646 $form->isblank("accno", $locale->text('GIFI missing!')); 647 AM->save_gifi(\%myconfig, \%$form); 648 $form->redirect($locale->text('GIFI saved!')); 649 650} 651 652 653sub copy_to_coa { 654 655 $form->isblank("accno", $locale->text('GIFI missing!')); 656 657 AM->save_gifi(\%myconfig, \%$form); 658 659 delete $form->{id}; 660 $form->{gifi_accno} = $form->{accno}; 661 662 $form->{title} = "Add"; 663 $form->{charttype} = "A"; 664 665 &account_header; 666 &form_footer; 667 668} 669 670 671sub delete_gifi { 672 673 AM->delete_gifi(\%myconfig, \%$form); 674 $form->redirect($locale->text('GIFI deleted!')); 675 676} 677 678 679sub add_department { 680 681 $form->{title} = $locale->text('Add Department'); 682 $form->{role} = "P"; 683 684 $form->{callback} = "$form->{script}?action=add_department&path=$form->{path}&login=$form->{login}" unless $form->{callback}; 685 686 &department_header; 687 &form_footer; 688 689} 690 691 692sub edit_department { 693 694 $form->{title} = $locale->text('Edit Department'); 695 696 AM->get_department(\%myconfig, \%$form); 697 698 &department_header; 699 &form_footer; 700 701} 702 703 704sub list_department { 705 706 AM->departments(\%myconfig, \%$form); 707 708 $form->{callback} = "$form->{script}?action=list_department"; 709 710 for (qw(path login)) { $form->{callback} .= "&$_=$form->{$_}" } 711 712 my $callback = $form->escape($form->{callback}); 713 714 $form->{title} = $locale->text('Departments') . " / $form->{company}"; 715 716 my @column_index = qw(description cost profit up down); 717 718 my %column_data; 719 720 $column_data{description} = qq|<th width=90% class=listheading>|.$locale->text('Description').qq|</th>|; 721 $column_data{cost} = qq|<th class=listheading nowrap>|.$locale->text('Cost Center').qq|</th>|; 722 $column_data{profit} = qq|<th class=listheading nowrap>|.$locale->text('Profit Center').qq|</th>|; 723 $column_data{up} = qq|<th class=listheading> </th>|; 724 $column_data{down} = qq|<th class=listheading> </th>|; 725 726 $form->helpref("list_department", $myconfig{countrycode}); 727 728 $form->header; 729 730 print qq| 731<body> 732 733<table width=100%> 734 <tr> 735 <th class=listtop>$form->{helpref}$form->{title}</a></th> 736 </tr> 737 <tr height="5"></tr> 738 <tr> 739 <td> 740 <table width=100%> 741 <tr class=listheading> 742|; 743 744 for (@column_index) { print "$column_data{$_}\n" } 745 746 print qq| 747 </tr> 748|; 749 750 my $i; 751 my $costcenter; 752 my $profitcenter; 753 754 foreach my $ref (@{ $form->{ALL} }) { 755 756 $i++; $i %= 2; 757 758 print qq| 759 <tr valign=top class=listrow$i> 760|; 761 762 $costcenter = ($ref->{role} eq "C") ? "*" : " "; 763 $profitcenter = ($ref->{role} eq "P") ? "*" : " "; 764 765 $column_data{description} = qq|<td><a href=$form->{script}?action=edit_department&id=$ref->{id}&path=$form->{path}&login=$form->{login}&callback=$callback>$ref->{description}</td>|; 766 $column_data{cost} = qq|<td align=center>$costcenter</td>|; 767 $column_data{profit} = qq|<td align=center>$profitcenter</td>|; 768 $column_data{up} = qq|<td><a href=$form->{script}?action=move&db=department&fld=id&id=$ref->{id}&move=up&path=$form->{path}&login=$form->{login}&callback=$callback><img src=$images/up.png alt="+" border=0></td>|; 769 $column_data{down} = qq|<td><a href=$form->{script}?action=move&db=department&fld=id&id=$ref->{id}&move=down&path=$form->{path}&login=$form->{login}&callback=$callback><img src=$images/down.png alt="-" border=0></td>|; 770 771 for (@column_index) { print "$column_data{$_}\n" } 772 773 print qq| 774 </tr> 775|; 776 } 777 778 print qq| 779 </table> 780 </td> 781 </tr> 782 <tr> 783 <td><hr size=3 noshade></td> 784 </tr> 785</table> 786 787<br> 788<form method=post action=$form->{script}> 789|; 790 791 $form->{type} = "department"; 792 793 $form->hide_form(qw(type callback path login)); 794 795 print qq| 796<input class=submit type=submit name=action value="|.$locale->text('Add Department').qq|">|; 797 798 if ($form->{menubar}) { 799 require "$form->{path}/menu.pl"; 800 &menubar; 801 } 802 803 print qq| 804 </form> 805 806</body> 807</html> 808|; 809 810} 811 812 813sub department_header { 814 815 $form->{description} = $form->quote($form->{description}); 816 817 my $rows; 818 my $description; 819 820 if (($rows = $form->numtextrows($form->{description}, 60)) > 1) { 821 $description = qq|<textarea name="description" rows=$rows cols=60 wrap=soft>$form->{description}</textarea>|; 822 } else { 823 $description = qq|<input name=description size=60 value="|.$form->quote($form->{description}).qq|">|; 824 } 825 826 my %checked; 827 828 $checked{C} = "checked" if $form->{role} eq "C"; 829 $checked{P} = "checked" if $form->{role} eq "P"; 830 831 $form->helpref("department", $myconfig{countrycode}); 832 833 $form->header; 834 835 print qq| 836<body> 837 838<form method=post action=$form->{script}> 839 840<input type=hidden name=id value=$form->{id}> 841<input type=hidden name=type value=department> 842 843<table width=100%> 844 <tr> 845 <th class=listtop colspan=2>$form->{helpref}$form->{title}</a></th> 846 </tr> 847 <tr height="5"></tr> 848 <tr> 849 <th align=right>|.$locale->text('Description').qq|</th> 850 <td>$description</td> 851 </tr> 852 <tr> 853 <td></td> 854 <td><input type=radio class=radio name=role value="C" $checked{C}> |.$locale->text('Cost Center').qq| 855 <input type=radio class=radio name=role value="P" $checked{P}> |.$locale->text('Profit Center').qq| 856 </td> 857 </tr> 858 <tr> 859 <td colspan=2><hr size=3 noshade></td> 860 </tr> 861</table> 862|; 863 864} 865 866 867sub save_department { 868 869 $form->isblank("description", $locale->text('Description missing!')); 870 AM->save_department(\%myconfig, \%$form); 871 $form->redirect($locale->text('Department saved!')); 872 873} 874 875 876sub delete_department { 877 878 AM->delete_department(\%myconfig, \%$form); 879 $form->redirect($locale->text('Department deleted!')); 880 881} 882 883 884sub add_business { 885 886 $form->{title} = $locale->text('Add Business'); 887 888 $form->{callback} = "$form->{script}?action=add_business&path=$form->{path}&login=$form->{login}" unless $form->{callback}; 889 890 &business_header; 891 &form_footer; 892 893} 894 895 896sub edit_business { 897 898 $form->{title} = $locale->text('Edit Business'); 899 900 AM->get_business(\%myconfig, \%$form); 901 902 &business_header; 903 904 $form->{orphaned} = 1; 905 &form_footer; 906 907} 908 909 910sub list_business { 911 912 AM->business(\%myconfig, \%$form); 913 914 $form->{callback} = "$form->{script}?action=list_business"; 915 916 for (qw(path login)) { $form->{callback} .= "&$_=$form->{$_}" } 917 918 my $callback = $form->escape($form->{callback}); 919 920 $form->{title} = $locale->text('Type of Business') . " / $form->{company}"; 921 922 my @column_index = qw(description discount up down); 923 924 my %column_data; 925 926 $column_data{description} = qq|<th width=90% class=listheading>|.$locale->text('Description').qq|</th>|; 927 $column_data{discount} = qq|<th class=listheading>|.$locale->text('Discount').qq| %</th>|; 928 $column_data{up} = qq|<th class=listheading> </th>|; 929 $column_data{down} = qq|<th class=listheading> </th>|; 930 931 $form->helpref("list_business", $myconfig{countrycode}); 932 933 $form->header; 934 935 print qq| 936<body> 937 938<table width=100%> 939 <tr> 940 <th class=listtop>$form->{helpref}$form->{title}</a></th> 941 </tr> 942 <tr height="5"></tr> 943 <tr> 944 <td> 945 <table width=100%> 946 <tr class=listheading> 947|; 948 949 for (@column_index) { print "$column_data{$_}\n" } 950 951 print qq| 952 </tr> 953|; 954 955 my $i; 956 my $discount; 957 958 foreach my $ref (@{ $form->{ALL} }) { 959 960 $i++; $i %= 2; 961 962 print qq| 963 <tr valign=top class=listrow$i> 964|; 965 966 $discount = $form->format_amount(\%myconfig, $ref->{discount} * 100, $form->{precision}, " "); 967 968 $column_data{description} = qq|<td><a href=$form->{script}?action=edit_business&id=$ref->{id}&path=$form->{path}&login=$form->{login}&callback=$callback>$ref->{description}</td>|; 969 $column_data{discount} = qq|<td align=right>$discount</td>|; 970 $column_data{up} = qq|<td><a href=$form->{script}?action=move&db=business&fld=id&id=$ref->{id}&move=up&path=$form->{path}&login=$form->{login}&callback=$callback><img src=$images/up.png alt="+" border=0></td>|; 971 $column_data{down} = qq|<td><a href=$form->{script}?action=move&db=business&fld=id&id=$ref->{id}&move=down&path=$form->{path}&login=$form->{login}&callback=$callback><img src=$images/down.png alt="-" border=0></td>|; 972 973 for (@column_index) { print "$column_data{$_}\n" } 974 975 print qq| 976 </tr> 977|; 978 } 979 980 print qq| 981 </table> 982 </td> 983 </tr> 984 <tr> 985 <td><hr size=3 noshade></td> 986 </tr> 987</table> 988 989<br> 990<form method=post action=$form->{script}> 991|; 992 993 $form->{type} = "business"; 994 995 $form->hide_form(qw(type callback path login)); 996 997 print qq| 998<input class=submit type=submit name=action value="|.$locale->text('Add Business').qq|">|; 999 1000 if ($form->{menubar}) { 1001 require "$form->{path}/menu.pl"; 1002 &menubar; 1003 } 1004 1005 print qq| 1006</form> 1007 1008</body> 1009</html> 1010|; 1011 1012} 1013 1014 1015sub business_header { 1016 1017 $form->{description} = $form->quote($form->{description}); 1018 $form->{discount} = $form->format_amount(\%myconfig, $form->{discount} * 100); 1019 1020 $form->helpref("business", $myconfig{countrycode}); 1021 1022 $form->header; 1023 1024 print qq| 1025<body> 1026 1027<form method=post action=$form->{script}> 1028 1029<input type=hidden name=id value=$form->{id}> 1030<input type=hidden name=type value=business> 1031 1032<table width=100%> 1033 <tr> 1034 <th class=listtop>$form->{helpref}$form->{title}</a></th> 1035 </tr> 1036 <tr height="5"></tr> 1037 <tr> 1038 <td> 1039 <table> 1040 <tr> 1041 <th align=right>|.$locale->text('Type of Business').qq|</th> 1042 <td><input name=description size=30 value="|.$form->quote($form->{description}).qq|"></td> 1043 <tr> 1044 <tr> 1045 <th align=right>|.$locale->text('Discount').qq| %</th> 1046 <td><input name=discount class="inputright" size=5 value=$form->{discount}></td> 1047 </tr> 1048 </table> 1049 </td> 1050 </tr> 1051 <tr> 1052 <td><hr size=3 noshade></td> 1053 </tr> 1054</table> 1055|; 1056 1057} 1058 1059 1060sub save_business { 1061 1062 $form->isblank("description", $locale->text('Description missing!')); 1063 AM->save_business(\%myconfig, \%$form); 1064 $form->redirect($locale->text('Business saved!')); 1065 1066} 1067 1068 1069sub delete_business { 1070 1071 AM->delete_business(\%myconfig, \%$form); 1072 $form->redirect($locale->text('Business deleted!')); 1073 1074} 1075 1076 1077 1078sub add_payment_method { 1079 1080 $form->{title} = $locale->text('Add Payment Method'); 1081 1082 $form->{callback} = "$form->{script}?action=add_payment_method&path=$form->{path}&login=$form->{login}" unless $form->{callback}; 1083 1084 $form->{roundchange} = 0; 1085 &paymentmethod_header; 1086 &form_footer; 1087 1088} 1089 1090 1091sub edit_paymentmethod { 1092 1093 $form->{title} = $locale->text('Edit Payment Method'); 1094 1095 AM->get_paymentmethod(\%myconfig, \%$form); 1096 1097 &paymentmethod_header; 1098 1099 $form->{orphaned} = 1; 1100 &form_footer; 1101 1102} 1103 1104 1105sub list_paymentmethod { 1106 1107 AM->paymentmethod(\%myconfig, \%$form); 1108 1109 my $href = "$form->{script}?action=list_paymentmethod&direction=$form->{direction}&oldsort=$form->{oldsort}&path=$form->{path}&login=$form->{login}"; 1110 1111 $form->sort_order(); 1112 1113 $form->{callback} = "$form->{script}?action=list_paymentmethod&direction=$form->{direction}&oldsort=$form->{oldsort}&path=$form->{path}&login=$form->{login}"; 1114 1115 my $callback = $form->escape($form->{callback}); 1116 1117 $form->{title} = $locale->text('Method of Payment'); 1118 1119 my @column_index = qw(rn description fee roundchange up down); 1120 1121 my %column_data; 1122 1123 $column_data{rn} = qq|<th><a class=listheading href=$href&sort=rn>|.$locale->text('No.').qq|</a></th>|; 1124 $column_data{description} = qq|<th width=99%><a class=listheading href=$href&sort=description>|.$locale->text('Description').qq|</a></th>|; 1125 $column_data{fee} = qq|<th class=listheading>|.$locale->text('Fee').qq|</th>|; 1126 $column_data{roundchange} = qq|<th class=listheading>|.$locale->text('Round').qq|</th>|; 1127 $column_data{up} = qq|<th class=listheading> </th>|; 1128 $column_data{down} = qq|<th class=listheading> </th>|; 1129 1130 $form->helpref("list_paymentmethod", $myconfig{countrycode}); 1131 1132 $form->{title} .= " / $form->{company}"; 1133 1134 $form->header; 1135 1136 print qq| 1137<body> 1138 1139<table width=100%> 1140 <tr> 1141 <th class=listtop>$form->{helpref}$form->{title}</a></th> 1142 </tr> 1143 <tr height="5"></tr> 1144 <tr> 1145 <td> 1146 <table width=100%> 1147 <tr class=listheading> 1148|; 1149 1150 for (@column_index) { print "$column_data{$_}\n" } 1151 1152 print qq| 1153 </tr> 1154|; 1155 1156 my $i; 1157 my $fee; 1158 1159 foreach my $ref (@{ $form->{ALL} }) { 1160 1161 $i++; $i %= 2; 1162 1163 print qq| 1164 <tr valign=top class=listrow$i> 1165|; 1166 1167 $fee = $form->format_amount(\%myconfig, $ref->{fee}, $form->{precision}, " "); 1168 $roundchange = $form->format_amount(\%myconfig, $ref->{roundchange}, $form->{precision}, " "); 1169 1170 $column_data{rn} = qq|<td align=right>$ref->{rn}</td>|; 1171 $column_data{description} = qq|<td><a href=$form->{script}?action=edit_paymentmethod&id=$ref->{id}&path=$form->{path}&login=$form->{login}&callback=$callback>$ref->{description}</td>|; 1172 $column_data{fee} = qq|<td align=right>$fee</td>|; 1173 $column_data{roundchange} = qq|<td align=right>$roundchange</td>|; 1174 $column_data{up} = qq|<td><a href=$form->{script}?action=move&db=paymentmethod&fld=id&id=$ref->{id}&move=up&path=$form->{path}&login=$form->{login}&callback=$callback><img src=$images/up.png alt="+" border=0></td>|; 1175 $column_data{down} = qq|<td><a href=$form->{script}?action=move&db=paymentmethod&fld=id&id=$ref->{id}&move=down&path=$form->{path}&login=$form->{login}&callback=$callback><img src=$images/down.png alt="-" border=0></td>|; 1176 1177 for (@column_index) { print "$column_data{$_}\n" } 1178 1179 print qq| 1180 </tr> 1181|; 1182 } 1183 1184 print qq| 1185 </table> 1186 </td> 1187 </tr> 1188 <tr> 1189 <td><hr size=3 noshade></td> 1190 </tr> 1191</table> 1192 1193<br> 1194<form method=post action=$form->{script}> 1195|; 1196 1197 $form->{type} = "paymentmethod"; 1198 1199 $form->hide_form(qw(type callback path login)); 1200 1201 print qq| 1202<input class=submit type=submit name=action value="|.$locale->text('Add Payment Method').qq|">|; 1203 1204 if ($form->{menubar}) { 1205 require "$form->{path}/menu.pl"; 1206 &menubar; 1207 } 1208 1209 print qq| 1210</form> 1211 1212</body> 1213</html> 1214|; 1215 1216} 1217 1218 1219sub paymentmethod_header { 1220 1221 $form->{description} = $form->quote($form->{description}); 1222 $form->{fee} = $form->format_amount(\%myconfig, $form->{fee}, $form->{precision}); 1223 1224 $roundchange{$form->{roundchange}} = "checked"; 1225 1226 $form->helpref("paymentmethod", $myconfig{countrycode}); 1227 1228 $form->header; 1229 1230 print qq| 1231<body> 1232 1233<form method=post action=$form->{script}> 1234 1235<input type=hidden name=id value=$form->{id}> 1236<input type=hidden name=type value=paymentmethod> 1237 1238<table width=100%> 1239 <tr> 1240 <th class=listtop>$form->{helpref}$form->{title}</a></th> 1241 </tr> 1242 <tr height="5"></tr> 1243 <tr> 1244 <td> 1245 <table> 1246 <tr> 1247 <th align=right>|.$locale->text('Payment Method').qq|</th> 1248 <td><input name=description size=30 value="|.$form->quote($form->{description}).qq|"></td> 1249 </tr> 1250 <tr> 1251 <th align=right>|.$locale->text('Round').qq|</th> 1252 <td> 1253 <input name=roundchange type=radio class=radio value="0" $roundchange{0}>0 1254 <input name=roundchange type=radio class=radio value="0.05" $roundchange{0.05}>|.$form->format_amount(\%myconfig, 0.05, $form->{precision}).qq| 1255 <input name=roundchange type=radio class=radio value="0.1" $roundchange{0.1}>|.$form->format_amount(\%myconfig, 0.10, $form->{precision}).qq| 1256 <input name=roundchange type=radio class=radio value="0.2" $roundchange{0.2}>|.$form->format_amount(\%myconfig, 0.20, $form->{precision}).qq| 1257 <input name=roundchange type=radio class=radio value="0.25" $roundchange{0.25}>|.$form->format_amount(\%myconfig, 0.25, $form->{precision}).qq| 1258 <input name=roundchange type=radio class=radio value="0.5" $roundchange{0.5}>|.$form->format_amount(\%myconfig, 0.50, $form->{precision}).qq| 1259 <input name=roundchange type=radio class=radio value="1" $roundchange{1}>|.$form->format_amount(\%myconfig, 1.00, $form->{precision}).qq| 1260 </td> 1261 </tr> 1262 <tr> 1263 <th align=right>|.$locale->text('Fee').qq|</th> 1264 <td><input name=fee class="inputright" size=12 value=$form->{fee}></td> 1265 </tr> 1266 </table> 1267 </td> 1268 </tr> 1269 <tr> 1270 <td><hr size=3 noshade></td> 1271 </tr> 1272</table> 1273|; 1274 1275} 1276 1277 1278sub save_paymentmethod { 1279 1280 $form->isblank("description", $locale->text('Description missing!')); 1281 AM->save_paymentmethod(\%myconfig, \%$form); 1282 $form->redirect($locale->text('Payment Method saved!')); 1283 1284} 1285 1286 1287sub delete_paymentmethod { 1288 1289 AM->delete_paymentmethod(\%myconfig, \%$form); 1290 $form->redirect($locale->text('Payment Method deleted!')); 1291 1292} 1293 1294 1295sub add_sic { 1296 1297 $form->{title} = $locale->text('Add SIC'); 1298 1299 $form->{callback} = "$form->{script}?action=add_sic&path=$form->{path}&login=$form->{login}" unless $form->{callback}; 1300 1301 &sic_header; 1302 &form_footer; 1303 1304} 1305 1306 1307sub edit_sic { 1308 1309 $form->{title} = $locale->text('Edit SIC'); 1310 1311 $form->{code} =~ s/\\'/'/g; 1312 $form->{code} =~ s/\\\\/\\/g; 1313 1314 AM->get_sic(\%myconfig, \%$form); 1315 $form->{id} = $form->{code}; 1316 1317 &sic_header; 1318 1319 $form->{orphaned} = 1; 1320 &form_footer; 1321 1322} 1323 1324 1325sub list_sic { 1326 1327 AM->sic(\%myconfig, \%$form); 1328 1329 my $href = "$form->{script}?action=list_sic&direction=$form->{direction}&oldsort=$form->{oldsort}&path=$form->{path}&login=$form->{login}"; 1330 1331 $form->sort_order(); 1332 1333 $form->{callback} = "$form->{script}?action=list_sic&direction=$form->{direction}&oldsort=$form->{oldsort}&path=$form->{path}&login=$form->{login}"; 1334 1335 my $callback = $form->escape($form->{callback}); 1336 1337 $form->{title} = $locale->text('Standard Industrial Codes'); 1338 1339 my @column_index = $form->sort_columns(qw(code description)); 1340 1341 my %column_data; 1342 1343 $column_data{code} = qq|<th><a class=listheading href=$href&sort=code>|.$locale->text('Code').qq|</a></th>|; 1344 $column_data{description} = qq|<th><a class=listheading href=$href&sort=description>|.$locale->text('Description').qq|</a></th>|; 1345 1346 $form->helpref("list_sic", $myconfig{countrycode}); 1347 1348 $form->{title} .= " / $form->{company}"; 1349 1350 $form->header; 1351 1352 print qq| 1353<body> 1354 1355<table width=100%> 1356 <tr> 1357 <th class=listtop>$form->{helpref}$form->{title}</a></th> 1358 </tr> 1359 <tr height="5"></tr> 1360 <tr> 1361 <td> 1362 <table width=100%> 1363 <tr class=listheading> 1364|; 1365 1366 for (@column_index) { print "$column_data{$_}\n" } 1367 1368 print qq| 1369 </tr> 1370|; 1371 1372 my $i; 1373 1374 foreach my $ref (@{ $form->{ALL} }) { 1375 1376 $i++; $i %= 2; 1377 1378 if ($ref->{sictype} eq 'H') { 1379 print qq| 1380 <tr valign=top class=listheading> 1381|; 1382 $column_data{code} = qq|<th><a href=$form->{script}?action=edit_sic&code=$ref->{code}&path=$form->{path}&login=$form->{login}&callback=$callback>$ref->{code}</th>|; 1383 $column_data{description} = qq|<th>$ref->{description}</th>|; 1384 1385 } else { 1386 print qq| 1387 <tr valign=top class=listrow$i> 1388|; 1389 1390 $column_data{code} = qq|<td><a href=$form->{script}?action=edit_sic&code=$ref->{code}&path=$form->{path}&login=$form->{login}&callback=$callback>$ref->{code}</td>|; 1391 $column_data{description} = qq|<td>$ref->{description}</td>|; 1392 1393 } 1394 1395 for (@column_index) { print "$column_data{$_}\n" } 1396 1397 print qq| 1398 </tr> 1399|; 1400 } 1401 1402 print qq| 1403 </table> 1404 </td> 1405 </tr> 1406 <tr> 1407 <td><hr size=3 noshade></td> 1408 </tr> 1409</table> 1410 1411<br> 1412<form method=post action=$form->{script}> 1413|; 1414 1415 $form->{type} = "sic"; 1416 1417 $form->hide_form(qw(type callback path login)); 1418 1419 print qq| 1420<input class=submit type=submit name=action value="|.$locale->text('Add SIC').qq|">|; 1421 1422 if ($form->{menubar}) { 1423 require "$form->{path}/menu.pl"; 1424 &menubar; 1425 } 1426 1427 print qq| 1428</form> 1429 1430</body> 1431</html> 1432|; 1433 1434} 1435 1436 1437sub sic_header { 1438 1439 for (qw(code description)) { $form->{$_} = $form->quote($form->{$_}) } 1440 1441 my %checked; 1442 $checked{H} = ($form->{sictype} eq 'H') ? "checked" : ""; 1443 1444 $form->helpref("sic", $myconfig{countrycode}); 1445 1446 $form->header; 1447 1448 print qq| 1449<body> 1450 1451<form method=post action=$form->{script}> 1452 1453<input type=hidden name=type value=sic> 1454<input type=hidden name=id value="$form->{code}"> 1455 1456<table width=100%> 1457 <tr> 1458 <th class=listtop colspan=2>$form->{helpref}$form->{title}</a></th> 1459 </tr> 1460 <tr height="5"></tr> 1461 <tr> 1462 <th align=right>|.$locale->text('Code').qq|</th> 1463 <td><input name=code size=10 value="|.$form->quote($form->{code}).qq|"></td> 1464 </tr> 1465 <tr> 1466 <td></td> 1467 <th align=left><input name=sictype class=checkbox type=checkbox value="H" $checked{H}> |.$locale->text('Heading').qq|</th> 1468 </tr> 1469 <tr> 1470 <th align=right>|.$locale->text('Description').qq|</th> 1471 <td><input name=description size=60 value="|.$form->quote($form->{description}).qq|"></td> 1472 </tr> 1473 <tr> 1474 <td colspan=2><hr size=3 noshade></td> 1475 </tr> 1476</table> 1477|; 1478 1479} 1480 1481 1482sub save_sic { 1483 1484 $form->isblank("code", $locale->text('Code missing!')); 1485 $form->isblank("description", $locale->text('Description missing!')); 1486 AM->save_sic(\%myconfig, \%$form); 1487 $form->redirect($locale->text('SIC saved!')); 1488 1489} 1490 1491 1492sub delete_sic { 1493 1494 AM->delete_sic(\%myconfig, \%$form); 1495 $form->redirect($locale->text('SIC deleted!')); 1496 1497} 1498 1499 1500sub add_language { 1501 1502 $form->{title} = $locale->text('Add Language'); 1503 1504 $form->{callback} = "$form->{script}?action=add_language&path=$form->{path}&login=$form->{login}" unless $form->{callback}; 1505 1506 &language_header; 1507 &form_footer; 1508 1509} 1510 1511 1512sub edit_language { 1513 1514 $form->{title} = $locale->text('Edit Language'); 1515 1516 $form->{code} =~ s/\\'/'/g; 1517 $form->{code} =~ s/\\\\/\\/g; 1518 1519 AM->get_language(\%myconfig, \%$form); 1520 $form->{id} = $form->{code}; 1521 1522 &language_header; 1523 1524 $form->{orphaned} = 1; 1525 &form_footer; 1526 1527} 1528 1529 1530sub list_language { 1531 1532 AM->language(\%myconfig, \%$form); 1533 1534 my $href = "$form->{script}?action=list_language&direction=$form->{direction}&oldsort=$form->{oldsort}&path=$form->{path}&login=$form->{login}"; 1535 1536 $form->sort_order(); 1537 1538 $form->{callback} = "$form->{script}?action=list_language&direction=$form->{direction}&oldsort=$form->{oldsort}&path=$form->{path}&login=$form->{login}"; 1539 1540 my $callback = $form->escape($form->{callback}); 1541 1542 $form->{title} = $locale->text('Languages') . " / $form->{company}"; 1543 1544 my @column_index = $form->sort_columns(qw(code description)); 1545 1546 my %column_data; 1547 1548 $column_data{code} = qq|<th><a class=listheading href=$href&sort=code>|.$locale->text('Code').qq|</a></th>|; 1549 $column_data{description} = qq|<th><a class=listheading href=$href&sort=description>|.$locale->text('Description').qq|</a></th>|; 1550 1551 $form->helpref("list_language", $myconfig{countrycode}); 1552 1553 $form->header; 1554 1555 print qq| 1556<body> 1557 1558<table width=100%> 1559 <tr> 1560 <th class=listtop>$form->{helpref}$form->{title}</a></th> 1561 </tr> 1562 <tr height="5"></tr> 1563 <tr> 1564 <td> 1565 <table width=100%> 1566 <tr class=listheading> 1567|; 1568 1569 for (@column_index) { print "$column_data{$_}\n" } 1570 1571 print qq| 1572 </tr> 1573|; 1574 1575 my $i; 1576 1577 foreach my $ref (@{ $form->{ALL} }) { 1578 1579 $i++; $i %= 2; 1580 1581 print qq| 1582 <tr valign=top class=listrow$i> 1583|; 1584 1585 $column_data{code} = qq|<td><a href=$form->{script}?action=edit_language&code=$ref->{code}&path=$form->{path}&login=$form->{login}&callback=$callback>$ref->{code}</td>|; 1586 $column_data{description} = qq|<td>$ref->{description}</td>|; 1587 1588 for (@column_index) { print "$column_data{$_}\n" } 1589 1590 print qq| 1591 </tr> 1592|; 1593 } 1594 1595 print qq| 1596 </table> 1597 </td> 1598 </tr> 1599 <tr> 1600 <td><hr size=3 noshade></td> 1601 </tr> 1602</table> 1603 1604<br> 1605<form method=post action=$form->{script}> 1606|; 1607 1608 $form->{type} = "language"; 1609 1610 $form->hide_form(qw(type callback path login)); 1611 1612 print qq| 1613<input class=submit type=submit name=action value="|.$locale->text('Add Language').qq|">|; 1614 1615 if ($form->{menubar}) { 1616 require "$form->{path}/menu.pl"; 1617 &menubar; 1618 } 1619 1620 print qq| 1621</form> 1622 1623</body> 1624</html> 1625|; 1626 1627} 1628 1629 1630sub language_header { 1631 1632 for (qw(code description)) { $form->{$_} = $form->quote($form->{$_}) } 1633 1634 $form->helpref("language", $myconfig{countrycode}); 1635 1636 $form->header; 1637 1638 print qq| 1639<body> 1640 1641<form method=post action=$form->{script}> 1642 1643<input type=hidden name=type value=language> 1644<input type=hidden name=id value="$form->{code}"> 1645 1646<table width=100%> 1647 <tr> 1648 <th class=listtop colspan=2>$form->{helpref}$form->{title}</a></th> 1649 </tr> 1650 <tr height="5"></tr> 1651 <tr> 1652 <th align=right>|.$locale->text('Code').qq|</th> 1653 <td><input name=code size=10 value="$form->{code}"></td> 1654 </tr> 1655 <tr> 1656 <th align=right>|.$locale->text('Description').qq|</th> 1657 <td><input name=description size=60 value="|.$form->quote($form->{description}).qq|"></td> 1658 </tr> 1659 <td colspan=2><hr size=3 noshade></td> 1660 </tr> 1661</table> 1662|; 1663 1664} 1665 1666 1667sub save_language { 1668 1669 $form->isblank("code", $locale->text('Code missing!')); 1670 $form->isblank("description", $locale->text('Description missing!')); 1671 1672 $form->{code} =~ s/(\.\.|\*)//g; 1673 1674 AM->save_language(\%myconfig, \%$form); 1675 1676 $targetdir = "$templates/$myconfig{templates}/$form->{code}"; 1677 $basedir = "$myconfig{templates}"; 1678 $basedir = "$myconfig{templates}/$form->{copydir}" if $form->{copydir}; 1679 $basedir = "$templates/$basedir"; 1680 1681 umask(002); 1682 1683 if (mkdir "$targetdir", oct("771")) { 1684 unless (-d "$basedir") { 1685 $basedir = "$templates/$myconfig{templates}"; 1686 } 1687 1688 opendir TEMPLATEDIR, "$basedir" or $form->error("$basedir : $!"); 1689 1690 @templates = grep !/^\.\.?$/, readdir TEMPLATEDIR; 1691 closedir TEMPLATEDIR; 1692 1693 umask(007); 1694 1695 for (@templates) { 1696 if (-f "$basedir/$_") { 1697 open(TEMP, "$basedir/$_") or $form->error("$basedir/$_ : $!"); 1698 1699 unless (-f "$targetdir/$_") { 1700 open(NEW, ">$targetdir/$_") or $form->error("$targetdir/$_ : $!"); 1701 1702 while ($line = <TEMP>) { 1703 print NEW $line; 1704 } 1705 close(NEW); 1706 } 1707 1708 close(TEMP); 1709 } 1710 } 1711 } else { 1712 $form->error($locale->text('Unable to create directory: ')."$targetdir"); 1713 } 1714 1715 unless ($form->{copydir}) { 1716 if ($form->{id} && ($form->{id} ne $form->{code})) { 1717 # remove old directory 1718 $dir = "$templates/$myconfig{templates}/$form->{id}"; 1719 unlink <$dir/*>; 1720 rmdir "$dir"; 1721 } 1722 } 1723 1724 $form->redirect($locale->text('Language saved!')); 1725 1726} 1727 1728 1729sub delete_language { 1730 1731 $form->{title} = $locale->text('Confirm!'); 1732 1733 $form->header; 1734 1735 print qq| 1736<body> 1737 1738<form method=post action=$form->{script}> 1739|; 1740 1741 for (qw(action nextsub)) { delete $form->{$_} } 1742 1743 $form->hide_form; 1744 1745 print qq| 1746<h2 class=confirm>$form->{title}</h2> 1747 1748<h4>|.$locale->text('Are you sure you want to delete language: ').qq| $form->{code}</h4> 1749 1750<input type=hidden name=action value=continue> 1751<input type=hidden name=nextsub value=yes_delete_language> 1752<input name=action class=submit type=submit value="|.$locale->text('Continue').qq|"> 1753</form> 1754 1755</body> 1756</html> 1757|; 1758 1759} 1760 1761 1762sub yes_delete_language { 1763 1764 # check if template dir is used by another dataset 1765 open(FH, "$memberfile") or $form->error("$memberfile : $!\n"); 1766 @member = <FH>; 1767 close(FH); 1768 1769 %templates = (); 1770 1771 while (@member) { 1772 $_ = shift @member; 1773 if (/^\[admin\@(.*)\]/) { 1774 do { 1775 if (/^templates=(.*)/) { 1776 $templates{$1}++; 1777 } 1778 $_ = shift @member; 1779 } until /^\s/; 1780 } 1781 } 1782 1783 AM->delete_language(\%myconfig, \%$form); 1784 1785 unless ($templates{$myconfig{templates}} > 1) { 1786 # delete templates 1787 $dir = "$templates/$myconfig{templates}/$form->{code}"; 1788 if (-d $dir) { 1789 unlink <$dir/*>; 1790 rmdir "$dir"; 1791 } 1792 } 1793 $form->redirect($locale->text('Language deleted!')); 1794 1795} 1796 1797 1798sub list_mimetypes { 1799 1800 AM->mimetypes(\%myconfig, \%$form); 1801 1802 my $href = "$form->{script}?action=list_mimetypes&direction=$form->{direction}&oldsort=$form->{oldsort}&path=$form->{path}&login=$form->{login}"; 1803 1804 $form->sort_order(); 1805 1806 $form->{callback} = "$form->{script}?action=list_mimetypes&direction=$form->{direction}&oldsort=$form->{oldsort}&path=$form->{path}&login=$form->{login}"; 1807 1808 my $callback = $form->escape($form->{callback}); 1809 1810 $form->{title} = $locale->text('Mimetypes') . " / $form->{company}"; 1811 1812 my @column_index = $form->sort_columns(qw(extension contenttype)); 1813 1814 my %column_data; 1815 1816 $column_data{extension} = qq|<th><a class=listheading href=$href&sort=extension>|.$locale->text('Extension').qq|</a></th>|; 1817 $column_data{contenttype} = qq|<th><a class=listheading href=$href&sort=contenttype>|.$locale->text('Content-Type').qq|</a></th>|; 1818 1819 $form->helpref("list_mimetypes", $myconfig{countrycode}); 1820 1821 $form->header; 1822 1823 print qq| 1824<body> 1825 1826<table width=100%> 1827 <tr> 1828 <th class=listtop>$form->{helpref}$form->{title}</a></th> 1829 </tr> 1830 <tr height="5"></tr> 1831 <tr> 1832 <td> 1833 <table width=100%> 1834 <tr class=listheading> 1835|; 1836 1837 for (@column_index) { print "$column_data{$_}\n" } 1838 1839 print qq| 1840 </tr> 1841|; 1842 1843 my $i; 1844 1845 foreach my $ref (@{ $form->{ALL} }) { 1846 1847 $i++; $i %= 2; 1848 1849 print qq| 1850 <tr valign=top class=listrow$i> 1851|; 1852 1853 $column_data{extension} = qq|<td><a href=$form->{script}?action=edit_mimetype&extension=$ref->{extension}&contenttype=$ref->{contenttype}&path=$form->{path}&login=$form->{login}&callback=$callback>$ref->{extension}</td>|; 1854 $column_data{contenttype} = qq|<td>$ref->{contenttype}</td>|; 1855 1856 for (@column_index) { print "$column_data{$_}\n" } 1857 1858 print qq| 1859 </tr> 1860|; 1861 } 1862 1863 print qq| 1864 </table> 1865 </td> 1866 </tr> 1867 <tr> 1868 <td><hr size=3 noshade></td> 1869 </tr> 1870</table> 1871 1872<br> 1873<form method=post action=$form->{script}> 1874|; 1875 1876 $form->{type} = "mimetype"; 1877 1878 $form->hide_form(qw(type callback path login)); 1879 1880 print qq| 1881<input class=submit type=submit name=action value="|.$locale->text('Add Mimetype').qq|">|; 1882 1883 if ($form->{menubar}) { 1884 require "$form->{path}/menu.pl"; 1885 &menubar; 1886 } 1887 1888 print qq| 1889</form> 1890 1891</body> 1892</html> 1893|; 1894 1895} 1896 1897 1898sub edit_mimetype { 1899 1900 $form->{title} = $locale->text('Edit Mimetype'); 1901 1902 &mimetype_header; 1903 1904} 1905 1906 1907sub add_mimetype { 1908 1909 $form->{title} = $locale->text('Add Mimetype'); 1910 1911 $form->{callback} = "$form->{script}?action=add_mimetype&path=$form->{path}&login=$form->{login}" unless $form->{callback}; 1912 1913 &mimetype_header; 1914 1915} 1916 1917 1918sub mimetype_header { 1919 1920 $form->helpref("mimetype", $myconfig{countrycode}); 1921 1922 $form->header; 1923 1924 print qq| 1925<body> 1926 1927<form method=post action=$form->{script}> 1928 1929<input type=hidden name=type value=mimetype> 1930 1931<table width=100%> 1932 <tr> 1933 <th class=listtop colspan=2>$form->{helpref}$form->{title}</a></th> 1934 </tr> 1935 <tr height="5"></tr> 1936 <tr> 1937 <th align=right>|.$locale->text('Extension').qq|</th> 1938 <td><input name=extension size=10 value="$form->{extension}"></td> 1939 </tr> 1940 <tr> 1941 <th align=right>|.$locale->text('Content-Type').qq|</th> 1942 <td><input name=contenttype size=60 value="|.$form->quote($form->{contenttype}).qq|"></td> 1943 </tr> 1944 <td colspan=2><hr size=3 noshade></td> 1945 </tr> 1946</table> 1947 1948|; 1949 1950 $form->hide_form(qw(callback path login)); 1951 1952 my %button; 1953 1954 $button{'Save'} = { ndx => 3, key => 'S', value => $locale->text('Save') }; 1955 1956 if ($form->{extension}) { 1957 $button{'Delete'} = { ndx => 16, key => 'D', value => $locale->text('Delete') }; 1958 } 1959 1960 $form->print_button(\%button); 1961 1962 if ($form->{menubar}) { 1963 require "$form->{path}/menu.pl"; 1964 &menubar; 1965 } 1966 1967 print qq| 1968</form> 1969 1970</body> 1971</html> 1972|; 1973 1974 1975} 1976 1977 1978sub save_mimetype { 1979 1980 $form->isblank("extension", $locale->text('Extension missing!')); 1981 $form->isblank("contenttype", $locale->text('Content-Type missing!')); 1982 1983 AM->save_mimetype(\%myconfig, \%$form); 1984 1985 $form->redirect($locale->text('Mimetype saved!')); 1986 1987} 1988 1989 1990sub delete_mimetype { 1991 1992 AM->delete_mimetype(\%myconfig, \%$form); 1993 1994 $form->redirect($locale->text('Mimetype deleted!')); 1995 1996} 1997 1998 1999sub display_stylesheet { 2000 2001 $form->{file} = "css/$myconfig{stylesheet}"; 2002 &display_form; 2003 2004} 2005 2006 2007sub list_templates { 2008 2009 AM->language(\%myconfig, \%$form); 2010 2011 if (! @{ $form->{ALL} }) { 2012 $form->{file} = "$templates/$form->{file}"; 2013 &display_form; 2014 exit; 2015 } 2016 2017 unshift @{ $form->{ALL} }, { code => '.', description => $locale->text('Default Template') }; 2018 2019 my $href = "$form->{script}?action=list_templates&direction=$form->{direction}&oldsort=$form->{oldsort}&file=$form->{file}&path=$form->{path}&login=$form->{login}"; 2020 2021 $form->sort_order(); 2022 2023 $form->{file} =~ s/$myconfig{templates}\///; 2024 $form->{title} = "$form->{file} / $form->{company}"; 2025 2026 my @column_index = $form->sort_columns(qw(code description)); 2027 2028 my %column_data; 2029 2030 $column_data{code} = qq|<th><a class=listheading href=$href&sort=code>|.$locale->text('Code').qq|</a></th>|; 2031 $column_data{description} = qq|<th><a class=listheading href=$href&sort=description>|.$locale->text('Description').qq|</a></th>|; 2032 2033 $form->helpref("list_templates", $myconfig{countrycode}); 2034 2035 $form->header; 2036 2037 print qq| 2038<body> 2039 2040<table width=100%> 2041 <tr> 2042 <th class=listtop>$form->{helpref}$form->{title}</a></th> 2043 </tr> 2044 <tr height="5"></tr> 2045 <tr> 2046 <td> 2047 <table width=100%> 2048 <tr class=listheading> 2049|; 2050 2051 for (@column_index) { print "$column_data{$_}\n" } 2052 2053 print qq| 2054 </tr> 2055|; 2056 2057 my $i; 2058 2059 foreach my $ref (@{ $form->{ALL} }) { 2060 2061 $i++; $i %= 2; 2062 2063 print qq| 2064 <tr valign=top class=listrow$i> 2065|; 2066 2067 $column_data{code} = qq|<td><a href=$form->{script}?action=display_form&file=$templates/$myconfig{templates}/$ref->{code}/$form->{file}&path=$form->{path}&login=$form->{login}>$ref->{code}</td>|; 2068 $column_data{description} = qq|<td>$ref->{description}</td>|; 2069 2070 for (@column_index) { print "$column_data{$_}\n" } 2071 2072 print qq| 2073 </tr> 2074|; 2075 } 2076 2077 print qq| 2078 </table> 2079 </td> 2080 </tr> 2081 <tr> 2082 <td><hr size=3 noshade></td> 2083 </tr> 2084</table> 2085 2086<br> 2087|; 2088 2089 if ($form->{menubar}) { 2090 require "$form->{path}/menu.pl"; 2091 &menubar; 2092 } 2093 2094 print qq| 2095 2096</body> 2097</html> 2098|; 2099 2100} 2101 2102 2103sub display_form { 2104 2105 $form->{callback} = qq|$form->{script}?action=display_form&file=$form->{file}&path=$form->{path}&login=$form->{login}| unless $form->{callback}; 2106 my $callback = $form->escape($form->{callback}); 2107 2108 $form->{file} =~ s/^(.:)*?\/|\.\.\/|\.\///g; 2109 $form->{file} =~ s/^\/*//g; 2110 $form->{file} =~ s/$userspath//; 2111 $form->{file} =~ s/$memberfile//; 2112 2113 @f = split /\//, $form->{file}; 2114 $file = pop @f; 2115 $basedir = join '/', @f; 2116 2117 AM->load_template(\%$form); 2118 2119 $form->{title} = $form->{file}; 2120 2121 $form->{body} =~ s/<%include\s+?(\S+)?\s+?(\S+)?%>/$1 <%include $2%>/g; 2122 $form->{body} =~ s/<%include\s+?(\S+)?%>/<a href=$form->{script}\?action=display_form&file=$basedir\/$1&path=$form->{path}&login=$form->{login}&callback=$callback>$1<\/a>/g; 2123 2124 $form->{body} =~ s/<%templates%>/$templates\/$myconfig{templates}/g; 2125 $form->{body} =~ s/<%language_code%>/$form->{language_code}/g; 2126 $form->{body} =~ s/<%if .*?%>|<%foreach .*?%>|<%end .*?%>//g; 2127 2128 if ($form->{file} =~ /\.txt$/) { 2129 $str = $form->{body}; 2130 while ($str) { 2131 $lpos = index $str, '<%'; 2132 $rpos = index $str, '%>'; 2133 $pos = $rpos + 2; 2134 2135 $tmpstr = substr $str, $lpos, $rpos - $lpos + 2; 2136 2137 if ($tmpstr =~ /(align|width|offset)=/) { 2138 $var = substr $tmpstr, 2; 2139 $var =~ s/\s.*//; 2140 $form->{temp} = $var; 2141 $tmpstr =~ s/$var/temp/; 2142 $tmpstr = $form->format_line($tmpstr); 2143 2144 $form->{body} =~ s/<%((.*?) (align|width|offset)=.*?)%>/$tmpstr/; 2145 } 2146 $str = substr $str, $pos; 2147 } 2148 } 2149 2150 $form->{body} =~ s/<%(.*?)%>/$1/g; 2151 2152 if ($form->{file} !~ /\.(html|xml)$/) { 2153 $form->{body} = "<pre>\n$form->{body}\n</pre>"; 2154 } 2155 2156 $form->{edit} = 1; 2157 2158 if ($form->{file} =~ /\/help\//) { 2159 $form->{edit} = $form->{admin}; 2160 } 2161 2162 $form->helpref("display_form", $myconfig{countrycode}); 2163 2164 $form->header; 2165 2166 print qq| 2167<body> 2168 2169<table width=100%> 2170 <tr> 2171 <th class=listtop>$form->{helpref}$form->{title}</a></th> 2172 </tr> 2173</table> 2174 2175$form->{body} 2176|; 2177 2178 $extension = $form->{file}; 2179 $extension =~ s/.*?\.//; 2180 2181 print qq| 2182<form method=post action=$form->{script}> 2183|; 2184 2185 $form->{type} = "template"; 2186 2187 $form->hide_form(qw(file type path login callback)); 2188 2189 print qq| 2190<p> 2191<input name=action type=submit class=submit value="|.$locale->text('Edit').qq|">| if $form->{edit}; 2192 2193 print qq| 2194</form> 2195|; 2196 2197 if ($form->{menubar}) { 2198 require "$form->{path}/menu.pl"; 2199 &menubar; 2200 } 2201 2202 print qq| 2203 2204</body> 2205</html> 2206|; 2207 2208} 2209 2210 2211sub edit_template { 2212 2213 AM->load_template(\%$form); 2214 2215 $form->{title} = $form->{file}; 2216 # convert   to &nbsp; 2217 $form->{body} =~ s/ /&nbsp;/gi; 2218 2219 $form->{callback} = "$form->{script}?action=display_form&file=$form->{file}&path=$form->{path}&login=$form->{login}" unless $form->{callback}; 2220 2221 $form->helpref("edit_form", $myconfig{countrycode}); 2222 2223 $form->header; 2224 2225 $form->{type} = "template"; 2226 2227 print qq| 2228<body> 2229 2230<form method=post action=$form->{script}> 2231 2232<table width=100%> 2233 <tr> 2234 <th class=listtop>$form->{helpref}$form->{title}</a></th> 2235 </tr> 2236 <tr height="5"></tr> 2237 <tr> 2238 <td> 2239 2240<textarea name=body rows=45 cols=80> 2241$form->{body}</textarea> 2242 2243 </td> 2244 </tr> 2245</table> 2246 2247<br> 2248<input type=submit class=submit name=action value="|.$locale->text('Save').qq|"> 2249|; 2250 2251 $form->hide_form(qw(file type path login callback)); 2252 2253 if ($form->{menubar}) { 2254 require "$form->{path}/menu.pl"; 2255 &menubar; 2256 } 2257 2258 print qq| 2259 </form> 2260 2261</body> 2262</html> 2263|; 2264 2265} 2266 2267 2268sub save_template { 2269 2270 AM->save_template(\%$form); 2271 $form->redirect($locale->text('Template saved!')); 2272 2273} 2274 2275 2276sub taxes { 2277 2278 # get tax account numbers 2279 AM->taxes(\%myconfig, \%$form); 2280 2281 my $i = 0; 2282 foreach my $ref (@{ $form->{taxrates} }) { 2283 $i++; 2284 $form->{"taxrate_$i"} = $ref->{rate}; 2285 $form->{"taxdescription_$i"} = $ref->{description}; 2286 2287 for (qw(accno taxnumber validto closed)) { $form->{"${_}_$i"} = $ref->{$_} } 2288 $form->{taxaccounts} .= "$ref->{id}_$i "; 2289 } 2290 chop $form->{taxaccounts}; 2291 2292 &display_taxes; 2293 2294} 2295 2296 2297sub display_taxes { 2298 2299 $form->{title} = $locale->text('Taxes') . " / $form->{company}"; 2300 2301 $form->{type} = "taxes"; 2302 2303 $form->helpref("display_taxes", $myconfig{countrycode}); 2304 2305 $form->header; 2306 2307 &calendar; 2308 2309 print qq| 2310<body> 2311 2312<form method="post" name="main" action="$form->{script}"> 2313 2314<table width=100%> 2315 <tr><th class=listtop>$form->{helpref}$form->{title}</a></th></tr> 2316 <tr> 2317 <td> 2318 <table> 2319 <tr> 2320 <th>|.$locale->text('Account').qq|</th> 2321 <th>|.$locale->text('Description').qq|</th> 2322 <th>|.$locale->text('Closed').qq|</th> 2323 <th>|.$locale->text('Rate').qq| (%)</th> 2324 <th>|.$locale->text('Number').qq|</th> 2325 <th>|.$locale->text('Valid To').qq|</th> 2326 </tr> 2327|; 2328 2329 my $sametax; 2330 2331 for (split(/ /, $form->{taxaccounts})) { 2332 2333 my ($id, $i) = split /_/, $_; 2334 2335 $form->{"taxrate_$i"} = $form->format_amount(\%myconfig, $form->{"taxrate_$i"}, undef, 0); 2336 2337 $form->hide_form(map { "${_}_$i" } qw(taxdescription accno)); 2338 2339 print qq| 2340 <tr>|; 2341 2342 if ($form->{"accno_$i"} eq $sametax) { 2343 print qq| 2344 <th></th> 2345 <th></th> 2346 <th></th>|; 2347 } else { 2348 print qq|<th align=left>$form->{"accno_$i"}</th>|; 2349 print qq|<th align=left>$form->{"taxdescription_$i"}</th>|; 2350 2351 $closed = ($form->{"closed_$i"}) ? "checked" : ""; 2352 print qq|<td><input name="closed_$id" type=checkbox value=1 $closed></td>|; 2353 } 2354 2355 print qq| 2356 <td><input name="taxrate_$i" class="inputright" size=6 value=$form->{"taxrate_$i"}></td> 2357 <td><input name="taxnumber_$i" value="$form->{"taxnumber_$i"}"></td> 2358 <td><input name="validto_$i" size=11 class=date value="$form->{"validto_$i"}" title="$myconfig{dateformat}">|.&js_calendar("main", "validto_$i").qq|</td> 2359 </tr> 2360|; 2361 $sametax = $form->{"accno_$i"}; 2362 2363 } 2364 2365 print qq| 2366 </table> 2367 </td> 2368 </tr> 2369 <tr> 2370 <td><hr size=3 noshade></td> 2371 </tr> 2372</table> 2373|; 2374 2375 $form->hide_form(qw(company type taxaccounts path login)); 2376 2377 print qq| 2378<input type=submit class=submit name=action value="|.$locale->text('Update').qq|"> 2379<input type=submit class=submit name=action value="|.$locale->text('Save').qq|">|; 2380 2381 if ($form->{menubar}) { 2382 require "$form->{path}/menu.pl"; 2383 &menubar; 2384 } 2385 2386 print qq| 2387 </form> 2388 2389</body> 2390</html> 2391|; 2392 2393} 2394 2395 2396sub update { 2397 2398 &{ "update_$form->{type}" } 2399 2400} 2401 2402 2403sub update_taxes { 2404 2405 @tax = (); 2406 @flds = qw(id closed taxrate taxdescription taxnumber accno validto); 2407 foreach $item (split / /, $form->{taxaccounts}) { 2408 ($id, $i) = split /_/, $item; 2409 $form->{"id_$i"} = $id; 2410 $form->{"closed_$i"} = $form->{"closed_$id"}; 2411 push @{ $tax{$id} }, { map { $_ => $form->{"${_}_$i"} } @flds }; 2412 } 2413 2414 foreach $item (keys %tax) { 2415 for $ref (@{$tax{$item}}) { 2416 push @tax, $ref; 2417 $validto = $ref->{validto}; 2418 $id = $ref->{id}; 2419 $accno = $ref->{accno}; 2420 $taxdescription = $ref->{taxdescription}; 2421 last unless $validto; 2422 } 2423 if ($validto) { 2424 push @tax, { id => $id, accno => $accno, taxdescription => $taxdescription }; 2425 } 2426 } 2427 2428 $form->{taxaccounts} = ""; 2429 $i = 1; 2430 for $ref (sort { $a->{accno} cmp $b->{accno} } @tax) { 2431 $form->{taxaccounts} .= "$ref->{id}_$i "; 2432 for (@flds) { $form->{"${_}_$i"} = $ref->{$_} } 2433 $i++; 2434 } 2435 chop $form->{taxaccounts}; 2436 2437 &display_taxes; 2438 2439} 2440 2441 2442sub defaults { 2443 2444 # get defaults for account numbers and last numbers 2445 AM->defaultaccounts(\%myconfig, \%$form); 2446 2447 foreach my $key (keys %{ $form->{accno} }) { 2448 foreach my $accno (sort keys %{ $form->{accno}{$key} }) { 2449 $form->{"select$key"} .= "$accno--$form->{accno}{$key}{$accno}{description}\n"; 2450 if ($form->{accno}{$key}{$accno}{id} == $form->{defaults}{$key}) { 2451 $form->{$key} = qq|$accno--$form->{accno}{$key}{$accno}{description}|; 2452 } 2453 } 2454 } 2455 2456 2457 for (qw(accno defaults)) { delete $form->{$_} } 2458 2459 my %checked; 2460 $checked{cash} = "checked" if $form->{method} eq 'cash'; 2461 $checked{namesbynumber} = "checked" if $form->{namesbynumber}; 2462 $checked{company} = "checked" unless $form->{typeofcontact}; 2463 $checked{person} = "checked" if $form->{typeofcontact} eq 'person'; 2464 $roundchange{$form->{roundchange}} = "checked"; 2465 2466 for (qw(cdt checkinventory hideaccounts forcewarehouse)) { 2467 $checked{$_} = "checked" if $form->{$_}; 2468 } 2469 2470 for (qw(glnumber sinumber sonumber ponumber sqnumber rfqnumber employeenumber customernumber vendornumber)) { 2471 $checked{"lock_$_"} = "checked" if $form->{"lock_$_"}; 2472 } 2473 2474 $form->{title} = $locale->text('System Defaults'); 2475 2476 $form->helpref("system_defaults", $myconfig{countrycode}); 2477 2478 $form->header; 2479 2480 print qq| 2481<body> 2482 2483<form method=post action=$form->{script}> 2484 2485<input type=hidden name=type value=defaults> 2486 2487<table width=100%> 2488 <tr><th class=listtop>$form->{helpref}$form->{title}</a></th></tr> 2489 <tr height="5"></tr> 2490 <tr> 2491 <td> 2492 <table> 2493 <tr valign=top> 2494 <td> 2495 <table> 2496 <tr> 2497 <th align=right>|.$locale->text('Company Name').qq|</th> 2498 <td><input name=company size=35 value="|.$form->quote($form->{company}).qq|"></td> 2499 </tr> 2500 <tr valign=top> 2501 <th align=right>|.$locale->text('Address').qq|</th> 2502 <td><textarea name=address rows=3 cols=35>$form->{address}</textarea></td> 2503 </tr> 2504 <tr> 2505 <th align=right>|.$locale->text('Phone').qq|</th> 2506 <td><input name=tel size=14 value="$form->{tel}"></td> 2507 </tr> 2508 <tr> 2509 <th align=right>|.$locale->text('Fax').qq|</th> 2510 <td><input name=fax size=14 value="$form->{fax}"></td> 2511 </tr> 2512 <tr> 2513 <th align=right>|.$locale->text('E-mail').qq|</th> 2514 <td><input name=companyemail size=35 value="$form->{companyemail}"></td> 2515 </tr> 2516 <tr> 2517 <th align=right>|.$locale->text('Website').qq|</th> 2518 <td><input name=companywebsite size=35 value="$form->{companywebsite}"></td> 2519 </tr> 2520 <tr> 2521 <th align=right>|.$locale->text('Business Number').qq|</th> 2522 <td><input name=businessnumber size=35 value="|.$form->quote($form->{businessnumber}).qq|"></td> 2523 </tr> 2524 <tr> 2525 <th align=right>|.$locale->text('Reporting Method').qq|</th> 2526 <td><input name=method class=checkbox type=checkbox value=cash $checked{cash}> |.$locale->text('Cash').qq|</td> 2527 </tr> 2528 <tr> 2529 <th align=right>|.$locale->text('Cash Discount').qq|</th> 2530 <td><input name=cdt class=checkbox type=checkbox value="1" $checked{cdt}> |.$locale->text('Taxable').qq|</td> 2531 </tr> 2532 <tr> 2533 <th align=right>|.$locale->text('Reference Documents').qq|</th> 2534 <td><input name=referenceurl size=60 value="$form->{referenceurl}"></td> 2535 </tr> 2536 <tr> 2537 <th align=right>|.$locale->text('Precision').qq|</th> 2538 <td><input name=precision class="inputright" size=5 value="$form->{precision}"></td> 2539 </tr> 2540 <tr> 2541 <th align=right>|.$locale->text('Annual Interest').qq|</th> 2542 <td><input name=annualinterest class="inputright" size=5 value="$form->{annualinterest}"> %</td> 2543 </tr> 2544 <tr> 2545 <th align=right>|.$locale->text('Late Payment Fee').qq|</th> 2546 <td><input name=latepaymentfee class="inputright" size=5 value="$form->{latepaymentfee}"> %</td> 2547 </tr> 2548 <tr> 2549 <th align=right>|.$locale->text('Restocking Charge').qq|</th> 2550 <td><input name=restockingcharge class="inputright" size=5 value="$form->{restockingcharge}"> %</td> 2551 </tr> 2552 <tr> 2553 <th align=right>|.$locale->text('Round').qq|</th> 2554 <td> 2555 <input name=roundchange type=radio class=radio value="0.01" $roundchange{0.01}>0.01 2556 <input name=roundchange type=radio class=radio value="0.05" $roundchange{0.05}>0.05 2557 <input name=roundchange type=radio class=radio value="0.1" $roundchange{0.1}>0.10 2558 <input name=roundchange type=radio class=radio value="0.2" $roundchange{0.2}>0.20 2559 <input name=roundchange type=radio class=radio value="0.5" $roundchange{0.5}>0.50 2560 <input name=roundchange type=radio class=radio value="1" $roundchange{1}>1.00 2561 </td> 2562 </tr> 2563 <tr> 2564 <th align=right>|.$locale->text('Weight Unit').qq|</th> 2565 <td><input name=weightunit size=5 value="$form->{weightunit}"></td> 2566 </tr> 2567 <tr> 2568 <th align=right>|.$locale->text('Sort Names by').qq|</th> 2569 <td><input name=namesbynumber class=checkbox type=checkbox value="1" $checked{namesbynumber}> |.$locale->text('Number').qq| 2570 </td> 2571 </tr> 2572 <tr> 2573 <th align=right>|.$locale->text('Type of Contact').qq|</th> 2574 <td><input name=typeofcontact class=radio type=radio value="" $checked{company}> |.$locale->text('Company').qq| 2575 <input name=typeofcontact class=radio type=radio value="person" $checked{person}> |.$locale->text('Person').qq| 2576 </td> 2577 </tr> 2578 <tr> 2579 <th align=right>|.$locale->text('Check Inventory').qq|</th> 2580 <td><input name=checkinventory class=checkbox type=checkbox value=1 $checked{checkinventory}></td> 2581 </tr> 2582 <tr> 2583 <th align=right>|.$locale->text('Force Warehouse').qq|</th> 2584 <td><input name=forcewarehouse class=checkbox type=checkbox value=1 $checked{forcewarehouse}></td> 2585 </tr> 2586 2587 <tr> 2588 <th align=right>|.$locale->text('Hide Closed Accounts').qq|</th> 2589 <td><input name=hideaccounts class=checkbox type=checkbox value=1 $checked{hideaccounts}></td> 2590 </tr> 2591 </table> 2592 </td> 2593 </tr> 2594 </table> 2595 </td> 2596 </tr> 2597 <tr> 2598 <th class=listheading>|.$locale->text('Default Accounts').qq|</th> 2599 </tr> 2600 <tr> 2601 <td> 2602 <table> 2603 <tr> 2604 <th align=right nowrap>|.$locale->text('Inventory').qq|</th> 2605 <td><select name=IC>|.$form->select_option($form->{"selectIC"}, $form->{IC}).qq|</select></td> 2606 </tr> 2607 <tr> 2608 <th align=right nowrap>|.$locale->text('Income').qq|</th> 2609 <td><select name=IC_income>|.$form->select_option($form->{"selectIC_income"}, $form->{IC_income}).qq|</select></td> 2610 </tr> 2611 <tr> 2612 <th align=right nowrap>|.$locale->text('Expense').qq|</th> 2613 <td><select name=IC_expense>|.$form->select_option($form->{"selectIC_expense"}, $form->{IC_expense}).qq|</select></td> 2614 </tr> 2615 <tr> 2616 <th align=right nowrap>|.$locale->text('Foreign Exchange Gain/Loss').qq|</th> 2617 <td><select name=fxgainloss>|.$form->select_option($form->{"selectfxgainloss"}, $form->{fxgainloss}).qq|</select></td> 2618 </tr> 2619 <tr> 2620 <th align=right nowrap>|.$locale->text('Cash Over/Short').qq|</th> 2621 <td><select name=cashovershort>|.$form->select_option($form->{"selectfxgainloss"}, $form->{cashovershort}).qq|</select></td> 2622 </tr> 2623 </table> 2624 </td> 2625 </tr> 2626 <tr> 2627 <th class=listheading>|.$locale->text('Last Numbers').qq|</th> 2628 </tr> 2629 <tr> 2630 <td> 2631 <table> 2632 <tr> 2633 <th></th> 2634 <td></td> 2635 <th>|.$locale->text('Lock').qq|</th> 2636 </tr> 2637 <tr> 2638 <th align=right nowrap>|.$locale->text('GL Reference Number').qq|</th> 2639 <td><input name=glnumber size=40 value="$form->{glnumber}"></td> 2640 <td><input name=lock_glnumber class=checkbox type=checkbox value=1 $checked{lock_glnumber}></td> 2641 </tr> 2642 <tr> 2643 <th align=right nowrap>|.$locale->text('Sales Invoice/AR Transaction Number').qq|</th> 2644 <td><input name=sinumber size=40 value="$form->{sinumber}"></td> 2645 <td><input name=lock_sinumber class=checkbox type=checkbox value=1 $checked{lock_sinumber}></td> 2646 </tr> 2647 <tr> 2648 <th align=right nowrap>|.$locale->text('Sales Order Number').qq|</th> 2649 <td><input name=sonumber size=40 value="$form->{sonumber}"></td> 2650 <td><input name=lock_sonumber class=checkbox type=checkbox value=1 $checked{lock_sonumber}></td> 2651 </tr> 2652 <tr> 2653 <th align=right nowrap>|.$locale->text('Vendor Invoice/AP Transaction Number').qq|</th> 2654 <td><input name=vinumber size=40 value="$form->{vinumber}"></td> 2655 </tr> 2656 <tr> 2657 <th align=right nowrap>|.$locale->text('Batch Number').qq|</th> 2658 <td><input name=batchnumber size=40 value="$form->{batchnumber}"></td> 2659 </tr> 2660 <tr> 2661 <th align=right nowrap>|.$locale->text('Voucher Number').qq|</th> 2662 <td><input name=vouchernumber size=40 value="$form->{vouchernumber}"></td> 2663 </tr> 2664 <tr> 2665 <th align=right nowrap>|.$locale->text('Purchase Order Number').qq|</th> 2666 <td><input name=ponumber size=40 value="$form->{ponumber}"></td> 2667 <td><input name=lock_ponumber class=checkbox type=checkbox value=1 $checked{lock_ponumber}></td> 2668 </tr> 2669 <tr> 2670 <th align=right nowrap>|.$locale->text('Sales Quotation Number').qq|</th> 2671 <td><input name=sqnumber size=40 value="$form->{sqnumber}"></td> 2672 <td><input name=lock_sqnumber class=checkbox type=checkbox value=1 $checked{lock_sqnumber}></td> 2673 </tr> 2674 <tr> 2675 <th align=right nowrap>|.$locale->text('RFQ Number').qq|</th> 2676 <td><input name=rfqnumber size=40 value="$form->{rfqnumber}"></td> 2677 <td><input name=lock_rfqnumber class=checkbox type=checkbox value=1 $checked{lock_rfqnumber}></td> 2678 </tr> 2679 <tr> 2680 <th align=right nowrap>|.$locale->text('Part Number').qq|</th> 2681 <td><input name=partnumber size=40 value="$form->{partnumber}"></td> 2682 </tr> 2683 <tr> 2684 <th align=right nowrap>|.$locale->text('Job/Project Number').qq|</th> 2685 <td><input name=projectnumber size=40 value="$form->{projectnumber}"></td> 2686 </tr> 2687 <tr> 2688 <th align=right nowrap>|.$locale->text('Employee Number').qq|</th> 2689 <td><input name=employeenumber size=40 value="$form->{employeenumber}"></td> 2690 <td><input name=lock_employeenumber class=checkbox type=checkbox value=1 $checked{lock_employeenumber}></td> 2691 </tr> 2692 <tr> 2693 <th align=right nowrap>|.$locale->text('Customer Number').qq|</th> 2694 <td><input name=customernumber size=40 value="$form->{customernumber}"></td> 2695 <td><input name=lock_customernumber class=checkbox type=checkbox value=1 $checked{lock_customernumber}></td> 2696 </tr> 2697 <tr> 2698 <th align=right nowrap>|.$locale->text('Vendor Number').qq|</th> 2699 <td><input name=vendornumber size=40 value="$form->{vendornumber}"></td> 2700 <td><input name=lock_vendornumber class=checkbox type=checkbox value=1 $checked{lock_vendornumber}></td> 2701 </tr> 2702 </table> 2703 </td> 2704 </tr> 2705 <tr> 2706 <td><hr size=3 noshade></td> 2707 </tr> 2708</table> 2709|; 2710 2711 $form->{optional} = "company address tel fax companyemail companywebsite yearend weightunit businessnumber closedto revtrans audittrail method cdt namesbynumber typeofcontact roundchange referenceurl annualinterest latepaymentfee restockingcharge checkinventory hideaccounts forcewarehouse"; 2712 2713 for (qw(gl si so vi batch voucher po sq rfq part project employee customer vendor)) { $form->{optional} .= " ${_}number" } 2714 2715 for (qw(gl si so po sq rfq employee customer vendor)) { $form->{optional} .= " lock_${_}number" } 2716 2717 @f = qw(closedto revtrans audittrail); 2718 2719 for (qw(printer opendrawer poledisplay poledisplayon)) { 2720 if ($form->{$_}) { 2721 push @f, $_; 2722 $form->{optional} .= " $_"; 2723 } 2724 } 2725 for (keys %$form) { 2726 if ($_ =~ /_\d+/) { 2727 push @f, $_; 2728 $form->{optional} .= " $_"; 2729 } 2730 } 2731 2732 $form->hide_form(@f) if @f; 2733 2734 $form->hide_form(qw(optional path login)); 2735 2736 print qq| 2737<input type=submit class=submit name=action value="|.$locale->text('Save').qq|">|; 2738 2739 if ($form->{menubar}) { 2740 require "$form->{path}/menu.pl"; 2741 &menubar; 2742 } 2743 2744 print qq| 2745 </form> 2746 2747</body> 2748</html> 2749|; 2750 2751} 2752 2753 2754sub workstations { 2755 2756 # get printers etc. 2757 if (! $form->{have}) { 2758 AM->workstations(\%myconfig, \%$form); 2759 } 2760 2761 $form->{title} = $locale->text('Workstations') . " / $form->{company}"; 2762 2763 $form->{numworkstations} ||= 1; 2764 $form->{numprinters} ||= 1; 2765 $form->{numprinters_1} ||= 1; 2766 2767 $form->helpref("workstations", $myconfig{countrycode}); 2768 2769 $form->header; 2770 2771 print qq| 2772<body> 2773 2774<form method=post action=$form->{script}> 2775 2776<input type=hidden name=type value=workstations> 2777 2778<table width=100%> 2779 <tr><th class=listtop>$form->{helpref}$form->{title}</a></th></tr> 2780 <tr height="5"></tr> 2781 <tr> 2782 <th class=listheading>|.$locale->text('Default').qq|</th> 2783 </tr> 2784 <tr> 2785 <td> 2786 <table> 2787 <tr> 2788 <td> </td> 2789 <th nowrap>|.$locale->text('Description').qq|</th> 2790 <th nowrap>|.$locale->text('Command').qq|</th> 2791 </tr> 2792 2793 <tr> 2794 <th align=right nowrap>|.$locale->text('Printer').qq|</th> 2795 <td><input name="printer_1" value="|.$form->quote($form->{printer_1}).qq|"></td> 2796 <td><input name="command_1" value="|.$form->quote($form->{command_1}).qq|" size=60></td> 2797 </tr> 2798|; 2799 2800 for (2 .. $form->{numprinters}) { 2801 print qq| 2802 <tr> 2803 <td> </td> 2804 <td><input name="printer_$_" value="|.$form->quote($form->{"printer_$_"}).qq|"></td> 2805 <td><input name="command_$_" value="|.$form->quote($form->{"command_$_"}).qq|" size=60></td> 2806 </tr> 2807|; 2808 } 2809 2810 $checked = "checked" if $form->{"poledisplayon"}; 2811 2812 print qq| 2813 <tr> 2814 <th align=right nowrap>|.$locale->text('Cash Drawer').qq|</th> 2815 <td> </td> 2816 <td><input name="cashdrawer" value="|.$form->quote($form->{"cashdrawer"}).qq|" size=60></td> 2817 </tr> 2818 <tr> 2819 <th align=right nowrap>|.$locale->text('Poledisplay').qq|</th> 2820 <td> </td> 2821 <td><input name="poledisplay" value="|.$form->quote($form->{"poledisplay"}).qq|" size=60></td> 2822 <td><input name="poledisplayon" type=checkbox style=checkbox $checked><b>|.$locale->text('On').qq|</b></td> 2823 </tr> 2824|; 2825 2826 print qq| 2827 </table> 2828 </td> 2829 </tr> 2830 2831 <tr> 2832 <th class=listheading>|.$locale->text('Workstations').qq|</th> 2833 </tr> 2834 2835 <tr> 2836 <td> 2837 <table> 2838|; 2839 2840 for $i (1 .. $form->{numworkstations}) { 2841 2842 print qq| 2843 <tr> 2844 <th align=right nowrap>|.$locale->text('Workstation').qq|</th> 2845 <td><input name="workstation_$i" value="|.$form->quote($form->{"workstation_$i"}).qq|"></td> 2846 </tr> 2847 2848 <tr> 2849 <th align=right nowrap>|.$locale->text('Printer').qq|</th> 2850 <td><input name="printer_${i}_1" value="|.$form->quote($form->{"printer_${i}_1"}).qq|"></td> 2851 <td><input name="command_${i}_1" value="|.$form->quote($form->{"command_${i}_1"}).qq|" size=60></td> 2852 </tr> 2853|; 2854 2855 for (2 .. $form->{"numprinters_$i"}) { 2856 print qq| 2857 <tr> 2858 <td> </td> 2859 <td><input name="printer_${i}_$_" value="|.$form->quote($form->{"printer_${i}_$_"}).qq|"></td> 2860 <td><input name="command_${i}_$_" value="|.$form->quote($form->{"command_${i}_$_"}).qq|" size=60></td> 2861 </tr> 2862|; 2863 } 2864 2865 $checked = ($form->{"poledisplayon_$i"}) ? "checked" : ""; 2866 2867 print qq| 2868 <tr> 2869 <th align=right nowrap>|.$locale->text('Cash Drawer').qq|</th> 2870 <td> </td> 2871 <td><input name="cashdrawer_$i" value="|.$form->quote($form->{"cashdrawer_$i"}).qq|" size=60></td> 2872 </tr> 2873 <tr> 2874 <th align=right nowrap>|.$locale->text('Poledisplay').qq|</th> 2875 <td> </td> 2876 <td><input name="poledisplay_$i" value="|.$form->quote($form->{"poledisplay_$i"}).qq|" size=60></td> 2877 <td><input name="poledisplayon_$i" type=checkbox style=checkbox $checked><b>|.$locale->text('On').qq|</b></td> 2878 </tr> 2879|; 2880 2881 if ($i != $form->{numworkstations}) { 2882 print qq| 2883 <tr> 2884 <td colspan=4><hr size=3 noshade></td> 2885 </tr> 2886|; 2887 } 2888 } 2889 2890 print qq| 2891 </table> 2892 </td> 2893 </tr> 2894 2895 <tr> 2896 <td><hr size=3 noshade></td> 2897 </tr> 2898</table> 2899|; 2900 2901 $form->hide_form(qw(company numprinters numworkstations path login)); 2902 $form->hide_form(map { "numprinters_$_" } (1 .. $form->{numworkstations})); 2903 2904 print qq| 2905<input type=submit class=submit name=action value="|.$locale->text('Update').qq|"> 2906<input type=submit class=submit name=action value="|.$locale->text('Save').qq|">|; 2907 2908 if ($form->{menubar}) { 2909 require "$form->{path}/menu.pl"; 2910 &menubar; 2911 } 2912 2913 print qq| 2914 </form> 2915 2916</body> 2917</html> 2918|; 2919 2920} 2921 2922 2923sub update_workstations { 2924 2925 @p = (); 2926 for (1 .. $form->{numprinters}) { 2927 if ($form->{"printer_$_"} && $form->{"command_$_"}) { 2928 push @p, { printer => $form->{"printer_$_"}, 2929 command => $form->{"command_$_"} }; 2930 } 2931 } 2932 2933 $i = 1; 2934 for (@p) { 2935 $form->{"printer_$i"} = $_->{printer}; 2936 $form->{"command_$i"} = $_->{command}; 2937 $i++; 2938 } 2939 $form->{numprinters} = $i; 2940 2941 2942 %ws = (); 2943 $j = 1; 2944 for $i (1 .. $form->{numworkstations}) { 2945 2946 if ($form->{"workstation_$i"}) { 2947 2948 $ws{$j}{workstation} = $form->{"workstation_$i"}; 2949 2950 $ws{$j}{poledisplayon} = $form->{"poledisplayon_$i"}; 2951 $ws{$j}{cashdrawer} = $form->{"cashdrawer_$i"}; 2952 $ws{$j}{poledisplay} = $form->{"poledisplay_$i"}; 2953 2954 @{$ws{$j}{p}} = (); 2955 $form->{"numprinters_$i"}++; 2956 2957 for (1 .. $form->{"numprinters_$i"}) { 2958 if ($form->{"printer_${i}_$_"} && $form->{"command_${i}_$_"}) { 2959 push @{$ws{$j}{p}}, { printer => $form->{"printer_${i}_$_"}, 2960 command => $form->{"command_${i}_$_"} }; 2961 } 2962 } 2963 $j++; 2964 } 2965 2966 for (qw(workstation poledisplayon cashdrawer poledisplay)) { delete $form->{"${_}_$i"} } 2967 for (1 .. $form->{"numprinters_$i"}) { 2968 delete $form->{"printer_${i}_$_"}; 2969 delete $form->{"command_${i}_$_"}; 2970 } 2971 delete $form->{"numprinters_$i"}; 2972 2973 } 2974 2975 $i = 1; 2976 for $j (sort { $a <=> $b } keys %ws) { 2977 $form->{"workstation_$i"} = $ws{$j}{workstation}; 2978 2979 $form->{"poledisplayon_$i"} = $ws{$j}{poledisplayon}; 2980 $form->{"cashdrawer_$i"} = $ws{$j}{cashdrawer}; 2981 $form->{"poledisplay_$i"} = $ws{$j}{poledisplay}; 2982 2983 $k = 1; 2984 for (@{$ws{$j}{p}}) { 2985 $form->{"printer_${i}_$k"} = $_->{printer}; 2986 $form->{"command_${i}_$k"} = $_->{command}; 2987 $k++; 2988 } 2989 $form->{"numprinters_$i"} = $k; 2990 $i++; 2991 } 2992 $form->{numworkstations} = $i; 2993 2994 $form->{have} = 1; 2995 2996 &workstations; 2997 2998} 2999 3000 3001sub save_workstations { 3002 3003 if (AM->save_workstations(\%myconfig, \%$form)) { 3004 $form->redirect($locale->text('Workstations saved!')); 3005 } else { 3006 $form->error($locale->text('Failed to save workstations!')); 3007 } 3008 3009} 3010 3011 3012sub config { 3013 3014 AM->get_defaults(\%myconfig, \%$form); 3015 3016 for (qw(mm-dd-yy mm/dd/yy dd-mm-yy dd/mm/yy dd.mm.yy yyyy-mm-dd)) { $form->{selectdateformat} .= "$_\n" } 3017 3018 for (qw(1,000.00 1000.00 1.000,00 1000,00 1'000.00)) { $form->{selectnumberformat} .= "$_\n" } 3019 3020 $form->{signature} = $form->quote($myconfig{signature}); 3021 $form->{signature} =~ s/\\n/\n/g; 3022 $form->{oldpassword} = $myconfig{password}; 3023 3024 my %countrycodes = User->country_codes; 3025 3026 for (sort { $countrycodes{$a} cmp $countrycodes{$b} } keys %countrycodes) { 3027 $form->{selectcountrycode} .= qq|${_}--$countrycodes{$_}|; 3028 } 3029 $form->{selectcountrycode} = qq|--English\n$form->{selectcountrycode}|; 3030 3031 opendir CSS, "css/."; 3032 my @all = grep /.*\.css$/, readdir CSS; 3033 closedir CSS; 3034 3035 for (@all) { $form->{selectstylesheet} .= "$_\n" } 3036 $form->{selectstylesheet} .= "\n"; 3037 3038 if (@{ $form->{all_printer} }) { 3039 $form->{selectprinter} = "\n"; 3040 for (@{ $form->{all_printer} }) { $form->{selectprinter} .= "$_->{printer}\n" } 3041 chomp $form->{selectprinter}; 3042 3043 $printer = qq| 3044 <tr> 3045 <th align=right>|.$locale->text('Printer').qq|</th> 3046 <td><select name=printer>| 3047 .$form->select_option($form->{selectprinter}, $myconfig{printer}, undef) 3048 .qq|</select></td> 3049 </tr> 3050|; 3051 3052 $myconfig{outputformat} ||= "Postscript"; 3053 } 3054 3055 my $selectoutputformat = qq|html--|.$locale->text('html').qq| 3056xml--|.$locale->text('XML').qq| 3057txt--|.$locale->text('Text'); 3058 3059 if ($latex) { 3060 $selectoutputformat .= qq| 3061ps--Postscript 3062pdf--PDF|; 3063 } 3064 3065 my $outputformat = qq| 3066 <tr> 3067 <th align=right>|.$locale->text('Output Format').qq|</th> 3068 <td><select name=outputformat>| 3069 .$form->select_option($selectoutputformat, $myconfig{outputformat}, undef, 1) 3070 .qq|</select></td> 3071 </tr> 3072|; 3073 3074 3075 my $adminname; 3076 if ($form->{login} eq "admin\@$myconfig{dbname}") { 3077 $adminname = qq| 3078 <tr> 3079 <th align=right>|.$locale->text('Name').qq|</th> 3080 <td><input name=name value="$myconfig{name}" size=35></td> 3081 </tr> 3082 <tr> 3083 <th align=right>|.$locale->text('E-mail').qq|</th> 3084 <td><input name=email value="$myconfig{email}" size=35></td> 3085 </tr> 3086|; 3087 } 3088 3089 3090 $form->{title} = $locale->text('Edit Preferences'); 3091 3092 $form->helpref("user_preferences", $myconfig{countrycode}); 3093 3094 $form->{type} = "preferences"; 3095 3096 $selectencoding = User->encoding($myconfig{dbdriver}); 3097 3098 $form->header; 3099 3100 print qq| 3101<body> 3102 3103<form method=post action=$form->{script}> 3104 3105<table width=100%> 3106 <tr><th class=listtop>$form->{helpref}$form->{title}</a></th></tr> 3107 <tr> 3108 <td> 3109 <table width=100%> 3110 <tr valign=top> 3111 <td width=50%> 3112 <table> 3113 <tr> 3114 <td></td> 3115 <td width=99%></td> 3116 </tr> 3117 <tr> 3118 <th align=right>|.$locale->text('Password').qq|</th> 3119 <td><input type=password name=new_password value="$myconfig{password}" size=10></td> 3120 </tr> 3121 <tr> 3122 <th align=right>|.$locale->text('Confirm').qq|</th> 3123 <td><input type=password name=confirm_password value="$myconfig{password}" size=10></td> 3124 </tr> 3125 $adminname 3126 <tr valign=top> 3127 <th align=right>|.$locale->text('Signature').qq|</th> 3128 <td><textarea name="signature" rows="3" cols="35">$form->{signature}</textarea></td> 3129 </tr> 3130 </table> 3131 </td> 3132 <td> 3133 <table> 3134 <tr> 3135 <th align=right>|.$locale->text('Date Format').qq|</th> 3136 <td><select name=dateformat>| 3137 .$form->select_option($form->{selectdateformat}, $myconfig{dateformat}) 3138 .qq|</select></td> 3139 </tr> 3140 <tr> 3141 <th align=right>|.$locale->text('Number Format').qq|</th> 3142 <td><select name=numberformat>| 3143 .$form->select_option($form->{selectnumberformat}, $myconfig{numberformat}) 3144 .qq|</select></td> 3145 </tr> 3146 <tr> 3147 <th align=right nowrap>|.$locale->text('Multibyte Encoding').qq|</th> 3148 <td><select name=encoding>|.$form->select_option($selectencoding, $myconfig{charset},1,1).qq|</select></td> 3149 </tr> 3150 <tr> 3151 <th align=right>|.$locale->text('Dropdown Limit').qq|</th> 3152 <td><input name=vclimit class="inputright" size=10 value="$myconfig{vclimit}"></td> 3153 </tr> 3154 <tr> 3155 <th align=right>|.$locale->text('Menu Width').qq|</th> 3156 <td><input name=menuwidth class="inputright" size=10 value="$myconfig{menuwidth}"></td> 3157 </tr> 3158 <tr> 3159 <th align=right>|.$locale->text('Language').qq|</th> 3160 <td><select name=countrycode>| 3161 .$form->select_option($form->{selectcountrycode}, $myconfig{countrycode}, undef, 1) 3162 .qq|</select></td> 3163 </tr> 3164 <tr> 3165 <th align=right>|.$locale->text('Session Timeout').qq|</th> 3166 <td><input name=timeout class="inputright" size=10 value="$myconfig{timeout}"></td> 3167 </tr> 3168 <tr> 3169 <th align=right>|.$locale->text('Stylesheet').qq|</th> 3170 <td><select name=usestylesheet>| 3171 .$form->select_option($form->{selectstylesheet}, $myconfig{stylesheet}) 3172 .qq|</select></td> 3173 </tr> 3174 $outputformat 3175 $printer 3176 </table> 3177 </td> 3178 </tr> 3179 </table> 3180 </td> 3181 <tr> 3182 <td><hr size=3 noshade></td> 3183 </tr> 3184</table> 3185|; 3186 3187 $form->hide_form(qw(type oldpassword path login)); 3188 3189 if ($form->{login} ne "admin\@$myconfig{dbname}") { 3190 $form->hide_form(qw(name email)); 3191 } 3192 3193 print qq| 3194<input type=submit class=submit name=action value="|.$locale->text('Save').qq|">|; 3195 3196 if ($form->{menubar}) { 3197 require "$form->{path}/menu.pl"; 3198 &menubar; 3199 } 3200 3201 print qq| 3202 </form> 3203 3204</body> 3205</html> 3206|; 3207 3208} 3209 3210 3211sub save_defaults { 3212 3213 if (AM->save_defaults(\%myconfig, \%$form)) { 3214 $form->redirect($locale->text('Defaults saved!')); 3215 } else { 3216 $form->error($locale->text('Cannot save defaults!')); 3217 } 3218 3219} 3220 3221 3222sub save_taxes { 3223 3224 for (split / /, $form->{taxaccounts}) { 3225 ($accno, $i) = split /_/, $_; 3226 if ($accno eq $sameaccno && $i > 1) { 3227 $j = $i - 1; 3228 if (! $form->{"validto_$j"}) { 3229 $form->error($locale->text('Valid To date missing for').qq| $form->{"taxdescription_$j"}|); 3230 } 3231 } 3232 $sameaccno = $accno; 3233 } 3234 3235 if (AM->save_taxes(\%myconfig, \%$form)) { 3236 $form->redirect($locale->text('Taxes saved!')); 3237 } else { 3238 $form->error($locale->text('Cannot save taxes!')); 3239 } 3240 3241} 3242 3243 3244sub save_preferences { 3245 3246 $form->{stylesheet} = $form->{usestylesheet}; 3247 3248 if ($form->{new_password} eq $form->{oldpassword}) { 3249 $form->{encrypted} = 1; 3250 } else { 3251 if ($form->{new_password}) { 3252 $form->error('Password may not contain ? or &') if $form->{new_password} =~ /\?|\&/; 3253 if ($form->{new_password} ne $form->{confirm_password}) { 3254 $form->error($locale->text('Password does not match!')); 3255 } 3256 } 3257 } 3258 $form->{password} = $form->{new_password}; 3259 $form->{tan} = $myconfig{tan}; 3260 $form->{charset} = $form->{encoding}; 3261 3262 if (AM->save_preferences(\%$form, $memberfile, $userspath)) { 3263 $form->redirect($locale->text('Preferences saved!')); 3264 } else { 3265 $form->error($locale->text('Cannot save preferences!')); 3266 } 3267 3268} 3269 3270 3271sub backup { 3272 3273 if ($form->{media} eq 'email') { 3274 $form->error($locale->text('No email address for')." $myconfig{name}") unless ($myconfig{email}); 3275 3276 $form->{OUT} = "$sendmail"; 3277 3278 } 3279 3280 $SIG{INT} = 'IGNORE'; 3281 AM->backup(\%myconfig, \%$form, $userspath, $gzip); 3282 3283 if ($form->{media} eq 'email') { 3284 $form->redirect($locale->text('Backup sent to').qq| $myconfig{email}|); 3285 } 3286 3287} 3288 3289 3290sub restore { 3291 3292 $form->{title} = $locale->text('Restore'); 3293 3294 $form->helpref("restore", $myconfig{countrycode}); 3295 3296 $form->header; 3297 3298 $form->error($locale->text('Must be logged in as admin!')) unless $form->{admin};; 3299 3300 $form->{nextsub} = "get_dataset"; 3301 $form->{action} = "continue"; 3302 3303print qq| 3304<body> 3305 3306<form enctype="multipart/form-data" method=post action=$form->{script}> 3307 3308<table width=100%> 3309 <tr> 3310 <th class=listtop>$form->{helpref}$form->{title}</a></th> 3311 </tr> 3312 <tr height="5"></tr> 3313 <tr> 3314 <td> 3315 <table> 3316 <tr> 3317 <th align="right">|.$locale->text('Backup File').qq|</th> 3318 <td> 3319 <input name=data size=60 type=file> 3320 </td> 3321 </tr> 3322 </table> 3323 </td> 3324 </tr> 3325 <tr> 3326 <td><hr size=3 noshade></td> 3327 </tr> 3328 3329</table> 3330|; 3331 3332 $form->hide_form(qw(nextsub login path)); 3333 3334 print qq| 3335<input name=action class=submit type=submit value="|.$locale->text('Continue').qq|"> 3336</form> 3337 3338</body> 3339</html> 3340|; 3341 3342} 3343 3344 3345sub get_dataset { 3346 3347 if ($form->{tmpfile} =~ /\.gz$/) { 3348 if ($gzip) { 3349 ($gzip) = split / /, $gzip; 3350 } else { 3351 unlink "$userspath/$form->{tmpfile}"; 3352 $form->error($locale->text('Cannot process gzipped file!')); 3353 } 3354 3355 @args = ("$gzip", '-d', "$userspath/$form->{tmpfile}"); 3356 system(@args) == 0 or $form->error($locale->text('gzip failed!')); 3357 3358 $form->{tmpfile} =~ s/\..*//; 3359 @e = split /\./, $form->{filename}; 3360 pop @e; 3361 if (@e) { 3362 $form->{filename} = join '.', @e; 3363 } 3364 } 3365 3366 open(FH, "$userspath/$form->{tmpfile}") or $form->error("$userspath/$form->{tmpfile} : $!"); 3367 open(SP, ">$spool/$myconfig{dbname}/$form->{filename}") or $form->error("$spool/$myconfig{dbname}/$form->{filename} : $!"); 3368 3369 for (<FH>) { 3370 print SP $_; 3371 if (/-- Version:/) { 3372 @d = split / /, $_; 3373 $form->{restoredbversion} = $d[2]; 3374 chop $form->{restoredbversion}; 3375 } 3376 if (/-- Dataset:/) { 3377 @d = split / /, $_; 3378 $form->{restoredbname} = $d[2]; 3379 chop $form->{restoredbname}; 3380 } 3381 } 3382 close(FH); 3383 close(SP); 3384 3385 unlink "$userspath/$form->{tmpfile}"; 3386 3387 unless ($form->{restoredbversion} && $form->{restoredbname}) { 3388 unlink "$spool/$myconfig{dbname}/$form->{filename}"; 3389 $form->error($locale->text('Not a SQL-Ledger backup!')); 3390 } 3391 3392 if ($myconfig{dbname} ne $form->{restoredbname}) { 3393 $dbname = qq| 3394 <tr> 3395 <td><b>|.$locale->text('Dataset different!').qq|</b> 3396<br><b>$myconfig{dbname}</b> |. 3397$locale->text('will be restored with data from').qq| <b>$form->{restoredbname}</b></td> 3398 </tr> 3399|; 3400 } else { 3401 $dbname = qq| 3402 <tr> 3403 <th align=left>|.$locale->text('Restoring Dataset:').qq| $myconfig{dbname}</th> 3404 </tr> 3405|; 3406 } 3407 3408 if ($form->{dbversion} ne $form->{restoredbversion}) { 3409 if ($form->{restoredbversion} gt $form->{dbversion}) { 3410 unlink "$spool/$myconfig{dbname}/$form->{filename}"; 3411 $form->error($locale->text('Dataset version newer, SQL-Ledger must first be upgraded!')); 3412 } 3413 3414 $dbversion = qq| 3415 <tr> 3416 <td><b>|.$locale->text('Dataset Version different!').qq|</b> 3417<br>|.$locale->text('Dataset will be upgraded to').qq| <b>$form->{dbversion}</b></td> 3418 </tr> 3419|; 3420 3421 } else { 3422 $dbversion = qq| 3423 <tr> 3424 <th align=left>|.$locale->text('Dataset Version:').qq| $form->{dbversion}</th> 3425 </tr> 3426|; 3427 } 3428 3429 $form->{title} = $locale->text('Restore'); 3430 3431 $form->helpref("restore", $myconfig{countrycode}); 3432 3433 $form->header; 3434 3435print qq| 3436<body> 3437 3438<form method=post action=$form->{script}> 3439 3440<table width=100%> 3441 <tr><th class=listtop>$form->{helpref}$form->{title}</a></th></tr> 3442 <tr height="5"></tr> 3443 $dbname 3444 $dbversion 3445</table> 3446 3447<hr size=3 noshade> 3448 3449<br> 3450<input type=submit class=submit name=action value="|.$locale->text('Continue').qq|"> 3451|; 3452 3453 $form->{nextsub} = "do_restore"; 3454 $form->{action} = "do_restore"; 3455 3456 $form->hide_form(qw(restoredbversion filename nextsub action login path)); 3457 3458 print qq| 3459</form> 3460 3461</body> 3462</html> 3463|; 3464 3465} 3466 3467 3468sub do_restore { 3469 3470 $form->header; 3471 3472 $form->error($locale->text('Must be logged in as admin!')) unless $form->{admin}; 3473 3474 open FH, ">$userspath/$myconfig{dbname}.LCK" or $form->error($!); 3475 close(FH); 3476 3477 $form->info($locale->text('Restoring dataset version')." $form->{restoredbversion}\n"); 3478 3479 if ($ok = AM->restore(\%myconfig, \%$form, "$spool/$myconfig{dbname}/$form->{filename}")) { 3480 $form->info($locale->text('done')."\n"); 3481 } else { 3482 $form->info($locale->text('failed!')."\n"); 3483 } 3484 3485 unlink "$spool/$myconfig{dbname}/$form->{filename}"; 3486 3487 if ($ok) { 3488 if ($form->{dbversion} ne $form->{restoredbversion}) { 3489 &upgrade_dataset; 3490 } 3491 } 3492 3493 unlink "$userspath/$myconfig{dbname}.LCK"; 3494 3495} 3496 3497 3498sub upgrade_dataset { 3499 3500 $user = new User $memberfile, $form->{login}; 3501 3502 open FH, ">$userspath/$myconfig{dbname}.LCK" or $form->error($!); 3503 3504 for (qw(dbname dbhost dbport dbdriver dbuser)) { $form->{$_} = $myconfig{$_} } 3505 $form->{dbpasswd} = unpack 'u', $myconfig{dbpasswd}; 3506 3507 $form->info($locale->text('Upgrading to Version')." $form->{dbversion} ... \n"); 3508 3509 # required for Oracle 3510 $form->{dbdefault} = $sid; 3511 3512 $user->dbupdate(\%$form); 3513 3514 unlink "$userspath/$myconfig{dbname}.LCK"; 3515 3516 $form->info($locale->text('done')); 3517 3518} 3519 3520 3521sub audit_control { 3522 3523 $form->{title} = $locale->text('Audit Control'); 3524 3525 $form->error($locale->text('Must be logged in as admin!')) unless $form->{admin}; 3526 3527 AM->closedto(\%myconfig, \%$form); 3528 3529 my %checked; 3530 for (qw(revtrans audittrail)) { $checked{$_} = "checked" if $form->{$_} } 3531 3532 $form->helpref("audit_control", $myconfig{countrycode}); 3533 3534 $form->header; 3535 3536 &calendar; 3537 3538 print qq| 3539<body> 3540 3541<form method="post" name="main" action="$form->{script}"> 3542 3543<table width=100%> 3544 <tr><th class=listtop>$form->{helpref}$form->{title}</a></th></tr> 3545 <tr height="5"></tr> 3546 <tr> 3547 <td> 3548 <table> 3549 <tr> 3550 <th align=right>|.$locale->text('Enforce transaction reversal for all dates').qq|</th> 3551 <td><input name=revtrans class=checkbox type=checkbox value="1" $checked{revtrans}></td> 3552 </tr> 3553 <tr> 3554 <th align=right>|.$locale->text('Close Books up to').qq|</th> 3555 <td><input name=closedto size=11 class=date title="$myconfig{dateformat}" value=$form->{closedto}>|.&js_calendar("main", "closedto").qq|</td> 3556 </tr> 3557 <tr> 3558 <th align=right>|.$locale->text('Activate Audit trail').qq|</th> 3559 <td><input name=audittrail class=checkbox type=checkbox value="1" $checked{audittrail}></td> 3560 </tr> 3561 <tr> 3562 <th align=right>|.$locale->text('Remove Audit trail up to').qq|</th> 3563 <td><input name=removeaudittrail size=11 class=date title="$myconfig{dateformat}">|.&js_calendar("main", "removeaudittrail").qq|</td> 3564 </tr> 3565 </table> 3566 </td> 3567 </tr> 3568</table> 3569 3570<hr size=3 noshade> 3571 3572<br> 3573<input type=submit class=submit name=action value="|.$locale->text('Continue').qq|"> 3574|; 3575 3576 $form->{nextsub} = "doclose"; 3577 $form->{action} = "doclose"; 3578 3579 $form->hide_form(qw(nextsub action login path)); 3580 3581 print qq| 3582</form> 3583 3584</body> 3585</html> 3586|; 3587 3588} 3589 3590 3591sub doclose { 3592 3593 $form->error($locale->text('Must be logged in as admin!')) unless $form->{admin}; 3594 3595 AM->closebooks(\%myconfig, \%$form); 3596 3597 my $msg; 3598 if ($form->{revtrans}) { 3599 $msg = $locale->text('Transaction reversal enforced for all dates'); 3600 } else { 3601 3602 if ($form->{closedto}) { 3603 $msg = $locale->text('Books closed up to') 3604 ." ".$locale->date(\%myconfig, $form->{closedto}, 1); 3605 } else { 3606 $msg = $locale->text('Books are open'); 3607 } 3608 } 3609 3610 $msg .= "<p>"; 3611 if ($form->{audittrail}) { 3612 $msg .= $locale->text('Audit trail enabled'); 3613 } else { 3614 $msg .= $locale->text('Audit trail disabled'); 3615 } 3616 3617 $msg .= "<p>"; 3618 if ($form->{removeaudittrail}) { 3619 $msg .= $locale->text('Audit trail removed up to') 3620 ." ".$locale->date(\%myconfig, $form->{removeaudittrail}, 1); 3621 } 3622 3623 $form->redirect($msg); 3624 3625} 3626 3627 3628sub audit_log { 3629 3630 AM->audit_log_links(\%myconfig, \%$form); 3631 3632 if (@{ $form->{all_employee} }) { 3633 $form->{selectemployee} = "\n"; 3634 for (@{ $form->{all_employee} }) { $form->{selectemployee} .= qq|$_->{name}--$_->{id}\n| } 3635 3636 $employee = qq| 3637 <tr> 3638 <th align=right nowrap>|.$locale->text('Employee').qq|</th> 3639 <td><select name=employee>| 3640 .$form->select_option($form->{selectemployee}, undef, 1) 3641 .qq|</select> 3642 </td> 3643|; 3644 3645 } 3646 3647 if (@{ $form->{all_action} }) { 3648 $form->{selectaction} = "\n"; 3649 for (@{ $form->{all_action} }) { $form->{selectaction} .= qq|$_->{action}\n| } 3650 3651 $action = qq| 3652 <tr> 3653 <th align=right nowrap>|.$locale->text('Action').qq|</th> 3654 <td><select name=logaction>| 3655 .$form->select_option($form->{selectaction}) 3656 .qq|</select> 3657 </td> 3658|; 3659 } 3660 3661 3662 $form->{title} = $locale->text('Audit Log') . " / $form->{company}"; 3663 3664 $form->helpref("audit_log", $myconfig{countrycode}); 3665 3666 $form->header; 3667 3668 &calendar; 3669 3670 print qq| 3671<body> 3672 3673<form method="post" name="main" action="$form->{script}"> 3674 3675<table width=100%> 3676 <tr><th class=listtop>$form->{helpref}$form->{title}</a></th></tr> 3677 <tr height="5"></tr> 3678 <tr> 3679 <td> 3680 <table> 3681 $employee 3682 $action 3683 <tr> 3684 <th align=right nowrap>|.$locale->text('Reference').qq|</th> 3685 <td><input name=reference></td> 3686 </tr> 3687 <tr> 3688 <th align=right nowrap>|.$locale->text('From').qq|</th> 3689 <td><input name=transdatefrom size=11 class=date title="$myconfig{dateformat}">|.&js_calendar("main", "transdatefrom").qq| 3690 <b>|.$locale->text('To').qq|</b> 3691 <input name=transdateto size=11 class=date title="$myconfig{dateformat}">|.&js_calendar("main", "transdateto").qq|</td> 3692 </tr> 3693 </table> 3694 </td> 3695 </tr> 3696 <tr> 3697 <td><hr size=3 noshade></td> 3698 </tr> 3699</table> 3700 3701<br> 3702<input class=submit type=submit name=action value="|.$locale->text('Continue').qq|"> 3703|; 3704 3705 $form->{nextsub} = "list_audit_log"; 3706 $form->hide_form(qw(nextsub path login)); 3707 3708 print qq| 3709 3710</form> 3711 3712</body> 3713</html> 3714|; 3715 3716} 3717 3718 3719sub list_audit_log { 3720 3721 AM->audit_log(\%myconfig, \%$form); 3722 3723 $form->helpref("audit_trail", $myconfig{countrycode}); 3724 3725 # construct href 3726 $href = qq|$form->{script}?action=list_audit_log|; 3727 for (qw(oldsort direction path login)) { $href .= qq|&$_=$form->{$_}| } 3728 3729 # construct callback 3730 3731 $form->sort_order(); 3732 3733 $callback = qq|$form->{script}?action=list_audit_log|; 3734 for (qw(oldsort direction path login)) { $callback .= qq|&$_=$form->{$_}| } 3735 3736 if ($form->{employee}) { 3737 ($employee) = split /--/, $form->{employee}; 3738 $callback .= "&employee=".$form->escape($form->{employee},1); 3739 $href .= "&employee=".$form->escape($form->{employee}); 3740 $option = $locale->text('Employee')." : $employee"; 3741 } 3742 if ($form->{logaction}) { 3743 $callback .= "&logaction=$form->{logaction}"; 3744 $href .= "&logaction=$form->{logaction}"; 3745 $option .= "\n<br>" if ($option); 3746 $option .= $locale->text('Action')." : $form->{logaction}"; 3747 } 3748 if ($form->{reference}) { 3749 $callback .= "&reference=".$form->escape($form->{reference},1); 3750 $href .= "&reference=".$form->escape($form->{reference}); 3751 $option .= "\n<br>" if ($option); 3752 $option .= $locale->text('Reference')." : $form->{reference}"; 3753 } 3754 if ($form->{transdatefrom}) { 3755 $callback .= "&transdatefrom=$form->{transdatefrom}"; 3756 $href .= "&transdatefrom=$form->{transdatefrom}"; 3757 $option .= "\n<br>" if ($option); 3758 $option .= $locale->text('From')." ".$locale->date(\%myconfig, $form->{transdatefrom}, 1); 3759 } 3760 if ($form->{transdateto}) { 3761 $callback .= "&transdateto=$form->{transdateto}"; 3762 $href .= "&transdateto=$form->{transdateto}"; 3763 $option .= "\n<br>" if ($option); 3764 $option .= $locale->text('To')." ".$locale->date(\%myconfig, $form->{transdateto}, 1); 3765 } 3766 3767 @column_index = $form->sort_columns(qw(transdate transtime tablename reference trans_id formname action name employeenumber login)); 3768 3769 $column_header{transdate} = qq|<th><a class=listheading href=$href&sort=transdate>|.$locale->text('Date').qq|</a></th>|; 3770 $column_header{transtime} = qq|<th class=listheading>|.$locale->text('Time').qq|</th>|; 3771 $column_header{name} = qq|<th><a class=listheading href=$href&sort=name>|.$locale->text('Employee').qq|</a></th>|; 3772 $column_header{employeenumber} = qq|<th><a class=listheading href=$href&sort=employeenumber>|.$locale->text('Number').qq|</a></th>|; 3773 $column_header{tablename} = qq|<th><a class=listheading href=$href&sort=tablename>|.$locale->text('Table').qq|</a></th>|; 3774 $column_header{reference} = qq|<th><a class=listheading href=$href&sort=reference>|.$locale->text('Reference').qq|</a></th>|; 3775 $column_header{trans_id} = qq|<th><a class=listheading href=$href&sort=trans_id>|.$locale->text('ID').qq|</a></th>|; 3776 $column_header{formname} = qq|<th><a class=listheading href=$href&sort=formname>|.$locale->text('Form').qq|</a></th>|; 3777 $column_header{action} = qq|<th><a class=listheading href=$href&sort=action>|.$locale->text('Action').qq|</a></th>|; 3778 $column_header{login} = qq|<th><a class=listheading href=$href&sort=login>|.$locale->text('Login').qq|</a></th>|; 3779 3780 $form->{title} = $locale->text('Audit Log') . " / $form->{company}"; 3781 3782 $form->header; 3783 3784 print qq| 3785<body> 3786 3787<form method="post" name="main" action="$form->{script}"> 3788 3789<table width=100%> 3790 <tr> 3791 <th class=listtop>$form->{helpref}$form->{title}</a></th> 3792 </tr> 3793 <tr height="5"></tr> 3794 <tr> 3795 <td>$option</td> 3796 </tr> 3797 <tr> 3798 <td> 3799 <table width=100%> 3800 <tr class=listheading>|; 3801 3802 for (@column_index) { print "\n$column_header{$_}" } 3803 3804 print qq| 3805 </tr> 3806|; 3807 3808 # add sort and escape callback 3809 $callback .= "&sort=$form->{sort}"; 3810 $form->{callback} = $callback; 3811 $callback = $form->escape($callback); 3812 3813 %formname = ( part => { ic => { module => 'ic', param => [ 'item=part' ] } }, 3814 service => { ic => { module => 'ic', param => [ 'item=service' ] } }, 3815 kit => { ic => { module => 'ic', param => [ 'item=kit' ] } }, 3816 assembly => { ic => { module => 'ic', param => [ 'item=assembly' ] } }, 3817 transaction => { ar => { module => 'ar', param => [ 'type=transaction' ] }, 3818 ap => { module => 'ap', param => [ 'type=transaction' ] }, 3819 gl => { module => 'gl' } }, 3820 credit_note => { ar => { module => 'ar', param => [ 'type=credit_note' ] } }, 3821 debit_note => { ap => { module => 'ap', param => [ 'type=debit_note' ] } }, 3822 invoice => { ar => { module => 'is', param => [ 'type=invoice' ] }, 3823 ap => { module => 'ir', param => [ 'type=invoice' ] } }, 3824 deposit => { ar => { module => 'ar', param => [ 'type=transaction' ] } }, 3825 'pre-payment' => { ap => { module => 'ap', param => [ 'type=transaction' ] } }, 3826 pos_invoice => { ar => { module => 'ps' } }, 3827 credit_invoice => { ar => { module => 'is', param => [ 'type=credit_invoice' ] } }, 3828 debit_invoice => { ap => { module => 'ir', param => [ 'type=debit_invoice' ] } }, 3829 sales_order => { oe => { module => 'oe', param => [ 'type=sales_order', 'vc=customer' ] } }, 3830 purchase_order => { oe => { module => 'oe', param => [ 'type=purchase_order', 'vc=vendor' ] } }, 3831 sales_quotation => { oe => { module => 'oe', param => [ 'type=sales_quotation', 'vc=customer' ] } }, 3832 request_quotation => { oe => { module => 'oe', param => [ 'type=request_quotation' ] } }, 3833 timecard => { jcitems => { module => 'jc', param => [ 'type=timecard', 'project=project' ] } }, 3834 storescard => { jcitems => { module => 'jc', param => [ 'type=storescard', 'project=job' ] } }, 3835 yearend => { gl => { module => 'gl' } }, 3836 ); 3837 3838 foreach $ref (@{ $form->{ALL} }) { 3839 3840 for (@column_index) { $column_data{$_} = "<td>$ref->{$_} </td>" } 3841 3842 if ($ref->{trans_id} && $ref->{action} ne 'deleted') { 3843 if ($formname{$ref->{formname}}) { 3844 $href = "$formname{$ref->{formname}}{$ref->{tablename}}{module}.pl?action=edit&id=$ref->{trans_id}"; 3845 for (qw(path login)) { 3846 $href .= "&$_=$form->{$_}"; 3847 } 3848 for (@{ $formname{$ref->{formname}}{$ref->{tablename}}{param} }) { 3849 $href .= "&$_"; 3850 } 3851 $href .= "&callback=$callback"; 3852 $column_data{trans_id} = qq|<td><a href=$href>$ref->{trans_id}</td>|; 3853 } 3854 } 3855 3856 if ($ref->{login} ne 'admin') { 3857 $href = "hr.pl?action=edit&db=employee&id=$ref->{employee_id}"; 3858 for (qw(path login)) { 3859 $href .= "&$_=$form->{$_}"; 3860 } 3861 $href .= "&callback=$callback"; 3862 $column_data{name} = qq|<td><a href=$href>$ref->{name}</td>|; 3863 } 3864 3865 $j++; $j %= 2; 3866 3867 print " 3868 <tr class=listrow$j>"; 3869 3870 for (@column_index) { print "\n$column_data{$_}" } 3871 3872 print qq| 3873 </tr> 3874|; 3875 3876 } 3877 3878 print qq| 3879 </table> 3880 </tr> 3881 <tr> 3882 <td><hr size=3 noshade></td> 3883 </tr> 3884</table> 3885 3886<br> 3887|; 3888 3889 $form->hide_form(qw(callback path login sort)); 3890 3891 if ($form->{menubar}) { 3892 require "$form->{path}/menu.pl"; 3893 &menubar; 3894 } 3895 3896 print qq| 3897</form> 3898 3899</body> 3900</html> 3901|; 3902 3903} 3904 3905 3906sub add_warehouse { 3907 3908 $form->{title} = $locale->text('Add Warehouse'); 3909 3910 $form->{callback} = "$form->{script}?action=add_warehouse&path=$form->{path}&login=$form->{login}" unless $form->{callback}; 3911 3912 &warehouse_header; 3913 &form_footer; 3914 3915} 3916 3917 3918sub edit_warehouse { 3919 3920 $form->{title} = $locale->text('Edit Warehouse'); 3921 3922 AM->get_warehouse(\%myconfig, \%$form); 3923 3924 &warehouse_header; 3925 &form_footer; 3926 3927} 3928 3929 3930sub list_warehouse { 3931 3932 AM->warehouses(\%myconfig, \%$form); 3933 3934 my $href = "$form->{script}?action=list_warehouse"; 3935 3936 $form->{callback} = "$form->{script}?action=list_warehouse"; 3937 3938 for (qw(path login)) { $form->{callback} .= "&$_=$form->{$_}" } 3939 3940 my $callback = $form->escape($form->{callback}); 3941 3942 $form->{title} = $locale->text('Warehouses') . " / $form->{company}"; 3943 3944 my @column_index = $form->sort_columns(qw(description address up down)); 3945 3946 my %column_data; 3947 3948 $column_data{description} = qq|<th class=listheading>|.$locale->text('Description').qq|</th>|; 3949 $column_data{address} = qq|<th class=listheading>|.$locale->text('Address').qq|</th>|; 3950 $column_data{up} = qq|<th width=1% class=listheading> </th>|; 3951 $column_data{down} = qq|<th width=1% class=listheading> </th>|; 3952 3953 $form->helpref("list_warehouse", $myconfig{countrycode}); 3954 3955 $form->header; 3956 3957 print qq| 3958<body> 3959 3960<table width=100%> 3961 <tr> 3962 <th class=listtop>$form->{helpref}$form->{title}</a></th> 3963 </tr> 3964 <tr height="5"></tr> 3965 <tr> 3966 <td> 3967 <table width=100%> 3968 <tr class=listheading> 3969|; 3970 3971 for (@column_index) { print "$column_data{$_}\n" } 3972 3973 print qq| 3974 </tr> 3975|; 3976 3977 my $i; 3978 3979 foreach my $ref (@{ $form->{ALL} }) { 3980 3981 $i++; $i %= 2; 3982 3983 print qq| 3984 <tr valign=top class=listrow$i> 3985|; 3986 3987 $column_data{description} = qq|<td><a href=$form->{script}?action=edit_warehouse&id=$ref->{id}&path=$form->{path}&login=$form->{login}&callback=$callback>$ref->{description}</td>|; 3988 $column_data{address} = qq|<td>$ref->{address1} $ref->{address2} $ref->{city} $ref->{state} $ref->{zipcode} $ref->{country}</td>|; 3989 $column_data{up} = qq|<td><a href=$form->{script}?action=move&db=warehouse&fld=id&id=$ref->{id}&move=up&path=$form->{path}&login=$form->{login}&callback=$callback><img src=$images/up.png alt="+" border=0></td>|; 3990 $column_data{down} = qq|<td><a href=$form->{script}?action=move&db=warehouse&fld=id&id=$ref->{id}&move=down&path=$form->{path}&login=$form->{login}&callback=$callback><img src=$images/down.png alt="-" border=0></td>|; 3991 3992 for (@column_index) { print "$column_data{$_}\n" } 3993 3994 print qq| 3995 </tr> 3996|; 3997 } 3998 3999 print qq| 4000 </table> 4001 </td> 4002 </tr> 4003 <tr> 4004 <td><hr size=3 noshade></td> 4005 </tr> 4006</table> 4007 4008<br> 4009<form method=post action=$form->{script}> 4010|; 4011 4012 $form->{type} = "warehouse"; 4013 4014 $form->hide_form(qw(type callback path login)); 4015 4016 print qq| 4017<input class=submit type=submit name=action value="|.$locale->text('Add Warehouse').qq|">|; 4018 4019 if ($form->{menubar}) { 4020 require "$form->{path}/menu.pl"; 4021 &menubar; 4022 } 4023 4024 print qq| 4025 </form> 4026 4027</body> 4028</html> 4029|; 4030 4031} 4032 4033 4034 4035sub warehouse_header { 4036 4037 $form->{description} = $form->quote($form->{description}); 4038 4039 my $description; 4040 my $rows; 4041 4042 if (($rows = $form->numtextrows($form->{description}, 60)) > 1) { 4043 $description = qq|<textarea name="description" rows=$rows cols=60 wrap=soft>$form->{description}</textarea>|; 4044 } else { 4045 $description = qq|<input name=description size=60 value="|.$form->quote($form->{description}).qq|">|; 4046 } 4047 4048 $form->helpref("warehouse", $myconfig{countrycode}); 4049 4050 $form->header; 4051 4052 print qq| 4053<body> 4054 4055<form method=post action=$form->{script}> 4056 4057<input type=hidden name=id value=$form->{id}> 4058<input type=hidden name=type value=warehouse> 4059 4060<table width=100%> 4061 <tr> 4062 <th class=listtop colspan=2>$form->{helpref}$form->{title}</a></th> 4063 </tr> 4064 <tr height="5"></tr> 4065 <tr> 4066 <th align=right>|.$locale->text('Description').qq|</th> 4067 <td>$description</td> 4068 </tr> 4069 <tr> 4070 <th align=right nowrap>|.$locale->text('Address').qq|</th> 4071 <td><input name=address1 size=35 maxlength=32 value="|.$form->quote($form->{address1}).qq|"></td> 4072 </tr> 4073 <tr> 4074 <th></th> 4075 <td><input name=address2 size=35 maxlength=32 value="|.$form->quote($form->{address2}).qq|"></td> 4076 </tr> 4077 <tr> 4078 <th align=right nowrap>|.$locale->text('City').qq|</th> 4079 <td><input name=city size=35 maxlength=32 value="|.$form->quote($form->{city}).qq|"></td> 4080 </tr> 4081 <tr> 4082 <th align=right nowrap>|.$locale->text('State/Province').qq|</th> 4083 <td><input name=state size=35 maxlength=32 value="|.$form->quote($form->{state}).qq|"></td> 4084 </tr> 4085 <tr> 4086 <th align=right nowrap>|.$locale->text('Zip/Postal Code').qq|</th> 4087 <td><input name=zipcode size=10 maxlength=10 value="|.$form->quote($form->{zipcode}).qq|"></td> 4088 </tr> 4089 <tr> 4090 <th align=right nowrap>|.$locale->text('Country').qq|</th> 4091 <td><input name=country size=35 maxlength=32 value="|.$form->quote($form->{country}).qq|"></td> 4092 </tr> 4093 <tr> 4094 <td colspan=2><hr size=3 noshade></td> 4095 </tr> 4096</table> 4097|; 4098 4099} 4100 4101 4102sub save_warehouse { 4103 4104 $form->isblank("description", $locale->text('Description missing!')); 4105 if (AM->save_warehouse(\%myconfig, \%$form)) { 4106 $form->redirect($locale->text('Warehouse saved!')); 4107 } 4108 4109 $form->error($locale->text('Failed to save Warehouse!')); 4110 4111} 4112 4113 4114sub delete_warehouse { 4115 4116 if (AM->delete_warehouse(\%myconfig, \%$form)) { 4117 $form->redirect($locale->text('Warehouse deleted!')); 4118 } 4119 4120 $form->error($locale->text('Failed to delete Warehouse!')); 4121 4122} 4123 4124 4125sub yearend { 4126 4127 AM->earningsaccounts(\%myconfig, \%$form); 4128 4129 for (@{ $form->{chart} }) { $form->{selectchart} .= "$_->{accno}--$_->{description}\n" } 4130 4131 $checked{accrual} = "checked" if $form->{method} eq 'accrual'; 4132 $checked{cash} = "checked" if $form->{method} eq 'cash'; 4133 4134 $form->{title} = $locale->text('Yearend') . " / $form->{company}"; 4135 4136 $form->helpref("yearend", $myconfig{countrycode}); 4137 4138 $form->header; 4139 4140 &calendar; 4141 4142 print qq| 4143<body> 4144 4145<form method="post" name="main" action="$form->{script}"> 4146 4147<table width=100%> 4148 <tr> 4149 <th class=listtop>$form->{helpref}$form->{title}</a></th> 4150 </tr> 4151 <tr height="5"></tr> 4152 <tr> 4153 <td> 4154 <table> 4155 <tr> 4156 <th align=right>|.$locale->text('Date').qq| <font color=red>*</font></th> 4157 <td><input name=todate size=11 class=date title="$myconfig{dateformat}" value=$todate>|.&js_calendar("main", "todate").qq|</td> 4158 </tr> 4159 <tr> 4160 <th align=right>|.$locale->text('Reference').qq|</th> 4161 <td><input name=reference size=20></td> 4162 </tr> 4163 <tr> 4164 <th align=right>|.$locale->text('Description').qq|</th> 4165 <td><textarea name=description rows=3 cols=50 wrap=soft></textarea></td> 4166 </tr> 4167 <tr> 4168 <th align=right>|.$locale->text('Retained Earnings').qq|</th> 4169 <td><select name=accno>| 4170 .$form->select_option($form->{selectchart}) 4171 .qq|</select></td> 4172 </tr> 4173 <tr> 4174 <th align=right>|.$locale->text('Method').qq|</th> 4175 <td><input name=method class=radio type=radio value=accrual $checked{accrual}> |.$locale->text('Accrual').qq| <input name=method class=radio type=radio value=cash $checked{cash}> |.$locale->text('Cash').qq|</td> 4176 </tr> 4177 </table> 4178 </td> 4179 </tr> 4180</table> 4181 4182<hr size=3 noshade> 4183 4184|; 4185 4186 $form->{l_accno} = "Y"; 4187 $form->{nextsub} = "generate_yearend"; 4188 4189 $form->hide_form(qw(l_accno nextsub precision path login)); 4190 4191 print qq| 4192<input class=submit type=submit name=action value="|.$locale->text('Continue').qq|">|; 4193 4194} 4195 4196 4197sub generate_yearend { 4198 4199 $form->isblank("todate", $locale->text('Yearend date missing!')); 4200 4201 RP->yearend_statement(\%myconfig, \%$form); 4202 4203 $form->{transdate} = $form->{todate}; 4204 4205 my $earnings = 0; 4206 my $ok; 4207 4208 $form->{rowcount} = 1; 4209 for (keys %{ $form->{I} }) { 4210 if ($form->{I}{$_}{charttype} eq "A") { 4211 $form->{"debit_$form->{rowcount}"} = $form->{I}{$_}{amount}; 4212 $earnings += $form->{I}{$_}{amount}; 4213 $form->{"accno_$form->{rowcount}"} = $_; 4214 $form->{rowcount}++; 4215 $ok = 1; 4216 } 4217 } 4218 4219 for (keys %{ $form->{E} }) { 4220 if ($form->{E}{$_}{charttype} eq "A") { 4221 $form->{"credit_$form->{rowcount}"} = $form->{E}{$_}{amount} * -1; 4222 $earnings += $form->{E}{$_}{amount}; 4223 $form->{"accno_$form->{rowcount}"} = $_; 4224 $form->{rowcount}++; 4225 $ok = 1; 4226 } 4227 } 4228 if ($earnings > 0) { 4229 $form->{"credit_$form->{rowcount}"} = $earnings; 4230 $form->{"accno_$form->{rowcount}"} = $form->{accno} 4231 } else { 4232 $form->{"debit_$form->{rowcount}"} = $earnings * -1; 4233 $form->{"accno_$form->{rowcount}"} = $form->{accno} 4234 } 4235 4236 if ($ok && $earnings) { 4237 if (AM->post_yearend(\%myconfig, \%$form)) { 4238 $form->redirect($locale->text('Yearend posted!')); 4239 } else { 4240 $form->error($locale->text('Yearend posting failed!')); 4241 } 4242 } else { 4243 $form->error('Nothing to do!'); 4244 } 4245 4246} 4247 4248 4249 4250sub company_logo { 4251 4252 AM->company_defaults(\%myconfig, \%$form); 4253 $form->{address} =~ s/\n/<br>/g; 4254 4255 $form->{stylesheet} = $myconfig{stylesheet}; 4256 4257 $form->{title} = $locale->text('About'); 4258 4259 if ($form->{username}) { 4260 $user = qq| 4261 <tr> 4262 <th align=right>|.$locale->text('User').qq|</th> 4263 <td>$form->{username}</td> 4264 </tr> 4265|; 4266 } 4267 4268 if ($myconfig{dbhost}) { 4269 $dbhost = qq| 4270 <tr> 4271 <th align=right>|.$locale->text('Database Host').qq|</th> 4272 <td>$myconfig{dbhost}</td> 4273 </tr> 4274|; 4275 } 4276 4277 4278 # create the logo screen 4279 $form->header; 4280 4281 print qq| 4282<body> 4283 4284<pre> 4285 4286 4287 4288 4289 4290</pre> 4291<center> 4292<a href="http://www.sql-ledger.com" target=_blank><img src=$images/sql-ledger.png border=0></a> 4293<h1 class=login>|.$locale->text('Version').qq| $form->{version}</h1> 4294 4295<p> 4296|.$locale->text('Licensed to').qq| 4297<p> 4298<b> 4299$form->{company} 4300<br>$form->{address} 4301</b> 4302 4303<p> 4304<table border=0> 4305 $user 4306 <tr> 4307 <th align=right>|.$locale->text('Dataset').qq|</th> 4308 <td>$myconfig{dbname}</td> 4309 </tr> 4310 $dbhost 4311</table> 4312 4313</center> 4314 4315</body> 4316</html> 4317|; 4318 4319} 4320 4321 4322sub recurring_transactions { 4323 4324# $locale->text('Day') 4325# $locale->text('Days') 4326# $locale->text('Month') 4327# $locale->text('Months') 4328# $locale->text('Week') 4329# $locale->text('Weeks') 4330# $locale->text('Year') 4331# $locale->text('Years') 4332 4333 $form->{stylesheet} = $myconfig{stylesheet}; 4334 4335 $column_data{id} = ""; 4336 4337 AM->recurring_transactions(\%myconfig, \%$form); 4338 4339 $form->{title} = $locale->text('Recurring Transactions') . " / $form->{company}"; 4340 4341 my $href = "$form->{script}?action=recurring_transactions"; 4342 for (qw(path login)) { $href .= qq|&$_=$form->{$_}| } 4343 my $callback = $href; 4344 for (qw(direction oldsort)) { $href .= qq|&$_=$form->{$_}| } 4345 4346 $form->sort_order(); 4347 4348 my @column_index = qw(ndx reference description name vcnumber); 4349 4350 push @column_index, qw(nextdate enddate id amount curr repeat howmany recurringemail recurringprint); 4351 4352 my %column_data; 4353 4354 $form->{allbox} = ($form->{allbox}) ? "checked" : ""; 4355 $action = ($form->{deselect}) ? "deselect_all" : "select_all"; 4356 $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>|; 4357 4358 $column_data{reference} = "<th><a class=listheading href=$href&sort=reference>".$locale->text('Reference').qq"</a></th>"; 4359 $column_data{id} = "<th class=listheading>".$locale->text('ID')."</th>"; 4360 $column_data{description} = "<th><a class=listheading href=$href&sort=description>".$locale->text('Description')."</th>"; 4361 $column_data{name} = "<th nowrap><a class=listheading href=$href&sort=name>".$locale->text('Company Name')."</th>"; 4362 $column_data{vcnumber} = "<th nowrap><a class=listheading href=$href&sort=vcnumber>".$locale->text('Company Number')."</th>"; 4363 $column_data{nextdate} = "<th><a class=listheading href=$href&sort=nextdate>".$locale->text('Next')."</a></th>"; 4364 $column_data{enddate} = "<th><a class=listheading href=$href&sort=enddate>".$locale->text('Ends')."</a></th>"; 4365 $column_data{amount} = "<th class=listheading>".$locale->text('Amount')."</th>"; 4366 $column_data{curr} = "<th class=listheading> </th>"; 4367 $column_data{repeat} = "<th class=listheading>".$locale->text('Every')."</th>"; 4368 $column_data{howmany} = "<th class=listheading>".$locale->text('Times')."</th>"; 4369 $column_data{recurringemail} = "<th class=listheading nowrap>".$locale->text('E-mail')."</th>"; 4370 $column_data{recurringprint} = "<th class=listheading>".$locale->text('Print')."</th>"; 4371 4372 if ($form->{direction} eq 'ASC') { 4373 $callback .= "&direction=DESC"; 4374 } else { 4375 $callback .= "&direction=ASC"; 4376 } 4377 $callback = $form->escape("$callback&sort=$form->{sort}"); 4378 4379 $form->helpref("recurring_transactions", $myconfig{countrycode}); 4380 4381 # create the logo screen 4382 $form->header; 4383 4384 &calendar; 4385 4386 &check_all(qw(allbox ndx_)); 4387 4388print qq| 4389<body> 4390 4391<form method="post" name="main" action="$form->{script}"> 4392 4393<table width=100%> 4394 <tr> 4395 <th class=listtop>$form->{helpref}$form->{title}</a></th> 4396 </tr> 4397 <tr height="5"></tr> 4398 <tr> 4399 <td> 4400 <table width=100%> 4401 <tr class=listheading> 4402|; 4403 4404 for (@column_index) { print "\n$column_data{$_}" } 4405 4406 print qq| 4407 </tr> 4408|; 4409 4410 my $i = 1; 4411 my $j; 4412 my $k; 4413 my $colspan = $#column_index + 1; 4414 my %tr = ( ar => $locale->text('AR'), 4415 ap => $locale->text('AP'), 4416 gl => $locale->text('GL'), 4417 so => $locale->text('Sales Orders'), 4418 po => $locale->text('Purchase Orders'), 4419 ); 4420 my %f = &formnames; 4421 my @f; 4422 my $ref; 4423 my $unit; 4424 my $repeat; 4425 my $reference; 4426 my $module; 4427 my $type; 4428 4429 foreach my $transaction (sort keys %{ $form->{transactions} }) { 4430 print qq| 4431 <tr> 4432 <th class=listheading colspan=$colspan>$tr{$transaction}</th> 4433 </tr> 4434|; 4435 4436 foreach $ref (@{ $form->{transactions}{$transaction} }) { 4437 4438 for (@column_index) { $column_data{$_} = "<td>$ref->{$_}</td>" } 4439 4440 for (qw(nextdate enddate)) { $column_data{$_} = "<td nowrap>$ref->{$_}</td>" } 4441 4442 if ($ref->{repeat} > 1) { 4443 $unit = $locale->text(ucfirst $ref->{unit}); 4444 $repeat = "$ref->{repeat} $unit"; 4445 } else { 4446 chop $ref->{unit}; 4447 $unit = $locale->text(ucfirst $ref->{unit}); 4448 $repeat = $unit; 4449 } 4450 4451 $column_data{ndx} = qq|<td></td>|; 4452 4453 if (!$ref->{expired}) { 4454 $k++; 4455 $checked = ""; 4456 if ($ref->{overdue} <= 0) { 4457 $checked = "checked"; 4458 } 4459 if (exists $form->{deselect}) { 4460 $checked = ($form->{deselect}) ? "checked" : ""; 4461 } 4462 $column_data{ndx} = qq|<td><input name="ndx_$k" class=checkbox type=checkbox value=$ref->{id} $checked></td>|; 4463 $column_data{nextdate} = qq|<td nowrap><input name="nextdate_$k" size=11 value="$ref->{nextdate}" title="$myconfig{dateformat}">|.&js_calendar("main", "nextdate_$k").qq|</td>|; 4464 } 4465 4466 $reference = ($ref->{reference}) ? $ref->{reference} : $locale->text('Next Number'); 4467 $column_data{reference} = qq|<td nowrap><a href=$form->{script}?action=edit_recurring&id=$ref->{id}&vc=$ref->{vc}&path=$form->{path}&login=$form->{login}&module=$ref->{module}&invoice=$ref->{invoice}&transaction=$ref->{transaction}&recurringnextdate=$ref->{nextdate}&callback=$callback>$reference</a></td>|; 4468 4469 $module = "$ref->{module}.pl"; 4470 $type = ""; 4471 4472 if ($ref->{module} eq 'ar') { 4473 $module = "is.pl" if $ref->{invoice}; 4474 $ref->{amount} /= $ref->{exchangerate}; 4475 $column_data{name} = qq|<td><a href=ct.pl?path=$form->{path}&login=$form->{login}&action=edit&id=$ref->{name_id}&db=$ref->{vc}&callback=$callback>$ref->{name}</a></td>|; 4476 } 4477 if ($ref->{module} eq 'ap') { 4478 $module = "ir.pl" if $ref->{invoice}; 4479 $ref->{amount} /= $ref->{exchangerate}; 4480 $column_data{name} = qq|<td><a href=ct.pl?path=$form->{path}&login=$form->{login}&action=edit&id=$ref->{name_id}&db=$ref->{vc}&callback=$callback>$ref->{name}</a></td>|; 4481 } 4482 if ($ref->{module} eq 'oe') { 4483 $type = ($ref->{vc} eq 'customer') ? "sales_order" : "purchase_order"; 4484 $column_data{name} = qq|<td><a href=ct.pl?path=$form->{path}&login=$form->{login}&action=edit&id=$ref->{name_id}&db=$ref->{vc}&callback=$callback>$ref->{name}</a></td>|; 4485 } 4486 4487 $column_data{vcnumber} = qq|<td>$ref->{vcnumber} </td>|; 4488 $column_data{id} = qq|<td><a href=$module?action=edit&id=$ref->{id}&vc=$ref->{vc}&path=$form->{path}&login=$form->{login}&type=$type&callback=$callback>$ref->{id}</a></td>|; 4489 4490 $column_data{repeat} = "<td align=right nowrap>$repeat</td>"; 4491 $column_data{howmany} = "<td align=right nowrap>".$form->format_amount(\%myconfig, $ref->{howmany})."</td>"; 4492 $column_data{amount} = "<td align=right nowrap>".$form->format_amount(\%myconfig, $ref->{amount}, $form->{precision})."</td>"; 4493 4494 $column_data{recurringemail} = "<td nowrap>"; 4495 @f = split /:/, $ref->{recurringemail}; 4496 for (0 .. $#f) { $column_data{recurringemail} .= $locale->text($f{$f[$_]})."<br>" } 4497 $column_data{recurringemail} .= "</td>"; 4498 4499 $column_data{recurringprint} = "<td nowrap>"; 4500 @f = split /:/, $ref->{recurringprint}; 4501 for (0 .. $#f) { $column_data{recurringprint} .= $locale->text($f{$f[$_]})."<br>" } 4502 $column_data{recurringprint} .= "</td>"; 4503 4504 $j++; $j %= 2; 4505 print qq| 4506 <tr class=listrow$j> 4507|; 4508 4509 for (@column_index) { print "\n$column_data{$_}" } 4510 4511 print qq| 4512 </tr> 4513|; 4514 } 4515 } 4516 4517 print qq| 4518 </tr> 4519 </table> 4520 </td> 4521 </tr> 4522 <tr> 4523 <td><hr size=3 noshade></td> 4524 </tr> 4525</table> 4526|; 4527 4528 $form->{lastndx} = $k; 4529 4530 $form->hide_form(qw(lastndx path login allbox)); 4531 4532 %button = ('Select all' => { ndx => 2, key => 'A', value => $locale->text('Select all') }, 4533 'Deselect all' => { ndx => 3, key => 'A', value => $locale->text('Deselect all') }, 4534 'Process Transactions' => { ndx => 4, key => 'P', value => $locale->text('Process Transactions') } 4535 ); 4536 4537 if ($form->{deselect}) { 4538 delete $button{'Select all'}; 4539 } else { 4540 delete $button{'Deselect all'}; 4541 } 4542 4543 $form->print_button(\%button); 4544 4545 if ($form->{menubar}) { 4546 require "$form->{path}/menu.pl"; 4547 &menubar; 4548 } 4549 4550 print qq| 4551</form> 4552 4553</body> 4554</html> 4555|; 4556 4557} 4558 4559 4560sub select_all { 4561 4562 for (1 .. $form->{rowcount}) { $form->{"ndx_$_"} = 1 } 4563 $form->{allbox} = 1; 4564 $form->{deselect} = 1; 4565 &recurring_transactions; 4566 4567} 4568 4569 4570sub deselect_all { 4571 4572 for (1 .. $form->{rowcount}) { $form->{"ndx_$_"} = "" } 4573 $form->{allbox} = ""; 4574 $form->{deselect} = 0; 4575 &recurring_transactions; 4576 4577} 4578 4579 4580sub edit_recurring { 4581 4582 %links = ( ar => 'create_links', 4583 ap => 'create_links', 4584 gl => 'create_links', 4585 is => 'invoice_links', 4586 ir => 'invoice_links', 4587 oe => 'order_links', 4588 ); 4589 %prepare = ( is => 'prepare_invoice', 4590 ir => 'prepare_invoice', 4591 oe => 'prepare_order', 4592 ); 4593 4594 $form->{type} = "transaction"; 4595 4596 if ($form->{module} eq 'ar') { 4597 if ($form->{invoice}) { 4598 $form->{type} = "invoice"; 4599 $form->{module} = "is"; 4600 } 4601 } 4602 if ($form->{module} eq 'ap') { 4603 if ($form->{invoice}) { 4604 $form->{type} = "invoice"; 4605 $form->{module} = "ir"; 4606 } 4607 } 4608 4609 if ($form->{module} eq 'oe') { 4610 %tr = ( so => sales_order, 4611 po => purchase_order, 4612 ); 4613 4614 $form->{type} = $tr{$form->{transaction}}; 4615 } 4616 4617 $form->{script} = "$form->{module}.pl"; 4618 do "$form->{path}/$form->{script}"; 4619 4620 &{ $links{$form->{module}} }; 4621 4622 # return if transaction doesn't exist 4623 $form->redirect unless $form->{recurring}; 4624 4625 if ($prepare{$form->{module}}) { 4626 &{ $prepare{$form->{module}} }; 4627 } 4628 4629 $form->{selectformat} = qq|html--|.$locale->text('html').qq| 4630xml--|.$locale->text('XML').qq| 4631txt--|.$locale->text('Text'); 4632 4633 if ($latex) { 4634 $form->{selectformat} .= qq| 4635ps--|.$locale->text('Postscript').qq| 4636pdf--|.$locale->text('PDF'); 4637 } 4638 4639 &schedule; 4640 4641} 4642 4643 4644sub process_transactions { 4645 4646 # save variables 4647 my $pt = new Form; 4648 for (keys %$form) { $pt->{$_} = $form->{$_} } 4649 4650 my $defaultprinter; 4651 4652 $myconfig{vclimit} = 0; 4653 my %f = &formnames; 4654 my $invfld; 4655 my $ok; 4656 my $ordfld; 4657 my $flabel; 4658 my $ordnumber; 4659 my $header; 4660 4661 for (my $i = 1; $i <= $pt->{lastndx}; $i++) { 4662 if ($pt->{"ndx_$i"}) { 4663 my $id = $pt->{"ndx_$i"}; 4664 4665 # process transaction 4666 AM->recurring_details(\%myconfig, \%$pt, $id); 4667 4668 $pt->{nextdate} = $pt->{"nextdate_$i"} if $pt->{"nextdate_$i"}; 4669 4670 $header = $form->{header}; 4671 4672 # reset $form 4673 for (keys %$form) { delete $form->{$_}; } 4674 for (qw(login path stylesheet timeout precision)) { $form->{$_} = $pt->{$_}; } 4675 $form->{id} = $id; 4676 $form->{header} = $header; 4677 4678 # post, print, email 4679 if ($pt->{arid} || $pt->{apid} || $pt->{oeid}) { 4680 if ($pt->{arid} || $pt->{apid}) { 4681 if ($pt->{arid}) { 4682 $form->{script} = ($pt->{invoice}) ? "is.pl" : "ar.pl"; 4683 $form->{ARAP} = "AR"; 4684 $form->{module} = "ar"; 4685 $invfld = "sinumber"; 4686 } else { 4687 $form->{script} = ($pt->{invoice}) ? "ir.pl" : "ap.pl"; 4688 $form->{ARAP} = "AP"; 4689 $form->{module} = "ap"; 4690 $invfld = "vinumber"; 4691 } 4692 do "$form->{path}/$form->{script}"; 4693 4694 if ($pt->{invoice}) { 4695 &invoice_links; 4696 &prepare_invoice; 4697 4698 for (keys %$form) { $form->{$_} = $form->unquote($form->{$_}) } 4699 4700 } else { 4701 &create_links; 4702 4703 $form->{type} = "transaction"; 4704 for (1 .. $form->{rowcount} - 1) { $form->{"amount_$_"} = $form->format_amount(\%myconfig, $form->{"amount_$_"}, $form->{precision}) } 4705 for (split / /, $form->{taxaccounts}) { $form->{"tax_$_"} = $form->format_amount(\%myconfig, $form->{"tax_$_"}, $form->{precision}) } 4706 } 4707 4708 for (1 .. $form->{paidaccounts}) { $form->{"paid_$_"} = $form->format_amount(\%myconfig, $form->{"paid_$_"}, $form->{precision}) } 4709 $form->{discount_paid} = $form->format_amount(\%myconfig, $form->{discount_paid}, $form->{precision}); 4710 4711 $defaultprinter = $form->{all_printer}[0]->{printer}; 4712 4713 delete $form->{"$form->{ARAP}_links"}; 4714 for (qw(acc_trans invoice_details)) { delete $form->{$_} } 4715 for (qw(department employee language month partsgroup project years printer)) { delete $form->{"all_$_"} } 4716 4717 $form->{invnumber} = $pt->{reference}; 4718 $form->{description} = $pt->{description}; 4719 $form->{transdate} = $pt->{nextdate}; 4720 4721 # exchangerate 4722 if ($form->{currency} ne $form->{defaultcurrency}) { 4723 $exchangerate = $form->get_exchangerate(\%myconfig, undef, $form->{currency}, $form->{transdate}); 4724 $form->{exchangerate} = $form->format_amount(\%myconfig, $exchangerate) if $exchangerate; 4725 } 4726 4727 # tax accounts 4728 $form->all_taxaccounts(\%myconfig, undef, $form->{transdate}); 4729 4730 # calculate duedate 4731 $form->{duedate} = $form->add_date(\%myconfig, $form->{transdate}, $pt->{overdue}, "days"); 4732 4733 if ($pt->{payment}) { 4734 # calculate date paid 4735 for ($j = 1; $j <= $form->{paidaccounts}; $j++) { 4736 $form->{"datepaid_$j"} = $form->add_date(\%myconfig, $form->{transdate}, $pt->{paid}, "days"); 4737 ($form->{"$form->{ARAP}_paid_$j"}) = split /--/, $form->{"$form->{ARAP}_paid_$j"}; 4738 delete $form->{"cleared_$j"}; 4739 4740 if ($form->{currency} ne $form->{defaultcurrency}) { 4741 $form->{"exchangerate_$j"} = $form->{exchangerate}; 4742 $exchangerate = $form->get_exchangerate(\%myconfig, undef, $form->{currency}, $form->{"datepaid_$j"}); 4743 $form->{"exchangerate_$j"} = $form->format_amount(\%myconfig, $exchangerate) if $exchangerate; 4744 } 4745 } 4746 } else { 4747 delete $form->{"paid_1"}; 4748 $form->{"$form->{ARAP}_paid_1"} = $form->{payment_accno}; 4749 $form->{"paymentmethod_1"} = $form->{payment_method}; 4750 $form->{paidaccounts} = 1; 4751 } 4752 4753 for (qw(id recurring printed emailed queued)) { delete $form->{$_} } 4754 4755 ($form->{$form->{ARAP}}) = split /--/, $form->{$form->{ARAP}}; 4756 4757 $form->{invnumber} = $form->update_defaults(\%myconfig, "$invfld") unless $form->{invnumber}; 4758 $form->{reference} = $form->{invnumber}; 4759 for (qw(invnumber reference description)) { $form->{$_} = $form->unquote($form->{$_}) } 4760 4761 if ($pt->{invoice}) { 4762 if ($pt->{arid}) { 4763 $form->info("\n".$locale->text('Posting')." ".$locale->text('Sales Invoice')." $form->{invnumber} ... "); 4764 $ok = IS->post_invoice(\%myconfig, \%$form); 4765 } else { 4766 $form->info("\n".$locale->text('Posting')." ".$locale->text('Vendor Invoice')." $form->{invnumber} ... "); 4767 $ok = IR->post_invoice(\%myconfig, \%$form); 4768 } 4769 } else { 4770 $form->info("\n".$locale->text('Posting')." ".$locale->text('Transaction')." $form->{invnumber} ... "); 4771 $ok = AA->post_transaction(\%myconfig, \%$form); 4772 } 4773 if ($ok) { 4774 $form->info($locale->text('ok')); 4775 } else { 4776 $form->info($locale->text('failed')); 4777 } 4778 4779 # print form 4780 if ($latex && $ok) { 4781 $ok = &print_recurring(\%$pt, $defaultprinter); 4782 } 4783 4784 &email_recurring(\%$pt) if $ok; 4785 4786 } else { 4787 4788 # order 4789 $form->{script} = "oe.pl"; 4790 $form->{module} = "oe"; 4791 4792 $ordnumber = "ordnumber"; 4793 if ($pt->{customer_id}) { 4794 $form->{vc} = "customer"; 4795 $form->{type} = "sales_order"; 4796 $ordfld = "sonumber"; 4797 $flabel = $locale->text('Sales Order'); 4798 } else { 4799 $form->{vc} = "vendor"; 4800 $form->{type} = "purchase_order"; 4801 $ordfld = "ponumber"; 4802 $flabel = $locale->text('Purchase Order'); 4803 } 4804 require "$form->{path}/$form->{script}"; 4805 4806 &order_links; 4807 &prepare_order; 4808 4809 $defaultprinter = $form->{all_printer}[0]->{printer}; 4810 4811 for (keys %$form) { $form->{$_} = $form->unquote($form->{$_}) } 4812 4813 $form->{$ordnumber} = $pt->{reference}; 4814 $form->{description} = $pt->{description}; 4815 $form->{transdate} = $pt->{nextdate}; 4816 4817 # exchangerate 4818 if ($form->{currency} ne $form->{defaultcurrency}) { 4819 $exchangerate = $form->get_exchangerate(\%myconfig, undef, $form->{currency}, $form->{transdate}); 4820 $form->{exchangerate} = $form->format_amount(\%myconfig, $exchangerate) if $exchangerate; 4821 } 4822 4823 # calculate reqdate 4824 $form->{reqdate} = $form->add_date(\%myconfig, $form->{transdate}, $pt->{req}, "days") if $form->{reqdate}; 4825 4826 for (qw(id recurring printed emailed queued)) { delete $form->{$_} } 4827 for (1 .. $form->{rowcount}) { delete $form->{"orderitems_id_$_"} } 4828 4829 $form->{$ordnumber} = $form->update_defaults(\%myconfig, "$ordfld") unless $form->{$ordnumber}; 4830 $form->{reference} = $form->{$ordnumber}; 4831 for ("$ordnumber", "reference", "description") { $form->{$_} = $form->unquote($form->{$_}) } 4832 $form->{closed} = 0; 4833 4834 $form->info("\n".$locale->text('Saving')." ".$flabel." $form->{$ordnumber} ... "); 4835 if ($ok = OE->save(\%myconfig, \%$form)) { 4836 $form->info($locale->text('ok')); 4837 } else { 4838 $form->info($locale->text('failed')); 4839 } 4840 4841 # print form 4842 if ($latex && $ok) { 4843 &print_recurring(\%$pt, $defaultprinter); 4844 } 4845 4846 &email_recurring(\%$pt); 4847 4848 } 4849 4850 } else { 4851 # GL transaction 4852 GL->transaction(\%myconfig, \%$form); 4853 4854 $form->{reference} = $pt->{reference}; 4855 $form->{description} = $pt->{description}; 4856 $form->{transdate} = $pt->{nextdate}; 4857 4858 $form->{defaultcurrency} = substr($form->{currencies},0,3); 4859 4860 # exchangerate 4861 if ($form->{currency} ne $form->{defaultcurrency}) { 4862 $exchangerate = $form->get_exchangerate(\%myconfig, undef, $form->{currency}, $form->{transdate}); 4863 $form->{exchangerate} = $form->format_amount(\%myconfig, $exchangerate) if $exchangerate; 4864 } 4865 4866 $j = 1; 4867 foreach $ref (@{ $form->{GL} }) { 4868 $form->{"accno_$j"} = "$ref->{accno}--$ref->{description}"; 4869 4870 $form->{"projectnumber_$j"} = "$ref->{projectnumber}--$ref->{project_id}" if $ref->{project_id}; 4871 $form->{"fx_transaction_$j"} = $ref->{fx_transaction}; 4872 4873 if ($ref->{amount} < 0) { 4874 $form->{"debit_$j"} = $ref->{amount} * -1; 4875 } else { 4876 $form->{"credit_$j"} = $ref->{amount}; 4877 } 4878 4879 $j++; 4880 } 4881 4882 $form->{rowcount} = $j; 4883 4884 for (qw(id recurring)) { delete $form->{$_} } 4885 $form->info("\n".$locale->text('Posting')." ".$locale->text('GL Transaction')." $form->{reference} ... "); 4886 if ($ok = GL->post_transaction(\%myconfig, \%$form)) { 4887 $form->info($locale->text('ok')); 4888 } else { 4889 $form->info($locale->text('failed')); 4890 } 4891 } 4892 4893 AM->update_recurring(\%myconfig, \%$pt, $id) if $ok; 4894 4895 } 4896 } 4897 4898 $form->{callback} = "am.pl?action=recurring_transactions&path=$form->{path}&login=$form->{login}&header=$form->{header}"; 4899 $form->redirect; 4900 4901} 4902 4903 4904sub print_recurring { 4905 my ($pt, $defaultprinter) = @_; 4906 4907 my %f = &formnames; 4908 my @f; 4909 my $ok = 1; 4910 my $media; 4911 my @a; 4912 4913 if ($pt->{recurringprint}) { 4914 @f = split /:/, $pt->{recurringprint}; 4915 for ($j = 0; $j <= $#f; $j += 3) { 4916 $media = $f[$j+2]; 4917 $media ||= $myconfig->{printer}; 4918 $media ||= $defaultprinter; 4919 4920 $form->info("\n".$locale->text('Printing')." ".$locale->text($f{$f[$j]})." $form->{reference} ... "); 4921 4922 @a = ("perl", "$form->{script}", "action=reprint&module=$form->{module}&type=$form->{type}&login=$form->{login}&path=$form->{path}&id=$form->{id}&formname=$f[$j]&format=$f[$j+1]&media=$media&vc=$form->{vc}&ARAP=$form->{ARAP}"); 4923 4924 $ok = !(system(@a)); 4925 4926 if ($ok) { 4927 $form->info($locale->text('ok')); 4928 } else { 4929 $form->info($locale->text('failed')); 4930 last; 4931 } 4932 } 4933 } 4934 4935 $ok; 4936 4937} 4938 4939 4940sub email_recurring { 4941 my ($pt) = @_; 4942 4943 my %f = &formnames; 4944 my $ok = 1; 4945 4946 if ($pt->{recurringemail}) { 4947 4948 my @f = split /:/, $pt->{recurringemail}; 4949 for (my $j = 0; $j <= $#f; $j += 2) { 4950 4951 $form->info("\n".$locale->text('Sending')." ".$locale->text($f{$f[$j]})." $form->{reference} ... "); 4952 4953 # no email, bail out 4954 if (!$form->{email}) { 4955 $form->info($locale->text('E-mail address missing!')); 4956 last; 4957 } 4958 4959 $message = $form->escape($pt->{message},1); 4960 4961 @a = ("perl", "$form->{script}", "action=reprint&module=$form->{module}&type=$form->{type}&login=$form->{login}&path=$form->{path}&id=$form->{id}&formname=$f[$j]&format=$f[$j+1]&media=email&vc=$form->{vc}&ARAP=$form->{ARAP}&message=$message"); 4962 4963 $ok = !(system(@a)); 4964 4965 if ($ok) { 4966 $form->info($locale->text('ok')); 4967 } else { 4968 $form->info($locale->text('failed')); 4969 last; 4970 } 4971 } 4972 } 4973 4974 $ok; 4975 4976} 4977 4978 4979 4980sub formnames { 4981 4982# $locale->text('Transaction') 4983# $locale->text('Invoice') 4984# $locale->text('Credit Invoice') 4985# $locale->text('Credit Note') 4986# $locale->text('Debit Invoice') 4987# $locale->text('Debit Note') 4988# $locale->text('Packing List') 4989# $locale->text('Pick List') 4990# $locale->text('Sales Order') 4991# $locale->text('Work Order') 4992# $locale->text('Purchase Order') 4993# $locale->text('Bin List') 4994# $locale->text('Barcode') 4995# $locale->text('Remittance Voucher') 4996 4997 return ( transaction => 'Transaction', 4998 invoice => 'Invoice', 4999 credit_invoice => 'Credit Invoice', 5000 credit_note => 'Credit Note', 5001 debit_invoice => 'Debit Invoice', 5002 debit_note => 'Debit Note', 5003 packing_list => 'Packing List', 5004 pick_list => 'Pick List', 5005 sales_order => 'Sales Order', 5006 work_order => 'Work Order', 5007 purchase_order => 'Purchase Order', 5008 bin_list => 'Bin List', 5009 barcode => 'Barcode', 5010 remittance_voucher => 'Remittance Voucher', 5011 ); 5012 5013} 5014 5015 5016sub continue { &{ $form->{nextsub} } } 5017sub yes { &{ $form->{nextsub} } } 5018 5019 5020sub clear_semaphores { 5021 5022 $form->{title} = $locale->text('Confirm!'); 5023 5024 $form->header; 5025 5026 print qq| 5027<body> 5028 5029<form method=post action=$form->{script}> 5030|; 5031 5032 $form->{nextsub} = "remove_locks"; 5033 $form->hide_form; 5034 5035 print qq| 5036<h2 class=confirm>$form->{title}</h2> 5037 5038<h4>|.$locale->text('Remove semaphores?').qq|</h4> 5039 5040<input name=action class=submit type=submit value="|.$locale->text('Yes').qq|"> 5041</form> 5042 5043</body> 5044</html> 5045|; 5046 5047} 5048 5049 5050sub remove_locks { 5051 5052 AM->remove_locks(\%myconfig, \%$form, $userspath); 5053 5054 $form->info($locale->text('Locks removed!')); 5055 5056} 5057 5058 5059sub lock_dataset { 5060 5061 $form->{title} = $locale->text('Lock Dataset'); 5062 $form->helpref("lock_dataset", $myconfig{countrycode}); 5063 5064 $form->error($locale->text('Must be logged in as admin!')) unless $form->{admin}; 5065 5066 if (-f "$userspath/$myconfig{dbname}.LCK") { 5067 open FH, "$userspath/$myconfig{dbname}.LCK"; 5068 $form->{msg} = <FH>; 5069 close(FH); 5070 } 5071 5072 $form->header; 5073 5074 $form->{nextsub} = "do_lock_dataset"; 5075 $form->{action} = "continue"; 5076 5077print qq| 5078<body> 5079 5080<form method=post action=$form->{script}> 5081 5082<table width=100%> 5083 <tr> 5084 <th class=listtop>$form->{helpref}$form->{title}</a></th> 5085 </tr> 5086 <tr height="5"></tr> 5087 <tr> 5088 <td> 5089 <table> 5090 <tr> 5091 <th align="right">|.$locale->text('Lock Message').qq|</th> 5092 <td> 5093 <input name=msg value="$form->{msg}" size=60> 5094 </td> 5095 </tr> 5096 </table> 5097 </td> 5098 </tr> 5099 <tr> 5100 <td><hr size=3 noshade></td> 5101 </tr> 5102 5103</table> 5104|; 5105 5106 $form->hide_form(qw(nextsub login path)); 5107 5108 print qq| 5109<input name=action class=submit type=submit value="|.$locale->text('Continue').qq|"> 5110</form> 5111 5112</body> 5113</html> 5114|; 5115 5116} 5117 5118 5119sub do_lock_dataset { 5120 5121 open(FH, ">$userspath/$myconfig{dbname}.LCK") or $form->error("$userspath/$myconfig{dbname}.LCK : $!"); 5122 5123 if ($form->{msg}) { 5124 print FH $form->{msg}; 5125 } 5126 close(FH); 5127 5128 $form->redirect($locale->text('Dataset locked!')); 5129 5130} 5131 5132 5133sub unlock_dataset { 5134 5135 $form->error($locale->text('Must be logged in as admin!')) unless $form->{admin}; 5136 5137 $form->{title} = $locale->text('Confirm!'); 5138 5139 $form->header; 5140 5141 print qq| 5142<body> 5143 5144<form method=post action=$form->{script}> 5145|; 5146 5147 $form->{nextsub} = "do_unlock_dataset"; 5148 $form->hide_form; 5149 5150 print qq| 5151<h2 class=confirm>$form->{title}</h2> 5152 5153<h4>|.$locale->text('Unlock dataset?').qq|</h4> 5154 5155<input name=action class=submit type=submit value="|.$locale->text('Yes').qq|"> 5156</form> 5157 5158</body> 5159</html> 5160|; 5161 5162} 5163 5164 5165sub do_unlock_dataset { 5166 5167 if (-f "$userspath/$myconfig{dbname}.LCK") { 5168 unlink "$userspath/$myconfig{dbname}.LCK"; 5169 } 5170 5171 $form->info($locale->text('Dataset lock removed!')."\n"); 5172 5173} 5174 5175 5176sub bank_accounts { 5177 5178 AM->bank_accounts(\%myconfig, \%$form); 5179 5180 $form->{title} = $locale->text('Bank Accounts') . " / $form->{company}"; 5181 5182 $callback = "$form->{script}?action=bank_accounts"; 5183 for (qw(path login)) { $callback .= "&$_=$form->{$_}" } 5184 5185 @column_index = qw(accno description name iban bic membernumber clearingnumber rvc dcn closed); 5186 5187 $callback = $form->escape($callback); 5188 5189 $column_header{accno} = qq|<th class=listheading>|.$locale->text('Account').qq|</th>|; 5190 $column_header{description} = qq|<th class=listheading>|.$locale->text('Description').qq|</th>|; 5191 $column_header{name} = qq|<th class=listheading>|.$locale->text('Bank').qq|</th>|; 5192 $column_header{iban} = qq|<th class=listheading>|.$locale->text('IBAN').qq|</th>|; 5193 $column_header{bic} = qq|<th class=listheading>|.$locale->text('BIC').qq|</th>|; 5194 $column_header{membernumber} = qq|<th class=listheading>|.$locale->text('Member No.').qq|</th>|; 5195 $column_header{clearingnumber} = qq|<th class=listheading>|.$locale->text('Clearing No.').qq|</th>|; 5196 $column_header{rvc} = qq|<th class=listheading>|.$locale->text('RVC').qq|</th>|; 5197 $column_header{dcn} = qq|<th class=listheading>|.$locale->text('DCN').qq|</th>|; 5198 $column_header{closed} = qq|<th class=listheading>|.$locale->text('Closed').qq|</th>|; 5199 5200 $form->helpref("bank_accounts", $myconfig{countrycode}); 5201 5202 $form->header; 5203 5204 print qq| 5205<body> 5206 5207<table width=100%> 5208 <tr> 5209 <th class=listtop>$form->{helpref}$form->{title}</a></th> 5210 </tr> 5211 <tr height="5"></tr> 5212 <tr> 5213 <td> 5214 <table width=100%> 5215 <tr class=listheading> 5216|; 5217 5218 for (@column_index) { print "$column_header{$_}\n" } 5219 5220 print qq| 5221 </tr> 5222|; 5223 5224 foreach $ref (@{ $form->{ALL} }) { 5225 5226 for (qw(name description)) { $column_data{$_} = "<td nowrap>$ref->{$_} </td>" } 5227 for (qw(membernumber clearingnumber rvc dcn)) { $column_data{$_} = "<td>$ref->{$_} </td>" } 5228 for (qw(iban bic)) { $column_data{$_} = "<td nowrap>$ref->{$_} </td>" } 5229 $column_data{accno} = "<td><a href=$form->{script}?action=edit_bank&id=$ref->{id}&path=$form->{path}&login=$form->{login}&callback=$callback>$ref->{accno}</td>"; 5230 $closed = ($ref->{closed}) ? "*" : " "; 5231 $column_data{closed} = "<td>$closed</td>"; 5232 5233 $j++; $j %= 2; 5234 print " 5235 <tr class=listrow$j> 5236"; 5237 5238 for (@column_index) { print "$column_data{$_}\n" } 5239 5240 print qq| 5241 </tr> 5242|; 5243 5244 } 5245 5246 print qq| 5247 </table> 5248 </td> 5249 </tr> 5250 <tr> 5251 <td><hr size=3 noshade></td> 5252 </tr> 5253</table> 5254 5255</body> 5256</html> 5257|; 5258 5259} 5260 5261 5262sub edit_bank { 5263 5264 AM->get_bank(\%myconfig, \%$form); 5265 5266 &bank_header; 5267 &bank_footer; 5268 5269} 5270 5271 5272sub bank_header { 5273 5274 $form->{title} = $locale->text('Bank Account Details') . " / $form->{company}"; 5275 5276 $form->helpref("bank", $myconfig{countrycode}); 5277 5278 $checked{closed} = ($form->{closed}) ? "checked" : ""; 5279 5280 $form->header; 5281 5282 print qq| 5283<body> 5284 5285<form method=post action=$form->{script}> 5286 5287<table width=100%> 5288 <tr> 5289 <th class=listtop>$form->{helpref}$form->{title}</a></th> 5290 </tr> 5291 5292 <tr> 5293 <td> 5294 <table> 5295 <tr> 5296 <th align=right>|.$locale->text('Bank Account').qq|</th> 5297 <td>$form->{account}</td> 5298 <td><input name=closed class=checkbox type=checkbox value=1 $checked{closed}> |.$locale->text('Closed').qq|</td> 5299 </tr> 5300 <tr> 5301 <th align=right nowrap>|.$locale->text('Bank').qq|</th> 5302 <td><input name=name size=32 maxlength=64 value="|.$form->quote($form->{name}).qq|"></td> 5303 </tr> 5304 <tr> 5305 <th align=right>|.$locale->text('BIC').qq|</th> 5306 <td><input name=bic size=11 maxlength=11 value="$form->{bic}"></td> 5307 </tr> 5308 <tr> 5309 <th align=right>|.$locale->text('IBAN').qq|</th> 5310 <td><input name=iban size=24 maxlength=34 value="$form->{iban}"></td> 5311 </tr> 5312 <tr> 5313 <th align=right nowrap>|.$locale->text('Address').qq|</th> 5314 <td><input name=address1 size=32 maxlength=32 value="|.$form->quote($form->{address1}).qq|"></td> 5315 </tr> 5316 <tr> 5317 <th></th> 5318 <td><input name=address2 size=32 maxlength=32 value="|.$form->quote($form->{address2}).qq|"></td> 5319 </tr> 5320 <tr> 5321 <th align=right nowrap>|.$locale->text('City').qq|</th> 5322 <td><input name=city size=32 maxlength=32 value="|.$form->quote($form->{city}).qq|"></td> 5323 </tr> 5324 <tr> 5325 <th align=right nowrap>|.$locale->text('State/Province').qq|</th> 5326 <td><input name=state size=32 maxlength=32 value="|.$form->quote($form->{state}).qq|"></td> 5327 </tr> 5328 <tr> 5329 <th align=right nowrap>|.$locale->text('Zip/Postal Code').qq|</th> 5330 <td><input name=zipcode size=11 maxlength=10 value="|.$form->quote($form->{zipcode}).qq|"></td> 5331 </tr> 5332 <tr> 5333 <th align=right nowrap>|.$locale->text('Country').qq|</th> 5334 <td><input name=country size=32 maxlength=32 value="|.$form->quote($form->{country}).qq|"></td> 5335 </tr> 5336 <tr> 5337 <th align=right>|.$locale->text('Member No.').qq|</th> 5338 <td><input name=membernumber value="$form->{membernumber}"></td> 5339 </tr> 5340 <tr> 5341 <th align=right>|.$locale->text('Clearing No.').qq|</th> 5342 <td><input name=clearingnumber value="$form->{clearingnumber}"></td> 5343 </tr> 5344 <tr> 5345 <th align=right>|.$locale->text('RVC').qq|</th> 5346 <td><input name=rvc size=80 value="$form->{rvc}"></td> 5347 </tr> 5348 <tr> 5349 <th align=right>|.$locale->text('DCN').qq|</th> 5350 <td><input name=dcn size=60 value="$form->{dcn}"></td> 5351 </tr> 5352 <tr> 5353 <th align=right>|.$locale->text('Check No.').qq|</th> 5354 <td><input name="check_$form->{accno}" value="$form->{"check_$form->{accno}"}"></td> 5355 </tr> 5356 <tr> 5357 <th align=right>|.$locale->text('Receipt No.').qq|</th> 5358 <td><input name="receipt_$form->{accno}" value="$form->{"receipt_$form->{accno}"}"></td> 5359 </tr> 5360 </table> 5361 </td> 5362 </tr> 5363 <tr> 5364 <td><hr size=3 noshade></td> 5365 </tr> 5366</table> 5367 5368|; 5369 5370} 5371 5372 5373sub bank_footer { 5374 5375 %button = ( 5376 'Save' => { ndx => 2, key => 'S', value => $locale->text('Save') } 5377 ); 5378 5379 $form->{type} = "bank"; 5380 5381 $form->hide_form(qw(id type login path account callback)); 5382 5383 $form->print_button(\%button); 5384 5385 if ($form->{menubar}) { 5386 require "$form->{path}/menu.pl"; 5387 &menubar; 5388 } 5389 5390 print qq| 5391 5392 </form> 5393 5394</body> 5395</html> 5396|; 5397 5398} 5399 5400 5401sub save_bank { 5402 5403 if (!AM->save_bank(\%myconfig, \%$form)) { 5404 $form->error($locale->text('Failed to save Bank!')); 5405 } 5406 5407 $form->redirect($locale->text('Bank saved!')); 5408 5409} 5410 5411 5412sub search_exchangerates { 5413 5414 AM->exchangerates(\%myconfig, $form); 5415 5416 $form->{title} = $locale->text('Exchange Rates') . " / $form->{company}"; 5417 5418 $form->{nextsub} = "list_exchangerates"; 5419 5420 # currencies 5421 @curr = split /:/, $form->{currencies}; 5422 $form->{defaultcurrency} = $curr[0]; 5423 shift @curr; 5424 $selectcurrency = "\n"; 5425 for (@curr) { $selectcurrency .= "$_\n" } 5426 5427 if (@curr) { 5428 $selectcurrency = qq|<tr> 5429 <th align=right nowrap>|.$locale->text('Currency').qq|</th> 5430 <td><select name=currency>| 5431 .$form->select_option($selectcurrency, $form->{currency}) 5432 .qq|</select></td></tr>|; 5433 } else { 5434 $form->error($locale->text('No foreign currencies!')); 5435 } 5436 5437 if (@{ $form->{all_years} }) { 5438 $selectaccountingyear = "\n"; 5439 for (@{ $form->{all_years} }) { $selectaccountingyear .= qq|$_\n| } 5440 $selectaccountingmonth = "\n"; 5441 for (sort keys %{ $form->{all_month} }) { $selectaccountingmonth .= qq|$_--| .$locale->text($form->{all_month}{$_}).qq|\n| } 5442 5443 $selectfrom = qq| 5444 <tr> 5445 <th align=right>|.$locale->text('Period').qq|</th> 5446 <td> 5447 <select name=month>|.$form->select_option($selectaccountingmonth, $form->{month}, 1, 1).qq|</select> 5448 <select name=year>|.$form->select_option($selectaccountingyear, $form->{year}).qq|</select> 5449 <input name=interval class=radio type=radio value=0 checked> |.$locale->text('Current').qq| 5450 <input name=interval class=radio type=radio value=1> |.$locale->text('Month').qq| 5451 <input name=interval class=radio type=radio value=3> |.$locale->text('Quarter').qq| 5452 <input name=interval class=radio type=radio value=12> |.$locale->text('Year').qq| 5453 </td> 5454 </tr> 5455|; 5456 } 5457 5458 $form->helpref("search_exchangerates", $myconfig{countrycode}); 5459 5460 $form->header; 5461 5462 &calendar; 5463 5464 print qq| 5465<body> 5466 5467<form method="post" name="main" action="$form->{script}"> 5468 5469 5470<table width=100%> 5471 <tr><th class=listtop>$form->{helpref}$form->{title}</a></th></tr> 5472 <tr height="5"></tr> 5473 <tr> 5474 <td> 5475 <table> 5476 $selectcurrency 5477 <tr> 5478 <th align=right nowrap>|.$locale->text('From').qq|</th> 5479 <td colspan=3><input name=transdatefrom size=11 class=date title="$myconfig{dateformat}">|.&js_calendar("main", "transdatefrom").qq|<b>|.$locale->text('To').qq|</b> <input name=transdateto size=11 class=date title="$myconfig{dateformat}">|.&js_calendar("main", "transdateto").qq|</td> 5480 </tr> 5481 $selectfrom 5482 </table> 5483 </td> 5484 </tr> 5485 <tr> 5486 <td><hr size=3 noshade></td> 5487 </tr> 5488</table> 5489 5490<br> 5491<input type=hidden name=action value=continue> 5492<input class=submit type=submit name=action value="|.$locale->text('Continue').qq|">|; 5493 5494 $form->{sort} = "transdate"; 5495 5496 $form->hide_form(qw(sort nextsub path login)); 5497 5498 if ($form->{menubar}) { 5499 require "$form->{path}/menu.pl"; 5500 &menubar; 5501 } 5502 5503 print qq| 5504</form> 5505 5506</body> 5507</html> 5508|; 5509 5510} 5511 5512 5513sub list_exchangerates { 5514 5515 AM->get_exchangerates(\%myconfig, \%$form); 5516 5517 $href = "$form->{script}?action=list_exchangerates"; 5518 for (qw(direction oldsort path login)) { $href .= qq|&$_=$form->{$_}| } 5519 5520 $form->sort_order(); 5521 5522 $callback = "$form->{script}?action=list_exchangerates"; 5523 for (qw(direction oldsort path login)) { $callback .= qq|&$_=$form->{$_}| } 5524 5525 if ($form->{currency}) { 5526 $callback .= "¤cy=".$form->escape($form->{currency},1); 5527 $href .= "¤cy=".$form->escape($form->{currency}); 5528 $option .= "\n<br>" if ($option); 5529 $option .= $locale->text('Currency')." : $form->{currency}"; 5530 } 5531 if ($form->{transdatefrom}) { 5532 $callback .= "&transdatefrom=$form->{transdatefrom}"; 5533 $href .= "&transdatefrom=$form->{transdatefrom}"; 5534 $option .= "\n<br>" if ($option); 5535 $option .= $locale->text('From')." ".$locale->date(\%myconfig, $form->{transdatefrom}, 1); 5536 } 5537 if ($form->{transdateto}) { 5538 $callback .= "&transdateto=$form->{transdateto}"; 5539 $href .= "&transdateto=$form->{transdateto}"; 5540 $option .= "\n<br>" if ($option); 5541 $option .= $locale->text('To')." ".$locale->date(\%myconfig, $form->{transdateto}, 1); 5542 } 5543 5544 @column_index = qw(transdate); 5545 5546 if ($form->{currency}) { 5547 @curr = ($form->{currency}); 5548 $form->{currencies} = $form->{currency}; 5549 push @column_index, $form->{currency}; 5550 $column_header{$form->{currency}} = "<th class=listheading>$form->{currency}</th>"; 5551 } else { 5552 @curr = split /:/, $form->{currencies}; 5553 shift @curr; 5554 $form->{currencies} = join ':', @curr; 5555 for $curr (@curr) { 5556 push @column_index, $curr; 5557 $column_header{$curr} = "<th class=listheading>$curr</th>"; 5558 } 5559 } 5560 5561 $form->{title} = $locale->text('Exchange Rates') . " / $form->{company}"; 5562 5563 $column_header{transdate} = "<th><a class=listheading href=$href&sort=$form->{sort}>".$locale->text('Date')."</a></th>"; 5564 5565 5566 $form->helpref("list_exchangerates", $myconfig{countrycode}); 5567 5568 $form->header; 5569 5570 print qq| 5571<body> 5572 5573<table width=100%> 5574 <tr> 5575 <th class=listtop>$form->{helpref}$form->{title}</a></th> 5576 </tr> 5577 <tr height="5"></tr> 5578 <tr> 5579 <td>$option</td> 5580 </tr> 5581 <tr> 5582 <td> 5583 <table width=100%> 5584 <tr class=listheading> 5585|; 5586 5587 for (@column_index) { print "\n$column_header{$_}" } 5588 5589 print qq| 5590 </tr> 5591|; 5592 5593 @column_index = qw(transdate); 5594 5595 if ($form->{currency}) { 5596 push @column_index, "$form->{currency}exchangerate"; 5597 } else { 5598 for $curr (@curr) { 5599 push @column_index, "${curr}exchangerate"; 5600 } 5601 } 5602 5603 # escape callback for href 5604 $form->{callback} = $callback .= "&sort=$form->{sort}"; 5605 5606 $callback = $form->escape($callback); 5607 5608 if (@{ $form->{transactions} }) { 5609 $samedate = $form->{transactions}[0]{transdate}; 5610 foreach $curr (@curr) { 5611 $column_data{"${curr}exchangerate"} = "<td> </td>"; 5612 } 5613 } 5614 5615 foreach $ref (@{ $form->{transactions} }) { 5616 5617 if ($ref->{transdate} eq $samedate) { 5618 $href = "$form->{script}?action=edit_exchangerate&transdate=$ref->{transdate}¤cies=$form->{currencies}&path=$form->{path}&login=$form->{login}&callback=$callback"; 5619 $column_data{transdate} = "<td><a href=$href>$ref->{transdate}</td>"; 5620 $column_data{"$ref->{curr}exchangerate"} = "<td align=right>".$form->format_amount(\%myconfig, $ref->{exchangerate}, undef, " ").qq|</td>|; 5621 } else { 5622 5623 $j++; $j %= 2; 5624 5625 print qq| 5626 <tr class=listrow$j> 5627|; 5628 5629 for (@column_index) { print "\n$column_data{$_}" } 5630 5631 print qq| 5632 </tr> 5633|; 5634 5635 foreach $curr (@curr) { 5636 $column_data{"${curr}exchangerate"} = "<td> </td>"; 5637 } 5638 5639 $href = "$form->{script}?action=edit_exchangerate&transdate=$ref->{transdate}¤cies=$form->{currencies}&path=$form->{path}&login=$form->{login}&callback=$callback"; 5640 $column_data{transdate} = "<td><a href=$href>$ref->{transdate}</td>"; 5641 $column_data{"$ref->{curr}exchangerate"} = "<td align=right>".$form->format_amount(\%myconfig, $ref->{exchangerate}, undef, " ").qq|</td>|; 5642 5643 $samedate = $ref->{transdate}; 5644 5645 } 5646 5647 } 5648 5649 $j++; $j %= 2; 5650 5651 print qq| 5652 <tr class=listrow$j> 5653|; 5654 5655 for (@column_index) { print "\n$column_data{$_}" } 5656 5657 print qq| 5658 </tr> 5659 </table> 5660 </td> 5661 </tr> 5662 <tr> 5663 <td><hr size=3 noshade></td> 5664 </tr> 5665</table> 5666 5667<br> 5668<form method=post action=$form->{script}> 5669 5670<input class=submit type=submit name=action value="|.$locale->text('Add Exchange Rate').qq|">|; 5671 5672 $form->hide_form(qw(currencies sort callback path login)); 5673 5674 if ($form->{menubar}) { 5675 require "$form->{path}/menu.pl"; 5676 &menubar; 5677 } 5678 5679 print qq| 5680</form> 5681 5682</body> 5683</html> 5684|; 5685 5686} 5687 5688 5689sub edit_exchangerate { 5690 5691 $form->{title} = $locale->text('Edit Exchange Rate'); 5692 5693 $form->{callback} = "$form->{script}?action=edit_exchangerate&transdate=$form->{transdate}¤cies=$form->{currencies}&path=$form->{path}&login=$form->{login}" unless $form->{callback}; 5694 5695 for (qw(transdatefrom transdateto)) { $form->{$_} = $form->{transdate} }; 5696 5697 $currencies = $form->{currencies}; 5698 for (split /:/, $form->{currencies}) { $curr{$_} = 1 }; 5699 AM->get_exchangerates(\%myconfig, \%$form); 5700 5701 for $ref (@{ $form->{transactions} }) { 5702 $form->{"$ref->{curr}exchangerate"} = $ref->{exchangerate}; 5703 $curr{$ref->{curr}} = 1; 5704 } 5705 5706 if ($currencies) { 5707 $form->{currencies} = $currencies; 5708 } else { 5709 $form->{currencies} = join ':', sort keys %curr; 5710 } 5711 5712 &exchangerate_header; 5713 &form_footer; 5714 5715} 5716 5717 5718sub add_exchange_rate { 5719 5720 $form->{title} = $locale->text('Add Exchange Rate'); 5721 5722 $form->{callback} = "$form->{script}?action=add_exchange_rate¤cies=$form->{currencies}&path=$form->{path}&login=$form->{login}" unless $form->{callback}; 5723 5724 &exchangerate_header; 5725 &form_footer; 5726 5727} 5728 5729 5730sub exchangerate_header { 5731 5732 $form->helpref("exchangerates", $myconfig{countrycode}); 5733 5734 $form->header; 5735 5736 print qq| 5737<body> 5738 5739<form method=post action=$form->{script}> 5740 5741<table width=100%> 5742 <tr> 5743 <th class=listtop>$form->{helpref}$form->{title}</a></th> 5744 </tr> 5745 <tr height="5"></tr> 5746 <tr> 5747 <td> 5748 <table> 5749 <tr> 5750 <td></td> 5751 <td><input name=transdate value="$form->{transdate}" size=11 class=date title="$myconfig{dateformat}"></td> 5752 <th>|.$locale->text('Exchangerate').qq|</th> 5753 </tr> 5754|; 5755 5756 for (split /:/, $form->{currencies}) { 5757 print qq| 5758 <tr> 5759 <td><input type=hidden name="$_" value=1></td> 5760 <th align=left>$_</th> 5761 <td><input name="${_}exchangerate" class="inputright" value="|.$form->format_amount(\%myconfig, $form->{"${_}exchangerate"}).qq|"></td> 5762 </tr> 5763|; 5764 } 5765 5766 print qq| 5767 </table> 5768 </td> 5769 </tr> 5770 <tr> 5771 <td><hr size=3 noshade></td> 5772 </tr> 5773</table> 5774|; 5775 5776 $form->{type} = "exchangerate"; 5777 $form->{oldtransdate} = $form->{transdate}; 5778 5779 $form->hide_form(qw(type id currencies oldtransdate)); 5780 5781} 5782 5783 5784sub save_exchangerate { 5785 5786 $form->isblank("transdate", $locale->text('Date missing!')); 5787 AM->save_exchangerate(\%myconfig, \%$form); 5788 $form->redirect($locale->text('Exchange Rate saved!')); 5789 5790} 5791 5792 5793sub list_currencies { 5794 5795 AM->currencies(\%myconfig, \%$form); 5796 5797 my $href = "$form->{script}?action=list_currencies"; 5798 for (qw(direction oldsort path login)) { $href .= qq|&$_=$form->{$_}| } 5799 5800 $form->sort_order(); 5801 5802 my $callback = "$form->{script}?action=list_currencies"; 5803 for (qw(direction oldsort path login)) { $callback .= qq|&$_=$form->{$_}| } 5804 5805 $form->{callback} = $callback .= "&sort=$form->{sort}"; 5806 $callback = $form->escape($callback); 5807 5808 $form->{title} = $locale->text('Currencies') . " / $form->{company}"; 5809 5810 my @column_index = $form->sort_columns(qw(rn curr prec up down)); 5811 5812 my %column_data; 5813 5814 $column_data{rn} = qq|<th><a class=listheading href=$href&sort=rn>|.$locale->text('No.').qq|</a></th>|; 5815 $column_data{curr} = qq|<th width=99%><a class=listheading href=$href&sort=curr>|.$locale->text('Currency').qq|</a></th>|; 5816 $column_data{prec} = qq|<th class=listheading>|.$locale->text('Precision').qq|</th>|; 5817 $column_data{up} = qq|<th class=listheading> </th>|; 5818 $column_data{down} = qq|<th class=listheading> </th>|; 5819 5820 $form->helpref("list_currencies", $myconfig{countrycode}); 5821 5822 $form->header; 5823 5824 print qq| 5825<body> 5826 5827<table width=100%> 5828 <tr> 5829 <th class=listtop>$form->{helpref}$form->{title}</a></th> 5830 </tr> 5831 <tr height="5"></tr> 5832 <tr> 5833 <td> 5834 <table width=100%> 5835 <tr class=listheading> 5836|; 5837 5838 for (@column_index) { print "$column_data{$_}\n" } 5839 5840 print qq| 5841 </tr> 5842|; 5843 5844 my $i; 5845 5846 foreach my $ref (@{ $form->{ALL} }) { 5847 5848 $i++; $i %= 2; 5849 5850 print qq| 5851 <tr valign=top class=listrow$i> 5852|; 5853 5854 $ref->{curr} =~ s/ //g; 5855 $column_data{rn} = qq|<td align=right>$ref->{rn}</td>|; 5856 $column_data{curr} = qq|<td><a href=$form->{script}?action=edit_currency&curr=$ref->{curr}&rn=$ref->{rn}&path=$form->{path}&login=$form->{login}&callback=$callback>$ref->{curr}</td>|; 5857 $column_data{prec} = qq|<td align=right>$ref->{prec}</td>|; 5858 $column_data{up} = qq|<td align=center><a href=$form->{script}?action=move&db=curr&fld=curr&id=$ref->{curr}&move=up&path=$form->{path}&login=$form->{login}&callback=$callback><img src=$images/up.png alt="+" border=0></td>|; 5859 $column_data{down} = qq|<td align=center><a href=$form->{script}?action=move&db=curr&fld=curr&id=$ref->{curr}&move=down&path=$form->{path}&login=$form->{login}&callback=$callback><img src=$images/down.png alt="-" border=0></td>|; 5860 5861 5862 for (@column_index) { print "$column_data{$_}\n" } 5863 5864 print qq| 5865 </tr> 5866|; 5867 } 5868 5869 print qq| 5870 </table> 5871 </td> 5872 </tr> 5873 <tr> 5874 <td><hr size=3 noshade></td> 5875 </tr> 5876</table> 5877 5878<br> 5879<form method=post action=$form->{script}> 5880 5881<input class=submit type=submit name=action value="|.$locale->text('Add Currency').qq|">|; 5882 5883 $form->{type} = "currency"; 5884 5885 $form->hide_form(qw(type callback path login)); 5886 5887 if ($form->{menubar}) { 5888 require "$form->{path}/menu.pl"; 5889 &menubar; 5890 } 5891 5892 print qq| 5893 </form> 5894 5895</body> 5896</html> 5897|; 5898 5899} 5900 5901 5902sub add_currency { 5903 5904 $form->{title} = $locale->text('Add Currency'); 5905 5906 $form->{callback} = "$form->{script}?action=add_currency&path=$form->{path}&login=$form->{login}" unless $form->{callback}; 5907 5908 ¤cy_header; 5909 &form_footer; 5910 5911} 5912 5913 5914sub edit_currency { 5915 5916 $form->{title} = $locale->text('Edit Currency'); 5917 5918 AM->get_currency(\%myconfig, \%$form); 5919 5920 $form->{id} = 1; 5921 ¤cy_header; 5922 &form_footer; 5923 5924} 5925 5926 5927sub delete_currency { 5928 5929 if (AM->delete_currency(\%myconfig, \%$form)) { 5930 $form->redirect($locale->text('Currency deleted!')); 5931 } 5932 5933 $form->error($locale->text('Failed to delete Currency!')); 5934 5935} 5936 5937 5938sub move { 5939 5940 AM->move(\%myconfig, \%$form); 5941 $form->redirect; 5942 5943} 5944 5945 5946sub currency_header { 5947 5948 $form->helpref("currency", $myconfig{countrycode}); 5949 5950 $form->header; 5951 5952 $form->{type} = "currency"; 5953 5954 print qq| 5955<body> 5956 5957<form method=post action=$form->{script}> 5958 5959<table width=100%> 5960 <tr> 5961 <th class=listtop colspan=2>$form->{helpref}$form->{title}</a></th> 5962 </tr> 5963 <tr height="5"></tr> 5964 <tr> 5965 <td> 5966 <table> 5967 <tr> 5968 <th align=right>|.$locale->text('Currency').qq|</th> 5969 <td><input name=curr size=3 maxlength=3 value="$form->{curr}"></td> 5970 <th align=right>|.$locale->text('Precision').qq|</th> 5971 <td><input name=prec class="inputright" size=3 value="$form->{prec}"></td> 5972 </tr> 5973 </table> 5974 </td> 5975 </tr> 5976 <tr> 5977 <td colspan=2><hr size=3 noshade></td> 5978 </tr> 5979</table> 5980|; 5981 5982 $form->hide_form(qw(type rn)); 5983 5984} 5985 5986 5987sub save_currency { 5988 5989 $form->isblank("curr", $locale->text('Currency missing!')); 5990 if (AM->save_currency(\%myconfig, \%$form)) { 5991 $form->redirect($locale->text('Currency saved!')); 5992 } 5993 5994 $form->error($locale->text('Failed to save Currency!')); 5995 5996} 5997 5998 5999sub list_roles { 6000 6001 AM->roles(\%myconfig, \%$form); 6002 6003 $locale = new Locale "$myconfig{countrycode}", "menu"; 6004 6005 my $href = "$form->{script}?action=list_roles"; 6006 for (qw(direction oldsort path login)) { $href .= "&$_=$form->{$_}" } 6007 6008 $form->sort_order(); 6009 6010 my $callback = "$form->{script}?action=list_roles"; 6011 for (qw(direction oldsort path login)) { $callback .= "&$_=$form->{$_}" } 6012 6013 $form->{callback} = $callback; 6014 $callback = $form->escape($form->{callback}); 6015 6016 $form->{title} = $locale->text('Roles') . " / $form->{company}"; 6017 6018 my @column_index = $form->sort_columns(qw(description acs up down)); 6019 6020 my %column_data; 6021 6022 $column_data{rn} = qq|<th><a class=listheading href=$href&sort=rn>|.$locale->text('No.').qq|</a></th>|; 6023 $column_data{description} = qq|<th width=99%><a class=listheading href=$href&sort=description>|.$locale->text('Description').qq|</a></th>|; 6024 $column_data{acs} = qq|<th class=listheading nowrap>|.$locale->text('Disable').qq|</th>|; 6025 6026 for (qw(up down)) { $column_data{$_} = qq|<th class=listheading> </th>| } 6027 6028 $form->helpref("list_roles", $myconfig{countrycode}); 6029 6030 $form->header; 6031 6032 print qq| 6033<body> 6034 6035<table width=100%> 6036 <tr> 6037 <th class=listtop>$form->{helpref}$form->{title}</a></th> 6038 </tr> 6039 <tr height="5"></tr> 6040 <tr> 6041 <td> 6042 <table width=100%> 6043 <tr class=listheading> 6044|; 6045 6046 for (@column_index) { print "$column_data{$_}\n" } 6047 6048 print qq| 6049 </tr> 6050|; 6051 6052 $login = $form->{login}; 6053 $login =~ s/\@.*//; 6054 6055 my $i; 6056 $lastitem = @{ $form->{ALL} }; 6057 6058 foreach my $ref (@{ $form->{ALL} }) { 6059 6060 $i++; $i %= 2; 6061 6062 print qq| 6063 <tr valign=top class=listrow$i> 6064|; 6065 6066 $column_data{rn} = qq|<td align=right>$ref->{rn}</td>|; 6067 6068 $edit = 0; 6069 $edit = 1 if $form->{admin}; 6070 6071 if ($edit) { 6072 $column_data{description} = qq|<td><a href=$form->{script}?action=edit_role&id=$ref->{id}&path=$form->{path}&login=$form->{login}&callback=$callback>$ref->{description}</td>|; 6073 } else { 6074 $column_data{description} = qq|<td>$ref->{description}</td>|; 6075 } 6076 6077 chop $ref->{acs}; 6078 $acs = ""; 6079 for (split /;/, $ref->{acs}) { 6080 ($item) = split /--/, $_; 6081 s/--$item//; 6082 s/ / /g; 6083 6084 @acs = split /--/, $_; 6085 6086 $acs .= join '--', map { $locale->text($_) } @acs; 6087 $acs .= "<br>"; 6088 } 6089 $column_data{acs} = qq|<td nowrap>$acs</td>|; 6090 6091 for (qw(up down)) { $column_data{$_} = qq|<td> </td>| } 6092 6093 $edit = 0; 6094 $edit = 1 if $ref->{rn} > 1 && ($form->{role} && $form->{rn}{$form->{role}} < $ref->{rn} - 1); 6095 $edit = 1 if $form->{admin}; 6096 6097 if ($edit) { 6098 $column_data{up} = qq|<td align=center><a href=$form->{script}?action=move&db=acsrole&fld=id&id=$ref->{id}&move=up&path=$form->{path}&login=$form->{login}&callback=$callback><img src=$images/up.png alt="+" border=0></td>|; 6099 } 6100 6101 $edit = 0; 6102 $edit = 1 if $ref->{rn} < $lastitem && ($form->{role} && $form->{rn}{$form->{role}} < $ref->{rn}); 6103 $edit = 1 if $form->{admin}; 6104 6105 if ($edit) { 6106 $column_data{down} = qq|<td align=center><a href=$form->{script}?action=move&db=acsrole&fld=id&id=$ref->{id}&move=down&path=$form->{path}&login=$form->{login}&callback=$callback><img src=$images/down.png alt="-" border=0></td>|; 6107 } 6108 6109 for (@column_index) { print "$column_data{$_}\n" } 6110 6111 print qq| 6112 </tr> 6113|; 6114 } 6115 6116 print qq| 6117 </table> 6118 </td> 6119 </tr> 6120 <tr> 6121 <td><hr size=3 noshade></td> 6122 </tr> 6123</table> 6124 6125<br> 6126|; 6127 6128 if ($form->{admin}) { 6129 print qq| 6130<form method=post action=$form->{script}> 6131 6132<input class=submit type=submit name=action value="|.$locale->text('Add Role').qq|">|; 6133 6134 $form->{type} = "role"; 6135 6136 $form->hide_form(qw(type callback path login)); 6137 6138 print qq| 6139 </form> 6140|; 6141 } 6142 6143 if ($form->{menubar}) { 6144 require "$form->{path}/menu.pl"; 6145 &menubar; 6146 } 6147 6148 print qq| 6149 6150</body> 6151</html> 6152|; 6153 6154} 6155 6156 6157sub add_role { 6158 6159 $form->{title} = $locale->text('Add Role'); 6160 6161 &role_header; 6162 &form_footer; 6163 6164} 6165 6166 6167sub edit_role { 6168 6169 $form->{title} = $locale->text('Edit Role'); 6170 6171 AM->get_role(\%myconfig, \%$form); 6172 6173 &role_header; 6174 &form_footer; 6175 6176} 6177 6178 6179sub role_header { 6180 6181 $menufile = "menu.ini"; 6182 6183 $form->{type} = "role"; 6184 6185 $form->helpref("roles", $myconfig{countrycode}); 6186 6187 $locale = new Locale "$myconfig{countrycode}", "menu"; 6188 6189 $form->header; 6190 6191 &check_all(qw(allbox_select ndx_)); 6192 6193 print qq| 6194<body> 6195 6196<form method=post action=$form->{script}> 6197 6198<table width=100%> 6199 <tr> 6200 <th class=listtop colspan=2>$form->{helpref}$form->{title}</a></th> 6201 </tr> 6202 <tr height="5"></tr> 6203 <tr> 6204 <td> 6205 <table> 6206 <tr> 6207 <th align=right nowrap>|.$locale->text('Description').qq|</th> 6208 <td><input name=description size=35 value="|.$form->quote($form->{description}).qq|"></td> 6209 </tr> 6210 </table> 6211 </td> 6212 </tr> 6213 <tr class=listheading> 6214 <th colspan=2>|.$locale->text('Access Control').qq|</th> 6215 </tr> 6216 <tr> 6217 <th colspan=2><input name="allbox_select" type=checkbox class=checkbox value="1" onChange="CheckAll();" checked></th> 6218 </tr> 6219|; 6220 6221 # access control 6222 open(FH, $menufile) or $form->error("$menufile : $!"); 6223 # scan for first menu level 6224 @a = <FH>; 6225 close(FH); 6226 6227 if (open(FH, "$form->{path}/custom/$menufile")) { 6228 push @a, <FH>; 6229 } 6230 close(FH); 6231 6232 foreach $item (@a) { 6233 next unless $item =~ /\[\w+/; 6234 next if $item =~ /\#/; 6235 6236 $item =~ s/(\[|\])//g; 6237 chomp $item; 6238 6239 if ($item =~ /--/) { 6240 ($level, $menuitem) = split /--/, $item, 2; 6241 } else { 6242 $level = $item; 6243 $menuitem = $item; 6244 push @acsorder, $item; 6245 } 6246 6247 push @{ $acs{$level} }, $menuitem; 6248 6249 } 6250 6251 foreach $item (split /;/, $form->{acs}) { 6252 ($key, $value) = split /--/, $item, 2; 6253 $excl{$key}{$value} = 1; 6254 } 6255 6256 foreach $key (@acsorder) { 6257 6258 $checked = ($excl{$key}{$key}) ? "" : "checked"; 6259 6260 # can't have variable names with & and spaces 6261 $item = $form->escape("${key}--$key",1); 6262 6263 $acsheading = $key; 6264 $acsheading =~ s/ / /g; 6265 6266 $acsheading = qq| 6267 <th align=left nowrap><input name="ndx_$item" class=checkbox type=checkbox value=1 $checked> |.$locale->text($acsheading).qq|</th>\n|; 6268 $menuitems .= "$item;"; 6269 6270 $acsdata = qq| 6271 <td>|; 6272 6273 foreach $item (@{ $acs{$key} }) { 6274 next if ($key eq $item); 6275 6276 $checked = ($excl{$key}{$item}) ? "" : "checked"; 6277 6278 @acs = split /--/, $item; 6279 $acs = join '--', map { $locale->text($_) } @acs; 6280 6281 $acsitem = $form->escape("${key}--$item",1); 6282 6283 $acsdata .= qq| 6284 <br><input name="$acsitem" class=checkbox type=checkbox value=1 $checked> $acs|; 6285 $menuitems .= "$acsitem;"; 6286 } 6287 $acsdata .= qq| 6288 </td>|; 6289 6290 print qq| 6291 <tr valign=top>$acsheading $acsdata 6292 </tr> 6293|; 6294 } 6295 6296 $form->{acs} = "$menuitems"; 6297 6298 print qq| 6299 <tr> 6300 <td colspan=2><hr size=3 noshade></td> 6301 </tr> 6302</table> 6303|; 6304 6305 $form->hide_form(qw(id type acs)); 6306 6307} 6308 6309 6310sub save_role { 6311 6312 $form->isblank("description", $locale->text('Description missing!')); 6313 6314 for (split /;/, $form->{acs}) { 6315 ($id1, $id2) = split /--/, $_; 6316 if ($id1 eq $id2) { 6317 $item = $form->escape($_,1); 6318 $form->{$item} = $form->{"ndx_$item"}; 6319 delete $form->{"ndx_$item"}; 6320 } 6321 } 6322 6323 if (AM->save_role(\%myconfig, \%$form)) { 6324 $form->redirect($locale->text('Role saved!')); 6325 } 6326 6327 $form->error($locale->text('Failed to save Role!')); 6328 6329} 6330 6331 6332sub delete_role { 6333 6334 if (AM->delete_role(\%myconfig, \%$form)) { 6335 $form->redirect($locale->text('Role deleted!')); 6336 } 6337 6338 $form->error($locale->text('Failed to delete Role!')); 6339 6340} 6341 6342 6343sub monitor { 6344 6345 $form->error($locale->text('Must be logged in as admin!')) unless $form->{admin}; 6346 6347 $form->{title} = $locale->text('Database Monitor'); 6348 6349 $form->{reportcode} = 'monitor'; 6350 $form->reports(\%myconfig); 6351 6352 if (@{ $form->{all_report} }) { 6353 $form->{selectreportform} = "\n"; 6354 for (@{ $form->{all_report} }) { $form->{selectreportform} .= qq|$_->{reportdescription}--$_->{reportid}\n| } 6355 $reportform = $locale->text('SQL command').qq| 6356 <select name=report onChange="ChangeReport();">|.$form->select_option($form->{selectreportform}, $form->{report}, 1) 6357 .qq|</select> 6358 <p> 6359|; 6360 } 6361 6362 @input = qw(sql); 6363 6364 $form->header; 6365 6366 &change_report(\%$form, \@input); 6367 6368 print qq| 6369<body> 6370 6371<h2 class=confirm>$form->{title}</h2> 6372 6373<form method=post action=$form->{script}> 6374 6375$reportform 6376|; 6377 6378 print $locale->text('Enter a SQL command to send to the server'); 6379 6380 print qq| 6381<br><textarea rows=10 cols=70 wrap name=sql>$form->{sqlcommand}</textarea> 6382|; 6383 6384 $button{'Run SQL command'} = { ndx => 1, key => 'R', value => $locale->text('Run SQL command') }; 6385 6386 $button{'Save SQL command'} = { ndx => 2, key => 'S', value => $locale->text('Save SQL command') } if $form->{sqlcommand}; 6387 6388 $button{'Delete SQL command'} = { ndx => 3, key => 'D', value => $locale->text('Delete SQL command') } if $form->{report}; 6389 6390 $form->print_button(\%button); 6391 6392 $form->hide_form(qw(sqlcommand path login)); 6393 6394print qq| 6395</form> 6396 6397</body> 6398</html> 6399|; 6400 6401} 6402 6403 6404sub run_sql_command { 6405 6406 $form->isblank("sql", $locale->text('SQL statement missing')); 6407 6408 $form->error($locale->text('Must be logged in as admin!')) unless $form->{admin}; 6409 6410 $form->{callback} = "$form->{script}?action=monitor&path=$form->{path}&login=$form->{login}&report=$form->{report}&header=1&sqlcommand=".$form->escape($form->{sql},1); 6411 6412 # connect to database 6413 $dbh = $form->dbconnect(\%myconfig); 6414 6415 $form->{title} = $locale->text('SQL Run'); 6416 6417 $form->header; 6418 6419 if ($form->{sql} =~ /^select/i) { 6420 $sth = $dbh->prepare($form->{sql}); 6421 6422 if ($sth->execute) { 6423 6424 $form->info($form->{sql}); 6425 6426 print qq| 6427 <table border=1> 6428 <tr class=listtop>|; 6429 6430 for (0 .. $sth->{NUM_OF_FIELDS} - 1) { 6431 print qq| 6432 <th class=listheading>$sth->{NAME}->[$_]</th> 6433 |; 6434 } 6435 print qq|</tr>\n|; 6436 6437 while (@arr = $sth->fetchrow_array) { 6438 $j++; $j %= 2; 6439 print "<tr class=listrow$j>"; 6440 foreach $item (@arr) { 6441 print "<td>$item "; 6442 } 6443 print "</tr>"; 6444 } 6445 print "</table>"; 6446 } 6447 6448 $sth->finish; 6449 6450 } else { 6451 if ($dbh->do($form->{sql})) { 6452 $form->info($form->{sql}); 6453 } 6454 } 6455 6456 $dbh->disconnect; 6457 6458 $form->redirect; 6459 6460} 6461 6462 6463sub save_sql_command { 6464 6465 $form->isblank("sql", $locale->text('SQL statement missing')); 6466 6467 $form->error($locale->text('Must be logged in as admin!')) unless $form->{admin}; 6468 6469 ($form->{reportdescription}, $form->{reportid}) = split /--/, $form->{report}; 6470 6471 $form->{title} = $locale->text('Save SQL command'); 6472 6473 $form->header; 6474 6475 print qq| 6476<body> 6477 6478<form method="post" name="main" action="$form->{script}"> 6479 6480<table width=100%> 6481 <tr> 6482 <th class=listtop>$form->{helpref}$form->{title}</a></th> 6483 </tr> 6484 <tr height="5"></tr> 6485 <tr> 6486 <table> 6487 <tr> 6488 <th>|.$locale->text('Description').qq|</th> 6489 <th>|.$locale->text('SQL command').qq|</th> 6490 </tr> 6491 <tr valign=top> 6492 <td><input name=reportdescription size=40 value="$form->{reportdescription}"></td> 6493 <td>$form->{sql}</td> 6494 </tr> 6495 </table> 6496 </tr> 6497<table> 6498<hr> 6499|; 6500 6501 %button = ('Save' => { ndx => 1, key => 'S', value => $locale->text('Save') } ); 6502 6503 $form->print_button(\%button); 6504 6505 $form->{type} = "sql"; 6506 $form->{sql} =~ s/"/\\"/g; 6507 6508 $form->hide_form(qw(reportid sql type path login)); 6509 6510 print qq| 6511</form> 6512 6513</body> 6514</html> 6515|; 6516 6517} 6518 6519 6520sub delete_sql_command { 6521 6522 $form->isblank("sql", $locale->text('SQL statement missing')); 6523 6524 $form->error($locale->text('Must be logged in as admin!')) unless $form->{admin}; 6525 6526 $form->{reportcode} = 'monitor'; 6527 (undef, $form->{reportid}) = split /--/, $form->{report}; 6528 6529 $form->save_report(\%myconfig); 6530 6531 $form->{callback} = "$form->{script}?action=monitor&path=$form->{path}&login=$form->{login}"; 6532 6533 $form->redirect; 6534 6535} 6536 6537 6538sub save_sql { 6539 6540 $form->{reportcode} = 'monitor'; 6541 for (qw(type sqlcommand)) { delete $form->{$_} } 6542 6543 $form->save_report(\%myconfig); 6544 6545 $form->{callback} = "$form->{script}?action=monitor&path=$form->{path}&login=$form->{login}"; 6546 6547 $form->redirect; 6548 6549} 6550 6551 6552