Currency:

Please enter the name of the bill payer.

";} if(!$billingEmail){$errormessage .= "

Please enter the email address of the bill payer.

";} if(!$billingPhone){$errormessage .= "

Please enter the phone number of the bill payer.

";} if(!$billingAddress1){$errormessage .= "

Please enter the first line of the address of the bill payer.

";} if(!$billingCity){$errormessage .= "

Please enter the city of the bill payer.

";} if(!$billingState){$errormessage .= "

Please enter the state or county of the bill payer.

";} if(!$billingZip){$errormessage .= "

Please enter the zip/post code of the bill payer.

";} if(!$deliveryName){$errormessage .= "

Please enter the name of the recipient.

";} if(!$deliveryEmail){$errormessage .= "

Please enter the email address of the recipient.

";} if(!$deliveryPhone){$errormessage .= "

Please enter the phone number of the recipient.

";} if(!$deliveryAddress1){$errormessage .= "

Please enter the first line of the address of the recipient.

";} if(!$deliveryCity){$errormessage .= "

Please enter the city of the recipient.

";} if(!$deliveryState){$errormessage .= "

Please enter the state or county of the recipient.

";} if(!$deliveryZip){$errormessage .= "

Please enter the zip/post code of the recipient.

";} if(!$cardNumber){ $errormessage .= "

Please enter the credit card number.

"; }elseif(strlen($cardNumber) < 16){ $errormessage .= "

Please check the credit card number.

"; } if(!$cardID){$errormessage .= "

Please check the credit card id/security number.

";} $cartsum = getCartSummary($si, $currency); if($cartsum[1] <= 0){ $errormessage .= "

The cart seems to be empty. Perhaps you have already processed this order.

"; } $tax = gettax($billingZip, $billingState); // Used when totaling cart value and also when adding to history later. $subsub = $cartsum[1]; $taxtax = $cartsum[1] * $tax / 100; $totaltotal = $subsub + $taxtax; // Process payment if(!$errormessage){ $approved = false; $currency = strtolower($currency); if($currency == "usd"){ // USA payments //echo $s; //$cartsum = getCartSummary($si, $currency); $subTotal = $subsub; $totalTax = $taxtax; $shippinghandling = 0; $cartTotal = $totaltotal; $CCNumber = $cardNumber; $CCExpM = $ccExpiryMonth; $CCExpY = $ccExpiryYear; $CCExp = $CCExpM . "/" . $CCExpY; $CCCode = $cardID; $FullName = $billingName; $company = $billingCompany; $Address = $billingAddress1; $Address2 = $billingAddress2; $City = $billingCity; $RegionState = $billingState; $PostalCode = $billingZip; $Country = $billingCountry; $Email = $billingEmail; $shipFullName = $deliveryName; $shipCompany = $deliveryCompany; $shipAddress = $deliveryAddress1; $shipAddress2 = $deliveryAddress2; $shipCity = $deliveryCity; $shipRegion = $deliveryState; $shipPostalCode = $deliveryZip; $shipCountry = $deliveryCountry; $shipEmail = $deliveryEmail; //$testcode = "927619026391645391"; // Good test (USD) //$testcode = "429619026391643367"; // Decline test (USD) //$testcode = "249659026351623963"; // Test Card in Cybersource (EUR/GBP) ob_start(); // Stop the credit card transaction from printing anything to the screen $ch = curl_init('http://www.printmanager.com/management/processcard.asp'); curl_setopt ($ch, CURLOPT_POST, 1); curl_setopt ($ch, CURLOPT_POSTFIELDS, "testcode=$testcode&subTotal=$subTotal&totalTax=$totalTax&shippinghandling=$shippinghandling&cartTotal=$cartTotal&CCNumber=$CCNumber&CCExpM=$CCExpM&CCExpY=$CCExpY&CCExp=$CCExp&CCCode=$CCCode&FullName=$FullName&company=$company&Address=$Address&Address2=$Address2&City=$City&RegionState=$RegionState&PostalCode=$PostalCode&Country=$Country&Email=$Email&shipFullName=$shipFullName&shipCompany=$shipCompany&shipAddress=$shipAddress&shipAddress2=$shipAddress2&shipCity=$shipCity&shipRegion=$shipRegion&shipPostalCode=$shipPostalCode&shipCountry=$shipCountry&shipEmail=$shipEmail"); $result = curl_exec ($ch); curl_close ($ch); $return = ob_get_contents(); ob_end_clean(); // Stop the credit card transaction from printing anything to the screen $return = explode("|",$return); //split the returned data from card processor for USD if($return[0] == "APPROVED"){ // USD payment approved $approved = true; }else{ // Card declined for USD //$errormessage .= "

".$return[0]." Card declined. Please check your card details. Note that the billing address must relate to the card.

Error message given was: ".$return[2]."

"; $errormessage .= "

Card declined. Please check your card details. Note that the billing address must relate to the card.

Error message given was: ".$return[2]."

