summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorꦌꦫꦶꦏ꧀ꦦꦿꦧꦮꦑꦩꦭ꧀ <erik@darapsa.co.id>2021-07-20 22:38:18 +0800
committerꦌꦫꦶꦏ꧀ꦦꦿꦧꦮꦑꦩꦭ꧀ <erik@darapsa.co.id>2021-07-20 22:38:18 +0800
commit8d2476666edc596e5332cafe880f4103e70521ce (patch)
tree8f7042a170ff75eedc71e359180712433e45a1e0
parent89e5f9be28448e62e85b2b7d53c9c06c9528cc50 (diff)
Now the HTML is created in libpikul
-rw-r--r--config/pikul.tag60
1 files changed, 24 insertions, 36 deletions
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 <<EOR
sub {
my ($widget, $extra) = @_;
- my $elements;
- if ($widget eq 'select') {
- $elements = '<select name="mv_shipmode"' . ($extra ? " $extra" : '') . '>';
- }
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(
- <option value=")
- . $table . qq(_$code")
- . ($Tag->value('mv_shipmode') eq $table . "_$code" ? ' selected' : '')
- . ">$table&nbsp;$code</option>";
- }
- }
- }
- if ($widget eq 'select') {
- $elements .= q(
- </select>);
- }
+ $weight,
+ $widget,
+ $extra,
+ 'mv_shipmode',
+ $Tag->value('mv_shipmode'),
+ \@code_prefixes,
+ \@name_prefixes
+ );
+ Pikul::cleanup();
return $elements;
}
EOR