Samdan

Untitled

May 5th, 2018
259
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 40.58 KB | None | 0 0
  1. <?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
  2.  
  3. class deposit extends CI_Controller {
  4.  
  5.     /**
  6.     *
  7.     * Start
  8.     * Create Date: 21 July, 2016
  9.     * This controller to manage member's deposit page.
  10.     * Created saravana kumar.
  11.     * @see http://ihyip.com/admin/sitesettings/
  12.     * Last Updated: 06 Jun, 2017
  13.     * End
  14.     *
  15.     */
  16.  
  17.     public function __construct() {
  18.         parent::__construct();
  19.  
  20.         $status = site_info('site_status');
  21.         if($status!='on'){
  22.             redirect('offline');
  23.         }
  24.  
  25.         // user login only
  26.         if($this->session->userdata('user_login') || $this->session->userdata('admin_login')) {
  27.  
  28.             // form validation library
  29.             $this->load->library('form_validation');
  30.             $this->load->model('packages_model');
  31.             $this->load->model('finance_model');
  32.            
  33.         } else {
  34.             $this->session->set_userdata('user_last_page', current_url());
  35.             redirect('user/login');
  36.         }
  37.        
  38.     }
  39.    
  40.     public function index()
  41.     {
  42.         $site_data = $this->common_model->GetSettingall('infobox');
  43.  
  44.         if($site_data) {
  45.            
  46.             foreach ($site_data as $row) {
  47.                 $this->data[$row->site_key] = $row->site_value;
  48.             }
  49.  
  50.         } else {
  51.             $site_data_default = $this->common_model->defaultlangSettingall('infobox');
  52.             foreach ($site_data_default as $row) {
  53.                 $this->data[$row->site_key] = $row->site_value;
  54.             }
  55.         }
  56.  
  57.         $site_lang_data = $this->common_model->GetSiteSettings('site');
  58.        
  59.        
  60.         if($site_lang_data){   
  61.             $site_data = array_merge($site_data, $site_lang_data);
  62.         }
  63.  
  64.         foreach ($site_data as $row) {
  65.             $this->data[$row->site_key] = $row->site_value;
  66.         }
  67.  
  68.        
  69.         $this->data['deposits'] = $this->common_model->Depositlist();
  70.        
  71.         $this->load->view('user/depositlist', $this->data);
  72.        
  73.     }
  74.     public function makedeposit() {
  75.  
  76.         $site_data = $this->common_model->GetSettingall('infobox');
  77.  
  78.         if($site_data) {
  79.            
  80.             foreach ($site_data as $row) {
  81.                 $this->data[$row->site_key] = $row->site_value;
  82.             }
  83.  
  84.         } else {
  85.             $site_data_default = $this->common_model->defaultlangSettingall('infobox');
  86.             foreach ($site_data_default as $row) {
  87.                 $this->data[$row->site_key] = $row->site_value;
  88.             }
  89.         }
  90.  
  91.         $site_lang_data = $this->common_model->GetSiteSettings('site');
  92.        
  93.        
  94.         if($site_lang_data){   
  95.             $site_data = array_merge($site_data, $site_lang_data);
  96.         }
  97.  
  98.         foreach ($site_data as $row) {
  99.             $this->data[$row->site_key] = $row->site_value;
  100.         }
  101.        
  102.  
  103.         $user_data = $this->common_model->GetSettingall('user');
  104.        
  105.         foreach ($user_data as $row) {
  106.             $this->data[$row->site_key] = $row->site_value;
  107.         }
  108.        
  109.         $package_condition = "status = '1' AND is_delete = '0' AND closed = '0' ";
  110.         $this->data['packages'] = $this->common_model->GetPackages($package_condition);
  111.         $condition = "payment_key in('status') AND payment_value = 'on'";
  112.         $this->data['payment_list'] = $this->common_model->GetPaymentsName($condition);
  113.         $this->data['action'] = base_url().'makedeposit';
  114.  
  115.         // user make deposit
  116.         if($this->input->post()) {
  117.  
  118.             $deposit_amt = $this->input->post('tokenamt');
  119.             $reinvest = $this->input->post('reinvest');
  120.  
  121.             $amount=$this->input->post('amount');
  122.             $payment=$this->input->post('payment');
  123.  
  124.  
  125.             //check payment available
  126.  
  127.             $payment_id = $this->input->post('select_payment');
  128.             $packageid = $this->input->post('select_package');
  129.  
  130.             /*echo $payment_id;*/
  131.  
  132.             /*if($payment_id=='1' || $payment_id=='3')
  133.             {
  134.                 $amount=$amount;
  135.                 $btc_amount=$amount;
  136.                 $currency=$payment_id;
  137.             }
  138.             else if($payment_id=='2')
  139.             {
  140.                 $btc_amount=$amount;
  141.                 $url = "https://api.cryptonator.com/api/ticker/btc-usd";
  142.                 $json = file_get_contents($url);
  143.                 $data_api = json_decode($json, TRUE);
  144.                 $data_amts=$data_api['ticker']['price'];
  145.                 $btc_amount=$data_amts*$amount;
  146.                 $currency='2';
  147.             }*/
  148.            
  149.             if($payment=='1')
  150.             {
  151.                 $amount=$amount;
  152.                 $btc_amount=$amount;
  153.                 $currency=$payment_id;
  154.             }
  155.             else if($payment=='2')
  156.             {
  157.                 $btc_amount=$amount;
  158.                 $url = "https://api.cryptonator.com/api/ticker/btc-usd";
  159.                 $json = file_get_contents($url);
  160.                 $data_api = json_decode($json, TRUE);
  161.                 $data_amts=$data_api['ticker']['price'];
  162.                 $btc_amount=$data_amts*$amount;
  163.                 $currency='2';
  164.             }
  165.             else if($payment=='3')
  166.             {
  167.                 $btc_amount=$amount;
  168.                 $url = "https://api.cryptonator.com/api/ticker/eth-usd";
  169.                 $json = file_get_contents($url);
  170.                 $data_api = json_decode($json, TRUE);
  171.                 $data_amts=$data_api['ticker']['price'];
  172.                 $btc_amount=$data_amts*$amount;
  173.                 $currency='3';
  174.             }
  175.             else if($payment=='4')
  176.             {
  177.                 $btc_amount=$amount;
  178.                 $url = "https://free.currencyconverterapi.com/api/v5/convert?q=USD_MNT&compact=y";
  179.                 $json = file_get_contents($url);
  180.                 $data_api = json_decode($json, TRUE);
  181.                 $data_amts=$data_api['USD_MNT']['val'];
  182.                 $btc_amount=$data_amts*$amount;
  183.                 $currency='4';
  184.             }
  185.  
  186.             /*echo $currency;
  187.  
  188.             exit;*/
  189.        
  190.  
  191.             $package_data = $this->packages_model->GetPackage($packageid);
  192.            
  193.             $package_name = $package_data->package_name;
  194.  
  195.             $payment_data = $this->common_model->GetPayment($payment_id);
  196.  
  197.             // $plan_condition "packageid = ".$packageid." AND min_amount >= ".$deposit_amt."  OR max_amount > ".$deposit_amt;
  198.             // $plan_data = $this->common_model->DepositPlan($plan_condition);
  199.  
  200.             $plans = $this->packages_model->GetPlans($packageid);
  201.             foreach ($plans as $plan) {
  202.                 if($plan->min_amount <= $deposit_amt && $plan->max_amount >= $deposit_amt && $deposit_amt > 0){
  203.                     $plan_data = $plan;
  204.                     $flag = TRUE;
  205.                 }
  206.             }
  207.             // $plan_data = $this->packages_model->DepositPlan($packageid,$deposit_amt);
  208.  
  209.             if(empty($flag)){
  210.                 foreach ($plans as $plan) {
  211.                     if($plan->min_amount <= $deposit_amt && $deposit_amt > 0) {
  212.                         $plan_data = $plan;
  213.                     }
  214.                 }
  215.             }
  216.            
  217.             $plan_name = $plan_data->plan_name;
  218.  
  219.             if($package_data->periord_name=='daily'){
  220.                 $periord_name = 'Days';
  221.             } elseif($package_data->periord_name=='hourly') {
  222.                 $periord_name = 'Hours';
  223.             } elseif($package_data->periord_name=='monthly') {
  224.                 $periord_name = 'Months';
  225.             } elseif($package_data->periord_name=='weekly') {
  226.                 $periord_name = 'Weeks';
  227.             } elseif($package_data->periord_name=='yearly') {
  228.                 $periord_name = 'Years';
  229.             } else {
  230.                 $periord_name = $package_data->periord_name;
  231.             }
  232.  
  233.             if($payment_data) {
  234.  
  235.                 $payment_name = $payment_data[0]->payment_name;
  236.                 $payment_id = $payment_data[0]->payment_id;
  237.  
  238.                 $form_data['payment_name'] = $payment_name;
  239.                 $form_data['payment_id'] = $payment_id;
  240.                 $compound_rate = ($this->input->post('compound_rate')) ? $this->input->post('compound_rate') : '0';
  241.                 $flag=0;
  242.                 if($payment_id=='2')
  243.                 {
  244.                     $pay_mode=$payment_data[0]->payment_value;
  245.                     if($pay_mode=='block' || $pay_mode=='address')
  246.                         $flag=1;
  247.  
  248.                 }
  249.                 if($payment_id=='20')
  250.                 {
  251.                     $flag=1;
  252.                 }
  253.                
  254.                 $pending_deposit = array(
  255.                     "uusersid" => $this->session->userdata('uusersid'),
  256.                     'planid' => $plan_data->planid,
  257.                     "amount"    =>  $this->input->post('amount'),
  258.                     "btc_amount"    =>  $btc_amount,
  259.                     "currency"      =>$currency,
  260.                     "compound"  =>  $this->input->post('tokenamt'),
  261.                     "compound_rate" =>  $compound_rate,
  262.                     "status"   =>  "pending",
  263.                     "description" => 'Deposit Request',
  264.                     "invest_date"     =>  '0000-00-00 00:00:00',
  265.                     'mature_date' => '0000-00-00 00:00:00',
  266.                     "run_date"     =>  '0000-00-00 00:00:00'
  267.                 );
  268.                 if(!$reinvest){
  269.                     $pending_deposit["payment_id"]  =   $payment_id;
  270.                 } else {
  271.                     $pending_deposit["payment_id"]  =   "0";
  272.                 }
  273.                
  274.  
  275.  
  276.                 if($flag!='1')
  277.                 {
  278.                     $query_status = $this->db->insert('deposit',$pending_deposit);
  279.                     $depositid=$this->db->insert_id();
  280.                     $deposit_data['deposit_id'] = $depositid;
  281.                 }
  282.                 else
  283.                 {
  284.                     $deposit_data['deposit_id'] ='0';
  285.                 }
  286.        
  287.                 if($reinvest){
  288.                     $userbalance = $this->myGatewaybalance();
  289.  
  290.                     $form_data['reinvest'] = true;
  291.                     $form_data['action'] = base_url().'reinvest';
  292.                     $form_data['success_url'] = base_url().'user/deposit/success';
  293.                     $form_data['cancel_url'] = base_url().'user/deposit/cancel';
  294.                     $form_data['balance'] = $userbalance;
  295.  
  296.                 } else {
  297.  
  298.                     foreach ($payment_data as $row) {
  299.                         $form_data[$row->payment_key] = $row->payment_value;
  300.                         $form_data[$row->payment_key] = $row->payment_value;
  301.                     }
  302.                    
  303.                     $form_data['action'] = base_url().'user/deposit/success';
  304.                     $form_data['success_url'] = base_url().'user/deposit/success';
  305.                     $form_data['cancel_url'] = base_url().'user/deposit/cancel';
  306.                     $form_data['ipn_url'] = base_url().'ipn/payment/'.$payment_name;
  307.                 }
  308.  
  309.                 $form_data['currency_unit'] = $currency;
  310.                 $this->data['form_payment'] = $form_data;
  311.                
  312.  
  313.                 $deposit_data['amount'] = $this->input->post('amount');
  314.                 $deposit_data['compound_rate'] = $compound_rate;
  315.                 $deposit_data['uusersid'] = $this->session->userdata('uusersid');
  316.                 $deposit_data['planid'] = $plan_data->planid;
  317.                 $deposit_data['currency_unit'] = $currency;
  318.  
  319.                 $user = $this->common_model->GetUser($this->session->userdata('uusersid'));
  320.                 $deposit_data['username'] = $user->username;
  321.                 $deposit_data['package_name'] = $package_name;
  322.                 $deposit_data['plan_name'] = $plan_name;
  323.                 $deposit_data['rate'] = $plan_data->rate.'% '.ucfirst($package_data->periord_name);
  324.                 $deposit_data['duration'] = $package_data->duration.' '.ucfirst($periord_name);
  325.                 $deposit_data['description'] = $package_data->description;
  326.                 if($package_data->rtn_principal_status){
  327.                     $deposit_data['return_principal'] = $package_data->rtn_principal;
  328.                 }
  329.  
  330.                 $this->data['form_deposit'] = $deposit_data;
  331.  
  332.                 $this->load->view('user/deposit/summary', $this->data);
  333.             } else {
  334.                 redirect('deposit');
  335.             }
  336.         } else {
  337.             $this->load->view('user/deposit/makedeposit',$this->data);
  338.             // redirect('user/deposit');
  339.         }
  340.          
  341.     }
  342.  
  343.     public function bankwire() {
  344.  
  345.         if(isset($_POST) && count($_POST) > 0) {
  346.  
  347.             $uusersid = $this->input->post('uusersid');
  348.             $amount = $this->input->post('amount');
  349.             $payment_id = $this->input->post('payment_id');
  350.             $currid = $this->input->post('currency_id');
  351.  
  352.             $depositid = $this->input->post('depositid');
  353.             $planid = $this->input->post('planid');
  354.             $plans_info = $this->packages_model->GetPlan($planid);
  355.  
  356.             $deposit_data  = $this->Calculate_plan($planid, $depositid);
  357.            
  358.             $deposit_data["status"]   =  "pending";
  359.             $deposit_data["description"] = "deposit request";
  360.  
  361.             $this->db->where('depositid', $depositid);
  362.             $query_status = $this->db->update('deposit',$deposit_data);
  363.             $trid = "TRAN".strtoupper(uniqid());
  364.             $history_data = array(
  365.                 "uusersid" => $uusersid,
  366.                 "amount"    =>  $amount,
  367.                 "type"   =>  "deposit_req",
  368.                 "description" => 'deposit request',
  369.                 "date"     =>  date("Y-m-d H:i:s"),
  370.                 "payment_id"    =>  $payment_id,
  371.                 "transactionid" => $trid,
  372.                 "depositid" =>  $depositid,
  373.                 "currency"=>$currid
  374.             );
  375.            
  376.             $query_status = $this->db->insert('history',$history_data);
  377.  
  378.             $user = $this->common_model->GetUser($uusersid);
  379.  
  380.             $payment_data = $this->common_model->GetPayment('12');
  381.                
  382.             foreach ($payment_data as $row)
  383.             {
  384.                 $form_data[$row->payment_key] = $row->payment_value;
  385.                 /*print_r($form_data[$row->payment_key]);*/
  386.             }
  387.            
  388.             // sent mail to user
  389.             $subject = 'Investment Information';
  390.             $mailid = '5';
  391.             $mail_subject_data = $this->common_model->getMailTemplate($mailid);
  392.             $message  = str_replace('[FIRSTNAME]', $user->fullname, $mail_subject_data->message);
  393.             $message  = str_replace('[AMT]', $amount, $message);
  394.             $message  = str_replace('[PLAN]', $plans_info->plan_name, $message);
  395.             $message  = str_replace('[PAYMENT]', 'Bankwire', $message);
  396.             $message  = str_replace('[transid]', $trid, $message);
  397.             $message  = str_replace('#verfyurl', base_url(), $message);
  398.             $message  = str_replace('#adminemill', $mail_subject_data->from_mail, $message);
  399.             $message  = str_replace('#sitename', site_info_lang('site_name',$this->session->userdata('langid')), $message);
  400.  
  401.             if($mail_subject_data->status=='1'){
  402.  
  403.             $mail_status = $this->sendmail($user->email, $user->fullname, $subject, $message,$mail_subject_data->from_mail);
  404.  
  405.             }
  406.            
  407.             /*$this->data['success'] = $this->lang->line('lbl_payment_pending');*/
  408.             $this->data['bank_payment'] = $form_data;
  409.  
  410.             $this->data['trans_id'] = $trid;
  411.            
  412.             $this->load->view('user/success',$this->data);
  413.             // redirect('success');
  414.  
  415.         } else {
  416.             redirect('');
  417.         }
  418.     }
  419. public function btc() {
  420.  
  421.         if(isset($_POST) && count($_POST) > 0) {
  422.  
  423.             $uusersid = $this->input->post('uusersid');
  424.             $amount = $this->input->post('amount');
  425.             $payment_id = $this->input->post('payment_id');
  426.             $currid = $this->input->post('currency_id');
  427.  
  428.             $depositid = $this->input->post('depositid');
  429.             $planid = $this->input->post('planid');
  430.             $plans_info = $this->packages_model->GetPlan($planid);
  431.  
  432.             $deposit_data  = $this->Calculate_plan($planid, $depositid);
  433.            
  434.             $deposit_data["status"]   =  "pending";
  435.             $deposit_data["description"] = "deposit request";
  436.  
  437.             $this->db->where('depositid', $depositid);
  438.             $query_status = $this->db->update('deposit',$deposit_data);
  439.             $trid = "TRAN".strtoupper(uniqid());
  440.             $history_data = array(
  441.                 "uusersid" => $uusersid,
  442.                 "amount"    =>  $amount,
  443.                 "type"   =>  "deposit_req",
  444.                 "description" => 'deposit request',
  445.                 "date"     =>  date("Y-m-d H:i:s"),
  446.                 "payment_id"    =>  $payment_id,
  447.                 "transactionid" => $trid,
  448.                 "depositid" =>  $depositid,
  449.                 "currency"=>$currid
  450.             );
  451.            
  452.             $query_status = $this->db->insert('history',$history_data);
  453.  
  454.             $user = $this->common_model->GetUser($uusersid);
  455.  
  456.             $payment_data = $this->common_model->GetPayment('12');
  457.                
  458.             foreach ($payment_data as $row)
  459.             {
  460.                 $form_data[$row->payment_key] = $row->payment_value;
  461.                 /*print_r($form_data[$row->payment_key]);*/
  462.             }
  463.            
  464.             // sent mail to user
  465.             $subject = 'Investment Information';
  466.             $mailid = '5';
  467.             $mail_subject_data = $this->common_model->getMailTemplate($mailid);
  468.             $message  = str_replace('[FIRSTNAME]', $user->fullname, $mail_subject_data->message);
  469.             $message  = str_replace('[AMT]', $amount, $message);
  470.             $message  = str_replace('[PLAN]', $plans_info->plan_name, $message);
  471.             $message  = str_replace('[PAYMENT]', 'Bitcon', $message);
  472.             $message  = str_replace('[transid]', $trid, $message);
  473.             $message  = str_replace('#verfyurl', base_url(), $message);
  474.             $message  = str_replace('#adminemill', $mail_subject_data->from_mail, $message);
  475.             $message  = str_replace('#sitename', site_info_lang('site_name',$this->session->userdata('langid')), $message);
  476.  
  477.             if($mail_subject_data->status=='1'){
  478.  
  479.             $mail_status = $this->sendmail($user->email, $user->fullname, $subject, $message,$mail_subject_data->from_mail);
  480.  
  481.             }
  482.            
  483.             /*$this->data['success'] = $this->lang->line('lbl_payment_pending');*/
  484.  
  485.             $this->load->view('user/success',$this->data);
  486.             // redirect('success');
  487.  
  488.         } else {
  489.             redirect('');
  490.         }
  491.     }
  492.  
  493.  
  494.     public function block() {
  495.  
  496.         if(isset($_POST) && count($_POST) > 0) {
  497.  
  498.            
  499.  
  500.             /*$uusersid = $this->input->post('uusersid');
  501.             //$uusersid=$this->session->userdata('uusersid');
  502.             $amount = $this->input->post('amount');
  503.             $btc_amount=$this->input->post('btc_amount');
  504.             $pay_mode=$this->input->post('pay_mode');
  505.             $payment_id = $this->input->post('payment_id');
  506.             $pay_address=$this->input->post('pay_address');
  507.  
  508.             $depositid = $this->input->post('depositid');
  509.             $planid = $this->input->post('planid');
  510.             $plans_info = $this->packages_model->GetPlan($planid);
  511.  
  512.             $deposit_data  = $this->Calculate_plan($planid, $depositid);
  513.            
  514.             $deposit_data["status"]   =  "pending";
  515.             $deposit_data["description"] = "deposit request";
  516.             $deposit_data["btc_amount"] = $btc_amount;
  517.             $deposit_data["amount"]=$amount;
  518.             $deposit_data["uusersid"]=$uusersid;
  519.             $deposit_data["pay_mode"] = $pay_mode;
  520.             $deposit_data["btc_address"] = $pay_address;
  521.             $deposit_data["payment_id"]='2';
  522.             $deposit_data["currency"]='2';
  523.  
  524.  
  525.  
  526.             $this->db->where('depositid', $depositid);
  527.             //$query_status = $this->db->insert('deposit',$deposit_data);
  528.             //$depositid = $this->db->insert_id();
  529.  
  530.  
  531.             $trid = "TRAN".strtoupper(uniqid());
  532.             $history_data = array(
  533.                 "uusersid" => $uusersid,
  534.                 "amount"    =>  $amount,
  535.                 "type"   =>  "deposit_req",
  536.                 "description" => 'deposit made',
  537.                 "date"     =>  date("Y-m-d H:i:s"),
  538.                 "payment_id"    =>  $payment_id,
  539.                 "transactionid" => $trid,
  540.                 "depositid" =>  $depositid
  541.             );
  542.            
  543.             //$query_status = $this->db->insert('history',$history_data);
  544.  
  545.             $user = $this->common_model->GetUser($uusersid);
  546.  
  547.            
  548.             //$this->db->query("update deposit_address set status='1',depositid='$depositid' where uuserid='$uusersid' and status='0'");
  549.             // sent mail to user
  550.             $subject = 'Investment Information';
  551.             $mailid = '5';
  552.             $mail_subject_data = $this->common_model->getMailTemplate($mailid);
  553.             $message  = str_replace('[FIRSTNAME]', $user->fullname, $mail_subject_data->message);
  554.             $message  = str_replace('[AMT]', $amount, $message);
  555.             $message  = str_replace('[PLAN]', $plans_info->plan_name, $message);
  556.             $message  = str_replace('[PAYMENT]', 'Bankwire', $message);
  557.             $message  = str_replace('[transid]', $trid, $message);
  558.             $message  = str_replace('#verfyurl', base_url(), $message);
  559.             $message  = str_replace('#adminemill', $mail_subject_data->from_mail, $message);
  560.             $message  = str_replace('#sitename', site_info_lang('site_name',$this->session->userdata('langid')), $message);
  561.  
  562.             if($mail_subject_data->status=='1'){
  563.  
  564.             //$mail_status = $this->sendmail($user->email, $user->fullname, $subject, $message);
  565.  
  566.             }
  567.            
  568.             // $this->data['success'] =  'Your Deposit made successfully';
  569.             // $this->load->view('user/success',$this->data);*/
  570.  
  571.             $this->data['success'] =  $this->lang->line('lbl_payment_pending');
  572.             $this->load->view('user/success',$this->data);
  573.  
  574.         } else {
  575.             redirect('');
  576.         }
  577.     }
  578.  
  579.  
  580.     private function Calculate_plan($planid) {
  581.  
  582.         // $planid = $this->input->post('planid');
  583.         $plans = $this->packages_model->GetPlan($planid);
  584.  
  585.         if($plans) {
  586.  
  587.             $packageid = $plans->packageid;
  588.  
  589.             $condition = "packageid = '".$packageid."'";
  590.             $package_data = $this->common_model->GetRow('package',$condition);
  591.            
  592.             switch ($package_data->periord_id) {
  593.                 case '5':
  594.                     $add_date = "+1 hour";
  595.                     $periord_type = 'hour';
  596.                     break;
  597.                 case '1':
  598.                     $add_date = "+1 day";
  599.                     $periord_type = 'day';
  600.                     break;
  601.                 case '2':
  602.                     $add_date = "+7 days";
  603.                     $periord_type = 'days';
  604.                     break;
  605.                 case '3':
  606.                     $add_date = "+1 month";
  607.                     $periord_type = 'month';
  608.                     break;
  609.                 case '4':
  610.                     $add_date = "+1 year";
  611.                     $periord_type = 'year';
  612.                     break;
  613.                 case '6':
  614.                     $add_date = "+3 days";
  615.                     $periord_type = 'days';
  616.                     break;
  617.                 case '7':
  618.                     $period = "2 months";
  619.                     $diff = $months2;
  620.                     break;
  621.                 case '8':
  622.                     $period = "3 months";
  623.                     $diff = $months3;
  624.                     break;
  625.                 case '9':
  626.                     $period = "6 months";
  627.                     $diff = $months6;
  628.                     break;
  629.                 case '10':
  630.                     $period = $package_data->duration." days";
  631.                     $diff = $customdays;
  632.                     break;
  633.             }
  634.  
  635.             if($package_data->duration){
  636.                
  637.                 $invest_date = date("Y-m-d H:i:s");
  638.                 $date = $invest_date;
  639.                 $date = strtotime($date);
  640.                 $date = strtotime("+".$package_data->duration. " day" , $date);
  641.                 $mature_date = date('Y-m-d H:i:s', $date);
  642.             }
  643.             else {
  644.                 $invest_date = date("Y-m-d H:i:s");
  645.                 $mature_date = "0000-00-00 00:00:00";
  646.             }
  647.  
  648.             $today = strtotime(date('Y-m-d H:i:s'));
  649.             $date = strtotime($add_date, $today);
  650.             $next_run_date = date('Y-m-d H:i:s', $date);
  651.  
  652.             $calc_data = array(
  653.                 "invest_date"     =>  $invest_date,
  654.                 'mature_date' => $mature_date,
  655.                 "run_date"     =>  $next_run_date
  656.             );
  657.             return $calc_data;
  658.         }
  659.     }
  660.  
  661.     function reinvest() {
  662.  
  663.         if(isset($_POST) && count($_POST) > 0) {
  664.  
  665.             $uusersid = $this->input->post('uusersid');
  666.             $amount = $this->input->post('amount');
  667.             // $payment_id = $this->input->post('payment_id');
  668.  
  669.             $depositid = $this->input->post('depositid');
  670.             $planid = $this->input->post('planid');
  671.             $plans_info = $this->packages_model->GetPlan($planid);
  672.            
  673.             $deposit_data  = $this->Calculate_plan($planid, $depositid);
  674.  
  675.             $deposit_data["status"]   =  "active";
  676.             $deposit_data["description"] = "deposit made";
  677.             $this->db->where('depositid', $depositid);
  678.             $query_status = $this->db->update('deposit',$deposit_data);
  679.             $trid = "TRAN".strtoupper(uniqid());
  680.             $history_data = array(
  681.                 "uusersid" => $uusersid,
  682.                 "amount"    =>  $amount,
  683.                 "type"   =>  "reinvest",
  684.                 "description" => 'deposit made',
  685.                 "date"     =>  date("Y-m-d H:i:s"),
  686.                 // "payment_id" =>  $payment_id,
  687.                 "transactionid" => $trid,
  688.                 "depositid" =>  $depositid
  689.             );
  690.            
  691.             $query_status = $this->db->insert('history',$history_data);
  692.  
  693.             /* Update user rank */
  694.  
  695.             $dep_condition = "uusersid = '".$uusersid."' AND status='active'";
  696.             $this->db->select_sum('amount');
  697.             $this->db->where($dep_condition);
  698.             $query = $this->db->get('deposit');
  699.             if($query->row()){
  700.                 $total_deposit = $query->row();
  701.                 if($total_deposit){
  702.                     $turnover = $total_deposit->amount;
  703.                    
  704.                     /* Update user rank */
  705.                     $rankquery = $this->db->query("SELECT * FROM rank_controls WHERE turnover <= '".$turnover."' AND status='1' ORDER BY turnover DESC LIMIT 0,1");
  706.                     if($rankquery->row()) {
  707.                         $rank_data = $rankquery->row();
  708.                         $user_data = array(
  709.                             'rankid' => $rank_data->rankid
  710.                         );
  711.                         $this->db->where('uusersid',$uusersid);
  712.                         $update_user = $this->db->update('uusers',$user_data);
  713.                     }
  714.  
  715.                 }
  716.             }
  717.  
  718.             /*$this->load->library('Commission');
  719.             $comm = new commission();
  720.             $this->commission->Commission_calc($uusersid);*/
  721.  
  722.             $user = $this->common_model->GetUser($uusersid);
  723.  
  724.             // sent mail to user
  725.             $subject = 'Investment Information';
  726.             $mailid = '5';
  727.             $mail_subject_data = $this->common_model->getMailTemplate($mailid);
  728.             $message  = str_replace('[FIRSTNAME]', $user->fullname, $mail_subject_data->message);
  729.             $message  = str_replace('[AMT]', $amount, $message);
  730.             $message  = str_replace('[PLAN]', $plans_info->plan_name, $message);
  731.             $message  = str_replace('[PAYMENT]', 'Reinvest', $message);
  732.             $message  = str_replace('[transid]', $trid, $message);
  733.             $message  = str_replace('#verfyurl', base_url(), $message);
  734.             $message  = str_replace('#adminemill', $mail_subject_data->from_mail, $message);
  735.             $message  = str_replace('#sitename', site_info_lang('site_name',$this->session->userdata('langid')), $message);
  736.            
  737.             if($mail_subject_data->status=='1'){
  738.  
  739.             $mail_status = $this->sendmail($user->email, $user->fullname, $subject, $message,$mail_subject_data->from_mail);
  740.             }
  741.            
  742.             // $this->data['success'] =  'Your Deposit made successfully';
  743.             // $this->load->view('user/success',$this->data);
  744.             redirect('success');
  745.  
  746.         } else {
  747.             redirect('');
  748.         }
  749.     }
  750.  
  751.     function validamount()
  752.     {
  753.         $packageid = $this->input->post('packageid');
  754.  
  755.         if($packageid){
  756.             $currency_info = defaultcurrency();
  757.             // SELECT * FROM `plans` WHERE `packageid` ='1' AND `min_amount` <= 100 ORDER BY `min_amount` LIMIT 1
  758.             $amount = number_format($this->input->post('amount'), $currency_info->deimal_point, '.', '');
  759.  
  760.             $planmin = $this->packages_model->GetMinamount($packageid);
  761.             $planmax = $this->packages_model->GetMaxamount($packageid);
  762.  
  763.             $min = number_format($planmin->min_amount, $currency_info->deimal_point, '.', '');
  764.             $max = number_format($planmax->max_amount, $currency_info->deimal_point, '.', '');
  765.  
  766.             // if($min <= $amount && $max >= $amount && $amount!=0) {
  767.             if($min <= $amount && $amount!=0) {
  768.             // if($min <= $amount) {
  769.                 $json['valid'] = true;
  770.             } else {
  771.                 $json['valid'] = false;
  772.             }
  773.  
  774.         } else {
  775.             $json['valid'] = false;
  776.         }
  777.         echo json_encode($json);
  778.     }
  779.  
  780.     function checkbalance(){
  781.         // pr($this->session->userdata());
  782.  
  783.         $currency_info = defaultcurrency();
  784.  
  785.         // $gateway_id = $this->input->post('payment_id');
  786.  
  787.         // $this->db->select('payment_name');
  788.         // $this->db->where('payment_id',$gateway_id);
  789.         // $this->db->from('payment_controls');
  790.         // $query = $this->db->get();
  791.         // $payment_res = $query->row();
  792.         // $payment_name = $payment_res->payment_name;
  793.  
  794.         $uusersid  = ($this->session->userdata('uusersid')) ? $this->session->userdata('uusersid') : '3';
  795.  
  796.         $earnings_type  = "'interest', 'commissions', 'bonus', 'fund_received', 'release_deposit'";
  797.         $expenses_type  = "'reinvest', 'withdrawal', 'withdraw_request', 'penalty', 'fund_send', 'withdraw_fee', 'transfer_fee'";
  798.  
  799.         // calculate user earnings
  800.         // $condition = "uusersid = '".$uusersid."' AND  payment_id = '".$gateway_id."' AND type IN (".$earnings_type.")";
  801.         $condition = "uusersid = '".$uusersid."' AND  type IN (".$earnings_type.")";
  802.         $earnings = $this->common_model->GetEarnings('history',$condition);
  803.         // echo "<br/>".$this->db->Last_query();
  804.         // calculate user expenses
  805.         // $condition1 = "uusersid = '".$uusersid."' AND  payment_id = '".$gateway_id."' AND type IN (".$expenses_type.")";
  806.         $condition1 = "uusersid = '".$uusersid."' AND type IN (".$expenses_type.")";
  807.        
  808.         $expenses = $this->common_model->GetEarnings('history',$condition1);
  809.         // echo "<br/>".$this->db->Last_query();
  810.  
  811.         $Earnings = ($earnings->earnamt) ? $earnings->earnamt : '0';
  812.         $Expenses = ($expenses->earnamt) ? $expenses->earnamt : '0' ;
  813.         $AvailableBalance = $Earnings - $Expenses;
  814.        
  815.         if($AvailableBalance) {
  816.             if($AvailableBalance < 0)
  817.             {
  818.                 $user_avl_balance = 0;
  819.             } else {
  820.                 $user_avl_balance = $AvailableBalance;
  821.             }
  822.             $json['success'] = true;
  823.             // $json['payment'] = $payment_name;
  824.             $json['balance'] = $currency_info->currency_symbol.''.number_format($user_avl_balance,$currency_info->deimal_point, '.', '').''.$currency_info->currency_unit;
  825.             $json['raw_balance'] = number_format($AvailableBalance,$currency_info->deimal_point, '.', '');
  826.        
  827.         } else {
  828.             $json['error'] = true;
  829.             // $json['payment'] = $payment_name;
  830.             $json['balance'] = $currency_info->currency_symbol.''.number_format(0,$currency_info->deimal_point, '.', '').''.$currency_info->currency_unit;
  831.             $json['raw_balance'] = number_format(0,$currency_info->deimal_point, '.', '');
  832.         }
  833.  
  834.         echo json_encode($json);
  835.  
  836.     }
  837.  
  838.     function myGatewaybalance(){
  839.            
  840.         $uusersid  = $this->session->userdata('uusersid');
  841.         $currency_info = defaultcurrency();
  842.         $earnings_type  = "'interest', 'commissions', 'bonus', 'fund_received', 'release_deposit'";
  843.         $expenses_type  = "'reinvest', 'withdrawal', 'withdraw_request', 'penalty', 'fund_send', 'withdraw_fee', 'transfer_fee'";
  844.  
  845.         // calculate user earnings
  846.         $condition = "uusersid = '".$uusersid."' AND type IN (".$earnings_type.")";
  847.         $earnings = $this->common_model->GetEarnings('history',$condition);
  848.  
  849.         // calculate user expenses
  850.         $condition1 = "uusersid = '".$uusersid."' AND type IN (".$expenses_type.")";
  851.        
  852.         $expenses = $this->common_model->GetEarnings('history',$condition1);
  853.  
  854.         $Earnings = ($earnings->earnamt) ? $earnings->earnamt : '0';
  855.         $Expenses = ($expenses->earnamt) ? $expenses->earnamt : '0' ;
  856.         $AvailableBalance = $Earnings - $Expenses;
  857.         return $AvailableBalance;
  858.            
  859.        
  860.     }
  861.  
  862.     public function checkpackage($packageid) {
  863.        
  864.         $currency_info = defaultcurrency();
  865.  
  866.         $condition = "packageid ='" . $packageid . "'";
  867.  
  868.         // $json['compound'] = '';
  869.        
  870.         $this->db->where('packageid', $packageid);
  871.         $this->db->select('compond_min, compond_max, from_balance');
  872.         $this->db->from('package');
  873.        
  874.         $query = $this->db->get();
  875.         if ($query->num_rows()>0) {
  876.             $package =  $query->row();
  877.            
  878.             if($package->compond_min!=$package->compond_max || $package->compond_max!=0) {
  879.                
  880.                 $json['compound']  = '<h2>'.strtoupper($this->lang->line('lbl_compound_rate')).'</h2>
  881.                             <div class="nren">
  882.                                 <div>
  883.                                     <select name="compound_rate" class="bootstrap-select form-control">
  884.                                     <option value="">'.$this->lang->line('none_selected').'</option>';
  885.            
  886.                                     $range = range($package->compond_min,$package->compond_max,5);
  887.                                     foreach ($range as $cm) {
  888.                                         $json['compound']  .= '<option value="'.$cm.'">'.$cm.'% </option>';
  889.                                     }
  890.                    
  891.                                 $json['compound'] .= '</select>
  892.                             </div>
  893.                             <div class="messageContainer"></div>
  894.                         </div>';
  895.                    
  896.             }
  897.  
  898.             if($package->from_balance == '1') {
  899.                 $json['reinvest'] = TRUE;
  900.             } else {
  901.                 $json['reinvest'] = FALSE;
  902.             }
  903.             echo  json_encode($json);
  904.            
  905.         }
  906.     }
  907.  
  908.     public function success() {
  909.  
  910.         if(isset($_POST) && count($_POST) > 0) {
  911.            
  912.             /*
  913.             $customdata = explode(',', $_POST['custom']);
  914.             $uusersid = $customdata[0];
  915.             $depositid = $customdata[1];
  916.  
  917.             $deposits = $this->common_model->successDeposit($depositid);
  918.            
  919.             if($deposits) {
  920.            
  921.                 if($deposits->duration){
  922.                    
  923.                     $invest_date = date("Y-m-d H:i:s");
  924.                     $date = $invest_date;
  925.                     $date = strtotime($date);
  926.                     $date = strtotime("+".$deposits->duration." day", $date);
  927.                     $mature_date = date('Y-m-d H:i:s', $date);
  928.                 }
  929.                 else {
  930.                     $invest_date = date("Y-m-d H:i:s");
  931.                     $mature_date = date("Y-m-d H:i:s");
  932.                 }
  933.  
  934.                 switch ($deposits->periord_id) {
  935.                     case '5':
  936.                         $add_date = "+1 hour";
  937.                         break;
  938.                     case '1':
  939.                         $add_date = "+1 day";
  940.                         break;
  941.                     case '2':
  942.                         $add_date = "+7 days";
  943.                         break;
  944.                     case '3':
  945.                         $add_date = "+1 month";
  946.                         break;
  947.                     case '4':
  948.                         $add_date = "+1 year";
  949.                         break;
  950.                 }
  951.  
  952.                 $today = strtotime(date('Y-m-d H:i:s'));
  953.                 $date = strtotime($add_date, $today);
  954.                 $next_run_date = date('Y-m-d H:i:s', $date);
  955.  
  956.                 $deposit_data = array(
  957.                     "status"   =>  "active",
  958.                     "description" => 'deposit made',
  959.                     "invest_date"     =>  $invest_date,
  960.                     'mature_date' => $mature_date,
  961.                     "run_date"     =>  $next_run_date
  962.                 );
  963.                
  964.                 $this->db->where('depositid', $depositid);
  965.                 $query_status = $this->db->update('deposit',$deposit_data);
  966.                 $depositid = $this->db->insert_id();
  967.  
  968.                 $history_data = array(
  969.                     "uusersid" => $deposits->uusersid,
  970.                     "amount"    =>  $deposits->amount,
  971.                     "type"   =>  "deposit",
  972.                     "description" => 'deposit made',
  973.                     "date"     =>  date("Y-m-d H:i:s"),
  974.                     "payment_id"    =>  $deposits->payment_id,
  975.                     "transactionid" => "TRAN".strtoupper(uniqid()),
  976.                     "depositid" =>  $deposits->depositid
  977.                 );
  978.                
  979.                 $query_status = $this->db->insert('history',$history_data);
  980.             }
  981.             */
  982.            
  983.             $this->data['success'] =  $this->lang->line('lbl_payment_success');
  984.             $this->load->view('user/success',$this->data);
  985.         } else {
  986.             $this->data['success'] =  $this->lang->line('lbl_payment_success');
  987.             $this->load->view('user/success',$this->data);
  988.         }
  989.        
  990.  
  991.     }
  992.  
  993.  
  994.     public function success1() {
  995.  
  996.         if(isset($_POST) && count($_POST) > 0) {
  997.            
  998.             $this->data['success'] =  $this->lang->line('lbl_payment_pending');
  999.             $this->load->view('user/success',$this->data);
  1000.         } else {
  1001.             $this->data['success'] =  $this->lang->line('lbl_payment_success');
  1002.             $this->load->view('user/success',$this->data);
  1003.         }
  1004.        
  1005.  
  1006.     }
  1007.  
  1008.     public function cancel() {
  1009.         $this->data['error'] =  $this->lang->line('lbl_payment_fail');
  1010.         $this->load->view('user/cancel',$this->data);
  1011.     }
  1012.  
  1013.     public function Canceldeposit($id)
  1014.     {
  1015.  
  1016.         $myencrypt = new MyEncrypt;
  1017.         $depositid = $myencrypt->decode($id);
  1018.  
  1019.         $deposit_data = $this->common_model->getDepositData($depositid);
  1020.  
  1021.         if($deposit_data)
  1022.         {
  1023.             $return_amount = $deposit_data->amount * ($deposit_data->rtn_principal / 100 );
  1024.  
  1025.             $history_data = array(
  1026.                 "uusersid"  => $deposit_data->uusersid,
  1027.                 "amount"    => $return_amount,
  1028.                 "type"      => "release_deposit",
  1029.                 "description"   => "Close deposit from admin",
  1030.                 "date"     =>  date('Y-m-d H:i:s'),
  1031.                 "payment_id"    =>  $deposit_data->payment_id,
  1032.                 "transactionid" => "TRAN".strtoupper(uniqid()),
  1033.                 "depositid" =>  $deposit_data->depositid
  1034.             );
  1035.  
  1036.             $query_status = $this->db->insert('history',$history_data);
  1037.  
  1038.             $close_deposit_data = array(
  1039.                 'run_date' =>  date('Y-m-d H:i:s'),
  1040.                 'status'  =>   "matured"
  1041.             );
  1042.             $this->db->where('depositid',$deposit_data->depositid);
  1043.             $query_status = $this->db->update('deposit',$close_deposit_data);
  1044.  
  1045.             if($query_status) {
  1046.                 $this->session->set_flashdata('success_message', $this->lang->line('close_deposit_success_message'));
  1047.                 redirect('user/deposit');
  1048.             } else {
  1049.                 $this->session->set_flashdata('error_message', $this->lang->line('close_deposit_error_message'));
  1050.                 redirect('user/deposit');
  1051.             }
  1052.         } else {
  1053.             $this->db->where('depositid', $depositid);
  1054.             $close_status = $this->db->delete('deposit');
  1055.  
  1056.             if($close_status) {
  1057.                 $this->session->set_flashdata('success_message', $this->lang->line('close_deposit_success_message'));
  1058.                 redirect('user/deposit');
  1059.             } else {
  1060.                 $this->session->set_flashdata('error_message', $this->lang->line('close_deposit_error_message'));
  1061.                 redirect('user/deposit');
  1062.             }
  1063.         }
  1064.     }
  1065.     public function Interestlist($id) {
  1066.        
  1067.         $currency_info = defaultcurrency();
  1068.  
  1069.         $myencrypt = new MyEncrypt;
  1070.         // $depositid = $myencrypt->decode($id);
  1071.         $depositid = '10';
  1072.         // $condition ="depositid = '".$depositid."' AND uusersid = '".$this->session->userdata('uusersid')."' AND type in ('interest', 'commissions')";
  1073.         $condition ="depositid = '".$depositid."' AND type in ('interest', 'commissions') ORDER BY `date` DESC";
  1074.         $interst_history = $this->common_model->GetResults('history',$condition);
  1075.        
  1076.         $table = '<div class="datatable"><table>';
  1077.         $table .= '<colgroup>
  1078.                  <col width="35%">
  1079.                  <col width="35%">
  1080.                  <col width="30%">
  1081.                </colgroup>';
  1082.         $table .= '<tr>';
  1083.         $table .= '<th>'.$this->lang->line('trans_date').'</th>';
  1084.         $table .= '<th>'.$this->lang->line('transactionID').'</th>';
  1085.         $table .= '<th>'.$this->lang->line('trans_amnt').'</th>';
  1086.         // $table .= '<th>'.$this->lang->line('trans_descr').'</th>';
  1087.         $table .= '</tr>';
  1088.         if($interst_history)
  1089.         {              
  1090.             foreach ($interst_history as $row)
  1091.             {
  1092.  
  1093.                 $table .= '<tr>';
  1094.                 $table .= '<td>'.$row->date.'</td>';
  1095.                 $table .= '<td>'.$row->transactionid.'</td>';
  1096.                 $table .= '<td>'.$currency_info->currency_symbol."".number_format($row->amount, $currency_info->deimal_point, '.', '').' '.strtoupper($currency_info->currency_unit).'</td>';
  1097.                 // $table .= '<td>'.$row->description.'</td>';
  1098.                 $table .= '</tr>';
  1099.                    
  1100.             }
  1101.         }
  1102.         else
  1103.         {
  1104.             $table .= '<tr>';
  1105.             $table .= '<td colspan="4">'.$this->lang->line('lbl_no_records').'</td>';
  1106.             $table .= '</tr>';
  1107.         }
  1108.         $table .= '</table></div>';
  1109.         echo $table;
  1110.  
  1111.     }
  1112.  
  1113.     public function checkdeposit($id) {
  1114.         $currency_info = defaultcurrency();
  1115.         $myencrypt = new MyEncrypt;
  1116.         $depositid = $myencrypt->decode($id);
  1117.         $deposit = $this->common_model->getDepositData($depositid);
  1118.         $return_princ_amount = '0';
  1119.  
  1120.         if($deposit) {
  1121.             $deposit_amount = $deposit->amount;
  1122.             if($deposit->rtn_principal_status == '1') {
  1123.                 $return_princ_amount = $deposit_amount * ($deposit->rtn_principal / 100);
  1124.                 $loss_amount = $deposit_amount - $return_princ_amount;
  1125.             } else {
  1126.                 $loss_amount = $deposit_amount - $return_princ_amount;
  1127.             }
  1128.             echo $currency_info->currency_symbol."".number_format($loss_amount, $currency_info->deimal_point, '.', '').' '.strtoupper($currency_info->currency_unit);
  1129.         }
  1130.     }
  1131.  
  1132.     public function checkearnings() {
  1133.         $currency_info = defaultcurrency();
  1134.  
  1135.         $packageid = $this->input->post('packageid');
  1136.         $deposit_amt = $this->input->post('amount');
  1137.  
  1138.         $condition="icoid = '1'";
  1139.         $coin = $this->common_model->GetRow('icoset',$condition);
  1140.  
  1141.         $json['totalcoinamnt'] = $coin->valuetoken;
  1142.  
  1143.         $package = $this->packages_model->GetPackage($packageid);
  1144.  
  1145.         if($package->periord_name=='daily'){
  1146.             $periord_name = 'Days';
  1147.         } elseif($package->periord_name=='hourly') {
  1148.             $periord_name = 'Hours';
  1149.         } elseif($package->periord_name=='monthly') {
  1150.             $periord_name = 'Months';
  1151.         } elseif($package->periord_name=='weekly') {
  1152.             $periord_name = 'Weeks';
  1153.         } elseif($package->periord_name=='yearly') {
  1154.             $periord_name = 'Years';
  1155.         } else {
  1156.             $periord_name = $package->periord_name;
  1157.         }
  1158.  
  1159.         $json['duration'] = $package->duration.' '.$periord_name;
  1160.  
  1161.         $plans = $this->packages_model->GetPlans($packageid);
  1162.        
  1163.         foreach ($plans as $plan) {
  1164.  
  1165.             // if($plan->min_amount <= $deposit_amt && $plan->max_amount >= $deposit_amt && $deposit_amt > 0){
  1166.             if($plan->min_amount <= $deposit_amt && $deposit_amt > 0){
  1167.                 $plan_data = $plan;
  1168.             }
  1169.         }
  1170.         $json['plan_name'] = $plan_data->rate.'% '.$package->periord_name;
  1171.        
  1172.         $profit = 0;
  1173.         $compound = $this->input->post('compound_rate');
  1174.         if($compound) {
  1175.             for($i=1;$i<=$package->duration; $i++){
  1176.                 $deposit_interest =  $deposit_amt * ($plan_data->rate / 100);
  1177.                 $compound_interest = $deposit_interest * ($compound / 100);
  1178.  
  1179.                 $profit = $profit + ($deposit_interest - $compound_interest);
  1180.                 $deposit_amt = $deposit_amt + $compound_interest;  
  1181.             }
  1182.            
  1183.         } else {
  1184.             $profit = $deposit_amt * ($plan_data->rate / 100) * $package->duration;
  1185.         }
  1186.         // $json['profit']  = $currency_info->currency_symbol."".number_format($profit, $currency_info->deimal_point, '.', '');
  1187.         echo json_encode($json);
  1188.     }
  1189.  
  1190.     public function Cancelprocess() {
  1191.        
  1192.         $depositid = $this->input->post('depositid');
  1193.         $this->db->where('depositid', $depositid);
  1194.         $close_status = $this->db->delete('deposit');
  1195.         if($close_status) {
  1196.             echo '1';
  1197.         } else {
  1198.             echo '0';
  1199.         }
  1200.     }
  1201.  
  1202.     public function sendmail($useremail, $fullname, $subject, $message, $from_mail) {
  1203.  
  1204.         $this->load->library('My_PHPMailer');
  1205.         $condition = "settings_name = 'email'";
  1206.         $email_setting_data = $this->common_model->GetSettingall_lang($condition);
  1207.  
  1208.         foreach ($email_setting_data as $row) {
  1209.             $mail_data[$row->site_key] = $row->site_value;
  1210.         }
  1211.  
  1212.         if($mail_data['email_throw']=='php')
  1213.         {
  1214.             $mail = new PHPMailer();
  1215.             $mail->isMail();
  1216.  
  1217.         } else {
  1218.  
  1219.             $mail = new PHPMailer();
  1220.             $mail->IsSMTP();
  1221.             $mail->SMTPAuth   = TRUE;
  1222.             $mail->SMTPSecure = $mail_data['smtp_type'];  
  1223.             $mail->Host       = $mail_data['smtp_hostname'];      
  1224.             $mail->Port       = $mail_data['smtp_portno'];                  
  1225.             $mail->Username   = $mail_data['smtp_username'];  
  1226.             $mail->Password   = $mail_data['smtp_password'];  
  1227.         }
  1228.                  
  1229.         $mail->SetFrom($from_mail, site_info_lang('site_name',$this->session->userdata('langid')));  
  1230.         $mail->AddReplyTo($from_mail,site_info_lang('site_name',$this->session->userdata('langid')));
  1231.  
  1232.         $message  = str_replace('#adminemail', $from_mail, $message);
  1233.  
  1234.         $mail->Subject    = $subject;
  1235.         $mail->msgHTML($message);
  1236.        
  1237.         $mail->AddAddress($useremail, $fullname);
  1238.        
  1239.         if(!$mail->Send()) {
  1240.             // return $mail->ErrorInfo;
  1241.             return false;
  1242.         } else {
  1243.             return true;
  1244.         }
  1245.     }
  1246.    
  1247.    
  1248. }
Advertisement
Add Comment
Please, Sign In to add comment