diff options
Diffstat (limited to 'config')
| -rw-r--r-- | config/pikul_order.tag | 57 | 
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 |