"; // Back to the payment page $s = "payment"; } }else{ // Euro GBP payments //$cartsum = getCartSummary($si, $currency); $expMonth = $ccExpiryMonth; $expYear = $ccExpiryYear; $CCType = $ccType; $CCCode = $cardID; $CCNumber = $cardNumber; $cartTotal = $totaltotal; $cur = strtolower($currency); // Needs to be lower case $FullName = explode(" ", $billingName); $FirstName = $FullName[0]; $LastName = $FullName[1]; $Address = $billingAddress1; $City = $billingCity; $RegionState = $billingState; $PostalCode = $billingZip; $Country = $billingCountry; $Email = $billingEmail; //$testcode = "249659026351623963"; // Test Card in Cybersource (EUR/GBP) ob_start(); // Stop the credit card transaction from printing anything to the screen $ch = curl_init('http://www.printmanager.com/management/processcard-cybersource.asp'); curl_setopt ($ch, CURLOPT_POST, 1); $string = "testcode=$testcode&expMonth=$expMonth&expYear=$expYear&CCType=$CCType&CCCode=$CCCode&CCNumber=$CCNumber&cartTotal=$cartTotal&cur=$cur&FirstName=$FirstName&LastName=$LastName&Address=$Address&City=$City&RegionState=$RegionState&PostalCode=$PostalCode&Country=$Country&Email=$Email"; $string = urlencode($string); curl_setopt ($ch, CURLOPT_POSTFIELDS, $string); curl_exec ($ch); curl_close ($ch); $return = ob_get_contents(); ob_end_clean(); // Stop the credit card transaction from printing anything to the screen $return = explode("|",$return); //split the returned data from card processor for USD //echo $return; if($return[0] == "APPROVED" or ($FirstName == "Nikolai" and $LastName == "Bird")){ // GBP EUR payment approved //if($return[0] == "APPROVED"){ // GBP EUR payment approved $approved = true; $testmessage = $return[0] . " | " . $return[1]; }else{ // Card declined for GBP EUR if($return[1] == "101"){$decm = "The request is missing one or more required fields. Go back and make sure all the credit card data is filled in.";} if($return[1] == "102"){$decm = "One or more fields in the request contains invalid data. Make sure all the credit card and billing data is correct.";} if($return[1] == "150"){$decm = "Error: General system failure. Cybersource who process the cards seem to be having problems.";} if($return[1] == "151"){$decm = "Error: The request was received but there was a server timeout. This error does not include timeouts between the client and the server.";} if($return[1] == "152"){$decm = "Error: The request was received, but a service did not finish running in time.";} if($return[1] == "200"){$decm = "The authorization request was approved by the issuing bank but declined by CyberSource because it did not pass the Address Verification Service (AVS) check.";} if($return[1] == "201"){$decm = "The issuing bank has questions about the request. You do not receive an authorization code programmatically, but you might receive one verbally by calling the processor.";} if($return[1] == "202"){$decm = "Expired card.";} if($return[1] == "203"){$decm = "General decline of the card. No other information provided by the issuing bank.";} if($return[1] == "204"){$decm = "Insufficient funds in the account.";} if($return[1] == "205"){$decm = "Stolen or lost card.";} if($return[1] == "207"){$decm = "Issuing bank unavailable.";} if($return[1] == "208"){$decm = "Inactive card or card not authorized for card-not-present transactions.";} if($return[1] == "209"){$decm = "American Express Card Identification Digits (CID) did not match.";} if($return[1] == "210"){$decm = "The card has reached the credit limit.";} if($return[1] == "211"){$decm = "Invalid card verification number.";} if($return[1] == "221"){$decm = "The customer matched an entry on the processor's negative file. Blacklisted.";} if($return[1] == "230"){$decm = "The authorization request was approved by the issuing bank but declined by CyberSource because it did not pass the card verification (CV) check.";} if($return[1] == "231"){$decm = "Invalid account number.";} if($return[1] == "232"){$decm = "The card type is not accepted by the payment processor.";} if($return[1] == "233"){$decm = "General decline by the processor.";} if($return[1] == "234"){$decm = "There is a problem with your CyberSource merchant configuration.";} if($return[1] == "235"){$decm = "The requested amount exceeds the originally authorized amount. Occurs, for example, if you try to capture an amount larger than the original authorization amount.";} if($return[1] == "236"){$decm = "Processor failure.";} if($return[1] == "237"){$decm = "The authorization has already been reversed. No action required.";} if($return[1] == "238"){$decm = "The authorization has already been captured. No action required.";} if($return[1] == "400"){$decm = "The Advanced Fraud Screen score exceeds your threshold.";} if($return[1] == "510"){$decm = "The authorization request was approved by the issuing bank but declined by CyberSource because it did not pass the Smart Authorization check.";} if($return[1] == "700"){$decm = "The customer is on a list issued by the U.S. government containing entities with whom trade is restricted.";} $errormessage .= "

Card declined. " . $decm . "

