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