Completed
Push — v3.0 ( 23635d...e28df5 )
by Samir
23s
created
freeswitch/fs/lib/astpp.cdr.php 2 patches
Doc Comments   +16 added lines patch added patch discarded remove patch
@@ -189,6 +189,10 @@  discard block
 block discarded – undo
189 189
 }
190 190
 
191 191
 //Insert parent resellers cdr
192
+/**
193
+ * @param string $provider_cost
194
+ * @param boolean $flag_parent
195
+ */
192 196
 function insert_parent_data($dataVariable,$actual_calltype,$parentid,$origination_rate,$actual_duration,$provider_cost,$flag_parent,$logger,$db,$decimal_points)
193 197
 {
194 198
 	while($parentid > 0 )
@@ -250,6 +254,9 @@  discard block
 block discarded – undo
250 254
 }
251 255
 
252 256
 //Insert callee cdr entry for DID calls
257
+/**
258
+ * @param boolean $flag_parent
259
+ */
253 260
 function insert_extra_receiver_entry($dataVariable,$origination_rate,$termination_rate,$account_type,$actual_duration,$provider_cost,$parentid,$flag_parent,$accountid,$logger,$db,$decimal_points)
254 261
 {
255 262
 		$localVariable = $dataVariable;
@@ -318,6 +325,9 @@  discard block
 block discarded – undo
318 325
 }
319 326
 
320 327
 //Update user balance
328
+/**
329
+ * @param integer $entity_id
330
+ */
321 331
 function update_balance($user_id, $amount, $entity_id, $logger, $db) {
322 332
     $math_sign = ($entity_id == 0 || $entity_id == 1) ? '-' : '+';
323 333
     $query = "UPDATE accounts SET balance=balance-" . $amount . " WHERE id=" . $user_id;
@@ -457,6 +467,9 @@  discard block
 block discarded – undo
457 467
 }
458 468
 
459 469
 // String append prefix for checking rates
470
+/**
471
+ * @param string $field
472
+ */
460 473
 function number_loop($destination,$field,$db)
461 474
 {
462 475
 	$max_len_prefix  = strlen($destination);
@@ -471,6 +484,9 @@  discard block
 block discarded – undo
471 484
 }
472 485
 
473 486
 //Convert current time to GMT
487
+/**
488
+ * @param string $date
489
+ */
474 490
 function convert_to_gmt($date)
