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