/packaging/

ml'/>
summaryrefslogtreecommitdiff
path: root/bin/mozilla/pos.pl
blob: 1c5c34063cc189e02d28b259862cd375b3c90d9b (plain)
  1. #=====================================================================
  2. # LedgerSMB Small Medium Business Accounting
  3. # http://sourceforge.net/projects/ledger-smb/
  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) 2003
  17. #
  18. # Author: DWS Systems Inc.
  19. # Web: http://www.sql-ledger.org
  20. #
  21. # Contributors: Steve Doerr <sdoerr907@everestkc.net>
  22. #
  23. #
  24. # This program is free software; you can redistribute it and/or modify
  25. # it under the terms of the GNU General Public License as published by
  26. # the Free Software Foundation; either version 2 of the License, or
  27. # (at your option) any later version.
  28. #
  29. # This program is distributed in the hope that it will be useful,
  30. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  31. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  32. # GNU General Public License for more details.
  33. # You should have received a copy of the GNU General Public License
  34. # along with this program; if not, write to the Free Software
  35. # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  36. #=====================================================================
  37. #
  38. # POS
  39. #
  40. #=====================================================================
  41. 1;
  42. # end
  43. sub add {
  44. $form->{title} = $locale->text('Add POS Invoice');
  45. $form->{callback} = "$form->{script}?action=$form->{nextsub}&path=$form->{path}&login=$form->{login}&sessionid=$form->{sessionid}" unless $form->{callback};
  46. &invoice_links;
  47. $form->{type} = "pos_invoice";
  48. $form->{format} = "txt";
  49. $form->{media} = ($myconfig{printer}) ? $myconfig{printer} : "screen";
  50. $form->{rowcount} = 0;
  51. $form->{readonly} = ($myconfig{acs} =~ /POS--Sale/) ? 1 : 0;
  52. $ENV{REMOTE_ADDR} =~ /(\d+)\.(\d+)\.(\d+)\.(\d+)/;
  53. $form->{till} = $4;
  54. $form->{partsgroup} = "";
  55. for (@{ $form->{all_partsgroup} }) { $form->{partsgroup} .= "$_->{partsgroup}--$_->{translation}\n"; }
  56. &display_form;
  57. }
  58. sub openinvoices {
  59. $ENV{REMOTE_ADDR} =~ /(\d+)\.(\d+)\.(\d+)\.(\d+)/;
  60. $form->{till} = $4;
  61. $form->{sort} = 'transdate';
  62. for (qw(open l_invnumber l_transdate l_name l_amount l_curr l_till l_subtotal)) { $form->{$_} = 'Y'; }
  63. if ($myconfig{role} ne 'user') {
  64. $form->{l_employee} = 'Y';
  65. }
  66. $form->{title} = $locale->text('Open');
  67. transactions;
  68. }
  69. sub edit {
  70. $form->{title} = $locale->text('Edit POS Invoice');
  71. $form->{callback} = "$form->{script}?action=$form->{nextsub}&path=$form->{path}&login=$form->{login}&sessionid=$form->{sessionid}" unless $form->{callback};
  72. &invoice_links;
  73. &prepare_invoice;
  74. $form->{type} = "pos_invoice";
  75. $form->{format} = "txt";
  76. $form->{media} = ($myconfig{printer}) ? $myconfig{printer} : "screen";
  77. $form->{readonly} = ($myconfig{acs} =~ /POS--Sale/) ? 1 : 0;
  78. $form->{partsgroup} = "";
  79. for (@{ $form->{all_partsgroup} }) { $form->{partsgroup} .= "$_->{partsgroup}--$_->{translation}\n"; }
  80. &display_form;
  81. }
  82. sub form_header {
  83. # set option selected
  84. for (qw(AR currency)) {
  85. $form->{"select$_"} =~ s/ selected//;
  86. $form->{"select$_"} =~ s/option>\Q$form->{$_}\E/option selected>$form->{$_}/;
  87. }
  88. for (qw(customer department employee)) {
  89. $form->{"select$_"} = $form->unescape($form->{"select$_"});
  90. $form->{"select$_"} =~ s/ selected//;
  91. $form->{"select$_"} =~ s/(<option value="\Q$form->{$_}\E")/$1 selected/;
  92. }
  93. $form->{exchangerate} = $form->format_amount(\%myconfig, $form->{exchangerate});
  94. $exchangerate = qq|<tr>|;
  95. $exchangerate .= qq|
  96. <th align=right nowrap>|.$locale->text('Currency').qq|</th>
  97. <td><select name=currency>$form->{selectcurrency}</select></td> | if $form->{defaultcurrency};
  98. $exchangerate .= qq|
  99. <input type=hidden name=selectcurrency value="$form->{selectcurrency}">
  100. <input type=hidden name=defaultcurrency value=$form->{defaultcurrency}>
  101. |;
  102. if ($form->{defaultcurrency} && $form->{currency} ne $form->{defaultcurrency}) {
  103. if ($form->{forex}) {
  104. $exchangerate .= qq|<th align=right>|.$locale->text('Exchange Rate').qq|</th><td>$form->{exchangerate}<input type=hidden name=exchangerate value=$form->{exchangerate}></td>|;
  105. } else {
  106. $exchangerate .= qq|<th align=right>|.$locale->text('Exchange Rate').qq|</th><td><input name=exchangerate size=10 value=$form->{exchangerate}></td>|;
  107. }
  108. }
  109. $exchangerate .= qq|
  110. <input type=hidden name=forex value=$form->{forex}>
  111. </tr>
  112. |;
  113. if ($form->{selectcustomer}) {
  114. $customer = qq|<select name=customer>$form->{selectcustomer}</select>
  115. <input type=hidden name="selectcustomer" value="|.
  116. $form->escape($form->{selectcustomer},1).qq|">|;
  117. } else {
  118. $customer = qq|<input name=customer value="$form->{customer}" size=35>|;
  119. }
  120. $department = qq|
  121. <tr>
  122. <th align="right" nowrap>|.$locale->text('Department').qq|</th>
  123. <td colspan=3><select name=department>$form->{selectdepartment}</select>
  124. <input type=hidden name=selectdepartment value="|.
  125. $form->escape($form->{selectdepartment},1).qq|">
  126. </td>
  127. </tr>
  128. | if $form->{selectdepartment};
  129. $employee = qq|
  130. <tr>
  131. <th align=right nowrap>|.$locale->text('Salesperson').qq|</th>
  132. <td colspan=3><select name=employee>$form->{selectemployee}</select></td>
  133. <input type=hidden name=selectemployee value="|.
  134. $form->escape($form->{selectemployee},1).qq|">
  135. </tr>
  136. | if $form->{selectemployee};
  137. if ($form->{change} != $form->{oldchange}) {
  138. $form->{creditremaining} -= $form->{oldchange};
  139. }
  140. $n = ($form->{creditremaining} < 0) ? "0" : "1";
  141. if ($form->{business}) {
  142. $business = qq|
  143. <tr>
  144. <th align=right nowrap>|.$locale->text('Business').qq|</th>
  145. <td>$form->{business}</td>
  146. <td width=10></td>
  147. <th align=right nowrap>|.$locale->text('Trade Discount').qq|</th>
  148. <td>|.$form->format_amount(\%myconfig, $form->{tradediscount} * 100).qq| %</td>
  149. </tr>
  150. |;
  151. }
  152. if ($form->{selectlanguage}) {
  153. if ($form->{language_code} ne $form->{oldlanguage_code}) {
  154. # rebuild partsgroup
  155. $form->get_partsgroup(\%myconfig, { language_code => $form->{language_code}, searchitems => 'nolabor'});
  156. $form->{partsgroup} = "";
  157. for (@{ $form->{all_partsgroup} }) { $form->{partsgroup} .= "$_->{partsgroup}--$_->{translation}\n"; }
  158. $form->{oldlanguage_code} = $form->{language_code};
  159. }
  160. $form->{"selectlanguage"} = $form->unescape($form->{"selectlanguage"});
  161. $form->{"selectlanguage"} =~ s/ selected//;
  162. $form->{"selectlanguage"} =~ s/(<option value="\Q$form->{language_code}\E")/$1 selected/;
  163. $lang = qq|
  164. <tr>
  165. <th align=right>|.$locale->text('Language').qq|</th>
  166. <td colspan=3><select name=language_code>$form->{selectlanguage}</select></td>
  167. </tr>
  168. <input type=hidden name=oldlanguage_code value=$form->{oldlanguage_code}>
  169. <input type=hidden name=selectlanguage value="|.
  170. $form->escape($form->{selectlanguage},1).qq|">|;
  171. }
  172. $i = $form->{rowcount} + 1;
  173. $focus = "partnumber_$i";
  174. $form->header;
  175. print qq|
  176. <body onLoad="document.forms[0].${focus}.focus()" />
  177. <form method=post action="$form->{script}">
  178. |;
  179. $form->hide_form(qw(id till type format printed title discount creditlimit creditremaining tradediscount business closedto locked oldtransdate customer_id oldcustomer));
  180. print qq|
  181. <input type=hidden name=vc value="customer">
  182. <table width=100%>
  183. <tr class=listtop>
  184. <th class=listtop>$form->{title}</font></th>
  185. </tr>
  186. <tr height="5"></tr>
  187. <tr>
  188. <td>
  189. <table width=100%>
  190. <tr valign=top>
  191. <td>
  192. <table>
  193. <tr>
  194. <th align=right nowrap>|.$locale->text('Customer').qq|</th>
  195. <td colspan=3>$customer</td>
  196. </tr>
  197. <tr>
  198. <td></td>
  199. <td colspan=3>
  200. <table>
  201. <tr>
  202. <th align=right nowrap>|.$locale->text('Credit Limit').qq|</th>
  203. <td>$form->{creditlimit}</td>
  204. <td width=10></td>
  205. <th align=right nowrap>|.$locale->text('Remaining').qq|</th>
  206. <td class="plus$n">|.$form->format_amount(\%myconfig, $form->{creditremaining}, 0, "0").qq|</font></td>
  207. </tr>
  208. $business
  209. </table>
  210. </td>
  211. </tr>
  212. <tr>
  213. <th align=right nowrap>|.$locale->text('Record in').qq|</th>
  214. <td colspan=3><select name=AR>$form->{selectAR}</select></td>
  215. <input type=hidden name=selectAR value="$form->{selectAR}">
  216. </tr>
  217. $department
  218. </table>
  219. </td>
  220. <td>
  221. <table>
  222. $employee
  223. $exchangerate
  224. $lang
  225. </table>
  226. </td>
  227. </tr>
  228. </table>
  229. </td>
  230. </tr>
  231. <tr>
  232. <td>
  233. </td>
  234. </tr>
  235. |;
  236. $form->hide_form(qw(taxaccounts duedate invnumber transdate selectcurrency defaultcurrency));
  237. for (split / /, $form->{taxaccounts}) {
  238. $form->hide_form("${_}_rate", "${_}_description", "${_}_taxnumber");
  239. }
  240. }
  241. sub form_footer {
  242. $form->{invtotal} = $form->{invsubtotal};
  243. $form->{taxincluded} = ($form->{taxincluded}) ? "checked" : "";
  244. $taxincluded = "";
  245. if ($form->{taxaccounts}) {
  246. $taxincluded = qq|
  247. <tr height="5"></tr>
  248. <tr>
  249. <td align=right>
  250. <input name=taxincluded class=checkbox type=checkbox value=1 $form->{taxincluded}></td><th align=left>|.$locale->text('Tax Included').qq|</th>
  251. </tr>
  252. |;
  253. }
  254. if (!$form->{taxincluded}) {
  255. for (split / /, $form->{taxaccounts}) {
  256. if ($form->{"${_}_base"}) {
  257. $form->{"${_}_total"} = $form->round_amount($form->{"${_}_base"} * $form->{"${_}_rate"}, 2);
  258. $form->{invtotal} += $form->{"${_}_total"};
  259. $form->{"${_}_total"} = $form->format_amount(\%myconfig, $form->{"${_}_total"}, 2, 0);
  260. $tax .= qq|
  261. <tr>
  262. <th align=right>$form->{"${_}_description"}</th>
  263. <td align=right>$form->{"${_}_total"}</td>
  264. </tr>
  265. |;
  266. }
  267. }