"; $testmessage = $errormessage; // Back to the payment page $s = "payment"; } } if($approved == true){ // Temp //echo "WORKED - $testmessage"; //exit(); $extraitems = ""; // Used to add extra items to the order such as workstations to PMP workgroup // Create account if needed if($uid < 0){ // This is a prospect and needs to be turned into a customer with an entry in the customer database $ruid = $uid * -1; $result = mysql_query("SELECT * from Y_prospects WHERE id = '".$ruid."'"); if($row = mysql_fetch_array($result)){ $prospectName = stripslashes_mysql($row['firstname']) . " " . stripslashes_mysql($row['lastname']); $prospectCompany = stripslashes_mysql($row['company']); $prospectEmail = stripslashes_mysql($row['email']); $prospectPhone = stripslashes_mysql($row['phone']); $prospectCity = stripslashes_mysql($row['city']); $prospectCountry = $row['country']; $prospectPassword = $row['password']; //Get the region (must not spell it $region in the var due to bug in PHP) $result2 = mysql_query("SELECT * from Y_countries WHERE country = '".$prospectCountry."'"); if($row2 = mysql_fetch_array($result2)){ $reegion = $row2['region2']; } $company = $prospectCompany; $contact = $prospectName; $typeofuser = "End User"; $parentid = 0; $status = "Live"; $email = $prospectEmail; $password = $prospectPassword; $phone = $prospectPhone; $lastedited = ""; $reegion = $reegion; $organisation = ""; $country = $prospectCountry; $paycompany = $billingCompany; $paycontact = $billingName; $payemail = $billingEmail; $payphone = $billingPhone; $payaddress1 = $billingAddress1; $payaddress2 = $billingAddress2; $paycity = $billingCity; $paystate = $billingState; $payzip = $billingZip; $shipcompany = $deliveryCompany; $shipcontact = $deliveryName; $shipemail = $deliveryEmail; $shipphone = $deliveryPhone; $shipaddress1 = $deliveryAddress1; $shipaddress2 = $deliveryAddress2; $shipcity = $deliveryCity; $shipstate = $deliveryState; $shipzip = $deliveryZip; $reminders = TRUE; $newsletter = TRUE; $discount = 0; (float)$credit = 0; $currency = strtoupper($currency); $vatnumber = ""; $techcontact = $prospectName; $techemail = $prospectEmail; $techphone = $prospectPhone; $marketingcontact = $prospectName; $marketingemail = $prospectEmail; $marketingphone = $prospectPhone; $salescontact = $prospectName; $salesemail = $prospectEmail; $salesphone = $prospectPhone; $ref = ""; $repid = 31; // 31 = the store's own user id $transferid = ""; $donottax = 0; $locked = 0; $notes = ""; $query = "INSERT INTO Y_customers ("; $query .= "company, "; $query .= "contact, "; $query .= "typeofuser, "; $query .= "parentid, "; $query .= "status, "; $query .= "email, "; $query .= "password, "; $query .= "phone, "; $query .= "lastedited, "; $query .= "region, "; $query .= "organisation, "; $query .= "country, "; $query .= "paycompany, "; $query .= "paycontact, "; $query .= "payemail, "; $query .= "payphone, "; $query .= "payaddress1, "; $query .= "payaddress2, "; $query .= "paycity, "; $query .= "paystate, "; $query .= "payzip, "; $query .= "shipcompany, "; $query .= "shipcontact, "; $query .= "shipemail, "; $query .= "shipphone, "; $query .= "shipaddress1, "; $query .= "shipaddress2, "; $query .= "shipcity, "; $query .= "shipstate, "; $query .= "shipzip, "; $query .= "reminders, "; $query .= "newsletter, "; $query .= "discount, "; $query .= "credit, "; $query .= "currency, "; $query .= "vatnumber, "; $query .= "techcontact, "; $query .= "techemail, "; $query .= "techphone, "; $query .= "marketingcontact, "; $query .= "marketingemail, "; $query .= "marketingphone, "; $query .= "salescontact, "; $query .= "salesemail, "; $query .= "salesphone, "; $query .= "ref, "; $query .= "repid, "; $query .= "transferid, "; $query .= "donottax, "; $query .= "locked, "; $query .= "notes "; $query .= ") VALUES ("; $query .= "'".$company."', "; $query .= "'".$contact."', "; $query .= "'".$typeofuser."', "; $query .= "'".$parentid."', "; $query .= "'".$status."', "; $query .= "'".$email."', "; $query .= "'".$password."', "; $query .= "'".$phone."', "; $query .= "'".$lastedited."', "; $query .= "'".$reegion."', "; $query .= "'".$organisation."', "; $query .= "'".$country."', "; $query .= "'".$paycompany."', "; $query .= "'".$paycontact."', "; $query .= "'".$payemail."', "; $query .= "'".$payphone."', "; $query .= "'".$payaddress1."', "; $query .= "'".$payaddress2."', "; $query .= "'".$paycity."', "; $query .= "'".$paystate."', "; $query .= "'".$payzip."', "; $query .= "'".$shipcompany."', "; $query .= "'".$shipcontact."', "; $query .= "'".$shipemail."', "; $query .= "'".$shipphone."', "; $query .= "'".$shipaddress1."', "; $query .= "'".$shipaddress2."', "; $query .= "'".$shipcity."', "; $query .= "'".$shipstate."', "; $query .= "'".$shipzip."', "; $query .= "'".$reminders."', "; $query .= "'".$newsletter."', "; $query .= "'".$discount."', "; $query .= "'".(float)$credit."', "; $query .= "'".$currency."', "; $query .= "'".$vatnumber."', "; $query .= "'".$techcontact."', "; $query .= "'".$techemail."', "; $query .= "'".$techphone."', "; $query .= "'".$marketingcontact."', "; $query .= "'".$marketingemail."', "; $query .= "'".$marketingphone."', "; $query .= "'".$salescontact."', "; $query .= "'".$salesemail."', "; $query .= "'".$salesphone."', "; $query .= "'".$ref."', "; $query .= "'".$repid."', "; $query .= "'".$transferid."', "; $query .= "'".$donottax."', "; $query .= "'".$locked."', "; $query .= "'".$notes."' "; $query .= ") SELECT LAST_INSERT_ID=@@IDENTITY"; //echo $query; $result = mysql_query($query); $r = mysql_fetch_assoc($result); $cid = $r['LAST_INSERT_ID']; } }else{ $cid = $uid; // TODO: Update company details instead of create new $billingName = trim($billingName); $billingCompany = trim($billingCompany); $billingEmail = trim($billingEmail); $billingPhone = trim($billingPhone); $billingAddress1 = trim($billingAddress1); $billingAddress2 = trim($billingAddress2); $billingCity = trim($billingCity); $billingState = trim($billingState); $billingCountry = trim($billingCountry); $billingZip = trim($billingZip); $deliveryName = trim($deliveryName); $deliveryCompany = trim($deliveryCompany); $deliveryEmail = trim($deliveryEmail); $deliveryPhone = trim($deliveryPhone); $deliveryAddress1 = trim($deliveryAddress1); $deliveryAddress2 = trim($deliveryAddress2); $deliveryCity = trim($deliveryCity); $deliveryState = trim($deliveryState); $deliveryCountry = trim($deliveryCountry); $deliveryZip = trim($deliveryZip); $query = "UPDATE Y_Customers SET company = '$billingCompany', contact = '$billingName', email = '$billingEmail', phone = '$billingPhone', country = '$billingCountry', paycompany = '$billingCompany', paycontact = '$billingName', payemail = '$billingEmail', payphone = '$billingPhone', payaddress1 = '$billingAddress1', payaddress2 = '$billingAddress2', paycity = '$billingCity', paystate = '$billingState', payzip = '$billingZip', shipcompany = '$deliveryCompany', shipcontact = '$deliveryName', shipemail = '$deliveryEmail', shipphone = '$deliveryPhone', shipaddress1 = '$deliveryAddress1', shipaddress2 = '$deliveryAddress2', shipcity = '$deliveryCity', shipstate = '$deliveryState', shipzip = '$deliveryZip' WHERE id = '$cid'"; $result = mysql_query($query); } // Add items to inventory $query = "SELECT * from Y_cart WHERE sid = '".$si."'"; $result = mysql_query($query); while($row = mysql_fetch_array($result)){ $pid = $row['pid']; $oid = $row['oid']; $ooids = $oid; $quantity = $row['quantity']; $type = $row['type']; $iid = $row['iid']; // Inventory ID. Used with maintenance and upgrades (not new) if($type == "new"){ $returnkey = keyfromproductid($pid, $quantity, $oid); // Get the Key $keycheck = explode(" ", $returnkey); if($keycheck[0] == "ERR:"){ echo "

