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