summaryrefslogtreecommitdiff
path: root/config
diff options
context:
space:
mode:
authorꦌꦫꦶꦏ꧀ꦦꦿꦧꦮꦑꦩꦭ꧀ <erik@darapsa.co.id>2021-07-17 10:53:05 +0800
committerꦌꦫꦶꦏ꧀ꦦꦿꦧꦮꦑꦩꦭ꧀ <erik@darapsa.co.id>2021-07-17 10:53:05 +0800
commit26402c5c6db611a88f058bff0279b23bccb33957 (patch)
treee372e92fa526046a70fb45b8b7793cd994c427a4 /config
parentef97980def513ed45831a607b56aa304af637dbd (diff)
Template tag for ordering
Diffstat (limited to 'config')
-rw-r--r--config/pikul_order.tag57
1 files changed, 57 insertions, 0 deletions
diff --git a/config/pikul_order.tag b/config/pikul_order.tag
new file mode 100644
index 0000000..062d5ac
--- /dev/null
+++ b/config/pikul_order.tag
@@ -0,0 +1,57 @@
+UserTag pikul_order Order order_number insurance
+UserTag pikul_order Routine <<EOR
+sub {
+ my ($order_number, $insurance) = @_;
+ my ($shipmode, $nitems, $subtotal, $fname, $lname, $address1, $address2, $city, $state, $phone_day)
+ = @{$Tag->query({
+ sql => "SELECT shipmode,nitems,subtotal,fname,lname,address1,address2,city,state,phone_day \
+ FROM transactions WHERE code='$order_number'",
+ wantarray => 1
+ })->[0]};
+ my ($table, $service) = split(/_/, shift split(/ /, $shipmode));
+ my ($company, @provisions, $origin);
+ if (substr($table, 0, 8) eq 'anteraja') {
+ $company = $::Variable->{PIKUL_ANTERAJA};
+ @provisions = (
+ "$Global::Variable->{ANTERAJA_BASE_PATH}",
+ "$Global::Variable->{ANTERAJA_ACCESS_KEY_ID}",
+ "$Global::Variable->{ANTERAJA_SECRET_ACCESS_KEY}",
+ "$Global::Variable->{ANTERAJA_PREFIX}"
+ );
+ $origin = $::Variable->{ANTERAJA_ORIGIN};
+ }
+ my @items = @{$Tag->query({sql => "SELECT sku,quantity FROM orderline WHERE \
+ order_number='$order_number'",
+ wantarray => 1
+ })->[0]};
+ for my $item (@items) {
+ ($item->[2], $item->[3], $item->[4]) = @{$Tag->query({
+ sql => "SELECT description,price,weight FROM products WHERE sku='$item->[0]'",
+ wantarray => 1
+ })->[0]};
+ }
+ use Pikul;
+ Pikul::init($company, \@provisions);
+ my $waybill = Pikul::order(
+ $order_number,
+ $service,
+ $::Variable->{COMPANY},
+ $::Variable->{PHONE},
+ $origin,
+ $::Variable->{ADDRESS},
+ "$fname $lname",
+ $phone_day,
+ $Tag->query({sql => "SELECT code FROM $table WHERE district='$address2' AND city='$city' \
+ AND province='$state'",
+ wantarray => 1
+ })->[0]->[0] || '',
+ $address1,
+ $nitems,
+ \@items,
+ $insurance,
+ $subtotal
+ );
+ Pikul::cleanup();
+ return $waybill;
+}
+EOR