Completed
Pull Request — v3.0 (#136)
by
unknown
25:07
created
web_interface/astpp/application/modules/login/controllers/login.php 4 patches
Doc Comments   +5 added lines patch added patch discarded remove patch
@@ -314,6 +314,11 @@
 block discarded – undo
314 314
       }         
315 315
 	redirect(base_url() . 'user/user/');
316 316
     }
317
+
318
+    /**
319
+     * @param integer $last_invoice_ID
320
+     * @param string $due_date
321
+     */
317 322
     function generate_receipt($accountid,$amount,$accountinfo,$last_invoice_ID,$invoice_prefix,$due_date){
318 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');            
319 324
         $this->db->insert("invoices",$invoice_data);
Please login to merge, or discard this patch.
Indentation   +157 added lines, -157 removed lines patch added patch discarded remove patch
@@ -22,16 +22,16 @@  discard block
 block discarded – undo
22 22
 ###############################################################################
23 23
 class Login extends MX_Controller {
24 24
 
25
-    function Login() {
26
-        parent::__construct();
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
-    }
25
+	function Login() {
26
+		parent::__construct();
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 33
     
34
-    function set_lang_global($post=false){ 
34
+	function set_lang_global($post=false){ 
35 35
 	if(!is_array($post)){
36 36
 		$str=trim($post);
37 37
 		$new_arr[$str]=$str;
@@ -51,25 +51,25 @@  discard block
 block discarded – undo
51 51
 	} 
52 52
 	$this->locale->set_lang();
53 53
 	return true;
54
-    }
54
+	}
55 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']);
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 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);
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 73
 		/*
74 74
 		*
75 75
 		* Purpose : Display logo based on domain name
@@ -115,24 +115,24 @@  discard block
 block discarded – undo
115 115
 		$this->session->set_userdata('user_footer', $data['user_footer']);
116 116
 		//                      echo $data['user_header'];exit;
117 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 {
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 132
 		   
133
-                        $data['astpp_notification'] = "Login Failed! Try Again..";
134
-                }
135
-            }
133
+						$data['astpp_notification'] = "Login Failed! Try Again..";
134
+				}
135
+			}
136 136
 	/*
137 137
 	* Purpose : Display logo based on domain name
138 138
 	*/
@@ -148,10 +148,10 @@  discard block
 block discarded – undo
148 148
 	$this->session->set_userdata('user_footer', $data['website_footer']);
149 149
 	//              echo $data['user_logo'];exit;
150 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 {
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 155
 	/*
156 156
 	*
157 157
 	* Purpose : Display logo based on domain name
@@ -172,79 +172,79 @@  discard block
 block discarded – undo
172 172
 		$this->session->set_userdata('user_footer', $data['user_footer']);
173 173
 	//              echo $data['user_logo'];exit;
174 174
 /***************************************************************************************/
175
-	    if ($this->session->userdata('logintype') == '2') {
175
+		if ($this->session->userdata('logintype') == '2') {
176 176
 		redirect(base_url() . 'dashboard/');
177
-	    } else {
177
+		} else {
178 178
 		redirect(base_url().'user/user/');
179
-	    }
180
-        }
181
-    }
179
+		}
180
+		}
181
+	}
182 182
 
183
-    function logout() {
184
-        $this->session->sess_destroy();
185
-        redirect(base_url());
186
-    }
183
+	function logout() {
184
+		$this->session->sess_destroy();
185
+		redirect(base_url());
186
+	}
187 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){
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 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'];
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 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(
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 248
 			'created_date'=>$date,
249 249
 			'credit'=>$balance_amt,
250 250
 			'debit'=>'-',
@@ -253,45 +253,45 @@  discard block
 block discarded – undo
253 253
 			'invoiceid'=>$invoice_id,
254 254
 			'description'=>"Payment Made by Paypal on date:-".$date,
255 255
 			'item_type'=>'PAYMENT',
256
-	  	        'before_balance'=>$account_data['balance'],
256
+	  			'before_balance'=>$account_data['balance'],
257 257
 			'after_balance'=>$account_data['balance']+$balance_amt,
258 258
 			);
259 259
 		$this->db->insert("invoice_details", $details_insert); 
260 260
 		$this->db_model->update_balance($balance_amt,$account_data["id"],"credit");            
261 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)){
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 266
 			foreach($reseller_arr as $key=>$reseller_id){
267 267
 			  $account_data = (array)$this->db->get_where("accounts", array("id" => $reseller_id))->first_row();
268 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);
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 284
 			  $parent_id=$account_data['reseller_id'] > 0 ? $account_data['reseller_id'] : -1;
285 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);
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 295
 			  $details_insert=array(
296 296
 				'created_date'=>$date,
297 297
 				'credit'=>$balance_amt,
@@ -301,29 +301,29 @@  discard block
 block discarded – undo
301 301
 				'invoiceid'=>$invoice_id,
302 302
 				'description'=>"Your account has been credited due to your customer account recharge done by paypal",
303 303
 				'item_type'=>'PAYMENT',
304
-		  	        'before_balance'=>$account_data['balance'],
304
+		  			'before_balance'=>$account_data['balance'],
305 305
 				'after_balance'=>$account_data['balance']+$balance_amt,
306 306
 			   );
307
-		          $this->db->insert("invoice_details", $details_insert); 
308
-	          	  $this->db_model->update_balance($balance_amt,$account_data["id"],"credit");  			         
307
+				  $this->db->insert("invoice_details", $details_insert); 
308
+			  	  $this->db_model->update_balance($balance_amt,$account_data["id"],"credit");  			         
309 309
 			}
310
-		      }
310
+			  }
311 311
 		}
312 312
 		redirect(base_url() . 'user/user/');
313
-        }
314
-      }         
313
+		}
314
+	  }         
315 315
 	redirect(base_url() . 'user/user/');
316
-    }
317
-    function generate_receipt($accountid,$amount,$accountinfo,$last_invoice_ID,$invoice_prefix,$due_date){
316
+	}
317
+	function generate_receipt($accountid,$amount,$accountinfo,$last_invoice_ID,$invoice_prefix,$due_date){
318 318
 		$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');            
319
-        $this->db->insert("invoices",$invoice_data);
320
-        $invoiceid = $this->db->insert_id();    
321
-        return  $invoiceid;  
322
-    }
319
+		$this->db->insert("invoices",$invoice_data);
320
+		$invoiceid = $this->db->insert_id();    
321
+		return  $invoiceid;  
322
+	}
323 323
     
324
-    function get_language_text(){
324
+	function get_language_text(){
325 325
    // echo '<pre>'; print_r($_POST); exit;
326
-      echo gettext($_POST['display']); 
326
+	  echo gettext($_POST['display']); 
327 327
  	}  
328 328
     
329 329
 }
Please login to merge, or discard this patch.
Spacing   +98 added lines, -98 removed lines patch added patch discarded remove patch
@@ -31,23 +31,23 @@  discard block
 block discarded – undo
31 31
         $this->load->model('db_model');
32 32
     }
33 33
     
