exit();
//header("Pragma: no-cache");
//header('Content-type: text/html; charset=utf-8');
//header( "Content-type: text/html; charset=iso-8859-1");
//error_reporting(E_ALL);
header("Last-Modified: " . gmdate( "D, j M Y H:i:s" ) . " GMT" );
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
header("Cache-Control: no-store, no-cache, must-revalidate" ); // HTTP/1.1
header("Cache-Control: post-check=0, pre-check=0", FALSE );
header("Pragma: no-cache" ); // HTTP/1.0
// sleep(3);
//$debug=yes1997;
/*********************************************************
Checkout page .... handles donations via CC
REMEMBER TO UNCOMMENT LINE: unset($cc_test_domain); !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
*********************************************************/
require'../commonfiles/Functions.php';
require'../commonfiles/MyFunctions.php';
require'../commonfiles/brandconfig.php';
require'../commonfiles/newtemplate.php';
require'../commonfiles/class.currency.php';
if($code!='SPCA')
{
exit();
}
// connect mysql
$crm = new MySQL_class;
$crm->Create($crm_db,$crm_user,$crm_host,$crm_pass);
$tmp = new MySQL_class;
$tmp->Create($template_db,$template_user,$template_host,$template_pass);
$gc_sql=$crm; // session handling
$cdc = new MySQL_class;
$cdc->Create($cdc_db,$cdc_user,$cdc_host,$cdc_pass);
$brnd = new MySQL_class;
$brnd->Create($db,$user,$host,$pass);
$dir = new MySQL_class;
$dir->Create($directory_db,$directory_user,$directory_host,$directory_pass);
// foil hackers
unset($u_type,$u_id,$session_email,$customer_relation_id);
complex_striptags($_GET);
complex_striptags($_POST);
// start session
start_session($php_sessid);
if($team_id)
{
$donation_team_id = $team_id;
}
if(page_auth(3,$u_type,$cdc) == "yes")
{
$staging = "yes";
}
unset($u_type,$u_id,$session_email,$customer_relation_id);
// log it
//app_log('store',$PHP_SELF,$search_word,$application_id,'view',$code,$array);
$app_logs_sql = new MySQL_class;
$app_logs_sql->Create($app_logs_db,$app_logs_user,$app_logs_host,$app_logs_pass);
$end_user = "yes";
start_session($sessid);
// populate the error messages
$message_array = get_messages('store_checkout',$language_c,$TEMPLATE_MESSAGE,$code,$tmp);
unset($u_id,$cdc_type);
// configuration options for the page
$conf = get_conf2(6);
if(!$donation_team_member_id && !$team_id && !$donation_individual_id && !$donation_id)
{
echo "where is the fundraiser...";
exit();
}
// page starts
$order_header_id = ass($order_header_id);
$today = gmdate('Y-m-d');
// most common -- team member
if($donation_team_member_id)
{
$query = "select m.monetary_goal, d.campaign_id, contact_id, d.id
from $DONATION_TEAM t, $DONATION_TEAM_MEMBER m, $DONATION d
where m.id = '".ass($donation_team_member_id)."'
and m.donation_team_id = t.id
and t.donation_id = d.id
and t.brand = '$code' ";
$data = $crm->mydata($query);
$donation_id = $data[id][0];
}
// team donation
if($donation_team_id)
{
$query = "select t.monetary_goal, d.campaign_id, d.id
from $DONATION_TEAM t, $DONATION d
where t.id = '".ass($donation_team_id)."'
and t.donation_id = d.id
and t.brand = '$code' ";
$data = $crm->mydata($query);
$donation_id = $data[id][0];
}
// solo
if($donation_individual_id)
{
$query = "select i.monetary_goal, d.campaign_id, i.contact_id, d.id
from $DONATION_INDIVIDUAL i, $DONATION d
where i.id = '".ass($donation_individual_id)."'
and i.donation_id = d.id
and d.brand = '$code' ";
$data = $crm->mydata($query);
$donation_id = $data[id][0];
}
// direct
if(!$data[monetary_goal][0])
{
$query = "select monetary_goal, campaign_id, d.id
from $DONATION d
where d.id = '".ass($donation_id)."'
and d.brand = '$code' ";
$data = $crm->mydata($query);
}
if(!$data[contact_id][0] && !$donation_id)
{
echo"error2: invalid id";
exit();
}
$sponsored_cdc_id = $data['contact_id'][0];
if(!$cdc_type)
{
$cdc_type = 'contact';
}
$personal_monetary_goal = $data['monetary_goal'][0];
$campaign_id = $data['campaign_id'][0];
if(!$sponsored_cdc_id && !$donation_id)
{
echo "Invalid Fundraiser";
exit();
}
$query = "select name, description, currency, monetary_goal
from $CAMPAIGN
where id = '$campaign_id'
and brand = '$code' ";
$data = $crm->mydata($query);
$campaign_name = $data['name'][0];
$campaign_description = $data['description'][0];
$currency_code = $data['currency'][0];
//$global_monetary_goal = $data['monetary_goal'][0];
$sponsored_info = get_cdc($sponsored_cdc_id,$code,$cdc);
if($cdc_type == 'company')
{
$query = "select name from $DONATION_TEAM
where id = '".ass($team_id)."'
and brand = '$code' ";
$data = $crm->mydata($query);
$sponsored_name = $data['name'][0];
$entity_type = "Team";
}
if($cdc_type == 'contact')
{
$sponsored_name = $sponsored_info['first_name']." ".$sponsored_info['last_name'];
$entity_type = "Individual";
}
if(!$cdc_type)
{
$query = "select d.name
from $DONATION
where id = '".ass($donation_id)."'
and c.brand = '$code' ";
$data = $crm->mydata($query);
$sponsored_name = $data[name][0];
$entity_type = "Direct";
}
if(!$currency_code)
{
$currency_code = "USD";
}
if(!$locale)
{
$locale = "en_US.UTF8";
}
$query = "select id
from $CURRENCY_EXCHANGE_RATE
where currency_code = '$currency_code'
and date_accurate = '$today'
and brand = '$code' ";
$data_currency_exchange_rate = $crm->mydata($query);
$currency_exchange_rate_id = $data_currency_exchange_rate[id][0];
//setlocale(LC_MONETARY, 'en_US');
//$fmt = new NumberFormatter( $locale, NumberFormatter::CURRENCY );
$fmt = new DwNumberFormatter();
// if user is not logged in the next values will be empty
$query = "select company_id, division_id, contact_id
from $CRM_RELATION
where relation_id = '$customer_relation_id'
and relation_id != ''
and brand = '$code' ";
$data = $crm->mydata($query);
$company_id = $data[company_id][0];
$division_id = $data[division_id][0];
$contact_id = $data[contact_id][0];
if($carry=='')
{
$carry = $u_id;
}
// to use carry in a good way user needs to be logged in => is better that carry is not injected
if($u_id=='')
{
$carry = "";
}
if($cc_submit)
{
// first create order header
$query = "select * from $ORDER_HEADER
where order_header_id = '".ass($order_header_id)."'
and brand = '$code' ";
$oh_data = $crm->mydata($query);
if($oh_data=="")
{
$order_header_id = make_rand();
$query = "insert into $ORDER_HEADER set
order_header_id = '$order_header_id',
relation_id = '$customer_relation_id',
company_id = '$company_id',
division_id = '$division_id',
contact_id = '$contact_id',
order_date = '".gmdate("Y-m-d H:i:s")."',
gm_date = '".gmdate("Y-m-d H:i:s")."',
status = 'PENDING',
payment_method = 'CREDIT_CARD',
created_by = '$u_id',
order_type = 'NEW_BUSINESS',
invoice_id = '$order_header_id',
brand = '$code' ";
$crm->Insert($query);
}
// only one entry as its a donation
$query = "select * from $ORDER_DETAIL
where order_header_id = '".ass($order_header_id)."'
and brand = '$code' ";
$oh_data = $crm->mydata($query);
if($oh_data=="")
{
$query = "insert into $ORDER_DETAIL set
order_detail_id = '".make_rand()."',
order_header_id = '$order_header_id',
product_name = 'Donation',
price = '".ass($donation_amount)."',
currency = '$currency_code',
quantity = '1',
type_revenue = 'DONATION',
brand = '$code' ";
$crm->Insert($query);
} else {
$query = "update $ORDER_DETAIL set
price = '".ass($donation_amount)."'
where order_header_id = '$order_header_id'
and brand = '$code' ";
$crm->Update($query);
}
if($all_cc)
{
$split = str_replace(" ","",$all_cc);
$split = str_replace("-","",$split);
$first_four = substr($split,0,4);
$second_four = substr($split,4,4);
$third_four = substr($split,8,4);
$fourth_four = substr($split,12,4);
}
// lets make sure they entered all the right stuff
//if(!luhn_check($all_cc))
if(!luhn_check($all_cc) && $foo==600)
{
if(!$staging)
{
$l_message = $message_array['checkout_06'];
$message .= "
$l_message - 1";
$show_credit_card = "yes";
}
}
if(strlen($first_four)!=4 || strlen($second_four)!=4 || strlen($third_four)!=4)
{
//$message .= "
Please enter the credit card number correctly.";
$l_message = $message_array['checkout_06'];
$message .= "
$l_message - 2";
$show_credit_card = "yes";
}
if($month=="")
{
//$message .="
Please enter the month of expiration.";
$l_message = $message_array['checkout_07'];
$message .="
$l_message";
$show_credit_card ="yes";
}
if($year=="")
{
//$message .="
Please enter the year of expiration of the credit card.";
$l_message = $message_array['checkout_08'];
$message .="
$l_message";
$show_credit_card ="yes";
}
if($first_name=="")
{
//$message .="
Please enter card holders first name.";
$l_message = $message_array['checkout_09'];
$message .="
$l_message";
$show_credit_card ="yes";
}
if($last_name=="")
{
//$message .="
Please enter card holders last name.";
$l_message = $message_array['checkout_10'];
$message .="
$l_message";
$show_credit_card ="yes";
}
if($email=="")
{
//$message .="
Please enter your email.";
//$l_message = $message_array['checkout_16'];
//$l_message = "Please enter your email.";
$l_message = $message_array['checkout_32'];
$message .="
$l_message";
$show_credit_card ="yes";
}
else if(!valid_email(trim($email)))
{
//$message .="
Please enter a valid email.";
//$l_message = $message_array['checkout_16'];
$l_message = $message_array['checkout_32'];
$message .="
$l_message";
$show_credit_card ="yes";
}
if($phone=="")
{
//$message .="
Please enter the card holders telephone number.";
$l_message = $message_array['checkout_11'];
$message .="
$l_message";
$show_credit_card ="yes";
}
if($address_1_1=="")
{
//$message .="
Please enter the street address.";
$l_message = $message_array['checkout_12'];
$message .="
$l_message";
$show_credit_card ="yes";
}
if($city=="")
{
//$message .="
Please enter the city.";
$l_message = $message_array['checkout_13'];
$message .="
$l_message";
$show_credit_card ="yes";
}
if($province=="")
{
//$message .="
Please enter the state or province.";
$l_message = $message_array['checkout_14'];
$message .="
$l_message";
$show_credit_card ="yes";
}
if($zip=="")
{
//$message .="
Please enter the zipcode or postal code.";
$l_message = $message_array['checkout_15'];
$message .="
$l_message";
$show_credit_card ="yes";
}
if($country=="")
{
//$message .="
Please enter the country.";
$l_message = $message_array['checkout_16'];
$message .="
$l_message";
$show_credit_card ="yes";
}
if(!is_numeric($donation_amount) || $donation_amount <= 0)
{
//$message .="
Please enter a valid donation amount.";
//$l_message = "Please enter a valid donation amount.";
$l_message = $message_array['checkout_33'];
$message .="
$l_message";
$show_credit_card ="yes";
}
$query = "select status
from $ORDER_HEADER
where order_header_id = '$order_header_id'
and brand = '$code' ";
$data = $crm->mydata($query);
if($data[status][0]=='PAID')
{
//$message .="
You have already completed this order and your transaction was successful.";
$l_message = $message_array['checkout_17'];
$message .="
$l_message";
$show_credit_card ="yes";
// $show_receipt = "yes";
}
}
if($cc_submit && $message=="")
{
// verify the person did not click submit twice
$query = "select status, cc_processing
from $ORDER_HEADER
where contact_id = '$u_id'
and contact_id != ''
and cc_processing = 'Y'
and brand = '$code' ";
$data = $crm->mydata($query);
if($data[status][0]=='PAID')
{
// header("location: /store/my_account.php?message=You+clicked+submit+more+than+once. Your transaction was successful.");
$l_message = $message_array['checkout_19'];
header("location: /store/my_account.php?message=$l_message&sessid=$sessid");
exit();
}
if($data[status][0]=='PENDING')
{
//header("location: /store/my_account.php?message=".urlencode("You clicked submit more than once. Unfortunately the credit card processor does not allow me to query for previous transactions through the API that I (this computer) has access to so I have sent an email to our support staff letting them know your transaction needs to be researched. We have to make sure that we do not double bill you.")."");
$l_message = $message_array['checkout_20'];
header("location: /store/my_account.php?message=".urlencode($l_message)."&sessid=$sessid" );
$l_message = $message_array['checkout_21'];
mail2("company@dwalliance.com","A partially processed order is in the system.","brand = $code, account = $u_id, email = $session_email \n $code/crm2/show.php?type=contact&id=$carry",$PHP_SELF,$code);
exit();
} else {
$query = "update $ORDER_HEADER set cc_processing = 'Y',
notes = '".ass($notes)."'
where order_header_id = '$order_header_id'
and brand = '$code' ";
$crm->Update($query);
}
// process the credit card ......
// get the total
$query = "select sum((quantity*price) + (quantity*price*provincial_sales_tax) + (quantity*price*goods_and_services_tax) + (quantity*price*harmonized_sales_tax)) as total
from $ORDER_DETAIL
where order_header_id = '$order_header_id'
and brand = '$code' ";
$data = $crm->mydata($query);
$grand_total = $data[total][0];
$grand_total = round($grand_total,2);
if($order_header_id=='')
{
//echo"Sorry but your order is invalid.";
$l_message = $message_array['checkout_22'];
echo $l_message;
mail2("jimmy@dwalliance.com","no order header id","$query \n $code u_id = $u_id \n session_id = $sessid ",$PHP_SELF,$code);
exit();
}
if(!abs($grand_total))
{
//echo"Sorry the order has an invalid amount.";
$l_message = $message_array['checkout_23'];
echo $l_message;
mail2("jimmy@dwalliance.com","invalid amount -- no value","$query \n u_id = $u_id \n brand = $code ",$PHP_SELF,$code);
// el("invalid amount -- no value $query u_id = $u_id brand = $code");
exit();
}
$query = "select m_account_id from $ORDER_HEADER
where order_header_id = '$order_header_id'
and brand = '$code' ";
$data = $crm->mydata($query);
$m_account_id = $data[m_account_id][0];
if($m_account_id)
{
$maccount_detail = get_account_details($m_account_id,$code,$brnd);
if($maccount_detail[type]=='authorize.net')
{
$cc_process = 'yes';
}
if($maccount_detail[type]=='moneris')
{
$cc_process = 'yes';
}
if($maccount_detail[type]=='eway')
{
$cc_process = 'yes';
}
}
// ******** build the order ***********
// for making installments
if($billed=='installment')
{
$order[billed] = $billed;
$order[num_recurs] = $num_recurs - 1;
$order[period] = 1;
$grand_total = $amount_per_installment;
$transaction_description = "Installment Donation";
}
// for making recurring payments
if($billed=='recurring')
{
$order[billed] = $billed;
$order[period] = $period;
// make it last 5 years
if($period==1)
{
$num_recurs = 60;
}
if($period==3)
{
$num_recurs = 20;
}
if($period==6)
{
$num_recurs = 10;
}
if($period==12)
{
$num_recurs = 5;
}
if(!$num_recurs)
{
$num_recurs = 5;
}
$order[num_recurs] = $num_recurs;
$transaction_description = "Recurring Donation";
}
if(!$transaction_description)
{
$transaction_description = "Online Donation";
}
$order[transaction_description] = $transaction_description;
$order[time_stamp] = gmdate("YmdHis");
$order[invoice_number] = substr($order_header_id,0,10);
$order[grandtotal] = $grand_total;
$order[cc_number] = "$first_four$second_four$third_four$fourth_four";
$order[cc_type] = $cc_type;
$order[cc_expiration] = "$month$year";
$order[cc_expiration_mn] = $month;
$order[cc_expiration_yr] = $year;
$order[cc_cvv2_number] = $cc_cvv2_number;
$order[first_name] = $first_name;
$order[company_name] = $company_name;
$order[last_name] = $last_name;
$order[phone] = $phone ;
$order[customer_email] = $email;
$order[street_address] = $address_1_1;
$order[city]= $city;
$order[state]= $province;
$order[zipcode]= $zip;
$order[country]= $country;
$order[currency] = $currency_code;
$order[ip_address] = $_SERVER[HTTP_X_FORWARDED_FOR];
$order[description] = $order_description;
$order[cvn] = $cvn;
// el(capture_print_r($order));
unset($cc_test_domain);
$cc_test_domain[] = 'ISRG';
// $cc_test_domain[] = 'EMCORP';
// $cc_test_domain[] = 'SPCA';
//$cc_test_domain[] = 'DWALLC';
// $cc_test_domain[] = 'LEGINT';
// $cc_test_domain[] = 'EVENTREG';
$safe_ip[] = '70.49.159.224';
$safe_ip[] = '186.15.153.79';
$safe_ip[] = '69.70.72.10';
$safe_ip[] = '190.10.3.169';
$safe_ip[] = '70.51.122.67';
$safe_ip[] = '173.164.162.229';
$safe_ip[] = '173.164.162.225';
$safe_ip[] = '173.164.162.230';
$safe_ip[] = '173.164.162.226';
$safe_ip[] = '190.10.3.169';
$ip = explode(",",$_SERVER["HTTP_X_FORWARDED_FOR"]);
$_SERVER["HTTP_X_FORWARDED_FOR"] = $ip[0];
if(!in_array($_SERVER["HTTP_X_FORWARDED_FOR"],$safe_ip))
{
//el($_SERVER["HTTP_X_FORWARDED_FOR"]);
unset($cc_test_domain);
}
if($cc_process)
{
// authorize.net AIM implementation
if($maccount_detail[type] == 'authorize.net')
{
include('../commonfiles/class.authorize.php');
$auth = new authorizenet;
$order[login] = $maccount_detail[authorize_net_login_id];
if(!$maccount_detail[authorize_x_tran_key])
{
$order[password] = $maccount_detail[authorize_net_password];
} else {
$order[x_tran_key] = $maccount_detail[authorize_x_tran_key];
}
if(!@in_array($code,$cc_test_domain))
{
if($grand_total!='0.00')
{
$result = $auth->cc_sale($order);
} else {
$order[grandtotal] = '1.00'; // this keeps the auth from failing
$result = $auth->cc_auth($order);
$order[grandtotal] = '0.00'; // this makes sure the order history is correct
}
} else {
$result[success_response] = '1';
$result[transaction_id] = '1234';
mail2('jimmy@dwalliance.com',"$code $order_header_id free order","","jimmy@dwalliance.com","Jimmy Brake");
}
}
// moneris
if($maccount_detail[type] == 'moneris')
{
//el($code);
if(!@in_array($code,$cc_test_domain))
{
include('../commonfiles/monerisv250/mpgClasses.php');
include('../commonfiles/moneris.php');
$mpgCustInfo = moneris_customer_info($order);
$result = moneris_purchase($order,$carry,$maccount_detail,$mpgCustInfo,$mpgRecur);
if($result[success_response] == 1)
{
// moneris FUCKING sux
if($order[num_recurs])
{
$mpgRecur = moneris_recurring($order);
$moneris_sux = moneris_purchase($order,$carry,$maccount_detail,$mpgCustInfo,$mpgRecur);
}
$query = "update $ORDER_HEADER set
invoice_id = '$result[invoice_id]'
where order_header_id = '$order_header_id'
and brand = '$code' ";
$crm->Update($query);
}
} else {
$result[success_response] = '1';
$result[transaction_id] = '1234';
mail2('jimmy@dwalliance.com',"$code $order_header_id moneris free order","","jimmy@dwalliance.com","Jimmy Brake");
}
}
// paypal
if($maccount_detail[type] == 'paypal_website_pro')
{
require('../commonfiles/paypal/DoDirect.php');
$result = paypalDoDirect($order,$maccount_detail);
}
// eway
if($maccount_detail[type] == 'eway')
{
require('../commonfiles/class.eway.com.au.php');
// for testing ...
if(@in_array($code,$cc_test_domain))
{
$order[test] = 'Y';
$order[cc_number] = '4444333322221111';
$maccount_detail[ewayCustomerID] = '87654321';
}
$result = eway_sale($order,$maccount_detail);
}
$order[cc_number] = '';
if($result[success_response]!='1')
{
$message .= "
$result[response_reason_text]";
$show_credit_card = 'yes';
$v = capture_print_r($order);
log_cc($order_header_id,$contact_id,$company_id,$result,$v,$app_logs_sql,$code);
$v = capture_print_r($result);
mail2("isurge3@yahoo.com", "$code $email CC failure $PHP_SELF $_SERVER[HTTP_HOST] "," $v", "sysadmin@dwalliance.com","sysadmin");
} else {
$auth_code = $result[transaction_id];
$v = capture_print_r($order);
log_cc($order_header_id,$contact_id,$company_id,$result,$v,$app_logs_sql,$code);
$v = capture_print_r($result);
mail2("isurge3@yahoo.com", "$code $email CC success $PHP_SELF $_SERVER[HTTP_HOST]", $v, "sysadmin@dwalliance.com","sysadmin");
$cc_approved = "yes";
}
}
if($show_credit_card == 'yes')
{
$query = "update $ORDER_HEADER set cc_processing = 'N'
where order_header_id = '$order_header_id'
and brand = '$code' ";
$crm->Update($query);
}
}
unset($approved);
if($cc_approved)
{
$approved = "yes";
$query = "update $ORDER_HEADER set cc_processing = 'N'
where order_header_id = '$order_header_id'
and brand = '$code' ";
$crm->Update($query);
}
if($approved && $message=="")
{
// update order headers
if($cc_approved)
{
// create user account here => plus set carry
$contact_info_query = "";
if(!$u_id)
{
// IF USER IS NOT LOGGED IN !!!
include("../commonfiles/create_contact.php");
// see if client already exists by email
$query = "select cdc_id
from $CDC
where email = '".ass($email)."'
and brand = '$code' ";
$data_dupe_contact = $cdc->mydata($query);
// if contact not exists create it
if(!$data_dupe_contact[cdc_id][0])
{
$contact_data = array();
$contact_data['first_name'] = $first_name;
$contact_data['last_name'] = $last_name;
$contact_data['email'] = $email;
$contact_data['telephone_1 '] = $phone;
$contact_data['address_1_1'] = $address_1_1;
$contact_data['address_1_2'] = $address_1_2;
$contact_data['city_1'] = $city;
$contact_data['province_1'] = $province;
$contact_data['zipcode_1'] = $zip;
$contact_data['country_1'] = $country;
$u_id = create_contact($contact_data,$code);
$carry = $u_id;
$contact_id = $u_id;
// create company if any...
if($company_name)
{
$data_relation = create_company_and_relation($company_name,$u_id,$crm,$code);
$company_id = $data_relation[company_id];
$the_customer_relation_id = $data_relation[relation_id];
}
} else {
// if contact already exists => but not logged in
$u_id = $data_dupe_contact[cdc_id][0];
$carry = $u_id;
$contact_id = $u_id;
// if user supplied a company name
if($company_name)
{
$data_relation = create_company_and_relation($company_name,$u_id,$crm,$code);
$company_id = $data_relation[company_id];
$the_customer_relation_id = $data_relation[relation_id];
} else {
// get company and relation if any...
$query = "select relation_id, company_id
from $CRM_RELATION
where contact_id = '$u_id'
and company_id != ''
and division_id = ''
and disable = '0'
and brand = '$code'
order by last_modified desc
limit 0,1 ";
$data_relation = $crm->mydata($query);
$company_id = $data_relation[company_id][0];
$the_customer_relation_id = $data_relation[relation_id][0];
}
}
$contact_info_query = "relation_id = '$the_customer_relation_id',
company_id = '$company_id',
contact_id = '$carry', ";
}
$query = "update $ORDER_HEADER set
status = 'PAID',
approve_date = '".gmdate("Y-m-d H:i:s")."',
$contact_info_query
cc_name = '".addslashes("$first_name $last_name")."',
cc_first_name = '".addslashes($first_name)."',
cc_last_name = '".addslashes($last_name)."',
cc_address_1 = '".addslashes($address_1_1)."',
cc_city = '".addslashes($city)."',
cc_province = '".addslashes($province)."',
cc_postal_code = '".addslashes($zip)."',
cc_country = '".addslashes($country)."',
cc_type = '$cc_type',
cc_first4 = '$first_four',
cc_last4 = '$fourth_four',
cc_phone_number = '".addslashes($phone)."',
cc_expiration_date = '$month / $year',
cc_auth_code = '$auth_code'
where order_header_id = '$order_header_id'
and brand = '$code' ";
$crm->Update($query);
$query = "insert into $ORDER_PARTIAL_PAYMENT set
partial_payment_id = '".make_rand()."',
order_header_id = '$order_header_id',
relation_id = '$the_customer_relation_id',
currency_exchange_rate_id = '$currency_exchange_rate_id',
amount = '".ass($donation_amount)."',
currency = '$currency_code',
company_id = '$company_id',
contact_id = '$carry',
cc_name = '".ass("$first_name $last_name")."',
cc_first_name = '".addslashes($first_name)."',
cc_last_name = '".addslashes($last_name)."',
cc_address_1 = '".addslashes($address_1_1)."',
cc_city = '".addslashes($city)."',
cc_province = '".addslashes($province)."',
cc_postal_code = '".addslashes($zip)."',
cc_country = '".addslashes($country)."',
cc_type = '$cc_type',
cc_first4 = '$first_four',
cc_last4 = '$fourth_four',
cc_phone_number = '$phone',
cc_expiration_date = '$month / $year',
cc_auth_code = '$auth_code',
# cc_clearing_house_id = '$cybersourceid',
payment_method = 'CREDIT_CARD',
notes = '".addslashes($notes)."',
order_date = '".gmdate("Y-m-d H:i:s")."',
transaction_date = '".gmdate("Y-m-d H:i:s")."',
created_by = '$u_id',
m_account_id = '$m_account_id',
brand = '$code' ";
$crm->Insert($query);
// insert donation entry here
$name_in_donor_scroll = $name_in_donor_scroll?"Y":"N";
$amount_in_donor_scroll = $amount_in_donor_scroll?"Y":"N";
if($donation_team_member_id)
{
$tmp_sql = " id_type = 'donation_team_member_id',
id_value = '".ass($donation_team_member_id)."', ";
}
if($donation_individual_id)
{
$tmp_sql = " id_type = 'donation_individual_id',
id_value = '".ass($donation_individual_id)."', ";
}
if($team_id)
{
$tmp_sql = "id_type = 'donation_team_id',
id_value = '".ass($team_id)."',";
}
if(!$tmp_sql)
{
$tmp_sql = "id_type = 'donation_id',
id_value = '".ass($donation_id)."', ";
}
$query = "insert into $DONATION_GIFT set
id = '".make_rand()."',
donation_id = '".ass($donation_id)."',
$tmp_sql
order_header_id = '".ass($order_header_id)."',
name_in_donor_scroll = '".ass($name_in_donor_scroll)."',
amount_in_donor_scroll = '".ass($amount_in_donor_scroll)."',
brand = '$code' ";
$crm->Insert($query);
// last billing foo
$contact = get_cdc($carry,$code,$cdc);
$company = get_cdc($company_id,$code,$cdc);
insert_order_contact($order_header_id,$company,$contact,'CONTACT',$code,$crm);
$billing = get_cdc($u_id,$code,$cdc);
insert_order_contact($order_header_id,$company,$billing,'BILLING',$code,$crm);
}
$cc_month = $month;
$cc_year = $year;
// send email and move to home or whatever
if($cc_approved)
{
// print order details
$query = "select product_name, price, quantity, product_id
from $ORDER_DETAIL
where order_header_id = '$order_header_id'
and brand = '$code' ";
$data = $crm->mydata($query);
for($a=0;$a