summaryrefslogtreecommitdiff
path: root/bin/lynx/ct.pl
blob: 5bccf6d1852291dd15c57f9b8be5052443b08950 (plain)
  1. #=====================================================================
  2. # LedgerSMB Small Medium Business Accounting
  3. # Copyright (C) 2006
  4. # This work contains copyrighted information from a number of sources all used
  5. # with permission.
  6. #
  7. # This file contains source code included with or based on SQL-Ledger which
  8. # is Copyright Dieter Simader and DWS Systems Inc. 2000-2005 and licensed
  9. # under the GNU General Public License version 2 or, at your option, any later
  10. # version. For a full list including contact information of contributors,
  11. # maintainers, and copyright holders, see the CONTRIBUTORS file.
  12. #
  13. # Original Copyright Notice from SQL-Ledger 2.6.17 (before the fork):
  14. # Copyright (c) 2001
  15. #
  16. # Author: DWS Systems Inc.
  17. # Web: http://www.sql-ledger.org
  18. #
  19. # Contributors: Reed White <alta@alta-research.com>
  20. #
  21. #
  22. # Author: DWS Systems Inc.
  23. # Web: http://sourceforge.net/projects/ledger-smb/
  24. #
  25. # Contributors: Reed White <alta@alta-research.com>
  26. #
  27. # This program is free software; you can redistribute it and/or modify
  28. # it under the terms of the GNU General Public License as published by
  29. # the Free Software Foundation; either version 2 of the License, or
  30. # (at your option) any later version.
  31. #
  32. # This program is distributed in the hope that it will be useful,
  33. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  34. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  35. # GNU General Public License for more details.
  36. # You should have received a copy of the GNU General Public License
  37. # along with this program; if not, write to the Free Software
  38. # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  39. #======================================================================
  40. #
  41. # customer/vendor module
  42. #
  43. #======================================================================
  44. use SL::CT;
  45. 1;
  46. # end of main
  47. sub add {
  48. $form->{title} = "Add";
  49. # $locale->text('Add Customer')
  50. # $locale->text('Add Vendor')
  51. $form->{callback} = "$form->{script}?action=add&db=$form->{db}&path=$form->{path}&login=$form->{login}&sessionid=$form->{sessionid}" 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. } else {
  67. $invlabel = $locale->text('Vendor Invoices');
  68. $ordlabel = $locale->text('Purchase Orders');
  69. $quolabel = $locale->text('Request for Quotations');
  70. }
  71. $form->{title} = $locale->text($label);
  72. $form->{nextsub} = "list_history";
  73. $transactions = qq|
  74. <tr>
  75. <td></td>
  76. <td>
  77. <table>
  78. <tr>
  79. <td>
  80. <table>
  81. <tr>
  82. <td><input name=type type=radio class=radio value=invoice checked> $invlabel</td>
  83. </tr>
  84. <tr>
  85. <td><input name=type type=radio class=radio value=order> $ordlabel</td>
  86. </tr>
  87. <tr>
  88. <td><input name="type" type=radio class=radio value=quotation> $quolabel</td>
  89. </tr>
  90. </table>
  91. </td>
  92. <td>
  93. <table>
  94. <tr>
  95. <th>|.$locale->text('From').qq|</th>
  96. <td><input name=transdatefrom size=11 title="$myconfig{dateformat}"></td>
  97. <th>|.$locale->text('To').qq|</th>
  98. <td><input name=transdateto size=11 title="$myconfig{dateformat}"></td>
  99. </tr>
  100. <tr>
  101. <td></td>
  102. <td colspan=3>
  103. <input name="open" type=checkbox class=checkbox value=Y checked>&nbsp;|.$locale->text('Open').qq|
  104. <input name="closed" type=checkbox class=checkbox value=Y checked>&nbsp;|.$locale->text('Closed').qq|
  105. </td>
  106. </tr>
  107. </table>
  108. </td>
  109. </tr>
  110. </table>
  111. </td>
  112. </tr>
  113. |;
  114. $include = qq|
  115. <tr>
  116. <th align=right nowrap>|.$locale->text('Include in Report').qq|</th>
  117. <td>
  118. <table>
  119. <tr>
  120. <td><input name=history type=radio class=radio value=summary checked> |.$locale->text('Summary').qq|</td>
  121. <td><input name=history type=radio class=radio value=detail> |.$locale->text('Detail').qq|
  122. </td>
  123. </tr>
  124. <tr>
  125. <td>
  126. <input name="l_partnumber" type=checkbox class=checkbox value=Y checked>&nbsp;|.$locale->text('Part Number').qq|
  127. </td>
  128. <td>
  129. <input name="l_description" type=checkbox class=checkbox value=Y checked>&nbsp;|.$locale->text('Description').qq|
  130. </td>
  131. <td>
  132. <input name="l_sellprice" type=checkbox class=checkbox value=Y checked>&nbsp;|.$locale->text('Sell Price').qq|
  133. </td>
  134. <td>
  135. <input name="l_curr" type=checkbox class=checkbox value=Y>&nbsp;|.$locale->text('Currency').qq|
  136. </td>
  137. </tr>
  138. <tr>
  139. <td>
  140. <input name="l_qty" type=checkbox class=checkbox value=Y>&nbsp;|.$locale->text('Qty').qq|
  141. </td>
  142. <td>
  143. <input name="l_unit" type=checkbox class=checkbox value=Y>&nbsp;|.$locale->text('Unit').qq|
  144. </td>
  145. <td>
  146. <input name="l_discount" type=checkbox class=checkbox value=Y>&nbsp;|.$locale->text('Discount').qq|
  147. </td>
  148. <tr>
  149. </tr>
  150. <td>
  151. <input name="l_deliverydate" type=checkbox class=checkbox value=Y>&nbsp;|.$locale->text('Delivery Date').qq|
  152. </td>
  153. <td>
  154. <input name="l_projectnumber" type=checkbox class=checkbox value=Y>&nbsp;|.$locale->text('Project Number').qq|
  155. </td>
  156. <td>
  157. <input name="l_serialnumber" type=checkbox class=checkbox value=Y>&nbsp;|.$locale->text('Serial Number').qq|
  158. </td>
  159. </tr>
  160. </table>
  161. </td>
  162. </tr>
  163. |;
  164. &search_name;
  165. if ($form->{menubar}) {
  166. require "$form->{path}/menu.pl";
  167. &menubar;
  168. }
  169. print qq|
  170. </body>
  171. </html>
  172. |;
  173. }
  174. sub transactions {
  175. if ($form->{db} eq 'customer') {
  176. $translabel = $locale->text('AR Transactions');
  177. $invlabel = $locale->text('Sales Invoices');
  178. $ordlabel = $locale->text('Sales Orders');
  179. $quolabel = $locale->text('Quotations');
  180. } else {
  181. $translabel = $locale->text('AP Transactions');
  182. $invlabel = $locale->text('Vendor Invoices');
  183. $ordlabel = $locale->text('Purchase Orders');
  184. $quolabel = $locale->text('Request for Quotations');
  185. }
  186. $transactions = qq|
  187. <tr>
  188. <td></td>
  189. <td>
  190. <table>
  191. <tr>
  192. <td>
  193. <table>
  194. <tr>
  195. <td><input name="l_transnumber" type=checkbox class=checkbox value=Y> $translabel</td>
  196. </tr>
  197. <tr>
  198. <td><input name="l_invnumber" type=checkbox class=checkbox value=Y> $invlabel</td>
  199. </tr>
  200. <tr>
  201. <td><input name="l_ordnumber" type=checkbox class=checkbox value=Y> $ordlabel</td>
  202. </tr>
  203. <tr>
  204. <td><input name="l_quonumber" type=checkbox class=checkbox value=Y> $quolabel</td>
  205. </tr>
  206. </table>
  207. </td>
  208. <td>
  209. <table>
  210. <tr>
  211. <th>|.$locale->text('From').qq|</th>
  212. <td><input name=transdatefrom size=11 title="$myconfig{dateformat}"></td>
  213. <th>|.$locale->text('To').qq|</th>
  214. <td><input name=transdateto size=11 title="$myconfig{dateformat}"></td>
  215. </tr>
  216. <tr>
  217. <td></td>
  218. <td colspan=3>
  219. <input name="open" type=checkbox class=checkbox value=Y checked>&nbsp;|.$locale->text('Open').qq|
  220. <input name="closed" type=checkbox class=checkbox value=Y checked>&nbsp;|.$locale->text('Closed').qq|
  221. </td>
  222. </tr>
  223. <tr>
  224. <td></td>
  225. <td colspan=3>
  226. <input name="l_amount" type=checkbox class=checkbox value=Y checked>&nbsp;|.$locale->text('Amount').qq|
  227. <input name="l_tax" type=checkbox class=checkbox value=Y checked>&nbsp;|.$locale->text('Tax').qq|
  228. <input name="l_total" type=checkbox class=checkbox value=Y checked>&nbsp;|.$locale->text('Total').qq|
  229. <input name="l_subtotal" type=checkbox class=checkbox value=Y>&nbsp;|.$locale->text('Subtotal').qq|
  230. </td>
  231. </tr>
  232. </table>
  233. </td>
  234. </tr>
  235. </table>
  236. </td>
  237. </tr>
  238. |;
  239. }
  240. sub include_in_report {
  241. $label = ucfirst $form->{db};
  242. @a = ();
  243. push @a, qq|<input name="l_ndx" type=checkbox class=checkbox value=Y> |.$locale->text('No.');
  244. push @a, qq|<input name="l_id" type=checkbox class=checkbox value=Y> |.$locale->text('ID');
  245. push @a, qq|<input name="l_$form->{db}number" type=checkbox class=checkbox value=Y> |.$locale->text($label . ' Number');
  246. push @a, qq|<input name="l_name" type=checkbox class=checkbox value=Y $form->{l_name}> |.$locale->text('Company Name');
  247. push @a, qq|<input name="l_contact" type=checkbox class=checkbox value=Y $form->{l_contact}> |.$locale->text('Contact');
  248. push @a, qq|<input name="l_email" type=checkbox class=checkbox value=Y $form->{l_email}> |.$locale->text('E-mail');
  249. push @a, qq|<input name="l_address" type=checkbox class=checkbox value=Y> |.$locale->text('Address');
  250. push @a, qq|<input name="l_city" type=checkbox class=checkbox value=Y> |.$locale->text('City');
  251. push @a, qq|<input name="l_state" type=checkbox class=checkbox value=Y> |.$locale->text('State/Province');
  252. push @a, qq|<input name="l_zipcode" type=checkbox class=checkbox value=Y> |.$locale->text('Zip/Postal Code');
  253. push @a, qq|<input name="l_country" type=checkbox class=checkbox value=Y> |.$locale->text('Country');
  254. push @a, qq|<input name="l_phone" type=checkbox class=checkbox value=Y $form->{l_phone}> |.$locale->text('Phone');
  255. push @a, qq|<input name="l_fax" type=checkbox class=checkbox value=Y> |.$locale->text('Fax');
  256. push @a, qq|<input name="l_cc" type=checkbox class=checkbox value=Y> |.$locale->text('Cc');
  257. if ($myconfig{role} =~ /(admin|manager)/) {
  258. push @a, qq|<input name="l_bcc" type=checkbox class=checkbox value=Y> |.$locale->text('Bcc');
  259. }
  260. push @a, qq|<input name="l_notes" type=checkbox class=checkbox value=Y> |.$locale->text('Notes');
  261. push @a, qq|<input name="l_discount" type=checkbox class=checkbox value=Y> |.$locale->text('Discount');
  262. push @a, qq|<input name="l_taxaccount" type=checkbox class=checkbox value=Y> |.$locale->text('Tax Account');
  263. push @a, qq|<input name="l_taxnumber" type=checkbox class=checkbox value=Y> |.$locale->text('Tax Number');
  264. if ($form->{db} eq 'customer') {
  265. push @a, qq|<input name="l_employee" type=checkbox class=checkbox value=Y> |.$locale->text('Salesperson');
  266. push @a, qq|<input name="l_manager" type=checkbox class=checkbox value=Y> |.$locale->text('Manager');
  267. push @a, qq|<input name="l_pricegroup" type=checkbox class=checkbox value=Y> |.$locale->text('Pricegroup');
  268. } else {
  269. push @a, qq|<input name="l_employee" type=checkbox class=checkbox value=Y> |.$locale->text('Employee');
  270. push @a, qq|<input name="l_manager" type=checkbox class=checkbox value=Y> |.$locale->text('Manager');
  271. push @a, qq|<input name="l_gifi_accno" type=checkbox class=checkbox value=Y> |.$locale->text('GIFI');
  272. }
  273. push @a, qq|<input name="l_sic_code" type=checkbox class=checkbox value=Y> |.$locale->text('SIC');
  274. push @a, qq|<input name="l_iban" type=checkbox class=checkbox value=Y> |.$locale->text('IBAN');
  275. push @a, qq|<input name="l_bic" type=checkbox class=checkbox value=Y> |.$locale->text('BIC');
  276. push @a, qq|<input name="l_business" type=checkbox class=checkbox value=Y> |.$locale->text('Type of Business');
  277. push @a, qq|<input name="l_terms" type=checkbox class=checkbox value=Y> |.$locale->text('Terms');
  278. push @a, qq|<input name="l_language" type=checkbox class=checkbox value=Y> |.$locale->text('Language');
  279. push @a, qq|<input name="l_startdate" type=checkbox class=checkbox value=Y> |.$locale->text('Startdate');
  280. push @a, qq|<input name="l_enddate" type=checkbox class=checkbox value=Y> |.$locale->text('Enddate');
  281. $include = qq|
  282. <tr>
  283. <th align=right nowrap>|.$locale->text('Include in Report').qq|</th>
  284. <td>
  285. <table>
  286. |;
  287. while (@a) {
  288. $include .= qq|<tr>\n|;
  289. for (1 .. 5) {
  290. $include .= qq|<td nowrap>|. shift @a;
  291. $include .= qq|</td>\n|;
  292. }
  293. $include .= qq|</tr>\n|;
  294. }
  295. $include .= qq|
  296. </table>
  297. </td>
  298. </tr>
  299. |;
  300. }
  301. sub search {
  302. # $locale->text('Customers')
  303. # $locale->text('Vendors')
  304. $form->{title} = $locale->text('Search') unless $form->{title};
  305. for (qw(name contact phone email)) { $form->{"l_$_"} = 'checked' }
  306. $form->{nextsub} = "list_names";
  307. $orphan = qq|
  308. <tr>
  309. <td></td>
  310. <td><input name=status class=radio type=radio value=all checked>&nbsp;|.$locale->text('All').qq|
  311. <input name=status class=radio type=radio value=active>&nbsp;|.$locale->text('Active').qq|
  312. <input name=status class=radio type=radio value=inactive>&nbsp;|.$locale->text('Inactive').qq|
  313. <input name=status class=radio type=radio value=orphaned>&nbsp;|.$locale->text('Orphaned').qq|</td>
  314. </tr>
  315. |;
  316. &transactions;
  317. &include_in_report;
  318. &search_name;
  319. if ($form->{menubar}) {
  320. require "$form->{path}/menu.pl";
  321. &menubar;
  322. }
  323. print qq|
  324. </body>
  325. </html>
  326. |;
  327. }
  328. sub search_name {
  329. $label = ucfirst $form->{db};
  330. if ($form->{db} eq 'customer') {
  331. $employee = qq|
  332. <th align=right nowrap>|.$locale->text('Salesperson').qq|</th>
  333. <td><input name=employee size=32></td>
  334. |;
  335. }
  336. if ($form->{db} eq 'vendor') {
  337. $employee = qq|
  338. <th align=right nowrap>|.$locale->text('Employee').qq|</th>
  339. <td><input name=employee size=32></td>
  340. |;
  341. }
  342. $form->header;
  343. print qq|
  344. <body>
  345. <form method=post action=$form->{script}>
  346. <input type=hidden name=db value=$form->{db}>
  347. <table width=100%>
  348. <tr>
  349. <th class=listtop>$form->{title}</th>
  350. </tr>
  351. <tr height="5"></tr>
  352. <tr valign=top>
  353. <td>
  354. <table>
  355. <tr valign=top>
  356. <td>
  357. <table>
  358. <tr>
  359. <th align=right nowrap>|.$locale->text('Company Name').qq|</th>
  360. <td><input name=name size=32></td>
  361. </tr>
  362. <tr>
  363. <th align=right nowrap>|.$locale->text('Contact').qq|</th>
  364. <td><input name=contact size=32></td>
  365. </tr>
  366. <tr>
  367. <th align=right nowrap>|.$locale->text('E-mail').qq|</th>
  368. <td><input name=email size=32></td>
  369. </tr>
  370. <tr>
  371. <th align=right nowrap>|.$locale->text('Phone').qq|</th>
  372. <td><input name=phone size=20></td>
  373. </tr>
  374. <tr>
  375. $employee
  376. </tr>
  377. <tr>
  378. <th align=right nowrap>|.$locale->text('Notes').qq|</th>
  379. <td colspan=3><textarea name=notes rows=3 cols=32></textarea></td>
  380. </tr>
  381. </table>
  382. </td>
  383. <td>
  384. <table>
  385. <tr>
  386. <th align=right nowrap>|.$locale->text($label . ' Number').qq|</th>
  387. <td><input name=$form->{db}number size=32></td>
  388. </tr>
  389. <tr>
  390. <th align=right nowrap>|.$locale->text('Address').qq|</th>
  391. <td><input name=address size=32></td>
  392. </tr>
  393. <tr>
  394. <th align=right nowrap>|.$locale->text('City').qq|</th>
  395. <td><input name=city size=32></td>
  396. </tr>
  397. <tr>
  398. <th align=right nowrap>|.$locale->text('State/Province').qq|</th>
  399. <td><input name=state size=32></td>
  400. </tr>
  401. <tr>
  402. <th align=right nowrap>|.$locale->text('Zip/Postal Code').qq|</th>
  403. <td><input name=zipcode size=10></td>
  404. </tr>
  405. <tr>
  406. <th align=right nowrap>|.$locale->text('Country').qq|</th>
  407. <td><input name=country size=32></td>
  408. </tr>
  409. <tr>
  410. <th align=right nowrap>|.$locale->text('Startdate').qq|</th>
  411. <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>
  412. </tr>
  413. </table>
  414. </td>
  415. </tr>
  416. </table>
  417. </td>
  418. </tr>
  419. <tr>
  420. <td>
  421. <table>
  422. $orphan
  423. $transactions
  424. $include
  425. </table>
  426. </td>
  427. </tr>
  428. <tr>
  429. <td><hr size=3 noshade></td>
  430. </tr>
  431. </table>
  432. <input type=hidden name=nextsub value=$form->{nextsub}>
  433. <input type=hidden name=path value=$form->{path}>
  434. <input type=hidden name=login value=$form->{login}>
  435. <input type=hidden name=sessionid value=$form->{sessionid}>
  436. <br>
  437. <input type=submit class=submit name=action value="|.$locale->text('Continue').qq|">
  438. </form>
  439. |;
  440. }
  441. sub list_names {
  442. CT->search(\%myconfig, \%$form);
  443. $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}";
  444. $form->sort_order();
  445. $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}";
  446. @columns = $form->sort_columns(id, name, "$form->{db}number", address,
  447. city, state, zipcode, country, contact,
  448. phone, fax, email, cc, bcc, employee,
  449. manager, notes, discount, terms,
  450. taxaccount, taxnumber, gifi_accno, sic_code, business,
  451. pricegroup, language, iban, bic,
  452. startdate, enddate,
  453. invnumber, invamount, invtax, invtotal,
  454. ordnumber, ordamount, ordtax, ordtotal,
  455. quonumber, quoamount, quotax, quototal);
  456. unshift @columns, "ndx";
  457. $form->{l_invnumber} = "Y" if $form->{l_transnumber};
  458. foreach $item (qw(inv ord quo)) {
  459. if ($form->{"l_${item}number"}) {
  460. for (qw(amount tax total)) { $form->{"l_$item$_"} = $form->{"l_$_"} }
  461. $removeemployee = 1;
  462. $openclosed = 1;
  463. }
  464. }
  465. $form->{open} = $form->{closed} = "" if !$openclosed;
  466. foreach $item (@columns) {
  467. if ($form->{"l_$item"} eq "Y") {
  468. push @column_index, $item;
  469. # add column to href and callback
  470. $callback .= "&l_$item=Y";
  471. $href .= "&l_$item=Y";
  472. }
  473. }
  474. foreach $item (qw(amount tax total transnumber)) {
  475. if ($form->{"l_$item"} eq "Y") {
  476. $callback .= "&l_$item=Y";
  477. $href .= "&l_$item=Y";
  478. }
  479. }
  480. if ($form->{status} eq 'all') {
  481. $option = $locale->text('All');
  482. }
  483. if ($form->{status} eq 'orphaned') {
  484. $option = $locale->text('Orphaned');
  485. }
  486. if ($form->{status} eq 'active') {
  487. $option = $locale->text('Active');
  488. }
  489. if ($form->{status} eq 'inactive') {
  490. $option = $locale->text('Inactive');
  491. }
  492. if ($form->{name}) {
  493. $callback .= "&name=".$form->escape($form->{name},1);
  494. $href .= "&name=".$form->escape($form->{name});
  495. $option .= "\n<br>".$locale->text('Name')." : $form->{name}";
  496. }
  497. if ($form->{address}) {
  498. $callback .= "&address=".$form->escape($form->{address},1);
  499. $href .= "&address=".$form->escape($form->{address});
  500. $option .= "\n<br>".$locale->text('Address')." : $form->{address}";
  501. }
  502. if ($form->{city}) {
  503. $callback .= "&city=".$form->escape($form->{city},1);
  504. $href .= "&city=".$form->escape($form->{city});
  505. $option .= "\n<br>".$locale->text('City')." : $form->{city}";
  506. }
  507. if ($form->{state}) {
  508. $callback .= "&state=".$form->escape($form->{state},1);
  509. $href .= "&state=".$form->escape($form->{state});
  510. $option .= "\n<br>".$locale->text('State')." : $form->{state}";
  511. }
  512. if ($form->{zipcode}) {
  513. $callback .= "&zipcode=".$form->escape($form->{zipcode},1);
  514. $href .= "&zipcode=".$form->escape($form->{zipcode});
  515. $option .= "\n<br>".$locale->text('Zip/Postal Code')." : $form->{zipcode}";
  516. }
  517. if ($form->{country}) {
  518. $callback .= "&country=".$form->escape($form->{country},1);
  519. $href .= "&country=".$form->escape($form->{country});
  520. $option .= "\n<br>".$locale->text('Country')." : $form->{country}";
  521. }
  522. if ($form->{contact}) {
  523. $callback .= "&contact=".$form->escape($form->{contact},1);
  524. $href .= "&contact=".$form->escape($form->{contact});
  525. $option .= "\n<br>".$locale->text('Contact')." : $form->{contact}";
  526. }
  527. if ($form->{employee}) {
  528. $callback .= "&employee=".$form->escape($form->{employee},1);
  529. $href .= "&employee=".$form->escape($form->{employee});
  530. $option .= "\n<br>";
  531. if ($form->{db} eq 'customer') {
  532. $option .= $locale->text('Salesperson');
  533. }
  534. if ($form->{db} eq 'vendor') {
  535. $option .= $locale->text('Employee');
  536. }
  537. $option .= " : $form->{employee}";
  538. }
  539. $fromdate = "";
  540. $todate = "";
  541. if ($form->{startdatefrom}) {
  542. $callback .= "&startdatefrom=$form->{startdatefrom}";
  543. $href .= "&startdatefrom=$form->{startdatefrom}";
  544. $fromdate = $locale->date(\%myconfig, $form->{startdatefrom}, 1);
  545. }
  546. if ($form->{startdateto}) {
  547. $callback .= "&startdateto=$form->{startdateto}";
  548. $href .= "&startdateto=$form->{startdateto}";
  549. $todate = $locale->date(\%myconfig, $form->{startdateto}, 1);
  550. }
  551. if ($fromdate || $todate) {
  552. $option .= "\n<br>".$locale->text('Startdate')." $fromdate - $todate";
  553. }
  554. if ($form->{notes}) {
  555. $callback .= "&notes=".$form->escape($form->{notes},1);
  556. $href .= "&notes=".$form->escape($form->{notes});
  557. $option .= "\n<br>".$locale->text('Notes')." : $form->{notes}";
  558. }
  559. if ($form->{"$form->{db}number"}) {
  560. $callback .= qq|&$form->{db}number=|.$form->escape($form->{"$form->{db}number"},1);
  561. $href .= "&$form->{db}number=".$form->escape($form->{"$form->{db}number"});
  562. $option .= "\n<br>".$locale->text('Number').qq| : $form->{"$form->{db}number"}|;
  563. }
  564. if ($form->{phone}) {
  565. $callback .= "&phone=".$form->escape($form->{phone},1);
  566. $href .= "&phone=".$form->escape($form->{phone});
  567. $option .= "\n<br>".$locale->text('Phone')." : $form->{phone}";
  568. }
  569. if ($form->{email}) {
  570. $callback .= "&email=".$form->escape($form->{email},1);
  571. $href .= "&email=".$form->escape($form->{email});
  572. $option .= "\n<br>".$locale->text('E-mail')." : $form->{email}";
  573. }
  574. if ($form->{transdatefrom}) {
  575. $callback .= "&transdatefrom=$form->{transdatefrom}";
  576. $href .= "&transdatefrom=$form->{transdatefrom}";
  577. $option .= "\n<br>" if ($option);
  578. $option .= $locale->text('From')."&nbsp;".$locale->date(\%myconfig, $form->{transdatefrom}, 1);
  579. }
  580. if ($form->{transdateto}) {
  581. $callback .= "&transdateto=$form->{transdateto}";
  582. $href .= "&transdateto=$form->{transdateto}";
  583. if ($form->{transdatefrom}) {
  584. $option .= " ";
  585. } else {
  586. $option .= "\n<br>" if ($option);
  587. }
  588. $option .= $locale->text('To')."&nbsp;".$locale->date(\%myconfig, $form->{transdateto}, 1);
  589. }
  590. if ($form->{open}) {
  591. $callback .= "&open=$form->{open}";
  592. $href .= "&open=$form->{open}";
  593. $option .= "\n<br>" if ($option);
  594. $option .= $locale->text('Open');
  595. }
  596. if ($form->{closed}) {
  597. $callback .= "&closed=$form->{closed}";
  598. $href .= "&closed=$form->{closed}";
  599. $option .= "\n<br>" if ($option);
  600. $option .= $locale->text('Closed');
  601. }
  602. $form->{callback} = "$callback&sort=$form->{sort}";
  603. $callback = $form->escape($form->{callback});
  604. $column_header{ndx} = qq|<th class=listheading>&nbsp;</th>|;
  605. $column_header{id} = qq|<th class=listheading>|.$locale->text('ID').qq|</th>|;
  606. $column_header{"$form->{db}number"} = qq|<th><a class=listheading href=$href&sort=$form->{db}number>|.$locale->text('Number').qq|</a></th>|;
  607. $column_header{name} = qq|<th><a class=listheading href=$href&sort=name>|.$locale->text('Name').qq|</a></th>|;
  608. $column_header{address} = qq|<th class=listheading>|.$locale->text('Address').qq|</th>|;
  609. $column_header{city} = qq|<th><a class=listheading href=$href&sort=city>|.$locale->text('City').qq|</a></th>|;
  610. $column_header{state} = qq|<th><a class=listheading href=$href&sort=state>|.$locale->text('State/Province').qq|</a></th>|;
  611. $column_header{zipcode} = qq|<th><a class=listheading href=$href&sort=zipcode>|.$locale->text('Zip/Postal Code').qq|</a></th>|;
  612. $column_header{country} = qq|<th><a class=listheading href=$href&sort=country>|.$locale->text('Country').qq|</a></th>|;
  613. $column_header{contact} = qq|<th><a class=listheading href=$href&sort=contact>|.$locale->text('Contact').qq|</a></th>|;
  614. $column_header{phone} = qq|<th><a class=listheading href=$href&sort=phone>|.$locale->text('Phone').qq|</a></th>|;
  615. $column_header{fax} = qq|<th><a class=listheading href=$href&sort=fax>|.$locale->text('Fax').qq|</a></th>|;
  616. $column_header{email} = qq|<th><a class=listheading href=$href&sort=email>|.$locale->text('E-mail').qq|</a></th>|;
  617. $column_header{cc} = qq|<th><a class=listheading href=$href&sort=cc>|.$locale->text('Cc').qq|</a></th>|;
  618. $column_header{bcc} = qq|<th><a class=listheading href=$href&sort=cc>|.$locale->text('Bcc').qq|</a></th>|;
  619. $column_header{notes} = qq|<th><a class=listheading href=$href&sort=notes>|.$locale->text('Notes').qq|</a></th>|;
  620. $column_header{discount} = qq|<th class=listheading>%</th>|;
  621. $column_header{terms} = qq|<th class=listheading>|.$locale->text('Terms').qq|</th>|;
  622. $column_header{taxnumber} = qq|<th><a class=listheading href=$href&sort=taxnumber>|.$locale->text('Tax Number').qq|</a></th>|;
  623. $column_header{taxaccount} = qq|<th class=listheading>|.$locale->text('Tax Account').qq|</th>|;
  624. $column_header{gifi_accno} = qq|<th><a class=listheading href=$href&sort=gifi_accno>|.$locale->text('GIFI').qq|</a></th>|;
  625. $column_header{sic_code} = qq|<th><a class=listheading href=$href&sort=sic_code>|.$locale->text('SIC').qq|</a></th>|;
  626. $column_header{business} = qq|<th><a class=listheading href=$href&sort=business>|.$locale->text('Type of Business').qq|</a></th>|;
  627. $column_header{iban} = qq|<th class=listheading>|.$locale->text('IBAN').qq|</th>|;
  628. $column_header{bic} = qq|<th class=listheading>|.$locale->text('BIC').qq|</th>|;
  629. $column_header{startdate} = qq|<th><a class=listheading href=$href&sort=startdate>|.$locale->text('Startdate').qq|</a></th>|;
  630. $column_header{enddate} = qq|<th><a class=listheading href=$href&sort=enddate>|.$locale->text('Enddate').qq|</a></th>|;
  631. $column_header{invnumber} = qq|<th><a class=listheading href=$href&sort=invnumber>|.$locale->text('Invoice').qq|</a></th>|;
  632. $column_header{ordnumber} = qq|<th><a class=listheading href=$href&sort=ordnumber>|.$locale->text('Order').qq|</a></th>|;
  633. $column_header{quonumber} = qq|<th><a class=listheading href=$href&sort=quonumber>|.$locale->text('Quotation').qq|</a></th>|;
  634. if ($form->{db} eq 'customer') {
  635. $column_header{employee} = qq|<th><a class=listheading href=$href&sort=employee>|.$locale->text('Salesperson').qq|</a></th>|;
  636. } else {
  637. $column_header{employee} = qq|<th><a class=listheading href=$href&sort=employee>|.$locale->text('Employee').qq|</a></th>|;
  638. }
  639. $column_header{manager} = qq|<th><a class=listheading href=$href&sort=manager>|.$locale->text('Manager').qq|</a></th>|;
  640. $column_header{pricegroup} = qq|<th><a class=listheading href=$href&sort=pricegroup>|.$locale->text('Pricegroup').qq|</a></th>|;
  641. $column_header{language} = qq|<th><a class=listheading href=$href&sort=language>|.$locale->text('Language').qq|</a></th>|;
  642. $amount = $locale->text('Amount');
  643. $tax = $locale->text('Tax');
  644. $total = $locale->text('Total');
  645. $column_header{invamount} = qq|<th class=listheading>$amount</th>|;
  646. $column_header{ordamount} = qq|<th class=listheading>$amount</th>|;
  647. $column_header{quoamount} = qq|<th class=listheading>$amount</th>|;
  648. $column_header{invtax} = qq|<th class=listheading>$tax</th>|;
  649. $column_header{ordtax} = qq|<th class=listheading>$tax</th>|;
  650. $column_header{quotax} = qq|<th class=listheading>$tax</th>|;
  651. $column_header{invtotal} = qq|<th class=listheading>$total</th>|;
  652. $column_header{ordtotal} = qq|<th class=listheading>$total</th>|;
  653. $column_header{quototal} = qq|<th class=listheading>$total</th>|;
  654. if ($form->{status}) {
  655. $label = ucfirst $form->{db}."s";
  656. $form->{title} = $locale->text($label);
  657. } else {
  658. $label = ucfirst $form->{db};
  659. $form->{title} = $locale->text($label ." Transactions");
  660. }
  661. $form->header;
  662. print qq|
  663. <body>
  664. <table width=100%>
  665. <tr>
  666. <th class=listtop>$form->{title}</th>
  667. </tr>
  668. <tr height="5"></tr>
  669. <tr>
  670. <td>$option</td>
  671. </tr>
  672. <tr>
  673. <td>
  674. <table width=100%>
  675. <tr class=listheading>
  676. |;
  677. for (@column_index) { print "$column_header{$_}\n" }
  678. print qq|
  679. </tr>
  680. |;
  681. $ordertype = ($form->{db} eq 'customer') ? 'sales_order' : 'purchase_order';
  682. $quotationtype = ($form->{db} eq 'customer') ? 'sales_quotation' : 'request_quotation';
  683. $subtotal = 0;
  684. $i = 0;
  685. foreach $ref (@{ $form->{CT} }) {
  686. if ($ref->{$form->{sort}} ne $sameitem && $form->{l_subtotal}) {
  687. # print subtotal
  688. if ($subtotal) {
  689. for (@column_index) { $column_data{$_} = "<td>&nbsp;</td>" }
  690. &list_subtotal;
  691. }
  692. }
  693. if ($ref->{id} eq $sameid) {
  694. for (@column_index) { $column_data{$_} = "<td>&nbsp;</td>" }
  695. } else {
  696. $i++;
  697. $ref->{notes} =~ s/\r?\n/<br>/g;
  698. for (@column_index) { $column_data{$_} = "<td>$ref->{$_}&nbsp;</td>" }
  699. $column_data{ndx} = "<td align=right>$i</td>";
  700. if ($ref->{$form->{sort}} eq $sameitem) {
  701. $column_data{$form->{sort}} = "<td>&nbsp;</td>";
  702. }
  703. $column_data{address} = "<td>$ref->{address1} $ref->{address2}&nbsp;</td>";
  704. $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>";
  705. $email = "";
  706. if ($form->{sort} =~ /(email|cc)/) {
  707. if ($ref->{$form->{sort}} ne $sameitem) {
  708. $email = 1;
  709. }
  710. } else {
  711. $email = 1;
  712. }
  713. if ($email) {
  714. foreach $item (qw(email cc bcc)) {
  715. if ($ref->{$item}) {
  716. $email = $ref->{$item};
  717. $email =~ s/</\&lt;/;
  718. $email =~ s/>/\&gt;/;
  719. $column_data{$item} = qq|<td><a href="mailto:$ref->{$item}">$email</a></td>|;
  720. }
  721. }
  722. }
  723. }
  724. if ($ref->{formtype} eq 'invoice') {
  725. $column_data{invnumber} = "<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>";
  726. $column_data{invamount} = "<td align=right>".$form->format_amount(\%myconfig, $ref->{netamount}, 2, "&nbsp;")."</td>";
  727. $column_data{invtax} = "<td align=right>".$form->format_amount(\%myconfig, $ref->{amount} - $ref->{netamount}, 2, "&nbsp;")."</td>";
  728. $column_data{invtotal} = "<td align=right>".$form->format_amount(\%myconfig, $ref->{amount}, 2, "&nbsp;")."</td>";
  729. $invamountsubtotal += $ref->{netamount};
  730. $invtaxsubtotal += ($ref->{amount} - $ref->{netamount});
  731. $invtotalsubtotal += $ref->{amount};
  732. $subtotal = 1;
  733. }
  734. if ($ref->{formtype} eq 'order') {
  735. $column_data{ordnumber} = "<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>";
  736. $column_data{ordamount} = "<td align=right>".$form->format_amount(\%myconfig, $ref->{netamount}, 2, "&nbsp;")."</td>";
  737. $column_data{ordtax} = "<td align=right>".$form->format_amount(\%myconfig, $ref->{amount} - $ref->{netamount}, 2, "&nbsp;")."</td>";
  738. $column_data{ordtotal} = "<td align=right>".$form->format_amount(\%myconfig, $ref->{amount}, 2, "&nbsp;")."</td>";
  739. $ordamountsubtotal += $ref->{netamount};
  740. $ordtaxsubtotal += ($ref->{amount} - $ref->{netamount});
  741. $ordtotalsubtotal += $ref->{amount};
  742. $subtotal = 1;
  743. }
  744. if ($ref->{formtype} eq 'quotation') {
  745. $column_data{quonumber} = "<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>";
  746. $column_data{quoamount} = "<td align=right>".$form->format_amount(\%myconfig, $ref->{netamount}, 2, "&nbsp;")."</td>";
  747. $column_data{quotax} = "<td align=right>".$form->format_amount(\%myconfig, $ref->{amount} - $ref->{netamount}, 2, "&nbsp;")."</td>";
  748. $column_data{quototal} = "<td align=right>".$form->format_amount(\%myconfig, $ref->{amount}, 2, "&nbsp;")."</td>";
  749. $quoamountsubtotal += $ref->{netamount};
  750. $quotaxsubtotal += ($ref->{amount} - $ref->{netamount});
  751. $quototalsubtotal += $ref->{amount};
  752. $subtotal = 1;
  753. }
  754. if ($sameid ne "$ref->{id}") {
  755. if ($form->{l_discount}) {
  756. $column_data{discount} = "<td align=right>".$form->format_amount(\%myconfig, $ref->{discount} * 100, "", "&nbsp;")."</td>";
  757. }
  758. if ($form->{l_terms}) {
  759. $column_data{terms} = "<td align=right>".$form->format_amount(\%myconfig, $ref->{terms}, "", "&nbsp;")."</td>";
  760. }
  761. }
  762. $j++; $j %= 2;
  763. print "
  764. <tr class=listrow$j>
  765. ";
  766. for (@column_index) { print "$column_data{$_}\n" }
  767. print qq|
  768. </tr>
  769. |;
  770. $sameitem = "$ref->{$form->{sort}}";
  771. $sameid = $ref->{id};
  772. }
  773. if ($form->{l_subtotal} && $subtotal) {
  774. for (@column_index) { $column_data{$_} = "<td>&nbsp;</td>" }
  775. &list_subtotal;
  776. }
  777. $i = 1;
  778. if ($myconfig{acs} !~ /AR--AR/) {
  779. if ($form->{db} eq 'customer') {
  780. $button{'AR--Customers--Add Customer'}{code} = qq|<input class=submit type=submit name=action value="|.$locale->text('Add Customer').qq|"> |;
  781. $button{'AR--Customers--Add Customer'}{order} = $i++;
  782. }
  783. }
  784. if ($myconfig{acs} !~ /AP--AP/) {
  785. if ($form->{db} eq 'vendor') {
  786. $button{'AP--Vendors--Add Vendor'}{code} = qq|<input class=submit type=submit name=action value="|.$locale->text('Add Vendor').qq|"> |;
  787. $button{'AP--Vendors--Add Vendor'}{order} = $i++;
  788. }
  789. }
  790. foreach $item (split /;/, $myconfig{acs}) {
  791. delete $button{$item};
  792. }
  793. print qq|
  794. </table>
  795. </td>
  796. </tr>
  797. <tr>
  798. <td><hr size=3 noshade></td>
  799. </tr>
  800. </table>
  801. <br>
  802. <form method=post action=$form->{script}>
  803. |;
  804. $form->hide_form(qw(callback db path login sessionid));
  805. if ($form->{status}) {
  806. foreach $item (sort { $a->{order} <=> $b->{order} } %button) {
  807. print $item->{code};
  808. }
  809. }
  810. if ($form->{menubar}) {
  811. require "$form->{path}/menu.pl";
  812. &menubar;
  813. }
  814. print qq|
  815. </form>
  816. </body>
  817. </html>
  818. |;
  819. }
  820. sub list_subtotal {
  821. $column_data{invamount} = "<td align=right>".$form->format_amount(\%myconfig, $invamountsubtotal, 2, "&nbsp;")."</td>";
  822. $column_data{invtax} = "<td align=right>".$form->format_amount(\%myconfig, $invtaxsubtotal, 2, "&nbsp;")."</td>";
  823. $column_data{invtotal} = "<td align=right>".$form->format_amount(\%myconfig, $invtotalsubtotal, 2, "&nbsp;")."</td>";
  824. $invamountsubtotal = 0;
  825. $invtaxsubtotal = 0;
  826. $invtotalsubtotal = 0;
  827. $column_data{ordamount} = "<td align=right>".$form->format_amount(\%myconfig, $ordamountsubtotal, 2, "&nbsp;")."</td>";
  828. $column_data{ordtax} = "<td align=right>".$form->format_amount(\%myconfig, $ordtaxsubtotal, 2, "&nbsp;")."</td>";
  829. $column_data{ordtotal} = "<td align=right>".$form->format_amount(\%myconfig, $ordtotalsubtotal, 2, "&nbsp;")."</td>";
  830. $ordamountsubtotal = 0;
  831. $ordtaxsubtotal = 0;
  832. $ordtotalsubtotal = 0;
  833. $column_data{quoamount} = "<td align=right>".$form->format_amount(\%myconfig, $quoamountsubtotal, 2, "&nbsp;")."</td>";
  834. $column_data{quotax} = "<td align=right>".$form->format_amount(\%myconfig, $quotaxsubtotal, 2, "&nbsp;")."</td>";
  835. $column_data{quototal} = "<td align=right>".$form->format_amount(\%myconfig, $quototalsubtotal, 2, "&nbsp;")."</td>";
  836. $quoamountsubtotal = 0;
  837. $quotaxsubtotal = 0;
  838. $quototalsubtotal = 0;
  839. print "
  840. <tr class=listsubtotal>
  841. ";
  842. for (@column_index) { print "$column_data{$_}\n" }
  843. print qq|
  844. </tr>
  845. |;
  846. }
  847. sub list_history {
  848. CT->get_history(\%myconfig, \%$form);
  849. $href = "$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}";
  850. $form->sort_order();
  851. $callback = "$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}";
  852. $form->{l_fxsellprice} = $form->{l_curr};
  853. @columns = $form->sort_columns(partnumber, description, qty, unit, sellprice, fxsellprice, curr, discount, deliverydate, projectnumber, serialnumber);
  854. if ($form->{history} eq 'summary') {
  855. @columns = $form->sort_columns(partnumber, description, qty, unit, sellprice, curr);
  856. }
  857. foreach $item (@columns) {
  858. if ($form->{"l_$item"} eq "Y") {
  859. push @column_index, $item;
  860. # add column to href and callback
  861. $callback .= "&l_$item=Y";
  862. $href .= "&l_$item=Y";
  863. }
  864. }
  865. if ($form->{history} eq 'detail') {
  866. $option = $locale->text('Detail');
  867. }
  868. if ($form->{history} eq 'summary') {
  869. $option .= $locale->text('Summary');
  870. }
  871. if ($form->{name}) {
  872. $callback .= "&name=".$form->escape($form->{name},1);
  873. $href .= "&name=".$form->escape($form->{name});
  874. $option .= "\n<br>".$locale->text('Name')." : $form->{name}";
  875. }
  876. if ($form->{contact}) {
  877. $callback .= "&contact=".$form->escape($form->{contact},1);
  878. $href .= "&contact=".$form->escape($form->{contact});
  879. $option .= "\n<br>".$locale->text('Contact')." : $form->{contact}";
  880. }
  881. if ($form->{"$form->{db}number"}) {
  882. $callback .= qq|&$form->{db}number=|.$form->escape($form->{"$form->{db}number"},1);
  883. $href .= "&$form->{db}number=".$form->escape($form->{"$form->{db}number"});
  884. $option .= "\n<br>".$locale->text('Number').qq| : $form->{"$form->{db}number"}|;
  885. }
  886. if ($form->{email}) {
  887. $callback .= "&email=".$form->escape($form->{email},1);
  888. $href .= "&email=".$form->escape($form->{email});
  889. $option .= "\n<br>".$locale->text('E-mail')." : $form->{email}";
  890. }
  891. if ($form->{transdatefrom}) {
  892. $callback .= "&transdatefrom=$form->{transdatefrom}";
  893. $href .= "&transdatefrom=$form->{transdatefrom}";
  894. $option .= "\n<br>" if ($option);
  895. $option .= $locale->text('From')."&nbsp;".$locale->date(\%myconfig, $form->{transdatefrom}, 1);
  896. }
  897. if ($form->{transdateto}) {
  898. $callback .= "&transdateto=$form->{transdateto}";
  899. $href .= "&transdateto=$form->{transdateto}";
  900. if ($form->{transdatefrom}) {
  901. $option .= " ";
  902. } else {
  903. $option .= "\n<br>" if ($option);
  904. }
  905. $option .= $locale->text('To')."&nbsp;".$locale->date(\%myconfig, $form->{transdateto}, 1);
  906. }
  907. if ($form->{open}) {
  908. $callback .= "&open=$form->{open}";
  909. $href .= "&open=$form->{open}";
  910. $option .= "\n<br>" if ($option);
  911. $option .= $locale->text('Open');
  912. }
  913. if ($form->{closed}) {
  914. $callback .= "&closed=$form->{closed}";
  915. $href .= "&closed=$form->{closed}";
  916. $option .= "\n<br>" if ($option);
  917. $option .= $locale->text('Closed');
  918. }
  919. $form->{callback} = "$callback&sort=$form->{sort}";
  920. $callback = $form->escape($form->{callback});
  921. $column_header{partnumber} = qq|<th><a class=listheading href=$href&sort=partnumber>|.$locale->text('Part Number').qq|</a></th>|;
  922. $column_header{description} = qq|<th><a class=listheading href=$href&sort=description>|.$locale->text('Description').qq|</a></th>|;
  923. if ($form->{history} eq 'summary') {
  924. $column_header{sellprice} = qq|<th class=listheading>|.$locale->text('Total').qq|</th>|;
  925. } else {
  926. $column_header{sellprice} = qq|<th class=listheading>|.$locale->text('Sell Price').qq|</th>|;
  927. }
  928. $column_header{fxsellprice} = qq|<th>&nbsp;</th>|;
  929. $column_header{curr} = qq|<th class=listheading>|.$locale->text('Curr').qq|</th>|;
  930. $column_header{discount} = qq|<th class=listheading>|.$locale->text('Discount').qq|</th>|;
  931. $column_header{qty} = qq|<th class=listheading>|.$locale->text('Qty').qq|</th>|;
  932. $column_header{unit} = qq|<th class=listheading>|.$locale->text('Unit').qq|</th>|;
  933. $column_header{deliverydate} = qq|<th><a class=listheading href=$href&sort=deliverydate>|.$locale->text('Delivery Date').qq|</a></th>|;
  934. $column_header{projectnumber} = qq|<th><a class=listheading href=$href&sort=projectnumber>|.$locale->text('Project Number').qq|</a></th>|;
  935. $column_header{serialnumber} = qq|<th><a class=listheading href=$href&sort=serialnumber>|.$locale->text('Serial Number').qq|</a></th>|;
  936. # $locale->text('Customer History')
  937. # $locale->text('Vendor History')
  938. $label = ucfirst $form->{db};
  939. $form->{title} = $locale->text($label." History");
  940. $colspan = $#column_index + 1;
  941. $form->header;
  942. print qq|
  943. <body>
  944. <table width=100%>
  945. <tr>
  946. <th class=listtop>$form->{title}</th>
  947. </tr>
  948. <tr height="5"></tr>
  949. <tr>
  950. <td>$option</td>
  951. </tr>
  952. <tr>
  953. <td>
  954. <table width=100%>
  955. <tr class=listheading>
  956. |;
  957. for (@column_index) { print "$column_header{$_}\n" }
  958. print qq|
  959. </tr>
  960. |;
  961. $module = 'oe';
  962. if ($form->{db} eq 'customer') {
  963. $invlabel = $locale->text('Sales Invoice');
  964. $ordlabel = $locale->text('Sales Order');
  965. $quolabel = $locale->text('Quotation');
  966. $ordertype = 'sales_order';
  967. $quotationtype = 'sales_quotation';
  968. if ($form->{type} eq 'invoice') {
  969. $module = 'is';
  970. }
  971. } else {
  972. $invlabel = $locale->text('Vendor Invoice');
  973. $ordlabel = $locale->text('Purchase Order');
  974. $quolabel = $locale->text('RFQ');
  975. $ordertype = 'purchase_order';
  976. $quotationtype = 'request_quotation';
  977. if ($form->{type} eq 'invoice') {
  978. $module = 'ir';
  979. }
  980. }
  981. $ml = ($form->{db} eq 'vendor') ? -1 : 1;
  982. foreach $ref (@{ $form->{CT} }) {
  983. if ($ref->{id} ne $sameid) {
  984. # print the header
  985. print qq|
  986. <tr class=listheading>
  987. <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>
  988. </tr>
  989. |;
  990. }
  991. if ($form->{type} ne 'invoice') {
  992. $ref->{fxsellprice} = $ref->{sellprice};
  993. $ref->{sellprice} *= $ref->{exchangerate};
  994. }
  995. if ($form->{history} eq 'detail' and $ref->{invid} ne $sameinvid) {
  996. # print inv, ord, quo number
  997. $i++; $i %= 2;
  998. print qq|
  999. <tr class=listrow$i>
  1000. |;
  1001. if ($form->{type} eq 'invoice') {
  1002. print 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>|;
  1003. }
  1004. if ($form->{type} eq 'order') {
  1005. print 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>|;
  1006. }
  1007. if ($form->{type} eq 'quotation') {
  1008. print 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>|;
  1009. }
  1010. print qq|
  1011. </tr>
  1012. |;
  1013. }
  1014. for (@column_index) { $column_data{$_} = "<td>$ref->{$_}&nbsp;</td>" }
  1015. if ($form->{l_curr}) {
  1016. $column_data{fxsellprice} = qq|<td align=right>|.$form->format_amount(\%myconfig, $ref->{fxsellprice}, 2)."</td>";
  1017. }
  1018. $column_data{sellprice} = qq|<td align=right>|.$form->format_amount(\%myconfig, $ref->{sellprice}, 2)."</td>";
  1019. $column_data{qty} = qq|<td align=right>|.$form->format_amount(\%myconfig, $ref->{qty} * $ml)."</td>";
  1020. $column_data{discount} = qq|<td align=right>|.$form->format_amount(\%myconfig, $ref->{discount} * 100, "", "&nbsp;")."</td>";
  1021. $column_data{partnumber} = 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>|;
  1022. $i++; $i %= 2;
  1023. print qq|
  1024. <tr class=listrow$i>
  1025. |;
  1026. for (@column_index) { print "$column_data{$_}\n" }
  1027. print qq|
  1028. </tr>
  1029. |;
  1030. $sameid = $ref->{id};
  1031. $sameinvid = $ref->{invid};
  1032. }
  1033. print qq|
  1034. </table>
  1035. </td>
  1036. </tr>
  1037. <tr>
  1038. <td><hr size=3 noshade></td>
  1039. </tr>
  1040. </table>
  1041. |;
  1042. if ($form->{menubar}) {
  1043. require "$form->{path}/menu.pl";
  1044. &menubar;
  1045. }
  1046. print qq|
  1047. </form>
  1048. </body>
  1049. </html>
  1050. |;
  1051. }
  1052. sub edit {
  1053. # $locale->text('Edit Customer')
  1054. # $locale->text('Edit Vendor')
  1055. CT->create_links(\%myconfig, \%$form);
  1056. for (keys %$form) { $form->{$_} = $form->quote($form->{$_}) }
  1057. $form->{title} = "Edit";
  1058. # format discount
  1059. $form->{discount} *= 100;
  1060. &form_header;
  1061. &form_footer;
  1062. }
  1063. sub form_header {
  1064. $form->{taxincluded} = ($form->{taxincluded}) ? "checked" : "";
  1065. $form->{creditlimit} = $form->format_amount(\%myconfig, $form->{creditlimit}, 0);
  1066. $form->{discount} = $form->format_amount(\%myconfig, $form->{discount}, "");
  1067. $form->{terms} = $form->format_amount(\%myconfig, $form->{terms}, "");
  1068. if ($myconfig{role} =~ /(admin|manager)/) {
  1069. $bcc = qq|
  1070. <tr>
  1071. <th align=right nowrap>|.$locale->text('Bcc').qq|</th>
  1072. <td><input name=bcc size=35 value="$form->{bcc}"></td>
  1073. </tr>
  1074. |;
  1075. }
  1076. if ($form->{currencies}) {
  1077. # currencies
  1078. for (split /:/, $form->{currencies}) { $form->{selectcurrency} .= "<option>$_\n" }
  1079. $form->{selectcurrency} =~ s/option>($form->{curr})/option selected>$1/;
  1080. $currency = qq|
  1081. <th>|.$locale->text('Currency').qq|</th>
  1082. <td><select name=curr>$form->{selectcurrency}</select></td>
  1083. |;
  1084. }
  1085. foreach $item (split / /, $form->{taxaccounts}) {
  1086. if ($form->{tax}{$item}{taxable}) {
  1087. $taxable .= qq| <input name="tax_$item" value=1 class=checkbox type=checkbox checked>&nbsp;<b>$form->{tax}{$item}{description}</b>|;
  1088. } else {
  1089. $taxable .= qq| <input name="tax_$item" value=1 class=checkbox type=checkbox>&nbsp;<b>$form->{tax}{$item}{description}</b>|;
  1090. }
  1091. }
  1092. if ($taxable) {
  1093. $tax = qq|
  1094. <tr>
  1095. <th align=right>|.$locale->text('Taxable').qq|</th>
  1096. <td colspan=5>
  1097. <table>
  1098. <tr>
  1099. <td>$taxable</td>
  1100. <td><input name=taxincluded class=checkbox type=checkbox value=1 $form->{taxincluded}></td>
  1101. <th align=left>|.$locale->text('Tax Included').qq|</th>
  1102. </tr>
  1103. </table>
  1104. </td>
  1105. </tr>
  1106. |;
  1107. }
  1108. $typeofbusiness = qq|
  1109. <th></th>
  1110. <td></td>
  1111. |;
  1112. if (@{ $form->{all_business} }) {
  1113. $form->{selectbusiness} = qq|<option>\n|;
  1114. for (@{ $form->{all_business} }) { $form->{selectbusiness} .= qq|<option value="$_->{description}--$_->{id}">$_->{description}\n| }
  1115. $form->{selectbusiness} =~ s/(<option value="\Q$form->{business}--$form->{business_id}\E")>/$1 selected>/;
  1116. $typeofbusiness = qq|
  1117. <th align=right>|.$locale->text('Type of Business').qq|</th>
  1118. <td><select name=business>$form->{selectbusiness}</select></td>
  1119. |;
  1120. }
  1121. $pricegroup = qq|
  1122. <th></th>
  1123. <td></td>
  1124. |;
  1125. if (@{ $form->{all_pricegroup} } && $form->{db} eq 'customer') {
  1126. $form->{selectpricegroup} = qq|<option>\n|;
  1127. for (@{ $form->{all_pricegroup} }) { $form->{selectpricegroup} .= qq|<option value="$_->{pricegroup}--$_->{id}">$_->{pricegroup}\n| }
  1128. $form->{selectpricegroup} =~ s/(<option value="\Q$form->{pricegroup}--$form->{pricegroup_id}\E")/$1 selected/;
  1129. $pricegroup = qq|
  1130. <th align=right>|.$locale->text('Pricegroup').qq|</th>
  1131. <td><select name=pricegroup>$form->{selectpricegroup}</select></td>
  1132. |;
  1133. }
  1134. $lang = qq|
  1135. <th></th>
  1136. <td></td>
  1137. |;
  1138. if (@{ $form->{all_language} }) {
  1139. $form->{selectlanguage} = qq|<option>\n|;
  1140. for (@{ $form->{all_language} }) { $form->{selectlanguage} .= qq|<option value="$_->{description}--$_->{code}">$_->{description}\n| }
  1141. $form->{selectlanguage} =~ s/(<option value="\Q$form->{language}--$form->{language_code}\E")/$1 selected/;
  1142. $lang = qq|
  1143. <th align=right>|.$locale->text('Language').qq|</th>
  1144. <td><select name=language>$form->{selectlanguage}</select></td>
  1145. |;
  1146. }
  1147. $employeelabel = $locale->text('Salesperson');
  1148. $form->{selectemployee} = qq|<option>\n|;
  1149. for (@{ $form->{all_employee} }) { $form->{selectemployee} .= qq|<option value="$_->{name}--$_->{id}">$_->{name}\n| }
  1150. $form->{selectemployee} =~ s/(<option value="\Q$form->{employee}--$form->{employee_id}\E")/$1 selected/;
  1151. if ($form->{db} eq 'vendor') {
  1152. $gifi = qq|
  1153. <th align=right>|.$locale->text('Sub-contract GIFI').qq|</th>
  1154. <td><input name=gifi_accno size=9 value="$form->{gifi_accno}"></td>
  1155. |;
  1156. $employeelabel = $locale->text('Employee');
  1157. }
  1158. if (@{ $form->{all_employee} }) {
  1159. $employee = qq|
  1160. <th align=right>$employeelabel</th>|;
  1161. if ($myconfig{role} ne 'user' || !$form->{id}) {
  1162. $employee .= qq|
  1163. <td><select name=employee>$form->{selectemployee}</select></td>
  1164. |;
  1165. } else {
  1166. $employee .= qq|
  1167. <td>$form->{employee}</td>
  1168. <input type=hidden name=employee value="$form->{employee}--$form->{employee_id}">|;
  1169. }
  1170. }
  1171. # $locale->text('Customer Number')
  1172. # $locale->text('Vendor Number')
  1173. $label = ucfirst $form->{db};
  1174. $form->{title} = $locale->text("$form->{title} $label");
  1175. $form->header;
  1176. print qq|
  1177. <body>
  1178. <form method=post action=$form->{script}>
  1179. <table width=100%>
  1180. <tr>
  1181. <th class=listtop>$form->{title}</th>
  1182. </tr>
  1183. <tr height="5"></tr>
  1184. <tr>
  1185. <td>
  1186. <table width=100%>
  1187. <tr valign=top>
  1188. <td width=50%>
  1189. <table width=100%>
  1190. <tr class=listheading>
  1191. <th class=listheading colspan=2 width=50%>|.$locale->text('Billing Address').qq|</th>
  1192. <tr>
  1193. <th align=right nowrap>|.$locale->text($label .' Number').qq|</th>
  1194. <td><input name="$form->{db}number" size=35 maxlength=32 value="$form->{"$form->{db}number"}"></td>
  1195. </tr>
  1196. <tr>
  1197. <th align=right nowrap>|.$locale->text('Company Name').qq|</th>
  1198. <td><input name=name size=35 maxlength=64 value="$form->{name}"></td>
  1199. </tr>
  1200. <tr>
  1201. <th align=right nowrap>|.$locale->text('Address').qq|</th>
  1202. <td><input name=address1 size=35 maxlength=32 value="$form->{address1}"></td>
  1203. </tr>
  1204. <tr>
  1205. <th></th>
  1206. <td><input name=address2 size=35 maxlength=32 value="$form->{address2}"></td>
  1207. </tr>
  1208. <tr>
  1209. <th align=right nowrap>|.$locale->text('City').qq|</th>
  1210. <td><input name=city size=35 maxlength=32 value="$form->{city}"></td>
  1211. </tr>
  1212. <tr>
  1213. <th align=right nowrap>|.$locale->text('State/Province').qq|</th>
  1214. <td><input name=state size=35 maxlength=32 value="$form->{state}"></td>
  1215. </tr>
  1216. <tr>
  1217. <th align=right nowrap>|.$locale->text('Zip/Postal Code').qq|</th>
  1218. <td><input name=zipcode size=10 maxlength=10 value="$form->{zipcode}"></td>
  1219. </tr>
  1220. <tr>
  1221. <th align=right nowrap>|.$locale->text('Country').qq|</th>
  1222. <td><input name=country size=35 maxlength=32 value="$form->{country}"></td>
  1223. </tr>
  1224. <tr>
  1225. <th align=right nowrap>|.$locale->text('Contact').qq|</th>
  1226. <td><input name=contact size=35 maxlength=64 value="$form->{contact}"></td>
  1227. </tr>
  1228. <tr>
  1229. <th align=right nowrap>|.$locale->text('Phone').qq|</th>
  1230. <td><input name=phone size=20 maxlength=20 value="$form->{phone}"></td>
  1231. </tr>
  1232. <tr>
  1233. <th align=right nowrap>|.$locale->text('Fax').qq|</th>
  1234. <td><input name=fax size=20 maxlength=20 value="$form->{fax}"></td>
  1235. </tr>
  1236. <tr>
  1237. <th align=right nowrap>|.$locale->text('E-mail').qq|</th>
  1238. <td><input name=email size=35 value="$form->{email}"></td>
  1239. </tr>
  1240. <tr>
  1241. <th align=right nowrap>|.$locale->text('Cc').qq|</th>
  1242. <td><input name=cc size=35 value="$form->{cc}"></td>
  1243. </tr>
  1244. $bcc
  1245. </table>
  1246. </td>
  1247. <td width=50%>
  1248. <table width=100%>
  1249. <tr>
  1250. <th class=listheading colspan=2>|.$locale->text('Shipping Address').qq|</th>
  1251. </tr>
  1252. <tr>
  1253. <td><input name=none size=35 value=|. ("=" x 35) .qq|></td>
  1254. </tr>
  1255. <tr>
  1256. <td><input name=shiptoname size=35 maxlength=64 value="$form->{shiptoname}"></td>
  1257. </tr>
  1258. <tr>
  1259. <td><input name=shiptoaddress1 size=35 maxlength=32 value="$form->{shiptoaddress1}"></td>
  1260. </tr>
  1261. <tr>
  1262. <td><input name=shiptoaddress2 size=35 maxlength=32 value="$form->{shiptoaddress2}"></td>
  1263. </tr>
  1264. <tr>
  1265. <td><input name=shiptocity size=35 maxlength=32 value="$form->{shiptocity}"></td>
  1266. </tr>
  1267. <tr>
  1268. <td><input name=shiptostate size=35 maxlength=32 value="$form->{shiptostate}"></td>
  1269. </tr>
  1270. <tr>
  1271. <td><input name=shiptozipcode size=10 maxlength=10 value="$form->{shiptozipcode}"></td>
  1272. </tr>
  1273. <tr>
  1274. <td><input name=shiptocountry size=35 maxlength=32 value="$form->{shiptocountry}"></td>
  1275. </tr>
  1276. <tr>
  1277. <td><input name=shiptocontact size=35 maxlength=64 value="$form->{shiptocontact}"></td>
  1278. </tr>
  1279. <tr>
  1280. <td><input name=shiptophone size=20 maxlength=20 value="$form->{shiptophone}"></td>
  1281. </tr>
  1282. <tr>
  1283. <td><input name=shiptofax size=20 maxlength=20 value="$form->{shiptofax}"></td>
  1284. </tr>
  1285. <tr>
  1286. <td><input name=shiptoemail size=35 value="$form->{shiptoemail}"></td>
  1287. </tr>
  1288. </table>
  1289. </td>
  1290. </tr>
  1291. </table>
  1292. </td>
  1293. </tr>
  1294. <tr>
  1295. <td>
  1296. <table>
  1297. $tax
  1298. <tr>
  1299. <th align=right>|.$locale->text('Startdate').qq|</th>
  1300. <td><input name=startdate size=11 title="$myconfig{dateformat}" value=$form->{startdate}></td>
  1301. <th align=right>|.$locale->text('Enddate').qq|</th>
  1302. <td><input name=enddate size=11 title="$myconfig{dateformat}" value=$form->{enddate}></td>
  1303. </tr>
  1304. <tr>
  1305. <th align=right>|.$locale->text('Credit Limit').qq|</th>
  1306. <td><input name=creditlimit size=9 value="$form->{creditlimit}"></td>
  1307. <th align=right>|.$locale->text('Terms').qq|</th>
  1308. <td><input name=terms size=2 value="$form->{terms}"> <b>|.$locale->text('days').qq|</b></td>
  1309. <th align=right>|.$locale->text('Discount').qq|</th>
  1310. <td><input name=discount size=4 value="$form->{discount}">
  1311. <b>%</b></td>
  1312. </tr>
  1313. <tr>
  1314. <th align=right>|.$locale->text('Tax Number / SSN').qq|</th>
  1315. <td><input name=taxnumber size=20 value="$form->{taxnumber}"></td>
  1316. $gifi
  1317. <th align=right>|.$locale->text('SIC').qq|</th>
  1318. <td><input name=sic_code size=6 maxlength=6 value="$form->{sic_code}"></td>
  1319. </tr>
  1320. <tr>
  1321. $typeofbusiness
  1322. <th align=right>|.$locale->text('BIC').qq|</th>
  1323. <td><input name=bic size=11 maxlength=11 value="$form->{bic}"></td>
  1324. <th align=right>|.$locale->text('IBAN').qq|</th>
  1325. <td><input name=iban size=24 maxlength=34 value="$form->{iban}"></td>
  1326. </tr>
  1327. <tr>
  1328. $pricegroup
  1329. $lang
  1330. $currency
  1331. </tr>
  1332. <tr valign=top>
  1333. $employee
  1334. <td colspan=4>
  1335. <table>
  1336. <tr valign=top>
  1337. <th align=left nowrap>|.$locale->text('Notes').qq|</th>
  1338. <td><textarea name=notes rows=3 cols=40 wrap=soft>$form->{notes}</textarea></td>
  1339. </tr>
  1340. </table>
  1341. </td>
  1342. </tr>
  1343. </table>
  1344. </td>
  1345. </tr>
  1346. <tr>
  1347. <td><hr size=3 noshade></td>
  1348. </tr>
  1349. </table>
  1350. |;
  1351. }
  1352. sub form_footer {
  1353. # type=submit $locale->text('Save')
  1354. # type=submit $locale->text('Save as new')
  1355. # type=submit $locale->text('AR Transaction')
  1356. # type=submit $locale->text('Sales Invoice')
  1357. # type=submit $locale->text('Sales Order')
  1358. # type=submit $locale->text('Quotation')
  1359. # type=submit $locale->text('AP Transaction')
  1360. # type=submit $locale->text('Vendor Invoice')
  1361. # type=submit $locale->text('Purchase Order')
  1362. # type=submit $locale->text('RFQ')
  1363. # type=submit $locale->text('Pricelist')
  1364. # type=submit $locale->text('Delete')
  1365. # type=submit $locale->text('POS')
  1366. %button = ('Save' => { ndx => 1, key => 'S', value => $locale->text('Save') },
  1367. 'Save as new' => { ndx => 2, key => 'N', value => $locale->text('Save as new') },
  1368. 'AR Transaction' => { ndx => 7, key => 'A', value => $locale->text('AR Transaction') },
  1369. 'AP Transaction' => { ndx => 8, key => 'A', value => $locale->text('AP Transaction') },
  1370. 'Sales Invoice' => { ndx => 9, key => 'I', value => $locale->text('Sales Invoice') },
  1371. 'POS' => { ndx => 10, key => 'C', value => $locale->text('POS') },
  1372. 'Sales Order' => { ndx => 11, key => 'O', value => $locale->text('Sales Order') },
  1373. 'Quotation' => { ndx => 12, key => 'Q', value => $locale->text('Quotation') },
  1374. 'Vendor Invoice' => { ndx => 13, key => 'I', value => $locale->text('Vendor Invoice') },
  1375. 'Purchase Order' => { ndx => 14, key => 'O', value => $locale->text('Purchase Order') },
  1376. 'RFQ' => { ndx => 15, key => 'Q', value => $locale->text('RFQ') },
  1377. 'Pricelist' => { ndx => 16, key => 'P', value => $locale->text('Pricelist') },
  1378. 'Delete' => { ndx => 17, key => 'D', value => $locale->text('Delete') },
  1379. );
  1380. %a = ();
  1381. if ($form->{db} eq 'customer') {
  1382. if ($myconfig{acs} !~ /AR--Customers--Add Customer/) {
  1383. $a{'Save'} = 1;
  1384. if ($form->{id}) {
  1385. $a{'Save as new'} = 1;
  1386. if ($form->{status} eq 'orphaned') {
  1387. $a{'Delete'} = 1;
  1388. }
  1389. }
  1390. }
  1391. if ($myconfig{acs} !~ /AR--AR/) {
  1392. if ($myconfig{acs} !~ /AR--Add Transaction/) {
  1393. $a{'AR Transaction'} = 1;
  1394. }
  1395. if ($myconfig{acs} !~ /AR--Sales Invoice/) {
  1396. $a{'Sales Invoice'} = 1;
  1397. }
  1398. }
  1399. if ($myconfig{acs} !~ /POS--POS/) {
  1400. if ($myconfig{acs} !~ /POS--Sale/) {
  1401. $a{'POS'} = 1;
  1402. }
  1403. }
  1404. if ($myconfig{acs} !~ /Order Entry--Order Entry/) {
  1405. if ($myconfig{acs} !~ /Order Entry--Sales Order/) {
  1406. $a{'Sales Order'} = 1;
  1407. }
  1408. }
  1409. if ($myconfig{acs} !~ /Quotations--Quotations/) {
  1410. if ($myconfig{acs} !~ /Quotations--Quotation/) {
  1411. $a{'Quotation'} = 1;
  1412. }
  1413. }
  1414. }
  1415. if ($form->{db} eq 'vendor') {
  1416. if ($myconfig{acs} !~ /AP--Vendors--Add Vendor/) {
  1417. $a{'Save'} = 1;
  1418. if ($form->{id}) {
  1419. $a{'Save as new'} = 1;
  1420. if ($form->{status} eq 'orphaned') {
  1421. $a{'Delete'} = 1;
  1422. }
  1423. }
  1424. }
  1425. if ($myconfig{acs} !~ /AP--AP/) {
  1426. if ($myconfig{acs} !~ /AP--Add Transaction/) {
  1427. $a{'AP Transaction'} = 1;
  1428. }
  1429. if ($myconfig{acs} !~ /AP--Vendor Invoice/) {
  1430. $a{'Vendor Invoice'} = 1;
  1431. }
  1432. }
  1433. if ($myconfig{acs} !~ /Order Entry--Order Entry/) {
  1434. if ($myconfig{acs} !~ /Order Entry--Purchase Order/) {
  1435. $a{'Purchase Order'} = 1;
  1436. }
  1437. }
  1438. if ($myconfig{acs} !~ /Quotations--Quotations/) {
  1439. if ($myconfig{acs} !~ /Quotations--RFQ/) {
  1440. $a{'RFQ'} = 1;
  1441. }
  1442. }
  1443. }
  1444. if ($myconfig{acs} !~ /Goods & Services--Goods & Services/) {
  1445. $myconfig{acs} =~ s/(Goods & Services--)Add (Service|Assembly).*;/$1--Add Part/g;
  1446. if ($myconfig{acs} !~ /Goods & Services--Add Part/) {
  1447. $a{'Pricelist'} = 1;
  1448. }
  1449. }
  1450. $form->hide_form(qw(id taxaccounts path login sessionid callback db));
  1451. for (keys %button) { delete $button{$_} if ! $a{$_} }
  1452. for (sort { $button{$a}->{ndx} <=> $button{$b}->{ndx} } keys %button) { $form->print_button(\%button, $_) }
  1453. if ($form->{menubar}) {
  1454. require "$form->{path}/menu.pl";
  1455. &menubar;
  1456. }
  1457. print qq|
  1458. </form>
  1459. </body>
  1460. </html>
  1461. |;
  1462. }
  1463. sub pricelist {
  1464. $form->isblank("name", $locale->text('Name missing!'));
  1465. $form->{display_form} ||= "display_pricelist";
  1466. CT->pricelist(\%myconfig, \%$form);
  1467. foreach $ref (@{ $form->{"all_partspricelist"} }) {
  1468. $i++;
  1469. for (keys %$ref) { $form->{"${_}_$i"} = $ref->{$_} }
  1470. }
  1471. $form->{rowcount} = $i;
  1472. # currencies
  1473. @curr = split /:/, $form->{currencies};
  1474. for (@curr) { $form->{selectcurrency} .= "<option>$_\n" }
  1475. if (@ { $form->{all_partsgroup} }) {
  1476. $form->{selectpartsgroup} = "";
  1477. foreach $ref (@ { $form->{all_partsgroup} }) {
  1478. $form->{selectpartsgroup} .= qq|$ref->{partsgroup}--$ref->{id}\n|;
  1479. }
  1480. }
  1481. for (qw(currencies all_partsgroup all_partspricelist)) { delete $form->{$_} }
  1482. foreach $i (1 .. $form->{rowcount}) {
  1483. if ($form->{db} eq 'customer') {
  1484. $form->{"pricebreak_$i"} = $form->format_amount(\%myconfig, $form->{"pricebreak_$i"});
  1485. $form->{"sellprice_$i"} = $form->format_amount(\%myconfig, $form->{"sellprice_$i"}, 2);
  1486. }
  1487. if ($form->{db} eq 'vendor') {
  1488. $form->{"leadtime_$i"} = $form->format_amount(\%myconfig, $form->{"leadtime_$i"});
  1489. $form->{"lastcost_$i"} = $form->format_amount(\%myconfig, $form->{"lastcost_$i"}, 2);
  1490. }
  1491. }
  1492. $form->{rowcount}++;
  1493. &{ "$form->{db}_pricelist" };
  1494. }
  1495. sub customer_pricelist {
  1496. @flds = qw(runningnumber id partnumber description sellprice unit partsgroup pricebreak curr validfrom validto);
  1497. $form->{rowcount}--;
  1498. # remove empty rows
  1499. if ($form->{rowcount}) {
  1500. foreach $i (1 .. $form->{rowcount}) {
  1501. for (qw(pricebreak sellprice)) { $form->{"${_}_$i"} = $form->parse_amount(\%myconfig, $form->{"${_}_$i"}) }
  1502. ($a, $b) = split /\./, $form->{"pricebreak_$i"};
  1503. $a = length $a;
  1504. $b = length $b;
  1505. $whole = ($whole > $a) ? $whole : $a;
  1506. $dec = ($dec > $b) ? $dec : $b;
  1507. }
  1508. $pad1 = '0' x $whole;
  1509. $pad2 = '0' x $dec;
  1510. foreach $i (1 .. $form->{rowcount}) {
  1511. ($a, $b) = split /\./, $form->{"pricebreak_$i"};
  1512. $a = substr("$pad1$a", -$whole);
  1513. $b = substr("$b$pad2", 0, $dec);
  1514. $ndx{qq|$form->{"partnumber_$i"}_$form->{"id_$i"}_$a$b|} = $i;
  1515. }
  1516. $i = 1;
  1517. for (sort keys %ndx) { $form->{"runningnumber_$ndx{$_}"} = $i++ }
  1518. foreach $i (1 .. $form->{rowcount}) {
  1519. if ($form->{"partnumber_$i"} && $form->{"sellprice_$i"}) {
  1520. if ($form->{"id_$i"} eq $sameid) {
  1521. $j = $i + 1;
  1522. next if ($form->{"id_$j"} eq $sameid && !$form->{"pricebreak_$i"});
  1523. }
  1524. push @a, {};
  1525. $j = $#a;
  1526. for (@flds) { $a[$j]->{$_} = $form->{"${_}_$i"} }
  1527. $count++;
  1528. }
  1529. $sameid = $form->{"id_$i"};
  1530. }
  1531. $form->redo_rows(\@flds, \@a, $count, $form->{rowcount});
  1532. $form->{rowcount} = $count;
  1533. }
  1534. $form->{rowcount}++;
  1535. if ($form->{display_form}) {
  1536. &{ "$form->{display_form}" };
  1537. }
  1538. }
  1539. sub vendor_pricelist {
  1540. @flds = qw(runningnumber id sku partnumber description lastcost unit partsgroup curr leadtime);
  1541. $form->{rowcount}--;
  1542. # remove empty rows
  1543. if ($form->{rowcount}) {
  1544. foreach $i (1 .. $form->{rowcount}) {
  1545. for (qw(leadtime lastcost)) { $form->{"${_}_$i"} = $form->parse_amount(\%myconfig, $form->{"${_}_$i"}) }
  1546. $var = ($form->{"partnumber_$i"}) ? $form->{"sku_$i"} : qq|_$form->{"sku_$i"}|;
  1547. $ndx{$var} = $i;
  1548. }
  1549. $i = 1;
  1550. for (sort keys %ndx) { $form->{"runningnumber_$ndx{$_}"} = $i++ }
  1551. foreach $i (1 .. $form->{rowcount}) {
  1552. if ($form->{"sku_$i"}) {
  1553. push @a, {};
  1554. $j = $#a;
  1555. for (@flds) { $a[$j]->{$_} = $form->{"${_}_$i"} }
  1556. $count++;
  1557. }
  1558. }
  1559. $form->redo_rows(\@flds, \@a, $count, $form->{rowcount});
  1560. $form->{rowcount} = $count;
  1561. }
  1562. $form->{rowcount}++;
  1563. if ($form->{display_form}) {
  1564. &{ "$form->{display_form}" };
  1565. }
  1566. }
  1567. sub display_pricelist {
  1568. &pricelist_header;
  1569. delete $form->{action};
  1570. $form->hide_form;
  1571. &pricelist_footer;
  1572. }
  1573. sub pricelist_header {
  1574. $form->{title} = $form->{name};
  1575. $form->header;
  1576. print qq|
  1577. <body>
  1578. <form method=post action="$form->{script}">
  1579. <table width=100%>
  1580. <tr>
  1581. <th class=listtop>$form->{title}</th>
  1582. </tr>
  1583. <tr height="5"></tr>
  1584. |;
  1585. if ($form->{db} eq 'customer') {
  1586. @column_index = qw(partnumber description);
  1587. push @column_index, "partsgroup" if $form->{selectpartsgroup};
  1588. push @column_index, qw(pricebreak sellprice curr validfrom validto);
  1589. $column_header{pricebreak} = qq|<th class=listheading nowrap>|.$locale->text('Break').qq|</th>|;
  1590. $column_header{sellprice} = qq|<th class=listheading nowrap>|.$locale->text('Sell Price').qq|</th>|;
  1591. $column_header{validfrom} = qq|<th class=listheading nowrap>|.$locale->text('From').qq|</th>|;
  1592. $column_header{validto} = qq|<th class=listheading nowrap>|.$locale->text('To').qq|</th>|;
  1593. }
  1594. if ($form->{db} eq 'vendor') {
  1595. @column_index = qw(sku partnumber description);
  1596. push @column_index, "partsgroup" if $form->{selectpartsgroup};
  1597. push @column_index, qw(lastcost curr leadtime);
  1598. $column_header{sku} = qq|<th class=listheading nowrap>|.$locale->text('SKU').qq|</th>|;
  1599. $column_header{leadtime} = qq|<th class=listheading nowrap>|.$locale->text('Leadtime').qq|</th>|;
  1600. $column_header{lastcost} = qq|<th class=listheading nowrap>|.$locale->text('Cost').qq|</th>|;
  1601. }
  1602. $column_header{partnumber} = qq|<th class=listheading nowrap>|.$locale->text('Number').qq|</th>|;
  1603. $column_header{description} = qq|<th class=listheading nowrap width=80%>|.$locale->text('Description').qq|</th>|;
  1604. $column_header{partsgroup} = qq|<th class=listheading nowrap>|.$locale->text('Group').qq|</th>|;
  1605. $column_header{curr} = qq|<th class=listheading nowrap>|.$locale->text('Curr').qq|</th>|;
  1606. print qq|
  1607. <tr>
  1608. <td>
  1609. <table width=100%>
  1610. <tr class=listheading>
  1611. |;
  1612. for (@column_index) { print "\n$column_header{$_}" }
  1613. print qq|
  1614. </tr>
  1615. |;
  1616. $sameid = "";
  1617. foreach $i (1 .. $form->{rowcount}) {
  1618. $selectcurrency = $form->{selectcurrency};
  1619. $selectcurrency =~ s/option>\Q$form->{"curr_$i"}\E/option selected>$form->{"curr_$i"}/;
  1620. if ($form->{selectpartsgroup}) {
  1621. if ($i < $form->{rowcount}) {
  1622. ($partsgroup) = split /--/, $form->{"partsgroup_$i"};
  1623. $column_data{partsgroup} = qq|<td>$partsgroup</td>
  1624. <input type=hidden name="partsgroup_$i" value="|.$form->quote($form->{"partsgroup_$i"}).qq|">|;
  1625. }
  1626. }
  1627. if ($i < $form->{rowcount}) {
  1628. if ($form->{"id_$i"} eq $sameid) {
  1629. for (qw(partnumber description partsgroup)) { $column_data{$_} = qq|<td>&nbsp;</td>
  1630. <input type=hidden name="${_}_$i" value="|.$form->quote($form->{"${_}_$i"}).qq|">| }
  1631. } else {
  1632. $column_data{sku} = qq|<td><input name="sku_$i" value="$form->{"sku_$i"}"></td>|;
  1633. $column_data{partnumber} = qq|<td><input name="partnumber_$i" value="$form->{"partnumber_$i"}"></td>|;
  1634. $column_data{description} = qq|<td>$form->{"description_$i"}&nbsp;</td>
  1635. <input type=hidden name="description_$i" value="|.$form->quote($form->{"description_$i"}).qq|">|;
  1636. }
  1637. $column_data{partnumber} .= qq|
  1638. <input type=hidden name="id_$i" value="$form->{"id_$i"}">|;
  1639. } else {
  1640. if ($form->{db} eq 'customer') {
  1641. $column_data{partnumber} = qq|<td><input name="partnumber_$i" value="$form->{"partnumber_$i"}"></td>|;
  1642. } else {
  1643. $column_data{partnumber} = qq|<td>&nbsp;</td>|;
  1644. }
  1645. $column_data{partnumber} .= qq|
  1646. <input type=hidden name="id_$i" value="$form->{"id_$i"}">|;
  1647. $column_data{sku} = qq|<td><input name="sku_$i" value="$form->{"sku_$i"}"></td>|;
  1648. $column_data{description} = qq|<td><input name="description_$i" value="$form->{"description_$i"}"></td>|;
  1649. if ($form->{selectpartsgroup}) {
  1650. $selectpartsgroup = "<option>";
  1651. foreach $line (split /\n/, $form->{selectpartsgroup}) {
  1652. $selectpartsgroup .= qq|\n<option value="|.$form->quote($line).qq|">| .(split /--/, $line)[0];
  1653. }
  1654. $column_data{partsgroup} = qq|<td><select name="partsgroup_$i">$selectpartsgroup</select></td>|;
  1655. }
  1656. }
  1657. if ($form->{db} eq 'customer') {
  1658. $column_data{pricebreak} = qq|<td align=right><input name="pricebreak_$i" size=5 value=|.$form->format_amount(\%myconfig, $form->{"pricebreak_$i"}).qq|></td>|;
  1659. $column_data{sellprice} = qq|<td align=right><input name="sellprice_$i" size=10 value=|.$form->format_amount(\%myconfig, $form->{"sellprice_$i"}, 2).qq|></td>|;
  1660. $column_data{validfrom} = qq|<td><input name="validfrom_$i" size=11 value=$form->{"validfrom_$i"}></td>|;
  1661. $column_data{validto} = qq|<td><input name="validto_$i" size=11 value=$form->{"validto_$i"}></td>|;
  1662. }
  1663. if ($form->{db} eq 'vendor') {
  1664. $column_data{leadtime} = qq|<td align=right><input name="leadtime_$i" size=5 value=|.$form->format_amount(\%myconfig, $form->{"leadtime_$i"}).qq|></td>|;
  1665. $column_data{lastcost} = qq|<td align=right><input name="lastcost_$i" size=10 value=|.$form->format_amount(\%myconfig, $form->{"lastcost_$i"}, 2).qq|></td>|;
  1666. }
  1667. $column_data{curr} = qq|<td><select name="curr_$i">$selectcurrency</select></td>|;
  1668. print qq|<tr valign=top>|;
  1669. for (@column_index) { print "\n$column_data{$_}" }
  1670. print qq|</tr>|;
  1671. $sameid = $form->{"id_$i"};
  1672. }
  1673. print qq|
  1674. </table>
  1675. </td>
  1676. </tr>
  1677. <tr>
  1678. <td><hr size=3 noshade></td>
  1679. </tr>
  1680. </table>
  1681. |;
  1682. # delete variables
  1683. foreach $i (1 .. $form->{rowcount}) {
  1684. for (@column_index, "id") { delete $form->{"${_}_$i"} }
  1685. }
  1686. for (qw(title titlebar script none)) { delete $form->{$_} }
  1687. }
  1688. sub pricelist_footer {
  1689. # type=submit $locale->text('Update')
  1690. # type=submit $locale->text('Save Pricelist')
  1691. %button = ('Update' => { ndx => 1, key => 'U', value => $locale->text('Update') },
  1692. 'Save Pricelist' => { ndx => 3, key => 'S', value => $locale->text('Save Pricelist') },
  1693. );
  1694. for (sort { $button{$a}->{ndx} <=> $button{$b}->{ndx} } keys %button) { $form->print_button(\%button, $_) }
  1695. print qq|
  1696. </form>
  1697. </body>
  1698. </html>
  1699. |;
  1700. }
  1701. sub update {
  1702. $i = $form->{rowcount};
  1703. $additem = 0;
  1704. if ($form->{db} eq 'customer') {
  1705. $additem = 1 if ! (($form->{"partnumber_$i"} eq "") && ($form->{"description_$i"} eq "") && ($form->{"partsgroup_$i"} eq ""));
  1706. }
  1707. if ($form->{db} eq 'vendor') {
  1708. if (! (($form->{"sku_$i"} eq "") && ($form->{"description_$i"} eq "") && ($form->{"partsgroup_$i"} eq ""))) {
  1709. $additem = 1;
  1710. $form->{"partnumber_$i"} = $form->{"sku_$i"};
  1711. }
  1712. }
  1713. if ($additem) {
  1714. CT->retrieve_item(\%myconfig, \%$form);
  1715. $rows = scalar @{ $form->{item_list} };
  1716. if ($rows > 0) {
  1717. if ($rows > 1) {
  1718. &select_item;
  1719. exit;
  1720. } else {
  1721. $sellprice = $form->{"sellprice_$i"};
  1722. $pricebreak = $form->{"pricebreak_$i"};
  1723. $lastcost = $form->{"lastcost_$i"};
  1724. for (qw(partnumber description)) { $form->{item_list}[0]{$_} = $form->quote($form->{item_list}[0]{$_}) }
  1725. for (keys %{ $form->{item_list}[0] }) { $form->{"${_}_$i"} = $form->{item_list}[0]{$_} }
  1726. if ($form->{db} eq 'customer') {
  1727. if ($sellprice) {
  1728. $form->{"sellprice_$i"} = $sellprice;
  1729. }
  1730. $form->{"sellprice_$i"} = $form->format_amount(\%myconfig, $form->{"sellprice_$i"}, 2);
  1731. $form->{"pricebreak_$i"} = $pricebreak;
  1732. } else {
  1733. foreach $j (1 .. $form->{rowcount} - 1) {
  1734. if ($form->{"sku_$j"} eq $form->{"partnumber_$i"}) {
  1735. $form->error($locale->text('Item already on pricelist!'));
  1736. }
  1737. }
  1738. if ($lastcost) {
  1739. $form->{"lastcost_$i"} = $lastcost;
  1740. }
  1741. $form->{"lastcost_$i"} = $form->format_amount(\%myconfig, $form->{"lastcost_$i"}, 2);
  1742. $form->{"sku_$i"} = $form->{"partnumber_$i"};
  1743. # delete $form->{"partnumber_$i"};
  1744. }
  1745. $form->{rowcount}++;
  1746. }
  1747. } else {
  1748. $form->error($locale->text('Item not on file!'));
  1749. }
  1750. }
  1751. &{ "$form->{db}_pricelist" };
  1752. }
  1753. sub select_item {
  1754. @column_index = qw(ndx partnumber description partsgroup unit sellprice lastcost);
  1755. $column_data{ndx} = qq|<th>&nbsp;</th>|;
  1756. $column_data{partnumber} = qq|<th class=listheading>|.$locale->text('Number').qq|</th>|;
  1757. $column_data{description} = qq|<th class=listheading>|.$locale->text('Description').qq|</th>|;
  1758. $column_data{partsgroup} = qq|<th class=listheading>|.$locale->text('Group').qq|</th>|;
  1759. $column_data{unit} = qq|<th class=listheading>|.$locale->text('Unit').qq|</th>|;
  1760. $column_data{sellprice} = qq|<th class=listheading>|.$locale->text('Sell Price').qq|</th>|;
  1761. $column_data{lastcost} = qq|<th class=listheading>|.$locale->text('Cost').qq|</th>|;
  1762. $form->header;
  1763. $title = $locale->text('Select items');
  1764. print qq|
  1765. <body>
  1766. <form method=post action="$form->{script}">
  1767. <table width=100%>
  1768. <tr>
  1769. <th class=listtop>$title</th>
  1770. </tr>
  1771. <tr height="5"></tr>
  1772. <tr>
  1773. <td>$option</td>
  1774. </tr>
  1775. <tr>
  1776. <td>
  1777. <table width=100%>
  1778. <tr class=listheading>|;
  1779. for (@column_index) { print "\n$column_data{$_}" }
  1780. print qq|
  1781. </tr>
  1782. |;
  1783. my $i = 0;
  1784. foreach $ref (@{ $form->{item_list} }) {
  1785. $i++;
  1786. for (qw(partnumber description unit)) { $ref->{$_} = $form->quote($ref->{$_}) }
  1787. $column_data{ndx} = qq|<td><input name="ndx_$i" class=checkbox type=checkbox value=$i></td>|;
  1788. for (qw(partnumber description partsgroup unit)) { $column_data{$_} = qq|<td>$ref->{$_}&nbsp;</td>| }
  1789. $column_data{sellprice} = qq|<td align=right>|.$form->format_amount(\%myconfig, $ref->{sellprice}, 2, "&nbsp;").qq|</td>|;
  1790. $column_data{lastcost} = qq|<td align=right>|.$form->format_amount(\%myconfig, $ref->{lastcost}, 2, "&nbsp;").qq|</td>|;
  1791. $j++; $j %= 2;
  1792. print qq|
  1793. <tr class=listrow$j>|;
  1794. for (@column_index) { print "\n$column_data{$_}" }
  1795. print qq|
  1796. </tr>
  1797. |;
  1798. for (qw(partnumber description partsgroup partsgroup_id sellprice lastcost unit id)) {
  1799. print qq|<input type=hidden name="new_${_}_$i" value="$ref->{$_}">\n|;
  1800. }
  1801. }
  1802. print qq|
  1803. </table>
  1804. </td>
  1805. </tr>
  1806. <tr>
  1807. <td><hr size=3 noshade></td>
  1808. </tr>
  1809. </table>
  1810. <input name=lastndx type=hidden value=$i>
  1811. |;
  1812. # delete action variable
  1813. for (qw(nextsub item_list)) { delete $form->{$_} }
  1814. $form->{action} = "item_selected";
  1815. $form->hide_form;
  1816. print qq|
  1817. <input type=hidden name=nextsub value=item_selected>
  1818. <br>
  1819. <input class=submit type=submit name=action value="|.$locale->text('Continue').qq|">
  1820. </form>
  1821. </body>
  1822. </html>
  1823. |;
  1824. }
  1825. sub item_selected {
  1826. # add rows
  1827. $i = $form->{rowcount};
  1828. %id = ();
  1829. for $i (1 .. $form->{rowcount} - 1) {
  1830. $id{$form->{"id_$i"}} = 1;
  1831. }
  1832. for $j (1 .. $form->{lastndx}) {
  1833. if ($form->{"ndx_$j"}) {
  1834. if ($id{$form->{"new_id_$j"}}) {
  1835. next if $form->{db} eq 'vendor';
  1836. }
  1837. for (qw(id partnumber description unit sellprice lastcost)) {
  1838. $form->{"${_}_$i"} = $form->{"new_${_}_$j"};
  1839. }
  1840. $form->{"partsgroup_$i"} = qq|$form->{"new_partsgroup_$j"}--$form->{"new_partsgroup_id_$j"}|;
  1841. $form->{"sku_$i"} = $form->{"new_partnumber_$j"};
  1842. $i++;
  1843. }
  1844. }
  1845. $form->{rowcount} = $i;
  1846. # delete all the new_ variables
  1847. for $i (1 .. $form->{lastndx}) {
  1848. for (qw(id partnumber description unit sellprice lastcost partsgroup partsgroup_id)) { delete $form->{"new_${_}_$i"} }
  1849. delete $form->{"ndx_$i"};
  1850. }
  1851. for (qw(ndx lastndx nextsub)) { delete $form->{$_} }
  1852. &{ "$form->{db}_pricelist" };
  1853. }
  1854. sub save_pricelist {
  1855. &{ "CT::save_$form->{db}" }("", \%myconfig, \%$form);
  1856. $callback = $form->{callback};
  1857. $form->{callback} = "$form->{script}?action=edit";
  1858. for (qw(db id login path sessionid)) { $form->{callback} .= "&$_=$form->{$_}" }
  1859. $form->{callback} .= "&callback=".$form->escape($callback,1);
  1860. if (CT->save_pricelist(\%myconfig, \%$form)) {
  1861. $form->redirect;
  1862. } else {
  1863. $form->error($locale->text('Could not save pricelist!'));
  1864. }
  1865. }
  1866. sub add_transaction {
  1867. $form->isblank("name", $locale->text("Name missing!"));
  1868. &{ "CT::save_$form->{db}" }("", \%myconfig, \%$form);
  1869. $form->{callback} = $form->escape($form->{callback},1);
  1870. $name = $form->escape($form->{name},1);
  1871. $form->{callback} = "$form->{script}?login=$form->{login}&path=$form->{path}&sessionid=$form->{sessionid}&action=add&vc=$form->{db}&$form->{db}_id=$form->{id}&$form->{db}=$name&type=$form->{type}&callback=$form->{callback}";
  1872. $form->redirect;
  1873. }
  1874. sub ap_transaction {
  1875. $form->{script} = "ap.pl";
  1876. $form->{type} = "ap_transaction";
  1877. &add_transaction;
  1878. }
  1879. sub ar_transaction {
  1880. $form->{script} = "ar.pl";
  1881. $form->{type} = "ar_transaction";
  1882. &add_transaction;
  1883. }
  1884. sub sales_invoice {
  1885. $form->{script} = "is.pl";
  1886. $form->{type} = "invoice";
  1887. &add_transaction;
  1888. }
  1889. sub pos {
  1890. $form->{script} = "ps.pl";
  1891. $form->{type} = "pos_invoice";
  1892. &add_transaction;
  1893. }
  1894. sub vendor_invoice {
  1895. $form->{script} = "ir.pl";
  1896. $form->{type} = "invoice";
  1897. &add_transaction;
  1898. }
  1899. sub rfq {
  1900. $form->{script} = "oe.pl";
  1901. $form->{type} = "request_quotation";
  1902. &add_transaction;
  1903. }
  1904. sub quotation {
  1905. $form->{script} = "oe.pl";
  1906. $form->{type} = "sales_quotation";
  1907. &add_transaction;
  1908. }
  1909. sub sales_order {
  1910. $form->{script} = "oe.pl";
  1911. $form->{type} = "sales_order";
  1912. &add_transaction;
  1913. }
  1914. sub purchase_order {
  1915. $form->{script} = "oe.pl";
  1916. $form->{type} = "purchase_order";
  1917. &add_transaction;
  1918. }
  1919. sub save_as_new {
  1920. delete $form->{id};
  1921. &save;
  1922. }
  1923. sub save {
  1924. # $locale->text('Customer saved!')
  1925. # $locale->text('Vendor saved!')
  1926. $msg = ucfirst $form->{db};
  1927. $msg .= " saved!";
  1928. $form->isblank("name", $locale->text("Name missing!"));
  1929. &{ "CT::save_$form->{db}" }("", \%myconfig, \%$form);
  1930. $form->redirect($locale->text($msg));
  1931. }
  1932. sub delete {
  1933. # $locale->text('Customer deleted!')
  1934. # $locale->text('Cannot delete customer!')
  1935. # $locale->text('Vendor deleted!')
  1936. # $locale->text('Cannot delete vendor!')
  1937. CT->delete(\%myconfig, \%$form);
  1938. $msg = ucfirst $form->{db};
  1939. $msg .= " deleted!";
  1940. $form->redirect($locale->text($msg));
  1941. }
  1942. sub continue { &{ $form->{nextsub} } };
  1943. sub add_customer { &add };
  1944. sub add_vendor { &add };