From 9e1956b7de95179d6b488d6a01fcb8046a821ef2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=A6=8C=EA=A6=AB=EA=A6=B6=EA=A6=8F=EA=A7=80=EA=A6=A6?= =?UTF-8?q?=EA=A6=BF=EA=A6=A7=EA=A6=AE=EA=A6=91=EA=A6=A9=EA=A6=AD=EA=A7=80?= Date: Tue, 20 Jul 2021 00:15:43 +0800 Subject: Tag to show service codes already wrapped in select option HTML elements. --- config/pikul_codes.tag | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 config/pikul_codes.tag (limited to 'config') diff --git a/config/pikul_codes.tag b/config/pikul_codes.tag new file mode 100644 index 0000000..f8c99cb --- /dev/null +++ b/config/pikul_codes.tag @@ -0,0 +1,36 @@ +UserTag pikul-codes Order company district city province weight +UserTag pikul-codes Routine <{PIKUL_ANTERAJA}) { + @provisions = ( + $Global::Variable->{ANTERAJA_ACCESS_KEY_ID}, + $Global::Variable->{ANTERAJA_SECRET_ACCESS_KEY}, + $Global::Variable->{ANTERAJA_BASE_PATH} + ); + $origin = $::Variable->{ANTERAJA_ORIGIN}; + $table = 'anteraja'; + } + use Pikul; + Pikul::init($company, \@provisions); + my @codes = @{Pikul::codes( + $origin, + $Tag->query({ + sql => "SELECT code FROM $table WHERE district='$district' AND \ + city='$city' AND province='$province'", + wantarray => 1 + })->[0]->[0] || '', + $weight)}; + Pikul::cleanup(); + my $elements = ''; + return $elements; +} +EOR -- cgit v1.2.3 From 76bda3da1176fee9603e69274086085fbb85953e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=A6=8C=EA=A6=AB=EA=A6=B6=EA=A6=8F=EA=A7=80=EA=A6=A6?= =?UTF-8?q?=EA=A6=BF=EA=A6=A7=EA=A6=AE=EA=A6=91=EA=A6=A9=EA=A6=AD=EA=A7=80?= Date: Tue, 20 Jul 2021 00:20:29 +0800 Subject: Reindented --- config/pikul_codes.tag | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'config') diff --git a/config/pikul_codes.tag b/config/pikul_codes.tag index f8c99cb..377aad2 100644 --- a/config/pikul_codes.tag +++ b/config/pikul_codes.tag @@ -27,10 +27,10 @@ sub { my $mv_shipmode = $Tag->value('mv_shipmode'); for my $i (0 .. $#codes) { $elements .= qq! - !; + !; } $elements .= q' - '; + '; return $elements; } EOR -- cgit v1.2.3 From b521361bfc18d0fcbe7773018f8f34e1b6900eae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=A6=8C=EA=A6=AB=EA=A6=B6=EA=A6=8F=EA=A7=80=EA=A6=A6?= =?UTF-8?q?=EA=A6=BF=EA=A6=A7=EA=A6=AE=EA=A6=91=EA=A6=A9=EA=A6=AD=EA=A7=80?= Date: Tue, 20 Jul 2021 00:30:25 +0800 Subject: Tidy up --- config/pikul_codes.tag | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'config') diff --git a/config/pikul_codes.tag b/config/pikul_codes.tag index 377aad2..4169c0b 100644 --- a/config/pikul_codes.tag +++ b/config/pikul_codes.tag @@ -26,11 +26,16 @@ sub { my $elements = ''; + $elements .= q( + ); return $elements; } EOR -- cgit v1.2.3 From 0550cb43f08b97292639f800512df3965ee96df1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=A6=8C=EA=A6=AB=EA=A6=B6=EA=A6=8F=EA=A7=80=EA=A6=A6?= =?UTF-8?q?=EA=A6=BF=EA=A6=A7=EA=A6=AE=EA=A6=91=EA=A6=A9=EA=A6=AD=EA=A7=80?= Date: Tue, 20 Jul 2021 14:34:23 +0800 Subject: mv_shipmode seems to be always submitted --- config/pikul_codes.tag | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) (limited to 'config') diff --git a/config/pikul_codes.tag b/config/pikul_codes.tag index 4169c0b..fb4a0e6 100644 --- a/config/pikul_codes.tag +++ b/config/pikul_codes.tag @@ -24,15 +24,12 @@ sub { $weight)}; Pikul::cleanup(); my $elements = '); -- cgit v1.2.3 From 488e6e8145ce64dd124ba6187a5d7b5813bb927b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=A6=8C=EA=A6=AB=EA=A6=B6=EA=A6=8F=EA=A7=80=EA=A6=A6?= =?UTF-8?q?=EA=A6=BF=EA=A6=A7=EA=A6=AE=EA=A6=91=EA=A6=A9=EA=A6=AD=EA=A7=80?= Date: Tue, 20 Jul 2021 14:50:48 +0800 Subject: Trying to get weight shouldn't be the template user's concern --- config/pikul_codes.tag | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'config') diff --git a/config/pikul_codes.tag b/config/pikul_codes.tag index fb4a0e6..71fd5cc 100644 --- a/config/pikul_codes.tag +++ b/config/pikul_codes.tag @@ -1,7 +1,7 @@ -UserTag pikul-codes Order company district city province weight +UserTag pikul-codes Order company district city province UserTag pikul-codes Routine <{PIKUL_ANTERAJA}) { @provisions = ( @@ -12,6 +12,10 @@ sub { $origin = $::Variable->{ANTERAJA_ORIGIN}; $table = 'anteraja'; } + my $weight = 0.0; + for my $item (@{$Carts->{main}}) { + $weight += $Tag->data('products', 'weight', $item->{code}) * $item->{quantity}; + } use Pikul; Pikul::init($company, \@provisions); my @codes = @{Pikul::codes( -- cgit v1.2.3 From 0253ac37312fc76d2cbea0ad1eb10aed066cea9b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=A6=8C=EA=A6=AB=EA=A6=B6=EA=A6=8F=EA=A7=80=EA=A6=A6?= =?UTF-8?q?=EA=A6=BF=EA=A6=A7=EA=A6=AE=EA=A6=91=EA=A6=A9=EA=A6=AD=EA=A7=80?= Date: Tue, 20 Jul 2021 18:22:43 +0800 Subject: Rename pikul_codes to just pikul --- config/pikul.tag | 42 ++++++++++++++++++++++++++++++++++++++++++ config/pikul_codes.tag | 42 ------------------------------------------ 2 files changed, 42 insertions(+), 42 deletions(-) create mode 100644 config/pikul.tag delete mode 100644 config/pikul_codes.tag (limited to 'config') diff --git a/config/pikul.tag b/config/pikul.tag new file mode 100644 index 0000000..17030a7 --- /dev/null +++ b/config/pikul.tag @@ -0,0 +1,42 @@ +UserTag pikul Order company district city province +UserTag pikul Routine <{PIKUL_ANTERAJA}) { + @provisions = ( + $Global::Variable->{ANTERAJA_ACCESS_KEY_ID}, + $Global::Variable->{ANTERAJA_SECRET_ACCESS_KEY}, + $Global::Variable->{ANTERAJA_BASE_PATH} + ); + $origin = $::Variable->{ANTERAJA_ORIGIN}; + $table = 'anteraja'; + } + my $weight = 0.0; + for my $item (@{$Carts->{main}}) { + $weight += $Tag->data('products', 'weight', $item->{code}) * $item->{quantity}; + } + use Pikul; + Pikul::init($company, \@provisions); + my @codes = @{Pikul::codes( + $origin, + $Tag->query({ + sql => "SELECT code FROM $table WHERE district='$district' AND \ + city='$city' AND province='$province'", + wantarray => 1 + })->[0]->[0] || '', + $weight)}; + Pikul::cleanup(); + my $elements = '); + return $elements; +} +EOR diff --git a/config/pikul_codes.tag b/config/pikul_codes.tag deleted file mode 100644 index 71fd5cc..0000000 --- a/config/pikul_codes.tag +++ /dev/null @@ -1,42 +0,0 @@ -UserTag pikul-codes Order company district city province -UserTag pikul-codes Routine <{PIKUL_ANTERAJA}) { - @provisions = ( - $Global::Variable->{ANTERAJA_ACCESS_KEY_ID}, - $Global::Variable->{ANTERAJA_SECRET_ACCESS_KEY}, - $Global::Variable->{ANTERAJA_BASE_PATH} - ); - $origin = $::Variable->{ANTERAJA_ORIGIN}; - $table = 'anteraja'; - } - my $weight = 0.0; - for my $item (@{$Carts->{main}}) { - $weight += $Tag->data('products', 'weight', $item->{code}) * $item->{quantity}; - } - use Pikul; - Pikul::init($company, \@provisions); - my @codes = @{Pikul::codes( - $origin, - $Tag->query({ - sql => "SELECT code FROM $table WHERE district='$district' AND \ - city='$city' AND province='$province'", - wantarray => 1 - })->[0]->[0] || '', - $weight)}; - Pikul::cleanup(); - my $elements = '); - return $elements; -} -EOR -- cgit v1.2.3 From e6854c2c645e8602f988fa4dd305cca610310e2d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=A6=8C=EA=A6=AB=EA=A6=B6=EA=A6=8F=EA=A7=80=EA=A6=A6?= =?UTF-8?q?=EA=A6=BF=EA=A6=A7=EA=A6=AE=EA=A6=91=EA=A6=A9=EA=A6=AD=EA=A7=80?= Date: Tue, 20 Jul 2021 18:51:09 +0800 Subject: district, city, & province in tag --- config/pikul.tag | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'config') diff --git a/config/pikul.tag b/config/pikul.tag index 17030a7..ea279c2 100644 --- a/config/pikul.tag +++ b/config/pikul.tag @@ -1,7 +1,7 @@ -UserTag pikul Order company district city province +UserTag pikul Order company UserTag pikul Routine <{PIKUL_ANTERAJA}) { @provisions = ( @@ -18,13 +18,13 @@ sub { } use Pikul; Pikul::init($company, \@provisions); + my $district = $Tag->value('address2'); + my $city = $Tag->value('city'); + my $province = $Tag->value('state'); my @codes = @{Pikul::codes( $origin, - $Tag->query({ - sql => "SELECT code FROM $table WHERE district='$district' AND \ - city='$city' AND province='$province'", - wantarray => 1 - })->[0]->[0] || '', + $Tag->query({ sql => "SELECT code FROM $table WHERE district='$district' AND city='$city' \ + AND province='$province'", wantarray => 1})->[0]->[0] || '', $weight)}; Pikul::cleanup(); my $elements = ''; + } use Pikul; - Pikul::init($company, \@provisions); - my $district = $Tag->value('address2'); - my $city = $Tag->value('city'); - my $province = $Tag->value('state'); - my @codes = @{Pikul::codes( + for (my $company = $::Variable->{PIKUL_ANTERAJA}; $company <= $::Variable->{PIKUL_ANTERAJA}; + $company++) { + my (@provisions, $origin, $table); + if ($company == $::Variable->{PIKUL_ANTERAJA}) { + @provisions = ( + $Global::Variable->{ANTERAJA_ACCESS_KEY_ID}, + $Global::Variable->{ANTERAJA_SECRET_ACCESS_KEY}, + $Global::Variable->{ANTERAJA_BASE_PATH} + ); + $origin = $::Variable->{ANTERAJA_ORIGIN}; + $table = 'anteraja'; + } + Pikul::init($company, \@provisions); + my @codes = @{Pikul::codes( $origin, $Tag->query({ sql => "SELECT code FROM $table WHERE district='$district' AND city='$city' \ AND province='$province'", wantarray => 1})->[0]->[0] || '', $weight)}; - Pikul::cleanup(); - my $elements = '); -- cgit v1.2.3 From 89e5f9be28448e62e85b2b7d53c9c06c9528cc50 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=A6=8C=EA=A6=AB=EA=A6=B6=EA=A6=8F=EA=A7=80=EA=A6=A6?= =?UTF-8?q?=EA=A6=BF=EA=A6=A7=EA=A6=AE=EA=A6=91=EA=A6=A9=EA=A6=AD=EA=A7=80?= Date: Tue, 20 Jul 2021 19:43:32 +0800 Subject: select option are only if select --- config/pikul.tag | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) (limited to 'config') diff --git a/config/pikul.tag b/config/pikul.tag index 343e50b..3c8f455 100644 --- a/config/pikul.tag +++ b/config/pikul.tag @@ -2,6 +2,10 @@ UserTag pikul Order widget extra UserTag pikul Routine <'; + } my $district = $Tag->value('address2'); my $city = $Tag->value('city'); my $province = $Tag->value('state'); @@ -9,10 +13,6 @@ sub { for my $item (@{$Carts->{main}}) { $weight += $Tag->data('products', 'weight', $item->{code}) * $item->{quantity}; } - my $elements; - if ($widget eq 'select') { - $elements = '); + } return $elements; } EOR -- cgit v1.2.3 From 8d2476666edc596e5332cafe880f4103e70521ce Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=A6=8C=EA=A6=AB=EA=A6=B6=EA=A6=8F=EA=A7=80=EA=A6=A6?= =?UTF-8?q?=EA=A6=BF=EA=A6=A7=EA=A6=AE=EA=A6=91=EA=A6=A9=EA=A6=AD=EA=A7=80?= Date: Tue, 20 Jul 2021 22:38:18 +0800 Subject: Now the HTML is created in libpikul --- config/pikul.tag | 60 +++++++++++++++++++++++--------------------------------- 1 file changed, 24 insertions(+), 36 deletions(-) (limited to 'config') diff --git a/config/pikul.tag b/config/pikul.tag index 3c8f455..bbbbd8d 100644 --- a/config/pikul.tag +++ b/config/pikul.tag @@ -2,10 +2,6 @@ UserTag pikul Order widget extra UserTag pikul Routine <'; - } my $district = $Tag->value('address2'); my $city = $Tag->value('city'); my $province = $Tag->value('state'); @@ -13,40 +9,32 @@ 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 ' + ); use Pikul; - for (my $company = $::Variable->{PIKUL_ANTERAJA}; $company <= $::Variable->{PIKUL_ANTERAJA}; - $company++) { - my (@provisions, $origin, $table); - if ($company == $::Variable->{PIKUL_ANTERAJA}) { - @provisions = ( - $Global::Variable->{ANTERAJA_ACCESS_KEY_ID}, - $Global::Variable->{ANTERAJA_SECRET_ACCESS_KEY}, - $Global::Variable->{ANTERAJA_BASE_PATH} - ); - $origin = $::Variable->{ANTERAJA_ORIGIN}; - $table = 'anteraja'; - } - Pikul::init($company, \@provisions); - my @codes = @{Pikul::codes( - $origin, - $Tag->query({ sql => "SELECT code FROM $table WHERE district='$district' AND city='$city' \ + 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] || '', - $weight)}; - Pikul::cleanup(); - for my $code (@codes) { - if ($widget eq 'select') { - $elements .= q( - "; - } - } - } - if ($widget eq 'select') { - $elements .= q( - ); - } + $weight, + $widget, + $extra, + 'mv_shipmode', + $Tag->value('mv_shipmode'), + \@code_prefixes, + \@name_prefixes + ); + Pikul::cleanup(); return $elements; } EOR -- cgit v1.2.3 From 02ff6591ba83e1b8a934ec8017f8af7a45657fa8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=A6=8C=EA=A6=AB=EA=A6=B6=EA=A6=8F=EA=A7=80=EA=A6=A6?= =?UTF-8?q?=EA=A6=BF=EA=A6=A7=EA=A6=AE=EA=A6=91=EA=A6=A9=EA=A6=AD=EA=A7=80?= Date: Sat, 24 Jul 2021 12:28:46 +0800 Subject: Origins and destinations can now be more than one --- config/pikul.tag | 54 +++++++++++++++++++++++++++++++++++--------------- config/pikul_cost.tag | 5 +++-- config/pikul_order.tag | 1 + 3 files changed, 42 insertions(+), 18 deletions(-) (limited to 'config') 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}, -- cgit v1.2.3