summaryrefslogtreecommitdiff
path: root/bin/rp.pl
blob: 26f55dcf22964f818e0d863ba96c4bbb9528739e (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) 2001
  17. #
  18. # Author: DWS Systems Inc.
  19. # Web: http://www.sql-ledger.org
  20. #
  21. # Contributors: Antonio Gallardo <agssa@ibw.com.ni>
  22. # Benjamin Lee <benjaminlee@consultant.com>
  23. #
  24. #
  25. # This program is free software; you can redistribute it and/or modify
  26. # it under the terms of the GNU General Public License as published by
  27. # the Free Software Foundation; either version 2 of the License, or
  28. # (at your option) any later version.
  29. #
  30. # This program is distributed in the hope that it will be useful,
  31. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  32. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  33. # GNU General Public License for more details.
  34. # You should have received a copy of the GNU General Public License
  35. # along with this program; if not, write to the Free Software
  36. # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  37. #======================================================================
  38. #
  39. # module for preparing Income Statement and Balance Sheet
  40. #
  41. #======================================================================
  42. use Error qw(:try);
  43. require "bin/arap.pl";
  44. use LedgerSMB::Template;
  45. use LedgerSMB::PE;
  46. use LedgerSMB::RP;
  47. 1;
  48. # end of main
  49. # this is for our long dates
  50. # $locale->text('January')
  51. # $locale->text('February')
  52. # $locale->text('March')
  53. # $locale->text('April')
  54. # $locale->text('May ')
  55. # $locale->text('June')
  56. # $locale->text('July')
  57. # $locale->text('August')
  58. # $locale->text('September')
  59. # $locale->text('October')
  60. # $locale->text('November')
  61. # $locale->text('December')
  62. # this is for our short month
  63. # $locale->text('Jan')
  64. # $locale->text('Feb')
  65. # $locale->text('Mar')
  66. # $locale->text('Apr')
  67. # $locale->text('May')
  68. # $locale->text('Jun')
  69. # $locale->text('Jul')
  70. # $locale->text('Aug')
  71. # $locale->text('Sep')
  72. # $locale->text('Oct')
  73. # $locale->text('Nov')
  74. # $locale->text('Dec')
  75. # $locale->text('Balance Sheet')
  76. # $locale->text('Income Statement')
  77. # $locale->text('Trial Balance')
  78. # $locale->text('AR Aging')
  79. # $locale->text('AP Aging')
  80. # $locale->text('Tax collected')
  81. # $locale->text('Tax paid')
  82. # $locale->text('Receipts')
  83. # $locale->text('Payments')
  84. # $locale->text('Project Transactions')
  85. # $locale->text('Non-taxable Sales')
  86. # $locale->text('Non-taxable Purchases')
  87. sub report {
  88. %report = ( balance_sheet => { title => 'Balance Sheet' },
  89. income_statement => { title => 'Income Statement' },
  90. trial_balance => { title => 'Trial Balance' },
  91. ar_aging => { title => 'AR Aging', vc => 'customer' },
  92. ap_aging => { title => 'AP Aging', vc => 'vendor' },
  93. tax_collected => { title => 'Tax collected', vc => 'customer' },
  94. tax_paid => { title => 'Tax paid' },
  95. nontaxable_sales => { title => 'Non-taxable Sales', vc => 'customer' },
  96. nontaxable_purchases => { title => 'Non-taxable Purchases' },
  97. receipts => { title => 'Receipts', vc => 'customer' },
  98. payments => { title => 'Payments' },
  99. projects => { title => 'Project Transactions' },
  100. inv_activity => { title => 'Inventory Activity'},
  101. );
  102. $form->{title} = $locale->text($report{$form->{report}}->{title});
  103. $gifi = qq|
  104. <tr>
  105. <th align=right>|.$locale->text('Accounts').qq|</th>
  106. <td><input name=accounttype class=radio type=radio value=standard checked> |.$locale->text('Standard').qq|
  107. <input name=accounttype class=radio type=radio value=gifi> |.$locale->text('GIFI').qq|
  108. </td>
  109. </tr>
  110. |;
  111. # get departments
  112. $form->all_departments(\%myconfig, undef, $report{$form->{report}}->{vc});
  113. if (@{ $form->{all_department} }) {
  114. $form->{selectdepartment} = "<option>\n";
  115. for (@{ $form->{all_department} }) { $form->{selectdepartment} .= qq|<option value="$_->{description}--$_->{id}">$_->{description}\n| }
  116. }
  117. $department = qq|
  118. <tr>
  119. <th align=right nowrap>|.$locale->text('Department').qq|</th>
  120. <td colspan=3><select name=department>$form->{selectdepartment}</select></td>
  121. </tr>
  122. | if $form->{selectdepartment};
  123. if (@{ $form->{all_years} }) {
  124. # accounting years
  125. $form->{selectaccountingyear} = "<option>\n";
  126. for (@{ $form->{all_years} }) { $form->{selectaccountingyear} .= qq|<option>$_\n| }
  127. $form->{selectaccountingmonth} = "<option>\n";
  128. for (sort keys %{ $form->{all_month} }) { $form->{selectaccountingmonth} .= qq|<option value=$_>|.$locale->text($form->{all_month}{$_}).qq|\n| }
  129. $selectfrom = qq|
  130. <tr>
  131. <th align=right>|.$locale->text('Period').qq|</th>
  132. <td colspan=3>
  133. <select name=month>$form->{selectaccountingmonth}</select>
  134. <select name=year>$form->{selectaccountingyear}</select>
  135. <input name=interval class=radio type=radio value=0 checked>&nbsp;|.$locale->text('Current').qq|
  136. <input name=interval class=radio type=radio value=1>&nbsp;|.$locale->text('Month').qq|
  137. <input name=interval class=radio type=radio value=3>&nbsp;|.$locale->text('Quarter').qq|
  138. <input name=interval class=radio type=radio value=12>&nbsp;|.$locale->text('Year').qq|
  139. </td>
  140. </tr>
  141. |;
  142. $selectto = qq|
  143. <tr>
  144. <th align=right></th>
  145. <td>
  146. <select name=month>$form->{selectaccountingmonth}</select>
  147. <select name=year>$form->{selectaccountingyear}</select>
  148. </td>
  149. </tr>
  150. |;
  151. }
  152. $summary = qq|
  153. <tr>
  154. <th></th>
  155. <td><input name=summary type=radio class=radio value=1 checked> |.$locale->text('Summary').qq|
  156. <input name=summary type=radio class=radio value=0> |.$locale->text('Detail').qq|
  157. </td>
  158. </tr>
  159. |;
  160. # get projects
  161. $form->all_projects(\%myconfig);
  162. if (@{ $form->{all_project} }) {
  163. $form->{selectproject} = "<option>\n";
  164. for (@{ $form->{all_project} }) { $form->{selectproject} .= qq|<option value="$_->{projectnumber}--$_->{id}">$_->{projectnumber}\n| }
  165. $project = qq|
  166. <tr>
  167. <th align=right nowrap>|.$locale->text('Project').qq|</th>
  168. <td colspan=3><select name=projectnumber>$form->{selectproject}</select></td>
  169. </tr>|;
  170. }
  171. $form->header;
  172. print qq|
  173. <body>
  174. <form method=post action=$form->{script}>
  175. <input type=hidden name=title value="$form->{title}">
  176. <table width=100%>
  177. <tr>
  178. <th class=listtop>$form->{title}</th>
  179. </tr>
  180. <tr height="5"></tr>
  181. <tr>
  182. <td>
  183. <table>
  184. $department
  185. |;
  186. if ($form->{report} eq "projects") {
  187. print qq|
  188. $project
  189. <input type=hidden name=nextsub value=generate_projects>
  190. <tr>
  191. <th align=right>|.$locale->text('From').qq|</th>
  192. <td><input name=fromdate size=11 title="$myconfig{dateformat}" value=$form->{fromdate}></td>
  193. <th align=right>|.$locale->text('To').qq|</th>
  194. <td><input name=todate size=11 title="$myconfig{dateformat}"></td>
  195. </tr>
  196. $selectfrom
  197. </table>
  198. </td>
  199. </tr>
  200. <tr>
  201. <td>
  202. <table>
  203. <tr>
  204. <th align=right nowrap>|.$locale->text('Include in Report').qq|</th>
  205. <td><input name=l_heading class=checkbox type=checkbox value=Y>&nbsp;|.$locale->text('Heading').qq|
  206. <input name=l_subtotal class=checkbox type=checkbox value=Y>&nbsp;|.$locale->text('Subtotal').qq|</td>
  207. </tr>
  208. |;
  209. }
  210. if ($form->{report} eq "inv_activity"){
  211. $gifi = '';
  212. print qq|
  213. <input type=hidden name=nextsub value=generate_inv_activity>
  214. <tr>
  215. <th align=right>|.$locale->text('From').qq|</th>
  216. <td><input name=fromdate size=11 title="$myconfig{dateformat}" value=$form->{fromdate}></td>
  217. <th align=right>|.$locale->text('To').qq|</th>
  218. <td><input name=todate size=11 title="$myconfig{dateformat}"></td>
  219. </tr>
  220. <tr>
  221. <th align=right>|.$locale->text('Period').qq|</th>
  222. <td colspan=3>
  223. <select name=frommonth>$form->{selectaccountingmonth}</select>
  224. <select name=fromyear>$form->{selectaccountingyear}</select>
  225. <input name=interval class=radio type=radio value=0 checked>|.$locale->text('Current').qq|
  226. <input name=interval class=radio type=radio value=1>|.$locale->text('Month').qq|
  227. <input name=interval class=radio type=radio value=3>|.$locale->text('Quarter').qq|
  228. <input name=interval class=radio type=radio value=12>|.$locale->text('Year').qq|
  229. </td>
  230. </tr>
  231. </table>
  232. <table>
  233. <tr>
  234. <th>|.$locale->text("Part Number").qq|</th>
  235. <td><input name=partnumber></td>
  236. <th>|.$locale->text('Description').qq|</th>
  237. <td><input type=text name=description></td>
  238. </tr>|;
  239. }
  240. if ($form->{report} eq "income_statement") {
  241. print qq|
  242. $project
  243. <input type=hidden name=nextsub value=generate_income_statement>
  244. <tr>
  245. <th align=right>|.$locale->text('From').qq|</th>
  246. <td><input name=fromdate size=11 title="$myconfig{dateformat}" value=$form->{fromdate}></td>
  247. <th align=right>|.$locale->text('To').qq|</th>
  248. <td><input name=todate size=11 title="$myconfig{dateformat}"></td>
  249. </tr>
  250. |;
  251. if ($selectfrom) {
  252. print qq|
  253. <tr>
  254. <th align=right>|.$locale->text('Period').qq|</th>
  255. <td colspan=3>
  256. <select name=frommonth>$form->{selectaccountingmonth}</select>
  257. <select name=fromyear>$form->{selectaccountingyear}</select>
  258. <input name=interval class=radio type=radio value=0 checked>&nbsp;|.$locale->text('Current').qq|
  259. <input name=interval class=radio type=radio value=1>&nbsp;|.$locale->text('Month').qq|
  260. <input name=interval class=radio type=radio value=3>&nbsp;|.$locale->text('Quarter').qq|
  261. <input name=interval class=radio type=radio value=12>&nbsp;|.$locale->text('Year').qq|
  262. </td>
  263. </tr>
  264. |;
  265. }
  266. print qq|
  267. <tr>
  268. <th align=right>|.$locale->text('Compare to').qq|</th>
  269. </tr>
  270. <tr>
  271. <th align=right>|.$locale->text('From').qq|</th>
  272. <td><input name=comparefromdate size=11 title="$myconfig{dateformat}"></td>
  273. <th align=right>|.$locale->text('To').qq|</th>
  274. <td><input name=comparetodate size=11 title="$myconfig{dateformat}"></td>
  275. </tr>
  276. |;
  277. if ($selectto) {
  278. print qq|
  279. <tr>
  280. <th align=right>|.$locale->text('Period').qq|</th>
  281. <td>
  282. <select name=comparemonth>$form->{selectaccountingmonth}</select>
  283. <select name=compareyear>$form->{selectaccountingyear}</select>
  284. </td>
  285. </tr>
  286. |;
  287. }
  288. print qq|
  289. <tr>
  290. <th align=right>|.$locale->text('Decimalplaces').qq|</th>
  291. <td><input name=decimalplaces size=3 value=2></td>
  292. </tr>
  293. </table>
  294. </td>
  295. </tr>
  296. <tr>
  297. <td>
  298. <table>
  299. <tr>
  300. <th align=right>|.$locale->text('Method').qq|</th>
  301. <td colspan=3><input name=method class=radio type=radio value=accrual checked>|.$locale->text('Accrual').qq|
  302. &nbsp;<input name=method class=radio type=radio value=cash>|.$locale->text('Cash').qq|</td>
  303. </tr>
  304. <tr>
  305. <th align=right nowrap>|.$locale->text('Include in Report').qq|</th>
  306. <td colspan=3><input name=l_heading class=checkbox type=checkbox value=Y>&nbsp;|.$locale->text('Heading').qq|
  307. <input name=l_subtotal class=checkbox type=checkbox value=Y>&nbsp;|.$locale->text('Subtotal').qq|
  308. <input name=l_accno class=checkbox type=checkbox value=Y>&nbsp;|.$locale->text('Account Number').qq|</td>
  309. </tr>
  310. |;
  311. }
  312. if ($form->{report} eq "balance_sheet") {
  313. print qq|
  314. <input type=hidden name=nextsub value=generate_balance_sheet>
  315. <tr>
  316. <th align=right>|.$locale->text('as at').qq|</th>
  317. <td><input name=asofdate size=11 title="$myconfig{dateformat}" value=$form->{asofdate}></td>
  318. |;
  319. if ($selectfrom) {
  320. print qq|
  321. <td>
  322. <select name=asofmonth>$form->{selectaccountingmonth}</select>
  323. <select name=asofyear>$form->{selectaccountingyear}</select>
  324. </td>
  325. |;
  326. }
  327. print qq|
  328. </tr>
  329. <th align=right nowrap>|.$locale->text('Compare to').qq|</th>
  330. <td><input name=compareasofdate size=11 title="$myconfig{dateformat}"></td>
  331. <td>
  332. |;
  333. if ($selectto) {
  334. print qq|
  335. <select name=compareasofmonth>$form->{selectaccountingmonth}</select>
  336. <select name=compareasofyear>$form->{selectaccountingyear}</select>
  337. </td>
  338. |;
  339. }
  340. print qq|
  341. </tr>
  342. <tr>
  343. <th align=right>|.$locale->text('Decimalplaces').qq|</th>
  344. <td><input name=decimalplaces size=3 value=2></td>
  345. </tr>
  346. </table>
  347. </td>
  348. </tr>
  349. <tr>
  350. <td>
  351. <table>
  352. <tr>
  353. <th align=right>|.$locale->text('Method').qq|</th>
  354. <td colspan=3><input name=method class=radio type=radio value=accrual checked>|.$locale->text('Accrual').qq|
  355. &nbsp;<input name=method class=radio type=radio value=cash>|.$locale->text('Cash').qq|</td>
  356. </tr>
  357. <tr>
  358. <th align=right nowrap>|.$locale->text('Include in Report').qq|</th>
  359. <td><input name=l_heading class=checkbox type=checkbox value=Y>&nbsp;|.$locale->text('Heading').qq|
  360. <input name=l_subtotal class=checkbox type=checkbox value=Y>&nbsp;|.$locale->text('Subtotal').qq|
  361. <input name=l_accno class=checkbox type=checkbox value=Y>&nbsp;|.$locale->text('Account Number').qq|</td>
  362. </tr>
  363. |;
  364. }
  365. if ($form->{report} eq "trial_balance") {
  366. print qq|
  367. <input type=hidden name=nextsub value=generate_trial_balance>
  368. <tr>
  369. <th align=right>|.$locale->text('From').qq|</th>
  370. <td><input name=fromdate size=11 title="$myconfig{dateformat}" value=$form->{fromdate}></td>
  371. <th align=right>|.$locale->text('To').qq|</th>
  372. <td><input name=todate size=11 title="$myconfig{dateformat}"></td>
  373. </tr>
  374. $selectfrom
  375. </table>
  376. </td>
  377. </tr>
  378. <tr>
  379. <td>
  380. <table>
  381. <tr>
  382. <th align=right nowrap>|.$locale->text('Include in Report').qq|</th>
  383. <td><input name=l_heading class=checkbox type=checkbox value=Y>&nbsp;|.$locale->text('Heading').qq|
  384. <input name=l_subtotal class=checkbox type=checkbox value=Y>&nbsp;|.$locale->text('Subtotal').qq|
  385. <input name=all_accounts class=checkbox type=checkbox value=Y>&nbsp;|.$locale->text('All Accounts').qq|</td>
  386. </tr>
  387. |;
  388. }
  389. if ($form->{report} =~ /^tax_/) {
  390. $gifi = "";
  391. $form->{db} = ($form->{report} =~ /_collected/) ? "ar" : "ap";
  392. RP->get_taxaccounts(\%myconfig, \%$form);
  393. print qq|
  394. <input type=hidden name=nextsub value=generate_tax_report>
  395. <tr>
  396. <th align=right>|.$locale->text('From').qq|</th>
  397. <td><input name=fromdate size=11 title="$myconfig{dateformat}" value=$form->{fromdate}></td>
  398. <th align=right>|.$locale->text('To').qq|</th>
  399. <td><input name=todate size=11 title="$myconfig{dateformat}"></td>
  400. </tr>
  401. $selectfrom
  402. $summary
  403. <tr>
  404. <th align=right>|.$locale->text('Report for').qq|</th>
  405. <td colspan=3>
  406. |;
  407. $checked = "checked";
  408. foreach $ref (@{ $form->{taxaccounts} }) {
  409. print qq|<input name=accno class=radio type=radio value=$ref->{accno} $checked>&nbsp;$ref->{description}
  410. <input name="$ref->{accno}_description" type=hidden value="$ref->{description}">
  411. <input name="$ref->{accno}_rate" type=hidden value="$ref->{rate}">|;
  412. $checked = "";
  413. }
  414. print qq|
  415. <input type=hidden name=db value=$form->{db}>
  416. <input type=hidden name=sort value=transdate>
  417. </td>
  418. </tr>
  419. |;
  420. if (@{ $form->{gifi_taxaccounts} }) {
  421. print qq|
  422. <tr>
  423. <th align=right>|.$locale->text('GIFI').qq|</th>
  424. <td colspan=3>
  425. |;
  426. foreach $ref (@{ $form->{gifi_taxaccounts} }) {
  427. print qq|<input name=accno class=radio type=radio value="gifi_$ref->{accno}">&nbsp;$ref->{description}
  428. <input name="gifi_$ref->{accno}_description" type=hidden value="$ref->{description}">
  429. <input name="gifi_$ref->{accno}_rate" type=hidden value="$ref->{rate}">|;
  430. }
  431. print qq|
  432. </td>
  433. </tr>
  434. |;
  435. }
  436. print qq|
  437. <tr>
  438. <th align=right>|.$locale->text('Method').qq|</th>
  439. <td colspan=3><input name=method class=radio type=radio value=accrual checked>|.$locale->text('Accrual').qq|
  440. &nbsp;<input name=method class=radio type=radio value=cash>|.$locale->text('Cash').qq|</td>
  441. </tr>
  442. </table>
  443. </td>
  444. </tr>
  445. <tr>
  446. <td>
  447. <table>
  448. <tr>
  449. <th align=right>|.$locale->text('Include in Report').qq|</th>
  450. <td>
  451. <table>
  452. <tr>
  453. <td><input name="l_id" class=checkbox type=checkbox value=Y></td>
  454. <td>|.$locale->text('ID').qq|</td>
  455. <td><input name="l_invnumber" class=checkbox type=checkbox value=Y checked></td>
  456. <td>|.$locale->text('Invoice').qq|</td>
  457. <td><input name="l_transdate" class=checkbox type=checkbox value=Y checked></td>
  458. <td>|.$locale->text('Date').qq|</td>
  459. </tr>
  460. <tr>
  461. <td><input name="l_name" class=checkbox type=checkbox value=Y checked></td>
  462. |;
  463. if ($form->{db} eq 'ar') {
  464. print qq|<td>|.$locale->text('Customer').qq|</td>|;
  465. }
  466. if ($form->{db} eq 'ap') {
  467. print qq|<td>|.$locale->text('Vendor').qq|</td>|;
  468. }
  469. print qq|
  470. <td><input name="l_description" class=checkbox type=checkbox value=Y checked></td>
  471. <td>|.$locale->text('Description').qq|</td>
  472. <td><input name="l_netamount" class=checkbox type=checkbox value=Y checked></td>
  473. <td>|.$locale->text('Amount').qq|</td>
  474. <td><input name="l_tax" class=checkbox type=checkbox value=Y checked></td>
  475. <td>|.$locale->text('Tax').qq|</td>
  476. <td><input name="l_total" class=checkbox type=checkbox value=Y checked></td>
  477. <td>|.$locale->text('Total').qq|</td>
  478. </tr>
  479. <tr>
  480. </tr>
  481. <tr>
  482. <td><input name="l_subtotal" class=checkbox type=checkbox value=Y></td>
  483. <td>|.$locale->text('Subtotal').qq|</td>
  484. </tr>
  485. </table>
  486. </td>
  487. </tr>
  488. |;
  489. }
  490. if ($form->{report} =~ /^nontaxable_/) {
  491. $gifi = "";
  492. $form->{db} = ($form->{report} =~ /_sales/) ? "ar" : "ap";
  493. print qq|
  494. <input type=hidden name=nextsub value=generate_tax_report>
  495. <input type=hidden name=db value=$form->{db}>
  496. <input type=hidden name=sort value=transdate>
  497. <input type=hidden name=report value=$form->{report}>
  498. <tr>
  499. <th align=right>|.$locale->text('From').qq|</th>
  500. <td><input name=fromdate size=11 title="$myconfig{dateformat}" value=$form->{fromdate}></td>
  501. <th align=right>|.$locale->text('To').qq|</th>
  502. <td><input name=todate size=11 title="$myconfig{dateformat}"></td>
  503. </tr>
  504. $selectfrom
  505. $summary
  506. <tr>
  507. <th align=right>|.$locale->text('Method').qq|</th>
  508. <td colspan=3><input name=method class=radio type=radio value=accrual checked>|.$locale->text('Accrual').qq|
  509. &nbsp;<input name=method class=radio type=radio value=cash>|.$locale->text('Cash').qq|</td>
  510. </tr>
  511. <tr>
  512. <th align=right>|.$locale->text('Include in Report').qq|</th>
  513. <td colspan=3>
  514. <table>
  515. <tr>
  516. <td><input name="l_id" class=checkbox type=checkbox value=Y></td>
  517. <td>|.$locale->text('ID').qq|</td>
  518. <td><input name="l_invnumber" class=checkbox type=checkbox value=Y checked></td>
  519. <td>|.$locale->text('Invoice').qq|</td>
  520. <td><input name="l_transdate" class=checkbox type=checkbox value=Y checked></td>
  521. <td>|.$locale->text('Date').qq|</td>
  522. </tr>
  523. <tr>
  524. <td><input name="l_name" class=checkbox type=checkbox value=Y checked></td>
  525. |;
  526. if ($form->{db} eq 'ar') {
  527. print qq|<td>|.$locale->text('Customer').qq|</td>|;
  528. }
  529. if ($form->{db} eq 'ap') {
  530. print qq|<td>|.$locale->text('Vendor').qq|</td>|;
  531. }
  532. print qq|
  533. <td><input name="l_description" class=checkbox type=checkbox value=Y checked></td>
  534. <td>|.$locale->text('Description').qq|</td>
  535. <td><input name="l_netamount" class=checkbox type=checkbox value=Y checked></td>
  536. <td>|.$locale->text('Amount').qq|</td>
  537. </tr>
  538. <tr>
  539. <td><input name="l_subtotal" class=checkbox type=checkbox value=Y></td>
  540. <td>|.$locale->text('Subtotal').qq|</td>
  541. </tr>
  542. </table>
  543. </td>
  544. </tr>
  545. |;
  546. }
  547. if (($form->{report} eq "ar_aging") || ($form->{report} eq "ap_aging")) {
  548. $gifi = "";
  549. if ($form->{report} eq 'ar_aging') {
  550. $label = $locale->text('Customer');
  551. $form->{vc} = 'customer';
  552. } else {
  553. $label = $locale->text('Vendor');
  554. $form->{vc} = 'vendor';
  555. }
  556. $nextsub = "generate_$form->{report}";
  557. # setup vc selection
  558. $form->all_vc(\%myconfig, $form->{vc}, ($form->{vc} eq 'customer') ? "AR" : "AP");
  559. for (@{ $form->{"all_$form->{vc}"} }) { $vc .= qq|<option value="$_->{name}--$_->{id}">$_->{name}\n| }
  560. $vc = ($vc) ? qq|<select name=$form->{vc}><option>\n$vc</select>| : qq|<input name=$form->{vc} size=35>|;
  561. $postscript = "postscript" if $myconfig{printer};
  562. print qq|
  563. <tr>
  564. <th align=right>|.$locale->text($label).qq|</th>
  565. <td>$vc</td>
  566. </tr>
  567. <tr>
  568. <th align=right>|.$locale->text('To').qq|</th>
  569. <td><input name=todate size=11 title="$myconfig{dateformat}"></td>
  570. </tr>
  571. $selectto
  572. <input type=hidden name=type value=statement>
  573. <input type=hidden name=format value=$postscript>
  574. <input type=hidden name=media value="$myconfig{printer}">
  575. <input type=hidden name=nextsub value=$nextsub>
  576. <input type=hidden name=action value=$nextsub>
  577. $summary
  578. <tr>
  579. <table>
  580. <tr>
  581. <th>|.$locale->text('Include in Report').qq|</th>
  582. <td>
  583. <table>
  584. <tr>
  585. <td nowrap><input name=overdue type=radio class=radio value=0 checked> |.$locale->text('Aged').qq|</td>
  586. <td nowrap><input name=overdue type=radio class=radio value=1> |.$locale->text('Overdue').qq|</td>
  587. </tr>
  588. <tr>
  589. <td nowrap width=70><input name=c0 type=checkbox class=checkbox value=1 checked> |.$locale->text('Current').qq|</td>
  590. <td nowrap width=70><input name=c30 type=checkbox class=checkbox value=1 checked> 30</td>
  591. <td nowrap width=70><input name=c60 type=checkbox class=checkbox value=1 checked> 60</td>
  592. <td nowrap width=70><input name=c90 type=checkbox class=checkbox value=1 checked> 90</td>
  593. </td>
  594. </tr>
  595. </table>
  596. </td>
  597. </tr>
  598. </table>
  599. </tr>
  600. |;
  601. }
  602. # above action can be removed if there is more than one input field
  603. if ($form->{report} =~ /(receipts|payments)$/) {
  604. $gifi = "";
  605. $form->{db} = ($form->{report} =~ /payments$/) ? "ap" : "ar";
  606. RP->paymentaccounts(\%myconfig, \%$form);
  607. $selection = "<option>\n";
  608. foreach $ref (@{ $form->{PR} }) {
  609. $paymentaccounts .= "$ref->{accno} ";
  610. $selection .= "<option>$ref->{accno}--$ref->{description}\n";
  611. }
  612. chop $paymentaccounts;
  613. print qq|
  614. <input type=hidden name=nextsub value=list_payments>
  615. <tr>
  616. <th align=right nowrap>|.$locale->text('Account').qq|</th>
  617. <td colspan=3><select name=account>$selection</select>
  618. <input type=hidden name=paymentaccounts value="$paymentaccounts">
  619. </td>
  620. </tr>
  621. <tr>
  622. <th align=right nowrap>|.$locale->text('Description').qq|</th>
  623. <td colspan=3><input name=description size=35></td>
  624. </tr>
  625. <tr>
  626. <th align=right nowrap>|.$locale->text('Source').qq|</th>
  627. <td colspan=3><input name=source></td>
  628. </tr>
  629. <tr>
  630. <th align=right nowrap>|.$locale->text('Memo').qq|</th>
  631. <td colspan=3><input name=memo size=30></td>
  632. </tr>
  633. <tr>
  634. <th align=right>|.$locale->text('From').qq|</th>
  635. <td><input name=fromdate size=11 title="$myconfig{dateformat}" value=$form->{fromdate}></td>
  636. <th align=right>|.$locale->text('To').qq|</th>
  637. <td><input name=todate size=11 title="$myconfig{dateformat}"></td>
  638. </tr>
  639. $selectfrom
  640. <tr>
  641. <td align=right><input type=checkbox class=checkbox name=fx_transaction value=1 checked></td>
  642. <td colspan=3>|.$locale->text('Include Exchange Rate Difference').qq|</td>
  643. </tr>
  644. <tr>
  645. <td align=right><input name=l_subtotal class=checkbox type=checkbox value=Y></td>
  646. <td align=left colspan=3>|.$locale->text('Subtotal').qq|</th>
  647. </tr>
  648. <input type=hidden name=db value=$form->{db}>
  649. <input type=hidden name=sort value=transdate>
  650. |;
  651. }
  652. print qq|
  653. $gifi
  654. </table>
  655. </td>
  656. </tr>
  657. <tr>
  658. <td><hr size=3 noshade></td>
  659. </tr>
  660. </table>
  661. <br>
  662. <input type="hidden" name="path" value="$form->{path}">
  663. <input type="hidden" name="login" value="$form->{login}">
  664. <input type="hidden" name="sessionid" value="$form->{sessionid}">
  665. <button type="submit" class="submit" name="action" value="continue">|.$locale->text('Continue').qq|</button>
  666. </form>
  667. |;
  668. if ($form->{lynx}) {
  669. require "bin/menu.pl";
  670. &menubar;
  671. }
  672. print qq|
  673. </body>
  674. </html>
  675. |;
  676. }
  677. sub continue { &{$form->{nextsub}} };
  678. sub generate_inv_activity {
  679. $form->header;
  680. RP->inventory_activity(\%myconfig, \%$form);
  681. $title = $form->escape($form->{title});
  682. # if ($form->{department}) {
  683. # ($department) = split /--/, $form->{department};
  684. # $options = $locale->text('Department')." : $department<br>";
  685. # $department = $form->escape($form->{department});
  686. # }
  687. ## if ($form->{projectnumber}) {
  688. # ($projectnumber) = split /--/, $form->{projectnumber};
  689. # $options .= $locale->text('Project Number')." : $projectnumber<br>";
  690. # $projectnumber = $form->escape($form->{projectnumber});
  691. # }
  692. # if there are any dates
  693. if ($form->{fromdate} || $form->{todate}) {
  694. if ($form->{fromdate}) {
  695. $fromdate = $locale->date(\%myconfig, $form->{fromdate}, 1);
  696. }
  697. if ($form->{todate}) {
  698. $todate = $locale->date(\%myconfig, $form->{todate}, 1);
  699. }
  700. $form->{period} = "$fromdate - $todate";
  701. } else {
  702. $form->{period} = $locale->date(\%myconfig, $form->current_date(\%myconfig), 1);
  703. }
  704. $options .= $form->{period};
  705. @column_index = qw(partnumber description sold revenue received expense);
  706. $href = qq|rp.pl?path=$form->{path}&action=continue&accounttype=$form->{accounttype}&login=$form->{login}&sessionid=$form->{sessionid}&fromdate=$form->{fromdate}&todate=$form->{todate}&l_heading=$form->{l_heading}&l_subtotal=$form->{l_subtotal}&department=$department&projectnumber=$projectnumber&project_id=$form->{project_id}&title=$title&nextsub=$form->{nextsub}|;
  707. $column_header{partnumber} = qq|
  708. <th class=listheading><a class=listheading href="$href&sort_col=partnumber">|
  709. .$locale->text('Part Number').qq|</a></th>|;
  710. $column_header{description} = qq|
  711. <th class=listheading><a class=listheading href="$href&sort_col=description">|
  712. .$locale->text('Description').qq|</a></th>|;
  713. $column_header{sold} = qq|
  714. <th class=listheading><a class=listheading href="$href&sort_col=sold">|
  715. .$locale->text('Sold').qq|</a></th>|;
  716. $column_header{revenue} = qq|
  717. <th class=listheading><a class=listheading href="$href&sort_col=revenue">|
  718. .$locale->text('Revenue').qq|</a></th>|;
  719. $column_header{received} = qq|
  720. <th class=listheading><a class=listheading href="$href&sort_col=received">|
  721. .$locale->text('Received').qq|</a></th>|;
  722. $column_header{expense} = qq|
  723. <th class=listheading><a class=listheading href="$href&sort_col=expense">|
  724. .$locale->text('Expense').qq|</a></th>|;
  725. print qq|
  726. <body>
  727. <table width=100%>
  728. <tr>
  729. <th class=listtop>$form->{title}</th>
  730. </tr>
  731. <tr height="5"></tr>
  732. <tr>
  733. <td>$options</td>
  734. </tr>
  735. <tr>
  736. <td>
  737. <table width=100%>
  738. <tr>|;
  739. map { print "$column_header{$_}\n" } @column_index;
  740. print qq|
  741. </tr>
  742. |;
  743. if ($form->{sort_col} eq 'qty' || $form->{sort_col} eq 'revenue'){
  744. $form->{sort_type} = 'numeric';
  745. }
  746. $i = 0;
  747. $cols = "l_transdate=Y&l_name=Y&l_invnumber=Y&summary=1";
  748. $dates= "transdatefrom=$form->{fromdate}&transdateto=$form->{todate}&year=$form->{fromyear}&month=$form->{frommonth}&interval=$form->{interval}";
  749. $base="path=$form->{path}&login=$form->{login}&sessionid=$form->{sessionid}";
  750. $form->{callback} = "rp.pl?action=continue&$base";
  751. $form->{callback} = $form->escape($form->{callback});
  752. $callback = "callback=$form->{callback}";
  753. # sort the whole thing by account numbers and display
  754. foreach $ref (@{ $form->{TB} }) {
  755. $description = $form->escape($ref->{description});
  756. $i = $i % 2;
  757. $pnumhref="ic.pl?action=edit&id=$ref->{id}&$base&callback=$form->{callback}";
  758. $soldhref="ar.pl?action=transactions&partsid=$ref->{id}&$base&$cols&$dates&$callback";
  759. $rechref="ap.pl?action=transactions&partsid=$ref->{id}&$base&$cols&$dates&callback=$form->{callback}";
  760. $ml = ($ref->{category} =~ /(A|E)/) ? -1 : 1;
  761. $debit = $form->format_amount(\%myconfig, $ref->{debit}, 2, "&nbsp;");
  762. $credit = $form->format_amount(\%myconfig, $ref->{credit}, 2, "&nbsp;");
  763. $begbalance = $form->format_amount(\%myconfig, $ref->{balance} * $ml, 2, "&nbsp;");
  764. $endbalance = $form->format_amount(\%myconfig, ($ref->{balance} + $ref->{amount}) * $ml, 2, "&nbsp;");
  765. $ref->{partnumber} = qq|<a href="$pnumhref">$ref->{partnumber}</a>|;
  766. $ref->{sold} = qq|<a href="$soldhref">$ref->{sold}</a>|;
  767. $ref->{received} = qq|<a href="$rechref">$ref->{received}<a/>|;
  768. map { $column_data{$_} = "<td>&nbsp;</td>" }
  769. @column_index;
  770. print qq|
  771. <tr class=listrow$i>
  772. |;
  773. map { print "<td>$ref->{$_}</td>\n" } @column_index;
  774. print qq|
  775. </tr>
  776. |;
  777. ++$i;
  778. }
  779. print qq|
  780. </tr>
  781. </table>
  782. </td>
  783. </tr>
  784. <tr>
  785. <td><hr size=3 noshade></td>
  786. </tr>
  787. </table>
  788. </body>
  789. </html>
  790. |;
  791. }
  792. sub generate_income_statement {
  793. $form->{padding} = "&nbsp;&nbsp;";
  794. $form->{bold} = "<b>";
  795. $form->{endbold} = "</b>";
  796. $form->{br} = "<br>";
  797. RP->income_statement(\%myconfig, \%$form);
  798. ($form->{department}) = split /--/, $form->{department};
  799. ($form->{projectnumber}) = split /--/, $form->{projectnumber};
  800. $form->{period} = $locale->date(\%myconfig, $form->current_date(\%myconfig), 1);
  801. $form->{todate} = $form->current_date(\%myconfig) unless $form->{todate};
  802. # if there are any dates construct a where
  803. if ($form->{fromdate} || $form->{todate}) {
  804. unless ($form->{todate}) {
  805. $form->{todate} = $form->current_date(\%myconfig);
  806. }
  807. $longtodate = $locale->date(\%myconfig, $form->{todate}, 1);
  808. $shorttodate = $locale->date(\%myconfig, $form->{todate}, 0);
  809. $longfromdate = $locale->date(\%myconfig, $form->{fromdate}, 1);
  810. $shortfromdate = $locale->date(\%myconfig, $form->{fromdate}, 0);
  811. $form->{this_period} = "$shortfromdate<br>\n$shorttodate";
  812. $form->{period} = $locale->text('for Period').qq|<br>\n$longfromdate |.$locale->text('To').qq| $longtodate|;
  813. }
  814. if ($form->{comparefromdate} || $form->{comparetodate}) {
  815. $longcomparefromdate = $locale->date(\%myconfig, $form->{comparefromdate}, 1);
  816. $shortcomparefromdate = $locale->date(\%myconfig, $form->{comparefromdate}, 0);
  817. $longcomparetodate = $locale->date(\%myconfig, $form->{comparetodate}, 1);
  818. $shortcomparetodate = $locale->date(\%myconfig, $form->{comparetodate}, 0);
  819. $form->{last_period} = "$shortcomparefromdate<br>\n$shortcomparetodate";
  820. $form->{period} .= "<br>\n$longcomparefromdate ".$locale->text('To').qq| $longcomparetodate|;
  821. }
  822. # setup variables for the form
  823. @a = qw(company address businessnumber);
  824. for (@a) { $form->{$_} = $myconfig{$_} }
  825. $form->{address} =~ s/\\n/<br>/g;
  826. $form->{templates} = $myconfig{templates};
  827. $form->{IN} = "income_statement.html";
  828. if (($form->{'media'} eq 'screen') and ($form->{'format'} eq 'html')) {
  829. my $template = LedgerSMB::Template->new(\%myconfig, $form->{'formname'}, 'HTML');
  830. try {
  831. $template->render($form);
  832. $form->header;
  833. print $template->{'output'};
  834. exit;
  835. } catch Error::Simple with {
  836. my $E = shift;
  837. $form->error($E->stacktrace);
  838. };
  839. }
  840. $form->parse_template;
  841. }
  842. sub generate_balance_sheet {
  843. $form->{padding} = "&nbsp;&nbsp;";
  844. $form->{bold} = "<b>";
  845. $form->{endbold} = "</b>";
  846. $form->{br} = "<br>";
  847. RP->balance_sheet(\%myconfig, \%$form);
  848. $form->{asofdate} = $form->current_date(\%myconfig) unless $form->{asofdate};
  849. $form->{period} = $locale->date(\%myconfig, $form->current_date(\%myconfig), 1);
  850. ($form->{department}) = split /--/, $form->{department};
  851. # define Current Earnings account
  852. $padding = ($form->{l_heading}) ? $form->{padding} : "";
  853. push(@{$form->{equity_account}}, $padding.$locale->text('Current Earnings'));
  854. $form->{this_period} = $locale->date(\%myconfig, $form->{asofdate}, 0);
  855. $form->{last_period} = $locale->date(\%myconfig, $form->{compareasofdate}, 0);
  856. $form->{IN} = "balance_sheet.html";
  857. # setup company variables for the form
  858. for (qw(company address businessnumber nativecurr)) { $form->{$_} = $myconfig{$_} }
  859. $form->{address} =~ s/\\n/<br>/g;
  860. $form->{templates} = $myconfig{templates};
  861. if (($form->{'media'} eq 'screen') and ($form->{'format'} eq 'html')) {
  862. my $template = LedgerSMB::Template->new(\%myconfig, $form->{'formname'}, 'HTML');
  863. try {
  864. $template->render($form);
  865. $form->header;
  866. print $template->{'output'};
  867. exit;
  868. } catch Error::Simple with {
  869. my $E = shift;
  870. $form->error($E->stacktrace);
  871. };
  872. }
  873. $form->parse_template;
  874. }
  875. sub generate_projects {
  876. $form->{nextsub} = "generate_projects";
  877. $form->{title} = $locale->text('Project Transactions');
  878. RP->trial_balance(\%myconfig, \%$form);
  879. &list_accounts;
  880. }
  881. # Antonio Gallardo
  882. #
  883. # D.S. Feb 16, 2001
  884. # included links to display transactions for period entered
  885. # added headers and subtotals
  886. #
  887. sub generate_trial_balance {
  888. # get for each account initial balance, debits and credits
  889. RP->trial_balance(\%myconfig, \%$form);
  890. $form->{nextsub} = "generate_trial_balance";
  891. $form->{title} = $locale->text('Trial Balance');
  892. $form->{callback} = "$form->{script}?action=generate_trial_balance";
  893. for (qw(login path sessionid nextsub fromdate todate month year interval l_heading l_subtotal all_accounts accounttype title)) { $form->{callback} .= "&$_=$form->{$_}" }
  894. $form->{callback} = $form->escape($form->{callback});
  895. &list_accounts;
  896. }
  897. sub list_accounts {
  898. $title = $form->escape($form->{title});
  899. if ($form->{department}) {
  900. ($department) = split /--/, $form->{department};
  901. $options = $locale->text('Department')." : $department<br>";
  902. $department = $form->escape($form->{department});
  903. }
  904. if ($form->{projectnumber}) {
  905. ($projectnumber) = split /--/, $form->{projectnumber};
  906. $options .= $locale->text('Project Number')." : $projectnumber<br>";
  907. $projectnumber = $form->escape($form->{projectnumber});
  908. }
  909. # if there are any dates
  910. if ($form->{fromdate} || $form->{todate}) {
  911. if ($form->{fromdate}) {
  912. $fromdate = $locale->date(\%myconfig, $form->{fromdate}, 1);
  913. }
  914. if ($form->{todate}) {
  915. $todate = $locale->date(\%myconfig, $form->{todate}, 1);
  916. }
  917. $form->{period} = "$fromdate - $todate";
  918. } else {
  919. $form->{period} = $locale->date(\%myconfig, $form->current_date(\%myconfig), 1);
  920. }
  921. $options .= $form->{period};
  922. @column_index = qw(accno description begbalance debit credit endbalance);
  923. $column_header{accno} = qq|<th class=listheading>|.$locale->text('Account').qq|</th>|;
  924. $column_header{description} = qq|<th class=listheading>|.$locale->text('Description').qq|</th>|;
  925. $column_header{debit} = qq|<th class=listheading>|.$locale->text('Debit').qq|</th>|;
  926. $column_header{credit} = qq|<th class=listheading>|.$locale->text('Credit').qq|</th>|;
  927. $column_header{begbalance} = qq|<th class=listheading>|.$locale->text('Balance').qq|</th>|;
  928. $column_header{endbalance} = qq|<th class=listheading>|.$locale->text('Balance').qq|</th>|;
  929. if ($form->{accounttype} eq 'gifi') {
  930. $column_header{accno} = qq|<th class=listheading>|.$locale->text('GIFI').qq|</th>|;
  931. }
  932. $form->header;
  933. print qq|
  934. <body>
  935. <table width=100%>
  936. <tr>
  937. <th class=listtop>$form->{title}</th>
  938. </tr>
  939. <tr height="5"></tr>
  940. <tr>
  941. <td>$options</td>
  942. </tr>
  943. <tr>
  944. <td>
  945. <table width=100%>
  946. <tr>|;
  947. for (@column_index) { print "$column_header{$_}\n" }
  948. print qq|
  949. </tr>
  950. |;
  951. # sort the whole thing by account numbers and display
  952. foreach $ref (sort { $a->{accno} cmp $b->{accno} } @{ $form->{TB} }) {
  953. $description = $form->escape($ref->{description});
  954. $href = qq|ca.pl?path=$form->{path}&action=list_transactions&accounttype=$form->{accounttype}&login=$form->{login}&sessionid=$form->{sessionid}&fromdate=$form->{fromdate}&todate=$form->{todate}&sort=transdate&l_heading=$form->{l_heading}&l_subtotal=$form->{l_subtotal}&department=$department&projectnumber=$projectnumber&project_id=$form->{project_id}&title=$title&nextsub=$form->{nextsub}&prevreport=$form->{callback}|;
  955. if ($form->{accounttype} eq 'gifi') {
  956. $href .= "&gifi_accno=$ref->{accno}&gifi_description=$description";
  957. $na = $locale->text('N/A');
  958. if (!$ref->{accno}) {
  959. for (qw(accno description)) { $ref->{$_} = $na }
  960. }
  961. } else {
  962. $href .= "&accno=$ref->{accno}&description=$description";
  963. }
  964. $ml = ($ref->{category} =~ /(A|E)/) ? -1 : 1;
  965. $ml *= -1 if $ref->{contra};
  966. $debit = $form->format_amount(\%myconfig, $ref->{debit}, 2, "&nbsp;");
  967. $credit = $form->format_amount(\%myconfig, $ref->{credit}, 2, "&nbsp;");
  968. $begbalance = $form->format_amount(\%myconfig, $ref->{balance} * $ml, 2, "&nbsp;");
  969. $endbalance = $form->format_amount(\%myconfig, ($ref->{balance} + $ref->{amount}) * $ml, 2, "&nbsp;");
  970. if ($ref->{charttype} eq "H" && $subtotal && $form->{l_subtotal}) {
  971. if ($subtotal) {
  972. for (qw(accno begbalance endbalance)) { $column_data{$_} = "<th>&nbsp;</th>" }
  973. $subtotalbegbalance = $form->format_amount(\%myconfig, $subtotalbegbalance, 2, "&nbsp;");
  974. $subtotalendbalance = $form->format_amount(\%myconfig, $subtotalendbalance, 2, "&nbsp;");
  975. $subtotaldebit = $form->format_amount(\%myconfig, $subtotaldebit, 2, "&nbsp;");
  976. $subtotalcredit = $form->format_amount(\%myconfig, $subtotalcredit, 2, "&nbsp;");
  977. $column_data{description} = "<th class=listsubtotal>$subtotaldescription</th>";
  978. $column_data{begbalance} = "<th align=right class=listsubtotal>$subtotalbegbalance</th>";
  979. $column_data{endbalance} = "<th align=right class=listsubtotal>$subtotalendbalance</th>";
  980. $column_data{debit} = "<th align=right class=listsubtotal>$subtotaldebit</th>";
  981. $column_data{credit} = "<th align=right class=listsubtotal>$subtotalcredit</th>";
  982. print qq|
  983. <tr class=listsubtotal>
  984. |;
  985. for (@column_index) { print "$column_data{$_}\n" }
  986. print qq|
  987. </tr>
  988. |;
  989. }
  990. }
  991. if ($ref->{charttype} eq "H") {
  992. $subtotal = 1;
  993. $subtotaldescription = $ref->{description};
  994. $subtotaldebit = $ref->{debit};
  995. $subtotalcredit = $ref->{credit};
  996. $subtotalbegbalance = 0;
  997. $subtotalendbalance = 0;
  998. if ($form->{l_heading}) {
  999. if (! $form->{all_accounts}) {
  1000. if (($subtotaldebit + $subtotalcredit) == 0) {
  1001. $subtotal = 0;
  1002. next;
  1003. }
  1004. }
  1005. } else {
  1006. $subtotal = 0;
  1007. if ($form->{all_accounts} || ($form->{l_subtotal} && (($subtotaldebit + $subtotalcredit) != 0))) {
  1008. $subtotal = 1;
  1009. }
  1010. next;
  1011. }
  1012. for (qw(accno debit credit begbalance endbalance)) { $column_data{$_} = "<th>&nbsp;</th>" }
  1013. $column_data{description} = "<th class=listheading>$ref->{description}</th>";
  1014. }
  1015. if ($ref->{charttype} eq "A") {
  1016. $column_data{accno} = "<td><a href=$href>$ref->{accno}</a></td>";
  1017. $column_data{description} = "<td>$ref->{description}</td>";
  1018. $column_data{debit} = "<td align=right>$debit</td>";
  1019. $column_data{credit} = "<td align=right>$credit</td>";
  1020. $column_data{begbalance} = "<td align=right>$begbalance</td>";
  1021. $column_data{endbalance} = "<td align=right>$endbalance</td>";
  1022. $totaldebit += $ref->{debit};
  1023. $totalcredit += $ref->{credit};
  1024. $cml = ($ref->{contra}) ? -1 : 1;
  1025. $subtotalbegbalance += $ref->{balance} * $ml * $cml;
  1026. $subtotalendbalance += ($ref->{balance} + $ref->{amount}) * $ml * $cml;
  1027. }
  1028. if ($ref->{charttype} eq "H") {
  1029. print qq|
  1030. <tr class=listheading>
  1031. |;
  1032. }
  1033. if ($ref->{charttype} eq "A") {
  1034. $i++; $i %= 2;
  1035. print qq|
  1036. <tr class=listrow$i>
  1037. |;
  1038. }
  1039. for (@column_index) { print "$column_data{$_}\n" }
  1040. print qq|
  1041. </tr>
  1042. |;
  1043. }
  1044. # print last subtotal
  1045. if ($subtotal && $form->{l_subtotal}) {
  1046. for (qw(accno begbalance endbalance)) { $column_data{$_} = "<th>&nbsp;</th>" }
  1047. $subtotalbegbalance = $form->format_amount(\%myconfig, $subtotalbegbalance, 2, "&nbsp;");
  1048. $subtotalendbalance = $form->format_amount(\%myconfig, $subtotalendbalance, 2, "&nbsp;");
  1049. $subtotaldebit = $form->format_amount(\%myconfig, $subtotaldebit, 2, "&nbsp;");
  1050. $subtotalcredit = $form->format_amount(\%myconfig, $subtotalcredit, 2, "&nbsp;");
  1051. $column_data{description} = "<th class=listsubtotal>$subtotaldescription</th>";
  1052. $column_data{begbalance} = "<th align=right class=listsubtotal>$subtotalbegbalance</th>";
  1053. $column_data{endbalance} = "<th align=right class=listsubtotal>$subtotalendbalance</th>";
  1054. $column_data{debit} = "<th align=right class=listsubtotal>$subtotaldebit</th>";
  1055. $column_data{credit} = "<th align=right class=listsubtotal>$subtotalcredit</th>";
  1056. print qq|
  1057. <tr class=listsubtotal>
  1058. |;
  1059. for (@column_index) { print "$column_data{$_}\n" }
  1060. print qq|
  1061. </tr>
  1062. |;
  1063. }
  1064. $totaldebit = $form->format_amount(\%myconfig, $totaldebit, 2, "&nbsp;");
  1065. $totalcredit = $form->format_amount(\%myconfig, $totalcredit, 2, "&nbsp;");
  1066. for (qw(accno description begbalance endbalance)) { $column_data{$_} = "<th>&nbsp;</th>" }
  1067. $column_data{debit} = qq|<th align=right class=listtotal>$totaldebit</th>|;
  1068. $column_data{credit} = qq|<th align=right class=listtotal>$totalcredit</th>|;
  1069. print qq|
  1070. <tr class=listtotal>
  1071. |;
  1072. for (@column_index) { print "$column_data{$_}\n" }
  1073. print qq|
  1074. </tr>
  1075. </table>
  1076. </td>
  1077. </tr>
  1078. <tr>
  1079. <td><hr size=3 noshade></td>
  1080. </tr>
  1081. </table>
  1082. </body>
  1083. </html>
  1084. |;
  1085. }
  1086. sub generate_ar_aging {
  1087. # split customer
  1088. ($form->{customer}) = split(/--/, $form->{customer});
  1089. $customer = $form->escape($form->{customer},1);
  1090. $title = $form->escape($form->{title},1);
  1091. $media = $form->escape($form->{media},1);
  1092. $form->{ct} = "customer";
  1093. $form->{arap} = "ar";
  1094. RP->aging(\%myconfig, \%$form);
  1095. $form->{callback} = qq|$form->{script}?path=$form->{path}&action=generate_ar_aging&login=$form->{login}&sessionid=$form->{sessionid}&todate=$form->{todate}&customer=$customer&title=$title&type=$form->{type}&format=$form->{format}&media=$media&summary=$form->{summary}|;
  1096. &aging;
  1097. }
  1098. sub generate_ap_aging {
  1099. # split vendor
  1100. ($form->{vendor}) = split(/--/, $form->{vendor});
  1101. $vendor = $form->escape($form->{vendor},1);
  1102. $title = $form->escape($form->{title},1);
  1103. $media = $form->escape($form->{media},1);
  1104. $form->{ct} = "vendor";
  1105. $form->{arap} = "ap";
  1106. RP->aging(\%myconfig, \%$form);
  1107. $form->{callback} = qq|$form->{script}?path=$form->{path}&action=generate_ap_aging&login=$form->{login}&sessionid=$form->{sessionid}&todate=$form->{todate}&vendor=$vendor&title=$title&type=$form->{type}&format=$form->{format}&media=$media&summary=$form->{summary}|;
  1108. &aging;
  1109. }
  1110. sub aging {
  1111. $form->header;
  1112. $column_header{statement} = qq|<th class=listheading width=1%>&nbsp;</th>|;
  1113. $column_header{ct} = qq|<th class=listheading width=60%>|.$locale->text(ucfirst $form->{ct}).qq|</th>|;
  1114. $column_header{language} = qq|<th class=listheading>|.$locale->text('Language').qq|</th>|;
  1115. $column_header{invnumber} = qq|<th class=listheading>|.$locale->text('Invoice').qq|</th>|;
  1116. $column_header{ordnumber} = qq|<th class=listheading>|.$locale->text('Order').qq|</th>|;
  1117. $column_header{transdate} = qq|<th class=listheading nowrap>|.$locale->text('Date').qq|</th>|;
  1118. $column_header{duedate} = qq|<th class=listheading nowrap>|.$locale->text('Due Date').qq|</th>|;
  1119. $column_header{c0} = qq|<th class=listheading width=10% nowrap>|.$locale->text('Current').qq|</th>|;
  1120. $column_header{c30} = qq|<th class=listheading width=10% nowrap>30</th>|;
  1121. $column_header{c60} = qq|<th class=listheading width=10% nowrap>60</th>|;
  1122. $column_header{c90} = qq|<th class=listheading width=10% nowrap>90</th>|;
  1123. $column_header{total} = qq|<th class=listheading width=10% nowrap>|.$locale->text('Total').qq|</th>|;
  1124. @column_index = qw(statement ct);
  1125. if (@{ $form->{all_language} } && $form->{arap} eq 'ar') {
  1126. push @column_index, "language";
  1127. $form->{selectlanguage} = qq|<option>\n|;
  1128. for (@{ $form->{all_language} }) { $form->{selectlanguage} .= qq|<option value="$_->{code}">$_->{description}\n| }
  1129. }
  1130. @c = ();
  1131. for (qw(c0 c30 c60 c90)) {
  1132. if ($form->{$_}) {
  1133. push @c, $_;
  1134. $form->{callback} .= "&$_=$form->{$_}";
  1135. }
  1136. }
  1137. if (!$form->{summary}) {
  1138. push @column_index, qw(invnumber ordnumber transdate duedate);
  1139. }
  1140. push @column_index, @c;
  1141. push @column_index, "total";
  1142. $option = $locale->text('Aged');
  1143. if ($form->{overdue}) {
  1144. $option= $locale->text('Aged Overdue');
  1145. $form->{callback} .= "&overdue=$form->{overdue}";
  1146. }
  1147. if ($form->{department}) {
  1148. $option .= "\n<br>" if $option;
  1149. ($department) = split /--/, $form->{department};
  1150. $option .= $locale->text('Department')." : $department";
  1151. $department = $form->escape($form->{department},1);
  1152. $form->{callback} .= "&department=$department";
  1153. }
  1154. if ($form->{arap} eq 'ar') {
  1155. if ($form->{customer}) {
  1156. $option .= "\n<br>" if $option;
  1157. $option .= $form->{customer};
  1158. }
  1159. }
  1160. if ($form->{arap} eq 'ap') {
  1161. shift @column_index;
  1162. if ($form->{vendor}) {
  1163. $option .= "\n<br>" if $option;
  1164. $option .= $form->{vendor};
  1165. }
  1166. }
  1167. $todate = $locale->date(\%myconfig, $form->{todate}, 1);
  1168. $option .= "\n<br>" if $option;
  1169. $option .= $locale->text('for Period')." ".$locale->text('To')." $todate";
  1170. print qq|
  1171. <body>
  1172. <form method=post action=$form->{script}>
  1173. <table width=100%>
  1174. <tr>
  1175. <th class=listtop>$form->{title}</th>
  1176. </tr>
  1177. <tr height="5"></tr>
  1178. <tr>
  1179. <td>$option</td>
  1180. </tr>
  1181. <tr>
  1182. <td>
  1183. <table width=100%>
  1184. |;
  1185. $ctid = 0;
  1186. $i = 0;
  1187. $k = 0;
  1188. $l = $#{ $form->{AG} };
  1189. foreach $ref (@{ $form->{AG} }) {
  1190. if ($curr ne $ref->{curr}) {
  1191. $ctid = 0;
  1192. for (@column_index) { $column_data{$_} = qq|<th>&nbsp;</th>| }
  1193. if ($curr) {
  1194. $c0total = $form->format_amount(\%myconfig, $c0total, 2, "&nbsp");
  1195. $c30total = $form->format_amount(\%myconfig, $c30total, 2, "&nbsp");
  1196. $c60total = $form->format_amount(\%myconfig, $c60total, 2, "&nbsp");
  1197. $c90total = $form->format_amount(\%myconfig, $c90total, 2, "&nbsp");
  1198. $total = $form->format_amount(\%myconfig, $total, 2, "&nbsp");
  1199. for (qw(ct statement language)) { $column_data{$_} = qq|<td>&nbsp;</td>| }
  1200. $column_data{c0} = qq|<th align=right>$c0total</th>|;
  1201. $column_data{c30} = qq|<th align=right>$c30total</th>|;
  1202. $column_data{c60} = qq|<th align=right>$c60total</th>|;
  1203. $column_data{c90} = qq|<th align=right>$c90total</th>|;
  1204. $column_data{total} = qq|<th align=right>$total</th>|;
  1205. print qq|
  1206. <tr class=listtotal>
  1207. |;
  1208. for (@column_index) { print "$column_data{$_}\n" }
  1209. print qq|
  1210. </tr>
  1211. |;
  1212. $c0subtotal = 0;
  1213. $c30subtotal = 0;
  1214. $c60subtotal = 0;
  1215. $c90subtotal = 0;
  1216. $subtotal = 0;
  1217. $c0total = 0;
  1218. $c30total = 0;
  1219. $c60total = 0;
  1220. $c90total = 0;
  1221. $total = 0;
  1222. }
  1223. $curr = $ref->{curr};
  1224. print qq|
  1225. <tr>
  1226. <td></td>
  1227. <th>$curr</th>
  1228. </tr>
  1229. <tr class=listheading>
  1230. |;
  1231. for (@column_index) { print "$column_header{$_}\n" }
  1232. print qq|
  1233. </tr>
  1234. |;
  1235. }
  1236. $k++;
  1237. if ($ctid != $ref->{ctid}) {
  1238. $i++;
  1239. $column_data{ct} = qq|<td>$ref->{name}</td>|;
  1240. if ($form->{selectlanguage}) {
  1241. $form->{"selectlanguage_$i"} = $form->{selectlanguage};
  1242. $form->{"selectlanguage_$i"} =~ s/(<option value="\Q$ref->{language_code}\E")/$1 selected/;
  1243. $column_data{language} = qq|<td><select name="language_code_$i">$form->{"selectlanguage_$i"}</select></td>|;
  1244. }
  1245. $column_data{statement} = qq|<td><input name="statement_$i" type=checkbox class=checkbox value=1 $ref->{checked}>
  1246. <input type=hidden name="$form->{ct}_id_$i" value=$ref->{ctid}>
  1247. <input type=hidden name="curr_$i" value=$ref->{curr}>
  1248. </td>|;
  1249. }
  1250. $ctid = $ref->{ctid};
  1251. for (qw(c0 c30 c60 c90)) { $ref->{$_} = $form->round_amount($ref->{$_} / $ref->{exchangerate}, 2) }
  1252. $c0subtotal += $ref->{c0};
  1253. $c30subtotal += $ref->{c30};
  1254. $c60subtotal += $ref->{c60};
  1255. $c90subtotal += $ref->{c90};
  1256. $c0total += $ref->{c0};
  1257. $c30total += $ref->{c30};
  1258. $c60total += $ref->{c60};
  1259. $c90total += $ref->{c90};
  1260. $ref->{total} = ($ref->{c0} + $ref->{c30} + $ref->{c60} + $ref->{c90});
  1261. $subtotal += $ref->{total};
  1262. $total += $ref->{total};
  1263. $ref->{c0} = $form->format_amount(\%myconfig, $ref->{c0}, 2, "&nbsp;");
  1264. $ref->{c30} = $form->format_amount(\%myconfig, $ref->{c30}, 2, "&nbsp;");
  1265. $ref->{c60} = $form->format_amount(\%myconfig, $ref->{c60}, 2, "&nbsp;");
  1266. $ref->{c90} = $form->format_amount(\%myconfig, $ref->{c90}, 2, "&nbsp;");
  1267. $ref->{total} = $form->format_amount(\%myconfig, $ref->{total}, 2, "&nbsp;");
  1268. $href = qq|$ref->{module}.pl?path=$form->{path}&action=edit&id=$ref->{id}&login=$form->{login}&sessionid=$form->{sessionid}&callback=|.$form->escape($form->{callback});
  1269. $column_data{invnumber} = qq|<td><a href=$href>$ref->{invnumber}</a></td>|;
  1270. for (qw(ordnumber transdate duedate)) { $column_data{$_} = qq|<td>$ref->{$_}</td>| }
  1271. for (qw(c0 c30 c60 c90 total)) { $column_data{$_} = qq|<td align=right>$ref->{$_}</td>| }
  1272. if (!$form->{summary}) {
  1273. $j++; $j %= 2;
  1274. print qq|
  1275. <tr class=listrow$j>
  1276. |;
  1277. for (@column_index) { print "$column_data{$_}\n" }
  1278. print qq|
  1279. </tr>
  1280. |;
  1281. for (qw(ct statement language)) { $column_data{$_} = qq|<td>&nbsp;</td>| }
  1282. }
  1283. # print subtotal
  1284. $nextid = ($k <= $l) ? $form->{AG}->[$k]->{ctid} : 0;
  1285. if ($ctid != $nextid) {
  1286. $c0subtotal = $form->format_amount(\%myconfig, $c0subtotal, 2, "&nbsp");
  1287. $c30subtotal = $form->format_amount(\%myconfig, $c30subtotal, 2, "&nbsp");
  1288. $c60subtotal = $form->format_amount(\%myconfig, $c60subtotal, 2, "&nbsp");
  1289. $c90subtotal = $form->format_amount(\%myconfig, $c90subtotal, 2, "&nbsp");
  1290. $subtotal = $form->format_amount(\%myconfig, $subtotal, 2, "&nbsp");
  1291. if ($form->{summary}) {
  1292. $column_data{c0} = qq|<td align=right>$c0subtotal</th>|;
  1293. $column_data{c30} = qq|<td align=right>$c30subtotal</th>|;
  1294. $column_data{c60} = qq|<td align=right>$c60subtotal</th>|;
  1295. $column_data{c90} = qq|<td align=right>$c90subtotal</th>|;
  1296. $column_data{total} = qq|<td align=right>$subtotal</th>|;
  1297. $j++; $j %= 2;
  1298. print qq|
  1299. <tr class=listrow$j>
  1300. |;
  1301. for (@column_index) { print "$column_data{$_}\n" }
  1302. print qq|
  1303. </tr>
  1304. |;
  1305. } else {
  1306. for (@column_index) { $column_data{$_} = qq|<th>&nbsp;</th>| }
  1307. $column_data{c0} = qq|<th class=listsubtotal align=right>$c0subtotal</th>|;
  1308. $column_data{c30} = qq|<th class=listsubtotal align=right>$c30subtotal</th>|;
  1309. $column_data{c60} = qq|<th class=listsubtotal align=right>$c60subtotal</th>|;
  1310. $column_data{c90} = qq|<th class=listsubtotal align=right>$c90subtotal</th>|;
  1311. $column_data{total} = qq|<th class=listsubtotal align=right>$subtotal</th>|;
  1312. # print subtotals
  1313. print qq|
  1314. <tr class=listsubtotal>
  1315. |;
  1316. for (@column_index) { print "$column_data{$_}\n" }
  1317. print qq|
  1318. </tr>
  1319. |;
  1320. }
  1321. $c0subtotal = 0;
  1322. $c30subtotal = 0;
  1323. $c60subtotal = 0;
  1324. $c90subtotal = 0;
  1325. $subtotal = 0;
  1326. }
  1327. }
  1328. print qq|
  1329. </tr>
  1330. <tr class=listtotal>
  1331. |;
  1332. for (@column_index) { $column_data{$_} = qq|<th>&nbsp;</th>| }
  1333. $c0total = $form->format_amount(\%myconfig, $c0total, 2, "&nbsp;");
  1334. $c30total = $form->format_amount(\%myconfig, $c30total, 2, "&nbsp;");
  1335. $c60total = $form->format_amount(\%myconfig, $c60total, 2, "&nbsp;");
  1336. $c90total = $form->format_amount(\%myconfig, $c90total, 2, "&nbsp;");
  1337. $total = $form->format_amount(\%myconfig, $total, 2, "&nbsp;");
  1338. $column_data{c0} = qq|<th align=right class=listtotal>$c0total</th>|;
  1339. $column_data{c30} = qq|<th align=right class=listtotal>$c30total</th>|;
  1340. $column_data{c60} = qq|<th align=right class=listtotal>$c60total</th>|;
  1341. $column_data{c90} = qq|<th align=right class=listtotal>$c90total</th>|;
  1342. $column_data{total} = qq|<th align=right class=listtotal>$total</th>|;
  1343. for (@column_index) { print "$column_data{$_}\n" }
  1344. print qq|
  1345. </tr>
  1346. <input type=hidden name=rowcount value=$i>
  1347. </table>
  1348. </td>
  1349. </tr>
  1350. <tr>
  1351. <td>
  1352. |;
  1353. &print_options if ($form->{arap} eq 'ar');
  1354. print qq|
  1355. </td>
  1356. </tr>
  1357. <tr>
  1358. <td><hr size=3 noshade></td>
  1359. </tr>
  1360. </table>
  1361. |;
  1362. if ($form->{arap} eq 'ar') {
  1363. $form->hide_form(qw(todate title summary overdue c0 c30 c60 c90 callback arap ct department path login sessionid));
  1364. print qq|
  1365. <input type=hidden name=$form->{ct} value="$form->{$form->{ct}}">
  1366. |;
  1367. # type=submit $locale->text('Select all')
  1368. # type=submit $locale->text('Print')
  1369. # type=submit $locale->text('E-mail')
  1370. %button = ('select_all' => { ndx => 1, key => 'A', value => $locale->text('Select all') },
  1371. 'print' => { ndx => 2, key => 'P', value => $locale->text('Print') },
  1372. 'e_mail' => { ndx => 5, key => 'E', value => $locale->text('E-mail') },
  1373. );
  1374. for (sort { $button{$a}->{ndx} <=> $button{$b}->{ndx} } keys %button) { $form->print_button(\%button, $_) }
  1375. }
  1376. if ($form->{lynx}) {
  1377. require "bin/menu.pl";
  1378. &menubar;
  1379. }
  1380. print qq|
  1381. </form>
  1382. </body>
  1383. </html>
  1384. |;
  1385. }
  1386. sub select_all {
  1387. RP->aging(\%myconfig, \%$form);
  1388. for (@{ $form->{AG} }) { $_->{checked} = "checked" }
  1389. &aging;
  1390. }
  1391. sub print_options {
  1392. $form->{sendmode} = "attachment";
  1393. $form->{copies} = 1 unless $form->{copies};
  1394. $form->{PD}{$form->{type}} = "selected";
  1395. $form->{DF}{$form->{format}} = "selected";
  1396. $form->{SM}{$form->{sendmode}} = "selected";
  1397. $format = qq|
  1398. <option value=html $form->{PD}{format}>html|;
  1399. $type = qq|
  1400. <option value=statement $form->{PD}{statement}>|.$locale->text('Statement');
  1401. if ($form->{media} eq 'email') {
  1402. $media = qq|
  1403. <td><select name=sendmode>
  1404. <option value=attachment $form->{SM}{attachment}>|.$locale->text('Attachment').qq|
  1405. <option value=inline $form->{SM}{inline}>|.$locale->text('In-line');
  1406. } else {
  1407. $media = qq|
  1408. <td><select name=media>
  1409. <option value=screen>|.$locale->text('Screen');
  1410. if (%{LedgerSMB::Sysconfig::printer} && ${LedgerSMB::Sysconfig::latex}) {
  1411. for (sort keys %{LedgerSMB::Sysconfig::printer}) { $media .= qq|
  1412. <option value="$_">$_| }
  1413. }
  1414. }
  1415. $media =~ s/(<option value="\Q$form->{media}\E")/$1 selected/;
  1416. $media .= qq|</select></td>|;
  1417. if (${LedgerSMB::Sysconfig::latex}) {
  1418. $format .= qq|
  1419. <option value=postscript $form->{DF}{postscript}>|.$locale->text('Postscript').qq|
  1420. <option value=pdf $form->{DF}{pdf}>|.$locale->text('PDF');
  1421. }
  1422. print qq|
  1423. <table>
  1424. <tr>
  1425. <td><select name=type>$type</select></td>
  1426. <td><select name=format>$format</select></td>
  1427. $media
  1428. |;
  1429. if (%{LedgerSMB::Sysconfig::printer} && ${LedgerSMB::Sysconfig::latex} && $form->{media} ne 'email') {
  1430. print qq|
  1431. <td>|.$locale->text('Copies').qq|
  1432. <input name=copies size=2 value=$form->{copies}></td>
  1433. |;
  1434. }
  1435. print qq|
  1436. </tr>
  1437. </table>
  1438. |;
  1439. }
  1440. sub e_mail {
  1441. # get name and email addresses
  1442. for $i (1 .. $form->{rowcount}) {
  1443. if ($form->{"statement_$i"}) {
  1444. $form->{"$form->{ct}_id"} = $form->{"$form->{ct}_id_$i"};
  1445. $form->{"statement_1"} = 1;
  1446. $form->{"language_code_1"} = $form->{"language_code_$i"};
  1447. $form->{"curr_1"} = $form->{"curr_$i"};
  1448. RP->get_customer(\%myconfig, \%$form);
  1449. $selected = 1;
  1450. last;
  1451. }
  1452. }
  1453. $form->error($locale->text('Nothing selected!')) unless $selected;
  1454. if ($myconfig{role} =~ /(admin|manager)/) {
  1455. $bcc = qq|
  1456. <th align=right nowrap=true>|.$locale->text('Bcc').qq|</th>
  1457. <td><input name=bcc size=30 value="$form->{bcc}"></td>
  1458. |;
  1459. }
  1460. $title = $locale->text('E-mail Statement to [_1]', $form->{$form->{ct}});
  1461. $form->{media} = "email";
  1462. $form->header;
  1463. print qq|
  1464. <body>
  1465. <form method=post action=$form->{script}>
  1466. <table width=100%>
  1467. <tr class=listtop>
  1468. <th>$title</th>
  1469. </tr>
  1470. <tr height="5"></tr>
  1471. <tr>
  1472. <td>
  1473. <table width=100%>
  1474. <tr>
  1475. <th align=right nowrap>|.$locale->text('E-mail').qq|</th>
  1476. <td><input name=email size=30 value="$form->{email}"></td>
  1477. <th align=right nowrap>|.$locale->text('Cc').qq|</th>
  1478. <td><input name=cc size=30 value="$form->{cc}"></td>
  1479. </tr>
  1480. <tr>
  1481. <th align=right nowrap>|.$locale->text('Subject').qq|</th>
  1482. <td><input name=subject size=30 value="$form->{subject}"></td>
  1483. $bcc
  1484. </tr>
  1485. </table>
  1486. </td>
  1487. </tr>
  1488. <tr>
  1489. <td>
  1490. <table width=100%>
  1491. <tr>
  1492. <th align=left nowrap>|.$locale->text('Message').qq|</th>
  1493. </tr>
  1494. <tr>
  1495. <td><textarea name=message rows=15 cols=60 wrap=soft>$form->{message}</textarea></td>
  1496. </tr>
  1497. </table>
  1498. </td>
  1499. </tr>
  1500. <tr>
  1501. <td>
  1502. |;
  1503. &print_options;
  1504. for (qw(email cc bcc subject message type sendmode format action nextsub)) { delete $form->{$_} }
  1505. $form->hide_form;
  1506. print qq|
  1507. </td>
  1508. </tr>
  1509. <tr>
  1510. <td><hr size=3 noshade></td>
  1511. </tr>
  1512. </table>
  1513. <input type="hidden" name="nextsub" value="send_email">
  1514. <br>
  1515. <button name="action" class="submit" type="submit" value="continue">|.$locale->text('Continue').qq|</button>
  1516. </form>
  1517. </body>
  1518. </html>
  1519. |;
  1520. }
  1521. sub send_email {
  1522. $form->{OUT} = "${LedgerSMB::Sysconfig::sendmail}";
  1523. $form->{printmode} = '|-';
  1524. $form->{subject} = $locale->text('Statement - [_1]', $form->{todate}) unless $form->{subject};
  1525. $form->isblank("email", $locale->text('E-mail address missing!'));
  1526. RP->aging(\%myconfig, \%$form);
  1527. &print_form;
  1528. $form->redirect($locale->text('Statement sent to [_1]', $form->{$form->{ct}}));
  1529. }
  1530. sub print {
  1531. if ($form->{media} !~ /(screen|email)/) {
  1532. $form->error($locale->text('Select postscript or PDF!')) if ($form->{format} !~ /(postscript|pdf)/);
  1533. }
  1534. for $i (1 .. $form->{rowcount}) {
  1535. if ($form->{"statement_$i"}) {
  1536. $form->{"$form->{ct}_id"} = $form->{"$form->{ct}_id_$i"};
  1537. $language_code = $form->{"language_code_$i"};
  1538. $curr = $form->{"curr_$i"};
  1539. $selected = 1;
  1540. last;
  1541. }
  1542. }
  1543. $form->error($locale->text('Nothing selected!')) unless $selected;
  1544. if ($form->{media} !~ /(screen|email)/) {
  1545. $form->{OUT} = "${LedgerSMB::Sysconfig::printer}{$form->{media}}";
  1546. $form->{printmode} = '|-';
  1547. $form->{"$form->{ct}_id"} = "";
  1548. $SIG{INT} = 'IGNORE';
  1549. } else {
  1550. $form->{"statement_1"} = 1;
  1551. $form->{"language_code_1"} = $language_code;
  1552. $form->{"curr_1"} = $curr;
  1553. }
  1554. RP->aging(\%myconfig, \%$form);
  1555. &print_form;
  1556. $form->redirect($locale->text('Statements sent to printer!')) if ($form->{media} !~ /(screen|email)/);
  1557. }
  1558. sub print_form {
  1559. $form->{statementdate} = $locale->date(\%myconfig, $form->{todate}, 1);
  1560. $form->{templates} = "$myconfig{templates}";
  1561. # setup variables for the form
  1562. @a = qw(company address businessnumber tel fax);
  1563. for (@a) { $form->{$_} = $myconfig{$_} }
  1564. $form->{address} =~ s/\\n/\n/g;
  1565. $form->format_string(@a);
  1566. $form->{IN} = "$form->{type}.html";
  1567. if ($form->{format} eq 'postscript') {
  1568. $form->{IN} =~ s/html$/tex/;
  1569. }
  1570. if ($form->{format} eq 'pdf') {
  1571. $form->{IN} =~ s/html$/tex/;
  1572. }
  1573. @a = qw(name address1 address2 city state zipcode country contact);
  1574. push @a, "$form->{ct}phone", "$form->{ct}fax", "$form->{ct}taxnumber";
  1575. push @a, 'email' if ! $form->{media} eq 'email';
  1576. $i = 0;
  1577. while (@{ $form->{AG} }) {
  1578. $ref = shift @{ $form->{AG} };
  1579. if ($ctid != $ref->{ctid}) {
  1580. $ctid = $ref->{ctid};
  1581. $i++;
  1582. if ($form->{"statement_$i"}) {
  1583. for (@a) { $form->{$_} = $ref->{$_} }
  1584. $form->format_string(@a);
  1585. $form->{$form->{ct}} = $form->{name};
  1586. $form->{"$form->{ct}_id"} = $ref->{ctid};
  1587. $form->{language_code} = $form->{"language_code_$i"};
  1588. $form->{currency} = $form->{"curr_$i"};
  1589. for (qw(invnumber ordnumber ponumber notes invdate duedate)) { $form->{$_} = () }
  1590. $form->{total} = 0;
  1591. foreach $item (qw(c0 c30 c60 c90)) {
  1592. $form->{$item} = ();
  1593. $form->{"${item}total"} = 0;
  1594. }
  1595. &statement_details($ref) if $ref->{curr} eq $form->{currency};
  1596. while ($ref) {
  1597. if (scalar (@{ $form->{AG} }) > 0) {
  1598. # one or more left to go
  1599. if ($ctid == $form->{AG}->[0]->{ctid}) {
  1600. $ref = shift @{ $form->{AG} };
  1601. &statement_details($ref) if $ref->{curr} eq $form->{currency};
  1602. # any more?
  1603. $ref = scalar (@{ $form->{AG} });
  1604. } else {
  1605. $ref = 0;
  1606. }
  1607. } else {
  1608. # set initial ref to 0
  1609. $ref = 0;
  1610. }
  1611. }
  1612. for ("c0", "c30", "c60", "c90", "") { $form->{"${_}total"} = $form->format_amount(\%myconfig, $form->{"${_}total"}, 2) }
  1613. if (($form->{'media'} eq 'screen') and ($form->{'format'} eq 'html')) {
  1614. my $template = LedgerSMB::Template->new(\%myconfig, $form->{'formname'}, 'HTML');
  1615. try {
  1616. $template->render($form);
  1617. $form->header;
  1618. print $template->{'output'};
  1619. exit;
  1620. } catch Error::Simple with {
  1621. my $E = shift;
  1622. $form->error($E->stacktrace);
  1623. };
  1624. }
  1625. $form->parse_template(\%myconfig, ${LedgerSMB::Sysconfig::userspath});
  1626. }
  1627. }
  1628. }
  1629. }
  1630. sub statement_details {
  1631. my ($ref) = @_;
  1632. $ref->{invdate} = $ref->{transdate};
  1633. my @a = qw(invnumber ordnumber ponumber notes invdate duedate);
  1634. for (@a) { $form->{"${_}_1"} = $ref->{$_} }
  1635. $form->format_string(qw(invnumber_1 ordnumber_1 ponumber_1 notes_1));
  1636. for (@a) { push @{ $form->{$_} }, $form->{"${_}_1"} }
  1637. foreach $item (qw(c0 c30 c60 c90)) {
  1638. eval { $ref->{$item} = $form->round_amount($ref->{$item} / $ref->{exchangerate}, 2) };
  1639. $form->{"${item}total"} += $ref->{$item};
  1640. $form->{total} += $ref->{$item};
  1641. push @{ $form->{$item} }, $form->format_amount(\%myconfig, $ref->{$item}, 2);
  1642. }
  1643. }
  1644. sub generate_tax_report {
  1645. RP->tax_report(\%myconfig, \%$form);
  1646. $descvar = "$form->{accno}_description";
  1647. $description = $form->escape($form->{$descvar});
  1648. $ratevar = "$form->{accno}_rate";
  1649. $taxrate = $form->{"$form->{accno}_rate"};
  1650. if ($form->{accno} =~ /^gifi_/) {
  1651. $descvar = "gifi_$form->{accno}_description";
  1652. $description = $form->escape($form->{$descvar});
  1653. $ratevar = "gifi_$form->{accno}_rate";
  1654. $taxrate = $form->{"gifi_$form->{accno}_rate"};
  1655. }
  1656. $department = $form->escape($form->{department});
  1657. # construct href
  1658. $href = "$form->{script}?path=$form->{path}&direction=$form->{direction}&oldsort=$form->{oldsort}&action=generate_tax_report&login=$form->{login}&sessionid=$form->{sessionid}&fromdate=$form->{fromdate}&todate=$form->{todate}&db=$form->{db}&method=$form->{method}&summary=$form->{summary}&accno=$form->{accno}&$descvar=$description&department=$department&$ratevar=$taxrate&report=$form->{report}";
  1659. # construct callback
  1660. $description = $form->escape($form->{$descvar},1);
  1661. $department = $form->escape($form->{department},1);
  1662. $form->sort_order();
  1663. $callback = "$form->{script}?path=$form->{path}&direction=$form->{direction}&oldsort=$form->{oldsort}&action=generate_tax_report&login=$form->{login}&sessionid=$form->{sessionid}&fromdate=$form->{fromdate}&todate=$form->{todate}&db=$form->{db}&method=$form->{method}&summary=$form->{summary}&accno=$form->{accno}&$descvar=$description&department=$department&$ratevar=$taxrate&report=$form->{report}";
  1664. $form->{title} = $locale->text('GIFI')." - " if ($form->{accno} =~ /^gifi_/);
  1665. $title = $form->escape($form->{title});
  1666. $href .= "&title=$title";
  1667. $title = $form->escape($form->{title},1);
  1668. $callback .= "&title=$title";
  1669. $form->{title} = qq|$form->{title} $form->{"$form->{accno}_description"} |;
  1670. @columns = $form->sort_columns(qw(id transdate invnumber name description netamount tax total));
  1671. $form->{"l_description"} = "" if $form->{summary};
  1672. foreach $item (@columns) {
  1673. if ($form->{"l_$item"} eq "Y") {
  1674. push @column_index, $item;
  1675. # add column to href and callback
  1676. $callback .= "&l_$item=Y";
  1677. $href .= "&l_$item=Y";
  1678. }
  1679. }
  1680. if ($form->{l_subtotal} eq 'Y') {
  1681. $callback .= "&l_subtotal=Y";
  1682. $href .= "&l_subtotal=Y";
  1683. }
  1684. if ($form->{department}) {
  1685. ($department) = split /--/, $form->{department};
  1686. $option = $locale->text('Department')." : $department";
  1687. }
  1688. # if there are any dates
  1689. if ($form->{fromdate} || $form->{todate}) {
  1690. if ($form->{fromdate}) {
  1691. $fromdate = $locale->date(\%myconfig, $form->{fromdate}, 1);
  1692. }
  1693. if ($form->{todate}) {
  1694. $todate = $locale->date(\%myconfig, $form->{todate}, 1);
  1695. }
  1696. $form->{period} = "$fromdate - $todate";
  1697. } else {
  1698. $form->{period} = $locale->date(\%myconfig, $form->current_date(\%myconfig), 1);
  1699. }
  1700. if ($form->{db} eq 'ar') {
  1701. $name = $locale->text('Customer');
  1702. $invoice = 'is.pl';
  1703. $arap = 'ar.pl';
  1704. }
  1705. if ($form->{db} eq 'ap') {
  1706. $name = $locale->text('Vendor');
  1707. $invoice = 'ir.pl';
  1708. $arap = 'ap.pl';
  1709. }
  1710. $option .= "<br>" if $option;
  1711. $option .= "$form->{period}";
  1712. $column_header{id} = qq|<th><a class=listheading href=$href&sort=id>|.$locale->text('ID').qq|</th>|;
  1713. $column_header{invnumber} = qq|<th><a class=listheading href=$href&sort=invnumber>|.$locale->text('Invoice').qq|</th>|;
  1714. $column_header{transdate} = qq|<th><a class=listheading href=$href&sort=transdate>|.$locale->text('Date').qq|</th>|;
  1715. $column_header{netamount} = qq|<th class=listheading>|.$locale->text('Amount').qq|</th>|;
  1716. $column_header{tax} = qq|<th class=listheading>|.$locale->text('Tax').qq|</th>|;
  1717. $column_header{total} = qq|<th class=listheading>|.$locale->text('Total').qq|</th>|;
  1718. $column_header{name} = qq|<th><a class=listheading href=$href&sort=name>$name</th>|;
  1719. $column_header{description} = qq|<th><a class=listheading href=$href&sort=description>|.$locale->text('Description').qq|</th>|;
  1720. $form->header;
  1721. print qq|
  1722. <body>
  1723. <table width=100%>
  1724. <tr>
  1725. <th class=listtop colspan=$colspan>$form->{title}</th>
  1726. </tr>
  1727. <tr height="5"></tr>
  1728. <tr>
  1729. <td>$option</td>
  1730. </tr>
  1731. <tr>
  1732. <td>
  1733. <table width=100%>
  1734. <tr class=listheading>
  1735. |;
  1736. for (@column_index) { print "$column_header{$_}\n" }
  1737. print qq|
  1738. </tr>
  1739. |;
  1740. # add sort and escape callback
  1741. $callback = $form->escape($callback . "&sort=$form->{sort}");
  1742. if (@{ $form->{TR} }) {
  1743. $sameitem = $form->{TR}->[0]->{$form->{sort}};
  1744. }
  1745. foreach $ref (@{ $form->{TR} }) {
  1746. $module = ($ref->{invoice}) ? $invoice : $arap;
  1747. $module = 'ps.pl' if $ref->{till};
  1748. if ($form->{l_subtotal} eq 'Y') {
  1749. if ($sameitem ne $ref->{$form->{sort}}) {
  1750. &tax_subtotal;
  1751. $sameitem = $ref->{$form->{sort}};
  1752. }
  1753. }
  1754. $totalnetamount += $ref->{netamount};
  1755. $totaltax += $ref->{tax};
  1756. $ref->{total} = $ref->{netamount} + $ref->{tax};
  1757. $subtotalnetamount += $ref->{netamount};
  1758. $subtotaltax += $ref->{tax};
  1759. for (qw(netamount tax total)) { $ref->{$_} = $form->format_amount(\%myconfig, $ref->{$_}, 2, "&nbsp;"); }
  1760. $column_data{id} = qq|<td>$ref->{id}</td>|;
  1761. $column_data{invnumber} = qq|<td><a href=$module?path=$form->{path}&action=edit&id=$ref->{id}&login=$form->{login}&sessionid=$form->{sessionid}&callback=$callback>$ref->{invnumber}</a></td>|;
  1762. for (qw(id transdate name partnumber description)) { $column_data{$_} = qq|<td>$ref->{$_}</td>| }
  1763. for (qw(netamount tax total)) { $column_data{$_} = qq|<td align=right>$ref->{$_}</td>| }
  1764. $i++; $i %= 2;
  1765. print qq|
  1766. <tr class=listrow$i>
  1767. |;
  1768. for (@column_index) { print "$column_data{$_}\n" }
  1769. print qq|
  1770. </tr>
  1771. |;
  1772. }
  1773. if ($form->{l_subtotal} eq 'Y') {
  1774. &tax_subtotal;
  1775. }
  1776. for (@column_index) { $column_data{$_} = qq|<th>&nbsp;</th>| }
  1777. print qq|
  1778. </tr>
  1779. <tr class=listtotal>
  1780. |;
  1781. $total = $form->format_amount(\%myconfig, $totalnetamount + $totaltax, 2, "&nbsp;");
  1782. $totalnetamount = $form->format_amount(\%myconfig, $totalnetamount, 2, "&nbsp;");
  1783. $totaltax = $form->format_amount(\%myconfig, $totaltax, 2, "&nbsp;");
  1784. $column_data{netamount} = qq|<th class=listtotal align=right>$totalnetamount</th>|;
  1785. $column_data{tax} = qq|<th class=listtotal align=right>$totaltax</th>|;
  1786. $column_data{total} = qq|<th class=listtotal align=right>$total</th>|;
  1787. for (@column_index) { print "$column_data{$_}\n" }
  1788. print qq|
  1789. </tr>
  1790. </table>
  1791. </td>
  1792. </tr>
  1793. <tr>
  1794. <td><hr size=3 noshade></td>
  1795. </tr>
  1796. </table>
  1797. </body>
  1798. </html>
  1799. |;
  1800. }
  1801. sub tax_subtotal {
  1802. for (@column_index) { $column_data{$_} = "<td>&nbsp;</td>" }
  1803. $subtotal = $form->format_amount(\%myconfig, $subtotalnetamount + $subtotaltax, 2, "&nbsp;");
  1804. $subtotalnetamount = $form->format_amount(\%myconfig, $subtotalnetamount, 2, "&nbsp;");
  1805. $subtotaltax = $form->format_amount(\%myconfig, $subtotaltax, 2, "&nbsp;");
  1806. $column_data{netamount} = "<th class=listsubtotal align=right>$subtotalnetamount</th>";
  1807. $column_data{tax} = "<th class=listsubtotal align=right>$subtotaltax</th>";
  1808. $column_data{total} = "<th class=listsubtotal align=right>$subtotal</th>";
  1809. $subtotalnetamount = 0;
  1810. $subtotaltax = 0;
  1811. print qq|
  1812. <tr class=listsubtotal>
  1813. |;
  1814. for (@column_index) { print "\n$column_data{$_}" }
  1815. print qq|
  1816. </tr>
  1817. |;
  1818. }
  1819. sub list_payments {
  1820. if ($form->{account}) {
  1821. ($form->{paymentaccounts}) = split /--/, $form->{account};
  1822. }
  1823. if ($form->{department}) {
  1824. ($department, $form->{department_id}) = split /--/, $form->{department};
  1825. $option = $locale->text('Department')." : $department";
  1826. }
  1827. RP->payments(\%myconfig, \%$form);
  1828. @columns = $form->sort_columns(qw(transdate name paid source memo));
  1829. if ($form->{till}) {
  1830. @columns = $form->sort_columns(qw(transdate name paid curr source till));
  1831. if ($myconfig{role} ne 'user') {
  1832. @columns = $form->sort_columns(qw(transdate name paid curr source till employee));
  1833. }
  1834. }
  1835. # construct href
  1836. $title = $form->escape($form->{title});
  1837. $form->{paymentaccounts} =~ s/ /%20/g;
  1838. $href = "$form->{script}?path=$form->{path}&direction=$form->{direction}&sort=$form->{sort}&oldsort=$form->{oldsort}&action=list_payments&till=$form->{till}&login=$form->{login}&sessionid=$form->{sessionid}&fromdate=$form->{fromdate}&todate=$form->{todate}&fx_transaction=$form->{fx_transaction}&db=$form->{db}&l_subtotal=$form->{l_subtotal}&prepayment=$form->{prepayment}&paymentaccounts=$form->{paymentaccounts}&title=".$form->escape($form->{title});
  1839. $form->sort_order();
  1840. $form->{callback} = "$form->{script}?path=$form->{path}&direction=$form->{direction}&sort=$form->{sort}&oldsort=$form->{oldsort}&action=list_payments&till=$form->{till}&login=$form->{login}&sessionid=$form->{sessionid}&fromdate=$form->{fromdate}&todate=$form->{todate}&fx_transaction=$form->{fx_transaction}&db=$form->{db}&l_subtotal=$form->{l_subtotal}&prepayment=$form->{prepayment}&paymentaccounts=$form->{paymentaccounts}&title=".$form->escape($form->{title},1);
  1841. if ($form->{account}) {
  1842. $callback .= "&account=".$form->escape($form->{account},1);
  1843. $href .= "&account=".$form->escape($form->{account});
  1844. $option .= "\n<br>" if ($option);
  1845. $option .= $locale->text('Account')." : $form->{account}";
  1846. }
  1847. if ($form->{department}) {
  1848. $callback .= "&department=".$form->escape($form->{department},1);
  1849. $href .= "&department=".$form->escape($form->{department});
  1850. $option .= "\n<br>" if ($option);
  1851. $option .= $locale->text('Department')." : $form->{department}";
  1852. }
  1853. if ($form->{description}) {
  1854. $callback .= "&description=".$form->escape($form->{description},1);
  1855. $href .= "&description=".$form->escape($form->{description});
  1856. $option .= "\n<br>" if ($option);
  1857. $option .= $locale->text('Description')." : $form->{description}";
  1858. }
  1859. if ($form->{source}) {
  1860. $callback .= "&source=".$form->escape($form->{source},1);
  1861. $href .= "&source=".$form->escape($form->{source});
  1862. $option .= "\n<br>" if ($option);
  1863. $option .= $locale->text('Source')." : $form->{source}";
  1864. }
  1865. if ($form->{memo}) {
  1866. $callback .= "&memo=".$form->escape($form->{memo},1);
  1867. $href .= "&memo=".$form->escape($form->{memo});
  1868. $option .= "\n<br>" if ($option);
  1869. $option .= $locale->text('Memo')." : $form->{memo}";
  1870. }
  1871. if ($form->{fromdate}) {
  1872. $option .= "\n<br>" if ($option);
  1873. $option .= $locale->text('From')."&nbsp;".$locale->date(\%myconfig, $form->{fromdate}, 1);
  1874. }
  1875. if ($form->{todate}) {
  1876. $option .= "\n<br>" if ($option);
  1877. $option .= $locale->text('To')."&nbsp;".$locale->date(\%myconfig, $form->{todate}, 1);
  1878. }
  1879. $callback = $form->escape($form->{callback});
  1880. $column_header{name} = "<th><a class=listheading href=$href&sort=name>".$locale->text('Description')."</a></th>";
  1881. $column_header{transdate} = "<th><a class=listheading href=$href&sort=transdate>".$locale->text('Date')."</a></th>";
  1882. $column_header{paid} = "<th class=listheading>".$locale->text('Amount')."</a></th>";
  1883. $column_header{curr} = "<th class=listheading>".$locale->text('Curr')."</a></th>";
  1884. $column_header{source} = "<th><a class=listheading href=$href&sort=source>".$locale->text('Source')."</a></th>";
  1885. $column_header{memo} = "<th><a class=listheading href=$href&sort=memo>".$locale->text('Memo')."</a></th>";
  1886. $column_header{employee} = "<th><a class=listheading href=$href&sort=employee>".$locale->text('Salesperson')."</a></th>";
  1887. $column_header{till} = "<th><a class=listheading href=$href&sort=till>".$locale->text('Till')."</a></th>";
  1888. @column_index = @columns;
  1889. $colspan = $#column_index + 1;
  1890. $form->header;
  1891. print qq|
  1892. <body>
  1893. <table width=100%>
  1894. <tr>
  1895. <th class=listtop>$form->{title}</th>
  1896. </tr>
  1897. <tr height="5"></tr>
  1898. <tr>
  1899. <td>$option</td>
  1900. </tr>
  1901. <tr>
  1902. <td>
  1903. <table width=100%>
  1904. <tr class=listheading>
  1905. |;
  1906. for (@column_index) { print "\n$column_header{$_}" }
  1907. print qq|
  1908. </tr>
  1909. |;
  1910. foreach $ref (sort { $a->{accno} cmp $b->{accno} } @{ $form->{PR} }) {
  1911. next unless @{ $form->{$ref->{id}} };
  1912. print qq|
  1913. <tr>
  1914. <th colspan=$colspan align=left>$ref->{accno}--$ref->{description}</th>
  1915. </tr>
  1916. |;
  1917. if (@{ $form->{$ref->{id}} }) {
  1918. $sameitem = $form->{$ref->{id}}[0]->{$form->{sort}};
  1919. }
  1920. foreach $payment (@{ $form->{$ref->{id}} }) {
  1921. if ($form->{l_subtotal}) {
  1922. if ($payment->{$form->{sort}} ne $sameitem) {
  1923. # print subtotal
  1924. &payment_subtotal;
  1925. }
  1926. }
  1927. next if ($form->{till} && ! $payment->{till});
  1928. $column_data{name} = "<td>$payment->{name}&nbsp;</td>";
  1929. $column_data{transdate} = "<td>$payment->{transdate}&nbsp;</td>";
  1930. $column_data{paid} = "<td align=right>".$form->format_amount(\%myconfig, $payment->{paid}, 2, "&nbsp;")."</td>";
  1931. $column_data{curr} = "<td>$payment->{curr}</td>";
  1932. $column_data{source} = "<td>$payment->{source}&nbsp;</td>";
  1933. $column_data{memo} = "<td>$payment->{memo}&nbsp;</td>";
  1934. $column_data{employee} = "<td>$payment->{employee}&nbsp;</td>";
  1935. $column_data{till} = "<td>$payment->{till}&nbsp;</td>";
  1936. $subtotalpaid += $payment->{paid};
  1937. $accounttotalpaid += $payment->{paid};
  1938. $totalpaid += $payment->{paid};
  1939. $i++; $i %= 2;
  1940. print qq|
  1941. <tr class=listrow$i>
  1942. |;
  1943. for (@column_index) { print "\n$column_data{$_}" }
  1944. print qq|
  1945. </tr>
  1946. |;
  1947. $sameitem = $payment->{$form->{sort}};
  1948. }
  1949. &payment_subtotal if $form->{l_subtotal};
  1950. # print account totals
  1951. for (@column_index) { $column_data{$_} = "<td>&nbsp;</td>" }
  1952. $column_data{paid} = "<th class=listtotal align=right>".$form->format_amount(\%myconfig, $accounttotalpaid, 2, "&nbsp;")."</th>";
  1953. print qq|
  1954. <tr class=listtotal>
  1955. |;
  1956. for (@column_index) { print "\n$column_data{$_}" }
  1957. print qq|
  1958. </tr>
  1959. |;
  1960. $accounttotalpaid = 0;
  1961. }
  1962. # print total
  1963. for (@column_index) { $column_data{$_} = "<td>&nbsp;</td>" }
  1964. $column_data{paid} = "<th class=listtotal align=right>".$form->format_amount(\%myconfig, $totalpaid, 2, "&nbsp;")."</th>";
  1965. print qq|
  1966. <tr class=listtotal>
  1967. |;
  1968. for (@column_index) { print "\n$column_data{$_}" }
  1969. print qq|
  1970. </tr>
  1971. </table>
  1972. </td>
  1973. </tr>
  1974. <tr>
  1975. <td><hr size=3 noshade></td>
  1976. </tr>
  1977. </table>
  1978. |;
  1979. if ($form->{lynx}) {
  1980. require "bin/menu.pl";
  1981. &menubar;
  1982. }
  1983. print qq|
  1984. </body>
  1985. </html>
  1986. |;
  1987. }
  1988. sub payment_subtotal {
  1989. if ($subtotalpaid != 0) {
  1990. for (@column_index) { $column_data{$_} = "<td>&nbsp;</td>" }
  1991. $column_data{paid} = "<th class=listsubtotal align=right>".$form->format_amount(\%myconfig, $subtotalpaid, 2, "&nbsp;")."</th>";
  1992. print qq|
  1993. <tr class=listsubtotal>
  1994. |;
  1995. for (@column_index) { print "\n$column_data{$_}" }
  1996. print qq|
  1997. </tr>
  1998. |;
  1999. }
  2000. $subtotalpaid = 0;
  2001. }