|
|


 |
function UPS_Ground($tmp_state, $tmp_date){
// build associative array of all states and delivery days
$StateTime["AL"]=4;
//$StateTime["AK"]=0; // Can't ship ups ground to alaska
$StateTime["AZ"]=5;
$StateTime["AR"]=4;
$StateTime["CA"]=6;
$StateTime["CO"]=5;
$StateTime["CT"]=5;
$StateTime["DE"]=5;
$StateTime["DC"]=4;
$StateTime["FL"]=6;
$StateTime["GA"]=5;
//$StateTime["HI"]=0; // Can't drive to Hawaii
$StateTime["ID"]=6;
$StateTime["IL"]=3;
$StateTime["IN"]=3;
$StateTime["IA"]=3;
$StateTime["KS"]=4;
$StateTime["KY"]=3;
$StateTime["LA"]=4;
$StateTime["ME"]=5;
$StateTime["MD"]=4;
$StateTime["MA"]=5;
$StateTime["MI"]=3;
$StateTime["MN"]=3;
$StateTime["MS"]=4;
$StateTime["MO"]=3;
$StateTime["MT"]=5;
$StateTime["NE"]=4;
$StateTime["NV"]=5;
$StateTime["NH"]=5;
$StateTime["NJ"]=5;
$StateTime["NM"]=5;
$StateTime["NY"]=5;
$StateTime["NC"]=4;
$StateTime["ND"]=4;
$StateTime["OH"]=3;
$StateTime["OK"]=4;
$StateTime["OR"]=6;
$StateTime["PA"]=5;
$StateTime["RI"]=5;
$StateTime["SC"]=4;
$StateTime["SD"]=4;
$StateTime["TN"]=4;
$StateTime["TX"]=6;
$StateTime["UT"]=5;
$StateTime["VT"]=5;
$StateTime["VA"]=4;
$StateTime["WA"]=5;
$StateTime["WV"]=4;
$StateTime["WI"]=1;
$StateTime["WY"]=5;
//Determine how many days to add to delivery corresonding to appropriate state
foreach($StateTime as $key=>$value) {
if ($tmp_state == $key){
// return state day value
$add_amount = $value;
break;
}else{
// return 0 because state not found
$add_amount = 0;
}
}
// calculate UPS Ground delivery date
list($month, $day, $year) = explode('/', $tmp_date);
$tmp_new = date("m/d/y", mktime(0, 0, 0, $month, $day + $add_amount, $year));
// calculate if it is a day UPS Delivers
list($month, $day, $year) = explode('/', $tmp_new);
$tmp_new_date = date("m/d/y", mktime(0, 0, 0, $month, $day + UPS_Day($tmp_new), $year));
// check if it is on a no delivery date
$new_date = UPS_NoDelivery($tmp_new_date);
return $new_date;
}
function UPS_Day($tmp_date){
// check to see if day falls on a day ups does not ship and if so add days next ship date
list($month, $day, $year) = explode('/', $tmp_date);
$tmp_long_date = mktime(0, 0, 0, $month, $day, $year); // use timestamp to make date
$tmp_wkday = date('w',$tmp_long_date); // determine day of week number
switch ($tmp_wkday){ // if order date is on certain day of week ...
case 0: // sunday
$tmp_shipdate = 1;
break;
case 6: // saturday
$tmp_shipdate = 2;
break;
default: // mon - fri
$tmp_shipdate = 0;
} // End Switch
return $tmp_shipdate;
} // end function
function UPS_NoPickup($tmp_date){ // date passed in is in m/d/y format
// build array of dates with no pickup and enter the next pickup day
$no_pickup_array["12/18/04"]="12/20/04";
$no_pickup_array["12/24/04"]="12/27/04";
$no_pickup_array["12/31/04"]="1/3/05";
$no_pickup_array["1/1/05"]="1/3/05";
// search if date passed in is in array
foreach($no_pickup_array as $key=>$value) {
if ($key == $tmp_date){
// return new date because in array
$new_date = $value;
break;
}else{
// return date passed in because not in array
$new_date = $tmp_date;
}
}
return $new_date;
} // end function
function UPS_NoDelivery($tmp_date){ // date passed in is m/d/y format
// determine if date is a date when there is not delivery
// build array of dates with no delivery and enter the next delivery day
$no_delivery_array["12/18/04"]="12/20/04";
$no_delivery_array["12/31/04"]="1/3/05";
$no_delivery_array["1/1/05"]="1/3/05";
// search if date passed in is in array
foreach($no_delivery_array as $key=>$value) {
if ($key == $tmp_date){
// return new date because in array
$new_date = $value;
break;
}else{
// return date passed in because not in array
$new_date = $tmp_date;
}
}
return $new_date;
} // end function
function Postal_Holiday($tmp_date){ // date passed in is in m/d/y format
// build array of dates with no pickup and enter the next pickup day
$postal_holiday_array["12/25/04"]="12/27/04";
$postal_holiday_array["1/1/05"]="1/3/05";
$postal_holiday_array["1/17/05"]="1/18/05";
$postal_holiday_array["2/21/05"]="2/22/05";
$postal_holiday_array["5/30/05"]="5/31/05";
$postal_holiday_array["7/4/05"]="7/6/05";
$postal_holiday_array["9/5/05"]="9/6/05";
$postal_holiday_array["10/10/05"]="10/11/05";
$postal_holiday_array["11/11/05"]="11/14/05";
$postal_holiday_array["11/24/05"]="11/25/05";
$postal_holiday_array["12/26/05"]="12/27/05";
$postal_holiday_array["1/2/06"]="1/3/06";
// search if date passed in is in array
foreach($postal_holiday_array as $key=>$value) {
if ($key == $tmp_date){
// return new date because in array
$new_date = $value;
break;
}else{
// return date passed in because not in array
$new_date = $tmp_date;
}
}
return $new_date;
} // end function
function WeekDay($tmp_day){ // $tmp_day passed in is actual day of week number
// calculate actual day of week name
switch ($tmp_day){
case 0: // Sunday
$tmp_dayname = "Sun.";
break;
case 1: // Monday
$tmp_dayname = 'Mon.';
break;
case 2: // Tuesday
$tmp_dayname = 'Tue.';
break;
case 3: // Wednesday
$tmp_dayname = 'Wed.';
break;
case 4: // Thursday
$tmp_dayname = 'Thu.';
break;
case 5: // Friday
$tmp_dayname = 'Fri.';
break;
case 6: // Saturday
$tmp_dayname = 'Sat.';
break;
Default:
$tmp_dayname = 'Value not a weekday';
} // End Switch
return $tmp_dayname;
} // End Function
function date_shipped($tmp_date){
// Calculate how many days to add to the order date to get ship date.
list($month, $day, $year) = explode('/', $tmp_date);
$tmp_long_date = mktime(0, 0, 0, $month, $day, $year);
$tmp_wkday = date('w',$tmp_long_date); // get day of week
switch ($tmp_wkday){ // if order date is on certain day of week ...
case 0: // sunday
$tmp_shipdate = 1;
break;
case 5: // friday
$tmp_shipdate = 3;
break;
case 6: // saturday
$tmp_shipdate = 2;
break;
default: // mon - thrs
$tmp_shipdate = 1;
} // End Switch
return $tmp_shipdate;
} // End Function
function UPS_Date($tmp_date){
// Calculate how many days to add to the order date to get UPS dates
list($month, $day, $year) = explode('/', $tmp_date);
$tmp_long_date = mktime(0, 0, 0, $month, $day, $year);
$tmp_wkday = date('w',$tmp_long_date); // determine day of week number
switch ($tmp_wkday){ // if ship date is on certain day of week ...
case 0: // sunday
$tmp_shipdate = 1;
break;
case 5: // friday
$tmp_shipdate = 3;
break;
case 6: // saturday
$tmp_shipdate = 2;
break;
default: // mon - thrs
$tmp_shipdate = 1;
} // End Switch
return $tmp_shipdate;
} // End Function
function Postal_Date($tmp_date){
// Calculate how many days to add to the order date to get United States Postal Service Date
list($month, $day, $year) = explode('/', $tmp_date);
$tmp_long_date = mktime(0, 0, 0, $month, $day, $year);
$tmp_wkday = date('w',$tmp_long_date); // determine day of week number
switch ($tmp_wkday){ // if ship date is on certain day of week ...
case 0: // sunday
$tmp_shipdate = 3;
break;
case 4: // thursday
$tmp_shipdate = 4;
break;
case 5: // friday
$tmp_shipdate = 4;
break;
case 6: // saturday
$tmp_shipdate = 4;
break;
default: // Mon - Wed
$tmp_shipdate = 3;
} // End Switch
return $tmp_shipdate;
} // End Function
function monthday($tmp_date){
// format date into month/day (m/d)
list($month, $day, $year) = explode('/', $tmp_date);
return date("m/d", mktime(0, 0, 0, $month, $day, $year));
}
// Get Today's Date Variables
$tdate = date("m/d/Y");
$tdate_name = WeekDay(date('w'));
// calculate date shipped
$tmp_date_ship = date("m/d/y", mktime(0, 0, 0, date("m") , date("d") + date_shipped(date("m/d/y")), date("y")));
// check if it falls on a no pickup day
$date_ship = UPS_NoPickup($tmp_date_ship);
list($month, $day, $year) = explode('/', $date_ship);
$date_ship_name = WeekDay (date("w", mktime(0, 0, 0, $month, $day, $year)));
// calculate UPS Next Day
list($month, $day, $year) = explode('/', $date_ship);
$tmp_ups_nextday = date("m/d/y", mktime(0, 0, 0, $month, $day + UPS_Date($date_ship), $year));
// check if it is on a no delivery date
$ups_nextday = UPS_NoDelivery($tmp_ups_nextday);
list($month, $day, $year) = explode('/', $ups_nextday);
$ups_nextday_name = WeekDay (date("w", mktime(0, 0, 0, $month, $day, $year)));
// calculate UPS 2 Day
list($month, $day, $year) = explode('/', $ups_nextday);
$tmp_ups_2day = date("m/d/y", mktime(0, 0, 0, $month, $day + UPS_Date($ups_nextday), $year));
// check if it is on a no delivery date
$ups_2day = UPS_NoDelivery($tmp_ups_2day);
list($month, $day, $year) = explode('/', $ups_2day);
$ups_2day_name = WeekDay(date("w", mktime(0, 0, 0, $month, $day, $year)));
// calculate UPS 3 Day
list($month, $day, $year) = explode('/', $ups_2day);
$tmp_ups_3day = date("m/d/y", mktime(0, 0, 0, $month, $day + UPS_Date($ups_2day), $year));
// check if it is on a no delivery date
$ups_3day = UPS_NoDelivery($tmp_ups_3day);
list($month, $day, $year) = explode('/', $ups_3day);
$ups_3day_name = WeekDay(date("w", mktime(0, 0, 0, $month, $day, $year)));
// calculate Postal Priority
list($month, $day, $year) = explode('/', $date_ship);
$tmp_postal_priority = date("m/d/y", mktime(0, 0, 0, $month, $day + Postal_Date($date_ship), $year));
$postal_priority = Postal_Holiday($tmp_postal_priority);
list($month, $day, $year) = explode('/', $postal_priority);
$postal_priority_name = WeekDay(date("w", mktime(0, 0, 0, $month, $day, $year)));
?>
Order
Received |
Order
Shipped |
Estimated
Delivery Dates1 |
UPS
Next Day |
UPS
2nd Day |
UPS
3 Day Select |
|
|
echo $tdate_name . " " . monthday($tdate); ?> |
echo $date_ship_name . " " . monthday($date_ship); ?> |
echo $ups_nextday_name . " " . monthday($ups_nextday); ?> |
echo $ups_2day_name . " " . monthday($ups_2day); ?> |
echo $ups_3day_name . " " . monthday($ups_3day); ?> |
// there is no state passed in so
if (!$_POST){
print "";
}else{
// state is passed in so run routine and dispaly "new state" link
$tmp_state=$_POST['new_state'];
$ups_ground_date = UPS_Ground($tmp_state, $date_ship);
list($month, $day, $year) = explode('/', $ups_ground_date);
$ups_ground_date_name = WeekDay(date("w", mktime(0, 0, 0, $month, $day, $year)));
print "$ups_ground_date_name " . monthday($ups_ground_date) . " ";
print "Calculate New State";
}
?>
|
echo $postal_priority_name . " " . monthday($postal_priority); ?> |
| Delivery Schedule Notes: |
| 1. |
Delivery times listed are estimates only. |
| 2. |
In the United States, UPS
observes the following holidays: |
| |
- Memorial Day - May 28, 2007
- Independence Day - July 4, 2007
- Labor Day - September 3, 2007
- Thanksgiving Day - November 22,
2007
- Day after Thanksgiving - November 23, 2007
- Christmas Day - December
25, 2007
- New Year´s Eve - December 31, 2007
- New Year's Day - January
1, 2008
|
| 3. |
US Postal Service Priority Mail estimated time of
2-3 days is not guaranteed. |
|
|
|
|
|