$b)
// { print “{$a}:{$b}
“; };
$libraryid = $_REQUEST[‘libraryid’];
if ($libraryid == ”)
{ $libraryid = 2; };
$type = strtolower($_REQUEST[‘type’]);
if (($type <> ‘print’) and ($type <> ‘pdf’))
{ $type = ‘print’; };
$lrow = mfetch(mquery(“SELECT * FROM `libraries` WHERE `libraryid` = {$libraryid}”));
// Look for guides to order
$gresult = mquery(“SELECT * FROM `guides` WHERE `libraryid` = {$libraryid} ORDER BY `guidename`”);
$guideorders = array();
while ($grow = mfetch($gresult)) {
if ($_REQUEST[“guide_{$grow[‘guideid’]}”] == ‘on’)
{ $guideorders[$grow[‘guideid’]] = $grow[‘guidename’]; };
};
if ((count($guideorders) > 0) and ($_REQUEST[‘proceed_x’] <> ”)) {
// Checkout page
$gc = mrows(mquery(“SELECT * FROM `guides` WHERE `libraryid` = {$libraryid}”));
if ($type == ‘print’) {
$ordertype = ‘Print’;
$orderprice = $lrow[‘guidepriceprint’];
}
else {
$ordertype = ‘PDF’;
$orderprice = $lrow[‘guidepricepdf’];
};
$totalprice = $orderprice * count($guideorders);
$email = trim($_REQUEST[’email’]);
$firstname = trim($_REQUEST[‘firstname’]);
$mi = trim($_REQUEST[‘mi’]);
$lastname = trim($_REQUEST[‘lastname’]);
$firm = trim($_REQUEST[‘firm’]);
$profession = trim($_REQUEST[‘profession’]);
$address1 = trim($_REQUEST[‘address1’]);
$address2 = trim($_REQUEST[‘address2’]);
$city = trim($_REQUEST[‘city’]);
$state = $_REQUEST[‘state’];
$zip = trim($_REQUEST[‘zip’]);
$country = $_REQUEST[‘country’];
$telephone = trim($_REQUEST[‘telephone’]);
$cctype = $_REQUEST[‘cctype’];
$ccname = trim($_REQUEST[‘ccname’]);
$ccnumber = trim($_REQUEST[‘ccnumber’]);
$ccmonth = $_REQUEST[‘ccmonth’];
$ccyear = $_REQUEST[‘ccyear’];
$terms = $_REQUEST[‘terms’];
$copybilling = ($_REQUEST[‘copybilling’] == ‘on’);
if ($copybilling) {
$s_firstname = $firstname;
$s_mi = $mi;
$s_lastname = $lastname;
$s_address1 = $address1;
$s_address2 = $address2;
$s_city = $city;
$s_state = $state;
$s_zip = $zip;
$s_country = $country;
}
else {
$s_firstname = trim($_REQUEST[‘s_firstname’]);
$s_mi = trim($_REQUEST[‘s_mi’]);
$s_lastname = trim($_REQUEST[‘s_lastname’]);
$s_address1 = trim($_REQUEST[‘s_address1’]);
$s_address2 = trim($_REQUEST[‘s_address2’]);
$s_city = trim($_REQUEST[‘s_city’]);
$s_state = $_REQUEST[‘s_state’];
$s_zip = trim($_REQUEST[‘s_zip’]);
$s_country = $_REQUEST[‘s_country’];
};
$transaction = false;
if (($email <> ”) or ($firstname <> ”) or ($lastname <> ”) or ($firm <> ”)) {
$error = ”;
if ($email == ”)
{ $error .= ‘You must enter an email address
‘; }
elseif ((strpos($email,’@’) == 0) or (strpos($email,’.’) == 0) or
(strpos($email,’ ‘) > 0))
{ $error .= ‘Email address is not valid.
‘; };
if ($firstname == ”)
{ $error .= ‘You must enter a First Name.
‘; };
if ($lastname == ”)
{ $error .= ‘You must enter a Last Name.
‘; };
if ($address1 == ”)
{ $error .= ‘You must enter an Address.
‘; };
if ($city == ”)
{ $error .= ‘You must enter a City.
‘; };
if ($state == ”)
{ $error .= ‘You must select a State/Province.
‘; };
if ($zip == ”)
{ $error .= ‘You must enter a Zip Code.
‘; };
if (($type == ‘print’) and (!$copybilling)) {
if ($s_firstname == ”)
{ $error .= ‘You must enter a Shipping First Name.
‘; };
if ($s_lastname == ”)
{ $error .= ‘You must enter a Shipping Last Name.
‘; };
if ($s_address1 == ”)
{ $error .= ‘You must enter a Shipping Address.
‘; };
if ($s_city == ”)
{ $error .= ‘You must enter a Shipping City.
‘; };
if ($s_state == ”)
{ $error .= ‘You must select a Shipping State/Province.
‘; };
if ($s_zip == ”)
{ $error .= ‘You must enter a Shipping Zip Code.
‘; };
};
if ($ccnumber == ”)
{ $error .= ‘You must enter a Credit Card Number.
‘; };
if ($terms <> ‘agree’)
{ $error .= ‘You must agree to the Terms of Use Agreement in order to complete your order.
‘; };
if ($error == ”) {
// Process credit card transaction
// Add record
$aquery = “INSERT INTO `guideorders` (`email`,`firstname`,`mi`,`lastname`,`firm`,`profession`,`address1`,`address2`,`city`,`state`,`zip`,`country`,`telephone`,`paymentmethod`,`ccname`,`ccnumber`,`ccmonth`,`ccyear`,`amount`,`active`,`libraryid`,`s_firstname`,`s_mi`,`s_lastname`,`s_address1`,`s_address2`,`s_city`,`s_state`,`s_zip`,`s_country`) VALUES (”
. ‘”‘ . addslashes($email) . ‘”,”‘ . addslashes($firstname) . ‘”,”‘ . addslashes($mi) . ‘”,”‘ . addslashes($lastname) . ‘”,”‘ . addslashes($firm) . “\”,\”{$profession}\”,\”” . addslashes($address1) . ‘”,”‘ . addslashes($address2)
. ‘”,”‘ . addslashes($city) . ‘”,”‘ . addslashes($state) . ‘”,”‘ . addslashes($zip) . ‘”,”‘ . addslashes($country) . ‘”,”‘ . addslashes($telephone) . “\”,\”{$cctype}\”,\”” . addslashes($ccname) . ‘”,”‘ . addslashes($ccnumber) . “\”,{$ccmonth},{$ccyear},{$totalprice},”
. “0,{$libraryid},\”” . addslashes($s_firstname) . ‘”,”‘ . addslashes($s_mi) . ‘”,”‘ . addslashes($s_lastname) . ‘”,”‘ . addslashes($s_address1) . ‘”,”‘ . addslashes($s_address2) . ‘”,”‘ . addslashes($s_city) . ‘”,”‘
. addslashes($s_state) . ‘”,”‘ . addslashes($s_zip) . ‘”,”‘ . addslashes($s_country) . ‘”)’;
$aresult = mquery($aquery) or die(“Error adding subscription information!”);
$orderid = mysql_insert_id();
// Add guides
foreach ($guideorders as $guideid => $guidename) {
$aresult = mquery(“INSERT INTO `guideorderdetails` (`guideorderid`,`guideid`) VALUES ({$orderid},{$guideid})”);
};
$status = process_credit($orderid,’guideorder’);
if ($status) {
// Show receipt page
$transaction = true;
sendguideorderemail($orderid);
}
else {
$error = ‘Credit card transaction did not complete successfully.
‘;
};
};
};
if (!$transaction) {
print “
{$lrow[‘libraryname’]}
Your Order
if ($error <> ”) {
print “
Your transaction could not be completed due to the following errors:
{$error}
“;
print “Please check your information and submit your transaction again, or call us toll-free at 800-965-3002.
“;
};
print ‘
‘;
print ‘
} else { $srow = mfetch(mquery("SELECT * FROM `guideorders` WHERE `guideorderid` = {$orderid}")); ?>
=$lrow['libraryname']?>
Your Order Confirmation
Thank you for becoming ordering Guides the online =$lrow['libraryname']?>. Please print and save this page, which serves as your order confirmation.
Order Number: | =$orderid?> |
Guides Ordered | |
Guide Title | Format |
{$drow[‘guidename’]} | “; if ($type == ‘print’) { print ‘Print’; } else { print ‘PDF’; }; print ” Download (PDF)“; print “ |
Billing Information | |
Email Address: | =$srow['email']?> |
Name: | =$srow['firstname']?> =$srow['mi']?> =$srow['lastname']?> |
Law Firm/Company: | =$srow['firm']?> |
Address: | =$srow['address1']?> =$srow['address2']?> =$srow['city']?>, =$srow['state']?> =$srow['zip']?> =$srow['country']?> |
Telephone: | =$srow['telephone']?> |
Shipping Information | |
Name: | =$srow['s_firstname']?> =$srow['s_mi']?> =$srow['s_lastname']?> |
Address: | =$srow['s_address1']?> =$srow['s_address2']?> =$srow['s_city']?>, =$srow['s_state']?> =$srow['s_zip']?> =$srow['s_country']?> |
Payment Method | |
Credit Card Type: | switch ($srow['paymentmethod']) { case 'V': print "Visa"; break; case 'M': print "Mastercard"; break; case 'D': print "Discover"; break; case 'A': print "American Express"; break; }; ?> |
Name on Credit Card: | =$srow['ccname']?> |
Credit Card Number: | =$srow['ccnumber']?> |
Expiration Date: | =$srow['ccmonth']?>/=$srow['ccyear']?> |
Total Price: | $=number_format($srow['amount'],2)?> |
}; } else { print "
{$lrow[‘libraryname’]}
“;
print “
Purchasing Individual Guides
“;
print “Individual Guides from the {$lrow[‘libraryname’]} are available for purchase in either PRINT or PDF formats.
“;
print “
- Print Format – You may order a printed, soft-cover bound copy of one or more Guides at a cost of $” . number_format($lrow[‘guidepriceprint’],2) . ” per Guide. When you order a Print copy of a Guide, you will also receive via Email the PDF version of the same Guide absolutely FREE of charge.
- PDF Format – You can immediately download individual Guides (PDF) from the {$lrow[‘libraryname’]} at a cost of $” . number_format($lrow[‘guidepricepdf’],2) . ” per Guide.
“;
print “
“;
print ‘
‘;
};
?>