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