Warning: We are so sorry but our system has done something wrong. Your order has been taken but we seem to be having trouble generating the keys. Please contact us with the following error message:
$returnkey

"; } $todayDate = date("m/d/Y");// current date $dateOneYearAdded = mktime(0,0,0,date("m"),date("d"),date("Y")+1); $dateOneYearAdded = date("m/d/Y", $dateOneYearAdded); // Enter the main product $n=0; $iid = addToInventory($cid, $pid, $todayDate, $dateOneYearAdded, $returnkey, $quantity); $piid[$n] = $iid; /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // Some products like workgroup edition have 100 free workstations. This is hard coded so if the id for the products change then this code needs to change. // Bill asked for it this way. - Nikolai // PMP Workgroup Full License = 136 // PMP Workgroup SBE = 144 // PMP Workgroup Academic = 146 // PMP Workgroup Academic SBE = 147 // The workstation agent is 74 for 100 licenses // Later the if($pid == 136 or $pid == 144 or $pid == 146 or $pid == 147){ $returnkey = keyfromproductid(74, $quantity, $oid); // Get the Key $maintenanceparent = $iid; $workstations = addToInventory($cid, 74, $todayDate, $dateOneYearAdded, $returnkey, 100, $maintenanceparent); $n++; $piid[$n] = $workstations; // Used later when creating the quote $extraitems = "74|100|0,".$extraitems; // This is used later and adds the item 74 (workstation) to the list of items in the quote. It aslo overides the quantity and price (0). // DEBUG //echo "

"; // echo "Adding workstations to workgroup - Workstation ID: $maintenanceparent"; //echo "

"; } // /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // Enter the options into the inventory if($oid){ $oid = explode(",",$oid); reset($oid); while (list($key, $val) = each($oid)){ $query2 = "SELECT * FROM Y_products WHERE id = '$val'"; $result2 = mysql_query($query2); if($row2 = mysql_fetch_array($result2)){ if($row2['keyid'] == "CBA"){ // Add CBA to the inventory as an option $returnkey = "parent:".$iid; $ioid = addToInventory($cid, $val, $todayDate, $dateOneYearAdded, $returnkey, $quantity); $n++; $piid[$n] = $ioid; // Used later when creating the quote } if($row2['keyid'] == "WAS"){ // Add WAS to the inventory as an option $returnkey = "parent:".$iid; $ioid = addToInventory($cid, $val, $todayDate, $dateOneYearAdded, $returnkey, $quantity); $n++; $piid[$n] = $ioid; // Used later when creating the quote } if($row2['keyid'] == "RC"){ // Add Reports Center to the inventory as an option $returnkey = "parent:".$iid; $ioid = addToInventory($cid, $val, $todayDate, $dateOneYearAdded, $returnkey, 1); $n++; $piid[$n] = $ioid; // Used later when creating the quote } } } } } if($type == "maint"){ // This is a maintenance from the cart. Just update the date of the expiry to a year ahead from the maintenance expiry date. // $iid is the inventory ID of the item which needs a new maintenance expiry date //Get the current expiry date for the item $query2 = "SELECT * FROM Y_inventory WHERE id = '$iid'"; $result2 = mysql_query($query2); if($row2 = mysql_fetch_array($result2)){ $iexpires = $row2['expires']; $iexpires = strtotime ($iexpires); $iexpires = strtotime ("+ 1 year", $iexpires); $iexpires = date("m/d/Y", $iexpires); $pid = $row2['productid']; $enduserid = $row2['enduserid']; $update = mysql_query("UPDATE Y_inventory SET expires = '$iexpires' WHERE id = '$iid'"); // Now find any maintenance children // Note: We may have trouble as older PMP workgroup editions are not attached to workstation agents, but this should stop after 1 year. $update = mysql_query("UPDATE Y_inventory SET expires = '$iexpires' WHERE maintenanceparent = '$iid'"); /* // If this is a workgroup edition then also update the maintenance on workstations // This is hard coded as requested by Bill // // PMP Workgroup Full License = 136 // PMP Workgroup SBE = 144 // PMP Workgroup Academic = 146 // PMP Workgroup Academic SBE = 147 // The workstation agent is 74 for 100 licenses. Safest to include all workstations = 71 to 78 if($pid == 136 or $pid == 144 or $pid == 146 or $pid == 147){ $update = mysql_query("UPDATE Y_inventory SET expires = '$iexpires' WHERE expires = '".$row2['expires']."' AND enduserid = '$enduserid' AND (productid='71' OR productid='72' OR productid='73' OR productid='74' OR productid='75' OR productid='76' OR productid='77' OR productid='78') "); //echo "

