/doc/plugins/shortcut/

cut icon' href='/favicon.ico'/>
summaryrefslogtreecommitdiff
path: root/bin/ct.pl
blob: d5cadf32dc1e7e9b9f7253fd6abf5ee75db3beee (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} =
  50. "$form->{script}?action=add&db=$form->{db}&path=$form->{path}&login=$form->{login}&sessionid=$form->{sessionid}"
  51. unless $form->{callback};
  52. CT->create_links( \%myconfig, \%$form );
  53. &form_header;
  54. &form_footer;
  55. }
  56. sub history {
  57. # $locale->text('Customer History')
  58. # $locale->text('Vendor History')
  59. $history = 1;
  60. $label = ucfirst $form->{db};
  61. $label .= " History";
  62. if ( $form->{db} eq 'customer' ) {
  63. $invlabel = $locale->text('Sales Invoices');
  64. $ordlabel = $locale->text('Sales Orders');
  65. $quolabel = $locale->text('Quotations');
  66. }
  67. else {
  68. $invlabel = $locale->text('Vendor Invoices');
  69. $ordlabel = $locale->text('Purchase Orders');
  70. $quolabel = $locale->text('Request for Quotations');
  71. }
  72. $form->{title} = $locale->text($label);
  73. $form->{nextsub} = "list_history";
  74. $transactions = qq|
  75. <tr>
  76. <td></td>
  77. <td>
  78. <table>
  79. <tr>
  80. <td>
  81. <table>
  82. <tr>
  83. <td><input name=type type=radio class=radio value=invoice checked> $invlabel</td>
  84. </tr>
  85. <tr>
  86. <td><input name=type type=radio class=radio value=order> $ordlabel</td>
  87. </tr>
  88. <tr>
  89. <td><input name="type" type=radio class=radio value=quotation> $quolabel</td>
  90. </tr>
  91. </table>
  92. </td>
  93. <td>
  94. <table>
  95. <tr>
  96. <th>| . $locale->text('From') . qq|</th>
  97. <td><input class="date" name=transdatefrom size=11 title="$myconfig{dateformat}"></td>
  98. <th>| . $locale->text('To') . qq|</th>
  99. <td><input class="date" name=transdateto size=11 title="$myconfig{dateformat}"></td>
  100. </tr>
  101. <tr>
  102. <td></td>
  103. <td colspan=3>
  104. <input name="open" type=checkbox class=checkbox value=Y checked>&nbsp;|
  105. . $locale->text('Open') . qq|
  106. <input name="closed" type=checkbox class=checkbox value=Y checked>&nbsp;|
  107. . $locale->text('Closed') . qq|
  108. </td>
  109. </tr>
  110. </table>
  111. </td>
  112. </tr>
  113. </table>
  114. </td>
  115. </tr>
  116. |;
  117. $include = qq|
  118. <tr>
  119. <th align=right nowrap>| . $locale->text('Include in Report') . qq|</th>
  120. <td>
  121. <table>
  122. <tr>
  123. <td><input name=history type=radio class=radio value=summary checked> |
  124. . $locale->text('Summary')
  125. . qq|</td>
  126. <td><input name=history type=radio class=radio value=detail> |
  127. . $locale->text('Detail') . qq|
  128. </td>
  129. </tr>
  130. <tr>
  131. <td>
  132. <input name="l_partnumber" type=checkbox class=checkbox value=Y checked>&nbsp;|
  133. . $locale->text('Part Number') . qq|
  134. </td>
  135. <td>
  136. <input name="l_description" type=checkbox class=checkbox value=Y checked>&nbsp;|
  137. . $locale->text('Description') . qq|
  138. </td>
  139. <td>
  140. <input name="l_sellprice" type=checkbox class=checkbox value=Y checked>&nbsp;|
  141. . $locale->text('Sell Price') . qq|
  142. </td>
  143. <td>
  144. <input name="l_curr" type=checkbox class=checkbox value=Y>&nbsp;|
  145. . $locale->text('Currency') . qq|
  146. </td>
  147. </tr>
  148. <tr>
  149. <td>
  150. <input name="l_qty" type=checkbox class=checkbox value=Y>&nbsp;|
  151. . $locale->text('Qty') . qq|
  152. </td>
  153. <td>
  154. <input name="l_unit" type=checkbox class=checkbox value=Y>&nbsp;|
  155. . $locale->text('Unit') . qq|
  156. </td>
  157. <td>
  158. <input name="l_discount" type=checkbox class=checkbox value=Y>&nbsp;|
  159. . $locale->text('Discount') . qq|
  160. </td>
  161. <tr>
  162. </tr>
  163. <td>
  164. <input name="l_deliverydate" type=checkbox class=checkbox value=Y>&nbsp;|
  165. . $locale->text('Delivery Date') . qq|
  166. </td>
  167. <td>
  168. <input name="l_projectnumber" type=checkbox class=checkbox value=Y>&nbsp;|
  169. . $locale->text('Project Number') . qq|
  170. </td>
  171. <td>
  172. <input name="l_serialnumber" type=checkbox class=checkbox value=Y>&nbsp;|
  173. . $locale->text('Serial Number') . qq|
  174. </td>
  175. </tr>
  176. </table>
  177. </td>
  178. </tr>
  179. |;
  180. &search_name;
  181. if ( $form->{lynx} ) {
  182. require "bin/menu.pl";
  183. &menubar;
  184. }
  185. print qq|
  186. </body>
  187. </html>
  188. |;
  189. }
  190. sub transactions {
  191. if ( $form->{db} eq 'customer' ) {
  192. $translabel = $locale->text('AR Transactions');
  193. $invlabel = $locale->text('Sales Invoices');
  194. $ordlabel = $locale->text('Sales Orders');
  195. $quolabel = $locale->text('Quotations');
  196. }
  197. else {
  198. $translabel = $locale->text('AP Transactions');
  199. $invlabel = $locale->text('Vendor Invoices');
  200. $ordlabel = $locale->text('Purchase Orders');
  201. $quolabel = $locale->text('Request for Quotations');
  202. }
  203. $transactions = qq|
  204. <tr>
  205. <td></td>
  206. <td>
  207. <table>
  208. <tr>
  209. <td>
  210. <table>
  211. <tr>
  212. <td><input name="l_transnumber" type=checkbox class=checkbox value=Y> $translabel</td>
  213. </tr>
  214. <tr>
  215. <td><input name="l_invnumber" type=checkbox class=checkbox value=Y> $invlabel</td>
  216. </tr>
  217. <tr>
  218. <td><input name="l_ordnumber" type=checkbox class=checkbox value=Y> $ordlabel</td>
  219. </tr>
  220. <tr>
  221. <td><input name="l_quonumber" type=checkbox class=checkbox value=Y> $quolabel</td>
  222. </tr>
  223. </table>
  224. </td>
  225. <td>
  226. <table>
  227. <tr>
  228. <th>| . $locale->text('From') . qq|</th>
  229. <td><input class="date" name=transdatefrom size=11 title="$myconfig{dateformat}"></td>
  230. <th>| . $locale->text('To') . qq|</th>
  231. <td><input class="date" name=transdateto size=11 title="$myconfig{dateformat}"></td>
  232. </tr>
  233. <tr>
  234. <td></td>
  235. <td colspan=3>
  236. <input name="open" type=checkbox class=checkbox value=Y checked>&nbsp;|
  237. . $locale->text('Open') . qq|
  238. <input name="closed" type=checkbox class=checkbox value=Y checked>&nbsp;|
  239. . $locale->text('Closed') . qq|
  240. </td>
  241. </tr>
  242. <tr>
  243. <td></td>
  244. <td colspan=3>
  245. <input name="l_amount" type=checkbox class=checkbox value=Y checked>&nbsp;|
  246. . $locale->text('Amount') . qq|
  247. <input name="l_tax" type=checkbox class=checkbox value=Y checked>&nbsp;|
  248. . $locale->text('Tax') . qq|
  249. <input name="l_total" type=checkbox class=checkbox value=Y checked>&nbsp;|
  250. . $locale->text('Total') . qq|
  251. <input name="l_subtotal" type=checkbox class=checkbox value=Y>&nbsp;|
  252. . $locale->text('Subtotal') . qq|
  253. </td>
  254. </tr>
  255. </table>
  256. </td>
  257. </tr>
  258. </table>
  259. </td>
  260. </tr>
  261. |;
  262. }
  263. sub include_in_report {
  264. $label = ucfirst $form->{db};
  265. @a = ();
  266. push @a, qq|<input name="l_ndx" type=checkbox class=checkbox value=Y> |
  267. . $locale->text('No.');
  268. push @a, qq|<input name="l_id" type=checkbox class=checkbox value=Y> |
  269. . $locale->text('ID');
  270. push @a,
  271. qq|<input name="l_$form->{db}number" type=checkbox class=checkbox value=Y> |
  272. . $locale->text( $label . ' Number' );
  273. push @a,
  274. qq|<input name="l_name" type=checkbox class=checkbox value=Y $form->{l_name}> |
  275. . $locale->text('Company Name');
  276. push @a,
  277. qq|<input name="l_contact" type=checkbox class=checkbox value=Y $form->{l_contact}> |
  278. . $locale->text('Contact');
  279. push @a,
  280. qq|<input name="l_email" type=checkbox class=checkbox value=Y $form->{l_email}> |
  281. . $locale->text('E-mail');
  282. push @a, qq|<input name="l_address" type=checkbox class=checkbox value=Y> |
  283. . $locale->text('Address');
  284. push @a, qq|<input name="l_city" type=checkbox class=checkbox value=Y> |
  285. . $locale->text('City');
  286. push @a, qq|<input name="l_state" type=checkbox class=checkbox value=Y> |
  287. . $locale->text('State/Province');
  288. push @a, qq|<input name="l_zipcode" type=checkbox class=checkbox value=Y> |
  289. . $locale->text('Zip/Postal Code');
  290. push @a, qq|<input name="l_country" type=checkbox class=checkbox value=Y> |
  291. . $locale->text('Country');
  292. push @a,
  293. qq|<input name="l_phone" type=checkbox class=checkbox value=Y $form->{l_phone}> |
  294. . $locale->text('Phone');
  295. push @a, qq|<input name="l_fax" type=checkbox class=checkbox value=Y> |
  296. . $locale->text('Fax');
  297. push @a, qq|<input name="l_cc" type=checkbox class=checkbox value=Y> |
  298. . $locale->text('Cc');
  299. if ( $myconfig{role} =~ /(admin|manager)/ ) {
  300. push @a, qq|<input name="l_bcc" type=checkbox class=checkbox value=Y> |
  301. . $locale->text('Bcc');
  302. }
  303. push @a, qq|<input name="l_notes" type=checkbox class=checkbox value=Y> |
  304. . $locale->text('Notes');
  305. push @a, qq|<input name="l_discount" type=checkbox class=checkbox value=Y> |
  306. . $locale->text('Discount');
  307. push @a,
  308. qq|<input name="l_taxaccount" type=checkbox class=checkbox value=Y> |
  309. . $locale->text('Tax Account');
  310. push @a,
  311. qq|<input name="l_taxnumber" type=checkbox class=checkbox value=Y> |
  312. . $locale->text('Tax Number');
  313. if ( $form->{db} eq 'customer' ) {
  314. push @a,
  315. qq|<input name="l_employee" type=checkbox class=checkbox value=Y> |
  316. . $locale->text('Salesperson');
  317. push @a,
  318. qq|<input name="l_manager" type=checkbox class=checkbox value=Y> |
  319. . $locale->text('Manager');
  320. push @a,
  321. qq|<input name="l_pricegroup" type=checkbox class=checkbox value=Y> |
  322. . $locale->text('Pricegroup');
  323. }
  324. else {
  325. push @a,
  326. qq|<input name="l_employee" type=checkbox class=checkbox value=Y> |
  327. . $locale->text('Employee');
  328. push @a,
  329. qq|<input name="l_manager" type=checkbox class=checkbox value=Y> |
  330. . $locale->text('Manager');
  331. push @a,
  332. qq|<input name="l_gifi_accno" type=checkbox class=checkbox value=Y> |
  333. . $locale->text('GIFI');
  334. }
  335. push @a, qq|<input name="l_sic_code" type=checkbox class=checkbox value=Y> |
  336. . $locale->text('SIC');
  337. push @a, qq|<input name="l_iban" type=checkbox class=checkbox value=Y> |
  338. . $locale->text('IBAN');
  339. push @a, qq|<input name="l_bic" type=checkbox class=checkbox value=Y> |
  340. . $locale->text('BIC');
  341. push @a, qq|<input name="l_business" type=checkbox class=checkbox value=Y> |
  342. . $locale->text('Type of Business');
  343. push @a, qq|<input name="l_terms" type=checkbox class=checkbox value=Y> |
  344. . $locale->text('Terms');
  345. push @a, qq|<input name="l_language" type=checkbox class=checkbox value=Y> |
  346. . $locale->text('Language');
  347. push @a,
  348. qq|<input name="l_startdate" type=checkbox class=checkbox value=Y> |
  349. . $locale->text('Startdate');
  350. push @a, qq|<input name="l_enddate" type=checkbox class=checkbox value=Y> |
  351. . $locale->text('Enddate');
  352. $include = qq|
  353. <tr>
  354. <th align=right nowrap>| . $locale->text('Include in Report') . qq|</th>
  355. <td>
  356. <table>
  357. |;
  358. while (@a) {
  359. $include .= qq|<tr>\n|;
  360. for ( 1 .. 5 ) {
  361. $include .= qq|<td nowrap>| . shift @a;
  362. $include .= qq|</td>\n|;
  363. }
  364. $include .= qq|</tr>\n|;
  365. }
  366. $include .= qq|
  367. </table>
  368. </td>
  369. </tr>
  370. |;
  371. }
  372. sub search {
  373. # $locale->text('Customers')
  374. # $locale->text('Vendors')
  375. $form->{title} = $locale->text('Search') unless $form->{title};
  376. for (qw(name contact phone email)) { $form->{"l_$_"} = 'checked' }
  377. $form->{nextsub} = "list_names";
  378. $orphan = qq|
  379. <tr>
  380. <td></td>
  381. <td><input name=status class=radio type=radio value=all checked>&nbsp;|
  382. . $locale->text('All') . qq|
  383. <input name=status class=radio type=radio value=active>&nbsp;|
  384. . $locale->text('Active') . qq|
  385. <input name=status class=radio type=radio value=inactive>&nbsp;|
  386. . $locale->text('Inactive') . qq|
  387. <input name=status class=radio type=radio value=orphaned>&nbsp;|
  388. . $locale->text('Orphaned')
  389. . qq|</td>
  390. </tr>
  391. |;
  392. &transactions;
  393. &include_in_report;
  394. &search_name;
  395. if ( $form->{lynx} ) {
  396. require "bin/menu.pl";
  397. &menubar;
  398. }
  399. print qq|
  400. </body>
  401. </html>
  402. |;
  403. }
  404. sub search_name {
  405. $label = ucfirst $form->{db};
  406. if ( $form->{db} eq 'customer' ) {
  407. $employee = qq|
  408. <th align=right nowrap>| . $locale->text('Salesperson') . qq|</th>
  409. <td><input name=employee size=32></td>
  410. |;
  411. }
  412. if ( $form->{db} eq 'vendor' ) {
  413. $employee = qq|
  414. <th align=right nowrap>| . $locale->text('Employee') . qq|</th>
  415. <td><input name=employee size=32></td>
  416. |;
  417. }
  418. $form->header;
  419. print qq|
  420. <body>
  421. <form method=post action=$form->{script}>
  422. <input type=hidden name=db value=$form->{db}>
  423. <table width=100%>
  424. <tr>
  425. <th class=listtop>$form->{title}</th>
  426. </tr>
  427. <tr height="5"></tr>
  428. <tr valign=top>
  429. <td>
  430. <table>
  431. <tr valign=top>
  432. <td>
  433. <table>
  434. <tr>
  435. <th align=right nowrap>| . $locale->text('Company Name') . qq|</th>
  436. <td><input name=name size=32></td>
  437. </tr>
  438. <tr>
  439. <th align=right nowrap>| . $locale->text('Contact') . qq|</th>
  440. <td><input name=contact size=32></td>
  441. </tr>
  442. <tr>
  443. <th align=right nowrap>| . $locale->text('E-mail') . qq|</th>
  444. <td><input name=email size=32></td>
  445. </tr>
  446. <tr>
  447. <th align=right nowrap>| . $locale->text('Phone') . qq|</th>
  448. <td><input name=phone size=20></td>
  449. </tr>
  450. <tr>
  451. $employee
  452. </tr>
  453. <tr>
  454. <th align=right nowrap>| . $locale->text('Notes') . qq|</th>
  455. <td colspan=3><textarea name=notes rows=3 cols=32></textarea></td>
  456. </tr>
  457. </table>
  458. </td>
  459. <td>
  460. <table>
  461. <tr>
  462. <th align=right nowrap>| . $locale->text( $label . ' Number' ) . qq|</th>
  463. <td><input name=$form->{db}number size=32></td>
  464. </tr>
  465. <tr>
  466. <th align=right nowrap>| . $locale->text('Address') . qq|</th>
  467. <td><input name=address size=32></td>
  468. </tr>
  469. <tr>
  470. <th align=right nowrap>| . $locale->text('City') . qq|</th>
  471. <td><input name=city size=32></td>
  472. </tr>
  473. <tr>
  474. <th align=right nowrap>| . $locale->text('State/Province') . qq|</th>
  475. <td><input name=state size=32></td>
  476. </tr>
  477. <tr>
  478. <th align=right nowrap>| . $locale->text('Zip/Postal Code') . qq|</th>
  479. <td><input name=zipcode size=10></td>
  480. </tr>
  481. <tr>
  482. <th align=right nowrap>| . $locale->text('Country') . qq|</th>
  483. <td><input name=country size=32></td>
  484. </tr>
  485. <tr>
  486. <th align=right nowrap>| . $locale->text('Startdate') . qq|</th>
  487. <td>|
  488. . $locale->text('From')
  489. . qq| <input class="date" name=startdatefrom size=11 title="$myconfig{dateformat}"> |
  490. . $locale->text('To')
  491. . qq| <input class="date" name=startdateto size=11 title="$myconfig{dateformat}"></td>
  492. </tr>
  493. </table>
  494. </td>
  495. </tr>
  496. </table>
  497. </td>
  498. </tr>
  499. <tr>
  500. <td>
  501. <table>
  502. $orphan
  503. $transactions
  504. $include
  505. </table>
  506. </td>
  507. </tr>
  508. <tr>
  509. <td><hr size=3 noshade></td>
  510. </tr>
  511. </table>
  512. <input type="hidden" name="nextsub" value="$form->{nextsub}">
  513. <input type="hidden" name="path" value="$form->{path}">
  514. <input type="hidden" name="login" value="$form->{login}">
  515. <input type="hidden" name="sessionid" value="$form->{sessionid}">
  516. <br>
  517. <button type="submit" class="submit" name="action" value="continue">|
  518. . $locale->text('Continue')
  519. . qq|</button>
  520. </form>
  521. |;
  522. }
  523. sub list_names {
  524. CT->search( \%myconfig, \%$form );
  525. $href =
  526. "$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}";
  527. $form->sort_order();
  528. $callback =
  529. "$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}";
  530. @columns = $form->sort_columns( id, name, "$form->{db}number", address,
  531. city, state, zipcode, country,
  532. contact, phone, fax, email,
  533. cc, bcc, employee, manager,
  534. notes, discount, terms, taxaccount,
  535. taxnumber, gifi_accno, sic_code, business,
  536. pricegroup, language, iban, bic,
  537. startdate, enddate, invnumber, invamount,
  538. invtax, invtotal, ordnumber, ordamount,
  539. ordtax, ordtotal, quonumber, quoamount,
  540. quotax, quototal
  541. );
  542. unshift @columns, "ndx";
  543. $form->{l_invnumber} = "Y" if $form->{l_transnumber};
  544. foreach $item (qw(inv ord quo)) {
  545. if ( $form->{"l_${item}number"} ) {
  546. for (qw(amount tax total)) {
  547. $form->{"l_$item$_"} = $form->{"l_$_"};
  548. }
  549. $removeemployee = 1;
  550. $openclosed = 1;
  551. }
  552. }
  553. $form->{open} = $form->{closed} = "" if !$openclosed;
  554. foreach $item (@columns) {
  555. if ( $form->{"l_$item"} eq "Y" ) {
  556. push @column_index, $item;
  557. # add column to href and callback
  558. $callback .= "&l_$item=Y";
  559. $href .= "&l_$item=Y";
  560. }
  561. }
  562. foreach $item (qw(amount tax total transnumber)) {
  563. if ( $form->{"l_$item"} eq "Y" ) {
  564. $callback .= "&l_$item=Y";
  565. $href .= "&l_$item=Y";
  566. }
  567. }
  568. if ( $form->{status} eq 'all' ) {
  569. $option = $locale->text('All');
  570. }
  571. if ( $form->{status} eq 'orphaned' ) {
  572. $option = $locale->text('Orphaned');
  573. }
  574. if ( $form->{status} eq 'active' ) {
  575. $option = $locale->text('Active');
  576. }
  577. if ( $form->{status} eq 'inactive' ) {
  578. $option = $locale->text('Inactive');
  579. }
  580. if ( $form->{name} ) {
  581. $callback .= "&name=" . $form->escape( $form->{name}, 1 );
  582. $href .= "&name=" . $form->escape( $form->{name} );
  583. $option .= "\n<br>" . $locale->text('Name') . " : $form->{name}";
  584. }
  585. if ( $form->{address} ) {
  586. $callback .= "&address=" . $form->escape( $form->{address}, 1 );
  587. $href .= "&address=" . $form->escape( $form->{address} );
  588. $option .= "\n<br>" . $locale->text('Address') . " : $form->{address}";
  589. }
  590. if ( $form->{city} ) {
  591. $callback .= "&city=" . $form->escape( $form->{city}, 1 );
  592. $href .= "&city=" . $form->escape( $form->{city} );
  593. $option .= "\n<br>" . $locale->text('City') . " : $form->{city}";
  594. }
  595. if ( $form->{state} ) {
  596. $callback .= "&state=" . $form->escape( $form->{state}, 1 );
  597. $href .= "&state=" . $form->escape( $form->{state} );
  598. $option .= "\n<br>" . $locale->text('State') . " : $form->{state}";
  599. }
  600. if ( $form->{zipcode} ) {
  601. $callback .= "&zipcode=" . $form->escape( $form->{zipcode}, 1 );
  602. $href .= "&zipcode=" . $form->escape( $form->{zipcode} );
  603. $option .=
  604. "\n<br>" . $locale->text('Zip/Postal Code') . " : $form->{zipcode}";
  605. }
  606. if ( $form->{country} ) {
  607. $callback .= "&country=" . $form->escape( $form->{country}, 1 );
  608. $href .= "&country=" . $form->escape( $form->{country} );
  609. $option .= "\n<br>" . $locale->text('Country') . " : $form->{country}";
  610. }
  611. if ( $form->{contact} ) {
  612. $callback .= "&contact=" . $form->escape( $form->{contact}, 1 );
  613. $href .= "&contact=" . $form->escape( $form->{contact} );
  614. $option .= "\n<br>" . $locale->text('Contact') . " : $form->{contact}";
  615. }
  616. if ( $form->{employee} ) {
  617. $callback .= "&employee=" . $form->escape( $form->{employee}, 1 );
  618. $href .= "&employee=" . $form->escape( $form->{employee} );
  619. $option .= "\n<br>";
  620. if ( $form->{db} eq 'customer' ) {
  621. $option .= $locale->text('Salesperson');
  622. }
  623. if ( $form->{db} eq 'vendor' ) {
  624. $option .= $locale->text('Employee');
  625. }
  626. $option .= " : $form->{employee}";
  627. }
  628. $fromdate = "";
  629. $todate = "";
  630. if ( $form->{startdatefrom} ) {
  631. $callback .= "&startdatefrom=$form->{startdatefrom}";
  632. $href .= "&startdatefrom=$form->{startdatefrom}";
  633. $fromdate = $locale->date( \%myconfig, $form->{startdatefrom}, 1 );
  634. }
  635. if ( $form->{startdateto} ) {
  636. $callback .= "&startdateto=$form->{startdateto}";
  637. $href .= "&startdateto=$form->{startdateto}";
  638. $todate = $locale->date( \%myconfig, $form->{startdateto}, 1 );
  639. }
  640. if ( $fromdate || $todate ) {
  641. $option .=
  642. "\n<br>" . $locale->text('Startdate') . " $fromdate - $todate";
  643. }
  644. if ( $form->{notes} ) {
  645. $callback .= "&notes=" . $form->escape( $form->{notes}, 1 );
  646. $href .= "&notes=" . $form->escape( $form->{notes} );
  647. $option .= "\n<br>" . $locale->text('Notes') . " : $form->{notes}";
  648. }
  649. if ( $form->{"$form->{db}number"} ) {
  650. $callback .=
  651. qq|&$form->{db}number=|
  652. . $form->escape( $form->{"$form->{db}number"}, 1 );
  653. $href .=
  654. "&$form->{db}number=" . $form->escape( $form->{"$form->{db}number"} );
  655. $option .= "\n<br>"
  656. . $locale->text('Number')
  657. . qq| : $form->{"$form->{db}number"}|;
  658. }
  659. if ( $form->{phone} ) {
  660. $callback .= "&phone=" . $form->escape( $form->{phone}, 1 );
  661. $href .= "&phone=" . $form->escape( $form->{phone} );
  662. $option .= "\n<br>" . $locale->text('Phone') . " : $form->{phone}";
  663. }
  664. if ( $form->{email} ) {
  665. $callback .= "&email=" . $form->escape( $form->{email}, 1 );
  666. $href .= "&email=" . $form->escape( $form->{email} );
  667. $option .= "\n<br>" . $locale->text('E-mail') . " : $form->{email}";
  668. }
  669. if ( $form->{transdatefrom} ) {
  670. $callback .= "&transdatefrom=$form->{transdatefrom}";
  671. $href .= "&transdatefrom=$form->{transdatefrom}";
  672. $option .= "\n<br>" if ($option);
  673. $option .=
  674. $locale->text('From') . "&nbsp;"
  675. . $locale->date( \%myconfig, $form->{transdatefrom}, 1 );
  676. }
  677. if ( $form->{transdateto} ) {
  678. $callback .= "&transdateto=$form->{transdateto}";
  679. $href .= "&transdateto=$form->{transdateto}";
  680. if ( $form->{transdatefrom} ) {
  681. $option .= " ";
  682. }
  683. else {
  684. $option .= "\n<br>" if ($option);
  685. }
  686. $option .=
  687. $locale->text('To') . "&nbsp;"
  688. . $locale->date( \%myconfig, $form->{transdateto}, 1 );
  689. }
  690. if ( $form->{open} ) {
  691. $callback .= "&open=$form->{open}";
  692. $href .= "&open=$form->{open}";
  693. $option .= "\n<br>" if ($option);
  694. $option .= $locale->text('Open');
  695. }
  696. if ( $form->{closed} ) {
  697. $callback .= "&closed=$form->{closed}";
  698. $href .= "&closed=$form->{closed}";
  699. $option .= "\n<br>" if ($option);
  700. $option .= $locale->text('Closed');
  701. }
  702. $form->{callback} = "$callback&sort=$form->{sort}";
  703. $callback = $form->escape( $form->{callback} );
  704. $column_header{ndx} = qq|<th class=listheading>&nbsp;</th>|;
  705. $column_header{id} =
  706. qq|<th class=listheading>| . $locale->text('ID') . qq|</th>|;
  707. $column_header{"$form->{db}number"} =
  708. qq|<th><a class=listheading href=$href&sort=$form->{db}number>|
  709. . $locale->text('Number')
  710. . qq|</a></th>|;
  711. $column_header{name} =
  712. qq|<th><a class=listheading href=$href&sort=name>|
  713. . $locale->text('Name')
  714. . qq|</a></th>|;
  715. $column_header{address} =
  716. qq|<th class=listheading>| . $locale->text('Address') . qq|</th>|;
  717. $column_header{city} =
  718. qq|<th><a class=listheading href=$href&sort=city>|
  719. . $locale->text('City')
  720. . qq|</a></th>|;
  721. $column_header{state} =
  722. qq|<th><a class=listheading href=$href&sort=state>|
  723. . $locale->text('State/Province')
  724. . qq|</a></th>|;
  725. $column_header{zipcode} =
  726. qq|<th><a class=listheading href=$href&sort=zipcode>|
  727. . $locale->text('Zip/Postal Code')
  728. . qq|</a></th>|;
  729. $column_header{country} =
  730. qq|<th><a class=listheading href=$href&sort=country>|
  731. . $locale->text('Country')
  732. . qq|</a></th>|;
  733. $column_header{contact} =
  734. qq|<th><a class=listheading href=$href&sort=contact>|
  735. . $locale->text('Contact')
  736. . qq|</a></th>|;
  737. $column_header{phone} =
  738. qq|<th><a class=listheading href=$href&sort=phone>|
  739. . $locale->text('Phone')
  740. . qq|</a></th>|;
  741. $column_header{fax} =
  742. qq|<th><a class=listheading href=$href&sort=fax>|
  743. . $locale->text('Fax')
  744. . qq|</a></th>|;
  745. $column_header{email} =
  746. qq|<th><a class=listheading href=$href&sort=email>|
  747. . $locale->text('E-mail')
  748. . qq|</a></th>|;
  749. $column_header{cc} =
  750. qq|<th><a class=listheading href=$href&sort=cc>|
  751. . $locale->text('Cc')
  752. . qq|</a></th>|;
  753. $column_header{bcc} =
  754. qq|<th><a class=listheading href=$href&sort=cc>|
  755. . $locale->text('Bcc')
  756. . qq|</a></th>|;
  757. $column_header{notes} =
  758. qq|<th><a class=listheading href=$href&sort=notes>|
  759. . $locale->text('Notes')
  760. . qq|</a></th>|;
  761. $column_header{discount} = qq|<th class=listheading>%</th>|;
  762. $column_header{terms} =
  763. qq|<th class=listheading>| . $locale->text('Terms') . qq|</th>|;
  764. $column_header{taxnumber} =
  765. qq|<th><a class=listheading href=$href&sort=taxnumber>|
  766. . $locale->text('Tax Number')
  767. . qq|</a></th>|;
  768. $column_header{taxaccount} =
  769. qq|<th class=listheading>| . $locale->text('Tax Account') . qq|</th>|;
  770. $column_header{gifi_accno} =
  771. qq|<th><a class=listheading href=$href&sort=gifi_accno>|
  772. . $locale->text('GIFI')
  773. . qq|</a></th>|;
  774. $column_header{sic_code} =
  775. qq|<th><a class=listheading href=$href&sort=sic_code>|
  776. . $locale->text('SIC')
  777. . qq|</a></th>|;
  778. $column_header{business} =
  779. qq|<th><a class=listheading href=$href&sort=business>|
  780. . $locale->text('Type of Business')
  781. . qq|</a></th>|;
  782. $column_header{iban} =
  783. qq|<th class=listheading>| . $locale->text('IBAN') . qq|</th>|;
  784. $column_header{bic} =
  785. qq|<th class=listheading>| . $locale->text('BIC') . qq|</th>|;
  786. $column_header{startdate} =
  787. qq|<th><a class=listheading href=$href&sort=startdate>|
  788. . $locale->text('Startdate')
  789. . qq|</a></th>|;
  790. $column_header{enddate} =
  791. qq|<th><a class=listheading href=$href&sort=enddate>|
  792. . $locale->text('Enddate')
  793. . qq|</a></th>|;
  794. $column_header{invnumber} =
  795. qq|<th><a class=listheading href=$href&sort=invnumber>|
  796. . $locale->text('Invoice')
  797. . qq|</a></th>|;
  798. $column_header{ordnumber} =
  799. qq|<th><a class=listheading href=$href&sort=ordnumber>|
  800. . $locale->text('Order')
  801. . qq|</a></th>|;
  802. $column_header{quonumber} =
  803. qq|<th><a class=listheading href=$href&sort=quonumber>|
  804. . $locale->text('Quotation')
  805. . qq|</a></th>|;
  806. if ( $form->{db} eq 'customer' ) {
  807. $column_header{employee} =
  808. qq|<th><a class=listheading href=$href&sort=employee>|
  809. . $locale->text('Salesperson')
  810. . qq|</a></th>|;
  811. }
  812. else {
  813. $column_header{employee} =
  814. qq|<th><a class=listheading href=$href&sort=employee>|
  815. . $locale->text('Employee')
  816. . qq|</a></th>|;
  817. }
  818. $column_header{manager} =
  819. qq|<th><a class=listheading href=$href&sort=manager>|
  820. . $locale->text('Manager')
  821. . qq|</a></th>|;
  822. $column_header{pricegroup} =
  823. qq|<th><a class=listheading href=$href&sort=pricegroup>|
  824. . $locale->text('Pricegroup')
  825. . qq|</a></th>|;
  826. $column_header{language} =
  827. qq|<th><a class=listheading href=$href&sort=language>|
  828. . $locale->text('Language')
  829. . qq|</a></th>|;
  830. $amount = $locale->text('Amount');
  831. $tax = $locale->text('Tax');
  832. $total = $locale->text('Total');
  833. $column_header{invamount} = qq|<th class=listheading>$amount</th>|;
  834. $column_header{ordamount} = qq|<th class=listheading>$amount</th>|;
  835. $column_header{quoamount} = qq|<th class=listheading>$amount</th>|;
  836. $column_header{invtax} = qq|<th class=listheading>$tax</th>|;
  837. $column_header{ordtax} = qq|<th class=listheading>$tax</th>|;
  838. $column_header{quotax} = qq|<th class=listheading>$tax</th>|;
  839. $column_header{invtotal} = qq|<th class=listheading>$total</th>|;
  840. $column_header{ordtotal} = qq|<th class=listheading>$total</th>|;
  841. $column_header{quototal} = qq|<th class=listheading>$total</th>|;
  842. if ( $form->{status} ) {
  843. $label = ucfirst $form->{db} . "s";
  844. $form->{title} = $locale->text($label);
  845. }
  846. else {
  847. $label = ucfirst $form->{db};
  848. $form->{title} = $locale->text( $label . " Transactions" );
  849. }
  850. $form->header;
  851. print qq|
  852. <body>
  853. <table width=100%>
  854. <tr>
  855. <th class=listtop>$form->{title}</th>
  856. </tr>
  857. <tr height="5"></tr>
  858. <tr>
  859. <td>$option</td>
  860. </tr>
  861. <tr>
  862. <td>
  863. <table width=100%>
  864. <tr class=listheading>
  865. |;
  866. for (@column_index) { print "$column_header{$_}\n" }
  867. print qq|
  868. </tr>
  869. |;
  870. $ordertype =
  871. ( $form->{db} eq 'customer' ) ? 'sales_order' : 'purchase_order';
  872. $quotationtype =
  873. ( $form->{db} eq 'customer' ) ? 'sales_quotation' : 'request_quotation';
  874. $subtotal = 0;
  875. $i = 0;
  876. foreach $ref ( @{ $form->{CT} } ) {
  877. if ( $ref->{ $form->{sort} } ne $sameitem && $form->{l_subtotal} ) {
  878. # print subtotal
  879. if ($subtotal) {
  880. for (@column_index) { $column_data{$_} = "<td>&nbsp;</td>" }
  881. &list_subtotal;
  882. }
  883. }
  884. if ( $ref->{id} eq $sameid ) {
  885. for (@column_index) { $column_data{$_} = "<td>&nbsp;</td>" }
  886. }
  887. else {
  888. $i++;
  889. $ref->{notes} =~ s/\r?\n/<br>/g;
  890. for (@column_index) {
  891. $column_data{$_} = "<td>$ref->{$_}&nbsp;</td>";
  892. }
  893. $column_data{ndx} = "<td align=right>$i</td>";
  894. if ( $ref->{ $form->{sort} } eq $sameitem ) {
  895. $column_data{ $form->{sort} } = "<td>&nbsp;</td>";
  896. }
  897. $column_data{address} =
  898. "<td>$ref->{address1} $ref->{address2}&nbsp;</td>";
  899. $column_data{name} =
  900. "<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>";
  901. $email = "";
  902. if ( $form->{sort} =~ /(email|cc)/ ) {
  903. if ( $ref->{ $form->{sort} } ne $sameitem ) {
  904. $email = 1;
  905. }
  906. }
  907. else {
  908. $email = 1;
  909. }
  910. if ($email) {
  911. foreach $item (qw(email cc bcc)) {
  912. if ( $ref->{$item} ) {
  913. $email = $ref->{$item};
  914. $email =~ s/</\&lt;/;
  915. $email =~ s/>/\&gt;/;
  916. $column_data{$item} =
  917. qq|<td><a href="mailto:$ref->{$item}">$email</a></td>|;
  918. }
  919. }
  920. }
  921. }
  922. if ( $ref->{formtype} eq 'invoice' ) {
  923. $column_data{invnumber} =
  924. "<td><a href=$ref->{module}.pl?action=edit&id=$ref->{invid}&path=$form->{path}&login=$form->{login}&sessionid=$form->{sessionid}&callback=$callback>$ref->{invnumber}&nbsp;</td>";
  925. $column_data{invamount} =
  926. "<td align=right>"
  927. . $form->format_amount( \%myconfig, $ref->{netamount}, 2,
  928. "&nbsp;" )
  929. . "</td>";
  930. $column_data{invtax} = "<td align=right>"
  931. . $form->format_amount( \%myconfig,
  932. $ref->{amount} - $ref->{netamount},
  933. 2, "&nbsp;" )
  934. . "</td>";
  935. $column_data{invtotal} =
  936. "<td align=right>"
  937. . $form->format_amount( \%myconfig, $ref->{amount}, 2, "&nbsp;" )
  938. . "</td>";
  939. $invamountsubtotal += $ref->{netamount};
  940. $invtaxsubtotal += ( $ref->{amount} - $ref->{netamount} );
  941. $invtotalsubtotal += $ref->{amount};
  942. $subtotal = 1;
  943. }
  944. if ( $ref->{formtype} eq 'order' ) {
  945. $column_data{ordnumber} =
  946. "<td><a href=$ref->{module}.pl?action=edit&id=$ref->{invid}&type=$ordertype&path=$form->{path}&login=$form->{login}&sessionid=$form->{sessionid}&callback=$callback>$ref->{ordnumber}&nbsp;</td>";
  947. $column_data{ordamount} =
  948. "<td align=right>"
  949. . $form->format_amount( \%myconfig, $ref->{netamount}, 2,
  950. "&nbsp;" )
  951. . "</td>";
  952. $column_data{ordtax} = "<td align=right>"
  953. . $form->format_amount( \%myconfig,
  954. $ref->{amount} - $ref->{netamount},
  955. 2, "&nbsp;" )
  956. . "</td>";
  957. $column_data{ordtotal} =
  958. "<td align=right>"
  959. . $form->format_amount( \%myconfig, $ref->{amount}, 2, "&nbsp;" )
  960. . "</td>";
  961. $ordamountsubtotal += $ref->{netamount};
  962. $ordtaxsubtotal += ( $ref->{amount} - $ref->{netamount} );
  963. $ordtotalsubtotal += $ref->{amount};
  964. $subtotal = 1;
  965. }
  966. if ( $ref->{formtype} eq 'quotation' ) {
  967. $column_data{quonumber} =
  968. "<td><a href=$ref->{module}.pl?action=edit&id=$ref->{invid}&type=$quotationtype&path=$form->{path}&login=$form->{login}&sessionid=$form->{sessionid}&callback=$callback>$ref->{quonumber}&nbsp;</td>";
  969. $column_data{quoamount} =
  970. "<td align=right>"
  971. . $form->format_amount( \%myconfig, $ref->{netamount}, 2,
  972. "&nbsp;" )
  973. . "</td>";
  974. $column_data{quotax} = "<td align=right>"
  975. . $form->format_amount( \%myconfig,
  976. $ref->{amount} - $ref->{netamount},
  977. 2, "&nbsp;" )
  978. . "</td>";
  979. $column_data{quototal} =
  980. "<td align=right>"
  981. . $form->format_amount( \%myconfig, $ref->{amount}, 2, "&nbsp;" )
  982. . "</td>";
  983. $quoamountsubtotal += $ref->{netamount};
  984. $quotaxsubtotal += ( $ref->{amount} - $ref->{netamount} );
  985. $quototalsubtotal += $ref->{amount};
  986. $subtotal = 1;
  987. }
  988. if ( $sameid ne "$ref->{id}" ) {
  989. if ( $form->{l_discount} ) {
  990. $column_data{discount} = "<td align=right>"
  991. . $form->format_amount( \%myconfig, $ref->{discount} * 100,
  992. "", "&nbsp;" )
  993. . "</td>";
  994. }
  995. if ( $form->{l_terms} ) {
  996. $column_data{terms} = "<td align=right>"
  997. . $form->format_amount( \%myconfig, $ref->{terms}, "",
  998. "&nbsp;" )
  999. . "</td>";
  1000. }
  1001. }
  1002. $j++;
  1003. $j %= 2;
  1004. print "
  1005. <tr class=listrow$j>
  1006. ";
  1007. for (@column_index) { print "$column_data{$_}\n" }
  1008. print qq|
  1009. </tr>
  1010. |;
  1011. $sameitem = "$ref->{$form->{sort}}";
  1012. $sameid = $ref->{id};
  1013. }
  1014. if ( $form->{l_subtotal} && $subtotal ) {
  1015. for (@column_index) { $column_data{$_} = "<td>&nbsp;</td>" }
  1016. &list_subtotal;
  1017. }
  1018. $i = 1;
  1019. if ( $myconfig{acs} !~ /AR--AR/ ) {
  1020. if ( $form->{db} eq 'customer' ) {
  1021. $button{'AR--Customers--Add Customer'}{code} =
  1022. qq|<button class="submit" type="submit" name="action" value="add_customer">|
  1023. . $locale->text('Add Customer')
  1024. . qq|</button> |;
  1025. $button{'AR--Customers--Add Customer'}{order} = $i++;
  1026. }
  1027. }
  1028. if ( $myconfig{acs} !~ /AP--AP/ ) {
  1029. if ( $form->{db} eq 'vendor' ) {
  1030. $button{'AP--Vendors--Add Vendor'}{code} =
  1031. qq|<button class="submit" type="submit" name="action" value="add_vendor">|
  1032. . $locale->text('Add Vendor')
  1033. . qq|</button> |;
  1034. $button{'AP--Vendors--Add Vendor'}{order} = $i++;
  1035. }
  1036. }
  1037. foreach $item ( split /;/, $myconfig{acs} ) {
  1038. delete $button{$item};
  1039. }
  1040. print qq|
  1041. </table>
  1042. </td>
  1043. </tr>
  1044. <tr>
  1045. <td><hr size=3 noshade></td>
  1046. </tr>
  1047. </table>
  1048. <br>
  1049. <form method=post action=$form->{script}>
  1050. |;
  1051. $form->hide_form(qw(callback db path login sessionid));
  1052. if ( $form->{status} ) {
  1053. foreach $item ( sort { $a->{order} <=> $b->{order} } %button ) {
  1054. print $item->{code};
  1055. }
  1056. }
  1057. if ( $form->{lynx} ) {
  1058. require "bin/menu.pl";
  1059. &menubar;
  1060. }
  1061. print qq|
  1062. </form>
  1063. </body>
  1064. </html>
  1065. |;
  1066. }
  1067. sub list_subtotal {
  1068. $column_data{invamount} =
  1069. "<td align=right>"
  1070. . $form->format_amount( \%myconfig, $invamountsubtotal, 2, "&nbsp;" )
  1071. . "</td>";
  1072. $column_data{invtax} =
  1073. "<td align=right>"
  1074. . $form->format_amount( \%myconfig, $invtaxsubtotal, 2, "&nbsp;" )
  1075. . "</td>";
  1076. $column_data{invtotal} =
  1077. "<td align=right>"
  1078. . $form->format_amount( \%myconfig, $invtotalsubtotal, 2, "&nbsp;" )
  1079. . "</td>";
  1080. $invamountsubtotal = 0;
  1081. $invtaxsubtotal = 0;
  1082. $invtotalsubtotal = 0;
  1083. $column_data{ordamount} =
  1084. "<td align=right>"
  1085. . $form->format_amount( \%myconfig, $ordamountsubtotal, 2, "&nbsp;" )
  1086. . "</td>";
  1087. $column_data{ordtax} =
  1088. "<td align=right>"
  1089. . $form->format_amount( \%myconfig, $ordtaxsubtotal, 2, "&nbsp;" )
  1090. . "</td>";
  1091. $column_data{ordtotal} =
  1092. "<td align=right>"
  1093. . $form->format_amount( \%myconfig, $ordtotalsubtotal, 2, "&nbsp;" )
  1094. . "</td>";
  1095. $ordamountsubtotal = 0;
  1096. $ordtaxsubtotal = 0;
  1097. $ordtotalsubtotal = 0;
  1098. $column_data{quoamount} =
  1099. "<td align=right>"
  1100. . $form->format_amount( \%myconfig, $quoamountsubtotal, 2, "&nbsp;" )
  1101. . "</td>";
  1102. $column_data{quotax} =
  1103. "<td align=right>"
  1104. . $form->format_amount( \%myconfig, $quotaxsubtotal, 2, "&nbsp;" )
  1105. . "</td>";
  1106. $column_data{quototal} =
  1107. "<td align=right>"
  1108. . $form->format_amount( \%myconfig, $quototalsubtotal, 2, "&nbsp;" )
  1109. . "</td>";
  1110. $quoamountsubtotal = 0;
  1111. $quotaxsubtotal = 0;
  1112. $quototalsubtotal = 0;
  1113. print "
  1114. <tr class=listsubtotal>
  1115. ";
  1116. for (@column_index) { print "$column_data{$_}\n" }
  1117. print qq|
  1118. </tr>
  1119. |;
  1120. }
  1121. sub list_history {
  1122. CT->get_history( \%myconfig, \%$form );
  1123. $href =
  1124. "$form->{script}?action=list_history&direction=$form->{direction}&oldsort=$form->{oldsort}&db=$form->{db}&path=$form->{path}&login=$form->{login}&sessionid=$form->{sessionid}&type=$form->{type}&transdatefrom=$form->{transdatefrom}&transdateto=$form->{transdateto}&history=$form->{history}";
  1125. $form->sort_order();
  1126. $callback =
  1127. "$form->{script}?action=list_history&direction=$form->{direction}&oldsort=$form->{oldsort}&db=$form->{db}&path=$form->{path}&login=$form->{login}&sessionid=$form->{sessionid}&type=$form->{type}&transdatefrom=$form->{transdatefrom}&transdateto=$form->{transdateto}&history=$form->{history}";
  1128. $form->{l_fxsellprice} = $form->{l_curr};
  1129. @columns = $form->sort_columns( partnumber, description, qty, unit,
  1130. sellprice, fxsellprice, curr, discount,
  1131. deliverydate, projectnumber, serialnumber
  1132. );
  1133. if ( $form->{history} eq 'summary' ) {
  1134. @columns =
  1135. $form->sort_columns( partnumber, description, qty, unit, sellprice,
  1136. curr );
  1137. }
  1138. foreach $item (@columns) {
  1139. if ( $form->{"l_$item"} eq "Y" ) {
  1140. push @column_index, $item;
  1141. # add column to href and callback
  1142. $callback .= "&l_$item=Y";
  1143. $href .= "&l_$item=Y";
  1144. }
  1145. }
  1146. if ( $form->{history} eq 'detail' ) {
  1147. $option = $locale->text('Detail');
  1148. }
  1149. if ( $form->{history} eq 'summary' ) {
  1150. $option .= $locale->text('Summary');
  1151. }
  1152. if ( $form->{name} ) {
  1153. $callback .= "&name=" . $form->escape( $form->{name}, 1 );
  1154. $href .= "&name=" . $form->escape( $form->{name} );
  1155. $option .= "\n<br>" . $locale->text('Name') . " : $form->{name}";
  1156. }
  1157. if ( $form->{contact} ) {
  1158. $callback .= "&contact=" . $form->escape( $form->{contact}, 1 );
  1159. $href .= "&contact=" . $form->escape( $form->{contact} );
  1160. $option .= "\n<br>" . $locale->text('Contact') . " : $form->{contact}";
  1161. }
  1162. if ( $form->{"$form->{db}number"} ) {
  1163. $callback .=
  1164. qq|&$form->{db}number=|
  1165. . $form->escape( $form->{"$form->{db}number"}, 1 );
  1166. $href .=
  1167. "&$form->{db}number=" . $form->escape( $form->{"$form->{db}number"} );
  1168. $option .= "\n<br>"
  1169. . $locale->text('Number')
  1170. . qq| : $form->{"$form->{db}number"}|;
  1171. }
  1172. if ( $form->{email} ) {
  1173. $callback .= "&email=" . $form->escape( $form->{email}, 1 );
  1174. $href .= "&email=" . $form->escape( $form->{email} );
  1175. $option .= "\n<br>" . $locale->text('E-mail') . " : $form->{email}";
  1176. }
  1177. if ( $form->{transdatefrom} ) {
  1178. $callback .= "&transdatefrom=$form->{transdatefrom}";
  1179. $href .= "&transdatefrom=$form->{transdatefrom}";
  1180. $option .= "\n<br>" if ($option);
  1181. $option .=
  1182. $locale->text('From') . "&nbsp;"
  1183. . $locale->date( \%myconfig, $form->{transdatefrom}, 1 );
  1184. }
  1185. if ( $form->{transdateto} ) {
  1186. $callback .= "&transdateto=$form->{transdateto}";
  1187. $href .= "&transdateto=$form->{transdateto}";
  1188. if ( $form->{transdatefrom} ) {
  1189. $option .= " ";
  1190. }
  1191. else {
  1192. $option .= "\n<br>" if ($option);
  1193. }
  1194. $option .=
  1195. $locale->text('To') . "&nbsp;"
  1196. . $locale->date( \%myconfig, $form->{transdateto}, 1 );
  1197. }
  1198. if ( $form->{open} ) {
  1199. $callback .= "&open=$form->{open}";
  1200. $href .= "&open=$form->{open}";
  1201. $option .= "\n<br>" if ($option);
  1202. $option .= $locale->text('Open');
  1203. }
  1204. if ( $form->{closed} ) {
  1205. $callback .= "&closed=$form->{closed}";
  1206. $href .= "&closed=$form->{closed}";
  1207. $option .= "\n<br>" if ($option);
  1208. $option .= $locale->text('Closed');
  1209. }
  1210. $form->{callback} = "$callback&sort=$form->{sort}";
  1211. $callback = $form->escape( $form->{callback} );
  1212. $column_header{partnumber} =
  1213. qq|<th><a class=listheading href=$href&sort=partnumber>|
  1214. . $locale->text('Part Number')
  1215. . qq|</a></th>|;
  1216. $column_header{description} =
  1217. qq|<th><a class=listheading href=$href&sort=description>|
  1218. . $locale->text('Description')
  1219. . qq|</a></th>|;
  1220. if ( $form->{history} eq 'summary' ) {
  1221. $column_header{sellprice} =
  1222. qq|<th class=listheading>| . $locale->text('Total') . qq|</th>|;
  1223. }
  1224. else {
  1225. $column_header{sellprice} =
  1226. qq|<th class=listheading>| . $locale->text('Sell Price') . qq|</th>|;
  1227. }
  1228. $column_header{fxsellprice} = qq|<th>&nbsp;</th>|;
  1229. $column_header{curr} =
  1230. qq|<th class=listheading>| . $locale->text('Curr') . qq|</th>|;
  1231. $column_header{discount} =
  1232. qq|<th class=listheading>| . $locale->text('Discount') . qq|</th>|;
  1233. $column_header{qty} =
  1234. qq|<th class=listheading>| . $locale->text('Qty') . qq|</th>|;
  1235. $column_header{unit} =
  1236. qq|<th class=listheading>| . $locale->text('Unit') . qq|</th>|;
  1237. $column_header{deliverydate} =
  1238. qq|<th><a class=listheading href=$href&sort=deliverydate>|
  1239. . $locale->text('Delivery Date')
  1240. . qq|</a></th>|;
  1241. $column_header{projectnumber} =
  1242. qq|<th><a class=listheading href=$href&sort=projectnumber>|
  1243. . $locale->text('Project Number')
  1244. . qq|</a></th>|;
  1245. $column_header{serialnumber} =
  1246. qq|<th><a class=listheading href=$href&sort=serialnumber>|
  1247. . $locale->text('Serial Number')
  1248. . qq|</a></th>|;
  1249. # $locale->text('Customer History')
  1250. # $locale->text('Vendor History')
  1251. $label = ucfirst $form->{db};
  1252. $form->{title} = $locale->text( $label . " History" );
  1253. $colspan = $#column_index + 1;
  1254. $form->header;
  1255. print qq|
  1256. <body>
  1257. <table width=100%>
  1258. <tr>
  1259. <th class=listtop>$form->{title}</th>
  1260. </tr>
  1261. <tr height="5"></tr>
  1262. <tr>
  1263. <td>$option</td>
  1264. </tr>
  1265. <tr>
  1266. <td>
  1267. <table width=100%>
  1268. <tr class=listheading>
  1269. |;
  1270. for (@column_index) { print "$column_header{$_}\n" }
  1271. print qq|
  1272. </tr>
  1273. |;
  1274. $module = 'oe';
  1275. if ( $form->{db} eq 'customer' ) {
  1276. $invlabel = $locale->text('Sales Invoice');
  1277. $ordlabel = $locale->text('Sales Order');
  1278. $quolabel = $locale->text('Quotation');
  1279. $ordertype = 'sales_order';
  1280. $quotationtype = 'sales_quotation';
  1281. if ( $form->{type} eq 'invoice' ) {
  1282. $module = 'is';
  1283. }
  1284. }
  1285. else {
  1286. $invlabel = $locale->text('Vendor Invoice');
  1287. $ordlabel = $locale->text('Purchase Order');
  1288. $quolabel = $locale->text('RFQ');
  1289. $ordertype = 'purchase_order';
  1290. $quotationtype = 'request_quotation';
  1291. if ( $form->{type} eq 'invoice' ) {
  1292. $module = 'ir';
  1293. }
  1294. }
  1295. $ml = ( $form->{db} eq 'vendor' ) ? -1 : 1;
  1296. foreach $ref ( @{ $form->{CT} } ) {
  1297. if ( $ref->{id} ne $sameid ) {
  1298. # print the header
  1299. print qq|
  1300. <tr class=listheading>
  1301. <th colspan=$colspan><a class=listheading href=$form->{script}?action=edit&id=$ref->{ctid}&db=$form->{db}&path=$form->{path}&login=$form->{login}&sessionid=$form->{sessionid}&callback=$callback>$ref->{name} $ref->{address}</a></th>
  1302. </tr>
  1303. |;
  1304. }
  1305. if ( $form->{type} ne 'invoice' ) {
  1306. $ref->{fxsellprice} = $ref->{sellprice};
  1307. $ref->{sellprice} *= $ref->{exchangerate};
  1308. }
  1309. if ( $form->{history} eq 'detail' and $ref->{invid} ne $sameinvid ) {
  1310. # print inv, ord, quo number
  1311. $i++;
  1312. $i %= 2;
  1313. print qq|
  1314. <tr class=listrow$i>
  1315. |;
  1316. if ( $form->{type} eq 'invoice' ) {
  1317. print
  1318. qq|<th align=left colspan=$colspan><a href=${module}.pl?action=edit&id=$ref->{invid}&path=$form->{path}&login=$form->{login}&sessionid=$form->{sessionid}&callback=$callback>$invlabel $ref->{invnumber} / $ref->{employee}</a></th>|;
  1319. }
  1320. if ( $form->{type} eq 'order' ) {
  1321. print
  1322. qq|<th align=left colspan=$colspan><a href=${module}.pl?action=edit&id=$ref->{invid}&type=$ordertype&path=$form->{path}&login=$form->{login}&sessionid=$form->{sessionid}&callback=$callback>$ordlabel $ref->{ordnumber} / $ref->{employee}</a></th>|;
  1323. }
  1324. if ( $form->{type} eq 'quotation' ) {
  1325. print
  1326. qq|<th align=left colspan=$colspan><a href=${module}.pl?action=edit&id=$ref->{invid}&type=$quotationtype&path=$form->{path}&login=$form->{login}&sessionid=$form->{sessionid}&callback=$callback>$quolabel $ref->{quonumber} / $ref->{employee}</a></th>|;
  1327. }
  1328. print qq|
  1329. </tr>
  1330. |;
  1331. }
  1332. for (@column_index) { $column_data{$_} = "<td>$ref->{$_}&nbsp;</td>" }
  1333. if ( $form->{l_curr} ) {
  1334. $column_data{fxsellprice} =
  1335. qq|<td align=right>|
  1336. . $form->format_amount( \%myconfig, $ref->{fxsellprice}, 2 )
  1337. . "</td>";
  1338. }
  1339. $column_data{sellprice} =
  1340. qq|<td align=right>|
  1341. . $form->format_amount( \%myconfig, $ref->{sellprice}, 2 ) . "</td>";
  1342. $column_data{qty} =
  1343. qq|<td align=right>|
  1344. . $form->format_amount( \%myconfig, $ref->{qty} * $ml ) . "</td>";
  1345. $column_data{discount} = qq|<td align=right>|
  1346. . $form->format_amount( \%myconfig, $ref->{discount} * 100,
  1347. "", "&nbsp;" )
  1348. . "</td>";
  1349. $column_data{partnumber} =
  1350. qq|<td><a href=ic.pl?action=edit&id=$ref->{pid}&path=$form->{path}&login=$form->{login}&sessionid=$form->{sessionid}&callback=$callback>$ref->{partnumber}</td>|;
  1351. $i++;
  1352. $i %= 2;
  1353. print qq|
  1354. <tr class=listrow$i>
  1355. |;
  1356. for (@column_index) { print "$column_data{$_}\n" }
  1357. print qq|
  1358. </tr>
  1359. |;
  1360. $sameid = $ref->{id};
  1361. $sameinvid = $ref->{invid};
  1362. }
  1363. print qq|
  1364. </table>
  1365. </td>
  1366. </tr>
  1367. <tr>
  1368. <td><hr size=3 noshade></td>
  1369. </tr>
  1370. </table>
  1371. |;
  1372. if ( $form->{lynx} ) {
  1373. require "bin/menu.pl";
  1374. &menubar;
  1375. }
  1376. print qq|
  1377. </form>
  1378. </body>
  1379. </html>
  1380. |;
  1381. }
  1382. sub edit {
  1383. # $locale->text('Edit Customer')
  1384. # $locale->text('Edit Vendor')
  1385. CT->create_links( \%myconfig, \%$form );
  1386. for ( keys %$form ) { $form->{$_} = $form->quote( $form->{$_} ) }
  1387. $form->{title} = "Edit";
  1388. # format discount
  1389. $form->{discount} *= 100;
  1390. &form_header;
  1391. &form_footer;
  1392. }
  1393. sub form_header {
  1394. $form->{taxincluded} = ( $form->{taxincluded} ) ? "checked" : "";
  1395. $form->{creditlimit} =
  1396. $form->format_amount( \%myconfig, $form->{creditlimit}, 0 );
  1397. $form->{discount} =
  1398. $form->format_amount( \%myconfig, $form->{discount}, "" );
  1399. $form->{terms} = $form->format_amount( \%myconfig, $form->{terms}, "" );
  1400. if ( $myconfig{role} =~ /(admin|manager)/ ) {
  1401. $bcc = qq|
  1402. <tr>
  1403. <th align=right nowrap>| . $locale->text('Bcc') . qq|</th>
  1404. <td><input name=bcc size=35 value="$form->{bcc}"></td>
  1405. </tr>
  1406. |;
  1407. }
  1408. if ( $form->{currencies} ) {
  1409. # currencies
  1410. for ( split /:/, $form->{currencies} ) {
  1411. $form->{selectcurrency} .= "<option>$_\n";
  1412. }
  1413. $form->{selectcurrency} =~ s/option>($form->{curr})/option selected>$1/;
  1414. $currency = qq|
  1415. <th>| . $locale->text('Currency') . qq|</th>
  1416. <td><select name=curr>$form->{selectcurrency}</select></td>
  1417. |;
  1418. }
  1419. foreach $item ( split / /, $form->{taxaccounts} ) {
  1420. if ( $form->{tax}{$item}{taxable} ) {
  1421. $taxable .=
  1422. qq| <input name="tax_$item" value=1 class=checkbox type=checkbox checked>&nbsp;<b>$form->{tax}{$item}{description}</b>|;
  1423. }
  1424. else {
  1425. $taxable .=
  1426. qq| <input name="tax_$item" value=1 class=checkbox type=checkbox>&nbsp;<b>$form->{tax}{$item}{description}</b>|;
  1427. }
  1428. }
  1429. if ($taxable) {
  1430. $tax = qq|
  1431. <tr>
  1432. <th align=right>| . $locale->text('Taxable') . qq|</th>
  1433. <td colspan=5>
  1434. <table>
  1435. <tr>
  1436. <td>$taxable</td>
  1437. <td><input name=taxincluded class=checkbox type=checkbox value=1 $form->{taxincluded}></td>
  1438. <th align=left>| . $locale->text('Tax Included') . qq|</th>
  1439. </tr>
  1440. </table>
  1441. </td>
  1442. </tr>
  1443. |;
  1444. }
  1445. $typeofbusiness = qq|
  1446. <th></th>
  1447. <td></td>
  1448. |;
  1449. if ( @{ $form->{all_business} } ) {
  1450. $form->{selectbusiness} = qq|<option>\n|;
  1451. for ( @{ $form->{all_business} } ) {
  1452. $form->{selectbusiness} .=
  1453. qq|<option value="$_->{description}--$_->{id}">$_->{description}\n|;
  1454. }
  1455. $form->{selectbusiness} =~
  1456. s/(<option value="\Q$form->{business}--$form->{business_id}\E")>/$1 selected>/;
  1457. $typeofbusiness = qq|
  1458. <th align=right>| . $locale->text('Type of Business') . qq|</th>
  1459. <td><select name=business>$form->{selectbusiness}</select></td>
  1460. |;
  1461. }
  1462. $pricegroup = qq|
  1463. <th></th>
  1464. <td></td>
  1465. |;
  1466. if ( @{ $form->{all_pricegroup} } && $form->{db} eq 'customer' ) {
  1467. $form->{selectpricegroup} = qq|<option>\n|;
  1468. for ( @{ $form->{all_pricegroup} } ) {
  1469. $form->{selectpricegroup} .=
  1470. qq|<option value="$_->{pricegroup}--$_->{id}">$_->{pricegroup}\n|;
  1471. }
  1472. $form->{selectpricegroup} =~
  1473. s/(<option value="\Q$form->{pricegroup}--$form->{pricegroup_id}\E")/$1 selected/;
  1474. $pricegroup = qq|
  1475. <th align=right>| . $locale->text('Pricegroup') . qq|</th>
  1476. <td><select name=pricegroup>$form->{selectpricegroup}</select></td>
  1477. |;
  1478. }
  1479. $lang = qq|
  1480. <th></th>
  1481. <td></td>
  1482. |;
  1483. if ( @{ $form->{all_language} } ) {
  1484. $form->{selectlanguage} = qq|<option>\n|;
  1485. for ( @{ $form->{all_language} } ) {
  1486. $form->{selectlanguage} .=
  1487. qq|<option value="$_->{description}--$_->{code}">$_->{description}\n|;
  1488. }
  1489. $form->{selectlanguage} =~
  1490. s/(<option value="\Q$form->{language}--$form->{language_code}\E")/$1 selected/;
  1491. $lang = qq|
  1492. <th align=right>| . $locale->text('Language') . qq|</th>
  1493. <td><select name=language>$form->{selectlanguage}</select></td>
  1494. |;
  1495. }
  1496. $employeelabel = $locale->text('Salesperson');
  1497. $form->{selectemployee} = qq|<option>\n|;
  1498. for ( @{ $form->{all_employee} } ) {
  1499. $form->{selectemployee} .=
  1500. qq|<option value="$_->{name}--$_->{id}">$_->{name}\n|;
  1501. }
  1502. $form->{selectemployee} =~
  1503. s/(<option value="\Q$form->{employee}--$form->{employee_id}\E")/$1 selected/;
  1504. if ( $form->{db} eq 'vendor' ) {
  1505. $gifi = qq|
  1506. <th align=right>| . $locale->text('Sub-contract GIFI') . qq|</th>
  1507. <td><input name=gifi_accno size=9 value="$form->{gifi_accno}"></td>
  1508. |;
  1509. $employeelabel = $locale->text('Employee');
  1510. }
  1511. if ( @{ $form->{all_employee} } ) {
  1512. $employee = qq|
  1513. <th align=right>$employeelabel</th>|;
  1514. if ( $myconfig{role} ne 'user' || !$form->{id} ) {
  1515. $employee .= qq|
  1516. <td><select name=employee>$form->{selectemployee}</select></td>
  1517. |;
  1518. }
  1519. else {
  1520. $employee .= qq|
  1521. <td>$form->{employee}</td>
  1522. <input type=hidden name=employee value="$form->{employee}--$form->{employee_id}">|;
  1523. }
  1524. }
  1525. # $locale->text('Customer Number')
  1526. # $locale->text('Vendor Number')
  1527. $label = ucfirst $form->{db};
  1528. $form->{title} = $locale->text("$form->{title} $label");
  1529. $form->header;
  1530. print qq|
  1531. <body>
  1532. <form method=post action=$form->{script}>
  1533. <table width=100%>
  1534. <tr>
  1535. <th class=listtop>$form->{title}</th>
  1536. </tr>
  1537. <tr height="5"></tr>
  1538. <tr>
  1539. <td>
  1540. <table width=100%>
  1541. <tr valign=top>
  1542. <td width=50%>
  1543. <table width=100%>
  1544. <tr class=listheading>
  1545. <th class=listheading colspan=2 width=50%>|
  1546. . $locale->text('Billing Address')
  1547. . qq|</th>
  1548. <tr>
  1549. <th align=right nowrap>| . $locale->text( $label . ' Number' ) . qq|</th>
  1550. <td><input name="$form->{db}number" size=35 maxlength=32 value="$form->{"$form->{db}number"}"></td>
  1551. </tr>
  1552. <tr>
  1553. <th align=right nowrap>| . $locale->text('Company Name') . qq|</th>
  1554. <td><input name=name size=35 maxlength=64 value="$form->{name}"></td>
  1555. </tr>
  1556. <tr>
  1557. <th align=right nowrap>| . $locale->text('Address') . qq|</th>
  1558. <td><input name=address1 size=35 maxlength=32 value="$form->{address1}"></td>
  1559. </tr>
  1560. <tr>
  1561. <th></th>
  1562. <td><input name=address2 size=35 maxlength=32 value="$form->{address2}"></td>
  1563. </tr>
  1564. <tr>
  1565. <th align=right nowrap>| . $locale->text('City') . qq|</th>