Login::paypal_response()   D
last analyzed

Complexity

Conditions 17
Paths 98

Size

Total Lines 130
Code Lines 118

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 17
eloc 118
nc 98
nop 0
dl 0
loc 130
rs 4.8361
c 0
b 0
f 0

How to fix   Long Method    Complexity   

Long Method

Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.

For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.

Commonly applied refactorings include:

1
<?php
2
###############################################################################
3
# ASTPP - Open Source VoIP Billing Solution
4
#
5
# Copyright (C) 2016 iNextrix Technologies Pvt. Ltd.
6
# Samir Doshi <[email protected]>
7
# ASTPP Version 3.0 and above
8
# License https://www.gnu.org/licenses/agpl-3.0.html
9
#
10
# This program is free software: you can redistribute it and/or modify
11
# it under the terms of the GNU Affero General Public License as
12
# published by the Free Software Foundation, either version 3 of the
13
# License, or (at your option) any later version.
14
# 
15
# This program is distributed in the hope that it will be useful,
16
# but WITHOUT ANY WARRANTY; without even the implied warranty of
17
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18
# GNU Affero General Public License for more details.
19
# 
20
# You should have received a copy of the GNU Affero General Public License
21
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
22
###############################################################################
23
class Login extends MX_Controller {
24
25 View Code Duplication
	function Login() {
26
		parent::__construct();
0 ignored issues
show
Comprehensibility Bug introduced by
It seems like you call parent on a different method (__construct() instead of Login()). Are you sure this is correct? If so, you might want to change this to $this->__construct().

This check looks for a call to a parent method whose name is different than the method from which it is called.

Consider the following code:

class Daddy
{
    protected function getFirstName()
    {
        return "Eidur";
    }

    protected function getSurName()
    {
        return "Gudjohnsen";
    }
}

class Son
{
    public function getFirstName()
    {
        return parent::getSurname();
    }
}

The getFirstName() method in the Son calls the wrong method in the parent class.

Loading history...
27
		$this->load->helper('form');
28
		$this->load->library('astpp/permission');
29
		$this->load->library('encrypt');        
30
		$this->load->model('Auth_model');
31
		$this->load->model('db_model');
32
	}
33
    
34
	function set_lang_global($post=false){ 
35
	if(!is_array($post)){
36
		$str=trim($post);
37
		$new_arr[$str]=$str;
0 ignored issues
show
Coding Style Comprehensibility introduced by
$new_arr was never initialized. Although not strictly required by PHP, it is generally a good practice to add $new_arr = array(); before regardless.

Adding an explicit array definition is generally preferable to implicit array definition as it guarantees a stable state of the code.

Let’s take a look at an example:

foreach ($collection as $item) {
    $myArray['foo'] = $item->getFoo();

    if ($item->hasBar()) {
        $myArray['bar'] = $item->getBar();
    }

    // do something with $myArray
}

As you can see in this example, the array $myArray is initialized the first time when the foreach loop is entered. You can also see that the value of the bar key is only written conditionally; thus, its value might result from a previous iteration.

This might or might not be intended. To make your intention clear, your code more readible and to avoid accidental bugs, we recommend to add an explicit initialization $myArray = array() either outside or inside the foreach loop.

Loading history...
38
		$post=$new_arr;
39
	}
40
	if(isset($post['fr_FR'])){
41
	 $language=$post['fr_FR'];
42
	 $this->session->set_userdata('user_language', $language);
43
	}
44
	if(isset($post['es_ES'])){
45
	 $language=$post['es_ES'];
46
	 $this->session->set_userdata('user_language', $language);         
47
	}       
48
	if(isset($post['en_EN'])){
49
	 $language=$post['en_EN'];
50
	 $this->session->unset_userdata('user_language',$language);
51
	} 
52
	$this->locale->set_lang();
53
	return true;
54
	}
55
56
	function index() {
57
		if ($this->session->userdata('user_login') == FALSE) {
58
			if (!empty($_POST) && trim($_POST['username']) != '' && trim($_POST['password']) != '') {
59
			$_POST['password']=$this->common->encode($_POST['password']);
60
				$user_valid = $this->Auth_model->verify_login($_POST['username'], $_POST['password']);
61
                
62
				if ($user_valid == 1) {
63
					$this->session->set_userdata('user_login', TRUE);
64
			$where = "number = '".$this->db->escape_str($_POST['username'])."' OR email = '".$this->db->escape_str($_POST['username'])."'";
65
					$result = $this->db_model->getSelect("*", "accounts",$where);
66
					$result = $result->result_array();
67
					$result = $result[0];
68
					 $logintype=$result['type']== -1 ? 2: $result['type'];
69
					$this->session->set_userdata('logintype', $logintype);
70
					$this->session->set_userdata('userlevel_logintype', $result['type']);
71
					$this->session->set_userdata('username', $_POST['username']);
72
					$this->session->set_userdata('accountinfo', $result);
73
		/*
74
		*
75
		* Purpose : Display logo based on domain name
76
		*
77
		*/
78
		$this->db->select("*");
79
		if ($result['type'] == '2' || $result['type'] == '-1') {
80
			$this->db->where(array("accountid"=>$result["id"]));
81
		} else if ($result['type'] == '0') {
82 View Code Duplication
			if ($result['reseller_id'] == 0) {
83
				$this->db->where(array("accountid"=>"1"));
84
			} else {
85
				$this->db->where(array("accountid"=>$result["reseller_id"]));
86
			}
87
		} else if ($result['type'] == '1') {
88
			if ($result['reseller_id'] == 0) {
89
				$result_invoice = $this->common->get_field_name('id', 'invoice_conf', array("accountid" => $result['id']));
90
				
91 View Code Duplication
				if ($result_invoice) {
92
					$this->db->where(array("accountid"=>$result["id"]));
93
				} else {
94
					$this->db->where(array("accountid"=>"1"));
95
				}
96
				
97
			} else {
98
				$result_invoice = $this->common->get_field_name('id', 'invoice_conf', array("accountid" => $result['reseller_id']));
99 View Code Duplication
				if ($result_invoice) {
100
					$this->db->where(array("accountid"=>$result["reseller_id"]));
101
				} else {
102
					$this->db->where(array("accountid"=>"1"));
103
				}
104
			}
105
		} else {
106
			$this->db->where(array("accountid"=>"1"));
107
		}
108
		$res = $this->db->get("invoice_conf");
109
		$logo_arr = $res->result();
110
	$data['user_logo'] = (isset($logo_arr[0]->logo) && $logo_arr[0]->logo != "") ? $logo_arr[0]->accountid."_".$logo_arr[0]->logo : "logo.png";
0 ignored issues
show
Coding Style Comprehensibility introduced by
$data was never initialized. Although not strictly required by PHP, it is generally a good practice to add $data = array(); before regardless.

Adding an explicit array definition is generally preferable to implicit array definition as it guarantees a stable state of the code.

Let’s take a look at an example:

foreach ($collection as $item) {
    $myArray['foo'] = $item->getFoo();

    if ($item->hasBar()) {
        $myArray['bar'] = $item->getBar();
    }

    // do something with $myArray
}

As you can see in this example, the array $myArray is initialized the first time when the foreach loop is entered. You can also see that the value of the bar key is only written conditionally; thus, its value might result from a previous iteration.

This might or might not be intended. To make your intention clear, your code more readible and to avoid accidental bugs, we recommend to add an explicit initialization $myArray = array() either outside or inside the foreach loop.

Loading history...
111
		$data['user_header'] = (isset($logo_arr[0]->website_title) && $logo_arr[0]->website_title != "") ? $logo_arr[0]->website_title : "ASTPP - Open Source Voip Billing Solution";
112
		$data['user_footer'] = (isset($logo_arr[0]->website_footer) && $logo_arr[0]->website_footer != "") ? $logo_arr[0]->website_footer : "Inextrix Technologies Pvt. Ltd All Rights Reserved.";
113
		$this->session->set_userdata('user_logo', $data['user_logo']);
114
		$this->session->set_userdata('user_header', $data['user_header']);
115
		$this->session->set_userdata('user_footer', $data['user_footer']);
116
		//                      echo $data['user_header'];exit;
0 ignored issues
show
Unused Code Comprehensibility introduced by
80% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
117
		/***************************************************************************************/
118
					if ($result['type'] == 0 || $result['type'] == 1) {
119
						$menu_list = $this->permission->get_module_access($result['type']);
120
						$this->session->set_userdata('mode_cur', 'user');
121
						if($result['type'] == 1){
122
							redirect(base_url() . 'dashboard/');
123
						}else{
124
							redirect(base_url() . 'user/user/');
125
						}
126
					} else {
127
						$menu_list = $this->permission->get_module_access($result['type']);
128
						$this->session->set_userdata('mode_cur', 'admin');
129
						redirect(base_url() . 'dashboard/');
130
					}
131
				} else {
132
		   
133
						$data['astpp_notification'] = "Login Failed! Try Again..";
0 ignored issues
show
Coding Style Comprehensibility introduced by
$data was never initialized. Although not strictly required by PHP, it is generally a good practice to add $data = array(); before regardless.

Adding an explicit array definition is generally preferable to implicit array definition as it guarantees a stable state of the code.

Let’s take a look at an example:

foreach ($collection as $item) {
    $myArray['foo'] = $item->getFoo();

    if ($item->hasBar()) {
        $myArray['bar'] = $item->getBar();
    }

    // do something with $myArray
}

As you can see in this example, the array $myArray is initialized the first time when the foreach loop is entered. You can also see that the value of the bar key is only written conditionally; thus, its value might result from a previous iteration.

This might or might not be intended. To make your intention clear, your code more readible and to avoid accidental bugs, we recommend to add an explicit initialization $myArray = array() either outside or inside the foreach loop.

Loading history...
134
				}
135
			}
136
	/*
137
	* Purpose : Display logo based on domain name
138
	*/
139
	$this->db->select("*");
140
	$this->db->where(array("domain"=>$_SERVER["HTTP_HOST"]));
141
	$res = $this->db->get("invoice_conf");
142
	$logo_arr = $res->result();
143
	$data['user_logo'] = (isset($logo_arr[0]->logo) && $logo_arr[0]->logo != "") ? $logo_arr[0]->accountid."_".$logo_arr[0]->logo : "logo.png";
0 ignored issues
show
Bug introduced by
The variable $data does not seem to be defined for all execution paths leading up to this point.

If you define a variable conditionally, it can happen that it is not defined for all execution paths.

Let’s take a look at an example:

function myFunction($a) {
    switch ($a) {
        case 'foo':
            $x = 1;
            break;

        case 'bar':
            $x = 2;
            break;
    }

    // $x is potentially undefined here.
    echo $x;
}

In the above example, the variable $x is defined if you pass “foo” or “bar” as argument for $a. However, since the switch statement has no default case statement, if you pass any other value, the variable $x would be undefined.

Available Fixes

  1. Check for existence of the variable explicitly:

    function myFunction($a) {
        switch ($a) {
            case 'foo':
                $x = 1;
                break;
    
            case 'bar':
                $x = 2;
                break;
        }
    
        if (isset($x)) { // Make sure it's always set.
            echo $x;
        }
    }
    
  2. Define a default value for the variable:

    function myFunction($a) {
        $x = ''; // Set a default which gets overridden for certain paths.
        switch ($a) {
            case 'foo':
                $x = 1;
                break;
    
            case 'bar':
                $x = 2;
                break;
        }
    
        echo $x;
    }
    
  3. Add a value for the missing path:

    function myFunction($a) {
        switch ($a) {
            case 'foo':
                $x = 1;
                break;
    
            case 'bar':
                $x = 2;
                break;
    
            // We add support for the missing case.
            default:
                $x = '';
                break;
        }
    
        echo $x;
    }
    
Loading history...
144
	$data['website_header'] = (isset($logo_arr[0]->website_title) && $logo_arr[0]->website_title != "") ? $logo_arr[0]->website_title : "ASTPP - Open Source Voip Billing Solution";
145
	$data['website_footer'] = (isset($logo_arr[0]->website_footer) && $logo_arr[0]->website_footer != "") ? $logo_arr[0]->website_footer : "Inextrix Technologies Pvt. Ltd All Rights Reserved.";
146
	$this->session->set_userdata('user_logo', $data['user_logo']);
147
	$this->session->set_userdata('user_header', $data['website_header']);
148
	$this->session->set_userdata('user_footer', $data['website_footer']);
149
	//              echo $data['user_logo'];exit;
0 ignored issues
show
Unused Code Comprehensibility introduced by
80% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
150
	/***************************************************************************************/
151
			$this->session->set_userdata('user_login', FALSE);
152
			$data['app_name'] = 'ASTPP - Open Source Billing Solution';
153
			$this->load->view('view_login', $data);
154
		}else {
155
	/*
156
	*
157
	* Purpose : Display logo based on domain name
158
	*
159
	*/
160
		  $this->db->select("*");
161
		  $this->db->where(array("domain"=>$_SERVER["HTTP_HOST"]));
162
		  $res = $this->db->get("invoice_conf");
163
		  $logo_arr = $res->result();
164
//print_r( $logo_arr );exit;
0 ignored issues
show
Unused Code Comprehensibility introduced by
67% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
165
166
	$data['user_logo'] = (isset($logo_arr[0]->logo) && $logo_arr[0]->logo != "") ? $logo_arr[0]->accountid."_".$logo_arr[0]->logo : "logo.png";
167
		 $data['user_header'] = (isset($logo_arr[0]->website_title) && $logo_arr[0]->website_title != "") ? $logo_arr[0]->website_title : "ASTPP - Open Source Voip Billing Solution";
168
 $data['user_footer'] = (isset($logo_arr[0]->website_footer) && $logo_arr[0]->website_footer != "") ? $logo_arr[0]->website_footer : "Inextrix Technologies Pvt. Ltd All Rights Reserved.";
169
		
170
		$this->session->set_userdata('user_logo', $data['user_logo']);
171
		 $this->session->set_userdata('user_header', $data['user_header']);
172
		$this->session->set_userdata('user_footer', $data['user_footer']);
173
	//              echo $data['user_logo'];exit;
0 ignored issues
show
Unused Code Comprehensibility introduced by
67% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
174
/***************************************************************************************/
175
		if ($this->session->userdata('logintype') == '2') {
176
		redirect(base_url() . 'dashboard/');
177
		} else {
178
		redirect(base_url().'user/user/');
179
		}
180
		}
181
	}
182
183
	function logout() {
184
		$this->session->sess_destroy();
185
		redirect(base_url());
186
	}
187
  function paypal_response(){
188
	  if(count($_POST)>0)
189
	  {
190
		$response_arr=$_POST;
191
		$fp=fopen("/var/log/astpp/astpp_payment.log","w+");
192
		$date = date("Y-m-d H:i:s");
193
		fwrite($fp,"====================".$date."===============================\n");
194
		foreach($response_arr as $key => $value){	  
195
			fwrite($fp,$key.":::>".$value."\n");
196
		}
197
		$payment_check = $this->db_model->countQuery("txn_id", "payments", array("txn_id" => $response_arr['txn_id']));
198
		if( ($response_arr["payment_status"] == "Pending" || $response_arr["payment_status"] == "Complete" || $response_arr["payment_status"] == "Completed" ) && $payment_check == 0){
199
200
			$paypal_tax = (array)$this->db->get_where("system", array("name" => "paypal_tax","group_title"=>"paypal"))->first_row();
201
			$paypal_tax =$paypal_tax['value'];
202
			$balance_amt = $actual_amount = $response_arr["custom"];
203
			$paypal_fee = (array)$this->db->get_where("system", array("name" => "paypal_fee","group_title"=>"paypal"))->first_row();
204
			$paypal_fee = $paypal_fee['value'];
205
			$paypalfee = ($paypal_fee == 0)?'0':$response_arr["mc_gross"];
206
			$account_data = (array)$this->db->get_where("accounts", array("id" => $response_arr["item_number"]))->first_row();
207
			$currency = (array)$this->db->get_where('currency', array("id"=>$account_data["currency_id"]))->first_row();
208
			$date = date('Y-m-d H:i:s');
209
			$payment_trans_array = array("accountid"=>$response_arr["item_number"],
210
							"amount"=>$response_arr["payment_gross"],
211
									"tax"=>"1",
212
									"payment_method"=>"Paypal",
213
									"actual_amount"=>$actual_amount,
214
									"paypal_fee"=>$paypalfee,
215
							"user_currency"=>$currency["currency"],
216
							"currency_rate"=>$currency["currencyrate"],
217
							"transaction_details"=>json_encode($response_arr),
218
							"date"=>$date);
219
			 $paymentid=$this->db->insert('payment_transaction',$payment_trans_array);
220
			 $parent_id =$account_data['reseller_id'] > 0 ? $account_data['reseller_id'] : '-1';
221
		 $payment_arr = array("accountid"=> $response_arr["item_number"],
222
		 		"payment_mode"=>"1","credit"=>$balance_amt,
223
				"type"=>"PAYPAL",
224
				"payment_by"=>$parent_id,
225
				"notes"=>"Payment Made by Paypal on date:-".$date,
226
				"paypalid"=>$paymentid,
227
				"txn_id"=>$response_arr["txn_id"],
228
				'payment_date'=>gmdate('Y-m-d H:i:s',strtotime($response_arr['payment_date'])));
229
		 $this->db->insert('payments', $payment_arr);
230
		 $this->db->select('invoiceid');
231
		 $this->db->order_by('id','desc');
232
		 $this->db->limit(1);
233
 		 $last_invoice_result=(array)$this->db->get('invoices')->first_row();
234
 		 $last_invoice_ID=isset($last_invoice_result['invoiceid'] ) && $last_invoice_result['invoiceid'] > 0 ?$last_invoice_result['invoiceid'] : 1;
235
 		 $reseller_id=$account_data['reseller_id'] > 0 ? $account_data['reseller_id'] : 0;
236
		 $where="accountid IN ('".$reseller_id."','1')";
237
		 $this->db->where($where);
238
		 $this->db->select('*');
239
		 $this->db->order_by('accountid', 'desc');
240
		 $this->db->limit(1);
241
			 $invoiceconf = $this->db->get('invoice_conf');
242
			 $invoiceconf = (array)$invoiceconf->first_row();
243
		 $invoice_prefix=$invoiceconf['invoice_prefix'];
244
245
		 $due_date = gmdate("Y-m-d H:i:s",strtotime(gmdate("Y-m-d H:i:s")." +".$invoiceconf['interval']." days"));  
246
		 $invoice_id=$this->generate_receipt($account_data['id'],$balance_amt,$account_data,$last_invoice_ID+1,$invoice_prefix,$due_date);
247
		 $details_insert=array(
248
			'created_date'=>$date,
249
			'credit'=>$balance_amt,
250
			'debit'=>'-',
251
			'accountid'=>$account_data["id"],
252
			'reseller_id'=>$account_data['reseller_id'],
253
			'invoiceid'=>$invoice_id,
254
			'description'=>"Payment Made by Paypal on date:-".$date,
255
			'item_type'=>'PAYMENT',
256
	  			'before_balance'=>$account_data['balance'],
257
			'after_balance'=>$account_data['balance']+$balance_amt,
258
			);
259
		$this->db->insert("invoice_details", $details_insert); 
260
		$this->db_model->update_balance($balance_amt,$account_data["id"],"credit");            
261
		if($parent_id > 0){
262
			  $reseller_ids=$this->common->get_parent_info($parent_id,0);
263
			  $reseller_ids=rtrim($reseller_ids,",");
264
			  $reseller_arr=explode(",",$reseller_ids);
265
			  if(!empty($reseller_arr)){
266
			foreach($reseller_arr as $key=>$reseller_id){
267
			  $account_data = (array)$this->db->get_where("accounts", array("id" => $reseller_id))->first_row();
268
			  $this->db->select('invoiceid');
269
				  $this->db->order_by('id','desc');
270
				  $this->db->limit(1);
271
 					  $last_invoice_result=(array)$this->db->get('invoices')->first_row();
272
 					  $last_invoice_ID=$last_invoice_result['invoiceid'];
273
 		 		  $reseller_id=$account_data['reseller_id'] > 0 ? $account_data['reseller_id'] : 0;
274
					  $where="accountid IN ('".$reseller_id."','1')";
275
					  $this->db->where($where);
276
				  $this->db->select('*');
277
				  $this->db->order_by('accountid', 'desc');
278
				  $this->db->limit(1);
279
				  $invoiceconf = $this->db->get('invoice_conf');
280
				  $invoiceconf = (array)$invoiceconf->first_row();
281
					  $invoice_prefix=$invoiceconf['invoice_prefix'];
282
		 		  $due_date = gmdate("Y-m-d H:i:s",strtotime(gmdate("Y-m-d H:i:s")." +".$invoiceconf['interval']." days"));
283
		 		  $invoice_id=$this->generate_receipt($account_data['id'],$balance_amt,$account_data,$last_invoice_ID+1,$invoice_prefix,$due_date);
284
			  $parent_id=$account_data['reseller_id'] > 0 ? $account_data['reseller_id'] : -1;
285
			  $payment_arr = array("accountid"=> $account_data["id"],
286
		 					"payment_mode"=>"1",
287
		 					"credit"=>$balance_amt,
288
							"type"=>"PAYPAL",
289
							"payment_by"=>$parent_id,
290
							"notes"=>"Your account has been credited due to your customer account recharge done by paypal",
291
							"paypalid"=>$paymentid,
292
							"txn_id"=>$response_arr["txn_id"],
293
							'payment_date'=>gmdate('Y-m-d H:i:s',strtotime($response_arr['payment_date'])));
294
	 			  $this->db->insert('payments', $payment_arr);
295
			  $details_insert=array(
296
				'created_date'=>$date,
297
				'credit'=>$balance_amt,
298
				'debit'=>'-',
299
				'accountid'=>$account_data['id'],
300
				'reseller_id'=>$parent_id,
301
				'invoiceid'=>$invoice_id,
302
				'description'=>"Your account has been credited due to your customer account recharge done by paypal",
303
				'item_type'=>'PAYMENT',
304
		  	        'before_balance'=>$account_data['balance'],
305
				'after_balance'=>$account_data['balance']+$balance_amt,
306
			   );
307
		          $this->db->insert("invoice_details", $details_insert); 
308
	          	  $this->db_model->update_balance($balance_amt,$account_data["id"],"credit");  			         
309
			}
310
		      }
311
		}
312
		redirect(base_url() . 'user/user/');
313
        }
314
      }         
315
	redirect(base_url() . 'user/user/');
316
    }
317
318
    /**
319
     * @param integer $last_invoice_ID
320
     * @param string $due_date
321
     */
322 View Code Duplication
    function generate_receipt($accountid,$amount,$accountinfo,$last_invoice_ID,$invoice_prefix,$due_date){
323
		$invoice_data = array("accountid"=>$accountid,"invoice_prefix" =>$invoice_prefix,"invoiceid"=>'0000'.$last_invoice_ID,"reseller_id"=>$accountinfo['reseller_id'],"invoice_date"=>gmdate("Y-m-d H:i:s"),"from_date"=>  gmdate("Y-m-d H:i:s"),"to_date"=>gmdate("Y-m-d H:i:s"),"due_date"=>$due_date,"status"=>1,"balance"=>$accountinfo['balance'],"amount"=>$amount,"type"=>'R',"confirm"=>'1');            
324
        $this->db->insert("invoices",$invoice_data);
325
        $invoiceid = $this->db->insert_id();    
326
        return  $invoiceid;  
327
    }
328
    
329
    function get_language_text(){
330
   // echo '<pre>'; print_r($_POST); exit;
0 ignored issues
show
Unused Code Comprehensibility introduced by
65% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
331
      echo gettext($_POST['display']); 
332
 	}  
333
    
334
}
335
336
?>
0 ignored issues
show
Best Practice introduced by
It is not recommended to use PHP's closing tag ?> in files other than templates.

Using a closing tag in PHP files that only contain PHP code is not recommended as you might accidentally add whitespace after the closing tag which would then be output by PHP. This can cause severe problems, for example headers cannot be sent anymore.

A simple precaution is to leave off the closing tag as it is not required, and it also has no negative effects whatsoever.

Loading history...
337