\n"; $HTML .= "\n"; $HTML .= "\n"; $HTML .= "".lang("BILLING INFORMATION")."      

\n"; $HTML .= "$BFIRSTNAME $BLASTNAME
"; if ($BCOMPANY != "") { $HTML .= "$BCOMPANY
\n"; } $HTML .= "$BADDRESS1
\n"; if ($BADDRESS2 != "") { $HTML .= "$BADDRESS2
\n"; } $HTML .= "$BCITY, $BSTATE    $BZIPCODE
\n"; $HTML .= "$BCOUNTRY

\n"; $HTML .= "$BPHONE
\n"; $HTML .= "$BEMAILADDRESS\n"; $HTML .= "\n"; # Show Shipping Info on Invoice? if ( $cartprefs->get("disable_shipping") == "yes" ) { $show_shipping = "hidden"; }else{ $show_shipping = "visible"; } $HTML .= "\n"; $HTML .= "".lang("SHIPPING INFORMATION")."      

\n"; $HTML .= "$SFIRSTNAME $SLASTNAME
"; if ($SCOMPANY != "") { $HTML .= "$SCOMPANY
\n"; } $HTML .= "$SADDRESS1
\n"; if ($SADDRESS2 != "") { $HTML .= "$SADDRESS2
\n"; } $HTML .= "$SCITY, $SSTATE    $SZIPCODE
\n"; $tmpSC = split(" - ",$SCOUNTRY); $HTML .= "$tmpSC[0] - $tmpSC[1]

