@@ -20,7 +20,7 @@ discard block |
||
20 | 20 | # You should have received a copy of the GNU Affero General Public License |
21 | 21 | # along with this program. If not, see <http://www.gnu.org/licenses/>. |
22 | 22 | ############################################################################### |
23 | -if (!defined('BASEPATH')) |
|
23 | +if ( ! defined('BASEPATH')) |
|
24 | 24 | exit('No direct script access allowed'); |
25 | 25 | |
26 | 26 | class Taxes_form { |
@@ -28,13 +28,13 @@ discard block |
||
28 | 28 | $this->CI = & get_instance(); |
29 | 29 | } |
30 | 30 | function get_taxes_form_fields() { |
31 | - $form['forms'] = array(base_url() . 'taxes/taxes_save/', array('id' => 'taxes_form', 'method' => 'POST', 'name' => 'taxes_form')); |
|
31 | + $form['forms'] = array(base_url().'taxes/taxes_save/', array('id' => 'taxes_form', 'method' => 'POST', 'name' => 'taxes_form')); |
|
32 | 32 | $form['Tax Information'] = array( |
33 | 33 | array('', 'HIDDEN', array('name' => 'id'), '', '', '', ''), |
34 | - array('Name', 'INPUT', array('name' => 'taxes_description', 'size' => '20', 'class' => "text field medium"), '', 'tOOL TIP', ''), |
|
34 | + array('Name', 'INPUT', array('name' => 'taxes_description', 'size' => '20', 'class' => "text field medium"), '', 'tOOL TIP', ''), |
|
35 | 35 | array('Priority', 'INPUT', array('name' => 'taxes_priority', 'size' => '20', 'maxlength' => '5', 'class' => "text field medium"), 'trim|required|numeric', 'tOOL TIP', ''), |
36 | 36 | array('Amount', 'INPUT', array('name' => 'taxes_amount', 'size' => '20', 'maxlength' => '20', 'class' => "text field medium"), 'trim|required|numeric|xss_clean', 'tOOL TIP', ''), |
37 | - array('Rate(%)', 'INPUT', array('name' => 'taxes_rate', 'size' => '20','maxlength' => '20', 'class' => "text field medium"), 'trim|numeric|xss_clean', 'tOOL TIP', ''), |
|
37 | + array('Rate(%)', 'INPUT', array('name' => 'taxes_rate', 'size' => '20', 'maxlength' => '20', 'class' => "text field medium"), 'trim|numeric|xss_clean', 'tOOL TIP', ''), |
|
38 | 38 | array('Status', 'status', 'SELECT', '', '', 'tOOL TIP', 'Please Enter account number', '', '', '', 'set_status'), |
39 | 39 | |
40 | 40 | ); |
@@ -48,7 +48,7 @@ discard block |
||
48 | 48 | $form['Search'] = array( |
49 | 49 | array('Name', 'INPUT', array('name' => 'taxes_description[taxes_description]', '', 'size' => '20', 'class' => "text field "), '', 'tOOL TIP', '1', 'taxes_description[taxes_description-string]', '', '', '', 'search_string_type', ''), |
50 | 50 | array('Amount', 'INPUT', array('name' => 'taxes_amount[taxes_amount]', 'value' => '', 'size' => '20', 'class' => "text field "), '', 'Tool tips info', '1', 'taxes_amount[taxes_amount-integer]', '', '', '', 'search_int_type', ''), |
51 | - array('Rate(%)', 'INPUT', array('name' => 'taxes_rate[taxes_rate]', 'value' => '', 'size' => '20', 'class' => "text field "), '', 'Tool tips info', '1', 'taxes_rate[taxes_rate-integer]', '', '', '', 'search_int_type', ''), array('Status', 'status', 'SELECT', '', '', 'tOOL TIP', 'Please Enter account number', '', '', '', 'set_search_status', '', ''), array('', 'HIDDEN', 'ajax_search', '1', '', '', ''), |
|
51 | + array('Rate(%)', 'INPUT', array('name' => 'taxes_rate[taxes_rate]', 'value' => '', 'size' => '20', 'class' => "text field "), '', 'Tool tips info', '1', 'taxes_rate[taxes_rate-integer]', '', '', '', 'search_int_type', ''), array('Status', 'status', 'SELECT', '', '', 'tOOL TIP', 'Please Enter account number', '', '', '', 'set_search_status', '', ''), array('', 'HIDDEN', 'ajax_search', '1', '', '', ''), |
|
52 | 52 | array('', 'HIDDEN', 'advance_search', '1', '', '', '') |
53 | 53 | ); |
54 | 54 | $form['button_search'] = array('name' => 'action', 'id' => "taxes_search_btn", 'content' => 'Search', 'value' => 'save', 'type' => 'button', 'class' => 'btn btn-line-parrot pull-right'); |
@@ -58,14 +58,14 @@ discard block |
||
58 | 58 | |
59 | 59 | function build_taxes_list_for_admin() { |
60 | 60 | $account_info = $accountinfo = $this->CI->session->userdata('accountinfo'); |
61 | - $currency_id=$account_info['currency_id']; |
|
62 | - $currency=$this->CI->common->get_field_name('currency', 'currency', $currency_id); |
|
63 | - $grid_field_arr = json_encode(array(array("<input type='checkbox' name='chkAll' class='ace checkall'/><label class='lbl'></label>", "30", "", "", "", "","","false","center"), |
|
64 | - array("Name", "270", "taxes_description", "", "", "","","true","center"), |
|
65 | - array("Priority", "145", "taxes_priority", "", "", "","","true","center"), |
|
66 | - array("Amount($currency)", "260", "taxes_amount", "taxes_amount", "taxes_amount", "convert_to_currency","","true","right"), |
|
67 | - array("Rate(%)", "230", "taxes_rate", "", "", "","","true","right"), |
|
68 | - array("Status", "160", "status", "status", "taxes", "get_status","","true","center"), |
|
61 | + $currency_id = $account_info['currency_id']; |
|
62 | + $currency = $this->CI->common->get_field_name('currency', 'currency', $currency_id); |
|
63 | + $grid_field_arr = json_encode(array(array("<input type='checkbox' name='chkAll' class='ace checkall'/><label class='lbl'></label>", "30", "", "", "", "", "", "false", "center"), |
|
64 | + array("Name", "270", "taxes_description", "", "", "", "", "true", "center"), |
|
65 | + array("Priority", "145", "taxes_priority", "", "", "", "", "true", "center"), |
|
66 | + array("Amount($currency)", "260", "taxes_amount", "taxes_amount", "taxes_amount", "convert_to_currency", "", "true", "right"), |
|
67 | + array("Rate(%)", "230", "taxes_rate", "", "", "", "", "true", "right"), |
|
68 | + array("Status", "160", "status", "status", "taxes", "get_status", "", "true", "center"), |
|
69 | 69 | array("Action", "175", "", "", "", array("EDIT" => array("url" => "taxes/taxes_edit/", "mode" => "popup"), |
70 | 70 | "DELETE" => array("url" => "taxes/taxes_delete/", "mode" => "single"))) |
71 | 71 | )); |
@@ -73,8 +73,8 @@ discard block |
||
73 | 73 | } |
74 | 74 | |
75 | 75 | function build_grid_buttons() { |
76 | - $buttons_json = json_encode(array(array("Create","btn btn-line-warning btn", "fa fa-plus-circle fa-lg", "button_action", "/taxes/taxes_add/", "popup"), |
|
77 | - array("Delete","btn btn-line-danger", "fa fa-times-circle fa-lg", "button_action", "/taxes/taxes_delete_multiple/"))); |
|
76 | + $buttons_json = json_encode(array(array("Create", "btn btn-line-warning btn", "fa fa-plus-circle fa-lg", "button_action", "/taxes/taxes_add/", "popup"), |
|
77 | + array("Delete", "btn btn-line-danger", "fa fa-times-circle fa-lg", "button_action", "/taxes/taxes_delete_multiple/"))); |
|
78 | 78 | return $buttons_json; |
79 | 79 | } |
80 | 80 |
@@ -20,8 +20,9 @@ |
||
20 | 20 | # You should have received a copy of the GNU Affero General Public License |
21 | 21 | # along with this program. If not, see <http://www.gnu.org/licenses/>. |
22 | 22 | ############################################################################### |
23 | -if (!defined('BASEPATH')) |
|
24 | - exit('No direct script access allowed'); |
|
23 | +if (!defined('BASEPATH')) { |
|
24 | + exit('No direct script access allowed'); |
|
25 | +} |
|
25 | 26 | |
26 | 27 | class Taxes_form { |
27 | 28 | function __construct() { |
@@ -41,20 +41,20 @@ discard block |
||
41 | 41 | } |
42 | 42 | return $query; |
43 | 43 | } |
44 | - function get_reseller_package_list($flag,$accountid,$accounttype,$start = 0, $limit = 0){ |
|
45 | - $instant_search=$this->session->userdata('left_panel_search_'.$accounttype.'_packages'); |
|
44 | + function get_reseller_package_list($flag, $accountid, $accounttype, $start = 0, $limit = 0) { |
|
45 | + $instant_search = $this->session->userdata('left_panel_search_'.$accounttype.'_packages'); |
|
46 | 46 | $instant_search_currency = $this->common_model->add_calculate_currency($instant_search, "", '', true, false); |
47 | - $like_str=!empty($instant_search) ? "(package_name like '%$instant_search%' |
|
48 | - OR includedseconds like '%$instant_search%')":null; |
|
49 | - $this->db->where('id',$accountid); |
|
47 | + $like_str = ! empty($instant_search) ? "(package_name like '%$instant_search%' |
|
48 | + OR includedseconds like '%$instant_search%')" : null; |
|
49 | + $this->db->where('id', $accountid); |
|
50 | 50 | $this->db->select('pricelist_id'); |
51 | - $account_info=(array)$this->db->get('accounts')->first_row(); |
|
52 | - $where=array('pricelist_id'=>$account_info['pricelist_id']); |
|
53 | - if(!empty($like_str)) |
|
51 | + $account_info = (array)$this->db->get('accounts')->first_row(); |
|
52 | + $where = array('pricelist_id'=>$account_info['pricelist_id']); |
|
53 | + if ( ! empty($like_str)) |
|
54 | 54 | $this->db->where($like_str); |
55 | 55 | if ($flag) { |
56 | 56 | $query = $this->db_model->select("*", "packages", $where, "id", "ASC", $limit, $start); |
57 | - }else { |
|
57 | + } else { |
|
58 | 58 | $query = $this->db_model->countQuery("*", "packages", $where); |
59 | 59 | } |
60 | 60 | return $query; |
@@ -68,7 +68,7 @@ discard block |
||
68 | 68 | /* |
69 | 69 | ASTPP 3.0 Add creation date |
70 | 70 | */ |
71 | - $add_array['creation_date']=gmdate('Y-m-d H:i:s'); |
|
71 | + $add_array['creation_date'] = gmdate('Y-m-d H:i:s'); |
|
72 | 72 | /*******************************************/ |
73 | 73 | $this->db->insert("packages", $add_array); |
74 | 74 | return true; |
@@ -79,7 +79,7 @@ discard block |
||
79 | 79 | /* |
80 | 80 | ASTPP 3.0 add last modified field. |
81 | 81 | */ |
82 | - $data['last_modified_date']=gmdate('Y-m-d H:i:s'); |
|
82 | + $data['last_modified_date'] = gmdate('Y-m-d H:i:s'); |
|
83 | 83 | /********************************************/ |
84 | 84 | if ($this->session->userdata('logintype') == 1 || $this->session->userdata('logintype') == 5) { |
85 | 85 | $account_data = $this->session->userdata("accountinfo"); |
@@ -94,7 +94,7 @@ discard block |
||
94 | 94 | /* ASTPP 3.0 |
95 | 95 | * Remove Package information from table package_patterns as well. |
96 | 96 | */ |
97 | - $this->db->where('package_id',$id); |
|
97 | + $this->db->where('package_id', $id); |
|
98 | 98 | $this->db->delete('package_patterns'); |
99 | 99 | /***************************************/ |
100 | 100 | $this->db->where("id", $id); |
@@ -105,89 +105,89 @@ discard block |
||
105 | 105 | function getpackage_counter_list($flag, $start = 0, $limit = 0) { |
106 | 106 | $where = array(); |
107 | 107 | $accountinfo = $this->session->userdata('accountinfo'); |
108 | - $reseller_id=$accountinfo['type']== -1 ? 0 : $accountinfo['id']; |
|
109 | - $this->db->where('reseller_id',$reseller_id); |
|
108 | + $reseller_id = $accountinfo['type'] == -1 ? 0 : $accountinfo['id']; |
|
109 | + $this->db->where('reseller_id', $reseller_id); |
|
110 | 110 | $this->db->select('id'); |
111 | - $result=$this->db->get('accounts'); |
|
111 | + $result = $this->db->get('accounts'); |
|
112 | 112 | $this->db_model->build_search('package_list_search'); |
113 | - if($this->session->userdata('advance_search')!= 1){ |
|
114 | - if($result->num_rows() >0){ |
|
115 | - $acc_arr=array(); |
|
116 | - $result=$result->result_array(); |
|
117 | - foreach($result as $data){ |
|
118 | - $acc_arr[]=$data['id']; |
|
113 | + if ($this->session->userdata('advance_search') != 1) { |
|
114 | + if ($result->num_rows() > 0) { |
|
115 | + $acc_arr = array(); |
|
116 | + $result = $result->result_array(); |
|
117 | + foreach ($result as $data) { |
|
118 | + $acc_arr[] = $data['id']; |
|
119 | 119 | } |
120 | - $this->db->where_in('accountid',$acc_arr); |
|
121 | - if($flag){ |
|
120 | + $this->db->where_in('accountid', $acc_arr); |
|
121 | + if ($flag) { |
|
122 | 122 | $this->db->select('*'); |
123 | 123 | } |
124 | - else{ |
|
124 | + else { |
|
125 | 125 | $this->db->select('count(id) as count'); |
126 | 126 | } |
127 | - if($flag){ |
|
127 | + if ($flag) { |
|
128 | 128 | $this->db->limit($limit, $start); |
129 | 129 | } |
130 | - if (isset($_GET['sortname']) && $_GET['sortname'] != 'undefined'){ |
|
131 | - $this->db->order_by($_GET['sortname'], ($_GET['sortorder']=='undefined')?'desc':$_GET['sortorder']); |
|
132 | - }else{ |
|
133 | - $this->db->order_by('seconds','desc'); |
|
130 | + if (isset($_GET['sortname']) && $_GET['sortname'] != 'undefined') { |
|
131 | + $this->db->order_by($_GET['sortname'], ($_GET['sortorder'] == 'undefined') ? 'desc' : $_GET['sortorder']); |
|
132 | + } else { |
|
133 | + $this->db->order_by('seconds', 'desc'); |
|
134 | 134 | } |
135 | - $result=$this->db->get('counters'); |
|
135 | + $result = $this->db->get('counters'); |
|
136 | 136 | // echo $this->db->last_query();exit; |
137 | - if($flag){ |
|
137 | + if ($flag) { |
|
138 | 138 | return $result; |
139 | - }else{ |
|
140 | - $result=$result->result_array(); |
|
139 | + } else { |
|
140 | + $result = $result->result_array(); |
|
141 | 141 | return $result[0]['count']; |
142 | 142 | } |
143 | - }else{ |
|
144 | - if($flag){ |
|
145 | - $query=(object)array('num_rows'=>0); |
|
143 | + } else { |
|
144 | + if ($flag) { |
|
145 | + $query = (object)array('num_rows'=>0); |
|
146 | 146 | } |
147 | - else{ |
|
148 | - $query=0; |
|
147 | + else { |
|
148 | + $query = 0; |
|
149 | 149 | } |
150 | 150 | return $query; |
151 | 151 | } |
152 | - }else{ |
|
152 | + } else { |
|
153 | 153 | |
154 | - if($result->num_rows() >0){ |
|
155 | - $acc_arr=array(); |
|
156 | - $result=$result->result_array(); |
|
157 | - foreach($result as $data){ |
|
158 | - $acc_arr[]=$data['id']; |
|
154 | + if ($result->num_rows() > 0) { |
|
155 | + $acc_arr = array(); |
|
156 | + $result = $result->result_array(); |
|
157 | + foreach ($result as $data) { |
|
158 | + $acc_arr[] = $data['id']; |
|
159 | 159 | } |
160 | - $this->db->where_in('accountid',$acc_arr); |
|
160 | + $this->db->where_in('accountid', $acc_arr); |
|
161 | 161 | } |
162 | 162 | |
163 | - if($flag){ |
|
163 | + if ($flag) { |
|
164 | 164 | $this->db->select('*'); |
165 | 165 | } |
166 | - else{ |
|
166 | + else { |
|
167 | 167 | $this->db->select('count(id) as count'); |
168 | 168 | } |
169 | - if($flag){ |
|
170 | - $this->db->order_by('seconds','desc'); |
|
169 | + if ($flag) { |
|
170 | + $this->db->order_by('seconds', 'desc'); |
|
171 | 171 | $this->db->limit($limit, $start); |
172 | 172 | } |
173 | - $result=$this->db->get('counters'); |
|
173 | + $result = $this->db->get('counters'); |
|
174 | 174 | // echo $this->db->last_query();exit; |
175 | - if($result->num_rows() > 0){ |
|
176 | - if($flag){ |
|
175 | + if ($result->num_rows() > 0) { |
|
176 | + if ($flag) { |
|
177 | 177 | |
178 | 178 | return $result; |
179 | - }else{ |
|
180 | - $result=$result->result_array(); |
|
179 | + } else { |
|
180 | + $result = $result->result_array(); |
|
181 | 181 | |
182 | 182 | return $result[0]['count']; |
183 | 183 | } |
184 | - }else{ |
|
185 | - if($flag){ |
|
184 | + } else { |
|
185 | + if ($flag) { |
|
186 | 186 | |
187 | - $query=(object)array('num_rows'=>0); |
|
187 | + $query = (object)array('num_rows'=>0); |
|
188 | 188 | } |
189 | - else{ |
|
190 | - $query=0; |
|
189 | + else { |
|
190 | + $query = 0; |
|
191 | 191 | } |
192 | 192 | // echo $this->db->last_query();exit; |
193 | 193 | return $query; |
@@ -199,7 +199,7 @@ discard block |
||
199 | 199 | //echo "<pre>"; prit_r($data); exit; |
200 | 200 | $this->db->select("pattern,comment"); |
201 | 201 | $this->db->where("id IN (".$data.")"); |
202 | - $result=$this->db->get("routes")->result_array(); |
|
202 | + $result = $this->db->get("routes")->result_array(); |
|
203 | 203 | |
204 | 204 | $tmp = array(); |
205 | 205 | foreach ($result as $key => $data_value) { |
@@ -50,11 +50,12 @@ discard block |
||
50 | 50 | $this->db->select('pricelist_id'); |
51 | 51 | $account_info=(array)$this->db->get('accounts')->first_row(); |
52 | 52 | $where=array('pricelist_id'=>$account_info['pricelist_id']); |
53 | - if(!empty($like_str)) |
|
54 | - $this->db->where($like_str); |
|
53 | + if(!empty($like_str)) { |
|
54 | + $this->db->where($like_str); |
|
55 | + } |
|
55 | 56 | if ($flag) { |
56 | 57 | $query = $this->db_model->select("*", "packages", $where, "id", "ASC", $limit, $start); |
57 | - }else { |
|
58 | + } else { |
|
58 | 59 | $query = $this->db_model->countQuery("*", "packages", $where); |
59 | 60 | } |
60 | 61 | return $query; |
@@ -120,8 +121,7 @@ discard block |
||
120 | 121 | $this->db->where_in('accountid',$acc_arr); |
121 | 122 | if($flag){ |
122 | 123 | $this->db->select('*'); |
123 | - } |
|
124 | - else{ |
|
124 | + } else{ |
|
125 | 125 | $this->db->select('count(id) as count'); |
126 | 126 | } |
127 | 127 | if($flag){ |
@@ -129,27 +129,26 @@ discard block |
||
129 | 129 | } |
130 | 130 | if (isset($_GET['sortname']) && $_GET['sortname'] != 'undefined'){ |
131 | 131 | $this->db->order_by($_GET['sortname'], ($_GET['sortorder']=='undefined')?'desc':$_GET['sortorder']); |
132 | - }else{ |
|
132 | + } else{ |
|
133 | 133 | $this->db->order_by('seconds','desc'); |
134 | 134 | } |
135 | 135 | $result=$this->db->get('counters'); |
136 | 136 | // echo $this->db->last_query();exit; |
137 | 137 | if($flag){ |
138 | 138 | return $result; |
139 | - }else{ |
|
139 | + } else{ |
|
140 | 140 | $result=$result->result_array(); |
141 | 141 | return $result[0]['count']; |
142 | 142 | } |
143 | - }else{ |
|
143 | + } else{ |
|
144 | 144 | if($flag){ |
145 | 145 | $query=(object)array('num_rows'=>0); |
146 | - } |
|
147 | - else{ |
|
146 | + } else{ |
|
148 | 147 | $query=0; |
149 | 148 | } |
150 | 149 | return $query; |
151 | 150 | } |
152 | - }else{ |
|
151 | + } else{ |
|
153 | 152 | |
154 | 153 | if($result->num_rows() >0){ |
155 | 154 | $acc_arr=array(); |
@@ -162,8 +161,7 @@ discard block |
||
162 | 161 | |
163 | 162 | if($flag){ |
164 | 163 | $this->db->select('*'); |
165 | - } |
|
166 | - else{ |
|
164 | + } else{ |
|
167 | 165 | $this->db->select('count(id) as count'); |
168 | 166 | } |
169 | 167 | if($flag){ |
@@ -176,17 +174,16 @@ discard block |
||
176 | 174 | if($flag){ |
177 | 175 | |
178 | 176 | return $result; |
179 | - }else{ |
|
177 | + } else{ |
|
180 | 178 | $result=$result->result_array(); |
181 | 179 | |
182 | 180 | return $result[0]['count']; |
183 | 181 | } |
184 | - }else{ |
|
182 | + } else{ |
|
185 | 183 | if($flag){ |
186 | 184 | |
187 | 185 | $query=(object)array('num_rows'=>0); |
188 | - } |
|
189 | - else{ |
|
186 | + } else{ |
|
190 | 187 | $query=0; |
191 | 188 | } |
192 | 189 | // echo $this->db->last_query();exit; |
@@ -35,7 +35,7 @@ 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 | |
@@ -66,12 +66,12 @@ discard block |
||
66 | 66 | |
67 | 67 | echo json_encode($json_data); |
68 | 68 | } |
69 | - function package_list_reseller($accountid,$accounttype){ |
|
69 | + function package_list_reseller($accountid, $accounttype) { |
|
70 | 70 | $json_data = array(); |
71 | - $count_all = $this->package_model->get_reseller_package_list(false,$accountid,$accounttype); |
|
71 | + $count_all = $this->package_model->get_reseller_package_list(false, $accountid, $accounttype); |
|
72 | 72 | $paging_data = $this->form->load_grid_config($count_all, $_GET['rp'], $_GET['page']); |
73 | 73 | $json_data = $paging_data["json_paging"]; |
74 | - $query = $this->package_model->get_reseller_package_list(true,$accountid,$accounttype,$paging_data["paging"]["start"], $paging_data["paging"]["page_no"]); |
|
74 | + $query = $this->package_model->get_reseller_package_list(true, $accountid, $accounttype, $paging_data["paging"]["start"], $paging_data["paging"]["page_no"]); |
|
75 | 75 | $grid_fields = json_decode($this->package_form->build_package_list_for_reseller()); |
76 | 76 | $json_data['rows'] = $this->form->build_grid($query, $grid_fields); |
77 | 77 | echo json_encode($json_data); |
@@ -87,7 +87,7 @@ discard block |
||
87 | 87 | $this->session->set_userdata('package_list_search', $action); |
88 | 88 | } |
89 | 89 | if (@$ajax_search != 1) { |
90 | - redirect(base_url() . 'package/package_list/'); |
|
90 | + redirect(base_url().'package/package_list/'); |
|
91 | 91 | } |
92 | 92 | } |
93 | 93 | |
@@ -105,30 +105,30 @@ discard block |
||
105 | 105 | function package_edit($edit_id = '') { |
106 | 106 | $data['page_title'] = 'Package Details'; |
107 | 107 | $accountinfo = $this->session->userdata("accountinfo"); |
108 | - $reseller_id=$accountinfo['type'] == 1 ? $accountinfo['id']:0; |
|
109 | - $package_result = $this->db_model->getSelect("*", " packages", array('id' => $edit_id,"reseller_id"=>$reseller_id)); |
|
108 | + $reseller_id = $accountinfo['type'] == 1 ? $accountinfo['id'] : 0; |
|
109 | + $package_result = $this->db_model->getSelect("*", " packages", array('id' => $edit_id, "reseller_id"=>$reseller_id)); |
|
110 | 110 | if ($package_result->num_rows > 0) { |
111 | - $package_info=(array)$package_result->first_row(); |
|
111 | + $package_info = (array)$package_result->first_row(); |
|
112 | 112 | $data['form'] = $this->form->build_form($this->package_form->get_package_form_fields($package_info['id']), $package_info); |
113 | - $data['edit_id']=$package_info['id']; |
|
113 | + $data['edit_id'] = $package_info['id']; |
|
114 | 114 | $this->load->view('view_packages_edit', $data); |
115 | 115 | } else { |
116 | - redirect(base_url() . 'package/package_list/'); |
|
116 | + redirect(base_url().'package/package_list/'); |
|
117 | 117 | } |
118 | 118 | } |
119 | 119 | |
120 | - function package_save($id="") { |
|
120 | + function package_save($id = "") { |
|
121 | 121 | $add_array = $this->input->post(); |
122 | 122 | $data['form'] = $this->form->build_form($this->package_form->get_package_form_fields($add_array['id']), $add_array); |
123 | 123 | if ($add_array['id'] != '') { |
124 | 124 | if ($this->form_validation->run() == FALSE) { |
125 | - $data['edit_id']= $add_array['id']; |
|
125 | + $data['edit_id'] = $add_array['id']; |
|
126 | 126 | $data['validation_errors'] = validation_errors(); |
127 | 127 | $this->load->view('view_packages_edit', $data); |
128 | 128 | } else { |
129 | 129 | $this->package_model->edit_package($add_array, $add_array['id']); |
130 | 130 | $this->session->set_flashdata('astpp_errormsg', 'Package updated successfully!'); |
131 | - redirect(base_url() . 'package/package_list/'); |
|
131 | + redirect(base_url().'package/package_list/'); |
|
132 | 132 | exit; |
133 | 133 | } |
134 | 134 | } else { |
@@ -143,14 +143,14 @@ discard block |
||
143 | 143 | ASTPP 3.0 |
144 | 144 | For Email Broadcast when package is add |
145 | 145 | **/ |
146 | - $accountinfo = $this->db_model->getSelect("*", "accounts", array("pricelist_id" => $add_array['pricelist_id'],"status"=>0, "deleted"=>0)); |
|
146 | + $accountinfo = $this->db_model->getSelect("*", "accounts", array("pricelist_id" => $add_array['pricelist_id'], "status"=>0, "deleted"=>0)); |
|
147 | 147 | $accountinfo = $accountinfo->result_array(); |
148 | 148 | $this->session->set_flashdata('astpp_errormsg', 'Package added successfully!'); |
149 | - foreach($accountinfo as $key => $value){ |
|
149 | + foreach ($accountinfo as $key => $value) { |
|
150 | 150 | $this->common->mail_to_users('add_package', $value); |
151 | 151 | } |
152 | 152 | /**************************************/ |
153 | - redirect(base_url() . 'package/package_list/'); |
|
153 | + redirect(base_url().'package/package_list/'); |
|
154 | 154 | exit; |
155 | 155 | } |
156 | 156 | } |
@@ -166,14 +166,14 @@ discard block |
||
166 | 166 | $package_detail = $this->db_model->getSelect("*", "packages", array("id"=>$id)); |
167 | 167 | $package_detail = $package_detail->result_array(); |
168 | 168 | $package_detail = $package_detail[0]; |
169 | - $accountinfo = $this->db_model->getSelect("*", "accounts", array("pricelist_id" => $package_detail['pricelist_id'],"status"=>0, "deleted"=>0)); |
|
169 | + $accountinfo = $this->db_model->getSelect("*", "accounts", array("pricelist_id" => $package_detail['pricelist_id'], "status"=>0, "deleted"=>0)); |
|
170 | 170 | $this->package_model->remove_package($id); |
171 | 171 | $this->session->set_flashdata('astpp_notification', 'Package removed successfully!'); |
172 | - foreach($accountinfo->result_array() as $key => $value){ |
|
172 | + foreach ($accountinfo->result_array() as $key => $value) { |
|
173 | 173 | $this->common->mail_to_users('remove_package', $value); |
174 | 174 | } |
175 | 175 | /******************************************/ |
176 | - redirect(base_url() . 'package/package_list/'); |
|
176 | + redirect(base_url().'package/package_list/'); |
|
177 | 177 | } |
178 | 178 | |
179 | 179 | function package_delete_multiple() { |
@@ -183,28 +183,28 @@ discard block |
||
183 | 183 | echo $this->db->delete("packages"); |
184 | 184 | } |
185 | 185 | |
186 | - function package_pattern_list($package_id){ |
|
186 | + function package_pattern_list($package_id) { |
|
187 | 187 | $data['page_title'] = 'Package Codes'; |
188 | - if(!empty($package_id)){ |
|
188 | + if ( ! empty($package_id)) { |
|
189 | 189 | $data['grid_fields'] = $this->package_form->build_pattern_list_for_customer($package_id); |
190 | 190 | $data['grid_buttons'] = $this->package_form->set_pattern_grid_buttons($package_id); |
191 | 191 | $data["edit_id"] = $package_id; |
192 | - $this->load->view("view_package_pattern_list",$data); |
|
193 | - }else{ |
|
192 | + $this->load->view("view_package_pattern_list", $data); |
|
193 | + } else { |
|
194 | 194 | redirect(base_url()."package/package_list/"); |
195 | 195 | } |
196 | 196 | } |
197 | - function package_pattern_list_json($package_id){ |
|
197 | + function package_pattern_list_json($package_id) { |
|
198 | 198 | $json_data = array(); |
199 | - $instant_search=$this->session->userdata('left_panel_search_package_pattern'); |
|
200 | - $like_str=!empty($instant_search) ? "(patterns like '%$instant_search%' OR destination like '%$instant_search%' )" :null; |
|
201 | - if(!empty($like_str)) |
|
199 | + $instant_search = $this->session->userdata('left_panel_search_package_pattern'); |
|
200 | + $like_str = ! empty($instant_search) ? "(patterns like '%$instant_search%' OR destination like '%$instant_search%' )" : null; |
|
201 | + if ( ! empty($like_str)) |
|
202 | 202 | $this->db->where($like_str); |
203 | 203 | $where = array('package_id' => $package_id); |
204 | 204 | $count_all = $this->db_model->countQuery("*", "package_patterns", $where); |
205 | 205 | $paging_data = $this->form->load_grid_config($count_all, $_GET['rp'], $_GET['page']); |
206 | 206 | $json_data = $paging_data["json_paging"]; |
207 | - if(!empty($like_str)) |
|
207 | + if ( ! empty($like_str)) |
|
208 | 208 | $this->db->where($like_str); |
209 | 209 | $pattern_data = $this->db_model->select("*", "package_patterns", $where, "id", "ASC", $paging_data["paging"]["page_no"], $paging_data["paging"]["start"]); |
210 | 210 | |
@@ -237,11 +237,11 @@ discard block |
||
237 | 237 | |
238 | 238 | echo json_encode($json_data); |
239 | 239 | } |
240 | - function package_counter_report_export(){ |
|
240 | + function package_counter_report_export() { |
|
241 | 241 | $query = $this->db_model->getSelect("*", "counters", ''); |
242 | 242 | $outbound_array = array(); |
243 | 243 | ob_clean(); |
244 | - $outbound_array[] = array("Package Name", "Account", "Used Seconds"); |
|
244 | + $outbound_array[] = array("Package Name", "Account", "Used Seconds"); |
|
245 | 245 | if ($query->num_rows() > 0) { |
246 | 246 | |
247 | 247 | foreach ($query->result_array() as $row) { |
@@ -253,10 +253,10 @@ discard block |
||
253 | 253 | } |
254 | 254 | } |
255 | 255 | $this->load->helper('csv'); |
256 | - array_to_csv($outbound_array, 'Usage_Report_' . date("Y-m-d") . '.csv'); |
|
256 | + array_to_csv($outbound_array, 'Usage_Report_'.date("Y-m-d").'.csv'); |
|
257 | 257 | |
258 | 258 | } |
259 | - function package_pattern_json($package_id){ |
|
259 | + function package_pattern_json($package_id) { |
|
260 | 260 | $json_data = array(); |
261 | 261 | $where = array('package_id' => $package_id); |
262 | 262 | |
@@ -283,37 +283,37 @@ discard block |
||
283 | 283 | function package_patterns_add_json($accountid) { |
284 | 284 | $this->load->module('rates/rates'); |
285 | 285 | $json_data = array(); |
286 | - $count_all = $this->rates_model->getunblocked_package_pattern($accountid,false); |
|
286 | + $count_all = $this->rates_model->getunblocked_package_pattern($accountid, false); |
|
287 | 287 | $paging_data = $this->form->load_grid_config($count_all, $_GET['rp'], $_GET['page']); |
288 | 288 | $json_data = $paging_data["json_paging"]; |
289 | 289 | |
290 | - $query = $this->rates->rates_model->getunblocked_package_pattern($accountid,true, $paging_data["paging"]["start"], $paging_data["paging"]["page_no"]); |
|
290 | + $query = $this->rates->rates_model->getunblocked_package_pattern($accountid, true, $paging_data["paging"]["start"], $paging_data["paging"]["page_no"]); |
|
291 | 291 | $grid_fields = json_decode($this->rates->rates_form->build_block_pattern_list_for_customer()); |
292 | 292 | $json_data['rows'] = $this->rates->form->build_grid($query, $grid_fields); |
293 | 293 | |
294 | 294 | echo json_encode($json_data); |
295 | 295 | } |
296 | 296 | function package_patterns_add_info($packageid) { |
297 | - $result = $this->package_model->insert_package_pattern($this->input->post('prefixies', true),$packageid); |
|
297 | + $result = $this->package_model->insert_package_pattern($this->input->post('prefixies', true), $packageid); |
|
298 | 298 | unset($_POST); |
299 | 299 | echo $result; |
300 | 300 | exit; |
301 | 301 | } |
302 | 302 | function package_patterns_delete($packageid, $patternid) { |
303 | 303 | $this->db->delete("package_patterns", array("id" => $patternid)); |
304 | - redirect(base_url() . "package/package_pattern_list/$packageid"); |
|
304 | + redirect(base_url()."package/package_pattern_list/$packageid"); |
|
305 | 305 | } |
306 | - function package_patterns_selected_delete(){ |
|
306 | + function package_patterns_selected_delete() { |
|
307 | 307 | $ids = $this->input->post("selected_ids", true); |
308 | 308 | $where = "id IN ($ids)"; |
309 | 309 | unset($_POST); |
310 | - echo $this->db->delete("package_patterns",$where); |
|
310 | + echo $this->db->delete("package_patterns", $where); |
|
311 | 311 | } |
312 | 312 | |
313 | - function package_quick_search($module_name){ |
|
313 | + function package_quick_search($module_name) { |
|
314 | 314 | $action = $this->input->post(); |
315 | - $this->session->set_userdata('left_panel_search_package_pattern',""); |
|
316 | - if(!empty($action['left_panel_search'])){ |
|
315 | + $this->session->set_userdata('left_panel_search_package_pattern', ""); |
|
316 | + if ( ! empty($action['left_panel_search'])) { |
|
317 | 317 | $this->session->set_userdata('left_panel_search_package_pattern', $action['left_panel_search']); |
318 | 318 | } |
319 | 319 | } |
@@ -322,22 +322,22 @@ discard block |
||
322 | 322 | function package_patterns_import($edit_id) { |
323 | 323 | //echo "nick";exit; |
324 | 324 | $data['page_title'] = 'Import Package Patterns'; |
325 | - $this->session->set_userdata('import_package_code_csv',""); |
|
326 | - $error_data = $this->session->userdata('import_package_code_csv_error'); |
|
325 | + $this->session->set_userdata('import_package_code_csv', ""); |
|
326 | + $error_data = $this->session->userdata('import_package_code_csv_error'); |
|
327 | 327 | $full_path = $this->config->item('rates-file-path'); |
328 | - if(file_exists($full_path.$error_data) && $error_data != ""){ |
|
328 | + if (file_exists($full_path.$error_data) && $error_data != "") { |
|
329 | 329 | unlink($full_path.$error_data); |
330 | - $this->session->set_userdata('import_package_code_csv_error',""); |
|
330 | + $this->session->set_userdata('import_package_code_csv_error', ""); |
|
331 | 331 | } |
332 | 332 | $data['edit_id'] = $edit_id; |
333 | 333 | $this->load->view('view_import_package_code', $data); |
334 | 334 | } |
335 | 335 | |
336 | 336 | |
337 | - function package_patterns_download_sample_file($file_name){ |
|
337 | + function package_patterns_download_sample_file($file_name) { |
|
338 | 338 | $this->load->helper('download'); |
339 | 339 | $full_path = base_url()."assets/Rates_File/".$file_name.".csv"; |
340 | - $arrContextOptions=array( |
|
340 | + $arrContextOptions = array( |
|
341 | 341 | "ssl"=>array( |
342 | 342 | "verify_peer"=>false, |
343 | 343 | "verify_peer_name"=>false, |
@@ -348,75 +348,75 @@ discard block |
||
348 | 348 | } |
349 | 349 | |
350 | 350 | |
351 | - function package_patterns_preview_file($edit_id){ |
|
352 | - $invalid_flag= false; |
|
353 | - $data=array(); |
|
351 | + function package_patterns_preview_file($edit_id) { |
|
352 | + $invalid_flag = false; |
|
353 | + $data = array(); |
|
354 | 354 | $data['page_title'] = 'Import Package Patterns'; |
355 | - $check_header=$this->input->post('check_header',true); |
|
356 | - if(empty($_FILES) || !isset($_FILES)){ |
|
355 | + $check_header = $this->input->post('check_header', true); |
|
356 | + if (empty($_FILES) || ! isset($_FILES)) { |
|
357 | 357 | redirect(base_url()."package/package_pattern_list/"); |
358 | 358 | } |
359 | - $get_extension=strpos($_FILES['package_code_import']['name'],'.'); |
|
359 | + $get_extension = strpos($_FILES['package_code_import']['name'], '.'); |
|
360 | 360 | $new_final_arr_key = $this->config->item('package-code-field'); |
361 | - if(!$get_extension){ |
|
362 | - $data['error']= "Please Upload File Atleast"; |
|
361 | + if ( ! $get_extension) { |
|
362 | + $data['error'] = "Please Upload File Atleast"; |
|
363 | 363 | } |
364 | 364 | //echo "<pre>";print_r($_FILES);exit; |
365 | - if (isset($_FILES['package_code_import']['name']) && $_FILES['package_code_import']['name'] != "" ) { |
|
366 | - list($txt,$ext) = explode(".", $_FILES['package_code_import']['name']); |
|
365 | + if (isset($_FILES['package_code_import']['name']) && $_FILES['package_code_import']['name'] != "") { |
|
366 | + list($txt, $ext) = explode(".", $_FILES['package_code_import']['name']); |
|
367 | 367 | |
368 | - if($ext == "csv" && $_FILES['package_code_import']['size'] > 0){ |
|
368 | + if ($ext == "csv" && $_FILES['package_code_import']['size'] > 0) { |
|
369 | 369 | $error = $_FILES['package_code_import']['error']; |
370 | 370 | if ($error == 0) { |
371 | 371 | $uploadedFile = $_FILES["package_code_import"]["tmp_name"]; |
372 | - $csv_data=$this->csvreader->parse_file($uploadedFile,$new_final_arr_key,$check_header); |
|
373 | - if(!empty($csv_data)){ |
|
372 | + $csv_data = $this->csvreader->parse_file($uploadedFile, $new_final_arr_key, $check_header); |
|
373 | + if ( ! empty($csv_data)) { |
|
374 | 374 | $full_path = $this->config->item('rates-file-path'); |
375 | 375 | //echo "<pre>";print_r($full_path);exit; |
376 | - $actual_file_name = "ASTPP-ORIGIN-RATES-".date("Y-m-d H:i:s"). "." . $ext; |
|
376 | + $actual_file_name = "ASTPP-ORIGIN-RATES-".date("Y-m-d H:i:s").".".$ext; |
|
377 | 377 | //echo "<pre>";print_r($actual_file_name);exit; |
378 | - if (move_uploaded_file($uploadedFile,$full_path.$actual_file_name)) { |
|
379 | - $flag=false; |
|
378 | + if (move_uploaded_file($uploadedFile, $full_path.$actual_file_name)) { |
|
379 | + $flag = false; |
|
380 | 380 | //$data['trunkid']=isset($_POST['trunk_id']) && $_POST['trunk_id'] > 0 ? $_POST['trunk_id'] : 0; |
381 | 381 | $data['csv_tmp_data'] = $csv_data; |
382 | 382 | //$data['pricelistid'] = $_POST['pricelist_id']; |
383 | 383 | $data['page_title'] = "Package Patterns Preview"; |
384 | - $data['check_header']=$check_header; |
|
385 | - $this->session->set_userdata('import_package_code_csv',$actual_file_name); |
|
386 | - }else{ |
|
384 | + $data['check_header'] = $check_header; |
|
385 | + $this->session->set_userdata('import_package_code_csv', $actual_file_name); |
|
386 | + } else { |
|
387 | 387 | $data['error'] = "File Uploading Fail Please Try Again"; |
388 | 388 | } |
389 | 389 | } |
390 | 390 | } |
391 | - else{ |
|
392 | - $data['error']=="File Uploading Fail Please Try Again"; |
|
391 | + else { |
|
392 | + $data['error'] == "File Uploading Fail Please Try Again"; |
|
393 | 393 | } |
394 | 394 | } |
395 | 395 | else { |
396 | 396 | $data['error'] = "Invalid file format : Only CSV file allows to import records(Can't import empty file)"; |
397 | 397 | } |
398 | - }else{ |
|
399 | - $invalid_flag=true; |
|
398 | + } else { |
|
399 | + $invalid_flag = true; |
|
400 | 400 | } |
401 | 401 | if ($invalid_flag) { |
402 | 402 | $str = ''; |
403 | 403 | if (empty($_FILES['package_code_import']['name'])) { |
404 | - $str.= '<br/>Please Select File.'; |
|
404 | + $str .= '<br/>Please Select File.'; |
|
405 | 405 | } |
406 | - $data['error']=$str; |
|
406 | + $data['error'] = $str; |
|
407 | 407 | } |
408 | 408 | $data['edit_id'] = $edit_id; |
409 | 409 | $this->load->view('view_import_package_code', $data); |
410 | 410 | } |
411 | 411 | |
412 | 412 | |
413 | - function package_patterns_import_file($edit_id,$check_header=false) { |
|
413 | + function package_patterns_import_file($edit_id, $check_header = false) { |
|
414 | 414 | //echo $edit_id."===="; exit; |
415 | 415 | $new_final_arr = array(); |
416 | 416 | $invalid_array = array(); |
417 | 417 | $new_final_arr_key = $this->config->item('package-code-field'); |
418 | 418 | $screen_path = $this->config->item('screen_path'); |
419 | - $reseller_id=0; |
|
419 | + $reseller_id = 0; |
|
420 | 420 | if ($this->session->userdata('logintype') == 1 || $this->session->userdata('logintype') == 5) { |
421 | 421 | $reseller_id = $this->session->userdata["accountinfo"]['id']; |
422 | 422 | } |
@@ -424,113 +424,113 @@ discard block |
||
424 | 424 | $full_path = $this->config->item('rates-file-path'); |
425 | 425 | //echo "<pre>";print_r($full_path);exit; |
426 | 426 | $originationrate_file_name = $this->session->userdata('import_package_code_csv'); |
427 | - $csv_tmp_data = $this->csvreader->parse_file($full_path.$originationrate_file_name,$new_final_arr_key,$check_header); |
|
427 | + $csv_tmp_data = $this->csvreader->parse_file($full_path.$originationrate_file_name, $new_final_arr_key, $check_header); |
|
428 | 428 | //echo "<pre>";print_r($csv_tmp_data);exit; |
429 | - $i=0; |
|
430 | - $pattern_arr=array(); |
|
429 | + $i = 0; |
|
430 | + $pattern_arr = array(); |
|
431 | 431 | foreach ($csv_tmp_data as $key => $csv_data) { |
432 | - if(isset($csv_data['patterns']) && $csv_data['patterns']!= '' && $i != 0){ |
|
433 | - $str=null; |
|
434 | - $pattern=$csv_data['patterns']; |
|
435 | - if(!in_array($csv_data['patterns'],$pattern_arr)){ |
|
432 | + if (isset($csv_data['patterns']) && $csv_data['patterns'] != '' && $i != 0) { |
|
433 | + $str = null; |
|
434 | + $pattern = $csv_data['patterns']; |
|
435 | + if ( ! in_array($csv_data['patterns'], $pattern_arr)) { |
|
436 | 436 | $this->db->select('count(id) as count'); |
437 | - $this->db->where('patterns',"^".$csv_data['patterns'].".*"); |
|
438 | - $this->db->where('package_id',$edit_id); |
|
439 | - $pattern_res=(array)$this->db->get('package_patterns')->first_row(); |
|
440 | - if($pattern_res['count'] ==0){ |
|
441 | - $csv_data['destination']= isset($csv_data['destination'])? $csv_data['destination'] :''; |
|
442 | - $str=$this->data_validate($csv_data); |
|
443 | - if($str != ""){ |
|
444 | - $invalid_array[$i]=$csv_data; |
|
437 | + $this->db->where('patterns', "^".$csv_data['patterns'].".*"); |
|
438 | + $this->db->where('package_id', $edit_id); |
|
439 | + $pattern_res = (array)$this->db->get('package_patterns')->first_row(); |
|
440 | + if ($pattern_res['count'] == 0) { |
|
441 | + $csv_data['destination'] = isset($csv_data['destination']) ? $csv_data['destination'] : ''; |
|
442 | + $str = $this->data_validate($csv_data); |
|
443 | + if ($str != "") { |
|
444 | + $invalid_array[$i] = $csv_data; |
|
445 | 445 | $invalid_array[$i]['error'] = $str; |
446 | 446 | } |
447 | - else{ |
|
448 | - $csv_data['patterns'] = "^" . $csv_data['patterns'] . ".*"; |
|
447 | + else { |
|
448 | + $csv_data['patterns'] = "^".$csv_data['patterns'].".*"; |
|
449 | 449 | $csv_data['package_id'] = $edit_id; |
450 | - $new_final_arr[$i]=$csv_data; |
|
451 | - $pattern_arr[$csv_data['patterns']]=$csv_data['patterns']; |
|
450 | + $new_final_arr[$i] = $csv_data; |
|
451 | + $pattern_arr[$csv_data['patterns']] = $csv_data['patterns']; |
|
452 | 452 | } |
453 | - }else{ |
|
454 | - $invalid_array[$i]=$csv_data; |
|
453 | + } else { |
|
454 | + $invalid_array[$i] = $csv_data; |
|
455 | 455 | $invalid_array[$i]['error'] = "Duplicate pattern found from database."; |
456 | 456 | } |
457 | - }else{ |
|
458 | - $invalid_array[$i]=$csv_data; |
|
457 | + } else { |
|
458 | + $invalid_array[$i] = $csv_data; |
|
459 | 459 | $invalid_array[$i]['error'] = "Duplicate pattern found from import file"; |
460 | 460 | } |
461 | - $pattern_arr[$csv_data['patterns']]=$pattern; |
|
461 | + $pattern_arr[$csv_data['patterns']] = $pattern; |
|
462 | 462 | } |
463 | 463 | |
464 | 464 | $i++; |
465 | 465 | } |
466 | - if(!empty($new_final_arr)){ |
|
466 | + if ( ! empty($new_final_arr)) { |
|
467 | 467 | $result = $this->package_model->bulk_insert_package_pattern($new_final_arr); |
468 | 468 | } |
469 | 469 | //unlink($full_path.$originationrate_file_name); |
470 | - $count=count($invalid_array); |
|
470 | + $count = count($invalid_array); |
|
471 | 471 | //echo "<pre>";print_r($count);exit; |
472 | - if($count >0){ |
|
472 | + if ($count > 0) { |
|
473 | 473 | $session_id = "-1"; |
474 | 474 | $fp = fopen($full_path.$session_id.'.csv', 'w'); |
475 | - foreach($new_final_arr_key as $key=>$value){ |
|
476 | - $custom_array[0][$key]=ucfirst($key); |
|
475 | + foreach ($new_final_arr_key as $key=>$value) { |
|
476 | + $custom_array[0][$key] = ucfirst($key); |
|
477 | 477 | } |
478 | - $custom_array[0]['error']= "Error"; |
|
479 | - $invalid_array =array_merge($custom_array,$invalid_array); |
|
480 | - foreach($invalid_array as $err_data){ |
|
481 | - fputcsv($fp,$err_data); |
|
478 | + $custom_array[0]['error'] = "Error"; |
|
479 | + $invalid_array = array_merge($custom_array, $invalid_array); |
|
480 | + foreach ($invalid_array as $err_data) { |
|
481 | + fputcsv($fp, $err_data); |
|
482 | 482 | } |
483 | 483 | fclose($fp); |
484 | 484 | $this->session->set_userdata('import_package_code_csv_error', $session_id.".csv"); |
485 | 485 | $data["error"] = $invalid_array; |
486 | 486 | $data['packageid'] = $edit_id; |
487 | 487 | $data['impoted_count'] = count($new_final_arr); |
488 | - $data['failure_count'] = count($invalid_array)-1; |
|
488 | + $data['failure_count'] = count($invalid_array) - 1; |
|
489 | 489 | $data['page_title'] = 'Package Patterns Import Error'; |
490 | 490 | //print_r($data) ;exit; |
491 | - $this->load->view('view_import_error',$data); |
|
492 | - } else{ |
|
491 | + $this->load->view('view_import_error', $data); |
|
492 | + } else { |
|
493 | 493 | $this->session->set_flashdata('astpp_errormsg', 'Package patterns imported successfully!'); |
494 | 494 | //echo base_url()."package/package_pattern_list/" . $edit_id . "/";exit; |
495 | - redirect(base_url()."package/package_pattern_list/" . $edit_id . "/"); |
|
495 | + redirect(base_url()."package/package_pattern_list/".$edit_id."/"); |
|
496 | 496 | } |
497 | 497 | } |
498 | 498 | |
499 | - function data_validate($csvdata){ |
|
500 | - $str=null; |
|
499 | + function data_validate($csvdata) { |
|
500 | + $str = null; |
|
501 | 501 | $alpha_regex = "/^[a-z ,.'-]+$/i"; |
502 | 502 | $alpha_numeric_regex = "/^[a-z0-9 ,.'-]+$/i"; |
503 | 503 | $email_regex = "/^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$/"; |
504 | - $str.= $csvdata['patterns']!= '' ? null : 'Code,'; |
|
505 | - $str=rtrim($str,','); |
|
506 | - if(!$str){ |
|
507 | - $str.= is_numeric($csvdata['patterns']) ? null : 'Code,'; |
|
504 | + $str .= $csvdata['patterns'] != '' ? null : 'Code,'; |
|
505 | + $str = rtrim($str, ','); |
|
506 | + if ( ! $str) { |
|
507 | + $str .= is_numeric($csvdata['patterns']) ? null : 'Code,'; |
|
508 | 508 | |
509 | - $str.= preg_match( $alpha_numeric_regex, $csvdata['destination'] ) ? null :'Destination,'; |
|
509 | + $str .= preg_match($alpha_numeric_regex, $csvdata['destination']) ? null : 'Destination,'; |
|
510 | 510 | |
511 | - if($str){ |
|
512 | - $str=rtrim($str,','); |
|
513 | - $error_field=explode(',',$str); |
|
511 | + if ($str) { |
|
512 | + $str = rtrim($str, ','); |
|
513 | + $error_field = explode(',', $str); |
|
514 | 514 | $count = count($error_field); |
515 | - $str.= $count > 1 ? ' are not valid' : ' is not Valid'; |
|
515 | + $str .= $count > 1 ? ' are not valid' : ' is not Valid'; |
|
516 | 516 | return $str; |
517 | 517 | } |
518 | - else{ |
|
518 | + else { |
|
519 | 519 | return false; |
520 | 520 | } |
521 | 521 | } |
522 | - else{ |
|
523 | - $str=rtrim($str,','); |
|
524 | - $error_field=explode(',',$str); |
|
522 | + else { |
|
523 | + $str = rtrim($str, ','); |
|
524 | + $error_field = explode(',', $str); |
|
525 | 525 | $count = count($error_field); |
526 | - $str.= $count > 1 ? ' are required' : ' is Required'; |
|
526 | + $str .= $count > 1 ? ' are required' : ' is Required'; |
|
527 | 527 | return $str; |
528 | 528 | } |
529 | 529 | } |
530 | 530 | |
531 | - function package_patterns_error_download(){ |
|
531 | + function package_patterns_error_download() { |
|
532 | 532 | $this->load->helper('download'); |
533 | - $error_data = $this->session->userdata('import_package_code_csv_error'); |
|
533 | + $error_data = $this->session->userdata('import_package_code_csv_error'); |
|
534 | 534 | $full_path = $this->config->item('rates-file-path'); |
535 | 535 | $data = file_get_contents($full_path.$error_data); |
536 | 536 | force_download("Package_Code_error.csv", $data); |
@@ -34,8 +34,9 @@ discard block |
||
34 | 34 | $this->load->model('package_model'); |
35 | 35 | $this->load->library('csvreader'); |
36 | 36 | |
37 | - if ($this->session->userdata('user_login') == FALSE) |
|
38 | - redirect(base_url() . '/astpp/login'); |
|
37 | + if ($this->session->userdata('user_login') == FALSE) { |
|
38 | + redirect(base_url() . '/astpp/login'); |
|
39 | + } |
|
39 | 40 | } |
40 | 41 | |
41 | 42 | |
@@ -190,7 +191,7 @@ discard block |
||
190 | 191 | $data['grid_buttons'] = $this->package_form->set_pattern_grid_buttons($package_id); |
191 | 192 | $data["edit_id"] = $package_id; |
192 | 193 | $this->load->view("view_package_pattern_list",$data); |
193 | - }else{ |
|
194 | + } else{ |
|
194 | 195 | redirect(base_url()."package/package_list/"); |
195 | 196 | } |
196 | 197 | } |
@@ -198,14 +199,16 @@ discard block |
||
198 | 199 | $json_data = array(); |
199 | 200 | $instant_search=$this->session->userdata('left_panel_search_package_pattern'); |
200 | 201 | $like_str=!empty($instant_search) ? "(patterns like '%$instant_search%' OR destination like '%$instant_search%' )" :null; |
201 | - if(!empty($like_str)) |
|
202 | - $this->db->where($like_str); |
|
202 | + if(!empty($like_str)) { |
|
203 | + $this->db->where($like_str); |
|
204 | + } |
|
203 | 205 | $where = array('package_id' => $package_id); |
204 | 206 | $count_all = $this->db_model->countQuery("*", "package_patterns", $where); |
205 | 207 | $paging_data = $this->form->load_grid_config($count_all, $_GET['rp'], $_GET['page']); |
206 | 208 | $json_data = $paging_data["json_paging"]; |
207 | - if(!empty($like_str)) |
|
208 | - $this->db->where($like_str); |
|
209 | + if(!empty($like_str)) { |
|
210 | + $this->db->where($like_str); |
|
211 | + } |
|
209 | 212 | $pattern_data = $this->db_model->select("*", "package_patterns", $where, "id", "ASC", $paging_data["paging"]["page_no"], $paging_data["paging"]["start"]); |
210 | 213 | |
211 | 214 | $grid_fields = json_decode($this->package_form->build_pattern_list_for_customer($package_id)); |
@@ -383,19 +386,17 @@ discard block |
||
383 | 386 | $data['page_title'] = "Package Patterns Preview"; |
384 | 387 | $data['check_header']=$check_header; |
385 | 388 | $this->session->set_userdata('import_package_code_csv',$actual_file_name); |
386 | - }else{ |
|
389 | + } else{ |
|
387 | 390 | $data['error'] = "File Uploading Fail Please Try Again"; |
388 | 391 | } |
389 | 392 | } |
390 | - } |
|
391 | - else{ |
|
393 | + } else{ |
|
392 | 394 | $data['error']=="File Uploading Fail Please Try Again"; |
393 | 395 | } |
394 | - } |
|
395 | - else { |
|
396 | + } else { |
|
396 | 397 | $data['error'] = "Invalid file format : Only CSV file allows to import records(Can't import empty file)"; |
397 | 398 | } |
398 | - }else{ |
|
399 | + } else{ |
|
399 | 400 | $invalid_flag=true; |
400 | 401 | } |
401 | 402 | if ($invalid_flag) { |
@@ -443,18 +444,17 @@ discard block |
||
443 | 444 | if($str != ""){ |
444 | 445 | $invalid_array[$i]=$csv_data; |
445 | 446 | $invalid_array[$i]['error'] = $str; |
446 | - } |
|
447 | - else{ |
|
447 | + } else{ |
|
448 | 448 | $csv_data['patterns'] = "^" . $csv_data['patterns'] . ".*"; |
449 | 449 | $csv_data['package_id'] = $edit_id; |
450 | 450 | $new_final_arr[$i]=$csv_data; |
451 | 451 | $pattern_arr[$csv_data['patterns']]=$csv_data['patterns']; |
452 | 452 | } |
453 | - }else{ |
|
453 | + } else{ |
|
454 | 454 | $invalid_array[$i]=$csv_data; |
455 | 455 | $invalid_array[$i]['error'] = "Duplicate pattern found from database."; |
456 | 456 | } |
457 | - }else{ |
|
457 | + } else{ |
|
458 | 458 | $invalid_array[$i]=$csv_data; |
459 | 459 | $invalid_array[$i]['error'] = "Duplicate pattern found from import file"; |
460 | 460 | } |
@@ -514,12 +514,10 @@ discard block |
||
514 | 514 | $count = count($error_field); |
515 | 515 | $str.= $count > 1 ? ' are not valid' : ' is not Valid'; |
516 | 516 | return $str; |
517 | - } |
|
518 | - else{ |
|
517 | + } else{ |
|
519 | 518 | return false; |
520 | 519 | } |
521 | - } |
|
522 | - else{ |
|
520 | + } else{ |
|
523 | 521 | $str=rtrim($str,','); |
524 | 522 | $error_field=explode(',',$str); |
525 | 523 | $count = count($error_field); |
@@ -22,19 +22,19 @@ discard block |
||
22 | 22 | # along with this program. If not, see <http://www.gnu.org/licenses/>. |
23 | 23 | ############################################################################### |
24 | 24 | |
25 | -if (!defined('BASEPATH')) |
|
25 | +if ( ! defined('BASEPATH')) |
|
26 | 26 | exit('No direct script access allowed'); |
27 | 27 | |
28 | 28 | class Package_form { |
29 | 29 | |
30 | - function get_package_form_fields($id='') { |
|
31 | - $form['forms'] = array(base_url() . 'package/package_save/'.$id."/",array('id'=>'packeage_form','method'=>'POST','name'=>'packeage_form')); |
|
30 | + function get_package_form_fields($id = '') { |
|
31 | + $form['forms'] = array(base_url().'package/package_save/'.$id."/", array('id'=>'packeage_form', 'method'=>'POST', 'name'=>'packeage_form')); |
|
32 | 32 | $form['Package Information'] = array( |
33 | 33 | array('', 'HIDDEN', array('name' => 'id'), '', '', '', ''), |
34 | 34 | array('', 'HIDDEN', array('name' => 'status', 'value' => '1'), '', '', ''), |
35 | - array('Name', 'INPUT', array('name' => 'package_name', 'size' => '20', 'class' => "text field medium"), 'trim|required|xss_clean', 'tOOL TIP', ''), |
|
36 | - array('Rate Group', 'pricelist_id', 'SELECT', '', 'dropdown', 'tOOL TIP', 'Please Enter account number', 'id', 'name', 'pricelists', 'build_dropdown', 'where_arr', array("status" => "0","reseller_id" => "0")), |
|
37 | - array('Included Seconds', 'INPUT', array('name' => 'includedseconds', 'size' => '20', 'class' => "text field medium"), 'trim|is_numeric|required|xss_clean', 'tOOL TIP', ''), |
|
35 | + array('Name', 'INPUT', array('name' => 'package_name', 'size' => '20', 'class' => "text field medium"), 'trim|required|xss_clean', 'tOOL TIP', ''), |
|
36 | + array('Rate Group', 'pricelist_id', 'SELECT', '', 'dropdown', 'tOOL TIP', 'Please Enter account number', 'id', 'name', 'pricelists', 'build_dropdown', 'where_arr', array("status" => "0", "reseller_id" => "0")), |
|
37 | + array('Included Seconds', 'INPUT', array('name' => 'includedseconds', 'size' => '20', 'class' => "text field medium"), 'trim|is_numeric|required|xss_clean', 'tOOL TIP', ''), |
|
38 | 38 | /** |
39 | 39 | ASTPP 3.0 |
40 | 40 | Add For Package Inbound or Outbound or both? |
@@ -53,13 +53,13 @@ discard block |
||
53 | 53 | $form['forms'] = array("", array('id' => "package_search")); |
54 | 54 | $form['Search'] = array( |
55 | 55 | array('Name', 'INPUT', array('name' => 'package_name[package_name]', '', 'size' => '20', 'class' => "text field"), '', 'tOOL TIP', '1', 'package_name[package_name-string]', '', '', '', 'search_string_type', ''), |
56 | - array('Rate Group', 'pricelist_id', 'SELECT', '', '', 'tOOL TIP', 'Please Enter account number', 'id', 'name', 'pricelists', 'build_dropdown', 'where_arr', array("status" => "0","reseller_id" => "0")), |
|
56 | + array('Rate Group', 'pricelist_id', 'SELECT', '', '', 'tOOL TIP', 'Please Enter account number', 'id', 'name', 'pricelists', 'build_dropdown', 'where_arr', array("status" => "0", "reseller_id" => "0")), |
|
57 | 57 | array('Included Seconds', 'INPUT', array('name' => 'includedseconds[includedseconds]', 'value' => '', 'size' => '20', 'class' => "text field"), '', 'Tool tips info', '1', 'includedseconds[includedseconds-integer]', '', '', '', 'search_int_type', ''), |
58 | 58 | /** |
59 | 59 | ASTPP 3.0 |
60 | 60 | Add For Package Inbound or Outbound or both? |
61 | 61 | **/ |
62 | - array('Applicable For?', 'applicable_for', 'SELECT', '', '', 'tOOL TIP', '', '', '', '', 'set_package_type', '',''), |
|
62 | + array('Applicable For?', 'applicable_for', 'SELECT', '', '', 'tOOL TIP', '', '', '', '', 'set_package_type', '', ''), |
|
63 | 63 | /*********************************************/ |
64 | 64 | array('Status', 'status', 'SELECT', '', '', 'tOOL TIP', 'Please Enter account number', '', '', '', 'set_search_status', '', ''), |
65 | 65 | |
@@ -75,28 +75,28 @@ discard block |
||
75 | 75 | |
76 | 76 | function build_package_list_for_admin() { |
77 | 77 | // array(display name, width, db_field_parent_table,feidname, db_field_child_table,function name); |
78 | - $grid_field_arr = json_encode(array(array("<input type='checkbox' name='chkAll' class='ace checkall'/><label class='lbl'></label>", "30", "", "", "", "","","false","center"), |
|
78 | + $grid_field_arr = json_encode(array(array("<input type='checkbox' name='chkAll' class='ace checkall'/><label class='lbl'></label>", "30", "", "", "", "", "", "false", "center"), |
|
79 | 79 | /** |
80 | 80 | ASTPP 3.0 |
81 | 81 | For Package edit on Name |
82 | 82 | **/ |
83 | - array("Name", "170", "package_name", "", "", "","EDITABLE","true","center"), |
|
83 | + array("Name", "170", "package_name", "", "", "", "EDITABLE", "true", "center"), |
|
84 | 84 | /***********************************/ |
85 | - array("Rate Group", "150", "pricelist_id", "name", "pricelists", "get_field_name","","true","center"), |
|
86 | - array("Included Seconds", "160", "includedseconds", "", "", "","","true","center"), |
|
85 | + array("Rate Group", "150", "pricelist_id", "name", "pricelists", "get_field_name", "", "true", "center"), |
|
86 | + array("Included Seconds", "160", "includedseconds", "", "", "", "", "true", "center"), |
|
87 | 87 | /** |
88 | 88 | ASTPP 3.0 |
89 | 89 | Add For Package Inbound or Outbound or both? |
90 | 90 | **/ |
91 | - array("Applicable For?", "200", "applicable_for", "applicable_for", "applicable_for", "get_package_type","","true","center"), |
|
91 | + array("Applicable For?", "200", "applicable_for", "applicable_for", "applicable_for", "get_package_type", "", "true", "center"), |
|
92 | 92 | /****************************************************/ |
93 | 93 | /* |
94 | 94 | ASTPP 3.0 |
95 | 95 | Creation date,last modified date show in grid |
96 | 96 | */ |
97 | - array("Status", "140", "status", "status", "packages", "get_status","","true","center"), |
|
98 | - array("Created Date", "120", "creation_date", "creation_date", "creation_date", "convert_GMT_to","","true","center"), |
|
99 | - array("Modified Date", "140", "last_modified_date", "last_modified_date", "last_modified_date", "convert_GMT_to","","true","center"), |
|
97 | + array("Status", "140", "status", "status", "packages", "get_status", "", "true", "center"), |
|
98 | + array("Created Date", "120", "creation_date", "creation_date", "creation_date", "convert_GMT_to", "", "true", "center"), |
|
99 | + array("Modified Date", "140", "last_modified_date", "last_modified_date", "last_modified_date", "convert_GMT_to", "", "true", "center"), |
|
100 | 100 | /***************************************************************/ |
101 | 101 | /* |
102 | 102 | ASTPP 3.0 |
@@ -111,7 +111,7 @@ discard block |
||
111 | 111 | } |
112 | 112 | |
113 | 113 | function build_grid_buttons() { |
114 | - $buttons_json = json_encode(array(array("Create","btn btn-line-warning btn","fa fa-plus-circle fa-lg", "button_action", "/package/package_add/"), |
|
114 | + $buttons_json = json_encode(array(array("Create", "btn btn-line-warning btn", "fa fa-plus-circle fa-lg", "button_action", "/package/package_add/"), |
|
115 | 115 | array("Delete", "btn btn-line-danger", "fa fa-times-circle fa-lg", "button_action", "/package/package_delete_multiple/") |
116 | 116 | )); |
117 | 117 | return $buttons_json; |
@@ -121,15 +121,15 @@ discard block |
||
121 | 121 | |
122 | 122 | function build_package_counter_list_for_admin() { |
123 | 123 | // array(display name, width, db_field_parent_table,feidname, db_field_child_table,function name); |
124 | - $grid_field_arr = json_encode(array(array("Package Name", "430", "package_id", "package_name", "packages", "get_field_name","","true","center"), |
|
125 | - array("Account", "420", "accountid", "first_name,last_name,number", "accounts", "get_field_name_coma_new","","true","center"), |
|
126 | - array("Used Seconds", "420", "seconds", "", "", "","","true","center"), |
|
124 | + $grid_field_arr = json_encode(array(array("Package Name", "430", "package_id", "package_name", "packages", "get_field_name", "", "true", "center"), |
|
125 | + array("Account", "420", "accountid", "first_name,last_name,number", "accounts", "get_field_name_coma_new", "", "true", "center"), |
|
126 | + array("Used Seconds", "420", "seconds", "", "", "", "", "true", "center"), |
|
127 | 127 | )); |
128 | 128 | return $grid_field_arr; |
129 | 129 | } |
130 | 130 | function build_pattern_list_for_customer($packageid) { |
131 | 131 | $grid_field_arr = json_encode(array( |
132 | - array("<input type='checkbox' name='chkAll' class='ace checkall'/><label class='lbl'></label>", "30", "", "", "", "","","false","center"), |
|
132 | + array("<input type='checkbox' name='chkAll' class='ace checkall'/><label class='lbl'></label>", "30", "", "", "", "", "", "false", "center"), |
|
133 | 133 | array("Code", "450", "patterns", "patterns", "", "get_only_numeric_val"), |
134 | 134 | array("Destination", "450", "destination", "", "", ""), |
135 | 135 | array("Action", "100", "", "", "", array("DELETE" => array("url" => "package/package_patterns_delete/$packageid/", "mode" => "single"))) |
@@ -137,7 +137,7 @@ discard block |
||
137 | 137 | return $grid_field_arr; |
138 | 138 | } |
139 | 139 | function set_pattern_grid_buttons($packageid) { |
140 | - $buttons_json = json_encode(array(array("Create","btn btn-line-warning btn","fa fa-plus-circle fa-lg", "button_action", "/package/customer_add_patterns/$packageid", "popup"))); |
|
140 | + $buttons_json = json_encode(array(array("Create", "btn btn-line-warning btn", "fa fa-plus-circle fa-lg", "button_action", "/package/customer_add_patterns/$packageid", "popup"))); |
|
141 | 141 | return $buttons_json; |
142 | 142 | } |
143 | 143 | |
@@ -145,17 +145,17 @@ discard block |
||
145 | 145 | |
146 | 146 | function build_package_counter_report() { |
147 | 147 | $buttons_json = json_encode(array( |
148 | - array("Export","btn btn-xing" ," fa fa-download fa-lg", "button_action", "/package/package_counter_report_export/", 'single') |
|
148 | + array("Export", "btn btn-xing", " fa fa-download fa-lg", "button_action", "/package/package_counter_report_export/", 'single') |
|
149 | 149 | |
150 | 150 | )); |
151 | 151 | return $buttons_json; |
152 | 152 | } |
153 | - function build_package_list_for_reseller(){ |
|
153 | + function build_package_list_for_reseller() { |
|
154 | 154 | $grid_field_arr = json_encode(array( |
155 | - array("Name", "310", "package_name", "", "", "","","true","center"), |
|
156 | - array("Rate Group", "250", "pricelist_id", "name", "pricelists", "get_field_name","","true","center"), |
|
157 | - array("Included Seconds", "260", "includedseconds", "", "", "","","true","center"), |
|
158 | - array("Status", "160", "status", "status", "status", "get_status","","true","center"), |
|
155 | + array("Name", "310", "package_name", "", "", "", "", "true", "center"), |
|
156 | + array("Rate Group", "250", "pricelist_id", "name", "pricelists", "get_field_name", "", "true", "center"), |
|
157 | + array("Included Seconds", "260", "includedseconds", "", "", "", "", "true", "center"), |
|
158 | + array("Status", "160", "status", "status", "status", "get_status", "", "true", "center"), |
|
159 | 159 | )); |
160 | 160 | return $grid_field_arr; |
161 | 161 | } |
@@ -22,8 +22,9 @@ |
||
22 | 22 | # along with this program. If not, see <http://www.gnu.org/licenses/>. |
23 | 23 | ############################################################################### |
24 | 24 | |
25 | -if (!defined('BASEPATH')) |
|
26 | - exit('No direct script access allowed'); |
|
25 | +if (!defined('BASEPATH')) { |
|
26 | + exit('No direct script access allowed'); |
|
27 | +} |
|
27 | 28 | |
28 | 29 | class Package_form { |
29 | 30 |
@@ -2,20 +2,20 @@ discard block |
||
2 | 2 | <? startblock('extra_head') ?> |
3 | 3 | <? endblock() ?> |
4 | 4 | <? startblock('page-title') ?> |
5 | -<?= $page_title;?> |
|
5 | +<?= $page_title; ?> |
|
6 | 6 | <? endblock() ?> |
7 | 7 | <? startblock('content') ?> |
8 | - <?php if(!isset($csv_tmp_data)){ ?> |
|
8 | + <?php if ( ! isset($csv_tmp_data)) { ?> |
|
9 | 9 | |
10 | 10 | <section class="slice color-three padding-t-20"> |
11 | 11 | <div class="w-section inverse no-padding"> |
12 | 12 | <div class="container"> |
13 | - <form method="post" action="<?= base_url().'package/package_patterns_preview_file/'.$edit_id . "/"?>" enctype="multipart/form-data" id="package_code"> |
|
13 | + <form method="post" action="<?= base_url().'package/package_patterns_preview_file/'.$edit_id."/"?>" enctype="multipart/form-data" id="package_code"> |
|
14 | 14 | <div class="row"> |
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> |
@@ -35,9 +35,9 @@ discard block |
||
35 | 35 | </div> |
36 | 36 | </div> |
37 | 37 | <? |
38 | - $logintype=$this->session->userdata('userlevel_logintype'); |
|
38 | + $logintype = $this->session->userdata('userlevel_logintype'); |
|
39 | 39 | // $trunk=null; |
40 | - if($logintype !=1) { ?> |
|
40 | + if ($logintype != 1) { ?> |
|
41 | 41 | <div class="col-md-12 no-padding"> |
42 | 42 | |
43 | 43 | <div> |
@@ -97,7 +97,7 @@ discard block |
||
97 | 97 | <?}?> |
98 | 98 | |
99 | 99 | <?php |
100 | - if(isset($csv_tmp_data) && !empty($csv_tmp_data)){ ?> |
|
100 | + if (isset($csv_tmp_data) && ! empty($csv_tmp_data)) { ?> |
|
101 | 101 | |
102 | 102 | <section class="slice color-three"> |
103 | 103 | <div class="w-section inverse no-padding"> |
@@ -106,14 +106,14 @@ discard block |
||
106 | 106 | <div class="col-md-12 margin-t-10"> |
107 | 107 | <form id="import_form" name="import_form" action="<?=base_url()?>package/package_patterns_import_file/<?=$edit_id?>/<?=$check_header?>/" method="POST"> |
108 | 108 | <table width="100%" border="1" class="details_table table"> |
109 | - <? $cnt =7; |
|
110 | - foreach($csv_tmp_data as $csv_key => $csv_value){ |
|
111 | - if($csv_key < 15){ |
|
109 | + <? $cnt = 7; |
|
110 | + foreach ($csv_tmp_data as $csv_key => $csv_value) { |
|
111 | + if ($csv_key < 15) { |
|
112 | 112 | echo "<tr>"; |
113 | - foreach($csv_value as $field_name => $field_val){ |
|
114 | - if($csv_key == 0){ |
|
113 | + foreach ($csv_value as $field_name => $field_val) { |
|
114 | + if ($csv_key == 0) { |
|
115 | 115 | echo "<th>".ucfirst($field_name)."</th>"; |
116 | - }else{ |
|
116 | + } else { |
|
117 | 117 | echo "<td class='portlet-content'>".$field_val."</td>"; |
118 | 118 | } |
119 | 119 | } |
@@ -104,7 +104,7 @@ |
||
104 | 104 | foreach($csv_value as $field_name => $field_val){ |
105 | 105 | if($csv_key == 0){ |
106 | 106 | echo "<th>".ucfirst($field_name)."</th>"; |
107 | - }else{ |
|
107 | + } else{ |
|
108 | 108 | echo "<td class='portlet-content'>".$field_val."</td>"; |
109 | 109 | } |
110 | 110 | } |
@@ -12,7 +12,7 @@ |
||
12 | 12 | <div class="w-section inverse no-padding"> |
13 | 13 | <?php echo $form; ?> |
14 | 14 | <?php |
15 | - if(isset($validation_errors) && $validation_errors != ''){ ?> |
|
15 | + if (isset($validation_errors) && $validation_errors != '') { ?> |
|
16 | 16 | <script> |
17 | 17 | var ERR_STR = '<?php echo $validation_errors; ?>'; |
18 | 18 | print_error(ERR_STR); |
@@ -26,9 +26,9 @@ discard block |
||
26 | 26 | |
27 | 27 | function user_model() { |
28 | 28 | parent::__construct(); |
29 | - if(Common_model::$global_config['system_config']['opensips']==0){ |
|
29 | + if (Common_model::$global_config['system_config']['opensips'] == 0) { |
|
30 | 30 | $db_config = Common_model::$global_config['system_config']; |
31 | - $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="; |
|
31 | + $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="; |
|
32 | 32 | $this->opensips_db = $this->load->database($opensipdsn, true); |
33 | 33 | } |
34 | 34 | } |
@@ -91,9 +91,9 @@ discard block |
||
91 | 91 | $this->db->select('count(id) as count'); |
92 | 92 | } |
93 | 93 | if ($flag) { |
94 | - if (isset($_GET['sortname']) && $_GET['sortname'] != 'undefined'){ |
|
95 | - $this->db->order_by($_GET['sortname'], ($_GET['sortorder']=='undefined')?'desc':$_GET['sortorder']); |
|
96 | - }else{ |
|
94 | + if (isset($_GET['sortname']) && $_GET['sortname'] != 'undefined') { |
|
95 | + $this->db->order_by($_GET['sortname'], ($_GET['sortorder'] == 'undefined') ? 'desc' : $_GET['sortorder']); |
|
96 | + } else { |
|
97 | 97 | $this->db->order_by('invoice_date', 'desc'); |
98 | 98 | } |
99 | 99 | } |
@@ -107,7 +107,7 @@ discard block |
||
107 | 107 | } |
108 | 108 | } else { |
109 | 109 | if ($flag) { |
110 | - $query = (object) array('num_rows' => 0); |
|
110 | + $query = (object)array('num_rows' => 0); |
|
111 | 111 | } else { |
112 | 112 | $query = 0; |
113 | 113 | } |
@@ -117,13 +117,13 @@ discard block |
||
117 | 117 | |
118 | 118 | function get_user_charge_history($flag, $start = 0, $limit = 0) { |
119 | 119 | $this->db_model->build_search('user_charge_history_search'); |
120 | - $accountinfo=$this->session->userdata('accountinfo'); |
|
121 | - $where['accountid']=$accountinfo['id']; |
|
122 | - if($this->session->userdata('advance_search') != 1){ |
|
123 | - $where['created_date >=']=gmdate("Y-m-1 00:00:00"); |
|
124 | - $where['created_date <=']=gmdate("Y-m-d 23:59:59"); |
|
120 | + $accountinfo = $this->session->userdata('accountinfo'); |
|
121 | + $where['accountid'] = $accountinfo['id']; |
|
122 | + if ($this->session->userdata('advance_search') != 1) { |
|
123 | + $where['created_date >='] = gmdate("Y-m-1 00:00:00"); |
|
124 | + $where['created_date <='] = gmdate("Y-m-d 23:59:59"); |
|
125 | 125 | } |
126 | - $where['item_type <>']='STANDARD'; |
|
126 | + $where['item_type <>'] = 'STANDARD'; |
|
127 | 127 | if ($flag) { |
128 | 128 | $query = $this->db_model->select("*", "invoice_details", $where, "id", "DESC", $limit, $start); |
129 | 129 | } else { |
@@ -174,9 +174,9 @@ discard block |
||
174 | 174 | return true; |
175 | 175 | } |
176 | 176 | |
177 | - function user_ipmap_list($flag,$limit='',$start=''){ |
|
178 | - $accountinfo=$this->session->userdata('accountinfo'); |
|
179 | - $where['accountid']=$accountinfo['id']; |
|
177 | + function user_ipmap_list($flag, $limit = '', $start = '') { |
|
178 | + $accountinfo = $this->session->userdata('accountinfo'); |
|
179 | + $where['accountid'] = $accountinfo['id']; |
|
180 | 180 | $this->db_model->build_search('user_ipmap_search'); |
181 | 181 | if ($flag) { |
182 | 182 | $query = $this->db_model->select("*", "ip_map", $where, "id", "ASC", $limit, $start); |
@@ -185,7 +185,7 @@ discard block |
||
185 | 185 | } |
186 | 186 | return $query; |
187 | 187 | } |
188 | - function user_sipdevices_list($flag, $accountid = "",$start = "", $limit = "") { |
|
188 | + function user_sipdevices_list($flag, $accountid = "", $start = "", $limit = "") { |
|
189 | 189 | $where = array("accountid" => $accountid); |
190 | 190 | $this->db_model->build_search('user_sipdevices_search'); |
191 | 191 | $query = array(); |
@@ -220,11 +220,11 @@ discard block |
||
220 | 220 | return $query; |
221 | 221 | } |
222 | 222 | |
223 | - function user_sipdevice_info($edit_id){ |
|
223 | + function user_sipdevice_info($edit_id) { |
|
224 | 224 | $sipdevice_info = $this->db_model->getSelect("*", "sip_devices", array('id' => $edit_id)); |
225 | 225 | $sipdevice_arr = (array)$sipdevice_info->first_row(); |
226 | 226 | $vars = (array)json_decode($sipdevice_arr['dir_vars']); |
227 | - $params = (array)json_decode($sipdevice_arr['dir_params'],true); |
|
227 | + $params = (array)json_decode($sipdevice_arr['dir_params'], true); |
|
228 | 228 | $query = array('id' => $sipdevice_arr['id'], |
229 | 229 | 'fs_username' => $sipdevice_arr['username'], |
230 | 230 | 'accountcode' => $sipdevice_arr['accountid'], |
@@ -240,7 +240,7 @@ discard block |
||
240 | 240 | 'fs_password' => $params['password']); |
241 | 241 | return $query; |
242 | 242 | } |
243 | - function user_sipdevice_add($add_array){ |
|
243 | + function user_sipdevice_add($add_array) { |
|
244 | 244 | $account_data = $this->session->userdata("accountinfo"); |
245 | 245 | $parms_array = array('password' => $add_array['fs_password'], |
246 | 246 | 'vm-enabled' => $add_array['voicemail_enabled'], |
@@ -260,12 +260,12 @@ discard block |
||
260 | 260 | 'status' => $add_array['status'], |
261 | 261 | 'dir_params' => json_encode($parms_array), |
262 | 262 | 'dir_vars' => json_encode($parms_array_vars), |
263 | - 'sip_profile_id' => $this->common->get_field_name('id','sip_profiles',array('name'=>'default'))); |
|
263 | + 'sip_profile_id' => $this->common->get_field_name('id', 'sip_profiles', array('name'=>'default'))); |
|
264 | 264 | $this->db->insert('sip_devices', $new_array); |
265 | 265 | $this->common->mail_to_users('add_sip_device', $account_data); |
266 | 266 | return true; |
267 | 267 | } |
268 | - function user_sipdevice_edit($add_array){ |
|
268 | + function user_sipdevice_edit($add_array) { |
|
269 | 269 | $parms_array = array('password' => $add_array['fs_password'], |
270 | 270 | 'vm-enabled' => $add_array['voicemail_enabled'], |
271 | 271 | 'vm-password' => $add_array['voicemail_password'], |
@@ -277,62 +277,62 @@ discard block |
||
277 | 277 | $parms_array_vars = array('effective_caller_id_name' => $add_array['effective_caller_id_name'], |
278 | 278 | 'effective_caller_id_number' => $add_array['effective_caller_id_number'],); |
279 | 279 | $log_type = $this->session->userdata("logintype"); |
280 | - if($log_type == 0 || $log_type == 3 || $log_type == 1){ |
|
281 | - $add_array['sip_profile_id']=$this->common->get_field_name('id','sip_profiles',array('name'=>'default')); |
|
280 | + if ($log_type == 0 || $log_type == 3 || $log_type == 1) { |
|
281 | + $add_array['sip_profile_id'] = $this->common->get_field_name('id', 'sip_profiles', array('name'=>'default')); |
|
282 | 282 | } |
283 | - $add_array['status'] = isset($add_array['status'])?$add_array['status']:"0"; |
|
284 | - $new_array = array('last_modified_date'=>gmdate('Y-m-d H:i:s'),'username' => $add_array['fs_username'],'status' => $add_array['status'], |
|
283 | + $add_array['status'] = isset($add_array['status']) ? $add_array['status'] : "0"; |
|
284 | + $new_array = array('last_modified_date'=>gmdate('Y-m-d H:i:s'), 'username' => $add_array['fs_username'], 'status' => $add_array['status'], |
|
285 | 285 | 'dir_params' => json_encode($parms_array), |
286 | 286 | 'dir_vars' => json_encode($parms_array_vars), 'sip_profile_id' => $add_array['sip_profile_id']); |
287 | - $this->db->update('sip_devices', $new_array,array('id'=>$add_array['id'])); |
|
287 | + $this->db->update('sip_devices', $new_array, array('id'=>$add_array['id'])); |
|
288 | 288 | return true; |
289 | 289 | } |
290 | - function getuser_cdrs_list($flag, $start, $limit,$export=true) { |
|
290 | + function getuser_cdrs_list($flag, $start, $limit, $export = true) { |
|
291 | 291 | $this->db_model->build_search('user_cdrs_report_search'); |
292 | 292 | $account_data = $this->session->userdata("accountinfo"); |
293 | - $field_name='debit'; |
|
294 | - if($account_data['type']==0 || $account_data['type']==1){ |
|
295 | - $where['accountid']=$account_data['id']; |
|
293 | + $field_name = 'debit'; |
|
294 | + if ($account_data['type'] == 0 || $account_data['type'] == 1) { |
|
295 | + $where['accountid'] = $account_data['id']; |
|
296 | 296 | |
297 | 297 | } |
298 | - if($account_data['type']==3){ |
|
299 | - $where['provider_id']=$account_data['id']; |
|
300 | - $field_name='cost'; |
|
298 | + if ($account_data['type'] == 3) { |
|
299 | + $where['provider_id'] = $account_data['id']; |
|
300 | + $field_name = 'cost'; |
|
301 | 301 | } |
302 | - $table_name=$account_data['type'] !=1 ? 'cdrs': 'reseller_cdrs'; |
|
303 | - if($this->session->userdata('advance_search') != 1){ |
|
304 | - $where['callstart >= ']=date("Y-m-d")." 00:00:00"; |
|
305 | - $where['callstart <=']=date("Y-m-d")." 23:59:59"; |
|
302 | + $table_name = $account_data['type'] != 1 ? 'cdrs' : 'reseller_cdrs'; |
|
303 | + if ($this->session->userdata('advance_search') != 1) { |
|
304 | + $where['callstart >= '] = date("Y-m-d")." 00:00:00"; |
|
305 | + $where['callstart <='] = date("Y-m-d")." 23:59:59"; |
|
306 | 306 | } |
307 | 307 | $this->db->where($where); |
308 | 308 | $this->db->order_by("callstart desc"); |
309 | 309 | if ($flag) { |
310 | - if (!$export) |
|
310 | + if ( ! $export) |
|
311 | 311 | $this->db->limit($limit, $start); |
312 | 312 | $this->db->select('callstart,callerid,callednum,pattern,notes,billseconds,disposition,debit,cost,accountid,pricelist_id,calltype,is_recording,trunk_id,uniqueid'); |
313 | - }else { |
|
313 | + } else { |
|
314 | 314 | $this->db->select('count(*) as count,sum(billseconds) as billseconds,sum(debit) as total_debit,sum(cost) as total_cost,group_concat(distinct(pricelist_id)) as pricelist_ids,group_concat(distinct(trunk_id)) as trunk_ids'); |
315 | 315 | } |
316 | 316 | $result = $this->db->get($table_name); |
317 | 317 | return $result; |
318 | 318 | } |
319 | 319 | |
320 | - function user_fund_transfer($data){ |
|
320 | + function user_fund_transfer($data) { |
|
321 | 321 | $accountinfo = $this->session->userdata['accountinfo']; |
322 | - $data["payment_by"] = $accountinfo['reseller_id'] > 0 ? $accountinfo['reseller_id'] : -1 ; |
|
322 | + $data["payment_by"] = $accountinfo['reseller_id'] > 0 ? $accountinfo['reseller_id'] : -1; |
|
323 | 323 | $data['accountid'] = $data['id']; |
324 | 324 | $data['payment_mode'] = $data['payment_type']; |
325 | - unset($data['action'],$data['id'],$data['account_currency'],$data['payment_type']); |
|
325 | + unset($data['action'], $data['id'], $data['account_currency'], $data['payment_type']); |
|
326 | 326 | if (isset($data)) { |
327 | - $data['credit']=$data['credit'] =='' ? 0 : $data['credit']; |
|
327 | + $data['credit'] = $data['credit'] == '' ? 0 : $data['credit']; |
|
328 | 328 | $date = gmdate('Y-m-d H:i:s'); |
329 | - $accountid=$data['accountid']; |
|
330 | - while($accountid > 0 ){ |
|
331 | - $customer_id=$accountid; |
|
332 | - $accountid=$this->common_model->get_parent_info($accountid); |
|
333 | - $parent_id=$accountid > 0 ? $accountid : -1; |
|
334 | - $balance = $this->db_model->update_balance($data['credit'], $customer_id,$data['payment_mode']); |
|
335 | - if($data['payment_mode'] == 0){ |
|
329 | + $accountid = $data['accountid']; |
|
330 | + while ($accountid > 0) { |
|
331 | + $customer_id = $accountid; |
|
332 | + $accountid = $this->common_model->get_parent_info($accountid); |
|
333 | + $parent_id = $accountid > 0 ? $accountid : -1; |
|
334 | + $balance = $this->db_model->update_balance($data['credit'], $customer_id, $data['payment_mode']); |
|
335 | + if ($data['payment_mode'] == 0) { |
|
336 | 336 | $insert_arr = array("accountid" => $customer_id, |
337 | 337 | "credit" => $data['credit'], |
338 | 338 | 'payment_mode'=>$data['payment_mode'], |
@@ -348,28 +348,28 @@ discard block |
||
348 | 348 | } |
349 | 349 | function user_dashboard_recent_recharge_info() |
350 | 350 | { |
351 | - $accountinfo=$this->session->userdata('accountinfo'); |
|
352 | - $userlevel_logintype=$this->session->userdata('userlevel_logintype'); |
|
351 | + $accountinfo = $this->session->userdata('accountinfo'); |
|
352 | + $userlevel_logintype = $this->session->userdata('userlevel_logintype'); |
|
353 | 353 | |
354 | - $where_arr=array('payment_by'=>-1); |
|
355 | - if($userlevel_logintype == 1){ |
|
356 | - $where_arr=array('payment_by'=>$accountinfo['id']); |
|
354 | + $where_arr = array('payment_by'=>-1); |
|
355 | + if ($userlevel_logintype == 1) { |
|
356 | + $where_arr = array('payment_by'=>$accountinfo['id']); |
|
357 | 357 | } |
358 | - if($userlevel_logintype == 0 || $userlevel_logintype == 3){ |
|
359 | - $where_arr=array('accountid'=>$accountinfo['id']); |
|
358 | + if ($userlevel_logintype == 0 || $userlevel_logintype == 3) { |
|
359 | + $where_arr = array('accountid'=>$accountinfo['id']); |
|
360 | 360 | } |
361 | 361 | $this->db->where($where_arr); |
362 | 362 | $this->db->select('id,accountid,credit,payment_date,notes'); |
363 | 363 | $this->db->from('payments'); |
364 | 364 | $this->db->limit(10); |
365 | - $this->db->order_by('payment_date','desc'); |
|
365 | + $this->db->order_by('payment_date', 'desc'); |
|
366 | 366 | return $this->db->get(); |
367 | 367 | } |
368 | 368 | |
369 | 369 | function get_user_rates_list($flag, $start = 0, $limit = 0) { |
370 | 370 | $this->db_model->build_search('user_rates_list_search'); |
371 | 371 | $account_data = $this->session->userdata("accountinfo"); |
372 | - $where = array("pricelist_id" => $account_data["pricelist_id"],"status" => '0'); |
|
372 | + $where = array("pricelist_id" => $account_data["pricelist_id"], "status" => '0'); |
|
373 | 373 | if ($flag) { |
374 | 374 | $query = $this->db_model->select("*", "routes", $where, "id", "ASC", $limit, $start); |
375 | 375 | } else { |
@@ -378,42 +378,42 @@ discard block |
||
378 | 378 | return $query; |
379 | 379 | } |
380 | 380 | function get_user_opensips($flag, $account_number = "", $start = "0", $limit = "0") { |
381 | - $this->db_model->build_search_opensips($this->opensips_db,'user_opensips_search'); |
|
382 | - $this->opensips_db->where('accountcode',$account_number); |
|
381 | + $this->db_model->build_search_opensips($this->opensips_db, 'user_opensips_search'); |
|
382 | + $this->opensips_db->where('accountcode', $account_number); |
|
383 | 383 | if ($flag) { |
384 | - $this->opensips_db->limit($limit,$start); |
|
384 | + $this->opensips_db->limit($limit, $start); |
|
385 | 385 | } |
386 | 386 | $result = $this->opensips_db->get("subscriber"); |
387 | - if($result->num_rows() > 0){ |
|
388 | - if($flag){ |
|
387 | + if ($result->num_rows() > 0) { |
|
388 | + if ($flag) { |
|
389 | 389 | return $result; |
390 | 390 | } |
391 | - else{ |
|
391 | + else { |
|
392 | 392 | return $result->num_rows(); |
393 | 393 | } |
394 | - }else{ |
|
395 | - if($flag){ |
|
396 | - $result=(object)array('num_rows'=>0); |
|
394 | + } else { |
|
395 | + if ($flag) { |
|
396 | + $result = (object)array('num_rows'=>0); |
|
397 | 397 | } |
398 | - else{ |
|
399 | - $result=0; |
|
398 | + else { |
|
399 | + $result = 0; |
|
400 | 400 | } |
401 | 401 | return $result; |
402 | 402 | } |
403 | 403 | } |
404 | 404 | function user_opensips_add($data) { |
405 | 405 | unset($data["action"]); |
406 | - $data['creation_date']=gmdate("Y-m-d H:i:s"); |
|
407 | - $accountinfo=$this->session->userdata('accountinfo'); |
|
408 | - $data['reseller_id']=$accountinfo['type']==1 ? $accountinfo['id'] : 0; |
|
406 | + $data['creation_date'] = gmdate("Y-m-d H:i:s"); |
|
407 | + $accountinfo = $this->session->userdata('accountinfo'); |
|
408 | + $data['reseller_id'] = $accountinfo['type'] == 1 ? $accountinfo['id'] : 0; |
|
409 | 409 | $this->opensips_db->insert("subscriber", $data); |
410 | 410 | } |
411 | 411 | |
412 | 412 | function user_opensips_edit($data, $id) { |
413 | 413 | unset($data["action"]); |
414 | - $data=array("username"=>$data['username'],"password"=>$data['password'],"accountcode"=>$data['accountcode'],"domain"=>$data['domain']); |
|
414 | + $data = array("username"=>$data['username'], "password"=>$data['password'], "accountcode"=>$data['accountcode'], "domain"=>$data['domain']); |
|
415 | 415 | $this->opensips_db->where("id", $id); |
416 | - $data['last_modified_date']=gmdate("Y-m-d H:i:s"); |
|
416 | + $data['last_modified_date'] = gmdate("Y-m-d H:i:s"); |
|
417 | 417 | $this->opensips_db->update("subscriber", $data); |
418 | 418 | } |
419 | 419 | function user_opensips_delete($id) { |
@@ -421,12 +421,12 @@ discard block |
||
421 | 421 | $this->opensips_db->delete("subscriber"); |
422 | 422 | return true; |
423 | 423 | } |
424 | - function get_user_invoice_list($flag, $start = 0, $limit = 0){ |
|
424 | + function get_user_invoice_list($flag, $start = 0, $limit = 0) { |
|
425 | 425 | $this->db_model->build_search('user_invoice_list_search'); |
426 | - $accountinfo=$this->session->userdata('accountinfo'); |
|
427 | - $where = array("accountid" => $accountinfo['id'],'confirm'=>1); |
|
426 | + $accountinfo = $this->session->userdata('accountinfo'); |
|
427 | + $where = array("accountid" => $accountinfo['id'], 'confirm'=>1); |
|
428 | 428 | $this->db->where($where); |
429 | - $or_where= "(type='I' OR type='R')"; |
|
429 | + $or_where = "(type='I' OR type='R')"; |
|
430 | 430 | $this->db->where($or_where); |
431 | 431 | if ($flag) { |
432 | 432 | $query = $this->db_model->select("*", "invoices", "", "invoice_date", "desc", $limit, $start); |
@@ -437,7 +437,7 @@ discard block |
||
437 | 437 | |
438 | 438 | return $query; |
439 | 439 | } |
440 | - function get_user_cdrs_info($flag,$accountid,$start = 0, $limit = 0){ |
|
440 | + function get_user_cdrs_info($flag, $accountid, $start = 0, $limit = 0) { |
|
441 | 441 | if ($flag) { |
442 | 442 | $query = $this->db_model->select("*", "reseller_cdrs", "", "invoice_date", "desc", $limit, $start); |
443 | 443 | |
@@ -447,38 +447,38 @@ discard block |
||
447 | 447 | |
448 | 448 | } |
449 | 449 | function get_invoiceconf($accountid) { |
450 | - $return_array=array(); |
|
450 | + $return_array = array(); |
|
451 | 451 | $logintype = $this->session->userdata('logintype'); |
452 | 452 | if ($logintype == 1 || $logintype == 5) { |
453 | 453 | |
454 | 454 | $where = array("accountid" => $this->session->userdata["accountinfo"]['id']); |
455 | - }else{ |
|
456 | - $where=array('id'=> $accountid); |
|
455 | + } else { |
|
456 | + $where = array('id'=> $accountid); |
|
457 | 457 | } |
458 | - $query = $this->db_model->getSelect("*","invoice_conf",$where); |
|
459 | - foreach($query->result_array() as $key => $value) |
|
458 | + $query = $this->db_model->getSelect("*", "invoice_conf", $where); |
|
459 | + foreach ($query->result_array() as $key => $value) |
|
460 | 460 | { |
461 | - $return_array=$value; |
|
461 | + $return_array = $value; |
|
462 | 462 | } |
463 | 463 | return $return_array; |
464 | 464 | } |
465 | 465 | |
466 | 466 | |
467 | - function getprovider_cdrs_list($flag, $start, $limit,$export=true) { |
|
467 | + function getprovider_cdrs_list($flag, $start, $limit, $export = true) { |
|
468 | 468 | $this->db_model->build_search('user_provider_cdrs_report_search'); |
469 | 469 | $account_data = $this->session->userdata("accountinfo"); |
470 | - $where['provider_id']=$account_data['id']; |
|
471 | - if($this->session->userdata('advance_search') != 1){ |
|
472 | - $where['callstart >= ']=date("Y-m-d")." 00:00:00"; |
|
473 | - $where['callstart <=']=date("Y-m-d")." 23:59:59"; |
|
470 | + $where['provider_id'] = $account_data['id']; |
|
471 | + if ($this->session->userdata('advance_search') != 1) { |
|
472 | + $where['callstart >= '] = date("Y-m-d")." 00:00:00"; |
|
473 | + $where['callstart <='] = date("Y-m-d")." 23:59:59"; |
|
474 | 474 | } |
475 | 475 | $this->db->where($where); |
476 | - $this->db->order_by("callstart","desc"); |
|
476 | + $this->db->order_by("callstart", "desc"); |
|
477 | 477 | if ($flag) { |
478 | - if (!$export) |
|
478 | + if ( ! $export) |
|
479 | 479 | $this->db->limit($limit, $start); |
480 | 480 | $this->db->select('callstart,callerid,callednum,pattern,notes,billseconds,disposition,cost,accountid,pricelist_id,calltype,is_recording,trunk_id,uniqueid'); |
481 | - }else { |
|
481 | + } else { |
|
482 | 482 | $this->db->select('count(*) as count,sum(billseconds) as billseconds,sum(cost) as total_cost,group_concat(distinct(trunk_id)) as trunk_ids'); |
483 | 483 | } |
484 | 484 | $result = $this->db->get('cdrs'); |
@@ -93,7 +93,7 @@ discard block |
||
93 | 93 | if ($flag) { |
94 | 94 | if (isset($_GET['sortname']) && $_GET['sortname'] != 'undefined'){ |
95 | 95 | $this->db->order_by($_GET['sortname'], ($_GET['sortorder']=='undefined')?'desc':$_GET['sortorder']); |
96 | - }else{ |
|
96 | + } else{ |
|
97 | 97 | $this->db->order_by('invoice_date', 'desc'); |
98 | 98 | } |
99 | 99 | } |
@@ -307,10 +307,11 @@ discard block |
||
307 | 307 | $this->db->where($where); |
308 | 308 | $this->db->order_by("callstart desc"); |
309 | 309 | if ($flag) { |
310 | - if (!$export) |
|
311 | - $this->db->limit($limit, $start); |
|
310 | + if (!$export) { |
|
311 | + $this->db->limit($limit, $start); |
|
312 | + } |
|
312 | 313 | $this->db->select('callstart,callerid,callednum,pattern,notes,billseconds,disposition,debit,cost,accountid,pricelist_id,calltype,is_recording,trunk_id,uniqueid'); |
313 | - }else { |
|
314 | + } else { |
|
314 | 315 | $this->db->select('count(*) as count,sum(billseconds) as billseconds,sum(debit) as total_debit,sum(cost) as total_cost,group_concat(distinct(pricelist_id)) as pricelist_ids,group_concat(distinct(trunk_id)) as trunk_ids'); |
315 | 316 | } |
316 | 317 | $result = $this->db->get($table_name); |
@@ -387,15 +388,13 @@ discard block |
||
387 | 388 | if($result->num_rows() > 0){ |
388 | 389 | if($flag){ |
389 | 390 | return $result; |
390 | - } |
|
391 | - else{ |
|
391 | + } else{ |
|
392 | 392 | return $result->num_rows(); |
393 | 393 | } |
394 | - }else{ |
|
394 | + } else{ |
|
395 | 395 | if($flag){ |
396 | 396 | $result=(object)array('num_rows'=>0); |
397 | - } |
|
398 | - else{ |
|
397 | + } else{ |
|
399 | 398 | $result=0; |
400 | 399 | } |
401 | 400 | return $result; |
@@ -452,7 +451,7 @@ discard block |
||
452 | 451 | if ($logintype == 1 || $logintype == 5) { |
453 | 452 | |
454 | 453 | $where = array("accountid" => $this->session->userdata["accountinfo"]['id']); |
455 | - }else{ |
|
454 | + } else{ |
|
456 | 455 | $where=array('id'=> $accountid); |
457 | 456 | } |
458 | 457 | $query = $this->db_model->getSelect("*","invoice_conf",$where); |
@@ -475,10 +474,11 @@ discard block |
||
475 | 474 | $this->db->where($where); |
476 | 475 | $this->db->order_by("callstart","desc"); |
477 | 476 | if ($flag) { |
478 | - if (!$export) |
|
479 | - $this->db->limit($limit, $start); |
|
477 | + if (!$export) { |
|
478 | + $this->db->limit($limit, $start); |
|
479 | + } |
|
480 | 480 | $this->db->select('callstart,callerid,callednum,pattern,notes,billseconds,disposition,cost,accountid,pricelist_id,calltype,is_recording,trunk_id,uniqueid'); |
481 | - }else { |
|
481 | + } else { |
|
482 | 482 | $this->db->select('count(*) as count,sum(billseconds) as billseconds,sum(cost) as total_cost,group_concat(distinct(trunk_id)) as trunk_ids'); |
483 | 483 | } |
484 | 484 | $result = $this->db->get('cdrs'); |
@@ -31,17 +31,17 @@ discard block |
||
31 | 31 | |
32 | 32 | } |
33 | 33 | |
34 | - function index(){ |
|
34 | + function index() { |
|
35 | 35 | $account_data = $this->session->userdata("accountinfo"); |
36 | 36 | $data["accountid"] = $account_data["id"]; |
37 | 37 | $data["accountid"] = $account_data["id"]; |
38 | 38 | $data["page_title"] = "Recharge"; |
39 | 39 | |
40 | 40 | $system_config = common_model::$global_config['system_config']; |
41 | - if($system_config["paypal_mode"]==0){ |
|
41 | + if ($system_config["paypal_mode"] == 0) { |
|
42 | 42 | $data["paypal_url"] = $system_config["paypal_url"]; |
43 | 43 | $data["paypal_email_id"] = $system_config["paypal_id"]; |
44 | - }else{ |
|
44 | + } else { |
|
45 | 45 | $data["paypal_url"] = $system_config["paypal_sandbox_url"]; |
46 | 46 | $data["paypal_email_id"] = $system_config["paypal_sandbox_id"]; |
47 | 47 | } |
@@ -49,12 +49,12 @@ discard block |
||
49 | 49 | |
50 | 50 | $data["from_currency"] = $this->common->get_field_name('currency', 'currency', $account_data["currency_id"]); |
51 | 51 | $data["to_currency"] = Common_model::$global_config['system_config']['base_currency']; |
52 | - $this->load->view("user_payment",$data); |
|
52 | + $this->load->view("user_payment", $data); |
|
53 | 53 | } |
54 | 54 | |
55 | - function convert_amount($amount){ |
|
56 | - $amount = $this->common_model->add_calculate_currency($amount,"","",true,false); |
|
57 | - echo number_format((float)$amount,2); |
|
55 | + function convert_amount($amount) { |
|
56 | + $amount = $this->common_model->add_calculate_currency($amount, "", "", true, false); |
|
57 | + echo number_format((float)$amount, 2); |
|
58 | 58 | } |
59 | 59 | } |
60 | 60 | ?> |
@@ -41,7 +41,7 @@ |
||
41 | 41 | if($system_config["paypal_mode"]==0){ |
42 | 42 | $data["paypal_url"] = $system_config["paypal_url"]; |
43 | 43 | $data["paypal_email_id"] = $system_config["paypal_id"]; |
44 | - }else{ |
|
44 | + } else{ |
|
45 | 45 | $data["paypal_url"] = $system_config["paypal_sandbox_url"]; |
46 | 46 | $data["paypal_email_id"] = $system_config["paypal_sandbox_id"]; |
47 | 47 | } |
@@ -36,8 +36,9 @@ discard block |
||
36 | 36 | } |
37 | 37 | |
38 | 38 | function index() { |
39 | - if ($this->session->userdata('user_login') == FALSE) |
|
40 | - redirect(base_url() . 'login/login'); |
|
39 | + if ($this->session->userdata('user_login') == FALSE) { |
|
40 | + redirect(base_url() . 'login/login'); |
|
41 | + } |
|
41 | 42 | $data['page_title'] = 'Dashboard'; |
42 | 43 | $this->load->view('view_user_dashboard', $data); |
43 | 44 | } |
@@ -266,7 +267,7 @@ discard block |
||
266 | 267 | $this->session->set_flashdata('astpp_notification', 'Insuffiecient fund to purchase this did'); |
267 | 268 | redirect(base_url() . "user/user_didlist/"); |
268 | 269 | } |
269 | - }else{ |
|
270 | + } else{ |
|
270 | 271 | $this->session->set_flashdata('astpp_notification', 'This DID already purchased by someone.'); |
271 | 272 | redirect(base_url() . "user/user_didlist/"); |
272 | 273 | } |
@@ -298,7 +299,7 @@ discard block |
||
298 | 299 | $this->session->set_flashdata('astpp_notification', 'DID Removed Successfully.'); |
299 | 300 | redirect(base_url() . "user/user_didlist/"); |
300 | 301 | } |
301 | - }else{ |
|
302 | + } else{ |
|
302 | 303 | $this->session->set_flashdata('astpp_notification', 'DID not found.'); |
303 | 304 | redirect(base_url() . "user/user_didlist/"); |
304 | 305 | } |
@@ -355,8 +356,9 @@ discard block |
||
355 | 356 | $markup = $this->common->get_field_name('markup', 'pricelists', array('id'=>$account_data["pricelist_id"])); |
356 | 357 | $markup = ($markup > 0)?$markup:1; |
357 | 358 | $action['cost']['cost'] = $this->common_model->add_calculate_currency($action['cost']['cost'], "", '', true, false); |
358 | - if($account_data['type']!=3) |
|
359 | - $action['cost']['cost']=($action['cost']['cost'] - ($action['cost']['cost']*$markup)/100); |
|
359 | + if($account_data['type']!=3) { |
|
360 | + $action['cost']['cost']=($action['cost']['cost'] - ($action['cost']['cost']*$markup)/100); |
|
361 | + } |
|
360 | 362 | } |
361 | 363 | $this->session->set_userdata('user_rates_list_search', $action); |
362 | 364 | } |
@@ -695,7 +697,7 @@ discard block |
||
695 | 697 | $this->session->set_userdata('accountinfo', $result[0]); |
696 | 698 | $this->session->set_flashdata('astpp_errormsg',' Your profile updated successfully!'); |
697 | 699 | redirect(base_url() . 'user/user_myprofile/'); |
698 | - }else{ |
|
700 | + } else{ |
|
699 | 701 | $this->session->set_flashdata('astpp_notification', 'Something wrong.Please contact to administrator.'); |
700 | 702 | } |
701 | 703 | } |
@@ -729,7 +731,7 @@ discard block |
||
729 | 731 | $this->session->set_flashdata('astpp_errormsg', 'Password updated successfully!'); |
730 | 732 | redirect(base_url() . 'user/user_change_password/'); |
731 | 733 | } |
732 | - }else{ |
|
734 | + } else{ |
|
733 | 735 | $data_array['id']=$accountinfo['id']; |
734 | 736 | $data['form'] = $this->form->build_form($this->user_form->get_userprofile_change_password(),$data_array); |
735 | 737 | } |
@@ -745,7 +747,7 @@ discard block |
||
745 | 747 | $data['form_search'] = $this->form->build_serach_form($this->user_form->build_user_refill_report_search()); |
746 | 748 | if($accountinfo['type'] == 1){ |
747 | 749 | $this->load->view('view_reseller_refill_report', $data); |
748 | - }else{ |
|
750 | + } else{ |
|
749 | 751 | $this->load->view('view_user_refill_report', $data); |
750 | 752 | } |
751 | 753 | } |
@@ -829,19 +831,18 @@ discard block |
||
829 | 831 | } else { |
830 | 832 | $payment = ' <button style="padding: 0 8px;" class="btn btn-success" type="button">Paid</button>'; |
831 | 833 | } |
832 | - }else{ |
|
834 | + } else{ |
|
833 | 835 | $payment = ''; |
834 | 836 | } |
835 | 837 | if($value['generate_type'] == 1){ |
836 | 838 | $invoice_type='Manually'; |
837 | - }else{ |
|
839 | + } else{ |
|
838 | 840 | $invoice_type='Automatically'; |
839 | 841 | } |
840 | 842 | |
841 | 843 | if($value['type'] == 'R'){ |
842 | 844 | $icon = '<div class="flx_font flx_magenta">R</div>'; |
843 | - } |
|
844 | - else |
|
845 | + } else |
|
845 | 846 | { |
846 | 847 | $icon = '<div class="flx_font flx_drk_pink">I</div>'; |
847 | 848 | |
@@ -904,7 +905,7 @@ discard block |
||
904 | 905 | $amount = $this->input->post("value",true); |
905 | 906 | $amount = $this->common_model->add_calculate_currency($amount,"","",true,false); |
906 | 907 | echo number_format($amount,2); |
907 | - }else{ |
|
908 | + } else{ |
|
908 | 909 | $this->payment->index(); |
909 | 910 | } |
910 | 911 | } |
@@ -1092,7 +1093,7 @@ discard block |
||
1092 | 1093 | $this->db->where('reseller_pricing.note','dids.number',false); |
1093 | 1094 | $this->db->where('reseller_pricing.reseller_id',$accountinfo['reseller_id']); |
1094 | 1095 | $this->db->from('dids,reseller_pricing'); |
1095 | - }else{ |
|
1096 | + } else{ |
|
1096 | 1097 | $this->db->where('parent_id',0); |
1097 | 1098 | $this->db->where('accountid',0); |
1098 | 1099 | $this->db->select('id,number,setup,monthlycost'); |
@@ -1393,7 +1394,7 @@ discard block |
||
1393 | 1394 | ); |
1394 | 1395 | $this->db->insert("ani_map", $insert_arr); |
1395 | 1396 | $this->session->set_flashdata('astpp_errormsg', 'Add Caller ID Sucessfully!'); |
1396 | - }else{ |
|
1397 | + } else{ |
|
1397 | 1398 | $this->session->set_flashdata('astpp_notification', 'Please Enter Caller ID value.'); |
1398 | 1399 | } |
1399 | 1400 | } else { |
@@ -1538,7 +1539,7 @@ discard block |
||
1538 | 1539 | if($action=="GET_AMT"){ |
1539 | 1540 | $amount = $this->input->post("value",true); |
1540 | 1541 | $this->payment->convert_amount($amount); |
1541 | - }else{ |
|
1542 | + } else{ |
|
1542 | 1543 | $this->payment->index(); |
1543 | 1544 | } |
1544 | 1545 | } |
@@ -1573,34 +1574,25 @@ discard block |
||
1573 | 1574 | $minimum_fund=(array)$this->db->get_where('system',array("name"=>"minimum_fund_transfer"),1)->first_row(); |
1574 | 1575 | if ($post_array['toaccountid'] == $account_info['number']) { |
1575 | 1576 | $this->session->set_flashdata('astpp_notification', 'You can not transfer fund in same account.'); |
1576 | - } |
|
1577 | - elseif ($reseller_id != $account_info['reseller_id']) { |
|
1577 | + } elseif ($reseller_id != $account_info['reseller_id']) { |
|
1578 | 1578 | $this->session->set_flashdata('astpp_notification', 'You can only transfer fund in same level account.'); |
1579 | - } |
|
1580 | - elseif ($post_array['toaccountid'] == '') { |
|
1579 | + } elseif ($post_array['toaccountid'] == '') { |
|
1581 | 1580 | $this->session->set_flashdata('astpp_notification', 'Please enter To account number.'); |
1582 | - } |
|
1583 | - elseif (empty($post_array['credit'])) { |
|
1581 | + } elseif (empty($post_array['credit'])) { |
|
1584 | 1582 | $this->session->set_flashdata('astpp_notification', 'Please enter a amount.'); |
1585 | - } |
|
1586 | - elseif ($post_array['credit'] > $balance) { |
|
1583 | + } elseif ($post_array['credit'] > $balance) { |
|
1587 | 1584 | $this->session->set_flashdata('astpp_notification', 'You have insufficient balance.'); |
1588 | - } |
|
1589 | - elseif ($toid <= 0 || !isset($post_array['toaccountid'])) { |
|
1585 | + } elseif ($toid <= 0 || !isset($post_array['toaccountid'])) { |
|
1590 | 1586 | $this->session->set_flashdata('astpp_notification', 'Please enter valid account number.'); |
1591 | - } |
|
1592 | - elseif ($post_array['credit'] < 0) { |
|
1587 | + } elseif ($post_array['credit'] < 0) { |
|
1593 | 1588 | $this->session->set_flashdata('astpp_notification', 'Please enter amount greater then 0.'); |
1594 | - } |
|
1595 | - elseif ($minimum_fund['value'] >= $post_array['credit']) { |
|
1589 | + } elseif ($minimum_fund['value'] >= $post_array['credit']) { |
|
1596 | 1590 | $this->session->set_flashdata('astpp_notification', 'You need to enter minimum amount of fund transfer ' . $minimum_fund['value'] . ' .'); |
1597 | - } |
|
1598 | - elseif (!isset($toid) || !isset($post_array['toaccountid'])) { |
|
1591 | + } elseif (!isset($toid) || !isset($post_array['toaccountid'])) { |
|
1599 | 1592 | $this->session->set_flashdata('astpp_notification', 'Please enter valid account number!'); |
1600 | - } |
|
1601 | - elseif ($post_array['credit'] < 0 || $post_array['credit'] > $balance) { |
|
1593 | + } elseif ($post_array['credit'] < 0 || $post_array['credit'] > $balance) { |
|
1602 | 1594 | $this->session->set_flashdata('astpp_notification', 'Insuffiecient amount !'); |
1603 | - }else{ |
|
1595 | + } else{ |
|
1604 | 1596 | $from['id'] = $post_array['id']; |
1605 | 1597 | $from['account_currency'] = $post_array['account_currency']; |
1606 | 1598 | $from['accountid'] = $post_array['fromaccountid']; |
@@ -1635,7 +1627,7 @@ discard block |
||
1635 | 1627 | $this->session->set_flashdata('astpp_notification', 'Sorry We are not able to process this request.'); |
1636 | 1628 | } |
1637 | 1629 | } |
1638 | - }else{ |
|
1630 | + } else{ |
|
1639 | 1631 | $this->session->set_flashdata('astpp_notification', 'Account number not found.'); |
1640 | 1632 | } |
1641 | 1633 | } else { |
@@ -1727,7 +1719,7 @@ discard block |
||
1727 | 1719 | $this->user_model->user_opensips_edit($add_array, $add_array['id']); |
1728 | 1720 | echo json_encode(array("SUCCESS"=> " OpenSips updated successfully!")); |
1729 | 1721 | exit; |
1730 | - }else{ |
|
1722 | + } else{ |
|
1731 | 1723 | echo json_encode($auth_flag); |
1732 | 1724 | exit; |
1733 | 1725 | } |
@@ -1744,7 +1736,7 @@ discard block |
||
1744 | 1736 | $this->user_model->user_opensips_add($add_array); |
1745 | 1737 | echo json_encode(array("SUCCESS"=> "OpenSips added successfully!")); |
1746 | 1738 | exit; |
1747 | - }else{ |
|
1739 | + } else{ |
|
1748 | 1740 | echo json_encode($auth_flag); |
1749 | 1741 | exit; |
1750 | 1742 | } |
@@ -1765,10 +1757,10 @@ discard block |
||
1765 | 1757 | $auth_flag = $auth_flag->num_rows(); |
1766 | 1758 | if($auth_flag == 0){ |
1767 | 1759 | return "TRUE"; |
1768 | - }else{ |
|
1760 | + } else{ |
|
1769 | 1761 | return array("username_error"=>"Duplicate Username Found.Username Must be Unique"); |
1770 | 1762 | } |
1771 | - }else{ |
|
1763 | + } else{ |
|
1772 | 1764 | return array("username_error"=>"User name is required field."); |
1773 | 1765 | } |
1774 | 1766 | return "0"; |
@@ -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']); |