function smart_updateMarkup($values, $action, $updateall = false) { global $curUserInfo; $en_ID = $values['append']; if ($updateall) { $res_disc = $_POST['default_disc']; $res_trans = $_POST['default_trans']; } else { $res_disc = $_POST['res_disc_' . $userid]; $res_trans = $_POST['res_trans_' . $userid]; } $sql = "select cb_ID,cb_config\n\t\t\tFROM \n\t\t\t\tcs_entities as ce\n\t\t\tLEFT JOIN \n\t\t\t\tcs_entities_affiliates as ea ON (ea.ea_en_ID = ce.en_ID)\n\t\t\tLEFT JOIN \n\t\t\t\tcs_company_banks as cb ON (ce.en_ID = cb.cb_en_ID AND cb.bank_id = 0)\n\t\t\tWHERE\n\t\t\t\tea.ea_affiliate_ID = '" . $curUserInfo['en_ID'] . "'"; if ($en_ID || !$updateall) { $sql .= " and ce.en_ID = '{$en_ID}'"; } $markupResult = sql_query_read($sql) or dieLog(mysql_error() . " ~ {$sql}"); if (!mysql_num_rows($markupResult)) { return array("action" => "Affiliate(s) Not Found.", "status" => "fail"); } while ($markupInfo = mysql_fetch_assoc($markupResult)) { if (!$markupInfo['cb_ID']) { $sql = "insert into cs_company_banks set cb_en_ID = '" . intval($markupInfo['merchant_en_ID']) . "',bank_id=0;"; $result = sql_query_write($sql) or dieLog(mysql_error() . " ~ {$sql}"); $cb_ID = mysql_insert_id(); } else { $cb_ID = $markupInfo['cb_ID']; $markupInfo['cb_config'] = etel_unserialize($markupInfo['cb_config']); } $update = array('default' => array('Reseller' => array('disct' => $res_disc, 'trans' => $res_trans, 'en_ID' => $curUserInfo['en_ID']))); if ($updateall && $markupInfo['cb_config']['default']['Reseller']) { $update = NULL; } if ($update) { $updated = etel_update_serialized_field('cs_company_banks', 'cb_config', " cb_ID = '{$cb_ID}'", $update); if (!$updateall) { if ($updated) { return array("action" => "Merchant Rates Updated Successfully.", "status" => "success"); } return array("action" => "Error, Please contact support.", "status" => "fail"); } } } return array("action" => "Merchant(s) Rates Updated Successfully.", "status" => "success"); }
$curUserInfo = mysql_fetch_assoc($result); $curUserInfo['en_info'] = etel_unserialize($curUserInfo['en_info']); $_SESSION["gw_user_email"] = $curUserInfo['en_email']; $_SESSION["gw_user_en_ID"] = $curUserInfo['en_ID']; $_SESSION["gw_user_en_type"] = $curUserInfo['en_type']; $companyInfo = $curUserInfo; // Phase out companyInfo } else { if ($_SESSION["userType"] == "Reseller") { $sql = "\r\n\t\tselect \r\n\t\t\t*\r\n\t\tfrom \r\n\t\t\tcs_entities as en \r\n\t\twhere \r\n\t\t\ten_username='******' \r\n\t\t\tand en_password='******' \r\n\t\t"; $result = sql_query_read($sql) or dieLog(mysql_errno() . ": " . mysql_error() . "<BR>Cannot execute query {$sql}"); if (mysql_num_rows($result) < 1) { $redirect_home = true; } $curUserInfo = mysql_fetch_assoc($result); $curUserInfo['en_info'] = etel_unserialize($curUserInfo['en_info']); $_SESSION["gw_user_email"] = $curUserInfo['en_email']; $_SESSION["gw_user_en_ID"] = $curUserInfo['en_ID']; $_SESSION["gw_user_en_type"] = $curUserInfo['en_type']; $resellerInfo = $curUserInfo; $companyInfo = $curUserInfo; // Phase out companyInfo } else { //$index = $_SESSION["gw_index"]; //if(!$index) $index = $config_default_index; //session_destroy(); //header("location:$index"); //exit(); } } if ($curUserInfo['en_access']) {
function add_new_merchant($companyInfo, $sendmail = true, $getmail = false) { $returnInfo = array('status' => true, 'msg' => 'Company Created Successfully'); //foreach($companyInfo as $key=>$data) // $companyInfo[$key] = quote_smart($data); $res = check_merchant_conflict($companyInfo); if (!$res['status']) { return $res; } if ($res['res']['ref']) { $companyInfo['en_ref'] = substr(strtoupper(md5(time() + rand(1, 1000000))), 0, 8); } $qry_insert_user = "******"; $qry_insert_user .= " values('" . $companyInfo['en_username'] . "','" . $companyInfo['en_password'] . "','" . $companyInfo['en_company'] . "','" . $companyInfo['en_ref'] . "','" . $companyInfo['en_email'] . "','" . $companyInfo['volumenumber'] . "',0,'" . $companyInfo['transaction_type'] . "','" . $companyInfo['how_about_us'] . "',NOW(),'" . $companyInfo['phonenumber'] . "','" . $companyInfo['contact_phone'] . "','" . $companyInfo['cd_contact_im'] . "','" . $companyInfo['en_gateway_ID'] . "','" . $companyInfo['url1'] . "','" . $companyInfo['cd_timezone'] . "')"; $show_sql = sql_query_write($qry_insert_user) or dieLog(mysql_error() . " ~ {$str_qry}"); $is_success = 0; $user_id = mysql_insert_id(); $user_reference_num = func_User_Ref_No($user_id); $is_success = func_update_single_field('cs_companydetails', 'ReferenceNumber', $user_reference_num, false, 'userId', $user_id); $sql = "Insert into cs_entities\r\n\t\t\tset \r\n\t\t\t\ten_username = '******'en_username'] . "',\r\n\t\t\t\ten_password = MD5('" . ($companyInfo['en_username'] . $companyInfo['en_password']) . "'),\r\n\t\t\t\ten_ref = '" . $companyInfo['en_ref'] . "',\r\n\t\t\t\ten_email = '" . $companyInfo['en_email'] . "',\r\n\t\t\t\ten_company = '" . $companyInfo['en_company'] . "',\r\n\t\t\t\ten_gateway_ID = '" . $companyInfo['en_gateway_ID'] . "',\r\n\t\t\t\ten_signup = NOW(),\r\n\t\t\t\ten_type = 'merchant',\r\n\t\t\t\ten_type_id = '" . quote_smart($user_id) . "'\r\n\t\t\t"; sql_query_write($sql) or dieLog(mysql_error() . " ~ {$str_qry}"); $en_ID = mysql_insert_id(); $returnInfo['en_ID'] = $en_ID; $sql = "insert into cs_company_banks set cb_en_ID = '{$en_ID}',bank_id=0;"; $result = sql_query_write($sql) or dieLog(mysql_error() . " ~ {$sql}"); $cb_ID = mysql_insert_id(); if ($companyInfo['etel_reseller_ref']) { $sql = "SELECT \r\n\t\t\t\ten_ID,en_info from cs_entities where\r\n\t\t\t\ten_ref = '" . $companyInfo['etel_reseller_ref'] . "'"; $result = sql_query_read($sql) or dieLog(mysql_error() . " ~ {$sql}"); $resellerInfo = mysql_fetch_assoc($result); $resellerInfo['en_info'] = etel_unserialize($resellerInfo['en_info']); $returnInfo['ea_affiliate_ID'] = $resellerInfo['en_ID']; set_affiliate($en_ID, $resellerInfo['en_ID'], 'Reseller', array('Disc_Markup' => $resellerInfo['en_info']['Reseller']['Default_Disc_Markup'], 'Trans_Markup' => $resellerInfo['en_info']['Reseller']['Default_Trans_Markup'])); } if ($companyInfo['etel_affiliate_ref']) { $sql = "SELECT \r\n\t\t\t\ten_ID from cs_entities where\r\n\t\t\t\ten_ref = '" . $companyInfo['etel_affiliate_ref'] . "'"; $result = sql_query_read($sql) or dieLog(mysql_error() . " ~ {$sql}"); $affiliateMerchantInfo = mysql_fetch_assoc($result); set_affiliate($affiliateMerchantInfo['en_ID'], $en_ID, 'Affiliate', array('Disc_Markup' => $companyInfo['discount_markup'], 'Trans_Markup' => $companyInfo['transaction_markup'])); } if ($sendmail || $getmail) { $emailData["email"] = $companyInfo['en_email']; $emailData["full_name"] = "Merchant"; $emailData["companyname"] = $companyInfo['en_company']; $emailData["username"] = $companyInfo['en_username']; $emailData["password"] = $companyInfo['en_password']; $emailData["Reference_ID"] = $companyInfo['en_ref']; $emailData["gateway_select"] = $companyInfo['en_gateway_ID']; $emailData['tmpl_custom_id'] = $companyInfo['en_gateway_ID']; $letterTempate = 'merchant_welcome_letter'; } if ($sendmail) { send_email_template($letterTempate, $emailData); } if ($getmail) { $returnInfo['email_info'] = get_email_template($letterTempate, $emailData); } return $returnInfo; }
function get_payouts($conditions, $entityId) { if (!is_array($conditions)) { return array('status' => false, 'msg' => 'Invalid Conditions'); } if (!$entityId) { return array('status' => false, 'msg' => 'Invalid Entity ID'); } if ($conditions['date_between']) { $where_sql .= " AND pa_date Between '" . quote_smart($conditions['date_between']['Start']) . "' AND '" . quote_smart($conditions['date_between']['End']) . "' "; } if ($conditions['pa_ID']) { $where_sql .= " AND pa_ID = '" . intval($conditions['pa_ID']) . "' "; } $sql = "Select pa.*,pt_amount as Amount, DATE_FORMAT(pa_date, '%Y-%m-%d') as ByDate\r\n\t\tfrom cs_profit_action as pa\r\n\t\tleft join cs_profit on pa_ID = pt_action_ID and pt_type = 'Payout'\r\n\t\tWHERE pa_type='Payout' and pa_en_ID = '{$entityId}' {$where_sql}\r\n\t\tORDER BY pa_date desc\t\r\n\t\t"; $result = sql_query_read($sql) or dieLog(mysql_error() . " ~ {$sql_rev}"); if (!mysql_num_rows($result)) { return array('status' => false, 'msg' => 'Could not get Transaction Profit Info'); } while ($row = mysql_fetch_assoc($result)) { $row['pa_info'] = etel_unserialize($row['pa_info']); $Payouts[$row['ByDate']] = $row; } return $Payouts; }
function etel_update_serialized_field($table, $field, $sql_conditions, $update) { if (!$table || !$sql_conditions || !$field) { return false; } if (!is_array($update)) { return false; } $sql = "select {$field} from {$table} where {$sql_conditions}"; $result = sql_query_read($sql) or dieLog(mysql_error() . " ~ {$sql}"); if (!mysql_num_rows($result)) { return false; } $info_ser = mysql_result($result, 0, 0); $info = etel_unserialize($info_ser); if ($info_ser && $info === false) { dieLog("Serialization Failure: {$info_ser} WHERE {$sql_conditions}"); } etel_add_array($info, $update); $new_ser = etel_serialize($info); if ($info_ser == $new_ser) { return array('info' => $info, 'updated' => false); } $sql = "update {$table} set {$field} = '" . mysql_real_escape_string($new_ser) . "' where {$sql_conditions}"; if (is_array($info)) { sql_query_write($sql) or dieLog(mysql_error() . " ~ {$sql}"); } else { return false; } return array('info' => $info, 'updated' => true); }