475 491
 {
476 492
 	return gmdate('Y-m-d H:i:s', strtotime($date) );
Please login to merge, or discard this patch.
Spacing   +103 added lines, -103 removed lines patch added patch discarded remove patch
@@ -22,7 +22,7 @@  discard block
 block discarded – undo
22 22
 ###############################################################################
23 23
 
24 24
 //Process CDR 
25
-function process_cdr($data,$db,$logger,$decimal_points)
25
+function process_cdr($data, $db, $logger, $decimal_points)
26 26
 {
27 27
 	//$logger->log(print_r($data,true));//exit;
28 28
 
@@ -46,15 +46,15 @@  discard block
 block discarded – undo
46 46
 
47 47
     if ($dataVariable['billsec'] == 0 && $dataVariable['hangup_cause'] == 'NORMAL_CLEARING')
48 48
     {
49
-        $hangup_cause = isset($dataVariable['last_bridge_hangup_cause'])?$dataVariable['last_bridge_hangup_cause']:$dataVariable['hangup_cause'];
50
-    }else{
49
+        $hangup_cause = isset($dataVariable['last_bridge_hangup_cause']) ? $dataVariable['last_bridge_hangup_cause'] : $dataVariable['hangup_cause'];
50
+    } else {
51 51
         $hangup_cause = $dataVariable['hangup_cause'];
52 52
     }   
53 53
 
54 54
     if ($dataVariable['error_cdr'] == '1')
55 55
     {
56 56
         //Get actual hangup cause 
57
-        $hangup_cause= (isset($dataVariable['error_cdr'])) ? $dataVariable['last_bridge_hangup_cause'] : (isset($dataVariable['last_bridge_hangup_cause'])?$dataVariable['last_bridge_hangup_cause']:$dataVariable['hangup_cause']); 
57
+        $hangup_cause = (isset($dataVariable['error_cdr'])) ? $dataVariable['last_bridge_hangup_cause'] : (isset($dataVariable['last_bridge_hangup_cause']) ? $dataVariable['last_bridge_hangup_cause'] : $dataVariable['hangup_cause']); 
58 58
     }
59 59
 
60 60
 	/*#### PATCH FOR ONE WAY AUDIO ####*/
@@ -65,14 +65,14 @@  discard block
 block discarded – undo
65 65
 	/*#### ************* END *************####*/
66 66
 
67 67
     //Don't thing this will be useful anytime. Need to remove it after testing. 
68
-	if($hangup_cause == "NONE")
68
+	if ($hangup_cause == "NONE")
69 69
 	{
70 70
 		$hangup_cause = $dataVariable['current_application_data'];
71 71
 	}
72 72
 
73 73
     $dataVariable['hangup_cause'] = $hangup_cause;
74 74
 
75
-	if ( ($dataVariable['hangup_cause'] != 'NORMAL_CLEARING') && ($dataVariable['hangup_cause'] != 'ALLOTTED_TIMEOUT')) {
75
+	if (($dataVariable['hangup_cause'] != 'NORMAL_CLEARING') && ($dataVariable['hangup_cause'] != 'ALLOTTED_TIMEOUT')) {
76 76
 	  	$dataVariable['billsec'] = 0;
77 77
 	}
78 78
 
@@ -86,13 +86,13 @@  discard block
 block discarded – undo
86 86
 	$actual_calltype = $dataVariable['calltype'];
87 87
 	
88 88
     //Normalize origination and termination rates array 		   
89
-	if(isset($dataVariable['origination_rates']))
89
+	if (isset($dataVariable['origination_rates']))
90 90
 	   $origination_rate = normalize_origination_rate($dataVariable['origination_rates']);
91
-	if(isset($dataVariable['termination_rates']))
91
+	if (isset($dataVariable['termination_rates']))
92 92
 	   $termination_rate = normalize_rate($dataVariable['termination_rates']);
93 93
 
94 94
     //If receiver account id found then explicitly set call direction and call type 
95
-	if(isset($dataVariable['receiver_accid']))
95
+	if (isset($dataVariable['receiver_accid']))
96 96
 	{
97 97
 		$dataVariable['call_direction'] = "outbound";
98 98
         $dataVariable['calltype'] = "STANDARD";
@@ -101,23 +101,23 @@  discard block
 block discarded – undo
101 101
     //Check if cusotmer have any package seconds left to use
102 102
 	if ($actual_duration > 0)			
103 103
     {
104
-			$package_array = package_calculation( $dataVariable['effective_destination_number'],$origination_rate[$accountid]['RATEGROUP'],$actual_duration,$dataVariable['call_direction'],$accountid,$db,$logger);
105
-			if(!empty($package_array))
104
+			$package_array = package_calculation($dataVariable['effective_destination_number'], $origination_rate[$accountid]['RATEGROUP'], $actual_duration, $dataVariable['call_direction'], $accountid, $db, $logger);
105
+			if ( ! empty($package_array))
106 106
 			{
107 107
 				$dataVariable['calltype'] = "FREE";
108
-				$dataVariable['package_id']= $package_array['package_id'];
108
+				$dataVariable['package_id'] = $package_array['package_id'];
109 109
 			}
110 110
 	}
111 111
 	
112 112
     //Calculate debit of customer call 			
113
-	$debit = calc_cost($dataVariable,$origination_rate[$accountid],$logger,$decimal_points);
113
+	$debit = calc_cost($dataVariable, $origination_rate[$accountid], $logger, $decimal_points);
114 114
 
115 115
     //Calculate cost for customer call for provider
116
-	$provider_cost = calc_cost($dataVariable,$termination_rate,$logger,$decimal_points);
116
+	$provider_cost = calc_cost($dataVariable, $termination_rate, $logger, $decimal_points);
117 117
 
118 118
     //Calculate parent cost if customer have any parent 
119
-	$parent_cost = ($parentid > 0) ? calc_cost($dataVariable,$origination_rate[$parentid],$logger,$decimal_points) : $provider_cost;
120
-    $logger->log("Debit :".$debit ." Cost : ".$cost ." Provider Cost : ".$parent_cost);
119
+	$parent_cost = ($parentid > 0) ? calc_cost($dataVariable, $origination_rate[$parentid], $logger, $decimal_points) : $provider_cost;
120
+    $logger->log("Debit :".$debit." Cost : ".$cost." Provider Cost : ".$parent_cost);
121 121
     
122 122
     //Initialize final cost variable to use for billing
123 123
 	$cost = ($parent_cost > 0) ? $parent_cost : $provider_cost;    
@@ -125,33 +125,33 @@  discard block
 block discarded – undo
125 125
     //Outbound call entry for all type of calls 
126 126
 	$logger->log("*********************** OUTBOUND CALL ENTRY START *************");
127 127
 
128
-	$cdr_string = get_cdr_string($dataVariable,$accountid,$account_type,$actual_duration,$termination_rate,$origination_rate,$provider_cost,$parentid,$debit,$cost,$logger);
128
+	$cdr_string = get_cdr_string($dataVariable, $accountid, $account_type, $actual_duration, $termination_rate, $origination_rate, $provider_cost, $parentid, $debit, $cost, $logger);
129 129
 
130 130
 	$query = "INSERT INTO cdrs (uniqueid,accountid,type,callerid,callednum,billseconds,trunk_id,trunkip,callerip,disposition,callstart,debit,cost,provider_id,pricelist_id,package_id,pattern,notes,rate_cost,reseller_id,reseller_code,reseller_code_destination,reseller_cost,provider_code,provider_code_destination,provider_cost,provider_call_cost,call_direction,calltype,profile_start_stamp,answer_stamp,bridge_stamp,progress_stamp,progress_media_stamp,end_stamp,billmsec,answermsec,waitmsec,progress_mediamsec,flow_billmsec)  values ($cdr_string)";
131 131
 	$logger->log($query);
132 132
 	$db->run($query);
133 133
 	
134 134
     //Update customer balance
135
-	if($debit > 0 && $dataVariable['calltype'] != "FREE")
135
+	if ($debit > 0 && $dataVariable['calltype'] != "FREE")
136 136
 	{
137 137
 		update_balance($accountid, $debit, 0, $logger, $db);
138 138
 	}
139 139
 
140 140
     //Update parent or provider balance
141
-	if($parent_cost > 0){
141
+	if ($parent_cost > 0) {
142 142
 		update_balance($termination_rate['PROVIDER'], ($parent_cost * -1), 3, $logger, $db);
143 143
 	}
144 144
 
145 145
     //Resellers CDR entry
146 146
     $flag_parent = false;
147
-    insert_parent_data($dataVariable,$actual_calltype,$parentid,$origination_rate,$actual_duration,$provider_cost,$flag_parent,$logger,$db,$decimal_points);
147
+    insert_parent_data($dataVariable, $actual_calltype, $parentid, $origination_rate, $actual_duration, $provider_cost, $flag_parent, $logger, $db, $decimal_points);
148 148
 
149 149
     $logger->log("*********************** OUTBOUND CALL ENTRY END *************");
150 150
 
151 151
    
152 152
     //************ ADDING EXTRA ENTRY For local/DID Inbound call ****************************
153
-	$receiver_parentid=0;
154
-	if(isset($dataVariable['receiver_accid']) && $dataVariable['receiver_accid'] != "")
153
+	$receiver_parentid = 0;
154
+	if (isset($dataVariable['receiver_accid']) && $dataVariable['receiver_accid'] != "")
155 155
 	{
156 156
     	$logger->log("*********************** EXTRA ENTRY SECTION FOR BILLING START *************");            
157 157
 
@@ -160,7 +160,7 @@  discard block
 block discarded – undo
160 160
         $dataVariable['calltype'] = "DID";
161 161
 
162 162
         //Override variables if call for DID PSTN
163
-        if(isset($dataVariable['caller_did_account_id']))
163
+        if (isset($dataVariable['caller_did_account_id']))
164 164
         {
165 165
             $dataVariable['receiver_accid'] = $dataVariable['caller_did_account_id'];
166 166
     		$dataVariable['call_direction'] = "outbound";
@@ -171,17 +171,17 @@  discard block
 block discarded – undo
171 171
         
172 172
 
173 173
         //Get call receiver account information 
174
-		$receiver_carddata = get_accounts($dataVariable['receiver_accid'],$logger,$db);
174
+		$receiver_carddata = get_accounts($dataVariable['receiver_accid'], $logger, $db);
175 175
 		$receiver_parentid = $receiver_carddata['reseller_id'];
176 176
 
177 177
         //For additional cdr entry of receiver
178
-		insert_extra_receiver_entry($dataVariable,$origination_rate,$termination_rate,$account_type,$actual_duration,$provider_cost,$receiver_parentid,$flag_parent,$dataVariable['receiver_accid'],$logger,$db,$decimal_points);
178
+		insert_extra_receiver_entry($dataVariable, $origination_rate, $termination_rate, $account_type, $actual_duration, $provider_cost, $receiver_parentid, $flag_parent, $dataVariable['receiver_accid'], $logger, $db, $decimal_points);
179 179
 
180 180
 		$flag_parent = true;
181 181
 		$dataVariable['uuid'] = $dataVariable['uuid'].$dataVariable['calltype']."_".$receiver_parentid;
182 182
 
183 183
         //Insert parent reseller cdr
184
-		insert_parent_data($dataVariable,$actual_calltype,$receiver_parentid,$origination_rate,$actual_duration,$provider_cost,$flag_parent,$logger,$db,$decimal_points);
184
+		insert_parent_data($dataVariable, $actual_calltype, $receiver_parentid, $origination_rate, $actual_duration, $provider_cost, $flag_parent, $logger, $db, $decimal_points);
185 185
     	$logger->log("*********************** EXTRA ENTRY SECTION FOR BILLING END *************");            
186 186
 	}
187 187
     //*****************************************************************************************
@@ -189,16 +189,16 @@  discard block
 block discarded – undo
189 189
 }
190 190
 
191 191
 //Insert parent resellers cdr
192
-function insert_parent_data($dataVariable,$actual_calltype,$parentid,$origination_rate,$actual_duration,$provider_cost,$flag_parent,$logger,$db,$decimal_points)
192
+function insert_parent_data($dataVariable, $actual_calltype, $parentid, $origination_rate, $actual_duration, $provider_cost, $flag_parent, $logger, $db, $decimal_points)
193 193
 {
194
-	while($parentid > 0 )
194
+	while ($parentid > 0)
195 195
 	{
196 196
 		$logger->log("*************** IN PARENT DATA SECTION ********");
197 197
 		$dataVariable['calltype'] = $actual_calltype;
198
-		$carddata = get_accounts($parentid,$logger,$db);
198
+		$carddata = get_accounts($parentid, $logger, $db);
199 199
 		$accountid = $carddata['id'];
200 200
 
201
-		$debit = calc_cost($dataVariable,$origination_rate[$accountid],$logger,$decimal_points);
201
+		$debit = calc_cost($dataVariable, $origination_rate[$accountid], $logger, $decimal_points);
202 202
 
203 203
         //If receiver account id found then explicitly set call direction and call type
204 204
         /*if(isset($dataVariable['receiver_accid']))
@@ -208,31 +208,31 @@  discard block
 block discarded – undo
208 208
         }*/
209 209
 
210 210
         //Check if reseller have any package seconds left to use        
211
-		if ($actual_duration > 0)		{
212
-			$package_array = package_calculation( $dataVariable['effective_destination_number'],$origination_rate[$accountid]['RATEGROUP'],$actual_duration,$dataVariable['call_direction'],$accountid,$db,$logger);
213
-			if(!empty($package_array))
211
+		if ($actual_duration > 0) {
212
+			$package_array = package_calculation($dataVariable['effective_destination_number'], $origination_rate[$accountid]['RATEGROUP'], $actual_duration, $dataVariable['call_direction'], $accountid, $db, $logger);
213
+			if ( ! empty($package_array))
214 214
 			{
215 215
 				$dataVariable['calltype'] = "FREE";
216
-				$dataVariable['package_id']= $package_array['package_id'];
216
+				$dataVariable['package_id'] = $package_array['package_id'];
217 217
 			}
218 218
 		}	
219 219
 
220 220
         //Get parent id for cost calculation 
221 221
 		$parentid = $carddata['reseller_id'];
222
-		$parent_cost = ($parentid > 0) ? calc_cost($dataVariable,$origination_rate[$parentid],$logger,$decimal_points) : $provider_cost;
222
+		$parent_cost = ($parentid > 0) ? calc_cost($dataVariable, $origination_rate[$parentid], $logger, $decimal_points) : $provider_cost;
223 223
 		$cost = ($parent_cost > 0) ? $parent_cost : $provider_cost;
224 224
 	
225
-		if(isset($dataVariable['receiver_accid']) && $dataVariable['receiver_accid'] != "" && $flag_parent == true)
225
+		if (isset($dataVariable['receiver_accid']) && $dataVariable['receiver_accid'] != "" && $flag_parent == true)
226 226
 		{
227 227
 			$logger->log("********* IN RESELLER FOR RECEIVER ENTRY START ******");
228 228
 			$flag_parent = true;
229
-			insert_extra_receiver_entry($dataVariable,$origination_rate,$termination_rate,$account_type,$actual_duration,$provider_cost,$parentid,$flag_parent,$accountid,$logger,$db,$decimal_points);
229
+			insert_extra_receiver_entry($dataVariable, $origination_rate, $termination_rate, $account_type, $actual_duration, $provider_cost, $parentid, $flag_parent, $accountid, $logger, $db, $decimal_points);
230 230
     		$logger->log("********* IN RESELLER FOR RECEIVER ENTRY END ******");
231 231
 			return true;	
232 232
 
233
-		}else{
233
+		} else {
234 234
 
235
-		    $cdr_string = get_reseller_cdr_string($dataVariable,$accountid,$account_type,$actual_duration,$termination_rate,$origination_rate,$provider_cost,$parentid,$debit,$cost);	
235
+		    $cdr_string = get_reseller_cdr_string($dataVariable, $accountid, $account_type, $actual_duration, $termination_rate, $origination_rate, $provider_cost, $parentid, $debit, $cost);	
236 236
 
237 237
  			$query = "INSERT INTO reseller_cdrs (uniqueid,accountid,callerid,callednum,billseconds,disposition,callstart,debit,cost,pricelist_id,package_id,pattern,notes,rate_cost,
238 238
 		reseller_id,reseller_code,reseller_code_destination,reseller_cost,call_direction,calltype) values ($cdr_string)";
@@ -240,7 +240,7 @@  discard block
 block discarded – undo
240 240
 			$db->run($query);
241 241
 
242 242
 			//Update reseller balance
243
-			if( $debit > 0 && $dataVariable['calltype'] != "FREE"){
243
+			if ($debit > 0 && $dataVariable['calltype'] != "FREE") {
244 244
 				update_balance($accountid, $debit, 0, $logger, $db);
245 245
 			}
246 246
 		}
@@ -250,40 +250,40 @@  discard block
 block discarded – undo
250 250
 }
251 251
 
252 252
 //Insert callee cdr entry for DID calls
253
-function insert_extra_receiver_entry($dataVariable,$origination_rate,$termination_rate,$account_type,$actual_duration,$provider_cost,$parentid,$flag_parent,$accountid,$logger,$db,$decimal_points)
253
+function insert_extra_receiver_entry($dataVariable, $origination_rate, $termination_rate, $account_type, $actual_duration, $provider_cost, $parentid, $flag_parent, $accountid, $logger, $db, $decimal_points)
254 254
 {
255 255
 		$localVariable = $dataVariable;
256 256
 		$localVariable['call_direction'] = "inbound";
257 257
 		$localVariable['uuid'] = $localVariable['uuid'].$dataVariable['calltype']."_".$accountid;
258 258
 		
259
-		if($dataVariable['calltype'] == "LOCAL")
259
+		if ($dataVariable['calltype'] == "LOCAL")
260 260
 		{
261 261
 			$origination_rate[$accountid]['CODE'] = $dataVariable['effective_destination_number'];
262 262
 			$origination_rate[$accountid]['DESTINATION'] = $dataVariable['calltype'];
263
-			if($flag_parent == false){
264
-				$cdr_string = get_cdr_string($localVariable,$accountid,$account_type,$actual_duration,$termination_rate,$origination_rate,$provider_cost,$parentid,0,0,$logger);
263
+			if ($flag_parent == false) {
264
+				$cdr_string = get_cdr_string($localVariable, $accountid, $account_type, $actual_duration, $termination_rate, $origination_rate, $provider_cost, $parentid, 0, 0, $logger);
265 265
 			}
266
-			else{
267
-				$cdr_string = get_reseller_cdr_string($dataVariable,$accountid,$account_type,$actual_duration,$termination_rate,$origination_rate,$provider_cost,$parentid,$debit,$cost);
266
+			else {
267
+				$cdr_string = get_reseller_cdr_string($dataVariable, $accountid, $account_type, $actual_duration, $termination_rate, $origination_rate, $provider_cost, $parentid, $debit, $cost);
268 268
 			}
269
-		}else{
269
+		} else {
270 270
 
271 271
 			$origination_rate_did = normalize_origination_rate($dataVariable['origination_rates_did']);
272
-			$debit = calc_cost($dataVariable,$origination_rate_did[$accountid],$logger,$decimal_points);
272
+			$debit = calc_cost($dataVariable, $origination_rate_did[$accountid], $logger, $decimal_points);
273 273
 
274
-			if($flag_parent == false){
274
+			if ($flag_parent == false) {
275 275
 				
276
-				$cdr_string = get_cdr_string($localVariable,$accountid,$account_type,$actual_duration,$termination_rate,$origination_rate_did,$provider_cost,$parentid,$debit,0,$logger);
276
+				$cdr_string = get_cdr_string($localVariable, $accountid, $account_type, $actual_duration, $termination_rate, $origination_rate_did, $provider_cost, $parentid, $debit, 0, $logger);
277 277
 			}
278
-			else{
279
-				$cdr_string = get_reseller_cdr_string($dataVariable,$accountid,$account_type,$actual_duration,$termination_rate,$origination_rate,$provider_cost,$parentid,$debit,$cost);
278
+			else {
279
+				$cdr_string = get_reseller_cdr_string($dataVariable, $accountid, $account_type, $actual_duration, $termination_rate, $origination_rate, $provider_cost, $parentid, $debit, $cost);
280 280
 			}
281 281
 		}
282 282
 	  
283
-		if($flag_parent == false)
283
+		if ($flag_parent == false)
284 284
 		{
285 285
 			$query = "INSERT INTO cdrs(uniqueid,accountid,type,callerid,callednum,billseconds,trunk_id,trunkip,callerip,disposition,callstart,debit,cost,provider_id,pricelist_id,package_id,pattern,notes,rate_cost,reseller_id,reseller_code,reseller_code_destination,reseller_cost,provider_code,provider_code_destination,provider_cost,provider_call_cost,call_direction,calltype,profile_start_stamp,answer_stamp,bridge_stamp,progress_stamp,progress_media_stamp,end_stamp,billmsec,answermsec,waitmsec,progress_mediamsec,flow_billmsec) values ($cdr_string)";
286
-		}else{
286
+		} else {
287 287
 			$query = "INSERT INTO reseller_cdrs (uniqueid,accountid,callerid,callednum,billseconds,disposition,callstart,debit,cost,pricelist_id,package_id,pattern,notes,rate_cost,
288 288
 	reseller_id,reseller_code,reseller_code_destination,reseller_cost,call_direction,calltype) values ($cdr_string)";
289 289
 		}
@@ -291,7 +291,7 @@  discard block
 block discarded – undo
291 291
 		$logger->log($query);
292 292
 		$db->run($query);	
293 293
 
294
-		if($debit > 0 && ($dataVariable['calltype'] != "FREE" && $dataVariable['calltype'] != "LOCAL"))
294
+		if ($debit > 0 && ($dataVariable['calltype'] != "FREE" && $dataVariable['calltype'] != "LOCAL"))
295 295
 		{
296 296
 			update_balance($accountid, $debit, 0, $logger, $db);
297 297
 		}
@@ -299,29 +299,29 @@  discard block
 block discarded – undo
299 299
 }
300 300
 
301 301
 //Generate CDR string for insert query for customer.
302
-function get_cdr_string($dataVariable,$accountid,$account_type,$actual_duration,$termination_rate,$origination_rate,$provider_cost,$parentid,$debit,$cost,$logger)
302
+function get_cdr_string($dataVariable, $accountid, $account_type, $actual_duration, $termination_rate, $origination_rate, $provider_cost, $parentid, $debit, $cost, $logger)
303 303
 {
304 304
 
305
-        $dataVariable['calltype'] = ($dataVariable['calltype'] == 'DID-LOCAL' || $dataVariable['calltype'] == 'SIP-DID' || $dataVariable['calltype'] == 'OTHER')?"DID":$dataVariable['calltype'];
305
+        $dataVariable['calltype'] = ($dataVariable['calltype'] == 'DID-LOCAL' || $dataVariable['calltype'] == 'SIP-DID' || $dataVariable['calltype'] == 'OTHER') ? "DID" : $dataVariable['calltype'];
306 306
 
307
-		return  $cdr_string = "'".($dataVariable['uuid'])."','".$accountid."','".$account_type."','".(urldecode($dataVariable['caller_id']))."','".($dataVariable['effective_destination_number'])."','".$actual_duration."',".(($termination_rate['TRUNK']) ? $termination_rate['TRUNK'] : '0').",".(($dataVariable['sip_via_host']) ? "'".$dataVariable['sip_via_host']."'" : '').",".(($dataVariable['sip_contact_host']) ? "'".$dataVariable['sip_contact_host']."'" : '').",'".($dataVariable['hangup_cause'])."','".urldecode($dataVariable['callstart'])."','".$debit."','".$cost."',".(($termination_rate['PROVIDER']) ? $termination_rate['PROVIDER'] : '0').",'".$origination_rate[$accountid]['RATEGROUP']."','".$dataVariable['package_id']."','".($origination_rate[$accountid]['CODE'])."',".(($origination_rate[$accountid]['DESTINATION']) ? "'".htmlentities($origination_rate[$accountid]['DESTINATION'],ENT_COMPAT, 'UTF-8')."'" : "'".''."'").",".(($origination_rate[$accountid]['COST']) ? "'".$origination_rate[$accountid]['COST']."'" : "'".'0'."'").",
308
-'".$parentid."',".(($origination_rate[$parentid]['CODE'] ) ? "'".$origination_rate[$parentid]['CODE']."'" : "'".'0'."'").",".(($origination_rate[$parentid]['DESTINATION']) ?  "'".$origination_rate[$parentid]['DESTINATION']."'" : "'".''."'").",".(($origination_rate[$parentid]['COST']) ?  "'".$origination_rate[$parentid]['COST']."'" :  '0').",".(($termination_rate['CODE']) ? "'".$termination_rate['CODE']."'" : "'".''."'" ).",
307
+		return  $cdr_string = "'".($dataVariable['uuid'])."','".$accountid."','".$account_type."','".(urldecode($dataVariable['caller_id']))."','".($dataVariable['effective_destination_number'])."','".$actual_duration."',".(($termination_rate['TRUNK']) ? $termination_rate['TRUNK'] : '0').",".(($dataVariable['sip_via_host']) ? "'".$dataVariable['sip_via_host']."'" : '').",".(($dataVariable['sip_contact_host']) ? "'".$dataVariable['sip_contact_host']."'" : '').",'".($dataVariable['hangup_cause'])."','".urldecode($dataVariable['callstart'])."','".$debit."','".$cost."',".(($termination_rate['PROVIDER']) ? $termination_rate['PROVIDER'] : '0').",'".$origination_rate[$accountid]['RATEGROUP']."','".$dataVariable['package_id']."','".($origination_rate[$accountid]['CODE'])."',".(($origination_rate[$accountid]['DESTINATION']) ? "'".htmlentities($origination_rate[$accountid]['DESTINATION'], ENT_COMPAT, 'UTF-8')."'" : "'".''."'").",".(($origination_rate[$accountid]['COST']) ? "'".$origination_rate[$accountid]['COST']."'" : "'".'0'."'").",
308
+'".$parentid."',".(($origination_rate[$parentid]['CODE']) ? "'".$origination_rate[$parentid]['CODE']."'" : "'".'0'."'").",".(($origination_rate[$parentid]['DESTINATION']) ? "'".$origination_rate[$parentid]['DESTINATION']."'" : "'".''."'").",".(($origination_rate[$parentid]['COST']) ? "'".$origination_rate[$parentid]['COST']."'" : '0').",".(($termination_rate['CODE']) ? "'".$termination_rate['CODE']."'" : "'".''."'").",
309 309
 ".(($termination_rate['DESTINATION']) ? "'".$termination_rate['DESTINATION']."'" : "'".''."'").",".(($termination_rate['COST']) ? "'".$termination_rate['COST']."'" : '0').",'".$provider_cost."',".(($dataVariable['call_direction']) ? "'".$dataVariable['call_direction']."'" : "'internal'").",'".($dataVariable['calltype'])."','".convert_to_gmt(urldecode($dataVariable['profile_start_stamp']))."','".convert_to_gmt(urldecode($dataVariable['answer_stamp']))."','".convert_to_gmt(urldecode($dataVariable['bridge_stamp']))."','".convert_to_gmt(urldecode(@$dataVariable['progress_stamp']))."','".convert_to_gmt(urldecode(@$dataVariable['progress_media_stamp']))."','".convert_to_gmt(urldecode($dataVariable['end_stamp']))."',".$dataVariable['billmsec'].",'".$dataVariable['answermsec']."','".$dataVariable['waitmsec']."','".$dataVariable['progress_mediamsec']."','".$dataVariable['flow_billmsec']."'";
310 310
 
311 311
 }
312 312
 
313 313
 //Generate CDR string for insert query for reseller
314
-function get_reseller_cdr_string($dataVariable,$accountid,$account_type,$actual_duration,$termination_rate,$origination_rate,$provider_cost,$parentid,$debit,$cost)
314
+function get_reseller_cdr_string($dataVariable, $accountid, $account_type, $actual_duration, $termination_rate, $origination_rate, $provider_cost, $parentid, $debit, $cost)
315 315
 {
316
-        $dataVariable['calltype'] = ($dataVariable['calltype'] == 'DID-LOCAL' || $dataVariable['calltype'] == 'SIP-DID' || $dataVariable['calltype'] == 'OTHER')?"DID":$dataVariable['calltype'];
317
-	return $cdr_string = "'".($dataVariable['uuid'])."','".$accountid."','".(urldecode($dataVariable['caller_id']))."','".($dataVariable['effective_destination_number'])."','".$actual_duration."','".($dataVariable['hangup_cause'])."','".convert_to_gmt(urldecode($dataVariable['callstart']))."','".$debit."','".$cost."','".$origination_rate[$accountid]['RATEGROUP']."','".$dataVariable['package_id']."','".($origination_rate[$accountid]['CODE'])."',".(($origination_rate[$accountid]['DESTINATION']) ? "'".$origination_rate[$accountid]['DESTINATION']."'" : "'".''."'").",".(($origination_rate[$accountid]['COST']) ? "'".$origination_rate[$accountid]['COST']."'" : "'".'0'."'").",'".$parentid."',".(($origination_rate[$parentid]['CODE'] ) ? "'".$origination_rate[$parentid]['CODE']."'" : "'".'0'."'").",".(($origination_rate[$parentid]['DESTINATION']) ?  "'".$origination_rate[$parentid]['DESTINATION']."'" : "'".''."'").",".(($origination_rate[$parentid]['COST']) ?  "'".$origination_rate[$parentid]['COST']."'" :  '0').",".(($dataVariable['call_direction']) ? "'".$dataVariable['call_direction']."'" : "'internal'").",'".($dataVariable['calltype'])."'";
316
+        $dataVariable['calltype'] = ($dataVariable['calltype'] == 'DID-LOCAL' || $dataVariable['calltype'] == 'SIP-DID' || $dataVariable['calltype'] == 'OTHER') ? "DID" : $dataVariable['calltype'];
317
+	return $cdr_string = "'".($dataVariable['uuid'])."','".$accountid."','".(urldecode($dataVariable['caller_id']))."','".($dataVariable['effective_destination_number'])."','".$actual_duration."','".($dataVariable['hangup_cause'])."','".convert_to_gmt(urldecode($dataVariable['callstart']))."','".$debit."','".$cost."','".$origination_rate[$accountid]['RATEGROUP']."','".$dataVariable['package_id']."','".($origination_rate[$accountid]['CODE'])."',".(($origination_rate[$accountid]['DESTINATION']) ? "'".$origination_rate[$accountid]['DESTINATION']."'" : "'".''."'").",".(($origination_rate[$accountid]['COST']) ? "'".$origination_rate[$accountid]['COST']."'" : "'".'0'."'").",'".$parentid."',".(($origination_rate[$parentid]['CODE']) ? "'".$origination_rate[$parentid]['CODE']."'" : "'".'0'."'").",".(($origination_rate[$parentid]['DESTINATION']) ? "'".$origination_rate[$parentid]['DESTINATION']."'" : "'".''."'").",".(($origination_rate[$parentid]['COST']) ? "'".$origination_rate[$parentid]['COST']."'" : '0').",".(($dataVariable['call_direction']) ? "'".$dataVariable['call_direction']."'" : "'internal'").",'".($dataVariable['calltype'])."'";
318 318
 }
319 319
 
320 320
 //Update user balance
321 321
 function update_balance($user_id, $amount, $entity_id, $logger, $db) {
322 322
     $math_sign = ($entity_id == 0 || $entity_id == 1) ? '-' : '+';
323
-    $query = "UPDATE accounts SET balance=balance-" . $amount . " WHERE id=" . $user_id;
324
-    $logger->log("Balance update : " . $query);
323
+    $query = "UPDATE accounts SET balance=balance-".$amount." WHERE id=".$user_id;
324
+    $logger->log("Balance update : ".$query);
325 325
     $db->run($query);
326 326
 }
327 327
 
@@ -329,13 +329,13 @@  discard block
 block discarded – undo
329 329
 function normalize_rate($dataVariable)
330 330
 {
331 331
 	$rates = urldecode($dataVariable);
332
-    $data = explode("|",$rates);
332
+    $data = explode("|", $rates);
333 333
 
334 334
 	$newarray = array();
335
-    foreach($data as $key => $value)
335
+    foreach ($data as $key => $value)
336 336
     {
337
-            $data1 = explode(":",$value);
338
-            foreach($data1 as $newkey => $newvalue)
337
+            $data1 = explode(":", $value);
338
+            foreach ($data1 as $newkey => $newvalue)
339 339
             {
340 340
                     $newarray[$data1[0]] = $data1[$newkey];
341 341
             }
@@ -347,16 +347,16 @@  discard block
 block discarded – undo
347 347
 function normalize_origination_rate($dataVariable)
348 348
 {
349 349
 	$rates = urldecode($dataVariable);
350
-	$data = explode("|",$rates);
350
+	$data = explode("|", $rates);
351 351
 	$newarray = array();
352 352
 	$newarray1 = array();	
353
-	foreach($data as $key => $value)
353
+	foreach ($data as $key => $value)
354 354
 	{
355
-		$data1 = explode(":",$value);
356
-		foreach($data1 as $newkey => $newvalue)
355
+		$data1 = explode(":", $value);
356
+		foreach ($data1 as $newkey => $newvalue)
357 357
 		{
358 358
 			$newarray[$data1[0]] = $data1[$newkey];
359
-			if($newvalue == "ACCID" ){
359
+			if ($newvalue == "ACCID") {
360 360
 				$newarray1[$data1[1]] = $newarray;
361 361
 			}
362 362
 		}
@@ -365,13 +365,13 @@  discard block
 block discarded – undo
365 365
 }
366 366
 
367 367
 // Calculate cost for billing 
368
-function calc_cost($dataVariable, $rates, $logger,$decimal_points)
368
+function calc_cost($dataVariable, $rates, $logger, $decimal_points)
369 369
 {
370 370
 	//$logger->log(print_r($rates,true));
371 371
 	$duration = $dataVariable['billsec'];
372
-	$call_cost=0;  
372
+	$call_cost = 0;  
373 373
 	$duration -= $rates['INCLUDEDSECONDS'];
374
-	if ($duration > 0 && ($dataVariable['hangup_cause'] == 'NORMAL_CLEARING' || $dataVariable['hangup_cause']  == 'ALLOTTED_TIMEOUT')) {
374
+	if ($duration > 0 && ($dataVariable['hangup_cause'] == 'NORMAL_CLEARING' || $dataVariable['hangup_cause'] == 'ALLOTTED_TIMEOUT')) {
375 375
 
376 376
     		$rates['INC'] = ($rates['INC'] == 0) ? 1 : $rates['INC'];
377 377
             $call_cost = $rates['CONNECTIONCOST'];
@@ -380,46 +380,46 @@  discard block
 block discarded – undo
380 380
     
381 381
             if ($billseconds > 0)
382 382
             {
383
-                $call_cost += (ceil($billseconds/$rates['INC'])*$rates['INC'])*($rates['COST']/60);
383
+                $call_cost += (ceil($billseconds / $rates['INC']) * $rates['INC']) * ($rates['COST'] / 60);
384 384
             }
385 385
     }
386
-    $call_cost = number_format($call_cost,$decimal_points);
386
+    $call_cost = number_format($call_cost, $decimal_points);
387 387
     $logger->log("Return cost ".$call_cost);
388 388
     return $call_cost;
389 389
 }
390 390
 
391 391
 // get intial package information
392
-function package_calculation($destination_number,$pricelist_id,$duration,$call_direction,$accountid,$db,$logger)
392
+function package_calculation($destination_number, $pricelist_id, $duration, $call_direction, $accountid, $db, $logger)
393 393
 {
394 394
 	$package_array = array();
395
-	$custom_destination = number_loop($destination_number,"patterns",$db);
395
+	$custom_destination = number_loop($destination_number, "patterns", $db);
396 396
 
397 397
 	$query = "SELECT * FROM packages  as P inner join package_patterns as PKGPTR on P.id = PKGPTR.package_id WHERE ".$custom_destination." AND status = 0 AND pricelist_id = ".$pricelist_id." ORDER BY LENGTH(PKGPTR.patterns) DESC LIMIT 1";
398 398
 
399 399
 	$package_info = $db->run($query);
400
-	if($package_info){
400
+	if ($package_info) {
401 401
 		$package_info = $package_info[0];
402 402
 
403
-		if( ($package_info['applicable_for'] == "0" && $call_direction == "outbound") || ($package_info['applicable_for'] == "1" && $call_direction == "inbound") || ($package_info['applicable_for'] == "2") ) {
403
+		if (($package_info['applicable_for'] == "0" && $call_direction == "outbound") || ($package_info['applicable_for'] == "1" && $call_direction == "inbound") || ($package_info['applicable_for'] == "2")) {
404 404
 	
405
-			$counter_info =  get_counters($accountid,$package_info['package_id'],$db,$logger);
405
+			$counter_info = get_counters($accountid, $package_info['package_id'], $db, $logger);
406 406
 
407
-			if(!$counter_info) {
407
+			if ( ! $counter_info) {
408 408
 				$Insert_Query = "INSERT INTO counters (package_id,accountid) VALUES (".$package_info['package_id'].",".$accountid.")";		
409
-				$logger->log("Insert Counters  : " . $Insert_query);
409
+				$logger->log("Insert Counters  : ".$Insert_query);
410 410
 				$db->run($Insert_Query);
411
-				$counter_info =  get_counters($accountid,$package_info['package_id'],$db,$logger);
411
+				$counter_info = get_counters($accountid, $package_info['package_id'], $db, $logger);
412 412
 				
413 413
 			}	
414 414
 			//print_r($counter_info);
415
-			if ( $package_info['includedseconds'] > ($counter_info['seconds'] )) {
415
+			if ($package_info['includedseconds'] > ($counter_info['seconds'])) {
416 416
 				$availableseconds = $package_info['includedseconds'] - $counter_info['seconds'];
417 417
 				$freeseconds = ($availableseconds >= $duration) ? $duration : $availableseconds;
418 418
 				$duration = ($availableseconds >= $duration) ? $duration : $availableseconds;
419
-				$update_query = "UPDATE counters SET seconds = ".($counter_info['seconds'] + $freeseconds ). " WHERE id = ". $counter_info['id'];
420
-				$logger->log("Update Counters  : " . $update_query);
419
+				$update_query = "UPDATE counters SET seconds = ".($counter_info['seconds'] + $freeseconds)." WHERE id = ".$counter_info['id'];
420
+				$logger->log("Update Counters  : ".$update_query);
421 421
 				$db->run($update_query);
422
-				$package_array['package_id']= $package_info['package_id'];
422
+				$package_array['package_id'] = $package_info['package_id'];
423 423
 				$package_array['calltype'] = "FREE";
424 424
 			}						
425 425
 		} 
@@ -428,21 +428,21 @@  discard block
 block discarded – undo
428 428
 } 
429 429
 
430 430
 // Getting used package minutes in counter table
431
-function get_counters($accountid,$package_id,$db,$logger)
431
+function get_counters($accountid, $package_id, $db, $logger)
432 432
 {
433 433
 	$query_counter = "SELECT id,seconds FROM counters  WHERE  accountid = ".$accountid." AND package_id = ".$package_id." AND status=1 LIMIT 1";
434 434
 	$counter = $db->run($query_counter);
435
-	$logger->log("GET Counters  : " . $query_counter);
436
-	if($counter)
435
+	$logger->log("GET Counters  : ".$query_counter);
436
+	if ($counter)
437 437
 	    return $counter[0];	
438 438
 	else
439 439
 	    return "";
440 440
 }
441 441
 
442 442
 //Get user info
443
-function get_accounts($parent_id,$logger, $db) {
444
-	$query = "SELECT * FROM accounts WHERE id=" . $parent_id;
445
-	$logger->log("GET configuration  : " . $query);
443
+function get_accounts($parent_id, $logger, $db) {
444
+	$query = "SELECT * FROM accounts WHERE id=".$parent_id;
445
+	$logger->log("GET configuration  : ".$query);
446 446
 	$res_user = $db->run($query);
447 447
 	return $res_user[0];
448 448
 }
@@ -452,27 +452,27 @@  discard block
 block discarded – undo
452 452
 {
453 453
 	$query = "SELECT name,value FROM system WHERE name='decimal_points' and group_title = 'global'";
454 454
 	$config = $db->run($query);
455
-	$logger->log("GET configuration  : " . $query);
455
+	$logger->log("GET configuration  : ".$query);
456 456
 	return $config[0];
457 457
 }
458 458
 
459 459
 // String append prefix for checking rates
460
-function number_loop($destination,$field,$db)
460
+function number_loop($destination, $field, $db)
461 461
 {
462
-	$max_len_prefix  = strlen($destination);
462
+	$max_len_prefix = strlen($destination);
463 463
 	$number_prefix = '(';
464
-	while ($max_len_prefix  > 0)
464
+	while ($max_len_prefix > 0)
465 465
 	{
466
-		$number_prefix .= "$field='^".substr($destination,0,$max_len_prefix).".*' OR ";
466
+		$number_prefix .= "$field='^".substr($destination, 0, $max_len_prefix).".*' OR ";
467 467
 		$max_len_prefix--;
468 468
 	}
469
-	$number_prefix .= "$field='^defaultprefix.*')";//echo $number_prefix;exit;
469
+	$number_prefix .= "$field='^defaultprefix.*')"; //echo $number_prefix;exit;
470 470
 	return $number_prefix;
471 471
 }
472 472
 
473 473
 //Convert current time to GMT
474 474
 function convert_to_gmt($date)
475 475
 {
476
-	return gmdate('Y-m-d H:i:s', strtotime($date) );
476
+	return gmdate('Y-m-d H:i:s', strtotime($date));
477 477
 }
478 478
 ?>
Please login to merge, or discard this patch.
freeswitch/fs/lib/astpp.db.php 2 patches
Doc Comments   +3 added lines patch added patch discarded remove patch
@@ -47,6 +47,9 @@
 block discarded – undo
47 47
         echo $this->error;
48 48
     }
49 49
 
50
+    /**
51
+     * @param string $bind
52
+     */
50 53
     public function cleanup($bind) {
51 54
         if (!is_array($bind)) {
52 55
             if (!empty($bind))
Please login to merge, or discard this patch.
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -48,8 +48,8 @@  discard block
 block discarded – undo
48 48
     }
49 49
 
50 50
     public function cleanup($bind) {
51
-        if (!is_array($bind)) {
52
-            if (!empty($bind))
51
+        if ( ! is_array($bind)) {
52
+            if ( ! empty($bind))
53 53
                 $bind = array($bind);
54 54
             else
55 55
                 $bind = array();
@@ -65,9 +65,9 @@  discard block
 block discarded – undo
65 65
         try {
66 66
             $pdostmt = $this->prepare($this->sql);
67 67
             if ($pdostmt->execute($this->bind) !== false) {
68
-                if (preg_match("/^(" . implode("|", array("select", "describe", "pragma")) . ") /i", $this->sql))
68
+                if (preg_match("/^(".implode("|", array("select", "describe", "pragma")).") /i", $this->sql))
69 69
                     return $pdostmt->fetchAll(PDO::FETCH_ASSOC);
70
-                elseif (preg_match("/^(" . implode("|", array("delete", "insert", "update")) . ") /i", $this->sql))
70
+                elseif (preg_match("/^(".implode("|", array("delete", "insert", "update")).") /i", $this->sql))
71 71
                     return $pdostmt->rowCount();
72 72
             }
73 73
         } catch (PDOException $e) {
Please login to merge, or discard this patch.
freeswitch/fs/lib/astpp.functions.php 2 patches
Doc Comments   +3 added lines patch added patch discarded remove patch
@@ -118,6 +118,9 @@
 block discarded – undo
118 118
 }
119 119
 
120 120
 //Update user balance
121
+/**
122
+ * @param integer $entity_id
123
+ */
121 124
 function update_balance($user_id, $amount, $entity_id, $logger, $db) {
122 125
     if ($amount > 0) {
123 126
         $math_sign = ($entity_id == 0 || $entity_id == 1) ? '-' : '+';
Please login to merge, or discard this patch.
Spacing   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -54,25 +54,25 @@  discard block
 block discarded – undo
54 54
         $number_len = strlen($destination_number);
55 55
         $number_loop_str = '(';
56 56
         while ($number_len > 0) {
57
-            $number_loop_str .= " code='" . substr($destination_number, 0, $number_len) . "' OR ";
57
+            $number_loop_str .= " code='".substr($destination_number, 0, $number_len)."' OR ";
58 58
             $number_len -= 1;
59 59
         }
60 60
         $number_loop_str .= " code='--')";
61 61
 
62
-        $query = "SELECT A.id as package_id,code,includedseconds FROM tbl_package AS A ,tbl_package_codes AS B WHERE " . $number_loop_str . " AND B.package_id = A.id AND A.ratecard_id=" . $rates_array['ratecard_id'] . " AND A.status=0 AND A.is_del=0 ORDER BY length(code) DESC";
63
-        $logger->log("Package Query : " . $query);
62
+        $query = "SELECT A.id as package_id,code,includedseconds FROM tbl_package AS A ,tbl_package_codes AS B WHERE ".$number_loop_str." AND B.package_id = A.id AND A.ratecard_id=".$rates_array['ratecard_id']." AND A.status=0 AND A.is_del=0 ORDER BY length(code) DESC";
63
+        $logger->log("Package Query : ".$query);
64 64
         $res_package = $db->run($query);
65 65
 
66 66
         foreach ($res_package as $res_package_key => $package_info) {
67 67
             if (isset($package_info['package_id'])) {
68
-                $query = "SELECT SUM(used_seconds) as used_seconds FROM tbl_package_usage WHERE code=" . $package_info['code'] . " AND package_id=" . $package_info['package_id'] . " AND user_id=" . $user_id;
69
-                $logger->log("Package usage Query : " . $query);
68
+                $query = "SELECT SUM(used_seconds) as used_seconds FROM tbl_package_usage WHERE code=".$package_info['code']." AND package_id=".$package_info['package_id']." AND user_id=".$user_id;
69
+                $logger->log("Package usage Query : ".$query);
70 70
                 $res_pkg_usg = $db->run($query);
71 71
                 $package_usage_info = $res_pkg_usg[0];
72 72
 
73 73
                 $used_seconds = (isset($package_usage_info['used_seconds'])) ? $package_usage_info['used_seconds'] : 0;
74 74
 
75
-                $logger->log("Included seconds : " . $package_info['includedseconds'] . ", Used seconds : " . $used_seconds);
75
+                $logger->log("Included seconds : ".$package_info['includedseconds'].", Used seconds : ".$used_seconds);
76 76
                 if ($package_info['includedseconds'] > $used_seconds) {
77 77
                     $remaining_seconds = $package_info['includedseconds'] - ($duration + $used_seconds);
78 78
                     if ($remaining_seconds > 0) {
@@ -85,8 +85,8 @@  discard block
 block discarded – undo
85 85
                     $flag = true;
86 86
                     $xml_cdr->variables->package_id = $package_info['package_id'];
87 87
 
88
-                    $query = "INSERT INTO tbl_package_usage (package_id,user_id,code,used_seconds) VALUES (" . $package_info['package_id'] . "," . $user_id . ",'" . $package_info['code'] . "'," . $dud_sec . ") ON DUPLICATE KEY UPDATE used_seconds=used_seconds+" . $dud_sec;
89
-                    $logger->log("Package Usage Query : " . $query);
88
+                    $query = "INSERT INTO tbl_package_usage (package_id,user_id,code,used_seconds) VALUES (".$package_info['package_id'].",".$user_id.",'".$package_info['code']."',".$dud_sec.") ON DUPLICATE KEY UPDATE used_seconds=used_seconds+".$dud_sec;
89
+                    $logger->log("Package Usage Query : ".$query);
90 90
                     $db->run($query);
91 91
 
92 92
                     break;
@@ -99,21 +99,21 @@  discard block
 block discarded – undo
99 99
 
100 100
 //Process user/vendor cdr
101 101
 function do_cdr_process($xml_cdr, $debit, $cost, $vendor_cost, $rates_array, $parent_id = 0, $parent_rates, $carrier_rates_array, $logger, $db) {
102
-    $query_string = "'" . $xml_cdr->variables->uuid . "','" . $xml_cdr->variables->user_id . "','" . $xml_cdr->variables->entity_id . "','" . urldecode($xml_cdr->variables->effective_caller_id_name) . "','" . $xml_cdr->variables->effective_caller_id_number . "','" . $xml_cdr->variables->effective_destination_number . "'," . $xml_cdr->variables->duration . ",'" . $xml_cdr->variables->carrier_id . "','" . $xml_cdr->callflow[0]->caller_profile->originatee->originatee_caller_profile->network_addr . "','" . $xml_cdr->variables->sip_contact_host . "','" . $xml_cdr->variables->hangup_cause . "','" . urldecode($xml_cdr->variables->start_stamp) . "'," . $debit . "," . $cost . ",'" . $xml_cdr->variables->vendor_id . "'," . $vendor_cost . "," . $rates_array['ratecard_id'] . "," . $xml_cdr->variables->package_id . ",'" . $rates_array['code'] . "','" . $rates_array['destination'] . "','" . $rates_array['cost'] . "','" . $parent_id . "','" . @$parent_rates['code'] . "','" . @$parent_rates['destination'] . "','" . @$parent_rates['cost'] . "','" . @$carrier_rates_array['code'] . "','" . @$carrier_rates_array['destination'] . "','" . @$carrier_rates_array['cost'] . "','" . $xml_cdr->variables->call_direction . "','" . urldecode($xml_cdr->variables->profile_start_stamp) . "','" . urldecode($xml_cdr->variables->answer_stamp) . "','" . urldecode($xml_cdr->variables->bridge_stamp) . "','" . urldecode($xml_cdr->variables->progress_stamp) . "','" . urldecode($xml_cdr->variables->progress_media_stamp) . "','" . urldecode($xml_cdr->variables->end_stamp) . "'," . $xml_cdr->variables->billmsec . "," . $xml_cdr->variables->answermsec . "," . $xml_cdr->variables->waitmsec . "," . $xml_cdr->variables->progress_mediamsec . "," . $xml_cdr->variables->flow_billmsec;
102
+    $query_string = "'".$xml_cdr->variables->uuid."','".$xml_cdr->variables->user_id."','".$xml_cdr->variables->entity_id."','".urldecode($xml_cdr->variables->effective_caller_id_name)."','".$xml_cdr->variables->effective_caller_id_number."','".$xml_cdr->variables->effective_destination_number."',".$xml_cdr->variables->duration.",'".$xml_cdr->variables->carrier_id."','".$xml_cdr->callflow[0]->caller_profile->originatee->originatee_caller_profile->network_addr."','".$xml_cdr->variables->sip_contact_host."','".$xml_cdr->variables->hangup_cause."','".urldecode($xml_cdr->variables->start_stamp)."',".$debit.",".$cost.",'".$xml_cdr->variables->vendor_id."',".$vendor_cost.",".$rates_array['ratecard_id'].",".$xml_cdr->variables->package_id.",'".$rates_array['code']."','".$rates_array['destination']."','".$rates_array['cost']."','".$parent_id."','".@$parent_rates['code']."','".@$parent_rates['destination']."','".@$parent_rates['cost']."','".@$carrier_rates_array['code']."','".@$carrier_rates_array['destination']."','".@$carrier_rates_array['cost']."','".$xml_cdr->variables->call_direction."','".urldecode($xml_cdr->variables->profile_start_stamp)."','".urldecode($xml_cdr->variables->answer_stamp)."','".urldecode($xml_cdr->variables->bridge_stamp)."','".urldecode($xml_cdr->variables->progress_stamp)."','".urldecode($xml_cdr->variables->progress_media_stamp)."','".urldecode($xml_cdr->variables->end_stamp)."',".$xml_cdr->variables->billmsec.",".$xml_cdr->variables->answermsec.",".$xml_cdr->variables->waitmsec.",".$xml_cdr->variables->progress_mediamsec.",".$xml_cdr->variables->flow_billmsec;
103 103
 
104 104
     $query = "INSERT INTO tbl_cdrs (uniqueid,user_id,entity_id,callerid_name,callerid_number,dstnum,duration,carrier_id,carrierip,callerip,disposition,start_stamp,debit,cost,vendor_id,vendor_cost,ratecard_id,package_id,rate_code,rate_code_destination,rate_cost,parent_id,parent_code,parent_code_destination,parent_cost,carrier_code,carrier_code_destination ,carrier_cost,call_direction,profile_start_stamp,answer_stamp,bridge_stamp,progress_stamp,progress_media_stamp,end_stamp,billmsec,answermsec,waitmsec,progress_mediamsec,flow_billmsec) values ($query_string)";
105 105
 
106
-    $logger->log("CDR Query : " . $query);
106
+    $logger->log("CDR Query : ".$query);
107 107
     $db->run($query);
108 108
 }
109 109
 
110 110
 //Process reseller cdr
111 111
 function do_reseller_cdr_process($xml_cdr, $debit, $cost, $rates_array, $parent_id = 0, $parent_rates, $logger, $db) {
112
-    $query_string = "'" . $xml_cdr->variables->uuid . "','" . $xml_cdr->variables->user_id . "','" . urldecode($xml_cdr->variables->effective_caller_id_name) . "','" . $xml_cdr->variables->effective_caller_id_number . "','" . $xml_cdr->variables->effective_destination_number . "'," . $xml_cdr->variables->duration . ",'" . $xml_cdr->variables->hangup_cause . "','" . urldecode($xml_cdr->variables->start_stamp) . "'," . $debit . "," . $cost . "," . $rates_array['ratecard_id'] . "," . $xml_cdr->variables->package_id . ",'" . $rates_array['code'] . "','" . $rates_array['destination'] . "','" . $rates_array['cost'] . "','" . $parent_id . "','" . @$parent_rates['code'] . "','" . @$parent_rates['destination'] . "','" . @$parent_rates['cost'] . "','" . $xml_cdr->variables->call_direction . "'";
112
+    $query_string = "'".$xml_cdr->variables->uuid."','".$xml_cdr->variables->user_id."','".urldecode($xml_cdr->variables->effective_caller_id_name)."','".$xml_cdr->variables->effective_caller_id_number."','".$xml_cdr->variables->effective_destination_number."',".$xml_cdr->variables->duration.",'".$xml_cdr->variables->hangup_cause."','".urldecode($xml_cdr->variables->start_stamp)."',".$debit.",".$cost.",".$rates_array['ratecard_id'].",".$xml_cdr->variables->package_id.",'".$rates_array['code']."','".$rates_array['destination']."','".$rates_array['cost']."','".$parent_id."','".@$parent_rates['code']."','".@$parent_rates['destination']."','".@$parent_rates['cost']."','".$xml_cdr->variables->call_direction."'";
113 113
 
114 114
     $query = "INSERT INTO tbl_cdrs_reseller (uniqueid,reseller_id,callerid_name,callerid_number,dstnum,duration,disposition,start_stamp,debit,cost,ratecard_id,package_id,rate_code,rate_code_destination,rate_cost,parent_id,parent_code,parent_code_destination,parent_cost,call_direction) values ($query_string)";
115 115
 
116
-    $logger->log("CDR Query : " . $query);
116
+    $logger->log("CDR Query : ".$query);
117 117
     $db->run($query);
118 118
 }
119 119
 
@@ -121,15 +121,15 @@  discard block
 block discarded – undo
121 121
 function update_balance($user_id, $amount, $entity_id, $logger, $db) {
122 122
     if ($amount > 0) {
123 123
         $math_sign = ($entity_id == 0 || $entity_id == 1) ? '-' : '+';
124
-        $query = "UPDATE tbl_users SET credit=credit$math_sign" . $amount . " WHERE id=" . $user_id;
125
-        $logger->log("Balance update : " . $query);
124
+        $query = "UPDATE tbl_users SET credit=credit$math_sign".$amount." WHERE id=".$user_id;
125
+        $logger->log("Balance update : ".$query);
126 126
         $db->run($query);
127 127
     }
128 128
 }
129 129
 
130 130
 //Get user info
131 131
 function get_user_info($parent_id, $db) {
132
-    $query = "SELECT * FROM tbl_users WHERE id=" . $parent_id;
132
+    $query = "SELECT * FROM tbl_users WHERE id=".$parent_id;
133 133
     $res_user = $db->run($query);
134 134
     return $res_user[0];
135 135
 }
Please login to merge, or discard this patch.
web_interface/astpp/application/controllers/currencyupdate.php 2 patches
Doc Comments   +4 added lines patch added patch discarded remove patch
@@ -64,6 +64,10 @@
 block discarded – undo
64 64
 	      redirect(base_url()."/systems/currency_list/");
65 65
 	      exit;
66 66
 	}
67
+
68
+	/**
69
+	 * @param string $url
70
+	 */
67 71
 	function curl_response($url)
68 72
 	{
69 73
 		    $ch = curl_init();  // Initialising cURL
Please login to merge, or discard this patch.
Spacing   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -29,30 +29,30 @@  discard block
 block discarded – undo
29 29
         $this->load->model("db_model");
30 30
         $this->load->library("astpp/common");
31 31
     }
32
-    function update_currency(){
32
+    function update_currency() {
33 33
         $where = array("currency <>"=> Common_model::$global_config['system_config']['base_currency']);
34 34
         $query = $this->db_model->getSelect("*", "currency", $where);
35 35
 
36
-        if($query->num_rows >0){
37
-            $currency_data =$query->result_array();
36
+        if ($query->num_rows > 0) {
37
+            $currency_data = $query->result_array();
38 38
     		$url = "http://finance.yahoo.com/d/quotes.csv?e=.csv&f=sl1d1t1&s=";
39 39
 	    	foreach ($currency_data as $currency_value) {
40 40
 	    	    $url .= Common_model::$global_config['system_config']['base_currency'].$currency_value['currency'].'=X+';
41 41
 	    	}
42 42
 	    	$url .= '&f=l1';
43 43
 
44
-	    	$sql='';
44
+	    	$sql = '';
45 45
 	    	$response = $this->curl_response($url);
46
-	    	$content_data = explode(' ',$response);
46
+	    	$content_data = explode(' ', $response);
47 47
 
48
-	    	foreach ($content_data as $content_data1){
49
-	    	   $currency_arr= explode("\n", $content_data1);
50
-	    	    foreach($currency_arr as $final_val)
48
+	    	foreach ($content_data as $content_data1) {
49
+	    	   $currency_arr = explode("\n", $content_data1);
50
+	    	    foreach ($currency_arr as $final_val)
51 51
 	    	    {
52 52
 	    	        $currency_final = array();
53
-	    		    $currency_final= explode(',', $final_val);
54
-	    		    if(isset($currency_final[1]) && $currency_final[1] != "" && $currency_final[0]!='' && $currency_final[1] != 'N/A'){
55
-			      $sql = "UPDATE currency SET currencyRate = ".$currency_final[1]." WHERE currency = '".substr($currency_final[0],4,3)."'";
53
+	    		    $currency_final = explode(',', $final_val);
54
+	    		    if (isset($currency_final[1]) && $currency_final[1] != "" && $currency_final[0] != '' && $currency_final[1] != 'N/A') {
55
+			      $sql = "UPDATE currency SET currencyRate = ".$currency_final[1]." WHERE currency = '".substr($currency_final[0], 4, 3)."'";
56 56
 			      $this->db->query($sql);
57 57
 	    		    }
58 58
 	    	    }
@@ -66,14 +66,14 @@  discard block
 block discarded – undo
66 66
 	}
67 67
 	function curl_response($url)
68 68
 	{
69
-		    $ch = curl_init();  // Initialising cURL
70
-		    curl_setopt ( $ch, CURLOPT_URL, $url );
71
-		    curl_setopt ( $ch, CURLOPT_FOLLOWLOCATION, 1 );
72
-		    curl_setopt ( $ch, CURLOPT_RETURNTRANSFER, 1 );
73
-		    curl_setopt ( $ch, CURLOPT_ENCODING, "" );
74
-		    curl_setopt ( $ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv:1.9.2) Gecko/20100115 Firefox/3.6 (.NET CLR 3.5.30729)" );
69
+		    $ch = curl_init(); // Initialising cURL
70
+		    curl_setopt($ch, CURLOPT_URL, $url);
71
+		    curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
72
+		    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
73
+		    curl_setopt($ch, CURLOPT_ENCODING, "");
74
+		    curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv:1.9.2) Gecko/20100115 Firefox/3.6 (.NET CLR 3.5.30729)");
75 75
 		    $data = curl_exec($ch); // Executing the cURL request and assigning the returned data to the $data variable
76
-		    curl_close($ch);        // Closing cURL
76
+		    curl_close($ch); // Closing cURL
77 77
 		    return $data;
78 78
 	}
79 79
 }
Please login to merge, or discard this patch.
web_interface/astpp/application/controllers/generateInvoice.php 2 patches
Doc Comments   +15 added lines patch added patch discarded remove patch
@@ -89,6 +89,10 @@  discard block
 block discarded – undo
89 89
         return $last_invoice_date;
90 90
     }
91 91
 
92
+    /**
93
+     * @param string $start_date
94
+     * @param string $end_date
95
+     */
92 96
     function Generate_Daily_invoice($account_value, $start_date, $end_date) {
93 97
         //  echo "INVOICE SCRIPT-------start date :".$start_date."-------end date....".$end_date;
94 98
 
@@ -99,6 +103,10 @@  discard block
 block discarded – undo
99 103
         $this->process_invoice($account_value, $start_date, $end_date);
100 104
     }
101 105
 
106
+    /**
107
+     * @param string $start_date
108
+     * @param string $end_date
109
+     */
102 110
     function Generate_Monthly_invoice($account_value, $start_date, $end_date) {
103 111
         require_once('updateBalance.php');
104 112
         $updateBalance = new updateBalance();
@@ -181,6 +189,9 @@  discard block
 block discarded – undo
181 189
         return true;
182 190
     }
183 191
 
192
+    /**
193
+     * @param string $last_invoice_ID
194
+     */
184 195
     function create_invoice($account, $from_date, $to_date, $last_invoice_ID, $INVprefix, $invoiceconf) {
185 196
         //$due_date = gmdate("Y-m-d H:i:s",strtotime($to_date." +".$invoiceconf['interval']." days"));
186 197
         if ($invoiceconf['interval'] > 0) {
@@ -234,6 +245,10 @@  discard block
 block discarded – undo
234 245
         }
235 246
     }
236 247
 
248
+    /**
249
+     * @param string $FilePath
250
+     * @param string $Filenm
251
+     */
237 252
     function send_email_notification($FilePath, $Filenm, $AccountData, $invoice_conf, $invData) {
238 253
         $TemplateData = array();
239 254
         $where = array('name' => 'email_new_invoice');
Please login to merge, or discard this patch.
Spacing   +32 added lines, -32 removed lines patch added patch discarded remove patch
@@ -52,15 +52,15 @@  discard block
 block discarded – undo
52 52
         if ($query->num_rows > 0) {
53 53
             $account_data = $query->result_array();
54 54
             foreach ($account_data as $data_key => $account_value) {
55
-                $end_date = gmdate("Y-m-d") . " 23:59:59";
56
-                $account_value['sweep_id'] = (int) $account_value['sweep_id'];
55
+                $end_date = gmdate("Y-m-d")." 23:59:59";
56
+                $account_value['sweep_id'] = (int)$account_value['sweep_id'];
57 57
                 switch ($account_value['sweep_id']) {
58 58
                     case 0:
59 59
                         $start_date = $this->validate_invoice_date($account_value);
60 60
                         if (strtotime($start_date) >= strtotime(gmdate("Y-m-d H:i:s"))) {
61 61
                             $start_date = gmdate("Y-m-d H:i:s");
62 62
                         }
63
-                        $end_date = gmdate("Y-m-d 23:59:59", strtotime($start_date . " + 1 days"));
63
+                        $end_date = gmdate("Y-m-d 23:59:59", strtotime($start_date." + 1 days"));
64 64
                         $this->Generate_Daily_invoice($account_value, $start_date, $end_date);
65 65
                         break;
66 66
                     case 2:
@@ -69,23 +69,23 @@  discard block
 block discarded – undo
69 69
                             if (strtotime($start_date) >= strtotime(gmdate("Y-m-d H:i:s"))) {
70 70
                                 $start_date = gmdate("Y-m-d H:i:s");
71 71
                             }
72
-                            $end_date = gmdate("Y-m-d 23:59:59", strtotime($start_date . " + 1 month"));
72
+                            $end_date = gmdate("Y-m-d 23:59:59", strtotime($start_date." + 1 month"));
73 73
                             $this->Generate_Monthly_invoice($account_value, $start_date, $end_date);
74 74
                         }
75 75
                         break;
76 76
                 }
77 77
             }
78
-            $screen_path = getcwd() . "/cron";
79
-            $screen_filename = "Email_Broadcast_" . strtotime('now');
80
-            $command = "cd " . $screen_path . " && /usr/bin/screen -d -m -S  $screen_filename php cron.php BroadcastEmail";
78
+            $screen_path = getcwd()."/cron";
79
+            $screen_filename = "Email_Broadcast_".strtotime('now');
80
+            $command = "cd ".$screen_path." && /usr/bin/screen -d -m -S  $screen_filename php cron.php BroadcastEmail";
81 81
             exec($command);
82 82
         }
83 83
     }
84 84
 
85 85
     function validate_invoice_date($account_value) {
86
-        $last_invoice_date = $this->common->get_invoice_date("to_date", $account_value["id"],$account_value['reseller_id'],"to_date");
86
+        $last_invoice_date = $this->common->get_invoice_date("to_date", $account_value["id"], $account_value['reseller_id'], "to_date");
87 87
         $last_invoice_date = ($last_invoice_date) ? $last_invoice_date : $account_value['creation'];
88
-        $last_invoice_date = gmdate("Y-m-d H:i:s",strtotime("+1 Second",strtotime($last_invoice_date)));
88
+        $last_invoice_date = gmdate("Y-m-d H:i:s", strtotime("+1 Second", strtotime($last_invoice_date)));
89 89
         return $last_invoice_date;
90 90
     }
91 91
 
@@ -111,7 +111,7 @@  discard block
 block discarded – undo
111 111
         //Get Invoice configuration using single query instead of multiple queries.
112 112
         $invoice_conf = array();
113 113
         $reseller_id = ($accountdata['reseller_id'] == 0) ? 1 : $accountdata['reseller_id'];
114
-        $where = "accountid IN ('" . $reseller_id . "','1')";
114
+        $where = "accountid IN ('".$reseller_id."','1')";
115 115
         $this->db->select('*');
116 116
         $this->db->where($where);
117 117
         $this->db->order_by('accountid', 'desc');
@@ -119,7 +119,7 @@  discard block
 block discarded – undo
119 119
         $invoice_conf = $this->db->get('invoice_conf');
120 120
         $invoice_conf = (array)$invoice_conf->first_row();
121 121
         /*******************************************************/
122
-        $last_invoice_ID = $this->common->get_invoice_date("invoiceid","", $accountdata['reseller_id']);
122
+        $last_invoice_ID = $this->common->get_invoice_date("invoiceid", "", $accountdata['reseller_id']);
123 123
         if ($last_invoice_ID && $last_invoice_ID > 0) {
124 124
             $last_invoice_ID = ($last_invoice_ID + 1);
125 125
         } else {
@@ -143,8 +143,8 @@  discard block
 block discarded – undo
143 143
     function count_invoice_data($account, $start_date = "", $end_date = "") {
144 144
         $cdr_query = "";
145 145
         $inv_data_query = "";
146
-        $cdr_query = "select calltype,sum(debit) as debit from cdrs where accountid = " . $account['id'];
147
-        $cdr_query .= " AND callstart >='" . $start_date . "' AND callstart <= '" . $end_date . "' AND invoiceid=0 group by calltype";
146
+        $cdr_query = "select calltype,sum(debit) as debit from cdrs where accountid = ".$account['id'];
147
+        $cdr_query .= " AND callstart >='".$start_date."' AND callstart <= '".$end_date."' AND invoiceid=0 group by calltype";
148 148
 //echo $cdr_query; 
149 149
         $cdr_data = $this->db->query($cdr_query);
150 150
         if ($cdr_data->num_rows > 0) {
@@ -153,11 +153,11 @@  discard block
 block discarded – undo
153 153
             foreach ($cdr_data as $cdrvalue) {
154 154
                 $cdrvalue['debit'] = round($cdrvalue['debit'], self::$global_config['system_config']['decimalpoints']);
155 155
                 $tempArr = array("accountid" => $account['id'], "reseller_id" => $account['reseller_id'], "item_id" => "0",
156
-                    "description" => $cdrvalue['calltype'] . " CALLS for the period (" . $start_date . " to " . $end_date, "debit" => $cdrvalue['debit'], "item_type" => $cdrvalue['calltype'], "created_date" => $end_date);
156
+                    "description" => $cdrvalue['calltype']." CALLS for the period (".$start_date." to ".$end_date, "debit" => $cdrvalue['debit'], "item_type" => $cdrvalue['calltype'], "created_date" => $end_date);
157 157
                 $this->db->insert("invoice_details", $tempArr);
158 158
             }
159 159
         }
160
-        $inv_data_query = "select count(id) as count,sum(debit) as debit,sum(credit) as credit from invoice_details where accountid=" . $account['id'] . " AND created_date >='" . $start_date . "' AND created_date <= '" . $end_date . "'  AND invoiceid=0 AND item_type != 'FREECALL'";
160
+        $inv_data_query = "select count(id) as count,sum(debit) as debit,sum(credit) as credit from invoice_details where accountid=".$account['id']." AND created_date >='".$start_date."' AND created_date <= '".$end_date."'  AND invoiceid=0 AND item_type != 'FREECALL'";
161 161
 //echo $inv_data_query;         
162 162
         $invoice_data = $this->db->query($inv_data_query);
163 163
         if ($invoice_data->num_rows > 0) {
@@ -175,8 +175,8 @@  discard block
 block discarded – undo
175 175
 
176 176
     //Change Order of arguements
177 177
     function update_cdrs_data($accountid, $invoiceid, $start_date = "", $end_date = "") {
178
-        $inv_data_query = "update invoice_details SET invoiceid = '" . $invoiceid . "' where accountid=" . $accountid;
179
-        $inv_data_query .= " AND created_date >='" . $start_date . "' AND created_date <= '" . $end_date . "'  AND invoiceid=0 AND item_type !='PAYMENT'";
178
+        $inv_data_query = "update invoice_details SET invoiceid = '".$invoiceid."' where accountid=".$accountid;
179
+        $inv_data_query .= " AND created_date >='".$start_date."' AND created_date <= '".$end_date."'  AND invoiceid=0 AND item_type !='PAYMENT'";
180 180
         $this->db->query($inv_data_query);
181 181
         return true;
182 182
     }
@@ -184,24 +184,24 @@  discard block
 block discarded – undo
184 184
     function create_invoice($account, $from_date, $to_date, $last_invoice_ID, $INVprefix, $invoiceconf) {
185 185
         //$due_date = gmdate("Y-m-d H:i:s",strtotime($to_date." +".$invoiceconf['interval']." days"));
186 186
         if ($invoiceconf['interval'] > 0) {
187
-            $due_date = gmdate("Y-m-d H:i:s", strtotime(gmdate("Y-m-d H:i:s") . " +" . $invoiceconf['interval'] . " days"));
187
+            $due_date = gmdate("Y-m-d H:i:s", strtotime(gmdate("Y-m-d H:i:s")." +".$invoiceconf['interval']." days"));
188 188
         } else {
189
-            $due_date = gmdate("Y-m-d H:i:s", strtotime(gmdate("Y-m-d H:i:s") . " +7 days"));
189
+            $due_date = gmdate("Y-m-d H:i:s", strtotime(gmdate("Y-m-d H:i:s")." +7 days"));
190 190
         }
191 191
         // echo "due daye-------".$due_date.'----------'.$to_date.'------------> Invoice interval'.$invoiceconf['interval']; 
192 192
         $balance = ($account['credit_limit'] - $account['balance']);
193 193
         $automatic_flag = self::$global_config['system_config']['automatic_invoice'];
194
-	if($automatic_flag == 1){
194
+	if ($automatic_flag == 1) {
195 195
 	        $invoice_data = array("accountid" => $account['id'], "invoice_prefix" => $INVprefix, "invoiceid" => $last_invoice_ID, "reseller_id" =>
196 196
             $account['reseller_id'], "invoice_date" => gmdate("Y-m-d H:i:s"), "from_date" => $from_date, "to_date" => $to_date, "due_date" => $due_date, "status" => 1, "amount" => "0.00", "balance" => $balance);
197
-	}else{
197
+	} else {
198 198
 	        $invoice_data = array("accountid" => $account['id'], "invoice_prefix" => $INVprefix, "invoiceid" => $last_invoice_ID, "reseller_id" =>
199 199
             $account['reseller_id'], "invoice_date" => gmdate("Y-m-d H:i:s"), "from_date" => $from_date, "to_date" => $to_date, "due_date" => $due_date, "status" => 1, "amount" => "0.00", "balance" => $balance, "confirm" => 1);
200 200
 	}
201 201
         // echo "<pre>"; print_r($invoice_data); exit;
202 202
         $this->db->insert("invoices", $invoice_data);
203 203
         $invoiceid = $this->db->insert_id();
204
-	if($automatic_flag == 0){
204
+	if ($automatic_flag == 0) {
205 205
             $this->download_invoice($invoiceid, $account, $invoiceconf);
206 206
 	}
207 207
         return $invoiceid;
@@ -226,8 +226,8 @@  discard block
 block discarded – undo
226 226
         $invoicedata = $this->db_model->getSelect("*", "invoices", array("id" => $invoiceid));
227 227
         $invoicedata = $invoicedata->result_array();
228 228
         $invoicedata = $invoicedata[0];
229
-        $FilePath = FCPATH . "invoices/" . $accountdata["id"] . '/' . $invoicedata['invoice_prefix']."".$invoicedata['invoiceid'] . "_invoice.pdf";
230
-        $Filenm = $invoicedata['invoice_prefix'] ."_". $invoicedata['invoiceid'] . "_invoice.pdf";
229
+        $FilePath = FCPATH."invoices/".$accountdata["id"].'/'.$invoicedata['invoice_prefix']."".$invoicedata['invoiceid']."_invoice.pdf";
230
+        $Filenm = $invoicedata['invoice_prefix']."_".$invoicedata['invoiceid']."_invoice.pdf";
231 231
         $this->common->get_invoice_template($invoicedata, $accountdata, false);
232 232
         if ($invoice_conf['invoice_notification']) {
233 233
             $this->send_email_notification($FilePath, $Filenm, $accountdata, $invoice_conf, $invoicedata);
@@ -240,21 +240,21 @@  discard block
 block discarded – undo
240 240
         $EmailTemplate = $this->db_model->getSelect("*", "default_templates", $where);
241 241
         foreach ($EmailTemplate->result_array() as $TemplateVal) {
242 242
             $TemplateData = $TemplateVal;
243
-            $TemplateData['subject'] = str_replace('#NAME#', $AccountData['first_name'] . " " . $AccountData['last_name'], $TemplateData['subject']);
244
-            $TemplateData['subject'] = str_replace('#INVOICE_NUMBER#', $invData['invoice_prefix'] . $invData['invoiceid'], $TemplateData['subject']);
245
-            $TemplateData['template'] = str_replace('#NAME#', $AccountData['first_name'] . " " . $AccountData['last_name'], $TemplateData['template']);
246
-            $TemplateData['template'] = str_replace('#INVOICE_NUMBER#', $invData['invoice_prefix'] . $invData['invoiceid'], $TemplateData['template']);
243
+            $TemplateData['subject'] = str_replace('#NAME#', $AccountData['first_name']." ".$AccountData['last_name'], $TemplateData['subject']);
244
+            $TemplateData['subject'] = str_replace('#INVOICE_NUMBER#', $invData['invoice_prefix'].$invData['invoiceid'], $TemplateData['subject']);
245
+            $TemplateData['template'] = str_replace('#NAME#', $AccountData['first_name']." ".$AccountData['last_name'], $TemplateData['template']);
246
+            $TemplateData['template'] = str_replace('#INVOICE_NUMBER#', $invData['invoice_prefix'].$invData['invoiceid'], $TemplateData['template']);
247 247
             $TemplateData['template'] = str_replace('#AMOUNT#', $invData['amount'], $TemplateData['template']);
248 248
 
249 249
             $TemplateData['template'] = str_replace("#COMPANY_EMAIL#", $invoice_conf['emailaddress'], $TemplateData['template']);
250 250
             $TemplateData['template'] = str_replace("#COMPANY_NAME#", $invoice_conf['company_name'], $TemplateData['template']);
251 251
             $TemplateData['template'] = str_replace("#COMPANY_WEBSITE#", $invoice_conf['website'], $TemplateData['template']);
252
-            $TemplateData['template'] = str_replace("#INVOICE_DATE#",$invData['invoice_date'], $TemplateData['template']);
252
+            $TemplateData['template'] = str_replace("#INVOICE_DATE#", $invData['invoice_date'], $TemplateData['template']);
253 253
             $TemplateData['template'] = str_replace("#DUE_DATE#", $invData['due_date'], $TemplateData['template']);
254 254
         }
255
-        $dir_path = getcwd() . "/attachments/";
256
-        $path = $dir_path . $Filenm;
257
-        $command = "cp " . $FilePath . " " . $path;
255
+        $dir_path = getcwd()."/attachments/";
256
+        $path = $dir_path.$Filenm;
257
+        $command = "cp ".$FilePath." ".$path;
258 258
         exec($command);
259 259
         $email_array = array('accountid' => $AccountData['id'],
260 260
             'subject' => $TemplateData['subject'],
Please login to merge, or discard this patch.
web_interface/astpp/application/controllers/updateBalance.php 2 patches
Doc Comments   +11 added lines patch added patch discarded remove patch
@@ -153,6 +153,10 @@  discard block
 block discarded – undo
153 153
         }
154 154
     }
155 155
 
156
+    /**
157
+     * @param string $fromdate
158
+     * @param string $todate
159
+     */
156 160
     function calculate_charges($AccountDATA, $itemArr, $charge, $fromdate, $todate, $pro_rate = "1") {
157 161
         $lastdate = false;
158 162
         $billing_cycle = ($AccountDATA['sweep_id'] == "0") ? "1 day" : "1 month";
@@ -217,6 +221,9 @@  discard block
 block discarded – undo
217 221
         return $lastdate;
218 222
     }
219 223
 
224
+    /**
225
+     * @param string $todate
226
+     */
220 227
     function Manage_invoice_item($AccountData, $description, $item_id, $charge, $type, $fromdate, $todate, $invoicedate) {
221 228
         $invoiceid = 0;
222 229
         $Bal = "0.00"; 
@@ -263,6 +270,10 @@  discard block
 block discarded – undo
263 270
         $this->manage_invoice($invoice_item_arr);
264 271
     }
265 272
     
273
+    /**
274
+     * @param string $select
275
+     * @param string $table
276
+     */
266 277
     function get_table_data($select, $table, $where) {
267 278
         $query = $this->db_model->getSelect($select, $table, $where);
268 279
         if ($query->num_rows > 0) {
Please login to merge, or discard this patch.
Spacing   +28 added lines, -28 removed lines patch added patch discarded remove patch
@@ -50,7 +50,7 @@  discard block
 block discarded – undo
50 50
         
51 51
         // Check Charge is applied that is for first time or already calculated before
52 52
 
53
-        $where = "(charge_upto ='0000-00-00 00:00:00' OR charge_upto <='" . gmdate("Y-m-d H:i:s") . "')";
53
+        $where = "(charge_upto ='0000-00-00 00:00:00' OR charge_upto <='".gmdate("Y-m-d H:i:s")."')";
54 54
         $this->db->where('accountid', $accountinfo['id']);
55 55
         $this->db->where($where);
56 56
         $this->db->select('*');
@@ -61,13 +61,13 @@  discard block
 block discarded – undo
61 61
             foreach ($accountchargs as $accharges) {
62 62
                 //Get information from database of active charges.
63 63
                 $charge_data = $this->get_table_data("*", "charges", array("id" => $accharges['charge_id'], "status" => "0"));
64
-                if ($charge_data && !empty($charge_data)) {
64
+                if ($charge_data && ! empty($charge_data)) {
65 65
                     $charge_data = $charge_data[0];
66 66
                     //Get Start Date of Charge
67 67
                     $charge_upto = ($accharges["charge_upto"] != "0000-00-00 00:00:00" && $accharges["charge_upto"] != "") ?
68
-                            date("Y-m-d H:i:s", strtotime("+1 Second", strtotime($accharges["charge_upto"]))) :$accharges["assign_date"];
69
-                   if($accountinfo['original_sweep_id'] == 2 && $charge_data['pro_rate'] == 0 && $charge_data['sweep_id'] == 2 && ($accountinfo['invoice_day']< gmdate("d",strtotime($accharges['assign_date'])))) {
70
-                      $charge_upto=   date("Y-m-" . $accountinfo['invoice_day'] . " H:i:s", strtotime($accharges["assign_date"]));
68
+                            date("Y-m-d H:i:s", strtotime("+1 Second", strtotime($accharges["charge_upto"]))) : $accharges["assign_date"];
69
+                   if ($accountinfo['original_sweep_id'] == 2 && $charge_data['pro_rate'] == 0 && $charge_data['sweep_id'] == 2 && ($accountinfo['invoice_day'] < gmdate("d", strtotime($accharges['assign_date'])))) {
70
+                      $charge_upto = date("Y-m-".$accountinfo['invoice_day']." H:i:s", strtotime($accharges["assign_date"]));
71 71
                    }
72 72
                     //Overwrite Billing scehdule of customer assign proper charge
73 73
                     if ($accountinfo['sweep_id'] != $charge_data['sweep_id']) {
@@ -134,7 +134,7 @@  discard block
 block discarded – undo
134 134
                                 $lastdate = $this->calculate_charges($reseller_acc_data, $itemArr, $reseller_dids["monthlycost"], $fromdate, $todate, "1");
135 135
                                 if ($lastdate)
136 136
                                     $this->db->update("reseller_pricing", array("charge_upto" => $lastdate), array("note" => $did_value["number"], "reseller_id" => $reseller_acc_data["id"]));
137
-                            }else {
137
+                            } else {
138 138
                                 //Apply charges to Resellers.
139 139
                                 $lastdate = $this->calculate_charges($reseller_acc_data, $itemArr, $reseller_dids["monthlycost"], $fromdate, $todate, "1");
140 140
                                 if ($lastdate)
@@ -156,39 +156,39 @@  discard block
 block discarded – undo
156 156
     function calculate_charges($AccountDATA, $itemArr, $charge, $fromdate, $todate, $pro_rate = "1") {
157 157
         $lastdate = false;
158 158
         $billing_cycle = ($AccountDATA['sweep_id'] == "0") ? "1 day" : "1 month";
159
-        $last_invoice_date = $this->common->get_invoice_date("invoice_date",$AccountDATA['id'],$AccountDATA['reseller_id']);
159
+        $last_invoice_date = $this->common->get_invoice_date("invoice_date", $AccountDATA['id'], $AccountDATA['reseller_id']);
160 160
       //Below variable gives date based on assign or creation or monthly user billing day
161
-        $last_invoice_date = ($last_invoice_date) ? $last_invoice_date : (($pro_rate == 0 && $AccountDATA['original_sweep_id'] == 2 && ($AccountDATA['invoice_day']< gmdate("d",strtotime($itemArr['assign_date'])))) ? date("Y-m-" . $AccountDATA['invoice_day'] . " 00:00:00") : (($pro_rate == 1 && $AccountDATA['original_sweep_id'] == 0) ? date("Y-m-d 00:00:00", strtotime($itemArr['assign_date'])) : date("Y-m-d 00:00:00", strtotime($AccountDATA['creation']))));
161
+        $last_invoice_date = ($last_invoice_date) ? $last_invoice_date : (($pro_rate == 0 && $AccountDATA['original_sweep_id'] == 2 && ($AccountDATA['invoice_day'] < gmdate("d", strtotime($itemArr['assign_date'])))) ? date("Y-m-".$AccountDATA['invoice_day']." 00:00:00") : (($pro_rate == 1 && $AccountDATA['original_sweep_id'] == 0) ? date("Y-m-d 00:00:00", strtotime($itemArr['assign_date'])) : date("Y-m-d 00:00:00", strtotime($AccountDATA['creation']))));
162 162
         $last_invoice_date = ($last_invoice_date <= $fromdate) ? $last_invoice_date : $fromdate;
163 163
         $Charges_date_range = array();
164
-        $prorate_array =array();
164
+        $prorate_array = array();
165 165
         $daylen = 60 * 60 * 24;
166 166
         /*Get assign day and billing day for postpaid monthly user.
167 167
          */
168
-        $assign_day=($AccountDATA['original_sweep_id']==2 && $AccountDATA['posttoexternal']==1) ? gmdate("d",strtotime($itemArr['assign_date'])):0;
169
-        $billing_day=($AccountDATA['original_sweep_id']==2 && $AccountDATA['posttoexternal']==1) ? $AccountDATA['invoice_day']:0;
168
+        $assign_day = ($AccountDATA['original_sweep_id'] == 2 && $AccountDATA['posttoexternal'] == 1) ? gmdate("d", strtotime($itemArr['assign_date'])) : 0;
169
+        $billing_day = ($AccountDATA['original_sweep_id'] == 2 && $AccountDATA['posttoexternal'] == 1) ? $AccountDATA['invoice_day'] : 0;
170 170
         //Create an array if charge not applied yet and invoice day is greater than assign_day
171
-        if($itemArr['charge_upto'] == "0000-00-00 00:00:00" && ($billing_day > $assign_day) && $pro_rate==0 && $itemArr['cycle']==2 && $AccountDATA['original_sweep_id']==2){
172
-	  $last_invoice_date = gmdate("Y-m-d H:i:s",strtotime("-1 second",strtotime(date("Y-m-" . $AccountDATA['invoice_day'] . " 00:00:00", strtotime($itemArr["assign_date"])))));
173
-	  $prorate_array[] = array("start_date" => date("Y-m-d H:i:s",strtotime($itemArr['assign_date'])), "end_date" => $last_invoice_date);
171
+        if ($itemArr['charge_upto'] == "0000-00-00 00:00:00" && ($billing_day > $assign_day) && $pro_rate == 0 && $itemArr['cycle'] == 2 && $AccountDATA['original_sweep_id'] == 2) {
172
+	  $last_invoice_date = gmdate("Y-m-d H:i:s", strtotime("-1 second", strtotime(date("Y-m-".$AccountDATA['invoice_day']." 00:00:00", strtotime($itemArr["assign_date"])))));
173
+	  $prorate_array[] = array("start_date" => date("Y-m-d H:i:s", strtotime($itemArr['assign_date'])), "end_date" => $last_invoice_date);
174 174
 	  
175 175
         }
176 176
         while (strtotime($last_invoice_date) <= strtotime($todate)) {
177
-            $startdate=$last_invoice_date;
178
-            $last_invoice_date = gmdate("Y-m-d H:i:s", strtotime("+" . $billing_cycle, strtotime($last_invoice_date)));
179
-            $Charges_date_range[] = array("start_date" =>gmdate("Y-m-d H:i:s",strtotime("+1 Second",strtotime($startdate))), "end_date" => $last_invoice_date);
177
+            $startdate = $last_invoice_date;
178
+            $last_invoice_date = gmdate("Y-m-d H:i:s", strtotime("+".$billing_cycle, strtotime($last_invoice_date)));
179
+            $Charges_date_range[] = array("start_date" =>gmdate("Y-m-d H:i:s", strtotime("+1 Second", strtotime($startdate))), "end_date" => $last_invoice_date);
180 180
         }
181
-        if(!empty($prorate_array)){
181
+        if ( ! empty($prorate_array)) {
182 182
          array_pop($Charges_date_range);
183
-         $Charges_date_range=array_merge($prorate_array,$Charges_date_range);
183
+         $Charges_date_range = array_merge($prorate_array, $Charges_date_range);
184 184
         }
185
-        if (!empty($Charges_date_range)) {
185
+        if ( ! empty($Charges_date_range)) {
186 186
             foreach ($Charges_date_range as $ChargeVal) {
187
-                if (($pro_rate == 0 && $itemArr['cycle'] != 2) || (($billing_day <= $assign_day) && $pro_rate==0 && $itemArr['cycle']==2 && $AccountDATA['original_sweep_id']==2)) {
187
+                if (($pro_rate == 0 && $itemArr['cycle'] != 2) || (($billing_day <= $assign_day) && $pro_rate == 0 && $itemArr['cycle'] == 2 && $AccountDATA['original_sweep_id'] == 2)) {
188 188
                     $ChargeVal['end_date'] = gmdate("Y-m-d 23:59:59", strtotime("-1 Day", strtotime($ChargeVal['end_date'])));
189 189
                 }
190
-                if (!empty($itemArr['charge_upto']) && empty($lastdate)) {
191
-                    $start_date = ($itemArr['charge_upto'] == '0000-00-00 00:00:00' && $AccountDATA['sweep_id'] == 2 ) ? $itemArr['assign_date'] : $ChargeVal['start_date'];
190
+                if ( ! empty($itemArr['charge_upto']) && empty($lastdate)) {
191
+                    $start_date = ($itemArr['charge_upto'] == '0000-00-00 00:00:00' && $AccountDATA['sweep_id'] == 2) ? $itemArr['assign_date'] : $ChargeVal['start_date'];
192 192
                 } else {
193 193
                     $start_date = (empty($lastdate)) ? $ChargeVal['start_date'] : gmdate("Y-m-d H:i:s", strtotime("+1 second", strtotime($lastdate)));
194 194
                 }
@@ -222,13 +222,13 @@  discard block
 block discarded – undo
222 222
         $Bal = "0.00"; 
223 223
         if ($AccountData["posttoexternal"] == 0) {
224 224
 	    $reseller_id = $AccountData['type'] == 1 ? $AccountData['id'] : 0;
225
-	    $where = "accountid IN ('" . $reseller_id . "','1')";
225
+	    $where = "accountid IN ('".$reseller_id."','1')";
226 226
 	    $this->db->where($where);
227 227
 	    $this->db->select('*');
228 228
 	    $this->db->order_by('accountid', 'desc');
229 229
 	    $this->db->limit(1);
230 230
 	    $invoiceconf = $this->db->get('invoice_conf');
231
-	    $invoice_conf = (array) $invoiceconf->first_row();
231
+	    $invoice_conf = (array)$invoiceconf->first_row();
232 232
 	    $last_invoiceid = $this->common->get_invoice_date('invoiceid', '', $AccountData['reseller_id']);
233 233
 	    if ($last_invoiceid && $last_invoiceid > 0) {
234 234
 	    	$last_invoiceid = ($last_invoiceid + 1);
@@ -237,10 +237,10 @@  discard block
 block discarded – undo
237 237
 	    }
238 238
 	    $last_invoiceid = str_pad($last_invoiceid, (strlen($last_invoiceid) + 4), '0', STR_PAD_LEFT);
239 239
 	    $invoice_prefix = $invoice_conf['invoice_prefix'];
240
-	    $due_date = gmdate("Y-m-d H:i:s", strtotime(gmdate("Y-m-d H:i:s") . " +" . $invoice_conf['interval'] . " days"));
240
+	    $due_date = gmdate("Y-m-d H:i:s", strtotime(gmdate("Y-m-d H:i:s")." +".$invoice_conf['interval']." days"));
241 241
 
242 242
             $invoiceid = $this->common_model->generate_receipt($AccountData["id"], $charge, $AccountData, $last_invoiceid, $invoice_prefix, $due_date);
243
-            $this->db->set('balance', 'balance-' . $charge, FALSE);
243
+            $this->db->set('balance', 'balance-'.$charge, FALSE);
244 244
             $this->db->where('id', $AccountData["id"]);
245 245
             $this->db->update("accounts");
246 246
             $AccountData['balance'] = ($AccountData['balance'] - $charge);
@@ -255,7 +255,7 @@  discard block
 block discarded – undo
255 255
         }
256 256
         $invoice_item_arr = array("accountid" => $AccountData["id"],
257 257
             "reseller_id" => $AccountData["reseller_id"],
258
-            "description" => trim($description . "-" . $fromdate . " to " . $todate),
258
+            "description" => trim($description."-".$fromdate." to ".$todate),
259 259
             "item_id" => $item_id, "debit" => $charge, "invoiceid" => $invoiceid,
260 260
             "created_date" => trim($invoicedate),
261 261
             "item_type" => $type
Please login to merge, or discard this patch.
web_interface/astpp/application/libraries/astpp/common.php 2 patches
Doc Comments   +39 added lines, -2 removed lines patch added patch discarded remove patch
@@ -44,8 +44,6 @@  discard block
 block discarded – undo
44 44
 // __construct
45 45
     /**
46 46
      * adds raw html to the field array
47
-     * @param type $label
48
-     * @param type $field add
49 47
      */
50 48
     function generate_password() {
51 49
         $pass = substr(md5(rand(0, 1000000000)), 0, common_model::$global_config['system_config']['pinlength']);
@@ -93,6 +91,9 @@  discard block
 block discarded – undo
93 91
         return $uname;
94 92
     }
95 93
 
94
+    /**
95
+     * @param string $length
96
+     */
96 97
     function random_string($length) {
97 98
         $chars = "1234567890"; //length:36
98 99
         $final_rand = '';
@@ -132,6 +133,10 @@  discard block
 block discarded – undo
132 133
         return $number;
133 134
     }
134 135
 
136
+    /**
137
+     * @param string $select
138
+     * @param string $table
139
+     */
135 140
     function get_field_count($select, $table, $where) {
136 141
 //        echo $select."=====".$table."===".$where;
137 142
         if (is_array($where)) {
@@ -147,6 +152,10 @@  discard block
 block discarded – undo
147 152
         }
148 153
     }
149 154
 
155
+    /**
156
+     * @param string $select
157
+     * @param string $table
158
+     */
150 159
     function get_field_name($select, $table, $where) {
151 160
         if (is_array($where)) {
152 161
             $where = $where;
@@ -162,6 +171,10 @@  discard block
 block discarded – undo
162 171
         }
163 172
     }
164 173
 
174
+    /**
175
+     * @param string $select
176
+     * @param string $table
177
+     */
165 178
     function get_field_name_coma_new($select, $table, $where) {
166 179
         $value = '';
167 180
         if (is_array($where)) {
@@ -504,6 +517,9 @@  discard block
 block discarded – undo
504 517
     }
505 518
    
506 519
 
520
+    /**
521
+     * @param string $select
522
+     */
507 523
     function get_invoice_date($select, $accountid = 0, $reseller_id, $order_by = 'id') {
508 524
         $where = array("reseller_id" => $reseller_id);
509 525
         if ($accountid > 0) {
@@ -1175,6 +1191,9 @@  discard block
 block discarded – undo
1175 1191
 
1176 1192
     }
1177 1193
 
1194
+    /**
1195
+     * @param string $message
1196
+     */
1178 1197
     function emailFunction($from, $to, $subject, $message, $company_name = "", $attachment = "", $account_id, $reseller_id) {
1179 1198
         $send_mail_details = array('from' => $from,
1180 1199
             'to' => $to,
@@ -1373,12 +1392,18 @@  discard block
 block discarded – undo
1373 1392
       Password encode decode
1374 1393
      * ******* */
1375 1394
 
1395
+    /**
1396
+     * @param string $string
1397
+     */
1376 1398
     function encode_params($string) {
1377 1399
         $data = base64_encode($string);
1378 1400
         $data = str_replace(array('+', '/', '='), array('-', '$', ''), $data);
1379 1401
         return $data;
1380 1402
     }
1381 1403
 
1404
+    /**
1405
+     * @param string $value
1406
+     */
1382 1407
     function encode($value) {
1383 1408
         $text = $value;
1384 1409
         $iv_size = mcrypt_get_iv_size(MCRYPT_RIJNDAEL_256, MCRYPT_MODE_ECB);
@@ -1830,14 +1855,26 @@  discard block
 block discarded – undo
1830 1855
         }
1831 1856
     }
1832 1857
     
1858
+    /**
1859
+     * @param string $table_name
1860
+     */
1833 1861
     function delete_data($table_name,$where_arr){
1834 1862
         $this->CI->db->where($where_arr);
1835 1863
         $this->CI->db->delete($table_name);
1836 1864
     }
1865
+
1866
+    /**
1867
+     * @param string $table_name
1868
+     */
1837 1869
     function update_data($table_name,$where_arr,$update_arr){
1838 1870
         $this->CI->db->where($where_arr);
1839 1871
         $this->CI->db->update($table_name,$update_arr);
1840 1872
     }
1873
+
1874
+    /**
1875
+     * @param string $table_name
1876
+     * @param string $select
1877
+     */
1841 1878
     function select_data($table_name,$where_arr,$select){
1842 1879
         $this->CI->db->where($where_arr);
1843 1880
         $this->CI->db->select($select);
Please login to merge, or discard this patch.
Spacing   +425 added lines, -425 removed lines patch added patch discarded remove patch
@@ -22,7 +22,7 @@  discard block
 block discarded – undo
22 22
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
23 23
 ###############################################################################
24 24
 
25
-if (!defined('BASEPATH'))
25
+if ( ! defined('BASEPATH'))
26 26
     exit('No direct script access allowed');
27 27
 
28 28
 /**
@@ -88,7 +88,7 @@  discard block
 block discarded – undo
88 88
         if ($tablename == 'accounts' && $start_prifix_value != 0) {
89 89
             $length = strlen($start_prifix_value);
90 90
             $uname = substr($uname, $length);
91
-            $uname = $start_prifix_value . $uname;
91
+            $uname = $start_prifix_value.$uname;
92 92
         }
93 93
         return $uname;
94 94
     }
@@ -113,12 +113,12 @@  discard block
 block discarded – undo
113 113
             $uname = $this->random_string($length);
114 114
             $uname = strtolower($uname);
115 115
             if (isset($default))
116
-                $uname = $default . $uname;
117
-            if (!in_array($uname, $number)) {
116
+                $uname = $default.$uname;
117
+            if ( ! in_array($uname, $number)) {
118 118
                 $where = array($field => $uname);
119 119
                 $acc_result = $this->CI->db_model->getSelect('Count(id) as count', $tablename, $where);
120 120
                 $acc_result = $acc_result->result_array();
121
-                if ($acc_result[0]['count'] == 0 && !in_array($uname, $number)) {
121
+                if ($acc_result[0]['count'] == 0 && ! in_array($uname, $number)) {
122 122
                     $number[] = $uname;
123 123
                     $j++;
124 124
                 }
@@ -140,7 +140,7 @@  discard block
 block discarded – undo
140 140
             $where = array($select => $where);
141 141
         }
142 142
         $field_name = $this->CI->db_model->countQuery($select, $table, $where);
143
-        if (isset($field_name) && !empty($field_name)) {
143
+        if (isset($field_name) && ! empty($field_name)) {
144 144
             return $field_name;
145 145
         } else {
146 146
             return "0";
@@ -155,7 +155,7 @@  discard block
 block discarded – undo
155 155
         }
156 156
         $field_name = $this->CI->db_model->getSelect($select, $table, $where);
157 157
         $field_name = $field_name->result();
158
-        if (isset($field_name) && !empty($field_name)) {
158
+        if (isset($field_name) && ! empty($field_name)) {
159 159
             return $field_name[0]->$select;
160 160
         } else {
161 161
             return "";
@@ -175,12 +175,12 @@  discard block
 block discarded – undo
175 175
 
176 176
             $field_name = $this->CI->db_model->getSelect($select, $table, $where_in);
177 177
             $field_name = $field_name->result();
178
-            if (isset($field_name) && !empty($field_name)) {
178
+            if (isset($field_name) && ! empty($field_name)) {
179 179
                 foreach ($select1 as $sel) {
180 180
                     if ($sel == 'number') {
181
-                        $value.="(" . $field_name[0]->$sel . ")";
181
+                        $value .= "(".$field_name[0]->$sel.")";
182 182
                     } else {
183
-                        $value.= $field_name[0]->$sel . " ";
183
+                        $value .= $field_name[0]->$sel." ";
184 184
                     }
185 185
                 }
186 186
             } else {
@@ -196,12 +196,12 @@  discard block
 block discarded – undo
196 196
         $where = array("number" => $where);
197 197
         $field_name = $this->CI->db_model->getSelect("id,accountid,parent_id", 'dids', $where);
198 198
         $field_name = $field_name->result();
199
-        if (isset($field_name) && !empty($field_name)) {
199
+        if (isset($field_name) && ! empty($field_name)) {
200 200
             if (isset($field_name[0]) && $accountinfo['type'] != 1) {
201
-                if ($field_name[0]->accountid != 0 && $field_name[0]->parent_id ==0) {
202
-                    $flag_status = "<a href='../did_list_release/" . $field_name[0]->id . "' title='Release' onClick='return get_reliase_msg();'><span class=' label label-sm label-inverse_blue arrowed_blue-in' title='release'>Release(C)<span></a>";
201
+                if ($field_name[0]->accountid != 0 && $field_name[0]->parent_id == 0) {
202
+                    $flag_status = "<a href='../did_list_release/".$field_name[0]->id."' title='Release' onClick='return get_reliase_msg();'><span class=' label label-sm label-inverse_blue arrowed_blue-in' title='release'>Release(C)<span></a>";
203 203
                 } else if ($field_name[0]->parent_id != 0) {
204
-                    $flag_status = "<a href='../did_list_release/" . $field_name[0]->id . "' title='Release' onClick='return get_reliase_msg();'><span class=' label label-sm label-inverse_blue arrowed_blue-in' title='release'>Release(R)</span></a>";
204
+                    $flag_status = "<a href='../did_list_release/".$field_name[0]->id."' title='Release' onClick='return get_reliase_msg();'><span class=' label label-sm label-inverse_blue arrowed_blue-in' title='release'>Release(R)</span></a>";
205 205
                 } else {
206 206
                     $flag_status = "<span class=' label label-sm label-inverse arrowed-in' title='Not in use'>Not in use</span>";
207 207
                 }
@@ -211,8 +211,8 @@  discard block
 block discarded – undo
211 211
                 $field_name_re = $this->CI->db_model->getSelect("reseller_id", 'reseller_pricing', $where);
212 212
                 $field_name_re = $field_name_re->result();
213 213
 
214
-                if (isset($field_name_re) && !empty($field_name_re)) {
215
-                    $flag_status = "<a href='../did_list_release/" . $field_name[0]->id . "' title='Release' onClick='return get_reliase_msg();'><span class=' label label-sm label-inverse_blue arrowed_blue-in' title='release'>Release(R)</span></a>";
214
+                if (isset($field_name_re) && ! empty($field_name_re)) {
215
+                    $flag_status = "<a href='../did_list_release/".$field_name[0]->id."' title='Release' onClick='return get_reliase_msg();'><span class=' label label-sm label-inverse_blue arrowed_blue-in' title='release'>Release(R)</span></a>";
216 216
                 } else {
217 217
                     $flag_status = "<span class=' label label-sm label-inverse arrowed-in' title='Not in use'>Not in use</span>";
218 218
                 }
@@ -222,32 +222,32 @@  discard block
 block discarded – undo
222 222
         }
223 223
         return $flag_status;
224 224
     }
225
-    function check_did_avl_export($number){
226
-      $this->CI->db->where('number',$number);
225
+    function check_did_avl_export($number) {
226
+      $this->CI->db->where('number', $number);
227 227
       $this->CI->db->select('id,accountid,parent_id');
228
-      $status=null;
229
-      $did_info=(array)$this->CI->db->get('dids')->first_row();
230
-      $accountinfo=$this->CI->session->userdata('accountinfo');
231
-      if($did_info['accountid'] ==0 && $did_info['parent_id']==0){
232
-	$status='Not in use';
228
+      $status = null;
229
+      $did_info = (array)$this->CI->db->get('dids')->first_row();
230
+      $accountinfo = $this->CI->session->userdata('accountinfo');
231
+      if ($did_info['accountid'] == 0 && $did_info['parent_id'] == 0) {
232
+	$status = 'Not in use';
233 233
       }
234
-      elseif($accountinfo['type'] !=1){
235
-	if($did_info['accountid'] ==0 && $did_info['parent_id'] > 0){
236
-	  $status='Purchase by Reseller';
234
+      elseif ($accountinfo['type'] != 1) {
235
+	if ($did_info['accountid'] == 0 && $did_info['parent_id'] > 0) {
236
+	  $status = 'Purchase by Reseller';
237 237
 	}
238
-	if($did_info['accountid'] > 0 && $did_info['parent_id'] == 0){
239
-	  $status='Purchase by Customer';
238
+	if ($did_info['accountid'] > 0 && $did_info['parent_id'] == 0) {
239
+	  $status = 'Purchase by Customer';
240 240
 	}
241
-      }else{
242
-       $where_arr=array('note'=>$did_info['number'],"parent_id"=>$accountinfo['id']);
241
+      } else {
242
+       $where_arr = array('note'=>$did_info['number'], "parent_id"=>$accountinfo['id']);
243 243
        $this->db->where($where);
244 244
        $this->CI->db->select('reseller_id,parent_id');
245 245
        $reseller_pricing = (array)$this->db->get('reseller_pricing')->first_row();
246
-       if($reseller_pricing['reseller_id']==0 && $did_info['accountid']==0 && $did_info['parent_id']==$accountinfo['id']){
247
-        $status='Not in use';
246
+       if ($reseller_pricing['reseller_id'] == 0 && $did_info['accountid'] == 0 && $did_info['parent_id'] == $accountinfo['id']) {
247
+        $status = 'Not in use';
248 248
        }
249
-       if($reseller_pricing['reseller_id']==0 && $did_info['accountid']==0){
250
-       $status='Not in use';
249
+       if ($reseller_pricing['reseller_id'] == 0 && $did_info['accountid'] == 0) {
250
+       $status = 'Not in use';
251 251
        }
252 252
       }
253 253
       return $status;
@@ -256,24 +256,24 @@  discard block
 block discarded – undo
256 256
     function check_did_avl_reseller($select, $table, $where) {
257 257
         $accountinfo = $this->CI->session->userdata('accountinfo');
258 258
         $flag_status = "<span class=' label label-sm label-inverse arrowed-in' title='Not in use'>Not in use</span>";
259
-        $this->CI->db->where('number',$where);
259
+        $this->CI->db->where('number', $where);
260 260
         $this->CI->db->select('id,accountid,parent_id,number');
261
-        $did_info=(array)$this->CI->db->get('dids')->first_row();
262
-        if($did_info['accountid'] > 0 && $did_info['parent_id'] == $accountinfo['id']){
263
-	    $flag_status = "<a href='../did_list_release/" . $did_info['id'] . "' title='Release' onClick='return get_reliase_msg();'><span class=' label label-sm label-inverse_blue arrowed_blue-in' title='release'>Release(C)<span></a>";
261
+        $did_info = (array)$this->CI->db->get('dids')->first_row();
262
+        if ($did_info['accountid'] > 0 && $did_info['parent_id'] == $accountinfo['id']) {
263
+	    $flag_status = "<a href='../did_list_release/".$did_info['id']."' title='Release' onClick='return get_reliase_msg();'><span class=' label label-sm label-inverse_blue arrowed_blue-in' title='release'>Release(C)<span></a>";
264 264
 	}
265
-        else if($accountinfo['type']!=1 && $did_info['parent_id'] != $accountinfo['id']){
266
-	    $flag_status = "<a href='../did_list_release/" . $did_info['id'] . "' title='Release' onClick='return get_reliase_msg();'><span class=' label label-sm label-inverse_blue arrowed_blue-in' title='release'>Release(R)</span></a>";
267
-        }else{
268
-	    $reseller_id= $accountinfo['type'] != 1 ? 0 : $accountinfo['id'];
269
-	    $where = array("note" => $did_info['number'],'parent_id'=>$reseller_id);
265
+        else if ($accountinfo['type'] != 1 && $did_info['parent_id'] != $accountinfo['id']) {
266
+	    $flag_status = "<a href='../did_list_release/".$did_info['id']."' title='Release' onClick='return get_reliase_msg();'><span class=' label label-sm label-inverse_blue arrowed_blue-in' title='release'>Release(R)</span></a>";
267
+        } else {
268
+	    $reseller_id = $accountinfo['type'] != 1 ? 0 : $accountinfo['id'];
269
+	    $where = array("note" => $did_info['number'], 'parent_id'=>$reseller_id);
270 270
             $this->CI->db->where($where);
271 271
 	    $this->CI->db->select('reseller_id,id');
272
-	    $reseller_pricing_info=(array)$this->CI->db->get('reseller_pricing')->first_row();
273
-	    if (isset($reseller_pricing_info) && !empty($reseller_pricing_info)) {
274
-		  $flag_status="<a href='../did/did_reseller_edit/delete/".$reseller_pricing_info['id']."' title='Reliase' onClick='return get_reliase_msg();'><span class=' label label-sm label-inverse_blue arrowed_blue-in' title='release'>Release(R)</span></a>";
275
-	    }else{
276
-	      $flag_status="<span class=' label label-sm label-inverse arrowed-in' title='Not in use'>Not in use</span>";
272
+	    $reseller_pricing_info = (array)$this->CI->db->get('reseller_pricing')->first_row();
273
+	    if (isset($reseller_pricing_info) && ! empty($reseller_pricing_info)) {
274
+		  $flag_status = "<a href='../did/did_reseller_edit/delete/".$reseller_pricing_info['id']."' title='Reliase' onClick='return get_reliase_msg();'><span class=' label label-sm label-inverse_blue arrowed_blue-in' title='release'>Release(R)</span></a>";
275
+	    } else {
276
+	      $flag_status = "<span class=' label label-sm label-inverse arrowed-in' title='Not in use'>Not in use</span>";
277 277
 	    }
278 278
         }
279 279
         return $flag_status;
@@ -292,8 +292,8 @@  discard block
 block discarded – undo
292 292
 
293 293
             $field_name = $this->CI->db_model->getSelect($select, $table, $where_in);
294 294
             $field_name = $field_name->result();
295
-            if (isset($field_name) && !empty($field_name)) {
296
-                $value.= $field_name[0]->$select . ",";
295
+            if (isset($field_name) && ! empty($field_name)) {
296
+                $value .= $field_name[0]->$select.",";
297 297
             } else {
298 298
                 $value = "";
299 299
             }
@@ -325,7 +325,7 @@  discard block
 block discarded – undo
325 325
             if (isset($uri_segment[3])) {
326 326
                 return $week_arr;
327 327
             } else {
328
-                $week_drp = form_dropdown(array("name" => 'invoice_day','style'=>"width: 100% !important;" , "class" => "invoice_day"), $week_arr, $day);
328
+                $week_drp = form_dropdown(array("name" => 'invoice_day', 'style'=>"width: 100% !important;", "class" => "invoice_day"), $week_arr, $day);
329 329
                 return $week_drp;
330 330
             }
331 331
         }
@@ -337,7 +337,7 @@  discard block
 block discarded – undo
337 337
                 return $mon_arr;
338 338
             } else {
339 339
                 $day = $invoice_date > 0 ? $invoice_date : date('d');
340
-                $month_drp = form_dropdown(array("name" => 'invoice_day',"class" => "width_dropdown invoice_day"), $mon_arr, $day);
340
+                $month_drp = form_dropdown(array("name" => 'invoice_day', "class" => "width_dropdown invoice_day"), $mon_arr, $day);
341 341
                 return $month_drp;
342 342
             }
343 343
         }
@@ -349,7 +349,7 @@  discard block
 block discarded – undo
349 349
     }
350 350
 
351 351
     function set_routetype($status = '') {
352
-        $status_array = array( '0' => 'LCR','1' => 'COST',);
352
+        $status_array = array('0' => 'LCR', '1' => 'COST',);
353 353
         return $status_array;
354 354
     }
355 355
 
@@ -378,12 +378,12 @@  discard block
 block discarded – undo
378 378
         $status_array = array('1' => 'Yes', '0' => 'No');
379 379
         return $status_array;
380 380
     }
381
-    function set_pin_allow($status=''){
382
-        $status_array = array('0' => 'Disable','1' => 'Enable');
381
+    function set_pin_allow($status = '') {
382
+        $status_array = array('0' => 'Disable', '1' => 'Enable');
383 383
         return $status_array;
384 384
     }
385
-    function set_pin_allow_customer($status=''){
386
-        $status_array = array('0' => 'No','1' => 'Yes');
385
+    function set_pin_allow_customer($status = '') {
386
+        $status_array = array('0' => 'No', '1' => 'Yes');
387 387
         return $status_array;
388 388
     }
389 389
     function get_allow($select = "", $table = "", $status) {
@@ -391,20 +391,20 @@  discard block
 block discarded – undo
391 391
     }
392 392
 
393 393
     function set_call_type($call_type = "") {
394
-        $call_type_array = array("-1" => "--Select--",'1' => 'DID-Local',"3"=>"SIP-DID", '0' => 'PSTN',  '2' => 'Other',);
394
+        $call_type_array = array("-1" => "--Select--", '1' => 'DID-Local', "3"=>"SIP-DID", '0' => 'PSTN', '2' => 'Other',);
395 395
         return $call_type_array;
396 396
     }
397
-    function set_call_type_search(){
398
-	$call_type_array = array("" => "--Select--",'1' => 'DID-Local',"3"=>"SIP-DID", '0' => 'PSTN',  '2' => 'Other',);
397
+    function set_call_type_search() {
398
+	$call_type_array = array("" => "--Select--", '1' => 'DID-Local', "3"=>"SIP-DID", '0' => 'PSTN', '2' => 'Other',);
399 399
         return $call_type_array;
400 400
     }
401 401
     function get_call_type($select = "", $table = "", $call_type) {
402
-        $call_type_array = array('1' => 'DID-Local',"3"=>"SIP-DID",'0' => 'PSTN',  '2' => 'Other','-1'=>"");
402
+        $call_type_array = array('1' => 'DID-Local', "3"=>"SIP-DID", '0' => 'PSTN', '2' => 'Other', '-1'=>"");
403 403
         return $call_type_array[$call_type];
404 404
     }
405 405
 
406 406
     function get_custom_call_type($call_type) {
407
-        $call_type_array = array('DID-Local' => '1',"SIP-DID"=>"3",'PSTN' => '0','Other' => '2',""=>"-1");
407
+        $call_type_array = array('DID-Local' => '1', "SIP-DID"=>"3", 'PSTN' => '0', 'Other' => '2', ""=>"-1");
408 408
         return $call_type_array[$call_type];
409 409
     }
410 410
 
@@ -429,7 +429,7 @@  discard block
 block discarded – undo
429 429
     }
430 430
 
431 431
 	function set_entity_type_email_mass($entity_type = "") {
432
-        $entity_array = array('' => "--Select--", '0' => 'Customer','1'=>'Reseller','3' => "Provider");
432
+        $entity_array = array('' => "--Select--", '0' => 'Customer', '1'=>'Reseller', '3' => "Provider");
433 433
         return $entity_array;
434 434
     }
435 435
 
@@ -466,21 +466,21 @@  discard block
 block discarded – undo
466 466
    show status on all grid
467 467
    */
468 468
    function get_status($select = "", $table = "", $status) {
469
-       if($select !='export'){
470
-        $status_tab=$this->encode($table);
471
-        $status['table']="'".$status_tab."'";
472
-        if($status['status'] == 0){
469
+       if ($select != 'export') {
470
+        $status_tab = $this->encode($table);
471
+        $status['table'] = "'".$status_tab."'";
472
+        if ($status['status'] == 0) {
473 473
 	$status_array = '<div style="width: 100%; text-align: -moz-center; padding: 0;"><input type="checkbox" name="onoffswitch" class="onoffswitch-checkbox" id=switch'.$status['id'].' value='.$status['status'].' onclick="javascript:processForm('.$status['id'].','.$status['table'].')" checked>
474 474
 	<label class="onoffswitch-label" for=switch'.$status["id"].'>
475 475
      	<span class="onoffswitch-inner"></span>
476 476
 	</label></div>';
477
-	}else{
477
+	} else {
478 478
 	$status_array = '<div style="width: 100%; text-align: -moz-center; padding: 0;"><input type="checkbox" name="onoffswitch" class="onoffswitch-checkbox" id=switch'.$status['id'].' value='.$status['status'].' onclick="javascript:processForm('.$status['id'].','.$status['table'].')">
479 479
 	<label class="onoffswitch-label" for=switch'.$status["id"].'>
480 480
      	<span class="onoffswitch-inner"></span>
481 481
 	</label></div>';
482 482
 	}
483
-	}else{
483
+	} else {
484 484
 		return ($status == 0) ? "Active" : "Inactive";
485 485
 	}
486 486
 	return $status_array;
@@ -494,13 +494,13 @@  discard block
 block discarded – undo
494 494
         return ($status == 0) ? "Yes" : "No";
495 495
     }
496 496
     
497
-    function get_import_status($status){
497
+    function get_import_status($status) {
498 498
      return strtolower(trim($status)) == 'active' ? 0 : 1;
499 499
      
500 500
     }
501
-    function get_did_status($select,$table,$status){
501
+    function get_did_status($select, $table, $status) {
502 502
     
503
-      return ($status['status']==0) ? "<span class='label label-sm label-inverse arrowed-in' title='release'>Active<span>" : "<span class='label label-sm' title='release'>Inactive<span>";
503
+      return ($status['status'] == 0) ? "<span class='label label-sm label-inverse arrowed-in' title='release'>Active<span>" : "<span class='label label-sm' title='release'>Inactive<span>";
504 504
     }
505 505
    
506 506
 
@@ -511,7 +511,7 @@  discard block
 block discarded – undo
511 511
         }
512 512
         $invoice_res = $this->CI->db_model->select($select, "invoices", $where, $order_by, "DESC", "1", "0");
513 513
         if ($invoice_res->num_rows > 0) {
514
-            $invoice_info = (array) $invoice_res->first_row();
514
+            $invoice_info = (array)$invoice_res->first_row();
515 515
             return $invoice_info[$select];
516 516
         }
517 517
         return false;
@@ -537,23 +537,23 @@  discard block
 block discarded – undo
537 537
 
538 538
     function convert_to_currency($select = "", $table = "", $amount) {
539 539
         $this->CI->load->model('common_model');
540
-        return $this->CI->common_model->calculate_currency($amount,'','',true,false);
540
+        return $this->CI->common_model->calculate_currency($amount, '', '', true, false);
541 541
     }
542
-    function account_number_icon($select = "", $table = "", $number){
543
-    $return_value='';
544
-    $where=array('number'=>$number);
545
-    $account_res = (array)$this->CI->db->get_where("accounts",$where)->first_row();
546
-    if($account_res['type'] == 0){
547
-    $return_value= '<div class="flx_font flx_magenta" title="Customer">C</div>'." <span title='Edit'>". $account_res['number']." </span>";    
542
+    function account_number_icon($select = "", $table = "", $number) {
543
+    $return_value = '';
544
+    $where = array('number'=>$number);
545
+    $account_res = (array)$this->CI->db->get_where("accounts", $where)->first_row();
546
+    if ($account_res['type'] == 0) {
547
+    $return_value = '<div class="flx_font flx_magenta" title="Customer">C</div>'." <span title='Edit'>".$account_res['number']." </span>";    
548 548
     }
549
-    if($account_res['type']==3){
550
-    $return_value='<div class="flx_font flx_blue" title="Provider">P</div>'." <span title='Edit'>".$account_res['number']." </span>";
549
+    if ($account_res['type'] == 3) {
550
+    $return_value = '<div class="flx_font flx_blue" title="Provider">P</div>'." <span title='Edit'>".$account_res['number']." </span>";
551 551
     }
552
-    if($account_res['type']== -1 || $account_res['type']==2){
553
-      $return_value='<div class="flx_font flx_pink" title="Admin">A</div>'." <span title='Edit'>".$account_res['number']." </span>";
552
+    if ($account_res['type'] == -1 || $account_res['type'] == 2) {
553
+      $return_value = '<div class="flx_font flx_pink" title="Admin">A</div>'." <span title='Edit'>".$account_res['number']." </span>";
554 554
     }
555
-    if($account_res['type']== 4){
556
-      $return_value='<div class="flx_font flx_purple" title="Subadmin">S</div>'." <span title='Edit'>".$account_res['number']." </span>";
555
+    if ($account_res['type'] == 4) {
556
+      $return_value = '<div class="flx_font flx_purple" title="Subadmin">S</div>'." <span title='Edit'>".$account_res['number']." </span>";
557 557
     }
558 558
     return $return_value;
559 559
     }
@@ -628,7 +628,7 @@  discard block
 block discarded – undo
628 628
     }
629 629
 
630 630
     function search_string_type($status = '') {
631
-        $status_array = array('5'=>"Begins With",'1' => 'Contains', '2' => 'Doesnt Contain', '3' => 'Is Equal To', '4' => 'Is Not Equal To',"6"=>"Ends With");
631
+        $status_array = array('5'=>"Begins With", '1' => 'Contains', '2' => 'Doesnt Contain', '3' => 'Is Equal To', '4' => 'Is Not Equal To', "6"=>"Ends With");
632 632
         return $status_array;
633 633
     }
634 634
 
@@ -649,7 +649,7 @@  discard block
 block discarded – undo
649 649
     }
650 650
 
651 651
     function convert_to_percentage($select = "", $table = "", $amount) {
652
-        return round($amount, 2) . " %";
652
+        return round($amount, 2)." %";
653 653
     }
654 654
 
655 655
     function convert_to_minutes($select = "", $table = "", $amount) {
@@ -661,7 +661,7 @@  discard block
 block discarded – undo
661 661
         return $status_array;
662 662
     }
663 663
     
664
-    	function set_routetype_status($select= ''){
664
+    	function set_routetype_status($select = '') {
665 665
         $status_array = array("" => "--Select--",
666 666
             "0" => "LCR",
667 667
             "1" => "COST"
@@ -676,8 +676,8 @@  discard block
 block discarded – undo
676 676
             $array = explode(",", $attachement);
677 677
             $str = '';	
678 678
             foreach ($array as $key => $val) {
679
-                $link = base_url() . "email/email_history_list_attachment/" . $val;
680
-                $str.="<a href='" . $link . "' title='" . $val . "' class='btn btn-royelblue btn-sm'><i class='fa fa-paperclip fa-fw'></i></a>&nbsp;&nbsp;";
679
+                $link = base_url()."email/email_history_list_attachment/".$val;
680
+                $str .= "<a href='".$link."' title='".$val."' class='btn btn-royelblue btn-sm'><i class='fa fa-paperclip fa-fw'></i></a>&nbsp;&nbsp;";
681 681
             }
682 682
             return $str;
683 683
         } else {
@@ -764,7 +764,7 @@  discard block
 block discarded – undo
764 764
 
765 765
     function get_action_buttons($buttons_arr, $linkid) {
766 766
         $ret_url = '';
767
-        if (!empty($buttons_arr) && $buttons_arr != '') {
767
+        if ( ! empty($buttons_arr) && $buttons_arr != '') {
768 768
             foreach ($buttons_arr as $button_key => $buttons_params) {
769 769
                 if (strtoupper($button_key) == "EDIT") {
770 770
                     $ret_url .= $this->build_edit_button($buttons_params, $linkid);
@@ -833,31 +833,31 @@  discard block
 block discarded – undo
833 833
     }
834 834
 
835 835
     function build_delete_button_animap($url, $linkid) {
836
-        $link = base_url() . $url . "" . $linkid;
837
-        return '<a href="javascript:void(0)" class="btn btn-royelblue btn-sm" title="Delete" onClick="return get_alert_msg_destination(' . $linkid . ');"><i class="fa fa-trash fa-fw"></i></a>';
836
+        $link = base_url().$url."".$linkid;
837
+        return '<a href="javascript:void(0)" class="btn btn-royelblue btn-sm" title="Delete" onClick="return get_alert_msg_destination('.$linkid.');"><i class="fa fa-trash fa-fw"></i></a>';
838 838
     }
839 839
 
840 840
     function build_edit_button_animap($button_params, $linkid) {
841
-        $link = base_url() . $button_params->url . "" . $linkid;
842
-        return '<a href="javascript:void(0);" id="destination_new" class="btn btn-royelblue btn-sm" onclick="return get_destination(' . $linkid . ');" title="Update"><i class="fa fa-pencil-square-o fa-fw"></i></a>&nbsp;';
841
+        $link = base_url().$button_params->url."".$linkid;
842
+        return '<a href="javascript:void(0);" id="destination_new" class="btn btn-royelblue btn-sm" onclick="return get_destination('.$linkid.');" title="Update"><i class="fa fa-pencil-square-o fa-fw"></i></a>&nbsp;';
843 843
     }
844 844
 
845 845
     function build_animap_button($button_params, $linkid) {
846
-        $link = base_url() . $button_params->url . "" . $linkid;
847
-        return '<a href="' . $link . '" class="btn btn-royelblue btn-sm animap_image" rel="facebox" title="ANI Map"><i class="fa fa-reorder fa-fw"></i></a>&nbsp;';
846
+        $link = base_url().$button_params->url."".$linkid;
847
+        return '<a href="'.$link.'" class="btn btn-royelblue btn-sm animap_image" rel="facebox" title="ANI Map"><i class="fa fa-reorder fa-fw"></i></a>&nbsp;';
848 848
     }
849 849
 
850 850
     function build_edit_button($button_params, $linkid) {
851
-        $link = base_url() . $button_params->url . "" . $linkid;
851
+        $link = base_url().$button_params->url."".$linkid;
852 852
        
853 853
         if ($button_params->mode == 'popup') {
854
-            $rel = (isset($button_params->layout) && $button_params->layout != '')?"facebox_".$button_params->layout:"facebox";
855
-            return '<a href="' . $link . '" class="btn btn-royelblue btn-sm" rel="'.$rel.'" title="Edit" ="small"><i class="fa fa-pencil-square-o fa-fw"></i></a>&nbsp;';
854
+            $rel = (isset($button_params->layout) && $button_params->layout != '') ? "facebox_".$button_params->layout : "facebox";
855
+            return '<a href="'.$link.'" class="btn btn-royelblue btn-sm" rel="'.$rel.'" title="Edit" ="small"><i class="fa fa-pencil-square-o fa-fw"></i></a>&nbsp;';
856 856
             
857
-        }else if(strpos($link,'customer_edit') !== false){
858
-        return '<a href="' . $link . '" class="btn btn-royelblue btn-sm" title="Edit"><i class="fa fa-pencil-square-o fa-fw"></i></a>&nbsp;';
859
-        }else {
860
-            return '<a href="' . $link . '" class="btn btn-royelblue btn-sm" title="Edit"><i class="fa fa-pencil-square-o fa-fw"></i></a>&nbsp;';
857
+        } else if (strpos($link, 'customer_edit') !== false) {
858
+        return '<a href="'.$link.'" class="btn btn-royelblue btn-sm" title="Edit"><i class="fa fa-pencil-square-o fa-fw"></i></a>&nbsp;';
859
+        } else {
860
+            return '<a href="'.$link.'" class="btn btn-royelblue btn-sm" title="Edit"><i class="fa fa-pencil-square-o fa-fw"></i></a>&nbsp;';
861 861
         }
862 862
     }
863 863
 
@@ -865,18 +865,18 @@  discard block
 block discarded – undo
865 865
       For Edit on Account number or name
866 866
      **/
867 867
     function build_custome_edit_button($button_params, $field, $linkid) {
868
-        $link = base_url() . $button_params->url . "" . $linkid;
869
-        if(isset($button_params->layout)){
868
+        $link = base_url().$button_params->url."".$linkid;
869
+        if (isset($button_params->layout)) {
870 870
 			if ($button_params->mode == 'popup') {
871
-				return '<a href="' . $link . '" style="cursor:pointer;color:#005298;" rel="facebox_medium" title="Update">' . $field . '</a>&nbsp;';
871
+				return '<a href="'.$link.'" style="cursor:pointer;color:#005298;" rel="facebox_medium" title="Update">'.$field.'</a>&nbsp;';
872 872
 			} else {
873
-				return '<a href="' . $link . '" style="cursor:pointer;color:#005298;" title="Edit">' . $field . '</a>&nbsp;';
873
+				return '<a href="'.$link.'" style="cursor:pointer;color:#005298;" title="Edit">'.$field.'</a>&nbsp;';
874 874
 			}
875
-		}else{ 
875
+		} else { 
876 876
 			if ($button_params->mode == 'popup') {
877
-				return '<a href="' . $link . '" style="cursor:pointer;color:#005298;" rel="facebox" title="Update">' . $field . '</a>&nbsp;';
877
+				return '<a href="'.$link.'" style="cursor:pointer;color:#005298;" rel="facebox" title="Update">'.$field.'</a>&nbsp;';
878 878
 			} else {
879
-				return '<a href="' . $link . '" style="cursor:pointer;color:#005298;" title="Edit">' . $field . '</a>&nbsp;';
879
+				return '<a href="'.$link.'" style="cursor:pointer;color:#005298;" title="Edit">'.$field.'</a>&nbsp;';
880 880
 			}
881 881
 		}
882 882
     }
@@ -884,126 +884,126 @@  discard block
 block discarded – undo
884 884
     /************************************ */
885 885
 
886 886
     function build_edit_button_restore($button_params, $linkid) {
887
-        $link = base_url() . $button_params->url . "" . $linkid;
887
+        $link = base_url().$button_params->url."".$linkid;
888 888
         if ($button_params->mode == 'popup') {
889
-            return '<a href="' . $link . '" class="btn btn-royelblue btn-sm" rel="facebox" title="Restore" onClick="return get_alert_msg();"><i class="fa fa-reorder fa-fw"></i></a>&nbsp;';
889
+            return '<a href="'.$link.'" class="btn btn-royelblue btn-sm" rel="facebox" title="Restore" onClick="return get_alert_msg();"><i class="fa fa-reorder fa-fw"></i></a>&nbsp;';
890 890
         } else {
891
-            return '<a href="' . $link . '" class="btn btn-royelblue btn-sm" title="Restore" onClick="return get_alert_msg_restore();"><i class="fa fa-reorder fa-fw"></i></a>&nbsp;';
891
+            return '<a href="'.$link.'" class="btn btn-royelblue btn-sm" title="Restore" onClick="return get_alert_msg_restore();"><i class="fa fa-reorder fa-fw"></i></a>&nbsp;';
892 892
         }
893 893
     }
894 894
 
895 895
     function build_delete_button($url, $linkid) {
896
-        $flag='0';
897
-        $data=  explode("/",$url);
898
-        $link = base_url() . $url . "" . $linkid;
899
-        foreach($data as $key=>$value){
900
-            if($value == 'price_delete')
896
+        $flag = '0';
897
+        $data = explode("/", $url);
898
+        $link = base_url().$url."".$linkid;
899
+        foreach ($data as $key=>$value) {
900
+            if ($value == 'price_delete')
901 901
                 $flag = '1';
902
-            if($value == 'trunk_remove')
903
-                $flag='2';
904
-            if($value == 'customer_delete' ||$value =='provider_delete')
905
-                $flag='3';
906
-            if($value == 'reseller_delete')
907
-                $flag='4';
902
+            if ($value == 'trunk_remove')
903
+                $flag = '2';
904
+            if ($value == 'customer_delete' || $value == 'provider_delete')
905
+                $flag = '3';
906
+            if ($value == 'reseller_delete')
907
+                $flag = '4';
908 908
             }    
909
-            if($flag=='1'){
910
-                $where=array('pricelist_id'=>$linkid,'deleted !=' =>'1');
911
-                $customer_cnt=$this->get_field_count('id','accounts',$where);
912
-                    $where=array('pricelist_id'=>$linkid);
913
-                    $rategroup_cnt=$this->get_field_count('id','routes',$where);
914
-                    if($rategroup_cnt > 0 || $customer_cnt > 0 ){
909
+            if ($flag == '1') {
910
+                $where = array('pricelist_id'=>$linkid, 'deleted !=' =>'1');
911
+                $customer_cnt = $this->get_field_count('id', 'accounts', $where);
912
+                    $where = array('pricelist_id'=>$linkid);
913
+                    $rategroup_cnt = $this->get_field_count('id', 'routes', $where);
914
+                    if ($rategroup_cnt > 0 || $customer_cnt > 0) {
915 915
                         
916
-                        return '<a href="' . $link . '" class="btn btn-royelblue btn-sm" title="Delete" onClick="return get_alert_message('.$rategroup_cnt.','.$customer_cnt.','.$linkid.',1);"><i class="fa fa-trash fa-fw"></i></a>';
916
+                        return '<a href="'.$link.'" class="btn btn-royelblue btn-sm" title="Delete" onClick="return get_alert_message('.$rategroup_cnt.','.$customer_cnt.','.$linkid.',1);"><i class="fa fa-trash fa-fw"></i></a>';
917 917
                     }
918
-                    else{
919
-                        return '<a href="' . $link . '" class="btn btn-royelblue btn-sm" title="Delete" onClick="return get_alert_msg();"><i class="fa fa-trash fa-fw"></i></a>';
918
+                    else {
919
+                        return '<a href="'.$link.'" class="btn btn-royelblue btn-sm" title="Delete" onClick="return get_alert_msg();"><i class="fa fa-trash fa-fw"></i></a>';
920 920
                     }
921 921
             }
922
-            if($flag=='2'){
923
-                $where=array('trunk_id'=>$linkid);
924
-                $trunk_cnt=$this->get_field_count('id','outbound_routes',$where);
925
-                if($trunk_cnt > 0){
926
-                    return '<a href="' . $link . '" class="btn btn-royelblue btn-sm" title="Delete" onClick="return get_alert_message('.$trunk_cnt.',null,'.$linkid.',2);"><i class="fa fa-trash fa-fw"></i></a>';
922
+            if ($flag == '2') {
923
+                $where = array('trunk_id'=>$linkid);
924
+                $trunk_cnt = $this->get_field_count('id', 'outbound_routes', $where);
925
+                if ($trunk_cnt > 0) {
926
+                    return '<a href="'.$link.'" class="btn btn-royelblue btn-sm" title="Delete" onClick="return get_alert_message('.$trunk_cnt.',null,'.$linkid.',2);"><i class="fa fa-trash fa-fw"></i></a>';
927 927
                 }
928
-                else{
929
-                    return '<a href="' . $link . '" class="btn btn-royelblue btn-sm" title="Delete" onClick="return get_alert_msg();"><i class="fa fa-trash fa-fw"></i></a>';
928
+                else {
929
+                    return '<a href="'.$link.'" class="btn btn-royelblue btn-sm" title="Delete" onClick="return get_alert_msg();"><i class="fa fa-trash fa-fw"></i></a>';
930 930
                 }
931 931
             }
932
-            if($flag == '3'){
933
-		return '<a href="' . $link . '" class="btn btn-royelblue btn-sm" title="Delete" onClick="return get_alert_message(0,null,'.$linkid.',3);">
932
+            if ($flag == '3') {
933
+		return '<a href="'.$link.'" class="btn btn-royelblue btn-sm" title="Delete" onClick="return get_alert_message(0,null,'.$linkid.',3);">
934 934
 		<i class="fa fa-trash fa-fw"></i></a>';
935 935
             }
936
-            if($flag == '4'){
937
-		return '<a href="' . $link . '" class="btn btn-royelblue btn-sm" title="Delete" onClick="return get_alert_message(0,null,'.$linkid.',4);">
936
+            if ($flag == '4') {
937
+		return '<a href="'.$link.'" class="btn btn-royelblue btn-sm" title="Delete" onClick="return get_alert_message(0,null,'.$linkid.',4);">
938 938
 		<i class="fa fa-trash fa-fw"></i></a>';
939 939
             }
940
-            if($flag=='0' && $url.$linkid !='accounts/admin_delete/1' ){
941
-                return '<a href="' . $link . '" class="btn btn-royelblue btn-sm" title="Delete" onClick="return get_alert_msg();"><i class="fa fa-trash fa-fw"></i></a>';
940
+            if ($flag == '0' && $url.$linkid != 'accounts/admin_delete/1') {
941
+                return '<a href="'.$link.'" class="btn btn-royelblue btn-sm" title="Delete" onClick="return get_alert_msg();"><i class="fa fa-trash fa-fw"></i></a>';
942 942
             }  
943 943
     }
944 944
 
945 945
     function build_view_button($button_params, $linkid) {
946
-        $link = base_url() . $button_params->url . "" . $linkid;
946
+        $link = base_url().$button_params->url."".$linkid;
947 947
         if ($button_params->mode == 'popup') {
948
-			$rel = (isset($button_params->layout) && $button_params->layout != '')?"facebox_".$button_params->layout:"facebox";
949
-            return '<a href="' . $link . '" class="btn btn-royelblue btn-sm" rel="'.$rel.'" title="View Details"><i class="fa fa-reorder fa-fw"></i></a>&nbsp;';
948
+			$rel = (isset($button_params->layout) && $button_params->layout != '') ? "facebox_".$button_params->layout : "facebox";
949
+            return '<a href="'.$link.'" class="btn btn-royelblue btn-sm" rel="'.$rel.'" title="View Details"><i class="fa fa-reorder fa-fw"></i></a>&nbsp;';
950 950
         } else {
951
-            return '<a href="' . $link . '" class="btn btn-royelblue btn-sm" title="View Details"><i class="fa fa-reorder fa-fw"></i></a>&nbsp;';
951
+            return '<a href="'.$link.'" class="btn btn-royelblue btn-sm" title="View Details"><i class="fa fa-reorder fa-fw"></i></a>&nbsp;';
952 952
         }
953 953
     }
954 954
 
955 955
     function build_add_taxes_button($button_params, $linkid) {
956
-        $link = base_url() . $button_params->url . "" . $linkid;
956
+        $link = base_url().$button_params->url."".$linkid;
957 957
         if ($button_params->mode == 'popup') {
958
-            return '<a href="' . $link . '" class="btn btn-royelblue btn-sm" rel="facebox" title="Add Account Taxes"><i class="fa fa-reorder fa-fw"></i></a>&nbsp;';
958
+            return '<a href="'.$link.'" class="btn btn-royelblue btn-sm" rel="facebox" title="Add Account Taxes"><i class="fa fa-reorder fa-fw"></i></a>&nbsp;';
959 959
         } else {
960
-            return '<a href="' . $link . '" class="btn btn-royelblue btn-sm" title="Add Account Taxes"><i class="fa fa-reorder fa-fw"></i></a>&nbsp;';
960
+            return '<a href="'.$link.'" class="btn btn-royelblue btn-sm" title="Add Account Taxes"><i class="fa fa-reorder fa-fw"></i></a>&nbsp;';
961 961
         }
962 962
     }
963 963
 
964 964
     function build_add_download_database_button($url, $linkid) {
965
-        $link = base_url() . $url . "" . $linkid;
966
-        return '<a href="' . $link . '" class="btn btn-royelblue btn-sm "  title="Download Database" ><i class="fa-fw fa fa-file-archive-o"></i></a>&nbsp;';
965
+        $link = base_url().$url."".$linkid;
966
+        return '<a href="'.$link.'" class="btn btn-royelblue btn-sm "  title="Download Database" ><i class="fa-fw fa fa-file-archive-o"></i></a>&nbsp;';
967 967
     }
968 968
 
969 969
     function build_add_callerid_button($button_params, $linkid) {
970
-        $link = base_url() . $button_params->url . "" . $linkid;
970
+        $link = base_url().$button_params->url."".$linkid;
971 971
         if ($button_params->mode == 'popup') {
972
-            return '<a href="' . $link . '" class="btn btn-royelblue btn-sm" rel="facebox" title="Force Caller Id"><i class="fa fa-mobile-phone fa-fw"></i></a>&nbsp;';
972
+            return '<a href="'.$link.'" class="btn btn-royelblue btn-sm" rel="facebox" title="Force Caller Id"><i class="fa fa-mobile-phone fa-fw"></i></a>&nbsp;';
973 973
         } else {
974
-            return '<a href="' . $link . '" class="btn btn-royelblue btn-sm" title="CallerID"><i class="fa fa-mobile-phone fa-fw"></i></a>&nbsp;';
974
+            return '<a href="'.$link.'" class="btn btn-royelblue btn-sm" title="CallerID"><i class="fa fa-mobile-phone fa-fw"></i></a>&nbsp;';
975 975
         }
976 976
     }
977 977
 
978 978
     function build_start_button($url, $linkid) {
979
-        $link = base_url() . $url . "" . $linkid;
979
+        $link = base_url().$url."".$linkid;
980 980
 
981
-        return '<a href="' . $link . '" class=""  title="Start" style="text-decoration:none;color: #428BCA;"><b>Start |</b></a>&nbsp;';
981
+        return '<a href="'.$link.'" class=""  title="Start" style="text-decoration:none;color: #428BCA;"><b>Start |</b></a>&nbsp;';
982 982
     }
983 983
 
984 984
     function build_stop_button($url, $linkid) {
985
-        $link = base_url() . $url . "" . $linkid;
986
-        return '<a href="' . $link . '" class=""  title="Stop" style="text-decoration:none;color: #428BCA;" ><b>Stop |</b></a>&nbsp;';
985
+        $link = base_url().$url."".$linkid;
986
+        return '<a href="'.$link.'" class=""  title="Stop" style="text-decoration:none;color: #428BCA;" ><b>Stop |</b></a>&nbsp;';
987 987
     }
988 988
 
989 989
     function build_reload_button($url, $linkid) {
990
-        $link = base_url() . $url . "" . $linkid;
991
-        return '<a href="' . $link . '" class=""  title="reload" style="text-decoration:none;color: #428BCA;"><b>Reload |</b></a>&nbsp;';
990
+        $link = base_url().$url."".$linkid;
991
+        return '<a href="'.$link.'" class=""  title="reload" style="text-decoration:none;color: #428BCA;"><b>Reload |</b></a>&nbsp;';
992 992
     }
993 993
 
994 994
     function build_rescan_button($url, $linkid) {
995
-        $link = base_url() . $url . "" . $linkid;
996
-        return '<a href="' . $link . '" class=""  title="rescan" style="text-decoration:none;color: #428BCA;"><b>Rescan</b></a>&nbsp;';
995
+        $link = base_url().$url."".$linkid;
996
+        return '<a href="'.$link.'" class=""  title="rescan" style="text-decoration:none;color: #428BCA;"><b>Rescan</b></a>&nbsp;';
997 997
     }
998 998
 
999 999
     function build_add_payment_button($url, $linkid) {
1000
-        $link = base_url() . $url . "" . $linkid;
1001
-        return '<a href="' . $link . '" class="btn btn-royelblue btn-sm" rel="facebox" title="Refill" ><i class="fa fa-usd fa-fw"></i></a>&nbsp;';
1000
+        $link = base_url().$url."".$linkid;
1001
+        return '<a href="'.$link.'" class="btn btn-royelblue btn-sm" rel="facebox" title="Refill" ><i class="fa fa-usd fa-fw"></i></a>&nbsp;';
1002 1002
     }
1003 1003
 
1004 1004
     function build_add_download_button($url, $linkid) {
1005
-        $link = base_url() . $url . "" . $linkid;
1006
-        return '<a href="' . $link . '" class="btn btn-royelblue btn-sm"  title="Download Invoice" ><i class="fa fa-cloud-download fa-fw"></i></a>&nbsp;';
1005
+        $link = base_url().$url."".$linkid;
1006
+        return '<a href="'.$link.'" class="btn btn-royelblue btn-sm"  title="Download Invoice" ><i class="fa fa-cloud-download fa-fw"></i></a>&nbsp;';
1007 1007
     }
1008 1008
 
1009 1009
     /*
@@ -1012,11 +1012,11 @@  discard block
 block discarded – undo
1012 1012
      */
1013 1013
 
1014 1014
     function build_edit_button_resend($button_params, $linkid) {
1015
-        $link = base_url() . $button_params->url . "" . $linkid;
1015
+        $link = base_url().$button_params->url."".$linkid;
1016 1016
         if ($button_params->mode == 'popup') {
1017
-            return '<a href="' . $link . '" class="btn btn-royelblue btn-sm" rel="facebox" title="Resend Mail"><i class="fa fa-repeat"></i></a>&nbsp;';
1017
+            return '<a href="'.$link.'" class="btn btn-royelblue btn-sm" rel="facebox" title="Resend Mail"><i class="fa fa-repeat"></i></a>&nbsp;';
1018 1018
         } else {
1019
-            return '<a href="' . $link . '" class="btn btn-royelblue btn-sm" title="Resend Mail"><i class="fa fa-repeat"></i></a>&nbsp;';
1019
+            return '<a href="'.$link.'" class="btn btn-royelblue btn-sm" title="Resend Mail"><i class="fa fa-repeat"></i></a>&nbsp;';
1020 1020
         }
1021 1021
     }
1022 1022
 
@@ -1031,17 +1031,17 @@  discard block
 block discarded – undo
1031 1031
     function mail_to_users($type, $accountinfo, $attachment = "", $amount = "") {
1032 1032
 		$subject = "";
1033 1033
         $settings_reply_email = '[email protected]';
1034
-        $reseller_id=$accountinfo['reseller_id'] > 0 ? $accountinfo['reseller_id'] : 0;
1035
-		$where="accountid IN ('".$reseller_id."','1')";
1034
+        $reseller_id = $accountinfo['reseller_id'] > 0 ? $accountinfo['reseller_id'] : 0;
1035
+		$where = "accountid IN ('".$reseller_id."','1')";
1036 1036
         $this->CI->db->where($where);
1037 1037
         $this->CI->db->select('emailaddress');
1038 1038
         $this->CI->db->order_by('accountid', 'desc');
1039 1039
         $this->CI->db->limit(1);
1040 1040
         $invoiceconf = $this->CI->db->get('invoice_conf');
1041 1041
         $invoiceconf = (array)$invoiceconf->first_row();
1042
-        $settings_reply_email=$invoiceconf['emailaddress'];
1043
-        $company_name=Common_model::$global_config['system_config']['company_name'];
1044
-        $company_website=Common_model::$global_config['system_config']['company_website'];
1042
+        $settings_reply_email = $invoiceconf['emailaddress'];
1043
+        $company_name = Common_model::$global_config['system_config']['company_name'];
1044
+        $company_website = Common_model::$global_config['system_config']['company_website'];
1045 1045
         $where = array('name' => $type);
1046 1046
         $query = $this->CI->db_model->getSelect("*", "default_templates", $where);
1047 1047
         $query = $query->result();
@@ -1052,106 +1052,106 @@  discard block
 block discarded – undo
1052 1052
         $message = str_replace("#COMPANY_NAME#", $company_name, $message);
1053 1053
         $message = str_replace("#COMPANY_WEBSITE#", $company_website, $message);
1054 1054
         $message = str_replace("</p>", "", $message);
1055
-		if(isset($accountinfo['refill_amount']) && $accountinfo['refill_amount']!= ""){
1055
+		if (isset($accountinfo['refill_amount']) && $accountinfo['refill_amount'] != "") {
1056 1056
 			$refillamount = $accountinfo['refill_amount'];
1057
-		}else{
1057
+		} else {
1058 1058
 			$refillamount = "0";
1059 1059
 		}
1060 1060
 		
1061 1061
         switch ($type) {
1062 1062
             case 'email_add_user':
1063
-                $message = str_replace('#NAME#', $accountinfo['first_name'] . " " . $accountinfo['last_name'], $message);
1063
+                $message = str_replace('#NAME#', $accountinfo['first_name']." ".$accountinfo['last_name'], $message);
1064 1064
                 $message = str_replace('#NUMBER#', $accountinfo['number'], $message);
1065 1065
                 $message = str_replace('#PASSWORD#', $accountinfo['password'], $message);
1066 1066
                 $message = str_replace('#LINK#', $accountinfo['confirm'], $message);
1067 1067
                 break;
1068 1068
             case 'email_forgot_user':
1069
-                $message = str_replace('#NAME#', $accountinfo['first_name'] . " " . $accountinfo['last_name'], $message);
1069
+                $message = str_replace('#NAME#', $accountinfo['first_name']." ".$accountinfo['last_name'], $message);
1070 1070
                 $message = str_replace('#NUMBER#', $accountinfo['number'], $message);
1071 1071
                 $message = str_replace('#PASSWORD#', $accountinfo['password'], $message);
1072 1072
                 $message = str_replace('#LINK#', $accountinfo['link'], $message);
1073 1073
                 break;
1074 1074
 
1075 1075
             case 'email_forgot_confirmation':
1076
-                $message = str_replace('#NAME#', $accountinfo['first_name'] . " " . $accountinfo['last_name'], $message);
1076
+                $message = str_replace('#NAME#', $accountinfo['first_name']." ".$accountinfo['last_name'], $message);
1077 1077
                 $message = str_replace('#CONFIRM#', $accountinfo['confirm'], $message);
1078 1078
                 break;
1079 1079
 
1080 1080
             case 'email_signup_confirmation':
1081
-                $message = str_replace('#NAME#', $accountinfo['first_name'] . " " . $accountinfo['last_name'], $message);
1081
+                $message = str_replace('#NAME#', $accountinfo['first_name']." ".$accountinfo['last_name'], $message);
1082 1082
                 $message = str_replace('#CONFIRM#', $accountinfo['confirm'], $message);
1083 1083
                 break;
1084 1084
             case 'add_sip_device':
1085
-                $message = str_replace('#NAME#', $accountinfo['first_name'] . " " . $accountinfo['last_name'], $message);
1085
+                $message = str_replace('#NAME#', $accountinfo['first_name']." ".$accountinfo['last_name'], $message);
1086 1086
                 $message = str_replace('#USERNAME#', $accountinfo['number'], $message);
1087 1087
                 $message = str_replace('#PASSWORD#', $accountinfo['password'], $message);
1088 1088
                 break;
1089 1089
                               
1090 1090
             case 'voip_account_refilled':
1091
-                $message = str_replace('#NAME#', $accountinfo['first_name'] . " " . $accountinfo['last_name'], $message);
1091
+                $message = str_replace('#NAME#', $accountinfo['first_name']." ".$accountinfo['last_name'], $message);
1092 1092
                 $message = str_replace('#REFILLBALANCE#', $accountinfo['refill_amount'], $message);
1093 1093
                 $message = str_replace('#BALANCE#', $accountinfo['refill_amount'] + $accountinfo['balance'], $message);
1094 1094
                 break;
1095 1095
             case 'voip_child_account_refilled':
1096
-                $reseller_number= $this->CI->common->get_field_name('number', 'accounts', $accountinfo['reseller_id']);
1097
-                $message = str_replace('#NAME#', $accountinfo['first_name'] . " " . $accountinfo['last_name'], $message);
1096
+                $reseller_number = $this->CI->common->get_field_name('number', 'accounts', $accountinfo['reseller_id']);
1097
+                $message = str_replace('#NAME#', $accountinfo['first_name']." ".$accountinfo['last_name'], $message);
1098 1098
                 $message = str_replace('#REFILLBALANCE#', $accountinfo['refill_amount'], $message);
1099 1099
                 $message = str_replace('#BALANCE#', $accountinfo['balance'], $message);
1100
-                $message = str_replace('#ACCOUNTNUMBER#',$reseller_number, $message);
1100
+                $message = str_replace('#ACCOUNTNUMBER#', $reseller_number, $message);
1101 1101
                 break;
1102 1102
             case 'add_subscription':
1103
-                $message = str_replace('#NAME#', $accountinfo['first_name'] . " " . $accountinfo['last_name'], $message);
1103
+                $message = str_replace('#NAME#', $accountinfo['first_name']." ".$accountinfo['last_name'], $message);
1104 1104
                 break;
1105 1105
             case 'remove_subscription':
1106
-                $message = str_replace('#NAME#', $accountinfo['first_name'] . " " . $accountinfo['last_name'], $message);
1106
+                $message = str_replace('#NAME#', $accountinfo['first_name']." ".$accountinfo['last_name'], $message);
1107 1107
                 break;
1108 1108
             case 'add_package':
1109
-                $message = str_replace('#NAME#', $accountinfo['first_name'] . " " . $accountinfo['last_name'], $message);
1109
+                $message = str_replace('#NAME#', $accountinfo['first_name']." ".$accountinfo['last_name'], $message);
1110 1110
                 break;
1111 1111
             case 'remove_package':
1112
-                $message = str_replace('#NAME#', $accountinfo['first_name'] . " " . $accountinfo['last_name'], $message);
1112
+                $message = str_replace('#NAME#', $accountinfo['first_name']." ".$accountinfo['last_name'], $message);
1113 1113
                 break;
1114 1114
             case 'email_calling_card':
1115
-                $message = str_replace('#NAME#', $accountinfo['first_name'] . " " . $accountinfo['last_name'], $message);
1115
+                $message = str_replace('#NAME#', $accountinfo['first_name']." ".$accountinfo['last_name'], $message);
1116 1116
                 $message = str_replace('#CARDNUMBER#', $accountinfo['cardnumber'], $message);
1117 1117
                 $message = str_replace('#PIN#', $accountinfo['pin'], $message);
1118 1118
                 $message = str_replace('#BALANCE#', $accountinfo['balance'], $message);
1119 1119
                 break;
1120 1120
             case 'email_low_balance';
1121
-                $message = str_replace('#NAME#', $accountinfo['first_name'] . " " . $accountinfo['last_name'], $message);
1121
+                $message = str_replace('#NAME#', $accountinfo['first_name']." ".$accountinfo['last_name'], $message);
1122 1122
                 $to_currency = $this->CI->common->get_field_name('currency', 'currency', $accountinfo['currency_id']);
1123 1123
                 $balance = $this->CI->common_model->calculate_currency($accountinfo['balance'], "", $to_currency, true, true);
1124 1124
                 $message = str_replace('#BALANCE#', $accountinfo['balance'], $message);
1125 1125
                 break;
1126 1126
             case 'email_new_invoice';
1127
-                $message = str_replace('#NAME#', $accountinfo['first_name'] . " " . $accountinfo['last_name'], $message);
1127
+                $message = str_replace('#NAME#', $accountinfo['first_name']." ".$accountinfo['last_name'], $message);
1128 1128
                 $message = str_replace('#AMOUNT#', $amount, $message);
1129 1129
                 $message = str_replace('#INVOICE_NUMBER#', $amount, $message);
1130 1130
                 $subject = $query[0]->subject;
1131 1131
                 $subject = str_replace("#INVOICE_NUMBER#", $amount, $subject);
1132 1132
                 break;
1133 1133
              case 'email_add_did';
1134
-				if(isset($accountinfo['did_maxchannels']) && $accountinfo['did_maxchannels']!= ""){
1134
+				if (isset($accountinfo['did_maxchannels']) && $accountinfo['did_maxchannels'] != "") {
1135 1135
 					$accountinfo['did_maxchannels'] = $accountinfo['did_maxchannels'];
1136
-				}else if($accountinfo['did_maxchannels'] == "0"){
1136
+				} else if ($accountinfo['did_maxchannels'] == "0") {
1137 1137
 							$accountinfo['did_maxchannels'] = "Unlimited";
1138
-				}else{
1138
+				} else {
1139 1139
 					$accountinfo['did_maxchannels'] = "Unlimited";
1140 1140
 				}
1141
-                $message = str_replace('#NAME#', $accountinfo['first_name'] . " " . $accountinfo['last_name'], $message);
1142
-                $message = str_replace('#DIDNUMBER#', $accountinfo['did_number'] , $message);
1143
-                $message = str_replace('#COUNTRYNAME#',$accountinfo['did_country_id'], $message);
1144
-                $message = str_replace('#SETUPFEE#',$accountinfo['did_setup'], $message);
1145
-                $message = str_replace('#MONTHLYFEE#',$accountinfo['did_monthlycost'], $message);
1146
-                $message = str_replace('#MAXCHANNEL#',$accountinfo['did_maxchannels'], $message);
1141
+                $message = str_replace('#NAME#', $accountinfo['first_name']." ".$accountinfo['last_name'], $message);
1142
+                $message = str_replace('#DIDNUMBER#', $accountinfo['did_number'], $message);
1143
+                $message = str_replace('#COUNTRYNAME#', $accountinfo['did_country_id'], $message);
1144
+                $message = str_replace('#SETUPFEE#', $accountinfo['did_setup'], $message);
1145
+                $message = str_replace('#MONTHLYFEE#', $accountinfo['did_monthlycost'], $message);
1146
+                $message = str_replace('#MAXCHANNEL#', $accountinfo['did_maxchannels'], $message);
1147 1147
                 $message = str_replace('#NUMBER#', $accountinfo['number'], $message);	
1148 1148
 				$subject = $query[0]->subject;
1149 1149
 				$subject = str_replace("#NUMBER#", $accountinfo['number'], $subject);
1150 1150
 				$subject = str_replace("#DIDNUMBER#", $accountinfo['did_number'], $subject);
1151 1151
                 break;
1152 1152
             case 'email_remove_did';
1153
-                $message = str_replace('#NAME#', $accountinfo['first_name'] . " " . $accountinfo['last_name'], $message);
1154
-                $message = str_replace('#DIDNUMBER#', $accountinfo['did_number'],$message);
1153
+                $message = str_replace('#NAME#', $accountinfo['first_name']." ".$accountinfo['last_name'], $message);
1154
+                $message = str_replace('#DIDNUMBER#', $accountinfo['did_number'], $message);
1155 1155
                 $message = str_replace('#NUMBER#', $accountinfo['number'], $message);	
1156 1156
 				$subject = $query[0]->subject;
1157 1157
 				$subject = str_replace("#NUMBER#", $accountinfo['number'], $subject);
@@ -1159,9 +1159,9 @@  discard block
 block discarded – undo
1159 1159
                 break;
1160 1160
         }
1161 1161
         
1162
-        if($subject == ""){
1162
+        if ($subject == "") {
1163 1163
 			$subject = $query[0]->subject;
1164
-			$subject = str_replace("#NAME#", $accountinfo['first_name'] . " " . $accountinfo['last_name'], $subject);
1164
+			$subject = str_replace("#NAME#", $accountinfo['first_name']." ".$accountinfo['last_name'], $subject);
1165 1165
 			$subject = str_replace("#COMPANY_NAME#", $company_name, $subject);	
1166 1166
 		}
1167 1167
         $account_id = (isset($accountinfo['last_id']) && $accountinfo['last_id'] != "") ? $accountinfo['last_id'] : $accountinfo['id'];
@@ -1245,13 +1245,13 @@  discard block
 block discarded – undo
1245 1245
         $result = $this->CI->db->get('invoice_details');
1246 1246
         if ($result->num_rows() > 0) {
1247 1247
             $result = $result->result_array();
1248
-	    if($select == 'debit'){
1249
-		if($result[0]['item_type'] == 'POSTCHARG'){
1248
+	    if ($select == 'debit') {
1249
+		if ($result[0]['item_type'] == 'POSTCHARG') {
1250 1250
 	            return $this->convert_to_currency('', '', $result[0]['debit']);
1251
-		}else{
1251
+		} else {
1252 1252
 	            return $this->convert_to_currency('', '', $result[0]['credit']);
1253 1253
 		}
1254
-	    }else{
1254
+	    } else {
1255 1255
 		   return $result[0][$select];
1256 1256
 	    }
1257 1257
         } else {
@@ -1302,7 +1302,7 @@  discard block
 block discarded – undo
1302 1302
 
1303 1303
             $timezone_result = $timezone_result->result_array();
1304 1304
             foreach ($timezone_result as $data) {
1305
-                $gmtoffset+=$data['gmtoffset'];
1305
+                $gmtoffset += $data['gmtoffset'];
1306 1306
             }
1307 1307
         }
1308 1308
 // 	  echo $gmtoffset;exit;
@@ -1366,7 +1366,7 @@  discard block
 block discarded – undo
1366 1366
     }
1367 1367
 
1368 1368
     function get_refill_coupon_used($select = '', $table = '', $status) {
1369
-        return $status['status'] == 2 ? '<img src= "'.base_url().'assets/images/true.png" style="height:20px;width:20px;" title="Yes">' : '<img src= "'. base_url().'/assets/images/false.png" style="height:20px;width:20px;" title="No">';
1369
+        return $status['status'] == 2 ? '<img src= "'.base_url().'assets/images/true.png" style="height:20px;width:20px;" title="Yes">' : '<img src= "'.base_url().'/assets/images/false.png" style="height:20px;width:20px;" title="No">';
1370 1370
     }
1371 1371
 
1372 1372
     /*     * *******
@@ -1444,20 +1444,20 @@  discard block
 block discarded – undo
1444 1444
         $status_array = array('0' => 'Enable', '1' => 'Disable');
1445 1445
         return $status_array;
1446 1446
     }
1447
-    function custom_status($status){
1447
+    function custom_status($status) {
1448 1448
 		$status_array = array('0' => 'Yes', '1' => 'No');
1449 1449
         return $status_array;
1450 1450
     }
1451 1451
     
1452
-    function custom_status_active($status){
1452
+    function custom_status_active($status) {
1453 1453
       $status_array = array('0' => 'Active', '1' => 'InActive');
1454 1454
       return $status_array;
1455 1455
     }
1456
-    function custom_status_true($status){
1456
+    function custom_status_true($status) {
1457 1457
       $status_array = array('0' => 'TRUE', '1' => 'FALSE');
1458 1458
       return $status_array;
1459 1459
     }
1460
-    function custom_status_voicemail($status){
1460
+    function custom_status_voicemail($status) {
1461 1461
       $status_array = array('true' => 'True', 'false' => 'False');
1462 1462
       return $status_array;
1463 1463
     }
@@ -1484,7 +1484,7 @@  discard block
 block discarded – undo
1484 1484
         return $status_array;
1485 1485
     }
1486 1486
 	
1487
-    function enable_disable_option(){
1487
+    function enable_disable_option() {
1488 1488
         $option_array = array('0' => 'Enable', '1' => 'Disable');
1489 1489
         return $option_array;
1490 1490
     }
@@ -1512,14 +1512,14 @@  discard block
 block discarded – undo
1512 1512
         $status_array = array('1' => 'Enable', '0' => 'Disable',);
1513 1513
         return $status_array;
1514 1514
     }
1515
-    function default_signup_rategroup(){
1515
+    function default_signup_rategroup() {
1516 1516
         $this->CI->db->select("id,name");
1517
-        $this->CI->db->where("status",0);
1518
-        $this->CI->db->where("reseller_id",0);
1519
-        $pricelist_result=$this->CI->db->get("pricelists")->result_array();
1520
-        $pricelist_arr=array();
1521
-        foreach($pricelist_result as $result){
1522
-            $pricelist_arr[$result['id']]=$result['name'];
1517
+        $this->CI->db->where("status", 0);
1518
+        $this->CI->db->where("reseller_id", 0);
1519
+        $pricelist_result = $this->CI->db->get("pricelists")->result_array();
1520
+        $pricelist_arr = array();
1521
+        foreach ($pricelist_result as $result) {
1522
+            $pricelist_arr[$result['id']] = $result['name'];
1523 1523
         }
1524 1524
         return $pricelist_arr;
1525 1525
         
@@ -1593,17 +1593,17 @@  discard block
 block discarded – undo
1593 1593
       Calculate Currency manually.
1594 1594
      */
1595 1595
 
1596
-    function calculate_currency_manually($currency_info, $amount, $show_currency_flag = true,$number_format=true) {
1596
+    function calculate_currency_manually($currency_info, $amount, $show_currency_flag = true, $number_format = true) {
1597 1597
         $decimal_points = $currency_info['decimalpoints'];
1598 1598
         $system_currency_rate = $currency_info['base_currency']['currencyrate'];
1599 1599
         $user_currency_rate = $currency_info['user_currency']['currencyrate'];
1600
-        $calculated_amount=(float)(($amount * $currency_info['user_currency']['currencyrate']) / $currency_info['base_currency']['currencyrate']); 
1601
-        if($number_format){
1602
-         $calculated_amount = number_format($calculated_amount,$currency_info['decimalpoints']);
1600
+        $calculated_amount = (float)(($amount * $currency_info['user_currency']['currencyrate']) / $currency_info['base_currency']['currencyrate']); 
1601
+        if ($number_format) {
1602
+         $calculated_amount = number_format($calculated_amount, $currency_info['decimalpoints']);
1603 1603
         }
1604
-        if ($show_currency_flag){
1604
+        if ($show_currency_flag) {
1605 1605
           return $calculated_amount." ".$currency_info['user_currency']['currency'];
1606
-        }else{
1606
+        } else {
1607 1607
           return $calculated_amount;
1608 1608
         }
1609 1609
     }
@@ -1618,7 +1618,7 @@  discard block
 block discarded – undo
1618 1618
     }
1619 1619
 
1620 1620
     function set_summarycustomer_groupby($status = '') {
1621
-        $status_array = array('' => "--Select--", 'accountid' => 'Account', 'pattern' => 'Code','package_id'=>"Package");
1621
+        $status_array = array('' => "--Select--", 'accountid' => 'Account', 'pattern' => 'Code', 'package_id'=>"Package");
1622 1622
         return $status_array;
1623 1623
     }
1624 1624
 
@@ -1634,7 +1634,7 @@  discard block
 block discarded – undo
1634 1634
         $accountinfo = $this->CI->session->userdata('accountinfo');
1635 1635
         //Get User Currency id 
1636 1636
         $user_currency_id = $accountinfo['currency_id'] > 0 ? $accountinfo['currency_id'] : $base_currency;
1637
-        $where = "currency = '" . $base_currency . "' OR id= " . $user_currency_id;
1637
+        $where = "currency = '".$base_currency."' OR id= ".$user_currency_id;
1638 1638
         $this->CI->db->where($where);
1639 1639
         $this->CI->db->select('*');
1640 1640
         $currency_result = $this->CI->db->get('currency');
@@ -1652,7 +1652,7 @@  discard block
 block discarded – undo
1652 1652
                 }
1653 1653
             }
1654 1654
         } else if ($currency_result->num_rows() == 1) {
1655
-            $currency_info['user_currency'] = $currency_info['base_currency'] = (array) $currency_result->first_row();
1655
+            $currency_info['user_currency'] = $currency_info['base_currency'] = (array)$currency_result->first_row();
1656 1656
         }
1657 1657
         //Get Decimal points as per defined from system.
1658 1658
         $currency_info['decimalpoints'] = Common_model::$global_config['system_config']['decimalpoints'];
@@ -1661,15 +1661,15 @@  discard block
 block discarded – undo
1661 1661
 
1662 1662
     function convert_to_show_in($search_name = "", $table = "", $second) {
1663 1663
         $search_arr = $this->CI->session->userdata($search_name);
1664
-        $show_seconds = (!empty($search_arr['search_in'])) ? $search_arr['search_in'] : 'minutes';
1665
-        return ($show_seconds === 'minutes') ? ($second > 0 ) ?
1666
-                        sprintf('%02d',$second / 60) . ":" . sprintf('%02d', ($second % 60)) : "00:00"  : sprintf('%02d', $second);
1664
+        $show_seconds = ( ! empty($search_arr['search_in'])) ? $search_arr['search_in'] : 'minutes';
1665
+        return ($show_seconds === 'minutes') ? ($second > 0) ?
1666
+                        sprintf('%02d', $second / 60).":".sprintf('%02d', ($second % 60)) : "00:00" : sprintf('%02d', $second);
1667 1667
     }
1668 1668
 
1669 1669
     function array_column($input, $columnKey, $indexKey = null) {
1670 1670
         $array = array();
1671 1671
         foreach ($input as $value) {
1672
-            if (!isset($value[$columnKey])) {
1672
+            if ( ! isset($value[$columnKey])) {
1673 1673
                 trigger_error("Key \"$columnKey\" does not exist in array");
1674 1674
                 return false;
1675 1675
             }
@@ -1677,11 +1677,11 @@  discard block
 block discarded – undo
1677 1677
             if (is_null($indexKey)) {
1678 1678
                 $array[] = $value[$columnKey];
1679 1679
             } else {
1680
-                if (!isset($value[$indexKey])) {
1680
+                if ( ! isset($value[$indexKey])) {
1681 1681
                     trigger_error("Key \"$indexKey\" does not exist in array");
1682 1682
                     return false;
1683 1683
                 }
1684
-                if (!is_scalar($value[$indexKey])) {
1684
+                if ( ! is_scalar($value[$indexKey])) {
1685 1685
                     trigger_error("Key \"$indexKey\" does not contain scalar value");
1686 1686
                     return false;
1687 1687
                 }
@@ -1698,22 +1698,22 @@  discard block
 block discarded – undo
1698 1698
     }
1699 1699
 
1700 1700
     function currency_decimal($amount) {
1701
-		$amount = str_replace( ',', '', $amount );
1701
+		$amount = str_replace(',', '', $amount);
1702 1702
         $decimal_amount = Common_model::$global_config['system_config']['decimalpoints'];
1703
-        $number_convert = number_format((float) $amount, $decimal_amount, '.', '');
1703
+        $number_convert = number_format((float)$amount, $decimal_amount, '.', '');
1704 1704
         return $number_convert;
1705 1705
     }
1706 1706
 
1707
-    function add_invoice_details($account_arr, $charge_type, $amount,$description) {
1707
+    function add_invoice_details($account_arr, $charge_type, $amount, $description) {
1708 1708
         $accountinfo = $this->CI->session->userdata('accountinfo');
1709 1709
         $reseller_id = $accountinfo['type'] == 1 ? $accountinfo['id'] : 0;
1710
-        $where = "accountid IN ('" . $reseller_id . "','1')";
1710
+        $where = "accountid IN ('".$reseller_id."','1')";
1711 1711
         $this->CI->db->where($where);
1712 1712
         $this->CI->db->select('*');
1713 1713
         $this->CI->db->order_by('accountid', 'desc');
1714 1714
         $this->CI->db->limit(1);
1715 1715
         $invoiceconf = $this->CI->db->get('invoice_conf');
1716
-        $invoice_conf = (array) $invoiceconf->first_row();
1716
+        $invoice_conf = (array)$invoiceconf->first_row();
1717 1717
         $last_invoiceid = $this->get_invoice_date('invoiceid', '', $account_arr['reseller_id']);
1718 1718
         if ($last_invoiceid && $last_invoiceid > 0) {
1719 1719
             $last_invoiceid = ($last_invoiceid + 1);
@@ -1722,7 +1722,7 @@  discard block
 block discarded – undo
1722 1722
         }
1723 1723
         $last_invoiceid = str_pad($last_invoiceid, (strlen($last_invoiceid) + 4), '0', STR_PAD_LEFT);
1724 1724
         $invoice_prefix = $invoice_conf['invoice_prefix'];
1725
-        $due_date = gmdate("Y-m-d H:i:s", strtotime(gmdate("Y-m-d H:i:s") . " +" . $invoice_conf['interval'] . " days"));
1725
+        $due_date = gmdate("Y-m-d H:i:s", strtotime(gmdate("Y-m-d H:i:s")." +".$invoice_conf['interval']." days"));
1726 1726
         $invoiceid = $account_arr['posttoexternal'] == 0 ? $this->CI->common_model->generate_receipt($account_arr['id'], $amount, $account_arr, $last_invoiceid, $invoice_prefix, $due_date) : 0;
1727 1727
         
1728 1728
         $insert_arr = array("accountid" => $account_arr['id'],
@@ -1740,111 +1740,111 @@  discard block
 block discarded – undo
1740 1740
     }
1741 1741
     /* ASTPP  3.0  Remove all information related to going to delete customer.
1742 1742
      */
1743
-    function customer_delete_dependencies($id){
1744
-          $this->delete_data('ani_map',array('accountid'=>$id));
1745
-          $this->delete_data('block_patterns',array('accountid'=>$id));
1746
-          $this->delete_data('charge_to_account',array('accountid'=>$id));
1747
-          $this->delete_data('counters',array('accountid'=>$id));
1748
-          $this->delete_data('ip_map',array('accountid'=>$id));
1749
-          $this->delete_data('sip_devices',array('accountid'=>$id));
1750
-          $this->delete_data('speed_dial',array('accountid'=>$id));
1751
-          $this->delete_data('taxes_to_accounts',array('accountid'=>$id));
1752
-          $this->delete_data('mail_details',array('accountid'=>$id));
1753
-          $this->update_data('dids',array("accountid"=>$id),array('accountid'=>0));
1754
-          $this->update_data("accounts",array("id"=>$id),array("deleted"=>1));
1743
+    function customer_delete_dependencies($id) {
1744
+          $this->delete_data('ani_map', array('accountid'=>$id));
1745
+          $this->delete_data('block_patterns', array('accountid'=>$id));
1746
+          $this->delete_data('charge_to_account', array('accountid'=>$id));
1747
+          $this->delete_data('counters', array('accountid'=>$id));
1748
+          $this->delete_data('ip_map', array('accountid'=>$id));
1749
+          $this->delete_data('sip_devices', array('accountid'=>$id));
1750
+          $this->delete_data('speed_dial', array('accountid'=>$id));
1751
+          $this->delete_data('taxes_to_accounts', array('accountid'=>$id));
1752
+          $this->delete_data('mail_details', array('accountid'=>$id));
1753
+          $this->update_data('dids', array("accountid"=>$id), array('accountid'=>0));
1754
+          $this->update_data("accounts", array("id"=>$id), array("deleted"=>1));
1755 1755
     }
1756 1756
     /*
1757 1757
      *  ASTPP  3.0 
1758 1758
      *  Remove all information related to going to delete reseller.
1759 1759
      */
1760
-    function reseller_delete_dependencies($id){
1761
-        $accountinfo=$this->CI->session->userdata('accountinfo');
1762
-        $child_arr=$this->select_data("accounts",array("reseller_id"=>$id,"type"=>0),'id,reseller_id');
1763
-        if($child_arr){
1764
-            foreach($child_arr as $value){
1760
+    function reseller_delete_dependencies($id) {
1761
+        $accountinfo = $this->CI->session->userdata('accountinfo');
1762
+        $child_arr = $this->select_data("accounts", array("reseller_id"=>$id, "type"=>0), 'id,reseller_id');
1763
+        if ($child_arr) {
1764
+            foreach ($child_arr as $value) {
1765 1765
                 $this->customer_delete_dependencies($value['id']);
1766 1766
             }
1767 1767
         }
1768
-        $package_arr=$this->select_data("packages",array("reseller_id"=>$id),'id');
1769
-        if($package_arr){
1770
-            foreach($package_arr as $value){
1771
-                $this->delete_data('package_patterns',array("id"=>$value['id']));
1768
+        $package_arr = $this->select_data("packages", array("reseller_id"=>$id), 'id');
1769
+        if ($package_arr) {
1770
+            foreach ($package_arr as $value) {
1771
+                $this->delete_data('package_patterns', array("id"=>$value['id']));
1772 1772
             }
1773 1773
         }
1774
-        $acc_arr=$this->select_data('accounts',array("id"=>$id),'id,reseller_id');
1775
-        $parent_id=0;
1776
-        if($acc_arr){
1777
-            $parent_id=$acc_arr[0]['reseller_id'];
1774
+        $acc_arr = $this->select_data('accounts', array("id"=>$id), 'id,reseller_id');
1775
+        $parent_id = 0;
1776
+        if ($acc_arr) {
1777
+            $parent_id = $acc_arr[0]['reseller_id'];
1778 1778
         }
1779
-        $pricelist_arr=$this->select_data('pricelists',array('reseller_id'=>$id),'id');
1780
-        if($pricelist_arr){
1781
-             foreach($pricelist_arr as $value){
1782
-                $this->delete_data("routing",array("pricelist_id"=>$value['id']));
1783
-                $this->delete_data("routes",array("pricelist_id"=>$value['id']));
1784
-                $this->update_data('pricelists',array('id'=>$value['id']),array('status'=>2));         
1779
+        $pricelist_arr = $this->select_data('pricelists', array('reseller_id'=>$id), 'id');
1780
+        if ($pricelist_arr) {
1781
+             foreach ($pricelist_arr as $value) {
1782
+                $this->delete_data("routing", array("pricelist_id"=>$value['id']));
1783
+                $this->delete_data("routes", array("pricelist_id"=>$value['id']));
1784
+                $this->update_data('pricelists', array('id'=>$value['id']), array('status'=>2));         
1785 1785
              }
1786 1786
         }
1787
-        $charge_arr=$this->select_data('charges',array('reseller_id'=>$id),'id');
1788
-        if($charge_arr){
1789
-             foreach($charge_arr as $value){
1790
-                $this->delete_data("charge_to_account",array("charge_id"=>$value['id']));
1787
+        $charge_arr = $this->select_data('charges', array('reseller_id'=>$id), 'id');
1788
+        if ($charge_arr) {
1789
+             foreach ($charge_arr as $value) {
1790
+                $this->delete_data("charge_to_account", array("charge_id"=>$value['id']));
1791 1791
              }
1792 1792
         }
1793
-        $this->delete_data('charges',array('reseller_id'=>$id));
1794
-        $this->update_data('dids',array('parent_id'=>$id),array("parent_id"=>$parent_id));
1795
-        $this->delete_data('reseller_pricing',array("reseller_id"=>$id));
1796
-        $this->delete_data('refill_coupon',array("reseller_id"=>$id));
1797
-        $this->delete_data('mail_details',array('accountid'=>$id));
1798
-        $taxes_arr=$this->select_data('taxes',array("reseller_id"=>$id),'id');
1799
-        if($taxes_arr){
1800
-             foreach($taxes_arr as $value){
1801
-                $this->delete_data("taxes_to_accounts",array("taxes_id"=>$value['id']));
1793
+        $this->delete_data('charges', array('reseller_id'=>$id));
1794
+        $this->update_data('dids', array('parent_id'=>$id), array("parent_id"=>$parent_id));
1795
+        $this->delete_data('reseller_pricing', array("reseller_id"=>$id));
1796
+        $this->delete_data('refill_coupon', array("reseller_id"=>$id));
1797
+        $this->delete_data('mail_details', array('accountid'=>$id));
1798
+        $taxes_arr = $this->select_data('taxes', array("reseller_id"=>$id), 'id');
1799
+        if ($taxes_arr) {
1800
+             foreach ($taxes_arr as $value) {
1801
+                $this->delete_data("taxes_to_accounts", array("taxes_id"=>$value['id']));
1802 1802
              }
1803 1803
         }
1804
-        $this->delete_data('taxes',array("reseller_id"=>$id));
1805
-        $this->delete_data('default_templates',array("reseller_id"=>$id));
1806
-        $package_arr=$this->select_data('packages',array('reseller_id'=>$id),'id');
1807
-        if($package_arr){
1808
-            $this->delete_data("counters",array("package_id"=>$value['id']));
1809
-            $this->delete_data("package_patterns",array("package_id"=>$value['id']));
1804
+        $this->delete_data('taxes', array("reseller_id"=>$id));
1805
+        $this->delete_data('default_templates', array("reseller_id"=>$id));
1806
+        $package_arr = $this->select_data('packages', array('reseller_id'=>$id), 'id');
1807
+        if ($package_arr) {
1808
+            $this->delete_data("counters", array("package_id"=>$value['id']));
1809
+            $this->delete_data("package_patterns", array("package_id"=>$value['id']));
1810 1810
         }
1811
-        $this->delete_data('invoice_conf',array('accountid'=>$id));
1812
-        $this->delete_data('packages',array("reseller_id"=>$id));
1813
-        $this->update_data('accounts',array("id"=>$id),array("deleted"=>1));
1811
+        $this->delete_data('invoice_conf', array('accountid'=>$id));
1812
+        $this->delete_data('packages', array("reseller_id"=>$id));
1813
+        $this->update_data('accounts', array("id"=>$id), array("deleted"=>1));
1814 1814
     }
1815 1815
     function subreseller_list($parent_id = '') {
1816 1816
         $customer_id = $parent_id;
1817 1817
         $this->reseller_delete_dependencies($parent_id);
1818
-        $query = 'select id,type from accounts where reseller_id = ' . $parent_id .' AND deleted =0';
1818
+        $query = 'select id,type from accounts where reseller_id = '.$parent_id.' AND deleted =0';
1819 1819
         $result = $this->CI->db->query($query);
1820 1820
         if ($result->num_rows() > 0) {
1821 1821
             $result = $result->result_array();
1822 1822
             foreach ($result as $data) {
1823
-	      if($data['type']==1){
1823
+	      if ($data['type'] == 1) {
1824 1824
 		  $this->reseller_delete_dependencies($data['id']);
1825 1825
 		  $this->subreseller_list($data['id']);
1826
-	      }else{
1826
+	      } else {
1827 1827
 		  $this->customer_delete_dependencies($data['id']);
1828 1828
 	      }
1829 1829
             }
1830 1830
         }
1831 1831
     }
1832 1832
     
1833
-    function delete_data($table_name,$where_arr){
1833
+    function delete_data($table_name, $where_arr) {
1834 1834
         $this->CI->db->where($where_arr);
1835 1835
         $this->CI->db->delete($table_name);
1836 1836
     }
1837
-    function update_data($table_name,$where_arr,$update_arr){
1837
+    function update_data($table_name, $where_arr, $update_arr) {
1838 1838
         $this->CI->db->where($where_arr);
1839
-        $this->CI->db->update($table_name,$update_arr);
1839
+        $this->CI->db->update($table_name, $update_arr);
1840 1840
     }
1841
-    function select_data($table_name,$where_arr,$select){
1841
+    function select_data($table_name, $where_arr, $select) {
1842 1842
         $this->CI->db->where($where_arr);
1843 1843
         $this->CI->db->select($select);
1844
-        $result=$this->CI->db->get($table_name);
1845
-        if($result->num_rows() > 0){
1844
+        $result = $this->CI->db->get($table_name);
1845
+        if ($result->num_rows() > 0) {
1846 1846
             return $result->result_array();
1847
-        }else{
1847
+        } else {
1848 1848
             return false;
1849 1849
         }
1850 1850
     }
@@ -1856,82 +1856,82 @@  discard block
 block discarded – undo
1856 1856
     function get_call_waiting($select = "", $table = "", $status) {
1857 1857
         return ($status == 0) ? "Enable" : "Disable";
1858 1858
 	}
1859
-  function set_invoice_details($select= ''){
1859
+  function set_invoice_details($select = '') {
1860 1860
         $status_array = array("invoice_select" => "--Select--",
1861 1861
             "invoice_inactive" => "Deleted Invoices",
1862 1862
             "invoice_active" => "All Invoices",
1863 1863
         );
1864 1864
         return $status_array;
1865 1865
 }
1866
-function get_invoice_template($invoicedata,$accountdata,$flag){
1866
+function get_invoice_template($invoicedata, $accountdata, $flag) {
1867 1867
       $login_info = $this->CI->session->userdata('accountinfo');
1868 1868
 
1869 1869
       $invoice_config = $this->CI->db_model->getSelect("*", "invoice_conf", array('accountid'=>$login_info['id']));
1870
-      $invoice_config= $invoice_config->result_array();
1871
-      $invoice_config_res= $invoice_config[0];
1870
+      $invoice_config = $invoice_config->result_array();
1871
+      $invoice_config_res = $invoice_config[0];
1872 1872
 
1873 1873
       $accountdata["currency_id"] = $this->get_field_name('currency', 'currency', $accountdata["currency_id"]);
1874 1874
       $accountdata["country"] = $this->get_field_name('country', 'countrycode', $accountdata["country_id"]);
1875 1875
       $data["to_currency"] = Common_model::$global_config['system_config']['base_currency'];
1876
-      if($login_info['type'] == -1){
1876
+      if ($login_info['type'] == -1) {
1877 1877
           $currency = $data["to_currency"];
1878
-      }elseif($login_info['type'] == 1){
1878
+      }elseif ($login_info['type'] == 1) {
1879 1879
 	  $accountdata["currency_id"] = $this->get_field_name('currency', 'currency', $login_info["currency_id"]);
1880 1880
           $currency = $accountdata["currency_id"];
1881
-      }else{
1881
+      } else {
1882 1882
           $currency = $accountdata["currency_id"];
1883 1883
       }
1884
-      $decimal_amount=Common_model::$global_config['system_config']['decimalpoints'];
1884
+      $decimal_amount = Common_model::$global_config['system_config']['decimalpoints'];
1885 1885
       ob_start();
1886 1886
       $this->CI->load->library('/html2pdf/html2pdf');
1887
-      $this->CI->html2pdf = new HTML2PDF('P','A4','en');
1887
+      $this->CI->html2pdf = new HTML2PDF('P', 'A4', 'en');
1888 1888
       $this->CI->html2pdf->pdf->SetDisplayMode('fullpage');
1889
-      $template_config=$this->CI->config->item('invoice_template');
1889
+      $template_config = $this->CI->config->item('invoice_template');
1890 1890
       include($template_config.'invoice_template.php');
1891 1891
       $content = ob_get_clean();
1892 1892
       ob_clean();
1893 1893
 
1894 1894
 	$ACCOUNTADD = '';
1895
-	$ACCOUNTADD_CUSTOMER ='';
1895
+	$ACCOUNTADD_CUSTOMER = '';
1896 1896
 	$ACCOUNTADD_RIGHT = '';
1897 1897
 	$ACCOUNT_DESCRIPTION = '';
1898 1898
 	$ACCOUNT_CDRS = '';
1899
-	$ACCOUNT_TOTAL= '';
1899
+	$ACCOUNT_TOTAL = '';
1900 1900
 	$ACCOUNT_TOTAL_FINAL = '';
1901 1901
 	$ACCOUNT_FINAL = '';
1902
-	$CHARGE_ACCOUNT ='';
1902
+	$CHARGE_ACCOUNT = '';
1903 1903
 	$service_info = '';
1904 1904
 	$TotalChrg = "0.00";
1905 1905
 	$NETAMT = "0.00";
1906 1906
 	$TAXAMT = "0.00";
1907
-	$total_sum=0;
1908
-	$total_vat=0;
1907
+	$total_sum = 0;
1908
+	$total_vat = 0;
1909 1909
 	$fromdate = strtotime($invoicedata['from_date']);
1910
-	$from_date =date("Y-m-d",$fromdate);
1910
+	$from_date = date("Y-m-d", $fromdate);
1911 1911
 	$duedate = strtotime($invoicedata['due_date']);
1912
-	$due_date =date("Y-m-d",$duedate);
1912
+	$due_date = date("Y-m-d", $duedate);
1913 1913
 
1914 1914
 /*************************** Company Address Code START ***************************************************/
1915 1915
         $ACCOUNTADD .= '<tr>';
1916 1916
         $ACCOUNTADD .= '<td style="width:100%;font-size: 12px;color:#525252;font-family:arial; line-height: 22px;"><b>'.$invoice_config_res['company_name'].'</b></td>';
1917 1917
         $ACCOUNTADD .= '</tr>';
1918
-	if ( $invoice_config_res['address'] != ""){
1918
+	if ($invoice_config_res['address'] != "") {
1919 1919
 
1920 1920
         $ACCOUNTADD .= '<tr><td style="width:100%;font-size: 12px;color:#525252;font-family:arial; line-height: 22px;">'.$invoice_config_res['address'].'</td></tr>';
1921 1921
     }
1922
-	if ( $invoice_config_res['city'] != ""){
1922
+	if ($invoice_config_res['city'] != "") {
1923 1923
 
1924 1924
         $ACCOUNTADD .= '<tr><td style="width:100%;font-size: 12px;color:#525252;font-family:arial; line-height: 22px;">'.$invoice_config_res['city'].'</td></tr>';
1925 1925
     }
1926
-	if ( $invoice_config_res['province'] != ""){
1926
+	if ($invoice_config_res['province'] != "") {
1927 1927
 
1928 1928
         $ACCOUNTADD .= '<tr><td style="width:100%;font-size: 12px;color:#525252;font-family:arial; line-height: 22px;">'.$invoice_config_res['province'].'</td></tr>';
1929 1929
     }
1930
-	if ( $invoice_config_res['country'] != ""){
1930
+	if ($invoice_config_res['country'] != "") {
1931 1931
 
1932 1932
         $ACCOUNTADD .= '<tr><td style="width:100%;font-size: 12px;color:#525252;font-family:arial; line-height: 22px;">'.$invoice_config_res['country'].'</td></tr>';
1933 1933
     }
1934
-	if ( $invoice_config_res['zipcode'] != ""){
1934
+	if ($invoice_config_res['zipcode'] != "") {
1935 1935
 
1936 1936
         $ACCOUNTADD .= '<tr><td style="width:100%;font-size: 12px;color:#525252;font-family:arial; line-height: 22px;">'.$invoice_config_res['zipcode'].'</td></tr>';
1937 1937
     }
@@ -1942,27 +1942,27 @@  discard block
 block discarded – undo
1942 1942
         $ACCOUNTADD_CUSTOMER .= '<table><tr>';
1943 1943
         $ACCOUNTADD_CUSTOMER .= '<td style="width:100%;font-size: 12px;color:#525252;font-family:arial; line-height: 22px;"><b>'.$accountdata['company_name'].'</b></td></tr>';
1944 1944
 
1945
-	if ( $accountdata['address_1'] != ""){
1945
+	if ($accountdata['address_1'] != "") {
1946 1946
 
1947 1947
         $ACCOUNTADD_CUSTOMER .= '<tr><td style="width:100%;font-size: 12px;color:#525252;font-family:arial; line-height: 22px;">'.$accountdata['address_1'].'</td></tr>';
1948 1948
     }
1949
-	if ( $accountdata['city'] != ""){
1949
+	if ($accountdata['city'] != "") {
1950 1950
 
1951 1951
         $ACCOUNTADD_CUSTOMER .= '<tr><td style="width:100%;font-size: 12px;color:#525252;font-family:arial; line-height: 22px;">'.$accountdata['city'].'</td></tr>';
1952 1952
     }
1953
-	if ( $accountdata['province'] != ""){
1953
+	if ($accountdata['province'] != "") {
1954 1954
 
1955 1955
         $ACCOUNTADD_CUSTOMER .= '<tr><td style="width:100%;font-size: 12px;color:#525252;font-family:arial; line-height: 22px;">'.$accountdata['province'].'</td></tr>';
1956 1956
     }
1957
-	if ( $accountdata['country'] != ""){
1957
+	if ($accountdata['country'] != "") {
1958 1958
 
1959 1959
         $ACCOUNTADD_CUSTOMER .= '<tr><td style="width:100%;font-size: 12px;color:#525252;font-family:arial; line-height: 22px;">'.$accountdata['country'].'</td></tr>';
1960 1960
     }
1961
-	if ( $accountdata['postal_code'] != ""){
1961
+	if ($accountdata['postal_code'] != "") {
1962 1962
 
1963 1963
         $ACCOUNTADD_CUSTOMER .= '<tr><td style="width:100%;font-size: 12px;color:#525252;font-family:arial; line-height: 22px;">'.$accountdata['postal_code'].'</td></tr>';
1964 1964
     }
1965
-    $ACCOUNTADD_CUSTOMER .="</table>"; 
1965
+    $ACCOUNTADD_CUSTOMER .= "</table>"; 
1966 1966
 /*************************** Customer Address Code END ***************************************************/
1967 1967
 
1968 1968
 
@@ -1972,7 +1972,7 @@  discard block
 block discarded – undo
1972 1972
 	$ACCOUNT_DESCRIPTION .= '<td style="width:20%;font-size: 12px;color:#fff;font-family:arial; line-height: 22px;">Date</td>';
1973 1973
         $ACCOUNT_DESCRIPTION .= '<td  style="width:40%;font-size: 12px;color:#fff;font-family:arial; line-height: 22px;">Description</td>';
1974 1974
         $ACCOUNT_DESCRIPTION .= '<td  style="width:20%;font-size: 12px;color:#fff;font-family:arial; line-height: 22px;">Charge Type</td>';
1975
-	$ACCOUNT_DESCRIPTION .= '<td style="width:20%;font-size: 12px;color:#fff;font-family:arial; line-height: 22px;text-align:right;">Amount ('.$currency .')</td>';
1975
+	$ACCOUNT_DESCRIPTION .= '<td style="width:20%;font-size: 12px;color:#fff;font-family:arial; line-height: 22px;text-align:right;">Amount ('.$currency.')</td>';
1976 1976
         $ACCOUNT_DESCRIPTION .= '</tr>';
1977 1977
 
1978 1978
 
@@ -1980,23 +1980,23 @@  discard block
 block discarded – undo
1980 1980
 	$ACCOUNT_CDRS .= '<td style="width:40%;font-size: 12px;color:#fff;font-family:arial; line-height: 22px;">Description</td>';
1981 1981
 	$ACCOUNT_CDRS .= '<td style="width:20%;font-size: 12px;color:#fff;font-family:arial; line-height: 22px;">Duration (Seconds)</td>';
1982 1982
         $ACCOUNT_CDRS .= '<td style="width:20%;font-size: 12px;color:#fff;font-family:arial; line-height: 22px;">Total Calls</td>';
1983
-	$ACCOUNT_CDRS .= '<td style="width:20%;font-size: 12px;color:#fff;font-family:arial; line-height: 22px;text-align:right;">Amount ('.$currency .')</td>';
1983
+	$ACCOUNT_CDRS .= '<td style="width:20%;font-size: 12px;color:#fff;font-family:arial; line-height: 22px;text-align:right;">Amount ('.$currency.')</td>';
1984 1984
         $ACCOUNT_CDRS .= '</tr>';
1985 1985
 
1986 1986
 	/*** manual invoice **/
1987
-	$this->CI->db->where('item_type <>','INVPAY');
1988
-        $invoice_details = $this->CI->db_model->getSelect('*', 'invoice_details',array("invoiceid"=> $invoicedata['id'],'item_type <>'=> 'TAX' ));
1989
-	$invoice_details= $invoice_details->result_array();
1990
-	$total_sum=0;
1991
-	foreach($invoice_details as $charge_res){
1992
-	    if($charge_res['item_type'] == 'DIDCHRG' || $charge_res['item_type'] == 'SUBCHRG' || $charge_res['item_type'] == 'manual_inv' ){
1993
-		if($charge_res['item_type'] == 'manual_inv'){
1987
+	$this->CI->db->where('item_type <>', 'INVPAY');
1988
+        $invoice_details = $this->CI->db_model->getSelect('*', 'invoice_details', array("invoiceid"=> $invoicedata['id'], 'item_type <>'=> 'TAX'));
1989
+	$invoice_details = $invoice_details->result_array();
1990
+	$total_sum = 0;
1991
+	foreach ($invoice_details as $charge_res) {
1992
+	    if ($charge_res['item_type'] == 'DIDCHRG' || $charge_res['item_type'] == 'SUBCHRG' || $charge_res['item_type'] == 'manual_inv') {
1993
+		if ($charge_res['item_type'] == 'manual_inv') {
1994 1994
 			$charge_res['item_type'] = 'Manual Invoice';
1995 1995
 		}
1996
-		if($charge_res['item_type'] == 'DIDCHRG'){
1996
+		if ($charge_res['item_type'] == 'DIDCHRG') {
1997 1997
 			$charge_res['item_type'] = 'DID Charge';
1998 1998
 		}
1999
-		if($charge_res['item_type'] == 'SUBCHRG'){
1999
+		if ($charge_res['item_type'] == 'SUBCHRG') {
2000 2000
 			$charge_res['item_type'] = 'Subscription Charge';
2001 2001
 		}
2002 2002
 
@@ -2007,12 +2007,12 @@  discard block
 block discarded – undo
2007 2007
 
2008 2008
 		$ACCOUNT_DESCRIPTION .= '<td style="width:20%;font-size: 12px;color:#525252;font-family:arial; line-height: 22px;text-align:right;">'.$this->currency_decimal($this->CI->common_model->calculate_currency($charge_res['debit'])).'</td>';
2009 2009
 		$ACCOUNT_DESCRIPTION .= '</tr>';
2010
-	     }else{
2011
-            $cdrs_data = $this->CI->db_model->getSelect("sum(billseconds) as billseconds,count(*) as count", "cdrs", array("accountid" => $charge_res['accountid'],"calltype" => $charge_res['item_type']));
2010
+	     } else {
2011
+            $cdrs_data = $this->CI->db_model->getSelect("sum(billseconds) as billseconds,count(*) as count", "cdrs", array("accountid" => $charge_res['accountid'], "calltype" => $charge_res['item_type']));
2012 2012
             $cdrs_result = $cdrs_data->result_array();
2013
-	    if($cdrs_result[0]['count'] > 0 ){
2014
-		$cdrs_record_count=$cdrs_result[0]['count'] ;
2015
-		$cdrs_record_billseconds=$cdrs_result[0]['billseconds'] ;
2013
+	    if ($cdrs_result[0]['count'] > 0) {
2014
+		$cdrs_record_count = $cdrs_result[0]['count'];
2015
+		$cdrs_record_billseconds = $cdrs_result[0]['billseconds'];
2016 2016
 /*echo '<pre>'.$cdrs_record_count;
2017 2017
 print_r($cdrs_result);
2018 2018
 exit;*/
@@ -2030,8 +2030,8 @@  discard block
 block discarded – undo
2030 2030
 
2031 2031
 /**********************************Tax Apply Start********************************************************************/
2032 2032
 	$total_sum = $total_sum;
2033
-	$total_sum=$this->currency_decimal($this->CI->common_model->calculate_currency($total_sum));
2034
-        $invoice_tax = $this->CI->db_model->getSelect('*', 'invoice_details',array("invoiceid"=> $invoicedata['id'],'item_type '=> 'TAX'));
2033
+	$total_sum = $this->currency_decimal($this->CI->common_model->calculate_currency($total_sum));
2034
+        $invoice_tax = $this->CI->db_model->getSelect('*', 'invoice_details', array("invoiceid"=> $invoicedata['id'], 'item_type '=> 'TAX'));
2035 2035
  	//$ACCOUNT_TOTAL .= '<td><table style="width:100%;margin-left:360px;">';
2036 2036
 
2037 2037
 	$ACCOUNT_TOTAL .= '<tr>';
@@ -2041,35 +2041,35 @@  discard block
 block discarded – undo
2041 2041
 //	$ACCOUNT_TOTAL .= '<td style="width:20%;font-size: 12px;color:#000;font-family:arial; line-height: 22px;text-align:right;">'.$total_sum .'</td>';
2042 2042
         $ACCOUNT_TOTAL .= '</tr>';
2043 2043
 
2044
-	if($invoice_tax->num_rows() > 0 ){
2045
-	   foreach($invoice_tax->result_array() as $invoice_tax){
2044
+	if ($invoice_tax->num_rows() > 0) {
2045
+	   foreach ($invoice_tax->result_array() as $invoice_tax) {
2046 2046
 
2047
-		$total_vat +=$invoice_tax['debit'];
2047
+		$total_vat += $invoice_tax['debit'];
2048 2048
 		$ACCOUNT_TOTAL .= '<tr>';
2049 2049
 		$ACCOUNT_TOTAL .= '<td style="width:20%;font-size: 12px;color:#000;font-family:arial; line-height: 22px;text-align:right;"></td>';
2050 2050
 		$ACCOUNT_TOTAL .= '<td style="width:40%;font-size: 12px;color:#000;font-family:arial; line-height: 22px;text-align:right;"></td>';
2051 2051
 		$ACCOUNT_TOTAL .= '<td style="width:20%;font-size: 12px;color:#000;font-family:arial; line-height: 22px;"><b>'.$invoice_tax["description"].':</b></td>';
2052
-		$ACCOUNT_TOTAL .= '<td style="width:20%;font-size: 12px;color:#000;font-family:arial; line-height: 22px;text-align:right;">'.$this->currency_decimal($this->CI->common_model->calculate_currency($total_vat)) .'</td>';
2052
+		$ACCOUNT_TOTAL .= '<td style="width:20%;font-size: 12px;color:#000;font-family:arial; line-height: 22px;text-align:right;">'.$this->currency_decimal($this->CI->common_model->calculate_currency($total_vat)).'</td>';
2053 2053
 		$ACCOUNT_TOTAL .= '</tr>';
2054 2054
 
2055 2055
 	   }
2056
-		$total_vat=$this->currency_decimal($this->CI->common_model->calculate_currency($total_vat));	
2057
-	}else{
2056
+		$total_vat = $this->currency_decimal($this->CI->common_model->calculate_currency($total_vat));	
2057
+	} else {
2058 2058
 /********harsh_308***********/
2059 2059
 		$ACCOUNT_TOTAL .= '<tr>';
2060 2060
 		$ACCOUNT_TOTAL .= '<td style="width:20%;font-size: 12px;color:#000;font-family:arial; line-height: 22px;"></td>';
2061 2061
 		$ACCOUNT_TOTAL .= '<td style="width:40%;font-size: 12px;color:#000;font-family:arial; line-height: 22px;"></td>';
2062 2062
 		$ACCOUNT_TOTAL .= '<td style="width:20%;font-size: 12px;color:#000;font-family:arial; line-height: 22px;"><b>Total TAX:</b></td>';
2063
-		$ACCOUNT_TOTAL .= '<td style="width:20%;font-size: 12px;color:#000;font-family:arial; line-height: 22px;text-align:right;">'.$this->currency_decimal($total_vat) .'</td>';
2063
+		$ACCOUNT_TOTAL .= '<td style="width:20%;font-size: 12px;color:#000;font-family:arial; line-height: 22px;text-align:right;">'.$this->currency_decimal($total_vat).'</td>';
2064 2064
 		$ACCOUNT_TOTAL .= '</tr>';
2065 2065
 
2066 2066
 	}
2067
-	$sub_total=$total_sum+$total_vat;
2067
+	$sub_total = $total_sum + $total_vat;
2068 2068
 	$ACCOUNT_TOTAL .= '<tr>';
2069 2069
 	$ACCOUNT_TOTAL .= '<td style="width:20%;font-size: 12px;color:#000;font-family:arial; line-height: 22px;"></td>';
2070 2070
 	$ACCOUNT_TOTAL .= '<td style="width:40%;font-size: 12px;color:#000;font-family:arial; line-height: 22px;"></td>';
2071 2071
 	$ACCOUNT_TOTAL .= '<td style="width:20%;font-size: 12px;color:#000;font-family:arial; line-height: 22px;"><b>Sub Total:</b></td>';
2072
-	$ACCOUNT_TOTAL .= '<td style="width:20%;font-size: 12px;color:#000;font-family:arial; line-height: 22px;text-align:right;">'.$this->currency_decimal($sub_total) .'</td>';
2072
+	$ACCOUNT_TOTAL .= '<td style="width:20%;font-size: 12px;color:#000;font-family:arial; line-height: 22px;text-align:right;">'.$this->currency_decimal($sub_total).'</td>';
2073 2073
 	$ACCOUNT_TOTAL .= '</tr>';
2074 2074
 
2075 2075
 
@@ -2098,26 +2098,26 @@  discard block
 block discarded – undo
2098 2098
 
2099 2099
 /*************************** Invoice Note Code END ***************************************************/
2100 2100
         $invoice_notes = $this->CI->db_model->getSelect('*', 'invoices', array('id'=>$invoicedata['id']));
2101
-        $invoice_notes=$invoice_notes->result_array();
2102
-	if(isset($invoice_notes[0]['notes'])){
2103
-		$invoice_notes=$invoice_notes[0]['notes'];
2104
-	}else{
2105
-		if($invoice_notes[0]['invoice_note'] == '0' ){
2106
-			$invoice_notes='THIS IS A 30 DAY ACCOUNT, SO PLEASE MAKE PAYMENT WITHIN THESE TERMS';
2107
-		}else{
2108
-			$invoice_notes=$invoice_notes[0]['invoice_note'];
2101
+        $invoice_notes = $invoice_notes->result_array();
2102
+	if (isset($invoice_notes[0]['notes'])) {
2103
+		$invoice_notes = $invoice_notes[0]['notes'];
2104
+	} else {
2105
+		if ($invoice_notes[0]['invoice_note'] == '0') {
2106
+			$invoice_notes = 'THIS IS A 30 DAY ACCOUNT, SO PLEASE MAKE PAYMENT WITHIN THESE TERMS';
2107
+		} else {
2108
+			$invoice_notes = $invoice_notes[0]['invoice_note'];
2109 2109
 		}
2110 2110
 	}
2111 2111
 /*************************** Invoice Note Code END ***************************************************/
2112 2112
 
2113 2113
 	if (file_exists(getcwd()."/upload/".$invoice_config[0]['accountid']."_".$invoice_config[0]['logo'])) {
2114
-		if($invoice_config[0]['logo'] != ''){
2115
-			$content = str_replace("<LOGO>",base_url()."upload/".$invoice_config[0]['accountid']."_".$invoice_config[0]['logo'],$content);
2116
-		}else{
2117
-			$content = str_replace("<LOGO>",base_url().'/assets/images/logo.png',$content);
2114
+		if ($invoice_config[0]['logo'] != '') {
2115
+			$content = str_replace("<LOGO>", base_url()."upload/".$invoice_config[0]['accountid']."_".$invoice_config[0]['logo'], $content);
2116
+		} else {
2117
+			$content = str_replace("<LOGO>", base_url().'/assets/images/logo.png', $content);
2118 2118
 		}
2119
-	}else{
2120
-		$content = str_replace("<LOGO>",base_url().'/assets/images/logo.png',$content);
2119
+	} else {
2120
+		$content = str_replace("<LOGO>", base_url().'/assets/images/logo.png', $content);
2121 2121
 	}
2122 2122
 
2123 2123
 	$ACCOUNT_TOTAL_FINAL .= '<tr>';
@@ -2126,37 +2126,37 @@  discard block
 block discarded – undo
2126 2126
 	$ACCOUNT_TOTAL_FINAL .= '</tr>';
2127 2127
 
2128 2128
       //  $content = str_replace("<LOGO>",$image_logo,$content);   
2129
-        $content = str_replace("<ACCOUNTADD>",$ACCOUNTADD,$content);
2130
-        $content = str_replace("<ACCOUNTADD_CUSTOMER>",$ACCOUNTADD_CUSTOMER,$content);
2131
-        $content = str_replace("<ACCOUNTADD_RIGHT>",$ACCOUNTADD_RIGHT,$content);
2132
-	$content = str_replace("<ACCOUNT_DESCRIPTION>",$ACCOUNT_DESCRIPTION,$content);
2133
-	$content = str_replace("<ACCOUNT_CDRS>",$ACCOUNT_CDRS,$content);
2134
-	$content = str_replace("<ACCOUNT_TOTAL>",$ACCOUNT_TOTAL,$content);
2135
-	$content = str_replace("<ACCOUNT_TOTAL_FINAL>",$ACCOUNT_TOTAL_FINAL,$content);
2136
-        $content = str_replace("<NOTES>",$invoice_notes,$content);
2129
+        $content = str_replace("<ACCOUNTADD>", $ACCOUNTADD, $content);
2130
+        $content = str_replace("<ACCOUNTADD_CUSTOMER>", $ACCOUNTADD_CUSTOMER, $content);
2131
+        $content = str_replace("<ACCOUNTADD_RIGHT>", $ACCOUNTADD_RIGHT, $content);
2132
+	$content = str_replace("<ACCOUNT_DESCRIPTION>", $ACCOUNT_DESCRIPTION, $content);
2133
+	$content = str_replace("<ACCOUNT_CDRS>", $ACCOUNT_CDRS, $content);
2134
+	$content = str_replace("<ACCOUNT_TOTAL>", $ACCOUNT_TOTAL, $content);
2135
+	$content = str_replace("<ACCOUNT_TOTAL_FINAL>", $ACCOUNT_TOTAL_FINAL, $content);
2136
+        $content = str_replace("<NOTES>", $invoice_notes, $content);
2137 2137
 
2138 2138
 //echo $content; exit;
2139 2139
 
2140
-	$invoice_path=$this->CI->config->item('invoices_path');
2140
+	$invoice_path = $this->CI->config->item('invoices_path');
2141 2141
 	$download_path = $invoice_path.$accountdata["id"].'/'.$invoicedata['invoice_prefix'].$invoicedata['invoiceid']."_invoice.pdf"; 
2142 2142
        //echo  $download_path; exit;
2143 2143
        $this->CI->html2pdf->pdf->SetDisplayMode('fullpage');
2144 2144
        $this->CI->html2pdf->writeHTML($content);
2145 2145
        
2146
-       if($flag== 'TRUE'){
2146
+       if ($flag == 'TRUE') {
2147 2147
         $download_path = $invoicedata['invoice_prefix'].$invoicedata['invoiceid'].".pdf";
2148 2148
        
2149
-        $this->CI->html2pdf->Output($download_path,"D");        
2150
-       }else{
2149
+        $this->CI->html2pdf->Output($download_path, "D");        
2150
+       } else {
2151 2151
         $current_dir = getcwd()."/invoices/";
2152 2152
         $dir_name = $accountdata["id"];
2153
-        if(!is_dir($current_dir.$dir_name)){
2154
-                mkdir($current_dir.$dir_name,0777, true);
2153
+        if ( ! is_dir($current_dir.$dir_name)) {
2154
+                mkdir($current_dir.$dir_name, 0777, true);
2155 2155
                 chmod($current_dir.$dir_name, 0777);        
2156 2156
         }        
2157
-        $invoice_path=$this->CI->config->item('invoices_path');
2157
+        $invoice_path = $this->CI->config->item('invoices_path');
2158 2158
         $download_path = $invoice_path.$accountdata["id"].'/'.$invoicedata['invoice_prefix'].$invoicedata['invoiceid']."_invoice.pdf"; 
2159
-        $this->CI->html2pdf->Output($download_path,"F");         
2159
+        $this->CI->html2pdf->Output($download_path, "F");         
2160 2160
        }
2161 2161
 }
2162 2162
     function reseller_select_value($select, $table, $id_where = '') {
@@ -2176,55 +2176,55 @@  discard block
 block discarded – undo
2176 2176
 	   return 'Admin';
2177 2177
     }
2178 2178
     
2179
-    function get_subreseller_info($parent_id){
2180
-        if(!empty($parent_id)){
2181
-	  $str=$parent_id.",";
2182
-        }else{
2183
-          $str=null;
2179
+    function get_subreseller_info($parent_id) {
2180
+        if ( ! empty($parent_id)) {
2181
+	  $str = $parent_id.",";
2182
+        } else {
2183
+          $str = null;
2184 2184
         }
2185 2185
         $query = "select id from accounts where reseller_id = '$parent_id' AND deleted =0 AND type=1";
2186 2186
         $result = $this->CI->db->query($query);
2187
-        if($result->num_rows() > 0){
2187
+        if ($result->num_rows() > 0) {
2188 2188
         $result = $result->result_array();
2189
-	  foreach ($result as $data){
2190
-	    if(!empty($data['id'])){
2191
-	      $str.=$this->get_subreseller_info($data['id']);
2189
+	  foreach ($result as $data) {
2190
+	    if ( ! empty($data['id'])) {
2191
+	      $str .= $this->get_subreseller_info($data['id']);
2192 2192
 	    }
2193 2193
 	  }
2194 2194
 	}
2195 2195
 	return $str;
2196 2196
     }
2197
-    function get_parent_info($child_id,$parent_id){
2198
-        if(!empty($child_id)){
2199
-	  $str=$child_id.",";
2200
-        }else{
2201
-          $str=null;
2197
+    function get_parent_info($child_id, $parent_id) {
2198
+        if ( ! empty($child_id)) {
2199
+	  $str = $child_id.",";
2200
+        } else {
2201
+          $str = null;
2202 2202
         }
2203
-        if($child_id > 0){
2203
+        if ($child_id > 0) {
2204 2204
         $query = "select reseller_id from accounts where id = '$child_id'";
2205 2205
         $result = $this->CI->db->query($query);
2206
-        if($result->num_rows() > 0){
2206
+        if ($result->num_rows() > 0) {
2207 2207
         $parent_info = (array)$result->first_row();
2208
-	  if($parent_info['reseller_id'] != $parent_id){
2209
-	    $str.=$this->get_parent_info($parent_info['reseller_id'],$parent_id);
2208
+	  if ($parent_info['reseller_id'] != $parent_id) {
2209
+	    $str .= $this->get_parent_info($parent_info['reseller_id'], $parent_id);
2210 2210
 	  }
2211 2211
 	}
2212 2212
 	}
2213 2213
 	return $str;
2214 2214
     }
2215
-    function get_did_accountid($select,$table,$where){
2216
-      $accountinfo=$this->CI->session->userdata('accountinfo');
2217
-      $this->CI->db->where('note',$where);
2218
-      $this->CI->db->where('parent_id',$accountinfo['id']);
2215
+    function get_did_accountid($select, $table, $where) {
2216
+      $accountinfo = $this->CI->session->userdata('accountinfo');
2217
+      $this->CI->db->where('note', $where);
2218
+      $this->CI->db->where('parent_id', $accountinfo['id']);
2219 2219
       $this->CI->db->select('reseller_id');
2220
-      $reseller_pricing_result=$this->CI->db->get('reseller_pricing');
2221
-      $account_info=(array)$reseller_pricing_result->first_row();
2222
-      $account_name=$this->get_field_name_coma_new('first_name,last_name,number','accounts',$account_info['reseller_id']);
2220
+      $reseller_pricing_result = $this->CI->db->get('reseller_pricing');
2221
+      $account_info = (array)$reseller_pricing_result->first_row();
2222
+      $account_name = $this->get_field_name_coma_new('first_name,last_name,number', 'accounts', $account_info['reseller_id']);
2223 2223
       return $account_name;     
2224 2224
     }
2225 2225
 
2226
-    function get_status_new($select = "",$table = "",$status = "") {
2227
-      return ($status['status']==0) ? "<span class='label label-sm label-inverse arrowed-in' title='release'>Active<span>" : "<span class='label label-sm' title='release'>Inactive<span>";
2226
+    function get_status_new($select = "", $table = "", $status = "") {
2227
+      return ($status['status'] == 0) ? "<span class='label label-sm label-inverse arrowed-in' title='release'>Active<span>" : "<span class='label label-sm' title='release'>Inactive<span>";
2228 2228
     }
2229 2229
     
2230 2230
 }
Please login to merge, or discard this patch.
web_interface/astpp/application/libraries/astpp/email_lib.php 2 patches
Doc Comments   +7 added lines patch added patch discarded remove patch
@@ -91,6 +91,9 @@  discard block
 block discarded – undo
91 91
         return false;
92 92
     }
93 93
 
94
+    /**
95
+     * @param string $detail_type
96
+     */
94 97
     function get_info($id,$detail_type)
95 98
     {
96 99
 	$where = array('id' => $id);
@@ -183,6 +186,10 @@  discard block
 block discarded – undo
183 186
 		}
184 187
 	}
185 188
     }
189
+
190
+    /**
191
+     * @param string $attachment
192
+     */
186 193
     function mail_history($attachment)
187 194
     {
188 195
 		$send_mail_details = array('from'=>$this->from,
Please login to merge, or discard this patch.
Spacing   +81 added lines, -81 removed lines patch added patch discarded remove patch
@@ -21,7 +21,7 @@  discard block
 block discarded – undo
21 21
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
22 22
 ###############################################################################
23 23
 
24
-if (!defined('BASEPATH'))
24
+if ( ! defined('BASEPATH'))
25 25
     exit('No direct script access allowed');
26 26
 
27 27
 /**
@@ -30,19 +30,19 @@  discard block
 block discarded – undo
30 30
 class email_lib {
31 31
 
32 32
     protected $CI; // codeigniter
33
-    public $email='';
34
-    public $smtp='';
35
-    public $smtp_host='';
36
-    public $smtp_user='';
37
-    public $smtp_pass='';
38
-    public $smtp_port='';
39
-    public $message='';
40
-    public $from='';
41
-    public $to='';
42
-    public $subject='';
43
-    public $company_name='';
44
-    public $company_website='';
45
-    public $account_id='';
33
+    public $email = '';
34
+    public $smtp = '';
35
+    public $smtp_host = '';
36
+    public $smtp_user = '';
37
+    public $smtp_pass = '';
38
+    public $smtp_port = '';
39
+    public $message = '';
40
+    public $from = '';
41
+    public $to = '';
42
+    public $subject = '';
43
+    public $company_name = '';
44
+    public $company_website = '';
45
+    public $account_id = '';
46 46
 
47 47
     function __construct($library_name = '') {
48 48
 
@@ -57,13 +57,13 @@  discard block
 block discarded – undo
57 57
 		$where = array('group_title' =>'email');
58 58
 	        $query = $this->CI->db_model->getSelect("*", "system", $where);
59 59
 	        $query = $query->result_array();
60
-		foreach($query as $key=>$val){
60
+		foreach ($query as $key=>$val) {
61 61
 			$tempvar = strtolower($val['name']);
62
-			$this->$tempvar=$val['value'];
62
+			$this->$tempvar = $val['value'];
63 63
 		}
64 64
     }
65 65
 
66
-    function get_template( $type)
66
+    function get_template($type)
67 67
     {
68 68
 	$where = array('name' => $type);
69 69
         $query = $this->CI->db_model->getSelect("*", "default_templates", $where);
@@ -77,27 +77,27 @@  discard block
 block discarded – undo
77 77
 	$where = array('id' => $accountid);
78 78
         $query = $this->CI->db_model->getSelect("*", "accounts", $where);
79 79
         $query = $query->result_array();
80
-	if(isset($query[0]['email']) && $query[0]['email']!=''){
81
-		$query[0]['currency_name']=$this->CI->common->get_field_name('currency', 'currency', $query[0]['currency_id']);
82
-		$query[0]['timezone_name']=$this->CI->common->get_field_name('gmtzone', 'timezone', $query[0]['timezone_id']);
83
-		$query[0]['country_name']=$this->CI->common->get_field_name('country', 'countrycode', $query[0]['country_id']);
84
-		$this->to=$query[0]['email'];
80
+	if (isset($query[0]['email']) && $query[0]['email'] != '') {
81
+		$query[0]['currency_name'] = $this->CI->common->get_field_name('currency', 'currency', $query[0]['currency_id']);
82
+		$query[0]['timezone_name'] = $this->CI->common->get_field_name('gmtzone', 'timezone', $query[0]['timezone_id']);
83
+		$query[0]['country_name'] = $this->CI->common->get_field_name('country', 'countrycode', $query[0]['country_id']);
84
+		$this->to = $query[0]['email'];
85 85
 		$this->account_id = $query[0]['id'];
86 86
 		unset($query[0]['id']);
87
-		$query[0]['username']=$query[0]['number'];
87
+		$query[0]['username'] = $query[0]['number'];
88 88
 		unset($query[0]['number']);
89 89
 		return $query[0];
90 90
 	}
91 91
         return false;
92 92
     }
93 93
 
94
-    function get_info($id,$detail_type)
94
+    function get_info($id, $detail_type)
95 95
     {
96 96
 	$where = array('id' => $id);
97 97
         $query = $this->CI->db_model->getSelect("*", $detail_type, $where);
98 98
         $query = $query->result_array();
99
-	if(isset($query[0]['accountid'])){
100
-		$query=$this->get_account_info($query [0]['accountid']);
99
+	if (isset($query[0]['accountid'])) {
100
+		$query = $this->get_account_info($query [0]['accountid']);
101 101
 		return $query[0];
102 102
 	}
103 103
 	return false;
@@ -108,47 +108,47 @@  discard block
 block discarded – undo
108 108
 	$where = array();
109 109
         $query = $this->CI->db_model->getSelect("*", "invoice_conf", $where);
110 110
         $query = $query->result();
111
-	if(isset($query[0]->emailaddress) && $query[0]->emailaddress!=''){
112
-		$this->company_website=$query[0]->website;
113
-		$this->from=$query[0]->emailaddress;
114
-		$this->company_name=$query[0]->company_name;
111
+	if (isset($query[0]->emailaddress) && $query[0]->emailaddress != '') {
112
+		$this->company_website = $query[0]->website;
113
+		$this->from = $query[0]->emailaddress;
114
+		$this->company_name = $query[0]->company_name;
115 115
 		return true;
116 116
 	}
117 117
 	return false;
118 118
     }
119 119
 
120
-    function build_template($template_type,$detail,$detail_type='') {
121
-	if(!is_array($template_type))
120
+    function build_template($template_type, $detail, $detail_type = '') {
121
+	if ( ! is_array($template_type))
122 122
 		$this->get_template($template_type);
123
-	else{
124
-		$this->message=$template_type['message'];
125
-		$this->subject=$template_type['subject'];
126
-		$template_type='';
123
+	else {
124
+		$this->message = $template_type['message'];
125
+		$this->subject = $template_type['subject'];
126
+		$template_type = '';
127 127
 	}
128
-	if(is_array($detail))
128
+	if (is_array($detail))
129 129
 	{
130
-		$templateinfo=$detail;
131
-		if(isset($detail['email'])){
132
-			$this->to=$detail['email'];
130
+		$templateinfo = $detail;
131
+		if (isset($detail['email'])) {
132
+			$this->to = $detail['email'];
133 133
 		}
134 134
 /*****
135 135
 ASTPP  3.0 
136 136
 Email test
137 137
 ****/
138
-		if(isset($templateinfo['number'])){	
139
-			$templateinfo['username']=$templateinfo['number'];
138
+		if (isset($templateinfo['number'])) {	
139
+			$templateinfo['username'] = $templateinfo['number'];
140 140
 		}
141 141
 
142 142
 /*************/
143
-		$this->account_id=$templateinfo['accountid'];
143
+		$this->account_id = $templateinfo['accountid'];
144 144
 		unset($templateinfo['number']);
145 145
 	}
146
-	else if(!is_array($detail) && $detail_type=='')
147
-		$templateinfo=$this->get_account_info($detail);
146
+	else if ( ! is_array($detail) && $detail_type == '')
147
+		$templateinfo = $this->get_account_info($detail);
148 148
 	else
149
-		$templateinfo=$this->get_info($detail,$detail_type);
149
+		$templateinfo = $this->get_info($detail, $detail_type);
150 150
 
151
-	if($this->get_admin_details() && is_array($templateinfo) && isset($templateinfo['first_name']) && $templateinfo['first_name']!=''){
151
+	if ($this->get_admin_details() && is_array($templateinfo) && isset($templateinfo['first_name']) && $templateinfo['first_name'] != '') {
152 152
 		$this->message = html_entity_decode($this->message);
153 153
 		$this->message = str_replace("#COMPANY_EMAIL#", $this->from, $this->message);
154 154
 		$this->message = str_replace("#COMPANY_NAME#", $this->company_name, $this->message);
@@ -193,33 +193,33 @@  discard block
 block discarded – undo
193 193
 			   'status'=>'1',
194 194
 			   'attachment'=>$attachment
195 195
 			  );
196
-		$this->CI->db->insert('mail_details',$send_mail_details);
196
+		$this->CI->db->insert('mail_details', $send_mail_details);
197 197
 		return $this->CI->db->insert_id();
198 198
     }
199 199
     function update_mail_history($id)
200 200
     {
201 201
 		$this->CI->db->where(array('id' => $id));
202 202
 		$send_mail_details = array('status'=>'0');
203
-		$this->CI->db->update('mail_details',$send_mail_details);
203
+		$this->CI->db->update('mail_details', $send_mail_details);
204 204
     }
205 205
     function set_email_paramenters($details)
206 206
     {
207
-		if(!is_array($details)){
207
+		if ( ! is_array($details)) {
208 208
 			$this->get_admin_details();
209 209
 			$where = array('id'=>$details);
210 210
 			$query = $this->CI->db_model->getSelect("*", "mail_details", $where);
211 211
 			$query = $query->result_array();
212
-			$details=$query[0];
212
+			$details = $query[0];
213 213
 		}
214
-		$this->message=$details['body'];
215
-		$this->from=$details['from'];
216
-		$this->to=$details['to'];
217
-		$this->subject=$details['subject'];
218
-		$this->account_id=$details['accountid'];
214
+		$this->message = $details['body'];
215
+		$this->from = $details['from'];
216
+		$this->to = $details['to'];
217
+		$this->subject = $details['subject'];
218
+		$this->account_id = $details['accountid'];
219 219
     }
220 220
     function get_smtp_details()
221 221
     {
222
-	if($this->smtp_port=='' || $this->smtp_host=='' || $this->smtp_user=='' || $this->smtp_pass=='')exit;
222
+	if ($this->smtp_port == '' || $this->smtp_host == '' || $this->smtp_user == '' || $this->smtp_pass == '')exit;
223 223
 		$config['protocol'] = "smtp";
224 224
 		$config['smtp_host'] = $this->smtp_host;
225 225
 		$config['smtp_port'] = $this->smtp_port;
@@ -231,21 +231,21 @@  discard block
 block discarded – undo
231 231
 		$this->CI->email->initialize($config);
232 232
     }
233 233
 
234
-    function send_email($template_type,$details,$detail_type='',$attachment='',$resend=0,$mass_mail=0,$brodcast=0) {
234
+    function send_email($template_type, $details, $detail_type = '', $attachment = '', $resend = 0, $mass_mail = 0, $brodcast = 0) {
235 235
 	$this->get_email_settings();
236
-	if(!$this->email){
237
-		if(!$resend){
238
-			$this->build_template($template_type,$details,$detail_type);
239
-		}else{
236
+	if ( ! $this->email) {
237
+		if ( ! $resend) {
238
+			$this->build_template($template_type, $details, $detail_type);
239
+		} else {
240 240
 			$this->set_email_paramenters($details);
241 241
 		}
242 242
 
243
-		if(!$brodcast)
244
-	        	$history_id=$this->mail_history($attachment);
243
+		if ( ! $brodcast)
244
+	        	$history_id = $this->mail_history($attachment);
245 245
 		else	
246
-			$history_id=$details['history_id'];
247
-		if(isset($this->from) && $this->from!='' && isset($this->to) && $this->to!='' && !$mass_mail){
248
-			if(!$this->smtp){
246
+			$history_id = $details['history_id'];
247
+		if (isset($this->from) && $this->from != '' && isset($this->to) && $this->to != '' && ! $mass_mail) {
248
+			if ( ! $this->smtp) {
249 249
 				$this->get_smtp_details();
250 250
 			}			
251 251
 			$this->CI->email->from($this->from, $this->company_name);
@@ -255,11 +255,11 @@  discard block
 block discarded – undo
255 255
 			eval("\$message = \"".$this->message."\";");
256 256
 			$this->CI->email->message($this->message);
257 257
 
258
-			if($attachment!="")
258
+			if ($attachment != "")
259 259
 			{
260
-			        $attac_exp=explode(",",$attachment);
261
-		       	  	foreach($attac_exp as $key=>$value){
262
-			   		if($value != ''){
260
+			        $attac_exp = explode(",", $attachment);
261
+		       	  	foreach ($attac_exp as $key=>$value) {
262
+			   		if ($value != '') {
263 263
 			       	$this->CI->email->attach(getcwd()."/attachments/".$value);       	  	
264 264
 				   	}
265 265
 				}
@@ -274,22 +274,22 @@  discard block
 block discarded – undo
274 274
 ASTPP  3.0 
275 275
 Add For Signup Module
276 276
 **/
277
-    function send_mail($template_type,$details,$detail_type='',$attachment='',$resend=0,$mass_mail=0,$brodcast=0) {
277
+    function send_mail($template_type, $details, $detail_type = '', $attachment = '', $resend = 0, $mass_mail = 0, $brodcast = 0) {
278 278
 	$this->get_email_settings();
279
-	if(!$this->email){
279
+	if ( ! $this->email) {
280 280
 		
281
-		if(!$resend){
282
-			$this->build_template($template_type,$details,$detail_type);
283
-		}else{
281
+		if ( ! $resend) {
282
+			$this->build_template($template_type, $details, $detail_type);
283
+		} else {
284 284
 			$this->set_email_paramenters($details);
285 285
 		}
286 286
 
287
-		if(!$brodcast)
288
-	        	$history_id=$this->mail_history($attachment);
287
+		if ( ! $brodcast)
288
+	        	$history_id = $this->mail_history($attachment);
289 289
 		else	
290
-			$history_id=$details['history_id'];
291
-		if(isset($this->from) && $this->from!='' && isset($this->to) && $this->to!='' && !$mass_mail){
292
-			if(!$this->smtp){
290
+			$history_id = $details['history_id'];
291
+		if (isset($this->from) && $this->from != '' && isset($this->to) && $this->to != '' && ! $mass_mail) {
292
+			if ( ! $this->smtp) {
293 293
 				$this->get_smtp_details();
294 294
 			}			
295 295
 			$this->CI->email->from($this->from, $this->company_name);
Please login to merge, or discard this patch.
web_interface/astpp/application/libraries/astpp/form.php 2 patches
Doc Comments   -2 removed lines patch added patch discarded remove patch
@@ -52,8 +52,6 @@
 block discarded – undo
52 52
 // __construct
53 53
     /**
54 54
      * adds raw html to the field array
55
-     * @param type $label
56
-     * @param type $field add
57 55
      */
58 56
     function check_permissions() {
59 57
         if ($this->CI->session->userdata('user_login') == TRUE) {
Please login to merge, or discard this patch.
Spacing   +245 added lines, -245 removed lines patch added patch discarded remove patch
@@ -21,7 +21,7 @@  discard block
 block discarded – undo
21 21
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
22 22
 ###############################################################################
23 23
 
24
-if (!defined('BASEPATH'))
24
+if ( ! defined('BASEPATH'))
25 25
     exit('No direct script access allowed');
26 26
 
27 27
 /**
@@ -30,7 +30,7 @@  discard block
 block discarded – undo
30 30
 class Form {
31 31
 
32 32
     protected $CI; // codeigniter
33
-    protected $fields = array();  // array of fields
33
+    protected $fields = array(); // array of fields
34 34
     protected $form_title = 'Form';
35 35
     protected $form_id = 'form';
36 36
     protected $form_action = '';
@@ -58,31 +58,31 @@  discard block
 block discarded – undo
58 58
     function check_permissions() {
59 59
         if ($this->CI->session->userdata('user_login') == TRUE) {
60 60
             $module_info = unserialize($this->CI->session->userdata("permited_modules"));
61
-            if($this->CI->session->userdata('userlevel_logintype')!= 0 && $this->CI->session->userdata('userlevel_logintype')!= 3){
62
-	    $module_info[]='dashboard';
61
+            if ($this->CI->session->userdata('userlevel_logintype') != 0 && $this->CI->session->userdata('userlevel_logintype') != 3) {
62
+	    $module_info[] = 'dashboard';
63 63
             }
64 64
             $url = $this->CI->uri->uri_string;
65 65
             $file_name = explode("/", $url);
66
-            if(isset($file_name['1']) ){
66
+            if (isset($file_name['1'])) {
67 67
 	      $module = explode('_', $file_name['1']);
68
-            }else{
69
-              $module=$file_name;
68
+            } else {
69
+              $module = $file_name;
70 70
             }
71
-            if($this->CI->session->userdata('userlevel_logintype')==1 ){
72
-				$module_info[]='user';
71
+            if ($this->CI->session->userdata('userlevel_logintype') == 1) {
72
+				$module_info[] = 'user';
73 73
 			}
74 74
             if (in_array($module[0], $module_info)) {
75
-                if($this->CI->session->userdata('userlevel_logintype')== 0 && $module[0] == 'customer' && isset($file_name[1]) && $file_name[1] !='customer_transfer'){
76
-                     redirect(base_url() . 'user/user/');
77
-                }else{
75
+                if ($this->CI->session->userdata('userlevel_logintype') == 0 && $module[0] == 'customer' && isset($file_name[1]) && $file_name[1] != 'customer_transfer') {
76
+                     redirect(base_url().'user/user/');
77
+                } else {
78 78
                    return true;
79 79
                 }
80 80
             } else {
81 81
                 $this->CI->session->set_userdata('astpp_errormsg', 'You do not have permission to access this module..!');
82 82
                 if ($this->CI->session->userdata('userlevel_logintype') == '-1' || $this->CI->session->userdata('logintype') == '1') {
83
-                    redirect(base_url() . 'dashboard/');
83
+                    redirect(base_url().'dashboard/');
84 84
                 } else {
85
-                    redirect(base_url() . 'user/user/');
85
+                    redirect(base_url().'user/user/');
86 86
                 }
87 87
             }
88 88
         } else {
@@ -92,12 +92,12 @@  discard block
 block discarded – undo
92 92
 
93 93
     function build_form($fields_array, $values) {
94 94
         $form_contents = '';
95
-        $form_contents.= '<div class="pop_md col-md-12 margin-t-10 padding-x-8">';
96
-        if(isset($fields_array['breadcrumb'])){
97
-            $form_contents.=form_breadcrumb($fields_array['breadcrumb']);
95
+        $form_contents .= '<div class="pop_md col-md-12 margin-t-10 padding-x-8">';
96
+        if (isset($fields_array['breadcrumb'])) {
97
+            $form_contents .= form_breadcrumb($fields_array['breadcrumb']);
98 98
             unset($fields_array['breadcrumb']);
99 99
         }
100
-        $form_contents.= form_open($fields_array['forms'][0], $fields_array['forms'][1]);
100
+        $form_contents .= form_open($fields_array['forms'][0], $fields_array['forms'][1]);
101 101
         unset($fields_array['forms']);
102 102
         $button_array = array();
103 103
         if (isset($fields_array['button_save']) || isset($fields_array['button_cancel']) || isset($fields_array['additional_button'])) {
@@ -113,76 +113,76 @@  discard block
 block discarded – undo
113 113
             }
114 114
         }
115 115
         if (isset($additiopnal_button)) {
116
-            $form_contents.= form_button(gettext($additiopnal_button));
116
+            $form_contents .= form_button(gettext($additiopnal_button));
117 117
         }
118 118
         $i = 0;
119 119
         foreach ($fields_array as $fieldset_key => $form_fileds) {
120 120
             if (count($fields_array) > 1) {
121 121
                 if ($i == 1 || $i == 3) {
122
-                    $form_contents.= '<div class="col-md-6 no-padding pull-right">';
123
-                    $form_contents.= '<div class="col-md-12 padding-x-4">';
122
+                    $form_contents .= '<div class="col-md-6 no-padding pull-right">';
123
+                    $form_contents .= '<div class="col-md-12 padding-x-4">';
124 124
                 } else {
125
-                    $form_contents.= '<div class="col-md-6 no-padding">';
126
-                    $form_contents.= '<div class="col-md-12 padding-x-4">';
125
+                    $form_contents .= '<div class="col-md-6 no-padding">';
126
+                    $form_contents .= '<div class="col-md-12 padding-x-4">';
127 127
                 }
128 128
             } else {
129
-               $form_contents.= '<div class="col-md-12 no-padding">';
130
-                $form_contents.= '<div class="col-md-12 no-padding">';
129
+               $form_contents .= '<div class="col-md-12 no-padding">';
130
+                $form_contents .= '<div class="col-md-12 no-padding">';
131 131
             }
132
-            $form_contents.= '<ul class="no-padding">';
133
-                $form_contents.= '<div class="col-md-12 no-padding">';
132
+            $form_contents .= '<ul class="no-padding">';
133
+                $form_contents .= '<div class="col-md-12 no-padding">';
134 134
             if ($i == 1 || $i == 3) {
135
-                $form_contents.= form_fieldset(gettext($fieldset_key));
135
+                $form_contents .= form_fieldset(gettext($fieldset_key));
136 136
             } else {
137
-                $form_contents.= form_fieldset(gettext($fieldset_key));
137
+                $form_contents .= form_fieldset(gettext($fieldset_key));
138 138
             }
139 139
             foreach ($form_fileds as $fieldkey => $fieldvalue) {
140
-                $form_contents.= '<li class="col-md-12">';
140
+                $form_contents .= '<li class="col-md-12">';
141 141
                 if ($fieldvalue[1] == 'HIDDEN') {
142 142
                     if (isset($this->CI->input->post))
143
-                        $fieldvalue[2]['value'] = (!$this->CI->input->post($fieldvalue[2]['name'])) ? @$fieldvalue[2]['value'] : $this->CI->input->post($fieldvalue[2]['name']);
143
+                        $fieldvalue[2]['value'] = ( ! $this->CI->input->post($fieldvalue[2]['name'])) ? @$fieldvalue[2]['value'] : $this->CI->input->post($fieldvalue[2]['name']);
144 144
                     else
145
-                        $fieldvalue[2]['value'] = ($values) ? (isset($values[$fieldvalue[2]['name']]) ? $values[$fieldvalue[2]['name']] : ''):(isset($fieldvalue[2]['value']) ? $fieldvalue[2]['value'] :'');
146
-                    $form_contents.= form_hidden($fieldvalue[2]['name'], $fieldvalue[2]['value']);
147
-                }else {
148
-		      $validation_arr=array();
149
-		      if($fieldvalue[1]=='INPUT'){
150
-		        if(!empty($fieldvalue[3])){
151
-		          $validation_arr=explode("|",$fieldvalue[3]);
145
+                        $fieldvalue[2]['value'] = ($values) ? (isset($values[$fieldvalue[2]['name']]) ? $values[$fieldvalue[2]['name']] : '') : (isset($fieldvalue[2]['value']) ? $fieldvalue[2]['value'] : '');
146
+                    $form_contents .= form_hidden($fieldvalue[2]['name'], $fieldvalue[2]['value']);
147
+                } else {
148
+		      $validation_arr = array();
149
+		      if ($fieldvalue[1] == 'INPUT') {
150
+		        if ( ! empty($fieldvalue[3])) {
151
+		          $validation_arr = explode("|", $fieldvalue[3]);
152 152
 		        }
153 153
 		      }
154
-		      elseif($fieldvalue[2]=='SELECT'){
154
+		      elseif ($fieldvalue[2] == 'SELECT') {
155 155
 
156
-		        if(is_array($fieldvalue[4])){
157
-		          $validation_arr=explode("|",$fieldvalue[4]['rules']);
158
-		        }else{
159
-		        $validation_arr=explode("|",$fieldvalue[4]);
156
+		        if (is_array($fieldvalue[4])) {
157
+		          $validation_arr = explode("|", $fieldvalue[4]['rules']);
158
+		        } else {
159
+		        $validation_arr = explode("|", $fieldvalue[4]);
160 160
 		        }
161 161
 		      }
162
-		      if(!empty($validation_arr)){
163
-		      $fieldvalue[0] = in_array('required',$validation_arr) ? $fieldvalue[0]."<span style='color:black;'> *</span>" : $fieldvalue[0];
164
-		      $fieldvalue[0] = in_array('dropdown',$validation_arr) ? $fieldvalue[0]."<span style='color:black;'> *</span>" : $fieldvalue[0];
162
+		      if ( ! empty($validation_arr)) {
163
+		      $fieldvalue[0] = in_array('required', $validation_arr) ? $fieldvalue[0]."<span style='color:black;'> *</span>" : $fieldvalue[0];
164
+		      $fieldvalue[0] = in_array('dropdown', $validation_arr) ? $fieldvalue[0]."<span style='color:black;'> *</span>" : $fieldvalue[0];
165 165
 		      }
166 166
  
167 167
                     if (is_array($fieldvalue[1]) || (is_array($fieldvalue[2]) && isset($fieldvalue[2]['hidden']))) {
168
-                        $form_contents.= form_label(gettext($fieldvalue[0]), $fieldvalue[0], array('class' => 'col-md-3 no-padding add_settings'));
168
+                        $form_contents .= form_label(gettext($fieldvalue[0]), $fieldvalue[0], array('class' => 'col-md-3 no-padding add_settings'));
169 169
                     } else {
170
-                        $form_contents.= form_label(gettext($fieldvalue[0]), "", array("class" => "col-md-3 no-padding"));
170
+                        $form_contents .= form_label(gettext($fieldvalue[0]), "", array("class" => "col-md-3 no-padding"));
171 171
                     }
172 172
                 }
173
-                if ($fieldvalue[2] == 'SELECT' && !isset($fieldvalue[13])) {
173
+                if ($fieldvalue[2] == 'SELECT' && ! isset($fieldvalue[13])) {
174 174
 
175 175
                 /*
176 176
                  To make Drop down enabled disabled
177 177
                 */
178
-                 $extra =isset($fieldvalue[1]['extra']) ? $fieldvalue[1]['extra'] :'';
178
+                 $extra = isset($fieldvalue[1]['extra']) ? $fieldvalue[1]['extra'] : '';
179 179
                  /***************************/
180 180
                     if ($fieldvalue[7] != '' && $fieldvalue[8] != '') {
181
-                        $str = $fieldvalue[7] . "," . $fieldvalue[8];
181
+                        $str = $fieldvalue[7].",".$fieldvalue[8];
182 182
 
183
-                        if (isset($this->CI->input->post)){
184
-                            $fieldvalue['value'] = (!$this->CI->input->post($fieldvalue[1])) ? @$fieldvalue[1] : $this->CI->input->post($fieldvalue[1]);
185
-                        }else{
183
+                        if (isset($this->CI->input->post)) {
184
+                            $fieldvalue['value'] = ( ! $this->CI->input->post($fieldvalue[1])) ? @$fieldvalue[1] : $this->CI->input->post($fieldvalue[1]);
185
+                        } else {
186 186
                             if (is_array($fieldvalue[1])) {
187 187
                                 $fieldvalue['value'] = ($values) ? @$values[$fieldvalue[1]['name']] : @$fieldvalue[1];
188 188
                             } else {
@@ -191,38 +191,38 @@  discard block
 block discarded – undo
191 191
                         }
192 192
                         $drp_array = call_user_func_array(array($this->CI->db_model, $fieldvalue[10]), array($str, $fieldvalue[9], $fieldvalue[11], $fieldvalue[12]));
193 193
 
194
-                        if ($fieldset_key ==  gettext('System Configuration Information') || ($fieldset_key == 'Billing Information'  && $fieldvalue[0] == 'Force Trunk') || ($fieldset_key == 'Card Information' && $fieldvalue[0] == 'Rate Group') || ($fieldset_key == 'Billing Information' && $fieldvalue[0] == 'Account') || $fieldset_key == 'Freeswitch Devices' && $fieldvalue[0] == 'Rate Group' || ($fieldset_key== 'Origination Rate Add/Edit' && $fieldvalue[0] == 'Trunks' )||$fieldset_key== 'Billing Information' && $fieldvalue[0] == 'Rate Group'  || ($fieldset_key== 'Information' && $fieldvalue[0] == 'Failover GW Name #1') || ($fieldset_key== 'Information' && $fieldvalue[0] == 'Failover GW Name #2') || ($fieldset_key== 'Information' && $fieldvalue[0] == 'Rate Group') || ($fieldset_key== 'Sip Devices' && $fieldvalue[0] == 'Sip Profile') || ($fieldset_key== 'Sip Devices' && $fieldvalue[0] == 'Account')) {
195
-                            $form_contents.=form_dropdown_all($fieldvalue[1], $drp_array, $fieldvalue['value'],$extra);
194
+                        if ($fieldset_key == gettext('System Configuration Information') || ($fieldset_key == 'Billing Information' && $fieldvalue[0] == 'Force Trunk') || ($fieldset_key == 'Card Information' && $fieldvalue[0] == 'Rate Group') || ($fieldset_key == 'Billing Information' && $fieldvalue[0] == 'Account') || $fieldset_key == 'Freeswitch Devices' && $fieldvalue[0] == 'Rate Group' || ($fieldset_key == 'Origination Rate Add/Edit' && $fieldvalue[0] == 'Trunks') || $fieldset_key == 'Billing Information' && $fieldvalue[0] == 'Rate Group' || ($fieldset_key == 'Information' && $fieldvalue[0] == 'Failover GW Name #1') || ($fieldset_key == 'Information' && $fieldvalue[0] == 'Failover GW Name #2') || ($fieldset_key == 'Information' && $fieldvalue[0] == 'Rate Group') || ($fieldset_key == 'Sip Devices' && $fieldvalue[0] == 'Sip Profile') || ($fieldset_key == 'Sip Devices' && $fieldvalue[0] == 'Account')) {
195
+                            $form_contents .= form_dropdown_all($fieldvalue[1], $drp_array, $fieldvalue['value'], $extra);
196 196
                         } else {
197
-                            $form_contents.=form_dropdown($fieldvalue[1], $drp_array, $fieldvalue['value'], $extra);
197
+                            $form_contents .= form_dropdown($fieldvalue[1], $drp_array, $fieldvalue['value'], $extra);
198 198
                         }
199
-			            if(isset($fieldvalue[4]) && $fieldvalue[4] != ''){
200
-                        	if(is_array($fieldvalue[4])){
199
+			            if (isset($fieldvalue[4]) && $fieldvalue[4] != '') {
200
+                        	if (is_array($fieldvalue[4])) {
201 201
 								
202
-								if(isset($fieldvalue[1]['name'])){
203
-									$fieldvalue_pass=$fieldvalue[1]['name'];
204
-								}else{
205
-									$fieldvalue_pass=$fieldvalue[1];
202
+								if (isset($fieldvalue[1]['name'])) {
203
+									$fieldvalue_pass = $fieldvalue[1]['name'];
204
+								} else {
205
+									$fieldvalue_pass = $fieldvalue[1];
206 206
 								}
207 207
 								
208 208
         				        $this->CI->form_validation->set_rules($fieldvalue_pass, $fieldvalue[0], $fieldvalue[4]['rules']);
209
-        				    }else{
209
+        				    } else {
210 210
 								
211
-								if(isset($fieldvalue[1]['name'])){
212
-									$fieldvalue_pass=$fieldvalue[1]['name'];
213
-								}else{
214
-									$fieldvalue_pass=$fieldvalue[1];
211
+								if (isset($fieldvalue[1]['name'])) {
212
+									$fieldvalue_pass = $fieldvalue[1]['name'];
213
+								} else {
214
+									$fieldvalue_pass = $fieldvalue[1];
215 215
 								}
216 216
 								
217 217
         				       $this->CI->form_validation->set_rules($fieldvalue_pass, $fieldvalue[0], $fieldvalue[4]);
218 218
         				    }   
219 219
                         }
220
-                        $form_contents.= '<div class="tooltips error_div pull-left no-padding" id="'.(is_array($fieldvalue[1])?$fieldvalue[1]['name']:$fieldvalue[1]).'_error_div" ><i style="color:#D95C5C; padding-left: 3px; padding-top: 10px;" class="fa fa-exclamation-triangle"></i>';
221
-                        $form_contents.= '<span class="popup_error error  no-padding" id="'.(gettext(is_array($fieldvalue[1])?$fieldvalue[1]['name']:$fieldvalue[1])).'_error">
220
+                        $form_contents .= '<div class="tooltips error_div pull-left no-padding" id="'.(is_array($fieldvalue[1]) ? $fieldvalue[1]['name'] : $fieldvalue[1]).'_error_div" ><i style="color:#D95C5C; padding-left: 3px; padding-top: 10px;" class="fa fa-exclamation-triangle"></i>';
221
+                        $form_contents .= '<span class="popup_error error  no-padding" id="'.(gettext(is_array($fieldvalue[1]) ? $fieldvalue[1]['name'] : $fieldvalue[1])).'_error">
222 222
                         </span></div>';                         
223 223
                     } else {
224 224
                         if (isset($this->CI->input->post)) {
225
-                            $fieldvalue['value'] = (!$this->CI->input->post($fieldvalue[1])) ? @$fieldvalue[1] : $this->CI->input->post($fieldvalue[1]);
225
+                            $fieldvalue['value'] = ( ! $this->CI->input->post($fieldvalue[1])) ? @$fieldvalue[1] : $this->CI->input->post($fieldvalue[1]);
226 226
                         } else {
227 227
                             if (is_array($fieldvalue[1])) {
228 228
                                 $fieldvalue['value'] = ($values) ? @$values[$fieldvalue[1]['name']] : @$fieldvalue[1];
@@ -231,53 +231,53 @@  discard block
 block discarded – undo
231 231
                             }
232 232
                         }
233 233
 
234
-                        $str = $fieldvalue[7] . "," . $fieldvalue[8];
234
+                        $str = $fieldvalue[7].",".$fieldvalue[8];
235 235
                         $drp_array = call_user_func_array(array($this->CI->common, $fieldvalue[10]), array($fieldvalue[9]));
236
-                        $form_contents.=form_dropdown($fieldvalue[1], $drp_array, $fieldvalue['value'],$extra);
237
-                        if(isset($fieldvalue[4]) && $fieldvalue[4] != ''){
236
+                        $form_contents .= form_dropdown($fieldvalue[1], $drp_array, $fieldvalue['value'], $extra);
237
+                        if (isset($fieldvalue[4]) && $fieldvalue[4] != '') {
238 238
 			  $this->CI->form_validation->set_rules($fieldvalue[1], $fieldvalue[0], $fieldvalue[4]);
239 239
                         }
240
-                        $form_contents.= '<div class="tooltips error_div pull-left no-padding" id="'.(is_array($fieldvalue[1])?$fieldvalue[1]['name']:$fieldvalue[1]).'_error_div" ><i style="color:#D95C5C; padding-left: 3px; padding-top: 10px;" class="fa fa-exclamation-triangle"></i>';
241
-                        $form_contents.= '<span class="popup_error error  no-padding" id="'.(is_array($fieldvalue[1])?$fieldvalue[1]['name']:$fieldvalue[1]).'_error">
240
+                        $form_contents .= '<div class="tooltips error_div pull-left no-padding" id="'.(is_array($fieldvalue[1]) ? $fieldvalue[1]['name'] : $fieldvalue[1]).'_error_div" ><i style="color:#D95C5C; padding-left: 3px; padding-top: 10px;" class="fa fa-exclamation-triangle"></i>';
241
+                        $form_contents .= '<span class="popup_error error  no-padding" id="'.(is_array($fieldvalue[1]) ? $fieldvalue[1]['name'] : $fieldvalue[1]).'_error">
242 242
                         </span></div>';                        
243 243
                     }
244 244
                 } else if (isset($fieldvalue[13]) && $fieldvalue[13] != '') {
245 245
 
246 246
                     /* For multi select code */
247
-                    $str = $fieldvalue[7] . "," . $fieldvalue[8];
247
+                    $str = $fieldvalue[7].",".$fieldvalue[8];
248 248
 
249 249
                     if (isset($this->CI->input->post))
250
-                        $fieldvalue['value'] = (!$this->CI->input->post($fieldvalue[1])) ? @$fieldvalue[1] : $this->CI->input->post($fieldvalue[1]);
250
+                        $fieldvalue['value'] = ( ! $this->CI->input->post($fieldvalue[1])) ? @$fieldvalue[1] : $this->CI->input->post($fieldvalue[1]);
251 251
                     else
252 252
                         $fieldvalue['value'] = ($values) ? @$values[$fieldvalue[1]] : @$fieldvalue[1];
253 253
 
254 254
                     $drp_array = call_user_func_array(array($this->CI->db_model, $fieldvalue[10]), array($str, $fieldvalue[9], $fieldvalue[11], $fieldvalue[12]));
255 255
                     if ($fieldset_key === 'System Configuration Information') {
256
-                        $form_contents.=form_dropdown_multiselect($fieldvalue[1], $drp_array, '');
256
+                        $form_contents .= form_dropdown_multiselect($fieldvalue[1], $drp_array, '');
257 257
                     } else {
258
-                        $form_contents.=form_dropdown_multiselect($fieldvalue[1] . "[]", $drp_array, $fieldvalue['value']);
258
+                        $form_contents .= form_dropdown_multiselect($fieldvalue[1]."[]", $drp_array, $fieldvalue['value']);
259 259
                     }
260
-                    if(isset($fieldvalue[4]) && $fieldvalue[4] != ''){
260
+                    if (isset($fieldvalue[4]) && $fieldvalue[4] != '') {
261 261
 			$this->CI->form_validation->set_rules($fieldvalue[1], $fieldvalue[0], $fieldvalue[4]);
262 262
                     }
263
-                    $form_contents.= '<div class="tooltips error_div pull-left no-padding" id="'.$fieldvalue[1].'_error_div" ><i style="color:#D95C5C; padding-left: 3px; padding-top: 10px;" class="fa fa-exclamation-triangle"></i>';
264
-                    $form_contents.= '<span class="popup_error error  no-padding" id="'.$fieldvalue[1].'_error"></span></div>';                   
263
+                    $form_contents .= '<div class="tooltips error_div pull-left no-padding" id="'.$fieldvalue[1].'_error_div" ><i style="color:#D95C5C; padding-left: 3px; padding-top: 10px;" class="fa fa-exclamation-triangle"></i>';
264
+                    $form_contents .= '<span class="popup_error error  no-padding" id="'.$fieldvalue[1].'_error"></span></div>';                   
265 265
                     /* End---------------------   For multi select code */
266 266
                 } else if ($fieldvalue[1] == 'INPUT') {
267 267
 
268 268
 
269 269
                     if (isset($this->CI->input->post))
270
-                        $fieldvalue[2]['value'] = (!$this->CI->input->post($fieldvalue[2]['name'])) ? $fieldvalue[2]['value'] : $this->CI->input->post($fieldvalue[2]['name']);
271
-                    else{
272
-                        $fieldvalue[2]['value'] = ($values) ? (isset($values[$fieldvalue[2]['name']]) ? $values[$fieldvalue[2]['name']] : ''):(isset($fieldvalue[2]['value']) ? $fieldvalue[2]['value'] :'');
270
+                        $fieldvalue[2]['value'] = ( ! $this->CI->input->post($fieldvalue[2]['name'])) ? $fieldvalue[2]['value'] : $this->CI->input->post($fieldvalue[2]['name']);
271
+                    else {
272
+                        $fieldvalue[2]['value'] = ($values) ? (isset($values[$fieldvalue[2]['name']]) ? $values[$fieldvalue[2]['name']] : '') : (isset($fieldvalue[2]['value']) ? $fieldvalue[2]['value'] : '');
273 273
                     }    
274
-                    $form_contents.= form_input($fieldvalue[2], 'readonly');
275
-                    if(isset($fieldvalue[6]) && !empty($fieldvalue[6])){
276
-                        $form_contents.=$fieldvalue[6];
274
+                    $form_contents .= form_input($fieldvalue[2], 'readonly');
275
+                    if (isset($fieldvalue[6]) && ! empty($fieldvalue[6])) {
276
+                        $form_contents .= $fieldvalue[6];
277 277
                     }    
278 278
                     $this->CI->form_validation->set_rules($fieldvalue[2]['name'], $fieldvalue[0], $fieldvalue[3]);
279
-                    $form_contents.= '<div class="tooltips error_div pull-left no-padding" id="'.$fieldvalue[2]['name'].'_error_div" ><i style="color:#D95C5C; padding-left: 3px; padding-top: 10px;" class="fa fa-exclamation-triangle"></i>';
280
-                    $form_contents.= '<span class="popup_error error  no-padding" id="'.$fieldvalue[2]['name'].'_error">
279
+                    $form_contents .= '<div class="tooltips error_div pull-left no-padding" id="'.$fieldvalue[2]['name'].'_error_div" ><i style="color:#D95C5C; padding-left: 3px; padding-top: 10px;" class="fa fa-exclamation-triangle"></i>';
280
+                    $form_contents .= '<span class="popup_error error  no-padding" id="'.$fieldvalue[2]['name'].'_error">
281 281
                     </span></div>';
282 282
                 }
283 283
                 /* 
@@ -285,98 +285,98 @@  discard block
 block discarded – undo
285 285
                  */
286 286
                 else if ($fieldvalue[1] == 'IMAGE') {
287 287
                     if (isset($this->CI->input->post))
288
-                        $fieldvalue[2]['value'] = (!$this->CI->input->post($fieldvalue[2]['name'])) ? @$fieldvalue[2]['value'] : $this->CI->input->post($fieldvalue[2]['name']);
288
+                        $fieldvalue[2]['value'] = ( ! $this->CI->input->post($fieldvalue[2]['name'])) ? @$fieldvalue[2]['value'] : $this->CI->input->post($fieldvalue[2]['name']);
289 289
                        
290 290
                     else
291 291
                         $fieldvalue[2]['value'] = ($values) ? @$values[$fieldvalue[2]['name']] : @$fieldvalue[2]['value'];
292 292
                         $fieldvalue[2]['style'] = isset($fieldvalue[2]['style']) ? $fieldvalue[2]['style'] : "";
293
-                    $form_contents.= form_image($fieldvalue[2], 'readonly',$fieldvalue[2]['style']);
294
-                    	 $form_contents.=@$fieldvalue[6];
293
+                    $form_contents .= form_image($fieldvalue[2], 'readonly', $fieldvalue[2]['style']);
294
+                    	 $form_contents .= @$fieldvalue[6];
295 295
                     $this->CI->form_validation->set_rules($fieldvalue[2]['name'], $fieldvalue[0], $fieldvalue[3]);
296
-                    $form_contents.= '<div class="tooltips error_div pull-left no-padding" id="'.$fieldvalue[2]['name'].'_error_div" ><i style="color:#D95C5C; padding-left: 3px; padding-top: 10px;" class="fa fa-exclamation-triangle"></i>';
297
-                    $form_contents.= '<span class="popup_error error  no-padding" id="'.$fieldvalue[2]['name'].'_error">
296
+                    $form_contents .= '<div class="tooltips error_div pull-left no-padding" id="'.$fieldvalue[2]['name'].'_error_div" ><i style="color:#D95C5C; padding-left: 3px; padding-top: 10px;" class="fa fa-exclamation-triangle"></i>';
297
+                    $form_contents .= '<span class="popup_error error  no-padding" id="'.$fieldvalue[2]['name'].'_error">
298 298
                     </span></div>';
299 299
                 }
300 300
                 else if ($fieldvalue[1] == 'DEL_BUTTON') {
301 301
                     if (isset($this->CI->input->post))
302
-                        $fieldvalue[2]['value'] = (!$this->CI->input->post($fieldvalue[2]['name'])) ? @$fieldvalue[2]['value'] : $this->CI->input->post($fieldvalue[2]['name']);
302
+                        $fieldvalue[2]['value'] = ( ! $this->CI->input->post($fieldvalue[2]['name'])) ? @$fieldvalue[2]['value'] : $this->CI->input->post($fieldvalue[2]['name']);
303 303
                        
304 304
                     else
305 305
                         $fieldvalue[2]['value'] = ($values) ? @$values[$fieldvalue[2]['name']] : @$fieldvalue[2]['value'];
306 306
                         $fieldvalue[2]['style'] = isset($fieldvalue[2]['style']) ? $fieldvalue[2]['style'] : "";
307
-                    $form_contents.= form_img_delete($fieldvalue[2], 'readonly',$fieldvalue[2]['style']);
308
-                    	 $form_contents.=@$fieldvalue[6];
307
+                    $form_contents .= form_img_delete($fieldvalue[2], 'readonly', $fieldvalue[2]['style']);
308
+                    	 $form_contents .= @$fieldvalue[6];
309 309
                     $this->CI->form_validation->set_rules($fieldvalue[2]['name'], $fieldvalue[0], $fieldvalue[3]);
310
-                    $form_contents.= '<div class="tooltips error_div pull-left no-padding" id="'.$fieldvalue[2]['name'].'_error_div" ><i style="color:#D95C5C; padding-left: 3px; padding-top: 10px;" class="fa fa-exclamation-triangle"></i>';
311
-                    $form_contents.= '<span class="popup_error error  no-padding" id="'.$fieldvalue[2]['name'].'_error">
310
+                    $form_contents .= '<div class="tooltips error_div pull-left no-padding" id="'.$fieldvalue[2]['name'].'_error_div" ><i style="color:#D95C5C; padding-left: 3px; padding-top: 10px;" class="fa fa-exclamation-triangle"></i>';
311
+                    $form_contents .= '<span class="popup_error error  no-padding" id="'.$fieldvalue[2]['name'].'_error">
312 312
                     </span></div>';
313 313
                 }
314 314
                 /**********************************************************************************/
315 315
                 else if ($fieldvalue[1] == 'PASSWORD') {
316 316
                     if (isset($this->CI->input->post))
317
-                        $fieldvalue[2]['value'] = (!$this->CI->input->post($fieldvalue[2]['name'])) ? @$fieldvalue[2]['value'] : $this->CI->input->post($fieldvalue[2]['name']);
317
+                        $fieldvalue[2]['value'] = ( ! $this->CI->input->post($fieldvalue[2]['name'])) ? @$fieldvalue[2]['value'] : $this->CI->input->post($fieldvalue[2]['name']);
318 318
                     else
319
-                        $fieldvalue[2]['value'] = ($values) ?@$values[$fieldvalue[2]['name']] : @$fieldvalue[2]['value'];
320
-                    $form_contents.= form_password($fieldvalue[2]);
319
+                        $fieldvalue[2]['value'] = ($values) ? @$values[$fieldvalue[2]['name']] : @$fieldvalue[2]['value'];
320
+                    $form_contents .= form_password($fieldvalue[2]);
321 321
                     $this->CI->form_validation->set_rules($fieldvalue[2]['name'], $fieldvalue[0], $fieldvalue[3]);
322
-                    $form_contents.= '<div class="tooltips error_div pull-left no-padding" id="'.$fieldvalue[2]['name'].'_error_div" ><i style="color:#D95C5C; padding-left: 3px; padding-top: 10px;" class="fa fa-exclamation-triangle"></i>';
323
-                    $form_contents.= '<span class="popup_error error  no-padding" id="'.$fieldvalue[2]['name'].'_error">
322
+                    $form_contents .= '<div class="tooltips error_div pull-left no-padding" id="'.$fieldvalue[2]['name'].'_error_div" ><i style="color:#D95C5C; padding-left: 3px; padding-top: 10px;" class="fa fa-exclamation-triangle"></i>';
323
+                    $form_contents .= '<span class="popup_error error  no-padding" id="'.$fieldvalue[2]['name'].'_error">
324 324
                     </span></div>';
325 325
                 } else if ($fieldvalue[2] == 'CHECKBOX') {
326 326
                     $OptionArray = array();
327 327
 
328
-					if(isset($fieldvalue[7]) && $fieldvalue[7] != '')
328
+					if (isset($fieldvalue[7]) && $fieldvalue[7] != '')
329 329
 					$OptionArray = call_user_func_array(array($this->CI->common, $fieldvalue[7]), array($fieldvalue[6]));
330
-                    if (isset($this->CI->input->post)){
331
-                        $fieldvalue[3]['value'] = (!$this->CI->input->post($fieldvalue[1])) ? @$fieldvalue[3]['value'] : $this->CI->input->post($fieldvalue[1]);
330
+                    if (isset($this->CI->input->post)) {
331
+                        $fieldvalue[3]['value'] = ( ! $this->CI->input->post($fieldvalue[1])) ? @$fieldvalue[3]['value'] : $this->CI->input->post($fieldvalue[1]);
332 332
                     }    
333 333
                     else
334 334
                     {
335
-                        $fieldvalue[3]['value'] = ($values) ? (isset($values[$fieldvalue[1]]) && $values[$fieldvalue[1]] ? 1: 0) : @$fieldvalue[3]['value'];
335
+                        $fieldvalue[3]['value'] = ($values) ? (isset($values[$fieldvalue[1]]) && $values[$fieldvalue[1]] ? 1 : 0) : @$fieldvalue[3]['value'];
336 336
 					}
337 337
                     if ($fieldvalue[3]['value'] == "1") {
338 338
                         $checked = true;
339 339
                     } else {
340 340
                         $checked = false;
341 341
                     };
342
-                    if(isset($fieldvalue[3]['table_name']) && $fieldvalue[3]['table_name'] != ""){
342
+                    if (isset($fieldvalue[3]['table_name']) && $fieldvalue[3]['table_name'] != "") {
343 343
 							
344
-						 $form_contents.= form_checkbox($fieldvalue[1], $fieldvalue[3]['value'],$checked , $OptionArray);
345
-					}else{
346
-						 $form_contents.= form_checkbox($fieldvalue[1], $fieldvalue[3]['value'],$checked ,$OptionArray);
344
+						 $form_contents .= form_checkbox($fieldvalue[1], $fieldvalue[3]['value'], $checked, $OptionArray);
345
+					} else {
346
+						 $form_contents .= form_checkbox($fieldvalue[1], $fieldvalue[3]['value'], $checked, $OptionArray);
347 347
 					}
348 348
                 } else if ($fieldvalue[1] == 'TEXTAREA') {
349 349
 
350 350
                     if (isset($this->CI->input->post))
351
-                        $fieldvalue[2]['value'] = (!$this->CI->input->post($fieldvalue[2]['name'])) ? @$fieldvalue[2]['value'] : $this->CI->input->post($fieldvalue[2]['name']);
351
+                        $fieldvalue[2]['value'] = ( ! $this->CI->input->post($fieldvalue[2]['name'])) ? @$fieldvalue[2]['value'] : $this->CI->input->post($fieldvalue[2]['name']);
352 352
                     else
353 353
                         $fieldvalue[2]['value'] = ($values) ? $values[$fieldvalue[2]['name']] : @$fieldvalue[2]['value'];
354
-                    $form_contents.= form_textarea($fieldvalue[2]);
354
+                    $form_contents .= form_textarea($fieldvalue[2]);
355 355
                 }
356 356
                 else if ($fieldvalue[2] == 'RADIO') {
357 357
 
358
-                    $form_contents.= form_radio($fieldvalue[1], $fieldvalue[3]['value'], $fieldvalue[3]['checked']);
358
+                    $form_contents .= form_radio($fieldvalue[1], $fieldvalue[3]['value'], $fieldvalue[3]['checked']);
359 359
                 }
360
-                $form_contents.= '</li>';
360
+                $form_contents .= '</li>';
361 361
             }
362 362
 
363
-            $form_contents.= '</ul>';
364
-            $form_contents.= '</div>';
365
-            $form_contents.= '</div>';
363
+            $form_contents .= '</ul>';
364
+            $form_contents .= '</div>';
365
+            $form_contents .= '</div>';
366 366
             $i++;
367 367
         }
368 368
 
369
-        $form_contents.= '<center><div class="col-md-12 margin-t-20 margin-b-20">';
369
+        $form_contents .= '<center><div class="col-md-12 margin-t-20 margin-b-20">';
370 370
 
371
-        $form_contents.= form_button($save);
371
+        $form_contents .= form_button($save);
372 372
 
373 373
 	if (isset($cancel)) {
374
-            $form_contents.= form_button($cancel);
374
+            $form_contents .= form_button($cancel);
375 375
         }
376
-        $form_contents.= '</center></div>';
377
-        $form_contents.= form_fieldset_close();
378
-        $form_contents.= form_close();
379
-        $form_contents.= '</div>';
376
+        $form_contents .= '</center></div>';
377
+        $form_contents .= form_fieldset_close();
378
+        $form_contents .= form_close();
379
+        $form_contents .= '</div>';
380 380
 
381 381
 
382 382
         return $form_contents;
@@ -384,8 +384,8 @@  discard block
 block discarded – undo
384 384
 
385 385
     function build_serach_form($fields_array) {
386 386
         $form_contents = '';
387
-        $form_contents.= '<div>';
388
-        $form_contents.= form_open($fields_array['forms'][0], $fields_array['forms'][1]);
387
+        $form_contents .= '<div>';
388
+        $form_contents .= form_open($fields_array['forms'][0], $fields_array['forms'][1]);
389 389
         unset($fields_array['forms']);
390 390
         $button_array = array();
391 391
 	/*******
@@ -398,13 +398,13 @@  discard block
 block discarded – undo
398 398
                 $cancel = $fields_array['button_reset'];
399 399
                 unset($fields_array['button_reset']);
400 400
             }
401
-	    $button_search_delete='';
401
+	    $button_search_delete = '';
402 402
             if (isset($fields_array['button_search_delete'])) {
403 403
                 $button_search_delete = $fields_array['button_search_delete'];
404 404
                 unset($fields_array['button_search_delete']);
405 405
             }
406
-            if(isset($fields_array['display_in'])){
407
-	      $display_in=$fields_array['display_in'];
406
+            if (isset($fields_array['display_in'])) {
407
+	      $display_in = $fields_array['display_in'];
408 408
 	      unset($fields_array['display_in']);
409 409
 	    }
410 410
         }
@@ -412,31 +412,31 @@  discard block
 block discarded – undo
412 412
         $i = 1;
413 413
         foreach ($fields_array as $fieldset_key => $form_fileds) {
414 414
 
415
-            $form_contents.= '<ul class="padding-15">';
416
-            $form_contents.= form_fieldset(gettext($fieldset_key),array('style' => 'font-weight:bold;'),"search");
415
+            $form_contents .= '<ul class="padding-15">';
416
+            $form_contents .= form_fieldset(gettext($fieldset_key), array('style' => 'font-weight:bold;'), "search");
417 417
 
418 418
             foreach ($form_fileds as $fieldkey => $fieldvalue) {
419 419
                 if ($i == 0) {
420
-                    $form_contents.= '<li class="col-md-12">';
420
+                    $form_contents .= '<li class="col-md-12">';
421 421
                 }
422
-                $form_contents.= '<div class="col-md-3 no-padding">';
422
+                $form_contents .= '<div class="col-md-3 no-padding">';
423 423
                 if ($fieldvalue[1] == 'HIDDEN') {
424
-                    $form_contents.= form_hidden($fieldvalue[2], $fieldvalue[3]);
424
+                    $form_contents .= form_hidden($fieldvalue[2], $fieldvalue[3]);
425 425
                 } else {
426
-                    $form_contents.= form_label(gettext($fieldvalue[0]), "", array("class" => "search_label col-md-12 no-padding"));
426
+                    $form_contents .= form_label(gettext($fieldvalue[0]), "", array("class" => "search_label col-md-12 no-padding"));
427 427
                 }
428 428
                 if ($fieldvalue[1] == 'INPUT') {
429
-                    $form_contents.= form_input($fieldvalue[2]);
429
+                    $form_contents .= form_input($fieldvalue[2]);
430 430
                 }
431 431
 
432 432
 
433 433
                 if ($fieldvalue[2] == 'SELECT' || $fieldvalue[5] == '1') {
434 434
 			  
435 435
                     if ($fieldvalue[7] != '' && $fieldvalue[8] != '') {
436
-                        $str = $fieldvalue[7] . "," . $fieldvalue[8];
436
+                        $str = $fieldvalue[7].",".$fieldvalue[8];
437 437
 
438 438
                         $drp_array = call_user_func_array(array($this->CI->db_model, $fieldvalue[10]), array($str, $fieldvalue[9], $fieldvalue[11], $fieldvalue[12]));
439
-                        $form_contents.=form_dropdown_all(gettext($fieldvalue[1]), $drp_array, '');
439
+                        $form_contents .= form_dropdown_all(gettext($fieldvalue[1]), $drp_array, '');
440 440
                     } else {
441 441
 
442 442
                         if ($fieldvalue[1] == 'INPUT') {
@@ -444,54 +444,54 @@  discard block
 block discarded – undo
444 444
                         }
445 445
 			
446 446
                         $drp_array = call_user_func_array(array($this->CI->common, $fieldvalue[10]), array($fieldvalue[9]));
447
-                        $form_contents.=form_dropdown_all_search(gettext($fieldvalue[1]), $drp_array, '');
447
+                        $form_contents .= form_dropdown_all_search(gettext($fieldvalue[1]), $drp_array, '');
448 448
                     }
449 449
                 } else if ($fieldvalue[1] == 'PASSWORD') {
450
-                    $form_contents.= form_password($fieldvalue[2]);
450
+                    $form_contents .= form_password($fieldvalue[2]);
451 451
                 } else if ($fieldvalue[2] == 'CHECKBOX') {
452
-                    $form_contents.= form_checkbox(gettext($fieldvalue[1]), $fieldvalue[3]['value'], $fieldvalue[3]['checked']);
452
+                    $form_contents .= form_checkbox(gettext($fieldvalue[1]), $fieldvalue[3]['value'], $fieldvalue[3]['checked']);
453 453
                 }
454
-                $form_contents.= '</div>';
454
+                $form_contents .= '</div>';
455 455
                 if ($i % 5 == 0) {
456
-                    $form_contents.= '</li>';
456
+                    $form_contents .= '</li>';
457 457
                     $i = 0;
458 458
                 }
459 459
                 $i++;
460 460
             }
461 461
         }
462
-        $form_contents.= '<div class="col-md-12 margin-t-20 margin-b-20">';
463
-        $form_contents.= form_button($cancel);
464
-        $form_contents.= form_button($save);
465
-        if(!empty($display_in)){
466
-            $form_contents.="<div class='col-md-5 pull-right'>";
467
-            $form_contents.="<div class='col-md-3'></div>";
468
-            $extra_parameters['class']=$display_in['label_class'];
469
-            $extra_parameters['style']=$display_in['label_style'];
470
-            $form_contents.=form_label($display_in['content'], "",$extra_parameters);
471
-            $drp_array = call_user_func_array(array($this->CI->common,$display_in['function']),array());
472
-            $extra_parameters['class']=$display_in['dropdown_class'];
473
-            $extra_parameters['style']=$display_in['dropdown_style'];
474
-            $form_contents.=form_dropdown_all_search($display_in, $drp_array, '',$extra_parameters);
475
-            $form_contents.="</div>";
462
+        $form_contents .= '<div class="col-md-12 margin-t-20 margin-b-20">';
463
+        $form_contents .= form_button($cancel);
464
+        $form_contents .= form_button($save);
465
+        if ( ! empty($display_in)) {
466
+            $form_contents .= "<div class='col-md-5 pull-right'>";
467
+            $form_contents .= "<div class='col-md-3'></div>";
468
+            $extra_parameters['class'] = $display_in['label_class'];
469
+            $extra_parameters['style'] = $display_in['label_style'];
470
+            $form_contents .= form_label($display_in['content'], "", $extra_parameters);
471
+            $drp_array = call_user_func_array(array($this->CI->common, $display_in['function']), array());
472
+            $extra_parameters['class'] = $display_in['dropdown_class'];
473
+            $extra_parameters['style'] = $display_in['dropdown_style'];
474
+            $form_contents .= form_dropdown_all_search($display_in, $drp_array, '', $extra_parameters);
475
+            $form_contents .= "</div>";
476 476
         }
477
-        if(isset($button_search_delete) && $button_search_delete != ''){
478
-	  $form_contents.= form_button($button_search_delete);
477
+        if (isset($button_search_delete) && $button_search_delete != '') {
478
+	  $form_contents .= form_button($button_search_delete);
479 479
         }
480
-        $form_contents.='<div class="col-md-12 no-padding margin-t-15" style="">
480
+        $form_contents .= '<div class="col-md-12 no-padding margin-t-15" style="">
481 481
 		<div class="pull-right btn-close" id="global_clearsearch_filter">Close</div> 
482 482
 	</div>';
483
-        $form_contents.= '</ul>';        
484
-        $form_contents.= '</div>';
485
-        $form_contents.= form_fieldset_close();
486
-        $form_contents.= form_close();
487
-        $form_contents.= '</div>';
483
+        $form_contents .= '</ul>';        
484
+        $form_contents .= '</div>';
485
+        $form_contents .= form_fieldset_close();
486
+        $form_contents .= form_close();
487
+        $form_contents .= '</div>';
488 488
 
489 489
         return $form_contents;
490 490
     }
491 491
     function build_batchupdate_form($fields_array) {
492 492
         $form_contents = '';
493
-        $form_contents.= '<div >';
494
-        $form_contents.= form_open($fields_array['forms'][0], $fields_array['forms'][1]);
493
+        $form_contents .= '<div >';
494
+        $form_contents .= form_open($fields_array['forms'][0], $fields_array['forms'][1]);
495 495
         unset($fields_array['forms']);
496 496
         $button_array = array();
497 497
         if (isset($fields_array['button_search']) || isset($fields_array['button_reset'])) {
@@ -505,69 +505,69 @@  discard block
 block discarded – undo
505 505
         $i = 1;
506 506
         foreach ($fields_array as $fieldset_key => $form_fileds) {
507 507
 
508
-            $form_contents.= '<ul>';
509
-            $form_contents.= form_fieldset(gettext($fieldset_key), array('style' => 'margin-left:-22px;font-weight:bold;'));
508
+            $form_contents .= '<ul>';
509
+            $form_contents .= form_fieldset(gettext($fieldset_key), array('style' => 'margin-left:-22px;font-weight:bold;'));
510 510
             foreach ($form_fileds as $fieldkey => $fieldvalue) {
511 511
                 if ($i == 0) {
512
-                    $form_contents.= '<li>';
512
+                    $form_contents .= '<li>';
513 513
                 }
514
-                $form_contents.= '<div class="col-md-4 no-padding">';
514
+                $form_contents .= '<div class="col-md-4 no-padding">';
515 515
                 if ($fieldvalue[1] == 'HIDDEN') {
516
-                    $form_contents.= form_hidden($fieldvalue[2], $fieldvalue[3]);
516
+                    $form_contents .= form_hidden($fieldvalue[2], $fieldvalue[3]);
517 517
                 } else {
518
-                    $form_contents.= form_label(gettext($fieldvalue[0]), "", array("class" => "search_label col-md-12 no-padding"));
518
+                    $form_contents .= form_label(gettext($fieldvalue[0]), "", array("class" => "search_label col-md-12 no-padding"));
519 519
                 }
520 520
                 if ($fieldvalue[2] == 'SELECT' || $fieldvalue[5] == '1') {
521 521
                     if ($fieldvalue[7] != '' && $fieldvalue[8] != '') {
522
-                        $str = $fieldvalue[7] . "," . $fieldvalue[8];
523
-                        if(is_array($fieldvalue[13])){
522
+                        $str = $fieldvalue[7].",".$fieldvalue[8];
523
+                        if (is_array($fieldvalue[13])) {
524 524
                             $drp_array = call_user_func_array(array($this->CI->common, $fieldvalue[14]), array($fieldvalue[13]));
525
-                            $form_contents.=form_dropdown($fieldvalue[13], $drp_array, '');
525
+                            $form_contents .= form_dropdown($fieldvalue[13], $drp_array, '');
526 526
                         }
527 527
                         /**
528 528
   		        ASTPP  3.0 
529 529
    		        Reseller Batch Update
530 530
                         **/ 
531
-                        if($fieldvalue[10] == 'set_status'){
532
-			$drp_array =array('0'=>'Active','1'=>'Inactive');
531
+                        if ($fieldvalue[10] == 'set_status') {
532
+			$drp_array = array('0'=>'Active', '1'=>'Inactive');
533 533
 			}
534 534
 			/************************************************************/
535
-			else{
536
-                        $drp_array = call_user_func_array(array($this->CI->db_model, $fieldvalue[10]), array($str, $fieldvalue[9], $fieldvalue[11], $fieldvalue[12]));}
537
-                        $form_contents.=form_dropdown_all($fieldvalue[1], $drp_array, '');
535
+			else {
536
+                        $drp_array = call_user_func_array(array($this->CI->db_model, $fieldvalue[10]), array($str, $fieldvalue[9], $fieldvalue[11], $fieldvalue[12])); }
537
+                        $form_contents .= form_dropdown_all($fieldvalue[1], $drp_array, '');
538 538
                     } else {
539 539
                         if ($fieldvalue[1] == 'INPUT') {
540 540
                             $drp_name = $fieldvalue[6];
541 541
                         }
542 542
                         $drp_array = call_user_func_array(array($this->CI->common, $fieldvalue[10]), array($fieldvalue[9]));
543
-                        $form_contents.=form_dropdown($drp_name, $drp_array, '');
543
+                        $form_contents .= form_dropdown($drp_name, $drp_array, '');
544 544
                     }
545 545
                 }
546 546
                 if ($fieldvalue[1] == 'INPUT') {
547
-                    $form_contents.= form_input($fieldvalue[2]);
547
+                    $form_contents .= form_input($fieldvalue[2]);
548 548
                 } else if ($fieldvalue[2] == 'CHECKBOX') {
549
-                    $form_contents.= form_checkbox($fieldvalue[1], $fieldvalue[3]['value'], $fieldvalue[3]['checked']);
549
+                    $form_contents .= form_checkbox($fieldvalue[1], $fieldvalue[3]['value'], $fieldvalue[3]['checked']);
550 550
                 }
551
-                $form_contents.= '</div>';
551
+                $form_contents .= '</div>';
552 552
                 if ($i % 5 == 0) {
553
-                    $form_contents.= '</li>';
553
+                    $form_contents .= '</li>';
554 554
                     $i = 0;
555 555
                 }
556 556
                 $i++;
557 557
             }
558 558
         }
559 559
 
560
-        $form_contents.= '</ul>';
561
-        $form_contents.= '<div class="col-md-12 margin-t-20 margin-b-20">';
560
+        $form_contents .= '</ul>';
561
+        $form_contents .= '<div class="col-md-12 margin-t-20 margin-b-20">';
562 562
 
563
-        $form_contents.= form_button($cancel);
564
-        $form_contents.= form_button($save);
565
-        $form_contents.='<div class="col-md-12 no-padding margin-t-15" style="margin-bottom:10px; !important">
563
+        $form_contents .= form_button($cancel);
564
+        $form_contents .= form_button($save);
565
+        $form_contents .= '<div class="col-md-12 no-padding margin-t-15" style="margin-bottom:10px; !important">
566 566
 						<div class="pull-right btn-close" id="global_clearbatchupdate_filter">Close</div></div>';
567
-        $form_contents.= form_fieldset_close();
568
-        $form_contents.= form_close();
569
-        $form_contents.= '</div>';
570
-        $form_contents.= '</div>';
567
+        $form_contents .= form_fieldset_close();
568
+        $form_contents .= form_close();
569
+        $form_contents .= '</div>';
570
+        $form_contents .= '</div>';
571 571
 
572 572
         return $form_contents;
573 573
     }
@@ -599,21 +599,21 @@  discard block
 block discarded – undo
599 599
                 ASTPP  3.0 
600 600
                 For Edit on Account number or name
601 601
             */
602
-		$row_id = isset($row['id']) ? $row["id"]: '';
602
+		$row_id = isset($row['id']) ? $row["id"] : '';
603 603
 /*****************************/
604 604
                 foreach ($grid_fields as $field_key => $field_arr) {
605 605
 /**
606 606
 ASTPP  3.0 
607 607
 For Edit on Account number or name
608 608
 **/
609
-		     $Actionkey = array_search(gettext('Action'), $this->CI->common->array_column($grid_fields,0));
609
+		     $Actionkey = array_search(gettext('Action'), $this->CI->common->array_column($grid_fields, 0));
610 610
 /*********************************/
611 611
                     if ($field_arr[2] != "") {
612 612
                         if ($field_arr[3] != "") {
613
-                           if($field_arr[2]=="status"){
613
+                           if ($field_arr[2] == "status") {
614 614
                             $row['id'] = $row_id;
615 615
                             $jsn_tmp[$field_key] = call_user_func_array(array($this->CI->common, $field_arr[5]), array($field_arr[3], $field_arr[4], $row));
616
-			   }else{
616
+			   } else {
617 617
                             $jsn_tmp[$field_key] = call_user_func_array(array($this->CI->common, $field_arr[5]), array($field_arr[3], $field_arr[4], $row[$field_arr[2]]));
618 618
 			   }
619 619
 
@@ -622,53 +622,53 @@  discard block
 block discarded – undo
622 622
 For Edit on Account number or name
623 623
 **/
624 624
 			    $row[$field_arr[2]] = $jsn_tmp[$field_key];
625
-            } if(array_search("EDITABLE", $field_arr)){
625
+            } if (array_search("EDITABLE", $field_arr)) {
626 626
 			    $ActionArr = $grid_fields[$Actionkey];
627
-                if($ActionArr[5]->EDIT->url =="accounts/customer_edit/" || $ActionArr[5]->EDIT->url =="accounts/provider_edit/"){
628
-                   $ActionArr[5]->EDIT->url=$row['type']==0 ?  "accounts/customer_edit/"  : "accounts/provider_edit/";
627
+                if ($ActionArr[5]->EDIT->url == "accounts/customer_edit/" || $ActionArr[5]->EDIT->url == "accounts/provider_edit/") {
628
+                   $ActionArr[5]->EDIT->url = $row['type'] == 0 ? "accounts/customer_edit/" : "accounts/provider_edit/";
629 629
                 }
630
-                if($ActionArr[5]->EDIT->url =="accounts/admin_edit/" || $ActionArr[5]->EDIT->url =="accounts/subadmin_edit/"){
631
-                   $ActionArr[5]->EDIT->url=$row['type']==4 ?  "accounts/subadmin_edit/"  : "accounts/admin_edit/";
630
+                if ($ActionArr[5]->EDIT->url == "accounts/admin_edit/" || $ActionArr[5]->EDIT->url == "accounts/subadmin_edit/") {
631
+                   $ActionArr[5]->EDIT->url = $row['type'] == 4 ? "accounts/subadmin_edit/" : "accounts/admin_edit/";
632 632
                 }
633 633
                 $acctype = "";
634
-                if(isset($row["type"]) && ($row["type"] == '0' || $row["type"] == '1' || $row["type"] == '3')){
635
-                    $acctype = (isset($row["posttoexternal"]) && $row["posttoexternal"] != '')? "<span class='label label-default pull-right'>".$this->CI->common->get_account_type("","",$row["posttoexternal"])."</span>":"";
634
+                if (isset($row["type"]) && ($row["type"] == '0' || $row["type"] == '1' || $row["type"] == '3')) {
635
+                    $acctype = (isset($row["posttoexternal"]) && $row["posttoexternal"] != '') ? "<span class='label label-default pull-right'>".$this->CI->common->get_account_type("", "", $row["posttoexternal"])."</span>" : "";
636 636
                 }
637 637
 
638
-                $fieldstr = $this->CI->common->build_custome_edit_button($ActionArr[5]->EDIT,$row[$field_arr[2]],$row["id"]);
639
-                if($acctype != ''){
638
+                $fieldstr = $this->CI->common->build_custome_edit_button($ActionArr[5]->EDIT, $row[$field_arr[2]], $row["id"]);
639
+                if ($acctype != '') {
640 640
                     $jsn_tmp[$field_key] = $fieldstr."<br/>".$acctype;
641
-                }else{
641
+                } else {
642 642
                     $jsn_tmp[$field_key] = $fieldstr;
643 643
                 }
644 644
 			    
645 645
 
646 646
 /*********************************/
647
-		      }else {
647
+		      } else {
648 648
                             $jsn_tmp[$field_key] = $row[$field_arr[2]];
649 649
                   }                  				
650 650
             } else {
651 651
                 if ($field_arr[0] == gettext("Action")) {
652
-			    if(isset($field_arr[5]) && isset($field_arr[5]->EDIT) && isset($field_arr[5]->DELETE)){
652
+			    if (isset($field_arr[5]) && isset($field_arr[5]->EDIT) && isset($field_arr[5]->DELETE)) {
653 653
 		             
654
-		              if($field_arr[5]->EDIT->url == 'accounts/customer_edit/' || $field_arr[5]->EDIT->url == 'accounts/provider_edit/' || $field_arr[5]->DELETE->url == 'accounts/provider_delete/' ||$field_arr[5]->DELETE->url == 'accounts/customer_delete/'){
655
-		               if( $row['type'] == '0'|| strtolower($row['type']) == 'customer'){
656
-		                $field_arr[5]->EDIT->url ='accounts/customer_edit/';
657
-		                $field_arr[5]->DELETE->url ='accounts/customer_delete/';
654
+		              if ($field_arr[5]->EDIT->url == 'accounts/customer_edit/' || $field_arr[5]->EDIT->url == 'accounts/provider_edit/' || $field_arr[5]->DELETE->url == 'accounts/provider_delete/' || $field_arr[5]->DELETE->url == 'accounts/customer_delete/') {
655
+		               if ($row['type'] == '0' || strtolower($row['type']) == 'customer') {
656
+		                $field_arr[5]->EDIT->url = 'accounts/customer_edit/';
657
+		                $field_arr[5]->DELETE->url = 'accounts/customer_delete/';
658 658
 		               }
659
-		               if($row['type'] == 3 || strtolower($row['type']) == 'provider'){
660
-		                $field_arr[5]->EDIT->url ='accounts/provider_edit/';
661
-		                $field_arr[5]->DELETE->url ='accounts/provider_delete/';
659
+		               if ($row['type'] == 3 || strtolower($row['type']) == 'provider') {
660
+		                $field_arr[5]->EDIT->url = 'accounts/provider_edit/';
661
+		                $field_arr[5]->DELETE->url = 'accounts/provider_delete/';
662 662
 		               }
663 663
 		              }
664
-		              if($field_arr[5]->EDIT->url == 'accounts/admin_edit/' || $field_arr[5]->EDIT->url == 'accounts/subadmin_edit/' || $field_arr[5]->DELETE->url == 'accounts/admin_delete/' ||$field_arr[5]->DELETE->url == 'accounts/subadmin_delete/'){
665
-		               if($row['type'] == 2 || strtolower($row['type']) == 'administrator'){
666
-		                $field_arr[5]->EDIT->url ='accounts/admin_edit/';
667
-		                $field_arr[5]->DELETE->url ='accounts/admin_delete/';
664
+		              if ($field_arr[5]->EDIT->url == 'accounts/admin_edit/' || $field_arr[5]->EDIT->url == 'accounts/subadmin_edit/' || $field_arr[5]->DELETE->url == 'accounts/admin_delete/' || $field_arr[5]->DELETE->url == 'accounts/subadmin_delete/') {
665
+		               if ($row['type'] == 2 || strtolower($row['type']) == 'administrator') {
666
+		                $field_arr[5]->EDIT->url = 'accounts/admin_edit/';
667
+		                $field_arr[5]->DELETE->url = 'accounts/admin_delete/';
668 668
 		               }
669
-		               if($row['type'] == 4 || strtolower($row['type']) == 'sub admin'){
670
-		                $field_arr[5]->EDIT->url ='accounts/subadmin_edit/';
671
-		                $field_arr[5]->DELETE->url ='accounts/subadmin_delete/';
669
+		               if ($row['type'] == 4 || strtolower($row['type']) == 'sub admin') {
670
+		                $field_arr[5]->EDIT->url = 'accounts/subadmin_edit/';
671
+		                $field_arr[5]->DELETE->url = 'accounts/subadmin_delete/';
672 672
 		               }
673 673
 		            }
674 674
 			   }
@@ -679,16 +679,16 @@  discard block
 block discarded – undo
679 679
                             $jsn_tmp[$field_key] = $this->CI->common->get_action_buttons($field_arr[5], $row_id);
680 680
                             /****************************************************************************/
681 681
                         }
682
-                        elseif($field_arr[0] == gettext("Profile Action"))
682
+                        elseif ($field_arr[0] == gettext("Profile Action"))
683 683
                         {
684
-                           if(isset($field_arr[5]) && isset($field_arr[5]->START) && isset($field_arr[5]->STOP) && isset($field_arr[5]->RELOAD) && isset($field_arr[5]->RESCAN)){
684
+                           if (isset($field_arr[5]) && isset($field_arr[5]->START) && isset($field_arr[5]->STOP) && isset($field_arr[5]->RELOAD) && isset($field_arr[5]->RESCAN)) {
685 685
                             }
686 686
                            $jsn_tmp[$field_key] = $this->CI->common->get_action_buttons($field_arr[5], $row["id"]);
687 687
                         
688 688
                         }
689 689
                         else {
690
-                            $className = (isset($field_arr['9']) && $field_arr['9'] != '')?$field_arr['9']:"chkRefNos";
691
-                            $jsn_tmp[$field_key] = '<input type="checkbox" name="chkAll" id=' . $row['id'] . ' class="ace '.$className.'" onclick="clickchkbox(' . $row['id'] . ')" value=' . $row['id'] . '><lable class="lbl"></lable>';                        }
690
+                            $className = (isset($field_arr['9']) && $field_arr['9'] != '') ? $field_arr['9'] : "chkRefNos";
691
+                            $jsn_tmp[$field_key] = '<input type="checkbox" name="chkAll" id='.$row['id'].' class="ace '.$className.'" onclick="clickchkbox('.$row['id'].')" value='.$row['id'].'><lable class="lbl"></lable>'; }
692 692
                     }
693 693
                 }
694 694
                 $json_data[] = array('cell' => $jsn_tmp);
@@ -702,20 +702,20 @@  discard block
 block discarded – undo
702 702
         $json_data = array();
703 703
         foreach ($query as $row) {
704 704
             foreach ($grid_fields as $field_key => $field_arr) {
705
-                $row_id = isset($row['id']) ? $row["id"]: '';
705
+                $row_id = isset($row['id']) ? $row["id"] : '';
706 706
 /**
707 707
 ASTPP  3.0 
708 708
 For Edit on Account number or name
709 709
 **/
710
-		$Actionkey = array_search('Action',$this->CI->common->array_column($grid_fields,0)); 
710
+		$Actionkey = array_search('Action', $this->CI->common->array_column($grid_fields, 0)); 
711 711
 /*******************************/
712 712
 
713 713
                 if ($field_arr[2] != "") {
714 714
                     if ($field_arr[3] != "") {
715
-                         if($field_arr[2]=="status"){
715
+                         if ($field_arr[2] == "status") {
716 716
                             $row['id'] = $row_id;
717 717
                             $jsn_tmp[$field_key] = call_user_func_array(array($this->CI->common, $field_arr[5]), array($field_arr[3], $field_arr[4], $row));
718
-						 }else{
718
+						 } else {
719 719
                             $jsn_tmp[$field_key] = call_user_func_array(array($this->CI->common, $field_arr[5]), array($field_arr[3], $field_arr[4], $row[$field_arr[2]]));
720 720
 						 }
721 721
 /**
@@ -723,17 +723,17 @@  discard block
 block discarded – undo
723 723
 For Edit on Account number or name
724 724
 **/
725 725
  			$row[$field_arr[2]] = $jsn_tmp[$field_key];
726
-                      } if(array_search("EDITABLE", $field_arr)){
726
+                      } if (array_search("EDITABLE", $field_arr)) {
727 727
 			    $ActionArr = $grid_fields[$Actionkey];
728
-                if($ActionArr[5]->EDIT->url =="accounts/customer_edit/" || $ActionArr[5]->EDIT->url =="accounts/provider_edit/"){
729
-                   $ActionArr[5]->EDIT->url=$row['type']==0 ?  "accounts/customer_edit/"  : "accounts/provider_edit/";
728
+                if ($ActionArr[5]->EDIT->url == "accounts/customer_edit/" || $ActionArr[5]->EDIT->url == "accounts/provider_edit/") {
729
+                   $ActionArr[5]->EDIT->url = $row['type'] == 0 ? "accounts/customer_edit/" : "accounts/provider_edit/";
730 730
                 }
731
-                if($ActionArr[5]->EDIT->url =="accounts/admin_edit/" || $ActionArr[5]->EDIT->url =="accounts/subadmin_edit/"){
732
-                   $ActionArr[5]->EDIT->url=$row['type']==4 ?  "accounts/subadmin_edit/"  : "accounts/admin_edit/";
731
+                if ($ActionArr[5]->EDIT->url == "accounts/admin_edit/" || $ActionArr[5]->EDIT->url == "accounts/subadmin_edit/") {
732
+                   $ActionArr[5]->EDIT->url = $row['type'] == 4 ? "accounts/subadmin_edit/" : "accounts/admin_edit/";
733 733
                 }
734
-			    $jsn_tmp[$field_key] = $this->CI->common->build_custome_edit_button($ActionArr[5]->EDIT,$row[$field_arr[2]],$row["id"]);
734
+			    $jsn_tmp[$field_key] = $this->CI->common->build_custome_edit_button($ActionArr[5]->EDIT, $row[$field_arr[2]], $row["id"]);
735 735
 /*******************************/
736
-		    }else {
736
+		    } else {
737 737
                         $jsn_tmp[$field_key] = isset($row[$field_arr[2]]) ? $row[$field_arr[2]] : "";
738 738
                     }
739 739
                 } else {
@@ -741,7 +741,7 @@  discard block
 block discarded – undo
741 741
                         $jsn_tmp[$field_key] = $this->CI->common->get_action_buttons($field_arr[5], $row["id"]);
742 742
                     }
743 743
 		      else {
744
-                            $jsn_tmp[$field_key] = '<input type="checkbox" name="chkAll" id=' . $row['id'] . ' class="ace chkRefNos" onclick="clickchkbox(' . $row['id'] . ')" value=' . $row['id'] . '><lable class="lbl"></lable>';
744
+                            $jsn_tmp[$field_key] = '<input type="checkbox" name="chkAll" id='.$row['id'].' class="ace chkRefNos" onclick="clickchkbox('.$row['id'].')" value='.$row['id'].'><lable class="lbl"></lable>';
745 745
                         }
746 746
                 }
747 747
             }
Please login to merge, or discard this patch.