@@ -24,16 +24,16 @@ discard block |
||
24 | 24 | if ( ! defined('BASEPATH')) { |
25 | 25 | exit('No direct script access allowed'); |
26 | 26 | } |
27 | -class freeswitch_lib{ |
|
27 | +class freeswitch_lib { |
|
28 | 28 | |
29 | - function event_socket_create($host='127.0.0.1', $port='8021', $password='ClueCon') { |
|
29 | + function event_socket_create($host = '127.0.0.1', $port = '8021', $password = 'ClueCon') { |
|
30 | 30 | $fp = @fsockopen($host, $port, $errno, $errdesc); |
31 | 31 | // or die("Connection to $host failed"); |
32 | 32 | // socket_set_blocking($fp,false); |
33 | 33 | |
34 | 34 | if ($fp) { |
35 | - socket_set_blocking($fp,false); |
|
36 | - while (!feof($fp)) { |
|
35 | + socket_set_blocking($fp, false); |
|
36 | + while ( ! feof($fp)) { |
|
37 | 37 | $buffer = fgets($fp, 1024); |
38 | 38 | usleep(100); //allow time for reponse |
39 | 39 | if (trim($buffer) == "Content-Type: auth/request") { |
@@ -56,7 +56,7 @@ discard block |
||
56 | 56 | $response = ""; |
57 | 57 | $i = 0; |
58 | 58 | $contentlength = 0; |
59 | - while (!feof($fp)) { |
|
59 | + while ( ! feof($fp)) { |
|
60 | 60 | $buffer = fgets($fp, 4096); |
61 | 61 | if ($contentlength > 0) { |
62 | 62 | $response .= $buffer; |
@@ -31,7 +31,7 @@ |
||
31 | 31 | if ($xml == "") |
32 | 32 | xml_not_found(); |
33 | 33 | echo $xml; |
34 | -}else { |
|
34 | +} else { |
|
35 | 35 | xml_not_found(); |
36 | 36 | } |
37 | 37 | $logger->log("*************************** Directory Ends **********************************"); |
@@ -15,7 +15,7 @@ discard block |
||
15 | 15 | <div class="col-md-12"> |
16 | 16 | <div class="w-box"> |
17 | 17 | <span style="margin-left:10px; text-align: center;background-color: none;color:#DD191D;"> |
18 | - <? if(isset($error) && !empty($error)) { |
|
18 | + <? if (isset($error) && ! empty($error)) { |
|
19 | 19 | echo $error; |
20 | 20 | }?> |
21 | 21 | </span> |
@@ -31,19 +31,19 @@ discard block |
||
31 | 31 | <div class="col-md-12 no-padding"> |
32 | 32 | <label class="col-md-3">Rate Group:</label> |
33 | 33 | <div> |
34 | - <? $pricelists = form_dropdown('pricelist_id', $this->db_model->build_dropdown("id,name", "pricelists","where_arr", array("reseller_id" => "0", "status" => "0")), ''); |
|
34 | + <? $pricelists = form_dropdown('pricelist_id', $this->db_model->build_dropdown("id,name", "pricelists", "where_arr", array("reseller_id" => "0", "status" => "0")), ''); |
|
35 | 35 | echo $pricelists; |
36 | 36 | ?> |
37 | 37 | </div> |
38 | 38 | </div> |
39 | 39 | <? |
40 | - $logintype=$this->session->userdata('userlevel_logintype'); |
|
40 | + $logintype = $this->session->userdata('userlevel_logintype'); |
|
41 | 41 | // $trunk=null; |
42 | - if($logintype !=1) { ?> |
|
42 | + if ($logintype != 1) { ?> |
|
43 | 43 | <div class="col-md-12 no-padding"> |
44 | 44 | <label class="col-md-3">Force Trunk:</label> |
45 | 45 | <div> |
46 | - <? $trunklist = form_dropdown_all('trunk_id', $this->db_model->build_dropdown("id,name", "trunks","where_arr", array("status" => "0")), ''); |
|
46 | + <? $trunklist = form_dropdown_all('trunk_id', $this->db_model->build_dropdown("id,name", "trunks", "where_arr", array("status" => "0")), ''); |
|
47 | 47 | echo $trunklist; |
48 | 48 | ?> |
49 | 49 | </div> |
@@ -100,7 +100,7 @@ discard block |
||
100 | 100 | <?}?> |
101 | 101 | |
102 | 102 | <?php |
103 | - if(isset($csv_tmp_data) && !empty($csv_tmp_data)){ ?> |
|
103 | + if (isset($csv_tmp_data) && ! empty($csv_tmp_data)) { ?> |
|
104 | 104 | |
105 | 105 | <section class="slice color-three"> |
106 | 106 | <div class="w-section inverse no-padding"> |
@@ -109,14 +109,14 @@ discard block |
||
109 | 109 | <div class="col-md-12 margin-t-10"> |
110 | 110 | <form id="import_form" name="import_form" action="<?=base_url()?>rates/origination_rate_import_file/<?= $pricelistid?>/<?=$trunkid?>/<?=$check_header?>/" method="POST"> |
111 | 111 | <table width="100%" border="1" class="details_table table"> |
112 | - <? $cnt =7; |
|
113 | - foreach($csv_tmp_data as $csv_key => $csv_value){ |
|
114 | - if($csv_key < 15){ |
|
112 | + <? $cnt = 7; |
|
113 | + foreach ($csv_tmp_data as $csv_key => $csv_value) { |
|
114 | + if ($csv_key < 15) { |
|
115 | 115 | echo "<tr>"; |
116 | - foreach($csv_value as $field_name => $field_val){ |
|
117 | - if($csv_key == 0){ |
|
116 | + foreach ($csv_value as $field_name => $field_val) { |
|
117 | + if ($csv_key == 0) { |
|
118 | 118 | echo "<th>".ucfirst($field_name)."</th>"; |
119 | - }else{ |
|
119 | + } else { |
|
120 | 120 | echo "<td class='portlet-content'>".$field_val."</td>"; |
121 | 121 | } |
122 | 122 | } |
@@ -6,19 +6,19 @@ |
||
6 | 6 | <div class="padding-b-10 col-md-12 no-padding"> |
7 | 7 | |
8 | 8 | <?php |
9 | - $str = isset($_SERVER['HTTPS'])&& $_SERVER['HTTPS'] == 'on' ? 'https://' :'http://'; |
|
9 | + $str = isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on' ? 'https://' : 'http://'; |
|
10 | 10 | $this->db->select('*'); |
11 | - $this->db->where('domain',$_SERVER['HTTP_HOST']); |
|
12 | - $this->db->or_where('domain','http://'.$_SERVER['HTTP_HOST']); |
|
13 | - $this->db->or_where('domain','https://'.$_SERVER['HTTP_HOST']); |
|
14 | - $result=$this->db->get('invoice_conf'); |
|
15 | - if($result->num_rows() > 0){ |
|
16 | - $result=$result->result_array(); |
|
11 | + $this->db->where('domain', $_SERVER['HTTP_HOST']); |
|
12 | + $this->db->or_where('domain', 'http://'.$_SERVER['HTTP_HOST']); |
|
13 | + $this->db->or_where('domain', 'https://'.$_SERVER['HTTP_HOST']); |
|
14 | + $result = $this->db->get('invoice_conf'); |
|
15 | + if ($result->num_rows() > 0) { |
|
16 | + $result = $result->result_array(); |
|
17 | 17 | $footer = $result[0]['website_footer']; |
18 | - }else{ |
|
18 | + } else { |
|
19 | 19 | $footer = ''; |
20 | 20 | } |
21 | - if($footer != ''){ ?> |
|
21 | + if ($footer != '') { ?> |
|
22 | 22 | <div style="margin-left:470px; "><?=$footer ?> |
23 | 23 | |
24 | 24 | <div style="" class="pull-left"> |
@@ -28,7 +28,7 @@ discard block |
||
28 | 28 | { |
29 | 29 | case 'development': |
30 | 30 | // error_reporting(E_ALL); |
31 | - error_reporting(E_ERROR|E_WARNING|E_PARSE); |
|
31 | + error_reporting(E_ERROR | E_WARNING | E_PARSE); |
|
32 | 32 | break; |
33 | 33 | |
34 | 34 | case 'testing': |
@@ -55,24 +55,24 @@ discard block |
||
55 | 55 | $config = $lib->get_configurations($db); |
56 | 56 | |
57 | 57 | //Set default decimal points |
58 | -$decimal_points = ($config['decimal_points'] <= 0)?4:$config['decimal_points']; |
|
58 | +$decimal_points = ($config['decimal_points'] <= 0) ? 4 : $config['decimal_points']; |
|
59 | 59 | |
60 | 60 | //Define logger object |
61 | 61 | $logger = new logger($lib); |
62 | 62 | |
63 | -if(isset($_SERVER["CONTENT_TYPE"]) && $_SERVER["CONTENT_TYPE"] == "application/json") { |
|
63 | +if (isset($_SERVER["CONTENT_TYPE"]) && $_SERVER["CONTENT_TYPE"] == "application/json") { |
|
64 | 64 | |
65 | 65 | $db->run("SET NAMES utf8"); |
66 | - $data = json_decode(file_get_contents("php://input"),true); |
|
66 | + $data = json_decode(file_get_contents("php://input"), true); |
|
67 | 67 | //error_log(print_r($data,true)); |
68 | - $logger->log(print_r($data,true)); |
|
69 | - if($data['variables']['calltype']== "CALLINGCARD"){ |
|
70 | - if(isset($data['variables']['originating_leg_uuid'])) |
|
68 | + $logger->log(print_r($data, true)); |
|
69 | + if ($data['variables']['calltype'] == "CALLINGCARD") { |
|
70 | + if (isset($data['variables']['originating_leg_uuid'])) |
|
71 | 71 | { |
72 | - process_cdr($data,$db,$logger,$decimal_points); |
|
72 | + process_cdr($data, $db, $logger, $decimal_points); |
|
73 | 73 | } |
74 | - }else{ |
|
75 | - process_cdr($data,$db,$logger,$decimal_points); |
|
74 | + } else { |
|
75 | + process_cdr($data, $db, $logger, $decimal_points); |
|
76 | 76 | } |
77 | 77 | } |
78 | 78 |
@@ -176,35 +176,35 @@ |
||
176 | 176 | <fieldset> |
177 | 177 | <legend> <?=ucfirst($group_title)?></legend> |
178 | 178 | <div style="width:50%;float:left;"> |
179 | - <?php $currency = Common_model::$global_config['system_config']['base_currency'];?> |
|
180 | - <?php $count=ceil(sizeof($details)/2); $i=0; $class="tleft";?> |
|
181 | - <?php foreach($details as$key=>$val){ ?> |
|
182 | - <?php if($count==$i){ |
|
179 | + <?php $currency = Common_model::$global_config['system_config']['base_currency']; ?> |
|
180 | + <?php $count = ceil(sizeof($details) / 2); $i = 0; $class = "tleft"; ?> |
|
181 | + <?php foreach ($details as$key=>$val) { ?> |
|
182 | + <?php if ($count == $i) { |
|
183 | 183 | echo '</div><div style="width:50%;float:left;">'; |
184 | - $class="tright"; |
|
184 | + $class = "tright"; |
|
185 | 185 | } ?> |
186 | 186 | <div class="col-md-12"> |
187 | 187 | <div class="<?=$class?>" href='#'> |
188 | - <label class="col-md-5 no-padding"><?php echo $val['display_name'];?> * </label> |
|
189 | - <?php if(method_exists($this->common,$val['field_type'])){ |
|
190 | - $option_array = $this->common->$val['field_type'](); |
|
188 | + <label class="col-md-5 no-padding"><?php echo $val['display_name']; ?> * </label> |
|
189 | + <?php if (method_exists($this->common, $val['field_type'])) { |
|
190 | + $option_array = $this->common->$val['field_type'](); |
|
191 | 191 | $drpstr = '<select name="'.$val['name'].'" class="col-md-5 form-control selectpicker" data-live-search="true">'; |
192 | - foreach($option_array as $option_key=>$option_val){ |
|
193 | - $selected = ($val['value'] == $option_key)? "selected='selected'":""; |
|
192 | + foreach ($option_array as $option_key=>$option_val) { |
|
193 | + $selected = ($val['value'] == $option_key) ? "selected='selected'" : ""; |
|
194 | 194 | $drpstr .= '<option value="'.$option_key.'"'.$selected.'>'.$option_val.'</option>'; |
195 | 195 | } |
196 | 196 | $drpstr .= '</select>'; |
197 | 197 | echo $drpstr; |
198 | 198 | unset($drpstr); |
199 | - } else{ ?> |
|
200 | - <input name="<?php echo $val['name'] ?>" value='<?php echo isset($val['value'])?$val['value']:''; ?>' size="20" maxlength="100" class="col-md-5 form-control" type="text"> |
|
199 | + } else { ?> |
|
200 | + <input name="<?php echo $val['name'] ?>" value='<?php echo isset($val['value']) ? $val['value'] : ''; ?>' size="20" maxlength="100" class="col-md-5 form-control" type="text"> |
|
201 | 201 | <?php }?> |
202 | - <span class="demo"><?php echo str_replace('smtp',"SMTP",$val['comment']);?></span> |
|
202 | + <span class="demo"><?php echo str_replace('smtp', "SMTP", $val['comment']); ?></span> |
|
203 | 203 | |
204 | 204 | </div> |
205 | 205 | </div> |
206 | 206 | |
207 | - <?php $i++;?> |
|
207 | + <?php $i++; ?> |
|
208 | 208 | <?php }?> |
209 | 209 | </div> |
210 | 210 | </fieldset> |
@@ -35,14 +35,14 @@ discard block |
||
35 | 35 | $this->load->library('csvreader'); |
36 | 36 | |
37 | 37 | if ($this->session->userdata('user_login') == FALSE) |
38 | - redirect(base_url() . '/astpp/login'); |
|
38 | + redirect(base_url().'/astpp/login'); |
|
39 | 39 | } |
40 | 40 | |
41 | 41 | function did_add() { |
42 | 42 | $data['page_title'] = 'Create DID'; |
43 | 43 | $data['form'] = $this->form->build_form($this->did_form->get_dids_form_fields(), ''); |
44 | 44 | $data['country_id'] = $this->common->get_field_name('id', 'countrycode', array('country' => Common_model::$global_config['system_config']['country'])); |
45 | - if (!$data['country_id']) { |
|
45 | + if ( ! $data['country_id']) { |
|
46 | 46 | $data['country_id'] = 1; |
47 | 47 | } |
48 | 48 | $this->load->view('view_did_add_edit', $data); |
@@ -64,7 +64,7 @@ discard block |
||
64 | 64 | $data['country_id'] = Common_model::$global_config['system_config']['country']; |
65 | 65 | } |
66 | 66 | /* * ************************************************* */ |
67 | - if (!$data['country_id']) { |
|
67 | + if ( ! $data['country_id']) { |
|
68 | 68 | $data['country_id'] = 1; |
69 | 69 | } |
70 | 70 | $edit_data['setup'] = $this->common_model->to_calculate_currency($edit_data['setup'], '', '', false, false); |
@@ -83,9 +83,9 @@ discard block |
||
83 | 83 | |
84 | 84 | function did_save() { |
85 | 85 | $add_array = $this->input->post(); |
86 | - $parent_id =isset($add_array['parent_id']) && $add_array['parent_id'] >0 ? $add_array['parent_id'] : ''; |
|
87 | - $accountid =isset($add_array['accountid']) && $add_array['accountid'] > 0 ? $add_array['accountid'] : ''; |
|
88 | - $data['form'] = $this->form->build_form($this->did_form->get_dids_form_fields($add_array['id'],$parent_id,$accountid), $add_array); |
|
86 | + $parent_id = isset($add_array['parent_id']) && $add_array['parent_id'] > 0 ? $add_array['parent_id'] : ''; |
|
87 | + $accountid = isset($add_array['accountid']) && $add_array['accountid'] > 0 ? $add_array['accountid'] : ''; |
|
88 | + $data['form'] = $this->form->build_form($this->did_form->get_dids_form_fields($add_array['id'], $parent_id, $accountid), $add_array); |
|
89 | 89 | if ($add_array['id'] != '') { |
90 | 90 | $data['page_title'] = 'Edit DID'; |
91 | 91 | if ($this->form_validation->run() == FALSE) { |
@@ -95,13 +95,13 @@ discard block |
||
95 | 95 | } else { |
96 | 96 | $number = $add_array['number']; |
97 | 97 | unset($add_array['number']); |
98 | - $add_array['accountid']=isset($add_array['accountid']) ?$add_array['accountid'] : 0; |
|
98 | + $add_array['accountid'] = isset($add_array['accountid']) ? $add_array['accountid'] : 0; |
|
99 | 99 | $add_array['setup'] = $this->common_model->add_calculate_currency($add_array['setup'], '', '', false, false); |
100 | 100 | $add_array['monthlycost'] = $this->common_model->add_calculate_currency($add_array['monthlycost'], '', '', false, false); |
101 | 101 | $add_array['connectcost'] = $this->common_model->add_calculate_currency($add_array['connectcost'], '', '', false, false); |
102 | 102 | $add_array['cost'] = $this->common_model->add_calculate_currency($add_array['cost'], '', '', false, false); |
103 | 103 | $this->did_model->edit_did($add_array, $add_array['id'], $number); |
104 | - echo json_encode(array("SUCCESS" => $number . " DID Updated Successfully!")); |
|
104 | + echo json_encode(array("SUCCESS" => $number." DID Updated Successfully!")); |
|
105 | 105 | exit; |
106 | 106 | } |
107 | 107 | } else { |
@@ -120,9 +120,9 @@ discard block |
||
120 | 120 | $add_array['monthlycost'] = $this->common_model->add_calculate_currency($add_array['monthlycost'], '', '', false, false); |
121 | 121 | $add_array['connectcost'] = $this->common_model->add_calculate_currency($add_array['connectcost'], '', '', false, false); |
122 | 122 | $add_array['cost'] = $this->common_model->add_calculate_currency($add_array['cost'], '', '', false, false); |
123 | - $add_array['accountid']=isset($add_array['accountid'])?$add_array['accountid'] : 0; |
|
123 | + $add_array['accountid'] = isset($add_array['accountid']) ? $add_array['accountid'] : 0; |
|
124 | 124 | $this->did_model->add_did($add_array); |
125 | - echo json_encode(array("SUCCESS" => $add_array["number"] . " DID Added Successfully!")); |
|
125 | + echo json_encode(array("SUCCESS" => $add_array["number"]." DID Added Successfully!")); |
|
126 | 126 | exit; |
127 | 127 | exit; |
128 | 128 | } |
@@ -132,7 +132,7 @@ discard block |
||
132 | 132 | function did_remove($id) { |
133 | 133 | $this->did_model->remove_did($id); |
134 | 134 | $this->session->set_flashdata('astpp_notification', 'DID Removed Successfully!'); |
135 | - redirect(base_url() . 'did/did_list/'); |
|
135 | + redirect(base_url().'did/did_list/'); |
|
136 | 136 | } |
137 | 137 | |
138 | 138 | /* |
@@ -141,54 +141,54 @@ discard block |
||
141 | 141 | */ |
142 | 142 | |
143 | 143 | function did_list_release($id) { |
144 | - $accountinfo=$this->session->userdata('accountinfo'); |
|
145 | - $this->db->where('id',$id); |
|
144 | + $accountinfo = $this->session->userdata('accountinfo'); |
|
145 | + $this->db->where('id', $id); |
|
146 | 146 | $this->db->select('parent_id,accountid,number'); |
147 | - $did_info=(array)$this->db->get('dids')->first_row(); |
|
148 | - if($did_info['parent_id'] > 0){ |
|
149 | - $str=$this->common->get_parent_info($did_info['parent_id'],$accountinfo['id']); |
|
150 | - $str=rtrim($str,","); |
|
151 | - $account_result=(array)$this->db->get_where('accounts',"id IN (".$str.")")->result_array(); |
|
152 | - foreach($account_result as $key=>$acc_row){ |
|
153 | - $acc_row['did_number']=$did_info['number']; |
|
147 | + $did_info = (array)$this->db->get('dids')->first_row(); |
|
148 | + if ($did_info['parent_id'] > 0) { |
|
149 | + $str = $this->common->get_parent_info($did_info['parent_id'], $accountinfo['id']); |
|
150 | + $str = rtrim($str, ","); |
|
151 | + $account_result = (array)$this->db->get_where('accounts', "id IN (".$str.")")->result_array(); |
|
152 | + foreach ($account_result as $key=>$acc_row) { |
|
153 | + $acc_row['did_number'] = $did_info['number']; |
|
154 | 154 | $this->common->mail_to_users('email_remove_did', $acc_row); |
155 | 155 | } |
156 | 156 | } |
157 | - if($accountinfo['type'] == -1){ |
|
158 | - $update_array = array('parent_id' => 0, 'accountid' => 0, 'assign_date' => '0000-00-00 00:00:00', "charge_upto" => "0000-00-00 00:00:00","last_modified_date"=>gmdate("Y-m-d H:i:s"),'call_type'=>'-1','extensions'=>''); |
|
157 | + if ($accountinfo['type'] == -1) { |
|
158 | + $update_array = array('parent_id' => 0, 'accountid' => 0, 'assign_date' => '0000-00-00 00:00:00', "charge_upto" => "0000-00-00 00:00:00", "last_modified_date"=>gmdate("Y-m-d H:i:s"), 'call_type'=>'-1', 'extensions'=>''); |
|
159 | 159 | $where = array('id' => $id); |
160 | 160 | $this->db->where($where); |
161 | 161 | $this->db->update('dids', $update_array); |
162 | - if($did_info['parent_id'] > 0){ |
|
163 | - $this->db->where('note',$did_info['number']); |
|
162 | + if ($did_info['parent_id'] > 0) { |
|
163 | + $this->db->where('note', $did_info['number']); |
|
164 | 164 | $this->db->delete("reseller_pricing"); |
165 | 165 | } |
166 | - }else{ |
|
167 | - $reseller_ids=$this->common->get_subreseller_info($accountinfo['id']); |
|
168 | - $reseller_ids=rtrim($reseller_ids,","); |
|
169 | - $where="parent_id IN ($reseller_ids)"; |
|
170 | - $this->db->where('note',$did_info['number']); |
|
171 | - $this->db->delete('reseller_pricing',$where); |
|
166 | + } else { |
|
167 | + $reseller_ids = $this->common->get_subreseller_info($accountinfo['id']); |
|
168 | + $reseller_ids = rtrim($reseller_ids, ","); |
|
169 | + $where = "parent_id IN ($reseller_ids)"; |
|
170 | + $this->db->where('note', $did_info['number']); |
|
171 | + $this->db->delete('reseller_pricing', $where); |
|
172 | 172 | } |
173 | - if($accountinfo['type']==1){ |
|
174 | - $update_array = array('parent_id' => $accountinfo['id'], 'accountid' => 0, 'assign_date' => '0000-00-00 00:00:00', "charge_upto" => "0000-00-00 00:00:00","last_modified_date"=>gmdate("Y-m-d H:i:s"),'call_type'=>'-1','extensions'=>''); |
|
175 | - }else{ |
|
176 | - $update_array = array('parent_id' => 0, 'accountid' => 0, 'assign_date' => '0000-00-00 00:00:00', "charge_upto" => "0000-00-00 00:00:00","last_modified_date"=>gmdate("Y-m-d H:i:s"),'call_type'=>'-1','extensions'=>''); |
|
173 | + if ($accountinfo['type'] == 1) { |
|
174 | + $update_array = array('parent_id' => $accountinfo['id'], 'accountid' => 0, 'assign_date' => '0000-00-00 00:00:00', "charge_upto" => "0000-00-00 00:00:00", "last_modified_date"=>gmdate("Y-m-d H:i:s"), 'call_type'=>'-1', 'extensions'=>''); |
|
175 | + } else { |
|
176 | + $update_array = array('parent_id' => 0, 'accountid' => 0, 'assign_date' => '0000-00-00 00:00:00', "charge_upto" => "0000-00-00 00:00:00", "last_modified_date"=>gmdate("Y-m-d H:i:s"), 'call_type'=>'-1', 'extensions'=>''); |
|
177 | 177 | } |
178 | 178 | $where = array('id' => $id); |
179 | 179 | $this->db->where($where); |
180 | 180 | $this->db->update('dids', $update_array); |
181 | - $accountid=$did_info['accountid'] > 0 ? $did_info['accountid']:0; |
|
182 | - if($did_info['accountid'] > 0 ){ |
|
183 | - $email_user_id=$did_info['accountid']; |
|
184 | - }elseif($did_info['parent_id'] > 0){ |
|
185 | - $email_user_id=$did_info['parent_id']; |
|
181 | + $accountid = $did_info['accountid'] > 0 ? $did_info['accountid'] : 0; |
|
182 | + if ($did_info['accountid'] > 0) { |
|
183 | + $email_user_id = $did_info['accountid']; |
|
184 | + }elseif ($did_info['parent_id'] > 0) { |
|
185 | + $email_user_id = $did_info['parent_id']; |
|
186 | 186 | } |
187 | - $accountinfo=(array)$this->db->get_where('accounts',array("id"=>$email_user_id))->first_row(); |
|
187 | + $accountinfo = (array)$this->db->get_where('accounts', array("id"=>$email_user_id))->first_row(); |
|
188 | 188 | $accountinfo['did_number'] = $did_info['number']; |
189 | 189 | $this->common->mail_to_users('email_remove_did', $accountinfo); |
190 | 190 | $this->session->set_flashdata('astpp_errormsg', 'DID Released Successfully!'); |
191 | - redirect(base_url() . 'did/did_list/'); |
|
191 | + redirect(base_url().'did/did_list/'); |
|
192 | 192 | } |
193 | 193 | |
194 | 194 | function did_list() { |
@@ -204,33 +204,33 @@ discard block |
||
204 | 204 | } |
205 | 205 | |
206 | 206 | if ($this->session->userdata['userlevel_logintype'] == '1') { |
207 | - $drp_list=array(); |
|
207 | + $drp_list = array(); |
|
208 | 208 | $accountinfo = $this->session->userdata('accountinfo'); |
209 | - if($accountinfo['reseller_id'] > 0){ |
|
210 | - $dids_array=$this->db->query("SELECT a.id AS id,a.number as number, b.monthlycost, b.setup FROM dids AS a, reseller_pricing AS b WHERE a.number = b.note AND b.reseller_id = ".$accountinfo['reseller_id']." AND a.parent_id =".$accountinfo['reseller_id'])->result_array(); |
|
211 | - }else{ |
|
209 | + if ($accountinfo['reseller_id'] > 0) { |
|
210 | + $dids_array = $this->db->query("SELECT a.id AS id,a.number as number, b.monthlycost, b.setup FROM dids AS a, reseller_pricing AS b WHERE a.number = b.note AND b.reseller_id = ".$accountinfo['reseller_id']." AND a.parent_id =".$accountinfo['reseller_id'])->result_array(); |
|
211 | + } else { |
|
212 | 212 | $this->db->select('id,monthlycost,setup,number'); |
213 | - $this->db->where('accountid',0); |
|
214 | - $this->db->where('parent_id',0); |
|
215 | - $dids_array=$this->db->get('dids')->result_array(); |
|
213 | + $this->db->where('accountid', 0); |
|
214 | + $this->db->where('parent_id', 0); |
|
215 | + $dids_array = $this->db->get('dids')->result_array(); |
|
216 | 216 | } |
217 | - if(!empty($dids_array)){ |
|
217 | + if ( ! empty($dids_array)) { |
|
218 | 218 | foreach ($dids_array as $drp_value) { |
219 | - if (!empty($drp_value['monthlycost']) && $drp_value['monthlycost'] != 0) { |
|
219 | + if ( ! empty($drp_value['monthlycost']) && $drp_value['monthlycost'] != 0) { |
|
220 | 220 | $did_cost = $this->common_model->to_calculate_currency($drp_value['monthlycost'], '', '', true, false); |
221 | 221 | } else { |
222 | 222 | $did_cost = 0; |
223 | 223 | } |
224 | - if (!empty($drp_value['setup']) && $drp_value['setup'] != 0) { |
|
224 | + if ( ! empty($drp_value['setup']) && $drp_value['setup'] != 0) { |
|
225 | 225 | $did_setup = $this->common_model->to_calculate_currency($drp_value['setup'], '', '', true, false); |
226 | 226 | } else { |
227 | 227 | $did_setup = 0; |
228 | 228 | } |
229 | - $drp_list[$drp_value['id']] = $drp_value['number'] . ' ( Setup : ' . $did_setup . ')' . '( Monthly : ' . $did_cost . ' )'; |
|
229 | + $drp_list[$drp_value['id']] = $drp_value['number'].' ( Setup : '.$did_setup.')'.'( Monthly : '.$did_cost.' )'; |
|
230 | 230 | /* * ********************************************************************************************* */ |
231 | 231 | } |
232 | 232 | } |
233 | - $data['didlist'] = form_dropdown_all(array("name"=>"free_did_list","id"=>"free_did_list","class"=>"did_dropdown"), $drp_list, ''); |
|
233 | + $data['didlist'] = form_dropdown_all(array("name"=>"free_did_list", "id"=>"free_did_list", "class"=>"did_dropdown"), $drp_list, ''); |
|
234 | 234 | } |
235 | 235 | if ($this->session->userdata['userlevel_logintype'] == '1') { |
236 | 236 | $data['grid_fields'] = $this->did_form->build_did_list_for_reseller_login(); |
@@ -270,7 +270,7 @@ discard block |
||
270 | 270 | $this->session->set_userdata('did_list_search', $action); |
271 | 271 | } |
272 | 272 | if (@$ajax_search != 1) { |
273 | - redirect(base_url() . 'did/did_list/'); |
|
273 | + redirect(base_url().'did/did_list/'); |
|
274 | 274 | } |
275 | 275 | } |
276 | 276 | |
@@ -318,10 +318,10 @@ discard block |
||
318 | 318 | */ |
319 | 319 | function customer_did($accountid, $accounttype) { |
320 | 320 | $json_data = array(); |
321 | - $instant_search=$this->session->userdata('left_panel_search_'.$accounttype.'_did'); |
|
322 | - $account_arr=(array)$this->db->get_where('accounts',array("id"=>$accountid))->first_row(); |
|
321 | + $instant_search = $this->session->userdata('left_panel_search_'.$accounttype.'_did'); |
|
322 | + $account_arr = (array)$this->db->get_where('accounts', array("id"=>$accountid))->first_row(); |
|
323 | 323 | $field_name = $accounttype == "reseller" ? "parent_id" : 'accountid'; |
324 | - $like_str=!empty($instant_search) ? |
|
324 | + $like_str = ! empty($instant_search) ? |
|
325 | 325 | "(a.note like '%$instant_search%' |
326 | 326 | OR a.init_inc like '%$instant_search%' |
327 | 327 | OR a.inc like '%$instant_search%' |
@@ -330,32 +330,32 @@ discard block |
||
330 | 330 | OR a.setup like '%$instant_search%' |
331 | 331 | OR a.monthlycost like '%$instant_search%' |
332 | 332 | OR a.connectcost like '%$instant_search%' |
333 | - )" :null; |
|
333 | + )" : null; |
|
334 | 334 | if ($account_arr['reseller_id'] != 0) { |
335 | - if(!empty($like_str)) |
|
335 | + if ( ! empty($like_str)) |
|
336 | 336 | $this->db->where($like_str); |
337 | - if($accounttype=='reseller'){ |
|
338 | - $this->db->where('a.note','b.number',false); |
|
339 | - $this->db->where('a.reseller_id',$account_arr['id']); |
|
340 | - $this->db->where('a.parent_id',$account_arr['reseller_id']); |
|
337 | + if ($accounttype == 'reseller') { |
|
338 | + $this->db->where('a.note', 'b.number', false); |
|
339 | + $this->db->where('a.reseller_id', $account_arr['id']); |
|
340 | + $this->db->where('a.parent_id', $account_arr['reseller_id']); |
|
341 | 341 | $this->db->select('count(a.id) as count'); |
342 | - $count_result=(array)$this->db->get('reseller_pricing as a,dids as b')->first_row(); |
|
342 | + $count_result = (array)$this->db->get('reseller_pricing as a,dids as b')->first_row(); |
|
343 | 343 | $paging_data = $this->form->load_grid_config($count_result['count'], $_GET['rp'], $_GET['page']); |
344 | 344 | $json_data = $paging_data["json_paging"]; |
345 | - $this->db->where('a.note','b.number',false); |
|
346 | - $this->db->where('a.reseller_id',$account_arr['id']); |
|
347 | - $this->db->where('a.parent_id',$account_arr['reseller_id']); |
|
345 | + $this->db->where('a.note', 'b.number', false); |
|
346 | + $this->db->where('a.reseller_id', $account_arr['id']); |
|
347 | + $this->db->where('a.parent_id', $account_arr['reseller_id']); |
|
348 | 348 | $this->db->select('a . * , b.id, a.reseller_id AS accountid,a.note as number,b.country_id as country_id'); |
349 | - $this->db->limit($paging_data["paging"]["page_no"],$paging_data["paging"]["start"]); |
|
350 | - $query=$this->db->get('reseller_pricing as a,dids as b'); |
|
351 | - }else{ |
|
352 | - $count_result=(array)$this->db->query('select count(id) as count from dids where accountid='.$accountid." AND parent_id =".$account_arr['reseller_id'])->first_row(); |
|
349 | + $this->db->limit($paging_data["paging"]["page_no"], $paging_data["paging"]["start"]); |
|
350 | + $query = $this->db->get('reseller_pricing as a,dids as b'); |
|
351 | + } else { |
|
352 | + $count_result = (array)$this->db->query('select count(id) as count from dids where accountid='.$accountid." AND parent_id =".$account_arr['reseller_id'])->first_row(); |
|
353 | 353 | $paging_data = $this->form->load_grid_config($count_result['count'], $_GET['rp'], $_GET['page']); |
354 | 354 | $json_data = $paging_data["json_paging"]; |
355 | - $query=$this->db->query("SELECT a . * ,a.note as number,b.country_id as country_id,b.id FROM reseller_pricing AS a, dids AS b WHERE b.accountid =".$account_arr['id']." AND a.note = b.number AND a.reseller_id =".$account_arr['reseller_id']); |
|
355 | + $query = $this->db->query("SELECT a . * ,a.note as number,b.country_id as country_id,b.id FROM reseller_pricing AS a, dids AS b WHERE b.accountid =".$account_arr['id']." AND a.note = b.number AND a.reseller_id =".$account_arr['reseller_id']); |
|
356 | 356 | } |
357 | - }else{ |
|
358 | - $like_str=!empty($instant_search) ? |
|
357 | + } else { |
|
358 | + $like_str = ! empty($instant_search) ? |
|
359 | 359 | "(dids.number like '%$instant_search%' |
360 | 360 | OR dids.inc like '%$instant_search%' |
361 | 361 | OR dids.cost like '%$instant_search%' |
@@ -363,14 +363,14 @@ discard block |
||
363 | 363 | OR dids.setup like '%$instant_search%' |
364 | 364 | OR dids.monthlycost like '%$instant_search%' |
365 | 365 | OR dids.connectcost like '%$instant_search%' |
366 | - )" :null; |
|
367 | - if(!empty($like_str)) |
|
366 | + )" : null; |
|
367 | + if ( ! empty($like_str)) |
|
368 | 368 | $this->db->where($like_str); |
369 | 369 | $where = array($field_name => $accountid); |
370 | 370 | $count_all = $this->db_model->countQuery("*", "dids", $where); |
371 | 371 | $paging_data = $this->form->load_grid_config($count_all, $_GET['rp'], $_GET['page']); |
372 | 372 | $json_data = $paging_data["json_paging"]; |
373 | - if(!empty($like_str)) |
|
373 | + if ( ! empty($like_str)) |
|
374 | 374 | $this->db->where($like_str); |
375 | 375 | $query = $this->db_model->select("*", "dids", $where, "id", "ASC", $paging_data["paging"]["page_no"], $paging_data["paging"]["start"]); |
376 | 376 | } |
@@ -382,9 +382,9 @@ discard block |
||
382 | 382 | $ids = $this->input->post("selected_ids", true); |
383 | 383 | $where = "id IN ($ids)"; |
384 | 384 | $this->db->where($where); |
385 | - $this->db->select("group_concat(concat('''',number,'''')) as number",false); |
|
386 | - $dids_result=(array)$this->db->get('dids')->first_row(); |
|
387 | - $notes_where="note IN (".$dids_result['number'].")"; |
|
385 | + $this->db->select("group_concat(concat('''',number,'''')) as number", false); |
|
386 | + $dids_result = (array)$this->db->get('dids')->first_row(); |
|
387 | + $notes_where = "note IN (".$dids_result['number'].")"; |
|
388 | 388 | $this->db->where($notes_where); |
389 | 389 | $this->db->delete('reseller_pricing'); |
390 | 390 | $this->db->where($where); |
@@ -398,7 +398,7 @@ discard block |
||
398 | 398 | */ |
399 | 399 | function did_reseller_edit($action = false, $id = false) { |
400 | 400 | $data['page_title'] = 'Edit DID '; |
401 | - $accountinfo=$this->session->userdata('accountinfo'); |
|
401 | + $accountinfo = $this->session->userdata('accountinfo'); |
|
402 | 402 | if ($action == 'edit') { |
403 | 403 | if (($this->input->post())) { |
404 | 404 | $post = $this->input->post(); |
@@ -427,7 +427,7 @@ discard block |
||
427 | 427 | $accountinfo = $this->did_model->get_account($accountinfo['number']); |
428 | 428 | $reseller_did = $this->db_model->getSelect("*", "reseller_pricing", array('id' => $id)); |
429 | 429 | $reseller_didinfo = (array)$reseller_did->first_row(); |
430 | - if (!empty($reseller_didinfo)) { |
|
430 | + if ( ! empty($reseller_didinfo)) { |
|
431 | 431 | $reseller_didinfo['setup'] = $this->common_model->to_calculate_currency($reseller_didinfo['setup'], '', '', true, false); |
432 | 432 | $reseller_didinfo['monthlycost'] = $this->common_model->to_calculate_currency($reseller_didinfo['monthlycost'], '', '', true, false); |
433 | 433 | $reseller_didinfo['connectcost'] = $this->common_model->to_calculate_currency($reseller_didinfo['connectcost'], '', '', true, false); |
@@ -441,43 +441,43 @@ discard block |
||
441 | 441 | } |
442 | 442 | } |
443 | 443 | if ($action == 'delete') { |
444 | - $this->db->where('id',$id); |
|
444 | + $this->db->where('id', $id); |
|
445 | 445 | $this->db->select('note'); |
446 | - $reseller_pricing=(array)$this->db->get('reseller_pricing')->first_row(); |
|
447 | - $did_number=$reseller_pricing['note']; |
|
448 | - $did_info=(array)$this->db->get_where('dids',array('number'=>$did_number))->first_row(); |
|
449 | - $query="select count(id) as count from reseller_pricing where id >= (select id from reseller_pricing where note =$did_number AND parent_id =".$accountinfo['reseller_id']." AND reseller_id =".$accountinfo['id'].") AND note= $did_number order by id desc"; |
|
450 | - $result=(array)$this->db->query($query)->first_row(); |
|
451 | - if($result['count'] > 0){ |
|
452 | - $str=$this->common->get_parent_info($did_info['parent_id'],$accountinfo['id']); |
|
453 | - $str=rtrim($str,","); |
|
454 | - $account_result=(array)$this->db->get_where('accounts',"id IN (".$str.")")->result_array(); |
|
455 | - foreach($account_result as $key=>$acc_row){ |
|
456 | - $acc_row['did_number']=$did_info['number']; |
|
446 | + $reseller_pricing = (array)$this->db->get('reseller_pricing')->first_row(); |
|
447 | + $did_number = $reseller_pricing['note']; |
|
448 | + $did_info = (array)$this->db->get_where('dids', array('number'=>$did_number))->first_row(); |
|
449 | + $query = "select count(id) as count from reseller_pricing where id >= (select id from reseller_pricing where note =$did_number AND parent_id =".$accountinfo['reseller_id']." AND reseller_id =".$accountinfo['id'].") AND note= $did_number order by id desc"; |
|
450 | + $result = (array)$this->db->query($query)->first_row(); |
|
451 | + if ($result['count'] > 0) { |
|
452 | + $str = $this->common->get_parent_info($did_info['parent_id'], $accountinfo['id']); |
|
453 | + $str = rtrim($str, ","); |
|
454 | + $account_result = (array)$this->db->get_where('accounts', "id IN (".$str.")")->result_array(); |
|
455 | + foreach ($account_result as $key=>$acc_row) { |
|
456 | + $acc_row['did_number'] = $did_info['number']; |
|
457 | 457 | $this->common->mail_to_users('email_remove_did', $acc_row); |
458 | 458 | } |
459 | - $reseller_ids=$this->common->get_subreseller_info($accountinfo['id']); |
|
460 | - $reseller_ids=rtrim($reseller_ids,","); |
|
461 | - $where="parent_id IN ($reseller_ids)"; |
|
462 | - $this->db->where('note',$did_info['number']); |
|
463 | - $this->db->delete('reseller_pricing',$where); |
|
464 | - $this->db->where('reseller_id',$accountinfo['id']); |
|
465 | - $this->db->where('note',$did_info['number']); |
|
459 | + $reseller_ids = $this->common->get_subreseller_info($accountinfo['id']); |
|
460 | + $reseller_ids = rtrim($reseller_ids, ","); |
|
461 | + $where = "parent_id IN ($reseller_ids)"; |
|
462 | + $this->db->where('note', $did_info['number']); |
|
463 | + $this->db->delete('reseller_pricing', $where); |
|
464 | + $this->db->where('reseller_id', $accountinfo['id']); |
|
465 | + $this->db->where('note', $did_info['number']); |
|
466 | 466 | $this->db->delete('reseller_pricing'); |
467 | 467 | } |
468 | - $this->db->where('number',$did_number); |
|
468 | + $this->db->where('number', $did_number); |
|
469 | 469 | $this->db->select('accountid'); |
470 | - $did_array=(array)$this->db->get('dids')->first_row(); |
|
471 | - if($did_array['accountid'] > 0){ |
|
472 | - $customer_info=(array)$this->db->get_where('accounts',array('id'=>$did_array['accountid']))->first_row(); |
|
473 | - $customer_info['did_number']=$did_number; |
|
470 | + $did_array = (array)$this->db->get('dids')->first_row(); |
|
471 | + if ($did_array['accountid'] > 0) { |
|
472 | + $customer_info = (array)$this->db->get_where('accounts', array('id'=>$did_array['accountid']))->first_row(); |
|
473 | + $customer_info['did_number'] = $did_number; |
|
474 | 474 | $this->common->mail_to_users('email_remove_did', $customer_info); |
475 | 475 | } |
476 | - $did_array=array("accountid"=>0,"parent_id"=>$accountinfo['reseller_id'], "assign_date" => "0000-00-00 00:00:00", "charge_upto" => "0000-00-00 00:00:00"); |
|
477 | - $this->db->where('number',$did_number); |
|
478 | - $this->db->update('dids',$did_array); |
|
476 | + $did_array = array("accountid"=>0, "parent_id"=>$accountinfo['reseller_id'], "assign_date" => "0000-00-00 00:00:00", "charge_upto" => "0000-00-00 00:00:00"); |
|
477 | + $this->db->where('number', $did_number); |
|
478 | + $this->db->update('dids', $did_array); |
|
479 | 479 | $this->session->set_flashdata('astpp_notification', 'DID Removed Successfully!'); |
480 | - redirect(base_url() . 'did/did_list/'); |
|
480 | + redirect(base_url().'did/did_list/'); |
|
481 | 481 | } |
482 | 482 | } |
483 | 483 | |
@@ -486,37 +486,37 @@ discard block |
||
486 | 486 | $accountinfo = $this->session->userdata('accountinfo'); |
487 | 487 | $where = array('id' => $accountinfo['id']); |
488 | 488 | $account = $this->db_model->getSelect("*", "accounts", $where); |
489 | - $currency_name=$this->common->get_field_name('currency',"currency",array('id'=>$accountinfo['currency_id'])); |
|
490 | - $accountinfo= (array)$account->first_row(); |
|
489 | + $currency_name = $this->common->get_field_name('currency', "currency", array('id'=>$accountinfo['currency_id'])); |
|
490 | + $accountinfo = (array)$account->first_row(); |
|
491 | 491 | if (($this->input->post())) { |
492 | 492 | $post = $this->input->post(); |
493 | 493 | if (isset($post['free_did_list']) && $post['free_did_list'] != '') { |
494 | 494 | // For deduction of admin price to reseller |
495 | 495 | $didinfo = $this->did_model->get_did_by_number($post['free_did_list']); |
496 | - if($accountinfo['reseller_id'] > 0 ){ |
|
497 | - $reseller_pricing_query = $this->db_model->getSelect("call_type,setup,extensions,monthlycost,connectcost,includedseconds,cost,inc", "reseller_pricing", array("note" => $didinfo['number'],'reseller_id'=>$accountinfo['reseller_id'])); |
|
496 | + if ($accountinfo['reseller_id'] > 0) { |
|
497 | + $reseller_pricing_query = $this->db_model->getSelect("call_type,setup,extensions,monthlycost,connectcost,includedseconds,cost,inc", "reseller_pricing", array("note" => $didinfo['number'], 'reseller_id'=>$accountinfo['reseller_id'])); |
|
498 | 498 | $reseller_pricing_result = (array)$reseller_pricing_query->first_row(); |
499 | - $didinfo['call_type']=$reseller_pricing_result['call_type']; |
|
500 | - $didinfo['extensions']=$reseller_pricing_result['extensions']; |
|
501 | - $didinfo['setup']=$reseller_pricing_result['setup']; |
|
502 | - $didinfo['monthlycost']=$reseller_pricing_result['monthlycost']; |
|
503 | - $didinfo['connectcost']=$reseller_pricing_result['connectcost']; |
|
504 | - $didinfo['includedseconds']=$reseller_pricing_result['includedseconds']; |
|
505 | - $didinfo['cost']=$reseller_pricing_result['cost']; |
|
506 | - $didinfo['inc']=$reseller_pricing_result['inc']; |
|
499 | + $didinfo['call_type'] = $reseller_pricing_result['call_type']; |
|
500 | + $didinfo['extensions'] = $reseller_pricing_result['extensions']; |
|
501 | + $didinfo['setup'] = $reseller_pricing_result['setup']; |
|
502 | + $didinfo['monthlycost'] = $reseller_pricing_result['monthlycost']; |
|
503 | + $didinfo['connectcost'] = $reseller_pricing_result['connectcost']; |
|
504 | + $didinfo['includedseconds'] = $reseller_pricing_result['includedseconds']; |
|
505 | + $didinfo['cost'] = $reseller_pricing_result['cost']; |
|
506 | + $didinfo['inc'] = $reseller_pricing_result['inc']; |
|
507 | 507 | } |
508 | 508 | $available_bal = $this->db_model->get_available_bal($accountinfo); |
509 | 509 | $accountinfo['did_number'] = $didinfo['number']; |
510 | 510 | $accountinfo['did_country_id'] = $didinfo['country_id']; |
511 | - $accountinfo['did_setup'] = $this->common_model->calculate_currency($didinfo['setup'],'',$currency_name,true,true); |
|
512 | - $accountinfo['did_monthlycost'] = $this->common_model->calculate_currency($didinfo['monthlycost'],'',$currency_name,true,true); |
|
511 | + $accountinfo['did_setup'] = $this->common_model->calculate_currency($didinfo['setup'], '', $currency_name, true, true); |
|
512 | + $accountinfo['did_monthlycost'] = $this->common_model->calculate_currency($didinfo['monthlycost'], '', $currency_name, true, true); |
|
513 | 513 | $accountinfo['did_maxchannels'] = $didinfo['maxchannels']; |
514 | 514 | if ($available_bal >= $didinfo["setup"]) { |
515 | 515 | $available_bal = $this->db_model->update_balance($didinfo['setup'], $accountinfo['id'], "debit"); |
516 | - $this->db_model->update("dids", array('parent_id' => $accountinfo['id'],"assign_date"=>gmdate("Y-m-d H:i:s")), array("id" => $didinfo['id'])); |
|
516 | + $this->db_model->update("dids", array('parent_id' => $accountinfo['id'], "assign_date"=>gmdate("Y-m-d H:i:s")), array("id" => $didinfo['id'])); |
|
517 | 517 | $this->did_model->insert_reseller_pricing($accountinfo, $didinfo); |
518 | - $this->common->add_invoice_details($accountinfo,"DIDCHRG",$didinfo['setup'],$didinfo['number']); |
|
519 | - $this->common->mail_to_users('email_add_did', $accountinfo,"",$didinfo['number']); |
|
518 | + $this->common->add_invoice_details($accountinfo, "DIDCHRG", $didinfo['setup'], $didinfo['number']); |
|
519 | + $this->common->mail_to_users('email_add_did', $accountinfo, "", $didinfo['number']); |
|
520 | 520 | $this->session->set_flashdata('astpp_errormsg', 'DID Purchased Successfully.'); |
521 | 521 | } else { |
522 | 522 | $this->session->set_flashdata('astpp_notification', 'Insuffiecient fund to purchase this did'); |
@@ -525,7 +525,7 @@ discard block |
||
525 | 525 | $this->session->set_flashdata('astpp_notification', 'Please Select DID.'); |
526 | 526 | } |
527 | 527 | } |
528 | - redirect(base_url() . 'did/did_list/'); |
|
528 | + redirect(base_url().'did/did_list/'); |
|
529 | 529 | exit; |
530 | 530 | } |
531 | 531 | |
@@ -547,8 +547,8 @@ discard block |
||
547 | 547 | |
548 | 548 | function did_download_sample_file($file_name) { |
549 | 549 | $this->load->helper('download'); |
550 | - $full_path = base_url() . "assets/Rates_File/" . $file_name . ".csv"; |
|
551 | - $arrContextOptions=array( |
|
550 | + $full_path = base_url()."assets/Rates_File/".$file_name.".csv"; |
|
551 | + $arrContextOptions = array( |
|
552 | 552 | "ssl"=>array( |
553 | 553 | "verify_peer"=>false, |
554 | 554 | "verify_peer_name"=>false, |
@@ -567,28 +567,28 @@ discard block |
||
567 | 567 | $this->session->set_userdata('import_did_rate_csv', ""); |
568 | 568 | $error_data = $this->session->userdata('import_did_csv_error'); |
569 | 569 | $full_path = $this->config->item('rates-file-path'); |
570 | - if (file_exists($full_path . $error_data) && $error_data != "") { |
|
571 | - unlink($full_path . $error_data); |
|
570 | + if (file_exists($full_path.$error_data) && $error_data != "") { |
|
571 | + unlink($full_path.$error_data); |
|
572 | 572 | $this->session->set_userdata('import_did_csv_error', ""); |
573 | 573 | } |
574 | - $accountinfo=$this->session->userdata('accountinfo'); |
|
575 | - $this->db->where('id',$accountinfo['currency_id']); |
|
574 | + $accountinfo = $this->session->userdata('accountinfo'); |
|
575 | + $this->db->where('id', $accountinfo['currency_id']); |
|
576 | 576 | $this->db->select('currency'); |
577 | - $currency_info=(array)$this->db->get('currency')->first_row(); |
|
578 | - $data['fields']="DID,Country,Account,Per Minute Cost(".$currency_info['currency']."),Initial Increment,Increment,Setup Fee(".$currency_info['currency']."),Monthly Fee(".$currency_info['currency']."),Call Type,Destination,Status"; |
|
577 | + $currency_info = (array)$this->db->get('currency')->first_row(); |
|
578 | + $data['fields'] = "DID,Country,Account,Per Minute Cost(".$currency_info['currency']."),Initial Increment,Increment,Setup Fee(".$currency_info['currency']."),Monthly Fee(".$currency_info['currency']."),Call Type,Destination,Status"; |
|
579 | 579 | $this->load->view('view_import_did', $data); |
580 | 580 | } |
581 | 581 | |
582 | 582 | function did_preview_file() { |
583 | 583 | $data['page_title'] = 'Import DIDs'; |
584 | 584 | $config_did_array = $this->config->item('DID-rates-field'); |
585 | - $accountinfo=$this->session->userdata('accountinfo'); |
|
586 | - $this->db->where('id',$accountinfo['currency_id']); |
|
585 | + $accountinfo = $this->session->userdata('accountinfo'); |
|
586 | + $this->db->where('id', $accountinfo['currency_id']); |
|
587 | 587 | $this->db->select('currency'); |
588 | - $currency_info=(array)$this->db->get('currency')->first_row(); |
|
589 | - foreach($config_did_array as $key=>$value){ |
|
588 | + $currency_info = (array)$this->db->get('currency')->first_row(); |
|
589 | + foreach ($config_did_array as $key=>$value) { |
|
590 | 590 | $key = str_replace('CURRENCY', $currency_info['currency'], $key); |
591 | - $did_fields_array[$key]=$value; |
|
591 | + $did_fields_array[$key] = $value; |
|
592 | 592 | } |
593 | 593 | $check_header = $this->input->post('check_header', true); |
594 | 594 | $invalid_flag = false; |
@@ -599,10 +599,10 @@ discard block |
||
599 | 599 | if ($error == 0) { |
600 | 600 | $uploadedFile = $_FILES["didimport"]["tmp_name"]; |
601 | 601 | $full_path = $this->config->item('rates-file-path'); |
602 | - $actual_file_name = "ASTPP-DIDs-" . date("Y-m-d H:i:s") . "." . $ext; |
|
603 | - if (move_uploaded_file($uploadedFile, $full_path . $actual_file_name)) { |
|
602 | + $actual_file_name = "ASTPP-DIDs-".date("Y-m-d H:i:s").".".$ext; |
|
603 | + if (move_uploaded_file($uploadedFile, $full_path.$actual_file_name)) { |
|
604 | 604 | $data['page_title'] = 'Import DIDs Preview'; |
605 | - $data['csv_tmp_data'] = $this->csvreader->parse_file($full_path . $actual_file_name, $did_fields_array, $check_header); |
|
605 | + $data['csv_tmp_data'] = $this->csvreader->parse_file($full_path.$actual_file_name, $did_fields_array, $check_header); |
|
606 | 606 | $data['provider_id'] = $_POST['provider_id']; |
607 | 607 | $data['check_header'] = $check_header; |
608 | 608 | $this->session->set_userdata('import_did_rate_csv', $actual_file_name); |
@@ -619,7 +619,7 @@ discard block |
||
619 | 619 | if ($invalid_flag) { |
620 | 620 | $str = ''; |
621 | 621 | if (empty($_FILES['didimport']['name'])) { |
622 | - $str.= '<br/>Please Select File.'; |
|
622 | + $str .= '<br/>Please Select File.'; |
|
623 | 623 | } |
624 | 624 | $data['error'] = $str; |
625 | 625 | } |
@@ -630,32 +630,32 @@ discard block |
||
630 | 630 | $new_final_arr = array(); |
631 | 631 | $invalid_array = array(); |
632 | 632 | $new_final_arr_key = $this->config->item('DID-rates-field'); |
633 | - $accountinfo=$this->session->userdata('accountinfo'); |
|
634 | - $reseller_id = $accountinfo['type']==1 ? $accountinfo['id']: 0; |
|
633 | + $accountinfo = $this->session->userdata('accountinfo'); |
|
634 | + $reseller_id = $accountinfo['type'] == 1 ? $accountinfo['id'] : 0; |
|
635 | 635 | |
636 | 636 | $full_path = $this->config->item('rates-file-path'); |
637 | 637 | $did_file_name = $this->session->userdata('import_did_rate_csv'); |
638 | - $csv_tmp_data = $this->csvreader->parse_file($full_path . $did_file_name, $new_final_arr_key, $check_header); |
|
638 | + $csv_tmp_data = $this->csvreader->parse_file($full_path.$did_file_name, $new_final_arr_key, $check_header); |
|
639 | 639 | $flag = false; |
640 | 640 | $i = 0; |
641 | 641 | $number_arr = array(); |
642 | - $reseller_array=array(); |
|
643 | - $final_reseller_array=array(); |
|
642 | + $reseller_array = array(); |
|
643 | + $final_reseller_array = array(); |
|
644 | 644 | foreach ($csv_tmp_data as $key => $csv_data) { |
645 | 645 | |
646 | 646 | if (isset($csv_data['number']) && $csv_data['number'] != '' && $i != 0) { |
647 | 647 | $str = null; |
648 | - if(isset($csv_data['call_type'])){ |
|
649 | - if(strtolower($csv_data['call_type']) == 'sip-did'){ |
|
648 | + if (isset($csv_data['call_type'])) { |
|
649 | + if (strtolower($csv_data['call_type']) == 'sip-did') { |
|
650 | 650 | $call_type = '3'; |
651 | - } else if(strtolower($csv_data['call_type']) == 'did-local'){ |
|
651 | + } else if (strtolower($csv_data['call_type']) == 'did-local') { |
|
652 | 652 | $call_type = '1'; |
653 | - } else if(strtolower($csv_data['call_type']) == 'other'){ |
|
653 | + } else if (strtolower($csv_data['call_type']) == 'other') { |
|
654 | 654 | $call_type = '2'; |
655 | 655 | } else { |
656 | 656 | $call_type = '0'; |
657 | 657 | } |
658 | - } else{ |
|
658 | + } else { |
|
659 | 659 | $call_type = '0'; |
660 | 660 | } |
661 | 661 | $csv_data['accountid'] = isset($csv_data['accountid']) ? $csv_data['accountid'] : 0; |
@@ -664,77 +664,77 @@ discard block |
||
664 | 664 | $csv_data['call_type'] = $call_type; |
665 | 665 | $csv_data['extensions'] = isset($csv_data['extensions']) ? $csv_data['extensions'] : ''; |
666 | 666 | $csv_data['includedseconds'] = isset($csv_data['includedseconds']) ? $csv_data['includedseconds'] : 0; |
667 | - $csv_data['cost'] = !empty($csv_data['cost']) && is_numeric($csv_data['cost']) && $csv_data['cost'] ? $csv_data['cost'] : 0; |
|
668 | - $csv_data['setup'] = !empty($csv_data['setup']) && is_numeric($csv_data['setup']) && $csv_data['setup'] > 0 ? $csv_data['setup'] : 0; |
|
669 | - $csv_data['monthlycost'] = !empty($csv_data['monthlycost']) && is_numeric($csv_data['monthlycost']) && $csv_data['monthlycost'] > 0 ? $csv_data['monthlycost'] : 0; |
|
670 | - $csv_data['connectcost'] = !empty($csv_data['connectcost']) && is_numeric($csv_data['connectcost']) && $csv_data['connectcost'] > 0 ? $csv_data['connectcost'] : 0; |
|
667 | + $csv_data['cost'] = ! empty($csv_data['cost']) && is_numeric($csv_data['cost']) && $csv_data['cost'] ? $csv_data['cost'] : 0; |
|
668 | + $csv_data['setup'] = ! empty($csv_data['setup']) && is_numeric($csv_data['setup']) && $csv_data['setup'] > 0 ? $csv_data['setup'] : 0; |
|
669 | + $csv_data['monthlycost'] = ! empty($csv_data['monthlycost']) && is_numeric($csv_data['monthlycost']) && $csv_data['monthlycost'] > 0 ? $csv_data['monthlycost'] : 0; |
|
670 | + $csv_data['connectcost'] = ! empty($csv_data['connectcost']) && is_numeric($csv_data['connectcost']) && $csv_data['connectcost'] > 0 ? $csv_data['connectcost'] : 0; |
|
671 | 671 | $csv_data['inc'] = isset($csv_data['inc']) ? $csv_data['inc'] : 0; |
672 | 672 | $str = $this->data_validate($csv_data); |
673 | 673 | if ($str != "") { |
674 | 674 | $invalid_array[$i] = $csv_data; |
675 | 675 | $invalid_array[$i]['error'] = $str; |
676 | 676 | } else { |
677 | - if (!in_array($csv_data['number'], $number_arr)) { |
|
677 | + if ( ! in_array($csv_data['number'], $number_arr)) { |
|
678 | 678 | $number_count = $this->db_model->countQuery('id', 'dids', array('number' => $csv_data['number'])); |
679 | 679 | if ($number_count > 0) { |
680 | 680 | $invalid_array[$i] = $csv_data; |
681 | 681 | $invalid_array[$i]['error'] = 'Duplicate DID found from database'; |
682 | 682 | } else { |
683 | - if($csv_data['accountid'] > 0 && $csv_data['setup'] > 0){ |
|
683 | + if ($csv_data['accountid'] > 0 && $csv_data['setup'] > 0) { |
|
684 | 684 | $this->db->where('type IN(0,1,3)'); |
685 | - $this->db->where('reseller_id',0); |
|
686 | - $this->db->where('deleted',0); |
|
687 | - $this->db->where('status',0); |
|
688 | - $account_info=(array)$this->db->get_where('accounts',array("number"=>$csv_data['accountid']))->first_row(); |
|
689 | - if($account_info){ |
|
690 | - $account_balance=$this->db_model->get_available_bal($account_info); |
|
685 | + $this->db->where('reseller_id', 0); |
|
686 | + $this->db->where('deleted', 0); |
|
687 | + $this->db->where('status', 0); |
|
688 | + $account_info = (array)$this->db->get_where('accounts', array("number"=>$csv_data['accountid']))->first_row(); |
|
689 | + if ($account_info) { |
|
690 | + $account_balance = $this->db_model->get_available_bal($account_info); |
|
691 | 691 | $setup = $this->common_model->add_calculate_currency($csv_data['setup'], '', '', false, false); |
692 | - if($account_balance >= $setup){ |
|
693 | - $field_name=$account_info['type']==1 ? 'parent_id':'accountid'; |
|
694 | - $currency_name=$this->common->get_field_name('currency',"currency",array('id'=>$account_info['currency_id'])); |
|
692 | + if ($account_balance >= $setup) { |
|
693 | + $field_name = $account_info['type'] == 1 ? 'parent_id' : 'accountid'; |
|
694 | + $currency_name = $this->common->get_field_name('currency', "currency", array('id'=>$account_info['currency_id'])); |
|
695 | 695 | $csv_data['monthlycost'] = $this->common_model->add_calculate_currency($csv_data['monthlycost'], '', '', false, false); |
696 | 696 | $csv_data['cost'] = $this->common_model->add_calculate_currency($csv_data['cost'], '', '', false, false); |
697 | 697 | $csv_data['connectcost'] = $this->common_model->add_calculate_currency($csv_data['connectcost'], '', '', false, false); |
698 | - $csv_data['setup']=$setup; |
|
699 | - $csv_data[$field_name]=$account_info['id']; |
|
700 | - $csv_data['status']=$this->common->get_import_status($csv_data['status']); |
|
701 | - $available_bal = $this->db_model->update_balance($csv_data["setup"],$account_info['id'], "debit"); |
|
698 | + $csv_data['setup'] = $setup; |
|
699 | + $csv_data[$field_name] = $account_info['id']; |
|
700 | + $csv_data['status'] = $this->common->get_import_status($csv_data['status']); |
|
701 | + $available_bal = $this->db_model->update_balance($csv_data["setup"], $account_info['id'], "debit"); |
|
702 | 702 | $account_info['did_number'] = $csv_data['number']; |
703 | 703 | $account_info['did_country_id'] = $csv_data['country_id']; |
704 | - $account_info['did_setup'] = $this->common_model->calculate_currency($csv_data['setup'],'',$currency_name,true,true); |
|
705 | - $account_info['did_monthlycost'] = $this->common_model->calculate_currency($csv_data['monthlycost'],'',$currency_name,true,true); |
|
704 | + $account_info['did_setup'] = $this->common_model->calculate_currency($csv_data['setup'], '', $currency_name, true, true); |
|
705 | + $account_info['did_monthlycost'] = $this->common_model->calculate_currency($csv_data['monthlycost'], '', $currency_name, true, true); |
|
706 | 706 | $account_info['did_maxchannels'] = "0"; |
707 | - $csv_data['country_id']=$this->common->get_field_name('id','countrycode',array("country"=>$csv_data['country_id'])); |
|
708 | - if($account_info['type']==1){ |
|
709 | - $reseller_array=$csv_data; |
|
710 | - $reseller_array['note']=$csv_data['number']; |
|
711 | - $reseller_array['reseller_id']=$account_info['id']; |
|
712 | - $reseller_array['parent_id']=$account_info['reseller_id']; |
|
713 | - $reseller_array['assign_date']=gmdate("Y-m-d H:i:s"); |
|
714 | - unset($reseller_array['number'],$csv_data['accountid'],$reseller_array['accountid'],$reseller_array['country_id'],$reseller_array['init_inc']); |
|
715 | - $csv_data['accountid']=0; |
|
716 | - $final_reseller_array[$i]=$reseller_array; |
|
717 | - }else{ |
|
718 | - $csv_data['parent_id']=0; |
|
707 | + $csv_data['country_id'] = $this->common->get_field_name('id', 'countrycode', array("country"=>$csv_data['country_id'])); |
|
708 | + if ($account_info['type'] == 1) { |
|
709 | + $reseller_array = $csv_data; |
|
710 | + $reseller_array['note'] = $csv_data['number']; |
|
711 | + $reseller_array['reseller_id'] = $account_info['id']; |
|
712 | + $reseller_array['parent_id'] = $account_info['reseller_id']; |
|
713 | + $reseller_array['assign_date'] = gmdate("Y-m-d H:i:s"); |
|
714 | + unset($reseller_array['number'], $csv_data['accountid'], $reseller_array['accountid'], $reseller_array['country_id'], $reseller_array['init_inc']); |
|
715 | + $csv_data['accountid'] = 0; |
|
716 | + $final_reseller_array[$i] = $reseller_array; |
|
717 | + } else { |
|
718 | + $csv_data['parent_id'] = 0; |
|
719 | 719 | } |
720 | - $csv_data['assign_date']=gmdate("Y-m-d H:i:s"); |
|
720 | + $csv_data['assign_date'] = gmdate("Y-m-d H:i:s"); |
|
721 | 721 | $new_final_arr[$i] = $csv_data; |
722 | 722 | $this->common->mail_to_users('email_add_did', $account_info); |
723 | - }else{ |
|
723 | + } else { |
|
724 | 724 | $invalid_array[$i] = $csv_data; |
725 | 725 | $invalid_array[$i]['error'] = 'Account have not sufficient amount to purchase this DID.'; |
726 | 726 | } |
727 | - }else{ |
|
727 | + } else { |
|
728 | 728 | $invalid_array[$i] = $csv_data; |
729 | 729 | $invalid_array[$i]['error'] = 'Account not found or assign to invalid account'; |
730 | 730 | } |
731 | - }else{ |
|
731 | + } else { |
|
732 | 732 | $csv_data['setup'] = $this->common_model->add_calculate_currency($csv_data['setup'], '', '', false, false); |
733 | 733 | $csv_data['monthlycost'] = $this->common_model->add_calculate_currency($csv_data['monthlycost'], '', '', false, false); |
734 | 734 | $csv_data['cost'] = $this->common_model->add_calculate_currency($csv_data['cost'], '', '', false, false); |
735 | 735 | $csv_data['connectcost'] = $this->common_model->add_calculate_currency($csv_data['connectcost'], '', '', false, false); |
736 | - $csv_data['accountid']=0; |
|
737 | - $csv_data['country_id']=$this->common->get_field_name('id','countrycode',array("country"=>$csv_data['country_id'])); |
|
736 | + $csv_data['accountid'] = 0; |
|
737 | + $csv_data['country_id'] = $this->common->get_field_name('id', 'countrycode', array("country"=>$csv_data['country_id'])); |
|
738 | 738 | $new_final_arr[$i] = $csv_data; |
739 | 739 | } |
740 | 740 | } |
@@ -747,17 +747,17 @@ discard block |
||
747 | 747 | } |
748 | 748 | $i++; |
749 | 749 | } |
750 | - if (!empty($new_final_arr)) { |
|
750 | + if ( ! empty($new_final_arr)) { |
|
751 | 751 | $result = $this->did_model->bulk_insert_dids($new_final_arr); |
752 | 752 | } |
753 | - if(!empty($final_reseller_array)){ |
|
753 | + if ( ! empty($final_reseller_array)) { |
|
754 | 754 | $this->db->insert_batch('reseller_pricing', $final_reseller_array); |
755 | 755 | } |
756 | 756 | unlink($full_path.$did_file_name); |
757 | 757 | $count = count($invalid_array); |
758 | 758 | if ($count > 0) { |
759 | 759 | $session_id = "-1"; |
760 | - $fp = fopen($full_path . $session_id . '.csv', 'w'); |
|
760 | + $fp = fopen($full_path.$session_id.'.csv', 'w'); |
|
761 | 761 | foreach ($new_final_arr_key as $key => $value) { |
762 | 762 | $custom_array[0][$key] = ucfirst($key); |
763 | 763 | } |
@@ -767,16 +767,16 @@ discard block |
||
767 | 767 | fputcsv($fp, $err_data); |
768 | 768 | } |
769 | 769 | fclose($fp); |
770 | - $this->session->set_userdata('import_did_csv_error', $session_id . ".csv"); |
|
770 | + $this->session->set_userdata('import_did_csv_error', $session_id.".csv"); |
|
771 | 771 | $data["error"] = $invalid_array; |
772 | 772 | $data['provider_id'] = $provider_id; |
773 | - $data['import_record_count'] = count($new_final_arr)+count($reseller_array); |
|
773 | + $data['import_record_count'] = count($new_final_arr) + count($reseller_array); |
|
774 | 774 | $data['failure_count'] = count($invalid_array) - 1; |
775 | 775 | $data['page_title'] = 'DID Import Error'; |
776 | 776 | $this->load->view('view_import_error', $data); |
777 | 777 | } else { |
778 | - $this->session->set_flashdata('astpp_errormsg', 'Total ' . count($new_final_arr) . ' DIDs Imported Successfully!'); |
|
779 | - redirect(base_url() . "did/did_list/"); |
|
778 | + $this->session->set_flashdata('astpp_errormsg', 'Total '.count($new_final_arr).' DIDs Imported Successfully!'); |
|
779 | + redirect(base_url()."did/did_list/"); |
|
780 | 780 | } |
781 | 781 | } |
782 | 782 | |
@@ -785,17 +785,17 @@ discard block |
||
785 | 785 | $alpha_regex = "/^[a-z ,.'-]+$/i"; |
786 | 786 | $alpha_numeric_regex = "/^[a-z0-9 ,.'-]+$/i"; |
787 | 787 | $email_regex = "/^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$/"; |
788 | - $str.= $csvdata['number'] != '' ? null : 'Number,'; |
|
788 | + $str .= $csvdata['number'] != '' ? null : 'Number,'; |
|
789 | 789 | $str = rtrim($str, ','); |
790 | - if (!$str) { |
|
791 | - $str.= is_numeric($csvdata['number']) ? null : 'Number,'; |
|
792 | - $str.=!empty($csvdata['connectcost']) && is_numeric($csvdata['connectcost']) ? null : ( empty($csvdata['connectcost']) ? null : 'Connect Cost,'); |
|
793 | - $str.=!empty($csvdata['includedseconds']) && is_numeric($csvdata['includedseconds']) ? null : ( empty($csvdata['includedseconds']) ? null : 'Included Seconds,'); |
|
790 | + if ( ! $str) { |
|
791 | + $str .= is_numeric($csvdata['number']) ? null : 'Number,'; |
|
792 | + $str .= ! empty($csvdata['connectcost']) && is_numeric($csvdata['connectcost']) ? null : (empty($csvdata['connectcost']) ? null : 'Connect Cost,'); |
|
793 | + $str .= ! empty($csvdata['includedseconds']) && is_numeric($csvdata['includedseconds']) ? null : (empty($csvdata['includedseconds']) ? null : 'Included Seconds,'); |
|
794 | 794 | if ($str) { |
795 | 795 | $str = rtrim($str, ','); |
796 | 796 | $error_field = explode(',', $str); |
797 | 797 | $count = count($error_field); |
798 | - $str.= $count > 1 ? ' are not valid' : ' is not Valid'; |
|
798 | + $str .= $count > 1 ? ' are not valid' : ' is not Valid'; |
|
799 | 799 | return $str; |
800 | 800 | } else { |
801 | 801 | return false; |
@@ -804,7 +804,7 @@ discard block |
||
804 | 804 | $str = rtrim($str, ','); |
805 | 805 | $error_field = explode(',', $str); |
806 | 806 | $count = count($error_field); |
807 | - $str.= $count > 1 ? ' are required' : ' is Required'; |
|
807 | + $str .= $count > 1 ? ' are required' : ' is Required'; |
|
808 | 808 | return $str; |
809 | 809 | } |
810 | 810 | } |
@@ -813,38 +813,38 @@ discard block |
||
813 | 813 | $this->load->helper('download'); |
814 | 814 | $error_data = $this->session->userdata('import_did_csv_error'); |
815 | 815 | $full_path = $this->config->item('rates-file-path'); |
816 | - $data = file_get_contents($full_path . $error_data); |
|
816 | + $data = file_get_contents($full_path.$error_data); |
|
817 | 817 | force_download("error_did_rates.csv", $data); |
818 | 818 | } |
819 | 819 | |
820 | 820 | function did_export_data_xls() { |
821 | 821 | $account_info = $accountinfo = $this->session->userdata('accountinfo'); |
822 | - $currency_id=$account_info['currency_id']; |
|
823 | - $currency=$this->common->get_field_name('currency', 'currency', $currency_id); |
|
822 | + $currency_id = $account_info['currency_id']; |
|
823 | + $currency = $this->common->get_field_name('currency', 'currency', $currency_id); |
|
824 | 824 | $query = $this->did_model->getdid_list(true, '0', '10000000'); |
825 | 825 | ob_clean(); |
826 | - $outbound_array[] = array("DID", "Country", "Account","Per Minute Cost($currency)","Initial Increment","Increment","Setup Fee($currency)","Monthly Fee($currency)","Call Type","Destination","Status","Modified Date","Is Purchased"); |
|
826 | + $outbound_array[] = array("DID", "Country", "Account", "Per Minute Cost($currency)", "Initial Increment", "Increment", "Setup Fee($currency)", "Monthly Fee($currency)", "Call Type", "Destination", "Status", "Modified Date", "Is Purchased"); |
|
827 | 827 | if ($query->num_rows() > 0) { |
828 | 828 | foreach ($query->result_array() as $row) { |
829 | 829 | $outbound_array[] = array( |
830 | 830 | $row['number'], |
831 | 831 | $this->common->get_field_name("country", "countrycode", $row['country_id']), |
832 | 832 | $this->common->get_field_name("number", "accounts", $row['accountid']), |
833 | - $this->common_model->calculate_currency($row['cost'], '', '',true, false), |
|
833 | + $this->common_model->calculate_currency($row['cost'], '', '', true, false), |
|
834 | 834 | $row['init_inc'], |
835 | 835 | $row['inc'], |
836 | - $this->common_model->calculate_currency($row['setup'], '', '',true, false), |
|
837 | - $this->common_model->calculate_currency($row['monthlycost'], '', '',true, false), |
|
838 | - $this->common->get_call_type("","",$row['call_type']), |
|
836 | + $this->common_model->calculate_currency($row['setup'], '', '', true, false), |
|
837 | + $this->common_model->calculate_currency($row['monthlycost'], '', '', true, false), |
|
838 | + $this->common->get_call_type("", "", $row['call_type']), |
|
839 | 839 | $row['extensions'], |
840 | - $this->common->get_status('export','',$row['status']), |
|
840 | + $this->common->get_status('export', '', $row['status']), |
|
841 | 841 | $row['last_modified_date'], |
842 | 842 | $this->common->check_did_avl_export($row['number']) |
843 | 843 | ); |
844 | 844 | } |
845 | 845 | } |
846 | 846 | $this->load->helper('csv'); |
847 | - array_to_csv($outbound_array, 'DIDs_' . date("Y-m-d") . '.csv'); |
|
847 | + array_to_csv($outbound_array, 'DIDs_'.date("Y-m-d").'.csv'); |
|
848 | 848 | } |
849 | 849 | |
850 | 850 | } |
@@ -37,31 +37,31 @@ discard block |
||
37 | 37 | |
38 | 38 | function index() { |
39 | 39 | if ($this->session->userdata('user_login') == FALSE) |
40 | - redirect(base_url() . 'login/login'); |
|
40 | + redirect(base_url().'login/login'); |
|
41 | 41 | $data['page_title'] = 'Dashboard'; |
42 | 42 | $this->load->view('view_user_dashboard', $data); |
43 | 43 | } |
44 | 44 | |
45 | 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) |
|
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 | 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']; |
|
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 | 65 | $i++; |
66 | 66 | } |
67 | 67 | } |
@@ -91,7 +91,7 @@ discard block |
||
91 | 91 | } |
92 | 92 | function user_dashboard_invoices_data() { |
93 | 93 | $accountinfo = $this->session->userdata('accountinfo'); |
94 | - $currency=$this->common->get_field_name('currency','currency',array("id"=>$accountinfo['currency_id'])); |
|
94 | + $currency = $this->common->get_field_name('currency', 'currency', array("id"=>$accountinfo['currency_id'])); |
|
95 | 95 | $this->db->where('accountid', $accountinfo['id']); |
96 | 96 | $this->db->where('confirm', 1); |
97 | 97 | $this->db->select('*'); |
@@ -108,20 +108,20 @@ discard block |
||
108 | 108 | $json_data[0]['amount'] = 'Amount ('.$currency.')'; |
109 | 109 | $i = 1; |
110 | 110 | foreach ($result as $key => $data) { |
111 | - $invoice_prefix= $entity_type =$this->common->get_field_name('invoice_prefix','invoices',array('id'=>$data['id'])); |
|
111 | + $invoice_prefix = $entity_type = $this->common->get_field_name('invoice_prefix', 'invoices', array('id'=>$data['id'])); |
|
112 | 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'; |
|
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 | 118 | } |
119 | - if($inv_type == 'manual_inv'){ |
|
120 | - $inv_type='Manually'; |
|
119 | + if ($inv_type == 'manual_inv') { |
|
120 | + $inv_type = 'Manually'; |
|
121 | 121 | } |
122 | - $inv_debit=$this->common->convert_to_currency('', '', $data['amount']); |
|
123 | - if($inv_debit == ''){ |
|
124 | - $inv_debit=$this->common->convert_to_currency('', '',0); |
|
122 | + $inv_debit = $this->common->convert_to_currency('', '', $data['amount']); |
|
123 | + if ($inv_debit == '') { |
|
124 | + $inv_debit = $this->common->convert_to_currency('', '', 0); |
|
125 | 125 | } |
126 | 126 | $json_data[$i]['type'] = $data['type']; |
127 | 127 | $json_data[$i]['id'] = $invoice_num; |
@@ -134,54 +134,54 @@ discard block |
||
134 | 134 | echo json_encode($json_data); |
135 | 135 | } |
136 | 136 | |
137 | - function user_dashboard_subscription_data(){ |
|
138 | - $accountinfo=$this->session->userdata('accountinfo'); |
|
139 | - $this->db->where('accountid',$accountinfo['id']); |
|
137 | + function user_dashboard_subscription_data() { |
|
138 | + $accountinfo = $this->session->userdata('accountinfo'); |
|
139 | + $this->db->where('accountid', $accountinfo['id']); |
|
140 | 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(); |
|
141 | + $this->db->order_by('assign_date', 'desc'); |
|
142 | + $result = $this->db->get('charge_to_account', 10); |
|
143 | + $json_data = array(); |
|
144 | 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,","); |
|
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 | 154 | $where = "id IN ($charge_str)"; |
155 | 155 | $this->db->where($where); |
156 | 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'; |
|
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 | 182 | } |
183 | - } else{ |
|
184 | - $json_data[$i]['sweep_id']='Anonymous'; |
|
183 | + } else { |
|
184 | + $json_data[$i]['sweep_id'] = 'Anonymous'; |
|
185 | 185 | } |
186 | 186 | $i++; |
187 | 187 | } |
@@ -192,7 +192,7 @@ discard block |
||
192 | 192 | function user_edit_account() { |
193 | 193 | if ($add_array['id'] != '') { |
194 | 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; |
|
195 | + $data['page_title'] = 'Edit '.$entity_name; |
|
196 | 196 | if ($this->form_validation->run() == FALSE) { |
197 | 197 | $data['validation_errors'] = validation_errors(); |
198 | 198 | } else { |
@@ -201,14 +201,14 @@ discard block |
||
201 | 201 | $this->accounts->accounts_model->edit_account($add_array, $add_array['id']); |
202 | 202 | $accountinfo = $this->session->userdata('accountinfo'); |
203 | 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()); |
|
204 | + $this->session->set_userdata('accountinfo', (array)$this->db->get_where('accounts', array('id' => $add_array['id']))->first_row()); |
|
205 | 205 | } |
206 | - $this->session->set_flashdata('astpp_errormsg', ucfirst($entity_name) . ' updated successfully!'); |
|
207 | - redirect(base_url() . 'user/user/'); |
|
206 | + $this->session->set_flashdata('astpp_errormsg', ucfirst($entity_name).' updated successfully!'); |
|
207 | + redirect(base_url().'user/user/'); |
|
208 | 208 | } |
209 | 209 | $this->load->view('view_user_details', $data); |
210 | 210 | } else { |
211 | - $data['page_title'] = 'Edit ' . $entity_name; |
|
211 | + $data['page_title'] = 'Edit '.$entity_name; |
|
212 | 212 | $where = array('id' => $account_data["id"]); |
213 | 213 | $account = $this->db_model->getSelect("*", "accounts", $where); |
214 | 214 | $data["account_data"] = $account->result_array(); |
@@ -225,52 +225,52 @@ discard block |
||
225 | 225 | function user_did_edit($edit_id = '') { |
226 | 226 | $data['page_title'] = 'Edit DIDs'; |
227 | 227 | $account_data = $this->session->userdata("accountinfo"); |
228 | - $this->db->where('id',$edit_id); |
|
228 | + $this->db->where('id', $edit_id); |
|
229 | 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); |
|
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 | 233 | $this->load->view('view_user_did_edit', $data); |
234 | 234 | } |
235 | 235 | |
236 | - function user_dids_action($action,$did_id = "") { |
|
236 | + function user_dids_action($action, $did_id = "") { |
|
237 | 237 | $accountinfo = $this->session->userdata('accountinfo'); |
238 | 238 | $reseller_id = $accountinfo['reseller_id']; |
239 | 239 | $did_id = empty($did_id) ? $this->input->post("free_didlist", true) : $did_id; |
240 | 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(); |
|
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 | 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']; |
|
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 | 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'])); |
|
250 | + $reseller_pricing_res = $this->db_model->getSelect("*", "reseller_pricing", array("note" => $did_arr['number'], "reseller_id"=>$accountinfo['reseller_id'])); |
|
251 | 251 | $reseller_pricing_arr = (array)$reseller_pricing_res->first_row(); |
252 | - $setup_cost=$reseller_pricing_arr['setup']; |
|
252 | + $setup_cost = $reseller_pricing_arr['setup']; |
|
253 | 253 | } |
254 | 254 | $available_bal = $this->db_model->get_available_bal($account_arr); |
255 | 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']); |
|
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 | 261 | $this->session->set_flashdata('astpp_errormsg', 'Did added successfully.'); |
262 | - redirect(base_url() . "user/user_didlist/"); |
|
262 | + redirect(base_url()."user/user_didlist/"); |
|
263 | 263 | } else { |
264 | 264 | $this->session->set_flashdata('astpp_notification', 'Insuffiecient fund to purchase this did'); |
265 | - redirect(base_url() . "user/user_didlist/"); |
|
265 | + redirect(base_url()."user/user_didlist/"); |
|
266 | 266 | } |
267 | - }else{ |
|
267 | + } else { |
|
268 | 268 | $this->session->set_flashdata('astpp_notification', 'This DID already purchased by someone.'); |
269 | - redirect(base_url() . "user/user_didlist/"); |
|
269 | + redirect(base_url()."user/user_didlist/"); |
|
270 | 270 | } |
271 | 271 | } |
272 | 272 | if ($action == "edit") { |
273 | - $add_array=$this->input->post(); |
|
273 | + $add_array = $this->input->post(); |
|
274 | 274 | $data['form'] = $this->form->build_form($this->user_form->build_user_did_form($add_array['free_didlist']), $add_array); |
275 | 275 | if ($this->form_validation->run() == FALSE) { |
276 | 276 | $data['validation_errors'] = validation_errors(); |
@@ -278,27 +278,27 @@ discard block |
||
278 | 278 | exit; |
279 | 279 | } else { |
280 | 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") |
|
281 | + "extensions" => $add_array['extensions'], "last_modified_date"=>gmdate("Y-m-d H:i:s") |
|
282 | 282 | ); |
283 | 283 | $this->db->update("dids", $update_arr, array("id" => $did_id)); |
284 | - if($accountinfo['reseller_id'] > 0 ){ |
|
284 | + if ($accountinfo['reseller_id'] > 0) { |
|
285 | 285 | |
286 | - $this->db->update('reseller_pricing',$update_arr,array('note'=>$did_arr['number'])); |
|
286 | + $this->db->update('reseller_pricing', $update_arr, array('note'=>$did_arr['number'])); |
|
287 | 287 | } |
288 | - echo json_encode(array("SUCCESS" => $did_arr['number'] . " DID Updated Successfully!")); |
|
288 | + echo json_encode(array("SUCCESS" => $did_arr['number']." DID Updated Successfully!")); |
|
289 | 289 | exit; |
290 | 290 | } |
291 | 291 | $this->load->view('view_user_did_edit', $data); |
292 | 292 | } |
293 | 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']); |
|
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 | 296 | $this->session->set_flashdata('astpp_notification', 'DID Removed Successfully.'); |
297 | - redirect(base_url() . "user/user_didlist/"); |
|
297 | + redirect(base_url()."user/user_didlist/"); |
|
298 | 298 | } |
299 | - }else{ |
|
299 | + } else { |
|
300 | 300 | $this->session->set_flashdata('astpp_notification', 'DID not found.'); |
301 | - redirect(base_url() . "user/user_didlist/"); |
|
301 | + redirect(base_url()."user/user_didlist/"); |
|
302 | 302 | } |
303 | 303 | } |
304 | 304 | |
@@ -324,13 +324,13 @@ discard block |
||
324 | 324 | $query = $this->user_model->get_user_rates_list(true, $paging_data["paging"]["start"], $paging_data["paging"]["page_no"]); |
325 | 325 | $grid_fields = json_decode($this->user_form->user_rates_list()); |
326 | 326 | foreach ($query->result_array() as $key => $value) { |
327 | - $cost=$account_data['type']!=3 ? ($value['cost'] + (($value['cost']*$markup)/100)) : $value['cost']; |
|
327 | + $cost = $account_data['type'] != 3 ? ($value['cost'] + (($value['cost'] * $markup) / 100)) : $value['cost']; |
|
328 | 328 | $json_data['rows'][] = array('cell' => array( |
329 | - $this->common->get_only_numeric_val("","",$value["pattern"]), |
|
329 | + $this->common->get_only_numeric_val("", "", $value["pattern"]), |
|
330 | 330 | $value['comment'], |
331 | - $this->common_model->calculate_currency($value['connectcost'],'','',true,false), |
|
331 | + $this->common_model->calculate_currency($value['connectcost'], '', '', true, false), |
|
332 | 332 | $value['includedseconds'], |
333 | - $this->common_model->calculate_currency(($cost),'','',true,false), |
|
333 | + $this->common_model->calculate_currency(($cost), '', '', true, false), |
|
334 | 334 | $value['init_inc'], |
335 | 335 | $value['inc'] |
336 | 336 | )); |
@@ -344,22 +344,22 @@ discard block |
||
344 | 344 | if ($this->input->post('advance_search', TRUE) == 1) { |
345 | 345 | $this->session->set_userdata('advance_search', $this->input->post('advance_search')); |
346 | 346 | $action = $this->input->post(); |
347 | - unset($action['action'],$action['advance_search']); |
|
347 | + unset($action['action'], $action['advance_search']); |
|
348 | 348 | if (isset($action['connectcost']['connectcost']) && $action['connectcost']['connectcost'] != '') { |
349 | 349 | $action['connectcost']['connectcost'] = $this->common_model->add_calculate_currency($action['connectcost']['connectcost'], "", '', true, false); |
350 | 350 | } |
351 | 351 | if (isset($action['cost']['cost']) && $action['cost']['cost'] != '') { |
352 | 352 | $account_data = $this->session->userdata("accountinfo"); |
353 | 353 | $markup = $this->common->get_field_name('markup', 'pricelists', array('id'=>$account_data["pricelist_id"])); |
354 | - $markup = ($markup > 0)?$markup:1; |
|
354 | + $markup = ($markup > 0) ? $markup : 1; |
|
355 | 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); |
|
356 | + if ($account_data['type'] != 3) |
|
357 | + $action['cost']['cost'] = ($action['cost']['cost'] - ($action['cost']['cost'] * $markup) / 100); |
|
358 | 358 | } |
359 | 359 | $this->session->set_userdata('user_rates_list_search', $action); |
360 | 360 | } |
361 | 361 | if ($ajax_search != 1) { |
362 | - redirect(base_url() . 'user/user_rates_list/'); |
|
362 | + redirect(base_url().'user/user_rates_list/'); |
|
363 | 363 | } |
364 | 364 | } |
365 | 365 | |
@@ -369,34 +369,34 @@ discard block |
||
369 | 369 | } |
370 | 370 | |
371 | 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); |
|
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 | 375 | $query = $this->user_model->get_user_rates_list(true, '', '', false); |
376 | 376 | $markup = $this->common->get_field_name('markup', 'pricelists', array('id'=>$account_data["pricelist_id"])); |
377 | 377 | ob_clean(); |
378 | - $inbound_array[] = array("Code", "Destination","Connect Cost($currency)","Included Seconds","Per Minute Cost($currency)","Initital Increment","Increment"); |
|
378 | + $inbound_array[] = array("Code", "Destination", "Connect Cost($currency)", "Included Seconds", "Per Minute Cost($currency)", "Initital Increment", "Increment"); |
|
379 | 379 | if ($query->num_rows() > 0) { |
380 | 380 | foreach ($query->result_array() as $row) { |
381 | - $cost=$account_data['type']!=3 ? ($row['cost'] + ($row['cost']*$markup)/100) :$row['cost']; |
|
381 | + $cost = $account_data['type'] != 3 ? ($row['cost'] + ($row['cost'] * $markup) / 100) : $row['cost']; |
|
382 | 382 | $inbound_array[] = array( |
383 | - $row['pattern']=$this->common->get_only_numeric_val("","",$row["pattern"]), |
|
383 | + $row['pattern'] = $this->common->get_only_numeric_val("", "", $row["pattern"]), |
|
384 | 384 | $row['comment'], |
385 | - $this->common_model->calculate_currency($row['connectcost'],'','',true,false), |
|
385 | + $this->common_model->calculate_currency($row['connectcost'], '', '', true, false), |
|
386 | 386 | $row['includedseconds'], |
387 | - $this->common_model->calculate_currency($cost,'','',true,false), |
|
387 | + $this->common_model->calculate_currency($cost, '', '', true, false), |
|
388 | 388 | $row['init_inc'], |
389 | 389 | $row['inc'] |
390 | 390 | ); |
391 | 391 | } |
392 | 392 | } |
393 | 393 | $this->load->helper('csv'); |
394 | - array_to_csv($inbound_array, 'Rates_' . date("Y-m-d") . '.csv'); |
|
394 | + array_to_csv($inbound_array, 'Rates_'.date("Y-m-d").'.csv'); |
|
395 | 395 | } |
396 | 396 | |
397 | 397 | function user_refill($action = "") { |
398 | 398 | if (common_model::$global_config['system_config']['paypal_status'] == 1) { |
399 | - redirect(base_url() . 'user/user/'); |
|
399 | + redirect(base_url().'user/user/'); |
|
400 | 400 | } |
401 | 401 | $this->load->module("user/refill"); |
402 | 402 | if ($action == "GET_AMT") { |
@@ -438,14 +438,14 @@ discard block |
||
438 | 438 | $this->load->model('user_model'); |
439 | 439 | $this->user_model->change_db_password($update, $id); |
440 | 440 | $this->session->set_flashdata('astpp_errormsg', "Password changed Sucessfully....!!!"); |
441 | - redirect(base_url() . 'user/user/changepassword/'); |
|
441 | + redirect(base_url().'user/user/changepassword/'); |
|
442 | 442 | } else { |
443 | 443 | $this->session->set_flashdata('astpp_notification', "New Password & Conformpassword not match."); |
444 | - redirect(base_url() . 'user/user/changepassword/'); |
|
444 | + redirect(base_url().'user/user/changepassword/'); |
|
445 | 445 | } |
446 | 446 | } else { |
447 | 447 | $this->session->set_flashdata('astpp_notification', "Invalid old passwword."); |
448 | - redirect(base_url() . 'user/user/changepassword/'); |
|
448 | + redirect(base_url().'user/user/changepassword/'); |
|
449 | 449 | } |
450 | 450 | } |
451 | 451 | |
@@ -471,7 +471,7 @@ discard block |
||
471 | 471 | $acc_data = $this->session->userdata("accountinfo"); |
472 | 472 | $reseller_id = $acc_data['reseller_id']; |
473 | 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 . "'"); |
|
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 | 475 | $reseller_data = array(); |
476 | 476 | $data['refill_coupon_list'] = form_dropdown_all('refill_coupon_list', $reseller_data, ''); |
477 | 477 | $this->load->view('view_refill_coupon_list', $data); |
@@ -501,11 +501,11 @@ discard block |
||
501 | 501 | echo json_encode(2); |
502 | 502 | } else { |
503 | 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); |
|
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 | 509 | echo json_encode($refill_coupon_result); |
510 | 510 | } |
511 | 511 | } else { |
@@ -539,10 +539,10 @@ discard block |
||
539 | 539 | $this->db->where('number', $refill_coupon_no); |
540 | 540 | $refill_coupon_data = array('status' => 2, "account_id" => $customer_id, 'firstused' => $date); |
541 | 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 . ''); |
|
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 | 543 | $this->db->insert('payments', $payment_arr); |
544 | 544 | } |
545 | - redirect(base_url() . "user/user_refill_coupon_list/"); |
|
545 | + redirect(base_url()."user/user_refill_coupon_list/"); |
|
546 | 546 | } |
547 | 547 | |
548 | 548 | function user_packages() { |
@@ -553,7 +553,7 @@ discard block |
||
553 | 553 | |
554 | 554 | function user_packages_json() { |
555 | 555 | $json_data = array(); |
556 | - $count_all = $this->user_model->get_user_packages_list(false,'',''); |
|
556 | + $count_all = $this->user_model->get_user_packages_list(false, '', ''); |
|
557 | 557 | $paging_data = $this->form->load_grid_config($count_all, $_GET['rp'], $_GET['page']); |
558 | 558 | $json_data = $paging_data["json_paging"]; |
559 | 559 | $query = $this->user_model->get_user_packages_list(true, $paging_data["paging"]["start"], $paging_data["paging"]["page_no"]); |
@@ -596,19 +596,19 @@ discard block |
||
596 | 596 | $json_data['rows'] = $this->form->build_grid($query, $grid_fields); |
597 | 597 | echo json_encode($json_data); |
598 | 598 | } |
599 | - function user_emails_search(){ |
|
599 | + function user_emails_search() { |
|
600 | 600 | $ajax_search = $this->input->post('ajax_search', 0); |
601 | 601 | if ($this->input->post('advance_search', TRUE) == 1) { |
602 | 602 | $this->session->set_userdata('advance_search', $this->input->post('advance_search')); |
603 | 603 | $action = $this->input->post(); |
604 | - unset($action['action'],$action['advance_search']); |
|
604 | + unset($action['action'], $action['advance_search']); |
|
605 | 605 | $this->session->set_userdata('user_emails_search', $action); |
606 | 606 | } |
607 | 607 | if (@$ajax_search != 1) { |
608 | - redirect(base_url() . 'user/user_emails/'); |
|
608 | + redirect(base_url().'user/user_emails/'); |
|
609 | 609 | } |
610 | 610 | } |
611 | - function user_emails_clearsearchfilter(){ |
|
611 | + function user_emails_clearsearchfilter() { |
|
612 | 612 | $this->session->set_userdata('advance_search', 0); |
613 | 613 | $this->session->set_userdata('user_emails_search', ""); |
614 | 614 | } |
@@ -620,30 +620,30 @@ discard block |
||
620 | 620 | if (isset($add_array['submit'])) { |
621 | 621 | if ($_FILES['file']['name'] == '') { |
622 | 622 | $invoiceconf = $this->user_model->get_invoiceconf(); |
623 | - $file_name=($invoiceconf['logo'] != '') ? $invoiceconf['logo'] : ''; |
|
623 | + $file_name = ($invoiceconf['logo'] != '') ? $invoiceconf['logo'] : ''; |
|
624 | 624 | } |
625 | 625 | if (isset($_FILES['file']['name']) && $_FILES['file']['name'] != '') { |
626 | 626 | $files = $_FILES['file']; |
627 | 627 | if ($files['size'] < 0) { |
628 | 628 | $this->session->set_flashdata('astpp_notification', 'PLease upload maximum file'); |
629 | - redirect(base_url() . "accounts/reseller_invoice_config/". $add_array['accountid']."/"); |
|
629 | + redirect(base_url()."accounts/reseller_invoice_config/".$add_array['accountid']."/"); |
|
630 | 630 | } |
631 | 631 | $file = $_FILES['file']; |
632 | 632 | $uploadedFile = $file["tmp_name"]; |
633 | 633 | $file_name = $file['name']; |
634 | 634 | $file_type = $file['type']; |
635 | 635 | 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']; |
|
636 | + $dir_path = FCPATH."upload/"; |
|
637 | + $path = $dir_path.$add_array['accountid']."_".$file['name']; |
|
638 | 638 | if (move_uploaded_file($uploadedFile, $path)) { |
639 | 639 | $this->session->set_flashdata('astpp_errormsg', gettext('files added successfully!')); |
640 | 640 | } else { |
641 | 641 | $this->session->set_flashdata('astpp_notification', "File Uploading Fail Please Try Again"); |
642 | - redirect(base_url() . 'user/user_invoice_config/'); |
|
642 | + redirect(base_url().'user/user_invoice_config/'); |
|
643 | 643 | } |
644 | 644 | } else { |
645 | 645 | $this->session->set_flashdata('astpp_notification', 'Please upload only image!'); |
646 | - redirect(base_url() . 'user/user_invoice_config/'); |
|
646 | + redirect(base_url().'user/user_invoice_config/'); |
|
647 | 647 | } |
648 | 648 | } |
649 | 649 | $add_array['logo'] = $file_name; |
@@ -655,24 +655,24 @@ discard block |
||
655 | 655 | $this->user_model->edit_invoice_config($add_array, $add_array['id']); |
656 | 656 | } |
657 | 657 | $this->session->set_flashdata('astpp_errormsg', 'Invoice config updated successfully!'); |
658 | - redirect(base_url() . 'user/user_invoice_config/'); |
|
658 | + redirect(base_url().'user/user_invoice_config/'); |
|
659 | 659 | } else { |
660 | - $data["account_data"] =(array)$this->db->get_where('invoice_conf',array("accountid"=>$accountinfo['id']))->first_row(); |
|
661 | - if(isset($data["account_data"]['logo'])){ |
|
662 | - $data["account_data"]['file']=$accountinfo['id']."_".$data["account_data"]['logo']; |
|
660 | + $data["account_data"] = (array)$this->db->get_where('invoice_conf', array("accountid"=>$accountinfo['id']))->first_row(); |
|
661 | + if (isset($data["account_data"]['logo'])) { |
|
662 | + $data["account_data"]['file'] = $accountinfo['id']."_".$data["account_data"]['logo']; |
|
663 | 663 | } |
664 | 664 | $this->load->view('view_user_invoices_config', $data); |
665 | 665 | } |
666 | 666 | } |
667 | 667 | |
668 | - 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); |
|
668 | + 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 | 674 | $this->db->where($where_arr); |
675 | - $this->db->update('invoice_conf',$post_arr); |
|
675 | + $this->db->update('invoice_conf', $post_arr); |
|
676 | 676 | } |
677 | 677 | |
678 | 678 | function user_myprofile() { |
@@ -691,9 +691,9 @@ discard block |
||
691 | 691 | $result = $this->db->get_where('accounts', array('id' => $add_array['id'])); |
692 | 692 | $result = $result->result_array(); |
693 | 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{ |
|
694 | + $this->session->set_flashdata('astpp_errormsg', ' Your profile updated successfully!'); |
|
695 | + redirect(base_url().'user/user_myprofile/'); |
|
696 | + } else { |
|
697 | 697 | $this->session->set_flashdata('astpp_notification', 'Something wrong.Please contact to administrator.'); |
698 | 698 | } |
699 | 699 | } |
@@ -715,35 +715,35 @@ discard block |
||
715 | 715 | $accountinfo = $this->session->userdata("accountinfo"); |
716 | 716 | $data['page_title'] = "Change Password"; |
717 | 717 | $add_array = $this->input->post(); |
718 | - if(!empty($add_array)) { |
|
718 | + if ( ! empty($add_array)) { |
|
719 | 719 | $data['form'] = $this->form->build_form($this->user_form->get_userprofile_change_password(), $add_array); |
720 | 720 | if ($this->form_validation->run() == FALSE) { |
721 | 721 | $data['validation_errors'] = validation_errors(); |
722 | 722 | } else { |
723 | 723 | $password_encode = $this->common->encode($add_array['new_password']); |
724 | 724 | $data = array('password' => $password_encode); |
725 | - $this->db->where('id',$add_array['id']); |
|
725 | + $this->db->where('id', $add_array['id']); |
|
726 | 726 | $this->db->update('accounts', $data); |
727 | 727 | $this->session->set_flashdata('astpp_errormsg', 'Password updated successfully!'); |
728 | - redirect(base_url() . 'user/user_change_password/'); |
|
728 | + redirect(base_url().'user/user_change_password/'); |
|
729 | 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); |
|
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 | 733 | } |
734 | 734 | $this->load->view('view_user_change_password', $data); |
735 | 735 | } |
736 | 736 | |
737 | 737 | function user_refill_report() { |
738 | - $accountinfo=$this->session->userdata('accountinfo'); |
|
738 | + $accountinfo = $this->session->userdata('accountinfo'); |
|
739 | 739 | $data['page_title'] = 'Refill Report'; |
740 | 740 | $data['search_flag'] = true; |
741 | 741 | $this->session->set_userdata('advance_search', 0); |
742 | 742 | $data['grid_fields'] = $this->user_form->build_user_refill_report(); |
743 | 743 | $data['form_search'] = $this->form->build_serach_form($this->user_form->build_user_refill_report_search()); |
744 | - if($accountinfo['type'] == 1){ |
|
744 | + if ($accountinfo['type'] == 1) { |
|
745 | 745 | $this->load->view('view_reseller_refill_report', $data); |
746 | - }else{ |
|
746 | + } else { |
|
747 | 747 | $this->load->view('view_user_refill_report', $data); |
748 | 748 | } |
749 | 749 | } |
@@ -751,7 +751,7 @@ discard block |
||
751 | 751 | function user_refill_report_json() { |
752 | 752 | $json_data = array(); |
753 | 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']); |
|
754 | + $paging_data = $this->form->load_grid_config($count_all, $_GET['rp'], $_GET['page']); |
|
755 | 755 | $json_data = $paging_data["json_paging"]; |
756 | 756 | $query = $this->user_model->get_user_refill_list(true, $paging_data["paging"]["start"], $paging_data["paging"]["page_no"]); |
757 | 757 | $grid_fields = json_decode($this->user_form->build_user_refill_report()); |
@@ -764,14 +764,14 @@ discard block |
||
764 | 764 | if ($this->input->post('advance_search', TRUE) == 1) { |
765 | 765 | $this->session->set_userdata('advance_search', $this->input->post('advance_search')); |
766 | 766 | $action = $this->input->post(); |
767 | - unset($action['action'],$action['advance_search']); |
|
767 | + unset($action['action'], $action['advance_search']); |
|
768 | 768 | if (isset($action['credit']['credit']) && $action['credit']['credit'] != '') { |
769 | 769 | $action['credit']['credit'] = $this->common_model->add_calculate_currency($action['credit']['credit'], "", '', true, false); |
770 | 770 | } |
771 | 771 | $this->session->set_userdata('user_refill_report_search', $action); |
772 | 772 | } |
773 | 773 | if (@$ajax_search != 1) { |
774 | - redirect(base_url() . 'user/user_refill_report/'); |
|
774 | + redirect(base_url().'user/user_refill_report/'); |
|
775 | 775 | } |
776 | 776 | } |
777 | 777 | |
@@ -794,7 +794,7 @@ discard block |
||
794 | 794 | $count_all = $this->user_model->get_user_invoice_list(false, '', '', $where); |
795 | 795 | $paging_data = $this->form->load_grid_config($count_all, $_GET['rp'], $_GET['page']); |
796 | 796 | $json_data = $paging_data["json_paging"]; |
797 | - $user_currency=$this->common->get_field_name('currency','currency',$accountinfo['currency_id']); |
|
797 | + $user_currency = $this->common->get_field_name('currency', 'currency', $accountinfo['currency_id']); |
|
798 | 798 | $invoices_query = $this->user_model->get_user_invoice_list(true, $paging_data["paging"]["start"], $paging_data["paging"]["page_no"], $where); |
799 | 799 | $invoices_result = $invoices_query->result_array(); |
800 | 800 | $ountstanding_value = 0; |
@@ -805,7 +805,7 @@ discard block |
||
805 | 805 | $total_credit = (array)$invoice_details_result->first_row(); |
806 | 806 | $total_credit = $total_credit['total_credit']; |
807 | 807 | foreach ($invoices_result as $key => $value) { |
808 | - $total_amount+=$value['amount']; |
|
808 | + $total_amount += $value['amount']; |
|
809 | 809 | $invoice_date = date("Y-m-d", strtotime($value['invoice_date'])); |
810 | 810 | $from_date = date("Y-m-d", strtotime($value['from_date'])); |
811 | 811 | $due_date = date("Y-m-d", strtotime($value['due_date'])); |
@@ -820,23 +820,23 @@ discard block |
||
820 | 820 | if ($invoice_total_query->num_rows() > 0) { |
821 | 821 | $invoice_total_result = $invoice_total_query->result_array(); |
822 | 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 | - if($value['type'] == 'I'){ |
|
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 | + if ($value['type'] == 'I') { |
|
825 | 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>'; |
|
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 | 827 | } else { |
828 | 828 | $payment = ' <button style="padding: 0 8px;" class="btn btn-success" type="button">Paid</button>'; |
829 | 829 | } |
830 | - }else{ |
|
830 | + } else { |
|
831 | 831 | $payment = ''; |
832 | 832 | } |
833 | - if($value['generate_type'] == 1){ |
|
834 | - $invoice_type='Manually'; |
|
835 | - }else{ |
|
836 | - $invoice_type='Automatically'; |
|
833 | + if ($value['generate_type'] == 1) { |
|
834 | + $invoice_type = 'Manually'; |
|
835 | + } else { |
|
836 | + $invoice_type = 'Automatically'; |
|
837 | 837 | } |
838 | 838 | |
839 | - if($value['type'] == 'R'){ |
|
839 | + if ($value['type'] == 'R') { |
|
840 | 840 | $icon = '<div class="flx_font flx_magenta">R</div>'; |
841 | 841 | } |
842 | 842 | else |
@@ -869,13 +869,13 @@ discard block |
||
869 | 869 | print_r($action); |
870 | 870 | unset($action['action']); |
871 | 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" : ''; |
|
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 | 875 | $this->session->set_userdata('user_invoice_list_search', $action); |
876 | 876 | } |
877 | 877 | if (@$ajax_search != 1) { |
878 | - redirect(base_url() . 'user/user_invoice_list/'); |
|
878 | + redirect(base_url().'user/user_invoice_list/'); |
|
879 | 879 | } |
880 | 880 | } |
881 | 881 | |
@@ -888,25 +888,25 @@ discard block |
||
888 | 888 | $this->load->module('invoices/invoices'); |
889 | 889 | $this->invoices->invoice_main_download($invoiceid); |
890 | 890 | } |
891 | - function user_list_responce(){ |
|
891 | + function user_list_responce() { |
|
892 | 892 | $this->load->module('invoices/invoices'); |
893 | 893 | $this->invoices->invoice_list_responce(); |
894 | 894 | } |
895 | - function user_invoice_payment($invoiceid){ |
|
895 | + function user_invoice_payment($invoiceid) { |
|
896 | 896 | $this->load->module('invoices/invoices'); |
897 | 897 | $this->invoices->invoice_summary($invoiceid); |
898 | 898 | } |
899 | - function user_invoice_payment_pay($action=""){ |
|
899 | + function user_invoice_payment_pay($action = "") { |
|
900 | 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{ |
|
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 | 906 | $this->payment->index(); |
907 | 907 | } |
908 | 908 | } |
909 | - function user_invoice_download($invoiceid){ |
|
909 | + function user_invoice_download($invoiceid) { |
|
910 | 910 | $this->load->module('invoices/invoices'); |
911 | 911 | $this->invoices->invoice_download($invoiceid); |
912 | 912 | } |
@@ -925,43 +925,43 @@ discard block |
||
925 | 925 | $json_data = $paging_data["json_paging"]; |
926 | 926 | $query = $this->user_model->get_user_charge_history(true, $paging_data["paging"]["start"], $paging_data["paging"]["page_no"]); |
927 | 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; |
|
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 | 936 | foreach ($result as $key => $value) { |
937 | - $date=$this->common->convert_GMT_to('','',$value['created_date']); |
|
937 | + $date = $this->common->convert_GMT_to('', '', $value['created_date']); |
|
938 | 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'){ |
|
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 | 957 | $credit = '(-) '.$credit; |
958 | 958 | } |
959 | - if($value['after_balance'] == '-'){ |
|
960 | - $after_balance='-'; |
|
961 | - } else{ |
|
962 | - $after_balance=$this->common->convert_to_currency('','',$value['after_balance']); |
|
959 | + if ($value['after_balance'] == '-') { |
|
960 | + $after_balance = '-'; |
|
961 | + } else { |
|
962 | + $after_balance = $this->common->convert_to_currency('', '', $value['after_balance']); |
|
963 | 963 | } |
964 | - $description=$value['description']; |
|
964 | + $description = $value['description']; |
|
965 | 965 | $cust_type = $this->common->get_field_name('posttoexternal', 'accounts', $value['accountid']); |
966 | 966 | $json_data['rows'][] = array('cell' => array( |
967 | 967 | $date, |
@@ -977,7 +977,7 @@ discard block |
||
977 | 977 | } |
978 | 978 | $debit_sum = 0; |
979 | 979 | $credit_sum = 0; |
980 | - foreach($res as $value){ |
|
980 | + foreach ($res as $value) { |
|
981 | 981 | $cust_type = $this->common->get_field_name('posttoexternal', 'accounts', $value['accountid']); |
982 | 982 | $cust_type = $this->common->get_field_name('posttoexternal', 'accounts', $value['accountid']); |
983 | 983 | $debit_sum += $value['debit']; |
@@ -985,7 +985,7 @@ discard block |
||
985 | 985 | $before_balance += $value['before_balance']; |
986 | 986 | $after_balance += $value['after_balance']; |
987 | 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>','-','-'); |
|
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 | 989 | echo json_encode($json_data); |
990 | 990 | |
991 | 991 | |
@@ -997,8 +997,8 @@ discard block |
||
997 | 997 | $action = $this->input->post(); |
998 | 998 | unset($action['action']); |
999 | 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" : ''; |
|
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 | 1002 | if (isset($action['debit']['debit']) && $action['debit']['debit'] != '') { |
1003 | 1003 | $action['debit']['debit'] = $this->common_model->add_calculate_currency($action['debit']['debit'], "", '', true, false); |
1004 | 1004 | } |
@@ -1008,7 +1008,7 @@ discard block |
||
1008 | 1008 | $this->session->set_userdata('user_charge_history_search', $action); |
1009 | 1009 | } |
1010 | 1010 | if (@$ajax_search != 1) { |
1011 | - redirect(base_url() . 'user/user_charges_history/'); |
|
1011 | + redirect(base_url().'user/user_charges_history/'); |
|
1012 | 1012 | } |
1013 | 1013 | } |
1014 | 1014 | |
@@ -1026,7 +1026,7 @@ discard block |
||
1026 | 1026 | |
1027 | 1027 | function user_subscriptions_json() { |
1028 | 1028 | |
1029 | - $accountinfo=$this->session->userdata('accountinfo'); |
|
1029 | + $accountinfo = $this->session->userdata('accountinfo'); |
|
1030 | 1030 | $json_data = array(); |
1031 | 1031 | $select = "charge_to_account.id,charges.description,charges.charge,charges.sweep_id"; |
1032 | 1032 | $table = "charges"; |
@@ -1057,14 +1057,14 @@ discard block |
||
1057 | 1057 | if (isset($action['charge']['charge']) && $action['charge']['charge'] != '') { |
1058 | 1058 | $action['charge']['charge'] = $this->common_model->add_calculate_currency($action['charge']['charge'], "", '', true, false); |
1059 | 1059 | } |
1060 | - if(isset($action['sweep_id']) && $action['sweep_id'] != ''){ |
|
1061 | - $action['charges.sweep_id']=$action['sweep_id']; |
|
1060 | + if (isset($action['sweep_id']) && $action['sweep_id'] != '') { |
|
1061 | + $action['charges.sweep_id'] = $action['sweep_id']; |
|
1062 | 1062 | unset($action['sweep_id']); |
1063 | 1063 | } |
1064 | 1064 | $this->session->set_userdata('user_subscription_search', $action); |
1065 | 1065 | } |
1066 | 1066 | if (@$ajax_search != 1) { |
1067 | - redirect(base_url() . 'user/user_subscriptions/'); |
|
1067 | + redirect(base_url().'user/user_subscriptions/'); |
|
1068 | 1068 | } |
1069 | 1069 | } |
1070 | 1070 | |
@@ -1074,7 +1074,7 @@ discard block |
||
1074 | 1074 | } |
1075 | 1075 | |
1076 | 1076 | function user_didlist() { |
1077 | - $accountinfo=$this->session->userdata('accountinfo'); |
|
1077 | + $accountinfo = $this->session->userdata('accountinfo'); |
|
1078 | 1078 | $data['page_title'] = 'Purchase DIDs'; |
1079 | 1079 | $data['search_flag'] = true; |
1080 | 1080 | $data['grid_fields'] = $this->user_form->build_user_didlist(); |
@@ -1082,38 +1082,38 @@ discard block |
||
1082 | 1082 | $data["grid_buttons"] = array(); |
1083 | 1083 | $acc_data = $this->session->userdata("accountinfo"); |
1084 | 1084 | $data['accountid'] = $acc_data['id']; |
1085 | - $data['country_id']=$acc_data['country_id']; |
|
1085 | + $data['country_id'] = $acc_data['country_id']; |
|
1086 | 1086 | $result_did_final = array(); |
1087 | - if($accountinfo['reseller_id'] > 0){ |
|
1087 | + if ($accountinfo['reseller_id'] > 0) { |
|
1088 | 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']); |
|
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 | 1092 | $this->db->from('dids,reseller_pricing'); |
1093 | - }else{ |
|
1094 | - $this->db->where('parent_id',0); |
|
1095 | - $this->db->where('accountid',0); |
|
1093 | + } else { |
|
1094 | + $this->db->where('parent_id', 0); |
|
1095 | + $this->db->where('accountid', 0); |
|
1096 | 1096 | $this->db->select('id,number,setup,monthlycost'); |
1097 | 1097 | $this->db->from('dids'); |
1098 | 1098 | } |
1099 | - $dids_array=(array)$this->db->get()->result_array(); |
|
1100 | - $drp_list=array(); |
|
1101 | - if(!empty($dids_array)){ |
|
1099 | + $dids_array = (array)$this->db->get()->result_array(); |
|
1100 | + $drp_list = array(); |
|
1101 | + if ( ! empty($dids_array)) { |
|
1102 | 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); |
|
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 | 1105 | } else { |
1106 | 1106 | $did_cost = 0; |
1107 | 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); |
|
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 | 1110 | } else { |
1111 | 1111 | $did_setup = 0; |
1112 | 1112 | } |
1113 | - $drp_list[$drp_value['id']] = $drp_value['number'] . ' ( Setup : ' . $did_setup . ')' . '( Monthly : ' . $did_cost . ' )'; |
|
1113 | + $drp_list[$drp_value['id']] = $drp_value['number'].' ( Setup : '.$did_setup.')'.'( Monthly : '.$did_cost.' )'; |
|
1114 | 1114 | } |
1115 | 1115 | } |
1116 | - $data['didlist'] = form_dropdown_all(array("name"=>"free_didlist","id"=>"free_didlist","class"=>"did_dropdown"), $drp_list, ''); |
|
1116 | + $data['didlist'] = form_dropdown_all(array("name"=>"free_didlist", "id"=>"free_didlist", "class"=>"did_dropdown"), $drp_list, ''); |
|
1117 | 1117 | $this->load->view('view_user_did_list', $data); |
1118 | 1118 | } |
1119 | 1119 | |
@@ -1153,9 +1153,9 @@ discard block |
||
1153 | 1153 | if ($this->input->post('advance_search', TRUE) == 1) { |
1154 | 1154 | $this->session->set_userdata('advance_search', $this->input->post('advance_search')); |
1155 | 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']; |
|
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 | 1159 | unset($action['call_type']); |
1160 | 1160 | } |
1161 | 1161 | unset($action['action']); |
@@ -1163,7 +1163,7 @@ discard block |
||
1163 | 1163 | $this->session->set_userdata('user_did_search', $action); |
1164 | 1164 | } |
1165 | 1165 | if (@$ajax_search != 1) { |
1166 | - redirect(base_url() . 'user/user_didlist/'); |
|
1166 | + redirect(base_url().'user/user_didlist/'); |
|
1167 | 1167 | } |
1168 | 1168 | } |
1169 | 1169 | |
@@ -1172,14 +1172,14 @@ discard block |
||
1172 | 1172 | $this->session->set_userdata('user_did_search', ""); |
1173 | 1173 | } |
1174 | 1174 | |
1175 | - function user_ipmap(){ |
|
1175 | + function user_ipmap() { |
|
1176 | 1176 | $this->session->set_userdata('advance_search', 0); |
1177 | 1177 | $data['grid_fields'] = $this->user_form->build_user_ipmap(); |
1178 | 1178 | $data['form_search'] = $this->form->build_serach_form($this->user_form->build_user_ipmap_search()); |
1179 | 1179 | $this->load->view('view_user_ipmap_list', $data); |
1180 | 1180 | } |
1181 | 1181 | |
1182 | - function user_ipmap_json(){ |
|
1182 | + function user_ipmap_json() { |
|
1183 | 1183 | $json_data = array(); |
1184 | 1184 | $account_data = $this->session->userdata("accountinfo"); |
1185 | 1185 | $count_all = $this->user_model->user_ipmap_list(false); |
@@ -1191,7 +1191,7 @@ discard block |
||
1191 | 1191 | echo json_encode($json_data); |
1192 | 1192 | } |
1193 | 1193 | |
1194 | - function user_ipmap_search(){ |
|
1194 | + function user_ipmap_search() { |
|
1195 | 1195 | $ajax_search = $this->input->post('ajax_search', 0); |
1196 | 1196 | if ($this->input->post('advance_search', TRUE) == 1) { |
1197 | 1197 | $this->session->set_userdata('advance_search', $this->input->post('advance_search')); |
@@ -1201,24 +1201,24 @@ discard block |
||
1201 | 1201 | $this->session->set_userdata('user_ipmap_search', $action); |
1202 | 1202 | } |
1203 | 1203 | if (@$ajax_search != 1) { |
1204 | - redirect(base_url() . 'user/user_ipmap/'); |
|
1204 | + redirect(base_url().'user/user_ipmap/'); |
|
1205 | 1205 | } |
1206 | 1206 | } |
1207 | 1207 | |
1208 | - function user_ipmap_clearsearchfilter(){ |
|
1208 | + function user_ipmap_clearsearchfilter() { |
|
1209 | 1209 | $this->session->set_userdata('advance_search', 0); |
1210 | 1210 | $this->session->set_userdata('user_ipmap_search', ""); |
1211 | 1211 | } |
1212 | 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'){ |
|
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 | 1217 | $ip = $add_array['ip']; |
1218 | 1218 | if (strpos($ip, '/') !== false) { |
1219 | 1219 | $add_array['ip'] = $add_array['ip']; |
1220 | 1220 | } else { |
1221 | - $add_array['ip'] = $add_array['ip'] . '/32'; |
|
1221 | + $add_array['ip'] = $add_array['ip'].'/32'; |
|
1222 | 1222 | } |
1223 | 1223 | $where = array("ip" => trim($add_array['ip']), "prefix" => trim($add_array['prefix'])); |
1224 | 1224 | $getdata = $this->db_model->countQuery("*", "ip_map", $where); |
@@ -1239,8 +1239,8 @@ discard block |
||
1239 | 1239 | $this->session->set_flashdata('astpp_errormsg', 'IP Added Sucessfully.'); |
1240 | 1240 | } |
1241 | 1241 | } |
1242 | - if($action =='delete'){ |
|
1243 | - $this->db->delete('ip_map',array('id'=>$id)); |
|
1242 | + if ($action == 'delete') { |
|
1243 | + $this->db->delete('ip_map', array('id'=>$id)); |
|
1244 | 1244 | $this->session->set_flashdata('astpp_notification', 'IP Removed Sucessfully.'); |
1245 | 1245 | } |
1246 | 1246 | redirect(base_url()."user/user_ipmap/"); |
@@ -1261,23 +1261,23 @@ discard block |
||
1261 | 1261 | $paging_data = $this->form->load_grid_config($count_all, $_GET['rp'], $_GET['page']); |
1262 | 1262 | $json_data = $paging_data["json_paging"]; |
1263 | 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"]); |
|
1264 | + $query = $this->user_model->user_sipdevices_list(true, $account_data['id'], $paging_data["paging"]["start"], $paging_data["paging"]["page_no"]); |
|
1265 | 1265 | foreach ($query as $key => $value) { |
1266 | 1266 | $path_true = base_url().'/assets/images/true.png'; |
1267 | 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">'; |
|
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 | 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>', |
|
1270 | + '<input type="checkbox" name="chkAll" id="'.$value['id'].'" class="ace chkRefNos" onclick="clickchkbox('.$value['id'].')" value='.$value['id'].'><lable class="lbl"></lable>', |
|
1271 | 1271 | $value['username'], |
1272 | 1272 | $value['password'], |
1273 | 1273 | $value['effective_caller_id_name'], |
1274 | 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']), |
|
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 | 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>' |
|
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 | 1281 | )); |
1282 | 1282 | } |
1283 | 1283 | echo json_encode($json_data); |
@@ -1292,7 +1292,7 @@ discard block |
||
1292 | 1292 | $this->session->set_userdata('user_sipdevices_search', $action); |
1293 | 1293 | } |
1294 | 1294 | if (@$ajax_search != 1) { |
1295 | - redirect(base_url() . 'user/user_sipdevices/'); |
|
1295 | + redirect(base_url().'user/user_sipdevices/'); |
|
1296 | 1296 | } |
1297 | 1297 | } |
1298 | 1298 | |
@@ -1301,12 +1301,12 @@ discard block |
||
1301 | 1301 | $this->session->set_userdata('user_sipdevices_search', ""); |
1302 | 1302 | } |
1303 | 1303 | |
1304 | - function user_sipdevices_add(){ |
|
1304 | + function user_sipdevices_add() { |
|
1305 | 1305 | $data['page_title'] = 'Create SIP Device'; |
1306 | - $data['form'] = $this->form->build_form($this->user_form->build_user_sipdevices_form(),""); |
|
1306 | + $data['form'] = $this->form->build_form($this->user_form->build_user_sipdevices_form(), ""); |
|
1307 | 1307 | $this->load->view('view_user_sipdevices_add_edit', $data); |
1308 | 1308 | } |
1309 | - function user_sipdevices_edit($edit_id=''){ |
|
1309 | + function user_sipdevices_edit($edit_id = '') { |
|
1310 | 1310 | $account_data = $this->session->userdata("accountinfo"); |
1311 | 1311 | $data['page_title'] = 'Edit SIP Device'; |
1312 | 1312 | $where = array('id' => $edit_id); |
@@ -1314,7 +1314,7 @@ discard block |
||
1314 | 1314 | $data['form'] = $this->form->build_form($this->user_form->build_user_sipdevices_form($edit_id), $sipdevice_info); |
1315 | 1315 | $this->load->view('view_user_sipdevices_add_edit', $data); |
1316 | 1316 | } |
1317 | - function user_sipdevices_save(){ |
|
1317 | + function user_sipdevices_save() { |
|
1318 | 1318 | $add_array = $this->input->post(); |
1319 | 1319 | $data['form'] = $this->form->build_form($this->user_form->build_user_sipdevices_form($add_array['id']), $add_array); |
1320 | 1320 | if ($add_array['id'] != '') { |
@@ -1342,15 +1342,15 @@ discard block |
||
1342 | 1342 | } |
1343 | 1343 | } |
1344 | 1344 | function user_sipdevices_delete($id) { |
1345 | - $this->db->delete('sip_devices',array('id'=>$id)); |
|
1345 | + $this->db->delete('sip_devices', array('id'=>$id)); |
|
1346 | 1346 | $this->session->set_flashdata('astpp_notification', 'SIP Device Removed Sucessfully!'); |
1347 | - redirect(base_url() . "user/user_sipdevices/"); |
|
1347 | + redirect(base_url()."user/user_sipdevices/"); |
|
1348 | 1348 | } |
1349 | 1349 | |
1350 | - function user_sipdevices_delete_multiple(){ |
|
1350 | + function user_sipdevices_delete_multiple() { |
|
1351 | 1351 | $ids = $this->input->post("selected_ids", true); |
1352 | 1352 | $where = "id IN ($ids)"; |
1353 | - $this->db->delete("sip_devices",$where); |
|
1353 | + $this->db->delete("sip_devices", $where); |
|
1354 | 1354 | echo TRUE; |
1355 | 1355 | } |
1356 | 1356 | |
@@ -1383,7 +1383,7 @@ discard block |
||
1383 | 1383 | $cnt_result = $cnt_result->result_array(); |
1384 | 1384 | $count = $cnt_result[0]['count']; |
1385 | 1385 | if ($count == 0) { |
1386 | - if($add_array['number'] != ""){ |
|
1386 | + if ($add_array['number'] != "") { |
|
1387 | 1387 | $accountinfo = $this->session->userdata("accountinfo"); |
1388 | 1388 | $insert_arr = array("number" => $add_array['number'], |
1389 | 1389 | "accountid" => $accountinfo['id'], |
@@ -1391,7 +1391,7 @@ discard block |
||
1391 | 1391 | ); |
1392 | 1392 | $this->db->insert("ani_map", $insert_arr); |
1393 | 1393 | $this->session->set_flashdata('astpp_errormsg', 'Add Caller ID Sucessfully!'); |
1394 | - }else{ |
|
1394 | + } else { |
|
1395 | 1395 | $this->session->set_flashdata('astpp_notification', 'Please Enter Caller ID value.'); |
1396 | 1396 | } |
1397 | 1397 | } else { |
@@ -1403,28 +1403,28 @@ discard block |
||
1403 | 1403 | $this->db_model->delete("ani_map", array("id" => $aniid)); |
1404 | 1404 | |
1405 | 1405 | } |
1406 | - redirect(base_url() . "user/user_animap_list/"); |
|
1406 | + redirect(base_url()."user/user_animap_list/"); |
|
1407 | 1407 | } |
1408 | 1408 | |
1409 | 1409 | function user_alert_threshold() { |
1410 | 1410 | $data['page_title'] = 'Alert Threshold'; |
1411 | 1411 | $accountinfo = $this->session->userdata("accountinfo"); |
1412 | 1412 | $add_array = $this->input->post(); |
1413 | - if (!empty($add_array)) { |
|
1414 | - unset($add_array['action'],$add_array['id']); |
|
1413 | + if ( ! empty($add_array)) { |
|
1414 | + unset($add_array['action'], $add_array['id']); |
|
1415 | 1415 | $this->user_model->edit_alert_threshold($add_array, $accountinfo['id']); |
1416 | 1416 | $this->session->set_flashdata('astpp_errormsg', 'Alert Threshold updated successfully!'); |
1417 | - redirect(base_url() . 'user/user_alert_threshold/'); |
|
1417 | + redirect(base_url().'user/user_alert_threshold/'); |
|
1418 | 1418 | } else { |
1419 | 1419 | $where = array('id' => $accountinfo["id"]); |
1420 | 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()); |
|
1421 | + $data['form'] = $this->form->build_form($this->user_form->user_alert_threshold(), (array)$account->first_row()); |
|
1422 | 1422 | $this->load->view('view_user_alert_threshold', $data); |
1423 | 1423 | } |
1424 | 1424 | } |
1425 | 1425 | |
1426 | 1426 | function user_cdrs_report() { |
1427 | - $accountinfo=$this->session->userdata('accountinfo'); |
|
1427 | + $accountinfo = $this->session->userdata('accountinfo'); |
|
1428 | 1428 | $data['page_title'] = 'CDRs'; |
1429 | 1429 | $data['search_flag'] = true; |
1430 | 1430 | $data["grid_buttons"] = $this->user_form->build_cdrs_report_buttons(); |
@@ -1434,10 +1434,10 @@ discard block |
||
1434 | 1434 | } |
1435 | 1435 | |
1436 | 1436 | function user_cdrs_report_json() { |
1437 | - $accountinfo=$this->session->userdata('accountinfo'); |
|
1438 | - $variable=$accountinfo['type'] != 3 ?'total_debit':'total_cost'; |
|
1437 | + $accountinfo = $this->session->userdata('accountinfo'); |
|
1438 | + $variable = $accountinfo['type'] != 3 ? 'total_debit' : 'total_cost'; |
|
1439 | 1439 | $count_res = $this->user_model->getuser_cdrs_list(false, "", ""); |
1440 | - $count_all = (array) $count_res->first_row(); |
|
1440 | + $count_all = (array)$count_res->first_row(); |
|
1441 | 1441 | $paging_data = $this->form->load_grid_config($count_all['count'], $_GET['rp'], $_GET['page']); |
1442 | 1442 | $json_data = $paging_data["json_paging"]; |
1443 | 1443 | $query = $this->user_model->getuser_cdrs_list(true, $paging_data["paging"]["start"], $paging_data["paging"]["page_no"], false); |
@@ -1445,16 +1445,16 @@ discard block |
||
1445 | 1445 | $json_data['rows'] = $this->form->build_grid($query, $grid_fields); |
1446 | 1446 | if ($count_all['count'] > 0) { |
1447 | 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']; |
|
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 | 1451 | $json_data['rows'][] = array("cell" => array( |
1452 | 1452 | "<b>Grand Total</b>", |
1453 | 1453 | "", |
1454 | 1454 | "", |
1455 | 1455 | "", |
1456 | 1456 | $duration, |
1457 | - "<b>".$this->common_model->calculate_currency($count_all[$variable],"","",true,false)."</b>", |
|
1457 | + "<b>".$this->common_model->calculate_currency($count_all[$variable], "", "", true, false)."</b>", |
|
1458 | 1458 | "", |
1459 | 1459 | "", |
1460 | 1460 | )); |
@@ -1475,7 +1475,7 @@ discard block |
||
1475 | 1475 | $this->session->set_userdata('user_cdrs_report_search', $action); |
1476 | 1476 | } |
1477 | 1477 | if (@$ajax_search != 1) { |
1478 | - redirect(base_url() . 'user/user_cdrs_report/'); |
|
1478 | + redirect(base_url().'user/user_cdrs_report/'); |
|
1479 | 1479 | } |
1480 | 1480 | } |
1481 | 1481 | |
@@ -1486,20 +1486,20 @@ discard block |
||
1486 | 1486 | |
1487 | 1487 | function user_cdrreport_export() { |
1488 | 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); |
|
1489 | + $currency_id = $account_info['currency_id']; |
|
1490 | + $currency = $this->common->get_field_name('currency', 'currency', $currency_id); |
|
1491 | 1491 | $count_res = $this->user_model->getuser_cdrs_list(false, "", ""); |
1492 | - $count_all = (array) $count_res->first_row(); |
|
1492 | + $count_all = (array)$count_res->first_row(); |
|
1493 | 1493 | ob_clean(); |
1494 | - $customer_array[] = array("Date", "CallerID", "Called Number","Code", "Destination", "Duration", "Debit($currency)", "Disposition", "Call Type"); |
|
1494 | + $customer_array[] = array("Date", "CallerID", "Called Number", "Code", "Destination", "Duration", "Debit($currency)", "Disposition", "Call Type"); |
|
1495 | 1495 | if ($count_all['count'] > 0) { |
1496 | 1496 | $query = $this->user_model->getuser_cdrs_list(true, '', '', true); |
1497 | 1497 | $currency_info = $this->common->get_currency_info(); |
1498 | 1498 | $search_arr = $this->session->userdata('user_cdrs_report_search'); |
1499 | - $show_seconds = (!empty($search_arr['search_in'])) ? $search_arr['search_in'] : 'minutes'; |
|
1499 | + $show_seconds = ( ! empty($search_arr['search_in'])) ? $search_arr['search_in'] : 'minutes'; |
|
1500 | 1500 | 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']; |
|
1501 | + $duration = ($show_seconds == 'minutes') ? ($value['billseconds'] > 0) ? |
|
1502 | + floor($value['billseconds'] / 60).":".sprintf("%02d", $value['billseconds'] % 60) : "00:00" : $value['billseconds']; |
|
1503 | 1503 | $customer_array[] = array( |
1504 | 1504 | $this->common->convert_GMT_to('', '', $value['callstart']), |
1505 | 1505 | $value['callerid'], |
@@ -1507,13 +1507,13 @@ discard block |
||
1507 | 1507 | filter_var($value['pattern'], FILTER_SANITIZE_NUMBER_INT), |
1508 | 1508 | $value['notes'], |
1509 | 1509 | $duration, |
1510 | - $this->common->calculate_currency_manually($currency_info, $value['debit'],false), |
|
1510 | + $this->common->calculate_currency_manually($currency_info, $value['debit'], false), |
|
1511 | 1511 | $value['disposition'], |
1512 | 1512 | $value['calltype'] |
1513 | 1513 | ); |
1514 | 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']; |
|
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 | 1517 | $customer_array[] = array("Grand Total", |
1518 | 1518 | "", |
1519 | 1519 | "", |
@@ -1526,26 +1526,26 @@ discard block |
||
1526 | 1526 | ); |
1527 | 1527 | } |
1528 | 1528 | $this->load->helper('csv'); |
1529 | - array_to_csv($customer_array, 'Customer_CDR_' . date("Y-m-d") . '.csv'); |
|
1529 | + array_to_csv($customer_array, 'Customer_CDR_'.date("Y-m-d").'.csv'); |
|
1530 | 1530 | } |
1531 | - function user_payment($action=""){ |
|
1532 | - if(common_model::$global_config['system_config']['paypal_status'] == 1){ |
|
1533 | - redirect(base_url() . 'user/user/'); |
|
1531 | + function user_payment($action = "") { |
|
1532 | + if (common_model::$global_config['system_config']['paypal_status'] == 1) { |
|
1533 | + redirect(base_url().'user/user/'); |
|
1534 | 1534 | } |
1535 | 1535 | $this->load->module("user/payment"); |
1536 | - if($action=="GET_AMT"){ |
|
1537 | - $amount = $this->input->post("value",true); |
|
1536 | + if ($action == "GET_AMT") { |
|
1537 | + $amount = $this->input->post("value", true); |
|
1538 | 1538 | $this->payment->convert_amount($amount); |
1539 | - }else{ |
|
1539 | + } else { |
|
1540 | 1540 | $this->payment->index(); |
1541 | 1541 | } |
1542 | 1542 | } |
1543 | 1543 | |
1544 | - function user_fund_transfer(){ |
|
1544 | + function user_fund_transfer() { |
|
1545 | 1545 | $data['page_title'] = 'Fund Transfer'; |
1546 | 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(); |
|
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 | 1549 | $data['form'] = $this->form->build_form($this->user_form->build_user_fund_transfer_form($account['number'], $currency['currency'], $accountinfo['id']), ''); |
1550 | 1550 | $this->load->view('view_user_fund_transfer', $data); |
1551 | 1551 | } |
@@ -1554,8 +1554,8 @@ discard block |
||
1554 | 1554 | $data['page_title'] = 'Fund Transfer'; |
1555 | 1555 | $post_array = $this->input->post(); |
1556 | 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(); |
|
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 | 1559 | $data['form'] = $this->form->build_form($this->user_form->build_user_fund_transfer_form($account['number'], $currency['currency'], $accountinfo['id']), $post_array); |
1560 | 1560 | if ($this->form_validation->run() == FALSE) { |
1561 | 1561 | $data['validation_errors'] = validation_errors(); |
@@ -1564,11 +1564,11 @@ discard block |
||
1564 | 1564 | $account_info = $this->session->userdata('accountinfo'); |
1565 | 1565 | $balance = $this->common->get_field_name('balance', 'accounts', array('id' => $account_info['id'], 'status' => 0, 'type' => 0, 'deleted' => 0)); |
1566 | 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){ |
|
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 | 1569 | $reseller_id = $toaccountinfo['reseller_id']; |
1570 | 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(); |
|
1571 | + $minimum_fund = (array)$this->db->get_where('system', array("name"=>"minimum_fund_transfer"), 1)->first_row(); |
|
1572 | 1572 | if ($post_array['toaccountid'] == $account_info['number']) { |
1573 | 1573 | $this->session->set_flashdata('astpp_notification', 'You can not transfer fund in same account.'); |
1574 | 1574 | } |
@@ -1584,21 +1584,21 @@ discard block |
||
1584 | 1584 | elseif ($post_array['credit'] > $balance) { |
1585 | 1585 | $this->session->set_flashdata('astpp_notification', 'You have insufficient balance.'); |
1586 | 1586 | } |
1587 | - elseif ($toid <= 0 || !isset($post_array['toaccountid'])) { |
|
1587 | + elseif ($toid <= 0 || ! isset($post_array['toaccountid'])) { |
|
1588 | 1588 | $this->session->set_flashdata('astpp_notification', 'Please enter valid account number.'); |
1589 | 1589 | } |
1590 | 1590 | elseif ($post_array['credit'] < 0) { |
1591 | 1591 | $this->session->set_flashdata('astpp_notification', 'Please enter amount greater then 0.'); |
1592 | 1592 | } |
1593 | 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'] . ' .'); |
|
1594 | + $this->session->set_flashdata('astpp_notification', 'You need to enter minimum amount of fund transfer '.$minimum_fund['value'].' .'); |
|
1595 | 1595 | } |
1596 | - elseif (!isset($toid) || !isset($post_array['toaccountid'])) { |
|
1596 | + elseif ( ! isset($toid) || ! isset($post_array['toaccountid'])) { |
|
1597 | 1597 | $this->session->set_flashdata('astpp_notification', 'Please enter valid account number!'); |
1598 | 1598 | } |
1599 | 1599 | elseif ($post_array['credit'] < 0 || $post_array['credit'] > $balance) { |
1600 | 1600 | $this->session->set_flashdata('astpp_notification', 'Insuffiecient amount !'); |
1601 | - }else{ |
|
1601 | + } else { |
|
1602 | 1602 | $from['id'] = $post_array['id']; |
1603 | 1603 | $from['account_currency'] = $post_array['account_currency']; |
1604 | 1604 | $from['accountid'] = $post_array['fromaccountid']; |
@@ -1633,13 +1633,13 @@ discard block |
||
1633 | 1633 | $this->session->set_flashdata('astpp_notification', 'Sorry We are not able to process this request.'); |
1634 | 1634 | } |
1635 | 1635 | } |
1636 | - }else{ |
|
1636 | + } else { |
|
1637 | 1637 | $this->session->set_flashdata('astpp_notification', 'Account number not found.'); |
1638 | 1638 | } |
1639 | 1639 | } else { |
1640 | 1640 | $this->session->set_flashdata('astpp_notification', 'You can not transfer fund in same account.'); |
1641 | 1641 | } |
1642 | - redirect(base_url() . 'user/user_fund_transfer/'); |
|
1642 | + redirect(base_url().'user/user_fund_transfer/'); |
|
1643 | 1643 | } |
1644 | 1644 | $this->load->view('view_user_fund_transfer', $data); |
1645 | 1645 | } |
@@ -1657,7 +1657,7 @@ discard block |
||
1657 | 1657 | $accountinfo = $this->session->userdata("accountinfo"); |
1658 | 1658 | $json_data = array(); |
1659 | 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']); |
|
1660 | + $paging_data = $this->form->load_grid_config($count_all, $_GET['rp'], $_GET['page']); |
|
1661 | 1661 | $json_data = $paging_data["json_paging"]; |
1662 | 1662 | $query = $this->user_model->get_user_opensips(true, $accountinfo['number'], $paging_data["paging"]["start"], $paging_data["paging"]["page_no"]); |
1663 | 1663 | $grid_fields = json_decode($this->user_form->build_user_opensips()); |
@@ -1681,7 +1681,7 @@ discard block |
||
1681 | 1681 | $this->session->set_userdata('user_opensips_search', $action); |
1682 | 1682 | } |
1683 | 1683 | if ($ajax_search != 1) { |
1684 | - redirect(base_url() . 'user/user_opensips/'); |
|
1684 | + redirect(base_url().'user/user_opensips/'); |
|
1685 | 1685 | } |
1686 | 1686 | } |
1687 | 1687 | |
@@ -1694,10 +1694,10 @@ discard block |
||
1694 | 1694 | $this->load->view('view_opensips_add_edit', $data); |
1695 | 1695 | } |
1696 | 1696 | |
1697 | - function user_opensips_edit($edit_id){ |
|
1697 | + function user_opensips_edit($edit_id) { |
|
1698 | 1698 | $data['page_title'] = 'Edit Opensips'; |
1699 | 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="; |
|
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 | 1701 | $this->opensips_db = $this->load->database($opensipdsn, true); |
1702 | 1702 | $where = array('id' => $edit_id); |
1703 | 1703 | $this->opensips_db->where($where); |
@@ -1710,7 +1710,7 @@ discard block |
||
1710 | 1710 | |
1711 | 1711 | } |
1712 | 1712 | |
1713 | - function user_opensips_save(){ |
|
1713 | + function user_opensips_save() { |
|
1714 | 1714 | $add_array = $this->input->post(); |
1715 | 1715 | $data['form'] = $this->form->build_form($this->user_form->build_user_opensips_form(), $add_array); |
1716 | 1716 | if ($add_array['id'] != '') { |
@@ -1721,11 +1721,11 @@ discard block |
||
1721 | 1721 | exit; |
1722 | 1722 | } else { |
1723 | 1723 | $auth_flag = $this->validate_device_data($add_array); |
1724 | - if($auth_flag == "TRUE"){ |
|
1724 | + if ($auth_flag == "TRUE") { |
|
1725 | 1725 | $this->user_model->user_opensips_edit($add_array, $add_array['id']); |
1726 | 1726 | echo json_encode(array("SUCCESS"=> " OpenSips updated successfully!")); |
1727 | 1727 | exit; |
1728 | - }else{ |
|
1728 | + } else { |
|
1729 | 1729 | echo json_encode($auth_flag); |
1730 | 1730 | exit; |
1731 | 1731 | } |
@@ -1738,48 +1738,48 @@ discard block |
||
1738 | 1738 | exit; |
1739 | 1739 | } else { |
1740 | 1740 | $auth_flag = $this->validate_device_data($add_array); |
1741 | - if($auth_flag == "TRUE"){ |
|
1741 | + if ($auth_flag == "TRUE") { |
|
1742 | 1742 | $this->user_model->user_opensips_add($add_array); |
1743 | 1743 | echo json_encode(array("SUCCESS"=> "OpenSips added successfully!")); |
1744 | 1744 | exit; |
1745 | - }else{ |
|
1745 | + } else { |
|
1746 | 1746 | echo json_encode($auth_flag); |
1747 | 1747 | exit; |
1748 | 1748 | } |
1749 | 1749 | } |
1750 | 1750 | } |
1751 | 1751 | } |
1752 | - function validate_device_data($data){ |
|
1753 | - if(isset($data["username"]) && $data["username"] != ""){ |
|
1752 | + function validate_device_data($data) { |
|
1753 | + if (isset($data["username"]) && $data["username"] != "") { |
|
1754 | 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="; |
|
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 | 1756 | $this->opensips_db = $this->load->database($opensipdsn, true); |
1757 | 1757 | $where = array("username"=>$data["username"]); |
1758 | - if($data['id'] != ""){ |
|
1759 | - $this->opensips_db->where("id <>",$data['id']); |
|
1758 | + if ($data['id'] != "") { |
|
1759 | + $this->opensips_db->where("id <>", $data['id']); |
|
1760 | 1760 | } |
1761 | 1761 | $this->opensips_db->where($where); |
1762 | 1762 | $auth_flag = $this->opensips_db->get("subscriber"); |
1763 | 1763 | $auth_flag = $auth_flag->num_rows(); |
1764 | - if($auth_flag == 0){ |
|
1764 | + if ($auth_flag == 0) { |
|
1765 | 1765 | return "TRUE"; |
1766 | - }else{ |
|
1766 | + } else { |
|
1767 | 1767 | return array("username_error"=>"Duplicate Username Found.Username Must be Unique"); |
1768 | 1768 | } |
1769 | - }else{ |
|
1769 | + } else { |
|
1770 | 1770 | return array("username_error"=>"User name is required field."); |
1771 | 1771 | } |
1772 | 1772 | return "0"; |
1773 | 1773 | } |
1774 | 1774 | |
1775 | - function user_opensips_delete($id){ |
|
1775 | + function user_opensips_delete($id) { |
|
1776 | 1776 | $this->user_model->user_opensips_delete($id); |
1777 | 1777 | $this->session->set_flashdata('astpp_errormsg', 'Opensips Device Removed Successfully!.'); |
1778 | - redirect(base_url() . "user/user_opensips/"); |
|
1778 | + redirect(base_url()."user/user_opensips/"); |
|
1779 | 1779 | } |
1780 | - function user_opensips_delete_multiple(){ |
|
1780 | + function user_opensips_delete_multiple() { |
|
1781 | 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="; |
|
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 | 1783 | $this->opensips_db = $this->load->database($opensipdsn, true); |
1784 | 1784 | $ids = $this->input->post("selected_ids", true); |
1785 | 1785 | $where = "id IN ($ids)"; |
@@ -1788,27 +1788,27 @@ discard block |
||
1788 | 1788 | echo TRUE; |
1789 | 1789 | } |
1790 | 1790 | |
1791 | - function user_cdrs(){ |
|
1791 | + function user_cdrs() { |
|
1792 | 1792 | $data['username'] = $this->session->userdata('user_name'); |
1793 | - $accountinfo=$this->session->userdata('accountinfo'); |
|
1793 | + $accountinfo = $this->session->userdata('accountinfo'); |
|
1794 | 1794 | $data['page_title'] = 'CDRs'; |
1795 | 1795 | $accounttype = strtolower($this->common->get_entity_type('', '', $accountinfo['type'])); |
1796 | 1796 | $this->load->module('reports/reports'); |
1797 | 1797 | $data['grid_fields'] = $this->reports->reports_form->build_report_list_for_user($accounttype); |
1798 | 1798 | $data['form_search'] = $this->form->build_serach_form($this->user_form->build_user_opensips_search()); |
1799 | - $data['accounttype']=$accounttype; |
|
1799 | + $data['accounttype'] = $accounttype; |
|
1800 | 1800 | $this->load->view('view_user_cdrs', $data); |
1801 | 1801 | } |
1802 | - function user_cdrs_json(){ |
|
1803 | - $accountinfo=$this->session->userdata('accountinfo'); |
|
1802 | + function user_cdrs_json() { |
|
1803 | + $accountinfo = $this->session->userdata('accountinfo'); |
|
1804 | 1804 | $accounttype = strtolower($this->common->get_entity_type('', '', $accountinfo['type'])); |
1805 | 1805 | $this->load->module('reports/reports'); |
1806 | 1806 | $this->reports->customer_cdrreport($accountinfo['id'], $accounttype); |
1807 | 1807 | } |
1808 | - function user_details_search($module_name){ |
|
1808 | + function user_details_search($module_name) { |
|
1809 | 1809 | $action = $this->input->post(); |
1810 | - $this->session->set_userdata('left_panel_search_'.$module_name,""); |
|
1811 | - if(!empty($action['left_panel_search'])){ |
|
1810 | + $this->session->set_userdata('left_panel_search_'.$module_name, ""); |
|
1811 | + if ( ! empty($action['left_panel_search'])) { |
|
1812 | 1812 | $this->session->set_userdata('left_panel_search_'.$module_name, $action['left_panel_search']); |
1813 | 1813 | } |
1814 | 1814 | } |
@@ -1820,7 +1820,7 @@ discard block |
||
1820 | 1820 | |
1821 | 1821 | |
1822 | 1822 | function user_provider_cdrs_report() { |
1823 | - $accountinfo=$this->session->userdata('accountinfo'); |
|
1823 | + $accountinfo = $this->session->userdata('accountinfo'); |
|
1824 | 1824 | $data['page_title'] = 'Provider CDRs Report'; |
1825 | 1825 | $data['search_flag'] = true; |
1826 | 1826 | $data["grid_buttons"] = $this->user_form->build_provider_report_buttons(); |
@@ -1830,10 +1830,10 @@ discard block |
||
1830 | 1830 | } |
1831 | 1831 | |
1832 | 1832 | function user_provider_cdrs_report_json() { |
1833 | - $accountinfo=$this->session->userdata('accountinfo'); |
|
1834 | - $variable=$accountinfo['type'] != 3 ?'total_debit':'total_cost'; |
|
1833 | + $accountinfo = $this->session->userdata('accountinfo'); |
|
1834 | + $variable = $accountinfo['type'] != 3 ? 'total_debit' : 'total_cost'; |
|
1835 | 1835 | $count_res = $this->user_model->getprovider_cdrs_list(false, "", ""); |
1836 | - $count_all = (array) $count_res->first_row(); |
|
1836 | + $count_all = (array)$count_res->first_row(); |
|
1837 | 1837 | $paging_data = $this->form->load_grid_config($count_all['count'], $_GET['rp'], $_GET['page']); |
1838 | 1838 | $json_data = $paging_data["json_paging"]; |
1839 | 1839 | $query = $this->user_model->getprovider_cdrs_list(true, $paging_data["paging"]["start"], $paging_data["paging"]["page_no"], false); |
@@ -1841,16 +1841,16 @@ discard block |
||
1841 | 1841 | $json_data['rows'] = $this->form->build_grid($query, $grid_fields); |
1842 | 1842 | if ($count_all['count'] > 0) { |
1843 | 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']; |
|
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 | 1847 | $json_data['rows'][] = array("cell" => array( |
1848 | 1848 | "<b>Grand Total</b>", |
1849 | 1849 | "", |
1850 | 1850 | "", |
1851 | 1851 | "", |
1852 | 1852 | $duration, |
1853 | - "<b>".$this->common_model->calculate_currency($count_all[$variable],"","",true,false)."</b>", |
|
1853 | + "<b>".$this->common_model->calculate_currency($count_all[$variable], "", "", true, false)."</b>", |
|
1854 | 1854 | "", |
1855 | 1855 | "", |
1856 | 1856 | )); |
@@ -1871,7 +1871,7 @@ discard block |
||
1871 | 1871 | $this->session->set_userdata('user_provider_cdrs_report_search', $action); |
1872 | 1872 | } |
1873 | 1873 | if ($ajax_search != 1) { |
1874 | - redirect(base_url() . 'user/user_provider_cdrs_report/'); |
|
1874 | + redirect(base_url().'user/user_provider_cdrs_report/'); |
|
1875 | 1875 | } |
1876 | 1876 | } |
1877 | 1877 | |
@@ -1882,53 +1882,53 @@ discard block |
||
1882 | 1882 | |
1883 | 1883 | function user_provider_cdrreport_export() { |
1884 | 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); |
|
1885 | + $currency_id = $account_info['currency_id']; |
|
1886 | + $currency = $this->common->get_field_name('currency', 'currency', $currency_id); |
|
1887 | 1887 | $count_res = $this->user_model->getprovider_cdrs_list(false, "", ""); |
1888 | - $count_all = (array) $count_res->first_row(); |
|
1888 | + $count_all = (array)$count_res->first_row(); |
|
1889 | 1889 | ob_clean(); |
1890 | 1890 | $customer_array[] = array("Date", "CallerID", "Called Number", "Destination", "Duration", "Cost($currency)", "Disposition", "Call Type"); |
1891 | 1891 | if ($count_all['count'] > 0) { |
1892 | 1892 | $query = $this->user_model->getuser_cdrs_list(true, '', '', true); |
1893 | 1893 | $currency_info = $this->common->get_currency_info(); |
1894 | 1894 | $search_arr = $this->session->userdata('user_provider_cdrs_report_search'); |
1895 | - $show_seconds = (!empty($search_arr['search_in'])) ? $search_arr['search_in'] : 'minutes'; |
|
1895 | + $show_seconds = ( ! empty($search_arr['search_in'])) ? $search_arr['search_in'] : 'minutes'; |
|
1896 | 1896 | 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']; |
|
1897 | + $duration = ($show_seconds == 'minutes') ? ($value['billseconds'] > 0) ? |
|
1898 | + floor($value['billseconds'] / 60).":".sprintf("%02d", $value['billseconds'] % 60) : "00:00" : $value['billseconds']; |
|
1899 | 1899 | $customer_array[] = array( |
1900 | 1900 | $this->common->convert_GMT_to('', '', $value['callstart']), |
1901 | 1901 | $value['callerid'], |
1902 | 1902 | $value['callednum'], |
1903 | 1903 | filter_var($value['pattern'], FILTER_SANITIZE_NUMBER_INT), |
1904 | 1904 | $duration, |
1905 | - $this->common->calculate_currency_manually($currency_info, $value['cost'],false), |
|
1905 | + $this->common->calculate_currency_manually($currency_info, $value['cost'], false), |
|
1906 | 1906 | $value['disposition'], |
1907 | 1907 | $value['calltype'] |
1908 | 1908 | ); |
1909 | 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']; |
|
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 | 1912 | $customer_array[] = array("Grand Total", |
1913 | 1913 | "", |
1914 | 1914 | "", |
1915 | 1915 | "", |
1916 | 1916 | $duration, |
1917 | - $this->common->calculate_currency_manually($currency_info, $count_all['total_cost'],false,true), |
|
1917 | + $this->common->calculate_currency_manually($currency_info, $count_all['total_cost'], false, true), |
|
1918 | 1918 | "", |
1919 | 1919 | "" |
1920 | 1920 | ); |
1921 | 1921 | } |
1922 | 1922 | $this->load->helper('csv'); |
1923 | - array_to_csv($customer_array, 'Provider_CDR_' . date("Y-m-d") . '.csv'); |
|
1923 | + array_to_csv($customer_array, 'Provider_CDR_'.date("Y-m-d").'.csv'); |
|
1924 | 1924 | } |
1925 | - function user_speeddial(){ |
|
1925 | + function user_speeddial() { |
|
1926 | 1926 | $data['page_title'] = "Speed Dial"; |
1927 | 1927 | $accountinfo = $this->session->userdata('accountinfo'); |
1928 | 1928 | $where = array('id' => $accountinfo['id'], "reseller_id" => $accountinfo['reseller_id']); |
1929 | 1929 | $account = $this->db_model->getSelect("*", "accounts", $where); |
1930 | 1930 | if ($account->num_rows() > 0) { |
1931 | - $account_data = (array) $account->first_row(); |
|
1931 | + $account_data = (array)$account->first_row(); |
|
1932 | 1932 | $speeddial_res = $this->db->get_where("speed_dial", array("accountid" => $accountinfo['id'])); |
1933 | 1933 | $speeddial_info = array(); |
1934 | 1934 | if ($speeddial_res->num_rows() > 0) { |
@@ -1939,14 +1939,14 @@ discard block |
||
1939 | 1939 | } |
1940 | 1940 | $data['speeddial'] = $speeddial_info; |
1941 | 1941 | $this->load->view('view_user_speeddial', $data); |
1942 | - } else{ |
|
1942 | + } else { |
|
1943 | 1943 | redirect(base_url.'user/user/'); |
1944 | 1944 | } |
1945 | 1945 | } |
1946 | 1946 | |
1947 | - function user_speeddial_save(){ |
|
1948 | - $add_array= $this->input->post(); |
|
1949 | - $accountinfo=$this->session->userdata('accountinfo'); |
|
1947 | + function user_speeddial_save() { |
|
1948 | + $add_array = $this->input->post(); |
|
1949 | + $accountinfo = $this->session->userdata('accountinfo'); |
|
1950 | 1950 | $where = array("accountid" => $accountinfo['id']); |
1951 | 1951 | $this->db->select('count(id) as count'); |
1952 | 1952 | $this->db->where($where); |
@@ -1964,8 +1964,8 @@ discard block |
||
1964 | 1964 | } |
1965 | 1965 | } |
1966 | 1966 | function user_speeddial_remove() { |
1967 | - $accountinfo=$this->session->userdata('accountinfo'); |
|
1968 | - $add_array=$this->input->post(); |
|
1967 | + $accountinfo = $this->session->userdata('accountinfo'); |
|
1968 | + $add_array = $this->input->post(); |
|
1969 | 1969 | $updateinfo = array('number' => ''); |
1970 | 1970 | $this->db->where('speed_num', $add_array['number']); |
1971 | 1971 | $this->db->where('accountid', $accountinfo['id']); |
@@ -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); |