1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
############################################################################### |
4
|
|
|
# ASTPP - Open Source VoIP Billing Solution |
5
|
|
|
# |
6
|
|
|
# Copyright (C) 2016 iNextrix Technologies Pvt. Ltd. |
7
|
|
|
# Samir Doshi <[email protected]> |
8
|
|
|
# ASTPP Version 3.0 and above |
9
|
|
|
# License https://www.gnu.org/licenses/agpl-3.0.html |
10
|
|
|
# |
11
|
|
|
# This program is free software: you can redistribute it and/or modify |
12
|
|
|
# it under the terms of the GNU Affero General Public License as |
13
|
|
|
# published by the Free Software Foundation, either version 3 of the |
14
|
|
|
# License, or (at your option) any later version. |
15
|
|
|
# |
16
|
|
|
# This program is distributed in the hope that it will be useful, |
17
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
18
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
19
|
|
|
# GNU Affero General Public License for more details. |
20
|
|
|
# |
21
|
|
|
# You should have received a copy of the GNU Affero General Public License |
22
|
|
|
# along with this program. If not, see <http://www.gnu.org/licenses/>. |
23
|
|
|
############################################################################### |
24
|
|
|
|
25
|
|
|
class User extends MX_Controller { |
26
|
|
|
|
27
|
|
View Code Duplication |
function User() { |
28
|
|
|
parent::__construct(); |
|
|
|
|
29
|
|
|
$this->load->helper('template_inheritance'); |
30
|
|
|
$this->load->helper('form'); |
31
|
|
|
$this->load->library("astpp/form"); |
32
|
|
|
$this->load->library("user_form"); |
33
|
|
|
$this->load->model('Auth_model'); |
34
|
|
|
$this->load->model('Astpp_common'); |
35
|
|
|
$this->load->model('user_model'); |
36
|
|
|
} |
37
|
|
|
|
38
|
|
|
function index() { |
39
|
|
|
if ($this->session->userdata('user_login') == FALSE) |
40
|
|
|
redirect(base_url() . 'login/login'); |
41
|
|
|
$data['page_title'] = 'Dashboard'; |
|
|
|
|
42
|
|
|
$this->load->view('view_user_dashboard', $data); |
43
|
|
|
} |
44
|
|
|
|
45
|
|
|
function user_dashboard_recent_payments() { |
46
|
|
|
$result=$this->user_model->user_dashboard_recent_recharge_info(); |
47
|
|
|
$gmtoffset=$this->common->get_timezone_offset(); |
48
|
|
|
$i=0; |
49
|
|
|
$json_data=array(); |
50
|
|
|
if($result->num_rows() > 0) |
51
|
|
|
{ |
52
|
|
|
$account_arr = $this->common->get_array('id,number,first_name,last_name', 'accounts',''); |
53
|
|
|
$json_data[0]['accountid']='Accounts'; |
54
|
|
|
$json_data[0]['credit']='Amount'; |
55
|
|
|
$json_data[0]['payment_date']='Date'; |
56
|
|
|
$json_data[0]['notes']='Notes'; |
57
|
|
|
foreach($result->result_array() as $key=>$data){ |
58
|
|
|
$current_timestamp=strtotime($data['payment_date']); |
59
|
|
|
$modified_date=$current_timestamp+$gmtoffset; |
60
|
|
|
$data['accountid'] = ($data['accountid'] != '' && isset($account_arr[$data['accountid']])) ? $account_arr[$data['accountid']] :"Anonymous"; |
61
|
|
|
$json_data[$i]['accountid']=$data['accountid']; |
62
|
|
|
$json_data[$i]['credit']=$this->common_model->calculate_currency($data['credit'],'','',true,false); |
63
|
|
|
$json_data[$i]['payment_date']=date('Y-m-d H:i:s',strtotime($data['payment_date'])+$gmtoffset); |
64
|
|
|
$json_data[$i]['notes']=$data['notes']; |
65
|
|
|
$i++; |
66
|
|
|
} |
67
|
|
|
} |
68
|
|
|
echo json_encode($json_data); |
69
|
|
|
} |
70
|
|
|
|
71
|
|
|
function user_dashboard_package_data() { |
72
|
|
|
$accountinfo = $this->session->userdata('accountinfo'); |
73
|
|
|
$json_data = array(); |
74
|
|
|
$this->db->where('pricelist_id', $accountinfo['pricelist_id']); |
75
|
|
|
$this->db->select('*'); |
76
|
|
|
$result = $this->db->get('packages', 10); |
77
|
|
|
$i = 1; |
78
|
|
|
if ($result->num_rows() > 0) { |
79
|
|
|
$json_data[0]['package_name'] = 'Package Name'; |
80
|
|
|
$json_data[0]['includedseconds'] = 'Included Seconds'; |
81
|
|
|
$json_data[0]['status'] = 'Status'; |
82
|
|
|
$result = $result->result_array(); |
83
|
|
|
foreach ($result as $data) { |
84
|
|
|
$json_data[$i]['package_name'] = $data['package_name']; |
85
|
|
|
$json_data[$i]['includedseconds'] = $data['includedseconds']; |
86
|
|
|
$json_data[$i]['status'] = $this->common->get_status('export', '', $data['status']); |
87
|
|
|
$i++; |
88
|
|
|
} |
89
|
|
|
} |
90
|
|
|
echo json_encode($json_data); |
91
|
|
|
} |
92
|
|
|
function user_dashboard_invoices_data() { |
93
|
|
|
$accountinfo = $this->session->userdata('accountinfo'); |
94
|
|
|
$currency=$this->common->get_field_name('currency','currency',array("id"=>$accountinfo['currency_id'])); |
95
|
|
|
$this->db->where('accountid', $accountinfo['id']); |
96
|
|
|
$this->db->where('confirm', 1); |
97
|
|
|
$this->db->select('*'); |
98
|
|
|
$this->db->order_by('invoice_date', 'desc'); |
99
|
|
|
$result = $this->db->get('invoices', 10); |
100
|
|
|
$json_data = array(); |
101
|
|
|
$gmtoffset = $this->common->get_timezone_offset(); |
102
|
|
|
if ($result->num_rows() > 0) { |
103
|
|
|
$result = $result->result_array(); |
104
|
|
|
$json_data[0]['type'] = 'Invoice Type'; |
105
|
|
|
$json_data[0]['id'] = 'Number'; |
106
|
|
|
$json_data[0]['from_date'] = 'From Date'; |
107
|
|
|
$json_data[0]['invoice_date'] = 'Generated Date'; |
108
|
|
|
$json_data[0]['amount'] = 'Amount ('.$currency.')'; |
109
|
|
|
$i = 1; |
110
|
|
|
foreach ($result as $key => $data) { |
111
|
|
|
$invoice_prefix= $entity_type =$this->common->get_field_name('invoice_prefix','invoices',array('id'=>$data['id'])); |
112
|
|
|
|
113
|
|
|
$invoiceid= $entity_type =$this->common->get_field_name('invoiceid','invoices',array('id'=>$data['id'])); |
114
|
|
|
$invoice_num=$invoice_prefix.$invoiceid; |
115
|
|
|
$inv_type=$this->common->get_invoice_total('item_type', '', $data['id']); |
116
|
|
|
if($inv_type == ''){ |
117
|
|
|
$inv_type='Automatically'; |
118
|
|
|
} |
119
|
|
|
if($inv_type == 'manual_inv'){ |
120
|
|
|
$inv_type='Manually'; |
121
|
|
|
} |
122
|
|
|
$inv_debit=$this->common->convert_to_currency('', '', $data['amount']); |
123
|
|
|
if($inv_debit == ''){ |
124
|
|
|
$inv_debit=$this->common->convert_to_currency('', '',0); |
125
|
|
|
} |
126
|
|
|
$json_data[$i]['type'] = $data['type']; |
127
|
|
|
$json_data[$i]['id'] = $invoice_num; |
128
|
|
|
$json_data[$i]['from_date'] = date('Y-m-d H:i:s', strtotime($data['from_date']) + $gmtoffset); |
129
|
|
|
$json_data[$i]['invoice_date'] = date('Y-m-d H:i:s', strtotime($data['invoice_date']) + $gmtoffset); |
130
|
|
|
$json_data[$i]['amount'] = $inv_debit; |
131
|
|
|
$i++; |
132
|
|
|
} |
133
|
|
|
} |
134
|
|
|
echo json_encode($json_data); |
135
|
|
|
} |
136
|
|
|
|
137
|
|
|
function user_dashboard_subscription_data(){ |
138
|
|
|
$accountinfo=$this->session->userdata('accountinfo'); |
139
|
|
|
$this->db->where('accountid',$accountinfo['id']); |
140
|
|
|
$this->db->select('*'); |
141
|
|
|
$this->db->order_by('assign_date','desc'); |
142
|
|
|
$result=$this->db->get('charge_to_account',10); |
143
|
|
|
$json_data=array(); |
144
|
|
|
|
145
|
|
|
$gmtoffset=$this->common->get_timezone_offset(); |
146
|
|
|
if($result->num_rows()> 0 ){ |
147
|
|
|
$result=$result->result_array(); |
148
|
|
|
$charge_str=null; |
149
|
|
|
$charges_arr=array(); |
150
|
|
|
foreach($result as $charges_data){ |
151
|
|
|
$charge_str.=$charges_data['charge_id'].","; |
152
|
|
|
} |
153
|
|
|
$charge_str=rtrim($charge_str,","); |
154
|
|
|
$where = "id IN ($charge_str)"; |
155
|
|
|
$this->db->where($where); |
156
|
|
|
$this->db->select('id,description,sweep_id'); |
157
|
|
|
$charge_result=$this->db->get('charges'); |
158
|
|
|
foreach($charge_result->result_array() as $data){ |
159
|
|
|
$charges_arr[$data['id']]['description']=$data['description']; |
160
|
|
|
$charges_arr[$data['id']]['sweep_id']=$data['sweep_id']; |
161
|
|
|
} |
162
|
|
|
$json_data[0]['charge_id']='Charge Name'; |
163
|
|
|
$json_data[0]['assign_date']='Assign Date'; |
164
|
|
|
$json_data[0]['sweep_id']='Billing Cycle'; |
165
|
|
|
$i=1; |
166
|
|
|
foreach($result as $key=>$data){ |
167
|
|
|
if(isset($charges_arr[$data['charge_id']]['sweep_id'])){ |
168
|
|
|
$sweep_id= $charges_arr[$data['charge_id']]['sweep_id']; |
169
|
|
|
} |
170
|
|
|
$data['charge_id'] =isset($charges_arr[$data['charge_id']]['description']) ? $charges_arr[$data['charge_id']]['description'] :"Anonymous"; |
171
|
|
|
$json_data[$i]['charge_id']=$data['charge_id']; |
172
|
|
|
if($data['assign_date'] != '0000-00-00 00:00:00'){ |
173
|
|
|
$json_data[$i]['assign_date']=date('Y-m-d H:i:s',strtotime($data['assign_date'])+$gmtoffset); |
174
|
|
|
} else{ |
175
|
|
|
$json_data[$i]['assign_date']=$data['assign_date']; |
176
|
|
|
} |
177
|
|
|
if(isset($sweep_id)){ |
178
|
|
|
if($sweep_id ==0){ |
179
|
|
|
$json_data[$i]['sweep_id']='Daily'; |
180
|
|
|
} else{ |
181
|
|
|
$json_data[$i]['sweep_id']='Monthly'; |
182
|
|
|
} |
183
|
|
|
} else{ |
184
|
|
|
$json_data[$i]['sweep_id']='Anonymous'; |
185
|
|
|
} |
186
|
|
|
$i++; |
187
|
|
|
} |
188
|
|
|
} |
189
|
|
|
echo json_encode($json_data); |
190
|
|
|
} |
191
|
|
|
|
192
|
|
|
function user_edit_account() { |
193
|
|
|
if ($add_array['id'] != '') { |
|
|
|
|
194
|
|
|
$data['form'] = $this->form->build_form($this->accounts->accounts_form->get_user_form_fields($add_array['id']), $add_array); |
|
|
|
|
195
|
|
|
$data['page_title'] = 'Edit ' . $entity_name; |
|
|
|
|
196
|
|
|
if ($this->form_validation->run() == FALSE) { |
197
|
|
|
$data['validation_errors'] = validation_errors(); |
198
|
|
|
} else { |
199
|
|
|
$add_array['password'] = $this->common->encode($add_array['password']); |
|
|
|
|
200
|
|
|
unset($add_array['number']); |
201
|
|
|
$this->accounts->accounts_model->edit_account($add_array, $add_array['id']); |
202
|
|
|
$accountinfo = $this->session->userdata('accountinfo'); |
203
|
|
|
if ($add_array['id'] == $accountinfo['id']) { |
204
|
|
|
$this->session->set_userdata('accountinfo',(array)$this->db->get_where('accounts', array('id' => $add_array['id']))->first_row()); |
205
|
|
|
} |
206
|
|
|
$this->session->set_flashdata('astpp_errormsg', ucfirst($entity_name) . ' updated successfully!'); |
207
|
|
|
redirect(base_url() . 'user/user/'); |
208
|
|
|
} |
209
|
|
|
$this->load->view('view_user_details', $data); |
210
|
|
|
} else { |
211
|
|
|
$data['page_title'] = 'Edit ' . $entity_name; |
|
|
|
|
212
|
|
|
$where = array('id' => $account_data["id"]); |
|
|
|
|
213
|
|
|
$account = $this->db_model->getSelect("*", "accounts", $where); |
214
|
|
|
$data["account_data"] = $account->result_array(); |
215
|
|
|
|
216
|
|
|
foreach ($account->result_array() as $key => $value) { |
217
|
|
|
$editable_data = $value; |
218
|
|
|
} |
219
|
|
|
$editable_data['password'] = $this->common->decode($editable_data['password']); |
|
|
|
|
220
|
|
|
$data['form'] = $this->form->build_form($this->accounts->accounts_form->get_user_form_fields($editable_data['id']), $editable_data); |
221
|
|
|
$this->load->view('view_user_details', $data); |
222
|
|
|
} |
223
|
|
|
} |
224
|
|
|
|
225
|
|
|
function user_did_edit($edit_id = '') { |
226
|
|
|
$data['page_title'] = 'Edit DIDs'; |
|
|
|
|
227
|
|
|
$account_data = $this->session->userdata("accountinfo"); |
228
|
|
|
$this->db->where('id',$edit_id); |
229
|
|
|
$this->db->select('id,call_type,extensions,number'); |
230
|
|
|
$did_info=(array)$this->db->get('dids')->first_row(); |
231
|
|
|
$did_info['free_didlist']=$did_info['id']; |
232
|
|
|
$data['form'] = $this->form->build_form($this->user_form->build_user_did_form(),$did_info); |
233
|
|
|
$this->load->view('view_user_did_edit', $data); |
234
|
|
|
} |
235
|
|
|
|
236
|
|
|
function user_dids_action($action,$did_id = "") { |
237
|
|
|
$accountinfo = $this->session->userdata('accountinfo'); |
238
|
|
|
$reseller_id = $accountinfo['reseller_id']; |
239
|
|
|
$did_id = empty($did_id) ? $this->input->post("free_didlist", true) : $did_id; |
240
|
|
|
|
241
|
|
|
if($did_id !=''){ |
242
|
|
|
$account_query = $this->db_model->getSelect("*", "accounts",array('id' => $accountinfo['id'])); |
243
|
|
|
$account_arr = (array) $account_query->first_row(); |
244
|
|
|
$did_query = $this->db_model->getSelect("*", "dids", array("id" => $did_id)); |
245
|
|
|
$did_arr = (array) $did_query->first_row(); |
246
|
|
|
if ($action == "add"){ |
247
|
|
|
if($did_arr['accountid'] == 0 && $did_arr['parent_id'] == $reseller_id ) { |
248
|
|
|
$setup_cost=$did_arr['setup']; |
249
|
|
|
if ($accountinfo["reseller_id"] > 0) { |
250
|
|
|
$reseller_pricing_res = $this->db_model->getSelect("*", "reseller_pricing", array("note" => $did_arr['number'],"reseller_id"=>$accountinfo['reseller_id'])); |
251
|
|
|
$reseller_pricing_arr = (array)$reseller_pricing_res->first_row(); |
252
|
|
|
$setup_cost=$reseller_pricing_arr['setup']; |
253
|
|
|
} |
254
|
|
|
$available_bal = $this->db_model->get_available_bal($account_arr); |
255
|
|
|
if ($available_bal >= $setup_cost) { |
256
|
|
|
$available_bal = $this->db_model->update_balance($setup_cost,$accountinfo["id"], "debit"); |
257
|
|
|
$accountinfo=(array)$this->db->get_where('accounts',array("id"=>$accountinfo['id']))->first_row(); |
258
|
|
|
$this->common->add_invoice_details($accountinfo,"DIDCHRG",$setup_cost,$did_arr['number']); |
259
|
|
|
$this->db_model->update("dids", array("accountid" => $accountinfo["id"],"assign_date" => gmdate('Y-m-d H:i:s')), array("id" => $did_id)); |
260
|
|
|
$this->common->mail_to_users('email_add_did', $account_arr,"",$did_arr['number']); |
261
|
|
|
$this->session->set_flashdata('astpp_errormsg', 'Did added successfully.'); |
262
|
|
|
redirect(base_url() . "user/user_didlist/"); |
263
|
|
|
} else { |
264
|
|
|
$this->session->set_flashdata('astpp_notification', 'Insuffiecient fund to purchase this did'); |
265
|
|
|
redirect(base_url() . "user/user_didlist/"); |
266
|
|
|
} |
267
|
|
|
}else{ |
268
|
|
|
$this->session->set_flashdata('astpp_notification', 'This DID already purchased by someone.'); |
269
|
|
|
redirect(base_url() . "user/user_didlist/"); |
270
|
|
|
} |
271
|
|
|
} |
272
|
|
|
if ($action == "edit") { |
273
|
|
|
$add_array=$this->input->post(); |
274
|
|
|
$data['form'] = $this->form->build_form($this->user_form->build_user_did_form($add_array['free_didlist']), $add_array); |
|
|
|
|
275
|
|
|
if ($this->form_validation->run() == FALSE) { |
276
|
|
|
$data['validation_errors'] = validation_errors(); |
277
|
|
|
echo $data['validation_errors']; |
278
|
|
|
exit; |
279
|
|
|
} else { |
280
|
|
|
$update_arr = array("call_type" => $add_array['call_type'], |
281
|
|
|
"extensions" => $add_array['extensions'],"last_modified_date"=>gmdate("Y-m-d H:i:s") |
282
|
|
|
); |
283
|
|
|
$this->db->update("dids", $update_arr, array("id" => $did_id)); |
284
|
|
|
if($accountinfo['reseller_id'] > 0 ){ |
285
|
|
|
|
286
|
|
|
$this->db->update('reseller_pricing',$update_arr,array('note'=>$did_arr['number'])); |
287
|
|
|
} |
288
|
|
|
echo json_encode(array("SUCCESS" => $did_arr['number'] . " DID Updated Successfully!")); |
289
|
|
|
exit; |
290
|
|
|
} |
291
|
|
|
$this->load->view('view_user_did_edit', $data); |
|
|
|
|
292
|
|
|
} |
293
|
|
|
if ($action == "delete") { |
294
|
|
|
$this->db->update("dids", array("accountid" =>0,"assign_date" =>"0000-00-00 00:00:00" , 'charge_upto'=>"0000-00-00 00:00:00"),array("id" => $did_id)); |
295
|
|
|
$this->common->mail_to_users('email_remove_did', $account_arr,"",$did_arr['number']); |
296
|
|
|
$this->session->set_flashdata('astpp_notification', 'DID Removed Successfully.'); |
297
|
|
|
redirect(base_url() . "user/user_didlist/"); |
298
|
|
|
} |
299
|
|
|
}else{ |
300
|
|
|
$this->session->set_flashdata('astpp_notification', 'DID not found.'); |
301
|
|
|
redirect(base_url() . "user/user_didlist/"); |
302
|
|
|
} |
303
|
|
|
} |
304
|
|
|
|
305
|
|
View Code Duplication |
function user_rates_list() { |
306
|
|
|
$data['username'] = $this->session->userdata('user_name'); |
|
|
|
|
307
|
|
|
$data['page_title'] = 'My Rates'; |
308
|
|
|
$data['search_flag'] = true; |
309
|
|
|
$this->session->set_userdata('advance_search', 0); |
310
|
|
|
$this->load->module('rates/rates'); |
311
|
|
|
$data["grid_buttons"] = $this->user_form->user_rates_list_buttons(); |
312
|
|
|
$data['grid_fields'] = $this->user_form->user_rates_list(); |
313
|
|
|
$data['form_search'] = $this->form->build_serach_form($this->user_form->user_rates_list_search()); |
314
|
|
|
$this->load->view('view_user_rates_list', $data); |
315
|
|
|
} |
316
|
|
|
|
317
|
|
|
function user_rates_list_json() { |
318
|
|
|
$account_data = $this->session->userdata("accountinfo"); |
319
|
|
|
$markup = $this->common->get_field_name('markup', 'pricelists', array('id'=>$account_data["pricelist_id"])); |
320
|
|
|
$count_all = $this->user_model->get_user_rates_list(false); |
321
|
|
|
$paging_data = $this->form->load_grid_config($count_all, $_GET['rp'], $_GET['page']); |
322
|
|
|
$json_data = $paging_data["json_paging"]; |
323
|
|
|
|
324
|
|
|
$query = $this->user_model->get_user_rates_list(true, $paging_data["paging"]["start"], $paging_data["paging"]["page_no"]); |
325
|
|
|
$grid_fields = json_decode($this->user_form->user_rates_list()); |
326
|
|
View Code Duplication |
foreach ($query->result_array() as $key => $value) { |
327
|
|
|
$cost=$account_data['type']!=3 ? ($value['cost'] + (($value['cost']*$markup)/100)) : $value['cost']; |
328
|
|
|
$json_data['rows'][] = array('cell' => array( |
329
|
|
|
$this->common->get_only_numeric_val("","",$value["pattern"]), |
330
|
|
|
$value['comment'], |
331
|
|
|
$this->common_model->calculate_currency($value['connectcost'],'','',true,false), |
332
|
|
|
$value['includedseconds'], |
333
|
|
|
$this->common_model->calculate_currency(($cost),'','',true,false), |
334
|
|
|
$value['init_inc'], |
335
|
|
|
$value['inc'] |
336
|
|
|
)); |
337
|
|
|
} |
338
|
|
|
echo json_encode($json_data); |
339
|
|
|
} |
340
|
|
|
|
341
|
|
|
function user_rates_list_search() { |
342
|
|
|
$ajax_search = $this->input->post('ajax_search', 0); |
343
|
|
|
|
344
|
|
|
if ($this->input->post('advance_search', TRUE) == 1) { |
345
|
|
|
$this->session->set_userdata('advance_search', $this->input->post('advance_search')); |
346
|
|
|
$action = $this->input->post(); |
347
|
|
|
unset($action['action'],$action['advance_search']); |
348
|
|
|
if (isset($action['connectcost']['connectcost']) && $action['connectcost']['connectcost'] != '') { |
349
|
|
|
$action['connectcost']['connectcost'] = $this->common_model->add_calculate_currency($action['connectcost']['connectcost'], "", '', true, false); |
350
|
|
|
} |
351
|
|
|
if (isset($action['cost']['cost']) && $action['cost']['cost'] != '') { |
352
|
|
|
$account_data = $this->session->userdata("accountinfo"); |
353
|
|
|
$markup = $this->common->get_field_name('markup', 'pricelists', array('id'=>$account_data["pricelist_id"])); |
354
|
|
|
$markup = ($markup > 0)?$markup:1; |
355
|
|
|
$action['cost']['cost'] = $this->common_model->add_calculate_currency($action['cost']['cost'], "", '', true, false); |
356
|
|
|
if($account_data['type']!=3) |
357
|
|
|
$action['cost']['cost']=($action['cost']['cost'] - ($action['cost']['cost']*$markup)/100); |
358
|
|
|
} |
359
|
|
|
$this->session->set_userdata('user_rates_list_search', $action); |
360
|
|
|
} |
361
|
|
|
if ($ajax_search != 1) { |
362
|
|
|
redirect(base_url() . 'user/user_rates_list/'); |
363
|
|
|
} |
364
|
|
|
} |
365
|
|
|
|
366
|
|
|
function user_rates_list_clearsearchfilter() { |
367
|
|
|
$this->session->set_userdata('advance_search', 0); |
368
|
|
|
$this->session->set_userdata('user_rates_list_search', ""); |
369
|
|
|
} |
370
|
|
|
|
371
|
|
|
function user_rates_list_export() { |
372
|
|
|
$account_data=$this->session->userdata('accountinfo'); |
373
|
|
|
$currency_id=$account_data['currency_id']; |
374
|
|
|
$currency=$this->common->get_field_name('currency', 'currency', $currency_id); |
375
|
|
|
$query = $this->user_model->get_user_rates_list(true, '', '', false); |
376
|
|
|
$markup = $this->common->get_field_name('markup', 'pricelists', array('id'=>$account_data["pricelist_id"])); |
377
|
|
|
ob_clean(); |
378
|
|
|
$inbound_array[] = array("Code", "Destination","Connect Cost($currency)","Included Seconds","Per Minute Cost($currency)","Initital Increment","Increment"); |
|
|
|
|
379
|
|
|
if ($query->num_rows() > 0) { |
380
|
|
View Code Duplication |
foreach ($query->result_array() as $row) { |
381
|
|
|
$cost=$account_data['type']!=3 ? ($row['cost'] + ($row['cost']*$markup)/100) :$row['cost']; |
382
|
|
|
$inbound_array[] = array( |
383
|
|
|
$row['pattern']=$this->common->get_only_numeric_val("","",$row["pattern"]), |
384
|
|
|
$row['comment'], |
385
|
|
|
$this->common_model->calculate_currency($row['connectcost'],'','',true,false), |
386
|
|
|
$row['includedseconds'], |
387
|
|
|
$this->common_model->calculate_currency($cost,'','',true,false), |
388
|
|
|
$row['init_inc'], |
389
|
|
|
$row['inc'] |
390
|
|
|
); |
391
|
|
|
} |
392
|
|
|
} |
393
|
|
|
$this->load->helper('csv'); |
394
|
|
|
array_to_csv($inbound_array, 'Rates_' . date("Y-m-d") . '.csv'); |
395
|
|
|
} |
396
|
|
|
|
397
|
|
View Code Duplication |
function user_refill($action = "") { |
398
|
|
|
if (common_model::$global_config['system_config']['paypal_status'] == 1) { |
399
|
|
|
redirect(base_url() . 'user/user/'); |
400
|
|
|
} |
401
|
|
|
$this->load->module("user/refill"); |
402
|
|
|
if ($action == "GET_AMT") { |
403
|
|
|
$amount = $this->input->post("value", true); |
404
|
|
|
$this->refill->convert_amount($amount); |
405
|
|
|
} else { |
406
|
|
|
$this->refill->index(); |
407
|
|
|
} |
408
|
|
|
} |
409
|
|
|
|
410
|
|
|
function user_convert_amount($amount) { |
411
|
|
|
$amount = $this->common_model->add_calculate_currency($amount, "", "", false, false); |
412
|
|
|
echo number_format($amount, 5); |
413
|
|
|
} |
414
|
|
|
|
415
|
|
|
|
416
|
|
|
function user_report_export() { |
417
|
|
|
$this->load->module('reports/reports'); |
418
|
|
|
$this->user_cdrreport_export(); |
419
|
|
|
} |
420
|
|
|
|
421
|
|
|
function change_password() { |
422
|
|
|
$accountinfo = $this->session->userdata('accountinfo'); |
423
|
|
|
$id = $accountinfo['id']; |
424
|
|
|
$this->load->model('user_model'); |
425
|
|
|
|
426
|
|
|
$query = $this->user_model->change_password($id); |
427
|
|
|
foreach ($query as $row) { |
428
|
|
|
$data['password'] = $row->password; |
|
|
|
|
429
|
|
|
} |
430
|
|
|
$databasepassword = $data['password']; |
|
|
|
|
431
|
|
|
$password = $_POST['oldpassword']; |
432
|
|
|
$newpassword = $_POST['newpassword']; |
433
|
|
|
$conformpassword = $_POST['conformpassword']; |
434
|
|
|
if ($databasepassword == $password) { |
435
|
|
|
|
436
|
|
|
if ($conformpassword == $newpassword) { |
437
|
|
|
$update = $newpassword; |
438
|
|
|
$this->load->model('user_model'); |
439
|
|
|
$this->user_model->change_db_password($update, $id); |
440
|
|
|
$this->session->set_flashdata('astpp_errormsg', "Password changed Sucessfully....!!!"); |
441
|
|
|
redirect(base_url() . 'user/user/changepassword/'); |
442
|
|
|
} else { |
443
|
|
|
$this->session->set_flashdata('astpp_notification', "New Password & Conformpassword not match."); |
444
|
|
|
redirect(base_url() . 'user/user/changepassword/'); |
445
|
|
|
} |
446
|
|
|
} else { |
447
|
|
|
$this->session->set_flashdata('astpp_notification', "Invalid old passwword."); |
448
|
|
|
redirect(base_url() . 'user/user/changepassword/'); |
449
|
|
|
} |
450
|
|
|
} |
451
|
|
|
|
452
|
|
|
function changepassword() { |
453
|
|
|
$data['username'] = $this->session->userdata('user_name'); |
|
|
|
|
454
|
|
|
$data['page_title'] = 'Change Password'; |
455
|
|
|
$this->load->view('view_changepassword', $data); |
456
|
|
|
} |
457
|
|
|
|
458
|
|
|
function user_generate_password() { |
459
|
|
|
echo $this->common->generate_password(); |
460
|
|
|
} |
461
|
|
|
|
462
|
|
|
function user_generate_number($digit) { |
463
|
|
|
echo $this->common->find_uniq_rendno($digit, 'number', 'accounts'); |
464
|
|
|
} |
465
|
|
|
|
466
|
|
|
function user_refill_coupon_list() { |
467
|
|
|
$data['username'] = $this->session->userdata('user_name'); |
|
|
|
|
468
|
|
|
$data['page_title'] = 'Refill Coupon List'; |
469
|
|
|
$this->load->module('refill_coupon/refill_coupon'); |
470
|
|
|
$data['grid_fields'] = $this->refill_coupon->refill_coupon_form->build_user_refill_coupon_grid(); |
471
|
|
|
$acc_data = $this->session->userdata("accountinfo"); |
472
|
|
|
$reseller_id = $acc_data['reseller_id']; |
473
|
|
|
|
474
|
|
|
$drp_data = $this->db->query("SELECT id,CONCAT(number,'(',amount,')') as details,number FROM refill_coupon WHERE status = '0' and reseller_id='" . $reseller_id . "'"); |
475
|
|
|
$reseller_data = array(); |
476
|
|
|
$data['refill_coupon_list'] = form_dropdown_all('refill_coupon_list', $reseller_data, ''); |
|
|
|
|
477
|
|
|
$this->load->view('view_refill_coupon_list', $data); |
478
|
|
|
} |
479
|
|
|
|
480
|
|
|
function user_refill_coupon_list_json() { |
481
|
|
|
$account_data = $this->session->userdata("accountinfo"); |
482
|
|
|
|
483
|
|
|
$this->load->module('refill_coupon/refill_coupon'); |
484
|
|
|
$this->refill_coupon->refill_coupon_customer_json($account_data["id"]); |
485
|
|
|
} |
486
|
|
|
|
487
|
|
|
function user_refill_coupon_number($refill_coupon_no) { |
488
|
|
|
$accountinfo = $this->session->userdata('accountinfo'); |
489
|
|
|
$reseller_id = $accountinfo['reseller_id']; |
490
|
|
|
$customer_id = $accountinfo['id']; |
491
|
|
|
$this->db->where('reseller_id', $reseller_id); |
492
|
|
|
$this->db->where('number', $refill_coupon_no); |
493
|
|
|
$this->db->select('*'); |
494
|
|
|
$refill_coupon_result = $this->db->get('refill_coupon'); |
495
|
|
|
if ($refill_coupon_result->num_rows() > 0) { |
496
|
|
|
$refill_coupon_result = $refill_coupon_result->result_array(); |
497
|
|
|
$refill_coupon_result = $refill_coupon_result[0]; |
498
|
|
|
if ($refill_coupon_result['status'] == 1) { |
499
|
|
|
echo json_encode(1); |
500
|
|
|
} elseif ($refill_coupon_result['status'] == 2) { |
501
|
|
|
echo json_encode(2); |
502
|
|
|
} else { |
503
|
|
|
$this->db->select('balance'); |
504
|
|
|
$result = (array)$this->db->get_where('accounts',array('id'=>$customer_id))->first_row(); |
505
|
|
|
$user_balance=$this->db_model->get_available_bal($accountinfo); |
506
|
|
|
$original_balance=$refill_coupon_result['amount']; |
507
|
|
|
$refill_coupon_result['amount'] = $this->common_model->to_calculate_currency($original_balance,'','',TRUE,TRUE); |
508
|
|
|
$refill_coupon_result['new_balance'] = $this->common_model->to_calculate_currency($user_balance+$original_balance,'','',TRUE,TRUE); |
509
|
|
|
echo json_encode($refill_coupon_result); |
510
|
|
|
} |
511
|
|
|
} else { |
512
|
|
|
echo json_encode(3); |
513
|
|
|
} |
514
|
|
|
} |
515
|
|
|
|
516
|
|
|
function user_refill_coupon_action($refill_coupon_no) { |
517
|
|
|
$accountinfo = $this->session->userdata('accountinfo'); |
518
|
|
|
$reseller_id = $accountinfo['reseller_id']; |
519
|
|
|
if ($reseller_id == 0) { |
520
|
|
|
$reseller_id = '-1'; |
521
|
|
|
} |
522
|
|
|
$date = gmdate('Y-m-d H:i:s'); |
523
|
|
|
$customer_id = $accountinfo['id']; |
524
|
|
|
$this->db->where('number', $refill_coupon_no); |
525
|
|
|
$this->db->select('amount'); |
526
|
|
|
$result = $this->db->get('refill_coupon'); |
527
|
|
|
if ($result->num_rows() > 0) { |
528
|
|
|
$result = $result->result_array(); |
529
|
|
|
$amount = $result[0]['amount']; |
530
|
|
|
$this->db->where('id', $customer_id); |
531
|
|
|
$this->db->select('balance'); |
532
|
|
|
$result = $this->db->get('accounts'); |
533
|
|
|
$result = $result->result_array(); |
534
|
|
|
$current_balance = $result[0]['balance']; |
535
|
|
|
$new_balance = $current_balance + $amount; |
536
|
|
|
$data = array('balance' => $new_balance); |
537
|
|
|
$this->db->where('id', $customer_id); |
538
|
|
|
$this->db->update('accounts', $data); |
539
|
|
|
$this->db->where('number', $refill_coupon_no); |
540
|
|
|
$refill_coupon_data = array('status' => 2, "account_id" => $customer_id, 'firstused' => $date); |
541
|
|
|
$this->db->update('refill_coupon', $refill_coupon_data); |
542
|
|
|
$payment_arr = array("accountid" => $customer_id, 'type' => 'refill_coupon', 'credit' => $amount, 'payment_by' => $reseller_id, 'payment_date' => $date, 'refill_coupon_number' => $refill_coupon_no, 'notes' => 'Recharge using Refill coupon,Refill coupon No. ' . $refill_coupon_no . ''); |
543
|
|
|
$this->db->insert('payments', $payment_arr); |
544
|
|
|
} |
545
|
|
|
redirect(base_url() . "user/user_refill_coupon_list/"); |
546
|
|
|
} |
547
|
|
|
|
548
|
|
|
function user_packages() { |
549
|
|
|
$data['page_title'] = 'Packages'; |
|
|
|
|
550
|
|
|
$data['grid_fields'] = $this->user_form->build_packages_list_for_user(); |
551
|
|
|
$this->load->view('view_user_packages_list', $data); |
552
|
|
|
} |
553
|
|
|
|
554
|
|
|
function user_packages_json() { |
555
|
|
|
$json_data = array(); |
556
|
|
|
$count_all = $this->user_model->get_user_packages_list(false,'',''); |
557
|
|
|
$paging_data = $this->form->load_grid_config($count_all, $_GET['rp'], $_GET['page']); |
558
|
|
|
$json_data = $paging_data["json_paging"]; |
559
|
|
|
$query = $this->user_model->get_user_packages_list(true, $paging_data["paging"]["start"], $paging_data["paging"]["page_no"]); |
560
|
|
|
$grid_fields = json_decode($this->user_form->build_packages_list_for_user()); |
561
|
|
|
$json_data['rows'] = $this->form->build_grid($query, $grid_fields); |
562
|
|
|
echo json_encode($json_data); |
563
|
|
|
} |
564
|
|
|
|
565
|
|
|
function user_invoices() { |
566
|
|
|
$data['page_title'] = 'Invoices'; |
|
|
|
|
567
|
|
|
$this->load->view('view_user_invoices_list', $data); |
568
|
|
|
} |
569
|
|
|
|
570
|
|
|
function user_invoices_json() { |
571
|
|
|
$json_data = array(); |
572
|
|
|
$count_all = $this->user_model->get_user_invoices_list(false); |
573
|
|
|
$paging_data = $this->form->load_grid_config($count_all, 10, 1); |
574
|
|
|
$json_data = $paging_data["json_paging"]; |
575
|
|
|
$query = $this->user_model->get_user_invoices_list(true, $paging_data["paging"]["start"], $paging_data["paging"]["page_no"]); |
576
|
|
|
$this->load->module('invoices/invoices'); |
577
|
|
|
$grid_fields = json_decode($this->user_form->build_invoices_list_for_user()); |
578
|
|
|
$json_data['rows'] = $this->form->build_grid($query, $grid_fields); |
579
|
|
|
echo json_encode($json_data); |
580
|
|
|
} |
581
|
|
|
|
582
|
|
|
function user_emails() { |
583
|
|
|
$data['page_title'] = 'EMails'; |
|
|
|
|
584
|
|
|
$data['grid_fields'] = $this->user_form->build_emails_list_for_user(); |
585
|
|
|
$data['form_search'] = $this->form->build_serach_form($this->user_form->build_user_emails_search()); |
586
|
|
|
$this->load->view('view_user_emails_list', $data); |
587
|
|
|
} |
588
|
|
|
|
589
|
|
|
function user_emails_json() { |
590
|
|
|
$json_data = array(); |
591
|
|
|
$count_all = $this->user_model->get_user_emails_list(false); |
592
|
|
|
$paging_data = $this->form->load_grid_config($count_all, $_GET['rp'], $_GET['page']); |
593
|
|
|
$json_data = $paging_data["json_paging"]; |
594
|
|
|
$query = $this->user_model->get_user_emails_list(true, $paging_data["paging"]["start"], $paging_data["paging"]["page_no"]); |
595
|
|
|
$grid_fields = json_decode($this->user_form->build_emails_list_for_user()); |
596
|
|
|
$json_data['rows'] = $this->form->build_grid($query, $grid_fields); |
597
|
|
|
echo json_encode($json_data); |
598
|
|
|
} |
599
|
|
View Code Duplication |
function user_emails_search(){ |
600
|
|
|
$ajax_search = $this->input->post('ajax_search', 0); |
601
|
|
|
if ($this->input->post('advance_search', TRUE) == 1) { |
602
|
|
|
$this->session->set_userdata('advance_search', $this->input->post('advance_search')); |
603
|
|
|
$action = $this->input->post(); |
604
|
|
|
unset($action['action'],$action['advance_search']); |
605
|
|
|
$this->session->set_userdata('user_emails_search', $action); |
606
|
|
|
} |
607
|
|
|
if (@$ajax_search != 1) { |
608
|
|
|
redirect(base_url() . 'user/user_emails/'); |
609
|
|
|
} |
610
|
|
|
} |
611
|
|
|
function user_emails_clearsearchfilter(){ |
612
|
|
|
$this->session->set_userdata('advance_search', 0); |
613
|
|
|
$this->session->set_userdata('user_emails_search', ""); |
614
|
|
|
} |
615
|
|
|
function user_invoice_config() { |
616
|
|
|
$data['page_title'] = 'Company Profile'; |
|
|
|
|
617
|
|
|
$accountinfo = $this->session->userdata("accountinfo"); |
618
|
|
|
$add_array = $this->input->post(); |
619
|
|
|
$data["account_data"] = $add_array; |
620
|
|
|
if (isset($add_array['submit'])) { |
621
|
|
View Code Duplication |
if ($_FILES['file']['name'] == '') { |
622
|
|
|
$invoiceconf = $this->user_model->get_invoiceconf(); |
623
|
|
|
$file_name=($invoiceconf['logo'] != '') ? $invoiceconf['logo'] : ''; |
624
|
|
|
} |
625
|
|
|
if (isset($_FILES['file']['name']) && $_FILES['file']['name'] != '') { |
626
|
|
|
$files = $_FILES['file']; |
627
|
|
View Code Duplication |
if ($files['size'] < 0) { |
628
|
|
|
$this->session->set_flashdata('astpp_notification', 'PLease upload maximum file'); |
629
|
|
|
redirect(base_url() . "accounts/reseller_invoice_config/". $add_array['accountid']."/"); |
630
|
|
|
} |
631
|
|
|
$file = $_FILES['file']; |
632
|
|
|
$uploadedFile = $file["tmp_name"]; |
633
|
|
|
$file_name = $file['name']; |
634
|
|
|
$file_type = $file['type']; |
635
|
|
View Code Duplication |
if ($file_type == 'image/jpg' || $file_type == 'image/png' || $file_type == 'image/jpeg') { |
636
|
|
|
$dir_path = FCPATH. "upload/"; |
637
|
|
|
$path = $dir_path . $add_array['accountid']."_".$file['name']; |
638
|
|
|
if (move_uploaded_file($uploadedFile, $path)) { |
639
|
|
|
$this->session->set_flashdata('astpp_errormsg', gettext('files added successfully!')); |
640
|
|
|
} else { |
641
|
|
|
$this->session->set_flashdata('astpp_notification', "File Uploading Fail Please Try Again"); |
642
|
|
|
redirect(base_url() . 'user/user_invoice_config/'); |
643
|
|
|
} |
644
|
|
|
} else { |
645
|
|
|
$this->session->set_flashdata('astpp_notification', 'Please upload only image!'); |
646
|
|
|
redirect(base_url() . 'user/user_invoice_config/'); |
647
|
|
|
} |
648
|
|
|
} |
649
|
|
|
$add_array['logo'] = $file_name; |
|
|
|
|
650
|
|
|
unset($add_array['submit']); |
651
|
|
|
if ($add_array['id'] == '') { |
652
|
|
|
$add_array['accountid'] = $accountinfo['id']; |
653
|
|
|
$this->user_model->add_invoice_config($add_array); |
654
|
|
|
} else { |
655
|
|
|
$this->user_model->edit_invoice_config($add_array, $add_array['id']); |
656
|
|
|
} |
657
|
|
|
$this->session->set_flashdata('astpp_errormsg', 'Invoice config updated successfully!'); |
658
|
|
|
redirect(base_url() . 'user/user_invoice_config/'); |
659
|
|
|
} else { |
660
|
|
|
$data["account_data"] =(array)$this->db->get_where('invoice_conf',array("accountid"=>$accountinfo['id']))->first_row(); |
661
|
|
View Code Duplication |
if(isset($data["account_data"]['logo'])){ |
662
|
|
|
$data["account_data"]['file']=$accountinfo['id']."_".$data["account_data"]['logo']; |
663
|
|
|
} |
664
|
|
|
$this->load->view('view_user_invoices_config', $data); |
665
|
|
|
} |
666
|
|
|
} |
667
|
|
|
|
668
|
|
View Code Duplication |
function user_invoice_logo_delete($accountid){ |
669
|
|
|
$invoiceconf = $this->db_model->getSelect("*", "invoice_conf", array("accountid"=> $accountid)); |
670
|
|
|
$result=$invoiceconf->result_array(); |
671
|
|
|
$logo=$result[0]['logo']; |
672
|
|
|
$post_arr=array('logo'=>''); |
673
|
|
|
$where_arr=array('logo'=>$logo); |
674
|
|
|
$this->db->where($where_arr); |
675
|
|
|
$this->db->update('invoice_conf',$post_arr); |
676
|
|
|
} |
677
|
|
|
|
678
|
|
|
function user_myprofile() { |
679
|
|
|
$accountinfo = $this->session->userdata("accountinfo"); |
680
|
|
|
$entity_name = strtolower($this->common->get_entity_type('', '', $accountinfo['type'])); |
681
|
|
|
$data['page_title'] = 'My Profile'; |
|
|
|
|
682
|
|
|
$add_array = $this->input->post(); |
683
|
|
|
if ($add_array['id'] != '') { |
684
|
|
|
$add_array['type'] = $accountinfo['type']; |
685
|
|
|
$data['form'] = $this->form->build_form($this->user_form->get_userprofile_form_fields($add_array), $add_array); |
686
|
|
View Code Duplication |
if ($this->form_validation->run() == FALSE) { |
687
|
|
|
$data['validation_errors'] = validation_errors(); |
688
|
|
|
} else { |
689
|
|
|
if ($add_array['id'] == $accountinfo['id']) { |
690
|
|
|
$this->user_model->edit_account($add_array, $add_array['id']); |
691
|
|
|
$result = $this->db->get_where('accounts', array('id' => $add_array['id'])); |
692
|
|
|
$result = $result->result_array(); |
693
|
|
|
$this->session->set_userdata('accountinfo', $result[0]); |
694
|
|
|
$this->session->set_flashdata('astpp_errormsg',' Your profile updated successfully!'); |
695
|
|
|
redirect(base_url() . 'user/user_myprofile/'); |
696
|
|
|
}else{ |
697
|
|
|
$this->session->set_flashdata('astpp_notification', 'Something wrong.Please contact to administrator.'); |
698
|
|
|
} |
699
|
|
|
} |
700
|
|
View Code Duplication |
} else { |
701
|
|
|
$where = array('id' => $accountinfo["id"]); |
702
|
|
|
$account = $this->db_model->getSelect("*", "accounts", $where); |
703
|
|
|
$data["account_data"] = $account->result_array(); |
704
|
|
|
|
705
|
|
|
foreach ($account->result_array() as $key => $value) { |
706
|
|
|
$editable_data = $value; |
707
|
|
|
} |
708
|
|
|
$editable_data['password'] = $this->common->decode($editable_data['password']); |
|
|
|
|
709
|
|
|
$data['form'] = $this->form->build_form($this->user_form->get_userprofile_form_fields($editable_data), $editable_data); |
710
|
|
|
} |
711
|
|
|
$this->load->view('view_user_details', $data); |
712
|
|
|
} |
713
|
|
|
|
714
|
|
|
function user_change_password() { |
715
|
|
|
$accountinfo = $this->session->userdata("accountinfo"); |
716
|
|
|
$data['page_title'] = "Change Password"; |
|
|
|
|
717
|
|
|
$add_array = $this->input->post(); |
718
|
|
|
if(!empty($add_array)) { |
719
|
|
|
$data['form'] = $this->form->build_form($this->user_form->get_userprofile_change_password(), $add_array); |
720
|
|
|
if ($this->form_validation->run() == FALSE) { |
721
|
|
|
$data['validation_errors'] = validation_errors(); |
722
|
|
|
} else { |
723
|
|
|
$password_encode = $this->common->encode($add_array['new_password']); |
724
|
|
|
$data = array('password' => $password_encode); |
725
|
|
|
$this->db->where('id',$add_array['id']); |
726
|
|
|
$this->db->update('accounts', $data); |
727
|
|
|
$this->session->set_flashdata('astpp_errormsg', 'Password updated successfully!'); |
728
|
|
|
redirect(base_url() . 'user/user_change_password/'); |
729
|
|
|
} |
730
|
|
|
}else{ |
731
|
|
|
$data_array['id']=$accountinfo['id']; |
|
|
|
|
732
|
|
|
$data['form'] = $this->form->build_form($this->user_form->get_userprofile_change_password(),$data_array); |
733
|
|
|
} |
734
|
|
|
$this->load->view('view_user_change_password', $data); |
735
|
|
|
} |
736
|
|
|
|
737
|
|
View Code Duplication |
function user_refill_report() { |
738
|
|
|
$accountinfo=$this->session->userdata('accountinfo'); |
739
|
|
|
$data['page_title'] = 'Refill Report'; |
|
|
|
|
740
|
|
|
$data['search_flag'] = true; |
741
|
|
|
$this->session->set_userdata('advance_search', 0); |
742
|
|
|
$data['grid_fields'] = $this->user_form->build_user_refill_report(); |
743
|
|
|
$data['form_search'] = $this->form->build_serach_form($this->user_form->build_user_refill_report_search()); |
744
|
|
|
if($accountinfo['type'] == 1){ |
745
|
|
|
$this->load->view('view_reseller_refill_report', $data); |
746
|
|
|
}else{ |
747
|
|
|
$this->load->view('view_user_refill_report', $data); |
748
|
|
|
} |
749
|
|
|
} |
750
|
|
|
|
751
|
|
|
function user_refill_report_json() { |
752
|
|
|
$json_data = array(); |
753
|
|
|
$count_all = $this->user_model->get_user_refill_list(false); |
754
|
|
|
$paging_data = $this->form->load_grid_config($count_all,$_GET['rp'], $_GET['page']); |
755
|
|
|
$json_data = $paging_data["json_paging"]; |
756
|
|
|
$query = $this->user_model->get_user_refill_list(true, $paging_data["paging"]["start"], $paging_data["paging"]["page_no"]); |
757
|
|
|
$grid_fields = json_decode($this->user_form->build_user_refill_report()); |
758
|
|
|
$json_data['rows'] = $this->form->build_grid($query, $grid_fields); |
759
|
|
|
echo json_encode($json_data); |
760
|
|
|
} |
761
|
|
|
|
762
|
|
View Code Duplication |
function user_refill_report_search() { |
763
|
|
|
$ajax_search = $this->input->post('ajax_search', 0); |
764
|
|
|
if ($this->input->post('advance_search', TRUE) == 1) { |
765
|
|
|
$this->session->set_userdata('advance_search', $this->input->post('advance_search')); |
766
|
|
|
$action = $this->input->post(); |
767
|
|
|
unset($action['action'],$action['advance_search']); |
768
|
|
|
if (isset($action['credit']['credit']) && $action['credit']['credit'] != '') { |
769
|
|
|
$action['credit']['credit'] = $this->common_model->add_calculate_currency($action['credit']['credit'], "", '', true, false); |
770
|
|
|
} |
771
|
|
|
$this->session->set_userdata('user_refill_report_search', $action); |
772
|
|
|
} |
773
|
|
|
if (@$ajax_search != 1) { |
774
|
|
|
redirect(base_url() . 'user/user_refill_report/'); |
775
|
|
|
} |
776
|
|
|
} |
777
|
|
|
|
778
|
|
|
function user_refill_report_clearsearchfilter() { |
779
|
|
|
$this->session->set_userdata('advance_search', 0); |
780
|
|
|
$this->session->set_userdata('user_refill_report_search', ""); |
781
|
|
|
} |
782
|
|
|
|
783
|
|
View Code Duplication |
function user_invoices_list() { |
784
|
|
|
$data['page_title'] = 'Invoices'; |
|
|
|
|
785
|
|
|
$data['search_flag'] = true; |
786
|
|
|
$this->session->set_userdata('advance_search', 0); |
787
|
|
|
$data['grid_fields'] = $this->user_form->build_user_invoices(); |
788
|
|
|
$data['form_search'] = $this->form->build_serach_form($this->user_form->build_user_invoices_search()); |
789
|
|
|
$this->load->view('view_user_invoices_list', $data); |
790
|
|
|
} |
791
|
|
|
function user_invoices_list_json() { |
792
|
|
|
$accountinfo = $this->session->userdata('accountinfo'); |
793
|
|
|
$where = array("accountid" => $accountinfo['id']); |
794
|
|
|
$count_all = $this->user_model->get_user_invoice_list(false, '', '', $where); |
795
|
|
|
$paging_data = $this->form->load_grid_config($count_all, $_GET['rp'], $_GET['page']); |
796
|
|
|
$json_data = $paging_data["json_paging"]; |
797
|
|
|
$user_currency=$this->common->get_field_name('currency','currency',$accountinfo['currency_id']); |
798
|
|
|
$invoices_query = $this->user_model->get_user_invoice_list(true, $paging_data["paging"]["start"], $paging_data["paging"]["page_no"], $where); |
799
|
|
|
$invoices_result = $invoices_query->result_array(); |
800
|
|
|
$ountstanding_value = 0; |
801
|
|
|
$total_amount = 0; |
802
|
|
|
$this->db->where('accountid', $accountinfo['id']); |
803
|
|
|
$this->db->select('sum(credit) as total_credit'); |
804
|
|
|
$invoice_details_result = $this->db->get('invoice_details'); |
805
|
|
|
$total_credit = (array)$invoice_details_result->first_row(); |
806
|
|
|
$total_credit = $total_credit['total_credit']; |
807
|
|
|
foreach ($invoices_result as $key => $value) { |
808
|
|
|
$total_amount+=$value['amount']; |
809
|
|
|
$invoice_date = date("Y-m-d", strtotime($value['invoice_date'])); |
810
|
|
|
$from_date = date("Y-m-d", strtotime($value['from_date'])); |
811
|
|
|
$due_date = date("Y-m-d", strtotime($value['due_date'])); |
812
|
|
|
$outstanding = $value['amount']; |
813
|
|
|
$invoice_total_query = $this->db_model->select("sum(debit) as debit,sum(credit) as credit,created_date", "invoice_details", array("invoiceid" => $value['id'], "item_type" => "INVPAY"), "created_date", "DESC", "1", "0"); |
814
|
|
|
if ($invoice_total_query->num_rows() > 0) { |
815
|
|
|
$invoice_total_query = $invoice_total_query->result_array(); |
816
|
|
|
$outstanding -= $invoice_total_query[0]['credit']; |
817
|
|
|
$payment_last = ($invoice_total_query[0]['created_date']) ? date("Y-m-d", strtotime($invoice_total_query[0]['created_date'])) : ''; |
818
|
|
|
} |
819
|
|
|
$invoice_total_query = $this->db_model->select("debit,created_date", "invoice_details", array("invoiceid" => $value['id'], "item_type" => "INVPAY"), "created_date", "DESC", "1", "0"); |
820
|
|
|
if ($invoice_total_query->num_rows() > 0) { |
821
|
|
|
$invoice_total_result = $invoice_total_query->result_array(); |
822
|
|
|
} |
823
|
|
|
$download = '<a href="' . base_url() . '/user/user_invoice_download/' . $value['id'] . '/00' . $value['invoice_prefix'] . $value['invoiceid'] . '" class="btn btn-royelblue btn-sm" title="Download Invoice" ><i class="fa fa-cloud-download fa-fw"></i></a> '; |
824
|
|
View Code Duplication |
if($value['type'] == 'I'){ |
825
|
|
|
if ($outstanding > 0) { |
826
|
|
|
$payment = ' <a style="padding: 0 8px;" href="' . base_url() . 'user/user_invoice_payment/' . $value['id'] . '" class="btn btn-warning" title="Payment">Unpaid</a>'; |
827
|
|
|
} else { |
828
|
|
|
$payment = ' <button style="padding: 0 8px;" class="btn btn-success" type="button">Paid</button>'; |
829
|
|
|
} |
830
|
|
|
}else{ |
831
|
|
|
$payment = ''; |
832
|
|
|
} |
833
|
|
|
if($value['generate_type'] == 1){ |
834
|
|
|
$invoice_type='Manually'; |
835
|
|
|
}else{ |
836
|
|
|
$invoice_type='Automatically'; |
837
|
|
|
} |
838
|
|
|
|
839
|
|
|
if($value['type'] == 'R'){ |
840
|
|
|
$icon = '<div class="flx_font flx_magenta">R</div>'; |
841
|
|
|
} |
842
|
|
|
else |
843
|
|
|
{ |
844
|
|
|
$icon = '<div class="flx_font flx_drk_pink">I</div>'; |
845
|
|
|
|
846
|
|
|
} |
847
|
|
|
|
848
|
|
|
$json_data['rows'][] = array('cell' => array( |
849
|
|
|
$value['invoice_prefix'].$value['invoiceid'].$icon, |
850
|
|
|
$invoice_type, |
851
|
|
|
$invoice_date, |
852
|
|
|
$from_date, |
853
|
|
|
$due_date, |
854
|
|
|
$payment_last, |
|
|
|
|
855
|
|
|
$this->common->currency_decimal($this->common_model->calculate_currency($value['amount'])), |
856
|
|
|
$this->common->currency_decimal($this->common_model->calculate_currency($outstanding)), |
857
|
|
|
$download.$payment, |
858
|
|
|
)); |
859
|
|
|
$ountstanding_value = $ountstanding_value + $outstanding; |
860
|
|
|
} |
861
|
|
|
echo json_encode($json_data); |
862
|
|
|
} |
863
|
|
|
|
864
|
|
|
function user_invoices_list_search() { |
865
|
|
|
$ajax_search = $this->input->post('ajax_search', 0); |
866
|
|
|
if ($this->input->post('advance_search', TRUE) == 1) { |
867
|
|
|
$this->session->set_userdata('advance_search', $this->input->post('advance_search')); |
868
|
|
|
$action = $this->input->post(); |
869
|
|
|
print_r($action); |
870
|
|
|
unset($action['action']); |
871
|
|
|
unset($action['advance_search']); |
872
|
|
|
$action['from_date'][0] = $action['from_date'][0] ? $action['from_date'][0] . " 00:00:00" : ''; |
873
|
|
|
$action['to_date'][1] = $action['to_date'][1] ? $action['to_date'][1] . " 23:59:59" : ''; |
874
|
|
|
$action['invoice_date'][0] = $action['invoice_date'][0] ? $action['invoice_date'][0] . " 00:00:00" : ''; |
875
|
|
|
$this->session->set_userdata('user_invoice_list_search', $action); |
876
|
|
|
} |
877
|
|
|
if (@$ajax_search != 1) { |
878
|
|
|
redirect(base_url() . 'user/user_invoice_list/'); |
879
|
|
|
} |
880
|
|
|
} |
881
|
|
|
|
882
|
|
|
function user_invoices_list_clearsearchfilter() { |
883
|
|
|
$this->session->set_userdata('advance_search', 0); |
884
|
|
|
$this->session->set_userdata('user_invoice_list_search', ""); |
885
|
|
|
} |
886
|
|
|
|
887
|
|
|
function user_invoices_download($invoiceid) { |
888
|
|
|
$this->load->module('invoices/invoices'); |
889
|
|
|
$this->invoices->invoice_main_download($invoiceid); |
890
|
|
|
} |
891
|
|
|
function user_list_responce(){ |
892
|
|
|
$this->load->module('invoices/invoices'); |
893
|
|
|
$this->invoices->invoice_list_responce(); |
894
|
|
|
} |
895
|
|
|
function user_invoice_payment($invoiceid){ |
896
|
|
|
$this->load->module('invoices/invoices'); |
897
|
|
|
$this->invoices->invoice_summary($invoiceid); |
898
|
|
|
} |
899
|
|
|
function user_invoice_payment_pay($action=""){ |
900
|
|
|
$this->load->module("user/payment"); |
901
|
|
|
if($action=="GET_AMT"){ |
902
|
|
|
$amount = $this->input->post("value",true); |
903
|
|
|
$amount = $this->common_model->add_calculate_currency($amount,"","",true,false); |
904
|
|
|
echo number_format($amount,2); |
905
|
|
|
}else{ |
906
|
|
|
$this->payment->index(); |
907
|
|
|
} |
908
|
|
|
} |
909
|
|
|
function user_invoice_download($invoiceid){ |
910
|
|
|
$this->load->module('invoices/invoices'); |
911
|
|
|
$this->invoices->invoice_download($invoiceid); |
912
|
|
|
} |
913
|
|
View Code Duplication |
function user_charges_history() { |
914
|
|
|
$data['page_title'] = 'Charges History'; |
|
|
|
|
915
|
|
|
$this->session->set_userdata('advance_search', 0); |
916
|
|
|
$data['grid_fields'] = $this->user_form->build_user_charge_history(); |
917
|
|
|
$data['form_search'] = $this->form->build_serach_form($this->user_form->build_user_charge_history_search()); |
918
|
|
|
$this->load->view('view_user_charges_list', $data); |
919
|
|
|
} |
920
|
|
|
|
921
|
|
|
function user_charges_history_json() { |
922
|
|
|
$json_data = array(); |
923
|
|
|
$count_all = $this->user_model->get_user_charge_history(false); |
924
|
|
|
$paging_data = $this->form->load_grid_config($count_all, $_GET['rp'], $_GET['page']); |
925
|
|
|
$json_data = $paging_data["json_paging"]; |
926
|
|
|
$query = $this->user_model->get_user_charge_history(true, $paging_data["paging"]["start"], $paging_data["paging"]["page_no"]); |
927
|
|
|
|
928
|
|
|
$result= $query->result_array(); |
929
|
|
|
$query1 = $this->user_model->get_user_charge_history(true,'',''); |
930
|
|
|
$res= $query1->result_array(); |
931
|
|
|
$debit=0; |
932
|
|
|
$credit=0; |
933
|
|
|
$before_balance=0; |
934
|
|
|
$after_balance=0; |
935
|
|
|
$i=0; |
936
|
|
|
foreach ($result as $key => $value) { |
937
|
|
|
$date=$this->common->convert_GMT_to('','',$value['created_date']); |
938
|
|
|
$cust_type = $this->common->get_field_name('posttoexternal', 'accounts', $value['accountid']); |
939
|
|
|
$invoice_prefix= $entity_type =$this->common->get_field_name('invoice_prefix','invoices',array('id'=>$value['invoiceid'])); |
940
|
|
|
$invoiceid= $entity_type =$this->common->get_field_name('invoiceid','invoices',array('id'=>$value['invoiceid'])); |
941
|
|
|
$invoice_num=$invoice_prefix.$invoiceid; |
942
|
|
|
$account=$this->common->get_field_name_coma_new('first_name,last_name,number','accounts',$value['accountid']); |
943
|
|
|
$reseller=$this->common->reseller_select_value('first_name,last_name,number','accounts',$value['reseller_id']); |
944
|
|
|
$item_type=$value['item_type']; |
945
|
|
|
if($value['before_balance'] == '-'){ |
946
|
|
|
$before_balance='-'; |
947
|
|
|
} else{ |
948
|
|
|
$before_balance=$this->common->convert_to_currency('','',$value['before_balance']); |
949
|
|
|
} |
950
|
|
|
if($value['debit'] == '-'){ |
951
|
|
|
$debit='-'; |
952
|
|
|
} else{ |
953
|
|
|
$debit=$this->common->convert_to_currency('','',$value['debit']); |
954
|
|
|
} |
955
|
|
|
$credit=$this->common->convert_to_currency('','',$value['credit']); |
956
|
|
|
if($cust_type == 0 && $value['item_type'] == 'INVPAY'){ |
957
|
|
|
$credit = '(-) '.$credit; |
958
|
|
|
} |
959
|
|
|
if($value['after_balance'] == '-'){ |
960
|
|
|
$after_balance='-'; |
961
|
|
|
} else{ |
962
|
|
|
$after_balance=$this->common->convert_to_currency('','',$value['after_balance']); |
963
|
|
|
} |
964
|
|
|
$description=$value['description']; |
965
|
|
|
$cust_type = $this->common->get_field_name('posttoexternal', 'accounts', $value['accountid']); |
966
|
|
|
$json_data['rows'][] = array('cell' => array( |
967
|
|
|
$date, |
968
|
|
|
$invoice_num, |
969
|
|
|
$item_type, |
970
|
|
|
$before_balance, |
971
|
|
|
$debit, |
972
|
|
|
$credit, |
973
|
|
|
$after_balance, |
974
|
|
|
$description, |
975
|
|
|
)); |
976
|
|
|
|
977
|
|
|
} |
978
|
|
|
$debit_sum = 0; |
979
|
|
|
$credit_sum = 0; |
980
|
|
View Code Duplication |
foreach($res as $value){ |
981
|
|
|
$cust_type = $this->common->get_field_name('posttoexternal', 'accounts', $value['accountid']); |
982
|
|
|
$cust_type = $this->common->get_field_name('posttoexternal', 'accounts', $value['accountid']); |
983
|
|
|
$debit_sum += $value['debit']; |
984
|
|
|
$credit_sum += $value['credit']; |
985
|
|
|
$before_balance += $value['before_balance']; |
986
|
|
|
$after_balance += $value['after_balance']; |
987
|
|
|
} |
988
|
|
|
$json_data['rows'][$count_all]['cell']=array('<b>Total</b>','-','-','-','<b>'.$this->common->convert_to_currency('','',$debit_sum).'</b>','<b>'.$this->common->convert_to_currency('','',$credit_sum).'</b>','-','-'); |
989
|
|
|
echo json_encode($json_data); |
990
|
|
|
|
991
|
|
|
|
992
|
|
|
} |
993
|
|
|
function user_charges_history_search() { |
994
|
|
|
$ajax_search = $this->input->post('ajax_search', 0); |
995
|
|
|
if ($this->input->post('advance_search', TRUE) == 1) { |
996
|
|
|
$this->session->set_userdata('advance_search', $this->input->post('advance_search')); |
997
|
|
|
$action = $this->input->post(); |
998
|
|
|
unset($action['action']); |
999
|
|
|
unset($action['advance_search']); |
1000
|
|
|
$action['created_date'][0] = $action['created_date'][0] ? $action['created_date'][0] . " 00:00:00" : ''; |
1001
|
|
|
$action['created_date'][1] = $action['created_date'][1] ? $action['created_date'][1] . " 23:59:59" : ''; |
1002
|
|
|
if (isset($action['debit']['debit']) && $action['debit']['debit'] != '') { |
1003
|
|
|
$action['debit']['debit'] = $this->common_model->add_calculate_currency($action['debit']['debit'], "", '', true, false); |
1004
|
|
|
} |
1005
|
|
|
if (isset($action['credit']['credit']) && $action['credit']['credit'] != '') { |
1006
|
|
|
$action['credit']['credit'] = $this->common_model->add_calculate_currency($action['credit']['credit'], "", '', true, false); |
1007
|
|
|
} |
1008
|
|
|
$this->session->set_userdata('user_charge_history_search', $action); |
1009
|
|
|
} |
1010
|
|
|
if (@$ajax_search != 1) { |
1011
|
|
|
redirect(base_url() . 'user/user_charges_history/'); |
1012
|
|
|
} |
1013
|
|
|
} |
1014
|
|
|
|
1015
|
|
|
function user_charges_history_clearsearchfilter() { |
1016
|
|
|
$this->session->set_userdata('advance_search', 0); |
1017
|
|
|
$this->session->set_userdata('user_charge_history_search', ""); |
1018
|
|
|
} |
1019
|
|
View Code Duplication |
function user_subscriptions() { |
1020
|
|
|
$data['page_title'] = 'Subscriptions'; |
|
|
|
|
1021
|
|
|
$this->session->set_userdata('advance_search', 0); |
1022
|
|
|
$data['grid_fields'] = $this->user_form->build_user_subscription(); |
1023
|
|
|
$data['form_search'] = $this->form->build_serach_form($this->user_form->build_user_subscription_search()); |
1024
|
|
|
$this->load->view('view_user_subscriptions_list', $data); |
1025
|
|
|
} |
1026
|
|
|
|
1027
|
|
|
function user_subscriptions_json() { |
1028
|
|
|
|
1029
|
|
|
$accountinfo=$this->session->userdata('accountinfo'); |
1030
|
|
|
$json_data = array(); |
1031
|
|
|
$select = "charge_to_account.id,charges.description,charges.charge,charges.sweep_id"; |
1032
|
|
|
$table = "charges"; |
1033
|
|
|
$jionTable = array('charge_to_account', 'accounts'); |
1034
|
|
|
$jionCondition = array('charges.id = charge_to_account.charge_id', 'accounts.id = charge_to_account.accountid'); |
1035
|
|
|
$type = array('left', 'inner'); |
1036
|
|
|
$where = array('accounts.id' => $accountinfo['id']); |
1037
|
|
|
$order_type = 'charges.id'; |
1038
|
|
|
$order_by = "ASC"; |
1039
|
|
|
$this->db_model->build_search("user_subscription_search"); |
1040
|
|
|
$count_all = $this->db_model->getCountWithJion($table, $select, $where, $jionTable, $jionCondition, $type); |
1041
|
|
|
$paging_data = $this->form->load_grid_config($count_all, $_GET['rp'], $_GET['page']); |
1042
|
|
|
$json_data = $paging_data["json_paging"]; |
1043
|
|
|
$this->db_model->build_search("user_subscription_search"); |
1044
|
|
|
|
1045
|
|
|
$account_charge_list = $this->db_model->getAllJionQuery($table, $select, $where, $jionTable, $jionCondition, $type, $paging_data["paging"]["page_no"], $paging_data["paging"]["start"], $order_by, $order_type, ""); |
1046
|
|
|
$grid_fields = json_decode($this->user_form->build_user_subscription()); |
1047
|
|
|
$json_data['rows'] = $this->form->build_grid($account_charge_list, $grid_fields); |
1048
|
|
|
echo json_encode($json_data); |
1049
|
|
|
} |
1050
|
|
|
function user_subscriptions_search() { |
1051
|
|
|
$ajax_search = $this->input->post('ajax_search', 0); |
1052
|
|
|
if ($this->input->post('advance_search', TRUE) == 1) { |
1053
|
|
|
$this->session->set_userdata('advance_search', $this->input->post('advance_search')); |
1054
|
|
|
$action = $this->input->post(); |
1055
|
|
|
unset($action['action']); |
1056
|
|
|
unset($action['advance_search']); |
1057
|
|
|
if (isset($action['charge']['charge']) && $action['charge']['charge'] != '') { |
1058
|
|
|
$action['charge']['charge'] = $this->common_model->add_calculate_currency($action['charge']['charge'], "", '', true, false); |
1059
|
|
|
} |
1060
|
|
|
if(isset($action['sweep_id']) && $action['sweep_id'] != ''){ |
1061
|
|
|
$action['charges.sweep_id']=$action['sweep_id']; |
1062
|
|
|
unset($action['sweep_id']); |
1063
|
|
|
} |
1064
|
|
|
$this->session->set_userdata('user_subscription_search', $action); |
1065
|
|
|
} |
1066
|
|
|
if (@$ajax_search != 1) { |
1067
|
|
|
redirect(base_url() . 'user/user_subscriptions/'); |
1068
|
|
|
} |
1069
|
|
|
} |
1070
|
|
|
|
1071
|
|
|
function user_subscriptions_clearsearchfilter() { |
1072
|
|
|
$this->session->set_userdata('advance_search', 0); |
1073
|
|
|
$this->session->set_userdata('user_subscription_search', ""); |
1074
|
|
|
} |
1075
|
|
|
|
1076
|
|
|
function user_didlist() { |
1077
|
|
|
$accountinfo=$this->session->userdata('accountinfo'); |
1078
|
|
|
$data['page_title'] = 'Purchase DIDs'; |
|
|
|
|
1079
|
|
|
$data['search_flag'] = true; |
1080
|
|
|
$data['grid_fields'] = $this->user_form->build_user_didlist(); |
1081
|
|
|
$data['form_search'] = $this->form->build_serach_form($this->user_form->build_user_didlist_search()); |
1082
|
|
|
$data["grid_buttons"] = array(); |
1083
|
|
|
$acc_data = $this->session->userdata("accountinfo"); |
1084
|
|
|
$data['accountid'] = $acc_data['id']; |
1085
|
|
|
$data['country_id']=$acc_data['country_id']; |
1086
|
|
|
$result_did_final = array(); |
1087
|
|
|
if($accountinfo['reseller_id'] > 0){ |
1088
|
|
|
$this->db->select('dids.id, dids.number, reseller_pricing.setup, reseller_pricing.monthlycost'); |
1089
|
|
|
$this->db->where('dids.accountid',0); |
1090
|
|
|
$this->db->where('reseller_pricing.note','dids.number',false); |
1091
|
|
|
$this->db->where('reseller_pricing.reseller_id',$accountinfo['reseller_id']); |
1092
|
|
|
$this->db->from('dids,reseller_pricing'); |
1093
|
|
|
}else{ |
1094
|
|
|
$this->db->where('parent_id',0); |
1095
|
|
|
$this->db->where('accountid',0); |
1096
|
|
|
$this->db->select('id,number,setup,monthlycost'); |
1097
|
|
|
$this->db->from('dids'); |
1098
|
|
|
} |
1099
|
|
|
$dids_array=(array)$this->db->get()->result_array(); |
1100
|
|
|
$drp_list=array(); |
1101
|
|
View Code Duplication |
if(!empty($dids_array)){ |
1102
|
|
|
foreach ($dids_array as $drp_value) { |
1103
|
|
|
if (!empty($drp_value['monthlycost']) && $drp_value['monthlycost'] != 0) { |
1104
|
|
|
$did_cost = $this->common_model->to_calculate_currency($drp_value['monthlycost'],'','',true,true); |
1105
|
|
|
} else { |
1106
|
|
|
$did_cost = 0; |
1107
|
|
|
} |
1108
|
|
|
if (!empty($drp_value['setup']) && $drp_value['setup'] != 0) { |
1109
|
|
|
$did_setup = $this->common_model->to_calculate_currency($drp_value['setup'],'','',true,true); |
1110
|
|
|
} else { |
1111
|
|
|
$did_setup = 0; |
1112
|
|
|
} |
1113
|
|
|
$drp_list[$drp_value['id']] = $drp_value['number'] . ' ( Setup : ' . $did_setup . ')' . '( Monthly : ' . $did_cost . ' )'; |
1114
|
|
|
} |
1115
|
|
|
} |
1116
|
|
|
$data['didlist'] = form_dropdown_all(array("name"=>"free_didlist","id"=>"free_didlist","class"=>"did_dropdown"), $drp_list, ''); |
|
|
|
|
1117
|
|
|
$this->load->view('view_user_did_list', $data); |
1118
|
|
|
} |
1119
|
|
|
|
1120
|
|
|
function user_didlist_json() { |
1121
|
|
|
$account_data = $this->session->userdata("accountinfo"); |
1122
|
|
|
if ($account_data['reseller_id'] != 0) { |
1123
|
|
|
$json_data = array(); |
1124
|
|
|
$where = array('dids.accountid' => $account_data['id']); |
1125
|
|
|
$jionCondition = 'dids.number = reseller_pricing.note AND dids.parent_id = reseller_pricing.reseller_id'; |
1126
|
|
|
$count_all = $this->db_model->getJionQueryCount("dids", '*', $where, "reseller_pricing", $jionCondition, 'inner'); |
1127
|
|
|
$paging_data = $this->form->load_grid_config($count_all, $_GET['rp'], $_GET['page']); |
1128
|
|
|
$json_data = $paging_data["json_paging"]; |
1129
|
|
|
$this->db_model->build_search('user_did_search'); |
1130
|
|
|
$query = $this->db_model->getJionQuery("dids", 'reseller_pricing.setup,reseller_pricing.cost,reseller_pricing.last_modified_date,reseller_pricing.connectcost,reseller_pricing.inc,reseller_pricing.init_inc,reseller_pricing.includedseconds,reseller_pricing.monthlycost,dids.number,dids.id,dids.accountid,dids.extensions,dids.status,dids.provider_id,dids.allocation_bill_status,reseller_pricing.disconnectionfee,dids.dial_as,dids.call_type,dids.country_id', $where, "reseller_pricing", $jionCondition, 'inner', $paging_data["paging"]["page_no"], $paging_data["paging"]["start"], "dids.id", "", ''); |
1131
|
|
|
} else { |
1132
|
|
|
$json_data = array(); |
1133
|
|
|
$where = array('accountid' => $account_data['id']); |
1134
|
|
|
$this->db_model->build_search('user_did_search'); |
1135
|
|
|
$count_all = $this->db_model->countQuery("*", "dids", $where); |
1136
|
|
|
$paging_data = $this->form->load_grid_config($count_all, $_GET['rp'], $_GET['page']); |
1137
|
|
|
$json_data = $paging_data["json_paging"]; |
1138
|
|
|
$this->db_model->build_search('user_did_search'); |
1139
|
|
|
$query = $this->db_model->getSelect("*", "dids", $where, "id", "ASC", $paging_data["paging"]["page_no"], $paging_data["paging"]["start"]); |
1140
|
|
|
} |
1141
|
|
|
$did_grid_fields = json_decode($this->user_form->build_user_didlist()); |
1142
|
|
|
$json_data['rows'] = $this->form->build_grid($query, $did_grid_fields); |
1143
|
|
|
echo json_encode($json_data); |
1144
|
|
|
} |
1145
|
|
|
|
1146
|
|
|
function user_did_country() { |
1147
|
|
|
$this->load->module('accounts/accounts'); |
1148
|
|
|
$this->accounts->customer_did_country(); |
1149
|
|
|
} |
1150
|
|
|
|
1151
|
|
|
function user_didlist_search() { |
1152
|
|
|
$ajax_search = $this->input->post('ajax_search', 0); |
1153
|
|
|
if ($this->input->post('advance_search', TRUE) == 1) { |
1154
|
|
|
$this->session->set_userdata('advance_search', $this->input->post('advance_search')); |
1155
|
|
|
$action = $this->input->post(); |
1156
|
|
|
$accountinfo=$this->session->userdata('accountinfo'); |
1157
|
|
|
if($accountinfo['reseller_id'] > 0 && $action['call_type'] > 0){ |
1158
|
|
|
$action['dids.call_type']=$action['call_type']; |
1159
|
|
|
unset($action['call_type']); |
1160
|
|
|
} |
1161
|
|
|
unset($action['action']); |
1162
|
|
|
unset($action['advance_search']); |
1163
|
|
|
$this->session->set_userdata('user_did_search', $action); |
1164
|
|
|
} |
1165
|
|
|
if (@$ajax_search != 1) { |
1166
|
|
|
redirect(base_url() . 'user/user_didlist/'); |
1167
|
|
|
} |
1168
|
|
|
} |
1169
|
|
|
|
1170
|
|
|
function user_didlist_clearsearchfilter() { |
1171
|
|
|
$this->session->set_userdata('advance_search', 0); |
1172
|
|
|
$this->session->set_userdata('user_did_search', ""); |
1173
|
|
|
} |
1174
|
|
|
|
1175
|
|
|
function user_ipmap(){ |
1176
|
|
|
$this->session->set_userdata('advance_search', 0); |
1177
|
|
|
$data['grid_fields'] = $this->user_form->build_user_ipmap(); |
|
|
|
|
1178
|
|
|
$data['form_search'] = $this->form->build_serach_form($this->user_form->build_user_ipmap_search()); |
1179
|
|
|
$this->load->view('view_user_ipmap_list', $data); |
1180
|
|
|
} |
1181
|
|
|
|
1182
|
|
View Code Duplication |
function user_ipmap_json(){ |
1183
|
|
|
$json_data = array(); |
1184
|
|
|
$account_data = $this->session->userdata("accountinfo"); |
1185
|
|
|
$count_all = $this->user_model->user_ipmap_list(false); |
1186
|
|
|
$paging_data = $this->form->load_grid_config($count_all, $_GET['rp'], $_GET['page']); |
1187
|
|
|
$json_data = $paging_data["json_paging"]; |
1188
|
|
|
$query = $this->user_model->user_ipmap_list(true, $paging_data["paging"]["start"], $paging_data["paging"]["page_no"]); |
1189
|
|
|
$ipmap_grid_fields = json_decode($this->user_form->build_user_ipmap()); |
1190
|
|
|
$json_data['rows'] = $this->form->build_grid($query, $ipmap_grid_fields); |
1191
|
|
|
echo json_encode($json_data); |
1192
|
|
|
} |
1193
|
|
|
|
1194
|
|
View Code Duplication |
function user_ipmap_search(){ |
1195
|
|
|
$ajax_search = $this->input->post('ajax_search', 0); |
1196
|
|
|
if ($this->input->post('advance_search', TRUE) == 1) { |
1197
|
|
|
$this->session->set_userdata('advance_search', $this->input->post('advance_search')); |
1198
|
|
|
$action = $this->input->post(); |
1199
|
|
|
unset($action['action']); |
1200
|
|
|
unset($action['advance_search']); |
1201
|
|
|
$this->session->set_userdata('user_ipmap_search', $action); |
1202
|
|
|
} |
1203
|
|
|
if (@$ajax_search != 1) { |
1204
|
|
|
redirect(base_url() . 'user/user_ipmap/'); |
1205
|
|
|
} |
1206
|
|
|
} |
1207
|
|
|
|
1208
|
|
|
function user_ipmap_clearsearchfilter(){ |
1209
|
|
|
$this->session->set_userdata('advance_search', 0); |
1210
|
|
|
$this->session->set_userdata('user_ipmap_search', ""); |
1211
|
|
|
} |
1212
|
|
|
|
1213
|
|
|
function user_ipmap_action($action='delete',$id=false){ |
1214
|
|
|
$add_array=$this->input->post(); |
1215
|
|
|
$accountinfo=$this->session->userdata('accountinfo'); |
1216
|
|
|
if($action == 'add'){ |
1217
|
|
|
$ip = $add_array['ip']; |
1218
|
|
View Code Duplication |
if (strpos($ip, '/') !== false) { |
1219
|
|
|
$add_array['ip'] = $add_array['ip']; |
1220
|
|
|
} else { |
1221
|
|
|
$add_array['ip'] = $add_array['ip'] . '/32'; |
1222
|
|
|
} |
1223
|
|
|
$where = array("ip" => trim($add_array['ip']), "prefix" => trim($add_array['prefix'])); |
1224
|
|
|
$getdata = $this->db_model->countQuery("*", "ip_map", $where); |
1225
|
|
View Code Duplication |
if ($getdata > 0) { |
1226
|
|
|
$this->session->set_flashdata('astpp_notification', 'IP already exist in system.'); |
1227
|
|
|
} else { |
1228
|
|
|
unset($add_array['action']); |
1229
|
|
|
$add_array['context'] = 'default'; |
1230
|
|
|
$add_array['accountid'] = $accountinfo['id']; |
1231
|
|
|
$ip_flag = $this->db->insert("ip_map", $add_array); |
1232
|
|
|
if ($ip_flag) { |
1233
|
|
|
$this->load->library('freeswitch_lib'); |
1234
|
|
|
$this->load->module('freeswitch/freeswitch'); |
1235
|
|
|
$command = "api reloadacl"; |
1236
|
|
|
$response = $this->freeswitch_model->reload_freeswitch($command); |
1237
|
|
|
$this->session->set_userdata('astpp_notification', $response); |
1238
|
|
|
} |
1239
|
|
|
$this->session->set_flashdata('astpp_errormsg', 'IP Added Sucessfully.'); |
1240
|
|
|
} |
1241
|
|
|
} |
1242
|
|
|
if($action =='delete'){ |
1243
|
|
|
$this->db->delete('ip_map',array('id'=>$id)); |
1244
|
|
|
$this->session->set_flashdata('astpp_notification', 'IP Removed Sucessfully.'); |
1245
|
|
|
} |
1246
|
|
|
redirect(base_url()."user/user_ipmap/"); |
1247
|
|
|
} |
1248
|
|
|
|
1249
|
|
View Code Duplication |
function user_sipdevices() { |
1250
|
|
|
$data['page_title'] = 'SIP Devices'; |
|
|
|
|
1251
|
|
|
$this->session->set_userdata('advance_search', 0); |
1252
|
|
|
$data['grid_fields'] = $this->user_form->build_user_sipdevices(); |
1253
|
|
|
$data['form_search'] = $this->form->build_serach_form($this->user_form->build_user_sipdevices_search()); |
1254
|
|
|
$this->load->view('view_user_sipdevices_list', $data); |
1255
|
|
|
} |
1256
|
|
|
|
1257
|
|
|
function user_sipdevices_json() { |
1258
|
|
|
$account_data = $this->session->userdata("accountinfo"); |
1259
|
|
|
$json_data = array(); |
1260
|
|
|
$count_all = $this->user_model->user_sipdevices_list(false, $account_data['id']); |
1261
|
|
|
$paging_data = $this->form->load_grid_config($count_all, $_GET['rp'], $_GET['page']); |
1262
|
|
|
$json_data = $paging_data["json_paging"]; |
1263
|
|
|
$devices_result = array(); |
1264
|
|
|
$query = $this->user_model->user_sipdevices_list(true,$account_data['id'], $paging_data["paging"]["start"], $paging_data["paging"]["page_no"]); |
1265
|
|
|
foreach ($query as $key => $value) { |
1266
|
|
|
$path_true = base_url().'/assets/images/true.png'; |
1267
|
|
|
$path_false = base_url().'/assets/images/false.png'; |
1268
|
|
|
$voicemail_enabled = $value['voicemail_enabled'] == 'true'? '<img src='.$path_true.' style="height:20px;width:20px;" title="Enable">' : '<img src='.$path_false.' style="height:20px;width:20px;" title="Disable">'; |
1269
|
|
|
$json_data['rows'][] = array('cell' => array( |
1270
|
|
|
'<input type="checkbox" name="chkAll" id="'.$value['id'].'" class="ace chkRefNos" onclick="clickchkbox('.$value['id'].')" value=' .$value['id'].'><lable class="lbl"></lable>', |
1271
|
|
|
$value['username'], |
1272
|
|
|
$value['password'], |
1273
|
|
|
$value['effective_caller_id_name'], |
1274
|
|
|
$value['effective_caller_id_number'], |
1275
|
|
|
$this->common->get_status('status', 'sip_devices',$value), |
1276
|
|
|
$this->common->convert_GMT_to('','',$value['creation_date']), |
1277
|
|
|
$this->common->convert_GMT_to('','',$value['last_modified_date']), |
1278
|
|
|
$voicemail_enabled, |
1279
|
|
|
'<a href="'. base_url() .'user/user_sipdevices_edit/' . $value['id'] . '/" class="btn btn-royelblue btn-sm" rel="facebox" title="Edit"> <i class="fa fa-pencil-square-o fa-fw"></i></a> '. |
1280
|
|
|
'<a href="'. base_url() .'user/user_sipdevices_delete/' .$value['id']. '/" class="btn btn-royelblue btn-sm" title="Delete" onClick="return get_alert_msg();"> <i class="fa fa-trash fa-fw"></i></a>' |
1281
|
|
|
)); |
1282
|
|
|
} |
1283
|
|
|
echo json_encode($json_data); |
1284
|
|
|
} |
1285
|
|
View Code Duplication |
function user_sipdevices_search() { |
1286
|
|
|
$ajax_search = $this->input->post('ajax_search', 0); |
1287
|
|
|
if ($this->input->post('advance_search', TRUE) == 1) { |
1288
|
|
|
$this->session->set_userdata('advance_search', $this->input->post('advance_search')); |
1289
|
|
|
$action = $this->input->post(); |
1290
|
|
|
unset($action['action']); |
1291
|
|
|
unset($action['advance_search']); |
1292
|
|
|
$this->session->set_userdata('user_sipdevices_search', $action); |
1293
|
|
|
} |
1294
|
|
|
if (@$ajax_search != 1) { |
1295
|
|
|
redirect(base_url() . 'user/user_sipdevices/'); |
1296
|
|
|
} |
1297
|
|
|
} |
1298
|
|
|
|
1299
|
|
|
function user_sipdevices_clearsearchfilter() { |
1300
|
|
|
$this->session->set_userdata('advance_search', 0); |
1301
|
|
|
$this->session->set_userdata('user_sipdevices_search', ""); |
1302
|
|
|
} |
1303
|
|
|
|
1304
|
|
|
function user_sipdevices_add(){ |
1305
|
|
|
$data['page_title'] = 'Create SIP Device'; |
|
|
|
|
1306
|
|
|
$data['form'] = $this->form->build_form($this->user_form->build_user_sipdevices_form(),""); |
1307
|
|
|
$this->load->view('view_user_sipdevices_add_edit', $data); |
1308
|
|
|
} |
1309
|
|
|
function user_sipdevices_edit($edit_id=''){ |
1310
|
|
|
$account_data = $this->session->userdata("accountinfo"); |
1311
|
|
|
$data['page_title'] = 'Edit SIP Device'; |
|
|
|
|
1312
|
|
|
$where = array('id' => $edit_id); |
1313
|
|
|
$sipdevice_info = $this->user_model->user_sipdevice_info($edit_id); |
1314
|
|
|
$data['form'] = $this->form->build_form($this->user_form->build_user_sipdevices_form($edit_id), $sipdevice_info); |
1315
|
|
|
$this->load->view('view_user_sipdevices_add_edit', $data); |
1316
|
|
|
} |
1317
|
|
View Code Duplication |
function user_sipdevices_save(){ |
1318
|
|
|
$add_array = $this->input->post(); |
1319
|
|
|
$data['form'] = $this->form->build_form($this->user_form->build_user_sipdevices_form($add_array['id']), $add_array); |
|
|
|
|
1320
|
|
|
if ($add_array['id'] != '') { |
1321
|
|
|
$data['page_title'] = 'Edit SIP Devices'; |
1322
|
|
|
if ($this->form_validation->run() == FALSE) { |
1323
|
|
|
$data['validation_errors'] = validation_errors(); |
1324
|
|
|
echo $data['validation_errors']; |
1325
|
|
|
exit; |
1326
|
|
|
} else { |
1327
|
|
|
$this->user_model->user_sipdevice_edit($add_array, $add_array['id']); |
1328
|
|
|
echo json_encode(array("SUCCESS"=> "SIP Device Updated Successfully!")); |
1329
|
|
|
exit; |
1330
|
|
|
} |
1331
|
|
|
} else { |
1332
|
|
|
$data['page_title'] = 'Create SIP Device'; |
1333
|
|
|
if ($this->form_validation->run() == FALSE) { |
1334
|
|
|
$data['validation_errors'] = validation_errors(); |
1335
|
|
|
echo $data['validation_errors']; |
1336
|
|
|
exit; |
1337
|
|
|
} else { |
1338
|
|
|
$this->user_model->user_sipdevice_add($add_array); |
1339
|
|
|
echo json_encode(array("SUCCESS"=> "SIP Device Added Successfully!")); |
1340
|
|
|
exit; |
1341
|
|
|
} |
1342
|
|
|
} |
1343
|
|
|
} |
1344
|
|
|
function user_sipdevices_delete($id) { |
1345
|
|
|
$this->db->delete('sip_devices',array('id'=>$id)); |
1346
|
|
|
$this->session->set_flashdata('astpp_notification', 'SIP Device Removed Sucessfully!'); |
1347
|
|
|
redirect(base_url() . "user/user_sipdevices/"); |
1348
|
|
|
} |
1349
|
|
|
|
1350
|
|
View Code Duplication |
function user_sipdevices_delete_multiple(){ |
1351
|
|
|
$ids = $this->input->post("selected_ids", true); |
1352
|
|
|
$where = "id IN ($ids)"; |
1353
|
|
|
$this->db->delete("sip_devices",$where); |
1354
|
|
|
echo TRUE; |
1355
|
|
|
} |
1356
|
|
|
|
1357
|
|
|
function user_animap_list() { |
1358
|
|
|
$data['page_title'] = 'Caller ID'; |
|
|
|
|
1359
|
|
|
$this->session->set_userdata('advance_search', 0); |
1360
|
|
|
$data['grid_fields'] = $this->user_form->build_user_animap(); |
1361
|
|
|
$this->load->view('view_user_animap', $data); |
1362
|
|
|
} |
1363
|
|
|
|
1364
|
|
View Code Duplication |
function user_animap_list_json() { |
1365
|
|
|
$account_data = $this->session->userdata("accountinfo"); |
1366
|
|
|
$json_data = array(); |
1367
|
|
|
$where = array("accountid" => $account_data['id']); |
1368
|
|
|
$count_all = $this->db_model->countQuery("*", "ani_map", $where); |
1369
|
|
|
$paging_data = $this->form->load_grid_config($count_all, $_GET['rp'], $_GET['page']); |
1370
|
|
|
$json_data = $paging_data["json_paging"]; |
1371
|
|
|
$query = $this->db_model->select("*", "ani_map", $where, "id", "ASC", $paging_data["paging"]["page_no"], $paging_data["paging"]["start"]); |
1372
|
|
|
$grid_fields = json_decode($this->user_form->build_user_animap()); |
1373
|
|
|
$json_data['rows'] = $this->form->build_grid($query, $grid_fields); |
1374
|
|
|
echo json_encode($json_data); |
1375
|
|
|
} |
1376
|
|
|
|
1377
|
|
|
function user_animap_action($action, $aniid = "") { |
1378
|
|
|
$add_array = $this->input->post(); |
1379
|
|
|
if ($action == "add" && $add_array['number'] != '') { |
1380
|
|
|
$this->db->where('number', $add_array['number']); |
1381
|
|
|
$this->db->select('count(id) as count'); |
1382
|
|
|
$cnt_result = $this->db->get('ani_map'); |
1383
|
|
|
$cnt_result = $cnt_result->result_array(); |
1384
|
|
|
$count = $cnt_result[0]['count']; |
1385
|
|
|
if ($count == 0) { |
1386
|
|
|
if($add_array['number'] != ""){ |
1387
|
|
|
$accountinfo = $this->session->userdata("accountinfo"); |
1388
|
|
|
$insert_arr = array("number" => $add_array['number'], |
1389
|
|
|
"accountid" => $accountinfo['id'], |
1390
|
|
|
"context" => "default" |
1391
|
|
|
); |
1392
|
|
|
$this->db->insert("ani_map", $insert_arr); |
1393
|
|
|
$this->session->set_flashdata('astpp_errormsg', 'Add Caller ID Sucessfully!'); |
1394
|
|
|
}else{ |
1395
|
|
|
$this->session->set_flashdata('astpp_notification', 'Please Enter Caller ID value.'); |
1396
|
|
|
} |
1397
|
|
|
} else { |
1398
|
|
|
$this->session->set_flashdata('astpp_notification', ' Caller ID already Exists.'); |
1399
|
|
|
} |
1400
|
|
|
} |
1401
|
|
View Code Duplication |
if ($action == "delete") { |
1402
|
|
|
$this->session->set_flashdata('astpp_notification', 'Caller ID removed sucessfully!'); |
1403
|
|
|
$this->db_model->delete("ani_map", array("id" => $aniid)); |
1404
|
|
|
|
1405
|
|
|
} |
1406
|
|
|
redirect(base_url() . "user/user_animap_list/"); |
1407
|
|
|
} |
1408
|
|
|
|
1409
|
|
|
function user_alert_threshold() { |
1410
|
|
|
$data['page_title'] = 'Alert Threshold'; |
|
|
|
|
1411
|
|
|
$accountinfo = $this->session->userdata("accountinfo"); |
1412
|
|
|
$add_array = $this->input->post(); |
1413
|
|
|
if (!empty($add_array)) { |
1414
|
|
|
unset($add_array['action'],$add_array['id']); |
1415
|
|
|
$this->user_model->edit_alert_threshold($add_array, $accountinfo['id']); |
1416
|
|
|
$this->session->set_flashdata('astpp_errormsg', 'Alert Threshold updated successfully!'); |
1417
|
|
|
redirect(base_url() . 'user/user_alert_threshold/'); |
1418
|
|
|
} else { |
1419
|
|
|
$where = array('id' => $accountinfo["id"]); |
1420
|
|
|
$account = $this->db_model->getSelect("notify_credit_limit,notify_flag,notify_email", "accounts", $where); |
1421
|
|
|
$data['form'] = $this->form->build_form($this->user_form->user_alert_threshold(),(array)$account->first_row()); |
1422
|
|
|
$this->load->view('view_user_alert_threshold', $data); |
1423
|
|
|
} |
1424
|
|
|
} |
1425
|
|
|
|
1426
|
|
View Code Duplication |
function user_cdrs_report() { |
1427
|
|
|
$accountinfo=$this->session->userdata('accountinfo'); |
1428
|
|
|
$data['page_title'] = 'CDRs'; |
|
|
|
|
1429
|
|
|
$data['search_flag'] = true; |
1430
|
|
|
$data["grid_buttons"] = $this->user_form->build_cdrs_report_buttons(); |
1431
|
|
|
$data['grid_fields'] = $this->user_form->build_cdrs_report($accountinfo['type']); |
1432
|
|
|
$data['form_search'] = $this->form->build_serach_form($this->user_form->build_cdrs_report_search($accountinfo['type'])); |
1433
|
|
|
$this->load->view('view_user_cdrs_report', $data); |
1434
|
|
|
} |
1435
|
|
|
|
1436
|
|
View Code Duplication |
function user_cdrs_report_json() { |
1437
|
|
|
$accountinfo=$this->session->userdata('accountinfo'); |
1438
|
|
|
$variable=$accountinfo['type'] != 3 ?'total_debit':'total_cost'; |
1439
|
|
|
$count_res = $this->user_model->getuser_cdrs_list(false, "", ""); |
1440
|
|
|
$count_all = (array) $count_res->first_row(); |
1441
|
|
|
$paging_data = $this->form->load_grid_config($count_all['count'], $_GET['rp'], $_GET['page']); |
1442
|
|
|
$json_data = $paging_data["json_paging"]; |
1443
|
|
|
$query = $this->user_model->getuser_cdrs_list(true, $paging_data["paging"]["start"], $paging_data["paging"]["page_no"], false); |
1444
|
|
|
$grid_fields = json_decode($this->user_form->build_cdrs_report($accountinfo['type'])); |
1445
|
|
|
$json_data['rows'] = $this->form->build_grid($query, $grid_fields); |
1446
|
|
|
if ($count_all['count'] > 0) { |
1447
|
|
|
$search_arr = $this->session->userdata('user_cdrs_report_search'); |
1448
|
|
|
$show_seconds = (!empty($search_arr['search_in'])) ? $search_arr['search_in'] : 'minutes'; |
1449
|
|
|
$duration = ($show_seconds == 'minutes') ? ($count_all['billseconds'] > 0 ) ? |
1450
|
|
|
floor($count_all['billseconds'] / 60) . ":" . sprintf("%02d", $count_all['billseconds'] % 60) : "00:00" : $count_all['billseconds']; |
1451
|
|
|
$json_data['rows'][] = array("cell" => array( |
1452
|
|
|
"<b>Grand Total</b>", |
1453
|
|
|
"", |
1454
|
|
|
"", |
1455
|
|
|
"", |
1456
|
|
|
$duration, |
1457
|
|
|
"<b>".$this->common_model->calculate_currency($count_all[$variable],"","",true,false)."</b>", |
1458
|
|
|
"", |
1459
|
|
|
"", |
1460
|
|
|
)); |
1461
|
|
|
} |
1462
|
|
|
echo json_encode($json_data); |
1463
|
|
|
} |
1464
|
|
|
|
1465
|
|
View Code Duplication |
function user_cdrs_report_search() { |
1466
|
|
|
$ajax_search = $this->input->post('ajax_search', 0); |
1467
|
|
|
if ($this->input->post('advance_search', TRUE) == 1) { |
1468
|
|
|
$this->session->set_userdata('advance_search', $this->input->post('advance_search')); |
1469
|
|
|
$action = $this->input->post(); |
1470
|
|
|
unset($action['action']); |
1471
|
|
|
unset($action['advance_search']); |
1472
|
|
|
if (isset($action['debit']['debit']) && $action['debit']['debit'] != '') { |
1473
|
|
|
$action['debit']['debit'] = $this->common_model->add_calculate_currency($action['debit']['debit'], "", '', true, false); |
1474
|
|
|
} |
1475
|
|
|
$this->session->set_userdata('user_cdrs_report_search', $action); |
1476
|
|
|
} |
1477
|
|
|
if (@$ajax_search != 1) { |
1478
|
|
|
redirect(base_url() . 'user/user_cdrs_report/'); |
1479
|
|
|
} |
1480
|
|
|
} |
1481
|
|
|
|
1482
|
|
|
function user_cdrs_report_clearsearchfilter() { |
1483
|
|
|
$this->session->set_userdata('advance_search', 0); |
1484
|
|
|
$this->session->set_userdata('user_cdrs_report_search', ""); |
1485
|
|
|
} |
1486
|
|
|
|
1487
|
|
|
function user_cdrreport_export() { |
1488
|
|
|
$account_info = $accountinfo = $this->session->userdata('accountinfo'); |
1489
|
|
|
$currency_id=$account_info['currency_id']; |
1490
|
|
|
$currency=$this->common->get_field_name('currency', 'currency', $currency_id); |
1491
|
|
|
$count_res = $this->user_model->getuser_cdrs_list(false, "", ""); |
1492
|
|
|
$count_all = (array) $count_res->first_row(); |
1493
|
|
|
ob_clean(); |
1494
|
|
|
$customer_array[] = array("Date", "CallerID", "Called Number","Code", "Destination", "Duration", "Debit($currency)", "Disposition", "Call Type"); |
|
|
|
|
1495
|
|
|
if ($count_all['count'] > 0) { |
1496
|
|
|
$query = $this->user_model->getuser_cdrs_list(true, '', '', true); |
1497
|
|
|
$currency_info = $this->common->get_currency_info(); |
1498
|
|
|
$search_arr = $this->session->userdata('user_cdrs_report_search'); |
1499
|
|
|
$show_seconds = (!empty($search_arr['search_in'])) ? $search_arr['search_in'] : 'minutes'; |
1500
|
|
View Code Duplication |
foreach ($query->result_array() as $value) { |
1501
|
|
|
$duration = ($show_seconds == 'minutes') ? ($value['billseconds'] > 0 ) ? |
1502
|
|
|
floor($value['billseconds'] / 60) . ":" . sprintf("%02d", $value['billseconds'] % 60) : "00:00" : $value['billseconds']; |
1503
|
|
|
$customer_array[] = array( |
1504
|
|
|
$this->common->convert_GMT_to('', '', $value['callstart']), |
1505
|
|
|
$value['callerid'], |
1506
|
|
|
$value['callednum'], |
1507
|
|
|
filter_var($value['pattern'], FILTER_SANITIZE_NUMBER_INT), |
1508
|
|
|
$value['notes'], |
1509
|
|
|
$duration, |
1510
|
|
|
$this->common->calculate_currency_manually($currency_info, $value['debit'],false), |
1511
|
|
|
$value['disposition'], |
1512
|
|
|
$value['calltype'] |
1513
|
|
|
); |
1514
|
|
|
} |
1515
|
|
|
$duration = ($show_seconds == 'minutes') ? ($count_all['billseconds'] > 0 ) ? |
1516
|
|
|
floor($count_all['billseconds'] / 60) . ":" . sprintf("%02d", $count_all['billseconds'] % 60) : "00:00" : $count_all['billseconds']; |
1517
|
|
|
$customer_array[] = array("Grand Total", |
1518
|
|
|
"", |
1519
|
|
|
"", |
1520
|
|
|
"", |
1521
|
|
|
"", |
1522
|
|
|
$duration, |
1523
|
|
|
$this->common->calculate_currency_manually($currency_info, $count_all['total_debit']), |
1524
|
|
|
"", |
1525
|
|
|
"" |
1526
|
|
|
); |
1527
|
|
|
} |
1528
|
|
|
$this->load->helper('csv'); |
1529
|
|
|
array_to_csv($customer_array, 'Customer_CDR_' . date("Y-m-d") . '.csv'); |
1530
|
|
|
} |
1531
|
|
View Code Duplication |
function user_payment($action=""){ |
1532
|
|
|
if(common_model::$global_config['system_config']['paypal_status'] == 1){ |
1533
|
|
|
redirect(base_url() . 'user/user/'); |
1534
|
|
|
} |
1535
|
|
|
$this->load->module("user/payment"); |
1536
|
|
|
if($action=="GET_AMT"){ |
1537
|
|
|
$amount = $this->input->post("value",true); |
1538
|
|
|
$this->payment->convert_amount($amount); |
1539
|
|
|
}else{ |
1540
|
|
|
$this->payment->index(); |
1541
|
|
|
} |
1542
|
|
|
} |
1543
|
|
|
|
1544
|
|
|
function user_fund_transfer(){ |
1545
|
|
|
$data['page_title'] = 'Fund Transfer'; |
|
|
|
|
1546
|
|
|
$accountinfo = $this->session->userdata('accountinfo'); |
1547
|
|
|
$account=(array)$this->db->get_where('accounts',array("id"=>$accountinfo['id']))->first_row(); |
1548
|
|
|
$currency = (array)$this->db->get_where('currency',array("id"=>$account['currency_id']))->first_row(); |
1549
|
|
|
$data['form'] = $this->form->build_form($this->user_form->build_user_fund_transfer_form($account['number'], $currency['currency'], $accountinfo['id']), ''); |
1550
|
|
|
$this->load->view('view_user_fund_transfer', $data); |
1551
|
|
|
} |
1552
|
|
|
|
1553
|
|
|
function user_fund_transfer_save() { |
1554
|
|
|
$data['page_title'] = 'Fund Transfer'; |
|
|
|
|
1555
|
|
|
$post_array = $this->input->post(); |
1556
|
|
|
$accountinfo = $this->session->userdata('accountinfo'); |
1557
|
|
|
$account=(array)$this->db->get_where('accounts',array("id"=>$accountinfo['id']))->first_row(); |
1558
|
|
|
$currency = (array)$this->db->get_where('currency',array("id"=>$account['currency_id']))->first_row(); |
1559
|
|
|
$data['form'] = $this->form->build_form($this->user_form->build_user_fund_transfer_form($account['number'], $currency['currency'], $accountinfo['id']), $post_array); |
1560
|
|
|
if ($this->form_validation->run() == FALSE) { |
1561
|
|
|
$data['validation_errors'] = validation_errors(); |
1562
|
|
|
} else { |
1563
|
|
|
if (trim($post_array['fromaccountid']) != trim($post_array['toaccountid'])) { |
1564
|
|
|
$account_info = $this->session->userdata('accountinfo'); |
1565
|
|
|
$balance = $this->common->get_field_name('balance', 'accounts', array('id' => $account_info['id'], 'status' => 0, 'type' => 0, 'deleted' => 0)); |
1566
|
|
|
$toid = $this->common->get_field_name('id', 'accounts', array('number' => $post_array['toaccountid'], 'status' => 0, 'type' => 0, 'deleted' => 0)); |
1567
|
|
|
$toaccountinfo=(array)$this->db->get_where('accounts',array('number' => $post_array['toaccountid'], 'status' => 0, 'type' => 0, 'deleted' => 0),1)->first_row(); |
1568
|
|
|
if($toaccountinfo){ |
|
|
|
|
1569
|
|
|
$reseller_id = $toaccountinfo['reseller_id']; |
1570
|
|
|
$post_array['credit'] = $this->common_model->add_calculate_currency($post_array['credit'], '', '', false, false); |
1571
|
|
|
$minimum_fund=(array)$this->db->get_where('system',array("name"=>"minimum_fund_transfer"),1)->first_row(); |
1572
|
|
|
if ($post_array['toaccountid'] == $account_info['number']) { |
1573
|
|
|
$this->session->set_flashdata('astpp_notification', 'You can not transfer fund in same account.'); |
1574
|
|
|
} |
1575
|
|
|
elseif ($reseller_id != $account_info['reseller_id']) { |
1576
|
|
|
$this->session->set_flashdata('astpp_notification', 'You can only transfer fund in same level account.'); |
1577
|
|
|
} |
1578
|
|
|
elseif ($post_array['toaccountid'] == '') { |
1579
|
|
|
$this->session->set_flashdata('astpp_notification', 'Please enter To account number.'); |
1580
|
|
|
} |
1581
|
|
|
elseif (empty($post_array['credit'])) { |
1582
|
|
|
$this->session->set_flashdata('astpp_notification', 'Please enter a amount.'); |
1583
|
|
|
} |
1584
|
|
|
elseif ($post_array['credit'] > $balance) { |
1585
|
|
|
$this->session->set_flashdata('astpp_notification', 'You have insufficient balance.'); |
1586
|
|
|
} |
1587
|
|
|
elseif ($toid <= 0 || !isset($post_array['toaccountid'])) { |
1588
|
|
|
$this->session->set_flashdata('astpp_notification', 'Please enter valid account number.'); |
1589
|
|
|
} |
1590
|
|
|
elseif ($post_array['credit'] < 0) { |
1591
|
|
|
$this->session->set_flashdata('astpp_notification', 'Please enter amount greater then 0.'); |
1592
|
|
|
} |
1593
|
|
|
elseif ($minimum_fund['value'] >= $post_array['credit']) { |
1594
|
|
|
$this->session->set_flashdata('astpp_notification', 'You need to enter minimum amount of fund transfer ' . $minimum_fund['value'] . ' .'); |
1595
|
|
|
} |
1596
|
|
|
elseif (!isset($toid) || !isset($post_array['toaccountid'])) { |
1597
|
|
|
$this->session->set_flashdata('astpp_notification', 'Please enter valid account number!'); |
1598
|
|
|
} |
1599
|
|
|
elseif ($post_array['credit'] < 0 || $post_array['credit'] > $balance) { |
1600
|
|
|
$this->session->set_flashdata('astpp_notification', 'Insuffiecient amount !'); |
1601
|
|
|
}else{ |
1602
|
|
|
$from['id'] = $post_array['id']; |
|
|
|
|
1603
|
|
|
$from['account_currency'] = $post_array['account_currency']; |
1604
|
|
|
$from['accountid'] = $post_array['fromaccountid']; |
1605
|
|
View Code Duplication |
if ($account['posttoexternal'] == 1) { |
1606
|
|
|
$from['credit'] = abs($post_array['credit']); |
1607
|
|
|
$from['payment_type'] = '0'; |
1608
|
|
|
} else { |
1609
|
|
|
$from['credit'] = abs($post_array['credit']); |
1610
|
|
|
$from['payment_type'] = 'debit'; |
1611
|
|
|
} |
1612
|
|
|
$from['posttoexternal'] = $account['posttoexternal']; |
1613
|
|
|
|
1614
|
|
|
$from['notes'] = $post_array['notes']; |
1615
|
|
|
$from['action'] = 'save'; |
1616
|
|
|
$to['id'] = $toid; |
|
|
|
|
1617
|
|
|
$to['account_currency'] = $post_array['account_currency']; |
1618
|
|
|
$to['accountid'] = $post_array['toaccountid']; |
1619
|
|
View Code Duplication |
if ($toaccountinfo['posttoexternal'] == 0) { |
1620
|
|
|
$to['credit'] = abs($post_array['credit']); |
1621
|
|
|
$to['payment_type'] = '0'; |
1622
|
|
|
} else { |
1623
|
|
|
$to['credit'] = abs($post_array['credit']); |
1624
|
|
|
$to['payment_type'] = 'debit'; |
1625
|
|
|
} |
1626
|
|
|
$to['notes'] = $post_array['notes']; |
1627
|
|
|
$to['action'] = 'save'; |
1628
|
|
|
$response = $this->user_model->user_fund_transfer($from); |
1629
|
|
|
if ($response) { |
1630
|
|
|
$toresponse = $this->user_model->user_fund_transfer($to); |
1631
|
|
|
$this->session->set_flashdata('astpp_errormsg', 'Transfer success!'); |
1632
|
|
|
} else { |
1633
|
|
|
$this->session->set_flashdata('astpp_notification', 'Sorry We are not able to process this request.'); |
1634
|
|
|
} |
1635
|
|
|
} |
1636
|
|
|
}else{ |
1637
|
|
|
$this->session->set_flashdata('astpp_notification', 'Account number not found.'); |
1638
|
|
|
} |
1639
|
|
|
} else { |
1640
|
|
|
$this->session->set_flashdata('astpp_notification', 'You can not transfer fund in same account.'); |
1641
|
|
|
} |
1642
|
|
|
redirect(base_url() . 'user/user_fund_transfer/'); |
1643
|
|
|
} |
1644
|
|
|
$this->load->view('view_user_fund_transfer', $data); |
1645
|
|
|
} |
1646
|
|
View Code Duplication |
function user_opensips() { |
1647
|
|
|
$data['username'] = $this->session->userdata('user_name'); |
|
|
|
|
1648
|
|
|
$data['page_title'] = 'Opensips List'; |
1649
|
|
|
$data['search_flag'] = true; |
1650
|
|
|
$data["fs_grid_buttons"] = $this->user_form->build_user_opensips_buttons(); |
1651
|
|
|
$data['grid_fields'] = $this->user_form->build_user_opensips(); |
1652
|
|
|
$data['form_search'] = $this->form->build_serach_form($this->user_form->build_user_opensips_search()); |
1653
|
|
|
$this->load->view('view_opensips_list', $data); |
1654
|
|
|
} |
1655
|
|
|
|
1656
|
|
View Code Duplication |
function user_opensips_json() { |
1657
|
|
|
$accountinfo = $this->session->userdata("accountinfo"); |
1658
|
|
|
$json_data = array(); |
1659
|
|
|
$count_all = $this->user_model->get_user_opensips(false, $accountinfo['number']); |
1660
|
|
|
$paging_data = $this->form->load_grid_config($count_all,$_GET['rp'],$_GET['page']); |
1661
|
|
|
$json_data = $paging_data["json_paging"]; |
1662
|
|
|
$query = $this->user_model->get_user_opensips(true, $accountinfo['number'], $paging_data["paging"]["start"], $paging_data["paging"]["page_no"]); |
1663
|
|
|
$grid_fields = json_decode($this->user_form->build_user_opensips()); |
1664
|
|
|
$json_data['rows'] = $this->form->build_grid($query, $grid_fields); |
1665
|
|
|
echo json_encode($json_data); |
1666
|
|
|
} |
1667
|
|
|
|
1668
|
|
|
function user_opensips_clearsearchfilter() { |
1669
|
|
|
$this->session->set_userdata('advance_search', 0); |
1670
|
|
|
$this->session->set_userdata('user_opensips_search', ""); |
1671
|
|
|
} |
1672
|
|
|
|
1673
|
|
View Code Duplication |
function user_opensips_search() { |
1674
|
|
|
$ajax_search = $this->input->post('ajax_search', 0); |
1675
|
|
|
|
1676
|
|
|
if ($this->input->post('advance_search', TRUE) == 1) { |
1677
|
|
|
$this->session->set_userdata('advance_search', $this->input->post('advance_search')); |
1678
|
|
|
$action = $this->input->post(); |
1679
|
|
|
unset($action['action']); |
1680
|
|
|
unset($action['advance_search']); |
1681
|
|
|
$this->session->set_userdata('user_opensips_search', $action); |
1682
|
|
|
} |
1683
|
|
|
if ($ajax_search != 1) { |
1684
|
|
|
redirect(base_url() . 'user/user_opensips/'); |
1685
|
|
|
} |
1686
|
|
|
} |
1687
|
|
|
|
1688
|
|
|
function user_opensips_add() { |
1689
|
|
|
$accountinfo = $this->session->userdata("accountinfo"); |
1690
|
|
|
$data['username'] = $this->session->userdata('user_name'); |
|
|
|
|
1691
|
|
|
$data['flag'] = 'create'; |
1692
|
|
|
$data['page_title'] = 'Create Opensips'; |
1693
|
|
|
$data['form'] = $this->form->build_form($this->user_form->build_user_opensips_form(), ''); |
1694
|
|
|
$this->load->view('view_opensips_add_edit', $data); |
1695
|
|
|
} |
1696
|
|
|
|
1697
|
|
|
function user_opensips_edit($edit_id){ |
1698
|
|
|
$data['page_title'] = 'Edit Opensips'; |
|
|
|
|
1699
|
|
|
$db_config = Common_model::$global_config['system_config']; |
1700
|
|
|
$opensipdsn = "mysql://" . $db_config['opensips_dbuser'] . ":" . $db_config['opensips_dbpass'] . "@" . $db_config['opensips_dbhost'] . "/" . $db_config['opensips_dbname'] . "?char_set=utf8&dbcollat=utf8_general_ci&cache_on=true&cachedir="; |
1701
|
|
|
$this->opensips_db = $this->load->database($opensipdsn, true); |
|
|
|
|
1702
|
|
|
$where = array('id' => $edit_id); |
1703
|
|
|
$this->opensips_db->where($where); |
1704
|
|
|
$account = $this->opensips_db->get("subscriber"); |
1705
|
|
|
foreach ($account->result_array() as $key => $value) { |
1706
|
|
|
$edit_data = $value; |
1707
|
|
|
} |
1708
|
|
|
$data['form'] = $this->form->build_form($this->user_form->build_user_opensips_form($edit_id), $edit_data); |
|
|
|
|
1709
|
|
|
$this->load->view('view_opensips_add_edit', $data); |
1710
|
|
|
|
1711
|
|
|
} |
1712
|
|
|
|
1713
|
|
View Code Duplication |
function user_opensips_save(){ |
1714
|
|
|
$add_array = $this->input->post(); |
1715
|
|
|
$data['form'] = $this->form->build_form($this->user_form->build_user_opensips_form(), $add_array); |
|
|
|
|
1716
|
|
|
if ($add_array['id'] != '') { |
1717
|
|
|
$data['page_title'] = 'Edit Opensips'; |
1718
|
|
|
if ($this->form_validation->run() == FALSE) { |
1719
|
|
|
$data['validation_errors'] = validation_errors(); |
1720
|
|
|
echo $data['validation_errors']; |
1721
|
|
|
exit; |
1722
|
|
|
} else { |
1723
|
|
|
$auth_flag = $this->validate_device_data($add_array); |
1724
|
|
|
if($auth_flag == "TRUE"){ |
1725
|
|
|
$this->user_model->user_opensips_edit($add_array, $add_array['id']); |
1726
|
|
|
echo json_encode(array("SUCCESS"=> " OpenSips updated successfully!")); |
1727
|
|
|
exit; |
1728
|
|
|
}else{ |
1729
|
|
|
echo json_encode($auth_flag); |
1730
|
|
|
exit; |
1731
|
|
|
} |
1732
|
|
|
} |
1733
|
|
|
} else { |
1734
|
|
|
$data['page_title'] = 'Add Opensips'; |
1735
|
|
|
if ($this->form_validation->run() == FALSE) { |
1736
|
|
|
$data['validation_errors'] = validation_errors(); |
1737
|
|
|
echo $data['validation_errors']; |
1738
|
|
|
exit; |
1739
|
|
|
} else { |
1740
|
|
|
$auth_flag = $this->validate_device_data($add_array); |
1741
|
|
|
if($auth_flag == "TRUE"){ |
1742
|
|
|
$this->user_model->user_opensips_add($add_array); |
1743
|
|
|
echo json_encode(array("SUCCESS"=> "OpenSips added successfully!")); |
1744
|
|
|
exit; |
1745
|
|
|
}else{ |
1746
|
|
|
echo json_encode($auth_flag); |
1747
|
|
|
exit; |
1748
|
|
|
} |
1749
|
|
|
} |
1750
|
|
|
} |
1751
|
|
|
} |
1752
|
|
View Code Duplication |
function validate_device_data($data){ |
1753
|
|
|
if(isset($data["username"]) && $data["username"] != ""){ |
1754
|
|
|
$db_config = Common_model::$global_config['system_config']; |
1755
|
|
|
$opensipdsn = "mysql://" . $db_config['opensips_dbuser'] . ":" . $db_config['opensips_dbpass'] . "@" . $db_config['opensips_dbhost'] . "/" . $db_config['opensips_dbname'] . "?char_set=utf8&dbcollat=utf8_general_ci&cache_on=true&cachedir="; |
1756
|
|
|
$this->opensips_db = $this->load->database($opensipdsn, true); |
1757
|
|
|
$where = array("username"=>$data["username"]); |
1758
|
|
|
if($data['id'] != ""){ |
1759
|
|
|
$this->opensips_db->where("id <>",$data['id']); |
1760
|
|
|
} |
1761
|
|
|
$this->opensips_db->where($where); |
1762
|
|
|
$auth_flag = $this->opensips_db->get("subscriber"); |
1763
|
|
|
$auth_flag = $auth_flag->num_rows(); |
1764
|
|
|
if($auth_flag == 0){ |
1765
|
|
|
return "TRUE"; |
1766
|
|
|
}else{ |
1767
|
|
|
return array("username_error"=>"Duplicate Username Found.Username Must be Unique"); |
1768
|
|
|
} |
1769
|
|
|
}else{ |
1770
|
|
|
return array("username_error"=>"User name is required field."); |
1771
|
|
|
} |
1772
|
|
|
return "0"; |
|
|
|
|
1773
|
|
|
} |
1774
|
|
|
|
1775
|
|
|
function user_opensips_delete($id){ |
1776
|
|
|
$this->user_model->user_opensips_delete($id); |
1777
|
|
|
$this->session->set_flashdata('astpp_errormsg', 'Opensips Device Removed Successfully!.'); |
1778
|
|
|
redirect(base_url() . "user/user_opensips/"); |
1779
|
|
|
} |
1780
|
|
|
function user_opensips_delete_multiple(){ |
1781
|
|
|
$db_config = Common_model::$global_config['system_config']; |
1782
|
|
|
$opensipdsn = "mysql://" . $db_config['opensips_dbuser'] . ":" . $db_config['opensips_dbpass'] . "@" . $db_config['opensips_dbhost'] . "/" . $db_config['opensips_dbname'] . "?char_set=utf8&dbcollat=utf8_general_ci&cache_on=true&cachedir="; |
1783
|
|
|
$this->opensips_db = $this->load->database($opensipdsn, true); |
1784
|
|
|
$ids = $this->input->post("selected_ids", true); |
1785
|
|
|
$where = "id IN ($ids)"; |
1786
|
|
|
$this->opensips_db->where($where); |
1787
|
|
|
$this->opensips_db->delete("subscriber"); |
1788
|
|
|
echo TRUE; |
1789
|
|
|
} |
1790
|
|
|
|
1791
|
|
|
function user_cdrs(){ |
1792
|
|
|
$data['username'] = $this->session->userdata('user_name'); |
|
|
|
|
1793
|
|
|
$accountinfo=$this->session->userdata('accountinfo'); |
1794
|
|
|
$data['page_title'] = 'CDRs'; |
1795
|
|
|
$accounttype = strtolower($this->common->get_entity_type('', '', $accountinfo['type'])); |
1796
|
|
|
$this->load->module('reports/reports'); |
1797
|
|
|
$data['grid_fields'] = $this->reports->reports_form->build_report_list_for_user($accounttype); |
1798
|
|
|
$data['form_search'] = $this->form->build_serach_form($this->user_form->build_user_opensips_search()); |
1799
|
|
|
$data['accounttype']=$accounttype; |
1800
|
|
|
$this->load->view('view_user_cdrs', $data); |
1801
|
|
|
} |
1802
|
|
|
function user_cdrs_json(){ |
1803
|
|
|
$accountinfo=$this->session->userdata('accountinfo'); |
1804
|
|
|
$accounttype = strtolower($this->common->get_entity_type('', '', $accountinfo['type'])); |
1805
|
|
|
$this->load->module('reports/reports'); |
1806
|
|
|
$this->reports->customer_cdrreport($accountinfo['id'], $accounttype); |
1807
|
|
|
} |
1808
|
|
View Code Duplication |
function user_details_search($module_name){ |
1809
|
|
|
$action = $this->input->post(); |
1810
|
|
|
$this->session->set_userdata('left_panel_search_'.$module_name,""); |
1811
|
|
|
if(!empty($action['left_panel_search'])){ |
1812
|
|
|
$this->session->set_userdata('left_panel_search_'.$module_name, $action['left_panel_search']); |
1813
|
|
|
} |
1814
|
|
|
} |
1815
|
|
|
|
1816
|
|
|
function user_provider_report_export() { |
1817
|
|
|
$this->load->module('reports/reports'); |
1818
|
|
|
$this->provider_cdrreport_export(); |
|
|
|
|
1819
|
|
|
} |
1820
|
|
|
|
1821
|
|
|
|
1822
|
|
View Code Duplication |
function user_provider_cdrs_report() { |
1823
|
|
|
$accountinfo=$this->session->userdata('accountinfo'); |
1824
|
|
|
$data['page_title'] = 'Provider CDRs Report'; |
|
|
|
|
1825
|
|
|
$data['search_flag'] = true; |
1826
|
|
|
$data["grid_buttons"] = $this->user_form->build_provider_report_buttons(); |
1827
|
|
|
$data['grid_fields'] = $this->user_form->build_provider_report($accountinfo['type']); |
1828
|
|
|
$data['form_search'] = $this->form->build_serach_form($this->user_form->build_provider_report_search($accountinfo['type'])); |
1829
|
|
|
$this->load->view('view_provider_cdrs_report', $data); |
1830
|
|
|
} |
1831
|
|
|
|
1832
|
|
View Code Duplication |
function user_provider_cdrs_report_json() { |
1833
|
|
|
$accountinfo=$this->session->userdata('accountinfo'); |
1834
|
|
|
$variable=$accountinfo['type'] != 3 ?'total_debit':'total_cost'; |
1835
|
|
|
$count_res = $this->user_model->getprovider_cdrs_list(false, "", ""); |
1836
|
|
|
$count_all = (array) $count_res->first_row(); |
1837
|
|
|
$paging_data = $this->form->load_grid_config($count_all['count'], $_GET['rp'], $_GET['page']); |
1838
|
|
|
$json_data = $paging_data["json_paging"]; |
1839
|
|
|
$query = $this->user_model->getprovider_cdrs_list(true, $paging_data["paging"]["start"], $paging_data["paging"]["page_no"], false); |
1840
|
|
|
$grid_fields = json_decode($this->user_form->build_provider_report($accountinfo['type'])); |
1841
|
|
|
$json_data['rows'] = $this->form->build_grid($query, $grid_fields); |
1842
|
|
|
if ($count_all['count'] > 0) { |
1843
|
|
|
$search_arr = $this->session->userdata('user_provider_cdrs_report_search'); |
1844
|
|
|
$show_seconds = (!empty($search_arr['search_in'])) ? $search_arr['search_in'] : 'minutes'; |
1845
|
|
|
$duration = ($show_seconds == 'minutes') ? ($count_all['billseconds'] > 0 ) ? |
1846
|
|
|
floor($count_all['billseconds'] / 60) . ":" . sprintf("%02d", $count_all['billseconds'] % 60) : "00:00" : $count_all['billseconds']; |
1847
|
|
|
$json_data['rows'][] = array("cell" => array( |
1848
|
|
|
"<b>Grand Total</b>", |
1849
|
|
|
"", |
1850
|
|
|
"", |
1851
|
|
|
"", |
1852
|
|
|
$duration, |
1853
|
|
|
"<b>".$this->common_model->calculate_currency($count_all[$variable],"","",true,false)."</b>", |
1854
|
|
|
"", |
1855
|
|
|
"", |
1856
|
|
|
)); |
1857
|
|
|
} |
1858
|
|
|
echo json_encode($json_data); |
1859
|
|
|
} |
1860
|
|
|
|
1861
|
|
View Code Duplication |
function user_provider_cdrs_report_search() { |
1862
|
|
|
$ajax_search = $this->input->post('ajax_search', 0); |
1863
|
|
|
if ($this->input->post('advance_search', TRUE) == 1) { |
1864
|
|
|
$this->session->set_userdata('advance_search', $this->input->post('advance_search')); |
1865
|
|
|
$action = $this->input->post(); |
1866
|
|
|
if (isset($action['cost']['cost']) && $action['cost']['cost'] != '') { |
1867
|
|
|
$action['cost']['cost'] = $this->common_model->add_calculate_currency($action['cost']['cost'], "", '', true, false); |
1868
|
|
|
} |
1869
|
|
|
unset($action['action']); |
1870
|
|
|
unset($action['advance_search']); |
1871
|
|
|
$this->session->set_userdata('user_provider_cdrs_report_search', $action); |
1872
|
|
|
} |
1873
|
|
|
if ($ajax_search != 1) { |
1874
|
|
|
redirect(base_url() . 'user/user_provider_cdrs_report/'); |
1875
|
|
|
} |
1876
|
|
|
} |
1877
|
|
|
|
1878
|
|
|
function user_provider_cdrs_report_clearsearchfilter() { |
1879
|
|
|
$this->session->set_userdata('advance_search', 0); |
1880
|
|
|
$this->session->set_userdata('user_provider_cdrs_report_search', ""); |
1881
|
|
|
} |
1882
|
|
|
|
1883
|
|
|
function user_provider_cdrreport_export() { |
1884
|
|
|
$account_info = $accountinfo = $this->session->userdata('accountinfo'); |
1885
|
|
|
$currency_id=$account_info['currency_id']; |
1886
|
|
|
$currency=$this->common->get_field_name('currency', 'currency', $currency_id); |
1887
|
|
|
$count_res = $this->user_model->getprovider_cdrs_list(false, "", ""); |
1888
|
|
|
$count_all = (array) $count_res->first_row(); |
1889
|
|
|
ob_clean(); |
1890
|
|
|
$customer_array[] = array("Date", "CallerID", "Called Number", "Destination", "Duration", "Cost($currency)", "Disposition", "Call Type"); |
|
|
|
|
1891
|
|
|
if ($count_all['count'] > 0) { |
1892
|
|
|
$query = $this->user_model->getuser_cdrs_list(true, '', '', true); |
1893
|
|
|
$currency_info = $this->common->get_currency_info(); |
1894
|
|
|
$search_arr = $this->session->userdata('user_provider_cdrs_report_search'); |
1895
|
|
|
$show_seconds = (!empty($search_arr['search_in'])) ? $search_arr['search_in'] : 'minutes'; |
1896
|
|
View Code Duplication |
foreach ($query->result_array() as $value) { |
1897
|
|
|
$duration = ($show_seconds == 'minutes') ? ($value['billseconds'] > 0 ) ? |
1898
|
|
|
floor($value['billseconds'] / 60) . ":" . sprintf("%02d", $value['billseconds'] % 60) : "00:00" : $value['billseconds']; |
1899
|
|
|
$customer_array[] = array( |
1900
|
|
|
$this->common->convert_GMT_to('', '', $value['callstart']), |
1901
|
|
|
$value['callerid'], |
1902
|
|
|
$value['callednum'], |
1903
|
|
|
filter_var($value['pattern'], FILTER_SANITIZE_NUMBER_INT), |
1904
|
|
|
$duration, |
1905
|
|
|
$this->common->calculate_currency_manually($currency_info, $value['cost'],false), |
1906
|
|
|
$value['disposition'], |
1907
|
|
|
$value['calltype'] |
1908
|
|
|
); |
1909
|
|
|
} |
1910
|
|
|
$duration = ($show_seconds == 'minutes') ? ($count_all['billseconds'] > 0 ) ? |
1911
|
|
|
floor($count_all['billseconds'] / 60) . ":" . sprintf("%02d", $count_all['billseconds'] % 60) : "00:00" : $count_all['billseconds']; |
1912
|
|
|
$customer_array[] = array("Grand Total", |
1913
|
|
|
"", |
1914
|
|
|
"", |
1915
|
|
|
"", |
1916
|
|
|
$duration, |
1917
|
|
|
$this->common->calculate_currency_manually($currency_info, $count_all['total_cost'],false,true), |
1918
|
|
|
"", |
1919
|
|
|
"" |
1920
|
|
|
); |
1921
|
|
|
} |
1922
|
|
|
$this->load->helper('csv'); |
1923
|
|
|
array_to_csv($customer_array, 'Provider_CDR_' . date("Y-m-d") . '.csv'); |
1924
|
|
|
} |
1925
|
|
|
function user_speeddial(){ |
1926
|
|
|
$data['page_title'] = "Speed Dial"; |
|
|
|
|
1927
|
|
|
$accountinfo = $this->session->userdata('accountinfo'); |
1928
|
|
|
$where = array('id' => $accountinfo['id'], "reseller_id" => $accountinfo['reseller_id']); |
1929
|
|
|
$account = $this->db_model->getSelect("*", "accounts", $where); |
1930
|
|
|
if ($account->num_rows() > 0) { |
1931
|
|
|
$account_data = (array) $account->first_row(); |
1932
|
|
|
$speeddial_res = $this->db->get_where("speed_dial", array("accountid" => $accountinfo['id'])); |
1933
|
|
|
$speeddial_info = array(); |
1934
|
|
View Code Duplication |
if ($speeddial_res->num_rows() > 0) { |
1935
|
|
|
$speeddial_res = $speeddial_res->result_array(); |
1936
|
|
|
foreach ($speeddial_res as $key => $value) { |
1937
|
|
|
$speeddial_info[$value['speed_num']] = $value['number']; |
1938
|
|
|
} |
1939
|
|
|
} |
1940
|
|
|
$data['speeddial'] = $speeddial_info; |
1941
|
|
|
$this->load->view('view_user_speeddial', $data); |
1942
|
|
|
} else{ |
1943
|
|
|
redirect(base_url.'user/user/'); |
1944
|
|
|
} |
1945
|
|
|
} |
1946
|
|
|
|
1947
|
|
|
function user_speeddial_save(){ |
1948
|
|
|
$add_array= $this->input->post(); |
1949
|
|
|
$accountinfo=$this->session->userdata('accountinfo'); |
1950
|
|
|
$where = array("accountid" => $accountinfo['id']); |
1951
|
|
|
$this->db->select('count(id) as count'); |
1952
|
|
|
$this->db->where($where); |
1953
|
|
|
$speed_dial_result = (array)$this->db->get('speed_dial')->first_row(); |
1954
|
|
|
if ($speed_dial_result['count'] == 0) { |
1955
|
|
|
for ($i = 0; $i <= 9; $i++) { |
1956
|
|
|
$dest_number = $add_array['number'] == $i ? $add_array['destination'] : ''; |
1957
|
|
|
$data[$i] = array("number" => $dest_number, "speed_num" => $i, 'accountid' => $accountinfo['id']); |
|
|
|
|
1958
|
|
|
} |
1959
|
|
|
$this->db->insert_batch('speed_dial', $data); |
|
|
|
|
1960
|
|
|
} else { |
1961
|
|
|
$this->db->where('speed_num', $add_array['number']); |
1962
|
|
|
$this->db->where('accountid', $accountinfo['id']); |
1963
|
|
|
$result = $this->db->update('speed_dial', array('number' => $add_array['destination'])); |
1964
|
|
|
} |
1965
|
|
|
} |
1966
|
|
|
function user_speeddial_remove() { |
1967
|
|
|
$accountinfo=$this->session->userdata('accountinfo'); |
1968
|
|
|
$add_array=$this->input->post(); |
1969
|
|
|
$updateinfo = array('number' => ''); |
1970
|
|
|
$this->db->where('speed_num', $add_array['number']); |
1971
|
|
|
$this->db->where('accountid', $accountinfo['id']); |
1972
|
|
|
$result = $this->db->update('speed_dial', $updateinfo); |
1973
|
|
|
} |
1974
|
|
|
} |
1975
|
|
|
|
1976
|
|
|
?> |
|
|
|
|
1977
|
|
|
|
1978
|
|
|
|
This check looks for a call to a parent method whose name is different than the method from which it is called.
Consider the following code:
The
getFirstName()
method in theSon
calls the wrong method in the parent class.