$main::lxdebug->leave_sub();
}
+sub lead {
+ $main::lxdebug->enter_sub();
+
+ my ($self, $myconfig, $form) = @_;
+
+ # connect to database
+ my $dbh = $form->dbconnect($myconfig);
+
+ my $query = qq|SELECT id, lead
+ FROM leads
+ ORDER BY 2|;
+
+ $sth = $dbh->prepare($query);
+ $sth->execute || $form->dberror($query);
+
+ while (my $ref = $sth->fetchrow_hashref(NAME_lc)) {
+ push @{ $form->{ALL} }, $ref;
+ }
+
+ $sth->finish;
+ $dbh->disconnect;
+
+ $main::lxdebug->leave_sub();
+}
+
+sub get_lead {
+ $main::lxdebug->enter_sub();
+
+ my ($self, $myconfig, $form) = @_;
+
+ # connect to database
+ my $dbh = $form->dbconnect($myconfig);
+
+ my $query =
+ qq|SELECT l.id, l.lead
+ FROM leads l
+ WHERE l.id = $form->{id}|;
+ my $sth = $dbh->prepare($query);
+ $sth->execute || $form->dberror($query);
+
+ my $ref = $sth->fetchrow_hashref(NAME_lc);
+
+ map { $form->{$_} = $ref->{$_} } keys %$ref;
+
+ $sth->finish;
+
+ $dbh->disconnect;
+
+ $main::lxdebug->leave_sub();
+}
+
+sub save_lead {
+ $main::lxdebug->enter_sub();
+
+ my ($self, $myconfig, $form) = @_;
+
+ # connect to database
+ my $dbh = $form->dbconnect($myconfig);
+
+ $form->{lead} =~ s/\'/\'\'/g;
+
+ # id is the old record
+ if ($form->{id}) {
+ $query = qq|UPDATE leads SET
+ lead = '$form->{description}'
+ WHERE id = $form->{id}|;
+ } else {
+ $query = qq|INSERT INTO leads
+ (lead)
+ VALUES ('$form->{description}')|;
+ }
+ $dbh->do($query) || $form->dberror($query);
+
+ $dbh->disconnect;
+
+ $main::lxdebug->leave_sub();
+}
+
+sub delete_lead {
+ $main::lxdebug->enter_sub();
+
+ my ($self, $myconfig, $form) = @_;
+
+ # connect to database
+ my $dbh = $form->dbconnect($myconfig);
+
+ $query = qq|DELETE FROM leads
+ WHERE id = $form->{id}|;
+ $dbh->do($query) || $form->dberror($query);
+
+ $dbh->disconnect;
+
+ $main::lxdebug->leave_sub();
+}
+
sub business {
$main::lxdebug->enter_sub();
$sth->finish;
}
+
+ $query = "SELECT inventory_accno_id FROM defaults";
+ ($form->{"std_inventory_accno_id"}) = $dbh->selectrow_array($query);
+
my $module = "IC";
$query = qq|SELECT c.accno, c.description, c.link, c.id,
d.inventory_accno_id, d.income_accno_id, d.expense_accno_id
my $sth = $dbh->prepare($query);
$sth->execute || $form->dberror($query);
while (my $ref = $sth->fetchrow_hashref(NAME_lc)) {
- foreach my $key (split /:/, $ref->{link}) {
+ foreach my $key (split(/:/, $ref->{link})) {
+ if (!$form->{"std_inventory_accno_id"} && ($key eq "IC")) {
+ $form->{"std_inventory_accno_id"} = $ref->{"id"};
+ }
if ($key =~ /$module/) {
if ( ($ref->{id} eq $ref->{inventory_accno_id})
|| ($ref->{id} eq $ref->{income_accno_id})
description => $ref->{description},
selected => "selected",
id => $ref->{id} };
- } else {
+ } else {
push @{ $form->{"${module}_links"}{$key} },
{ accno => $ref->{accno},
description => $ref->{description},
$main::lxdebug->leave_sub();
}
-sub adr {
- $main::lxdebug->enter_sub();
-
- my ($self, $myconfig, $form) = @_;
-
- # connect to database
- my $dbh = $form->dbconnect($myconfig);
-
- my $query = qq|SELECT id, adr_description, adr_code
- FROM adr
- ORDER BY adr_code|;
-
- $sth = $dbh->prepare($query);
- $sth->execute || $form->dberror($query);
-
- while (my $ref = $sth->fetchrow_hashref(NAME_lc)) {
- push @{ $form->{ALL} }, $ref;
- }
-
- $sth->finish;
- $dbh->disconnect;
-
- $main::lxdebug->leave_sub();
-}
-
-sub get_adr {
- $main::lxdebug->enter_sub();
-
- my ($self, $myconfig, $form) = @_;
-
- # connect to database
- my $dbh = $form->dbconnect($myconfig);
-
- my $query =
- qq|SELECT a.adr_description, a.adr_code
- FROM adr a
- WHERE a.id = $form->{id}|;
- my $sth = $dbh->prepare($query);
- $sth->execute || $form->dberror($query);
-
- my $ref = $sth->fetchrow_hashref(NAME_lc);
-
- map { $form->{$_} = $ref->{$_} } keys %$ref;
-
- $sth->finish;
-
- $dbh->disconnect;
-
- $main::lxdebug->leave_sub();
-}
-
-sub save_adr {
- $main::lxdebug->enter_sub();
-
- my ($self, $myconfig, $form) = @_;
-
- # connect to database
- my $dbh = $form->dbconnect($myconfig);
-
- $form->{adr_description} =~ s/\'/\'\'/g;
- $form->{adr_code} =~ s/\'/\'\'/g;
-
-
- # id is the old record
- if ($form->{id}) {
- $query = qq|UPDATE adr SET
- adr_description = '$form->{adr_description}',
- adr_code = '$form->{adr_code}'
- WHERE id = $form->{id}|;
- } else {
- $query = qq|INSERT INTO adr
- (adr_description, adr_code)
- VALUES ('$form->{adr_description}', '$form->{adr_code}')|;
- }
- $dbh->do($query) || $form->dberror($query);
-
- $dbh->disconnect;
-
- $main::lxdebug->leave_sub();
-}
-
-sub delete_adr {
- $main::lxdebug->enter_sub();
-
- my ($self, $myconfig, $form) = @_;
-
- # connect to database
- my $dbh = $form->dbconnect($myconfig);
-
- $query = qq|DELETE FROM adr
- WHERE id = $form->{id}|;
- $dbh->do($query) || $form->dberror($query);
-
- $dbh->disconnect;
-
- $main::lxdebug->leave_sub();
-}
-
sub payment {
$main::lxdebug->enter_sub();
my ($self, $myconfig, $form, $memberfile, $userspath, $webdav) = @_;
- map { ($form->{$_}) = split /--/, $form->{$_} }
+ map { ($form->{$_}) = split(/--/, $form->{$_}) }
qw(inventory_accno income_accno expense_accno fxgain_accno fxloss_accno);
my @a;
$form->{curr} =~ s/ //g;
- map { push(@a, uc pack "A3", $_) if $_ } split /:/, $form->{curr};
+ map { push(@a, uc pack "A3", $_) if $_ } split(/:/, $form->{curr});
$form->{curr} = join ':', @a;
# connect to database
WHERE login = '$form->{login}'|;
$dbh->do($query) || $form->dberror($query);
- foreach my $item (split / /, $form->{taxaccounts}) {
+ foreach my $item (split(/ /, $form->{taxaccounts})) {
$query = qq|UPDATE tax
SET rate = | . ($form->{$item} / 100) . qq|,
taxnumber = '$form->{"taxnumber_$item"}'
$query = qq|UPDATE defaults SET closedto = NULL,
revtrans = '1'|;
- } else {
- if ($form->{closedto}) {
+ } elsif ($form->{closedto}) {
- $query = qq|UPDATE defaults SET closedto = '$form->{closedto}',
+ $query = qq|UPDATE defaults SET closedto = '$form->{closedto}',
revtrans = '0'|;
- } else {
+ } else {
- $query = qq|UPDATE defaults SET closedto = NULL,
+ $query = qq|UPDATE defaults SET closedto = NULL,
revtrans = '0'|;
- }
}
# set close in defaults