Passed
Branch v3.5 (f0ef26)
by Samir
36:09
created
web_interface/astpp/application/modules/pricing/models/pricing_model.php 1 patch
Spacing   +28 added lines, -28 removed lines patch added patch discarded remove patch
@@ -22,77 +22,77 @@
 block discarded – undo
22 22
 // ##############################################################################
23 23
 class pricing_model extends CI_Model {
24 24
 	function pricing_model() {
25
-		parent::__construct ();
25
+		parent::__construct();
26 26
 	}
27 27
 	function getpricing_list($flag, $start = 0, $limit = 0) {
28
-		$this->db_model->build_search ( 'price_list_search' );
29
-		if ($this->session->userdata ( 'logintype' ) == 1 || $this->session->userdata ( 'logintype' ) == 5) {
30
-			$account_data = $this->session->userdata ( "accountinfo" );
28
+		$this->db_model->build_search('price_list_search');
29
+		if ($this->session->userdata('logintype') == 1 || $this->session->userdata('logintype') == 5) {
30
+			$account_data = $this->session->userdata("accountinfo");
31 31
 			$reseller = $account_data ['id'];
32 32
 			// $where = array("reseller_id" => $reseller, "status" => "0");
33
-			$where = array (
33
+			$where = array(
34 34
 					"reseller_id" => $reseller,
35 35
 					"status != " => "2" 
36 36
 			);
37 37
 		} else {
38
-			$where = array (
38
+			$where = array(
39 39
 					"reseller_id" => "0",
40 40
 					"status != " => "2" 
41 41
 			);
42 42
 		}
43 43
 		if ($flag) {
44
-			$query = $this->db_model->Select ( "*", "pricelists", $where, "id", "ASC", $limit, $start );
44
+			$query = $this->db_model->Select("*", "pricelists", $where, "id", "ASC", $limit, $start);
45 45
 		} else {
46
-			$query = $this->db_model->countQuery ( "*", "pricelists", $where );
46
+			$query = $this->db_model->countQuery("*", "pricelists", $where);
47 47
 		}
48 48
 		return $query;
49 49
 	}
50 50
 	function add_price($add_array) {
51
-		unset ( $add_array ["action"] );
51
+		unset ($add_array ["action"]);
52 52
 		/*
53 53
 		 * ASTPP 3.0 Add Rategroup add creation date.
54 54
 		 */
55
-		$add_array ['creation_date'] = gmdate ( "Y-m-d H:i:s" );
55
+		$add_array ['creation_date'] = gmdate("Y-m-d H:i:s");
56 56
 		/**
57 57
 		 * *********************************
58 58
 		 */
59
-		if ($this->session->userdata ( 'logintype' ) == 1 || $this->session->userdata ( 'logintype' ) == 5) {
60
-			$account_data = $this->session->userdata ( "accountinfo" );
59
+		if ($this->session->userdata('logintype') == 1 || $this->session->userdata('logintype') == 5) {
60
+			$account_data = $this->session->userdata("accountinfo");
61 61
 			$add_array ["reseller_id"] = $account_data ['id'];
62 62
 		} else {
63 63
 			$add_array ["reseller_id"] = "0";
64 64
 		}
65
-		$this->db->insert ( "pricelists", $add_array );
65
+		$this->db->insert("pricelists", $add_array);
66 66
 		
67
-		return $this->db->insert_id ();
67
+		return $this->db->insert_id();
68 68
 	}
69 69
 	function edit_price($data, $id) {
70
-		unset ( $data ["action"] );
70
+		unset ($data ["action"]);
71 71
 		/*
72 72
 		 * ASTPP 3.0 Edit Rategroup time update last mofied date.
73 73
 		 */
74
-		$data ['last_modified_date'] = gmdate ( "Y-m-d H:i:s" );
74
+		$data ['last_modified_date'] = gmdate("Y-m-d H:i:s");
75 75
 		/**
76 76
 		 * ******************************************************
77 77
 		 */
78
-		$this->db->where ( "id", $id );
79
-		$this->db->update ( "pricelists", $data );
78
+		$this->db->where("id", $id);
79
+		$this->db->update("pricelists", $data);
80 80
 		return true;
81 81
 	}
82 82
 	function get_price_list_for_cdrs() {
83
-		if ($this->session->userdata ( 'username' ) != "" && $this->session->userdata ( 'logintype' ) != 2) {
84
-			$this->db->where ( 'reseller', $this->session->userdata ( 'username' ) );
83
+		if ($this->session->userdata('username') != "" && $this->session->userdata('logintype') != 2) {
84
+			$this->db->where('reseller', $this->session->userdata('username'));
85 85
 		} else {
86
-			$this->db->where ( array (
86
+			$this->db->where(array(
87 87
 					'reseller' => "0" 
88
-			) );
88
+			));
89 89
 		}
90
-		$this->db->where ( 'status <', 2 );
91
-		$this->db->order_by ( 'name', 'desc' );
92
-		$query = $this->db->get ( "pricelists" );
93
-		$price_list = array ();
94
-		$result = $query->result_array ();
95
-		foreach ( $result as $row ) {
90
+		$this->db->where('status <', 2);
91
+		$this->db->order_by('name', 'desc');
92
+		$query = $this->db->get("pricelists");
93
+		$price_list = array();
94
+		$result = $query->result_array();
95
+		foreach ($result as $row) {
96 96
 			$price_list [$row ['name']] = $row ['name'];
97 97
 		}
98 98
 		return $price_list;
Please login to merge, or discard this patch.
web_interface/astpp/application/modules/pricing/controllers/pricing.php 3 patches
Indentation   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -245,8 +245,8 @@
 block discarded – undo
245 245
 		}
246 246
 	}
247 247
 /**
248
- * ********************************************************
249
- */
248
+	 * ********************************************************
249
+	 */
250 250
 }
251 251
 
252 252
 ?>
Please login to merge, or discard this patch.
Spacing   +121 added lines, -121 removed lines patch added patch discarded remove patch
@@ -22,130 +22,130 @@  discard block
 block discarded – undo
22 22
 // ##############################################################################
23 23
 class pricing extends CI_Controller {
24 24
 	function pricing() {
25
-		parent::__construct ();
25
+		parent::__construct();
26 26
 		
27
-		$this->load->helper ( 'template_inheritance' );
27
+		$this->load->helper('template_inheritance');
28 28
 		
29
-		$this->load->library ( 'session' );
30
-		$this->load->library ( "pricing_form" );
31
-		$this->load->library ( 'astpp/form' );
32
-		$this->load->model ( 'pricing_model' );
29
+		$this->load->library('session');
30
+		$this->load->library("pricing_form");
31
+		$this->load->library('astpp/form');
32
+		$this->load->model('pricing_model');
33 33
 		
34
-		if ($this->session->userdata ( 'user_login' ) == FALSE)
35
-			redirect ( base_url () . '/astpp/login' );
34
+		if ($this->session->userdata('user_login') == FALSE)
35
+			redirect(base_url().'/astpp/login');
36 36
 	}
37 37
 	function price_add($type = "") {
38
-		$data ['username'] = $this->session->userdata ( 'user_name' );
38
+		$data ['username'] = $this->session->userdata('user_name');
39 39
 		$data ['flag'] = 'Create Rate Group';
40
-		$data ['page_title'] = gettext ( 'Create Rate Group' );
41
-		$data ['form'] = $this->form->build_form ( $this->pricing_form->get_pricing_form_fields (), '' );
40
+		$data ['page_title'] = gettext('Create Rate Group');
41
+		$data ['form'] = $this->form->build_form($this->pricing_form->get_pricing_form_fields(), '');
42 42
 		
43
-		$this->load->view ( 'view_price_add_edit', $data );
43
+		$this->load->view('view_price_add_edit', $data);
44 44
 	}
45 45
 	function price_edit($edit_id = '') {
46
-		$data ['page_title'] = gettext ( 'Edit Rate Group' );
47
-		$where = array (
46
+		$data ['page_title'] = gettext('Edit Rate Group');
47
+		$where = array(
48 48
 				'id' => $edit_id 
49 49
 		);
50
-		$account = $this->db_model->getSelect ( "*", " pricelists", $where );
51
-		foreach ( $account->result_array () as $key => $value ) {
50
+		$account = $this->db_model->getSelect("*", " pricelists", $where);
51
+		foreach ($account->result_array() as $key => $value) {
52 52
 			$edit_data = $value;
53 53
 		}
54
-		$routing_data = $this->db_model->getSelect ( "trunk_id", "routing", array (
54
+		$routing_data = $this->db_model->getSelect("trunk_id", "routing", array(
55 55
 				"pricelist_id" => $edit_id 
56
-		) );
56
+		));
57 57
 		if ($routing_data->num_rows > 0) {
58
-			foreach ( $routing_data->result_array () as $trunkid ) {
58
+			foreach ($routing_data->result_array() as $trunkid) {
59 59
 				$edit_data ["trunk_id"] [] = $trunkid ["trunk_id"];
60 60
 			}
61 61
 		}
62
-		$data ['form'] = $this->form->build_form ( $this->pricing_form->get_pricing_form_fields (), $edit_data );
63
-		$this->load->view ( 'view_price_add_edit', $data );
62
+		$data ['form'] = $this->form->build_form($this->pricing_form->get_pricing_form_fields(), $edit_data);
63
+		$this->load->view('view_price_add_edit', $data);
64 64
 	}
65 65
 	function price_save() {
66
-		$add_array = $this->input->post ();
66
+		$add_array = $this->input->post();
67 67
 		
68
-		$data ['form'] = $this->form->build_form ( $this->pricing_form->get_pricing_form_fields (), $add_array );
68
+		$data ['form'] = $this->form->build_form($this->pricing_form->get_pricing_form_fields(), $add_array);
69 69
 		if ($add_array ['id'] != '') {
70
-			$data ['page_title'] = gettext ( 'Edit Price Details' );
71
-			if ($this->form_validation->run () == FALSE) {
72
-				$data ['validation_errors'] = validation_errors ();
70
+			$data ['page_title'] = gettext('Edit Price Details');
71
+			if ($this->form_validation->run() == FALSE) {
72
+				$data ['validation_errors'] = validation_errors();
73 73
 				echo $data ['validation_errors'];
74 74
 				exit ();
75 75
 			} else {
76
-				$where = array (
76
+				$where = array(
77 77
 						"pricelist_id" => $add_array ['id'] 
78 78
 				);
79
-				$this->db->delete ( "routing", $where );
80
-				if (isset ( $add_array ['trunk_id'] ) && $add_array ['trunk_id'] != '') {
81
-					$this->set_force_routing ( $add_array ['id'], $add_array ['trunk_id'] );
82
-					unset ( $add_array ['trunk_id'] );
79
+				$this->db->delete("routing", $where);
80
+				if (isset ($add_array ['trunk_id']) && $add_array ['trunk_id'] != '') {
81
+					$this->set_force_routing($add_array ['id'], $add_array ['trunk_id']);
82
+					unset ($add_array ['trunk_id']);
83 83
 				}
84
-				$this->pricing_model->edit_price ( $add_array, $add_array ['id'] );
85
-				echo json_encode ( array (
86
-						"SUCCESS" => $add_array ["name"] . " rate group updated successfully!" 
87
-				) );
84
+				$this->pricing_model->edit_price($add_array, $add_array ['id']);
85
+				echo json_encode(array(
86
+						"SUCCESS" => $add_array ["name"]." rate group updated successfully!" 
87
+				));
88 88
 				exit ();
89 89
 			}
90
-			$this->load->view ( 'view_price_add_edit', $data );
90
+			$this->load->view('view_price_add_edit', $data);
91 91
 		} else {
92
-			$data ['page_title'] = gettext ( 'Create Price Details' );
93
-			if ($this->form_validation->run () == FALSE) {
94
-				$data ['validation_errors'] = validation_errors ();
92
+			$data ['page_title'] = gettext('Create Price Details');
93
+			if ($this->form_validation->run() == FALSE) {
94
+				$data ['validation_errors'] = validation_errors();
95 95
 				echo $data ['validation_errors'];
96 96
 				exit ();
97 97
 			} else {
98
-				if (isset ( $add_array ['trunk_id'] ) && ! empty ( $add_array ['trunk_id'] ))
98
+				if (isset ($add_array ['trunk_id']) && ! empty ($add_array ['trunk_id']))
99 99
 					$trunk_id = $add_array ['trunk_id'];
100
-				unset ( $add_array ['trunk_id'] );
101
-				$priceid = $this->pricing_model->add_price ( $add_array );
102
-				if (isset ( $trunk_id ) && $trunk_id != '') {
103
-					$this->set_force_routing ( $priceid, $trunk_id );
100
+				unset ($add_array ['trunk_id']);
101
+				$priceid = $this->pricing_model->add_price($add_array);
102
+				if (isset ($trunk_id) && $trunk_id != '') {
103
+					$this->set_force_routing($priceid, $trunk_id);
104 104
 				}
105
-				echo json_encode ( array (
106
-						"SUCCESS" => $add_array ["name"] . " rate group added successfully!" 
107
-				) );
105
+				echo json_encode(array(
106
+						"SUCCESS" => $add_array ["name"]." rate group added successfully!" 
107
+				));
108 108
 				exit ();
109 109
 			}
110 110
 		}
111 111
 	}
112 112
 	function set_force_routing($priceid, $trunkid) {
113 113
 		// echo "<pre>".$priceid; print_r($trunkid);
114
-		foreach ( $trunkid as $id ) {
115
-			$routing_arr = array (
114
+		foreach ($trunkid as $id) {
115
+			$routing_arr = array(
116 116
 					"trunk_id" => $id,
117 117
 					"pricelist_id" => $priceid 
118 118
 			);
119
-			$this->db->insert ( "routing", $routing_arr );
119
+			$this->db->insert("routing", $routing_arr);
120 120
 		}
121 121
 	}
122 122
 	function price_list_search() {
123
-		$ajax_search = $this->input->post ( 'ajax_search', 0 );
123
+		$ajax_search = $this->input->post('ajax_search', 0);
124 124
 		
125
-		if ($this->input->post ( 'advance_search', TRUE ) == 1) {
126
-			$this->session->set_userdata ( 'advance_search', $this->input->post ( 'advance_search' ) );
127
-			$action = $this->input->post ();
128
-			unset ( $action ['action'] );
129
-			unset ( $action ['advance_search'] );
130
-			$this->session->set_userdata ( 'price_list_search', $action );
125
+		if ($this->input->post('advance_search', TRUE) == 1) {
126
+			$this->session->set_userdata('advance_search', $this->input->post('advance_search'));
127
+			$action = $this->input->post();
128
+			unset ($action ['action']);
129
+			unset ($action ['advance_search']);
130
+			$this->session->set_userdata('price_list_search', $action);
131 131
 		}
132 132
 		if (@$ajax_search != 1) {
133
-			redirect ( base_url () . 'accounts/customer_list/' );
133
+			redirect(base_url().'accounts/customer_list/');
134 134
 		}
135 135
 	}
136 136
 	function price_list_clearsearchfilter() {
137
-		$this->session->set_userdata ( 'advance_search', 0 );
138
-		$this->session->set_userdata ( 'account_search', "" );
137
+		$this->session->set_userdata('advance_search', 0);
138
+		$this->session->set_userdata('account_search', "");
139 139
 	}
140 140
 	function price_list() {
141
-		$data ['username'] = $this->session->userdata ( 'user_name' );
142
-		$data ['page_title'] = gettext ( 'Rate Groups' );
141
+		$data ['username'] = $this->session->userdata('user_name');
142
+		$data ['page_title'] = gettext('Rate Groups');
143 143
 		$data ['search_flag'] = true;
144
-		$this->session->set_userdata ( 'advance_search', 0 );
145
-		$data ['grid_fields'] = $this->pricing_form->build_pricing_list_for_admin ();
146
-		$data ["grid_buttons"] = $this->pricing_form->build_grid_buttons ();
147
-		$data ['form_search'] = $this->form->build_serach_form ( $this->pricing_form->get_pricing_search_form () );
148
-		$this->load->view ( 'view_price_list', $data );
144
+		$this->session->set_userdata('advance_search', 0);
145
+		$data ['grid_fields'] = $this->pricing_form->build_pricing_list_for_admin();
146
+		$data ["grid_buttons"] = $this->pricing_form->build_grid_buttons();
147
+		$data ['form_search'] = $this->form->build_serach_form($this->pricing_form->get_pricing_search_form());
148
+		$this->load->view('view_price_list', $data);
149 149
 	}
150 150
 	
151 151
 	/**
@@ -153,95 +153,95 @@  discard block
 block discarded – undo
153 153
 	 * Listing of Accounts table data through php function json_encode
154 154
 	 */
155 155
 	function price_list_json() {
156
-		$json_data = array ();
157
-		$count_all = $this->pricing_model->getpricing_list ( false );
158
-		$paging_data = $this->form->load_grid_config ( $count_all, $_GET ['rp'], $_GET ['page'] );
156
+		$json_data = array();
157
+		$count_all = $this->pricing_model->getpricing_list(false);
158
+		$paging_data = $this->form->load_grid_config($count_all, $_GET ['rp'], $_GET ['page']);
159 159
 		$json_data = $paging_data ["json_paging"];
160 160
 		
161
-		$query = $this->pricing_model->getpricing_list ( true, $paging_data ["paging"] ["start"], $paging_data ["paging"] ["page_no"] );
162
-		$grid_fields = json_decode ( $this->pricing_form->build_pricing_list_for_admin () );
163
-		$json_data ['rows'] = $this->form->build_grid ( $query, $grid_fields );
161
+		$query = $this->pricing_model->getpricing_list(true, $paging_data ["paging"] ["start"], $paging_data ["paging"] ["page_no"]);
162
+		$grid_fields = json_decode($this->pricing_form->build_pricing_list_for_admin());
163
+		$json_data ['rows'] = $this->form->build_grid($query, $grid_fields);
164 164
 		
165
-		echo json_encode ( $json_data );
165
+		echo json_encode($json_data);
166 166
 	}
167 167
 	function price_delete($pricelist_id) {
168
-		$where = array (
168
+		$where = array(
169 169
 				"id" => $pricelist_id 
170 170
 		);
171
-		$this->db_model->update ( "pricelists", array (
171
+		$this->db_model->update("pricelists", array(
172 172
 				"status" => "2" 
173
-		), $where );
174
-		$this->db->delete ( "routing", array (
173
+		), $where);
174
+		$this->db->delete("routing", array(
175 175
 				"pricelist_id" => $pricelist_id 
176
-		) );
177
-		$this->session->set_flashdata ( 'astpp_notification', 'Rate group removed successfully!' );
178
-		redirect ( base_url () . 'pricing/price_list/' );
176
+		));
177
+		$this->session->set_flashdata('astpp_notification', 'Rate group removed successfully!');
178
+		redirect(base_url().'pricing/price_list/');
179 179
 	}
180 180
 	function price_delete_multiple() {
181
-		$add_array = $this->input->post ();
182
-		$where = 'IN (' . $add_array ['selected_ids'] . ')';
183
-		if (isset ( $add_array ['flag'] )) {
184
-			$update_data = array (
181
+		$add_array = $this->input->post();
182
+		$where = 'IN ('.$add_array ['selected_ids'].')';
183
+		if (isset ($add_array ['flag'])) {
184
+			$update_data = array(
185 185
 					'status' => '2' 
186 186
 			);
187
-			$this->db->where ( 'pricelist_id ' . $where );
188
-			$this->db->delete ( 'routes' );
189
-			$this->db->delete ( "routing", array (
187
+			$this->db->where('pricelist_id '.$where);
188
+			$this->db->delete('routes');
189
+			$this->db->delete("routing", array(
190 190
 					"pricelist_id" => $where 
191
-			) );
192
-			$this->db->where ( 'id ' . $where );
193
-			echo $this->db->update ( 'pricelists', $update_data );
191
+			));
192
+			$this->db->where('id '.$where);
193
+			echo $this->db->update('pricelists', $update_data);
194 194
 		} else {
195
-			$pricelist_arr = array ();
195
+			$pricelist_arr = array();
196 196
 			// Get selected Rategroup Name from database.
197
-			$this->db->select ( 'id,name' );
198
-			$this->db->where ( 'id ' . $where );
199
-			$pricelist_res = $this->db->get ( 'pricelists' );
200
-			$pricelist_res = $pricelist_res->result_array ();
201
-			foreach ( $pricelist_res as $value ) {
197
+			$this->db->select('id,name');
198
+			$this->db->where('id '.$where);
199
+			$pricelist_res = $this->db->get('pricelists');
200
+			$pricelist_res = $pricelist_res->result_array();
201
+			foreach ($pricelist_res as $value) {
202 202
 				$pricelist_arr [$value ['id']] ['name'] = $value ['name'];
203 203
 			}
204 204
 			// Get count of accounts which are using selected rategroups.
205
-			$this->db->where ( 'pricelist_id ' . $where );
206
-			$this->db->where ( 'deleted', 0 );
207
-			$this->db->select ( 'count(id) as cnt,pricelist_id' );
208
-			$this->db->group_by ( 'pricelist_id' );
209
-			$account_res = $this->db->get ( 'accounts' );
210
-			if ($account_res->num_rows () > 0) {
211
-				$account_res = $account_res->result_array ();
212
-				foreach ( $account_res as $key => $value ) {
205
+			$this->db->where('pricelist_id '.$where);
206
+			$this->db->where('deleted', 0);
207
+			$this->db->select('count(id) as cnt,pricelist_id');
208
+			$this->db->group_by('pricelist_id');
209
+			$account_res = $this->db->get('accounts');
210
+			if ($account_res->num_rows() > 0) {
211
+				$account_res = $account_res->result_array();
212
+				foreach ($account_res as $key => $value) {
213 213
 					$pricelist_arr [$value ['pricelist_id']] ['account'] = $value ['cnt'];
214 214
 				}
215 215
 			}
216 216
 			// Get count of routes which are using selected rategroups.
217
-			$this->db->where ( 'pricelist_id ' . $where );
218
-			$this->db->select ( 'count(id) as cnt,pricelist_id' );
219
-			$this->db->group_by ( 'pricelist_id' );
220
-			$routes_res = $this->db->get ( 'routes' );
221
-			if ($routes_res->num_rows () > 0) {
222
-				$routes_res = $routes_res->result_array ();
223
-				foreach ( $routes_res as $key => $value ) {
217
+			$this->db->where('pricelist_id '.$where);
218
+			$this->db->select('count(id) as cnt,pricelist_id');
219
+			$this->db->group_by('pricelist_id');
220
+			$routes_res = $this->db->get('routes');
221
+			if ($routes_res->num_rows() > 0) {
222
+				$routes_res = $routes_res->result_array();
223
+				foreach ($routes_res as $key => $value) {
224 224
 					$pricelist_arr [$value ['pricelist_id']] ['routes'] = $value ['cnt'];
225 225
 				}
226 226
 			}
227 227
 			$str = null;
228
-			foreach ( $pricelist_arr as $key => $value ) {
228
+			foreach ($pricelist_arr as $key => $value) {
229 229
 				$custom_str = null;
230
-				if (isset ( $value ['account'] ) || isset ( $value ['routes'] )) {
231
-					if (isset ( $value ['account'] )) {
232
-						$custom_str .= $value ['account'] . " accounts and ";
230
+				if (isset ($value ['account']) || isset ($value ['routes'])) {
231
+					if (isset ($value ['account'])) {
232
+						$custom_str .= $value ['account']." accounts and ";
233 233
 					}
234
-					if (isset ( $value ['routes'] )) {
235
-						$custom_str .= $value ['routes'] . " origination rates and ";
234
+					if (isset ($value ['routes'])) {
235
+						$custom_str .= $value ['routes']." origination rates and ";
236 236
 					}
237
-					$str .= " Rate group Name : " . $value ['name'] . " using by " . rtrim ( $custom_str, " and " ) . "\n";
237
+					$str .= " Rate group Name : ".$value ['name']." using by ".rtrim($custom_str, " and ")."\n";
238 238
 				}
239 239
 			}
240
-			if (! empty ( $str )) {
240
+			if ( ! empty ($str)) {
241 241
 				$data ['str'] = $str;
242 242
 			}
243 243
 			$data ['selected_ids'] = $add_array ['selected_ids'];
244
-			echo json_encode ( $data );
244
+			echo json_encode($data);
245 245
 		}
246 246
 	}
247 247
 /**
Please login to merge, or discard this patch.
Braces   +6 added lines, -4 removed lines patch added patch discarded remove patch
@@ -31,8 +31,9 @@  discard block
 block discarded – undo
31 31
 		$this->load->library ( 'astpp/form' );
32 32
 		$this->load->model ( 'pricing_model' );
33 33
 		
34
-		if ($this->session->userdata ( 'user_login' ) == FALSE)
35
-			redirect ( base_url () . '/astpp/login' );
34
+		if ($this->session->userdata ( 'user_login' ) == FALSE) {
35
+					redirect ( base_url () . '/astpp/login' );
36
+		}
36 37
 	}
37 38
 	function price_add($type = "") {
38 39
 		$data ['username'] = $this->session->userdata ( 'user_name' );
@@ -95,8 +96,9 @@  discard block
 block discarded – undo
95 96
 				echo $data ['validation_errors'];
96 97
 				exit ();
97 98
 			} else {
98
-				if (isset ( $add_array ['trunk_id'] ) && ! empty ( $add_array ['trunk_id'] ))
99
-					$trunk_id = $add_array ['trunk_id'];
99
+				if (isset ( $add_array ['trunk_id'] ) && ! empty ( $add_array ['trunk_id'] )) {
100
+									$trunk_id = $add_array ['trunk_id'];
101
+				}
100 102
 				unset ( $add_array ['trunk_id'] );
101 103
 				$priceid = $this->pricing_model->add_price ( $add_array );
102 104
 				if (isset ( $trunk_id ) && $trunk_id != '') {
Please login to merge, or discard this patch.
web_interface/astpp/application/modules/pricing/libraries/pricing_form.php 2 patches
Spacing   +108 added lines, -108 removed lines patch added patch discarded remove patch
@@ -20,27 +20,27 @@  discard block
 block discarded – undo
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
 class pricing_form {
26 26
 	function __construct($library_name = '') {
27
-		$this->CI = & get_instance ();
27
+		$this->CI = & get_instance();
28 28
 	}
29 29
 	function get_pricing_form_fields() {
30
-		$form ['forms'] = array (
31
-				base_url () . 'pricing/price_save/',
32
-				array (
30
+		$form ['forms'] = array(
31
+				base_url().'pricing/price_save/',
32
+				array(
33 33
 						'id' => 'pricing_form',
34 34
 						'method' => 'POST',
35 35
 						'name' => 'pricing_form' 
36 36
 				) 
37 37
 		);
38
-		if ($this->CI->session->userdata ( 'logintype' ) == 1 || $this->CI->session->userdata ( 'logintype' ) == 5) {
39
-			$form ['Rate Group Information'] = array (
40
-					array (
38
+		if ($this->CI->session->userdata('logintype') == 1 || $this->CI->session->userdata('logintype') == 5) {
39
+			$form ['Rate Group Information'] = array(
40
+					array(
41 41
 							'',
42 42
 							'HIDDEN',
43
-							array (
43
+							array(
44 44
 									'name' => 'id' 
45 45
 							),
46 46
 							'',
@@ -48,10 +48,10 @@  discard block
 block discarded – undo
48 48
 							'',
49 49
 							'' 
50 50
 					),
51
-					array (
51
+					array(
52 52
 							'',
53 53
 							'HIDDEN',
54
-							array (
54
+							array(
55 55
 									'name' => 'status',
56 56
 									'value' => '1' 
57 57
 							),
@@ -59,10 +59,10 @@  discard block
 block discarded – undo
59 59
 							'',
60 60
 							'' 
61 61
 					),
62
-					array (
63
-							gettext ( 'Name' ),
62
+					array(
63
+							gettext('Name'),
64 64
 							'INPUT',
65
-							array (
65
+							array(
66 66
 									'name' => 'name',
67 67
 									'size' => '20',
68 68
 									'class' => "text field medium" 
@@ -71,8 +71,8 @@  discard block
 block discarded – undo
71 71
 							'tOOL TIP',
72 72
 							'Please Enter account number' 
73 73
 					),
74
-					array (
75
-							gettext ( 'Routing Type' ),
74
+					array(
75
+							gettext('Routing Type'),
76 76
 							'routing_type',
77 77
 							'SELECT',
78 78
 							'',
@@ -84,10 +84,10 @@  discard block
 block discarded – undo
84 84
 							'',
85 85
 							'set_routetype' 
86 86
 					),
87
-					array (
88
-							gettext ( 'Initial Increment' ),
87
+					array(
88
+							gettext('Initial Increment'),
89 89
 							'INPUT',
90
-							array (
90
+							array(
91 91
 									'name' => 'initially_increment',
92 92
 									'size' => '20',
93 93
 									'class' => "text field medium" 
@@ -96,10 +96,10 @@  discard block
 block discarded – undo
96 96
 							'tOOL TIP',
97 97
 							'Please Enter account number' 
98 98
 					),
99
-					array (
100
-							gettext ( 'Default Increment' ),
99
+					array(
100
+							gettext('Default Increment'),
101 101
 							'INPUT',
102
-							array (
102
+							array(
103 103
 									'name' => 'inc',
104 104
 									'size' => '20',
105 105
 									'class' => "text field medium" 
@@ -108,10 +108,10 @@  discard block
 block discarded – undo
108 108
 							'tOOL TIP',
109 109
 							'Please Enter account number' 
110 110
 					),
111
-					array (
112
-							gettext ( 'Markup(%)' ),
111
+					array(
112
+							gettext('Markup(%)'),
113 113
 							'INPUT',
114
-							array (
114
+							array(
115 115
 									'name' => 'markup',
116 116
 									'value' => "0",
117 117
 									'size' => '20',
@@ -121,8 +121,8 @@  discard block
 block discarded – undo
121 121
 							'tOOL TIP',
122 122
 							'Please Enter account number' 
123 123
 					),
124
-					array (
125
-							gettext ( 'Status' ),
124
+					array(
125
+							gettext('Status'),
126 126
 							'status',
127 127
 							'SELECT',
128 128
 							'',
@@ -136,11 +136,11 @@  discard block
 block discarded – undo
136 136
 					) 
137 137
 			);
138 138
 		} else {
139
-			$form ['Rate Group Information'] = array (
140
-					array (
139
+			$form ['Rate Group Information'] = array(
140
+					array(
141 141
 							'',
142 142
 							'HIDDEN',
143
-							array (
143
+							array(
144 144
 									'name' => 'id' 
145 145
 							),
146 146
 							'',
@@ -148,10 +148,10 @@  discard block
 block discarded – undo
148 148
 							'',
149 149
 							'' 
150 150
 					),
151
-					array (
151
+					array(
152 152
 							'',
153 153
 							'HIDDEN',
154
-							array (
154
+							array(
155 155
 									'name' => 'status',
156 156
 									'value' => '1' 
157 157
 							),
@@ -159,10 +159,10 @@  discard block
 block discarded – undo
159 159
 							'',
160 160
 							'' 
161 161
 					),
162
-					array (
163
-							gettext ( 'Name' ),
162
+					array(
163
+							gettext('Name'),
164 164
 							'INPUT',
165
-							array (
165
+							array(
166 166
 									'name' => 'name',
167 167
 									'size' => '20',
168 168
 									'maxlength' => '30',
@@ -172,8 +172,8 @@  discard block
 block discarded – undo
172 172
 							'tOOL TIP',
173 173
 							'Please Enter account number' 
174 174
 					),
175
-					array (
176
-							gettext ( 'Routing Type' ),
175
+					array(
176
+							gettext('Routing Type'),
177 177
 							'routing_type',
178 178
 							'SELECT',
179 179
 							'',
@@ -185,10 +185,10 @@  discard block
 block discarded – undo
185 185
 							'',
186 186
 							'set_routetype' 
187 187
 					),
188
-					array (
189
-							gettext ( 'Initial Increment' ),
188
+					array(
189
+							gettext('Initial Increment'),
190 190
 							'INPUT',
191
-							array (
191
+							array(
192 192
 									'name' => 'initially_increment',
193 193
 									'size' => '20',
194 194
 									'class' => "text field medium" 
@@ -197,10 +197,10 @@  discard block
 block discarded – undo
197 197
 							'tOOL TIP',
198 198
 							'Please Enter account number' 
199 199
 					),
200
-					array (
201
-							gettext ( 'Default Increment' ),
200
+					array(
201
+							gettext('Default Increment'),
202 202
 							'INPUT',
203
-							array (
203
+							array(
204 204
 									'name' => 'inc',
205 205
 									'size' => '20',
206 206
 									'class' => "text field medium" 
@@ -209,10 +209,10 @@  discard block
 block discarded – undo
209 209
 							'tOOL TIP',
210 210
 							'Please Enter account number' 
211 211
 					),
212
-					array (
213
-							gettext ( 'Markup(%)' ),
212
+					array(
213
+							gettext('Markup(%)'),
214 214
 							'INPUT',
215
-							array (
215
+							array(
216 216
 									'name' => 'markup',
217 217
 									'value' => "0",
218 218
 									'size' => '20',
@@ -222,8 +222,8 @@  discard block
 block discarded – undo
222 222
 							'tOOL TIP',
223 223
 							'Please Enter account number' 
224 224
 					),
225
-					array (
226
-							gettext ( 'Trunks' ),
225
+					array(
226
+							gettext('Trunks'),
227 227
 							'trunk_id',
228 228
 							'SELECT',
229 229
 							'',
@@ -235,13 +235,13 @@  discard block
 block discarded – undo
235 235
 							'trunks',
236 236
 							'build_dropdown',
237 237
 							'where_arr',
238
-							array (
238
+							array(
239 239
 									"status <" => "2" 
240 240
 							),
241 241
 							'multi' 
242 242
 					),
243
-					array (
244
-							gettext ( 'Status' ),
243
+					array(
244
+							gettext('Status'),
245 245
 							'status',
246 246
 							'SELECT',
247 247
 							'',
@@ -256,17 +256,17 @@  discard block
 block discarded – undo
256 256
 			);
257 257
 		}
258 258
 		
259
-		$form ['button_cancel'] = array (
259
+		$form ['button_cancel'] = array(
260 260
 				'name' => 'action',
261
-				'content' => gettext ( 'Close' ),
261
+				'content' => gettext('Close'),
262 262
 				'value' => 'cancel',
263 263
 				'type' => 'button',
264 264
 				'class' => 'btn btn-line-sky margin-x-10',
265 265
 				'onclick' => 'return redirect_page(\'NULL\')' 
266 266
 		);
267
-		$form ['button_save'] = array (
267
+		$form ['button_save'] = array(
268 268
 				'name' => 'action',
269
-				'content' => gettext ( 'Save' ),
269
+				'content' => gettext('Save'),
270 270
 				'value' => 'save',
271 271
 				'id' => 'submit',
272 272
 				'type' => 'button',
@@ -276,17 +276,17 @@  discard block
 block discarded – undo
276 276
 		return $form;
277 277
 	}
278 278
 	function get_pricing_search_form() {
279
-		$form ['forms'] = array (
279
+		$form ['forms'] = array(
280 280
 				"",
281
-				array (
281
+				array(
282 282
 						'id' => "price_search" 
283 283
 				) 
284 284
 		);
285
-		$form ['Search'] = array (
286
-				array (
287
-						gettext ( 'Name' ),
285
+		$form ['Search'] = array(
286
+				array(
287
+						gettext('Name'),
288 288
 						'INPUT',
289
-						array (
289
+						array(
290 290
 								'name' => 'name[name]',
291 291
 								'',
292 292
 								'size' => '20',
@@ -302,8 +302,8 @@  discard block
 block discarded – undo
302 302
 						'search_string_type',
303 303
 						'' 
304 304
 				),
305
-				array (
306
-						gettext ( 'Routing Type' ),
305
+				array(
306
+						gettext('Routing Type'),
307 307
 						'routing_type',
308 308
 						'SELECT',
309 309
 						'',
@@ -317,10 +317,10 @@  discard block
 block discarded – undo
317 317
 						'',
318 318
 						'' 
319 319
 				),
320
-				array (
321
-						gettext ( 'Initial Increment ' ),
320
+				array(
321
+						gettext('Initial Increment '),
322 322
 						'INPUT',
323
-						array (
323
+						array(
324 324
 								'name' => 'initially_increment[initially_increment]',
325 325
 								'',
326 326
 								'size' => '20',
@@ -336,10 +336,10 @@  discard block
 block discarded – undo
336 336
 						'search_string_type',
337 337
 						'' 
338 338
 				),
339
-				array (
340
-						gettext ( 'Default Increment ' ),
339
+				array(
340
+						gettext('Default Increment '),
341 341
 						'INPUT',
342
-						array (
342
+						array(
343 343
 								'name' => 'inc[inc]',
344 344
 								'',
345 345
 								'size' => '20',
@@ -356,7 +356,7 @@  discard block
 block discarded – undo
356 356
 						'' 
357 357
 				),
358 358
 				
359
-				array (
359
+				array(
360 360
 						'Status',
361 361
 						'status',
362 362
 						'SELECT',
@@ -371,7 +371,7 @@  discard block
 block discarded – undo
371 371
 						'',
372 372
 						'' 
373 373
 				),
374
-				array (
374
+				array(
375 375
 						'',
376 376
 						'HIDDEN',
377 377
 						'ajax_search',
@@ -380,7 +380,7 @@  discard block
 block discarded – undo
380 380
 						'',
381 381
 						'' 
382 382
 				),
383
-				array (
383
+				array(
384 384
 						'',
385 385
 						'HIDDEN',
386 386
 						'advance_search',
@@ -391,18 +391,18 @@  discard block
 block discarded – undo
391 391
 				) 
392 392
 		)
393 393
 		;
394
-		$form ['button_search'] = array (
394
+		$form ['button_search'] = array(
395 395
 				'name' => 'action',
396 396
 				'id' => "price_search_btn",
397
-				'content' => gettext ( 'Search' ),
397
+				'content' => gettext('Search'),
398 398
 				'value' => 'save',
399 399
 				'type' => 'button',
400 400
 				'class' => "btn btn-line-parrot pull-right" 
401 401
 		);
402
-		$form ['button_reset'] = array (
402
+		$form ['button_reset'] = array(
403 403
 				'name' => 'action',
404 404
 				'id' => "id_reset",
405
-				'content' => gettext ( 'Clear' ),
405
+				'content' => gettext('Clear'),
406 406
 				'value' => 'cancel',
407 407
 				'type' => 'reset',
408 408
 				'class' => "btn btn-line-sky pull-right margin-x-10" 
@@ -416,8 +416,8 @@  discard block
 block discarded – undo
416 416
 	 */
417 417
 	function build_pricing_list_for_admin() {
418 418
 		// array(display name, width, db_field_parent_table,feidname, db_field_child_table,function name);
419
-		$grid_field_arr = json_encode ( array (
420
-				array (
419
+		$grid_field_arr = json_encode(array(
420
+				array(
421 421
 						"<input type='checkbox' name='chkAll' class='ace checkall'/><label class='lbl'></label>",
422 422
 						"30",
423 423
 						"",
@@ -433,8 +433,8 @@  discard block
 block discarded – undo
433 433
 				 * For Rategroup edit on Name
434 434
 				 * *
435 435
 				 */
436
-				array (
437
-						gettext ( "Name" ),
436
+				array(
437
+						gettext("Name"),
438 438
 						"110",
439 439
 						"name",
440 440
 						"",
@@ -447,16 +447,16 @@  discard block
 block discarded – undo
447 447
 				/**
448 448
 				 * ************************************
449 449
 				 */
450
-				array (
451
-						gettext ( "Routing Type" ),
450
+				array(
451
+						gettext("Routing Type"),
452 452
 						"120",
453 453
 						"routing_type",
454 454
 						"routing_type",
455 455
 						"routing_type",
456 456
 						"get_routetype" 
457 457
 				),
458
-				array (
459
-						gettext ( "Initial Increment" ),
458
+				array(
459
+						gettext("Initial Increment"),
460 460
 						"140",
461 461
 						"initially_increment",
462 462
 						"",
@@ -466,7 +466,7 @@  discard block
 block discarded – undo
466 466
 						"true",
467 467
 						"center" 
468 468
 				),
469
-				array (
469
+				array(
470 470
 						"Default Increment",
471 471
 						"140",
472 472
 						"inc",
@@ -477,8 +477,8 @@  discard block
 block discarded – undo
477 477
 						"true",
478 478
 						"center" 
479 479
 				),
480
-				array (
481
-						gettext ( "Markup(%)" ),
480
+				array(
481
+						gettext("Markup(%)"),
482 482
 						"100",
483 483
 						"markup",
484 484
 						"",
@@ -488,8 +488,8 @@  discard block
 block discarded – undo
488 488
 						"true",
489 489
 						"center" 
490 490
 				),
491
-				array (
492
-						gettext ( "Rate Count" ),
491
+				array(
492
+						gettext("Rate Count"),
493 493
 						"100",
494 494
 						"id",
495 495
 						"pricelist_id",
@@ -499,8 +499,8 @@  discard block
 block discarded – undo
499 499
 						"true",
500 500
 						"center" 
501 501
 				),
502
-				array (
503
-						gettext ( "Status" ),
502
+				array(
503
+						gettext("Status"),
504 504
 						"110",
505 505
 						"status",
506 506
 						"id",
@@ -510,8 +510,8 @@  discard block
 block discarded – undo
510 510
 						"true",
511 511
 						"center" 
512 512
 				),
513
-				array (
514
-						gettext ( "Created Date" ),
513
+				array(
514
+						gettext("Created Date"),
515 515
 						"120",
516 516
 						"creation_date",
517 517
 						"creation_date",
@@ -521,8 +521,8 @@  discard block
 block discarded – undo
521 521
 						"true",
522 522
 						"center" 
523 523
 				),
524
-				array (
525
-						gettext ( "Modified Date" ),
524
+				array(
525
+						gettext("Modified Date"),
526 526
 						"140",
527 527
 						"last_modified_date",
528 528
 						"last_modified_date",
@@ -532,45 +532,45 @@  discard block
 block discarded – undo
532 532
 						"true",
533 533
 						"center" 
534 534
 				),
535
-				array (
536
-						gettext ( "Action" ),
535
+				array(
536
+						gettext("Action"),
537 537
 						"150",
538 538
 						"",
539 539
 						"",
540 540
 						"",
541
-						array (
542
-								"EDIT" => array (
541
+						array(
542
+								"EDIT" => array(
543 543
 										"url" => "pricing/price_edit/",
544 544
 										"mode" => "popup" 
545 545
 								),
546 546
 								
547
-								"DELETE" => array (
547
+								"DELETE" => array(
548 548
 										"url" => "pricing/price_delete/",
549 549
 										"mode" => "single" 
550 550
 								) 
551 551
 						) 
552 552
 				) 
553
-		) );
553
+		));
554 554
 		return $grid_field_arr;
555 555
 	}
556 556
 	function build_grid_buttons() {
557
-		$buttons_json = json_encode ( array (
558
-				array (
559
-						gettext ( "Create" ),
557
+		$buttons_json = json_encode(array(
558
+				array(
559
+						gettext("Create"),
560 560
 						"btn btn-line-warning btn",
561 561
 						"fa fa-plus-circle fa-lg",
562 562
 						"button_action",
563 563
 						"/pricing/price_add/",
564 564
 						"popup" 
565 565
 				),
566
-				array (
567
-						gettext ( "Delete" ),
566
+				array(
567
+						gettext("Delete"),
568 568
 						"btn btn-line-danger",
569 569
 						"fa fa-times-circle fa-lg",
570 570
 						"button_action",
571 571
 						"/pricing/price_delete_multiple/" 
572 572
 				) 
573
-		) );
573
+		));
574 574
 		return $buttons_json;
575 575
 	}
576 576
 }
Please login to merge, or discard this patch.
Braces   +2 added lines, -1 removed lines patch added patch discarded remove patch
@@ -20,8 +20,9 @@
 block discarded – undo
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
 class pricing_form {
26 27
 	function __construct($library_name = '') {
27 28
 		$this->CI = & get_instance ();
Please login to merge, or discard this patch.
web_interface/astpp/application/modules/rates/models/rates_model.php 2 patches
Spacing   +146 added lines, -146 removed lines patch added patch discarded remove patch
@@ -22,105 +22,105 @@  discard block
 block discarded – undo
22 22
 // ##############################################################################
23 23
 class rates_model extends CI_Model {
24 24
 	function rates_model() {
25
-		parent::__construct ();
25
+		parent::__construct();
26 26
 	}
27 27
 	function get_termination_rates_list($flag, $start = 0, $limit = 0) {
28
-		$this->db_model->build_search ( 'termination_rates_list_search' );
28
+		$this->db_model->build_search('termination_rates_list_search');
29 29
 		/**
30 30
 		 * ******
31 31
 		 * ASTPP 3.0
32 32
 		 * Batch Delete
33 33
 		 * *******
34 34
 		 */
35
-		if ($this->session->userdata ( 'advance_batch_delete' ) == 1) {
35
+		if ($this->session->userdata('advance_batch_delete') == 1) {
36 36
 			
37 37
 			//Samir - Added if condition to resolve "Delete Search Record - This option deletes ALL termination rates #264"
38 38
 			if (count($this->db->ar_where) > 0)
39 39
 			{
40
-				$this->db->where ( array (
40
+				$this->db->where(array(
41 41
 						"trunk_id >" => "0" 
42
-				) );
43
-				$this->db->delete ( "outbound_routes" );				
42
+				));
43
+				$this->db->delete("outbound_routes");				
44 44
 			}
45
-			$this->session->set_userdata ( 'advance_batch_delete', '0' );
46
-			$this->session->unset_userdata ( 'advance_batch_delete' );			
45
+			$this->session->set_userdata('advance_batch_delete', '0');
46
+			$this->session->unset_userdata('advance_batch_delete');			
47 47
 		}
48 48
 		/**
49 49
 		 * ***********
50 50
 		 */
51 51
 		if ($flag) {
52
-			$query = $this->db_model->select ( "*", "outbound_routes", "", "id", "ASC", $limit, $start );
52
+			$query = $this->db_model->select("*", "outbound_routes", "", "id", "ASC", $limit, $start);
53 53
 		} else {
54
-			$query = $this->db_model->countQuery ( "*", "outbound_routes", "" );
54
+			$query = $this->db_model->countQuery("*", "outbound_routes", "");
55 55
 		}
56 56
 		return $query;
57 57
 	}
58 58
 	function get_termination_rate($flag, $start = 0, $limit = 0, $export = true) {
59
-		$this->db_model->build_search ( 'termination_rates_list_search' );
60
-		$this->db->from ( 'outbound_routes' );
59
+		$this->db_model->build_search('termination_rates_list_search');
60
+		$this->db->from('outbound_routes');
61 61
 		if ($flag) {
62 62
 			if ($export)
63
-				$this->db->limit ( $limit, $start );
64
-			$result = $this->db->get ();
63
+				$this->db->limit($limit, $start);
64
+			$result = $this->db->get();
65 65
 		} else {
66
-			$result = $this->db->count_all_results ();
66
+			$result = $this->db->count_all_results();
67 67
 		}
68 68
 		return $result;
69 69
 	}
70 70
 	function get_origination_rate($flag, $start = 0, $limit = 0, $export = true) {
71
-		$this->db_model->build_search ( 'origination_rate_list_search' );
72
-		if ($this->session->userdata ( 'logintype' ) == 1 || $this->session->userdata ( 'logintype' ) == 5) {
73
-			$account_data = $this->session->userdata ( "accountinfo" );
71
+		$this->db_model->build_search('origination_rate_list_search');
72
+		if ($this->session->userdata('logintype') == 1 || $this->session->userdata('logintype') == 5) {
73
+			$account_data = $this->session->userdata("accountinfo");
74 74
 			$reseller = $account_data ['id'];
75
-			$where = array (
75
+			$where = array(
76 76
 					"reseller_id" => $reseller 
77 77
 			);
78 78
 		} else {
79
-			$where = array (
79
+			$where = array(
80 80
 					'reseller_id' => '0' 
81 81
 			);
82 82
 		}
83 83
 		
84
-		$this->db_model->build_search ( 'origination_rate_list_search' );
84
+		$this->db_model->build_search('origination_rate_list_search');
85 85
 		if ($flag) {
86 86
 			if ($export)
87
-				$this->db->limit ( $limit, $start );
88
-			$result = $this->db_model->select ( "*", "routes", $where, "id", "ASC", $limit, $start );
87
+				$this->db->limit($limit, $start);
88
+			$result = $this->db_model->select("*", "routes", $where, "id", "ASC", $limit, $start);
89 89
 		} else {
90
-			$result = $this->db_model->countQuery ( "*", "routes", $where );
90
+			$result = $this->db_model->countQuery("*", "routes", $where);
91 91
 		}
92 92
 		// echo "<pre>";print_r($result->result());exit;
93 93
 		return $result;
94 94
 	}
95 95
 	function get_origination_rate_for_user($flag, $start = 0, $limit = 0, $export = true) {
96
-		$this->db_model->build_search ( 'origination_rate_list_search' );
96
+		$this->db_model->build_search('origination_rate_list_search');
97 97
 		
98
-		$account_data = $this->session->userdata ( "accountinfo" );
98
+		$account_data = $this->session->userdata("accountinfo");
99 99
 		
100
-		$where = array (
100
+		$where = array(
101 101
 				"pricelist_id" => $account_data ["pricelist_id"] 
102 102
 		);
103 103
 		
104
-		$this->db_model->build_search ( 'origination_rate_list_search' );
104
+		$this->db_model->build_search('origination_rate_list_search');
105 105
 		if ($flag) {
106 106
 			if ($export)
107
-				$this->db->limit ( $limit, $start );
108
-			$result = $this->db_model->select ( "*", "routes", $where, "id", "ASC", $limit, $start );
107
+				$this->db->limit($limit, $start);
108
+			$result = $this->db_model->select("*", "routes", $where, "id", "ASC", $limit, $start);
109 109
 		} else {
110
-			$result = $this->db_model->countQuery ( "*", "routes", $where );
110
+			$result = $this->db_model->countQuery("*", "routes", $where);
111 111
 		}
112 112
 		return $result;
113 113
 	}
114 114
 	// ==============================================
115 115
 	function get_origination_rate_list($flag, $start = 0, $limit = 0) {
116
-		$this->db_model->build_search ( 'origination_rate_list_search' );
117
-		if ($this->session->userdata ( 'logintype' ) == 1 || $this->session->userdata ( 'logintype' ) == 5) {
118
-			$account_data = $this->session->userdata ( "accountinfo" );
119
-			$where = array (
116
+		$this->db_model->build_search('origination_rate_list_search');
117
+		if ($this->session->userdata('logintype') == 1 || $this->session->userdata('logintype') == 5) {
118
+			$account_data = $this->session->userdata("accountinfo");
119
+			$where = array(
120 120
 					"reseller_id" => $account_data ['id'] 
121 121
 			);
122 122
 		} else {
123
-			$where = array (
123
+			$where = array(
124 124
 					'reseller_id' => '0' 
125 125
 			);
126 126
 		}
@@ -130,158 +130,158 @@  discard block
 block discarded – undo
130 130
 		 * Batch delete
131 131
 		 * ***********
132 132
 		 */
133
-		if ($this->session->userdata ( 'advance_batch_delete' ) == 1) {
133
+		if ($this->session->userdata('advance_batch_delete') == 1) {
134 134
 			//Samir - Added if condition to resolve "Delete Search Record - This option deletes ALL termination rates #264"
135 135
 			if (count($this->db->ar_where) > 0)
136 136
 			{
137
-				$this->db->where ( $where );
138
-				$this->db->delete ( "routes" );				
137
+				$this->db->where($where);
138
+				$this->db->delete("routes");				
139 139
 			}
140
-			$this->session->set_userdata ( 'advance_batch_delete', '0' );	
141
-			$this->session->unset_userdata ( 'advance_batch_delete' );
140
+			$this->session->set_userdata('advance_batch_delete', '0');	
141
+			$this->session->unset_userdata('advance_batch_delete');
142 142
 		}
143
-		$this->db_model->build_search ( 'origination_rate_list_search' );
143
+		$this->db_model->build_search('origination_rate_list_search');
144 144
 		/**
145 145
 		 * ********************
146 146
 		 */
147 147
 		
148 148
 		if ($flag) {
149
-			$query = $this->db_model->select ( "*", "routes", $where, "id", "ASC", $limit, $start );
149
+			$query = $this->db_model->select("*", "routes", $where, "id", "ASC", $limit, $start);
150 150
 		} else {
151
-			$query = $this->db_model->countQuery ( "*", "routes", $where );
151
+			$query = $this->db_model->countQuery("*", "routes", $where);
152 152
 		}
153 153
 		// echo $this->db->last_query();
154 154
 		return $query;
155 155
 	}
156 156
 	function getunblocked_pattern_list($accountid, $flag, $start = 0, $limit = 0) {
157
-		$this->db_model->build_search ( 'origination_rate_list_search' );
158
-		if ($this->session->userdata ( 'logintype' ) == 1 || $this->session->userdata ( 'logintype' ) == 5) {
159
-			$account_data = $this->session->userdata ( "accountinfo" );
157
+		$this->db_model->build_search('origination_rate_list_search');
158
+		if ($this->session->userdata('logintype') == 1 || $this->session->userdata('logintype') == 5) {
159
+			$account_data = $this->session->userdata("accountinfo");
160 160
 			$reseller = $account_data ['id'];
161
-			$where = array (
161
+			$where = array(
162 162
 					"reseller_id" => $reseller,
163 163
 					"status" => "0" 
164 164
 			);
165 165
 		} else {
166
-			$where = array (
166
+			$where = array(
167 167
 					"status" => "0",
168 168
 					'reseller_id' => '0' 
169 169
 			);
170 170
 		}
171
-		$where1 = '(pattern NOT IN (select blocked_patterns from block_patterns where accountid = "' . $accountid . '"))';
172
-		$this->db->where ( $where1 );
171
+		$where1 = '(pattern NOT IN (select blocked_patterns from block_patterns where accountid = "'.$accountid.'"))';
172
+		$this->db->where($where1);
173 173
 		if ($flag) {
174
-			$query = $this->db_model->select ( "*", "routes", $where, "id", "ASC", $limit, $start );
174
+			$query = $this->db_model->select("*", "routes", $where, "id", "ASC", $limit, $start);
175 175
 			// echo "<pre>"; print_r($query); exit;
176 176
 		} else {
177
-			$query = $this->db_model->countQuery ( "*", "routes", $where );
177
+			$query = $this->db_model->countQuery("*", "routes", $where);
178 178
 		}
179 179
 		return $query;
180 180
 	}
181 181
 	function getunblocked_package_pattern($accountid, $flag, $start = 0, $limit = 0) {
182
-		$this->db_model->build_search ( 'origination_rate_list_search' );
183
-		if ($this->session->userdata ( 'logintype' ) == 1 || $this->session->userdata ( 'logintype' ) == 5) {
184
-			$account_data = $this->session->userdata ( "accountinfo" );
182
+		$this->db_model->build_search('origination_rate_list_search');
183
+		if ($this->session->userdata('logintype') == 1 || $this->session->userdata('logintype') == 5) {
184
+			$account_data = $this->session->userdata("accountinfo");
185 185
 			$reseller = $account_data ['id'];
186
-			$where = array (
186
+			$where = array(
187 187
 					"reseller_id" => $reseller,
188 188
 					"status" => "0" 
189 189
 			);
190 190
 		} else {
191
-			$where = array (
191
+			$where = array(
192 192
 					"status" => "0",
193 193
 					'reseller_id' => '0' 
194 194
 			);
195 195
 		}
196
-		$where1 = '(pattern NOT IN (select DISTINCT patterns from package_patterns where package_id = "' . $accountid . '"))';
197
-		$this->db->where ( $where1 );
196
+		$where1 = '(pattern NOT IN (select DISTINCT patterns from package_patterns where package_id = "'.$accountid.'"))';
197
+		$this->db->where($where1);
198 198
 		if ($flag) {
199
-			$query = $this->db_model->select ( "*", "routes", $where, "id", "ASC", $limit, $start );
199
+			$query = $this->db_model->select("*", "routes", $where, "id", "ASC", $limit, $start);
200 200
 		} else {
201
-			$query = $this->db_model->countQuery ( "*", "routes", $where );
201
+			$query = $this->db_model->countQuery("*", "routes", $where);
202 202
 		}
203 203
 		return $query;
204 204
 	}
205 205
 	function get_origination_rate_list_for_user($flag, $start = 0, $limit = 0) {
206
-		$this->db_model->build_search ( 'user_rates_list_search' );
206
+		$this->db_model->build_search('user_rates_list_search');
207 207
 		
208
-		$account_data = $this->session->userdata ( "accountinfo" );
209
-		$where = array (
208
+		$account_data = $this->session->userdata("accountinfo");
209
+		$where = array(
210 210
 				"pricelist_id" => $account_data ["pricelist_id"],
211 211
 				"status" => '0' 
212 212
 		);
213 213
 		
214
-		$this->db_model->build_search ( 'origination_rate_list_search' );
214
+		$this->db_model->build_search('origination_rate_list_search');
215 215
 		if ($flag) {
216
-			$query = $this->db_model->select ( "*", "routes", $where, "id", "ASC", $limit, $start );
216
+			$query = $this->db_model->select("*", "routes", $where, "id", "ASC", $limit, $start);
217 217
 		} else {
218
-			$query = $this->db_model->countQuery ( "*", "routes", $where );
218
+			$query = $this->db_model->countQuery("*", "routes", $where);
219 219
 		}
220 220
 		return $query;
221 221
 	}
222 222
 	function add_termination_rate($add_array) {
223
-		unset ( $add_array ["action"] );
224
-		if ($this->session->userdata ( 'logintype' ) == 1 || $this->session->userdata ( 'logintype' ) == 5) {
225
-			$account_data = $this->session->userdata ( "accountinfo" );
223
+		unset ($add_array ["action"]);
224
+		if ($this->session->userdata('logintype') == 1 || $this->session->userdata('logintype') == 5) {
225
+			$account_data = $this->session->userdata("accountinfo");
226 226
 			$reseller = $account_data ['id'];
227 227
 			$add_array ['reseller_id'] = $reseller;
228 228
 		}
229
-		$add_array ['pattern'] = "^" . $add_array ['pattern'] . ".*";
229
+		$add_array ['pattern'] = "^".$add_array ['pattern'].".*";
230 230
 		$add_array ['prepend'] = $add_array ['prepend'];
231 231
 		/*
232 232
 		 * ASTPP 3.0
233 233
 		 * add creation date.
234 234
 		 */
235
-		$add_array ['creation_date'] = gmdate ( 'Y-m-d H:i:s' );
235
+		$add_array ['creation_date'] = gmdate('Y-m-d H:i:s');
236 236
 		/**
237 237
 		 * ****************************************************
238 238
 		 */
239
-		$this->insert_if_not_exitst ( $add_array, "outbound_routes" );
239
+		$this->insert_if_not_exitst($add_array, "outbound_routes");
240 240
 		// $this->db->insert("outbound_routes", $add_array);
241 241
 		return true;
242 242
 	}
243 243
 	function edit_termination_rate($data, $id) {
244
-		unset ( $data ["action"] );
244
+		unset ($data ["action"]);
245 245
 		/*
246 246
 		 * ASTPP 3.0
247 247
 		 * Edit time last modified date
248 248
 		 */
249
-		$data ['last_modified_date'] = gmdate ( 'Y-m-d H:i:s' );
249
+		$data ['last_modified_date'] = gmdate('Y-m-d H:i:s');
250 250
 		/**
251 251
 		 * ************************************************
252 252
 		 */
253
-		$data ['pattern'] = "^" . $data ['pattern'] . ".*";
254
-		$this->db->where ( "id", $id );
255
-		$this->db->update ( "outbound_routes", $data );
253
+		$data ['pattern'] = "^".$data ['pattern'].".*";
254
+		$this->db->where("id", $id);
255
+		$this->db->update("outbound_routes", $data);
256 256
 	}
257 257
 	function remove_termination_rate($id) {
258
-		$this->db->where ( "id", $id );
259
-		$this->db->delete ( "outbound_routes" );
258
+		$this->db->where("id", $id);
259
+		$this->db->delete("outbound_routes");
260 260
 		return true;
261 261
 	}
262 262
 	function add_origination_rate($add_array) {
263
-		unset ( $add_array ["action"] );
263
+		unset ($add_array ["action"]);
264 264
 		/*
265 265
 		 * ASTPP 3.0
266 266
 		 * ADD time put creation date in routes table
267 267
 		 */
268
-		$add_array ['creation_date'] = gmdate ( 'Y-m-d H:i:s' );
268
+		$add_array ['creation_date'] = gmdate('Y-m-d H:i:s');
269 269
 		/**
270 270
 		 * *******************************************
271 271
 		 */
272
-		if ($this->session->userdata ( 'logintype' ) == 1 || $this->session->userdata ( 'logintype' ) == 5) {
273
-			$account_data = $this->session->userdata ( "accountinfo" );
272
+		if ($this->session->userdata('logintype') == 1 || $this->session->userdata('logintype') == 5) {
273
+			$account_data = $this->session->userdata("accountinfo");
274 274
 			$reseller = $account_data ['id'];
275 275
 			$add_array ['reseller_id'] = $reseller;
276 276
 		}
277
-		$add_array ['pattern'] = "^" . $add_array ['pattern'] . ".*";
277
+		$add_array ['pattern'] = "^".$add_array ['pattern'].".*";
278 278
 		/**
279 279
 		 * ***********
280 280
 		 * ASTPP 3.0
281 281
 		 * Rate insert
282 282
 		 * ************
283 283
 		 */
284
-		$this->insert_if_not_exitst ( $add_array, "routes" );
284
+		$this->insert_if_not_exitst($add_array, "routes");
285 285
 		// $this->db->insert("routes", $add_array);
286 286
 		/**
287 287
 		 * ****************************
@@ -289,28 +289,28 @@  discard block
 block discarded – undo
289 289
 		return true;
290 290
 	}
291 291
 	function edit_origination_rate($data, $id) {
292
-		unset ( $data ["action"] );
292
+		unset ($data ["action"]);
293 293
 		/*
294 294
 		 * ASTPP 3.0
295 295
 		 * Edit tile last modified date update
296 296
 		 */
297
-		$data ['last_modified_date'] = gmdate ( 'Y-m-d H:i:s' );
297
+		$data ['last_modified_date'] = gmdate('Y-m-d H:i:s');
298 298
 		/**
299 299
 		 * *****************************************************
300 300
 		 */
301
-		$data ['pattern'] = "^" . $data ['pattern'] . ".*";
302
-		$this->db->where ( "id", $id );
303
-		$this->db->update ( "routes", $data );
301
+		$data ['pattern'] = "^".$data ['pattern'].".*";
302
+		$this->db->where("id", $id);
303
+		$this->db->update("routes", $data);
304 304
 	}
305 305
 	function remove_origination_rate($id) {
306
-		$this->db->where ( "id", $id );
307
-		$this->db->delete ( "routes" );
306
+		$this->db->where("id", $id);
307
+		$this->db->delete("routes");
308 308
 		return true;
309 309
 	}
310 310
 	function get_trunk_name($field_value) {
311
-		$this->db->where ( "name", $field_value );
312
-		$query = $this->db->get ( 'trunks' );
313
-		$data = $query->result ();
311
+		$this->db->where("name", $field_value);
312
+		$query = $this->db->get('trunks');
313
+		$data = $query->result();
314 314
 		if ($query->num_rows > 0) {
315 315
 			return $data [0]->id;
316 316
 		} else {
@@ -318,8 +318,8 @@  discard block
 block discarded – undo
318 318
 		}
319 319
 	}
320 320
 	function bulk_insert_termination_rate($field_values, $count) {
321
-		$keys = array_keys ( $field_values );
322
-		$arr_key = array_keys ( $field_values [$keys [0]] );
321
+		$keys = array_keys($field_values);
322
+		$arr_key = array_keys($field_values [$keys [0]]);
323 323
 		$str = null;
324 324
 		$i = 0;
325 325
 		$update_fields [] = "comment=VALUES(comment),
@@ -333,28 +333,28 @@  discard block
 block discarded – undo
333 333
 		prepend=VALUES(prepend),
334 334
 		last_modified_date=VALUES(last_modified_date),
335 335
 		status=VALUES(status)";
336
-		$insert_string = "INSERT INTO outbound_routes (" . implode ( ', ', $arr_key ) . ") VALUES ";
337
-		$update_string = " ON DUPLICATE KEY UPDATE " . implode ( ', ', $update_fields );
336
+		$insert_string = "INSERT INTO outbound_routes (".implode(', ', $arr_key).") VALUES ";
337
+		$update_string = " ON DUPLICATE KEY UPDATE ".implode(', ', $update_fields);
338 338
 		$k = 0;
339
-		$j = ceil ( $count / 500 );
339
+		$j = ceil($count / 500);
340 340
 		$current_value = 0;
341
-		for($i = 0; $i < $j; $i ++) {
341
+		for ($i = 0; $i < $j; $i++) {
342 342
 			$str = null;
343
-			for($k = 0; $k <= 500; $k ++) {
343
+			for ($k = 0; $k <= 500; $k++) {
344 344
 				$current_value = ($i * 500) + $k;
345
-				if (isset ( $field_values [$current_value] )) {
346
-					$str .= "('" . implode ( "','", $field_values [$current_value] ) . "'),";
345
+				if (isset ($field_values [$current_value])) {
346
+					$str .= "('".implode("','", $field_values [$current_value])."'),";
347 347
 				}
348 348
 			}
349
-			$str = rtrim ( $str, "," );
350
-			$this->db->query ( $insert_string . $str . $update_string, false );
349
+			$str = rtrim($str, ",");
350
+			$this->db->query($insert_string.$str.$update_string, false);
351 351
 		}
352 352
 		return true;
353 353
 	}
354 354
 	function bulk_insert_origination_rate($field_values, $count) {
355
-		$temp_arr = array ();
356
-		$keys = array_keys ( $field_values );
357
-		$arr_key = array_keys ( $field_values [$keys [0]] );
355
+		$temp_arr = array();
356
+		$keys = array_keys($field_values);
357
+		$arr_key = array_keys($field_values [$keys [0]]);
358 358
 		$str = null;
359 359
 		$i = 0;
360 360
 		$update_fields [] = "comment=VALUES(comment),
@@ -365,60 +365,60 @@  discard block
 block discarded – undo
365 365
 		inc=VALUES(inc),
366 366
 		last_modified_date=VALUES(last_modified_date),
367 367
 		status=VALUES(status)";
368
-		$insert_string = "INSERT INTO routes (" . implode ( ', ', $arr_key ) . ") VALUES ";
369
-		$update_string = " ON DUPLICATE KEY UPDATE " . implode ( ', ', $update_fields );
368
+		$insert_string = "INSERT INTO routes (".implode(', ', $arr_key).") VALUES ";
369
+		$update_string = " ON DUPLICATE KEY UPDATE ".implode(', ', $update_fields);
370 370
 		$k = 0;
371
-		$j = ceil ( $count / 500 );
371
+		$j = ceil($count / 500);
372 372
 		$current_value = 0;
373
-		for($i = 0; $i < $j; $i ++) {
373
+		for ($i = 0; $i < $j; $i++) {
374 374
 			$str = null;
375
-			for($k = 0; $k <= 500; $k ++) {
375
+			for ($k = 0; $k <= 500; $k++) {
376 376
 				$current_value = ($i * 500) + $k;
377
-				if (isset ( $field_values [$current_value] )) {
378
-					$str .= "('" . implode ( "','", $field_values [$current_value] ) . "'),";
377
+				if (isset ($field_values [$current_value])) {
378
+					$str .= "('".implode("','", $field_values [$current_value])."'),";
379 379
 				}
380 380
 			}
381
-			$str = rtrim ( $str, "," );
382
-			$this->db->query ( $insert_string . $str . $update_string, false );
381
+			$str = rtrim($str, ",");
382
+			$this->db->query($insert_string.$str.$update_string, false);
383 383
 		}
384 384
 		return true;
385 385
 	}
386 386
 	function termination_rate_batch_update($update_array) {
387
-		$this->db_model->build_search ( 'termination_rates_list_search' );
388
-		if ($this->session->userdata ( 'logintype' ) == 1 || $this->session->userdata ( 'logintype' ) == 5) {
389
-			$account_data = $this->session->userdata ( "accountinfo" );
390
-			$this->db->where ( "reseller_id", $account_data ['id'] );
387
+		$this->db_model->build_search('termination_rates_list_search');
388
+		if ($this->session->userdata('logintype') == 1 || $this->session->userdata('logintype') == 5) {
389
+			$account_data = $this->session->userdata("accountinfo");
390
+			$this->db->where("reseller_id", $account_data ['id']);
391 391
 		}
392 392
 		
393
-		$updateflg = $this->db_model->build_batch_update_array ( $update_array );
393
+		$updateflg = $this->db_model->build_batch_update_array($update_array);
394 394
 		if ($updateflg)
395
-			return $this->db->update ( "outbound_routes" );
395
+			return $this->db->update("outbound_routes");
396 396
 		else
397 397
 			return false;
398 398
 	}
399 399
 	function origination_rate_batch_update($update_array) {
400
-		$this->db_model->build_search ( 'origination_rate_list_search' );
401
-		if ($this->session->userdata ( 'logintype' ) == 1 || $this->session->userdata ( 'logintype' ) == 5) {
402
-			$account_data = $this->session->userdata ( "accountinfo" );
403
-			$this->db->where ( "reseller_id", $account_data ['id'] );
400
+		$this->db_model->build_search('origination_rate_list_search');
401
+		if ($this->session->userdata('logintype') == 1 || $this->session->userdata('logintype') == 5) {
402
+			$account_data = $this->session->userdata("accountinfo");
403
+			$this->db->where("reseller_id", $account_data ['id']);
404 404
 		}
405
-		$updateflg = $this->db_model->build_batch_update_array ( $update_array );
405
+		$updateflg = $this->db_model->build_batch_update_array($update_array);
406 406
 		if ($updateflg)
407
-			return $this->db->update ( "routes" );
407
+			return $this->db->update("routes");
408 408
 		else
409 409
 			return false;
410 410
 	}
411 411
 	function getreseller_rates_list($flag, $start = 0, $limit = 0, $export = false) {
412
-		$this->db_model->build_search ( 'resellerrates_list_search' );
413
-		$account_data = $this->session->userdata ( "accountinfo" );
414
-		$where = array (
412
+		$this->db_model->build_search('resellerrates_list_search');
413
+		$account_data = $this->session->userdata("accountinfo");
414
+		$where = array(
415 415
 				"status" => "0",
416 416
 				"pricelist_id" => $account_data ["pricelist_id"] 
417 417
 		);
418 418
 		if ($flag) {
419
-			$query = $this->db_model->select ( "*", "routes", $where, "id", "ASC", $limit, $start );
419
+			$query = $this->db_model->select("*", "routes", $where, "id", "ASC", $limit, $start);
420 420
 		} else {
421
-			$query = $this->db_model->countQuery ( "*", "routes", $where );
421
+			$query = $this->db_model->countQuery("*", "routes", $where);
422 422
 		}
423 423
 		return $query;
424 424
 	}
@@ -437,17 +437,17 @@  discard block
 block discarded – undo
437 437
 		$insert_key = "";
438 438
 		$insert_value = "";
439 439
 		$update_str = "";
440
-		foreach ( $add_array as $key => $value ) {
440
+		foreach ($add_array as $key => $value) {
441 441
 			if ($key != 'id') {
442
-				$insert_key .= $key . ",";
443
-				$insert_value .= "'" . mysql_real_escape_string ( $value ) . "',";
444
-				$update_str .= $key . " = '" . mysql_real_escape_string ( $value ) . "',";
442
+				$insert_key .= $key.",";
443
+				$insert_value .= "'".mysql_real_escape_string($value)."',";
444
+				$update_str .= $key." = '".mysql_real_escape_string($value)."',";
445 445
 			}
446 446
 		}
447
-		$insert_key = rtrim ( $insert_key, "," );
448
-		$insert_value = rtrim ( $insert_value, "," );
449
-		$update_str = rtrim ( $update_str, "," );
450
-		$insert_str .= $insert_key . ") values" . "(" . $insert_value . ")  ON DUPLICATE KEY UPDATE $update_str";
451
-		$this->db->query ( $insert_str );
447
+		$insert_key = rtrim($insert_key, ",");
448
+		$insert_value = rtrim($insert_value, ",");
449
+		$update_str = rtrim($update_str, ",");
450
+		$insert_str .= $insert_key.") values"."(".$insert_value.")  ON DUPLICATE KEY UPDATE $update_str";
451
+		$this->db->query($insert_str);
452 452
 	}
453 453
 }
Please login to merge, or discard this patch.
Braces   +19 added lines, -14 removed lines patch added patch discarded remove patch
@@ -59,8 +59,9 @@  discard block
 block discarded – undo
59 59
 		$this->db_model->build_search ( 'termination_rates_list_search' );
60 60
 		$this->db->from ( 'outbound_routes' );
61 61
 		if ($flag) {
62
-			if ($export)
63
-				$this->db->limit ( $limit, $start );
62
+			if ($export) {
63
+							$this->db->limit ( $limit, $start );
64
+			}
64 65
 			$result = $this->db->get ();
65 66
 		} else {
66 67
 			$result = $this->db->count_all_results ();
@@ -83,8 +84,9 @@  discard block
 block discarded – undo
83 84
 		
84 85
 		$this->db_model->build_search ( 'origination_rate_list_search' );
85 86
 		if ($flag) {
86
-			if ($export)
87
-				$this->db->limit ( $limit, $start );
87
+			if ($export) {
88
+							$this->db->limit ( $limit, $start );
89
+			}
88 90
 			$result = $this->db_model->select ( "*", "routes", $where, "id", "ASC", $limit, $start );
89 91
 		} else {
90 92
 			$result = $this->db_model->countQuery ( "*", "routes", $where );
@@ -103,8 +105,9 @@  discard block
 block discarded – undo
103 105
 		
104 106
 		$this->db_model->build_search ( 'origination_rate_list_search' );
105 107
 		if ($flag) {
106
-			if ($export)
107
-				$this->db->limit ( $limit, $start );
108
+			if ($export) {
109
+							$this->db->limit ( $limit, $start );
110
+			}
108 111
 			$result = $this->db_model->select ( "*", "routes", $where, "id", "ASC", $limit, $start );
109 112
 		} else {
110 113
 			$result = $this->db_model->countQuery ( "*", "routes", $where );
@@ -391,10 +394,11 @@  discard block
 block discarded – undo
391 394
 		}
392 395
 		
393 396
 		$updateflg = $this->db_model->build_batch_update_array ( $update_array );
394
-		if ($updateflg)
395
-			return $this->db->update ( "outbound_routes" );
396
-		else
397
-			return false;
397
+		if ($updateflg) {
398
+					return $this->db->update ( "outbound_routes" );
399
+		} else {
400
+					return false;
401
+		}
398 402
 	}
399 403
 	function origination_rate_batch_update($update_array) {
400 404
 		$this->db_model->build_search ( 'origination_rate_list_search' );
@@ -403,10 +407,11 @@  discard block
 block discarded – undo
403 407
 			$this->db->where ( "reseller_id", $account_data ['id'] );
404 408
 		}
405 409
 		$updateflg = $this->db_model->build_batch_update_array ( $update_array );
406
-		if ($updateflg)
407
-			return $this->db->update ( "routes" );
408
-		else
409
-			return false;
410
+		if ($updateflg) {
411
+					return $this->db->update ( "routes" );
412
+		} else {
413
+					return false;
414
+		}
410 415
 	}
411 416
 	function getreseller_rates_list($flag, $start = 0, $limit = 0, $export = false) {
412 417
 		$this->db_model->build_search ( 'resellerrates_list_search' );
Please login to merge, or discard this patch.
web_interface/astpp/application/modules/rates/controllers/rates.php 3 patches
Indentation   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -1374,8 +1374,8 @@
 block discarded – undo
1374 1374
 		force_download ( "Termination_rate_mapper_error.csv", $data );
1375 1375
 	}
1376 1376
 /**
1377
- * **********************
1378
- */
1377
+	 * **********************
1378
+	 */
1379 1379
 }
1380 1380
 ?>
1381 1381
  
Please login to merge, or discard this patch.
Spacing   +681 added lines, -681 removed lines patch added patch discarded remove patch
@@ -22,23 +22,23 @@  discard block
 block discarded – undo
22 22
 // ##############################################################################
23 23
 class Rates extends MX_Controller {
24 24
 	function Rates() {
25
-		parent::__construct ();
25
+		parent::__construct();
26 26
 		
27
-		$this->load->helper ( 'template_inheritance' );
27
+		$this->load->helper('template_inheritance');
28 28
 		
29
-		$this->load->library ( 'session' );
30
-		$this->load->library ( 'rates_form' );
31
-		$this->load->library ( 'astpp/form' );
32
-		$this->load->model ( 'rates_model' );
33
-		$this->load->library ( 'csvreader' );
34
-		ini_set ( "memory_limit", "2048M" );
35
-		ini_set ( "max_execution_time", "259200" );
36
-		if ($this->session->userdata ( 'user_login' ) == FALSE)
37
-			redirect ( base_url () . '/astpp/login' );
29
+		$this->load->library('session');
30
+		$this->load->library('rates_form');
31
+		$this->load->library('astpp/form');
32
+		$this->load->model('rates_model');
33
+		$this->load->library('csvreader');
34
+		ini_set("memory_limit", "2048M");
35
+		ini_set("max_execution_time", "259200");
36
+		if ($this->session->userdata('user_login') == FALSE)
37
+			redirect(base_url().'/astpp/login');
38 38
 	}
39 39
 	function termination_rates_list() {
40
-		$data ['username'] = $this->session->userdata ( 'user_name' );
41
-		$data ['page_title'] = gettext ( 'Termination Rates' );
40
+		$data ['username'] = $this->session->userdata('user_name');
41
+		$data ['page_title'] = gettext('Termination Rates');
42 42
 		$data ['search_flag'] = true;
43 43
 		$data ['batch_update_flag'] = true;
44 44
 		/**
@@ -51,68 +51,68 @@  discard block
 block discarded – undo
51 51
 		/**
52 52
 		 * ************
53 53
 		 */
54
-		$this->session->set_userdata ( 'advance_search', 0 );
55
-		$data ['grid_fields'] = $this->rates_form->build_termination_rate_for_admin ();
56
-		$data ["grid_buttons"] = $this->rates_form->build_grid_buttons ();
57
-		$data ['form_search'] = $this->form->build_serach_form ( $this->rates_form->get_termination_rate_search_form () );
58
-		$data ['form_batch_update'] = $this->form->build_batchupdate_form ( $this->rates_form->termination_rate_batch_update_form () );
59
-		$this->load->view ( 'view_termination_rates_list', $data );
54
+		$this->session->set_userdata('advance_search', 0);
55
+		$data ['grid_fields'] = $this->rates_form->build_termination_rate_for_admin();
56
+		$data ["grid_buttons"] = $this->rates_form->build_grid_buttons();
57
+		$data ['form_search'] = $this->form->build_serach_form($this->rates_form->get_termination_rate_search_form());
58
+		$data ['form_batch_update'] = $this->form->build_batchupdate_form($this->rates_form->termination_rate_batch_update_form());
59
+		$this->load->view('view_termination_rates_list', $data);
60 60
 	}
61 61
 	/**
62 62
 	 * -------Here we write code for controller accounts functions account_list------
63 63
 	 * Listing of Accounts table data through php function json_encode
64 64
 	 */
65 65
 	function termination_rates_list_json() {
66
-		$json_data = array ();
67
-		$count_all = $this->rates_model->get_termination_rates_list ( false );
68
-		$paging_data = $this->form->load_grid_config ( $count_all, $_GET ['rp'], $_GET ['page'] );
66
+		$json_data = array();
67
+		$count_all = $this->rates_model->get_termination_rates_list(false);
68
+		$paging_data = $this->form->load_grid_config($count_all, $_GET ['rp'], $_GET ['page']);
69 69
 		$json_data = $paging_data ["json_paging"];
70 70
 		
71
-		$query = $this->rates_model->get_termination_rates_list ( true, $paging_data ["paging"] ["start"], $paging_data ["paging"] ["page_no"] );
72
-		$grid_fields = json_decode ( $this->rates_form->build_termination_rate_for_admin () );
73
-		$json_data ['rows'] = $this->form->build_grid ( $query, $grid_fields );
71
+		$query = $this->rates_model->get_termination_rates_list(true, $paging_data ["paging"] ["start"], $paging_data ["paging"] ["page_no"]);
72
+		$grid_fields = json_decode($this->rates_form->build_termination_rate_for_admin());
73
+		$json_data ['rows'] = $this->form->build_grid($query, $grid_fields);
74 74
 		
75
-		echo json_encode ( $json_data );
75
+		echo json_encode($json_data);
76 76
 	}
77 77
 	function termination_rates_list_delete($flag = '') {
78
-		$json_data = array ();
79
-		$this->session->set_userdata ( 'advance_batch_data_delete', 1 );
80
-		$count_all = $this->rates_model->get_termination_rates_list ( false );
78
+		$json_data = array();
79
+		$this->session->set_userdata('advance_batch_data_delete', 1);
80
+		$count_all = $this->rates_model->get_termination_rates_list(false);
81 81
 		echo $count_all;
82 82
 	}
83 83
 	/**
84 84
 	 * *************
85 85
 	 */
86 86
 	function termination_rate_import() {
87
-		$data ['page_title'] = gettext ( 'Import Termination Rates' );
88
-		$this->session->set_userdata ( 'import_termination_rate_csv', "" );
89
-		$this->session->set_userdata ( 'import_termination_rate_csv_error', "" );
90
-		$this->load->view ( 'view_import_termination_rate', $data );
87
+		$data ['page_title'] = gettext('Import Termination Rates');
88
+		$this->session->set_userdata('import_termination_rate_csv', "");
89
+		$this->session->set_userdata('import_termination_rate_csv_error', "");
90
+		$this->load->view('view_import_termination_rate', $data);
91 91
 	}
92 92
 	function termination_rate_preview_file() {
93 93
 		$invalid_flag = false;
94
-		$check_header = $this->input->post ( 'check_header', true );
95
-		$data ['page_title'] = gettext ( 'Import Termination Rates' );
96
-		$new_final_arr_key = $this->config->item ( 'Termination-rates-field' );
97
-		if (empty ( $_FILES ) || ! isset ( $_FILES )) {
98
-			redirect ( base_url () . "rates/termination_rates_list/" );
94
+		$check_header = $this->input->post('check_header', true);
95
+		$data ['page_title'] = gettext('Import Termination Rates');
96
+		$new_final_arr_key = $this->config->item('Termination-rates-field');
97
+		if (empty ($_FILES) || ! isset ($_FILES)) {
98
+			redirect(base_url()."rates/termination_rates_list/");
99 99
 		}
100
-		if (isset ( $_FILES ['termination_rate_import'] ['name'] ) && $_FILES ['termination_rate_import'] ['name'] != "" && isset ( $_POST ['trunk_id'] ) && $_POST ['trunk_id'] != '') {
101
-			list ( $txt, $ext ) = explode ( ".", $_FILES ['termination_rate_import'] ['name'] );
100
+		if (isset ($_FILES ['termination_rate_import'] ['name']) && $_FILES ['termination_rate_import'] ['name'] != "" && isset ($_POST ['trunk_id']) && $_POST ['trunk_id'] != '') {
101
+			list ($txt, $ext) = explode(".", $_FILES ['termination_rate_import'] ['name']);
102 102
 			if ($ext == "csv" && $_FILES ['termination_rate_import'] ['size'] > 0) {
103 103
 				$error = $_FILES ['termination_rate_import'] ['error'];
104 104
 				if ($error == 0) {
105 105
 					$uploadedFile = $_FILES ["termination_rate_import"] ["tmp_name"];
106
-					$csv_data = $this->csvreader->parse_file ( $uploadedFile, $new_final_arr_key, $check_header );
107
-					if (! empty ( $csv_data )) {
108
-						$full_path = $this->config->item ( 'rates-file-path' );
109
-						$actual_file_name = "ASTPP-TERMINATION-RATES-" . date ( "Y-m-d H:i:s" ) . "." . $ext;
110
-						if (move_uploaded_file ( $uploadedFile, $full_path . $actual_file_name )) {
106
+					$csv_data = $this->csvreader->parse_file($uploadedFile, $new_final_arr_key, $check_header);
107
+					if ( ! empty ($csv_data)) {
108
+						$full_path = $this->config->item('rates-file-path');
109
+						$actual_file_name = "ASTPP-TERMINATION-RATES-".date("Y-m-d H:i:s").".".$ext;
110
+						if (move_uploaded_file($uploadedFile, $full_path.$actual_file_name)) {
111 111
 							$data ['csv_tmp_data'] = $csv_data;
112 112
 							$data ['trunkid'] = $_POST ['trunk_id'];
113 113
 							$data ['check_header'] = $check_header;
114
-							$data ['page_title'] = gettext ( 'Termination Rates Preview' );
115
-							$this->session->set_userdata ( 'import_termination_rate_csv', $actual_file_name );
114
+							$data ['page_title'] = gettext('Termination Rates Preview');
115
+							$this->session->set_userdata('import_termination_rate_csv', $actual_file_name);
116 116
 						} else {
117 117
 							$data ['error'] = "File Uploading Fail Please Try Again";
118 118
 						}
@@ -128,134 +128,134 @@  discard block
 block discarded – undo
128 128
 		}
129 129
 		if ($invalid_flag) {
130 130
 			$str = '';
131
-			if (! isset ( $_POST ['trunk_id'] ) || empty ( $_POST ['trunk_id'] )) {
131
+			if ( ! isset ($_POST ['trunk_id']) || empty ($_POST ['trunk_id'])) {
132 132
 				$str .= '<br/>Please Create Trunk.';
133 133
 			}
134
-			if (empty ( $_FILES ['termination_rate_import'] ['name'] )) {
134
+			if (empty ($_FILES ['termination_rate_import'] ['name'])) {
135 135
 				$str .= '<br/>Please Select  File.';
136 136
 			}
137 137
 			$data ['error'] = $str;
138 138
 		}
139
-		$this->load->view ( 'view_import_termination_rate', $data );
139
+		$this->load->view('view_import_termination_rate', $data);
140 140
 	}
141 141
 	function termination_rate_rates_import($trunkID, $check_header = false) {
142
-		$new_final_arr = array ();
143
-		$invalid_array = array ();
142
+		$new_final_arr = array();
143
+		$invalid_array = array();
144 144
 		$row_count = 0;
145
-		$new_final_arr_key = $this->config->item ( 'Termination-rates-field' );
146
-		$screen_path = $this->config->item ( 'screen_path' );
147
-		if ($this->session->userdata ( 'logintype' ) == 1 || $this->session->userdata ( 'logintype' ) == 5) {
148
-			$account_data = $this->session->userdata ( "accountinfo" );
145
+		$new_final_arr_key = $this->config->item('Termination-rates-field');
146
+		$screen_path = $this->config->item('screen_path');
147
+		if ($this->session->userdata('logintype') == 1 || $this->session->userdata('logintype') == 5) {
148
+			$account_data = $this->session->userdata("accountinfo");
149 149
 		}
150
-		$full_path = $this->config->item ( 'rates-file-path' );
151
-		$terminationrate_file_name = $this->session->userdata ( 'import_termination_rate_csv' );
152
-		$csv_tmp_data = $this->csvreader->parse_file ( $full_path . $terminationrate_file_name, $new_final_arr_key, $check_header );
150
+		$full_path = $this->config->item('rates-file-path');
151
+		$terminationrate_file_name = $this->session->userdata('import_termination_rate_csv');
152
+		$csv_tmp_data = $this->csvreader->parse_file($full_path.$terminationrate_file_name, $new_final_arr_key, $check_header);
153 153
 		$i = 0;
154
-		foreach ( $csv_tmp_data as $key => $csv_data ) {
155
-			if (isset ( $csv_data ['pattern'] ) && $csv_data ['pattern'] != '' && $i != 0) {
154
+		foreach ($csv_tmp_data as $key => $csv_data) {
155
+			if (isset ($csv_data ['pattern']) && $csv_data ['pattern'] != '' && $i != 0) {
156 156
 				$str = null;
157
-				$csv_data ['prepend'] = isset ( $csv_data ['prepend'] ) ? $csv_data ['prepend'] : '';
158
-				$csv_data ['comment'] = isset ( $csv_data ['comment'] ) ? $csv_data ['comment'] : '';
159
-				$csv_data ['connectcost'] = isset ( $csv_data ['connectcost'] ) ? $this->common_model->add_calculate_currency ( $csv_data ['connectcost'], '', '', false, false ) : 0;
160
-				$csv_data ['includedseconds'] = isset ( $csv_data ['includedseconds'] ) ? $csv_data ['includedseconds'] : 0;
161
-				$csv_data ['cost'] = ! empty ( $csv_data ['cost'] ) && is_numeric ( $csv_data ['cost'] ) ? $this->common_model->add_calculate_currency ( $csv_data ['cost'], '', '', false, false ) : 0;
162
-				$csv_data ['inc'] = isset ( $csv_data ['inc'] ) ? $csv_data ['inc'] : 0;
163
-				$csv_data ['precedence'] = isset ( $csv_data ['precedence'] ) ? $csv_data ['precedence'] : '';
164
-				$csv_data ['strip'] = isset ( $csv_data ['strip'] ) ? $csv_data ['strip'] : '';
165
-				$str = $this->data_validate ( $csv_data );
157
+				$csv_data ['prepend'] = isset ($csv_data ['prepend']) ? $csv_data ['prepend'] : '';
158
+				$csv_data ['comment'] = isset ($csv_data ['comment']) ? $csv_data ['comment'] : '';
159
+				$csv_data ['connectcost'] = isset ($csv_data ['connectcost']) ? $this->common_model->add_calculate_currency($csv_data ['connectcost'], '', '', false, false) : 0;
160
+				$csv_data ['includedseconds'] = isset ($csv_data ['includedseconds']) ? $csv_data ['includedseconds'] : 0;
161
+				$csv_data ['cost'] = ! empty ($csv_data ['cost']) && is_numeric($csv_data ['cost']) ? $this->common_model->add_calculate_currency($csv_data ['cost'], '', '', false, false) : 0;
162
+				$csv_data ['inc'] = isset ($csv_data ['inc']) ? $csv_data ['inc'] : 0;
163
+				$csv_data ['precedence'] = isset ($csv_data ['precedence']) ? $csv_data ['precedence'] : '';
164
+				$csv_data ['strip'] = isset ($csv_data ['strip']) ? $csv_data ['strip'] : '';
165
+				$str = $this->data_validate($csv_data);
166 166
 				if ($str != "") {
167 167
 					$invalid_array [$i] = $csv_data;
168 168
 					$invalid_array [$i] ['error'] = $str;
169 169
 				} else {
170 170
 					$csv_data ['trunk_id'] = $trunkID;
171
-					$csv_data ['pattern'] = "^" . $csv_data ['pattern'] . ".*";
172
-					$csv_data ['creation_date'] = gmdate ( "Y-m-d H:i:s" );
173
-					$csv_data ['last_modified_date'] = gmdate ( "Y-m-d H:i:s" );
171
+					$csv_data ['pattern'] = "^".$csv_data ['pattern'].".*";
172
+					$csv_data ['creation_date'] = gmdate("Y-m-d H:i:s");
173
+					$csv_data ['last_modified_date'] = gmdate("Y-m-d H:i:s");
174 174
 					$new_final_arr [$i] = $csv_data;
175
-					$row_count ++;
175
+					$row_count++;
176 176
 				}
177 177
 			}
178
-			$i ++;
178
+			$i++;
179 179
 		}
180
-		if (! empty ( $new_final_arr )) {
181
-			$this->rates_model->bulk_insert_termination_rate ( $new_final_arr, $row_count );
180
+		if ( ! empty ($new_final_arr)) {
181
+			$this->rates_model->bulk_insert_termination_rate($new_final_arr, $row_count);
182 182
 		}
183
-		unlink ( $full_path . $terminationrate_file_name );
184
-		$count = count ( $invalid_array );
183
+		unlink($full_path.$terminationrate_file_name);
184
+		$count = count($invalid_array);
185 185
 		if ($count > 0) {
186 186
 			$session_id = "-1";
187
-			$fp = fopen ( $full_path . $session_id . '.csv', 'w' );
188
-			foreach ( $new_final_arr_key as $key => $value ) {
189
-				$custom_array [0] [$key] = ucfirst ( $key );
187
+			$fp = fopen($full_path.$session_id.'.csv', 'w');
188
+			foreach ($new_final_arr_key as $key => $value) {
189
+				$custom_array [0] [$key] = ucfirst($key);
190 190
 			}
191 191
 			$custom_array [0] ['error'] = "Error";
192
-			$invalid_array = array_merge ( $custom_array, $invalid_array );
193
-			foreach ( $invalid_array as $err_data ) {
194
-				fputcsv ( $fp, $err_data );
192
+			$invalid_array = array_merge($custom_array, $invalid_array);
193
+			foreach ($invalid_array as $err_data) {
194
+				fputcsv($fp, $err_data);
195 195
 			}
196
-			fclose ( $fp );
197
-			$this->session->set_userdata ( 'import_termination_rate_csv_error', $session_id . ".csv" );
196
+			fclose($fp);
197
+			$this->session->set_userdata('import_termination_rate_csv_error', $session_id.".csv");
198 198
 			$data ["error"] = $invalid_array;
199 199
 			$data ['trunkid'] = $trunkID;
200
-			$data ['impoted_count'] = count ( $new_final_arr );
201
-			$data ['failure_count'] = count ( $invalid_array ) - 1;
202
-			$data ['page_title'] = gettext ( 'Termination Rates Import Error' );
203
-			$this->load->view ( 'view_import_error', $data );
200
+			$data ['impoted_count'] = count($new_final_arr);
201
+			$data ['failure_count'] = count($invalid_array) - 1;
202
+			$data ['page_title'] = gettext('Termination Rates Import Error');
203
+			$this->load->view('view_import_error', $data);
204 204
 		} else {
205
-			$this->session->set_flashdata ( 'astpp_errormsg', 'Total ' . count ( $new_final_arr ) . ' Termination rates imported successfully!' );
206
-			redirect ( base_url () . "rates/termination_rates_list/" );
205
+			$this->session->set_flashdata('astpp_errormsg', 'Total '.count($new_final_arr).' Termination rates imported successfully!');
206
+			redirect(base_url()."rates/termination_rates_list/");
207 207
 		}
208 208
 	}
209 209
 	function termination_rate_error_download() {
210
-		$this->load->helper ( 'download' );
211
-		$error_data = $this->session->userdata ( 'import_termination_rate_csv_error' );
212
-		$full_path = $this->config->item ( 'rates-file-path' );
213
-		$data = file_get_contents ( $full_path . $error_data );
214
-		force_download ( "Termination_rate_error.csv", $data );
210
+		$this->load->helper('download');
211
+		$error_data = $this->session->userdata('import_termination_rate_csv_error');
212
+		$full_path = $this->config->item('rates-file-path');
213
+		$data = file_get_contents($full_path.$error_data);
214
+		force_download("Termination_rate_error.csv", $data);
215 215
 	}
216 216
 	function origination_rate_import() {
217
-		$data ['page_title'] = gettext ( 'Import Origination Rates' );
218
-		$this->session->set_userdata ( 'import_origination_rate_csv', "" );
219
-		$error_data = $this->session->userdata ( 'import_origination_rate_csv_error' );
220
-		$full_path = $this->config->item ( 'rates-file-path' );
221
-		if (file_exists ( $full_path . $error_data ) && $error_data != "") {
222
-			unlink ( $full_path . $error_data );
223
-			$this->session->set_userdata ( 'import_origination_rate_csv_error', "" );
217
+		$data ['page_title'] = gettext('Import Origination Rates');
218
+		$this->session->set_userdata('import_origination_rate_csv', "");
219
+		$error_data = $this->session->userdata('import_origination_rate_csv_error');
220
+		$full_path = $this->config->item('rates-file-path');
221
+		if (file_exists($full_path.$error_data) && $error_data != "") {
222
+			unlink($full_path.$error_data);
223
+			$this->session->set_userdata('import_origination_rate_csv_error', "");
224 224
 		}
225
-		$this->load->view ( 'view_import_origination_rate', $data );
225
+		$this->load->view('view_import_origination_rate', $data);
226 226
 	}
227 227
 	function origination_rate_preview_file() {
228 228
 		$invalid_flag = false;
229
-		$data = array ();
230
-		$data ['page_title'] = gettext ( 'Import Origination Rates' );
231
-		$check_header = $this->input->post ( 'check_header', true );
232
-		if (empty ( $_FILES ) || ! isset ( $_FILES )) {
233
-			redirect ( base_url () . "rates/origination_rate_list/" );
229
+		$data = array();
230
+		$data ['page_title'] = gettext('Import Origination Rates');
231
+		$check_header = $this->input->post('check_header', true);
232
+		if (empty ($_FILES) || ! isset ($_FILES)) {
233
+			redirect(base_url()."rates/origination_rate_list/");
234 234
 		}
235
-		$get_extension = strpos ( $_FILES ['origination_rate_import'] ['name'], '.' );
236
-		$new_final_arr_key = $this->config->item ( 'Origination-rates-field' );
237
-		if (! $get_extension) {
235
+		$get_extension = strpos($_FILES ['origination_rate_import'] ['name'], '.');
236
+		$new_final_arr_key = $this->config->item('Origination-rates-field');
237
+		if ( ! $get_extension) {
238 238
 			$data ['error'] = "Please Upload File Atleast";
239 239
 		}
240
-		if (isset ( $_FILES ['origination_rate_import'] ['name'] ) && $_FILES ['origination_rate_import'] ['name'] != "" && isset ( $_POST ['pricelist_id'] ) && $_POST ['pricelist_id'] != '') {
241
-			list ( $txt, $ext ) = explode ( ".", $_FILES ['origination_rate_import'] ['name'] );
240
+		if (isset ($_FILES ['origination_rate_import'] ['name']) && $_FILES ['origination_rate_import'] ['name'] != "" && isset ($_POST ['pricelist_id']) && $_POST ['pricelist_id'] != '') {
241
+			list ($txt, $ext) = explode(".", $_FILES ['origination_rate_import'] ['name']);
242 242
 			
243 243
 			if ($ext == "csv" && $_FILES ['origination_rate_import'] ['size'] > 0) {
244 244
 				$error = $_FILES ['origination_rate_import'] ['error'];
245 245
 				if ($error == 0) {
246 246
 					$uploadedFile = $_FILES ["origination_rate_import"] ["tmp_name"];
247
-					$csv_data = $this->csvreader->parse_file ( $uploadedFile, $new_final_arr_key, $check_header );
248
-					if (! empty ( $csv_data )) {
249
-						$full_path = $this->config->item ( 'rates-file-path' );
250
-						$actual_file_name = "ASTPP-ORIGIN-RATES-" . date ( "Y-m-d H:i:s" ) . "." . $ext;
251
-						if (move_uploaded_file ( $uploadedFile, $full_path . $actual_file_name )) {
247
+					$csv_data = $this->csvreader->parse_file($uploadedFile, $new_final_arr_key, $check_header);
248
+					if ( ! empty ($csv_data)) {
249
+						$full_path = $this->config->item('rates-file-path');
250
+						$actual_file_name = "ASTPP-ORIGIN-RATES-".date("Y-m-d H:i:s").".".$ext;
251
+						if (move_uploaded_file($uploadedFile, $full_path.$actual_file_name)) {
252 252
 							$flag = false;
253
-							$data ['trunkid'] = isset ( $_POST ['trunk_id'] ) && $_POST ['trunk_id'] > 0 ? $_POST ['trunk_id'] : 0;
253
+							$data ['trunkid'] = isset ($_POST ['trunk_id']) && $_POST ['trunk_id'] > 0 ? $_POST ['trunk_id'] : 0;
254 254
 							$data ['csv_tmp_data'] = $csv_data;
255 255
 							$data ['pricelistid'] = $_POST ['pricelist_id'];
256
-							$data ['page_title'] = gettext ( "Origination Rates Preview" );
256
+							$data ['page_title'] = gettext("Origination Rates Preview");
257 257
 							$data ['check_header'] = $check_header;
258
-							$this->session->set_userdata ( 'import_origination_rate_csv', $actual_file_name );
258
+							$this->session->set_userdata('import_origination_rate_csv', $actual_file_name);
259 259
 						} else {
260 260
 							$data ['error'] = "File Uploading Fail Please Try Again";
261 261
 						}
@@ -271,86 +271,86 @@  discard block
 block discarded – undo
271 271
 		}
272 272
 		if ($invalid_flag) {
273 273
 			$str = '';
274
-			if (! isset ( $_POST ['pricelist_id'] ) || empty ( $_POST ['pricelist_id'] )) {
274
+			if ( ! isset ($_POST ['pricelist_id']) || empty ($_POST ['pricelist_id'])) {
275 275
 				$str .= '<br/>Please Create Rate Group.';
276 276
 			}
277
-			if (empty ( $_FILES ['origination_rate_import'] ['name'] )) {
277
+			if (empty ($_FILES ['origination_rate_import'] ['name'])) {
278 278
 				$str .= '<br/>Please Select File.';
279 279
 			}
280 280
 			$data ['error'] = $str;
281 281
 		}
282
-		$this->load->view ( 'view_import_origination_rate', $data );
282
+		$this->load->view('view_import_origination_rate', $data);
283 283
 	}
284 284
 	function origination_rate_import_file($pricelistID, $trunkid, $check_header = false) {
285
-		$new_final_arr = array ();
286
-		$invalid_array = array ();
287
-		$new_final_arr_key = $this->config->item ( 'Origination-rates-field' );
288
-		$screen_path = $this->config->item ( 'screen_path' );
285
+		$new_final_arr = array();
286
+		$invalid_array = array();
287
+		$new_final_arr_key = $this->config->item('Origination-rates-field');
288
+		$screen_path = $this->config->item('screen_path');
289 289
 		$reseller_id = 0;
290
-		if ($this->session->userdata ( 'logintype' ) == 1 || $this->session->userdata ( 'logintype' ) == 5) {
290
+		if ($this->session->userdata('logintype') == 1 || $this->session->userdata('logintype') == 5) {
291 291
 			$reseller_id = $this->session->userdata ["accountinfo"] ['id'];
292 292
 		}
293 293
 		
294
-		$full_path = $this->config->item ( 'rates-file-path' );
295
-		$originationrate_file_name = $this->session->userdata ( 'import_origination_rate_csv' );
296
-		$csv_tmp_data = $this->csvreader->parse_file ( $full_path . $originationrate_file_name, $new_final_arr_key, $check_header );
294
+		$full_path = $this->config->item('rates-file-path');
295
+		$originationrate_file_name = $this->session->userdata('import_origination_rate_csv');
296
+		$csv_tmp_data = $this->csvreader->parse_file($full_path.$originationrate_file_name, $new_final_arr_key, $check_header);
297 297
 		// echo "<pre>";print_r($csv_tmp_data);exit;
298 298
 		$i = 0;
299 299
 		$row_count = 0;
300
-		foreach ( $csv_tmp_data as $key => $csv_data ) {
301
-			if (isset ( $csv_data ['pattern'] ) && $csv_data ['pattern'] != '' && $i != 0) {
300
+		foreach ($csv_tmp_data as $key => $csv_data) {
301
+			if (isset ($csv_data ['pattern']) && $csv_data ['pattern'] != '' && $i != 0) {
302 302
 				$str = null;
303
-				$csv_data ['comment'] = isset ( $csv_data ['comment'] ) ? $csv_data ['comment'] : '';
304
-				$csv_data ['connectcost'] = isset ( $csv_data ['connectcost'] ) ? $this->common_model->add_calculate_currency ( $csv_data ['connectcost'], '', '', false, false ) : 0;
305
-				$csv_data ['includedseconds'] = isset ( $csv_data ['includedseconds'] ) ? $csv_data ['includedseconds'] : 0;
306
-				$csv_data ['cost'] = ! empty ( $csv_data ['cost'] ) && is_numeric ( $csv_data ['cost'] ) ? $this->common_model->add_calculate_currency ( $csv_data ['cost'], '', '', false, false ) : 0;
307
-				$csv_data ['inc'] = isset ( $csv_data ['inc'] ) ? $csv_data ['inc'] : 0;
308
-				$csv_data ['precedence'] = isset ( $csv_data ['precedence'] ) ? $csv_data ['precedence'] : '';
309
-				$csv_data ['last_modified_date'] = gmdate ( "Y-m-d H:i:s" );
310
-				$str = $this->data_validate ( $csv_data );
303
+				$csv_data ['comment'] = isset ($csv_data ['comment']) ? $csv_data ['comment'] : '';
304
+				$csv_data ['connectcost'] = isset ($csv_data ['connectcost']) ? $this->common_model->add_calculate_currency($csv_data ['connectcost'], '', '', false, false) : 0;
305
+				$csv_data ['includedseconds'] = isset ($csv_data ['includedseconds']) ? $csv_data ['includedseconds'] : 0;
306
+				$csv_data ['cost'] = ! empty ($csv_data ['cost']) && is_numeric($csv_data ['cost']) ? $this->common_model->add_calculate_currency($csv_data ['cost'], '', '', false, false) : 0;
307
+				$csv_data ['inc'] = isset ($csv_data ['inc']) ? $csv_data ['inc'] : 0;
308
+				$csv_data ['precedence'] = isset ($csv_data ['precedence']) ? $csv_data ['precedence'] : '';
309
+				$csv_data ['last_modified_date'] = gmdate("Y-m-d H:i:s");
310
+				$str = $this->data_validate($csv_data);
311 311
 				if ($str != "") {
312 312
 					$invalid_array [$i] = $csv_data;
313 313
 					$invalid_array [$i] ['error'] = $str;
314 314
 				} else {
315 315
 					$csv_data ['pricelist_id'] = $pricelistID;
316 316
 					$csv_data ['trunk_id'] = $trunkid;
317
-					$csv_data ['pattern'] = "^" . $csv_data ['pattern'] . ".*";
317
+					$csv_data ['pattern'] = "^".$csv_data ['pattern'].".*";
318 318
 					$csv_data ['reseller_id'] = $reseller_id;
319
-					$csv_data ['creation_date'] = gmdate ( "Y-m-d H:i:s" );
320
-					$csv_data ['last_modified_date'] = gmdate ( "Y-m-d H:i:s" );
319
+					$csv_data ['creation_date'] = gmdate("Y-m-d H:i:s");
320
+					$csv_data ['last_modified_date'] = gmdate("Y-m-d H:i:s");
321 321
 					$new_final_arr [$i] = $csv_data;
322
-					$row_count ++;
322
+					$row_count++;
323 323
 				}
324 324
 			}
325
-			$i ++;
325
+			$i++;
326 326
 		}
327
-		if (! empty ( $new_final_arr )) {
328
-			$this->rates_model->bulk_insert_origination_rate ( $new_final_arr, $row_count );
327
+		if ( ! empty ($new_final_arr)) {
328
+			$this->rates_model->bulk_insert_origination_rate($new_final_arr, $row_count);
329 329
 		}
330
-		unlink ( $full_path . $originationrate_file_name );
331
-		$count = count ( $invalid_array );
330
+		unlink($full_path.$originationrate_file_name);
331
+		$count = count($invalid_array);
332 332
 		if ($count > 0) {
333 333
 			$session_id = "-1";
334
-			$fp = fopen ( $full_path . $session_id . '.csv', 'w' );
335
-			foreach ( $new_final_arr_key as $key => $value ) {
336
-				$custom_array [0] [$key] = ucfirst ( $key );
334
+			$fp = fopen($full_path.$session_id.'.csv', 'w');
335
+			foreach ($new_final_arr_key as $key => $value) {
336
+				$custom_array [0] [$key] = ucfirst($key);
337 337
 			}
338 338
 			$custom_array [0] ['error'] = "Error";
339
-			$invalid_array = array_merge ( $custom_array, $invalid_array );
340
-			foreach ( $invalid_array as $err_data ) {
341
-				fputcsv ( $fp, $err_data );
339
+			$invalid_array = array_merge($custom_array, $invalid_array);
340
+			foreach ($invalid_array as $err_data) {
341
+				fputcsv($fp, $err_data);
342 342
 			}
343
-			fclose ( $fp );
344
-			$this->session->set_userdata ( 'import_origination_rate_csv_error', $session_id . ".csv" );
343
+			fclose($fp);
344
+			$this->session->set_userdata('import_origination_rate_csv_error', $session_id.".csv");
345 345
 			$data ["error"] = $invalid_array;
346 346
 			$data ['pricelistid'] = $pricelistID;
347
-			$data ['impoted_count'] = count ( $new_final_arr );
348
-			$data ['failure_count'] = count ( $invalid_array ) - 1;
349
-			$data ['page_title'] = gettext ( 'Origination Rates Import Error' );
350
-			$this->load->view ( 'view_import_error', $data );
347
+			$data ['impoted_count'] = count($new_final_arr);
348
+			$data ['failure_count'] = count($invalid_array) - 1;
349
+			$data ['page_title'] = gettext('Origination Rates Import Error');
350
+			$this->load->view('view_import_error', $data);
351 351
 		} else {
352
-			$this->session->set_flashdata ( 'astpp_errormsg', 'Total ' . count ( $new_final_arr ) . ' Origination rates imported successfully!' );
353
-			redirect ( base_url () . "rates/origination_rates_list/" );
352
+			$this->session->set_flashdata('astpp_errormsg', 'Total '.count($new_final_arr).' Origination rates imported successfully!');
353
+			redirect(base_url()."rates/origination_rates_list/");
354 354
 		}
355 355
 	}
356 356
 	function data_validate($csvdata) {
@@ -359,144 +359,144 @@  discard block
 block discarded – undo
359 359
 		$alpha_numeric_regex = "/^[a-z0-9 ,.'-]+$/i";
360 360
 		$email_regex = "/^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$/";
361 361
 		$str .= $csvdata ['pattern'] != '' ? null : 'Code,';
362
-		$str = rtrim ( $str, ',' );
363
-		if (! $str) {
364
-			$str .= is_numeric ( $csvdata ['pattern'] ) ? null : 'Code,';
362
+		$str = rtrim($str, ',');
363
+		if ( ! $str) {
364
+			$str .= is_numeric($csvdata ['pattern']) ? null : 'Code,';
365 365
 			
366
-			$str .= ! empty ( $csvdata ['connectcost'] ) && is_numeric ( $csvdata ['connectcost'] ) ? null : (empty ( $csvdata ['connectcost'] ) ? null : 'Connect Cost,');
367
-			$str .= ! empty ( $csvdata ['includedseconds'] ) && is_numeric ( $csvdata ['includedseconds'] ) ? null : (empty ( $csvdata ['includedseconds'] ) ? null : 'Included Seconds,');
366
+			$str .= ! empty ($csvdata ['connectcost']) && is_numeric($csvdata ['connectcost']) ? null : (empty ($csvdata ['connectcost']) ? null : 'Connect Cost,');
367
+			$str .= ! empty ($csvdata ['includedseconds']) && is_numeric($csvdata ['includedseconds']) ? null : (empty ($csvdata ['includedseconds']) ? null : 'Included Seconds,');
368 368
 			
369
-			$str .= ! empty ( $csvdata ['inc'] ) && is_numeric ( $csvdata ['inc'] ) ? null : (empty ( $csvdata ['inc'] ) ? null : 'Increment,');
370
-			$str .= ! empty ( $csvdata ['precedence'] ) && is_numeric ( $csvdata ['precedence'] ) ? null : (empty ( $csvdata ['precedence'] ) ? null : 'Precedence,');
371
-			$str .= (isset ( $csvdata ['strip'] ) && ! empty ( $csvdata ['strip'] )) ? (is_numeric ( $csvdata ['strip'] ) ? null : 'Strip,') : null;
369
+			$str .= ! empty ($csvdata ['inc']) && is_numeric($csvdata ['inc']) ? null : (empty ($csvdata ['inc']) ? null : 'Increment,');
370
+			$str .= ! empty ($csvdata ['precedence']) && is_numeric($csvdata ['precedence']) ? null : (empty ($csvdata ['precedence']) ? null : 'Precedence,');
371
+			$str .= (isset ($csvdata ['strip']) && ! empty ($csvdata ['strip'])) ? (is_numeric($csvdata ['strip']) ? null : 'Strip,') : null;
372 372
 			if ($str) {
373
-				$str = rtrim ( $str, ',' );
374
-				$error_field = explode ( ',', $str );
375
-				$count = count ( $error_field );
373
+				$str = rtrim($str, ',');
374
+				$error_field = explode(',', $str);
375
+				$count = count($error_field);
376 376
 				$str .= $count > 1 ? ' are not valid' : ' is not Valid';
377 377
 				return $str;
378 378
 			} else {
379 379
 				return false;
380 380
 			}
381 381
 		} else {
382
-			$str = rtrim ( $str, ',' );
383
-			$error_field = explode ( ',', $str );
384
-			$count = count ( $error_field );
382
+			$str = rtrim($str, ',');
383
+			$error_field = explode(',', $str);
384
+			$count = count($error_field);
385 385
 			$str .= $count > 1 ? ' are required' : ' is Required';
386 386
 			return $str;
387 387
 		}
388 388
 	}
389 389
 	function origination_rate_error_download() {
390
-		$this->load->helper ( 'download' );
391
-		$error_data = $this->session->userdata ( 'import_origination_rate_csv_error' );
392
-		$full_path = $this->config->item ( 'rates-file-path' );
393
-		$data = file_get_contents ( $full_path . $error_data );
394
-		force_download ( "Origination_rate_error.csv", $data );
390
+		$this->load->helper('download');
391
+		$error_data = $this->session->userdata('import_origination_rate_csv_error');
392
+		$full_path = $this->config->item('rates-file-path');
393
+		$data = file_get_contents($full_path.$error_data);
394
+		force_download("Origination_rate_error.csv", $data);
395 395
 	}
396 396
 	function origination_rate_add($type = "") {
397
-		$data ['username'] = $this->session->userdata ( 'user_name' );
397
+		$data ['username'] = $this->session->userdata('user_name');
398 398
 		$data ['flag'] = 'create';
399
-		$data ['page_title'] = gettext ( 'Create Origination Rate' );
400
-		$data ['form'] = $this->form->build_form ( $this->rates_form->get_origination_rate_form_fields (), '' );
399
+		$data ['page_title'] = gettext('Create Origination Rate');
400
+		$data ['form'] = $this->form->build_form($this->rates_form->get_origination_rate_form_fields(), '');
401 401
 		
402
-		$this->load->view ( 'view_origination_rate_add_edit', $data );
402
+		$this->load->view('view_origination_rate_add_edit', $data);
403 403
 	}
404 404
 	function origination_rate_edit($edit_id = '') {
405
-		$data ['page_title'] = gettext ( 'Edit Origination Rate' );
406
-		if ($this->session->userdata ( 'logintype' ) == 1 || $this->session->userdata ( 'logintype' ) == 5) {
407
-			$account_data = $this->session->userdata ( "accountinfo" );
405
+		$data ['page_title'] = gettext('Edit Origination Rate');
406
+		if ($this->session->userdata('logintype') == 1 || $this->session->userdata('logintype') == 5) {
407
+			$account_data = $this->session->userdata("accountinfo");
408 408
 			$reseller = $account_data ['id'];
409
-			$where = array (
409
+			$where = array(
410 410
 					'id' => $edit_id,
411 411
 					"reseller_id" => $reseller 
412 412
 			);
413 413
 		} else {
414
-			$where = array (
414
+			$where = array(
415 415
 					'id' => $edit_id 
416 416
 			);
417 417
 		}
418
-		$account = $this->db_model->getSelect ( "*", "routes", $where );
418
+		$account = $this->db_model->getSelect("*", "routes", $where);
419 419
 		if ($account->num_rows > 0) {
420
-			foreach ( $account->result_array () as $key => $value ) {
420
+			foreach ($account->result_array() as $key => $value) {
421 421
 				$edit_data = $value;
422 422
 			}
423
-			$edit_data ['connectcost'] = $this->common_model->to_calculate_currency ( $edit_data ['connectcost'], '', '', true, false );
424
-			$edit_data ['cost'] = $this->common_model->to_calculate_currency ( $edit_data ['cost'], '', '', true, false );
425
-			$edit_data ['pattern'] = filter_var ( $edit_data ['pattern'], FILTER_SANITIZE_NUMBER_INT );
423
+			$edit_data ['connectcost'] = $this->common_model->to_calculate_currency($edit_data ['connectcost'], '', '', true, false);
424
+			$edit_data ['cost'] = $this->common_model->to_calculate_currency($edit_data ['cost'], '', '', true, false);
425
+			$edit_data ['pattern'] = filter_var($edit_data ['pattern'], FILTER_SANITIZE_NUMBER_INT);
426 426
 			
427
-			$data ['form'] = $this->form->build_form ( $this->rates_form->get_origination_rate_form_fields (), $edit_data );
428
-			$this->load->view ( 'view_origination_rate_add_edit', $data );
427
+			$data ['form'] = $this->form->build_form($this->rates_form->get_origination_rate_form_fields(), $edit_data);
428
+			$this->load->view('view_origination_rate_add_edit', $data);
429 429
 		} else {
430
-			redirect ( base_url () . 'rates/origination_rate_list/' );
430
+			redirect(base_url().'rates/origination_rate_list/');
431 431
 		}
432 432
 	}
433 433
 	function origination_rate_save() {
434
-		$add_array = $this->input->post ();
435
-		$data ['form'] = $this->form->build_form ( $this->rates_form->get_origination_rate_form_fields (), $add_array );
434
+		$add_array = $this->input->post();
435
+		$data ['form'] = $this->form->build_form($this->rates_form->get_origination_rate_form_fields(), $add_array);
436 436
 		if ($add_array ['id'] != '') {
437
-			$data ['page_title'] = gettext ( 'Edit Origination Rate' );
438
-			if ($this->form_validation->run () == FALSE) {
439
-				$data ['validation_errors'] = validation_errors ();
437
+			$data ['page_title'] = gettext('Edit Origination Rate');
438
+			if ($this->form_validation->run() == FALSE) {
439
+				$data ['validation_errors'] = validation_errors();
440 440
 				echo $data ['validation_errors'];
441 441
 				exit ();
442 442
 			} else {
443
-				$add_array ['connectcost'] = $this->common_model->add_calculate_currency ( $add_array ['connectcost'], '', '', false, false );
444
-				$add_array ['cost'] = $this->common_model->add_calculate_currency ( $add_array ['cost'], '', '', false, false );
445
-				$this->rates_model->edit_origination_rate ( $add_array, $add_array ['id'] );
446
-				echo json_encode ( array (
443
+				$add_array ['connectcost'] = $this->common_model->add_calculate_currency($add_array ['connectcost'], '', '', false, false);
444
+				$add_array ['cost'] = $this->common_model->add_calculate_currency($add_array ['cost'], '', '', false, false);
445
+				$this->rates_model->edit_origination_rate($add_array, $add_array ['id']);
446
+				echo json_encode(array(
447 447
 						"SUCCESS" => "Origination rate updated successfully!" 
448
-				) );
448
+				));
449 449
 				exit ();
450 450
 			}
451 451
 		} else {
452
-			$data ['page_title'] = gettext ( 'Add Origination Rate' );
453
-			if ($this->form_validation->run () == FALSE) {
454
-				$data ['validation_errors'] = validation_errors ();
452
+			$data ['page_title'] = gettext('Add Origination Rate');
453
+			if ($this->form_validation->run() == FALSE) {
454
+				$data ['validation_errors'] = validation_errors();
455 455
 				echo $data ['validation_errors'];
456 456
 				exit ();
457 457
 			} else {
458 458
 				
459
-				$add_array ['connectcost'] = $this->common_model->add_calculate_currency ( $add_array ['connectcost'], '', '', false, false );
460
-				$add_array ['cost'] = $this->common_model->add_calculate_currency ( $add_array ['cost'], '', '', false, false );
461
-				$this->rates_model->add_origination_rate ( $add_array );
462
-				echo json_encode ( array (
459
+				$add_array ['connectcost'] = $this->common_model->add_calculate_currency($add_array ['connectcost'], '', '', false, false);
460
+				$add_array ['cost'] = $this->common_model->add_calculate_currency($add_array ['cost'], '', '', false, false);
461
+				$this->rates_model->add_origination_rate($add_array);
462
+				echo json_encode(array(
463 463
 						"SUCCESS" => "Origination rate added successfully!" 
464
-				) );
464
+				));
465 465
 				exit ();
466 466
 			}
467 467
 		}
468 468
 	}
469 469
 	function origination_rates_list_search() {
470
-		$ajax_search = $this->input->post ( 'ajax_search', 0 );
470
+		$ajax_search = $this->input->post('ajax_search', 0);
471 471
 		
472
-		if ($this->input->post ( 'advance_search', TRUE ) == 1) {
473
-			$this->session->set_userdata ( 'advance_search', $this->input->post ( 'advance_search' ) );
474
-			$action = $this->input->post ();
475
-			unset ( $action ['action'] );
476
-			unset ( $action ['advance_search'] );
477
-			$this->session->set_userdata ( 'origination_rate_list_search', $action );
472
+		if ($this->input->post('advance_search', TRUE) == 1) {
473
+			$this->session->set_userdata('advance_search', $this->input->post('advance_search'));
474
+			$action = $this->input->post();
475
+			unset ($action ['action']);
476
+			unset ($action ['advance_search']);
477
+			$this->session->set_userdata('origination_rate_list_search', $action);
478 478
 		}
479 479
 		if (@$ajax_search != 1) {
480
-			redirect ( base_url () . 'rates/origination_rates_list/' );
480
+			redirect(base_url().'rates/origination_rates_list/');
481 481
 		}
482 482
 	}
483 483
 	function origination_rates_list_clearsearchfilter() {
484
-		$this->session->set_userdata ( 'advance_search', 0 );
485
-		$this->session->set_userdata ( 'account_search', "" );
484
+		$this->session->set_userdata('advance_search', 0);
485
+		$this->session->set_userdata('account_search', "");
486 486
 	}
487 487
 	function termination_rate_delete($id) {
488
-		$this->rates_model->remove_termination_rate ( $id );
489
-		$this->session->set_flashdata ( 'astpp_notification', 'Termination removed successfully!' );
490
-		redirect ( base_url () . '/rates/termination_rates_list/' );
488
+		$this->rates_model->remove_termination_rate($id);
489
+		$this->session->set_flashdata('astpp_notification', 'Termination removed successfully!');
490
+		redirect(base_url().'/rates/termination_rates_list/');
491 491
 	}
492 492
 	function origination_rate_delete($id) {
493
-		$this->rates_model->remove_origination_rate ( $id );
494
-		$this->session->set_flashdata ( 'astpp_notification', 'Origination rate removed successfully!' );
495
-		redirect ( base_url () . 'rates/origination_rates_list/' );
493
+		$this->rates_model->remove_origination_rate($id);
494
+		$this->session->set_flashdata('astpp_notification', 'Origination rate removed successfully!');
495
+		redirect(base_url().'rates/origination_rates_list/');
496 496
 	}
497 497
 	function origination_rates_list() {
498
-		$data ['username'] = $this->session->userdata ( 'user_name' );
499
-		$data ['page_title'] = gettext ( 'Origination Rates' );
498
+		$data ['username'] = $this->session->userdata('user_name');
499
+		$data ['page_title'] = gettext('Origination Rates');
500 500
 		$data ['search_flag'] = true;
501 501
 		$data ['batch_update_flag'] = true;
502 502
 		/**
@@ -509,12 +509,12 @@  discard block
 block discarded – undo
509 509
 		/**
510 510
 		 * ************
511 511
 		 */
512
-		$this->session->set_userdata ( 'advance_search', 0 );
513
-		$data ['grid_fields'] = $this->rates_form->build_origination_rate_list_for_admin ();
514
-		$data ["grid_buttons"] = $this->rates_form->build_grid_buttons_origination_rate ();
515
-		$data ['form_search'] = $this->form->build_serach_form ( $this->rates_form->get_origination_rate_search_form () );
516
-		$data ['form_batch_update'] = $this->form->build_batchupdate_form ( $this->rates_form->origination_rate_batch_update_form () );
517
-		$this->load->view ( 'view_origination_rate_list', $data );
512
+		$this->session->set_userdata('advance_search', 0);
513
+		$data ['grid_fields'] = $this->rates_form->build_origination_rate_list_for_admin();
514
+		$data ["grid_buttons"] = $this->rates_form->build_grid_buttons_origination_rate();
515
+		$data ['form_search'] = $this->form->build_serach_form($this->rates_form->get_origination_rate_search_form());
516
+		$data ['form_batch_update'] = $this->form->build_batchupdate_form($this->rates_form->origination_rate_batch_update_form());
517
+		$this->load->view('view_origination_rate_list', $data);
518 518
 	}
519 519
 	
520 520
 	/**
@@ -524,249 +524,249 @@  discard block
 block discarded – undo
524 524
 	 * ********
525 525
 	 */
526 526
 	function origination_rates_list_json() {
527
-		$json_data = array ();
528
-		$count_all = $this->rates_model->get_origination_rate_list ( false );
529
-		$paging_data = $this->form->load_grid_config ( $count_all, $_GET ['rp'], $_GET ['page'] );
527
+		$json_data = array();
528
+		$count_all = $this->rates_model->get_origination_rate_list(false);
529
+		$paging_data = $this->form->load_grid_config($count_all, $_GET ['rp'], $_GET ['page']);
530 530
 		$json_data = $paging_data ["json_paging"];
531 531
 		// echo "<pre>"; print_r($json_data);
532
-		$query = $this->rates_model->get_origination_rate_list ( true, $paging_data ["paging"] ["start"], $paging_data ["paging"] ["page_no"] );
533
-		$grid_fields = json_decode ( $this->rates_form->build_origination_rate_list_for_admin () );
534
-		$json_data ['rows'] = $this->form->build_grid ( $query, $grid_fields );
532
+		$query = $this->rates_model->get_origination_rate_list(true, $paging_data ["paging"] ["start"], $paging_data ["paging"] ["page_no"]);
533
+		$grid_fields = json_decode($this->rates_form->build_origination_rate_list_for_admin());
534
+		$json_data ['rows'] = $this->form->build_grid($query, $grid_fields);
535 535
 		
536
-		echo json_encode ( $json_data );
536
+		echo json_encode($json_data);
537 537
 	}
538 538
 	function origination_rates_list_delete($flag = '') {
539
-		$json_data = array ();
540
-		$this->session->set_userdata ( 'advance_batch_data_delete', 1 );
541
-		$count_all = $this->rates_model->get_origination_rate_list ( false );
539
+		$json_data = array();
540
+		$this->session->set_userdata('advance_batch_data_delete', 1);
541
+		$count_all = $this->rates_model->get_origination_rate_list(false);
542 542
 		echo $count_all;
543 543
 	}
544 544
 	/**
545 545
 	 * ****************
546 546
 	 */
547 547
 	function termination_rate_add($type = "") {
548
-		$data ['username'] = $this->session->userdata ( 'user_name' );
548
+		$data ['username'] = $this->session->userdata('user_name');
549 549
 		$data ['flag'] = 'create';
550
-		$data ['page_title'] = gettext ( 'Create Termination Rate' );
551
-		$data ['form'] = $this->form->build_form ( $this->rates_form->get_termination_rate_form_fields (), '' );
552
-		$this->load->view ( 'view_termination_rate_add_edit', $data );
550
+		$data ['page_title'] = gettext('Create Termination Rate');
551
+		$data ['form'] = $this->form->build_form($this->rates_form->get_termination_rate_form_fields(), '');
552
+		$this->load->view('view_termination_rate_add_edit', $data);
553 553
 	}
554 554
 	function termination_rate_edit($edit_id = '') {
555
-		$data ['page_title'] = gettext ( 'Edit Termination Rate' );
556
-		$where = array (
555
+		$data ['page_title'] = gettext('Edit Termination Rate');
556
+		$where = array(
557 557
 				'id' => $edit_id 
558 558
 		);
559
-		$account = $this->db_model->getSelect ( "*", "outbound_routes", $where );
560
-		foreach ( $account->result_array () as $key => $value ) {
559
+		$account = $this->db_model->getSelect("*", "outbound_routes", $where);
560
+		foreach ($account->result_array() as $key => $value) {
561 561
 			$edit_data = $value;
562 562
 		}
563
-		$edit_data ['connectcost'] = $this->common_model->to_calculate_currency ( $edit_data ['connectcost'], '', '', false, false );
564
-		$edit_data ['cost'] = $this->common_model->to_calculate_currency ( $edit_data ['cost'], '', '', false, false );
563
+		$edit_data ['connectcost'] = $this->common_model->to_calculate_currency($edit_data ['connectcost'], '', '', false, false);
564
+		$edit_data ['cost'] = $this->common_model->to_calculate_currency($edit_data ['cost'], '', '', false, false);
565 565
 		
566
-		$edit_data ['pattern'] = filter_var ( $edit_data ['pattern'], FILTER_SANITIZE_NUMBER_INT );
567
-		$data ['form'] = $this->form->build_form ( $this->rates_form->get_termination_rate_form_fields (), $edit_data );
568
-		$this->load->view ( 'view_termination_rate_add_edit', $data );
566
+		$edit_data ['pattern'] = filter_var($edit_data ['pattern'], FILTER_SANITIZE_NUMBER_INT);
567
+		$data ['form'] = $this->form->build_form($this->rates_form->get_termination_rate_form_fields(), $edit_data);
568
+		$this->load->view('view_termination_rate_add_edit', $data);
569 569
 	}
570 570
 	function termination_rate_save() {
571
-		$add_array = $this->input->post ();
572
-		$data ['form'] = $this->form->build_form ( $this->rates_form->get_termination_rate_form_fields (), $add_array );
571
+		$add_array = $this->input->post();
572
+		$data ['form'] = $this->form->build_form($this->rates_form->get_termination_rate_form_fields(), $add_array);
573 573
 		if ($add_array ['id'] != '') {
574
-			$data ['page_title'] = gettext ( 'Edit Termination Rate' );
575
-			if ($this->form_validation->run () == FALSE) {
576
-				$data ['validation_errors'] = validation_errors ();
574
+			$data ['page_title'] = gettext('Edit Termination Rate');
575
+			if ($this->form_validation->run() == FALSE) {
576
+				$data ['validation_errors'] = validation_errors();
577 577
 				echo $data ['validation_errors'];
578 578
 				exit ();
579 579
 			} else {
580
-				$add_array ['connectcost'] = $this->common_model->add_calculate_currency ( $add_array ['connectcost'], '', '', false, false );
581
-				$add_array ['cost'] = $this->common_model->add_calculate_currency ( $add_array ['cost'], '', '', false, false );
582
-				$this->rates_model->edit_termination_rate ( $add_array, $add_array ['id'] );
583
-				echo json_encode ( array (
580
+				$add_array ['connectcost'] = $this->common_model->add_calculate_currency($add_array ['connectcost'], '', '', false, false);
581
+				$add_array ['cost'] = $this->common_model->add_calculate_currency($add_array ['cost'], '', '', false, false);
582
+				$this->rates_model->edit_termination_rate($add_array, $add_array ['id']);
583
+				echo json_encode(array(
584 584
 						"SUCCESS" => "Termination updated successfully!" 
585
-				) );
585
+				));
586 586
 				exit ();
587 587
 			}
588 588
 		} else {
589
-			$data ['page_title'] = gettext ( 'Add Termination Rate' );
590
-			if ($this->form_validation->run () == FALSE) {
591
-				$data ['validation_errors'] = validation_errors ();
589
+			$data ['page_title'] = gettext('Add Termination Rate');
590
+			if ($this->form_validation->run() == FALSE) {
591
+				$data ['validation_errors'] = validation_errors();
592 592
 				echo $data ['validation_errors'];
593 593
 				exit ();
594 594
 			} else {
595 595
 				
596
-				$add_array ['connectcost'] = $this->common_model->add_calculate_currency ( $add_array ['connectcost'], '', '', false, false );
597
-				$add_array ['cost'] = $this->common_model->add_calculate_currency ( $add_array ['cost'], '', '', false, false );
598
-				$this->rates_model->add_termination_rate ( $add_array );
599
-				echo json_encode ( array (
596
+				$add_array ['connectcost'] = $this->common_model->add_calculate_currency($add_array ['connectcost'], '', '', false, false);
597
+				$add_array ['cost'] = $this->common_model->add_calculate_currency($add_array ['cost'], '', '', false, false);
598
+				$this->rates_model->add_termination_rate($add_array);
599
+				echo json_encode(array(
600 600
 						"SUCCESS" => "Termination added successfully!" 
601
-				) );
601
+				));
602 602
 				exit ();
603 603
 			}
604 604
 		}
605
-		$this->load->view ( 'view_termination_rate_add_edit', $data );
605
+		$this->load->view('view_termination_rate_add_edit', $data);
606 606
 	}
607 607
 	function termination_rates_list_search() {
608
-		$ajax_search = $this->input->post ( 'ajax_search', 0 );
608
+		$ajax_search = $this->input->post('ajax_search', 0);
609 609
 		
610
-		if ($this->input->post ( 'advance_search', TRUE ) == 1) {
611
-			$this->session->set_userdata ( 'advance_search', $this->input->post ( 'advance_search' ) );
612
-			$action = $this->input->post ();
613
-			unset ( $action ['action'] );
614
-			unset ( $action ['advance_search'] );
615
-			$this->session->set_userdata ( 'termination_rates_list_search', $action );
610
+		if ($this->input->post('advance_search', TRUE) == 1) {
611
+			$this->session->set_userdata('advance_search', $this->input->post('advance_search'));
612
+			$action = $this->input->post();
613
+			unset ($action ['action']);
614
+			unset ($action ['advance_search']);
615
+			$this->session->set_userdata('termination_rates_list_search', $action);
616 616
 		}
617 617
 		if (@$ajax_search != 1) {
618
-			redirect ( base_url () . 'rates/termination_rates_list/' );
618
+			redirect(base_url().'rates/termination_rates_list/');
619 619
 		}
620 620
 	}
621 621
 	function termination_rates_list_clearsearchfilter() {
622
-		$this->session->set_userdata ( 'advance_search', 0 );
623
-		$this->session->set_userdata ( 'account_search', "" );
622
+		$this->session->set_userdata('advance_search', 0);
623
+		$this->session->set_userdata('account_search', "");
624 624
 	}
625 625
 	function customer_block_pattern_list($accountid, $accounttype) {
626
-		$json_data = array ();
627
-		$where = array (
626
+		$json_data = array();
627
+		$where = array(
628 628
 				'accountid' => $accountid 
629 629
 		);
630
-		$instant_search = $this->session->userdata ( 'left_panel_search_' . $accounttype . '_pattern' );
631
-		$like_str = ! empty ( $instant_search ) ? "(blocked_patterns like '%$instant_search%'  OR  destination like '%$instant_search%' )" : null;
632
-		if (! empty ( $like_str ))
633
-			$this->db->where ( $like_str );
634
-		$count_all = $this->db_model->countQuery ( "*", "block_patterns", $where );
635
-		$paging_data = $this->form->load_grid_config ( $count_all, $_GET ['rp'], $_GET ['page'] );
630
+		$instant_search = $this->session->userdata('left_panel_search_'.$accounttype.'_pattern');
631
+		$like_str = ! empty ($instant_search) ? "(blocked_patterns like '%$instant_search%'  OR  destination like '%$instant_search%' )" : null;
632
+		if ( ! empty ($like_str))
633
+			$this->db->where($like_str);
634
+		$count_all = $this->db_model->countQuery("*", "block_patterns", $where);
635
+		$paging_data = $this->form->load_grid_config($count_all, $_GET ['rp'], $_GET ['page']);
636 636
 		$json_data = $paging_data ["json_paging"];
637
-		if (! empty ( $like_str ))
638
-			$this->db->where ( $like_str );
639
-		$pattern_data = $this->db_model->getSelect ( "*", "block_patterns", $where, "id", "ASC", $paging_data ["paging"] ["page_no"], $paging_data ["paging"] ["start"] );
640
-		$grid_fields = json_decode ( $this->rates_form->build_pattern_list_for_customer ( $accountid, $accounttype ) );
641
-		$json_data ['rows'] = $this->form->build_grid ( $pattern_data, $grid_fields );
642
-		echo json_encode ( $json_data );
637
+		if ( ! empty ($like_str))
638
+			$this->db->where($like_str);
639
+		$pattern_data = $this->db_model->getSelect("*", "block_patterns", $where, "id", "ASC", $paging_data ["paging"] ["page_no"], $paging_data ["paging"] ["start"]);
640
+		$grid_fields = json_decode($this->rates_form->build_pattern_list_for_customer($accountid, $accounttype));
641
+		$json_data ['rows'] = $this->form->build_grid($pattern_data, $grid_fields);
642
+		echo json_encode($json_data);
643 643
 	}
644 644
 	function termination_rate_delete_multiple() {
645
-		$ids = $this->input->post ( "selected_ids", true );
645
+		$ids = $this->input->post("selected_ids", true);
646 646
 		$where = "id IN ($ids)";
647
-		$this->db->where ( $where );
648
-		echo $this->db->delete ( "outbound_routes" );
647
+		$this->db->where($where);
648
+		echo $this->db->delete("outbound_routes");
649 649
 	}
650 650
 	function origination_rate_delete_multiple() {
651
-		$ids = $this->input->post ( "selected_ids", true );
651
+		$ids = $this->input->post("selected_ids", true);
652 652
 		$where = "id IN ($ids)";
653
-		$this->db->where ( $where );
654
-		echo $this->db->delete ( "routes" );
653
+		$this->db->where($where);
654
+		echo $this->db->delete("routes");
655 655
 	}
656 656
 	function user_origination_rate_list_json() {
657
-		$json_data = array ();
658
-		$account_data = $this->session->userdata ( "accountinfo" );
659
-		$markup = $this->common->get_field_name ( 'markup', 'pricelists', array (
657
+		$json_data = array();
658
+		$account_data = $this->session->userdata("accountinfo");
659
+		$markup = $this->common->get_field_name('markup', 'pricelists', array(
660 660
 				'id' => $account_data ["pricelist_id"] 
661
-		) );
661
+		));
662 662
 		$markup = ($markup > 0) ? $markup : 1;
663 663
 		
664
-		$count_all = $this->rates_model->get_origination_rate_list_for_user ( false );
665
-		$paging_data = $this->form->load_grid_config ( $count_all, $_GET ['rp'], $_GET ['page'] );
664
+		$count_all = $this->rates_model->get_origination_rate_list_for_user(false);
665
+		$paging_data = $this->form->load_grid_config($count_all, $_GET ['rp'], $_GET ['page']);
666 666
 		$json_data = $paging_data ["json_paging"];
667 667
 		
668
-		$query = $this->rates_model->get_origination_rate_list_for_user ( true, $paging_data ["paging"] ["start"], $paging_data ["paging"] ["page_no"] );
669
-		$grid_fields = json_decode ( $this->rates_form->build_origination_rate_list_for_user () );
670
-		foreach ( $query->result_array () as $key => $value ) {
671
-			$json_data ['rows'] [] = array (
672
-					'cell' => array (
673
-							$this->common->get_only_numeric_val ( "", "", $value ["pattern"] ),
668
+		$query = $this->rates_model->get_origination_rate_list_for_user(true, $paging_data ["paging"] ["start"], $paging_data ["paging"] ["page_no"]);
669
+		$grid_fields = json_decode($this->rates_form->build_origination_rate_list_for_user());
670
+		foreach ($query->result_array() as $key => $value) {
671
+			$json_data ['rows'] [] = array(
672
+					'cell' => array(
673
+							$this->common->get_only_numeric_val("", "", $value ["pattern"]),
674 674
 							$value ['comment'],
675 675
 							$value ['inc'],
676
-							$this->common_model->calculate_currency ( ($value ['cost'] + ($value ['cost'] * $markup) / 100), '', '', '', true ),
677
-							$this->common_model->calculate_currency ( $value ['connectcost'], '', '', '', true ),
676
+							$this->common_model->calculate_currency(($value ['cost'] + ($value ['cost'] * $markup) / 100), '', '', '', true),
677
+							$this->common_model->calculate_currency($value ['connectcost'], '', '', '', true),
678 678
 							$value ['includedseconds'] 
679 679
 					) 
680 680
 			);
681 681
 		}
682 682
 		// $json_data['rows'] = $this->form->build_grid($query, $grid_fields);
683
-		echo json_encode ( $json_data );
683
+		echo json_encode($json_data);
684 684
 	}
685 685
 	function user_origination_rate_list_search() {
686
-		$ajax_search = $this->input->post ( 'ajax_search', 0 );
686
+		$ajax_search = $this->input->post('ajax_search', 0);
687 687
 		
688
-		if ($this->input->post ( 'advance_search', TRUE ) == 1) {
689
-			$this->session->set_userdata ( 'advance_search', $this->input->post ( 'advance_search' ) );
690
-			$action = $this->input->post ();
691
-			unset ( $action ['action'] );
692
-			unset ( $action ['advance_search'] );
693
-			$this->session->set_userdata ( 'origination_rate_list_search', $action );
688
+		if ($this->input->post('advance_search', TRUE) == 1) {
689
+			$this->session->set_userdata('advance_search', $this->input->post('advance_search'));
690
+			$action = $this->input->post();
691
+			unset ($action ['action']);
692
+			unset ($action ['advance_search']);
693
+			$this->session->set_userdata('origination_rate_list_search', $action);
694 694
 		}
695 695
 		if (@$ajax_search != 1) {
696
-			redirect ( base_url () . 'user/user_rates_list/' );
696
+			redirect(base_url().'user/user_rates_list/');
697 697
 		}
698 698
 	}
699 699
 	function user_origination_rate_list_clearsearchfilter() {
700
-		$this->session->set_userdata ( 'advance_search', 0 );
701
-		$this->session->set_userdata ( 'account_search', "" );
700
+		$this->session->set_userdata('advance_search', 0);
701
+		$this->session->set_userdata('account_search', "");
702 702
 	}
703 703
 	function customer_rates_download_sample_file($file_name) {
704
-		$this->load->helper ( 'download' );
705
-		$full_path = base_url () . "assets/Rates_File/" . $file_name . ".csv";
706
-		$arrContextOptions = array (
707
-				"ssl" => array (
704
+		$this->load->helper('download');
705
+		$full_path = base_url()."assets/Rates_File/".$file_name.".csv";
706
+		$arrContextOptions = array(
707
+				"ssl" => array(
708 708
 						"verify_peer" => false,
709 709
 						"verify_peer_name" => false 
710 710
 				) 
711 711
 		);
712
-		$file = file_get_contents ( $full_path, false, stream_context_create ( $arrContextOptions ) );
713
-		force_download ( "samplefile.csv", $file );
712
+		$file = file_get_contents($full_path, false, stream_context_create($arrContextOptions));
713
+		force_download("samplefile.csv", $file);
714 714
 	}
715 715
 	function termination_rate_batch_update() {
716
-		$batch_update_arr = $this->input->post ();
717
-		$batch_update_arr ["cost"] ["cost"] = isset ( $batch_update_arr ["cost"] ["cost"] ) ? $this->common_model->add_calculate_currency ( $batch_update_arr ["cost"] ["cost"], '', '', true, false ) : "0.0000";
718
-		$batch_update_arr ["connectcost"] ["connectcost"] = isset ( $batch_update_arr ["connectcost"] ["connectcost"] ) ? $this->common_model->add_calculate_currency ( $batch_update_arr ["connectcost"] ["connectcost"], '', '', true, false ) : "0.0000";
716
+		$batch_update_arr = $this->input->post();
717
+		$batch_update_arr ["cost"] ["cost"] = isset ($batch_update_arr ["cost"] ["cost"]) ? $this->common_model->add_calculate_currency($batch_update_arr ["cost"] ["cost"], '', '', true, false) : "0.0000";
718
+		$batch_update_arr ["connectcost"] ["connectcost"] = isset ($batch_update_arr ["connectcost"] ["connectcost"]) ? $this->common_model->add_calculate_currency($batch_update_arr ["connectcost"] ["connectcost"], '', '', true, false) : "0.0000";
719 719
 		// $batch_update_arr = array("inc"=> array("inc"=>"1","operator"=>"3"),"cost"=> array("cost"=>"1","operator"=>"4"));
720
-		$result = $this->rates_model->termination_rate_batch_update ( $batch_update_arr );
721
-		echo json_encode ( array (
720
+		$result = $this->rates_model->termination_rate_batch_update($batch_update_arr);
721
+		echo json_encode(array(
722 722
 				"SUCCESS" => "Termination rates batch updated successfully!" 
723
-		) );
723
+		));
724 724
 		exit ();
725 725
 	}
726 726
 	function origination_rate_batch_update() {
727
-		$batch_update_arr = $this->input->post ();
728
-		$batch_update_arr ["cost"] ["cost"] = isset ( $batch_update_arr ["cost"] ["cost"] ) ? $this->common_model->add_calculate_currency ( $batch_update_arr ["cost"] ["cost"], '', '', true, false ) : "0.0000";
727
+		$batch_update_arr = $this->input->post();
728
+		$batch_update_arr ["cost"] ["cost"] = isset ($batch_update_arr ["cost"] ["cost"]) ? $this->common_model->add_calculate_currency($batch_update_arr ["cost"] ["cost"], '', '', true, false) : "0.0000";
729 729
 		// $batch_update_arr = array("inc"=> array("inc"=>"1","operator"=>"3"),"cost"=> array("cost"=>"1","operator"=>"4"));
730
-		$result = $this->rates_model->origination_rate_batch_update ( $batch_update_arr );
731
-		echo json_encode ( array (
730
+		$result = $this->rates_model->origination_rate_batch_update($batch_update_arr);
731
+		echo json_encode(array(
732 732
 				"SUCCESS" => "Origination rates batch updated successfully!" 
733
-		) );
733
+		));
734 734
 		exit ();
735 735
 	}
736 736
 	function termination_rate_export_cdr_xls() {
737
-		$account_info = $accountinfo = $this->session->userdata ( 'accountinfo' );
737
+		$account_info = $accountinfo = $this->session->userdata('accountinfo');
738 738
 		$currency_id = $account_info ['currency_id'];
739
-		$currency = $this->common->get_field_name ( 'currency', 'currency', $currency_id );
740
-		$query = $this->rates_model->get_termination_rate ( true, '', '', false );
741
-		$outbound_array = array ();
742
-		ob_clean ();
743
-		$outbound_array [] = array (
744
-				gettext ( "Code" ),
745
-				gettext ( "Destination" ),
746
-				gettext ( "Connect Cost" ) . "(" . $currency . ")",
747
-				gettext ( "Included Seconds" ),
748
-				gettext ( "Per Minute Cost" ) . "(" . $currency . ")",
749
-				gettext ( "Initial Increment" ),
750
-				gettext ( "Increment" ),
751
-				gettext ( "Priority" ),
752
-				gettext ( "Strip" ),
753
-				gettext ( "Prepend" ),
754
-				gettext ( "Trunk" ),
755
-				gettext ( "Status" ),
756
-				gettext ( "Created Date" ),
757
-				gettext ( "Modified Date" ) 
739
+		$currency = $this->common->get_field_name('currency', 'currency', $currency_id);
740
+		$query = $this->rates_model->get_termination_rate(true, '', '', false);
741
+		$outbound_array = array();
742
+		ob_clean();
743
+		$outbound_array [] = array(
744
+				gettext("Code"),
745
+				gettext("Destination"),
746
+				gettext("Connect Cost")."(".$currency.")",
747
+				gettext("Included Seconds"),
748
+				gettext("Per Minute Cost")."(".$currency.")",
749
+				gettext("Initial Increment"),
750
+				gettext("Increment"),
751
+				gettext("Priority"),
752
+				gettext("Strip"),
753
+				gettext("Prepend"),
754
+				gettext("Trunk"),
755
+				gettext("Status"),
756
+				gettext("Created Date"),
757
+				gettext("Modified Date") 
758 758
 		);
759
-		if ($query->num_rows () > 0) {
759
+		if ($query->num_rows() > 0) {
760 760
 			
761
-			foreach ( $query->result_array () as $row ) {
761
+			foreach ($query->result_array() as $row) {
762 762
 				// echo"<pre>";print_r($row);exit;
763
-				$outbound_array [] = array (
764
-						$row ['pattern'] = $this->common->get_only_numeric_val ( "", "", $row ["pattern"] ),
763
+				$outbound_array [] = array(
764
+						$row ['pattern'] = $this->common->get_only_numeric_val("", "", $row ["pattern"]),
765 765
 						$row ['comment'],
766
-						$this->common_model->calculate_currency ( $row ['connectcost'], '', '', TRUE, false ),
766
+						$this->common_model->calculate_currency($row ['connectcost'], '', '', TRUE, false),
767 767
 						
768 768
 						$row ['includedseconds'],
769
-						$this->common_model->calculate_currency ( $row ['cost'], '', '', TRUE, false ),
769
+						$this->common_model->calculate_currency($row ['cost'], '', '', TRUE, false),
770 770
 						/**
771 771
 						 * ASTPP 3.0
772 772
 						 * For Add Initial Increment field
@@ -781,25 +781,25 @@  discard block
 block discarded – undo
781 781
 						$row ['strip'],
782 782
 						$row ['prepend'],
783 783
 						// $row['trunk_id'],
784
-						$this->common->get_field_name ( 'name', 'trunks', $row ["trunk_id"] ),
785
-						$this->common->get_status ( 'export', '', $row ['status'] ),
786
-						$this->common->convert_GMT_to ( '', '', $row ['creation_date'] ),
787
-						$this->common->convert_GMT_to ( '', '', $row ['last_modified_date'] ) 
784
+						$this->common->get_field_name('name', 'trunks', $row ["trunk_id"]),
785
+						$this->common->get_status('export', '', $row ['status']),
786
+						$this->common->convert_GMT_to('', '', $row ['creation_date']),
787
+						$this->common->convert_GMT_to('', '', $row ['last_modified_date']) 
788 788
 				);
789 789
 			}
790 790
 		}
791
-		$this->load->helper ( 'csv' );
791
+		$this->load->helper('csv');
792 792
 		
793
-		array_to_csv ( $outbound_array, 'Termination_Rates_' . date ( "Y-m-d" ) . '.csv' );
793
+		array_to_csv($outbound_array, 'Termination_Rates_'.date("Y-m-d").'.csv');
794 794
 	}
795 795
 	function termination_rate_export_cdr_pdf() {
796
-		$query = $this->rates_model->get_termination_rate ( true, '', '', false );
797
-		$outbound_array = array ();
798
-		$this->load->library ( 'fpdf' );
799
-		$this->load->library ( 'pdf' );
800
-		$this->fpdf = new PDF ( 'P', 'pt' );
801
-		$this->fpdf->initialize ( 'P', 'mm', 'A4' );
802
-		$this->fpdf->tablewidths = array (
796
+		$query = $this->rates_model->get_termination_rate(true, '', '', false);
797
+		$outbound_array = array();
798
+		$this->load->library('fpdf');
799
+		$this->load->library('pdf');
800
+		$this->fpdf = new PDF('P', 'pt');
801
+		$this->fpdf->initialize('P', 'mm', 'A4');
802
+		$this->fpdf->tablewidths = array(
803 803
 				20,
804 804
 				30,
805 805
 				20,
@@ -810,27 +810,27 @@  discard block
 block discarded – undo
810 810
 				20,
811 811
 				20 
812 812
 		);
813
-		$outbound_array [] = array (
814
-				gettext ( "Code" ),
815
-				gettext ( "Destination" ),
816
-				gettext ( "Connect Cost" ),
817
-				gettext ( "Included Seconds" ),
818
-				gettext ( "Per Minute Cost" ),
819
-				gettext ( "Initial Increment" ),
820
-				gettext ( "Increment" ),
821
-				gettext ( "Precedence" ),
822
-				gettext ( "Prepend" ),
823
-				gettext ( "Strip" ) 
813
+		$outbound_array [] = array(
814
+				gettext("Code"),
815
+				gettext("Destination"),
816
+				gettext("Connect Cost"),
817
+				gettext("Included Seconds"),
818
+				gettext("Per Minute Cost"),
819
+				gettext("Initial Increment"),
820
+				gettext("Increment"),
821
+				gettext("Precedence"),
822
+				gettext("Prepend"),
823
+				gettext("Strip") 
824 824
 		);
825
-		if ($query->num_rows () > 0) {
825
+		if ($query->num_rows() > 0) {
826 826
 			
827
-			foreach ( $query->result_array () as $row ) {
828
-				$outbound_array [] = array (
829
-						$row ['pattern'] = $this->common->get_only_numeric_val ( "", "", $row ["pattern"] ),
827
+			foreach ($query->result_array() as $row) {
828
+				$outbound_array [] = array(
829
+						$row ['pattern'] = $this->common->get_only_numeric_val("", "", $row ["pattern"]),
830 830
 						$row ['comment'],
831 831
 						$row ['connectcost'],
832 832
 						$row ['includedseconds'],
833
-						$this->common_model->calculate_currency ( $row ['cost'] ),
833
+						$this->common_model->calculate_currency($row ['cost']),
834 834
 						/**
835 835
 						 * ASTPP 3.0
836 836
 						 * For Add Initial Increment field
@@ -847,51 +847,51 @@  discard block
 block discarded – undo
847 847
 				);
848 848
 			}
849 849
 		}
850
-		$this->fpdf->AliasNbPages ();
851
-		$this->fpdf->AddPage ();
850
+		$this->fpdf->AliasNbPages();
851
+		$this->fpdf->AddPage();
852 852
 		
853
-		$this->fpdf->SetFont ( 'Arial', '', 15 );
854
-		$this->fpdf->SetXY ( 60, 5 );
855
-		$this->fpdf->Cell ( 100, 10, "Outbound Rates Report " . date ( 'Y-m-d' ) );
853
+		$this->fpdf->SetFont('Arial', '', 15);
854
+		$this->fpdf->SetXY(60, 5);
855
+		$this->fpdf->Cell(100, 10, "Outbound Rates Report ".date('Y-m-d'));
856 856
 		
857
-		$this->fpdf->SetY ( 20 );
858
-		$this->fpdf->SetFont ( 'Arial', '', 7 );
859
-		$this->fpdf->SetFillColor ( 255, 255, 255 );
857
+		$this->fpdf->SetY(20);
858
+		$this->fpdf->SetFont('Arial', '', 7);
859
+		$this->fpdf->SetFillColor(255, 255, 255);
860 860
 		$this->fpdf->lMargin = 2;
861 861
 		
862
-		$dimensions = $this->fpdf->export_pdf ( $outbound_array, "7" );
863
-		$this->fpdf->Output ( 'Termination_Rate_' . date ( "Y-m-d" ) . '.pdf', "D" );
862
+		$dimensions = $this->fpdf->export_pdf($outbound_array, "7");
863
+		$this->fpdf->Output('Termination_Rate_'.date("Y-m-d").'.pdf', "D");
864 864
 	}
865 865
 	function origination_rate_export_cdr_xls() {
866
-		$account_info = $accountinfo = $this->session->userdata ( 'accountinfo' );
866
+		$account_info = $accountinfo = $this->session->userdata('accountinfo');
867 867
 		$currency_id = $account_info ['currency_id'];
868
-		$currency = $this->common->get_field_name ( 'currency', 'currency', $currency_id );
869
-		$query = $this->rates_model->get_origination_rate ( true, '', '', false );
868
+		$currency = $this->common->get_field_name('currency', 'currency', $currency_id);
869
+		$query = $this->rates_model->get_origination_rate(true, '', '', false);
870 870
 		// echo "<pre>";print_r($query);exit;
871
-		$inbound_array = array ();
872
-		ob_clean ();
873
-		$inbound_array [] = array (
874
-				gettext ( "Code" ),
875
-				gettext ( "Destination" ),
876
-				gettext ( "Connect Cost" ) . "(" . $currency . ")",
877
-				gettext ( "Included Seconds" ),
878
-				gettext ( "Per Minute Cost" ) . "(" . $currency . ")",
879
-				gettext ( "Initial Increment" ),
880
-				gettext ( "Increment" ),
881
-				gettext ( "Rate Group" ),
882
-				gettext ( "Status" ),
883
-				gettext ( "Created Date" ) 
871
+		$inbound_array = array();
872
+		ob_clean();
873
+		$inbound_array [] = array(
874
+				gettext("Code"),
875
+				gettext("Destination"),
876
+				gettext("Connect Cost")."(".$currency.")",
877
+				gettext("Included Seconds"),
878
+				gettext("Per Minute Cost")."(".$currency.")",
879
+				gettext("Initial Increment"),
880
+				gettext("Increment"),
881
+				gettext("Rate Group"),
882
+				gettext("Status"),
883
+				gettext("Created Date") 
884 884
 		);
885
-		if ($query->num_rows () > 0) {
885
+		if ($query->num_rows() > 0) {
886 886
 			
887
-			foreach ( $query->result_array () as $row ) {
887
+			foreach ($query->result_array() as $row) {
888 888
 				// echo"<pre>";print_r($row);exit;
889
-				$inbound_array [] = array (
890
-						$row ['pattern'] = $this->common->get_only_numeric_val ( "", "", $row ["pattern"] ),
889
+				$inbound_array [] = array(
890
+						$row ['pattern'] = $this->common->get_only_numeric_val("", "", $row ["pattern"]),
891 891
 						$row ['comment'],
892
-						$this->common_model->calculate_currency ( $row ['connectcost'], '', '', TRUE, false ),
892
+						$this->common_model->calculate_currency($row ['connectcost'], '', '', TRUE, false),
893 893
 						$row ['includedseconds'],
894
-						$this->common_model->calculate_currency ( $row ['cost'], '', '', TRUE, false ),
894
+						$this->common_model->calculate_currency($row ['cost'], '', '', TRUE, false),
895 895
 						/**
896 896
 						 * ASTPP 3.0
897 897
 						 * For Add Initial Increment field
@@ -903,24 +903,24 @@  discard block
 block discarded – undo
903 903
 						 */
904 904
 						$row ['inc'],
905 905
 						// $row['precedence'],
906
-						$this->common->get_field_name ( 'name', 'pricelists', $row ['pricelist_id'] ),
907
-						$this->common->get_status ( 'export', '', $row ['status'] ),
906
+						$this->common->get_field_name('name', 'pricelists', $row ['pricelist_id']),
907
+						$this->common->get_status('export', '', $row ['status']),
908 908
 						$row ['creation_date'] 
909 909
 				);
910 910
 			}
911 911
 		}
912
-		$this->load->helper ( 'csv' );
913
-		array_to_csv ( $inbound_array, 'Origination_Rates_' . date ( "Y-m-d" ) . '.csv' );
912
+		$this->load->helper('csv');
913
+		array_to_csv($inbound_array, 'Origination_Rates_'.date("Y-m-d").'.csv');
914 914
 	}
915 915
 	function origination_rate_export_cdr_pdf() {
916
-		$query = $this->rates_model->get_origination_rate ( true, '', '', false );
916
+		$query = $this->rates_model->get_origination_rate(true, '', '', false);
917 917
 		
918
-		$inbound_array = array ();
919
-		$this->load->library ( 'fpdf' );
920
-		$this->load->library ( 'pdf' );
921
-		$this->fpdf = new PDF ( 'P', 'pt' );
922
-		$this->fpdf->initialize ( 'P', 'mm', 'A4' );
923
-		$this->fpdf->tablewidths = array (
918
+		$inbound_array = array();
919
+		$this->load->library('fpdf');
920
+		$this->load->library('pdf');
921
+		$this->fpdf = new PDF('P', 'pt');
922
+		$this->fpdf->initialize('P', 'mm', 'A4');
923
+		$this->fpdf->tablewidths = array(
924 924
 				20,
925 925
 				20,
926 926
 				20,
@@ -928,23 +928,23 @@  discard block
 block discarded – undo
928 928
 				20,
929 929
 				20 
930 930
 		);
931
-		$inbound_array [] = array (
932
-				gettext ( "Code" ),
933
-				gettext ( "Destination" ),
934
-				gettext ( "Connect Cost" ),
935
-				gettext ( "Included Seconds" ),
936
-				gettext ( "Per Minute Cost" ),
937
-				gettext ( "Initial Increment" ),
938
-				gettext ( "Increment" ) 
931
+		$inbound_array [] = array(
932
+				gettext("Code"),
933
+				gettext("Destination"),
934
+				gettext("Connect Cost"),
935
+				gettext("Included Seconds"),
936
+				gettext("Per Minute Cost"),
937
+				gettext("Initial Increment"),
938
+				gettext("Increment") 
939 939
 		);
940
-		if ($query->num_rows () > 0) {
941
-			foreach ( $query->result_array () as $row ) {
942
-				$inbound_array [] = array (
943
-						$row ['pattern'] = $this->common->get_only_numeric_val ( "", "", $row ["pattern"] ),
940
+		if ($query->num_rows() > 0) {
941
+			foreach ($query->result_array() as $row) {
942
+				$inbound_array [] = array(
943
+						$row ['pattern'] = $this->common->get_only_numeric_val("", "", $row ["pattern"]),
944 944
 						$row ['comment'],
945 945
 						$row ['connectcost'],
946 946
 						$row ['includedseconds'],
947
-						$this->common_model->calculate_currency ( $row ['cost'], '', '', '', false ),
947
+						$this->common_model->calculate_currency($row ['cost'], '', '', '', false),
948 948
 						/**
949 949
 						 * ASTPP 3.0
950 950
 						 * For Add Initial Increment field
@@ -958,29 +958,29 @@  discard block
 block discarded – undo
958 958
 				);
959 959
 			}
960 960
 		}
961
-		$this->fpdf->AliasNbPages ();
962
-		$this->fpdf->AddPage ();
961
+		$this->fpdf->AliasNbPages();
962
+		$this->fpdf->AddPage();
963 963
 		
964
-		$this->fpdf->SetFont ( 'Arial', '', 15 );
965
-		$this->fpdf->SetXY ( 60, 5 );
966
-		$this->fpdf->Cell ( 100, 10, "Origination Rates Report " . date ( 'Y-m-d' ) );
964
+		$this->fpdf->SetFont('Arial', '', 15);
965
+		$this->fpdf->SetXY(60, 5);
966
+		$this->fpdf->Cell(100, 10, "Origination Rates Report ".date('Y-m-d'));
967 967
 		
968
-		$this->fpdf->SetY ( 20 );
969
-		$this->fpdf->SetFont ( 'Arial', '', 7 );
970
-		$this->fpdf->SetFillColor ( 255, 255, 255 );
968
+		$this->fpdf->SetY(20);
969
+		$this->fpdf->SetFont('Arial', '', 7);
970
+		$this->fpdf->SetFillColor(255, 255, 255);
971 971
 		$this->fpdf->lMargin = 2;
972 972
 		
973
-		$dimensions = $this->fpdf->export_pdf ( $inbound_array, "5" );
974
-		$this->fpdf->Output ( 'Origination_Rate_' . date ( "Y-m-d" ) . '.pdf', "D" );
973
+		$dimensions = $this->fpdf->export_pdf($inbound_array, "5");
974
+		$this->fpdf->Output('Origination_Rate_'.date("Y-m-d").'.pdf', "D");
975 975
 	}
976 976
 	function user_origination_rate_cdr_pdf() {
977
-		$query = $this->rates_model->get_origination_rate_for_user ( true, '', '', false );
978
-		$inbound_array = array ();
979
-		$this->load->library ( 'fpdf' );
980
-		$this->load->library ( 'pdf' );
981
-		$this->fpdf = new PDF ( 'P', 'pt' );
982
-		$this->fpdf->initialize ( 'P', 'mm', 'A4' );
983
-		$this->fpdf->tablewidths = array (
977
+		$query = $this->rates_model->get_origination_rate_for_user(true, '', '', false);
978
+		$inbound_array = array();
979
+		$this->load->library('fpdf');
980
+		$this->load->library('pdf');
981
+		$this->fpdf = new PDF('P', 'pt');
982
+		$this->fpdf->initialize('P', 'mm', 'A4');
983
+		$this->fpdf->tablewidths = array(
984 984
 				20,
985 985
 				20,
986 986
 				20,
@@ -988,135 +988,135 @@  discard block
 block discarded – undo
988 988
 				20,
989 989
 				20 
990 990
 		);
991
-		$inbound_array [] = array (
992
-				gettext ( "Code" ),
993
-				gettext ( "Destination" ),
994
-				gettext ( "Increment" ),
995
-				gettext ( "Cost Per Minutes" ),
996
-				gettext ( "Connect Charge" ),
997
-				gettext ( "Included Seconds" ) 
991
+		$inbound_array [] = array(
992
+				gettext("Code"),
993
+				gettext("Destination"),
994
+				gettext("Increment"),
995
+				gettext("Cost Per Minutes"),
996
+				gettext("Connect Charge"),
997
+				gettext("Included Seconds") 
998 998
 		);
999
-		if ($query->num_rows () > 0) {
1000
-			foreach ( $query->result_array () as $row ) {
1001
-				$inbound_array [] = array (
1002
-						$row ['pattern'] = $this->common->get_only_numeric_val ( "", "", $row ["pattern"] ),
999
+		if ($query->num_rows() > 0) {
1000
+			foreach ($query->result_array() as $row) {
1001
+				$inbound_array [] = array(
1002
+						$row ['pattern'] = $this->common->get_only_numeric_val("", "", $row ["pattern"]),
1003 1003
 						$row ['comment'],
1004 1004
 						$row ['inc'],
1005
-						$this->common_model->calculate_currency ( $row ['cost'], '', '', '', false ),
1005
+						$this->common_model->calculate_currency($row ['cost'], '', '', '', false),
1006 1006
 						$row ['connectcost'],
1007 1007
 						$row ['includedseconds'] 
1008 1008
 				);
1009 1009
 			}
1010 1010
 		}
1011 1011
 		
1012
-		$this->fpdf->AliasNbPages ();
1013
-		$this->fpdf->AddPage ();
1012
+		$this->fpdf->AliasNbPages();
1013
+		$this->fpdf->AddPage();
1014 1014
 		
1015
-		$this->fpdf->SetFont ( 'Arial', '', 15 );
1016
-		$this->fpdf->SetXY ( 60, 5 );
1017
-		$this->fpdf->Cell ( 100, 10, "Rates Report " . date ( 'Y-m-d' ) );
1015
+		$this->fpdf->SetFont('Arial', '', 15);
1016
+		$this->fpdf->SetXY(60, 5);
1017
+		$this->fpdf->Cell(100, 10, "Rates Report ".date('Y-m-d'));
1018 1018
 		
1019
-		$this->fpdf->SetY ( 20 );
1020
-		$this->fpdf->SetFont ( 'Arial', '', 7 );
1021
-		$this->fpdf->SetFillColor ( 255, 255, 255 );
1019
+		$this->fpdf->SetY(20);
1020
+		$this->fpdf->SetFont('Arial', '', 7);
1021
+		$this->fpdf->SetFillColor(255, 255, 255);
1022 1022
 		$this->fpdf->lMargin = 2;
1023 1023
 		
1024
-		$dimensions = $this->fpdf->export_pdf ( $inbound_array, "5" );
1025
-		$this->fpdf->Output ( 'Rates_' . date ( "Y-m-d" ) . '.pdf', "D" );
1024
+		$dimensions = $this->fpdf->export_pdf($inbound_array, "5");
1025
+		$this->fpdf->Output('Rates_'.date("Y-m-d").'.pdf', "D");
1026 1026
 	}
1027 1027
 	function resellersrates_list() {
1028
-		$accountinfo = $this->session->userdata ( 'accountinfo' );
1029
-		$data ['username'] = $this->session->userdata ( 'user_name' );
1030
-		$data ['page_title'] = gettext ( 'My Rates' );
1028
+		$accountinfo = $this->session->userdata('accountinfo');
1029
+		$data ['username'] = $this->session->userdata('user_name');
1030
+		$data ['page_title'] = gettext('My Rates');
1031 1031
 		$data ['search_flag'] = true;
1032
-		$this->session->set_userdata ( 'advance_search', 0 );
1033
-		$data ['grid_fields'] = $this->rates_form->build_rates_list_for_reseller ();
1034
-		$data ["grid_buttons"] = $this->rates_form->build_grid_buttons_rates ();
1035
-		$data ['form_search'] = $this->form->build_serach_form ( $this->rates_form->get_reseller_origination_rate_search_form () );
1036
-		$this->load->view ( 'view_resellersrates_list', $data );
1032
+		$this->session->set_userdata('advance_search', 0);
1033
+		$data ['grid_fields'] = $this->rates_form->build_rates_list_for_reseller();
1034
+		$data ["grid_buttons"] = $this->rates_form->build_grid_buttons_rates();
1035
+		$data ['form_search'] = $this->form->build_serach_form($this->rates_form->get_reseller_origination_rate_search_form());
1036
+		$this->load->view('view_resellersrates_list', $data);
1037 1037
 	}
1038 1038
 	function resellersrates_list_json() {
1039
-		$json_data = array ();
1040
-		$account_data = $this->session->userdata ( "accountinfo" );
1041
-		$markup = $this->common->get_field_name ( 'markup', 'pricelists', array (
1039
+		$json_data = array();
1040
+		$account_data = $this->session->userdata("accountinfo");
1041
+		$markup = $this->common->get_field_name('markup', 'pricelists', array(
1042 1042
 				'id' => $account_data ["pricelist_id"] 
1043
-		) );
1043
+		));
1044 1044
 		// $markup = ($markup > 0)?$markup:1;
1045
-		$count_all = $this->rates_model->getreseller_rates_list ( false );
1046
-		$paging_data = $this->form->load_grid_config ( $count_all, $_GET ['rp'], $_GET ['page'] );
1045
+		$count_all = $this->rates_model->getreseller_rates_list(false);
1046
+		$paging_data = $this->form->load_grid_config($count_all, $_GET ['rp'], $_GET ['page']);
1047 1047
 		$json_data = $paging_data ["json_paging"];
1048
-		$query = $this->rates_model->getreseller_rates_list ( true, $paging_data ["paging"] ["start"], $paging_data ["paging"] ["page_no"] );
1049
-		$grid_fields = json_decode ( $this->rates_form->build_rates_list_for_reseller () );
1050
-		foreach ( $query->result_array () as $key => $value ) {
1051
-			$json_data ['rows'] [] = array (
1052
-					'cell' => array (
1053
-							$this->common->get_only_numeric_val ( "", "", $value ["pattern"] ),
1048
+		$query = $this->rates_model->getreseller_rates_list(true, $paging_data ["paging"] ["start"], $paging_data ["paging"] ["page_no"]);
1049
+		$grid_fields = json_decode($this->rates_form->build_rates_list_for_reseller());
1050
+		foreach ($query->result_array() as $key => $value) {
1051
+			$json_data ['rows'] [] = array(
1052
+					'cell' => array(
1053
+							$this->common->get_only_numeric_val("", "", $value ["pattern"]),
1054 1054
 							$value ['comment'],
1055
-							$this->common_model->calculate_currency ( $value ['connectcost'], '', '', 'true', true ),
1055
+							$this->common_model->calculate_currency($value ['connectcost'], '', '', 'true', true),
1056 1056
 							$value ['includedseconds'],
1057
-							$this->common_model->calculate_currency ( ($value ['cost'] + ($value ['cost'] * $markup) / 100), '', '', 'true', true ),
1057
+							$this->common_model->calculate_currency(($value ['cost'] + ($value ['cost'] * $markup) / 100), '', '', 'true', true),
1058 1058
 							$value ['inc'],
1059 1059
 							$value ['precedence'] 
1060 1060
 					) 
1061 1061
 			);
1062 1062
 		}
1063 1063
 		// $json_data['rows'] = $this->form->build_grid($query, $grid_fields);
1064
-		echo json_encode ( $json_data );
1064
+		echo json_encode($json_data);
1065 1065
 	}
1066 1066
 	function resellersrates_list_search() {
1067
-		$ajax_search = $this->input->post ( 'ajax_search', 0 );
1067
+		$ajax_search = $this->input->post('ajax_search', 0);
1068 1068
 		
1069
-		if ($this->input->post ( 'advance_search', TRUE ) == 1) {
1070
-			$this->session->set_userdata ( 'advance_search', $this->input->post ( 'advance_search' ) );
1071
-			$action = $this->input->post ();
1069
+		if ($this->input->post('advance_search', TRUE) == 1) {
1070
+			$this->session->set_userdata('advance_search', $this->input->post('advance_search'));
1071
+			$action = $this->input->post();
1072 1072
 			
1073
-			unset ( $action ['action'] );
1074
-			unset ( $action ['advance_search'] );
1075
-			$this->session->set_userdata ( 'resellerrates_list_search', $action );
1073
+			unset ($action ['action']);
1074
+			unset ($action ['advance_search']);
1075
+			$this->session->set_userdata('resellerrates_list_search', $action);
1076 1076
 		}
1077 1077
 		if (@$ajax_search != 1) {
1078
-			redirect ( base_url () . 'rates/resellersrates_list/' );
1078
+			redirect(base_url().'rates/resellersrates_list/');
1079 1079
 		}
1080 1080
 	}
1081 1081
 	function resellersrates_list_clearsearchfilter() {
1082
-		$this->session->set_userdata ( 'advance_search', 0 );
1083
-		$this->session->set_userdata ( 'resellerrates_list_search', "" );
1082
+		$this->session->set_userdata('advance_search', 0);
1083
+		$this->session->set_userdata('resellerrates_list_search', "");
1084 1084
 	}
1085 1085
 	function resellersrates_xls() {
1086
-		$account_info = $accountinfo = $this->session->userdata ( 'accountinfo' );
1086
+		$account_info = $accountinfo = $this->session->userdata('accountinfo');
1087 1087
 		$currency_id = $account_info ['currency_id'];
1088
-		$currency = $this->common->get_field_name ( 'currency', 'currency', $currency_id );
1089
-		$query = $this->rates_model->getreseller_rates_list ( true, '0', '0', '1' );
1090
-		$customer_array = array ();
1091
-		ob_clean ();
1088
+		$currency = $this->common->get_field_name('currency', 'currency', $currency_id);
1089
+		$query = $this->rates_model->getreseller_rates_list(true, '0', '0', '1');
1090
+		$customer_array = array();
1091
+		ob_clean();
1092 1092
 		
1093
-		$customer_array [] = array (
1094
-				gettext ( "Code" ),
1095
-				gettext ( "Destination" ),
1096
-				gettext ( "Connect Cost" ) . "(" . $currency . ")",
1097
-				gettext ( "Included Seconds" ),
1098
-				gettext ( "Per Minute Cost" ) . "(" . $currency . ")",
1099
-				gettext ( "Increment" ),
1100
-				gettext ( "Precedence" ) 
1093
+		$customer_array [] = array(
1094
+				gettext("Code"),
1095
+				gettext("Destination"),
1096
+				gettext("Connect Cost")."(".$currency.")",
1097
+				gettext("Included Seconds"),
1098
+				gettext("Per Minute Cost")."(".$currency.")",
1099
+				gettext("Increment"),
1100
+				gettext("Precedence") 
1101 1101
 		);
1102 1102
 		
1103
-		if ($query->num_rows () > 0) {
1103
+		if ($query->num_rows() > 0) {
1104 1104
 			
1105
-			foreach ( $query->result_array () as $row ) {
1105
+			foreach ($query->result_array() as $row) {
1106 1106
 				
1107
-				$customer_array [] = array (
1108
-						$row ['pattern'] = $this->common->get_only_numeric_val ( "", "", $row ["pattern"] ),
1107
+				$customer_array [] = array(
1108
+						$row ['pattern'] = $this->common->get_only_numeric_val("", "", $row ["pattern"]),
1109 1109
 						$row ['comment'],
1110 1110
 						$row ['connectcost'],
1111 1111
 						$row ['includedseconds'],
1112
-						$this->common_model->calculate_currency ( $row ['cost'] ),
1112
+						$this->common_model->calculate_currency($row ['cost']),
1113 1113
 						$row ['inc'],
1114 1114
 						$row ['precedence'] 
1115 1115
 				);
1116 1116
 			}
1117 1117
 		}
1118
-		$this->load->helper ( 'csv' );
1119
-		array_to_csv ( $customer_array, 'My_Own_Rate_' . date ( "Y-m-d" ) . '.csv' );
1118
+		$this->load->helper('csv');
1119
+		array_to_csv($customer_array, 'My_Own_Rate_'.date("Y-m-d").'.csv');
1120 1120
 		exit ();
1121 1121
 	}
1122 1122
 	/**
@@ -1126,109 +1126,109 @@  discard block
 block discarded – undo
1126 1126
 	 * **********
1127 1127
 	 */
1128 1128
 	function termination_rates_list_batch_delete() {
1129
-		$ajax_search = $this->input->post ( 'ajax_search', 0 );
1130
-		if ($this->input->post ( 'advance_search', TRUE ) == 1) {
1131
-			$this->session->set_userdata ( 'advance_batch_delete', $this->input->post ( 'advance_search' ) );
1132
-			$action = $this->input->post ();
1133
-			unset ( $action ['action'] );
1134
-			unset ( $action ['advance_search'] );
1135
-			$this->session->set_userdata ( 'termination_rates_list_search', $action );
1129
+		$ajax_search = $this->input->post('ajax_search', 0);
1130
+		if ($this->input->post('advance_search', TRUE) == 1) {
1131
+			$this->session->set_userdata('advance_batch_delete', $this->input->post('advance_search'));
1132
+			$action = $this->input->post();
1133
+			unset ($action ['action']);
1134
+			unset ($action ['advance_search']);
1135
+			$this->session->set_userdata('termination_rates_list_search', $action);
1136 1136
 		}
1137 1137
 		if (@$ajax_search != 1) {
1138
-			redirect ( base_url () . 'rates/termination_rates_list/' );
1138
+			redirect(base_url().'rates/termination_rates_list/');
1139 1139
 		}
1140 1140
 	}
1141 1141
 	function origination_rates_list_batch_delete() {
1142
-		$ajax_search = $this->input->post ( 'ajax_search', 0 );
1143
-		if ($this->input->post ( 'advance_search', TRUE ) == 1) {
1144
-			$this->session->set_userdata ( 'advance_batch_delete', $this->input->post ( 'advance_search' ) );
1145
-			$action = $this->input->post ();
1146
-			unset ( $action ['action'] );
1147
-			unset ( $action ['advance_search'] );
1148
-			$this->session->set_userdata ( 'origination_rate_list_search', $action );
1142
+		$ajax_search = $this->input->post('ajax_search', 0);
1143
+		if ($this->input->post('advance_search', TRUE) == 1) {
1144
+			$this->session->set_userdata('advance_batch_delete', $this->input->post('advance_search'));
1145
+			$action = $this->input->post();
1146
+			unset ($action ['action']);
1147
+			unset ($action ['advance_search']);
1148
+			$this->session->set_userdata('origination_rate_list_search', $action);
1149 1149
 		}
1150 1150
 		if (@$ajax_search != 1) {
1151
-			redirect ( base_url () . 'rates/origination_rates_list/' );
1151
+			redirect(base_url().'rates/origination_rates_list/');
1152 1152
 		}
1153 1153
 	}
1154 1154
 	/**
1155 1155
 	 * ******* Import Mapper Code - ISSUE-142 *********
1156 1156
 	 */
1157 1157
 	function termination_rate_import_mapper() {
1158
-		$data ['page_title'] = gettext ( 'Import Termination Rates using field mapper' );
1159
-		$this->session->set_userdata ( 'import_termination_rate_mapper_csv', "" );
1160
-		$this->session->set_userdata ( 'import_termination_rate_mapper_csv_error', "" );
1158
+		$data ['page_title'] = gettext('Import Termination Rates using field mapper');
1159
+		$this->session->set_userdata('import_termination_rate_mapper_csv', "");
1160
+		$this->session->set_userdata('import_termination_rate_mapper_csv_error', "");
1161 1161
 		
1162
-		$this->load->view ( 'view_import_termination_rate_mapper', $data );
1162
+		$this->load->view('view_import_termination_rate_mapper', $data);
1163 1163
 	}
1164 1164
 	function csv_to_array($filename = '', $delimiter = ',') {
1165
-		if (! file_exists ( $filename ) || ! is_readable ( $filename ))
1165
+		if ( ! file_exists($filename) || ! is_readable($filename))
1166 1166
 			return FALSE;
1167 1167
 		$header = NULL;
1168
-		$data = array ();
1169
-		if (($handle = fopen ( $filename, 'r' )) !== FALSE) {
1170
-			while ( ($row = fgetcsv ( $handle, 1000, $delimiter )) !== FALSE ) {
1168
+		$data = array();
1169
+		if (($handle = fopen($filename, 'r')) !== FALSE) {
1170
+			while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE) {
1171 1171
 				
1172
-				if (! $header)
1172
+				if ( ! $header)
1173 1173
 					$header = $row;
1174 1174
 				else
1175
-					$data [] = array_combine ( $header, $row );
1175
+					$data [] = array_combine($header, $row);
1176 1176
 			}
1177 1177
 			
1178
-			fclose ( $handle );
1178
+			fclose($handle);
1179 1179
 		}
1180 1180
 		
1181 1181
 		return $data;
1182 1182
 	}
1183 1183
 	function utf8_converter($array) {
1184
-		array_walk_recursive ( $array, function (&$item, $key) {
1185
-			if (! mb_detect_encoding ( $item, 'utf-8', true )) {
1186
-				$item = utf8_encode ( $item );
1184
+		array_walk_recursive($array, function(&$item, $key) {
1185
+			if ( ! mb_detect_encoding($item, 'utf-8', true)) {
1186
+				$item = utf8_encode($item);
1187 1187
 			}
1188 1188
 		} );
1189 1189
 		return $array;
1190 1190
 	}
1191 1191
 	function termination_rate_mapper_preview_file() {
1192 1192
 		$invalid_flag = false;
1193
-		$check_header = $this->input->post ( 'check_header', true );
1194
-		$data ['page_title'] = gettext ( 'Import Termination Rates' );
1195
-		$new_final_arr_key = $this->config->item ( 'Termination-rates-field' );
1196
-		if (empty ( $_FILES ) || ! isset ( $_FILES )) {
1197
-			redirect ( base_url () . "rates/termination_rates_list/" );
1193
+		$check_header = $this->input->post('check_header', true);
1194
+		$data ['page_title'] = gettext('Import Termination Rates');
1195
+		$new_final_arr_key = $this->config->item('Termination-rates-field');
1196
+		if (empty ($_FILES) || ! isset ($_FILES)) {
1197
+			redirect(base_url()."rates/termination_rates_list/");
1198 1198
 		}
1199 1199
 		
1200 1200
 		$data ['mapto_fields'] = $new_final_arr_key;
1201 1201
 		
1202
-		if (isset ( $_FILES ['termination_rate_import_mapper'] ['name'] ) && $_FILES ['termination_rate_import_mapper'] ['name'] != "" && isset ( $_POST ['trunk_id'] ) && $_POST ['trunk_id'] != '') {
1203
-			list ( $txt, $ext ) = explode ( ".", $_FILES ['termination_rate_import_mapper'] ['name'] );
1202
+		if (isset ($_FILES ['termination_rate_import_mapper'] ['name']) && $_FILES ['termination_rate_import_mapper'] ['name'] != "" && isset ($_POST ['trunk_id']) && $_POST ['trunk_id'] != '') {
1203
+			list ($txt, $ext) = explode(".", $_FILES ['termination_rate_import_mapper'] ['name']);
1204 1204
 			if ($ext == "csv" && $_FILES ['termination_rate_import_mapper'] ['size'] > 0) {
1205 1205
 				$error = $_FILES ['termination_rate_import_mapper'] ['error'];
1206 1206
 				if ($error == 0) {
1207 1207
 					$uploadedFile = $_FILES ["termination_rate_import_mapper"] ["tmp_name"];
1208 1208
 					
1209
-					$file_data = $this->csv_to_array ( $uploadedFile );
1209
+					$file_data = $this->csv_to_array($uploadedFile);
1210 1210
 					
1211
-					$field_select = (array_keys ( $file_data [0] ));
1211
+					$field_select = (array_keys($file_data [0]));
1212 1212
 					
1213 1213
 					$data ['file_data'] = $field_select;
1214 1214
 					
1215 1215
 					// $csv_data = $this->csvreader->parse_file($uploadedFile, $new_final_arr_key, $check_header);
1216 1216
 					
1217
-					$csv_data = $this->utf8_converter ( $this->csvreader->parse_file ( $uploadedFile, $field_select, $check_header ) );
1217
+					$csv_data = $this->utf8_converter($this->csvreader->parse_file($uploadedFile, $field_select, $check_header));
1218 1218
 					
1219
-					if (! empty ( $csv_data )) {
1220
-						$full_path = $this->config->item ( 'rates-file-path' );
1221
-						$actual_file_name = "ASTPP-TERMINATION-RATES-" . date ( "Y-m-d H:i:s" ) . "." . $ext;
1222
-						$actual_file_name = str_replace ( ' ', '-', $actual_file_name );
1223
-						$actual_file_name = str_replace ( ':', '-', $actual_file_name );
1219
+					if ( ! empty ($csv_data)) {
1220
+						$full_path = $this->config->item('rates-file-path');
1221
+						$actual_file_name = "ASTPP-TERMINATION-RATES-".date("Y-m-d H:i:s").".".$ext;
1222
+						$actual_file_name = str_replace(' ', '-', $actual_file_name);
1223
+						$actual_file_name = str_replace(':', '-', $actual_file_name);
1224 1224
 						
1225
-						if (move_uploaded_file ( $uploadedFile, $full_path . $actual_file_name )) {
1226
-							$data ['field_select'] = serialize ( $field_select );
1225
+						if (move_uploaded_file($uploadedFile, $full_path.$actual_file_name)) {
1226
+							$data ['field_select'] = serialize($field_select);
1227 1227
 							$data ['csv_tmp_data'] = $csv_data;
1228 1228
 							$data ['trunkid'] = $_POST ['trunk_id'];
1229 1229
 							$data ['check_header'] = $check_header;
1230
-							$data ['page_title'] = gettext ( 'Map CSV to Termination Rates' );
1231
-							$this->session->set_userdata ( 'import_termination_rate_mapper_csv', $actual_file_name );
1230
+							$data ['page_title'] = gettext('Map CSV to Termination Rates');
1231
+							$this->session->set_userdata('import_termination_rate_mapper_csv', $actual_file_name);
1232 1232
 						} else {
1233 1233
 							$data ['error'] = "File Uploading Fail Please Try Again";
1234 1234
 						}
@@ -1246,132 +1246,132 @@  discard block
 block discarded – undo
1246 1246
 		
1247 1247
 		if ($invalid_flag) {
1248 1248
 			$str = '';
1249
-			if (! isset ( $_POST ['trunk_id'] ) || empty ( $_POST ['trunk_id'] )) {
1249
+			if ( ! isset ($_POST ['trunk_id']) || empty ($_POST ['trunk_id'])) {
1250 1250
 				$str .= '<br/>Please Create Trunk.';
1251 1251
 			}
1252 1252
 			
1253
-			if (empty ( $_FILES ['termination_rate_import_mapper'] ['name'] )) {
1253
+			if (empty ($_FILES ['termination_rate_import_mapper'] ['name'])) {
1254 1254
 				$str .= '<br/>Please Select  File.';
1255 1255
 			}
1256 1256
 			
1257 1257
 			$data ['error'] = $str;
1258 1258
 		}
1259 1259
 		
1260
-		$this->load->view ( 'view_import_termination_rate_mapper', $data );
1260
+		$this->load->view('view_import_termination_rate_mapper', $data);
1261 1261
 	}
1262 1262
 	function termination_rate_rates_mapper_import() {
1263 1263
 		
1264 1264
 		// var_dump($this->input->post());
1265
-		$trunkID = $this->input->post ( "trunkid" );
1266
-		$check_header = $this->input->post ( "check_header" );
1267
-		$pattern_prefix = $this->input->post ( "pattern-prefix" );
1268
-		$filefields = unserialize ( $this->input->post ( "filefields" ) );
1269
-		$new_final_arr = array ();
1270
-		$invalid_array = array ();
1271
-		$new_final_arr_key = array ();
1272
-		foreach ( $filefields as $item ) {
1265
+		$trunkID = $this->input->post("trunkid");
1266
+		$check_header = $this->input->post("check_header");
1267
+		$pattern_prefix = $this->input->post("pattern-prefix");
1268
+		$filefields = unserialize($this->input->post("filefields"));
1269
+		$new_final_arr = array();
1270
+		$invalid_array = array();
1271
+		$new_final_arr_key = array();
1272
+		foreach ($filefields as $item) {
1273 1273
 			$new_final_arr_key [$item] = $item;
1274 1274
 		}
1275 1275
 		// $new_final_arr_key = $this->config->item('Termination-rates-field');
1276 1276
 		
1277
-		$screen_path = $this->config->item ( 'screen_path' );
1278
-		if ($this->session->userdata ( 'logintype' ) == 1 || $this->session->userdata ( 'logintype' ) == 5) {
1279
-			$account_data = $this->session->userdata ( "accountinfo" );
1277
+		$screen_path = $this->config->item('screen_path');
1278
+		if ($this->session->userdata('logintype') == 1 || $this->session->userdata('logintype') == 5) {
1279
+			$account_data = $this->session->userdata("accountinfo");
1280 1280
 		}
1281 1281
 		
1282
-		$full_path = $this->config->item ( 'rates-file-path' );
1283
-		$terminationrate_file_name = $this->session->userdata ( 'import_termination_rate_mapper_csv' );
1284
-		$csv_tmp_data = $this->csvreader->parse_file ( $full_path . $terminationrate_file_name, $new_final_arr_key, $check_header );
1282
+		$full_path = $this->config->item('rates-file-path');
1283
+		$terminationrate_file_name = $this->session->userdata('import_termination_rate_mapper_csv');
1284
+		$csv_tmp_data = $this->csvreader->parse_file($full_path.$terminationrate_file_name, $new_final_arr_key, $check_header);
1285 1285
 		
1286 1286
 		$i = 0;
1287
-		foreach ( $csv_tmp_data as $key => $csv_data ) {
1288
-			if (isset ( $csv_data [$this->input->post ( "pattern-select" )] ) && $csv_data [$this->input->post ( "pattern-select" )] != '' && $i != 0 && $i != 1) {
1287
+		foreach ($csv_tmp_data as $key => $csv_data) {
1288
+			if (isset ($csv_data [$this->input->post("pattern-select")]) && $csv_data [$this->input->post("pattern-select")] != '' && $i != 0 && $i != 1) {
1289 1289
 				$str = null;
1290
-				$csv_data ['pattern'] = ($this->input->post ( "pattern-prefix" )) ? $this->input->post ( "pattern-prefix" ) . $csv_data [$this->input->post ( "pattern-select" )] : $csv_data [$this->input->post ( "pattern-select" )];
1291
-				$csv_data ['cost'] = ($this->input->post ( "cost-select" )) ? $csv_data [$this->input->post ( "cost-select" )] : "";
1292
-				$csv_data ['cost'] = ($this->input->post ( "cost-prefix" )) ? $this->input->post ( "cost-prefix" ) . $csv_data ['cost'] : $csv_data ['cost'];
1293
-				$csv_data ['prepend'] = ($this->input->post ( "prepend-select" )) ? $csv_data [$this->input->post ( "prepend-select" )] : "";
1294
-				$csv_data ['prepend'] = ($this->input->post ( "prepend-prefix" )) ? $this->input->post ( "prepend-prefix" ) . $csv_data ['prepend'] : $csv_data ['prepend'];
1295
-				$csv_data ['comment'] = ($this->input->post ( "comment-select" )) ? $csv_data [$this->input->post ( "comment-select" )] : "";
1296
-				$csv_data ['comment'] = ($this->input->post ( "comment-prefix" )) ? $this->input->post ( "comment-prefix" ) . $csv_data ['comment'] : $csv_data ['comment'];
1297
-				$csv_data ['connectcost'] = ($this->input->post ( "connectcost-select" )) ? $csv_data [$this->input->post ( "connectcost-select" )] : "0";
1298
-				$csv_data ['connectcost'] = ($this->input->post ( "connectcost-prefix" )) ? $this->input->post ( "connectcost-prefix" ) . $csv_data ['connectcost'] : $csv_data ['connectcost'];
1299
-				$csv_data ['includedseconds'] = ($this->input->post ( "includedseconds-select" )) ? $csv_data [$this->input->post ( "includedseconds-select" )] : "0";
1300
-				$csv_data ['includedseconds'] = ($this->input->post ( "includedseconds-prefix" )) ? $this->input->post ( "includedseconds-prefix" ) . $csv_data ['includedseconds'] : $csv_data ['includedseconds'];
1301
-				$csv_data ['inc'] = ($this->input->post ( "inc-select" )) ? $csv_data [$this->input->post ( "inc-select" )] : "0";
1302
-				$csv_data ['inc'] = ($this->input->post ( "inc-prefix" )) ? $this->input->post ( "inc-prefix" ) . $csv_data ['inc'] : $csv_data ['inc'];
1303
-				$csv_data ['precedence'] = ($this->input->post ( "precedence-select" )) ? $csv_data [$this->input->post ( "precedence-select" )] : "";
1304
-				$csv_data ['precedence'] = ($this->input->post ( "precedence-prefix" )) ? $this->input->post ( "precedence-prefix" ) . $csv_data ['precedence'] : $csv_data ['precedence'];
1305
-				$csv_data ['strip'] = ($this->input->post ( "strip-select" )) ? $csv_data [$this->input->post ( "strip-select" )] : "";
1306
-				$csv_data ['strip'] = ($this->input->post ( "strip-prefix" )) ? $this->input->post ( "strip-prefix" ) . $csv_data ['strip'] : $csv_data ['strip'];
1307
-				$csv_data ['last_modified_date'] = date ( "Y-m-d H:i:s" );
1308
-				$str = $this->data_validate ( $csv_data );
1290
+				$csv_data ['pattern'] = ($this->input->post("pattern-prefix")) ? $this->input->post("pattern-prefix").$csv_data [$this->input->post("pattern-select")] : $csv_data [$this->input->post("pattern-select")];
1291
+				$csv_data ['cost'] = ($this->input->post("cost-select")) ? $csv_data [$this->input->post("cost-select")] : "";
1292
+				$csv_data ['cost'] = ($this->input->post("cost-prefix")) ? $this->input->post("cost-prefix").$csv_data ['cost'] : $csv_data ['cost'];
1293
+				$csv_data ['prepend'] = ($this->input->post("prepend-select")) ? $csv_data [$this->input->post("prepend-select")] : "";
1294
+				$csv_data ['prepend'] = ($this->input->post("prepend-prefix")) ? $this->input->post("prepend-prefix").$csv_data ['prepend'] : $csv_data ['prepend'];
1295
+				$csv_data ['comment'] = ($this->input->post("comment-select")) ? $csv_data [$this->input->post("comment-select")] : "";
1296
+				$csv_data ['comment'] = ($this->input->post("comment-prefix")) ? $this->input->post("comment-prefix").$csv_data ['comment'] : $csv_data ['comment'];
1297
+				$csv_data ['connectcost'] = ($this->input->post("connectcost-select")) ? $csv_data [$this->input->post("connectcost-select")] : "0";
1298
+				$csv_data ['connectcost'] = ($this->input->post("connectcost-prefix")) ? $this->input->post("connectcost-prefix").$csv_data ['connectcost'] : $csv_data ['connectcost'];
1299
+				$csv_data ['includedseconds'] = ($this->input->post("includedseconds-select")) ? $csv_data [$this->input->post("includedseconds-select")] : "0";
1300
+				$csv_data ['includedseconds'] = ($this->input->post("includedseconds-prefix")) ? $this->input->post("includedseconds-prefix").$csv_data ['includedseconds'] : $csv_data ['includedseconds'];
1301
+				$csv_data ['inc'] = ($this->input->post("inc-select")) ? $csv_data [$this->input->post("inc-select")] : "0";
1302
+				$csv_data ['inc'] = ($this->input->post("inc-prefix")) ? $this->input->post("inc-prefix").$csv_data ['inc'] : $csv_data ['inc'];
1303
+				$csv_data ['precedence'] = ($this->input->post("precedence-select")) ? $csv_data [$this->input->post("precedence-select")] : "";
1304
+				$csv_data ['precedence'] = ($this->input->post("precedence-prefix")) ? $this->input->post("precedence-prefix").$csv_data ['precedence'] : $csv_data ['precedence'];
1305
+				$csv_data ['strip'] = ($this->input->post("strip-select")) ? $csv_data [$this->input->post("strip-select")] : "";
1306
+				$csv_data ['strip'] = ($this->input->post("strip-prefix")) ? $this->input->post("strip-prefix").$csv_data ['strip'] : $csv_data ['strip'];
1307
+				$csv_data ['last_modified_date'] = date("Y-m-d H:i:s");
1308
+				$str = $this->data_validate($csv_data);
1309 1309
 				if ($str != "") {
1310 1310
 					$invalid_array [$i] = $csv_data;
1311 1311
 					$invalid_array [$i] ['error'] = $str;
1312 1312
 				} else {
1313 1313
 					$new_final_arr [$i] ['trunk_id'] = $trunkID;
1314
-					$new_final_arr [$i] ['pattern'] = "^" . $csv_data ['pattern'] . ".*";
1314
+					$new_final_arr [$i] ['pattern'] = "^".$csv_data ['pattern'].".*";
1315 1315
 					$new_final_arr [$i] ['prepend'] = $csv_data ['prepend'];
1316 1316
 					$new_final_arr [$i] ['last_modified_date'] = $csv_data ['last_modified_date'];
1317 1317
 					$new_final_arr [$i] ['comment'] = $csv_data ['comment'];
1318 1318
 					$new_final_arr [$i] ['connectcost'] = $csv_data ['connectcost'];
1319 1319
 					$new_final_arr [$i] ['includedseconds'] = $csv_data ['includedseconds'];
1320
-					$new_final_arr [$i] ['cost'] = ! empty ( $csv_data ['cost'] ) && is_numeric ( $csv_data ['cost'] ) ? $csv_data ['cost'] : 0;
1321
-					$new_final_arr [$i] ['inc'] = isset ( $csv_data ['inc'] ) ? $csv_data ['inc'] : 0;
1322
-					$new_final_arr [$i] ['precedence'] = isset ( $csv_data ['precedence'] ) ? $csv_data ['precedence'] : '';
1323
-					$new_final_arr [$i] ['strip'] = isset ( $csv_data ['strip'] ) ? $csv_data ['strip'] : '';
1320
+					$new_final_arr [$i] ['cost'] = ! empty ($csv_data ['cost']) && is_numeric($csv_data ['cost']) ? $csv_data ['cost'] : 0;
1321
+					$new_final_arr [$i] ['inc'] = isset ($csv_data ['inc']) ? $csv_data ['inc'] : 0;
1322
+					$new_final_arr [$i] ['precedence'] = isset ($csv_data ['precedence']) ? $csv_data ['precedence'] : '';
1323
+					$new_final_arr [$i] ['strip'] = isset ($csv_data ['strip']) ? $csv_data ['strip'] : '';
1324 1324
 				}
1325 1325
 			}
1326 1326
 			
1327
-			$i ++;
1327
+			$i++;
1328 1328
 		}
1329 1329
 		// print_r($new_final_arr);exit;
1330
-		if (! empty ( $new_final_arr )) {
1331
-			$result = $this->rates_model->bulk_insert_termination_rate ( $new_final_arr );
1330
+		if ( ! empty ($new_final_arr)) {
1331
+			$result = $this->rates_model->bulk_insert_termination_rate($new_final_arr);
1332 1332
 		} else {
1333 1333
 			
1334
-			$this->session->set_flashdata ( 'astpp_errormsg', 'Error - Nothing selected to import/process!' );
1335
-			redirect ( base_url () . 'rates/termination_rates_list/' );
1334
+			$this->session->set_flashdata('astpp_errormsg', 'Error - Nothing selected to import/process!');
1335
+			redirect(base_url().'rates/termination_rates_list/');
1336 1336
 		}
1337 1337
 		
1338
-		unlink ( $full_path . $terminationrate_file_name );
1339
-		$count = count ( $invalid_array );
1338
+		unlink($full_path.$terminationrate_file_name);
1339
+		$count = count($invalid_array);
1340 1340
 		
1341 1341
 		if ($count > 0) {
1342 1342
 			$session_id = "-1";
1343
-			$fp = fopen ( $full_path . $session_id . '.csv', 'w' );
1344
-			foreach ( $new_final_arr_key as $key => $value ) {
1345
-				$custom_array [0] [$key] = ucfirst ( $key );
1343
+			$fp = fopen($full_path.$session_id.'.csv', 'w');
1344
+			foreach ($new_final_arr_key as $key => $value) {
1345
+				$custom_array [0] [$key] = ucfirst($key);
1346 1346
 			}
1347 1347
 			
1348 1348
 			$custom_array [0] ['error'] = "Error";
1349
-			$invalid_array = array_merge ( $custom_array, $invalid_array );
1350
-			foreach ( $invalid_array as $err_data ) {
1351
-				fputcsv ( $fp, $err_data );
1349
+			$invalid_array = array_merge($custom_array, $invalid_array);
1350
+			foreach ($invalid_array as $err_data) {
1351
+				fputcsv($fp, $err_data);
1352 1352
 			}
1353 1353
 			
1354
-			fclose ( $fp );
1355
-			$this->session->set_userdata ( 'import_termination_rate_mapper_csv_error', $session_id . ".csv" );
1354
+			fclose($fp);
1355
+			$this->session->set_userdata('import_termination_rate_mapper_csv_error', $session_id.".csv");
1356 1356
 			$data ["error"] = $invalid_array;
1357 1357
 			$data ['trunkid'] = $trunkID;
1358
-			$data ['impoted_count'] = count ( $new_final_arr );
1359
-			$data ['failure_count'] = count ( $invalid_array ) - 1;
1360
-			$data ['page_title'] = gettext ( 'Termination Rates Import Error' );
1361
-			$this->load->view ( 'view_import_error', $data );
1358
+			$data ['impoted_count'] = count($new_final_arr);
1359
+			$data ['failure_count'] = count($invalid_array) - 1;
1360
+			$data ['page_title'] = gettext('Termination Rates Import Error');
1361
+			$this->load->view('view_import_error', $data);
1362 1362
 		} else {
1363
-			$this->session->set_flashdata ( 'astpp_errormsg', 'Total ' . count ( $new_final_arr ) . ' Termination rates imported successfully!' );
1363
+			$this->session->set_flashdata('astpp_errormsg', 'Total '.count($new_final_arr).' Termination rates imported successfully!');
1364 1364
 			
1365
-			redirect ( base_url () . "rates/termination_rates_list/" );
1365
+			redirect(base_url()."rates/termination_rates_list/");
1366 1366
 		}
1367 1367
 	}
1368 1368
 	function termination_rate_mapper_error_download() {
1369
-		$this->load->helper ( 'download' );
1370
-		$error_data = $this->session->userdata ( 'import_termination_rate_mapper_csv_error' );
1369
+		$this->load->helper('download');
1370
+		$error_data = $this->session->userdata('import_termination_rate_mapper_csv_error');
1371 1371
 		
1372
-		$full_path = $this->config->item ( 'rates-file-path' );
1373
-		$data = file_get_contents ( $full_path . $error_data );
1374
-		force_download ( "Termination_rate_mapper_error.csv", $data );
1372
+		$full_path = $this->config->item('rates-file-path');
1373
+		$data = file_get_contents($full_path.$error_data);
1374
+		force_download("Termination_rate_mapper_error.csv", $data);
1375 1375
 	}
1376 1376
 /**
1377 1377
  * **********************
Please login to merge, or discard this patch.
Braces   +17 added lines, -12 removed lines patch added patch discarded remove patch
@@ -33,8 +33,9 @@  discard block
 block discarded – undo
33 33
 		$this->load->library ( 'csvreader' );
34 34
 		ini_set ( "memory_limit", "2048M" );
35 35
 		ini_set ( "max_execution_time", "259200" );
36
-		if ($this->session->userdata ( 'user_login' ) == FALSE)
37
-			redirect ( base_url () . '/astpp/login' );
36
+		if ($this->session->userdata ( 'user_login' ) == FALSE) {
37
+					redirect ( base_url () . '/astpp/login' );
38
+		}
38 39
 	}
39 40
 	function termination_rates_list() {
40 41
 		$data ['username'] = $this->session->userdata ( 'user_name' );
@@ -629,13 +630,15 @@  discard block
 block discarded – undo
629 630
 		);
630 631
 		$instant_search = $this->session->userdata ( 'left_panel_search_' . $accounttype . '_pattern' );
631 632
 		$like_str = ! empty ( $instant_search ) ? "(blocked_patterns like '%$instant_search%'  OR  destination like '%$instant_search%' )" : null;
632
-		if (! empty ( $like_str ))
633
-			$this->db->where ( $like_str );
633
+		if (! empty ( $like_str )) {
634
+					$this->db->where ( $like_str );
635
+		}
634 636
 		$count_all = $this->db_model->countQuery ( "*", "block_patterns", $where );
635 637
 		$paging_data = $this->form->load_grid_config ( $count_all, $_GET ['rp'], $_GET ['page'] );
636 638
 		$json_data = $paging_data ["json_paging"];
637
-		if (! empty ( $like_str ))
638
-			$this->db->where ( $like_str );
639
+		if (! empty ( $like_str )) {
640
+					$this->db->where ( $like_str );
641
+		}
639 642
 		$pattern_data = $this->db_model->getSelect ( "*", "block_patterns", $where, "id", "ASC", $paging_data ["paging"] ["page_no"], $paging_data ["paging"] ["start"] );
640 643
 		$grid_fields = json_decode ( $this->rates_form->build_pattern_list_for_customer ( $accountid, $accounttype ) );
641 644
 		$json_data ['rows'] = $this->form->build_grid ( $pattern_data, $grid_fields );
@@ -1162,17 +1165,19 @@  discard block
 block discarded – undo
1162 1165
 		$this->load->view ( 'view_import_termination_rate_mapper', $data );
1163 1166
 	}
1164 1167
 	function csv_to_array($filename = '', $delimiter = ',') {
1165
-		if (! file_exists ( $filename ) || ! is_readable ( $filename ))
1166
-			return FALSE;
1168
+		if (! file_exists ( $filename ) || ! is_readable ( $filename )) {
1169
+					return FALSE;
1170
+		}
1167 1171
 		$header = NULL;
1168 1172
 		$data = array ();
1169 1173
 		if (($handle = fopen ( $filename, 'r' )) !== FALSE) {
1170 1174
 			while ( ($row = fgetcsv ( $handle, 1000, $delimiter )) !== FALSE ) {
1171 1175
 				
1172
-				if (! $header)
1173
-					$header = $row;
1174
-				else
1175
-					$data [] = array_combine ( $header, $row );
1176
+				if (! $header) {
1177
+									$header = $row;
1178
+				} else {
1179
+									$data [] = array_combine ( $header, $row );
1180
+				}
1176 1181
 			}
1177 1182
 			
1178 1183
 			fclose ( $handle );
Please login to merge, or discard this patch.
web_interface/astpp/application/modules/rates/libraries/rates_form.php 2 patches
Spacing   +418 added lines, -418 removed lines patch added patch discarded remove patch
@@ -20,26 +20,26 @@  discard block
 block discarded – undo
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
 class rates_form {
26 26
 	function __construct($library_name = '') {
27
-		$this->CI = & get_instance ();
27
+		$this->CI = & get_instance();
28 28
 	}
29 29
 	function get_termination_rate_form_fields() {
30
-		$form ['forms'] = array (
31
-				base_url () . 'rates/termination_rate_save/',
32
-				array (
30
+		$form ['forms'] = array(
31
+				base_url().'rates/termination_rate_save/',
32
+				array(
33 33
 						'id' => 'termination_rate_form',
34 34
 						'method' => 'POST',
35 35
 						'name' => 'termination_rate_form' 
36 36
 				) 
37 37
 		);
38
-		$form [gettext ( 'Rate Information' )] = array (
39
-				array (
38
+		$form [gettext('Rate Information')] = array(
39
+				array(
40 40
 						'',
41 41
 						'HIDDEN',
42
-						array (
42
+						array(
43 43
 								'name' => 'id' 
44 44
 						),
45 45
 						'',
@@ -47,8 +47,8 @@  discard block
 block discarded – undo
47 47
 						'',
48 48
 						'' 
49 49
 				),
50
-				array (
51
-						gettext ( 'Trunk' ),
50
+				array(
51
+						gettext('Trunk'),
52 52
 						'trunk_id',
53 53
 						'SELECT',
54 54
 						'',
@@ -60,14 +60,14 @@  discard block
 block discarded – undo
60 60
 						'trunks',
61 61
 						'build_dropdown',
62 62
 						'where_arr',
63
-						array (
63
+						array(
64 64
 								"status" => "0" 
65 65
 						) 
66 66
 				),
67
-				array (
68
-						gettext ( 'Code' ),
67
+				array(
68
+						gettext('Code'),
69 69
 						'INPUT',
70
-						array (
70
+						array(
71 71
 								'name' => 'pattern',
72 72
 								'size' => '20',
73 73
 								'class' => "text field medium" 
@@ -76,10 +76,10 @@  discard block
 block discarded – undo
76 76
 						'tOOL TIP',
77 77
 						'' 
78 78
 				),
79
-				array (
80
-						gettext ( 'Destination' ),
79
+				array(
80
+						gettext('Destination'),
81 81
 						'INPUT',
82
-						array (
82
+						array(
83 83
 								'name' => 'comment',
84 84
 								'size' => '20',
85 85
 								'class' => "text field medium" 
@@ -87,10 +87,10 @@  discard block
 block discarded – undo
87 87
 						'tOOL TIP',
88 88
 						'' 
89 89
 				),
90
-				array (
91
-						gettext ( 'Strip' ),
90
+				array(
91
+						gettext('Strip'),
92 92
 						'INPUT',
93
-						array (
93
+						array(
94 94
 								'name' => 'strip',
95 95
 								'size' => '20',
96 96
 								'class' => "text field medium" 
@@ -99,10 +99,10 @@  discard block
 block discarded – undo
99 99
 						'tOOL TIP',
100 100
 						'' 
101 101
 				),
102
-				array (
103
-						gettext ( 'Prepend' ),
102
+				array(
103
+						gettext('Prepend'),
104 104
 						'INPUT',
105
-						array (
105
+						array(
106 106
 								'name' => 'prepend',
107 107
 								'size' => '20',
108 108
 								'class' => "text field medium" 
@@ -111,8 +111,8 @@  discard block
 block discarded – undo
111 111
 						'tOOL TIP',
112 112
 						'' 
113 113
 				),
114
-				array (
115
-						gettext ( 'Status' ),
114
+				array(
115
+						gettext('Status'),
116 116
 						'status',
117 117
 						'SELECT',
118 118
 						'',
@@ -126,11 +126,11 @@  discard block
 block discarded – undo
126 126
 				) 
127 127
 		)
128 128
 		;
129
-		$form [gettext ( 'Billing Information' )] = array (
130
-				array (
131
-						gettext ( 'Connect Cost' ),
129
+		$form [gettext('Billing Information')] = array(
130
+				array(
131
+						gettext('Connect Cost'),
132 132
 						'INPUT',
133
-						array (
133
+						array(
134 134
 								'name' => 'connectcost',
135 135
 								'size' => '20',
136 136
 								'class' => "text field medium" 
@@ -139,10 +139,10 @@  discard block
 block discarded – undo
139 139
 						'tOOL TIP',
140 140
 						'' 
141 141
 				),
142
-				array (
143
-						gettext ( 'Included Seconds' ),
142
+				array(
143
+						gettext('Included Seconds'),
144 144
 						'INPUT',
145
-						array (
145
+						array(
146 146
 								'name' => 'includedseconds',
147 147
 								'size' => '20',
148 148
 								'class' => "text field medium" 
@@ -151,10 +151,10 @@  discard block
 block discarded – undo
151 151
 						'tOOL TIP',
152 152
 						'' 
153 153
 				),
154
-				array (
155
-						gettext ( 'Per Minute Cost' ),
154
+				array(
155
+						gettext('Per Minute Cost'),
156 156
 						'INPUT',
157
-						array (
157
+						array(
158 158
 								'name' => 'cost',
159 159
 								'size' => '20',
160 160
 								'class' => "text field medium" 
@@ -168,10 +168,10 @@  discard block
 block discarded – undo
168 168
 				 * For Add Initial Increment field
169 169
 				 * *
170 170
 				 */
171
-				array (
172
-						gettext ( 'Initial Increment' ),
171
+				array(
172
+						gettext('Initial Increment'),
173 173
 						'INPUT',
174
-						array (
174
+						array(
175 175
 								'name' => 'init_inc',
176 176
 								'size' => '20',
177 177
 								'class' => "text field medium" 
@@ -183,10 +183,10 @@  discard block
 block discarded – undo
183 183
 				/**
184 184
 				 * ****************************************************
185 185
 				 */
186
-				array (
187
-						gettext ( 'Increment' ),
186
+				array(
187
+						gettext('Increment'),
188 188
 						'INPUT',
189
-						array (
189
+						array(
190 190
 								'name' => 'inc',
191 191
 								'size' => '20',
192 192
 								'class' => "text field medium" 
@@ -195,10 +195,10 @@  discard block
 block discarded – undo
195 195
 						'tOOL TIP',
196 196
 						'' 
197 197
 				),
198
-				array (
199
-						gettext ( 'Priority' ),
198
+				array(
199
+						gettext('Priority'),
200 200
 						'INPUT',
201
-						array (
201
+						array(
202 202
 								'name' => 'precedence',
203 203
 								'size' => '20',
204 204
 								'class' => "text field medium" 
@@ -209,17 +209,17 @@  discard block
 block discarded – undo
209 209
 				) 
210 210
 		);
211 211
 		
212
-		$form ['button_cancel'] = array (
212
+		$form ['button_cancel'] = array(
213 213
 				'name' => 'action',
214
-				'content' => gettext ( 'Close' ),
214
+				'content' => gettext('Close'),
215 215
 				'value' => 'cancel',
216 216
 				'type' => 'button',
217 217
 				'class' => 'btn btn-line-sky margin-x-10',
218 218
 				'onclick' => 'return redirect_page(\'NULL\')' 
219 219
 		);
220
-		$form ['button_save'] = array (
220
+		$form ['button_save'] = array(
221 221
 				'name' => 'action',
222
-				'content' => gettext ( 'Save' ),
222
+				'content' => gettext('Save'),
223 223
 				'value' => 'save',
224 224
 				'id' => 'submit',
225 225
 				'type' => 'button',
@@ -229,10 +229,10 @@  discard block
 block discarded – undo
229 229
 		return $form;
230 230
 	}
231 231
 	function get_origination_rate_form_fields() {
232
-		$logintype = $this->CI->session->userdata ( 'userlevel_logintype' );
232
+		$logintype = $this->CI->session->userdata('userlevel_logintype');
233 233
 		$trunk = null;
234 234
 		if ($logintype != 1)
235
-			$trunk = array (
235
+			$trunk = array(
236 236
 					'Force Trunk',
237 237
 					'trunk_id',
238 238
 					'SELECT',
@@ -245,23 +245,23 @@  discard block
 block discarded – undo
245 245
 					'trunks',
246 246
 					'build_dropdown',
247 247
 					'where_arr',
248
-					array (
248
+					array(
249 249
 							"status" => "0" 
250 250
 					) 
251 251
 			);
252
-		$form ['forms'] = array (
253
-				base_url () . 'rates/origination_rate_save/',
254
-				array (
252
+		$form ['forms'] = array(
253
+				base_url().'rates/origination_rate_save/',
254
+				array(
255 255
 						'id' => 'origination_rate_form',
256 256
 						'method' => 'POST',
257 257
 						'name' => 'origination_rate_form' 
258 258
 				) 
259 259
 		);
260
-		$form [gettext ( 'Rate Information' )] = array (
261
-				array (
260
+		$form [gettext('Rate Information')] = array(
261
+				array(
262 262
 						'',
263 263
 						'HIDDEN',
264
-						array (
264
+						array(
265 265
 								'name' => 'id' 
266 266
 						),
267 267
 						'',
@@ -269,8 +269,8 @@  discard block
 block discarded – undo
269 269
 						'',
270 270
 						'' 
271 271
 				),
272
-				array (
273
-						gettext ( 'Rate Group' ),
272
+				array(
273
+						gettext('Rate Group'),
274 274
 						'pricelist_id',
275 275
 						'SELECT',
276 276
 						'',
@@ -282,15 +282,15 @@  discard block
 block discarded – undo
282 282
 						'pricelists',
283 283
 						'build_dropdown',
284 284
 						'where_arr',
285
-						array (
285
+						array(
286 286
 								"status" => "0",
287 287
 								'reseller_id' => 0 
288 288
 						) 
289 289
 				),
290
-				array (
291
-						gettext ( 'Code' ),
290
+				array(
291
+						gettext('Code'),
292 292
 						'INPUT',
293
-						array (
293
+						array(
294 294
 								'name' => 'pattern',
295 295
 								'size' => '20',
296 296
 								'class' => "text field medium" 
@@ -299,10 +299,10 @@  discard block
 block discarded – undo
299 299
 						'tOOL TIP',
300 300
 						'' 
301 301
 				),
302
-				array (
303
-						gettext ( 'Destination' ),
302
+				array(
303
+						gettext('Destination'),
304 304
 						'INPUT',
305
-						array (
305
+						array(
306 306
 								'name' => 'comment',
307 307
 								'size' => '20',
308 308
 								'class' => "text field medium" 
@@ -311,8 +311,8 @@  discard block
 block discarded – undo
311 311
 						'' 
312 312
 				),
313 313
 				// array('Priority', 'INPUT', array('name' => 'precedence', 'size' => '20', 'class' => "text field medium"), 'trim|numeric|xss_clean', 'tOOL TIP', ''),
314
-				array (
315
-						gettext ( 'Status' ),
314
+				array(
315
+						gettext('Status'),
316 316
 						'status',
317 317
 						'SELECT',
318 318
 						'',
@@ -326,11 +326,11 @@  discard block
 block discarded – undo
326 326
 				) 
327 327
 		)
328 328
 		;
329
-		$form [gettext ( 'Billing Information' )] = array (
330
-				array (
331
-						gettext ( 'Connect Cost' ),
329
+		$form [gettext('Billing Information')] = array(
330
+				array(
331
+						gettext('Connect Cost'),
332 332
 						'INPUT',
333
-						array (
333
+						array(
334 334
 								'name' => 'connectcost',
335 335
 								'size' => '20',
336 336
 								'class' => "text field medium" 
@@ -339,10 +339,10 @@  discard block
 block discarded – undo
339 339
 						'tOOL TIP',
340 340
 						'' 
341 341
 				),
342
-				array (
343
-						gettext ( 'Included Seconds' ),
342
+				array(
343
+						gettext('Included Seconds'),
344 344
 						'INPUT',
345
-						array (
345
+						array(
346 346
 								'name' => 'includedseconds',
347 347
 								'size' => '20',
348 348
 								'class' => "text field medium" 
@@ -351,10 +351,10 @@  discard block
 block discarded – undo
351 351
 						'tOOL TIP',
352 352
 						'' 
353 353
 				),
354
-				array (
355
-						gettext ( 'Per Minute Cost' ),
354
+				array(
355
+						gettext('Per Minute Cost'),
356 356
 						'INPUT',
357
-						array (
357
+						array(
358 358
 								'name' => 'cost',
359 359
 								'size' => '20',
360 360
 								'class' => "text field medium" 
@@ -368,10 +368,10 @@  discard block
 block discarded – undo
368 368
 				 * For Add Initial Increment field
369 369
 				 * *
370 370
 				 */
371
-				array (
372
-						gettext ( 'Initial Increment' ),
371
+				array(
372
+						gettext('Initial Increment'),
373 373
 						'INPUT',
374
-						array (
374
+						array(
375 375
 								'name' => 'init_inc',
376 376
 								'size' => '20',
377 377
 								'class' => "text field medium" 
@@ -383,10 +383,10 @@  discard block
 block discarded – undo
383 383
 				/**
384 384
 				 * *****************************************************************
385 385
 				 */
386
-				array (
387
-						gettext ( 'Increment' ),
386
+				array(
387
+						gettext('Increment'),
388 388
 						'INPUT',
389
-						array (
389
+						array(
390 390
 								'name' => 'inc',
391 391
 								'size' => '20',
392 392
 								'class' => "text field medium" 
@@ -398,17 +398,17 @@  discard block
 block discarded – undo
398 398
 				 $trunk,
399 399
 		);
400 400
 		
401
-		$form ['button_cancel'] = array (
401
+		$form ['button_cancel'] = array(
402 402
 				'name' => 'action',
403
-				'content' => gettext ( 'Close' ),
403
+				'content' => gettext('Close'),
404 404
 				'value' => 'cancel',
405 405
 				'type' => 'button',
406 406
 				'class' => 'btn btn-line-sky margin-x-10',
407 407
 				'onclick' => 'return redirect_page(\'NULL\')' 
408 408
 		);
409
-		$form ['button_save'] = array (
409
+		$form ['button_save'] = array(
410 410
 				'name' => 'action',
411
-				'content' => gettext ( 'Save' ),
411
+				'content' => gettext('Save'),
412 412
 				'value' => 'save',
413 413
 				'id' => 'submit',
414 414
 				'type' => 'button',
@@ -418,18 +418,18 @@  discard block
 block discarded – undo
418 418
 		return $form;
419 419
 	}
420 420
 	function get_termination_rate_search_form() {
421
-		$form ['forms'] = array (
421
+		$form ['forms'] = array(
422 422
 				"",
423
-				array (
423
+				array(
424 424
 						'id' => "termination_rate_search" 
425 425
 				) 
426 426
 		);
427
-		$form [gettext ( 'Search' )] = array (
427
+		$form [gettext('Search')] = array(
428 428
 				
429
-				array (
430
-						gettext ( 'Code' ),
429
+				array(
430
+						gettext('Code'),
431 431
 						'INPUT',
432
-						array (
432
+						array(
433 433
 								'name' => 'pattern[pattern]',
434 434
 								'',
435 435
 								'size' => '20',
@@ -445,10 +445,10 @@  discard block
 block discarded – undo
445 445
 						'search_string_type',
446 446
 						'' 
447 447
 				),
448
-				array (
449
-						gettext ( 'Destination' ),
448
+				array(
449
+						gettext('Destination'),
450 450
 						'INPUT',
451
-						array (
451
+						array(
452 452
 								'name' => 'comment[comment]',
453 453
 								'',
454 454
 								'size' => '20',
@@ -464,10 +464,10 @@  discard block
 block discarded – undo
464 464
 						'search_string_type',
465 465
 						'' 
466 466
 				),
467
-				array (
468
-						gettext ( 'Connect Cost' ),
467
+				array(
468
+						gettext('Connect Cost'),
469 469
 						'INPUT',
470
-						array (
470
+						array(
471 471
 								'name' => 'connectcost[connectcost]',
472 472
 								'value' => '',
473 473
 								'size' => '20',
@@ -483,10 +483,10 @@  discard block
 block discarded – undo
483 483
 						'search_int_type',
484 484
 						'' 
485 485
 				),
486
-				array (
487
-						gettext ( 'Included Seconds' ),
486
+				array(
487
+						gettext('Included Seconds'),
488 488
 						'INPUT',
489
-						array (
489
+						array(
490 490
 								'name' => 'includedseconds[includedseconds]',
491 491
 								'value' => '',
492 492
 								'size' => '20',
@@ -502,10 +502,10 @@  discard block
 block discarded – undo
502 502
 						'search_int_type',
503 503
 						'' 
504 504
 				),
505
-				array (
506
-						gettext ( 'Per Minute Cost' ),
505
+				array(
506
+						gettext('Per Minute Cost'),
507 507
 						'INPUT',
508
-						array (
508
+						array(
509 509
 								'name' => 'cost[cost]',
510 510
 								'value' => '',
511 511
 								'size' => '20',
@@ -526,10 +526,10 @@  discard block
 block discarded – undo
526 526
 				 * For Add Initial Increment field
527 527
 				 * *
528 528
 				 */
529
-				array (
530
-						gettext ( 'Initial Increment' ),
529
+				array(
530
+						gettext('Initial Increment'),
531 531
 						'INPUT',
532
-						array (
532
+						array(
533 533
 								'name' => 'init_inc[init_inc]',
534 534
 								'',
535 535
 								'size' => '20',
@@ -548,10 +548,10 @@  discard block
 block discarded – undo
548 548
 				/**
549 549
 				 * ************************************************************
550 550
 				 */
551
-				array (
552
-						gettext ( 'Increment' ),
551
+				array(
552
+						gettext('Increment'),
553 553
 						'INPUT',
554
-						array (
554
+						array(
555 555
 								'name' => 'inc[inc]',
556 556
 								'',
557 557
 								'size' => '20',
@@ -567,10 +567,10 @@  discard block
 block discarded – undo
567 567
 						'search_int_type',
568 568
 						'' 
569 569
 				),
570
-				array (
571
-						gettext ( 'Priority' ),
570
+				array(
571
+						gettext('Priority'),
572 572
 						'INPUT',
573
-						array (
573
+						array(
574 574
 								'name' => 'prepend[prepend]',
575 575
 								'',
576 576
 								'size' => '20',
@@ -586,8 +586,8 @@  discard block
 block discarded – undo
586 586
 						'search_string_type',
587 587
 						'' 
588 588
 				),
589
-				array (
590
-						gettext ( 'Trunk' ),
589
+				array(
590
+						gettext('Trunk'),
591 591
 						'trunk_id',
592 592
 						'SELECT',
593 593
 						'',
@@ -599,12 +599,12 @@  discard block
 block discarded – undo
599 599
 						'trunks',
600 600
 						'build_dropdown',
601 601
 						'where_arr',
602
-						array (
602
+						array(
603 603
 								"status" => "0" 
604 604
 						) 
605 605
 				),				
606
-				array (
607
-						gettext ( 'Status' ),
606
+				array(
607
+						gettext('Status'),
608 608
 						'status',
609 609
 						'SELECT',
610 610
 						'',
@@ -624,7 +624,7 @@  discard block
 block discarded – undo
624 624
 				 * Batch Delete
625 625
 				 * *****
626 626
 				 */
627
-				array (
627
+				array(
628 628
 						'',
629 629
 						'HIDDEN',
630 630
 						'ajax_search',
@@ -636,7 +636,7 @@  discard block
 block discarded – undo
636 636
 				/**
637 637
 				 * *********************
638 638
 				 */
639
-				array (
639
+				array(
640 640
 						'',
641 641
 						'HIDDEN',
642 642
 						'advance_search',
@@ -653,11 +653,11 @@  discard block
 block discarded – undo
653 653
 		 * Batch Delete
654 654
 		 * *****
655 655
 		 */
656
-		$form ['button_search_delete'] = array (
656
+		$form ['button_search_delete'] = array(
657 657
 				'name' => 'action',
658 658
 				'id' => "termination_rate_batch_dlt",
659 659
 				'onclick' => "check_btn();",
660
-				'content' => gettext ( 'Delete Search Record' ),
660
+				'content' => gettext('Delete Search Record'),
661 661
 				'style' => 'display:none;',
662 662
 				'value' => 'submit',
663 663
 				'type' => 'button',
@@ -673,11 +673,11 @@  discard block
 block discarded – undo
673 673
 		 * Batch Delete
674 674
 		 * *****
675 675
 		 */
676
-		$form ['button_search'] = array (
676
+		$form ['button_search'] = array(
677 677
 				'name' => 'action',
678 678
 				'id' => "termination_rate_search_btn",
679 679
 				'onclick' => 'search_btn();',
680
-				'content' => gettext ( 'Search' ),
680
+				'content' => gettext('Search'),
681 681
 				'value' => 'save',
682 682
 				'type' => 'button',
683 683
 				'class' => 'btn btn-line-parrot pull-right margin-x-10' 
@@ -685,10 +685,10 @@  discard block
 block discarded – undo
685 685
 		/**
686 686
 		 * ********************
687 687
 		 */
688
-		$form ['button_reset'] = array (
688
+		$form ['button_reset'] = array(
689 689
 				'name' => 'action',
690 690
 				'id' => "id_reset",
691
-				'content' => gettext ( 'Clear' ),
691
+				'content' => gettext('Clear'),
692 692
 				'value' => 'cancel',
693 693
 				'type' => 'reset',
694 694
 				'class' => 'btn btn-line-sky pull-right margin-x-10' 
@@ -697,17 +697,17 @@  discard block
 block discarded – undo
697 697
 		return $form;
698 698
 	}
699 699
 	function termination_rate_batch_update_form() {
700
-		$form ['forms'] = array (
700
+		$form ['forms'] = array(
701 701
 				"rates/termination_rate_batch_update/",
702
-				array (
702
+				array(
703 703
 						'id' => "termination_rate_batch_update" 
704 704
 				) 
705 705
 		);
706
-		$form ['Batch Update'] = array (
707
-				array (
708
-						gettext ( 'Connect Cost' ),
706
+		$form ['Batch Update'] = array(
707
+				array(
708
+						gettext('Connect Cost'),
709 709
 						'INPUT',
710
-						array (
710
+						array(
711 711
 								'name' => 'connectcost[connectcost]',
712 712
 								'id' => 'connectcost',
713 713
 								'value' => '',
@@ -717,7 +717,7 @@  discard block
 block discarded – undo
717 717
 						'',
718 718
 						'Tool tips info',
719 719
 						'1',
720
-						array (
720
+						array(
721 721
 								'name' => 'connectcost[operator]',
722 722
 								'class' => 'update_drp' 
723 723
 						),
@@ -727,10 +727,10 @@  discard block
 block discarded – undo
727 727
 						'update_int_type',
728 728
 						'' 
729 729
 				),
730
-				array (
731
-						gettext ( 'Included Seconds' ),
730
+				array(
731
+						gettext('Included Seconds'),
732 732
 						'INPUT',
733
-						array (
733
+						array(
734 734
 								'name' => 'includedseconds[includedseconds]',
735 735
 								'id' => 'includedseconds',
736 736
 								'value' => '',
@@ -740,7 +740,7 @@  discard block
 block discarded – undo
740 740
 						'',
741 741
 						'Tool tips info',
742 742
 						'1',
743
-						array (
743
+						array(
744 744
 								'name' => 'includedseconds[operator]',
745 745
 								'class' => 'update_drp' 
746 746
 						),
@@ -750,10 +750,10 @@  discard block
 block discarded – undo
750 750
 						'update_int_type',
751 751
 						'' 
752 752
 				),
753
-				array (
754
-						gettext ( 'Per Minute Cost' ),
753
+				array(
754
+						gettext('Per Minute Cost'),
755 755
 						'INPUT',
756
-						array (
756
+						array(
757 757
 								'name' => 'cost[cost]',
758 758
 								'id' => 'cost',
759 759
 								'value' => '',
@@ -763,7 +763,7 @@  discard block
 block discarded – undo
763 763
 						'',
764 764
 						'Tool tips info',
765 765
 						'1',
766
-						array (
766
+						array(
767 767
 								'name' => 'cost[operator]',
768 768
 								'class' => 'update_drp' 
769 769
 						),
@@ -774,10 +774,10 @@  discard block
 block discarded – undo
774 774
 						'' 
775 775
 				),
776 776
 				
777
-				array (
778
-						gettext ( 'Increment' ),
777
+				array(
778
+						gettext('Increment'),
779 779
 						'INPUT',
780
-						array (
780
+						array(
781 781
 								'name' => 'inc[inc]',
782 782
 								'id' => 'inc',
783 783
 								'size' => '20',
@@ -786,7 +786,7 @@  discard block
 block discarded – undo
786 786
 						'',
787 787
 						'tOOL TIP',
788 788
 						'1',
789
-						array (
789
+						array(
790 790
 								'name' => 'inc[operator]',
791 791
 								'class' => 'update_drp' 
792 792
 						),
@@ -796,10 +796,10 @@  discard block
 block discarded – undo
796 796
 						'update_int_type',
797 797
 						'' 
798 798
 				),
799
-				array (
800
-						gettext ( 'Priority' ),
799
+				array(
800
+						gettext('Priority'),
801 801
 						'INPUT',
802
-						array (
802
+						array(
803 803
 								'name' => 'precedence[precedence]',
804 804
 								'id' => 'precedence',
805 805
 								'size' => '20',
@@ -808,7 +808,7 @@  discard block
 block discarded – undo
808 808
 						'',
809 809
 						'tOOL TIP',
810 810
 						'1',
811
-						array (
811
+						array(
812 812
 								'name' => 'precedence[operator]',
813 813
 								'class' => 'update_drp' 
814 814
 						),
@@ -818,10 +818,10 @@  discard block
 block discarded – undo
818 818
 						'update_drp_type',
819 819
 						'' 
820 820
 				),
821
-				array (
822
-						gettext ( 'Prepand' ),
821
+				array(
822
+						gettext('Prepand'),
823 823
 						'INPUT',
824
-						array (
824
+						array(
825 825
 								'name' => 'prepend[prepend]',
826 826
 								'id' => 'prepend',
827 827
 								'size' => '20',
@@ -830,7 +830,7 @@  discard block
 block discarded – undo
830 830
 						'',
831 831
 						'tOOL TIP',
832 832
 						'1',
833
-						array (
833
+						array(
834 834
 								'name' => 'prepend[operator]',
835 835
 								'class' => 'update_drp' 
836 836
 						),
@@ -843,18 +843,18 @@  discard block
 block discarded – undo
843 843
 		)
844 844
 		;
845 845
 		
846
-		$form ['button_search'] = array (
846
+		$form ['button_search'] = array(
847 847
 				'name' => 'action',
848 848
 				'id' => "batch_update_btn",
849
-				'content' => gettext ( 'Update' ),
849
+				'content' => gettext('Update'),
850 850
 				'value' => 'save',
851 851
 				'type' => 'button',
852 852
 				'class' => 'btn btn-line-parrot pull-right' 
853 853
 		);
854
-		$form ['button_reset'] = array (
854
+		$form ['button_reset'] = array(
855 855
 				'name' => 'action',
856 856
 				'id' => "id_batch_reset",
857
-				'content' => gettext ( 'Clear' ),
857
+				'content' => gettext('Clear'),
858 858
 				'value' => 'cancel',
859 859
 				'type' => 'reset',
860 860
 				'class' => 'btn btn-line-sky pull-right margin-x-10' 
@@ -863,12 +863,12 @@  discard block
 block discarded – undo
863 863
 		return $form;
864 864
 	}
865 865
 	function origination_rate_batch_update_form() {
866
-		$logintype = $this->CI->session->userdata ( 'userlevel_logintype' );
866
+		$logintype = $this->CI->session->userdata('userlevel_logintype');
867 867
 		$trunk = null;
868 868
 		if ($logintype != 1)
869
-			$trunk = array (
869
+			$trunk = array(
870 870
 					'Force Trunk',
871
-					array (
871
+					array(
872 872
 							'name' => 'trunk_id[trunk_id]',
873 873
 							'id' => 'trunk_id' 
874 874
 					),
@@ -882,26 +882,26 @@  discard block
 block discarded – undo
882 882
 					'trunks',
883 883
 					'build_dropdown',
884 884
 					'where_arr',
885
-					array (
885
+					array(
886 886
 							"status" => "0" 
887 887
 					),
888
-					array (
888
+					array(
889 889
 							'name' => 'trunk_id[operator]',
890 890
 							'class' => 'update_drp' 
891 891
 					),
892 892
 					'update_drp_type' 
893 893
 			);
894
-		$form ['forms'] = array (
894
+		$form ['forms'] = array(
895 895
 				"rates/origination_rate_batch_update/",
896
-				array (
896
+				array(
897 897
 						'id' => "origination_rate_batch_update" 
898 898
 				) 
899 899
 		);
900
-		$form [gettext ( 'Batch Update' )] = array (
901
-				array (
902
-						gettext ( 'Connect Cost' ),
900
+		$form [gettext('Batch Update')] = array(
901
+				array(
902
+						gettext('Connect Cost'),
903 903
 						'INPUT',
904
-						array (
904
+						array(
905 905
 								'name' => 'connectcost[connectcost]',
906 906
 								'id' => 'connectcost',
907 907
 								'value' => '',
@@ -911,7 +911,7 @@  discard block
 block discarded – undo
911 911
 						'',
912 912
 						'Tool tips info',
913 913
 						'1',
914
-						array (
914
+						array(
915 915
 								'name' => 'connectcost[operator]',
916 916
 								'class' => 'update_drp' 
917 917
 						),
@@ -921,10 +921,10 @@  discard block
 block discarded – undo
921 921
 						'update_int_type',
922 922
 						'' 
923 923
 				),
924
-				array (
925
-						gettext ( 'Included Seconds' ),
924
+				array(
925
+						gettext('Included Seconds'),
926 926
 						'INPUT',
927
-						array (
927
+						array(
928 928
 								'name' => 'includedseconds[includedseconds]',
929 929
 								'id' => 'includedseconds',
930 930
 								'value' => '',
@@ -934,7 +934,7 @@  discard block
 block discarded – undo
934 934
 						'',
935 935
 						'Tool tips info',
936 936
 						'1',
937
-						array (
937
+						array(
938 938
 								'name' => 'includedseconds[operator]',
939 939
 								'class' => 'update_drp' 
940 940
 						),
@@ -944,10 +944,10 @@  discard block
 block discarded – undo
944 944
 						'update_int_type',
945 945
 						'' 
946 946
 				),
947
-				array (
948
-						gettext ( 'Per Minute Cost' ),
947
+				array(
948
+						gettext('Per Minute Cost'),
949 949
 						'INPUT',
950
-						array (
950
+						array(
951 951
 								'name' => 'cost[cost]',
952 952
 								'id' => 'cost',
953 953
 								'value' => '',
@@ -957,7 +957,7 @@  discard block
 block discarded – undo
957 957
 						'',
958 958
 						'Tool tips info',
959 959
 						'1',
960
-						array (
960
+						array(
961 961
 								'name' => 'cost[operator]',
962 962
 								'class' => 'update_drp' 
963 963
 						),
@@ -967,10 +967,10 @@  discard block
 block discarded – undo
967 967
 						'update_int_type',
968 968
 						'' 
969 969
 				),
970
-				array (
971
-						gettext ( 'Increment' ),
970
+				array(
971
+						gettext('Increment'),
972 972
 						'INPUT',
973
-						array (
973
+						array(
974 974
 								'name' => 'inc[inc]',
975 975
 								'id' => 'inc',
976 976
 								'size' => '20',
@@ -979,7 +979,7 @@  discard block
 block discarded – undo
979 979
 						'',
980 980
 						'tOOL TIP',
981 981
 						'1',
982
-						array (
982
+						array(
983 983
 								'name' => 'inc[operator]',
984 984
 								'class' => 'update_drp' 
985 985
 						),
@@ -993,18 +993,18 @@  discard block
 block discarded – undo
993 993
 				$trunk 
994 994
 		);
995 995
 		
996
-		$form ['button_search'] = array (
996
+		$form ['button_search'] = array(
997 997
 				'name' => 'action',
998 998
 				'id' => "batch_update",
999
-				'content' => gettext ( 'Update' ),
999
+				'content' => gettext('Update'),
1000 1000
 				'value' => 'save',
1001 1001
 				'type' => 'button',
1002 1002
 				'class' => 'btn btn-line-parrot pull-right' 
1003 1003
 		);
1004
-		$form ['button_reset'] = array (
1004
+		$form ['button_reset'] = array(
1005 1005
 				'name' => 'action',
1006 1006
 				'id' => "id_batch_reset",
1007
-				'content' => gettext ( 'Clear' ),
1007
+				'content' => gettext('Clear'),
1008 1008
 				'value' => 'cancel',
1009 1009
 				'type' => 'reset',
1010 1010
 				'class' => 'btn btn-line-sky pull-right margin-x-10' 
@@ -1013,13 +1013,13 @@  discard block
 block discarded – undo
1013 1013
 		return $form;
1014 1014
 	}
1015 1015
 	function build_rates_list_for_reseller() {
1016
-		$account_info = $accountinfo = $this->CI->session->userdata ( 'accountinfo' );
1016
+		$account_info = $accountinfo = $this->CI->session->userdata('accountinfo');
1017 1017
 		$currency_id = $account_info ['currency_id'];
1018
-		$currency = $this->CI->common->get_field_name ( 'currency', 'currency', $currency_id );
1018
+		$currency = $this->CI->common->get_field_name('currency', 'currency', $currency_id);
1019 1019
 		
1020
-		$grid_field_arr = json_encode ( array (
1021
-				array (
1022
-						gettext ( 'Code' ),
1020
+		$grid_field_arr = json_encode(array(
1021
+				array(
1022
+						gettext('Code'),
1023 1023
 						"140",
1024 1024
 						"pattern",
1025 1025
 						"pattern",
@@ -1029,16 +1029,16 @@  discard block
 block discarded – undo
1029 1029
 						"true",
1030 1030
 						"center" 
1031 1031
 				),
1032
-				array (
1033
-						gettext ( 'Destination' ),
1032
+				array(
1033
+						gettext('Destination'),
1034 1034
 						"240",
1035 1035
 						"comment",
1036 1036
 						"",
1037 1037
 						"",
1038 1038
 						"" 
1039 1039
 				),
1040
-				array (
1041
-						gettext ( 'Connection Cost(' . $currency . ')' ),
1040
+				array(
1041
+						gettext('Connection Cost('.$currency.')'),
1042 1042
 						"210",
1043 1043
 						"connectcost",
1044 1044
 						"connectcost",
@@ -1048,8 +1048,8 @@  discard block
 block discarded – undo
1048 1048
 						"true",
1049 1049
 						"right" 
1050 1050
 				),
1051
-				array (
1052
-						gettext ( 'Included Seconds' ),
1051
+				array(
1052
+						gettext('Included Seconds'),
1053 1053
 						"180",
1054 1054
 						"includedseconds",
1055 1055
 						"",
@@ -1059,8 +1059,8 @@  discard block
 block discarded – undo
1059 1059
 						"true",
1060 1060
 						"center" 
1061 1061
 				),
1062
-				array (
1063
-						gettext ( 'Per Minute Cost(' . $currency . ')' ),
1062
+				array(
1063
+						gettext('Per Minute Cost('.$currency.')'),
1064 1064
 						"180",
1065 1065
 						"cost",
1066 1066
 						"cost",
@@ -1070,8 +1070,8 @@  discard block
 block discarded – undo
1070 1070
 						"true",
1071 1071
 						"right" 
1072 1072
 				),
1073
-				array (
1074
-						gettext ( 'Increment' ),
1073
+				array(
1074
+						gettext('Increment'),
1075 1075
 						"140",
1076 1076
 						"inc",
1077 1077
 						"",
@@ -1081,8 +1081,8 @@  discard block
 block discarded – undo
1081 1081
 						"true",
1082 1082
 						"center" 
1083 1083
 				),
1084
-				array (
1085
-						gettext ( 'Priority' ),
1084
+				array(
1085
+						gettext('Priority'),
1086 1086
 						"155",
1087 1087
 						"precedence",
1088 1088
 						"",
@@ -1092,24 +1092,24 @@  discard block
 block discarded – undo
1092 1092
 						"true",
1093 1093
 						"center" 
1094 1094
 				) 
1095
-		) );
1095
+		));
1096 1096
 		return $grid_field_arr;
1097 1097
 	}
1098 1098
 	function get_reseller_origination_rate_search_form() {
1099
-		$accountinfo = $this->CI->session->userdata ( 'accountinfo' );
1099
+		$accountinfo = $this->CI->session->userdata('accountinfo');
1100 1100
 		
1101
-		$form ['forms'] = array (
1101
+		$form ['forms'] = array(
1102 1102
 				"",
1103
-				array (
1103
+				array(
1104 1104
 						'id' => "resellerrates_list_search" 
1105 1105
 				) 
1106 1106
 		);
1107
-		$form [gettext ( 'Search My Rates' )] = array (
1107
+		$form [gettext('Search My Rates')] = array(
1108 1108
 				
1109
-				array (
1110
-						gettext ( 'Code' ),
1109
+				array(
1110
+						gettext('Code'),
1111 1111
 						'INPUT',
1112
-						array (
1112
+						array(
1113 1113
 								'name' => 'pattern[pattern]',
1114 1114
 								'',
1115 1115
 								'size' => '20',
@@ -1125,10 +1125,10 @@  discard block
 block discarded – undo
1125 1125
 						'search_string_type',
1126 1126
 						'' 
1127 1127
 				),
1128
-				array (
1129
-						gettext ( 'Destination' ),
1128
+				array(
1129
+						gettext('Destination'),
1130 1130
 						'INPUT',
1131
-						array (
1131
+						array(
1132 1132
 								'name' => 'comment[comment]',
1133 1133
 								'',
1134 1134
 								'size' => '20',
@@ -1144,10 +1144,10 @@  discard block
 block discarded – undo
1144 1144
 						'search_string_type',
1145 1145
 						'' 
1146 1146
 				),
1147
-				array (
1148
-						gettext ( 'Connect Cost' ),
1147
+				array(
1148
+						gettext('Connect Cost'),
1149 1149
 						'INPUT',
1150
-						array (
1150
+						array(
1151 1151
 								'name' => 'connectcost[connectcost]',
1152 1152
 								'value' => '',
1153 1153
 								'size' => '20',
@@ -1163,10 +1163,10 @@  discard block
 block discarded – undo
1163 1163
 						'search_int_type',
1164 1164
 						'' 
1165 1165
 				),
1166
-				array (
1167
-						gettext ( 'Included Seconds' ),
1166
+				array(
1167
+						gettext('Included Seconds'),
1168 1168
 						'INPUT',
1169
-						array (
1169
+						array(
1170 1170
 								'name' => 'includedseconds[includedseconds]',
1171 1171
 								'value' => '',
1172 1172
 								'size' => '20',
@@ -1182,10 +1182,10 @@  discard block
 block discarded – undo
1182 1182
 						'search_int_type',
1183 1183
 						'' 
1184 1184
 				),
1185
-				array (
1186
-						gettext ( 'Per Minute Cost' ),
1185
+				array(
1186
+						gettext('Per Minute Cost'),
1187 1187
 						'INPUT',
1188
-						array (
1188
+						array(
1189 1189
 								'name' => 'cost[cost]',
1190 1190
 								'value' => '',
1191 1191
 								'size' => '20',
@@ -1201,10 +1201,10 @@  discard block
 block discarded – undo
1201 1201
 						'search_int_type',
1202 1202
 						'' 
1203 1203
 				),
1204
-				array (
1205
-						gettext ( 'Increment' ),
1204
+				array(
1205
+						gettext('Increment'),
1206 1206
 						'INPUT',
1207
-						array (
1207
+						array(
1208 1208
 								'name' => 'inc[inc]',
1209 1209
 								'',
1210 1210
 								'size' => '20',
@@ -1220,7 +1220,7 @@  discard block
 block discarded – undo
1220 1220
 						'search_int_type',
1221 1221
 						'' 
1222 1222
 				),
1223
-				array (
1223
+				array(
1224 1224
 						'',
1225 1225
 						'HIDDEN',
1226 1226
 						'ajax_search',
@@ -1229,7 +1229,7 @@  discard block
 block discarded – undo
1229 1229
 						'',
1230 1230
 						'' 
1231 1231
 				),
1232
-				array (
1232
+				array(
1233 1233
 						'',
1234 1234
 						'HIDDEN',
1235 1235
 						'advance_search',
@@ -1240,19 +1240,19 @@  discard block
 block discarded – undo
1240 1240
 				) 
1241 1241
 		);
1242 1242
 		
1243
-		$form ['button_search'] = array (
1243
+		$form ['button_search'] = array(
1244 1244
 				'name' => 'action',
1245 1245
 				'id' => "resellerrates_list_search_btn",
1246
-				'content' => gettext ( 'Search' ),
1246
+				'content' => gettext('Search'),
1247 1247
 				'value' => 'save',
1248 1248
 				'type' => 'button',
1249 1249
 				'class' => 'btn btn-line-parrot pull-right' 
1250 1250
 		);
1251
-		$form ['button_reset'] = array (
1251
+		$form ['button_reset'] = array(
1252 1252
 				'name' => 'action',
1253 1253
 				'id' => "id_reset",
1254 1254
 				'content' => 'Clear',
1255
-				'value' => gettext ( 'cancel' ),
1255
+				'value' => gettext('cancel'),
1256 1256
 				'type' => 'reset',
1257 1257
 				'class' => 'btn btn-line-sky pull-right margin-x-10' 
1258 1258
 		);
@@ -1260,18 +1260,18 @@  discard block
 block discarded – undo
1260 1260
 		return $form;
1261 1261
 	}
1262 1262
 	function get_origination_rate_search_form() {
1263
-		$form ['forms'] = array (
1263
+		$form ['forms'] = array(
1264 1264
 				"",
1265
-				array (
1265
+				array(
1266 1266
 						'id' => "origination_rate_list_search" 
1267 1267
 				) 
1268 1268
 		);
1269
-		$form [gettext ( 'Search' )] = array (
1269
+		$form [gettext('Search')] = array(
1270 1270
 				
1271
-				array (
1272
-						gettext ( 'Code' ),
1271
+				array(
1272
+						gettext('Code'),
1273 1273
 						'INPUT',
1274
-						array (
1274
+						array(
1275 1275
 								'name' => 'pattern[pattern]',
1276 1276
 								'',
1277 1277
 								'size' => '20',
@@ -1287,10 +1287,10 @@  discard block
 block discarded – undo
1287 1287
 						'search_string_type',
1288 1288
 						'' 
1289 1289
 				),
1290
-				array (
1291
-						gettext ( 'Destination' ),
1290
+				array(
1291
+						gettext('Destination'),
1292 1292
 						'INPUT',
1293
-						array (
1293
+						array(
1294 1294
 								'name' => 'comment[comment]',
1295 1295
 								'',
1296 1296
 								'size' => '20',
@@ -1306,10 +1306,10 @@  discard block
 block discarded – undo
1306 1306
 						'search_string_type',
1307 1307
 						'' 
1308 1308
 				),
1309
-				array (
1310
-						gettext ( 'Connect Cost' ),
1309
+				array(
1310
+						gettext('Connect Cost'),
1311 1311
 						'INPUT',
1312
-						array (
1312
+						array(
1313 1313
 								'name' => 'connectcost[connectcost]',
1314 1314
 								'value' => '',
1315 1315
 								'size' => '20',
@@ -1325,10 +1325,10 @@  discard block
 block discarded – undo
1325 1325
 						'search_int_type',
1326 1326
 						'' 
1327 1327
 				),
1328
-				array (
1329
-						gettext ( 'Included Seconds' ),
1328
+				array(
1329
+						gettext('Included Seconds'),
1330 1330
 						'INPUT',
1331
-						array (
1331
+						array(
1332 1332
 								'name' => 'includedseconds[includedseconds]',
1333 1333
 								'value' => '',
1334 1334
 								'size' => '20',
@@ -1344,10 +1344,10 @@  discard block
 block discarded – undo
1344 1344
 						'search_int_type',
1345 1345
 						'' 
1346 1346
 				),
1347
-				array (
1348
-						gettext ( 'Per Minute Cost' ),
1347
+				array(
1348
+						gettext('Per Minute Cost'),
1349 1349
 						'INPUT',
1350
-						array (
1350
+						array(
1351 1351
 								'name' => 'cost[cost]',
1352 1352
 								'value' => '',
1353 1353
 								'size' => '20',
@@ -1368,10 +1368,10 @@  discard block
 block discarded – undo
1368 1368
 				 * For Add Initial Increment field
1369 1369
 				 * *
1370 1370
 				 */
1371
-				array (
1372
-						gettext ( 'Initial Increment' ),
1371
+				array(
1372
+						gettext('Initial Increment'),
1373 1373
 						'INPUT',
1374
-						array (
1374
+						array(
1375 1375
 								'name' => 'init_inc[init_inc]',
1376 1376
 								'',
1377 1377
 								'size' => '20',
@@ -1390,10 +1390,10 @@  discard block
 block discarded – undo
1390 1390
 				/**
1391 1391
 				 * ***********************************************************
1392 1392
 				 */
1393
-				array (
1394
-						gettext ( 'Increment' ),
1393
+				array(
1394
+						gettext('Increment'),
1395 1395
 						'INPUT',
1396
-						array (
1396
+						array(
1397 1397
 								'name' => 'inc[inc]',
1398 1398
 								'',
1399 1399
 								'size' => '20',
@@ -1409,8 +1409,8 @@  discard block
 block discarded – undo
1409 1409
 						'search_int_type',
1410 1410
 						'' 
1411 1411
 				),
1412
-				array (
1413
-						gettext ( 'Rate Group' ),
1412
+				array(
1413
+						gettext('Rate Group'),
1414 1414
 						'pricelist_id',
1415 1415
 						'SELECT',
1416 1416
 						'',
@@ -1422,13 +1422,13 @@  discard block
 block discarded – undo
1422 1422
 						'pricelists',
1423 1423
 						'build_dropdown',
1424 1424
 						'where_arr',
1425
-						array (
1425
+						array(
1426 1426
 								"status" => "0",
1427 1427
 								"reseller_id" => "0" 
1428 1428
 						) 
1429 1429
 				),
1430
-				array (
1431
-						gettext ( 'Status' ),
1430
+				array(
1431
+						gettext('Status'),
1432 1432
 						'status',
1433 1433
 						'SELECT',
1434 1434
 						'',
@@ -1442,7 +1442,7 @@  discard block
 block discarded – undo
1442 1442
 						'',
1443 1443
 						'' 
1444 1444
 				),
1445
-				array (
1445
+				array(
1446 1446
 						'',
1447 1447
 						'HIDDEN',
1448 1448
 						'ajax_search',
@@ -1451,7 +1451,7 @@  discard block
 block discarded – undo
1451 1451
 						'',
1452 1452
 						'' 
1453 1453
 				),
1454
-				array (
1454
+				array(
1455 1455
 						'',
1456 1456
 						'HIDDEN',
1457 1457
 						'advance_search',
@@ -1467,11 +1467,11 @@  discard block
 block discarded – undo
1467 1467
 		 * Batch Delete
1468 1468
 		 * *****
1469 1469
 		 */
1470
-		$form ['button_search_delete'] = array (
1470
+		$form ['button_search_delete'] = array(
1471 1471
 				'name' => 'action',
1472 1472
 				'id' => "origination_rate_batch_dlt",
1473 1473
 				'onclick' => "check_btn();",
1474
-				'content' => gettext ( 'Delete Search Record' ),
1474
+				'content' => gettext('Delete Search Record'),
1475 1475
 				'style' => 'display:none;',
1476 1476
 				'value' => 'save',
1477 1477
 				'type' => 'button',
@@ -1487,11 +1487,11 @@  discard block
 block discarded – undo
1487 1487
 		 * Batch delete
1488 1488
 		 * ********
1489 1489
 		 */
1490
-		$form ['button_search'] = array (
1490
+		$form ['button_search'] = array(
1491 1491
 				'name' => 'action',
1492 1492
 				'id' => "origination_rate_list_search_btn",
1493 1493
 				'onclick' => 'search_btn();',
1494
-				'content' => gettext ( 'Search' ),
1494
+				'content' => gettext('Search'),
1495 1495
 				'value' => 'save',
1496 1496
 				'type' => 'button',
1497 1497
 				'class' => 'btn btn-line-parrot pull-right  margin-x-10' 
@@ -1499,10 +1499,10 @@  discard block
 block discarded – undo
1499 1499
 		/**
1500 1500
 		 * ***********************
1501 1501
 		 */
1502
-		$form ['button_reset'] = array (
1502
+		$form ['button_reset'] = array(
1503 1503
 				'name' => 'action',
1504 1504
 				'id' => "id_reset",
1505
-				'content' => gettext ( 'Clear' ),
1505
+				'content' => gettext('Clear'),
1506 1506
 				'value' => 'cancel',
1507 1507
 				'type' => 'reset',
1508 1508
 				'class' => 'btn btn-line-sky pull-right margin-x-10' 
@@ -1516,13 +1516,13 @@  discard block
 block discarded – undo
1516 1516
 	 * changes in grid size
1517 1517
 	 */
1518 1518
 	function build_termination_rate_for_admin() {
1519
-		$account_info = $accountinfo = $this->CI->session->userdata ( 'accountinfo' );
1519
+		$account_info = $accountinfo = $this->CI->session->userdata('accountinfo');
1520 1520
 		$currency_id = $account_info ['currency_id'];
1521
-		$currency = $this->CI->common->get_field_name ( 'currency', 'currency', $currency_id );
1521
+		$currency = $this->CI->common->get_field_name('currency', 'currency', $currency_id);
1522 1522
 		
1523 1523
 		// array(display name, width, db_field_parent_table,feidname, db_field_child_table,function name);
1524
-		$grid_field_arr = json_encode ( array (
1525
-				array (
1524
+		$grid_field_arr = json_encode(array(
1525
+				array(
1526 1526
 						"<input type='checkbox' name='chkAll' class='ace checkall'/><label class='lbl'></label>",
1527 1527
 						"30",
1528 1528
 						"",
@@ -1538,8 +1538,8 @@  discard block
 block discarded – undo
1538 1538
 				 * For Termination Rate edit on Code
1539 1539
 				 * *
1540 1540
 				 */
1541
-				array (
1542
-						gettext ( "Code" ),
1541
+				array(
1542
+						gettext("Code"),
1543 1543
 						"78",
1544 1544
 						"pattern",
1545 1545
 						"pattern",
@@ -1552,8 +1552,8 @@  discard block
 block discarded – undo
1552 1552
 				/**
1553 1553
 				 * ******************************
1554 1554
 				 */
1555
-				array (
1556
-						gettext ( "Destination" ),
1555
+				array(
1556
+						gettext("Destination"),
1557 1557
 						"80",
1558 1558
 						"comment",
1559 1559
 						"",
@@ -1563,8 +1563,8 @@  discard block
 block discarded – undo
1563 1563
 						"true",
1564 1564
 						"center" 
1565 1565
 				),
1566
-				array (
1567
-						gettext ( "Connect Cost($currency)" ),
1566
+				array(
1567
+						gettext("Connect Cost($currency)"),
1568 1568
 						"125",
1569 1569
 						"connectcost",
1570 1570
 						"connectcost",
@@ -1574,8 +1574,8 @@  discard block
 block discarded – undo
1574 1574
 						"true",
1575 1575
 						"right" 
1576 1576
 				),
1577
-				array (
1578
-						gettext ( "Included<br/> Seconds" ),
1577
+				array(
1578
+						gettext("Included<br/> Seconds"),
1579 1579
 						"70",
1580 1580
 						"includedseconds",
1581 1581
 						"",
@@ -1585,8 +1585,8 @@  discard block
 block discarded – undo
1585 1585
 						"true",
1586 1586
 						"center" 
1587 1587
 				),
1588
-				array (
1589
-						gettext ( "Per Minute <br/>Cost($currency)" ),
1588
+				array(
1589
+						gettext("Per Minute <br/>Cost($currency)"),
1590 1590
 						"100",
1591 1591
 						"cost",
1592 1592
 						"cost",
@@ -1596,8 +1596,8 @@  discard block
 block discarded – undo
1596 1596
 						"true",
1597 1597
 						"right" 
1598 1598
 				),
1599
-				array (
1600
-						gettext ( "Initial <br/> Increment" ),
1599
+				array(
1600
+						gettext("Initial <br/> Increment"),
1601 1601
 						"95",
1602 1602
 						"init_inc",
1603 1603
 						"",
@@ -1607,8 +1607,8 @@  discard block
 block discarded – undo
1607 1607
 						"true",
1608 1608
 						"center" 
1609 1609
 				),
1610
-				array (
1611
-						gettext ( "Increment" ),
1610
+				array(
1611
+						gettext("Increment"),
1612 1612
 						"75",
1613 1613
 						"inc",
1614 1614
 						"",
@@ -1618,8 +1618,8 @@  discard block
 block discarded – undo
1618 1618
 						"true",
1619 1619
 						"center" 
1620 1620
 				),
1621
-				array (
1622
-						gettext ( "Priority" ),
1621
+				array(
1622
+						gettext("Priority"),
1623 1623
 						"70",
1624 1624
 						"precedence",
1625 1625
 						"",
@@ -1629,8 +1629,8 @@  discard block
 block discarded – undo
1629 1629
 						"true",
1630 1630
 						"center" 
1631 1631
 				),
1632
-				array (
1633
-						gettext ( "Strip" ),
1632
+				array(
1633
+						gettext("Strip"),
1634 1634
 						"60",
1635 1635
 						"strip",
1636 1636
 						"",
@@ -1640,8 +1640,8 @@  discard block
 block discarded – undo
1640 1640
 						"true",
1641 1641
 						"center" 
1642 1642
 				),
1643
-				array (
1644
-						gettext ( "Prepend" ),
1643
+				array(
1644
+						gettext("Prepend"),
1645 1645
 						"70",
1646 1646
 						"prepend",
1647 1647
 						"pattern",
@@ -1651,8 +1651,8 @@  discard block
 block discarded – undo
1651 1651
 						"true",
1652 1652
 						"center" 
1653 1653
 				),
1654
-				array (
1655
-						gettext ( "Trunk" ),
1654
+				array(
1655
+						gettext("Trunk"),
1656 1656
 						"80",
1657 1657
 						"trunk_id",
1658 1658
 						"name",
@@ -1666,8 +1666,8 @@  discard block
 block discarded – undo
1666 1666
             ASTPP  3.0 
1667 1667
             creation field show in grid
1668 1668
             */
1669
-			array (
1670
-						gettext ( "Status" ),
1669
+			array(
1670
+						gettext("Status"),
1671 1671
 						"100",
1672 1672
 						"status",
1673 1673
 						"status",
@@ -1678,8 +1678,8 @@  discard block
 block discarded – undo
1678 1678
 						"center" 
1679 1679
 				),
1680 1680
 				// array("Created<br/>Date", "80", "creation_date", "creation_date", "creation_date", "convert_GMT_to","","true","center"),
1681
-				array (
1682
-						gettext ( "Modified Date" ),
1681
+				array(
1682
+						gettext("Modified Date"),
1683 1683
 						"150",
1684 1684
 						"last_modified_date",
1685 1685
 						"last_modified_date",
@@ -1701,25 +1701,25 @@  discard block
 block discarded – undo
1701 1701
 				 * ********************************************************************
1702 1702
 				 */
1703 1703
 				// array("Reseller", "103", "reseller_id", "number", "accounts", "get_field_name"),
1704
-				array (
1705
-						gettext ( "Action" ),
1704
+				array(
1705
+						gettext("Action"),
1706 1706
 						"80",
1707 1707
 						"",
1708 1708
 						"",
1709 1709
 						"",
1710
-						array (
1711
-								"EDIT" => array (
1710
+						array(
1711
+								"EDIT" => array(
1712 1712
 										"url" => "rates/termination_rate_edit/",
1713 1713
 										"mode" => "popup",
1714 1714
 										"layout" => "medium" 
1715 1715
 								),
1716
-								"DELETE" => array (
1716
+								"DELETE" => array(
1717 1717
 										"url" => "rates/termination_rate_delete/",
1718 1718
 										"mode" => "single" 
1719 1719
 								) 
1720 1720
 						) 
1721 1721
 				) 
1722
-		) );
1722
+		));
1723 1723
 		return $grid_field_arr;
1724 1724
 	}
1725 1725
 	/**
@@ -1731,13 +1731,13 @@  discard block
 block discarded – undo
1731 1731
 	 * changes in grid size
1732 1732
 	 */
1733 1733
 	function build_origination_rate_list_for_admin() {
1734
-		$account_info = $accountinfo = $this->CI->session->userdata ( 'accountinfo' );
1734
+		$account_info = $accountinfo = $this->CI->session->userdata('accountinfo');
1735 1735
 		$currency_id = $account_info ['currency_id'];
1736
-		$currency = $this->CI->common->get_field_name ( 'currency', 'currency', $currency_id );
1736
+		$currency = $this->CI->common->get_field_name('currency', 'currency', $currency_id);
1737 1737
 		
1738 1738
 		// array(display name, width, db_field_parent_table,feidname, db_field_child_table,function name);
1739
-		$grid_field_arr = json_encode ( array (
1740
-				array (
1739
+		$grid_field_arr = json_encode(array(
1740
+				array(
1741 1741
 						"<input type='checkbox' name='chkAll' class='ace checkall'/><label class='lbl'></label>",
1742 1742
 						"30",
1743 1743
 						"",
@@ -1753,8 +1753,8 @@  discard block
 block discarded – undo
1753 1753
 				 * For Origination rate edit on code
1754 1754
 				 * *
1755 1755
 				 */
1756
-				array (
1757
-						gettext ( "Code" ),
1756
+				array(
1757
+						gettext("Code"),
1758 1758
 						"75",
1759 1759
 						"pattern",
1760 1760
 						"pattern",
@@ -1767,8 +1767,8 @@  discard block
 block discarded – undo
1767 1767
 				/**
1768 1768
 				 * *********************************
1769 1769
 				 */
1770
-				array (
1771
-						gettext ( "Destination" ),
1770
+				array(
1771
+						gettext("Destination"),
1772 1772
 						"100",
1773 1773
 						"comment",
1774 1774
 						"",
@@ -1778,8 +1778,8 @@  discard block
 block discarded – undo
1778 1778
 						"true",
1779 1779
 						"center" 
1780 1780
 				),
1781
-				array (
1782
-						gettext ( "Connect Cost($currency)" ),
1781
+				array(
1782
+						gettext("Connect Cost($currency)"),
1783 1783
 						"130",
1784 1784
 						"connectcost",
1785 1785
 						"connectcost",
@@ -1789,8 +1789,8 @@  discard block
 block discarded – undo
1789 1789
 						"true",
1790 1790
 						"right" 
1791 1791
 				),
1792
-				array (
1793
-						gettext ( "Included Seconds" ),
1792
+				array(
1793
+						gettext("Included Seconds"),
1794 1794
 						"120",
1795 1795
 						"includedseconds",
1796 1796
 						"",
@@ -1800,8 +1800,8 @@  discard block
 block discarded – undo
1800 1800
 						"true",
1801 1801
 						"center" 
1802 1802
 				),
1803
-				array (
1804
-						gettext ( "Per Minute Cost($currency)" ),
1803
+				array(
1804
+						gettext("Per Minute Cost($currency)"),
1805 1805
 						"150",
1806 1806
 						"cost",
1807 1807
 						"cost",
@@ -1816,8 +1816,8 @@  discard block
 block discarded – undo
1816 1816
 				 * For Add Initial Increment field
1817 1817
 				 * *
1818 1818
 				 */
1819
-				array (
1820
-						gettext ( "Initial Increment" ),
1819
+				array(
1820
+						gettext("Initial Increment"),
1821 1821
 						"130",
1822 1822
 						"init_inc",
1823 1823
 						"",
@@ -1830,8 +1830,8 @@  discard block
 block discarded – undo
1830 1830
 				/**
1831 1831
 				 * ****************************************************************
1832 1832
 				 */
1833
-				array (
1834
-						gettext ( "Increment" ),
1833
+				array(
1834
+						gettext("Increment"),
1835 1835
 						"90",
1836 1836
 						"inc",
1837 1837
 						"",
@@ -1842,8 +1842,8 @@  discard block
 block discarded – undo
1842 1842
 						"center" 
1843 1843
 				),
1844 1844
 				// array("Priority", "72", "precedence", "", "", "","","true","center"),
1845
-				array (
1846
-						gettext ( "Rate Group" ),
1845
+				array(
1846
+						gettext("Rate Group"),
1847 1847
 						"90",
1848 1848
 						"pricelist_id",
1849 1849
 						"name",
@@ -1856,8 +1856,8 @@  discard block
 block discarded – undo
1856 1856
 			/*
1857 1857
             ASTPP  3.0  creation field show in grid
1858 1858
             */
1859
-			array (
1860
-						gettext ( "Status" ),
1859
+			array(
1860
+						gettext("Status"),
1861 1861
 						"100",
1862 1862
 						"status",
1863 1863
 						"status",
@@ -1868,8 +1868,8 @@  discard block
 block discarded – undo
1868 1868
 						"center" 
1869 1869
 				),
1870 1870
 				// array("Created<br/>Date", "80", "creation_date", "creation_date", "creation_date", "convert_GMT_to","","true","center"),
1871
-				array (
1872
-						gettext ( "Modified Date" ),
1871
+				array(
1872
+						gettext("Modified Date"),
1873 1873
 						"150",
1874 1874
 						"last_modified_date",
1875 1875
 						"last_modified_date",
@@ -1888,34 +1888,34 @@  discard block
 block discarded – undo
1888 1888
 				 * chnage in status active or inactive
1889 1889
 				 */
1890 1890
 				
1891
-				array (
1892
-						gettext ( "Action" ),
1891
+				array(
1892
+						gettext("Action"),
1893 1893
 						"95",
1894 1894
 						"",
1895 1895
 						"",
1896 1896
 						"",
1897
-						array (
1898
-								"EDIT" => array (
1897
+						array(
1898
+								"EDIT" => array(
1899 1899
 										"url" => "rates/origination_rate_edit/",
1900 1900
 										"mode" => "popup",
1901 1901
 										"layout" => "medium" 
1902 1902
 								),
1903
-								"DELETE" => array (
1903
+								"DELETE" => array(
1904 1904
 										"url" => "/rates/origination_rate_delete/",
1905 1905
 										"mode" => "single" 
1906 1906
 								) 
1907 1907
 						) 
1908 1908
 				) 
1909
-		) );
1909
+		));
1910 1910
 		return $grid_field_arr;
1911 1911
 	}
1912 1912
 	/**
1913 1913
 	 * *************************************************************************************
1914 1914
 	 */
1915 1915
 	function build_grid_buttons() {
1916
-		$buttons_json = json_encode ( array (
1917
-				array (
1918
-						gettext ( "Create" ),
1916
+		$buttons_json = json_encode(array(
1917
+				array(
1918
+						gettext("Create"),
1919 1919
 						"btn btn-line-warning btn",
1920 1920
 						"fa fa-plus-circle fa-lg",
1921 1921
 						"button_action",
@@ -1923,44 +1923,44 @@  discard block
 block discarded – undo
1923 1923
 						"popup",
1924 1924
 						"medium" 
1925 1925
 				),
1926
-				array (
1927
-						gettext ( "Delete" ),
1926
+				array(
1927
+						gettext("Delete"),
1928 1928
 						"btn btn-line-danger",
1929 1929
 						"fa fa-times-circle fa-lg",
1930 1930
 						"button_action",
1931 1931
 						"/rates/termination_rate_delete_multiple/" 
1932 1932
 				),
1933
-				array (
1934
-						gettext ( "import" ),
1933
+				array(
1934
+						gettext("import"),
1935 1935
 						"btn btn-line-blue",
1936 1936
 						"fa fa-upload fa-lg",
1937 1937
 						"button_action",
1938 1938
 						"/rates/termination_rate_import/",
1939 1939
 						'single' 
1940 1940
 				),
1941
-				array (
1942
-						gettext ( "Import with field map" ),
1941
+				array(
1942
+						gettext("Import with field map"),
1943 1943
 						"btn btn-line-blue",
1944 1944
 						"fa fa-upload fa-lg",
1945 1945
 						"button_action",
1946 1946
 						"/rates/termination_rate_import_mapper/",
1947 1947
 						'single' 
1948 1948
 				),
1949
-				array (
1950
-						gettext ( "Export" ),
1949
+				array(
1950
+						gettext("Export"),
1951 1951
 						"btn btn-xing",
1952 1952
 						" fa fa-download fa-lg",
1953 1953
 						"button_action",
1954 1954
 						"/rates/termination_rate_export_cdr_xls/",
1955 1955
 						'single' 
1956 1956
 				) 
1957
-		) );
1957
+		));
1958 1958
 		return $buttons_json;
1959 1959
 	}
1960 1960
 	function build_grid_buttons_origination_rate() {
1961
-		$buttons_json = json_encode ( array (
1962
-				array (
1963
-						gettext ( "Create" ),
1961
+		$buttons_json = json_encode(array(
1962
+				array(
1963
+						gettext("Create"),
1964 1964
 						"btn btn-line-warning btn",
1965 1965
 						"fa fa-plus-circle fa-lg",
1966 1966
 						"button_action",
@@ -1968,23 +1968,23 @@  discard block
 block discarded – undo
1968 1968
 						"popup",
1969 1969
 						"medium" 
1970 1970
 				),
1971
-				array (
1972
-						gettext ( "Delete" ),
1971
+				array(
1972
+						gettext("Delete"),
1973 1973
 						"btn btn-line-danger",
1974 1974
 						"fa fa-times-circle fa-lg",
1975 1975
 						"button_action",
1976 1976
 						"/rates/origination_rate_delete_multiple/" 
1977 1977
 				),
1978
-				array (
1979
-						gettext ( "import" ),
1978
+				array(
1979
+						gettext("import"),
1980 1980
 						"btn btn-line-blue",
1981 1981
 						"fa fa-upload fa-lg",
1982 1982
 						"button_action",
1983 1983
 						"/rates/origination_rate_import/",
1984 1984
 						'single' 
1985 1985
 				),
1986
-				array (
1987
-						gettext ( "Export" ),
1986
+				array(
1987
+						gettext("Export"),
1988 1988
 						"btn btn-xing",
1989 1989
 						" fa fa-download fa-lg",
1990 1990
 						"button_action",
@@ -1997,8 +1997,8 @@  discard block
 block discarded – undo
1997 1997
 	}
1998 1998
 	function build_termination_rate_list_for_customer() {
1999 1999
 		// array(display name, width, db_field_parent_table,feidname, db_field_child_table,function name);
2000
-		$grid_field_arr = json_encode ( array (
2001
-				array (
2000
+		$grid_field_arr = json_encode(array(
2001
+				array(
2002 2002
 						"<input type='checkbox' name='chkAll' class='ace checking checkall'/><label class='lbl'></label>",
2003 2003
 						"30",
2004 2004
 						"",
@@ -2009,76 +2009,76 @@  discard block
 block discarded – undo
2009 2009
 						"false",
2010 2010
 						"center" 
2011 2011
 				),
2012
-				array (
2013
-						gettext ( "Code" ),
2012
+				array(
2013
+						gettext("Code"),
2014 2014
 						"70",
2015 2015
 						"pattern",
2016 2016
 						"pattern",
2017 2017
 						"",
2018 2018
 						"get_only_numeric_val" 
2019 2019
 				),
2020
-				array (
2021
-						gettext ( "Increment" ),
2020
+				array(
2021
+						gettext("Increment"),
2022 2022
 						"75",
2023 2023
 						"inc",
2024 2024
 						"",
2025 2025
 						"",
2026 2026
 						"" 
2027 2027
 				),
2028
-				array (
2029
-						gettext ( "Connect <br> Charge", "100" ),
2028
+				array(
2029
+						gettext("Connect <br> Charge", "100"),
2030 2030
 						"connectcost",
2031 2031
 						"connectcost",
2032 2032
 						"connectcost",
2033 2033
 						"convert_to_currency" 
2034 2034
 				),
2035
-				array (
2036
-						gettext ( "Included <br> Seconds" ),
2035
+				array(
2036
+						gettext("Included <br> Seconds"),
2037 2037
 						"100",
2038 2038
 						"includedseconds",
2039 2039
 						"",
2040 2040
 						"",
2041 2041
 						"" 
2042 2042
 				),
2043
-				array (
2044
-						gettext ( "Destination" ),
2043
+				array(
2044
+						gettext("Destination"),
2045 2045
 						"100",
2046 2046
 						"comment",
2047 2047
 						"",
2048 2048
 						"",
2049 2049
 						"" 
2050 2050
 				),
2051
-				array (
2052
-						gettext ( "Cost per <br> Minutes" ),
2051
+				array(
2052
+						gettext("Cost per <br> Minutes"),
2053 2053
 						"100",
2054 2054
 						"cost",
2055 2055
 						"cost",
2056 2056
 						"cost",
2057 2057
 						"convert_to_currency" 
2058 2058
 				),
2059
-				array (
2060
-						gettext ( "Priority" ),
2059
+				array(
2060
+						gettext("Priority"),
2061 2061
 						"80",
2062 2062
 						"precedence",
2063 2063
 						"",
2064 2064
 						"",
2065 2065
 						"" 
2066 2066
 				),
2067
-				array (
2068
-						gettext ( "Reseller" ),
2067
+				array(
2068
+						gettext("Reseller"),
2069 2069
 						"80",
2070 2070
 						"reseller_id",
2071 2071
 						"number",
2072 2072
 						"accounts",
2073 2073
 						"get_field_name" 
2074 2074
 				) 
2075
-		) );
2075
+		));
2076 2076
 		return $grid_field_arr;
2077 2077
 	}
2078 2078
 	function build_block_pattern_list_for_customer() {
2079 2079
 		// array(display name, width, db_field_parent_table,feidname, db_field_child_table,function name);
2080
-		$grid_field_arr = json_encode ( array (
2081
-				array (
2080
+		$grid_field_arr = json_encode(array(
2081
+				array(
2082 2082
 						"<input type='checkbox' name='chkAll1' class='ace checking'/><label class='lbl'></label>",
2083 2083
 						"30",
2084 2084
 						"",
@@ -2090,28 +2090,28 @@  discard block
 block discarded – undo
2090 2090
 						"center",
2091 2091
 						"PatternChkBox" 
2092 2092
 				),
2093
-				array (
2094
-						gettext ( "Code" ),
2093
+				array(
2094
+						gettext("Code"),
2095 2095
 						"350",
2096 2096
 						"pattern",
2097 2097
 						"pattern",
2098 2098
 						"",
2099 2099
 						"get_only_numeric_val" 
2100 2100
 				),
2101
-				array (
2102
-						gettext ( "Destination" ),
2101
+				array(
2102
+						gettext("Destination"),
2103 2103
 						"350",
2104 2104
 						"comment",
2105 2105
 						"",
2106 2106
 						"",
2107 2107
 						"" 
2108 2108
 				) 
2109
-		) );
2109
+		));
2110 2110
 		return $grid_field_arr;
2111 2111
 	}
2112 2112
 	function build_pattern_list_for_customer($accountid, $accounttype) {
2113
-		$grid_field_arr = json_encode ( array (
2114
-				array (
2113
+		$grid_field_arr = json_encode(array(
2114
+				array(
2115 2115
 						"<input type='checkbox' name='chkAll' class='ace checkall'/><label class='lbl'></label>",
2116 2116
 						"30",
2117 2117
 						"",
@@ -2122,116 +2122,116 @@  discard block
 block discarded – undo
2122 2122
 						"false",
2123 2123
 						"center" 
2124 2124
 				),
2125
-				array (
2126
-						gettext ( "Code" ),
2125
+				array(
2126
+						gettext("Code"),
2127 2127
 						"450",
2128 2128
 						"blocked_patterns",
2129 2129
 						"blocked_patterns",
2130 2130
 						"",
2131 2131
 						"get_only_numeric_val" 
2132 2132
 				),
2133
-				array (
2134
-						gettext ( "Destination" ),
2133
+				array(
2134
+						gettext("Destination"),
2135 2135
 						"450",
2136 2136
 						"destination",
2137 2137
 						"",
2138 2138
 						"",
2139 2139
 						"" 
2140 2140
 				),
2141
-				array (
2142
-						gettext ( "Action" ),
2141
+				array(
2142
+						gettext("Action"),
2143 2143
 						"100",
2144 2144
 						"",
2145 2145
 						"",
2146 2146
 						"",
2147
-						array (
2148
-								"DELETE" => array (
2149
-										"url" => "accounts/" . $accounttype . "_delete_block_pattern/$accountid/",
2147
+						array(
2148
+								"DELETE" => array(
2149
+										"url" => "accounts/".$accounttype."_delete_block_pattern/$accountid/",
2150 2150
 										"mode" => "single" 
2151 2151
 								) 
2152 2152
 						) 
2153 2153
 				) 
2154
-		) );
2154
+		));
2155 2155
 		return $grid_field_arr;
2156 2156
 	}
2157 2157
 	function set_pattern_grid_buttons($accountid) {
2158
-		$buttons_json = json_encode ( array (
2159
-				array (
2160
-						gettext ( "Add Prefixes" ),
2158
+		$buttons_json = json_encode(array(
2159
+				array(
2160
+						gettext("Add Prefixes"),
2161 2161
 						"btn btn-line-warning btn",
2162 2162
 						"fa fa-plus-circle fa-lg",
2163 2163
 						"button_action",
2164 2164
 						"/accounts/customer_add_blockpatterns/$accountid",
2165 2165
 						"popup" 
2166 2166
 				) 
2167
-		) );
2167
+		));
2168 2168
 		return $buttons_json;
2169 2169
 	}
2170 2170
 	function build_origination_rate_list_for_user() {
2171 2171
 		// array(display name, width, db_field_parent_table,feidname, db_field_child_table,function name);
2172
-		$grid_field_arr = json_encode ( array (
2173
-				array (
2174
-						gettext ( "Code" ),
2172
+		$grid_field_arr = json_encode(array(
2173
+				array(
2174
+						gettext("Code"),
2175 2175
 						"155",
2176 2176
 						"pattern",
2177 2177
 						"pattern",
2178 2178
 						"",
2179 2179
 						"get_only_numeric_val" 
2180 2180
 				),
2181
-				array (
2182
-						gettext ( "Destination" ),
2181
+				array(
2182
+						gettext("Destination"),
2183 2183
 						"225",
2184 2184
 						"comment",
2185 2185
 						"",
2186 2186
 						"",
2187 2187
 						"" 
2188 2188
 				),
2189
-				array (
2190
-						gettext ( "Increment" ),
2189
+				array(
2190
+						gettext("Increment"),
2191 2191
 						"235",
2192 2192
 						"inc",
2193 2193
 						"",
2194 2194
 						"",
2195 2195
 						"" 
2196 2196
 				),
2197
-				array (
2198
-						gettext ( "Cost per Minutes" ),
2197
+				array(
2198
+						gettext("Cost per Minutes"),
2199 2199
 						"240",
2200 2200
 						"cost",
2201 2201
 						"cost",
2202 2202
 						"cost",
2203 2203
 						"convert_to_currency" 
2204 2204
 				),
2205
-				array (
2206
-						gettext ( "Connect Charge" ),
2205
+				array(
2206
+						gettext("Connect Charge"),
2207 2207
 						"200",
2208 2208
 						"connectcost",
2209 2209
 						"connectcost",
2210 2210
 						"connectcost",
2211 2211
 						"convert_to_currency" 
2212 2212
 				),
2213
-				array (
2214
-						gettext ( "Included Seconds" ),
2213
+				array(
2214
+						gettext("Included Seconds"),
2215 2215
 						"200",
2216 2216
 						"includedseconds",
2217 2217
 						"",
2218 2218
 						"",
2219 2219
 						"" 
2220 2220
 				) 
2221
-		) );
2221
+		));
2222 2222
 		return $grid_field_arr;
2223 2223
 	}
2224 2224
 	function build_grid_buttons_rates() {
2225
-		$buttons_json = json_encode ( array (
2226
-				array (
2227
-						gettext ( "Export" ),
2225
+		$buttons_json = json_encode(array(
2226
+				array(
2227
+						gettext("Export"),
2228 2228
 						"btn btn-xing",
2229 2229
 						" fa fa-download fa-lg",
2230 2230
 						"button_action",
2231 2231
 						"/rates/resellersrates_xls/",
2232 2232
 						'single' 
2233 2233
 				) 
2234
-		) );
2234
+		));
2235 2235
 		return $buttons_json;
2236 2236
 	}
2237 2237
 }
Please login to merge, or discard this patch.
Braces   +8 added lines, -5 removed lines patch added patch discarded remove patch
@@ -20,8 +20,9 @@  discard block
 block discarded – undo
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
 class rates_form {
26 27
 	function __construct($library_name = '') {
27 28
 		$this->CI = & get_instance ();
@@ -231,8 +232,8 @@  discard block
 block discarded – undo
231 232
 	function get_origination_rate_form_fields() {
232 233
 		$logintype = $this->CI->session->userdata ( 'userlevel_logintype' );
233 234
 		$trunk = null;
234
-		if ($logintype != 1)
235
-			$trunk = array (
235
+		if ($logintype != 1) {
236
+					$trunk = array (
236 237
 					'Force Trunk',
237 238
 					'trunk_id',
238 239
 					'SELECT',
@@ -249,6 +250,7 @@  discard block
 block discarded – undo
249 250
 							"status" => "0" 
250 251
 					) 
251 252
 			);
253
+		}
252 254
 		$form ['forms'] = array (
253 255
 				base_url () . 'rates/origination_rate_save/',
254 256
 				array (
@@ -865,8 +867,8 @@  discard block
 block discarded – undo
865 867
 	function origination_rate_batch_update_form() {
866 868
 		$logintype = $this->CI->session->userdata ( 'userlevel_logintype' );
867 869
 		$trunk = null;
868
-		if ($logintype != 1)
869
-			$trunk = array (
870
+		if ($logintype != 1) {
871
+					$trunk = array (
870 872
 					'Force Trunk',
871 873
 					array (
872 874
 							'name' => 'trunk_id[trunk_id]',
@@ -891,6 +893,7 @@  discard block
 block discarded – undo
891 893
 					),
892 894
 					'update_drp_type' 
893 895
 			);
896
+		}
894 897
 		$form ['forms'] = array (
895 898
 				"rates/origination_rate_batch_update/",
896 899
 				array (
Please login to merge, or discard this patch.
web_interface/astpp/application/modules/rates/views/view_import_error.php 3 patches
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -49,7 +49,7 @@
 block discarded – undo
49 49
                         <a href="<?= base_url().'rates/termination_rates_list/'?>"><input class="btn btn-line-sky margin-x-10" id="ok" type="button" name="action" value="Back to Termination Rates List" /> </a>
50 50
 
51 51
                        <?php $profile_url = explode("/",base_url(uri_string()));
52
-        if($profile_url[4] == 'termination_rate_rates_import'){ ?>
52
+		if($profile_url[4] == 'termination_rate_rates_import'){ ?>
53 53
                         <a href="<?= base_url().'rates/termination_rate_error_download/'?>"><input class="btn btn-line-parrot" id="ok" type="button" name="action" value="Download Errors" /> </a>
54 54
              </div></div>       <? }else{ ?>
55 55
              <a href="<?= base_url().'rates/termination_rate_mapper_error_download/'?>"><input class="btn btn-line-parrot" id="ok" type="button" name="action" value="Download Errors" /> </a>
Please login to merge, or discard this patch.
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -48,10 +48,10 @@
 block discarded – undo
48 48
                    <div class="pull-right">
49 49
                         <a href="<?= base_url().'rates/termination_rates_list/'?>"><input class="btn btn-line-sky margin-x-10" id="ok" type="button" name="action" value="Back to Termination Rates List" /> </a>
50 50
 
51
-                       <?php $profile_url = explode("/",base_url(uri_string()));
52
-        if($profile_url[4] == 'termination_rate_rates_import'){ ?>
51
+                       <?php $profile_url = explode("/", base_url(uri_string()));
52
+        if ($profile_url[4] == 'termination_rate_rates_import') { ?>
53 53
                         <a href="<?= base_url().'rates/termination_rate_error_download/'?>"><input class="btn btn-line-parrot" id="ok" type="button" name="action" value="Download Errors" /> </a>
54
-             </div></div>       <? }else{ ?>
54
+             </div></div>       <? } else { ?>
55 55
              <a href="<?= base_url().'rates/termination_rate_mapper_error_download/'?>"><input class="btn btn-line-parrot" id="ok" type="button" name="action" value="Download Errors" /> </a>
56 56
              
57 57
            <?  } }?>    
Please login to merge, or discard this patch.
Braces   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -51,7 +51,7 @@
 block discarded – undo
51 51
                        <?php $profile_url = explode("/",base_url(uri_string()));
52 52
         if($profile_url[4] == 'termination_rate_rates_import'){ ?>
53 53
                         <a href="<?= base_url().'rates/termination_rate_error_download/'?>"><input class="btn btn-line-parrot" id="ok" type="button" name="action" value="Download Errors" /> </a>
54
-             </div></div>       <? }else{ ?>
54
+             </div></div>       <? } else{ ?>
55 55
              <a href="<?= base_url().'rates/termination_rate_mapper_error_download/'?>"><input class="btn btn-line-parrot" id="ok" type="button" name="action" value="Download Errors" /> </a>
56 56
              
57 57
            <?  } }?>    
Please login to merge, or discard this patch.
web_interface/astpp/application/modules/trunk/models/trunk_model.php 1 patch
Spacing   +17 added lines, -17 removed lines patch added patch discarded remove patch
@@ -22,39 +22,39 @@
 block discarded – undo
22 22
 // ##############################################################################
23 23
 class trunk_model extends CI_Model {
24 24
 	function trunk_model() {
25
-		parent::__construct ();
25
+		parent::__construct();
26 26
 	}
27 27
 	function gettrunk_list($flag, $start = 0, $limit = 0) {
28
-		$this->db_model->build_search ( 'trunk_list_search' );
29
-		$where = array (
28
+		$this->db_model->build_search('trunk_list_search');
29
+		$where = array(
30 30
 				"status != " => "2" 
31 31
 		);
32 32
 		if ($flag) {
33
-			$query = $this->db_model->select ( "*", "trunks", $where, "id", "ASC", $limit, $start );
33
+			$query = $this->db_model->select("*", "trunks", $where, "id", "ASC", $limit, $start);
34 34
 		} else {
35
-			$query = $this->db_model->countQuery ( "*", "trunks", $where );
35
+			$query = $this->db_model->countQuery("*", "trunks", $where);
36 36
 		}
37 37
 		return $query;
38 38
 	}
39 39
 	function add_trunk($add_array) {
40
-		unset ( $add_array ["action"] );
41
-		$add_array ['creation_date'] = gmdate ( 'Y-m-d H:i:s' );
42
-		$this->db->insert ( "trunks", $add_array );
40
+		unset ($add_array ["action"]);
41
+		$add_array ['creation_date'] = gmdate('Y-m-d H:i:s');
42
+		$this->db->insert("trunks", $add_array);
43 43
 		return true;
44 44
 	}
45 45
 	function edit_trunk($data, $id) {
46
-		unset ( $data ["action"] );
47
-		$data ['last_modified_date'] = gmdate ( 'Y-m-d H:i:s' );
48
-		$this->db->where ( "id", $id );
49
-		$this->db->update ( "trunks", $data );
46
+		unset ($data ["action"]);
47
+		$data ['last_modified_date'] = gmdate('Y-m-d H:i:s');
48
+		$this->db->where("id", $id);
49
+		$this->db->update("trunks", $data);
50 50
 	}
51 51
 	function remove_trunk($id) {
52
-		$this->db->where ( "id", $id );
53
-		$this->db->update ( "trunks", array (
52
+		$this->db->where("id", $id);
53
+		$this->db->update("trunks", array(
54 54
 				"status" => 2 
55
-		) );
56
-		$this->db->where ( 'trunk_id', $id );
57
-		$this->db->delete ( 'outbound_routes' );
55
+		));
56
+		$this->db->where('trunk_id', $id);
57
+		$this->db->delete('outbound_routes');
58 58
 		return true;
59 59
 	}
60 60
 }
Please login to merge, or discard this patch.
web_interface/astpp/application/modules/trunk/controllers/trunk.php 2 patches
Spacing   +90 added lines, -90 removed lines patch added patch discarded remove patch
@@ -22,157 +22,157 @@
 block discarded – undo
22 22
 // ##############################################################################
23 23
 class Trunk extends CI_Controller {
24 24
 	function Trunk() {
25
-		parent::__construct ();
25
+		parent::__construct();
26 26
 		
27
-		$this->load->helper ( 'template_inheritance' );
27
+		$this->load->helper('template_inheritance');
28 28
 		
29
-		$this->load->library ( 'session' );
30
-		$this->load->library ( "trunk_form" );
31
-		$this->load->library ( 'astpp/form' );
32
-		$this->load->model ( 'trunk_model' );
29
+		$this->load->library('session');
30
+		$this->load->library("trunk_form");
31
+		$this->load->library('astpp/form');
32
+		$this->load->model('trunk_model');
33 33
 		
34
-		if ($this->session->userdata ( 'user_login' ) == FALSE)
35
-			redirect ( base_url () . '/astpp/login' );
34
+		if ($this->session->userdata('user_login') == FALSE)
35
+			redirect(base_url().'/astpp/login');
36 36
 	}
37 37
 	function trunk_list() {
38
-		$data ['username'] = $this->session->userdata ( 'user_name' );
39
-		$data ['page_title'] = gettext ( 'Trunks' );
38
+		$data ['username'] = $this->session->userdata('user_name');
39
+		$data ['page_title'] = gettext('Trunks');
40 40
 		$data ['search_flag'] = true;
41
-		$this->session->set_userdata ( 'advance_search', 0 );
42
-		$data ['grid_fields'] = $this->trunk_form->build_trunk_list_for_admin ();
43
-		$data ["grid_buttons"] = $this->trunk_form->build_grid_buttons ();
44
-		$data ['form_search'] = $this->form->build_serach_form ( $this->trunk_form->get_trunk_search_form () );
45
-		$this->load->view ( 'view_trunk_list', $data );
41
+		$this->session->set_userdata('advance_search', 0);
42
+		$data ['grid_fields'] = $this->trunk_form->build_trunk_list_for_admin();
43
+		$data ["grid_buttons"] = $this->trunk_form->build_grid_buttons();
44
+		$data ['form_search'] = $this->form->build_serach_form($this->trunk_form->get_trunk_search_form());
45
+		$this->load->view('view_trunk_list', $data);
46 46
 	}
47 47
 	function trunk_list_json() {
48
-		$json_data = array ();
49
-		$count_all = $this->trunk_model->gettrunk_list ( false );
50
-		$paging_data = $this->form->load_grid_config ( $count_all, $_GET ['rp'], $_GET ['page'] );
48
+		$json_data = array();
49
+		$count_all = $this->trunk_model->gettrunk_list(false);
50
+		$paging_data = $this->form->load_grid_config($count_all, $_GET ['rp'], $_GET ['page']);
51 51
 		$json_data = $paging_data ["json_paging"];
52
-		$query = $this->trunk_model->gettrunk_list ( true, $paging_data ["paging"] ["start"], $paging_data ["paging"] ["page_no"] );
53
-		$grid_fields = json_decode ( $this->trunk_form->build_trunk_list_for_admin () );
54
-		$json_data ['rows'] = $this->form->build_grid ( $query, $grid_fields );
55
-		echo json_encode ( $json_data );
52
+		$query = $this->trunk_model->gettrunk_list(true, $paging_data ["paging"] ["start"], $paging_data ["paging"] ["page_no"]);
53
+		$grid_fields = json_decode($this->trunk_form->build_trunk_list_for_admin());
54
+		$json_data ['rows'] = $this->form->build_grid($query, $grid_fields);
55
+		echo json_encode($json_data);
56 56
 	}
57 57
 	function trunk_add($type = "") {
58
-		$data ['username'] = $this->session->userdata ( 'user_name' );
58
+		$data ['username'] = $this->session->userdata('user_name');
59 59
 		$data ['flag'] = 'create';
60
-		$data ['page_title'] = gettext ( 'Create Trunk' );
61
-		$data ['form'] = $this->form->build_form ( $this->trunk_form->get_trunk_form_fields (), '' );
62
-		$this->load->view ( 'view_trunk_add_edit', $data );
60
+		$data ['page_title'] = gettext('Create Trunk');
61
+		$data ['form'] = $this->form->build_form($this->trunk_form->get_trunk_form_fields(), '');
62
+		$this->load->view('view_trunk_add_edit', $data);
63 63
 	}
64 64
 	function trunk_edit($edit_id = '') {
65
-		$data ['page_title'] = gettext ( 'Edit Trunk' );
66
-		$where = array (
65
+		$data ['page_title'] = gettext('Edit Trunk');
66
+		$where = array(
67 67
 				'id' => $edit_id 
68 68
 		);
69
-		$account = $this->db_model->getSelect ( "*", "trunks", $where );
70
-		foreach ( $account->result_array () as $key => $value ) {
69
+		$account = $this->db_model->getSelect("*", "trunks", $where);
70
+		foreach ($account->result_array() as $key => $value) {
71 71
 			$edit_data = $value;
72 72
 		}
73
-		$edit_data ["resellers_id"] = explode ( ",", $edit_data ["resellers_id"] );
74
-		$data ['form'] = $this->form->build_form ( $this->trunk_form->get_trunk_form_fields (), $edit_data );
75
-		$this->load->view ( 'view_trunk_add_edit', $data );
73
+		$edit_data ["resellers_id"] = explode(",", $edit_data ["resellers_id"]);
74
+		$data ['form'] = $this->form->build_form($this->trunk_form->get_trunk_form_fields(), $edit_data);
75
+		$this->load->view('view_trunk_add_edit', $data);
76 76
 	}
77 77
 	function trunk_save() {
78
-		$add_array = $this->input->post ();
79
-		$data ['form'] = $this->form->build_form ( $this->trunk_form->get_trunk_form_fields (), $add_array );
78
+		$add_array = $this->input->post();
79
+		$data ['form'] = $this->form->build_form($this->trunk_form->get_trunk_form_fields(), $add_array);
80 80
 		if ($add_array ['id'] != '') {
81
-			$data ['page_title'] = gettext ( 'Edit Trunk Rates' );
82
-			if ($this->form_validation->run () == FALSE) {
83
-				$data ['validation_errors'] = validation_errors ();
81
+			$data ['page_title'] = gettext('Edit Trunk Rates');
82
+			if ($this->form_validation->run() == FALSE) {
83
+				$data ['validation_errors'] = validation_errors();
84 84
 				echo $data ['validation_errors'];
85 85
 				exit ();
86 86
 			} else {
87
-				$this->trunk_model->edit_trunk ( $add_array, $add_array ['id'] );
88
-				echo json_encode ( array (
89
-						"SUCCESS" => $add_array ["name"] . " Trunk updated successfully!" 
90
-				) );
87
+				$this->trunk_model->edit_trunk($add_array, $add_array ['id']);
88
+				echo json_encode(array(
89
+						"SUCCESS" => $add_array ["name"]." Trunk updated successfully!" 
90
+				));
91 91
 				exit ();
92 92
 			}
93 93
 		} else {
94
-			$data ['page_title'] = gettext ( 'Termination Details' );
95
-			if ($this->form_validation->run () == FALSE) {
96
-				$data ['validation_errors'] = validation_errors ();
94
+			$data ['page_title'] = gettext('Termination Details');
95
+			if ($this->form_validation->run() == FALSE) {
96
+				$data ['validation_errors'] = validation_errors();
97 97
 				echo $data ['validation_errors'];
98 98
 				exit ();
99 99
 			} else {
100
-				$this->trunk_model->add_trunk ( $add_array );
101
-				echo json_encode ( array (
102
-						"SUCCESS" => $add_array ["name"] . " Trunk added successfully!" 
103
-				) );
100
+				$this->trunk_model->add_trunk($add_array);
101
+				echo json_encode(array(
102
+						"SUCCESS" => $add_array ["name"]." Trunk added successfully!" 
103
+				));
104 104
 				exit ();
105 105
 			}
106 106
 		}
107 107
 	}
108 108
 	function trunk_list_search() {
109
-		$ajax_search = $this->input->post ( 'ajax_search', 0 );
109
+		$ajax_search = $this->input->post('ajax_search', 0);
110 110
 		
111
-		if ($this->input->post ( 'advance_search', TRUE ) == 1) {
112
-			$this->session->set_userdata ( 'advance_search', $this->input->post ( 'advance_search' ) );
113
-			$action = $this->input->post ();
114
-			unset ( $action ['action'] );
115
-			unset ( $action ['advance_search'] );
116
-			$this->session->set_userdata ( 'trunk_list_search', $action );
111
+		if ($this->input->post('advance_search', TRUE) == 1) {
112
+			$this->session->set_userdata('advance_search', $this->input->post('advance_search'));
113
+			$action = $this->input->post();
114
+			unset ($action ['action']);
115
+			unset ($action ['advance_search']);
116
+			$this->session->set_userdata('trunk_list_search', $action);
117 117
 		}
118 118
 		if (@$ajax_search != 1) {
119
-			redirect ( base_url () . 'trunk/trunk_list/' );
119
+			redirect(base_url().'trunk/trunk_list/');
120 120
 		}
121 121
 	}
122 122
 	function trunk_list_clearsearchfilter() {
123
-		$this->session->set_userdata ( 'advance_search', 0 );
124
-		$this->session->set_userdata ( 'account_search', "" );
123
+		$this->session->set_userdata('advance_search', 0);
124
+		$this->session->set_userdata('account_search', "");
125 125
 	}
126 126
 	function trunk_remove($id) {
127
-		$this->trunk_model->remove_trunk ( $id );
128
-		$this->db->delete ( "routing", array (
127
+		$this->trunk_model->remove_trunk($id);
128
+		$this->db->delete("routing", array(
129 129
 				"trunk_id" => $id 
130
-		) );
131
-		$this->session->set_flashdata ( 'astpp_notification', 'Trunk removed successfully!' );
132
-		redirect ( base_url () . 'trunk/trunk_list/' );
130
+		));
131
+		$this->session->set_flashdata('astpp_notification', 'Trunk removed successfully!');
132
+		redirect(base_url().'trunk/trunk_list/');
133 133
 	}
134 134
 	function trunk_delete_multiple() {
135
-		$add_array = $this->input->post ();
136
-		$where = 'IN (' . $add_array ['selected_ids'] . ')';
137
-		if (isset ( $add_array ['flag'] )) {
138
-			$update_data = array (
135
+		$add_array = $this->input->post();
136
+		$where = 'IN ('.$add_array ['selected_ids'].')';
137
+		if (isset ($add_array ['flag'])) {
138
+			$update_data = array(
139 139
 					'status' => '2' 
140 140
 			);
141
-			$this->db->where ( 'trunk_id ' . $where );
142
-			$this->db->delete ( 'outbound_routes' );
143
-			$this->db->where ( 'id ' . $where );
144
-			$this->db->update ( 'trunks', $update_data );
141
+			$this->db->where('trunk_id '.$where);
142
+			$this->db->delete('outbound_routes');
143
+			$this->db->where('id '.$where);
144
+			$this->db->update('trunks', $update_data);
145 145
 			echo TRUE;
146 146
 		} else {
147
-			$trunk_arr = array ();
148
-			$this->db->select ( 'id,name' );
149
-			$this->db->where ( 'id ' . $where );
150
-			$trunk_res = $this->db->get ( 'trunks' );
151
-			$trunk_res = $trunk_res->result_array ();
152
-			foreach ( $trunk_res as $value ) {
147
+			$trunk_arr = array();
148
+			$this->db->select('id,name');
149
+			$this->db->where('id '.$where);
150
+			$trunk_res = $this->db->get('trunks');
151
+			$trunk_res = $trunk_res->result_array();
152
+			foreach ($trunk_res as $value) {
153 153
 				$trunk_arr [$value ['id']] ['name'] = $value ['name'];
154 154
 			}
155
-			$this->db->where ( 'trunk_id ' . $where );
156
-			$this->db->select ( 'count(id) as cnt,trunk_id' );
157
-			$this->db->group_by ( 'trunk_id' );
158
-			$outbound_routes_res = $this->db->get ( 'outbound_routes' );
159
-			if ($outbound_routes_res->num_rows () > 0) {
160
-				$outbound_routes_res = $outbound_routes_res->result_array ();
161
-				foreach ( $outbound_routes_res as $key => $value ) {
155
+			$this->db->where('trunk_id '.$where);
156
+			$this->db->select('count(id) as cnt,trunk_id');
157
+			$this->db->group_by('trunk_id');
158
+			$outbound_routes_res = $this->db->get('outbound_routes');
159
+			if ($outbound_routes_res->num_rows() > 0) {
160
+				$outbound_routes_res = $outbound_routes_res->result_array();
161
+				foreach ($outbound_routes_res as $key => $value) {
162 162
 					$trunk_arr [$value ['trunk_id']] ['outbound_routes'] = $value ['cnt'];
163 163
 				}
164 164
 			}
165 165
 			$str = null;
166
-			foreach ( $trunk_arr as $key => $value ) {
167
-				if (isset ( $value ['outbound_routes'] )) {
168
-					$str .= $value ['name'] . "trunk using by " . $value ['outbound_routes'] . " termination rates \n";
166
+			foreach ($trunk_arr as $key => $value) {
167
+				if (isset ($value ['outbound_routes'])) {
168
+					$str .= $value ['name']."trunk using by ".$value ['outbound_routes']." termination rates \n";
169 169
 				}
170 170
 			}
171
-			if (! empty ( $str )) {
171
+			if ( ! empty ($str)) {
172 172
 				$data ['str'] = $str;
173 173
 			}
174 174
 			$data ['selected_ids'] = $add_array ['selected_ids'];
175
-			echo json_encode ( $data );
175
+			echo json_encode($data);
176 176
 		}
177 177
 	}
178 178
 }
Please login to merge, or discard this patch.
Braces   +3 added lines, -2 removed lines patch added patch discarded remove patch
@@ -31,8 +31,9 @@
 block discarded – undo
31 31
 		$this->load->library ( 'astpp/form' );
32 32
 		$this->load->model ( 'trunk_model' );
33 33
 		
34
-		if ($this->session->userdata ( 'user_login' ) == FALSE)
35
-			redirect ( base_url () . '/astpp/login' );
34
+		if ($this->session->userdata ( 'user_login' ) == FALSE) {
35
+					redirect ( base_url () . '/astpp/login' );
36
+		}
36 37
 	}
37 38
 	function trunk_list() {
38 39
 		$data ['username'] = $this->session->userdata ( 'user_name' );
Please login to merge, or discard this patch.