Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
- class deposit extends CI_Controller {
- /**
- *
- * Start
- * Create Date: 21 July, 2016
- * This controller to manage member's deposit page.
- * Created saravana kumar.
- * @see http://ihyip.com/admin/sitesettings/
- * Last Updated: 06 Jun, 2017
- * End
- *
- */
- public function __construct() {
- parent::__construct();
- $status = site_info('site_status');
- if($status!='on'){
- redirect('offline');
- }
- // user login only
- if($this->session->userdata('user_login') || $this->session->userdata('admin_login')) {
- // form validation library
- $this->load->library('form_validation');
- $this->load->model('packages_model');
- $this->load->model('finance_model');
- } else {
- $this->session->set_userdata('user_last_page', current_url());
- redirect('user/login');
- }
- }
- public function index()
- {
- $site_data = $this->common_model->GetSettingall('infobox');
- if($site_data) {
- foreach ($site_data as $row) {
- $this->data[$row->site_key] = $row->site_value;
- }
- } else {
- $site_data_default = $this->common_model->defaultlangSettingall('infobox');
- foreach ($site_data_default as $row) {
- $this->data[$row->site_key] = $row->site_value;
- }
- }
- $site_lang_data = $this->common_model->GetSiteSettings('site');
- if($site_lang_data){
- $site_data = array_merge($site_data, $site_lang_data);
- }
- foreach ($site_data as $row) {
- $this->data[$row->site_key] = $row->site_value;
- }
- $this->data['deposits'] = $this->common_model->Depositlist();
- $this->load->view('user/depositlist', $this->data);
- }
- public function makedeposit() {
- $site_data = $this->common_model->GetSettingall('infobox');
- if($site_data) {
- foreach ($site_data as $row) {
- $this->data[$row->site_key] = $row->site_value;
- }
- } else {
- $site_data_default = $this->common_model->defaultlangSettingall('infobox');
- foreach ($site_data_default as $row) {
- $this->data[$row->site_key] = $row->site_value;
- }
- }
- $site_lang_data = $this->common_model->GetSiteSettings('site');
- if($site_lang_data){
- $site_data = array_merge($site_data, $site_lang_data);
- }
- foreach ($site_data as $row) {
- $this->data[$row->site_key] = $row->site_value;
- }
- $user_data = $this->common_model->GetSettingall('user');
- foreach ($user_data as $row) {
- $this->data[$row->site_key] = $row->site_value;
- }
- $package_condition = "status = '1' AND is_delete = '0' AND closed = '0' ";
- $this->data['packages'] = $this->common_model->GetPackages($package_condition);
- $condition = "payment_key in('status') AND payment_value = 'on'";
- $this->data['payment_list'] = $this->common_model->GetPaymentsName($condition);
- $this->data['action'] = base_url().'makedeposit';
- // user make deposit
- if($this->input->post()) {
- $deposit_amt = $this->input->post('tokenamt');
- $reinvest = $this->input->post('reinvest');
- $amount=$this->input->post('amount');
- $payment=$this->input->post('payment');
- //check payment available
- $payment_id = $this->input->post('select_payment');
- $packageid = $this->input->post('select_package');
- /*echo $payment_id;*/
- /*if($payment_id=='1' || $payment_id=='3')
- {
- $amount=$amount;
- $btc_amount=$amount;
- $currency=$payment_id;
- }
- else if($payment_id=='2')
- {
- $btc_amount=$amount;
- $url = "https://api.cryptonator.com/api/ticker/btc-usd";
- $json = file_get_contents($url);
- $data_api = json_decode($json, TRUE);
- $data_amts=$data_api['ticker']['price'];
- $btc_amount=$data_amts*$amount;
- $currency='2';
- }*/
- if($payment=='1')
- {
- $amount=$amount;
- $btc_amount=$amount;
- $currency=$payment_id;
- }
- else if($payment=='2')
- {
- $btc_amount=$amount;
- $url = "https://api.cryptonator.com/api/ticker/btc-usd";
- $json = file_get_contents($url);
- $data_api = json_decode($json, TRUE);
- $data_amts=$data_api['ticker']['price'];
- $btc_amount=$data_amts*$amount;
- $currency='2';
- }
- else if($payment=='3')
- {
- $btc_amount=$amount;
- $url = "https://api.cryptonator.com/api/ticker/eth-usd";
- $json = file_get_contents($url);
- $data_api = json_decode($json, TRUE);
- $data_amts=$data_api['ticker']['price'];
- $btc_amount=$data_amts*$amount;
- $currency='3';
- }
- else if($payment=='4')
- {
- $btc_amount=$amount;
- $url = "https://free.currencyconverterapi.com/api/v5/convert?q=USD_MNT&compact=y";
- $json = file_get_contents($url);
- $data_api = json_decode($json, TRUE);
- $data_amts=$data_api['USD_MNT']['val'];
- $btc_amount=$data_amts*$amount;
- $currency='4';
- }
- /*echo $currency;
- exit;*/
- $package_data = $this->packages_model->GetPackage($packageid);
- $package_name = $package_data->package_name;
- $payment_data = $this->common_model->GetPayment($payment_id);
- // $plan_condition "packageid = ".$packageid." AND min_amount >= ".$deposit_amt." OR max_amount > ".$deposit_amt;
- // $plan_data = $this->common_model->DepositPlan($plan_condition);
- $plans = $this->packages_model->GetPlans($packageid);
- foreach ($plans as $plan) {
- if($plan->min_amount <= $deposit_amt && $plan->max_amount >= $deposit_amt && $deposit_amt > 0){
- $plan_data = $plan;
- $flag = TRUE;
- }
- }
- // $plan_data = $this->packages_model->DepositPlan($packageid,$deposit_amt);
- if(empty($flag)){
- foreach ($plans as $plan) {
- if($plan->min_amount <= $deposit_amt && $deposit_amt > 0) {
- $plan_data = $plan;
- }
- }
- }
- $plan_name = $plan_data->plan_name;
- if($package_data->periord_name=='daily'){
- $periord_name = 'Days';
- } elseif($package_data->periord_name=='hourly') {
- $periord_name = 'Hours';
- } elseif($package_data->periord_name=='monthly') {
- $periord_name = 'Months';
- } elseif($package_data->periord_name=='weekly') {
- $periord_name = 'Weeks';
- } elseif($package_data->periord_name=='yearly') {
- $periord_name = 'Years';
- } else {
- $periord_name = $package_data->periord_name;
- }
- if($payment_data) {
- $payment_name = $payment_data[0]->payment_name;
- $payment_id = $payment_data[0]->payment_id;
- $form_data['payment_name'] = $payment_name;
- $form_data['payment_id'] = $payment_id;
- $compound_rate = ($this->input->post('compound_rate')) ? $this->input->post('compound_rate') : '0';
- $flag=0;
- if($payment_id=='2')
- {
- $pay_mode=$payment_data[0]->payment_value;
- if($pay_mode=='block' || $pay_mode=='address')
- $flag=1;
- }
- if($payment_id=='20')
- {
- $flag=1;
- }
- $pending_deposit = array(
- "uusersid" => $this->session->userdata('uusersid'),
- 'planid' => $plan_data->planid,
- "amount" => $this->input->post('amount'),
- "btc_amount" => $btc_amount,
- "currency" =>$currency,
- "compound" => $this->input->post('tokenamt'),
- "compound_rate" => $compound_rate,
- "status" => "pending",
- "description" => 'Deposit Request',
- "invest_date" => '0000-00-00 00:00:00',
- 'mature_date' => '0000-00-00 00:00:00',
- "run_date" => '0000-00-00 00:00:00'
- );
- if(!$reinvest){
- $pending_deposit["payment_id"] = $payment_id;
- } else {
- $pending_deposit["payment_id"] = "0";
- }
- if($flag!='1')
- {
- $query_status = $this->db->insert('deposit',$pending_deposit);
- $depositid=$this->db->insert_id();
- $deposit_data['deposit_id'] = $depositid;
- }
- else
- {
- $deposit_data['deposit_id'] ='0';
- }
- if($reinvest){
- $userbalance = $this->myGatewaybalance();
- $form_data['reinvest'] = true;
- $form_data['action'] = base_url().'reinvest';
- $form_data['success_url'] = base_url().'user/deposit/success';
- $form_data['cancel_url'] = base_url().'user/deposit/cancel';
- $form_data['balance'] = $userbalance;
- } else {
- foreach ($payment_data as $row) {
- $form_data[$row->payment_key] = $row->payment_value;
- $form_data[$row->payment_key] = $row->payment_value;
- }
- $form_data['action'] = base_url().'user/deposit/success';
- $form_data['success_url'] = base_url().'user/deposit/success';
- $form_data['cancel_url'] = base_url().'user/deposit/cancel';
- $form_data['ipn_url'] = base_url().'ipn/payment/'.$payment_name;
- }
- $form_data['currency_unit'] = $currency;
- $this->data['form_payment'] = $form_data;
- $deposit_data['amount'] = $this->input->post('amount');
- $deposit_data['compound_rate'] = $compound_rate;
- $deposit_data['uusersid'] = $this->session->userdata('uusersid');
- $deposit_data['planid'] = $plan_data->planid;
- $deposit_data['currency_unit'] = $currency;
- $user = $this->common_model->GetUser($this->session->userdata('uusersid'));
- $deposit_data['username'] = $user->username;
- $deposit_data['package_name'] = $package_name;
- $deposit_data['plan_name'] = $plan_name;
- $deposit_data['rate'] = $plan_data->rate.'% '.ucfirst($package_data->periord_name);
- $deposit_data['duration'] = $package_data->duration.' '.ucfirst($periord_name);
- $deposit_data['description'] = $package_data->description;
- if($package_data->rtn_principal_status){
- $deposit_data['return_principal'] = $package_data->rtn_principal;
- }
- $this->data['form_deposit'] = $deposit_data;
- $this->load->view('user/deposit/summary', $this->data);
- } else {
- redirect('deposit');
- }
- } else {
- $this->load->view('user/deposit/makedeposit',$this->data);
- // redirect('user/deposit');
- }
- }
- public function bankwire() {
- if(isset($_POST) && count($_POST) > 0) {
- $uusersid = $this->input->post('uusersid');
- $amount = $this->input->post('amount');
- $payment_id = $this->input->post('payment_id');
- $currid = $this->input->post('currency_id');
- $depositid = $this->input->post('depositid');
- $planid = $this->input->post('planid');
- $plans_info = $this->packages_model->GetPlan($planid);
- $deposit_data = $this->Calculate_plan($planid, $depositid);
- $deposit_data["status"] = "pending";
- $deposit_data["description"] = "deposit request";
- $this->db->where('depositid', $depositid);
- $query_status = $this->db->update('deposit',$deposit_data);
- $trid = "TRAN".strtoupper(uniqid());
- $history_data = array(
- "uusersid" => $uusersid,
- "amount" => $amount,
- "type" => "deposit_req",
- "description" => 'deposit request',
- "date" => date("Y-m-d H:i:s"),
- "payment_id" => $payment_id,
- "transactionid" => $trid,
- "depositid" => $depositid,
- "currency"=>$currid
- );
- $query_status = $this->db->insert('history',$history_data);
- $user = $this->common_model->GetUser($uusersid);
- $payment_data = $this->common_model->GetPayment('12');
- foreach ($payment_data as $row)
- {
- $form_data[$row->payment_key] = $row->payment_value;
- /*print_r($form_data[$row->payment_key]);*/
- }
- // sent mail to user
- $subject = 'Investment Information';
- $mailid = '5';
- $mail_subject_data = $this->common_model->getMailTemplate($mailid);
- $message = str_replace('[FIRSTNAME]', $user->fullname, $mail_subject_data->message);
- $message = str_replace('[AMT]', $amount, $message);
- $message = str_replace('[PLAN]', $plans_info->plan_name, $message);
- $message = str_replace('[PAYMENT]', 'Bankwire', $message);
- $message = str_replace('[transid]', $trid, $message);
- $message = str_replace('#verfyurl', base_url(), $message);
- $message = str_replace('#adminemill', $mail_subject_data->from_mail, $message);
- $message = str_replace('#sitename', site_info_lang('site_name',$this->session->userdata('langid')), $message);
- if($mail_subject_data->status=='1'){
- $mail_status = $this->sendmail($user->email, $user->fullname, $subject, $message,$mail_subject_data->from_mail);
- }
- /*$this->data['success'] = $this->lang->line('lbl_payment_pending');*/
- $this->data['bank_payment'] = $form_data;
- $this->data['trans_id'] = $trid;
- $this->load->view('user/success',$this->data);
- // redirect('success');
- } else {
- redirect('');
- }
- }
- public function btc() {
- if(isset($_POST) && count($_POST) > 0) {
- $uusersid = $this->input->post('uusersid');
- $amount = $this->input->post('amount');
- $payment_id = $this->input->post('payment_id');
- $currid = $this->input->post('currency_id');
- $depositid = $this->input->post('depositid');
- $planid = $this->input->post('planid');
- $plans_info = $this->packages_model->GetPlan($planid);
- $deposit_data = $this->Calculate_plan($planid, $depositid);
- $deposit_data["status"] = "pending";
- $deposit_data["description"] = "deposit request";
- $this->db->where('depositid', $depositid);
- $query_status = $this->db->update('deposit',$deposit_data);
- $trid = "TRAN".strtoupper(uniqid());
- $history_data = array(
- "uusersid" => $uusersid,
- "amount" => $amount,
- "type" => "deposit_req",
- "description" => 'deposit request',
- "date" => date("Y-m-d H:i:s"),
- "payment_id" => $payment_id,
- "transactionid" => $trid,
- "depositid" => $depositid,
- "currency"=>$currid
- );
- $query_status = $this->db->insert('history',$history_data);
- $user = $this->common_model->GetUser($uusersid);
- $payment_data = $this->common_model->GetPayment('12');
- foreach ($payment_data as $row)
- {
- $form_data[$row->payment_key] = $row->payment_value;
- /*print_r($form_data[$row->payment_key]);*/
- }
- // sent mail to user
- $subject = 'Investment Information';
- $mailid = '5';
- $mail_subject_data = $this->common_model->getMailTemplate($mailid);
- $message = str_replace('[FIRSTNAME]', $user->fullname, $mail_subject_data->message);
- $message = str_replace('[AMT]', $amount, $message);
- $message = str_replace('[PLAN]', $plans_info->plan_name, $message);
- $message = str_replace('[PAYMENT]', 'Bitcon', $message);
- $message = str_replace('[transid]', $trid, $message);
- $message = str_replace('#verfyurl', base_url(), $message);
- $message = str_replace('#adminemill', $mail_subject_data->from_mail, $message);
- $message = str_replace('#sitename', site_info_lang('site_name',$this->session->userdata('langid')), $message);
- if($mail_subject_data->status=='1'){
- $mail_status = $this->sendmail($user->email, $user->fullname, $subject, $message,$mail_subject_data->from_mail);
- }
- /*$this->data['success'] = $this->lang->line('lbl_payment_pending');*/
- $this->load->view('user/success',$this->data);
- // redirect('success');
- } else {
- redirect('');
- }
- }
- public function block() {
- if(isset($_POST) && count($_POST) > 0) {
- /*$uusersid = $this->input->post('uusersid');
- //$uusersid=$this->session->userdata('uusersid');
- $amount = $this->input->post('amount');
- $btc_amount=$this->input->post('btc_amount');
- $pay_mode=$this->input->post('pay_mode');
- $payment_id = $this->input->post('payment_id');
- $pay_address=$this->input->post('pay_address');
- $depositid = $this->input->post('depositid');
- $planid = $this->input->post('planid');
- $plans_info = $this->packages_model->GetPlan($planid);
- $deposit_data = $this->Calculate_plan($planid, $depositid);
- $deposit_data["status"] = "pending";
- $deposit_data["description"] = "deposit request";
- $deposit_data["btc_amount"] = $btc_amount;
- $deposit_data["amount"]=$amount;
- $deposit_data["uusersid"]=$uusersid;
- $deposit_data["pay_mode"] = $pay_mode;
- $deposit_data["btc_address"] = $pay_address;
- $deposit_data["payment_id"]='2';
- $deposit_data["currency"]='2';
- $this->db->where('depositid', $depositid);
- //$query_status = $this->db->insert('deposit',$deposit_data);
- //$depositid = $this->db->insert_id();
- $trid = "TRAN".strtoupper(uniqid());
- $history_data = array(
- "uusersid" => $uusersid,
- "amount" => $amount,
- "type" => "deposit_req",
- "description" => 'deposit made',
- "date" => date("Y-m-d H:i:s"),
- "payment_id" => $payment_id,
- "transactionid" => $trid,
- "depositid" => $depositid
- );
- //$query_status = $this->db->insert('history',$history_data);
- $user = $this->common_model->GetUser($uusersid);
- //$this->db->query("update deposit_address set status='1',depositid='$depositid' where uuserid='$uusersid' and status='0'");
- // sent mail to user
- $subject = 'Investment Information';
- $mailid = '5';
- $mail_subject_data = $this->common_model->getMailTemplate($mailid);
- $message = str_replace('[FIRSTNAME]', $user->fullname, $mail_subject_data->message);
- $message = str_replace('[AMT]', $amount, $message);
- $message = str_replace('[PLAN]', $plans_info->plan_name, $message);
- $message = str_replace('[PAYMENT]', 'Bankwire', $message);
- $message = str_replace('[transid]', $trid, $message);
- $message = str_replace('#verfyurl', base_url(), $message);
- $message = str_replace('#adminemill', $mail_subject_data->from_mail, $message);
- $message = str_replace('#sitename', site_info_lang('site_name',$this->session->userdata('langid')), $message);
- if($mail_subject_data->status=='1'){
- //$mail_status = $this->sendmail($user->email, $user->fullname, $subject, $message);
- }
- // $this->data['success'] = 'Your Deposit made successfully';
- // $this->load->view('user/success',$this->data);*/
- $this->data['success'] = $this->lang->line('lbl_payment_pending');
- $this->load->view('user/success',$this->data);
- } else {
- redirect('');
- }
- }
- private function Calculate_plan($planid) {
- // $planid = $this->input->post('planid');
- $plans = $this->packages_model->GetPlan($planid);
- if($plans) {
- $packageid = $plans->packageid;
- $condition = "packageid = '".$packageid."'";
- $package_data = $this->common_model->GetRow('package',$condition);
- switch ($package_data->periord_id) {
- case '5':
- $add_date = "+1 hour";
- $periord_type = 'hour';
- break;
- case '1':
- $add_date = "+1 day";
- $periord_type = 'day';
- break;
- case '2':
- $add_date = "+7 days";
- $periord_type = 'days';
- break;
- case '3':
- $add_date = "+1 month";
- $periord_type = 'month';
- break;
- case '4':
- $add_date = "+1 year";
- $periord_type = 'year';
- break;
- case '6':
- $add_date = "+3 days";
- $periord_type = 'days';
- break;
- case '7':
- $period = "2 months";
- $diff = $months2;
- break;
- case '8':
- $period = "3 months";
- $diff = $months3;
- break;
- case '9':
- $period = "6 months";
- $diff = $months6;
- break;
- case '10':
- $period = $package_data->duration." days";
- $diff = $customdays;
- break;
- }
- if($package_data->duration){
- $invest_date = date("Y-m-d H:i:s");
- $date = $invest_date;
- $date = strtotime($date);
- $date = strtotime("+".$package_data->duration. " day" , $date);
- $mature_date = date('Y-m-d H:i:s', $date);
- }
- else {
- $invest_date = date("Y-m-d H:i:s");
- $mature_date = "0000-00-00 00:00:00";
- }
- $today = strtotime(date('Y-m-d H:i:s'));
- $date = strtotime($add_date, $today);
- $next_run_date = date('Y-m-d H:i:s', $date);
- $calc_data = array(
- "invest_date" => $invest_date,
- 'mature_date' => $mature_date,
- "run_date" => $next_run_date
- );
- return $calc_data;
- }
- }
- function reinvest() {
- if(isset($_POST) && count($_POST) > 0) {
- $uusersid = $this->input->post('uusersid');
- $amount = $this->input->post('amount');
- // $payment_id = $this->input->post('payment_id');
- $depositid = $this->input->post('depositid');
- $planid = $this->input->post('planid');
- $plans_info = $this->packages_model->GetPlan($planid);
- $deposit_data = $this->Calculate_plan($planid, $depositid);
- $deposit_data["status"] = "active";
- $deposit_data["description"] = "deposit made";
- $this->db->where('depositid', $depositid);
- $query_status = $this->db->update('deposit',$deposit_data);
- $trid = "TRAN".strtoupper(uniqid());
- $history_data = array(
- "uusersid" => $uusersid,
- "amount" => $amount,
- "type" => "reinvest",
- "description" => 'deposit made',
- "date" => date("Y-m-d H:i:s"),
- // "payment_id" => $payment_id,
- "transactionid" => $trid,
- "depositid" => $depositid
- );
- $query_status = $this->db->insert('history',$history_data);
- /* Update user rank */
- $dep_condition = "uusersid = '".$uusersid."' AND status='active'";
- $this->db->select_sum('amount');
- $this->db->where($dep_condition);
- $query = $this->db->get('deposit');
- if($query->row()){
- $total_deposit = $query->row();
- if($total_deposit){
- $turnover = $total_deposit->amount;
- /* Update user rank */
- $rankquery = $this->db->query("SELECT * FROM rank_controls WHERE turnover <= '".$turnover."' AND status='1' ORDER BY turnover DESC LIMIT 0,1");
- if($rankquery->row()) {
- $rank_data = $rankquery->row();
- $user_data = array(
- 'rankid' => $rank_data->rankid
- );
- $this->db->where('uusersid',$uusersid);
- $update_user = $this->db->update('uusers',$user_data);
- }
- }
- }
- /*$this->load->library('Commission');
- $comm = new commission();
- $this->commission->Commission_calc($uusersid);*/
- $user = $this->common_model->GetUser($uusersid);
- // sent mail to user
- $subject = 'Investment Information';
- $mailid = '5';
- $mail_subject_data = $this->common_model->getMailTemplate($mailid);
- $message = str_replace('[FIRSTNAME]', $user->fullname, $mail_subject_data->message);
- $message = str_replace('[AMT]', $amount, $message);
- $message = str_replace('[PLAN]', $plans_info->plan_name, $message);
- $message = str_replace('[PAYMENT]', 'Reinvest', $message);
- $message = str_replace('[transid]', $trid, $message);
- $message = str_replace('#verfyurl', base_url(), $message);
- $message = str_replace('#adminemill', $mail_subject_data->from_mail, $message);
- $message = str_replace('#sitename', site_info_lang('site_name',$this->session->userdata('langid')), $message);
- if($mail_subject_data->status=='1'){
- $mail_status = $this->sendmail($user->email, $user->fullname, $subject, $message,$mail_subject_data->from_mail);
- }
- // $this->data['success'] = 'Your Deposit made successfully';
- // $this->load->view('user/success',$this->data);
- redirect('success');
- } else {
- redirect('');
- }
- }
- function validamount()
- {
- $packageid = $this->input->post('packageid');
- if($packageid){
- $currency_info = defaultcurrency();
- // SELECT * FROM `plans` WHERE `packageid` ='1' AND `min_amount` <= 100 ORDER BY `min_amount` LIMIT 1
- $amount = number_format($this->input->post('amount'), $currency_info->deimal_point, '.', '');
- $planmin = $this->packages_model->GetMinamount($packageid);
- $planmax = $this->packages_model->GetMaxamount($packageid);
- $min = number_format($planmin->min_amount, $currency_info->deimal_point, '.', '');
- $max = number_format($planmax->max_amount, $currency_info->deimal_point, '.', '');
- // if($min <= $amount && $max >= $amount && $amount!=0) {
- if($min <= $amount && $amount!=0) {
- // if($min <= $amount) {
- $json['valid'] = true;
- } else {
- $json['valid'] = false;
- }
- } else {
- $json['valid'] = false;
- }
- echo json_encode($json);
- }
- function checkbalance(){
- // pr($this->session->userdata());
- $currency_info = defaultcurrency();
- // $gateway_id = $this->input->post('payment_id');
- // $this->db->select('payment_name');
- // $this->db->where('payment_id',$gateway_id);
- // $this->db->from('payment_controls');
- // $query = $this->db->get();
- // $payment_res = $query->row();
- // $payment_name = $payment_res->payment_name;
- $uusersid = ($this->session->userdata('uusersid')) ? $this->session->userdata('uusersid') : '3';
- $earnings_type = "'interest', 'commissions', 'bonus', 'fund_received', 'release_deposit'";
- $expenses_type = "'reinvest', 'withdrawal', 'withdraw_request', 'penalty', 'fund_send', 'withdraw_fee', 'transfer_fee'";
- // calculate user earnings
- // $condition = "uusersid = '".$uusersid."' AND payment_id = '".$gateway_id."' AND type IN (".$earnings_type.")";
- $condition = "uusersid = '".$uusersid."' AND type IN (".$earnings_type.")";
- $earnings = $this->common_model->GetEarnings('history',$condition);
- // echo "<br/>".$this->db->Last_query();
- // calculate user expenses
- // $condition1 = "uusersid = '".$uusersid."' AND payment_id = '".$gateway_id."' AND type IN (".$expenses_type.")";
- $condition1 = "uusersid = '".$uusersid."' AND type IN (".$expenses_type.")";
- $expenses = $this->common_model->GetEarnings('history',$condition1);
- // echo "<br/>".$this->db->Last_query();
- $Earnings = ($earnings->earnamt) ? $earnings->earnamt : '0';
- $Expenses = ($expenses->earnamt) ? $expenses->earnamt : '0' ;
- $AvailableBalance = $Earnings - $Expenses;
- if($AvailableBalance) {
- if($AvailableBalance < 0)
- {
- $user_avl_balance = 0;
- } else {
- $user_avl_balance = $AvailableBalance;
- }
- $json['success'] = true;
- // $json['payment'] = $payment_name;
- $json['balance'] = $currency_info->currency_symbol.''.number_format($user_avl_balance,$currency_info->deimal_point, '.', '').''.$currency_info->currency_unit;
- $json['raw_balance'] = number_format($AvailableBalance,$currency_info->deimal_point, '.', '');
- } else {
- $json['error'] = true;
- // $json['payment'] = $payment_name;
- $json['balance'] = $currency_info->currency_symbol.''.number_format(0,$currency_info->deimal_point, '.', '').''.$currency_info->currency_unit;
- $json['raw_balance'] = number_format(0,$currency_info->deimal_point, '.', '');
- }
- echo json_encode($json);
- }
- function myGatewaybalance(){
- $uusersid = $this->session->userdata('uusersid');
- $currency_info = defaultcurrency();
- $earnings_type = "'interest', 'commissions', 'bonus', 'fund_received', 'release_deposit'";
- $expenses_type = "'reinvest', 'withdrawal', 'withdraw_request', 'penalty', 'fund_send', 'withdraw_fee', 'transfer_fee'";
- // calculate user earnings
- $condition = "uusersid = '".$uusersid."' AND type IN (".$earnings_type.")";
- $earnings = $this->common_model->GetEarnings('history',$condition);
- // calculate user expenses
- $condition1 = "uusersid = '".$uusersid."' AND type IN (".$expenses_type.")";
- $expenses = $this->common_model->GetEarnings('history',$condition1);
- $Earnings = ($earnings->earnamt) ? $earnings->earnamt : '0';
- $Expenses = ($expenses->earnamt) ? $expenses->earnamt : '0' ;
- $AvailableBalance = $Earnings - $Expenses;
- return $AvailableBalance;
- }
- public function checkpackage($packageid) {
- $currency_info = defaultcurrency();
- $condition = "packageid ='" . $packageid . "'";
- // $json['compound'] = '';
- $this->db->where('packageid', $packageid);
- $this->db->select('compond_min, compond_max, from_balance');
- $this->db->from('package');
- $query = $this->db->get();
- if ($query->num_rows()>0) {
- $package = $query->row();
- if($package->compond_min!=$package->compond_max || $package->compond_max!=0) {
- $json['compound'] = '<h2>'.strtoupper($this->lang->line('lbl_compound_rate')).'</h2>
- <div class="nren">
- <div>
- <select name="compound_rate" class="bootstrap-select form-control">
- <option value="">'.$this->lang->line('none_selected').'</option>';
- $range = range($package->compond_min,$package->compond_max,5);
- foreach ($range as $cm) {
- $json['compound'] .= '<option value="'.$cm.'">'.$cm.'% </option>';
- }
- $json['compound'] .= '</select>
- </div>
- <div class="messageContainer"></div>
- </div>';
- }
- if($package->from_balance == '1') {
- $json['reinvest'] = TRUE;
- } else {
- $json['reinvest'] = FALSE;
- }
- echo json_encode($json);
- }
- }
- public function success() {
- if(isset($_POST) && count($_POST) > 0) {
- /*
- $customdata = explode(',', $_POST['custom']);
- $uusersid = $customdata[0];
- $depositid = $customdata[1];
- $deposits = $this->common_model->successDeposit($depositid);
- if($deposits) {
- if($deposits->duration){
- $invest_date = date("Y-m-d H:i:s");
- $date = $invest_date;
- $date = strtotime($date);
- $date = strtotime("+".$deposits->duration." day", $date);
- $mature_date = date('Y-m-d H:i:s', $date);
- }
- else {
- $invest_date = date("Y-m-d H:i:s");
- $mature_date = date("Y-m-d H:i:s");
- }
- switch ($deposits->periord_id) {
- case '5':
- $add_date = "+1 hour";
- break;
- case '1':
- $add_date = "+1 day";
- break;
- case '2':
- $add_date = "+7 days";
- break;
- case '3':
- $add_date = "+1 month";
- break;
- case '4':
- $add_date = "+1 year";
- break;
- }
- $today = strtotime(date('Y-m-d H:i:s'));
- $date = strtotime($add_date, $today);
- $next_run_date = date('Y-m-d H:i:s', $date);
- $deposit_data = array(
- "status" => "active",
- "description" => 'deposit made',
- "invest_date" => $invest_date,
- 'mature_date' => $mature_date,
- "run_date" => $next_run_date
- );
- $this->db->where('depositid', $depositid);
- $query_status = $this->db->update('deposit',$deposit_data);
- $depositid = $this->db->insert_id();
- $history_data = array(
- "uusersid" => $deposits->uusersid,
- "amount" => $deposits->amount,
- "type" => "deposit",
- "description" => 'deposit made',
- "date" => date("Y-m-d H:i:s"),
- "payment_id" => $deposits->payment_id,
- "transactionid" => "TRAN".strtoupper(uniqid()),
- "depositid" => $deposits->depositid
- );
- $query_status = $this->db->insert('history',$history_data);
- }
- */
- $this->data['success'] = $this->lang->line('lbl_payment_success');
- $this->load->view('user/success',$this->data);
- } else {
- $this->data['success'] = $this->lang->line('lbl_payment_success');
- $this->load->view('user/success',$this->data);
- }
- }
- public function success1() {
- if(isset($_POST) && count($_POST) > 0) {
- $this->data['success'] = $this->lang->line('lbl_payment_pending');
- $this->load->view('user/success',$this->data);
- } else {
- $this->data['success'] = $this->lang->line('lbl_payment_success');
- $this->load->view('user/success',$this->data);
- }
- }
- public function cancel() {
- $this->data['error'] = $this->lang->line('lbl_payment_fail');
- $this->load->view('user/cancel',$this->data);
- }
- public function Canceldeposit($id)
- {
- $myencrypt = new MyEncrypt;
- $depositid = $myencrypt->decode($id);
- $deposit_data = $this->common_model->getDepositData($depositid);
- if($deposit_data)
- {
- $return_amount = $deposit_data->amount * ($deposit_data->rtn_principal / 100 );
- $history_data = array(
- "uusersid" => $deposit_data->uusersid,
- "amount" => $return_amount,
- "type" => "release_deposit",
- "description" => "Close deposit from admin",
- "date" => date('Y-m-d H:i:s'),
- "payment_id" => $deposit_data->payment_id,
- "transactionid" => "TRAN".strtoupper(uniqid()),
- "depositid" => $deposit_data->depositid
- );
- $query_status = $this->db->insert('history',$history_data);
- $close_deposit_data = array(
- 'run_date' => date('Y-m-d H:i:s'),
- 'status' => "matured"
- );
- $this->db->where('depositid',$deposit_data->depositid);
- $query_status = $this->db->update('deposit',$close_deposit_data);
- if($query_status) {
- $this->session->set_flashdata('success_message', $this->lang->line('close_deposit_success_message'));
- redirect('user/deposit');
- } else {
- $this->session->set_flashdata('error_message', $this->lang->line('close_deposit_error_message'));
- redirect('user/deposit');
- }
- } else {
- $this->db->where('depositid', $depositid);
- $close_status = $this->db->delete('deposit');
- if($close_status) {
- $this->session->set_flashdata('success_message', $this->lang->line('close_deposit_success_message'));
- redirect('user/deposit');
- } else {
- $this->session->set_flashdata('error_message', $this->lang->line('close_deposit_error_message'));
- redirect('user/deposit');
- }
- }
- }
- public function Interestlist($id) {
- $currency_info = defaultcurrency();
- $myencrypt = new MyEncrypt;
- // $depositid = $myencrypt->decode($id);
- $depositid = '10';
- // $condition ="depositid = '".$depositid."' AND uusersid = '".$this->session->userdata('uusersid')."' AND type in ('interest', 'commissions')";
- $condition ="depositid = '".$depositid."' AND type in ('interest', 'commissions') ORDER BY `date` DESC";
- $interst_history = $this->common_model->GetResults('history',$condition);
- $table = '<div class="datatable"><table>';
- $table .= '<colgroup>
- <col width="35%">
- <col width="35%">
- <col width="30%">
- </colgroup>';
- $table .= '<tr>';
- $table .= '<th>'.$this->lang->line('trans_date').'</th>';
- $table .= '<th>'.$this->lang->line('transactionID').'</th>';
- $table .= '<th>'.$this->lang->line('trans_amnt').'</th>';
- // $table .= '<th>'.$this->lang->line('trans_descr').'</th>';
- $table .= '</tr>';
- if($interst_history)
- {
- foreach ($interst_history as $row)
- {
- $table .= '<tr>';
- $table .= '<td>'.$row->date.'</td>';
- $table .= '<td>'.$row->transactionid.'</td>';
- $table .= '<td>'.$currency_info->currency_symbol."".number_format($row->amount, $currency_info->deimal_point, '.', '').' '.strtoupper($currency_info->currency_unit).'</td>';
- // $table .= '<td>'.$row->description.'</td>';
- $table .= '</tr>';
- }
- }
- else
- {
- $table .= '<tr>';
- $table .= '<td colspan="4">'.$this->lang->line('lbl_no_records').'</td>';
- $table .= '</tr>';
- }
- $table .= '</table></div>';
- echo $table;
- }
- public function checkdeposit($id) {
- $currency_info = defaultcurrency();
- $myencrypt = new MyEncrypt;
- $depositid = $myencrypt->decode($id);
- $deposit = $this->common_model->getDepositData($depositid);
- $return_princ_amount = '0';
- if($deposit) {
- $deposit_amount = $deposit->amount;
- if($deposit->rtn_principal_status == '1') {
- $return_princ_amount = $deposit_amount * ($deposit->rtn_principal / 100);
- $loss_amount = $deposit_amount - $return_princ_amount;
- } else {
- $loss_amount = $deposit_amount - $return_princ_amount;
- }
- echo $currency_info->currency_symbol."".number_format($loss_amount, $currency_info->deimal_point, '.', '').' '.strtoupper($currency_info->currency_unit);
- }
- }
- public function checkearnings() {
- $currency_info = defaultcurrency();
- $packageid = $this->input->post('packageid');
- $deposit_amt = $this->input->post('amount');
- $condition="icoid = '1'";
- $coin = $this->common_model->GetRow('icoset',$condition);
- $json['totalcoinamnt'] = $coin->valuetoken;
- $package = $this->packages_model->GetPackage($packageid);
- if($package->periord_name=='daily'){
- $periord_name = 'Days';
- } elseif($package->periord_name=='hourly') {
- $periord_name = 'Hours';
- } elseif($package->periord_name=='monthly') {
- $periord_name = 'Months';
- } elseif($package->periord_name=='weekly') {
- $periord_name = 'Weeks';
- } elseif($package->periord_name=='yearly') {
- $periord_name = 'Years';
- } else {
- $periord_name = $package->periord_name;
- }
- $json['duration'] = $package->duration.' '.$periord_name;
- $plans = $this->packages_model->GetPlans($packageid);
- foreach ($plans as $plan) {
- // if($plan->min_amount <= $deposit_amt && $plan->max_amount >= $deposit_amt && $deposit_amt > 0){
- if($plan->min_amount <= $deposit_amt && $deposit_amt > 0){
- $plan_data = $plan;
- }
- }
- $json['plan_name'] = $plan_data->rate.'% '.$package->periord_name;
- $profit = 0;
- $compound = $this->input->post('compound_rate');
- if($compound) {
- for($i=1;$i<=$package->duration; $i++){
- $deposit_interest = $deposit_amt * ($plan_data->rate / 100);
- $compound_interest = $deposit_interest * ($compound / 100);
- $profit = $profit + ($deposit_interest - $compound_interest);
- $deposit_amt = $deposit_amt + $compound_interest;
- }
- } else {
- $profit = $deposit_amt * ($plan_data->rate / 100) * $package->duration;
- }
- // $json['profit'] = $currency_info->currency_symbol."".number_format($profit, $currency_info->deimal_point, '.', '');
- echo json_encode($json);
- }
- public function Cancelprocess() {
- $depositid = $this->input->post('depositid');
- $this->db->where('depositid', $depositid);
- $close_status = $this->db->delete('deposit');
- if($close_status) {
- echo '1';
- } else {
- echo '0';
- }
- }
- public function sendmail($useremail, $fullname, $subject, $message, $from_mail) {
- $this->load->library('My_PHPMailer');
- $condition = "settings_name = 'email'";
- $email_setting_data = $this->common_model->GetSettingall_lang($condition);
- foreach ($email_setting_data as $row) {
- $mail_data[$row->site_key] = $row->site_value;
- }
- if($mail_data['email_throw']=='php')
- {
- $mail = new PHPMailer();
- $mail->isMail();
- } else {
- $mail = new PHPMailer();
- $mail->IsSMTP();
- $mail->SMTPAuth = TRUE;
- $mail->SMTPSecure = $mail_data['smtp_type'];
- $mail->Host = $mail_data['smtp_hostname'];
- $mail->Port = $mail_data['smtp_portno'];
- $mail->Username = $mail_data['smtp_username'];
- $mail->Password = $mail_data['smtp_password'];
- }
- $mail->SetFrom($from_mail, site_info_lang('site_name',$this->session->userdata('langid')));
- $mail->AddReplyTo($from_mail,site_info_lang('site_name',$this->session->userdata('langid')));
- $message = str_replace('#adminemail', $from_mail, $message);
- $mail->Subject = $subject;
- $mail->msgHTML($message);
- $mail->AddAddress($useremail, $fullname);
- if(!$mail->Send()) {
- // return $mail->ErrorInfo;
- return false;
- } else {
- return true;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment