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