1 #=====================================================================
2 # SQL-Ledger Accounting
5 # Author: Dieter Simader
6 # Email: dsimader@sql-ledger.org
7 # Web: http://www.sql-ledger.org
10 # This program is free software; you can redistribute it and/or modify
11 # it under the terms of the GNU General Public License as published by
12 # the Free Software Foundation; either version 2 of the License, or
13 # (at your option) any later version.
15 # This program is distributed in the hope that it will be useful,
16 # but WITHOUT ANY WARRANTY; without even the implied warranty of
17 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 # GNU General Public License for more details.
19 # You should have received a copy of the GNU General Public License
20 # along with this program; if not, write to the Free Software
21 # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
22 #======================================================================
26 #======================================================================
42 sub add { &{ "add_$form->{type}" } };
43 sub edit { &{ "edit_$form->{type}" } };
44 sub save { &{ "save_$form->{type}" } };
45 sub delete { &{ "delete_$form->{type}" } };
59 $form->{title} = "Add";
60 $form->{charttype} = "A";
62 $form->{callback} = "$form->{script}?action=list_account&path=$form->{path}&login=$form->{login}&sessionid=$form->{sessionid}" unless $form->{callback};
72 $form->{title} = "Edit";
74 $form->{accno} =~ s/\\'/'/g;
75 $form->{accno} =~ s/\\\\/\\/g;
77 AM->get_account(\%myconfig, \%$form);
79 foreach my $item (split(/:/, $form->{link})) {
80 $form->{$item} = "checked";
91 $form->{title} = $locale->text("$form->{title} Account");
93 $checked{$form->{charttype}} = "checked";
94 $checked{"$form->{category}_"} = "checked";
95 $checked{CT_tax} = ($form->{CT_tax}) ? "" : "checked";
97 map { $form->{$_} = $form->quote($form->{$_}) } qw(accno description);
99 # this is for our parser only!
100 # type=submit $locale->text('Add Account')
101 # type=submit $locale->text('Edit Account')
108 <form method=post action=$form->{script}>
110 <input type=hidden name=id value=$form->{id}>
111 <input type=hidden name=type value=account>
113 <input type=hidden name=inventory_accno_id value=$form->{inventory_accno_id}>
114 <input type=hidden name=income_accno_id value=$form->{income_accno_id}>
115 <input type=hidden name=expense_accno_id value=$form->{expense_accno_id}>
116 <input type=hidden name=fxgain_accno_id values=$form->{fxgain_accno_id}>
117 <input type=hidden name=fxloss_accno_id values=$form->{fxloss_accno_id}>
119 <table border=0 width=100%>
121 <th class=listtop>$form->{title}</th>
128 <th align=right>|.$locale->text('Account Number').qq|</th>
129 <td><input name=accno size=20 value="$form->{accno}"></td>
132 <th align=right>|.$locale->text('Description').qq|</th>
133 <td><input name=description size=40 value="$form->{description}"></td>
136 <th align=right>|.$locale->text('Account Type').qq|</th>
140 <td><input name=category type=radio class=radio value=A $checked{A_}> |.$locale->text('Asset').qq|\n<br>
141 <input name=category type=radio class=radio value=C $checked{C_}> |.$locale->text('Contra').qq|\n<br>
142 <input name=category type=radio class=radio value=L $checked{L_}> |.$locale->text('Liability').qq|\n<br>
143 <input name=category type=radio class=radio value=Q $checked{Q_}> |.$locale->text('Equity').qq|\n<br>
144 <input name=category type=radio class=radio value=I $checked{I_}> |.$locale->text('Income').qq|\n<br>
145 <input name=category type=radio class=radio value=E $checked{E_}> |.$locale->text('Expense')
147 <td width=50> </td>
149 <input name=charttype type=radio class=radio value="H" $checked{H}> |.$locale->text('Heading').qq|<br>
150 <input name=charttype type=radio class=radio value="A" $checked{A}> |.$locale->text('Account')
159 if ($form->{charttype} eq "A") {
165 <th align=left>|.$locale->text('Is this a summary account to record').qq|</th>
167 <input name=AR type=checkbox class=checkbox value=AR $form->{AR}> |.$locale->text('AR')
168 .qq| <input name=AP type=checkbox class=checkbox value=AP $form->{AP}> |.$locale->text('AP')
169 .qq| <input name=IC type=checkbox class=checkbox value=IC $form->{IC}> |.$locale->text('Inventory')
176 <th colspan=2>|.$locale->text('Include in drop-down menus').qq|</th>
182 <th align=left>|.$locale->text('Receivables').qq|</th>
183 <th align=left>|.$locale->text('Payables').qq|</th>
184 <th align=left>|.$locale->text('Parts Inventory').qq|</th>
185 <th align=left>|.$locale->text('Service Items').qq|</th>
186 <th align=left>|.$locale->text('Labor/Overhead').qq|</th>
190 <input name=AR_amount type=checkbox class=checkbox value=AR_amount $form->{AR_amount}> |.$locale->text('Income').qq|\n<br>
191 <input name=AR_paid type=checkbox class=checkbox value=AR_paid $form->{AR_paid}> |.$locale->text('Payment').qq|\n<br>
192 <input name=AR_tax type=checkbox class=checkbox value=AR_tax $form->{AR_tax}> |.$locale->text('Tax') .qq|
195 <input name=AP_amount type=checkbox class=checkbox value=AP_amount $form->{AP_amount}> |.$locale->text('Expense/Asset').qq|\n<br>
196 <input name=AP_paid type=checkbox class=checkbox value=AP_paid $form->{AP_paid}> |.$locale->text('Payment').qq|\n<br>
197 <input name=AP_tax type=checkbox class=checkbox value=AP_tax $form->{AP_tax}> |.$locale->text('Tax') .qq|
200 <input name=IC_sale type=checkbox class=checkbox value=IC_sale $form->{IC_sale}> |.$locale->text('Income').qq|\n<br>
201 <input name=IC_cogs type=checkbox class=checkbox value=IC_cogs $form->{IC_cogs}> |.$locale->text('COGS').qq|\n<br>
202 <input name=IC_taxpart type=checkbox class=checkbox value=IC_taxpart $form->{IC_taxpart}> |.$locale->text('Tax') .qq|
205 <input name=IC_income type=checkbox class=checkbox value=IC_income $form->{IC_income}> |.$locale->text('Income').qq|\n<br>
206 <input name=IC_expense type=checkbox class=checkbox value=IC_expense $form->{IC_expense}> |.$locale->text('Expense').qq|\n<br>
207 <input name=IC_taxservice type=checkbox class=checkbox value=IC_taxservice $form->{IC_taxservice}> |.$locale->text('Tax') .qq|
211 <input name=IC_cogs type=checkbox class=checkbox value=IC_cogs $form->{IC_cogs}> |.$locale->text('COGS').qq|\n<br>
221 <th align=left>|.$locale->text('Include this account on the customer/vendor forms to flag customer/vendor as taxable?').qq|</th>
223 <input name=CT_tax type=radio class=radio value=CT_tax $form->{CT_tax}> |.$locale->text('Yes').qq|
224 <input name=CT_tax type=radio class=radio value="" $checked{CT_tax}> |.$locale->text('No')
236 <th align=right>|.$locale->text('GIFI').qq|</th>
237 <td><input name=gifi_accno size=9 value=$form->{gifi_accno}></td>
243 <td><hr size=3 noshade></td>
255 <input name=callback type=hidden value="$form->{callback}">
257 <input type=hidden name=path value=$form->{path}>
258 <input type=hidden name=login value=$form->{login}>
259 <input type=hidden name=sessionid value=$form->{sessionid}>
262 <input type=submit class=submit name=action value="|.$locale->text('Save').qq|">
267 <input type=submit class=submit name=action value="|.$locale->text('Save as new').qq|">
271 if ($form->{id} && $form->{orphaned}) {
272 print qq|<input type=submit class=submit name=action value="|.$locale->text('Delete').qq|">|;
275 if ($form->{menubar}) {
276 require "$form->{path}/menu.pl";
292 $form->isblank("accno", $locale->text('Account Number missing!'));
293 $form->isblank("category", $locale->text('Account Type missing!'));
295 # check for conflicting accounts
296 if ($form->{AR} || $form->{AP} || $form->{IC}) {
297 map { $a .= $form->{$_} } qw(AR AP IC);
298 $form->error($locale->text('Cannot set account for more than one of AR, AP or IC')) if length $a > 2;
300 map { $form->error("$form->{AR}$form->{AP}$form->{IC} ". $locale->text('account cannot be set to any other type of account')) if $form->{$_} } qw(AR_amount AR_tax AR_paid AP_amount AP_tax AP_paid IC_sale IC_cogs IC_taxpart IC_income IC_expense IC_taxservice);
303 foreach $item ("AR", "AP") {
305 map { $i++ if $form->{$_} } ("${item}_amount", "${item}_paid", "${item}_tax");
306 $form->error($locale->text('Cannot set multiple options for')." $item") if $i > 1;
310 map { $i++ if $form->{$_} } qw(IC_sale IC_cogs IC_taxpart);
311 $form->error($locale->text('Cannot set multiple options for Parts Inventory')) if $i > 1;
314 map { $i++ if $form->{$_} } qw(IC_income IC_expense IC_taxservice);
315 $form->error($locale->text('Cannot set multiple options for Service Items')) if $i > 1;
317 $form->redirect($locale->text('Account saved!')) if (AM->save_account(\%myconfig, \%$form));
318 $form->error($locale->text('Cannot save account!'));
325 CA->all_accounts(\%myconfig, \%$form);
327 $form->{title} = $locale->text('Chart of Accounts');
330 $callback = "$form->{script}?action=list_account&path=$form->{path}&login=$form->{login}&sessionid=$form->{sessionid}";
332 @column_index = qw(accno gifi_accno description debit credit link);
334 $column_header{accno} = qq|<th class=listtop>|.$locale->text('Account').qq|</a></th>|;
335 $column_header{gifi_accno} = qq|<th class=listtop>|.$locale->text('GIFI').qq|</a></th>|;
336 $column_header{description} = qq|<th class=listtop>|.$locale->text('Description').qq|</a></th>|;
337 $column_header{debit} = qq|<th class=listtop>|.$locale->text('Debit').qq|</a></th>|;
338 $column_header{credit} = qq|<th class=listtop>|.$locale->text('Credit').qq|</a></th>|;
339 $column_header{link} = qq|<th class=listtop>|.$locale->text('Link').qq|</a></th>|;
343 $colspan = $#column_index + 1;
350 <th class=listtop colspan=$colspan>$form->{title}</th>
353 <tr class=listheading>
356 map { print "$column_header{$_}\n" } @column_index;
363 $callback = $form->escape($callback);
365 foreach $ca (@{ $form->{CA} }) {
367 $ca->{debit} = " ";
368 $ca->{credit} = " ";
370 if ($ca->{amount} > 0) {
371 $ca->{credit} = $form->format_amount(\%myconfig, $ca->{amount}, 2, " ");
373 if ($ca->{amount} < 0) {
374 $ca->{debit} = $form->format_amount(\%myconfig, -$ca->{amount}, 2, " ");
377 $ca->{link} =~ s/:/<br>/og;
379 if ($ca->{charttype} eq "H") {
380 print qq|<tr class=listheading>|;
382 $column_data{accno} = qq|<th><a class=listheading href=$form->{script}?action=edit_account&id=$ca->{id}&path=$form->{path}&login=$form->{login}&sessionid=$form->{sessionid}&callback=$callback>$ca->{accno}</a></th>|;
383 $column_data{gifi_accno} = qq|<th class=listheading><a href=$form->{script}?action=edit_gifi&accno=$ca->{gifi_accno}&path=$form->{path}&login=$form->{login}&sessionid=$form->{sessionid}&callback=$callback>$ca->{gifi_accno}</a> </th>|;
384 $column_data{description} = qq|<th class=listheading>$ca->{description} </th>|;
385 $column_data{debit} = qq|<th> </th>|;
386 $column_data{credit} = qq| <th> </th>|;
387 $column_data{link} = qq|<th> </th>|;
392 <tr valign=top class=listrow$i>|;
393 $column_data{accno} = qq|<td><a href=$form->{script}?action=edit_account&id=$ca->{id}&path=$form->{path}&login=$form->{login}&sessionid=$form->{sessionid}&callback=$callback>$ca->{accno}</a></td>|;
394 $column_data{gifi_accno} = qq|<td><a href=$form->{script}?action=edit_gifi&accno=$ca->{gifi_accno}&path=$form->{path}&login=$form->{login}&sessionid=$form->{sessionid}&callback=$callback>$ca->{gifi_accno}</a> </td>|;
395 $column_data{description} = qq|<td>$ca->{description} </td>|;
396 $column_data{debit} = qq|<td align=right>$ca->{debit}</td>|;
397 $column_data{credit} = qq|<td align=right>$ca->{credit}</td>|;
398 $column_data{link} = qq|<td>$ca->{link} </td>|;
402 map { print "$column_data{$_}\n" } @column_index;
408 <tr><td colspan=$colspan><hr size=3 noshade></td></tr>
420 $form->{title} = $locale->text('Delete Account');
422 foreach $id (qw(inventory_accno_id income_accno_id expense_accno_id fxgain_accno_id fxloss_accno_id)) {
423 if ($form->{id} == $form->{$id}) {
424 $form->error($locale->text('Cannot delete default account!'));
428 $form->redirect($locale->text('Account deleted!')) if (AM->delete_account(\%myconfig, \%$form));
429 $form->error($locale->text('Cannot delete account!'));
436 @{ $form->{fields} } = qw(accno description);
437 $form->{table} = "gifi";
439 AM->gifi_accounts(\%myconfig, \%$form);
441 $form->{title} = $locale->text('GIFI');
444 $callback = "$form->{script}?action=list_gifi&path=$form->{path}&login=$form->{login}&sessionid=$form->{sessionid}";
446 @column_index = qw(accno description);
448 $column_header{accno} = qq|<th class=listheading>|.$locale->text('GIFI').qq|</a></th>|;
449 $column_header{description} = qq|<th class=listheading>|.$locale->text('Description').qq|</a></th>|;
453 $colspan = $#column_index + 1;
460 <th class=listtop colspan=$colspan>$form->{title}</th>
463 <tr class=listheading>
466 map { print "$column_header{$_}\n" } @column_index;
473 $callback = $form->escape($callback);
475 foreach $ca (@{ $form->{ALL} }) {
480 <tr valign=top class=listrow$i>|;
482 $column_data{accno} = qq|<td><a href=$form->{script}?action=edit_gifi&coa=1&accno=$ca->{accno}&path=$form->{path}&login=$form->{login}&sessionid=$form->{sessionid}&callback=$callback>$ca->{accno}</td>|;
483 $column_data{description} = qq|<td>$ca->{description} </td>|;
485 map { print "$column_data{$_}\n" } @column_index;
492 <td colspan=$colspan><hr size=3 noshade></td>
504 $form->{title} = "Add";
507 $form->{callback} = "$form->{script}?action=list_gifi&path=$form->{path}&login=$form->{login}&sessionid=$form->{sessionid}";
519 $form->{title} = "Edit";
521 AM->get_gifi(\%myconfig, \%$form);
523 $form->error($locale->text('Account does not exist!')) unless $form->{accno};
533 $form->{title} = $locale->text("$form->{title} GIFI");
535 # $locale->text('Add GIFI')
536 # $locale->text('Edit GIFI')
538 map { $form->{$_} = $form->quote($form->{$_}) } qw(accno description);
545 <form method=post action=$form->{script}>
547 <input type=hidden name=id value="$form->{accno}">
548 <input type=hidden name=type value=gifi>
552 <th class=listtop>$form->{title}</th>
559 <th align=right>|.$locale->text('GIFI').qq|</th>
560 <td><input name=accno size=20 value="$form->{accno}"></td>
563 <th align=right>|.$locale->text('Description').qq|</th>
564 <td><input name=description size=60 value="$form->{description}"></td>
570 <td colspan=2><hr size=3 noshade></td>
582 <input name=callback type=hidden value="$form->{callback}">
584 <input type=hidden name=path value=$form->{path}>
585 <input type=hidden name=login value=$form->{login}>
586 <input type=hidden name=sessionid value=$form->{sessionid}>
588 <br><input type=submit class=submit name=action value="|.$locale->text('Save').qq|">|;
592 <input type=submit class=submit name=action value="|.$locale->text('Copy to COA').qq|">
595 if ($form->{accno} && $form->{orphaned}) {
596 print qq|<input type=submit class=submit name=action value="|.$locale->text('Delete').qq|">|;
600 if ($form->{menubar}) {
601 require "$form->{path}/menu.pl";
617 $form->isblank("accno", $locale->text('GIFI missing!'));
618 AM->save_gifi(\%myconfig, \%$form);
619 $form->redirect($locale->text('GIFI saved!'));
626 $form->isblank("accno", $locale->text('GIFI missing!'));
628 AM->save_gifi(\%myconfig, \%$form);
631 $form->{gifi_accno} = $form->{accno};
633 $form->{title} = "Add";
634 $form->{charttype} = "A";
644 AM->delete_gifi(\%myconfig, \%$form);
645 $form->redirect($locale->text('GIFI deleted!'));
652 $form->{title} = "Add";
655 $form->{callback} = "$form->{script}?action=add_department&path=$form->{path}&login=$form->{login}&sessionid=$form->{sessionid}" unless $form->{callback};
663 sub edit_department {
665 $form->{title} = "Edit";
667 AM->get_department(\%myconfig, \%$form);
675 sub list_department {
677 AM->departments(\%myconfig, \%$form);
679 $href = "$form->{script}?action=list_department&direction=$form->{direction}&path=$form->{path}&login=$form->{login}&sessionid=$form->{sessionid}";
683 $form->{callback} = "$form->{script}?action=list_department&direction=$form->{direction}&path=$form->{path}&login=$form->{login}&sessionid=$form->{sessionid}";
685 $callback = $form->escape($form->{callback});
687 $form->{title} = $locale->text('Departments');
689 @column_index = qw(description cost profit);
691 $column_header{description} = qq|<th width=90%><a class=listheading href=$href>|.$locale->text('Description').qq|</a></th>|;
692 $column_header{cost} = qq|<th class=listheading nowrap>|.$locale->text('Cost Center').qq|</th>|;
693 $column_header{profit} = qq|<th class=listheading nowrap>|.$locale->text('Profit Center').qq|</th>|;
702 <th class=listtop>$form->{title}</th>
708 <tr class=listheading>
711 map { print "$column_header{$_}\n" } @column_index;
717 foreach $ref (@{ $form->{ALL} }) {
722 <tr valign=top class=listrow$i>
725 $costcenter = ($ref->{role} eq "C") ? "*" : " ";
726 $profitcenter = ($ref->{role} eq "P") ? "*" : " ";
728 $column_data{description} = qq|<td><a href=$form->{script}?action=edit_department&id=$ref->{id}&path=$form->{path}&login=$form->{login}&sessionid=$form->{sessionid}&callback=$callback>$ref->{description}</td>|;
729 $column_data{cost} = qq|<td align=center>$costcenter</td>|;
730 $column_data{profit} = qq|<td align=center>$profitcenter</td>|;
732 map { print "$column_data{$_}\n" } @column_index;
744 <td><hr size=3 noshade></td>
749 <form method=post action=$form->{script}>
751 <input name=callback type=hidden value="$form->{callback}">
753 <input type=hidden name=type value=department>
755 <input type=hidden name=path value=$form->{path}>
756 <input type=hidden name=login value=$form->{login}>
757 <input type=hidden name=sessionid value=$form->{sessionid}>
759 <input class=submit type=submit name=action value="|.$locale->text('Add Department').qq|">|;
761 if ($form->{menubar}) {
762 require "$form->{path}/menu.pl";
776 sub department_header {
778 $form->{title} = $locale->text("$form->{title} Department");
780 # $locale->text('Add Department')
781 # $locale->text('Edit Department')
783 $form->{description} = $form->quote($form->{description});
785 if (($rows = $form->numtextrows($form->{description}, 60)) > 1) {
786 $description = qq|<textarea name="description" rows=$rows cols=60 wrap=soft>$form->{description}</textarea>|;
788 $description = qq|<input name=description size=60 value="$form->{description}">|;
791 $costcenter = "checked" if $form->{role} eq "C";
792 $profitcenter = "checked" if $form->{role} eq "P";
799 <form method=post action=$form->{script}>
801 <input type=hidden name=id value=$form->{id}>
802 <input type=hidden name=type value=department>
806 <th class=listtop colspan=2>$form->{title}</th>
810 <th align=right>|.$locale->text('Description').qq|</th>
811 <td>$description</td>
815 <td><input type=radio style=radio name=role value="C" $costcenter> |.$locale->text('Cost Center').qq|
816 <input type=radio style=radio name=role value="P" $profitcenter> |.$locale->text('Profit Center').qq|
819 <td colspan=2><hr size=3 noshade></td>
827 sub save_department {
829 $form->isblank("description", $locale->text('Description missing!'));
830 AM->save_department(\%myconfig, \%$form);
831 $form->redirect($locale->text('Department saved!'));
836 sub delete_department {
838 AM->delete_department(\%myconfig, \%$form);
839 $form->redirect($locale->text('Department deleted!'));
846 $form->{title} = "Add";
848 $form->{callback} = "$form->{script}?action=add_business&path=$form->{path}&login=$form->{login}&sessionid=$form->{sessionid}" unless $form->{callback};
858 $form->{title} = "Edit";
860 AM->get_business(\%myconfig, \%$form);
864 $form->{orphaned} = 1;
872 AM->business(\%myconfig, \%$form);
874 $href = "$form->{script}?action=list_business&direction=$form->{direction}&path=$form->{path}&login=$form->{login}&sessionid=$form->{sessionid}";
878 $form->{callback} = "$form->{script}?action=list_business&direction=$form->{direction}&path=$form->{path}&login=$form->{login}&sessionid=$form->{sessionid}";
880 $callback = $form->escape($form->{callback});
882 $form->{title} = $locale->text('Type of Business');
884 @column_index = qw(description discount);
886 $column_header{description} = qq|<th width=90%><a class=listheading href=$href>|.$locale->text('Description').qq|</a></th>|;
887 $column_header{discount} = qq|<th class=listheading>|.$locale->text('Discount').qq| %</th>|;
896 <th class=listtop>$form->{title}</th>
902 <tr class=listheading>
905 map { print "$column_header{$_}\n" } @column_index;
911 foreach $ref (@{ $form->{ALL} }) {
916 <tr valign=top class=listrow$i>
919 $discount = $form->format_amount(\%myconfig, $ref->{discount} * 100, 2, " ");
921 $column_data{description} = qq|<td><a href=$form->{script}?action=edit_business&id=$ref->{id}&path=$form->{path}&login=$form->{login}&sessionid=$form->{sessionid}&callback=$callback>$ref->{description}</td>|;
922 $column_data{discount} = qq|<td align=right>$discount</td>|;
924 map { print "$column_data{$_}\n" } @column_index;
936 <td><hr size=3 noshade></td>
941 <form method=post action=$form->{script}>
943 <input name=callback type=hidden value="$form->{callback}">
945 <input type=hidden name=type value=business>
947 <input type=hidden name=path value=$form->{path}>
948 <input type=hidden name=login value=$form->{login}>
949 <input type=hidden name=sessionid value=$form->{sessionid}>
951 <input class=submit type=submit name=action value="|.$locale->text('Add Business').qq|">|;
953 if ($form->{menubar}) {
954 require "$form->{path}/menu.pl";
969 sub business_header {
971 $form->{title} = $locale->text("$form->{title} Business");
973 # $locale->text('Add Business')
974 # $locale->text('Edit Business')
976 $form->{description} = $form->quote($form->{description});
977 $form->{discount} = $form->format_amount(\%myconfig, $form->{discount} * 100);
984 <form method=post action=$form->{script}>
986 <input type=hidden name=id value=$form->{id}>
987 <input type=hidden name=type value=business>
991 <th class=listtop>$form->{title}</th>
998 <th align=right>|.$locale->text('Type of Business').qq|</th>
999 <td><input name=description size=30 value="$form->{description}"></td>
1002 <th align=right>|.$locale->text('Discount').qq| %</th>
1003 <td><input name=discount size=5 value=$form->{discount}></td>
1009 <td><hr size=3 noshade></td>
1019 $form->isblank("description", $locale->text('Description missing!'));
1020 AM->save_business(\%myconfig, \%$form);
1021 $form->redirect($locale->text('Business saved!'));
1026 sub delete_business {
1028 AM->delete_business(\%myconfig, \%$form);
1029 $form->redirect($locale->text('Business deleted!'));
1037 $form->{title} = "Add";
1039 $form->{callback} = "$form->{script}?action=add_sic&path=$form->{path}&login=$form->{login}&sessionid=$form->{sessionid}" unless $form->{callback};
1049 $form->{title} = "Edit";
1051 $form->{code} =~ s/\\'/'/g;
1052 $form->{code} =~ s/\\\\/\\/g;
1054 AM->get_sic(\%myconfig, \%$form);
1055 $form->{id} = $form->{code};
1059 $form->{orphaned} = 1;
1067 AM->sic(\%myconfig, \%$form);
1069 $href = "$form->{script}?action=list_sic&direction=$form->{direction}&oldsort=$form->{oldsort}&path=$form->{path}&login=$form->{login}&sessionid=$form->{sessionid}";
1071 $form->sort_order();
1073 $form->{callback} = "$form->{script}?action=list_sic&direction=$form->{direction}&oldsort=$form->{oldsort}&path=$form->{path}&login=$form->{login}&sessionid=$form->{sessionid}";
1075 $callback = $form->escape($form->{callback});
1077 $form->{title} = $locale->text('Standard Industrial Codes');
1079 @column_index = $form->sort_columns(qw(code description));
1081 $column_header{code} = qq|<th><a class=listheading href=$href&sort=code>|.$locale->text('Code').qq|</a></th>|;
1082 $column_header{description} = qq|<th><a class=listheading href=$href&sort=description>|.$locale->text('Description').qq|</a></th>|;
1091 <th class=listtop>$form->{title}</th>
1093 <tr height="5"></tr>
1097 <tr class=listheading>
1100 map { print "$column_header{$_}\n" } @column_index;
1106 foreach $ref (@{ $form->{ALL} }) {
1110 if ($ref->{sictype} eq 'H') {
1112 <tr valign=top class=listheading>
1114 $column_data{code} = qq|<th><a href=$form->{script}?action=edit_sic&code=$ref->{code}&path=$form->{path}&login=$form->{login}&sessionid=$form->{sessionid}&callback=$callback>$ref->{code}</th>|;
1115 $column_data{description} = qq|<th>$ref->{description}</th>|;
1119 <tr valign=top class=listrow$i>
1122 $column_data{code} = qq|<td><a href=$form->{script}?action=edit_sic&code=$ref->{code}&path=$form->{path}&login=$form->{login}&sessionid=$form->{sessionid}&callback=$callback>$ref->{code}</td>|;
1123 $column_data{description} = qq|<td>$ref->{description}</td>|;
1127 map { print "$column_data{$_}\n" } @column_index;
1139 <td><hr size=3 noshade></td>
1144 <form method=post action=$form->{script}>
1146 <input name=callback type=hidden value="$form->{callback}">
1148 <input type=hidden name=type value=sic>
1150 <input type=hidden name=path value=$form->{path}>
1151 <input type=hidden name=login value=$form->{login}>
1152 <input type=hidden name=sessionid value=$form->{sessionid}>
1154 <input class=submit type=submit name=action value="|.$locale->text('Add SIC').qq|">|;
1156 if ($form->{menubar}) {
1157 require "$form->{path}/menu.pl";
1173 $form->{title} = $locale->text("$form->{title} SIC");
1175 # $locale->text('Add SIC')
1176 # $locale->text('Edit SIC')
1178 map { $form->{$_} = $form->quote($form->{$_}) } qw(code description);
1180 $checked = ($form->{sictype} eq 'H') ? "checked" : "";
1187 <form method=post action=$form->{script}>
1189 <input type=hidden name=type value=sic>
1190 <input type=hidden name=id value="$form->{code}">
1194 <th class=listtop colspan=2>$form->{title}</th>
1196 <tr height="5"></tr>
1198 <th align=right>|.$locale->text('Code').qq|</th>
1199 <td><input name=code size=10 value="$form->{code}"></td>
1203 <th align=left><input name=sictype type=checkbox style=checkbox value="H" $checked> |.$locale->text('Heading').qq|</th>
1206 <th align=right>|.$locale->text('Description').qq|</th>
1207 <td><input name=description size=60 value="$form->{description}"></td>
1209 <td colspan=2><hr size=3 noshade></td>
1219 $form->isblank("code", $locale->text('Code missing!'));
1220 $form->isblank("description", $locale->text('Description missing!'));
1221 AM->save_sic(\%myconfig, \%$form);
1222 $form->redirect($locale->text('SIC saved!'));
1229 AM->delete_sic(\%myconfig, \%$form);
1230 $form->redirect($locale->text('SIC deleted!'));
1237 $form->{title} = "Add";
1239 $form->{callback} = "$form->{script}?action=add_language&path=$form->{path}&login=$form->{login}&sessionid=$form->{sessionid}" unless $form->{callback};
1249 $form->{title} = "Edit";
1251 $form->{code} =~ s/\\'/'/g;
1252 $form->{code} =~ s/\\\\/\\/g;
1254 AM->get_language(\%myconfig, \%$form);
1255 $form->{id} = $form->{code};
1259 $form->{orphaned} = 1;
1267 AM->language(\%myconfig, \%$form);
1269 $href = "$form->{script}?action=list_language&direction=$form->{direction}&oldsort=$form->{oldsort}&path=$form->{path}&login=$form->{login}&sessionid=$form->{sessionid}";
1271 $form->sort_order();
1273 $form->{callback} = "$form->{script}?action=list_language&direction=$form->{direction}&oldsort=$form->{oldsort}&path=$form->{path}&login=$form->{login}&sessionid=$form->{sessionid}";
1275 $callback = $form->escape($form->{callback});
1277 $form->{title} = $locale->text('Languages');
1279 @column_index = $form->sort_columns(qw(code description));
1281 $column_header{code} = qq|<th><a class=listheading href=$href&sort=code>|.$locale->text('Code').qq|</a></th>|;
1282 $column_header{description} = qq|<th><a class=listheading href=$href&sort=description>|.$locale->text('Description').qq|</a></th>|;
1291 <th class=listtop>$form->{title}</th>
1293 <tr height="5"></tr>
1297 <tr class=listheading>
1300 map { print "$column_header{$_}\n" } @column_index;
1306 foreach $ref (@{ $form->{ALL} }) {
1311 <tr valign=top class=listrow$i>
1314 $column_data{code} = qq|<td><a href=$form->{script}?action=edit_language&code=$ref->{code}&path=$form->{path}&login=$form->{login}&sessionid=$form->{sessionid}&callback=$callback>$ref->{code}</td>|;
1315 $column_data{description} = qq|<td>$ref->{description}</td>|;
1317 map { print "$column_data{$_}\n" } @column_index;
1329 <td><hr size=3 noshade></td>
1334 <form method=post action=$form->{script}>
1336 <input name=callback type=hidden value="$form->{callback}">
1338 <input type=hidden name=type value=language>
1340 <input type=hidden name=path value=$form->{path}>
1341 <input type=hidden name=login value=$form->{login}>
1342 <input type=hidden name=sessionid value=$form->{sessionid}>
1344 <input class=submit type=submit name=action value="|.$locale->text('Add Language').qq|">|;
1346 if ($form->{menubar}) {
1347 require "$form->{path}/menu.pl";
1361 sub language_header {
1363 $form->{title} = $locale->text("$form->{title} Language");
1365 # $locale->text('Add Language')
1366 # $locale->text('Edit Language')
1368 map { $form->{$_} = $form->quote($form->{$_}) } qw(code description);
1375 <form method=post action=$form->{script}>
1377 <input type=hidden name=type value=language>
1378 <input type=hidden name=id value="$form->{code}">
1382 <th class=listtop colspan=2>$form->{title}</th>
1384 <tr height="5"></tr>
1386 <th align=right>|.$locale->text('Code').qq|</th>
1387 <td><input name=code size=10 value="$form->{code}"></td>
1390 <th align=right>|.$locale->text('Description').qq|</th>
1391 <td><input name=description size=60 value="$form->{description}"></td>
1393 <td colspan=2><hr size=3 noshade></td>
1403 $form->isblank("code", $locale->text('Code missing!'));
1404 $form->isblank("description", $locale->text('Description missing!'));
1405 AM->save_language(\%myconfig, \%$form);
1406 $form->redirect($locale->text('Language saved!'));
1411 sub delete_language {
1413 AM->delete_language(\%myconfig, \%$form);
1414 $form->redirect($locale->text('Language deleted!'));
1419 sub display_stylesheet {
1421 $form->{file} = "css/$myconfig{stylesheet}";
1429 $form->{file} =~ s/^(.:)*?\/|\.\.\///g;
1430 $form->{file} =~ s/^\/*//g;
1431 $form->{file} =~ s/$userspath//;
1433 $form->error("$!: $form->{file}") unless -f $form->{file};
1435 AM->load_template(\%$form);
1437 $form->{title} = $form->{file};
1439 # if it is anything but html
1440 if ($form->{file} !~ /\.html$/) {
1441 $form->{body} = "<pre>\n$form->{body}\n</pre>";
1451 <form method=post action=$form->{script}>
1453 <input name=file type=hidden value=$form->{file}>
1454 <input name=type type=hidden value=template>
1456 <input type=hidden name=path value=$form->{path}>
1457 <input type=hidden name=login value=$form->{login}>
1458 <input type=hidden name=sessionid value=$form->{sessionid}>
1460 <input name=action type=submit class=submit value="|.$locale->text('Edit').qq|">|;
1462 if ($form->{menubar}) {
1463 require "$form->{path}/menu.pl";
1479 AM->load_template(\%$form);
1481 $form->{title} = $locale->text('Edit Template');
1482 # convert   to &nbsp;
1483 $form->{body} =~ s/ /&nbsp;/gi;
1491 <form method=post action=$form->{script}>
1493 <input name=file type=hidden value=$form->{file}>
1494 <input name=type type=hidden value=template>
1496 <input type=hidden name=path value=$form->{path}>
1497 <input type=hidden name=login value=$form->{login}>
1498 <input type=hidden name=sessionid value=$form->{sessionid}>
1500 <input name=callback type=hidden value="$form->{script}?action=display_form&file=$form->{file}&path=$form->{path}&login=$form->{login}&sessionid=$form->{sessionid}">
1502 <textarea name=body rows=25 cols=70>
1507 <input type=submit class=submit name=action value="|.$locale->text('Save').qq|">|;
1509 if ($form->{menubar}) {
1510 require "$form->{path}/menu.pl";
1527 AM->save_template(\%$form);
1528 $form->redirect($locale->text('Template saved!'));
1535 # get defaults for account numbers and last numbers
1536 AM->defaultaccounts(\%myconfig, \%$form);
1538 foreach $key (keys %{ $form->{IC} }) {
1539 foreach $accno (sort keys %{ $form->{IC}{$key} }) {
1540 $form->{account}{$key} .= ($form->{IC}{$key}{$accno}{id} == $form->{defaults}{$key}) ? "<option selected>$accno--$form->{IC}{$key}{$accno}{description}\n" : "<option>$accno--$form->{IC}{$key}{$accno}{description}\n";
1544 $form->{title} = $locale->text('System Defaults');
1551 <form method=post action=$form->{script}>
1553 <input type=hidden name=type value=defaults>
1556 <tr><th class=listtop>$form->{title}</th></tr>
1561 <th align=right>|.$locale->text('Business Number').qq|</th>
1562 <td><input name=businessnumber size=25 value="$form->{defaults}{businessnumber}"></td>
1565 <th align=right>|.$locale->text('Weight Unit').qq|</th>
1566 <td><input name=weightunit size=5 value="$form->{defaults}{weightunit}"></td>
1572 <th class=listheading>|.$locale->text('Last Numbers & Default Accounts').qq|</th>
1578 <th align=right nowrap>|.$locale->text('Inventory Account').qq|</th>
1579 <td><select name=inventory_accno>$form->{account}{IC}</select></td>
1582 <th align=right nowrap>|.$locale->text('Income Account').qq|</th>
1583 <td><select name=income_accno>$form->{account}{IC_income}</select></td>
1586 <th align=right nowrap>|.$locale->text('Expense Account').qq|</th>
1587 <td><select name=expense_accno>$form->{account}{IC_expense}</select></td>
1590 <th align=right nowrap>|.$locale->text('Foreign Exchange Gain').qq|</th>
1591 <td><select name=fxgain_accno>$form->{account}{FX_gain}</select></td>
1594 <th align=right nowrap>|.$locale->text('Foreign Exchange Loss').qq|</th>
1595 <td><select name=fxloss_accno>$form->{account}{FX_loss}</select></td>
1601 <th align=left>|.$locale->text('Enter up to 3 letters separated by a colon (i.e CAD:USD:EUR) for your native and foreign currencies').qq|</th>
1605 <input name=curr size=40 value="$form->{defaults}{curr}">
1612 <th align=right nowrap>|.$locale->text('Sales Invoice Number').qq|</th>
1613 <td><input name=sinumber size=40 value="$form->{defaults}{sinumber}"></td>
1616 <th align=right nowrap>|.$locale->text('Sales Order Number').qq|</th>
1617 <td><input name=sonumber size=40 value="$form->{defaults}{sonumber}"></td>
1620 <th align=right nowrap>|.$locale->text('Vendor Invoice Number').qq|</th>
1621 <td><input name=vinumber size=40 value="$form->{defaults}{vinumber}"></td>
1624 <th align=right nowrap>|.$locale->text('Purchase Order Number').qq|</th>
1625 <td><input name=ponumber size=40 value="$form->{defaults}{ponumber}"></td>
1628 <th align=right nowrap>|.$locale->text('Sales Quotation Number').qq|</th>
1629 <td><input name=sqnumber size=40 value="$form->{defaults}{sqnumber}"></td>
1632 <th align=right nowrap>|.$locale->text('RFQ Number').qq|</th>
1633 <td><input name=rfqnumber size=40 value="$form->{defaults}{rfqnumber}"></td>
1636 <th align=right nowrap>|.$locale->text('Partnumber').qq|</th>
1637 <td><input name=partnumber size=40 value="$form->{defaults}{partnumber}"></td>
1640 <th align=right nowrap>|.$locale->text('Employee Number').qq|</th>
1641 <td><input name=employeenumber size=40 value="$form->{defaults}{employeenumber}"></td>
1644 <th align=right nowrap>|.$locale->text('Customer Number').qq|</th>
1645 <td><input name=customernumber size=40 value="$form->{defaults}{customernumber}"></td>
1648 <th align=right nowrap>|.$locale->text('Vendor Number').qq|</th>
1649 <td><input name=vendornumber size=40 value="$form->{defaults}{vendornumber}"></td>
1655 <th class=listheading>|.$locale->text('Tax Accounts').qq|</th>
1662 <th>|.$locale->text('Rate').qq| (%)</th>
1663 <th>|.$locale->text('Number').qq|</th>
1667 foreach $accno (sort keys %{ $form->{taxrates} }) {
1668 $form->{taxrates}{$accno}{rate} = $form->format_amount(\%myconfig, $form->{taxrates}{$accno}{rate});
1672 <th align=right>$form->{taxrates}{$accno}{description}</th>
1673 <td><input name=$form->{taxrates}{$accno}{id} size=6 value=$form->{taxrates}{$accno}{rate}></td>
1674 <td><input name="taxnumber_$form->{taxrates}{$accno}{id}" value="$form->{taxrates}{$accno}{taxnumber}"></td>
1677 $form->{taxaccounts} .= "$form->{taxrates}{$accno}{id} ";
1680 chop $form->{taxaccounts};
1686 <input name=taxaccounts type=hidden value="$form->{taxaccounts}">
1688 <td><hr size=3 noshade></td>
1692 <input type=hidden name=path value=$form->{path}>
1693 <input type=hidden name=login value=$form->{login}>
1694 <input type=hidden name=sessionid value=$form->{sessionid}>
1697 <input type=submit class=submit name=action value="|.$locale->text('Save').qq|">|;
1699 if ($form->{menubar}) {
1700 require "$form->{path}/menu.pl";
1717 foreach $item (qw(mm-dd-yy mm/dd/yy dd-mm-yy dd/mm/yy dd.mm.yy yyyy-mm-dd)) {
1718 $dateformat .= ($item eq $myconfig{dateformat}) ? "<option selected>$item\n" : "<option>$item\n";
1721 foreach $item (qw(1,000.00 1000.00 1.000,00 1000,00 1'000.00)) {
1722 $numberformat .= ($item eq $myconfig{numberformat}) ? "<option selected>$item\n" : "<option>$item\n";
1725 map { $myconfig{$_} = $form->quote($myconfig{$_}) } qw(name company address signature);
1726 map { $myconfig{$_} =~ s/\\n/\r\n/g } qw(address signature);
1728 %countrycodes = User->country_codes;
1731 foreach $key (sort { $countrycodes{$a} cmp $countrycodes{$b} } keys %countrycodes) {
1732 $countrycodes .= ($myconfig{countrycode} eq $key) ? "<option selected value=$key>$countrycodes{$key}\n" : "<option value=$key>$countrycodes{$key}\n";
1734 $countrycodes = qq|<option value="">English\n$countrycodes|;
1736 opendir CSS, "css/.";
1737 @all = grep /.*\.css$/, readdir CSS;
1740 foreach $item (@all) {
1741 if ($item eq $myconfig{stylesheet}) {
1742 $selectstylesheet .= qq|<option selected>$item\n|;
1744 $selectstylesheet .= qq|<option>$item\n|;
1747 $selectstylesheet .= "<option>\n";
1749 if (%printer && $latex) {
1750 $selectprinter = "<option>\n";
1751 foreach $item (sort keys %printer) {
1752 if ($myconfig{printer} eq $item) {
1753 $selectprinter .= qq|<option value="$item" selected>$item\n|;
1755 $selectprinter .= qq|<option value="$item">$item\n|;
1761 <th align=right>|.$locale->text('Printer').qq|</th>
1762 <td><select name=printer>$selectprinter</select></td>
1767 $form->{title} = $locale->text('Edit Preferences for').qq| $form->{login}|;
1774 <form method=post action=$form->{script}>
1776 <input type=hidden name=old_password value=$myconfig{password}>
1777 <input type=hidden name=type value=preferences>
1778 <input type=hidden name=role value=$myconfig{role}>
1781 <tr><th class=listtop>$form->{title}</th></tr>
1789 <th align=right>|.$locale->text('Name').qq|</th>
1790 <td><input name=name size=20 value="$myconfig{name}"></td>
1793 <th align=right>|.$locale->text('E-mail').qq|</th>
1794 <td><input name=email size=35 value="$myconfig{email}"></td>
1797 <th align=right>|.$locale->text('Signature').qq|</th>
1798 <td><textarea name=signature rows=3 cols=35>$myconfig{signature}</textarea></td>
1801 <th align=right>|.$locale->text('Phone').qq|</th>
1802 <td><input name=tel size=14 value="$myconfig{tel}"></td>
1805 <th align=right>|.$locale->text('Fax').qq|</th>
1806 <td><input name=fax size=14 value="$myconfig{fax}"></td>
1809 <th align=right>|.$locale->text('Company').qq|</th>
1810 <td><input name=company size=35 value="$myconfig{company}"></td>
1813 <th align=right>|.$locale->text('Address').qq|</th>
1814 <td><textarea name=address rows=4 cols=35>$myconfig{address}</textarea></td>
1821 <th align=right>|.$locale->text('Password').qq|</th>
1822 <td><input type=password name=new_password size=10 value=$myconfig{password}></td>
1825 <th align=right>|.$locale->text('Confirm').qq|</th>
1826 <td><input type=password name=confirm_password size=10></td>
1829 <th align=right>|.$locale->text('Date Format').qq|</th>
1830 <td><select name=dateformat>$dateformat</select></td>
1833 <th align=right>|.$locale->text('Number Format').qq|</th>
1834 <td><select name=numberformat>$numberformat</select></td>
1837 <th align=right>|.$locale->text('Dropdown Limit').qq|</th>
1838 <td><input name=vclimit size=10 value="$myconfig{vclimit}"></td>
1841 <th align=right>|.$locale->text('Menu Width').qq|</th>
1842 <td><input name=menuwidth size=10 value="$myconfig{menuwidth}"></td>
1845 <th align=right>|.$locale->text('Language').qq|</th>
1846 <td><select name=countrycode>$countrycodes</select></td>
1849 <th align=right>|.$locale->text('Character Set').qq|</th>
1850 <td><input name=charset size=20 value="$myconfig{charset}"></td>
1853 <th align=right>|.$locale->text('Session Timeout').qq|</th>
1854 <td><input name=timeout size=10 value="$myconfig{timeout}"></td>
1857 <th align=right>|.$locale->text('Stylesheet').qq|</th>
1858 <td><select name=usestylesheet>$selectstylesheet</select></td>
1867 <td><hr size=3 noshade></td>
1871 <input type=hidden name=path value=$form->{path}>
1872 <input type=hidden name=login value=$form->{login}>
1873 <input type=hidden name=sessionid value=$form->{sessionid}>
1876 <input type=submit class=submit name=action value="|.$locale->text('Save').qq|">|;
1878 if ($form->{menubar}) {
1879 require "$form->{path}/menu.pl";
1895 $form->redirect($locale->text('Defaults saved!')) if (AM->save_defaults(\%myconfig, \%$form));
1896 $form->error($locale->text('Cannot save defaults!'));
1901 sub save_preferences {
1903 $form->{stylesheet} = $form->{usestylesheet};
1905 if ($form->{new_password} ne $form->{old_password}) {
1906 $form->error($locale->text('Password does not match!')) if $form->{new_password} ne $form->{confirm_password};
1909 $form->redirect($locale->text('Preferences saved!')) if AM->save_preferences(\%myconfig, \%$form, $memberfile, $userspath);
1910 $form->error($locale->text('Cannot save preferences!'));
1917 if ($form->{media} eq 'email') {
1918 $form->error($locale->text('No email address for')." $myconfig{name}") unless ($myconfig{email});
1920 $form->{OUT} = "$sendmail";
1924 $SIG{INT} = 'IGNORE';
1925 AM->backup(\%myconfig, \%$form, $userspath, $gzip);
1927 if ($form->{media} eq 'email') {
1928 $form->redirect($locale->text('Backup sent to').qq| $myconfig{email}|);
1937 $form->{title} = $locale->text('Audit Control');
1939 AM->closedto(\%myconfig, \%$form);
1941 if ($form->{revtrans}) {
1942 $checked{revtransY} = "checked";
1944 $checked{revtransN} = "checked";
1947 if ($form->{audittrail}) {
1948 $checked{audittrailY} = "checked";
1950 $checked{audittrailN} = "checked";
1958 <form method=post action=$form->{script}>
1960 <input type=hidden name=path value=$form->{path}>
1961 <input type=hidden name=login value=$form->{login}>
1962 <input type=hidden name=sessionid value=$form->{sessionid}>
1965 <tr><th class=listtop>$form->{title}</th></tr>
1966 <tr height="5"></tr>
1971 <th align=right>|.$locale->text('Enforce transaction reversal for all dates').qq|</th>
1972 <td><input name=revtrans class=radio type=radio value="1" $checked{revtransY}> |.$locale->text('Yes').qq| <input name=revtrans class=radio type=radio value="0" $checked{revtransN}> |.$locale->text('No').qq|</td>
1975 <th align=right>|.$locale->text('Close Books up to').qq|</th>
1976 <td><input name=closedto size=11 title="$myconfig{dateformat}" value=$form->{closedto}></td>
1979 <th align=right>|.$locale->text('Activate Audit trails').qq|</th>
1980 <td><input name=audittrail class=radio type=radio value="1" $checked{audittrailY}> |.$locale->text('Yes').qq| <input name=audittrail class=radio type=radio value="0" $checked{audittrailN}> |.$locale->text('No').qq|</td>
1983 <th align=right>|.$locale->text('Remove Audit trails up to').qq|</th>
1984 <td><input name=removeaudittrail size=11 title="$myconfig{dateformat}"></td>
1994 <input type=hidden name=nextsub value=doclose>
1996 <input type=submit class=submit name=action value="|.$locale->text('Continue').qq|">
2009 AM->closebooks(\%myconfig, \%$form);
2011 if ($form->{revtrans}) {
2012 $msg = $locale->text('Transaction reversal enforced for all dates');
2014 if ($form->{closedto}) {
2015 $msg = $locale->text('Transaction reversal enforced up to')
2016 ." ".$locale->date(\%myconfig, $form->{closedto}, 1);
2018 $msg = $locale->text('Books are open');
2023 if ($form->{audittrail}) {
2024 $msg .= $locale->text('Audit trails enabled');
2026 $msg .= $locale->text('Audit trails disabled');
2030 if ($form->{removeaudittrail}) {
2031 $msg .= $locale->text('Audit trail removed up to')
2032 ." ".$locale->date(\%myconfig, $form->{removeaudittrail}, 1);
2035 $form->redirect($msg);
2042 $form->{title} = "Add";
2044 $form->{callback} = "$form->{script}?action=add_warehouse&path=$form->{path}&login=$form->{login}&sessionid=$form->{sessionid}" unless $form->{callback};
2052 sub edit_warehouse {
2054 $form->{title} = "Edit";
2056 AM->get_warehouse(\%myconfig, \%$form);
2064 sub list_warehouse {
2066 AM->warehouses(\%myconfig, \%$form);
2068 $href = "$form->{script}?action=list_warehouse&direction=$form->{direction}&path=$form->{path}&login=$form->{login}&sessionid=$form->{sessionid}";
2070 $form->sort_order();
2072 $form->{callback} = "$form->{script}?action=list_warehouse&direction=$form->{direction}&path=$form->{path}&login=$form->{login}&sessionid=$form->{sessionid}";
2074 $callback = $form->escape($form->{callback});
2076 $form->{title} = $locale->text('Warehouses');
2078 @column_index = qw(description);
2080 $column_header{description} = qq|<th width=100%><a class=listheading href=$href>|.$locale->text('Description').qq|</a></th>|;
2089 <th class=listtop>$form->{title}</th>
2091 <tr height="5"></tr>
2095 <tr class=listheading>
2098 map { print "$column_header{$_}\n" } @column_index;
2104 foreach $ref (@{ $form->{ALL} }) {
2109 <tr valign=top class=listrow$i>
2112 $column_data{description} = qq|<td><a href=$form->{script}?action=edit_warehouse&id=$ref->{id}&path=$form->{path}&login=$form->{login}&sessionid=$form->{sessionid}&callback=$callback>$ref->{description}</td>|;
2114 map { print "$column_data{$_}\n" } @column_index;
2126 <td><hr size=3 noshade></td>
2131 <form method=post action=$form->{script}>
2133 <input name=callback type=hidden value="$form->{callback}">
2135 <input type=hidden name=type value=warehouse>
2137 <input type=hidden name=path value=$form->{path}>
2138 <input type=hidden name=login value=$form->{login}>
2139 <input type=hidden name=sessionid value=$form->{sessionid}>
2141 <input class=submit type=submit name=action value="|.$locale->text('Add Warehouse').qq|">|;
2143 if ($form->{menubar}) {
2144 require "$form->{path}/menu.pl";
2159 sub warehouse_header {
2161 $form->{title} = $locale->text("$form->{title} Warehouse");
2163 # $locale->text('Add Warehouse')
2164 # $locale->text('Edit Warehouse')
2166 $form->{description} = $form->quote($form->{description});
2168 if (($rows = $form->numtextrows($form->{description}, 60)) > 1) {
2169 $description = qq|<textarea name="description" rows=$rows cols=60 wrap=soft>$form->{description}</textarea>|;
2171 $description = qq|<input name=description size=60 value="$form->{description}">|;
2180 <form method=post action=$form->{script}>
2182 <input type=hidden name=id value=$form->{id}>
2183 <input type=hidden name=type value=warehouse>
2187 <th class=listtop colspan=2>$form->{title}</th>
2189 <tr height="5"></tr>
2191 <th align=right>|.$locale->text('Description').qq|</th>
2192 <td>$description</td>
2195 <td colspan=2><hr size=3 noshade></td>
2203 sub save_warehouse {
2205 $form->isblank("description", $locale->text('Description missing!'));
2206 AM->save_warehouse(\%myconfig, \%$form);
2207 $form->redirect($locale->text('Warehouse saved!'));
2212 sub delete_warehouse {
2214 AM->delete_warehouse(\%myconfig, \%$form);
2215 $form->redirect($locale->text('Warehouse deleted!'));
2222 AM->earningsaccounts(\%myconfig, \%$form);
2223 map { $chart .= "<option>$_->{accno}--$_->{description}" } @{ $form->{chart} };
2225 $form->{title} = $locale->text('Yearend');
2231 <form method=post action=$form->{script}>
2233 <input type=hidden name=decimalplaces value=2>
2234 <input type=hidden name=l_accno value=Y>
2238 <th class=listtop>$form->{title}</th>
2240 <tr height="5"></tr>
2245 <th align=right>|.$locale->text('Yearend').qq|</th>
2246 <td><input name=todate size=11 title="$myconfig{dateformat}" value=$todate></td>
2249 <th align=right>|.$locale->text('Reference').qq|</th>
2250 <td><input name=reference size=20 value="|.$locale->text('Yearend').qq|"></td>
2253 <th align=right>|.$locale->text('Description').qq|</th>
2254 <td><textarea name=description rows=3 cols=50 wrap=soft></textarea></td>
2257 <th align=right>|.$locale->text('Retained Earnings').qq|</th>
2258 <td><select name=accno>$chart</select></td>
2261 <th align=right>|.$locale->text('Method').qq|</th>
2262 <td><input name=method class=radio type=radio value=accrual checked> |.$locale->text('Accrual').qq| <input name=method class=radio type=radio value=cash> |.$locale->text('Cash').qq|</td>
2271 <input type=hidden name=nextsub value=generate_yearend>
2273 <input type=hidden name=path value=$form->{path}>
2274 <input type=hidden name=login value=$form->{login}>
2275 <input type=hidden name=sessionid value=$form->{sessionid}>
2277 <input class=submit type=submit name=action value="|.$locale->text('Continue').qq|">|;
2282 sub generate_yearend {
2284 $form->isblank("todate", $locale->text('Yearend date missing!'));
2286 RP->yearend_statement(\%myconfig, \%$form);
2288 $form->{transdate} = $form->{todate};
2292 $form->{rowcount} = 1;
2293 foreach $key (keys %{ $form->{I} }) {
2294 if ($form->{I}{$key}{charttype} eq "A") {
2295 $form->{"debit_$form->{rowcount}"} = $form->{I}{$key}{this};
2296 $earnings += $form->{I}{$key}{this};
2297 $form->{"accno_$form->{rowcount}"} = $key;
2298 $form->{rowcount}++;
2303 foreach $key (keys %{ $form->{E} }) {
2304 if ($form->{E}{$key}{charttype} eq "A") {
2305 $form->{"credit_$form->{rowcount}"} = $form->{E}{$key}{this} * -1;
2306 $earnings += $form->{E}{$key}{this};
2307 $form->{"accno_$form->{rowcount}"} = $key;
2308 $form->{rowcount}++;
2312 if ($earnings > 0) {
2313 $form->{"credit_$form->{rowcount}"} = $earnings;
2314 $form->{"accno_$form->{rowcount}"} = $form->{accno}
2316 $form->{"debit_$form->{rowcount}"} = $earnings * -1;
2317 $form->{"accno_$form->{rowcount}"} = $form->{accno}
2321 if (AM->post_yearend(\%myconfig, \%$form)) {
2322 $form->redirect($locale->text('Yearend posted!'));
2324 $form->error($locale->text('Yearend posting failed!'));
2326 $form->error('Nothing to do!');
2335 $myconfig{address} =~ s/\\n/<br>/g;
2336 $myconfig{dbhost} = $locale->text('localhost') unless $myconfig{dbhost};
2338 map { $form->{$_} = $myconfig{$_} } qw(charset stylesheet);
2340 $form->{title} = $locale->text('About');
2342 # create the logo screen
2352 <a href="http://www.sql-ledger.org" target=_top><img src=sql-ledger.gif border=0></a>
2353 <h1 class=login>|.$locale->text('Version').qq| $form->{version}</h1>
2356 |.$locale->text('Licensed to').qq|
2360 <br>$myconfig{address}
2366 <th align=right>|.$locale->text('User').qq|</th>
2367 <td>$myconfig{name}</td>
2370 <th align=right>|.$locale->text('Dataset').qq|</th>
2371 <td>$myconfig{dbname}</td>
2374 <th align=right>|.$locale->text('Database Host').qq|</th>
2375 <td>$myconfig{dbhost}</td>
2390 &{ $form->{nextsub} };