diff options
author | ꦌꦫꦶꦏ꧀ꦦꦿꦧꦮꦑꦩꦭ꧀ <erik@darapsa.co.id> | 2021-07-20 00:15:43 +0800 |
---|---|---|
committer | ꦌꦫꦶꦏ꧀ꦦꦿꦧꦮꦑꦩꦭ꧀ <erik@darapsa.co.id> | 2021-07-20 00:15:43 +0800 |
commit | 9e1956b7de95179d6b488d6a01fcb8046a821ef2 (patch) | |
tree | 93088f9f7883424be0e66436f9798060bcf35209 /config | |
parent | c30ec71812ffa31b8d7d995f2b9bab5c23d15312 (diff) |
Tag to show service codes
already wrapped in select option HTML elements.
Diffstat (limited to 'config')
-rw-r--r-- | config/pikul_codes.tag | 36 |
1 files changed, 36 insertions, 0 deletions
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 <<EOR +sub { + my ($company, $district, $city, $province, $weight) = @_; + 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'; + } + 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 = '<select name="mv_shipmode" id="ship_widget" class="form-control" onchange="this.form.submit()">'; + my $mv_shipmode = $Tag->value('mv_shipmode'); + for my $i (0 .. $#codes) { + $elements .= qq! + <option name="mv_shipmode" value="$table! . qq!_$codes[$i]"! . ($mv_shipmode ? ($mv_shipmode eq $table . "_$codes[$i]" ? ' selected' : '') : $i ? '' : ' selected') . qq!>$table $codes[$i]</option>!; + } + $elements .= q' + </select>'; + return $elements; +} +EOR |