summaryrefslogtreecommitdiff
path: root/bin/arapprn.pl
blob: 397a624c24dc8afa1f2403b8cdab69ec60ac4539 (plain)
  1. #=====================================================================
  2. # LedgerSMB Small Medium Business Accounting
  3. # http://www.ledgersmb.org/
  4. #
  5. # Copyright (C) 2006
  6. # This work contains copyrighted information from a number of sources all used
  7. # with permission.
  8. #
  9. # This file contains source code included with or based on SQL-Ledger which
  10. # is Copyright Dieter Simader and DWS Systems Inc. 2000-2005 and licensed
  11. # under the GNU General Public License version 2 or, at your option, any later
  12. # version. For a full list including contact information of contributors,
  13. # maintainers, and copyright holders, see the CONTRIBUTORS file.
  14. #
  15. # Original Copyright Notice from SQL-Ledger 2.6.17 (before the fork):
  16. # Copyright (c) 2003
  17. #
  18. # Author: DWS Systems Inc.
  19. # Web: http://www.sql-ledger.org
  20. #
  21. #
  22. # This program is free software; you can redistribute it and/or modify
  23. # it under the terms of the GNU General Public License as published by
  24. # the Free Software Foundation; either version 2 of the License, or
  25. # (at your option) any later version.
  26. #
  27. # This program is distributed in the hope that it will be useful,
  28. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  29. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  30. # GNU General Public License for more details.
  31. # You should have received a copy of the GNU General Public License
  32. # along with this program; if not, write to the Free Software
  33. # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  34. #======================================================================
  35. #
  36. # This file has not undergone any whitespace cleanup.
  37. #
  38. # printing routines for ar, ap
  39. #
  40. # any custom scripts for this one
  41. if ( -f "bin/custom/arapprn.pl" ) {
  42. eval { require "bin/custom/arapprn.pl"; };
  43. }
  44. if ( -f "bin/custom/$form->{login}_arapprn.pl" ) {
  45. eval { require "bin/custom/$form->{login}_arapprn.pl"; };
  46. }
  47. 1;
  48. # end of main
  49. sub print {
  50. if ( $form->{media} !~ /screen/ ) {
  51. $form->error( $locale->text('Select postscript or PDF!') )
  52. if $form->{format} !~ /(postscript|pdf)/;
  53. $old_form = new Form;
  54. for ( keys %$form ) { $old_form->{$_} = $form->{$_} }
  55. }
  56. if ( $form->{formname} =~ /(check|receipt)/ ) {
  57. if ( $form->{media} eq 'screen' ) {
  58. $form->error( $locale->text('Select postscript or PDF!') )
  59. if $form->{format} !~ /(postscript|pdf)/;
  60. }
  61. }
  62. if ( !$form->{invnumber} ) {
  63. $invfld = 'sinumber';
  64. $invfld = 'vinumber' if $form->{ARAP} eq 'AP';
  65. $form->{invnumber} = $form->update_defaults( \%myconfig, $invfld );
  66. if ( $form->{media} eq 'screen' ) {
  67. if ( $form->{media} eq 'screen' ) {
  68. &update;
  69. exit;
  70. }
  71. }
  72. }
  73. if ( $form->{formname} =~ /(check|receipt)/ ) {
  74. if ( $form->{media} ne 'screen' ) {
  75. for (qw(action header)) { delete $form->{$_} }
  76. $form->{invtotal} = $form->{oldinvtotal};
  77. foreach $key ( keys %$form ) {
  78. $form->{$key} =~ s/&/%26/g;
  79. $form->{previousform} .= qq|$key=$form->{$key}&|;
  80. }
  81. chop $form->{previousform};
  82. $form->{previousform} = $form->escape( $form->{previousform}, 1 );
  83. }
  84. if ( $form->{paidaccounts} > 1 ) {
  85. if ( $form->{"paid_$form->{paidaccounts}"} ) {
  86. &update;
  87. exit;
  88. }
  89. elsif ( $form->{paidaccounts} > 2 ) {
  90. # select payment
  91. &select_payment;
  92. exit;
  93. }
  94. }
  95. else {
  96. $form->error( $locale->text('Nothing to print!') );
  97. }
  98. }
  99. if ( $filename = $queued{ $form->{formname} } ) {
  100. $form->{queued} =~ s/$form->{formname} $filename//;
  101. unlink "${LedgerSMB::Sysconfig::spool}/$filename";
  102. $filename =~ s/\..*$//g;
  103. }
  104. else {
  105. $filename = time;
  106. $filename .= $$;
  107. }
  108. $filename .= ( $form->{format} eq 'postscript' ) ? '.ps' : '.pdf';
  109. if ( $form->{media} ne 'screen' ) {
  110. $form->{OUT} = "${LedgerSMB::Sysconfig::spool}/$filename";
  111. $form->{printmode} = '>';
  112. }
  113. $form->{queued} .= " $form->{formname} $filename";
  114. $form->{queued} =~ s/^ //;
  115. $printform = new Form;
  116. for ( keys %$form ) {
  117. $printform->{$_} = $form->{$_};
  118. }
  119. if ( $form->{printandpost} ) {
  120. &post;
  121. }
  122. else {
  123. &{"print_$form->{formname}"}( $old_form, 1 );
  124. }
  125. }
  126. sub print_check {
  127. my ( $old_form, $i ) = @_;
  128. $display_form =
  129. ( $form->{display_form} ) ? $form->{display_form} : "display_form";
  130. if ( $form->{"paid_$i"} ) {
  131. @a = ();
  132. if ( exists $form->{longformat} ) {
  133. $form->{"datepaid_$i"} =
  134. $locale->date( \%myconfig, $form->{"datepaid_$i"},
  135. $form->{longformat} );
  136. }
  137. push @a, "source_$i", "memo_$i";
  138. $form->format_string(@a);
  139. }
  140. $form->{amount} = $form->{"paid_$i"};
  141. if ( ( $form->{formname} eq 'check' && $form->{vc} eq 'customer' )
  142. || ( $form->{formname} eq 'receipt' && $form->{vc} eq 'vendor' ) )
  143. {
  144. $form->{amount} =~ s/-//g;
  145. }
  146. for (qw(datepaid source memo)) { $form->{$_} = $form->{"${_}_$i"} }
  147. &{"$form->{vc}_details"};
  148. @a = qw(name address1 address2 city state zipcode country);
  149. foreach $item (qw(invnumber ordnumber)) {
  150. $temp{$item} = $form->{$item};
  151. delete $form->{$item};
  152. push( @{ $form->{$item} }, $temp{$item} );
  153. }
  154. push( @{ $form->{invdate} }, $form->{transdate} );
  155. push(
  156. @{ $form->{due} },
  157. $form->format_amount( \%myconfig, $form->{oldinvtotal}, 2 )
  158. );
  159. push( @{ $form->{paid} }, $form->{"paid_$i"} );
  160. use LedgerSMB::CP;
  161. $c =
  162. CP->new( ( $form->{language_code} )
  163. ? $form->{language_code}
  164. : $myconfig{countrycode} );
  165. $c->init;
  166. ( $whole, $form->{decimal} ) = split /\./,
  167. $form->parse_amount( \%myconfig, $form->{amount} );
  168. $form->{decimal} .= "00";
  169. $form->{decimal} = substr( $form->{decimal}, 0, 2 );
  170. $form->{text_decimal} = $c->num2text( $form->{decimal} * 1 );
  171. $form->{text_amount} = $c->num2text($whole);
  172. $form->{integer_amount} = $form->format_amount( $myconfig, $whole );
  173. ( $form->{employee} ) = split /--/, $form->{employee};
  174. $form->{notes} =~ s/^\s+//g;
  175. push @a, "notes";
  176. for (qw(company address tel fax businessnumber)) {
  177. $form->{$_} = $myconfig{$_};
  178. }
  179. $form->{address} =~ s/\\n/\n/g;
  180. push @a,
  181. qw(company address tel fax businessnumber text_amount text_decimal);
  182. $form->format_string(@a);
  183. $form->{templates} = "$myconfig{templates}";
  184. $form->{IN} =
  185. ( $form->{formname} eq 'transaction' )
  186. ? lc $form->{ARAP} . "_$form->{formname}.html"
  187. : "$form->{formname}.html";
  188. if ( $form->{format} =~ /(postscript|pdf)/ ) {
  189. $form->{IN} =~ s/html$/tex/;
  190. }
  191. if ( $form->{media} eq 'queue' ) {
  192. # save status
  193. $form->update_status( \%myconfig );
  194. $form->{queued} = $form->{queued};
  195. %audittrail = (
  196. tablename => ($order) ? 'oe' : lc $ARAP,
  197. reference => $form->{"${inv}number"},
  198. formname => $form->{formname},
  199. action => 'queued',
  200. id => $form->{id}
  201. );
  202. $form->{audittrail} .=
  203. $form->audittrail( "", \%myconfig, \%audittrail );
  204. $form->{OUT} = "${LedgerSMB::Sysconfig::spool}/$filename";
  205. $form->{printmode} = '>';
  206. $form->{queued} .= " $form->{formname} $filename";
  207. $form->{queued} =~ s/^ //;
  208. }
  209. if ( $form->{media} !~ /(screen|queue)/ ) {
  210. %queued = split / /, $form->{queued};
  211. $form->{OUT} = ${LedgerSMB::Sysconfig::printer}{ $form->{media} };
  212. $form->{printmode} = '|-';
  213. if ( $form->{printed} !~ /$form->{formname}/ ) {
  214. $form->{printed} .= " $form->{formname}";
  215. $form->{printed} =~ s/^ //;
  216. $form->update_status( \%myconfig );
  217. }
  218. %audittrail = (
  219. tablename => lc $form->{ARAP},
  220. reference => $form->{invnumber},
  221. formname => $form->{formname},
  222. action => 'printed',
  223. id => $form->{id}
  224. );
  225. %status = ();
  226. for (qw(printed audittrail)) { $status{$_} = $form->{$_} }
  227. $status{audittrail} .=
  228. $form->audittrail( "", \%myconfig, \%audittrail );
  229. }
  230. $form->{fileid} = $invnumber;
  231. $form->{fileid} =~ s/(\s|\W)+//g;
  232. $form->parse_template( \%myconfig );
  233. if ( $form->{previousform} ) {
  234. $previousform = $form->unescape( $form->{previousform} );
  235. for ( keys %$form ) { delete $form->{$_} }
  236. foreach $item ( split /&/, $previousform ) {
  237. ( $key, $value ) = split /=/, $item, 2;
  238. $value =~ s/%26/&/g;
  239. $form->{$key} = $value;
  240. }
  241. for (qw(exchangerate creditlimit creditremaining)) {
  242. $form->{$_} = $form->parse_amount( \%myconfig, $form->{$_} );
  243. }
  244. for ( 1 .. $form->{rowcount} ) {
  245. $form->{"amount_$_"} =
  246. $form->parse_amount( \%myconfig, $form->{"amount_$_"} );
  247. }
  248. for ( split / /, $form->{taxaccounts} ) {
  249. $form->{"tax_$_"} =
  250. $form->parse_amount( \%myconfig, $form->{"tax_$_"} );
  251. }
  252. for $i ( 1 .. $form->{paidaccounts} ) {
  253. for (qw(paid exchangerate)) {
  254. $form->{"${_}_$i"} =
  255. $form->parse_amount( \%myconfig, $form->{"${_}_$i"} );
  256. }
  257. }
  258. for (qw(printed audittrail)) { $form->{$_} = $status{$_} }
  259. &{"$display_form"};
  260. }
  261. }
  262. sub print_receipt {
  263. my ( $old_form, $i ) = @_;
  264. &print_check( $old_form, $i );
  265. }
  266. sub print_transaction {
  267. my ($old_form) = @_;
  268. $display_form =
  269. ( $form->{display_form} ) ? $form->{display_form} : "display_form";
  270. &{"$form->{vc}_details"};
  271. @a = qw(name address1 address2 city state zipcode country);
  272. $form->{invtotal} = 0;
  273. foreach $i ( 1 .. $form->{rowcount} - 1 ) {
  274. ( $form->{tempaccno}, $form->{tempaccount} ) = split /--/,
  275. $form->{"$form->{ARAP}_amount_$i"};
  276. ( $form->{tempprojectnumber} ) = split /--/,
  277. $form->{"projectnumber_$i"};
  278. $form->{tempdescription} = $form->{"description_$i"};
  279. $form->format_string(
  280. qw(tempaccno tempaccount tempprojectnumber tempdescription));
  281. push( @{ $form->{accno} }, $form->{tempaccno} );
  282. push( @{ $form->{account} }, $form->{tempaccount} );
  283. push( @{ $form->{description} }, $form->{tempdescription} );
  284. push( @{ $form->{projectnumber} }, $form->{tempprojectnumber} );
  285. push( @{ $form->{amount} }, $form->{"amount_$i"} );
  286. $form->{subtotal} +=
  287. $form->parse_amount( \%myconfig, $form->{"amount_$i"} );
  288. }
  289. foreach $accno ( split / /, $form->{taxaccounts} ) {
  290. if ( $form->{"tax_$accno"} ) {
  291. $form->format_string("${accno}_description");
  292. $tax += $form->parse_amount( \%myconfig, $form->{"tax_$accno"} );
  293. $form->{"${accno}_tax"} = $form->{"tax_$accno"};
  294. push( @{ $form->{tax} }, $form->{"tax_$accno"} );
  295. push(
  296. @{ $form->{taxdescription} },
  297. $form->{"${accno}_description"}
  298. );
  299. $form->{"${accno}_taxrate"} =
  300. $form->format_amount( $myconfig, $form->{"${accno}_rate"} * 100 );
  301. push( @{ $form->{taxrate} }, $form->{"${accno}_taxrate"} );
  302. push( @{ $form->{taxnumber} }, $form->{"${accno}_taxnumber"} );
  303. }
  304. }
  305. $tax = 0 if $form->{taxincluded};
  306. push @a, $form->{ARAP};
  307. $form->format_string(@a);
  308. $form->{paid} = 0;
  309. for $i ( 1 .. $form->{paidaccounts} - 1 ) {
  310. if ( $form->{"paid_$i"} ) {
  311. @a = ();
  312. $form->{paid} +=
  313. $form->parse_amount( \%myconfig, $form->{"paid_$i"} );
  314. if ( exists $form->{longformat} ) {
  315. $form->{"datepaid_$i"} =
  316. $locale->date( \%myconfig, $form->{"datepaid_$i"},
  317. $form->{longformat} );
  318. }
  319. push @a, "$form->{ARAP}_paid_$i", "source_$i", "memo_$i";
  320. $form->format_string(@a);
  321. ( $accno, $account ) = split /--/, $form->{"$form->{ARAP}_paid_$i"};
  322. push( @{ $form->{payment} }, $form->{"paid_$i"} );
  323. push( @{ $form->{paymentdate} }, $form->{"datepaid_$i"} );
  324. push( @{ $form->{paymentaccount} }, $account );
  325. push( @{ $form->{paymentsource} }, $form->{"source_$i"} );
  326. push( @{ $form->{paymentmemo} }, $form->{"memo_$i"} );
  327. }
  328. }
  329. $form->{invtotal} = $form->{subtotal} + $tax;
  330. $form->{total} = $form->{invtotal} - $form->{paid};
  331. use LedgerSMB::CP;
  332. $c =
  333. CP->new( ( $form->{language_code} )
  334. ? $form->{language_code}
  335. : $myconfig{countrycode} );
  336. $c->init;
  337. ( $whole, $form->{decimal} ) = split /\./, $form->{invtotal};
  338. $form->{decimal} .= "00";
  339. $form->{decimal} = substr( $form->{decimal}, 0, 2 );
  340. $form->{text_decimal} = $c->num2text( $form->{decimal} * 1 );
  341. $form->{text_amount} = $c->num2text($whole);
  342. $form->{integer_amount} = $form->format_amount( $myconfig, $whole );
  343. for (qw(invtotal subtotal paid total)) {
  344. $form->{$_} = $form->format_amount( \%myconfig, $form->{$_}, 2 );
  345. }
  346. ( $form->{employee} ) = split /--/, $form->{employee};
  347. if ( exists $form->{longformat} ) {
  348. for (qw(duedate transdate)) {
  349. $form->{$_} =
  350. $locale->date( \%myconfig, $form->{$_}, $form->{longformat} );
  351. }
  352. }
  353. $form->{notes} =~ s/^\s+//g;
  354. @a = ( "invnumber", "transdate", "duedate", "notes" );
  355. for (qw(company address tel fax businessnumber)) {
  356. $form->{$_} = $myconfig{$_};
  357. }
  358. $form->{address} =~ s/\\n/\n/g;
  359. push @a,
  360. qw(company address tel fax businessnumber text_amount text_decimal);
  361. $form->format_string(@a);
  362. $form->{invdate} = $form->{transdate};
  363. $form->{templates} = "$myconfig{templates}";
  364. $form->{IN} =
  365. ( $form->{formname} eq 'transaction' )
  366. ? lc $form->{ARAP} . "_$form->{formname}.html"
  367. : "$form->{formname}.html";
  368. if ( $form->{format} =~ /(postscript|pdf)/ ) {
  369. $form->{IN} =~ s/html$/tex/;
  370. }
  371. if ( $form->{media} eq 'queue' ) {
  372. %queued = split / /, $form->{queued};
  373. if ( $filename = $queued{ $form->{formname} } ) {
  374. $form->{queued} =~ s/$form->{formname} $filename//;
  375. unlink "${LedgerSMB::Sysconfig::spool}/$filename";
  376. $filename =~ s/\..*$//g;
  377. }
  378. else {
  379. $filename = time;
  380. $filename .= $$;
  381. }
  382. $filename .= ( $form->{format} eq 'postscript' ) ? '.ps' : '.pdf';
  383. $form->{OUT} = "${LedgerSMB::Sysconfig::spool}/$filename";
  384. $form->{printmode} = '>';
  385. $form->{queued} .= " $form->{formname} $filename";
  386. $form->{queued} =~ s/^ //;
  387. # save status
  388. $form->update_status( \%myconfig );
  389. $old_form->{queued} = $form->{queued};
  390. %audittrail = (
  391. tablename => ($order) ? 'oe' : lc $ARAP,
  392. reference => $form->{"${inv}number"},
  393. formname => $form->{formname},
  394. action => 'queued',
  395. id => $form->{id}
  396. );
  397. $old_form->{audittrail} .=
  398. $form->audittrail( "", \%myconfig, \%audittrail );
  399. }
  400. if ( $form->{media} !~ /(queue|screen)/ ) {
  401. $form->{OUT} = ${LedgerSMB::Sysconfig::printer}{ $form->{media} };
  402. $form->{printmode} = '|-';
  403. if ( $form->{printed} !~ /$form->{formname}/ ) {
  404. $form->{printed} .= " $form->{formname}";
  405. $form->{printed} =~ s/^ //;
  406. $form->update_status( \%myconfig );
  407. }
  408. $old_form->{printed} = $form->{printed} if %$old_form;
  409. %audittrail = (
  410. tablename => lc $form->{ARAP},
  411. reference => $form->{"invnumber"},
  412. formname => $form->{formname},
  413. action => 'printed',
  414. id => $form->{id}
  415. );
  416. $old_form->{audittrail} .=
  417. $form->audittrail( "", \%myconfig, \%audittrail )
  418. if %$old_form;
  419. }
  420. $form->{fileid} = $form->{invnumber};
  421. $form->{fileid} =~ s/(\s|\W)+//g;
  422. $form->parse_template( \%myconfig );
  423. if (%$old_form) {
  424. $old_form->{invnumber} = $form->{invnumber};
  425. $old_form->{invtotal} = $form->{invtotal};
  426. for ( keys %$form ) { delete $form->{$_} }
  427. for ( keys %$old_form ) { $form->{$_} = $old_form->{$_} }
  428. if ( !$form->{printandpost} ) {
  429. for (qw(exchangerate creditlimit creditremaining)) {
  430. $form->{$_} = $form->parse_amount( \%myconfig, $form->{$_} );
  431. }
  432. for ( 1 .. $form->{rowcount} ) {
  433. $form->{"amount_$_"} =
  434. $form->parse_amount( \%myconfig, $form->{"amount_$_"} );
  435. }
  436. for ( split / /, $form->{taxaccounts} ) {
  437. $form->{"tax_$_"} =
  438. $form->parse_amount( \%myconfig, $form->{"tax_$_"} );
  439. }
  440. for $i ( 1 .. $form->{paidaccounts} ) {
  441. for (qw(paid exchangerate)) {
  442. $form->{"${_}_$i"} =
  443. $form->parse_amount( \%myconfig, $form->{"${_}_$i"} );
  444. }
  445. }
  446. }
  447. &{"$display_form"};
  448. }
  449. }
  450. sub vendor_details { IR->vendor_details( \%myconfig, \%$form ) }
  451. sub customer_details { IS->customer_details( \%myconfig, \%$form ) }
  452. sub select_payment {
  453. @column_index =
  454. ( "ndx", "datepaid", "source", "memo", "paid", "$form->{ARAP}_paid" );
  455. # list payments with radio button on a form
  456. $form->header;
  457. $title = $locale->text('Select payment');
  458. $column_data{ndx} = qq|<th width=1%>&nbsp;</th>|;
  459. $column_data{datepaid} = qq|<th>| . $locale->text('Date') . qq|</th>|;
  460. $column_data{source} = qq|<th>| . $locale->text('Source') . qq|</th>|;
  461. $column_data{memo} = qq|<th>| . $locale->text('Memo') . qq|</th>|;
  462. $column_data{paid} = qq|<th>| . $locale->text('Amount') . qq|</th>|;
  463. $column_data{"$form->{ARAP}_paid"} =
  464. qq|<th>| . $locale->text('Account') . qq|</th>|;
  465. print qq|
  466. <body>
  467. <form method=post action=$form->{script}>
  468. <table width=100%>
  469. <tr>
  470. <th class=listtop>$title</th>
  471. </tr>
  472. <tr space=5></tr>
  473. <tr>
  474. <td>
  475. <table width=100%>
  476. <tr class=listheading>|;
  477. for (@column_index) { print "\n$column_data{$_}" }
  478. print qq|
  479. </tr>
  480. |;
  481. $checked = "checked";
  482. foreach $i ( 1 .. $form->{paidaccounts} - 1 ) {
  483. for (@column_index) {
  484. $column_data{$_} = qq|<td>$form->{"${_}_$i"}</td>|;
  485. }
  486. $paid = $form->{"paid_$i"};
  487. $ok = 1;
  488. $column_data{ndx} =
  489. qq|<td><input name=ndx class=radio type=radio value=$i $checked></td>|;
  490. $column_data{paid} = qq|<td align=right>$paid</td>|;
  491. $checked = "";
  492. $j++;
  493. $j %= 2;
  494. print qq|
  495. <tr class=listrow$j>|;
  496. for (@column_index) { print "\n$column_data{$_}" }
  497. print qq|
  498. </tr>
  499. |;
  500. }
  501. print qq|
  502. </table>
  503. </td>
  504. </tr>
  505. <tr>
  506. <td><hr size=3 noshade></td>
  507. </tr>
  508. </table>
  509. |;
  510. for (qw(action nextsub)) { delete $form->{$_} }
  511. $form->hide_form;
  512. print qq|
  513. <br>
  514. <input type=hidden name=nextsub value=payment_selected>
  515. |;
  516. if ($ok) {
  517. print qq|
  518. <button class="submit" type="submit" name="action" value="continue">|
  519. . $locale->text('Continue')
  520. . qq|</button>|;
  521. }
  522. print qq|
  523. </form>
  524. </body>
  525. </html>
  526. |;
  527. }
  528. sub payment_selected {
  529. &{"print_$form->{formname}"}( $form->{oldform}, $form->{ndx} );
  530. }
  531. sub print_options {
  532. if ( $form->{selectlanguage} ) {
  533. $form->{"selectlanguage"} =
  534. $form->unescape( $form->{"selectlanguage"} );
  535. $form->{"selectlanguage"} =~ s/ selected//;
  536. $form->{"selectlanguage"} =~
  537. s/(<option value="\Q$form->{language_code}\E")/$1 selected/;
  538. $lang = qq|<select name=language_code>$form->{selectlanguage}</select>
  539. <input type=hidden name=selectlanguage value="|
  540. . $form->escape( $form->{selectlanguage}, 1 ) . qq|">|;
  541. }
  542. $form->{selectformname} = $form->unescape( $form->{selectformname} );
  543. $form->{selectformname} =~ s/ selected//;
  544. $form->{selectformname} =~
  545. s/(<option value="\Q$form->{formname}\E")/$1 selected/;
  546. $type = qq|<select name=formname>$form->{selectformname}</select>
  547. <input type=hidden name=selectformname value="|
  548. . $form->escape( $form->{selectformname}, 1 ) . qq|">|;
  549. $media = qq|<select name=media>
  550. <option value="screen">| . $locale->text('Screen');
  551. $form->{selectformat} = qq|<option value="html">html\n|;
  552. if ( %{LedgerSMB::Sysconfig::printer} && ${LedgerSMB::Sysconfig::latex} ) {
  553. for ( sort keys %{LedgerSMB::Sysconfig::printer} ) {
  554. $media .= qq|
  555. <option value="$_">$_|;
  556. }
  557. }
  558. if ( ${LedgerSMB::Sysconfig::latex} ) {
  559. $form->{selectformat} .= qq|
  560. <option value="postscript">| . $locale->text('Postscript') . qq|
  561. <option value="pdf">| . $locale->text('PDF');
  562. $media .= qq|<option value="queue">| . $locale->text('Queue');
  563. }
  564. $format = qq|<select name=format>$form->{selectformat}</select>|;
  565. $format =~ s/(<option value="\Q$form->{format}\E")/$1 selected/;
  566. $format .= qq|
  567. <input type=hidden name=selectformat value="|
  568. . $form->escape( $form->{selectformat}, 1 ) . qq|">|;
  569. $media .= qq|</select>|;
  570. $media =~ s/(<option value="\Q$form->{media}\E")/$1 selected/;
  571. print qq|
  572. <table width=100%>
  573. <tr>
  574. <td>$type</td>
  575. <td>$lang</td>
  576. <td>$format</td>
  577. <td>$media</td>
  578. <td align=right width=90%>
  579. |;
  580. if ( $form->{printed} =~ /$form->{formname}/ ) {
  581. print $locale->text('Printed') . qq|<br>|;
  582. }
  583. if ( $form->{recurring} ) {
  584. print $locale->text('Scheduled');
  585. }
  586. print qq|
  587. </td>
  588. </tr>
  589. </table>
  590. |;
  591. }
  592. sub print_and_post {
  593. $form->error( $locale->text('Select postscript or PDF!') )
  594. if $form->{format} !~ /(postscript|pdf)/;
  595. $form->error( $locale->text('Select a Printer!') )
  596. if $form->{media} eq 'screen';
  597. $form->{printandpost} = 1;
  598. $form->{display_form} = "post";
  599. &print;
  600. }