#=====================================================================
# SQL-Ledger Accounting
-# Copyright (c) 1998-2002
+# Copyright (c) 2001
#
# Author: Dieter Simader
# Email: dsimader@sql-ledger.org
# Web: http://www.sql-ledger.org
#
+# Contributors:
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
$form->{title} = "Add";
- $form->{callback} = "$form->{script}?action=add&path=$form->{path}&login=$form->{login}&password=$form->{password}" unless $form->{callback};
+ $form->{callback} = "$form->{script}?action=add&transfer=$form->{transfer}&path=$form->{path}&login=$form->{login}&sessionid=$form->{sessionid}" unless $form->{callback};
# we use this only to set a default date
GL->transaction(\%myconfig, \%$form);
- map { $chart .= "<option>$_->{accno}--$_->{description}" } @{ $form->{chart} };
- $form->{chart} = $chart;
+ map { $form->{selectaccno} .= "<option>$_->{accno}--$_->{description}\n" } @{ $form->{all_accno} };
+
+ if ($form->{all_projects}) {
+ $form->{selectprojectnumber} = "<option>\n";
+ map { $form->{selectprojectnumber} .= qq|<option value="$_->{projectnumber}--$_->{id}">$_->{projectnumber}\n| } @{ $form->{all_projects} };
+ }
+
- $form->{rowcount} = 4;
+ $form->{rowcount} = ($form->{transfer}) ? 2 : 9;
+
+ # departments
+ $form->all_departments(\%myconfig);
+ if (@{ $form->{all_departments} }) {
+ $form->{selectdepartment} = "<option>\n";
+
+ map { $form->{selectdepartment} .= qq|<option value="$_->{description}--$_->{id}">$_->{description}\n| } (@{ $form->{all_departments} });
+ }
+
&display_form;
}
GL->transaction(\%myconfig, \%$form);
- map { $chart .= "<option>$_->{accno}--$_->{description}" } @{ $form->{chart} };
- $form->{chart} = $chart;
+ map { $form->{selectaccno} .= "<option>$_->{accno}--$_->{description}\n" } @{ $form->{all_accno} };
+
+ # projects
+ if ($form->{all_projects}) {
+ $form->{selectprojectnumber} = "<option>\n";
+ map { $form->{selectprojectnumber} .= qq|<option value="$_->{projectnumber}--$_->{id}">$_->{projectnumber}\n| } @{ $form->{all_projects} };
+ }
+
+
+ # departments
+ $form->all_departments(\%myconfig);
+ if (@{ $form->{all_departments} }) {
- $form->{locked} = ($form->datetonum($form->{transdate}, \%myconfig) <= $form->datetonum($form->{closedto}, \%myconfig));
+ $form->{department} = "$form->{department}--$form->{department_id}";
+
+ $form->{selectdepartment} = "<option>\n";
+
+ map { $form->{selectdepartment} .= qq|<option value="$_->{description}--$_->{id}">$_->{description}\n| } (@{ $form->{all_departments} });
+ }
+
+ $form->{locked} = ($form->{revtrans}) ? '1' : ($form->datetonum($form->{transdate}, \%myconfig) <= $form->datetonum($form->{closedto}, \%myconfig));
+
+ # readonly
+ $form->{readonly} = 1 if $myconfig{acs} =~ /General Ledger--Add Transaction/;
$form->{title} = "Edit";
$i = 1;
foreach $ref (@{ $form->{GL} }) {
- $form->{"accno_$i"} = $ref->{accno};
- $form->{"oldprojectnumber_$i"} = $form->{"projectnumber_$i"} = $ref->{projectnumber};
- $form->{"project_id_$i"} = $ref->{project_id};
+ $form->{"accno_$i"} = "$ref->{accno}--$ref->{description}";
+
+ $form->{"projectnumber_$i"} = "$ref->{projectnumber}--$ref->{project_id}";
+ $form->{"fx_transaction_$i"} = $ref->{fx_transaction};
if ($ref->{amount} < 0) {
$form->{totaldebit} -= $ref->{amount};
- $form->{"debit_$i"} = $form->format_amount(\%myconfig, $ref->{amount} * -1, 2);
+ $form->{"debit_$i"} = $ref->{amount} * -1;
} else {
$form->{totalcredit} += $ref->{amount};
- $form->{"credit_$i"} = ($ref->{amount} > 0) ? $form->format_amount(\%myconfig, $ref->{amount}, 2) : "";
+ $form->{"credit_$i"} = $ref->{amount};
}
- &form_row($i++);
+ $i++;
}
- &form_row($i);
+ $form->{rowcount} = $i;
+
+ &display_rows;
&form_footer;
$form->{title} = $locale->text('General Ledger')." ".$locale->text('Reports');
- $form->header;
+ $form->all_departments(\%myconfig);
+ # departments
+ if (@{ $form->{all_departments} }) {
+ $form->{selectdepartment} = "<option>\n";
+
+ map { $form->{selectdepartment} .= qq|<option value="$_->{description}--$_->{id}">$_->{description}\n| } (@{ $form->{all_departments} });
+
+ $department = qq|
+ <tr>
+ <th align=right nowrap>|.$locale->text('Department').qq|</th>
+ <td colspan=3><select name=department>$form->{selectdepartment}</select></td>
+ </tr>
+|;
+ }
+
+
+ # accounting years
+ $form->{selectaccountingyear} = "<option>\n";
+ map { $form->{selectaccountingyear} .= qq|<option>$_\n| } @{ $form->{all_years} };
+ $form->{selectaccountingmonth} = "<option>\n";
+ map { $form->{selectaccountingmonth} .= qq|<option value=$_>|.$locale->text($form->{all_month}{$_}).qq|\n| } sort keys %{ $form->{all_month} };
+
+ $selectfrom = qq|
+ <tr>
+ <th align=right>|.$locale->text('Period').qq|</th>
+ <td colspan=3>
+ <select name=month>$form->{selectaccountingmonth}</select>
+ <select name=year>$form->{selectaccountingyear}</select>
+ <input name=interval class=radio type=radio value=0 checked>|.$locale->text('Current').qq|
+ <input name=interval class=radio type=radio value=1>|.$locale->text('Month').qq|
+ <input name=interval class=radio type=radio value=3>|.$locale->text('Quarter').qq|
+ <input name=interval class=radio type=radio value=12>|.$locale->text('Year').qq|
+ </td>
+ </tr>
+|;
+
+ $form->header;
+
print qq|
<body>
<th align=right>|.$locale->text('Source').qq|</th>
<td><input name=source size=20></td>
</tr>
+ $department
<tr>
<th align=right>|.$locale->text('Description').qq|</th>
<td colspan=3><input name=description size=40></td>
<tr>
<th align=right>|.$locale->text('From').qq|</th>
<td><input name=datefrom size=11 title="$myconfig{dateformat}"></td>
- <th align=right>|.$locale->text('to').qq|</th>
+ <th align=right>|.$locale->text('To').qq|</th>
<td><input name=dateto size=11 title="$myconfig{dateformat}"></td>
</tr>
+ $selectfrom
+ <tr>
+ <th align=right>|.$locale->text('Amount').qq| >=</th>
+ <td><input name=amountfrom size=11></td>
+ <th align=right>|.$locale->text('Amount').qq| <=</th>
+ <td><input name=amountto size=11></td>
+ </tr>
<tr>
<th align=right>|.$locale->text('Include in Report').qq|</th>
<td colspan=3>
<td>
<input name="category" class=radio type=radio value=X checked> |.$locale->text('All').qq|
<input name="category" class=radio type=radio value=A> |.$locale->text('Asset').qq|
+ <input name="category" class=radio type=radio value=C> |.$locale->text('Contra').qq|
<input name="category" class=radio type=radio value=L> |.$locale->text('Liability').qq|
<input name="category" class=radio type=radio value=Q> |.$locale->text('Equity').qq|
<input name="category" class=radio type=radio value=I> |.$locale->text('Income').qq|
<input type=hidden name=path value=$form->{path}>
<input type=hidden name=login value=$form->{login}>
-<input type=hidden name=password value=$form->{password}>
+<input type=hidden name=sessionid value=$form->{sessionid}>
<br>
<input class=submit type=submit name=action value="|.$locale->text('Continue').qq|">
sub generate_report {
+ $form->{sort} = "transdate" unless $form->{sort};
+
GL->all_transactions(\%myconfig, \%$form);
- $callback = "$form->{script}?action=generate_report&path=$form->{path}&login=$form->{login}&password=$form->{password}";
-
+ $href = "$form->{script}?action=generate_report&direction=$form->{direction}&oldsort=$form->{oldsort}&path=$form->{path}&login=$form->{login}&sessionid=$form->{sessionid}";
+
+ $form->sort_order();
+
+ $callback = "$form->{script}?action=generate_report&direction=$form->{direction}&oldsort=$form->{oldsort}&path=$form->{path}&login=$form->{login}&sessionid=$form->{sessionid}";
+
%acctype = ( 'A' => $locale->text('Asset'),
+ 'C' => $locale->text('Contra'),
'L' => $locale->text('Liability'),
'Q' => $locale->text('Equity'),
'I' => $locale->text('Income'),
$form->{title} .= " : ".$locale->text($acctype{$form->{category}});
}
if ($form->{accno}) {
- $callback .= "&accno=$form->{accno}";
+ $href .= "&accno=".$form->escape($form->{accno});
+ $callback .= "&accno=".$form->escape($form->{accno},1);
$option = $locale->text('Account')." : $form->{accno} $form->{account_description}";
}
if ($form->{gifi_accno}) {
- $callback .= "&gifi_accno=$form->{gifi_accno}";
+ $href .= "&gifi_accno=".$form->escape($form->{gifi_accno});
+ $callback .= "&gifi_accno=".$form->escape($form->{gifi_accno},1);
$option .= "\n<br>" if $option;
$option .= $locale->text('GIFI')." : $form->{gifi_accno} $form->{gifi_account_description}";
}
if ($form->{source}) {
- $callback .= "&source=".$form->escape($form->{source});
+ $href .= "&source=".$form->escape($form->{source});
+ $callback .= "&source=".$form->escape($form->{source},1);
$option .= "\n<br>" if $option;
$option .= $locale->text('Source')." : $form->{source}";
}
if ($form->{reference}) {
- $callback .= "&reference=".$form->escape($form->{reference});
+ $href .= "&reference=".$form->escape($form->{reference});
+ $callback .= "&reference=".$form->escape($form->{reference},1);
$option .= "\n<br>" if $option;
$option .= $locale->text('Reference')." : $form->{reference}";
}
+ if ($form->{department}) {
+ $href .= "&department=".$form->escape($form->{department});
+ $callback .= "&department=".$form->escape($form->{department},1);
+ ($department) = split /--/, $form->{department};
+ $option .= "\n<br>" if $option;
+ $option .= $locale->text('Department')." : $department";
+ }
+
if ($form->{description}) {
- $callback .= "&description=".$form->escape($form->{description});
+ $href .= "&description=".$form->escape($form->{description});
+ $callback .= "&description=".$form->escape($form->{description},1);
$option .= "\n<br>" if $option;
$option .= $locale->text('Description')." : $form->{description}";
}
if ($form->{notes}) {
- $callback .= "¬es=".$form->escape($form->{notes});
+ $href .= "¬es=".$form->escape($form->{notes});
+ $callback .= "¬es=".$form->escape($form->{notes},1);
$option .= "\n<br>" if $option;
$option .= $locale->text('Notes')." : $form->{notes}";
}
if ($form->{datefrom}) {
+ $href .= "&datefrom=$form->{datefrom}";
$callback .= "&datefrom=$form->{datefrom}";
$option .= "\n<br>" if $option;
$option .= $locale->text('From')." ".$locale->date(\%myconfig, $form->{datefrom}, 1);
}
if ($form->{dateto}) {
+ $href .= "&dateto=$form->{dateto}";
$callback .= "&dateto=$form->{dateto}";
if ($form->{datefrom}) {
$option .= " ";
} else {
$option .= "\n<br>" if $option;
}
- $option .= $locale->text('to')." ".$locale->date(\%myconfig, $form->{dateto}, 1);
+ $option .= $locale->text('To')." ".$locale->date(\%myconfig, $form->{dateto}, 1);
+ }
+
+ if ($form->{amountfrom}) {
+ $href .= "&amountfrom=$form->{amountfrom}";
+ $callback .= "&amountfrom=$form->{amountfrom}";
+ $option .= "\n<br>" if $option;
+ $option .= $locale->text('Amount')." >= ".$form->format_amount(\%myconfig, $form->{amountfrom}, 2);
+ }
+ if ($form->{amountto}) {
+ $href .= "&amountto=$form->{amountto}";
+ $callback .= "&amountto=$form->{amountto}";
+ if ($form->{amountfrom}) {
+ $option .= " <= ";
+ } else {
+ $option .= "\n<br>" if $option;
+ $option .= $locale->text('Amount')." <= ";
+ }
+ $option .= $form->format_amount(\%myconfig, $form->{amountto}, 2);
}
@columns = $form->sort_columns(qw(transdate id reference description notes source debit credit accno gifi_accno));
+ if ($form->{link} =~ /_paid/) {
+ @columns = $form->sort_columns(qw(transdate id reference description notes source cleared debit credit accno gifi_accno));
+ $form->{l_cleared} = "Y";
+ }
+
if ($form->{accno} || $form->{gifi_accno}) {
@columns = grep !/(accno|gifi_accno)/, @columns;
push @columns, "balance";
$form->{l_balance} = "Y";
}
- $href = "$callback&sort=$form->{sort}"; # needed for accno
foreach $item (@columns) {
if ($form->{"l_$item"} eq "Y") {
$callback .= "&category=$form->{category}";
$href .= "&category=$form->{category}";
- $column_header{id} = "<th><a class=listheading href=$callback&sort=id>".$locale->text('ID')."</a></th>";
- $column_header{transdate} = "<th><a class=listheading href=$callback&sort=transdate>".$locale->text('Date')."</a></th>";
- $column_header{reference} = "<th><a class=listheading href=$callback&sort=reference>".$locale->text('Reference')."</a></th>";
- $column_header{source} = "<th><a class=listheading href=$callback&sort=source>".$locale->text('Source')."</a></th>";
- $column_header{description} = "<th><a class=listheading href=$callback&sort=description>".$locale->text('Description')."</a></th>";
+ $column_header{id} = "<th><a class=listheading href=$href&sort=id>".$locale->text('ID')."</a></th>";
+ $column_header{transdate} = "<th><a class=listheading href=$href&sort=transdate>".$locale->text('Date')."</a></th>";
+ $column_header{reference} = "<th><a class=listheading href=$href&sort=reference>".$locale->text('Reference')."</a></th>";
+ $column_header{source} = "<th><a class=listheading href=$href&sort=source>".$locale->text('Source')."</a></th>";
+ $column_header{description} = "<th><a class=listheading href=$href&sort=description>".$locale->text('Description')."</a></th>";
$column_header{notes} = "<th class=listheading>".$locale->text('Notes')."</th>";
$column_header{debit} = "<th class=listheading>".$locale->text('Debit')."</th>";
$column_header{credit} = "<th class=listheading>".$locale->text('Credit')."</th>";
- $column_header{accno} = "<th><a class=listheading href=$callback&sort=accno>".$locale->text('Account')."</a></th>";
- $column_header{gifi_accno} = "<th><a class=listheading href=$callback&sort=gifi_accno>".$locale->text('GIFI')."</a></th>";
- $column_header{balance} = "<th class=listheading>".$locale->text('Balance')."</th>";
+ $column_header{accno} = "<th><a class=listheading href=$href&sort=accno>".$locale->text('Account')."</a></th>";
+ $column_header{gifi_accno} = "<th><a class=listheading href=$href&sort=gifi_accno>".$locale->text('GIFI')."</a></th>";
+ $column_header{balance} = "<th>".$locale->text('Balance')."</th>";
+ $column_header{cleared} = qq|<th>|.$locale->text('R').qq|</th>|;
$form->header;
</tr>
|;
}
+
+ # reverse href
+ $direction = ($form->{direction} eq 'ASC') ? "ASC" : "DESC";
+ $form->sort_order();
+ $href =~ s/direction=$form->{direction}/direction=$direction/;
foreach $ref (@{ $form->{GL} }) {
$column_data{id} = "<td>$ref->{id}</td>";
$column_data{transdate} = "<td>$ref->{transdate}</td>";
- $column_data{reference} = "<td><a href=$ref->{module}.pl?action=edit&id=$ref->{id}&path=$form->{path}&login=$form->{login}&password=$form->{password}&callback=$callback>$ref->{reference}</td>";
+ $column_data{reference} = "<td><a href=$ref->{module}.pl?action=edit&id=$ref->{id}&path=$form->{path}&login=$form->{login}&sessionid=$form->{sessionid}&callback=$callback>$ref->{reference}</td>";
$column_data{description} = "<td>$ref->{description} </td>";
$column_data{source} = "<td>$ref->{source} </td>";
$column_data{notes} = "<td>$ref->{notes} </td>";
$column_data{accno} = "<td><a href=$href&accno=$ref->{accno}&callback=$callback>$ref->{accno}</a></td>";
$column_data{gifi_accno} = "<td><a href=$href&gifi_accno=$ref->{gifi_accno}&callback=$callback>$ref->{gifi_accno}</a> </td>";
$column_data{balance} = "<td align=right>".$form->format_amount(\%myconfig, $form->{balance} * $ml, 2, 0)."</td>";
+ $column_data{cleared} = ($ref->{cleared}) ? "<td>*</td>" : "<td> </td>";
$i++; $i %= 2;
print "
map { $column_data{$_} = "<td> </td>" } @column_index;
- $column_data{debit} = "<th align=right>".$form->format_amount(\%myconfig, $totaldebit, 2, " ")."</th>";
- $column_data{credit} = "<th align=right>".$form->format_amount(\%myconfig, $totalcredit, 2, " ")."</th>";
- $column_data{balance} = "<th align=right>".$form->format_amount(\%myconfig, $form->{balance} * $ml, 2, 0)."</th>";
+ $column_data{debit} = "<th align=right class=listtotal>".$form->format_amount(\%myconfig, $totaldebit, 2, " ")."</th>";
+ $column_data{credit} = "<th align=right class=listtotal>".$form->format_amount(\%myconfig, $totalcredit, 2, " ")."</th>";
+ $column_data{balance} = "<th align=right class=listtotal>".$form->format_amount(\%myconfig, $form->{balance} * $ml, 2, 0)."</th>";
print qq|
<tr class=listtotal>
map { print "$column_data{$_}\n" } @column_index;
+ $i = 1;
+ if ($myconfig{acs} !~ /GL--GL/) {
+ $button{'GL--Add Transaction'}{code} = qq|<input class=submit type=submit name=action value="|.$locale->text('GL Transaction').qq|"> |;
+ $button{'GL--Add Transaction'}{order} = $i++;
+ }
+ if ($myconfig{acs} !~ /AR--AR/) {
+ $button{'AR--Add Transaction'}{code} = qq|<input class=submit type=submit name=action value="|.$locale->text('AR Transaction').qq|"> |;
+ $button{'AR--Add Transaction'}{order} = $i++;
+ $button{'AR--Sales Invoice'}{code} = qq|<input class=submit type=submit name=action value="|.$locale->text('Sales Invoice ').qq|"> |;
+ $button{'AR--Sales Invoice'}{order} = $i++;
+ }
+ if ($myconfig{acs} !~ /AP--AP/) {
+ $button{'AP--Add Transaction'}{code} = qq|<input class=submit type=submit name=action value="|.$locale->text('AP Transaction').qq|"> |;
+ $button{'AP--Add Transaction'}{order} = $i++;
+ $button{'AP--Vendor Invoice'}{code} = qq|<input class=submit type=submit name=action value="|.$locale->text('Vendor Invoice ').qq|"> |;
+ $button{'AP--Vendor Invoice'}{order} = $i++;
+ }
+
+ foreach $item (split /;/, $myconfig{acs}) {
+ delete $button{$item};
+ }
+
print qq|
</tr>
</table>
<input type=hidden name=path value=$form->{path}>
<input type=hidden name=login value=$form->{login}>
-<input type=hidden name=password value=$form->{password}>
+<input type=hidden name=sessionid value=$form->{sessionid}>
+|;
-<input class=submit type=submit name=action value="|.$locale->text('GL Transaction').qq|">
-<input class=submit type=submit name=action value="|.$locale->text('AR Transaction').qq|">
-<input class=submit type=submit name=action value="|.$locale->text('AP Transaction').qq|">
-<input class=submit type=submit name=action value="|.$locale->text('Sales Invoice').qq|">
-<input class=submit type=submit name=action value="|.$locale->text('Vendor Invoice').qq|">
+ foreach $item (sort { $a->{order} <=> $b->{order} } %button) {
+ print $item->{code};
+ }
+
+ if ($form->{menubar}) {
+ require "$form->{path}/menu.pl";
+ &menubar;
+ }
+
+ print qq|
</form>
$subtotaldebit = $form->format_amount(\%myconfig, $subtotaldebit, 2, " ");
$subtotalcredit = $form->format_amount(\%myconfig, $subtotalcredit, 2, " ");
- map { $column_data{$_} = "<td> </td>" } qw(transdate id reference source description accno);
- $column_data{debit} = "<th class=listsubtotal align=right>$subtotaldebit</td>";
- $column_data{credit} = "<th class=listsubtotal align=right>$subtotalcredit</td>";
+ map { $column_data{$_} = "<td> </td>" } @column_index;
+
+ $column_data{debit} = "<th align=right class=listsubtotal>$subtotaldebit</td>";
+ $column_data{credit} = "<th align=right class=listsubtotal>$subtotalcredit</td>";
print "<tr class=listsubtotal>";
@a = ();
$count = 0;
- @flds = (qw(accno debit credit projectnumber project_id));
+ @flds = qw(accno debit credit projectnumber);
for $i (1 .. $form->{rowcount}) {
unless (($form->{"debit_$i"} eq "") && ($form->{"credit_$i"} eq "")) {
# take accno apart
($form->{"accno_$i"}) = split(/--/, $form->{"accno_$i"});
+ map { $form->{"${_}_$i"} = $form->parse_amount(\%myconfig, $form->{"${_}_$i"}) } qw(debit credit);
push @a, {};
$j = $#a;
}
}
+
for $i (1 .. $count) {
$j = $i - 1;
map { $form->{"${_}_$i"} = $a[$j]->{$_} } @flds;
map { delete $form->{"${_}_$i"} } @flds;
}
- $form->{rowcount} = $count;
-
- &check_project;
+ $form->{rowcount} = $count + 1;
&display_form;
sub display_form {
&form_header;
+ &display_rows;
+ &form_footer;
- $form->{rowcount}++;
+}
+
+
+sub display_rows {
+
+ $form->{selectprojectnumber} = $form->unescape($form->{selectprojectnumber});
+
$form->{totaldebit} = 0;
$form->{totalcredit} = 0;
-
+
for $i (1 .. $form->{rowcount}) {
- $form->{totaldebit} += $form->parse_amount(\%myconfig, $form->{"debit_$i"});
- $form->{totalcredit} += $form->parse_amount(\%myconfig, $form->{"credit_$i"});
- &form_row($i);
- }
-
- &form_footer;
+ $form->{totaldebit} += $form->{"debit_$i"};
+ $form->{totalcredit} += $form->{"credit_$i"};
-}
+ map { $form->{"${_}_$i"} = ($form->{"${_}_$i"}) ? $form->format_amount(\%myconfig, $form->{"${_}_$i"}, 2) : "" } qw(debit credit);
+ $selectaccno = $form->{selectaccno};
+ $selectaccno =~ s/option>\Q$form->{"accno_$i"}\E/option selected>$form->{"accno_$i"}/;
-sub form_row {
- my $i = shift;
-
- my $chart = $form->{chart};
- $chart =~ s/<option>$form->{"accno_$i"}/<option selected>$form->{"accno_$i"}/;
+ if ($form->{selectprojectnumber}) {
+ $selectprojectnumber = $form->{selectprojectnumber};
+ $selectprojectnumber =~ s/(<option value="$form->{"projectnumber_$i"}")/$1 selected/;
+
+ $project = qq|
+ <td><select name="projectnumber_$i">$selectprojectnumber</select></td>|;
+ }
+
- print qq|<tr>
- <td><select name="accno_$i">$chart</select></td>
+ if ($form->{transfer}) {
+ $form->{"fx_transaction_$i"} = ($form->{"fx_transaction_$i"}) ? "checked" : "";
+ $fx_transaction = qq|
+ <td><input name="fx_transaction_$i" class=checkbox type=checkbox value=1 $form->{"fx_transaction_$i"}></td>
+|;
+ } else {
+ $fx_transaction = qq|
+ <input type=hidden name="fx_transaction_$i" value=$form->{"fx_transaction_$i"}>
+|;
+ }
+
+
+ print qq|<tr>
+ <td><select name="accno_$i">$selectaccno</select></td>
+ $fx_transaction
<td><input name="debit_$i" size=12 value=$form->{"debit_$i"}></td>
<td><input name="credit_$i" size=12 value=$form->{"credit_$i"}></td>
- <td><input name="projectnumber_$i" size=12 value="$form->{"projectnumber_$i"}">
- <input type=hidden name="project_id_$i" value=$form->{"project_id_$i"}>
- <input type=hidden name="oldprojectnumber_$i" value="$form->{"oldprojectnumber_$i"}"></td>
+ $project
</tr>
-<input type=hidden name=rowcount value=$i>
|;
+ }
+
+
+ print qq|
+<input type=hidden name=rowcount value=$form->{rowcount}>
+<input type=hidden name=selectaccno value="$form->{selectaccno}">
+<input type=hidden name=selectprojectnumber value="|.$form->escape($form->{selectprojectnumber},1).qq|">|;
}
sub form_header {
$title = $form->{title};
- $form->{title} = $locale->text("$title General Ledger Transaction");
-
+ if ($form->{transfer}) {
+ $form->{title} = $locale->text("$title Cash Transfer Transaction");
+ } else {
+ $form->{title} = $locale->text("$title General Ledger Transaction");
+ }
+
+# $locale->text('Add Cash Transfer Transaction')
+# $locale->text('Edit Cash Transfer Transaction')
# $locale->text('Add General Ledger Transaction')
# $locale->text('Edit General Ledger Transaction')
+
+
+ $form->{selectdepartment} = $form->unescape($form->{selectdepartment});
+ $form->{selectdepartment} =~ s/ selected//;
+ $form->{selectdepartment} =~ s/(<option value="\Q$form->{department}\E")/$1 selected/;
- map { $form->{$_} =~ s/"/"/g } qw(reference description chart);
+ map { $form->{$_} = $form->quote($form->{$_}) } qw(reference description notes);
if (($rows = $form->numtextrows($form->{description}, 50)) > 1) {
$description = qq|<textarea name=description rows=$rows cols=50 wrap=soft>$form->{description}</textarea>|;
} else {
$notes = qq|<input name=notes size=50 value="$form->{notes}">|;
}
+
+ $department = qq|
+ <tr>
+ <th align=right nowrap>|.$locale->text('Department').qq|</th>
+ <td><select name=department>$form->{selectdepartment}</select></td>
+ <input type=hidden name=selectdepartment value="|.$form->escape($form->{selectdepartment},1).qq|">
+ </tr>
+| if $form->{selectdepartment};
+ $project = qq|
+ <th class=listheading>|.$locale->text('Project').qq|</th>
+| if $form->{selectprojectnumber};
+
+ if ($form->{transfer}) {
+ $fx_transaction = qq|
+ <th class=listheading>|.$locale->text('FX').qq|</th>
+|;
+ }
+
$form->header;
print qq|
<input name=id type=hidden value=$form->{id}>
-<input name=chart type=hidden value="$form->{chart}">
+<input type=hidden name=transfer value=$form->{transfer}>
+
+<input type=hidden name=selectaccno value="$form->{selectaccno}">
+
<input type=hidden name=closedto value=$form->{closedto}>
<input type=hidden name=locked value=$form->{locked}>
<input type=hidden name=title value="$title">
<tr>
<th align=right>|.$locale->text('Reference').qq|</th>
<td><input name=reference size=20 value="$form->{reference}"></td>
- <td align=right>
- <table>
- <tr>
- <th align=right>|.$locale->text('Date').qq|</th>
- <td><input name=transdate size=11 title="$myconfig{dateformat}" value=$form->{transdate}></td>
- </tr>
- </table>
- </td>
+ <th align=right>|.$locale->text('Date').qq|</th>
+ <td><input name=transdate size=11 title="$myconfig{dateformat}" value=$form->{transdate}></td>
</tr>
+ $department
<tr>
<th align=right>|.$locale->text('Description').qq|</th>
- <td colspan=2>$description</td>
+ <td colspan=3>$description</td>
</tr>
<tr>
<th align=right>|.$locale->text('Notes').qq|</th>
- <td colspan=2>$notes</td>
+ <td colspan=3>$notes</td>
</tr>
</table>
</td>
<table width=100%>
<tr class=listheading>
<th class=listheading>|.$locale->text('Account').qq|</th>
+ $fx_transaction
<th class=listheading>|.$locale->text('Debit').qq|</th>
<th class=listheading>|.$locale->text('Credit').qq|</th>
- <th class=listheading>|.$locale->text('Project').qq|</th>
+ $project
</tr>
|;
$decimalplaces = ($dec > 2) ? $dec : 2;
map { $form->{$_} = $form->format_amount(\%myconfig, $form->{$_}, $decimalplaces, " ") } qw(totaldebit totalcredit);
-
+
+
+ $project = qq|
+ <th> </th>
+| if $form->{selectprojectnumber};
+
+ if ($form->{transfer}) {
+ $fx_transaction = qq|
+ <th> </th>
+|;
+ }
+
print qq|
<tr class=listtotal>
<th> </th>
+ $fx_transaction
<th class=listtotal align=right>$form->{totaldebit}</th>
<th class=listtotal align=right>$form->{totalcredit}</th>
- <th> </th>
+ $project
</tr>
</table>
</td>
<input type=hidden name=path value=$form->{path}>
<input type=hidden name=login value=$form->{login}>
-<input type=hidden name=password value=$form->{password}>
+<input type=hidden name=sessionid value=$form->{sessionid}>
<input name=callback type=hidden value="$form->{callback}">
$transdate = $form->datetonum($form->{transdate}, \%myconfig);
$closedto = $form->datetonum($form->{closedto}, \%myconfig);
- if ($form->{id}) {
- print qq|<input class=submit type=submit name=action value="|.$locale->text('Update').qq|">
+ if (! $form->{readonly}) {
+
+ if ($form->{id}) {
+ print qq|<input class=submit type=submit name=action value="|.$locale->text('Update').qq|">
|;
- if (!$form->{revtrans}) {
if (!$form->{locked}) {
print qq|
<input class=submit type=submit name=action value="|.$locale->text('Post').qq|">
<input class=submit type=submit name=action value="|.$locale->text('Delete').qq|">
|;
}
- }
- if ($transdate > $closedto) {
print qq|
- <input class=submit type=submit name=action value="|.$locale->text('Post as new').qq|">
+ <input class=submit type=submit name=action value="|.$locale->text('Post as new').qq|">
|;
- }
-
- } else {
- if ($transdate > $closedto) {
- print qq|<input class=submit type=submit name=action value="|.$locale->text('Update').qq|">
- <input class=submit type=submit name=action value="|.$locale->text('Post').qq|">|;
+
+ } else {
+ if ($transdate > $closedto) {
+ print qq|<input class=submit type=submit name=action value="|.$locale->text('Update').qq|">
+ <input class=submit type=submit name=action value="|.$locale->text('Post').qq|">|;
+ }
}
}
- print "</form>
+ if ($form->{menubar}) {
+ require "$form->{path}/menu.pl";
+ &menubar;
+ }
+
+ print "
+ </form>
</body>
</html>
<form method=post action=$form->{script}>
|;
- map { $form->{$_} =~ s/"/"/g } qw(reference description chart);
-
- foreach $key (keys %$form) {
- print qq|<input type=hidden name=$key value="$form->{$key}">\n|;
- }
-
+ $form->hide_form();
+
print qq|
<h2 class=confirm>|.$locale->text('Confirm!').qq|</h2>
$transdate = $form->datetonum($form->{transdate}, \%myconfig);
$closedto = $form->datetonum($form->{closedto}, \%myconfig);
- # check project
- &check_project;
- # this is just for the wise guys
$form->error($locale->text('Cannot post transaction for a closed period!')) if ($transdate <= $closedto);
-
- if (($errno = GL->post_transaction(\%myconfig, \%$form)) <= -1) {
- $errno *= -1;
- $err[1] = $locale->text('Cannot have a value in both Debit and Credit!');
- $err[2] = $locale->text('Debit and credit out of balance!');
- $err[3] = $locale->text('Cannot post a transaction without a value!');
+
+ # add up debits and credits
+ if (!$form->{adjustment}) {
+ for $i (1 .. $form->{rowcount}) {
+ $debit += $form->parse_amount(\%myconfig, $form->{"debit_$i"});
+ $credit += $form->parse_amount(\%myconfig, $form->{"credit_$i"});
+ }
- $form->error($err[$errno]);
+ if ($form->round_amount($debit, 2) != $form->round_amount($credit, 2)) {
+ &post_adjustment;
+ exit;
+ }
}
-
- $form->redirect($locale->text('Transaction posted!'));
+
+ $form->redirect($locale->text('Transaction posted!')) if GL->post_transaction(\%myconfig, \%$form);
+ $form->error($locale->text('Cannot post transaction!'));
}
}
+sub post_adjustment {
+
+ $form->header;
+
+ print qq|
+<body>
+
+<form method=post action=$form->{script}>
+
+<input type=hidden name=adjustment value=1>
+|;
+
+ $form->hide_form();
+
+ print qq|
+<h2 class=confirm>|.$locale->text('Warning!').qq|</h2>
+
+<h4>|.$locale->text('Out of balance transaction!').qq|</h4>
+
+<input name=action class=submit type=submit value="|.$locale->text('Post').qq|">
+</form>
+|;
+
+}
+
+