예제 #1
0
 function process_transactions($params)
 {
     set_time_limit(0);
     if (!$params['Format']) {
         $params['Format'] = "TXT";
     }
     if (!$params['Incremental']) {
         $params['Incremental'] = "True";
     }
     $RF = new rates_fees();
     $trans = $this->Status_Download($params);
     $return_affected_rows = 0;
     $approve_affected_rows = 0;
     $log = "";
     foreach ($trans as $tran) {
         $update = false;
         $chargeback = false;
         $refund = false;
         $status = "";
         switch (strtolower($tran['ResponseType'])) {
             case "processed":
                 $update = false;
                 break;
             case "b":
                 $update = false;
                 break;
             case "f":
                 $update = true;
                 $status = 'A';
                 break;
             case "r":
                 $update = true;
                 $status = 'D';
                 break;
             case "nsf":
                 $update = true;
                 $status = 'D';
                 break;
             case "chargeback":
                 $update = true;
                 $status = 'D';
                 $chargeback = true;
                 break;
             case "invalid":
                 $update = true;
                 $status = 'D';
                 break;
             case "declined":
                 $update = true;
                 $status = 'D';
                 break;
             case "refund":
                 $update = true;
                 $status = 'D';
                 $refund = true;
                 break;
             case "credit":
                 $update = true;
                 $status = 'D';
                 $refund = true;
                 break;
             case "incomplete":
                 $update = true;
                 $status = 'D';
                 break;
             case "cancelled":
                 $update = true;
                 $status = 'D';
                 break;
             case "bo exception":
                 $update = true;
                 $status = 'D';
                 break;
             case "downloaded":
                 $update = false;
                 break;
             case "credit originated":
                 $update = false;
                 break;
             case "credit downloaded":
                 $update = false;
                 break;
             case "credit return":
                 $update = true;
                 $status = 'D';
                 $chargeback = true;
                 break;
             case "credit funded":
                 $update = true;
                 $status = 'A';
                 break;
         }
         $refid = substr($tran['ExternalClientID'], 0, 50);
         if (!$refid) {
             continue;
         }
         $sql = "\n\t\t\t\tselect * from \n\t\t\t\t\tcs_transactiondetails left join \n\t\t\t\t\tcs_subscription on \n\t\t\t\t\ttd_ss_ID = ss_ID\n\t\t\t\tWHERE\n\t\t\t\t\treference_number = '{$refid}'\n\t\t\t\t\tAND checkorcard='C'\t\t\n\t\t\t\tLIMIT 1\n\t\t\t";
         $tranResult = mysql_query($sql) or dieLog(mysql_error() . " ~ {$sql}");
         $transInfo = mysql_fetch_assoc($tranResult);
         $transId = $transInfo['transactionId'];
         if ($transInfo['status'] != 'P' && $update == true) {
             $update = false;
         }
         if (!$transId) {
             $log .= " Transaction ID Not Found!! " . print_r($tran, true);
             toLog('erroralert', 'misc', "Transaction ID Not Found!! {$transId} {$sql}");
             $update = false;
         }
         if ($update) {
             $log .= " Found Response Type (" . $tran['ResponseType'] . ") For ({$refid}):\n";
             $notify = 'decline';
             $bank_transid = $tran['TransID'];
             if ($tran['ResponseDate']) {
                 $billingDate = date('Y-m-d', strtotime($tran['ResponseDate']));
             } else {
                 $billingDate = "";
             }
             if ($chargeback) {
                 //is_chargeback
                 $sql = "\n\t\t\t\t\t\tUPDATE\n\t\t\t\t\t\t\tcs_transactiondetails left join \n\t\t\t\t\t\t\tcs_subscription on \n\t\t\t\t\t\t\ttd_ss_ID = ss_ID\n\t\t\t\t\t\tSET\n\t\t\t\t\t\t\tstatus='A',\n\t\t\t\t\t\t\ttd_is_chargeback = 1,\n\t\t\t\t\t\t\ttd_bank_transaction_id = '{$bank_transid}',\n\t\t\t\t\t\t\tbillingDate = '{$billingDate}',\n\t\t\t\t\t\t\ttd_merchant_deducted=0,\n\t\t\t\t\t\t\tss_rebill_status = 'inactive',\n\t\t\t\t\t\t\tss_rebill_status_text = 'Subscription Inactive due to Chargeback'\n\t\t\t\t\t\tWHERE\n\t\t\t\t\t\t\ttransactionId = '{$transId}'\n\t\t\t\t\t\t\tAND checkorcard='C'\t\t\n\t\t\t\t\t";
                 $log .= "  This transaction is a chargeback.\n";
                 $notify = 'chargeback';
                 $r = $RF->update_transaction_profit($transId);
             } else {
                 if ($refund) {
                     // cancel_status = y, cancel subscription
                     $sql = "\n\t\t\t\t\t\tUPDATE\n\t\t\t\t\t\t\tcs_transactiondetails left join \n\t\t\t\t\t\t\tcs_subscription on \n\t\t\t\t\t\t\ttd_ss_ID = ss_ID\n\t\t\t\t\t\tSET\n\t\t\t\t\t\t\tstatus='A',\n\t\t\t\t\t\t\tcancelstatus = 'Y',\n\t\t\t\t\t\t\ttd_bank_transaction_id = '{$bank_transid}',\n\t\t\t\t\t\t\tbillingDate = '{$billingDate}',\n\t\t\t\t\t\t\ttd_merchant_deducted=0,\n\t\t\t\t\t\t\tss_rebill_status = 'inactive',\n\t\t\t\t\t\t\tss_rebill_status_text = 'Subscription Inactive due to Refund'\n\t\t\t\t\t\tWHERE\n\t\t\t\t\t\t\ttransactionId = '{$transId}'\n\t\t\t\t\t\t\tAND checkorcard='C'\t\t\t\n\t\t\t\t\t";
                     $log .= "  This transaction is a refund.\n";
                     $notify = 'refund';
                     $r = $RF->update_transaction_profit($transId);
                 } else {
                     $ss_rebill_status_sql = $status == 'D' ? "ss_rebill_status = 'inactive', " : '';
                     $ss_rebill_status_text = $status == 'D' ? 'Subscription Inactive due to decline (' . $this->ach_status[$tran['ResponseType']] . ')' : 'Subscription Active';
                     $sql = "\n\t\t\t\t\t\tUPDATE\n\t\t\t\t\t\t\tcs_transactiondetails left join \n\t\t\t\t\t\t\tcs_subscription on \n\t\t\t\t\t\t\ttd_ss_ID = ss_ID\n\t\t\t\t\t\tSET\n\t\t\t\t\t\t\ttd_bank_transaction_id = '{$bank_transid}',\n\t\t\t\t\t\t\tstatus = '{$status}',\n\t\t\t\t\t\t\tbillingDate = '{$billingDate}',\n\t\t\t\t\t\t\ttd_merchant_deducted=0,\n\t\t\t\t\t\t\ttd_merchant_paid=0,\n\t\t\t\t\t\t\t{$ss_rebill_status_sql}\n\t\t\t\t\t\t\tss_rebill_status_text = '{$ss_rebill_status_text}'\n\t\t\t\t\t\tWHERE\n\t\t\t\t\t\t\ttransactionId = '{$transId}'\n\t\t\t\t\t\t\tAND checkorcard='C'\tAND status='P'\t\n\t\t\t\t\t";
                     $log .= "  This transaction's status is (" . $this->ach_status[$tran['ResponseType']] . ").\n";
                     $r = $RF->update_transaction_profit($transId);
                 }
             }
             sql_query_write($sql) or dieLog(mysql_error() . "<pre>{$sql}</pre>");
             $affected = mysql_affected_rows();
             if ($status != 'A') {
                 $return_affected_rows += $affected;
             } else {
                 $approve_affected_rows += $affected;
             }
             if ($status == 'A') {
                 if ($transInfo['td_is_a_rebill']) {
                     $notify = 'rebill';
                 } else {
                     $notify = 'approve';
                 }
             }
             if ($affected) {
                 Process_Transaction($transId, $notify, 0, 'transactionId');
             }
         } else {
             $log .= "  Ignoring Transaction.\n";
         }
     }
     $log .= "CheckGateway Result: ({$return_affected_rows}) Returns, ({$approve_affected_rows}) Approves.\n";
     return $log;
 }
