@@ -38,70 +38,70 @@ discard block |
||
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 | /*Date: 08-Mar-2017 |
107 | 107 | Reason: Improvement of Dashboard Performance*/ |
@@ -132,7 +132,7 @@ discard block |
||
132 | 132 | $acc_arr[$data['day']] = $data; |
133 | 133 | $customer_total_result['sum'] += $data['sum']; |
134 | 134 | $customer_total_result['answered'] += $data['answered']; |
135 | - if($data['mcd'] > $mcd){ |
|
135 | + if ($data['mcd'] > $mcd) { |
|
136 | 136 | $mcd = $data['mcd']; |
137 | 137 | } |
138 | 138 | $customer_total_result['mcd'] = $mcd; |
@@ -143,22 +143,22 @@ discard block |
||
143 | 143 | $customer_total_result['cost'] += $data['cost']; |
144 | 144 | $customer_total_result['completed'] += $data['completed']; |
145 | 145 | } |
146 | - foreach($resellerresult->result_array() as $data){ |
|
147 | - $reseller_arr[$data['day']]=$data; |
|
148 | - if(isset($acc_arr[$data['day']])){ |
|
149 | - $acc_arr[$data['day']]['sum']= $data['sum']+$acc_arr[$data['day']]['sum']; |
|
150 | - $acc_arr[$data['day']]['answered']= $data['answered']+$acc_arr[$data['day']]['answered']; |
|
151 | - $acc_arr[$data['day']]['failed']= $data['failed']+$acc_arr[$data['day']]['failed']; |
|
152 | - $acc_arr[$data['day']]['profit']= $data['profit']+$acc_arr[$data['day']]['profit']; |
|
153 | - $acc_arr[$data['day']]['completed']= $data['completed']+$acc_arr[$data['day']]['completed']; |
|
154 | - $acc_arr[$data['day']]['duration'] = $data['duration']+$acc_arr[$data['day']]['duration']; |
|
155 | - $acc_arr[$data['day']]['mcd'] =$data['mcd'] > $acc_arr[$data['day']]['mcd'] ? $data['mcd']: $acc_arr[$data['day']]['mcd']; |
|
156 | - }else{ |
|
157 | - $acc_arr[$data['day']]=$data; |
|
146 | + foreach ($resellerresult->result_array() as $data) { |
|
147 | + $reseller_arr[$data['day']] = $data; |
|
148 | + if (isset($acc_arr[$data['day']])) { |
|
149 | + $acc_arr[$data['day']]['sum'] = $data['sum'] + $acc_arr[$data['day']]['sum']; |
|
150 | + $acc_arr[$data['day']]['answered'] = $data['answered'] + $acc_arr[$data['day']]['answered']; |
|
151 | + $acc_arr[$data['day']]['failed'] = $data['failed'] + $acc_arr[$data['day']]['failed']; |
|
152 | + $acc_arr[$data['day']]['profit'] = $data['profit'] + $acc_arr[$data['day']]['profit']; |
|
153 | + $acc_arr[$data['day']]['completed'] = $data['completed'] + $acc_arr[$data['day']]['completed']; |
|
154 | + $acc_arr[$data['day']]['duration'] = $data['duration'] + $acc_arr[$data['day']]['duration']; |
|
155 | + $acc_arr[$data['day']]['mcd'] = $data['mcd'] > $acc_arr[$data['day']]['mcd'] ? $data['mcd'] : $acc_arr[$data['day']]['mcd']; |
|
156 | + } else { |
|
157 | + $acc_arr[$data['day']] = $data; |
|
158 | 158 | } |
159 | 159 | $reseller_total_result['sum'] += $acc_arr[$data['day']]['sum']; |
160 | 160 | $reseller_total_result['answered'] += $acc_arr[$data['day']]['answered']; |
161 | - if($data['mcd'] > $res_mcd){ |
|
161 | + if ($data['mcd'] > $res_mcd) { |
|
162 | 162 | $res_mcd = $data['mcd']; |
163 | 163 | } |
164 | 164 | $reseller_total_result['mcd'] = $res_mcd; |
@@ -167,130 +167,130 @@ discard block |
||
167 | 167 | $reseller_total_result['profit'] += $acc_arr[$data['day']]['profit']; |
168 | 168 | $reseller_total_result['completed'] += $acc_arr[$data['day']]['completed']; |
169 | 169 | } |
170 | - if(!empty($acc_arr)){ |
|
171 | - foreach($daterange as $date){ |
|
172 | - $json_data['date'][]=$date->format("d"); |
|
173 | - $day = (int) $date->format("d"); |
|
174 | - if(isset($acc_arr[$day])){ |
|
175 | - $asr= ($acc_arr[$day]['sum'] > 0 ) ? (round(($acc_arr[$day]['completed'] / $acc_arr[$day]['sum']) * 100,2)) : 0; |
|
176 | - $acd= ($acc_arr[$day]['completed'] > 0 ) ? round($acc_arr[$day]['duration'] / $acc_arr[$day]['completed'],2) : 0; |
|
177 | - $json_data['total'][]= array((string)$acc_arr[$day]['day'],(int) $acc_arr[$day]['sum']); |
|
178 | - $json_data['answered'][]= array((string)$acc_arr[$day]['day'],(int) $acc_arr[$day]['answered']); |
|
179 | - $json_data['failed'][]= array((string)$acc_arr[$day]['day'],(int) $acc_arr[$day]['failed']); |
|
180 | - $json_data['profit'][]= array((string)$acc_arr[$day]['day'],(float) str_replace(",", "", $this->common_model->calculate_currency($acc_arr[$day]['profit']))); |
|
181 | - $json_data['acd'][]=array((string)$acc_arr[$day]['day'],(float)$acd); |
|
182 | - $json_data['mcd'][]=array((string)$acc_arr[$day]['day'],(float)$acc_arr[$day]['mcd']); |
|
183 | - $json_data['asr'][]=array((string)$acc_arr[$day]['day'],(float)$asr); |
|
184 | - }else{ |
|
185 | - $json_data['total'][]= array($date->format("d"), 0); |
|
186 | - $json_data['answered'][]= array($date->format("d"), 0); |
|
187 | - $json_data['failed'][]= array($date->format("d"), 0); |
|
188 | - $json_data['profit'][]= array($date->format("d"), 0); |
|
189 | - $json_data['acd'][]=array($date->format("d"), 0); |
|
190 | - $json_data['mcd'][]=array($date->format("d"), 0); |
|
191 | - $json_data['asr'][]=array($date->format("d"),0); |
|
170 | + if ( ! empty($acc_arr)) { |
|
171 | + foreach ($daterange as $date) { |
|
172 | + $json_data['date'][] = $date->format("d"); |
|
173 | + $day = (int)$date->format("d"); |
|
174 | + if (isset($acc_arr[$day])) { |
|
175 | + $asr = ($acc_arr[$day]['sum'] > 0) ? (round(($acc_arr[$day]['completed'] / $acc_arr[$day]['sum']) * 100, 2)) : 0; |
|
176 | + $acd = ($acc_arr[$day]['completed'] > 0) ? round($acc_arr[$day]['duration'] / $acc_arr[$day]['completed'], 2) : 0; |
|
177 | + $json_data['total'][] = array((string)$acc_arr[$day]['day'], (int)$acc_arr[$day]['sum']); |
|
178 | + $json_data['answered'][] = array((string)$acc_arr[$day]['day'], (int)$acc_arr[$day]['answered']); |
|
179 | + $json_data['failed'][] = array((string)$acc_arr[$day]['day'], (int)$acc_arr[$day]['failed']); |
|
180 | + $json_data['profit'][] = array((string)$acc_arr[$day]['day'], (float)str_replace(",", "", $this->common_model->calculate_currency($acc_arr[$day]['profit']))); |
|
181 | + $json_data['acd'][] = array((string)$acc_arr[$day]['day'], (float)$acd); |
|
182 | + $json_data['mcd'][] = array((string)$acc_arr[$day]['day'], (float)$acc_arr[$day]['mcd']); |
|
183 | + $json_data['asr'][] = array((string)$acc_arr[$day]['day'], (float)$asr); |
|
184 | + } else { |
|
185 | + $json_data['total'][] = array($date->format("d"), 0); |
|
186 | + $json_data['answered'][] = array($date->format("d"), 0); |
|
187 | + $json_data['failed'][] = array($date->format("d"), 0); |
|
188 | + $json_data['profit'][] = array($date->format("d"), 0); |
|
189 | + $json_data['acd'][] = array($date->format("d"), 0); |
|
190 | + $json_data['mcd'][] = array($date->format("d"), 0); |
|
191 | + $json_data['asr'][] = array($date->format("d"), 0); |
|
192 | 192 | } |
193 | 193 | |
194 | 194 | } |
195 | 195 | } |
196 | - else{ |
|
197 | - foreach($daterange as $date){ |
|
198 | - $json_data['date'][]=$date->format("d"); |
|
199 | - $day = (int) $date->format("d"); |
|
200 | - $json_data['total'][]= array($date->format("d"), 0); |
|
201 | - $json_data['answered'][]= array($date->format("d"), 0); |
|
202 | - $json_data['failed'][]= array($date->format("d"), 0); |
|
203 | - $json_data['profit'][]= array($date->format("d"), 0); |
|
204 | - $json_data['acd'][]=array($date->format("d"), 0); |
|
205 | - $json_data['mcd'][]=array($date->format("d"), 0); |
|
206 | - $json_data['asr'][]=array($date->format("d"), 0); |
|
196 | + else { |
|
197 | + foreach ($daterange as $date) { |
|
198 | + $json_data['date'][] = $date->format("d"); |
|
199 | + $day = (int)$date->format("d"); |
|
200 | + $json_data['total'][] = array($date->format("d"), 0); |
|
201 | + $json_data['answered'][] = array($date->format("d"), 0); |
|
202 | + $json_data['failed'][] = array($date->format("d"), 0); |
|
203 | + $json_data['profit'][] = array($date->format("d"), 0); |
|
204 | + $json_data['acd'][] = array($date->format("d"), 0); |
|
205 | + $json_data['mcd'][] = array($date->format("d"), 0); |
|
206 | + $json_data['asr'][] = array($date->format("d"), 0); |
|
207 | 207 | } |
208 | 208 | } |
209 | 209 | |
210 | - $json_data['total_count']['sum']=$reseller_total_result['sum']+$customer_total_result['sum']; |
|
211 | - $json_data['total_count']['debit']=$this->common_model->to_calculate_currency($reseller_total_result['debit']+$customer_total_result['debit'],'','',true,true); |
|
212 | - $json_data['total_count']['cost']=$this->common_model->to_calculate_currency($reseller_total_result['cost']+$customer_total_result['cost'],'','',true,true); |
|
213 | - $json_data['total_count']['profit']=$this->common_model->to_calculate_currency($reseller_total_result['profit']+$customer_total_result['profit'],'','',true,true); |
|
214 | - $json_data['total_count']['completed']=$reseller_total_result['completed']+$customer_total_result['completed']; |
|
215 | - $json_data['total_count']['duration']=$reseller_total_result['duration']+$customer_total_result['duration']; |
|
216 | - $json_data['total_count']['acd']=$json_data['total_count']['completed'] > 0 ? round($json_data['total_count']['duration']/$json_data['total_count']['completed'],2):0; |
|
217 | - $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; |
|
218 | - $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; |
|
219 | - $json_data['total_count']['asr']=$this->common_model->format_currency($json_data['total_count']['asr']); |
|
210 | + $json_data['total_count']['sum'] = $reseller_total_result['sum'] + $customer_total_result['sum']; |
|
211 | + $json_data['total_count']['debit'] = $this->common_model->to_calculate_currency($reseller_total_result['debit'] + $customer_total_result['debit'], '', '', true, true); |
|
212 | + $json_data['total_count']['cost'] = $this->common_model->to_calculate_currency($reseller_total_result['cost'] + $customer_total_result['cost'], '', '', true, true); |
|
213 | + $json_data['total_count']['profit'] = $this->common_model->to_calculate_currency($reseller_total_result['profit'] + $customer_total_result['profit'], '', '', true, true); |
|
214 | + $json_data['total_count']['completed'] = $reseller_total_result['completed'] + $customer_total_result['completed']; |
|
215 | + $json_data['total_count']['duration'] = $reseller_total_result['duration'] + $customer_total_result['duration']; |
|
216 | + $json_data['total_count']['acd'] = $json_data['total_count']['completed'] > 0 ? round($json_data['total_count']['duration'] / $json_data['total_count']['completed'], 2) : 0; |
|
217 | + $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; |
|
218 | + $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; |
|
219 | + $json_data['total_count']['asr'] = $this->common_model->format_currency($json_data['total_count']['asr']); |
|
220 | 220 | echo json_encode($json_data); |
221 | 221 | } |
222 | 222 | |
223 | - function user_maximum_callminutes(){ |
|
223 | + function user_maximum_callminutes() { |
|
224 | 224 | $this->customerReport_maximum_callminutes(); |
225 | 225 | } |
226 | 226 | function customerReport_maximum_callminutes() |
227 | 227 | { |
228 | - $post=$this->input->post(); |
|
229 | - $year=isset($post['year']) && $post['year'] >0 ? $post['year']:date("Y"); |
|
230 | - $month=isset($post['month'])&& $post['month'] >0 ? $post['month']:date("m"); |
|
231 | - $start_date=date($year.'-'.$month.'-01'); |
|
232 | - $end_day= $year==date("Y") && $month ==date("m") ? date("d") :cal_days_in_month(CAL_GREGORIAN, $month, $year); |
|
233 | - $gmtoffset=$this->common->get_timezone_offset(); |
|
234 | - $end_date=date($year."-".$month."-".$end_day.' H:i:s'); |
|
235 | - $end_date=date('Y-m-d',strtotime($end_date)+$gmtoffset); |
|
228 | + $post = $this->input->post(); |
|
229 | + $year = isset($post['year']) && $post['year'] > 0 ? $post['year'] : date("Y"); |
|
230 | + $month = isset($post['month']) && $post['month'] > 0 ? $post['month'] : date("m"); |
|
231 | + $start_date = date($year.'-'.$month.'-01'); |
|
232 | + $end_day = $year == date("Y") && $month == date("m") ? date("d") : cal_days_in_month(CAL_GREGORIAN, $month, $year); |
|
233 | + $gmtoffset = $this->common->get_timezone_offset(); |
|
234 | + $end_date = date($year."-".$month."-".$end_day.' H:i:s'); |
|
235 | + $end_date = date('Y-m-d', strtotime($end_date) + $gmtoffset); |
|
236 | 236 | $json_data = array(); |
237 | - $result = $this->dashboard_model->get_customer_maximum_callminutes($start_date,$end_date); |
|
238 | - $i=0; |
|
239 | - $accountinfo=$this->session->userdata('accountinfo'); |
|
240 | - $reseller_id=($accountinfo['type']== -1 OR $accountinfo['type']== 2) ? 0 : $accountinfo['id']; |
|
241 | - if($this->session->userdata('userlevel_logintype')!= 0 && $this->session->userdata('userlevel_logintype')!= 3){ |
|
242 | - $account_arr = $this->common->get_array('id,number,first_name,last_name', 'accounts',array('reseller_id'=>$reseller_id)); |
|
243 | - } else{ |
|
244 | - $account_arr = $this->common->get_array('id,number,first_name,last_name', 'accounts',array('id'=>$reseller_id)); |
|
237 | + $result = $this->dashboard_model->get_customer_maximum_callminutes($start_date, $end_date); |
|
238 | + $i = 0; |
|
239 | + $accountinfo = $this->session->userdata('accountinfo'); |
|
240 | + $reseller_id = ($accountinfo['type'] == -1 OR $accountinfo['type'] == 2) ? 0 : $accountinfo['id']; |
|
241 | + if ($this->session->userdata('userlevel_logintype') != 0 && $this->session->userdata('userlevel_logintype') != 3) { |
|
242 | + $account_arr = $this->common->get_array('id,number,first_name,last_name', 'accounts', array('reseller_id'=>$reseller_id)); |
|
243 | + } else { |
|
244 | + $account_arr = $this->common->get_array('id,number,first_name,last_name', 'accounts', array('id'=>$reseller_id)); |
|
245 | 245 | } |
246 | - if($result->num_rows() > 0 ) |
|
246 | + if ($result->num_rows() > 0) |
|
247 | 247 | { |
248 | - foreach ($result->result_array() as $data){ |
|
249 | - $data['accountid'] = ($data['accountid'] != '' && isset($account_arr[$data['accountid']])) ? $account_arr[$data['accountid']] :"Anonymous"; |
|
250 | - $json_data[$i][]= $data['accountid']; |
|
251 | - $json_data[$i][]= round($data['billseconds']/60,0); |
|
248 | + foreach ($result->result_array() as $data) { |
|
249 | + $data['accountid'] = ($data['accountid'] != '' && isset($account_arr[$data['accountid']])) ? $account_arr[$data['accountid']] : "Anonymous"; |
|
250 | + $json_data[$i][] = $data['accountid']; |
|
251 | + $json_data[$i][] = round($data['billseconds'] / 60, 0); |
|
252 | 252 | $i++; |
253 | 253 | } |
254 | - }else{ |
|
254 | + } else { |
|
255 | 255 | $json_data[] = array(); |
256 | 256 | } |
257 | 257 | echo json_encode($json_data); |
258 | 258 | } |
259 | 259 | |
260 | - function user_maximum_callcount(){ |
|
260 | + function user_maximum_callcount() { |
|
261 | 261 | $this->customerReport_maximum_callcount(); |
262 | 262 | } |
263 | 263 | function customerReport_maximum_callcount() |
264 | 264 | { |
265 | - $post=$this->input->post(); |
|
266 | - $year=isset($post['year']) && $post['year'] >0 ? $post['year']:date("Y"); |
|
267 | - $month=isset($post['month'])&& $post['month'] >0 ? $post['month']:date("m"); |
|
268 | - $start_date=date($year.'-'.$month.'-01'); |
|
269 | - $end_day= $year==date("Y") && $month ==date("m") ? date("d") :cal_days_in_month(CAL_GREGORIAN, $month, $year); |
|
270 | - $gmtoffset=$this->common->get_timezone_offset(); |
|
271 | - $end_date=date($year."-".$month."-".$end_day.' H:i:s'); |
|
272 | - $end_date=date('Y-m-d',strtotime($end_date)+$gmtoffset); |
|
265 | + $post = $this->input->post(); |
|
266 | + $year = isset($post['year']) && $post['year'] > 0 ? $post['year'] : date("Y"); |
|
267 | + $month = isset($post['month']) && $post['month'] > 0 ? $post['month'] : date("m"); |
|
268 | + $start_date = date($year.'-'.$month.'-01'); |
|
269 | + $end_day = $year == date("Y") && $month == date("m") ? date("d") : cal_days_in_month(CAL_GREGORIAN, $month, $year); |
|
270 | + $gmtoffset = $this->common->get_timezone_offset(); |
|
271 | + $end_date = date($year."-".$month."-".$end_day.' H:i:s'); |
|
272 | + $end_date = date('Y-m-d', strtotime($end_date) + $gmtoffset); |
|
273 | 273 | $json_data = array(); |
274 | - $result = $this->dashboard_model->get_customer_maximum_callcount($start_date,$end_date); |
|
275 | - $accountinfo=$this->session->userdata('accountinfo'); |
|
276 | - $reseller_id=($accountinfo['type']== -1 OR $accountinfo['type']== 2) ? 0 : $accountinfo['id']; |
|
277 | - if($this->session->userdata('userlevel_logintype')!= 0 && $this->session->userdata('userlevel_logintype')!= 3){ |
|
278 | - $account_arr = $this->common->get_array('id,number,first_name,last_name', 'accounts',array('reseller_id'=>$reseller_id)); |
|
279 | - } else{ |
|
280 | - $account_arr = $this->common->get_array('id,number,first_name,last_name', 'accounts',array('id'=>$reseller_id)); |
|
274 | + $result = $this->dashboard_model->get_customer_maximum_callcount($start_date, $end_date); |
|
275 | + $accountinfo = $this->session->userdata('accountinfo'); |
|
276 | + $reseller_id = ($accountinfo['type'] == -1 OR $accountinfo['type'] == 2) ? 0 : $accountinfo['id']; |
|
277 | + if ($this->session->userdata('userlevel_logintype') != 0 && $this->session->userdata('userlevel_logintype') != 3) { |
|
278 | + $account_arr = $this->common->get_array('id,number,first_name,last_name', 'accounts', array('reseller_id'=>$reseller_id)); |
|
279 | + } else { |
|
280 | + $account_arr = $this->common->get_array('id,number,first_name,last_name', 'accounts', array('id'=>$reseller_id)); |
|
281 | 281 | } |
282 | - $i=0; |
|
283 | - if($result->num_rows() > 0 ) |
|
282 | + $i = 0; |
|
283 | + if ($result->num_rows() > 0) |
|
284 | 284 | { |
285 | 285 | foreach ($result->result_array() as $data) |
286 | 286 | { |
287 | - $data['accountid'] = ($data['accountid'] != '' && isset($account_arr[$data['accountid']])) ? $account_arr[$data['accountid']] :"Anonymous"; |
|
288 | - $json_data[$i][]= $data['accountid']; |
|
289 | - $json_data[$i][]= (int)$data['call_count']; |
|
287 | + $data['accountid'] = ($data['accountid'] != '' && isset($account_arr[$data['accountid']])) ? $account_arr[$data['accountid']] : "Anonymous"; |
|
288 | + $json_data[$i][] = $data['accountid']; |
|
289 | + $json_data[$i][] = (int)$data['call_count']; |
|
290 | 290 | $i++; |
291 | 291 | } |
292 | 292 | |
293 | - }else{ |
|
293 | + } else { |
|
294 | 294 | $json_data[] = array(); |
295 | 295 | } |
296 | 296 | echo json_encode($json_data); |