RewriteEngine On RewriteRule /VIRTUAL/([^/]+) http://$1 [R] RewriteCond %{HTTP_HOST} ^rip$ [NC] RewriteRule / http://rip:631/ [R,L] RewriteCond %{HTTP_HOST} ^proxy$ [NC] RewriteRule / http://rip:8080/ [R,L] #UseCanonicalName DNS UseCanonicalName Off NameVirtualHost * VirtualDocumentRoot /var/www/VIRTUAL/%0/www VirtualScriptAlias /var/www/VIRTUAL/%0/cgi-local Options +ExecCGI # AuthPAM_Enabled On AuthType Basic AuthName BOS require group users DocumentRoot /var/www ScriptAlias /cgi-local /var/www/cgi-local Options +ExecCGI # AuthPAM_Enabled On AuthType Basic AuthName BOS require group users edger-smb
Unnamed repository; edit this file to name it for gitweb.Jonas Smedegaard
summaryrefslogtreecommitdiff
path: root/bin/ct.pl
blob: 252c36be153f9dd5aa85ab10827bc5cb3182655b (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: Reed White <alta@alta-research.com>
  22. #
  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. # customer/vendor module
  40. #
  41. #======================================================================
  42. use LedgerSMB::CT;
  43. 1;
  44. # end of main
  45. sub add {
  46. $form->{title} = "Add";
  47. # $locale->text('Add Customer')
  48. # $locale->text('Add Vendor')
  49. $form->{callback} = "$form->{script}?action=add&db=$form->{db}&path=$form->{path}&login=$form->{login}&sessionid=$form->{sessionid}" unless $form->{callback};
  50. CT->create_links(\%myconfig, \%$form);
  51. &form_header;
  52. &form_footer;
  53. }
  54. sub history {
  55. # $locale->text('Customer History')
  56. # $locale->text('Vendor History')
  57. $history = 1;
  58. $label = ucfirst $form->{db};
  59. $label .= " History";
  60. if ($form->{db} eq 'customer') {
  61. $invlabel = $locale->text('Sales Invoices');
  62. $ordlabel = $locale->text('Sales Orders');
  63. $quolabel = $locale->text('Quotations');
  64. } else {
  65. $invlabel = $locale->text('Vendor Invoices');
  66. $ordlabel = $locale->text('Purchase Orders');
  67. $quolabel = $locale->text('Request for Quotations');
  68. }
  69. $form->{title} = $locale->text($label);
  70. $form->{nextsub} = "list_history";
  71. $transactions = qq|
  72. <tr>
  73. <td></td>
  74. <td>
  75. <table>
  76. <tr>
  77. <td>
  78. <table>
  79. <tr>
  80. <td><input name=type type=radio class=radio value=invoice checked> $invlabel</td>
  81. </tr>
  82. <tr>
  83. <td><input name=type type=radio class=radio value=order> $ordlabel</td>
  84. </tr>
  85. <tr>
  86. <td><input name="type" type=radio class=radio value=quotation> $quolabel</td>
  87. </tr>
  88. </table>
  89. </td>
  90. <td>
  91. <table>
  92. <tr>
  93. <th>|.$locale->text('From').qq|</th>
  94. <td><input name=transdatefrom size=11 title="$myconfig{dateformat}"></td>
  95. <th>|.$locale->text('To').qq|</th>
  96. <td><input name=transdateto size=11 title="$myconfig{dateformat}"></td>
  97. </tr>
  98. <tr>
  99. <td></td>
  100. <td colspan=3>
  101. <input name="open" type=checkbox class=checkbox value=Y checked>&nbsp;|.$locale->text('Open').qq|
  102. <input name="closed" type=checkbox class=checkbox value=Y checked>&nbsp;|.$locale->text('Closed').qq|
  103. </td>
  104. </tr>
  105. </table>
  106. </td>
  107. </tr>
  108. </table>
  109. </td>
  110. </tr>
  111. |;
  112. $include = qq|
  113. <tr>
  114. <th align=right nowrap>|.$locale->text('Include in Report').qq|</th>
  115. <td>
  116. <table>
  117. <tr>
  118. <td><input name=history type=radio class=radio value=summary checked> |.$locale->text('Summary').qq|</td>
  119. <td><input name=history type=radio class=radio value=detail> |.$locale->text('Detail').qq|
  120. </td>
  121. </tr>
  122. <tr>
  123. <td>
  124. <input name="l_partnumber" type=checkbox class=checkbox value=Y checked>&nbsp;|.$locale->text('Part Number').qq|
  125. </td>
  126. <td>
  127. <input name="l_description" type=checkbox class=checkbox value=Y checked>&nbsp;|.$locale->text('Description').qq|
  128. </td>
  129. <td>
  130. <input name="l_sellprice" type=checkbox class=checkbox value=Y checked>&nbsp;|.$locale->text('Sell Price').qq|
  131. </td>
  132. <td>
  133. <input name="l_curr" type=checkbox class=checkbox value=Y>&nbsp;|.$locale->text('Currency').qq|
  134. </td>
  135. </tr>
  136. <tr>
  137. <td>
  138. <input name="l_qty" type=checkbox class=checkbox value=Y>&nbsp;|.$locale->text('Qty').qq|
  139. </td>
  140. <td>
  141. <input name="l_unit" type=checkbox class=checkbox value=Y>&nbsp;|.$locale->text('Unit').qq|
  142. </td>
  143. <td>
  144. <input name="l_discount" type=checkbox class=checkbox value=Y>&nbsp;|.$locale->text('Discount').qq|
  145. </td>
  146. <tr>
  147. </tr>
  148. <td>
  149. <input name="l_deliverydate" type=checkbox class=checkbox value=Y>&nbsp;|.$locale->text('Delivery Date').qq|
  150. </td>
  151. <td>
  152. <input name="l_projectnumber" type=checkbox class=checkbox value=Y>&nbsp;|.$locale->text('Project Number').qq|
  153. </td>
  154. <td>
  155. <input name="l_serialnumber" type=checkbox class=checkbox value=Y>&nbsp;|.$locale->text('Serial Number').qq|
  156. </td>
  157. </tr>
  158. </table>
  159. </td>
  160. </tr>
  161. |;
  162. &search_name;
  163. if ($form->{lynx}) {
  164. require "bin/menu.pl";
  165. &menubar;
  166. }
  167. print qq|
  168. </body>
  169. </html>
  170. |;
  171. }
  172. sub transactions {
  173. if ($form->{db} eq 'customer') {
  174. $translabel = $locale->text('AR Transactions');
  175. $invlabel = $locale->text('Sales Invoices');
  176. $ordlabel = $locale->text('Sales Orders');
  177. $quolabel = $locale->text('Quotations');
  178. } else {
  179. $translabel = $locale->text('AP Transactions');
  180. $invlabel = $locale->text('Vendor Invoices');
  181. $ordlabel = $locale->text('Purchase Orders');
  182. $quolabel = $locale->text('Request for Quotations');
  183. }
  184. $transactions = qq|
  185. <tr>
  186. <td></td>
  187. <td>
  188. <table>
  189. <tr>
  190. <td>
  191. <table>
  192. <tr>
  193. <td><input name="l_transnumber" type=checkbox class=checkbox value=Y> $translabel</td>
  194. </tr>
  195. <tr>
  196. <td><input name="l_invnumber" type=checkbox class=checkbox value=Y> $invlabel</td>
  197. </tr>
  198. <tr>
  199. <td><input name="l_ordnumber" type=checkbox class=checkbox value=Y> $ordlabel</td>
  200. </tr>
  201. <tr>
  202. <td><input name="l_quonumber" type=checkbox class=checkbox value=Y> $quolabel</td>
  203. </tr>
  204. </table>
  205. </td>
  206. <td>
  207. <table>
  208. <tr>
  209. <th>|.$locale->text('From').qq|</th>
  210. <td><input name=transdatefrom size=11 title="$myconfig{dateformat}"></td>
  211. <th>|.$locale->text('To').qq|</th>
  212. <td><input name=transdateto size=11 title="$myconfig{dateformat}"></td>
  213. </tr>
  214. <tr>
  215. <td></td>
  216. <td colspan=3>
  217. <input name="open" type=checkbox class=checkbox value=Y checked>&nbsp;|.$locale->text('Open').qq|
  218. <input name="closed" type=checkbox class=checkbox value=Y checked>&nbsp;|.$locale->text('Closed').qq|
  219. </td>
  220. </tr>
  221. <tr>
  222. <td></td>
  223. <td colspan=3>
  224. <input name="l_amount" type=checkbox class=checkbox value=Y checked>&nbsp;|.$locale->text('Amount').qq|
  225. <input name="l_tax" type=checkbox class=checkbox value=Y checked>&nbsp;|.$locale->text('Tax').qq|
  226. <input name="l_total" type=checkbox class=checkbox value=Y checked>&nbsp;|.$locale->text('Total').qq|
  227. <input name="l_subtotal" type=checkbox class=checkbox value=Y>&nbsp;|.$locale->text('Subtotal').qq|
  228. </td>
  229. </tr>
  230. </table>
  231. </td>
  232. </tr>
  233. </table>
  234. </td>
  235. </tr>
  236. |;
  237. }
  238. sub include_in_report {
  239. $label = ucfirst $form->{db};
  240. @a = ();
  241. push @a, qq|<input name="l_ndx" type=checkbox class=checkbox value=Y> |.$locale->text('No.');
  242. push @a, qq|<input name="l_id" type=checkbox class=checkbox value=Y> |.$locale->text('ID');
  243. push @a, qq|<input name="l_$form->{db}number" type=checkbox class=checkbox value=Y> |.$locale->text($label . ' Number');
  244. push @a, qq|<input name="l_name" type=checkbox class=checkbox value=Y $form->{l_name}> |.$locale->text('Company Name');
  245. push @a, qq|<input name="l_contact" type=checkbox class=checkbox value=Y $form->{l_contact}> |.$locale->text('Contact');
  246. push @a, qq|<input name="l_email" type=checkbox class=checkbox value=Y $form->{l_email}> |.$locale->text('E-mail');
  247. push @a, qq|<input name="l_address" type=checkbox class=checkbox value=Y> |.$locale->text('Address');
  248. push @a, qq|<input name="l_city" type=checkbox class=checkbox value=Y> |.$locale->text('City');
  249. push @a, qq|<input name="l_state" type=checkbox class=checkbox value=Y> |.$locale->text('State/Province');
  250. push @a, qq|<input name="l_zipcode" type=checkbox class=checkbox value=Y> |.$locale->text('Zip/Postal Code');
  251. push @a, qq|<input name="l_country" type=checkbox class=checkbox value=Y> |.$locale->text('Country');
  252. push @a, qq|<input name="l_phone" type=checkbox class=checkbox value=Y $form->{l_phone}> |.$locale->text('Phone');
  253. push @a, qq|<input name="l_fax" type=checkbox class=checkbox value=Y> |.$locale->text('Fax');
  254. push @a, qq|<input name="l_cc" type=checkbox class=checkbox value=Y> |.$locale->text('Cc');
  255. if ($myconfig{role} =~ /(admin|manager)/) {
  256. push @a, qq|<input name="l_bcc" type=checkbox class=checkbox value=Y> |.$locale->text('Bcc');
  257. }
  258. push @a, qq|<input name="l_notes" type=checkbox class=checkbox value=Y> |.$locale->text('Notes');
  259. push @a, qq|<input name="l_discount" type=checkbox class=checkbox value=Y> |.$locale->text('Discount');
  260. push @a, qq|<input name="l_taxaccount" type=checkbox class=checkbox value=Y> |.$locale->text('Tax Account');
  261. push @a, qq|<input name="l_taxnumber" type=checkbox class=checkbox value=Y> |.$locale->text('Tax Number');
  262. if ($form->{db} eq 'customer') {
  263. push @a, qq|<input name="l_employee" type=checkbox class=checkbox value=Y> |.$locale->text('Salesperson');
  264. push @a, qq|<input name="l_manager" type=checkbox class=checkbox value=Y> |.$locale->text('Manager');
  265. push @a, qq|<input name="l_pricegroup" type=checkbox class=checkbox value=Y> |.$locale->text('Pricegroup');
  266. } else {
  267. push @a, qq|<input name="l_employee" type=checkbox class=checkbox value=Y> |.$locale->text('Employee');
  268. push @a, qq|<input name="l_manager" type=checkbox class=checkbox value=Y> |.$locale->text('Manager');
  269. push @a, qq|<input name="l_gifi_accno" type=checkbox class=checkbox value=Y> |.$locale->text('GIFI');
  270. }
  271. push @a, qq|<input name="l_sic_code" type=checkbox class=checkbox value=Y> |.$locale->text('SIC');
  272. push @a, qq|<input name="l_iban" type=checkbox class=checkbox value=Y> |.$locale->text('IBAN');
  273. push @a, qq|<input name="l_bic" type=checkbox class=checkbox value=Y> |.$locale->text('BIC');
  274. push @a, qq|<input name="l_business" type=checkbox class=checkbox value=Y> |.$locale->text('Type of Business');
  275. push @a, qq|<input name="l_terms" type=checkbox class=checkbox value=Y> |.$locale->text('Terms');
  276. push @a, qq|<input name="l_language" type=checkbox class=checkbox value=Y> |.$locale->text('Language');
  277. push @a, qq|<input name="l_startdate" type=checkbox class=checkbox value=Y> |.$locale->text('Startdate');
  278. push @a, qq|<input name="l_enddate" type=checkbox class=checkbox value=Y> |.$locale->text('Enddate');
  279. $include = qq|
  280. <tr>
  281. <th align=right nowrap>|.$locale->text('Include in Report').qq|</th>
  282. <td>
  283. <table>
  284. |;
  285. while (@a) {
  286. $include .= qq|<tr>\n|;
  287. for (1 .. 5) {
  288. $include .= qq|<td nowrap>|. shift @a;
  289. $include .= qq|</td>\n|;
  290. }
  291. $include .= qq|</tr>\n|;
  292. }
  293. $include .= qq|
  294. </table>
  295. </td>
  296. </tr>
  297. |;
  298. }
  299. sub search {
  300. # $locale->text('Customers')
  301. # $locale->text('Vendors')
  302. $form->{title} = $locale->text('Search') unless $form->{title};
  303. for (qw(name contact phone email)) { $form->{"l_$_"} = 'checked' }
  304. $form->{nextsub} = "list_names";
  305. $orphan = qq|
  306. <tr>
  307. <td></td>
  308. <td><input name=status class=radio type=radio value=all checked>&nbsp;|.$locale->text('All').qq|
  309. <input name=status class=radio type=radio value=active>&nbsp;|.$locale->text('Active').qq|
  310. <input name=status class=radio type=radio value=inactive>&nbsp;|.$locale->text('Inactive').qq|
  311. <input name=status class=radio type=radio value=orphaned>&nbsp;|.$locale->text('Orphaned').qq|</td>
  312. </tr>
  313. |;
  314. &transactions;
  315. &include_in_report;
  316. &search_name;
  317. if ($form->{lynx}) {
  318. require "bin/menu.pl";
  319. &menubar;
  320. }
  321. print qq|
  322. </body>
  323. </html>
  324. |;
  325. }
  326. sub search_name {
  327. $label = ucfirst $form->{db};
  328. if ($form->{db} eq 'customer') {
  329. $employee = qq|
  330. <th align=right nowrap>|.$locale->text('Salesperson').qq|</th>
  331. <td><input name=employee size=32></td>
  332. |;
  333. }
  334. if ($form->{db} eq 'vendor') {
  335. $employee = qq|
  336. <th align=right nowrap>|.$locale->text('Employee').qq|</th>
  337. <td><input name=employee size=32></td>
  338. |;
  339. }
  340. $form->header;
  341. print qq|
  342. <body>
  343. <form method=post action=$form->{script}>
  344. <input type=hidden name=db value=$form->{db}>
  345. <table width=100%>
  346. <tr>
  347. <th class=listtop>$form->{title}</th>
  348. </tr>
  349. <tr height="5"></tr>
  350. <tr valign=top>
  351. <td>
  352. <table>
  353. <tr valign=top>
  354. <td>
  355. <table>
  356. <tr>
  357. <th align=right nowrap>|.$locale->text('Company Name').qq|</th>
  358. <td><input name=name size=32></td>
  359. </tr>
  360. <tr>
  361. <th align=right nowrap>|.$locale->text('Contact').qq|</th>
  362. <td><input name=contact size=32></td>
  363. </tr>
  364. <tr>
  365. <th align=right nowrap>|.$locale->text('E-mail').qq|</th>
  366. <td><input name=email size=32></td>
  367. </tr>
  368. <tr>
  369. <th align=right nowrap>|.$locale->text('Phone').qq|</th>
  370. <td><input name=phone size=20></td>
  371. </tr>
  372. <tr>
  373. $employee
  374. </tr>
  375. <tr>
  376. <th align=right nowrap>|.$locale->text('Notes').qq|</th>
  377. <td colspan=3><textarea name=notes rows=3 cols=32></textarea></td>
  378. </tr>
  379. </table>
  380. </td>
  381. <td>
  382. <table>
  383. <tr>
  384. <th align=right nowrap>|.$locale->text($label . ' Number').qq|</th>
  385. <td><input name=$form->{db}number size=32></td>
  386. </tr>
  387. <tr>
  388. <th align=right nowrap>|.$locale->text('Address').qq|</th>
  389. <td><input name=address size=32></td>
  390. </tr>
  391. <tr>
  392. <th align=right nowrap>|.$locale->text('City').qq|</th>
  393. <td><input name=city size=32></td>
  394. </tr>
  395. <tr>
  396. <th align=right nowrap>|.$locale->text('State/Province').qq|</th>
  397. <td><input name=state size=32></td>
  398. </tr>
  399. <tr>
  400. <th align=right nowrap>|.$locale->text('Zip/Postal Code').qq|</th>
  401. <td><input name=zipcode size=10></td>
  402. </tr>
  403. <tr>
  404. <th align=right nowrap>|.$locale->text('Country').qq|</th>
  405. <td><input name=country size=32></td>
  406. </tr>
  407. <tr>
  408. <th align=right nowrap>|.$locale->text('Startdate').qq|</th>
  409. <td>|.$locale->text('From').qq| <input name=startdatefrom size=11 title="$myconfig{dateformat}"> |.$locale->text('To').qq| <input name=startdateto size=11 title="$myconfig{dateformat}"></td>
  410. </tr>
  411. </table>
  412. </td>
  413. </tr>
  414. </table>
  415. </td>
  416. </tr>
  417. <tr>
  418. <td>
  419. <table>
  420. $orphan
  421. $transactions
  422. $include
  423. </table>
  424. </td>
  425. </tr>
  426. <tr>
  427. <td><hr size=3 noshade></td>
  428. </tr>
  429. </table>
  430. <input type="hidden" name="nextsub" value="$form->{nextsub}">
  431. <input type="hidden" name="path" value="$form->{path}">
  432. <input type="hidden" name="login" value="$form->{login}">
  433. <input type="hidden" name="sessionid" value="$form->{sessionid}">
  434. <br>
  435. <button type="submit" class="submit" name="action" value="continue">|.$locale->text('Continue').qq|</button>
  436. </form>
  437. |;
  438. }
  439. sub list_names {
  440. CT->search(\%myconfig, \%$form);
  441. $href = "$form->{script}?action=list_names&direction=$form->{direction}&oldsort=$form->{oldsort}&db=$form->{db}&path=$form->{path}&login=$form->{login}&sessionid=$form->{sessionid}&status=$form->{status}&l_subtotal=$form->{l_subtotal}";
  442. $form->sort_order();
  443. $callback = "$form->{script}?action=list_names&direction=$form->{direction}&oldsort=$form->{oldsort}&db=$form->{db}&path=$form->{path}&login=$form->{login}&sessionid=$form->{sessionid}&status=$form->{status}&l_subtotal=$form->{l_subtotal}";
  444. @columns = $form->sort_columns(id, name, "$form->{db}number", address,
  445. city, state, zipcode, country, contact,
  446. phone, fax, email, cc, bcc, employee,
  447. manager, notes, discount, terms,
  448. taxaccount, taxnumber, gifi_accno, sic_code, business,
  449. pricegroup, language, iban, bic,
  450. startdate, enddate,
  451. invnumber, invamount, invtax, invtotal,
  452. ordnumber, ordamount, ordtax, ordtotal,
  453. quonumber, quoamount, quotax, quototal);
  454. unshift @columns, "ndx";
  455. $form->{l_invnumber} = "Y" if $form->{l_transnumber};
  456. foreach $item (qw(inv ord quo)) {
  457. if ($form->{"l_${item}number"}) {
  458. for (qw(amount tax total)) { $form->{"l_$item$_"} = $form->{"l_$_"} }
  459. $removeemployee = 1;
  460. $openclosed = 1;
  461. }
  462. }
  463. $form->{open} = $form->{closed} = "" if !$openclosed;
  464. foreach $item (@columns) {
  465. if ($form->{"l_$item"} eq "Y") {
  466. push @column_index, $item;
  467. # add column to href and callback
  468. $callback .= "&l_$item=Y";
  469. $href .= "&l_$item=Y";
  470. }
  471. }
  472. foreach $item (qw(amount tax total transnumber)) {
  473. if ($form->{"l_$item"} eq "Y") {
  474. $callback .= "&l_$item=Y";
  475. $href .= "&l_$item=Y";
  476. }
  477. }
  478. if ($form->{status} eq 'all') {
  479. $option = $locale->text('All');
  480. }
  481. if ($form->{status} eq 'orphaned') {
  482. $option = $locale->text('Orphaned');
  483. }
  484. if ($form->{status} eq 'active') {
  485. $option = $locale->text('Active');
  486. }
  487. if ($form->{status} eq 'inactive') {
  488. $option = $locale->text('Inactive');
  489. }
  490. if ($form->{name}) {
  491. $callback .= "&name=".$form->escape($form->{name},1);
  492. $href .= "&name=".$form->escape($form->{name});
  493. $option .= "\n<br>".$locale->text('Name')." : $form->{name}";
  494. }
  495. if ($form->{address}) {
  496. $callback .= "&address=".$form->escape($form->{address},1);
  497. $href .= "&address=".$form->escape($form->{address});
  498. $option .= "\n<br>".$locale->text('Address')." : $form->{address}";
  499. }
  500. if ($form->{city}) {
  501. $callback .= "&city=".$form->escape($form->{city},1);
  502. $href .= "&city=".$form->escape($form->{city});
  503. $option .= "\n<br>".$locale->text('City')." : $form->{city}";
  504. }
  505. if ($form->{state}) {
  506. $callback .= "&state=".$form->escape($form->{state},1);
  507. $href .= "&state=".$form->escape($form->{state});
  508. $option .= "\n<br>".$locale->text('State')." : $form->{state}";
  509. }
  510. if ($form->{zipcode}) {
  511. $callback .= "&zipcode=".$form->escape($form->{zipcode},1);
  512. $href .= "&zipcode=".$form->escape($form->{zipcode});
  513. $option .= "\n<br>".$locale->text('Zip/Postal Code')." : $form->{zipcode}";
  514. }
  515. if ($form->{country}) {
  516. $callback .= "&country=".$form->escape($form->{country},1);
  517. $href .= "&country=".$form->escape($form->{country});
  518. $option .= "\n<br>".$locale->text('Country')." : $form->{country}";
  519. }
  520. if ($form->{contact}) {
  521. $callback .= "&contact=".$form->escape($form->{contact},1);
  522. $href .= "&contact=".$form->escape($form->{contact});
  523. $option .= "\n<br>".$locale->text('Contact')." : $form->{contact}";
  524. }
  525. if ($form->{employee}) {
  526. $callback .= "&employee=".$form->escape($form->{employee},1);
  527. $href .= "&employee=".$form->escape($form->{employee});
  528. $option .= "\n<br>";
  529. if ($form->{db} eq 'customer') {
  530. $option .= $locale->text('Salesperson');
  531. }
  532. if ($form->{db} eq 'vendor') {
  533. $option .= $locale->text('Employee');
  534. }
  535. $option .= " : $form->{employee}";
  536. }
  537. $fromdate = "";
  538. $todate = "";
  539. if ($form->{startdatefrom}) {
  540. $callback .= "&startdatefrom=$form->{startdatefrom}";
  541. $href .= "&startdatefrom=$form->{startdatefrom}";
  542. $fromdate = $locale->date(\%myconfig, $form->{startdatefrom}, 1);
  543. }
  544. if ($form->{startdateto}) {
  545. $callback .= "&startdateto=$form->{startdateto}";
  546. $href .= "&startdateto=$form->{startdateto}";
  547. $todate = $locale->date(\%myconfig, $form->{startdateto}, 1);
  548. }
  549. if ($fromdate || $todate) {
  550. $option .= "\n<br>".$locale->text('Startdate')." $fromdate - $todate";
  551. }
  552. if ($form->{notes}) {
  553. $callback .= "&notes=".$form->escape($form->{notes},1);
  554. $href .= "&notes=".$form->escape($form->{notes});
  555. $option .= "\n<br>".$locale->text('Notes')." : $form->{notes}";
  556. }
  557. if ($form->{"$form->{db}number"}) {
  558. $callback .= qq|&$form->{db}number=|.$form->escape($form->{"$form->{db}number"},1);
  559. $href .= "&$form->{db}number=".$form->escape($form->{"$form->{db}number"});
  560. $option .= "\n<br>".$locale->text('Number').qq| : $form->{"$form->{db}number"}|;
  561. }
  562. if ($form->{phone}) {
  563. $callback .= "&phone=".$form->escape($form->{phone},1);
  564. $href .= "&phone=".$form->escape($form->{phone});
  565. $option .= "\n<br>".$locale->text('Phone')." : $form->{phone}";
  566. }
  567. if ($form->{email}) {
  568. $callback .= "&email=".$form->escape($form->{email},1);
  569. $href .= "&email=".$form->escape($form->{email});
  570. $option .= "\n<br>".$locale->text('E-mail')." : $form->{email}";
  571. }
  572. if ($form->{transdatefrom}) {
  573. $callback .= "&transdatefrom=$form->{transdatefrom}";
  574. $href .= "&transdatefrom=$form->{transdatefrom}";
  575. $option .= "\n<br>" if ($option);
  576. $option .= $locale->text('From')."&nbsp;".$locale->date(\%myconfig, $form->{transdatefrom}, 1);
  577. }
  578. if ($form->{transdateto}) {
  579. $callback .= "&transdateto=$form->{transdateto}";
  580. $href .= "&transdateto=$form->{transdateto}";
  581. if ($form->{transdatefrom}) {
  582. $option .= " ";
  583. } else {
  584. $option .= "\n<br>" if ($option);
  585. }
  586. $option .= $locale->text('To')."&nbsp;".$locale->date(\%myconfig, $form->{transdateto}, 1);
  587. }
  588. if ($form->{open}) {
  589. $callback .= "&open=$form->{open}";
  590. $href .= "&open=$form->{open}";
  591. $option .= "\n<br>" if ($option);
  592. $option .= $locale->text('Open');
  593. }
  594. if ($form->{closed}) {
  595. $callback .= "&closed=$form->{closed}";
  596. $href .= "&closed=$form->{closed}";
  597. $option .= "\n<br>" if ($option);
  598. $option .= $locale->text('Closed');
  599. }
  600. $form->{callback} = "$callback&sort=$form->{sort}";
  601. $callback = $form->escape($form->{callback});
  602. $column_header{ndx} = qq|<th class=listheading>&nbsp;</th>|;
  603. $column_header{id} = qq|<th class=listheading>|.$locale->text('ID').qq|</th>|;
  604. $column_header{"$form->{db}number"} = qq|<th><a class=listheading href=$href&sort=$form->{db}number>|.$locale->text('Number').qq|</a></th>|;
  605. $column_header{name} = qq|<th><a class=listheading href=$href&sort=name>|.$locale->text('Name').qq|</a></th>|;
  606. $column_header{address} = qq|<th class=listheading>|.$locale->text('Address').qq|</th>|;
  607. $column_header{city} = qq|<th><a class=listheading href=$href&sort=city>|.$locale->text('City').qq|</a></th>|;
  608. $column_header{state} = qq|<th><a class=listheading href=$href&sort=state>|.$locale->text('State/Province').qq|</a></th>|;
  609. $column_header{zipcode} = qq|<th><a class=listheading href=$href&sort=zipcode>|.$locale->text('Zip/Postal Code').qq|</a></th>|;
  610. $column_header{country} = qq|<th><a class=listheading href=$href&sort=country>|.$locale->text('Country').qq|</a></th>|;
  611. $column_header{contact} = qq|<th><a class=listheading href=$href&sort=contact>|.$locale->text('Contact').qq|</a></th>|;
  612. $column_header{phone} = qq|<th><a class=listheading href=$href&sort=phone>|.$locale->text('Phone').qq|</a></th>|;
  613. $column_header{fax} = qq|<th><a class=listheading href=$href&sort=fax>|.$locale->text('Fax').qq|</a></th>|;
  614. $column_header{email} = qq|<th><a class=listheading href=$href&sort=email>|.$locale->text('E-mail').qq|</a></th>|;
  615. $column_header{cc} = qq|<th><a class=listheading href=$href&sort=cc>|.$locale->text('Cc').qq|</a></th>|;
  616. $column_header{bcc} = qq|<th><a class=listheading href=$href&sort=cc>|.$locale->text('Bcc').qq|</a></th>|;
  617. $column_header{notes} = qq|<th><a class=listheading href=$href&sort=notes>|.$locale->text('Notes').qq|</a></th>|;
  618. $column_header{discount} = qq|<th class=listheading>%</th>|;
  619. $column_header{terms} = qq|<th class=listheading>|.$locale->text('Terms').qq|</th>|;
  620. $column_header{taxnumber} = qq|<th><a class=listheading href=$href&sort=taxnumber>|.$locale->text('Tax Number').qq|</a></th>|;
  621. $column_header{taxaccount} = qq|<th class=listheading>|.$locale->text('Tax Account').qq|</th>|;
  622. $column_header{gifi_accno} = qq|<th><a class=listheading href=$href&sort=gifi_accno>|.$locale->text('GIFI').qq|</a></th>|;
  623. $column_header{sic_code} = qq|<th><a class=listheading href=$href&sort=sic_code>|.$locale->text('SIC').qq|</a></th>|;
  624. $column_header{business} = qq|<th><a class=listheading href=$href&sort=business>|.$locale->text('Type of Business').qq|</a></th>|;
  625. $column_header{iban} = qq|<th class=listheading>|.$locale->text('IBAN').qq|</th>|;
  626. $column_header{bic} = qq|<th class=listheading>|.$locale->text('BIC').qq|</th>|;
  627. $column_header{startdate} = qq|<th><a class=listheading href=$href&sort=startdate>|.$locale->text('Startdate').qq|</a></th>|;
  628. $column_header{enddate} = qq|<th><a class=listheading href=$href&sort=enddate>|.$locale->text('Enddate').qq|</a></th>|;
  629. $column_header{invnumber} = qq|<th><a class=listheading href=$href&sort=invnumber>|.$locale->text('Invoice').qq|</a></th>|;
  630. $column_header{ordnumber} = qq|<th><a class=listheading href=$href&sort=ordnumber>|.$locale->text('Order').qq|</a></th>|;
  631. $column_header{quonumber} = qq|<th><a class=listheading href=$href&sort=quonumber>|.$locale->text('Quotation').qq|</a></th>|;
  632. if ($form->{db} eq 'customer') {
  633. $column_header{employee} = qq|<th><a class=listheading href=$href&sort=employee>|.$locale->text('Salesperson').qq|</a></th>|;
  634. } else {
  635. $column_header{employee} = qq|<th><a class=listheading href=$href&sort=employee>|.$locale->text('Employee').qq|</a></th>|;
  636. }
  637. $column_header{manager} = qq|<th><a class=listheading href=$href&sort=manager>|.$locale->text('Manager').qq|</a></th>|;
  638. $column_header{pricegroup} = qq|<th><a class=listheading href=$href&sort=pricegroup>|.$locale->text('Pricegroup').qq|</a></th>|;
  639. $column_header{language} = qq|<th><a class=listheading href=$href&sort=language>|.$locale->text('Language').qq|</a></th>|;
  640. $amount = $locale->text('Amount');
  641. $tax = $locale->text('Tax');
  642. $total = $locale->text('Total');
  643. $column_header{invamount} = qq|<th class=listheading>$amount</th>|;
  644. $column_header{ordamount} = qq|<th class=listheading>$amount</th>|;
  645. $column_header{quoamount} = qq|<th class=listheading>$amount</th>|;
  646. $column_header{invtax} = qq|<th class=listheading>$tax</th>|;
  647. $column_header{ordtax} = qq|<th class=listheading>$tax</th>|;
  648. $column_header{quotax} = qq|<th class=listheading>$tax</th>|;
  649. $column_header{invtotal} = qq|<th class=listheading>$total</th>|;
  650. $column_header{ordtotal} = qq|<th class=listheading>$total</th>|;
  651. $column_header{quototal} = qq|<th class=listheading>$total</th>|;
  652. if ($form->{status}) {
  653. $label = ucfirst $form->{db}."s";
  654. $form->{title} = $locale->text($label);
  655. } else {
  656. $label = ucfirst $form->{db};
  657. $form->{title} = $locale->text($label ." Transactions");
  658. }
  659. $form->header;
  660. print qq|
  661. <body>
  662. <table width=100%>
  663. <tr>
  664. <th class=listtop>$form->{title}</th>
  665. </tr>
  666. <tr height="5"></tr>
  667. <tr>
  668. <td>$option</td>
  669. </tr>
  670. <tr>
  671. <td>
  672. <table width=100%>
  673. <tr class=listheading>
  674. |;
  675. for (@column_index) { print "$column_header{$_}\n" }
  676. print qq|
  677. </tr>
  678. |;
  679. $ordertype = ($form->{db} eq 'customer') ? 'sales_order' : 'purchase_order';
  680. $quotationtype = ($form->{db} eq 'customer') ? 'sales_quotation' : 'request_quotation';
  681. $subtotal = 0;
  682. $i = 0;
  683. foreach $ref (@{ $form->{CT} }) {
  684. if ($ref->{$form->{sort}} ne $sameitem && $form->{l_subtotal}) {
  685. # print subtotal
  686. if ($subtotal) {
  687. for (@column_index) { $column_data{$_} = "<td>&nbsp;</td>" }
  688. &list_subtotal;
  689. }
  690. }
  691. if ($ref->{id} eq $sameid) {
  692. for (@column_index) { $column_data{$_} = "<td>&nbsp;</td>" }
  693. } else {
  694. $i++;
  695. $ref->{notes} =~ s/\r?\n/<br>/g;
  696. for (@column_index) { $column_data{$_} = "<td>$ref->{$_}&nbsp;</td>" }
  697. $column_data{ndx} = "<td align=right>$i</td>";
  698. if ($ref->{$form->{sort}} eq $sameitem) {
  699. $column_data{$form->{sort}} = "<td>&nbsp;</td>";
  700. }
  701. $column_data{address} = "<td>$ref->{address1} $ref->{address2}&nbsp;</td>";
  702. $column_data{name} = "<td><a href=$form->{script}?action=edit&id=$ref->{id}&db=$form->{db}&path=$form->{path}&login=$form->{login}&sessionid=$form->{sessionid}&status=$form->{status}&callback=$callback>$ref->{name}&nbsp;</td>";
  703. $email = "";
  704. if ($form->{sort} =~ /(email|cc)/) {
  705. if ($ref->{$form->{sort}} ne $sameitem) {
  706. $email = 1;
  707. }
  708. } else {
  709. $email = 1;
  710. }
  711. if ($email) {
  712. foreach $item (qw(email cc bcc)) {
  713. if ($ref->{$item}) {
  714. $email = $ref->{$item};
  715. $email =~ s/</\&lt;/;
  716. $email =~ s/>/\&gt;/;