예제 #2
0
chdir("..");
set_time_limit(500);
$gateway_db_select = 3;
$etel_disable_https = 1;
include "includes/dbconnection.php";
$RF = new rates_fees();
$log .= "Updating Pending Profit Actions.\n";
$sql = "SELECT pa_trans_id FROM `cs_profit_action` WHERE `pa_status` = 'pending' and `pa_type` = 'Transaction' order by pa_ID desc LIMIT 5000";
$result = sql_query_read($sql) or dieLog(mysql_error() . " ~ {$sql}");
if (mysql_num_rows($result) == 0) {
    $log .= "No Transaction Updates\n";
} else {
    while ($cs_profit_action = mysql_fetch_assoc($result)) {
        $log .= "  Updating Transaction Profit for '" . $cs_profit_action['pa_trans_id'] . "'.\n";
        $r = $RF->update_transaction_profit($cs_profit_action['pa_trans_id']);
        $log .= "  Result: " . $r['msg'] . "\n";
    }
}
//toLog('misc','system', $log);
$sql = "SELECT * FROM `cs_profit_action` WHERE `pa_status` = 'pending' and `pa_type` = 'Payout' order by pa_ID desc LIMIT 1000";
$result = sql_query_read($sql) or dieLog(mysql_error() . " ~ {$sql}");
if (mysql_num_rows($result) == 0) {
    $log .= "No Payout Updates\n";
} else {
    $log .= "\n Updating Pending Payout Actions.\n";
    while ($cs_profit_action = mysql_fetch_assoc($result)) {
        $log .= "  Updating Payout Profit for Entity '" . $cs_profit_action['pa_en_ID'] . "'.\n";
        $r = $RF->commit_payout($cs_profit_action['pa_en_ID'], array('date_entered' => $cs_profit_action['pa_date']));
        $log .= "  Result: " . $r['msg'] . "\n";
    }
예제 #3
0
function smart_removeRefund($values, $action)
{
    global $curUserInfo;
    if (!$curUserInfo['en_access'][ACCESS_AUTH_TRANS_MOD]) {
        return array("action" => "Invalid Access.", "status" => "Fail");
    }
    $transID = $values['append'];
    $qry_details = "UPDATE cs_transactiondetails SET `cancelstatus` = 'N',`td_bank_deducted`=1,`td_merchant_deducted`=1,`td_reseller_deducted`=1  WHERE `transactionId` = '{$transID}'";
    $rst_details = sql_query_write($qry_details) or dieLog(mysql_errno() . ": " . mysql_error() . "<BR>Cannot execute query");
    $qry_details = "DELETE FROM cs_callnotes WHERE `cn_type` = 'refundrequest' AND `transaction_id` = '{$transID}'";
    $rst_details = sql_query_write($qry_details) or dieLog(mysql_errno() . ": " . mysql_error() . "<BR>Cannot execute query");
    $RF = new rates_fees();
    $r = $RF->update_transaction_profit($transID);
    return array("action" => "Transaction ID " . $values['append'] . " refund removed.", "status" => "success");
}
예제 #4
0
    $access['Data']['td_tracking_info']['disable'] = false;
}
unset($access['Data']['cd_enable_tracking']);
unset($access['Data']['td_enable_tracking']);
$access['Data']['ss_cancel_id']['DisplayName'] = 'Cancelation ID';
if (!$access['Data']['ss_cancel_id']['Value']) {
    unset($access['Data']['ss_cancel_id']);
}
if (!$access['Data']['ss_billing_state']['Value']) {
    unset($access['Data']['ss_billing_state']);
}
if (!$access['Data']['Last_Rebill_Date']['Value']) {
    unset($access['Data']['Last_Rebill_Date']);
}
$RF = new rates_fees();
$r = $RF->update_transaction_profit($transactionId, true);
etelPrint($r);
$profit = $RF->get_profit(array('EffectiveOnly' => false, 'useTransTable' => true, 'where' => array('pa_trans_ID' => $transactionId)), 2);
if (!is_array($profit['Revenue'])) {
    $r = $RF->update_transaction_profit($transactionId);
    $profit = $RF->get_profit(array('EffectiveOnly' => false, 'useTransTable' => true, 'where' => array('pa_trans_ID' => $transactionId)), 2);
}
$row = 2;
$access['Data']['Breakdown']['RowDisplay'] = 'Wide';
$access['Data']['Breakdown']['Input'] = '';
$access['Data']['Breakdown']['disable'] = true;
$access['Data']['Breakdown']['DisplayName'] = false;
$access['Data']['Breakdown']['AddHtml'] .= $smarty->assign("Profit", $profit);
$access['Data']['Breakdown']['AddHtml'] = $smarty->fetch('cp_profitreport.tpl');
if ($_POST['submit_access'] == 'Submit') {
    $result = processAccessForm(&$access);
예제 #5
0
 function execute_transaction()
 {
     global $cnn_cs;
     global $etel_fraud_limit;
     ignore_user_abort(true);
     set_time_limit(500);
     if (!$_SESSION['tmpl_language']) {
         $_SESSION['tmpl_language'] = 'eng';
     }
     $rates = new rates_fees();
     $gw_emails_sales = $_SESSION['gw_emails_sales'];
     if (!$etel_fraud_limit) {
         $etel_fraud_limit = floatval($this->companyInfo['cd_fraudscore_limit']);
     }
     $this->transInfo['td_bank_recieved'] = 'no';
     $this->transInfo['companyname'] = $this->companyInfo['companyname'];
     $this->transInfo['cs_enable_passmgmt'] = $this->companyInfo['cs_enable_passmgmt'];
     if (!$this->transInfo['billing_descriptor']) {
         $this->transInfo['billing_descriptor'] = $this->bankInfo['bk_descriptor_visa'];
     }
     $this->transInfo['cardtype'] = $this->bankInfo['bk_trans_types'];
     if (!$this->transInfo['td_send_email'] == 'no') {
         $this->transInfo['td_send_email'] = 'yes';
     }
     if (!$this->transInfo['td_gcard']) {
         $this->transInfo['td_gcard'] = "NULL";
     }
     $this->transInfo['td_fraud_score'] = -1;
     //if($this->transInfo['td_customer_fee']) $this->transInfo['amount'] += $this->transInfo['td_customer_fee'];
     // INCORRECT. customer fee is already included in amount
     $_SESSION['etel_trans_pending'] = true;
     $_SESSION['etel_trans_pending_ref'] = $this->transInfo['reference_number'];
     $start_transaction = microtime_float();
     if ($this->mode == "Live") {
         $this->response = $this->fraud->execute_scrub_tests($this->transInfo, $this->bankInfo, $this->companyInfo);
         if ($this->response == -1) {
             $int_func = $this->int_function;
             $int_func_response = $int_func($this->transInfo, $this->bankInfo, $this->companyInfo);
             $log = "Transaction '" . $this->transInfo['reference_number'] . "' Integration Response: " . $int_func_response['td_process_result'] . " ~ Integration Query: " . $int_func_response['td_process_query'] . " ~ Response Info: " . serialize($int_func_response);
             $this->sanitizeChargeInfo($log);
             toLog('order', 'customer', $log, $this->trans_id);
             $this->response = $int_func_response;
         }
         $this->response['success'] = true;
         $this->transInfo['td_process_result'] = $int_func_response['td_process_result'];
         $this->transInfo['td_process_query'] = $int_func_response['td_process_query'];
         $this->transInfo['td_bank_transaction_id'] = $int_func_response['td_bank_transaction_id'];
         if ($int_func_response['td_gcard']) {
             $this->transInfo['td_gcard'] = $int_func_response['td_gcard'];
         }
         if (!$this->transInfo['td_gcard']) {
             $this->transInfo['td_gcard'] = "NULL";
         }
         $this->transInfo['td_bank_recieved'] = $int_func_response['td_bank_recieved'];
     } else {
         $this->response['errormsg'] = "Success";
         $this->response['success'] = true;
         $this->response['status'] = "A";
         $this->transInfo['td_process_result'] = "test";
         $this->transInfo['td_process_query'] = "test";
         $this->transInfo['td_bank_recieved'] = 'no';
     }
     $this->transInfo['status'] = $this->response['status'];
     $this->transInfo['td_process_msg'] = $this->response['td_process_msg'];
     if (!$this->transInfo['td_process_msg']) {
         $this->transInfo['td_process_msg'] = $this->response['errormsg'];
     }
     if ($this->transInfo['status'] == "D") {
         $this->transInfo['td_username'] = "";
         $this->transInfo['td_password'] = "";
     } else {
         if (!$this->transInfo['td_ss_ID'] && $this->transInfo['td_rebillingID'] > 1 && $this->mode == "Live" && $this->transInfo['status'] != "D") {
             $this->createSubscription();
             $this->set_transaction_subid();
             //$this->transInfo['td_ss_ID'] = $subsciption->transInfo['td_ss_ID'];
         }
     }
     $int_table = "cs_test_transactiondetails";
     if ($this->mode == "Live") {
         $int_table = "cs_transactiondetails";
     }
     $this->transInfo['td_process_duration'] = microtime_float() - $start_transaction;
     $this->transInfo['td_non_unique'] = $this->fraud->check_unique($int_table, $this->transInfo);
     $this->sanitizeChargeInfo($this->transInfo['td_process_query']);
     $this->sanitizeChargeInfo($this->transInfo['td_process_result']);
     $qrt_update_details = "\r\n\t\t\tupdate \r\n\t\t\t\t{$int_table} \r\n\t\t\tset \r\n\t\t\t\t`td_gcard` = '" . $this->transInfo['td_gcard'] . "', \r\n\t\t\t\t`td_bank_recieved` = '" . $this->transInfo['td_bank_recieved'] . "',\r\n\t\t\t\t`td_fraud_score` = '" . $this->transInfo['td_fraud_score'] . "',\r\n\t\t\t\t`status` = '" . $this->transInfo['status'] . "',\r\n\t\t\t\t`td_username` = '" . $this->transInfo['td_username'] . "',\r\n\t\t\t\t`td_process_msg` = '" . quote_smart($this->transInfo['td_process_msg']) . "',\r\n\t\t\t\t`td_password` = '" . $this->transInfo['td_password'] . "',\r\n\t\t\t\t`td_bank_transaction_id` = '" . $this->transInfo['td_bank_transaction_id'] . "',\r\n\t\t\t\t`td_process_query` = '" . quote_smart($this->transInfo['td_process_query']) . "',\r\n\t\t\t\t`td_process_result` = '" . quote_smart($this->transInfo['td_process_result']) . "',\r\n\t\t\t\t`td_process_duration` = '" . quote_smart($this->transInfo['td_process_duration']) . "',\r\n\t\t\t\t`td_non_unique` = '" . quote_smart($this->transInfo['td_non_unique']) . "',\r\n\t\t\t\t`td_ss_ID` = '" . quote_smart($this->transInfo['td_ss_ID']) . "'\r\n\t\t\twhere \r\n\t\t\t\ttransactionId = '" . $this->trans_id . "'\r\n\t\t\tLIMIT 1\t\r\n\t\t\t;\r\n\t\t\t";
     toLog('order', 'customer', "Transaction '" . $this->transInfo['reference_number'] . "' Update Query: " . $qrt_update_details, $this->trans_id);
     $show_insert_run = sql_query_write($qrt_update_details) or dieLog(mysql_errno() . ": " . mysql_error() . "<pre>{$qrt_update_details}</pre>");
     $rates->update_transaction_profit($this->trans_id, true);
     if ($this->response['success'] == true) {
         $this->response['transactionId'] = $this->trans_id;
         if ($this->transInfo['status'] == 'A' || $this->transInfo['status'] == 'P' && $this->transInfo['checkorcard'] == 'C') {
             if ($this->transInfo['td_send_email'] == 'yes') {
                 // Email
                 $email_to = $this->transInfo['email'];
                 //$useEmailTemplate = "customer_recur_subscription_confirmation_cc";
                 $useEmailTemplate = "customer_order_confirmation_cc";
                 //if($this->transInfo['td_one_time_subscription']) $useEmailTemplate = "customer_subscription_confirmation_cc";
                 //if($this->transInfo['td_is_a_rebill'] == 1) $useEmailTemplate = "customer_rebill_confirmation_cc";
                 $data = array();
                 $data['payment_type'] = $this->payment_type;
                 $data['billing_descriptor'] = $this->transInfo['billing_descriptor'];
                 $data['site_URL'] = $this->companyInfo['cs_URL'];
                 $data['reference_number'] = $this->transInfo['reference_number'];
                 $data['subscription_id'] = $this->transInfo['td_subscription_id'];
                 $data['full_name'] = $this->transInfo['surname'] . ", " . $this->transInfo['name'];
                 $pInfo = $this->transInfo['td_product_id'];
                 $data['product_info'] = $pInfo . ($pInfo ? ": " : '') . $this->transInfo['productdescription'];
                 $data['email'] = $email_to;
                 $data['customer_email'] = $email_to;
                 $data['credit_card_formatted'] = $this->credit_card_formatted;
                 $data['amount'] = "\$" . formatMoney($this->transInfo['amount'] - $this->transInfo['td_customer_fee']) . " USD";
                 $data['customer_fee'] = "\$" . formatMoney($this->transInfo['td_customer_fee']) . " USD";
                 $data['final_amount'] = "\$" . formatMoney($this->transInfo['amount']) . " USD";
                 $data['username'] = $this->transInfo['td_username'];
                 $data['password'] = $this->transInfo['td_password'];
                 $data['payment_schedule'] = $this->transInfo['payment_schedule'];
                 if (!$data['payment_schedule']) {
                     $data['payment_schedule'] = 'No Schedule';
                 }
                 $data['transaction_date'] = date("F j, Y G:i:s", strtotime($this->transInfo['transactionDate']));
                 $data['next_bill_date'] = $this->transInfo['nextDateInfo'];
                 $data['site_access_URL'] = $this->companyInfo['cs_member_url'];
                 $data['customer_support_email'] = $this->companyInfo['cs_support_email'];
                 $data['tmpl_language'] = $_SESSION['tmpl_language'];
                 $data['gateway_select'] = $this->companyInfo['gateway_id'];
                 $str_is_test = "THIS IS A TEST TRANSACTION ";
                 if ($this->mode == "Live") {
                     $str_is_test = "";
                 }
                 if ($this->transInfo['td_is_a_rebill']) {
                     $useEmailTemplate = "customer_recur_subscription_confirmation_cc";
                 }
                 if (!$this->transInfo['td_is_a_rebill']) {
                     send_email_template($useEmailTemplate, $data, $str_is_test);
                 }
                 // Send Customer Email.
                 if ($this->mode == "Live" && $this->bankInfo['bk_cc_bank_enabled'] == 1) {
                     $data['email'] = $this->bankInfo['bank_email'];
                     send_email_template($useEmailTemplate, $data, "(Bank Copy) ");
                 }
                 if ($this->companyInfo['cd_recieve_order_confirmations']) {
                     $data['email'] = $this->companyInfo['cd_recieve_order_confirmations'];
                     send_email_template($useEmailTemplate, $data, $str_is_test . "(Merchant Copy) ");
                 }
             }
         }
         if ($mode != "Live") {
             $sql = "\r\n\t\t\t\t\tUPDATE \r\n\t\t\t\t\t\tcs_companydetails \r\n\t\t\t\t\tset \r\n\t\t\t\t\t\t`cd_completion` = 7 \r\n\t\t\t\t\tWHERE \r\n\t\t\t\t\t\t`cd_completion` = 6 \r\n\t\t\t\t\t\tAND `userId` = '" . $this->transInfo['userId'] . "'\r\n\t\t\t\t\t";
             if ($this->companyInfo['cd_completion'] == 6) {
                 sql_query_write($sql) or dieLog(mysql_error() . "<pre>{$sql}</pre>");
             }
             $this->transInfo['td_product_id'] = "TEST MODE";
             $this->transInfo['amount'] = "TEST MODE";
         }
         $_SESSION['etel_trans_pending'] = true;
         // Post Notification
         $notify = 'decline';
         if ($this->transInfo['status'] == 'A' || $this->transInfo['status'] == 'P' && $this->transInfo['checkorcard'] == 'C') {
             if ($this->transInfo['td_is_a_rebill']) {
                 $notify = 'rebill';
             } else {
                 $notify = 'approve';
             }
         }
         Process_Transaction($this->transInfo['reference_number'], $notify, $this->mode != "Live");
         //approved or declined
     }
     $this->transInfo['transactionId'] = $this->trans_id;
     $this->response['transactionId'] = $this->transInfo['transactionId'];
     $this->response['reference_number'] = $this->transInfo['reference_number'];
     $this->response['td_subscription_id'] = $this->transInfo['td_subscription_id'];
     $this->response['watchInfo'] = $this->fraud->check_watchlist($this->transInfo);
     $_SESSION['etel_trans_pending'] = false;
 }
예제 #6
0
$RF = new rates_fees();
//for($i=0;$i<1000000000;$i+=10000)
//{
$j = 0;
$bank_id = 18;
$sql = "SELECT min( pa_trans_id ) AS mintrans\r\nFROM `cs_profit_action`";
$result = sql_query_read($sql) or dieLog($sql);
$min = mysql_result($result, 0, 0);
if ($min < 1) {
    $min = 500000000;
}
$sql = "SELECT transactionId,bank_id FROM `cs_transactiondetails` where \r\n\ttransactionId < {$min} \r\n\torder by transactionId desc LIMIT 200000";
echo "{$sql}<br>";
$result = sql_query_read($sql) or dieLog($sql);
while ($transInfo = mysql_fetch_assoc($result)) {
    $transIDs[] = $transInfo;
}
foreach ($transIDs as $transInfo) {
    if (in_array(intval($transInfo['bank_id']), array(18, 31, 32, 33, 34, 35, 37, 38, 39, 40))) {
        $RF = new rates_fees();
        $r = $RF->update_transaction_profit($transInfo['transactionId']);
        if ($r['status'] != 'success') {
            print_r($r);
        }
        //print($transInfo['transactionId'].'_'.$transInfo['userId'].'_'.$transInfo['reference_number'].'_'.$j);
        echo $j . " ";
    }
    $j++;
}
echo $j;
//echo "<script> setTimeout(\"document.location.href =  'manip.php?".rand(1,1000)."'\",100);</script>";