@@ -1,3 +1,5 @@ |
||
1 | -<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed'); |
|
1 | +<?php if ( ! defined('BASEPATH')) { |
|
2 | + exit('No direct script access allowed'); |
|
3 | +} |
|
2 | 4 | $lang['FOOTER.FOOTER'] = 'Copyright © 2003 - 2012. ASTPP - Open Source Solución de Facturación VOIP. Todos los Derechos Reservados.'; |
3 | 5 | ?> |
@@ -295,15 +295,15 @@ |
||
295 | 295 | // -------------------------------------------------------------------- |
296 | 296 | |
297 | 297 | /** |
298 | - * Parse major version |
|
299 | - * |
|
300 | - * Grabs the major version number from the |
|
301 | - * database server version string passed in. |
|
302 | - * |
|
303 | - * @access private |
|
304 | - * @param string $version |
|
305 | - * @return string major version number |
|
306 | - */ |
|
298 | + * Parse major version |
|
299 | + * |
|
300 | + * Grabs the major version number from the |
|
301 | + * database server version string passed in. |
|
302 | + * |
|
303 | + * @access private |
|
304 | + * @param string $version |
|
305 | + * @return string major version number |
|
306 | + */ |
|
307 | 307 | function _parse_major_version($version) |
308 | 308 | { |
309 | 309 | preg_match('/([0-9]+)\.([0-9]+)\.([0-9]+)/', $version, $ver_info); |
@@ -176,35 +176,35 @@ |
||
176 | 176 | <fieldset> |
177 | 177 | <legend> <?=ucfirst($group_title)?></legend> |
178 | 178 | <div style="width:50%;float:left;"> |
179 | - <?php $currency = Common_model::$global_config['system_config']['base_currency'];?> |
|
180 | - <?php $count=ceil(sizeof($details)/2); $i=0; $class="tleft";?> |
|
181 | - <?php foreach($details as$key=>$val){ ?> |
|
182 | - <?php if($count==$i){ |
|
179 | + <?php $currency = Common_model::$global_config['system_config']['base_currency']; ?> |
|
180 | + <?php $count = ceil(sizeof($details) / 2); $i = 0; $class = "tleft"; ?> |
|
181 | + <?php foreach ($details as$key=>$val) { ?> |
|
182 | + <?php if ($count == $i) { |
|
183 | 183 | echo '</div><div style="width:50%;float:left;">'; |
184 | - $class="tright"; |
|
184 | + $class = "tright"; |
|
185 | 185 | } ?> |
186 | 186 | <div class="col-md-12"> |
187 | 187 | <div class="<?=$class?>" href='#'> |
188 | - <label class="col-md-5 no-padding"><?php echo $val['display_name'];?> * </label> |
|
189 | - <?php if(method_exists($this->common,$val['field_type'])){ |
|
190 | - $option_array = $this->common->$val['field_type'](); |
|
188 | + <label class="col-md-5 no-padding"><?php echo $val['display_name']; ?> * </label> |
|
189 | + <?php if (method_exists($this->common, $val['field_type'])) { |
|
190 | + $option_array = $this->common->$val['field_type'](); |
|
191 | 191 | $drpstr = '<select name="'.$val['name'].'" class="col-md-5 form-control selectpicker" data-live-search="true">'; |
192 | - foreach($option_array as $option_key=>$option_val){ |
|
193 | - $selected = ($val['value'] == $option_key)? "selected='selected'":""; |
|
192 | + foreach ($option_array as $option_key=>$option_val) { |
|
193 | + $selected = ($val['value'] == $option_key) ? "selected='selected'" : ""; |
|
194 | 194 | $drpstr .= '<option value="'.$option_key.'"'.$selected.'>'.$option_val.'</option>'; |
195 | 195 | } |
196 | 196 | $drpstr .= '</select>'; |
197 | 197 | echo $drpstr; |
198 | 198 | unset($drpstr); |
199 | - } else{ ?> |
|
200 | - <input name="<?php echo $val['name'] ?>" value='<?php echo isset($val['value'])?$val['value']:''; ?>' size="20" maxlength="100" class="col-md-5 form-control" type="text"> |
|
199 | + } else { ?> |
|
200 | + <input name="<?php echo $val['name'] ?>" value='<?php echo isset($val['value']) ? $val['value'] : ''; ?>' size="20" maxlength="100" class="col-md-5 form-control" type="text"> |
|
201 | 201 | <?php }?> |
202 | - <span class="demo"><?php echo str_replace('smtp',"SMTP",$val['comment']);?></span> |
|
202 | + <span class="demo"><?php echo str_replace('smtp', "SMTP", $val['comment']); ?></span> |
|
203 | 203 | |
204 | 204 | </div> |
205 | 205 | </div> |
206 | 206 | |
207 | - <?php $i++;?> |
|
207 | + <?php $i++; ?> |
|
208 | 208 | <?php }?> |
209 | 209 | </div> |
210 | 210 | </fieldset> |
@@ -250,7 +250,8 @@ |
||
250 | 250 | // Insert callee cdr entry for DID calls |
251 | 251 | /** |
252 | 252 | * |
253 | - * @param boolean $flag_parent |
|
253 | + * @param boolean $flag_parent |
|
254 | + * @param string $provider_cost |
|
254 | 255 | */ |
255 | 256 | function insert_extra_receiver_entry($dataVariable, $origination_rate, $termination_rate, $account_type, $actual_duration, $provider_cost, $parentid, $flag_parent, $accountid, $logger, $db, $decimal_points) { |
256 | 257 | $localVariable = $dataVariable; |
@@ -26,8 +26,8 @@ discard block |
||
26 | 26 | // $logger->log(print_r($data,true));//exit; |
27 | 27 | |
28 | 28 | // Initializing variables |
29 | - $origination_rate = array (); |
|
30 | - $termination_rate = array (); |
|
29 | + $origination_rate = array(); |
|
30 | + $termination_rate = array(); |
|
31 | 31 | |
32 | 32 | // FS CDR variables |
33 | 33 | $dataVariable = $data ['variables']; |
@@ -36,21 +36,21 @@ discard block |
||
36 | 36 | $dataCallflow = $data ['callflow']; |
37 | 37 | |
38 | 38 | // Get account id |
39 | - $accountid = isset ( $dataVariable ['account_id'] ) ? $dataVariable ['account_id'] : '0'; |
|
39 | + $accountid = isset ($dataVariable ['account_id']) ? $dataVariable ['account_id'] : '0'; |
|
40 | 40 | |
41 | 41 | // Get caller id name and number |
42 | - $dataVariable ['effective_caller_id_name'] = (isset ( $dataVariable ['effective_caller_id_name'] )) ? $dataVariable ['effective_caller_id_name'] : $dataCallflow ['caller_profile'] ['caller_id_name']; |
|
43 | - $dataVariable ['effective_caller_id_number'] = (isset ( $dataVariable ['effective_caller_id_number'] )) ? $dataVariable ['effective_caller_id_number'] : $dataCallflow ['caller_profile'] ['caller_id_number']; |
|
42 | + $dataVariable ['effective_caller_id_name'] = (isset ($dataVariable ['effective_caller_id_name'])) ? $dataVariable ['effective_caller_id_name'] : $dataCallflow ['caller_profile'] ['caller_id_name']; |
|
43 | + $dataVariable ['effective_caller_id_number'] = (isset ($dataVariable ['effective_caller_id_number'])) ? $dataVariable ['effective_caller_id_number'] : $dataCallflow ['caller_profile'] ['caller_id_number']; |
|
44 | 44 | |
45 | 45 | if ($dataVariable ['billsec'] == 0 && $dataVariable ['hangup_cause'] == 'NORMAL_CLEARING') { |
46 | - $hangup_cause = isset ( $dataVariable ['last_bridge_hangup_cause'] ) ? $dataVariable ['last_bridge_hangup_cause'] : $dataVariable ['hangup_cause']; |
|
46 | + $hangup_cause = isset ($dataVariable ['last_bridge_hangup_cause']) ? $dataVariable ['last_bridge_hangup_cause'] : $dataVariable ['hangup_cause']; |
|
47 | 47 | } else { |
48 | 48 | $hangup_cause = $dataVariable ['hangup_cause']; |
49 | 49 | } |
50 | 50 | |
51 | 51 | if ($dataVariable ['error_cdr'] == '1') { |
52 | 52 | // Get actual hangup cause |
53 | - $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']); |
|
53 | + $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']); |
|
54 | 54 | } |
55 | 55 | |
56 | 56 | /* #### PATCH FOR ONE WAY AUDIO #### */ |
@@ -72,116 +72,116 @@ discard block |
||
72 | 72 | * } |
73 | 73 | */ |
74 | 74 | |
75 | - $account_type = (isset ( $dataVariable ['entity_id'] )) ? $dataVariable ['entity_id'] : '0'; |
|
76 | - $parentid = isset ( $dataVariable ['parent_id'] ) ? $dataVariable ['parent_id'] : '0'; |
|
75 | + $account_type = (isset ($dataVariable ['entity_id'])) ? $dataVariable ['entity_id'] : '0'; |
|
76 | + $parentid = isset ($dataVariable ['parent_id']) ? $dataVariable ['parent_id'] : '0'; |
|
77 | 77 | $parent_cost = 0; |
78 | 78 | $cost = 0; |
79 | 79 | $dataVariable ['package_id'] = 0; |
80 | 80 | $actual_duration = $dataVariable ['billsec']; |
81 | - $dataVariable ['calltype'] = isset ( $dataVariable ['calltype'] ) ? $dataVariable ['calltype'] : "STANDARD"; |
|
81 | + $dataVariable ['calltype'] = isset ($dataVariable ['calltype']) ? $dataVariable ['calltype'] : "STANDARD"; |
|
82 | 82 | $actual_calltype = $dataVariable ['calltype']; |
83 | 83 | |
84 | 84 | // Normalize origination and termination rates array |
85 | - if (isset ( $dataVariable ['origination_rates'] )) |
|
86 | - $origination_rate = normalize_origination_rate ( $dataVariable ['origination_rates'] ); |
|
87 | - if (isset ( $dataVariable ['termination_rates'] )) |
|
88 | - $termination_rate = normalize_rate ( $dataVariable ['termination_rates'] ); |
|
85 | + if (isset ($dataVariable ['origination_rates'])) |
|
86 | + $origination_rate = normalize_origination_rate($dataVariable ['origination_rates']); |
|
87 | + if (isset ($dataVariable ['termination_rates'])) |
|
88 | + $termination_rate = normalize_rate($dataVariable ['termination_rates']); |
|
89 | 89 | |
90 | 90 | // If receiver account id found then explicitly set call direction and call type |
91 | - if (isset ( $dataVariable ['receiver_accid'] )) { |
|
91 | + if (isset ($dataVariable ['receiver_accid'])) { |
|
92 | 92 | $dataVariable ['call_direction'] = "outbound"; |
93 | 93 | $dataVariable ['calltype'] = "STANDARD"; |
94 | 94 | } |
95 | 95 | |
96 | 96 | // Check if cusotmer have any package seconds left to use |
97 | 97 | if ($actual_duration > 0) { |
98 | - $package_array = package_calculation ( $dataVariable ['effective_destination_number'], $origination_rate [$accountid] ['RATEGROUP'], $actual_duration, $dataVariable ['call_direction'], $accountid, $db, $logger ); |
|
99 | - if (! empty ( $package_array )) { |
|
98 | + $package_array = package_calculation($dataVariable ['effective_destination_number'], $origination_rate [$accountid] ['RATEGROUP'], $actual_duration, $dataVariable ['call_direction'], $accountid, $db, $logger); |
|
99 | + if ( ! empty ($package_array)) { |
|
100 | 100 | $dataVariable ['calltype'] = "FREE"; |
101 | 101 | $dataVariable ['package_id'] = $package_array ['package_id']; |
102 | 102 | } |
103 | 103 | } |
104 | 104 | |
105 | 105 | // Calculate debit of customer call |
106 | - $debit = calc_cost ( $dataVariable, $origination_rate [$accountid], $logger, $decimal_points ); |
|
106 | + $debit = calc_cost($dataVariable, $origination_rate [$accountid], $logger, $decimal_points); |
|
107 | 107 | |
108 | 108 | // Calculate cost for customer call for provider |
109 | - $provider_cost = calc_cost ( $dataVariable, $termination_rate, $logger, $decimal_points ); |
|
109 | + $provider_cost = calc_cost($dataVariable, $termination_rate, $logger, $decimal_points); |
|
110 | 110 | |
111 | 111 | // Calculate parent cost if customer have any parent |
112 | - $parent_cost = ($parentid > 0) ? calc_cost ( $dataVariable, $origination_rate [$parentid], $logger, $decimal_points ) : $provider_cost; |
|
113 | - $logger->log ( "Debit :" . $debit . " Cost : " . $cost . " Provider Cost : " . $parent_cost ); |
|
112 | + $parent_cost = ($parentid > 0) ? calc_cost ($dataVariable, $origination_rate [$parentid], $logger, $decimal_points) : $provider_cost; |
|
113 | + $logger->log("Debit :".$debit." Cost : ".$cost." Provider Cost : ".$parent_cost); |
|
114 | 114 | |
115 | 115 | // Initialize final cost variable to use for billing |
116 | 116 | $cost = ($parent_cost > 0) ? $parent_cost : $provider_cost; |
117 | 117 | |
118 | 118 | // Outbound call entry for all type of calls |
119 | - $logger->log ( "*********************** OUTBOUND CALL ENTRY START *************" ); |
|
119 | + $logger->log("*********************** OUTBOUND CALL ENTRY START *************"); |
|
120 | 120 | |
121 | - $cdr_string = get_cdr_string ( $dataVariable, $accountid, $account_type, $actual_duration, $termination_rate, $origination_rate, $provider_cost, $parentid, $debit, $cost, $logger ); |
|
121 | + $cdr_string = get_cdr_string($dataVariable, $accountid, $account_type, $actual_duration, $termination_rate, $origination_rate, $provider_cost, $parentid, $debit, $cost, $logger); |
|
122 | 122 | |
123 | 123 | $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)"; |
124 | - $logger->log ( $query ); |
|
125 | - $db->run ( $query ); |
|
124 | + $logger->log($query); |
|
125 | + $db->run($query); |
|
126 | 126 | |
127 | 127 | // Update customer balance |
128 | 128 | if ($debit > 0 && $dataVariable ['calltype'] != "FREE") { |
129 | - update_balance ( $accountid, $debit, 0, $logger, $db ); |
|
129 | + update_balance($accountid, $debit, 0, $logger, $db); |
|
130 | 130 | } |
131 | 131 | |
132 | 132 | // Update parent or provider balance |
133 | 133 | if ($parent_cost > 0) { |
134 | - update_balance ( $termination_rate ['PROVIDER'], ($parent_cost * - 1), 3, $logger, $db ); |
|
134 | + update_balance($termination_rate ['PROVIDER'], ($parent_cost * - 1), 3, $logger, $db); |
|
135 | 135 | } |
136 | 136 | |
137 | 137 | // Resellers CDR entry |
138 | 138 | $flag_parent = false; |
139 | - insert_parent_data ( $dataVariable, $actual_calltype, $parentid, $origination_rate, $actual_duration, $provider_cost, $flag_parent, $logger, $db, $decimal_points ); |
|
139 | + insert_parent_data($dataVariable, $actual_calltype, $parentid, $origination_rate, $actual_duration, $provider_cost, $flag_parent, $logger, $db, $decimal_points); |
|
140 | 140 | |
141 | - $logger->log ( "*********************** OUTBOUND CALL ENTRY END *************" ); |
|
141 | + $logger->log("*********************** OUTBOUND CALL ENTRY END *************"); |
|
142 | 142 | |
143 | 143 | // ************ ADDING EXTRA ENTRY For local/DID Inbound call **************************** |
144 | 144 | $receiver_parentid = 0; |
145 | - if (isset ( $dataVariable ['receiver_accid'] ) && $dataVariable ['receiver_accid'] != "") { |
|
146 | - $logger->log ( "*********************** EXTRA ENTRY SECTION FOR BILLING START *************" ); |
|
145 | + if (isset ($dataVariable ['receiver_accid']) && $dataVariable ['receiver_accid'] != "") { |
|
146 | + $logger->log("*********************** EXTRA ENTRY SECTION FOR BILLING START *************"); |
|
147 | 147 | |
148 | 148 | // Explicitly set call direction and call type |
149 | 149 | $dataVariable ['call_direction'] = "inbound"; |
150 | 150 | $dataVariable ['calltype'] = "DID"; |
151 | 151 | // For inbound package calculation |
152 | 152 | if ($actual_duration > 0) { |
153 | - $package_array = package_calculation ( $dataVariable ['effective_destination_number'], $origination_rate [$accountid] ['RATEGROUP'], $actual_duration, $dataVariable ['call_direction'], $accountid, $db, $logger ); |
|
154 | - if (! empty ( $package_array )) { |
|
153 | + $package_array = package_calculation($dataVariable ['effective_destination_number'], $origination_rate [$accountid] ['RATEGROUP'], $actual_duration, $dataVariable ['call_direction'], $accountid, $db, $logger); |
|
154 | + if ( ! empty ($package_array)) { |
|
155 | 155 | $dataVariable ['calltype'] = "FREE"; |
156 | 156 | $dataVariable ['package_id'] = $package_array ['package_id']; |
157 | 157 | } |
158 | 158 | } |
159 | 159 | // Override variables if call for DID PSTN |
160 | - if (isset ( $dataVariable ['caller_did_account_id'] )) { |
|
160 | + if (isset ($dataVariable ['caller_did_account_id'])) { |
|
161 | 161 | $dataVariable ['receiver_accid'] = $dataVariable ['caller_did_account_id']; |
162 | 162 | $dataVariable ['call_direction'] = "outbound"; |
163 | 163 | $dataVariable ['calltype'] = "STANDARD"; |
164 | 164 | $dataVariable ['effective_destination_number'] = $dataVariable ['sip_to_user']; |
165 | - unset ( $termination_rate ); |
|
166 | - unset ( $provider_cost ); |
|
165 | + unset ($termination_rate); |
|
166 | + unset ($provider_cost); |
|
167 | 167 | } |
168 | 168 | |
169 | 169 | // Get call receiver account information |
170 | - $receiver_carddata = get_accounts ( $dataVariable ['receiver_accid'], $logger, $db ); |
|
170 | + $receiver_carddata = get_accounts($dataVariable ['receiver_accid'], $logger, $db); |
|
171 | 171 | $receiver_parentid = $receiver_carddata ['reseller_id']; |
172 | 172 | |
173 | 173 | // For additional cdr entry of receiver |
174 | - 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 ); |
|
174 | + 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); |
|
175 | 175 | |
176 | 176 | $flag_parent = true; |
177 | - $dataVariable ['uuid'] = $dataVariable ['uuid'] . $dataVariable ['calltype'] . "_" . $receiver_parentid; |
|
177 | + $dataVariable ['uuid'] = $dataVariable ['uuid'].$dataVariable ['calltype']."_".$receiver_parentid; |
|
178 | 178 | |
179 | 179 | // Insert parent reseller cdr |
180 | - insert_parent_data ( $dataVariable, $actual_calltype, $receiver_parentid, $origination_rate, $actual_duration, $provider_cost, $flag_parent, $logger, $db, $decimal_points ); |
|
181 | - $logger->log ( "*********************** EXTRA ENTRY SECTION FOR BILLING END *************" ); |
|
180 | + insert_parent_data($dataVariable, $actual_calltype, $receiver_parentid, $origination_rate, $actual_duration, $provider_cost, $flag_parent, $logger, $db, $decimal_points); |
|
181 | + $logger->log("*********************** EXTRA ENTRY SECTION FOR BILLING END *************"); |
|
182 | 182 | } |
183 | 183 | // ***************************************************************************************** |
184 | - $logger->log ( "*************************** CDR ends ********************************" ); |
|
184 | + $logger->log("*************************** CDR ends ********************************"); |
|
185 | 185 | } |
186 | 186 | |
187 | 187 | // Insert parent resellers cdr |
@@ -191,13 +191,13 @@ discard block |
||
191 | 191 | * @param boolean $flag_parent |
192 | 192 | */ |
193 | 193 | function insert_parent_data($dataVariable, $actual_calltype, $parentid, $origination_rate, $actual_duration, $provider_cost, $flag_parent, $logger, $db, $decimal_points) { |
194 | - while ( $parentid > 0 ) { |
|
195 | - $logger->log ( "*************** IN PARENT DATA SECTION ********" ); |
|
194 | + while ($parentid > 0) { |
|
195 | + $logger->log("*************** IN PARENT DATA SECTION ********"); |
|
196 | 196 | $dataVariable ['calltype'] = $actual_calltype; |
197 | - $carddata = get_accounts ( $parentid, $logger, $db ); |
|
197 | + $carddata = get_accounts($parentid, $logger, $db); |
|
198 | 198 | $accountid = $carddata ['id']; |
199 | 199 | |
200 | - $debit = calc_cost ( $dataVariable, $origination_rate [$accountid], $logger, $decimal_points ); |
|
200 | + $debit = calc_cost($dataVariable, $origination_rate [$accountid], $logger, $decimal_points); |
|
201 | 201 | |
202 | 202 | // If receiver account id found then explicitly set call direction and call type |
203 | 203 | /* |
@@ -210,8 +210,8 @@ discard block |
||
210 | 210 | |
211 | 211 | // Check if reseller have any package seconds left to use |
212 | 212 | if ($actual_duration > 0) { |
213 | - $package_array = package_calculation ( $dataVariable ['effective_destination_number'], $origination_rate [$accountid] ['RATEGROUP'], $actual_duration, $dataVariable ['call_direction'], $accountid, $db, $logger ); |
|
214 | - if (! empty ( $package_array )) { |
|
213 | + $package_array = package_calculation($dataVariable ['effective_destination_number'], $origination_rate [$accountid] ['RATEGROUP'], $actual_duration, $dataVariable ['call_direction'], $accountid, $db, $logger); |
|
214 | + if ( ! empty ($package_array)) { |
|
215 | 215 | $dataVariable ['calltype'] = "FREE"; |
216 | 216 | $dataVariable ['package_id'] = $package_array ['package_id']; |
217 | 217 | } |
@@ -219,27 +219,27 @@ discard block |
||
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) { |
|
226 | - $logger->log ( "********* IN RESELLER FOR RECEIVER ENTRY START ******" ); |
|
225 | + if (isset ($dataVariable ['receiver_accid']) && $dataVariable ['receiver_accid'] != "" && $flag_parent == true) { |
|
226 | + $logger->log("********* IN RESELLER FOR RECEIVER ENTRY START ******"); |
|
227 | 227 | $flag_parent = true; |
228 | - insert_extra_receiver_entry ( $dataVariable, $origination_rate, $termination_rate, $account_type, $actual_duration, $provider_cost, $parentid, $flag_parent, $accountid, $logger, $db, $decimal_points ); |
|
229 | - $logger->log ( "********* IN RESELLER FOR RECEIVER ENTRY END ******" ); |
|
228 | + insert_extra_receiver_entry($dataVariable, $origination_rate, $termination_rate, $account_type, $actual_duration, $provider_cost, $parentid, $flag_parent, $accountid, $logger, $db, $decimal_points); |
|
229 | + $logger->log("********* IN RESELLER FOR RECEIVER ENTRY END ******"); |
|
230 | 230 | return true; |
231 | 231 | } else { |
232 | 232 | |
233 | - $cdr_string = get_reseller_cdr_string ( $dataVariable, $accountid, $account_type, $actual_duration, $termination_rate, $origination_rate, $provider_cost, $parentid, $debit, $cost ); |
|
233 | + $cdr_string = get_reseller_cdr_string($dataVariable, $accountid, $account_type, $actual_duration, $termination_rate, $origination_rate, $provider_cost, $parentid, $debit, $cost); |
|
234 | 234 | |
235 | 235 | $query = "INSERT INTO reseller_cdrs (uniqueid,accountid,callerid,callednum,billseconds,disposition,callstart,debit,cost,pricelist_id,package_id,pattern,notes,rate_cost, |
236 | 236 | reseller_id,reseller_code,reseller_code_destination,reseller_cost,call_direction,calltype) values ($cdr_string)"; |
237 | - $logger->log ( $query ); |
|
238 | - $db->run ( $query ); |
|
237 | + $logger->log($query); |
|
238 | + $db->run($query); |
|
239 | 239 | |
240 | 240 | // Update reseller balance |
241 | 241 | if ($debit > 0 && $dataVariable ['calltype'] != "FREE") { |
242 | - update_balance ( $accountid, $debit, 0, $logger, $db ); |
|
242 | + update_balance($accountid, $debit, 0, $logger, $db); |
|
243 | 243 | } |
244 | 244 | } |
245 | 245 | //return true; |
@@ -255,26 +255,26 @@ discard block |
||
255 | 255 | function insert_extra_receiver_entry($dataVariable, $origination_rate, $termination_rate, $account_type, $actual_duration, $provider_cost, $parentid, $flag_parent, $accountid, $logger, $db, $decimal_points) { |
256 | 256 | $localVariable = $dataVariable; |
257 | 257 | $localVariable ['call_direction'] = "inbound"; |
258 | - $localVariable ['uuid'] = $localVariable ['uuid'] . $dataVariable ['calltype'] . "_" . $accountid; |
|
258 | + $localVariable ['uuid'] = $localVariable ['uuid'].$dataVariable ['calltype']."_".$accountid; |
|
259 | 259 | |
260 | 260 | if ($dataVariable ['calltype'] == "LOCAL") { |
261 | 261 | $origination_rate [$accountid] ['CODE'] = $dataVariable ['effective_destination_number']; |
262 | 262 | $origination_rate [$accountid] ['DESTINATION'] = $dataVariable ['calltype']; |
263 | 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 ); |
|
264 | + $cdr_string = get_cdr_string($localVariable, $accountid, $account_type, $actual_duration, $termination_rate, $origination_rate, $provider_cost, $parentid, 0, 0, $logger); |
|
265 | 265 | } else { |
266 | - $cdr_string = get_reseller_cdr_string ( $dataVariable, $accountid, $account_type, $actual_duration, $termination_rate, $origination_rate, $provider_cost, $parentid, $debit, $cost ); |
|
266 | + $cdr_string = get_reseller_cdr_string($dataVariable, $accountid, $account_type, $actual_duration, $termination_rate, $origination_rate, $provider_cost, $parentid, $debit, $cost); |
|
267 | 267 | } |
268 | 268 | } else { |
269 | 269 | |
270 | - $origination_rate_did = normalize_origination_rate ( $dataVariable ['origination_rates_did'] ); |
|
271 | - $debit = calc_cost ( $dataVariable, $origination_rate_did [$accountid], $logger, $decimal_points ); |
|
270 | + $origination_rate_did = normalize_origination_rate($dataVariable ['origination_rates_did']); |
|
271 | + $debit = calc_cost($dataVariable, $origination_rate_did [$accountid], $logger, $decimal_points); |
|
272 | 272 | |
273 | 273 | if ($flag_parent == false) { |
274 | 274 | |
275 | - $cdr_string = get_cdr_string ( $localVariable, $accountid, $account_type, $actual_duration, $termination_rate, $origination_rate_did, $provider_cost, $parentid, $debit, 0, $logger ); |
|
275 | + $cdr_string = get_cdr_string($localVariable, $accountid, $account_type, $actual_duration, $termination_rate, $origination_rate_did, $provider_cost, $parentid, $debit, 0, $logger); |
|
276 | 276 | } else { |
277 | - $cdr_string = get_reseller_cdr_string ( $dataVariable, $accountid, $account_type, $actual_duration, $termination_rate, $origination_rate, $provider_cost, $parentid, $debit, $cost ); |
|
277 | + $cdr_string = get_reseller_cdr_string($dataVariable, $accountid, $account_type, $actual_duration, $termination_rate, $origination_rate, $provider_cost, $parentid, $debit, $cost); |
|
278 | 278 | } |
279 | 279 | } |
280 | 280 | |
@@ -285,11 +285,11 @@ discard block |
||
285 | 285 | reseller_id,reseller_code,reseller_code_destination,reseller_cost,call_direction,calltype) values ($cdr_string)"; |
286 | 286 | } |
287 | 287 | |
288 | - $logger->log ( $query ); |
|
289 | - $db->run ( $query ); |
|
288 | + $logger->log($query); |
|
289 | + $db->run($query); |
|
290 | 290 | |
291 | 291 | if ($debit > 0 && ($dataVariable ['calltype'] != "FREE" && $dataVariable ['calltype'] != "LOCAL")) { |
292 | - update_balance ( $accountid, $debit, 0, $logger, $db ); |
|
292 | + update_balance($accountid, $debit, 0, $logger, $db); |
|
293 | 293 | } |
294 | 294 | return true; |
295 | 295 | } |
@@ -298,18 +298,18 @@ discard block |
||
298 | 298 | function get_cdr_string($dataVariable, $accountid, $account_type, $actual_duration, $termination_rate, $origination_rate, $provider_cost, $parentid, $debit, $cost, $logger) { |
299 | 299 | $dataVariable ['calltype'] = ($dataVariable ['calltype'] == 'DID-LOCAL' || $dataVariable ['calltype'] == 'SIP-DID' || $dataVariable ['calltype'] == 'OTHER') ? "DID" : $dataVariable ['calltype']; |
300 | 300 | // $callerIdNumber = isset($dataVariable['effective_caller_id_number']) && !empty($dataVariable['effective_caller_id_number'])? $dataVariable['effective_caller_id_number'] :$dataVariable['caller_id']; |
301 | - $callerIdNumber = ($dataVariable ['calltype'] == "DID") ? $dataVariable ['effective_caller_id_name'] . " <" . $dataVariable ['effective_caller_id_number'] . ">" : $dataVariable ['original_caller_id_name'] . " <" . $dataVariable ['original_caller_id_number'] . ">"; |
|
301 | + $callerIdNumber = ($dataVariable ['calltype'] == "DID") ? $dataVariable ['effective_caller_id_name']." <".$dataVariable ['effective_caller_id_number'].">" : $dataVariable ['original_caller_id_name']." <".$dataVariable ['original_caller_id_number'].">"; |
|
302 | 302 | |
303 | - return $cdr_string = "'" . ($dataVariable ['uuid']) . "','" . $accountid . "','" . $account_type . "','" . (urldecode ( $callerIdNumber )) . "','" . ($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' . "'") . ",'" . $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'] . "'" : "'" . '' . "'") . "," . (($termination_rate ['DESTINATION']) ? "'" . $termination_rate ['DESTINATION'] . "'" : "'" . '' . "'") . "," . (($termination_rate ['COST']) ? "'" . $termination_rate ['COST'] . "'" : '0') . ",'" . $provider_cost . "'," . (($dataVariable ['call_direction']) ? "'" . $dataVariable ['call_direction'] . "'" : "'internal'") . ",'" . ($dataVariable ['calltype']) . "','" . urldecode ( $dataVariable ['profile_start_stamp'] ) . "','" . urldecode ( $dataVariable ['answer_stamp'] ) . "','" . urldecode ( $dataVariable ['bridge_stamp'] ) . "','" . urldecode ( @$dataVariable ['progress_stamp'] ) . "','" . urldecode ( @$dataVariable ['progress_media_stamp'] ) . "','" . urldecode ( $dataVariable ['end_stamp'] ) . "'," . $dataVariable ['billmsec'] . ",'" . $dataVariable ['answermsec'] . "','" . $dataVariable ['waitmsec'] . "','" . $dataVariable ['progress_mediamsec'] . "','" . $dataVariable ['flow_billmsec'] . "'"; |
|
303 | + return $cdr_string = "'".($dataVariable ['uuid'])."','".$accountid."','".$account_type."','".(urldecode($callerIdNumber))."','".($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'."'").",'".$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']."'" : "'".''."'").",".(($termination_rate ['DESTINATION']) ? "'".$termination_rate ['DESTINATION']."'" : "'".''."'").",".(($termination_rate ['COST']) ? "'".$termination_rate ['COST']."'" : '0').",'".$provider_cost."',".(($dataVariable ['call_direction']) ? "'".$dataVariable ['call_direction']."'" : "'internal'").",'".($dataVariable ['calltype'])."','".urldecode($dataVariable ['profile_start_stamp'])."','".urldecode($dataVariable ['answer_stamp'])."','".urldecode($dataVariable ['bridge_stamp'])."','".urldecode(@$dataVariable ['progress_stamp'])."','".urldecode(@$dataVariable ['progress_media_stamp'])."','".urldecode($dataVariable ['end_stamp'])."',".$dataVariable ['billmsec'].",'".$dataVariable ['answermsec']."','".$dataVariable ['waitmsec']."','".$dataVariable ['progress_mediamsec']."','".$dataVariable ['flow_billmsec']."'"; |
|
304 | 304 | } |
305 | 305 | |
306 | 306 | // Generate CDR string for insert query for reseller |
307 | 307 | function get_reseller_cdr_string($dataVariable, $accountid, $account_type, $actual_duration, $termination_rate, $origination_rate, $provider_cost, $parentid, $debit, $cost) { |
308 | 308 | $dataVariable ['calltype'] = ($dataVariable ['calltype'] == 'DID-LOCAL' || $dataVariable ['calltype'] == 'SIP-DID' || $dataVariable ['calltype'] == 'OTHER') ? "DID" : $dataVariable ['calltype']; |
309 | 309 | // $callerIdNumber = isset($dataVariable['effective_caller_id_number']) && !empty($dataVariable['effective_caller_id_number'])? $dataVariable['effective_caller_id_number'] :$dataVariable['caller_id']; |
310 | - $callerIdNumber = ($dataVariable ['calltype'] == "DID") ? $dataVariable ['effective_caller_id_name'] . " <" . $dataVariable ['effective_caller_id_number'] . ">" : $dataVariable ['original_caller_id_name'] . " <" . $dataVariable ['original_caller_id_number'] . ">"; |
|
310 | + $callerIdNumber = ($dataVariable ['calltype'] == "DID") ? $dataVariable ['effective_caller_id_name']." <".$dataVariable ['effective_caller_id_number'].">" : $dataVariable ['original_caller_id_name']." <".$dataVariable ['original_caller_id_number'].">"; |
|
311 | 311 | |
312 | - return $cdr_string = "'" . ($dataVariable ['uuid']) . "','" . $accountid . "','" . (urldecode ( $callerIdNumber )) . "','" . ($dataVariable ['effective_destination_number']) . "','" . $actual_duration . "','" . ($dataVariable ['hangup_cause']) . "','" . 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']) . "'"; |
|
312 | + return $cdr_string = "'".($dataVariable ['uuid'])."','".$accountid."','".(urldecode($callerIdNumber))."','".($dataVariable ['effective_destination_number'])."','".$actual_duration."','".($dataVariable ['hangup_cause'])."','".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'])."'"; |
|
313 | 313 | } |
314 | 314 | |
315 | 315 | // Update user balance |
@@ -319,20 +319,20 @@ discard block |
||
319 | 319 | */ |
320 | 320 | function update_balance($user_id, $amount, $entity_id, $logger, $db) { |
321 | 321 | $math_sign = ($entity_id == 0 || $entity_id == 1) ? '-' : '+'; |
322 | - $query = "UPDATE accounts SET balance=IF(posttoexternal=1,balance+" . $amount . ",balance-" . $amount . ") WHERE id=" . $user_id; |
|
323 | - $logger->log ( "Balance update : " . $query ); |
|
324 | - $db->run ( $query ); |
|
322 | + $query = "UPDATE accounts SET balance=IF(posttoexternal=1,balance+".$amount.",balance-".$amount.") WHERE id=".$user_id; |
|
323 | + $logger->log("Balance update : ".$query); |
|
324 | + $db->run($query); |
|
325 | 325 | } |
326 | 326 | |
327 | 327 | // Normalize rate string which we are getting from dialplan |
328 | 328 | function normalize_rate($dataVariable) { |
329 | - $rates = urldecode ( $dataVariable ); |
|
330 | - $data = explode ( "|", $rates ); |
|
329 | + $rates = urldecode($dataVariable); |
|
330 | + $data = explode("|", $rates); |
|
331 | 331 | |
332 | - $newarray = array (); |
|
333 | - foreach ( $data as $key => $value ) { |
|
334 | - $data1 = explode ( ":", $value ); |
|
335 | - foreach ( $data1 as $newkey => $newvalue ) { |
|
332 | + $newarray = array(); |
|
333 | + foreach ($data as $key => $value) { |
|
334 | + $data1 = explode(":", $value); |
|
335 | + foreach ($data1 as $newkey => $newvalue) { |
|
336 | 336 | $newarray [$data1 [0]] = $data1 [$newkey]; |
337 | 337 | } |
338 | 338 | } |
@@ -341,13 +341,13 @@ discard block |
||
341 | 341 | |
342 | 342 | // Normalize originaion rate string which we are getting from dialplan |
343 | 343 | function normalize_origination_rate($dataVariable) { |
344 | - $rates = urldecode ( $dataVariable ); |
|
345 | - $data = explode ( "|", $rates ); |
|
346 | - $newarray = array (); |
|
347 | - $newarray1 = array (); |
|
348 | - foreach ( $data as $key => $value ) { |
|
349 | - $data1 = explode ( ":", $value ); |
|
350 | - foreach ( $data1 as $newkey => $newvalue ) { |
|
344 | + $rates = urldecode($dataVariable); |
|
345 | + $data = explode("|", $rates); |
|
346 | + $newarray = array(); |
|
347 | + $newarray1 = array(); |
|
348 | + foreach ($data as $key => $value) { |
|
349 | + $data1 = explode(":", $value); |
|
350 | + foreach ($data1 as $newkey => $newvalue) { |
|
351 | 351 | $newarray [$data1 [0]] = $data1 [$newkey]; |
352 | 352 | if ($newvalue == "ACCID") { |
353 | 353 | $newarray1 [$data1 [1]] = $newarray; |
@@ -371,43 +371,43 @@ discard block |
||
371 | 371 | $billseconds = $duration - $rates ['INITIALBLOCK']; |
372 | 372 | |
373 | 373 | if ($billseconds > 0) { |
374 | - $call_cost += (ceil ( $billseconds / $rates ['INC'] ) * $rates ['INC']) * ($rates ['COST'] / 60); |
|
374 | + $call_cost += (ceil($billseconds / $rates ['INC']) * $rates ['INC']) * ($rates ['COST'] / 60); |
|
375 | 375 | } |
376 | 376 | } |
377 | - $call_cost = number_format ( $call_cost, $decimal_points ); |
|
378 | - $logger->log ( "Return cost " . $call_cost ); |
|
377 | + $call_cost = number_format($call_cost, $decimal_points); |
|
378 | + $logger->log("Return cost ".$call_cost); |
|
379 | 379 | return $call_cost; |
380 | 380 | } |
381 | 381 | |
382 | 382 | // get intial package information |
383 | 383 | function package_calculation($destination_number, $pricelist_id, $duration, $call_direction, $accountid, $db, $logger) { |
384 | - $package_array = array (); |
|
385 | - $custom_destination = number_loop ( $destination_number, "patterns", $db ); |
|
384 | + $package_array = array(); |
|
385 | + $custom_destination = number_loop($destination_number, "patterns", $db); |
|
386 | 386 | |
387 | - $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"; |
|
387 | + $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"; |
|
388 | 388 | |
389 | - $package_info = $db->run ( $query ); |
|
389 | + $package_info = $db->run($query); |
|
390 | 390 | if ($package_info) { |
391 | 391 | $package_info = $package_info [0]; |
392 | 392 | |
393 | 393 | if (($package_info ['applicable_for'] == "0" && $call_direction == "outbound") || ($package_info ['applicable_for'] == "1" && $call_direction == "inbound") || ($package_info ['applicable_for'] == "2")) { |
394 | 394 | |
395 | - $counter_info = get_counters ( $accountid, $package_info ['package_id'], $db, $logger ); |
|
395 | + $counter_info = get_counters($accountid, $package_info ['package_id'], $db, $logger); |
|
396 | 396 | |
397 | - if (! $counter_info) { |
|
398 | - $Insert_Query = "INSERT INTO counters (package_id,accountid) VALUES (" . $package_info ['package_id'] . "," . $accountid . ")"; |
|
399 | - $logger->log ( "Insert Counters : " . $Insert_query ); |
|
400 | - $db->run ( $Insert_Query ); |
|
401 | - $counter_info = get_counters ( $accountid, $package_info ['package_id'], $db, $logger ); |
|
397 | + if ( ! $counter_info) { |
|
398 | + $Insert_Query = "INSERT INTO counters (package_id,accountid) VALUES (".$package_info ['package_id'].",".$accountid.")"; |
|
399 | + $logger->log("Insert Counters : ".$Insert_query); |
|
400 | + $db->run($Insert_Query); |
|
401 | + $counter_info = get_counters($accountid, $package_info ['package_id'], $db, $logger); |
|
402 | 402 | } |
403 | 403 | // print_r($counter_info); |
404 | 404 | if ($package_info ['includedseconds'] > ($counter_info ['seconds'])) { |
405 | 405 | $availableseconds = $package_info ['includedseconds'] - $counter_info ['seconds']; |
406 | 406 | $freeseconds = ($availableseconds >= $duration) ? $duration : $availableseconds; |
407 | 407 | $duration = ($availableseconds >= $duration) ? $duration : $availableseconds; |
408 | - $update_query = "UPDATE counters SET seconds = " . ($counter_info ['seconds'] + $freeseconds) . " WHERE id = " . $counter_info ['id']; |
|
409 | - $logger->log ( "Update Counters : " . $update_query ); |
|
410 | - $db->run ( $update_query ); |
|
408 | + $update_query = "UPDATE counters SET seconds = ".($counter_info ['seconds'] + $freeseconds)." WHERE id = ".$counter_info ['id']; |
|
409 | + $logger->log("Update Counters : ".$update_query); |
|
410 | + $db->run($update_query); |
|
411 | 411 | $package_array ['package_id'] = $package_info ['package_id']; |
412 | 412 | $package_array ['calltype'] = "FREE"; |
413 | 413 | } |
@@ -418,9 +418,9 @@ discard block |
||
418 | 418 | |
419 | 419 | // Getting used package minutes in counter table |
420 | 420 | function get_counters($accountid, $package_id, $db, $logger) { |
421 | - $query_counter = "SELECT id,seconds FROM counters WHERE accountid = " . $accountid . " AND package_id = " . $package_id . " AND status=1 LIMIT 1"; |
|
422 | - $counter = $db->run ( $query_counter ); |
|
423 | - $logger->log ( "GET Counters : " . $query_counter ); |
|
421 | + $query_counter = "SELECT id,seconds FROM counters WHERE accountid = ".$accountid." AND package_id = ".$package_id." AND status=1 LIMIT 1"; |
|
422 | + $counter = $db->run($query_counter); |
|
423 | + $logger->log("GET Counters : ".$query_counter); |
|
424 | 424 | if ($counter) |
425 | 425 | return $counter [0]; |
426 | 426 | else |
@@ -429,17 +429,17 @@ discard block |
||
429 | 429 | |
430 | 430 | // Get user info |
431 | 431 | function get_accounts($parent_id, $logger, $db) { |
432 | - $query = "SELECT * FROM accounts WHERE id=" . $parent_id; |
|
433 | - $logger->log ( "GET configuration : " . $query ); |
|
434 | - $res_user = $db->run ( $query ); |
|
432 | + $query = "SELECT * FROM accounts WHERE id=".$parent_id; |
|
433 | + $logger->log("GET configuration : ".$query); |
|
434 | + $res_user = $db->run($query); |
|
435 | 435 | return $res_user [0]; |
436 | 436 | } |
437 | 437 | |
438 | 438 | // Get configuration |
439 | 439 | function load_configuration($logger) { |
440 | 440 | $query = "SELECT name,value FROM system WHERE name='decimal_points' and group_title = 'global'"; |
441 | - $config = $db->run ( $query ); |
|
442 | - $logger->log ( "GET configuration : " . $query ); |
|
441 | + $config = $db->run($query); |
|
442 | + $logger->log("GET configuration : ".$query); |
|
443 | 443 | return $config [0]; |
444 | 444 | } |
445 | 445 | |
@@ -449,11 +449,11 @@ discard block |
||
449 | 449 | * @param string $field |
450 | 450 | */ |
451 | 451 | function number_loop($destination, $field, $db) { |
452 | - $max_len_prefix = strlen ( $destination ); |
|
452 | + $max_len_prefix = strlen($destination); |
|
453 | 453 | $number_prefix = '('; |
454 | - while ( $max_len_prefix > 0 ) { |
|
455 | - $number_prefix .= "$field='^" . substr ( $destination, 0, $max_len_prefix ) . ".*' OR "; |
|
456 | - $max_len_prefix --; |
|
454 | + while ($max_len_prefix > 0) { |
|
455 | + $number_prefix .= "$field='^".substr($destination, 0, $max_len_prefix).".*' OR "; |
|
456 | + $max_len_prefix--; |
|
457 | 457 | } |
458 | 458 | $number_prefix .= "$field='^defaultprefix.*')"; // echo $number_prefix;exit; |
459 | 459 | return $number_prefix; |
@@ -465,6 +465,6 @@ discard block |
||
465 | 465 | * @param string $date |
466 | 466 | */ |
467 | 467 | function convert_to_gmt($date) { |
468 | - return gmdate ( 'Y-m-d H:i:s', strtotime ( $date ) ); |
|
468 | + return gmdate('Y-m-d H:i:s', strtotime($date)); |
|
469 | 469 | } |
470 | 470 | ?> |
@@ -82,10 +82,12 @@ discard block |
||
82 | 82 | $actual_calltype = $dataVariable ['calltype']; |
83 | 83 | |
84 | 84 | // Normalize origination and termination rates array |
85 | - if (isset ( $dataVariable ['origination_rates'] )) |
|
86 | - $origination_rate = normalize_origination_rate ( $dataVariable ['origination_rates'] ); |
|
87 | - if (isset ( $dataVariable ['termination_rates'] )) |
|
88 | - $termination_rate = normalize_rate ( $dataVariable ['termination_rates'] ); |
|
85 | + if (isset ( $dataVariable ['origination_rates'] )) { |
|
86 | + $origination_rate = normalize_origination_rate ( $dataVariable ['origination_rates'] ); |
|
87 | + } |
|
88 | + if (isset ( $dataVariable ['termination_rates'] )) { |
|
89 | + $termination_rate = normalize_rate ( $dataVariable ['termination_rates'] ); |
|
90 | + } |
|
89 | 91 | |
90 | 92 | // If receiver account id found then explicitly set call direction and call type |
91 | 93 | if (isset ( $dataVariable ['receiver_accid'] )) { |
@@ -421,11 +423,12 @@ discard block |
||
421 | 423 | $query_counter = "SELECT id,seconds FROM counters WHERE accountid = " . $accountid . " AND package_id = " . $package_id . " AND status=1 LIMIT 1"; |
422 | 424 | $counter = $db->run ( $query_counter ); |
423 | 425 | $logger->log ( "GET Counters : " . $query_counter ); |
424 | - if ($counter) |
|
425 | - return $counter [0]; |
|
426 | - else |
|
427 | - return ""; |
|
428 | -} |
|
426 | + if ($counter) { |
|
427 | + return $counter [0]; |
|
428 | + } else { |
|
429 | + return ""; |
|
430 | + } |
|
431 | + } |
|
429 | 432 | |
430 | 433 | // Get user info |
431 | 434 | function get_accounts($parent_id, $logger, $db) { |
@@ -113,6 +113,11 @@ |
||
113 | 113 | $updateBalance->process_DID_charges ( $account_value, $start_date, $end_date, TRUE ); |
114 | 114 | $this->process_invoice ( $account_value, $start_date, $end_date ); |
115 | 115 | } |
116 | + |
|
117 | + /** |
|
118 | + * @param string $start_date |
|
119 | + * @param string $end_date |
|
120 | + */ |
|
116 | 121 | function process_invoice($accountdata, $start_date, $end_date) { |
117 | 122 | // Get Invoice configuration using single query instead of multiple queries. |
118 | 123 | $invoice_conf = array (); |
@@ -24,66 +24,66 @@ discard block |
||
24 | 24 | class GenerateInvoice extends MX_Controller { |
25 | 25 | public static $global_config; |
26 | 26 | function __construct() { |
27 | - parent::__construct (); |
|
28 | - $this->load->model ( "db_model" ); |
|
29 | - $this->load->library ( "astpp/common" ); |
|
30 | - $this->load->library ( 'html2pdf' ); |
|
31 | - ini_set ( "memory_limit", "2048M" ); |
|
32 | - ini_set ( "max_execution_time", "259200" ); |
|
33 | - $this->get_system_config (); |
|
27 | + parent::__construct(); |
|
28 | + $this->load->model("db_model"); |
|
29 | + $this->load->library("astpp/common"); |
|
30 | + $this->load->library('html2pdf'); |
|
31 | + ini_set("memory_limit", "2048M"); |
|
32 | + ini_set("max_execution_time", "259200"); |
|
33 | + $this->get_system_config(); |
|
34 | 34 | } |
35 | 35 | function get_system_config() { |
36 | - $query = $this->db->get ( "system" ); |
|
37 | - $config = array (); |
|
38 | - $result = $query->result_array (); |
|
39 | - foreach ( $result as $row ) { |
|
36 | + $query = $this->db->get("system"); |
|
37 | + $config = array(); |
|
38 | + $result = $query->result_array(); |
|
39 | + foreach ($result as $row) { |
|
40 | 40 | $config [$row ['name']] = $row ['value']; |
41 | 41 | } |
42 | 42 | self::$global_config ['system_config'] = $config; |
43 | 43 | } |
44 | 44 | function getInvoiceData() { |
45 | - $where = array ( |
|
45 | + $where = array( |
|
46 | 46 | "posttoexternal" => 1, |
47 | 47 | "deleted" => "0", |
48 | 48 | "status" => "0" |
49 | 49 | ); |
50 | - $query = $this->db_model->getSelect ( "*", "accounts", $where ); |
|
50 | + $query = $this->db_model->getSelect("*", "accounts", $where); |
|
51 | 51 | if ($query->num_rows > 0) { |
52 | - $account_data = $query->result_array (); |
|
53 | - foreach ( $account_data as $data_key => $account_value ) { |
|
54 | - $end_date = gmdate ( "Y-m-d" ) . " 23:59:59"; |
|
55 | - $account_value ['sweep_id'] = ( int ) $account_value ['sweep_id']; |
|
52 | + $account_data = $query->result_array(); |
|
53 | + foreach ($account_data as $data_key => $account_value) { |
|
54 | + $end_date = gmdate("Y-m-d")." 23:59:59"; |
|
55 | + $account_value ['sweep_id'] = (int)$account_value ['sweep_id']; |
|
56 | 56 | switch ($account_value ['sweep_id']) { |
57 | 57 | case 0 : |
58 | - $start_date = $this->validate_invoice_date ( $account_value ); |
|
59 | - if (strtotime ( $start_date ) >= strtotime ( gmdate ( "Y-m-d H:i:s" ) )) { |
|
60 | - $start_date = gmdate ( "Y-m-d H:i:s" ); |
|
58 | + $start_date = $this->validate_invoice_date($account_value); |
|
59 | + if (strtotime($start_date) >= strtotime(gmdate("Y-m-d H:i:s"))) { |
|
60 | + $start_date = gmdate("Y-m-d H:i:s"); |
|
61 | 61 | } |
62 | - $end_date = gmdate ( "Y-m-d 23:59:59", strtotime ( $start_date . " + 1 days" ) ); |
|
63 | - $this->Generate_Daily_invoice ( $account_value, $start_date, $end_date ); |
|
62 | + $end_date = gmdate("Y-m-d 23:59:59", strtotime($start_date." + 1 days")); |
|
63 | + $this->Generate_Daily_invoice($account_value, $start_date, $end_date); |
|
64 | 64 | break; |
65 | 65 | case 2 : |
66 | - if (date ( "d" ) == $account_value ['invoice_day']) { |
|
67 | - $start_date = $this->validate_invoice_date ( $account_value ); |
|
68 | - if (strtotime ( $start_date ) >= strtotime ( gmdate ( "Y-m-d H:i:s" ) )) { |
|
69 | - $start_date = gmdate ( "Y-m-d H:i:s" ); |
|
66 | + if (date("d") == $account_value ['invoice_day']) { |
|
67 | + $start_date = $this->validate_invoice_date($account_value); |
|
68 | + if (strtotime($start_date) >= strtotime(gmdate("Y-m-d H:i:s"))) { |
|
69 | + $start_date = gmdate("Y-m-d H:i:s"); |
|
70 | 70 | } |
71 | - $end_date = gmdate ( "Y-m-d 23:59:59", strtotime ( $start_date . " + 1 month" ) ); |
|
72 | - $this->Generate_Monthly_invoice ( $account_value, $start_date, $end_date ); |
|
71 | + $end_date = gmdate("Y-m-d 23:59:59", strtotime($start_date." + 1 month")); |
|
72 | + $this->Generate_Monthly_invoice($account_value, $start_date, $end_date); |
|
73 | 73 | } |
74 | 74 | break; |
75 | 75 | } |
76 | 76 | } |
77 | - $screen_path = getcwd () . "/cron"; |
|
78 | - $screen_filename = "Email_Broadcast_" . strtotime ( 'now' ); |
|
79 | - $command = "cd " . $screen_path . " && /usr/bin/screen -d -m -S $screen_filename php cron.php BroadcastEmail"; |
|
80 | - exec ( $command ); |
|
77 | + $screen_path = getcwd()."/cron"; |
|
78 | + $screen_filename = "Email_Broadcast_".strtotime('now'); |
|
79 | + $command = "cd ".$screen_path." && /usr/bin/screen -d -m -S $screen_filename php cron.php BroadcastEmail"; |
|
80 | + exec($command); |
|
81 | 81 | } |
82 | 82 | } |
83 | 83 | function validate_invoice_date($account_value) { |
84 | - $last_invoice_date = $this->common->get_invoice_date ( "to_date", $account_value ["id"], $account_value ['reseller_id'], "to_date" ); |
|
84 | + $last_invoice_date = $this->common->get_invoice_date("to_date", $account_value ["id"], $account_value ['reseller_id'], "to_date"); |
|
85 | 85 | $last_invoice_date = ($last_invoice_date) ? $last_invoice_date : $account_value ['creation']; |
86 | - $last_invoice_date = gmdate ( "Y-m-d H:i:s", strtotime ( "+1 Second", strtotime ( $last_invoice_date ) ) ); |
|
86 | + $last_invoice_date = gmdate("Y-m-d H:i:s", strtotime("+1 Second", strtotime($last_invoice_date))); |
|
87 | 87 | return $last_invoice_date; |
88 | 88 | } |
89 | 89 | |
@@ -95,10 +95,10 @@ discard block |
||
95 | 95 | function Generate_Daily_invoice($account_value, $start_date, $end_date) { |
96 | 96 | // echo "INVOICE SCRIPT-------start date :".$start_date."-------end date....".$end_date; |
97 | 97 | require_once ('updateBalance.php'); |
98 | - $updateBalance = new updateBalance (); |
|
99 | - $updateBalance->process_subscriptions ( $account_value, $start_date, $end_date, TRUE ); |
|
100 | - $updateBalance->process_DID_charges ( $account_value, $start_date, $end_date, TRUE ); |
|
101 | - $this->process_invoice ( $account_value, $start_date, $end_date ); |
|
98 | + $updateBalance = new updateBalance(); |
|
99 | + $updateBalance->process_subscriptions($account_value, $start_date, $end_date, TRUE); |
|
100 | + $updateBalance->process_DID_charges($account_value, $start_date, $end_date, TRUE); |
|
101 | + $this->process_invoice($account_value, $start_date, $end_date); |
|
102 | 102 | } |
103 | 103 | |
104 | 104 | /** |
@@ -108,78 +108,78 @@ discard block |
||
108 | 108 | */ |
109 | 109 | function Generate_Monthly_invoice($account_value, $start_date, $end_date) { |
110 | 110 | require_once ('updateBalance.php'); |
111 | - $updateBalance = new updateBalance (); |
|
112 | - $updateBalance->process_subscriptions ( $account_value, $start_date, $end_date, TRUE ); |
|
113 | - $updateBalance->process_DID_charges ( $account_value, $start_date, $end_date, TRUE ); |
|
114 | - $this->process_invoice ( $account_value, $start_date, $end_date ); |
|
111 | + $updateBalance = new updateBalance(); |
|
112 | + $updateBalance->process_subscriptions($account_value, $start_date, $end_date, TRUE); |
|
113 | + $updateBalance->process_DID_charges($account_value, $start_date, $end_date, TRUE); |
|
114 | + $this->process_invoice($account_value, $start_date, $end_date); |
|
115 | 115 | } |
116 | 116 | function process_invoice($accountdata, $start_date, $end_date) { |
117 | 117 | // Get Invoice configuration using single query instead of multiple queries. |
118 | - $invoice_conf = array (); |
|
118 | + $invoice_conf = array(); |
|
119 | 119 | $reseller_id = ($accountdata ['reseller_id'] == 0) ? 1 : $accountdata ['reseller_id']; |
120 | - $where = "accountid IN ('" . $reseller_id . "','1')"; |
|
121 | - $this->db->select ( '*' ); |
|
122 | - $this->db->where ( $where ); |
|
123 | - $this->db->order_by ( 'accountid', 'desc' ); |
|
124 | - $this->db->limit ( 1 ); |
|
125 | - $invoice_conf = $this->db->get ( 'invoice_conf' ); |
|
126 | - $invoice_conf = ( array ) $invoice_conf->first_row (); |
|
120 | + $where = "accountid IN ('".$reseller_id."','1')"; |
|
121 | + $this->db->select('*'); |
|
122 | + $this->db->where($where); |
|
123 | + $this->db->order_by('accountid', 'desc'); |
|
124 | + $this->db->limit(1); |
|
125 | + $invoice_conf = $this->db->get('invoice_conf'); |
|
126 | + $invoice_conf = (array)$invoice_conf->first_row(); |
|
127 | 127 | /** |
128 | 128 | * **************************************************** |
129 | 129 | */ |
130 | - $last_invoice_ID = $this->common->get_invoice_date ( "invoiceid", "", $accountdata ['reseller_id'] ); |
|
130 | + $last_invoice_ID = $this->common->get_invoice_date("invoiceid", "", $accountdata ['reseller_id']); |
|
131 | 131 | if ($last_invoice_ID && $last_invoice_ID > 0) { |
132 | 132 | $last_invoice_ID = ($last_invoice_ID + 1); |
133 | 133 | } else { |
134 | 134 | $last_invoice_ID = $invoice_conf ['invoice_start_from']; |
135 | 135 | } |
136 | - $last_invoice_ID = str_pad ( $last_invoice_ID, (strlen ( $last_invoice_ID ) + 4), '0', STR_PAD_LEFT ); |
|
137 | - $invoice_sub_total = $this->count_invoice_data ( $accountdata, $start_date, $end_date ); |
|
136 | + $last_invoice_ID = str_pad($last_invoice_ID, (strlen($last_invoice_ID) + 4), '0', STR_PAD_LEFT); |
|
137 | + $invoice_sub_total = $this->count_invoice_data($accountdata, $start_date, $end_date); |
|
138 | 138 | if ($invoice_sub_total > 0) { |
139 | - $invoiceid = $this->create_invoice ( $accountdata, $start_date, $end_date, $last_invoice_ID, $invoice_conf ['invoice_prefix'], $invoice_conf ); |
|
140 | - $this->update_cdrs_data ( $accountdata ['id'], $invoiceid, $start_date, $end_date ); |
|
141 | - $sort_order = $this->common_model->apply_invoice_taxes ( $invoiceid, $accountdata, $start_date ); |
|
142 | - $invoice_total = $this->set_invoice_total ( $invoiceid, $accountdata ['id'] ); |
|
143 | - $this->download_invoice ( $invoiceid, $accountdata, $invoice_conf ); |
|
139 | + $invoiceid = $this->create_invoice($accountdata, $start_date, $end_date, $last_invoice_ID, $invoice_conf ['invoice_prefix'], $invoice_conf); |
|
140 | + $this->update_cdrs_data($accountdata ['id'], $invoiceid, $start_date, $end_date); |
|
141 | + $sort_order = $this->common_model->apply_invoice_taxes($invoiceid, $accountdata, $start_date); |
|
142 | + $invoice_total = $this->set_invoice_total($invoiceid, $accountdata ['id']); |
|
143 | + $this->download_invoice($invoiceid, $accountdata, $invoice_conf); |
|
144 | 144 | } else { |
145 | - $invoiceid = $this->create_invoice ( $accountdata, $start_date, $end_date, $last_invoice_ID, $invoice_conf ['invoice_prefix'], $invoice_conf ); |
|
146 | - $sort_order = $this->common_model->apply_invoice_taxes ( $invoiceid, $accountdata, $start_date ); |
|
147 | - $invoice_total = $this->set_invoice_total ( $invoiceid, $accountdata ['id'] ); |
|
145 | + $invoiceid = $this->create_invoice($accountdata, $start_date, $end_date, $last_invoice_ID, $invoice_conf ['invoice_prefix'], $invoice_conf); |
|
146 | + $sort_order = $this->common_model->apply_invoice_taxes($invoiceid, $accountdata, $start_date); |
|
147 | + $invoice_total = $this->set_invoice_total($invoiceid, $accountdata ['id']); |
|
148 | 148 | } |
149 | 149 | } |
150 | 150 | function count_invoice_data($account, $start_date = "", $end_date = "") { |
151 | 151 | $cdr_query = ""; |
152 | 152 | $inv_data_query = ""; |
153 | - $cdr_query = "select calltype,sum(debit) as debit from cdrs where accountid = " . $account ['id']; |
|
154 | - $cdr_query .= " AND callstart >='" . $start_date . "' AND callstart <= '" . $end_date . "' AND invoiceid=0 group by calltype"; |
|
153 | + $cdr_query = "select calltype,sum(debit) as debit from cdrs where accountid = ".$account ['id']; |
|
154 | + $cdr_query .= " AND callstart >='".$start_date."' AND callstart <= '".$end_date."' AND invoiceid=0 group by calltype"; |
|
155 | 155 | // echo $cdr_query; |
156 | - $cdr_data = $this->db->query ( $cdr_query ); |
|
156 | + $cdr_data = $this->db->query($cdr_query); |
|
157 | 157 | if ($cdr_data->num_rows > 0) { |
158 | - $cdr_data = $cdr_data->result_array (); |
|
158 | + $cdr_data = $cdr_data->result_array(); |
|
159 | 159 | // echo '<pre>'; print_r($cdr_data); exit; |
160 | - foreach ( $cdr_data as $cdrvalue ) { |
|
161 | - $cdrvalue ['debit'] = round ( $cdrvalue ['debit'], self::$global_config ['system_config'] ['decimalpoints'] ); |
|
162 | - $tempArr = array ( |
|
160 | + foreach ($cdr_data as $cdrvalue) { |
|
161 | + $cdrvalue ['debit'] = round($cdrvalue ['debit'], self::$global_config ['system_config'] ['decimalpoints']); |
|
162 | + $tempArr = array( |
|
163 | 163 | "accountid" => $account ['id'], |
164 | 164 | "reseller_id" => $account ['reseller_id'], |
165 | 165 | "item_id" => "0", |
166 | - "description" => $cdrvalue ['calltype'] . " CALLS for the period (" . $start_date . " to " . $end_date, |
|
166 | + "description" => $cdrvalue ['calltype']." CALLS for the period (".$start_date." to ".$end_date, |
|
167 | 167 | "debit" => $cdrvalue ['debit'], |
168 | 168 | "item_type" => $cdrvalue ['calltype'], |
169 | 169 | "created_date" => $end_date |
170 | 170 | ); |
171 | - $this->db->insert ( "invoice_details", $tempArr ); |
|
171 | + $this->db->insert("invoice_details", $tempArr); |
|
172 | 172 | } |
173 | 173 | } |
174 | - $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'"; |
|
174 | + $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'"; |
|
175 | 175 | // echo $inv_data_query; |
176 | - $invoice_data = $this->db->query ( $inv_data_query ); |
|
176 | + $invoice_data = $this->db->query($inv_data_query); |
|
177 | 177 | if ($invoice_data->num_rows > 0) { |
178 | - $invoice_data = $invoice_data->result_array (); |
|
179 | - foreach ( $invoice_data as $data_value ) { |
|
178 | + $invoice_data = $invoice_data->result_array(); |
|
179 | + foreach ($invoice_data as $data_value) { |
|
180 | 180 | if ($data_value ['count'] > 0) { |
181 | 181 | $sub_total = ($data_value ['debit'] - $data_value ['credit']); |
182 | - $sub_total = round ( $sub_total, self::$global_config ['system_config'] ['decimalpoints'] ); |
|
182 | + $sub_total = round($sub_total, self::$global_config ['system_config'] ['decimalpoints']); |
|
183 | 183 | return $sub_total; |
184 | 184 | } |
185 | 185 | } |
@@ -189,9 +189,9 @@ discard block |
||
189 | 189 | |
190 | 190 | // Change Order of arguements |
191 | 191 | function update_cdrs_data($accountid, $invoiceid, $start_date = "", $end_date = "") { |
192 | - $inv_data_query = "update invoice_details SET invoiceid = '" . $invoiceid . "' where accountid=" . $accountid; |
|
193 | - $inv_data_query .= " AND created_date >='" . $start_date . "' AND created_date <= '" . $end_date . "' AND invoiceid=0 AND item_type !='PAYMENT'"; |
|
194 | - $this->db->query ( $inv_data_query ); |
|
192 | + $inv_data_query = "update invoice_details SET invoiceid = '".$invoiceid."' where accountid=".$accountid; |
|
193 | + $inv_data_query .= " AND created_date >='".$start_date."' AND created_date <= '".$end_date."' AND invoiceid=0 AND item_type !='PAYMENT'"; |
|
194 | + $this->db->query($inv_data_query); |
|
195 | 195 | return true; |
196 | 196 | } |
197 | 197 | |
@@ -202,20 +202,20 @@ discard block |
||
202 | 202 | function create_invoice($account, $from_date, $to_date, $last_invoice_ID, $INVprefix, $invoiceconf) { |
203 | 203 | // $due_date = gmdate("Y-m-d H:i:s",strtotime($to_date." +".$invoiceconf['interval']." days")); |
204 | 204 | if ($invoiceconf ['interval'] > 0) { |
205 | - $due_date = gmdate ( "Y-m-d H:i:s", strtotime ( gmdate ( "Y-m-d H:i:s" ) . " +" . $invoiceconf ['interval'] . " days" ) ); |
|
205 | + $due_date = gmdate("Y-m-d H:i:s", strtotime(gmdate("Y-m-d H:i:s")." +".$invoiceconf ['interval']." days")); |
|
206 | 206 | } else { |
207 | - $due_date = gmdate ( "Y-m-d H:i:s", strtotime ( gmdate ( "Y-m-d H:i:s" ) . " +7 days" ) ); |
|
207 | + $due_date = gmdate("Y-m-d H:i:s", strtotime(gmdate("Y-m-d H:i:s")." +7 days")); |
|
208 | 208 | } |
209 | 209 | // echo "due daye-------".$due_date.'----------'.$to_date.'------------> Invoice interval'.$invoiceconf['interval']; |
210 | 210 | $balance = ($account ['credit_limit'] - $account ['balance']); |
211 | 211 | $automatic_flag = self::$global_config ['system_config'] ['automatic_invoice']; |
212 | 212 | if ($automatic_flag == 1) { |
213 | - $invoice_data = array ( |
|
213 | + $invoice_data = array( |
|
214 | 214 | "accountid" => $account ['id'], |
215 | 215 | "invoice_prefix" => $INVprefix, |
216 | 216 | "invoiceid" => $last_invoice_ID, |
217 | 217 | "reseller_id" => $account ['reseller_id'], |
218 | - "invoice_date" => gmdate ( "Y-m-d H:i:s" ), |
|
218 | + "invoice_date" => gmdate("Y-m-d H:i:s"), |
|
219 | 219 | "from_date" => $from_date, |
220 | 220 | "to_date" => $to_date, |
221 | 221 | "due_date" => $due_date, |
@@ -224,12 +224,12 @@ discard block |
||
224 | 224 | "balance" => $balance |
225 | 225 | ); |
226 | 226 | } else { |
227 | - $invoice_data = array ( |
|
227 | + $invoice_data = array( |
|
228 | 228 | "accountid" => $account ['id'], |
229 | 229 | "invoice_prefix" => $INVprefix, |
230 | 230 | "invoiceid" => $last_invoice_ID, |
231 | 231 | "reseller_id" => $account ['reseller_id'], |
232 | - "invoice_date" => gmdate ( "Y-m-d H:i:s" ), |
|
232 | + "invoice_date" => gmdate("Y-m-d H:i:s"), |
|
233 | 233 | "from_date" => $from_date, |
234 | 234 | "to_date" => $to_date, |
235 | 235 | "due_date" => $due_date, |
@@ -240,49 +240,49 @@ discard block |
||
240 | 240 | ); |
241 | 241 | } |
242 | 242 | // echo "<pre>"; print_r($invoice_data); exit; |
243 | - $this->db->insert ( "invoices", $invoice_data ); |
|
244 | - $invoiceid = $this->db->insert_id (); |
|
243 | + $this->db->insert("invoices", $invoice_data); |
|
244 | + $invoiceid = $this->db->insert_id(); |
|
245 | 245 | if ($automatic_flag == 0) { |
246 | - $this->download_invoice ( $invoiceid, $account, $invoiceconf ); |
|
246 | + $this->download_invoice($invoiceid, $account, $invoiceconf); |
|
247 | 247 | } |
248 | 248 | return $invoiceid; |
249 | 249 | } |
250 | 250 | function set_invoice_total($invoiceid, $accountid) { |
251 | - $query = $this->db_model->getSelect ( "SUM(debit) as total", "invoice_details", array ( |
|
251 | + $query = $this->db_model->getSelect("SUM(debit) as total", "invoice_details", array( |
|
252 | 252 | "invoiceid" => $invoiceid, |
253 | 253 | "item_type <>" => "FREECALL" |
254 | - ) ); |
|
255 | - $query = $query->result_array (); |
|
254 | + )); |
|
255 | + $query = $query->result_array(); |
|
256 | 256 | $sub_total = $query ["0"] ["total"]; |
257 | - $updateArr = array ( |
|
257 | + $updateArr = array( |
|
258 | 258 | "amount" => $sub_total |
259 | 259 | ); |
260 | - $this->db->where ( array ( |
|
260 | + $this->db->where(array( |
|
261 | 261 | "id" => $invoiceid |
262 | - ) ); |
|
263 | - $this->db->update ( "invoices", $updateArr ); |
|
262 | + )); |
|
263 | + $this->db->update("invoices", $updateArr); |
|
264 | 264 | |
265 | - $updateArr = array ( |
|
265 | + $updateArr = array( |
|
266 | 266 | "balance" => "0.00" |
267 | 267 | ); |
268 | - $this->db->where ( array ( |
|
268 | + $this->db->where(array( |
|
269 | 269 | "id" => $accountid |
270 | - ) ); |
|
271 | - $this->db->update ( "accounts", $updateArr ); |
|
270 | + )); |
|
271 | + $this->db->update("accounts", $updateArr); |
|
272 | 272 | |
273 | 273 | return true; |
274 | 274 | } |
275 | 275 | function download_invoice($invoiceid, $accountdata, $invoice_conf) { |
276 | - $invoicedata = $this->db_model->getSelect ( "*", "invoices", array ( |
|
276 | + $invoicedata = $this->db_model->getSelect("*", "invoices", array( |
|
277 | 277 | "id" => $invoiceid |
278 | - ) ); |
|
279 | - $invoicedata = $invoicedata->result_array (); |
|
278 | + )); |
|
279 | + $invoicedata = $invoicedata->result_array(); |
|
280 | 280 | $invoicedata = $invoicedata [0]; |
281 | - $FilePath = FCPATH . "invoices/" . $accountdata ["id"] . '/' . $invoicedata ['invoice_prefix'] . "" . $invoicedata ['invoiceid'] . "_invoice.pdf"; |
|
282 | - $Filenm = $invoicedata ['invoice_prefix'] . "_" . $invoicedata ['invoiceid'] . "_invoice.pdf"; |
|
283 | - $this->common->get_invoice_template ( $invoicedata, $accountdata, false ); |
|
281 | + $FilePath = FCPATH."invoices/".$accountdata ["id"].'/'.$invoicedata ['invoice_prefix']."".$invoicedata ['invoiceid']."_invoice.pdf"; |
|
282 | + $Filenm = $invoicedata ['invoice_prefix']."_".$invoicedata ['invoiceid']."_invoice.pdf"; |
|
283 | + $this->common->get_invoice_template($invoicedata, $accountdata, false); |
|
284 | 284 | if ($invoice_conf ['invoice_notification']) { |
285 | - $this->send_email_notification ( $FilePath, $Filenm, $accountdata, $invoice_conf, $invoicedata ); |
|
285 | + $this->send_email_notification($FilePath, $Filenm, $accountdata, $invoice_conf, $invoicedata); |
|
286 | 286 | } |
287 | 287 | } |
288 | 288 | |
@@ -292,30 +292,30 @@ discard block |
||
292 | 292 | * @param string $Filenm |
293 | 293 | */ |
294 | 294 | function send_email_notification($FilePath, $Filenm, $AccountData, $invoice_conf, $invData) { |
295 | - $TemplateData = array (); |
|
296 | - $where = array ( |
|
295 | + $TemplateData = array(); |
|
296 | + $where = array( |
|
297 | 297 | 'name' => 'email_new_invoice' |
298 | 298 | ); |
299 | - $EmailTemplate = $this->db_model->getSelect ( "*", "default_templates", $where ); |
|
300 | - foreach ( $EmailTemplate->result_array () as $TemplateVal ) { |
|
299 | + $EmailTemplate = $this->db_model->getSelect("*", "default_templates", $where); |
|
300 | + foreach ($EmailTemplate->result_array() as $TemplateVal) { |
|
301 | 301 | $TemplateData = $TemplateVal; |
302 | - $TemplateData ['subject'] = str_replace ( '#NAME#', $AccountData ['first_name'] . " " . $AccountData ['last_name'], $TemplateData ['subject'] ); |
|
303 | - $TemplateData ['subject'] = str_replace ( '#INVOICE_NUMBER#', $invData ['invoice_prefix'] . $invData ['invoiceid'], $TemplateData ['subject'] ); |
|
304 | - $TemplateData ['template'] = str_replace ( '#NAME#', $AccountData ['first_name'] . " " . $AccountData ['last_name'], $TemplateData ['template'] ); |
|
305 | - $TemplateData ['template'] = str_replace ( '#INVOICE_NUMBER#', $invData ['invoice_prefix'] . $invData ['invoiceid'], $TemplateData ['template'] ); |
|
306 | - $TemplateData ['template'] = str_replace ( '#AMOUNT#', $invData ['amount'], $TemplateData ['template'] ); |
|
302 | + $TemplateData ['subject'] = str_replace('#NAME#', $AccountData ['first_name']." ".$AccountData ['last_name'], $TemplateData ['subject']); |
|
303 | + $TemplateData ['subject'] = str_replace('#INVOICE_NUMBER#', $invData ['invoice_prefix'].$invData ['invoiceid'], $TemplateData ['subject']); |
|
304 | + $TemplateData ['template'] = str_replace('#NAME#', $AccountData ['first_name']." ".$AccountData ['last_name'], $TemplateData ['template']); |
|
305 | + $TemplateData ['template'] = str_replace('#INVOICE_NUMBER#', $invData ['invoice_prefix'].$invData ['invoiceid'], $TemplateData ['template']); |
|
306 | + $TemplateData ['template'] = str_replace('#AMOUNT#', $invData ['amount'], $TemplateData ['template']); |
|
307 | 307 | |
308 | - $TemplateData ['template'] = str_replace ( "#COMPANY_EMAIL#", $invoice_conf ['emailaddress'], $TemplateData ['template'] ); |
|
309 | - $TemplateData ['template'] = str_replace ( "#COMPANY_NAME#", $invoice_conf ['company_name'], $TemplateData ['template'] ); |
|
310 | - $TemplateData ['template'] = str_replace ( "#COMPANY_WEBSITE#", $invoice_conf ['website'], $TemplateData ['template'] ); |
|
311 | - $TemplateData ['template'] = str_replace ( "#INVOICE_DATE#", $invData ['invoice_date'], $TemplateData ['template'] ); |
|
312 | - $TemplateData ['template'] = str_replace ( "#DUE_DATE#", $invData ['due_date'], $TemplateData ['template'] ); |
|
308 | + $TemplateData ['template'] = str_replace("#COMPANY_EMAIL#", $invoice_conf ['emailaddress'], $TemplateData ['template']); |
|
309 | + $TemplateData ['template'] = str_replace("#COMPANY_NAME#", $invoice_conf ['company_name'], $TemplateData ['template']); |
|
310 | + $TemplateData ['template'] = str_replace("#COMPANY_WEBSITE#", $invoice_conf ['website'], $TemplateData ['template']); |
|
311 | + $TemplateData ['template'] = str_replace("#INVOICE_DATE#", $invData ['invoice_date'], $TemplateData ['template']); |
|
312 | + $TemplateData ['template'] = str_replace("#DUE_DATE#", $invData ['due_date'], $TemplateData ['template']); |
|
313 | 313 | } |
314 | - $dir_path = getcwd () . "/attachments/"; |
|
315 | - $path = $dir_path . $Filenm; |
|
316 | - $command = "cp " . $FilePath . " " . $path; |
|
317 | - exec ( $command ); |
|
318 | - $email_array = array ( |
|
314 | + $dir_path = getcwd()."/attachments/"; |
|
315 | + $path = $dir_path.$Filenm; |
|
316 | + $command = "cp ".$FilePath." ".$path; |
|
317 | + exec($command); |
|
318 | + $email_array = array( |
|
319 | 319 | 'accountid' => $AccountData ['id'], |
320 | 320 | 'subject' => $TemplateData ['subject'], |
321 | 321 | 'body' => $TemplateData ['template'], |
@@ -326,7 +326,7 @@ discard block |
||
326 | 326 | 'template' => '' |
327 | 327 | ); |
328 | 328 | // echo "<pre>"; print_r($TemplateData); exit; |
329 | - $this->db->insert ( "mail_details", $email_array ); |
|
329 | + $this->db->insert("mail_details", $email_array); |
|
330 | 330 | } |
331 | 331 | } |
332 | 332 |
@@ -55,6 +55,10 @@ discard block |
||
55 | 55 | * BillAccountCharges is custom method which we use to manage instant billing for any type of services at the time of delete or release the services before the invoice process for prepaid or postpaid both type of customers. |
56 | 56 | * We define different different cases to manage it you can add it more if needed. |
57 | 57 | */ |
58 | + |
|
59 | + /** |
|
60 | + * @param string $BillType |
|
61 | + */ |
|
58 | 62 | function BillAccountCharges($BillType, $params) { |
59 | 63 | switch ($BillType) { |
60 | 64 | |
@@ -179,6 +183,10 @@ discard block |
||
179 | 183 | /* |
180 | 184 | * process_subscriptions method use to manage subscription charges associated with accounts. |
181 | 185 | */ |
186 | + |
|
187 | + /** |
|
188 | + * @param string $NowDate |
|
189 | + */ |
|
182 | 190 | function process_subscriptions($AccountData, $StartDate, $EndDate, $InvocieID, $NowDate) { |
183 | 191 | if ($this->Error_flag) { |
184 | 192 | echo ":::::::::::::::::::::::: SUBSCRIPTION BILLING START ::::::::::::::::::::::::\n"; |
@@ -235,6 +243,10 @@ discard block |
||
235 | 243 | /* |
236 | 244 | * process_subscriptions method use to manage subscription charges associated with accounts. |
237 | 245 | */ |
246 | + |
|
247 | + /** |
|
248 | + * @param string $NowDate |
|
249 | + */ |
|
238 | 250 | function process_DID_charges($AccountData, $StartDate, $EndDate, $InvocieID, $NowDate, $ManualFlag = false) { |
239 | 251 | if ($this->Error_flag) { |
240 | 252 | echo ":::::::::::::::::::::::: DIDs BILLING START ::::::::::::::::::::::::\n"; |
@@ -322,6 +334,10 @@ discard block |
||
322 | 334 | echo ":::::::::::::::::::::::: DIDs BILLING END ::::::::::::::::::::::::\n"; |
323 | 335 | } |
324 | 336 | } |
337 | + |
|
338 | + /** |
|
339 | + * @param string $billing_cycle |
|
340 | + */ |
|
325 | 341 | function Get_Date_Range_Array($billing_cycle, $itemArr, $StartDate, $EndDate) { |
326 | 342 | $last_invoice_date = $itemArr ['LastBillDate']; |
327 | 343 | |
@@ -528,6 +544,11 @@ discard block |
||
528 | 544 | |
529 | 545 | return $ItemEndDate; |
530 | 546 | } |
547 | + |
|
548 | + /** |
|
549 | + * @param string $select |
|
550 | + * @param string $table |
|
551 | + */ |
|
531 | 552 | function get_table_data($select, $table, $where) { |
532 | 553 | $query = $this->db_model->getSelect ( $select, $table, $where ); |
533 | 554 | if ($query->num_rows > 0) { |
@@ -551,6 +572,10 @@ discard block |
||
551 | 572 | } |
552 | 573 | |
553 | 574 | // Build an array for different services. |
575 | + |
|
576 | + /** |
|
577 | + * @param string $Type |
|
578 | + */ |
|
554 | 579 | function Build_ItemArr($description, $ItemID, $Type, $Cycle, $AssignDate, $BillDate, $NowDate) { |
555 | 580 | $ItemArr = array ( |
556 | 581 | 'Description' => $description, |
@@ -25,13 +25,13 @@ discard block |
||
25 | 25 | public $Error_flag = false; |
26 | 26 | public $currentdate = ""; |
27 | 27 | function __construct() { |
28 | - parent::__construct (); |
|
29 | - $this->load->model ( "db_model" ); |
|
30 | - $this->load->model ( "common_model" ); |
|
31 | - $this->load->library ( "astpp/common" ); |
|
28 | + parent::__construct(); |
|
29 | + $this->load->model("db_model"); |
|
30 | + $this->load->model("common_model"); |
|
31 | + $this->load->library("astpp/common"); |
|
32 | 32 | |
33 | 33 | // Set custom current date to generate invoice for specific date. |
34 | - $this->currentdate = gmdate ( "Y-m-d H:i:s" ); |
|
34 | + $this->currentdate = gmdate("Y-m-d H:i:s"); |
|
35 | 35 | // $this->currentdate = "2016-02-15 00:00:01"; |
36 | 36 | } |
37 | 37 | |
@@ -40,14 +40,14 @@ discard block |
||
40 | 40 | * This method we directly call from cron script and bill the services and charges which is associated with prepaid customers. |
41 | 41 | */ |
42 | 42 | function GetUpdateBalance() { |
43 | - $Accounts = $this->get_table_data ( "*", "accounts", array ( |
|
43 | + $Accounts = $this->get_table_data("*", "accounts", array( |
|
44 | 44 | "posttoexternal" => 0, |
45 | 45 | "status" => "0", |
46 | 46 | "deleted" => "0" |
47 | - ) ); |
|
48 | - foreach ( $Accounts as $AccountData ) { |
|
49 | - $this->process_subscriptions ( $AccountData, $this->currentdate, $this->currentdate, 0, $this->currentdate ); |
|
50 | - $this->process_DID_charges ( $AccountData, $this->currentdate, $this->currentdate, 0, $this->currentdate ); |
|
47 | + )); |
|
48 | + foreach ($Accounts as $AccountData) { |
|
49 | + $this->process_subscriptions($AccountData, $this->currentdate, $this->currentdate, 0, $this->currentdate); |
|
50 | + $this->process_DID_charges($AccountData, $this->currentdate, $this->currentdate, 0, $this->currentdate); |
|
51 | 51 | } |
52 | 52 | } |
53 | 53 | |
@@ -59,65 +59,65 @@ discard block |
||
59 | 59 | switch ($BillType) { |
60 | 60 | |
61 | 61 | case "SUBSCRIPTION" : |
62 | - if (is_array ( $params )) { |
|
63 | - $this->ProcessDailyCharges ( true, $params ['ChargeID'] ); |
|
62 | + if (is_array($params)) { |
|
63 | + $this->ProcessDailyCharges(true, $params ['ChargeID']); |
|
64 | 64 | } else { |
65 | - $this->ProcessDailyCharges ( true, $params ); |
|
65 | + $this->ProcessDailyCharges(true, $params); |
|
66 | 66 | } |
67 | 67 | break; |
68 | 68 | case "ACCOUNTSUBSCRIPTION" : |
69 | 69 | $AccountData = $params ['AccountInfo']; |
70 | - $LastBillDate = $this->common->get_field_name ( 'charge_upto', 'charge_to_account', array ( |
|
70 | + $LastBillDate = $this->common->get_field_name('charge_upto', 'charge_to_account', array( |
|
71 | 71 | 'accountid' => $AccountData ['id'], |
72 | 72 | 'charge_id' => $params ['ChargeID'] |
73 | - ) ); |
|
73 | + )); |
|
74 | 74 | if ($LastBillDate == '0000-00-00 00:00:00' || $LastBillDate == '') { |
75 | - $LastBillDate = $this->common->get_field_name ( 'assign_date', 'charge_to_account', array ( |
|
75 | + $LastBillDate = $this->common->get_field_name('assign_date', 'charge_to_account', array( |
|
76 | 76 | 'accountid' => $AccountData ['id'], |
77 | 77 | 'charge_id' => $params ['ChargeID'] |
78 | - ) ); |
|
78 | + )); |
|
79 | 79 | } |
80 | 80 | if ($AccountData ['sweep_id'] == 0) { |
81 | - $end_date = date ( "Y-m-d 23:59:59", strtotime ( $LastBillDate ) ); |
|
81 | + $end_date = date("Y-m-d 23:59:59", strtotime($LastBillDate)); |
|
82 | 82 | } else { |
83 | - $end_date = date ( "Y-m-" . $AccountData ['invoice_day'] . " 23:59:59", strtotime ( $LastBillDate . " + 1 month" ) ); |
|
84 | - $inv_date = date ( "Y-m-" . $AccountData ['invoice_day'] . " 23:59:59", strtotime ( $LastBillDate ) ); |
|
85 | - if (strtotime ( $inv_date ) > strtotime ( date ( "Y-m-d 23:59:59", strtotime ( $this->currentdate ) ) )) { |
|
83 | + $end_date = date("Y-m-".$AccountData ['invoice_day']." 23:59:59", strtotime($LastBillDate." + 1 month")); |
|
84 | + $inv_date = date("Y-m-".$AccountData ['invoice_day']." 23:59:59", strtotime($LastBillDate)); |
|
85 | + if (strtotime($inv_date) > strtotime(date("Y-m-d 23:59:59", strtotime($this->currentdate)))) { |
|
86 | 86 | $end_date = $inv_date; |
87 | 87 | } |
88 | 88 | } |
89 | - $this->process_subscriptions ( $AccountData, $LastBillDate, $end_date, 0, $this->currentdate ); |
|
89 | + $this->process_subscriptions($AccountData, $LastBillDate, $end_date, 0, $this->currentdate); |
|
90 | 90 | break; |
91 | 91 | case "DIDs" : |
92 | - if (! is_array ( $params )) { |
|
92 | + if ( ! is_array($params)) { |
|
93 | 93 | $params ['DIDid'] = $params; |
94 | 94 | } |
95 | - $DIDData = $this->get_table_data ( "*", "dids", array ( |
|
95 | + $DIDData = $this->get_table_data("*", "dids", array( |
|
96 | 96 | "id" => $params ['DIDid'] |
97 | - ) ); |
|
97 | + )); |
|
98 | 98 | $DIDData = $DIDData [0]; |
99 | 99 | if ($DIDData ['charge_upto'] == '0000-00-00 00:00:00') { |
100 | 100 | $DIDData ['charge_upto'] = $DIDData ['assign_date']; |
101 | 101 | } |
102 | 102 | $LastBillDate = $DIDData ['charge_upto']; |
103 | 103 | |
104 | - $AccountData = $this->get_table_data ( "*", "accounts", array ( |
|
104 | + $AccountData = $this->get_table_data("*", "accounts", array( |
|
105 | 105 | "id" => $DIDData ['accountid'] |
106 | - ) ); |
|
106 | + )); |
|
107 | 107 | $AccountData = $AccountData [0]; |
108 | 108 | $AccountData ['DIDid'] = $params ['DIDid']; |
109 | 109 | if ($AccountData ['sweep_id'] == 0) { |
110 | - $end_date = date ( "Y-m-d 23:59:59", strtotime ( $LastBillDate ) ); |
|
110 | + $end_date = date("Y-m-d 23:59:59", strtotime($LastBillDate)); |
|
111 | 111 | } else { |
112 | - $end_date = date ( "Y-m-" . $AccountData ['invoice_day'] . " 23:59:59", strtotime ( $LastBillDate . " + 1 month" ) ); |
|
113 | - $inv_date = date ( "Y-m-" . $AccountData ['invoice_day'] . " 23:59:59", strtotime ( $LastBillDate ) ); |
|
112 | + $end_date = date("Y-m-".$AccountData ['invoice_day']." 23:59:59", strtotime($LastBillDate." + 1 month")); |
|
113 | + $inv_date = date("Y-m-".$AccountData ['invoice_day']." 23:59:59", strtotime($LastBillDate)); |
|
114 | 114 | /* |
115 | 115 | * if(strtotime($inv_date) > strtotime(date("Y-m-d 23:59:59",strtotime($this->currentdate)))){ |
116 | 116 | * $end_date = $inv_date; |
117 | 117 | * } |
118 | 118 | */ |
119 | 119 | } |
120 | - $this->process_DID_charges ( $AccountData, $LastBillDate, $this->currentdate, 0, $this->currentdate, true ); |
|
120 | + $this->process_DID_charges($AccountData, $LastBillDate, $this->currentdate, 0, $this->currentdate, true); |
|
121 | 121 | break; |
122 | 122 | } |
123 | 123 | } |
@@ -126,52 +126,52 @@ discard block |
||
126 | 126 | */ |
127 | 127 | function ProcessDailyCharges($ManualFlag = false, $ChargeID = 0) { |
128 | 128 | if ($ManualFlag) { |
129 | - $ChargeData = $this->get_table_data ( "*", "charges", array ( |
|
129 | + $ChargeData = $this->get_table_data("*", "charges", array( |
|
130 | 130 | "id" => $ChargeID |
131 | - ) ); |
|
131 | + )); |
|
132 | 132 | } else { |
133 | - $ChargeData = $this->get_table_data ( "*", "charges", array ( |
|
133 | + $ChargeData = $this->get_table_data("*", "charges", array( |
|
134 | 134 | "sweep_id" => "0" |
135 | - ) ); |
|
135 | + )); |
|
136 | 136 | } |
137 | - if ($ChargeData && ! empty ( $ChargeData )) { |
|
138 | - foreach ( $ChargeData as $ChargeKey => $chargeValue ) { |
|
139 | - $AccountCharges = $this->Get_account_charges ( $chargeValue, $this->currentdate, true ); |
|
140 | - if ($AccountCharges->num_rows () > 0) { |
|
141 | - $AccountCharges = $AccountCharges->result_array (); |
|
142 | - foreach ( $AccountCharges as $AccChargeValue ) { |
|
137 | + if ($ChargeData && ! empty ($ChargeData)) { |
|
138 | + foreach ($ChargeData as $ChargeKey => $chargeValue) { |
|
139 | + $AccountCharges = $this->Get_account_charges($chargeValue, $this->currentdate, true); |
|
140 | + if ($AccountCharges->num_rows() > 0) { |
|
141 | + $AccountCharges = $AccountCharges->result_array(); |
|
142 | + foreach ($AccountCharges as $AccChargeValue) { |
|
143 | 143 | if ($AccChargeValue ['charge_upto'] == '0000-00-00 00:00:00') { |
144 | 144 | $AccChargeValue ['charge_upto'] = $AccChargeValue ['assign_date']; |
145 | 145 | } |
146 | 146 | $last_invoice_date = false; |
147 | - $AccountData = $this->get_table_data ( "*", "accounts", array ( |
|
147 | + $AccountData = $this->get_table_data("*", "accounts", array( |
|
148 | 148 | "id" => $AccChargeValue ['accountid'] |
149 | - ) ); |
|
149 | + )); |
|
150 | 150 | $AccountData = $AccountData [0]; |
151 | 151 | $AccountData ['sweep_id'] = $chargeValue ["sweep_id"]; |
152 | - $itemArr = $this->Build_ItemArr ( $chargeValue ['description'], $chargeValue ['id'], "SUBCHRG", $chargeValue ["sweep_id"], $AccChargeValue ['assign_date'], $AccChargeValue ['charge_upto'], $this->currentdate ); |
|
152 | + $itemArr = $this->Build_ItemArr($chargeValue ['description'], $chargeValue ['id'], "SUBCHRG", $chargeValue ["sweep_id"], $AccChargeValue ['assign_date'], $AccChargeValue ['charge_upto'], $this->currentdate); |
|
153 | 153 | |
154 | 154 | if ($AccountData ["posttoexternal"] == 0) { |
155 | 155 | $ChargeData ['charge_upto'] = $AccChargeValue ['charge_upto']; |
156 | 156 | $ChargeData ['charge'] = $chargeValue ['charge']; |
157 | - $last_invoice_date = $this->process_prepaid_customer ( $AccountData, $itemArr, $ChargeData, $this->currentdate ); |
|
157 | + $last_invoice_date = $this->process_prepaid_customer($AccountData, $itemArr, $ChargeData, $this->currentdate); |
|
158 | 158 | } else { |
159 | - $last_invoice_date = $this->calculate_charges ( $AccountData, 0, $itemArr, $chargeValue ["charge"], $AccChargeValue ['charge_upto'], $this->currentdate, $chargeValue ["pro_rate"] ); |
|
159 | + $last_invoice_date = $this->calculate_charges($AccountData, 0, $itemArr, $chargeValue ["charge"], $AccChargeValue ['charge_upto'], $this->currentdate, $chargeValue ["pro_rate"]); |
|
160 | 160 | } |
161 | 161 | // update last billing date to appropreate field. |
162 | 162 | if ($last_invoice_date) { |
163 | - $this->db->update ( "charge_to_account", array ( |
|
163 | + $this->db->update("charge_to_account", array( |
|
164 | 164 | "charge_upto" => $last_invoice_date |
165 | - ), array ( |
|
165 | + ), array( |
|
166 | 166 | "charge_id" => $chargeValue ["id"], |
167 | 167 | "accountid" => $AccountData ["id"] |
168 | - ) ); |
|
168 | + )); |
|
169 | 169 | } |
170 | 170 | } |
171 | 171 | } |
172 | 172 | } |
173 | 173 | } |
174 | - if (! $ManualFlag) { |
|
174 | + if ( ! $ManualFlag) { |
|
175 | 175 | exit (); |
176 | 176 | } |
177 | 177 | } |
@@ -185,45 +185,45 @@ discard block |
||
185 | 185 | } |
186 | 186 | |
187 | 187 | // Get account charges. |
188 | - $AccountCharges = $this->Get_account_charges ( $AccountData, $NowDate ); |
|
189 | - if ($AccountCharges->num_rows () > 0) { |
|
190 | - $AccountCharges = $AccountCharges->result_array (); |
|
188 | + $AccountCharges = $this->Get_account_charges($AccountData, $NowDate); |
|
189 | + if ($AccountCharges->num_rows() > 0) { |
|
190 | + $AccountCharges = $AccountCharges->result_array(); |
|
191 | 191 | |
192 | - foreach ( $AccountCharges as $AccChargeValue ) { |
|
192 | + foreach ($AccountCharges as $AccChargeValue) { |
|
193 | 193 | if ($this->Error_flag) { |
194 | 194 | echo "<pre>"; |
195 | - print_r ( $AccChargeValue ); |
|
195 | + print_r($AccChargeValue); |
|
196 | 196 | } |
197 | 197 | // Get information from database of active charges. |
198 | - $ChargeData = $this->get_table_data ( "*", "charges", array ( |
|
198 | + $ChargeData = $this->get_table_data("*", "charges", array( |
|
199 | 199 | "id" => $AccChargeValue ['charge_id'], |
200 | 200 | "status" => "0" |
201 | - ) ); |
|
202 | - if ($ChargeData && ! empty ( $ChargeData )) { |
|
201 | + )); |
|
202 | + if ($ChargeData && ! empty ($ChargeData)) { |
|
203 | 203 | $ChargeData = $ChargeData [0]; |
204 | 204 | if ($AccChargeValue ['charge_upto'] == '0000-00-00 00:00:00') { |
205 | 205 | $AccChargeValue ['charge_upto'] = $AccChargeValue ['assign_date']; |
206 | 206 | } |
207 | 207 | // build an array for further process. |
208 | - $itemArr = $this->Build_ItemArr ( $ChargeData ['description'], $ChargeData ['id'], "SUBCHRG", $ChargeData ["sweep_id"], $AccChargeValue ['assign_date'], $AccChargeValue ['charge_upto'], $NowDate ); |
|
208 | + $itemArr = $this->Build_ItemArr($ChargeData ['description'], $ChargeData ['id'], "SUBCHRG", $ChargeData ["sweep_id"], $AccChargeValue ['assign_date'], $AccChargeValue ['charge_upto'], $NowDate); |
|
209 | 209 | // Check account type is postpaid or prepaid. |
210 | 210 | if ($AccountData ["posttoexternal"] == 0) { |
211 | 211 | $ChargeData ['charge_upto'] = $AccChargeValue ['charge_upto']; |
212 | 212 | $ChargeData ['charge'] = $ChargeData ['charge']; |
213 | 213 | // If account is prepaid then process it using this method. |
214 | - $last_invoice_date = $this->process_prepaid_customer ( $AccountData, $itemArr, $ChargeData, $NowDate ); |
|
214 | + $last_invoice_date = $this->process_prepaid_customer($AccountData, $itemArr, $ChargeData, $NowDate); |
|
215 | 215 | } else { |
216 | 216 | // If account type is postpaid. |
217 | - $last_invoice_date = $this->calculate_charges ( $AccountData, $InvocieID, $itemArr, $ChargeData ["charge"], $StartDate, $EndDate, $ChargeData ["pro_rate"] ); |
|
217 | + $last_invoice_date = $this->calculate_charges($AccountData, $InvocieID, $itemArr, $ChargeData ["charge"], $StartDate, $EndDate, $ChargeData ["pro_rate"]); |
|
218 | 218 | } |
219 | 219 | // update last billing date to appropreate field. |
220 | 220 | if ($last_invoice_date) { |
221 | - $this->db->update ( "charge_to_account", array ( |
|
221 | + $this->db->update("charge_to_account", array( |
|
222 | 222 | "charge_upto" => $last_invoice_date |
223 | - ), array ( |
|
223 | + ), array( |
|
224 | 224 | "charge_id" => $ChargeData ["id"], |
225 | 225 | "accountid" => $AccountData ["id"] |
226 | - ) ); |
|
226 | + )); |
|
227 | 227 | } |
228 | 228 | } |
229 | 229 | } |
@@ -240,44 +240,44 @@ discard block |
||
240 | 240 | echo ":::::::::::::::::::::::: DIDs BILLING START ::::::::::::::::::::::::\n"; |
241 | 241 | } |
242 | 242 | if ($ManualFlag) { |
243 | - $DIDsData = $this->get_table_data ( "*", "dids", array ( |
|
243 | + $DIDsData = $this->get_table_data("*", "dids", array( |
|
244 | 244 | "status" => "0", |
245 | 245 | "accountid " => $AccountData ["id"], |
246 | 246 | "id" => $AccountData ["DIDid"] |
247 | - ) ); |
|
247 | + )); |
|
248 | 248 | } else { |
249 | - $DIDsData = $this->get_table_data ( "*", "dids", array ( |
|
249 | + $DIDsData = $this->get_table_data("*", "dids", array( |
|
250 | 250 | "status" => "0", |
251 | 251 | "accountid " => $AccountData ["id"] |
252 | - ) ); |
|
252 | + )); |
|
253 | 253 | } |
254 | 254 | $AccountData ['sweep_id'] = '2'; |
255 | 255 | if ($DIDsData) { |
256 | - foreach ( $DIDsData as $DIDvalue ) { |
|
256 | + foreach ($DIDsData as $DIDvalue) { |
|
257 | 257 | if ($DIDvalue ['charge_upto'] == '0000-00-00 00:00:00') { |
258 | 258 | $DIDvalue ['charge_upto'] = $DIDvalue ['assign_date']; |
259 | 259 | } |
260 | 260 | //ASTPP_DID_monthly_billing_issue |
261 | - $next_invoice_date = date("Y-m-d H:i:s",strtotime($DIDvalue ['charge_upto']." + 1 month")); |
|
262 | - $next_invoice_date = date("Y-m-d 23:59:59",strtotime($next_invoice_date." - 1 day")); |
|
263 | - if ($DIDvalue ['charge_upto'] != "0000-00-00 00:00:00" && strtotime ( $next_invoice_date ) < strtotime ( $EndDate )) { |
|
261 | + $next_invoice_date = date("Y-m-d H:i:s", strtotime($DIDvalue ['charge_upto']." + 1 month")); |
|
262 | + $next_invoice_date = date("Y-m-d 23:59:59", strtotime($next_invoice_date." - 1 day")); |
|
263 | + if ($DIDvalue ['charge_upto'] != "0000-00-00 00:00:00" && strtotime($next_invoice_date) < strtotime($EndDate)) { |
|
264 | 264 | //END |
265 | - $itemArr = $this->Build_ItemArr ( $DIDvalue ['number'], $DIDvalue ['id'], "DIDCHRG", "2", $DIDvalue ['assign_date'], $DIDvalue ['charge_upto'], $NowDate ); |
|
265 | + $itemArr = $this->Build_ItemArr($DIDvalue ['number'], $DIDvalue ['id'], "DIDCHRG", "2", $DIDvalue ['assign_date'], $DIDvalue ['charge_upto'], $NowDate); |
|
266 | 266 | if ($DIDvalue ['parent_id'] > 0) { |
267 | 267 | $ParentID = $DIDvalue ['parent_id']; |
268 | 268 | // If DID purchase by reseller then do reseller billing. |
269 | - while ( $ParentID != 0 ) { |
|
269 | + while ($ParentID != 0) { |
|
270 | 270 | if ($this->Error_flag) { |
271 | - echo ":::::::::::::::::::::::: Reseller DIDs BILLING START " . $ParentID . "::::::::::::::::::::::::\n"; |
|
271 | + echo ":::::::::::::::::::::::: Reseller DIDs BILLING START ".$ParentID."::::::::::::::::::::::::\n"; |
|
272 | 272 | } |
273 | 273 | // Get Reseller Account Details |
274 | - $reseller_dids = $this->get_table_data ( "*", "reseller_pricing", array ( |
|
274 | + $reseller_dids = $this->get_table_data("*", "reseller_pricing", array( |
|
275 | 275 | "reseller_id" => $ParentID, |
276 | 276 | "did_id" => $DIDvalue ["id"] |
277 | - ) ); |
|
278 | - $Reseller_Account_Data = $this->get_table_data ( "*", "accounts", array ( |
|
277 | + )); |
|
278 | + $Reseller_Account_Data = $this->get_table_data("*", "accounts", array( |
|
279 | 279 | "id" => $ParentID |
280 | - ) ); |
|
280 | + )); |
|
281 | 281 | $Reseller_Account_Data = $Reseller_Account_Data ['0']; |
282 | 282 | $Reseller_Account_Data ['sweep_id'] = '2'; |
283 | 283 | $reseller_dids = $reseller_dids [0]; |
@@ -285,19 +285,19 @@ discard block |
||
285 | 285 | if ($AccountData ["posttoexternal"] == 0) { |
286 | 286 | $ChargeData ['charge_upto'] = $DIDvalue ['charge_upto']; |
287 | 287 | $ChargeData ['charge'] = $DIDvalue ['monthlycost']; |
288 | - $last_invoice_date = $this->process_prepaid_customer ( $AccountData, $itemArr, $ChargeData, $NowDate ); |
|
288 | + $last_invoice_date = $this->process_prepaid_customer($AccountData, $itemArr, $ChargeData, $NowDate); |
|
289 | 289 | } else { |
290 | 290 | // Apply charges to Resellers. |
291 | - $last_invoice_date = $this->calculate_charges ( $Reseller_Account_Data, $InvocieID, $itemArr, $reseller_dids ["monthlycost"], $StartDate, $EndDate, "1" ); |
|
291 | + $last_invoice_date = $this->calculate_charges($Reseller_Account_Data, $InvocieID, $itemArr, $reseller_dids ["monthlycost"], $StartDate, $EndDate, "1"); |
|
292 | 292 | } |
293 | 293 | // Update last billing date for users DID. |
294 | 294 | if ($last_invoice_date) |
295 | - $this->db->update ( "reseller_pricing", array ( |
|
295 | + $this->db->update("reseller_pricing", array( |
|
296 | 296 | "charge_upto" => $last_invoice_date |
297 | - ), array ( |
|
297 | + ), array( |
|
298 | 298 | "did_id" => $DIDvalue ["id"], |
299 | 299 | "reseller_id" => $Reseller_Account_Data ["id"] |
300 | - ) ); |
|
300 | + )); |
|
301 | 301 | |
302 | 302 | $ParentID = $reseller_dids ['parent_id']; |
303 | 303 | if ($this->Error_flag) { |
@@ -306,15 +306,15 @@ discard block |
||
306 | 306 | } |
307 | 307 | } |
308 | 308 | // Apply charges for DID usage. |
309 | - $last_invoice_date = $this->calculate_charges ( $AccountData, $InvocieID, $itemArr, $DIDvalue ["monthlycost"], $StartDate, $EndDate, "1" ); |
|
309 | + $last_invoice_date = $this->calculate_charges($AccountData, $InvocieID, $itemArr, $DIDvalue ["monthlycost"], $StartDate, $EndDate, "1"); |
|
310 | 310 | if ($last_invoice_date) |
311 | 311 | // Update last billing date for users DID. |
312 | - $this->db->update ( "dids", array ( |
|
312 | + $this->db->update("dids", array( |
|
313 | 313 | "charge_upto" => $last_invoice_date |
314 | - ), array ( |
|
314 | + ), array( |
|
315 | 315 | "id" => $DIDvalue ["id"], |
316 | 316 | "accountid" => $AccountData ["id"] |
317 | - ) ); |
|
317 | + )); |
|
318 | 318 | } |
319 | 319 | } |
320 | 320 | } |
@@ -325,27 +325,27 @@ discard block |
||
325 | 325 | function Get_Date_Range_Array($billing_cycle, $itemArr, $StartDate, $EndDate) { |
326 | 326 | $last_invoice_date = $itemArr ['LastBillDate']; |
327 | 327 | |
328 | - $DateRangArr = array (); |
|
329 | - while ( strtotime ( date ( "Y-m-d", strtotime ( $last_invoice_date ) ) ) < strtotime ( date ( "Y-m-d", strtotime ( $EndDate . " -1 day" ) ) ) ) { |
|
328 | + $DateRangArr = array(); |
|
329 | + while (strtotime(date("Y-m-d", strtotime($last_invoice_date))) < strtotime(date("Y-m-d", strtotime($EndDate." -1 day")))) { |
|
330 | 330 | $startdate = $last_invoice_date; |
331 | 331 | $temp_last_date = $last_invoice_date; |
332 | - $last_invoice_date = date ( "Y-m-d 23:59:59", strtotime ( "+" . $billing_cycle, strtotime ( $last_invoice_date ) ) ); |
|
333 | - if (strtotime ( $last_invoice_date ) > strtotime ( $EndDate )) { |
|
332 | + $last_invoice_date = date("Y-m-d 23:59:59", strtotime("+".$billing_cycle, strtotime($last_invoice_date))); |
|
333 | + if (strtotime($last_invoice_date) > strtotime($EndDate)) { |
|
334 | 334 | $last_invoice_date = $EndDate; |
335 | 335 | } |
336 | 336 | |
337 | 337 | if ($this->Error_flag) { |
338 | - echo "Method : calculate_charges ::::::::::::::" . $startdate . " ::::::::::::::" . $last_invoice_date . "\n"; |
|
338 | + echo "Method : calculate_charges ::::::::::::::".$startdate." ::::::::::::::".$last_invoice_date."\n"; |
|
339 | 339 | } |
340 | 340 | // check if billing cycle is daily then set date for the same day. |
341 | 341 | if ($billing_cycle == "1 day") { |
342 | - $DateRangArr [] = array ( |
|
343 | - "StartDate" => date ( "Y-m-d 00:00:01", strtotime ( $startdate ) ), |
|
342 | + $DateRangArr [] = array( |
|
343 | + "StartDate" => date("Y-m-d 00:00:01", strtotime($startdate)), |
|
344 | 344 | "EndDate" => $temp_last_date |
345 | 345 | ); |
346 | 346 | } else { |
347 | - $DateRangArr [] = array ( |
|
348 | - "StartDate" => date ( "Y-m-d 00:00:01", strtotime ( $startdate ) ), |
|
347 | + $DateRangArr [] = array( |
|
348 | + "StartDate" => date("Y-m-d 00:00:01", strtotime($startdate)), |
|
349 | 349 | "EndDate" => $last_invoice_date |
350 | 350 | ); |
351 | 351 | } |
@@ -357,36 +357,36 @@ discard block |
||
357 | 357 | function calculate_charges($AccountData, $InvocieID, $itemArr, $Charge, $StartDate, $EndDate, $pro_rate = "1") { |
358 | 358 | if ($this->Error_flag) { |
359 | 359 | echo "<pre> :::::::::::::::::::::::: Item Array :::::::::::::::::::::::: \n"; |
360 | - print_r ( $itemArr ); |
|
360 | + print_r($itemArr); |
|
361 | 361 | } |
362 | 362 | |
363 | 363 | $billing_cycle = ($itemArr ['BillCycle'] == "0") ? "1 day" : "1 month"; |
364 | 364 | $last_invoice_date = $itemArr ['LastBillDate']; |
365 | 365 | |
366 | 366 | // get array between start and end date based on the billing cycle. |
367 | - $DateRangArr = $this->Get_Date_Range_Array ( $billing_cycle, $itemArr, $StartDate, $EndDate ); |
|
368 | - if (! empty ( $DateRangArr )) { |
|
367 | + $DateRangArr = $this->Get_Date_Range_Array($billing_cycle, $itemArr, $StartDate, $EndDate); |
|
368 | + if ( ! empty ($DateRangArr)) { |
|
369 | 369 | if ($this->Error_flag) { |
370 | 370 | echo "<pre> :::::::: Date Range Array :::::::: \n"; |
371 | - print_r ( $DateRangArr ); |
|
371 | + print_r($DateRangArr); |
|
372 | 372 | } |
373 | 373 | $daylen = 60 * 60 * 24; |
374 | - foreach ( $DateRangArr as $DateValue ) { |
|
374 | + foreach ($DateRangArr as $DateValue) { |
|
375 | 375 | |
376 | 376 | $last_invoice_date = $DateValue ['EndDate']; |
377 | - $start_date_str_time = strtotime ( $DateValue ['StartDate'] ); |
|
378 | - $end_date_str_time = strtotime ( $DateValue ['EndDate'] ); |
|
377 | + $start_date_str_time = strtotime($DateValue ['StartDate']); |
|
378 | + $end_date_str_time = strtotime($DateValue ['EndDate']); |
|
379 | 379 | |
380 | - $Temp_End_Date = new DateTime ( gmdate ( "Y-m-d H:i:s", strtotime ( "+1 second", strtotime ( $DateValue ['EndDate'] ) ) ) ); |
|
381 | - $Temp_Start_Date = new DateTime ( $DateValue ['StartDate'] ); |
|
382 | - $diff = $Temp_End_Date->diff ( $Temp_Start_Date ); |
|
380 | + $Temp_End_Date = new DateTime(gmdate("Y-m-d H:i:s", strtotime("+1 second", strtotime($DateValue ['EndDate'])))); |
|
381 | + $Temp_Start_Date = new DateTime($DateValue ['StartDate']); |
|
382 | + $diff = $Temp_End_Date->diff($Temp_Start_Date); |
|
383 | 383 | |
384 | 384 | $hours = $diff->h; |
385 | 385 | $hours = $hours + ($diff->days * 24); |
386 | 386 | |
387 | 387 | $days_diff = 0; |
388 | - $month = (($diff->format ( '%y' ) * 12) + $diff->format ( '%m' )); |
|
389 | - $total_num_of_day = cal_days_in_month ( CAL_GREGORIAN, date ( 'm', $start_date_str_time ), date ( 'Y', $start_date_str_time ) ); |
|
388 | + $month = (($diff->format('%y') * 12) + $diff->format('%m')); |
|
389 | + $total_num_of_day = cal_days_in_month(CAL_GREGORIAN, date('m', $start_date_str_time), date('Y', $start_date_str_time)); |
|
390 | 390 | |
391 | 391 | // default we assing product charge to temp charges for the billing. |
392 | 392 | $temp_charge = $Charge; |
@@ -397,20 +397,20 @@ discard block |
||
397 | 397 | } else { |
398 | 398 | // If bill cycle is monthly and prorate is enable then we charge to customer based on usage day. |
399 | 399 | if ($itemArr ['BillCycle'] == "2" && $pro_rate == "0") { |
400 | - $days_diff = floor ( ($end_date_str_time - $start_date_str_time) / $daylen ); |
|
400 | + $days_diff = floor(($end_date_str_time - $start_date_str_time) / $daylen); |
|
401 | 401 | $charge_per_day = ($Charge / $total_num_of_day); |
402 | 402 | $temp_charge = ($charge_per_day * $days_diff); |
403 | 403 | if ($this->Error_flag) { |
404 | - echo "Actual Charge : " . $Charge . " Charge Per Day : " . $charge_per_day . " Charge for Range : " . $temp_charge . "\n"; |
|
404 | + echo "Actual Charge : ".$Charge." Charge Per Day : ".$charge_per_day." Charge for Range : ".$temp_charge."\n"; |
|
405 | 405 | } |
406 | 406 | } |
407 | 407 | } |
408 | 408 | if ($this->Error_flag) { |
409 | - echo "<pre> Month difference between the date : " . $month . " Days are " . $days_diff . " Total No Of Days " . $total_num_of_day . "\n"; |
|
409 | + echo "<pre> Month difference between the date : ".$month." Days are ".$days_diff." Total No Of Days ".$total_num_of_day."\n"; |
|
410 | 410 | } |
411 | 411 | // If product charges more then 0 then we log entries in database. |
412 | 412 | if ($temp_charge > 0) { |
413 | - $this->Manage_invoice_item ( $AccountData, $InvocieID, $itemArr, $temp_charge, $DateValue ['StartDate'], $DateValue ['EndDate'], $EndDate ); |
|
413 | + $this->Manage_invoice_item($AccountData, $InvocieID, $itemArr, $temp_charge, $DateValue ['StartDate'], $DateValue ['EndDate'], $EndDate); |
|
414 | 414 | } |
415 | 415 | } |
416 | 416 | } |
@@ -420,7 +420,7 @@ discard block |
||
420 | 420 | |
421 | 421 | // Manage invoice detail data for postpaid and prepaid customers. |
422 | 422 | function Manage_invoice_item($AccountData, $InvocieID, $itemArr, $charge, $ItemStartDate, $ItemEndDate, $InvoiceEndDate) { |
423 | - $AccountData ["balance"] = $this->common->get_field_name ( 'balance', 'accounts', $AccountData ['id'] ); |
|
423 | + $AccountData ["balance"] = $this->common->get_field_name('balance', 'accounts', $AccountData ['id']); |
|
424 | 424 | $Balance = ($AccountData ["credit_limit"] - $AccountData ["balance"]); |
425 | 425 | |
426 | 426 | // If account type is prepaid then we generate receitp and manage data. |
@@ -428,15 +428,15 @@ discard block |
||
428 | 428 | // Do code for prepaid customers. |
429 | 429 | $Balance = $AccountData ["balance"]; |
430 | 430 | |
431 | - $InvoiceConf = $this->common->Get_Invoice_configuration ( $AccountData ); |
|
432 | - $last_invoice_ID = $this->common->get_invoice_date ( "invoiceid", "", $AccountData ['reseller_id'] ); |
|
431 | + $InvoiceConf = $this->common->Get_Invoice_configuration($AccountData); |
|
432 | + $last_invoice_ID = $this->common->get_invoice_date("invoiceid", "", $AccountData ['reseller_id']); |
|
433 | 433 | if ($last_invoice_ID && $last_invoice_ID > 0) { |
434 | 434 | $last_invoice_ID = ($last_invoice_ID + 1); |
435 | 435 | } else { |
436 | 436 | $last_invoice_ID = $InvoiceConf ['invoice_start_from']; |
437 | 437 | } |
438 | - $DueDate = date ( "Y-m-d 23:59:59", strtotime ( $this->currentdate . " +" . $InvoiceConf ['interval'] . " days" ) ); |
|
439 | - $InvoiceData = array ( |
|
438 | + $DueDate = date("Y-m-d 23:59:59", strtotime($this->currentdate." +".$InvoiceConf ['interval']." days")); |
|
439 | + $InvoiceData = array( |
|
440 | 440 | "accountid" => $AccountData ['id'], |
441 | 441 | "invoice_prefix" => $InvoiceConf ['invoice_prefix'], |
442 | 442 | "invoiceid" => $last_invoice_ID, |
@@ -452,8 +452,8 @@ discard block |
||
452 | 452 | "type" => "R" |
453 | 453 | ); |
454 | 454 | |
455 | - $this->db->insert ( "invoices", $InvoiceData ); |
|
456 | - $InvocieID = $this->db->insert_id (); |
|
455 | + $this->db->insert("invoices", $InvoiceData); |
|
456 | + $InvocieID = $this->db->insert_id(); |
|
457 | 457 | } else { |
458 | 458 | // Balance calculation for postpaid customers. |
459 | 459 | $Balance = ($AccountData ["credit_limit"] - $AccountData ["balance"]); |
@@ -461,18 +461,18 @@ discard block |
||
461 | 461 | // Update account balance. |
462 | 462 | if ($charge > 0) { |
463 | 463 | if ($AccountData ["posttoexternal"] == 0) { |
464 | - $this->db->set ( 'balance', "(balance - " . $charge . ")", FALSE ); |
|
464 | + $this->db->set('balance', "(balance - ".$charge.")", FALSE); |
|
465 | 465 | } else { |
466 | - $this->db->set ( 'balance', "(balance + " . $charge . ")", FALSE ); |
|
466 | + $this->db->set('balance', "(balance + ".$charge.")", FALSE); |
|
467 | 467 | } |
468 | - $this->db->where ( 'id', $AccountData ["id"] ); |
|
469 | - $this->db->update ( "accounts" ); |
|
468 | + $this->db->where('id', $AccountData ["id"]); |
|
469 | + $this->db->update("accounts"); |
|
470 | 470 | } |
471 | 471 | // Log detail entries of invoice item in invoice item table. |
472 | - $InvoiceItemArr = array ( |
|
472 | + $InvoiceItemArr = array( |
|
473 | 473 | "accountid" => $AccountData ["id"], |
474 | 474 | "reseller_id" => $AccountData ["reseller_id"], |
475 | - "description" => trim ( $itemArr ["Description"] . "-" . $ItemStartDate . " to " . $ItemEndDate ), |
|
475 | + "description" => trim($itemArr ["Description"]."-".$ItemStartDate." to ".$ItemEndDate), |
|
476 | 476 | "item_id" => $itemArr ["ItemID"], |
477 | 477 | "debit" => $charge, |
478 | 478 | "invoiceid" => $InvocieID, |
@@ -483,38 +483,38 @@ discard block |
||
483 | 483 | ); |
484 | 484 | if ($this->Error_flag) { |
485 | 485 | echo "<pre> ::::::::::: Invoice Detail Array ::::::::::: \n"; |
486 | - print_r ( $InvoiceItemArr ); |
|
486 | + print_r($InvoiceItemArr); |
|
487 | 487 | } |
488 | - $this->db->insert ( "invoice_details", $InvoiceItemArr ); |
|
488 | + $this->db->insert("invoice_details", $InvoiceItemArr); |
|
489 | 489 | |
490 | 490 | // Suppose account is prepaid then process account taxes and set total of invoice. |
491 | 491 | if ($AccountData ["posttoexternal"] == 0) { |
492 | 492 | if ($charge) { |
493 | - $sort_order = $this->common_model->apply_invoice_taxes ( $InvocieID, $AccountData, $ItemEndDate ); |
|
493 | + $sort_order = $this->common_model->apply_invoice_taxes($InvocieID, $AccountData, $ItemEndDate); |
|
494 | 494 | } |
495 | - $InvoiceTotal = $this->SetInvoiceTotal ( $InvocieID ); |
|
495 | + $InvoiceTotal = $this->SetInvoiceTotal($InvocieID); |
|
496 | 496 | } |
497 | 497 | } |
498 | 498 | // Set invoice total |
499 | 499 | function SetInvoiceTotal($InvocieID) { |
500 | - $query = $this->db_model->getSelect ( "SUM(debit) as total", "invoice_details", array ( |
|
500 | + $query = $this->db_model->getSelect("SUM(debit) as total", "invoice_details", array( |
|
501 | 501 | "invoiceid" => $InvocieID, |
502 | 502 | "item_type <>" => "FREECALL" |
503 | - ) ); |
|
504 | - $query = $query->result_array (); |
|
503 | + )); |
|
504 | + $query = $query->result_array(); |
|
505 | 505 | $TotalAmt = $query ["0"] ["total"]; |
506 | 506 | |
507 | 507 | if ($this->Error_flag) { |
508 | - echo "<pre> ::::::::::: Invoice Total ::::::::::: " . $TotalAmt . "\n"; |
|
508 | + echo "<pre> ::::::::::: Invoice Total ::::::::::: ".$TotalAmt."\n"; |
|
509 | 509 | } |
510 | 510 | |
511 | - $updateArr = array ( |
|
511 | + $updateArr = array( |
|
512 | 512 | "amount" => $TotalAmt |
513 | 513 | ); |
514 | - $this->db->where ( array ( |
|
514 | + $this->db->where(array( |
|
515 | 515 | "id" => $InvocieID |
516 | - ) ); |
|
517 | - $this->db->update ( "invoices", $updateArr ); |
|
516 | + )); |
|
517 | + $this->db->update("invoices", $updateArr); |
|
518 | 518 | |
519 | 519 | return true; |
520 | 520 | } |
@@ -523,15 +523,15 @@ discard block |
||
523 | 523 | // $InvocieID = $this->Generate_Receipt(); |
524 | 524 | $billing_cycle = ($itemArr ['BillCycle'] == "0") ? "1 day" : "1 month"; |
525 | 525 | $ItemStartDate = $ChargeData ['charge_upto']; |
526 | - $ItemEndDate = date ( "Y-m-d 23:59:59", strtotime ( $ChargeData ['charge_upto'] . " + " . $billing_cycle ) ); |
|
527 | - $this->Manage_invoice_item ( $AccountData, '0', $itemArr, $ChargeData ["charge"], $ItemStartDate, $ItemEndDate, $NowDate ); |
|
526 | + $ItemEndDate = date("Y-m-d 23:59:59", strtotime($ChargeData ['charge_upto']." + ".$billing_cycle)); |
|
527 | + $this->Manage_invoice_item($AccountData, '0', $itemArr, $ChargeData ["charge"], $ItemStartDate, $ItemEndDate, $NowDate); |
|
528 | 528 | |
529 | 529 | return $ItemEndDate; |
530 | 530 | } |
531 | 531 | function get_table_data($select, $table, $where) { |
532 | - $query = $this->db_model->getSelect ( $select, $table, $where ); |
|
532 | + $query = $this->db_model->getSelect($select, $table, $where); |
|
533 | 533 | if ($query->num_rows > 0) { |
534 | - $query_result = $query->result_array (); |
|
534 | + $query_result = $query->result_array(); |
|
535 | 535 | return $query_result; |
536 | 536 | } else { |
537 | 537 | return false; |
@@ -539,20 +539,20 @@ discard block |
||
539 | 539 | } |
540 | 540 | function Get_account_charges($AccountData, $NowDate, $flag = false) { |
541 | 541 | if ($flag) { |
542 | - $this->db->where ( 'charge_id', $AccountData ['id'] ); |
|
542 | + $this->db->where('charge_id', $AccountData ['id']); |
|
543 | 543 | } else { |
544 | - $this->db->where ( 'accountid', $AccountData ['id'] ); |
|
544 | + $this->db->where('accountid', $AccountData ['id']); |
|
545 | 545 | } |
546 | - $this->db->where ( "(charge_upto ='0000-00-00 00:00:00' OR charge_upto <='" . $NowDate . "')" ); |
|
547 | - $this->db->select ( '*' ); |
|
548 | - $data = $this->db->get ( 'charge_to_account' ); |
|
546 | + $this->db->where("(charge_upto ='0000-00-00 00:00:00' OR charge_upto <='".$NowDate."')"); |
|
547 | + $this->db->select('*'); |
|
548 | + $data = $this->db->get('charge_to_account'); |
|
549 | 549 | // echo $this->db->last_query(); exit; |
550 | 550 | return $data; |
551 | 551 | } |
552 | 552 | |
553 | 553 | // Build an array for different services. |
554 | 554 | function Build_ItemArr($description, $ItemID, $Type, $Cycle, $AssignDate, $BillDate, $NowDate) { |
555 | - $ItemArr = array ( |
|
555 | + $ItemArr = array( |
|
556 | 556 | 'Description' => $description, |
557 | 557 | "ItemID" => $ItemID, |
558 | 558 | "Type" => $Type, |
@@ -291,13 +291,14 @@ discard block |
||
291 | 291 | $last_invoice_date = $this->calculate_charges ( $Reseller_Account_Data, $InvocieID, $itemArr, $reseller_dids ["monthlycost"], $StartDate, $EndDate, "1" ); |
292 | 292 | } |
293 | 293 | // Update last billing date for users DID. |
294 | - if ($last_invoice_date) |
|
295 | - $this->db->update ( "reseller_pricing", array ( |
|
294 | + if ($last_invoice_date) { |
|
295 | + $this->db->update ( "reseller_pricing", array ( |
|
296 | 296 | "charge_upto" => $last_invoice_date |
297 | 297 | ), array ( |
298 | 298 | "did_id" => $DIDvalue ["id"], |
299 | 299 | "reseller_id" => $Reseller_Account_Data ["id"] |
300 | 300 | ) ); |
301 | + } |
|
301 | 302 | |
302 | 303 | $ParentID = $reseller_dids ['parent_id']; |
303 | 304 | if ($this->Error_flag) { |
@@ -307,14 +308,15 @@ discard block |
||
307 | 308 | } |
308 | 309 | // Apply charges for DID usage. |
309 | 310 | $last_invoice_date = $this->calculate_charges ( $AccountData, $InvocieID, $itemArr, $DIDvalue ["monthlycost"], $StartDate, $EndDate, "1" ); |
310 | - if ($last_invoice_date) |
|
311 | - // Update last billing date for users DID. |
|
311 | + if ($last_invoice_date) { |
|
312 | + // Update last billing date for users DID. |
|
312 | 313 | $this->db->update ( "dids", array ( |
313 | 314 | "charge_upto" => $last_invoice_date |
314 | 315 | ), array ( |
315 | 316 | "id" => $DIDvalue ["id"], |
316 | 317 | "accountid" => $AccountData ["id"] |
317 | 318 | ) ); |
319 | + } |
|
318 | 320 | } |
319 | 321 | } |
320 | 322 | } |
@@ -128,6 +128,11 @@ discard block |
||
128 | 128 | /* |
129 | 129 | * Process daily invoices. |
130 | 130 | */ |
131 | + |
|
132 | + /** |
|
133 | + * @param string $StartDate |
|
134 | + * @param string $EndDate |
|
135 | + */ |
|
131 | 136 | function Generate_Daily_Invoice($AccountData, $StartDate, $EndDate) { |
132 | 137 | if ($this->Error_flag) { |
133 | 138 | // Print Start date and End Date |
@@ -172,6 +177,11 @@ discard block |
||
172 | 177 | /* |
173 | 178 | * Process monthly invoices. |
174 | 179 | */ |
180 | + |
|
181 | + /** |
|
182 | + * @param string $StartDate |
|
183 | + * @param string $EndDate |
|
184 | + */ |
|
175 | 185 | function Generate_Monthly_Invoice($AccountData, $StartDate, $EndDate) { |
176 | 186 | if ($this->Error_flag) { |
177 | 187 | // Print Start date and End Date |
@@ -267,6 +277,10 @@ discard block |
||
267 | 277 | /* |
268 | 278 | * Process subscription and other charges like DIDs etc... |
269 | 279 | */ |
280 | + |
|
281 | + /** |
|
282 | + * @param string $NowDate |
|
283 | + */ |
|
270 | 284 | function ProcessCharges($AccountData, $StartDate, $EndDate, $InvocieID, $NowDate) { |
271 | 285 | if ($this->Error_flag) { |
272 | 286 | $this->PrintLogger ( "CHARGES CALCULATION PROCESS START" ); |
@@ -384,6 +398,11 @@ discard block |
||
384 | 398 | /* |
385 | 399 | * Send an email notification methid which log the invoice email notification in mail details table. |
386 | 400 | */ |
401 | + |
|
402 | + /** |
|
403 | + * @param string $FilePath |
|
404 | + * @param string $Filenm |
|
405 | + */ |
|
387 | 406 | function send_email_notification($FilePath, $Filenm, $AccountData, $invoice_conf, $invData) { |
388 | 407 | $TemplateData = array (); |
389 | 408 | $where = array ( |
@@ -27,28 +27,28 @@ discard block |
||
27 | 27 | public $CurrentDate = ""; |
28 | 28 | public $fp = ""; |
29 | 29 | function __construct() { |
30 | - parent::__construct (); |
|
31 | - $this->load->model ( "db_model" ); |
|
32 | - $this->load->library ( "astpp/common" ); |
|
30 | + parent::__construct(); |
|
31 | + $this->load->model("db_model"); |
|
32 | + $this->load->library("astpp/common"); |
|
33 | 33 | // $this->load->library('html2pdf'); |
34 | - ini_set ( "memory_limit", "2048M" ); |
|
35 | - ini_set ( "max_execution_time", "259200" ); |
|
36 | - $this->get_system_config (); |
|
34 | + ini_set("memory_limit", "2048M"); |
|
35 | + ini_set("max_execution_time", "259200"); |
|
36 | + $this->get_system_config(); |
|
37 | 37 | |
38 | - $this->fp = fopen ( "/var/log/astpp/astpp-invoice.log", "a+" ); |
|
38 | + $this->fp = fopen("/var/log/astpp/astpp-invoice.log", "a+"); |
|
39 | 39 | |
40 | 40 | // Set custom current date to generate invoice for specific date. |
41 | - $this->CurrentDate = gmdate ( "Y-m-d H:i:s" ); |
|
41 | + $this->CurrentDate = gmdate("Y-m-d H:i:s"); |
|
42 | 42 | // $this->CurrentDate = "2017-05-10 00:00:01"; |
43 | 43 | } |
44 | 44 | /* |
45 | 45 | * Function to get system configuration array. |
46 | 46 | */ |
47 | 47 | function get_system_config() { |
48 | - $query = $this->db->get ( "system" ); |
|
49 | - $config = array (); |
|
50 | - $result = $query->result_array (); |
|
51 | - foreach ( $result as $row ) { |
|
48 | + $query = $this->db->get("system"); |
|
49 | + $config = array(); |
|
50 | + $result = $query->result_array(); |
|
51 | + foreach ($result as $row) { |
|
52 | 52 | $config [$row ['name']] = $row ['value']; |
53 | 53 | } |
54 | 54 | self::$global_config ['system_config'] = $config; |
@@ -57,9 +57,9 @@ discard block |
||
57 | 57 | * Get last invoice date so script will start Invoice generation from that date. |
58 | 58 | */ |
59 | 59 | function GetLastInvoiceDate($AccountData) { |
60 | - $last_invoice_date = $this->common->get_invoice_date ( "to_date", $AccountData ["id"], $AccountData ['reseller_id'], "to_date" ); |
|
60 | + $last_invoice_date = $this->common->get_invoice_date("to_date", $AccountData ["id"], $AccountData ['reseller_id'], "to_date"); |
|
61 | 61 | $last_invoice_date = ($last_invoice_date) ? $last_invoice_date : $AccountData ['creation']; |
62 | - $last_invoice_date = date ( "Y-m-d 00:00:01", strtotime ( $last_invoice_date ) ); |
|
62 | + $last_invoice_date = date("Y-m-d 00:00:01", strtotime($last_invoice_date)); |
|
63 | 63 | return $last_invoice_date; |
64 | 64 | } |
65 | 65 | /* |
@@ -67,46 +67,46 @@ discard block |
||
67 | 67 | */ |
68 | 68 | function GenerateInvoice() { |
69 | 69 | if ($this->Error_flag) { |
70 | - $this->PrintLogger ( "::::: INVOICE PROCESS START ::::: \n" ); |
|
71 | - $this->PrintLogger ( ":::::" . gmdate ( "Y-m-d H:i:s" ) . ":::::\n" ); |
|
70 | + $this->PrintLogger("::::: INVOICE PROCESS START ::::: \n"); |
|
71 | + $this->PrintLogger(":::::".gmdate("Y-m-d H:i:s").":::::\n"); |
|
72 | 72 | } |
73 | 73 | |
74 | - $where = array ( |
|
74 | + $where = array( |
|
75 | 75 | "posttoexternal" => 1, |
76 | 76 | "deleted" => "0", |
77 | 77 | "status" => "0" |
78 | 78 | ); |
79 | - $query = $this->db_model->getSelect ( "*", "accounts", $where ); |
|
79 | + $query = $this->db_model->getSelect("*", "accounts", $where); |
|
80 | 80 | if ($query->num_rows > 0) { |
81 | - $account_data = $query->result_array (); |
|
82 | - foreach ( $account_data as $data_key => $AccountData ) { |
|
83 | - $StartDate = $this->GetLastInvoiceDate ( $AccountData ); |
|
84 | - $EndDate = gmdate ( "Y-m-d" ) . " 23:59:59"; |
|
81 | + $account_data = $query->result_array(); |
|
82 | + foreach ($account_data as $data_key => $AccountData) { |
|
83 | + $StartDate = $this->GetLastInvoiceDate($AccountData); |
|
84 | + $EndDate = gmdate("Y-m-d")." 23:59:59"; |
|
85 | 85 | |
86 | - $AccountData ['sweep_id'] = ( int ) $AccountData ['sweep_id']; |
|
86 | + $AccountData ['sweep_id'] = (int)$AccountData ['sweep_id']; |
|
87 | 87 | |
88 | 88 | switch ($AccountData ['sweep_id']) { |
89 | 89 | /* |
90 | 90 | * Invoice process for Daily customers. |
91 | 91 | */ |
92 | 92 | case 0 : |
93 | - if (Strtotime ( $StartDate ) > strtotime ( $this->CurrentDate )) { |
|
94 | - $StartDate = date ( "Y-m-d 00:00:01", strtotime ( $this->CurrentDate . " - 1 days" ) ); |
|
93 | + if (Strtotime($StartDate) > strtotime($this->CurrentDate)) { |
|
94 | + $StartDate = date("Y-m-d 00:00:01", strtotime($this->CurrentDate." - 1 days")); |
|
95 | 95 | } |
96 | - $EndDate = date ( "Y-m-d 23:59:59", strtotime ( $this->CurrentDate . " - 1 days" ) ); |
|
97 | - $this->Generate_Daily_Invoice ( $AccountData, $StartDate, $EndDate ); |
|
96 | + $EndDate = date("Y-m-d 23:59:59", strtotime($this->CurrentDate." - 1 days")); |
|
97 | + $this->Generate_Daily_Invoice($AccountData, $StartDate, $EndDate); |
|
98 | 98 | break; |
99 | 99 | /* |
100 | 100 | * Invoice process for monthly customers. |
101 | 101 | */ |
102 | 102 | case 2 : |
103 | 103 | // $AccountData['invoice_day'] = "01"; |
104 | - if (gmdate ( "d", strtotime ( "-1 days" ) ) == $AccountData ['invoice_day']) { |
|
105 | - $EndDate = date ( "Y-m-" . $AccountData ['invoice_day'] . " 23:59:59", strtotime ( $StartDate . " + 1 month" ) ); |
|
106 | - if (Strtotime ( $EndDate ) > strtotime ( $this->CurrentDate )) { |
|
104 | + if (gmdate("d", strtotime("-1 days")) == $AccountData ['invoice_day']) { |
|
105 | + $EndDate = date("Y-m-".$AccountData ['invoice_day']." 23:59:59", strtotime($StartDate." + 1 month")); |
|
106 | + if (Strtotime($EndDate) > strtotime($this->CurrentDate)) { |
|
107 | 107 | $EndDate = $this->CurrentDate; |
108 | 108 | } |
109 | - $this->Generate_Monthly_Invoice ( $AccountData, $StartDate, $EndDate ); |
|
109 | + $this->Generate_Monthly_Invoice($AccountData, $StartDate, $EndDate); |
|
110 | 110 | } |
111 | 111 | break; |
112 | 112 | } |
@@ -114,14 +114,14 @@ discard block |
||
114 | 114 | /* |
115 | 115 | * Send an email notification after invoice generation. |
116 | 116 | */ |
117 | - $screen_path = getcwd () . "/cron"; |
|
118 | - $screen_filename = "Email_Broadcast_" . strtotime ( 'now' ); |
|
119 | - $command = "cd " . $screen_path . " && /usr/bin/screen -d -m -S $screen_filename php cron.php BroadcastEmail"; |
|
117 | + $screen_path = getcwd()."/cron"; |
|
118 | + $screen_filename = "Email_Broadcast_".strtotime('now'); |
|
119 | + $command = "cd ".$screen_path." && /usr/bin/screen -d -m -S $screen_filename php cron.php BroadcastEmail"; |
|
120 | 120 | // exec($command); |
121 | 121 | } |
122 | 122 | if ($this->Error_flag) { |
123 | - $this->PrintLogger ( "INVOICE PROCESS END" ); |
|
124 | - $this->PrintLogger ( gmdate ( "Y-m-d H:i:s" ) ); |
|
123 | + $this->PrintLogger("INVOICE PROCESS END"); |
|
124 | + $this->PrintLogger(gmdate("Y-m-d H:i:s")); |
|
125 | 125 | } |
126 | 126 | exit (); |
127 | 127 | } |
@@ -131,21 +131,21 @@ discard block |
||
131 | 131 | function Generate_Daily_Invoice($AccountData, $StartDate, $EndDate) { |
132 | 132 | if ($this->Error_flag) { |
133 | 133 | // Print Start date and End Date |
134 | - $this->PrintLogger ( "PROCESS DIALY INVOICE" ); |
|
135 | - $this->PrintLogger ( "START DATE : " . $StartDate . " ::::: END DATE" . $EndDate ); |
|
134 | + $this->PrintLogger("PROCESS DIALY INVOICE"); |
|
135 | + $this->PrintLogger("START DATE : ".$StartDate." ::::: END DATE".$EndDate); |
|
136 | 136 | } |
137 | 137 | // Get invoice configuration for white lable invoice gneration. |
138 | - $InvoiceConf = $this->common->Get_Invoice_configuration ( $AccountData ); |
|
138 | + $InvoiceConf = $this->common->Get_Invoice_configuration($AccountData); |
|
139 | 139 | |
140 | 140 | if ($this->Error_flag) { |
141 | 141 | // Print Invoice Configuration which we are going to use in invoice. |
142 | - $this->PrintLogger ( "GET INVOICE CONFIGURATION" ); |
|
142 | + $this->PrintLogger("GET INVOICE CONFIGURATION"); |
|
143 | 143 | } |
144 | 144 | |
145 | 145 | // Get last generated invoice for admin or reseller |
146 | - $last_invoice_ID = $this->common->get_invoice_date ( "invoiceid", "", $AccountData ['reseller_id'] ); |
|
146 | + $last_invoice_ID = $this->common->get_invoice_date("invoiceid", "", $AccountData ['reseller_id']); |
|
147 | 147 | if ($this->Error_flag) { |
148 | - $this->PrintLogger ( "GET INVOICE DATE " . $last_invoice_ID ); |
|
148 | + $this->PrintLogger("GET INVOICE DATE ".$last_invoice_ID); |
|
149 | 149 | } |
150 | 150 | |
151 | 151 | if ($last_invoice_ID && $last_invoice_ID > 0) { |
@@ -155,19 +155,19 @@ discard block |
||
155 | 155 | } |
156 | 156 | |
157 | 157 | // Generate one blank invoice |
158 | - $InvocieID = $this->create_invoice ( $AccountData, $StartDate, $EndDate, $last_invoice_ID, $InvoiceConf ); |
|
158 | + $InvocieID = $this->create_invoice($AccountData, $StartDate, $EndDate, $last_invoice_ID, $InvoiceConf); |
|
159 | 159 | // Process other charges and subscription. |
160 | - $this->ProcessCharges ( $AccountData, $StartDate, $EndDate, $InvocieID, $this->CurrentDate ); |
|
160 | + $this->ProcessCharges($AccountData, $StartDate, $EndDate, $InvocieID, $this->CurrentDate); |
|
161 | 161 | |
162 | 162 | // Set invoice subtotal. |
163 | - $SubTotal = $this->GetSubTotal ( $AccountData, $StartDate, $EndDate, $InvocieID ); |
|
163 | + $SubTotal = $this->GetSubTotal($AccountData, $StartDate, $EndDate, $InvocieID); |
|
164 | 164 | if ($SubTotal) { |
165 | 165 | // Apply taxes on invoice amount. |
166 | - $sort_order = $this->common_model->apply_invoice_taxes ( $InvocieID, $AccountData, $EndDate ); |
|
166 | + $sort_order = $this->common_model->apply_invoice_taxes($InvocieID, $AccountData, $EndDate); |
|
167 | 167 | } |
168 | 168 | // set invoice total |
169 | - $InvoiceTotal = $this->SetInvoiceTotal ( $AccountData, $InvocieID ); |
|
170 | - $this->download_invoice ( $InvocieID, $AccountData, $InvoiceConf ); |
|
169 | + $InvoiceTotal = $this->SetInvoiceTotal($AccountData, $InvocieID); |
|
170 | + $this->download_invoice($InvocieID, $AccountData, $InvoiceConf); |
|
171 | 171 | } |
172 | 172 | /* |
173 | 173 | * Process monthly invoices. |
@@ -175,19 +175,19 @@ discard block |
||
175 | 175 | function Generate_Monthly_Invoice($AccountData, $StartDate, $EndDate) { |
176 | 176 | if ($this->Error_flag) { |
177 | 177 | // Print Start date and End Date |
178 | - $this->PrintLogger ( "PROCESS DIALY INVOICE" ); |
|
179 | - $this->PrintLogger ( "START DATE : " . $StartDate . " ::::: END DATE" . $EndDate ); |
|
178 | + $this->PrintLogger("PROCESS DIALY INVOICE"); |
|
179 | + $this->PrintLogger("START DATE : ".$StartDate." ::::: END DATE".$EndDate); |
|
180 | 180 | } |
181 | 181 | // Get invoice configuration for white lable invoice gneration. |
182 | - $InvoiceConf = $this->common->Get_Invoice_configuration ( $AccountData ); |
|
182 | + $InvoiceConf = $this->common->Get_Invoice_configuration($AccountData); |
|
183 | 183 | |
184 | 184 | if ($this->Error_flag) { |
185 | 185 | // Print Invoice Configuration which we are going to use in invoice. |
186 | - $this->PrintLogger ( $InvoiceConf ); |
|
186 | + $this->PrintLogger($InvoiceConf); |
|
187 | 187 | } |
188 | 188 | |
189 | 189 | // Get last generated invoice for admin or reseller |
190 | - $last_invoice_ID = $this->common->get_invoice_date ( "invoiceid", "", $AccountData ['reseller_id'] ); |
|
190 | + $last_invoice_ID = $this->common->get_invoice_date("invoiceid", "", $AccountData ['reseller_id']); |
|
191 | 191 | if ($last_invoice_ID && $last_invoice_ID > 0) { |
192 | 192 | $last_invoice_ID = ($last_invoice_ID + 1); |
193 | 193 | } else { |
@@ -195,18 +195,18 @@ discard block |
||
195 | 195 | } |
196 | 196 | |
197 | 197 | // Generate one blank invoice |
198 | - $InvocieID = $this->create_invoice ( $AccountData, $StartDate, $EndDate, $last_invoice_ID, $InvoiceConf ); |
|
198 | + $InvocieID = $this->create_invoice($AccountData, $StartDate, $EndDate, $last_invoice_ID, $InvoiceConf); |
|
199 | 199 | // Process other charges and subscription. |
200 | - $this->ProcessCharges ( $AccountData, $StartDate, $EndDate, $InvocieID, $this->CurrentDate ); |
|
200 | + $this->ProcessCharges($AccountData, $StartDate, $EndDate, $InvocieID, $this->CurrentDate); |
|
201 | 201 | // Set invoice subtotal. |
202 | - $SubTotal = $this->GetSubTotal ( $AccountData, $StartDate, $EndDate, $InvocieID ); |
|
202 | + $SubTotal = $this->GetSubTotal($AccountData, $StartDate, $EndDate, $InvocieID); |
|
203 | 203 | if ($SubTotal) { |
204 | 204 | // Apply taxes on invoice amount. |
205 | - $sort_order = $this->common_model->apply_invoice_taxes ( $InvocieID, $AccountData, $EndDate ); |
|
205 | + $sort_order = $this->common_model->apply_invoice_taxes($InvocieID, $AccountData, $EndDate); |
|
206 | 206 | } |
207 | 207 | // set invoice total |
208 | - $InvoiceTotal = $this->SetInvoiceTotal ( $AccountData, $InvocieID ); |
|
209 | - $this->download_invoice ( $InvocieID, $AccountData, $InvoiceConf ); |
|
208 | + $InvoiceTotal = $this->SetInvoiceTotal($AccountData, $InvocieID); |
|
209 | + $this->download_invoice($InvocieID, $AccountData, $InvoiceConf); |
|
210 | 210 | } |
211 | 211 | /* |
212 | 212 | * Create blank invoice at the starting of the process. |
@@ -215,9 +215,9 @@ discard block |
||
215 | 215 | |
216 | 216 | // set due date |
217 | 217 | if ($InvoiceConf ['interval'] > 0) { |
218 | - $DueDate = date ( "Y-m-d 23:59:59", strtotime ( $this->CurrentDate . " +" . $InvoiceConf ['interval'] . " days" ) ); |
|
218 | + $DueDate = date("Y-m-d 23:59:59", strtotime($this->CurrentDate." +".$InvoiceConf ['interval']." days")); |
|
219 | 219 | } else { |
220 | - $DueDate = date ( "Y-m-d 23:59:59", strtotime ( $this->CurrentDate . " +7 days" ) ); |
|
220 | + $DueDate = date("Y-m-d 23:59:59", strtotime($this->CurrentDate." +7 days")); |
|
221 | 221 | } |
222 | 222 | |
223 | 223 | $balance = ($AccountData ['credit_limit'] - $AccountData ['balance']); |
@@ -225,7 +225,7 @@ discard block |
||
225 | 225 | |
226 | 226 | // Automatic flag is use to manage the invoice generate with confirm mode or with out confirm mode. |
227 | 227 | if ($automatic_flag == 1) { |
228 | - $InvoiceData = array ( |
|
228 | + $InvoiceData = array( |
|
229 | 229 | "accountid" => $AccountData ['id'], |
230 | 230 | "invoice_prefix" => $InvoiceConf ['invoice_prefix'], |
231 | 231 | "invoiceid" => $last_invoice_ID, |
@@ -239,7 +239,7 @@ discard block |
||
239 | 239 | "balance" => $balance |
240 | 240 | ); |
241 | 241 | } else { |
242 | - $InvoiceData = array ( |
|
242 | + $InvoiceData = array( |
|
243 | 243 | "accountid" => $AccountData ['id'], |
244 | 244 | "invoice_prefix" => $InvoiceConf ['invoice_prefix'], |
245 | 245 | "invoiceid" => $last_invoice_ID, |
@@ -255,11 +255,11 @@ discard block |
||
255 | 255 | ); |
256 | 256 | } |
257 | 257 | if ($this->Error_flag) { |
258 | - $this->PrintLogger ( $InvoiceData ); |
|
258 | + $this->PrintLogger($InvoiceData); |
|
259 | 259 | } |
260 | 260 | // Generate insert entry for invoices. |
261 | - $this->db->insert ( "invoices", $InvoiceData ); |
|
262 | - $invoiceid = $this->db->insert_id (); |
|
261 | + $this->db->insert("invoices", $InvoiceData); |
|
262 | + $invoiceid = $this->db->insert_id(); |
|
263 | 263 | // Return last inserted id of invoice as a invocieid. |
264 | 264 | return $invoiceid; |
265 | 265 | } |
@@ -269,26 +269,26 @@ discard block |
||
269 | 269 | */ |
270 | 270 | function ProcessCharges($AccountData, $StartDate, $EndDate, $InvocieID, $NowDate) { |
271 | 271 | if ($this->Error_flag) { |
272 | - $this->PrintLogger ( "CHARGES CALCULATION PROCESS START" ); |
|
272 | + $this->PrintLogger("CHARGES CALCULATION PROCESS START"); |
|
273 | 273 | } |
274 | 274 | |
275 | 275 | // Assign invoice id to the post entries which is already inserted from the GUI and |
276 | - $inv_data_query = "update invoice_details SET invoiceid = '" . $InvocieID . "'"; |
|
277 | - $inv_data_query .= " where created_date >='" . $StartDate . "' AND created_date <= '" . $EndDate . "' AND invoiceid=0 AND item_type !='PAYMENT'"; |
|
278 | - $this->db->query ( $inv_data_query ); |
|
276 | + $inv_data_query = "update invoice_details SET invoiceid = '".$InvocieID."'"; |
|
277 | + $inv_data_query .= " where created_date >='".$StartDate."' AND created_date <= '".$EndDate."' AND invoiceid=0 AND item_type !='PAYMENT'"; |
|
278 | + $this->db->query($inv_data_query); |
|
279 | 279 | |
280 | 280 | // Reset current date for subscription billing. |
281 | - $NowDate = date ( "Y-m-d 23:59:59", strtotime ( $NowDate ) ); |
|
282 | - require_once (APPPATH . 'controllers/ProcessCharges.php'); |
|
283 | - $ProcessCharges = new ProcessCharges (); |
|
281 | + $NowDate = date("Y-m-d 23:59:59", strtotime($NowDate)); |
|
282 | + require_once (APPPATH.'controllers/ProcessCharges.php'); |
|
283 | + $ProcessCharges = new ProcessCharges(); |
|
284 | 284 | |
285 | 285 | // Process subscription charges for postpaid customers. |
286 | - $ProcessCharges->process_subscriptions ( $AccountData, $StartDate, $EndDate, $InvocieID, $NowDate ); |
|
286 | + $ProcessCharges->process_subscriptions($AccountData, $StartDate, $EndDate, $InvocieID, $NowDate); |
|
287 | 287 | // Process DID charges for postpaid customers. |
288 | - $ProcessCharges->process_DID_charges ( $AccountData, $StartDate, $EndDate, $InvocieID, $NowDate ); |
|
288 | + $ProcessCharges->process_DID_charges($AccountData, $StartDate, $EndDate, $InvocieID, $NowDate); |
|
289 | 289 | |
290 | 290 | if ($this->Error_flag) { |
291 | - $this->PrintLogger ( "CHARGES CALCULATION PROCESS END" ); |
|
291 | + $this->PrintLogger("CHARGES CALCULATION PROCESS END"); |
|
292 | 292 | } |
293 | 293 | } |
294 | 294 | /* |
@@ -298,38 +298,38 @@ discard block |
||
298 | 298 | $SubTotal = "0.0000"; |
299 | 299 | |
300 | 300 | // Generate CDRs entry for invoices in invoice detail table. |
301 | - $CDRqr = "select calltype,sum(debit) as debit from cdrs where accountid = " . $AccountData ['id'] . " AND callstart >='" . $StartDate . "' AND callstart <= '" . $EndDate . "' AND invoiceid=0 group by calltype"; |
|
302 | - $CDRdata = $this->db->query ( $CDRqr ); |
|
301 | + $CDRqr = "select calltype,sum(debit) as debit from cdrs where accountid = ".$AccountData ['id']." AND callstart >='".$StartDate."' AND callstart <= '".$EndDate."' AND invoiceid=0 group by calltype"; |
|
302 | + $CDRdata = $this->db->query($CDRqr); |
|
303 | 303 | if ($CDRdata->num_rows > 0) { |
304 | - $CDRdata = $CDRdata->result_array (); |
|
304 | + $CDRdata = $CDRdata->result_array(); |
|
305 | 305 | // echo '<pre>'; print_r($cdr_data); exit; |
306 | - foreach ( $CDRdata as $CDRvalue ) { |
|
307 | - $tempArr = array ( |
|
306 | + foreach ($CDRdata as $CDRvalue) { |
|
307 | + $tempArr = array( |
|
308 | 308 | "accountid" => $AccountData ['id'], |
309 | 309 | "reseller_id" => $AccountData ['reseller_id'], |
310 | 310 | "item_id" => "0", |
311 | - "description" => $CDRvalue ['calltype'] . " CALLS FOR PERIOD OF (" . $StartDate . " to " . $EndDate . ")", |
|
311 | + "description" => $CDRvalue ['calltype']." CALLS FOR PERIOD OF (".$StartDate." to ".$EndDate.")", |
|
312 | 312 | "debit" => $CDRvalue ['debit'], |
313 | 313 | "item_type" => $CDRvalue ['calltype'], |
314 | 314 | "created_date" => $this->CurrentDate, |
315 | 315 | "invoiceid" => $InvocieID |
316 | 316 | ); |
317 | 317 | if ($this->Error_flag) { |
318 | - $this->PrintLogger ( $tempArr ); |
|
318 | + $this->PrintLogger($tempArr); |
|
319 | 319 | } |
320 | - $this->db->insert ( "invoice_details", $tempArr ); |
|
320 | + $this->db->insert("invoice_details", $tempArr); |
|
321 | 321 | } |
322 | 322 | } |
323 | 323 | |
324 | 324 | // Get the subtotal. |
325 | - $Invoicequery = "select count(id) as count,sum(debit) as debit,sum(credit) as credit from invoice_details where accountid=" . $AccountData ['id'] . " AND invoiceid =" . $InvocieID . " AND item_type != 'FREECALL'"; |
|
326 | - $Invoicequery = $this->db->query ( $Invoicequery ); |
|
325 | + $Invoicequery = "select count(id) as count,sum(debit) as debit,sum(credit) as credit from invoice_details where accountid=".$AccountData ['id']." AND invoiceid =".$InvocieID." AND item_type != 'FREECALL'"; |
|
326 | + $Invoicequery = $this->db->query($Invoicequery); |
|
327 | 327 | if ($Invoicequery->num_rows > 0) { |
328 | - $InvData = $Invoicequery->result_array (); |
|
328 | + $InvData = $Invoicequery->result_array(); |
|
329 | 329 | if ($this->Error_flag) { |
330 | - $this->PrintLogger ( $InvData ); |
|
330 | + $this->PrintLogger($InvData); |
|
331 | 331 | } |
332 | - foreach ( $InvData as $totalvalue ) { |
|
332 | + foreach ($InvData as $totalvalue) { |
|
333 | 333 | if ($totalvalue ['count'] > 0) { |
334 | 334 | $SubTotal = ($totalvalue ['debit'] - $totalvalue ['credit']); |
335 | 335 | return $SubTotal; |
@@ -342,24 +342,24 @@ discard block |
||
342 | 342 | * Set invoice total by excluding FreeCalls. |
343 | 343 | */ |
344 | 344 | function SetInvoiceTotal($AccountData, $InvocieID) { |
345 | - $query = $this->db_model->getSelect ( "SUM(debit) as total", "invoice_details", array ( |
|
345 | + $query = $this->db_model->getSelect("SUM(debit) as total", "invoice_details", array( |
|
346 | 346 | "invoiceid" => $InvocieID, |
347 | 347 | "item_type <>" => "FREECALL" |
348 | - ) ); |
|
349 | - $query = $query->result_array (); |
|
348 | + )); |
|
349 | + $query = $query->result_array(); |
|
350 | 350 | $TotalAmt = $query ["0"] ["total"]; |
351 | 351 | |
352 | 352 | if ($this->Error_flag) { |
353 | - $this->PrintLogger ( "Invoice Total :::::" . $TotalAmt ); |
|
353 | + $this->PrintLogger("Invoice Total :::::".$TotalAmt); |
|
354 | 354 | } |
355 | 355 | |
356 | - $updateArr = array ( |
|
356 | + $updateArr = array( |
|
357 | 357 | "amount" => $TotalAmt |
358 | 358 | ); |
359 | - $this->db->where ( array ( |
|
359 | + $this->db->where(array( |
|
360 | 360 | "id" => $InvocieID |
361 | - ) ); |
|
362 | - $this->db->update ( "invoices", $updateArr ); |
|
361 | + )); |
|
362 | + $this->db->update("invoices", $updateArr); |
|
363 | 363 | |
364 | 364 | return true; |
365 | 365 | } |
@@ -367,17 +367,17 @@ discard block |
||
367 | 367 | * Invoice Download code which generate invoice PDF. |
368 | 368 | */ |
369 | 369 | function download_invoice($InvocieID, $AccountData, $InvoiceConf) { |
370 | - $InvoiceData = $this->db_model->getSelect ( "*", "invoices", array ( |
|
370 | + $InvoiceData = $this->db_model->getSelect("*", "invoices", array( |
|
371 | 371 | "id" => $InvocieID |
372 | - ) ); |
|
373 | - $InvoiceData = $InvoiceData->result_array (); |
|
372 | + )); |
|
373 | + $InvoiceData = $InvoiceData->result_array(); |
|
374 | 374 | $InvoiceData = $InvoiceData [0]; |
375 | - $FilePath = FCPATH . "invoices/" . $AccountData ["id"] . '/' . $InvoiceData ['invoice_prefix'] . "" . $InvoiceData ['invoiceid'] . "_invoice.pdf"; |
|
376 | - $Filenm = $InvoiceData ['invoice_prefix'] . "_" . $InvoiceData ['invoiceid'] . "_invoice.pdf"; |
|
375 | + $FilePath = FCPATH."invoices/".$AccountData ["id"].'/'.$InvoiceData ['invoice_prefix']."".$InvoiceData ['invoiceid']."_invoice.pdf"; |
|
376 | + $Filenm = $InvoiceData ['invoice_prefix']."_".$InvoiceData ['invoiceid']."_invoice.pdf"; |
|
377 | 377 | |
378 | - $this->common->get_invoice_template ( $InvoiceData, $AccountData, false, true ); |
|
378 | + $this->common->get_invoice_template($InvoiceData, $AccountData, false, true); |
|
379 | 379 | if ($InvoiceConf ['invoice_notification']) { |
380 | - $this->send_email_notification ( $FilePath, $Filenm, $AccountData, $InvoiceConf, $InvoiceData ); |
|
380 | + $this->send_email_notification($FilePath, $Filenm, $AccountData, $InvoiceConf, $InvoiceData); |
|
381 | 381 | } |
382 | 382 | } |
383 | 383 | |
@@ -385,30 +385,30 @@ discard block |
||
385 | 385 | * Send an email notification methid which log the invoice email notification in mail details table. |
386 | 386 | */ |
387 | 387 | function send_email_notification($FilePath, $Filenm, $AccountData, $invoice_conf, $invData) { |
388 | - $TemplateData = array (); |
|
389 | - $where = array ( |
|
388 | + $TemplateData = array(); |
|
389 | + $where = array( |
|
390 | 390 | 'name' => 'email_new_invoice' |
391 | 391 | ); |
392 | - $EmailTemplate = $this->db_model->getSelect ( "*", "default_templates", $where ); |
|
393 | - foreach ( $EmailTemplate->result_array () as $TemplateVal ) { |
|
392 | + $EmailTemplate = $this->db_model->getSelect("*", "default_templates", $where); |
|
393 | + foreach ($EmailTemplate->result_array() as $TemplateVal) { |
|
394 | 394 | $TemplateData = $TemplateVal; |
395 | - $TemplateData ['subject'] = str_replace ( '#NAME#', $AccountData ['first_name'] . " " . $AccountData ['last_name'], $TemplateData ['subject'] ); |
|
396 | - $TemplateData ['subject'] = str_replace ( '#INVOICE_NUMBER#', $invData ['invoice_prefix'] . $invData ['invoiceid'], $TemplateData ['subject'] ); |
|
397 | - $TemplateData ['template'] = str_replace ( '#NAME#', $AccountData ['first_name'] . " " . $AccountData ['last_name'], $TemplateData ['template'] ); |
|
398 | - $TemplateData ['template'] = str_replace ( '#INVOICE_NUMBER#', $invData ['invoice_prefix'] . $invData ['invoiceid'], $TemplateData ['template'] ); |
|
399 | - $TemplateData ['template'] = str_replace ( '#AMOUNT#', $invData ['amount'], $TemplateData ['template'] ); |
|
395 | + $TemplateData ['subject'] = str_replace('#NAME#', $AccountData ['first_name']." ".$AccountData ['last_name'], $TemplateData ['subject']); |
|
396 | + $TemplateData ['subject'] = str_replace('#INVOICE_NUMBER#', $invData ['invoice_prefix'].$invData ['invoiceid'], $TemplateData ['subject']); |
|
397 | + $TemplateData ['template'] = str_replace('#NAME#', $AccountData ['first_name']." ".$AccountData ['last_name'], $TemplateData ['template']); |
|
398 | + $TemplateData ['template'] = str_replace('#INVOICE_NUMBER#', $invData ['invoice_prefix'].$invData ['invoiceid'], $TemplateData ['template']); |
|
399 | + $TemplateData ['template'] = str_replace('#AMOUNT#', $invData ['amount'], $TemplateData ['template']); |
|
400 | 400 | |
401 | - $TemplateData ['template'] = str_replace ( "#COMPANY_EMAIL#", $invoice_conf ['emailaddress'], $TemplateData ['template'] ); |
|
402 | - $TemplateData ['template'] = str_replace ( "#COMPANY_NAME#", $invoice_conf ['company_name'], $TemplateData ['template'] ); |
|
403 | - $TemplateData ['template'] = str_replace ( "#COMPANY_WEBSITE#", $invoice_conf ['website'], $TemplateData ['template'] ); |
|
404 | - $TemplateData ['template'] = str_replace ( "#INVOICE_DATE#", $invData ['invoice_date'], $TemplateData ['template'] ); |
|
405 | - $TemplateData ['template'] = str_replace ( "#DUE_DATE#", $invData ['due_date'], $TemplateData ['template'] ); |
|
401 | + $TemplateData ['template'] = str_replace("#COMPANY_EMAIL#", $invoice_conf ['emailaddress'], $TemplateData ['template']); |
|
402 | + $TemplateData ['template'] = str_replace("#COMPANY_NAME#", $invoice_conf ['company_name'], $TemplateData ['template']); |
|
403 | + $TemplateData ['template'] = str_replace("#COMPANY_WEBSITE#", $invoice_conf ['website'], $TemplateData ['template']); |
|
404 | + $TemplateData ['template'] = str_replace("#INVOICE_DATE#", $invData ['invoice_date'], $TemplateData ['template']); |
|
405 | + $TemplateData ['template'] = str_replace("#DUE_DATE#", $invData ['due_date'], $TemplateData ['template']); |
|
406 | 406 | } |
407 | - $dir_path = getcwd () . "/attachments/"; |
|
408 | - $path = $dir_path . $Filenm; |
|
409 | - $command = "cp " . $FilePath . " " . $path; |
|
410 | - exec ( $command ); |
|
411 | - $email_array = array ( |
|
407 | + $dir_path = getcwd()."/attachments/"; |
|
408 | + $path = $dir_path.$Filenm; |
|
409 | + $command = "cp ".$FilePath." ".$path; |
|
410 | + exec($command); |
|
411 | + $email_array = array( |
|
412 | 412 | 'accountid' => $AccountData ['id'], |
413 | 413 | 'subject' => $TemplateData ['subject'], |
414 | 414 | 'body' => $TemplateData ['template'], |
@@ -419,22 +419,22 @@ discard block |
||
419 | 419 | 'template' => '' |
420 | 420 | ); |
421 | 421 | // echo "<pre>"; print_r($TemplateData); exit; |
422 | - $this->db->insert ( "mail_details", $email_array ); |
|
422 | + $this->db->insert("mail_details", $email_array); |
|
423 | 423 | } |
424 | 424 | function PrintLogger($Message) { |
425 | - if (is_array ( $Message )) { |
|
426 | - foreach ( $Message as $MessageKey => $MessageValue ) { |
|
427 | - if (is_array ( $MessageValue )) { |
|
428 | - foreach ( $MessageValue as $LogKey => $LogValue ) { |
|
429 | - fwrite ( $this->fp, "::::: " . $LogKey . " ::::: " . $LogValue . " :::::\n" ); |
|
425 | + if (is_array($Message)) { |
|
426 | + foreach ($Message as $MessageKey => $MessageValue) { |
|
427 | + if (is_array($MessageValue)) { |
|
428 | + foreach ($MessageValue as $LogKey => $LogValue) { |
|
429 | + fwrite($this->fp, "::::: ".$LogKey." ::::: ".$LogValue." :::::\n"); |
|
430 | 430 | } |
431 | 431 | } else { |
432 | - fwrite ( $this->fp, "::::: " . $MessageKey . " ::::: " . $MessageValue . " :::::\n" ); |
|
432 | + fwrite($this->fp, "::::: ".$MessageKey." ::::: ".$MessageValue." :::::\n"); |
|
433 | 433 | } |
434 | 434 | } |
435 | 435 | } else { |
436 | 436 | if ($this->Error_flag) { |
437 | - fwrite ( $this->fp, "::::: " . $Message . " :::::\n" ); |
|
437 | + fwrite($this->fp, "::::: ".$Message." :::::\n"); |
|
438 | 438 | } |
439 | 439 | } |
440 | 440 | } |
@@ -41,6 +41,11 @@ discard block |
||
41 | 41 | $this->process_DID_charges ( $account_val, gmdate ( "Y-m-d H:i:s" ), gmdate ( "Y-m-d H:i:s" ) ); |
42 | 42 | } |
43 | 43 | } |
44 | + |
|
45 | + /** |
|
46 | + * @param string $startdate |
|
47 | + * @param string $enddate |
|
48 | + */ |
|
44 | 49 | function process_subscriptions($accountinfo, $startdate, $enddate, $Manualflg = false) { |
45 | 50 | // Defined Original Sweep it for calculation start date for first time. |
46 | 51 | $accountinfo ['original_sweep_id'] = $accountinfo ['sweep_id']; |
@@ -107,6 +112,11 @@ discard block |
||
107 | 112 | } |
108 | 113 | } |
109 | 114 | } |
115 | + |
|
116 | + /** |
|
117 | + * @param string $startdate |
|
118 | + * @param string $enddate |
|
119 | + */ |
|
110 | 120 | function process_DID_charges($AccountDATA, $startdate, $enddate, $Manualflg = false) { |
111 | 121 | $dids_data = $this->get_table_data ( "*", "dids", array ( |
112 | 122 | "status" => "0", |
@@ -263,7 +273,8 @@ discard block |
||
263 | 273 | |
264 | 274 | /** |
265 | 275 | * |
266 | - * @param string $todate |
|
276 | + * @param string $todate |
|
277 | + * @param string $invoicedate |
|
267 | 278 | */ |
268 | 279 | function Manage_invoice_item($AccountData, $description, $item_id, $charge, $type, $fromdate, $todate, $invoicedate) { |
269 | 280 | $invoiceid = 0; |
@@ -22,23 +22,23 @@ discard block |
||
22 | 22 | // along with this program. If not, see <http://www.gnu.org/licenses/>. |
23 | 23 | // ############################################################################## |
24 | 24 | class UpdateBalance extends MX_Controller { |
25 | - public $account_arr = array (); |
|
25 | + public $account_arr = array(); |
|
26 | 26 | public $currentdate = ''; |
27 | 27 | function __construct() { |
28 | - parent::__construct (); |
|
29 | - $this->load->model ( "db_model" ); |
|
30 | - $this->load->model ( "common_model" ); |
|
31 | - $this->load->library ( "astpp/common" ); |
|
32 | - $this->currentdate = gmdate ( 'Y-m-d H:i:s' ); |
|
28 | + parent::__construct(); |
|
29 | + $this->load->model("db_model"); |
|
30 | + $this->load->model("common_model"); |
|
31 | + $this->load->library("astpp/common"); |
|
32 | + $this->currentdate = gmdate('Y-m-d H:i:s'); |
|
33 | 33 | } |
34 | 34 | function GetUpdateBalance() { |
35 | - $accounts_data = $this->get_table_data ( "*", "accounts", array ( |
|
35 | + $accounts_data = $this->get_table_data("*", "accounts", array( |
|
36 | 36 | "status" => "0", |
37 | 37 | "deleted" => "0" |
38 | - ) ); |
|
39 | - foreach ( $accounts_data as $account_val ) { |
|
40 | - $this->process_subscriptions ( $account_val, gmdate ( "Y-m-d H:i:s" ), gmdate ( "Y-m-d H:i:s" ) ); |
|
41 | - $this->process_DID_charges ( $account_val, gmdate ( "Y-m-d H:i:s" ), gmdate ( "Y-m-d H:i:s" ) ); |
|
38 | + )); |
|
39 | + foreach ($accounts_data as $account_val) { |
|
40 | + $this->process_subscriptions($account_val, gmdate("Y-m-d H:i:s"), gmdate("Y-m-d H:i:s")); |
|
41 | + $this->process_DID_charges($account_val, gmdate("Y-m-d H:i:s"), gmdate("Y-m-d H:i:s")); |
|
42 | 42 | } |
43 | 43 | } |
44 | 44 | function process_subscriptions($accountinfo, $startdate, $enddate, $Manualflg = false) { |
@@ -48,43 +48,43 @@ discard block |
||
48 | 48 | |
49 | 49 | // Check Charge is applied that is for first time or already calculated before |
50 | 50 | |
51 | - $where = "(charge_upto ='0000-00-00 00:00:00' OR charge_upto <='" . gmdate ( "Y-m-d H:i:s" ) . "')"; |
|
52 | - $this->db->where ( 'accountid', $accountinfo ['id'] ); |
|
53 | - $this->db->where ( $where ); |
|
54 | - $this->db->select ( '*' ); |
|
55 | - $account_charges = $this->db->get ( 'charge_to_account' ); |
|
56 | - if ($account_charges->num_rows () > 0) { |
|
57 | - $accountchargs = $account_charges->result_array (); |
|
51 | + $where = "(charge_upto ='0000-00-00 00:00:00' OR charge_upto <='".gmdate("Y-m-d H:i:s")."')"; |
|
52 | + $this->db->where('accountid', $accountinfo ['id']); |
|
53 | + $this->db->where($where); |
|
54 | + $this->db->select('*'); |
|
55 | + $account_charges = $this->db->get('charge_to_account'); |
|
56 | + if ($account_charges->num_rows() > 0) { |
|
57 | + $accountchargs = $account_charges->result_array(); |
|
58 | 58 | |
59 | - foreach ( $accountchargs as $accharges ) { |
|
59 | + foreach ($accountchargs as $accharges) { |
|
60 | 60 | // Get information from database of active charges. |
61 | - $charge_data = $this->get_table_data ( "*", "charges", array ( |
|
61 | + $charge_data = $this->get_table_data("*", "charges", array( |
|
62 | 62 | "id" => $accharges ['charge_id'], |
63 | 63 | "status" => "0" |
64 | - ) ); |
|
65 | - if ($charge_data && ! empty ( $charge_data )) { |
|
64 | + )); |
|
65 | + if ($charge_data && ! empty ($charge_data)) { |
|
66 | 66 | $charge_data = $charge_data [0]; |
67 | 67 | // Get Start Date of Charge |
68 | - $charge_upto = ($accharges ["charge_upto"] != "0000-00-00 00:00:00" && $accharges ["charge_upto"] != "") ? 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 | + $charge_upto = ($accharges ["charge_upto"] != "0000-00-00 00:00:00" && $accharges ["charge_upto"] != "") ? 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']) { |
74 | 74 | $accountinfo ['sweep_id'] = $charge_data ['sweep_id']; |
75 | 75 | } |
76 | 76 | // IF its already assigned before invoice start date then no need to applied same charge one more time |
77 | - if ($charge_upto != "0000-00-00 00:00:00" && $charge_upto != "" && strtotime ( $charge_upto ) < strtotime ( $enddate )) { |
|
78 | - $fromdate = gmdate ( "Y-m-d H:i:s", strtotime ( $charge_upto ) ); |
|
77 | + if ($charge_upto != "0000-00-00 00:00:00" && $charge_upto != "" && strtotime($charge_upto) < strtotime($enddate)) { |
|
78 | + $fromdate = gmdate("Y-m-d H:i:s", strtotime($charge_upto)); |
|
79 | 79 | if ($Manualflg) { |
80 | - $todate = gmdate ( "Y-m-d H:i:s", strtotime ( $enddate ) ); |
|
80 | + $todate = gmdate("Y-m-d H:i:s", strtotime($enddate)); |
|
81 | 81 | } else { |
82 | - $todate = gmdate ( "Y-m-d H:i:s", strtotime ( $charge_upto ) ); |
|
82 | + $todate = gmdate("Y-m-d H:i:s", strtotime($charge_upto)); |
|
83 | 83 | } |
84 | 84 | /* |
85 | 85 | * Add assign_date and charge_upto variable for calculation purpose. |
86 | 86 | */ |
87 | - $itemArr = array ( |
|
87 | + $itemArr = array( |
|
88 | 88 | 'description' => $charge_data ['description'], |
89 | 89 | 'item_id' => $charge_data ['id'], |
90 | 90 | "type" => "SUBCHRG", |
@@ -93,14 +93,14 @@ discard block |
||
93 | 93 | "charge_upto" => $accharges ['charge_upto'] |
94 | 94 | ); |
95 | 95 | // Add a new arguement ($accharges) which have all information of charges. |
96 | - $lastdate = $this->calculate_charges ( $accountinfo, $itemArr, $charge_data ["charge"], $fromdate, $todate, $charge_data ["pro_rate"] ); |
|
96 | + $lastdate = $this->calculate_charges($accountinfo, $itemArr, $charge_data ["charge"], $fromdate, $todate, $charge_data ["pro_rate"]); |
|
97 | 97 | if ($lastdate) { |
98 | - $this->db->update ( "charge_to_account", array ( |
|
98 | + $this->db->update("charge_to_account", array( |
|
99 | 99 | "charge_upto" => $lastdate |
100 | - ), array ( |
|
100 | + ), array( |
|
101 | 101 | "charge_id" => $charge_data ["id"], |
102 | 102 | "accountid" => $accountinfo ["id"] |
103 | - ) ); |
|
103 | + )); |
|
104 | 104 | } |
105 | 105 | } |
106 | 106 | } |
@@ -108,24 +108,24 @@ discard block |
||
108 | 108 | } |
109 | 109 | } |
110 | 110 | function process_DID_charges($AccountDATA, $startdate, $enddate, $Manualflg = false) { |
111 | - $dids_data = $this->get_table_data ( "*", "dids", array ( |
|
111 | + $dids_data = $this->get_table_data("*", "dids", array( |
|
112 | 112 | "status" => "0", |
113 | 113 | "accountid " => $AccountDATA ["id"] |
114 | - ) ); |
|
114 | + )); |
|
115 | 115 | $AccountDATA ['original_sweep_id'] = $AccountDATA ['sweep_id']; |
116 | 116 | $AccountDATA ['sweep_id'] = '2'; |
117 | 117 | if ($dids_data) { |
118 | - foreach ( $dids_data as $did_value ) { |
|
118 | + foreach ($dids_data as $did_value) { |
|
119 | 119 | $charge_upto = ($did_value ["charge_upto"] != "0000-00-00 00:00:00" && $did_value ["charge_upto"] != "") ? $did_value ["charge_upto"] : $did_value ["assign_date"]; |
120 | 120 | |
121 | - if ($charge_upto != "0000-00-00 00:00:00" && $charge_upto != "" && strtotime ( $charge_upto ) < strtotime ( $enddate )) { |
|
122 | - $fromdate = gmdate ( "Y-m-d H:i:s", strtotime ( $charge_upto ) ); |
|
121 | + if ($charge_upto != "0000-00-00 00:00:00" && $charge_upto != "" && strtotime($charge_upto) < strtotime($enddate)) { |
|
122 | + $fromdate = gmdate("Y-m-d H:i:s", strtotime($charge_upto)); |
|
123 | 123 | if ($Manualflg) { |
124 | - $todate = gmdate ( "Y-m-d H:i:s", strtotime ( $enddate ) ); |
|
124 | + $todate = gmdate("Y-m-d H:i:s", strtotime($enddate)); |
|
125 | 125 | } else { |
126 | - $todate = gmdate ( "Y-m-d H:i:s", strtotime ( $did_value ["upto_date"] ) ); |
|
126 | + $todate = gmdate("Y-m-d H:i:s", strtotime($did_value ["upto_date"])); |
|
127 | 127 | } |
128 | - $itemArr = array ( |
|
128 | + $itemArr = array( |
|
129 | 129 | 'description' => $did_value ['number'], |
130 | 130 | 'item_id' => $did_value ['id'], |
131 | 131 | "type" => "DIDCHRG", |
@@ -135,50 +135,50 @@ discard block |
||
135 | 135 | ); |
136 | 136 | if ($did_value ['parent_id'] > 0) { |
137 | 137 | $parent_id = $did_value ['parent_id']; |
138 | - while ( $parent_id != 0 ) { |
|
139 | - $reseller_dids = $this->get_table_data ( "*", "reseller_pricing", array ( |
|
138 | + while ($parent_id != 0) { |
|
139 | + $reseller_dids = $this->get_table_data("*", "reseller_pricing", array( |
|
140 | 140 | "reseller_id" => $parent_id, |
141 | 141 | "note" => $did_value ['number'] |
142 | - ) ); |
|
143 | - $reseller_acc_data = $this->get_table_data ( "*", "accounts", array ( |
|
142 | + )); |
|
143 | + $reseller_acc_data = $this->get_table_data("*", "accounts", array( |
|
144 | 144 | "id" => $parent_id |
145 | - ) ); |
|
145 | + )); |
|
146 | 146 | $reseller_acc_data = $reseller_acc_data ['0']; |
147 | 147 | $reseller_acc_data ['sweep_id'] = '2'; |
148 | 148 | $reseller_dids = $reseller_dids [0]; |
149 | 149 | if (($parent_id == $reseller_dids ['reseller_id'] && $did_value ['accountid'] > 0) || $reseller_dids ['parent_id'] == 0) { |
150 | 150 | // Apply charges to resellers customers. |
151 | - $lastdate = $this->calculate_charges ( $reseller_acc_data, $itemArr, $reseller_dids ["monthlycost"], $fromdate, $todate, "1" ); |
|
151 | + $lastdate = $this->calculate_charges($reseller_acc_data, $itemArr, $reseller_dids ["monthlycost"], $fromdate, $todate, "1"); |
|
152 | 152 | if ($lastdate) |
153 | - $this->db->update ( "reseller_pricing", array ( |
|
153 | + $this->db->update("reseller_pricing", array( |
|
154 | 154 | "charge_upto" => $lastdate |
155 | - ), array ( |
|
155 | + ), array( |
|
156 | 156 | "note" => $did_value ["number"], |
157 | 157 | "reseller_id" => $reseller_acc_data ["id"] |
158 | - ) ); |
|
158 | + )); |
|
159 | 159 | } else { |
160 | 160 | // Apply charges to Resellers. |
161 | - $lastdate = $this->calculate_charges ( $reseller_acc_data, $itemArr, $reseller_dids ["monthlycost"], $fromdate, $todate, "1" ); |
|
161 | + $lastdate = $this->calculate_charges($reseller_acc_data, $itemArr, $reseller_dids ["monthlycost"], $fromdate, $todate, "1"); |
|
162 | 162 | if ($lastdate) |
163 | - $this->db->update ( "reseller_pricing", array ( |
|
163 | + $this->db->update("reseller_pricing", array( |
|
164 | 164 | "charge_upto" => $lastdate |
165 | - ), array ( |
|
165 | + ), array( |
|
166 | 166 | "note" => $did_value ["number"], |
167 | 167 | "reseller_id" => $reseller_acc_data ["id"] |
168 | - ) ); |
|
168 | + )); |
|
169 | 169 | } |
170 | 170 | $parent_id = $reseller_dids ['parent_id']; |
171 | 171 | } |
172 | 172 | } |
173 | 173 | // else{ |
174 | - $lastdate = $this->calculate_charges ( $AccountDATA, $itemArr, $did_value ["monthlycost"], $fromdate, $todate, "1" ); |
|
174 | + $lastdate = $this->calculate_charges($AccountDATA, $itemArr, $did_value ["monthlycost"], $fromdate, $todate, "1"); |
|
175 | 175 | if ($lastdate) |
176 | - $this->db->update ( "dids", array ( |
|
176 | + $this->db->update("dids", array( |
|
177 | 177 | "charge_upto" => $lastdate |
178 | - ), array ( |
|
178 | + ), array( |
|
179 | 179 | "id" => $did_value ["id"], |
180 | 180 | "accountid" => $AccountDATA ["id"] |
181 | - ) ); |
|
181 | + )); |
|
182 | 182 | // } |
183 | 183 | } |
184 | 184 | } |
@@ -193,67 +193,67 @@ discard block |
||
193 | 193 | function calculate_charges($AccountDATA, $itemArr, $charge, $fromdate, $todate, $pro_rate = "1") { |
194 | 194 | $lastdate = false; |
195 | 195 | $billing_cycle = ($AccountDATA ['sweep_id'] == "0") ? "1 day" : "1 month"; |
196 | - $last_invoice_date = $this->common->get_invoice_date ( "invoice_date", $AccountDATA ['id'], $AccountDATA ['reseller_id'] ); |
|
196 | + $last_invoice_date = $this->common->get_invoice_date("invoice_date", $AccountDATA ['id'], $AccountDATA ['reseller_id']); |
|
197 | 197 | // Below variable gives date based on assign or creation or monthly user billing day |
198 | - $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'] ) ))); |
|
198 | + $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'])))); |
|
199 | 199 | $last_invoice_date = ($last_invoice_date <= $fromdate) ? $last_invoice_date : $fromdate; |
200 | - $Charges_date_range = array (); |
|
201 | - $prorate_array = array (); |
|
200 | + $Charges_date_range = array(); |
|
201 | + $prorate_array = array(); |
|
202 | 202 | $daylen = 60 * 60 * 24; |
203 | 203 | /* |
204 | 204 | * Get assign day and billing day for postpaid monthly user. |
205 | 205 | */ |
206 | - $assign_day = ($AccountDATA ['original_sweep_id'] == 2 && $AccountDATA ['posttoexternal'] == 1) ? gmdate ( "d", strtotime ( $itemArr ['assign_date'] ) ) : 0; |
|
206 | + $assign_day = ($AccountDATA ['original_sweep_id'] == 2 && $AccountDATA ['posttoexternal'] == 1) ? gmdate ("d", strtotime($itemArr ['assign_date'])) : 0; |
|
207 | 207 | $billing_day = ($AccountDATA ['original_sweep_id'] == 2 && $AccountDATA ['posttoexternal'] == 1) ? $AccountDATA ['invoice_day'] : 0; |
208 | 208 | // Create an array if charge not applied yet and invoice day is greater than assign_day |
209 | 209 | 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) { |
210 | - $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"] ) ) ) ) ); |
|
211 | - $prorate_array [] = array ( |
|
212 | - "start_date" => date ( "Y-m-d H:i:s", strtotime ( $itemArr ['assign_date'] ) ), |
|
210 | + $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"]))))); |
|
211 | + $prorate_array [] = array( |
|
212 | + "start_date" => date("Y-m-d H:i:s", strtotime($itemArr ['assign_date'])), |
|
213 | 213 | "end_date" => $last_invoice_date |
214 | 214 | ); |
215 | 215 | } |
216 | - while ( strtotime ( $last_invoice_date ) <= strtotime ( $todate ) ) { |
|
216 | + while (strtotime($last_invoice_date) <= strtotime($todate)) { |
|
217 | 217 | $startdate = $last_invoice_date; |
218 | - $last_invoice_date = gmdate ( "Y-m-d H:i:s", strtotime ( "+" . $billing_cycle, strtotime ( $last_invoice_date ) ) ); |
|
219 | - $Charges_date_range [] = array ( |
|
220 | - "start_date" => gmdate ( "Y-m-d H:i:s", strtotime ( "+1 Second", strtotime ( $startdate ) ) ), |
|
218 | + $last_invoice_date = gmdate("Y-m-d H:i:s", strtotime("+".$billing_cycle, strtotime($last_invoice_date))); |
|
219 | + $Charges_date_range [] = array( |
|
220 | + "start_date" => gmdate("Y-m-d H:i:s", strtotime("+1 Second", strtotime($startdate))), |
|
221 | 221 | "end_date" => $last_invoice_date |
222 | 222 | ); |
223 | 223 | } |
224 | - if (! empty ( $prorate_array )) { |
|
225 | - array_pop ( $Charges_date_range ); |
|
226 | - $Charges_date_range = array_merge ( $prorate_array, $Charges_date_range ); |
|
224 | + if ( ! empty ($prorate_array)) { |
|
225 | + array_pop($Charges_date_range); |
|
226 | + $Charges_date_range = array_merge($prorate_array, $Charges_date_range); |
|
227 | 227 | } |
228 | - if (! empty ( $Charges_date_range )) { |
|
229 | - foreach ( $Charges_date_range as $ChargeVal ) { |
|
228 | + if ( ! empty ($Charges_date_range)) { |
|
229 | + foreach ($Charges_date_range as $ChargeVal) { |
|
230 | 230 | if (($pro_rate == 0 && $itemArr ['cycle'] != 2) || (($billing_day <= $assign_day) && $pro_rate == 0 && $itemArr ['cycle'] == 2 && $AccountDATA ['original_sweep_id'] == 2)) { |
231 | - $ChargeVal ['end_date'] = gmdate ( "Y-m-d 23:59:59", strtotime ( "-1 Day", strtotime ( $ChargeVal ['end_date'] ) ) ); |
|
231 | + $ChargeVal ['end_date'] = gmdate("Y-m-d 23:59:59", strtotime("-1 Day", strtotime($ChargeVal ['end_date']))); |
|
232 | 232 | } |
233 | - if (! empty ( $itemArr ['charge_upto'] ) && empty ( $lastdate )) { |
|
233 | + if ( ! empty ($itemArr ['charge_upto']) && empty ($lastdate)) { |
|
234 | 234 | $start_date = ($itemArr ['charge_upto'] == '0000-00-00 00:00:00' && $AccountDATA ['sweep_id'] == 2) ? $itemArr ['assign_date'] : $ChargeVal ['start_date']; |
235 | 235 | } else { |
236 | - $start_date = (empty ( $lastdate )) ? $ChargeVal ['start_date'] : gmdate ( "Y-m-d H:i:s", strtotime ( "+1 second", strtotime ( $lastdate ) ) ); |
|
236 | + $start_date = (empty ($lastdate)) ? $ChargeVal ['start_date'] : gmdate("Y-m-d H:i:s", strtotime("+1 second", strtotime($lastdate))); |
|
237 | 237 | } |
238 | 238 | |
239 | - $lastdate = date ( "Y-m-d H:i:s", strtotime ( $ChargeVal ['end_date'] ) ); |
|
240 | - $end_date_str_time = strtotime ( "+1 Seconds", strtotime ( $lastdate ) ); |
|
241 | - $start_date_str_time = strtotime ( gmdate ( "Y-m-d 00:00:00", strtotime ( $start_date ) ) ); |
|
242 | - $temp_f_date = new DateTime ( gmdate ( "Y-m-d H:i:s", strtotime ( "+1 second", strtotime ( $lastdate ) ) ) ); |
|
243 | - $temp_t_date = new DateTime ( $start_date ); |
|
244 | - $diff = $temp_f_date->diff ( $temp_t_date ); |
|
245 | - $month = (($diff->format ( '%y' ) * 12) + $diff->format ( '%m' )); |
|
239 | + $lastdate = date("Y-m-d H:i:s", strtotime($ChargeVal ['end_date'])); |
|
240 | + $end_date_str_time = strtotime("+1 Seconds", strtotime($lastdate)); |
|
241 | + $start_date_str_time = strtotime(gmdate("Y-m-d 00:00:00", strtotime($start_date))); |
|
242 | + $temp_f_date = new DateTime(gmdate("Y-m-d H:i:s", strtotime("+1 second", strtotime($lastdate)))); |
|
243 | + $temp_t_date = new DateTime($start_date); |
|
244 | + $diff = $temp_f_date->diff($temp_t_date); |
|
245 | + $month = (($diff->format('%y') * 12) + $diff->format('%m')); |
|
246 | 246 | $temp_charge = $charge; |
247 | 247 | if (($month != "1" || $pro_rate == "0") && $itemArr ['cycle'] != '0') { |
248 | 248 | // Calculate Number of days in month from start date |
249 | - $total_num_of_day = cal_days_in_month ( CAL_GREGORIAN, date ( 'm', $start_date_str_time ), date ( 'Y', $start_date_str_time ) ); |
|
250 | - $days_diff = floor ( ($end_date_str_time - $start_date_str_time) / $daylen ); |
|
249 | + $total_num_of_day = cal_days_in_month(CAL_GREGORIAN, date('m', $start_date_str_time), date('Y', $start_date_str_time)); |
|
250 | + $days_diff = floor(($end_date_str_time - $start_date_str_time) / $daylen); |
|
251 | 251 | $chrg_per_day = ($charge / $total_num_of_day); |
252 | 252 | $temp_charge = ($chrg_per_day * $days_diff); |
253 | 253 | } |
254 | 254 | |
255 | - if (strtotime ( $ChargeVal ['start_date'] ) < strtotime ( $ChargeVal ['end_date'] )) { |
|
256 | - $this->Manage_invoice_item ( $AccountDATA, $itemArr ['description'], $itemArr ['item_id'], $temp_charge, $itemArr ['type'], $start_date, $lastdate, $todate ); |
|
255 | + if (strtotime($ChargeVal ['start_date']) < strtotime($ChargeVal ['end_date'])) { |
|
256 | + $this->Manage_invoice_item($AccountDATA, $itemArr ['description'], $itemArr ['item_id'], $temp_charge, $itemArr ['type'], $start_date, $lastdate, $todate); |
|
257 | 257 | } |
258 | 258 | // echo "<br/> ORG CHARG : " . $charge . " Charges : " . $temp_charge . "<br/>"; |
259 | 259 | } |
@@ -270,48 +270,48 @@ discard block |
||
270 | 270 | $Bal = "0.00"; |
271 | 271 | if ($AccountData ["posttoexternal"] == 0) { |
272 | 272 | $reseller_id = $AccountData ['type'] == 1 ? $AccountData ['id'] : 0; |
273 | - $where = "accountid IN ('" . $reseller_id . "','1')"; |
|
274 | - $this->db->where ( $where ); |
|
275 | - $this->db->select ( '*' ); |
|
276 | - $this->db->order_by ( 'accountid', 'desc' ); |
|
277 | - $this->db->limit ( 1 ); |
|
278 | - $invoiceconf = $this->db->get ( 'invoice_conf' ); |
|
279 | - $invoice_conf = ( array ) $invoiceconf->first_row (); |
|
280 | - $last_invoiceid = $this->common->get_invoice_date ( 'invoiceid', '', $AccountData ['reseller_id'] ); |
|
273 | + $where = "accountid IN ('".$reseller_id."','1')"; |
|
274 | + $this->db->where($where); |
|
275 | + $this->db->select('*'); |
|
276 | + $this->db->order_by('accountid', 'desc'); |
|
277 | + $this->db->limit(1); |
|
278 | + $invoiceconf = $this->db->get('invoice_conf'); |
|
279 | + $invoice_conf = (array)$invoiceconf->first_row(); |
|
280 | + $last_invoiceid = $this->common->get_invoice_date('invoiceid', '', $AccountData ['reseller_id']); |
|
281 | 281 | if ($last_invoiceid && $last_invoiceid > 0) { |
282 | 282 | $last_invoiceid = ($last_invoiceid + 1); |
283 | 283 | } else { |
284 | 284 | $last_invoiceid = $invoice_conf ['invoice_start_from']; |
285 | 285 | } |
286 | - $last_invoiceid = str_pad ( $last_invoiceid, (strlen ( $last_invoiceid ) + 4), '0', STR_PAD_LEFT ); |
|
286 | + $last_invoiceid = str_pad($last_invoiceid, (strlen($last_invoiceid) + 4), '0', STR_PAD_LEFT); |
|
287 | 287 | $invoice_prefix = $invoice_conf ['invoice_prefix']; |
288 | - $due_date = gmdate ( "Y-m-d H:i:s", strtotime ( gmdate ( "Y-m-d H:i:s" ) . " +" . $invoice_conf ['interval'] . " days" ) ); |
|
288 | + $due_date = gmdate("Y-m-d H:i:s", strtotime(gmdate("Y-m-d H:i:s")." +".$invoice_conf ['interval']." days")); |
|
289 | 289 | |
290 | - $invoiceid = $this->common_model->generate_receipt ( $AccountData ["id"], $charge, $AccountData, $last_invoiceid, $invoice_prefix, $due_date ); |
|
291 | - $this->db->set ( 'balance', 'balance-' . $charge, FALSE ); |
|
292 | - $this->db->where ( 'id', $AccountData ["id"] ); |
|
293 | - $this->db->update ( "accounts" ); |
|
290 | + $invoiceid = $this->common_model->generate_receipt($AccountData ["id"], $charge, $AccountData, $last_invoiceid, $invoice_prefix, $due_date); |
|
291 | + $this->db->set('balance', 'balance-'.$charge, FALSE); |
|
292 | + $this->db->where('id', $AccountData ["id"]); |
|
293 | + $this->db->update("accounts"); |
|
294 | 294 | $AccountData ['balance'] = ($AccountData ['balance'] - $charge); |
295 | 295 | $Bal = $AccountData ['balance']; |
296 | 296 | } else { |
297 | 297 | $Bal = ($AccountData ["credit_limit"] - $AccountData ["balance"]); |
298 | 298 | } |
299 | 299 | if ($Bal <= 0) { |
300 | - $this->db->set ( 'status', "1", FALSE ); |
|
301 | - $this->db->where ( 'id', $AccountData ["id"] ); |
|
302 | - $this->db->update ( "accounts" ); |
|
300 | + $this->db->set('status', "1", FALSE); |
|
301 | + $this->db->where('id', $AccountData ["id"]); |
|
302 | + $this->db->update("accounts"); |
|
303 | 303 | } |
304 | - $invoice_item_arr = array ( |
|
304 | + $invoice_item_arr = array( |
|
305 | 305 | "accountid" => $AccountData ["id"], |
306 | 306 | "reseller_id" => $AccountData ["reseller_id"], |
307 | - "description" => trim ( $description . "-" . $fromdate . " to " . $todate ), |
|
307 | + "description" => trim($description."-".$fromdate." to ".$todate), |
|
308 | 308 | "item_id" => $item_id, |
309 | 309 | "debit" => $charge, |
310 | 310 | "invoiceid" => $invoiceid, |
311 | - "created_date" => trim ( $invoicedate ), |
|
311 | + "created_date" => trim($invoicedate), |
|
312 | 312 | "item_type" => $type |
313 | 313 | ); |
314 | - $this->manage_invoice ( $invoice_item_arr ); |
|
314 | + $this->manage_invoice($invoice_item_arr); |
|
315 | 315 | } |
316 | 316 | |
317 | 317 | /** |
@@ -320,16 +320,16 @@ discard block |
||
320 | 320 | * @param string $table |
321 | 321 | */ |
322 | 322 | function get_table_data($select, $table, $where) { |
323 | - $query = $this->db_model->getSelect ( $select, $table, $where ); |
|
323 | + $query = $this->db_model->getSelect($select, $table, $where); |
|
324 | 324 | if ($query->num_rows > 0) { |
325 | - $query_result = $query->result_array (); |
|
325 | + $query_result = $query->result_array(); |
|
326 | 326 | return $query_result; |
327 | 327 | } else { |
328 | 328 | return false; |
329 | 329 | } |
330 | 330 | } |
331 | 331 | function Manage_Invoice($invoice_item_arr) { |
332 | - $this->db->insert ( "invoice_details", $invoice_item_arr ); |
|
332 | + $this->db->insert("invoice_details", $invoice_item_arr); |
|
333 | 333 | } |
334 | 334 | } |
335 | 335 | ?> |
@@ -149,36 +149,39 @@ |
||
149 | 149 | if (($parent_id == $reseller_dids ['reseller_id'] && $did_value ['accountid'] > 0) || $reseller_dids ['parent_id'] == 0) { |
150 | 150 | // Apply charges to resellers customers. |
151 | 151 | $lastdate = $this->calculate_charges ( $reseller_acc_data, $itemArr, $reseller_dids ["monthlycost"], $fromdate, $todate, "1" ); |
152 | - if ($lastdate) |
|
153 | - $this->db->update ( "reseller_pricing", array ( |
|
152 | + if ($lastdate) { |
|
153 | + $this->db->update ( "reseller_pricing", array ( |
|
154 | 154 | "charge_upto" => $lastdate |
155 | 155 | ), array ( |
156 | 156 | "note" => $did_value ["number"], |
157 | 157 | "reseller_id" => $reseller_acc_data ["id"] |
158 | 158 | ) ); |
159 | + } |
|
159 | 160 | } else { |
160 | 161 | // Apply charges to Resellers. |
161 | 162 | $lastdate = $this->calculate_charges ( $reseller_acc_data, $itemArr, $reseller_dids ["monthlycost"], $fromdate, $todate, "1" ); |
162 | - if ($lastdate) |
|
163 | - $this->db->update ( "reseller_pricing", array ( |
|
163 | + if ($lastdate) { |
|
164 | + $this->db->update ( "reseller_pricing", array ( |
|
164 | 165 | "charge_upto" => $lastdate |
165 | 166 | ), array ( |
166 | 167 | "note" => $did_value ["number"], |
167 | 168 | "reseller_id" => $reseller_acc_data ["id"] |
168 | 169 | ) ); |
170 | + } |
|
169 | 171 | } |
170 | 172 | $parent_id = $reseller_dids ['parent_id']; |
171 | 173 | } |
172 | 174 | } |
173 | 175 | // else{ |
174 | 176 | $lastdate = $this->calculate_charges ( $AccountDATA, $itemArr, $did_value ["monthlycost"], $fromdate, $todate, "1" ); |
175 | - if ($lastdate) |
|
176 | - $this->db->update ( "dids", array ( |
|
177 | + if ($lastdate) { |
|
178 | + $this->db->update ( "dids", array ( |
|
177 | 179 | "charge_upto" => $lastdate |
178 | 180 | ), array ( |
179 | 181 | "id" => $did_value ["id"], |
180 | 182 | "accountid" => $AccountDATA ["id"] |
181 | 183 | ) ); |
184 | + } |
|
182 | 185 | // } |
183 | 186 | } |
184 | 187 | } |
@@ -1416,6 +1416,11 @@ |
||
1416 | 1416 | ); |
1417 | 1417 | return $status_array; |
1418 | 1418 | } |
1419 | + |
|
1420 | + /** |
|
1421 | + * @param string $select |
|
1422 | + * @param string $table |
|
1423 | + */ |
|
1419 | 1424 | function build_concat_string($select, $table, $id_where = '') { |
1420 | 1425 | $select_params = explode ( ',', $select ); |
1421 | 1426 | $where = array ( |
@@ -21,8 +21,8 @@ discard block |
||
21 | 21 | // You should have received a copy of the GNU Affero General Public License |
22 | 22 | // along with this program. If not, see <http://www.gnu.org/licenses/>. |
23 | 23 | // ############################################################################## |
24 | -if (! defined ( 'BASEPATH' )) |
|
25 | - exit ( 'No direct script access allowed' ); |
|
24 | +if ( ! defined('BASEPATH')) |
|
25 | + exit ('No direct script access allowed'); |
|
26 | 26 | |
27 | 27 | /** |
28 | 28 | * Dynamically build forms for display |
@@ -30,11 +30,11 @@ discard block |
||
30 | 30 | class common { |
31 | 31 | protected $CI; // codeigniter |
32 | 32 | function __construct($library_name = '') { |
33 | - $this->CI = & get_instance (); |
|
34 | - $this->CI->load->library ( "timezone" ); |
|
35 | - $this->CI->load->model ( 'db_model' ); |
|
36 | - $this->CI->load->library ( 'email' ); |
|
37 | - $this->CI->load->library ( 'session' ); |
|
33 | + $this->CI = & get_instance(); |
|
34 | + $this->CI->load->library("timezone"); |
|
35 | + $this->CI->load->model('db_model'); |
|
36 | + $this->CI->load->library('email'); |
|
37 | + $this->CI->load->library('session'); |
|
38 | 38 | } |
39 | 39 | |
40 | 40 | // __construct |
@@ -44,52 +44,52 @@ discard block |
||
44 | 44 | function generate_password() { |
45 | 45 | $length = common_model::$global_config ['system_config'] ['pinlength']; |
46 | 46 | $chars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789!@#$^&{}~,.*()_-=+<>[]|?"; |
47 | - $pass = str_shuffle ( $chars ); |
|
48 | - $pass = substr ( base64_encode ( sha1 ( $pass . $chars, true ) ), 0, $length ); |
|
49 | - for($i = 0; $i < $length; $i ++) { |
|
50 | - $pass .= $chars {mt_rand ( 0, strlen ( $chars ) - 1 )}; |
|
47 | + $pass = str_shuffle($chars); |
|
48 | + $pass = substr(base64_encode(sha1($pass.$chars, true)), 0, $length); |
|
49 | + for ($i = 0; $i < $length; $i++) { |
|
50 | + $pass .= $chars {mt_rand(0, strlen($chars) - 1)}; |
|
51 | 51 | } |
52 | 52 | return $pass; |
53 | 53 | } |
54 | 54 | function find_uniq_rendno($size = '', $field = '', $tablename = '') { |
55 | 55 | if ($tablename != '') { |
56 | - $accounttype_array = array (); |
|
57 | - $uname = rand ( pow ( 10, $size - 1 ), pow ( 10, $size ) - 1 ); |
|
58 | - $where = array ( |
|
56 | + $accounttype_array = array(); |
|
57 | + $uname = rand(pow(10, $size - 1), pow(10, $size) - 1); |
|
58 | + $where = array( |
|
59 | 59 | $field => $uname |
60 | 60 | ); |
61 | - $acc_result = $this->CI->db_model->getSelect ( 'Count(*) as count', $tablename, $where ); |
|
62 | - $acc_result = $acc_result->result (); |
|
63 | - while ( $acc_result [0]->count != 0 ) { |
|
64 | - $uname = rand ( pow ( 10, $size - 1 ), pow ( 10, $size ) - 1 ); |
|
65 | - $acc_result = $this->CI->db_model->getSelect ( 'Count(*) as count', $tablename, $where ); |
|
61 | + $acc_result = $this->CI->db_model->getSelect('Count(*) as count', $tablename, $where); |
|
62 | + $acc_result = $acc_result->result(); |
|
63 | + while ($acc_result [0]->count != 0) { |
|
64 | + $uname = rand(pow(10, $size - 1), pow(10, $size) - 1); |
|
65 | + $acc_result = $this->CI->db_model->getSelect('Count(*) as count', $tablename, $where); |
|
66 | 66 | } |
67 | 67 | } else { |
68 | - $uname = rand ( pow ( 10, $size - 1 ), pow ( 10, $size ) - 1 ); |
|
68 | + $uname = rand(pow(10, $size - 1), pow(10, $size) - 1); |
|
69 | 69 | } |
70 | 70 | return $uname; |
71 | 71 | } |
72 | 72 | function find_uniq_rendno_customer($size = '', $field = '', $tablename = '') { |
73 | 73 | if ($tablename != '') { |
74 | - $accounttype_array = array (); |
|
75 | - $uname = rand ( pow ( 10, $size - 1 ), pow ( 10, $size ) - 1 ); |
|
76 | - $where = array ( |
|
74 | + $accounttype_array = array(); |
|
75 | + $uname = rand(pow(10, $size - 1), pow(10, $size) - 1); |
|
76 | + $where = array( |
|
77 | 77 | $field => $uname |
78 | 78 | ); |
79 | - $acc_result = $this->CI->db_model->getSelect ( 'Count(*) as count', $tablename, $where ); |
|
80 | - $acc_result = $acc_result->result (); |
|
81 | - while ( $acc_result [0]->count != 0 ) { |
|
82 | - $uname = rand ( pow ( 10, $size - 1 ), pow ( 10, $size ) - 1 ); |
|
83 | - $acc_result = $this->CI->db_model->getSelect ( 'Count(*) as count', $tablename, $where ); |
|
79 | + $acc_result = $this->CI->db_model->getSelect('Count(*) as count', $tablename, $where); |
|
80 | + $acc_result = $acc_result->result(); |
|
81 | + while ($acc_result [0]->count != 0) { |
|
82 | + $uname = rand(pow(10, $size - 1), pow(10, $size) - 1); |
|
83 | + $acc_result = $this->CI->db_model->getSelect('Count(*) as count', $tablename, $where); |
|
84 | 84 | } |
85 | 85 | } else { |
86 | - $uname = rand ( pow ( 10, $size - 1 ), pow ( 10, $size ) - 1 ); |
|
86 | + $uname = rand(pow(10, $size - 1), pow(10, $size) - 1); |
|
87 | 87 | } |
88 | 88 | $start_prifix_value = common_model::$global_config ['system_config'] ['startingdigit']; |
89 | 89 | if ($tablename == 'accounts' && $start_prifix_value != 0) { |
90 | - $length = strlen ( $start_prifix_value ); |
|
91 | - $uname = substr ( $uname, $length ); |
|
92 | - $uname = $start_prifix_value . $uname; |
|
90 | + $length = strlen($start_prifix_value); |
|
91 | + $uname = substr($uname, $length); |
|
92 | + $uname = $start_prifix_value.$uname; |
|
93 | 93 | } |
94 | 94 | return $uname; |
95 | 95 | } |
@@ -101,38 +101,38 @@ discard block |
||
101 | 101 | function random_string($length) { |
102 | 102 | $chars = "1234567890"; // length:36 |
103 | 103 | $final_rand = ''; |
104 | - for($i = 0; $i < $length; $i ++) { |
|
105 | - $final_rand .= $chars [rand ( 0, strlen ( $chars ) - 1 )]; |
|
104 | + for ($i = 0; $i < $length; $i++) { |
|
105 | + $final_rand .= $chars [rand(0, strlen($chars) - 1)]; |
|
106 | 106 | } |
107 | 107 | return $final_rand; |
108 | 108 | } |
109 | 109 | function find_uniq_rendno_accno($length = '', $field = '', $tablename = '', $default, $creation_count) { |
110 | - $number = array (); |
|
110 | + $number = array(); |
|
111 | 111 | $j = 0; |
112 | 112 | |
113 | - $total_count = pow ( 10, $length ); |
|
114 | - for($i = 1; $i <= $total_count; $i ++) { |
|
113 | + $total_count = pow(10, $length); |
|
114 | + for ($i = 1; $i <= $total_count; $i++) { |
|
115 | 115 | |
116 | 116 | $flag = false; |
117 | - $uname = $this->random_string ( $length ); |
|
118 | - $uname = strtolower ( $uname ); |
|
119 | - if (isset ( $default )) |
|
120 | - $uname = $default . $uname; |
|
121 | - if (! in_array ( $uname, $number )) { |
|
122 | - $where = array ( |
|
117 | + $uname = $this->random_string($length); |
|
118 | + $uname = strtolower($uname); |
|
119 | + if (isset ($default)) |
|
120 | + $uname = $default.$uname; |
|
121 | + if ( ! in_array($uname, $number)) { |
|
122 | + $where = array( |
|
123 | 123 | $field => $uname |
124 | 124 | ); |
125 | - $acc_result = $this->CI->db_model->getSelect ( 'Count(id) as count', $tablename, $where ); |
|
126 | - $acc_result = $acc_result->result_array (); |
|
127 | - if ($acc_result [0] ['count'] == 0 && ! in_array ( $uname, $number )) { |
|
125 | + $acc_result = $this->CI->db_model->getSelect('Count(id) as count', $tablename, $where); |
|
126 | + $acc_result = $acc_result->result_array(); |
|
127 | + if ($acc_result [0] ['count'] == 0 && ! in_array($uname, $number)) { |
|
128 | 128 | $number [] = $uname; |
129 | - $j ++; |
|
129 | + $j++; |
|
130 | 130 | } |
131 | 131 | if ($j == $creation_count) { |
132 | 132 | break; |
133 | 133 | } |
134 | 134 | } else { |
135 | - $total_count ++; |
|
135 | + $total_count++; |
|
136 | 136 | } |
137 | 137 | } |
138 | 138 | return $number; |
@@ -145,15 +145,15 @@ discard block |
||
145 | 145 | */ |
146 | 146 | function get_field_count($select, $table, $where) { |
147 | 147 | // echo $select."=====".$table."===".$where; |
148 | - if (is_array ( $where )) { |
|
148 | + if (is_array($where)) { |
|
149 | 149 | $where = $where; |
150 | 150 | } else { |
151 | - $where = array ( |
|
151 | + $where = array( |
|
152 | 152 | $select => $where |
153 | 153 | ); |
154 | 154 | } |
155 | - $field_name = $this->CI->db_model->countQuery ( $select, $table, $where ); |
|
156 | - if (isset ( $field_name ) && ! empty ( $field_name )) { |
|
155 | + $field_name = $this->CI->db_model->countQuery($select, $table, $where); |
|
156 | + if (isset ($field_name) && ! empty ($field_name)) { |
|
157 | 157 | return $field_name; |
158 | 158 | } else { |
159 | 159 | return "0"; |
@@ -166,16 +166,16 @@ discard block |
||
166 | 166 | * @param string $table |
167 | 167 | */ |
168 | 168 | function get_field_name($select, $table, $where) { |
169 | - if (is_array ( $where )) { |
|
169 | + if (is_array($where)) { |
|
170 | 170 | $where = $where; |
171 | 171 | } else { |
172 | - $where = array ( |
|
172 | + $where = array( |
|
173 | 173 | "id" => $where |
174 | 174 | ); |
175 | 175 | } |
176 | - $field_name = $this->CI->db_model->getSelect ( $select, $table, $where ); |
|
177 | - $field_name = $field_name->result (); |
|
178 | - if (isset ( $field_name ) && ! empty ( $field_name )) { |
|
176 | + $field_name = $this->CI->db_model->getSelect($select, $table, $where); |
|
177 | + $field_name = $field_name->result(); |
|
178 | + if (isset ($field_name) && ! empty ($field_name)) { |
|
179 | 179 | return $field_name [0]->$select; |
180 | 180 | } else { |
181 | 181 | return ""; |
@@ -189,61 +189,61 @@ discard block |
||
189 | 189 | */ |
190 | 190 | function get_field_name_coma_new($select, $table, $where) { |
191 | 191 | $value = ''; |
192 | - if (is_array ( $where )) { |
|
192 | + if (is_array($where)) { |
|
193 | 193 | $where = $where; |
194 | 194 | } else { |
195 | - $where = explode ( ',', $where ); |
|
195 | + $where = explode(',', $where); |
|
196 | 196 | } |
197 | - $select1 = explode ( ',', $select ); |
|
198 | - for($i = 0; $i < count ( $where ); $i ++) { |
|
199 | - $where_in = array ( |
|
197 | + $select1 = explode(',', $select); |
|
198 | + for ($i = 0; $i < count($where); $i++) { |
|
199 | + $where_in = array( |
|
200 | 200 | "id" => $where [$i] |
201 | 201 | ); |
202 | 202 | |
203 | - $field_name = $this->CI->db_model->getSelect ( $select, $table, $where_in ); |
|
204 | - $field_name = $field_name->result (); |
|
205 | - if (isset ( $field_name ) && ! empty ( $field_name )) { |
|
206 | - foreach ( $select1 as $sel ) { |
|
203 | + $field_name = $this->CI->db_model->getSelect($select, $table, $where_in); |
|
204 | + $field_name = $field_name->result(); |
|
205 | + if (isset ($field_name) && ! empty ($field_name)) { |
|
206 | + foreach ($select1 as $sel) { |
|
207 | 207 | if ($sel == 'number') { |
208 | - $value .= "(" . $field_name [0]->$sel . ")"; |
|
208 | + $value .= "(".$field_name [0]->$sel.")"; |
|
209 | 209 | } else { |
210 | - $value .= $field_name [0]->$sel . " "; |
|
210 | + $value .= $field_name [0]->$sel." "; |
|
211 | 211 | } |
212 | 212 | } |
213 | 213 | } else { |
214 | 214 | $value = ""; |
215 | 215 | } |
216 | 216 | } |
217 | - return rtrim ( $value, ',' ); |
|
217 | + return rtrim($value, ','); |
|
218 | 218 | } |
219 | 219 | function check_did_avl($select, $table, $where) { |
220 | - $accountinfo = $this->CI->session->userdata ( 'accountinfo' ); |
|
220 | + $accountinfo = $this->CI->session->userdata('accountinfo'); |
|
221 | 221 | $flag_status = ""; |
222 | - $where = array ( |
|
222 | + $where = array( |
|
223 | 223 | "number" => $where |
224 | 224 | ); |
225 | - $field_name = $this->CI->db_model->getSelect ( "id,accountid,parent_id", 'dids', $where ); |
|
226 | - $field_name = $field_name->result (); |
|
227 | - if (isset ( $field_name ) && ! empty ( $field_name )) { |
|
228 | - if (isset ( $field_name [0] ) && $accountinfo ['type'] != 1) { |
|
225 | + $field_name = $this->CI->db_model->getSelect("id,accountid,parent_id", 'dids', $where); |
|
226 | + $field_name = $field_name->result(); |
|
227 | + if (isset ($field_name) && ! empty ($field_name)) { |
|
228 | + if (isset ($field_name [0]) && $accountinfo ['type'] != 1) { |
|
229 | 229 | if ($field_name [0]->accountid != 0 && $field_name [0]->parent_id == 0) { |
230 | - $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>"; |
|
230 | + $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>"; |
|
231 | 231 | } else if ($field_name [0]->parent_id != 0) { |
232 | - $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>"; |
|
232 | + $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>"; |
|
233 | 233 | } else { |
234 | 234 | $flag_status = "<span class=' label label-sm label-inverse arrowed-in' title='Not in use'>Not in use</span>"; |
235 | 235 | } |
236 | 236 | } else { |
237 | 237 | $reseller_id = $accountinfo ['type'] != 1 ? 0 : $accountinfo ['id']; |
238 | - $where = array ( |
|
238 | + $where = array( |
|
239 | 239 | "note" => $field_name [0]->number, |
240 | 240 | 'parent_id' => $reseller_id |
241 | 241 | ); |
242 | - $field_name_re = $this->CI->db_model->getSelect ( "reseller_id", 'reseller_pricing', $where ); |
|
243 | - $field_name_re = $field_name_re->result (); |
|
242 | + $field_name_re = $this->CI->db_model->getSelect("reseller_id", 'reseller_pricing', $where); |
|
243 | + $field_name_re = $field_name_re->result(); |
|
244 | 244 | |
245 | - if (isset ( $field_name_re ) && ! empty ( $field_name_re )) { |
|
246 | - $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>"; |
|
245 | + if (isset ($field_name_re) && ! empty ($field_name_re)) { |
|
246 | + $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>"; |
|
247 | 247 | } else { |
248 | 248 | $flag_status = "<span class=' label label-sm label-inverse arrowed-in' title='Not in use'>Not in use</span>"; |
249 | 249 | } |
@@ -254,11 +254,11 @@ discard block |
||
254 | 254 | return $flag_status; |
255 | 255 | } |
256 | 256 | function check_did_avl_export($number) { |
257 | - $this->CI->db->where ( 'number', $number ); |
|
258 | - $this->CI->db->select ( 'id,accountid,parent_id' ); |
|
257 | + $this->CI->db->where('number', $number); |
|
258 | + $this->CI->db->select('id,accountid,parent_id'); |
|
259 | 259 | $status = null; |
260 | - $did_info = ( array ) $this->CI->db->get ( 'dids' )->first_row (); |
|
261 | - $accountinfo = $this->CI->session->userdata ( 'accountinfo' ); |
|
260 | + $did_info = (array)$this->CI->db->get('dids')->first_row(); |
|
261 | + $accountinfo = $this->CI->session->userdata('accountinfo'); |
|
262 | 262 | if ($did_info ['accountid'] == 0 && $did_info ['parent_id'] == 0) { |
263 | 263 | $status = 'Not in use'; |
264 | 264 | } elseif ($accountinfo ['type'] != 1) { |
@@ -269,13 +269,13 @@ discard block |
||
269 | 269 | $status = 'Purchase by Customer'; |
270 | 270 | } |
271 | 271 | } else { |
272 | - $where_arr = array ( |
|
272 | + $where_arr = array( |
|
273 | 273 | 'note' => $did_info ['number'], |
274 | 274 | "parent_id" => $accountinfo ['id'] |
275 | 275 | ); |
276 | - $this->db->where ( $where ); |
|
277 | - $this->CI->db->select ( 'reseller_id,parent_id' ); |
|
278 | - $reseller_pricing = ( array ) $this->db->get ( 'reseller_pricing' )->first_row (); |
|
276 | + $this->db->where($where); |
|
277 | + $this->CI->db->select('reseller_id,parent_id'); |
|
278 | + $reseller_pricing = (array)$this->db->get('reseller_pricing')->first_row(); |
|
279 | 279 | if ($reseller_pricing ['reseller_id'] == 0 && $did_info ['accountid'] == 0 && $did_info ['parent_id'] == $accountinfo ['id']) { |
280 | 280 | $status = 'Not in use'; |
281 | 281 | } |
@@ -286,26 +286,26 @@ discard block |
||
286 | 286 | return $status; |
287 | 287 | } |
288 | 288 | function check_did_avl_reseller($select, $table, $where) { |
289 | - $accountinfo = $this->CI->session->userdata ( 'accountinfo' ); |
|
289 | + $accountinfo = $this->CI->session->userdata('accountinfo'); |
|
290 | 290 | $flag_status = "<span class=' label label-sm label-inverse arrowed-in' title='Not in use'>Not in use</span>"; |
291 | - $this->CI->db->where ( 'number', $where ); |
|
292 | - $this->CI->db->select ( 'id,accountid,parent_id,number' ); |
|
293 | - $did_info = ( array ) $this->CI->db->get ( 'dids' )->first_row (); |
|
291 | + $this->CI->db->where('number', $where); |
|
292 | + $this->CI->db->select('id,accountid,parent_id,number'); |
|
293 | + $did_info = (array)$this->CI->db->get('dids')->first_row(); |
|
294 | 294 | if ($did_info ['accountid'] > 0 && $did_info ['parent_id'] == $accountinfo ['id']) { |
295 | - $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>"; |
|
295 | + $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>"; |
|
296 | 296 | } else if ($accountinfo ['type'] != 1 && $did_info ['parent_id'] != $accountinfo ['id']) { |
297 | - $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>"; |
|
297 | + $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>"; |
|
298 | 298 | } else { |
299 | 299 | $reseller_id = $accountinfo ['type'] != 1 ? 0 : $accountinfo ['id']; |
300 | - $where = array ( |
|
300 | + $where = array( |
|
301 | 301 | "note" => $did_info ['number'], |
302 | 302 | 'parent_id' => $reseller_id |
303 | 303 | ); |
304 | - $this->CI->db->where ( $where ); |
|
305 | - $this->CI->db->select ( 'reseller_id,id' ); |
|
306 | - $reseller_pricing_info = ( array ) $this->CI->db->get ( 'reseller_pricing' )->first_row (); |
|
307 | - if (isset ( $reseller_pricing_info ) && ! empty ( $reseller_pricing_info )) { |
|
308 | - $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>"; |
|
304 | + $this->CI->db->where($where); |
|
305 | + $this->CI->db->select('reseller_id,id'); |
|
306 | + $reseller_pricing_info = (array)$this->CI->db->get('reseller_pricing')->first_row(); |
|
307 | + if (isset ($reseller_pricing_info) && ! empty ($reseller_pricing_info)) { |
|
308 | + $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>"; |
|
309 | 309 | } else { |
310 | 310 | $flag_status = "<span class=' label label-sm label-inverse arrowed-in' title='Not in use'>Not in use</span>"; |
311 | 311 | } |
@@ -316,47 +316,47 @@ discard block |
||
316 | 316 | // get data for Comma seprated |
317 | 317 | function get_field_name_coma($select, $table, $where) { |
318 | 318 | $value = ''; |
319 | - if (is_array ( $where )) { |
|
319 | + if (is_array($where)) { |
|
320 | 320 | $where = $where; |
321 | 321 | } else { |
322 | - $where = explode ( ',', $where ); |
|
322 | + $where = explode(',', $where); |
|
323 | 323 | } |
324 | - for($i = 0; $i < count ( $where ); $i ++) { |
|
325 | - $where_in = array ( |
|
324 | + for ($i = 0; $i < count($where); $i++) { |
|
325 | + $where_in = array( |
|
326 | 326 | "id" => $where [$i] |
327 | 327 | ); |
328 | 328 | |
329 | - $field_name = $this->CI->db_model->getSelect ( $select, $table, $where_in ); |
|
330 | - $field_name = $field_name->result (); |
|
331 | - if (isset ( $field_name ) && ! empty ( $field_name )) { |
|
332 | - $value .= $field_name [0]->$select . ","; |
|
329 | + $field_name = $this->CI->db_model->getSelect($select, $table, $where_in); |
|
330 | + $field_name = $field_name->result(); |
|
331 | + if (isset ($field_name) && ! empty ($field_name)) { |
|
332 | + $value .= $field_name [0]->$select.","; |
|
333 | 333 | } else { |
334 | 334 | $value = ""; |
335 | 335 | } |
336 | 336 | } |
337 | - return rtrim ( $value, ',' ); |
|
337 | + return rtrim($value, ','); |
|
338 | 338 | } |
339 | 339 | function set_invoice_option($select = "", $table = "", $call_type = "", $edit_value = '') { |
340 | 340 | $invoice_date = false; |
341 | 341 | $uri_segment = $this->CI->uri->segments; |
342 | - if (isset ( $uri_segment [3] ) && $uri_segment [3] > 0 && empty ( $edit_value )) { |
|
343 | - $field_name = $this->CI->db_model->getSelect ( "sweep_id,invoice_day", "accounts", array ( |
|
342 | + if (isset ($uri_segment [3]) && $uri_segment [3] > 0 && empty ($edit_value)) { |
|
343 | + $field_name = $this->CI->db_model->getSelect("sweep_id,invoice_day", "accounts", array( |
|
344 | 344 | "id" => $uri_segment [3] |
345 | - ) ); |
|
346 | - $field_name = $field_name->result_array (); |
|
345 | + )); |
|
346 | + $field_name = $field_name->result_array(); |
|
347 | 347 | $select = $field_name [0] ["sweep_id"]; |
348 | 348 | $invoice_date = $field_name [0] ["invoice_day"]; |
349 | 349 | } else { |
350 | 350 | $invoice_date = $edit_value; |
351 | 351 | } |
352 | 352 | if ($select == "" || $select == "0") { |
353 | - $daily_arr = array ( |
|
353 | + $daily_arr = array( |
|
354 | 354 | "0" => "0" |
355 | 355 | ); |
356 | 356 | return $daily_arr; |
357 | 357 | } |
358 | 358 | if ($select == 1) { |
359 | - $week_arr = array ( |
|
359 | + $week_arr = array( |
|
360 | 360 | "1" => "Monday", |
361 | 361 | "2" => "Tuesday", |
362 | 362 | "3" => "Wednesday", |
@@ -365,53 +365,53 @@ discard block |
||
365 | 365 | "6" => "Saturday", |
366 | 366 | "7" => "Sunday" |
367 | 367 | ); |
368 | - $rawDate = date ( "Y-m-d" ); |
|
369 | - $day = date ( 'N', strtotime ( $rawDate ) ); |
|
370 | - if (isset ( $uri_segment [3] )) { |
|
368 | + $rawDate = date("Y-m-d"); |
|
369 | + $day = date('N', strtotime($rawDate)); |
|
370 | + if (isset ($uri_segment [3])) { |
|
371 | 371 | return $week_arr; |
372 | 372 | } else { |
373 | - $week_drp = form_dropdown ( array ( |
|
373 | + $week_drp = form_dropdown(array( |
|
374 | 374 | "name" => 'invoice_day', |
375 | 375 | 'style' => "width: 100% !important;", |
376 | 376 | "class" => "invoice_day" |
377 | - ), $week_arr, $day ); |
|
377 | + ), $week_arr, $day); |
|
378 | 378 | return $week_drp; |
379 | 379 | } |
380 | 380 | } |
381 | 381 | if ($select != 0 && $select != 1) { |
382 | - for($i = 1; $i < 29; $i ++) { |
|
382 | + for ($i = 1; $i < 29; $i++) { |
|
383 | 383 | $mon_arr [$i] = $i; |
384 | 384 | } |
385 | - if (isset ( $uri_segment [3] ) && $uri_segment [3] > 0 && empty ( $edit_value )) { |
|
385 | + if (isset ($uri_segment [3]) && $uri_segment [3] > 0 && empty ($edit_value)) { |
|
386 | 386 | return $mon_arr; |
387 | 387 | } else { |
388 | - $day = $invoice_date > 0 ? $invoice_date : date ( 'd' ); |
|
389 | - $month_drp = form_dropdown ( array ( |
|
388 | + $day = $invoice_date > 0 ? $invoice_date : date('d'); |
|
389 | + $month_drp = form_dropdown(array( |
|
390 | 390 | "name" => 'invoice_day', |
391 | 391 | "class" => "width_dropdown invoice_day" |
392 | - ), $mon_arr, $day ); |
|
392 | + ), $mon_arr, $day); |
|
393 | 393 | return $month_drp; |
394 | 394 | } |
395 | 395 | } |
396 | 396 | } |
397 | 397 | function set_status($status = '') { |
398 | - $status_array = array ( |
|
399 | - '0' => gettext ( 'Active' ), |
|
400 | - '1' => gettext ( 'Inactive' ) |
|
398 | + $status_array = array( |
|
399 | + '0' => gettext('Active'), |
|
400 | + '1' => gettext('Inactive') |
|
401 | 401 | ); |
402 | 402 | return $status_array; |
403 | 403 | } |
404 | 404 | function set_routetype($status = '') { |
405 | - $status_array = array ( |
|
406 | - '0' => gettext ( 'LCR' ), |
|
407 | - '1' => gettext ( 'COST' ) |
|
405 | + $status_array = array( |
|
406 | + '0' => gettext('LCR'), |
|
407 | + '1' => gettext('COST') |
|
408 | 408 | ); |
409 | 409 | return $status_array; |
410 | 410 | } |
411 | 411 | function set_prorate($status = '') { |
412 | - $status_array = array ( |
|
413 | - '0' => gettext ( 'Yes' ), |
|
414 | - '1' => gettext ( 'No' ) |
|
412 | + $status_array = array( |
|
413 | + '0' => gettext('Yes'), |
|
414 | + '1' => gettext('No') |
|
415 | 415 | ); |
416 | 416 | return $status_array; |
417 | 417 | } |
@@ -419,18 +419,18 @@ discard block |
||
419 | 419 | * Add For Package Inbound or Outbound or both? |
420 | 420 | */ |
421 | 421 | function set_package_type($applicable_for = "") { |
422 | - $package_applicable = array ( |
|
423 | - '0' => gettext ( 'Outbound' ), |
|
424 | - '1' => gettext ( 'Inbound' ), |
|
425 | - '2' => gettext ( 'Both' ) |
|
422 | + $package_applicable = array( |
|
423 | + '0' => gettext('Outbound'), |
|
424 | + '1' => gettext('Inbound'), |
|
425 | + '2' => gettext('Both') |
|
426 | 426 | ); |
427 | 427 | return $package_applicable; |
428 | 428 | } |
429 | 429 | function get_package_type($status = '', $table = "", $applicable_for) { |
430 | - $package_applicable = array ( |
|
431 | - '0' => gettext ( 'Outbound' ), |
|
432 | - '1' => gettext ( 'Inbound' ), |
|
433 | - '2' => gettext ( 'Both' ) |
|
430 | + $package_applicable = array( |
|
431 | + '0' => gettext('Outbound'), |
|
432 | + '1' => gettext('Inbound'), |
|
433 | + '2' => gettext('Both') |
|
434 | 434 | ); |
435 | 435 | return $package_applicable [$applicable_for]; |
436 | 436 | } |
@@ -438,30 +438,30 @@ discard block |
||
438 | 438 | * ****************************************** |
439 | 439 | */ |
440 | 440 | function set_allow($status = '') { |
441 | - $status_array = array ( |
|
442 | - '1' => gettext ( 'Yes' ), |
|
443 | - '0' => gettext ( 'No' ) |
|
441 | + $status_array = array( |
|
442 | + '1' => gettext('Yes'), |
|
443 | + '0' => gettext('No') |
|
444 | 444 | ); |
445 | 445 | return $status_array; |
446 | 446 | } |
447 | 447 | function set_allow_invoice($status = '') { |
448 | - $status_array = array ( |
|
449 | - '1' => gettext ( 'Yes' ), |
|
450 | - '0' => gettext ( 'No' ) |
|
448 | + $status_array = array( |
|
449 | + '1' => gettext('Yes'), |
|
450 | + '0' => gettext('No') |
|
451 | 451 | ); |
452 | 452 | return $status_array; |
453 | 453 | } |
454 | 454 | function set_pin_allow($status = '') { |
455 | - $status_array = array ( |
|
456 | - '0' => gettext ( 'Disable' ), |
|
457 | - '1' => gettext ( 'Enable' ) |
|
455 | + $status_array = array( |
|
456 | + '0' => gettext('Disable'), |
|
457 | + '1' => gettext('Enable') |
|
458 | 458 | ); |
459 | 459 | return $status_array; |
460 | 460 | } |
461 | 461 | function set_pin_allow_customer($status = '') { |
462 | - $status_array = array ( |
|
463 | - '0' => gettext ( 'No' ), |
|
464 | - '1' => gettext ( 'Yes' ) |
|
462 | + $status_array = array( |
|
463 | + '0' => gettext('No'), |
|
464 | + '1' => gettext('Yes') |
|
465 | 465 | ); |
466 | 466 | return $status_array; |
467 | 467 | } |
@@ -469,43 +469,43 @@ discard block |
||
469 | 469 | return ($status == 1) ? "Yes" : "No"; |
470 | 470 | } |
471 | 471 | function set_call_type($call_type = "") { |
472 | - $call_type_array = array ( |
|
473 | - "-1" => gettext ( "--Select--" ), |
|
474 | - '1' => gettext ( 'DID-Local' ), |
|
475 | - '5' => gettext ( 'DID@IP/URL' ), |
|
476 | - '4' => gettext ( 'Direct-IP' ), |
|
477 | - '2' => gettext ( 'Other' ), |
|
478 | - '0' => gettext ( 'PSTN' ), |
|
479 | - '3' => gettext ( 'SIP-DID' ) |
|
472 | + $call_type_array = array( |
|
473 | + "-1" => gettext("--Select--"), |
|
474 | + '1' => gettext('DID-Local'), |
|
475 | + '5' => gettext('DID@IP/URL'), |
|
476 | + '4' => gettext('Direct-IP'), |
|
477 | + '2' => gettext('Other'), |
|
478 | + '0' => gettext('PSTN'), |
|
479 | + '3' => gettext('SIP-DID') |
|
480 | 480 | ); |
481 | 481 | return $call_type_array; |
482 | 482 | } |
483 | 483 | function set_call_type_search() { |
484 | - $call_type_array = array ( |
|
485 | - "" => gettext ( "--Select--" ), |
|
486 | - '1' => gettext ( 'DID-Local' ), |
|
487 | - '5' => gettext ( 'DID@IP/URL' ), |
|
488 | - '4' => gettext ( 'Direct-IP' ), |
|
489 | - '2' => gettext ( 'Other' ), |
|
490 | - '0' => gettext ( 'PSTN' ), |
|
491 | - '3' => gettext ( 'SIP-DID' ) |
|
484 | + $call_type_array = array( |
|
485 | + "" => gettext("--Select--"), |
|
486 | + '1' => gettext('DID-Local'), |
|
487 | + '5' => gettext('DID@IP/URL'), |
|
488 | + '4' => gettext('Direct-IP'), |
|
489 | + '2' => gettext('Other'), |
|
490 | + '0' => gettext('PSTN'), |
|
491 | + '3' => gettext('SIP-DID') |
|
492 | 492 | ); |
493 | 493 | return $call_type_array; |
494 | 494 | } |
495 | 495 | function get_call_type($select = "", $table = "", $call_type) { |
496 | - $call_type_array = array ( |
|
497 | - '1' => gettext ( 'DID-Local' ), |
|
498 | - '5' => gettext ( 'DID@IP/URL' ), |
|
499 | - '4' => gettext ( 'Direct-IP' ), |
|
500 | - '2' => gettext ( 'Other' ), |
|
501 | - '0' => gettext ( 'PSTN' ), |
|
502 | - '3' => gettext ( 'SIP-DID' ), |
|
496 | + $call_type_array = array( |
|
497 | + '1' => gettext('DID-Local'), |
|
498 | + '5' => gettext('DID@IP/URL'), |
|
499 | + '4' => gettext('Direct-IP'), |
|
500 | + '2' => gettext('Other'), |
|
501 | + '0' => gettext('PSTN'), |
|
502 | + '3' => gettext('SIP-DID'), |
|
503 | 503 | '-1' => "" |
504 | 504 | ); |
505 | 505 | return $call_type_array [$call_type]; |
506 | 506 | } |
507 | 507 | function get_custom_call_type($call_type) { |
508 | - $call_type_array = array ( |
|
508 | + $call_type_array = array( |
|
509 | 509 | 'DID-Local' => '1', |
510 | 510 | 'DID@IP/URL' => '5', |
511 | 511 | 'Direct-IP' => '4', |
@@ -517,14 +517,14 @@ discard block |
||
517 | 517 | return $call_type_array [$call_type]; |
518 | 518 | } |
519 | 519 | function set_sip_config_option($option = "") { |
520 | - $config_option = array ( |
|
520 | + $config_option = array( |
|
521 | 521 | "true" => "True", |
522 | 522 | "false" => "False" |
523 | 523 | ); |
524 | 524 | return $config_option; |
525 | 525 | } |
526 | 526 | function get_entity_type($select = "", $table = "", $entity_type) { |
527 | - $entity_array = array ( |
|
527 | + $entity_array = array( |
|
528 | 528 | '-1' => "Administrator", |
529 | 529 | '0' => 'Customer', |
530 | 530 | '1' => 'Reseller', |
@@ -536,73 +536,73 @@ discard block |
||
536 | 536 | return ($entity_array [$entity_type]); |
537 | 537 | } |
538 | 538 | function set_entity_type_customer($entity_type = "") { |
539 | - $entity_array = array ( |
|
540 | - '' => gettext ( "--Select--" ), |
|
541 | - '0' => gettext ( 'Customer' ), |
|
542 | - '3' => gettext ( "Provider" ) |
|
539 | + $entity_array = array( |
|
540 | + '' => gettext("--Select--"), |
|
541 | + '0' => gettext('Customer'), |
|
542 | + '3' => gettext("Provider") |
|
543 | 543 | ); |
544 | 544 | return $entity_array; |
545 | 545 | } |
546 | 546 | function set_entity_type_admin($entity_type = "") { |
547 | - $entity_array = array ( |
|
548 | - '' => gettext ( "--Select--" ), |
|
549 | - '2' => gettext ( 'Admin' ), |
|
550 | - "4" => gettext ( "Sub Admin" ) |
|
547 | + $entity_array = array( |
|
548 | + '' => gettext("--Select--"), |
|
549 | + '2' => gettext('Admin'), |
|
550 | + "4" => gettext("Sub Admin") |
|
551 | 551 | ); |
552 | 552 | return $entity_array; |
553 | 553 | } |
554 | 554 | function set_entity_type_email_mass($entity_type = "") { |
555 | - $entity_array = array ( |
|
556 | - '' => gettext ( "--Select--" ), |
|
557 | - '0' => gettext ( 'Customer' ), |
|
558 | - '1' => gettext ( 'Reseller' ), |
|
559 | - '3' => gettext ( "Provider" ) |
|
555 | + $entity_array = array( |
|
556 | + '' => gettext("--Select--"), |
|
557 | + '0' => gettext('Customer'), |
|
558 | + '1' => gettext('Reseller'), |
|
559 | + '3' => gettext("Provider") |
|
560 | 560 | ); |
561 | 561 | return $entity_array; |
562 | 562 | } |
563 | 563 | function set_sip_config_options($option = "") { |
564 | - $config_option = array ( |
|
565 | - "false" => gettext ( "False" ), |
|
566 | - "true" => gettext ( "True" ) |
|
564 | + $config_option = array( |
|
565 | + "false" => gettext("False"), |
|
566 | + "true" => gettext("True") |
|
567 | 567 | ); |
568 | 568 | return $config_option; |
569 | 569 | } |
570 | 570 | function set_sip_config_default($option = "") { |
571 | - $config_option = array ( |
|
572 | - "" => gettext ( "--SELECT--" ), |
|
573 | - "false" => gettext ( "False" ), |
|
574 | - "true" => gettext ( "True" ) |
|
571 | + $config_option = array( |
|
572 | + "" => gettext("--SELECT--"), |
|
573 | + "false" => gettext("False"), |
|
574 | + "true" => gettext("True") |
|
575 | 575 | ); |
576 | 576 | return $config_option; |
577 | 577 | } |
578 | 578 | function set_sip_bind_params($option = "") { |
579 | - $config_option = array ( |
|
580 | - "" => gettext ( "--SELECT--" ), |
|
581 | - "udp" => gettext ( "UDP" ), |
|
582 | - "tcp" => gettext ( "TCP" ) |
|
579 | + $config_option = array( |
|
580 | + "" => gettext("--SELECT--"), |
|
581 | + "udp" => gettext("UDP"), |
|
582 | + "tcp" => gettext("TCP") |
|
583 | 583 | ); |
584 | 584 | return $config_option; |
585 | 585 | } |
586 | 586 | function set_sip_vad_option() { |
587 | - $config_option = array ( |
|
588 | - "in" => gettext ( "In" ), |
|
589 | - "out" => gettext ( "Out" ), |
|
590 | - "both" => gettext ( "Both" ) |
|
587 | + $config_option = array( |
|
588 | + "in" => gettext("In"), |
|
589 | + "out" => gettext("Out"), |
|
590 | + "both" => gettext("Both") |
|
591 | 591 | ); |
592 | 592 | return $config_option; |
593 | 593 | } |
594 | 594 | function set_sip_drp_option($option = "") { |
595 | - $status_array = array ( |
|
596 | - 'no' => gettext ( 'No' ), |
|
597 | - 'yes' => gettext ( 'Yes' ) |
|
595 | + $status_array = array( |
|
596 | + 'no' => gettext('No'), |
|
597 | + 'yes' => gettext('Yes') |
|
598 | 598 | ); |
599 | 599 | return $status_array; |
600 | 600 | } |
601 | 601 | function set_status_callingcard($status = '') { |
602 | - $status_array = array ( |
|
603 | - '1' => gettext ( 'Active' ), |
|
604 | - '0' => gettext ( 'Inactive' ), |
|
605 | - '2' => gettext ( 'Deleted' ) |
|
602 | + $status_array = array( |
|
603 | + '1' => gettext('Active'), |
|
604 | + '0' => gettext('Inactive'), |
|
605 | + '2' => gettext('Deleted') |
|
606 | 606 | ); |
607 | 607 | return $status_array; |
608 | 608 | } |
@@ -611,16 +611,16 @@ discard block |
||
611 | 611 | */ |
612 | 612 | function get_status($select = "", $table = "", $status) { |
613 | 613 | if ($select != 'export') { |
614 | - $status_tab = $this->encode ( $table ); |
|
615 | - $status ['table'] = "'" . $status_tab . "'"; |
|
614 | + $status_tab = $this->encode($table); |
|
615 | + $status ['table'] = "'".$status_tab."'"; |
|
616 | 616 | if ($status ['status'] == 0) { |
617 | - $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> |
|
618 | - <label class="onoffswitch-label" for=switch' . $status ["id"] . '> |
|
617 | + $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> |
|
618 | + <label class="onoffswitch-label" for=switch' . $status ["id"].'> |
|
619 | 619 | <span class="onoffswitch-inner"></span> |
620 | 620 | </label></div>'; |
621 | 621 | } else { |
622 | - $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'] . ')"> |
|
623 | - <label class="onoffswitch-label" for=switch' . $status ["id"] . '> |
|
622 | + $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'].')"> |
|
623 | + <label class="onoffswitch-label" for=switch' . $status ["id"].'> |
|
624 | 624 | <span class="onoffswitch-inner"></span> |
625 | 625 | </label></div>'; |
626 | 626 | } |
@@ -636,7 +636,7 @@ discard block |
||
636 | 636 | return ($status == 0) ? "Yes" : "No"; |
637 | 637 | } |
638 | 638 | function get_import_status($status) { |
639 | - return strtolower ( trim ( $status ) ) == 'active' ? 0 : 1; |
|
639 | + return strtolower(trim($status)) == 'active' ? 0 : 1; |
|
640 | 640 | } |
641 | 641 | function get_did_status($select, $table, $status) { |
642 | 642 | 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>"; |
@@ -647,83 +647,83 @@ discard block |
||
647 | 647 | * @param string $select |
648 | 648 | */ |
649 | 649 | function get_invoice_date($select, $accountid = 0, $reseller_id, $order_by = 'id') { |
650 | - $where = array ( |
|
650 | + $where = array( |
|
651 | 651 | "reseller_id" => $reseller_id |
652 | 652 | ); |
653 | 653 | if ($accountid > 0) { |
654 | 654 | $where ['accountid'] = $accountid; |
655 | 655 | |
656 | 656 | // Patch to fetch correct invoice date for postpaid customer |
657 | - $posttoexternal = $this->get_field_name ( "posttoexternal", "accounts", array ( |
|
657 | + $posttoexternal = $this->get_field_name("posttoexternal", "accounts", array( |
|
658 | 658 | "id" => $accountid |
659 | - ) ); |
|
659 | + )); |
|
660 | 660 | if ($posttoexternal == 1) |
661 | 661 | $where ['type'] = "I"; |
662 | 662 | } |
663 | - $invoice_res = $this->CI->db_model->select ( $select, "invoices", $where, $order_by, "DESC", "1", "0" ); |
|
663 | + $invoice_res = $this->CI->db_model->select($select, "invoices", $where, $order_by, "DESC", "1", "0"); |
|
664 | 664 | if ($invoice_res->num_rows > 0) { |
665 | - $invoice_info = ( array ) $invoice_res->first_row (); |
|
665 | + $invoice_info = (array)$invoice_res->first_row(); |
|
666 | 666 | return $invoice_info [$select]; |
667 | 667 | } |
668 | 668 | return false; |
669 | 669 | } |
670 | 670 | function convert_to_date($select = '', $table = '', $from_date) { |
671 | - $from_date = date ( 'Y-m-d', strtotime ( $from_date ) ); |
|
671 | + $from_date = date('Y-m-d', strtotime($from_date)); |
|
672 | 672 | return $from_date; |
673 | 673 | } |
674 | 674 | function get_account_balance($select = "", $table = "", $amount) { |
675 | - $this->CI->load->model ( 'common_model' ); |
|
675 | + $this->CI->load->model('common_model'); |
|
676 | 676 | if ($amount == 0) { |
677 | 677 | return $amount; |
678 | 678 | } else { |
679 | - $balance = $this->CI->common_model->add_calculate_currency ( ($amount), "", '', true, true ); |
|
679 | + $balance = $this->CI->common_model->add_calculate_currency(($amount), "", '', true, true); |
|
680 | 680 | |
681 | 681 | return $balance; |
682 | 682 | } |
683 | 683 | } |
684 | 684 | function convert_to_currency($select = "", $table = "", $amount) { |
685 | - $this->CI->load->model ( 'common_model' ); |
|
686 | - return $this->CI->common_model->calculate_currency ( $amount, '', '', true, false ); |
|
685 | + $this->CI->load->model('common_model'); |
|
686 | + return $this->CI->common_model->calculate_currency($amount, '', '', true, false); |
|
687 | 687 | } |
688 | 688 | function account_number_icon($select = "", $table = "", $number) { |
689 | 689 | $return_value = ''; |
690 | - $where = array ( |
|
690 | + $where = array( |
|
691 | 691 | 'number' => $number |
692 | 692 | ); |
693 | - $account_res = ( array ) $this->CI->db->get_where ( "accounts", $where )->first_row (); |
|
693 | + $account_res = (array)$this->CI->db->get_where("accounts", $where)->first_row(); |
|
694 | 694 | if ($account_res ['type'] == 0) { |
695 | - $return_value = '<div class="flx_font flx_magenta" title="Customer">C</div>' . " <span title='Edit'>" . $account_res ['number'] . " </span>"; |
|
695 | + $return_value = '<div class="flx_font flx_magenta" title="Customer">C</div>'." <span title='Edit'>".$account_res ['number']." </span>"; |
|
696 | 696 | } |
697 | 697 | if ($account_res ['type'] == 3) { |
698 | - $return_value = '<div class="flx_font flx_blue" title="Provider">P</div>' . " <span title='Edit'>" . $account_res ['number'] . " </span>"; |
|
698 | + $return_value = '<div class="flx_font flx_blue" title="Provider">P</div>'." <span title='Edit'>".$account_res ['number']." </span>"; |
|
699 | 699 | } |
700 | 700 | if ($account_res ['type'] == - 1 || $account_res ['type'] == 2) { |
701 | - $return_value = '<div class="flx_font flx_pink" title="Admin">A</div>' . " <span title='Edit'>" . $account_res ['number'] . " </span>"; |
|
701 | + $return_value = '<div class="flx_font flx_pink" title="Admin">A</div>'." <span title='Edit'>".$account_res ['number']." </span>"; |
|
702 | 702 | } |
703 | 703 | if ($account_res ['type'] == 4) { |
704 | - $return_value = '<div class="flx_font flx_purple" title="Subadmin">S</div>' . " <span title='Edit'>" . $account_res ['number'] . " </span>"; |
|
704 | + $return_value = '<div class="flx_font flx_purple" title="Subadmin">S</div>'." <span title='Edit'>".$account_res ['number']." </span>"; |
|
705 | 705 | } |
706 | 706 | return $return_value; |
707 | 707 | } |
708 | 708 | function convert_to_currency_account($select = "", $table = "", $amount) { |
709 | - $this->CI->load->model ( 'common_model' ); |
|
710 | - return $this->CI->common_model->calculate_currency_customer ( $amount ); |
|
709 | + $this->CI->load->model('common_model'); |
|
710 | + return $this->CI->common_model->calculate_currency_customer($amount); |
|
711 | 711 | } |
712 | 712 | function get_paid_status($select = "", $table = "", $status) { |
713 | 713 | return ($status == 1) ? "Paid" : "Unpaid"; |
714 | 714 | } |
715 | 715 | function set_account_type($status = '') { |
716 | - $status_array = array ( |
|
717 | - '0' => gettext ( 'Prepaid' ), |
|
718 | - '1' => gettext ( 'Postpaid' ) |
|
716 | + $status_array = array( |
|
717 | + '0' => gettext('Prepaid'), |
|
718 | + '1' => gettext('Postpaid') |
|
719 | 719 | ); |
720 | 720 | return $status_array; |
721 | 721 | } |
722 | 722 | function set_account_type_search($status = '') { |
723 | - $status_array = array ( |
|
724 | - '' => gettext ( "--Select--" ), |
|
725 | - '0' => gettext ( 'Prepaid' ), |
|
726 | - '1' => gettext ( 'Postpaid' ) |
|
723 | + $status_array = array( |
|
724 | + '' => gettext("--Select--"), |
|
725 | + '0' => gettext('Prepaid'), |
|
726 | + '1' => gettext('Postpaid') |
|
727 | 727 | ); |
728 | 728 | return $status_array; |
729 | 729 | } |
@@ -741,7 +741,7 @@ discard block |
||
741 | 741 | $type = "Admin"; |
742 | 742 | } else { |
743 | 743 | // $type = $this->get_field_name("number", "accounts", array("id" => $type)); |
744 | - $type = $this->build_concat_string ( $select, $table, $type ); |
|
744 | + $type = $this->build_concat_string($select, $table, $type); |
|
745 | 745 | } |
746 | 746 | return $type; |
747 | 747 | } |
@@ -753,9 +753,9 @@ discard block |
||
753 | 753 | if ($type == '-1') { |
754 | 754 | $type = "Admin"; |
755 | 755 | } else { |
756 | - $type = $this->get_field_name ( "number", "accounts", array ( |
|
756 | + $type = $this->get_field_name("number", "accounts", array( |
|
757 | 757 | "id" => $type |
758 | - ) ); |
|
758 | + )); |
|
759 | 759 | } |
760 | 760 | return $type; |
761 | 761 | } |
@@ -763,58 +763,58 @@ discard block |
||
763 | 763 | /* |
764 | 764 | * Recharge to Refill |
765 | 765 | */ |
766 | - $status_array = array ( |
|
767 | - '0' => gettext ( 'Refill' ), |
|
768 | - '1' => gettext ( 'Postcharge' ) |
|
766 | + $status_array = array( |
|
767 | + '0' => gettext('Refill'), |
|
768 | + '1' => gettext('Postcharge') |
|
769 | 769 | ); |
770 | 770 | return $status_array; |
771 | 771 | } |
772 | 772 | function search_int_type($status = '') { |
773 | - $status_array = array ( |
|
774 | - '1' => gettext ( 'Is Equal To' ), |
|
775 | - '2' => gettext ( 'Is Not Equal To' ), |
|
776 | - '3' => gettext ( 'Greater Than' ), |
|
777 | - '4' => gettext ( 'Less Than' ), |
|
778 | - '5' => gettext ( 'Greater Or Equal Than' ), |
|
779 | - '6' => gettext ( 'Less Or Equal Than' ) |
|
773 | + $status_array = array( |
|
774 | + '1' => gettext('Is Equal To'), |
|
775 | + '2' => gettext('Is Not Equal To'), |
|
776 | + '3' => gettext('Greater Than'), |
|
777 | + '4' => gettext('Less Than'), |
|
778 | + '5' => gettext('Greater Or Equal Than'), |
|
779 | + '6' => gettext('Less Or Equal Than') |
|
780 | 780 | ); |
781 | 781 | return $status_array; |
782 | 782 | } |
783 | 783 | function update_int_type($status = '') { |
784 | - $status_array = array ( |
|
785 | - '1' => gettext ( 'Preserve' ), |
|
786 | - '2' => gettext ( 'Set To' ), |
|
787 | - '3' => gettext ( 'Increase By' ), |
|
788 | - '4' => gettext ( 'Decrease By' ) |
|
784 | + $status_array = array( |
|
785 | + '1' => gettext('Preserve'), |
|
786 | + '2' => gettext('Set To'), |
|
787 | + '3' => gettext('Increase By'), |
|
788 | + '4' => gettext('Decrease By') |
|
789 | 789 | ); |
790 | 790 | return $status_array; |
791 | 791 | } |
792 | 792 | function update_drp_type($status = '') { |
793 | - $status_array = array ( |
|
794 | - '1' => gettext ( 'Preserve' ), |
|
795 | - '2' => gettext ( 'Set To' ) |
|
793 | + $status_array = array( |
|
794 | + '1' => gettext('Preserve'), |
|
795 | + '2' => gettext('Set To') |
|
796 | 796 | ); |
797 | 797 | return $status_array; |
798 | 798 | } |
799 | 799 | function search_string_type($status = '') { |
800 | - $status_array = array ( |
|
801 | - '5' => gettext ( "Begins With" ), |
|
802 | - '1' => gettext ( 'Contains' ), |
|
803 | - '2' => gettext ( 'Doesnt Contain' ), |
|
804 | - '3' => gettext ( 'Is Equal To' ), |
|
805 | - '4' => gettext ( 'Is Not Equal To' ), |
|
806 | - "6" => gettext ( "Ends With" ) |
|
800 | + $status_array = array( |
|
801 | + '5' => gettext("Begins With"), |
|
802 | + '1' => gettext('Contains'), |
|
803 | + '2' => gettext('Doesnt Contain'), |
|
804 | + '3' => gettext('Is Equal To'), |
|
805 | + '4' => gettext('Is Not Equal To'), |
|
806 | + "6" => gettext("Ends With") |
|
807 | 807 | ); |
808 | 808 | return $status_array; |
809 | 809 | } |
810 | 810 | function set_protocal($protpcal = '') { |
811 | - $status_array = array ( |
|
812 | - 'SIP' => gettext ( 'SIP' ), |
|
813 | - 'IAX2' => gettext ( 'IAX2' ), |
|
814 | - 'Zap' => gettext ( 'Zap' ), |
|
815 | - 'Local' => gettext ( 'Local' ), |
|
816 | - 'OH323' => gettext ( 'OH323' ), |
|
817 | - 'OOH323C' => gettext ( 'OOH323C' ) |
|
811 | + $status_array = array( |
|
812 | + 'SIP' => gettext('SIP'), |
|
813 | + 'IAX2' => gettext('IAX2'), |
|
814 | + 'Zap' => gettext('Zap'), |
|
815 | + 'Local' => gettext('Local'), |
|
816 | + 'OH323' => gettext('OH323'), |
|
817 | + 'OOH323C' => gettext('OOH323C') |
|
818 | 818 | ); |
819 | 819 | return $status_array; |
820 | 820 | } |
@@ -825,32 +825,32 @@ discard block |
||
825 | 825 | * Version 2.1 |
826 | 826 | */ |
827 | 827 | function set_notify_by($status = '') { |
828 | - $status_array = array ( |
|
829 | - '' => gettext ( 'Select Notify By' ), |
|
830 | - '0' => gettext ( 'CSV' ), |
|
831 | - '1' => gettext ( 'Email' ) |
|
828 | + $status_array = array( |
|
829 | + '' => gettext('Select Notify By'), |
|
830 | + '0' => gettext('CSV'), |
|
831 | + '1' => gettext('Email') |
|
832 | 832 | ); |
833 | 833 | return $status_array; |
834 | 834 | } |
835 | 835 | function convert_to_percentage($select = "", $table = "", $amount) { |
836 | - return round ( $amount, 2 ) . " %"; |
|
836 | + return round($amount, 2)." %"; |
|
837 | 837 | } |
838 | 838 | function convert_to_minutes($select = "", $table = "", $amount) { |
839 | - return str_replace ( '.', ':', round ( $amount / 60, 2 ) ); |
|
839 | + return str_replace('.', ':', round($amount / 60, 2)); |
|
840 | 840 | } |
841 | 841 | function set_filter_type_search($status = '') { |
842 | - $status_array = array ( |
|
843 | - 'pricelist_id' => gettext ( 'Rate Group' ), |
|
844 | - 'accountid' => gettext ( 'Customer' ), |
|
845 | - 'reseller_id' => gettext ( 'Reseller' ) |
|
842 | + $status_array = array( |
|
843 | + 'pricelist_id' => gettext('Rate Group'), |
|
844 | + 'accountid' => gettext('Customer'), |
|
845 | + 'reseller_id' => gettext('Reseller') |
|
846 | 846 | ); |
847 | 847 | return $status_array; |
848 | 848 | } |
849 | 849 | function set_routetype_status($select = '') { |
850 | - $status_array = array ( |
|
851 | - "" => gettext ( "--Select--" ), |
|
852 | - "0" => gettext ( "LCR" ), |
|
853 | - "1" => gettext ( "COST" ) |
|
850 | + $status_array = array( |
|
851 | + "" => gettext("--Select--"), |
|
852 | + "0" => gettext("LCR"), |
|
853 | + "1" => gettext("COST") |
|
854 | 854 | ); |
855 | 855 | return $status_array; |
856 | 856 | } |
@@ -858,11 +858,11 @@ discard block |
||
858 | 858 | // attachment download in email module... |
859 | 859 | function attachment_icons($select = "", $table = "", $attachement = "") { |
860 | 860 | if ($attachement != "") { |
861 | - $array = explode ( ",", $attachement ); |
|
861 | + $array = explode(",", $attachement); |
|
862 | 862 | $str = ''; |
863 | - foreach ( $array as $key => $val ) { |
|
864 | - $link = base_url () . "email/email_history_list_attachment/" . $val; |
|
865 | - $str .= "<a href='" . $link . "' title='" . $val . "' class='btn btn-royelblue btn-sm'><i class='fa fa-paperclip fa-fw'></i></a> "; |
|
863 | + foreach ($array as $key => $val) { |
|
864 | + $link = base_url()."email/email_history_list_attachment/".$val; |
|
865 | + $str .= "<a href='".$link."' title='".$val."' class='btn btn-royelblue btn-sm'><i class='fa fa-paperclip fa-fw'></i></a> "; |
|
866 | 866 | } |
867 | 867 | return $str; |
868 | 868 | } else { |
@@ -872,7 +872,7 @@ discard block |
||
872 | 872 | |
873 | 873 | /* * ************************************************************* */ |
874 | 874 | function set_despostion($dis = '') { |
875 | - $status_array = array ( |
|
875 | + $status_array = array( |
|
876 | 876 | "" => "--Select Disposition--", |
877 | 877 | "ACCOUNT_INACTIVE_DELETED" => "ACCOUNT_INACTIVE_DELETED", |
878 | 878 | "ACCOUNT_EXPIRE" => "ACCOUNT_EXPIRE", |
@@ -922,122 +922,122 @@ discard block |
||
922 | 922 | return $status_array; |
923 | 923 | } |
924 | 924 | function set_calltype($type = '') { |
925 | - $status_array = array ( |
|
926 | - "" => gettext ( "--Select Type--" ), |
|
927 | - "STANDARD" => gettext ( "STANDARD" ), |
|
928 | - "DID" => gettext ( "DID" ), |
|
929 | - "CALLINGCARD" => gettext ( "CALLINGCARD" ), |
|
930 | - "FREE" => gettext ( "FREE" ) |
|
925 | + $status_array = array( |
|
926 | + "" => gettext("--Select Type--"), |
|
927 | + "STANDARD" => gettext("STANDARD"), |
|
928 | + "DID" => gettext("DID"), |
|
929 | + "CALLINGCARD" => gettext("CALLINGCARD"), |
|
930 | + "FREE" => gettext("FREE") |
|
931 | 931 | ); |
932 | 932 | return $status_array; |
933 | 933 | } |
934 | 934 | function set_search_status($select = '') { |
935 | - $status_array = array ( |
|
936 | - "" => gettext ( "--Select--" ), |
|
937 | - "0" => gettext ( "Active" ), |
|
938 | - "1" => gettext ( "Inactive" ) |
|
935 | + $status_array = array( |
|
936 | + "" => gettext("--Select--"), |
|
937 | + "0" => gettext("Active"), |
|
938 | + "1" => gettext("Inactive") |
|
939 | 939 | ); |
940 | 940 | return $status_array; |
941 | 941 | } |
942 | 942 | function set_Billing_Schedule_status($select = '') { |
943 | - $status_array = array ( |
|
944 | - "" => gettext ( "--Select--" ), |
|
945 | - "0" => gettext ( "Daily" ), |
|
946 | - "2" => gettext ( "Monthly" ) |
|
943 | + $status_array = array( |
|
944 | + "" => gettext("--Select--"), |
|
945 | + "0" => gettext("Daily"), |
|
946 | + "2" => gettext("Monthly") |
|
947 | 947 | ); |
948 | 948 | return $status_array; |
949 | 949 | } |
950 | 950 | function get_action_buttons($buttons_arr, $linkid) { |
951 | 951 | $ret_url = ''; |
952 | - if (! empty ( $buttons_arr ) && $buttons_arr != '') { |
|
953 | - foreach ( $buttons_arr as $button_key => $buttons_params ) { |
|
954 | - if (strtoupper ( $button_key ) == "EDIT") { |
|
955 | - $ret_url .= $this->build_edit_button ( $buttons_params, $linkid ); |
|
952 | + if ( ! empty ($buttons_arr) && $buttons_arr != '') { |
|
953 | + foreach ($buttons_arr as $button_key => $buttons_params) { |
|
954 | + if (strtoupper($button_key) == "EDIT") { |
|
955 | + $ret_url .= $this->build_edit_button($buttons_params, $linkid); |
|
956 | 956 | } |
957 | 957 | /* |
958 | 958 | * |
959 | 959 | * Purpose : Add resend link |
960 | 960 | * Version 2.1 |
961 | 961 | */ |
962 | - if (strtoupper ( $button_key ) == "RESEND") { |
|
963 | - $ret_url .= $this->build_edit_button_resend ( $buttons_params, $linkid ); |
|
962 | + if (strtoupper($button_key) == "RESEND") { |
|
963 | + $ret_url .= $this->build_edit_button_resend($buttons_params, $linkid); |
|
964 | 964 | } |
965 | 965 | /* * ************************************* */ |
966 | - if (strtoupper ( $button_key ) == "EDIT_RESTORE") { |
|
967 | - $ret_url .= $this->build_edit_button_restore ( $buttons_params, $linkid ); |
|
966 | + if (strtoupper($button_key) == "EDIT_RESTORE") { |
|
967 | + $ret_url .= $this->build_edit_button_restore($buttons_params, $linkid); |
|
968 | 968 | } |
969 | - if (strtoupper ( $button_key ) == "DELETE") { |
|
970 | - $ret_url .= $this->build_delete_button ( $buttons_params->url, $linkid ); |
|
969 | + if (strtoupper($button_key) == "DELETE") { |
|
970 | + $ret_url .= $this->build_delete_button($buttons_params->url, $linkid); |
|
971 | 971 | } |
972 | - if (strtoupper ( $button_key ) == "VIEW") { |
|
973 | - $ret_url .= $this->build_view_button ( $buttons_params, $linkid ); |
|
972 | + if (strtoupper($button_key) == "VIEW") { |
|
973 | + $ret_url .= $this->build_view_button($buttons_params, $linkid); |
|
974 | 974 | } |
975 | - if (strtoupper ( $button_key ) == "TAXES") { |
|
976 | - $ret_url .= $this->build_add_taxes_button ( $buttons_params, $linkid ); |
|
975 | + if (strtoupper($button_key) == "TAXES") { |
|
976 | + $ret_url .= $this->build_add_taxes_button($buttons_params, $linkid); |
|
977 | 977 | } |
978 | - if (strtoupper ( $button_key ) == "BLUEBOX_LOGIN") { |
|
979 | - $ret_url .= $this->build_bluebox_login ( $buttons_params->url, $linkid ); |
|
978 | + if (strtoupper($button_key) == "BLUEBOX_LOGIN") { |
|
979 | + $ret_url .= $this->build_bluebox_login($buttons_params->url, $linkid); |
|
980 | 980 | } |
981 | - if (strtoupper ( $button_key ) == "CALLERID") { |
|
982 | - $ret_url .= $this->build_add_callerid_button ( $buttons_params, $linkid ); |
|
981 | + if (strtoupper($button_key) == "CALLERID") { |
|
982 | + $ret_url .= $this->build_add_callerid_button($buttons_params, $linkid); |
|
983 | 983 | } |
984 | - if (strtoupper ( $button_key ) == "PAYMENT") { |
|
985 | - $ret_url .= $this->build_add_payment_button ( $buttons_params->url, $linkid ); |
|
984 | + if (strtoupper($button_key) == "PAYMENT") { |
|
985 | + $ret_url .= $this->build_add_payment_button($buttons_params->url, $linkid); |
|
986 | 986 | } |
987 | - if (strtoupper ( $button_key ) == "DOWNLOAD") { |
|
988 | - $ret_url .= $this->build_add_download_button ( $buttons_params->url, $linkid ); |
|
987 | + if (strtoupper($button_key) == "DOWNLOAD") { |
|
988 | + $ret_url .= $this->build_add_download_button($buttons_params->url, $linkid); |
|
989 | 989 | } |
990 | - if (strtoupper ( $button_key ) == "START") { |
|
991 | - $ret_url .= $this->build_start_button ( $buttons_params->url, $linkid ); |
|
990 | + if (strtoupper($button_key) == "START") { |
|
991 | + $ret_url .= $this->build_start_button($buttons_params->url, $linkid); |
|
992 | 992 | } |
993 | - if (strtoupper ( $button_key ) == "STOP") { |
|
994 | - $ret_url .= $this->build_stop_button ( $buttons_params->url, $linkid ); |
|
993 | + if (strtoupper($button_key) == "STOP") { |
|
994 | + $ret_url .= $this->build_stop_button($buttons_params->url, $linkid); |
|
995 | 995 | } |
996 | - if (strtoupper ( $button_key ) == "RELOAD") { |
|
997 | - $ret_url .= $this->build_reload_button ( $buttons_params->url, $linkid ); |
|
996 | + if (strtoupper($button_key) == "RELOAD") { |
|
997 | + $ret_url .= $this->build_reload_button($buttons_params->url, $linkid); |
|
998 | 998 | } |
999 | - if (strtoupper ( $button_key ) == "RESCAN") { |
|
1000 | - $ret_url .= $this->build_rescan_button ( $buttons_params->url, $linkid ); |
|
999 | + if (strtoupper($button_key) == "RESCAN") { |
|
1000 | + $ret_url .= $this->build_rescan_button($buttons_params->url, $linkid); |
|
1001 | 1001 | } |
1002 | 1002 | |
1003 | - if (strtoupper ( $button_key ) == "DOWNLOAD_DATABASE") { |
|
1004 | - $ret_url .= $this->build_add_download_database_button ( $buttons_params->url, $linkid ); |
|
1003 | + if (strtoupper($button_key) == "DOWNLOAD_DATABASE") { |
|
1004 | + $ret_url .= $this->build_add_download_database_button($buttons_params->url, $linkid); |
|
1005 | 1005 | } |
1006 | - if (strtoupper ( $button_key ) == "DELETE_ANIMAP") { |
|
1007 | - $ret_url .= $this->build_delete_button_animap ( $buttons_params->url, $linkid ); |
|
1006 | + if (strtoupper($button_key) == "DELETE_ANIMAP") { |
|
1007 | + $ret_url .= $this->build_delete_button_animap($buttons_params->url, $linkid); |
|
1008 | 1008 | } |
1009 | - if (strtoupper ( $button_key ) == "EDIT_ANIMAP") { |
|
1010 | - $ret_url .= $this->build_edit_button_animap ( $buttons_params, $linkid ); |
|
1009 | + if (strtoupper($button_key) == "EDIT_ANIMAP") { |
|
1010 | + $ret_url .= $this->build_edit_button_animap($buttons_params, $linkid); |
|
1011 | 1011 | } |
1012 | - if (strtoupper ( $button_key ) == "ANIMAP") { |
|
1013 | - $ret_url .= $this->build_animap_button ( $buttons_params, $linkid ); |
|
1012 | + if (strtoupper($button_key) == "ANIMAP") { |
|
1013 | + $ret_url .= $this->build_animap_button($buttons_params, $linkid); |
|
1014 | 1014 | } |
1015 | 1015 | } |
1016 | 1016 | } |
1017 | 1017 | return $ret_url; |
1018 | 1018 | } |
1019 | 1019 | function build_delete_button_animap($url, $linkid) { |
1020 | - $link = base_url () . $url . "" . $linkid; |
|
1021 | - 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>'; |
|
1020 | + $link = base_url().$url."".$linkid; |
|
1021 | + 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>'; |
|
1022 | 1022 | } |
1023 | 1023 | function build_edit_button_animap($button_params, $linkid) { |
1024 | - $link = base_url () . $button_params->url . "" . $linkid; |
|
1025 | - 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> '; |
|
1024 | + $link = base_url().$button_params->url."".$linkid; |
|
1025 | + 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> '; |
|
1026 | 1026 | } |
1027 | 1027 | function build_animap_button($button_params, $linkid) { |
1028 | - $link = base_url () . $button_params->url . "" . $linkid; |
|
1029 | - 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> '; |
|
1028 | + $link = base_url().$button_params->url."".$linkid; |
|
1029 | + 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> '; |
|
1030 | 1030 | } |
1031 | 1031 | function build_edit_button($button_params, $linkid) { |
1032 | - $link = base_url () . $button_params->url . "" . $linkid; |
|
1032 | + $link = base_url().$button_params->url."".$linkid; |
|
1033 | 1033 | |
1034 | 1034 | if ($button_params->mode == 'popup') { |
1035 | - $rel = (isset ( $button_params->layout ) && $button_params->layout != '') ? "facebox_" . $button_params->layout : "facebox"; |
|
1036 | - 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> '; |
|
1037 | - } else if (strpos ( $link, 'customer_edit' ) !== false) { |
|
1038 | - return '<a href="' . $link . '" class="btn btn-royelblue btn-sm" title="Edit"><i class="fa fa-pencil-square-o fa-fw"></i></a> '; |
|
1035 | + $rel = (isset ($button_params->layout) && $button_params->layout != '') ? "facebox_".$button_params->layout : "facebox"; |
|
1036 | + 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> '; |
|
1037 | + } else if (strpos($link, 'customer_edit') !== false) { |
|
1038 | + return '<a href="'.$link.'" class="btn btn-royelblue btn-sm" title="Edit"><i class="fa fa-pencil-square-o fa-fw"></i></a> '; |
|
1039 | 1039 | } else { |
1040 | - return '<a href="' . $link . '" class="btn btn-royelblue btn-sm" title="Edit"><i class="fa fa-pencil-square-o fa-fw"></i></a> '; |
|
1040 | + return '<a href="'.$link.'" class="btn btn-royelblue btn-sm" title="Edit"><i class="fa fa-pencil-square-o fa-fw"></i></a> '; |
|
1041 | 1041 | } |
1042 | 1042 | } |
1043 | 1043 | |
@@ -1045,18 +1045,18 @@ discard block |
||
1045 | 1045 | * For Edit on Account number or name |
1046 | 1046 | */ |
1047 | 1047 | function build_custome_edit_button($button_params, $field, $linkid) { |
1048 | - $link = base_url () . $button_params->url . "" . $linkid; |
|
1049 | - if (isset ( $button_params->layout )) { |
|
1048 | + $link = base_url().$button_params->url."".$linkid; |
|
1049 | + if (isset ($button_params->layout)) { |
|
1050 | 1050 | if ($button_params->mode == 'popup') { |
1051 | - return '<a href="' . $link . '" style="cursor:pointer;color:#005298;" rel="facebox_medium" title="Update">' . $field . '</a> '; |
|
1051 | + return '<a href="'.$link.'" style="cursor:pointer;color:#005298;" rel="facebox_medium" title="Update">'.$field.'</a> '; |
|
1052 | 1052 | } else { |
1053 | - return '<a href="' . $link . '" style="cursor:pointer;color:#005298;" title="Edit">' . $field . '</a> '; |
|
1053 | + return '<a href="'.$link.'" style="cursor:pointer;color:#005298;" title="Edit">'.$field.'</a> '; |
|
1054 | 1054 | } |
1055 | 1055 | } else { |
1056 | 1056 | if ($button_params->mode == 'popup') { |
1057 | - return '<a href="' . $link . '" style="cursor:pointer;color:#005298;" rel="facebox" title="Update">' . $field . '</a> '; |
|
1057 | + return '<a href="'.$link.'" style="cursor:pointer;color:#005298;" rel="facebox" title="Update">'.$field.'</a> '; |
|
1058 | 1058 | } else { |
1059 | - return '<a href="' . $link . '" style="cursor:pointer;color:#005298;" title="Edit">' . $field . '</a> '; |
|
1059 | + return '<a href="'.$link.'" style="cursor:pointer;color:#005298;" title="Edit">'.$field.'</a> '; |
|
1060 | 1060 | } |
1061 | 1061 | } |
1062 | 1062 | } |
@@ -1065,18 +1065,18 @@ discard block |
||
1065 | 1065 | * ********************************** |
1066 | 1066 | */ |
1067 | 1067 | function build_edit_button_restore($button_params, $linkid) { |
1068 | - $link = base_url () . $button_params->url . "" . $linkid; |
|
1068 | + $link = base_url().$button_params->url."".$linkid; |
|
1069 | 1069 | if ($button_params->mode == 'popup') { |
1070 | - 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> '; |
|
1070 | + 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> '; |
|
1071 | 1071 | } else { |
1072 | - 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> '; |
|
1072 | + 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> '; |
|
1073 | 1073 | } |
1074 | 1074 | } |
1075 | 1075 | function build_delete_button($url, $linkid) { |
1076 | 1076 | $flag = '0'; |
1077 | - $data = explode ( "/", $url ); |
|
1078 | - $link = base_url () . $url . "" . $linkid; |
|
1079 | - foreach ( $data as $key => $value ) { |
|
1077 | + $data = explode("/", $url); |
|
1078 | + $link = base_url().$url."".$linkid; |
|
1079 | + foreach ($data as $key => $value) { |
|
1080 | 1080 | if ($value == 'price_delete') |
1081 | 1081 | $flag = '1'; |
1082 | 1082 | if ($value == 'trunk_remove') |
@@ -1087,98 +1087,98 @@ discard block |
||
1087 | 1087 | $flag = '4'; |
1088 | 1088 | } |
1089 | 1089 | if ($flag == '1') { |
1090 | - $where = array ( |
|
1090 | + $where = array( |
|
1091 | 1091 | 'pricelist_id' => $linkid, |
1092 | 1092 | 'deleted !=' => '1' |
1093 | 1093 | ); |
1094 | - $customer_cnt = $this->get_field_count ( 'id', 'accounts', $where ); |
|
1095 | - $where = array ( |
|
1094 | + $customer_cnt = $this->get_field_count('id', 'accounts', $where); |
|
1095 | + $where = array( |
|
1096 | 1096 | 'pricelist_id' => $linkid |
1097 | 1097 | ); |
1098 | - $rategroup_cnt = $this->get_field_count ( 'id', 'routes', $where ); |
|
1098 | + $rategroup_cnt = $this->get_field_count('id', 'routes', $where); |
|
1099 | 1099 | if ($rategroup_cnt > 0 || $customer_cnt > 0) { |
1100 | 1100 | |
1101 | - 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>'; |
|
1101 | + 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>'; |
|
1102 | 1102 | } else { |
1103 | - 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>'; |
|
1103 | + 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>'; |
|
1104 | 1104 | } |
1105 | 1105 | } |
1106 | 1106 | if ($flag == '2') { |
1107 | - $where = array ( |
|
1107 | + $where = array( |
|
1108 | 1108 | 'trunk_id' => $linkid |
1109 | 1109 | ); |
1110 | - $trunk_cnt = $this->get_field_count ( 'id', 'outbound_routes', $where ); |
|
1110 | + $trunk_cnt = $this->get_field_count('id', 'outbound_routes', $where); |
|
1111 | 1111 | if ($trunk_cnt > 0) { |
1112 | - 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>'; |
|
1112 | + 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>'; |
|
1113 | 1113 | } else { |
1114 | - 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>'; |
|
1114 | + 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>'; |
|
1115 | 1115 | } |
1116 | 1116 | } |
1117 | 1117 | if ($flag == '3') { |
1118 | - return '<a href="' . $link . '" class="btn btn-royelblue btn-sm" title="Delete" onClick="return get_alert_message(0,null,' . $linkid . ',3);"> |
|
1118 | + return '<a href="'.$link.'" class="btn btn-royelblue btn-sm" title="Delete" onClick="return get_alert_message(0,null,'.$linkid.',3);"> |
|
1119 | 1119 | <i class="fa fa-trash fa-fw"></i></a>'; |
1120 | 1120 | } |
1121 | 1121 | if ($flag == '4') { |
1122 | - return '<a href="' . $link . '" class="btn btn-royelblue btn-sm" title="Delete" onClick="return get_alert_message(0,null,' . $linkid . ',4);"> |
|
1122 | + return '<a href="'.$link.'" class="btn btn-royelblue btn-sm" title="Delete" onClick="return get_alert_message(0,null,'.$linkid.',4);"> |
|
1123 | 1123 | <i class="fa fa-trash fa-fw"></i></a>'; |
1124 | 1124 | } |
1125 | - if ($flag == '0' && $url . $linkid != 'accounts/admin_delete/1') { |
|
1126 | - 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>'; |
|
1125 | + if ($flag == '0' && $url.$linkid != 'accounts/admin_delete/1') { |
|
1126 | + 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>'; |
|
1127 | 1127 | } |
1128 | 1128 | } |
1129 | 1129 | function build_view_button($button_params, $linkid) { |
1130 | - $link = base_url () . $button_params->url . "" . $linkid; |
|
1130 | + $link = base_url().$button_params->url."".$linkid; |
|
1131 | 1131 | if ($button_params->mode == 'popup') { |
1132 | - $rel = (isset ( $button_params->layout ) && $button_params->layout != '') ? "facebox_" . $button_params->layout : "facebox"; |
|
1133 | - return '<a href="' . $link . '" class="btn btn-royelblue btn-sm" rel="' . $rel . '" title="View Details"><i class="fa fa-reorder fa-fw"></i></a> '; |
|
1132 | + $rel = (isset ($button_params->layout) && $button_params->layout != '') ? "facebox_".$button_params->layout : "facebox"; |
|
1133 | + return '<a href="'.$link.'" class="btn btn-royelblue btn-sm" rel="'.$rel.'" title="View Details"><i class="fa fa-reorder fa-fw"></i></a> '; |
|
1134 | 1134 | } else { |
1135 | - return '<a href="' . $link . '" class="btn btn-royelblue btn-sm" title="View Details"><i class="fa fa-reorder fa-fw"></i></a> '; |
|
1135 | + return '<a href="'.$link.'" class="btn btn-royelblue btn-sm" title="View Details"><i class="fa fa-reorder fa-fw"></i></a> '; |
|
1136 | 1136 | } |
1137 | 1137 | } |
1138 | 1138 | function build_add_taxes_button($button_params, $linkid) { |
1139 | - $link = base_url () . $button_params->url . "" . $linkid; |
|
1139 | + $link = base_url().$button_params->url."".$linkid; |
|
1140 | 1140 | if ($button_params->mode == 'popup') { |
1141 | - 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> '; |
|
1141 | + 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> '; |
|
1142 | 1142 | } else { |
1143 | - return '<a href="' . $link . '" class="btn btn-royelblue btn-sm" title="Add Account Taxes"><i class="fa fa-reorder fa-fw"></i></a> '; |
|
1143 | + return '<a href="'.$link.'" class="btn btn-royelblue btn-sm" title="Add Account Taxes"><i class="fa fa-reorder fa-fw"></i></a> '; |
|
1144 | 1144 | } |
1145 | 1145 | } |
1146 | 1146 | function build_add_download_database_button($url, $linkid) { |
1147 | - $link = base_url () . $url . "" . $linkid; |
|
1148 | - return '<a href="' . $link . '" class="btn btn-royelblue btn-sm " title="Download Database" ><i class="fa-fw fa fa-file-archive-o"></i></a> '; |
|
1147 | + $link = base_url().$url."".$linkid; |
|
1148 | + return '<a href="'.$link.'" class="btn btn-royelblue btn-sm " title="Download Database" ><i class="fa-fw fa fa-file-archive-o"></i></a> '; |
|
1149 | 1149 | } |
1150 | 1150 | function build_add_callerid_button($button_params, $linkid) { |
1151 | - $link = base_url () . $button_params->url . "" . $linkid; |
|
1151 | + $link = base_url().$button_params->url."".$linkid; |
|
1152 | 1152 | if ($button_params->mode == 'popup') { |
1153 | - 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> '; |
|
1153 | + 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> '; |
|
1154 | 1154 | } else { |
1155 | - return '<a href="' . $link . '" class="btn btn-royelblue btn-sm" title="CallerID"><i class="fa fa-mobile-phone fa-fw"></i></a> '; |
|
1155 | + return '<a href="'.$link.'" class="btn btn-royelblue btn-sm" title="CallerID"><i class="fa fa-mobile-phone fa-fw"></i></a> '; |
|
1156 | 1156 | } |
1157 | 1157 | } |
1158 | 1158 | function build_start_button($url, $linkid) { |
1159 | - $link = base_url () . $url . "" . $linkid; |
|
1159 | + $link = base_url().$url."".$linkid; |
|
1160 | 1160 | |
1161 | - return '<a href="' . $link . '" class="" title="Start" style="text-decoration:none;color: #428BCA;"><b>Start |</b></a> '; |
|
1161 | + return '<a href="'.$link.'" class="" title="Start" style="text-decoration:none;color: #428BCA;"><b>Start |</b></a> '; |
|
1162 | 1162 | } |
1163 | 1163 | function build_stop_button($url, $linkid) { |
1164 | - $link = base_url () . $url . "" . $linkid; |
|
1165 | - return '<a href="' . $link . '" class="" title="Stop" style="text-decoration:none;color: #428BCA;" ><b>Stop |</b></a> '; |
|
1164 | + $link = base_url().$url."".$linkid; |
|
1165 | + return '<a href="'.$link.'" class="" title="Stop" style="text-decoration:none;color: #428BCA;" ><b>Stop |</b></a> '; |
|
1166 | 1166 | } |
1167 | 1167 | function build_reload_button($url, $linkid) { |
1168 | - $link = base_url () . $url . "" . $linkid; |
|
1169 | - return '<a href="' . $link . '" class="" title="reload" style="text-decoration:none;color: #428BCA;"><b>Reload |</b></a> '; |
|
1168 | + $link = base_url().$url."".$linkid; |
|
1169 | + return '<a href="'.$link.'" class="" title="reload" style="text-decoration:none;color: #428BCA;"><b>Reload |</b></a> '; |
|
1170 | 1170 | } |
1171 | 1171 | function build_rescan_button($url, $linkid) { |
1172 | - $link = base_url () . $url . "" . $linkid; |
|
1173 | - return '<a href="' . $link . '" class="" title="rescan" style="text-decoration:none;color: #428BCA;"><b>Rescan</b></a> '; |
|
1172 | + $link = base_url().$url."".$linkid; |
|
1173 | + return '<a href="'.$link.'" class="" title="rescan" style="text-decoration:none;color: #428BCA;"><b>Rescan</b></a> '; |
|
1174 | 1174 | } |
1175 | 1175 | function build_add_payment_button($url, $linkid) { |
1176 | - $link = base_url () . $url . "" . $linkid; |
|
1177 | - return '<a href="' . $link . '" class="btn btn-royelblue btn-sm" rel="facebox" title="Refill" ><i class="fa fa-usd fa-fw"></i></a> '; |
|
1176 | + $link = base_url().$url."".$linkid; |
|
1177 | + return '<a href="'.$link.'" class="btn btn-royelblue btn-sm" rel="facebox" title="Refill" ><i class="fa fa-usd fa-fw"></i></a> '; |
|
1178 | 1178 | } |
1179 | 1179 | function build_add_download_button($url, $linkid) { |
1180 | - $link = base_url () . $url . "" . $linkid; |
|
1181 | - return '<a href="' . $link . '" class="btn btn-royelblue btn-sm" title="Download Invoice" ><i class="fa fa-cloud-download fa-fw"></i></a> '; |
|
1180 | + $link = base_url().$url."".$linkid; |
|
1181 | + return '<a href="'.$link.'" class="btn btn-royelblue btn-sm" title="Download Invoice" ><i class="fa fa-cloud-download fa-fw"></i></a> '; |
|
1182 | 1182 | } |
1183 | 1183 | |
1184 | 1184 | /* |
@@ -1186,11 +1186,11 @@ discard block |
||
1186 | 1186 | * Version 2.1 |
1187 | 1187 | */ |
1188 | 1188 | function build_edit_button_resend($button_params, $linkid) { |
1189 | - $link = base_url () . $button_params->url . "" . $linkid; |
|
1189 | + $link = base_url().$button_params->url."".$linkid; |
|
1190 | 1190 | if ($button_params->mode == 'popup') { |
1191 | - return '<a href="' . $link . '" class="btn btn-royelblue btn-sm" rel="facebox" title="Resend Mail"><i class="fa fa-repeat"></i></a> '; |
|
1191 | + return '<a href="'.$link.'" class="btn btn-royelblue btn-sm" rel="facebox" title="Resend Mail"><i class="fa fa-repeat"></i></a> '; |
|
1192 | 1192 | } else { |
1193 | - return '<a href="' . $link . '" class="btn btn-royelblue btn-sm" title="Resend Mail"><i class="fa fa-repeat"></i></a> '; |
|
1193 | + return '<a href="'.$link.'" class="btn btn-royelblue btn-sm" title="Resend Mail"><i class="fa fa-repeat"></i></a> '; |
|
1194 | 1194 | } |
1195 | 1195 | } |
1196 | 1196 | |
@@ -1198,36 +1198,36 @@ discard block |
||
1198 | 1198 | * ---------------------------------------------------------------------------- |
1199 | 1199 | */ |
1200 | 1200 | function get_only_numeric_val($select = "", $table = "", $string) { |
1201 | - return filter_var ( $string, FILTER_SANITIZE_NUMBER_INT ); |
|
1201 | + return filter_var($string, FILTER_SANITIZE_NUMBER_INT); |
|
1202 | 1202 | } |
1203 | 1203 | function mail_to_users($type, $accountinfo, $attachment = "", $amount = "") { |
1204 | 1204 | $subject = ""; |
1205 | 1205 | $settings_reply_email = '[email protected]'; |
1206 | 1206 | $reseller_id = $accountinfo ['reseller_id'] > 0 ? $accountinfo ['reseller_id'] : 0; |
1207 | - $where = "accountid IN ('" . $reseller_id . "','1')"; |
|
1208 | - $this->CI->db->where ( $where ); |
|
1209 | - $this->CI->db->select ( 'emailaddress' ); |
|
1210 | - $this->CI->db->order_by ( 'accountid', 'desc' ); |
|
1211 | - $this->CI->db->limit ( 1 ); |
|
1212 | - $invoiceconf = $this->CI->db->get ( 'invoice_conf' ); |
|
1213 | - $invoiceconf = ( array ) $invoiceconf->first_row (); |
|
1207 | + $where = "accountid IN ('".$reseller_id."','1')"; |
|
1208 | + $this->CI->db->where($where); |
|
1209 | + $this->CI->db->select('emailaddress'); |
|
1210 | + $this->CI->db->order_by('accountid', 'desc'); |
|
1211 | + $this->CI->db->limit(1); |
|
1212 | + $invoiceconf = $this->CI->db->get('invoice_conf'); |
|
1213 | + $invoiceconf = (array)$invoiceconf->first_row(); |
|
1214 | 1214 | $settings_reply_email = $invoiceconf ['emailaddress']; |
1215 | 1215 | $company_name = Common_model::$global_config ['system_config'] ['company_name']; |
1216 | 1216 | $company_website = Common_model::$global_config ['system_config'] ['company_website']; |
1217 | - $where = array ( |
|
1217 | + $where = array( |
|
1218 | 1218 | 'name' => $type |
1219 | 1219 | ); |
1220 | - $query = $this->CI->db_model->getSelect ( "*", "default_templates", $where ); |
|
1221 | - $query = $query->result (); |
|
1220 | + $query = $this->CI->db_model->getSelect("*", "default_templates", $where); |
|
1221 | + $query = $query->result(); |
|
1222 | 1222 | $message = $query [0]->template; |
1223 | 1223 | $useremail = $accountinfo ['email']; |
1224 | - $message = html_entity_decode ( $message ); |
|
1225 | - $message = str_replace ( "#COMPANY_EMAIL#", $settings_reply_email, $message ); |
|
1226 | - $message = str_replace ( "#COMPANY_NAME#", $company_name, $message ); |
|
1227 | - $message = str_replace ( "#COMPANY_WEBSITE#", $company_website, $message ); |
|
1228 | - $message = str_replace ( "<p>", "", $message ); |
|
1229 | - $message = str_replace ( "</p>", "", $message ); |
|
1230 | - if (isset ( $accountinfo ['refill_amount'] ) && $accountinfo ['refill_amount'] != "") { |
|
1224 | + $message = html_entity_decode($message); |
|
1225 | + $message = str_replace("#COMPANY_EMAIL#", $settings_reply_email, $message); |
|
1226 | + $message = str_replace("#COMPANY_NAME#", $company_name, $message); |
|
1227 | + $message = str_replace("#COMPANY_WEBSITE#", $company_website, $message); |
|
1228 | + $message = str_replace("<p>", "", $message); |
|
1229 | + $message = str_replace("</p>", "", $message); |
|
1230 | + if (isset ($accountinfo ['refill_amount']) && $accountinfo ['refill_amount'] != "") { |
|
1231 | 1231 | $refillamount = $accountinfo ['refill_amount']; |
1232 | 1232 | } else { |
1233 | 1233 | $refillamount = "0"; |
@@ -1235,139 +1235,139 @@ discard block |
||
1235 | 1235 | |
1236 | 1236 | switch ($type) { |
1237 | 1237 | case 'email_add_user' : |
1238 | - $message = str_replace ( '#NAME#', $accountinfo ['first_name'] . " " . $accountinfo ['last_name'], $message ); |
|
1239 | - $message = str_replace ( '#NUMBER#', $accountinfo ['number'], $message ); |
|
1240 | - $message = str_replace ( '#PASSWORD#', $accountinfo ['password'], $message ); |
|
1241 | - $message = str_replace ( '#LINK#', $accountinfo ['confirm'], $message ); |
|
1238 | + $message = str_replace('#NAME#', $accountinfo ['first_name']." ".$accountinfo ['last_name'], $message); |
|
1239 | + $message = str_replace('#NUMBER#', $accountinfo ['number'], $message); |
|
1240 | + $message = str_replace('#PASSWORD#', $accountinfo ['password'], $message); |
|
1241 | + $message = str_replace('#LINK#', $accountinfo ['confirm'], $message); |
|
1242 | 1242 | break; |
1243 | 1243 | case 'email_forgot_user' : |
1244 | - $message = str_replace ( '#NAME#', $accountinfo ['first_name'] . " " . $accountinfo ['last_name'], $message ); |
|
1245 | - $message = str_replace ( '#NUMBER#', $accountinfo ['number'], $message ); |
|
1246 | - $message = str_replace ( '#PASSWORD#', $accountinfo ['password'], $message ); |
|
1247 | - $message = str_replace ( '#LINK#', $accountinfo ['link'], $message ); |
|
1244 | + $message = str_replace('#NAME#', $accountinfo ['first_name']." ".$accountinfo ['last_name'], $message); |
|
1245 | + $message = str_replace('#NUMBER#', $accountinfo ['number'], $message); |
|
1246 | + $message = str_replace('#PASSWORD#', $accountinfo ['password'], $message); |
|
1247 | + $message = str_replace('#LINK#', $accountinfo ['link'], $message); |
|
1248 | 1248 | break; |
1249 | 1249 | |
1250 | 1250 | case 'email_forgot_confirmation' : |
1251 | - $message = str_replace ( '#NAME#', $accountinfo ['first_name'] . " " . $accountinfo ['last_name'], $message ); |
|
1252 | - $message = str_replace ( '#CONFIRM#', $accountinfo ['confirm'], $message ); |
|
1251 | + $message = str_replace('#NAME#', $accountinfo ['first_name']." ".$accountinfo ['last_name'], $message); |
|
1252 | + $message = str_replace('#CONFIRM#', $accountinfo ['confirm'], $message); |
|
1253 | 1253 | break; |
1254 | 1254 | |
1255 | 1255 | case 'email_signup_confirmation' : |
1256 | - $message = str_replace ( '#NAME#', $accountinfo ['first_name'] . " " . $accountinfo ['last_name'], $message ); |
|
1257 | - $message = str_replace ( '#CONFIRM#', $accountinfo ['confirm'], $message ); |
|
1256 | + $message = str_replace('#NAME#', $accountinfo ['first_name']." ".$accountinfo ['last_name'], $message); |
|
1257 | + $message = str_replace('#CONFIRM#', $accountinfo ['confirm'], $message); |
|
1258 | 1258 | break; |
1259 | 1259 | case 'add_sip_device' : |
1260 | - $sip_profiles = ( array ) $this->CI->db->get ( 'sip_profiles' )->first_row (); |
|
1261 | - $profile_data = json_decode ( $sip_profiles ['profile_data'], true ); |
|
1260 | + $sip_profiles = (array)$this->CI->db->get('sip_profiles')->first_row(); |
|
1261 | + $profile_data = json_decode($sip_profiles ['profile_data'], true); |
|
1262 | 1262 | if (Common_model::$global_config ['system_config'] ['opensips'] == 0) { |
1263 | 1263 | $domain = Common_model::$global_config ['system_config'] ['opensips_domain']; |
1264 | 1264 | |
1265 | 1265 | $port = $sip_profiles ['sip_port']; |
1266 | 1266 | } else { |
1267 | - $fs_server = ( array ) $this->CI->db->get ( 'freeswich_servers' )->first_row (); |
|
1267 | + $fs_server = (array)$this->CI->db->get('freeswich_servers')->first_row(); |
|
1268 | 1268 | $domain = $fs_server ['freeswitch_host']; |
1269 | 1269 | $port = $fs_server ['freeswitch_port']; |
1270 | 1270 | } |
1271 | 1271 | $codec = $profile_data ['outbound-codec-prefs']; |
1272 | - $sip_info = "SIP Server : " . $domain . " SIP Port : " . $port . " Preferable codecs : " . $codec; |
|
1273 | - $message = str_replace ( '#NAME#', $accountinfo ['first_name'] . " " . $accountinfo ['last_name'], $message ); |
|
1274 | - $message = str_replace ( '#USERNAME#', $accountinfo ['number'], $message ); |
|
1275 | - $message = str_replace ( '#SIPHOST#', $sip_info, $message ); |
|
1276 | - $message = str_replace ( '#PASSWORD#', $accountinfo ['password'], $message ); |
|
1272 | + $sip_info = "SIP Server : ".$domain." SIP Port : ".$port." Preferable codecs : ".$codec; |
|
1273 | + $message = str_replace('#NAME#', $accountinfo ['first_name']." ".$accountinfo ['last_name'], $message); |
|
1274 | + $message = str_replace('#USERNAME#', $accountinfo ['number'], $message); |
|
1275 | + $message = str_replace('#SIPHOST#', $sip_info, $message); |
|
1276 | + $message = str_replace('#PASSWORD#', $accountinfo ['password'], $message); |
|
1277 | 1277 | break; |
1278 | 1278 | |
1279 | 1279 | case 'voip_account_refilled' : |
1280 | 1280 | $currency_id = $accountinfo ['currency_id']; |
1281 | - $currency = $this->CI->common->get_field_name ( 'currency', 'currency', $currency_id ); |
|
1282 | - $message = str_replace ( '#NAME#', $accountinfo ['first_name'] . " " . $accountinfo ['last_name'], $message ); |
|
1283 | - $message = str_replace ( '#REFILLBALANCE#', $this->convert_to_currency ( '', '', $accountinfo ['refill_amount'] ) . ' ' . $currency, $message ); |
|
1284 | - $message = str_replace ( '#BALANCE#', $this->convert_to_currency ( '', '', $accountinfo ['refill_amount_balance'] ) . ' ' . $currency, $message ); |
|
1281 | + $currency = $this->CI->common->get_field_name('currency', 'currency', $currency_id); |
|
1282 | + $message = str_replace('#NAME#', $accountinfo ['first_name']." ".$accountinfo ['last_name'], $message); |
|
1283 | + $message = str_replace('#REFILLBALANCE#', $this->convert_to_currency('', '', $accountinfo ['refill_amount']).' '.$currency, $message); |
|
1284 | + $message = str_replace('#BALANCE#', $this->convert_to_currency('', '', $accountinfo ['refill_amount_balance']).' '.$currency, $message); |
|
1285 | 1285 | break; |
1286 | 1286 | case 'voip_child_account_refilled' : |
1287 | - $reseller_number = $this->CI->common->get_field_name ( 'number', 'accounts', $accountinfo ['reseller_id'] ); |
|
1288 | - $message = str_replace ( '#NAME#', $accountinfo ['first_name'] . " " . $accountinfo ['last_name'], $message ); |
|
1289 | - $message = str_replace ( '#REFILLBALANCE#', $accountinfo ['refill_amount'], $message ); |
|
1290 | - $message = str_replace ( '#BALANCE#', $accountinfo ['balance'], $message ); |
|
1291 | - $message = str_replace ( '#ACCOUNTNUMBER#', $reseller_number, $message ); |
|
1287 | + $reseller_number = $this->CI->common->get_field_name('number', 'accounts', $accountinfo ['reseller_id']); |
|
1288 | + $message = str_replace('#NAME#', $accountinfo ['first_name']." ".$accountinfo ['last_name'], $message); |
|
1289 | + $message = str_replace('#REFILLBALANCE#', $accountinfo ['refill_amount'], $message); |
|
1290 | + $message = str_replace('#BALANCE#', $accountinfo ['balance'], $message); |
|
1291 | + $message = str_replace('#ACCOUNTNUMBER#', $reseller_number, $message); |
|
1292 | 1292 | break; |
1293 | 1293 | case 'add_subscription' : |
1294 | - $message = str_replace ( '#NAME#', $accountinfo ['first_name'] . " " . $accountinfo ['last_name'], $message ); |
|
1294 | + $message = str_replace('#NAME#', $accountinfo ['first_name']." ".$accountinfo ['last_name'], $message); |
|
1295 | 1295 | break; |
1296 | 1296 | case 'remove_subscription' : |
1297 | - $message = str_replace ( '#NAME#', $accountinfo ['first_name'] . " " . $accountinfo ['last_name'], $message ); |
|
1297 | + $message = str_replace('#NAME#', $accountinfo ['first_name']." ".$accountinfo ['last_name'], $message); |
|
1298 | 1298 | break; |
1299 | 1299 | case 'add_package' : |
1300 | - $message = str_replace ( '#NAME#', $accountinfo ['first_name'] . " " . $accountinfo ['last_name'], $message ); |
|
1300 | + $message = str_replace('#NAME#', $accountinfo ['first_name']." ".$accountinfo ['last_name'], $message); |
|
1301 | 1301 | break; |
1302 | 1302 | case 'remove_package' : |
1303 | - $message = str_replace ( '#NAME#', $accountinfo ['first_name'] . " " . $accountinfo ['last_name'], $message ); |
|
1303 | + $message = str_replace('#NAME#', $accountinfo ['first_name']." ".$accountinfo ['last_name'], $message); |
|
1304 | 1304 | break; |
1305 | 1305 | case 'email_calling_card' : |
1306 | - $message = str_replace ( '#NAME#', $accountinfo ['first_name'] . " " . $accountinfo ['last_name'], $message ); |
|
1307 | - $message = str_replace ( '#CARDNUMBER#', $accountinfo ['cardnumber'], $message ); |
|
1308 | - $message = str_replace ( '#PIN#', $accountinfo ['pin'], $message ); |
|
1309 | - $message = str_replace ( '#BALANCE#', $accountinfo ['balance'], $message ); |
|
1306 | + $message = str_replace('#NAME#', $accountinfo ['first_name']." ".$accountinfo ['last_name'], $message); |
|
1307 | + $message = str_replace('#CARDNUMBER#', $accountinfo ['cardnumber'], $message); |
|
1308 | + $message = str_replace('#PIN#', $accountinfo ['pin'], $message); |
|
1309 | + $message = str_replace('#BALANCE#', $accountinfo ['balance'], $message); |
|
1310 | 1310 | break; |
1311 | 1311 | case 'email_low_balance' : |
1312 | - $to_currency = $this->CI->common->get_field_name ( 'currency', 'currency', $accountinfo ['currency_id'] ); |
|
1312 | + $to_currency = $this->CI->common->get_field_name('currency', 'currency', $accountinfo ['currency_id']); |
|
1313 | 1313 | $balance = ($accountinfo ['posttoexternal'] == 1) ? ($accountinfo ["credit_limit"] - $accountinfo ["balance"]) : ($accountinfo ["balance"]); |
1314 | - $useremail = ! empty ( $accountinfo ['notify_email'] ) ? $accountinfo ['notify_email'] : $accountinfo ['email']; |
|
1315 | - $message = str_replace ( '#NAME#', $accountinfo ['first_name'] . " " . $accountinfo ['last_name'], $message ); |
|
1316 | - $message = str_replace ( '#AMOUNT#', $balance, $message ); |
|
1314 | + $useremail = ! empty ($accountinfo ['notify_email']) ? $accountinfo ['notify_email'] : $accountinfo ['email']; |
|
1315 | + $message = str_replace('#NAME#', $accountinfo ['first_name']." ".$accountinfo ['last_name'], $message); |
|
1316 | + $message = str_replace('#AMOUNT#', $balance, $message); |
|
1317 | 1317 | $subject = $query [0]->subject; |
1318 | - $subject = str_replace ( "#NUMBER#", $accountinfo ['number'], $subject ); |
|
1318 | + $subject = str_replace("#NUMBER#", $accountinfo ['number'], $subject); |
|
1319 | 1319 | break; |
1320 | 1320 | case 'email_new_invoice' : |
1321 | - $message = str_replace ( '#NAME#', $accountinfo ['first_name'] . " " . $accountinfo ['last_name'], $message ); |
|
1322 | - $message = str_replace ( '#AMOUNT#', $amount, $message ); |
|
1323 | - $message = str_replace ( '#INVOICE_NUMBER#', $amount, $message ); |
|
1321 | + $message = str_replace('#NAME#', $accountinfo ['first_name']." ".$accountinfo ['last_name'], $message); |
|
1322 | + $message = str_replace('#AMOUNT#', $amount, $message); |
|
1323 | + $message = str_replace('#INVOICE_NUMBER#', $amount, $message); |
|
1324 | 1324 | $subject = $query [0]->subject; |
1325 | - $subject = str_replace ( "#INVOICE_NUMBER#", $amount, $subject ); |
|
1325 | + $subject = str_replace("#INVOICE_NUMBER#", $amount, $subject); |
|
1326 | 1326 | break; |
1327 | 1327 | case 'email_add_did' : |
1328 | - if (isset ( $accountinfo ['did_maxchannels'] ) && $accountinfo ['did_maxchannels'] != "") { |
|
1328 | + if (isset ($accountinfo ['did_maxchannels']) && $accountinfo ['did_maxchannels'] != "") { |
|
1329 | 1329 | $accountinfo ['did_maxchannels'] = $accountinfo ['did_maxchannels']; |
1330 | 1330 | } else if ($accountinfo ['did_maxchannels'] == "0") { |
1331 | 1331 | $accountinfo ['did_maxchannels'] = "Unlimited"; |
1332 | 1332 | } else { |
1333 | 1333 | $accountinfo ['did_maxchannels'] = "Unlimited"; |
1334 | 1334 | } |
1335 | - $message = str_replace ( '#NAME#', $accountinfo ['first_name'] . " " . $accountinfo ['last_name'], $message ); |
|
1336 | - $message = str_replace ( '#DIDNUMBER#', $accountinfo ['did_number'], $message ); |
|
1337 | - $message = str_replace ( '#COUNTRYNAME#', $accountinfo ['did_country_id'], $message ); |
|
1338 | - $message = str_replace ( '#SETUPFEE#', $accountinfo ['did_setup'], $message ); |
|
1339 | - $message = str_replace ( '#MONTHLYFEE#', $accountinfo ['did_monthlycost'], $message ); |
|
1340 | - $message = str_replace ( '#MAXCHANNEL#', $accountinfo ['did_maxchannels'], $message ); |
|
1341 | - $message = str_replace ( '#NUMBER#', $accountinfo ['number'], $message ); |
|
1335 | + $message = str_replace('#NAME#', $accountinfo ['first_name']." ".$accountinfo ['last_name'], $message); |
|
1336 | + $message = str_replace('#DIDNUMBER#', $accountinfo ['did_number'], $message); |
|
1337 | + $message = str_replace('#COUNTRYNAME#', $accountinfo ['did_country_id'], $message); |
|
1338 | + $message = str_replace('#SETUPFEE#', $accountinfo ['did_setup'], $message); |
|
1339 | + $message = str_replace('#MONTHLYFEE#', $accountinfo ['did_monthlycost'], $message); |
|
1340 | + $message = str_replace('#MAXCHANNEL#', $accountinfo ['did_maxchannels'], $message); |
|
1341 | + $message = str_replace('#NUMBER#', $accountinfo ['number'], $message); |
|
1342 | 1342 | $subject = $query [0]->subject; |
1343 | - $subject = str_replace ( "#NUMBER#", $accountinfo ['number'], $subject ); |
|
1344 | - $subject = str_replace ( "#DIDNUMBER#", $accountinfo ['did_number'], $subject ); |
|
1343 | + $subject = str_replace("#NUMBER#", $accountinfo ['number'], $subject); |
|
1344 | + $subject = str_replace("#DIDNUMBER#", $accountinfo ['did_number'], $subject); |
|
1345 | 1345 | break; |
1346 | 1346 | case 'email_remove_did' : |
1347 | - $message = str_replace ( '#NAME#', $accountinfo ['first_name'] . " " . $accountinfo ['last_name'], $message ); |
|
1348 | - $message = str_replace ( '#DIDNUMBER#', $accountinfo ['did_number'], $message ); |
|
1349 | - $message = str_replace ( '#NUMBER#', $accountinfo ['number'], $message ); |
|
1347 | + $message = str_replace('#NAME#', $accountinfo ['first_name']." ".$accountinfo ['last_name'], $message); |
|
1348 | + $message = str_replace('#DIDNUMBER#', $accountinfo ['did_number'], $message); |
|
1349 | + $message = str_replace('#NUMBER#', $accountinfo ['number'], $message); |
|
1350 | 1350 | $subject = $query [0]->subject; |
1351 | - $subject = str_replace ( "#NUMBER#", $accountinfo ['number'], $subject ); |
|
1352 | - $subject = str_replace ( "#DIDNUMBER#", $accountinfo ['did_number'], $subject ); |
|
1351 | + $subject = str_replace("#NUMBER#", $accountinfo ['number'], $subject); |
|
1352 | + $subject = str_replace("#DIDNUMBER#", $accountinfo ['did_number'], $subject); |
|
1353 | 1353 | break; |
1354 | 1354 | } |
1355 | 1355 | |
1356 | 1356 | if ($subject == "") { |
1357 | 1357 | $subject = $query [0]->subject; |
1358 | - $subject = str_replace ( "#NAME#", $accountinfo ['first_name'] . " " . $accountinfo ['last_name'], $subject ); |
|
1359 | - $subject = str_replace ( "#COMPANY_NAME#", $company_name, $subject ); |
|
1358 | + $subject = str_replace("#NAME#", $accountinfo ['first_name']." ".$accountinfo ['last_name'], $subject); |
|
1359 | + $subject = str_replace("#COMPANY_NAME#", $company_name, $subject); |
|
1360 | 1360 | } |
1361 | - $account_id = (isset ( $accountinfo ['last_id'] ) && $accountinfo ['last_id'] != "") ? $accountinfo ['last_id'] : $accountinfo ['id']; |
|
1361 | + $account_id = (isset ($accountinfo ['last_id']) && $accountinfo ['last_id'] != "") ? $accountinfo ['last_id'] : $accountinfo ['id']; |
|
1362 | 1362 | $reseller_id = $accountinfo ['reseller_id']; |
1363 | 1363 | if ($reseller_id != "0") { |
1364 | - $reseller_result = $this->CI->db_model->getSelect ( "email", "accounts", array ( |
|
1364 | + $reseller_result = $this->CI->db_model->getSelect("email", "accounts", array( |
|
1365 | 1365 | "id" => $reseller_id |
1366 | - ) ); |
|
1367 | - $reseller_info = ( array ) $reseller_result->first_row (); |
|
1366 | + )); |
|
1367 | + $reseller_info = (array)$reseller_result->first_row(); |
|
1368 | 1368 | $settings_reply_email = $reseller_info ['email']; |
1369 | 1369 | } |
1370 | - $this->emailFunction ( $settings_reply_email, $useremail, $subject, $message, $company_name, $attachment, $account_id, $reseller_id ); |
|
1370 | + $this->emailFunction($settings_reply_email, $useremail, $subject, $message, $company_name, $attachment, $account_id, $reseller_id); |
|
1371 | 1371 | } |
1372 | 1372 | |
1373 | 1373 | /** |
@@ -1375,7 +1375,7 @@ discard block |
||
1375 | 1375 | * @param string $message |
1376 | 1376 | */ |
1377 | 1377 | function emailFunction($from, $to, $subject, $message, $company_name = "", $attachment = "", $account_id, $reseller_id) { |
1378 | - $send_mail_details = array ( |
|
1378 | + $send_mail_details = array( |
|
1379 | 1379 | 'from' => $from, |
1380 | 1380 | 'to' => $to, |
1381 | 1381 | 'subject' => $subject, |
@@ -1386,8 +1386,8 @@ discard block |
||
1386 | 1386 | 'reseller_id' => $reseller_id |
1387 | 1387 | ); |
1388 | 1388 | |
1389 | - $this->CI->db->insert ( 'mail_details', $send_mail_details ); |
|
1390 | - return $this->CI->db->insert_id (); |
|
1389 | + $this->CI->db->insert('mail_details', $send_mail_details); |
|
1390 | + return $this->CI->db->insert_id(); |
|
1391 | 1391 | } |
1392 | 1392 | |
1393 | 1393 | // Added new parameter timezone_id for API |
@@ -1395,47 +1395,47 @@ discard block |
||
1395 | 1395 | if ($date == '0000-00-00 00:00:00') { |
1396 | 1396 | return $date; |
1397 | 1397 | } else { |
1398 | - return $this->CI->timezone->display_GMT ( $date, 1, $timezone_id ); |
|
1398 | + return $this->CI->timezone->display_GMT($date, 1, $timezone_id); |
|
1399 | 1399 | } |
1400 | 1400 | } |
1401 | 1401 | function convert_GMT($date) { |
1402 | - return $this->CI->timezone->convert_to_GMT ( $select = "", $table = "", $date ); |
|
1402 | + return $this->CI->timezone->convert_to_GMT($select = "", $table = "", $date); |
|
1403 | 1403 | } |
1404 | 1404 | |
1405 | 1405 | // @todo : Not sure how above function working. Rather impacting on existing application, creating new function. |
1406 | 1406 | function custom_convert_GMT($date, $timezone_id) { |
1407 | - return $this->CI->timezone->convert_to_GMT ( $date, 1, $timezone_id ); |
|
1407 | + return $this->CI->timezone->convert_to_GMT($date, 1, $timezone_id); |
|
1408 | 1408 | } |
1409 | 1409 | function convert_to_ucfirst($select = "", $table = "", $str_value) { |
1410 | - return ucfirst ( $str_value ); |
|
1410 | + return ucfirst($str_value); |
|
1411 | 1411 | } |
1412 | 1412 | function set_charge_type($status = '') { |
1413 | - $status_array = array ( |
|
1414 | - '1' => gettext ( 'Accounts' ), |
|
1415 | - '2' => gettext ( 'Rate Group' ) |
|
1413 | + $status_array = array( |
|
1414 | + '1' => gettext('Accounts'), |
|
1415 | + '2' => gettext('Rate Group') |
|
1416 | 1416 | ); |
1417 | 1417 | return $status_array; |
1418 | 1418 | } |
1419 | 1419 | function build_concat_string($select, $table, $id_where = '') { |
1420 | - $select_params = explode ( ',', $select ); |
|
1421 | - $where = array ( |
|
1420 | + $select_params = explode(',', $select); |
|
1421 | + $where = array( |
|
1422 | 1422 | "1" |
1423 | 1423 | ); |
1424 | 1424 | if ($id_where != '') { |
1425 | - $where = array ( |
|
1425 | + $where = array( |
|
1426 | 1426 | "id" => $id_where |
1427 | 1427 | ); |
1428 | 1428 | } |
1429 | - $select_params = explode ( ',', $select ); |
|
1430 | - if (isset ( $select_params [2] )) { |
|
1429 | + $select_params = explode(',', $select); |
|
1430 | + if (isset ($select_params [2])) { |
|
1431 | 1431 | $cnt_str = " $select_params[0],' ',$select_params[1],' ','(',$select_params[2],')' "; |
1432 | 1432 | } else { |
1433 | 1433 | $cnt_str = " $select_params[0],' (',$select_params[1],')' "; |
1434 | 1434 | } |
1435 | 1435 | $select = "concat($cnt_str) as $select_params[0] "; |
1436 | - $drp_array = $this->CI->db_model->getSelect ( $select, $table, $where ); |
|
1437 | - $drp_array = $drp_array->result (); |
|
1438 | - if (isset ( $drp_array [0] )) { |
|
1436 | + $drp_array = $this->CI->db_model->getSelect($select, $table, $where); |
|
1437 | + $drp_array = $drp_array->result(); |
|
1438 | + if (isset ($drp_array [0])) { |
|
1439 | 1439 | return $drp_array [0]->$select_params [0]; |
1440 | 1440 | } |
1441 | 1441 | } |
@@ -1444,20 +1444,20 @@ discard block |
||
1444 | 1444 | * Change invoice_total to invoice details |
1445 | 1445 | */ |
1446 | 1446 | function get_invoice_total($select = '', $table = '', $id) { |
1447 | - $where_arr = array ( |
|
1447 | + $where_arr = array( |
|
1448 | 1448 | 'invoiceid' => $id, |
1449 | 1449 | 'item_type <>' => "FREE" |
1450 | 1450 | ); |
1451 | - $this->CI->db->where ( $where_arr ); |
|
1452 | - $this->CI->db->select ( '*' ); |
|
1453 | - $result = $this->CI->db->get ( 'invoice_details' ); |
|
1454 | - if ($result->num_rows () > 0) { |
|
1455 | - $result = $result->result_array (); |
|
1451 | + $this->CI->db->where($where_arr); |
|
1452 | + $this->CI->db->select('*'); |
|
1453 | + $result = $this->CI->db->get('invoice_details'); |
|
1454 | + if ($result->num_rows() > 0) { |
|
1455 | + $result = $result->result_array(); |
|
1456 | 1456 | if ($select == 'debit') { |
1457 | 1457 | if ($result [0] ['item_type'] == 'POSTCHARG') { |
1458 | - return $this->convert_to_currency ( '', '', $result [0] ['debit'] ); |
|
1458 | + return $this->convert_to_currency('', '', $result [0] ['debit']); |
|
1459 | 1459 | } else { |
1460 | - return $this->convert_to_currency ( '', '', $result [0] ['credit'] ); |
|
1460 | + return $this->convert_to_currency('', '', $result [0] ['credit']); |
|
1461 | 1461 | } |
1462 | 1462 | } else { |
1463 | 1463 | return $result [0] [$select]; |
@@ -1467,14 +1467,14 @@ discard block |
||
1467 | 1467 | } |
1468 | 1468 | } |
1469 | 1469 | function get_array($select, $table_name, $where = false) { |
1470 | - $new_array = array (); |
|
1471 | - $select_params = array (); |
|
1472 | - $select_params = explode ( ",", $select ); |
|
1473 | - if (isset ( $select_params [3] )) { |
|
1470 | + $new_array = array(); |
|
1471 | + $select_params = array(); |
|
1472 | + $select_params = explode(",", $select); |
|
1473 | + if (isset ($select_params [3])) { |
|
1474 | 1474 | $cnt_str = " $select_params[1],'(',$select_params[2],' ',$select_params[3],')' "; |
1475 | 1475 | $select = "concat($cnt_str) as $select_params[3] "; |
1476 | 1476 | $field_name = $select_params [3]; |
1477 | - } elseif (isset ( $select_params [2] )) { |
|
1477 | + } elseif (isset ($select_params [2])) { |
|
1478 | 1478 | $cnt_str = " $select_params[1],' ','(',$select_params[2],')' "; |
1479 | 1479 | $select = "concat($cnt_str) as $select_params[2] "; |
1480 | 1480 | $field_name = $select_params [2]; |
@@ -1483,35 +1483,35 @@ discard block |
||
1483 | 1483 | $field_name = $select_params [1]; |
1484 | 1484 | } |
1485 | 1485 | if ($where) { |
1486 | - $this->CI->db->where ( $where ); |
|
1486 | + $this->CI->db->where($where); |
|
1487 | 1487 | } |
1488 | - $this->CI->db->select ( "$select_params[0],$select", false ); |
|
1489 | - $result = $this->CI->db->get ( $table_name ); |
|
1490 | - foreach ( $result->result_array () as $key => $value ) { |
|
1488 | + $this->CI->db->select("$select_params[0],$select", false); |
|
1489 | + $result = $this->CI->db->get($table_name); |
|
1490 | + foreach ($result->result_array() as $key => $value) { |
|
1491 | 1491 | $new_array [$value [$select_params [0]]] = $value [$field_name]; |
1492 | 1492 | } |
1493 | - ksort ( $new_array ); |
|
1493 | + ksort($new_array); |
|
1494 | 1494 | return $new_array; |
1495 | 1495 | } |
1496 | 1496 | function get_timezone_offset() { |
1497 | 1497 | $gmtoffset = 0; |
1498 | - $accountinfo = $this->CI->session->userdata ( 'accountinfo' ); |
|
1499 | - $account_result = $this->CI->db->get_where ( 'accounts', array ( |
|
1498 | + $accountinfo = $this->CI->session->userdata('accountinfo'); |
|
1499 | + $account_result = $this->CI->db->get_where('accounts', array( |
|
1500 | 1500 | 'id' => $accountinfo ['id'] |
1501 | - ) ); |
|
1502 | - $account_result = $account_result->result_array (); |
|
1501 | + )); |
|
1502 | + $account_result = $account_result->result_array(); |
|
1503 | 1503 | $accountinfo = $account_result [0]; |
1504 | - $timezone_id_arr = array ( |
|
1504 | + $timezone_id_arr = array( |
|
1505 | 1505 | $accountinfo ['timezone_id'] |
1506 | 1506 | ); |
1507 | - $this->CI->db->where_in ( 'id', $timezone_id_arr ); |
|
1508 | - $this->CI->db->select ( 'gmtoffset' ); |
|
1509 | - $this->CI->db->from ( 'timezone' ); |
|
1510 | - $timezone_result = $this->CI->db->get (); |
|
1511 | - if ($timezone_result->num_rows () > 0) { |
|
1507 | + $this->CI->db->where_in('id', $timezone_id_arr); |
|
1508 | + $this->CI->db->select('gmtoffset'); |
|
1509 | + $this->CI->db->from('timezone'); |
|
1510 | + $timezone_result = $this->CI->db->get(); |
|
1511 | + if ($timezone_result->num_rows() > 0) { |
|
1512 | 1512 | |
1513 | - $timezone_result = $timezone_result->result_array (); |
|
1514 | - foreach ( $timezone_result as $data ) { |
|
1513 | + $timezone_result = $timezone_result->result_array(); |
|
1514 | + foreach ($timezone_result as $data) { |
|
1515 | 1515 | $gmtoffset += $data ['gmtoffset']; |
1516 | 1516 | } |
1517 | 1517 | } |
@@ -1533,19 +1533,19 @@ discard block |
||
1533 | 1533 | * ** |
1534 | 1534 | */ |
1535 | 1535 | function set_refill_coupon_status($select = '', $table = '', $status = '') { |
1536 | - $refill_coupon_array = array ( |
|
1537 | - "" => gettext ( "--Select--" ), |
|
1538 | - '2' => gettext ( 'Yes' ), |
|
1539 | - '0' => gettext ( 'No' ) |
|
1536 | + $refill_coupon_array = array( |
|
1537 | + "" => gettext("--Select--"), |
|
1538 | + '2' => gettext('Yes'), |
|
1539 | + '0' => gettext('No') |
|
1540 | 1540 | ); |
1541 | 1541 | return $refill_coupon_array; |
1542 | 1542 | } |
1543 | 1543 | function get_refill_coupon_status($select = '', $table = '', $status) { |
1544 | - $refill_coupon_array = array ( |
|
1545 | - '0' => gettext ( 'Inactive' ), |
|
1546 | - '1' => gettext ( 'Active' ), |
|
1547 | - '2' => gettext ( 'Inuse' ), |
|
1548 | - "3" => gettext ( "Expired" ) |
|
1544 | + $refill_coupon_array = array( |
|
1545 | + '0' => gettext('Inactive'), |
|
1546 | + '1' => gettext('Active'), |
|
1547 | + '2' => gettext('Inuse'), |
|
1548 | + "3" => gettext("Expired") |
|
1549 | 1549 | ); |
1550 | 1550 | return $refill_coupon_array [$status]; |
1551 | 1551 | } |
@@ -1556,7 +1556,7 @@ discard block |
||
1556 | 1556 | return $status; |
1557 | 1557 | } |
1558 | 1558 | function get_refill_coupon_used($select = '', $table = '', $status) { |
1559 | - 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">'; |
|
1559 | + 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">'; |
|
1560 | 1560 | } |
1561 | 1561 | |
1562 | 1562 | /* |
@@ -1570,16 +1570,16 @@ discard block |
||
1570 | 1570 | * @param string $string |
1571 | 1571 | */ |
1572 | 1572 | function encode_params($string) { |
1573 | - $data = base64_encode ( $string ); |
|
1574 | - $data = str_replace ( array ( |
|
1573 | + $data = base64_encode($string); |
|
1574 | + $data = str_replace(array( |
|
1575 | 1575 | '+', |
1576 | 1576 | '/', |
1577 | 1577 | '=' |
1578 | - ), array ( |
|
1578 | + ), array( |
|
1579 | 1579 | '-', |
1580 | 1580 | '$', |
1581 | 1581 | '' |
1582 | - ), $data ); |
|
1582 | + ), $data); |
|
1583 | 1583 | return $data; |
1584 | 1584 | } |
1585 | 1585 | |
@@ -1589,31 +1589,31 @@ discard block |
||
1589 | 1589 | */ |
1590 | 1590 | function encode($value) { |
1591 | 1591 | $text = $value; |
1592 | - $iv_size = mcrypt_get_iv_size ( MCRYPT_RIJNDAEL_256, MCRYPT_MODE_ECB ); |
|
1593 | - $iv = mcrypt_create_iv ( $iv_size, MCRYPT_RAND ); |
|
1594 | - $crypttext = mcrypt_encrypt ( MCRYPT_RIJNDAEL_256, $this->CI->config->item ( 'private_key' ), $text, MCRYPT_MODE_ECB, $iv ); |
|
1595 | - return trim ( $this->encode_params ( $crypttext ) ); |
|
1592 | + $iv_size = mcrypt_get_iv_size(MCRYPT_RIJNDAEL_256, MCRYPT_MODE_ECB); |
|
1593 | + $iv = mcrypt_create_iv($iv_size, MCRYPT_RAND); |
|
1594 | + $crypttext = mcrypt_encrypt(MCRYPT_RIJNDAEL_256, $this->CI->config->item('private_key'), $text, MCRYPT_MODE_ECB, $iv); |
|
1595 | + return trim($this->encode_params($crypttext)); |
|
1596 | 1596 | } |
1597 | 1597 | function decode_params($string) { |
1598 | - $data = str_replace ( array ( |
|
1598 | + $data = str_replace(array( |
|
1599 | 1599 | '-', |
1600 | 1600 | '$' |
1601 | - ), array ( |
|
1601 | + ), array( |
|
1602 | 1602 | '+', |
1603 | 1603 | '/' |
1604 | - ), $string ); |
|
1605 | - $mod4 = strlen ( $data ) % 4; |
|
1604 | + ), $string); |
|
1605 | + $mod4 = strlen($data) % 4; |
|
1606 | 1606 | if ($mod4) { |
1607 | - $data .= substr ( '====', $mod4 ); |
|
1607 | + $data .= substr('====', $mod4); |
|
1608 | 1608 | } |
1609 | - return base64_decode ( $data ); |
|
1609 | + return base64_decode($data); |
|
1610 | 1610 | } |
1611 | 1611 | function decode($value) { |
1612 | - $crypttext = $this->decode_params ( $value ); |
|
1613 | - $iv_size = mcrypt_get_iv_size ( MCRYPT_RIJNDAEL_256, MCRYPT_MODE_ECB ); |
|
1614 | - $iv = mcrypt_create_iv ( $iv_size, MCRYPT_RAND ); |
|
1615 | - $decrypttext = mcrypt_decrypt ( MCRYPT_RIJNDAEL_256, $this->CI->config->item ( 'private_key' ), $crypttext, MCRYPT_MODE_ECB, $iv ); |
|
1616 | - return trim ( $decrypttext ); |
|
1612 | + $crypttext = $this->decode_params($value); |
|
1613 | + $iv_size = mcrypt_get_iv_size(MCRYPT_RIJNDAEL_256, MCRYPT_MODE_ECB); |
|
1614 | + $iv = mcrypt_create_iv($iv_size, MCRYPT_RAND); |
|
1615 | + $decrypttext = mcrypt_decrypt(MCRYPT_RIJNDAEL_256, $this->CI->config->item('private_key'), $crypttext, MCRYPT_MODE_ECB, $iv); |
|
1616 | + return trim($decrypttext); |
|
1617 | 1617 | } |
1618 | 1618 | |
1619 | 1619 | /** |
@@ -1622,7 +1622,7 @@ discard block |
||
1622 | 1622 | * ** |
1623 | 1623 | */ |
1624 | 1624 | function set_recording($status = '') { |
1625 | - $status_array = array ( |
|
1625 | + $status_array = array( |
|
1626 | 1626 | '0' => 'On', |
1627 | 1627 | '1' => 'Off' |
1628 | 1628 | ); |
@@ -1635,10 +1635,10 @@ discard block |
||
1635 | 1635 | return $status; |
1636 | 1636 | } |
1637 | 1637 | function email_search_status($select = '') { |
1638 | - $status_array = array ( |
|
1639 | - "" => gettext ( "--Select--" ), |
|
1640 | - "0" => gettext ( "Sent" ), |
|
1641 | - "1" => gettext ( "Not Sent" ) |
|
1638 | + $status_array = array( |
|
1639 | + "" => gettext("--Select--"), |
|
1640 | + "0" => gettext("Sent"), |
|
1641 | + "1" => gettext("Not Sent") |
|
1642 | 1642 | ); |
1643 | 1643 | return $status_array; |
1644 | 1644 | } |
@@ -1650,51 +1650,51 @@ discard block |
||
1650 | 1650 | * Version 2.1 |
1651 | 1651 | */ |
1652 | 1652 | function paypal_status($status = '') { |
1653 | - $status_array = array ( |
|
1654 | - '0' => gettext ( 'Enable' ), |
|
1655 | - '1' => gettext ( 'Disable' ) |
|
1653 | + $status_array = array( |
|
1654 | + '0' => gettext('Enable'), |
|
1655 | + '1' => gettext('Disable') |
|
1656 | 1656 | ); |
1657 | 1657 | return $status_array; |
1658 | 1658 | } |
1659 | 1659 | function playback_audio_notification($status = '') { |
1660 | - $status_array = array ( |
|
1661 | - '0' => gettext ( 'Enable' ), |
|
1662 | - '1' => gettext ( 'Disable' ) |
|
1660 | + $status_array = array( |
|
1661 | + '0' => gettext('Enable'), |
|
1662 | + '1' => gettext('Disable') |
|
1663 | 1663 | ); |
1664 | 1664 | return $status_array; |
1665 | 1665 | } |
1666 | 1666 | function custom_status($status) { |
1667 | - $status_array = array ( |
|
1668 | - '0' => gettext ( 'Yes' ), |
|
1669 | - '1' => gettext ( 'No' ) |
|
1667 | + $status_array = array( |
|
1668 | + '0' => gettext('Yes'), |
|
1669 | + '1' => gettext('No') |
|
1670 | 1670 | ); |
1671 | 1671 | return $status_array; |
1672 | 1672 | } |
1673 | 1673 | function custom_status_recording($status) { |
1674 | - $status_array = array ( |
|
1675 | - '1' => gettext ( 'No' ), |
|
1676 | - '0' => gettext ( 'Yes' ) |
|
1674 | + $status_array = array( |
|
1675 | + '1' => gettext('No'), |
|
1676 | + '0' => gettext('Yes') |
|
1677 | 1677 | ); |
1678 | 1678 | return $status_array; |
1679 | 1679 | } |
1680 | 1680 | function custom_status_active($status) { |
1681 | - $status_array = array ( |
|
1682 | - '0' => gettext ( 'Active' ), |
|
1683 | - '1' => gettext ( 'InActive' ) |
|
1681 | + $status_array = array( |
|
1682 | + '0' => gettext('Active'), |
|
1683 | + '1' => gettext('InActive') |
|
1684 | 1684 | ); |
1685 | 1685 | return $status_array; |
1686 | 1686 | } |
1687 | 1687 | function custom_status_true($status) { |
1688 | - $status_array = array ( |
|
1689 | - '0' => gettext ( 'TRUE' ), |
|
1690 | - '1' => gettext ( 'FALSE' ) |
|
1688 | + $status_array = array( |
|
1689 | + '0' => gettext('TRUE'), |
|
1690 | + '1' => gettext('FALSE') |
|
1691 | 1691 | ); |
1692 | 1692 | return $status_array; |
1693 | 1693 | } |
1694 | 1694 | function custom_status_voicemail($status) { |
1695 | - $status_array = array ( |
|
1696 | - 'true' => gettext ( 'True' ), |
|
1697 | - 'false' => gettext ( 'False' ) |
|
1695 | + $status_array = array( |
|
1696 | + 'true' => gettext('True'), |
|
1697 | + 'false' => gettext('False') |
|
1698 | 1698 | ); |
1699 | 1699 | return $status_array; |
1700 | 1700 | } |
@@ -1704,78 +1704,78 @@ discard block |
||
1704 | 1704 | * For enable Signup module |
1705 | 1705 | */ |
1706 | 1706 | function create_sipdevice($status = '') { |
1707 | - $status_array = array ( |
|
1708 | - '0' => gettext ( 'Enable' ), |
|
1709 | - '1' => gettext ( 'Disable' ) |
|
1707 | + $status_array = array( |
|
1708 | + '0' => gettext('Enable'), |
|
1709 | + '1' => gettext('Disable') |
|
1710 | 1710 | ); |
1711 | 1711 | return $status_array; |
1712 | 1712 | } |
1713 | 1713 | function enable_signup($status = '') { |
1714 | - $status_array = array ( |
|
1715 | - '0' => gettext ( 'Enable' ), |
|
1716 | - '1' => gettext ( 'Disable' ) |
|
1714 | + $status_array = array( |
|
1715 | + '0' => gettext('Enable'), |
|
1716 | + '1' => gettext('Disable') |
|
1717 | 1717 | ); |
1718 | 1718 | return $status_array; |
1719 | 1719 | } |
1720 | 1720 | function balance_announce($status = '') { |
1721 | - $status_array = array ( |
|
1722 | - '0' => gettext ( 'Enable' ), |
|
1723 | - '1' => gettext ( 'Disable' ) |
|
1721 | + $status_array = array( |
|
1722 | + '0' => gettext('Enable'), |
|
1723 | + '1' => gettext('Disable') |
|
1724 | 1724 | ); |
1725 | 1725 | return $status_array; |
1726 | 1726 | } |
1727 | 1727 | function minutes_announce($status = '') { |
1728 | - $status_array = array ( |
|
1729 | - '0' => gettext ( 'Enable' ), |
|
1730 | - '1' => gettext ( 'Disable' ) |
|
1728 | + $status_array = array( |
|
1729 | + '0' => gettext('Enable'), |
|
1730 | + '1' => gettext('Disable') |
|
1731 | 1731 | ); |
1732 | 1732 | return $status_array; |
1733 | 1733 | } |
1734 | 1734 | function enable_disable_option() { |
1735 | - $option_array = array ( |
|
1736 | - '0' => gettext ( 'Enable' ), |
|
1737 | - '1' => gettext ( 'Disable' ) |
|
1735 | + $option_array = array( |
|
1736 | + '0' => gettext('Enable'), |
|
1737 | + '1' => gettext('Disable') |
|
1738 | 1738 | ); |
1739 | 1739 | return $option_array; |
1740 | 1740 | } |
1741 | 1741 | function paypal_mode($status = '') { |
1742 | - $status_array = array ( |
|
1743 | - '0' => gettext ( 'Live' ), |
|
1744 | - '1' => gettext ( 'Sandbox' ) |
|
1742 | + $status_array = array( |
|
1743 | + '0' => gettext('Live'), |
|
1744 | + '1' => gettext('Sandbox') |
|
1745 | 1745 | ); |
1746 | 1746 | return $status_array; |
1747 | 1747 | } |
1748 | 1748 | function paypal_fee($status = '') { |
1749 | - $status_array = array ( |
|
1750 | - '0' => gettext ( 'Paid By Admin' ), |
|
1751 | - '1' => gettext ( 'Paid By Customer' ) |
|
1749 | + $status_array = array( |
|
1750 | + '0' => gettext('Paid By Admin'), |
|
1751 | + '1' => gettext('Paid By Customer') |
|
1752 | 1752 | ); |
1753 | 1753 | return $status_array; |
1754 | 1754 | } |
1755 | 1755 | function email() { |
1756 | - $status_array = array ( |
|
1757 | - '1' => gettext ( 'Enable' ), |
|
1758 | - '0' => gettext ( 'Disable' ) |
|
1756 | + $status_array = array( |
|
1757 | + '1' => gettext('Enable'), |
|
1758 | + '0' => gettext('Disable') |
|
1759 | 1759 | ); |
1760 | 1760 | return $status_array; |
1761 | 1761 | } |
1762 | 1762 | function smtp() { |
1763 | - return $this->set_allow (); |
|
1763 | + return $this->set_allow(); |
|
1764 | 1764 | } |
1765 | 1765 | function debug() { |
1766 | - $status_array = array ( |
|
1767 | - '1' => gettext ( 'Enable' ), |
|
1768 | - '0' => gettext ( 'Disable' ) |
|
1766 | + $status_array = array( |
|
1767 | + '1' => gettext('Enable'), |
|
1768 | + '0' => gettext('Disable') |
|
1769 | 1769 | ); |
1770 | 1770 | return $status_array; |
1771 | 1771 | } |
1772 | 1772 | function default_signup_rategroup() { |
1773 | - $this->CI->db->select ( "id,name" ); |
|
1774 | - $this->CI->db->where ( "status", 0 ); |
|
1775 | - $this->CI->db->where ( "reseller_id", 0 ); |
|
1776 | - $pricelist_result = $this->CI->db->get ( "pricelists" )->result_array (); |
|
1777 | - $pricelist_arr = array (); |
|
1778 | - foreach ( $pricelist_result as $result ) { |
|
1773 | + $this->CI->db->select("id,name"); |
|
1774 | + $this->CI->db->where("status", 0); |
|
1775 | + $this->CI->db->where("reseller_id", 0); |
|
1776 | + $pricelist_result = $this->CI->db->get("pricelists")->result_array(); |
|
1777 | + $pricelist_arr = array(); |
|
1778 | + foreach ($pricelist_result as $result) { |
|
1779 | 1779 | $pricelist_arr [$result ['id']] = $result ['name']; |
1780 | 1780 | } |
1781 | 1781 | return $pricelist_arr; |
@@ -1785,84 +1785,84 @@ discard block |
||
1785 | 1785 | * Enable Fax feature |
1786 | 1786 | */ |
1787 | 1787 | function outbound_fax() { |
1788 | - $status_array = array ( |
|
1789 | - '0' => gettext ( 'Enable' ), |
|
1790 | - '1' => gettext ( 'Disable' ) |
|
1788 | + $status_array = array( |
|
1789 | + '0' => gettext('Enable'), |
|
1790 | + '1' => gettext('Disable') |
|
1791 | 1791 | ); |
1792 | 1792 | return $status_array; |
1793 | 1793 | } |
1794 | 1794 | function inbound_fax() { |
1795 | - $status_array = array ( |
|
1796 | - '0' => gettext ( 'Enable' ), |
|
1797 | - '1' => gettext ( 'Disable' ) |
|
1795 | + $status_array = array( |
|
1796 | + '0' => gettext('Enable'), |
|
1797 | + '1' => gettext('Disable') |
|
1798 | 1798 | ); |
1799 | 1799 | return $status_array; |
1800 | 1800 | } |
1801 | 1801 | function opensips() { |
1802 | - $status_array = array ( |
|
1803 | - '1' => gettext ( 'Enable' ), |
|
1804 | - '0' => gettext ( 'Disable' ) |
|
1802 | + $status_array = array( |
|
1803 | + '1' => gettext('Enable'), |
|
1804 | + '0' => gettext('Disable') |
|
1805 | 1805 | ); |
1806 | 1806 | return $status_array; |
1807 | 1807 | } |
1808 | 1808 | function cc_ani_auth() { |
1809 | - $status_array = array ( |
|
1810 | - '1' => gettext ( 'Enable' ), |
|
1811 | - '0' => gettext ( 'Disable' ) |
|
1809 | + $status_array = array( |
|
1810 | + '1' => gettext('Enable'), |
|
1811 | + '0' => gettext('Disable') |
|
1812 | 1812 | ); |
1813 | 1813 | return $status_array; |
1814 | 1814 | } |
1815 | 1815 | function calling_cards_balance_announce() { |
1816 | - $status_array = array ( |
|
1817 | - '1' => gettext ( 'Enable' ), |
|
1818 | - '0' => gettext ( 'Disable' ) |
|
1816 | + $status_array = array( |
|
1817 | + '1' => gettext('Enable'), |
|
1818 | + '0' => gettext('Disable') |
|
1819 | 1819 | ); |
1820 | 1820 | return $status_array; |
1821 | 1821 | } |
1822 | 1822 | function calling_cards_timelimit_announce() { |
1823 | - $status_array = array ( |
|
1824 | - '1' => gettext ( 'Enable' ), |
|
1825 | - '0' => gettext ( 'Disable' ) |
|
1823 | + $status_array = array( |
|
1824 | + '1' => gettext('Enable'), |
|
1825 | + '0' => gettext('Disable') |
|
1826 | 1826 | ); |
1827 | 1827 | return $status_array; |
1828 | 1828 | } |
1829 | 1829 | function calling_cards_rate_announce() { |
1830 | - $status_array = array ( |
|
1831 | - '1' => gettext ( 'Enable' ), |
|
1832 | - '0' => gettext ( 'Disable' ) |
|
1830 | + $status_array = array( |
|
1831 | + '1' => gettext('Enable'), |
|
1832 | + '0' => gettext('Disable') |
|
1833 | 1833 | ); |
1834 | 1834 | return $status_array; |
1835 | 1835 | } |
1836 | 1836 | function startingdigit() { |
1837 | - $status_array = array ( |
|
1838 | - '1' => gettext ( 'Enable' ), |
|
1839 | - '0' => gettext ( 'Disable' ) |
|
1837 | + $status_array = array( |
|
1838 | + '1' => gettext('Enable'), |
|
1839 | + '0' => gettext('Disable') |
|
1840 | 1840 | ); |
1841 | 1841 | return $status_array; |
1842 | 1842 | } |
1843 | 1843 | function SMPT() { |
1844 | - $status_array = array ( |
|
1845 | - '1' => gettext ( 'Enable' ), |
|
1846 | - '0' => gettext ( 'Disable' ) |
|
1844 | + $status_array = array( |
|
1845 | + '1' => gettext('Enable'), |
|
1846 | + '0' => gettext('Disable') |
|
1847 | 1847 | ); |
1848 | 1848 | return $status_array; |
1849 | 1849 | } |
1850 | 1850 | function country() { |
1851 | - return $this->CI->common_model->get_country_list (); |
|
1851 | + return $this->CI->common_model->get_country_list(); |
|
1852 | 1852 | } |
1853 | 1853 | function default_timezone() { |
1854 | - return $this->CI->db_model->build_dropdown ( 'id,gmtzone', 'timezone' ); |
|
1854 | + return $this->CI->db_model->build_dropdown('id,gmtzone', 'timezone'); |
|
1855 | 1855 | } |
1856 | 1856 | function timezone() { |
1857 | - return $this->CI->db_model->build_dropdown ( 'gmttime,gmttime', 'timezone' ); |
|
1857 | + return $this->CI->db_model->build_dropdown('gmttime,gmttime', 'timezone'); |
|
1858 | 1858 | } |
1859 | 1859 | function base_currency() { |
1860 | - return $this->CI->db_model->build_dropdown ( 'currency,currencyname', 'currency' ); |
|
1860 | + return $this->CI->db_model->build_dropdown('currency,currencyname', 'currency'); |
|
1861 | 1861 | } |
1862 | 1862 | function automatic_invoice() { |
1863 | - $status_array = array ( |
|
1864 | - '0' => gettext ( 'Automatic' ), |
|
1865 | - '1' => gettext ( 'Manual' ) |
|
1863 | + $status_array = array( |
|
1864 | + '0' => gettext('Automatic'), |
|
1865 | + '1' => gettext('Manual') |
|
1866 | 1866 | ); |
1867 | 1867 | return $status_array; |
1868 | 1868 | } |
@@ -1874,12 +1874,12 @@ discard block |
||
1874 | 1874 | $decimal_points = $currency_info ['decimalpoints']; |
1875 | 1875 | $system_currency_rate = $currency_info ['base_currency'] ['currencyrate']; |
1876 | 1876 | $user_currency_rate = $currency_info ['user_currency'] ['currencyrate']; |
1877 | - $calculated_amount = ( float ) (($amount * $currency_info ['user_currency'] ['currencyrate']) / $currency_info ['base_currency'] ['currencyrate']); |
|
1877 | + $calculated_amount = (float)(($amount * $currency_info ['user_currency'] ['currencyrate']) / $currency_info ['base_currency'] ['currencyrate']); |
|
1878 | 1878 | if ($number_format) { |
1879 | - $calculated_amount = number_format ( $calculated_amount, $currency_info ['decimalpoints'] ); |
|
1879 | + $calculated_amount = number_format($calculated_amount, $currency_info ['decimalpoints']); |
|
1880 | 1880 | } |
1881 | 1881 | if ($show_currency_flag) { |
1882 | - return $calculated_amount . " " . $currency_info ['user_currency'] ['currency']; |
|
1882 | + return $calculated_amount." ".$currency_info ['user_currency'] ['currency']; |
|
1883 | 1883 | } else { |
1884 | 1884 | return $calculated_amount; |
1885 | 1885 | } |
@@ -1889,27 +1889,27 @@ discard block |
||
1889 | 1889 | * Using By Summary Report search |
1890 | 1890 | */ |
1891 | 1891 | function search_report_in($select = '') { |
1892 | - $status_array = array ( |
|
1892 | + $status_array = array( |
|
1893 | 1893 | "minutes" => "Minutes", |
1894 | 1894 | "seconds" => "Seconds" |
1895 | 1895 | ); |
1896 | 1896 | return $status_array; |
1897 | 1897 | } |
1898 | 1898 | function set_summarycustomer_groupby($status = '') { |
1899 | - $status_array = array ( |
|
1900 | - '' => gettext ( "--Select--" ), |
|
1901 | - 'accountid' => gettext ( 'Account' ), |
|
1902 | - 'pattern' => gettext ( 'Code' ), |
|
1903 | - 'package_id' => gettext ( "Package" ) |
|
1899 | + $status_array = array( |
|
1900 | + '' => gettext("--Select--"), |
|
1901 | + 'accountid' => gettext('Account'), |
|
1902 | + 'pattern' => gettext('Code'), |
|
1903 | + 'package_id' => gettext("Package") |
|
1904 | 1904 | ); |
1905 | 1905 | return $status_array; |
1906 | 1906 | } |
1907 | 1907 | function set_summaryprovider_groupby($status = '') { |
1908 | - $status_array = array ( |
|
1909 | - '' => gettext ( "--Select--" ), |
|
1910 | - 'provider_id' => gettext ( 'Account' ), |
|
1911 | - 'trunk_id' => gettext ( "Trunks" ), |
|
1912 | - 'pattern' => gettext ( 'Code' ) |
|
1908 | + $status_array = array( |
|
1909 | + '' => gettext("--Select--"), |
|
1910 | + 'provider_id' => gettext('Account'), |
|
1911 | + 'trunk_id' => gettext("Trunks"), |
|
1912 | + 'pattern' => gettext('Code') |
|
1913 | 1913 | ); |
1914 | 1914 | return $status_array; |
1915 | 1915 | } |
@@ -1917,17 +1917,17 @@ discard block |
||
1917 | 1917 | // System Currency info |
1918 | 1918 | $base_currency = Common_model::$global_config ['system_config'] ['base_currency']; |
1919 | 1919 | // Get Account Information from session to get currency_id |
1920 | - $accountinfo = $this->CI->session->userdata ( 'accountinfo' ); |
|
1920 | + $accountinfo = $this->CI->session->userdata('accountinfo'); |
|
1921 | 1921 | // Get User Currency id |
1922 | 1922 | $user_currency_id = $accountinfo ['currency_id'] > 0 ? $accountinfo ['currency_id'] : $base_currency; |
1923 | - $where = "currency = '" . $base_currency . "' OR id= " . $user_currency_id; |
|
1924 | - $this->CI->db->where ( $where ); |
|
1925 | - $this->CI->db->select ( '*' ); |
|
1926 | - $currency_result = $this->CI->db->get ( 'currency' ); |
|
1923 | + $where = "currency = '".$base_currency."' OR id= ".$user_currency_id; |
|
1924 | + $this->CI->db->where($where); |
|
1925 | + $this->CI->db->select('*'); |
|
1926 | + $currency_result = $this->CI->db->get('currency'); |
|
1927 | 1927 | |
1928 | - if ($currency_result->num_rows () == 2) { |
|
1929 | - $currency_result = $currency_result->result_array (); |
|
1930 | - foreach ( $currency_result as $key => $records ) { |
|
1928 | + if ($currency_result->num_rows() == 2) { |
|
1929 | + $currency_result = $currency_result->result_array(); |
|
1930 | + foreach ($currency_result as $key => $records) { |
|
1931 | 1931 | // User Currency is currency details of logged in user. |
1932 | 1932 | if ($records ['id'] == $user_currency_id) { |
1933 | 1933 | $currency_info ['user_currency'] = $records; |
@@ -1937,35 +1937,35 @@ discard block |
||
1937 | 1937 | $currency_info ['base_currency'] = $records; |
1938 | 1938 | } |
1939 | 1939 | } |
1940 | - } else if ($currency_result->num_rows () == 1) { |
|
1941 | - $currency_info ['user_currency'] = $currency_info ['base_currency'] = ( array ) $currency_result->first_row (); |
|
1940 | + } else if ($currency_result->num_rows() == 1) { |
|
1941 | + $currency_info ['user_currency'] = $currency_info ['base_currency'] = (array)$currency_result->first_row(); |
|
1942 | 1942 | } |
1943 | 1943 | // Get Decimal points as per defined from system. |
1944 | 1944 | $currency_info ['decimalpoints'] = Common_model::$global_config ['system_config'] ['decimalpoints']; |
1945 | 1945 | return $currency_info; |
1946 | 1946 | } |
1947 | 1947 | function convert_to_show_in($search_name = "", $table = "", $second) { |
1948 | - $search_arr = $this->CI->session->userdata ( $search_name ); |
|
1949 | - $show_seconds = (! empty ( $search_arr ['search_in'] )) ? $search_arr ['search_in'] : 'minutes'; |
|
1950 | - return ($show_seconds === 'minutes') ? ($second > 0) ? sprintf ( '%02d', $second / 60 ) . ":" . sprintf ( '%02d', ($second % 60) ) : "00:00" : sprintf ( '%02d', $second ); |
|
1948 | + $search_arr = $this->CI->session->userdata($search_name); |
|
1949 | + $show_seconds = ( ! empty ($search_arr ['search_in'])) ? $search_arr ['search_in'] : 'minutes'; |
|
1950 | + return ($show_seconds === 'minutes') ? ($second > 0) ? sprintf ('%02d', $second / 60).":".sprintf('%02d', ($second % 60)) : "00:00" : sprintf('%02d', $second); |
|
1951 | 1951 | } |
1952 | 1952 | function array_column($input, $columnKey, $indexKey = null) { |
1953 | - $array = array (); |
|
1954 | - foreach ( $input as $value ) { |
|
1955 | - if (! isset ( $value [$columnKey] )) { |
|
1956 | - trigger_error ( "Key \"$columnKey\" does not exist in array" ); |
|
1953 | + $array = array(); |
|
1954 | + foreach ($input as $value) { |
|
1955 | + if ( ! isset ($value [$columnKey])) { |
|
1956 | + trigger_error("Key \"$columnKey\" does not exist in array"); |
|
1957 | 1957 | return false; |
1958 | 1958 | } |
1959 | 1959 | |
1960 | - if (is_null ( $indexKey )) { |
|
1960 | + if (is_null($indexKey)) { |
|
1961 | 1961 | $array [] = $value [$columnKey]; |
1962 | 1962 | } else { |
1963 | - if (! isset ( $value [$indexKey] )) { |
|
1964 | - trigger_error ( "Key \"$indexKey\" does not exist in array" ); |
|
1963 | + if ( ! isset ($value [$indexKey])) { |
|
1964 | + trigger_error("Key \"$indexKey\" does not exist in array"); |
|
1965 | 1965 | return false; |
1966 | 1966 | } |
1967 | - if (! is_scalar ( $value [$indexKey] )) { |
|
1968 | - trigger_error ( "Key \"$indexKey\" does not contain scalar value" ); |
|
1967 | + if ( ! is_scalar($value [$indexKey])) { |
|
1968 | + trigger_error("Key \"$indexKey\" does not contain scalar value"); |
|
1969 | 1969 | return false; |
1970 | 1970 | } |
1971 | 1971 | $array [$value [$indexKey]] = $value [$columnKey]; |
@@ -1975,48 +1975,48 @@ discard block |
||
1975 | 1975 | return $array; |
1976 | 1976 | } |
1977 | 1977 | function group_by_time() { |
1978 | - $status_array = array ( |
|
1979 | - '' => gettext ( "--Select--" ), |
|
1980 | - 'HOUR' => gettext ( 'Hour' ), |
|
1981 | - 'DAY' => gettext ( "Day" ), |
|
1982 | - 'MONTH' => gettext ( 'Month' ), |
|
1983 | - "YEAR" => gettext ( "Year" ) |
|
1978 | + $status_array = array( |
|
1979 | + '' => gettext("--Select--"), |
|
1980 | + 'HOUR' => gettext('Hour'), |
|
1981 | + 'DAY' => gettext("Day"), |
|
1982 | + 'MONTH' => gettext('Month'), |
|
1983 | + "YEAR" => gettext("Year") |
|
1984 | 1984 | ); |
1985 | 1985 | return $status_array; |
1986 | 1986 | } |
1987 | 1987 | function currency_decimal($amount) { |
1988 | - $amount = str_replace ( ',', '', $amount ); |
|
1988 | + $amount = str_replace(',', '', $amount); |
|
1989 | 1989 | $decimal_amount = Common_model::$global_config ['system_config'] ['decimalpoints']; |
1990 | - $number_convert = number_format ( ( float ) $amount, $decimal_amount, '.', '' ); |
|
1990 | + $number_convert = number_format((float)$amount, $decimal_amount, '.', ''); |
|
1991 | 1991 | return $number_convert; |
1992 | 1992 | } |
1993 | 1993 | function add_invoice_details($account_arr, $charge_type, $amount, $description) { |
1994 | - $accountinfo = $this->CI->session->userdata ( 'accountinfo' ); |
|
1994 | + $accountinfo = $this->CI->session->userdata('accountinfo'); |
|
1995 | 1995 | $reseller_id = $accountinfo ['type'] == 1 ? $accountinfo ['id'] : 0; |
1996 | - $where = "accountid IN ('" . $reseller_id . "','1')"; |
|
1997 | - $this->CI->db->where ( $where ); |
|
1998 | - $this->CI->db->select ( '*' ); |
|
1999 | - $this->CI->db->order_by ( 'accountid', 'desc' ); |
|
2000 | - $this->CI->db->limit ( 1 ); |
|
2001 | - $invoiceconf = $this->CI->db->get ( 'invoice_conf' ); |
|
2002 | - $invoice_conf = ( array ) $invoiceconf->first_row (); |
|
2003 | - $last_invoiceid = $this->get_invoice_date ( 'invoiceid', '', $account_arr ['reseller_id'] ); |
|
1996 | + $where = "accountid IN ('".$reseller_id."','1')"; |
|
1997 | + $this->CI->db->where($where); |
|
1998 | + $this->CI->db->select('*'); |
|
1999 | + $this->CI->db->order_by('accountid', 'desc'); |
|
2000 | + $this->CI->db->limit(1); |
|
2001 | + $invoiceconf = $this->CI->db->get('invoice_conf'); |
|
2002 | + $invoice_conf = (array)$invoiceconf->first_row(); |
|
2003 | + $last_invoiceid = $this->get_invoice_date('invoiceid', '', $account_arr ['reseller_id']); |
|
2004 | 2004 | if ($last_invoiceid && $last_invoiceid > 0) { |
2005 | 2005 | $last_invoiceid = ($last_invoiceid + 1); |
2006 | 2006 | } else { |
2007 | 2007 | $last_invoiceid = $invoice_conf ['invoice_start_from']; |
2008 | 2008 | } |
2009 | - $last_invoiceid = str_pad ( $last_invoiceid, (strlen ( $last_invoiceid ) + 4), '0', STR_PAD_LEFT ); |
|
2009 | + $last_invoiceid = str_pad($last_invoiceid, (strlen($last_invoiceid) + 4), '0', STR_PAD_LEFT); |
|
2010 | 2010 | $invoice_prefix = $invoice_conf ['invoice_prefix']; |
2011 | - $due_date = gmdate ( "Y-m-d H:i:s", strtotime ( gmdate ( "Y-m-d H:i:s" ) . " +" . $invoice_conf ['interval'] . " days" ) ); |
|
2012 | - $invoiceid = $account_arr ['posttoexternal'] == 0 ? $this->CI->common_model->generate_receipt ( $account_arr ['id'], $amount, $account_arr, $last_invoiceid, $invoice_prefix, $due_date ) : 0; |
|
2011 | + $due_date = gmdate("Y-m-d H:i:s", strtotime(gmdate("Y-m-d H:i:s")." +".$invoice_conf ['interval']." days")); |
|
2012 | + $invoiceid = $account_arr ['posttoexternal'] == 0 ? $this->CI->common_model->generate_receipt($account_arr ['id'], $amount, $account_arr, $last_invoiceid, $invoice_prefix, $due_date) : 0; |
|
2013 | 2013 | $balance = ($account_arr ['posttoexternal'] == 1) ? $account_arr ['credit_limit'] - $account_arr ['balance'] : $account_arr ['balance']; |
2014 | - $insert_arr = array ( |
|
2014 | + $insert_arr = array( |
|
2015 | 2015 | "accountid" => $account_arr ['id'], |
2016 | 2016 | "description" => $description, |
2017 | 2017 | "debit" => $amount, |
2018 | 2018 | "credit" => '0', |
2019 | - "created_date" => gmdate ( "Y-m-d H:i:s" ), |
|
2019 | + "created_date" => gmdate("Y-m-d H:i:s"), |
|
2020 | 2020 | "invoiceid" => $invoiceid, |
2021 | 2021 | "reseller_id" => $account_arr ['reseller_id'], |
2022 | 2022 | "item_type" => $charge_type, |
@@ -2024,180 +2024,180 @@ discard block |
||
2024 | 2024 | "before_balance" => $balance, |
2025 | 2025 | "after_balance" => $balance - $amount |
2026 | 2026 | ); |
2027 | - $this->CI->db->insert ( "invoice_details", $insert_arr ); |
|
2027 | + $this->CI->db->insert("invoice_details", $insert_arr); |
|
2028 | 2028 | return true; |
2029 | 2029 | } |
2030 | 2030 | /* |
2031 | 2031 | * ASTPP 3.0 Remove all information related to going to delete customer. |
2032 | 2032 | */ |
2033 | 2033 | function customer_delete_dependencies($id) { |
2034 | - $this->delete_data ( 'ani_map', array ( |
|
2034 | + $this->delete_data('ani_map', array( |
|
2035 | 2035 | 'accountid' => $id |
2036 | - ) ); |
|
2037 | - $this->delete_data ( 'block_patterns', array ( |
|
2036 | + )); |
|
2037 | + $this->delete_data('block_patterns', array( |
|
2038 | 2038 | 'accountid' => $id |
2039 | - ) ); |
|
2040 | - $this->delete_data ( 'charge_to_account', array ( |
|
2039 | + )); |
|
2040 | + $this->delete_data('charge_to_account', array( |
|
2041 | 2041 | 'accountid' => $id |
2042 | - ) ); |
|
2043 | - $this->delete_data ( 'counters', array ( |
|
2042 | + )); |
|
2043 | + $this->delete_data('counters', array( |
|
2044 | 2044 | 'accountid' => $id |
2045 | - ) ); |
|
2046 | - $this->delete_data ( 'ip_map', array ( |
|
2045 | + )); |
|
2046 | + $this->delete_data('ip_map', array( |
|
2047 | 2047 | 'accountid' => $id |
2048 | - ) ); |
|
2049 | - $this->delete_data ( 'sip_devices', array ( |
|
2048 | + )); |
|
2049 | + $this->delete_data('sip_devices', array( |
|
2050 | 2050 | 'accountid' => $id |
2051 | - ) ); |
|
2052 | - $this->delete_data ( 'speed_dial', array ( |
|
2051 | + )); |
|
2052 | + $this->delete_data('speed_dial', array( |
|
2053 | 2053 | 'accountid' => $id |
2054 | - ) ); |
|
2055 | - $this->delete_data ( 'taxes_to_accounts', array ( |
|
2054 | + )); |
|
2055 | + $this->delete_data('taxes_to_accounts', array( |
|
2056 | 2056 | 'accountid' => $id |
2057 | - ) ); |
|
2058 | - $this->delete_data ( 'mail_details', array ( |
|
2057 | + )); |
|
2058 | + $this->delete_data('mail_details', array( |
|
2059 | 2059 | 'accountid' => $id |
2060 | - ) ); |
|
2061 | - $this->update_data ( 'dids', array ( |
|
2060 | + )); |
|
2061 | + $this->update_data('dids', array( |
|
2062 | 2062 | "accountid" => $id |
2063 | - ), array ( |
|
2063 | + ), array( |
|
2064 | 2064 | 'accountid' => 0 |
2065 | - ) ); |
|
2066 | - $this->update_data ( "accounts", array ( |
|
2065 | + )); |
|
2066 | + $this->update_data("accounts", array( |
|
2067 | 2067 | "id" => $id |
2068 | - ), array ( |
|
2068 | + ), array( |
|
2069 | 2069 | "deleted" => 1 |
2070 | - ) ); |
|
2070 | + )); |
|
2071 | 2071 | } |
2072 | 2072 | /* |
2073 | 2073 | * ASTPP 3.0 |
2074 | 2074 | * Remove all information related to going to delete reseller. |
2075 | 2075 | */ |
2076 | 2076 | function reseller_delete_dependencies($id) { |
2077 | - $accountinfo = $this->CI->session->userdata ( 'accountinfo' ); |
|
2078 | - $child_arr = $this->select_data ( "accounts", array ( |
|
2077 | + $accountinfo = $this->CI->session->userdata('accountinfo'); |
|
2078 | + $child_arr = $this->select_data("accounts", array( |
|
2079 | 2079 | "reseller_id" => $id, |
2080 | 2080 | "type" => 0 |
2081 | - ), 'id,reseller_id' ); |
|
2081 | + ), 'id,reseller_id'); |
|
2082 | 2082 | if ($child_arr) { |
2083 | - foreach ( $child_arr as $value ) { |
|
2084 | - $this->customer_delete_dependencies ( $value ['id'] ); |
|
2083 | + foreach ($child_arr as $value) { |
|
2084 | + $this->customer_delete_dependencies($value ['id']); |
|
2085 | 2085 | } |
2086 | 2086 | } |
2087 | - $package_arr = $this->select_data ( "packages", array ( |
|
2087 | + $package_arr = $this->select_data("packages", array( |
|
2088 | 2088 | "reseller_id" => $id |
2089 | - ), 'id' ); |
|
2089 | + ), 'id'); |
|
2090 | 2090 | if ($package_arr) { |
2091 | - foreach ( $package_arr as $value ) { |
|
2092 | - $this->delete_data ( 'package_patterns', array ( |
|
2091 | + foreach ($package_arr as $value) { |
|
2092 | + $this->delete_data('package_patterns', array( |
|
2093 | 2093 | "id" => $value ['id'] |
2094 | - ) ); |
|
2094 | + )); |
|
2095 | 2095 | } |
2096 | 2096 | } |
2097 | - $acc_arr = $this->select_data ( 'accounts', array ( |
|
2097 | + $acc_arr = $this->select_data('accounts', array( |
|
2098 | 2098 | "id" => $id |
2099 | - ), 'id,reseller_id' ); |
|
2099 | + ), 'id,reseller_id'); |
|
2100 | 2100 | $parent_id = 0; |
2101 | 2101 | if ($acc_arr) { |
2102 | 2102 | $parent_id = $acc_arr [0] ['reseller_id']; |
2103 | 2103 | } |
2104 | - $pricelist_arr = $this->select_data ( 'pricelists', array ( |
|
2104 | + $pricelist_arr = $this->select_data('pricelists', array( |
|
2105 | 2105 | 'reseller_id' => $id |
2106 | - ), 'id' ); |
|
2106 | + ), 'id'); |
|
2107 | 2107 | if ($pricelist_arr) { |
2108 | - foreach ( $pricelist_arr as $value ) { |
|
2109 | - $this->delete_data ( "routing", array ( |
|
2108 | + foreach ($pricelist_arr as $value) { |
|
2109 | + $this->delete_data("routing", array( |
|
2110 | 2110 | "pricelist_id" => $value ['id'] |
2111 | - ) ); |
|
2112 | - $this->delete_data ( "routes", array ( |
|
2111 | + )); |
|
2112 | + $this->delete_data("routes", array( |
|
2113 | 2113 | "pricelist_id" => $value ['id'] |
2114 | - ) ); |
|
2115 | - $this->update_data ( 'pricelists', array ( |
|
2114 | + )); |
|
2115 | + $this->update_data('pricelists', array( |
|
2116 | 2116 | 'id' => $value ['id'] |
2117 | - ), array ( |
|
2117 | + ), array( |
|
2118 | 2118 | 'status' => 2 |
2119 | - ) ); |
|
2119 | + )); |
|
2120 | 2120 | } |
2121 | 2121 | } |
2122 | - $charge_arr = $this->select_data ( 'charges', array ( |
|
2122 | + $charge_arr = $this->select_data('charges', array( |
|
2123 | 2123 | 'reseller_id' => $id |
2124 | - ), 'id' ); |
|
2124 | + ), 'id'); |
|
2125 | 2125 | if ($charge_arr) { |
2126 | - foreach ( $charge_arr as $value ) { |
|
2127 | - $this->delete_data ( "charge_to_account", array ( |
|
2126 | + foreach ($charge_arr as $value) { |
|
2127 | + $this->delete_data("charge_to_account", array( |
|
2128 | 2128 | "charge_id" => $value ['id'] |
2129 | - ) ); |
|
2129 | + )); |
|
2130 | 2130 | } |
2131 | 2131 | } |
2132 | - $this->delete_data ( 'charges', array ( |
|
2132 | + $this->delete_data('charges', array( |
|
2133 | 2133 | 'reseller_id' => $id |
2134 | - ) ); |
|
2135 | - $this->update_data ( 'dids', array ( |
|
2134 | + )); |
|
2135 | + $this->update_data('dids', array( |
|
2136 | 2136 | 'parent_id' => $id |
2137 | - ), array ( |
|
2137 | + ), array( |
|
2138 | 2138 | "parent_id" => $parent_id |
2139 | - ) ); |
|
2140 | - $this->delete_data ( 'reseller_pricing', array ( |
|
2139 | + )); |
|
2140 | + $this->delete_data('reseller_pricing', array( |
|
2141 | 2141 | "reseller_id" => $id |
2142 | - ) ); |
|
2143 | - $this->delete_data ( 'refill_coupon', array ( |
|
2142 | + )); |
|
2143 | + $this->delete_data('refill_coupon', array( |
|
2144 | 2144 | "reseller_id" => $id |
2145 | - ) ); |
|
2146 | - $this->delete_data ( 'mail_details', array ( |
|
2145 | + )); |
|
2146 | + $this->delete_data('mail_details', array( |
|
2147 | 2147 | 'accountid' => $id |
2148 | - ) ); |
|
2149 | - $taxes_arr = $this->select_data ( 'taxes', array ( |
|
2148 | + )); |
|
2149 | + $taxes_arr = $this->select_data('taxes', array( |
|
2150 | 2150 | "reseller_id" => $id |
2151 | - ), 'id' ); |
|
2151 | + ), 'id'); |
|
2152 | 2152 | if ($taxes_arr) { |
2153 | - foreach ( $taxes_arr as $value ) { |
|
2154 | - $this->delete_data ( "taxes_to_accounts", array ( |
|
2153 | + foreach ($taxes_arr as $value) { |
|
2154 | + $this->delete_data("taxes_to_accounts", array( |
|
2155 | 2155 | "taxes_id" => $value ['id'] |
2156 | - ) ); |
|
2156 | + )); |
|
2157 | 2157 | } |
2158 | 2158 | } |
2159 | - $this->delete_data ( 'taxes', array ( |
|
2159 | + $this->delete_data('taxes', array( |
|
2160 | 2160 | "reseller_id" => $id |
2161 | - ) ); |
|
2162 | - $this->delete_data ( 'default_templates', array ( |
|
2161 | + )); |
|
2162 | + $this->delete_data('default_templates', array( |
|
2163 | 2163 | "reseller_id" => $id |
2164 | - ) ); |
|
2165 | - $package_arr = $this->select_data ( 'packages', array ( |
|
2164 | + )); |
|
2165 | + $package_arr = $this->select_data('packages', array( |
|
2166 | 2166 | 'reseller_id' => $id |
2167 | - ), 'id' ); |
|
2167 | + ), 'id'); |
|
2168 | 2168 | if ($package_arr) { |
2169 | - $this->delete_data ( "counters", array ( |
|
2169 | + $this->delete_data("counters", array( |
|
2170 | 2170 | "package_id" => $value ['id'] |
2171 | - ) ); |
|
2172 | - $this->delete_data ( "package_patterns", array ( |
|
2171 | + )); |
|
2172 | + $this->delete_data("package_patterns", array( |
|
2173 | 2173 | "package_id" => $value ['id'] |
2174 | - ) ); |
|
2174 | + )); |
|
2175 | 2175 | } |
2176 | - $this->delete_data ( 'invoice_conf', array ( |
|
2176 | + $this->delete_data('invoice_conf', array( |
|
2177 | 2177 | 'accountid' => $id |
2178 | - ) ); |
|
2179 | - $this->delete_data ( 'packages', array ( |
|
2178 | + )); |
|
2179 | + $this->delete_data('packages', array( |
|
2180 | 2180 | "reseller_id" => $id |
2181 | - ) ); |
|
2182 | - $this->update_data ( 'accounts', array ( |
|
2181 | + )); |
|
2182 | + $this->update_data('accounts', array( |
|
2183 | 2183 | "id" => $id |
2184 | - ), array ( |
|
2184 | + ), array( |
|
2185 | 2185 | "deleted" => 1 |
2186 | - ) ); |
|
2186 | + )); |
|
2187 | 2187 | } |
2188 | 2188 | function subreseller_list($parent_id = '') { |
2189 | 2189 | $customer_id = $parent_id; |
2190 | - $this->reseller_delete_dependencies ( $parent_id ); |
|
2191 | - $query = 'select id,type from accounts where reseller_id = ' . $parent_id . ' AND deleted =0'; |
|
2192 | - $result = $this->CI->db->query ( $query ); |
|
2193 | - if ($result->num_rows () > 0) { |
|
2194 | - $result = $result->result_array (); |
|
2195 | - foreach ( $result as $data ) { |
|
2190 | + $this->reseller_delete_dependencies($parent_id); |
|
2191 | + $query = 'select id,type from accounts where reseller_id = '.$parent_id.' AND deleted =0'; |
|
2192 | + $result = $this->CI->db->query($query); |
|
2193 | + if ($result->num_rows() > 0) { |
|
2194 | + $result = $result->result_array(); |
|
2195 | + foreach ($result as $data) { |
|
2196 | 2196 | if ($data ['type'] == 1) { |
2197 | - $this->reseller_delete_dependencies ( $data ['id'] ); |
|
2198 | - $this->subreseller_list ( $data ['id'] ); |
|
2197 | + $this->reseller_delete_dependencies($data ['id']); |
|
2198 | + $this->subreseller_list($data ['id']); |
|
2199 | 2199 | } else { |
2200 | - $this->customer_delete_dependencies ( $data ['id'] ); |
|
2200 | + $this->customer_delete_dependencies($data ['id']); |
|
2201 | 2201 | } |
2202 | 2202 | } |
2203 | 2203 | } |
@@ -2208,11 +2208,11 @@ discard block |
||
2208 | 2208 | * @param string $table_name |
2209 | 2209 | */ |
2210 | 2210 | function delete_data($table_name, $where_arr) { |
2211 | - $this->CI->db->where ( $where_arr ); |
|
2211 | + $this->CI->db->where($where_arr); |
|
2212 | 2212 | if ($table_name == 'accounts') { |
2213 | - $this->CI->db->where ( 'type <>', '-1' ); |
|
2213 | + $this->CI->db->where('type <>', '-1'); |
|
2214 | 2214 | } |
2215 | - $this->CI->db->delete ( $table_name ); |
|
2215 | + $this->CI->db->delete($table_name); |
|
2216 | 2216 | } |
2217 | 2217 | |
2218 | 2218 | /** |
@@ -2220,11 +2220,11 @@ discard block |
||
2220 | 2220 | * @param string $table_name |
2221 | 2221 | */ |
2222 | 2222 | function update_data($table_name, $where_arr, $update_arr) { |
2223 | - $this->CI->db->where ( $where_arr ); |
|
2223 | + $this->CI->db->where($where_arr); |
|
2224 | 2224 | if ($table_name == 'accounts') { |
2225 | - $this->CI->db->where ( 'type <>', '-1' ); |
|
2225 | + $this->CI->db->where('type <>', '-1'); |
|
2226 | 2226 | } |
2227 | - $this->CI->db->update ( $table_name, $update_arr ); |
|
2227 | + $this->CI->db->update($table_name, $update_arr); |
|
2228 | 2228 | } |
2229 | 2229 | |
2230 | 2230 | /** |
@@ -2233,17 +2233,17 @@ discard block |
||
2233 | 2233 | * @param string $select |
2234 | 2234 | */ |
2235 | 2235 | function select_data($table_name, $where_arr, $select) { |
2236 | - $this->CI->db->where ( $where_arr ); |
|
2237 | - $this->CI->db->select ( $select ); |
|
2238 | - $result = $this->CI->db->get ( $table_name ); |
|
2239 | - if ($result->num_rows () > 0) { |
|
2240 | - return $result->result_array (); |
|
2236 | + $this->CI->db->where($where_arr); |
|
2237 | + $this->CI->db->select($select); |
|
2238 | + $result = $this->CI->db->get($table_name); |
|
2239 | + if ($result->num_rows() > 0) { |
|
2240 | + return $result->result_array(); |
|
2241 | 2241 | } else { |
2242 | 2242 | return false; |
2243 | 2243 | } |
2244 | 2244 | } |
2245 | 2245 | function set_call_waiting($status = '') { |
2246 | - $status_array = array ( |
|
2246 | + $status_array = array( |
|
2247 | 2247 | '0' => 'Enable', |
2248 | 2248 | '1' => 'Disable' |
2249 | 2249 | ); |
@@ -2253,47 +2253,47 @@ discard block |
||
2253 | 2253 | return ($status == 0) ? "Enable" : "Disable"; |
2254 | 2254 | } |
2255 | 2255 | function set_invoice_details($select = '') { |
2256 | - $status_array = array ( |
|
2257 | - "invoice_select" => gettext ( "--Select--" ), |
|
2258 | - "invoice_inactive" => gettext ( "Deleted Invoices" ), |
|
2259 | - "invoice_active" => gettext ( "All Invoices" ) |
|
2256 | + $status_array = array( |
|
2257 | + "invoice_select" => gettext("--Select--"), |
|
2258 | + "invoice_inactive" => gettext("Deleted Invoices"), |
|
2259 | + "invoice_active" => gettext("All Invoices") |
|
2260 | 2260 | ); |
2261 | 2261 | return $status_array; |
2262 | 2262 | } |
2263 | 2263 | // /*ASTPP_invoice_changes_05_05_start*/ |
2264 | 2264 | function get_invoice_template($invoicedata, $accountdata, $flag) { |
2265 | 2265 | // echo "<pre>";print_r($invoicedata);exit; |
2266 | - $login_info = $this->CI->session->userdata ( 'accountinfo' ); |
|
2267 | - $invoice_conf_res = array (); |
|
2266 | + $login_info = $this->CI->session->userdata('accountinfo'); |
|
2267 | + $invoice_conf_res = array(); |
|
2268 | 2268 | $reseller_id = ($accountdata ['reseller_id'] == 0) ? 1 : $accountdata ['reseller_id']; |
2269 | - $where = "accountid IN ('" . $reseller_id . "','1')"; |
|
2270 | - $this->CI->db->select ( '*' ); |
|
2271 | - $this->CI->db->where ( $where ); |
|
2272 | - $this->CI->db->order_by ( 'accountid', 'desc' ); |
|
2273 | - $this->CI->db->limit ( 1 ); |
|
2274 | - $invoice_conf = $this->CI->db->get ( 'invoice_conf' ); |
|
2275 | - $invoice_conf_res = ( array ) $invoice_conf->first_row (); |
|
2269 | + $where = "accountid IN ('".$reseller_id."','1')"; |
|
2270 | + $this->CI->db->select('*'); |
|
2271 | + $this->CI->db->where($where); |
|
2272 | + $this->CI->db->order_by('accountid', 'desc'); |
|
2273 | + $this->CI->db->limit(1); |
|
2274 | + $invoice_conf = $this->CI->db->get('invoice_conf'); |
|
2275 | + $invoice_conf_res = (array)$invoice_conf->first_row(); |
|
2276 | 2276 | |
2277 | - $accountdata ["currency_id"] = $this->get_field_name ( 'currency', 'currency', $accountdata ["currency_id"] ); |
|
2278 | - $accountdata ["country"] = $this->get_field_name ( 'country', 'countrycode', $accountdata ["country_id"] ); |
|
2277 | + $accountdata ["currency_id"] = $this->get_field_name('currency', 'currency', $accountdata ["currency_id"]); |
|
2278 | + $accountdata ["country"] = $this->get_field_name('country', 'countrycode', $accountdata ["country_id"]); |
|
2279 | 2279 | $data ["to_currency"] = Common_model::$global_config ['system_config'] ['base_currency']; |
2280 | 2280 | if ($login_info ['type'] == - 1) { |
2281 | 2281 | $currency = $data ["to_currency"]; |
2282 | 2282 | } elseif ($login_info ['type'] == 1) { |
2283 | - $accountdata ["currency_id"] = $this->get_field_name ( 'currency', 'currency', $login_info ["currency_id"] ); |
|
2283 | + $accountdata ["currency_id"] = $this->get_field_name('currency', 'currency', $login_info ["currency_id"]); |
|
2284 | 2284 | $currency = $accountdata ["currency_id"]; |
2285 | 2285 | } else { |
2286 | 2286 | $currency = $accountdata ["currency_id"]; |
2287 | 2287 | } |
2288 | 2288 | $decimal_amount = Common_model::$global_config ['system_config'] ['decimalpoints']; |
2289 | - ob_start (); |
|
2290 | - $this->CI->load->library ( '/html2pdf/html2pdf' ); |
|
2291 | - $this->CI->html2pdf = new HTML2PDF ( 'P', 'A4', 'en' ); |
|
2292 | - $this->CI->html2pdf->pdf->SetDisplayMode ( 'fullpage' ); |
|
2293 | - $template_config = $this->CI->config->item ( 'invoice_template' ); |
|
2294 | - include ($template_config . 'invoice_template.php'); |
|
2295 | - $content = ob_get_clean (); |
|
2296 | - ob_clean (); |
|
2289 | + ob_start(); |
|
2290 | + $this->CI->load->library('/html2pdf/html2pdf'); |
|
2291 | + $this->CI->html2pdf = new HTML2PDF('P', 'A4', 'en'); |
|
2292 | + $this->CI->html2pdf->pdf->SetDisplayMode('fullpage'); |
|
2293 | + $template_config = $this->CI->config->item('invoice_template'); |
|
2294 | + include ($template_config.'invoice_template.php'); |
|
2295 | + $content = ob_get_clean(); |
|
2296 | + ob_clean(); |
|
2297 | 2297 | $INVOICE_NUM = ''; |
2298 | 2298 | |
2299 | 2299 | $ACCOUNTADD = ''; |
@@ -2302,39 +2302,39 @@ discard block |
||
2302 | 2302 | $INVOICE_CHARGE = ''; |
2303 | 2303 | $total_sum = 0; |
2304 | 2304 | $total_vat = 0; |
2305 | - $fromdate = strtotime ( $invoicedata ['from_date'] ); |
|
2306 | - $from_date = date ( "Y-m-d", $fromdate ); |
|
2307 | - $duedate = strtotime ( $invoicedata ['due_date'] ); |
|
2308 | - $due_date = date ( "Y-m-d", $duedate ); |
|
2305 | + $fromdate = strtotime($invoicedata ['from_date']); |
|
2306 | + $from_date = date("Y-m-d", $fromdate); |
|
2307 | + $duedate = strtotime($invoicedata ['due_date']); |
|
2308 | + $due_date = date("Y-m-d", $duedate); |
|
2309 | 2309 | /** |
2310 | 2310 | * ****************************Invoivce number************************************************************* |
2311 | 2311 | */ |
2312 | - $INVOICE_NUM = '<td style="font-size: 10px;color:#000;font-family:arial; line-height: 22px;letter-spacing:02;float:right;"><b><h2>INVOICE :' . $invoicedata ["invoice_prefix"] . $invoicedata ["invoiceid"] . '</h2></b></td>'; |
|
2312 | + $INVOICE_NUM = '<td style="font-size: 10px;color:#000;font-family:arial; line-height: 22px;letter-spacing:02;float:right;"><b><h2>INVOICE :'.$invoicedata ["invoice_prefix"].$invoicedata ["invoiceid"].'</h2></b></td>'; |
|
2313 | 2313 | /** |
2314 | 2314 | * ************************* Company Address Code START ************************************************** |
2315 | 2315 | */ |
2316 | 2316 | //ASTPP_invoice_download_issue |
2317 | - $ACCOUNTADD .= '<tr><td style="width:100%;font-size: 12px;color:#000;font-family:arial; line-height: 22px;">' . $invoice_conf_res ['company_name'] . '</td>'; |
|
2317 | + $ACCOUNTADD .= '<tr><td style="width:100%;font-size: 12px;color:#000;font-family:arial; line-height: 22px;">'.$invoice_conf_res ['company_name'].'</td>'; |
|
2318 | 2318 | $ACCOUNTADD .= '</tr>'; |
2319 | 2319 | if ($invoice_conf_res ['address'] != "") { |
2320 | 2320 | |
2321 | - $ACCOUNTADD .= '<tr><td style="width:100%;font-size: 12px;color:#000;font-family:arial; line-height: 22px;">' . $invoice_conf_res ['address'] . '</td></tr>'; |
|
2321 | + $ACCOUNTADD .= '<tr><td style="width:100%;font-size: 12px;color:#000;font-family:arial; line-height: 22px;">'.$invoice_conf_res ['address'].'</td></tr>'; |
|
2322 | 2322 | } |
2323 | 2323 | if ($invoice_conf_res ['city'] != "") { |
2324 | 2324 | |
2325 | - $ACCOUNTADD .= '<tr><td style="width:100%;font-size: 12px;color:#000;font-family:arial; line-height: 22px;">' . $invoice_conf_res ['city'] . '</td></tr>'; |
|
2325 | + $ACCOUNTADD .= '<tr><td style="width:100%;font-size: 12px;color:#000;font-family:arial; line-height: 22px;">'.$invoice_conf_res ['city'].'</td></tr>'; |
|
2326 | 2326 | } |
2327 | 2327 | if ($invoice_conf_res ['province'] != "") { |
2328 | 2328 | |
2329 | - $ACCOUNTADD .= '<tr><td style="width:100%;font-size: 12px;color:#000;font-family:arial; line-height: 22px;">' . $invoice_conf_res ['province'] . '</td></tr>'; |
|
2329 | + $ACCOUNTADD .= '<tr><td style="width:100%;font-size: 12px;color:#000;font-family:arial; line-height: 22px;">'.$invoice_conf_res ['province'].'</td></tr>'; |
|
2330 | 2330 | } |
2331 | 2331 | if ($invoice_conf_res ['country'] != "") { |
2332 | 2332 | |
2333 | - $ACCOUNTADD .= '<tr><td style="width:100%;font-size: 12px;color:#000;font-family:arial; line-height: 22px;">' . $invoice_conf_res ['country'] . '</td></tr>'; |
|
2333 | + $ACCOUNTADD .= '<tr><td style="width:100%;font-size: 12px;color:#000;font-family:arial; line-height: 22px;">'.$invoice_conf_res ['country'].'</td></tr>'; |
|
2334 | 2334 | } |
2335 | 2335 | if ($invoice_conf_res ['zipcode'] != "") { |
2336 | 2336 | |
2337 | - $ACCOUNTADD .= '<tr><td style="width:100%;font-size: 12px;color:#000;font-family:arial; line-height: 22px;">' . $invoice_conf_res ['zipcode'] . '</td></tr>'; |
|
2337 | + $ACCOUNTADD .= '<tr><td style="width:100%;font-size: 12px;color:#000;font-family:arial; line-height: 22px;">'.$invoice_conf_res ['zipcode'].'</td></tr>'; |
|
2338 | 2338 | } |
2339 | 2339 | //END |
2340 | 2340 | /** |
@@ -2346,27 +2346,27 @@ discard block |
||
2346 | 2346 | */ |
2347 | 2347 | $ACCOUNTADD_CUSTOMER .= '<table align=right>'; |
2348 | 2348 | $ACCOUNTADD_CUSTOMER .= '<tr>'; |
2349 | - $ACCOUNTADD_CUSTOMER .= '<td align="right" style="width:100%;font-size: 12px;color:#000;font-family:arial; line-height: 22px;">' . $accountdata ['company_name'] . '</td></tr>'; |
|
2349 | + $ACCOUNTADD_CUSTOMER .= '<td align="right" style="width:100%;font-size: 12px;color:#000;font-family:arial; line-height: 22px;">'.$accountdata ['company_name'].'</td></tr>'; |
|
2350 | 2350 | |
2351 | 2351 | if ($accountdata ['address_1'] != "") { |
2352 | 2352 | |
2353 | - $ACCOUNTADD_CUSTOMER .= '<tr><td align="right" style="width:100%;font-size: 12px;color:#000;font-family:arial; line-height: 22px;">' . $accountdata ['address_1'] . '</td></tr>'; |
|
2353 | + $ACCOUNTADD_CUSTOMER .= '<tr><td align="right" style="width:100%;font-size: 12px;color:#000;font-family:arial; line-height: 22px;">'.$accountdata ['address_1'].'</td></tr>'; |
|
2354 | 2354 | } |
2355 | 2355 | if ($accountdata ['city'] != "") { |
2356 | 2356 | |
2357 | - $ACCOUNTADD_CUSTOMER .= '<tr><td align="right" style="width:100%;font-size: 12px;color:#000;font-family:arial; line-height: 22px;">' . $accountdata ['city'] . '</td></tr>'; |
|
2357 | + $ACCOUNTADD_CUSTOMER .= '<tr><td align="right" style="width:100%;font-size: 12px;color:#000;font-family:arial; line-height: 22px;">'.$accountdata ['city'].'</td></tr>'; |
|
2358 | 2358 | } |
2359 | 2359 | if ($accountdata ['province'] != "") { |
2360 | 2360 | |
2361 | - $ACCOUNTADD_CUSTOMER .= '<tr><td align="right" style="width:100%;font-size: 12px;color:#000;font-family:arial; line-height: 22px;">' . $accountdata ['province'] . '</td></tr>'; |
|
2361 | + $ACCOUNTADD_CUSTOMER .= '<tr><td align="right" style="width:100%;font-size: 12px;color:#000;font-family:arial; line-height: 22px;">'.$accountdata ['province'].'</td></tr>'; |
|
2362 | 2362 | } |
2363 | 2363 | if ($accountdata ['country'] != "") { |
2364 | 2364 | |
2365 | - $ACCOUNTADD_CUSTOMER .= '<tr><td align="right" style="width:100%;font-size: 12px;color:#000;font-family:arial; line-height: 22px;">' . $accountdata ['country'] . '</td></tr>'; |
|
2365 | + $ACCOUNTADD_CUSTOMER .= '<tr><td align="right" style="width:100%;font-size: 12px;color:#000;font-family:arial; line-height: 22px;">'.$accountdata ['country'].'</td></tr>'; |
|
2366 | 2366 | } |
2367 | 2367 | if ($accountdata ['postal_code'] != "") { |
2368 | 2368 | |
2369 | - $ACCOUNTADD_CUSTOMER .= '<tr><td align="right" style="width:100%;font-size: 12px;color:#000;font-family:arial; line-height: 22px;">' . $accountdata ['postal_code'] . '</td></tr>'; |
|
2369 | + $ACCOUNTADD_CUSTOMER .= '<tr><td align="right" style="width:100%;font-size: 12px;color:#000;font-family:arial; line-height: 22px;">'.$accountdata ['postal_code'].'</td></tr>'; |
|
2370 | 2370 | } |
2371 | 2371 | $ACCOUNTADD_CUSTOMER .= "</table>"; |
2372 | 2372 | /** |
@@ -2375,12 +2375,12 @@ discard block |
||
2375 | 2375 | /** |
2376 | 2376 | * *************************Invoice detail START ******************************************************* |
2377 | 2377 | */ |
2378 | - $recharge_amount = $invoice_details = $this->CI->db_model->getSelect ( 'sum(credit) as credit', 'invoice_details', array ( |
|
2378 | + $recharge_amount = $invoice_details = $this->CI->db_model->getSelect('sum(credit) as credit', 'invoice_details', array( |
|
2379 | 2379 | "invoiceid" => $invoicedata ['id'], |
2380 | 2380 | 'item_type' => 'INVPAY' |
2381 | - ) )->result_array (); |
|
2381 | + ))->result_array(); |
|
2382 | 2382 | |
2383 | - $recharge_amount = isset ( $recharge_amount [0] ['credit'] ) ? $recharge_amount [0] ['credit'] : '0'; |
|
2383 | + $recharge_amount = isset ($recharge_amount [0] ['credit']) ? $recharge_amount [0] ['credit'] : '0'; |
|
2384 | 2384 | $total_amount = $invoicedata ['amount'] - $recharge_amount; |
2385 | 2385 | $INVOICE_DETAIL .= '<tr> |
2386 | 2386 | <td style="width:100%;"> |
@@ -2388,28 +2388,28 @@ discard block |
||
2388 | 2388 | <tbody><tr> |
2389 | 2389 | |
2390 | 2390 | <td style="width:25%;"><b>Invoice Date :</b></td> |
2391 | - <td style="width:25%;text-align:right;border-right:1px solid #000; padding-right: 3px;">' . date ( "Y-m-d", strtotime ( $invoicedata ['invoice_date'] ) ) . '</td> |
|
2391 | + <td style="width:25%;text-align:right;border-right:1px solid #000; padding-right: 3px;">' . date("Y-m-d", strtotime($invoicedata ['invoice_date'])).'</td> |
|
2392 | 2392 | <td style="width:25%;padding-left: 5px;"><b>This Invoice Amount :</b> </td> |
2393 | - <td style="width:25%;text-align:right;">' . $this->currency_decimal ( $this->CI->common_model->calculate_currency ( $invoicedata ['amount'] ) ) . '</td> |
|
2393 | + <td style="width:25%;text-align:right;">' . $this->currency_decimal($this->CI->common_model->calculate_currency($invoicedata ['amount'])).'</td> |
|
2394 | 2394 | |
2395 | 2395 | </tr> |
2396 | 2396 | <tr> <td style="width:25%;"></td><td style="width:25%;border-right:1px solid #000;"></td></tr> |
2397 | 2397 | <tr> |
2398 | 2398 | <td style="width:25%;"><b>Invoice Due Date :</b></td> |
2399 | - <td style="width:25%;text-align:right;border-right:1px solid #000;padding-right: 3px;">' . $due_date . '</td> |
|
2399 | + <td style="width:25%;text-align:right;border-right:1px solid #000;padding-right: 3px;">' . $due_date.'</td> |
|
2400 | 2400 | <td style="width:25%;padding-left: 5px;"><b>Recharge Payments :</b> </td> |
2401 | - <td style="width:25%;text-align:right;">' . $this->currency_decimal ( $this->CI->common_model->calculate_currency ( $recharge_amount ) ) . '</td> |
|
2401 | + <td style="width:25%;text-align:right;">' . $this->currency_decimal($this->CI->common_model->calculate_currency($recharge_amount)).'</td> |
|
2402 | 2402 | |
2403 | 2403 | </tr> |
2404 | 2404 | <tr> <td style="width:25%;"></td><td style="width:25%;border-right:1px solid #000;"></td></tr> |
2405 | 2405 | <tr> |
2406 | 2406 | <td style="width:25%;border-bottom:1px solid #000;"><b>Account Number :</b></td> |
2407 | - <td style="width:25%;border-bottom:1px solid #000;text-align:right;border-right:1px solid #000;padding-right: 3px;">' . $accountdata ['number'] . '</td> |
|
2407 | + <td style="width:25%;border-bottom:1px solid #000;text-align:right;border-right:1px solid #000;padding-right: 3px;">' . $accountdata ['number'].'</td> |
|
2408 | 2408 | <td colspan="2" style="width:50%;padding-left: 3px;"> |
2409 | 2409 | <table style="border:1px solid #000;width:100%;"> |
2410 | 2410 | <tbody><tr> |
2411 | 2411 | <td style="width:50%;font-weight:bold;font-style:italic;">Total Amount :</td> |
2412 | - <td style="width:50%;text-align:right;font-style:italic;">' . $this->currency_decimal ( $this->CI->common_model->calculate_currency ( $total_amount ) ) . '</td> |
|
2412 | + <td style="width:50%;text-align:right;font-style:italic;">' . $this->currency_decimal($this->CI->common_model->calculate_currency($total_amount)).'</td> |
|
2413 | 2413 | </tr> |
2414 | 2414 | </tbody></table> |
2415 | 2415 | </td> |
@@ -2431,32 +2431,32 @@ discard block |
||
2431 | 2431 | <tr><th style="width:20%;border-left:1px solid #000;border-top:1px solid #000;border-bottom:1px solid #000;background-color:#EBEEF2;padding:5px;">Date </th> |
2432 | 2432 | <th style="width:40%;border-left:1px solid #000;border-top:1px solid #000;border-bottom:1px solid #000;background-color:#EBEEF2;padding:5px;">Description</th> |
2433 | 2433 | |
2434 | - <th style="width:15%;border-left:1px solid #000;border-top:1px solid #000;border-bottom:1px solid #000;background-color:#EBEEF2;padding:5px;">Unit Price (' . $currency . ')</th> |
|
2434 | + <th style="width:15%;border-left:1px solid #000;border-top:1px solid #000;border-bottom:1px solid #000;background-color:#EBEEF2;padding:5px;">Unit Price (' . $currency.')</th> |
|
2435 | 2435 | <th style="width:10%;border-left:1px solid #000;border-top:1px solid #000;border-bottom:1px solid #000;background-color:#EBEEF2;padding:5px;">Quantity</th> |
2436 | - <th style="width:15%;border-left:1px solid #000;border-right:1px solid #000;border-top:1px solid #000;border-bottom:1px solid #000;background-color:#EBEEF2;padding:5px;">Cost (' . $currency . ')</th> |
|
2436 | + <th style="width:15%;border-left:1px solid #000;border-right:1px solid #000;border-top:1px solid #000;border-bottom:1px solid #000;background-color:#EBEEF2;padding:5px;">Cost (' . $currency.')</th> |
|
2437 | 2437 | </tr> |
2438 | 2438 | '; |
2439 | - $this->CI->db->where ( 'item_type <>', 'INVPAY' ); |
|
2440 | - $invoice_details = $this->CI->db_model->getSelect ( '*', 'invoice_details', array ( |
|
2439 | + $this->CI->db->where('item_type <>', 'INVPAY'); |
|
2440 | + $invoice_details = $this->CI->db_model->getSelect('*', 'invoice_details', array( |
|
2441 | 2441 | "invoiceid" => $invoicedata ['id'], |
2442 | 2442 | 'item_type <>' => 'TAX' |
2443 | - ) ); |
|
2444 | - $invoice_details = $invoice_details->result_array (); |
|
2443 | + )); |
|
2444 | + $invoice_details = $invoice_details->result_array(); |
|
2445 | 2445 | |
2446 | - $invoice_tax = $this->CI->db_model->getSelect ( '*', 'invoice_details', array ( |
|
2446 | + $invoice_tax = $this->CI->db_model->getSelect('*', 'invoice_details', array( |
|
2447 | 2447 | "invoiceid" => $invoicedata ['id'], |
2448 | 2448 | 'item_type ' => 'TAX' |
2449 | - ) ); |
|
2449 | + )); |
|
2450 | 2450 | |
2451 | - foreach ( $invoice_details as $charge_res ) { |
|
2451 | + foreach ($invoice_details as $charge_res) { |
|
2452 | 2452 | |
2453 | 2453 | // echo "<pre>";print_r($charge_res['description']);exit; |
2454 | 2454 | $INVOICE_CHARGE .= '<tr > |
2455 | - <td style="width:20%;line-height:15px;border-left:1px solid #000;border-bottom:1px solid #000;padding:5px;">' . date ( 'Y-m-d', strtotime ( $charge_res ['created_date'] ) ) . '</td> |
|
2456 | - <td style="width:40%;line-height:15px;border-left:1px solid #000;border-bottom:1px solid #000;padding:5px;">' . $charge_res ['description'] . '</td> |
|
2457 | - <td style="width:15%;line-height:15px;border-left:1px solid #000;border-bottom:1px solid #000;text-align:right;padding:5px;">' . $this->currency_decimal ( $this->CI->common_model->calculate_currency ( $charge_res ['debit'] ) ) . '</td> |
|
2455 | + <td style="width:20%;line-height:15px;border-left:1px solid #000;border-bottom:1px solid #000;padding:5px;">' . date('Y-m-d', strtotime($charge_res ['created_date'])).'</td> |
|
2456 | + <td style="width:40%;line-height:15px;border-left:1px solid #000;border-bottom:1px solid #000;padding:5px;">' . $charge_res ['description'].'</td> |
|
2457 | + <td style="width:15%;line-height:15px;border-left:1px solid #000;border-bottom:1px solid #000;text-align:right;padding:5px;">' . $this->currency_decimal($this->CI->common_model->calculate_currency($charge_res ['debit'])).'</td> |
|
2458 | 2458 | <td style="width:10%;line-height:15px;border-left:1px solid #000;border-bottom:1px solid #000;text-align:right;padding:5px;">1</td> |
2459 | - <td style="width:15%;line-height:15px;border-right:1px solid #000;border-left:1px solid #000;border-bottom:1px solid #000;text-align:right;padding:5px;">' . $this->currency_decimal ( $this->CI->common_model->calculate_currency ( $charge_res ['debit'] ) ) . '</td> |
|
2459 | + <td style="width:15%;line-height:15px;border-right:1px solid #000;border-left:1px solid #000;border-bottom:1px solid #000;text-align:right;padding:5px;">' . $this->currency_decimal($this->CI->common_model->calculate_currency($charge_res ['debit'])).'</td> |
|
2460 | 2460 | </tr>'; |
2461 | 2461 | $total_sum += $charge_res ['debit']; |
2462 | 2462 | } |
@@ -2464,17 +2464,17 @@ discard block |
||
2464 | 2464 | $INVOICE_CHARGE .= '<tr> |
2465 | 2465 | <td></td><td></td> |
2466 | 2466 | <td colspan=2 style="border-left:1px solid #000;border-bottom:1px solid #000;width:20%;padding-left:5px;padding-top:5px;padding-bottom:5px;text-align:right;padding-right:5px;"><b>Sub Total</b></td> |
2467 | - <td style="border-left:1px solid #000;border-bottom:1px solid #000;border-right:1px solid #000;width:10%;text-align:right;padding-top:5px;padding-right:5px;">' . $this->currency_decimal ( $this->CI->common_model->calculate_currency ( $total_sum ) ) . '</td> |
|
2467 | + <td style="border-left:1px solid #000;border-bottom:1px solid #000;border-right:1px solid #000;width:10%;text-align:right;padding-top:5px;padding-right:5px;">' . $this->currency_decimal($this->CI->common_model->calculate_currency($total_sum)).'</td> |
|
2468 | 2468 | </tr>'; |
2469 | 2469 | |
2470 | - if ($invoice_tax->num_rows () > 0) { |
|
2471 | - foreach ( $invoice_tax->result_array () as $invoice_tax ) { |
|
2470 | + if ($invoice_tax->num_rows() > 0) { |
|
2471 | + foreach ($invoice_tax->result_array() as $invoice_tax) { |
|
2472 | 2472 | $total_vat += $invoice_tax ['debit']; |
2473 | - $total_vat = $this->currency_decimal ( $this->CI->common_model->calculate_currency ( $total_vat ) ); |
|
2473 | + $total_vat = $this->currency_decimal($this->CI->common_model->calculate_currency($total_vat)); |
|
2474 | 2474 | $INVOICE_CHARGE .= '<tr> |
2475 | 2475 | <td></td><td></td> |
2476 | - <td colspan=2 style="border-left:1px solid #000;border-bottom:1px solid #000;width:20%;padding-left:5px;padding-top:5px;padding-bottom:5px;text-align:right;padding-right:5px;"><b>Tax (' . $invoice_tax ["description"] . ')</b></td> |
|
2477 | - <td style="border-left:1px solid #000;border-bottom:1px solid #000;border-right:1px solid #000;width:10%;text-align:right;padding-top:5px;padding-right:5px;">' . $this->currency_decimal ( $total_vat ) . '</td> |
|
2476 | + <td colspan=2 style="border-left:1px solid #000;border-bottom:1px solid #000;width:20%;padding-left:5px;padding-top:5px;padding-bottom:5px;text-align:right;padding-right:5px;"><b>Tax (' . $invoice_tax ["description"].')</b></td> |
|
2477 | + <td style="border-left:1px solid #000;border-bottom:1px solid #000;border-right:1px solid #000;width:10%;text-align:right;padding-top:5px;padding-right:5px;">' . $this->currency_decimal($total_vat).'</td> |
|
2478 | 2478 | </tr>'; |
2479 | 2479 | } |
2480 | 2480 | } |
@@ -2482,7 +2482,7 @@ discard block |
||
2482 | 2482 | $INVOICE_CHARGE .= '<tr> |
2483 | 2483 | <td></td><td></td> |
2484 | 2484 | <td colspan=2 style="border-left:1px solid #000;border-bottom:1px solid #000;width:20%;padding-left:5px;padding-top:5px;padding-bottom:5px;text-align:right;padding-right:5px;"><b>Total</b> </td> |
2485 | - <td style="border-left:1px solid #000;border-bottom:1px solid #000;border-right:1px solid #000;width:10%;text-align:right;padding-top:5px;padding-right:5px;">' . $this->currency_decimal ( $sub_total ) . '</td> |
|
2485 | + <td style="border-left:1px solid #000;border-bottom:1px solid #000;border-right:1px solid #000;width:10%;text-align:right;padding-top:5px;padding-right:5px;">' . $this->currency_decimal($sub_total).'</td> |
|
2486 | 2486 | </tr> |
2487 | 2487 | |
2488 | 2488 | '; |
@@ -2494,11 +2494,11 @@ discard block |
||
2494 | 2494 | /** |
2495 | 2495 | * ************************* Invoice Note Code END ************************************************** |
2496 | 2496 | */ |
2497 | - $invoice_notes = $this->CI->db_model->getSelect ( '*', 'invoices', array ( |
|
2497 | + $invoice_notes = $this->CI->db_model->getSelect('*', 'invoices', array( |
|
2498 | 2498 | 'id' => $invoicedata ['id'] |
2499 | - ) ); |
|
2500 | - $invoice_notes = $invoice_notes->result_array (); |
|
2501 | - if (isset ( $invoice_notes [0] ['notes'] )) { |
|
2499 | + )); |
|
2500 | + $invoice_notes = $invoice_notes->result_array(); |
|
2501 | + if (isset ($invoice_notes [0] ['notes'])) { |
|
2502 | 2502 | $invoice_notes = $invoice_notes [0] ['notes']; |
2503 | 2503 | } else { |
2504 | 2504 | if ($invoice_notes [0] ['invoice_note'] == '0') { |
@@ -2511,113 +2511,113 @@ discard block |
||
2511 | 2511 | * ************************* Invoice Note Code END ************************************************** |
2512 | 2512 | */ |
2513 | 2513 | //ASTPP_invoice_download_issue |
2514 | - if (file_exists ( getcwd () . "/upload/" . $invoice_conf_res['accountid'] . "_" . $invoice_conf_res ['logo'] )) { |
|
2514 | + if (file_exists(getcwd()."/upload/".$invoice_conf_res['accountid']."_".$invoice_conf_res ['logo'])) { |
|
2515 | 2515 | if ($invoice_conf_res['logo'] != '') { |
2516 | - $content = str_replace ( "<LOGO>", FCPATH . "upload/" . $invoice_conf_res ['accountid'] . "_" . $invoice_conf_res['logo'], $content ); |
|
2516 | + $content = str_replace("<LOGO>", FCPATH."upload/".$invoice_conf_res ['accountid']."_".$invoice_conf_res['logo'], $content); |
|
2517 | 2517 | } else { |
2518 | - $content = str_replace ( "<LOGO>", FCPATH . '/assets/images/logo.png', $content ); |
|
2518 | + $content = str_replace("<LOGO>", FCPATH.'/assets/images/logo.png', $content); |
|
2519 | 2519 | } |
2520 | 2520 | } else { |
2521 | - $content = str_replace ( "<LOGO>", FCPATH . '/assets/images/logo.png', $content ); |
|
2521 | + $content = str_replace("<LOGO>", FCPATH.'/assets/images/logo.png', $content); |
|
2522 | 2522 | } |
2523 | 2523 | //END |
2524 | 2524 | |
2525 | - $content = str_replace ( "<INVOICE_NUM>", $INVOICE_NUM, $content ); |
|
2526 | - $content = str_replace ( "<ACCOUNTADD>", $ACCOUNTADD, $content ); |
|
2527 | - $content = str_replace ( "<ACCOUNTADD_CUSTOMER>", $ACCOUNTADD_CUSTOMER, $content ); |
|
2528 | - $content = str_replace ( "<INVOICE_DETAIL>", $INVOICE_DETAIL, $content ); |
|
2529 | - $content = str_replace ( "<INVOICE_CHARGE>", $INVOICE_CHARGE, $content ); |
|
2530 | - $content = str_replace ( "<NOTES>", $invoice_notes, $content ); |
|
2525 | + $content = str_replace("<INVOICE_NUM>", $INVOICE_NUM, $content); |
|
2526 | + $content = str_replace("<ACCOUNTADD>", $ACCOUNTADD, $content); |
|
2527 | + $content = str_replace("<ACCOUNTADD_CUSTOMER>", $ACCOUNTADD_CUSTOMER, $content); |
|
2528 | + $content = str_replace("<INVOICE_DETAIL>", $INVOICE_DETAIL, $content); |
|
2529 | + $content = str_replace("<INVOICE_CHARGE>", $INVOICE_CHARGE, $content); |
|
2530 | + $content = str_replace("<NOTES>", $invoice_notes, $content); |
|
2531 | 2531 | |
2532 | 2532 | // echo $content; exit; |
2533 | 2533 | |
2534 | - $invoice_path = $this->CI->config->item ( 'invoices_path' ); |
|
2535 | - $download_path = $invoice_path . $accountdata ["id"] . '/' . $invoicedata ['invoice_prefix'] . $invoicedata ['invoiceid'] . "_invoice.pdf"; |
|
2534 | + $invoice_path = $this->CI->config->item('invoices_path'); |
|
2535 | + $download_path = $invoice_path.$accountdata ["id"].'/'.$invoicedata ['invoice_prefix'].$invoicedata ['invoiceid']."_invoice.pdf"; |
|
2536 | 2536 | // echo $download_path; exit; |
2537 | - $this->CI->html2pdf->pdf->SetDisplayMode ( 'fullpage' ); |
|
2538 | - $this->CI->html2pdf->writeHTML ( $content ); |
|
2537 | + $this->CI->html2pdf->pdf->SetDisplayMode('fullpage'); |
|
2538 | + $this->CI->html2pdf->writeHTML($content); |
|
2539 | 2539 | |
2540 | 2540 | if ($flag == 'TRUE') { |
2541 | - $download_path = $invoicedata ['invoice_prefix'] . $invoicedata ['invoiceid'] . ".pdf"; |
|
2541 | + $download_path = $invoicedata ['invoice_prefix'].$invoicedata ['invoiceid'].".pdf"; |
|
2542 | 2542 | |
2543 | - $this->CI->html2pdf->Output ( $download_path, "D" ); |
|
2543 | + $this->CI->html2pdf->Output($download_path, "D"); |
|
2544 | 2544 | } else { |
2545 | - $current_dir = getcwd () . "/invoices/"; |
|
2545 | + $current_dir = getcwd()."/invoices/"; |
|
2546 | 2546 | $dir_name = $accountdata ["id"]; |
2547 | - if (! is_dir ( $current_dir . $dir_name )) { |
|
2548 | - mkdir ( $current_dir . $dir_name, 0777, true ); |
|
2549 | - chmod ( $current_dir . $dir_name, 0777 ); |
|
2547 | + if ( ! is_dir($current_dir.$dir_name)) { |
|
2548 | + mkdir($current_dir.$dir_name, 0777, true); |
|
2549 | + chmod($current_dir.$dir_name, 0777); |
|
2550 | 2550 | } |
2551 | - $invoice_path = $this->CI->config->item ( 'invoices_path' ); |
|
2552 | - $download_path = $invoice_path . $accountdata ["id"] . '/' . $invoicedata ['invoice_prefix'] . $invoicedata ['invoiceid'] . "_invoice.pdf"; |
|
2553 | - $this->CI->html2pdf->Output ( $download_path, "F" ); |
|
2551 | + $invoice_path = $this->CI->config->item('invoices_path'); |
|
2552 | + $download_path = $invoice_path.$accountdata ["id"].'/'.$invoicedata ['invoice_prefix'].$invoicedata ['invoiceid']."_invoice.pdf"; |
|
2553 | + $this->CI->html2pdf->Output($download_path, "F"); |
|
2554 | 2554 | } |
2555 | 2555 | } |
2556 | 2556 | // end |
2557 | 2557 | function reseller_select_value($select, $table, $id_where = '') { |
2558 | - $select_params = explode ( ',', $select ); |
|
2559 | - $where = array ( |
|
2558 | + $select_params = explode(',', $select); |
|
2559 | + $where = array( |
|
2560 | 2560 | "1" |
2561 | 2561 | ); |
2562 | 2562 | if ($id_where != '') { |
2563 | - $where = array ( |
|
2563 | + $where = array( |
|
2564 | 2564 | "id" => $id_where |
2565 | 2565 | ); |
2566 | 2566 | } |
2567 | - $select_params = explode ( ',', $select ); |
|
2567 | + $select_params = explode(',', $select); |
|
2568 | 2568 | $cnt_str = " $select_params[0],' ',$select_params[1],' ','(',$select_params[2],')' "; |
2569 | 2569 | $select = "concat($cnt_str) as $select_params[2] "; |
2570 | - $drp_array = $this->CI->db_model->getSelect ( $select, $table, $where ); |
|
2571 | - $drp_array = $drp_array->result (); |
|
2572 | - if (isset ( $drp_array [0] )) |
|
2570 | + $drp_array = $this->CI->db_model->getSelect($select, $table, $where); |
|
2571 | + $drp_array = $drp_array->result(); |
|
2572 | + if (isset ($drp_array [0])) |
|
2573 | 2573 | return $drp_array [0]->$select_params [2]; |
2574 | 2574 | else |
2575 | 2575 | return 'Admin'; |
2576 | 2576 | } |
2577 | 2577 | function get_subreseller_info($parent_id) { |
2578 | - if (! empty ( $parent_id )) { |
|
2579 | - $str = $parent_id . ","; |
|
2578 | + if ( ! empty ($parent_id)) { |
|
2579 | + $str = $parent_id.","; |
|
2580 | 2580 | } else { |
2581 | 2581 | $str = null; |
2582 | 2582 | } |
2583 | 2583 | $query = "select id from accounts where reseller_id = '$parent_id' AND deleted =0 AND type=1"; |
2584 | - $result = $this->CI->db->query ( $query ); |
|
2585 | - if ($result->num_rows () > 0) { |
|
2586 | - $result = $result->result_array (); |
|
2587 | - foreach ( $result as $data ) { |
|
2588 | - if (! empty ( $data ['id'] )) { |
|
2589 | - $str .= $this->get_subreseller_info ( $data ['id'] ); |
|
2584 | + $result = $this->CI->db->query($query); |
|
2585 | + if ($result->num_rows() > 0) { |
|
2586 | + $result = $result->result_array(); |
|
2587 | + foreach ($result as $data) { |
|
2588 | + if ( ! empty ($data ['id'])) { |
|
2589 | + $str .= $this->get_subreseller_info($data ['id']); |
|
2590 | 2590 | } |
2591 | 2591 | } |
2592 | 2592 | } |
2593 | 2593 | return $str; |
2594 | 2594 | } |
2595 | 2595 | function get_parent_info($child_id, $parent_id) { |
2596 | - if (! empty ( $child_id )) { |
|
2597 | - $str = $child_id . ","; |
|
2596 | + if ( ! empty ($child_id)) { |
|
2597 | + $str = $child_id.","; |
|
2598 | 2598 | } else { |
2599 | 2599 | $str = null; |
2600 | 2600 | } |
2601 | 2601 | if ($child_id > 0) { |
2602 | 2602 | $query = "select reseller_id from accounts where id = '$child_id'"; |
2603 | - $result = $this->CI->db->query ( $query ); |
|
2604 | - if ($result->num_rows () > 0) { |
|
2605 | - $parent_info = ( array ) $result->first_row (); |
|
2603 | + $result = $this->CI->db->query($query); |
|
2604 | + if ($result->num_rows() > 0) { |
|
2605 | + $parent_info = (array)$result->first_row(); |
|
2606 | 2606 | if ($parent_info ['reseller_id'] != $parent_id) { |
2607 | - $str .= $this->get_parent_info ( $parent_info ['reseller_id'], $parent_id ); |
|
2607 | + $str .= $this->get_parent_info($parent_info ['reseller_id'], $parent_id); |
|
2608 | 2608 | } |
2609 | 2609 | } |
2610 | 2610 | } |
2611 | 2611 | return $str; |
2612 | 2612 | } |
2613 | 2613 | function get_did_accountid($select, $table, $where) { |
2614 | - $accountinfo = $this->CI->session->userdata ( 'accountinfo' ); |
|
2615 | - $this->CI->db->where ( 'note', $where ); |
|
2616 | - $this->CI->db->where ( 'parent_id', $accountinfo ['id'] ); |
|
2617 | - $this->CI->db->select ( 'reseller_id' ); |
|
2618 | - $reseller_pricing_result = $this->CI->db->get ( 'reseller_pricing' ); |
|
2619 | - $account_info = ( array ) $reseller_pricing_result->first_row (); |
|
2620 | - $account_name = $this->get_field_name_coma_new ( 'first_name,last_name,number', 'accounts', $account_info ['reseller_id'] ); |
|
2614 | + $accountinfo = $this->CI->session->userdata('accountinfo'); |
|
2615 | + $this->CI->db->where('note', $where); |
|
2616 | + $this->CI->db->where('parent_id', $accountinfo ['id']); |
|
2617 | + $this->CI->db->select('reseller_id'); |
|
2618 | + $reseller_pricing_result = $this->CI->db->get('reseller_pricing'); |
|
2619 | + $account_info = (array)$reseller_pricing_result->first_row(); |
|
2620 | + $account_name = $this->get_field_name_coma_new('first_name,last_name,number', 'accounts', $account_info ['reseller_id']); |
|
2621 | 2621 | return $account_name; |
2622 | 2622 | } |
2623 | 2623 | function get_status_new($select = "", $table = "", $status = "") { |
@@ -2625,16 +2625,16 @@ discard block |
||
2625 | 2625 | } |
2626 | 2626 | // ASTPP_invoice_changes_05_05_start |
2627 | 2627 | function Get_Invoice_configuration($AccountData) { |
2628 | - $InvoiceConf = array (); |
|
2628 | + $InvoiceConf = array(); |
|
2629 | 2629 | $reseller_id = ($AccountData ['reseller_id'] == 0) ? 1 : $AccountData ['reseller_id']; |
2630 | - $where = "accountid IN ('" . $reseller_id . "','1')"; |
|
2631 | - $this->CI->db->select ( '*' ); |
|
2632 | - $this->CI->db->where ( $where ); |
|
2633 | - $this->CI->db->order_by ( 'accountid', 'desc' ); |
|
2634 | - $this->CI->db->limit ( 1 ); |
|
2635 | - $InvoiceConf = $this->CI->db->get ( 'invoice_conf' ); |
|
2636 | - $InvoiceConf = ( array ) $InvoiceConf->first_row (); |
|
2637 | - $InvoiceConf ['invoice_prefix'] = str_pad ( $InvoiceConf ['invoice_prefix'], (strlen ( $InvoiceConf ['invoice_prefix'] ) + 4), '0', STR_PAD_RIGHT ); |
|
2630 | + $where = "accountid IN ('".$reseller_id."','1')"; |
|
2631 | + $this->CI->db->select('*'); |
|
2632 | + $this->CI->db->where($where); |
|
2633 | + $this->CI->db->order_by('accountid', 'desc'); |
|
2634 | + $this->CI->db->limit(1); |
|
2635 | + $InvoiceConf = $this->CI->db->get('invoice_conf'); |
|
2636 | + $InvoiceConf = (array)$InvoiceConf->first_row(); |
|
2637 | + $InvoiceConf ['invoice_prefix'] = str_pad($InvoiceConf ['invoice_prefix'], (strlen($InvoiceConf ['invoice_prefix']) + 4), '0', STR_PAD_RIGHT); |
|
2638 | 2638 | |
2639 | 2639 | return $InvoiceConf; |
2640 | 2640 | } |
@@ -21,8 +21,9 @@ discard block |
||
21 | 21 | // You should have received a copy of the GNU Affero General Public License |
22 | 22 | // along with this program. If not, see <http://www.gnu.org/licenses/>. |
23 | 23 | // ############################################################################## |
24 | -if (! defined ( 'BASEPATH' )) |
|
24 | +if (! defined ( 'BASEPATH' )) { |
|
25 | 25 | exit ( 'No direct script access allowed' ); |
26 | +} |
|
26 | 27 | |
27 | 28 | /** |
28 | 29 | * Dynamically build forms for display |
@@ -116,8 +117,9 @@ discard block |
||
116 | 117 | $flag = false; |
117 | 118 | $uname = $this->random_string ( $length ); |
118 | 119 | $uname = strtolower ( $uname ); |
119 | - if (isset ( $default )) |
|
120 | - $uname = $default . $uname; |
|
120 | + if (isset ( $default )) { |
|
121 | + $uname = $default . $uname; |
|
122 | + } |
|
121 | 123 | if (! in_array ( $uname, $number )) { |
122 | 124 | $where = array ( |
123 | 125 | $field => $uname |
@@ -657,8 +659,9 @@ discard block |
||
657 | 659 | $posttoexternal = $this->get_field_name ( "posttoexternal", "accounts", array ( |
658 | 660 | "id" => $accountid |
659 | 661 | ) ); |
660 | - if ($posttoexternal == 1) |
|
661 | - $where ['type'] = "I"; |
|
662 | + if ($posttoexternal == 1) { |
|
663 | + $where ['type'] = "I"; |
|
664 | + } |
|
662 | 665 | } |
663 | 666 | $invoice_res = $this->CI->db_model->select ( $select, "invoices", $where, $order_by, "DESC", "1", "0" ); |
664 | 667 | if ($invoice_res->num_rows > 0) { |
@@ -1077,14 +1080,18 @@ discard block |
||
1077 | 1080 | $data = explode ( "/", $url ); |
1078 | 1081 | $link = base_url () . $url . "" . $linkid; |
1079 | 1082 | foreach ( $data as $key => $value ) { |
1080 | - if ($value == 'price_delete') |
|
1081 | - $flag = '1'; |
|
1082 | - if ($value == 'trunk_remove') |
|
1083 | - $flag = '2'; |
|
1084 | - if ($value == 'customer_delete' || $value == 'provider_delete') |
|
1085 | - $flag = '3'; |
|
1086 | - if ($value == 'reseller_delete') |
|
1087 | - $flag = '4'; |
|
1083 | + if ($value == 'price_delete') { |
|
1084 | + $flag = '1'; |
|
1085 | + } |
|
1086 | + if ($value == 'trunk_remove') { |
|
1087 | + $flag = '2'; |
|
1088 | + } |
|
1089 | + if ($value == 'customer_delete' || $value == 'provider_delete') { |
|
1090 | + $flag = '3'; |
|
1091 | + } |
|
1092 | + if ($value == 'reseller_delete') { |
|
1093 | + $flag = '4'; |
|
1094 | + } |
|
1088 | 1095 | } |
1089 | 1096 | if ($flag == '1') { |
1090 | 1097 | $where = array ( |
@@ -2569,10 +2576,11 @@ discard block |
||
2569 | 2576 | $select = "concat($cnt_str) as $select_params[2] "; |
2570 | 2577 | $drp_array = $this->CI->db_model->getSelect ( $select, $table, $where ); |
2571 | 2578 | $drp_array = $drp_array->result (); |
2572 | - if (isset ( $drp_array [0] )) |
|
2573 | - return $drp_array [0]->$select_params [2]; |
|
2574 | - else |
|
2575 | - return 'Admin'; |
|
2579 | + if (isset ( $drp_array [0] )) { |
|
2580 | + return $drp_array [0]->$select_params [2]; |
|
2581 | + } else { |
|
2582 | + return 'Admin'; |
|
2583 | + } |
|
2576 | 2584 | } |
2577 | 2585 | function get_subreseller_info($parent_id) { |
2578 | 2586 | if (! empty ( $parent_id )) { |