use SL::PE;
require "$form->{path}/arap.pl";
+require "bin/mozilla/common.pl";
1;
my $tax = 0;
my $taxaccno = "";
foreach $ref (@{ $form->{GL} }) {
- $form->{"projectnumber_$i"} = "$ref->{projectnumber}--$ref->{project_id}";
-
$j = $i - 1;
if ($tax && ($ref->{accno} eq $taxaccno)) {
$form->{"tax_$j"} = abs($ref->{amount});
}
}
+ $transdate = "";
+ foreach $key (sort keys(%{ $ref->{transdate} })) {
+ if ($key == 0) {
+ $transdate = "$ref->{transdate}{$key}";
+ } else {
+ $transdate .= "<br>$ref->{transdate}{$key}";
+ }
+ }
+
# $ref->{debit} = $form->format_amount(\%myconfig, $ref->{debit}, 2, " ");
# $ref->{credit} = $form->format_amount(\%myconfig, $ref->{credit}, 2, " ");
$column_data{id} = "<td align=right> $ref->{id} </td>";
- $column_data{transdate} =
- "<td align=center> $ref->{transdate} </td>";
+ $column_data{transdate} = "<td align=center>$transdate</td>";
$column_data{reference} =
"<td align=center><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{description} =
- "<td align=center>$ref->{description} </td>";
+ $column_data{description} = "<td align=center>$ref->{description} </td>";
$column_data{source} = "<td align=center>$ref->{source} </td>";
$column_data{notes} = "<td align=center>$ref->{notes} </td>";
$column_data{debit} = "<td align=right>$debit</td>";
<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|">|;
-
- if ($form->{menubar}) {
- require "$form->{path}/menu.pl";
- &menubar;
- }
-
- print qq|
+ . $locale->text('Vendor Invoice') . qq|">
</form>
sub update {
$lxdebug->enter_sub();
- if ($form->{transdate} ne $form->{oldtransdate}) {
- if ($form->{selectprojectnumber}) {
- $form->all_projects(\%myconfig, undef, $form->{transdate});
- if (@{ $form->{all_project} }) {
- $form->{selectprojectnumber} = "<option>\n";
- for (@{ $form->{all_project} }) {
- $form->{selectprojectnumber} .=
- qq|<option value="$_->{projectnumber}--$_->{id}">$_->{projectnumber}\n|;
- }
- $form->{selectprojectnumber} =
- $form->escape($form->{selectprojectnumber}, 1);
- }
- }
- $form->{oldtransdate} = $form->{transdate};
- }
+ $form->{oldtransdate} = $form->{transdate};
my @a = ();
my $count = 0;
my ($init) = @_;
$lxdebug->enter_sub();
- $form->{selectprojectnumber} = $form->unescape($form->{selectprojectnumber})
- if $form->{selectprojectnumber};
-
$form->{totaldebit} = 0;
$form->{totalcredit} = 0;
my $chart = $form->{chart};
$chart = $form->unquote($chart);
$form->{taxchart} = $form->unquote($form->{taxchart});
$taxchart = $form->{taxchart};
+
+ my @old_project_ids = ();
+ map({ push(@old_project_ids, $form->{"project_id_$_"})
+ if ($form->{"project_id_$_"}); } (1..$form->{"rowcount"}));
+
+ $form->get_lists("projects" => { "key" => "ALL_PROJECTS",
+ "all" => 0,
+ "old_id" => \@old_project_ids });
+
+ my %project_labels = ();
+ my @project_values = ("");
+ foreach my $item (@{ $form->{"ALL_PROJECTS"} }) {
+ push(@project_values, $item->{"id"});
+ $project_labels{$item->{"id"}} = $item->{"projectnumber"};
+ }
+
for $i (1 .. $form->{rowcount}) {
$source = qq|
. ($i + 10 + (($i - 1) * 8))
. qq|>$form->{taxchart}</select></td>|;
- # if ($form->{selectprojectnumber}) {
- # $project = qq|
- # <td><select name="projectnumber_$i">$form->{selectprojectnumber}</select></td>|;
- # }
$korrektur =
qq|<td><input type="checkbox" name="korrektur_$i" value="1" tabindex=|
. ($i + 9 + (($i - 1) * 8))
. qq|>$accno</select></td>|;
$tax = $taxchart;
$tax_selected = $form->{"taxchart_$i"};
- print(STDERR "TAX_SELCTED $tax_selected\n");
$tax =~ s/value=\"$tax_selected\"/value=\"$tax_selected\" selected/;
$tax =
qq|<td><select id="taxchart_$i" name="taxchart_$i" tabindex=|
. ($i + 10 + (($i - 1) * 8))
. qq|>$tax</select></td>|;
- # if ($form->{selectprojectnumber}) {
- # $form->{"projectnumber_$i"} = ""
- # if $form->{selectprojectnumber} !~ /$form->{"projectnumber_$i"}/;
- #
- # $project = $form->{"projectnumber_$i"};
- # $project =~ s/--.*//;
- # $project = qq|<td>$project</td>|;
- # }
-
if ($form->{transfer}) {
$checked = ($form->{"fx_transaction_$i"}) ? "1" : "";
$x = ($checked) ? "x" : "";
<td><select id="taxchart_$i" name="taxchart_$i" tabindex=|
. ($i + 10 + (($i - 1) * 8)) . qq|>$taxchart</select></td>|;
- # if ($form->{selectprojectnumber}) {
- # $project = qq|
- # <td><select name="projectnumber_$i">$form->{selectprojectnumber}</select></td>|;
- # }
$korrektur =
qq|<td><input type="checkbox" name="korrektur_$i" value="1" tabindex=|
. ($i + 9 + (($i - 1) * 8))
}
}
+ my $projectnumber =
+ NTI($cgi->popup_menu('-name' => "project_id_$i",
+ '-values' => \@project_values,
+ '-labels' => \%project_labels,
+ '-default' => $form->{"project_id_$i"} ));
+
print qq|<tr valign=top>
$accno
$fx_transaction
$tax
$source
$memo
+ <td>$projectnumber</td>
</tr>
|;
$form->hide_form(qw(rowcount selectaccno));
- # print qq|
- # <input type=hidden name=selectprojectnumber value="|
- # . $form->escape($form->{selectprojectnumber}, 1) . qq|">|;
$lxdebug->leave_sub();
}
<th class=listheading style="width:20%">|
. $locale->text('Source') . qq|</th>
<th class=listheading style="width:20%">| . $locale->text('Memo') . qq|</th>
- $project
+ <th class=listheading style="width:20%">|
+ . $locale->text('Project Number') . qq|</th>
</tr>
$jsscript
<td></td>
<th align=right class=listtotal> $form->{totaldebit}</th>
<th align=right class=listtotal> $form->{totalcredit}</th>
- <td colspan=5></td>
+ <td colspan=6></td>
</tr>
</table>
</td>
}
}
- if ($form->{menubar}) {
- require "$form->{path}/menu.pl";
- &menubar;
- }
-
print "
</form>
$transdate = $form->datetonum($form->{transdate}, \%myconfig);
$closedto = $form->datetonum($form->{closedto}, \%myconfig);
- # check project
- &check_project;
-
my @a = ();
my $count = 0;
my $debittax = 0;
if ($form->round_amount($debit, 2) != $form->round_amount($credit, 2)) {
$form->error($locale->text('Out of balance transaction!'));
}
+
+ if ($form->round_amount($debit, 2) + $form->round_amount($credit, 2) == 0) {
+ $form->error($locale->text('Empty transaction!'));
+ }
+
if (($errno = GL->post_transaction(\%myconfig, \%$form)) <= -1) {
$errno *= -1;
$err[1] = $locale->text('Cannot have a value in both Debit and Credit!');