summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorꦌꦫꦶꦏ꧀ꦦꦿꦧꦮꦑꦩꦭ꧀ <erik@darapsa.co.id>2021-07-24 12:28:46 +0800
committerꦌꦫꦶꦏ꧀ꦦꦿꦧꦮꦑꦩꦭ꧀ <erik@darapsa.co.id>2021-07-24 12:28:46 +0800
commit02ff6591ba83e1b8a934ec8017f8af7a45657fa8 (patch)
tree1e6fff51901125a2ab1a8ff8c2270175ed2b6867
parent11f642004eec38d604355c0df54a0201baa35018 (diff)
Origins and destinations can now be more than one
-rw-r--r--catalog.cfg4
-rw-r--r--config/pikul.tag54
-rw-r--r--config/pikul_cost.tag5
-rw-r--r--config/pikul_order.tag1
4 files changed, 45 insertions, 19 deletions
diff --git a/catalog.cfg b/catalog.cfg
index 87aeebe..5f84b3f 100644
--- a/catalog.cfg
+++ b/catalog.cfg
@@ -757,4 +757,6 @@ SearchProfile include/profiles/searchprofiles
Jobs log __LOGDIR__/jobs.log
Jobs base_directory etc/jobs
-Variable PIKUL_ANTERAJA 0
+Variable PIKUL 0
+Variable PIKUL_ANTERAJA 1
+Variable PIKUL_END 2
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},