$dnum = date(Ymd)*4; $from=$_POST['fr']; if($from==""){ $from=$_GET['fr']; } if($from!=$dnum){ echo("Unauthorized."); exit(); } $usrn=$_GET['usrn']; $usr=$_GET['usr']; $QID=$_GET['QID']; $CID=$_GET['CID']; $go=$_GET['go']; //nw or ch $qty = $_GET['qty']; $pr = $_GET['pr']; $item=$_GET['item']; $dbcnx = @mysql_connect('mysql.plainhost.com', 'ecosmar_ecosmart', 'ecoman1'); mysql_select_db('ecosmar_inv', $dbcnx); $getshipto=mysql_query("SELECT ID,Name,Company,Phone,Address,City,State,ZipCode FROM q_ship WHERE QID='$QID'"); if(!$getshipto){ $air[]="Could not get Ship To info: ".mysql_error(); }else{ $row=mysql_fetch_array($getshipto); $ID=$row['ID']; $Name=$row['Name']; $Company=$row['Company']; $Phone=$row['Phone']; $Address=$row['Address']; $City=$row['City']; $State=$row['State']; $ZipCod=$row['ZipCode']; $ZipCode=substr($ZipCod, 0, 5); }//gotshitpoo ///////////////////////////////check for carrier mysql_select_db('ecosmar_products', $dbcnx); $chkshipitem=mysql_query("SELECT carrier,flat FROM ship WHERE item='$item'"); if(!$chkshipitem){ $air[]="Could not get basic ship info: ".mysql_error(); }else{ $rowc=mysql_fetch_array($chkshipitem); $carcheck=$rowc[0]; $flatcheck=$rowc[1]; } ////////////////////////////////////check for flat rate if($flatcheck=="none" or $flatcheck==""){ $calc="on"; }elseif($flatcheck=="fixed"){ $getfixed=mysql_query("SELECT minimum,handling,rate_1 FROM ship WHERE item='$item'"); if(!$getfixed){ $air[]="Could not get fixed rate info: ".mysql_error(); }else{ $row=mysql_fetch_array($getfixed); $minimum=$row['minimum']; $handling=$row['handling']; $rate_1=$row['rate_1']; $price=($rate_1+$handling)*$qty; if($price < $minimum){ $shipprice=$minimum; }//price is less than minimum else{ $shipprice=$price; }//price is more than minimum }//gotfixed }//flat is fixed elseif($flatcheck=="percent"){ $getperc=mysql_query("SELECT minimum,handling,rate_1 FROM ship WHERE item='$item'"); if(!$getperc){ $air[]="Could not get percent rate info: ".mysql_error(); }else{ $row=mysql_fetch_array($getperc); $minimum=$row['minimum']; $handling=$row['handling']; $rate=$row['rate_1']*.01; $pricer=$rate_1*$pr; $price=($pricer+$handling)*$qty; if($price < $minimum){ $newshipprice=$minimum; }//price is less than minimum else{ $newshipprice=$price; }//price is more than minimum }//gotfixed }//flat is percent elseif($flatcheck=="weight"){ $getwgt=mysql_query("SELECT weight_lbs,minimum,handling,rate_1,rate_wgt_1,rate_2,rate_wgt_2,rate_3,rate_wgt_3 FROM ship WHERE item='$item'"); if(!$getwgt){ $air[]="Could not get weight rate info: ".mysql_error(); }else{ $row=mysql_fetch_array($getwgt); $weight_lbs=$row['weight_lbs']; $minimum=$row['minimum']; $handling=$row['handling']; $rate_1=$row['rate_1']; $rate_wgt_1=$row['rate_wgt_1']; $rate_2=$row['rate_2']; $rate_wgt_2=$row['rate_wgt_2']; $rate_3=$row['rate_3']; $rate_wgt_3=$row['rate_wgt_3']; $chkwgt=$weight_lbs*qty; if($chkwgt < $rate_wgt_1){ $rate=$rate_1; }elseif($chkwgt > $rate_wgt_1 AND $chkwgt < $rate_wgt_2){ $rate=$rate_2; }elseif($chkwgt > $rate_wgt_2 AND $chkwgt < $rate_wgt_3){ $rate=$rate_3; }else{ $shipforce="force"; $forcemess="Weight is too great for weight rate to be applied automatically."; }//no rate can be applied force shipping $price=($rate+$handling)*$qty; if($price < $minimum){ $newshipprice=$minimum; }//price is less than minimum else{ $newshipprice=$price; }//price is more than minimum }//gotwgt }//flat is weight else{ $calc="on"; }//flat fits no mold $getit=mysql_query("SELECT carrier,crr_phone,o_city,o_country,o_code,unit,weight_lbs,height_in,width_in,length_in,custom,currency,minimum,handling FROM ship WHERE item='$item'"); if(!$getit){ $air[]="Could not get info for calculation: ".mysql_error(); }else{ $row=mysql_fetch_array($getit); $carrier=$row['carrier']; $crr_phone=$row['crr_phone']; $o_city=$row['o_city']; $o_country=$row['o_country']; $o_code=$row['o_code']; $unit=$row['unit']; $weight_lbs=$row['weight_lbs']; $height_in=$row['height_in']; $width_in=$row['width_in']; $length_in=$row['length_in']; $custom=$row['custom']; $currency=$row['currency']; $minimum=$row['minimum']; $handling=$row['handling']; if($calc=="on"){ if($carrier=="UPS" or $carrier=="ups"){ $girth=($height_in*2)+($width_in*2); $dimension=$girth+$length_in; if($dimension>150){ $shipforce="force"; $forcemess="Package dimensions are oversized. Rate cannot be applied automatically."; $upscrr_phone="1-800-333-7400"; }else{ $upscrr_phone="1-800-742-5877"; if($dimension>130){ $weight=90; }else{ $weight=$weight_lbs; }//dimensions are commensurate with weight class if($Company==""){ $opt1=""; $opt2=""; }else{ $opt1=""; $opt2=""; } ///////////filter before sending to UPS $goup="yes"; if(is_numeric($o_code)){ $goup="yes"; }else{ $goup="no"; $goupmess="Unable to get Outgoing Zip Code."; } if($weight=="" or $weight==0){ $goup="no"; $goupmess="Unable to determine weight."; } if($goup=="yes"){ $ups="on"; echo("
" . ""); }//goup is yes else{ $shipforce="force"; $forcemess=$goupmess." Rate cannot be applied automatically."; }//goup is not yes }//dimensions are not oversized }//carrier is ups else{ $shipforce="force"; $forcemess="Carrier not automated. Rate cannot be applied automatically."; }//carrier is not UPS }//calculate is on }//gotit if($ups!="on"){ $carrier="BST"; if($shipforce!="force" AND $newshipprice !=""){ echo("" . "" . "Shipping Cost for: ($quantity) $item" . " |
$shipprice" .
" Click "ADD TO QUOTE" to Update Quote." . " |
" . "Unable to calculate shipping automatically." . " |
$forcemess " . "Click "GO" to Enable Manual input." . " Look for shipping information in Quote Notes." . " |
" . "Eco-\$mart Shipping" . " | Cancel" . " |