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# printing routines for ar, ap 11# 12 13# any custom scripts for this one 14if (-f "$form->{path}/custom/arapprn.pl") { 15 eval { require "$form->{path}/custom/arapprn.pl"; }; 16} 17if (-f "$form->{path}/custom/$form->{login}/arapprn.pl") { 18 eval { require "$form->{path}/custom/$form->{login}/arapprn.pl"; }; 19} 20 211; 22# end of main 23 24 25sub print { 26 27 if ($form->{media} !~ /screen/) { 28 $oldform = new Form; 29 for (keys %$form) { $oldform->{$_} = $form->{$_} } 30 } 31 32 if (! $form->{invnumber}) { 33 $invfld = 'sinumber'; 34 $invfld = 'vinumber' if $form->{ARAP} eq 'AP'; 35 $form->{invnumber} ||= '-'; 36 if ($form->{media} ne 'screen') { 37 $form->{invnumber} = $form->update_defaults(\%myconfig, $invfld); 38 } 39 } 40 41 if ($form->{formname} =~ /(check|receipt)/) { 42 if ($form->{media} ne 'screen') { 43 for (qw(action header)) { delete $form->{$_} } 44 $form->{invtotal} = $form->{oldinvtotal}; 45 46 foreach $key (keys %$form) { 47 $form->{$key} =~ s/&/%26/g; 48 $form->{previousform} .= qq|$key=$form->{$key}&|; 49 } 50 chop $form->{previousform}; 51 $form->{previousform} = $form->escape($form->{previousform}, 1); 52 } 53 54 if ($form->{paidaccounts} > 1) { 55 if ($form->{"paid_$form->{paidaccounts}"}) { 56 &update; 57 exit; 58 } elsif ($form->{paidaccounts} > 2) { 59 &select_payment; 60 exit; 61 } 62 } else { 63 $form->error($locale->text('Nothing to print!')); 64 } 65 66 } 67 68 &{ "print_$form->{formname}" }($oldform, 1); 69 70} 71 72 73sub print_check { 74 my ($oldform, $i) = @_; 75 76 $display_form = ($form->{display_form}) ? $form->{display_form} : "display_form"; 77 78 if ($form->{"paid_$i"}) { 79 @a = (); 80 81 $datepaid = $form->datetonum(\%myconfig, $form->{"datepaid_$i"}); 82 ($form->{yyyy}, $form->{mm}, $form->{dd}) = $datepaid =~ /(....)(..)(..)/; 83 84 if (exists $form->{longformat}) { 85 $form->{"datepaid_$i"} = $locale->date(\%myconfig, $form->{"datepaid_$i"}, $form->{longformat}); 86 } 87 88 push @a, "source_$i", "memo_$i"; 89 $form->format_string(@a); 90 } 91 92 $form->{amount} = $form->{"paid_$i"}; 93 94 if (($form->{formname} eq 'check' && $form->{vc} eq 'customer') || 95 ($form->{formname} eq 'receipt' && $form->{vc} eq 'vendor')) { 96 $form->{amount} =~ s/-//g; 97 } 98 99 for (qw(datepaid source memo)) { $form->{$_} = $form->{"${_}_$i"} } 100 101 AA->company_details(\%myconfig, \%$form); 102 @a = qw(name address1 address2 city state zipcode country); 103 push @a, qw(firstname lastname salutation contacttitle occupation mobile); 104 105 foreach $item (qw(invnumber ordnumber)) { 106 $temp{$item} = $form->{$item}; 107 delete $form->{$item}; 108 push(@{ $form->{$item} }, $temp{$item}); 109 } 110 push(@{ $form->{invdate} }, $form->{transdate}); 111 push(@{ $form->{due} }, $form->format_amount(\%myconfig, $form->{oldinvtotal}, $form->{precision})); 112 push(@{ $form->{paid} }, $form->{"paid_$i"}); 113 114 use SL::CP; 115 $c = CP->new(($form->{language_code}) ? $form->{language_code} : $myconfig{countrycode}); 116 $c->init; 117 ($whole, $form->{decimal}) = split /\./, $form->parse_amount(\%myconfig, $form->{amount}); 118 119 $form->{decimal} = substr("$form->{decimal}00", 0, 2); 120 $form->{text_decimal} = $c->num2text($form->{decimal} * 1); 121 $form->{text_amount} = $c->num2text($whole); 122 $form->{integer_amount} = $whole; 123 124 if ($form->{cd_amount}) { 125 ($whole, $form->{cd_decimal}) = split /\./, $form->{cd_invtotal}; 126 $form->{cd_decimal} = substr("$form->{cd_decimal}00", 0, 2); 127 $form->{text_cd_decimal} = $c->num2text($form->{cd_decimal} * 1); 128 $form->{text_cd_invtotal} = $c->num2text($whole); 129 $form->{integer_cd_invtotal} = $whole; 130 } 131 132 push @a, (qw(text_amount text_decimal text_cd_invtotal text_cd_decimal)); 133 134 # dcn 135 if ($form->{vc} eq 'customer') { 136 for (qw(memberno rvc dcn)) { $form->{$_} = $form->{"bank$_"} } 137 $form->{rvc} = $form->format_dcn($form->{rvc}); 138 $form->{dcn} = $form->format_dcn($form->{dcn}); 139 } 140 141 for (qw(employee)) { ($form->{$_}, $form->{"${_}_id"}) = split /--/, $form->{$_} }; 142 143 push @a, qw(employee notes intnotes company address tel fax businessnumber companyemail companywebsite); 144 145 $form->format_string(@a); 146 147 $form->{templates} = "$templates/$myconfig{templates}"; 148 $form->{IN} = "$form->{formname}.$form->{format}"; 149 150 if ($form->{format} =~ /(ps|pdf)/) { 151 $form->{IN} =~ s/$&$/tex/; 152 } 153 154 if ($form->{media} !~ /(screen)/) { 155 $form->{OUT} = qq~| $form->{"$form->{media}_printer"}~; 156 157 if ($form->{printed} !~ /$form->{formname}/) { 158 159 $form->{printed} .= " $form->{formname}"; 160 $form->{printed} =~ s/^ //; 161 162 $form->update_status(\%myconfig); 163 } 164 165 %audittrail = ( tablename => lc $form->{ARAP}, 166 reference => $form->{invnumber}, 167 formname => $form->{formname}, 168 action => 'printed', 169 id => $form->{id} ); 170 171 %status = (); 172 for (qw(printed audittrail)) { $status{$_} = $form->{$_} } 173 174 $status{audittrail} .= $form->audittrail("", \%myconfig, \%audittrail); 175 176 } 177 178 $form->{fileid} = $invnumber; 179 $form->{fileid} =~ s/(\s|\W)+//g; 180 181 $form->parse_template(\%myconfig, $userspath, $dvipdf, $xelatex); 182 183 if ($form->{previousform}) { 184 185 $previousform = $form->unescape($form->{previousform}); 186 187 for (keys %$form) { delete $form->{$_} } 188 189 foreach $item (split /&/, $previousform) { 190 ($key, $value) = split /=/, $item, 2; 191 $value =~ s/%26/&/g; 192 $form->{$key} = $value; 193 } 194 195 for (qw(exchangerate creditlimit creditremaining)) { $form->{$_} = $form->parse_amount(\%myconfig, $form->{$_}) } 196 197 for (1 .. $form->{rowcount}) { $form->{"amount_$_"} = $form->parse_amount(\%myconfig, $form->{"amount_$_"}) } 198 for (split / /, $form->{taxaccounts}) { $form->{"tax_$_"} = $form->parse_amount(\%myconfig, $form->{"tax_$_"}) } 199 200 for $i (1 .. $form->{paidaccounts}) { 201 for (qw(paid exchangerate)) { $form->{"${_}_$i"} = $form->parse_amount(\%myconfig, $form->{"${_}_$i"}) } 202 } 203 204 for (qw(printed audittrail)) { $form->{$_} = $status{$_} } 205 206 &{ "$display_form" }; 207 208 } 209 210} 211 212 213sub print_receipt { 214 my ($oldform, $i) = @_; 215 216 &print_check($oldform, $i); 217 218} 219 220sub print_remittance_voucher { 221 my ($oldform) = @_; 222 223 &print_transaction($oldform); 224 225} 226 227 228sub print_transaction { 229 my ($oldform) = @_; 230 231 $display_form = ($form->{display_form}) ? $form->{display_form} : "display_form"; 232 233 AA->company_details(\%myconfig, \%$form); 234 235 @a = qw(name address1 address2 city state zipcode country); 236 237 $form->{invdescription} = $form->{description}; 238 $form->{description} = (); 239 240 $form->{invtotal} = 0; 241 foreach $i (1 .. $form->{rowcount} - 1) { 242 ($form->{tempaccno}, $form->{tempaccount}) = split /--/, $form->{"$form->{ARAP}_amount_$i"}; 243 ($form->{tempprojectnumber}) = split /--/, $form->{"projectnumber_$i"}; 244 $form->{tempdescription} = $form->{"description_$i"}; 245 246 $form->format_string(qw(tempaccno tempaccount tempprojectnumber tempdescription)); 247 248 push(@{ $form->{accno} }, $form->{tempaccno}); 249 push(@{ $form->{account} }, $form->{tempaccount}); 250 push(@{ $form->{description} }, $form->{tempdescription}); 251 push(@{ $form->{projectnumber} }, $form->{tempprojectnumber}); 252 253 push(@{ $form->{amount} }, $form->{"amount_$i"}); 254 255 $form->{subtotal} += $form->parse_amount(\%myconfig, $form->{"amount_$i"}); 256 257 } 258 259 $form->{cd_subtotal} = $form->{subtotal}; 260 $cashdiscount = $form->parse_amount($myconfig, $form->{cashdiscount})/100; 261 $form->{cd_available} = $form->{subtotal} * $cashdiscount; 262 $cdt = $form->parse_amount($myconfig, $form->{discount_paid}); 263 $cdt ||= $form->{cd_available}; 264 $form->{cd_subtotal} -= $cdt; 265 $form->{cd_amount} = $cdt; 266 267 $cashdiscount = 0; 268 if ($form->{subtotal}) { 269 $cashdiscount = $cdt / $form->{subtotal}; 270 } 271 272 $cd_tax = 0; 273 for (split / /, $form->{taxaccounts}) { 274 275 if ($form->{"tax_$_"}) { 276 277 $form->format_string("${_}_description"); 278 279 $tax += $amount = $form->parse_amount(\%myconfig, $form->{"tax_$_"}); 280 281 $form->{"${_}_tax"} = $form->{"tax_$_"}; 282 push(@{ $form->{tax} }, $form->{"tax_$_"}); 283 284 if ($form->{cdt}) { 285 $cdt = ($form->{discount_paid}) ? $form->{"tax_$_"} : $amount * (1 - $cashdiscount); 286 $cd_tax += $form->round_amount($cdt, $form->{precision}); 287 push(@{ $form->{cd_tax} }, $form->format_amount(\%myconfig, $cdt, $form->{precision})); 288 } else { 289 push(@{ $form->{cd_tax} }, $form->{"tax_$_"}); 290 } 291 292 push(@{ $form->{taxdescription} }, $form->{"${_}_description"}); 293 294 $form->{"${_}_taxrate"} = $form->format_amount($myconfig, $form->{"${_}_rate"} * 100, undef, 0); 295 296 push(@{ $form->{taxrate} }, $form->{"${_}_taxrate"}); 297 298 push(@{ $form->{taxnumber} }, $form->{"${_}_taxnumber"}); 299 } 300 } 301 302 303 push @a, $form->{ARAP}; 304 $form->format_string(@a); 305 306 $form->{roundto} = 0; 307 if ($form->{roundchange}) { 308 %roundchange = split /[=;]/, $form->unescape($form->{roundchange}); 309 $form->{roundto} = $roundchange{''}; 310 if ($form->{selectpaymentmethod}) { 311 $form->{roundto} = $roundchange{$form->{"paymentmethod_$form->{paidaccounts}"}}; 312 } 313 } 314 315 $form->{paid} = 0; 316 317 for $i (1 .. $form->{paidaccounts}) { 318 319 if ($form->{"paid_$i"}) { 320 @a = (); 321 $form->{paid} += $form->parse_amount(\%myconfig, $form->{"paid_$i"}); 322 323 if (exists $form->{longformat}) { 324 $form->{"datepaid_$i"} = $locale->date(\%myconfig, $form->{"datepaid_$i"}, $form->{longformat}); 325 } 326 327 push @a, "$form->{ARAP}_paid_$i", "source_$i", "memo_$i"; 328 $form->format_string(@a); 329 330 ($accno, $account) = split /--/, $form->{"$form->{ARAP}_paid_$i"}; 331 332 push(@{ $form->{payment} }, $form->{"paid_$i"}); 333 push(@{ $form->{paymentdate} }, $form->{"datepaid_$i"}); 334 push(@{ $form->{paymentaccount} }, $account); 335 push(@{ $form->{paymentsource} }, $form->{"source_$i"}); 336 push(@{ $form->{paymentmemo} }, $form->{"memo_$i"}); 337 338 ($description) = split /--/, $form->{"paymentmethod_$i"}; 339 push(@{ $form->{paymentmethod} }, $description); 340 341 if ($form->{selectpaymentmethod}) { 342 $form->{roundto} = $roundchange{$form->{"paymentmethod_$i"}}; 343 } 344 345 } 346 } 347 348 if ($form->{formname} eq 'remittance_voucher') { 349 $form->isblank("dcn", qq|$form->{"$form->{ARAP}_paid_$form->{paidaccounts}"} : |.$locale->text('DCN missing!')); 350 $form->isblank("rvc", qq|$form->{"$form->{ARAP}_paid_$form->{paidaccounts}"} : |.$locale->text('RVC missing!')); 351 } 352 353 if ($form->{taxincluded}) { 354 $tax = 0; 355 $cd_tax = 0; 356 } 357 358 $form->{invtotal} = $form->{subtotal} + $tax; 359 $form->{cd_invtotal} = $form->{cd_subtotal} + $cd_tax; 360 361 use SL::CP; 362 $c = CP->new(($form->{language_code}) ? $form->{language_code} : $myconfig{countrycode}); 363 $c->init; 364 365 ($whole, $decimal) = split /\./, $form->{invtotal}; 366 $form->{decimal} = substr("${decimal}00", 0, 2); 367 $form->{text_decimal} = $c->num2text($form->{decimal} * 1); 368 $form->{text_amount} = $c->num2text($whole); 369 $form->{integer_amount} = $whole; 370 371 if ($form->{roundto} > 0.01) { 372 $form->{total} = $form->round_amount($form->round_amount(($form->{invtotal} - $form->{paid}) / $form->{roundto}, 0) * $form->{roundto}, $form->{precision}); 373 $form->{roundingdifference} = $form->round_amount($form->{paid} + $form->{total} - $form->{invtotal}, $form->{precision}); 374 } else { 375 $form->{total} = $form->{invtotal} - $form->{paid}; 376 } 377 378 ($whole, $decimal) = split /\./, $form->{total}; 379 $form->{out_decimal} = substr("${decimal}00", 0, 2); 380 $form->{text_out_decimal} = $c->num2text($form->{out_decimal} * 1); 381 $form->{text_out_amount} = $c->num2text($whole); 382 $form->{integer_out_amount} = $whole; 383 384 for (qw(cd_subtotal cd_amount cd_invtotal invtotal subtotal paid total)) { $form->{$_} = $form->format_amount(\%myconfig, $form->{$_}, $form->{precision}) } 385 386 # dcn 387 if ($form->{vc} eq 'customer') { 388 $form->{rvc} = $form->format_dcn($form->{rvc}); 389 $form->{dcn} = $form->format_dcn($form->{dcn}); 390 } 391 392 for (qw(employee)) { ($form->{$_}, $form->{"${_}_id"}) = split /--/, $form->{$_} }; 393 394 $form->fdld(\%myconfig, \%$locale); 395 396 if (exists $form->{longformat}) { 397 for (qw(duedate transdate)) { $form->{$_} = $locale->date(\%myconfig, $form->{$_}, $form->{longformat}) } 398 } 399 400 # before we format replace <%var%> 401 for (qw(description notes intnotes)) { $form->{$_} =~ s/<%(.*?)%>/$fld = lc $1; $form->{$fld}/ge } 402 403 @a = qw(employee invnumber transdate duedate notes intnotes dcn rvc); 404 405 push @a, qw(company address tel fax businessnumber companyemail companywebsite text_amount text_decimal text_out_decimal text_out_amount); 406 407 $form->format_string(@a); 408 409 $form->{invdate} = $form->{transdate}; 410 411 $form->{templates} = "$templates/$myconfig{templates}"; 412 $form->{IN} = "$form->{formname}.$form->{format}"; 413 $form->{IN} = lc $form->{ARAP} . "_$form->{formname}.$form->{format}" if $form->{formname} eq 'transaction'; 414 415 if ($form->{format} =~ /(ps|pdf)/) { 416 $form->{IN} =~ s/$&$/tex/; 417 } 418 419 $form->{pre} = "<body bgcolor=#ffffff>\n<pre>" if $form->{format} eq 'txt'; 420 421 if ($form->{media} !~ /(screen)/) { 422 $form->{OUT} = qq~| $form->{"$form->{media}_printer"}~; 423 424 if ($form->{printed} !~ /$form->{formname}/) { 425 426 $form->{printed} .= " $form->{formname}"; 427 $form->{printed} =~ s/^ //; 428 429 $form->{"$form->{formname}_printed"} = 1; 430 431 $form->update_status(\%myconfig); 432 } 433 434 if (%$oldform) { 435 $oldform->{printed} = $form->{printed}; 436 $oldform->{"$form->{formname}_printed"} = 1; 437 } 438 439 %audittrail = ( tablename => lc $form->{ARAP}, 440 reference => $form->{invnumber}, 441 formname => $form->{formname}, 442 action => 'printed', 443 id => $form->{id} ); 444 445 $oldform->{audittrail} .= $form->audittrail("", \%myconfig, \%audittrail) if %$oldform; 446 447 } 448 449 $form->{fileid} = $form->{invnumber}; 450 $form->{fileid} =~ s/(\s|\W)+//g; 451 452 $form->parse_template(\%myconfig, $userspath, $dvipdf, $xelatex); 453 454 if (%$oldform) { 455 $oldform->{invnumber} = $form->{invnumber}; 456 $oldform->{invtotal} = $form->{invtotal}; 457 458 for (keys %$form) { delete $form->{$_} } 459 for (keys %$oldform) { $form->{$_} = $oldform->{$_} } 460 461 if (! $form->{printandpost}) { 462 for (qw(exchangerate creditlimit creditremaining)) { $form->{$_} = $form->parse_amount(\%myconfig, $form->{$_}) } 463 464 for (1 .. $form->{rowcount}) { $form->{"amount_$_"} = $form->parse_amount(\%myconfig, $form->{"amount_$_"}) } 465 for (split / /, $form->{taxaccounts}) { $form->{"tax_$_"} = $form->parse_amount(\%myconfig, $form->{"tax_$_"}) } 466 467 for $i (1 .. $form->{paidaccounts}) { 468 for (qw(paid exchangerate)) { $form->{"${_}_$i"} = $form->parse_amount(\%myconfig, $form->{"${_}_$i"}) } 469 } 470 } 471 472 &{ "$display_form" }; 473 474 } 475 476} 477 478 479sub print_credit_note { &print_transaction }; 480sub print_debit_note { &print_transaction }; 481 482 483sub print_payslip { 484 my ($oldform) = @_; 485 486 HR->payslip_details(\%myconfig, \%$form); 487 488 $display_form = ($form->{display_form}) ? $form->{display_form} : "display_form"; 489 490 @a = (); 491 $form->{paid} = $form->parse_amount(\%myconfig, $form->{paid}); 492 493 if (exists $form->{longformat}) { 494 $form->{dateto} = $locale->date(\%myconfig, $form->{dateto}, $form->{longformat}); 495 $form->{transdate} = $locale->date(\%myconfig, $form->{transdate}, $form->{longformat}); 496 $form->{datepaid} = $form->{transdate}; 497 } 498 499 for (qw(employee paymentmethod department project)) { ($form->{$_}, $form->{"${_}_id"}) = split /--/, $form->{$_} }; 500 501 push @a, qw(ap payment employee paymentmethod department project gldescription source memo); 502 $form->format_string(@a); 503 504 505 use SL::CP; 506 $c = CP->new(($form->{language_code}) ? $form->{language_code} : $myconfig{countrycode}); 507 $c->init; 508 ($whole, $form->{decimal}) = split /\./, $form->{paid}; 509 510 $form->{decimal} .= "00"; 511 $form->{decimal} = substr($form->{decimal}, 0, 2); 512 $form->{text_decimal} = $c->num2text($form->{decimal} * 1); 513 $form->{text_amount} = $c->num2text($whole); 514 $form->{integer_amount} = $whole; 515 516 517 # before we format replace <%var%> 518 $form->{description} =~ s/<%(.*?)%>/$fld = lc $1; $form->{$fld}/ge; 519 520 @a = qw(description); 521 522 push @a, qw(company address tel fax businessnumber companyemail companywebsite text_amount text_decimal); 523 524 for $i (1 .. $form->{wage_rows}) { 525 if ($form->{"qty_$i"}) { 526 push @a, "wage_$i"; 527 528 push @{ $form->{wage} }, $form->{"wage_$i"}; 529 push @{ $form->{pay} }, $form->{"pay_$i"}; 530 push @{ $form->{qty} }, $form->{"qty_$i"}; 531 push @{ $form->{amount} }, $form->{"amount_$i"}; 532 } 533 } 534 535 delete $form->{deduct}; 536 537 for $i (1 .. $form->{deduction_rows}) { 538 if ($form->{"deduct_$i"}) { 539 push @a, "deduction_$i"; 540 541 push @{ $form->{deduction} }, $form->{"deduction_$i"}; 542 $form->{"deduct_$i"} =~ s/-//; 543 push @{ $form->{deduct} }, $form->{"deduct_$i"}; 544 } 545 } 546 547 $form->format_string(@a); 548 549 $form->{templates} = "$templates/$myconfig{templates}"; 550 $form->{IN} = "$form->{formname}.$form->{format}"; 551 552 if ($form->{format} =~ /(ps|pdf)/) { 553 $form->{IN} =~ s/$&$/tex/; 554 } 555 556 $form->{pre} = "<body bgcolor=#ffffff>\n<pre>" if $form->{format} eq 'txt'; 557 558 if ($form->{media} !~ /(screen)/) { 559 $form->{OUT} = qq~| $form->{"$form->{media}_printer"}~; 560 } 561 562 $form->parse_template(\%myconfig, $userspath, $dvipdf, $xelatex); 563 564 if (%$oldform) { 565 for (keys %$form) { delete $form->{$_} } 566 for (keys %$oldform) { $form->{$_} = $oldform->{$_} } 567 568 &{ "$display_form" }; 569 } 570 571} 572 573 574 575sub select_payment { 576 577 @column_index = qw(ndx datepaid source memo paid); 578 push @column_index, "$form->{ARAP}_paid"; 579 580 $helpref = $form->{helpref}; 581 $form->helpref("select_payment", $myconfig{countrycode}); 582 583 # list payments with radio button on a form 584 $form->header; 585 586 $title = $locale->text('Select payment'); 587 588 $column_data{ndx} = qq|<th width=1%> </th>|; 589 $column_data{datepaid} = qq|<th>|.$locale->text('Date').qq|</th>|; 590 $column_data{source} = qq|<th>|.$locale->text('Source').qq|</th>|; 591 $column_data{memo} = qq|<th>|.$locale->text('Memo').qq|</th>|; 592 $column_data{paid} = qq|<th>|.$locale->text('Amount').qq|</th>|; 593 $column_data{"$form->{ARAP}_paid"} = qq|<th>|.$locale->text('Account').qq|</th>|; 594 595 print qq| 596<body> 597 598<form method=post action=$form->{script}> 599 600<table width=100%> 601 <tr> 602 <th class=listtop>$form->{helpref}$title</a></th> 603 </tr> 604 <tr space=5></tr> 605 <tr> 606 <td> 607 <table width=100%> 608 <tr class=listheading>|; 609 610 for (@column_index) { print "\n$column_data{$_}" } 611 612 print qq| 613 </tr> 614|; 615 616 $checked = "checked"; 617 foreach $i (1 .. $form->{paidaccounts} - 1) { 618 619 for (@column_index) { $column_data{$_} = qq|<td>$form->{"${_}_$i"}</td>| } 620 621 $paid = $form->{"paid_$i"}; 622 $ok = 1; 623 624 $column_data{ndx} = qq|<td><input name=ndx class=radio type=radio value=$i $checked></td>|; 625 $column_data{paid} = qq|<td align=right>$paid</td>|; 626 $column_data{datepaid} = qq|<td nowrap>$form->{"datepaid_$i"}</td>|; 627 628 $checked = ""; 629 630 $j++; $j %= 2; 631 print qq| 632 <tr class=listrow$j>|; 633 634 for (@column_index) { print "\n$column_data{$_}" } 635 636 print qq| 637 </tr> 638|; 639 640 } 641 642 print qq| 643 </table> 644 </td> 645 </tr> 646 <tr> 647 <td><hr size=3 noshade></td> 648 </tr> 649</table> 650|; 651 652 for (qw(action nextsub)) { delete $form->{$_} } 653 $form->{helpref} = $helpref; 654 655 $form->hide_form; 656 657 print qq| 658 659<br> 660<input type=hidden name=nextsub value=payment_selected> 661|; 662 663 if ($ok) { 664 print qq| 665<input class=submit type=submit name=action value="|.$locale->text('Continue').qq|">|; 666 } 667 668 print qq| 669</form> 670 671</body> 672</html> 673|; 674 675} 676 677sub payment_selected { 678 679 &{ "print_$form->{formname}" }($form->{oldform}, $form->{ndx}); 680 681} 682 683 684sub print_options { 685 686 if ($form->{selectlanguage}) { 687 $lang = qq|<select name=language_code>|.$form->select_option($form->{selectlanguage}, $form->{language_code}, undef, 1).qq|</select>|; 688 } 689 690 $type = qq|<select name=formname>|.$form->select_option($form->{selectformname}, $form->{formname}, undef, 1).qq|</select>|; 691 692 $media = qq|<select name=media> 693 <option value="screen">|.$locale->text('Screen'); 694 695 $selectformat = qq|<option value="html">|.$locale->text('html').qq| 696<option value="xml">|.$locale->text('XML').qq| 697<option value="txt">|.$locale->text('Text'); 698 699 if ($form->{selectprinter} && $latex) { 700 for (split /\n/, $form->unescape($form->{selectprinter})) { $media .= qq| 701 <option value="$_">$_| } 702 } 703 704 if ($latex) { 705 $selectformat .= qq| 706<option value="ps">|.$locale->text('Postscript').qq| 707<option value="pdf">|.$locale->text('PDF'); 708 } 709 710 $format = qq|<select name=format>$selectformat</select>|; 711 $format =~ s/(<option value="\Q$form->{format}\E")/$1 selected/; 712 713 $media .= qq|</select>|; 714 $media =~ s/(<option value="\Q$form->{media}\E")/$1 selected/; 715 716 $checked{printed} = "checked" if $form->{"$form->{formname}_printed"}; 717 $checked{onhold} = "checked" if $form->{onhold}; 718 719 if (!$form->{nohold}) { 720 $status = qq| 721 <tr> 722 <td align=right><input name="onhold" type="checkbox" class="checkbox" value="1" $checked{onhold}></td> 723 <th align=left nowrap>|.$locale->text('On Hold').qq|</font></th> 724 <td align=right><input name="$form->{formname}_printed" type="checkbox" class="checkbox" value="1" $checked{printed}></td> 725 <th align=left nowrap>|.$locale->text('Printed').qq|</th> 726 </tr> 727|; 728 } 729 730 if ($form->{recurring}) { 731 $recurring = qq| 732 <tr> 733 <td></td> 734 <th align=left nowrap>|.$locale->text('Scheduled').qq|</th> 735 </tr> 736|; 737 } 738 739 print qq| 740 <table width=100%> 741 <tr> 742 <td>$type</td> 743 <td>$lang</td> 744 <td>$format</td> 745 <td>$media</td> 746 <td align=right width=90%> 747 <table> 748 $status 749 $recurring 750 </table> 751 </td> 752 </tr> 753 </table> 754|; 755 756} 757 758 759sub print_and_post { 760 761 $form->error($locale->text('Select a Printer!')) if $form->{media} eq 'screen'; 762 763 $form->{printandpost} = 1; 764 $form->{display_form} = "post"; 765 766 if (! $form->{invnumber}) { 767 $invfld = 'sinumber'; 768 $invfld = 'vinumber' if $form->{ARAP} eq 'AP'; 769 $form->{invnumber} = $form->update_defaults(\%myconfig, $invfld); 770 } 771 772 &print; 773 774} 775 776 777