summaryrefslogtreecommitdiff
path: root/bin/arapprn.pl
blob: 18fd884f7eace2711fb31c3a62126f5d7b56c247 (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!')) if $form->{format} !~ /(postscript|pdf)/;
  52. $old_form = new Form;
  53. for (keys %$form) { $old_form->{$_} = $form->{$_} }
  54. }
  55. if ($form->{formname} =~ /(check|receipt)/) {
  56. if ($form->{media} eq 'screen') {
  57. $form->error($locale->text('Select postscript or PDF!')) if $form->{format} !~ /(postscript|pdf)/;
  58. }
  59. }
  60. if (! $form->{invnumber}) {
  61. $invfld = 'sinumber';
  62. $invfld = 'vinumber' if $form->{ARAP} eq 'AP';
  63. $form->{invnumber} = $form->update_defaults(\%myconfig, $invfld);
  64. if ($form->{media} eq 'screen') {
  65. if ($form->{media} eq 'screen') {
  66. &update;
  67. exit;
  68. }
  69. }
  70. }
  71. if ($form->{formname} =~ /(check|receipt)/) {
  72. if ($form->{media} ne 'screen') {
  73. for (qw(action header)) { delete $form->{$_} }
  74. $form->{invtotal} = $form->{oldinvtotal};
  75. foreach $key (keys %$form) {
  76. $form->{$key} =~ s/&/%26/g;
  77. $form->{previousform} .= qq|$key=$form->{$key}&|;
  78. }
  79. chop $form->{previousform};
  80. $form->{previousform} = $form->escape($form->{previousform}, 1);
  81. }
  82. if ($form->{paidaccounts} > 1) {
  83. if ($form->{"paid_$form->{paidaccounts}"}) {
  84. &update;
  85. exit;
  86. } elsif ($form->{paidaccounts} > 2) {
  87. # select payment
  88. &select_payment;
  89. exit;
  90. }
  91. } else {
  92. $form->error($locale->text('Nothing to print!'));
  93. }
  94. }
  95. if ($filename = $queued{$form->{formname}}) {
  96. $form->{queued} =~ s/$form->{formname} $filename//;
  97. unlink "${LedgerSMB::Sysconfig::spool}/$filename";
  98. $filename =~ s/\..*$//g;
  99. } else {
  100. $filename = time;
  101. $filename .= $$;
  102. }
  103. $filename .= ($form->{format} eq 'postscript') ? '.ps' : '.pdf';
  104. $form->{OUT} = ">${LedgerSMB::Sysconfig::spool}/$filename" if
  105. $form->{media} ne 'screen';
  106. $form->{queued} .= " $form->{formname} $filename";
  107. $form->{queued} =~ s/^ //;
  108. $printform = new Form;
  109. for (keys %$form){
  110. $printform->{$_} = $form->{$_};
  111. }
  112. if ($form->{printandpost}){
  113. &post;
  114. } else {
  115. &{ "print_$form->{formname}" }($old_form, 1);
  116. }
  117. }
  118. sub print_check {
  119. my ($old_form, $i) = @_;
  120. $display_form = ($form->{display_form}) ? $form->{display_form} : "display_form";
  121. if ($form->{"paid_$i"}) {
  122. @a = ();
  123. if (exists $form->{longformat}) {
  124. $form->{"datepaid_$i"} = $locale->date(\%myconfig, $form->{"datepaid_$i"}, $form->{longformat});
  125. }
  126. push @a, "source_$i", "memo_$i";
  127. $form->format_string(@a);
  128. }
  129. $form->{amount} = $form->{"paid_$i"};
  130. if (($form->{formname} eq 'check' && $form->{vc} eq 'customer') ||
  131. ($form->{formname} eq 'receipt' && $form->{vc} eq 'vendor')) {
  132. $form->{amount} =~ s/-//g;
  133. }
  134. for (qw(datepaid source memo)) { $form->{$_} = $form->{"${_}_$i"} }
  135. &{ "$form->{vc}_details" };
  136. @a = qw(name address1 address2 city state zipcode country);
  137. foreach $item (qw(invnumber ordnumber)) {
  138. $temp{$item} = $form->{$item};
  139. delete $form->{$item};
  140. push(@{ $form->{$item} }, $temp{$item});
  141. }
  142. push(@{ $form->{invdate} }, $form->{transdate});
  143. push(@{ $form->{due} }, $form->format_amount(\%myconfig, $form->{oldinvtotal}, 2));
  144. push(@{ $form->{paid} }, $form->{"paid_$i"});
  145. use LedgerSMB::CP;
  146. $c = CP->new(($form->{language_code}) ? $form->{language_code} : $myconfig{countrycode});
  147. $c->init;
  148. ($whole, $form->{decimal}) = split /\./, $form->parse_amount(\%myconfig, $form->{amount});
  149. $form->{decimal} .= "00";
  150. $form->{decimal} = substr($form->{decimal}, 0, 2);
  151. $form->{text_decimal} = $c->num2text($form->{decimal} * 1);
  152. $form->{text_amount} = $c->num2text($whole);
  153. $form->{integer_amount} = $form->format_amount($myconfig, $whole);
  154. ($form->{employee}) = split /--/, $form->{employee};
  155. $form->{notes} =~ s/^\s+//g;
  156. push @a, "notes";
  157. for (qw(company address tel fax businessnumber)) { $form->{$_} = $myconfig{$_} }
  158. $form->{address} =~ s/\\n/\n/g;
  159. push @a, qw(company address tel fax businessnumber text_amount text_decimal);
  160. $form->format_string(@a);
  161. $form->{templates} = "$myconfig{templates}";
  162. $form->{IN} = ($form->{formname} eq 'transaction') ? lc $form->{ARAP} . "_$form->{formname}.html" : "$form->{formname}.html";
  163. if ($form->{format} =~ /(postscript|pdf)/) {
  164. $form->{IN} =~ s/html$/tex/;
  165. }
  166. if ($form->{media} eq 'queue') {
  167. # save status
  168. $form->update_status(\%myconfig);
  169. $form->{queued} = $form->{queued};
  170. %audittrail = ( tablename => ($order) ? 'oe' : lc $ARAP,
  171. reference => $form->{"${inv}number"},
  172. formname => $form->{formname},
  173. action => 'queued',
  174. id => $form->{id} );
  175. $form->{audittrail} .= $form->audittrail("", \%myconfig, \%audittrail);
  176. $form->{OUT} = ">${LedgerSMB::Sysconfig::spool}/$filename";
  177. $form->{queued} .= " $form->{formname} $filename";
  178. $form->{queued} =~ s/^ //;
  179. }
  180. if ($form->{media} !~ /(screen|queue)/) {
  181. %queued = split / /, $form->{queued};
  182. $form->{OUT} = "| ${LedgerSMB::Sysconfig::printer}{$form->{media}}";
  183. if ($form->{printed} !~ /$form->{formname}/) {
  184. $form->{printed} .= " $form->{formname}";
  185. $form->{printed} =~ s/^ //;
  186. $form->update_status(\%myconfig);
  187. }
  188. %audittrail = ( tablename => lc $form->{ARAP},
  189. reference => $form->{invnumber},
  190. formname => $form->{formname},
  191. action => 'printed',
  192. id => $form->{id} );
  193. %status = ();
  194. for (qw(printed audittrail)) { $status{$_} = $form->{$_} }
  195. $status{audittrail} .= $form->audittrail("", \%myconfig, \%audittrail);
  196. }
  197. $form->{fileid} = $invnumber;
  198. $form->{fileid} =~ s/(\s|\W)+//g;
  199. $form->parse_template(\%myconfig);
  200. if ($form->{previousform}) {
  201. $previousform = $form->unescape($form->{previousform});
  202. for (keys %$form) { delete $form->{$_} }
  203. foreach $item (split /&/, $previousform) {
  204. ($key, $value) = split /=/, $item, 2;
  205. $value =~ s/%26/&/g;
  206. $form->{$key} = $value;
  207. }
  208. for (qw(exchangerate creditlimit creditremaining)) { $form->{$_} = $form->parse_amount(\%myconfig, $form->{$_}) }
  209. for (1 .. $form->{rowcount}) { $form->{"amount_$_"} = $form->parse_amount(\%myconfig, $form->{"amount_$_"}) }
  210. for (split / /, $form->{taxaccounts}) { $form->{"tax_$_"} = $form->parse_amount(\%myconfig, $form->{"tax_$_"}) }
  211. for $i (1 .. $form->{paidaccounts}) {
  212. for (qw(paid exchangerate)) { $form->{"${_}_$i"} = $form->parse_amount(\%myconfig, $form->{"${_}_$i"}) }
  213. }
  214. for (qw(printed audittrail)) { $form->{$_} = $status{$_} }
  215. &{ "$display_form" };
  216. }
  217. }
  218. sub print_receipt {
  219. my ($old_form, $i) = @_;
  220. &print_check($old_form, $i);
  221. }
  222. sub print_transaction {
  223. my ($old_form) = @_;
  224. $display_form = ($form->{display_form}) ? $form->{display_form} : "display_form";
  225. &{ "$form->{vc}_details" };
  226. @a = qw(name address1 address2 city state zipcode country);
  227. $form->{invtotal} = 0;
  228. foreach $i (1 .. $form->{rowcount} - 1) {
  229. ($form->{tempaccno}, $form->{tempaccount}) = split /--/, $form->{"$form->{ARAP}_amount_$i"};
  230. ($form->{tempprojectnumber}) = split /--/, $form->{"projectnumber_$i"};
  231. $form->{tempdescription} = $form->{"description_$i"};
  232. $form->format_string(qw(tempaccno tempaccount tempprojectnumber tempdescription));
  233. push(@{ $form->{accno} }, $form->{tempaccno});
  234. push(@{ $form->{account} }, $form->{tempaccount});
  235. push(@{ $form->{description} }, $form->{tempdescription});
  236. push(@{ $form->{projectnumber} }, $form->{tempprojectnumber});
  237. push(@{ $form->{amount} }, $form->{"amount_$i"});
  238. $form->{subtotal} += $form->parse_amount(\%myconfig, $form->{"amount_$i"});
  239. }
  240. foreach $accno (split / /, $form->{taxaccounts}) {
  241. if ($form->{"tax_$accno"}) {
  242. $form->format_string("${accno}_description");
  243. $tax += $form->parse_amount(\%myconfig, $form->{"tax_$accno"});
  244. $form->{"${accno}_tax"} = $form->{"tax_$accno"};
  245. push(@{ $form->{tax} }, $form->{"tax_$accno"});
  246. push(@{ $form->{taxdescription} }, $form->{"${accno}_description"});
  247. $form->{"${accno}_taxrate"} = $form->format_amount($myconfig, $form->{"${accno}_rate"} * 100);
  248. push(@{ $form->{taxrate} }, $form->{"${accno}_taxrate"});
  249. push(@{ $form->{taxnumber} }, $form->{"${accno}_taxnumber"});
  250. }
  251. }
  252. $tax = 0 if $form->{taxincluded};
  253. push @a, $form->{ARAP};
  254. $form->format_string(@a);
  255. $form->{paid} = 0;
  256. for $i (1 .. $form->{paidaccounts} - 1) {
  257. if ($form->{"paid_$i"}) {
  258. @a = ();
  259. $form->{paid} += $form->parse_amount(\%myconfig, $form->{"paid_$i"});
  260. if (exists $form->{longformat}) {
  261. $form->{"datepaid_$i"} = $locale->date(\%myconfig, $form->{"datepaid_$i"}, $form->{longformat});
  262. }
  263. push @a, "$form->{ARAP}_paid_$i", "source_$i", "memo_$i";
  264. $form->format_string(@a);
  265. ($accno, $account) = split /--/, $form->{"$form->{ARAP}_paid_$i"};
  266. push(@{ $form->{payment} }, $form->{"paid_$i"});
  267. push(@{ $form->{paymentdate} }, $form->{"datepaid_$i"});
  268. push(@{ $form->{paymentaccount} }, $account);
  269. push(@{ $form->{paymentsource} }, $form->{"source_$i"});
  270. push(@{ $form->{paymentmemo} }, $form->{"memo_$i"});
  271. }
  272. }
  273. $form->{invtotal} = $form->{subtotal} + $tax;
  274. $form->{total} = $form->{invtotal} - $form->{paid};
  275. use LedgerSMB::CP;
  276. $c = CP->new(($form->{language_code}) ? $form->{language_code} : $myconfig{countrycode});
  277. $c->init;
  278. ($whole, $form->{decimal}) = split /\./, $form->{invtotal};
  279. $form->{decimal} .= "00";
  280. $form->{decimal} = substr($form->{decimal}, 0, 2);
  281. $form->{text_decimal} = $c->num2text($form->{decimal} * 1);
  282. $form->{text_amount} = $c->num2text($whole);
  283. $form->{integer_amount} = $form->format_amount($myconfig, $whole);
  284. for (qw(invtotal subtotal paid total)) { $form->{$_} = $form->format_amount(\%myconfig, $form->{$_}, 2) }
  285. ($form->{employee}) = split /--/, $form->{employee};
  286. if (exists $form->{longformat}) {
  287. for (qw(duedate transdate)) { $form->{$_} = $locale->date(\%myconfig, $form->{$_}, $form->{longformat}) }
  288. }
  289. $form->{notes} =~ s/^\s+//g;
  290. @a = ("invnumber", "transdate", "duedate", "notes");
  291. for (qw(company address tel fax businessnumber)) { $form->{$_} = $myconfig{$_} }
  292. $form->{address} =~ s/\\n/\n/g;
  293. push @a, qw(company address tel fax businessnumber text_amount text_decimal);
  294. $form->format_string(@a);
  295. $form->{invdate} = $form->{transdate};
  296. $form->{templates} = "$myconfig{templates}";
  297. $form->{IN} = ($form->{formname} eq 'transaction') ? lc $form->{ARAP} . "_$form->{formname}.html" : "$form->{formname}.html";
  298. if ($form->{format} =~ /(postscript|pdf)/) {
  299. $form->{IN} =~ s/html$/tex/;
  300. }
  301. if ($form->{media} eq 'queue') {
  302. %queued = split / /, $form->{queued};
  303. if ($filename = $queued{$form->{formname}}) {
  304. $form->{queued} =~ s/$form->{formname} $filename//;
  305. unlink "${LedgerSMB::Sysconfig::spool}/$filename";
  306. $filename =~ s/\..*$//g;
  307. } else {
  308. $filename = time;
  309. $filename .= $$;
  310. }
  311. $filename .= ($form->{format} eq 'postscript') ? '.ps' : '.pdf';
  312. $form->{OUT} = ">${LedgerSMB::Sysconfig::spool}/$filename";
  313. $form->{queued} .= " $form->{formname} $filename";
  314. $form->{queued} =~ s/^ //;
  315. # save status
  316. $form->update_status(\%myconfig);
  317. $old_form->{queued} = $form->{queued};
  318. %audittrail = ( tablename => ($order) ? 'oe' : lc $ARAP,
  319. reference => $form->{"${inv}number"},
  320. formname => $form->{formname},
  321. action => 'queued',
  322. id => $form->{id} );
  323. $old_form->{audittrail} .= $form->audittrail("", \%myconfig, \%audittrail);
  324. }
  325. if ($form->{media} !~ /(queue|screen)/) {
  326. $form->{OUT} = "| ${LedgerSMB::Sysconfig::printer}{$form->{media}}";
  327. if ($form->{printed} !~ /$form->{formname}/) {
  328. $form->{printed} .= " $form->{formname}";
  329. $form->{printed} =~ s/^ //;
  330. $form->update_status(\%myconfig);
  331. }
  332. $old_form->{printed} = $form->{printed} if %$old_form;
  333. %audittrail = ( tablename => lc $form->{ARAP},
  334. reference => $form->{"invnumber"},
  335. formname => $form->{formname},
  336. action => 'printed',
  337. id => $form->{id} );
  338. $old_form->{audittrail} .= $form->audittrail("", \%myconfig, \%audittrail) if %$old_form;
  339. }
  340. $form->{fileid} = $form->{invnumber};
  341. $form->{fileid} =~ s/(\s|\W)+//g;
  342. $form->parse_template(\%myconfig);
  343. if (%$old_form) {
  344. $old_form->{invnumber} = $form->{invnumber};
  345. $old_form->{invtotal} = $form->{invtotal};
  346. for (keys %$form) { delete $form->{$_} }
  347. for (keys %$old_form) { $form->{$_} = $old_form->{$_} }
  348. if (! $form->{printandpost}) {
  349. for (qw(exchangerate creditlimit creditremaining)) { $form->{$_} = $form->parse_amount(\%myconfig, $form->{$_}) }
  350. for (1 .. $form->{rowcount}) { $form->{"amount_$_"} = $form->parse_amount(\%myconfig, $form->{"amount_$_"}) }
  351. for (split / /, $form->{taxaccounts}) { $form->{"tax_$_"} = $form->parse_amount(\%myconfig, $form->{"tax_$_"}) }
  352. for $i (1 .. $form->{paidaccounts}) {
  353. for (qw(paid exchangerate)) { $form->{"${_}_$i"} = $form->parse_amount(\%myconfig, $form->{"${_}_$i"}) }
  354. }
  355. }
  356. &{ "$display_form" };
  357. }
  358. }
  359. sub vendor_details { IR->vendor_details(\%myconfig, \%$form) };
  360. sub customer_details { IS->customer_details(\%myconfig, \%$form) };
  361. sub select_payment {
  362. @column_index = ("ndx", "datepaid", "source", "memo", "paid", "$form->{ARAP}_paid");
  363. # list payments with radio button on a form
  364. $form->header;
  365. $title = $locale->text('Select payment');
  366. $column_data{ndx} = qq|<th width=1%>&nbsp;</th>|;
  367. $column_data{datepaid} = qq|<th>|.$locale->text('Date').qq|</th>|;
  368. $column_data{source} = qq|<th>|.$locale->text('Source').qq|</th>|;
  369. $column_data{memo} = qq|<th>|.$locale->text('Memo').qq|</th>|;
  370. $column_data{paid} = qq|<th>|.$locale->text('Amount').qq|</th>|;
  371. $column_data{"$form->{ARAP}_paid"} = qq|<th>|.$locale->text('Account').qq|</th>|;
  372. print qq|
  373. <body>
  374. <form method=post action=$form->{script}>
  375. <table width=100%>
  376. <tr>
  377. <th class=listtop>$title</th>
  378. </tr>
  379. <tr space=5></tr>
  380. <tr>
  381. <td>
  382. <table width=100%>
  383. <tr class=listheading>|;
  384. for (@column_index) { print "\n$column_data{$_}" }
  385. print qq|
  386. </tr>
  387. |;
  388. $checked = "checked";
  389. foreach $i (1 .. $form->{paidaccounts} - 1) {
  390. for (@column_index) { $column_data{$_} = qq|<td>$form->{"${_}_$i"}</td>| }
  391. $paid = $form->{"paid_$i"};
  392. $ok = 1;
  393. $column_data{ndx} = qq|<td><input name=ndx class=radio type=radio value=$i $checked></td>|;
  394. $column_data{paid} = qq|<td align=right>$paid</td>|;
  395. $checked = "";
  396. $j++; $j %= 2;
  397. print qq|
  398. <tr class=listrow$j>|;
  399. for (@column_index) { print "\n$column_data{$_}" }
  400. print qq|
  401. </tr>
  402. |;
  403. }
  404. print qq|
  405. </table>
  406. </td>
  407. </tr>
  408. <tr>
  409. <td><hr size=3 noshade></td>
  410. </tr>
  411. </table>
  412. |;
  413. for (qw(action nextsub)) { delete $form->{$_} }
  414. $form->hide_form;
  415. print qq|
  416. <br>
  417. <input type=hidden name=nextsub value=payment_selected>
  418. |;
  419. if ($ok) {
  420. print qq|
  421. <button class="submit" type="submit" name="action" value="continue">|.$locale->text('Continue').qq|</button>|;
  422. }
  423. print qq|
  424. </form>
  425. </body>
  426. </html>
  427. |;
  428. }
  429. sub payment_selected {
  430. &{ "print_$form->{formname}" }($form->{oldform}, $form->{ndx});
  431. }
  432. sub print_options {
  433. if ($form->{selectlanguage}) {
  434. $form->{"selectlanguage"} = $form->unescape($form->{"selectlanguage"});
  435. $form->{"selectlanguage"} =~ s/ selected//;
  436. $form->{"selectlanguage"} =~ s/(<option value="\Q$form->{language_code}\E")/$1 selected/;
  437. $lang = qq|<select name=language_code>$form->{selectlanguage}</select>
  438. <input type=hidden name=selectlanguage value="|.
  439. $form->escape($form->{selectlanguage},1).qq|">|;
  440. }
  441. $form->{selectformname} = $form->unescape($form->{selectformname});
  442. $form->{selectformname} =~ s/ selected//;
  443. $form->{selectformname} =~ s/(<option value="\Q$form->{formname}\E")/$1 selected/;
  444. $type = qq|<select name=formname>$form->{selectformname}</select>
  445. <input type=hidden name=selectformname value="|.$form->escape($form->{selectformname},1).qq|">|;
  446. $media = qq|<select name=media>
  447. <option value="screen">|.$locale->text('Screen');
  448. $form->{selectformat} = qq|<option value="html">html\n|;
  449. if (%{LedgerSMB::Sysconfig::printer} && ${LedgerSMB::Sysconfig::latex}) {
  450. for (sort keys %{LedgerSMB::Sysconfig::printer}) { $media .= qq|
  451. <option value="$_">$_| }
  452. }
  453. if (${LedgerSMB::Sysconfig::latex}) {
  454. $form->{selectformat} .= qq|
  455. <option value="postscript">|.$locale->text('Postscript').qq|
  456. <option value="pdf">|.$locale->text('PDF');
  457. $media .= qq|<option value="queue">|.$locale->text('Queue');
  458. }
  459. $format = qq|<select name=format>$form->{selectformat}</select>|;
  460. $format =~ s/(<option value="\Q$form->{format}\E")/$1 selected/;
  461. $format .= qq|
  462. <input type=hidden name=selectformat value="|.$form->escape($form->{selectformat},1).qq|">|;
  463. $media .= qq|</select>|;
  464. $media =~ s/(<option value="\Q$form->{media}\E")/$1 selected/;
  465. print qq|
  466. <table width=100%>
  467. <tr>
  468. <td>$type</td>
  469. <td>$lang</td>
  470. <td>$format</td>
  471. <td>$media</td>
  472. <td align=right width=90%>
  473. |;
  474. if ($form->{printed} =~ /$form->{formname}/) {
  475. print $locale->text('Printed').qq|<br>|;
  476. }
  477. if ($form->{recurring}) {
  478. print $locale->text('Scheduled');
  479. }
  480. print qq|
  481. </td>
  482. </tr>
  483. </table>
  484. |;
  485. }
  486. sub print_and_post {
  487. $form->error($locale->text('Select postscript or PDF!')) if $form->{format} !~ /(postscript|pdf)/;
  488. $form->error($locale->text('Select a Printer!')) if $form->{media} eq 'screen';
  489. $form->{printandpost} = 1;
  490. $form->{display_form} = "post";
  491. &print;
  492. }