/doc/tips/untrusted_git_push/

ico'/>
summaryrefslogtreecommitdiff
path: root/bin/oe.pl
blob: 642b073265fb2b0d0488d49dc389f9b2164d356a (plain)
  1. #=====================================================================
  2. # LedgerSMB Small Medium Business Accounting
  3. # http://www.ledgersmb.org/
  4. #
  5. # Copyright (C) 2006
  6. # This work contains copyrighted information from a number of sources all used
  7. # with permission.
  8. #
  9. # This file contains source code included with or based on SQL-Ledger which
  10. # is Copyright Dieter Simader and DWS Systems Inc. 2000-2005 and licensed
  11. # under the GNU General Public License version 2 or, at your option, any later
  12. # version. For a full list including contact information of contributors,
  13. # maintainers, and copyright holders, see the CONTRIBUTORS file.
  14. #
  15. # Original Copyright Notice from SQL-Ledger 2.6.17 (before the fork):
  16. # Copyright (c) 2001
  17. #
  18. # Author: DWS Systems Inc.
  19. # Web: http://www.sql-ledger.org
  20. #
  21. #
  22. # This program is free software; you can redistribute it and/or modify
  23. # it under the terms of the GNU General Public License as published by
  24. # the Free Software Foundation; either version 2 of the License, or
  25. # (at your option) any later version.
  26. #
  27. # This program is distributed in the hope that it will be useful,
  28. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  29. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  30. # GNU General Public License for more details.
  31. # You should have received a copy of the GNU General Public License
  32. # along with this program; if not, write to the Free Software
  33. # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  34. #======================================================================
  35. #
  36. # Order entry module
  37. # Quotation module
  38. #
  39. #======================================================================
  40. use LedgerSMB::OE;
  41. use LedgerSMB::IR;
  42. use LedgerSMB::IS;
  43. use LedgerSMB::PE;
  44. use LedgerSMB::Tax;
  45. use LedgerSMB::Locale;
  46. require "bin/arap.pl";
  47. require "bin/io.pl";
  48. 1;
  49. # end of main
  50. sub add {
  51. if ($form->{type} eq 'purchase_order') {
  52. $form->{title} = $locale->text('Add Purchase Order');
  53. $form->{vc} = 'vendor';
  54. }
  55. if ($form->{type} eq 'sales_order') {
  56. $form->{title} = $locale->text('Add Sales Order');
  57. $form->{vc} = 'customer';
  58. }
  59. if ($form->{type} eq 'request_quotation') {
  60. $form->{title} = $locale->text('Add Request for Quotation');
  61. $form->{vc} = 'vendor';
  62. }
  63. if ($form->{type} eq 'sales_quotation') {
  64. $form->{title} = $locale->text('Add Quotation');
  65. $form->{vc} = 'customer';
  66. }
  67. $form->{callback} = "$form->{script}?action=add&type=$form->{type}&vc=$form->{vc}&login=$form->{login}&path=$form->{path}&sessionid=$form->{sessionid}" unless $form->{callback};
  68. $form->{rowcount} = 0;
  69. &order_links;
  70. &prepare_order;
  71. &display_form;
  72. }
  73. sub edit {
  74. if ($form->{type} =~ /(purchase_order|bin_list)/) {
  75. $form->{title} = $locale->text('Edit Purchase Order');
  76. $form->{vc} = 'vendor';
  77. $form->{type} = 'purchase_order';
  78. }
  79. if ($form->{type} =~ /((sales|work)_order|(packing|pick)_list)/) {
  80. $form->{title} = $locale->text('Edit Sales Order');
  81. $form->{vc} = 'customer';
  82. $form->{type} = 'sales_order';
  83. }
  84. if ($form->{type} eq 'request_quotation') {
  85. $form->{title} = $locale->text('Edit Request for Quotation');
  86. $form->{vc} = 'vendor';
  87. }
  88. if ($form->{type} eq 'sales_quotation') {
  89. $form->{title} = $locale->text('Edit Quotation');
  90. $form->{vc} = 'customer';
  91. }
  92. &order_links;
  93. &prepare_order;
  94. &display_form;
  95. }
  96. sub order_links {
  97. # retrieve order/quotation
  98. OE->retrieve(\%myconfig, \%$form);
  99. # get customer/vendor
  100. $form->all_vc(\%myconfig, $form->{vc}, ($form->{vc} eq 'customer') ? "AR" : "AP", undef, $form->{transdate}, 1);
  101. # currencies
  102. @curr = split /:/, $form->{currencies};
  103. $form->{defaultcurrency} = $curr[0];
  104. chomp $form->{defaultcurrency};
  105. $form->{currency} = $form->{defaultcurrency} unless $form->{currency};
  106. for (@curr) { $form->{selectcurrency} .= "<option>$_\n" }
  107. $form->{oldlanguage_code} = $form->{language_code};
  108. $l{language_code} = $form->{language_code};
  109. $l{searchitems} = 'nolabor' if $form->{vc} eq 'customer';
  110. $form->get_partsgroup(\%myconfig, \%l);
  111. if (@{ $form->{all_partsgroup} }) {
  112. $form->{selectpartsgroup} = "<option>\n";
  113. foreach $ref (@ { $form->{all_partsgroup} }) {
  114. if ($ref->{translation}) {
  115. $form->{selectpartsgroup} .= qq|<option value="$ref->{partsgroup}--$ref->{id}">$ref->{translation}\n|;
  116. } else {
  117. $form->{selectpartsgroup} .= qq|<option value="$ref->{partsgroup}--$ref->{id}">$ref->{partsgroup}\n|;
  118. }
  119. }
  120. }
  121. if (@{ $form->{all_project} }) {
  122. $form->{selectprojectnumber} = "<option>\n";
  123. for (@{ $form->{all_project} }) { $form->{selectprojectnumber} .= qq|<option value="$_->{projectnumber}--$_->{id}">$_->{projectnumber}\n| }
  124. }l opt">} eq 'receipt') {
  125. $form->{ARAP} = "AR";
  126. $form->{arap} = "ar";
  127. $form->{vc} = "customer";
  128. $form->{formname} = "receipt";
  129. }
  130. if ($form->{type} eq 'check') {
  131. $form->{ARAP} = "AP";
  132. $form->{arap} = "ap";
  133. $form->{vc} = "vendor";
  134. $form->{formname} = "check";
  135. }
  136. $form->{payment} = "payments";
  137. $form->{callback} = "$form->{script}?action=$form->{action}";
  138. for (qw(path login sessionid type)) { $form->{callback} .= "&$_=$form->{$_}" }
  139. CP->paymentaccounts(\%myconfig, \%$form);
  140. if (@{ $form->{all_language} }) {
  141. $form->{selectlanguage} = "<option>\n";
  142. for (@{ $form->{all_language} }) { $form->{selectlanguage} .= qq|<option value="$_->{code}">$_->{description}\n| }
  143. }
  144. # departments
  145. if (@{ $form->{all_department} }) {
  146. $form->{selectdepartment} = "<option>\n";
  147. $form->{department} = "$form->{department}--$form->{department_id}" if $form->{department};
  148. for (@{ $form->{all_department} }) { $form->{selectdepartment} .= qq|<option value="$_->{description}--$_->{id}">$_->{description}\n| }
  149. }
  150. $form->{selectaccount} = "";
  151. $form->{"select$form->{ARAP}"} = "";
  152. for (@{ $form->{PR}{"$form->{ARAP}_paid"} }) { $form->{selectaccount} .= "<option>$_->{accno}--$_->{description}\n" }
  153. for (@{ $form->{PR}{$form->{ARAP}} }) { $form->{"select$form->{ARAP}"} .= "<option>$_->{accno}--$_->{description}\n" }
  154. # currencies
  155. @curr = split /:/, $form->{currencies};
  156. $form->{defaultcurrency} = $curr[0];
  157. chomp $form->{defaultcurrency};
  158. $form->{selectcurrency} = "";
  159. for (@curr) { $form->{selectcurrency} .= "<option>$_\n" }
  160. $form->{oldcurrency} = $form->{currency} = $form->{defaultcurrency};
  161. $form->{oldduedateto} = $form->{datepaid};
  162. $form->{media} = $myconfig{printer};
  163. $form->{format} = "pdf" unless $myconfig{printer};
  164. &payments_header;
  165. &invoices_due;
  166. &payments_footer;
  167. }
  168. sub payments_header {
  169. if ($form->{type} eq 'receipt') {
  170. $form->{title} = $locale->text('Receipts');
  171. }
  172. if ($form->{type} eq 'check') {
  173. $form->{title} = $locale->text('Payments');
  174. }
  175. for ("department") {
  176. $form->{"select$_"} = $form->unescape($form->{"select$_"});
  177. $form->{"select$_"} =~ s/ selected//;
  178. $form->{"select$_"} =~ s/(<option value="\Q$form->{$_}\E")/$1 selected/;
  179. }
  180. for ("account", "currency", "$form->{ARAP}") {
  181. $form->{"select$_"} =~ s/ selected//;
  182. $form->{"select$_"} =~ s/option>\Q$form->{$_}\E/option selected>$form->{$_}/;
  183. }
  184. if ($form->{defaultcurrency}) {
  185. $exchangerate = qq|
  186. <tr>
  187. <th align=right nowrap>|.$locale->text('Currency').qq|</th>
  188. <td><select name=currency>$form->{selectcurrency}</select></td>
  189. <input type=hidden name=selectcurrency value="$form->{selectcurrency}">
  190. <input type=hidden name=oldcurrency value=$form->{oldcurrency}>
  191. </tr>
  192. |;
  193. }
  194. if ($form->{currency} ne $form->{defaultcurrency}) {
  195. $form->{exchangerate} = $form->format_amount(\%myconfig, $form->{exchangerate});
  196. if ($form->{forex}) {
  197. $exchangerate .= qq|
  198. <tr>
  199. <th align=right nowrap>|.$locale->text('Exchange Rate').qq|</th>
  200. <td colspan=3><input type=hidden name=exchangerate size=10 value=$form->{exchangerate}>$form->{exchangerate}</td>
  201. </tr>