summaryrefslogtreecommitdiff
path: root/config
diff options
context:
space:
mode:
Diffstat (limited to 'config')
-rw-r--r--config/pikul.tag82
-rw-r--r--config/pikul_cost.tag5
-rw-r--r--config/pikul_order.tag1
3 files changed, 86 insertions, 2 deletions
diff --git a/config/pikul.tag b/config/pikul.tag
new file mode 100644
index 0000000..0164851
--- /dev/null
+++ b/config/pikul.tag
@@ -0,0 +1,82 @@
+UserTag pikul Order widget extra
+UserTag pikul Routine <<EOR
+sub {
+ my ($widget, $extra) = @_;
+ my $district = $Tag->value('address2');
+ my $city = $Tag->value('city');
+ my $province = $Tag->value('state');
+ my $weight = 0.0;
+ for my $item (@{$Carts->{main}}) {
+ $weight += $Tag->data('products', 'weight', $item->{code}) * $item->{quantity};
+ }
+ my (@origins, @destinations, @code_prefixes, @name_prefixes);
+ use Pikul;
+ 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 ';
+ } elsif ($company == $::Variable->{PIKUL_SICEPAT}) {
+ my $api_key = $::Variable->{SICEPAT_API_KEY}
+ || $Global::Variable->{SICEPAT_API_KEY};
+ if (!$api_key) {
+ $origins[$company] = undef;
+ $destinations[$company] = undef;
+ $code_prefixes[$company] = undef;
+ $name_prefixes[$company] = undef;
+ next;
+ }
+ Pikul::init($company, [
+ $api_key
+ ]);
+ $origins[$company] = $::Variable->{SICEPAT_ORIGIN}
+ || $Global::Variable->{SICEPAT_ORIGIN};
+ $destinations[$company] = $Tag->query({sql => "SELECT code FROM sicepat_destination\
+ WHERE district='$district' AND city='$city' AND \
+ province='$province'", wantarray => 1})->[0]->[0] || '';
+ $code_prefixes[$company] = 'sicepat_';
+ $name_prefixes[$company] = 'SiCepat ';
+ }
+ }
+ my $elements = Pikul::html(
+ \@origins,
+ \@destinations,
+ $weight,
+ $widget,
+ $extra,
+ 'mv_shipmode',
+ $Tag->value('mv_shipmode'),
+ \@code_prefixes,
+ \@name_prefixes
+ );
+ Pikul::cleanup();
+ return $elements;
+}
+EOR
diff --git a/config/pikul_cost.tag b/config/pikul_cost.tag
index ceec7c6..199e503 100644
--- a/config/pikul_cost.tag
+++ b/config/pikul_cost.tag
@@ -21,14 +21,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 e684837..35845f6 100644
--- a/config/pikul_order.tag
+++ b/config/pikul_order.tag
@@ -42,6 +42,7 @@ sub {
use Pikul;
Pikul::init($company, \@provisions);
my $tracking_number = Pikul::order(
+ $company,
$order_number,
$service,
$::Variable->{COMPANY},