34
-    function set_lang_global($post=false){ 
35
-	if(!is_array($post)){
36
-		$str=trim($post);
37
-		$new_arr[$str]=$str;
38
-		$post=$new_arr;
34
+    function set_lang_global($post = false) { 
35
+	if ( ! is_array($post)) {
36
+		$str = trim($post);
37
+		$new_arr[$str] = $str;
38
+		$post = $new_arr;
39 39
 	}
40
-	if(isset($post['fr_FR'])){
41
-	 $language=$post['fr_FR'];
40
+	if (isset($post['fr_FR'])) {
41
+	 $language = $post['fr_FR'];
42 42
 	 $this->session->set_userdata('user_language', $language);
43 43
 	}
44
-	if(isset($post['es_ES'])){
45
-	 $language=$post['es_ES'];
44
+	if (isset($post['es_ES'])) {
45
+	 $language = $post['es_ES'];
46 46
 	 $this->session->set_userdata('user_language', $language);         
47 47
 	}       
48
-	if(isset($post['en_EN'])){
49
-	 $language=$post['en_EN'];
50
-	 $this->session->unset_userdata('user_language',$language);
48
+	if (isset($post['en_EN'])) {
49
+	 $language = $post['en_EN'];
50
+	 $this->session->unset_userdata('user_language', $language);
51 51
 	} 
52 52
 	$this->locale->set_lang();
53 53
 	return true;
@@ -55,17 +55,17 @@  discard block
 block discarded – undo
55 55
 
56 56
     function index() {
57 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']);
58
+            if ( ! empty($_POST) && trim($_POST['username']) != '' && trim($_POST['password']) != '') {
59
+	        $_POST['password'] = $this->common->encode($_POST['password']);
60 60
                 $user_valid = $this->Auth_model->verify_login($_POST['username'], $_POST['password']);
61 61
                 
62 62
                 if ($user_valid == 1) {
63 63
                     $this->session->set_userdata('user_login', TRUE);
64 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);
65
+                    $result = $this->db_model->getSelect("*", "accounts", $where);
66 66
                     $result = $result->result_array();
67 67
                     $result = $result[0];
68
-                     $logintype=$result['type']== -1 ? 2: $result['type'];
68
+                     $logintype = $result['type'] == -1 ? 2 : $result['type'];
69 69
                     $this->session->set_userdata('logintype', $logintype);
70 70
                     $this->session->set_userdata('userlevel_logintype', $result['type']);
71 71
                     $this->session->set_userdata('username', $_POST['username']);
@@ -76,40 +76,40 @@  discard block
 block discarded – undo
76 76
 		*
77 77
 		*/
78 78
 		$this->db->select("*");
79
-		if($result['type'] == '2' || $result['type'] == '-1'){
79
+		if ($result['type'] == '2' || $result['type'] == '-1') {
80 80
 			$this->db->where(array("accountid"=>$result["id"]));
81
-		}else if($result['type'] == '0'){
82
-			if($result['reseller_id'] == 0){
81
+		} else if ($result['type'] == '0') {
82
+			if ($result['reseller_id'] == 0) {
83 83
 				$this->db->where(array("accountid"=>"1"));
84
-			}else{
84
+			} else {
85 85
 				$this->db->where(array("accountid"=>$result["reseller_id"]));
86 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']));
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 90
 				
91
-				if($result_invoice){
91
+				if ($result_invoice) {
92 92
 					$this->db->where(array("accountid"=>$result["id"]));
93
-				}else{
93
+				} else {
94 94
 					$this->db->where(array("accountid"=>"1"));
95 95
 				}
96 96
 				
97
-			}else{
98
-				$result_invoice = $this->common->get_field_name('id','invoice_conf', array("accountid" => $result['reseller_id']));
99
-				if($result_invoice){
97
+			} else {
98
+				$result_invoice = $this->common->get_field_name('id', 'invoice_conf', array("accountid" => $result['reseller_id']));
99
+				if ($result_invoice) {
100 100
 					$this->db->where(array("accountid"=>$result["reseller_id"]));
101
-				}else{
101
+				} else {
102 102
 					$this->db->where(array("accountid"=>"1"));
103 103
 				}
104 104
 			}
105
-		}else {
105
+		} else {
106 106
 			$this->db->where(array("accountid"=>"1"));
107 107
 		}
108 108
 		$res = $this->db->get("invoice_conf");
109 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" ;
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." ;
110
+	$data['user_logo'] = (isset($logo_arr[0]->logo) && $logo_arr[0]->logo != "") ? $logo_arr[0]->accountid."_".$logo_arr[0]->logo : "logo.png";
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 113
 		$this->session->set_userdata('user_logo', $data['user_logo']);
114 114
 		$this->session->set_userdata('user_header', $data['user_header']);
115 115
 		$this->session->set_userdata('user_footer', $data['user_footer']);
@@ -118,15 +118,15 @@  discard block
 block discarded – undo
118 118
                     if ($result['type'] == 0 || $result['type'] == 1) {
119 119
                         $menu_list = $this->permission->get_module_access($result['type']);
120 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/');
121
+                        if ($result['type'] == 1) {
122
+                            redirect(base_url().'dashboard/');
123
+                        } else {
124
+                            redirect(base_url().'user/user/');
125 125
                         }
126 126
                     } else {
127 127
                         $menu_list = $this->permission->get_module_access($result['type']);
128 128
                         $this->session->set_userdata('mode_cur', 'admin');
129
-                        redirect(base_url() . 'dashboard/');
129
+                        redirect(base_url().'dashboard/');
130 130
                     }
131 131
                 } else {
132 132
 		   
@@ -140,9 +140,9 @@  discard block
 block discarded – undo
140 140
 	$this->db->where(array("domain"=>$_SERVER["HTTP_HOST"]));
141 141
 	$res = $this->db->get("invoice_conf");
142 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" ;
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." ;
143
+	$data['user_logo'] = (isset($logo_arr[0]->logo) && $logo_arr[0]->logo != "") ? $logo_arr[0]->accountid."_".$logo_arr[0]->logo : "logo.png";
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 146
 	$this->session->set_userdata('user_logo', $data['user_logo']);
147 147
 	$this->session->set_userdata('user_header', $data['website_header']);
148 148
 	$this->session->set_userdata('user_footer', $data['website_footer']);
@@ -151,7 +151,7 @@  discard block
 block discarded – undo
151 151
             $this->session->set_userdata('user_login', FALSE);
152 152
             $data['app_name'] = 'ASTPP - Open Source Billing Solution';
153 153
             $this->load->view('view_login', $data);
154
-        }else {
154
+        } else {
155 155
 	/*
156 156
 	*
157 157
 	* Purpose : Display logo based on domain name
@@ -163,9 +163,9 @@  discard block
 block discarded – undo
163 163
 		  $logo_arr = $res->result();
164 164
 //print_r( $logo_arr );exit;
165 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." ;
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 169
 		
170 170
 		$this->session->set_userdata('user_logo', $data['user_logo']);
171 171
 		 $this->session->set_userdata('user_header', $data['user_header']);
@@ -173,7 +173,7 @@  discard block
 block discarded – undo
173 173
 	//              echo $data['user_logo'];exit;
174 174
 /***************************************************************************************/
175 175
 	    if ($this->session->userdata('logintype') == '2') {
176
-		redirect(base_url() . 'dashboard/');
176
+		redirect(base_url().'dashboard/');
177 177
 	    } else {
178 178
 		redirect(base_url().'user/user/');
179 179
 	    }
@@ -184,25 +184,25 @@  discard block
 block discarded – undo
184 184
         $this->session->sess_destroy();
185 185
         redirect(base_url());
186 186
     }
187
-  function paypal_response(){
188
-      if(count($_POST)>0)
187
+  function paypal_response() {
188
+      if (count($_POST) > 0)
189 189
       {
190
-        $response_arr=$_POST;
191
-	    $fp=fopen("/var/log/astpp/astpp_payment.log","w+");
190
+        $response_arr = $_POST;
191
+	    $fp = fopen("/var/log/astpp/astpp_payment.log", "w+");
192 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");
193
+	    fwrite($fp, "====================".$date."===============================\n");
194
+	    foreach ($response_arr as $key => $value) {	  
195
+		    fwrite($fp, $key.":::>".$value."\n");
196 196
 	    }
197 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){
198
+        if (($response_arr["payment_status"] == "Pending" || $response_arr["payment_status"] == "Complete" || $response_arr["payment_status"] == "Completed") && $payment_check == 0) {
199 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'];
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 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();
203
+            $paypal_fee = (array)$this->db->get_where("system", array("name" => "paypal_fee", "group_title"=>"paypal"))->first_row();
204 204
             $paypal_fee = $paypal_fee['value'];
205
-            $paypalfee = ($paypal_fee == 0)?'0':$response_arr["mc_gross"];
205
+            $paypalfee = ($paypal_fee == 0) ? '0' : $response_arr["mc_gross"];
206 206
             $account_data = (array)$this->db->get_where("accounts", array("id" => $response_arr["item_number"]))->first_row();
207 207
             $currency = (array)$this->db->get_where('currency', array("id"=>$account_data["currency_id"]))->first_row();
208 208
             $date = date('Y-m-d H:i:s');
@@ -216,35 +216,35 @@  discard block
 block discarded – undo
216 216
                 			"currency_rate"=>$currency["currencyrate"],
217 217
                 			"transaction_details"=>json_encode($response_arr),
218 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';
219
+             $paymentid = $this->db->insert('payment_transaction', $payment_trans_array);
220
+    	     $parent_id = $account_data['reseller_id'] > 0 ? $account_data['reseller_id'] : '-1';
221 221
 	     $payment_arr = array("accountid"=> $response_arr["item_number"],
222
-	     		"payment_mode"=>"1","credit"=>$balance_amt,
222
+	     		"payment_mode"=>"1", "credit"=>$balance_amt,
223 223
 	    		"type"=>"PAYPAL",
224 224
 	    		"payment_by"=>$parent_id,
225 225
 	    		"notes"=>"Payment Made by Paypal on date:-".$date,
226 226
 	    		"paypalid"=>$paymentid,
227 227
 		    	"txn_id"=>$response_arr["txn_id"],
228
-		    	'payment_date'=>gmdate('Y-m-d H:i:s',strtotime($response_arr['payment_date'])));
228
+		    	'payment_date'=>gmdate('Y-m-d H:i:s', strtotime($response_arr['payment_date'])));
229 229
 	     $this->db->insert('payments', $payment_arr);
230 230
 	     $this->db->select('invoiceid');
231
-	     $this->db->order_by('id','desc');
231
+	     $this->db->order_by('id', 'desc');
232 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')";
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 237
 	     $this->db->where($where);
238 238
 	     $this->db->select('*');
239 239
 	     $this->db->order_by('accountid', 'desc');
240 240
 	     $this->db->limit(1);
241 241
              $invoiceconf = $this->db->get('invoice_conf');
242 242
              $invoiceconf = (array)$invoiceconf->first_row();
243
-	     $invoice_prefix=$invoiceconf['invoice_prefix'];
243
+	     $invoice_prefix = $invoiceconf['invoice_prefix'];
244 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(
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 248
 			'created_date'=>$date,
249 249
 			'credit'=>$balance_amt,
250 250
 			'debit'=>'-',
@@ -254,34 +254,34 @@  discard block
 block discarded – undo
254 254
 			'description'=>"Payment Made by Paypal on date:-".$date,
255 255
 			'item_type'=>'PAYMENT',
256 256
 	  	        'before_balance'=>$account_data['balance'],
257
-			'after_balance'=>$account_data['balance']+$balance_amt,
257
+			'after_balance'=>$account_data['balance'] + $balance_amt,
258 258
 			);
259 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){
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 267
 			  $account_data = (array)$this->db->get_where("accounts", array("id" => $reseller_id))->first_row();
268 268
 			  $this->db->select('invoiceid');
269
-		          $this->db->order_by('id','desc');
269
+		          $this->db->order_by('id', 'desc');
270 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')";
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 275
 	                  $this->db->where($where);
276 276
 		          $this->db->select('*');
277 277
 		          $this->db->order_by('accountid', 'desc');
278 278
 		          $this->db->limit(1);
279 279
 		          $invoiceconf = $this->db->get('invoice_conf');
280 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;
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 285
 			  $payment_arr = array("accountid"=> $account_data["id"],
286 286
 	     					"payment_mode"=>"1",
287 287
 	     					"credit"=>$balance_amt,
@@ -290,9 +290,9 @@  discard block
 block discarded – undo
290 290
 	    					"notes"=>"Your account has been credited due to your customer account recharge done by paypal",
291 291
 				    		"paypalid"=>$paymentid,
292 292
 		    				"txn_id"=>$response_arr["txn_id"],
293
-		    				'payment_date'=>gmdate('Y-m-d H:i:s',strtotime($response_arr['payment_date'])));
293
+		    				'payment_date'=>gmdate('Y-m-d H:i:s', strtotime($response_arr['payment_date'])));
294 294
 	 	          $this->db->insert('payments', $payment_arr);
295
-			  $details_insert=array(
295
+			  $details_insert = array(
296 296
 				'created_date'=>$date,
297 297
 				'credit'=>$balance_amt,
298 298
 				'debit'=>'-',
@@ -302,26 +302,26 @@  discard block
 block discarded – undo
302 302
 				'description'=>"Your account has been credited due to your customer account recharge done by paypal",
303 303
 				'item_type'=>'PAYMENT',
304 304
 		  	        'before_balance'=>$account_data['balance'],
305
-				'after_balance'=>$account_data['balance']+$balance_amt,
305
+				'after_balance'=>$account_data['balance'] + $balance_amt,
306 306
 			   );
307 307
 		          $this->db->insert("invoice_details", $details_insert); 
308
-	          	  $this->db_model->update_balance($balance_amt,$account_data["id"],"credit");  			         
308
+	          	  $this->db_model->update_balance($balance_amt, $account_data["id"], "credit");  			         
309 309
 			}
310 310
 		      }
311 311
 		}
312
-		redirect(base_url() . 'user/user/');
312
+		redirect(base_url().'user/user/');
313 313
         }
314 314
       }         
315
-	redirect(base_url() . 'user/user/');
315
+	redirect(base_url().'user/user/');
316 316
     }
317
-    function generate_receipt($accountid,$amount,$accountinfo,$last_invoice_ID,$invoice_prefix,$due_date){
318
-		$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');            
319
-        $this->db->insert("invoices",$invoice_data);
317
+    function generate_receipt($accountid, $amount, $accountinfo, $last_invoice_ID, $invoice_prefix, $due_date) {
318
+		$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');            
319
+        $this->db->insert("invoices", $invoice_data);
320 320
         $invoiceid = $this->db->insert_id();    
321 321
         return  $invoiceid;  
322 322
     }
323 323
     
324
-    function get_language_text(){
324
+    function get_language_text() {
325 325
    // echo '<pre>'; print_r($_POST); exit;
326 326
       echo gettext($_POST['display']); 
327 327
  	}  
Please login to merge, or discard this patch.
Braces   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -78,31 +78,31 @@  discard block
 block discarded – undo
78 78
 		$this->db->select("*");
79 79
 		if($result['type'] == '2' || $result['type'] == '-1'){
80 80
 			$this->db->where(array("accountid"=>$result["id"]));
81
-		}else if($result['type'] == '0'){
81
+		} else if($result['type'] == '0'){
82 82
 			if($result['reseller_id'] == 0){
83 83
 				$this->db->where(array("accountid"=>"1"));
84
-			}else{
84
+			} else{
85 85
 				$this->db->where(array("accountid"=>$result["reseller_id"]));
86 86
 			}
87
-		}else if($result['type'] == '1'){
87
+		} else if($result['type'] == '1'){
88 88
 			if($result['reseller_id'] == 0){
89 89
 				$result_invoice = $this->common->get_field_name('id','invoice_conf', array("accountid" => $result['id']));
90 90
 				
91 91
 				if($result_invoice){
92 92
 					$this->db->where(array("accountid"=>$result["id"]));
93
-				}else{
93
+				} else{
94 94
 					$this->db->where(array("accountid"=>"1"));
95 95
 				}
96 96
 				
97
-			}else{
97
+			} else{
98 98
 				$result_invoice = $this->common->get_field_name('id','invoice_conf', array("accountid" => $result['reseller_id']));
99 99
 				if($result_invoice){
100 100
 					$this->db->where(array("accountid"=>$result["reseller_id"]));
101
-				}else{
101
+				} else{
102 102
 					$this->db->where(array("accountid"=>"1"));
103 103
 				}
104 104
 			}
105
-		}else {
105
+		} else {
106 106
 			$this->db->where(array("accountid"=>"1"));
107 107
 		}
108 108
 		$res = $this->db->get("invoice_conf");
@@ -120,7 +120,7 @@  discard block
 block discarded – undo
120 120
                         $this->session->set_userdata('mode_cur', 'user');
121 121
                         if($result['type'] == 1){
122 122
                             redirect(base_url() . 'dashboard/');
123
-                        }else{
123
+                        } else{
124 124
                             redirect(base_url() . 'user/user/');
125 125
                         }
126 126
                     } else {
@@ -151,7 +151,7 @@  discard block
 block discarded – undo
151 151
             $this->session->set_userdata('user_login', FALSE);
152 152
             $data['app_name'] = 'ASTPP - Open Source Billing Solution';
153 153
             $this->load->view('view_login', $data);
154
-        }else {
154
+        } else {
155 155
 	/*
156 156
 	*
157 157
 	* Purpose : Display logo based on domain name
Please login to merge, or discard this patch.
web_interface/astpp/application/modules/rates/models/rates_model.php 4 patches
Doc Comments   +3 added lines patch added patch discarded remove patch
@@ -332,6 +332,9 @@
 block discarded – undo
332 332
 ASTPP  3.0
333 333
 Rate insert
334 334
 *************/
335
+    /**
336
+     * @param string $table_name
337
+     */
335 338
     function insert_if_not_exitst($add_array,$table_name){
336 339
         $insert_str = "Insert into $table_name (";
337 340
         $insert_key = "";
Please login to merge, or discard this patch.
Indentation   +260 added lines, -260 removed lines patch added patch discarded remove patch
@@ -22,97 +22,97 @@  discard block
 block discarded – undo
22 22
 ###############################################################################
23 23
 class rates_model extends CI_Model {
24 24
 
25
-    function rates_model() {
26
-        parent::__construct();
27
-    }
25
+	function rates_model() {
26
+		parent::__construct();
27
+	}
28 28
 
29
-    function get_termination_rates_list($flag, $start = 0, $limit = 0) {
30
-        $this->db_model->build_search('termination_rates_list_search');
29
+	function get_termination_rates_list($flag, $start = 0, $limit = 0) {
30
+		$this->db_model->build_search('termination_rates_list_search');
31 31
 /********
32 32
 ASTPP  3.0 
33 33
 Batch Delete
34 34
 ********/
35
-        if($this->session->userdata('advance_batch_delete') == 1){
36
-           $this->db->where(array("trunk_id >"=>"0"));
37
-           $this->db->delete("outbound_routes");
38
-           $this->session->set_userdata('advance_batch_delete','0');
39
-	       $this->session->unset_userdata('advance_batch_delete');
35
+		if($this->session->userdata('advance_batch_delete') == 1){
36
+		   $this->db->where(array("trunk_id >"=>"0"));
37
+		   $this->db->delete("outbound_routes");
38
+		   $this->session->set_userdata('advance_batch_delete','0');
39
+		   $this->session->unset_userdata('advance_batch_delete');
40 40
 	   }
41 41
 /**************/
42
-        if ($flag) {
43
-            $query = $this->db_model->select("*", "outbound_routes", "", "id", "ASC", $limit, $start);
44
-        } else {
45
-            $query = $this->db_model->countQuery("*", "outbound_routes", "");
46
-        }
47
-        return $query;
48
-    }
49
-    function get_termination_rate($flag, $start = 0, $limit = 0, $export = true) {
50
-        $this->db_model->build_search('termination_rates_list_search');
51
-        $this->db->from('outbound_routes');
52
-        if ($flag) {
53
-            if ($export)
54
-                $this->db->limit($limit, $start);
55
-            $result = $this->db->get();
56
-        }else {
57
-            $result = $this->db->count_all_results();
58
-        }
59
-        return $result;
60
-    }
42
+		if ($flag) {
43
+			$query = $this->db_model->select("*", "outbound_routes", "", "id", "ASC", $limit, $start);
44
+		} else {
45
+			$query = $this->db_model->countQuery("*", "outbound_routes", "");
46
+		}
47
+		return $query;
48
+	}
49
+	function get_termination_rate($flag, $start = 0, $limit = 0, $export = true) {
50
+		$this->db_model->build_search('termination_rates_list_search');
51
+		$this->db->from('outbound_routes');
52
+		if ($flag) {
53
+			if ($export)
54
+				$this->db->limit($limit, $start);
55
+			$result = $this->db->get();
56
+		}else {
57
+			$result = $this->db->count_all_results();
58
+		}
59
+		return $result;
60
+	}
61 61
 
62
-    function get_origination_rate($flag, $start = 0, $limit = 0, $export = true) {
63
-        $this->db_model->build_search('origination_rate_list_search');
64
-	    if ($this->session->userdata('logintype') == 1 || $this->session->userdata('logintype') == 5) {
65
-            $account_data = $this->session->userdata("accountinfo");
66
-            $reseller = $account_data['id'];
67
-            $where = array("reseller_id" => $reseller);
68
-        } else {
69
-            $where = array('reseller_id'=>'0');
70
-        }
62
+	function get_origination_rate($flag, $start = 0, $limit = 0, $export = true) {
63
+		$this->db_model->build_search('origination_rate_list_search');
64
+		if ($this->session->userdata('logintype') == 1 || $this->session->userdata('logintype') == 5) {
65
+			$account_data = $this->session->userdata("accountinfo");
66
+			$reseller = $account_data['id'];
67
+			$where = array("reseller_id" => $reseller);
68
+		} else {
69
+			$where = array('reseller_id'=>'0');
70
+		}
71 71
        
72
-	    $this->db_model->build_search('origination_rate_list_search');
73
-        if ($flag) {
74
-            if ($export)
75
-                $this->db->limit($limit, $start);
76
-            $result = $this->db_model->select("*", "routes", $where, "id", "ASC", $limit, $start);
77
-        }else {
78
-            $result = $this->db_model->countQuery("*", "routes", $where);
79
-        }
72
+		$this->db_model->build_search('origination_rate_list_search');
73
+		if ($flag) {
74
+			if ($export)
75
+				$this->db->limit($limit, $start);
76
+			$result = $this->db_model->select("*", "routes", $where, "id", "ASC", $limit, $start);
77
+		}else {
78
+			$result = $this->db_model->countQuery("*", "routes", $where);
79
+		}
80 80
 // 	echo "<pre>";print_r($result->result());exit;
81
-        return $result;
82
-    }
81
+		return $result;
82
+	}
83 83
 
84
-    function get_origination_rate_for_user($flag, $start = 0, $limit = 0,$export = true) {
85
-        $this->db_model->build_search('origination_rate_list_search');
84
+	function get_origination_rate_for_user($flag, $start = 0, $limit = 0,$export = true) {
85
+		$this->db_model->build_search('origination_rate_list_search');
86 86
 
87
-        $account_data = $this->session->userdata("accountinfo");
87
+		$account_data = $this->session->userdata("accountinfo");
88 88
 
89
-        $where = array("pricelist_id" => $account_data["pricelist_id"]);
89
+		$where = array("pricelist_id" => $account_data["pricelist_id"]);
90 90
 
91
-        $this->db_model->build_search('origination_rate_list_search');
92
-        if ($flag) {
93
-            if ($export)
94
-                $this->db->limit($limit, $start);
95
-            $result = $this->db_model->select("*", "routes", $where, "id", "ASC", $limit, $start);
96
-        }else {
97
-            $result = $this->db_model->countQuery("*", "routes", $where);
98
-        }
99
-        return $result;
100
-    }
91
+		$this->db_model->build_search('origination_rate_list_search');
92
+		if ($flag) {
93
+			if ($export)
94
+				$this->db->limit($limit, $start);
95
+			$result = $this->db_model->select("*", "routes", $where, "id", "ASC", $limit, $start);
96
+		}else {
97
+			$result = $this->db_model->countQuery("*", "routes", $where);
98
+		}
99
+		return $result;
100
+	}
101 101
 // ==============================================
102
-    function get_origination_rate_list($flag, $start = 0, $limit = 0) {
103
-        $this->db_model->build_search('origination_rate_list_search');
104
-        if ($this->session->userdata('logintype') == 1 || $this->session->userdata('logintype') == 5) {
105
-            $account_data = $this->session->userdata("accountinfo");
106
-            $where = array("reseller_id" => $account_data['id']);
107
-        } else {
108
-            $where = array('reseller_id'=>'0');
109
-        }        
102
+	function get_origination_rate_list($flag, $start = 0, $limit = 0) {
103
+		$this->db_model->build_search('origination_rate_list_search');
104
+		if ($this->session->userdata('logintype') == 1 || $this->session->userdata('logintype') == 5) {
105
+			$account_data = $this->session->userdata("accountinfo");
106
+			$where = array("reseller_id" => $account_data['id']);
107
+		} else {
108
+			$where = array('reseller_id'=>'0');
109
+		}        
110 110
 /***********
111 111
 ASTPP  3.0 
112 112
 Batch delete
113 113
 ************/
114
-        if($this->session->userdata('advance_batch_delete') == 1){
115
-            $this->db->where($where);
114
+		if($this->session->userdata('advance_batch_delete') == 1){
115
+			$this->db->where($where);
116 116
 			$this->db->delete("routes");
117 117
 			//echo $this->db->last_query(); exit;
118 118
 			$this->session->set_userdata('advance_batch_delete','0');
@@ -122,232 +122,232 @@  discard block
 block discarded – undo
122 122
 		$this->db_model->build_search('origination_rate_list_search');
123 123
 /***********************/
124 124
 
125
-        if ($flag) {
126
-            $query = $this->db_model->select("*", "routes", $where, "id", "ASC", $limit, $start);
127
-        } else {
128
-            $query = $this->db_model->countQuery("*", "routes", $where);
125
+		if ($flag) {
126
+			$query = $this->db_model->select("*", "routes", $where, "id", "ASC", $limit, $start);
127
+		} else {
128
+			$query = $this->db_model->countQuery("*", "routes", $where);
129 129
             
130
-        }
131
-        //echo $this->db->last_query();
132
-        return $query;
133
-    }
134
-    function getunblocked_pattern_list($accountid,$flag, $start = 0, $limit = 0) {
135
-        $this->db_model->build_search('origination_rate_list_search');
136
-        if ($this->session->userdata('logintype') == 1 || $this->session->userdata('logintype') == 5) {
137
-            $account_data = $this->session->userdata("accountinfo");
138
-            $reseller = $account_data['id'];
139
-            $where = array("reseller_id" => $reseller, "status" => "0");
140
-        } else {
141
-            $where = array("status" => "0",'reseller_id'=>'0');
142
-        }
143
-        $where1 = '(pattern NOT IN (select blocked_patterns from block_patterns where accountid = "'.$accountid.'"))';
144
-        $this->db->where($where1);        
145
-        if ($flag) {
146
-            $query = $this->db_model->select("*", "routes", $where, "id", "ASC", $limit, $start);
130
+		}
131
+		//echo $this->db->last_query();
132
+		return $query;
133
+	}
134
+	function getunblocked_pattern_list($accountid,$flag, $start = 0, $limit = 0) {
135
+		$this->db_model->build_search('origination_rate_list_search');
136
+		if ($this->session->userdata('logintype') == 1 || $this->session->userdata('logintype') == 5) {
137
+			$account_data = $this->session->userdata("accountinfo");
138
+			$reseller = $account_data['id'];
139
+			$where = array("reseller_id" => $reseller, "status" => "0");
140
+		} else {
141
+			$where = array("status" => "0",'reseller_id'=>'0');
142
+		}
143
+		$where1 = '(pattern NOT IN (select blocked_patterns from block_patterns where accountid = "'.$accountid.'"))';
144
+		$this->db->where($where1);        
145
+		if ($flag) {
146
+			$query = $this->db_model->select("*", "routes", $where, "id", "ASC", $limit, $start);
147 147
 //             echo "<pre>"; print_r($query); exit;
148
-        } else {
149
-            $query = $this->db_model->countQuery("*", "routes", $where);
150
-        }
151
-        return $query;
152
-    }
153
-    function getunblocked_package_pattern($accountid,$flag, $start = 0, $limit = 0) {
154
-        $this->db_model->build_search('origination_rate_list_search');
155
-        if ($this->session->userdata('logintype') == 1 || $this->session->userdata('logintype') == 5) {
156
-            $account_data = $this->session->userdata("accountinfo");
157
-            $reseller = $account_data['id'];
158
-            $where = array("reseller_id" => $reseller, "status" => "0");
159
-        } else {
160
-            $where = array("status" => "0",'reseller_id'=>'0');
161
-        }
162
-        $where1 = '(pattern NOT IN (select DISTINCT patterns from package_patterns where package_id = "'.$accountid.'"))';
163
-        $this->db->where($where1);       
164
-        if ($flag) {
165
-            $query = $this->db_model->select("*", "routes", $where, "id", "ASC", $limit, $start);
166
-        } else {
167
-            $query = $this->db_model->countQuery("*", "routes", $where);
168
-        }
169
-        return $query;
170
-    }
148
+		} else {
149
+			$query = $this->db_model->countQuery("*", "routes", $where);
150
+		}
151
+		return $query;
152
+	}
153
+	function getunblocked_package_pattern($accountid,$flag, $start = 0, $limit = 0) {
154
+		$this->db_model->build_search('origination_rate_list_search');
155
+		if ($this->session->userdata('logintype') == 1 || $this->session->userdata('logintype') == 5) {
156
+			$account_data = $this->session->userdata("accountinfo");
157
+			$reseller = $account_data['id'];
158
+			$where = array("reseller_id" => $reseller, "status" => "0");
159
+		} else {
160
+			$where = array("status" => "0",'reseller_id'=>'0');
161
+		}
162
+		$where1 = '(pattern NOT IN (select DISTINCT patterns from package_patterns where package_id = "'.$accountid.'"))';
163
+		$this->db->where($where1);       
164
+		if ($flag) {
165
+			$query = $this->db_model->select("*", "routes", $where, "id", "ASC", $limit, $start);
166
+		} else {
167
+			$query = $this->db_model->countQuery("*", "routes", $where);
168
+		}
169
+		return $query;
170
+	}
171 171
 
172
-    function get_origination_rate_list_for_user($flag, $start = 0, $limit = 0) {
173
-        $this->db_model->build_search('user_rates_list_search');
172
+	function get_origination_rate_list_for_user($flag, $start = 0, $limit = 0) {
173
+		$this->db_model->build_search('user_rates_list_search');
174 174
 
175
-        $account_data = $this->session->userdata("accountinfo");
176
-        $where = array("pricelist_id" => $account_data["pricelist_id"],"status" => '0');
175
+		$account_data = $this->session->userdata("accountinfo");
176
+		$where = array("pricelist_id" => $account_data["pricelist_id"],"status" => '0');
177 177
 
178
-        $this->db_model->build_search('origination_rate_list_search');
179
-        if ($flag) {
180
-            $query = $this->db_model->select("*", "routes", $where, "id", "ASC", $limit, $start);
181
-        } else {
182
-            $query = $this->db_model->countQuery("*", "routes", $where);
183
-        }
184
-        return $query;
185
-    }
178
+		$this->db_model->build_search('origination_rate_list_search');
179
+		if ($flag) {
180
+			$query = $this->db_model->select("*", "routes", $where, "id", "ASC", $limit, $start);
181
+		} else {
182
+			$query = $this->db_model->countQuery("*", "routes", $where);
183
+		}
184
+		return $query;
185
+	}
186 186
 
187 187
 
188
-    function add_termination_rate($add_array) {
189
-        unset($add_array["action"]);
190
-        if ($this->session->userdata('logintype') == 1 || $this->session->userdata('logintype') == 5) {
191
-            $account_data = $this->session->userdata("accountinfo");
192
-            $reseller = $account_data['id'];
193
-            $add_array['reseller_id'] = $reseller;
194
-        }
195
-        $add_array['pattern'] = "^" . $add_array['pattern'] . ".*";
196
-        $add_array['prepend'] = $add_array['prepend'];
197
-        /*
188
+	function add_termination_rate($add_array) {
189
+		unset($add_array["action"]);
190
+		if ($this->session->userdata('logintype') == 1 || $this->session->userdata('logintype') == 5) {
191
+			$account_data = $this->session->userdata("accountinfo");
192
+			$reseller = $account_data['id'];
193
+			$add_array['reseller_id'] = $reseller;
194
+		}
195
+		$add_array['pattern'] = "^" . $add_array['pattern'] . ".*";
196
+		$add_array['prepend'] = $add_array['prepend'];
197
+		/*
198 198
         ASTPP  3.0 
199 199
          add creation date.
200 200
         */
201
-        $add_array['creation_date']=gmdate('Y-m-d H:i:s');
202
-        /*******************************************************/
203
-        $this->insert_if_not_exitst($add_array,"outbound_routes");
204
-        //$this->db->insert("outbound_routes", $add_array);
205
-        return true;
206
-    }
201
+		$add_array['creation_date']=gmdate('Y-m-d H:i:s');
202
+		/*******************************************************/
203
+		$this->insert_if_not_exitst($add_array,"outbound_routes");
204
+		//$this->db->insert("outbound_routes", $add_array);
205
+		return true;
206
+	}
207 207
 
208
-    function edit_termination_rate($data, $id) {
209
-        unset($data["action"]);
210
-        /*
208
+	function edit_termination_rate($data, $id) {
209
+		unset($data["action"]);
210
+		/*
211 211
         ASTPP  3.0
212 212
          Edit time last modified date
213 213
         */
214
-        $data['last_modified_date']=gmdate('Y-m-d H:i:s');
215
-        /***************************************************/
216
-        $data['pattern'] = "^" . $data['pattern'] . ".*";
217
-        $this->db->where("id", $id);
218
-        $this->db->update("outbound_routes", $data);
219
-    }
214
+		$data['last_modified_date']=gmdate('Y-m-d H:i:s');
215
+		/***************************************************/
216
+		$data['pattern'] = "^" . $data['pattern'] . ".*";
217
+		$this->db->where("id", $id);
218
+		$this->db->update("outbound_routes", $data);
219
+	}
220 220
 
221
-    function remove_termination_rate($id) {
222
-        $this->db->where("id", $id);
223
-        $this->db->delete("outbound_routes");
224
-        return true;
225
-    }
221
+	function remove_termination_rate($id) {
222
+		$this->db->where("id", $id);
223
+		$this->db->delete("outbound_routes");
224
+		return true;
225
+	}
226 226
 
227
-    function add_origination_rate($add_array) {
227
+	function add_origination_rate($add_array) {
228 228
 		
229
-        unset($add_array["action"]);
230
-        /*
229
+		unset($add_array["action"]);
230
+		/*
231 231
         ASTPP  3.0 
232 232
         ADD time put creation date in routes table 
233 233
         */
234
-        $add_array['creation_date']=gmdate('Y-m-d H:i:s');
235
-        /**********************************************/
236
-        if ($this->session->userdata('logintype') == 1 || $this->session->userdata('logintype') == 5) {
237
-            $account_data = $this->session->userdata("accountinfo");
238
-            $reseller = $account_data['id'];
239
-            $add_array['reseller_id'] = $reseller;
240
-        }
234
+		$add_array['creation_date']=gmdate('Y-m-d H:i:s');
235
+		/**********************************************/
236
+		if ($this->session->userdata('logintype') == 1 || $this->session->userdata('logintype') == 5) {
237
+			$account_data = $this->session->userdata("accountinfo");
238
+			$reseller = $account_data['id'];
239
+			$add_array['reseller_id'] = $reseller;
240
+		}
241 241
 	
242
-        $add_array['pattern'] = "^" . $add_array['pattern'] . ".*";
242
+		$add_array['pattern'] = "^" . $add_array['pattern'] . ".*";
243 243
 /*************
244 244
 ASTPP  3.0 
245 245
 Rate insert
246 246
 *************/
247
-        $this->insert_if_not_exitst($add_array,"routes");
247
+		$this->insert_if_not_exitst($add_array,"routes");
248 248
 //        $this->db->insert("routes", $add_array);
249 249
 /*******************************/
250
-        return true;
251
-    }
250
+		return true;
251
+	}
252 252
 
253
-    function edit_origination_rate($data, $id) {
254
-        unset($data["action"]);
255
-        /*
253
+	function edit_origination_rate($data, $id) {
254
+		unset($data["action"]);
255
+		/*
256 256
         ASTPP  3.0
257 257
          Edit tile last modified date update
258 258
         */
259
-        $data['last_modified_date']=gmdate('Y-m-d H:i:s');
260
-        /********************************************************/
261
-        $data['pattern'] = "^" . $data['pattern'] . ".*";
262
-        $this->db->where("id", $id);
263
-        $this->db->update("routes", $data);
264
-    }
259
+		$data['last_modified_date']=gmdate('Y-m-d H:i:s');
260
+		/********************************************************/
261
+		$data['pattern'] = "^" . $data['pattern'] . ".*";
262
+		$this->db->where("id", $id);
263
+		$this->db->update("routes", $data);
264
+	}
265 265
 
266
-    function remove_origination_rate($id) {
267
-        $this->db->where("id", $id);
268
-        $this->db->delete("routes");
269
-        return true;
270
-    }
266
+	function remove_origination_rate($id) {
267
+		$this->db->where("id", $id);
268
+		$this->db->delete("routes");
269
+		return true;
270
+	}
271 271
 
272
-    function get_trunk_name($field_value) {
273
-        $this->db->where("name", $field_value);
274
-        $query = $this->db->get('trunks');
275
-        $data = $query->result();
276
-        if ($query->num_rows > 0)
277
-            return $data[0]->id;
278
-        else
279
-            return '';
280
-    }
272
+	function get_trunk_name($field_value) {
273
+		$this->db->where("name", $field_value);
274
+		$query = $this->db->get('trunks');
275
+		$data = $query->result();
276
+		if ($query->num_rows > 0)
277
+			return $data[0]->id;
278
+		else
279
+			return '';
280
+	}
281 281
 
282
-    function bulk_insert_termination_rate($field_value) {
283
-        //$this->db->insert_batch('outbound_routes', $field_value);
284
-        $this->db->insert_on_duplicate_update_batch('outbound_routes', $field_value);
285
-        $affected_row = $this->db->affected_rows();
286
-        return $affected_row;
287
-    }
282
+	function bulk_insert_termination_rate($field_value) {
283
+		//$this->db->insert_batch('outbound_routes', $field_value);
284
+		$this->db->insert_on_duplicate_update_batch('outbound_routes', $field_value);
285
+		$affected_row = $this->db->affected_rows();
286
+		return $affected_row;
287
+	}
288 288
 
289
-    function bulk_insert_origination_rate($inserted_array) {
290
-        //$this->db->insert_batch('routes', $inserted_array);
291
-        $this->db->insert_on_duplicate_update_batch('routes', $inserted_array);
292
-        $affected_row = $this->db->affected_rows();
293
-        return $affected_row;
294
-    }
295
-    function termination_rate_batch_update($update_array){
296
-        $this->db_model->build_search('termination_rates_list_search');
297
-        if ($this->session->userdata('logintype') == 1 || $this->session->userdata('logintype') == 5) {
298
-            $account_data = $this->session->userdata("accountinfo");
299
-            $this->db->where("reseller_id",$account_data['id']);
300
-        }
289
+	function bulk_insert_origination_rate($inserted_array) {
290
+		//$this->db->insert_batch('routes', $inserted_array);
291
+		$this->db->insert_on_duplicate_update_batch('routes', $inserted_array);
292
+		$affected_row = $this->db->affected_rows();
293
+		return $affected_row;
294
+	}
295
+	function termination_rate_batch_update($update_array){
296
+		$this->db_model->build_search('termination_rates_list_search');
297
+		if ($this->session->userdata('logintype') == 1 || $this->session->userdata('logintype') == 5) {
298
+			$account_data = $this->session->userdata("accountinfo");
299
+			$this->db->where("reseller_id",$account_data['id']);
300
+		}
301 301
         
302
-        $updateflg = $this->db_model->build_batch_update_array($update_array);
303
-        if($updateflg)
304
-            return $this->db->update("outbound_routes");
305
-        else
306
-            return false;
307
-    }
308
-    function origination_rate_batch_update($update_array){
309
-        $this->db_model->build_search('origination_rate_list_search');
310
-        if ($this->session->userdata('logintype') == 1 || $this->session->userdata('logintype') == 5) {
311
-            $account_data = $this->session->userdata("accountinfo");
312
-            $this->db->where("reseller_id",$account_data['id']);
313
-        }
314
-        $updateflg = $this->db_model->build_batch_update_array($update_array);
315
-        if($updateflg)
316
-            return $this->db->update("routes");
317
-        else
318
-            return false;
319
-    }
320
-    function getreseller_rates_list($flag, $start = 0, $limit = 0,$export=false) {
321
-        $this->db_model->build_search('resellerrates_list_search');
322
-        $account_data = $this->session->userdata("accountinfo");
323
-        $where = array("status"=>"0","pricelist_id" => $account_data["pricelist_id"]);
324
-        if ($flag) {
325
-            $query = $this->db_model->select("*", "routes", $where, "id", "ASC", $limit, $start);            
326
-        } else {
327
-            $query = $this->db_model->countQuery("*", "routes", $where);
328
-        }
329
-        return $query;
330
-    }
302
+		$updateflg = $this->db_model->build_batch_update_array($update_array);
303
+		if($updateflg)
304
+			return $this->db->update("outbound_routes");
305
+		else
306
+			return false;
307
+	}
308
+	function origination_rate_batch_update($update_array){
309
+		$this->db_model->build_search('origination_rate_list_search');
310
+		if ($this->session->userdata('logintype') == 1 || $this->session->userdata('logintype') == 5) {
311
+			$account_data = $this->session->userdata("accountinfo");
312
+			$this->db->where("reseller_id",$account_data['id']);
313
+		}
314
+		$updateflg = $this->db_model->build_batch_update_array($update_array);
315
+		if($updateflg)
316
+			return $this->db->update("routes");
317
+		else
318
+			return false;
319
+	}
320
+	function getreseller_rates_list($flag, $start = 0, $limit = 0,$export=false) {
321
+		$this->db_model->build_search('resellerrates_list_search');
322
+		$account_data = $this->session->userdata("accountinfo");
323
+		$where = array("status"=>"0","pricelist_id" => $account_data["pricelist_id"]);
324
+		if ($flag) {
325
+			$query = $this->db_model->select("*", "routes", $where, "id", "ASC", $limit, $start);            
326
+		} else {
327
+			$query = $this->db_model->countQuery("*", "routes", $where);
328
+		}
329
+		return $query;
330
+	}
331 331
 /*************
332 332
 ASTPP  3.0
333 333
 Rate insert
334 334
 *************/
335
-    function insert_if_not_exitst($add_array,$table_name){
336
-        $insert_str = "Insert into $table_name (";
337
-        $insert_key = "";
338
-        $insert_value = "";
339
-        $update_str = "";
340
-        foreach($add_array as $key => $value){
341
-           if($key != 'id'){
342
-                   $insert_key .= $key.",";
343
-                   $insert_value .= "'$value',";   
344
-                   $update_str .= $key." = '$value',";
345
-           }
346
-        }
347
-        $insert_key = rtrim($insert_key,",");
348
-        $insert_value = rtrim($insert_value,",");
349
-        $update_str = rtrim($update_str,",");
350
-        $insert_str .= $insert_key.") values"."(".$insert_value.")  ON DUPLICATE KEY UPDATE $update_str";
351
-        $this->db->query($insert_str);
352
-    }   
335
+	function insert_if_not_exitst($add_array,$table_name){
336
+		$insert_str = "Insert into $table_name (";
337
+		$insert_key = "";
338
+		$insert_value = "";
339
+		$update_str = "";
340
+		foreach($add_array as $key => $value){
341
+		   if($key != 'id'){
342
+				   $insert_key .= $key.",";
343
+				   $insert_value .= "'$value',";   
344
+				   $update_str .= $key." = '$value',";
345
+		   }
346
+		}
347
+		$insert_key = rtrim($insert_key,",");
348
+		$insert_value = rtrim($insert_value,",");
349
+		$update_str = rtrim($update_str,",");
350
+		$insert_str .= $insert_key.") values"."(".$insert_value.")  ON DUPLICATE KEY UPDATE $update_str";
351
+		$this->db->query($insert_str);
352
+	}   
353 353
 }
Please login to merge, or discard this patch.
Spacing   +37 added lines, -37 removed lines patch added patch discarded remove patch
@@ -32,10 +32,10 @@  discard block
 block discarded – undo
32 32
 ASTPP  3.0 
33 33
 Batch Delete
34 34
 ********/
35
-        if($this->session->userdata('advance_batch_delete') == 1){
35
+        if ($this->session->userdata('advance_batch_delete') == 1) {
36 36
            $this->db->where(array("trunk_id >"=>"0"));
37 37
            $this->db->delete("outbound_routes");
38
-           $this->session->set_userdata('advance_batch_delete','0');
38
+           $this->session->set_userdata('advance_batch_delete', '0');
39 39
 	       $this->session->unset_userdata('advance_batch_delete');
40 40
 	   }
41 41
 /**************/
@@ -53,7 +53,7 @@  discard block
 block discarded – undo
53 53
             if ($export)
54 54
                 $this->db->limit($limit, $start);
55 55
             $result = $this->db->get();
56
-        }else {
56
+        } else {
57 57
             $result = $this->db->count_all_results();
58 58
         }
59 59
         return $result;
@@ -74,14 +74,14 @@  discard block
 block discarded – undo
74 74
             if ($export)
75 75
                 $this->db->limit($limit, $start);
76 76
             $result = $this->db_model->select("*", "routes", $where, "id", "ASC", $limit, $start);
77
-        }else {
77
+        } else {
78 78
             $result = $this->db_model->countQuery("*", "routes", $where);
79 79
         }
80 80
 // 	echo "<pre>";print_r($result->result());exit;
81 81
         return $result;
82 82
     }
83 83
 
84
-    function get_origination_rate_for_user($flag, $start = 0, $limit = 0,$export = true) {
84
+    function get_origination_rate_for_user($flag, $start = 0, $limit = 0, $export = true) {
85 85
         $this->db_model->build_search('origination_rate_list_search');
86 86
 
87 87
         $account_data = $this->session->userdata("accountinfo");
@@ -93,7 +93,7 @@  discard block
 block discarded – undo
93 93
             if ($export)
94 94
                 $this->db->limit($limit, $start);
95 95
             $result = $this->db_model->select("*", "routes", $where, "id", "ASC", $limit, $start);
96
-        }else {
96
+        } else {
97 97
             $result = $this->db_model->countQuery("*", "routes", $where);
98 98
         }
99 99
         return $result;
@@ -111,11 +111,11 @@  discard block
 block discarded – undo
111 111
 ASTPP  3.0 
112 112
 Batch delete
113 113
 ************/
114
-        if($this->session->userdata('advance_batch_delete') == 1){
114
+        if ($this->session->userdata('advance_batch_delete') == 1) {
115 115
             $this->db->where($where);
116 116
 			$this->db->delete("routes");
117 117
 			//echo $this->db->last_query(); exit;
118
-			$this->session->set_userdata('advance_batch_delete','0');
118
+			$this->session->set_userdata('advance_batch_delete', '0');
119 119
 			$this->session->unset_userdata('advance_batch_delete');
120 120
 			
121 121
 		}
@@ -131,14 +131,14 @@  discard block
 block discarded – undo
131 131
         //echo $this->db->last_query();
132 132
         return $query;
133 133
     }
134
-    function getunblocked_pattern_list($accountid,$flag, $start = 0, $limit = 0) {
134
+    function getunblocked_pattern_list($accountid, $flag, $start = 0, $limit = 0) {
135 135
         $this->db_model->build_search('origination_rate_list_search');
136 136
         if ($this->session->userdata('logintype') == 1 || $this->session->userdata('logintype') == 5) {
137 137
             $account_data = $this->session->userdata("accountinfo");
138 138
             $reseller = $account_data['id'];
139 139
             $where = array("reseller_id" => $reseller, "status" => "0");
140 140
         } else {
141
-            $where = array("status" => "0",'reseller_id'=>'0');
141
+            $where = array("status" => "0", 'reseller_id'=>'0');
142 142
         }
143 143
         $where1 = '(pattern NOT IN (select blocked_patterns from block_patterns where accountid = "'.$accountid.'"))';
144 144
         $this->db->where($where1);        
@@ -150,14 +150,14 @@  discard block
 block discarded – undo
150 150
         }
151 151
         return $query;
152 152
     }
153
-    function getunblocked_package_pattern($accountid,$flag, $start = 0, $limit = 0) {
153
+    function getunblocked_package_pattern($accountid, $flag, $start = 0, $limit = 0) {
154 154
         $this->db_model->build_search('origination_rate_list_search');
155 155
         if ($this->session->userdata('logintype') == 1 || $this->session->userdata('logintype') == 5) {
156 156
             $account_data = $this->session->userdata("accountinfo");
157 157
             $reseller = $account_data['id'];
158 158
             $where = array("reseller_id" => $reseller, "status" => "0");
159 159
         } else {
160
-            $where = array("status" => "0",'reseller_id'=>'0');
160
+            $where = array("status" => "0", 'reseller_id'=>'0');
161 161
         }
162 162
         $where1 = '(pattern NOT IN (select DISTINCT patterns from package_patterns where package_id = "'.$accountid.'"))';
163 163
         $this->db->where($where1);       
@@ -173,7 +173,7 @@  discard block
 block discarded – undo
173 173
         $this->db_model->build_search('user_rates_list_search');
174 174
 
175 175
         $account_data = $this->session->userdata("accountinfo");
176
-        $where = array("pricelist_id" => $account_data["pricelist_id"],"status" => '0');
176
+        $where = array("pricelist_id" => $account_data["pricelist_id"], "status" => '0');
177 177
 
178 178
         $this->db_model->build_search('origination_rate_list_search');
179 179
         if ($flag) {
@@ -192,15 +192,15 @@  discard block
 block discarded – undo
192 192
             $reseller = $account_data['id'];
193 193
             $add_array['reseller_id'] = $reseller;
194 194
         }
195
-        $add_array['pattern'] = "^" . $add_array['pattern'] . ".*";
195
+        $add_array['pattern'] = "^".$add_array['pattern'].".*";
196 196
         $add_array['prepend'] = $add_array['prepend'];
197 197
         /*
198 198
         ASTPP  3.0 
199 199
          add creation date.
200 200
         */
201
-        $add_array['creation_date']=gmdate('Y-m-d H:i:s');
201
+        $add_array['creation_date'] = gmdate('Y-m-d H:i:s');
202 202
         /*******************************************************/
203
-        $this->insert_if_not_exitst($add_array,"outbound_routes");
203
+        $this->insert_if_not_exitst($add_array, "outbound_routes");
204 204
         //$this->db->insert("outbound_routes", $add_array);
205 205
         return true;
206 206
     }
@@ -211,9 +211,9 @@  discard block
 block discarded – undo
211 211
         ASTPP  3.0
212 212
          Edit time last modified date
213 213
         */
214
-        $data['last_modified_date']=gmdate('Y-m-d H:i:s');
214
+        $data['last_modified_date'] = gmdate('Y-m-d H:i:s');
215 215
         /***************************************************/
216
-        $data['pattern'] = "^" . $data['pattern'] . ".*";
216
+        $data['pattern'] = "^".$data['pattern'].".*";
217 217
         $this->db->where("id", $id);
218 218
         $this->db->update("outbound_routes", $data);
219 219
     }
@@ -231,7 +231,7 @@  discard block
 block discarded – undo
231 231
         ASTPP  3.0 
232 232
         ADD time put creation date in routes table 
233 233
         */
234
-        $add_array['creation_date']=gmdate('Y-m-d H:i:s');
234
+        $add_array['creation_date'] = gmdate('Y-m-d H:i:s');
235 235
         /**********************************************/
236 236
         if ($this->session->userdata('logintype') == 1 || $this->session->userdata('logintype') == 5) {
237 237
             $account_data = $this->session->userdata("accountinfo");
@@ -239,12 +239,12 @@  discard block
 block discarded – undo
239 239
             $add_array['reseller_id'] = $reseller;
240 240
         }
241 241
 	
242
-        $add_array['pattern'] = "^" . $add_array['pattern'] . ".*";
242
+        $add_array['pattern'] = "^".$add_array['pattern'].".*";
243 243
 /*************
244 244
 ASTPP  3.0 
245 245
 Rate insert
246 246
 *************/
247
-        $this->insert_if_not_exitst($add_array,"routes");
247
+        $this->insert_if_not_exitst($add_array, "routes");
248 248
 //        $this->db->insert("routes", $add_array);
249 249
 /*******************************/
250 250
         return true;
@@ -256,9 +256,9 @@  discard block
 block discarded – undo
256 256
         ASTPP  3.0
257 257
          Edit tile last modified date update
258 258
         */
259
-        $data['last_modified_date']=gmdate('Y-m-d H:i:s');
259
+        $data['last_modified_date'] = gmdate('Y-m-d H:i:s');
260 260
         /********************************************************/
261
-        $data['pattern'] = "^" . $data['pattern'] . ".*";
261
+        $data['pattern'] = "^".$data['pattern'].".*";
262 262
         $this->db->where("id", $id);
263 263
         $this->db->update("routes", $data);
264 264
     }
@@ -292,35 +292,35 @@  discard block
 block discarded – undo
292 292
         $affected_row = $this->db->affected_rows();
293 293
         return $affected_row;
294 294
     }
295
-    function termination_rate_batch_update($update_array){
295
+    function termination_rate_batch_update($update_array) {
296 296
         $this->db_model->build_search('termination_rates_list_search');
297 297
         if ($this->session->userdata('logintype') == 1 || $this->session->userdata('logintype') == 5) {
298 298
             $account_data = $this->session->userdata("accountinfo");
299
-            $this->db->where("reseller_id",$account_data['id']);
299
+            $this->db->where("reseller_id", $account_data['id']);
300 300
         }
301 301
         
302 302
         $updateflg = $this->db_model->build_batch_update_array($update_array);
303
-        if($updateflg)
303
+        if ($updateflg)
304 304
             return $this->db->update("outbound_routes");
305 305
         else
306 306
             return false;
307 307
     }
308
-    function origination_rate_batch_update($update_array){
308
+    function origination_rate_batch_update($update_array) {
309 309
         $this->db_model->build_search('origination_rate_list_search');
310 310
         if ($this->session->userdata('logintype') == 1 || $this->session->userdata('logintype') == 5) {
311 311
             $account_data = $this->session->userdata("accountinfo");
312
-            $this->db->where("reseller_id",$account_data['id']);
312
+            $this->db->where("reseller_id", $account_data['id']);
313 313
         }
314 314
         $updateflg = $this->db_model->build_batch_update_array($update_array);
315
-        if($updateflg)
315
+        if ($updateflg)
316 316
             return $this->db->update("routes");
317 317
         else
318 318
             return false;
319 319
     }
320
-    function getreseller_rates_list($flag, $start = 0, $limit = 0,$export=false) {
320
+    function getreseller_rates_list($flag, $start = 0, $limit = 0, $export = false) {
321 321
         $this->db_model->build_search('resellerrates_list_search');
322 322
         $account_data = $this->session->userdata("accountinfo");
323
-        $where = array("status"=>"0","pricelist_id" => $account_data["pricelist_id"]);
323
+        $where = array("status"=>"0", "pricelist_id" => $account_data["pricelist_id"]);
324 324
         if ($flag) {
325 325
             $query = $this->db_model->select("*", "routes", $where, "id", "ASC", $limit, $start);            
326 326
         } else {
@@ -332,21 +332,21 @@  discard block
 block discarded – undo
332 332
 ASTPP  3.0
333 333
 Rate insert
334 334
 *************/
335
-    function insert_if_not_exitst($add_array,$table_name){
335
+    function insert_if_not_exitst($add_array, $table_name) {
336 336
         $insert_str = "Insert into $table_name (";
337 337
         $insert_key = "";
338 338
         $insert_value = "";
339 339
         $update_str = "";
340
-        foreach($add_array as $key => $value){
341
-           if($key != 'id'){
340
+        foreach ($add_array as $key => $value) {
341
+           if ($key != 'id') {
342 342
                    $insert_key .= $key.",";
343 343
                    $insert_value .= "'$value',";   
344 344
                    $update_str .= $key." = '$value',";
345 345
            }
346 346
         }
347
-        $insert_key = rtrim($insert_key,",");
348
-        $insert_value = rtrim($insert_value,",");
349
-        $update_str = rtrim($update_str,",");
347
+        $insert_key = rtrim($insert_key, ",");
348
+        $insert_value = rtrim($insert_value, ",");
349
+        $update_str = rtrim($update_str, ",");
350 350
         $insert_str .= $insert_key.") values"."(".$insert_value.")  ON DUPLICATE KEY UPDATE $update_str";
351 351
         $this->db->query($insert_str);
352 352
     }   
Please login to merge, or discard this patch.
Braces   +27 added lines, -21 removed lines patch added patch discarded remove patch
@@ -50,10 +50,11 @@  discard block
 block discarded – undo
50 50
         $this->db_model->build_search('termination_rates_list_search');
51 51
         $this->db->from('outbound_routes');
52 52
         if ($flag) {
53
-            if ($export)
54
-                $this->db->limit($limit, $start);
53
+            if ($export) {
54
+                            $this->db->limit($limit, $start);
55
+            }
55 56
             $result = $this->db->get();
56
-        }else {
57
+        } else {
57 58
             $result = $this->db->count_all_results();
58 59
         }
59 60
         return $result;
@@ -71,10 +72,11 @@  discard block
 block discarded – undo
71 72
        
72 73
 	    $this->db_model->build_search('origination_rate_list_search');
73 74
         if ($flag) {
74
-            if ($export)
75
-                $this->db->limit($limit, $start);
75
+            if ($export) {
76
+                            $this->db->limit($limit, $start);
77
+            }
76 78
             $result = $this->db_model->select("*", "routes", $where, "id", "ASC", $limit, $start);
77
-        }else {
79
+        } else {
78 80
             $result = $this->db_model->countQuery("*", "routes", $where);
79 81
         }
80 82
 // 	echo "<pre>";print_r($result->result());exit;
@@ -90,10 +92,11 @@  discard block
 block discarded – undo
90 92
 
91 93
         $this->db_model->build_search('origination_rate_list_search');
92 94
         if ($flag) {
93
-            if ($export)
94
-                $this->db->limit($limit, $start);
95
+            if ($export) {
96
+                            $this->db->limit($limit, $start);
97
+            }
95 98
             $result = $this->db_model->select("*", "routes", $where, "id", "ASC", $limit, $start);
96
-        }else {
99
+        } else {
97 100
             $result = $this->db_model->countQuery("*", "routes", $where);
98 101
         }
99 102
         return $result;
@@ -273,10 +276,11 @@  discard block
 block discarded – undo
273 276
         $this->db->where("name", $field_value);
274 277
         $query = $this->db->get('trunks');
275 278
         $data = $query->result();
276
-        if ($query->num_rows > 0)
277
-            return $data[0]->id;
278
-        else
279
-            return '';
279
+        if ($query->num_rows > 0) {
280
+                    return $data[0]->id;
281
+        } else {
282
+                    return '';
283
+        }
280 284
     }
281 285
 
282 286
     function bulk_insert_termination_rate($field_value) {
@@ -300,10 +304,11 @@  discard block
 block discarded – undo
300 304
         }
301 305
         
302 306
         $updateflg = $this->db_model->build_batch_update_array($update_array);
303
-        if($updateflg)
304
-            return $this->db->update("outbound_routes");
305
-        else
306
-            return false;
307
+        if($updateflg) {
308
+                    return $this->db->update("outbound_routes");
309
+        } else {
310
+                    return false;
311
+        }
307 312
     }
308 313
     function origination_rate_batch_update($update_array){
309 314
         $this->db_model->build_search('origination_rate_list_search');
@@ -312,10 +317,11 @@  discard block
 block discarded – undo
312 317
             $this->db->where("reseller_id",$account_data['id']);
313 318
         }
314 319
         $updateflg = $this->db_model->build_batch_update_array($update_array);
315
-        if($updateflg)
316
-            return $this->db->update("routes");
317
-        else
318
-            return false;
320
+        if($updateflg) {
321
+                    return $this->db->update("routes");
322
+        } else {
323
+                    return false;
324
+        }
319 325
     }
320 326
     function getreseller_rates_list($flag, $start = 0, $limit = 0,$export=false) {
321 327
         $this->db_model->build_search('resellerrates_list_search');
Please login to merge, or discard this patch.
web_interface/astpp/application/modules/signup/controllers/signup.php 4 patches
Doc Comments   +3 added lines patch added patch discarded remove patch
@@ -426,6 +426,9 @@
 block discarded – undo
426 426
         }
427 427
     }
428 428
 
429
+    /**
430
+     * @param string $temp_name
431
+     */
429 432
     function send_mail($account_id, $temp_name, $user_data) {
430 433
 		
431 434
 		
Please login to merge, or discard this patch.
Indentation   +422 added lines, -422 removed lines patch added patch discarded remove patch
@@ -24,464 +24,464 @@
 block discarded – undo
24 24
 
25 25
 class Signup extends MX_Controller {
26 26
 
27
-    function signup() {
28
-        parent::__construct();
29
-        $this->load->model('signup_model');
30
-        $this->load->helper('captcha');
31
-        $this->load->helper('template_inheritance');
32
-        //$this->load->library('form_validation');
33
-        $this->load->library('astpp/common');
34
-        $this->load->library('astpp/email_lib');
35
-        $this->load->model('db_model');
36
-        $this->load->model('common_model');
37
-        $this->load->library('session');
38
-        $this->load->library('encrypt');
39
-        $this->load->model('Astpp_common');
40
-
41
-        error_reporting(-1);
42
-        ini_set('display_errors', 'On');
43
-
44
-        $data['row'] = $this->signup_model->get_rate();
45
-    }
46
-
47
-    function index($key = "") {
48
-
49
-        if (Common_model::$global_config['system_config']['enable_signup'] == 1)
27
+	function signup() {
28
+		parent::__construct();
29
+		$this->load->model('signup_model');
30
+		$this->load->helper('captcha');
31
+		$this->load->helper('template_inheritance');
32
+		//$this->load->library('form_validation');
33
+		$this->load->library('astpp/common');
34
+		$this->load->library('astpp/email_lib');
35
+		$this->load->model('db_model');
36
+		$this->load->model('common_model');
37
+		$this->load->library('session');
38
+		$this->load->library('encrypt');
39
+		$this->load->model('Astpp_common');
40
+
41
+		error_reporting(-1);
42
+		ini_set('display_errors', 'On');
43
+
44
+		$data['row'] = $this->signup_model->get_rate();
45
+	}
46
+
47
+	function index($key = "") {
48
+
49
+		if (Common_model::$global_config['system_config']['enable_signup'] == 1)
50 50
 		{
51
-    		redirect(base_url());
51
+			redirect(base_url());
52 52
 		}
53 53
 
54
-        $userCaptcha = $this->input->post('userCaptcha');
55
-        $random_number = substr(number_format(time() * rand(), 0, '', ''), 0, 6);
56
-        $accountinfo=(array)$this->db->get_where('accounts',array('type'=>-1))->first_row();
57
-        $data['timezone_id'] = (!$accountinfo['timezone_id']) ? 1 : $accountinfo['timezone_id'];
58
-        $data['currency_id'] = (!$accountinfo['currency_id']) ? 1 : $accountinfo['currency_id'];
59
-        $data['country_id'] = (!$accountinfo['country_id']) ? 1 : $accountinfo['country_id'];
60
-
61
-        $vals = array(
62
-            'word' => $random_number,
63
-            'img_path' => getcwd() . '/assets/captcha/',
64
-            'img_url' => base_url() . 'assets/captcha/',
65
-            //'font_path' => './fonts/impact.ttf',
66
-            'img_width' => '243',
67
-            'img_height' => '50',
68
-            'expiration' => '3600'
69
-        );
70
-
71
-        if (isset($key) && $key != '') {
72
-            $data['key_unique'] = $key;
73
-        } else {
74
-            $data['key_unique'] = "admin";
75
-        }
76
-        $unique = $data['key_unique'];
77
-
78
-        if ($unique != "admin") {
79
-            $unique = $this->common->decode_params(trim($unique));
80
-            $decoded_str = $this->common->decode($unique);
81
-            $unique = $decoded_str;
82
-            $query = $this->db_model->getSelect("*", 'accounts', array('id' => $unique, "deleted" => "0"));
83
-            if ($query->num_rows() == 0) {
84
-                redirect(base_url() . "signup/signup_inactive");
85
-            }
86
-            if ($query->num_rows() > 0) {
87
-                $query = $query->result_array();
88
-                $query = $query[0];
89
-
90
-                if ($query['status'] != 0) {
91
-                    redirect(base_url() . "signup/signup_inactive");
92
-                }
93
-            }
94
-        }
95
-        $data['captcha'] = create_captcha($vals);
96
-        $this->session->set_userdata('captchaWord', $data['captcha']['word']);
97
-        $this->load->view('view_signup', $data);
98
-    }
99
-
100
-    public function check_captcha($str) {
101
-        $word = $this->session->userdata('captchaWord');
102
-        if (strcmp(strtoupper($str), strtoupper($word)) == 0) {
103
-            return true;
104
-        } else {
105
-            $this->form_validation->set_message('check_captcha', 'Please enter correct words!');
106
-            return false;
107
-        }
108
-    }
109
-
110
-    function terms_check() {
111
-        if (isset($_POST['agreeCheck']))
112
-            return true;
113
-        $this->form_validation->set_message('terms_check', 'THIS IS SOOOOO REQUIRED, DUDE!');
114
-        return false;
115
-    }
116
-
117
-     function signup_save($id = "") {
118
-        if (empty($_POST)) {
119
-            redirect(base_url() . "signup/");
120
-        } else {
121
-            $post_values = $this->input->post();
122
-            $userCaptcha = $this->input->post('userCaptcha');
123
-            $cnt_result = $this->db_model->countQuery("*", 'accounts', array('email' => $post_values['email']));
124
-
125
-            if ($userCaptcha != $this->session->userdata('captchaWord') || !filter_var($this->input->post('email'), FILTER_VALIDATE_EMAIL) || $cnt_result > 0) {
126
-                if (!filter_var($this->input->post('email'), FILTER_VALIDATE_EMAIL)) {
127
-                    $data['error']['email'] = "<div style='color: red;'> Please enter proper email </div>";
128
-                }
129
-                if ($userCaptcha != $this->session->userdata('captchaWord')) {
130
-                    $data['error']['userCaptcha'] = "<div style='color: red;'>Please enter valid Captcha code</div>";
131
-                }
132
-                if ($cnt_result > 0) {
133
-                    $data['error']['email'] = "<div style='color: red;'>Email Address already exists</div>";
134
-                }
135
-                $random_number = substr(number_format(time() * rand(), 0, '', ''), 0, 6);
136
-                $vals = array(
137
-                    'word' => $random_number,
138
-                    'img_path' => getcwd() . '/assets/captcha/',
139
-                    'img_url' => base_url() . 'assets/captcha/',
140
-                    //'font_path' => './fonts/impact.ttf',
141
-                    'img_width' => '243',
142
-                    'img_height' => '50',
143
-                    'expiration' => '3600'
144
-                );
145
-                //echo "<pre>"; print_r($_POST); exit;
146
-                if (isset($_POST['key_unique']) && $_POST['key_unique'] == "admin") {
147
-                    $data['key_unique'] = $_POST['key_unique'];
148
-                }
54
+		$userCaptcha = $this->input->post('userCaptcha');
55
+		$random_number = substr(number_format(time() * rand(), 0, '', ''), 0, 6);
56
+		$accountinfo=(array)$this->db->get_where('accounts',array('type'=>-1))->first_row();
57
+		$data['timezone_id'] = (!$accountinfo['timezone_id']) ? 1 : $accountinfo['timezone_id'];
58
+		$data['currency_id'] = (!$accountinfo['currency_id']) ? 1 : $accountinfo['currency_id'];
59
+		$data['country_id'] = (!$accountinfo['country_id']) ? 1 : $accountinfo['country_id'];
60
+
61
+		$vals = array(
62
+			'word' => $random_number,
63
+			'img_path' => getcwd() . '/assets/captcha/',
64
+			'img_url' => base_url() . 'assets/captcha/',
65
+			//'font_path' => './fonts/impact.ttf',
66
+			'img_width' => '243',
67
+			'img_height' => '50',
68
+			'expiration' => '3600'
69
+		);
70
+
71
+		if (isset($key) && $key != '') {
72
+			$data['key_unique'] = $key;
73
+		} else {
74
+			$data['key_unique'] = "admin";
75
+		}
76
+		$unique = $data['key_unique'];
77
+
78
+		if ($unique != "admin") {
79
+			$unique = $this->common->decode_params(trim($unique));
80
+			$decoded_str = $this->common->decode($unique);
81
+			$unique = $decoded_str;
82
+			$query = $this->db_model->getSelect("*", 'accounts', array('id' => $unique, "deleted" => "0"));
83
+			if ($query->num_rows() == 0) {
84
+				redirect(base_url() . "signup/signup_inactive");
85
+			}
86
+			if ($query->num_rows() > 0) {
87
+				$query = $query->result_array();
88
+				$query = $query[0];
89
+
90
+				if ($query['status'] != 0) {
91
+					redirect(base_url() . "signup/signup_inactive");
92
+				}
93
+			}
94
+		}
95
+		$data['captcha'] = create_captcha($vals);
96
+		$this->session->set_userdata('captchaWord', $data['captcha']['word']);
97
+		$this->load->view('view_signup', $data);
98
+	}
99
+
100
+	public function check_captcha($str) {
101
+		$word = $this->session->userdata('captchaWord');
102
+		if (strcmp(strtoupper($str), strtoupper($word)) == 0) {
103
+			return true;
104
+		} else {
105
+			$this->form_validation->set_message('check_captcha', 'Please enter correct words!');
106
+			return false;
107
+		}
108
+	}
109
+
110
+	function terms_check() {
111
+		if (isset($_POST['agreeCheck']))
112
+			return true;
113
+		$this->form_validation->set_message('terms_check', 'THIS IS SOOOOO REQUIRED, DUDE!');
114
+		return false;
115
+	}
116
+
117
+	 function signup_save($id = "") {
118
+		if (empty($_POST)) {
119
+			redirect(base_url() . "signup/");
120
+		} else {
121
+			$post_values = $this->input->post();
122
+			$userCaptcha = $this->input->post('userCaptcha');
123
+			$cnt_result = $this->db_model->countQuery("*", 'accounts', array('email' => $post_values['email']));
124
+
125
+			if ($userCaptcha != $this->session->userdata('captchaWord') || !filter_var($this->input->post('email'), FILTER_VALIDATE_EMAIL) || $cnt_result > 0) {
126
+				if (!filter_var($this->input->post('email'), FILTER_VALIDATE_EMAIL)) {
127
+					$data['error']['email'] = "<div style='color: red;'> Please enter proper email </div>";
128
+				}
129
+				if ($userCaptcha != $this->session->userdata('captchaWord')) {
130
+					$data['error']['userCaptcha'] = "<div style='color: red;'>Please enter valid Captcha code</div>";
131
+				}
132
+				if ($cnt_result > 0) {
133
+					$data['error']['email'] = "<div style='color: red;'>Email Address already exists</div>";
134
+				}
135
+				$random_number = substr(number_format(time() * rand(), 0, '', ''), 0, 6);
136
+				$vals = array(
137
+					'word' => $random_number,
138
+					'img_path' => getcwd() . '/assets/captcha/',
139
+					'img_url' => base_url() . 'assets/captcha/',
140
+					//'font_path' => './fonts/impact.ttf',
141
+					'img_width' => '243',
142
+					'img_height' => '50',
143
+					'expiration' => '3600'
144
+				);
145
+				//echo "<pre>"; print_r($_POST); exit;
146
+				if (isset($_POST['key_unique']) && $_POST['key_unique'] == "admin") {
147
+					$data['key_unique'] = $_POST['key_unique'];
148
+				}
149 149
 
150 150
 				$accountinfo=(array)$this->db->get_where('accounts',array('type'=>-1))->first_row();
151 151
 				$data['timezone_id'] = (!$accountinfo['timezone_id']) ? 1 : $accountinfo['timezone_id'];
152 152
 				$data['currency_id'] = (!$accountinfo['currency_id']) ? 1 : $accountinfo['currency_id'];
153 153
 				$data['country_id'] = (!$accountinfo['country_id']) ? 1 : $accountinfo['country_id'];
154 154
 
155
-                $data['timezone_id'] = (!$data['timezone_id']) ? 1 : $data['timezone_id'];
156
-                $data['currency_id'] = (!$data['currency_id']) ? 1 : $data['currency_id'];
157
-                $data['country_id'] = (!$data['country_id']) ? 1 : $data['country_id'];
155
+				$data['timezone_id'] = (!$data['timezone_id']) ? 1 : $data['timezone_id'];
156
+				$data['currency_id'] = (!$data['currency_id']) ? 1 : $data['currency_id'];
157
+				$data['country_id'] = (!$data['country_id']) ? 1 : $data['country_id'];
158 158
 
159
-                $data['value'] = $post_values;
160
-                $data['captcha'] = create_captcha($vals);
159
+				$data['value'] = $post_values;
160
+				$data['captcha'] = create_captcha($vals);
161 161
 
162
-                $this->session->set_userdata('captchaWord', $data['captcha']['word']);
163
-                $data['key_unique'] = $_POST['key_unique'];
164
-                $this->load->view('view_signup', $data);
165
-            } else {
166
-                //AVTLATP		
167
-                $user_data = $this->input->post();
162
+				$this->session->set_userdata('captchaWord', $data['captcha']['word']);
163
+				$data['key_unique'] = $_POST['key_unique'];
164
+				$this->load->view('view_signup', $data);
165
+			} else {
166
+				//AVTLATP		
167
+				$user_data = $this->input->post();
168 168
                
169
-                if (!isset($_POST['key_unique']) || !isset($_POST['email'])) {
170
-                    redirect(base_url() . "signup/");
171
-                }
172
-                $reseller_id = 0;
173
-                if (isset($_POST['key_unique']) && $_POST['key_unique'] != "admin") {
174
-                    $_POST['key_unique'] = $this->common->decode_params(trim($_POST['key_unique']));
175
-                    $decoded_str = $this->common->decode($_POST['key_unique']);
176
-                    $_POST['key_unique'] = $decoded_str;
177
-                    $user_data['key_unique'] = $_POST['key_unique'];
178
-                    $reseller_id = $user_data['key_unique'];
179
-                }
180
-                //echo "<pre>"; print_r($_POST); exit;
181
-                //AVTLATP
182
-                //Data want to insert or update
183
-                $user_data['status'] = "1";
184
-                $user_data['number'] = $this->common->find_uniq_rendno_customer(common_model::$global_config['system_config']['cardlength'], 'number', 'accounts');
185
-
186
-                $user_data['password'] = $this->common->encode($this->common->generate_password());
187
-                $user_data['pin'] = $this->common->generate_password();
188
-                $user_data['reseller_id'] = $reseller_id;
189
-                $user_data['posttoexternal'] = "0";
190
-
191
-                unset($user_data['userCaptcha']);
192
-                unset($user_data['action']);
193
-
194
-                $system_config = common_model::$global_config['system_config'];
195
-                $balance = $system_config["balance"];
196
-
197
-                /* $query = $this->db_model->getSelect("*", 'invoice_conf ', array('id' => $unique ,"deleted" => "0"));
169
+				if (!isset($_POST['key_unique']) || !isset($_POST['email'])) {
170
+					redirect(base_url() . "signup/");
171
+				}
172
+				$reseller_id = 0;
173
+				if (isset($_POST['key_unique']) && $_POST['key_unique'] != "admin") {
174
+					$_POST['key_unique'] = $this->common->decode_params(trim($_POST['key_unique']));
175
+					$decoded_str = $this->common->decode($_POST['key_unique']);
176
+					$_POST['key_unique'] = $decoded_str;
177
+					$user_data['key_unique'] = $_POST['key_unique'];
178
+					$reseller_id = $user_data['key_unique'];
179
+				}
180
+				//echo "<pre>"; print_r($_POST); exit;
181
+				//AVTLATP
182
+				//Data want to insert or update
183
+				$user_data['status'] = "1";
184
+				$user_data['number'] = $this->common->find_uniq_rendno_customer(common_model::$global_config['system_config']['cardlength'], 'number', 'accounts');
185
+
186
+				$user_data['password'] = $this->common->encode($this->common->generate_password());
187
+				$user_data['pin'] = $this->common->generate_password();
188
+				$user_data['reseller_id'] = $reseller_id;
189
+				$user_data['posttoexternal'] = "0";
190
+
191
+				unset($user_data['userCaptcha']);
192
+				unset($user_data['action']);
193
+
194
+				$system_config = common_model::$global_config['system_config'];
195
+				$balance = $system_config["balance"];
196
+
197
+				/* $query = $this->db_model->getSelect("*", 'invoice_conf ', array('id' => $unique ,"deleted" => "0"));
198 198
                   $query = $query->result_array(); */
199 199
 
200
-                $company_website = $system_config["company_website"];
201
-                $company_name = $system_config["company_name"];
200
+				$company_website = $system_config["company_website"];
201
+				$company_name = $system_config["company_name"];
202 202
 
203
-                //echo $company_name; exit;
204
-                $selection_rategroup_signup = $system_config["default_signup_rategroup"];
203
+				//echo $company_name; exit;
204
+				$selection_rategroup_signup = $system_config["default_signup_rategroup"];
205 205
 
206
-                if ($reseller_id != 0) {
207
-                    $result = $this->db_model->getSelect("*", "pricelists", array("reseller_id" => $reseller_id), "ASC");
208
-                    $result_arr = $result->result_array();
209
-                    $selection_rategroup_signup = $result_arr[0]['id'];
210
-                    $user_data['pricelist_id'] = (isset($selection_rategroup_signup) && $selection_rategroup_signup > 0 ) ? $selection_rategroup_signup : 0;
211
-                } else {
212
-                    $pricelist_id = $this->common->get_field_name('id', 'pricelists', array('name' => $selection_rategroup_signup));
213
-                    /* if($pricelis_id != "")
206
+				if ($reseller_id != 0) {
207
+					$result = $this->db_model->getSelect("*", "pricelists", array("reseller_id" => $reseller_id), "ASC");
208
+					$result_arr = $result->result_array();
209
+					$selection_rategroup_signup = $result_arr[0]['id'];
210
+					$user_data['pricelist_id'] = (isset($selection_rategroup_signup) && $selection_rategroup_signup > 0 ) ? $selection_rategroup_signup : 0;
211
+				} else {
212
+					$pricelist_id = $this->common->get_field_name('id', 'pricelists', array('name' => $selection_rategroup_signup));
213
+					/* if($pricelis_id != "")
214 214
                       $user_data['pricelist_id'] = $pricelis_id;
215 215
                       else
216 216
                       $user_data['pricelist_id'] = 0; */
217
-                    $user_data['pricelist_id'] = ($pricelist_id != "") ? $pricelist_id : 0;
218
-                }
219
-                $last_id='0';
220
-                //Insert or Update record
221
-                $signup_sipdevice_flag = $system_config['create_sipdevice'];
222
-                $last_id = $this->signup_model->add_user($user_data);
223
-                if ($last_id == "") {
224
-                    redirect(base_url() . "signup/signup_inactive");
225
-                }
226
-                if ($signup_sipdevice_flag == '0') {
227
-                    $query = $this->db_model->select("*", "sip_profiles", array('name' => "default"), "id", "ASC", '1', '0');
228
-                    $sip_id = $query->result_array();
229
-                    if($reseller_id > 0){
217
+					$user_data['pricelist_id'] = ($pricelist_id != "") ? $pricelist_id : 0;
218
+				}
219
+				$last_id='0';
220
+				//Insert or Update record
221
+				$signup_sipdevice_flag = $system_config['create_sipdevice'];
222
+				$last_id = $this->signup_model->add_user($user_data);
223
+				if ($last_id == "") {
224
+					redirect(base_url() . "signup/signup_inactive");
225
+				}
226
+				if ($signup_sipdevice_flag == '0') {
227
+					$query = $this->db_model->select("*", "sip_profiles", array('name' => "default"), "id", "ASC", '1', '0');
228
+					$sip_id = $query->result_array();
229
+					if($reseller_id > 0){
230 230
 						$reseller_id = $reseller_id;
231 231
 					}else{
232 232
 						$reseller_id = '0';
233 233
 					}
234
-                    $free_switch_array = array('fs_username' => $user_data['number'],
235
-                        'fs_password' => $user_data['password'],
236
-                        'context' => 'default',
237
-                        'effective_caller_id_name' => $user_data['number'],
238
-                        'effective_caller_id_number' => $user_data['number'],
239
-                        'sip_profile_id' => $sip_id[0]['id'],
240
-                        'reseller_id' => $reseller_id,
241
-                        'pricelist_id' => $user_data['pricelist_id'],
242
-                        'accountcode' => $last_id,
243
-                        'status' => $user_data['status'],
244
-                        'voicemail_enabled'=>true,
245
-                        'voicemail_password'=>'',
246
-                        'voicemail_mail_to'=>'',
247
-                        'voicemail_attach_file'=>true,
248
-                        'vm_keep_local_after_email'=>true,
249
-                        'vm_send_all_message'=>true,
250
-                        );
251
-                    $user_custom_array=array_merge($user_data,$free_switch_array);
252
-                    $user_custom_array['id']=$last_id;
253
-                    $user_custom_array['email']=$user_data['email'];
234
+					$free_switch_array = array('fs_username' => $user_data['number'],
235
+						'fs_password' => $user_data['password'],
236
+						'context' => 'default',
237
+						'effective_caller_id_name' => $user_data['number'],
238
+						'effective_caller_id_number' => $user_data['number'],
239
+						'sip_profile_id' => $sip_id[0]['id'],
240
+						'reseller_id' => $reseller_id,
241
+						'pricelist_id' => $user_data['pricelist_id'],
242
+						'accountcode' => $last_id,
243
+						'status' => $user_data['status'],
244
+						'voicemail_enabled'=>true,
245
+						'voicemail_password'=>'',
246
+						'voicemail_mail_to'=>'',
247
+						'voicemail_attach_file'=>true,
248
+						'vm_keep_local_after_email'=>true,
249
+						'vm_send_all_message'=>true,
250
+						);
251
+					$user_custom_array=array_merge($user_data,$free_switch_array);
252
+					$user_custom_array['id']=$last_id;
253
+					$user_custom_array['email']=$user_data['email'];
254 254
                    
255
-                    $this->load->model('freeswitch/freeswitch_model');
256
-                    $this->freeswitch_model->add_freeswith($user_custom_array);
257
-                }
258
-             // echo "<pre>"; print_r ($user_data); exit;
259
-                $activation = $this->encrypt->encode($user_data['number']);
260
-                $message = base_url() . 'signup/signup_confirm?email=' . urlencode($user_data['email']) . "&key=" . urlencode($activation);
261
-                $user_data['confirm'] = $message;
262
-
263
-                $this->send_mail($last_id, 'email_signup_confirmation', $user_data);
264
-                redirect(base_url() . "signup/signup_success");
265
-            }
266
-        }
267
-    }
268
-
269
-    function signup_confirm() {
270
-        if (!empty($_GET)) {
271
-
272
-            $system_config = common_model::$global_config['system_config'];
273
-            $balance = $system_config["balance"];
274
-            $accno = $this->encrypt->decode($_GET['key']);
275
-            $email = $_GET['email'];
276
-            $success = $this->signup_model->check_user($accno, $email, $balance);
277
-            $query = $this->db_model->getSelect("*", "accounts", array('number' => $accno));
278
-            $data = $query->result_array();
279
-            $user_data = $data[0];
280
-            $user_data['accountid'] = $user_data['id'];
281
-            $user_data['success'] = $success;
282
-            $user_data['balance'] = $balance;
283
-            $user_data['confirm'] = base_url();
284
-            $this->active($user_data, $success);
285
-        } else {
286
-            redirect(base_url());
287
-        }
288
-    }
289
-
290
-    function signup_success() {
291
-        $this->load->view('view_signup_success');
292
-    }
293
-
294
-    function signup_inactive() {
295
-        $this->load->view('view_signup_inactive');
296
-    }
297
-
298
-    function active($user_data, $success) {
299
-        $data['user_data'] = $user_data;
300
-        $data['user_data']['success'] = $success;
301
-
302
-        if ($user_data['success']) {
255
+					$this->load->model('freeswitch/freeswitch_model');
256
+					$this->freeswitch_model->add_freeswith($user_custom_array);
257
+				}
258
+			 // echo "<pre>"; print_r ($user_data); exit;
259
+				$activation = $this->encrypt->encode($user_data['number']);
260
+				$message = base_url() . 'signup/signup_confirm?email=' . urlencode($user_data['email']) . "&key=" . urlencode($activation);
261
+				$user_data['confirm'] = $message;
262
+
263
+				$this->send_mail($last_id, 'email_signup_confirmation', $user_data);
264
+				redirect(base_url() . "signup/signup_success");
265
+			}
266
+		}
267
+	}
268
+
269
+	function signup_confirm() {
270
+		if (!empty($_GET)) {
271
+
272
+			$system_config = common_model::$global_config['system_config'];
273
+			$balance = $system_config["balance"];
274
+			$accno = $this->encrypt->decode($_GET['key']);
275
+			$email = $_GET['email'];
276
+			$success = $this->signup_model->check_user($accno, $email, $balance);
277
+			$query = $this->db_model->getSelect("*", "accounts", array('number' => $accno));
278
+			$data = $query->result_array();
279
+			$user_data = $data[0];
280
+			$user_data['accountid'] = $user_data['id'];
281
+			$user_data['success'] = $success;
282
+			$user_data['balance'] = $balance;
283
+			$user_data['confirm'] = base_url();
284
+			$this->active($user_data, $success);
285
+		} else {
286
+			redirect(base_url());
287
+		}
288
+	}
289
+
290
+	function signup_success() {
291
+		$this->load->view('view_signup_success');
292
+	}
293
+
294
+	function signup_inactive() {
295
+		$this->load->view('view_signup_inactive');
296
+	}
297
+
298
+	function active($user_data, $success) {
299
+		$data['user_data'] = $user_data;
300
+		$data['user_data']['success'] = $success;
301
+
302
+		if ($user_data['success']) {
303 303
 			$user_data['password'] = $this->common->decode($user_data['password']);
304
-            $this->send_mail($user_data['id'], 'email_add_user', $user_data);
305
-        }
306
-        $this->load->view('view_signup_active', $data);
307
-    }
308
-
309
-    function forgotpassword() {
310
-        $this->load->view('view_forgotpassword');
311
-    }
312
-
313
-    function confirmpassword() {
314
-        $email = $_POST['email'];       
315
-        unset($_POST['action']);        
316
-        $where = array('email' => $email);
317
-        $this->db->where($where);
318
-        $this->db->or_where('number',$email);
319
-        $cnt_result = $this->db_model->countQuery("*", 'accounts', "");
320
-        if (!empty($email)) {
321
-            $names = array('0', '1', '3');
322
-            $this->db->where_in('type', $names);
323
-            $where_arr = array("email" => $email);
324
-            $this->db->where($where_arr);
304
+			$this->send_mail($user_data['id'], 'email_add_user', $user_data);
305
+		}
306
+		$this->load->view('view_signup_active', $data);
307
+	}
308
+
309
+	function forgotpassword() {
310
+		$this->load->view('view_forgotpassword');
311
+	}
312
+
313
+	function confirmpassword() {
314
+		$email = $_POST['email'];       
315
+		unset($_POST['action']);        
316
+		$where = array('email' => $email);
317
+		$this->db->where($where);
318
+		$this->db->or_where('number',$email);
319
+		$cnt_result = $this->db_model->countQuery("*", 'accounts', "");
320
+		if (!empty($email)) {
321
+			$names = array('0', '1', '3');
322
+			$this->db->where_in('type', $names);
323
+			$where_arr = array("email" => $email);
324
+			$this->db->where($where_arr);
325 325
 			$this->db->or_where('number',$email);
326
-            $acountdata = $this->db_model->getSelect("*", "accounts", "");
327
-            if ($acountdata->num_rows() > 0) {
328
-                $user_data = $acountdata->result_array();
329
-                $user_data = $user_data[0];
330
-                if ($user_data['status'] > 0) {
331
-                    $data['error']['email'] = "<div id='error_mail' style='color:red; margin: 1% 22%; float: left;'>This account is not Active.</div>";
332
-                    $this->load->view('view_forgotpassword', $data);
333
-                    exit;
334
-                }
335
-            }            
336
-            if ($acountdata->num_rows() == 0 && !filter_var($email, FILTER_VALIDATE_EMAIL)) {
337
-                if (!filter_var($email, FILTER_VALIDATE_EMAIL)) {
338
-                    $data['error']['email'] = "<div id='error_mail' style='color: red; margin: 2% 22%; float: left; width:100%;'>Please enter proper Username or Email.</div>";
339
-
340
-                    $this->load->view('view_forgotpassword', $data);
341
-                } else {
342
-                    $data['error']['email'] = "<div id='error_mail' style='color: red; margin: 2% 22%; float: left;width:100%;'>This Username or Email is not valid</div>";
343
-
344
-                    $this->load->view('view_forgotpassword', $data);
345
-                }
346
-            } else if($acountdata->num_rows() == 0){
347
-                    $data['error']['email'] = "<div id='error_mail' style='color: red; margin: 2% 22%; float: left; width:100%;'>Please enter proper Username or Email.</div>";
348
-                    $this->load->view('view_forgotpassword', $data);
349
-            } else {
350
-                $acountdata = $acountdata->result_array();
351
-                $user_data = $acountdata[0];
326
+			$acountdata = $this->db_model->getSelect("*", "accounts", "");
327
+			if ($acountdata->num_rows() > 0) {
328
+				$user_data = $acountdata->result_array();
329
+				$user_data = $user_data[0];
330
+				if ($user_data['status'] > 0) {
331
+					$data['error']['email'] = "<div id='error_mail' style='color:red; margin: 1% 22%; float: left;'>This account is not Active.</div>";
332
+					$this->load->view('view_forgotpassword', $data);
333
+					exit;
334
+				}
335
+			}            
336
+			if ($acountdata->num_rows() == 0 && !filter_var($email, FILTER_VALIDATE_EMAIL)) {
337
+				if (!filter_var($email, FILTER_VALIDATE_EMAIL)) {
338
+					$data['error']['email'] = "<div id='error_mail' style='color: red; margin: 2% 22%; float: left; width:100%;'>Please enter proper Username or Email.</div>";
339
+
340
+					$this->load->view('view_forgotpassword', $data);
341
+				} else {
342
+					$data['error']['email'] = "<div id='error_mail' style='color: red; margin: 2% 22%; float: left;width:100%;'>This Username or Email is not valid</div>";
343
+
344
+					$this->load->view('view_forgotpassword', $data);
345
+				}
346
+			} else if($acountdata->num_rows() == 0){
347
+					$data['error']['email'] = "<div id='error_mail' style='color: red; margin: 2% 22%; float: left; width:100%;'>Please enter proper Username or Email.</div>";
348
+					$this->load->view('view_forgotpassword', $data);
349
+			} else {
350
+				$acountdata = $acountdata->result_array();
351
+				$user_data = $acountdata[0];
352 352
                 
353
-                $email = $this->encrypt->encode($user_data['email']);
354
-                $activation = $this->encrypt->encode($user_data['number']);
355
-                $message = base_url() . 'confirm_pass?email=' . urlencode($email) . "&key=" . urlencode($activation);
356
-                $user_data['confirm'] = $message;
357
-                $where = array("email" => $user_data['email']);
358
-                $data = array("pass_link_status" => 1);
359
-                $this->db->where($where);
360
-                $this->db->update('accounts', $data);
361
-                $system_config = common_model::$global_config['system_config'];
362
-                $balance = $system_config["balance"];
363
-                $this->send_mail($user_data['id'], 'email_forgot_confirmation', $user_data);
364
-                $this->load->view('view_forgot_success');
365
-            }
366
-        } else {
367
-            redirect(base_url());
368
-        }
369
-    }
370
-
371
-    function confirm_pass() {
372
-        $confirm_pass = $_GET;
373
-        $accno = '';
374
-        $balance = '';
375
-        $email1 = $this->encrypt->decode($confirm_pass['email']);
376
-        $success = $this->signup_model->check_user($accno, $email1, $balance);
377
-        if (!empty($confirm_pass)) {
378
-            $where_arr = array("email" => $email1, "status" => 0);
379
-            $acountdata = $this->db_model->getSelect("*", "accounts", $where_arr);
380
-            if ($acountdata->num_rows() > 0) {
381
-                $acountdata = $acountdata->result_array();
382
-                $user_data = $acountdata[0];
383
-                $updateArr = array("pass_link_status" => 0);
384
-                $this->db->where(array("email" => $email1));
385
-                $this->db->update("accounts", $updateArr);
386
-                if ($user_data['pass_link_status'] == '0') {
387
-                    $user_data['success'] = $success;
388
-                    $data['user_data'] = $user_data;
389
-                    $this->active($user_data, $success);
390
-                } else {
391
-                    $data['email'] = $_GET['email'];
392
-                    $this->load->view('view_confirmpassword', $data);
393
-                }
394
-            }
395
-        }
396
-    }
397
-
398
-    function confirmpass() {
399
-        $passwordconf = $_POST;
400
-        $email1 = $this->encrypt->decode($passwordconf['email']);
401
-        if (!empty($passwordconf)) {
402
-            $acountdata = $this->db_model->getSelect("*", "accounts", array("email" => $email1));
403
-            //echo $this->db->last_query();exit;
404
-            if ($acountdata->num_rows() > 0) {
405
-                $acountdata = $acountdata->result_array();
406
-                $user_data = $acountdata[0];
407
-            }
408
-            $user_data['password'] = $this->common->encode($passwordconf['password']);
409
-            $updateArr = array("password" => $user_data['password']);
410
-            $where_arr = array("email" => $email1, "status" => 0);
411
-            $this->db->where($where_arr);
412
-            $this->db->update("accounts", $updateArr);
413
-            //$activation = $this->encrypt->encode($user_data['number']);
414
-            $message = base_url();
415
-            $user_data['confirm'] = $message;
416
-            $user_data['password'] = $passwordconf['password'];
417
-
418
-
419
-
420
-            $system_config = common_model::$global_config['system_config'];
421
-            $balance = $system_config["balance"];
422
-
423
-            $this->send_mail($user_data['id'], 'email_forgot_user', $user_data);
424
-
425
-            $this->successpassword();
426
-        }
427
-    }
428
-
429
-    function send_mail($account_id, $temp_name, $user_data) {
353
+				$email = $this->encrypt->encode($user_data['email']);
354
+				$activation = $this->encrypt->encode($user_data['number']);
355
+				$message = base_url() . 'confirm_pass?email=' . urlencode($email) . "&key=" . urlencode($activation);
356
+				$user_data['confirm'] = $message;
357
+				$where = array("email" => $user_data['email']);
358
+				$data = array("pass_link_status" => 1);
359
+				$this->db->where($where);
360
+				$this->db->update('accounts', $data);
361
+				$system_config = common_model::$global_config['system_config'];
362
+				$balance = $system_config["balance"];
363
+				$this->send_mail($user_data['id'], 'email_forgot_confirmation', $user_data);
364
+				$this->load->view('view_forgot_success');
365
+			}
366
+		} else {
367
+			redirect(base_url());
368
+		}
369
+	}
370
+
371
+	function confirm_pass() {
372
+		$confirm_pass = $_GET;
373
+		$accno = '';
374
+		$balance = '';
375
+		$email1 = $this->encrypt->decode($confirm_pass['email']);
376
+		$success = $this->signup_model->check_user($accno, $email1, $balance);
377
+		if (!empty($confirm_pass)) {
378
+			$where_arr = array("email" => $email1, "status" => 0);
379
+			$acountdata = $this->db_model->getSelect("*", "accounts", $where_arr);
380
+			if ($acountdata->num_rows() > 0) {
381
+				$acountdata = $acountdata->result_array();
382
+				$user_data = $acountdata[0];
383
+				$updateArr = array("pass_link_status" => 0);
384
+				$this->db->where(array("email" => $email1));
385
+				$this->db->update("accounts", $updateArr);
386
+				if ($user_data['pass_link_status'] == '0') {
387
+					$user_data['success'] = $success;
388
+					$data['user_data'] = $user_data;
389
+					$this->active($user_data, $success);
390
+				} else {
391
+					$data['email'] = $_GET['email'];
392
+					$this->load->view('view_confirmpassword', $data);
393
+				}
394
+			}
395
+		}
396
+	}
397
+
398
+	function confirmpass() {
399
+		$passwordconf = $_POST;
400
+		$email1 = $this->encrypt->decode($passwordconf['email']);
401
+		if (!empty($passwordconf)) {
402
+			$acountdata = $this->db_model->getSelect("*", "accounts", array("email" => $email1));
403
+			//echo $this->db->last_query();exit;
404
+			if ($acountdata->num_rows() > 0) {
405
+				$acountdata = $acountdata->result_array();
406
+				$user_data = $acountdata[0];
407
+			}
408
+			$user_data['password'] = $this->common->encode($passwordconf['password']);
409
+			$updateArr = array("password" => $user_data['password']);
410
+			$where_arr = array("email" => $email1, "status" => 0);
411
+			$this->db->where($where_arr);
412
+			$this->db->update("accounts", $updateArr);
413
+			//$activation = $this->encrypt->encode($user_data['number']);
414
+			$message = base_url();
415
+			$user_data['confirm'] = $message;
416
+			$user_data['password'] = $passwordconf['password'];
417
+
418
+
419
+
420
+			$system_config = common_model::$global_config['system_config'];
421
+			$balance = $system_config["balance"];
422
+
423
+			$this->send_mail($user_data['id'], 'email_forgot_user', $user_data);
424
+
425
+			$this->successpassword();
426
+		}
427
+	}
428
+
429
+	function send_mail($account_id, $temp_name, $user_data) {
430 430
 		
431 431
 		
432
-        $system_config = common_model::$global_config['system_config'];
433
-        //$screen_path = getcwd()."/cron";
434
-        //$screen_filename = "Email_Broadcast_".strtotime('now');
435
-        //$command = "cd ".$screen_path." && /usr/bin/screen -d -m -S  $screen_filename php cron.php BroadcastEmail";
436
-        //exec($command);
432
+		$system_config = common_model::$global_config['system_config'];
433
+		//$screen_path = getcwd()."/cron";
434
+		//$screen_filename = "Email_Broadcast_".strtotime('now');
435
+		//$command = "cd ".$screen_path." && /usr/bin/screen -d -m -S  $screen_filename php cron.php BroadcastEmail";
436
+		//exec($command);
437 437
         
438 438
         
439 439
      
440 440
         
441
-        $where = array('name' => $temp_name);
442
-        $EmailTemplate = $this->db_model->getSelect("*", "default_templates", $where);
443
-        $reseller_id = ($user_data['reseller_id'] >0) ? $user_data['reseller_id'] : 1;
444
-        $where="accountid IN ('".$reseller_id."','1')";
445
-        $this->db->where($where);
446
-        $this->db->select('*');
447
-        $this->db->order_by('accountid', 'desc');
448
-        $this->db->limit(1);
449
-        $invoiceconf = $this->db->get('invoice_conf');
450
-        $invoiceconf = (array)$invoiceconf->first_row();
451
-        $company_email = $invoiceconf['emailaddress'];
452
-        $company_website = $invoiceconf["website"];
453
-        $company_name = $invoiceconf["company_name"];
441
+		$where = array('name' => $temp_name);
442
+		$EmailTemplate = $this->db_model->getSelect("*", "default_templates", $where);
443
+		$reseller_id = ($user_data['reseller_id'] >0) ? $user_data['reseller_id'] : 1;
444
+		$where="accountid IN ('".$reseller_id."','1')";
445
+		$this->db->where($where);
446
+		$this->db->select('*');
447
+		$this->db->order_by('accountid', 'desc');
448
+		$this->db->limit(1);
449
+		$invoiceconf = $this->db->get('invoice_conf');
450
+		$invoiceconf = (array)$invoiceconf->first_row();
451
+		$company_email = $invoiceconf['emailaddress'];
452
+		$company_website = $invoiceconf["website"];
453
+		$company_name = $invoiceconf["company_name"];
454 454
         
455
-        $TemplateData = array();
455
+		$TemplateData = array();
456 456
         
457 457
         
458
-        foreach ($EmailTemplate->result_array() as $value) {
459
-            $TemplateData = $value;
460
-            $TemplateData['subject'] = str_replace('#NAME#', $user_data['first_name'] . " " . $user_data['last_name'], $TemplateData['subject']);
461
-            $TemplateData['template'] = str_replace('#NAME#', $user_data['first_name'] . " " . $user_data['last_name'], $TemplateData['template']);
462
-            $TemplateData['template'] = str_replace('#NUMBER#', $user_data['number'], $TemplateData['template']);
463
-            $TemplateData['template'] = str_replace('#PASSWORD#', $user_data['password'], $TemplateData['template']);
464
-            $TemplateData['template'] = str_replace('#COMPANY_WEBSITE#', $company_website, $TemplateData['template']);
465
-            $TemplateData['template'] = str_replace('#LINK#', $user_data['confirm'], $TemplateData['template']);
466
-            $TemplateData['template'] = str_replace('#COMPANY_EMAIL#', $company_email, $TemplateData['template']);
467
-            $TemplateData['template'] = str_replace('#COMPANY_NAME#', $company_name, $TemplateData['template']);
468
-        }
469
-        $email_array = array('accountid' => $account_id,
470
-            'subject' => $TemplateData['subject'],
471
-            'body' => $TemplateData['template'],
472
-            'from' => $invoiceconf['emailaddress'],
473
-            'to' => $user_data['email'],
474
-            'status' => "1",
475
-            //'attachment'=> $Filenm,
476
-            'template' => '');
477
-        //echo "<pre>"; print_r($TemplateData); exit;
478
-        $this->db->insert("mail_details", $email_array);
479
-        return true;
480
-    }
481
-
482
-    function successpassword() {
483
-        $this->load->view('view_successpassword');
484
-    }
458
+		foreach ($EmailTemplate->result_array() as $value) {
459
+			$TemplateData = $value;
460
+			$TemplateData['subject'] = str_replace('#NAME#', $user_data['first_name'] . " " . $user_data['last_name'], $TemplateData['subject']);
461
+			$TemplateData['template'] = str_replace('#NAME#', $user_data['first_name'] . " " . $user_data['last_name'], $TemplateData['template']);
462
+			$TemplateData['template'] = str_replace('#NUMBER#', $user_data['number'], $TemplateData['template']);
463
+			$TemplateData['template'] = str_replace('#PASSWORD#', $user_data['password'], $TemplateData['template']);
464
+			$TemplateData['template'] = str_replace('#COMPANY_WEBSITE#', $company_website, $TemplateData['template']);
465
+			$TemplateData['template'] = str_replace('#LINK#', $user_data['confirm'], $TemplateData['template']);
466
+			$TemplateData['template'] = str_replace('#COMPANY_EMAIL#', $company_email, $TemplateData['template']);
467
+			$TemplateData['template'] = str_replace('#COMPANY_NAME#', $company_name, $TemplateData['template']);
468
+		}
469
+		$email_array = array('accountid' => $account_id,
470
+			'subject' => $TemplateData['subject'],
471
+			'body' => $TemplateData['template'],
472
+			'from' => $invoiceconf['emailaddress'],
473
+			'to' => $user_data['email'],
474
+			'status' => "1",
475
+			//'attachment'=> $Filenm,
476
+			'template' => '');
477
+		//echo "<pre>"; print_r($TemplateData); exit;
478
+		$this->db->insert("mail_details", $email_array);
479
+		return true;
480
+	}
481
+
482
+	function successpassword() {
483
+		$this->load->view('view_successpassword');
484
+	}
485 485
 
486 486
 }
487 487
 ?>
Please login to merge, or discard this patch.
Spacing   +46 added lines, -46 removed lines patch added patch discarded remove patch
@@ -53,15 +53,15 @@  discard block
 block discarded – undo
53 53
 
54 54
         $userCaptcha = $this->input->post('userCaptcha');
55 55
         $random_number = substr(number_format(time() * rand(), 0, '', ''), 0, 6);
56
-        $accountinfo=(array)$this->db->get_where('accounts',array('type'=>-1))->first_row();
57
-        $data['timezone_id'] = (!$accountinfo['timezone_id']) ? 1 : $accountinfo['timezone_id'];
58
-        $data['currency_id'] = (!$accountinfo['currency_id']) ? 1 : $accountinfo['currency_id'];
59
-        $data['country_id'] = (!$accountinfo['country_id']) ? 1 : $accountinfo['country_id'];
56
+        $accountinfo = (array)$this->db->get_where('accounts', array('type'=>-1))->first_row();
57
+        $data['timezone_id'] = ( ! $accountinfo['timezone_id']) ? 1 : $accountinfo['timezone_id'];
58
+        $data['currency_id'] = ( ! $accountinfo['currency_id']) ? 1 : $accountinfo['currency_id'];
59
+        $data['country_id'] = ( ! $accountinfo['country_id']) ? 1 : $accountinfo['country_id'];
60 60
 
61 61
         $vals = array(
62 62
             'word' => $random_number,
63
-            'img_path' => getcwd() . '/assets/captcha/',
64
-            'img_url' => base_url() . 'assets/captcha/',
63
+            'img_path' => getcwd().'/assets/captcha/',
64
+            'img_url' => base_url().'assets/captcha/',
65 65
             //'font_path' => './fonts/impact.ttf',
66 66
             'img_width' => '243',
67 67
             'img_height' => '50',
@@ -81,14 +81,14 @@  discard block
 block discarded – undo
81 81
             $unique = $decoded_str;
82 82
             $query = $this->db_model->getSelect("*", 'accounts', array('id' => $unique, "deleted" => "0"));
83 83
             if ($query->num_rows() == 0) {
84
-                redirect(base_url() . "signup/signup_inactive");
84
+                redirect(base_url()."signup/signup_inactive");
85 85
             }
86 86
             if ($query->num_rows() > 0) {
87 87
                 $query = $query->result_array();
88 88
                 $query = $query[0];
89 89
 
90 90
                 if ($query['status'] != 0) {
91
-                    redirect(base_url() . "signup/signup_inactive");
91
+                    redirect(base_url()."signup/signup_inactive");
92 92
                 }
93 93
             }
94 94
         }
@@ -116,14 +116,14 @@  discard block
 block discarded – undo
116 116
 
117 117
      function signup_save($id = "") {
118 118
         if (empty($_POST)) {
119
-            redirect(base_url() . "signup/");
119
+            redirect(base_url()."signup/");
120 120
         } else {
121 121
             $post_values = $this->input->post();
122 122
             $userCaptcha = $this->input->post('userCaptcha');
123 123
             $cnt_result = $this->db_model->countQuery("*", 'accounts', array('email' => $post_values['email']));
124 124
 
125
-            if ($userCaptcha != $this->session->userdata('captchaWord') || !filter_var($this->input->post('email'), FILTER_VALIDATE_EMAIL) || $cnt_result > 0) {
126
-                if (!filter_var($this->input->post('email'), FILTER_VALIDATE_EMAIL)) {
125
+            if ($userCaptcha != $this->session->userdata('captchaWord') || ! filter_var($this->input->post('email'), FILTER_VALIDATE_EMAIL) || $cnt_result > 0) {
126
+                if ( ! filter_var($this->input->post('email'), FILTER_VALIDATE_EMAIL)) {
127 127
                     $data['error']['email'] = "<div style='color: red;'> Please enter proper email </div>";
128 128
                 }
129 129
                 if ($userCaptcha != $this->session->userdata('captchaWord')) {
@@ -135,8 +135,8 @@  discard block
 block discarded – undo
135 135
                 $random_number = substr(number_format(time() * rand(), 0, '', ''), 0, 6);
136 136
                 $vals = array(
137 137
                     'word' => $random_number,
138
-                    'img_path' => getcwd() . '/assets/captcha/',
139
-                    'img_url' => base_url() . 'assets/captcha/',
138
+                    'img_path' => getcwd().'/assets/captcha/',
139
+                    'img_url' => base_url().'assets/captcha/',
140 140
                     //'font_path' => './fonts/impact.ttf',
141 141
                     'img_width' => '243',
142 142
                     'img_height' => '50',
@@ -147,14 +147,14 @@  discard block
 block discarded – undo
147 147
                     $data['key_unique'] = $_POST['key_unique'];
148 148
                 }
149 149
 
150
-				$accountinfo=(array)$this->db->get_where('accounts',array('type'=>-1))->first_row();
151
-				$data['timezone_id'] = (!$accountinfo['timezone_id']) ? 1 : $accountinfo['timezone_id'];
152
-				$data['currency_id'] = (!$accountinfo['currency_id']) ? 1 : $accountinfo['currency_id'];
153
-				$data['country_id'] = (!$accountinfo['country_id']) ? 1 : $accountinfo['country_id'];
150
+				$accountinfo = (array)$this->db->get_where('accounts', array('type'=>-1))->first_row();
151
+				$data['timezone_id'] = ( ! $accountinfo['timezone_id']) ? 1 : $accountinfo['timezone_id'];
152
+				$data['currency_id'] = ( ! $accountinfo['currency_id']) ? 1 : $accountinfo['currency_id'];
153
+				$data['country_id'] = ( ! $accountinfo['country_id']) ? 1 : $accountinfo['country_id'];
154 154
 
155
-                $data['timezone_id'] = (!$data['timezone_id']) ? 1 : $data['timezone_id'];
156
-                $data['currency_id'] = (!$data['currency_id']) ? 1 : $data['currency_id'];
157
-                $data['country_id'] = (!$data['country_id']) ? 1 : $data['country_id'];
155
+                $data['timezone_id'] = ( ! $data['timezone_id']) ? 1 : $data['timezone_id'];
156
+                $data['currency_id'] = ( ! $data['currency_id']) ? 1 : $data['currency_id'];
157
+                $data['country_id'] = ( ! $data['country_id']) ? 1 : $data['country_id'];
158 158
 
159 159
                 $data['value'] = $post_values;
160 160
                 $data['captcha'] = create_captcha($vals);
@@ -166,8 +166,8 @@  discard block
 block discarded – undo
166 166
                 //AVTLATP		
167 167
                 $user_data = $this->input->post();
168 168
                
169
-                if (!isset($_POST['key_unique']) || !isset($_POST['email'])) {
170
-                    redirect(base_url() . "signup/");
169
+                if ( ! isset($_POST['key_unique']) || ! isset($_POST['email'])) {
170
+                    redirect(base_url()."signup/");
171 171
                 }
172 172
                 $reseller_id = 0;
173 173
                 if (isset($_POST['key_unique']) && $_POST['key_unique'] != "admin") {
@@ -207,7 +207,7 @@  discard block
 block discarded – undo
207 207
                     $result = $this->db_model->getSelect("*", "pricelists", array("reseller_id" => $reseller_id), "ASC");
208 208
                     $result_arr = $result->result_array();
209 209
                     $selection_rategroup_signup = $result_arr[0]['id'];
210
-                    $user_data['pricelist_id'] = (isset($selection_rategroup_signup) && $selection_rategroup_signup > 0 ) ? $selection_rategroup_signup : 0;
210
+                    $user_data['pricelist_id'] = (isset($selection_rategroup_signup) && $selection_rategroup_signup > 0) ? $selection_rategroup_signup : 0;
211 211
                 } else {
212 212
                     $pricelist_id = $this->common->get_field_name('id', 'pricelists', array('name' => $selection_rategroup_signup));
213 213
                     /* if($pricelis_id != "")
@@ -216,19 +216,19 @@  discard block
 block discarded – undo
216 216
                       $user_data['pricelist_id'] = 0; */
217 217
                     $user_data['pricelist_id'] = ($pricelist_id != "") ? $pricelist_id : 0;
218 218
                 }
219
-                $last_id='0';
219
+                $last_id = '0';
220 220
                 //Insert or Update record
221 221
                 $signup_sipdevice_flag = $system_config['create_sipdevice'];
222 222
                 $last_id = $this->signup_model->add_user($user_data);
223 223
                 if ($last_id == "") {
224
-                    redirect(base_url() . "signup/signup_inactive");
224
+                    redirect(base_url()."signup/signup_inactive");
225 225
                 }
226 226
                 if ($signup_sipdevice_flag == '0') {
227 227
                     $query = $this->db_model->select("*", "sip_profiles", array('name' => "default"), "id", "ASC", '1', '0');
228 228
                     $sip_id = $query->result_array();
229
-                    if($reseller_id > 0){
229
+                    if ($reseller_id > 0) {
230 230
 						$reseller_id = $reseller_id;
231
-					}else{
231
+					} else {
232 232
 						$reseller_id = '0';
233 233
 					}
234 234
                     $free_switch_array = array('fs_username' => $user_data['number'],
@@ -248,26 +248,26 @@  discard block
 block discarded – undo
248 248
                         'vm_keep_local_after_email'=>true,
249 249
                         'vm_send_all_message'=>true,
250 250
                         );
251
-                    $user_custom_array=array_merge($user_data,$free_switch_array);
252
-                    $user_custom_array['id']=$last_id;
253
-                    $user_custom_array['email']=$user_data['email'];
251
+                    $user_custom_array = array_merge($user_data, $free_switch_array);
252
+                    $user_custom_array['id'] = $last_id;
253
+                    $user_custom_array['email'] = $user_data['email'];
254 254
                    
255 255
                     $this->load->model('freeswitch/freeswitch_model');
256 256
                     $this->freeswitch_model->add_freeswith($user_custom_array);
257 257
                 }
258 258
              // echo "<pre>"; print_r ($user_data); exit;
259 259
                 $activation = $this->encrypt->encode($user_data['number']);
260
-                $message = base_url() . 'signup/signup_confirm?email=' . urlencode($user_data['email']) . "&key=" . urlencode($activation);
260
+                $message = base_url().'signup/signup_confirm?email='.urlencode($user_data['email'])."&key=".urlencode($activation);
261 261
                 $user_data['confirm'] = $message;
262 262
 
263 263
                 $this->send_mail($last_id, 'email_signup_confirmation', $user_data);
264
-                redirect(base_url() . "signup/signup_success");
264
+                redirect(base_url()."signup/signup_success");
265 265
             }
266 266
         }
267 267
     }
268 268
 
269 269
     function signup_confirm() {
270
-        if (!empty($_GET)) {
270
+        if ( ! empty($_GET)) {
271 271
 
272 272
             $system_config = common_model::$global_config['system_config'];
273 273
             $balance = $system_config["balance"];
@@ -315,14 +315,14 @@  discard block
 block discarded – undo
315 315
         unset($_POST['action']);        
316 316
         $where = array('email' => $email);
317 317
         $this->db->where($where);
318
-        $this->db->or_where('number',$email);
318
+        $this->db->or_where('number', $email);
319 319
         $cnt_result = $this->db_model->countQuery("*", 'accounts', "");
320
-        if (!empty($email)) {
320
+        if ( ! empty($email)) {
321 321
             $names = array('0', '1', '3');
322 322
             $this->db->where_in('type', $names);
323 323
             $where_arr = array("email" => $email);
324 324
             $this->db->where($where_arr);
325
-			$this->db->or_where('number',$email);
325
+			$this->db->or_where('number', $email);
326 326
             $acountdata = $this->db_model->getSelect("*", "accounts", "");
327 327
             if ($acountdata->num_rows() > 0) {
328 328
                 $user_data = $acountdata->result_array();
@@ -333,8 +333,8 @@  discard block
 block discarded – undo
333 333
                     exit;
334 334
                 }
335 335
             }            
336
-            if ($acountdata->num_rows() == 0 && !filter_var($email, FILTER_VALIDATE_EMAIL)) {
337
-                if (!filter_var($email, FILTER_VALIDATE_EMAIL)) {
336
+            if ($acountdata->num_rows() == 0 && ! filter_var($email, FILTER_VALIDATE_EMAIL)) {
337
+                if ( ! filter_var($email, FILTER_VALIDATE_EMAIL)) {
338 338
                     $data['error']['email'] = "<div id='error_mail' style='color: red; margin: 2% 22%; float: left; width:100%;'>Please enter proper Username or Email.</div>";
339 339
 
340 340
                     $this->load->view('view_forgotpassword', $data);
@@ -343,7 +343,7 @@  discard block
 block discarded – undo
343 343
 
344 344
                     $this->load->view('view_forgotpassword', $data);
345 345
                 }
346
-            } else if($acountdata->num_rows() == 0){
346
+            } else if ($acountdata->num_rows() == 0) {
347 347
                     $data['error']['email'] = "<div id='error_mail' style='color: red; margin: 2% 22%; float: left; width:100%;'>Please enter proper Username or Email.</div>";
348 348
                     $this->load->view('view_forgotpassword', $data);
349 349
             } else {
@@ -352,7 +352,7 @@  discard block
 block discarded – undo
352 352
                 
353 353
                 $email = $this->encrypt->encode($user_data['email']);
354 354
                 $activation = $this->encrypt->encode($user_data['number']);
355
-                $message = base_url() . 'confirm_pass?email=' . urlencode($email) . "&key=" . urlencode($activation);
355
+                $message = base_url().'confirm_pass?email='.urlencode($email)."&key=".urlencode($activation);
356 356
                 $user_data['confirm'] = $message;
357 357
                 $where = array("email" => $user_data['email']);
358 358
                 $data = array("pass_link_status" => 1);
@@ -374,7 +374,7 @@  discard block
 block discarded – undo
374 374
         $balance = '';
375 375
         $email1 = $this->encrypt->decode($confirm_pass['email']);
376 376
         $success = $this->signup_model->check_user($accno, $email1, $balance);
377
-        if (!empty($confirm_pass)) {
377
+        if ( ! empty($confirm_pass)) {
378 378
             $where_arr = array("email" => $email1, "status" => 0);
379 379
             $acountdata = $this->db_model->getSelect("*", "accounts", $where_arr);
380 380
             if ($acountdata->num_rows() > 0) {
@@ -398,7 +398,7 @@  discard block
 block discarded – undo
398 398
     function confirmpass() {
399 399
         $passwordconf = $_POST;
400 400
         $email1 = $this->encrypt->decode($passwordconf['email']);
401
-        if (!empty($passwordconf)) {
401
+        if ( ! empty($passwordconf)) {
402 402
             $acountdata = $this->db_model->getSelect("*", "accounts", array("email" => $email1));
403 403
             //echo $this->db->last_query();exit;
404 404
             if ($acountdata->num_rows() > 0) {
@@ -440,8 +440,8 @@  discard block
 block discarded – undo
440 440
         
441 441
         $where = array('name' => $temp_name);
442 442
         $EmailTemplate = $this->db_model->getSelect("*", "default_templates", $where);
443
-        $reseller_id = ($user_data['reseller_id'] >0) ? $user_data['reseller_id'] : 1;
444
-        $where="accountid IN ('".$reseller_id."','1')";
443
+        $reseller_id = ($user_data['reseller_id'] > 0) ? $user_data['reseller_id'] : 1;
444
+        $where = "accountid IN ('".$reseller_id."','1')";
445 445
         $this->db->where($where);
446 446
         $this->db->select('*');
447 447
         $this->db->order_by('accountid', 'desc');
@@ -457,8 +457,8 @@  discard block
 block discarded – undo
457 457
         
458 458
         foreach ($EmailTemplate->result_array() as $value) {
459 459
             $TemplateData = $value;
460
-            $TemplateData['subject'] = str_replace('#NAME#', $user_data['first_name'] . " " . $user_data['last_name'], $TemplateData['subject']);
461
-            $TemplateData['template'] = str_replace('#NAME#', $user_data['first_name'] . " " . $user_data['last_name'], $TemplateData['template']);
460
+            $TemplateData['subject'] = str_replace('#NAME#', $user_data['first_name']." ".$user_data['last_name'], $TemplateData['subject']);
461
+            $TemplateData['template'] = str_replace('#NAME#', $user_data['first_name']." ".$user_data['last_name'], $TemplateData['template']);
462 462
             $TemplateData['template'] = str_replace('#NUMBER#', $user_data['number'], $TemplateData['template']);
463 463
             $TemplateData['template'] = str_replace('#PASSWORD#', $user_data['password'], $TemplateData['template']);
464 464
             $TemplateData['template'] = str_replace('#COMPANY_WEBSITE#', $company_website, $TemplateData['template']);
Please login to merge, or discard this patch.
Braces   +4 added lines, -3 removed lines patch added patch discarded remove patch
@@ -108,8 +108,9 @@  discard block
 block discarded – undo
108 108
     }
109 109
 
110 110
     function terms_check() {
111
-        if (isset($_POST['agreeCheck']))
112
-            return true;
111
+        if (isset($_POST['agreeCheck'])) {
112
+                    return true;
113
+        }
113 114
         $this->form_validation->set_message('terms_check', 'THIS IS SOOOOO REQUIRED, DUDE!');
114 115
         return false;
115 116
     }
@@ -228,7 +229,7 @@  discard block
 block discarded – undo
228 229
                     $sip_id = $query->result_array();
229 230
                     if($reseller_id > 0){
230 231
 						$reseller_id = $reseller_id;
231
-					}else{
232
+					} else{
232 233
 						$reseller_id = '0';
233 234
 					}
234 235
                     $free_switch_array = array('fs_username' => $user_data['number'],
Please login to merge, or discard this patch.
web_interface/astpp/application/modules/summary/controllers/summary.php 4 patches
Doc Comments   +10 added lines patch added patch discarded remove patch
@@ -73,6 +73,9 @@  discard block
 block discarded – undo
73 73
         echo json_encode($json_data);
74 74
     }
75 75
 
76
+    /**
77
+     * @param string $entity
78
+     */
76 79
     function summary_column_arr($entity) {
77 80
         $new_column_arr = array();
78 81
         $total_width = '322';
@@ -126,6 +129,10 @@  discard block
 block discarded – undo
126 129
         return $new_column_arr;
127 130
     }
128 131
 
132
+    /**
133
+     * @param string $entity
134
+     * @param string $purpose
135
+     */
129 136
     function summary_report_grid($search_arr, $query, $entity, $purpose) {
130 137
         $export_arr = array();
131 138
         $db_field_name = $entity == 'provider' ? 'provider_id' : 'accountid';
@@ -330,6 +337,9 @@  discard block
 block discarded – undo
330 337
         redirect(base_url() . 'summary/customer/');
331 338
     }
332 339
 
340
+    /**
341
+     * @param string $entity
342
+     */
333 343
     function summary_search_info($entity) {
334 344
         $group_by_str = null;
335 345
         $select_str = null;
Please login to merge, or discard this patch.
Indentation   +510 added lines, -510 removed lines patch added patch discarded remove patch
@@ -24,569 +24,569 @@
 block discarded – undo
24 24
 
25 25
 class Summary extends MX_Controller {
26 26
 
27
-    function Summary() {
28
-        parent::__construct();
27
+	function Summary() {
28
+		parent::__construct();
29 29
 
30
-        $this->load->helper('template_inheritance');
30
+		$this->load->helper('template_inheritance');
31 31
 
32
-        $this->load->library('session');
33
-        $this->load->library('astpp/form');
34
-        $this->load->library("summary_form");
35
-        $this->load->model('summary_model');
36
-        $this->load->library('fpdf');
37
-        $this->load->library('pdf');
38
-        $this->fpdf = new PDF('P', 'pt');
39
-        $this->fpdf->initialize('P', 'mm', 'A4');
32
+		$this->load->library('session');
33
+		$this->load->library('astpp/form');
34
+		$this->load->library("summary_form");
35
+		$this->load->model('summary_model');
36
+		$this->load->library('fpdf');
37
+		$this->load->library('pdf');
38
+		$this->fpdf = new PDF('P', 'pt');
39
+		$this->fpdf->initialize('P', 'mm', 'A4');
40 40
 
41
-        if ($this->session->userdata('user_login') == FALSE)
42
-            redirect(base_url() . '/astpp/login');
43
-    }
44
-    function customer() {
45
-        $data['page_title'] = 'Customer Summary Report';
46
-        $data['search_flag'] = true;
47
-        $session_info = $this->session->userdata('customersummary_reports_search');
48
-        $accountinfo = $this->session->userdata('accountinfo');
49
-        $reseller_id = $accountinfo['type'] == 1 ? $accountinfo['id'] : 0;
50
-        $accountlist = $this->db_model->build_dropdown_deleted('id,IF(`deleted`=1,concat( first_name, " ", last_name, " ", "(", number, ")^" ),concat( first_name, " ", last_name, " ", "(", number, ")" )) as number', 'accounts', 'where_arr', array('reseller_id' => $reseller_id, "type" => "GLOBAL"));
51
-        $data['accountlist'] = $accountlist;
52
-        $data['session_info'] = $session_info;
53
-        $data['search_string_type'] = $this->common->search_string_type();
54
-        $data['search_report'] = $this->common->search_report_in();
55
-        $new_column_arr = $this->summary_column_arr('customer');
56
-        $data['grid_fields'] = $this->summary_form->build_customersummary($new_column_arr);
57
-        $data["grid_buttons"] = $this->summary_form->build_grid_buttons_customersummary();
58
-        $data['groupby_field'] = $this->common->set_summarycustomer_groupby();
59
-        $data['groupby_time'] = $this->common->group_by_time();
60
-        $this->load->view('view_customersummary_report', $data);
61
-    }
41
+		if ($this->session->userdata('user_login') == FALSE)
42
+			redirect(base_url() . '/astpp/login');
43
+	}
44
+	function customer() {
45
+		$data['page_title'] = 'Customer Summary Report';
46
+		$data['search_flag'] = true;
47
+		$session_info = $this->session->userdata('customersummary_reports_search');
48
+		$accountinfo = $this->session->userdata('accountinfo');
49
+		$reseller_id = $accountinfo['type'] == 1 ? $accountinfo['id'] : 0;
50
+		$accountlist = $this->db_model->build_dropdown_deleted('id,IF(`deleted`=1,concat( first_name, " ", last_name, " ", "(", number, ")^" ),concat( first_name, " ", last_name, " ", "(", number, ")" )) as number', 'accounts', 'where_arr', array('reseller_id' => $reseller_id, "type" => "GLOBAL"));
51
+		$data['accountlist'] = $accountlist;
52
+		$data['session_info'] = $session_info;
53
+		$data['search_string_type'] = $this->common->search_string_type();
54
+		$data['search_report'] = $this->common->search_report_in();
55
+		$new_column_arr = $this->summary_column_arr('customer');
56
+		$data['grid_fields'] = $this->summary_form->build_customersummary($new_column_arr);
57
+		$data["grid_buttons"] = $this->summary_form->build_grid_buttons_customersummary();
58
+		$data['groupby_field'] = $this->common->set_summarycustomer_groupby();
59
+		$data['groupby_time'] = $this->common->group_by_time();
60
+		$this->load->view('view_customersummary_report', $data);
61
+	}
62 62
 
63
-    function customer_json() {
64
-        $search_arr = $this->summary_search_info('customer');
65
-        $count_all = $this->summary_model->get_customersummary_report_list(false, 0, 0, $search_arr['group_by_str'], $search_arr['select_str'],$search_arr['order_str'],false);
66
-        $paging_data = $this->form->load_grid_config($count_all, $_GET['rp'], $_GET['page']);
67
-        $json_data = $paging_data["json_paging"];
68
-        $query = $this->summary_model->get_customersummary_report_list(true, $paging_data["paging"]["start"], $paging_data["paging"]["page_no"], $search_arr['group_by_str'], $search_arr['select_str'],$search_arr['order_str'], false);
69
-        if ($query->num_rows() > 0) {
70
-            $json_data['rows'] = $this->summary_report_grid($search_arr, $query, 'customer', 'grid');
71
-        }
72
-        $this->session->set_userdata('customersummary_reports_export', $search_arr);
73
-        echo json_encode($json_data);
74
-    }
63
+	function customer_json() {
64
+		$search_arr = $this->summary_search_info('customer');
65
+		$count_all = $this->summary_model->get_customersummary_report_list(false, 0, 0, $search_arr['group_by_str'], $search_arr['select_str'],$search_arr['order_str'],false);
66
+		$paging_data = $this->form->load_grid_config($count_all, $_GET['rp'], $_GET['page']);
67
+		$json_data = $paging_data["json_paging"];
68
+		$query = $this->summary_model->get_customersummary_report_list(true, $paging_data["paging"]["start"], $paging_data["paging"]["page_no"], $search_arr['group_by_str'], $search_arr['select_str'],$search_arr['order_str'], false);
69
+		if ($query->num_rows() > 0) {
70
+			$json_data['rows'] = $this->summary_report_grid($search_arr, $query, 'customer', 'grid');
71
+		}
72
+		$this->session->set_userdata('customersummary_reports_export', $search_arr);
73
+		echo json_encode($json_data);
74
+	}
75 75
 
76
-    function summary_column_arr($entity) {
77
-        $new_column_arr = array();
78
-        $total_width = '322';
79
-        $column_name = 'accountid';
80
-        if ($this->session->userdata('advance_search') == '1') {
81
-            $search_array = $this->session->userdata($entity . 'summary_reports_search');
82
-            if(isset($search_array['time']) && !empty($search_array['time'])){
83
-                   $new_column_arr[]=array(ucfirst(strtolower($search_array['time'])), "58", $search_array['time']."(callstart)", "", "", "");
84
-            }
85
-            if (isset($search_array['groupby_1']) && !empty($search_array['groupby_1'])) {
86
-                $first_column_groupby = $search_array['groupby_1'];
76
+	function summary_column_arr($entity) {
77
+		$new_column_arr = array();
78
+		$total_width = '322';
79
+		$column_name = 'accountid';
80
+		if ($this->session->userdata('advance_search') == '1') {
81
+			$search_array = $this->session->userdata($entity . 'summary_reports_search');
82
+			if(isset($search_array['time']) && !empty($search_array['time'])){
83
+				   $new_column_arr[]=array(ucfirst(strtolower($search_array['time'])), "58", $search_array['time']."(callstart)", "", "", "");
84
+			}
85
+			if (isset($search_array['groupby_1']) && !empty($search_array['groupby_1'])) {
86
+				$first_column_groupby = $search_array['groupby_1'];
87 87
 
88
-                if ($first_column_groupby == 'accountid') {
89
-                    $new_column_arr[] = array("Account", "105",'accountid', "first_name,last_name,number", "accounts", "build_concat_string");
90
-                } elseif ($first_column_groupby == 'pattern') {
91
-                    $new_column_arr[] = array("Code", "45", "pattern", "pattern", "", "get_only_numeric_val");
92
-                    $new_column_arr[] = array("Destination", "59", "notes", "", "", "");
93
-                } elseif($first_column_groupby =='package_id'){
94
-		    $new_column_arr[] = array("Package", "105",'package_id', "package_name", "packages", "get_field_name");
95
-                }
96
-            }
97
-            if (isset($search_array['groupby_2']) && !empty($search_array['groupby_2'])) {
98
-                $third_column_groupby = $search_array['groupby_2'];
99
-                if ($third_column_groupby == 'accountid') {
100
-                    $new_column_arr[] = array("Account", "105", 'accountid', "first_name,last_name,number", "accounts", "build_concat_string");
101
-                } elseif ($third_column_groupby == 'pattern') {
102
-                    $new_column_arr[] = array("Code", "45", "pattern", "pattern", "", "get_only_numeric_val");
103
-                    $new_column_arr[] = array("Destination", "59", "notes", "", "", "");
104
-                } elseif($third_column_groupby	 =='package_id'){
105
-		    $new_column_arr[] = array("Package", "105",'package_id', "package_name", "packages", "get_field_name");
106
-                }
107
-            }
108
-            if (isset($search_array['groupby_3']) && !empty($search_array['groupby_3'])) {
109
-                $fifth_column_groupby = $search_array['groupby_3'];
110
-                if ($fifth_column_groupby == 'accountid') {
111
-                    $new_column_arr[] = array("Account", "105", 'accountid', "first_name,last_name,number", "accounts", "build_concat_string");
112
-                } elseif ($fifth_column_groupby == 'pattern') {
113
-                    $new_column_arr[] = array("Code", "45", "pattern", "pattern", "", "get_only_numeric_val");
114
-                    $new_column_arr[] = array("Destination", "59", "notes", "", "", "");
115
-                } elseif($fifth_column_groupby	 =='package_id'){
116
-		    $new_column_arr[] = array("Package", "105",'package_id', "package_name", "packages", "get_field_name");
117
-                }
118
-            }
119
-            if (empty($new_column_arr)) {
120
-                $new_column_arr[] = array("Account", '322', 'accountid', "first_name,last_name,number", "accounts", "build_concat_string");
121
-            }
122
-        } else {
123
-            $new_column_arr[] = array("Account", '322', 'accountid', "first_name,last_name,number", "accounts", "build_concat_string");
124
-        }
88
+				if ($first_column_groupby == 'accountid') {
89
+					$new_column_arr[] = array("Account", "105",'accountid', "first_name,last_name,number", "accounts", "build_concat_string");
90
+				} elseif ($first_column_groupby == 'pattern') {
91
+					$new_column_arr[] = array("Code", "45", "pattern", "pattern", "", "get_only_numeric_val");
92
+					$new_column_arr[] = array("Destination", "59", "notes", "", "", "");
93
+				} elseif($first_column_groupby =='package_id'){
94
+			$new_column_arr[] = array("Package", "105",'package_id', "package_name", "packages", "get_field_name");
95
+				}
96
+			}
97
+			if (isset($search_array['groupby_2']) && !empty($search_array['groupby_2'])) {
98
+				$third_column_groupby = $search_array['groupby_2'];
99
+				if ($third_column_groupby == 'accountid') {
100
+					$new_column_arr[] = array("Account", "105", 'accountid', "first_name,last_name,number", "accounts", "build_concat_string");
101
+				} elseif ($third_column_groupby == 'pattern') {
102
+					$new_column_arr[] = array("Code", "45", "pattern", "pattern", "", "get_only_numeric_val");
103
+					$new_column_arr[] = array("Destination", "59", "notes", "", "", "");
104
+				} elseif($third_column_groupby	 =='package_id'){
105
+			$new_column_arr[] = array("Package", "105",'package_id', "package_name", "packages", "get_field_name");
106
+				}
107
+			}
108
+			if (isset($search_array['groupby_3']) && !empty($search_array['groupby_3'])) {
109
+				$fifth_column_groupby = $search_array['groupby_3'];
110
+				if ($fifth_column_groupby == 'accountid') {
111
+					$new_column_arr[] = array("Account", "105", 'accountid', "first_name,last_name,number", "accounts", "build_concat_string");
112
+				} elseif ($fifth_column_groupby == 'pattern') {
113
+					$new_column_arr[] = array("Code", "45", "pattern", "pattern", "", "get_only_numeric_val");
114
+					$new_column_arr[] = array("Destination", "59", "notes", "", "", "");
115
+				} elseif($fifth_column_groupby	 =='package_id'){
116
+			$new_column_arr[] = array("Package", "105",'package_id', "package_name", "packages", "get_field_name");
117
+				}
118
+			}
119
+			if (empty($new_column_arr)) {
120
+				$new_column_arr[] = array("Account", '322', 'accountid', "first_name,last_name,number", "accounts", "build_concat_string");
121
+			}
122
+		} else {
123
+			$new_column_arr[] = array("Account", '322', 'accountid', "first_name,last_name,number", "accounts", "build_concat_string");
124
+		}
125 125
         
126
-        return $new_column_arr;
127
-    }
126
+		return $new_column_arr;
127
+	}
128 128
 
129
-    function summary_report_grid($search_arr, $query, $entity, $purpose) {
130
-        $export_arr = array();
131
-        $db_field_name = $entity == 'provider' ? 'provider_id' : 'accountid';
132
-        $show_seconds = (!empty($search_arr['search_in'])) ? $search_arr['search_in'] : 'minutes';
133
-        $currency_info =$this->common->get_currency_info();
134
-        foreach ($query->result_array() as $row1) {
135
-            $atmpt = $row1['attempts'];
136
-            $cmplt = ($row1['completed'] != 0) ? $row1['completed'] : 0;
137
-            $acd = ($row1['completed'] > 0 ) ? round($row1['billable'] / $row1['completed']) : 0;
138
-            $mcd = $row1['mcd'];
139
-            if ($show_seconds == 'minutes') {
140
-                $avgsec = $acd > 0 ? sprintf('%02d',$acd / 60) . ":" . sprintf('%02d',($acd % 60)) : "00:00";
141
-                $maxsec = $mcd > 0 ? sprintf('%02d',$mcd / 60) . ":" . sprintf('%02d',($mcd % 60))  : "00:00";
142
-                $duration = ($row1['duration'] > 0 ) ? sprintf('%02d',$row1['duration'] / 60) . ":" . sprintf('%02d',($row1['duration'] % 60)) : "00:00";
143
-                $billsec = ($row1['billable'] > 0 ) ? sprintf('%02d',$row1['billable'] / 60) . ":" . sprintf('%02d',($row1['billable'] % 60)) : "00:00";
144
-            } else {
145
-                $duration = sprintf('%02d',$row1['duration']);
146
-                $avgsec = $acd;
147
-                $maxsec = $mcd;
148
-                $billsec = sprintf('%02d',$row1['billable']);
149
-            }
150
-            if ($entity != 'provider') {
151
-                $profit = $this->common->calculate_currency_manually($currency_info,$row1['debit'] - $row1['cost'],false);
152
-                $debit  = $this->common->calculate_currency_manually($currency_info,$row1['debit'],false);
153
-            }
154
-            $cost  = $this->common->calculate_currency_manually($currency_info,$row1['cost'],false);
155
-            $asr = ($atmpt > 0 ) ? (round(($cmplt / $atmpt) * 100,2)) : '0.00' ;
156
-            $new_arr = array();
157
-            if ($this->session->userdata('advance_search') == 1) {
158
-                if (!empty($search_arr['groupby_time'])) {
159
-                       $time =$row1[$search_arr['groupby_time']];
160
-                       if($search_arr['groupby_time']== "HOUR"|| $search_arr['groupby_time']== "DAY"){
129
+	function summary_report_grid($search_arr, $query, $entity, $purpose) {
130
+		$export_arr = array();
131
+		$db_field_name = $entity == 'provider' ? 'provider_id' : 'accountid';
132
+		$show_seconds = (!empty($search_arr['search_in'])) ? $search_arr['search_in'] : 'minutes';
133
+		$currency_info =$this->common->get_currency_info();
134
+		foreach ($query->result_array() as $row1) {
135
+			$atmpt = $row1['attempts'];
136
+			$cmplt = ($row1['completed'] != 0) ? $row1['completed'] : 0;
137
+			$acd = ($row1['completed'] > 0 ) ? round($row1['billable'] / $row1['completed']) : 0;
138
+			$mcd = $row1['mcd'];
139
+			if ($show_seconds == 'minutes') {
140
+				$avgsec = $acd > 0 ? sprintf('%02d',$acd / 60) . ":" . sprintf('%02d',($acd % 60)) : "00:00";
141
+				$maxsec = $mcd > 0 ? sprintf('%02d',$mcd / 60) . ":" . sprintf('%02d',($mcd % 60))  : "00:00";
142
+				$duration = ($row1['duration'] > 0 ) ? sprintf('%02d',$row1['duration'] / 60) . ":" . sprintf('%02d',($row1['duration'] % 60)) : "00:00";
143
+				$billsec = ($row1['billable'] > 0 ) ? sprintf('%02d',$row1['billable'] / 60) . ":" . sprintf('%02d',($row1['billable'] % 60)) : "00:00";
144
+			} else {
145
+				$duration = sprintf('%02d',$row1['duration']);
146
+				$avgsec = $acd;
147
+				$maxsec = $mcd;
148
+				$billsec = sprintf('%02d',$row1['billable']);
149
+			}
150
+			if ($entity != 'provider') {
151
+				$profit = $this->common->calculate_currency_manually($currency_info,$row1['debit'] - $row1['cost'],false);
152
+				$debit  = $this->common->calculate_currency_manually($currency_info,$row1['debit'],false);
153
+			}
154
+			$cost  = $this->common->calculate_currency_manually($currency_info,$row1['cost'],false);
155
+			$asr = ($atmpt > 0 ) ? (round(($cmplt / $atmpt) * 100,2)) : '0.00' ;
156
+			$new_arr = array();
157
+			if ($this->session->userdata('advance_search') == 1) {
158
+				if (!empty($search_arr['groupby_time'])) {
159
+					   $time =$row1[$search_arr['groupby_time']];
160
+					   if($search_arr['groupby_time']== "HOUR"|| $search_arr['groupby_time']== "DAY"){
161 161
 			  $time=sprintf('%02d',$time);
162
-                       }
163
-                       if($search_arr['groupby_time']== "MONTH"){
162
+					   }
163
+					   if($search_arr['groupby_time']== "MONTH"){
164 164
 			  $dateObj   = DateTime::createFromFormat('!m',$time);
165 165
 			  $time= $dateObj->format('F');
166
-                       }
167
-                    $new_arr[] = $time;
168
-                }
169
-                if ($search_arr['groupby_1'] == $db_field_name) {
170
-                    $new_arr[] = $this->common->build_concat_string("first_name,last_name,number", "accounts", $row1[$db_field_name]);
171
-                } elseif ($search_arr['groupby_1'] == 'pattern') {
172
-                    $new_arr[] = filter_var($row1['pattern'], FILTER_SANITIZE_NUMBER_INT);
173
-                    $new_arr[] = $row1['notes'];
174
-                } elseif ($search_arr['groupby_1'] == 'trunk_id') {
175
-                    $new_arr[] = $this->common->get_field_name('name', 'trunks', $row1['trunk_id']);
176
-                } elseif($search_arr['groupby_1'] == 'package_id'){
177
-		    $new_arr[] = $this->common->get_field_name('package_name', 'packages', $row1['package_id']);
178
-                }
166
+					   }
167
+					$new_arr[] = $time;
168
+				}
169
+				if ($search_arr['groupby_1'] == $db_field_name) {
170
+					$new_arr[] = $this->common->build_concat_string("first_name,last_name,number", "accounts", $row1[$db_field_name]);
171
+				} elseif ($search_arr['groupby_1'] == 'pattern') {
172
+					$new_arr[] = filter_var($row1['pattern'], FILTER_SANITIZE_NUMBER_INT);
173
+					$new_arr[] = $row1['notes'];
174
+				} elseif ($search_arr['groupby_1'] == 'trunk_id') {
175
+					$new_arr[] = $this->common->get_field_name('name', 'trunks', $row1['trunk_id']);
176
+				} elseif($search_arr['groupby_1'] == 'package_id'){
177
+			$new_arr[] = $this->common->get_field_name('package_name', 'packages', $row1['package_id']);
178
+				}
179 179
                 
180
-                if ($search_arr['groupby_2'] == $db_field_name) {
181
-                    $new_arr[] = $this->common->build_concat_string("first_name,last_name,number", "accounts", $row1[$db_field_name]);
182
-                } elseif ($search_arr['groupby_2'] == 'pattern') {
183
-                    $new_arr[] = filter_var($row1['pattern'], FILTER_SANITIZE_NUMBER_INT);
184
-                    $new_arr[] = $row1['notes'];
185
-                } elseif ($search_arr['groupby_2'] == 'trunk_id') {
186
-                    $new_arr[] = $this->common->get_field_name('name', 'trunks', $row1['trunk_id']);
187
-                } elseif($search_arr['groupby_2'] == 'package_id'){
188
-		    $new_arr[] = $this->common->get_field_name('package_name', 'packages', $row1['package_id']);
189
-                }
180
+				if ($search_arr['groupby_2'] == $db_field_name) {
181
+					$new_arr[] = $this->common->build_concat_string("first_name,last_name,number", "accounts", $row1[$db_field_name]);
182
+				} elseif ($search_arr['groupby_2'] == 'pattern') {
183
+					$new_arr[] = filter_var($row1['pattern'], FILTER_SANITIZE_NUMBER_INT);
184
+					$new_arr[] = $row1['notes'];
185
+				} elseif ($search_arr['groupby_2'] == 'trunk_id') {
186
+					$new_arr[] = $this->common->get_field_name('name', 'trunks', $row1['trunk_id']);
187
+				} elseif($search_arr['groupby_2'] == 'package_id'){
188
+			$new_arr[] = $this->common->get_field_name('package_name', 'packages', $row1['package_id']);
189
+				}
190 190
                 
191
-                if ($search_arr['groupby_3'] == $db_field_name) {
192
-                    $new_arr[] = $this->common->build_concat_string("first_name,last_name,number", "accounts", $row1[$db_field_name]);
193
-                } elseif ($search_arr['groupby_3'] == 'pattern') {
194
-                    $new_arr[] = filter_var($row1['pattern'], FILTER_SANITIZE_NUMBER_INT);
195
-                    $new_arr[] = $row1['notes'];
196
-                } elseif ($search_arr['groupby_3'] == 'trunk_id') {
197
-                    $new_arr[] = $this->common->get_field_name('name', 'trunks', $row1['trunk_id']);
198
-                }  elseif($search_arr['groupby_3'] == 'package_id'){
199
-		    $new_arr[] = $this->common->get_field_name('package_name', 'packages', $row1['package_id']);
200
-                }
201
-                if (empty($new_arr)) {
202
-                    $new_arr[] = $this->common->build_concat_string("first_name,last_name,number", "accounts", $row1[$db_field_name]);
203
-                }
204
-            } else {
205
-                $new_arr[] = $this->common->build_concat_string("first_name,last_name,number", "accounts", $row1[$db_field_name]);
206
-            }
207
-            if ($entity != 'provider') {
208
-                $custom_array = array(
209
-                    $atmpt,
210
-                    $cmplt,
211
-                    $duration,
212
-                    round($asr, 2),
213
-                    $avgsec,
214
-                    $maxsec,
215
-                    $billsec,
216
-                    $debit,
217
-                    $cost,
218
-                    $profit);
219
-            } else {
220
-                $custom_array = array(
221
-                    $atmpt,
222
-                    $cmplt,
223
-                    $duration,
224
-                    round($asr, 2),
225
-                    $avgsec,
226
-                    $maxsec,
227
-                    $billsec,
228
-                    $cost
229
-                );
230
-            }
231
-            $final_array = array_merge($new_arr, $custom_array);
232
-            $json_data[] = array('cell' => $final_array);
233
-            $export_arr[] = $final_array;
234
-        }
235
-        $function_name = 'get_' . $entity . 'summary_report_list';
236
-        $total_info = $this->summary_model->$function_name(true, '', '', '', $search_arr['select_str'],  $search_arr['order_str'],true);
237
-        $total_info = $total_info->result_array();
238
-        $total_info = $total_info[0];
239
-        $total_asr = ($total_info['attempts'] > 0 ) ? round(($total_info['completed'] / $total_info['attempts']) * 100, 2) : 0;
240
-        $total_acd = ($total_info['completed']> 0 ) ?round($total_info['billable'] / $total_info['completed']) : 0 ;
241
-        if ($show_seconds == 'minutes') {
242
-            $total_info['duration'] = $total_info['duration'] > 0 ? sprintf('%02d',$total_info['duration'] / 60) . ":" . sprintf('%02d',($total_info['duration'] % 60)) : "00:00";
243
-            $total_info['billable'] = $total_info['billable'] > 0 ? sprintf('%02d',$total_info['billable'] / 60) . ":" . sprintf('%02d',($total_info['billable'] % 60)) : "00:00";
244
-            $total_acd = $total_acd > 0 ? sprintf('%02d',$total_acd / 60) . ":" .  sprintf('%02d',($total_acd % 60)) : "00:00";
245
-            $total_info['mcd'] = $total_info['mcd'] > 0 ? sprintf('%02d',$total_info['mcd'] / 60) . ":" .  sprintf('%02d',($total_info['mcd'] % 60)) : "00:00";
246
-        }
247
-        if ($entity != 'provider') {
248
-            $total_profit =   $this->common->calculate_currency_manually($currency_info,$total_info['debit'] - $total_info['cost'],false);
249
-            $total_debit =   $this->common->calculate_currency_manually($currency_info,$total_info['debit'],false);
250
-        }
251
-        $total_cost =   $this->common->calculate_currency_manually($currency_info,$total_info['cost'],false);
252
-        if ($entity != 'provider') {
253
-            $last_array = array(
254
-                "<b>".$total_info['attempts']."</b>",
255
-                "<b>".$total_info['completed']."</b>",
256
-                "<b>".$total_info['duration']."</b>",
257
-                "<b>".$total_asr."</b>",
191
+				if ($search_arr['groupby_3'] == $db_field_name) {
192
+					$new_arr[] = $this->common->build_concat_string("first_name,last_name,number", "accounts", $row1[$db_field_name]);
193
+				} elseif ($search_arr['groupby_3'] == 'pattern') {
194
+					$new_arr[] = filter_var($row1['pattern'], FILTER_SANITIZE_NUMBER_INT);
195
+					$new_arr[] = $row1['notes'];
196
+				} elseif ($search_arr['groupby_3'] == 'trunk_id') {
197
+					$new_arr[] = $this->common->get_field_name('name', 'trunks', $row1['trunk_id']);
198
+				}  elseif($search_arr['groupby_3'] == 'package_id'){
199
+			$new_arr[] = $this->common->get_field_name('package_name', 'packages', $row1['package_id']);
200
+				}
201
+				if (empty($new_arr)) {
202
+					$new_arr[] = $this->common->build_concat_string("first_name,last_name,number", "accounts", $row1[$db_field_name]);
203
+				}
204
+			} else {
205
+				$new_arr[] = $this->common->build_concat_string("first_name,last_name,number", "accounts", $row1[$db_field_name]);
206
+			}
207
+			if ($entity != 'provider') {
208
+				$custom_array = array(
209
+					$atmpt,
210
+					$cmplt,
211
+					$duration,
212
+					round($asr, 2),
213
+					$avgsec,
214
+					$maxsec,
215
+					$billsec,
216
+					$debit,
217
+					$cost,
218
+					$profit);
219
+			} else {
220
+				$custom_array = array(
221
+					$atmpt,
222
+					$cmplt,
223
+					$duration,
224
+					round($asr, 2),
225
+					$avgsec,
226
+					$maxsec,
227
+					$billsec,
228
+					$cost
229
+				);
230
+			}
231
+			$final_array = array_merge($new_arr, $custom_array);
232
+			$json_data[] = array('cell' => $final_array);
233
+			$export_arr[] = $final_array;
234
+		}
235
+		$function_name = 'get_' . $entity . 'summary_report_list';
236
+		$total_info = $this->summary_model->$function_name(true, '', '', '', $search_arr['select_str'],  $search_arr['order_str'],true);
237
+		$total_info = $total_info->result_array();
238
+		$total_info = $total_info[0];
239
+		$total_asr = ($total_info['attempts'] > 0 ) ? round(($total_info['completed'] / $total_info['attempts']) * 100, 2) : 0;
240
+		$total_acd = ($total_info['completed']> 0 ) ?round($total_info['billable'] / $total_info['completed']) : 0 ;
241
+		if ($show_seconds == 'minutes') {
242
+			$total_info['duration'] = $total_info['duration'] > 0 ? sprintf('%02d',$total_info['duration'] / 60) . ":" . sprintf('%02d',($total_info['duration'] % 60)) : "00:00";
243
+			$total_info['billable'] = $total_info['billable'] > 0 ? sprintf('%02d',$total_info['billable'] / 60) . ":" . sprintf('%02d',($total_info['billable'] % 60)) : "00:00";
244
+			$total_acd = $total_acd > 0 ? sprintf('%02d',$total_acd / 60) . ":" .  sprintf('%02d',($total_acd % 60)) : "00:00";
245
+			$total_info['mcd'] = $total_info['mcd'] > 0 ? sprintf('%02d',$total_info['mcd'] / 60) . ":" .  sprintf('%02d',($total_info['mcd'] % 60)) : "00:00";
246
+		}
247
+		if ($entity != 'provider') {
248
+			$total_profit =   $this->common->calculate_currency_manually($currency_info,$total_info['debit'] - $total_info['cost'],false);
249
+			$total_debit =   $this->common->calculate_currency_manually($currency_info,$total_info['debit'],false);
250
+		}
251
+		$total_cost =   $this->common->calculate_currency_manually($currency_info,$total_info['cost'],false);
252
+		if ($entity != 'provider') {
253
+			$last_array = array(
254
+				"<b>".$total_info['attempts']."</b>",
255
+				"<b>".$total_info['completed']."</b>",
256
+				"<b>".$total_info['duration']."</b>",
257
+				"<b>".$total_asr."</b>",
258 258
 		"<b>".$total_acd."</b>",
259 259
 		"<b>".$total_info['mcd']."</b>",
260 260
 		"<b>".$total_info['billable']."</b>",
261 261
 		"<b>".$total_debit."</b>",
262 262
 		"<b>".$total_cost."</b>",
263 263
 		"<b>".$total_profit."</b>"
264
-            );
265
-        } else {
266
-            $last_array = array(
267
-                 "<b>".$total_info['attempts']."</b>",
268
-                 "<b>".$total_info['completed']."</b>",
269
-                 "<b>".$total_info['duration']."</b>",
270
-                 "<b>".$total_asr."</b>",
271
-                 "<b>".$total_acd."</b>",
272
-                 "<b>".$total_info['mcd']."</b>",
273
-                 "<b>".$total_info['billable']."</b>",
274
-                 "<b>".$total_cost."</b>",
275
-            );
276
-        }
277
-        if ($purpose == 'export') {
278
-            $search_arr['custom_total_array'][0] = "Grand Total";
279
-        }
280
-        $new_export_array=array();
281
-        foreach($last_array as $key=>$value){
264
+			);
265
+		} else {
266
+			$last_array = array(
267
+				 "<b>".$total_info['attempts']."</b>",
268
+				 "<b>".$total_info['completed']."</b>",
269
+				 "<b>".$total_info['duration']."</b>",
270
+				 "<b>".$total_asr."</b>",
271
+				 "<b>".$total_acd."</b>",
272
+				 "<b>".$total_info['mcd']."</b>",
273
+				 "<b>".$total_info['billable']."</b>",
274
+				 "<b>".$total_cost."</b>",
275
+			);
276
+		}
277
+		if ($purpose == 'export') {
278
+			$search_arr['custom_total_array'][0] = "Grand Total";
279
+		}
280
+		$new_export_array=array();
281
+		foreach($last_array as $key=>$value){
282 282
 	  $value=str_replace("<b>","",$value);
283 283
 	  $value=str_replace("</b>",'',$value);
284 284
 	  if($key == 7 || $key ==8 || $key ==9){
285
-	      $value = sprintf("%.".$currency_info['decimalpoints']."f",floatval(preg_replace('/[^\d.]/', '', $value)));
285
+		  $value = sprintf("%.".$currency_info['decimalpoints']."f",floatval(preg_replace('/[^\d.]/', '', $value)));
286 286
 	  }
287 287
 	  $new_export_array[$key]=$value;
288
-        }
289
-        $total_array = array_merge($search_arr['custom_total_array'], $last_array);
290
-        $custom_export_arr =array_merge($search_arr['custom_total_array'],$new_export_array);
291
-        $export_arr[] = $custom_export_arr;
292
-        $json_data[] = array('cell' => $total_array);
293
-        return $purpose == 'grid' ? $json_data : $export_arr;
294
-    }
288
+		}
289
+		$total_array = array_merge($search_arr['custom_total_array'], $last_array);
290
+		$custom_export_arr =array_merge($search_arr['custom_total_array'],$new_export_array);
291
+		$export_arr[] = $custom_export_arr;
292
+		$json_data[] = array('cell' => $total_array);
293
+		return $purpose == 'grid' ? $json_data : $export_arr;
294
+	}
295 295
 
296
-    function customer_export_csv() {
296
+	function customer_export_csv() {
297 297
 		$account_info = $accountinfo = $this->session->userdata('accountinfo');
298 298
 		$currency_id=$account_info['currency_id'];
299 299
 		$currency=$this->common->get_field_name('currency', 'currency', $currency_id);
300
-        $search_arr = $this->session->userdata('customersummary_reports_export');
301
-        $data_arr = array();
302
-        $query = $this->summary_model->get_customersummary_report_list(true, '', '', $search_arr['group_by_str'], $search_arr['select_str'],$search_arr['order_str'], true);
303
-        $search_header = explode(",", $search_arr['export_str']);
304
-        ob_clean();
305
-        $fixed_header = array('Attempted Calls','Completed Calls','Duration', 'ASR', 'ACD','MCD','Billable', 'Debit('.$currency.')','Cost('.$currency.')','Profit');
306
-        $header_arr[] = array_merge($search_header, $fixed_header);
307
-        if ($query->num_rows() > 0) {
308
-            $data_arr = $this->summary_report_grid($search_arr, $query, 'customer', 'export');
309
-        } 
310
-        $customer_array = array_merge($header_arr, $data_arr);
300
+		$search_arr = $this->session->userdata('customersummary_reports_export');
301
+		$data_arr = array();
302
+		$query = $this->summary_model->get_customersummary_report_list(true, '', '', $search_arr['group_by_str'], $search_arr['select_str'],$search_arr['order_str'], true);
303
+		$search_header = explode(",", $search_arr['export_str']);
304
+		ob_clean();
305
+		$fixed_header = array('Attempted Calls','Completed Calls','Duration', 'ASR', 'ACD','MCD','Billable', 'Debit('.$currency.')','Cost('.$currency.')','Profit');
306
+		$header_arr[] = array_merge($search_header, $fixed_header);
307
+		if ($query->num_rows() > 0) {
308
+			$data_arr = $this->summary_report_grid($search_arr, $query, 'customer', 'export');
309
+		} 
310
+		$customer_array = array_merge($header_arr, $data_arr);
311 311
 
312
-        $this->load->helper('csv');
313
-        array_to_csv($customer_array, 'Customer_Summary_Report_' . date("Y-m-d") . '.csv');
314
-    }
312
+		$this->load->helper('csv');
313
+		array_to_csv($customer_array, 'Customer_Summary_Report_' . date("Y-m-d") . '.csv');
314
+	}
315 315
 
316
-    function customer_search() {
317
-        if ($this->input->post('advance_search', TRUE) == 1) {
318
-            $this->session->set_userdata('advance_search', $this->input->post('advance_search'));
319
-            unset($_POST['action']);
320
-            unset($_POST['advance_search']);
321
-            $this->session->set_userdata('customersummary_reports_search', $this->input->post());
322
-        }
323
-        redirect(base_url() . 'summary/customer/');
324
-    }
316
+	function customer_search() {
317
+		if ($this->input->post('advance_search', TRUE) == 1) {
318
+			$this->session->set_userdata('advance_search', $this->input->post('advance_search'));
319
+			unset($_POST['action']);
320
+			unset($_POST['advance_search']);
321
+			$this->session->set_userdata('customersummary_reports_search', $this->input->post());
322
+		}
323
+		redirect(base_url() . 'summary/customer/');
324
+	}
325 325
 
326
-    function customer_clearsearchfilter() {
327
-        $this->session->set_userdata('advance_search', 0);
328
-        $this->session->set_userdata('customersummary_reports_search', "");
329
-        $this->session->set_userdata('customersummary_reports_export', "");
330
-        redirect(base_url() . 'summary/customer/');
331
-    }
326
+	function customer_clearsearchfilter() {
327
+		$this->session->set_userdata('advance_search', 0);
328
+		$this->session->set_userdata('customersummary_reports_search', "");
329
+		$this->session->set_userdata('customersummary_reports_export', "");
330
+		redirect(base_url() . 'summary/customer/');
331
+	}
332 332
 
333
-    function summary_search_info($entity) {
334
-        $group_by_str = null;
335
-        $select_str = null;
336
-        $group_by_time=null;
337
-        $group_by_1 = null;
338
-        $group_by_2 = null;
339
-        $group_by_3 = null;
340
-        $order_str=null;
341
-        $custom_total_array = array();
342
-        $custom_search = array();
343
-        $export_select_str = null;
344
-        $new_arr['search_in'] = 'minutes';
345
-        $i = 0;
346
-        $db_field_name = $entity == 'provider' ? 'provider_id' : 'accountid';
347
-        if ($this->session->userdata('advance_search') == 1) {
348
-            $custom_search = $this->session->userdata($entity . 'summary_reports_search');
349
-            if (isset($custom_search['time']) && !empty($custom_search['time'])) {
350
-                $group_by_str.=$custom_search['time'] . "(callstart),";
351
-                $select_str.=$custom_search['time'] . "(callstart) as ".$custom_search['time'].",";
352
-                $order_str.=$custom_search['time'].",";
353
-                $group_by_time = $custom_search['time'];
354
-                $export_select_str.=$custom_search['time'].",";
355
-                $custom_total_array[$i] = null;
356
-                $i++;
357
-            }
358
-            if (isset($custom_search['groupby_1']) && !empty($custom_search['groupby_1'])) {
359
-                $group_by_str.=$custom_search['groupby_1'] . ",";
360
-                $select_str.=$custom_search['groupby_1'] . ",";
361
-                $order_str.=$custom_search['groupby_1'] . ",";
362
-                $group_by_1 = $custom_search['groupby_1'];
363
-                if ($custom_search['groupby_1'] == $db_field_name) {
364
-                    $export_select_str.='Account,';
365
-                } elseif ($custom_search['groupby_1'] == 'trunk_id') {
366
-                    $export_select_str.='Trunk,';
367
-                } elseif ($custom_search['groupby_1'] == 'pattern') {
368
-                    $select_str.='notes,';
369
-                    $order_str.='notes,';
370
-                    $export_select_str.="Code,Destination,";
371
-                    $custom_total_array[$i] = null;
372
-                    $i++;
373
-                } elseif($custom_search['groupby_1'] =='package_id'){
374
-		    $export_select_str.='Package,';
375
-                }
376
-                $custom_total_array[$i] = null;
377
-                $i++;
378
-            }
333
+	function summary_search_info($entity) {
334
+		$group_by_str = null;
335
+		$select_str = null;
336
+		$group_by_time=null;
337
+		$group_by_1 = null;
338
+		$group_by_2 = null;
339
+		$group_by_3 = null;
340
+		$order_str=null;
341
+		$custom_total_array = array();
342
+		$custom_search = array();
343
+		$export_select_str = null;
344
+		$new_arr['search_in'] = 'minutes';
345
+		$i = 0;
346
+		$db_field_name = $entity == 'provider' ? 'provider_id' : 'accountid';
347
+		if ($this->session->userdata('advance_search') == 1) {
348
+			$custom_search = $this->session->userdata($entity . 'summary_reports_search');
349
+			if (isset($custom_search['time']) && !empty($custom_search['time'])) {
350
+				$group_by_str.=$custom_search['time'] . "(callstart),";
351
+				$select_str.=$custom_search['time'] . "(callstart) as ".$custom_search['time'].",";
352
+				$order_str.=$custom_search['time'].",";
353
+				$group_by_time = $custom_search['time'];
354
+				$export_select_str.=$custom_search['time'].",";
355
+				$custom_total_array[$i] = null;
356
+				$i++;
357
+			}
358
+			if (isset($custom_search['groupby_1']) && !empty($custom_search['groupby_1'])) {
359
+				$group_by_str.=$custom_search['groupby_1'] . ",";
360
+				$select_str.=$custom_search['groupby_1'] . ",";
361
+				$order_str.=$custom_search['groupby_1'] . ",";
362
+				$group_by_1 = $custom_search['groupby_1'];
363
+				if ($custom_search['groupby_1'] == $db_field_name) {
364
+					$export_select_str.='Account,';
365
+				} elseif ($custom_search['groupby_1'] == 'trunk_id') {
366
+					$export_select_str.='Trunk,';
367
+				} elseif ($custom_search['groupby_1'] == 'pattern') {
368
+					$select_str.='notes,';
369
+					$order_str.='notes,';
370
+					$export_select_str.="Code,Destination,";
371
+					$custom_total_array[$i] = null;
372
+					$i++;
373
+				} elseif($custom_search['groupby_1'] =='package_id'){
374
+			$export_select_str.='Package,';
375
+				}
376
+				$custom_total_array[$i] = null;
377
+				$i++;
378
+			}
379 379
             
380
-            if (isset($custom_search['groupby_2']) && !empty($custom_search['groupby_2'])) {
381
-                $group_by_str.=$custom_search['groupby_2'] . ",";
382
-                $select_str.=$custom_search['groupby_2'] . ",";
383
-                $order_str.=$custom_search['groupby_2'] . ",";
384
-                $group_by_2 = $custom_search['groupby_2'];
385
-                if ($custom_search['groupby_2'] == $db_field_name) {
386
-                    $export_select_str.='Account,';
387
-                } elseif ($custom_search['groupby_2'] == 'trunk_id') {
388
-                    $export_select_str.='Trunk,';
389
-                } elseif ($custom_search['groupby_2'] == 'pattern') {
390
-                    $select_str.='notes,';
391
-                    $order_str.='notes,';
392
-                    $export_select_str.="Code,Destination,";
393
-                    $custom_total_array[$i] = null;
394
-                    $i++;
395
-                } elseif($custom_search['groupby_2'] =='package_id'){
396
-		    $export_select_str.='Package,';
397
-                }
398
-                $custom_total_array[$i] = null;
399
-                $i++;
400
-            }
380
+			if (isset($custom_search['groupby_2']) && !empty($custom_search['groupby_2'])) {
381
+				$group_by_str.=$custom_search['groupby_2'] . ",";
382
+				$select_str.=$custom_search['groupby_2'] . ",";
383
+				$order_str.=$custom_search['groupby_2'] . ",";
384
+				$group_by_2 = $custom_search['groupby_2'];
385
+				if ($custom_search['groupby_2'] == $db_field_name) {
386
+					$export_select_str.='Account,';
387
+				} elseif ($custom_search['groupby_2'] == 'trunk_id') {
388
+					$export_select_str.='Trunk,';
389
+				} elseif ($custom_search['groupby_2'] == 'pattern') {
390
+					$select_str.='notes,';
391
+					$order_str.='notes,';
392
+					$export_select_str.="Code,Destination,";
393
+					$custom_total_array[$i] = null;
394
+					$i++;
395
+				} elseif($custom_search['groupby_2'] =='package_id'){
396
+			$export_select_str.='Package,';
397
+				}
398
+				$custom_total_array[$i] = null;
399
+				$i++;
400
+			}
401 401
 
402
-            if (isset($custom_search['groupby_3']) && !empty($custom_search['groupby_3'])) {
403
-                $group_by_str.=$custom_search['groupby_3'] . ",";
404
-                $select_str.=$custom_search['groupby_3'] . ",";
405
-                $order_str.=$custom_search['groupby_3'] . ",";
406
-                $group_by_3 = $custom_search['groupby_3'];
407
-                if ($custom_search['groupby_3'] == 'accountid' || $custom_search['groupby_3'] == 'provider_id') {
408
-                    $export_select_str.='Account,';
409
-                } elseif ($custom_search['groupby_3'] == 'trunk_id') {
410
-                    $export_select_str.='Trunk,';
411
-                } elseif ($custom_search['groupby_3'] == 'pattern') {
412
-                    $select_str.='notes,';
413
-                    $order_str.='notes,';
414
-                    $export_select_str.="Code,Destination,";
415
-                    $custom_total_array[$i] = null;
416
-                    $i++;
417
-                } elseif($custom_search['groupby_3'] =='package_id'){
418
-		    $export_select_str.='Package,';
419
-                }
420
-                $custom_total_array[$i] = null;
421
-                $i++;
422
-            }
423
-            $new_arr['search_in'] = (isset($custom_search['search_in']) && !empty($custom_search['search_in'])) ? $custom_search['search_in'] : 'minutes';
424
-            unset($custom_search['groupby_1'], $custom_search['groupby_2'], $custom_search['groupby_3'], $custom_search['search_in']);
425
-            $this->session->set_userdata('summary_' . $entity . '_search', $custom_search);
426
-        }
427
-        if (!empty($group_by_str)) {
428
-            $group_by_str = rtrim($group_by_str, ",");
429
-            $select_str = rtrim($select_str, ",");
430
-            $order_str = rtrim($order_str, ",");
431
-            $export_select_str = rtrim($export_select_str, ",");
432
-        } else {
433
-            $select_str = $db_field_name;
434
-            $order_str = $db_field_name;
435
-            $group_by_str = $db_field_name;
436
-            $export_select_str = "Account";
437
-        }
402
+			if (isset($custom_search['groupby_3']) && !empty($custom_search['groupby_3'])) {
403
+				$group_by_str.=$custom_search['groupby_3'] . ",";
404
+				$select_str.=$custom_search['groupby_3'] . ",";
405
+				$order_str.=$custom_search['groupby_3'] . ",";
406
+				$group_by_3 = $custom_search['groupby_3'];
407
+				if ($custom_search['groupby_3'] == 'accountid' || $custom_search['groupby_3'] == 'provider_id') {
408
+					$export_select_str.='Account,';
409
+				} elseif ($custom_search['groupby_3'] == 'trunk_id') {
410
+					$export_select_str.='Trunk,';
411
+				} elseif ($custom_search['groupby_3'] == 'pattern') {
412
+					$select_str.='notes,';
413
+					$order_str.='notes,';
414
+					$export_select_str.="Code,Destination,";
415
+					$custom_total_array[$i] = null;
416
+					$i++;
417
+				} elseif($custom_search['groupby_3'] =='package_id'){
418
+			$export_select_str.='Package,';
419
+				}
420
+				$custom_total_array[$i] = null;
421
+				$i++;
422
+			}
423
+			$new_arr['search_in'] = (isset($custom_search['search_in']) && !empty($custom_search['search_in'])) ? $custom_search['search_in'] : 'minutes';
424
+			unset($custom_search['groupby_1'], $custom_search['groupby_2'], $custom_search['groupby_3'], $custom_search['search_in']);
425
+			$this->session->set_userdata('summary_' . $entity . '_search', $custom_search);
426
+		}
427
+		if (!empty($group_by_str)) {
428
+			$group_by_str = rtrim($group_by_str, ",");
429
+			$select_str = rtrim($select_str, ",");
430
+			$order_str = rtrim($order_str, ",");
431
+			$export_select_str = rtrim($export_select_str, ",");
432
+		} else {
433
+			$select_str = $db_field_name;
434
+			$order_str = $db_field_name;
435
+			$group_by_str = $db_field_name;
436
+			$export_select_str = "Account";
437
+		}
438 438
 
439
-        array_pop($custom_total_array);
440
-        array_unshift($custom_total_array, '<b>Grand Total</b>');
441
-        $new_arr['export_str'] = $export_select_str;
442
-        $new_arr['select_str'] = $select_str;
443
-        $new_arr['order_str'] = $order_str;
444
-        $new_arr['group_by_str'] = $group_by_str;
445
-        $new_arr['groupby_1'] = $group_by_1;
446
-        $new_arr['groupby_2'] = $group_by_2;
447
-        $new_arr['groupby_3'] = $group_by_3;
448
-        $new_arr['groupby_time']=$group_by_time;
449
-        $new_arr['custom_total_array'] = $custom_total_array;
450
-        return $new_arr;
451
-    }
439
+		array_pop($custom_total_array);
440
+		array_unshift($custom_total_array, '<b>Grand Total</b>');
441
+		$new_arr['export_str'] = $export_select_str;
442
+		$new_arr['select_str'] = $select_str;
443
+		$new_arr['order_str'] = $order_str;
444
+		$new_arr['group_by_str'] = $group_by_str;
445
+		$new_arr['groupby_1'] = $group_by_1;
446
+		$new_arr['groupby_2'] = $group_by_2;
447
+		$new_arr['groupby_3'] = $group_by_3;
448
+		$new_arr['groupby_time']=$group_by_time;
449
+		$new_arr['custom_total_array'] = $custom_total_array;
450
+		return $new_arr;
451
+	}
452 452
 
453
-    function provider() {
454
-        $data['page_title'] = 'Provider Summary Report';
455
-        $data['search_flag'] = true;
456
-        $session_info = $this->session->userdata('providersummary_reports_search');
457
-        $accountlist = $this->db_model->build_dropdown_deleted('id,IF(`deleted`=1,concat( first_name, " ", last_name, " ", "(", number, ")^" ),concat( first_name, " ", last_name, " ", "(", number, ")" )) as number', 'accounts', 'where_arr', array("type" => "3"));
458
-        $trunklist = $this->db_model->build_dropdown('id,name', 'trunks', '', array());
459
-        $data['trunklist'] = $trunklist;
460
-        $data['accountlist'] = $accountlist;
461
-        $data['session_info'] = $session_info;
462
-        $data['seconds'] = $this->session->userdata('provider_seconds');
463
-        $data['search_report'] = $this->common->search_report_in();
464
-        $data['grid_fields'] = $this->summary_form->build_providersummary();
465
-        $data["grid_buttons"] = $this->summary_form->build_grid_buttons_providersummary();
466
-        $data['search_string_type'] = $this->common->search_string_type();
467
-        $data['groupby_field'] = $this->common->set_summaryprovider_groupby();
468
-        $data['groupby_time'] = $this->common->group_by_time();
469
-        $this->load->view('view_providersummary_report', $data);
470
-    }
453
+	function provider() {
454
+		$data['page_title'] = 'Provider Summary Report';
455
+		$data['search_flag'] = true;
456
+		$session_info = $this->session->userdata('providersummary_reports_search');
457
+		$accountlist = $this->db_model->build_dropdown_deleted('id,IF(`deleted`=1,concat( first_name, " ", last_name, " ", "(", number, ")^" ),concat( first_name, " ", last_name, " ", "(", number, ")" )) as number', 'accounts', 'where_arr', array("type" => "3"));
458
+		$trunklist = $this->db_model->build_dropdown('id,name', 'trunks', '', array());
459
+		$data['trunklist'] = $trunklist;
460
+		$data['accountlist'] = $accountlist;
461
+		$data['session_info'] = $session_info;
462
+		$data['seconds'] = $this->session->userdata('provider_seconds');
463
+		$data['search_report'] = $this->common->search_report_in();
464
+		$data['grid_fields'] = $this->summary_form->build_providersummary();
465
+		$data["grid_buttons"] = $this->summary_form->build_grid_buttons_providersummary();
466
+		$data['search_string_type'] = $this->common->search_string_type();
467
+		$data['groupby_field'] = $this->common->set_summaryprovider_groupby();
468
+		$data['groupby_time'] = $this->common->group_by_time();
469
+		$this->load->view('view_providersummary_report', $data);
470
+	}
471 471
 
472
-    function provider_json() {
473
-        $search_arr = $this->summary_search_info('provider');
474
-        $count_all = $this->summary_model->get_providersummary_report_list(false,'','', $search_arr['group_by_str'], $search_arr['select_str'], $search_arr['order_str'],false);
475
-        $paging_data = $this->form->load_grid_config($count_all, $_GET['rp'], $_GET['page']);
476
-        $json_data = $paging_data["json_paging"];
477
-        $query = $this->summary_model->get_providersummary_report_list(true, $paging_data["paging"]["start"], $paging_data["paging"]["page_no"], $search_arr['group_by_str'], $search_arr['select_str'],$search_arr['order_str'], false);
478
-        if ($query->num_rows() > 0) {
479
-            $json_data['rows'] = $this->summary_report_grid($search_arr, $query, 'provider', 'grid');
480
-        }
481
-        $this->session->set_userdata('providersummary_reports_export', $search_arr);
482
-        echo json_encode($json_data);
483
-    }
472
+	function provider_json() {
473
+		$search_arr = $this->summary_search_info('provider');
474
+		$count_all = $this->summary_model->get_providersummary_report_list(false,'','', $search_arr['group_by_str'], $search_arr['select_str'], $search_arr['order_str'],false);
475
+		$paging_data = $this->form->load_grid_config($count_all, $_GET['rp'], $_GET['page']);
476
+		$json_data = $paging_data["json_paging"];
477
+		$query = $this->summary_model->get_providersummary_report_list(true, $paging_data["paging"]["start"], $paging_data["paging"]["page_no"], $search_arr['group_by_str'], $search_arr['select_str'],$search_arr['order_str'], false);
478
+		if ($query->num_rows() > 0) {
479
+			$json_data['rows'] = $this->summary_report_grid($search_arr, $query, 'provider', 'grid');
480
+		}
481
+		$this->session->set_userdata('providersummary_reports_export', $search_arr);
482
+		echo json_encode($json_data);
483
+	}
484 484
 
485
-    function provider_export_csv() {
485
+	function provider_export_csv() {
486 486
 		$account_info = $accountinfo = $this->session->userdata('accountinfo');
487 487
 		$currency_id=$account_info['currency_id'];
488 488
 		$currency=$this->common->get_field_name('currency', 'currency', $currency_id);
489
-        $search_arr = $this->session->userdata('providersummary_reports_export');
490
-        $data_arr = array();
491
-        $query = $this->summary_model->get_providersummary_report_list(true, '', '', $search_arr['group_by_str'], $search_arr['select_str'],$search_arr['order_str'], true);
492
-        $search_header = explode(",", $search_arr['export_str']);
493
-        ob_clean();
494
-        $fixed_header = array("Attempted Calls", "Completed Calls", "Duration", "ASR", "ACD", "MCD", "Billable", "Cost($currency)");
495
-        $header_arr[] = array_merge($search_header, $fixed_header);
496
-        if ($query->num_rows() > 0) {
497
-            $data_arr = $this->summary_report_grid($search_arr, $query, 'provider', 'export');
498
-        }
499
-        $provider_array = array_merge($header_arr, $data_arr);
489
+		$search_arr = $this->session->userdata('providersummary_reports_export');
490
+		$data_arr = array();
491
+		$query = $this->summary_model->get_providersummary_report_list(true, '', '', $search_arr['group_by_str'], $search_arr['select_str'],$search_arr['order_str'], true);
492
+		$search_header = explode(",", $search_arr['export_str']);
493
+		ob_clean();
494
+		$fixed_header = array("Attempted Calls", "Completed Calls", "Duration", "ASR", "ACD", "MCD", "Billable", "Cost($currency)");
495
+		$header_arr[] = array_merge($search_header, $fixed_header);
496
+		if ($query->num_rows() > 0) {
497
+			$data_arr = $this->summary_report_grid($search_arr, $query, 'provider', 'export');
498
+		}
499
+		$provider_array = array_merge($header_arr, $data_arr);
500 500
 
501
-        $this->load->helper('csv');
502
-        array_to_csv($provider_array, 'Provider_Summary_Report_' . date("Y-m-d") . '.csv');
503
-    }
501
+		$this->load->helper('csv');
502
+		array_to_csv($provider_array, 'Provider_Summary_Report_' . date("Y-m-d") . '.csv');
503
+	}
504 504
 
505
-    function provider_search() {
506
-        if ($this->input->post('advance_search', TRUE) == 1) {
507
-            $this->session->set_userdata('advance_search', $this->input->post('advance_search'));
508
-            unset($_POST['action'], $_POST['advance_search']);
509
-            $this->session->set_userdata('providersummary_reports_search', $this->input->post());
510
-        }
511
-        redirect(base_url() . 'summary/provider/');
512
-    }
505
+	function provider_search() {
506
+		if ($this->input->post('advance_search', TRUE) == 1) {
507
+			$this->session->set_userdata('advance_search', $this->input->post('advance_search'));
508
+			unset($_POST['action'], $_POST['advance_search']);
509
+			$this->session->set_userdata('providersummary_reports_search', $this->input->post());
510
+		}
511
+		redirect(base_url() . 'summary/provider/');
512
+	}
513 513
 
514
-    function provider_clearsearchfilter() {
515
-        $this->session->set_userdata('advance_search', 0);
516
-        $this->session->set_userdata('providersummary_reports_search', "");
517
-        $this->session->set_userdata('providersummary_reports_export', "");
518
-        redirect(base_url() . "summary/provider/");
519
-    }
514
+	function provider_clearsearchfilter() {
515
+		$this->session->set_userdata('advance_search', 0);
516
+		$this->session->set_userdata('providersummary_reports_search', "");
517
+		$this->session->set_userdata('providersummary_reports_export', "");
518
+		redirect(base_url() . "summary/provider/");
519
+	}
520 520
 
521
-    function reseller() {
522
-        $data['username'] = $this->session->userdata('user_name');
523
-        $data['page_title'] = 'Reseller Summary Report';
524
-        $data['search_flag'] = true;
525
-        $session_info = $this->session->userdata('resellersummary_reports_search');
526
-        $accountinfo = $this->session->userdata('accountinfo');
527
-        $reseller_id = $accountinfo['type'] == 1 ? $accountinfo['id'] : 0;
528
-        $accountlist = $this->db_model->build_dropdown_deleted('id,IF(`deleted`=1,concat( first_name, " ", last_name, " ", "(", number, ")^" ),concat( first_name, " ", last_name, " ", "(", number, ")" )) as number', 'accounts', 'where_arr', array('reseller_id' => $reseller_id, "type" => "1"));
529
-        $data['accountlist'] = $accountlist;
530
-        $data['seconds'] = $this->session->userdata('reseller_seconds');
531
-        $data['session_info'] = $session_info;
532
-        $data['search_report'] = $this->common->search_report_in();
533
-        $data['search_string_type'] = $this->common->search_string_type();
534
-        $new_column_arr = $this->summary_column_arr('reseller');
535
-        $data['grid_fields'] = $this->summary_form->build_resellersummary($new_column_arr);
536
-        $data["grid_buttons"] = $this->summary_form->build_grid_buttons_resellersummary();
537
-        $data['groupby_field'] = $this->common->set_summarycustomer_groupby();
538
-        $data['groupby_time'] = $this->common->group_by_time();
539
-        $this->load->view('view_resellersummary_report', $data);
540
-    }
521
+	function reseller() {
522
+		$data['username'] = $this->session->userdata('user_name');
523
+		$data['page_title'] = 'Reseller Summary Report';
524
+		$data['search_flag'] = true;
525
+		$session_info = $this->session->userdata('resellersummary_reports_search');
526
+		$accountinfo = $this->session->userdata('accountinfo');
527
+		$reseller_id = $accountinfo['type'] == 1 ? $accountinfo['id'] : 0;
528
+		$accountlist = $this->db_model->build_dropdown_deleted('id,IF(`deleted`=1,concat( first_name, " ", last_name, " ", "(", number, ")^" ),concat( first_name, " ", last_name, " ", "(", number, ")" )) as number', 'accounts', 'where_arr', array('reseller_id' => $reseller_id, "type" => "1"));
529
+		$data['accountlist'] = $accountlist;
530
+		$data['seconds'] = $this->session->userdata('reseller_seconds');
531
+		$data['session_info'] = $session_info;
532
+		$data['search_report'] = $this->common->search_report_in();
533
+		$data['search_string_type'] = $this->common->search_string_type();
534
+		$new_column_arr = $this->summary_column_arr('reseller');
535
+		$data['grid_fields'] = $this->summary_form->build_resellersummary($new_column_arr);
536
+		$data["grid_buttons"] = $this->summary_form->build_grid_buttons_resellersummary();
537
+		$data['groupby_field'] = $this->common->set_summarycustomer_groupby();
538
+		$data['groupby_time'] = $this->common->group_by_time();
539
+		$this->load->view('view_resellersummary_report', $data);
540
+	}
541 541
 
542
-    function reseller_json() {
543
-        $search_arr = $this->summary_search_info('reseller');
544
-        $count_all = $this->summary_model->get_resellersummary_report_list(false, 0, 0, $search_arr['group_by_str'], $search_arr['select_str'],$search_arr['order_str'],false);
545
-        $paging_data = $this->form->load_grid_config($count_all, $_GET['rp'], $_GET['page']);
546
-        $json_data = $paging_data["json_paging"];
547
-        $query = $this->summary_model->get_resellersummary_report_list(true, $paging_data["paging"]["start"], $paging_data["paging"]["page_no"], $search_arr['group_by_str'], $search_arr['select_str'],$search_arr['order_str'], false);
548
-        if ($query->num_rows() > 0) {
549
-            $json_data['rows'] = $this->summary_report_grid($search_arr, $query, 'reseller', 'grid');
550
-        }
551
-        $this->session->set_userdata('resellersummary_reports_export', $search_arr);
552
-        echo json_encode($json_data);
553
-    }
542
+	function reseller_json() {
543
+		$search_arr = $this->summary_search_info('reseller');
544
+		$count_all = $this->summary_model->get_resellersummary_report_list(false, 0, 0, $search_arr['group_by_str'], $search_arr['select_str'],$search_arr['order_str'],false);
545
+		$paging_data = $this->form->load_grid_config($count_all, $_GET['rp'], $_GET['page']);
546
+		$json_data = $paging_data["json_paging"];
547
+		$query = $this->summary_model->get_resellersummary_report_list(true, $paging_data["paging"]["start"], $paging_data["paging"]["page_no"], $search_arr['group_by_str'], $search_arr['select_str'],$search_arr['order_str'], false);
548
+		if ($query->num_rows() > 0) {
549
+			$json_data['rows'] = $this->summary_report_grid($search_arr, $query, 'reseller', 'grid');
550
+		}
551
+		$this->session->set_userdata('resellersummary_reports_export', $search_arr);
552
+		echo json_encode($json_data);
553
+	}
554 554
 
555
-    function reseller_search() {
556
-        if ($this->input->post('advance_search', TRUE) == 1) {
557
-            $this->session->set_userdata('advance_search', $this->input->post('advance_search'));
558
-            unset($_POST['action'], $_POST['advance_search']);
559
-            $this->session->set_userdata('resellersummary_reports_search', $this->input->post());
560
-        }
561
-        redirect(base_url() . "summary/reseller/");
562
-    }
555
+	function reseller_search() {
556
+		if ($this->input->post('advance_search', TRUE) == 1) {
557
+			$this->session->set_userdata('advance_search', $this->input->post('advance_search'));
558
+			unset($_POST['action'], $_POST['advance_search']);
559
+			$this->session->set_userdata('resellersummary_reports_search', $this->input->post());
560
+		}
561
+		redirect(base_url() . "summary/reseller/");
562
+	}
563 563
 
564
-    function reseller_clearsearchfilter() {
565
-        $this->session->set_userdata('advance_search', 0);
566
-        $this->session->set_userdata('resellersummary_reports_search', "");
567
-        $this->session->set_userdata('resellersummary_reports_export', "");
568
-        redirect(base_url() . "summary/reseller/");
569
-    }
564
+	function reseller_clearsearchfilter() {
565
+		$this->session->set_userdata('advance_search', 0);
566
+		$this->session->set_userdata('resellersummary_reports_search', "");
567
+		$this->session->set_userdata('resellersummary_reports_export', "");
568
+		redirect(base_url() . "summary/reseller/");
569
+	}
570 570
 
571
-    function reseller_export_csv() {
571
+	function reseller_export_csv() {
572 572
 		 $account_info = $accountinfo = $this->session->userdata('accountinfo');
573 573
 		$currency_id=$account_info['currency_id'];
574 574
 		$currency=$this->common->get_field_name('currency', 'currency', $currency_id);
575 575
 		
576
-        $search_arr = $this->session->userdata('resellersummary_reports_export');
577
-        $data_arr = array();
578
-        $query = $this->summary_model->get_resellersummary_report_list(true, '', '', $search_arr['group_by_str'], $search_arr['select_str'],$search_arr['order_str'],true);
579
-        $search_header = explode(",", $search_arr['export_str']);
580
-        ob_clean();
581
-        $fixed_header = array("Attempted Calls", "Completed Calls", "Duration", "ASR", "ACD", "MCD", "Billable", "Debit($currency)", "Cost($currency)", "Profit");
582
-        $header_arr[] = array_merge($search_header, $fixed_header);
583
-        if ($query->num_rows() > 0) {
584
-            $data_arr = $this->summary_report_grid($search_arr, $query, 'reseller', 'export');
585
-        }
586
-        $reseller_array = array_merge($header_arr, $data_arr);
587
-        $this->load->helper('csv');
588
-        array_to_csv($reseller_array, 'Reseller_Summary_Report_' . date("Y-m-d") . '.csv');
589
-    }
576
+		$search_arr = $this->session->userdata('resellersummary_reports_export');
577
+		$data_arr = array();
578
+		$query = $this->summary_model->get_resellersummary_report_list(true, '', '', $search_arr['group_by_str'], $search_arr['select_str'],$search_arr['order_str'],true);
579
+		$search_header = explode(",", $search_arr['export_str']);
580
+		ob_clean();
581
+		$fixed_header = array("Attempted Calls", "Completed Calls", "Duration", "ASR", "ACD", "MCD", "Billable", "Debit($currency)", "Cost($currency)", "Profit");
582
+		$header_arr[] = array_merge($search_header, $fixed_header);
583
+		if ($query->num_rows() > 0) {
584
+			$data_arr = $this->summary_report_grid($search_arr, $query, 'reseller', 'export');
585
+		}
586
+		$reseller_array = array_merge($header_arr, $data_arr);
587
+		$this->load->helper('csv');
588
+		array_to_csv($reseller_array, 'Reseller_Summary_Report_' . date("Y-m-d") . '.csv');
589
+	}
590 590
 
591 591
 }
592 592
 ?>
Please login to merge, or discard this patch.
Spacing   +126 added lines, -126 removed lines patch added patch discarded remove patch
@@ -39,7 +39,7 @@  discard block
 block discarded – undo
39 39
         $this->fpdf->initialize('P', 'mm', 'A4');
40 40
 
41 41
         if ($this->session->userdata('user_login') == FALSE)
42
-            redirect(base_url() . '/astpp/login');
42
+            redirect(base_url().'/astpp/login');
43 43
     }
44 44
     function customer() {
45 45
         $data['page_title'] = 'Customer Summary Report';
@@ -62,10 +62,10 @@  discard block
 block discarded – undo
62 62
 
63 63
     function customer_json() {
64 64
         $search_arr = $this->summary_search_info('customer');
65
-        $count_all = $this->summary_model->get_customersummary_report_list(false, 0, 0, $search_arr['group_by_str'], $search_arr['select_str'],$search_arr['order_str'],false);
65
+        $count_all = $this->summary_model->get_customersummary_report_list(false, 0, 0, $search_arr['group_by_str'], $search_arr['select_str'], $search_arr['order_str'], false);
66 66
         $paging_data = $this->form->load_grid_config($count_all, $_GET['rp'], $_GET['page']);
67 67
         $json_data = $paging_data["json_paging"];
68
-        $query = $this->summary_model->get_customersummary_report_list(true, $paging_data["paging"]["start"], $paging_data["paging"]["page_no"], $search_arr['group_by_str'], $search_arr['select_str'],$search_arr['order_str'], false);
68
+        $query = $this->summary_model->get_customersummary_report_list(true, $paging_data["paging"]["start"], $paging_data["paging"]["page_no"], $search_arr['group_by_str'], $search_arr['select_str'], $search_arr['order_str'], false);
69 69
         if ($query->num_rows() > 0) {
70 70
             $json_data['rows'] = $this->summary_report_grid($search_arr, $query, 'customer', 'grid');
71 71
         }
@@ -78,42 +78,42 @@  discard block
 block discarded – undo
78 78
         $total_width = '322';
79 79
         $column_name = 'accountid';
80 80
         if ($this->session->userdata('advance_search') == '1') {
81
-            $search_array = $this->session->userdata($entity . 'summary_reports_search');
82
-            if(isset($search_array['time']) && !empty($search_array['time'])){
83
-                   $new_column_arr[]=array(ucfirst(strtolower($search_array['time'])), "58", $search_array['time']."(callstart)", "", "", "");
81
+            $search_array = $this->session->userdata($entity.'summary_reports_search');
82
+            if (isset($search_array['time']) && ! empty($search_array['time'])) {
83
+                   $new_column_arr[] = array(ucfirst(strtolower($search_array['time'])), "58", $search_array['time']."(callstart)", "", "", "");
84 84
             }
85
-            if (isset($search_array['groupby_1']) && !empty($search_array['groupby_1'])) {
85
+            if (isset($search_array['groupby_1']) && ! empty($search_array['groupby_1'])) {
86 86
                 $first_column_groupby = $search_array['groupby_1'];
87 87
 
88 88
                 if ($first_column_groupby == 'accountid') {
89
-                    $new_column_arr[] = array("Account", "105",'accountid', "first_name,last_name,number", "accounts", "build_concat_string");
89
+                    $new_column_arr[] = array("Account", "105", 'accountid', "first_name,last_name,number", "accounts", "build_concat_string");
90 90
                 } elseif ($first_column_groupby == 'pattern') {
91 91
                     $new_column_arr[] = array("Code", "45", "pattern", "pattern", "", "get_only_numeric_val");
92 92
                     $new_column_arr[] = array("Destination", "59", "notes", "", "", "");
93
-                } elseif($first_column_groupby =='package_id'){
94
-		    $new_column_arr[] = array("Package", "105",'package_id', "package_name", "packages", "get_field_name");
93
+                } elseif ($first_column_groupby == 'package_id') {
94
+		    $new_column_arr[] = array("Package", "105", 'package_id', "package_name", "packages", "get_field_name");
95 95
                 }
96 96
             }
97
-            if (isset($search_array['groupby_2']) && !empty($search_array['groupby_2'])) {
97
+            if (isset($search_array['groupby_2']) && ! empty($search_array['groupby_2'])) {
98 98
                 $third_column_groupby = $search_array['groupby_2'];
99 99
                 if ($third_column_groupby == 'accountid') {
100 100
                     $new_column_arr[] = array("Account", "105", 'accountid', "first_name,last_name,number", "accounts", "build_concat_string");
101 101
                 } elseif ($third_column_groupby == 'pattern') {
102 102
                     $new_column_arr[] = array("Code", "45", "pattern", "pattern", "", "get_only_numeric_val");
103 103
                     $new_column_arr[] = array("Destination", "59", "notes", "", "", "");
104
-                } elseif($third_column_groupby	 =='package_id'){
105
-		    $new_column_arr[] = array("Package", "105",'package_id', "package_name", "packages", "get_field_name");
104
+                } elseif ($third_column_groupby == 'package_id') {
105
+		    $new_column_arr[] = array("Package", "105", 'package_id', "package_name", "packages", "get_field_name");
106 106
                 }
107 107
             }
108
-            if (isset($search_array['groupby_3']) && !empty($search_array['groupby_3'])) {
108
+            if (isset($search_array['groupby_3']) && ! empty($search_array['groupby_3'])) {
109 109
                 $fifth_column_groupby = $search_array['groupby_3'];
110 110
                 if ($fifth_column_groupby == 'accountid') {
111 111
                     $new_column_arr[] = array("Account", "105", 'accountid', "first_name,last_name,number", "accounts", "build_concat_string");
112 112
                 } elseif ($fifth_column_groupby == 'pattern') {
113 113
                     $new_column_arr[] = array("Code", "45", "pattern", "pattern", "", "get_only_numeric_val");
114 114
                     $new_column_arr[] = array("Destination", "59", "notes", "", "", "");
115
-                } elseif($fifth_column_groupby	 =='package_id'){
116
-		    $new_column_arr[] = array("Package", "105",'package_id', "package_name", "packages", "get_field_name");
115
+                } elseif ($fifth_column_groupby == 'package_id') {
116
+		    $new_column_arr[] = array("Package", "105", 'package_id', "package_name", "packages", "get_field_name");
117 117
                 }
118 118
             }
119 119
             if (empty($new_column_arr)) {
@@ -129,40 +129,40 @@  discard block
 block discarded – undo
129 129
     function summary_report_grid($search_arr, $query, $entity, $purpose) {
130 130
         $export_arr = array();
131 131
         $db_field_name = $entity == 'provider' ? 'provider_id' : 'accountid';
132
-        $show_seconds = (!empty($search_arr['search_in'])) ? $search_arr['search_in'] : 'minutes';
133
-        $currency_info =$this->common->get_currency_info();
132
+        $show_seconds = ( ! empty($search_arr['search_in'])) ? $search_arr['search_in'] : 'minutes';
133
+        $currency_info = $this->common->get_currency_info();
134 134
         foreach ($query->result_array() as $row1) {
135 135
             $atmpt = $row1['attempts'];
136 136
             $cmplt = ($row1['completed'] != 0) ? $row1['completed'] : 0;
137
-            $acd = ($row1['completed'] > 0 ) ? round($row1['billable'] / $row1['completed']) : 0;
137
+            $acd = ($row1['completed'] > 0) ? round($row1['billable'] / $row1['completed']) : 0;
138 138
             $mcd = $row1['mcd'];
139 139
             if ($show_seconds == 'minutes') {
140
-                $avgsec = $acd > 0 ? sprintf('%02d',$acd / 60) . ":" . sprintf('%02d',($acd % 60)) : "00:00";
141
-                $maxsec = $mcd > 0 ? sprintf('%02d',$mcd / 60) . ":" . sprintf('%02d',($mcd % 60))  : "00:00";
142
-                $duration = ($row1['duration'] > 0 ) ? sprintf('%02d',$row1['duration'] / 60) . ":" . sprintf('%02d',($row1['duration'] % 60)) : "00:00";
143
-                $billsec = ($row1['billable'] > 0 ) ? sprintf('%02d',$row1['billable'] / 60) . ":" . sprintf('%02d',($row1['billable'] % 60)) : "00:00";
140
+                $avgsec = $acd > 0 ? sprintf('%02d', $acd / 60).":".sprintf('%02d', ($acd % 60)) : "00:00";
141
+                $maxsec = $mcd > 0 ? sprintf('%02d', $mcd / 60).":".sprintf('%02d', ($mcd % 60)) : "00:00";
142
+                $duration = ($row1['duration'] > 0) ? sprintf('%02d', $row1['duration'] / 60).":".sprintf('%02d', ($row1['duration'] % 60)) : "00:00";
143
+                $billsec = ($row1['billable'] > 0) ? sprintf('%02d', $row1['billable'] / 60).":".sprintf('%02d', ($row1['billable'] % 60)) : "00:00";
144 144
             } else {
145
-                $duration = sprintf('%02d',$row1['duration']);
145
+                $duration = sprintf('%02d', $row1['duration']);
146 146
                 $avgsec = $acd;
147 147
                 $maxsec = $mcd;
148
-                $billsec = sprintf('%02d',$row1['billable']);
148
+                $billsec = sprintf('%02d', $row1['billable']);
149 149
             }
150 150
             if ($entity != 'provider') {
151
-                $profit = $this->common->calculate_currency_manually($currency_info,$row1['debit'] - $row1['cost'],false);
152
-                $debit  = $this->common->calculate_currency_manually($currency_info,$row1['debit'],false);
151
+                $profit = $this->common->calculate_currency_manually($currency_info, $row1['debit'] - $row1['cost'], false);
152
+                $debit  = $this->common->calculate_currency_manually($currency_info, $row1['debit'], false);
153 153
             }
154
-            $cost  = $this->common->calculate_currency_manually($currency_info,$row1['cost'],false);
155
-            $asr = ($atmpt > 0 ) ? (round(($cmplt / $atmpt) * 100,2)) : '0.00' ;
154
+            $cost = $this->common->calculate_currency_manually($currency_info, $row1['cost'], false);
155
+            $asr = ($atmpt > 0) ? (round(($cmplt / $atmpt) * 100, 2)) : '0.00';
156 156
             $new_arr = array();
157 157
             if ($this->session->userdata('advance_search') == 1) {
158
-                if (!empty($search_arr['groupby_time'])) {
159
-                       $time =$row1[$search_arr['groupby_time']];
160
-                       if($search_arr['groupby_time']== "HOUR"|| $search_arr['groupby_time']== "DAY"){
161
-			  $time=sprintf('%02d',$time);
158
+                if ( ! empty($search_arr['groupby_time'])) {
159
+                       $time = $row1[$search_arr['groupby_time']];
160
+                       if ($search_arr['groupby_time'] == "HOUR" || $search_arr['groupby_time'] == "DAY") {
161
+			  $time = sprintf('%02d', $time);
162 162
                        }
163
-                       if($search_arr['groupby_time']== "MONTH"){
164
-			  $dateObj   = DateTime::createFromFormat('!m',$time);
165
-			  $time= $dateObj->format('F');
163
+                       if ($search_arr['groupby_time'] == "MONTH") {
164
+			  $dateObj = DateTime::createFromFormat('!m', $time);
165
+			  $time = $dateObj->format('F');
166 166
                        }
167 167
                     $new_arr[] = $time;
168 168
                 }
@@ -173,7 +173,7 @@  discard block
 block discarded – undo
173 173
                     $new_arr[] = $row1['notes'];
174 174
                 } elseif ($search_arr['groupby_1'] == 'trunk_id') {
175 175
                     $new_arr[] = $this->common->get_field_name('name', 'trunks', $row1['trunk_id']);
176
-                } elseif($search_arr['groupby_1'] == 'package_id'){
176
+                } elseif ($search_arr['groupby_1'] == 'package_id') {
177 177
 		    $new_arr[] = $this->common->get_field_name('package_name', 'packages', $row1['package_id']);
178 178
                 }
179 179
                 
@@ -184,7 +184,7 @@  discard block
 block discarded – undo
184 184
                     $new_arr[] = $row1['notes'];
185 185
                 } elseif ($search_arr['groupby_2'] == 'trunk_id') {
186 186
                     $new_arr[] = $this->common->get_field_name('name', 'trunks', $row1['trunk_id']);
187
-                } elseif($search_arr['groupby_2'] == 'package_id'){
187
+                } elseif ($search_arr['groupby_2'] == 'package_id') {
188 188
 		    $new_arr[] = $this->common->get_field_name('package_name', 'packages', $row1['package_id']);
189 189
                 }
190 190
                 
@@ -195,7 +195,7 @@  discard block
 block discarded – undo
195 195
                     $new_arr[] = $row1['notes'];
196 196
                 } elseif ($search_arr['groupby_3'] == 'trunk_id') {
197 197
                     $new_arr[] = $this->common->get_field_name('name', 'trunks', $row1['trunk_id']);
198
-                }  elseif($search_arr['groupby_3'] == 'package_id'){
198
+                }  elseif ($search_arr['groupby_3'] == 'package_id') {
199 199
 		    $new_arr[] = $this->common->get_field_name('package_name', 'packages', $row1['package_id']);
200 200
                 }
201 201
                 if (empty($new_arr)) {
@@ -232,23 +232,23 @@  discard block
 block discarded – undo
232 232
             $json_data[] = array('cell' => $final_array);
233 233
             $export_arr[] = $final_array;
234 234
         }
235
-        $function_name = 'get_' . $entity . 'summary_report_list';
236
-        $total_info = $this->summary_model->$function_name(true, '', '', '', $search_arr['select_str'],  $search_arr['order_str'],true);
235
+        $function_name = 'get_'.$entity.'summary_report_list';
236
+        $total_info = $this->summary_model->$function_name(true, '', '', '', $search_arr['select_str'], $search_arr['order_str'], true);
237 237
         $total_info = $total_info->result_array();
238 238
         $total_info = $total_info[0];
239
-        $total_asr = ($total_info['attempts'] > 0 ) ? round(($total_info['completed'] / $total_info['attempts']) * 100, 2) : 0;
240
-        $total_acd = ($total_info['completed']> 0 ) ?round($total_info['billable'] / $total_info['completed']) : 0 ;
239
+        $total_asr = ($total_info['attempts'] > 0) ? round(($total_info['completed'] / $total_info['attempts']) * 100, 2) : 0;
240
+        $total_acd = ($total_info['completed'] > 0) ? round($total_info['billable'] / $total_info['completed']) : 0;
241 241
         if ($show_seconds == 'minutes') {
242
-            $total_info['duration'] = $total_info['duration'] > 0 ? sprintf('%02d',$total_info['duration'] / 60) . ":" . sprintf('%02d',($total_info['duration'] % 60)) : "00:00";
243
-            $total_info['billable'] = $total_info['billable'] > 0 ? sprintf('%02d',$total_info['billable'] / 60) . ":" . sprintf('%02d',($total_info['billable'] % 60)) : "00:00";
244
-            $total_acd = $total_acd > 0 ? sprintf('%02d',$total_acd / 60) . ":" .  sprintf('%02d',($total_acd % 60)) : "00:00";
245
-            $total_info['mcd'] = $total_info['mcd'] > 0 ? sprintf('%02d',$total_info['mcd'] / 60) . ":" .  sprintf('%02d',($total_info['mcd'] % 60)) : "00:00";
242
+            $total_info['duration'] = $total_info['duration'] > 0 ? sprintf('%02d', $total_info['duration'] / 60).":".sprintf('%02d', ($total_info['duration'] % 60)) : "00:00";
243
+            $total_info['billable'] = $total_info['billable'] > 0 ? sprintf('%02d', $total_info['billable'] / 60).":".sprintf('%02d', ($total_info['billable'] % 60)) : "00:00";
244
+            $total_acd = $total_acd > 0 ? sprintf('%02d', $total_acd / 60).":".sprintf('%02d', ($total_acd % 60)) : "00:00";
245
+            $total_info['mcd'] = $total_info['mcd'] > 0 ? sprintf('%02d', $total_info['mcd'] / 60).":".sprintf('%02d', ($total_info['mcd'] % 60)) : "00:00";
246 246
         }
247 247
         if ($entity != 'provider') {
248
-            $total_profit =   $this->common->calculate_currency_manually($currency_info,$total_info['debit'] - $total_info['cost'],false);
249
-            $total_debit =   $this->common->calculate_currency_manually($currency_info,$total_info['debit'],false);
248
+            $total_profit = $this->common->calculate_currency_manually($currency_info, $total_info['debit'] - $total_info['cost'], false);
249
+            $total_debit = $this->common->calculate_currency_manually($currency_info, $total_info['debit'], false);
250 250
         }
251
-        $total_cost =   $this->common->calculate_currency_manually($currency_info,$total_info['cost'],false);
251
+        $total_cost = $this->common->calculate_currency_manually($currency_info, $total_info['cost'], false);
252 252
         if ($entity != 'provider') {
253 253
             $last_array = array(
254 254
                 "<b>".$total_info['attempts']."</b>",
@@ -277,17 +277,17 @@  discard block
 block discarded – undo
277 277
         if ($purpose == 'export') {
278 278
             $search_arr['custom_total_array'][0] = "Grand Total";
279 279
         }
280
-        $new_export_array=array();
281
-        foreach($last_array as $key=>$value){
282
-	  $value=str_replace("<b>","",$value);
283
-	  $value=str_replace("</b>",'',$value);
284
-	  if($key == 7 || $key ==8 || $key ==9){
285
-	      $value = sprintf("%.".$currency_info['decimalpoints']."f",floatval(preg_replace('/[^\d.]/', '', $value)));
280
+        $new_export_array = array();
281
+        foreach ($last_array as $key=>$value) {
282
+	  $value = str_replace("<b>", "", $value);
283
+	  $value = str_replace("</b>", '', $value);
284
+	  if ($key == 7 || $key == 8 || $key == 9) {
285
+	      $value = sprintf("%.".$currency_info['decimalpoints']."f", floatval(preg_replace('/[^\d.]/', '', $value)));
286 286
 	  }
287
-	  $new_export_array[$key]=$value;
287
+	  $new_export_array[$key] = $value;
288 288
         }
289 289
         $total_array = array_merge($search_arr['custom_total_array'], $last_array);
290
-        $custom_export_arr =array_merge($search_arr['custom_total_array'],$new_export_array);
290
+        $custom_export_arr = array_merge($search_arr['custom_total_array'], $new_export_array);
291 291
         $export_arr[] = $custom_export_arr;
292 292
         $json_data[] = array('cell' => $total_array);
293 293
         return $purpose == 'grid' ? $json_data : $export_arr;
@@ -295,14 +295,14 @@  discard block
 block discarded – undo
295 295
 
296 296
     function customer_export_csv() {
297 297
 		$account_info = $accountinfo = $this->session->userdata('accountinfo');
298
-		$currency_id=$account_info['currency_id'];
299
-		$currency=$this->common->get_field_name('currency', 'currency', $currency_id);
298
+		$currency_id = $account_info['currency_id'];
299
+		$currency = $this->common->get_field_name('currency', 'currency', $currency_id);
300 300
         $search_arr = $this->session->userdata('customersummary_reports_export');
301 301
         $data_arr = array();
302
-        $query = $this->summary_model->get_customersummary_report_list(true, '', '', $search_arr['group_by_str'], $search_arr['select_str'],$search_arr['order_str'], true);
302
+        $query = $this->summary_model->get_customersummary_report_list(true, '', '', $search_arr['group_by_str'], $search_arr['select_str'], $search_arr['order_str'], true);
303 303
         $search_header = explode(",", $search_arr['export_str']);
304 304
         ob_clean();
305
-        $fixed_header = array('Attempted Calls','Completed Calls','Duration', 'ASR', 'ACD','MCD','Billable', 'Debit('.$currency.')','Cost('.$currency.')','Profit');
305
+        $fixed_header = array('Attempted Calls', 'Completed Calls', 'Duration', 'ASR', 'ACD', 'MCD', 'Billable', 'Debit('.$currency.')', 'Cost('.$currency.')', 'Profit');
306 306
         $header_arr[] = array_merge($search_header, $fixed_header);
307 307
         if ($query->num_rows() > 0) {
308 308
             $data_arr = $this->summary_report_grid($search_arr, $query, 'customer', 'export');
@@ -310,7 +310,7 @@  discard block
 block discarded – undo
310 310
         $customer_array = array_merge($header_arr, $data_arr);
311 311
 
312 312
         $this->load->helper('csv');
313
-        array_to_csv($customer_array, 'Customer_Summary_Report_' . date("Y-m-d") . '.csv');
313
+        array_to_csv($customer_array, 'Customer_Summary_Report_'.date("Y-m-d").'.csv');
314 314
     }
315 315
 
316 316
     function customer_search() {
@@ -320,24 +320,24 @@  discard block
 block discarded – undo
320 320
             unset($_POST['advance_search']);
321 321
             $this->session->set_userdata('customersummary_reports_search', $this->input->post());
322 322
         }
323
-        redirect(base_url() . 'summary/customer/');
323
+        redirect(base_url().'summary/customer/');
324 324
     }
325 325
 
326 326
     function customer_clearsearchfilter() {
327 327
         $this->session->set_userdata('advance_search', 0);
328 328
         $this->session->set_userdata('customersummary_reports_search', "");
329 329
         $this->session->set_userdata('customersummary_reports_export', "");
330
-        redirect(base_url() . 'summary/customer/');
330
+        redirect(base_url().'summary/customer/');
331 331
     }
332 332
 
333 333
     function summary_search_info($entity) {
334 334
         $group_by_str = null;
335 335
         $select_str = null;
336
-        $group_by_time=null;
336
+        $group_by_time = null;
337 337
         $group_by_1 = null;
338 338
         $group_by_2 = null;
339 339
         $group_by_3 = null;
340
-        $order_str=null;
340
+        $order_str = null;
341 341
         $custom_total_array = array();
342 342
         $custom_search = array();
343 343
         $export_select_str = null;
@@ -345,86 +345,86 @@  discard block
 block discarded – undo
345 345
         $i = 0;
346 346
         $db_field_name = $entity == 'provider' ? 'provider_id' : 'accountid';
347 347
         if ($this->session->userdata('advance_search') == 1) {
348
-            $custom_search = $this->session->userdata($entity . 'summary_reports_search');
349
-            if (isset($custom_search['time']) && !empty($custom_search['time'])) {
350
-                $group_by_str.=$custom_search['time'] . "(callstart),";
351
-                $select_str.=$custom_search['time'] . "(callstart) as ".$custom_search['time'].",";
352
-                $order_str.=$custom_search['time'].",";
348
+            $custom_search = $this->session->userdata($entity.'summary_reports_search');
349
+            if (isset($custom_search['time']) && ! empty($custom_search['time'])) {
350
+                $group_by_str .= $custom_search['time']."(callstart),";
351
+                $select_str .= $custom_search['time']."(callstart) as ".$custom_search['time'].",";
352
+                $order_str .= $custom_search['time'].",";
353 353
                 $group_by_time = $custom_search['time'];
354
-                $export_select_str.=$custom_search['time'].",";
354
+                $export_select_str .= $custom_search['time'].",";
355 355
                 $custom_total_array[$i] = null;
356 356
                 $i++;
357 357
             }
358
-            if (isset($custom_search['groupby_1']) && !empty($custom_search['groupby_1'])) {
359
-                $group_by_str.=$custom_search['groupby_1'] . ",";
360
-                $select_str.=$custom_search['groupby_1'] . ",";
361
-                $order_str.=$custom_search['groupby_1'] . ",";
358
+            if (isset($custom_search['groupby_1']) && ! empty($custom_search['groupby_1'])) {
359
+                $group_by_str .= $custom_search['groupby_1'].",";
360
+                $select_str .= $custom_search['groupby_1'].",";
361
+                $order_str .= $custom_search['groupby_1'].",";
362 362
                 $group_by_1 = $custom_search['groupby_1'];
363 363
                 if ($custom_search['groupby_1'] == $db_field_name) {
364
-                    $export_select_str.='Account,';
364
+                    $export_select_str .= 'Account,';
365 365
                 } elseif ($custom_search['groupby_1'] == 'trunk_id') {
366
-                    $export_select_str.='Trunk,';
366
+                    $export_select_str .= 'Trunk,';
367 367
                 } elseif ($custom_search['groupby_1'] == 'pattern') {
368
-                    $select_str.='notes,';
369
-                    $order_str.='notes,';
370
-                    $export_select_str.="Code,Destination,";
368
+                    $select_str .= 'notes,';
369
+                    $order_str .= 'notes,';
370
+                    $export_select_str .= "Code,Destination,";
371 371
                     $custom_total_array[$i] = null;
372 372
                     $i++;
373
-                } elseif($custom_search['groupby_1'] =='package_id'){
374
-		    $export_select_str.='Package,';
373
+                } elseif ($custom_search['groupby_1'] == 'package_id') {
374
+		    $export_select_str .= 'Package,';
375 375
                 }
376 376
                 $custom_total_array[$i] = null;
377 377
                 $i++;
378 378
             }
379 379
             
380
-            if (isset($custom_search['groupby_2']) && !empty($custom_search['groupby_2'])) {
381
-                $group_by_str.=$custom_search['groupby_2'] . ",";
382
-                $select_str.=$custom_search['groupby_2'] . ",";
383
-                $order_str.=$custom_search['groupby_2'] . ",";
380
+            if (isset($custom_search['groupby_2']) && ! empty($custom_search['groupby_2'])) {
381
+                $group_by_str .= $custom_search['groupby_2'].",";
382
+                $select_str .= $custom_search['groupby_2'].",";
383
+                $order_str .= $custom_search['groupby_2'].",";
384 384
                 $group_by_2 = $custom_search['groupby_2'];
385 385
                 if ($custom_search['groupby_2'] == $db_field_name) {
386
-                    $export_select_str.='Account,';
386
+                    $export_select_str .= 'Account,';
387 387
                 } elseif ($custom_search['groupby_2'] == 'trunk_id') {
388
-                    $export_select_str.='Trunk,';
388
+                    $export_select_str .= 'Trunk,';
389 389
                 } elseif ($custom_search['groupby_2'] == 'pattern') {
390
-                    $select_str.='notes,';
391
-                    $order_str.='notes,';
392
-                    $export_select_str.="Code,Destination,";
390
+                    $select_str .= 'notes,';
391
+                    $order_str .= 'notes,';
392
+                    $export_select_str .= "Code,Destination,";
393 393
                     $custom_total_array[$i] = null;
394 394
                     $i++;
395
-                } elseif($custom_search['groupby_2'] =='package_id'){
396
-		    $export_select_str.='Package,';
395
+                } elseif ($custom_search['groupby_2'] == 'package_id') {
396
+		    $export_select_str .= 'Package,';
397 397
                 }
398 398
                 $custom_total_array[$i] = null;
399 399
                 $i++;
400 400
             }
401 401
 
402
-            if (isset($custom_search['groupby_3']) && !empty($custom_search['groupby_3'])) {
403
-                $group_by_str.=$custom_search['groupby_3'] . ",";
404
-                $select_str.=$custom_search['groupby_3'] . ",";
405
-                $order_str.=$custom_search['groupby_3'] . ",";
402
+            if (isset($custom_search['groupby_3']) && ! empty($custom_search['groupby_3'])) {
403
+                $group_by_str .= $custom_search['groupby_3'].",";
404
+                $select_str .= $custom_search['groupby_3'].",";
405
+                $order_str .= $custom_search['groupby_3'].",";
406 406
                 $group_by_3 = $custom_search['groupby_3'];
407 407
                 if ($custom_search['groupby_3'] == 'accountid' || $custom_search['groupby_3'] == 'provider_id') {
408
-                    $export_select_str.='Account,';
408
+                    $export_select_str .= 'Account,';
409 409
                 } elseif ($custom_search['groupby_3'] == 'trunk_id') {
410
-                    $export_select_str.='Trunk,';
410
+                    $export_select_str .= 'Trunk,';
411 411
                 } elseif ($custom_search['groupby_3'] == 'pattern') {
412
-                    $select_str.='notes,';
413
-                    $order_str.='notes,';
414
-                    $export_select_str.="Code,Destination,";
412
+                    $select_str .= 'notes,';
413
+                    $order_str .= 'notes,';
414
+                    $export_select_str .= "Code,Destination,";
415 415
                     $custom_total_array[$i] = null;
416 416
                     $i++;
417
-                } elseif($custom_search['groupby_3'] =='package_id'){
418
-		    $export_select_str.='Package,';
417
+                } elseif ($custom_search['groupby_3'] == 'package_id') {
418
+		    $export_select_str .= 'Package,';
419 419
                 }
420 420
                 $custom_total_array[$i] = null;
421 421
                 $i++;
422 422
             }
423
-            $new_arr['search_in'] = (isset($custom_search['search_in']) && !empty($custom_search['search_in'])) ? $custom_search['search_in'] : 'minutes';
423
+            $new_arr['search_in'] = (isset($custom_search['search_in']) && ! empty($custom_search['search_in'])) ? $custom_search['search_in'] : 'minutes';
424 424
             unset($custom_search['groupby_1'], $custom_search['groupby_2'], $custom_search['groupby_3'], $custom_search['search_in']);
425
-            $this->session->set_userdata('summary_' . $entity . '_search', $custom_search);
425
+            $this->session->set_userdata('summary_'.$entity.'_search', $custom_search);
426 426
         }
427
-        if (!empty($group_by_str)) {
427
+        if ( ! empty($group_by_str)) {
428 428
             $group_by_str = rtrim($group_by_str, ",");
429 429
             $select_str = rtrim($select_str, ",");
430 430
             $order_str = rtrim($order_str, ",");
@@ -445,7 +445,7 @@  discard block
 block discarded – undo
445 445
         $new_arr['groupby_1'] = $group_by_1;
446 446
         $new_arr['groupby_2'] = $group_by_2;
447 447
         $new_arr['groupby_3'] = $group_by_3;
448
-        $new_arr['groupby_time']=$group_by_time;
448
+        $new_arr['groupby_time'] = $group_by_time;
449 449
         $new_arr['custom_total_array'] = $custom_total_array;
450 450
         return $new_arr;
451 451
     }
@@ -471,10 +471,10 @@  discard block
 block discarded – undo
471 471
 
472 472
     function provider_json() {
473 473
         $search_arr = $this->summary_search_info('provider');
474
-        $count_all = $this->summary_model->get_providersummary_report_list(false,'','', $search_arr['group_by_str'], $search_arr['select_str'], $search_arr['order_str'],false);
474
+        $count_all = $this->summary_model->get_providersummary_report_list(false, '', '', $search_arr['group_by_str'], $search_arr['select_str'], $search_arr['order_str'], false);
475 475
         $paging_data = $this->form->load_grid_config($count_all, $_GET['rp'], $_GET['page']);
476 476
         $json_data = $paging_data["json_paging"];
477
-        $query = $this->summary_model->get_providersummary_report_list(true, $paging_data["paging"]["start"], $paging_data["paging"]["page_no"], $search_arr['group_by_str'], $search_arr['select_str'],$search_arr['order_str'], false);
477
+        $query = $this->summary_model->get_providersummary_report_list(true, $paging_data["paging"]["start"], $paging_data["paging"]["page_no"], $search_arr['group_by_str'], $search_arr['select_str'], $search_arr['order_str'], false);
478 478
         if ($query->num_rows() > 0) {
479 479
             $json_data['rows'] = $this->summary_report_grid($search_arr, $query, 'provider', 'grid');
480 480
         }
@@ -484,11 +484,11 @@  discard block
 block discarded – undo
484 484
 
485 485
     function provider_export_csv() {
486 486
 		$account_info = $accountinfo = $this->session->userdata('accountinfo');
487
-		$currency_id=$account_info['currency_id'];
488
-		$currency=$this->common->get_field_name('currency', 'currency', $currency_id);
487
+		$currency_id = $account_info['currency_id'];
488
+		$currency = $this->common->get_field_name('currency', 'currency', $currency_id);
489 489
         $search_arr = $this->session->userdata('providersummary_reports_export');
490 490
         $data_arr = array();
491
-        $query = $this->summary_model->get_providersummary_report_list(true, '', '', $search_arr['group_by_str'], $search_arr['select_str'],$search_arr['order_str'], true);
491
+        $query = $this->summary_model->get_providersummary_report_list(true, '', '', $search_arr['group_by_str'], $search_arr['select_str'], $search_arr['order_str'], true);
492 492
         $search_header = explode(",", $search_arr['export_str']);
493 493
         ob_clean();
494 494
         $fixed_header = array("Attempted Calls", "Completed Calls", "Duration", "ASR", "ACD", "MCD", "Billable", "Cost($currency)");
@@ -499,7 +499,7 @@  discard block
 block discarded – undo
499 499
         $provider_array = array_merge($header_arr, $data_arr);
500 500
 
501 501
         $this->load->helper('csv');
502
-        array_to_csv($provider_array, 'Provider_Summary_Report_' . date("Y-m-d") . '.csv');
502
+        array_to_csv($provider_array, 'Provider_Summary_Report_'.date("Y-m-d").'.csv');
503 503
     }
504 504
 
505 505
     function provider_search() {
@@ -508,14 +508,14 @@  discard block
 block discarded – undo
508 508
             unset($_POST['action'], $_POST['advance_search']);
509 509
             $this->session->set_userdata('providersummary_reports_search', $this->input->post());
510 510
         }
511
-        redirect(base_url() . 'summary/provider/');
511
+        redirect(base_url().'summary/provider/');
512 512
     }
513 513
 
514 514
     function provider_clearsearchfilter() {
515 515
         $this->session->set_userdata('advance_search', 0);
516 516
         $this->session->set_userdata('providersummary_reports_search', "");
517 517
         $this->session->set_userdata('providersummary_reports_export', "");
518
-        redirect(base_url() . "summary/provider/");
518
+        redirect(base_url()."summary/provider/");
519 519
     }
520 520
 
521 521
     function reseller() {
@@ -541,10 +541,10 @@  discard block
 block discarded – undo
541 541
 
542 542
     function reseller_json() {
543 543
         $search_arr = $this->summary_search_info('reseller');
544
-        $count_all = $this->summary_model->get_resellersummary_report_list(false, 0, 0, $search_arr['group_by_str'], $search_arr['select_str'],$search_arr['order_str'],false);
544
+        $count_all = $this->summary_model->get_resellersummary_report_list(false, 0, 0, $search_arr['group_by_str'], $search_arr['select_str'], $search_arr['order_str'], false);
545 545
         $paging_data = $this->form->load_grid_config($count_all, $_GET['rp'], $_GET['page']);
546 546
         $json_data = $paging_data["json_paging"];
547
-        $query = $this->summary_model->get_resellersummary_report_list(true, $paging_data["paging"]["start"], $paging_data["paging"]["page_no"], $search_arr['group_by_str'], $search_arr['select_str'],$search_arr['order_str'], false);
547
+        $query = $this->summary_model->get_resellersummary_report_list(true, $paging_data["paging"]["start"], $paging_data["paging"]["page_no"], $search_arr['group_by_str'], $search_arr['select_str'], $search_arr['order_str'], false);
548 548
         if ($query->num_rows() > 0) {
549 549
             $json_data['rows'] = $this->summary_report_grid($search_arr, $query, 'reseller', 'grid');
550 550
         }
@@ -558,24 +558,24 @@  discard block
 block discarded – undo
558 558
             unset($_POST['action'], $_POST['advance_search']);
559 559
             $this->session->set_userdata('resellersummary_reports_search', $this->input->post());
560 560
         }
561
-        redirect(base_url() . "summary/reseller/");
561
+        redirect(base_url()."summary/reseller/");
562 562
     }
563 563
 
564 564
     function reseller_clearsearchfilter() {
565 565
         $this->session->set_userdata('advance_search', 0);
566 566
         $this->session->set_userdata('resellersummary_reports_search', "");
567 567
         $this->session->set_userdata('resellersummary_reports_export', "");
568
-        redirect(base_url() . "summary/reseller/");
568
+        redirect(base_url()."summary/reseller/");
569 569
     }
570 570
 
571 571
     function reseller_export_csv() {
572 572
 		 $account_info = $accountinfo = $this->session->userdata('accountinfo');
573
-		$currency_id=$account_info['currency_id'];
574
-		$currency=$this->common->get_field_name('currency', 'currency', $currency_id);
573
+		$currency_id = $account_info['currency_id'];
574
+		$currency = $this->common->get_field_name('currency', 'currency', $currency_id);
575 575
 		
576 576
         $search_arr = $this->session->userdata('resellersummary_reports_export');
577 577
         $data_arr = array();
578
-        $query = $this->summary_model->get_resellersummary_report_list(true, '', '', $search_arr['group_by_str'], $search_arr['select_str'],$search_arr['order_str'],true);
578
+        $query = $this->summary_model->get_resellersummary_report_list(true, '', '', $search_arr['group_by_str'], $search_arr['select_str'], $search_arr['order_str'], true);
579 579
         $search_header = explode(",", $search_arr['export_str']);
580 580
         ob_clean();
581 581
         $fixed_header = array("Attempted Calls", "Completed Calls", "Duration", "ASR", "ACD", "MCD", "Billable", "Debit($currency)", "Cost($currency)", "Profit");
@@ -585,7 +585,7 @@  discard block
 block discarded – undo
585 585
         }
586 586
         $reseller_array = array_merge($header_arr, $data_arr);
587 587
         $this->load->helper('csv');
588
-        array_to_csv($reseller_array, 'Reseller_Summary_Report_' . date("Y-m-d") . '.csv');
588
+        array_to_csv($reseller_array, 'Reseller_Summary_Report_'.date("Y-m-d").'.csv');
589 589
     }
590 590
 
591 591
 }
Please login to merge, or discard this patch.
Braces   +4 added lines, -3 removed lines patch added patch discarded remove patch
@@ -38,8 +38,9 @@  discard block
 block discarded – undo
38 38
         $this->fpdf = new PDF('P', 'pt');
39 39
         $this->fpdf->initialize('P', 'mm', 'A4');
40 40
 
41
-        if ($this->session->userdata('user_login') == FALSE)
42
-            redirect(base_url() . '/astpp/login');
41
+        if ($this->session->userdata('user_login') == FALSE) {
42
+                    redirect(base_url() . '/astpp/login');
43
+        }
43 44
     }
44 45
     function customer() {
45 46
         $data['page_title'] = 'Customer Summary Report';
@@ -195,7 +196,7 @@  discard block
 block discarded – undo
195 196
                     $new_arr[] = $row1['notes'];
196 197
                 } elseif ($search_arr['groupby_3'] == 'trunk_id') {
197 198
                     $new_arr[] = $this->common->get_field_name('name', 'trunks', $row1['trunk_id']);
198
-                }  elseif($search_arr['groupby_3'] == 'package_id'){
199
+                } elseif($search_arr['groupby_3'] == 'package_id'){
199 200
 		    $new_arr[] = $this->common->get_field_name('package_name', 'packages', $row1['package_id']);
200 201
                 }
201 202
                 if (empty($new_arr)) {
Please login to merge, or discard this patch.
web_interface/astpp/system/core/Benchmark.php 2 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -67,7 +67,7 @@
 block discarded – undo
67 67
 	 * @param	string	a particular marked point
68 68
 	 * @param	string	a particular marked point
69 69
 	 * @param	integer	the number of decimal places
70
-	 * @return	mixed
70
+	 * @return	string
71 71
 	 */
72 72
 	function elapsed_time($point1 = '', $point2 = '', $decimals = 4)
73 73
 	{
Please login to merge, or discard this patch.
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1,4 +1,6 @@
 block discarded – undo
1
-<?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');
1
+<?php  if ( ! defined('BASEPATH')) {
2
+	exit('No direct script access allowed');
3
+}
2 4
 /*
3 5
 | -------------------------------------------------------------------
4 6
 | AUTO-LOADER
Please login to merge, or discard this patch.
web_interface/astpp/system/core/Common.php 4 patches
Doc Comments   +3 added lines patch added patch discarded remove patch
@@ -467,6 +467,9 @@
 block discarded – undo
467 467
 */
468 468
 if ( ! function_exists('_exception_handler'))
469 469
 {
470
+	/**
471
+	 * @param integer $severity
472
+	 */
470 473
 	function _exception_handler($severity, $message, $filepath, $line)
471 474
 	{
472 475
 		 // We don't bother with "strict" notices since they tend to fill up
Please login to merge, or discard this patch.
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -254,7 +254,7 @@
 block discarded – undo
254 254
 			}
255 255
 		}
256 256
 		$_config[0] =& $config;
257
-                return $_config[0];
257
+				return $_config[0];
258 258
 
259 259
 	}
260 260
 }
Please login to merge, or discard this patch.
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -81,7 +81,7 @@  discard block
 block discarded – undo
81 81
 		// write a file then read it.  Bah...
82 82
 		if (is_dir($file))
83 83
 		{
84
-			$file = rtrim($file, '/').'/'.md5(mt_rand(1,100).mt_rand(1,100));
84
+			$file = rtrim($file, '/').'/'.md5(mt_rand(1, 100).mt_rand(1, 100));
85 85
 
86 86
 			if (($fp = @fopen($file, FOPEN_WRITE_CREATE)) === FALSE)
87 87
 			{
@@ -253,7 +253,7 @@  discard block
 block discarded – undo
253 253
 				}
254 254
 			}
255 255
 		}
256
-		$_config[0] =& $config;
256
+		$_config[0] = & $config;
257 257
                 return $_config[0];
258 258
 
259 259
 	}
@@ -275,7 +275,7 @@  discard block
 block discarded – undo
275 275
 
276 276
 		if ( ! isset($_config_item[$item]))
277 277
 		{
278
-			$config =& get_config();
278
+			$config = & get_config();
279 279
 
280 280
 			if ( ! isset($config[$item]))
281 281
 			{
@@ -306,7 +306,7 @@  discard block
 block discarded – undo
306 306
 {
307 307
 	function show_error($message, $status_code = 500, $heading = 'An Error Was Encountered')
308 308
 	{
309
-		$_error =& load_class('Exceptions', 'core');
309
+		$_error = & load_class('Exceptions', 'core');
310 310
 		echo $_error->show_error($heading, $message, 'error_general', $status_code);
311 311
 		exit;
312 312
 	}
@@ -328,7 +328,7 @@  discard block
 block discarded – undo
328 328
 {
329 329
 	function show_404($page = '', $log_error = TRUE)
330 330
 	{
331
-		$_error =& load_class('Exceptions', 'core');
331
+		$_error = & load_class('Exceptions', 'core');
332 332
 		$_error->show_404($page, $log_error);
333 333
 		exit;
334 334
 	}
@@ -356,7 +356,7 @@  discard block
 block discarded – undo
356 356
 			return;
357 357
 		}
358 358
 
359
-		$_log =& load_class('Log');
359
+		$_log = & load_class('Log');
360 360
 		$_log->write_log($level, $message, $php_error);
361 361
 	}
362 362
 }
@@ -479,7 +479,7 @@  discard block
 block discarded – undo
479 479
 			return;
480 480
 		}
481 481
 
482
-		$_error =& load_class('Exceptions', 'core');
482
+		$_error = & load_class('Exceptions', 'core');
483 483
 
484 484
 		// Should we display the error? We'll get the current error_reporting
485 485
 		// level and add its bits with the severity bits to find out.
@@ -521,11 +521,11 @@  discard block
 block discarded – undo
521 521
 		
522 522
 		if ($url_encoded)
523 523
 		{
524
-			$non_displayables[] = '/%0[0-8bcef]/';	// url encoded 00-08, 11, 12, 14, 15
525
-			$non_displayables[] = '/%1[0-9a-f]/';	// url encoded 16-31
524
+			$non_displayables[] = '/%0[0-8bcef]/'; // url encoded 00-08, 11, 12, 14, 15
525
+			$non_displayables[] = '/%1[0-9a-f]/'; // url encoded 16-31
526 526
 		}
527 527
 		
528
-		$non_displayables[] = '/[\x00-\x08\x0B\x0C\x0E-\x1F\x7F]+/S';	// 00-08, 11, 12, 14-31, 127
528
+		$non_displayables[] = '/[\x00-\x08\x0B\x0C\x0E-\x1F\x7F]+/S'; // 00-08, 11, 12, 14-31, 127
529 529
 
530 530
 		do
531 531
 		{
Please login to merge, or discard this patch.
Braces   +7 added lines, -9 removed lines patch added patch discarded remove patch
@@ -1,4 +1,6 @@  discard block
 block discarded – undo
1
-<?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');
1
+<?php  if ( ! defined('BASEPATH')) {
2
+	exit('No direct script access allowed');
3
+}
2 4
 /**
3 5
  * CodeIgniter
4 6
  *
@@ -92,8 +94,7 @@  discard block
 block discarded – undo
92 94
 			@chmod($file, DIR_WRITE_MODE);
93 95
 			@unlink($file);
94 96
 			return TRUE;
95
-		}
96
-		elseif ( ! is_file($file) OR ($fp = @fopen($file, FOPEN_WRITE_CREATE)) === FALSE)
97
+		} elseif ( ! is_file($file) OR ($fp = @fopen($file, FOPEN_WRITE_CREATE)) === FALSE)
97 98
 		{
98 99
 			return FALSE;
99 100
 		}
@@ -437,12 +438,10 @@  discard block
 block discarded – undo
437 438
 		if (substr(php_sapi_name(), 0, 3) == 'cgi')
438 439
 		{
439 440
 			header("Status: {$code} {$text}", TRUE);
440
-		}
441
-		elseif ($server_protocol == 'HTTP/1.1' OR $server_protocol == 'HTTP/1.0')
441
+		} elseif ($server_protocol == 'HTTP/1.1' OR $server_protocol == 'HTTP/1.0')
442 442
 		{
443 443
 			header($server_protocol." {$code} {$text}", TRUE, $code);
444
-		}
445
-		else
444
+		} else
446 445
 		{
447 446
 			header("HTTP/1.1 {$code} {$text}", TRUE, $code);
448 447
 		}
@@ -553,8 +552,7 @@  discard block
 block discarded – undo
553 552
 		if (is_array($var))
554 553
 		{
555 554
 			return array_map('html_escape', $var);
556
-		}
557
-		else
555
+		} else
558 556
 		{
559 557
 			return htmlspecialchars($var, ENT_QUOTES, config_item('charset'));
560 558
 		}
Please login to merge, or discard this patch.
web_interface/astpp/system/core/Config.php 4 patches
Doc Comments   +3 added lines, -2 removed lines patch added patch discarded remove patch
@@ -56,7 +56,7 @@  discard block
 block discarded – undo
56 56
 	 * @param   string	the config file name
57 57
 	 * @param   boolean  if configuration values should be loaded into their own section
58 58
 	 * @param   boolean  true if errors should just return false, false if an error message should be displayed
59
-	 * @return  boolean  if the file was successfully loaded or not
59
+	 * @return  boolean|null  if the file was successfully loaded or not
60 60
 	 */
61 61
 	function __construct()
62 62
 	{
@@ -223,6 +223,7 @@  discard block
 block discarded – undo
223 223
 	 * @access	public
224 224
 	 * @param	string	the config item name
225 225
 	 * @param	bool
226
+	 * @param string $item
226 227
 	 * @return	string
227 228
 	 */
228 229
 	function slash_item($item)
@@ -288,7 +289,7 @@  discard block
 block discarded – undo
288 289
 	 * Build URI string for use in Config::site_url() and Config::base_url()
289 290
 	 *
290 291
 	 * @access protected
291
-	 * @param  $uri
292
+	 * @param  string $uri
292 293
 	 * @return string
293 294
 	 */
294 295
 	protected function _uri_string($uri)
Please login to merge, or discard this patch.
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -316,7 +316,7 @@
 block discarded – undo
316 316
 				$uri = $str;
317 317
 			}
318 318
 		}
319
-	    return $uri;
319
+		return $uri;
320 320
 	}
321 321
 
322 322
 	// --------------------------------------------------------------------
Please login to merge, or discard this patch.
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -60,7 +60,7 @@  discard block
 block discarded – undo
60 60
 	 */
61 61
 	function __construct()
62 62
 	{
63
-		$this->config =& get_config();
63
+		$this->config = & get_config();
64 64
 		log_message('debug', "Config Class Initialized");
65 65
 
66 66
 		// Set the base_url automatically if none was provided
@@ -69,7 +69,7 @@  discard block
 block discarded – undo
69 69
 			if (isset($_SERVER['HTTP_HOST']))
70 70
 			{
71 71
 				$base_url = isset($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) !== 'off' ? 'https' : 'http';
72
-				$base_url .= '://'. $_SERVER['HTTP_HOST'];
72
+				$base_url .= '://'.$_SERVER['HTTP_HOST'];
73 73
 				$base_url .= str_replace(basename($_SERVER['SCRIPT_NAME']), '', $_SERVER['SCRIPT_NAME']);
74 74
 			}
75 75
 
@@ -231,7 +231,7 @@  discard block
 block discarded – undo
231 231
 		{
232 232
 			return FALSE;
233 233
 		}
234
-		if( trim($this->config[$item]) == '')
234
+		if (trim($this->config[$item]) == '')
235 235
 		{
236 236
 			return '';
237 237
 		}
@@ -279,7 +279,7 @@  discard block
 block discarded – undo
279 279
 	 */
280 280
 	function base_url($uri = '')
281 281
 	{
282
-		return $this->slash_item('base_url').ltrim($this->_uri_string($uri),'/');
282
+		return $this->slash_item('base_url').ltrim($this->_uri_string($uri), '/');
283 283
 	}
284 284
 
285 285
 	// -------------------------------------------------------------
Please login to merge, or discard this patch.
Braces   +9 added lines, -14 removed lines patch added patch discarded remove patch
@@ -1,4 +1,6 @@  discard block
 block discarded – undo
1
-<?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');
1
+<?php  if ( ! defined('BASEPATH')) {
2
+	exit('No direct script access allowed');
3
+}
2 4
 /**
3 5
  * CodeIgniter
4 6
  *
@@ -71,9 +73,7 @@  discard block
 block discarded – undo
71 73
 				$base_url = isset($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) !== 'off' ? 'https' : 'http';
72 74
 				$base_url .= '://'. $_SERVER['HTTP_HOST'];
73 75
 				$base_url .= str_replace(basename($_SERVER['SCRIPT_NAME']), '', $_SERVER['SCRIPT_NAME']);
74
-			}
75
-
76
-			else
76
+			} else
77 77
 			{
78 78
 				$base_url = 'http://localhost/';
79 79
 			}
@@ -143,13 +143,11 @@  discard block
 block discarded – undo
143 143
 				if (isset($this->config[$file]))
144 144
 				{
145 145
 					$this->config[$file] = array_merge($this->config[$file], $config);
146
-				}
147
-				else
146
+				} else
148 147
 				{
149 148
 					$this->config[$file] = $config;
150 149
 				}
151
-			}
152
-			else
150
+			} else
153 151
 			{
154 152
 				$this->config = array_merge($this->config, $config);
155 153
 			}
@@ -196,8 +194,7 @@  discard block
 block discarded – undo
196 194
 			}
197 195
 
198 196
 			$pref = $this->config[$item];
199
-		}
200
-		else
197
+		} else
201 198
 		{
202 199
 			if ( ! isset($this->config[$index]))
203 200
 			{
@@ -260,8 +257,7 @@  discard block
 block discarded – undo
260 257
 		{
261 258
 			$suffix = ($this->item('url_suffix') == FALSE) ? '' : $this->item('url_suffix');
262 259
 			return $this->slash_item('base_url').$this->slash_item('index_page').$this->_uri_string($uri).$suffix;
263
-		}
264
-		else
260
+		} else
265 261
 		{
266 262
 			return $this->slash_item('base_url').$this->item('index_page').'?'.$this->_uri_string($uri);
267 263
 		}
@@ -300,8 +296,7 @@  discard block
 block discarded – undo
300 296
 				$uri = implode('/', $uri);
301 297
 			}
302 298
 			$uri = trim($uri, '/');
303
-		}
304
-		else
299
+		} else
305 300
 		{
306 301
 			if (is_array($uri))
307 302
 			{
Please login to merge, or discard this patch.
web_interface/astpp/system/core/Exceptions.php 3 patches
Doc Comments   +2 added lines patch added patch discarded remove patch
@@ -130,6 +130,8 @@
 block discarded – undo
130 130
 	 * @param	string	the message
131 131
 	 * @param	string	the template name
132 132
 	 * @param 	int		the status code
133
+	 * @param string $heading
134
+	 * @param string $message
133 135
 	 * @return	string
134 136
 	 */
135 137
 	function show_error($heading, $message, $template = 'error_general', $status_code = 500)
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -88,7 +88,7 @@  discard block
 block discarded – undo
88 88
 	{
89 89
 		$severity = ( ! isset($this->levels[$severity])) ? $severity : $this->levels[$severity];
90 90
 
91
-		log_message('error', 'Severity: '.$severity.'  --> '.$message. ' '.$filepath.' '.$line, TRUE);
91
+		log_message('error', 'Severity: '.$severity.'  --> '.$message.' '.$filepath.' '.$line, TRUE);
92 92
 	}
93 93
 
94 94
 	// --------------------------------------------------------------------
@@ -171,7 +171,7 @@  discard block
 block discarded – undo
171 171
 		if (FALSE !== strpos($filepath, '/'))
172 172
 		{
173 173
 			$x = explode('/', $filepath);
174
-			$filepath = $x[count($x)-2].'/'.end($x);
174
+			$filepath = $x[count($x) - 2].'/'.end($x);
175 175
 		}
176 176
 
177 177
 		if (ob_get_level() > $this->ob_level + 1)
Please login to merge, or discard this patch.
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1,4 +1,6 @@
 block discarded – undo
1
-<?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');
1
+<?php  if ( ! defined('BASEPATH')) {
2
+	exit('No direct script access allowed');
3
+}
2 4
 /*
3 5
 | -------------------------------------------------------------------
4 6
 | AUTO-LOADER
Please login to merge, or discard this patch.
web_interface/astpp/system/core/Hooks.php 4 patches
Doc Comments   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -108,7 +108,7 @@  discard block
 block discarded – undo
108 108
 	 *
109 109
 	 * @access	private
110 110
 	 * @param	string	the hook name
111
-	 * @return	mixed
111
+	 * @return	boolean
112 112
 	 */
113 113
 	function _call_hook($which = '')
114 114
 	{
@@ -141,7 +141,7 @@  discard block
 block discarded – undo
141 141
 	 *
142 142
 	 * @access	private
143 143
 	 * @param	array	the hook details
144
-	 * @return	bool
144
+	 * @return	null|boolean
145 145
 	 */
146 146
 	function _run_hook($data)
147 147
 	{
Please login to merge, or discard this patch.
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -82,7 +82,7 @@
 block discarded – undo
82 82
 
83 83
 		if (defined('ENVIRONMENT') AND is_file(APPPATH.'config/'.ENVIRONMENT.'/hooks.php'))
84 84
 		{
85
-		    include(APPPATH.'config/'.ENVIRONMENT.'/hooks.php');
85
+			include(APPPATH.'config/'.ENVIRONMENT.'/hooks.php');
86 86
 		}
87 87
 		elseif (is_file(APPPATH.'config/hooks.php'))
88 88
 		{
Please login to merge, or discard this patch.
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -33,19 +33,19 @@  discard block
 block discarded – undo
33 33
 	 *
34 34
 	 * @var bool
35 35
 	 */
36
-	var $enabled		= FALSE;
36
+	var $enabled = FALSE;
37 37
 	/**
38 38
 	 * List of all hooks set in config/hooks.php
39 39
 	 *
40 40
 	 * @var array
41 41
 	 */
42
-	var $hooks			= array();
42
+	var $hooks = array();
43 43
 	/**
44 44
 	 * Determines wether hook is in progress, used to prevent infinte loops
45 45
 	 *
46 46
 	 * @var bool
47 47
 	 */
48
-	var $in_progress	= FALSE;
48
+	var $in_progress = FALSE;
49 49
 
50 50
 	/**
51 51
 	 * Constructor
@@ -67,7 +67,7 @@  discard block
 block discarded – undo
67 67
 	 */
68 68
 	function _initialize()
69 69
 	{
70
-		$CFG =& load_class('Config', 'core');
70
+		$CFG = & load_class('Config', 'core');
71 71
 
72 72
 		// If hooks are not enabled in the config file
73 73
 		// there is nothing else to do
@@ -95,7 +95,7 @@  discard block
 block discarded – undo
95 95
 			return;
96 96
 		}
97 97
 
98
-		$this->hooks =& $hook;
98
+		$this->hooks = & $hook;
99 99
 		$this->enabled = TRUE;
100 100
 	}
101 101
 
@@ -182,9 +182,9 @@  discard block
 block discarded – undo
182 182
 		// Set class/function name
183 183
 		// -----------------------------------
184 184
 
185
-		$class		= FALSE;
186
-		$function	= FALSE;
187
-		$params		= '';
185
+		$class = FALSE;
186
+		$function = FALSE;
187
+		$params = '';
188 188
 
189 189
 		if (isset($data['class']) AND $data['class'] != '')
190 190
 		{
Please login to merge, or discard this patch.
Braces   +6 added lines, -7 removed lines patch added patch discarded remove patch
@@ -1,4 +1,6 @@  discard block
 block discarded – undo
1
-<?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');
1
+<?php  if ( ! defined('BASEPATH')) {
2
+	exit('No direct script access allowed');
3
+}
2 4
 /**
3 5
  * CodeIgniter
4 6
  *
@@ -83,8 +85,7 @@  discard block
 block discarded – undo
83 85
 		if (defined('ENVIRONMENT') AND is_file(APPPATH.'config/'.ENVIRONMENT.'/hooks.php'))
84 86
 		{
85 87
 		    include(APPPATH.'config/'.ENVIRONMENT.'/hooks.php');
86
-		}
87
-		elseif (is_file(APPPATH.'config/hooks.php'))
88
+		} elseif (is_file(APPPATH.'config/hooks.php'))
88 89
 		{
89 90
 			include(APPPATH.'config/hooks.php');
90 91
 		}
@@ -123,8 +124,7 @@  discard block
 block discarded – undo
123 124
 			{
124 125
 				$this->_run_hook($val);
125 126
 			}
126
-		}
127
-		else
127
+		} else
128 128
 		{
129 129
 			$this->_run_hook($this->hooks[$which]);
130 130
 		}
@@ -225,8 +225,7 @@  discard block
 block discarded – undo
225 225
 
226 226
 			$HOOK = new $class;
227 227
 			$HOOK->$function($params);
228
-		}
229
-		else
228
+		} else
230 229
 		{
231 230
 			if ( ! function_exists($function))
232 231
 			{
Please login to merge, or discard this patch.