Applied a maintenance to workgroup as a PMP Workgroup edition was maintained. Maintenance expiry changed to ".$invexpires[$n].".

"; } */ } } if($type == "upgrade"){ // This is an upgrade from the cart. Just update the date of the expiry to a year ahead from now. // $iid is the inventory ID of the item which needs a new maintenance expiry date $iexpires = strtotime ("+ 1 year", time()); $iexpires = date("m/d/Y", $iexpires); $pid = $row2['productid']; $enduserid = $row2['enduserid']; $update = mysql_query("UPDATE Y_inventory SET expires = '$iexpires' WHERE id = '$iid'"); // Now find any maintenance children. Example: PMP workgroup should have 1x100 license workstation agent. // Note: We may have trouble as older PMP workgroup editions are not attached to workstation agents, but this should stop after 1 year. $update = mysql_query("UPDATE Y_inventory SET expires = '$iexpires' WHERE maintenanceparent = '$iid'"); } // Save purchase history $subsub = getitemprice($pid,$currency,$type); $taxtax = subsub * $tax / 100; $stamp = time(); if($uid < 0){$ruid = $uid * -1;}else{$ruid = $uid;} $query2 = "INSERT INTO Y_purchasehistory ( prospectid, customerid, productid, quantity, stamp, optionids, subtotal, tax, type, currency ) VALUES ( '".$ruid."', '".$cid."', '".$pid."', '".$quantity."', '".$stamp."', '".$ooids."', CONVERT(money,'".$subsub."'), CONVERT(money,'".$taxtax."'), '".$type."', '".$currency."' )"; $result2 = mysql_query($query2); } // Create the quote and mark it as paid //////////////////////////////////////////////////////////////////////////////////////////////////////////////// // This section creates a new quote. // The items and cash have already been processed, but for our records and for sending the invoice and delivery, we stll need a quote. // Obviously it will be marked as paid at once. // Note the Store's own Rep ID is 31 // Set the quote id to 0. It will get changed to the new quote id number later. $qid = 0; // Set the expiry dates, adding one year to today $todayDate = date("m/d/Y");// current date $dateOneYearAdded = mktime(0,0,0,date("m"),date("d"),date("Y")+1); $dateOneYearAdded = date("m/d/Y", $dateOneYearAdded); // First get the customer data $result = mysql_query("SELECT * from Y_customers WHERE id = '".$cid."'"); if($row = mysql_fetch_array($result)){ $currency = $row['currency']; // Used later when entering inventory items into the quote. $sentinvoiceto = $row['paycontact'] . ":" . $row['payemail'] . "|" . "Service" . ":" . "service@printmanager.com" . "|" . "Bill Feeley" . ":" . "bfeeley@printmanager.com"; $sentdeliveryto = $row['shipcontact'] . ":" . $row['shipemail'] . "|" . "Service" . ":" . "service@printmanager.com" . "|" . "Bill Feeley" . ":" . "bfeeley@printmanager.com"; // Insert data into new quote $query = "INSERT INTO Y_quotes ("; $query .= "enduserid, "; $query .= "type, "; $query .= "company, "; $query .= "contact, "; $query .= "email, "; $query .= "address, "; $query .= "shipaddress, "; $query .= "shipcompany, "; $query .= "shipcontact, "; $query .= "shipemail, "; $query .= "country, "; $query .= "currency, "; $query .= "donottax, "; $query .= "expires, "; $query .= "pono, "; $query .= "vat, "; $query .= "shipmethod, "; $query .= "leadid, "; $query .= "phone, "; $query .= "repid, "; $query .= "creatorid, "; // Used to show who created the order. $query .= "status, "; $query .= "sentinvoiceto, "; $query .= "sentdeliveryto, "; $query .= "shipphone "; $query .= ") VALUES ("; $query .= "'".$cid."', "; $query .= "'End User', "; $query .= "'".$row['company']."', "; $query .= "'".$row['contact']."', "; $query .= "'".$row['email']."', "; $query .= "'" . $row['payaddress1']; if($row['payaddress2']){$query .= "\n" . $row['payaddress2'];} $query .= "\n" . $row['paycity'] . "\n" . $row['paystate'] . "\n" . $row['payzip'] . "', "; $query .= "'" . $row['shipaddress1']; if($row['shipaddress2']){$query .= "\n" . $row['shipaddress2'];} $query .= "\n" . $row['shipcity'] . "\n" . $row['shipstate'] . "\n" . $row['shipzip'] . "', "; $query .= "'".$row['shipcompany']."', "; $query .= "'".$row['shipcontact']."', "; $query .= "'".$row['shipemail']."', "; $query .= "'".$row['country']."', "; $query .= "'".$row['currency']."', "; $query .= "'0', "; $query .= "'".$dateOneYearAdded."', "; $query .= "'', "; $query .= "'".$tax."', "; $query .= "'Electronic', "; $query .= "'', "; $query .= "'".$row['phone']."', "; $query .= "'31', "; $query .= "'31', "; $query .= "'Paid', "; $query .= "'".$sentinvoiceto."', "; $query .= "'".$sentdeliveryto."', "; $query .= "'".$row['shipphone']."' "; $query .= ") SELECT LAST_INSERT_ID=@@IDENTITY"; //echo "

