Skip to content

Commit

Permalink
Merge pull request #7547 from ehuelsmann/cleanup/shipto
Browse files Browse the repository at this point in the history
Move 'shipto' to io.pl
  • Loading branch information
ehuelsmann committed Jul 26, 2023
2 parents cfd8914 + 26463ce commit b9136f3
Show file tree
Hide file tree
Showing 2 changed files with 162 additions and 172 deletions.
177 changes: 162 additions & 15 deletions old/bin/io.pl
Expand Up @@ -1600,7 +1600,7 @@ sub ship_to {

&{"$form->{vc}_details"};

&list_locations_contacts();
list_locations_contacts( \%myconfig, \%$form );

$number =
( $form->{vc} eq 'customer' )
Expand Down Expand Up @@ -1871,18 +1871,6 @@ sub ship_to {
=cut



sub list_locations_contacts
{


IS->list_locations_contacts( \%myconfig, \%$form );


}



sub construct_countrys_types
{

Expand All @@ -1891,13 +1879,13 @@ sub construct_countrys_types
if($_[0] eq "country")
{

$retvalue=IS->construct_countrys(\%$form);
$retvalue=construct_countrys(\%$form);

}
elsif($_[0] eq "type")
{

$retvalue=IS->construct_types(\%$form);
$retvalue=construct_types(\%$form);

}
return($retvalue);
Expand Down Expand Up @@ -1992,4 +1980,163 @@ sub setlocation_id
$form->{"shiptolocationid"}=$form->{$index};
}


sub list_locations_contacts
{

my ( $myconfig, $form ) = @_;



my $dbh = $form->{dbh};

# get rest for the customer
my $query = qq|
WITH eca AS (select * from entity_credit_account
where id = ?
)
select id as shiptolocationid,line_one as shiptoaddress1,line_two as shiptoaddress2,line_three as shiptoaddress3,city as shiptocity,
state as shiptostate,mail_code as shiptozipcode,country as shiptocountry
from (
select (eca__list_locations(id)).*
FROM eca
UNION
SELECT (entity__list_locations(entity_id)).*
FROM eca
) l
WHERE location_class = 3;
|;



my $sth = $dbh->prepare($query);

$sth->execute( $form->{customer_id} ) || $form->dberror($query);

my $i=0;

while($ref = $sth->fetchrow_hashref(NAME_lc))
{
$i++;
for ( keys %$ref )
{
$form->{"$_\_$i"} = $ref->{$_};
}

}

$form->{totallocations}=$i;

$sth->finish();






$query = qq|
select c.class as shiptotype,ec.contact as shiptocontact,ec.description as shiptodescription
from eca_to_contact ec
join contact_class c on(c.id=ec.contact_class_id)
where ec.credit_id=?;
|;



$sth = $dbh->prepare($query);

$sth->execute( $form->{customer_id} ) || $form->dberror($query);

$i=0;

while($ref = $sth->fetchrow_hashref(NAME_lc))
{
$i++;
for ( keys %$ref )
{
$form->{"$_\_$i"} = $ref->{$_};
}

}

$form->{totalcontacts}=$i;

$sth->finish();

# for ( keys %$ref ) { $form->{$_} = $ref->{$_} }
}


sub construct_countrys
{


my ( $form ) = @_;

my $dbh = $form->{dbh};


my $query = qq|
select id,name from location_list_country();
|;



my $sth = $dbh->prepare($query);

$sth->execute() || $form->dberror($query);

my $returnvalue=qq|<option value=""></option>|;

while(my $ref = $sth->fetchrow_hashref(NAME_lc))
{

$returnvalue.=qq|<option value="$ref->{id} ">$ref->{name}</option>|;

}


$sth->finish();

return($returnvalue);

}


sub construct_types
{


my ( $form ) = @_;

my $dbh = $form->{dbh};


my $query = qq|
select id,class from contact_class;
|;



my $sth = $dbh->prepare($query);

$sth->execute() || $form->dberror($query);

my $returnvalue=qq|<option value=""></option>|;

while(my $ref = $sth->fetchrow_hashref(NAME_lc))
{

$returnvalue.=qq|<option value="$ref->{id} ">|.$ref->{class}.qq|</option>|; ## no critic (ProhibitMagicNumbers) sniff

}


$sth->finish();

return($returnvalue);

}


1;
157 changes: 0 additions & 157 deletions old/lib/LedgerSMB/IS.pm
Expand Up @@ -1536,163 +1536,6 @@ sub toggle_on_hold {
}


sub list_locations_contacts
{

my ( $self, $myconfig, $form ) = @_;



my $dbh = $form->{dbh};

# get rest for the customer
my $query = qq|
WITH eca AS (select * from entity_credit_account
where id = ?
)
select id as shiptolocationid,line_one as shiptoaddress1,line_two as shiptoaddress2,line_three as shiptoaddress3,city as shiptocity,
state as shiptostate,mail_code as shiptozipcode,country as shiptocountry
from (
select (eca__list_locations(id)).*
FROM eca
UNION
SELECT (entity__list_locations(entity_id)).*
FROM eca
) l
WHERE location_class = 3;
|;



my $sth = $dbh->prepare($query);

$sth->execute( $form->{customer_id} ) || $form->dberror($query);

my $i=0;

while($ref = $sth->fetchrow_hashref(NAME_lc))
{
$i++;
for ( keys %$ref )
{
$form->{"$_\_$i"} = $ref->{$_};
}

}

$form->{totallocations}=$i;

$sth->finish();






$query = qq|
select c.class as shiptotype,ec.contact as shiptocontact,ec.description as shiptodescription
from eca_to_contact ec
join contact_class c on(c.id=ec.contact_class_id)
where ec.credit_id=?;
|;



$sth = $dbh->prepare($query);

$sth->execute( $form->{customer_id} ) || $form->dberror($query);

$i=0;

while($ref = $sth->fetchrow_hashref(NAME_lc))
{
$i++;
for ( keys %$ref )
{
$form->{"$_\_$i"} = $ref->{$_};
}

}

$form->{totalcontacts}=$i;

$sth->finish();

# for ( keys %$ref ) { $form->{$_} = $ref->{$_} }
}


sub construct_countrys
{


my ( $self,$form ) = @_;

my $dbh = $form->{dbh};


my $query = qq|
select id,short_name from location_list_country();
|;



my $sth = $dbh->prepare($query);

$sth->execute() || $form->dberror($query);

my $returnvalue=qq|<option value="">null</option>|;

while(my $ref = $sth->fetchrow_hashref(NAME_lc))
{

$returnvalue.=qq|<option value="$ref->{id} ">$ref->{short_name}</option>|;

}


$sth->finish();

return($returnvalue);

}


sub construct_types
{


my ( $self,$form ) = @_;

my $dbh = $form->{dbh};


my $query = qq|
select id,class from contact_class;
|;



my $sth = $dbh->prepare($query);

$sth->execute() || $form->dberror($query);

my $returnvalue=qq|<option value="">null</option>|;

while(my $ref = $sth->fetchrow_hashref(NAME_lc))
{

$returnvalue.=qq|<option value="$ref->{id} ">|.substr($ref->{class},0,3).qq|</option>|; ## no critic (ProhibitMagicNumbers) sniff

}


$sth->finish();

return($returnvalue);

}




Expand Down

0 comments on commit b9136f3

Please sign in to comment.