diff options
Diffstat (limited to 'config')
-rw-r--r-- | config/pikul.tag | 54 | ||||
-rw-r--r-- | config/pikul_cost.tag | 5 | ||||
-rw-r--r-- | config/pikul_order.tag | 1 |
3 files changed, 42 insertions, 18 deletions
diff --git a/config/pikul.tag b/config/pikul.tag index bbbbd8d..db2d8ea 100644 --- a/config/pikul.tag +++ b/config/pikul.tag @@ -9,23 +9,45 @@ sub { for my $item (@{$Carts->{main}}) { $weight += $Tag->data('products', 'weight', $item->{code}) * $item->{quantity}; } - my @provisions = ( - $Global::Variable->{ANTERAJA_ACCESS_KEY_ID}, - $Global::Variable->{ANTERAJA_SECRET_ACCESS_KEY}, - $Global::Variable->{ANTERAJA_BASE_PATH} - ); - my @code_prefixes = ( - 'anteraja_' - ); - my @name_prefixes = ( - 'Anteraja ' - ); + my (@origins, @destinations, @code_prefixes, @name_prefixes); use Pikul; - Pikul::init($::Variable->{PIKUL_ANTERAJA}, \@provisions); - my $elements = Pikul::html( - $::Variable->{ANTERAJA_ORIGIN}, - $Tag->query({sql => "SELECT code FROM anteraja WHERE district='$district' AND city='$city' \ - AND province='$province'", wantarray => 1})->[0]->[0] || '', + for (my $company = $::Variable->{PIKUL}; $company < $::Variable->{PIKUL_END}; $company++) { + if ($company == $::Variable->{PIKUL}) { + $origins[$company] = undef; + $destinations[$company] = undef; + $code_prefixes[$company] = undef; + $name_prefixes[$company] = undef; + } elsif ($company == $::Variable->{PIKUL_ANTERAJA}) { + my $access_key_id = $::Variable->{ANTERAJA_ACCESS_KEY_ID} + || $Global::Variable->{ANTERAJA_ACCESS_KEY_ID}; + my $secret_access_key = $::Variable->{ANTERAJA_SECRET_ACCESS_KEY} + || $Global::Variable->{ANTERAJA_SECRET_ACCESS_KEY}; + my $base_path = $::Variable->{ANTERAJA_BASE_PATH} + || $Global::Variable->{ANTERAJA_BASE_PATH}; + if (!$access_key_id || !$secret_access_key || !$base_path) { + $origins[$company] = undef; + $destinations[$company] = undef; + $code_prefixes[$company] = undef; + $name_prefixes[$company] = undef; + next; + } + Pikul::init($company, [ + $access_key_id, + $secret_access_key, + $base_path + ]); + $origins[$company] = $::Variable->{ANTERAJA_ORIGIN} + || $Global::Variable->{ANTERAJA_ORIGIN}; + $destinations[$company] = $Tag->query({sql => "SELECT code FROM anteraja WHERE \ + district='$district' AND city='$city' AND province='$province'", + wantarray => 1})->[0]->[0] || ''; + $code_prefixes[$company] = 'anteraja_'; + $name_prefixes[$company] = 'Anteraja '; + } + } + my $elements = Pikul::html( + \@origins, + \@destinations, $weight, $widget, $extra, diff --git a/config/pikul_cost.tag b/config/pikul_cost.tag index 2cea3f2..4b8aad0 100644 --- a/config/pikul_cost.tag +++ b/config/pikul_cost.tag @@ -15,14 +15,15 @@ sub { use Pikul; Pikul::init($company, \@provisions); my $cost = Pikul::cost( + $company, + $service, $origin, $Tag->query({ sql => "SELECT code FROM $table WHERE district='$district' AND \ city='$city' AND province='$province'", wantarray => 1 })->[0]->[0] || '', - $weight, - $service); + $weight); Pikul::cleanup(); return $cost; } diff --git a/config/pikul_order.tag b/config/pikul_order.tag index e5541f1..f8bf255 100644 --- a/config/pikul_order.tag +++ b/config/pikul_order.tag @@ -35,6 +35,7 @@ sub { use Pikul; Pikul::init($company, \@provisions); my $tracking_number = Pikul::order( + $company, $order_number, $service, $::Variable->{COMPANY}, |