\n"; $HTML .= "$SPHONE
\n"; $HTML .= "\n"; $HTML .= "\n"; $HTML .= "
\n\n"; # Show view/edit cart link? $cartpref = new userdata("cart"); if ( $cartpref->get("invoice_viewedit_link") == "yes" ) { $HTML .= "\n\n"; } if ( $taxpref->get('vat-or-gst') == "" ) { $taxpref->set("vat-or-gst", 'VAT'); } ############################################################################################ // Show invoice notice for offline shipping calculation ############################################################################################ if ( $SHIPPING_OPTS[SHIP_METHOD] == "Offline" ) { $HTML .= "\n"; $HTML .= " \n"; $HTML .= " \n"; $HTML .= " \n"; $HTML .= "
\n"; $HTML .= " \n"; $HTML .= " ".$SHIPPING_OPTS[NOTICE]; $HTML .= " \n"; $HTML .= "
\n"; $HTML .= "
\n"; } ############################################################################################ // ----------------------------------------------------------------------------------------- // NOW DISPLAY ACTUAL INVOICE LINE ITEMS // ----------------------------------------------------------------------------------------- ############################################################################################ $HTML .= "\n"; $tmp_formdata = split(":p:", $CART_FORMDATA); $tmp_keyid = split(";", $CART_KEYID); $tmp_qty = split(";", $CART_QTY); $tmp_skuno = split(";", $CART_SKUNO); $tmp_catno = split(";", $CART_CATNO); $CART_PRODNAME = str_replace('<', '<', $CART_PRODNAME); $CART_PRODNAME = str_replace('>', '>', $CART_PRODNAME); $tmp_name = split(";", $CART_PRODNAME); foreach($tmp_name as $var=>$val){ $tmp_name[$var] = str_replace('>', '>', $tmp_name[$var]); $tmp_name[$var] = str_replace('<', '<', $tmp_name[$var]); } $tmp_subcat = split(";", $CART_SUBCAT); $tmp_varname = split(";", $CART_VARNAME); $tmp_price = split(";", $CART_UNITPRICE); $tmp_sub = split(";", $CART_UNITSUBTOTAL); $display_subtotal = 0; // Reset Display sub_total; we'll calculate that on the fly $line_items = count($tmp_qty); // Count the number of array vars we have after split $line_items = $line_items - 2; // Subtract 2 because (a)we start count at 0 (b) we always have a trailing semi-colon; # Alternate row bg color if ($sep == "row-altbg") { $sep = "row-normalbg"; } else { $sep = "row-altbg"; } /*--Test session data---* $HTML .= " \n"; $HTML .= " \n"; $HTML .= " \n"; $HTML .= " \n"; $HTML .= " \n"; $HTML .= " \n"; /*--Test session data---*/ $HTML .= "\n"; $HTML .= "\n"; $HTML .= "\n"; $HTML .= "\n"; $HTML .= "\n"; $HTML .= "\n"; for ($z=0;$z<=$line_items;$z++) { $display_subtotal = $display_subtotal + $tmp_sub[$z]; // Add Unit Sub Total to Total Sub Total ??? Confused yet? if ($sep == "row-altbg") { $sep = "row-normalbg"; } else { $sep = "row-altbg"; } if (strlen($tmp_subcat[$z]) > 2) { $tmp_varname[$z] = "- " . $tmp_varname[$z]; } // Format for proper display // ----------------------------------------------------------- // Build display for sku number and catalog number in invoice // ----------------------------------------------------------- $ref_id_display = "
"; if ($tmp_skuno[$z] != "") { $ref_id_display .= "[Sku: $tmp_skuno[$z]] "; } if ($tmp_catno[$z] != "") { $ref_id_display .= "[Cat: $tmp_catno[$z]] "; } $ref_id_display .= "
"; $ref_id_display = strtoupper($ref_id_display); // ----------------------------------------------------------- $tmp_name[$z] = str_replace("#Q#", """, $tmp_name[$z]); // Fix for quotes not appearing in product name $HTML .= "\n"; $HTML .= "\n"; $HTML .= "\n"; $HTML .= "\n"; $HTML .= "\n"; $HTML .= "\n"; } // End of $z Loop // ======================================================================================== // DISPLAY ORDER SUB-TOTAL // ======================================================================================== if ($sep == "row-altbg") { $sep = "row-normalbg"; } else { $sep = "row-altbg"; } $HTML .= "\n"; $HTML .= "\n"; $HTML .= "\n"; $HTML .= "\n"; $HTML .= "\n"; // ======================================================================================== // DISPLAY TAX TOTAL // ======================================================================================== // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // Read Tax Table to determine if current ship-to state/country needs // to be charged sales tax // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ //Make sure tax variables are upper case $BSTATE = strtoupper($BSTATE); $SSTATE = strtoupper($SSTATE); $BCOUNTRY = strtoupper($BCOUNTRY); $SCOUNTRY = strtoupper($SCOUNTRY); $taxpref = new userdata("tax_rate_options"); $stax_perc = "$stax_perc"; $result = mysql_query("SELECT * FROM cart_tax"); while ($TAX = mysql_fetch_array($result)) { // if ($BSTATE == trim($TAX['state'])) { // $stax_perc = $TAX['rate']; // } // BUG FIX #656 Provided by nsna_andrew if ($taxpref->get("taxby") == "SCOUNTRY") { if ($SSTATE == trim($TAX['state'])) { $stax_perc = $TAX['rate']; } } else { if ($BSTATE == trim($TAX['state'])) { $stax_perc = $TAX['rate']; } } } //====================== //Check for VAT tax //====================== # Make sure there's a VAT number if ($OPTIONS[CHARGE_VAT] == "yes" && $OPTIONS[VAT_REG] != "vatnum") { $ctax_perc = "$ctax_perc"; $result = mysql_query("SELECT * FROM cart_vat"); while ( $VAT = mysql_fetch_array($result) ) { # Set default if no value if ( $taxpref->get("taxby") == "" ) { $taxpref->set("taxby", "BCOUNTRY"); } if ( ${$taxpref->get("taxby")} == $VAT['country'] ) { $ctax_perc = $VAT['rate']; } } } // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // If so, calculate tax // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ if ( ($stax_perc != "") || ($ctax_perc != "") ) { $staxrate = $stax_perc; $ctaxrate = $ctax_perc; $scalcTax = $staxrate / 100; $ccalcTax = $ctaxrate / 100; $exempt = 0; // Bugzilla #38 $vatSub = 0; // Euro Stuff - 040408 $numSkus = count($tmp_skuno); // Bugzilla #38 // Account for "tax exempt" items in calculation - Bugzilla #38 // 2004-04-08: Also account for items with special VAT rate // 2004-08-02: Check new "SPECIAL_TAX" field and leave SHIPC alone for ($m=0;$m<=$numSkus;$m++) { $result = mysql_query("SELECT * FROM cart_products WHERE PROD_SKU = '$tmp_skuno[$m]'"); $getProd = mysql_fetch_array($result); if ($getProd[OPTION_CHARGETAX] == "N" ) { $exempt += $tmp_sub[$m]; } if ($getProd[SPECIAL_TAX] != "") { $vatRate = $getProd[SPECIAL_TAX]; $calcVat = $vatRate / 100; $vatSub += $calcVat * $tmp_sub[$m]; } } $tax_subtotal = $display_subtotal - $exempt; // Bugzilla #38 $sthisTax = $tax_subtotal * $scalcTax; // Bugzilla #38 $cthisTax = $tax_subtotal * $ccalcTax; // Bugzilla #38 $stax = number_format($sthisTax,2); $ctax = number_format($cthisTax,2); $staxrate = "( $stax_perc% )"; if ( $ctax_perc == "" ){ $ctaxrate = "( 0% )"; } else { $ctaxrate = "( $ctax_perc% )"; } } else { $staxrate = ""; $ctaxrate = ""; // Account for Special Tax items when no tax is charged - Bugzilla #38 $numSkus = count($tmp_skuno); // Bugzilla #38 for ($s=0;$s<=$numSkus;$s++) { $result = mysql_query("SELECT * FROM cart_products WHERE PROD_SKU = '$tmp_skuno[$s]'"); $getSpecial = mysql_fetch_array($result); if ($getSpecial[SPECIAL_TAX] != "") { $vatRate = $getSpecial[SPECIAL_TAX]; $calcVat = $vatRate / 100; $vatSub += $calcVat * $tmp_sub[$s]; } } //$sdisplay_tax = "0.00"; //$cdisplay_tax = "0.00"; } # Country tax: Do not display here if option to charge tax after shipping is set if ( $cthisTax != "" && $cthisTax > 0 && $taxpref->get("taxwhen") != "aftershipping" ) { $HTML .= "\n"; $HTML .= "\n"; //$HTML .= "\n"; $HTML .= "\n"; $HTML .= "\n"; } # Vat item tax if ( $vatSub != "" && $vatSub != "0.00" ){ $HTML .= "\n"; $HTML .= "\n"; $HTML .= "\n"; $HTML .= "\n"; $HTML .= "\n"; } # State tax: Do not display here if option to charge tax after shipping is set if ( $sthisTax != "" && $sthisTax != "0.00" && $taxpref->get("taxwhen") != "aftershipping" ) { $HTML .= "\n"; $HTML .= "\n"; $HTML .= "\n"; $HTML .= "\n"; $HTML .= "\n"; } ########################################################################################### // DISPLAY SHIPPING TOTAL ########################################################################################### $HTML .= " \n"; $HTML .= " \n"; $HTML .= " \n"; $HTML .= " \n"; # STATE TAX: Update tax total to include shipping? # Include shipping charges in tax calculation? if ( $taxpref->get("taxwhen") == "aftershipping" && $sthisTax > 0 ) { // Cameron Fix, ( make sure to not include shipping total twice if using country and state tax); $state_tax = 'included'; $state_sub_total_with_shipping = $tax_subtotal + $SHIPPING_TOTAL; // end cam fix $tax_subtotal = $tax_subtotal + $SHIPPING_TOTAL; $sthisTax = $scalcTax * $tax_subtotal; // $HTML .= "
New taxed total: [".$tax_subtotal."]
"; // $HTML .= "
New tax amount: [".$taxed_shipping."]
"; # Display tax total after shipping charges $HTML .= " \n"; $HTML .= " \n"; $HTML .= " \n"; $HTML .= " \n"; $HTML .= " \n"; } # COUNTRY TAX: Update tax total to include shipping? # Include shipping charges in tax calculation? if ( $taxpref->get("taxwhen") == "aftershipping" && $cthisTax > 0 ) { // Cameron Fix, ( make sure to not include shipping total twice if using country and state tax); if($state_tax == 'included'){ $tax_subtotal = $state_sub_total_with_shipping; $cthisTax = $ccalcTax * $tax_subtotal; } else { $tax_subtotal = $tax_subtotal + $SHIPPING_TOTAL; $cthisTax = $ccalcTax * $tax_subtotal; } // end cam fix // $HTML .= "
New taxed total: [".$tax_subtotal."]
"; // $HTML .= "
New tax amount: [".$taxed_shipping."]
"; # Display tax total after shipping charges $HTML .= " \n"; $HTML .= " \n"; $HTML .= " \n"; $HTML .= " \n"; $HTML .= " \n"; } ########################################################################################### // DISPLAY TOTAL SALE COST ########################################################################################### //more testing //echo "SHIPPING_TOTAL >> ($SHIPPING_TOTAL)
\n"; $ORDER_TOTAL = $display_subtotal + $sthisTax + $cthisTax + $vatSub + $SHIPPING_TOTAL; //echo "ORDER_TOTAL = display_subtotal($display_subtotal) + display_tax($display_tax) + SHIPPING_TOTAL($SHIPPING_TOTAL)
\n"; $ORDER_TOTAL = sprintf ("%01.2f", $ORDER_TOTAL); //echo "FINAL ORDER_TOTAL ----->> $ORDER_TOTAL\n"; $HTML .= "\n"; $HTML .= "\n"; $HTML .= "\n"; $HTML .= "\n"; $HTML .= "\n"; // Register ORDER_TOTAL with our session for databasing and payment processing // ------------------------------------------------------------------------------------- if (!session_is_registered("ORDER_TOTAL")) { session_register("ORDER_TOTAL"); } $_SESSION['ORDER_TOTAL'] = $ORDER_TOTAL; $HTML .= "
\n"; $HTML .= " Order Number: ".$ORDER_NUMBER."\n"; $HTML .= "
\n"; $HTML .= " Order Total: ".$ORDER_TOTAL."\n"; $HTML .= "
\n"; $HTML .= "".lang("Product Name")."\n"; $HTML .= "\n"; $HTML .= "".lang("Unit Price")."\n"; $HTML .= "\n"; $HTML .= "".lang("Quantity")."\n"; $HTML .= "\n"; $HTML .= "".lang("Sub-Total")."\n"; $HTML .= "
\n"; //Do we need to display special VAT rate? $result = mysql_query("SELECT * FROM cart_products WHERE PROD_SKU = '$tmp_skuno[$z]'"); $getVat = mysql_fetch_array($result); $specVat = ""; if ($getVat['SPECIAL_TAX'] != "" && $OPTIONS['CHARGE_VAT'] == "yes" && $OPTIONS['VAT_REG'] != "vatnum") { $specVat = "(".$taxpref->get('vat-or-gst')." ".$getVat['SPECIAL_TAX']."%)"; } $HTML .= "$ref_id_display".$tmp_name[$z]." ".$specVat."
".$tmp_subcat[$z]." ".$tmp_varname[$z]."\n"; $HTML .= ""; //format form data into line-items $form_line = split(":br:", $tmp_formdata[$z]); $num_fl = count($form_line); for ($f=0;$f<=$num_fl;$f++) { $HTML .= $form_line[$f] . "
\n"; } eval(hook("pgm-more_information.php:dispinv")); $HTML .= "
"; $HTML .= "
\n"; $HTML .= $dSign."".$tmp_price[$z]."\n"; $HTML .= "\n"; $HTML .= "[".$tmp_qty[$z]."]\n"; $HTML .= "\n"; $tmp_sub[$z] = sprintf ("%01.2f", $tmp_sub[$z]); $HTML .= $dSign."$tmp_sub[$z]\n"; $HTML .= "
\n"; $HTML .= "\n"; $HTML .= "\n"; $HTML .= "Sub-Total:\n"; $HTML .= "\n"; $display_subtotal = sprintf ("%01.2f", $display_subtotal); $HTML .= $dSign."$display_subtotal\n"; $HTML .= "
\n"; $HTML .= "\n"; $HTML .= "\n"; $HTML .= "\n"; $HTML .= " ".$BCOUNTRY." Tax ".$ctaxrate.":\n"; $HTML .= "\n"; $cthisTax = sprintf ("%01.2f", $cthisTax); $HTML .= $dSign.$cthisTax."\n"; $HTML .= "
\n"; $HTML .= "\n"; $HTML .= "\n"; $HTML .= lang("Special Tax")." ".$getVat[SPECIAL_TAX]."%: \n"; $HTML .= "\n"; $vatSub = sprintf ("%01.2f", $vatSub); $HTML .= $dSign."$vatSub\n"; $HTML .= "
\n"; $HTML .= "\n"; $HTML .= "\n"; // BUG FIX #656 Provided by nsna_andrew $HTML .= ($taxpref->get("taxby") == "SCOUNTRY" ? $SSTATE : $BSTATE); $HTML .= " ".lang("Tax")." ".$staxrate.": \n"; // $HTML .= $BSTATE." ".lang("Tax")." ".$staxrate.": \n"; $HTML .= "\n"; $sthisTax = sprintf ("%01.2f", $sthisTax); $HTML .= $dSign."".$sthisTax."\n"; $HTML .= "
\n"; $HTML .= " $SHIPPING_INSTRUCTIONS    ".lang("Shipping & Handling").":\n"; $HTML .= " \n"; $sshiptax = 0; $cshiptax = 0; // Do not echo price value if using Offline Shipping // =================================================== if ( $SHIPPING_OPTS[SHIP_METHOD] == "Offline" ) { // Pending Calculation $HTML .= " ".lang("Pending Calculation")."\n"; } else { # Account for shipping option to disable charging shipping for individual products # Note: Only for non-subtotal shipping charge method. SubTotal-based shipping charges calculated in pgm-checkout.php:825 if ( $SHIPPING_OPTS['SHIP_METHOD'] != "SubTotal" ) { for ($m=0;$m<=$numSkus;$m++) { $result = mysql_query("SELECT * FROM cart_products WHERE PROD_SKU = '$tmp_skuno[$m]'"); $getProd = mysql_fetch_array($result); if ($getProd['OPTION_CHARGESHIPPING'] == "N") { $amoutToDel = $getProd['PROD_SHIPA']*$tmp_qty[$m]; $SHIPPING_TOTAL = $SHIPPING_TOTAL - $amoutToDel; // # Testing - Items with disabled shipping // echo "shipping for sku num(".$getProd[PROD_SKU].") and prikey (".$getProd[PRIKEY].") is (".$getProd[PROD_SHIPA].")
"; // echo "The current row is (".$m.")
"; // echo "qty in session (".$tmp_qty[$m].")
"; // echo "This is the amount to delete (".$amoutToDel.")
"; } } } $SHIPPING_TOTAL = sprintf ("%01.2f", $SHIPPING_TOTAL); $HTML .= " ".$dSign.$SHIPPING_TOTAL."\n"; } $HTML .= "
\n"; $HTML .= "  \n"; $HTML .= " \n"; // BUG FIX #656 Provided by nsna_andrew $HTML .= ($taxpref->get("taxby") == "SCOUNTRY" ? $SSTATE : $BSTATE); $HTML .= " ".lang("Tax")." ".$staxrate.": \n"; // $HTML .= $BSTATE." ".lang("Tax")." ".$staxrate.": \n"; $HTML .= " \n"; $sthisTax = sprintf ("%01.2f", $sthisTax); $HTML .= $dSign."".$sthisTax."\n"; $HTML .= "
\n"; $HTML .= "  \n"; $HTML .= " \n"; $HTML .= ${$taxpref->get("taxby")}." ".lang("Tax")." ".$ctaxrate.": \n"; $HTML .= " \n"; $cthisTax = sprintf ("%01.2f", $cthisTax); $HTML .= $dSign."".$cthisTax."\n"; $HTML .= "
\n"; $HTML .= "\n"; $HTML .= "\n"; $HTML .= "".lang("Total").":\n"; $HTML .= "\n"; $HTML .= "".$dSign.$ORDER_TOTAL."\n"; $HTML .= "
\n\n"; echo $HTML; ?>