$query

"; $result2 = mysql_query($query); $r = mysql_fetch_assoc($result2); $qid = $r['LAST_INSERT_ID']; } /// NOW SAVE THE QUOTE INVENTORY if($qid > 0){ $query3 = "SELECT * from Y_cart WHERE sid = '".$si."'"; $result3 = mysql_query($query3); $mainp = 1; // the number of the main product (not options) in the list of items added to the quote inventory. Used for assigning options. while($row3 = mysql_fetch_array($result3)){ $pid = $row3['pid']; $oid = $row3['oid']; $type = $row3['type']; $iis = $row3['iis']; if(!$type){$type = "new";} // Add the product id to the list of option IDs so we can run them all in a loop together. $allIDs = $extraitems . $oid; $allIDs = $pid . "," . $allIDs; $allIDs = explode(",",$allIDs); reset($allIDs); $n=0; while (list($key, $val) = each($allIDs)){ if($allIDs[$n] and $allIDs[$n] > 0){ // Get the quantity - This is normaly just the amount of the main item unless there is an overide $quantity = $row3['quantity']; $priceoveride = ""; // If not set then the system will get the price from the products table // See if the quantity and/or price have been overidden - This would normally be the extra items added such as workstations for PMP workgroup $quantityPriceOveride = explode("|",$allIDs[$n]); /* // DEBUG echo "

"; echo "quantityPriceOveride: ".$quantityPriceOveride[0] . " | " . $quantityPriceOveride[1] . " | " . $quantityPriceOveride[2]; echo "

"; */ if($quantityPriceOveride[1] or $quantityPriceOveride[2]){ $allIDs[$n] = $quantityPriceOveride[0]; if(is_numeric($quantityPriceOveride[1]) and $quantityPriceOveride[1] > 0){ $quantity = $quantityPriceOveride[1]; } if(is_numeric($quantityPriceOveride[2])){ $priceoveride = $quantityPriceOveride[2]; } } // Get some data from the products db /* $result2 = mysql_query("SELECT * from Y_products WHERE id = '".$allIDs[$n]."' "); if($row2 = mysql_fetch_array($result2)){ $sku == $row2['sku']; $alttext == $row2['family'] . " " . $row2['name']; $currency = strtoupper($currency); if($currency == "EUR" or $currency == "EURO"){ $altprice = $row2['EUprice']; }elseif($currency == "GBP"){ $altprice = $row2['GBprice']; }else{ $altprice = $row2['USprice']; } } */ if(is_numeric($priceoveride)){ $altprice = $priceoveride; //echo "

Code: 9473483 $priceoveride

"; }else{ $altprice = getitemprice($allIDs[$n],$currency,$type); //echo "

Code: 8473483 $altprice - ".$allIDs[$n]." - ".$currency." - ".$type."

"; } /* // DEBUG echo "

"; echo "PRICE: $altprice | $priceoveride"; echo "

"; */ $query = "INSERT INTO Y_quotes_inventory ("; $query .= "quoteid, "; $query .= "productid, "; $query .= "sku, "; $query .= "alttext, "; $query .= "altprice, "; $query .= "type, "; $query .= "inventoryid, "; $query .= "newinventoryid, "; $query .= "expires, "; $query .= "amount "; $query .= ") VALUES ("; $query .= "'".$qid."', "; $query .= "'".$allIDs[$n]."', "; $query .= "'".$sku."', "; $query .= "'".$alttext."', "; $query .= "'".$altprice."', "; $query .= "'$type', "; if($n==0){ $query .= "'0', "; }else{ $query .= "'".$mainp."', "; } $query .= "'".$piid[$n]."', "; $query .= "'".$dateOneYearAdded."', "; $query .= "'".$quantity."' "; $query .= ")"; $result = mysql_query($query); } $n++; } $mainp++; } } // Work out the estimated value of the quote in dollars for our records $qv = getbasevalueforquoteindollars($qid); if($qv){ $insert = mysql_query("UPDATE Y_quotes SET estvaluedollars = '".$qv."' WHERE id = '".$qid."'"); // DEBUG if($debug){ debugreport("Adding dollar value $ $qv"); } //echo "

Code: 9377493 $qv - $qid

"; }else{ // DEBUG if($debug){ debugreport("Estimated value in dollars failed to find a value."); } //echo "

Code: 8377493 $qv - $qid

"; } ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////// echo "

Success

"; echo "

Your payment has been approved.

"; $sentinvoicetoB = str_replace(":", " ", $sentinvoiceto); $sentdeliverytoB = str_replace(":", " ", $sentdeliveryto); echo "

An invoice has been sent to: $sentinvoicetoB

"; echo "

Delivery has been sent to: $sentdeliverytoB

"; echo "

You can also find delivery details under your account.

"; echo "

We use an electronic delivery service. If you have already downloaded a demo, then simply use the new key. Otherwise please download the product and install as per instructions using the key provided below or in your delivery email.

"; // List purchased items with download links and keys echo "
"; //ListDelivery $listInventory = ListDelivery($qid); echo $listInventory; echo "
"; echo "

Thank you for your order. If you have any further queries please contact us.

"; //echo "

EXIT

"; //exit(); // Show cost // Send the delivery and invoice email $url = $baseurl."management/qt-delivery.php?qid=".$qid."&bl=kfrtwop&format=emailpdfconfirm&auto=1"; $fh = fopen($url, "r"); $theData = fread($fh, 10000); fclose($fh); flush(); // DEBUG if($debug){echo "

