summaryrefslogtreecommitdiff
path: root/bin/arapprn.pl
blob: 2d5bf18936fb79d342572ff863a0e45ef9560889 (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. delete $form->{printandpost};
  121. $form->{action} = 'post';
  122. &post;
  123. }
  124. else {
  125. &{"print_$form->{formname}"}( $old_form, 1 );
  126. }
  127. }
  128. sub print_check {
  129. my ( $old_form, $i ) = @_;
  130. $display_form =
  131. ( $form->{display_form} ) ? $form->{display_form} : "display_form";
  132. if ( $form->{"paid_$i"} ) {
  133. @a = ();
  134. if ( exists $form->{longformat} ) {
  135. $form->{"datepaid_$i"} =
  136. $locale->date( \%myconfig, $form->{"datepaid_$i"},
  137. $form->{longformat} );
  138. }
  139. push @a, "source_$i", "memo_$i";
  140. $form->format_string(@a);
  141. }
  142. $form->{amount} = $form->{"paid_$i"};
  143. if ( ( $form->{formname} eq 'check' && $form->{vc} eq 'customer' )
  144. || ( $form->{formname} eq 'receipt' && $form->{vc} eq 'vendor' ) )
  145. {
  146. $form->{amount} =~ s/-//g;
  147. }
  148. for (qw(datepaid source memo)) { $form->{$_} = $form->{"${_}_$i"} }
  149. &{"$form->{vc}_details"};
  150. @a = qw(name address1 address2 city state zipcode country);
  151. foreach $item (qw(invnumber ordnumber)) {
  152. $temp{$item} = $form->{$item};
  153. delete $form->{$item};
  154. push( @{ $form->{$item} }, $temp{$item} );
  155. }
  156. push( @{ $form->{invdate} }, $form->{transdate} );
  157. push(
  158. @{ $form->{due} },
  159. $form->format_amount( \%myconfig, $form->{oldinvtotal}, 2 )
  160. );
  161. push( @{ $form->{paid} }, $form->{"paid_$i"} );
  162. use LedgerSMB::CP;
  163. $c =
  164. CP->new( ( $form->{language_code} )
  165. ? $form->{language_code}
  166. : $myconfig{countrycode} );
  167. $c->init;
  168. ( $whole, $form->{decimal} ) = split /\./,
  169. $form->parse_amount( \%myconfig, $form->{amount} );
  170. $form->{decimal} .= "00";
  171. $form->{decimal} = substr( $form->{decimal}, 0, 2 );
  172. $form->{text_decimal} = $c->num2text( $form->{decimal} * 1 );
  173. $form->{text_amount} = $c->num2text($whole);
  174. $form->{integer_amount} = $form->format_amount( $myconfig, $whole );
  175. ( $form->{employee} ) = split /--/, $form->{employee};
  176. $form->{notes} =~ s/^\s+//g;
  177. push @a, "notes";
  178. for (qw(company address tel fax businessnumber)) {
  179. $form->{$_} = $myconfig{$_};
  180. }
  181. $form->{address} =~ s/\\n/\n/g;
  182. push @a,
  183. qw(company address tel fax businessnumber text_amount text_decimal);
  184. $form->format_string(@a);
  185. $form->{templates} = "$myconfig{templates}";
  186. $form->{IN} =
  187. ( $form->{formname} eq 'transaction' )
  188. ? lc $form->{ARAP} . "_$form->{formname}.html"
  189. : "$form->{formname}.html";
  190. if ( $form->{format} =~ /(postscript|pdf)/ ) {
  191. $form->{IN} =~ s/html$/tex/;
  192. }
  193. if ( $form->{media} eq 'queue' ) {
  194. # save status
  195. $form->update_status( \%myconfig );
  196. $form->{queued} = $form->{queued};
  197. %audittrail = (
  198. tablename => ($order) ? 'oe' : lc $ARAP,
  199. reference => $form->{"${inv}number"},
  200. formname => $form->{formname},
  201. action => 'queued',
  202. id => $form->{id}
  203. );
  204. $form->{audittrail} .=
  205. $form->audittrail( "", \%myconfig, \%audittrail );
  206. $form->{OUT} = "${LedgerSMB::Sysconfig::spool}/$filename";
  207. $form->{printmode} = '>';
  208. $form->{queued} .= " $form->{formname} $filename";
  209. $form->{queued} =~ s/^ //;
  210. }
  211. if ( $form->{media} !~ /(screen|queue)/ ) {
  212. %queued = split / /, $form->{queued};
  213. $form->{OUT} = ${LedgerSMB::Sysconfig::printer}{ $form->{media} };
  214. $form->{printmode} = '|-';
  215. if ( $form->{printed} !~ /$form->{formname}/ ) {
  216. $form->{printed} .= " $form->{formname}";
  217. $form->{printed} =~ s/^ //;
  218. $form->update_status( \%myconfig );
  219. }
  220. %audittrail = (
  221. tablename => lc $form->{ARAP},
  222. reference => $form->{invnumber},
  223. formname => $form->{formname},
  224. action => 'printed',
  225. id => $form->{id}
  226. );
  227. %status = ();
  228. for (qw(printed audittrail)) { $status{$_} = $form->{$_} }
  229. $status{audittrail} .=
  230. $form->audittrail( "", \%myconfig, \%audittrail );
  231. }
  232. $form->{fileid} = $invnumber;
  233. $form->{fileid} =~ s/(\s|\W)+//g;
  234. $form->parse_template( \%myconfig );
  235. if ( $form->{previousform} ) {
  236. $previousform = $form->unescape( $form->{previousform} );
  237. for ( keys %$form ) { delete $form->{$_} }
  238. foreach $item ( split /&/, $previousform ) {
  239. ( $key, $value ) = split /=/, $item, 2;
  240. $value =~ s/%26/&/g;
  241. $form->{$key} = $value;
  242. }
  243. for (qw(exchangerate creditlimit creditremaining)) {
  244. $form->{$_} = $form->parse_amount( \%myconfig, $form->{$_} );
  245. }
  246. for ( 1 .. $form->{rowcount} ) {
  247. $form->{"amount_$_"} =
  248. $form->parse_amount( \%myconfig, $form->{"amount_$_"} );
  249. }
  250. for ( split / /, $form->{taxaccounts} ) {
  251. $form->{"tax_$_"} =
  252. $form->parse_amount( \%myconfig, $form->{"tax_$_"} );
  253. }
  254. for $i ( 1 .. $form->{paidaccounts} ) {
  255. for (qw(paid exchangerate)) {
  256. $form->{"${_}_$i"} =
  257. $form->parse_amount( \%myconfig, $form->{"${_}_$i"} );
  258. }
  259. }
  260. for (qw(printed audittrail)) { $form->{$_} = $status{$_} }
  261. &{"$display_form"};
  262. }
  263. }
  264. sub print_receipt {
  265. my ( $old_form, $i ) = @_;
  266. &print_check( $old_form, $i );
  267. }
  268. sub print_transaction {
  269. my ($old_form) = @_;
  270. $display_form =
  271. ( $form->{display_form} ) ? $form->{display_form} : "display_form";
  272. &{"$form->{vc}_details"};
  273. @a = qw(name address1 address2 city state zipcode country);
  274. $form->{invtotal} = 0;
  275. foreach $i ( 1 .. $form->{rowcount} - 1 ) {
  276. ( $form->{tempaccno}, $form->{tempaccount} ) = split /--/,
  277. $form->{"$form->{ARAP}_amount_$i"};
  278. ( $form->{tempprojectnumber} ) = split /--/,
  279. $form->{"projectnumber_$i"};
  280. $form->{tempdescription} = $form->{"description_$i"};
  281. $form->format_string(
  282. qw(tempaccno tempaccount tempprojectnumber tempdescription));
  283. push( @{ $form->{accno} }, $form->{tempaccno} );
  284. push( @{ $form->{account} }, $form->{tempaccount} );
  285. push( @{ $form->{description} }, $form->{tempdescription} );
  286. push( @{ $form->{projectnumber} }, $form->{tempprojectnumber} );
  287. push( @{ $form->{amount} }, $form->{"amount_$i"} );
  288. $form->{subtotal} +=
  289. $form->parse_amount( \%myconfig, $form->{"amount_$i"} );
  290. }
  291. foreach $accno ( split / /, $form->{taxaccounts} ) {
  292. if ( $form->{"tax_$accno"} ) {
  293. $form->format_string("${accno}_description");
  294. $tax += $form->parse_amount( \%myconfig, $form->{"tax_$accno"} );
  295. $form->{"${accno}_tax"} = $form->{"tax_$accno"};
  296. push( @{ $form->{tax} }, $form->{"tax_$accno"} );
  297. push(
  298. @{ $form->{taxdescription} },
  299. $form->{"${accno}_description"}
  300. );
  301. $form->{"${accno}_taxrate"} =
  302. $form->format_amount( $myconfig, $form->{"${accno}_rate"} * 100 );
  303. push( @{ $form->{taxrate} }, $form->{"${accno}_taxrate"} );
  304. push( @{ $form->{taxnumber} }, $form->{"${accno}_taxnumber"} );
  305. }
  306. }
  307. $tax = 0 if $form->{taxincluded};
  308. push @a, $form->{ARAP};
  309. $form->format_string(@a);
  310. $form->{paid} = 0;
  311. for $i ( 1 .. $form->{paidaccounts} - 1 ) {
  312. if ( $form->{"paid_$i"} ) {
  313. @a = ();
  314. $form->{paid} +=
  315. $form->parse_amount( \%myconfig, $form->{"paid_$i"} );
  316. if ( exists $form->{longformat} ) {
  317. $form->{"datepaid_$i"} =
  318. $locale->date( \%myconfig, $form->{"datepaid_$i"},
  319. $form->{longformat} );
  320. }
  321. push @a, "$form->{ARAP}_paid_$i", "source_$i", "memo_$i";
  322. $form->format_string(@a);
  323. ( $accno, $account ) = split /--/, $form->{"$form->{ARAP}_paid_$i"};
  324. push( @{ $form->{payment} }, $form->{"paid_$i"} );
  325. push( @{ $form->{paymentdate} }, $form->{"datepaid_$i"} );
  326. push( @{ $form->{paymentaccount} }, $account );
  327. push( @{ $form->{paymentsource} }, $form->{"source_$i"} );
  328. push( @{ $form->{paymentmemo} }, $form->{"memo_$i"} );
  329. }
  330. }
  331. $form->{invtotal} = $form->{subtotal} + $tax;
  332. $form->{total} = $form->{invtotal} - $form->{paid};
  333. use LedgerSMB::CP;
  334. $c =
  335. CP->new( ( $form->{language_code} )
  336. ? $form->{language_code}
  337. : $myconfig{countrycode} );
  338. $c->init;
  339. ( $whole, $form->{decimal} ) = split /\./, $form->{invtotal};
  340. $form->{decimal} .= "00";
  341. $form->{decimal} = substr( $form->{decimal}, 0, 2 );
  342. $form->{text_decimal} = $c->num2text( $form->{decimal} * 1 );
  343. $form->{text_amount} = $c->num2text($whole);
  344. $form->{integer_amount} = $form->format_amount( $myconfig, $whole );
  345. for (qw(invtotal subtotal paid total)) {
  346. $form->{$_} = $form->format_amount( \%myconfig, $form->{$_}, 2 );
  347. }
  348. ( $form->{employee} ) = split /--/, $form->{employee};
  349. if ( exists $form->{longformat} ) {
  350. for (qw(duedate transdate)) {
  351. $form->{$_} =
  352. $locale->date( \%myconfig, $form->{$_}, $form->{longformat} );
  353. }
  354. }
  355. $form->{notes} =~ s/^\s+//g;
  356. @a = ( "invnumber", "transdate", "duedate", "notes" );
  357. for (qw(company address tel fax businessnumber)) {
  358. $form->{$_} = $myconfig{$_};
  359. }
  360. $form->{address} =~ s/\\n/\n/g;
  361. push @a,
  362. qw(company address tel fax businessnumber text_amount text_decimal);
  363. $form->format_string(@a);
  364. $form->{invdate} = $form->{transdate};
  365. $form->{templates} = "$myconfig{templates}";
  366. $form->{IN} =
  367. ( $form->{formname} eq 'transaction' )
  368. ? lc $form->{ARAP} . "_$form->{formname}.html"
  369. : "$form->{formname}.html";
  370. if ( $form->{format} =~ /(postscript|pdf)/ ) {
  371. $form->{IN} =~ s/html$/tex/;
  372. }
  373. if ( $form->{media} eq 'queue' ) {
  374. %queued = split / /, $form->{queued};
  375. if ( $filename = $queued{ $form->{formname} } ) {
  376. $form->{queued} =~ s/$form->{formname} $filename//;
  377. unlink "${LedgerSMB::Sysconfig::spool}/$filename";
  378. $filename =~ s/\..*$//g;
  379. }
  380. else {
  381. $filename = time;
  382. $filename .= $$;
  383. }
  384. $filename .= ( $form->{format} eq 'postscript' ) ? '.ps' : '.pdf';
  385. $form->{OUT} = "${LedgerSMB::Sysconfig::spool}/$filename";
  386. $form->{printmode} = '>';
  387. $form->{queued} .= " $form->{formname} $filename";
  388. $form->{queued} =~ s/^ //;
  389. # save status
  390. $form->update_status( \%myconfig );
  391. $old_form->{queued} = $form->{queued};
  392. %audittrail = (
  393. tablename => ($order) ? 'oe' : lc $ARAP,
  394. reference => $form->{"${inv}number"},
  395. formname => $form->{formname},
  396. action => 'queued',
  397. id => $form->{id}
  398. );
  399. $old_form->{audittrail} .=
  400. $form->audittrail( "", \%myconfig, \%audittrail );
  401. }
  402. if ( $form->{media} !~ /(queue|screen)/ ) {
  403. $form->{OUT} = ${LedgerSMB::Sysconfig::printer}{ $form->{media} };
  404. $form->{printmode} = '|-';
  405. if ( $form->{printed} !~ /$form->{formname}/ ) {
  406. $form->{printed} .= " $form->{formname}";
  407. $form->{printed} =~ s/^ //;
  408. $form->update_status( \%myconfig );
  409. }
  410. $old_form->{printed} = $form->{printed} if %$old_form;
  411. %audittrail = (
  412. tablename => lc $form->{ARAP},
  413. reference => $form->{"invnumber"},
  414. formname => $form->{formname},
  415. action => 'printed',
  416. id => $form->{id}
  417. );
  418. $old_form->{audittrail} .=
  419. $form->audittrail( "", \%myconfig, \%audittrail )
  420. if %$old_form;
  421. }
  422. $form->{fileid} = $form->{invnumber};
  423. $form->{fileid} =~ s/(\s|\W)+//g;
  424. $form->parse_template( \%myconfig );
  425. if (%$old_form) {
  426. $old_form->{invnumber} = $form->{invnumber};
  427. $old_form->{invtotal} = $form->{invtotal};
  428. for ( keys %$form ) { delete $form->{$_} }
  429. for ( keys %$old_form ) { $form->{$_} = $old_form->{$_} }
  430. if ( !$form->{printandpost} ) {
  431. for (qw(exchangerate creditlimit creditremaining)) {
  432. $form->{$_} = $form->parse_amount( \%myconfig, $form->{$_} );
  433. }
  434. for ( 1 .. $form->{rowcount} ) {
  435. $form->{"amount_$_"} =
  436. $form->parse_amount( \%myconfig, $form->{"amount_$_"} );
  437. }
  438. for ( split / /, $form->{taxaccounts} ) {
  439. $form->{"tax_$_"} =
  440. $form->parse_amount( \%myconfig, $form->{"tax_$_"} );
  441. }
  442. for $i ( 1 .. $form->{paidaccounts} ) {
  443. for (qw(paid exchangerate)) {
  444. $form->{"${_}_$i"} =
  445. $form->parse_amount( \%myconfig, $form->{"${_}_$i"} );
  446. }
  447. }
  448. }
  449. &{"$display_form"};
  450. }
  451. }
  452. sub vendor_details { IR->vendor_details( \%myconfig, \%$form ) }
  453. sub customer_details { IS->customer_details( \%myconfig, \%$form ) }
  454. sub select_payment {
  455. @column_index =
  456. ( "ndx", "datepaid", "source", "memo", "paid", "$form->{ARAP}_paid" );
  457. # list payments with radio button on a form
  458. $form->header;
  459. $title = $locale->text('Select payment');
  460. $column_data{ndx} = qq|<th width=1%>&nbsp;</th>|;
  461. $column_data{datepaid} = qq|<th>| . $locale->text('Date') . qq|</th>|;
  462. $column_data{source} = qq|<th>| . $locale->text('Source') . qq|</th>|;
  463. $column_data{memo} = qq|<th>| . $locale->text('Memo') . qq|</th>|;
  464. $column_data{paid} = qq|<th>| . $locale->text('Amount') . qq|</th>|;
  465. $column_data{"$form->{ARAP}_paid"} =
  466. qq|<th>| . $locale->text('Account') . qq|</th>|;
  467. print qq|
  468. <body>
  469. <form method=post action=$form->{script}>
  470. <table width=100%>
  471. <tr>
  472. <th class=listtop>$title</th>
  473. </tr>
  474. <tr space=5></tr>
  475. <tr>
  476. <td>
  477. <table width=100%>
  478. <tr class=listheading>|;
  479. for (@column_index) { print "\n$column_data{$_}" }
  480. print qq|
  481. </tr>
  482. |;
  483. $checked = "checked";
  484. foreach $i ( 1 .. $form->{paidaccounts} - 1 ) {
  485. for (@column_index) {
  486. $column_data{$_} = qq|<td>$form->{"${_}_$i"}</td>|;
  487. }
  488. $paid = $form->{"paid_$i"};
  489. $ok = 1;
  490. $column_data{ndx} =
  491. qq|<td><input name=ndx class=radio type=radio value=$i $checked></td>|;
  492. $column_data{paid} = qq|<td align=right>$paid</td>|;
  493. $checked = "";
  494. $j++;
  495. $j %= 2;
  496. print qq|
  497. <tr class=listrow$j>|;
  498. for (@column_index) { print "\n$column_data{$_}" }
  499. print qq|
  500. </tr>
  501. |;
  502. }
  503. print qq|
  504. </table>
  505. </td>
  506. </tr>
  507. <tr>
  508. <td><hr size=3 noshade></td>
  509. </tr>
  510. </table>
  511. |;
  512. for (qw(action nextsub)) { delete $form->{$_} }
  513. $form->hide_form;
  514. print qq|
  515. <br>
  516. <input type=hidden name=nextsub value=payment_selected>
  517. |;
  518. if ($ok) {
  519. print qq|
  520. <button class="submit" type="submit" name="action" value="continue">|
  521. . $locale->text('Continue')
  522. . qq|</button>|;
  523. }
  524. print qq|
  525. </form>
  526. </body>
  527. </html>
  528. |;
  529. }
  530. sub payment_selected {
  531. &{"print_$form->{formname}"}( $form->{oldform}, $form->{ndx} );
  532. }
  533. sub print_options {
  534. if ( $form->{selectlanguage} ) {
  535. $form->{"selectlanguage"} =
  536. $form->unescape( $form->{"selectlanguage"} );
  537. $form->{"selectlanguage"} =~ s/ selected//;
  538. $form->{"selectlanguage"} =~
  539. s/(<option value="\Q$form->{language_code}\E")/$1 selected/;
  540. $lang = qq|<select name=language_code>$form->{selectlanguage}</select>
  541. <input type=hidden name=selectlanguage value="|
  542. . $form->escape( $form->{selectlanguage}, 1 ) . qq|">|;
  543. }
  544. $form->{selectformname} = $form->unescape( $form->{selectformname} );
  545. $form->{selectformname} =~ s/ selected//;
  546. $form->{selectformname} =~
  547. s/(<option value="\Q$form->{formname}\E")/$1 selected/;
  548. $type = qq|<select name=formname>$form->{selectformname}</select>
  549. <input type=hidden name=selectformname value="|
  550. . $form->escape( $form->{selectformname}, 1 ) . qq|">|;
  551. $media = qq|<select name=media>
  552. <option value="screen">| . $locale->text('Screen');
  553. $form->{selectformat} = qq|<option value="html">html\n|;
  554. if ( %{LedgerSMB::Sysconfig::printer} && ${LedgerSMB::Sysconfig::latex} ) {
  555. for ( sort keys %{LedgerSMB::Sysconfig::printer} ) {
  556. $media .= qq|
  557. <option value="$_">$_|;
  558. }
  559. }
  560. if ( ${LedgerSMB::Sysconfig::latex} ) {
  561. $form->{selectformat} .= qq|
  562. <option value="postscript">| . $locale->text('Postscript') . qq|
  563. <option value="pdf">| . $locale->text('PDF');
  564. $media .= qq|<option value="queue">| . $locale->text('Queue');
  565. }
  566. $format = qq|<select name=format>$form->{selectformat}</select>|;
  567. $format =~ s/(<option value="\Q$form->{format}\E")/$1 selected/;
  568. $format .= qq|
  569. <input type=hidden name=selectformat value="|
  570. . $form->escape( $form->{selectformat}, 1 ) . qq|">|;
  571. $media .= qq|</select>|;
  572. $media =~ s/(<option value="\Q$form->{media}\E")/$1 selected/;
  573. print qq|
  574. <table width=100%>
  575. <tr>
  576. <td>$type</td>
  577. <td>$lang</td>
  578. <td>$format</td>
  579. <td>$media</td>
  580. <td align=right width=90%>
  581. |;
  582. if ( $form->{printed} =~ /$form->{formname}/ ) {
  583. print $locale->text('Printed') . qq|<br>|;
  584. }
  585. if ( $form->{recurring} ) {
  586. print $locale->text('Scheduled');
  587. }
  588. print qq|
  589. </td>
  590. </tr>
  591. </table>
  592. |;
  593. }
  594. sub print_and_post {
  595. $form->error( $locale->text('Select postscript or PDF!') )
  596. if $form->{format} !~ /(postscript|pdf)/;
  597. $form->error( $locale->text('Select a Printer!') )
  598. if $form->{media} eq 'screen';
  599. $form->{printandpost} = 1;
  600. $form->{display_form} = "post";
  601. &print;
  602. }