diff options
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 |