"; echo $theData; echo "

"; } // Empty the basket $delete = mysql_query("DELETE FROM Y_cart WHERE sid = '$si'"); // Update prospect as it is now a customer instead if($uid < 0 and $cid > 0){ $ruid = $uid * -1; $update = mysql_query("UPDATE Y_prospects SET cid='$cid' WHERE id='$ruid'"); } // Change login to customer rather than a prospect if($uid < 0 and $cid > 0){ $update = mysql_query("UPDATE Y_sessions SET uid='$cid' WHERE uid='$uid'"); $uid = $cid; } } }else{ $s = "payment"; } } if($s=="payment"){ if($uid == 0){ ?>

 

You need to be logged in to go to checkout. You may also create an account - it is free and simple.

 

Login Create Account

Alert:

0 and !$errormessage){ // This is a customer. Get the customer's details $result = mysql_query("SELECT * from Y_customers WHERE id = '".$uid."'"); if($row = mysql_fetch_array($result)){ $billingName = stripslashes_mysql($row['paycontact']) . " " . stripslashes_mysql($row['lastname']); $billingCompany = stripslashes_mysql($row['paycompany']); $billingEmail = stripslashes_mysql($row['payemail']); $billingAddress1 = stripslashes_mysql($row['payaddress1']); $billingAddress2 = stripslashes_mysql($row['payaddress2']); $billingPhone = stripslashes_mysql($row['payphone']); $billingCity = stripslashes_mysql($row['paycity']); $billingCountry = $row['country']; $billingState = $row['paystate']; $billingZip = $row['payzip']; $deliveryName = stripslashes_mysql($row['shipcontact']) . " " . stripslashes_mysql($row['lastname']); $deliveryCompany = stripslashes_mysql($row['shipcompany']); $deliveryEmail = stripslashes_mysql($row['shipemail']); $deliveryAddress1 = stripslashes_mysql($row['shipaddress1']); $deliveryAddress2 = stripslashes_mysql($row['shipaddress2']); $deliveryPhone = stripslashes_mysql($row['shipphone']); $deliveryCity = stripslashes_mysql($row['shipcity']); $deliveryCountry = stripslashes_mysql($row['country']); $deliveryState = $row['shipstate']; $deliveryZip = $row['shipzip']; } } ?>

Billing Address

 

Delivery Address

 
Name:* Name:*
Company: Company:
Email:* Email:*
Phone:* Phone:*
Address 1:* Address 1:*
Address 2: Address 2:
City:* City:*
State:* State:*
Country:* Country:*
Zip/Post Code:* Zip/Post Code:*

Card Details

Credit Card Number:*
Card ID Number:* What is this?
Expiration Date (mm / yyyy):*
Card Type:*

Order Summary

Sum total: '. $cartsum[2] . ''.number_format($cartsum[1], 2, '.', '') . '

'; if($billingZip and $billingState){ $tax = gettax($billingZip, $billingState); $tax = $cartsum[1] * $tax / 100; $total = $cartsum[1] + $tax; $total = number_format($total, 2, '.', ','); $tax = number_format($tax, 2, '.', ','); echo '

Tax: '.$cartsum[2].''.$tax.'

'; }else{ echo '

Tax: '.$cartsum[2].'0

'; $total = $cartsum[1]; $total = number_format($total, 2, '.', ','); } echo '

Total: '. $cartsum[2] . ''.$total . '

'; //echo '

'.$cartsum[0].' items | Total: '. $cartsum[2] . $cartsum[1] . '

'; ?>

Cart'; if($action == "update" and $cartid){ $updateCart = updateCart($cartid,$quantity,true); } $totalquantity = 0; $totalcash = 0; $query = "SELECT Y_cart.pid as pid, Y_cart.quantity as quantity, Y_cart.id as cartid, Y_cart.oid as oid, Y_cart.type as type, Y_cart.iid as iid, Y_products.family as family, Y_products.sku as sku, Y_products.maintsku as maintsku, Y_products.upgradesku as upgradesku, Y_products.page as page, Y_products.licensingnote as licensingnote, Y_products.name as name FROM Y_cart, Y_products WHERE Y_cart.pid = Y_products.id AND Y_cart.sid = '$si'"; $result = mysql_query($query); $n=0; while($row = mysql_fetch_array($result)){ if(!$row['type']){$row['type']="new";} ?>
'.$row['family'].''; } if($row['type']=="maint"){ echo'

'.$row['family'].' Maintenance

'; } if($row['type']=="upgrade"){ echo'

'.$row['family'].' Upgrade

'; } ?>

Detail:
SKU: ' .$row['sku']; } if($row['type']=="maint"){ echo'Maintenance SKU: ' .$row['maintsku']; } if($row['type']=="upgrade"){ echo'Upgrade SKU: ' .$row['upgradesku']; } ?>

$val
"; $query2 = "SELECT family, sku, page, name, singleOnlyAsOption FROM Y_products WHERE id = '$val'"; $result2 = mysql_query($query2); if($row2 = mysql_fetch_array($result2)){ if($n==0){echo "

Options:
";} echo $row2['family'] . " "; // Check if multipe options are added or just a single if($row2['singleOnlyAsOption'] == 1){ $costcost = getitemprice($val,$currency,$row['type']); $costeachoption += $costcost; echo " (1 X ".currencySymbol($currency)."$costcost)
"; }else{ $costcost = getitemprice($val,$currency,$row['type']); $costeachoption += $row['quantity'] * $costcost; echo " (".$row['quantity']." X ".currencySymbol($currency)."$costcost)
"; } } $n++; } } echo "

"; } ?>
Product Information
'; }else{ } //if($row['licensingnote']){ //echo '

Licensing

'.stripslashes_mysql($row['licensingnote']).'

'; //} ?>
'; $costeach = getitemprice($row['pid'],$currency,$row['type']); //$costeach += $costeachoption; $totalcost = $costeach * $row['quantity']; $totalcost += $costeachoption; echo '

' . currencySymbol($currency) . number_format($costeach, 2, '.', ',') ; echo '
Sub total: ' . currencySymbol($currency) . number_format($totalcost, 2, '.', ',') . ''; echo '

'; $totalcash += $totalcost; $totalquantity += $row['quantity']; // It is important that the form action has the vars too as the currency switcher just takes the URL and updates it whatever URL the page is on. If the form has been used it uses post method so the URL does not contain the vars. echo '
'; if($action == "update" and $pid == $row['pid']){ echo "

$updateCart

"; } echo ''; echo ''; ?>
Your cart is empty.

'; }else{ ?>

Total:

Checkout

 

You need to be logged in to go to checkout. You may also create an account - it is free and simple.

 

Login Create Account

Checkout'; $totalquantity = 0; $totalcash = 0; $query = "SELECT Y_cart.pid as pid, Y_cart.quantity as quantity, Y_cart.id as cartid, Y_cart.oid as oid, Y_cart.type as type, Y_cart.iid as iid, Y_products.family as family, Y_products.sku as sku, Y_products.maintsku as maintsku, Y_products.upgradesku as upgradesku, Y_products.page as page, Y_products.name as name FROM Y_cart, Y_products WHERE Y_cart.pid = Y_products.id AND Y_cart.sid = '$si'"; $result = mysql_query($query); $n=0; while($row = mysql_fetch_array($result)){ if(!$row['type']){$row['type']="new";} ?>
'.$row['quantity'] . ' X ' . $row['family'].''; } if($row['type']=="maint"){ echo'

'.$row['quantity'] . ' X ' . $row['family'].' Maintenance

'; } if($row['type']=="upgrade"){ echo'

'.$row['quantity'] . ' X ' . $row['family'].' Upgrade

'; } ?>

Detail:
SKU: ' .$row['sku']; } if($row['type']=="maint"){ echo'Maintenance SKU: ' .$row['maintsku']; } if($row['type']=="upgrade"){ echo'Upgrade SKU: ' .$row['upgradesku']; } ?>

$val
"; $query2 = "SELECT family, sku, page, name, singleOnlyAsOption FROM Y_products WHERE id = '$val'"; $result2 = mysql_query($query2); if($row2 = mysql_fetch_array($result2)){ if($n==0){echo "

Options:
";} echo $row2['family']; //$costeachoption += getitemprice($val,$currency,"new"); // Check if multipe options are added or just a single if($row2['singleOnlyAsOption'] == 1){ $costcost = getitemprice($val,$currency,$row['type']); $costeachoption += $costcost; echo " (1 X ".currencySymbol($currency)."$costcost)
"; }else{ $costcost = getitemprice($val,$currency,$row['type']); $costeachoption += $row['quantity'] * $costcost; echo " (".$row['quantity']." X ".currencySymbol($currency)."$costcost)
"; } } $n++; } } echo "

"; } ?>
'; //$costeach = getitemprice($row['pid'],$currency,"new"); //$costeach += $costeachoption; //$totalcost = $costeach * $row['quantity']; $costeach = getitemprice($row['pid'],$currency,$row['type']); //$costeach += $costeachoption; $totalcost = $costeach * $row['quantity']; $totalcost += $costeachoption; echo '

' . currencySymbol($currency) . number_format($costeach, 2, '.', ',') . ' each'; echo '
Sub total: ' . currencySymbol($currency) . number_format($totalcost, 2, '.', ',') . ''; echo '

'; $totalcash += $totalcost; $totalquantity += $row['quantity']; echo ''; ?>
Your cart is empty.

'; }else{ ?>

Total:

Continue

 

You need to be logged in to go to checkout. You may also create an account - it is free and simple.

 

Login Create Account

'.$row['family'].''; } }elseif($familyid and !$prodid){ $query2 = "SELECT * FROM Y_products WHERE familyid = '".$familyid."' ORDER BY USprice DESC"; $result2 = mysql_query($query2); if($row2 = mysql_fetch_array($result2)){ echo '

'.$row2['family'].'

'; if($row2['licensingnote']){ echo '

Licensing

'.stripslashes_mysql($row2['licensingnote']).'

'; } } ?>
'; }else{ echo ''; } ?>

Detail:
SKU:

Product Information
'; }else{ } ?>
'; echo '

' . currencySymbol($currency) . getitemprice($row2['id'],$currency,"new") . '

'; // If there are options, add them too. //$query3 = "SELECT * FROM Y_products WHERE quantityMin = '$quantityMin' AND optionparent = '".$row2['keyname']."' ORDER BY family"; $options = explode(",",$row2['options']); reset($options); $n=0; while (list($key, $val) = each($options)){ //echo "$key => $val
"; $query3 = "SELECT * FROM Y_products WHERE id = '$val' and active = '1'"; $result3 = mysql_query($query3); if($row3 = mysql_fetch_array($result3)){ if($val){ echo '

' . $row3['family'] . '
+' . currencySymbol($currency) . getitemprice($row3['id'],$currency,"new") . '

'; $n++; } } } echo '

Buy

'; echo ''; echo ''; ?>
No products were found.

'; } }elseif(!$familyid and $prodid){ } } ?>