session_start();
$session = session_id();
require_once("../../includes/config.php");
require_once("../script/classes/shoppingcart.php");
require_once("../script/lookups.php");
require_once("../script/Excel/reader.php");
//-----------------------------------------------------------------------
// Initialize Shopping Cart
$cart = new Cart($db);
$contents = $cart->display_contents($session);
$numberOfItems = $cart->num_items($session);
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
// USPS Configuration
$USPS_debug = false; // Display the XML response from USPS
$USPS_international = false; // Whether or not to support international shipping
$USPS_url = "http://Production.ShippingAPIs.com/ShippingAPI.dll";
$USPS_username = "593THREA1827";
$USPS_password = "103XM40PO661";
$USPS_domestic_ZipOrigination = "85034";
$USPS_domestic_Service = "Priority";
$USPS_domestic_Container = "Flat Rate Envelope";
$USPS_domestic_Size = "REGULAR";
$USPS_intl_MailType = "Package";
// Calculate Weight
// 1 pound = 16 ounces
$USPS_shirt_ounces = 0;
$USPS_numberOfShirts = 0;
$USPS_numberOfPrints = 0;
$USPS_numberOfAll = 0;
for ($i=0; $i < $numberOfItems; $i++) {
if ($contents['style'][$i] != "NULL" && $contents['color'][$i] != "NULL" && $contents['size'][$i] != "NULL") {
//Item is NOT a print..
$USPS_shirt_ounces += ($contents['quantity'][$i] * ($lookUpWeights[$contents['size'][$i]]));
//Gather some stats
$USPS_numberOfShirts += 1;
$USPS_numberOfAll += 1;
} else {
//Gather some stats
$USPS_numberOfPrints += 1;
$USPS_numberOfAll += 1;
}
}
$USPS_shirt_pounds = floor($USPS_shirt_ounces / 16);
$USPS_shirt_ounces = $USPS_shirt_ounces % 16;
$city = "";
$state= "";
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
// This section calculates the shipping information. Interfaces with
// the USPS site via XML.
$validShipping = false; // If this stays false, there will be a "Pending" price on the form, and
// the Checkout button will be unavailable. Instead the $zipError value
// will be displayed in it's place.
$USofA = true;
$zipError = "";
$displayZipCode = "style=\"display:\""; //This is used when a country is selected, it hides the zip code menu on load
$displayButton = "Submit Zip Code"; //This is used if a country is selected, it will be "zip code" with US, and "Country" with
//Every other country...
//Build out the Country selection box, defaulted to the US being selected.
$countryDropDown = "";
foreach($lookUpCountry as $key => $value) {
if ($key == "US") {
$countryDropDown .= "";
} else {
$countryDropDown .= "";
}
}
$sql = "SELECT * FROM accounting_zipcode WHERE session='" . $session . "'";
$zip_result = $db->getRow($sql);
if (is_object($zip_result)) {
// Either a zipcode, or a country is associated with this session..
$shipping_zip = "value='" . $zip_result->zipcode . "'";
if ($USPS_numberOfPrints < $USPS_numberOfAll) {
// A shirt exists in the cart... (not just prints)
if ($zip_result->country == "US") {
//If it's the US, interface with the USPS domestic shipping API using zipcodes
//$shipping_zip = "value='" . $zip_result->zipcode . "'";
//-------------------------------------------------------------------------------------------------------------------
// SHIPPING SECTION
//-------------------------------------------------------------------------------------------------------------------
$data_string = "API=RateV2&XML=";
$data_string .= "";
$data_string .= "" . $USPS_domestic_Service . "";
$data_string .= "" . $USPS_domestic_ZipOrigination . "";
$data_string .= "" . $zip_result->zipcode . "";
$data_string .= "" . $USPS_shirt_pounds . "";
$data_string .= "" . $USPS_shirt_ounces . "";
$data_string .= "" . $USPS_domestic_Container . "";
$data_string .= "" . $USPS_domestic_Size . "";
$data_string .= "";
$data_string .= "";
// Get a CURL handle
$curl_handle = curl_init ();
// Tell CURL the URL of the recipient script
curl_setopt ($curl_handle, CURLOPT_URL, $USPS_url);
// This section sets various options. See http://www.php.net/manual/en/function.curl-setopt.php
curl_setopt ($curl_handle, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt ($curl_handle, CURLOPT_RETURNTRANSFER, 1);
curl_setopt ($curl_handle, CURLOPT_POST, 1);
curl_setopt ($curl_handle, CURLOPT_POSTFIELDS, $data_string);
// Perform the POST and get the data returned by the server.
$result = curl_exec ($curl_handle) or die ("There has been a CURL_EXEC error");
// Close the CURL handle
curl_close ($curl_handle);
if ($USPS_debug) echo "" . htmlentities($result) . "";
if (!ereg("Error", $result)) {
//If there was no error, display the shipping rate.
$split = split("", $result);
$result = split("", $split[1]);
$Shipping_price = $result[0];
$validShipping = true;
} else {
//If an error was encountered, get the error description from the USPS
$split = split("", $result);
$result = split("", $split[1]);
$zipError = "USPS Response: " . $result[0];
$Shipping_price = 0;
}
//-------------------------------------------------------------------------------------------------------------------
// TAX SECTION
//-------------------------------------------------------------------------------------------------------------------
// ExcelFile($filename, $encoding);
$data = new Spreadsheet_Excel_Reader();
// Set output Encoding.
$data->setOutputEncoding('CP1251');
$data->read('../script/taxrates.xls');
error_reporting(E_ALL ^ E_NOTICE);
for ($i = 2; $i <= $data->sheets[0]['numRows']; $i++) {
$tempData[trim($data->sheets[0]['cells'][$i][2])] = trim($data->sheets[0]['cells'][$i][8]);
}
//print_r($zipLookup);
foreach ($tempData as $zips=>$rate) {
$ziplist = explode(",", $zips);
foreach ($ziplist as $key) {
$zipLookup[trim($key)] = trim($rate);
}
}
/*
print "";
print_r($zipLookup);
print "
";
print "Matching zipcode " . $zip_result->zipcode . " with rate: " . $zipLookup[$zip_result->zipcode] . " ";
print "";
*/
$taxRate = $zipLookup[$zip_result->zipcode];
} else {
//Country was NOT the United States, so interface with the International Shipping
// API from the USPS
$displayZipCode = "style=\"display:none;\"";
$displayButton = "Submit Country";
$USofA = false;
$data_string = "API=IntlRate&XML=";
$data_string .= "";
$data_string .= "" . $USPS_shirt_pounds . "";
$data_string .= "" . $USPS_shirt_ounces . "";
$data_string .= "" . $USPS_intl_MailType . "";
$data_string .= "" . $lookUpCountry[$zip_result->country] . "";
$data_string .= "";
$data_string .= "";
// Get a CURL handle
$curl_handle = curl_init ();
// Tell CURL the URL of the recipient script
curl_setopt ($curl_handle, CURLOPT_URL, $USPS_url);
// This section sets various options. See http://www.php.net/manual/en/function.curl-setopt.php
curl_setopt ($curl_handle, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt ($curl_handle, CURLOPT_RETURNTRANSFER, 1);
curl_setopt ($curl_handle, CURLOPT_POST, 1);
curl_setopt ($curl_handle, CURLOPT_POSTFIELDS, $data_string);
// Perform the POST and get the data returned by the server.
$result = curl_exec ($curl_handle) or die ("There has been a CURL_EXEC error");
// Close the CURL handle
curl_close ($curl_handle);
if ($USPS_debug) echo "" . htmlentities($result) . "";
if (!ereg("Error", $result)) {
//If there was no error, display the shipping rate.
$split = split("", $result);
$result_price = split("", $split[1]);
$Shipping_price = $result_price[0];
$validShipping = true;
} else {
//If an error was encountered, get the error description from the USPS
$split = split("", $result);
$result = split("", $split[1]);
$zipError = "USPS Response: " . $result[0];
$Shipping_price = 0;
}
// Build out the country dropdown, overwrites the default US dropdown..
$countryDropDown = "";
foreach($lookUpCountry as $key => $value) {
if ($key == $zip_result->country) {
$countryDropDown .= "";
} else {
$countryDropDown .= "";
}
}
}
} else {
//The Only items in the cart are prints..
$validShipping = true;
$Shipping_price = 0;
}
} else {
$Shipping_price = 0;
}
//-----------------------------------------------------------------------
?>
For an alternate route to Journal of Emerging finance market.There are affordable cars, and then there are cars that offer thrilling performance. Rarely do the two ever converge, but Japanese automake mazada.new impreza 2008 Impreza Photos | Subaru News, Articles, Road Tests, Test Drives, Comparisons, Concepts.manhattan beach toyota Los Angeles Toyota Dealer, is a New & Pre-Owned Toyota dealership, with OEM Toyota parts and professional Toyota service.fashions like you need it: make fashion trends work for you, get fashion on a budget, dress for your body and look great for special occasions.How to treat a fragile man without health insurance man.gadget store buy drinking games, gadgets & boys toys. Shop online for fun gifts, presents, gizmos and games.Review and road test of the Ford mondeo.Discover new cars from hyndai.Find new kia.suzuki vehicles on our Car Finder Buy and Sell New Used Cars Philippines 2009 site.Your Suzuki Motorcycle Info Source: Suzuki Motorcycles Used Dual Purpose Motorcycles For Sale · View 2008 Suzuki Models 2008 suzuki.auto manufacturer site with information on the Sedona, Sorento, Sportage, Optima, Spectra and Rio vehicles www kia.Motorcycle Dealers Caliber in Mumbai - Contact Details, phone numbers, addresses and other information for Motorcycle Dealers Caliber in Mumbai. dealerships caliber.Electronics and gadgets are two words that fit very well together. The electronic gadget.2001 excursion highlights from Consumer Guide Automotive. Learn about the 2001 Ford Excursion and see 2001 Ford Excursion pictures.ford Motor Company maker of cars, trucks, SUVs and other vehicles. View our vehicle showroom, get genuine Ford parts and accessories, find dealers.The soul of Formula M: reloaded. Combining motorsport capabilities with everyday driving. The bmw coupe.Vintage and Classic Car Club of India vintage car.Welcome - Feel Good Natural health stores.Welcome to mazdas global website.Locate the nearest Chevrolet Car chevy dealermark2 savage magazine problems