@@ -119,7 +119,7 @@ |
||
119 | 119 | </label> |
120 | 120 | </div> |
121 | 121 | <div class="col-md-3"> |
122 | - <input class="col-md-2 form-control" name="speed_dial_<?php echo $i; ?>" id="speed_dial_<?php echo $i; ?>" size="16" type="text" value="<?php if (isset($speeddial[$i]) && !empty($speeddial[$i])) { |
|
122 | + <input class="col-md-2 form-control" name="speed_dial_<?php echo $i; ?>" id="speed_dial_<?php echo $i; ?>" size="16" type="text" value="<?php if (isset($speeddial[$i]) && ! empty($speeddial[$i])) { |
|
123 | 123 | echo $speeddial[$i]; |
124 | 124 | } ?>"> |
125 | 125 | </div> |
@@ -21,24 +21,24 @@ |
||
21 | 21 | <div class="col-md-12 no-padding color-three border_box"> |
22 | 22 | <div class="pull-left"> |
23 | 23 | <ul class="breadcrumb"> |
24 | - <?php $accountinfo=$this->session->userdata('accountinfo'); |
|
25 | - if($accountinfo['type']==1){ ?> |
|
26 | - <li><a href="<?= base_url() . "user/user_myprofile/"; ?>">My Profile</a></li> |
|
27 | - <?php } else{ ?> |
|
24 | + <?php $accountinfo = $this->session->userdata('accountinfo'); |
|
25 | + if ($accountinfo['type'] == 1) { ?> |
|
26 | + <li><a href="<?= base_url()."user/user_myprofile/"; ?>">My Profile</a></li> |
|
27 | + <?php } else { ?> |
|
28 | 28 | <li><a href="#">Configuration</a></li> |
29 | 29 | <?php } |
30 | 30 | ?> |
31 | 31 | |
32 | 32 | <li class='active'> |
33 | - <a href="<?= base_url() . "user/user_ipmap/"; ?>">IP Settings</a> |
|
33 | + <a href="<?= base_url()."user/user_ipmap/"; ?>">IP Settings</a> |
|
34 | 34 | </li> |
35 | 35 | </ul> |
36 | 36 | </div> |
37 | - <?php if($accountinfo['type']==1) { ?> |
|
37 | + <?php if ($accountinfo['type'] == 1) { ?> |
|
38 | 38 | <div class="pull-right"> |
39 | 39 | <ul class="breadcrumb"> |
40 | 40 | <li class="active pull-right"> |
41 | - <a href="<?= base_url() . "user/user_myprofile/"; ?>"> <i class="fa fa-fast-backward" aria-hidden="true"></i> Back</a></li> |
|
41 | + <a href="<?= base_url()."user/user_myprofile/"; ?>"> <i class="fa fa-fast-backward" aria-hidden="true"></i> Back</a></li> |
|
42 | 42 | </ul> |
43 | 43 | </div> |
44 | 44 | <?php }?> |
@@ -198,13 +198,13 @@ |
||
198 | 198 | </div> |
199 | 199 | </div> |
200 | 200 | <?php |
201 | - if($account_data['logo'] != ''){ |
|
202 | - $logo=$account_data['file']; |
|
203 | - }else{ |
|
204 | - $logo=$account_data['logo']; |
|
201 | + if ($account_data['logo'] != '') { |
|
202 | + $logo = $account_data['file']; |
|
203 | + } else { |
|
204 | + $logo = $account_data['logo']; |
|
205 | 205 | } |
206 | - if($logo != ''){ |
|
207 | - $file_name= base_url()."upload/$logo"; |
|
206 | + if ($logo != '') { |
|
207 | + $file_name = base_url()."upload/$logo"; |
|
208 | 208 | ?> |
209 | 209 | |
210 | 210 | <div class='col-md-12 no-padding'> |
@@ -43,24 +43,24 @@ |
||
43 | 43 | <div class="col-md-12 no-padding color-three border_box"> |
44 | 44 | <div class="pull-left"> |
45 | 45 | <ul class="breadcrumb"> |
46 | - <?php $accountinfo=$this->session->userdata('accountinfo'); |
|
47 | - if($accountinfo['type']==1){ ?> |
|
48 | - <li><a href="<?= base_url() . "user/user_myprofile/"; ?>">My Profile</a></li> |
|
49 | - <?php } else{ ?> |
|
46 | + <?php $accountinfo = $this->session->userdata('accountinfo'); |
|
47 | + if ($accountinfo['type'] == 1) { ?> |
|
48 | + <li><a href="<?= base_url()."user/user_myprofile/"; ?>">My Profile</a></li> |
|
49 | + <?php } else { ?> |
|
50 | 50 | <li><a href="#">Configuration</a></li> |
51 | 51 | <?php } |
52 | 52 | ?> |
53 | 53 | |
54 | 54 | <li class='active'> |
55 | - <a href="<?= base_url() . "user/user_animap_list/"; ?>">Caller ID</a> |
|
55 | + <a href="<?= base_url()."user/user_animap_list/"; ?>">Caller ID</a> |
|
56 | 56 | </li> |
57 | 57 | </ul> |
58 | 58 | </div> |
59 | - <?php if($accountinfo['type']==1) { ?> |
|
59 | + <?php if ($accountinfo['type'] == 1) { ?> |
|
60 | 60 | <div class="pull-right"> |
61 | 61 | <ul class="breadcrumb"> |
62 | 62 | <li class="active pull-right"> |
63 | - <a href="<?= base_url() . "user/user_myprofile/"; ?>"> <i class="fa fa-fast-backward" aria-hidden="true"></i> Back</a></li> |
|
63 | + <a href="<?= base_url()."user/user_myprofile/"; ?>"> <i class="fa fa-fast-backward" aria-hidden="true"></i> Back</a></li> |
|
64 | 64 | </ul> |
65 | 65 | </div> |
66 | 66 | <?php }?> |
@@ -52,24 +52,24 @@ |
||
52 | 52 | <div class="col-md-12 no-padding color-three border_box"> |
53 | 53 | <div class="pull-left"> |
54 | 54 | <ul class="breadcrumb"> |
55 | - <?php $accountinfo=$this->session->userdata('accountinfo'); |
|
56 | - if($accountinfo['type']==1){ ?> |
|
57 | - <li><a href="<?= base_url() . "user/user_myprofile/"; ?>">My Profile</a></li> |
|
58 | - <?php } else{ ?> |
|
55 | + <?php $accountinfo = $this->session->userdata('accountinfo'); |
|
56 | + if ($accountinfo['type'] == 1) { ?> |
|
57 | + <li><a href="<?= base_url()."user/user_myprofile/"; ?>">My Profile</a></li> |
|
58 | + <?php } else { ?> |
|
59 | 59 | <li><a href="#">Billing</a></li> |
60 | 60 | <?php } |
61 | 61 | ?> |
62 | 62 | |
63 | 63 | <li class='active'> |
64 | - <a href="<?= base_url() . "user/user_invoices_list/"; ?>">Invoices </a> |
|
64 | + <a href="<?= base_url()."user/user_invoices_list/"; ?>">Invoices </a> |
|
65 | 65 | </li> |
66 | 66 | </ul> |
67 | 67 | </div> |
68 | - <?php if($accountinfo['type']==1) { ?> |
|
68 | + <?php if ($accountinfo['type'] == 1) { ?> |
|
69 | 69 | <div class="pull-right"> |
70 | 70 | <ul class="breadcrumb"> |
71 | 71 | <li class="active pull-right"> |
72 | - <a href="<?= base_url() . "user/user_myprofile/"; ?>"> <i class="fa fa-fast-backward" aria-hidden="true"></i> Back</a></li> |
|
72 | + <a href="<?= base_url()."user/user_myprofile/"; ?>"> <i class="fa fa-fast-backward" aria-hidden="true"></i> Back</a></li> |
|
73 | 73 | </ul> |
74 | 74 | </div> |
75 | 75 | <?php }?> |
@@ -42,22 +42,22 @@ |
||
42 | 42 | <div class="col-md-12 no-padding color-three border_box"> |
43 | 43 | <div class="pull-left"> |
44 | 44 | <ul class="breadcrumb"> |
45 | - <?php $accountinfo=$this->session->userdata('accountinfo'); |
|
46 | - if($accountinfo['type']==1){ ?> |
|
47 | - <li><a href="<?= base_url() . "user/user_myprofile/"; ?>">My Profile</a></li> |
|
48 | - <?php } else{ ?> |
|
45 | + <?php $accountinfo = $this->session->userdata('accountinfo'); |
|
46 | + if ($accountinfo['type'] == 1) { ?> |
|
47 | + <li><a href="<?= base_url()."user/user_myprofile/"; ?>">My Profile</a></li> |
|
48 | + <?php } else { ?> |
|
49 | 49 | <li><a href="#">Billing</a></li> |
50 | 50 | <?php } ?> |
51 | 51 | <li class='active'> |
52 | - <a href="<?= base_url() . "user/user_charges_history/"; ?>">Charges History </a> |
|
52 | + <a href="<?= base_url()."user/user_charges_history/"; ?>">Charges History </a> |
|
53 | 53 | </li> |
54 | 54 | </ul> |
55 | 55 | </div> |
56 | - <?php if($accountinfo['type']==1) { ?> |
|
56 | + <?php if ($accountinfo['type'] == 1) { ?> |
|
57 | 57 | <div class="pull-right"> |
58 | 58 | <ul class="breadcrumb"> |
59 | 59 | <li class="active pull-right"> |
60 | - <a href="<?= base_url() . "user/user_myprofile/"; ?>"> <i class="fa fa-fast-backward" aria-hidden="true"></i> Back</a></li> |
|
60 | + <a href="<?= base_url()."user/user_myprofile/"; ?>"> <i class="fa fa-fast-backward" aria-hidden="true"></i> Back</a></li> |
|
61 | 61 | </ul> |
62 | 62 | </div> |
63 | 63 | <?php }?> |
@@ -31,23 +31,23 @@ discard block |
||
31 | 31 | |
32 | 32 | function get_recent_recharge() |
33 | 33 | { |
34 | - $accountinfo=$this->session->userdata('accountinfo'); |
|
35 | - $userlevel_logintype=$this->session->userdata('userlevel_logintype'); |
|
34 | + $accountinfo = $this->session->userdata('accountinfo'); |
|
35 | + $userlevel_logintype = $this->session->userdata('userlevel_logintype'); |
|
36 | 36 | |
37 | - $where_arr=array('payment_by'=>-1); |
|
38 | - if($userlevel_logintype == 1){ |
|
39 | - $where_arr=array('payment_by'=>$accountinfo['id']); |
|
37 | + $where_arr = array('payment_by'=>-1); |
|
38 | + if ($userlevel_logintype == 1) { |
|
39 | + $where_arr = array('payment_by'=>$accountinfo['id']); |
|
40 | 40 | } |
41 | - if($userlevel_logintype == 0 || $userlevel_logintype == 3){ |
|
42 | - $where_arr=array('accountid'=>$accountinfo['id']); |
|
41 | + if ($userlevel_logintype == 0 || $userlevel_logintype == 3) { |
|
42 | + $where_arr = array('accountid'=>$accountinfo['id']); |
|
43 | 43 | } |
44 | 44 | $this->db->where($where_arr); |
45 | 45 | $this->db->select('id,accountid,credit,payment_date'); |
46 | 46 | $this->db->limit(12); |
47 | - $this->db->order_by('payment_date','desc'); |
|
47 | + $this->db->order_by('payment_date', 'desc'); |
|
48 | 48 | return $this->db->get('payments'); |
49 | 49 | } |
50 | - function get_call_statistics($table,$parent_id,$start_date='',$end_date='',$group_flag=true) |
|
50 | + function get_call_statistics($table, $parent_id, $start_date = '', $end_date = '', $group_flag = true) |
|
51 | 51 | { |
52 | 52 | $this->db->select("count(uniqueid) as sum, |
53 | 53 | count(CASE WHEN billseconds > 0 THEN 1 END) as answered, |
@@ -59,46 +59,46 @@ discard block |
||
59 | 59 | sum(cost) as cost, |
60 | 60 | SUM(CASE WHEN billseconds > 0 THEN 1 ELSE 0 END) as completed, |
61 | 61 | DAY(callstart) as day",false); |
62 | - $this->db->where('callstart >=',$start_date." 00:00:00"); |
|
63 | - $this->db->where('callstart <=',$end_date." 23:59:59"); |
|
64 | - $this->db->where('reseller_id',$parent_id); |
|
65 | - if($group_flag) |
|
62 | + $this->db->where('callstart >=', $start_date." 00:00:00"); |
|
63 | + $this->db->where('callstart <=', $end_date." 23:59:59"); |
|
64 | + $this->db->where('reseller_id', $parent_id); |
|
65 | + if ($group_flag) |
|
66 | 66 | $this->db->group_by("DAY(callstart)"); |
67 | - $result=$this->db->get($table); |
|
67 | + $result = $this->db->get($table); |
|
68 | 68 | return $result; |
69 | 69 | } |
70 | - function get_customer_maximum_callminutes($start_date,$end_date) |
|
70 | + function get_customer_maximum_callminutes($start_date, $end_date) |
|
71 | 71 | { |
72 | - $start_date=$start_date." 00:00:00"; |
|
73 | - $end_date=$end_date." 23:59:59"; |
|
74 | - $accountinfo=$this->session->userdata('accountinfo'); |
|
75 | - $parent_id= ($accountinfo['type'] == 1) ? $accountinfo['id']:0; |
|
76 | - if($this->session->userdata('userlevel_logintype')!= 0 && $this->session->userdata('userlevel_logintype')!= 3) { |
|
77 | - $where ="reseller_id ='$parent_id'"; |
|
72 | + $start_date = $start_date." 00:00:00"; |
|
73 | + $end_date = $end_date." 23:59:59"; |
|
74 | + $accountinfo = $this->session->userdata('accountinfo'); |
|
75 | + $parent_id = ($accountinfo['type'] == 1) ? $accountinfo['id'] : 0; |
|
76 | + if ($this->session->userdata('userlevel_logintype') != 0 && $this->session->userdata('userlevel_logintype') != 3) { |
|
77 | + $where = "reseller_id ='$parent_id'"; |
|
78 | 78 | } else { |
79 | - $where ="accountid ='$parent_id'"; |
|
79 | + $where = "accountid ='$parent_id'"; |
|
80 | 80 | } |
81 | - $where= $where." AND callstart >= '".$start_date."' AND callstart <= '".$end_date."'"; |
|
82 | - $select_query= "(SELECT sum( billseconds ) AS billseconds,accountid FROM (cdrs) WHERE $where group by accountid order by sum(billseconds) desc limit 10) |
|
81 | + $where = $where." AND callstart >= '".$start_date."' AND callstart <= '".$end_date."'"; |
|
82 | + $select_query = "(SELECT sum( billseconds ) AS billseconds,accountid FROM (cdrs) WHERE $where group by accountid order by sum(billseconds) desc limit 10) |
|
83 | 83 | union |
84 | 84 | (SELECT sum( billseconds ) AS billseconds,accountid FROM (reseller_cdrs) WHERE $where |
85 | 85 | group by accountid order by sum(billseconds) desc limit 10 ) ORDER BY billseconds DESC LIMIT 10 "; |
86 | 86 | return $this->db->query($select_query); |
87 | 87 | } |
88 | 88 | |
89 | - function get_customer_maximum_callcount($start_date,$end_date) |
|
89 | + function get_customer_maximum_callcount($start_date, $end_date) |
|
90 | 90 | { |
91 | - $start_date=$start_date." 00:00:00"; |
|
92 | - $end_date=$end_date." 23:59:59"; |
|
93 | - $accountinfo=$this->session->userdata('accountinfo'); |
|
94 | - $parent_id= ($accountinfo['type'] == 1) ? $accountinfo['id']:0; |
|
95 | - if($this->session->userdata('userlevel_logintype')!= 0 && $this->session->userdata('userlevel_logintype')!= 3) { |
|
96 | - $where ="reseller_id ='$parent_id'"; |
|
91 | + $start_date = $start_date." 00:00:00"; |
|
92 | + $end_date = $end_date." 23:59:59"; |
|
93 | + $accountinfo = $this->session->userdata('accountinfo'); |
|
94 | + $parent_id = ($accountinfo['type'] == 1) ? $accountinfo['id'] : 0; |
|
95 | + if ($this->session->userdata('userlevel_logintype') != 0 && $this->session->userdata('userlevel_logintype') != 3) { |
|
96 | + $where = "reseller_id ='$parent_id'"; |
|
97 | 97 | } else { |
98 | - $where ="accountid ='$parent_id'"; |
|
98 | + $where = "accountid ='$parent_id'"; |
|
99 | 99 | } |
100 | - $where= $where." AND callstart >= '".$start_date."' AND callstart <= '".$end_date."'"; |
|
101 | - $select_query="(SELECT count(uniqueid) as call_count, `accountid` FROM (`cdrs`) WHERE $where GROUP BY `accountid` ORDER BY `call_count` desc LIMIT 10) |
|
100 | + $where = $where." AND callstart >= '".$start_date."' AND callstart <= '".$end_date."'"; |
|
101 | + $select_query = "(SELECT count(uniqueid) as call_count, `accountid` FROM (`cdrs`) WHERE $where GROUP BY `accountid` ORDER BY `call_count` desc LIMIT 10) |
|
102 | 102 | UNION |
103 | 103 | (SELECT count(uniqueid) as call_count,accountid FROM (reseller_cdrs) WHERE $where GROUP BY `accountid` ORDER BY `call_count` desc LIMIT 10) |
104 | 104 | ORDER BY call_count desc limit 10"; |
@@ -38,215 +38,215 @@ |
||
38 | 38 | function index() |
39 | 39 | { |
40 | 40 | if ($this->session->userdata('user_login') == FALSE) |
41 | - redirect(base_url() . 'login/login'); |
|
41 | + redirect(base_url().'login/login'); |
|
42 | 42 | $data['page_title'] = 'Dashboard'; |
43 | 43 | if ($this->session->userdata('logintype') == 0) |
44 | 44 | { |
45 | 45 | $this->load->view('view_user_dashboard', $data); |
46 | 46 | } else { |
47 | - $gmtoffset=$this->common->get_timezone_offset(); |
|
47 | + $gmtoffset = $this->common->get_timezone_offset(); |
|
48 | 48 | $this->load->view('view_dashboard', $data); |
49 | 49 | } |
50 | 50 | } |
51 | - function user_recent_payments(){ |
|
51 | + function user_recent_payments() { |
|
52 | 52 | $this->customerReport_recent_payments(); |
53 | 53 | } |
54 | 54 | function customerReport_recent_payments() |
55 | 55 | { |
56 | - $accountinfo=$this->session->userdata('accountinfo'); |
|
57 | - $currency=$this->common->get_field_name('currency','currency',array("id"=>$accountinfo['currency_id'])); |
|
56 | + $accountinfo = $this->session->userdata('accountinfo'); |
|
57 | + $currency = $this->common->get_field_name('currency', 'currency', array("id"=>$accountinfo['currency_id'])); |
|
58 | 58 | $json_data = array(); |
59 | - $i=1; |
|
59 | + $i = 1; |
|
60 | 60 | $result = $this->dashboard_model->get_recent_recharge(); |
61 | - $gmtoffset=$this->common->get_timezone_offset(); |
|
62 | - if($result->num_rows() > 0) |
|
61 | + $gmtoffset = $this->common->get_timezone_offset(); |
|
62 | + if ($result->num_rows() > 0) |
|
63 | 63 | { |
64 | - $account_arr = $this->common->get_array('id,number,first_name,last_name', 'accounts',''); |
|
65 | - $json_data[0]['accountid']='Accounts'; |
|
66 | - $json_data[0]['credit']='Amount('.$currency.")"; |
|
67 | - $json_data[0]['payment_date']='Date'; |
|
68 | - foreach($result->result_array() as $key=>$data){ |
|
69 | - $current_timestamp=strtotime($data['payment_date']); |
|
70 | - $modified_date=$current_timestamp+$gmtoffset; |
|
71 | - $data['accountid'] = ($data['accountid'] != '' && isset($account_arr[$data['accountid']])) ? $account_arr[$data['accountid']] :"Anonymous"; |
|
72 | - $json_data[$i]['accountid']=$data['accountid']; |
|
73 | - $json_data[$i]['credit']=$this->common_model->calculate_currency($data['credit'],'','',true,false); |
|
74 | - $json_data[$i]['payment_date']=date('Y-m-d H:i:s',strtotime($data['payment_date'])+$gmtoffset); |
|
64 | + $account_arr = $this->common->get_array('id,number,first_name,last_name', 'accounts', ''); |
|
65 | + $json_data[0]['accountid'] = 'Accounts'; |
|
66 | + $json_data[0]['credit'] = 'Amount('.$currency.")"; |
|
67 | + $json_data[0]['payment_date'] = 'Date'; |
|
68 | + foreach ($result->result_array() as $key=>$data) { |
|
69 | + $current_timestamp = strtotime($data['payment_date']); |
|
70 | + $modified_date = $current_timestamp + $gmtoffset; |
|
71 | + $data['accountid'] = ($data['accountid'] != '' && isset($account_arr[$data['accountid']])) ? $account_arr[$data['accountid']] : "Anonymous"; |
|
72 | + $json_data[$i]['accountid'] = $data['accountid']; |
|
73 | + $json_data[$i]['credit'] = $this->common_model->calculate_currency($data['credit'], '', '', true, false); |
|
74 | + $json_data[$i]['payment_date'] = date('Y-m-d H:i:s', strtotime($data['payment_date']) + $gmtoffset); |
|
75 | 75 | $i++; |
76 | 76 | } |
77 | 77 | } |
78 | 78 | echo json_encode($json_data); |
79 | 79 | } |
80 | - function user_call_statistics_with_profit(){ |
|
80 | + function user_call_statistics_with_profit() { |
|
81 | 81 | $this->customerReport_call_statistics_with_profit(); |
82 | 82 | } |
83 | 83 | function customerReport_call_statistics_with_profit() { |
84 | - $post=$this->input->post(); |
|
85 | - $year=isset($post['year']) && $post['year'] >0 ? $post['year']:date("Y"); |
|
86 | - $month=isset($post['month'])&& $post['month'] >0 ? $post['month']:date("m"); |
|
84 | + $post = $this->input->post(); |
|
85 | + $year = isset($post['year']) && $post['year'] > 0 ? $post['year'] : date("Y"); |
|
86 | + $month = isset($post['month']) && $post['month'] > 0 ? $post['month'] : date("m"); |
|
87 | 87 | $json_data = array(); |
88 | - $start_date=date($year.'-'.$month.'-01'); |
|
89 | - $end_day= $year==date("Y") && $month ==date("m") ? date("d") :cal_days_in_month(CAL_GREGORIAN, $month, $year); |
|
90 | - $gmtoffset=$this->common->get_timezone_offset(); |
|
91 | - $end_date=date($year."-".$month."-".$end_day.' H:i:s'); |
|
92 | - $end_date=date('Y-m-d',strtotime($end_date)+$gmtoffset); |
|
93 | - $current_date=(int)date("d"); |
|
94 | - $count=0; |
|
95 | - $i=0; |
|
88 | + $start_date = date($year.'-'.$month.'-01'); |
|
89 | + $end_day = $year == date("Y") && $month == date("m") ? date("d") : cal_days_in_month(CAL_GREGORIAN, $month, $year); |
|
90 | + $gmtoffset = $this->common->get_timezone_offset(); |
|
91 | + $end_date = date($year."-".$month."-".$end_day.' H:i:s'); |
|
92 | + $end_date = date('Y-m-d', strtotime($end_date) + $gmtoffset); |
|
93 | + $current_date = (int)date("d"); |
|
94 | + $count = 0; |
|
95 | + $i = 0; |
|
96 | 96 | $begin = new DateTime($start_date); |
97 | 97 | $end = new DateTime($end_date); |
98 | - $end=$end->modify('+1 day'); |
|
98 | + $end = $end->modify('+1 day'); |
|
99 | 99 | $daterange = new DatePeriod($begin, new DateInterval('P1D'), $end); |
100 | - $records_date=array(); |
|
101 | - $accountinfo=$this->session->userdata('accountinfo'); |
|
102 | - $parent_id= ($accountinfo['type'] == 1) ? $accountinfo['id'] : 0; |
|
103 | - $customerresult = $this->dashboard_model->get_call_statistics('cdrs',$parent_id,$start_date,$end_date); |
|
104 | - $resellerresult = $this->dashboard_model->get_call_statistics('reseller_cdrs',$parent_id,$start_date,$end_date); |
|
100 | + $records_date = array(); |
|
101 | + $accountinfo = $this->session->userdata('accountinfo'); |
|
102 | + $parent_id = ($accountinfo['type'] == 1) ? $accountinfo['id'] : 0; |
|
103 | + $customerresult = $this->dashboard_model->get_call_statistics('cdrs', $parent_id, $start_date, $end_date); |
|
104 | + $resellerresult = $this->dashboard_model->get_call_statistics('reseller_cdrs', $parent_id, $start_date, $end_date); |
|
105 | 105 | $acc_arr = array(); |
106 | 106 | foreach ($customerresult->result_array() as $data) { |
107 | 107 | $acc_arr[$data['day']] = $data; |
108 | 108 | } |
109 | - foreach($resellerresult->result_array() as $data){ |
|
110 | - $reseller_arr[$data['day']]=$data; |
|
111 | - if(isset($acc_arr[$data['day']])){ |
|
112 | - $acc_arr[$data['day']]['sum']= $data['sum']+$acc_arr[$data['day']]['sum']; |
|
113 | - $acc_arr[$data['day']]['answered']= $data['answered']+$acc_arr[$data['day']]['answered']; |
|
114 | - $acc_arr[$data['day']]['failed']= $data['failed']+$acc_arr[$data['day']]['failed']; |
|
115 | - $acc_arr[$data['day']]['profit']= $data['profit']+$acc_arr[$data['day']]['profit']; |
|
116 | - $acc_arr[$data['day']]['completed']= $data['completed']+$acc_arr[$data['day']]['completed']; |
|
117 | - $acc_arr[$data['day']]['duration'] = $data['duration']+$acc_arr[$data['day']]['duration']; |
|
118 | - $acc_arr[$data['day']]['mcd'] =$data['mcd'] > $acc_arr[$data['day']]['mcd'] ? $data['mcd']: $acc_arr[$data['day']]['mcd']; |
|
119 | - }else{ |
|
120 | - $acc_arr[$data['day']]=$data; |
|
109 | + foreach ($resellerresult->result_array() as $data) { |
|
110 | + $reseller_arr[$data['day']] = $data; |
|
111 | + if (isset($acc_arr[$data['day']])) { |
|
112 | + $acc_arr[$data['day']]['sum'] = $data['sum'] + $acc_arr[$data['day']]['sum']; |
|
113 | + $acc_arr[$data['day']]['answered'] = $data['answered'] + $acc_arr[$data['day']]['answered']; |
|
114 | + $acc_arr[$data['day']]['failed'] = $data['failed'] + $acc_arr[$data['day']]['failed']; |
|
115 | + $acc_arr[$data['day']]['profit'] = $data['profit'] + $acc_arr[$data['day']]['profit']; |
|
116 | + $acc_arr[$data['day']]['completed'] = $data['completed'] + $acc_arr[$data['day']]['completed']; |
|
117 | + $acc_arr[$data['day']]['duration'] = $data['duration'] + $acc_arr[$data['day']]['duration']; |
|
118 | + $acc_arr[$data['day']]['mcd'] = $data['mcd'] > $acc_arr[$data['day']]['mcd'] ? $data['mcd'] : $acc_arr[$data['day']]['mcd']; |
|
119 | + } else { |
|
120 | + $acc_arr[$data['day']] = $data; |
|
121 | 121 | } |
122 | 122 | } |
123 | - if(!empty($acc_arr)){ |
|
124 | - foreach($daterange as $date){ |
|
125 | - $json_data['date'][]=$date->format("d"); |
|
126 | - $day = (int) $date->format("d"); |
|
127 | - if(isset($acc_arr[$day])){ |
|
128 | - $asr= ($acc_arr[$day]['sum'] > 0 ) ? (round(($acc_arr[$day]['completed'] / $acc_arr[$day]['sum']) * 100,2)) : 0; |
|
129 | - $acd= ($acc_arr[$day]['completed'] > 0 ) ? round($acc_arr[$day]['duration'] / $acc_arr[$day]['completed'],2) : 0; |
|
130 | - $json_data['total'][]= array((string)$acc_arr[$day]['day'],(int) $acc_arr[$day]['sum']); |
|
131 | - $json_data['answered'][]= array((string)$acc_arr[$day]['day'],(int) $acc_arr[$day]['answered']); |
|
132 | - $json_data['failed'][]= array((string)$acc_arr[$day]['day'],(int) $acc_arr[$day]['failed']); |
|
133 | - $json_data['profit'][]= array((string)$acc_arr[$day]['day'],(float) str_replace(",", "", $this->common_model->calculate_currency($acc_arr[$day]['profit']))); |
|
134 | - $json_data['acd'][]=array((string)$acc_arr[$day]['day'],(float)$acd); |
|
135 | - $json_data['mcd'][]=array((string)$acc_arr[$day]['day'],(float)$acc_arr[$day]['mcd']); |
|
136 | - $json_data['asr'][]=array((string)$acc_arr[$day]['day'],(float)$asr); |
|
137 | - }else{ |
|
138 | - $json_data['total'][]= array($date->format("d"), 0); |
|
139 | - $json_data['answered'][]= array($date->format("d"), 0); |
|
140 | - $json_data['failed'][]= array($date->format("d"), 0); |
|
141 | - $json_data['profit'][]= array($date->format("d"), 0); |
|
142 | - $json_data['acd'][]=array($date->format("d"), 0); |
|
143 | - $json_data['mcd'][]=array($date->format("d"), 0); |
|
144 | - $json_data['asr'][]=array($date->format("d"),0); |
|
123 | + if ( ! empty($acc_arr)) { |
|
124 | + foreach ($daterange as $date) { |
|
125 | + $json_data['date'][] = $date->format("d"); |
|
126 | + $day = (int)$date->format("d"); |
|
127 | + if (isset($acc_arr[$day])) { |
|
128 | + $asr = ($acc_arr[$day]['sum'] > 0) ? (round(($acc_arr[$day]['completed'] / $acc_arr[$day]['sum']) * 100, 2)) : 0; |
|
129 | + $acd = ($acc_arr[$day]['completed'] > 0) ? round($acc_arr[$day]['duration'] / $acc_arr[$day]['completed'], 2) : 0; |
|
130 | + $json_data['total'][] = array((string)$acc_arr[$day]['day'], (int)$acc_arr[$day]['sum']); |
|
131 | + $json_data['answered'][] = array((string)$acc_arr[$day]['day'], (int)$acc_arr[$day]['answered']); |
|
132 | + $json_data['failed'][] = array((string)$acc_arr[$day]['day'], (int)$acc_arr[$day]['failed']); |
|
133 | + $json_data['profit'][] = array((string)$acc_arr[$day]['day'], (float)str_replace(",", "", $this->common_model->calculate_currency($acc_arr[$day]['profit']))); |
|
134 | + $json_data['acd'][] = array((string)$acc_arr[$day]['day'], (float)$acd); |
|
135 | + $json_data['mcd'][] = array((string)$acc_arr[$day]['day'], (float)$acc_arr[$day]['mcd']); |
|
136 | + $json_data['asr'][] = array((string)$acc_arr[$day]['day'], (float)$asr); |
|
137 | + } else { |
|
138 | + $json_data['total'][] = array($date->format("d"), 0); |
|
139 | + $json_data['answered'][] = array($date->format("d"), 0); |
|
140 | + $json_data['failed'][] = array($date->format("d"), 0); |
|
141 | + $json_data['profit'][] = array($date->format("d"), 0); |
|
142 | + $json_data['acd'][] = array($date->format("d"), 0); |
|
143 | + $json_data['mcd'][] = array($date->format("d"), 0); |
|
144 | + $json_data['asr'][] = array($date->format("d"), 0); |
|
145 | 145 | } |
146 | 146 | |
147 | 147 | } |
148 | 148 | } |
149 | - else{ |
|
150 | - foreach($daterange as $date){ |
|
151 | - $json_data['date'][]=$date->format("d"); |
|
152 | - $day = (int) $date->format("d"); |
|
153 | - $json_data['total'][]= array($date->format("d"), 0); |
|
154 | - $json_data['answered'][]= array($date->format("d"), 0); |
|
155 | - $json_data['failed'][]= array($date->format("d"), 0); |
|
156 | - $json_data['profit'][]= array($date->format("d"), 0); |
|
157 | - $json_data['acd'][]=array($date->format("d"), 0); |
|
158 | - $json_data['mcd'][]=array($date->format("d"), 0); |
|
159 | - $json_data['asr'][]=array($date->format("d"), 0); |
|
149 | + else { |
|
150 | + foreach ($daterange as $date) { |
|
151 | + $json_data['date'][] = $date->format("d"); |
|
152 | + $day = (int)$date->format("d"); |
|
153 | + $json_data['total'][] = array($date->format("d"), 0); |
|
154 | + $json_data['answered'][] = array($date->format("d"), 0); |
|
155 | + $json_data['failed'][] = array($date->format("d"), 0); |
|
156 | + $json_data['profit'][] = array($date->format("d"), 0); |
|
157 | + $json_data['acd'][] = array($date->format("d"), 0); |
|
158 | + $json_data['mcd'][] = array($date->format("d"), 0); |
|
159 | + $json_data['asr'][] = array($date->format("d"), 0); |
|
160 | 160 | } |
161 | 161 | } |
162 | - $customer_total_result = $this->dashboard_model->get_call_statistics('cdrs',$parent_id,$start_date,$end_date,false); |
|
163 | - $reseller_total_result = $this->dashboard_model->get_call_statistics('reseller_cdrs',$parent_id,$start_date,$end_date,false); |
|
164 | - $customer_total_result=(array)$customer_total_result->first_row(); |
|
165 | - $reseller_total_result=(array)$reseller_total_result->first_row(); |
|
166 | - $json_data['total_count']['sum']=$reseller_total_result['sum']+$customer_total_result['sum']; |
|
167 | - $json_data['total_count']['debit']=$this->common_model->to_calculate_currency($reseller_total_result['debit']+$customer_total_result['debit'],'','',true,true); |
|
168 | - $json_data['total_count']['cost']=$this->common_model->to_calculate_currency($reseller_total_result['cost']+$customer_total_result['cost'],'','',true,true); |
|
169 | - $json_data['total_count']['profit']=$this->common_model->to_calculate_currency($reseller_total_result['profit']+$customer_total_result['profit'],'','',true,true); |
|
170 | - $json_data['total_count']['completed']=$reseller_total_result['completed']+$customer_total_result['completed']; |
|
171 | - $json_data['total_count']['duration']=$reseller_total_result['duration']+$customer_total_result['duration']; |
|
172 | - $json_data['total_count']['acd']=$json_data['total_count']['completed'] > 0 ? round($json_data['total_count']['duration']/$json_data['total_count']['completed'],2):0; |
|
173 | - $json_data['total_count']['mcd']=($customer_total_result['mcd'] > 0 || $reseller_total_result['mcd'] > 0 ) ? ($customer_total_result['mcd'] > $reseller_total_result['mcd'] ? $customer_total_result['mcd']:$reseller_total_result['mcd']) : 0; |
|
174 | - $json_data['total_count']['asr']=($json_data['total_count']['sum'] > 0 ) ? (round(($json_data['total_count']['completed'] / $json_data['total_count']['sum']) * 100,2)) : 0; |
|
175 | - $json_data['total_count']['asr']=$this->common_model->format_currency($json_data['total_count']['asr']); |
|
162 | + $customer_total_result = $this->dashboard_model->get_call_statistics('cdrs', $parent_id, $start_date, $end_date, false); |
|
163 | + $reseller_total_result = $this->dashboard_model->get_call_statistics('reseller_cdrs', $parent_id, $start_date, $end_date, false); |
|
164 | + $customer_total_result = (array)$customer_total_result->first_row(); |
|
165 | + $reseller_total_result = (array)$reseller_total_result->first_row(); |
|
166 | + $json_data['total_count']['sum'] = $reseller_total_result['sum'] + $customer_total_result['sum']; |
|
167 | + $json_data['total_count']['debit'] = $this->common_model->to_calculate_currency($reseller_total_result['debit'] + $customer_total_result['debit'], '', '', true, true); |
|
168 | + $json_data['total_count']['cost'] = $this->common_model->to_calculate_currency($reseller_total_result['cost'] + $customer_total_result['cost'], '', '', true, true); |
|
169 | + $json_data['total_count']['profit'] = $this->common_model->to_calculate_currency($reseller_total_result['profit'] + $customer_total_result['profit'], '', '', true, true); |
|
170 | + $json_data['total_count']['completed'] = $reseller_total_result['completed'] + $customer_total_result['completed']; |
|
171 | + $json_data['total_count']['duration'] = $reseller_total_result['duration'] + $customer_total_result['duration']; |
|
172 | + $json_data['total_count']['acd'] = $json_data['total_count']['completed'] > 0 ? round($json_data['total_count']['duration'] / $json_data['total_count']['completed'], 2) : 0; |
|
173 | + $json_data['total_count']['mcd'] = ($customer_total_result['mcd'] > 0 || $reseller_total_result['mcd'] > 0) ? ($customer_total_result['mcd'] > $reseller_total_result['mcd'] ? $customer_total_result['mcd'] : $reseller_total_result['mcd']) : 0; |
|
174 | + $json_data['total_count']['asr'] = ($json_data['total_count']['sum'] > 0) ? (round(($json_data['total_count']['completed'] / $json_data['total_count']['sum']) * 100, 2)) : 0; |
|
175 | + $json_data['total_count']['asr'] = $this->common_model->format_currency($json_data['total_count']['asr']); |
|
176 | 176 | echo json_encode($json_data); |
177 | 177 | } |
178 | 178 | |
179 | - function user_maximum_callminutes(){ |
|
179 | + function user_maximum_callminutes() { |
|
180 | 180 | $this->customerReport_maximum_callminutes(); |
181 | 181 | } |
182 | 182 | function customerReport_maximum_callminutes() |
183 | 183 | { |
184 | - $post=$this->input->post(); |
|
185 | - $year=isset($post['year']) && $post['year'] >0 ? $post['year']:date("Y"); |
|
186 | - $month=isset($post['month'])&& $post['month'] >0 ? $post['month']:date("m"); |
|
187 | - $start_date=date($year.'-'.$month.'-01'); |
|
188 | - $end_day= $year==date("Y") && $month ==date("m") ? date("d") :cal_days_in_month(CAL_GREGORIAN, $month, $year); |
|
189 | - $gmtoffset=$this->common->get_timezone_offset(); |
|
190 | - $end_date=date($year."-".$month."-".$end_day.' H:i:s'); |
|
191 | - $end_date=date('Y-m-d',strtotime($end_date)+$gmtoffset); |
|
184 | + $post = $this->input->post(); |
|
185 | + $year = isset($post['year']) && $post['year'] > 0 ? $post['year'] : date("Y"); |
|
186 | + $month = isset($post['month']) && $post['month'] > 0 ? $post['month'] : date("m"); |
|
187 | + $start_date = date($year.'-'.$month.'-01'); |
|
188 | + $end_day = $year == date("Y") && $month == date("m") ? date("d") : cal_days_in_month(CAL_GREGORIAN, $month, $year); |
|
189 | + $gmtoffset = $this->common->get_timezone_offset(); |
|
190 | + $end_date = date($year."-".$month."-".$end_day.' H:i:s'); |
|
191 | + $end_date = date('Y-m-d', strtotime($end_date) + $gmtoffset); |
|
192 | 192 | $json_data = array(); |
193 | - $result = $this->dashboard_model->get_customer_maximum_callminutes($start_date,$end_date); |
|
194 | - $i=0; |
|
195 | - $accountinfo=$this->session->userdata('accountinfo'); |
|
196 | - $reseller_id=$accountinfo['type']== -1 ? 0 : $accountinfo['id']; |
|
197 | - if($this->session->userdata('userlevel_logintype')!= 0 && $this->session->userdata('userlevel_logintype')!= 3){ |
|
198 | - $account_arr = $this->common->get_array('id,number,first_name,last_name', 'accounts',array('reseller_id'=>$reseller_id)); |
|
199 | - } else{ |
|
200 | - $account_arr = $this->common->get_array('id,number,first_name,last_name', 'accounts',array('id'=>$reseller_id)); |
|
193 | + $result = $this->dashboard_model->get_customer_maximum_callminutes($start_date, $end_date); |
|
194 | + $i = 0; |
|
195 | + $accountinfo = $this->session->userdata('accountinfo'); |
|
196 | + $reseller_id = $accountinfo['type'] == -1 ? 0 : $accountinfo['id']; |
|
197 | + if ($this->session->userdata('userlevel_logintype') != 0 && $this->session->userdata('userlevel_logintype') != 3) { |
|
198 | + $account_arr = $this->common->get_array('id,number,first_name,last_name', 'accounts', array('reseller_id'=>$reseller_id)); |
|
199 | + } else { |
|
200 | + $account_arr = $this->common->get_array('id,number,first_name,last_name', 'accounts', array('id'=>$reseller_id)); |
|
201 | 201 | } |
202 | - if($result->num_rows() > 0 ) |
|
202 | + if ($result->num_rows() > 0) |
|
203 | 203 | { |
204 | - foreach ($result->result_array() as $data){ |
|
205 | - $data['accountid'] = ($data['accountid'] != '' && isset($account_arr[$data['accountid']])) ? $account_arr[$data['accountid']] :"Anonymous"; |
|
206 | - $json_data[$i][]= $data['accountid']; |
|
207 | - $json_data[$i][]= round($data['billseconds']/60,0); |
|
204 | + foreach ($result->result_array() as $data) { |
|
205 | + $data['accountid'] = ($data['accountid'] != '' && isset($account_arr[$data['accountid']])) ? $account_arr[$data['accountid']] : "Anonymous"; |
|
206 | + $json_data[$i][] = $data['accountid']; |
|
207 | + $json_data[$i][] = round($data['billseconds'] / 60, 0); |
|
208 | 208 | $i++; |
209 | 209 | } |
210 | - }else{ |
|
210 | + } else { |
|
211 | 211 | $json_data[] = array(); |
212 | 212 | } |
213 | 213 | echo json_encode($json_data); |
214 | 214 | } |
215 | 215 | |
216 | - function user_maximum_callcount(){ |
|
216 | + function user_maximum_callcount() { |
|
217 | 217 | $this->customerReport_maximum_callcount(); |
218 | 218 | } |
219 | 219 | function customerReport_maximum_callcount() |
220 | 220 | { |
221 | - $post=$this->input->post(); |
|
222 | - $year=isset($post['year']) && $post['year'] >0 ? $post['year']:date("Y"); |
|
223 | - $month=isset($post['month'])&& $post['month'] >0 ? $post['month']:date("m"); |
|
224 | - $start_date=date($year.'-'.$month.'-01'); |
|
225 | - $end_day= $year==date("Y") && $month ==date("m") ? date("d") :cal_days_in_month(CAL_GREGORIAN, $month, $year); |
|
226 | - $gmtoffset=$this->common->get_timezone_offset(); |
|
227 | - $end_date=date($year."-".$month."-".$end_day.' H:i:s'); |
|
228 | - $end_date=date('Y-m-d',strtotime($end_date)+$gmtoffset); |
|
221 | + $post = $this->input->post(); |
|
222 | + $year = isset($post['year']) && $post['year'] > 0 ? $post['year'] : date("Y"); |
|
223 | + $month = isset($post['month']) && $post['month'] > 0 ? $post['month'] : date("m"); |
|
224 | + $start_date = date($year.'-'.$month.'-01'); |
|
225 | + $end_day = $year == date("Y") && $month == date("m") ? date("d") : cal_days_in_month(CAL_GREGORIAN, $month, $year); |
|
226 | + $gmtoffset = $this->common->get_timezone_offset(); |
|
227 | + $end_date = date($year."-".$month."-".$end_day.' H:i:s'); |
|
228 | + $end_date = date('Y-m-d', strtotime($end_date) + $gmtoffset); |
|
229 | 229 | $json_data = array(); |
230 | - $result = $this->dashboard_model->get_customer_maximum_callcount($start_date,$end_date); |
|
231 | - $accountinfo=$this->session->userdata('accountinfo'); |
|
232 | - $reseller_id=$accountinfo['type']== -1 ? 0 : $accountinfo['id']; |
|
233 | - if($this->session->userdata('userlevel_logintype')!= 0 && $this->session->userdata('userlevel_logintype')!= 3){ |
|
234 | - $account_arr = $this->common->get_array('id,number,first_name,last_name', 'accounts',array('reseller_id'=>$reseller_id)); |
|
235 | - } else{ |
|
236 | - $account_arr = $this->common->get_array('id,number,first_name,last_name', 'accounts',array('id'=>$reseller_id)); |
|
230 | + $result = $this->dashboard_model->get_customer_maximum_callcount($start_date, $end_date); |
|
231 | + $accountinfo = $this->session->userdata('accountinfo'); |
|
232 | + $reseller_id = $accountinfo['type'] == -1 ? 0 : $accountinfo['id']; |
|
233 | + if ($this->session->userdata('userlevel_logintype') != 0 && $this->session->userdata('userlevel_logintype') != 3) { |
|
234 | + $account_arr = $this->common->get_array('id,number,first_name,last_name', 'accounts', array('reseller_id'=>$reseller_id)); |
|
235 | + } else { |
|
236 | + $account_arr = $this->common->get_array('id,number,first_name,last_name', 'accounts', array('id'=>$reseller_id)); |
|
237 | 237 | } |
238 | - $i=0; |
|
239 | - if($result->num_rows() > 0 ) |
|
238 | + $i = 0; |
|
239 | + if ($result->num_rows() > 0) |
|
240 | 240 | { |
241 | 241 | foreach ($result->result_array() as $data) |
242 | 242 | { |
243 | - $data['accountid'] = ($data['accountid'] != '' && isset($account_arr[$data['accountid']])) ? $account_arr[$data['accountid']] :"Anonymous"; |
|
244 | - $json_data[$i][]= $data['accountid']; |
|
245 | - $json_data[$i][]= (int)$data['call_count']; |
|
243 | + $data['accountid'] = ($data['accountid'] != '' && isset($account_arr[$data['accountid']])) ? $account_arr[$data['accountid']] : "Anonymous"; |
|
244 | + $json_data[$i][] = $data['accountid']; |
|
245 | + $json_data[$i][] = (int)$data['call_count']; |
|
246 | 246 | $i++; |
247 | 247 | } |
248 | 248 | |
249 | - }else{ |
|
249 | + } else { |
|
250 | 250 | $json_data[] = array(); |
251 | 251 | } |
252 | 252 | echo json_encode($json_data); |
@@ -375,7 +375,7 @@ discard block |
||
375 | 375 | $yearArray = range($start_year, $end_year); |
376 | 376 | foreach ($yearArray as $year) { |
377 | 377 | $selected = ($year == $currentyear) ? 'selected' : ''; |
378 | - echo '<option ' . $selected . ' value="' . $year . '">' . $year . '</option>'; |
|
378 | + echo '<option '.$selected.' value="'.$year.'">'.$year.'</option>'; |
|
379 | 379 | } |
380 | 380 | ?> |
381 | 381 | </select> |
@@ -388,7 +388,7 @@ discard block |
||
388 | 388 | $monthPadding = str_pad($month, 2, "0", STR_PAD_LEFT); |
389 | 389 | $fdate = date("F", strtotime($monthPadding)); |
390 | 390 | $selected = (date("m") == $monthPadding) ? 'selected' : null; |
391 | - echo '<option value="' . $monthPadding . '" ' . $selected . '>' . date("F", mktime(null, null, null, $monthPadding, 1)) . '</option>'; |
|
391 | + echo '<option value="'.$monthPadding.'" '.$selected.'>'.date("F", mktime(null, null, null, $monthPadding, 1)).'</option>'; |
|
392 | 392 | } |
393 | 393 | ?> |
394 | 394 | </select> |